@fluixi/dom 1.0.0-alpha.83 → 1.0.0-alpha.85

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.
Files changed (182) hide show
  1. package/dist/cdn/dom-client.cjs +1427 -1
  2. package/dist/cdn/dom-client.d.ts +2 -2
  3. package/dist/cdn/dom-client.global.js +2 -1
  4. package/dist/cdn/dom-client.js +3 -3
  5. package/dist/cdn/dom-client.mjs +1430 -1
  6. package/dist/cdn/dom.cjs +3127 -1
  7. package/dist/cdn/dom.d.ts +2 -2
  8. package/dist/cdn/dom.global.js +2 -1
  9. package/dist/cdn/dom.js +4 -4
  10. package/dist/cdn/dom.mjs +3133 -1
  11. package/dist/index.cjs +3155 -1
  12. package/dist/index.js +2 -2
  13. package/dist/index.mjs +3149 -1
  14. package/dist/lib/component/index.cjs +128 -1
  15. package/dist/lib/component/index.mjs +105 -1
  16. package/dist/lib/component/modifiers.cjs +126 -1
  17. package/dist/lib/component/modifiers.d.ts +12 -0
  18. package/dist/lib/component/modifiers.d.ts.map +1 -1
  19. package/dist/lib/component/modifiers.js +12 -84
  20. package/dist/lib/component/modifiers.mjs +105 -1
  21. package/dist/lib/dom/delegate.cjs +60 -1
  22. package/dist/lib/dom/delegate.js +1 -1
  23. package/dist/lib/dom/delegate.mjs +39 -1
  24. package/dist/lib/dom/dynamic-element.cjs +949 -1
  25. package/dist/lib/dom/dynamic-element.d.ts +3 -3
  26. package/dist/lib/dom/dynamic-element.js +2 -2
  27. package/dist/lib/dom/dynamic-element.mjs +928 -1
  28. package/dist/lib/dom/hydration-state.cjs +93 -1
  29. package/dist/lib/dom/hydration-state.d.ts +1 -1
  30. package/dist/lib/dom/hydration-state.js +1 -1
  31. package/dist/lib/dom/hydration-state.mjs +72 -1
  32. package/dist/lib/dom/hydration.cjs +685 -1
  33. package/dist/lib/dom/hydration.js +8 -8
  34. package/dist/lib/dom/hydration.mjs +664 -1
  35. package/dist/lib/dom/index.cjs +2040 -1
  36. package/dist/lib/dom/index.js +1 -1
  37. package/dist/lib/dom/index.mjs +2020 -1
  38. package/dist/lib/dom/integration.cjs +71 -1
  39. package/dist/lib/dom/integration.js +3 -3
  40. package/dist/lib/dom/integration.mjs +51 -1
  41. package/dist/lib/dom/island.cjs +790 -1
  42. package/dist/lib/dom/island.d.ts +1 -1
  43. package/dist/lib/dom/island.js +11 -11
  44. package/dist/lib/dom/island.mjs +769 -1
  45. package/dist/lib/dom/runtime.cjs +1432 -1
  46. package/dist/lib/dom/runtime.d.ts +60 -17
  47. package/dist/lib/dom/runtime.d.ts.map +1 -1
  48. package/dist/lib/dom/runtime.js +122 -79
  49. package/dist/lib/dom/runtime.mjs +1414 -1
  50. package/dist/lib/dom/server/fx-data.cjs +53 -1
  51. package/dist/lib/dom/server/fx-data.d.ts +5 -5
  52. package/dist/lib/dom/server/fx-data.js +6 -6
  53. package/dist/lib/dom/server/fx-data.mjs +32 -1
  54. package/dist/lib/dom/server/host.cjs +66 -1
  55. package/dist/lib/dom/server/host.d.ts +6 -0
  56. package/dist/lib/dom/server/host.d.ts.map +1 -1
  57. package/dist/lib/dom/server/host.js +7 -1
  58. package/dist/lib/dom/server/host.mjs +45 -1
  59. package/dist/lib/dom/server/index.cjs +759 -1
  60. package/dist/lib/dom/server/index.d.ts +1 -1
  61. package/dist/lib/dom/server/index.js +1 -1
  62. package/dist/lib/dom/server/index.mjs +743 -1
  63. package/dist/lib/dom/server/nodes.cjs +302 -1
  64. package/dist/lib/dom/server/nodes.d.ts +2 -2
  65. package/dist/lib/dom/server/nodes.d.ts.map +1 -1
  66. package/dist/lib/dom/server/nodes.js +4 -4
  67. package/dist/lib/dom/server/nodes.mjs +279 -1
  68. package/dist/lib/dom/server/parse-template.cjs +395 -1
  69. package/dist/lib/dom/server/parse-template.d.ts +1 -1
  70. package/dist/lib/dom/server/parse-template.js +4 -4
  71. package/dist/lib/dom/server/parse-template.mjs +372 -1
  72. package/dist/lib/dom/server/render.cjs +691 -1
  73. package/dist/lib/dom/server/render.d.ts +9 -1
  74. package/dist/lib/dom/server/render.d.ts.map +1 -1
  75. package/dist/lib/dom/server/render.js +23 -15
  76. package/dist/lib/dom/server/render.mjs +677 -1
  77. package/dist/lib/dom/server/request-context.cjs +110 -1
  78. package/dist/lib/dom/server/request-context.d.ts +29 -9
  79. package/dist/lib/dom/server/request-context.d.ts.map +1 -1
  80. package/dist/lib/dom/server/request-context.js +28 -8
  81. package/dist/lib/dom/server/request-context.mjs +89 -1
  82. package/dist/lib/dom/server/serialize.cjs +187 -1
  83. package/dist/lib/dom/server/serialize.js +3 -3
  84. package/dist/lib/dom/server/serialize.mjs +164 -1
  85. package/dist/lib/dom/server-renderer.cjs +760 -1
  86. package/dist/lib/dom/server-renderer.js +1 -1
  87. package/dist/lib/dom/server-renderer.mjs +745 -1
  88. package/dist/lib/dom/types.cjs +18 -1
  89. package/dist/lib/dom/utils.cjs +381 -1
  90. package/dist/lib/dom/utils.d.ts +1 -88
  91. package/dist/lib/dom/utils.d.ts.map +1 -1
  92. package/dist/lib/dom/utils.js +2 -99
  93. package/dist/lib/dom/utils.mjs +361 -1
  94. package/dist/lib/dom/versions.cjs +60 -1
  95. package/dist/lib/dom/versions.d.ts +3 -3
  96. package/dist/lib/dom/versions.d.ts.map +1 -1
  97. package/dist/lib/dom/versions.js +17 -5
  98. package/dist/lib/dom/versions.mjs +37 -1
  99. package/dist/lib/element/attributes.cjs +19 -1
  100. package/dist/lib/element/attributes.d.ts +7 -7
  101. package/dist/lib/element/attributes.js +1 -1
  102. package/dist/lib/element/attributes.mjs +1 -0
  103. package/dist/lib/element/index.cjs +19 -1
  104. package/dist/lib/element/index.mjs +1 -0
  105. package/dist/lib/element/types.cjs +18 -1
  106. package/dist/lib/element/types.d.ts +4 -5
  107. package/dist/lib/element/types.d.ts.map +1 -1
  108. package/dist/lib/element/types.js +0 -1
  109. package/dist/lib/flow/class-map.cjs +38 -1
  110. package/dist/lib/flow/class-map.d.ts +3 -3
  111. package/dist/lib/flow/class-map.js +2 -2
  112. package/dist/lib/flow/class-map.mjs +17 -1
  113. package/dist/lib/flow/client-only.cjs +57 -1
  114. package/dist/lib/flow/client-only.d.ts +4 -4
  115. package/dist/lib/flow/client-only.js +3 -3
  116. package/dist/lib/flow/client-only.mjs +36 -1
  117. package/dist/lib/flow/dynamic.cjs +53 -1
  118. package/dist/lib/flow/dynamic.d.ts +2 -2
  119. package/dist/lib/flow/dynamic.js +3 -3
  120. package/dist/lib/flow/dynamic.mjs +32 -1
  121. package/dist/lib/flow/error-boundary.cjs +43 -1
  122. package/dist/lib/flow/error-boundary.d.ts +2 -2
  123. package/dist/lib/flow/error-boundary.js +3 -3
  124. package/dist/lib/flow/error-boundary.mjs +22 -1
  125. package/dist/lib/flow/for.cjs +66 -1
  126. package/dist/lib/flow/for.d.ts +9 -9
  127. package/dist/lib/flow/for.d.ts.map +1 -1
  128. package/dist/lib/flow/for.js +2 -2
  129. package/dist/lib/flow/for.mjs +45 -1
  130. package/dist/lib/flow/index-flow.cjs +67 -1
  131. package/dist/lib/flow/index-flow.d.ts +5 -5
  132. package/dist/lib/flow/index-flow.js +4 -4
  133. package/dist/lib/flow/index-flow.mjs +46 -1
  134. package/dist/lib/flow/index.cjs +805 -1
  135. package/dist/lib/flow/index.mjs +792 -1
  136. package/dist/lib/flow/portal.cjs +538 -1
  137. package/dist/lib/flow/portal.mjs +519 -1
  138. package/dist/lib/flow/show.cjs +81 -1
  139. package/dist/lib/flow/show.d.ts +1 -1
  140. package/dist/lib/flow/show.d.ts.map +1 -1
  141. package/dist/lib/flow/show.js +4 -115
  142. package/dist/lib/flow/show.mjs +67 -1
  143. package/dist/lib/flow/style-map.cjs +43 -1
  144. package/dist/lib/flow/style-map.d.ts +3 -3
  145. package/dist/lib/flow/style-map.js +3 -3
  146. package/dist/lib/flow/style-map.mjs +22 -1
  147. package/dist/lib/flow/switch.cjs +91 -1
  148. package/dist/lib/flow/switch.d.ts +3 -3
  149. package/dist/lib/flow/switch.d.ts.map +1 -1
  150. package/dist/lib/flow/switch.js +6 -6
  151. package/dist/lib/flow/switch.mjs +70 -1
  152. package/dist/lib/flow/utils.cjs +44 -1
  153. package/dist/lib/flow/utils.d.ts +1 -1
  154. package/dist/lib/flow/utils.js +1 -1
  155. package/dist/lib/flow/utils.mjs +23 -1
  156. package/dist/lib/html.cjs +32 -1
  157. package/dist/lib/html.d.ts +6 -6
  158. package/dist/lib/html.js +5 -5
  159. package/dist/lib/html.mjs +11 -1
  160. package/dist/lib/index.cjs +3104 -1
  161. package/dist/lib/index.d.ts +0 -1
  162. package/dist/lib/index.d.ts.map +1 -1
  163. package/dist/lib/index.js +2 -3
  164. package/dist/lib/index.mjs +3097 -1
  165. package/dist/lib/shared/types.cjs +18 -1
  166. package/dist/lib/shared/types.d.ts +8 -8
  167. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  168. package/dist/version.generated.cjs +26 -1
  169. package/dist/version.generated.d.ts +1 -1
  170. package/dist/version.generated.js +2 -2
  171. package/dist/version.generated.mjs +5 -1
  172. package/package.json +7 -6
  173. package/dist/lib/jsx/control-flow/flow.cjs +0 -1
  174. package/dist/lib/jsx/control-flow/flow.d.ts +0 -2
  175. package/dist/lib/jsx/control-flow/flow.d.ts.map +0 -1
  176. package/dist/lib/jsx/control-flow/flow.js +0 -627
  177. package/dist/lib/jsx/control-flow/flow.mjs +0 -0
  178. package/dist/lib/jsx/control-flow/for-flow.cjs +0 -1
  179. package/dist/lib/jsx/control-flow/for-flow.d.ts +0 -2
  180. package/dist/lib/jsx/control-flow/for-flow.d.ts.map +0 -1
  181. package/dist/lib/jsx/control-flow/for-flow.js +0 -1
  182. package/dist/lib/jsx/control-flow/for-flow.mjs +0 -0
@@ -1 +1,36 @@
1
- import{createMemo as u,createSignal as c}from"@fluixi/reactive/signal";var i=Symbol.for("fluixi.dom.server-host"),l=globalThis,s=l[i]??={server:typeof document>"u",nodes:null};function r(){return s.server}var n={active:!1,cursor:null,parents:[]};function d(e){if(r())return e.fallback??null;let t=n.active,[o,a]=c(!t);return t&&queueMicrotask(()=>a(!0)),u(()=>o()?e.children:e.fallback??null,void 0,{name:"client-only"})}var x=d;export{d as ClientOnly,x as NoSsr};
1
+ // src/lib/flow/client-only.ts
2
+ import { createMemo, createSignal } from "@fluixi/reactive/signal";
3
+
4
+ // src/lib/dom/server/host.ts
5
+ var STATE = /* @__PURE__ */ Symbol.for("fluixi.dom.server-host");
6
+ var realm = globalThis;
7
+ var state = realm[STATE] ??= {
8
+ server: typeof document === "undefined",
9
+ nodes: null
10
+ };
11
+ function isServer() {
12
+ return state.server;
13
+ }
14
+
15
+ // src/lib/dom/hydration-state.ts
16
+ var hydration = {
17
+ active: false,
18
+ cursor: null,
19
+ parents: []
20
+ };
21
+
22
+ // src/lib/flow/client-only.ts
23
+ function ClientOnly(props) {
24
+ if (isServer()) return props.fallback ?? null;
25
+ const hydrating = hydration.active;
26
+ const [ready, setReady] = createSignal(!hydrating);
27
+ if (hydrating) queueMicrotask(() => setReady(true));
28
+ return createMemo(() => ready() ? props.children : props.fallback ?? null, void 0, {
29
+ name: "client-only"
30
+ });
31
+ }
32
+ var NoSsr = ClientOnly;
33
+ export {
34
+ ClientOnly,
35
+ NoSsr
36
+ };
@@ -1 +1,53 @@
1
- "use strict";var a=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var d=(n,e)=>{for(var s in e)a(n,s,{get:e[s],enumerable:!0})},T=(n,e,s,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of y(e))!l.call(n,t)&&t!==s&&a(n,t,{get:()=>e[t],enumerable:!(c=u(e,t))||c.enumerable});return n};var m=n=>T(a({},"__esModule",{value:!0}),n);var g={};d(g,{Dynamic:()=>A});module.exports=m(g);var r=require("@fluixi/reactive/signal");function f(n){return typeof n=="function"?n:(()=>n)}function A(n){let e=f(n.component),{component:s,...c}=n,t=(0,r.getOwner)(),i=null,p;return(0,r.createMemo)(()=>{let o=e();return o!==p&&(i&&(0,r.disposeScope)(i),i=(0,r.createChildOwner)(t),p=o),o==null?null:typeof o=="string"?{tag:o,props:c}:(0,r.runWithOwner)(i,()=>o(c))},void 0,{name:"Dynamic"})}
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/lib/flow/dynamic.ts
21
+ var dynamic_exports = {};
22
+ __export(dynamic_exports, {
23
+ Dynamic: () => Dynamic
24
+ });
25
+ module.exports = __toCommonJS(dynamic_exports);
26
+ var import_signal = require("@fluixi/reactive/signal");
27
+
28
+ // src/lib/flow/utils.ts
29
+ function normalizeAccessor(value) {
30
+ return typeof value === "function" ? value : (() => value);
31
+ }
32
+
33
+ // src/lib/flow/dynamic.ts
34
+ function Dynamic(props) {
35
+ const getComponent = normalizeAccessor(props.component);
36
+ const { component: _c, ...rest } = props;
37
+ const parentOwner = (0, import_signal.getOwner)();
38
+ let scope = null;
39
+ let current;
40
+ return (0, import_signal.createMemo)(() => {
41
+ const C = getComponent();
42
+ if (C !== current) {
43
+ if (scope) (0, import_signal.disposeScope)(scope);
44
+ scope = (0, import_signal.createChildOwner)(parentOwner);
45
+ current = C;
46
+ }
47
+ if (C == null) return null;
48
+ if (typeof C === "string") {
49
+ return { tag: C, props: rest };
50
+ }
51
+ return (0, import_signal.runWithOwner)(scope, () => C(rest));
52
+ }, void 0, { name: "Dynamic" });
53
+ }
@@ -11,11 +11,11 @@ export interface DynamicProps<T extends Record<string, any> = Record<string, any
11
11
  [key: string]: any;
12
12
  }
13
13
  /**
14
- * Renders a component dynamically mirrors SolidJS `<Dynamic>`.
14
+ * Renders a component dynamically: mirrors SolidJS `<Dynamic>`.
15
15
  *
16
16
  * The `component` prop can be a reactive accessor. When it changes,
17
17
  * the old output is discarded and the new component is called.
18
- * Returns a memo works in both JSX and `html` templates.
18
+ * Returns a memo: works in both JSX and `html` templates.
19
19
  *
20
20
  * @example JSX
21
21
  * <Dynamic component={tab() === 'a' ? CompA : CompB} value={x()} />
@@ -1,11 +1,11 @@
1
1
  import { createMemo, createChildOwner, disposeScope, getOwner, runWithOwner } from '@fluixi/reactive/signal';
2
2
  import { normalizeAccessor } from './utils.js';
3
3
  /**
4
- * Renders a component dynamically mirrors SolidJS `<Dynamic>`.
4
+ * Renders a component dynamically: mirrors SolidJS `<Dynamic>`.
5
5
  *
6
6
  * The `component` prop can be a reactive accessor. When it changes,
7
7
  * the old output is discarded and the new component is called.
8
- * Returns a memo works in both JSX and `html` templates.
8
+ * Returns a memo: works in both JSX and `html` templates.
9
9
  *
10
10
  * @example JSX
11
11
  * <Dynamic component={tab() === 'a' ? CompA : CompB} value={x()} />
@@ -35,7 +35,7 @@ export function Dynamic(props) {
35
35
  if (C == null)
36
36
  return null;
37
37
  if (typeof C === 'string') {
38
- // Intrinsic element return a descriptor that the runtime can handle.
38
+ // Intrinsic element: return a descriptor that the runtime can handle.
39
39
  return { tag: C, props: rest };
40
40
  }
41
41
  return runWithOwner(scope, () => C(rest));
@@ -1 +1,32 @@
1
- import{createMemo as a,createChildOwner as p,disposeScope as f,getOwner as u,runWithOwner as y}from"@fluixi/reactive/signal";function s(n){return typeof n=="function"?n:(()=>n)}function g(n){let c=s(n.component),{component:l,...t}=n,i=u(),r=null,o;return a(()=>{let e=c();return e!==o&&(r&&f(r),r=p(i),o=e),e==null?null:typeof e=="string"?{tag:e,props:t}:y(r,()=>e(t))},void 0,{name:"Dynamic"})}export{g as Dynamic};
1
+ // src/lib/flow/dynamic.ts
2
+ import { createMemo, createChildOwner, disposeScope, getOwner, runWithOwner } from "@fluixi/reactive/signal";
3
+
4
+ // src/lib/flow/utils.ts
5
+ function normalizeAccessor(value) {
6
+ return typeof value === "function" ? value : (() => value);
7
+ }
8
+
9
+ // src/lib/flow/dynamic.ts
10
+ function Dynamic(props) {
11
+ const getComponent = normalizeAccessor(props.component);
12
+ const { component: _c, ...rest } = props;
13
+ const parentOwner = getOwner();
14
+ let scope = null;
15
+ let current;
16
+ return createMemo(() => {
17
+ const C = getComponent();
18
+ if (C !== current) {
19
+ if (scope) disposeScope(scope);
20
+ scope = createChildOwner(parentOwner);
21
+ current = C;
22
+ }
23
+ if (C == null) return null;
24
+ if (typeof C === "string") {
25
+ return { tag: C, props: rest };
26
+ }
27
+ return runWithOwner(scope, () => C(rest));
28
+ }, void 0, { name: "Dynamic" });
29
+ }
30
+ export {
31
+ Dynamic
32
+ };
@@ -1 +1,43 @@
1
- "use strict";var l=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var y=(n,r)=>{for(var t in r)l(n,t,{get:r[t],enumerable:!0})},d=(n,r,t,c)=>{if(r&&typeof r=="object"||typeof r=="function")for(let e of f(r))!i.call(n,e)&&e!==t&&l(n,e,{get:()=>r[e],enumerable:!(c=u(r,e))||c.enumerable});return n};var k=n=>d(l({},"__esModule",{value:!0}),n);var h={};y(h,{ErrorBoundary:()=>b});module.exports=k(h);var a=require("@fluixi/reactive/signal");function b(n){let[r,t]=(0,a.createSignal)(null),c=()=>t(null);return(0,a.createMemo)(()=>{let e=r();if(e!==null)return typeof n.fallback=="function"?n.fallback(e,c):n.fallback;try{return typeof n.children=="function"?n.children():n.children}catch(o){return t(o),typeof n.fallback=="function"?n.fallback(o,c):n.fallback}},void 0,{name:"ErrorBoundary"})}
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/lib/flow/error-boundary.ts
21
+ var error_boundary_exports = {};
22
+ __export(error_boundary_exports, {
23
+ ErrorBoundary: () => ErrorBoundary
24
+ });
25
+ module.exports = __toCommonJS(error_boundary_exports);
26
+ var import_signal = require("@fluixi/reactive/signal");
27
+ function ErrorBoundary(props) {
28
+ const [error, setError] = (0, import_signal.createSignal)(null);
29
+ const reset = () => setError(null);
30
+ return (0, import_signal.createMemo)(() => {
31
+ const err = error();
32
+ if (err !== null) {
33
+ return typeof props.fallback === "function" ? props.fallback(err, reset) : props.fallback;
34
+ }
35
+ try {
36
+ const content = typeof props.children === "function" ? props.children() : props.children;
37
+ return content;
38
+ } catch (e) {
39
+ setError(e);
40
+ return typeof props.fallback === "function" ? props.fallback(e, reset) : props.fallback;
41
+ }
42
+ }, void 0, { name: "ErrorBoundary" });
43
+ }
@@ -9,10 +9,10 @@ export interface ErrorBoundaryProps {
9
9
  * Catches synchronous errors thrown during child rendering.
10
10
  *
11
11
  * When a child throws, renders `fallback` instead. `fallback` can be a
12
- * static value or a function `(err, reset) => UI` calling `reset()` clears
12
+ * static value or a function `(err, reset) => UI`, calling `reset()` clears
13
13
  * the error state and retries rendering the children.
14
14
  *
15
- * Returns a memo works in both JSX and `html` templates.
15
+ * Returns a memo: works in both JSX and `html` templates.
16
16
  *
17
17
  * Note: Only catches errors thrown synchronously during the render phase
18
18
  * (memo evaluation). Async errors inside effects are not caught here.
@@ -3,10 +3,10 @@ import { createMemo, createSignal } from '@fluixi/reactive/signal';
3
3
  * Catches synchronous errors thrown during child rendering.
4
4
  *
5
5
  * When a child throws, renders `fallback` instead. `fallback` can be a
6
- * static value or a function `(err, reset) => UI` calling `reset()` clears
6
+ * static value or a function `(err, reset) => UI`, calling `reset()` clears
7
7
  * the error state and retries rendering the children.
8
8
  *
9
- * Returns a memo works in both JSX and `html` templates.
9
+ * Returns a memo: works in both JSX and `html` templates.
10
10
  *
11
11
  * Note: Only catches errors thrown synchronously during the render phase
12
12
  * (memo evaluation). Async errors inside effects are not caught here.
@@ -39,7 +39,7 @@ export function ErrorBoundary(props) {
39
39
  return content;
40
40
  }
41
41
  catch (e) {
42
- // Caught a synchronous render error switch to fallback.
42
+ // Caught a synchronous render error: switch to fallback.
43
43
  setError(e);
44
44
  return typeof props.fallback === 'function'
45
45
  ? props.fallback(e, reset)
@@ -1 +1,22 @@
1
- import{createMemo as o,createSignal as l}from"@fluixi/reactive/signal";function d(n){let[a,e]=l(null),t=()=>e(null);return o(()=>{let c=a();if(c!==null)return typeof n.fallback=="function"?n.fallback(c,t):n.fallback;try{return typeof n.children=="function"?n.children():n.children}catch(r){return e(r),typeof n.fallback=="function"?n.fallback(r,t):n.fallback}},void 0,{name:"ErrorBoundary"})}export{d as ErrorBoundary};
1
+ // src/lib/flow/error-boundary.ts
2
+ import { createMemo, createSignal } from "@fluixi/reactive/signal";
3
+ function ErrorBoundary(props) {
4
+ const [error, setError] = createSignal(null);
5
+ const reset = () => setError(null);
6
+ return createMemo(() => {
7
+ const err = error();
8
+ if (err !== null) {
9
+ return typeof props.fallback === "function" ? props.fallback(err, reset) : props.fallback;
10
+ }
11
+ try {
12
+ const content = typeof props.children === "function" ? props.children() : props.children;
13
+ return content;
14
+ } catch (e) {
15
+ setError(e);
16
+ return typeof props.fallback === "function" ? props.fallback(e, reset) : props.fallback;
17
+ }
18
+ }, void 0, { name: "ErrorBoundary" });
19
+ }
20
+ export {
21
+ ErrorBoundary
22
+ };
@@ -1 +1,66 @@
1
- "use strict";var u=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var x=(r,e)=>{for(var t in e)u(r,t,{get:e[t],enumerable:!0})},v=(r,e,t,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of T(e))!A.call(r,n)&&n!==t&&u(r,n,{get:()=>e[n],enumerable:!(a=f(e,n))||a.enumerable});return r};var U=r=>v(u({},"__esModule",{value:!0}),r);var b={};x(b,{For:()=>m});module.exports=U(b);var i=require("@fluixi/reactive/signal");function p(r){return()=>{let e=r();return typeof e=="function"?e():e}}var c={active:!1,cursor:null,parents:[]};function h(r){let e=c.parents.lastIndexOf(r);e!==-1&&(c.parents.length=e),c.cursor=r.nextSibling}function d(r){if(!c.active||r==null)return;let e=Array.isArray(r)?r[r.length-1]:r;e&&typeof e.nodeType=="number"&&h(e)}function m(r){let e=p(()=>r.each),t=()=>r.fallback??null,a=(n,o)=>{let s=r.children,y=Array.isArray(s)?s.map(l=>typeof l=="function"?l(n,o):l):typeof s=="function"?s(n,o):s;return d(y),y};return r.by?(0,i.keyArray)(e,r.by,(n,o)=>a(n,o),{fallback:t}):(0,i.mapArray)(e,(n,o)=>a(n,o),{fallback:t})}
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/lib/flow/for.ts
21
+ var for_exports = {};
22
+ __export(for_exports, {
23
+ For: () => For
24
+ });
25
+ module.exports = __toCommonJS(for_exports);
26
+ var import_signal = require("@fluixi/reactive/signal");
27
+
28
+ // src/lib/flow/utils.ts
29
+ function resolveReactiveProp(read) {
30
+ return () => {
31
+ const value = read();
32
+ return typeof value === "function" ? value() : value;
33
+ };
34
+ }
35
+
36
+ // src/lib/dom/hydration-state.ts
37
+ var hydration = {
38
+ active: false,
39
+ cursor: null,
40
+ parents: []
41
+ };
42
+ function ascendPast(node) {
43
+ const idx = hydration.parents.lastIndexOf(node);
44
+ if (idx !== -1) hydration.parents.length = idx;
45
+ hydration.cursor = node.nextSibling;
46
+ }
47
+ function hydrateAdvancePast(rendered) {
48
+ if (!hydration.active || rendered == null) return;
49
+ const last = Array.isArray(rendered) ? rendered[rendered.length - 1] : rendered;
50
+ if (last && typeof last.nodeType === "number") {
51
+ ascendPast(last);
52
+ }
53
+ }
54
+
55
+ // src/lib/flow/for.ts
56
+ function For(props) {
57
+ const each = resolveReactiveProp(() => props.each);
58
+ const fallback = () => props.fallback ?? null;
59
+ const render = (item, index) => {
60
+ const children = props.children;
61
+ const rendered = Array.isArray(children) ? children.map((c) => typeof c === "function" ? c(item, index) : c) : typeof children === "function" ? children(item, index) : children;
62
+ hydrateAdvancePast(rendered);
63
+ return rendered;
64
+ };
65
+ return props.by ? (0, import_signal.keyArray)(each, props.by, (item, index) => render(item, index), { fallback }) : (0, import_signal.mapArray)(each, (item, index) => render(item, index), { fallback });
66
+ }
@@ -1,8 +1,8 @@
1
1
  import { Accessor } from '@fluixi/reactive/signal';
2
2
  type EachSource<T> = ReadonlyArray<T> | (() => ReadonlyArray<T> | null | undefined) | Accessor<ReadonlyArray<T>> | null | undefined | false;
3
- /** Props when `by` is NOT provided item is the plain value `T`. */
3
+ /** Props when `by` is not provided: item is the plain value `T`. */
4
4
  export interface ForPropsUnkeyed<T, U = any> {
5
- /** Reactive array to iterate over static, readonly, accessor, or signal. */
5
+ /** Reactive array to iterate over: static, readonly, accessor, or signal. */
6
6
  each: EachSource<T>;
7
7
  /** Rendered when the array is empty or nullish. */
8
8
  fallback?: any;
@@ -15,15 +15,15 @@ export interface ForPropsUnkeyed<T, U = any> {
15
15
  children: (item: T, index: Accessor<number>) => U;
16
16
  by?: undefined;
17
17
  }
18
- /** Props when `by` IS provided item is a reactive `Accessor<T>`. */
18
+ /** Props when `by` is provided: item is a reactive `Accessor<T>`. */
19
19
  export interface ForPropsKeyed<T, U = any> {
20
- /** Reactive array to iterate over static, readonly, accessor, or signal. */
20
+ /** Reactive array to iterate over: static, readonly, accessor, or signal. */
21
21
  each: EachSource<T>;
22
22
  /** Rendered when the array is empty or nullish. */
23
23
  fallback?: any;
24
24
  /**
25
25
  * Render function called once per unique key.
26
- * `item` is a reactive accessor call `item()` inside to read the current value.
26
+ * `item` is a reactive accessor: call `item()` inside to read the current value.
27
27
  * The same DOM is reused whenever `by(item)` returns the same key, even if the
28
28
  * object reference changes.
29
29
  *
@@ -39,21 +39,21 @@ export interface ForPropsKeyed<T, U = any> {
39
39
  }
40
40
  export type ForProps<T, U = any> = ForPropsUnkeyed<T, U> | ForPropsKeyed<T, U>;
41
41
  /**
42
- * Keyed list rendering mirrors SolidJS `<For>`.
42
+ * Keyed list rendering: mirrors SolidJS `<For>`.
43
43
  *
44
- * Default: keyed by object reference. Same object at new index only index
44
+ * Default: keyed by object reference. Same object at new index -> only index
45
45
  * signal updates (no DOM re-render). Removed items are disposed.
46
46
  *
47
47
  * With `by`: keyed by the return value of `by(item)`. When the same key is
48
48
  * found in the previous render, the DOM entry is reused and the index signal
49
49
  * is updated. The item accessor is a live `createMemo(() => list[idx()])` so
50
50
  * that reading `item().someField` inside a reactive context creates a
51
- * fine-grained dependency on the store proxy property not a frozen snapshot.
51
+ * fine-grained dependency on the store proxy property, not a frozen snapshot.
52
52
  *
53
53
  * @example Reference-keyed (default)
54
54
  * <For each={items}>{(item, idx) => <li>{item.name}</li>}</For>
55
55
  *
56
- * @example Stable-key (by prop) survives object recreation
56
+ * @example Stable-key (by prop): survives object recreation
57
57
  * <For each={rows} by={r => r.id}>
58
58
  * {(row, idx) => <tr><td>{() => row().name}</td></tr>}
59
59
  * </For>
@@ -1 +1 @@
1
- {"version":3,"file":"for.d.ts","sourceRoot":"","sources":["../../../src/lib/flow/for.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAsB,MAAM,yBAAyB,CAAC;AAIvE,KAAK,UAAU,CAAC,CAAC,IACb,aAAa,CAAC,CAAC,CAAC,GAChB,CAAC,MAAM,aAAa,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC,GAC3C,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,GAC1B,IAAI,GACJ,SAAS,GACT,KAAK,CAAC;AAEV,qEAAqE;AACrE,MAAM,WAAW,eAAe,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG;IACzC,8EAA8E;IAC9E,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IACpB,mDAAmD;IACnD,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf;;;;;OAKG;IACH,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAClD,EAAE,CAAC,EAAE,SAAS,CAAC;CAChB;AAED,sEAAsE;AACtE,MAAM,WAAW,aAAa,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG;IACvC,8EAA8E;IAC9E,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IACpB,mDAAmD;IACnD,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf;;;;;;;;OAQG;IACH,QAAQ,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5D;;;OAGG;IACH,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,GAAG,CAAC;CACtB;AAED,MAAM,MAAM,QAAQ,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG,IAAI,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAE/E;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,wBAAgB,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;AACrE,wBAAgB,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC"}
1
+ {"version":3,"file":"for.d.ts","sourceRoot":"","sources":["../../../src/lib/flow/for.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAsB,MAAM,yBAAyB,CAAC;AAIvE,KAAK,UAAU,CAAC,CAAC,IACb,aAAa,CAAC,CAAC,CAAC,GAChB,CAAC,MAAM,aAAa,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC,GAC3C,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,GAC1B,IAAI,GACJ,SAAS,GACT,KAAK,CAAC;AAEV,oEAAoE;AACpE,MAAM,WAAW,eAAe,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG;IACzC,6EAA6E;IAC7E,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IACpB,mDAAmD;IACnD,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf;;;;;OAKG;IACH,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAClD,EAAE,CAAC,EAAE,SAAS,CAAC;CAChB;AAED,qEAAqE;AACrE,MAAM,WAAW,aAAa,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG;IACvC,6EAA6E;IAC7E,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IACpB,mDAAmD;IACnD,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf;;;;;;;;OAQG;IACH,QAAQ,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5D;;;OAGG;IACH,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,GAAG,CAAC;CACtB;AAED,MAAM,MAAM,QAAQ,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG,IAAI,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAE/E;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,wBAAgB,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;AACrE,wBAAgB,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC"}
@@ -4,7 +4,7 @@ import { hydrateAdvancePast } from '../dom/hydration-state.js';
4
4
  export function For(props) {
5
5
  // Read `each` lazily through the prop getter so `each={items()}` re-runs inside
6
6
  // mapArray's tracking memo (fine-grained keyed diffing), while `each={items}` still
7
- // works resolveReactiveProp unwraps the accessor form once.
7
+ // works: resolveReactiveProp unwraps the accessor form once.
8
8
  const each = resolveReactiveProp(() => props.each);
9
9
  const fallback = () => props.fallback ?? null;
10
10
  // Render the children (a fn, or an array of fn/values) for one item, then
@@ -19,7 +19,7 @@ export function For(props) {
19
19
  hydrateAdvancePast(rendered);
20
20
  return rendered;
21
21
  };
22
- // `by` key-function reconciliation (item is a live accessor); default
22
+ // `by` -> key-function reconciliation (item is a live accessor); default ->
23
23
  // reference reconciliation (item is the plain value). Both keep each item in
24
24
  // its own root so list items stay owner-stable.
25
25
  return props.by
@@ -1 +1,45 @@
1
- import{mapArray as d,keyArray as f}from"@fluixi/reactive/signal";function u(r){return()=>{let e=r();return typeof e=="function"?e():e}}var a={active:!1,cursor:null,parents:[]};function p(r){let e=a.parents.lastIndexOf(r);e!==-1&&(a.parents.length=e),a.cursor=r.nextSibling}function y(r){if(!a.active||r==null)return;let e=Array.isArray(r)?r[r.length-1]:r;e&&typeof e.nodeType=="number"&&p(e)}function m(r){let e=u(()=>r.each),c=()=>r.fallback??null,i=(n,t)=>{let o=r.children,l=Array.isArray(o)?o.map(s=>typeof s=="function"?s(n,t):s):typeof o=="function"?o(n,t):o;return y(l),l};return r.by?f(e,r.by,(n,t)=>i(n,t),{fallback:c}):d(e,(n,t)=>i(n,t),{fallback:c})}export{m as For};
1
+ // src/lib/flow/for.ts
2
+ import { mapArray, keyArray } from "@fluixi/reactive/signal";
3
+
4
+ // src/lib/flow/utils.ts
5
+ function resolveReactiveProp(read) {
6
+ return () => {
7
+ const value = read();
8
+ return typeof value === "function" ? value() : value;
9
+ };
10
+ }
11
+
12
+ // src/lib/dom/hydration-state.ts
13
+ var hydration = {
14
+ active: false,
15
+ cursor: null,
16
+ parents: []
17
+ };
18
+ function ascendPast(node) {
19
+ const idx = hydration.parents.lastIndexOf(node);
20
+ if (idx !== -1) hydration.parents.length = idx;
21
+ hydration.cursor = node.nextSibling;
22
+ }
23
+ function hydrateAdvancePast(rendered) {
24
+ if (!hydration.active || rendered == null) return;
25
+ const last = Array.isArray(rendered) ? rendered[rendered.length - 1] : rendered;
26
+ if (last && typeof last.nodeType === "number") {
27
+ ascendPast(last);
28
+ }
29
+ }
30
+
31
+ // src/lib/flow/for.ts
32
+ function For(props) {
33
+ const each = resolveReactiveProp(() => props.each);
34
+ const fallback = () => props.fallback ?? null;
35
+ const render = (item, index) => {
36
+ const children = props.children;
37
+ const rendered = Array.isArray(children) ? children.map((c) => typeof c === "function" ? c(item, index) : c) : typeof children === "function" ? children(item, index) : children;
38
+ hydrateAdvancePast(rendered);
39
+ return rendered;
40
+ };
41
+ return props.by ? keyArray(each, props.by, (item, index) => render(item, index), { fallback }) : mapArray(each, (item, index) => render(item, index), { fallback });
42
+ }
43
+ export {
44
+ For
45
+ };
@@ -1 +1,67 @@
1
- "use strict";var s=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var p=(e,r)=>{for(var n in r)s(e,n,{get:r[n],enumerable:!0})},y=(e,r,n,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of d(r))!f.call(e,t)&&t!==n&&s(e,t,{get:()=>r[t],enumerable:!(o=u(r,t))||o.enumerable});return e};var T=e=>y(s({},"__esModule",{value:!0}),e);var A={};p(A,{Index:()=>v});module.exports=T(A);var l=require("@fluixi/reactive/signal");function i(e){return()=>{let r=e();return typeof r=="function"?r():r}}var a={active:!1,cursor:null,parents:[]};function x(e){let r=a.parents.lastIndexOf(e);r!==-1&&(a.parents.length=r),a.cursor=e.nextSibling}function c(e){if(!a.active||e==null)return;let r=Array.isArray(e)?e[e.length-1]:e;r&&typeof r.nodeType=="number"&&x(r)}function v(e){let r=i(()=>e.each);return(0,l.indexArray)(r,(n,o)=>{let t=e.children(n,o);return c(t),t},{fallback:()=>e.fallback??null})}
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/lib/flow/index-flow.ts
21
+ var index_flow_exports = {};
22
+ __export(index_flow_exports, {
23
+ Index: () => Index
24
+ });
25
+ module.exports = __toCommonJS(index_flow_exports);
26
+ var import_signal = require("@fluixi/reactive/signal");
27
+
28
+ // src/lib/flow/utils.ts
29
+ function resolveReactiveProp(read) {
30
+ return () => {
31
+ const value = read();
32
+ return typeof value === "function" ? value() : value;
33
+ };
34
+ }
35
+
36
+ // src/lib/dom/hydration-state.ts
37
+ var hydration = {
38
+ active: false,
39
+ cursor: null,
40
+ parents: []
41
+ };
42
+ function ascendPast(node) {
43
+ const idx = hydration.parents.lastIndexOf(node);
44
+ if (idx !== -1) hydration.parents.length = idx;
45
+ hydration.cursor = node.nextSibling;
46
+ }
47
+ function hydrateAdvancePast(rendered) {
48
+ if (!hydration.active || rendered == null) return;
49
+ const last = Array.isArray(rendered) ? rendered[rendered.length - 1] : rendered;
50
+ if (last && typeof last.nodeType === "number") {
51
+ ascendPast(last);
52
+ }
53
+ }
54
+
55
+ // src/lib/flow/index-flow.ts
56
+ function Index(props) {
57
+ const each = resolveReactiveProp(() => props.each);
58
+ return (0, import_signal.indexArray)(
59
+ each,
60
+ (item, index) => {
61
+ const rendered = props.children(item, index);
62
+ hydrateAdvancePast(rendered);
63
+ return rendered;
64
+ },
65
+ { fallback: () => props.fallback ?? null }
66
+ );
67
+ }
@@ -6,7 +6,7 @@ export interface IndexProps<T, U = any> {
6
6
  fallback?: any;
7
7
  /**
8
8
  * Render function called once per stable index slot.
9
- * `item` is a reactive accessor updates when the item at that index changes.
9
+ * `item` is a reactive accessor: updates when the item at that index changes.
10
10
  * `index` is a plain number (stable).
11
11
  *
12
12
  * JSX: <Index each={items()}>{(item, index) => <li>{item().name}</li>}</Index>
@@ -15,20 +15,20 @@ export interface IndexProps<T, U = any> {
15
15
  children: (item: Accessor<T>, index: number) => U;
16
16
  }
17
17
  /**
18
- * Non-keyed list rendering mirrors SolidJS `<Index>`.
18
+ * Non-keyed list rendering: mirrors SolidJS `<Index>`.
19
19
  *
20
20
  * Keyed by position. When the list grows, new slots are created.
21
21
  * When it shrinks, trailing slots are disposed. When an item at a
22
22
  * given index changes value, only the `item` signal updates (no re-render).
23
- * Returns a memo of the rendered array works in both JSX and `html` templates.
23
+ * Returns a memo of the rendered array: works in both JSX and `html` templates.
24
24
  *
25
25
  * @example JSX
26
26
  * <Index each={items()} fallback={<p>Empty</p>}>
27
- * {(item, index) => <li>{index} {item().name}</li>}
27
+ * {(item, index) => <li>{index}: {item().name}</li>}
28
28
  * </Index>
29
29
  *
30
30
  * @example html template
31
- * Index({ each: items, children: (item, i) => html`<li>${i} ${item().name}</li>` })
31
+ * Index({ each: items, children: (item, i) => html`<li>${i}. ${item().name}</li>` })
32
32
  */
33
33
  export declare function Index<T, U = any>(props: IndexProps<T, U>): Accessor<U[] | any>;
34
34
  //# sourceMappingURL=index-flow.d.ts.map
@@ -2,20 +2,20 @@ import { indexArray } from '@fluixi/reactive/signal';
2
2
  import { resolveReactiveProp } from './utils.js';
3
3
  import { hydrateAdvancePast } from '../dom/hydration-state.js';
4
4
  /**
5
- * Non-keyed list rendering mirrors SolidJS `<Index>`.
5
+ * Non-keyed list rendering: mirrors SolidJS `<Index>`.
6
6
  *
7
7
  * Keyed by position. When the list grows, new slots are created.
8
8
  * When it shrinks, trailing slots are disposed. When an item at a
9
9
  * given index changes value, only the `item` signal updates (no re-render).
10
- * Returns a memo of the rendered array works in both JSX and `html` templates.
10
+ * Returns a memo of the rendered array: works in both JSX and `html` templates.
11
11
  *
12
12
  * @example JSX
13
13
  * <Index each={items()} fallback={<p>Empty</p>}>
14
- * {(item, index) => <li>{index} {item().name}</li>}
14
+ * {(item, index) => <li>{index}: {item().name}</li>}
15
15
  * </Index>
16
16
  *
17
17
  * @example html template
18
- * Index({ each: items, children: (item, i) => html`<li>${i} ${item().name}</li>` })
18
+ * Index({ each: items, children: (item, i) => html`<li>${i}. ${item().name}</li>` })
19
19
  */
20
20
  export function Index(props) {
21
21
  const each = resolveReactiveProp(() => props.each);
@@ -1 +1,46 @@
1
- import{indexArray as l}from"@fluixi/reactive/signal";function o(e){return()=>{let r=e();return typeof r=="function"?r():r}}var t={active:!1,cursor:null,parents:[]};function c(e){let r=t.parents.lastIndexOf(e);r!==-1&&(t.parents.length=r),t.cursor=e.nextSibling}function a(e){if(!t.active||e==null)return;let r=Array.isArray(e)?e[e.length-1]:e;r&&typeof r.nodeType=="number"&&c(r)}function x(e){let r=o(()=>e.each);return l(r,(s,i)=>{let n=e.children(s,i);return a(n),n},{fallback:()=>e.fallback??null})}export{x as Index};
1
+ // src/lib/flow/index-flow.ts
2
+ import { indexArray } from "@fluixi/reactive/signal";
3
+
4
+ // src/lib/flow/utils.ts
5
+ function resolveReactiveProp(read) {
6
+ return () => {
7
+ const value = read();
8
+ return typeof value === "function" ? value() : value;
9
+ };
10
+ }
11
+
12
+ // src/lib/dom/hydration-state.ts
13
+ var hydration = {
14
+ active: false,
15
+ cursor: null,
16
+ parents: []
17
+ };
18
+ function ascendPast(node) {
19
+ const idx = hydration.parents.lastIndexOf(node);
20
+ if (idx !== -1) hydration.parents.length = idx;
21
+ hydration.cursor = node.nextSibling;
22
+ }
23
+ function hydrateAdvancePast(rendered) {
24
+ if (!hydration.active || rendered == null) return;
25
+ const last = Array.isArray(rendered) ? rendered[rendered.length - 1] : rendered;
26
+ if (last && typeof last.nodeType === "number") {
27
+ ascendPast(last);
28
+ }
29
+ }
30
+
31
+ // src/lib/flow/index-flow.ts
32
+ function Index(props) {
33
+ const each = resolveReactiveProp(() => props.each);
34
+ return indexArray(
35
+ each,
36
+ (item, index) => {
37
+ const rendered = props.children(item, index);
38
+ hydrateAdvancePast(rendered);
39
+ return rendered;
40
+ },
41
+ { fallback: () => props.fallback ?? null }
42
+ );
43
+ }
44
+ export {
45
+ Index
46
+ };