@fluixi/jsx 1.0.0-alpha.100
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 +123 -0
- package/dist/index.cjs +189 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +170 -0
- package/dist/lib/index.cjs +208 -0
- package/dist/lib/index.d.ts +72 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +158 -0
- package/dist/lib/index.mjs +188 -0
- package/dist/lib/jsx-dev-runtime.cjs +73 -0
- package/dist/lib/jsx-dev-runtime.d.ts +11 -0
- package/dist/lib/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/lib/jsx-dev-runtime.js +60 -0
- package/dist/lib/jsx-dev-runtime.mjs +54 -0
- package/dist/lib/jsx-runtime.cjs +138 -0
- package/dist/lib/jsx-runtime.d.ts +57 -0
- package/dist/lib/jsx-runtime.d.ts.map +1 -0
- package/dist/lib/jsx-runtime.js +164 -0
- package/dist/lib/jsx-runtime.mjs +121 -0
- package/dist/lib/jsx.d.ts +142 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -0
- package/package.json +66 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ibrahima Touré
|
|
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,123 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/fluixi/assets/main/logos/128x128.png" alt="Fluixi" width="120" height="120" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
# @fluixi/jsx
|
|
6
|
+
|
|
7
|
+
**The JSX runtime and types Fluixi compiles against.**
|
|
8
|
+
|
|
9
|
+
[](./LICENSE)
|
|
10
|
+

|
|
11
|
+
[](https://www.npmjs.com/package/@fluixi/jsx)
|
|
12
|
+

|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
This is the `jsxImportSource` for Fluixi: the `jsx`/`jsxs`/`Fragment` factories, the element
|
|
17
|
+
helpers, and the JSX type definitions that give intrinsic elements and their attributes real
|
|
18
|
+
types.
|
|
19
|
+
|
|
20
|
+
It is a small package with a narrow job. **Most Fluixi code never imports it** — the compiler
|
|
21
|
+
turns JSX into direct DOM calls, so the factories are a fallback for anything it did not
|
|
22
|
+
compile. Components, control flow, rendering and reactivity live elsewhere; see
|
|
23
|
+
[Where things actually live](#where-things-actually-live).
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pnpm add @fluixi/jsx @fluixi/dom
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Setup
|
|
32
|
+
|
|
33
|
+
Point TypeScript at this package and let the Vite plugin compile:
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"compilerOptions": {
|
|
38
|
+
"jsx": "preserve",
|
|
39
|
+
"jsxImportSource": "@fluixi/jsx"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
// vite.config.ts
|
|
46
|
+
import { fluixi } from '@fluixi/vite-plugin';
|
|
47
|
+
|
|
48
|
+
export default { plugins: [fluixi()] };
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
`npm create fluixi` wires both for you.
|
|
52
|
+
|
|
53
|
+
## What it exports
|
|
54
|
+
|
|
55
|
+
| Export | Purpose |
|
|
56
|
+
| --- | --- |
|
|
57
|
+
| `jsx`, `jsxs`, `Fragment` | The automatic-runtime factories |
|
|
58
|
+
| `jsxDEV` | The development factory |
|
|
59
|
+
| `createElement`, `cloneElement`, `isValidElement` | Classic element helpers |
|
|
60
|
+
| `createRef`, `forwardRef` | Refs |
|
|
61
|
+
| `renderToString` | String rendering |
|
|
62
|
+
| `mergeProps` | Merge prop objects, keeping getters live |
|
|
63
|
+
| `delegateEvents` | Register delegated event types |
|
|
64
|
+
| `createReactiveJSX`, `jsxComponent`, `defineComponent`, `memo`, `hydrate` | Lower-level integration seams |
|
|
65
|
+
|
|
66
|
+
Types: `JSXElement`, `JSXComponent`, `JSXProps`, `RefCallback`, `RefObject`, plus the global
|
|
67
|
+
`JSX` namespace with intrinsic elements.
|
|
68
|
+
|
|
69
|
+
## Where things actually live
|
|
70
|
+
|
|
71
|
+
This package is a runtime, not a framework façade. Reaching for it directly is usually a sign
|
|
72
|
+
you want one of these instead:
|
|
73
|
+
|
|
74
|
+
| You want | Import from |
|
|
75
|
+
| --- | --- |
|
|
76
|
+
| `Show`, `For`, `Index`, `Switch`, `Match`, `Portal`, `Dynamic`, `ErrorBoundary` | `@fluixi/core` or `@fluixi/dom` |
|
|
77
|
+
| `render`, `hydrate` (app entry) | `@fluixi/core` |
|
|
78
|
+
| `signal`, `memo`, `effect`, `store` | `@fluixi/reactive` |
|
|
79
|
+
| Server rendering | `@fluixi/server`, or `@fluixi/start` for the whole thing |
|
|
80
|
+
| The JSX → DOM compile | `@fluixi/compiler`, `@fluixi/vite-plugin` |
|
|
81
|
+
|
|
82
|
+
## Typing an element
|
|
83
|
+
|
|
84
|
+
The `JSX` namespace types intrinsic elements and their attributes, so a misspelled attribute
|
|
85
|
+
or a wrong event handler is an error rather than a silent no-op:
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
const el = <input type="text" onInput={(e) => console.log(e.currentTarget.value)} />;
|
|
89
|
+
// ^ typed as InputEvent on HTMLInputElement
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Reactive attributes accept an accessor as well as a value, which is what lets the compiler
|
|
93
|
+
wire a binding without changing your types:
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
const count = $signal(0);
|
|
97
|
+
<div title={() => `count: ${count()}`} data-count={count()} />;
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Refs
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
import { createRef } from '@fluixi/jsx';
|
|
104
|
+
|
|
105
|
+
function Field() {
|
|
106
|
+
const input = createRef<HTMLInputElement>();
|
|
107
|
+
onMount(() => input.current?.focus());
|
|
108
|
+
return <input ref={input} />;
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
A callback ref works too — `ref={(el) => …}` — and both forms are typed bivariantly, so a
|
|
113
|
+
component that takes `HTMLElement` accepts a more specific ref.
|
|
114
|
+
|
|
115
|
+
## License
|
|
116
|
+
|
|
117
|
+
MIT
|
|
118
|
+
|
|
119
|
+
## Links
|
|
120
|
+
|
|
121
|
+
- [Fluixi docs](https://docs.fluixi.com)
|
|
122
|
+
- [npm](https://www.npmjs.com/package/@fluixi/jsx)
|
|
123
|
+
- [Repository](https://github.com/fluixi/core)
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/*! @fluixi/jsx v1.0.0-alpha.100 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/index.ts
|
|
22
|
+
var index_exports = {};
|
|
23
|
+
__export(index_exports, {
|
|
24
|
+
Fragment: () => Fragment,
|
|
25
|
+
cloneElement: () => cloneElement,
|
|
26
|
+
createElement: () => createElement,
|
|
27
|
+
createReactiveJSX: () => createReactiveJSX,
|
|
28
|
+
createRef: () => createRef,
|
|
29
|
+
defineComponent: () => defineComponent,
|
|
30
|
+
delegateEvents: () => import_dom3.delegateEvents,
|
|
31
|
+
forwardRef: () => forwardRef,
|
|
32
|
+
hydrate: () => hydrate,
|
|
33
|
+
isValidElement: () => isValidElement,
|
|
34
|
+
jsx: () => jsx,
|
|
35
|
+
jsxComponent: () => jsxComponent,
|
|
36
|
+
jsxDEV: () => jsxDEV,
|
|
37
|
+
jsxs: () => jsxs,
|
|
38
|
+
memo: () => memo,
|
|
39
|
+
mergeProps: () => mergeProps,
|
|
40
|
+
renderToString: () => renderToString
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(index_exports);
|
|
43
|
+
|
|
44
|
+
// src/lib/jsx-runtime.ts
|
|
45
|
+
var import_dom = require("@fluixi/dom");
|
|
46
|
+
var import_dom2 = require("@fluixi/dom");
|
|
47
|
+
var import_signal = require("@fluixi/reactive/signal");
|
|
48
|
+
var Fragment = /* @__PURE__ */ Symbol.for("fluixi.fragment");
|
|
49
|
+
var isSSR = typeof window === "undefined";
|
|
50
|
+
function normalizeChildren(children) {
|
|
51
|
+
if (children === void 0 || children === null || children === false) return null;
|
|
52
|
+
if (Array.isArray(children)) {
|
|
53
|
+
return children.map(normalizeChildren).flat();
|
|
54
|
+
}
|
|
55
|
+
return children;
|
|
56
|
+
}
|
|
57
|
+
function jsx(type, props, key) {
|
|
58
|
+
if (type == null) return null;
|
|
59
|
+
const p = props || {};
|
|
60
|
+
if (key !== void 0) p.key = key;
|
|
61
|
+
if (type === Fragment) {
|
|
62
|
+
return (0, import_signal.createMemo)(() => (0, import_dom.asComponent)(normalizeChildren(p.children)));
|
|
63
|
+
}
|
|
64
|
+
if (typeof type === "function") {
|
|
65
|
+
const { type: renderType } = (0, import_dom.checkRenderType)(type);
|
|
66
|
+
if (type.$$typeof === /* @__PURE__ */ Symbol.for("react.provider") || renderType === "provider") {
|
|
67
|
+
return type(p);
|
|
68
|
+
}
|
|
69
|
+
if (isSSR) return { type, props: p };
|
|
70
|
+
return (0, import_signal.createMemo)(() => (0, import_dom2.createComponent)(type, p), void 0, { name: "jsx component" });
|
|
71
|
+
}
|
|
72
|
+
if (typeof type === "string" && type.trim().length > 0) {
|
|
73
|
+
return createNativeElement(type, p);
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
var jsxs = jsx;
|
|
78
|
+
function createNativeElement(tag, props) {
|
|
79
|
+
if (isSSR) return { type: tag, props: props || {} };
|
|
80
|
+
return (0, import_dom2.createDynamicElement)(tag, props);
|
|
81
|
+
}
|
|
82
|
+
function createElement(type, props, ...children) {
|
|
83
|
+
const p = { ...props };
|
|
84
|
+
if (children.length > 0) p.children = children.length === 1 ? children[0] : children;
|
|
85
|
+
return jsx(type, p);
|
|
86
|
+
}
|
|
87
|
+
function isValidElement(object) {
|
|
88
|
+
return typeof object === "object" && object !== null && "type" in object;
|
|
89
|
+
}
|
|
90
|
+
function cloneElement(element, props, ...children) {
|
|
91
|
+
return jsx(element.type, {
|
|
92
|
+
...element.props,
|
|
93
|
+
...props,
|
|
94
|
+
children: children.length ? children : element.props.children
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
function createRef(initialValue) {
|
|
98
|
+
return { current: initialValue || null };
|
|
99
|
+
}
|
|
100
|
+
function mergeProps(...sources) {
|
|
101
|
+
const target = {};
|
|
102
|
+
for (const source of sources) {
|
|
103
|
+
if (!source) continue;
|
|
104
|
+
const descriptors = Object.getOwnPropertyDescriptors(source);
|
|
105
|
+
Object.defineProperties(target, descriptors);
|
|
106
|
+
}
|
|
107
|
+
return target;
|
|
108
|
+
}
|
|
109
|
+
function forwardRef(fn) {
|
|
110
|
+
return (props) => fn(props, props.ref);
|
|
111
|
+
}
|
|
112
|
+
async function renderToString(element) {
|
|
113
|
+
throw new Error("renderToString should be imported from server module");
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// src/lib/jsx-dev-runtime.ts
|
|
117
|
+
function jsxDEV(type, props, key, isStaticChildren, source, self) {
|
|
118
|
+
return jsx(type, props, key);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// src/lib/index.ts
|
|
122
|
+
var import_dom3 = require("@fluixi/dom");
|
|
123
|
+
var import_dom4 = require("@fluixi/dom");
|
|
124
|
+
var import_signal2 = require("@fluixi/reactive/signal");
|
|
125
|
+
function createReactiveJSX(config) {
|
|
126
|
+
(0, import_dom4.initializeIntegration)({
|
|
127
|
+
signalSystem: config.signalSystem
|
|
128
|
+
});
|
|
129
|
+
return {
|
|
130
|
+
jsx,
|
|
131
|
+
jsxs,
|
|
132
|
+
jsxDEV,
|
|
133
|
+
Fragment,
|
|
134
|
+
render: (element, container) => {
|
|
135
|
+
if (!container) return;
|
|
136
|
+
(0, import_signal2.batch)(() => {
|
|
137
|
+
while (container.firstChild) {
|
|
138
|
+
container.removeChild(container.firstChild);
|
|
139
|
+
}
|
|
140
|
+
if (element instanceof Node) {
|
|
141
|
+
container.appendChild(element);
|
|
142
|
+
} else if (Array.isArray(element)) {
|
|
143
|
+
element.forEach((el) => {
|
|
144
|
+
if (el instanceof Node) {
|
|
145
|
+
container.appendChild(el);
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
},
|
|
151
|
+
batch: import_signal2.batch
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
function jsxComponent(fn) {
|
|
155
|
+
return fn;
|
|
156
|
+
}
|
|
157
|
+
function defineComponent(name, fn) {
|
|
158
|
+
Object.defineProperty(fn, "name", { value: name });
|
|
159
|
+
return fn;
|
|
160
|
+
}
|
|
161
|
+
function memo(component, equals) {
|
|
162
|
+
let lastProps;
|
|
163
|
+
let lastResult;
|
|
164
|
+
return (props) => {
|
|
165
|
+
if (lastProps !== void 0) {
|
|
166
|
+
if (equals ? equals(lastProps, props) : shallowEqual(lastProps, props)) {
|
|
167
|
+
return lastResult;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
lastProps = props;
|
|
171
|
+
lastResult = component(props);
|
|
172
|
+
return lastResult;
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
function shallowEqual(a, b) {
|
|
176
|
+
if (a === b) return true;
|
|
177
|
+
if (typeof a !== "object" || typeof b !== "object") return false;
|
|
178
|
+
if (a === null || b === null) return false;
|
|
179
|
+
const keysA = Object.keys(a);
|
|
180
|
+
const keysB = Object.keys(b);
|
|
181
|
+
if (keysA.length !== keysB.length) return false;
|
|
182
|
+
for (const key of keysA) {
|
|
183
|
+
if (a[key] !== b[key]) return false;
|
|
184
|
+
}
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
function hydrate(element, container) {
|
|
188
|
+
return (0, import_dom4.render)(element, container);
|
|
189
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib/index.js';
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/*! @fluixi/jsx v1.0.0-alpha.100 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
|
|
2
|
+
|
|
3
|
+
// src/lib/jsx-runtime.ts
|
|
4
|
+
import {
|
|
5
|
+
asComponent,
|
|
6
|
+
checkRenderType
|
|
7
|
+
} from "@fluixi/dom";
|
|
8
|
+
import { createComponent, createDynamicElement } from "@fluixi/dom";
|
|
9
|
+
import { createSignal, createMemo } from "@fluixi/reactive/signal";
|
|
10
|
+
var Fragment = /* @__PURE__ */ Symbol.for("fluixi.fragment");
|
|
11
|
+
var isSSR = typeof window === "undefined";
|
|
12
|
+
function normalizeChildren(children) {
|
|
13
|
+
if (children === void 0 || children === null || children === false) return null;
|
|
14
|
+
if (Array.isArray(children)) {
|
|
15
|
+
return children.map(normalizeChildren).flat();
|
|
16
|
+
}
|
|
17
|
+
return children;
|
|
18
|
+
}
|
|
19
|
+
function jsx(type, props, key) {
|
|
20
|
+
if (type == null) return null;
|
|
21
|
+
const p = props || {};
|
|
22
|
+
if (key !== void 0) p.key = key;
|
|
23
|
+
if (type === Fragment) {
|
|
24
|
+
return createMemo(() => asComponent(normalizeChildren(p.children)));
|
|
25
|
+
}
|
|
26
|
+
if (typeof type === "function") {
|
|
27
|
+
const { type: renderType } = checkRenderType(type);
|
|
28
|
+
if (type.$$typeof === /* @__PURE__ */ Symbol.for("react.provider") || renderType === "provider") {
|
|
29
|
+
return type(p);
|
|
30
|
+
}
|
|
31
|
+
if (isSSR) return { type, props: p };
|
|
32
|
+
return createMemo(() => createComponent(type, p), void 0, { name: "jsx component" });
|
|
33
|
+
}
|
|
34
|
+
if (typeof type === "string" && type.trim().length > 0) {
|
|
35
|
+
return createNativeElement(type, p);
|
|
36
|
+
}
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
var jsxs = jsx;
|
|
40
|
+
function createNativeElement(tag, props) {
|
|
41
|
+
if (isSSR) return { type: tag, props: props || {} };
|
|
42
|
+
return createDynamicElement(tag, props);
|
|
43
|
+
}
|
|
44
|
+
function createElement(type, props, ...children) {
|
|
45
|
+
const p = { ...props };
|
|
46
|
+
if (children.length > 0) p.children = children.length === 1 ? children[0] : children;
|
|
47
|
+
return jsx(type, p);
|
|
48
|
+
}
|
|
49
|
+
function isValidElement(object) {
|
|
50
|
+
return typeof object === "object" && object !== null && "type" in object;
|
|
51
|
+
}
|
|
52
|
+
function cloneElement(element, props, ...children) {
|
|
53
|
+
return jsx(element.type, {
|
|
54
|
+
...element.props,
|
|
55
|
+
...props,
|
|
56
|
+
children: children.length ? children : element.props.children
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function createRef(initialValue) {
|
|
60
|
+
return { current: initialValue || null };
|
|
61
|
+
}
|
|
62
|
+
function mergeProps(...sources) {
|
|
63
|
+
const target = {};
|
|
64
|
+
for (const source of sources) {
|
|
65
|
+
if (!source) continue;
|
|
66
|
+
const descriptors = Object.getOwnPropertyDescriptors(source);
|
|
67
|
+
Object.defineProperties(target, descriptors);
|
|
68
|
+
}
|
|
69
|
+
return target;
|
|
70
|
+
}
|
|
71
|
+
function forwardRef(fn) {
|
|
72
|
+
return (props) => fn(props, props.ref);
|
|
73
|
+
}
|
|
74
|
+
async function renderToString(element) {
|
|
75
|
+
throw new Error("renderToString should be imported from server module");
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// src/lib/jsx-dev-runtime.ts
|
|
79
|
+
function jsxDEV(type, props, key, isStaticChildren, source, self) {
|
|
80
|
+
return jsx(type, props, key);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// src/lib/index.ts
|
|
84
|
+
import { delegateEvents as delegateEvents2 } from "@fluixi/dom";
|
|
85
|
+
import { createPortal, initializeIntegration, render } from "@fluixi/dom";
|
|
86
|
+
import { batch } from "@fluixi/reactive/signal";
|
|
87
|
+
function createReactiveJSX(config) {
|
|
88
|
+
initializeIntegration({
|
|
89
|
+
signalSystem: config.signalSystem
|
|
90
|
+
});
|
|
91
|
+
return {
|
|
92
|
+
jsx,
|
|
93
|
+
jsxs,
|
|
94
|
+
jsxDEV,
|
|
95
|
+
Fragment,
|
|
96
|
+
render: (element, container) => {
|
|
97
|
+
if (!container) return;
|
|
98
|
+
batch(() => {
|
|
99
|
+
while (container.firstChild) {
|
|
100
|
+
container.removeChild(container.firstChild);
|
|
101
|
+
}
|
|
102
|
+
if (element instanceof Node) {
|
|
103
|
+
container.appendChild(element);
|
|
104
|
+
} else if (Array.isArray(element)) {
|
|
105
|
+
element.forEach((el) => {
|
|
106
|
+
if (el instanceof Node) {
|
|
107
|
+
container.appendChild(el);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
},
|
|
113
|
+
batch
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function jsxComponent(fn) {
|
|
117
|
+
return fn;
|
|
118
|
+
}
|
|
119
|
+
function defineComponent(name, fn) {
|
|
120
|
+
Object.defineProperty(fn, "name", { value: name });
|
|
121
|
+
return fn;
|
|
122
|
+
}
|
|
123
|
+
function memo(component, equals) {
|
|
124
|
+
let lastProps;
|
|
125
|
+
let lastResult;
|
|
126
|
+
return (props) => {
|
|
127
|
+
if (lastProps !== void 0) {
|
|
128
|
+
if (equals ? equals(lastProps, props) : shallowEqual(lastProps, props)) {
|
|
129
|
+
return lastResult;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
lastProps = props;
|
|
133
|
+
lastResult = component(props);
|
|
134
|
+
return lastResult;
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function shallowEqual(a, b) {
|
|
138
|
+
if (a === b) return true;
|
|
139
|
+
if (typeof a !== "object" || typeof b !== "object") return false;
|
|
140
|
+
if (a === null || b === null) return false;
|
|
141
|
+
const keysA = Object.keys(a);
|
|
142
|
+
const keysB = Object.keys(b);
|
|
143
|
+
if (keysA.length !== keysB.length) return false;
|
|
144
|
+
for (const key of keysA) {
|
|
145
|
+
if (a[key] !== b[key]) return false;
|
|
146
|
+
}
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
function hydrate(element, container) {
|
|
150
|
+
return render(element, container);
|
|
151
|
+
}
|
|
152
|
+
export {
|
|
153
|
+
Fragment,
|
|
154
|
+
cloneElement,
|
|
155
|
+
createElement,
|
|
156
|
+
createReactiveJSX,
|
|
157
|
+
createRef,
|
|
158
|
+
defineComponent,
|
|
159
|
+
delegateEvents2 as delegateEvents,
|
|
160
|
+
forwardRef,
|
|
161
|
+
hydrate,
|
|
162
|
+
isValidElement,
|
|
163
|
+
jsx,
|
|
164
|
+
jsxComponent,
|
|
165
|
+
jsxDEV,
|
|
166
|
+
jsxs,
|
|
167
|
+
memo,
|
|
168
|
+
mergeProps,
|
|
169
|
+
renderToString
|
|
170
|
+
};
|