@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/lib/index.mjs
CHANGED
|
@@ -1 +1,188 @@
|
|
|
1
|
-
|
|
1
|
+
// src/lib/jsx-runtime.ts
|
|
2
|
+
import {
|
|
3
|
+
asComponent,
|
|
4
|
+
checkRenderType
|
|
5
|
+
} from "@fluixi/dom";
|
|
6
|
+
import { createComponent, createDynamicElement } from "@fluixi/dom";
|
|
7
|
+
import { createSignal, createMemo } from "@fluixi/reactive/signal";
|
|
8
|
+
var Fragment = /* @__PURE__ */ Symbol.for("fluixi.fragment");
|
|
9
|
+
var isSSR = typeof window === "undefined";
|
|
10
|
+
function normalizeChildren(children) {
|
|
11
|
+
if (children === void 0 || children === null || children === false) return null;
|
|
12
|
+
if (Array.isArray(children)) {
|
|
13
|
+
return children.map(normalizeChildren).flat();
|
|
14
|
+
}
|
|
15
|
+
return children;
|
|
16
|
+
}
|
|
17
|
+
function jsx(type, props, key) {
|
|
18
|
+
if (type == null) return null;
|
|
19
|
+
const p = props || {};
|
|
20
|
+
if (key !== void 0) p.key = key;
|
|
21
|
+
if (type === Fragment) {
|
|
22
|
+
return createMemo(() => asComponent(normalizeChildren(p.children)));
|
|
23
|
+
}
|
|
24
|
+
if (typeof type === "function") {
|
|
25
|
+
const { type: renderType } = checkRenderType(type);
|
|
26
|
+
if (type.$$typeof === /* @__PURE__ */ Symbol.for("react.provider") || renderType === "provider") {
|
|
27
|
+
return type(p);
|
|
28
|
+
}
|
|
29
|
+
if (isSSR) return { type, props: p };
|
|
30
|
+
return createMemo(() => createComponent(type, p), void 0, { name: "jsx component" });
|
|
31
|
+
}
|
|
32
|
+
if (typeof type === "string" && type.trim().length > 0) {
|
|
33
|
+
return createNativeElement(type, p);
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
var jsxs = jsx;
|
|
38
|
+
function createNativeElement(tag, props) {
|
|
39
|
+
if (isSSR) return { type: tag, props: props || {} };
|
|
40
|
+
return createDynamicElement(tag, props);
|
|
41
|
+
}
|
|
42
|
+
function createElement(type, props, ...children) {
|
|
43
|
+
const p = { ...props };
|
|
44
|
+
if (children.length > 0) p.children = children.length === 1 ? children[0] : children;
|
|
45
|
+
return jsx(type, p);
|
|
46
|
+
}
|
|
47
|
+
function isValidElement(object) {
|
|
48
|
+
return typeof object === "object" && object !== null && "type" in object;
|
|
49
|
+
}
|
|
50
|
+
function cloneElement(element, props, ...children) {
|
|
51
|
+
return jsx(element.type, {
|
|
52
|
+
...element.props,
|
|
53
|
+
...props,
|
|
54
|
+
children: children.length ? children : element.props.children
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function createRef(initialValue) {
|
|
58
|
+
return { current: initialValue || null };
|
|
59
|
+
}
|
|
60
|
+
function mergeProps(...sources) {
|
|
61
|
+
const target = {};
|
|
62
|
+
for (const source of sources) {
|
|
63
|
+
if (!source) continue;
|
|
64
|
+
const descriptors = Object.getOwnPropertyDescriptors(source);
|
|
65
|
+
Object.defineProperties(target, descriptors);
|
|
66
|
+
}
|
|
67
|
+
return target;
|
|
68
|
+
}
|
|
69
|
+
function forwardRef(fn) {
|
|
70
|
+
return (props) => fn(props, props.ref);
|
|
71
|
+
}
|
|
72
|
+
async function renderToString(element) {
|
|
73
|
+
throw new Error("renderToString should be imported from server module");
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// src/lib/jsx-dev-runtime.ts
|
|
77
|
+
function jsxDEV(type, props, key, isStaticChildren, source, self) {
|
|
78
|
+
return jsx(type, props, key);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// src/lib/index.ts
|
|
82
|
+
import { delegateEvents as delegateEvents2 } from "@fluixi/dom";
|
|
83
|
+
import { createPortal, initializeIntegration, render } from "@fluixi/dom";
|
|
84
|
+
import { batch } from "@fluixi/reactive/signal";
|
|
85
|
+
function createReactiveJSX(config) {
|
|
86
|
+
initializeIntegration({
|
|
87
|
+
signalSystem: config.signalSystem
|
|
88
|
+
});
|
|
89
|
+
return {
|
|
90
|
+
jsx,
|
|
91
|
+
jsxs,
|
|
92
|
+
jsxDEV,
|
|
93
|
+
Fragment,
|
|
94
|
+
render: (element, container) => {
|
|
95
|
+
if (!container) return;
|
|
96
|
+
batch(() => {
|
|
97
|
+
while (container.firstChild) {
|
|
98
|
+
container.removeChild(container.firstChild);
|
|
99
|
+
}
|
|
100
|
+
if (element instanceof Node) {
|
|
101
|
+
container.appendChild(element);
|
|
102
|
+
} else if (Array.isArray(element)) {
|
|
103
|
+
element.forEach((el) => {
|
|
104
|
+
if (el instanceof Node) {
|
|
105
|
+
container.appendChild(el);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
},
|
|
111
|
+
batch
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function jsxComponent(fn) {
|
|
115
|
+
return fn;
|
|
116
|
+
}
|
|
117
|
+
function defineComponent(name, fn) {
|
|
118
|
+
Object.defineProperty(fn, "name", { value: name });
|
|
119
|
+
return fn;
|
|
120
|
+
}
|
|
121
|
+
function memo(component, equals) {
|
|
122
|
+
let lastProps;
|
|
123
|
+
let lastResult;
|
|
124
|
+
return (props) => {
|
|
125
|
+
if (lastProps !== void 0) {
|
|
126
|
+
if (equals ? equals(lastProps, props) : shallowEqual(lastProps, props)) {
|
|
127
|
+
return lastResult;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
lastProps = props;
|
|
131
|
+
lastResult = component(props);
|
|
132
|
+
return lastResult;
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function shallowEqual(a, b) {
|
|
136
|
+
if (a === b) return true;
|
|
137
|
+
if (typeof a !== "object" || typeof b !== "object") return false;
|
|
138
|
+
if (a === null || b === null) return false;
|
|
139
|
+
const keysA = Object.keys(a);
|
|
140
|
+
const keysB = Object.keys(b);
|
|
141
|
+
if (keysA.length !== keysB.length) return false;
|
|
142
|
+
for (const key of keysA) {
|
|
143
|
+
if (a[key] !== b[key]) return false;
|
|
144
|
+
}
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
function hydrate(element, container) {
|
|
148
|
+
return render(element, container);
|
|
149
|
+
}
|
|
150
|
+
var index_default = {
|
|
151
|
+
jsx,
|
|
152
|
+
jsxs,
|
|
153
|
+
jsxDEV,
|
|
154
|
+
Fragment,
|
|
155
|
+
createElement,
|
|
156
|
+
createRef,
|
|
157
|
+
forwardRef,
|
|
158
|
+
isValidElement,
|
|
159
|
+
cloneElement,
|
|
160
|
+
renderToString,
|
|
161
|
+
createPortal,
|
|
162
|
+
render,
|
|
163
|
+
hydrate,
|
|
164
|
+
memo,
|
|
165
|
+
jsxComponent,
|
|
166
|
+
defineComponent,
|
|
167
|
+
createReactiveJSX
|
|
168
|
+
};
|
|
169
|
+
export {
|
|
170
|
+
Fragment,
|
|
171
|
+
cloneElement,
|
|
172
|
+
createElement,
|
|
173
|
+
createReactiveJSX,
|
|
174
|
+
createRef,
|
|
175
|
+
index_default as default,
|
|
176
|
+
defineComponent,
|
|
177
|
+
delegateEvents2 as delegateEvents,
|
|
178
|
+
forwardRef,
|
|
179
|
+
hydrate,
|
|
180
|
+
isValidElement,
|
|
181
|
+
jsx,
|
|
182
|
+
jsxComponent,
|
|
183
|
+
jsxDEV,
|
|
184
|
+
jsxs,
|
|
185
|
+
memo,
|
|
186
|
+
mergeProps,
|
|
187
|
+
renderToString
|
|
188
|
+
};
|
|
@@ -1 +1,73 @@
|
|
|
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/lib/jsx-dev-runtime.ts
|
|
22
|
+
var jsx_dev_runtime_exports = {};
|
|
23
|
+
__export(jsx_dev_runtime_exports, {
|
|
24
|
+
Fragment: () => Fragment,
|
|
25
|
+
jsx: () => jsx,
|
|
26
|
+
jsxDEV: () => jsxDEV,
|
|
27
|
+
jsxs: () => jsxs
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(jsx_dev_runtime_exports);
|
|
30
|
+
|
|
31
|
+
// src/lib/jsx-runtime.ts
|
|
32
|
+
var import_dom = require("@fluixi/dom");
|
|
33
|
+
var import_dom2 = require("@fluixi/dom");
|
|
34
|
+
var import_signal = require("@fluixi/reactive/signal");
|
|
35
|
+
var Fragment = /* @__PURE__ */ Symbol.for("fluixi.fragment");
|
|
36
|
+
var isSSR = typeof window === "undefined";
|
|
37
|
+
function normalizeChildren(children) {
|
|
38
|
+
if (children === void 0 || children === null || children === false) return null;
|
|
39
|
+
if (Array.isArray(children)) {
|
|
40
|
+
return children.map(normalizeChildren).flat();
|
|
41
|
+
}
|
|
42
|
+
return children;
|
|
43
|
+
}
|
|
44
|
+
function jsx(type, props, key) {
|
|
45
|
+
if (type == null) return null;
|
|
46
|
+
const p = props || {};
|
|
47
|
+
if (key !== void 0) p.key = key;
|
|
48
|
+
if (type === Fragment) {
|
|
49
|
+
return (0, import_signal.createMemo)(() => (0, import_dom.asComponent)(normalizeChildren(p.children)));
|
|
50
|
+
}
|
|
51
|
+
if (typeof type === "function") {
|
|
52
|
+
const { type: renderType } = (0, import_dom.checkRenderType)(type);
|
|
53
|
+
if (type.$$typeof === /* @__PURE__ */ Symbol.for("react.provider") || renderType === "provider") {
|
|
54
|
+
return type(p);
|
|
55
|
+
}
|
|
56
|
+
if (isSSR) return { type, props: p };
|
|
57
|
+
return (0, import_signal.createMemo)(() => (0, import_dom2.createComponent)(type, p), void 0, { name: "jsx component" });
|
|
58
|
+
}
|
|
59
|
+
if (typeof type === "string" && type.trim().length > 0) {
|
|
60
|
+
return createNativeElement(type, p);
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
var jsxs = jsx;
|
|
65
|
+
function createNativeElement(tag, props) {
|
|
66
|
+
if (isSSR) return { type: tag, props: props || {} };
|
|
67
|
+
return (0, import_dom2.createDynamicElement)(tag, props);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// src/lib/jsx-dev-runtime.ts
|
|
71
|
+
function jsxDEV(type, props, key, isStaticChildren, source, self) {
|
|
72
|
+
return jsx(type, props, key);
|
|
73
|
+
}
|
|
@@ -1 +1,54 @@
|
|
|
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
|
+
|
|
45
|
+
// src/lib/jsx-dev-runtime.ts
|
|
46
|
+
function jsxDEV(type, props, key, isStaticChildren, source, self) {
|
|
47
|
+
return jsx(type, props, key);
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
Fragment,
|
|
51
|
+
jsx,
|
|
52
|
+
jsxDEV,
|
|
53
|
+
jsxs
|
|
54
|
+
};
|
package/dist/lib/jsx-runtime.cjs
CHANGED
|
@@ -1 +1,138 @@
|
|
|
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/lib/jsx-runtime.ts
|
|
22
|
+
var jsx_runtime_exports = {};
|
|
23
|
+
__export(jsx_runtime_exports, {
|
|
24
|
+
Fragment: () => Fragment,
|
|
25
|
+
cloneElement: () => cloneElement,
|
|
26
|
+
createElement: () => createElement,
|
|
27
|
+
createRef: () => createRef,
|
|
28
|
+
delegatedSet: () => globalDelegatedSet,
|
|
29
|
+
forwardRef: () => forwardRef,
|
|
30
|
+
isValidElement: () => isValidElement,
|
|
31
|
+
jsx: () => jsx,
|
|
32
|
+
jsxDEV: () => jsxDEV,
|
|
33
|
+
jsxs: () => jsxs,
|
|
34
|
+
mergeProps: () => mergeProps,
|
|
35
|
+
renderToString: () => renderToString,
|
|
36
|
+
splitProps: () => splitProps,
|
|
37
|
+
useRef: () => useRef
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(jsx_runtime_exports);
|
|
40
|
+
var import_dom = require("@fluixi/dom");
|
|
41
|
+
var import_dom2 = require("@fluixi/dom");
|
|
42
|
+
var import_signal = require("@fluixi/reactive/signal");
|
|
43
|
+
var Fragment = /* @__PURE__ */ Symbol.for("fluixi.fragment");
|
|
44
|
+
var isSSR = typeof window === "undefined";
|
|
45
|
+
var globalDelegatedSet = /* @__PURE__ */ new Set();
|
|
46
|
+
function normalizeChildren(children) {
|
|
47
|
+
if (children === void 0 || children === null || children === false) return null;
|
|
48
|
+
if (Array.isArray(children)) {
|
|
49
|
+
return children.map(normalizeChildren).flat();
|
|
50
|
+
}
|
|
51
|
+
return children;
|
|
52
|
+
}
|
|
53
|
+
function jsx(type, props, key) {
|
|
54
|
+
if (type == null) return null;
|
|
55
|
+
const p = props || {};
|
|
56
|
+
if (key !== void 0) p.key = key;
|
|
57
|
+
if (type === Fragment) {
|
|
58
|
+
return (0, import_signal.createMemo)(() => (0, import_dom.asComponent)(normalizeChildren(p.children)));
|
|
59
|
+
}
|
|
60
|
+
if (typeof type === "function") {
|
|
61
|
+
const { type: renderType } = (0, import_dom.checkRenderType)(type);
|
|
62
|
+
if (type.$$typeof === /* @__PURE__ */ Symbol.for("react.provider") || renderType === "provider") {
|
|
63
|
+
return type(p);
|
|
64
|
+
}
|
|
65
|
+
if (isSSR) return { type, props: p };
|
|
66
|
+
return (0, import_signal.createMemo)(() => (0, import_dom2.createComponent)(type, p), void 0, { name: "jsx component" });
|
|
67
|
+
}
|
|
68
|
+
if (typeof type === "string" && type.trim().length > 0) {
|
|
69
|
+
return createNativeElement(type, p);
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
var jsxs = jsx;
|
|
74
|
+
function jsxDEV(type, props, key, _isStaticChildren) {
|
|
75
|
+
return jsx(type, props, key);
|
|
76
|
+
}
|
|
77
|
+
function createNativeElement(tag, props) {
|
|
78
|
+
if (isSSR) return { type: tag, props: props || {} };
|
|
79
|
+
return (0, import_dom2.createDynamicElement)(tag, props);
|
|
80
|
+
}
|
|
81
|
+
function createElement(type, props, ...children) {
|
|
82
|
+
const p = { ...props };
|
|
83
|
+
if (children.length > 0) p.children = children.length === 1 ? children[0] : children;
|
|
84
|
+
return jsx(type, p);
|
|
85
|
+
}
|
|
86
|
+
function isValidElement(object) {
|
|
87
|
+
return typeof object === "object" && object !== null && "type" in object;
|
|
88
|
+
}
|
|
89
|
+
function cloneElement(element, props, ...children) {
|
|
90
|
+
return jsx(element.type, {
|
|
91
|
+
...element.props,
|
|
92
|
+
...props,
|
|
93
|
+
children: children.length ? children : element.props.children
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
function createRef(initialValue) {
|
|
97
|
+
return { current: initialValue || null };
|
|
98
|
+
}
|
|
99
|
+
function useRef(initialValue) {
|
|
100
|
+
const [get, set] = (0, import_signal.createSignal)(initialValue ?? null);
|
|
101
|
+
return {
|
|
102
|
+
get current() {
|
|
103
|
+
return get();
|
|
104
|
+
},
|
|
105
|
+
set current(v) {
|
|
106
|
+
set(v);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
function mergeProps(...sources) {
|
|
111
|
+
const target = {};
|
|
112
|
+
for (const source of sources) {
|
|
113
|
+
if (!source) continue;
|
|
114
|
+
const descriptors = Object.getOwnPropertyDescriptors(source);
|
|
115
|
+
Object.defineProperties(target, descriptors);
|
|
116
|
+
}
|
|
117
|
+
return target;
|
|
118
|
+
}
|
|
119
|
+
function splitProps(props, keys) {
|
|
120
|
+
const picked = {};
|
|
121
|
+
const rest = {};
|
|
122
|
+
const keySet = new Set(keys);
|
|
123
|
+
const descriptors = Object.getOwnPropertyDescriptors(props);
|
|
124
|
+
for (const key in descriptors) {
|
|
125
|
+
if (keySet.has(key)) {
|
|
126
|
+
Object.defineProperty(picked, key, descriptors[key]);
|
|
127
|
+
} else {
|
|
128
|
+
Object.defineProperty(rest, key, descriptors[key]);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return [picked, rest];
|
|
132
|
+
}
|
|
133
|
+
function forwardRef(fn) {
|
|
134
|
+
return (props) => fn(props, props.ref);
|
|
135
|
+
}
|
|
136
|
+
async function renderToString(element) {
|
|
137
|
+
throw new Error("renderToString should be imported from server module");
|
|
138
|
+
}
|
package/dist/lib/jsx-runtime.mjs
CHANGED
|
@@ -1 +1,121 @@
|
|
|
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
|
+
var globalDelegatedSet = /* @__PURE__ */ new Set();
|
|
13
|
+
function normalizeChildren(children) {
|
|
14
|
+
if (children === void 0 || children === null || children === false) return null;
|
|
15
|
+
if (Array.isArray(children)) {
|
|
16
|
+
return children.map(normalizeChildren).flat();
|
|
17
|
+
}
|
|
18
|
+
return children;
|
|
19
|
+
}
|
|
20
|
+
function jsx(type, props, key) {
|
|
21
|
+
if (type == null) return null;
|
|
22
|
+
const p = props || {};
|
|
23
|
+
if (key !== void 0) p.key = key;
|
|
24
|
+
if (type === Fragment) {
|
|
25
|
+
return createMemo(() => asComponent(normalizeChildren(p.children)));
|
|
26
|
+
}
|
|
27
|
+
if (typeof type === "function") {
|
|
28
|
+
const { type: renderType } = checkRenderType(type);
|
|
29
|
+
if (type.$$typeof === /* @__PURE__ */ Symbol.for("react.provider") || renderType === "provider") {
|
|
30
|
+
return type(p);
|
|
31
|
+
}
|
|
32
|
+
if (isSSR) return { type, props: p };
|
|
33
|
+
return createMemo(() => createComponent(type, p), void 0, { name: "jsx component" });
|
|
34
|
+
}
|
|
35
|
+
if (typeof type === "string" && type.trim().length > 0) {
|
|
36
|
+
return createNativeElement(type, p);
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
var jsxs = jsx;
|
|
41
|
+
function jsxDEV(type, props, key, _isStaticChildren) {
|
|
42
|
+
return jsx(type, props, key);
|
|
43
|
+
}
|
|
44
|
+
function createNativeElement(tag, props) {
|
|
45
|
+
if (isSSR) return { type: tag, props: props || {} };
|
|
46
|
+
return createDynamicElement(tag, props);
|
|
47
|
+
}
|
|
48
|
+
function createElement(type, props, ...children) {
|
|
49
|
+
const p = { ...props };
|
|
50
|
+
if (children.length > 0) p.children = children.length === 1 ? children[0] : children;
|
|
51
|
+
return jsx(type, p);
|
|
52
|
+
}
|
|
53
|
+
function isValidElement(object) {
|
|
54
|
+
return typeof object === "object" && object !== null && "type" in object;
|
|
55
|
+
}
|
|
56
|
+
function cloneElement(element, props, ...children) {
|
|
57
|
+
return jsx(element.type, {
|
|
58
|
+
...element.props,
|
|
59
|
+
...props,
|
|
60
|
+
children: children.length ? children : element.props.children
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function createRef(initialValue) {
|
|
64
|
+
return { current: initialValue || null };
|
|
65
|
+
}
|
|
66
|
+
function useRef(initialValue) {
|
|
67
|
+
const [get, set] = createSignal(initialValue ?? null);
|
|
68
|
+
return {
|
|
69
|
+
get current() {
|
|
70
|
+
return get();
|
|
71
|
+
},
|
|
72
|
+
set current(v) {
|
|
73
|
+
set(v);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function mergeProps(...sources) {
|
|
78
|
+
const target = {};
|
|
79
|
+
for (const source of sources) {
|
|
80
|
+
if (!source) continue;
|
|
81
|
+
const descriptors = Object.getOwnPropertyDescriptors(source);
|
|
82
|
+
Object.defineProperties(target, descriptors);
|
|
83
|
+
}
|
|
84
|
+
return target;
|
|
85
|
+
}
|
|
86
|
+
function splitProps(props, keys) {
|
|
87
|
+
const picked = {};
|
|
88
|
+
const rest = {};
|
|
89
|
+
const keySet = new Set(keys);
|
|
90
|
+
const descriptors = Object.getOwnPropertyDescriptors(props);
|
|
91
|
+
for (const key in descriptors) {
|
|
92
|
+
if (keySet.has(key)) {
|
|
93
|
+
Object.defineProperty(picked, key, descriptors[key]);
|
|
94
|
+
} else {
|
|
95
|
+
Object.defineProperty(rest, key, descriptors[key]);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return [picked, rest];
|
|
99
|
+
}
|
|
100
|
+
function forwardRef(fn) {
|
|
101
|
+
return (props) => fn(props, props.ref);
|
|
102
|
+
}
|
|
103
|
+
async function renderToString(element) {
|
|
104
|
+
throw new Error("renderToString should be imported from server module");
|
|
105
|
+
}
|
|
106
|
+
export {
|
|
107
|
+
Fragment,
|
|
108
|
+
cloneElement,
|
|
109
|
+
createElement,
|
|
110
|
+
createRef,
|
|
111
|
+
globalDelegatedSet as delegatedSet,
|
|
112
|
+
forwardRef,
|
|
113
|
+
isValidElement,
|
|
114
|
+
jsx,
|
|
115
|
+
jsxDEV,
|
|
116
|
+
jsxs,
|
|
117
|
+
mergeProps,
|
|
118
|
+
renderToString,
|
|
119
|
+
splitProps,
|
|
120
|
+
useRef
|
|
121
|
+
};
|
package/dist/lib/jsx.d.ts
CHANGED
|
@@ -87,9 +87,10 @@ export namespace JSX {
|
|
|
87
87
|
// ============================================================================
|
|
88
88
|
|
|
89
89
|
export interface IntrinsicElements extends A.IntrinsicElements {}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
90
|
+
|
|
91
|
+
export interface ElementChildrenAttribute {
|
|
92
|
+
children: {};
|
|
93
|
+
}
|
|
93
94
|
}
|
|
94
95
|
|
|
95
96
|
|
|
@@ -118,15 +119,20 @@ declare global {
|
|
|
118
119
|
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
119
120
|
interface FluixiElements {}
|
|
120
121
|
|
|
122
|
+
// Each name declared once, off the element types themselves.
|
|
123
|
+
//
|
|
124
|
+
// These used to be a type alias and an interface of the same name, where the interface
|
|
125
|
+
// extended `JSX.X` — which inside `declare global { namespace JSX }` is the name being
|
|
126
|
+
// declared. Extending itself makes it empty, so `JSX.IntrinsicElements` had no elements in
|
|
127
|
+
// it and every `<div>` in an application was "Property 'div' does not exist".
|
|
128
|
+
//
|
|
129
|
+
// `Element` stays an alias, and exactly what the dom can insert: a node, a string, a list,
|
|
130
|
+
// a function returning one. An interface cannot extend that union, and widening it — even
|
|
131
|
+
// by one member — makes `<b/>` unassignable to a `children` typed ComponentChild, which is
|
|
132
|
+
// the error every nested element produced.
|
|
121
133
|
namespace JSX {
|
|
122
|
-
type Element =
|
|
123
|
-
|
|
124
|
-
interface Element extends JSX.Element, FluixiElements {
|
|
125
|
-
strings?: TemplateStringsArray;
|
|
126
|
-
values?: readonly unknown[];
|
|
127
|
-
_$litType$?: number;
|
|
128
|
-
}
|
|
129
|
-
interface IntrinsicElements extends JSX.IntrinsicElements, FluixiElements {}
|
|
134
|
+
type Element = A.FxElement;
|
|
135
|
+
interface IntrinsicElements extends A.IntrinsicElements, FluixiElements {}
|
|
130
136
|
interface ElementChildrenAttribute {
|
|
131
137
|
children: {};
|
|
132
138
|
}
|