@bromscandium/runtime 1.0.0 → 1.0.2
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 +20 -20
- package/README.md +91 -91
- package/package.json +49 -49
- package/src/index.ts +56 -56
- package/src/jsx-runtime.ts +132 -132
- package/src/jsx.d.ts +373 -373
- package/src/lifecycle.ts +133 -133
- package/src/renderer.ts +655 -655
- package/src/vnode.ts +159 -159
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 bromscandium
|
|
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
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 bromscandium
|
|
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
21
|
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
# @bromscandium/runtime
|
|
2
|
-
|
|
3
|
-
JSX runtime, virtual DOM renderer, and hooks for BromiumJS.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install @bromscandium/runtime
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Usage
|
|
12
|
-
|
|
13
|
-
```tsx
|
|
14
|
-
import { createApp, h, Fragment } from '@bromscandium/runtime';
|
|
15
|
-
import { ref } from '@bromscandium/core';
|
|
16
|
-
|
|
17
|
-
function Counter() {
|
|
18
|
-
const count = ref(0);
|
|
19
|
-
|
|
20
|
-
return h('div', null,
|
|
21
|
-
h('p', null, `Count: ${count.value}`),
|
|
22
|
-
h('button', { onClick: () => count.value++ }, 'Increment')
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
createApp(Counter).mount('#app');
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
### With JSX
|
|
30
|
-
|
|
31
|
-
Configure your bundler to use `@bromscandium/runtime` as the JSX import source:
|
|
32
|
-
|
|
33
|
-
```json
|
|
34
|
-
{
|
|
35
|
-
"compilerOptions": {
|
|
36
|
-
"jsx": "react-jsx",
|
|
37
|
-
"jsxImportSource": "@bromscandium/runtime"
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
```tsx
|
|
43
|
-
function Counter() {
|
|
44
|
-
const count = ref(0);
|
|
45
|
-
|
|
46
|
-
return (
|
|
47
|
-
<div>
|
|
48
|
-
<p>Count: {count.value}</p>
|
|
49
|
-
<button onClick={() => count.value++}>Increment</button>
|
|
50
|
-
</div>
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
### Hooks
|
|
56
|
-
|
|
57
|
-
```tsx
|
|
58
|
-
import { useState, useRef, useMemo, useCallback, onMounted, onUnmounted } from '@bromscandium/runtime';
|
|
59
|
-
|
|
60
|
-
function Component() {
|
|
61
|
-
const count = useState(0);
|
|
62
|
-
const inputRef = useRef<HTMLInputElement>(null);
|
|
63
|
-
const doubled = useMemo(() => count.value * 2, [count.value]);
|
|
64
|
-
|
|
65
|
-
onMounted(() => console.log('Mounted'));
|
|
66
|
-
onUnmounted(() => console.log('Unmounted'));
|
|
67
|
-
|
|
68
|
-
return <div>{doubled}</div>;
|
|
69
|
-
}
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
## API
|
|
73
|
-
|
|
74
|
-
| Export | Description |
|
|
75
|
-
|--------|-------------|
|
|
76
|
-
| `createApp(component)` | Create application instance |
|
|
77
|
-
| `render(vnode, container)` | Render VNode to DOM |
|
|
78
|
-
| `h(type, props, children)` | Create VNode (hyperscript) |
|
|
79
|
-
| `jsx`, `jsxs`, `jsxDEV` | JSX runtime functions |
|
|
80
|
-
| `Fragment` | Fragment component |
|
|
81
|
-
| `useState(initial)` | State hook (returns Ref) |
|
|
82
|
-
| `useRef(initial)` | Mutable ref hook |
|
|
83
|
-
| `useMemo(factory, deps)` | Memoized value hook |
|
|
84
|
-
| `useCallback(fn, deps)` | Memoized callback hook |
|
|
85
|
-
| `onMounted(callback)` | Mount lifecycle hook |
|
|
86
|
-
| `onUpdated(callback)` | Update lifecycle hook |
|
|
87
|
-
| `onUnmounted(callback)` | Unmount lifecycle hook |
|
|
88
|
-
|
|
89
|
-
## License
|
|
90
|
-
|
|
91
|
-
MIT
|
|
1
|
+
# @bromscandium/runtime
|
|
2
|
+
|
|
3
|
+
JSX runtime, virtual DOM renderer, and hooks for BromiumJS.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @bromscandium/runtime
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { createApp, h, Fragment } from '@bromscandium/runtime';
|
|
15
|
+
import { ref } from '@bromscandium/core';
|
|
16
|
+
|
|
17
|
+
function Counter() {
|
|
18
|
+
const count = ref(0);
|
|
19
|
+
|
|
20
|
+
return h('div', null,
|
|
21
|
+
h('p', null, `Count: ${count.value}`),
|
|
22
|
+
h('button', { onClick: () => count.value++ }, 'Increment')
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
createApp(Counter).mount('#app');
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### With JSX
|
|
30
|
+
|
|
31
|
+
Configure your bundler to use `@bromscandium/runtime` as the JSX import source:
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"compilerOptions": {
|
|
36
|
+
"jsx": "react-jsx",
|
|
37
|
+
"jsxImportSource": "@bromscandium/runtime"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
function Counter() {
|
|
44
|
+
const count = ref(0);
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<div>
|
|
48
|
+
<p>Count: {count.value}</p>
|
|
49
|
+
<button onClick={() => count.value++}>Increment</button>
|
|
50
|
+
</div>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Hooks
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
import { useState, useRef, useMemo, useCallback, onMounted, onUnmounted } from '@bromscandium/runtime';
|
|
59
|
+
|
|
60
|
+
function Component() {
|
|
61
|
+
const count = useState(0);
|
|
62
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
63
|
+
const doubled = useMemo(() => count.value * 2, [count.value]);
|
|
64
|
+
|
|
65
|
+
onMounted(() => console.log('Mounted'));
|
|
66
|
+
onUnmounted(() => console.log('Unmounted'));
|
|
67
|
+
|
|
68
|
+
return <div>{doubled}</div>;
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## API
|
|
73
|
+
|
|
74
|
+
| Export | Description |
|
|
75
|
+
|--------|-------------|
|
|
76
|
+
| `createApp(component)` | Create application instance |
|
|
77
|
+
| `render(vnode, container)` | Render VNode to DOM |
|
|
78
|
+
| `h(type, props, children)` | Create VNode (hyperscript) |
|
|
79
|
+
| `jsx`, `jsxs`, `jsxDEV` | JSX runtime functions |
|
|
80
|
+
| `Fragment` | Fragment component |
|
|
81
|
+
| `useState(initial)` | State hook (returns Ref) |
|
|
82
|
+
| `useRef(initial)` | Mutable ref hook |
|
|
83
|
+
| `useMemo(factory, deps)` | Memoized value hook |
|
|
84
|
+
| `useCallback(fn, deps)` | Memoized callback hook |
|
|
85
|
+
| `onMounted(callback)` | Mount lifecycle hook |
|
|
86
|
+
| `onUpdated(callback)` | Update lifecycle hook |
|
|
87
|
+
| `onUnmounted(callback)` | Unmount lifecycle hook |
|
|
88
|
+
|
|
89
|
+
## License
|
|
90
|
+
|
|
91
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@bromscandium/runtime",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "BromiumJS runtime - JSX and rendering",
|
|
5
|
-
"author": "bromscandium",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/bromscandium/bromiumjs.git",
|
|
10
|
-
"directory": "packages/runtime"
|
|
11
|
-
},
|
|
12
|
-
"homepage": "https://github.com/bromscandium/bromiumjs#readme",
|
|
13
|
-
"bugs": {
|
|
14
|
-
"url": "https://github.com/bromscandium/bromiumjs/issues"
|
|
15
|
-
},
|
|
16
|
-
"keywords": ["bromium", "bromiumjs", "jsx", "runtime", "rendering"],
|
|
17
|
-
"type": "module",
|
|
18
|
-
"main": "./dist/index.js",
|
|
19
|
-
"module": "./dist/index.js",
|
|
20
|
-
"types": "./dist/index.d.ts",
|
|
21
|
-
"exports": {
|
|
22
|
-
".": {
|
|
23
|
-
"import": "./dist/index.js",
|
|
24
|
-
"types": "./dist/index.d.ts"
|
|
25
|
-
},
|
|
26
|
-
"./jsx-runtime": {
|
|
27
|
-
"import": "./dist/jsx-runtime.js",
|
|
28
|
-
"types": "./dist/jsx-runtime.d.ts"
|
|
29
|
-
},
|
|
30
|
-
"./jsx-dev-runtime": {
|
|
31
|
-
"import": "./dist/jsx-runtime.js",
|
|
32
|
-
"types": "./dist/jsx-runtime.d.ts"
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
"files": [
|
|
36
|
-
"dist",
|
|
37
|
-
"src"
|
|
38
|
-
],
|
|
39
|
-
"scripts": {
|
|
40
|
-
"build": "tsc",
|
|
41
|
-
"dev": "tsc --watch"
|
|
42
|
-
},
|
|
43
|
-
"dependencies": {
|
|
44
|
-
"@bromscandium/core": "^1.0.0"
|
|
45
|
-
},
|
|
46
|
-
"devDependencies": {
|
|
47
|
-
"typescript": "^5.9.3"
|
|
48
|
-
}
|
|
49
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@bromscandium/runtime",
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "BromiumJS runtime - JSX and rendering",
|
|
5
|
+
"author": "bromscandium",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/bromscandium/bromiumjs.git",
|
|
10
|
+
"directory": "packages/runtime"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/bromscandium/bromiumjs#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/bromscandium/bromiumjs/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": ["bromium", "bromiumjs", "jsx", "runtime", "rendering"],
|
|
17
|
+
"type": "module",
|
|
18
|
+
"main": "./dist/index.js",
|
|
19
|
+
"module": "./dist/index.js",
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"import": "./dist/index.js",
|
|
24
|
+
"types": "./dist/index.d.ts"
|
|
25
|
+
},
|
|
26
|
+
"./jsx-runtime": {
|
|
27
|
+
"import": "./dist/jsx-runtime.js",
|
|
28
|
+
"types": "./dist/jsx-runtime.d.ts"
|
|
29
|
+
},
|
|
30
|
+
"./jsx-dev-runtime": {
|
|
31
|
+
"import": "./dist/jsx-runtime.js",
|
|
32
|
+
"types": "./dist/jsx-runtime.d.ts"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist",
|
|
37
|
+
"src"
|
|
38
|
+
],
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsc",
|
|
41
|
+
"dev": "tsc --watch"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@bromscandium/core": "^1.0.0"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"typescript": "^5.9.3"
|
|
48
|
+
}
|
|
49
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
// Runtime package exports
|
|
2
|
-
|
|
3
|
-
// Type exports from vnode
|
|
4
|
-
export type {
|
|
5
|
-
VNode,
|
|
6
|
-
VNodeChild,
|
|
7
|
-
VNodeChildren,
|
|
8
|
-
VNodeType,
|
|
9
|
-
ComponentFunction,
|
|
10
|
-
ComponentInstance,
|
|
11
|
-
} from './vnode.js';
|
|
12
|
-
|
|
13
|
-
// Value exports from vnode
|
|
14
|
-
export {
|
|
15
|
-
Fragment,
|
|
16
|
-
Text,
|
|
17
|
-
createVNode,
|
|
18
|
-
normalizeChildren,
|
|
19
|
-
createTextVNode,
|
|
20
|
-
isVNode,
|
|
21
|
-
} from './vnode.js';
|
|
22
|
-
|
|
23
|
-
// Value exports from jsx-runtime
|
|
24
|
-
export {
|
|
25
|
-
jsx,
|
|
26
|
-
jsxs,
|
|
27
|
-
jsxDEV,
|
|
28
|
-
createElement,
|
|
29
|
-
h,
|
|
30
|
-
} from './jsx-runtime.js';
|
|
31
|
-
|
|
32
|
-
// Type exports from jsx-runtime
|
|
33
|
-
export type { JSXElement } from './jsx-runtime.js';
|
|
34
|
-
|
|
35
|
-
export {
|
|
36
|
-
render,
|
|
37
|
-
createApp,
|
|
38
|
-
} from './renderer.js';
|
|
39
|
-
|
|
40
|
-
export type { AppConfig } from './renderer.js';
|
|
41
|
-
|
|
42
|
-
export {
|
|
43
|
-
onMounted,
|
|
44
|
-
onUnmounted,
|
|
45
|
-
onUpdated,
|
|
46
|
-
getCurrentInstance,
|
|
47
|
-
setCurrentInstance,
|
|
48
|
-
} from './lifecycle.js';
|
|
49
|
-
|
|
50
|
-
// Hooks for state persistence
|
|
51
|
-
export {
|
|
52
|
-
useState,
|
|
53
|
-
useRef,
|
|
54
|
-
useMemo,
|
|
55
|
-
useCallback,
|
|
56
|
-
} from './hooks.js';
|
|
1
|
+
// Runtime package exports
|
|
2
|
+
|
|
3
|
+
// Type exports from vnode
|
|
4
|
+
export type {
|
|
5
|
+
VNode,
|
|
6
|
+
VNodeChild,
|
|
7
|
+
VNodeChildren,
|
|
8
|
+
VNodeType,
|
|
9
|
+
ComponentFunction,
|
|
10
|
+
ComponentInstance,
|
|
11
|
+
} from './vnode.js';
|
|
12
|
+
|
|
13
|
+
// Value exports from vnode
|
|
14
|
+
export {
|
|
15
|
+
Fragment,
|
|
16
|
+
Text,
|
|
17
|
+
createVNode,
|
|
18
|
+
normalizeChildren,
|
|
19
|
+
createTextVNode,
|
|
20
|
+
isVNode,
|
|
21
|
+
} from './vnode.js';
|
|
22
|
+
|
|
23
|
+
// Value exports from jsx-runtime
|
|
24
|
+
export {
|
|
25
|
+
jsx,
|
|
26
|
+
jsxs,
|
|
27
|
+
jsxDEV,
|
|
28
|
+
createElement,
|
|
29
|
+
h,
|
|
30
|
+
} from './jsx-runtime.js';
|
|
31
|
+
|
|
32
|
+
// Type exports from jsx-runtime
|
|
33
|
+
export type { JSXElement } from './jsx-runtime.js';
|
|
34
|
+
|
|
35
|
+
export {
|
|
36
|
+
render,
|
|
37
|
+
createApp,
|
|
38
|
+
} from './renderer.js';
|
|
39
|
+
|
|
40
|
+
export type { AppConfig } from './renderer.js';
|
|
41
|
+
|
|
42
|
+
export {
|
|
43
|
+
onMounted,
|
|
44
|
+
onUnmounted,
|
|
45
|
+
onUpdated,
|
|
46
|
+
getCurrentInstance,
|
|
47
|
+
setCurrentInstance,
|
|
48
|
+
} from './lifecycle.js';
|
|
49
|
+
|
|
50
|
+
// Hooks for state persistence
|
|
51
|
+
export {
|
|
52
|
+
useState,
|
|
53
|
+
useRef,
|
|
54
|
+
useMemo,
|
|
55
|
+
useCallback,
|
|
56
|
+
} from './hooks.js';
|