Skip to content

Commit 461ec7d

Browse files
committed
🎉 feat: kita
1 parent 18a186c commit 461ec7d

File tree

7 files changed

+30
-12
lines changed

7 files changed

+30
-12
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 0.6.3 - 8 Sep 2023
2+
Improvement:
3+
- Switch to Kita
4+
- Add support for Fragment
5+
- Remove unused library
6+
17
# 0.6.2 - 8 Sep 2023
28
Improvement:
39
- Add support for custom element

bun.lockb

-5.37 KB
Binary file not shown.

example/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,9 @@ const app = new Elysia()
2727
.get('/', () => page)
2828
.get('/jsx', () => jsx)
2929
.get('/html', ({ html }) => html(page))
30+
.get('/a', () => {
31+
<>
32+
<h1>Hello World</h1>
33+
</>
34+
})
3035
.listen(8080)

package.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,16 @@
3838
"elysia": ">= 0.6.0"
3939
},
4040
"devDependencies": {
41+
"@types/dompurify": "^3.0.2",
4142
"@types/node": "^20.5.9",
42-
"@types/react": "^18.2.21",
4343
"bun-types": "^0.8.1",
4444
"elysia": "0.6.19",
4545
"eslint": "^8.48.0",
46-
"hono": "^3.5.8",
4746
"rimraf": "4.3.1",
4847
"typescript": "^5.2.2"
4948
},
5049
"dependencies": {
51-
"@types/sanitize-html": "^2.9.0",
52-
"react": "^18.2.0",
53-
"sanitize-html": "^2.11.0",
54-
"typed-html": "^3.0.1"
50+
"@kitajs/html": "^1.4.6",
51+
"dompurify": "^3.0.5"
5552
}
5653
}

src/declaration.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
// @ts-ignore
2-
const { createElement } = require('typed-html')
2+
const { compile, Fragment } = require('@kitajs/html')
33

44
// @ts-ignore
5-
globalThis.ElysiaJSX = createElement
5+
globalThis.ElysiaJSX = compile
6+
// @ts-ignore
7+
globalThis.ElysiaJSX.Fragment = Fragment
68

79
declare function ElysiaJSX(...params: any[]): string
810

@@ -13,7 +15,11 @@ declare namespace JSX {
1315
// @ts-ignore
1416
type BaseHTMLTag = Record<string, unknown>
1517

18+
// @ts-ignore
19+
type BaseIntrinsicElements = Record<string, HtmlTag>
20+
1621
interface HtmlTag extends BaseHTMLTag {
22+
safe?: boolean
1723
accesskey?: string
1824
class?: string
1925
contenteditable?: string
@@ -29,6 +35,7 @@ declare namespace JSX {
2935
title?: string
3036
translate?: string | boolean
3137
}
38+
3239
interface HtmlAnchorTag extends HtmlTag {
3340
href?: string
3441
target?: string
@@ -347,8 +354,7 @@ declare namespace JSX {
347354
height?: string
348355
}
349356

350-
interface IntrinsicElements {
351-
[customElement: string]: HtmlTag
357+
interface IntrinsicElements extends BaseIntrinsicElements {
352358
a: HtmlAnchorTag
353359
abbr: HtmlTag
354360
address: HtmlTag

src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
/// <reference path="./declaration.ts" />
22
import { Elysia } from 'elysia'
3-
import sanitize from 'sanitize-html'
3+
import * as D from 'dompurify'
4+
5+
const sanitize = D.sanitize
6+
7+
const { compile } = require('@kitajs/html')
48

59
import './declaration'
610

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
1818
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
1919
"jsxFactory": "ElysiaJSX", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
20-
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
20+
"jsxFragmentFactory": "ElysiaJSX.Fragment", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
2121
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
2222
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
2323
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */

0 commit comments

Comments
 (0)