sinwan 0.1.0 → 1.1.0
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/README.md +66 -39
- package/dist/cjs/index.development.js +2373 -842
- package/dist/cjs/index.development.js.map +22 -18
- package/dist/cjs/index.production.min.js +2 -2
- package/dist/cjs/index.production.min.js.map +22 -18
- package/dist/cjs/jsx/jsx-dev-runtime.development.js +6 -16
- package/dist/cjs/jsx/jsx-dev-runtime.development.js.map +3 -3
- package/dist/cjs/jsx/jsx-dev-runtime.production.min.js +2 -2
- package/dist/cjs/jsx/jsx-dev-runtime.production.min.js.map +3 -3
- package/dist/cjs/jsx/jsx-runtime.development.js +6 -16
- package/dist/cjs/jsx/jsx-runtime.development.js.map +3 -3
- package/dist/cjs/jsx/jsx-runtime.production.min.js +2 -2
- package/dist/cjs/jsx/jsx-runtime.production.min.js.map +3 -3
- package/dist/cjs/renderer/index.development.js +1581 -0
- package/dist/cjs/renderer/index.development.js.map +25 -0
- package/dist/cjs/renderer/index.production.min.js +3 -0
- package/dist/cjs/renderer/index.production.min.js.map +25 -0
- package/dist/cjs/server/index.development.js +1210 -362
- package/dist/cjs/server/index.development.js.map +13 -10
- package/dist/cjs/server/index.production.min.js +2 -2
- package/dist/cjs/server/index.production.min.js.map +13 -10
- package/dist/component/control-flow.d.ts +71 -0
- package/dist/component/control-flow.d.ts.map +1 -0
- package/dist/component/index.d.ts +3 -1
- package/dist/component/index.d.ts.map +1 -1
- package/dist/component/instance.d.ts +7 -1
- package/dist/component/instance.d.ts.map +1 -1
- package/dist/component/lifecycle.d.ts +2 -1
- package/dist/component/lifecycle.d.ts.map +1 -1
- package/dist/component/provide-inject.d.ts +11 -5
- package/dist/component/provide-inject.d.ts.map +1 -1
- package/dist/esm/index.development.js +2253 -744
- package/dist/esm/index.development.js.map +22 -18
- package/dist/esm/index.production.min.js +2 -2
- package/dist/esm/index.production.min.js.map +22 -18
- package/dist/esm/jsx/jsx-dev-runtime.development.js +6 -16
- package/dist/esm/jsx/jsx-dev-runtime.development.js.map +3 -3
- package/dist/esm/jsx/jsx-dev-runtime.production.min.js +2 -2
- package/dist/esm/jsx/jsx-dev-runtime.production.min.js.map +3 -3
- package/dist/esm/jsx/jsx-runtime.development.js +6 -16
- package/dist/esm/jsx/jsx-runtime.development.js.map +3 -3
- package/dist/esm/jsx/jsx-runtime.production.min.js +2 -2
- package/dist/esm/jsx/jsx-runtime.production.min.js.map +3 -3
- package/dist/esm/renderer/index.development.js +1530 -0
- package/dist/esm/renderer/index.development.js.map +25 -0
- package/dist/esm/renderer/index.production.min.js +4 -0
- package/dist/esm/renderer/index.production.min.js.map +25 -0
- package/dist/esm/server/index.development.js +1210 -362
- package/dist/esm/server/index.development.js.map +13 -10
- package/dist/esm/server/index.production.min.js +2 -2
- package/dist/esm/server/index.production.min.js.map +13 -10
- package/dist/hydration/walk.d.ts.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/jsx/jsx-runtime.d.ts +13 -0
- package/dist/jsx/jsx-runtime.d.ts.map +1 -1
- package/dist/jsx/jsx-types.d.ts +122 -57
- package/dist/jsx/jsx-types.d.ts.map +1 -1
- package/dist/renderer/attributes.d.ts +11 -0
- package/dist/renderer/attributes.d.ts.map +1 -1
- package/dist/renderer/dom-ops.d.ts +4 -1
- package/dist/renderer/dom-ops.d.ts.map +1 -1
- package/dist/renderer/index.d.ts +2 -2
- package/dist/renderer/index.d.ts.map +1 -1
- package/dist/renderer/mount.d.ts +2 -5
- package/dist/renderer/mount.d.ts.map +1 -1
- package/dist/renderer/render-children.d.ts +2 -2
- package/dist/renderer/render-children.d.ts.map +1 -1
- package/dist/renderer/render-control-flow.d.ts +13 -0
- package/dist/renderer/render-control-flow.d.ts.map +1 -0
- package/dist/renderer/render-element.d.ts +1 -1
- package/dist/renderer/render-element.d.ts.map +1 -1
- package/dist/renderer/types.d.ts +10 -1
- package/dist/renderer/types.d.ts.map +1 -1
- package/dist/renderer/unmount.d.ts +20 -0
- package/dist/renderer/unmount.d.ts.map +1 -0
- package/dist/renderer.d.ts +1 -0
- package/dist/renderer.js +7 -0
- package/dist/renderer.mjs +4 -0
- package/dist/server/attribute-utils.d.ts +2 -0
- package/dist/server/attribute-utils.d.ts.map +1 -0
- package/dist/server/hydration-markers.d.ts.map +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/renderer.d.ts.map +1 -1
- package/dist/server/stream.d.ts +9 -1
- package/dist/server/stream.d.ts.map +1 -1
- package/dist/types.d.ts +8 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +19 -5
|
@@ -40,22 +40,12 @@ function buildElement(type, props, children) {
|
|
|
40
40
|
if (type === Fragment) {
|
|
41
41
|
return { tag: "", props: {}, children };
|
|
42
42
|
}
|
|
43
|
-
if (typeof type === "function") {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return result2;
|
|
48
|
-
}
|
|
49
|
-
return { tag: "", props: {}, children: normalizeChildren(result2) };
|
|
43
|
+
if (typeof type === "function" || typeof type === "string") {
|
|
44
|
+
const finalProps = props ?? {};
|
|
45
|
+
if (children.length > 0 && finalProps.children === undefined) {
|
|
46
|
+
finalProps.children = children.length === 1 ? children[0] : children;
|
|
50
47
|
}
|
|
51
|
-
|
|
52
|
-
if (result && typeof result === "object" && "tag" in result) {
|
|
53
|
-
return result;
|
|
54
|
-
}
|
|
55
|
-
return { tag: "", props: {}, children: normalizeChildren(result) };
|
|
56
|
-
}
|
|
57
|
-
if (typeof type === "string") {
|
|
58
|
-
return { tag: type, props: props || {}, children };
|
|
48
|
+
return { tag: type, props: finalProps, children };
|
|
59
49
|
}
|
|
60
50
|
return { tag: "", props: {}, children };
|
|
61
51
|
}
|
|
@@ -79,5 +69,5 @@ export {
|
|
|
79
69
|
Fragment
|
|
80
70
|
};
|
|
81
71
|
|
|
82
|
-
//# debugId=
|
|
72
|
+
//# debugId=43EDA70A864BB78364756E2164756E21
|
|
83
73
|
//# sourceMappingURL=jsx-dev-runtime.development.js.map
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/jsx/jsx-runtime.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * SinwanJS View Module — JSX Runtime\n *\n * JSX factory that returns SinwanElement structures for the view renderer.\n * Imported automatically when using JSX syntax.\n */\n\nimport type { SinwanElement, SinwanNode } from \"../types.ts\";\nimport type { SinwanIntrinsicElements } from \"./jsx-types\";\n\nexport const Fragment = Symbol(\"Fragment\");\n\n/**\n * A string that has been marked as safe HTML (already escaped).\n * Used for raw HTML injection with explicit trust marking.\n */\nexport class HtmlEscapedString extends String {\n constructor(public readonly value: string) {\n super(value);\n }\n override toString() {\n return this.value;\n }\n}\n\nexport const raw = (str: string) => new HtmlEscapedString(str);\n\n// Fast path for intrinsic elements\nconst VOID_ELEMENTS = new Set([\n \"area\",\n \"base\",\n \"br\",\n \"col\",\n \"embed\",\n \"hr\",\n \"img\",\n \"input\",\n \"link\",\n \"meta\",\n \"param\",\n \"source\",\n \"track\",\n \"wbr\",\n]);\n\n/**\n * Normalize children into an array of SinwanNode.\n */\nfunction normalizeChildren(children: any): SinwanNode[] {\n if (children == null || typeof children === \"boolean\") return [];\n if (Array.isArray(children)) return children.flat(Infinity);\n return [children];\n}\n\n/**\n * Build an SinwanElement from a component/tag invocation.\n * Shared logic for jsx, jsxs, and jsxDEV.\n */\nfunction buildElement(\n type: any,\n props: any,\n children: SinwanNode[],\n): SinwanElement {\n // Handle Fragment\n if (type === Fragment) {\n return { tag: \"\", props: {}, children };\n }\n\n //
|
|
5
|
+
"/**\n * SinwanJS View Module — JSX Runtime\n *\n * JSX factory that returns SinwanElement structures for the view renderer.\n * Imported automatically when using JSX syntax.\n */\n\nimport type { SinwanElement, SinwanNode } from \"../types.ts\";\nimport type { SinwanIntrinsicElements } from \"./jsx-types\";\n\nexport const Fragment = Symbol(\"Fragment\");\n\n/**\n * A string that has been marked as safe HTML (already escaped).\n * Used for raw HTML injection with explicit trust marking.\n */\nexport class HtmlEscapedString extends String {\n constructor(public readonly value: string) {\n super(value);\n }\n override toString() {\n return this.value;\n }\n}\n\nexport const raw = (str: string) => new HtmlEscapedString(str);\n\n// Fast path for intrinsic elements\nconst VOID_ELEMENTS = new Set([\n \"area\",\n \"base\",\n \"br\",\n \"col\",\n \"embed\",\n \"hr\",\n \"img\",\n \"input\",\n \"link\",\n \"meta\",\n \"param\",\n \"source\",\n \"track\",\n \"wbr\",\n]);\n\n/**\n * Normalize children into an array of SinwanNode.\n */\nfunction normalizeChildren(children: any): SinwanNode[] {\n if (children == null || typeof children === \"boolean\") return [];\n if (Array.isArray(children)) return children.flat(Infinity);\n return [children];\n}\n\n/**\n * Build an SinwanElement from a component/tag invocation.\n * Shared logic for jsx, jsxs, and jsxDEV.\n */\nfunction buildElement(\n type: any,\n props: any,\n children: SinwanNode[],\n): SinwanElement {\n // Handle Fragment\n if (type === Fragment) {\n return { tag: \"\", props: {}, children };\n }\n\n // Functional components and intrinsic HTML elements both pass the type\n // through as `tag`. The renderer (client / server / hydration) is the\n // single owner of component-instance creation and lifecycle dispatch.\n // Calling the function eagerly here would bypass instance management\n // and break `onMounted`, `provide`/`inject`, and the parent/child tree.\n if (typeof type === \"function\" || typeof type === \"string\") {\n const finalProps = props ?? {};\n // Mirror children into props.children so component setup can read it.\n if (children.length > 0 && finalProps.children === undefined) {\n finalProps.children = children.length === 1 ? children[0] : children;\n }\n return { tag: type, props: finalProps, children };\n }\n\n // Fallback\n return { tag: \"\", props: {}, children };\n}\n\n/**\n * JSX factory — called for elements with 0 or 1 child.\n * TypeScript auto-imports this in production mode (`react-jsx`).\n */\nexport function jsx(type: any, props: any, key?: any): SinwanElement {\n return buildElement(type, props, normalizeChildren(props?.children));\n}\n\n/**\n * JSX static factory — called for elements with 2+ children.\n * `props.children` is **already an array**, so we skip normalizeChildren.\n */\nexport function jsxs(type: any, props: any, key?: any): SinwanElement {\n const children = props?.children;\n // Children is guaranteed to be an array by the compiler\n return buildElement(\n type,\n props,\n Array.isArray(children)\n ? children.flat(Infinity)\n : normalizeChildren(children),\n );\n}\n\n/**\n * Source location metadata attached by the compiler in dev mode.\n */\nexport interface JSXSource {\n fileName: string;\n lineNumber: number;\n columnNumber: number;\n}\n\n/**\n * JSX dev factory — called in dev mode (`react-jsxdev`).\n * Receives extra source/debug info for better error messages.\n */\nexport function jsxDEV(\n type: any,\n props: any,\n key: any,\n isStaticChildren: boolean,\n source?: JSXSource,\n self?: unknown,\n): SinwanElement {\n const children = isStaticChildren\n ? Array.isArray(props?.children)\n ? props.children.flat(Infinity)\n : normalizeChildren(props?.children)\n : normalizeChildren(props?.children);\n\n const element = buildElement(type, props, children);\n\n // Attach debug metadata (useful for dev-tools / error traces)\n if (source) {\n (element as any).__source = source;\n }\n\n return element;\n}\n\nexport namespace JSX {\n export type Element = SinwanElement | Promise<SinwanElement>;\n export interface IntrinsicAttributes {\n key?: string | number;\n }\n export interface ElementChildrenAttribute {\n children: {};\n }\n export interface IntrinsicElements extends SinwanIntrinsicElements {}\n}\n\ndeclare global {\n namespace JSX {\n type Element = SinwanElement | Promise<SinwanElement>;\n interface IntrinsicAttributes {\n key?: string | number;\n }\n interface ElementChildrenAttribute {\n children: {};\n }\n interface IntrinsicElements extends SinwanIntrinsicElements {}\n }\n}\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": ";;AAUO,IAAM,WAAW,OAAO,UAAU;AAAA;AAMlC,MAAM,0BAA0B,OAAO;AAAA,EAChB;AAAA,EAA5B,WAAW,CAAiB,OAAe;AAAA,IACzC,MAAM,KAAK;AAAA,IADe;AAAA;AAAA,EAGnB,QAAQ,GAAG;AAAA,IAClB,OAAO,KAAK;AAAA;AAEhB;AAEO,IAAM,MAAM,CAAC,QAAgB,IAAI,kBAAkB,GAAG;AAG7D,IAAM,gBAAgB,IAAI,IAAI;AAAA,EAC5B;AAAA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
|
|
1
1
|
// @bun
|
|
2
|
-
var
|
|
2
|
+
var X=Symbol("Fragment");class f extends String{value;constructor(x){super(x);this.value=x}toString(){return this.value}}var T=(x)=>new f(x);function J(x){if(x==null||typeof x==="boolean")return[];if(Array.isArray(x))return x.flat(1/0);return[x]}function V(x,j,D){if(x===X)return{tag:"",props:{},children:D};if(typeof x==="function"||typeof x==="string"){let w=j??{};if(D.length>0&&w.children===void 0)w.children=D.length===1?D[0]:D;return{tag:x,props:w,children:D}}return{tag:"",props:{},children:D}}function k(x,j,D){return V(x,j,J(j?.children))}function q(x,j,D){let w=j?.children;return V(x,j,Array.isArray(w)?w.flat(1/0):J(w))}function M(x,j,D,w,v,R){let I=w?Array.isArray(j?.children)?j.children.flat(1/0):J(j?.children):J(j?.children),S=V(x,j,I);if(v)S.__source=v;return S}export{M as jsxDEV,X as Fragment};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
4
|
+
//# debugId=B3FA681E6687C79464756E2164756E21
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/jsx/jsx-runtime.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * SinwanJS View Module — JSX Runtime\n *\n * JSX factory that returns SinwanElement structures for the view renderer.\n * Imported automatically when using JSX syntax.\n */\n\nimport type { SinwanElement, SinwanNode } from \"../types.ts\";\nimport type { SinwanIntrinsicElements } from \"./jsx-types\";\n\nexport const Fragment = Symbol(\"Fragment\");\n\n/**\n * A string that has been marked as safe HTML (already escaped).\n * Used for raw HTML injection with explicit trust marking.\n */\nexport class HtmlEscapedString extends String {\n constructor(public readonly value: string) {\n super(value);\n }\n override toString() {\n return this.value;\n }\n}\n\nexport const raw = (str: string) => new HtmlEscapedString(str);\n\n// Fast path for intrinsic elements\nconst VOID_ELEMENTS = new Set([\n \"area\",\n \"base\",\n \"br\",\n \"col\",\n \"embed\",\n \"hr\",\n \"img\",\n \"input\",\n \"link\",\n \"meta\",\n \"param\",\n \"source\",\n \"track\",\n \"wbr\",\n]);\n\n/**\n * Normalize children into an array of SinwanNode.\n */\nfunction normalizeChildren(children: any): SinwanNode[] {\n if (children == null || typeof children === \"boolean\") return [];\n if (Array.isArray(children)) return children.flat(Infinity);\n return [children];\n}\n\n/**\n * Build an SinwanElement from a component/tag invocation.\n * Shared logic for jsx, jsxs, and jsxDEV.\n */\nfunction buildElement(\n type: any,\n props: any,\n children: SinwanNode[],\n): SinwanElement {\n // Handle Fragment\n if (type === Fragment) {\n return { tag: \"\", props: {}, children };\n }\n\n //
|
|
5
|
+
"/**\n * SinwanJS View Module — JSX Runtime\n *\n * JSX factory that returns SinwanElement structures for the view renderer.\n * Imported automatically when using JSX syntax.\n */\n\nimport type { SinwanElement, SinwanNode } from \"../types.ts\";\nimport type { SinwanIntrinsicElements } from \"./jsx-types\";\n\nexport const Fragment = Symbol(\"Fragment\");\n\n/**\n * A string that has been marked as safe HTML (already escaped).\n * Used for raw HTML injection with explicit trust marking.\n */\nexport class HtmlEscapedString extends String {\n constructor(public readonly value: string) {\n super(value);\n }\n override toString() {\n return this.value;\n }\n}\n\nexport const raw = (str: string) => new HtmlEscapedString(str);\n\n// Fast path for intrinsic elements\nconst VOID_ELEMENTS = new Set([\n \"area\",\n \"base\",\n \"br\",\n \"col\",\n \"embed\",\n \"hr\",\n \"img\",\n \"input\",\n \"link\",\n \"meta\",\n \"param\",\n \"source\",\n \"track\",\n \"wbr\",\n]);\n\n/**\n * Normalize children into an array of SinwanNode.\n */\nfunction normalizeChildren(children: any): SinwanNode[] {\n if (children == null || typeof children === \"boolean\") return [];\n if (Array.isArray(children)) return children.flat(Infinity);\n return [children];\n}\n\n/**\n * Build an SinwanElement from a component/tag invocation.\n * Shared logic for jsx, jsxs, and jsxDEV.\n */\nfunction buildElement(\n type: any,\n props: any,\n children: SinwanNode[],\n): SinwanElement {\n // Handle Fragment\n if (type === Fragment) {\n return { tag: \"\", props: {}, children };\n }\n\n // Functional components and intrinsic HTML elements both pass the type\n // through as `tag`. The renderer (client / server / hydration) is the\n // single owner of component-instance creation and lifecycle dispatch.\n // Calling the function eagerly here would bypass instance management\n // and break `onMounted`, `provide`/`inject`, and the parent/child tree.\n if (typeof type === \"function\" || typeof type === \"string\") {\n const finalProps = props ?? {};\n // Mirror children into props.children so component setup can read it.\n if (children.length > 0 && finalProps.children === undefined) {\n finalProps.children = children.length === 1 ? children[0] : children;\n }\n return { tag: type, props: finalProps, children };\n }\n\n // Fallback\n return { tag: \"\", props: {}, children };\n}\n\n/**\n * JSX factory — called for elements with 0 or 1 child.\n * TypeScript auto-imports this in production mode (`react-jsx`).\n */\nexport function jsx(type: any, props: any, key?: any): SinwanElement {\n return buildElement(type, props, normalizeChildren(props?.children));\n}\n\n/**\n * JSX static factory — called for elements with 2+ children.\n * `props.children` is **already an array**, so we skip normalizeChildren.\n */\nexport function jsxs(type: any, props: any, key?: any): SinwanElement {\n const children = props?.children;\n // Children is guaranteed to be an array by the compiler\n return buildElement(\n type,\n props,\n Array.isArray(children)\n ? children.flat(Infinity)\n : normalizeChildren(children),\n );\n}\n\n/**\n * Source location metadata attached by the compiler in dev mode.\n */\nexport interface JSXSource {\n fileName: string;\n lineNumber: number;\n columnNumber: number;\n}\n\n/**\n * JSX dev factory — called in dev mode (`react-jsxdev`).\n * Receives extra source/debug info for better error messages.\n */\nexport function jsxDEV(\n type: any,\n props: any,\n key: any,\n isStaticChildren: boolean,\n source?: JSXSource,\n self?: unknown,\n): SinwanElement {\n const children = isStaticChildren\n ? Array.isArray(props?.children)\n ? props.children.flat(Infinity)\n : normalizeChildren(props?.children)\n : normalizeChildren(props?.children);\n\n const element = buildElement(type, props, children);\n\n // Attach debug metadata (useful for dev-tools / error traces)\n if (source) {\n (element as any).__source = source;\n }\n\n return element;\n}\n\nexport namespace JSX {\n export type Element = SinwanElement | Promise<SinwanElement>;\n export interface IntrinsicAttributes {\n key?: string | number;\n }\n export interface ElementChildrenAttribute {\n children: {};\n }\n export interface IntrinsicElements extends SinwanIntrinsicElements {}\n}\n\ndeclare global {\n namespace JSX {\n type Element = SinwanElement | Promise<SinwanElement>;\n interface IntrinsicAttributes {\n key?: string | number;\n }\n interface ElementChildrenAttribute {\n children: {};\n }\n interface IntrinsicElements extends SinwanIntrinsicElements {}\n }\n}\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": ";AAUO,IAAM,EAAW,OAAO,UAAU,EAMlC,MAAM,UAA0B,MAAO,CAChB,MAA5B,WAAW,CAAiB,EAAe,CACzC,MAAM,CAAK,EADe,aAGnB,QAAQ,EAAG,CAClB,OAAO,KAAK,MAEhB,CAEO,IAAM,EAAM,CAAC,IAAgB,IAAI,EAAkB,CAAG,EAuB7D,SAAS,CAAiB,CAAC,EAA6B,CACtD,GAAI,GAAY,MAAQ,OAAO,IAAa,UAAW,MAAO,CAAC,EAC/D,GAAI,MAAM,QAAQ,CAAQ,EAAG,OAAO,EAAS,KAAK,GAAQ,EAC1D,MAAO,CAAC,CAAQ,EAOlB,SAAS,CAAY,CACnB,EACA,EACA,EACe,CAEf,GAAI,IAAS,EACX,MAAO,CAAE,IAAK,GAAI,MAAO,CAAC,EAAG,UAAS,
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";AAUO,IAAM,EAAW,OAAO,UAAU,EAMlC,MAAM,UAA0B,MAAO,CAChB,MAA5B,WAAW,CAAiB,EAAe,CACzC,MAAM,CAAK,EADe,aAGnB,QAAQ,EAAG,CAClB,OAAO,KAAK,MAEhB,CAEO,IAAM,EAAM,CAAC,IAAgB,IAAI,EAAkB,CAAG,EAuB7D,SAAS,CAAiB,CAAC,EAA6B,CACtD,GAAI,GAAY,MAAQ,OAAO,IAAa,UAAW,MAAO,CAAC,EAC/D,GAAI,MAAM,QAAQ,CAAQ,EAAG,OAAO,EAAS,KAAK,GAAQ,EAC1D,MAAO,CAAC,CAAQ,EAOlB,SAAS,CAAY,CACnB,EACA,EACA,EACe,CAEf,GAAI,IAAS,EACX,MAAO,CAAE,IAAK,GAAI,MAAO,CAAC,EAAG,UAAS,EAQxC,GAAI,OAAO,IAAS,YAAc,OAAO,IAAS,SAAU,CAC1D,IAAM,EAAa,GAAS,CAAC,EAE7B,GAAI,EAAS,OAAS,GAAK,EAAW,WAAa,OACjD,EAAW,SAAW,EAAS,SAAW,EAAI,EAAS,GAAK,EAE9D,MAAO,CAAE,IAAK,EAAM,MAAO,EAAY,UAAS,EAIlD,MAAO,CAAE,IAAK,GAAI,MAAO,CAAC,EAAG,UAAS,EAOjC,SAAS,CAAG,CAAC,EAAW,EAAY,EAA0B,CACnE,OAAO,EAAa,EAAM,EAAO,EAAkB,GAAO,QAAQ,CAAC,EAO9D,SAAS,CAAI,CAAC,EAAW,EAAY,EAA0B,CACpE,IAAM,EAAW,GAAO,SAExB,OAAO,EACL,EACA,EACA,MAAM,QAAQ,CAAQ,EAClB,EAAS,KAAK,GAAQ,EACtB,EAAkB,CAAQ,CAChC,EAgBK,SAAS,CAAM,CACpB,EACA,EACA,EACA,EACA,EACA,EACe,CACf,IAAM,EAAW,EACb,MAAM,QAAQ,GAAO,QAAQ,EAC3B,EAAM,SAAS,KAAK,GAAQ,EAC5B,EAAkB,GAAO,QAAQ,EACnC,EAAkB,GAAO,QAAQ,EAE/B,EAAU,EAAa,EAAM,EAAO,CAAQ,EAGlD,GAAI,EACD,EAAgB,SAAW,EAG9B,OAAO",
|
|
8
|
+
"debugId": "B3FA681E6687C79464756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -40,22 +40,12 @@ function buildElement(type, props, children) {
|
|
|
40
40
|
if (type === Fragment) {
|
|
41
41
|
return { tag: "", props: {}, children };
|
|
42
42
|
}
|
|
43
|
-
if (typeof type === "function") {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return result2;
|
|
48
|
-
}
|
|
49
|
-
return { tag: "", props: {}, children: normalizeChildren(result2) };
|
|
43
|
+
if (typeof type === "function" || typeof type === "string") {
|
|
44
|
+
const finalProps = props ?? {};
|
|
45
|
+
if (children.length > 0 && finalProps.children === undefined) {
|
|
46
|
+
finalProps.children = children.length === 1 ? children[0] : children;
|
|
50
47
|
}
|
|
51
|
-
|
|
52
|
-
if (result && typeof result === "object" && "tag" in result) {
|
|
53
|
-
return result;
|
|
54
|
-
}
|
|
55
|
-
return { tag: "", props: {}, children: normalizeChildren(result) };
|
|
56
|
-
}
|
|
57
|
-
if (typeof type === "string") {
|
|
58
|
-
return { tag: type, props: props || {}, children };
|
|
48
|
+
return { tag: type, props: finalProps, children };
|
|
59
49
|
}
|
|
60
50
|
return { tag: "", props: {}, children };
|
|
61
51
|
}
|
|
@@ -83,5 +73,5 @@ export {
|
|
|
83
73
|
Fragment
|
|
84
74
|
};
|
|
85
75
|
|
|
86
|
-
//# debugId=
|
|
76
|
+
//# debugId=38BADEB22589ACB864756E2164756E21
|
|
87
77
|
//# sourceMappingURL=jsx-runtime.development.js.map
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/jsx/jsx-runtime.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * SinwanJS View Module — JSX Runtime\n *\n * JSX factory that returns SinwanElement structures for the view renderer.\n * Imported automatically when using JSX syntax.\n */\n\nimport type { SinwanElement, SinwanNode } from \"../types.ts\";\nimport type { SinwanIntrinsicElements } from \"./jsx-types\";\n\nexport const Fragment = Symbol(\"Fragment\");\n\n/**\n * A string that has been marked as safe HTML (already escaped).\n * Used for raw HTML injection with explicit trust marking.\n */\nexport class HtmlEscapedString extends String {\n constructor(public readonly value: string) {\n super(value);\n }\n override toString() {\n return this.value;\n }\n}\n\nexport const raw = (str: string) => new HtmlEscapedString(str);\n\n// Fast path for intrinsic elements\nconst VOID_ELEMENTS = new Set([\n \"area\",\n \"base\",\n \"br\",\n \"col\",\n \"embed\",\n \"hr\",\n \"img\",\n \"input\",\n \"link\",\n \"meta\",\n \"param\",\n \"source\",\n \"track\",\n \"wbr\",\n]);\n\n/**\n * Normalize children into an array of SinwanNode.\n */\nfunction normalizeChildren(children: any): SinwanNode[] {\n if (children == null || typeof children === \"boolean\") return [];\n if (Array.isArray(children)) return children.flat(Infinity);\n return [children];\n}\n\n/**\n * Build an SinwanElement from a component/tag invocation.\n * Shared logic for jsx, jsxs, and jsxDEV.\n */\nfunction buildElement(\n type: any,\n props: any,\n children: SinwanNode[],\n): SinwanElement {\n // Handle Fragment\n if (type === Fragment) {\n return { tag: \"\", props: {}, children };\n }\n\n //
|
|
5
|
+
"/**\n * SinwanJS View Module — JSX Runtime\n *\n * JSX factory that returns SinwanElement structures for the view renderer.\n * Imported automatically when using JSX syntax.\n */\n\nimport type { SinwanElement, SinwanNode } from \"../types.ts\";\nimport type { SinwanIntrinsicElements } from \"./jsx-types\";\n\nexport const Fragment = Symbol(\"Fragment\");\n\n/**\n * A string that has been marked as safe HTML (already escaped).\n * Used for raw HTML injection with explicit trust marking.\n */\nexport class HtmlEscapedString extends String {\n constructor(public readonly value: string) {\n super(value);\n }\n override toString() {\n return this.value;\n }\n}\n\nexport const raw = (str: string) => new HtmlEscapedString(str);\n\n// Fast path for intrinsic elements\nconst VOID_ELEMENTS = new Set([\n \"area\",\n \"base\",\n \"br\",\n \"col\",\n \"embed\",\n \"hr\",\n \"img\",\n \"input\",\n \"link\",\n \"meta\",\n \"param\",\n \"source\",\n \"track\",\n \"wbr\",\n]);\n\n/**\n * Normalize children into an array of SinwanNode.\n */\nfunction normalizeChildren(children: any): SinwanNode[] {\n if (children == null || typeof children === \"boolean\") return [];\n if (Array.isArray(children)) return children.flat(Infinity);\n return [children];\n}\n\n/**\n * Build an SinwanElement from a component/tag invocation.\n * Shared logic for jsx, jsxs, and jsxDEV.\n */\nfunction buildElement(\n type: any,\n props: any,\n children: SinwanNode[],\n): SinwanElement {\n // Handle Fragment\n if (type === Fragment) {\n return { tag: \"\", props: {}, children };\n }\n\n // Functional components and intrinsic HTML elements both pass the type\n // through as `tag`. The renderer (client / server / hydration) is the\n // single owner of component-instance creation and lifecycle dispatch.\n // Calling the function eagerly here would bypass instance management\n // and break `onMounted`, `provide`/`inject`, and the parent/child tree.\n if (typeof type === \"function\" || typeof type === \"string\") {\n const finalProps = props ?? {};\n // Mirror children into props.children so component setup can read it.\n if (children.length > 0 && finalProps.children === undefined) {\n finalProps.children = children.length === 1 ? children[0] : children;\n }\n return { tag: type, props: finalProps, children };\n }\n\n // Fallback\n return { tag: \"\", props: {}, children };\n}\n\n/**\n * JSX factory — called for elements with 0 or 1 child.\n * TypeScript auto-imports this in production mode (`react-jsx`).\n */\nexport function jsx(type: any, props: any, key?: any): SinwanElement {\n return buildElement(type, props, normalizeChildren(props?.children));\n}\n\n/**\n * JSX static factory — called for elements with 2+ children.\n * `props.children` is **already an array**, so we skip normalizeChildren.\n */\nexport function jsxs(type: any, props: any, key?: any): SinwanElement {\n const children = props?.children;\n // Children is guaranteed to be an array by the compiler\n return buildElement(\n type,\n props,\n Array.isArray(children)\n ? children.flat(Infinity)\n : normalizeChildren(children),\n );\n}\n\n/**\n * Source location metadata attached by the compiler in dev mode.\n */\nexport interface JSXSource {\n fileName: string;\n lineNumber: number;\n columnNumber: number;\n}\n\n/**\n * JSX dev factory — called in dev mode (`react-jsxdev`).\n * Receives extra source/debug info for better error messages.\n */\nexport function jsxDEV(\n type: any,\n props: any,\n key: any,\n isStaticChildren: boolean,\n source?: JSXSource,\n self?: unknown,\n): SinwanElement {\n const children = isStaticChildren\n ? Array.isArray(props?.children)\n ? props.children.flat(Infinity)\n : normalizeChildren(props?.children)\n : normalizeChildren(props?.children);\n\n const element = buildElement(type, props, children);\n\n // Attach debug metadata (useful for dev-tools / error traces)\n if (source) {\n (element as any).__source = source;\n }\n\n return element;\n}\n\nexport namespace JSX {\n export type Element = SinwanElement | Promise<SinwanElement>;\n export interface IntrinsicAttributes {\n key?: string | number;\n }\n export interface ElementChildrenAttribute {\n children: {};\n }\n export interface IntrinsicElements extends SinwanIntrinsicElements {}\n}\n\ndeclare global {\n namespace JSX {\n type Element = SinwanElement | Promise<SinwanElement>;\n interface IntrinsicAttributes {\n key?: string | number;\n }\n interface ElementChildrenAttribute {\n children: {};\n }\n interface IntrinsicElements extends SinwanIntrinsicElements {}\n }\n}\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": ";;AAUO,IAAM,WAAW,OAAO,UAAU;AAAA;AAMlC,MAAM,0BAA0B,OAAO;AAAA,EAChB;AAAA,EAA5B,WAAW,CAAiB,OAAe;AAAA,IACzC,MAAM,KAAK;AAAA,IADe;AAAA;AAAA,EAGnB,QAAQ,GAAG;AAAA,IAClB,OAAO,KAAK;AAAA;AAEhB;AAEO,IAAM,MAAM,CAAC,QAAgB,IAAI,kBAAkB,GAAG;AAG7D,IAAM,gBAAgB,IAAI,IAAI;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAKD,SAAS,iBAAiB,CAAC,UAA6B;AAAA,EACtD,IAAI,YAAY,QAAQ,OAAO,aAAa;AAAA,IAAW,OAAO,CAAC;AAAA,EAC/D,IAAI,MAAM,QAAQ,QAAQ;AAAA,IAAG,OAAO,SAAS,KAAK,QAAQ;AAAA,EAC1D,OAAO,CAAC,QAAQ;AAAA;AAOlB,SAAS,YAAY,CACnB,MACA,OACA,UACe;AAAA,EAEf,IAAI,SAAS,UAAU;AAAA,IACrB,OAAO,EAAE,KAAK,IAAI,OAAO,CAAC,GAAG,SAAS;AAAA,EACxC;AAAA,
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";;AAUO,IAAM,WAAW,OAAO,UAAU;AAAA;AAMlC,MAAM,0BAA0B,OAAO;AAAA,EAChB;AAAA,EAA5B,WAAW,CAAiB,OAAe;AAAA,IACzC,MAAM,KAAK;AAAA,IADe;AAAA;AAAA,EAGnB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M,QAAQ,QAAQ,IAClB,SAAS,KAAK,QAAQ,IACtB,kBAAkB,QAAQ,CAChC;AAAA;AAgBK,SAAS,MAAM,CACpB,MACA,OACA,KACA,kBACA,QACA,MACe;AAAA,EACf,MAAM,WAAW,mBACb,MAAM,QAAQ,OAAO,QAAQ,IAC3B,MAAM,SAAS,KAAK,QAAQ,IAC5B,kBAAkB,OAAO,QAAQ,IACnC,kBAAkB,OAAO,QAAQ;AAAA,EAErC,MAAM,UAAU,aAAa,MAAM,OAAO,QAAQ;AAAA,EAGlD,IAAI,QAAQ;AAAA,IACT,QAAgB,WAAW;AAAA,EAC9B;AAAA,EAEA,OAAO;AAAA;",
|
|
8
|
+
"debugId": "38BADEB22589ACB864756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var K=Symbol("Fragment");class I extends String{value;constructor(j){super(j);this.value=j}toString(){return this.value}}var M=(j)=>new I(j);function
|
|
2
|
+
var K=Symbol("Fragment");class I extends String{value;constructor(j){super(j);this.value=j}toString(){return this.value}}var M=(j)=>new I(j);function x(j){if(j==null||typeof j==="boolean")return[];if(Array.isArray(j))return j.flat(1/0);return[j]}function B(j,k,q){if(j===K)return{tag:"",props:{},children:q};if(typeof j==="function"||typeof j==="string"){let w=k??{};if(q.length>0&&w.children===void 0)w.children=q.length===1?q[0]:q;return{tag:j,props:w,children:q}}return{tag:"",props:{},children:q}}function N(j,k,q){return B(j,k,x(k?.children))}function O(j,k,q){let w=k?.children;return B(j,k,Array.isArray(w)?w.flat(1/0):x(w))}function Q(j,k,q,w,D,L){let J=w?Array.isArray(k?.children)?k.children.flat(1/0):x(k?.children):x(k?.children),G=B(j,k,J);if(D)G.__source=D;return G}export{M as raw,O as jsxs,Q as jsxDEV,N as jsx,I as HtmlEscapedString,K as Fragment};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
4
|
+
//# debugId=B9B0AAC8EDF1EB4064756E2164756E21
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/jsx/jsx-runtime.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * SinwanJS View Module — JSX Runtime\n *\n * JSX factory that returns SinwanElement structures for the view renderer.\n * Imported automatically when using JSX syntax.\n */\n\nimport type { SinwanElement, SinwanNode } from \"../types.ts\";\nimport type { SinwanIntrinsicElements } from \"./jsx-types\";\n\nexport const Fragment = Symbol(\"Fragment\");\n\n/**\n * A string that has been marked as safe HTML (already escaped).\n * Used for raw HTML injection with explicit trust marking.\n */\nexport class HtmlEscapedString extends String {\n constructor(public readonly value: string) {\n super(value);\n }\n override toString() {\n return this.value;\n }\n}\n\nexport const raw = (str: string) => new HtmlEscapedString(str);\n\n// Fast path for intrinsic elements\nconst VOID_ELEMENTS = new Set([\n \"area\",\n \"base\",\n \"br\",\n \"col\",\n \"embed\",\n \"hr\",\n \"img\",\n \"input\",\n \"link\",\n \"meta\",\n \"param\",\n \"source\",\n \"track\",\n \"wbr\",\n]);\n\n/**\n * Normalize children into an array of SinwanNode.\n */\nfunction normalizeChildren(children: any): SinwanNode[] {\n if (children == null || typeof children === \"boolean\") return [];\n if (Array.isArray(children)) return children.flat(Infinity);\n return [children];\n}\n\n/**\n * Build an SinwanElement from a component/tag invocation.\n * Shared logic for jsx, jsxs, and jsxDEV.\n */\nfunction buildElement(\n type: any,\n props: any,\n children: SinwanNode[],\n): SinwanElement {\n // Handle Fragment\n if (type === Fragment) {\n return { tag: \"\", props: {}, children };\n }\n\n //
|
|
5
|
+
"/**\n * SinwanJS View Module — JSX Runtime\n *\n * JSX factory that returns SinwanElement structures for the view renderer.\n * Imported automatically when using JSX syntax.\n */\n\nimport type { SinwanElement, SinwanNode } from \"../types.ts\";\nimport type { SinwanIntrinsicElements } from \"./jsx-types\";\n\nexport const Fragment = Symbol(\"Fragment\");\n\n/**\n * A string that has been marked as safe HTML (already escaped).\n * Used for raw HTML injection with explicit trust marking.\n */\nexport class HtmlEscapedString extends String {\n constructor(public readonly value: string) {\n super(value);\n }\n override toString() {\n return this.value;\n }\n}\n\nexport const raw = (str: string) => new HtmlEscapedString(str);\n\n// Fast path for intrinsic elements\nconst VOID_ELEMENTS = new Set([\n \"area\",\n \"base\",\n \"br\",\n \"col\",\n \"embed\",\n \"hr\",\n \"img\",\n \"input\",\n \"link\",\n \"meta\",\n \"param\",\n \"source\",\n \"track\",\n \"wbr\",\n]);\n\n/**\n * Normalize children into an array of SinwanNode.\n */\nfunction normalizeChildren(children: any): SinwanNode[] {\n if (children == null || typeof children === \"boolean\") return [];\n if (Array.isArray(children)) return children.flat(Infinity);\n return [children];\n}\n\n/**\n * Build an SinwanElement from a component/tag invocation.\n * Shared logic for jsx, jsxs, and jsxDEV.\n */\nfunction buildElement(\n type: any,\n props: any,\n children: SinwanNode[],\n): SinwanElement {\n // Handle Fragment\n if (type === Fragment) {\n return { tag: \"\", props: {}, children };\n }\n\n // Functional components and intrinsic HTML elements both pass the type\n // through as `tag`. The renderer (client / server / hydration) is the\n // single owner of component-instance creation and lifecycle dispatch.\n // Calling the function eagerly here would bypass instance management\n // and break `onMounted`, `provide`/`inject`, and the parent/child tree.\n if (typeof type === \"function\" || typeof type === \"string\") {\n const finalProps = props ?? {};\n // Mirror children into props.children so component setup can read it.\n if (children.length > 0 && finalProps.children === undefined) {\n finalProps.children = children.length === 1 ? children[0] : children;\n }\n return { tag: type, props: finalProps, children };\n }\n\n // Fallback\n return { tag: \"\", props: {}, children };\n}\n\n/**\n * JSX factory — called for elements with 0 or 1 child.\n * TypeScript auto-imports this in production mode (`react-jsx`).\n */\nexport function jsx(type: any, props: any, key?: any): SinwanElement {\n return buildElement(type, props, normalizeChildren(props?.children));\n}\n\n/**\n * JSX static factory — called for elements with 2+ children.\n * `props.children` is **already an array**, so we skip normalizeChildren.\n */\nexport function jsxs(type: any, props: any, key?: any): SinwanElement {\n const children = props?.children;\n // Children is guaranteed to be an array by the compiler\n return buildElement(\n type,\n props,\n Array.isArray(children)\n ? children.flat(Infinity)\n : normalizeChildren(children),\n );\n}\n\n/**\n * Source location metadata attached by the compiler in dev mode.\n */\nexport interface JSXSource {\n fileName: string;\n lineNumber: number;\n columnNumber: number;\n}\n\n/**\n * JSX dev factory — called in dev mode (`react-jsxdev`).\n * Receives extra source/debug info for better error messages.\n */\nexport function jsxDEV(\n type: any,\n props: any,\n key: any,\n isStaticChildren: boolean,\n source?: JSXSource,\n self?: unknown,\n): SinwanElement {\n const children = isStaticChildren\n ? Array.isArray(props?.children)\n ? props.children.flat(Infinity)\n : normalizeChildren(props?.children)\n : normalizeChildren(props?.children);\n\n const element = buildElement(type, props, children);\n\n // Attach debug metadata (useful for dev-tools / error traces)\n if (source) {\n (element as any).__source = source;\n }\n\n return element;\n}\n\nexport namespace JSX {\n export type Element = SinwanElement | Promise<SinwanElement>;\n export interface IntrinsicAttributes {\n key?: string | number;\n }\n export interface ElementChildrenAttribute {\n children: {};\n }\n export interface IntrinsicElements extends SinwanIntrinsicElements {}\n}\n\ndeclare global {\n namespace JSX {\n type Element = SinwanElement | Promise<SinwanElement>;\n interface IntrinsicAttributes {\n key?: string | number;\n }\n interface ElementChildrenAttribute {\n children: {};\n }\n interface IntrinsicElements extends SinwanIntrinsicElements {}\n }\n}\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": ";AAUO,IAAM,EAAW,OAAO,UAAU,EAMlC,MAAM,UAA0B,MAAO,CAChB,MAA5B,WAAW,CAAiB,EAAe,CACzC,MAAM,CAAK,EADe,aAGnB,QAAQ,EAAG,CAClB,OAAO,KAAK,MAEhB,CAEO,IAAM,EAAM,CAAC,IAAgB,IAAI,EAAkB,CAAG,EAuB7D,SAAS,CAAiB,CAAC,EAA6B,CACtD,GAAI,GAAY,MAAQ,OAAO,IAAa,UAAW,MAAO,CAAC,EAC/D,GAAI,MAAM,QAAQ,CAAQ,EAAG,OAAO,EAAS,KAAK,GAAQ,EAC1D,MA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