@fluixi/jsx 1.0.0-alpha.53
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 +857 -0
- package/dist/index.cjs +1 -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 +1 -0
- package/dist/lib/index.cjs +1 -0
- package/dist/lib/index.d.ts +73 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +158 -0
- package/dist/lib/index.mjs +1 -0
- package/dist/lib/jsx-dev-runtime.cjs +1 -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 +1 -0
- package/dist/lib/jsx-runtime.cjs +1 -0
- package/dist/lib/jsx-runtime.d.ts +58 -0
- package/dist/lib/jsx-runtime.d.ts.map +1 -0
- package/dist/lib/jsx-runtime.js +181 -0
- package/dist/lib/jsx-runtime.mjs +1 -0
- package/dist/lib/jsx.d.ts +1460 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -0
- package/package.json +67 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var u=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var R=(e,t)=>{for(var n in t)u(e,n,{get:t[n],enumerable:!0})},C=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of T(t))!v.call(e,o)&&o!==n&&u(e,o,{get:()=>t[o],enumerable:!(r=b(t,o))||r.enumerable});return e};var w=e=>C(u({},"__esModule",{value:!0}),e);var I={};R(I,{Fragment:()=>l,cloneElement:()=>y,createElement:()=>m,createReactiveJSX:()=>V,createRef:()=>x,defineComponent:()=>A,delegateEvents:()=>h.delegateEvents,forwardRef:()=>S,hydrate:()=>K,isValidElement:()=>d,jsx:()=>i,jsxComponent:()=>D,jsxDEV:()=>c,jsxs:()=>f,memo:()=>F,mergeProps:()=>X,renderToString:()=>E});module.exports=w(I);var s=require("@fluixi/dom"),P=require("@fluixi/dom"),a=require("@fluixi/reactive/signal"),l=Symbol.for("fluixi.fragment"),j=typeof window>"u";function J(e){return e==null||e===!1?null:Array.isArray(e)?e.map(J).flat():e}function i(e,t,n){if(e==null)return null;let r=t||{};if(n!==void 0&&(r.key=n),e===l)return(0,a.createMemo)(()=>(0,s.asComponent)(J(r.children)));if(typeof e=="function"){let{type:o}=(0,s.checkRenderType)(e);return e.$$typeof===Symbol.for("react.provider")||o==="provider"?e(r):j?{type:e,props:r}:(0,a.createMemo)(()=>(0,P.createComponent)(e,r),void 0,{name:"jsx component"})}return typeof e=="string"&&e.trim().length>0?k(e,r):null}var f=i;function k(e,t){if(j)return{type:e,props:t||{}};let n=(0,s.isSVGElement)(e),r=n?document.createElementNS("http://www.w3.org/2000/svg",e):document.createElement(e);return O(r,t,n),r}function O(e,t,n){if((0,s.applyProps)(e,t,n),t&&t.children!==void 0){let r=(0,a.readChildren)(()=>t.children);Array.isArray(r)?r.forEach(o=>{(0,s.insert)(e,o,typeof o=="function"?null:void 0)}):(0,s.insert)(e,r,typeof r=="function"?null:void 0)}}function m(e,t,...n){let r={...t};return n.length>0&&(r.children=n.length===1?n[0]:n),i(e,r)}function d(e){return typeof e=="object"&&e!==null&&"type"in e}function y(e,t,...n){return i(e.type,{...e.props,...t,children:n.length?n:e.props.children})}function x(e){return{current:e||null}}function X(...e){let t={};for(let n of e){if(!n)continue;let r=Object.getOwnPropertyDescriptors(n);Object.defineProperties(t,r)}return t}function S(e){return t=>e(t,t.ref)}async function E(e){throw new Error("renderToString should be imported from server module")}function c(e,t,n,r,o,G){return i(e,t,n)}var h=require("@fluixi/dom");var p=require("@fluixi/dom"),g=require("@fluixi/reactive/signal");function V(e){return(0,p.initializeIntegration)({signalSystem:e.signalSystem}),{jsx:i,jsxs:f,jsxDEV:c,Fragment:l,render:(t,n)=>{n&&(0,g.batch)(()=>{for(;n.firstChild;)n.removeChild(n.firstChild);t instanceof Node?n.appendChild(t):Array.isArray(t)&&t.forEach(r=>{r instanceof Node&&n.appendChild(r)})})},batch:g.batch}}function D(e){return e}function A(e,t){return Object.defineProperty(t,"name",{value:e}),t}function F(e,t){let n,r;return o=>(n!==void 0&&(t?t(n,o):N(n,o))||(n=o,r=e(o)),r)}function N(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let o of n)if(e[o]!==t[o])return!1;return!0}function K(e,t){return(0,p.render)(e,t)}
|
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 @@
|
|
|
1
|
+
import{insert as f,isSVGElement as P,asComponent as j,checkRenderType as J,applyProps as X}from"@fluixi/dom";import{createComponent as h}from"@fluixi/dom";import{createSignal as Q,createMemo as p,readChildren as b}from"@fluixi/reactive/signal";var i=Symbol.for("fluixi.fragment"),c=typeof window>"u";function u(e){return e==null||e===!1?null:Array.isArray(e)?e.map(u).flat():e}function s(e,t,n){if(e==null)return null;let r=t||{};if(n!==void 0&&(r.key=n),e===i)return p(()=>j(u(r.children)));if(typeof e=="function"){let{type:o}=J(e);return e.$$typeof===Symbol.for("react.provider")||o==="provider"?e(r):c?{type:e,props:r}:p(()=>h(e,r),void 0,{name:"jsx component"})}return typeof e=="string"&&e.trim().length>0?T(e,r):null}var a=s;function T(e,t){if(c)return{type:e,props:t||{}};let n=P(e),r=n?document.createElementNS("http://www.w3.org/2000/svg",e):document.createElement(e);return v(r,t,n),r}function v(e,t,n){if(X(e,t,n),t&&t.children!==void 0){let r=b(()=>t.children);Array.isArray(r)?r.forEach(o=>{f(e,o,typeof o=="function"?null:void 0)}):f(e,r,typeof r=="function"?null:void 0)}}function m(e,t,...n){let r={...t};return n.length>0&&(r.children=n.length===1?n[0]:n),s(e,r)}function d(e){return typeof e=="object"&&e!==null&&"type"in e}function y(e,t,...n){return s(e.type,{...e.props,...t,children:n.length?n:e.props.children})}function x(e){return{current:e||null}}function R(...e){let t={};for(let n of e){if(!n)continue;let r=Object.getOwnPropertyDescriptors(n);Object.defineProperties(t,r)}return t}function S(e){return t=>e(t,t.ref)}async function E(e){throw new Error("renderToString should be imported from server module")}function l(e,t,n,r,o,O){return s(e,t,n)}import{delegateEvents as Ee}from"@fluixi/dom";import{createPortal as ae,initializeIntegration as C,render as w}from"@fluixi/dom";import{batch as g}from"@fluixi/reactive/signal";function fe(e){return C({signalSystem:e.signalSystem}),{jsx:s,jsxs:a,jsxDEV:l,Fragment:i,render:(t,n)=>{n&&g(()=>{for(;n.firstChild;)n.removeChild(n.firstChild);t instanceof Node?n.appendChild(t):Array.isArray(t)&&t.forEach(r=>{r instanceof Node&&n.appendChild(r)})})},batch:g}}function pe(e){return e}function ce(e,t){return Object.defineProperty(t,"name",{value:e}),t}function ue(e,t){let n,r;return o=>(n!==void 0&&(t?t(n,o):k(n,o))||(n=o,r=e(o)),r)}function k(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let o of n)if(e[o]!==t[o])return!1;return!0}function me(e,t){return w(e,t)}export{i as Fragment,y as cloneElement,m as createElement,fe as createReactiveJSX,x as createRef,ce as defineComponent,Ee as delegateEvents,S as forwardRef,me as hydrate,d as isValidElement,s as jsx,pe as jsxComponent,l as jsxDEV,a as jsxs,ue as memo,R as mergeProps,E as renderToString};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var E=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var O=Object.prototype.hasOwnProperty;var V=(e,t)=>{for(var n in t)E(e,n,{get:t[n],enumerable:!0})},D=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of k(t))!O.call(e,o)&&o!==n&&E(e,o,{get:()=>t[o],enumerable:!(r=w(t,o))||r.enumerable});return e};var A=e=>D(E({},"__esModule",{value:!0}),e);var G={};V(G,{Fragment:()=>a,cloneElement:()=>d,createElement:()=>u,createReactiveJSX:()=>h,createRef:()=>y,default:()=>I,defineComponent:()=>T,delegateEvents:()=>C.delegateEvents,forwardRef:()=>x,hydrate:()=>R,isValidElement:()=>m,jsx:()=>i,jsxComponent:()=>b,jsxDEV:()=>c,jsxs:()=>p,memo:()=>v,mergeProps:()=>X,renderToString:()=>S});module.exports=A(G);var s=require("@fluixi/dom"),P=require("@fluixi/dom"),f=require("@fluixi/reactive/signal"),a=Symbol.for("fluixi.fragment"),j=typeof window>"u";function J(e){return e==null||e===!1?null:Array.isArray(e)?e.map(J).flat():e}function i(e,t,n){if(e==null)return null;let r=t||{};if(n!==void 0&&(r.key=n),e===a)return(0,f.createMemo)(()=>(0,s.asComponent)(J(r.children)));if(typeof e=="function"){let{type:o}=(0,s.checkRenderType)(e);return e.$$typeof===Symbol.for("react.provider")||o==="provider"?e(r):j?{type:e,props:r}:(0,f.createMemo)(()=>(0,P.createComponent)(e,r),void 0,{name:"jsx component"})}return typeof e=="string"&&e.trim().length>0?F(e,r):null}var p=i;function F(e,t){if(j)return{type:e,props:t||{}};let n=(0,s.isSVGElement)(e),r=n?document.createElementNS("http://www.w3.org/2000/svg",e):document.createElement(e);return N(r,t,n),r}function N(e,t,n){if((0,s.applyProps)(e,t,n),t&&t.children!==void 0){let r=(0,f.readChildren)(()=>t.children);Array.isArray(r)?r.forEach(o=>{(0,s.insert)(e,o,typeof o=="function"?null:void 0)}):(0,s.insert)(e,r,typeof r=="function"?null:void 0)}}function u(e,t,...n){let r={...t};return n.length>0&&(r.children=n.length===1?n[0]:n),i(e,r)}function m(e){return typeof e=="object"&&e!==null&&"type"in e}function d(e,t,...n){return i(e.type,{...e.props,...t,children:n.length?n:e.props.children})}function y(e){return{current:e||null}}function X(...e){let t={};for(let n of e){if(!n)continue;let r=Object.getOwnPropertyDescriptors(n);Object.defineProperties(t,r)}return t}function x(e){return t=>e(t,t.ref)}async function S(e){throw new Error("renderToString should be imported from server module")}function c(e,t,n,r,o,$){return i(e,t,n)}var C=require("@fluixi/dom");var l=require("@fluixi/dom"),g=require("@fluixi/reactive/signal");function h(e){return(0,l.initializeIntegration)({signalSystem:e.signalSystem}),{jsx:i,jsxs:p,jsxDEV:c,Fragment:a,render:(t,n)=>{n&&(0,g.batch)(()=>{for(;n.firstChild;)n.removeChild(n.firstChild);t instanceof Node?n.appendChild(t):Array.isArray(t)&&t.forEach(r=>{r instanceof Node&&n.appendChild(r)})})},batch:g.batch}}function b(e){return e}function T(e,t){return Object.defineProperty(t,"name",{value:e}),t}function v(e,t){let n,r;return o=>(n!==void 0&&(t?t(n,o):K(n,o))||(n=o,r=e(o)),r)}function K(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let o of n)if(e[o]!==t[o])return!1;return!0}function R(e,t){return(0,l.render)(e,t)}var I={jsx:i,jsxs:p,jsxDEV:c,Fragment:a,createElement:u,createRef:y,forwardRef:x,isValidElement:m,cloneElement:d,renderToString:S,createPortal:l.createPortal,render:l.render,hydrate:R,memo:v,jsxComponent:b,defineComponent:T,createReactiveJSX:h};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Main entry point for @fluixi/jsx package
|
|
3
|
+
* @module @fluixi/jsx
|
|
4
|
+
*
|
|
5
|
+
* This package provides a comprehensive JSX runtime with:
|
|
6
|
+
* - Fine-grained reactive updates similar to SolidJS
|
|
7
|
+
* - Support for both lit-html templates and native JSX
|
|
8
|
+
* - Seamless integration with signal and store systems
|
|
9
|
+
* - Optimized DOM updates with compilation support
|
|
10
|
+
*/
|
|
11
|
+
export { jsx, jsxs, Fragment, createElement, createRef, forwardRef, isValidElement, cloneElement, renderToString, } from './jsx-runtime.js';
|
|
12
|
+
export { jsxDEV } from './jsx-dev-runtime.js';
|
|
13
|
+
export type { JSXElement, JSXComponent, JSXProps, RefCallback, RefObject, } from './jsx-runtime.js';
|
|
14
|
+
export { delegateEvents } from '@fluixi/dom';
|
|
15
|
+
export interface ReactiveJSXConfig {
|
|
16
|
+
signalSystem: any;
|
|
17
|
+
}
|
|
18
|
+
export interface ReactiveJSXAPI<Element = any> {
|
|
19
|
+
jsx: typeof jsx;
|
|
20
|
+
jsxs: typeof jsxs;
|
|
21
|
+
jsxDEV: typeof jsxDEV;
|
|
22
|
+
Fragment: typeof Fragment;
|
|
23
|
+
render: (element: any, container: Element) => void;
|
|
24
|
+
batch: (fn: () => void) => void;
|
|
25
|
+
}
|
|
26
|
+
import { jsxDEV } from './jsx-dev-runtime.js';
|
|
27
|
+
import { jsx, jsxs, Fragment, createElement, createRef, forwardRef, isValidElement, cloneElement, renderToString } from './jsx-runtime.js';
|
|
28
|
+
export { mergeProps } from './jsx-runtime.js';
|
|
29
|
+
import { createPortal, render } from '@fluixi/dom';
|
|
30
|
+
/**
|
|
31
|
+
* Create a reactive JSX API with custom configuration
|
|
32
|
+
* @deprecated Use direct imports instead
|
|
33
|
+
*/
|
|
34
|
+
export declare function createReactiveJSX(config: ReactiveJSXConfig): ReactiveJSXAPI;
|
|
35
|
+
/**
|
|
36
|
+
* Helper to create JSX-compatible components
|
|
37
|
+
*/
|
|
38
|
+
export declare function jsxComponent<P = any>(fn: (props: P) => JSX.Element): (props: P) => JSX.Element;
|
|
39
|
+
/**
|
|
40
|
+
* Helper to create JSX-compatible functional components with props validation
|
|
41
|
+
*/
|
|
42
|
+
export declare function defineComponent<P = any>(name: string, fn: (props: P) => JSX.Element): (props: P) => JSX.Element;
|
|
43
|
+
/**
|
|
44
|
+
* Memo wrapper for components
|
|
45
|
+
*/
|
|
46
|
+
export declare function memo<P = any>(component: (props: P) => JSX.Element, equals?: (prev: P, next: P) => boolean): (props: P) => JSX.Element;
|
|
47
|
+
/**
|
|
48
|
+
* Hydrate a server-rendered element
|
|
49
|
+
*/
|
|
50
|
+
export declare function hydrate(element: JSX.Element, container: Element): () => void;
|
|
51
|
+
export type { JSX } from './jsx.d.js';
|
|
52
|
+
export type { FluixiElements } from './jsx.d.js';
|
|
53
|
+
declare const _default: {
|
|
54
|
+
jsx: typeof jsx;
|
|
55
|
+
jsxs: typeof jsx;
|
|
56
|
+
jsxDEV: typeof jsxDEV;
|
|
57
|
+
Fragment: symbol;
|
|
58
|
+
createElement: typeof createElement;
|
|
59
|
+
createRef: typeof createRef;
|
|
60
|
+
forwardRef: typeof forwardRef;
|
|
61
|
+
isValidElement: typeof isValidElement;
|
|
62
|
+
cloneElement: typeof cloneElement;
|
|
63
|
+
renderToString: typeof renderToString;
|
|
64
|
+
createPortal: typeof createPortal;
|
|
65
|
+
render: typeof render;
|
|
66
|
+
hydrate: typeof hydrate;
|
|
67
|
+
memo: typeof memo;
|
|
68
|
+
jsxComponent: typeof jsxComponent;
|
|
69
|
+
defineComponent: typeof defineComponent;
|
|
70
|
+
createReactiveJSX: typeof createReactiveJSX;
|
|
71
|
+
};
|
|
72
|
+
export default _default;
|
|
73
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,OAAO,EAEL,GAAG,EACH,IAAI,EACJ,QAAQ,EAGR,aAAa,EACb,SAAS,EACT,UAAU,EACV,cAAc,EACd,YAAY,EAGZ,cAAc,GAGf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,YAAY,EACV,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,SAAS,GACV,MAAM,kBAAkB,CAAC;AAa1B,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAM7C,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,GAAG,CAAC;CACnB;AAED,MAAM,WAAW,cAAc,CAAC,OAAO,GAAG,GAAG;IAC3C,GAAG,EAAE,OAAO,GAAG,CAAC;IAChB,IAAI,EAAE,OAAO,IAAI,CAAC;IAClB,MAAM,EAAE,OAAO,MAAM,CAAC;IACtB,QAAQ,EAAE,OAAO,QAAQ,CAAC;IAC1B,MAAM,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IACnD,KAAK,EAAE,CAAC,EAAE,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;CACjC;AAED,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EACL,GAAG,EACH,IAAI,EACJ,QAAQ,EACR,aAAa,EACb,SAAS,EACT,UAAU,EACV,cAAc,EACd,YAAY,EACZ,cAAc,EAEf,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAyB,MAAM,EAAE,MAAM,aAAa,CAAC;AAG1E;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,iBAAiB,GAAG,cAAc,CAgC3E;AAMD;;GAEG;AACH,wBAAgB,YAAY,CAAC,CAAC,GAAG,GAAG,EAClC,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,GAAG,CAAC,OAAO,GAC5B,CAAC,KAAK,EAAE,CAAC,KAAK,GAAG,CAAC,OAAO,CAE3B;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,CAAC,GAAG,GAAG,EACrC,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,GAAG,CAAC,OAAO,GAC5B,CAAC,KAAK,EAAE,CAAC,KAAK,GAAG,CAAC,OAAO,CAG3B;AAED;;GAEG;AACH,wBAAgB,IAAI,CAAC,CAAC,GAAG,GAAG,EAC1B,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,GAAG,CAAC,OAAO,EACpC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,KAAK,OAAO,GACrC,CAAC,KAAK,EAAE,CAAC,KAAK,GAAG,CAAC,OAAO,CAe3B;AAuBD;;GAEG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,GAAG,MAAM,IAAI,CAG5E;AAMD,YAAY,EAAC,GAAG,EAAC,MAAM,YAAY,CAAC;AACpC,YAAY,EAAC,cAAc,EAAC,MAAM,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;AAM/C,wBAkBE"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Main entry point for @fluixi/jsx package
|
|
3
|
+
* @module @fluixi/jsx
|
|
4
|
+
*
|
|
5
|
+
* This package provides a comprehensive JSX runtime with:
|
|
6
|
+
* - Fine-grained reactive updates similar to SolidJS
|
|
7
|
+
* - Support for both lit-html templates and native JSX
|
|
8
|
+
* - Seamless integration with signal and store systems
|
|
9
|
+
* - Optimized DOM updates with compilation support
|
|
10
|
+
*/
|
|
11
|
+
// ============================================================================
|
|
12
|
+
// Core JSX Runtime
|
|
13
|
+
// ============================================================================
|
|
14
|
+
export {
|
|
15
|
+
// JSX factory functions
|
|
16
|
+
jsx, jsxs, Fragment,
|
|
17
|
+
// Element creation
|
|
18
|
+
createElement, createRef, forwardRef, isValidElement, cloneElement,
|
|
19
|
+
// Rendering
|
|
20
|
+
renderToString,
|
|
21
|
+
// delegateEvents,
|
|
22
|
+
// handleRef,
|
|
23
|
+
} from './jsx-runtime.js';
|
|
24
|
+
export { jsxDEV } from './jsx-dev-runtime.js';
|
|
25
|
+
// ============================================================================
|
|
26
|
+
// Compiler Utilities
|
|
27
|
+
// ============================================================================
|
|
28
|
+
// Build-time compiler utilities live in @fluixi/compiler (Node.js only):
|
|
29
|
+
// import { createVitePlugin } from '@fluixi/compiler/integrations'
|
|
30
|
+
// ============================================================================
|
|
31
|
+
// Legacy API (for backward compatibility)
|
|
32
|
+
// ============================================================================
|
|
33
|
+
export { delegateEvents } from '@fluixi/dom';
|
|
34
|
+
import { jsxDEV } from './jsx-dev-runtime.js';
|
|
35
|
+
import { jsx, jsxs, Fragment, createElement, createRef, forwardRef, isValidElement, cloneElement, renderToString,
|
|
36
|
+
// createPortal,
|
|
37
|
+
} from './jsx-runtime.js';
|
|
38
|
+
export { mergeProps } from './jsx-runtime.js';
|
|
39
|
+
import { createPortal, initializeIntegration, render } from '@fluixi/dom';
|
|
40
|
+
import { batch } from '@fluixi/reactive/signal';
|
|
41
|
+
/**
|
|
42
|
+
* Create a reactive JSX API with custom configuration
|
|
43
|
+
* @deprecated Use direct imports instead
|
|
44
|
+
*/
|
|
45
|
+
export function createReactiveJSX(config) {
|
|
46
|
+
// Initialize integration with signal system
|
|
47
|
+
initializeIntegration({
|
|
48
|
+
signalSystem: config.signalSystem,
|
|
49
|
+
});
|
|
50
|
+
return {
|
|
51
|
+
jsx,
|
|
52
|
+
jsxs,
|
|
53
|
+
jsxDEV,
|
|
54
|
+
Fragment,
|
|
55
|
+
render: (element, container) => {
|
|
56
|
+
if (!container)
|
|
57
|
+
return;
|
|
58
|
+
batch(() => {
|
|
59
|
+
while (container.firstChild) {
|
|
60
|
+
container.removeChild(container.firstChild);
|
|
61
|
+
}
|
|
62
|
+
if (element instanceof Node) {
|
|
63
|
+
container.appendChild(element);
|
|
64
|
+
}
|
|
65
|
+
else if (Array.isArray(element)) {
|
|
66
|
+
element.forEach((el) => {
|
|
67
|
+
if (el instanceof Node) {
|
|
68
|
+
container.appendChild(el);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
},
|
|
74
|
+
batch,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
// ============================================================================
|
|
78
|
+
// Component Helpers
|
|
79
|
+
// ============================================================================
|
|
80
|
+
/**
|
|
81
|
+
* Helper to create JSX-compatible components
|
|
82
|
+
*/
|
|
83
|
+
export function jsxComponent(fn) {
|
|
84
|
+
return fn;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Helper to create JSX-compatible functional components with props validation
|
|
88
|
+
*/
|
|
89
|
+
export function defineComponent(name, fn) {
|
|
90
|
+
Object.defineProperty(fn, 'name', { value: name });
|
|
91
|
+
return fn;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Memo wrapper for components
|
|
95
|
+
*/
|
|
96
|
+
export function memo(component, equals) {
|
|
97
|
+
let lastProps;
|
|
98
|
+
let lastResult;
|
|
99
|
+
return (props) => {
|
|
100
|
+
if (lastProps !== undefined) {
|
|
101
|
+
if (equals ? equals(lastProps, props) : shallowEqual(lastProps, props)) {
|
|
102
|
+
return lastResult;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
lastProps = props;
|
|
106
|
+
lastResult = component(props);
|
|
107
|
+
return lastResult;
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
function shallowEqual(a, b) {
|
|
111
|
+
if (a === b)
|
|
112
|
+
return true;
|
|
113
|
+
if (typeof a !== 'object' || typeof b !== 'object')
|
|
114
|
+
return false;
|
|
115
|
+
if (a === null || b === null)
|
|
116
|
+
return false;
|
|
117
|
+
const keysA = Object.keys(a);
|
|
118
|
+
const keysB = Object.keys(b);
|
|
119
|
+
if (keysA.length !== keysB.length)
|
|
120
|
+
return false;
|
|
121
|
+
for (const key of keysA) {
|
|
122
|
+
if (a[key] !== b[key])
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
// ============================================================================
|
|
128
|
+
// Render Function
|
|
129
|
+
// ============================================================================
|
|
130
|
+
/**
|
|
131
|
+
* Hydrate a server-rendered element
|
|
132
|
+
*/
|
|
133
|
+
export function hydrate(element, container) {
|
|
134
|
+
// For now, just render (full hydration would be more complex)
|
|
135
|
+
return render(element, container);
|
|
136
|
+
}
|
|
137
|
+
// ============================================================================
|
|
138
|
+
// Default Export
|
|
139
|
+
// ============================================================================
|
|
140
|
+
export default {
|
|
141
|
+
jsx,
|
|
142
|
+
jsxs,
|
|
143
|
+
jsxDEV,
|
|
144
|
+
Fragment,
|
|
145
|
+
createElement: createElement,
|
|
146
|
+
createRef: createRef,
|
|
147
|
+
forwardRef: forwardRef,
|
|
148
|
+
isValidElement: isValidElement,
|
|
149
|
+
cloneElement: cloneElement,
|
|
150
|
+
renderToString: renderToString,
|
|
151
|
+
createPortal: createPortal,
|
|
152
|
+
render,
|
|
153
|
+
hydrate,
|
|
154
|
+
memo,
|
|
155
|
+
jsxComponent,
|
|
156
|
+
defineComponent,
|
|
157
|
+
createReactiveJSX,
|
|
158
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{insert as y,isSVGElement as j,asComponent as J,checkRenderType as X,applyProps as h}from"@fluixi/dom";import{createComponent as b}from"@fluixi/dom";import{createSignal as ne,createMemo as x,readChildren as T}from"@fluixi/reactive/signal";var i=Symbol.for("fluixi.fragment"),S=typeof window>"u";function E(e){return e==null||e===!1?null:Array.isArray(e)?e.map(E).flat():e}function s(e,t,n){if(e==null)return null;let r=t||{};if(n!==void 0&&(r.key=n),e===i)return x(()=>J(E(r.children)));if(typeof e=="function"){let{type:o}=X(e);return e.$$typeof===Symbol.for("react.provider")||o==="provider"?e(r):S?{type:e,props:r}:x(()=>b(e,r),void 0,{name:"jsx component"})}return typeof e=="string"&&e.trim().length>0?v(e,r):null}var a=s;function v(e,t){if(S)return{type:e,props:t||{}};let n=j(e),r=n?document.createElementNS("http://www.w3.org/2000/svg",e):document.createElement(e);return R(r,t,n),r}function R(e,t,n){if(h(e,t,n),t&&t.children!==void 0){let r=T(()=>t.children);Array.isArray(r)?r.forEach(o=>{y(e,o,typeof o=="function"?null:void 0)}):y(e,r,typeof r=="function"?null:void 0)}}function f(e,t,...n){let r={...t};return n.length>0&&(r.children=n.length===1?n[0]:n),s(e,r)}function p(e){return typeof e=="object"&&e!==null&&"type"in e}function c(e,t,...n){return s(e.type,{...e.props,...t,children:n.length?n:e.props.children})}function u(e){return{current:e||null}}function C(...e){let t={};for(let n of e){if(!n)continue;let r=Object.getOwnPropertyDescriptors(n);Object.defineProperties(t,r)}return t}function m(e){return t=>e(t,t.ref)}async function d(e){throw new Error("renderToString should be imported from server module")}function l(e,t,n,r,o,K){return s(e,t,n)}import{delegateEvents as ge}from"@fluixi/dom";import{createPortal as w,initializeIntegration as k,render as P}from"@fluixi/dom";import{batch as g}from"@fluixi/reactive/signal";function O(e){return k({signalSystem:e.signalSystem}),{jsx:s,jsxs:a,jsxDEV:l,Fragment:i,render:(t,n)=>{n&&g(()=>{for(;n.firstChild;)n.removeChild(n.firstChild);t instanceof Node?n.appendChild(t):Array.isArray(t)&&t.forEach(r=>{r instanceof Node&&n.appendChild(r)})})},batch:g}}function V(e){return e}function D(e,t){return Object.defineProperty(t,"name",{value:e}),t}function A(e,t){let n,r;return o=>(n!==void 0&&(t?t(n,o):F(n,o))||(n=o,r=e(o)),r)}function F(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let o of n)if(e[o]!==t[o])return!1;return!0}function N(e,t){return P(e,t)}var de={jsx:s,jsxs:a,jsxDEV:l,Fragment:i,createElement:f,createRef:u,forwardRef:m,isValidElement:p,cloneElement:c,renderToString:d,createPortal:w,render:P,hydrate:N,memo:A,jsxComponent:V,defineComponent:D,createReactiveJSX:O};export{i as Fragment,c as cloneElement,f as createElement,O as createReactiveJSX,u as createRef,de as default,D as defineComponent,ge as delegateEvents,m as forwardRef,N as hydrate,p as isValidElement,s as jsx,V as jsxComponent,l as jsxDEV,a as jsxs,A as memo,C as mergeProps,d as renderToString};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var l=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var g=(e,n)=>{for(var r in n)l(e,r,{get:n[r],enumerable:!0})},x=(e,n,r,t)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of y(n))!S.call(e,o)&&o!==r&&l(e,o,{get:()=>n[o],enumerable:!(t=m(n,o))||t.enumerable});return e};var T=e=>x(l({},"__esModule",{value:!0}),e);var h={};g(h,{Fragment:()=>c,jsx:()=>a,jsxDEV:()=>P,jsxs:()=>d});module.exports=T(h);var s=require("@fluixi/dom"),u=require("@fluixi/dom"),i=require("@fluixi/reactive/signal"),c=Symbol.for("fluixi.fragment"),p=typeof window>"u";function f(e){return e==null||e===!1?null:Array.isArray(e)?e.map(f).flat():e}function a(e,n,r){if(e==null)return null;let t=n||{};if(r!==void 0&&(t.key=r),e===c)return(0,i.createMemo)(()=>(0,s.asComponent)(f(t.children)));if(typeof e=="function"){let{type:o}=(0,s.checkRenderType)(e);return e.$$typeof===Symbol.for("react.provider")||o==="provider"?e(t):p?{type:e,props:t}:(0,i.createMemo)(()=>(0,u.createComponent)(e,t),void 0,{name:"jsx component"})}return typeof e=="string"&&e.trim().length>0?E(e,t):null}var d=a;function E(e,n){if(p)return{type:e,props:n||{}};let r=(0,s.isSVGElement)(e),t=r?document.createElementNS("http://www.w3.org/2000/svg",e):document.createElement(e);return b(t,n,r),t}function b(e,n,r){if((0,s.applyProps)(e,n,r),n&&n.children!==void 0){let t=(0,i.readChildren)(()=>n.children);Array.isArray(t)?t.forEach(o=>{(0,s.insert)(e,o,typeof o=="function"?null:void 0)}):(0,s.insert)(e,t,typeof t=="function"?null:void 0)}}function P(e,n,r,t,o,J){return a(e,n,r)}
|
|
@@ -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 @@
|
|
|
1
|
+
import{insert as i,isSVGElement as p,asComponent as f,checkRenderType as d,applyProps as m}from"@fluixi/dom";import{createComponent as y}from"@fluixi/dom";import{createSignal as F,createMemo as a,readChildren as S}from"@fluixi/reactive/signal";var l=Symbol.for("fluixi.fragment"),c=typeof window>"u";function u(e){return e==null||e===!1?null:Array.isArray(e)?e.map(u).flat():e}function s(e,t,r){if(e==null)return null;let n=t||{};if(r!==void 0&&(n.key=r),e===l)return a(()=>f(u(n.children)));if(typeof e=="function"){let{type:o}=d(e);return e.$$typeof===Symbol.for("react.provider")||o==="provider"?e(n):c?{type:e,props:n}:a(()=>y(e,n),void 0,{name:"jsx component"})}return typeof e=="string"&&e.trim().length>0?x(e,n):null}var g=s;function x(e,t){if(c)return{type:e,props:t||{}};let r=p(e),n=r?document.createElementNS("http://www.w3.org/2000/svg",e):document.createElement(e);return T(n,t,r),n}function T(e,t,r){if(m(e,t,r),t&&t.children!==void 0){let n=S(()=>t.children);Array.isArray(n)?n.forEach(o=>{i(e,o,typeof o=="function"?null:void 0)}):i(e,n,typeof n=="function"?null:void 0)}}function q(e,t,r,n,o,E){return s(e,t,r)}export{l as Fragment,s as jsx,q as jsxDEV,g as jsxs};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var f=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var x=(e,n)=>{for(var t in n)f(e,t,{get:n[t],enumerable:!0})},T=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of S(n))!g.call(e,o)&&o!==t&&f(e,o,{get:()=>n[o],enumerable:!(r=m(n,o))||r.enumerable});return e};var E=e=>T(f({},"__esModule",{value:!0}),e);var K={};x(K,{Fragment:()=>p,cloneElement:()=>J,createElement:()=>w,createRef:()=>X,delegatedSet:()=>b,forwardRef:()=>A,isValidElement:()=>v,jsx:()=>l,jsxDEV:()=>R,jsxs:()=>P,mergeProps:()=>O,renderToString:()=>D,splitProps:()=>C,useRef:()=>k});module.exports=E(K);var s=require("@fluixi/dom"),c=require("@fluixi/dom"),i=require("@fluixi/reactive/signal"),p=Symbol.for("fluixi.fragment"),d=typeof window>"u",b=new Set;function y(e){return e==null||e===!1?null:Array.isArray(e)?e.map(y).flat():e}function l(e,n,t){if(e==null)return null;let r=n||{};if(t!==void 0&&(r.key=t),e===p)return(0,i.createMemo)(()=>(0,s.asComponent)(y(r.children)));if(typeof e=="function"){let{type:o}=(0,s.checkRenderType)(e);return e.$$typeof===Symbol.for("react.provider")||o==="provider"?e(r):d?{type:e,props:r}:(0,i.createMemo)(()=>(0,c.createComponent)(e,r),void 0,{name:"jsx component"})}return typeof e=="string"&&e.trim().length>0?h(e,r):null}var P=l;function R(e,n,t,r){return l(e,n,t)}function h(e,n){if(d)return{type:e,props:n||{}};let t=(0,s.isSVGElement)(e),r=t?document.createElementNS("http://www.w3.org/2000/svg",e):document.createElement(e);return j(r,n,t),r}function j(e,n,t){if((0,s.applyProps)(e,n,t),n&&n.children!==void 0){let r=(0,i.readChildren)(()=>n.children);Array.isArray(r)?r.forEach(o=>{(0,s.insert)(e,o,typeof o=="function"?null:void 0)}):(0,s.insert)(e,r,typeof r=="function"?null:void 0)}}function w(e,n,...t){let r={...n};return t.length>0&&(r.children=t.length===1?t[0]:t),l(e,r)}function v(e){return typeof e=="object"&&e!==null&&"type"in e}function J(e,n,...t){return l(e.type,{...e.props,...n,children:t.length?t:e.props.children})}function X(e){return{current:e||null}}function k(e){let[n,t]=(0,i.createSignal)(e??null);return{get current(){return n()},set current(r){t(r)}}}function O(...e){let n={};for(let t of e){if(!t)continue;let r=Object.getOwnPropertyDescriptors(t);Object.defineProperties(n,r)}return n}function C(e,n){let t={},r={},o=new Set(n),u=Object.getOwnPropertyDescriptors(e);for(let a in u)o.has(a)?Object.defineProperty(t,a,u[a]):Object.defineProperty(r,a,u[a]);return[t,r]}function A(e){return n=>e(n,n.ref)}async function D(e){throw new Error("renderToString should be imported from server module")}
|
|
@@ -0,0 +1,58 @@
|
|
|
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 type { TemplateResult, SVGTemplateResult } from 'lit';
|
|
10
|
+
export type JSXElement = TemplateResult | SVGTemplateResult | Node | string | number | boolean | null | undefined | JSXElement[];
|
|
11
|
+
export type JSXComponent<P = any> = (props: P) => JSXElement;
|
|
12
|
+
export interface JSXProps {
|
|
13
|
+
children?: JSXElement;
|
|
14
|
+
ref?: any;
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
}
|
|
17
|
+
export type RefCallback<T> = (instance: T) => void;
|
|
18
|
+
export type RefObject<T> = {
|
|
19
|
+
current: T | null;
|
|
20
|
+
};
|
|
21
|
+
export declare const Fragment: unique symbol;
|
|
22
|
+
declare const globalDelegatedSet: Set<string>;
|
|
23
|
+
/**
|
|
24
|
+
* Main JSX factory function.
|
|
25
|
+
* - String tags → native DOM element
|
|
26
|
+
* - Function tags → component (wrapped in createMemo for reactivity)
|
|
27
|
+
* - Fragment → children array
|
|
28
|
+
*/
|
|
29
|
+
export declare function jsx(type: any, props: any, key?: string): JSXElement;
|
|
30
|
+
export declare const jsxs: typeof jsx;
|
|
31
|
+
export declare function jsxDEV(type: any, props: any, key?: string, _isStaticChildren?: boolean): JSXElement;
|
|
32
|
+
export declare function createElement(type: any, props: any, ...children: any[]): JSXElement;
|
|
33
|
+
export declare function isValidElement(object: any): boolean;
|
|
34
|
+
export declare function cloneElement(element: any, props: any, ...children: any[]): any;
|
|
35
|
+
export declare function createRef<T>(initialValue?: T): {
|
|
36
|
+
current: NonNullable<T> | null;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Create a reactive ref compatible with `ref={...}` JSX prop.
|
|
40
|
+
* The `.current` property is backed by a signal for reactive tracking.
|
|
41
|
+
*/
|
|
42
|
+
export declare function useRef<T>(initialValue?: T): {
|
|
43
|
+
current: T | null | undefined;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Merge multiple props objects reactively.
|
|
47
|
+
* Getters from each source are preserved for reactive prop access.
|
|
48
|
+
*/
|
|
49
|
+
export declare function mergeProps<T extends object>(...sources: Partial<T>[]): T;
|
|
50
|
+
/**
|
|
51
|
+
* Split props into two objects: one with the specified keys, one with the rest.
|
|
52
|
+
*/
|
|
53
|
+
export declare function splitProps<T extends object, K extends keyof T>(props: T, keys: K[]): [Pick<T, K>, Omit<T, K>];
|
|
54
|
+
export declare function forwardRef(fn: Function): (props: any) => any;
|
|
55
|
+
export declare function renderToString(element: JSXElement): Promise<string>;
|
|
56
|
+
export { globalDelegatedSet as delegatedSet };
|
|
57
|
+
export type { JSX } from './jsx.d.js';
|
|
58
|
+
//# 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;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,KAAK,CAAC;AA+B7D,MAAM,MAAM,UAAU,GAClB,cAAc,GACd,iBAAiB,GACjB,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;AAuCD,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,181 @@
|
|
|
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 { insert, isSVGElement, asComponent, checkRenderType, applyProps as domProps } from '@fluixi/dom';
|
|
10
|
+
import { createComponent } from '@fluixi/dom';
|
|
11
|
+
import { createSignal, createMemo, readChildren } 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
|
+
const isSVG = isSVGElement(tag);
|
|
87
|
+
const element = isSVG
|
|
88
|
+
? document.createElementNS('http://www.w3.org/2000/svg', tag)
|
|
89
|
+
: document.createElement(tag);
|
|
90
|
+
applyProps(element, props, isSVG);
|
|
91
|
+
return element;
|
|
92
|
+
}
|
|
93
|
+
// Apply JSX props to a DOM element (via domProps), then insert its children.
|
|
94
|
+
function applyProps(element, props, isSVG) {
|
|
95
|
+
domProps(element, props, isSVG);
|
|
96
|
+
if (props && props.children !== undefined) {
|
|
97
|
+
const children = readChildren(() => props.children);
|
|
98
|
+
if (Array.isArray(children)) {
|
|
99
|
+
children.forEach((c) => {
|
|
100
|
+
insert(element, c, (typeof c === 'function' ? null : undefined));
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
insert(element, children, (typeof children === 'function' ? null : undefined));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// ============================================================================
|
|
109
|
+
// Additional Exports
|
|
110
|
+
// ============================================================================
|
|
111
|
+
export function createElement(type, props, ...children) {
|
|
112
|
+
const p = { ...props };
|
|
113
|
+
if (children.length > 0)
|
|
114
|
+
p.children = children.length === 1 ? children[0] : children;
|
|
115
|
+
return jsx(type, p);
|
|
116
|
+
}
|
|
117
|
+
export function isValidElement(object) {
|
|
118
|
+
return typeof object === 'object' && object !== null && 'type' in object;
|
|
119
|
+
}
|
|
120
|
+
export function cloneElement(element, props, ...children) {
|
|
121
|
+
return jsx(element.type, {
|
|
122
|
+
...element.props,
|
|
123
|
+
...props,
|
|
124
|
+
children: children.length ? children : element.props.children,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
export function createRef(initialValue) {
|
|
128
|
+
return { current: initialValue || null };
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Create a reactive ref compatible with `ref={...}` JSX prop.
|
|
132
|
+
* The `.current` property is backed by a signal for reactive tracking.
|
|
133
|
+
*/
|
|
134
|
+
export function useRef(initialValue) {
|
|
135
|
+
const [get, set] = createSignal(initialValue ?? null);
|
|
136
|
+
return {
|
|
137
|
+
get current() { return get(); },
|
|
138
|
+
set current(v) { set(v); },
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Merge multiple props objects reactively.
|
|
143
|
+
* Getters from each source are preserved for reactive prop access.
|
|
144
|
+
*/
|
|
145
|
+
export function mergeProps(...sources) {
|
|
146
|
+
const target = {};
|
|
147
|
+
for (const source of sources) {
|
|
148
|
+
if (!source)
|
|
149
|
+
continue;
|
|
150
|
+
const descriptors = Object.getOwnPropertyDescriptors(source);
|
|
151
|
+
Object.defineProperties(target, descriptors);
|
|
152
|
+
}
|
|
153
|
+
return target;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Split props into two objects: one with the specified keys, one with the rest.
|
|
157
|
+
*/
|
|
158
|
+
export function splitProps(props, keys) {
|
|
159
|
+
const picked = {};
|
|
160
|
+
const rest = {};
|
|
161
|
+
const keySet = new Set(keys);
|
|
162
|
+
const descriptors = Object.getOwnPropertyDescriptors(props);
|
|
163
|
+
for (const key in descriptors) {
|
|
164
|
+
if (keySet.has(key)) {
|
|
165
|
+
Object.defineProperty(picked, key, descriptors[key]);
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
Object.defineProperty(rest, key, descriptors[key]);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return [picked, rest];
|
|
172
|
+
}
|
|
173
|
+
export function forwardRef(fn) {
|
|
174
|
+
return (props) => fn(props, props.ref);
|
|
175
|
+
}
|
|
176
|
+
export async function renderToString(element) {
|
|
177
|
+
// Use @lit-labs/ssr or implementation from server module
|
|
178
|
+
throw new Error('renderToString should be imported from server module');
|
|
179
|
+
}
|
|
180
|
+
// Re-export delegatedSet accessor for the runtime to check
|
|
181
|
+
export { globalDelegatedSet as delegatedSet };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{insert as l,isSVGElement as p,asComponent as d,checkRenderType as y,applyProps as m}from"@fluixi/dom";import{createComponent as S}from"@fluixi/dom";import{createSignal as g,createMemo as u,readChildren as x}from"@fluixi/reactive/signal";var T=Symbol.for("fluixi.fragment"),f=typeof window>"u",L=new Set;function c(e){return e==null||e===!1?null:Array.isArray(e)?e.map(c).flat():e}function i(e,n,t){if(e==null)return null;let r=n||{};if(t!==void 0&&(r.key=t),e===T)return u(()=>d(c(r.children)));if(typeof e=="function"){let{type:o}=y(e);return e.$$typeof===Symbol.for("react.provider")||o==="provider"?e(r):f?{type:e,props:r}:u(()=>S(e,r),void 0,{name:"jsx component"})}return typeof e=="string"&&e.trim().length>0?E(e,r):null}var $=i;function z(e,n,t,r){return i(e,n,t)}function E(e,n){if(f)return{type:e,props:n||{}};let t=p(e),r=t?document.createElementNS("http://www.w3.org/2000/svg",e):document.createElement(e);return b(r,n,t),r}function b(e,n,t){if(m(e,n,t),n&&n.children!==void 0){let r=x(()=>n.children);Array.isArray(r)?r.forEach(o=>{l(e,o,typeof o=="function"?null:void 0)}):l(e,r,typeof r=="function"?null:void 0)}}function M(e,n,...t){let r={...n};return t.length>0&&(r.children=t.length===1?t[0]:t),i(e,r)}function _(e){return typeof e=="object"&&e!==null&&"type"in e}function q(e,n,...t){return i(e.type,{...e.props,...n,children:t.length?t:e.props.children})}function B(e){return{current:e||null}}function H(e){let[n,t]=g(e??null);return{get current(){return n()},set current(r){t(r)}}}function I(...e){let n={};for(let t of e){if(!t)continue;let r=Object.getOwnPropertyDescriptors(t);Object.defineProperties(n,r)}return n}function Q(e,n){let t={},r={},o=new Set(n),a=Object.getOwnPropertyDescriptors(e);for(let s in a)o.has(s)?Object.defineProperty(t,s,a[s]):Object.defineProperty(r,s,a[s]);return[t,r]}function U(e){return n=>e(n,n.ref)}async function W(e){throw new Error("renderToString should be imported from server module")}export{T as Fragment,q as cloneElement,M as createElement,B as createRef,L as delegatedSet,U as forwardRef,_ as isValidElement,i as jsx,z as jsxDEV,$ as jsxs,I as mergeProps,W as renderToString,Q as splitProps,H as useRef};
|