From 080b406eb9c6e78ce2d3c86afed75a97aead87f8 Mon Sep 17 00:00:00 2001 From: saltyaom Date: Fri, 15 Dec 2023 22:41:53 +0700 Subject: [PATCH] :tada: feat: 0.8 --- CHANGELOG.md | 5 ++ bun.lockb | Bin 64811 -> 55671 bytes example/index.tsx | 20 +++++-- example/simple.tsx | 13 +++- package.json | 144 ++++++++++++++++++++++----------------------- src/handler.ts | 3 +- src/html.ts | 2 + src/utils.ts | 3 +- 8 files changed, 105 insertions(+), 85 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 954725d..0532eab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ + +# 0.8.0-rc.0 - 15 Dec 2023 +Change: +- Add support for Elysia 0.8 + # 0.7.1 - 8 Oct 2023 Improvement: - [#19](https://github.com/elysiajs/elysia-html/pull/20) Update to Kita HTML v3 diff --git a/bun.lockb b/bun.lockb index 8b37b05d1c0ae1df8dd2b05b99eee7bb1941e969..1a0618ee8bc578fd3a66fba9c1778d0f678f07ce 100755 GIT binary patch delta 12722 zcmeHtXINC%7WO#F2-cvX!0z3ZGg`Mmebz0dRgzx&~xb>6-AS$plZ*4by+vv)R_ zyx3>5$lEieBJlO>Cn=lz^>Pb$-)-Soe)P|)y|#26GS6UHy3CpE9)2T8Wl2RsOZPL2 zWg>rC2|{@?E}KF|Kw3Z!tXSWy?5QXSjX_F%gY&rSeIx%;C3kW#k>w%qX6UyI(h~A3 z^s|LL18EJJUX+@WlaiL6nv-3U4Ly%c1wn)Q4r;l738a?$L-OFoMLF4{1ffhw%}U7` zgB$W12?AT0l~UxDk&}{Hn4Mdgk|7A0Ir-=(2s_MVMY-8|*##*@MQU?-fZ3?$fsTT+ zAvPeaXR5J&JGc$_Do8d!F-)FdnNY6GP?@Vzt6l+6IpS4v~x%sLAHV%UF21olA9x>6lNBr6c(kw z#LYah>>{tsGWKqOgM8yJXyBP;XXfP>Vk-B+*|i*kl$;`A1hR+u4P(EI?7TFuk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B!h=E>lw7^O$stgA;v>#RFKrd2L*2pM61&-)x1SA++2QY?Gj``A{?2 z*ZT}N#^{Uu7gCQ;C7;;$TU6}DmYFPJr!%{^RnFR-b!5?7Tj4iPMTeZ({jKJl$NZlf zvqoiBYyqkcmg$xEE9;`iZd|aX_M8Wsu(h)e?k?racSdk*L8T*;?pCm>%g(H7moJ-s z*oyVvEibRweNc~cV`KIgmbX0+-vHg54m+`}M|*G{+mFo=vll0w%gat&KY)SFd^)Q|&iZ(CxuBci7lr*$G+6s&ti0 zPF7k9&i-e!iQ8;hzk_y0?o>TGGds~`G}`du>O(fH=x0Yu*g<=w#v;1H5MKNcTaQW{ z{!oSbe^T$_&YquaOg8h=a64^=AEFf%FIw@`TUTx2go^WLDmlS5a1p5)54KesA7k5vVP+`YXue8Cp9*h46Gz1W| diff --git a/example/index.tsx b/example/index.tsx index 3099b53..94e0661 100644 --- a/example/index.tsx +++ b/example/index.tsx @@ -58,12 +58,20 @@ const indexSchema = { }) } -new Elysia() +const app = new Elysia() // https://elysiajs.com/plugins/html.html#options - .use(html()) - .get('/', ({ query }) => page(query), indexSchema) - .get('/tsx', ({ query }) => , indexSchema) - .get('/async', ({ query, stream }) => stream(, query), indexSchema) + .use(html({ + autoDetect: true + })) + .get('/', ({ html }) => html('

Hello World!

') + ) + // .get('/', ({ query }) => page(query), indexSchema) + // .get('/tsx', ({ query }) => , indexSchema) + // .get('/async', ({ query, stream }) => stream(, query), indexSchema) .listen(8080, () => console.log('Listening on http://localhost:8080')) - \ No newline at end of file +app.handle(new Request('http://localhost:8080/')) + .then((x) => x.text()) + .then(console.log) + +console.log(app.routes[0]?.composed?.toString()) diff --git a/example/simple.tsx b/example/simple.tsx index dc5b982..78ebc4f 100644 --- a/example/simple.tsx +++ b/example/simple.tsx @@ -1,6 +1,13 @@ import { Elysia } from 'elysia' import { html } from '../src' -new Elysia() - .use(html()) - .get('/0.7', () =>

Hello World

) +const app = new Elysia() + .use(html({ autoDetect: true })) + .get('/a', ({ html }) => html(`

Hello World

`)) + .compile() + +console.log(app.routes[0]?.composed?.toString()) + +app.handle(new Request('http://localhost:8080/a')) + .then((x) => x.text()) + .then(console.log) diff --git a/package.json b/package.json index 33da598..b6f97e4 100644 --- a/package.json +++ b/package.json @@ -1,78 +1,78 @@ { - "name": "@elysiajs/html", - "version": "0.8.0-rc.1", - "description": "Plugin for Elysia that add support for returning html", - "author": { - "name": "saltyAom", - "url": "https://github.com/SaltyAom", - "email": "saltyaom@gmail.com" + "name": "@elysiajs/html", + "version": "0.8.0-rc.0", + "description": "Plugin for Elysia that add support for returning html", + "author": { + "name": "saltyAom", + "url": "https://github.com/SaltyAom", + "email": "saltyaom@gmail.com" + }, + "main": "./dist/index.js", + "exports": { + ".": { + "bun": "./dist/index.js", + "node": "./dist/cjs/index.js", + "require": "./dist/cjs/index.js", + "import": "./dist/index.js", + "default": "./dist/index.js" }, - "main": "./dist/index.js", - "exports": { - ".": { - "bun": "./dist/index.js", - "node": "./dist/cjs/index.js", - "require": "./dist/cjs/index.js", - "import": "./dist/index.js", - "default": "./dist/index.js" - }, - "./htmx": { - "bun": "./dist/html.js", - "node": "./dist/cjs/htmx.js", - "require": "./dist/cjs/htmx.js", - "import": "./dist/htmx.js", - "default": "./dist/htmx.js" - }, - "./hotwire": { - "bun": "./dist/hotwire.js", - "node": "./dist/cjs/hotwire.js", - "require": "./dist/cjs/hotwire.js", - "import": "./dist/hotwire.js", - "default": "./dist/hotwire.js" - } + "./htmx": { + "bun": "./dist/html.js", + "node": "./dist/cjs/htmx.js", + "require": "./dist/cjs/htmx.js", + "import": "./dist/htmx.js", + "default": "./dist/htmx.js" }, - "types": "./src/index.ts", - "keywords": [ - "elysia", - "html" - ], - "homepage": "https://github.com/elysiajs/elysia-html", - "repository": { - "type": "git", - "url": "https://github.com/elysiajs/elysia-html" - }, - "bugs": "https://github.com/elysiajs/elysia-html/issues", - "license": "MIT", - "scripts": { - "dev": "bun run --watch example/index.tsx", - "test": "bun test && npm run test:node", - "test:node": "npm install --prefix ./test/node/cjs/ && npm install --prefix ./test/node/esm/ && node ./test/node/cjs/index.js && node ./test/node/esm/index.js", - "build": "rimraf dist && tsc --project tsconfig.esm.json && tsc --project tsconfig.cjs.json", - "release": "npm run build && npm run test && npm publish --access public", - "format": "prettier --write ." - }, - "peerDependencies": { - "elysia": ">= 0.8.0-rc.0" - }, - "devDependencies": { - "@elysiajs/stream": "^0.7.2", - "@types/node": "^20.7.2", - "bun-types": "^1.0.3", - "elysia": "0.8.0-rc.0", - "eslint": "^8.50.0", - "rimraf": "^5.0.5", - "typescript": "^5.2.2" - }, - "dependencies": { - "@kitajs/html": "^3.0.2", - "@kitajs/ts-html-plugin": "^1.2.0" + "./hotwire": { + "bun": "./dist/hotwire.js", + "node": "./dist/cjs/hotwire.js", + "require": "./dist/cjs/hotwire.js", + "import": "./dist/hotwire.js", + "default": "./dist/hotwire.js" + } + }, + "types": "./src/index.ts", + "keywords": [ + "elysia", + "html" + ], + "homepage": "https://github.com/elysiajs/elysia-html", + "repository": { + "type": "git", + "url": "https://github.com/elysiajs/elysia-html" + }, + "bugs": "https://github.com/elysiajs/elysia-html/issues", + "license": "MIT", + "scripts": { + "dev": "bun run --watch example/index.tsx", + "test": "bun test && npm run test:node", + "test:node": "npm install --prefix ./test/node/cjs/ && npm install --prefix ./test/node/esm/ && node ./test/node/cjs/index.js && node ./test/node/esm/index.js", + "build": "rimraf dist && tsc --project tsconfig.esm.json && tsc --project tsconfig.cjs.json", + "release": "npm run build && npm run test && npm publish --access public", + "format": "prettier --write ." + }, + "peerDependencies": { + "elysia": ">= 0.8.0-rc.0" + }, + "devDependencies": { + "@elysiajs/stream": "^0.7.2", + "@types/node": "^20.7.2", + "bun-types": "^1.0.3", + "elysia": "0.8.0-rc.2", + "eslint": "^8.50.0", + "rimraf": "^5.0.5", + "typescript": "^5.2.2" + }, + "dependencies": { + "@kitajs/html": "^3.0.2", + "@kitajs/ts-html-plugin": "^1.2.0" + }, + "peerDependenciesMeta": { + "@kitajs/html": { + "optional": true }, - "peerDependenciesMeta": { - "@kitajs/html": { - "optional": true - }, - "@kitajs/ts-html-plugin": { - "optional": true - } + "@kitajs/ts-html-plugin": { + "optional": true } + } } \ No newline at end of file diff --git a/src/handler.ts b/src/handler.ts index 5137caa..e29419c 100644 --- a/src/handler.ts +++ b/src/handler.ts @@ -19,9 +19,8 @@ export function handleHtml( isHtml(value) && // Avoids double adding !doctype or adding to non root html tags. isTagHtml(value) - ) { + ) value = '' + value - } return new Response( value, diff --git a/src/html.ts b/src/html.ts index e9ef031..a7bcd09 100644 --- a/src/html.ts +++ b/src/html.ts @@ -57,6 +57,8 @@ export function html(options: HtmlOptions = {}) { if (response instanceof Response) return response + set.headers['content-type'] = options.contentType! + return new Response(response) } diff --git a/src/utils.ts b/src/utils.ts index 74e2dfc..32f3455 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -5,9 +5,8 @@ * @see https://stackoverflow.com/q/11229831 */ export function isHtml(this: void, value?: any): value is string { - if (typeof value !== 'string') { + if (typeof value !== 'string') return false - } value = value.trim() const length = value.length