@react5/dom-jsx 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +41 -0
- package/dist/jsx-dev-runtime.d.ts +1 -0
- package/dist/jsx-dev-runtime.js +1 -0
- package/dist/jsx-runtime.d.ts +54 -0
- package/dist/jsx-runtime.js +1 -0
- package/package.json +48 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 react5com
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# @react5/dom-jsx
|
|
2
|
+
|
|
3
|
+
A small, dependency-free JSX runtime for vanilla TypeScript and JavaScript DOM projects.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install @react5/dom-jsx
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
For TypeScript automatic JSX, set these compiler options:
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
15
|
+
"compilerOptions": {
|
|
16
|
+
"jsx": "react-jsx",
|
|
17
|
+
"jsxImportSource": "@react5/dom-jsx"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The runtime also works with Vite. Vite discovers the package's ESM `jsx-runtime` and `jsx-dev-runtime` exports automatically when compiling TSX.
|
|
23
|
+
|
|
24
|
+
## Runtime behavior
|
|
25
|
+
|
|
26
|
+
Intrinsic JSX tags become DOM elements. `class` sets `className`, `style` accepts a style object, DOM properties are assigned when available, boolean attributes use presence semantics, and `onClick`-style function props become event listeners. Text, nested nodes, arrays, fragments, and function components are supported; `null`, `undefined`, and boolean children are ignored.
|
|
27
|
+
|
|
28
|
+
The public entry points are:
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { jsx, jsxs, Fragment } from '@react5/dom-jsx/jsx-runtime'
|
|
32
|
+
import { jsx, jsxs, jsxDEV, Fragment } from '@react5/dom-jsx/jsx-dev-runtime'
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Development
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
npm test # Run Vitest in jsdom
|
|
39
|
+
npm run typecheck
|
|
40
|
+
npm run build # Build JavaScript and declarations into dist/
|
|
41
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { jsx, jsxs, Fragment, jsx as jsxDEV } from './jsx-runtime';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Fragment as r,jsx as s,jsxs as j}from"./jsx-runtime.js";export{r as Fragment,s as jsx,s as jsxDEV,j as jsxs};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export type Child = Node | string | number | boolean | null | undefined | Child[];
|
|
2
|
+
export type Props = Record<string, unknown> & {
|
|
3
|
+
children?: Child | Child[];
|
|
4
|
+
};
|
|
5
|
+
export type Component<P = Props> = (props: P) => Node;
|
|
6
|
+
export type DOMEventHandler<T extends EventTarget, E extends Event> = (event: E & {
|
|
7
|
+
currentTarget: T;
|
|
8
|
+
}) => void;
|
|
9
|
+
export type EventProps<T extends HTMLElement> = {
|
|
10
|
+
onClick?: DOMEventHandler<T, MouseEvent>;
|
|
11
|
+
onInput?: DOMEventHandler<T, InputEvent>;
|
|
12
|
+
onChange?: DOMEventHandler<T, Event>;
|
|
13
|
+
onFocus?: DOMEventHandler<T, FocusEvent>;
|
|
14
|
+
onBlur?: DOMEventHandler<T, FocusEvent>;
|
|
15
|
+
onKeyDown?: DOMEventHandler<T, KeyboardEvent>;
|
|
16
|
+
onKeyUp?: DOMEventHandler<T, KeyboardEvent>;
|
|
17
|
+
};
|
|
18
|
+
export type ElementProps<T extends HTMLElement> = Partial<Omit<T, 'children' | 'style' | 'className'>> & EventProps<T> & {
|
|
19
|
+
class?: string;
|
|
20
|
+
style?: Partial<CSSStyleDeclaration>;
|
|
21
|
+
children?: unknown;
|
|
22
|
+
};
|
|
23
|
+
export declare namespace JSX {
|
|
24
|
+
type Element = Node;
|
|
25
|
+
interface IntrinsicElements {
|
|
26
|
+
div: ElementProps<HTMLDivElement>;
|
|
27
|
+
span: ElementProps<HTMLSpanElement>;
|
|
28
|
+
form: ElementProps<HTMLFormElement> & {
|
|
29
|
+
onSubmit?: DOMEventHandler<HTMLFormElement, SubmitEvent>;
|
|
30
|
+
};
|
|
31
|
+
label: ElementProps<HTMLLabelElement>;
|
|
32
|
+
input: ElementProps<HTMLInputElement>;
|
|
33
|
+
textarea: ElementProps<HTMLTextAreaElement>;
|
|
34
|
+
select: ElementProps<HTMLSelectElement>;
|
|
35
|
+
option: ElementProps<HTMLOptionElement>;
|
|
36
|
+
button: ElementProps<HTMLButtonElement>;
|
|
37
|
+
a: ElementProps<HTMLAnchorElement>;
|
|
38
|
+
h1: ElementProps<HTMLHeadingElement>;
|
|
39
|
+
h2: ElementProps<HTMLHeadingElement>;
|
|
40
|
+
h3: ElementProps<HTMLHeadingElement>;
|
|
41
|
+
p: ElementProps<HTMLParagraphElement>;
|
|
42
|
+
ul: ElementProps<HTMLUListElement>;
|
|
43
|
+
ol: ElementProps<HTMLOListElement>;
|
|
44
|
+
li: ElementProps<HTMLLIElement>;
|
|
45
|
+
section: ElementProps<HTMLElement>;
|
|
46
|
+
article: ElementProps<HTMLElement>;
|
|
47
|
+
header: ElementProps<HTMLElement>;
|
|
48
|
+
footer: ElementProps<HTMLElement>;
|
|
49
|
+
main: ElementProps<HTMLElement>;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export declare function jsx(tag: string | ((props: any) => Node), props: Props | null, _key?: string | number): Node;
|
|
53
|
+
export declare const jsxs: typeof jsx;
|
|
54
|
+
export declare function Fragment(props: Props): DocumentFragment;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e,t,n){return function(e,t){const n=t??{};if("function"==typeof e)return e(n);const r=document.createElement(e);for(const[i,c]of Object.entries(n))if("children"!==i)if(i.startsWith("on")&&"function"==typeof c)r.addEventListener(i.slice(2).toLowerCase(),c);else if("class"!==i){if("style"===i&&c&&"object"==typeof c)Object.assign(r.style,c);else if(null!=c)if(i.includes("-"))r.setAttribute(i,String(c));else if(!1!==c){if(i in r)try{r[i]=c;continue}catch{}r.setAttribute(i,!0===c?"":String(c))}}else r.className=String(c??"");return i(r,n.children),r}(e,t)}var t=e;function n(e){const t=document.createDocumentFragment();return i(t,e.children),t}function i(e,t){if(Array.isArray(t))for(const n of t)i(e,n);else t instanceof Node?e.appendChild(t):null!=t&&!1!==t&&!0!==t&&e.appendChild(document.createTextNode(String(t)))}export{n as Fragment,e as jsx,t as jsxs};
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@react5/dom-jsx",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "JSX runtime for vanilla TS/JS projects.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"JSX"
|
|
7
|
+
],
|
|
8
|
+
"homepage": "https://github.com/react5com/dom-jsx#readme",
|
|
9
|
+
"bugs": {
|
|
10
|
+
"url": "https://github.com/react5com/dom-jsx/issues"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/react5com/dom-jsx.git"
|
|
15
|
+
},
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"author": "react5.com",
|
|
18
|
+
"type": "module",
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"README.md",
|
|
22
|
+
"LICENSE"
|
|
23
|
+
],
|
|
24
|
+
"exports": {
|
|
25
|
+
"./jsx-runtime": {
|
|
26
|
+
"types": "./dist/jsx-runtime.d.ts",
|
|
27
|
+
"import": "./dist/jsx-runtime.js"
|
|
28
|
+
},
|
|
29
|
+
"./jsx-dev-runtime": {
|
|
30
|
+
"types": "./dist/jsx-dev-runtime.d.ts",
|
|
31
|
+
"import": "./dist/jsx-dev-runtime.js"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "vite build && tsc -p tsconfig.build.json",
|
|
36
|
+
"typecheck": "tsc --noEmit",
|
|
37
|
+
"test": "vitest run"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/node": "^26.6.2",
|
|
41
|
+
"esbuild": "^0.28.2",
|
|
42
|
+
"jsdom": "^30.1.0",
|
|
43
|
+
"terser": "^5.51.2",
|
|
44
|
+
"typescript": "^7.0.2",
|
|
45
|
+
"vite": "^8.3.0",
|
|
46
|
+
"vitest": "^5.0.1"
|
|
47
|
+
}
|
|
48
|
+
}
|