@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
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment, JSXComponent, JSXProps, JSXElement } from './jsx-runtime.js';
|
|
2
|
+
export { Fragment, jsx, jsxs };
|
|
3
|
+
/**
|
|
4
|
+
* jsxDEV - development version
|
|
5
|
+
*/
|
|
6
|
+
export declare function jsxDEV(type: string | JSXComponent, props: JSXProps | null, key?: string, isStaticChildren?: boolean, source?: {
|
|
7
|
+
fileName: string;
|
|
8
|
+
lineNumber: number;
|
|
9
|
+
columnNumber: number;
|
|
10
|
+
}, self?: any): JSXElement;
|
|
11
|
+
//# sourceMappingURL=jsx-dev-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx-dev-runtime.d.ts","sourceRoot":"","sources":["../../src/lib/jsx-dev-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EACH,IAAI,EACJ,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,UAAU,EACX,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;AAE/B;;GAEG;AACH,wBAAgB,MAAM,CACpB,IAAI,EAAE,MAAM,GAAG,YAAY,EAC3B,KAAK,EAAE,QAAQ,GAAG,IAAI,EACtB,GAAG,CAAC,EAAE,MAAM,EACZ,gBAAgB,CAAC,EAAE,OAAO,EAC1B,MAAM,CAAC,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,EACvE,IAAI,CAAC,EAAE,GAAG,GACT,UAAU,CAEZ"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment, } from './jsx-runtime.js';
|
|
2
|
+
export { Fragment, jsx, jsxs };
|
|
3
|
+
/**
|
|
4
|
+
* jsxDEV - development version
|
|
5
|
+
*/
|
|
6
|
+
export function jsxDEV(type, props, key, isStaticChildren, source, self) {
|
|
7
|
+
return jsx(type, props, key);
|
|
8
|
+
}
|
|
9
|
+
function validateProps(tag, props) {
|
|
10
|
+
if (typeof tag === 'string') {
|
|
11
|
+
const validProps = getValidDOMProps(tag);
|
|
12
|
+
for (const prop in props) {
|
|
13
|
+
if (!validProps.has(prop) &&
|
|
14
|
+
!prop.startsWith('on') &&
|
|
15
|
+
prop !== 'children') {
|
|
16
|
+
console.warn(`Invalid prop "${prop}" on <${tag}> element`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function getValidDOMProps(tag) {
|
|
22
|
+
const commonProps = new Set([
|
|
23
|
+
'className',
|
|
24
|
+
'class',
|
|
25
|
+
'style',
|
|
26
|
+
'id',
|
|
27
|
+
'key',
|
|
28
|
+
'ref',
|
|
29
|
+
'title',
|
|
30
|
+
'role',
|
|
31
|
+
'tabIndex',
|
|
32
|
+
'disabled',
|
|
33
|
+
'hidden',
|
|
34
|
+
'src',
|
|
35
|
+
'href',
|
|
36
|
+
'alt',
|
|
37
|
+
'target',
|
|
38
|
+
'type',
|
|
39
|
+
'value',
|
|
40
|
+
'checked',
|
|
41
|
+
'selected',
|
|
42
|
+
'placeholder',
|
|
43
|
+
'readOnly',
|
|
44
|
+
'required',
|
|
45
|
+
'min',
|
|
46
|
+
'max',
|
|
47
|
+
'step',
|
|
48
|
+
'pattern',
|
|
49
|
+
'autoComplete',
|
|
50
|
+
'autoFocus',
|
|
51
|
+
'cols',
|
|
52
|
+
'rows',
|
|
53
|
+
'multiple',
|
|
54
|
+
'size',
|
|
55
|
+
'accept',
|
|
56
|
+
'for',
|
|
57
|
+
'name',
|
|
58
|
+
]);
|
|
59
|
+
return commonProps;
|
|
60
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
|
|
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
|
+
};
|
|
@@ -0,0 +1,138 @@
|
|
|
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/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
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview JSX Runtime with Reactive DOM Support
|
|
3
|
+
* @module @fluixi/jsx
|
|
4
|
+
*
|
|
5
|
+
* Production-grade JSX runtime for the Fluixi reactive system.
|
|
6
|
+
* Key design: event handlers stored as $$eventname properties on DOM nodes
|
|
7
|
+
* (SolidJS delegation pattern) for reliable bubbling and preventDefault support.
|
|
8
|
+
*/
|
|
9
|
+
export type JSXElement = Node | string | number | boolean | null | undefined | JSXElement[];
|
|
10
|
+
export type JSXComponent<P = any> = (props: P) => JSXElement;
|
|
11
|
+
export interface JSXProps {
|
|
12
|
+
children?: JSXElement;
|
|
13
|
+
ref?: any;
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
}
|
|
16
|
+
export type RefCallback<T> = (instance: T) => void;
|
|
17
|
+
export type RefObject<T> = {
|
|
18
|
+
current: T | null;
|
|
19
|
+
};
|
|
20
|
+
export declare const Fragment: unique symbol;
|
|
21
|
+
declare const globalDelegatedSet: Set<string>;
|
|
22
|
+
/**
|
|
23
|
+
* Main JSX factory function.
|
|
24
|
+
* - String tags → native DOM element
|
|
25
|
+
* - Function tags → component (wrapped in createMemo for reactivity)
|
|
26
|
+
* - Fragment → children array
|
|
27
|
+
*/
|
|
28
|
+
export declare function jsx(type: any, props: any, key?: string): JSXElement;
|
|
29
|
+
export declare const jsxs: typeof jsx;
|
|
30
|
+
export declare function jsxDEV(type: any, props: any, key?: string, _isStaticChildren?: boolean): JSXElement;
|
|
31
|
+
export declare function createElement(type: any, props: any, ...children: any[]): JSXElement;
|
|
32
|
+
export declare function isValidElement(object: any): boolean;
|
|
33
|
+
export declare function cloneElement(element: any, props: any, ...children: any[]): any;
|
|
34
|
+
export declare function createRef<T>(initialValue?: T): {
|
|
35
|
+
current: NonNullable<T> | null;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Create a reactive ref compatible with `ref={...}` JSX prop.
|
|
39
|
+
* The `.current` property is backed by a signal for reactive tracking.
|
|
40
|
+
*/
|
|
41
|
+
export declare function useRef<T>(initialValue?: T): {
|
|
42
|
+
current: T | null | undefined;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Merge multiple props objects reactively.
|
|
46
|
+
* Getters from each source are preserved for reactive prop access.
|
|
47
|
+
*/
|
|
48
|
+
export declare function mergeProps<T extends object>(...sources: Partial<T>[]): T;
|
|
49
|
+
/**
|
|
50
|
+
* Split props into two objects: one with the specified keys, one with the rest.
|
|
51
|
+
*/
|
|
52
|
+
export declare function splitProps<T extends object, K extends keyof T>(props: T, keys: K[]): [Pick<T, K>, Omit<T, K>];
|
|
53
|
+
export declare function forwardRef(fn: Function): (props: any) => any;
|
|
54
|
+
export declare function renderToString(element: JSXElement): Promise<string>;
|
|
55
|
+
export { globalDelegatedSet as delegatedSet };
|
|
56
|
+
export type { JSX } from './jsx.d.js';
|
|
57
|
+
//# sourceMappingURL=jsx-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx-runtime.d.ts","sourceRoot":"","sources":["../../src/lib/jsx-runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA+BH,MAAM,MAAM,UAAU,GAClB,IAAI,GACJ,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,GACT,UAAU,EAAE,CAAC;AAEjB,MAAM,MAAM,YAAY,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,UAAU,CAAC;AAE7D,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,KAAK,IAAI,CAAC;AACnD,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI;IAAE,OAAO,EAAE,CAAC,GAAG,IAAI,CAAA;CAAE,CAAC;AAMjD,eAAO,MAAM,QAAQ,eAAgC,CAAC;AAKtD,QAAA,MAAM,kBAAkB,aAAoB,CAAC;AA+B7C;;;;;GAKG;AACH,wBAAgB,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,UAAU,CAiCnE;AAED,eAAO,MAAM,IAAI,YAAM,CAAC;AAExB,wBAAgB,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE,OAAO,GAAG,UAAU,CAEnG;AAkBD,wBAAgB,aAAa,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,QAAQ,EAAE,GAAG,EAAE,GAAG,UAAU,CAInF;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAEnD;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,QAAQ,EAAE,GAAG,EAAE,GAAG,GAAG,CAM9E;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,YAAY,CAAC,EAAE,CAAC;;EAE5C;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,YAAY,CAAC,EAAE,CAAC;aAIvB,CAAC,GAAG,IAAI,GAAG,SAAS;EAEtC;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAQxE;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,CAAC,EAC5D,KAAK,EAAE,CAAC,EACR,IAAI,EAAE,CAAC,EAAE,GACR,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAe1B;AAGD,wBAAgB,UAAU,CAAC,EAAE,EAAE,QAAQ,IAC7B,OAAO,GAAG,SACnB;AAED,wBAAsB,cAAc,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAGzE;AAGD,OAAO,EAAE,kBAAkB,IAAI,YAAY,EAAE,CAAC;AAM9C,YAAY,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview JSX Runtime with Reactive DOM Support
|
|
3
|
+
* @module @fluixi/jsx
|
|
4
|
+
*
|
|
5
|
+
* Production-grade JSX runtime for the Fluixi reactive system.
|
|
6
|
+
* Key design: event handlers stored as $$eventname properties on DOM nodes
|
|
7
|
+
* (SolidJS delegation pattern) for reliable bubbling and preventDefault support.
|
|
8
|
+
*/
|
|
9
|
+
import { asComponent, checkRenderType } from '@fluixi/dom';
|
|
10
|
+
import { createComponent, createDynamicElement } from '@fluixi/dom';
|
|
11
|
+
import { createSignal, createMemo } from '@fluixi/reactive/signal';
|
|
12
|
+
// ============================================================================
|
|
13
|
+
// Constants
|
|
14
|
+
// ============================================================================
|
|
15
|
+
export const Fragment = Symbol.for('fluixi.fragment');
|
|
16
|
+
const isSSR = typeof window === 'undefined';
|
|
17
|
+
// Track which event names we've registered globally (mirrors delegatedSet in runtime)
|
|
18
|
+
const globalDelegatedSet = new Set();
|
|
19
|
+
// ============================================================================
|
|
20
|
+
// Helper: createComponent
|
|
21
|
+
//
|
|
22
|
+
// Both backends now instantiate components through the framework's registered
|
|
23
|
+
// createComponent (imported from @fluixi/dom; fluixi registers it via
|
|
24
|
+
// registerCreateComponent). That path runs the component untracked AND applies
|
|
25
|
+
// the proper owner/lifecycle handling + asComponent stamping, so the jsx and
|
|
26
|
+
// imperative backends share one component-instantiation path. The dom shim
|
|
27
|
+
// falls back to `() => Comp(props)` only when no system is registered.
|
|
28
|
+
// ============================================================================
|
|
29
|
+
// ============================================================================
|
|
30
|
+
// Helper: normalizeChildren
|
|
31
|
+
// ============================================================================
|
|
32
|
+
function normalizeChildren(children) {
|
|
33
|
+
if (children === undefined || children === null || children === false)
|
|
34
|
+
return null;
|
|
35
|
+
if (Array.isArray(children)) {
|
|
36
|
+
return children.map(normalizeChildren).flat();
|
|
37
|
+
}
|
|
38
|
+
return children;
|
|
39
|
+
}
|
|
40
|
+
// ============================================================================
|
|
41
|
+
// JSX Factory
|
|
42
|
+
// ============================================================================
|
|
43
|
+
/**
|
|
44
|
+
* Main JSX factory function.
|
|
45
|
+
* - String tags → native DOM element
|
|
46
|
+
* - Function tags → component (wrapped in createMemo for reactivity)
|
|
47
|
+
* - Fragment → children array
|
|
48
|
+
*/
|
|
49
|
+
export function jsx(type, props, key) {
|
|
50
|
+
if (type == null)
|
|
51
|
+
return null;
|
|
52
|
+
const p = props || {};
|
|
53
|
+
if (key !== undefined)
|
|
54
|
+
p.key = key;
|
|
55
|
+
if (type === Fragment) {
|
|
56
|
+
return createMemo(() => asComponent(normalizeChildren(p.children)));
|
|
57
|
+
}
|
|
58
|
+
if (typeof type === 'function') {
|
|
59
|
+
const { type: renderType } = checkRenderType(type);
|
|
60
|
+
// Context Provider is called directly: no memo wrapper.
|
|
61
|
+
if (type.$$typeof === Symbol.for('react.provider') ||
|
|
62
|
+
renderType === 'provider') {
|
|
63
|
+
return type(p);
|
|
64
|
+
}
|
|
65
|
+
if (isSSR)
|
|
66
|
+
return { type, props: p };
|
|
67
|
+
// Wrap in a memo so the component is reactive.
|
|
68
|
+
return createMemo(() => createComponent(type, p), undefined, { name: 'jsx component' });
|
|
69
|
+
}
|
|
70
|
+
// Handle string tags (native elements)
|
|
71
|
+
if (typeof type === 'string' && type.trim().length > 0) {
|
|
72
|
+
return createNativeElement(type, p);
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
export const jsxs = jsx;
|
|
77
|
+
export function jsxDEV(type, props, key, _isStaticChildren) {
|
|
78
|
+
return jsx(type, props, key);
|
|
79
|
+
}
|
|
80
|
+
// ============================================================================
|
|
81
|
+
// Native Element Creation
|
|
82
|
+
// ============================================================================
|
|
83
|
+
function createNativeElement(tag, props) {
|
|
84
|
+
if (isSSR)
|
|
85
|
+
return { type: tag, props: props || {} };
|
|
86
|
+
// Element construction lives in @fluixi/dom: html`` and JSX compile to the same
|
|
87
|
+
// dom calls, and a polymorphic `as` needs the same factory without depending on
|
|
88
|
+
// this package. One implementation, so the two paths can't drift.
|
|
89
|
+
return createDynamicElement(tag, props);
|
|
90
|
+
}
|
|
91
|
+
// ============================================================================
|
|
92
|
+
// Additional Exports
|
|
93
|
+
// ============================================================================
|
|
94
|
+
export function createElement(type, props, ...children) {
|
|
95
|
+
const p = { ...props };
|
|
96
|
+
if (children.length > 0)
|
|
97
|
+
p.children = children.length === 1 ? children[0] : children;
|
|
98
|
+
return jsx(type, p);
|
|
99
|
+
}
|
|
100
|
+
export function isValidElement(object) {
|
|
101
|
+
return typeof object === 'object' && object !== null && 'type' in object;
|
|
102
|
+
}
|
|
103
|
+
export function cloneElement(element, props, ...children) {
|
|
104
|
+
return jsx(element.type, {
|
|
105
|
+
...element.props,
|
|
106
|
+
...props,
|
|
107
|
+
children: children.length ? children : element.props.children,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
export function createRef(initialValue) {
|
|
111
|
+
return { current: initialValue || null };
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Create a reactive ref compatible with `ref={...}` JSX prop.
|
|
115
|
+
* The `.current` property is backed by a signal for reactive tracking.
|
|
116
|
+
*/
|
|
117
|
+
export function useRef(initialValue) {
|
|
118
|
+
const [get, set] = createSignal(initialValue ?? null);
|
|
119
|
+
return {
|
|
120
|
+
get current() { return get(); },
|
|
121
|
+
set current(v) { set(v); },
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Merge multiple props objects reactively.
|
|
126
|
+
* Getters from each source are preserved for reactive prop access.
|
|
127
|
+
*/
|
|
128
|
+
export function mergeProps(...sources) {
|
|
129
|
+
const target = {};
|
|
130
|
+
for (const source of sources) {
|
|
131
|
+
if (!source)
|
|
132
|
+
continue;
|
|
133
|
+
const descriptors = Object.getOwnPropertyDescriptors(source);
|
|
134
|
+
Object.defineProperties(target, descriptors);
|
|
135
|
+
}
|
|
136
|
+
return target;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Split props into two objects: one with the specified keys, one with the rest.
|
|
140
|
+
*/
|
|
141
|
+
export function splitProps(props, keys) {
|
|
142
|
+
const picked = {};
|
|
143
|
+
const rest = {};
|
|
144
|
+
const keySet = new Set(keys);
|
|
145
|
+
const descriptors = Object.getOwnPropertyDescriptors(props);
|
|
146
|
+
for (const key in descriptors) {
|
|
147
|
+
if (keySet.has(key)) {
|
|
148
|
+
Object.defineProperty(picked, key, descriptors[key]);
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
Object.defineProperty(rest, key, descriptors[key]);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return [picked, rest];
|
|
155
|
+
}
|
|
156
|
+
export function forwardRef(fn) {
|
|
157
|
+
return (props) => fn(props, props.ref);
|
|
158
|
+
}
|
|
159
|
+
export async function renderToString(element) {
|
|
160
|
+
// Use @lit-labs/ssr or implementation from server module
|
|
161
|
+
throw new Error('renderToString should be imported from server module');
|
|
162
|
+
}
|
|
163
|
+
// Re-export delegatedSet accessor for the runtime to check
|
|
164
|
+
export { globalDelegatedSet as delegatedSet };
|
|
@@ -0,0 +1,121 @@
|
|
|
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
|
+
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
|
+
};
|