@fluixi/jsx 1.0.0-alpha.82 → 1.0.0-alpha.84
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/dist/index.cjs +189 -1
- package/dist/index.mjs +170 -1
- package/dist/lib/index.cjs +208 -1
- package/dist/lib/index.mjs +188 -1
- package/dist/lib/jsx-dev-runtime.cjs +73 -1
- package/dist/lib/jsx-dev-runtime.mjs +54 -1
- package/dist/lib/jsx-runtime.cjs +138 -1
- package/dist/lib/jsx-runtime.mjs +121 -1
- package/dist/lib/jsx.d.ts +17 -11
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +8 -8
package/dist/index.cjs
CHANGED
|
@@ -1 +1,189 @@
|
|
|
1
|
-
|
|
1
|
+
/*! @fluixi/jsx v1.0.0-alpha.84 | (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.mjs
CHANGED
|
@@ -1 +1,170 @@
|
|
|
1
|
-
|
|
1
|
+
/*! @fluixi/jsx v1.0.0-alpha.84 | (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
|
+
};
|
package/dist/lib/index.cjs
CHANGED
|
@@ -1 +1,208 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/lib/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
Fragment: () => Fragment,
|
|
24
|
+
cloneElement: () => cloneElement,
|
|
25
|
+
createElement: () => createElement,
|
|
26
|
+
createReactiveJSX: () => createReactiveJSX,
|
|
27
|
+
createRef: () => createRef,
|
|
28
|
+
default: () => index_default,
|
|
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
|
+
}
|
|
190
|
+
var index_default = {
|
|
191
|
+
jsx,
|
|
192
|
+
jsxs,
|
|
193
|
+
jsxDEV,
|
|
194
|
+
Fragment,
|
|
195
|
+
createElement,
|
|
196
|
+
createRef,
|
|
197
|
+
forwardRef,
|
|
198
|
+
isValidElement,
|
|
199
|
+
cloneElement,
|
|
200
|
+
renderToString,
|
|
201
|
+
createPortal: import_dom4.createPortal,
|
|
202
|
+
render: import_dom4.render,
|
|
203
|
+
hydrate,
|
|
204
|
+
memo,
|
|
205
|
+
jsxComponent,
|
|
206
|
+
defineComponent,
|
|
207
|
+
createReactiveJSX
|
|
208
|
+
};
|