@askrjs/askr 0.0.35 → 0.0.37

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 (202) hide show
  1. package/README.md +17 -9
  2. package/dist/bench/components/benchmark-row.js.map +1 -1
  3. package/dist/bench/components/benchmark-table.js +1 -1
  4. package/dist/bench/components/benchmark-table.js.map +1 -1
  5. package/dist/benchmark.js +3 -3
  6. package/dist/benchmark.js.map +1 -1
  7. package/dist/bin/askr-ssg.js.map +1 -1
  8. package/dist/boot/index.d.ts +1 -7
  9. package/dist/boot/index.d.ts.map +1 -1
  10. package/dist/boot/index.js +31 -42
  11. package/dist/boot/index.js.map +1 -1
  12. package/dist/common/control.js.map +1 -1
  13. package/dist/common/env.js.map +1 -1
  14. package/dist/common/ssr-errors.js.map +1 -1
  15. package/dist/common/vnode.js.map +1 -1
  16. package/dist/components/error-boundary.js.map +1 -1
  17. package/dist/components/index.d.ts +2 -0
  18. package/dist/components/index.js +2 -0
  19. package/dist/components/link.d.ts +4 -5
  20. package/dist/components/link.d.ts.map +1 -1
  21. package/dist/components/link.js +2 -1
  22. package/dist/components/link.js.map +1 -1
  23. package/dist/control/case.js.map +1 -1
  24. package/dist/control/for.js.map +1 -1
  25. package/dist/control/shared.js.map +1 -1
  26. package/dist/control/show.js.map +1 -1
  27. package/dist/data/index.d.ts.map +1 -1
  28. package/dist/data/index.js +165 -23
  29. package/dist/data/index.js.map +1 -1
  30. package/dist/dev/invariant.js.map +1 -1
  31. package/dist/dev/logger.js.map +1 -1
  32. package/dist/foundations/icon/icon.d.ts.map +1 -1
  33. package/dist/foundations/icon/icon.js.map +1 -1
  34. package/dist/foundations/icon/icon.types.d.ts +2 -1
  35. package/dist/foundations/icon/icon.types.d.ts.map +1 -1
  36. package/dist/foundations/icon/index.d.ts +3 -0
  37. package/dist/foundations/icon/index.js +2 -0
  38. package/dist/foundations/index.d.ts +1 -18
  39. package/dist/foundations/index.js +2 -18
  40. package/dist/foundations/interactions/dismissable.js.map +1 -1
  41. package/dist/foundations/interactions/focusable.js.map +1 -1
  42. package/dist/foundations/interactions/hoverable.js.map +1 -1
  43. package/dist/foundations/interactions/index.d.ts +7 -0
  44. package/dist/foundations/interactions/index.js +7 -0
  45. package/dist/foundations/interactions/interaction-policy.js +2 -2
  46. package/dist/foundations/interactions/interaction-policy.js.map +1 -1
  47. package/dist/foundations/interactions/pressable.js.map +1 -1
  48. package/dist/foundations/interactions/roving-focus.js.map +1 -1
  49. package/dist/foundations/state/controllable.js.map +1 -1
  50. package/dist/foundations/state/index.d.ts +2 -0
  51. package/dist/foundations/state/index.js +2 -0
  52. package/dist/foundations/structures/collection.js.map +1 -1
  53. package/dist/foundations/structures/index.d.ts +8 -0
  54. package/dist/foundations/structures/index.js +7 -0
  55. package/dist/foundations/structures/layer.js.map +1 -1
  56. package/dist/foundations/structures/layout.js.map +1 -1
  57. package/dist/foundations/structures/portal.js.map +1 -1
  58. package/dist/foundations/structures/presence.js.map +1 -1
  59. package/dist/foundations/structures/slot.js.map +1 -1
  60. package/dist/foundations/utilities/aria.js.map +1 -1
  61. package/dist/foundations/utilities/compose-handlers.js.map +1 -1
  62. package/dist/foundations/utilities/compose-ref.js.map +1 -1
  63. package/dist/foundations/utilities/index.d.ts +7 -0
  64. package/dist/foundations/utilities/index.js +6 -0
  65. package/dist/foundations/utilities/merge-props.js.map +1 -1
  66. package/dist/foundations/utilities/use-id.js.map +1 -1
  67. package/dist/fx/fx.js.map +1 -1
  68. package/dist/fx/timing.js.map +1 -1
  69. package/dist/index.d.ts +2 -16
  70. package/dist/index.js +1 -17
  71. package/dist/index.js.map +1 -1
  72. package/dist/jsx/utils.js.map +1 -1
  73. package/dist/jsx-dev-runtime.d.ts +1 -1
  74. package/dist/jsx-dev-runtime.js.map +1 -1
  75. package/dist/jsx-runtime.d.ts +1 -1
  76. package/dist/jsx-runtime.js.map +1 -1
  77. package/dist/renderer/children.js.map +1 -1
  78. package/dist/renderer/cleanup.js.map +1 -1
  79. package/dist/renderer/dom.js +92 -357
  80. package/dist/renderer/dom.js.map +1 -1
  81. package/dist/renderer/evaluate.js +7 -0
  82. package/dist/renderer/evaluate.js.map +1 -1
  83. package/dist/renderer/fastpath.js +20 -18
  84. package/dist/renderer/fastpath.js.map +1 -1
  85. package/dist/renderer/for-commit.js +486 -0
  86. package/dist/renderer/for-commit.js.map +1 -0
  87. package/dist/renderer/index.js.map +1 -1
  88. package/dist/renderer/keyed.js +84 -23
  89. package/dist/renderer/keyed.js.map +1 -1
  90. package/dist/renderer/reconcile.js +11 -18
  91. package/dist/renderer/reconcile.js.map +1 -1
  92. package/dist/renderer/utils.js +5 -1
  93. package/dist/renderer/utils.js.map +1 -1
  94. package/dist/resources/index.d.ts +1 -2
  95. package/dist/resources/index.js +1 -2
  96. package/dist/router/index.d.ts +2 -2
  97. package/dist/router/index.js +2 -2
  98. package/dist/router/match.js.map +1 -1
  99. package/dist/router/navigate.d.ts.map +1 -1
  100. package/dist/router/navigate.js +4 -2
  101. package/dist/router/navigate.js.map +1 -1
  102. package/dist/router/policy.js.map +1 -1
  103. package/dist/router/route-context.js.map +1 -1
  104. package/dist/router/route.d.ts +1 -1
  105. package/dist/router/route.d.ts.map +1 -1
  106. package/dist/router/route.js +2 -33
  107. package/dist/router/route.js.map +1 -1
  108. package/dist/runtime/child-scope.d.ts +1 -0
  109. package/dist/runtime/child-scope.d.ts.map +1 -1
  110. package/dist/runtime/child-scope.js +2 -0
  111. package/dist/runtime/child-scope.js.map +1 -1
  112. package/dist/runtime/component.js +1 -1
  113. package/dist/runtime/component.js.map +1 -1
  114. package/dist/runtime/context.js.map +1 -1
  115. package/dist/runtime/control.js.map +1 -1
  116. package/dist/runtime/derive.d.ts +2 -1
  117. package/dist/runtime/derive.d.ts.map +1 -1
  118. package/dist/runtime/derive.js +15 -10
  119. package/dist/runtime/derive.js.map +1 -1
  120. package/dist/runtime/dev-namespace.js.map +1 -1
  121. package/dist/runtime/effect.d.ts.map +1 -1
  122. package/dist/runtime/effect.js +34 -9
  123. package/dist/runtime/effect.js.map +1 -1
  124. package/dist/runtime/events.js.map +1 -1
  125. package/dist/runtime/execution-model.js.map +1 -1
  126. package/dist/runtime/fastlane.js.map +1 -1
  127. package/dist/runtime/for-bench.d.ts +1 -1
  128. package/dist/runtime/for-bench.d.ts.map +1 -1
  129. package/dist/runtime/for-bench.js +15 -14
  130. package/dist/runtime/for-bench.js.map +1 -1
  131. package/dist/runtime/for.d.ts +1 -0
  132. package/dist/runtime/for.d.ts.map +1 -1
  133. package/dist/runtime/for.js +90 -31
  134. package/dist/runtime/for.js.map +1 -1
  135. package/dist/runtime/operations.d.ts.map +1 -1
  136. package/dist/runtime/operations.js +10 -8
  137. package/dist/runtime/operations.js.map +1 -1
  138. package/dist/runtime/perf-metrics.js +8 -2
  139. package/dist/runtime/perf-metrics.js.map +1 -1
  140. package/dist/runtime/readable.js.map +1 -1
  141. package/dist/runtime/resource-cell.js +3 -2
  142. package/dist/runtime/resource-cell.js.map +1 -1
  143. package/dist/runtime/scheduler.d.ts +0 -1
  144. package/dist/runtime/scheduler.d.ts.map +1 -1
  145. package/dist/runtime/scheduler.js +6 -19
  146. package/dist/runtime/scheduler.js.map +1 -1
  147. package/dist/runtime/selector.d.ts.map +1 -1
  148. package/dist/runtime/selector.js +182 -103
  149. package/dist/runtime/selector.js.map +1 -1
  150. package/dist/runtime/snapshot-source.d.ts +10 -0
  151. package/dist/runtime/snapshot-source.d.ts.map +1 -0
  152. package/dist/runtime/snapshot-source.js +17 -0
  153. package/dist/runtime/snapshot-source.js.map +1 -0
  154. package/dist/runtime/ssr-bridge.js.map +1 -1
  155. package/dist/runtime/state.d.ts.map +1 -1
  156. package/dist/runtime/state.js +1 -5
  157. package/dist/runtime/state.js.map +1 -1
  158. package/dist/ssg/batch-render.js.map +1 -1
  159. package/dist/ssg/create-static-gen.js.map +1 -1
  160. package/dist/ssg/generate-metadata.js.map +1 -1
  161. package/dist/ssg/incremental-manifest.js.map +1 -1
  162. package/dist/ssg/index.d.ts +1 -6
  163. package/dist/ssg/index.js +1 -6
  164. package/dist/ssg/resolve-ssg-data.js.map +1 -1
  165. package/dist/ssg/route-utils.js.map +1 -1
  166. package/dist/ssg/write-static-files.js.map +1 -1
  167. package/dist/ssr/attrs.js.map +1 -1
  168. package/dist/ssr/context.d.ts +3 -1
  169. package/dist/ssr/context.d.ts.map +1 -1
  170. package/dist/ssr/context.js +31 -11
  171. package/dist/ssr/context.js.map +1 -1
  172. package/dist/ssr/escape.js +56 -16
  173. package/dist/ssr/escape.js.map +1 -1
  174. package/dist/ssr/index.d.ts +2 -31
  175. package/dist/ssr/index.d.ts.map +1 -1
  176. package/dist/ssr/index.js +19 -49
  177. package/dist/ssr/index.js.map +1 -1
  178. package/dist/ssr/render-keys.js +1 -12
  179. package/dist/ssr/render-keys.js.map +1 -1
  180. package/dist/ssr/sink.js.map +1 -1
  181. package/dist/ssr/verify-hydration.js +25 -0
  182. package/dist/ssr/verify-hydration.js.map +1 -0
  183. package/package.json +44 -19
  184. package/dist/_virtual/_rolldown/runtime.js +0 -7
  185. package/dist/foundations/core.d.ts +0 -15
  186. package/dist/foundations/core.js +0 -13
  187. package/dist/foundations/structures.d.ts +0 -7
  188. package/dist/foundations/structures.js +0 -6
  189. package/dist/ssg/batch-render.d.ts +0 -16
  190. package/dist/ssg/batch-render.d.ts.map +0 -1
  191. package/dist/ssg/generate-metadata.d.ts +0 -24
  192. package/dist/ssg/generate-metadata.d.ts.map +0 -1
  193. package/dist/ssg/resolve-ssg-data.d.ts +0 -23
  194. package/dist/ssg/resolve-ssg-data.d.ts.map +0 -1
  195. package/dist/ssg/route-utils.d.ts +0 -16
  196. package/dist/ssg/route-utils.d.ts.map +0 -1
  197. package/dist/ssg/write-static-files.d.ts +0 -15
  198. package/dist/ssg/write-static-files.d.ts.map +0 -1
  199. package/dist/ssr/render-keys.d.ts +0 -37
  200. package/dist/ssr/render-keys.d.ts.map +0 -1
  201. package/dist/ssr/stream-render.js +0 -76
  202. package/dist/ssr/stream-render.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"merge-props.js","names":[],"sources":["../../../src/foundations/utilities/merge-props.ts"],"sourcesContent":["/**\n * mergeProps\n *\n * Deterministic props merging.\n * - For non-handlers: `base` overwrites `injected`.\n * - For handlers present in both: handlers are composed with `injected` running\n * first; it may call `preventDefault()` to suppress the `base` handler.\n *\n * POLICY DECISIONS (LOCKED):\n *\n * 1. Merge Strategy\n * Base props overwrite injected props (base wins).\n * Exception: Event handlers are composed, not overwritten.\n *\n * 2. Event Handler Detection\n * Keys starting with \"on\" are treated as event handlers.\n * This matches JSX conventions.\n *\n * 3. Handler Composition Order\n * Injected handler runs first, base handler second.\n * This allows injected handlers to prevent default.\n *\n * 4. Return Type\n * Returns intersection type (TInjected & TBase) for type safety.\n */\nimport { composeHandlers } from './compose-handlers';\n\ntype Fn = (...args: readonly unknown[]) => void;\n\nfunction isEventHandlerKey(key: string): boolean {\n return key.startsWith('on');\n}\n\nexport function mergeProps<TBase extends object, TInjected extends object>(\n base: TBase,\n injected: TInjected\n): TInjected & TBase {\n // Fast path: if base is empty, return injected as-is\n const baseKeys = Object.keys(base);\n if (baseKeys.length === 0) {\n return injected as TInjected & TBase;\n }\n\n const out = { ...(injected as object) } as TInjected & TBase;\n\n for (const key of baseKeys as Array<Extract<keyof TBase, string>>) {\n const baseValue = (base as Record<string, unknown>)[key];\n const injectedValue = (injected as Record<string, unknown>)[key];\n\n if (\n isEventHandlerKey(key) &&\n typeof baseValue === 'function' &&\n typeof injectedValue === 'function'\n ) {\n // Invariant: injected runs first; it may call preventDefault() to\n // suppress base behaviour.\n (out as Record<string, unknown>)[key] = composeHandlers(\n injectedValue as unknown as Fn,\n baseValue as unknown as Fn\n );\n continue;\n }\n\n (out as Record<string, unknown>)[key] = baseValue;\n }\n\n return out;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,SAAS,kBAAkB,KAAsB;AAC/C,QAAO,IAAI,WAAW,KAAK;;AAG7B,SAAgB,WACd,MACA,UACmB;CAEnB,MAAM,WAAW,OAAO,KAAK,KAAK;AAClC,KAAI,SAAS,WAAW,EACtB,QAAO;CAGT,MAAM,MAAM,EAAE,GAAI,UAAqB;AAEvC,MAAK,MAAM,OAAO,UAAiD;EACjE,MAAM,YAAa,KAAiC;EACpD,MAAM,gBAAiB,SAAqC;AAE5D,MACE,kBAAkB,IAAI,IACtB,OAAO,cAAc,cACrB,OAAO,kBAAkB,YACzB;AAGC,OAAgC,OAAO,gBACtC,eACA,UACD;AACD;;AAGD,MAAgC,OAAO;;AAG1C,QAAO"}
1
+ {"version":3,"file":"merge-props.js","names":[],"sources":["../../../src/foundations/utilities/merge-props.ts"],"sourcesContent":["/**\n * mergeProps\n *\n * Deterministic props merging.\n * - For non-handlers: `base` overwrites `injected`.\n * - For handlers present in both: handlers are composed with `injected` running\n * first; it may call `preventDefault()` to suppress the `base` handler.\n *\n * POLICY DECISIONS (LOCKED):\n *\n * 1. Merge Strategy\n * Base props overwrite injected props (base wins).\n * Exception: Event handlers are composed, not overwritten.\n *\n * 2. Event Handler Detection\n * Keys starting with \"on\" are treated as event handlers.\n * This matches JSX conventions.\n *\n * 3. Handler Composition Order\n * Injected handler runs first, base handler second.\n * This allows injected handlers to prevent default.\n *\n * 4. Return Type\n * Returns intersection type (TInjected & TBase) for type safety.\n */\nimport { composeHandlers } from './compose-handlers';\n\ntype Fn = (...args: readonly unknown[]) => void;\n\nfunction isEventHandlerKey(key: string): boolean {\n return key.startsWith('on');\n}\n\nexport function mergeProps<TBase extends object, TInjected extends object>(\n base: TBase,\n injected: TInjected\n): TInjected & TBase {\n // Fast path: if base is empty, return injected as-is\n const baseKeys = Object.keys(base);\n if (baseKeys.length === 0) {\n return injected as TInjected & TBase;\n }\n\n const out = { ...(injected as object) } as TInjected & TBase;\n\n for (const key of baseKeys as Array<Extract<keyof TBase, string>>) {\n const baseValue = (base as Record<string, unknown>)[key];\n const injectedValue = (injected as Record<string, unknown>)[key];\n\n if (\n isEventHandlerKey(key) &&\n typeof baseValue === 'function' &&\n typeof injectedValue === 'function'\n ) {\n // Invariant: injected runs first; it may call preventDefault() to\n // suppress base behaviour.\n (out as Record<string, unknown>)[key] = composeHandlers(\n injectedValue as unknown as Fn,\n baseValue as unknown as Fn\n );\n continue;\n }\n\n (out as Record<string, unknown>)[key] = baseValue;\n }\n\n return out;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,SAAS,kBAAkB,KAAsB;CAC/C,OAAO,IAAI,WAAW,KAAK;;AAG7B,SAAgB,WACd,MACA,UACmB;CAEnB,MAAM,WAAW,OAAO,KAAK,KAAK;CAClC,IAAI,SAAS,WAAW,GACtB,OAAO;CAGT,MAAM,MAAM,EAAE,GAAI,UAAqB;CAEvC,KAAK,MAAM,OAAO,UAAiD;EACjE,MAAM,YAAa,KAAiC;EACpD,MAAM,gBAAiB,SAAqC;EAE5D,IACE,kBAAkB,IAAI,IACtB,OAAO,cAAc,cACrB,OAAO,kBAAkB,YACzB;GAGA,IAAiC,OAAO,gBACtC,eACA,UACD;GACD;;EAGF,IAAiC,OAAO;;CAG1C,OAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-id.js","names":[],"sources":["../../../src/foundations/utilities/use-id.ts"],"sourcesContent":["export interface FormatIdOptions {\n /** Defaults to 'askr' */\n prefix?: string;\n /** Stable, caller-provided identity */\n id: string | number;\n}\n\n/**\n * formatId\n *\n * Formats a stable ID from a caller-provided identity.\n * - Pure and deterministic (no time/randomness/global counters)\n * - SSR-safe\n *\n * POLICY DECISIONS (LOCKED):\n *\n * 1. No Auto-Generation\n * Caller must provide the `id`. No random/sequential generation.\n * This ensures determinism and SSR safety.\n *\n * 2. Format Convention\n * IDs are formatted as `{prefix}-{id}`.\n * Default prefix is \"askr\".\n *\n * 3. Type Coercion\n * Numbers are coerced to strings via String().\n * This is deterministic and consistent.\n */\nexport function formatId(options: FormatIdOptions): string {\n const prefix = options.prefix ?? 'askr';\n return `${prefix}-${String(options.id)}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA4BA,SAAgB,SAAS,SAAkC;AAEzD,QAAO,GADQ,QAAQ,UAAU,OAChB,GAAG,OAAO,QAAQ,GAAG"}
1
+ {"version":3,"file":"use-id.js","names":[],"sources":["../../../src/foundations/utilities/use-id.ts"],"sourcesContent":["export interface FormatIdOptions {\n /** Defaults to 'askr' */\n prefix?: string;\n /** Stable, caller-provided identity */\n id: string | number;\n}\n\n/**\n * formatId\n *\n * Formats a stable ID from a caller-provided identity.\n * - Pure and deterministic (no time/randomness/global counters)\n * - SSR-safe\n *\n * POLICY DECISIONS (LOCKED):\n *\n * 1. No Auto-Generation\n * Caller must provide the `id`. No random/sequential generation.\n * This ensures determinism and SSR safety.\n *\n * 2. Format Convention\n * IDs are formatted as `{prefix}-{id}`.\n * Default prefix is \"askr\".\n *\n * 3. Type Coercion\n * Numbers are coerced to strings via String().\n * This is deterministic and consistent.\n */\nexport function formatId(options: FormatIdOptions): string {\n const prefix = options.prefix ?? 'askr';\n return `${prefix}-${String(options.id)}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA4BA,SAAgB,SAAS,SAAkC;CAEzD,OAAO,GADQ,QAAQ,UAAU,OAChB,GAAG,OAAO,QAAQ,GAAG"}
package/dist/fx/fx.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"fx.js","names":[],"sources":["../../src/fx/fx.ts"],"sourcesContent":["import { globalScheduler } from '../runtime/scheduler';\nimport { getCurrentComponentInstance } from '../runtime/component';\nimport { logger } from '../dev/logger';\nimport { noopEventListener, noopEventListenerWithFlush } from './noop';\n\nexport type CancelFn = () => void;\n\n// Platform-specific timer handle types\ntype TimeoutHandle = ReturnType<typeof setTimeout> | null;\n// rAF may fall back to setTimeout in some environments/tests, include both\ntype RafHandle =\n | ReturnType<typeof requestAnimationFrame>\n | ReturnType<typeof setTimeout>\n | null;\n// requestIdleCallback may be unavailable; allow setTimeout fallback handle\ntype IdleHandle =\n | ReturnType<typeof requestIdleCallback>\n | ReturnType<typeof setTimeout>\n | null;\n\nfunction throwIfDuringRender(): void {\n const inst = getCurrentComponentInstance();\n if (inst !== null) {\n throw new Error(\n '[Askr] calling FX handler during render is not allowed. Move calls to event handlers or effects.'\n );\n }\n}\n\n/**\n * Helper: schedule a user callback through the global scheduler\n */\nfunction enqueueUserCallback(fn: () => void) {\n globalScheduler.enqueue(() => {\n try {\n fn();\n } catch (err) {\n // Keep behavior consistent with other scheduler-queued work\n logger.error('[Askr] FX handler error:', err);\n }\n });\n}\n\n// ---------- Event handlers ----------\n\nexport function debounceEvent(\n ms: number,\n handler: EventListener,\n options?: { leading?: boolean; trailing?: boolean }\n): EventListener & { cancel(): void; flush(): void } {\n const { leading = false, trailing = true } = options || {};\n\n const inst = getCurrentComponentInstance();\n // On SSR, event handlers are inert\n if (inst && inst.ssr) {\n return noopEventListenerWithFlush;\n }\n\n let timeoutId: TimeoutHandle = null;\n let lastEvent: Event | null = null;\n let lastCallTime = 0;\n\n const debounced = function (this: unknown, ev: Event) {\n // Disallow using returned handler during render\n throwIfDuringRender();\n\n const now = Date.now();\n lastEvent = ev;\n\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n\n if (leading && now - lastCallTime >= ms) {\n enqueueUserCallback(() => handler.call(null, ev));\n lastCallTime = now;\n }\n\n if (trailing) {\n timeoutId = setTimeout(() => {\n // Schedule through scheduler\n if (lastEvent) {\n enqueueUserCallback(() => handler.call(null, lastEvent!));\n }\n timeoutId = null;\n lastCallTime = Date.now();\n }, ms);\n }\n } as EventListener & { cancel(): void; flush(): void };\n\n debounced.cancel = () => {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n lastEvent = null;\n };\n\n debounced.flush = () => {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n const ev = lastEvent;\n lastEvent = null;\n timeoutId = null;\n if (ev) enqueueUserCallback(() => handler.call(null, ev));\n }\n };\n\n // Auto-cleanup on component unmount\n if (inst) {\n (inst.cleanupFns ??= []).push(() => {\n debounced.cancel();\n });\n }\n\n return debounced;\n}\n\nexport function throttleEvent(\n ms: number,\n handler: EventListener,\n options?: { leading?: boolean; trailing?: boolean }\n): EventListener & { cancel(): void } {\n const { leading = true, trailing = true } = options || {};\n\n const inst = getCurrentComponentInstance();\n if (inst && inst.ssr) {\n return noopEventListener;\n }\n\n let lastCallTime = 0;\n let timeoutId: TimeoutHandle = null;\n let lastEvent: Event | null = null;\n\n const throttled = function (this: unknown, ev: Event) {\n throwIfDuringRender();\n\n const now = Date.now();\n lastEvent = ev;\n\n if (leading && now - lastCallTime >= ms) {\n enqueueUserCallback(() => handler.call(null, ev));\n lastCallTime = now;\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n } else if (!leading && lastCallTime === 0) {\n lastCallTime = now;\n }\n\n if (trailing && timeoutId === null) {\n const wait = ms - (now - lastCallTime);\n timeoutId = setTimeout(\n () => {\n if (lastEvent)\n enqueueUserCallback(() => handler.call(null, lastEvent!));\n lastCallTime = Date.now();\n timeoutId = null;\n },\n Math.max(0, wait)\n );\n }\n } as EventListener & { cancel(): void };\n\n throttled.cancel = () => {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n lastEvent = null;\n };\n\n if (inst) {\n (inst.cleanupFns ??= []).push(() => throttled.cancel());\n }\n\n return throttled;\n}\n\nexport function rafEvent(\n handler: EventListener\n): EventListener & { cancel(): void } {\n const inst = getCurrentComponentInstance();\n if (inst && inst.ssr) {\n return noopEventListener;\n }\n\n let frameId: RafHandle = null;\n let lastEvent: Event | null = null;\n\n const scheduleFrame = () => {\n const rAF =\n typeof requestAnimationFrame !== 'undefined'\n ? requestAnimationFrame\n : (cb: FrameRequestCallback) => setTimeout(() => cb(Date.now()), 16);\n\n frameId = rAF(() => {\n frameId = null;\n if (lastEvent) {\n const ev = lastEvent;\n lastEvent = null;\n enqueueUserCallback(() => handler.call(null, ev));\n }\n });\n };\n\n const fn = function (this: unknown, ev: Event) {\n throwIfDuringRender();\n lastEvent = ev;\n if (frameId === null) scheduleFrame();\n } as EventListener & { cancel(): void };\n\n fn.cancel = () => {\n if (frameId !== null) {\n // If frameId is numeric and cancelAnimationFrame is available, use it;\n // otherwise fall back to clearTimeout for the setTimeout fallback.\n if (\n typeof cancelAnimationFrame !== 'undefined' &&\n typeof frameId === 'number'\n ) {\n cancelAnimationFrame(frameId);\n } else {\n clearTimeout(frameId as ReturnType<typeof setTimeout>);\n }\n frameId = null;\n }\n lastEvent = null;\n };\n\n if (inst) (inst.cleanupFns ??= []).push(() => fn.cancel());\n\n return fn;\n}\n\n// ---------- Scheduled work ----------\n\nexport function scheduleTimeout(ms: number, fn: () => void): CancelFn {\n throwIfDuringRender();\n const inst = getCurrentComponentInstance();\n if (inst && inst.ssr) {\n return () => {};\n }\n\n let id: TimeoutHandle = setTimeout(() => {\n id = null;\n enqueueUserCallback(fn);\n }, ms);\n\n const cancel = () => {\n if (id !== null) {\n clearTimeout(id);\n id = null;\n }\n };\n\n if (inst) (inst.cleanupFns ??= []).push(cancel);\n return cancel;\n}\n\nexport function scheduleIdle(\n fn: () => void,\n options?: { timeout?: number }\n): CancelFn {\n throwIfDuringRender();\n const inst = getCurrentComponentInstance();\n if (inst && inst.ssr) return () => {};\n\n let id: IdleHandle = null;\n let usingRIC = false;\n\n if (typeof requestIdleCallback !== 'undefined') {\n usingRIC = true;\n id = requestIdleCallback(() => {\n id = null;\n enqueueUserCallback(fn);\n }, options);\n } else {\n // Fallback: schedule on next macrotask\n id = setTimeout(() => {\n id = null;\n enqueueUserCallback(fn);\n }, 0);\n }\n\n const cancel = () => {\n if (id !== null) {\n // If using requestIdleCallback and available, call cancelIdleCallback for numeric ids.\n if (\n usingRIC &&\n typeof cancelIdleCallback !== 'undefined' &&\n typeof id === 'number'\n ) {\n cancelIdleCallback(id);\n } else {\n clearTimeout(id as ReturnType<typeof setTimeout>);\n }\n id = null;\n }\n };\n\n if (inst) (inst.cleanupFns ??= []).push(cancel);\n return cancel;\n}\n\nexport interface RetryOptions {\n maxAttempts?: number;\n delayMs?: number;\n backoff?: (attemptIndex: number) => number;\n}\n\nexport function scheduleRetry<T>(\n fn: () => Promise<T>,\n options?: RetryOptions\n): { cancel(): void } {\n throwIfDuringRender();\n const inst = getCurrentComponentInstance();\n if (inst && inst.ssr) return { cancel: () => {} };\n\n const {\n maxAttempts = 3,\n delayMs = 100,\n backoff = (i: number) => delayMs * Math.pow(2, i),\n } = options || {};\n\n let cancelled = false;\n\n const attempt = (index: number) => {\n if (cancelled) return;\n // Run user fn inside scheduler\n globalScheduler.enqueue(() => {\n if (cancelled) return;\n // Call fn (it may be async)\n const p = fn();\n p.then(\n () => {\n // Completed successfully\n },\n () => {\n if (cancelled) return;\n if (index + 1 < maxAttempts) {\n const delay = backoff(index);\n // Schedule next attempt via setTimeout so it gets enqueued through scheduleTimeout\n setTimeout(() => {\n attempt(index + 1);\n }, delay);\n }\n }\n ).catch((e) => {\n logger.error('[Askr] scheduleRetry error:', e);\n });\n });\n };\n\n // Start first attempt\n attempt(0);\n\n const cancel = () => {\n cancelled = true;\n };\n\n if (inst) (inst.cleanupFns ??= []).push(cancel);\n return { cancel };\n}\n"],"mappings":";;;;;AAoBA,SAAS,sBAA4B;AAEnC,KADa,6BACT,KAAS,KACX,OAAM,IAAI,MACR,mGACD;;;;;AAOL,SAAS,oBAAoB,IAAgB;AAC3C,iBAAgB,cAAc;AAC5B,MAAI;AACF,OAAI;WACG,KAAK;AAEZ,UAAO,MAAM,4BAA4B,IAAI;;GAE/C;;AAKJ,SAAgB,cACd,IACA,SACA,SACmD;CACnD,MAAM,EAAE,UAAU,OAAO,WAAW,SAAS,WAAW,EAAE;CAE1D,MAAM,OAAO,6BAA6B;AAE1C,KAAI,QAAQ,KAAK,IACf,QAAO;CAGT,IAAI,YAA2B;CAC/B,IAAI,YAA0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AE;QACjB,MAAM;;KAGd,CAAC,OAAO,MAAM;AACb,WAAO,MAAM,+BAA+B,EAAE;KAC9C;IACF;;AAIJ,SAAQ,EAAE;CAEV,MAAM,eAAe;AACnB,cAAY;;AAGd,KAAI,KAAM,EAAC,KAAK,eAAe,EAAE,EAAE,KAAK,OAAO;AAC/C,QAAO,EAAE,QAAQ"}
1
+ {"version":3,"file":"fx.js","names":[],"sources":["../../src/fx/fx.ts"],"sourcesContent":["import { globalScheduler } from '../runtime/scheduler';\nimport { getCurrentComponentInstance } from '../runtime/component';\nimport { logger } from '../dev/logger';\nimport { noopEventListener, noopEventListenerWithFlush } from './noop';\n\nexport type CancelFn = () => void;\n\n// Platform-specific timer handle types\ntype TimeoutHandle = ReturnType<typeof setTimeout> | null;\n// rAF may fall back to setTimeout in some environments/tests, include both\ntype RafHandle =\n | ReturnType<typeof requestAnimationFrame>\n | ReturnType<typeof setTimeout>\n | null;\n// requestIdleCallback may be unavailable; allow setTimeout fallback handle\ntype IdleHandle =\n | ReturnType<typeof requestIdleCallback>\n | ReturnType<typeof setTimeout>\n | null;\n\nfunction throwIfDuringRender(): void {\n const inst = getCurrentComponentInstance();\n if (inst !== null) {\n throw new Error(\n '[Askr] calling FX handler during render is not allowed. Move calls to event handlers or effects.'\n );\n }\n}\n\n/**\n * Helper: schedule a user callback through the global scheduler\n */\nfunction enqueueUserCallback(fn: () => void) {\n globalScheduler.enqueue(() => {\n try {\n fn();\n } catch (err) {\n // Keep behavior consistent with other scheduler-queued work\n logger.error('[Askr] FX handler error:', err);\n }\n });\n}\n\n// ---------- Event handlers ----------\n\nexport function debounceEvent(\n ms: number,\n handler: EventListener,\n options?: { leading?: boolean; trailing?: boolean }\n): EventListener & { cancel(): void; flush(): void } {\n const { leading = false, trailing = true } = options || {};\n\n const inst = getCurrentComponentInstance();\n // On SSR, event handlers are inert\n if (inst && inst.ssr) {\n return noopEventListenerWithFlush;\n }\n\n let timeoutId: TimeoutHandle = null;\n let lastEvent: Event | null = null;\n let lastCallTime = 0;\n\n const debounced = function (this: unknown, ev: Event) {\n // Disallow using returned handler during render\n throwIfDuringRender();\n\n const now = Date.now();\n lastEvent = ev;\n\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n\n if (leading && now - lastCallTime >= ms) {\n enqueueUserCallback(() => handler.call(null, ev));\n lastCallTime = now;\n }\n\n if (trailing) {\n timeoutId = setTimeout(() => {\n // Schedule through scheduler\n if (lastEvent) {\n enqueueUserCallback(() => handler.call(null, lastEvent!));\n }\n timeoutId = null;\n lastCallTime = Date.now();\n }, ms);\n }\n } as EventListener & { cancel(): void; flush(): void };\n\n debounced.cancel = () => {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n lastEvent = null;\n };\n\n debounced.flush = () => {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n const ev = lastEvent;\n lastEvent = null;\n timeoutId = null;\n if (ev) enqueueUserCallback(() => handler.call(null, ev));\n }\n };\n\n // Auto-cleanup on component unmount\n if (inst) {\n (inst.cleanupFns ??= []).push(() => {\n debounced.cancel();\n });\n }\n\n return debounced;\n}\n\nexport function throttleEvent(\n ms: number,\n handler: EventListener,\n options?: { leading?: boolean; trailing?: boolean }\n): EventListener & { cancel(): void } {\n const { leading = true, trailing = true } = options || {};\n\n const inst = getCurrentComponentInstance();\n if (inst && inst.ssr) {\n return noopEventListener;\n }\n\n let lastCallTime = 0;\n let timeoutId: TimeoutHandle = null;\n let lastEvent: Event | null = null;\n\n const throttled = function (this: unknown, ev: Event) {\n throwIfDuringRender();\n\n const now = Date.now();\n lastEvent = ev;\n\n if (leading && now - lastCallTime >= ms) {\n enqueueUserCallback(() => handler.call(null, ev));\n lastCallTime = now;\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n } else if (!leading && lastCallTime === 0) {\n lastCallTime = now;\n }\n\n if (trailing && timeoutId === null) {\n const wait = ms - (now - lastCallTime);\n timeoutId = setTimeout(\n () => {\n if (lastEvent)\n enqueueUserCallback(() => handler.call(null, lastEvent!));\n lastCallTime = Date.now();\n timeoutId = null;\n },\n Math.max(0, wait)\n );\n }\n } as EventListener & { cancel(): void };\n\n throttled.cancel = () => {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n lastEvent = null;\n };\n\n if (inst) {\n (inst.cleanupFns ??= []).push(() => throttled.cancel());\n }\n\n return throttled;\n}\n\nexport function rafEvent(\n handler: EventListener\n): EventListener & { cancel(): void } {\n const inst = getCurrentComponentInstance();\n if (inst && inst.ssr) {\n return noopEventListener;\n }\n\n let frameId: RafHandle = null;\n let lastEvent: Event | null = null;\n\n const scheduleFrame = () => {\n const rAF =\n typeof requestAnimationFrame !== 'undefined'\n ? requestAnimationFrame\n : (cb: FrameRequestCallback) => setTimeout(() => cb(Date.now()), 16);\n\n frameId = rAF(() => {\n frameId = null;\n if (lastEvent) {\n const ev = lastEvent;\n lastEvent = null;\n enqueueUserCallback(() => handler.call(null, ev));\n }\n });\n };\n\n const fn = function (this: unknown, ev: Event) {\n throwIfDuringRender();\n lastEvent = ev;\n if (frameId === null) scheduleFrame();\n } as EventListener & { cancel(): void };\n\n fn.cancel = () => {\n if (frameId !== null) {\n // If frameId is numeric and cancelAnimationFrame is available, use it;\n // otherwise fall back to clearTimeout for the setTimeout fallback.\n if (\n typeof cancelAnimationFrame !== 'undefined' &&\n typeof frameId === 'number'\n ) {\n cancelAnimationFrame(frameId);\n } else {\n clearTimeout(frameId as ReturnType<typeof setTimeout>);\n }\n frameId = null;\n }\n lastEvent = null;\n };\n\n if (inst) (inst.cleanupFns ??= []).push(() => fn.cancel());\n\n return fn;\n}\n\n// ---------- Scheduled work ----------\n\nexport function scheduleTimeout(ms: number, fn: () => void): CancelFn {\n throwIfDuringRender();\n const inst = getCurrentComponentInstance();\n if (inst && inst.ssr) {\n return () => {};\n }\n\n let id: TimeoutHandle = setTimeout(() => {\n id = null;\n enqueueUserCallback(fn);\n }, ms);\n\n const cancel = () => {\n if (id !== null) {\n clearTimeout(id);\n id = null;\n }\n };\n\n if (inst) (inst.cleanupFns ??= []).push(cancel);\n return cancel;\n}\n\nexport function scheduleIdle(\n fn: () => void,\n options?: { timeout?: number }\n): CancelFn {\n throwIfDuringRender();\n const inst = getCurrentComponentInstance();\n if (inst && inst.ssr) return () => {};\n\n let id: IdleHandle = null;\n let usingRIC = false;\n\n if (typeof requestIdleCallback !== 'undefined') {\n usingRIC = true;\n id = requestIdleCallback(() => {\n id = null;\n enqueueUserCallback(fn);\n }, options);\n } else {\n // Fallback: schedule on next macrotask\n id = setTimeout(() => {\n id = null;\n enqueueUserCallback(fn);\n }, 0);\n }\n\n const cancel = () => {\n if (id !== null) {\n // If using requestIdleCallback and available, call cancelIdleCallback for numeric ids.\n if (\n usingRIC &&\n typeof cancelIdleCallback !== 'undefined' &&\n typeof id === 'number'\n ) {\n cancelIdleCallback(id);\n } else {\n clearTimeout(id as ReturnType<typeof setTimeout>);\n }\n id = null;\n }\n };\n\n if (inst) (inst.cleanupFns ??= []).push(cancel);\n return cancel;\n}\n\nexport interface RetryOptions {\n maxAttempts?: number;\n delayMs?: number;\n backoff?: (attemptIndex: number) => number;\n}\n\nexport function scheduleRetry<T>(\n fn: () => Promise<T>,\n options?: RetryOptions\n): { cancel(): void } {\n throwIfDuringRender();\n const inst = getCurrentComponentInstance();\n if (inst && inst.ssr) return { cancel: () => {} };\n\n const {\n maxAttempts = 3,\n delayMs = 100,\n backoff = (i: number) => delayMs * Math.pow(2, i),\n } = options || {};\n\n let cancelled = false;\n\n const attempt = (index: number) => {\n if (cancelled) return;\n // Run user fn inside scheduler\n globalScheduler.enqueue(() => {\n if (cancelled) return;\n // Call fn (it may be async)\n const p = fn();\n p.then(\n () => {\n // Completed successfully\n },\n () => {\n if (cancelled) return;\n if (index + 1 < maxAttempts) {\n const delay = backoff(index);\n // Schedule next attempt via setTimeout so it gets enqueued through scheduleTimeout\n setTimeout(() => {\n attempt(index + 1);\n }, delay);\n }\n }\n ).catch((e) => {\n logger.error('[Askr] scheduleRetry error:', e);\n });\n });\n };\n\n // Start first attempt\n attempt(0);\n\n const cancel = () => {\n cancelled = true;\n };\n\n if (inst) (inst.cleanupFns ??= []).push(cancel);\n return { cancel };\n}\n"],"mappings":";;;;;AAoBA,SAAS,sBAA4B;CAEnC,IADa,6BACT,KAAS,MACX,MAAM,IAAI,MACR,mGACD;;;;;AAOL,SAAS,oBAAoB,IAAgB;CAC3C,gBAAgB,cAAc;EAC5B,IAAI;GACF,IAAI;WACG,KAAK;GAEZ,OAAO,MAAM,4BAA4B,IAAI;;GAE/C;;AAKJ,SAAgB,cACd,IACA,SACA,SACmD;CACnD,MAAM,EAAE,UAAU,OAAO,WAAW,SAAS,WAAW,EAAE;CAE1D,MAAM,OAAO,6BAA6B;CAE1C,IAAI,QAAQ,KAAK,KACf,OAAO;CAGT,IAAI,YAA2B;CAC/B,IAAI,YAA0B;CAC9B,IAAI,eAAe;CAEnB,MAAM,YAAY,SAAyB,IAAW;EAEpD,qBAAqB;EAErB,MAAM,MAAM,KAAK,KAAK;EACtB,YAAY;EAEZ,IAAI,cAAc,MAAM;GACtB,aAAa,UAAU;GACvB,YAAY;;EAGd,IAAI,WAAW,MAAM,gBAAgB,IAAI;GACvC,0BAA0B,QAAQ,KAAK,MAAM,GAAG,CAAC;GACjD,eAAe;;EAGjB,IAAI,UACF,YAAY,iBAAiB;GAE3B,IAAI,WACF,0BAA0B,QAAQ,KAAK,MAAM,UAAW,CAAC;GAE3D,YAAY;GACZ,eAAe,KAAK,KAAK;KACxB,GAAG;;CAIV,UAAU,eAAe;EACvB,IAAI,cAAc,MAAM;GACtB,aAAa,UAAU;GACvB,YAAY;;EAEd,YAAY;;CAGd,UAAU,cAAc;EACtB,IAAI,cAAc,MAAM;GACtB,aAAa,UAAU;GACvB,MAAM,KAAK;GACX,YAAY;GACZ,YAAY;GACZ,IAAI,IAAI,0BAA0B,QAAQ,KAAK,MAAM,GAAG,CAA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nD,KAAK;;;CAIT,IAAI,MAAM,CAAC,KAAK,eAAe,EAAE,EAAE,KAAK,OAAO;CAC/C,OAAO;;AAST,SAAgB,cACd,IACA,SACoB;CACpB,qBAAqB;CACrB,MAAM,OAAO,6BAA6B;CAC1C,IAAI,QAAQ,KAAK,KAAK,OAAO,EAAE,cAAc,IAAI;CAEjD,MAAM,EACJ,cAAc,GACd,UAAU,KACV,WAAW,MAAc,UAAU,KAAK,IAAI,GAAG,EAAE,KAC/C,WAAW,EAAE;CAEjB,IAAI,YAAY;CAEhB,MAAM,WAAW,UAAkB;EACjC,IAAI,WAAW;EAEf,gBAAgB,cAAc;GAC5B,IAAI,WAAW;GAGf,AADU,IACV,CAAE,WACM,UAGA;IACJ,IAAI,WAAW;IACf,IAAI,QAAQ,IAAI,aAAa;KAC3B,MAAM,QAAQ,QAAQ,MAAM;KAE5B,iBAAiB;MACf,QAAQ,QAAQ,EAAE;QACjB,MAAM;;KAGd,CAAC,OAAO,MAAM;IACb,OAAO,MAAM,+BAA+B,EAAE;KAC9C;IACF;;CAIJ,QAAQ,EAAE;CAEV,MAAM,eAAe;EACnB,YAAY;;CAGd,IAAI,MAAM,CAAC,KAAK,eAAe,EAAE,EAAE,KAAK,OAAO;CAC/C,OAAO,EAAE,QAAQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"timing.js","names":[],"sources":["../../src/fx/timing.ts"],"sourcesContent":["/**\n * Timing utilities — pure helpers for common async patterns\n * No framework coupling. No lifecycle awareness.\n */\n\nexport interface DebounceOptions {\n leading?: boolean;\n trailing?: boolean;\n}\n\nexport interface ThrottleOptions {\n leading?: boolean;\n trailing?: boolean;\n}\n\nexport interface RetryOptions {\n maxAttempts?: number;\n delayMs?: number;\n backoff?: (attemptIndex: number) => number;\n}\n\n/**\n * Debounce — delay execution, coalesce rapid calls\n *\n * Useful for: text input, resize, autosave\n *\n * @param fn Function to debounce\n * @param ms Delay in milliseconds\n * @param options trailing (default true), leading\n * @returns Debounced function with cancel() method\n *\n * @example\n * ```ts\n * const save = debounce((text) => api.save(text), 500);\n * input.addEventListener('input', (e) => save(e.target.value));\n * save.cancel(); // stop any pending execution\n * ```\n */\nexport function debounce<T extends (...args: unknown[]) => unknown>(\n fn: T,\n ms: number,\n options?: DebounceOptions\n): T & { cancel(): void } {\n let timeoutId: NodeJS.Timeout | null = null;\n const { leading = false, trailing = true } = options || {};\n let lastArgs: unknown[] | null = null;\n let lastThis: unknown = null;\n let lastCallTime = 0;\n\n const debounced = function (this: unknown, ...args: unknown[]) {\n const callTime = Date.now();\n lastArgs = args;\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n lastThis = this;\n\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n }\n\n if (leading && callTime - lastCallTime >= ms) {\n fn.apply(this, args);\n lastCallTime = callTime;\n }\n\n if (trailing) {\n timeoutId = setTimeout(() => {\n fn.apply(lastThis, lastArgs!);\n timeoutId = null;\n lastCallTime = Date.now();\n }, ms);\n }\n };\n\n debounced.cancel = () => {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n };\n\n return debounced as T & { cancel(): void };\n}\n\n/**\n * Throttle — rate-limit execution, keep first/last\n *\n * Useful for: scroll, mouse move, high-frequency events\n *\n * @param fn Function to throttle\n * @param ms Minimum interval between calls in milliseconds\n * @param options leading (default true), trailing (default true)\n * @returns Throttled function with cancel() method\n *\n * @example\n * ```ts\n * const handleScroll = throttle(updateUI, 100);\n * window.addEventListener('scroll', handleScroll);\n * handleScroll.cancel();\n * ```\n */\nexport function throttle<T extends (...args: unknown[]) => unknown>(\n fn: T,\n ms: number,\n options?: ThrottleOptions\n): T & { cancel(): void } {\n let lastCallTime = 0;\n let timeoutId: NodeJS.Timeout | null = null;\n const { leading = true, trailing = true } = options || {};\n let lastArgs: unknown[] | null = null;\n let lastThis: unknown = null;\n\n const throttled = function (this: unknown, ...args: unknown[]) {\n const callTime = Date.now();\n lastArgs = args;\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n lastThis = this;\n\n if (leading && callTime - lastCallTime >= ms) {\n fn.apply(this, args);\n lastCallTime = callTime;\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n } else if (!leading && lastCallTime === 0) {\n lastCallTime = callTime;\n }\n\n if (trailing && timeoutId === null) {\n timeoutId = setTimeout(\n () => {\n fn.apply(lastThis, lastArgs!);\n lastCallTime = Date.now();\n timeoutId = null;\n },\n ms - (callTime - lastCallTime)\n );\n }\n };\n\n throttled.cancel = () => {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n };\n\n return throttled as T & { cancel(): void };\n}\n\n/**\n * Once — guard against double execution\n *\n * Useful for: init logic, event safety\n *\n * @param fn Function to call at most once\n * @returns Function that executes fn only on first call\n *\n * @example\n * ```ts\n * const init = once(setup);\n * init(); // runs\n * init(); // does nothing\n * init(); // does nothing\n * ```\n */\nexport function once<T extends (...args: unknown[]) => unknown>(fn: T): T {\n let called = false;\n let result: unknown;\n\n return ((...args: unknown[]) => {\n if (!called) {\n called = true;\n result = fn(...args);\n }\n return result;\n }) as T;\n}\n\n/**\n * Defer — schedule on microtask queue\n *\n * Useful for: run-after-current-stack logic\n * More reliable than setTimeout(..., 0)\n *\n * @param fn Function to defer\n *\n * @example\n * ```ts\n * defer(() => update()); // runs after current stack, before next macrotask\n * ```\n */\nexport function defer(fn: () => void): void {\n Promise.resolve().then(fn);\n}\n\n/**\n * RAF — coalesce multiple updates into single frame\n *\n * Useful for: animation, layout work, render updates\n *\n * @param fn Function to schedule on next animation frame\n * @returns Function that schedules fn on requestAnimationFrame\n *\n * @example\n * ```ts\n * const update = raf(render);\n * update(); // schedules on next frame\n * update(); // same frame, no duplicate\n * ```\n */\nexport function raf<T extends (...args: unknown[]) => unknown>(fn: T): T {\n let frameId: number | null = null;\n let lastArgs: unknown[] | null = null;\n let lastThis: unknown = null;\n\n return function (this: unknown, ...args: unknown[]) {\n lastArgs = args;\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n lastThis = this;\n\n if (frameId === null) {\n frameId = requestAnimationFrame(() => {\n fn.apply(lastThis, lastArgs!);\n frameId = null;\n });\n }\n } as T;\n}\n\n/**\n * Idle — schedule low-priority work\n *\n * Useful for: background prep, non-urgent updates\n * Falls back to setTimeout if requestIdleCallback unavailable\n *\n * @param fn Function to call when idle\n * @param options timeout for fallback\n *\n * @example\n * ```ts\n * idle(() => prefetchData());\n * ```\n */\nexport function idle(fn: () => void, options?: { timeout?: number }): void {\n if (typeof requestIdleCallback !== 'undefined') {\n requestIdleCallback(fn, options ? { timeout: options.timeout } : undefined);\n } else {\n // Fallback: defer to microtask, then use setTimeout\n Promise.resolve().then(() => {\n setTimeout(fn, 0);\n });\n }\n}\n\n/**\n * Timeout — Promise-based delay\n *\n * Useful for: readable async code, waiting between retries\n *\n * @param ms Milliseconds to wait\n * @returns Promise that resolves after delay\n *\n * @example\n * ```ts\n * await timeout(300);\n * console.log('300ms later');\n * ```\n */\nexport function timeout(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Retry — attempt function with backoff\n *\n * Useful for: network calls, transient failures\n *\n * @param fn Async function to retry\n * @param options maxAttempts, delayMs, backoff function\n * @returns Promise with final result or error\n *\n * @example\n * ```ts\n * const data = await retry(() => fetch(url), {\n * maxAttempts: 3,\n * delayMs: 100,\n * });\n * ```\n */\nexport async function retry<T>(\n fn: () => Promise<T>,\n options?: RetryOptions\n): Promise<T> {\n const {\n maxAttempts = 3,\n delayMs = 100,\n backoff = (i: number) => delayMs * Math.pow(2, i),\n } = options || {};\n\n let lastError: Error | null = null;\n\n for (let attempt = 0; attempt < maxAttempts; attempt++) {\n try {\n return await fn();\n } catch (error) {\n lastError = error as Error;\n if (attempt < maxAttempts - 1) {\n const delay = backoff(attempt);\n await timeout(delay);\n }\n }\n }\n\n throw lastError || new Error('Retry failed');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAsCA,SAAgB,SACd,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1
+ {"version":3,"file":"timing.js","names":[],"sources":["../../src/fx/timing.ts"],"sourcesContent":["/**\n * Timing utilities — pure helpers for common async patterns\n * No framework coupling. No lifecycle awareness.\n */\n\nexport interface DebounceOptions {\n leading?: boolean;\n trailing?: boolean;\n}\n\nexport interface ThrottleOptions {\n leading?: boolean;\n trailing?: boolean;\n}\n\nexport interface RetryOptions {\n maxAttempts?: number;\n delayMs?: number;\n backoff?: (attemptIndex: number) => number;\n}\n\n/**\n * Debounce — delay execution, coalesce rapid calls\n *\n * Useful for: text input, resize, autosave\n *\n * @param fn Function to debounce\n * @param ms Delay in milliseconds\n * @param options trailing (default true), leading\n * @returns Debounced function with cancel() method\n *\n * @example\n * ```ts\n * const save = debounce((text) => api.save(text), 500);\n * input.addEventListener('input', (e) => save(e.target.value));\n * save.cancel(); // stop any pending execution\n * ```\n */\nexport function debounce<T extends (...args: unknown[]) => unknown>(\n fn: T,\n ms: number,\n options?: DebounceOptions\n): T & { cancel(): void } {\n let timeoutId: NodeJS.Timeout | null = null;\n const { leading = false, trailing = true } = options || {};\n let lastArgs: unknown[] | null = null;\n let lastThis: unknown = null;\n let lastCallTime = 0;\n\n const debounced = function (this: unknown, ...args: unknown[]) {\n const callTime = Date.now();\n lastArgs = args;\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n lastThis = this;\n\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n }\n\n if (leading && callTime - lastCallTime >= ms) {\n fn.apply(this, args);\n lastCallTime = callTime;\n }\n\n if (trailing) {\n timeoutId = setTimeout(() => {\n fn.apply(lastThis, lastArgs!);\n timeoutId = null;\n lastCallTime = Date.now();\n }, ms);\n }\n };\n\n debounced.cancel = () => {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n };\n\n return debounced as T & { cancel(): void };\n}\n\n/**\n * Throttle — rate-limit execution, keep first/last\n *\n * Useful for: scroll, mouse move, high-frequency events\n *\n * @param fn Function to throttle\n * @param ms Minimum interval between calls in milliseconds\n * @param options leading (default true), trailing (default true)\n * @returns Throttled function with cancel() method\n *\n * @example\n * ```ts\n * const handleScroll = throttle(updateUI, 100);\n * window.addEventListener('scroll', handleScroll);\n * handleScroll.cancel();\n * ```\n */\nexport function throttle<T extends (...args: unknown[]) => unknown>(\n fn: T,\n ms: number,\n options?: ThrottleOptions\n): T & { cancel(): void } {\n let lastCallTime = 0;\n let timeoutId: NodeJS.Timeout | null = null;\n const { leading = true, trailing = true } = options || {};\n let lastArgs: unknown[] | null = null;\n let lastThis: unknown = null;\n\n const throttled = function (this: unknown, ...args: unknown[]) {\n const callTime = Date.now();\n lastArgs = args;\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n lastThis = this;\n\n if (leading && callTime - lastCallTime >= ms) {\n fn.apply(this, args);\n lastCallTime = callTime;\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n } else if (!leading && lastCallTime === 0) {\n lastCallTime = callTime;\n }\n\n if (trailing && timeoutId === null) {\n timeoutId = setTimeout(\n () => {\n fn.apply(lastThis, lastArgs!);\n lastCallTime = Date.now();\n timeoutId = null;\n },\n ms - (callTime - lastCallTime)\n );\n }\n };\n\n throttled.cancel = () => {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n };\n\n return throttled as T & { cancel(): void };\n}\n\n/**\n * Once — guard against double execution\n *\n * Useful for: init logic, event safety\n *\n * @param fn Function to call at most once\n * @returns Function that executes fn only on first call\n *\n * @example\n * ```ts\n * const init = once(setup);\n * init(); // runs\n * init(); // does nothing\n * init(); // does nothing\n * ```\n */\nexport function once<T extends (...args: unknown[]) => unknown>(fn: T): T {\n let called = false;\n let result: unknown;\n\n return ((...args: unknown[]) => {\n if (!called) {\n called = true;\n result = fn(...args);\n }\n return result;\n }) as T;\n}\n\n/**\n * Defer — schedule on microtask queue\n *\n * Useful for: run-after-current-stack logic\n * More reliable than setTimeout(..., 0)\n *\n * @param fn Function to defer\n *\n * @example\n * ```ts\n * defer(() => update()); // runs after current stack, before next macrotask\n * ```\n */\nexport function defer(fn: () => void): void {\n Promise.resolve().then(fn);\n}\n\n/**\n * RAF — coalesce multiple updates into single frame\n *\n * Useful for: animation, layout work, render updates\n *\n * @param fn Function to schedule on next animation frame\n * @returns Function that schedules fn on requestAnimationFrame\n *\n * @example\n * ```ts\n * const update = raf(render);\n * update(); // schedules on next frame\n * update(); // same frame, no duplicate\n * ```\n */\nexport function raf<T extends (...args: unknown[]) => unknown>(fn: T): T {\n let frameId: number | null = null;\n let lastArgs: unknown[] | null = null;\n let lastThis: unknown = null;\n\n return function (this: unknown, ...args: unknown[]) {\n lastArgs = args;\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n lastThis = this;\n\n if (frameId === null) {\n frameId = requestAnimationFrame(() => {\n fn.apply(lastThis, lastArgs!);\n frameId = null;\n });\n }\n } as T;\n}\n\n/**\n * Idle — schedule low-priority work\n *\n * Useful for: background prep, non-urgent updates\n * Falls back to setTimeout if requestIdleCallback unavailable\n *\n * @param fn Function to call when idle\n * @param options timeout for fallback\n *\n * @example\n * ```ts\n * idle(() => prefetchData());\n * ```\n */\nexport function idle(fn: () => void, options?: { timeout?: number }): void {\n if (typeof requestIdleCallback !== 'undefined') {\n requestIdleCallback(fn, options ? { timeout: options.timeout } : undefined);\n } else {\n // Fallback: defer to microtask, then use setTimeout\n Promise.resolve().then(() => {\n setTimeout(fn, 0);\n });\n }\n}\n\n/**\n * Timeout — Promise-based delay\n *\n * Useful for: readable async code, waiting between retries\n *\n * @param ms Milliseconds to wait\n * @returns Promise that resolves after delay\n *\n * @example\n * ```ts\n * await timeout(300);\n * console.log('300ms later');\n * ```\n */\nexport function timeout(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Retry — attempt function with backoff\n *\n * Useful for: network calls, transient failures\n *\n * @param fn Async function to retry\n * @param options maxAttempts, delayMs, backoff function\n * @returns Promise with final result or error\n *\n * @example\n * ```ts\n * const data = await retry(() => fetch(url), {\n * maxAttempts: 3,\n * delayMs: 100,\n * });\n * ```\n */\nexport async function retry<T>(\n fn: () => Promise<T>,\n options?: RetryOptions\n): Promise<T> {\n const {\n maxAttempts = 3,\n delayMs = 100,\n backoff = (i: number) => delayMs * Math.pow(2, i),\n } = options || {};\n\n let lastError: Error | null = null;\n\n for (let attempt = 0; attempt < maxAttempts; attempt++) {\n try {\n return await fn();\n } catch (error) {\n lastError = error as Error;\n if (attempt < maxAttempts - 1) {\n const delay = backoff(attempt);\n await timeout(delay);\n }\n }\n }\n\n throw lastError || new Error('Retry failed');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAsCA,SAAgB,SACd,IACA,IACA,SACwB;CACxB,IAAI,YAAmC;CACvC,MAAM,EAAE,UAAU,OAAO,WAAW,SAAS,WAAW,EAAE;CAC1D,IAAI,WAA6B;CACjC,IAAI,WAAoB;CACxB,IAAI,eAAe;CAEnB,MAAM,YAAY,SAAyB,GAAG,MAAiB;EAC7D,MAAM,WAAW,KAAK,KAAK;EAC3B,WAAW;EAEX,WAAW;EAEX,IAAI,cAAc,MAChB,aAAa,UAAU;EAGzB,IAAI,WAAW,WAAW,gBAAgB,IAAI;GAC5C,GAAG,MAAM,MAAM,KAAK;GACpB,eAAe;;EAGjB,IAAI,UACF,YAAY,iBAAiB;GAC3B,GAAG,MAAM,UAAU,SAAU;GAC7B,YAAY;GACZ,eAAe,KAAK,KAAK;KACxB,GAAG;;CAIV,UAAU,eAAe;EACvB,IAAI,cAAc,MAAM;GACtB,aAAa,UAAU;GACvB,YAAY;;;CAIhB,OAAO;;;;;;;;;;;;;;;;;;;AAoBT,SAAgB,SACd,IACA,IACA,SACwB;CACxB,IAAI,eAAe;CACnB,IAAI,YAAmC;CACvC,MAAM,EAAE,UAAU,MAAM,WAAW,SAAS,WAAW,EAAE;CACzD,IAAI,WAA6B;CACjC,IAAI,WAAoB;CAExB,MAAM,YAAY,SAAyB,GAAG,MAAiB;EAC7D,MAAM,WAAW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I,SAAS,YAAY,WAAW,SAAS,GAAG,CAAC;;;;;;;;;;;;;;;;;;;AAoB1D,eAAsB,MACpB,IACA,SACY;CACZ,MAAM,EACJ,cAAc,GACd,UAAU,KACV,WAAW,MAAc,UAAU,KAAK,IAAI,GAAG,EAAE,KAC/C,WAAW,EAAE;CAEjB,IAAI,YAA0B;CAE9B,KAAK,IAAI,UAAU,GAAG,UAAU,aAAa,WAC3C,IAAI;EACF,OAAO,MAAM,IAAI;UACV,OAAO;EACd,YAAY;EACZ,IAAI,UAAU,cAAc,GAE1B,MAAM,QADQ,QAAQ,QACR,CAAM;;CAK1B,MAAM,6BAAa,IAAI,MAAM,eAAe"}
package/dist/index.d.ts CHANGED
@@ -3,21 +3,7 @@ import { Fragment } from "./common/jsx.js";
3
3
  import { State, state } from "./runtime/state.js";
4
4
  import { Context, defineContext, readContext } from "./runtime/context.js";
5
5
  import { getSignal } from "./runtime/component.js";
6
- import { For, ForProps } from "./control/for.js";
7
- import { AccessDecision, AccessDenyDecision, AccessRedirectDecision, GroupHelperOptions, PageHelperOptions, PageScopeRecord, RegisterRoutesOptions, RouteAuthMode, RouteAuthOptions, RouteAuthResolver, RouteAuthState, RouteComponent, RouteContext, RouteDefinition, RouteManifest, RouteMatch, RouteMode, RouteOptions, RoutePolicy, RouteRecord, RouteRenderResult, RouteRequestOptions, RouteRequestResult, RouteSnapshot } from "./common/router.js";
8
- import { HistoryScrollBehavior, NavigateOptions, NavigationScrollBehavior, ScrollRestorationOptions, navigate } from "./router/navigate.js";
9
- import { HydrateSPAConfig, IslandConfig, IslandsConfig, SPAConfig, cleanupApp, createIsland, createIslands, createSPA, hasApp, hydrateSPA } from "./boot/index.js";
10
- import { Show, ShowProps } from "./control/show.js";
11
- import { Case, CaseProps, Match, MatchProps } from "./control/case.js";
12
- import { jsx, jsxs } from "./jsx-runtime.js";
13
- import { Slot, SlotProps } from "./foundations/structures/slot.js";
14
- import { DefaultPortal, Portal, PortalProps, definePortal } from "./foundations/structures/portal.js";
15
6
  import { Derived, derive } from "./runtime/derive.js";
16
7
  import { Selector, selector } from "./runtime/selector.js";
17
- import { ResourceResult, resource } from "./runtime/operations.js";
18
- import { Mutation, Query, QueryConsistency, createMutation, createQuery, invalidate } from "./data/index.js";
19
- import { Outlet, currentRoute, fallback, group, index, lazy, page, registerRoutes, resolveRouteRequest, route } from "./router/route.js";
20
- import { allow, deny, forbidden, notFound, redirect, requireAuth, requirePermission, requireRole, unauthorized } from "./router/policy.js";
21
- import { Link, LinkProps } from "./components/link.js";
22
- import { ErrorBoundary, ErrorBoundaryFallbackRender, ErrorBoundaryProps } from "./components/error-boundary.js";
23
- export { type AccessDecision, type AccessDenyDecision, type AccessRedirectDecision, Case, type CaseProps, type Context, DefaultPortal, type Derived, ErrorBoundary, type ErrorBoundaryFallbackRender, type ErrorBoundaryProps, For, type ForProps, Fragment, type GroupHelperOptions, type HistoryScrollBehavior, type HydrateSPAConfig, type IslandConfig, type IslandsConfig, Link, type LinkProps, Match, type MatchProps, type Mutation, type NavigateOptions, type NavigationScrollBehavior, Outlet, type PageHelperOptions, type PageScopeRecord, Portal, type PortalProps, type Props, type Query, type QueryConsistency, type RegisterRoutesOptions, type ResourceResult, type RouteAuthMode, type RouteAuthOptions, type RouteAuthResolver, type RouteAuthState, type RouteComponent, type RouteContext, type RouteDefinition, type RouteManifest, type RouteMatch, type RouteMode, type RouteOptions, type RoutePolicy, type RouteRecord, type RouteRenderResult, type RouteRequestOptions, type RouteRequestResult, type RouteSnapshot, type SPAConfig, type ScrollRestorationOptions, type Selector, Show, type ShowProps, Slot, type SlotProps, type State, allow, cleanupApp, createIsland, createIslands, createMutation, createQuery, createSPA, currentRoute, defineContext, definePortal, deny, derive, fallback, forbidden, getSignal, group, hasApp, hydrateSPA, index, invalidate, jsx, jsxs, lazy, navigate, notFound, page, readContext, redirect, registerRoutes, requireAuth, requirePermission, requireRole, resolveRouteRequest, resource, route, selector, state, unauthorized };
8
+ import { jsx, jsxs } from "./jsx-runtime.js";
9
+ export { type Context, type Derived, Fragment, type Props, type Selector, type State, defineContext, derive, getSignal, jsx, jsxs, readContext, selector, state };
package/dist/index.js CHANGED
@@ -2,27 +2,11 @@ import { Fragment } from "./common/jsx.js";
2
2
  import { defineContext, readContext } from "./runtime/context.js";
3
3
  import { getSignal } from "./runtime/component.js";
4
4
  import { jsx, jsxs } from "./jsx-runtime.js";
5
- import { ErrorBoundary } from "./components/error-boundary.js";
6
5
  import { installRendererBridge } from "./renderer/index.js";
7
6
  import { state } from "./runtime/state.js";
8
7
  import { derive } from "./runtime/derive.js";
9
8
  import { selector } from "./runtime/selector.js";
10
- import { resource } from "./runtime/operations.js";
11
- import { createMutation, createQuery, invalidate } from "./data/index.js";
12
- import { allow, deny, forbidden, notFound, redirect, requireAuth, requirePermission, requireRole, unauthorized } from "./router/policy.js";
13
- import { Outlet, currentRoute, fallback, group, index, lazy, page, registerRoutes, resolveRouteRequest, route } from "./router/route.js";
14
- import { DefaultPortal, Portal, definePortal } from "./foundations/structures/portal.js";
15
- import { navigate } from "./router/navigate.js";
16
- import { cleanupApp, createIsland, createIslands, createSPA, hasApp, hydrateSPA } from "./boot/index.js";
17
9
  import "./jsx-runtime2.js";
18
- import { Link } from "./components/link.js";
19
- import "./router/index.js";
20
- import { For } from "./control/for.js";
21
- import { Show } from "./control/show.js";
22
- import { Case, Match } from "./control/case.js";
23
- import "./control/index.js";
24
- import { Slot } from "./foundations/structures/slot.js";
25
- import "./foundations/structures.js";
26
10
  //#region src/index.ts
27
11
  /**
28
12
  * Askr: Actor-backed deterministic UI framework
@@ -31,6 +15,6 @@ import "./foundations/structures.js";
31
15
  */
32
16
  installRendererBridge();
33
17
  //#endregion
34
- export { Case, DefaultPortal, ErrorBoundary, For, Fragment, Link, Match, Outlet, Portal, Show, Slot, allow, cleanupApp, createIsland, createIslands, createMutation, createQuery, createSPA, currentRoute, defineContext, definePortal, deny, derive, fallback, forbidden, getSignal, group, hasApp, hydrateSPA, index, invalidate, jsx, jsxs, lazy, navigate, notFound, page, readContext, redirect, registerRoutes, requireAuth, requirePermission, requireRole, resolveRouteRequest, resource, route, selector, state, unauthorized };
18
+ export { Fragment, defineContext, derive, getSignal, jsx, jsxs, readContext, selector, state };
35
19
 
36
20
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * Askr: Actor-backed deterministic UI framework\n *\n * Public API surface — only users should import from here\n */\n\nimport { installRendererBridge } from './renderer';\n\ninstallRendererBridge();\n\n// Runtime primitives\nexport { state } from './runtime/state';\nexport type { State } from './runtime/state';\nexport { derive } from './runtime/derive';\nexport type { Derived } from './runtime/derive';\nexport { getSignal } from './runtime/component';\nexport { selector } from './runtime/selector';\nexport type { Selector } from './runtime/selector';\n\n// Context\nexport { defineContext, readContext } from './runtime/context';\nexport type { Context } from './runtime/context';\n\n// Resources\nexport { resource } from './runtime/operations';\nexport type { ResourceResult } from './runtime/operations';\n\n// Data\nexport { createQuery, createMutation, invalidate } from './data';\nexport type { Query, Mutation, QueryConsistency } from './data';\n\n// App bootstrap\nexport {\n createIsland,\n createIslands,\n createSPA,\n hydrateSPA,\n cleanupApp,\n hasApp,\n} from './boot';\nexport type {\n IslandConfig,\n IslandsConfig,\n SPAConfig,\n HydrateSPAConfig,\n} from './boot';\n\n// Routing\nexport {\n registerRoutes,\n route,\n page,\n index,\n Outlet,\n currentRoute,\n group,\n fallback,\n lazy,\n allow,\n redirect,\n deny,\n unauthorized,\n forbidden,\n notFound,\n requireAuth,\n requireRole,\n requirePermission,\n resolveRouteRequest,\n type RouteSnapshot,\n type RouteMatch,\n type RouteComponent,\n type RouteMode,\n type RouteAuthMode,\n type RouteContext,\n type RoutePolicy,\n type RouteOptions,\n type RouteRecord,\n type RouteManifest,\n type PageScopeRecord,\n type AccessDecision,\n type AccessDenyDecision,\n type AccessRedirectDecision,\n type GroupHelperOptions,\n type PageHelperOptions,\n type RegisterRoutesOptions,\n type RouteDefinition,\n type RouteAuthOptions,\n type RouteAuthResolver,\n type RouteAuthState,\n type RouteRenderResult,\n type RouteRequestOptions,\n type RouteRequestResult,\n} from './router';\nexport { navigate } from './router/navigate';\nexport type {\n NavigateOptions,\n NavigationScrollBehavior,\n HistoryScrollBehavior,\n ScrollRestorationOptions,\n} from './router/navigate';\n\n// Components\nexport { Link } from './components/link';\nexport type { LinkProps } from './components/link';\nexport { ErrorBoundary } from './components/error-boundary';\nexport type {\n ErrorBoundaryProps,\n ErrorBoundaryFallbackRender,\n} from './components/error-boundary';\nexport { Case, For, Match, Show } from './control';\nexport type { CaseProps, ForProps, MatchProps, ShowProps } from './control';\nexport {\n Slot,\n definePortal,\n DefaultPortal,\n Portal,\n} from './foundations/structures';\nexport type { SlotProps, PortalProps } from './foundations/structures';\n\n// Re-export JSX runtime for tsconfig jsxImportSource\nexport { jsx, jsxs, Fragment } from './jsx-runtime';\n\n// Public types\nexport type { Props } from './common/props';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,uBAAuB"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * Askr: Actor-backed deterministic UI framework\n *\n * Public API surface — only users should import from here\n */\n\nimport { installRendererBridge } from './renderer';\n\ninstallRendererBridge();\n\n// Runtime primitives\nexport { state } from './runtime/state';\nexport type { State } from './runtime/state';\nexport { derive } from './runtime/derive';\nexport type { Derived } from './runtime/derive';\nexport { getSignal } from './runtime/component';\nexport { selector } from './runtime/selector';\nexport type { Selector } from './runtime/selector';\n\n// Context\nexport { defineContext, readContext } from './runtime/context';\nexport type { Context } from './runtime/context';\n\n// Re-export JSX runtime for tsconfig jsxImportSource\nexport { jsx, jsxs, Fragment } from './jsx-runtime';\n\n// Public types\nexport type { Props } from './common/props';\n"],"mappings":";;;;;;;;;;;;;;;AAQA,uBAAuB"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":[],"sources":["../../src/jsx/utils.ts"],"sourcesContent":["import { ELEMENT_TYPE, JSXElement } from './types';\n\nexport function isElement(value: unknown): value is JSXElement {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as JSXElement).$$typeof === ELEMENT_TYPE\n );\n}\n\nexport function cloneElement(\n element: JSXElement,\n props: Record<string, unknown>\n): JSXElement {\n return {\n ...element,\n props: { ...element.props, ...props },\n };\n}\n"],"mappings":";;;AAEA,SAAgB,UAAU,OAAqC;AAC7D,QACE,OAAO,UAAU,YACjB,UAAU,QACT,MAAqB,aAAa;;AAIvC,SAAgB,aACd,SACA,OACY;AACZ,QAAO;EACL,GAAG;EACH,OAAO;GAAE,GAAG,QAAQ;GAAO,GAAG;GAAO;EACtC"}
1
+ {"version":3,"file":"utils.js","names":[],"sources":["../../src/jsx/utils.ts"],"sourcesContent":["import { ELEMENT_TYPE, JSXElement } from './types';\n\nexport function isElement(value: unknown): value is JSXElement {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as JSXElement).$$typeof === ELEMENT_TYPE\n );\n}\n\nexport function cloneElement(\n element: JSXElement,\n props: Record<string, unknown>\n): JSXElement {\n return {\n ...element,\n props: { ...element.props, ...props },\n };\n}\n"],"mappings":";;;AAEA,SAAgB,UAAU,OAAqC;CAC7D,OACE,OAAO,UAAU,YACjB,UAAU,QACT,MAAqB,aAAa;;AAIvC,SAAgB,aACd,SACA,OACY;CACZ,OAAO;EACL,GAAG;EACH,OAAO;GAAE,GAAG,QAAQ;GAAO,GAAG;GAAO;EACtC"}
@@ -4,5 +4,5 @@ import { EagerControlPrimitive } from "./common/control.js";
4
4
  declare function jsxDEV(type: EagerControlPrimitive, props: Record<string, unknown> | null, key?: string | number, isStaticChildren?: boolean): unknown;
5
5
  declare function jsxDEV(type: unknown, props: Record<string, unknown> | null, key?: string | number, isStaticChildren?: boolean): JSXElement;
6
6
  //#endregion
7
- export { Fragment, jsxDEV };
7
+ export { Fragment, type JSXElement, jsxDEV };
8
8
  //# sourceMappingURL=jsx-dev-runtime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"jsx-dev-runtime.js","names":[],"sources":["../src/jsx/jsx-dev-runtime.ts"],"sourcesContent":["/**\n * JSX dev runtime factory\n * Same element shape as production runtime, with room for dev warnings.\n */\nimport type { Props } from '../common/props';\nimport {\n isEagerControlPrimitive,\n type EagerControlPrimitive,\n} from '../common/control';\nimport {\n ELEMENT_TYPE,\n Fragment,\n STATIC_CHILDREN,\n type JSXElement,\n} from './types';\nimport { markReadableUsage } from '../runtime/readable';\n\nfunction annotatePropsUsage(props: Record<string, unknown> | null): Props {\n const normalizedProps = (props ?? {}) as Props;\n\n for (const value of Object.values(normalizedProps)) {\n markReadableUsage(value);\n }\n\n return normalizedProps;\n}\n\nfunction markStaticChildren(props: Props): Props {\n if (Array.isArray(props.children)) {\n Object.defineProperty(props.children, STATIC_CHILDREN, {\n value: true,\n configurable: true,\n });\n }\n\n return props;\n}\n\nexport function jsxDEV(\n type: EagerControlPrimitive,\n props: Record<string, unknown> | null,\n key?: string | number,\n isStaticChildren?: boolean\n): unknown;\nexport function jsxDEV(\n type: unknown,\n props: Record<string, unknown> | null,\n key?: string | number,\n isStaticChildren?: boolean\n): JSXElement;\nexport function jsxDEV(\n type: unknown,\n props: Record<string, unknown> | null,\n key?: string | number,\n isStaticChildren = false\n): JSXElement | unknown {\n const normalizedProps = annotatePropsUsage(props);\n const preparedProps = isStaticChildren\n ? markStaticChildren(normalizedProps)\n : normalizedProps;\n\n if (isEagerControlPrimitive(type)) {\n return type(preparedProps);\n }\n\n return {\n $$typeof: ELEMENT_TYPE,\n type: type as string | ((props: Props) => unknown) | symbol,\n props: preparedProps,\n key: key ?? null,\n };\n}\n\n// Re-export Fragment for JSX\nexport { Fragment };\n"],"mappings":";;;;;AAiBA,SAAS,mBAAmB,OAA8C;CACxE,MAAM,kBAAmB,SAAS,EAAE;AAEpC,MAAK,MAAM,SAAS,OAAO,OAAO,gBAAgB,CAChD,mBAAkB,MAAM;AAG1B,QAAO;;AAGT,SAAS,mBAAmB,OAAqB;AAC/C,KAAI,MAAM,QAAQ,MAAM,SAAS,CAC/B,QAAO,eAAe,MAAM,UAAU,iBAAiB;EACrD,OAAO;EACP,cAAc;EACf,CAAC;AAGJ,QAAO;;AAeT,SAAgB,OACd,MACA,OACA,KACA,mBAAmB,OACG;CACtB,MAAM,kBAAkB,mBAAmB,MAAM;CACjD,MAAM,gBAAgB,mBAClB,mBAAmB,gBAAgB,GACnC;AAEJ,KAAI,wBAAwB,KAAK,CAC/B,QAAO,KAAK,cAAc;AAG5B,QAAO;EACL,UAAU;EACJ;EACN,OAAO;EACP,KAAK,OAAO;EACb"}
1
+ {"version":3,"file":"jsx-dev-runtime.js","names":[],"sources":["../src/jsx/jsx-dev-runtime.ts"],"sourcesContent":["/**\n * JSX dev runtime factory\n * Same element shape as production runtime, with room for dev warnings.\n */\nimport type { Props } from '../common/props';\nimport {\n isEagerControlPrimitive,\n type EagerControlPrimitive,\n} from '../common/control';\nimport {\n ELEMENT_TYPE,\n Fragment,\n STATIC_CHILDREN,\n type JSXElement,\n} from './types';\nimport { markReadableUsage } from '../runtime/readable';\n\nfunction annotatePropsUsage(props: Record<string, unknown> | null): Props {\n const normalizedProps = (props ?? {}) as Props;\n\n for (const value of Object.values(normalizedProps)) {\n markReadableUsage(value);\n }\n\n return normalizedProps;\n}\n\nfunction markStaticChildren(props: Props): Props {\n if (Array.isArray(props.children)) {\n Object.defineProperty(props.children, STATIC_CHILDREN, {\n value: true,\n configurable: true,\n });\n }\n\n return props;\n}\n\nexport function jsxDEV(\n type: EagerControlPrimitive,\n props: Record<string, unknown> | null,\n key?: string | number,\n isStaticChildren?: boolean\n): unknown;\nexport function jsxDEV(\n type: unknown,\n props: Record<string, unknown> | null,\n key?: string | number,\n isStaticChildren?: boolean\n): JSXElement;\nexport function jsxDEV(\n type: unknown,\n props: Record<string, unknown> | null,\n key?: string | number,\n isStaticChildren = false\n): JSXElement | unknown {\n const normalizedProps = annotatePropsUsage(props);\n const preparedProps = isStaticChildren\n ? markStaticChildren(normalizedProps)\n : normalizedProps;\n\n if (isEagerControlPrimitive(type)) {\n return type(preparedProps);\n }\n\n return {\n $$typeof: ELEMENT_TYPE,\n type: type as string | ((props: Props) => unknown) | symbol,\n props: preparedProps,\n key: key ?? null,\n };\n}\n\n// Re-export Fragment for JSX\nexport { Fragment };\nexport type { JSXElement };\n"],"mappings":";;;;;AAiBA,SAAS,mBAAmB,OAA8C;CACxE,MAAM,kBAAmB,SAAS,EAAE;CAEpC,KAAK,MAAM,SAAS,OAAO,OAAO,gBAAgB,EAChD,kBAAkB,MAAM;CAG1B,OAAO;;AAGT,SAAS,mBAAmB,OAAqB;CAC/C,IAAI,MAAM,QAAQ,MAAM,SAAS,EAC/B,OAAO,eAAe,MAAM,UAAU,iBAAiB;EACrD,OAAO;EACP,cAAc;EACf,CAAC;CAGJ,OAAO;;AAeT,SAAgB,OACd,MACA,OACA,KACA,mBAAmB,OACG;CACtB,MAAM,kBAAkB,mBAAmB,MAAM;CACjD,MAAM,gBAAgB,mBAClB,mBAAmB,gBAAgB,GACnC;CAEJ,IAAI,wBAAwB,KAAK,EAC/B,OAAO,KAAK,cAAc;CAG5B,OAAO;EACL,UAAU;EACJ;EACN,OAAO;EACP,KAAK,OAAO;EACb"}
@@ -8,5 +8,5 @@ declare function jsx(type: unknown, props: Record<string, unknown> | null, key?:
8
8
  declare function jsxs(type: EagerControlPrimitive, props: Record<string, unknown> | null, key?: string | number): unknown;
9
9
  declare function jsxs(type: unknown, props: Record<string, unknown> | null, key?: string | number): JSXElement;
10
10
  //#endregion
11
- export { Fragment, jsx, jsxDEV, jsxs };
11
+ export { Fragment, type JSXElement, jsx, jsxDEV, jsxs };
12
12
  //# sourceMappingURL=jsx-runtime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"jsx-runtime.js","names":[],"sources":["../src/jsx/jsx-runtime.ts"],"sourcesContent":["/**\n * JSX runtime factory\n * Same element shape as production runtime.\n */\n\nimport type { Props } from '../common/props';\nimport {\n isEagerControlPrimitive,\n type EagerControlPrimitive,\n} from '../common/control';\nimport {\n ELEMENT_TYPE,\n Fragment,\n STATIC_CHILDREN,\n type JSXElement,\n} from './types';\nimport { markReadableUsage } from '../runtime/readable';\n\nfunction annotatePropsUsage(props: Record<string, unknown> | null): Props {\n const normalizedProps = (props ?? {}) as Props;\n\n for (const value of Object.values(normalizedProps)) {\n markReadableUsage(value);\n }\n\n return normalizedProps;\n}\n\nfunction markStaticChildren(props: Props): Props {\n if (Array.isArray(props.children)) {\n Object.defineProperty(props.children, STATIC_CHILDREN, {\n value: true,\n configurable: true,\n });\n }\n\n return props;\n}\n\nexport function jsxDEV(\n type: EagerControlPrimitive,\n props: Record<string, unknown> | null,\n key?: string | number,\n isStaticChildren?: boolean\n): unknown;\nexport function jsxDEV(\n type: unknown,\n props: Record<string, unknown> | null,\n key?: string | number,\n isStaticChildren?: boolean\n): JSXElement;\nexport function jsxDEV(\n type: unknown,\n props: Record<string, unknown> | null,\n key?: string | number,\n isStaticChildren = false\n): JSXElement | unknown {\n const normalizedProps = annotatePropsUsage(props);\n const preparedProps = isStaticChildren\n ? markStaticChildren(normalizedProps)\n : normalizedProps;\n\n if (isEagerControlPrimitive(type)) {\n return type(preparedProps);\n }\n\n return {\n $$typeof: ELEMENT_TYPE,\n type: type as string | ((props: Props) => unknown) | symbol,\n props: preparedProps,\n key: key ?? null,\n };\n}\n\n// Production-style helpers: alias to the DEV factory for now\nexport function jsx(\n type: EagerControlPrimitive,\n props: Record<string, unknown> | null,\n key?: string | number\n): unknown;\nexport function jsx(\n type: unknown,\n props: Record<string, unknown> | null,\n key?: string | number\n): JSXElement;\nexport function jsx(\n type: unknown,\n props: Record<string, unknown> | null,\n key?: string | number\n) {\n return jsxDEV(type, props, key);\n}\n\nexport function jsxs(\n type: EagerControlPrimitive,\n props: Record<string, unknown> | null,\n key?: string | number\n): unknown;\nexport function jsxs(\n type: unknown,\n props: Record<string, unknown> | null,\n key?: string | number\n): JSXElement;\nexport function jsxs(\n type: unknown,\n props: Record<string, unknown> | null,\n key?: string | number\n) {\n const normalizedProps = markStaticChildren(annotatePropsUsage(props));\n\n if (isEagerControlPrimitive(type)) {\n return type(normalizedProps);\n }\n\n return {\n $$typeof: ELEMENT_TYPE,\n type: type as string | ((props: Props) => unknown) | symbol,\n props: normalizedProps,\n key: key ?? null,\n } as JSXElement;\n}\n\n// Re-export Fragment for JSX.\nexport { Fragment };\n"],"mappings":";;;;;AAkBA,SAAS,mBAAmB,OAA8C;CACxE,MAAM,kBAAmB,SAAS,EAAE;AAEpC,MAAK,MAAM,SAAS,OAAO,OAAO,gBAAgB,CAChD,mBAAkB,MAAM;AAG1B,QAAO;;AAGT,SAAS,mBAAmB,OAAqB;AAC/C,KAAI,MAAM,QAAQ,MAAM,SAAS,CAC/B,QAAO,eAAe,MAAM,UAAU,iBAAiB;EACrD,OAAO;EACP,cAAc;EACf,CAAC;AAGJ,QAAO;;AAeT,SAAgB,OACd,MACA,OACA,KACA,mBAAmB,OACG;CACtB,MAAM,kBAAkB,mBAAmB,MAAM;CACjD,MAAM,gBAAgB,mBAClB,mBAAmB,gBAAgB,GACnC;AAEJ,KAAI,wBAAwB,KAAK,CAC/B,QAAO,KAAK,cAAc;AAG5B,QAAO;EACL,UAAU;EACJ;EACN,OAAO;EACP,KAAK,OAAO;EACb;;AAcH,SAAgB,IACd,MACA,OACA,KACA;AACA,QAAO,OAAO,MAAM,OAAO,IAAI;;AAajC,SAAgB,KACd,MACA,OACA,KACA;CACA,MAAM,kBAAkB,mBAAmB,mBAAmB,MAAM,CAAC;AAErE,KAAI,wBAAwB,KAAK,CAC/B,QAAO,KAAK,gBAAgB;AAG9B,QAAO;EACL,UAAU;EACJ;EACN,OAAO;EACP,KAAK,OAAO;EACb"}
1
+ {"version":3,"file":"jsx-runtime.js","names":[],"sources":["../src/jsx/jsx-runtime.ts"],"sourcesContent":["/**\n * JSX runtime factory\n * Same element shape as production runtime.\n */\n\nimport type { Props } from '../common/props';\nimport {\n isEagerControlPrimitive,\n type EagerControlPrimitive,\n} from '../common/control';\nimport {\n ELEMENT_TYPE,\n Fragment,\n STATIC_CHILDREN,\n type JSXElement,\n} from './types';\nimport { markReadableUsage } from '../runtime/readable';\n\nfunction annotatePropsUsage(props: Record<string, unknown> | null): Props {\n const normalizedProps = (props ?? {}) as Props;\n\n for (const value of Object.values(normalizedProps)) {\n markReadableUsage(value);\n }\n\n return normalizedProps;\n}\n\nfunction markStaticChildren(props: Props): Props {\n if (Array.isArray(props.children)) {\n Object.defineProperty(props.children, STATIC_CHILDREN, {\n value: true,\n configurable: true,\n });\n }\n\n return props;\n}\n\nexport function jsxDEV(\n type: EagerControlPrimitive,\n props: Record<string, unknown> | null,\n key?: string | number,\n isStaticChildren?: boolean\n): unknown;\nexport function jsxDEV(\n type: unknown,\n props: Record<string, unknown> | null,\n key?: string | number,\n isStaticChildren?: boolean\n): JSXElement;\nexport function jsxDEV(\n type: unknown,\n props: Record<string, unknown> | null,\n key?: string | number,\n isStaticChildren = false\n): JSXElement | unknown {\n const normalizedProps = annotatePropsUsage(props);\n const preparedProps = isStaticChildren\n ? markStaticChildren(normalizedProps)\n : normalizedProps;\n\n if (isEagerControlPrimitive(type)) {\n return type(preparedProps);\n }\n\n return {\n $$typeof: ELEMENT_TYPE,\n type: type as string | ((props: Props) => unknown) | symbol,\n props: preparedProps,\n key: key ?? null,\n };\n}\n\n// Production-style helpers: alias to the DEV factory for now\nexport function jsx(\n type: EagerControlPrimitive,\n props: Record<string, unknown> | null,\n key?: string | number\n): unknown;\nexport function jsx(\n type: unknown,\n props: Record<string, unknown> | null,\n key?: string | number\n): JSXElement;\nexport function jsx(\n type: unknown,\n props: Record<string, unknown> | null,\n key?: string | number\n) {\n return jsxDEV(type, props, key);\n}\n\nexport function jsxs(\n type: EagerControlPrimitive,\n props: Record<string, unknown> | null,\n key?: string | number\n): unknown;\nexport function jsxs(\n type: unknown,\n props: Record<string, unknown> | null,\n key?: string | number\n): JSXElement;\nexport function jsxs(\n type: unknown,\n props: Record<string, unknown> | null,\n key?: string | number\n) {\n const normalizedProps = markStaticChildren(annotatePropsUsage(props));\n\n if (isEagerControlPrimitive(type)) {\n return type(normalizedProps);\n }\n\n return {\n $$typeof: ELEMENT_TYPE,\n type: type as string | ((props: Props) => unknown) | symbol,\n props: normalizedProps,\n key: key ?? null,\n } as JSXElement;\n}\n\n// Re-export Fragment for JSX.\nexport { Fragment };\nexport type { JSXElement };\n"],"mappings":";;;;;AAkBA,SAAS,mBAAmB,OAA8C;CACxE,MAAM,kBAAmB,SAAS,EAAE;CAEpC,KAAK,MAAM,SAAS,OAAO,OAAO,gBAAgB,EAChD,kBAAkB,MAAM;CAG1B,OAAO;;AAGT,SAAS,mBAAmB,OAAqB;CAC/C,IAAI,MAAM,QAAQ,MAAM,SAAS,EAC/B,OAAO,eAAe,MAAM,UAAU,iBAAiB;EACrD,OAAO;EACP,cAAc;EACf,CAAC;CAGJ,OAAO;;AAeT,SAAgB,OACd,MACA,OACA,KACA,mBAAmB,OACG;CACtB,MAAM,kBAAkB,mBAAmB,MAAM;CACjD,MAAM,gBAAgB,mBAClB,mBAAmB,gBAAgB,GACnC;CAEJ,IAAI,wBAAwB,KAAK,EAC/B,OAAO,KAAK,cAAc;CAG5B,OAAO;EACL,UAAU;EACJ;EACN,OAAO;EACP,KAAK,OAAO;EACb;;AAcH,SAAgB,IACd,MACA,OACA,KACA;CACA,OAAO,OAAO,MAAM,OAAO,IAAI;;AAajC,SAAgB,KACd,MACA,OACA,KACA;CACA,MAAM,kBAAkB,mBAAmB,mBAAmB,MAAM,CAAC;CAErE,IAAI,wBAAwB,KAAK,EAC/B,OAAO,KAAK,gBAAgB;CAG9B,OAAO;EACL,UAAU;EACJ;EACN,OAAO;EACP,KAAK,OAAO;EACb"}
@@ -1 +1 @@
1
- {"version":3,"file":"children.js","names":[],"sources":["../../src/renderer/children.ts"],"sourcesContent":["import { setDevValue, incDevCounter } from '../runtime/dev-namespace';\nimport { getRuntimeEnv } from './env';\nimport { keyedElements } from './keyed';\nimport { teardownNodeSubtree } from './cleanup';\nimport { createDOMNode, updateElementFromVnode } from './dom';\nimport { _isDOMElement, type DOMElement, type VNode } from './types';\nimport {\n hasNonTrivialProps,\n logFastPathDebug,\n now,\n recordDOMReplace,\n recordFastPathStats,\n tagNamesEqualIgnoreCase,\n} from './utils';\n\nfunction upperCommonTagName(tag: string): string | null {\n switch (tag) {\n case 'div':\n return 'DIV';\n case 'span':\n return 'SPAN';\n case 'p':\n return 'P';\n case 'a':\n return 'A';\n case 'button':\n return 'BUTTON';\n case 'input':\n return 'INPUT';\n case 'ul':\n return 'UL';\n case 'ol':\n return 'OL';\n case 'li':\n return 'LI';\n default:\n return null;\n }\n}\n\nfunction tagsEqualIgnoreCase(\n elementTagName: string,\n vnodeType: string\n): boolean {\n if (elementTagName === vnodeType) return true;\n\n const upperCommon = upperCommonTagName(vnodeType);\n if (upperCommon !== null && elementTagName === upperCommon) return true;\n\n return tagNamesEqualIgnoreCase(elementTagName, vnodeType);\n}\n\nexport function performBulkPositionalKeyedTextUpdate(\n parent: Element,\n keyedVnodes: Array<{ key: string | number; vnode: VNode }>\n) {\n const total = keyedVnodes.length;\n let reused = 0;\n let updatedKeys = 0;\n const start = now();\n const env = getRuntimeEnv();\n const debugFastPath =\n env.ASKR_FASTPATH_DEBUG === '1' || env.ASKR_FASTPATH_DEBUG === 'true';\n\n for (let index = 0; index < total; index += 1) {\n const { key, vnode } = keyedVnodes[index];\n const child = parent.children[index] as Element | undefined;\n\n if (\n child &&\n _isDOMElement(vnode) &&\n typeof (vnode as DOMElement).type === 'string'\n ) {\n const vnodeType = (vnode as DOMElement).type as string;\n\n if (tagsEqualIgnoreCase(child.tagName, vnodeType)) {\n const children =\n (vnode as DOMElement).children ||\n (vnode as DOMElement).props?.children;\n\n if (debugFastPath) {\n logFastPathDebug('positional idx', index, {\n chTag: child.tagName,\n vnodeType,\n chChildNodes: child.childNodes.length,\n childrenType: Array.isArray(children) ? 'array' : typeof children,\n });\n }\n\n updateTextContent(child, children, vnode as DOMElement);\n setDataKey(child, key, () => (updatedKeys += 1));\n reused += 1;\n continue;\n }\n\n if (debugFastPath) {\n logFastPathDebug('positional tag mismatch', index, {\n chTag: child.tagName,\n vnodeType,\n });\n }\n } else if (debugFastPath) {\n logFastPathDebug('positional missing or invalid', index, { ch: !!child });\n }\n\n replaceNodeAtPosition(parent, index, vnode);\n }\n\n const elapsed = now() - start;\n updateKeyedElementsMap(parent, keyedVnodes);\n\n const stats = { n: total, reused, updatedKeys, t: elapsed } as const;\n recordFastPathStats(stats, 'bulkKeyedPositionalHits');\n\n return stats;\n}\n\nfunction updateTextContent(\n el: Element,\n children: unknown,\n vnode: DOMElement\n): void {\n if (typeof children === 'string' || typeof children === 'number') {\n setTextNodeData(el, String(children));\n if (vnode.props && hasNonTrivialProps(vnode.props)) {\n updateElementFromVnode(el, vnode, false);\n }\n return;\n }\n\n if (\n Array.isArray(children) &&\n children.length === 1 &&\n (typeof children[0] === 'string' || typeof children[0] === 'number')\n ) {\n setTextNodeData(el, String(children[0]));\n if (vnode.props && hasNonTrivialProps(vnode.props)) {\n updateElementFromVnode(el, vnode, false);\n }\n return;\n }\n\n if (!tryUpdateTwoChildTextPattern(el, vnode)) {\n updateElementFromVnode(el, vnode);\n }\n}\n\nfunction tryUpdateTwoChildTextPattern(\n parentEl: Element,\n vnode: DOMElement\n): boolean {\n const vnodeChildren = vnode.props?.children ?? vnode.children;\n if (!Array.isArray(vnodeChildren) || vnodeChildren.length !== 2) return false;\n\n const firstChild = vnodeChildren[0];\n const secondChild = vnodeChildren[1];\n if (!_isDOMElement(firstChild) || !_isDOMElement(secondChild)) return false;\n if (\n typeof firstChild.type !== 'string' ||\n typeof secondChild.type !== 'string'\n ) {\n return false;\n }\n\n const firstElement = parentEl.children[0] as Element | undefined;\n const secondElement = parentEl.children[1] as Element | undefined;\n if (!firstElement || !secondElement) return false;\n if (parentEl.children.length !== 2 || parentEl.childNodes.length !== 2) {\n return false;\n }\n\n if (!tagsEqualIgnoreCase(firstElement.tagName, firstChild.type)) return false;\n if (!tagsEqualIgnoreCase(secondElement.tagName, secondChild.type))\n return false;\n\n const firstText = (firstChild.children ||\n firstChild.props?.children) as unknown;\n const secondText = (secondChild.children ||\n secondChild.props?.children) as unknown;\n\n if (typeof firstText === 'string' || typeof firstText === 'number') {\n setTextNodeData(firstElement, String(firstText));\n } else if (\n Array.isArray(firstText) &&\n firstText.length === 1 &&\n (typeof firstText[0] === 'string' || typeof firstText[0] === 'number')\n ) {\n setTextNodeData(firstElement, String(firstText[0]));\n } else {\n return false;\n }\n\n if (typeof secondText === 'string' || typeof secondText === 'number') {\n setTextNodeData(secondElement, String(secondText));\n } else if (\n Array.isArray(secondText) &&\n secondText.length === 1 &&\n (typeof secondText[0] === 'string' || typeof secondText[0] === 'number')\n ) {\n setTextNodeData(secondElement, String(secondText[0]));\n } else {\n return false;\n }\n\n return true;\n}\n\nfunction setTextNodeData(el: Element, text: string): void {\n if (el.childNodes.length === 1 && el.firstChild?.nodeType === 3) {\n const textNode = el.firstChild as Text;\n if (textNode.data !== text) textNode.data = text;\n } else {\n el.textContent = text;\n }\n}\n\nfunction setDataKey(\n el: Element,\n key: string | number,\n onSet: () => void\n): void {\n try {\n const next = String(key);\n if (el.getAttribute('data-key') === next) return;\n el.setAttribute('data-key', next);\n onSet();\n } catch {\n // Ignore errors setting data-key\n }\n}\n\nfunction replaceNodeAtPosition(\n parent: Element,\n index: number,\n vnode: VNode\n): void {\n const dom = createDOMNode(vnode);\n if (dom) {\n const existing = parent.children[index];\n if (existing) {\n teardownNodeSubtree(existing);\n parent.replaceChild(dom, existing);\n } else {\n parent.appendChild(dom);\n }\n }\n}\n\nfunction updateKeyedElementsMap(\n parent: Element,\n keyedVnodes: Array<{ key: string | number; vnode: VNode }>\n): void {\n try {\n const existing = keyedElements.get(parent);\n const newKeyMap = existing\n ? (existing.clear(), existing)\n : new Map<string | number, Element>();\n\n for (let index = 0; index < keyedVnodes.length; index += 1) {\n const key = keyedVnodes[index].key;\n const child = parent.children[index] as Element | undefined;\n if (child) newKeyMap.set(key, child);\n }\n\n keyedElements.set(parent, newKeyMap);\n } catch {\n // Ignore errors updating key map\n }\n}\n\nexport function performBulkTextReplace(parent: Element, newChildren: VNode[]) {\n const start = now();\n const existing = Array.from(parent.childNodes);\n const finalNodes: Node[] = [];\n let reused = 0;\n let created = 0;\n\n for (let index = 0; index < newChildren.length; index += 1) {\n const result = processChildNode(\n newChildren[index],\n existing[index],\n finalNodes\n );\n if (result === 'reused') reused += 1;\n else if (result === 'created') created += 1;\n }\n\n const tBuild = now() - start;\n const tCommit = commitBulkReplace(parent, finalNodes);\n\n keyedElements.delete(parent);\n\n const stats = {\n n: newChildren.length,\n reused,\n created,\n tBuild,\n tCommit,\n } as const;\n recordBulkTextStats(stats);\n\n return stats;\n}\n\nfunction processChildNode(\n vnode: VNode,\n existingNode: ChildNode | undefined,\n finalNodes: Node[]\n): 'reused' | 'created' | 'skipped' {\n if (typeof vnode === 'string' || typeof vnode === 'number') {\n return processTextVnode(String(vnode), existingNode, finalNodes);\n }\n\n if (typeof vnode === 'object' && vnode !== null && 'type' in vnode) {\n return processElementVnode(vnode, existingNode, finalNodes);\n }\n\n return 'skipped';\n}\n\nfunction processTextVnode(\n text: string,\n existingNode: ChildNode | undefined,\n finalNodes: Node[]\n): 'reused' | 'created' {\n if (existingNode && existingNode.nodeType === 3) {\n (existingNode as Text).data = text;\n finalNodes.push(existingNode);\n return 'reused';\n }\n\n finalNodes.push(document.createTextNode(text));\n return 'created';\n}\n\nfunction processElementVnode(\n vnode: VNode,\n existingNode: ChildNode | undefined,\n finalNodes: Node[]\n): 'reused' | 'created' | 'skipped' {\n const vnodeObj = vnode as unknown as { type?: unknown };\n\n if (typeof vnodeObj.type === 'string') {\n const tag = vnodeObj.type;\n if (\n existingNode &&\n existingNode.nodeType === 1 &&\n tagsEqualIgnoreCase((existingNode as Element).tagName, tag)\n ) {\n updateElementFromVnode(existingNode as Element, vnode);\n finalNodes.push(existingNode);\n return 'reused';\n }\n }\n\n const dom = createDOMNode(vnode);\n if (dom) {\n finalNodes.push(dom);\n return 'created';\n }\n\n return 'skipped';\n}\n\nfunction commitBulkReplace(parent: Element, nodes: Node[]): number {\n const startedAt = Date.now();\n const fragment = document.createDocumentFragment();\n\n for (let index = 0; index < nodes.length; index += 1) {\n fragment.appendChild(nodes[index]);\n }\n\n try {\n for (let node = parent.firstChild; node; ) {\n const next = node.nextSibling;\n teardownNodeSubtree(node);\n node = next;\n }\n } catch {\n // SLOW PATH: cleanup failure\n }\n\n recordDOMReplace('bulk-text-replace');\n parent.replaceChildren(fragment);\n return Date.now() - startedAt;\n}\n\nfunction recordBulkTextStats(stats: {\n n: number;\n reused: number;\n created: number;\n tBuild: number;\n tCommit: number;\n}): void {\n try {\n setDevValue('__LAST_BULK_TEXT_FASTPATH_STATS', stats);\n setDevValue('__LAST_FASTPATH_STATS', stats);\n setDevValue('__LAST_FASTPATH_COMMIT_COUNT', 1);\n incDevCounter('bulkTextFastpathHits');\n } catch {\n // Ignore stats errors\n }\n}\n\nexport function isBulkTextFastPathEligible(\n parent: Element,\n newChildren: VNode[]\n) {\n const env = getRuntimeEnv();\n const threshold = Number(env.ASKR_BULK_TEXT_THRESHOLD) || 1024;\n const requiredFraction = 0.8;\n\n const total = Array.isArray(newChildren) ? newChildren.length : 0;\n\n if (total < threshold) {\n recordBulkDiag({\n phase: 'bulk-unkeyed-eligible',\n reason: 'too-small',\n total,\n threshold,\n });\n return false;\n }\n\n const result = countSimpleChildren(newChildren);\n if (result.componentFound !== undefined) {\n recordBulkDiag({\n phase: 'bulk-unkeyed-eligible',\n reason: 'component-child',\n index: result.componentFound,\n });\n return false;\n }\n\n const fraction = result.simple / total;\n const eligible =\n fraction >= requiredFraction && parent.childNodes.length >= total;\n\n recordBulkDiag({\n phase: 'bulk-unkeyed-eligible',\n total,\n simple: result.simple,\n fraction,\n requiredFraction,\n eligible,\n });\n\n return eligible;\n}\n\nfunction countSimpleChildren(children: VNode[]): {\n simple: number;\n componentFound?: number;\n} {\n let simple = 0;\n\n for (let index = 0; index < children.length; index += 1) {\n const child = children[index];\n\n if (typeof child === 'string' || typeof child === 'number') {\n simple += 1;\n continue;\n }\n\n if (typeof child === 'object' && child !== null && 'type' in child) {\n const dom = child as DOMElement;\n\n if (typeof dom.type === 'function') {\n return { simple, componentFound: index };\n }\n\n if (typeof dom.type === 'string' && isSimpleElement(dom)) {\n simple += 1;\n }\n }\n }\n\n return { simple };\n}\n\nfunction isSimpleElement(dom: DOMElement): boolean {\n const children = dom.props?.children ?? dom.children;\n\n if (children === null || children === undefined) return true;\n\n if (typeof children === 'string' || typeof children === 'number') {\n return true;\n }\n\n if (\n Array.isArray(children) &&\n children.length === 1 &&\n (typeof children[0] === 'string' || typeof children[0] === 'number')\n ) {\n return true;\n }\n\n return false;\n}\n\nfunction recordBulkDiag(data: Record<string, unknown>): void {\n const env = getRuntimeEnv();\n if (env.NODE_ENV !== 'production' || env.ASKR_FASTPATH_DEBUG === '1') {\n try {\n setDevValue('__BULK_DIAG', data);\n } catch {\n // Ignore\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAeA,SAAS,mBAAmB,KAA4B;AACtD,SAAQ,KAAR;EACE,KAAK,MACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,KAAK,IACH,QAAO;EACT,KAAK,IACH,QAAO;EACT,KAAK,SACH,QAAO;EACT,KAAK,QACH,QAAO;EACT,KAAK,KACH,QAAO;EACT,KAAK,KACH,QAAO;EACT,KAAK,KACH,QAAO;EACT,QACE,QAAO;;;AAIb,SAAS,oBACP,gBACA,WACS;AACT,KAAI,mBAAmB,UAAW,QAAO;CAEzC,MAAM,cAAc,mBAAmB,UAAU;AACjD,KAAI,gBAAgB,QAAQ,mBAAmB,YAAa,QAAO;AAEnE,QAAO,wBAAwB,gBAAgB,UAAU;;AAG3D,SAAgB,qCACd,QACA,aACA;CACA,M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D,MAAM,QAAQ,SAAS;AAEvB,MAAI,OAAO,UAAU,YAAY,OAAO,UAAU,UAAU;AAC1D,aAAU;AACV;;AAGF,MAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU,OAAO;GAClE,MAAM,MAAM;AAEZ,OAAI,OAAO,IAAI,SAAS,WACtB,QAAO;IAAE;IAAQ,gBAAgB;IAAO;AAG1C,OAAI,OAAO,IAAI,SAAS,YAAY,gBAAgB,IAAI,CACtD,WAAU;;;AAKhB,QAAO,EAAE,QAAQ;;AAGnB,SAAS,gBAAgB,KAA0B;CACjD,MAAM,WAAW,IAAI,OAAO,YAAY,IAAI;AAE5C,KAAI,aAAa,QAAQ,aAAa,OAAW,QAAO;AAExD,KAAI,OAAO,aAAa,YAAY,OAAO,aAAa,SACtD,QAAO;AAGT,KACE,MAAM,QAAQ,SAAS,IACvB,SAAS,WAAW,MACnB,OAAO,SAAS,OAAO,YAAY,OAAO,SAAS,OAAO,UAE3D,QAAO;AAGT,QAAO;;AAGT,SAAS,eAAe,MAAqC;CAC3D,MAAM,MAAM,eAAe;AAC3B,KAAI,IAAI,aAAa,gBAAgB,IAAI,wBAAwB,IAC/D,KAAI;AACF,cAAY,eAAe,KAAK;SAC1B"}
1
+ {"version":3,"file":"children.js","names":[],"sources":["../../src/renderer/children.ts"],"sourcesContent":["import { setDevValue, incDevCounter } from '../runtime/dev-namespace';\nimport { getRuntimeEnv } from './env';\nimport { keyedElements } from './keyed';\nimport { teardownNodeSubtree } from './cleanup';\nimport { createDOMNode, updateElementFromVnode } from './dom';\nimport { _isDOMElement, type DOMElement, type VNode } from './types';\nimport {\n hasNonTrivialProps,\n logFastPathDebug,\n now,\n recordDOMReplace,\n recordFastPathStats,\n tagNamesEqualIgnoreCase,\n} from './utils';\n\nfunction upperCommonTagName(tag: string): string | null {\n switch (tag) {\n case 'div':\n return 'DIV';\n case 'span':\n return 'SPAN';\n case 'p':\n return 'P';\n case 'a':\n return 'A';\n case 'button':\n return 'BUTTON';\n case 'input':\n return 'INPUT';\n case 'ul':\n return 'UL';\n case 'ol':\n return 'OL';\n case 'li':\n return 'LI';\n default:\n return null;\n }\n}\n\nfunction tagsEqualIgnoreCase(\n elementTagName: string,\n vnodeType: string\n): boolean {\n if (elementTagName === vnodeType) return true;\n\n const upperCommon = upperCommonTagName(vnodeType);\n if (upperCommon !== null && elementTagName === upperCommon) return true;\n\n return tagNamesEqualIgnoreCase(elementTagName, vnodeType);\n}\n\nexport function performBulkPositionalKeyedTextUpdate(\n parent: Element,\n keyedVnodes: Array<{ key: string | number; vnode: VNode }>\n) {\n const total = keyedVnodes.length;\n let reused = 0;\n let updatedKeys = 0;\n const start = now();\n const env = getRuntimeEnv();\n const debugFastPath =\n env.ASKR_FASTPATH_DEBUG === '1' || env.ASKR_FASTPATH_DEBUG === 'true';\n\n for (let index = 0; index < total; index += 1) {\n const { key, vnode } = keyedVnodes[index];\n const child = parent.children[index] as Element | undefined;\n\n if (\n child &&\n _isDOMElement(vnode) &&\n typeof (vnode as DOMElement).type === 'string'\n ) {\n const vnodeType = (vnode as DOMElement).type as string;\n\n if (tagsEqualIgnoreCase(child.tagName, vnodeType)) {\n const children =\n (vnode as DOMElement).children ||\n (vnode as DOMElement).props?.children;\n\n if (debugFastPath) {\n logFastPathDebug('positional idx', index, {\n chTag: child.tagName,\n vnodeType,\n chChildNodes: child.childNodes.length,\n childrenType: Array.isArray(children) ? 'array' : typeof children,\n });\n }\n\n updateTextContent(child, children, vnode as DOMElement);\n setDataKey(child, key, () => (updatedKeys += 1));\n reused += 1;\n continue;\n }\n\n if (debugFastPath) {\n logFastPathDebug('positional tag mismatch', index, {\n chTag: child.tagName,\n vnodeType,\n });\n }\n } else if (debugFastPath) {\n logFastPathDebug('positional missing or invalid', index, { ch: !!child });\n }\n\n replaceNodeAtPosition(parent, index, vnode);\n }\n\n const elapsed = now() - start;\n updateKeyedElementsMap(parent, keyedVnodes);\n\n const stats = { n: total, reused, updatedKeys, t: elapsed } as const;\n recordFastPathStats(stats, 'bulkKeyedPositionalHits');\n\n return stats;\n}\n\nfunction updateTextContent(\n el: Element,\n children: unknown,\n vnode: DOMElement\n): void {\n if (typeof children === 'string' || typeof children === 'number') {\n setTextNodeData(el, String(children));\n if (vnode.props && hasNonTrivialProps(vnode.props)) {\n updateElementFromVnode(el, vnode, false);\n }\n return;\n }\n\n if (\n Array.isArray(children) &&\n children.length === 1 &&\n (typeof children[0] === 'string' || typeof children[0] === 'number')\n ) {\n setTextNodeData(el, String(children[0]));\n if (vnode.props && hasNonTrivialProps(vnode.props)) {\n updateElementFromVnode(el, vnode, false);\n }\n return;\n }\n\n if (!tryUpdateTwoChildTextPattern(el, vnode)) {\n updateElementFromVnode(el, vnode);\n }\n}\n\nfunction tryUpdateTwoChildTextPattern(\n parentEl: Element,\n vnode: DOMElement\n): boolean {\n const vnodeChildren = vnode.props?.children ?? vnode.children;\n if (!Array.isArray(vnodeChildren) || vnodeChildren.length !== 2) return false;\n\n const firstChild = vnodeChildren[0];\n const secondChild = vnodeChildren[1];\n if (!_isDOMElement(firstChild) || !_isDOMElement(secondChild)) return false;\n if (\n typeof firstChild.type !== 'string' ||\n typeof secondChild.type !== 'string'\n ) {\n return false;\n }\n\n const firstElement = parentEl.children[0] as Element | undefined;\n const secondElement = parentEl.children[1] as Element | undefined;\n if (!firstElement || !secondElement) return false;\n if (parentEl.children.length !== 2 || parentEl.childNodes.length !== 2) {\n return false;\n }\n\n if (!tagsEqualIgnoreCase(firstElement.tagName, firstChild.type)) return false;\n if (!tagsEqualIgnoreCase(secondElement.tagName, secondChild.type))\n return false;\n\n const firstText = (firstChild.children ||\n firstChild.props?.children) as unknown;\n const secondText = (secondChild.children ||\n secondChild.props?.children) as unknown;\n\n if (typeof firstText === 'string' || typeof firstText === 'number') {\n setTextNodeData(firstElement, String(firstText));\n } else if (\n Array.isArray(firstText) &&\n firstText.length === 1 &&\n (typeof firstText[0] === 'string' || typeof firstText[0] === 'number')\n ) {\n setTextNodeData(firstElement, String(firstText[0]));\n } else {\n return false;\n }\n\n if (typeof secondText === 'string' || typeof secondText === 'number') {\n setTextNodeData(secondElement, String(secondText));\n } else if (\n Array.isArray(secondText) &&\n secondText.length === 1 &&\n (typeof secondText[0] === 'string' || typeof secondText[0] === 'number')\n ) {\n setTextNodeData(secondElement, String(secondText[0]));\n } else {\n return false;\n }\n\n return true;\n}\n\nfunction setTextNodeData(el: Element, text: string): void {\n if (el.childNodes.length === 1 && el.firstChild?.nodeType === 3) {\n const textNode = el.firstChild as Text;\n if (textNode.data !== text) textNode.data = text;\n } else {\n el.textContent = text;\n }\n}\n\nfunction setDataKey(\n el: Element,\n key: string | number,\n onSet: () => void\n): void {\n try {\n const next = String(key);\n if (el.getAttribute('data-key') === next) return;\n el.setAttribute('data-key', next);\n onSet();\n } catch {\n // Ignore errors setting data-key\n }\n}\n\nfunction replaceNodeAtPosition(\n parent: Element,\n index: number,\n vnode: VNode\n): void {\n const dom = createDOMNode(vnode);\n if (dom) {\n const existing = parent.children[index];\n if (existing) {\n teardownNodeSubtree(existing);\n parent.replaceChild(dom, existing);\n } else {\n parent.appendChild(dom);\n }\n }\n}\n\nfunction updateKeyedElementsMap(\n parent: Element,\n keyedVnodes: Array<{ key: string | number; vnode: VNode }>\n): void {\n try {\n const existing = keyedElements.get(parent);\n const newKeyMap = existing\n ? (existing.clear(), existing)\n : new Map<string | number, Element>();\n\n for (let index = 0; index < keyedVnodes.length; index += 1) {\n const key = keyedVnodes[index].key;\n const child = parent.children[index] as Element | undefined;\n if (child) newKeyMap.set(key, child);\n }\n\n keyedElements.set(parent, newKeyMap);\n } catch {\n // Ignore errors updating key map\n }\n}\n\nexport function performBulkTextReplace(parent: Element, newChildren: VNode[]) {\n const start = now();\n const existing = Array.from(parent.childNodes);\n const finalNodes: Node[] = [];\n let reused = 0;\n let created = 0;\n\n for (let index = 0; index < newChildren.length; index += 1) {\n const result = processChildNode(\n newChildren[index],\n existing[index],\n finalNodes\n );\n if (result === 'reused') reused += 1;\n else if (result === 'created') created += 1;\n }\n\n const tBuild = now() - start;\n const tCommit = commitBulkReplace(parent, finalNodes);\n\n keyedElements.delete(parent);\n\n const stats = {\n n: newChildren.length,\n reused,\n created,\n tBuild,\n tCommit,\n } as const;\n recordBulkTextStats(stats);\n\n return stats;\n}\n\nfunction processChildNode(\n vnode: VNode,\n existingNode: ChildNode | undefined,\n finalNodes: Node[]\n): 'reused' | 'created' | 'skipped' {\n if (typeof vnode === 'string' || typeof vnode === 'number') {\n return processTextVnode(String(vnode), existingNode, finalNodes);\n }\n\n if (typeof vnode === 'object' && vnode !== null && 'type' in vnode) {\n return processElementVnode(vnode, existingNode, finalNodes);\n }\n\n return 'skipped';\n}\n\nfunction processTextVnode(\n text: string,\n existingNode: ChildNode | undefined,\n finalNodes: Node[]\n): 'reused' | 'created' {\n if (existingNode && existingNode.nodeType === 3) {\n (existingNode as Text).data = text;\n finalNodes.push(existingNode);\n return 'reused';\n }\n\n finalNodes.push(document.createTextNode(text));\n return 'created';\n}\n\nfunction processElementVnode(\n vnode: VNode,\n existingNode: ChildNode | undefined,\n finalNodes: Node[]\n): 'reused' | 'created' | 'skipped' {\n const vnodeObj = vnode as unknown as { type?: unknown };\n\n if (typeof vnodeObj.type === 'string') {\n const tag = vnodeObj.type;\n if (\n existingNode &&\n existingNode.nodeType === 1 &&\n tagsEqualIgnoreCase((existingNode as Element).tagName, tag)\n ) {\n updateElementFromVnode(existingNode as Element, vnode);\n finalNodes.push(existingNode);\n return 'reused';\n }\n }\n\n const dom = createDOMNode(vnode);\n if (dom) {\n finalNodes.push(dom);\n return 'created';\n }\n\n return 'skipped';\n}\n\nfunction commitBulkReplace(parent: Element, nodes: Node[]): number {\n const startedAt = Date.now();\n const fragment = document.createDocumentFragment();\n\n for (let index = 0; index < nodes.length; index += 1) {\n fragment.appendChild(nodes[index]);\n }\n\n try {\n for (let node = parent.firstChild; node; ) {\n const next = node.nextSibling;\n teardownNodeSubtree(node);\n node = next;\n }\n } catch {\n // SLOW PATH: cleanup failure\n }\n\n recordDOMReplace('bulk-text-replace');\n parent.replaceChildren(fragment);\n return Date.now() - startedAt;\n}\n\nfunction recordBulkTextStats(stats: {\n n: number;\n reused: number;\n created: number;\n tBuild: number;\n tCommit: number;\n}): void {\n try {\n setDevValue('__LAST_BULK_TEXT_FASTPATH_STATS', stats);\n setDevValue('__LAST_FASTPATH_STATS', stats);\n setDevValue('__LAST_FASTPATH_COMMIT_COUNT', 1);\n incDevCounter('bulkTextFastpathHits');\n } catch {\n // Ignore stats errors\n }\n}\n\nexport function isBulkTextFastPathEligible(\n parent: Element,\n newChildren: VNode[]\n) {\n const env = getRuntimeEnv();\n const threshold = Number(env.ASKR_BULK_TEXT_THRESHOLD) || 1024;\n const requiredFraction = 0.8;\n\n const total = Array.isArray(newChildren) ? newChildren.length : 0;\n\n if (total < threshold) {\n recordBulkDiag({\n phase: 'bulk-unkeyed-eligible',\n reason: 'too-small',\n total,\n threshold,\n });\n return false;\n }\n\n const result = countSimpleChildren(newChildren);\n if (result.componentFound !== undefined) {\n recordBulkDiag({\n phase: 'bulk-unkeyed-eligible',\n reason: 'component-child',\n index: result.componentFound,\n });\n return false;\n }\n\n const fraction = result.simple / total;\n const eligible =\n fraction >= requiredFraction && parent.childNodes.length >= total;\n\n recordBulkDiag({\n phase: 'bulk-unkeyed-eligible',\n total,\n simple: result.simple,\n fraction,\n requiredFraction,\n eligible,\n });\n\n return eligible;\n}\n\nfunction countSimpleChildren(children: VNode[]): {\n simple: number;\n componentFound?: number;\n} {\n let simple = 0;\n\n for (let index = 0; index < children.length; index += 1) {\n const child = children[index];\n\n if (typeof child === 'string' || typeof child === 'number') {\n simple += 1;\n continue;\n }\n\n if (typeof child === 'object' && child !== null && 'type' in child) {\n const dom = child as DOMElement;\n\n if (typeof dom.type === 'function') {\n return { simple, componentFound: index };\n }\n\n if (typeof dom.type === 'string' && isSimpleElement(dom)) {\n simple += 1;\n }\n }\n }\n\n return { simple };\n}\n\nfunction isSimpleElement(dom: DOMElement): boolean {\n const children = dom.props?.children ?? dom.children;\n\n if (children === null || children === undefined) return true;\n\n if (typeof children === 'string' || typeof children === 'number') {\n return true;\n }\n\n if (\n Array.isArray(children) &&\n children.length === 1 &&\n (typeof children[0] === 'string' || typeof children[0] === 'number')\n ) {\n return true;\n }\n\n return false;\n}\n\nfunction recordBulkDiag(data: Record<string, unknown>): void {\n const env = getRuntimeEnv();\n if (env.NODE_ENV !== 'production' || env.ASKR_FASTPATH_DEBUG === '1') {\n try {\n setDevValue('__BULK_DIAG', data);\n } catch {\n // Ignore\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAeA,SAAS,mBAAmB,KAA4B;CACtD,QAAQ,KAAR;EACE,KAAK,OACH,OAAO;EACT,KAAK,QACH,OAAO;EACT,KAAK,KACH,OAAO;EACT,KAAK,KACH,OAAO;EACT,KAAK,UACH,OAAO;EACT,KAAK,SACH,OAAO;EACT,KAAK,MACH,OAAO;EACT,KAAK,MACH,OAAO;EACT,KAAK,MACH,OAAO;EACT,SACE,OAAO;;;AAIb,SAAS,oBACP,gBACA,WACS;CACT,IAAI,mBAAmB,WAAW,OAAO;CAEzC,MAAM,cAAc,mBAAmB,UAAU;CACjD,IAAI,gBAAgB,QAAQ,mBAAmB,aAAa,OAAO;CAEnE,OAAO,wBAAwB,gBAAgB,UAAU;;AAG3D,SAAgB,qCACd,QACA,aACA;CACA,MAAM,QAAQ,YAAY;CAC1B,IAAI,SAAS;CACb,IAAI,cAAc;CAClB,MAAM,QAAQ,KAAK;CACnB,MAAM,MAAM,eAAe;CAC3B,MAAM,gBACJ,IAAI,wBAAwB,OAAO,IAAI,wBAAwB;CAEjE,KAAK,IAAI,QAAQ,GAAG,QAAQ,OAAO,SAAS,GAAG;EAC7C,MAAM,EAAE,KAAK,UAAU,YAAY;EACnC,MAAM,QAAQ,OAAO,SAAS;EAE9B,IACE,SACA,cAAc,MAAM,IACpB,OAAQ,MAAqB,SAAS,UACtC;GACA,MAAM,YAAa,MAAqB;GAExC,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jD,MAAM,WAAW,IAAI,OAAO,YAAY,IAAI;CAE5C,IAAI,aAAa,QAAQ,aAAa,QAAW,OAAO;CAExD,IAAI,OAAO,aAAa,YAAY,OAAO,aAAa,UACtD,OAAO;CAGT,IACE,MAAM,QAAQ,SAAS,IACvB,SAAS,WAAW,MACnB,OAAO,SAAS,OAAO,YAAY,OAAO,SAAS,OAAO,WAE3D,OAAO;CAGT,OAAO;;AAGT,SAAS,eAAe,MAAqC;CAC3D,MAAM,MAAM,eAAe;CAC3B,IAAI,IAAI,aAAa,gBAAgB,IAAI,wBAAwB,KAC/D,IAAI;EACF,YAAY,eAAe,KAAK;SAC1B"}
@@ -1 +1 @@
1
- {"version":3,"file":"cleanup.js","names":[],"sources":["../../src/renderer/cleanup.ts"],"sourcesContent":["import { cleanupComponent } from '../runtime/component';\nimport type { ComponentInstance } from '../runtime/component';\nimport { logger } from '../dev/logger';\nimport { incDevCounter } from '../runtime/dev-namespace';\nimport {\n clearDelegatedHandlersForElement,\n removeDelegatedListener,\n} from '../runtime/events';\n\ntype InstanceHost = Node & { __ASKR_INSTANCE?: unknown };\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Instance Cleanup Helpers\n// ─────────────────────────────────────────────────────────────────────────────\n\nfunction cleanupSingleInstance(\n node: InstanceHost,\n errors: unknown[] | null,\n strict: boolean\n): void {\n const inst = node.__ASKR_INSTANCE;\n if (!inst) return;\n\n try {\n cleanupComponent(inst as ComponentInstance);\n } catch (err) {\n if (strict) errors!.push(err);\n else logger.warn('[Askr] cleanupComponent failed:', err);\n }\n\n try {\n delete node.__ASKR_INSTANCE;\n } catch (e) {\n if (strict) errors!.push(e);\n }\n}\n\nfunction teardownSingleElement(\n element: Element,\n errors: unknown[] | null,\n strict: boolean\n): void {\n try {\n removeElementListeners(element);\n } catch (err) {\n if (strict) errors!.push(err);\n else logger.warn('[Askr] removeElementListeners failed:', err);\n }\n\n try {\n removeElementReactiveProps(element);\n } catch (err) {\n if (strict) errors!.push(err);\n else logger.warn('[Askr] removeElementReactiveProps failed:', err);\n }\n\n try {\n cleanupSingleInstance(element as InstanceHost, errors, strict);\n } catch (err) {\n if (strict) errors!.push(err);\n else logger.warn('[Askr] cleanupSingleInstance failed:', err);\n }\n}\n\n// Walk descendant elements with minimal allocations.\n// HOT PATH: used during subtree teardown (replace/unmount).\nfunction forEachDescendantElement(root: Element, visit: (el: Element) => void) {\n // Prefer TreeWalker when available; it avoids allocating a NodeList.\n try {\n const doc = root.ownerDocument;\n const createTreeWalker = doc?.createTreeWalker;\n if (typeof createTreeWalker === 'function') {\n // NodeFilter.SHOW_ELEMENT === 1\n const walker = createTreeWalker.call(doc, root, 1);\n let n = walker.firstChild();\n while (n) {\n visit(n as Element);\n n = walker.nextNode();\n }\n return;\n }\n } catch {\n // SLOW PATH: TreeWalker unavailable\n }\n\n // Fallback: querySelectorAll\n const descendants = root.querySelectorAll('*');\n for (let i = 0; i < descendants.length; i++) {\n visit(descendants[i]);\n }\n}\n\nfunction forEachElementInSubtree(root: Element, visit: (el: Element) => void) {\n visit(root);\n forEachDescendantElement(root, visit);\n}\n\n// Track listeners so we can remove them on cleanup\nexport interface ListenerMapEntry {\n handler: EventListener;\n original: EventListener;\n options?: boolean | AddEventListenerOptions;\n isDelegated?: boolean;\n updateHandler?: (nextHandler: EventListener) => void;\n}\nexport const elementListeners = new WeakMap<\n Element,\n Map<string, ListenerMapEntry>\n>();\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Public API\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * Clean up component instance attached to a DOM node\n * Accepts an optional `opts.strict` flag to surface errors instead of swallowing them.\n */\nexport function cleanupInstanceIfPresent(\n node: Node | null,\n opts?: { strict?: boolean }\n): void {\n if (!node) return;\n\n const strict = opts?.strict ?? false;\n const errors: unknown[] | null = strict ? [] : null;\n\n // Clean up the node itself\n try {\n cleanupSingleInstance(node as InstanceHost, errors, strict);\n } catch (err) {\n if (strict) errors!.push(err);\n else logger.warn('[Askr] cleanupInstanceIfPresent failed:', err);\n }\n\n if (node instanceof Element) {\n // Clean up any nested instances on descendants\n try {\n forEachDescendantElement(node, (d) => {\n try {\n cleanupSingleInstance(d as InstanceHost, errors, strict);\n } catch (err) {\n if (strict) errors!.push(err);\n else\n logger.warn(\n '[Askr] cleanupInstanceIfPresent descendant cleanup failed:',\n err\n );\n }\n });\n } catch (err) {\n if (strict) errors!.push(err);\n else\n logger.warn(\n '[Askr] cleanupInstanceIfPresent descendant query failed:',\n err\n );\n }\n }\n\n if (errors && errors.length > 0) {\n throw new AggregateError(errors, 'cleanupInstanceIfPresent failed');\n }\n}\n\n// Public helper to clean up any component instances under a node. Used by\n// runtime commit logic to ensure component instances are torn down when their\n// host nodes are removed during an update.\nexport function cleanupInstancesUnder(\n node: Node | null,\n opts?: { strict?: boolean }\n): void {\n cleanupInstanceIfPresent(node, opts);\n}\n\nexport function teardownNodeSubtree(\n node: Node | null,\n opts?: { strict?: boolean }\n): void {\n if (!node) return;\n\n const strict = opts?.strict ?? false;\n const errors: unknown[] | null = strict ? [] : null;\n\n if (!(node instanceof Element)) {\n cleanupSingleInstance(node as InstanceHost, errors, strict);\n if (errors && errors.length > 0) {\n throw new AggregateError(errors, 'teardownNodeSubtree failed');\n }\n return;\n }\n\n try {\n forEachElementInSubtree(node, (element) => {\n teardownSingleElement(element, errors, strict);\n });\n } catch (err) {\n if (strict) errors!.push(err);\n else logger.warn('[Askr] teardownNodeSubtree failed:', err);\n }\n\n if (errors && errors.length > 0) {\n throw new AggregateError(errors, 'teardownNodeSubtree failed');\n }\n}\n\n// Track reactive props cleanup functions and their function references\nexport interface ReactivePropCleanupEntry {\n cleanup: () => void;\n fnRef: unknown;\n updateFn?: (nextValue: unknown) => void;\n}\n\nexport const REACTIVE_CHILDREN_KEY = '__askr_reactive_children__';\n\nexport const elementReactivePropsCleanup = new WeakMap<\n Element,\n Map<string, ReactivePropCleanupEntry>\n>();\n\nexport function removeElementReactiveProps(element: Element): void {\n const cleanupMap = elementReactivePropsCleanup.get(element);\n if (cleanupMap) {\n for (const entry of cleanupMap.values()) {\n try {\n entry.cleanup();\n } catch (err) {\n logger.warn('[Askr] reactive prop cleanup failed:', err);\n }\n }\n elementReactivePropsCleanup.delete(element);\n }\n}\n\nexport function removeElementListeners(element: Element): void {\n const map = elementListeners.get(element);\n if (map) {\n for (const [eventName, entry] of map) {\n incDevCounter('listenerRemoves');\n if (entry.isDelegated) {\n removeDelegatedListener(element, eventName);\n } else {\n if (entry.options !== undefined)\n element.removeEventListener(eventName, entry.handler, entry.options);\n else element.removeEventListener(eventName, entry.handler);\n }\n }\n elementListeners.delete(element);\n }\n\n clearDelegatedHandlersForElement(element);\n}\n\nexport function removeAllListeners(root: Element | null): void {\n if (!root) return;\n\n forEachElementInSubtree(root, (el) => {\n removeElementListeners(el);\n removeElementReactiveProps(el);\n });\n}\n"],"mappings":";;;;;AAeA,SAAS,sBACP,MACA,QACA,QACM;CACN,MAAM,OAAO,KAAK;AAClB,KAAI,CAAC,KAAM;AAEX,KAAI;AACF,mBAAiB,KAA0B;UACpC,KAAK;AACZ,MAAI,OAAQ,QAAQ,KAAK,IAAI;MACxB,QAAO,KAAK,mCAAmC,IAAI;;AAG1D,KAAI;AACF,SAAO,KAAK;UACL,GAAG;AACV,MAAI,OAAQ,QAAQ,KAAK,EAAE;;;AAI/B,SAAS,sBACP,SACA,QACA,QACM;AACN,KAAI;AACF,yBAAuB,QAAQ;UACxB,KAAK;AACZ,MAAI,OAAQ,QAAQ,KAAK,IAAI;MACxB,QAAO,KAAK,yCAAyC,IAAI;;AAGhE,KAAI;AACF,6BAA2B,QAAQ;UAC5B,KAAK;AACZ,MAAI,OAAQ,QAAQ,KAAK,IAAI;MACxB,QAAO,KAAK,6CAA6C,IAAI;;AAGpE,KAAI;AACF,wBAAsB,SAAyB,QAAQ,OAAO;UACvD,KAAK;AACZ,MAAI,OAAQ,QAAQ,KAAK,IAAI;MACxB,QAAO,KAAK,wCAAwC,IAAI;;;AAMjE,SA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"file":"cleanup.js","names":[],"sources":["../../src/renderer/cleanup.ts"],"sourcesContent":["import { cleanupComponent } from '../runtime/component';\nimport type { ComponentInstance } from '../runtime/component';\nimport { logger } from '../dev/logger';\nimport { incDevCounter } from '../runtime/dev-namespace';\nimport {\n clearDelegatedHandlersForElement,\n removeDelegatedListener,\n} from '../runtime/events';\n\ntype InstanceHost = Node & { __ASKR_INSTANCE?: unknown };\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Instance Cleanup Helpers\n// ─────────────────────────────────────────────────────────────────────────────\n\nfunction cleanupSingleInstance(\n node: InstanceHost,\n errors: unknown[] | null,\n strict: boolean\n): void {\n const inst = node.__ASKR_INSTANCE;\n if (!inst) return;\n\n try {\n cleanupComponent(inst as ComponentInstance);\n } catch (err) {\n if (strict) errors!.push(err);\n else logger.warn('[Askr] cleanupComponent failed:', err);\n }\n\n try {\n delete node.__ASKR_INSTANCE;\n } catch (e) {\n if (strict) errors!.push(e);\n }\n}\n\nfunction teardownSingleElement(\n element: Element,\n errors: unknown[] | null,\n strict: boolean\n): void {\n try {\n removeElementListeners(element);\n } catch (err) {\n if (strict) errors!.push(err);\n else logger.warn('[Askr] removeElementListeners failed:', err);\n }\n\n try {\n removeElementReactiveProps(element);\n } catch (err) {\n if (strict) errors!.push(err);\n else logger.warn('[Askr] removeElementReactiveProps failed:', err);\n }\n\n try {\n cleanupSingleInstance(element as InstanceHost, errors, strict);\n } catch (err) {\n if (strict) errors!.push(err);\n else logger.warn('[Askr] cleanupSingleInstance failed:', err);\n }\n}\n\n// Walk descendant elements with minimal allocations.\n// HOT PATH: used during subtree teardown (replace/unmount).\nfunction forEachDescendantElement(root: Element, visit: (el: Element) => void) {\n // Prefer TreeWalker when available; it avoids allocating a NodeList.\n try {\n const doc = root.ownerDocument;\n const createTreeWalker = doc?.createTreeWalker;\n if (typeof createTreeWalker === 'function') {\n // NodeFilter.SHOW_ELEMENT === 1\n const walker = createTreeWalker.call(doc, root, 1);\n let n = walker.firstChild();\n while (n) {\n visit(n as Element);\n n = walker.nextNode();\n }\n return;\n }\n } catch {\n // SLOW PATH: TreeWalker unavailable\n }\n\n // Fallback: querySelectorAll\n const descendants = root.querySelectorAll('*');\n for (let i = 0; i < descendants.length; i++) {\n visit(descendants[i]);\n }\n}\n\nfunction forEachElementInSubtree(root: Element, visit: (el: Element) => void) {\n visit(root);\n forEachDescendantElement(root, visit);\n}\n\n// Track listeners so we can remove them on cleanup\nexport interface ListenerMapEntry {\n handler: EventListener;\n original: EventListener;\n options?: boolean | AddEventListenerOptions;\n isDelegated?: boolean;\n updateHandler?: (nextHandler: EventListener) => void;\n}\nexport const elementListeners = new WeakMap<\n Element,\n Map<string, ListenerMapEntry>\n>();\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Public API\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * Clean up component instance attached to a DOM node\n * Accepts an optional `opts.strict` flag to surface errors instead of swallowing them.\n */\nexport function cleanupInstanceIfPresent(\n node: Node | null,\n opts?: { strict?: boolean }\n): void {\n if (!node) return;\n\n const strict = opts?.strict ?? false;\n const errors: unknown[] | null = strict ? [] : null;\n\n // Clean up the node itself\n try {\n cleanupSingleInstance(node as InstanceHost, errors, strict);\n } catch (err) {\n if (strict) errors!.push(err);\n else logger.warn('[Askr] cleanupInstanceIfPresent failed:', err);\n }\n\n if (node instanceof Element) {\n // Clean up any nested instances on descendants\n try {\n forEachDescendantElement(node, (d) => {\n try {\n cleanupSingleInstance(d as InstanceHost, errors, strict);\n } catch (err) {\n if (strict) errors!.push(err);\n else\n logger.warn(\n '[Askr] cleanupInstanceIfPresent descendant cleanup failed:',\n err\n );\n }\n });\n } catch (err) {\n if (strict) errors!.push(err);\n else\n logger.warn(\n '[Askr] cleanupInstanceIfPresent descendant query failed:',\n err\n );\n }\n }\n\n if (errors && errors.length > 0) {\n throw new AggregateError(errors, 'cleanupInstanceIfPresent failed');\n }\n}\n\n// Public helper to clean up any component instances under a node. Used by\n// runtime commit logic to ensure component instances are torn down when their\n// host nodes are removed during an update.\nexport function cleanupInstancesUnder(\n node: Node | null,\n opts?: { strict?: boolean }\n): void {\n cleanupInstanceIfPresent(node, opts);\n}\n\nexport function teardownNodeSubtree(\n node: Node | null,\n opts?: { strict?: boolean }\n): void {\n if (!node) return;\n\n const strict = opts?.strict ?? false;\n const errors: unknown[] | null = strict ? [] : null;\n\n if (!(node instanceof Element)) {\n cleanupSingleInstance(node as InstanceHost, errors, strict);\n if (errors && errors.length > 0) {\n throw new AggregateError(errors, 'teardownNodeSubtree failed');\n }\n return;\n }\n\n try {\n forEachElementInSubtree(node, (element) => {\n teardownSingleElement(element, errors, strict);\n });\n } catch (err) {\n if (strict) errors!.push(err);\n else logger.warn('[Askr] teardownNodeSubtree failed:', err);\n }\n\n if (errors && errors.length > 0) {\n throw new AggregateError(errors, 'teardownNodeSubtree failed');\n }\n}\n\n// Track reactive props cleanup functions and their function references\nexport interface ReactivePropCleanupEntry {\n cleanup: () => void;\n fnRef: unknown;\n updateFn?: (nextValue: unknown) => void;\n}\n\nexport const REACTIVE_CHILDREN_KEY = '__askr_reactive_children__';\n\nexport const elementReactivePropsCleanup = new WeakMap<\n Element,\n Map<string, ReactivePropCleanupEntry>\n>();\n\nexport function removeElementReactiveProps(element: Element): void {\n const cleanupMap = elementReactivePropsCleanup.get(element);\n if (cleanupMap) {\n for (const entry of cleanupMap.values()) {\n try {\n entry.cleanup();\n } catch (err) {\n logger.warn('[Askr] reactive prop cleanup failed:', err);\n }\n }\n elementReactivePropsCleanup.delete(element);\n }\n}\n\nexport function removeElementListeners(element: Element): void {\n const map = elementListeners.get(element);\n if (map) {\n for (const [eventName, entry] of map) {\n incDevCounter('listenerRemoves');\n if (entry.isDelegated) {\n removeDelegatedListener(element, eventName);\n } else {\n if (entry.options !== undefined)\n element.removeEventListener(eventName, entry.handler, entry.options);\n else element.removeEventListener(eventName, entry.handler);\n }\n }\n elementListeners.delete(element);\n }\n\n clearDelegatedHandlersForElement(element);\n}\n\nexport function removeAllListeners(root: Element | null): void {\n if (!root) return;\n\n forEachElementInSubtree(root, (el) => {\n removeElementListeners(el);\n removeElementReactiveProps(el);\n });\n}\n"],"mappings":";;;;;AAeA,SAAS,sBACP,MACA,QACA,QACM;CACN,MAAM,OAAO,KAAK;CAClB,IAAI,CAAC,MAAM;CAEX,IAAI;EACF,iBAAiB,KAA0B;UACpC,KAAK;EACZ,IAAI,QAAQ,OAAQ,KAAK,IAAI;OACxB,OAAO,KAAK,mCAAmC,IAAI;;CAG1D,IAAI;EACF,OAAO,KAAK;UACL,GAAG;EACV,IAAI,QAAQ,OAAQ,KAAK,EAAE;;;AAI/B,SAAS,sBACP,SACA,QACA,QACM;CACN,IAAI;EACF,uBAAuB,QAAQ;UACxB,KAAK;EACZ,IAAI,QAAQ,OAAQ,KAAK,IAAI;OACxB,OAAO,KAAK,yCAAyC,IAAI;;CAGhE,IAAI;EACF,2BAA2B,QAAQ;UAC5B,KAAK;EACZ,IAAI,QAAQ,OAAQ,KAAK,IAAI;OACxB,OAAO,KAAK,6CAA6C,IAAI;;CAGpE,IAAI;EACF,sBAAsB,SAAyB,QAAQ,OAAO;UACvD,KAAK;EACZ,IAAI,QAAQ,OAAQ,KAAK,IAAI;OACxB,OAAO,KAAK,wCAAwC,IAAI;;;AAMjE,SAAS,yBAAyB,MAAe,OAA8B;CAE7E,IAAI;EACF,MAAM,MAAM,KAAK;EACjB,MAAM,mBAAmB,KAAK;EAC9B,IAAI,OAAO,qBAAqB,YAAY;GAE1C,MAAM,SAAS,iBAAiB,KAAK,KAAK,MAAM,EAAE;GAClD,IAAI,IAAI,OAAO,YAAY;GAC3B,OAAO,GAAG;IACR,MAAM,EAAa;IACnB,IAAI,OAAO,UAAU;;GAEvB;;SAEI;CAKR,MAAM,cAAc,KAAK,iBAAiB,IAAI;CAC9C,KAAK,IAAI,IAAI,GAAG,IAAI,YAAY,QAAQ,KACtC,MAAM,YAAY,GAAG;;AAIzB,SAAS,wBAAwB,MAAe,OAA8B;CA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