@pithyjs/core 0.1.0-beta.1 → 0.1.0-beta.11

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 (201) hide show
  1. package/README.md +12 -6
  2. package/dist/a11y/focus-trap.d.ts.map +1 -1
  3. package/dist/a11y/focus-trap.js +2 -0
  4. package/dist/a11y/focus-trap.js.map +1 -1
  5. package/dist/a11y/index.d.ts +4 -4
  6. package/dist/a11y/index.js +4 -4
  7. package/dist/a11y/index.js.map +1 -1
  8. package/dist/a11y/keyboard-utils.js.map +1 -1
  9. package/dist/a11y/roving-tabindex.js.map +1 -1
  10. package/dist/a11y/skip-link.js.map +1 -1
  11. package/dist/compile/bindSwitchCases.d.ts +8 -3
  12. package/dist/compile/bindSwitchCases.d.ts.map +1 -1
  13. package/dist/compile/bindSwitchCases.js +114 -181
  14. package/dist/compile/bindSwitchCases.js.map +1 -1
  15. package/dist/compile/binds/bindBoundAttributes.d.ts +1 -0
  16. package/dist/compile/binds/bindBoundAttributes.d.ts.map +1 -1
  17. package/dist/compile/binds/bindBoundAttributes.js +47 -2
  18. package/dist/compile/binds/bindBoundAttributes.js.map +1 -1
  19. package/dist/compile/binds/bindClassDirectives.d.ts +3 -2
  20. package/dist/compile/binds/bindClassDirectives.d.ts.map +1 -1
  21. package/dist/compile/binds/bindClassDirectives.js +53 -18
  22. package/dist/compile/binds/bindClassDirectives.js.map +1 -1
  23. package/dist/compile/binds/bindComponentsTags.d.ts +2 -0
  24. package/dist/compile/binds/bindComponentsTags.d.ts.map +1 -1
  25. package/dist/compile/binds/bindComponentsTags.js +86 -46
  26. package/dist/compile/binds/bindComponentsTags.js.map +1 -1
  27. package/dist/compile/binds/bindConditionals.d.ts +2 -2
  28. package/dist/compile/binds/bindConditionals.d.ts.map +1 -1
  29. package/dist/compile/binds/bindConditionals.js +22 -5
  30. package/dist/compile/binds/bindConditionals.js.map +1 -1
  31. package/dist/compile/binds/bindDefaultTwoWay.d.ts.map +1 -1
  32. package/dist/compile/binds/bindDefaultTwoWay.js +2 -1
  33. package/dist/compile/binds/bindDefaultTwoWay.js.map +1 -1
  34. package/dist/compile/binds/bindDeferDirectives.js +4 -4
  35. package/dist/compile/binds/bindDeferDirectives.js.map +1 -1
  36. package/dist/compile/binds/bindErrorBoundary.d.ts.map +1 -1
  37. package/dist/compile/binds/bindErrorBoundary.js +8 -3
  38. package/dist/compile/binds/bindErrorBoundary.js.map +1 -1
  39. package/dist/compile/binds/bindEventHandlers.js +2 -2
  40. package/dist/compile/binds/bindEventHandlers.js.map +1 -1
  41. package/dist/compile/binds/bindRefDirectives.js.map +1 -1
  42. package/dist/compile/binds/bindStyleDirectives.d.ts +17 -0
  43. package/dist/compile/binds/bindStyleDirectives.d.ts.map +1 -0
  44. package/dist/compile/binds/bindStyleDirectives.js +47 -0
  45. package/dist/compile/binds/bindStyleDirectives.js.map +1 -0
  46. package/dist/compile/binds/bindTextInterpolations.d.ts +2 -1
  47. package/dist/compile/binds/bindTextInterpolations.d.ts.map +1 -1
  48. package/dist/compile/binds/bindTextInterpolations.js +55 -17
  49. package/dist/compile/binds/bindTextInterpolations.js.map +1 -1
  50. package/dist/compile/binds/directiveRegistry.js.map +1 -1
  51. package/dist/compile/binds/forwardedAttrs.js.map +1 -1
  52. package/dist/compile/binds/propNames.d.ts +14 -0
  53. package/dist/compile/binds/propNames.d.ts.map +1 -0
  54. package/dist/compile/binds/propNames.js +116 -0
  55. package/dist/compile/binds/propNames.js.map +1 -0
  56. package/dist/compile/compileExpression.js.map +1 -1
  57. package/dist/compile/compileNodes.d.ts.map +1 -1
  58. package/dist/compile/compileNodes.js +6 -3
  59. package/dist/compile/compileNodes.js.map +1 -1
  60. package/dist/compile/compileTemplate.d.ts +3 -4
  61. package/dist/compile/compileTemplate.d.ts.map +1 -1
  62. package/dist/compile/compileTemplate.js +28 -31
  63. package/dist/compile/compileTemplate.js.map +1 -1
  64. package/dist/compile/componentResult.js.map +1 -1
  65. package/dist/compile/contentProjection.d.ts +1 -1
  66. package/dist/compile/contentProjection.d.ts.map +1 -1
  67. package/dist/compile/contentProjection.js +32 -15
  68. package/dist/compile/contentProjection.js.map +1 -1
  69. package/dist/compile/forLoops/bindForLoops.d.ts +2 -2
  70. package/dist/compile/forLoops/bindForLoops.d.ts.map +1 -1
  71. package/dist/compile/forLoops/bindForLoops.js +9 -22
  72. package/dist/compile/forLoops/bindForLoops.js.map +1 -1
  73. package/dist/compile/forLoops/createLoopManager.d.ts +3 -3
  74. package/dist/compile/forLoops/createLoopManager.d.ts.map +1 -1
  75. package/dist/compile/forLoops/createLoopManager.js +40 -38
  76. package/dist/compile/forLoops/createLoopManager.js.map +1 -1
  77. package/dist/compile/forLoops/index.d.ts +5 -5
  78. package/dist/compile/forLoops/index.js +5 -5
  79. package/dist/compile/forLoops/index.js.map +1 -1
  80. package/dist/compile/forLoops/loopHelpers.d.ts +6 -0
  81. package/dist/compile/forLoops/loopHelpers.d.ts.map +1 -1
  82. package/dist/compile/forLoops/loopHelpers.js +17 -0
  83. package/dist/compile/forLoops/loopHelpers.js.map +1 -1
  84. package/dist/compile/forLoops/loopSignals.js +2 -2
  85. package/dist/compile/forLoops/loopSignals.js.map +1 -1
  86. package/dist/compile/forLoops/loopTraversal.js +2 -2
  87. package/dist/compile/forLoops/loopTraversal.js.map +1 -1
  88. package/dist/compile/handleConditionalChain.d.ts +2 -2
  89. package/dist/compile/handleConditionalChain.d.ts.map +1 -1
  90. package/dist/compile/handleConditionalChain.js +22 -87
  91. package/dist/compile/handleConditionalChain.js.map +1 -1
  92. package/dist/compile/index.d.ts +17 -17
  93. package/dist/compile/index.js +14 -14
  94. package/dist/compile/index.js.map +1 -1
  95. package/dist/compile/injectScopedStyle.js.map +1 -1
  96. package/dist/compile/nodeExpando.d.ts +6 -0
  97. package/dist/compile/nodeExpando.d.ts.map +1 -1
  98. package/dist/compile/nodeExpando.js.map +1 -1
  99. package/dist/compile/parseHtml.d.ts.map +1 -1
  100. package/dist/compile/parseHtml.js +2 -2
  101. package/dist/compile/parseHtml.js.map +1 -1
  102. package/dist/compile/pithyTreeToDom.js +1 -1
  103. package/dist/compile/pithyTreeToDom.js.map +1 -1
  104. package/dist/compile/renderBranch.d.ts +13 -0
  105. package/dist/compile/renderBranch.d.ts.map +1 -0
  106. package/dist/compile/renderBranch.js +65 -0
  107. package/dist/compile/renderBranch.js.map +1 -0
  108. package/dist/compile/renderChildren.d.ts +2 -2
  109. package/dist/compile/renderChildren.js +2 -2
  110. package/dist/compile/renderChildren.js.map +1 -1
  111. package/dist/compile/ssrCrashes.d.ts +1 -1
  112. package/dist/compile/ssrCrashes.js +3 -3
  113. package/dist/compile/ssrCrashes.js.map +1 -1
  114. package/dist/compile/ssrMode.js +1 -1
  115. package/dist/compile/ssrMode.js.map +1 -1
  116. package/dist/compile/textValue.js.map +1 -1
  117. package/dist/compile/trimBlankEdges.d.ts +2 -0
  118. package/dist/compile/trimBlankEdges.d.ts.map +1 -0
  119. package/dist/compile/trimBlankEdges.js +15 -0
  120. package/dist/compile/trimBlankEdges.js.map +1 -0
  121. package/dist/config/index.js.map +1 -1
  122. package/dist/index.d.ts +6 -6
  123. package/dist/index.js +6 -6
  124. package/dist/index.js.map +1 -1
  125. package/dist/interfaces/index.d.ts +2 -2
  126. package/dist/interfaces/index.js +2 -2
  127. package/dist/interfaces/index.js.map +1 -1
  128. package/dist/interfaces/ref-signal.interface.js.map +1 -1
  129. package/dist/interfaces/ref.interface.js.map +1 -1
  130. package/dist/runtime/applyBindings.d.ts +3 -3
  131. package/dist/runtime/applyBindings.d.ts.map +1 -1
  132. package/dist/runtime/applyBindings.js +74 -22
  133. package/dist/runtime/applyBindings.js.map +1 -1
  134. package/dist/runtime/bindings/applyComponent.d.ts +2 -2
  135. package/dist/runtime/bindings/applyComponent.d.ts.map +1 -1
  136. package/dist/runtime/bindings/applyComponent.js +41 -32
  137. package/dist/runtime/bindings/applyComponent.js.map +1 -1
  138. package/dist/runtime/bindings/applyDefer.d.ts +1 -1
  139. package/dist/runtime/bindings/applyDefer.js +6 -6
  140. package/dist/runtime/bindings/applyDefer.js.map +1 -1
  141. package/dist/runtime/bindings/applySimple.d.ts +1 -1
  142. package/dist/runtime/bindings/applySimple.d.ts.map +1 -1
  143. package/dist/runtime/bindings/applySimple.js +45 -13
  144. package/dist/runtime/bindings/applySimple.js.map +1 -1
  145. package/dist/runtime/bindings/applyStructural.d.ts +1 -1
  146. package/dist/runtime/bindings/applyStructural.d.ts.map +1 -1
  147. package/dist/runtime/bindings/applyStructural.js +58 -68
  148. package/dist/runtime/bindings/applyStructural.js.map +1 -1
  149. package/dist/runtime/bindings/helpers.d.ts +1 -1
  150. package/dist/runtime/bindings/helpers.js +1 -1
  151. package/dist/runtime/bindings/helpers.js.map +1 -1
  152. package/dist/runtime/bindings/index.d.ts +6 -6
  153. package/dist/runtime/bindings/index.d.ts.map +1 -1
  154. package/dist/runtime/bindings/index.js +5 -5
  155. package/dist/runtime/bindings/index.js.map +1 -1
  156. package/dist/runtime/bindings/types.js.map +1 -1
  157. package/dist/runtime/bootstrap.d.ts +1 -1
  158. package/dist/runtime/bootstrap.js +1 -1
  159. package/dist/runtime/bootstrap.js.map +1 -1
  160. package/dist/runtime/createContextProxy.js.map +1 -1
  161. package/dist/runtime/deferHelpers.d.ts +1 -1
  162. package/dist/runtime/deferHelpers.js.map +1 -1
  163. package/dist/runtime/html.d.ts.map +1 -1
  164. package/dist/runtime/html.js +6 -5
  165. package/dist/runtime/html.js.map +1 -1
  166. package/dist/runtime/index.d.ts +6 -6
  167. package/dist/runtime/index.js +6 -6
  168. package/dist/runtime/index.js.map +1 -1
  169. package/dist/runtime/lazy.js +1 -1
  170. package/dist/runtime/lazy.js.map +1 -1
  171. package/dist/runtime/module-cache.js.map +1 -1
  172. package/dist/runtime/onDestroy.d.ts +7 -0
  173. package/dist/runtime/onDestroy.d.ts.map +1 -1
  174. package/dist/runtime/onDestroy.js +16 -1
  175. package/dist/runtime/onDestroy.js.map +1 -1
  176. package/dist/runtime/parseIdentifiersFromTemplate.js +1 -1
  177. package/dist/runtime/parseIdentifiersFromTemplate.js.map +1 -1
  178. package/dist/runtime/resource/createAction.d.ts +1 -1
  179. package/dist/runtime/resource/createAction.js +1 -1
  180. package/dist/runtime/resource/createAction.js.map +1 -1
  181. package/dist/runtime/resource/createResource.d.ts +1 -1
  182. package/dist/runtime/resource/createResource.d.ts.map +1 -1
  183. package/dist/runtime/resource/createResource.js +3 -4
  184. package/dist/runtime/resource/createResource.js.map +1 -1
  185. package/dist/runtime/resource/engine.d.ts +1 -1
  186. package/dist/runtime/resource/engine.js.map +1 -1
  187. package/dist/runtime/resource/index.d.ts +3 -3
  188. package/dist/runtime/resource/index.js +2 -2
  189. package/dist/runtime/resource/index.js.map +1 -1
  190. package/dist/runtime/resource/types.js.map +1 -1
  191. package/dist/types/globals.d.ts +2 -2
  192. package/dist/types/globals.js.map +1 -1
  193. package/dist/types/index.js.map +1 -1
  194. package/dist/utilities/index.d.ts +2 -2
  195. package/dist/utilities/index.js +2 -2
  196. package/dist/utilities/index.js.map +1 -1
  197. package/dist/utilities/ref-signal.utility.d.ts +1 -1
  198. package/dist/utilities/ref-signal.utility.js.map +1 -1
  199. package/dist/utilities/ref.untility.d.ts +1 -1
  200. package/dist/utilities/ref.untility.js.map +1 -1
  201. package/package.json +11 -6
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/runtime/bindings/types.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,4EAA4E;AAC5E,mFAAmF"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/runtime/bindings/types.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,4EAA4E;AAC5E,mFAAmF","sourcesContent":["// ─── Descriptor types (mirror codegen output) ────────────────────────────────\n// These describe the shape of the compact binding arrays emitted by the AOT\n// codegen in generateBindings.ts. Handlers narrow inside via the `t` discriminant.\n\nexport type BindingContext = Record<string, unknown>;\n\nexport interface FactoryResult {\n el?: HTMLElement | DocumentFragment;\n destroy?: () => void;\n}\n\nexport type Factory = (ctx: BindingContext) => FactoryResult | null | undefined;\n\n/** @codexApi {\"parent\":\"pithy.runtime.compile-nodes\",\"name\":\"ChildFactory\",\"stability\":\"experimental\",\"signature\":\"type ChildFactory = (ctx: BindingContext, wrap?: (nodes: DocumentFragment) => DocumentFragment) => { el: DocumentFragment; destroy: () => void }\"} */\nexport type ChildFactory = (\n ctx: BindingContext,\n wrap?: (nodes: DocumentFragment) => DocumentFragment\n) => { el: DocumentFragment; destroy: () => void };\n\nexport interface EventDesc {\n t: 'event';\n pid: string;\n event: string;\n expr: string;\n mods?: string[];\n}\nexport interface InterpDesc {\n t: 'interp';\n pid: string;\n parts: ({ s: string } | { e: string })[];\n}\nexport interface ClassDesc {\n t: 'class';\n pid: string;\n name: string;\n expr: string;\n}\nexport interface ClassesDesc {\n t: 'classes';\n pid: string;\n expr: string;\n}\nexport interface StyleDesc {\n t: 'style';\n pid: string;\n prop: string;\n expr: string;\n}\nexport interface BoundDesc {\n t: 'bound';\n pid: string;\n attr: string;\n expr: string;\n}\nexport interface RefDesc {\n t: 'ref';\n pid: string;\n name: string;\n}\nexport interface BindDesc {\n t: 'bind';\n pid: string;\n expr: string;\n}\nexport interface CompDesc {\n t: 'comp';\n pid: string;\n tag: string;\n props: Record<string, string>;\n children?: ChildFactory;\n}\nexport interface DeferDesc {\n t: 'defer';\n pid: string;\n trigger: string;\n load: string;\n placeholder?: string;\n when?: string;\n priority?: string;\n timeout?: number;\n}\nexport interface ErrorDesc {\n t: 'error';\n pid: string;\n expr: string;\n}\nexport interface ProjDesc {\n t: 'proj';\n pid: string;\n name: string;\n fallback?: Factory;\n}\nexport interface IfDesc {\n t: 'if';\n pid: string;\n branches: { expr?: string; factory: Factory }[];\n}\nexport interface ForDesc {\n t: 'for';\n pid: string;\n item: string;\n index?: string;\n expr: string;\n trackBy?: string;\n factory: Factory;\n}\nexport interface SwitchDesc {\n t: 'switch';\n pid: string;\n expr: string;\n cases: { val?: string; factory: Factory }[];\n}\n\nexport type Desc =\n | EventDesc\n | InterpDesc\n | ClassDesc\n | ClassesDesc\n | StyleDesc\n | BoundDesc\n | RefDesc\n | BindDesc\n | CompDesc\n | DeferDesc\n | ErrorDesc\n | ProjDesc\n | IfDesc\n | ForDesc\n | SwitchDesc;\n"]}
@@ -17,7 +17,7 @@
17
17
  * For SSR hydration, use `bootstrap` from `@pithyjs/ssr/client` instead —
18
18
  * it wraps this function and adds hydration detection.
19
19
  */
20
- import type { Component } from '../types';
20
+ import type { Component } from '../types/index.js';
21
21
  import type { PithyConfig, RouteNode, RouterFactory } from '@pithyjs/shared';
22
22
  export interface BootstrapOptions {
23
23
  /** The root App component */
@@ -50,7 +50,7 @@ export async function bootstrap(options) {
50
50
  // parse5 must be loaded before any component renders.
51
51
  // In production builds this block is dead-code-eliminated (import.meta.env.DEV → false).
52
52
  if (import.meta.env?.DEV) {
53
- const { loadJITCompiler } = await import('../compile/parseHtml');
53
+ const { loadJITCompiler } = await import('../compile/parseHtml.js');
54
54
  await loadJITCompiler();
55
55
  }
56
56
  // 2. Initialize design system
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../../src/runtime/bootstrap.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAiBF,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAsB1D,gFAAgF;AAChF,iBAAiB;AACjB,gFAAgF;AAEhF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wJAAwJ;AACxJ,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,OAAyB;IACvD,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAExC,6EAA6E;IAC7E,+EAA+E;IAC/E,8EAA8E;IAC9E,iFAAiF;IACjF,oCAAoC;IACpC,IAAI,OAAO,OAAO,CAAC,YAAY,KAAK,UAAU,EAAE,CAAC;Q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AC,sBAAsB,CAAC,CAAC;QACjE,MAAM,eAAe,EAAE,CAAC;IAC1B,CAAC;IAED,8BAA8B;IAC9B,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;QACxB,gBAAgB,CACd,MAAM,CAAC,YAAsD,CAC9D,CAAC;IACJ,CAAC;IAED,kEAAkE;IAClE,oEAAoE;IACpE,IAAI,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;QAC5B,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;QAClE,MAAM,MAAM,GAAG,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;YAC1D,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM;YACxB,CAAC,CAAC,UAAU,CAAC;QACf,QAAQ,CAAC,eAAe,CAAC,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;IACjE,CAAC;IAED,4DAA4D;IAC5D,qCAAqC;IACrC,MAAM,GAAG,GAAG,GAAG,EAAE,CAAC;IAClB,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAE3B,8DAA8D;IAC9D,sDAAsD;IACtD,mEAAmE;IACnE,0EAA0E;IAC1E,4EAA4E;IAC5E,MAAM,MAAM,GAAG,OAAO,CAAC,YAAY,CACjC,MAAM,EACN,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,CAA4B,CACjD,CAAC;IAEF,2DAA2D;IAC3D,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AACvB,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.runtime.bootstrap\",\n \"title\": \"App Bootstrap (Fresh Mount)\",\n \"category\": \"runtime\"\n}\n*/\n\n/**\n * @pithyjs/core - Fresh-mount Bootstrap\n *\n * Handles the standard app startup sequence for non-SSR apps:\n * 1. Initialize design system (if configured)\n * 2. Render App component and mount to DOM\n * 3. Create router (after App succeeds to avoid leaking listeners)\n * 4. Mount router (finds outlet, enables navigation)\n *\n * For SSR hydration, use `bootstrap` from `@pithyjs/ssr/client` instead —\n * it wraps this function and adds hydration detection.\n */\n\nimport type { Component } from '../types';\nimport type { PithyConfig, RouteNode, RouterFactory } from '@pithyjs/shared';\nimport { initDesignSystem } from '@pithyjs/design-system';\n\n// =============================================================================\n// Types\n// =============================================================================\n\nexport interface BootstrapOptions {\n /** The root App component */\n App: Component;\n /** Route tree (from virtual:pithy/routes.gen) */\n routes: RouteNode[];\n /** App configuration (from pithy.config.ts) */\n config: PithyConfig;\n /**\n * Router factory — pass `createRouter` from `@pithyjs/router`.\n *\n * Injected rather than imported so core never depends on the router\n * package, breaking the core ↔ router circular dependency.\n */\n createRouter: RouterFactory;\n}\n\n// =============================================================================\n// Implementation\n// =============================================================================\n\n/**\n * Bootstrap a PithyJS app with fresh mount (no hydration).\n *\n * In dev mode, automatically loads the JIT compiler (parse5) for runtime\n * `html\\`\\`` templates. In production, JIT is not loaded — templates must\n * be AOT-compiled. If your production app uses runtime `html()` templates,\n * call `loadJITCompiler()` from `@pithyjs/core/compile/parseHtml` before\n * calling `bootstrap()`.\n *\n * @example\n * ```ts\n * import { bootstrap } from '@pithyjs/core';\n * import { createRouter } from '@pithyjs/router';\n * import config from '../pithy.config';\n * import { routes } from 'virtual:pithy/routes.gen';\n * import App from './App';\n *\n * await bootstrap({ App, routes, config, createRouter });\n * ```\n */\n/** @codexApi {\"parent\":\"pithy.runtime.bootstrap\",\"name\":\"bootstrap\",\"stability\":\"stable\",\"signature\":\"(options: BootstrapOptions) => Promise<void>\"} */\nexport async function bootstrap(options: BootstrapOptions): Promise<void> {\n const { App, routes, config } = options;\n\n // 0. Validate preconditions before any side effects (fail fast — don't leave\n // a partially-mounted app if an untyped/JS caller omits a required option).\n // `createRouter` is required by TS, but a JS caller could omit it; surface\n // a clear, actionable error here rather than \"createRouter is not a function\"\n // after App has already mounted.\n if (typeof options.createRouter !== 'function') {\n throw new Error(\n \"[pithy] bootstrap() requires a 'createRouter' option — pass `createRouter` from '@pithyjs/router'.\"\n );\n }\n\n const appId = config.appId ?? 'app';\n const target = document.getElementById(appId);\n if (!target) {\n throw new Error(`[pithy] Container element #${appId} not found`);\n }\n\n // 1. In dev mode, templates use JIT compilation (parse5 in the browser via Vite).\n // AOT is disabled in dev (`aot: false` when config.command !== \"build\"), so\n // parse5 must be loaded before any component renders.\n // In production builds this block is dead-code-eliminated (import.meta.env.DEV → false).\n if (import.meta.env?.DEV) {\n const { loadJITCompiler } = await import('../compile/parseHtml');\n await loadJITCompiler();\n }\n\n // 2. Initialize design system\n if (config.designSystem) {\n initDesignSystem(\n config.designSystem as Parameters<typeof initDesignSystem>[0]\n );\n }\n\n // 3. Apply entrance animation preset (before App mount — sections\n // read data-entrance during observeEntrance() at component init)\n if (config.entrance?.preset) {\n const validPresets = ['none', 'subtle', 'standard', 'expressive'];\n const preset = validPresets.includes(config.entrance.preset)\n ? config.entrance.preset\n : 'standard';\n document.documentElement.setAttribute('data-entrance', preset);\n }\n\n // 4. Mount App component (before router so if App() throws,\n // no router listeners are leaked)\n const app = App();\n target.appendChild(app.el);\n\n // 5. Create router (after App succeeds — constructor installs\n // global history listeners and link interceptors).\n // The factory is injected via options (pass `createRouter` from\n // @pithyjs/router) so core never imports the router package — breaking\n // the core ↔ router circular dependency. (Presence validated at step 0.)\n const router = options.createRouter(\n routes,\n (config.router ?? {}) as Record<string, unknown>\n );\n\n // 6. Mount router (finds outlet, sets global, handles HMR)\n router.mount(target);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"createContextProxy.js","sourceRoot":"","sources":["../../src/runtime/createContextProxy.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,iFAAiF;AACjF,mLAAmL;AACnL,MAAM,UAAU,kBAAkB,CAChC,QAAmC;IAEnC,OAAO,IAAI,KAAK,CACd,EAAE,EACF;QACE,GAAG,CAAC,CAAC,EAAE,GAAoB;YACzB,KAAK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IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;oBACnD,OAAO,MAAM,CAAC,wBAAwB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;gBACnD,CAAC;YACH,CAAC;YACD,OAAO,SAAS,CAAC;QACnB,CAAC;KACF,CACF,CAAC;AACJ,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.runtime.context\",\n \"title\": \"Context Proxy System\",\n \"category\": \"runtime\"\n}\n*/\n\n// Wraps local variables, props, signals, and functions into one unified context.\n/** @codexApi {\"parent\":\"pithy.runtime.context\",\"name\":\"createContextProxy\",\"stability\":\"stable\",\"signature\":\"(contexts: Record<string, unknown>[]) => Record<string, unknown>\"} */\nexport function createContextProxy(\n contexts: Record<string, unknown>[]\n): Record<string, unknown> {\n return new Proxy(\n {},\n {\n get(_, key: string | symbol) {\n for (const ctx of contexts) {\n if (key in ctx) {\n return ctx[key as keyof typeof ctx];\n }\n }\n\n if (import.meta.env?.DEV) {\n if (typeof key !== 'symbol') {\n console.warn(`[pithy] Context key not found: ${key}`);\n }\n }\n\n return undefined;\n },\n has(_, key: string) {\n return contexts.some(ctx => key in ctx);\n },\n\n ownKeys(_) {\n const allKeys = new Set<string | symbol>();\n\n for (const ctx of contexts) {\n Reflect.ownKeys(ctx).forEach(key => allKeys.add(key));\n }\n\n return Array.from(allKeys);\n },\n\n getOwnPropertyDescriptor(_, key) {\n for (const ctx of contexts) {\n if (Object.prototype.hasOwnProperty.call(ctx, key)) {\n return Object.getOwnPropertyDescriptor(ctx, key);\n }\n }\n return undefined;\n },\n }\n );\n}\n"]}
@@ -14,7 +14,7 @@
14
14
  * @module runtime/deferHelpers
15
15
  */
16
16
  import type { LoadingPriority } from '@pithyjs/compiler';
17
- import type { LazyHandle } from './lazy';
17
+ import type { LazyHandle } from './lazy.js';
18
18
  /**
19
19
  * Load a lazy handle with timeout support.
20
20
  * Rejects with a timeout error if loading exceeds the given duration.
@@ -1 +1 @@
1
- {"version":3,"file":"deferHelpers.js","sourceRoot":"","sources":["../../src/runtime/deferHelpers.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAcF;;;;;;;GAOG;AACH,mLAAmL;AACnL,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,MAAqB,EACrB,SAAiB;IAEjB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE;YAChC,MAAM,CAAC,MAAM,EAAE,CAAC;YAChB,MAAM,CAAC,IAAI,KAAK,CAAC,6BAA6B,SAAS,IAAI,CAAC,CAAC,CAAC;QAChE,CAAC,EAAE,SAAS,CAAC,CAAC;QAEd,MAAM;aACH,IAAI,EAAE;aACN,IAAI,CAAC,MAAM,CAAC,EAAE;YACb,YAAY,CAAC,SAAS,CAAC,CAAC;YACxB,OAAO,CAAC,MAAM,CAAC,CAAC;QAClB,CAAC,CAAC;aACD,KAAK,CAAC,GAAG,CAAC,EAAE;YACX,YAAY,CAAC,SAAS,CAAC,CAAC;YACxB,MAAM,CAAC,GAAG,CAAC,CAAC;QACd,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,yMAAyM;AACzM,MAAM,UAAU,kBAAkB,CAChC,QAAoB,EACpB,QAAqC;IAErC,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;QACxB,QAAQ,EAAE,CAAC;QACX,OAAO;IACT,CAAC;IACD,IAAI,QAAQ,KAAK,KAAK,IAAI,OAAO,mBAAmB,KAAK,WAAW,EAAE,CAAC;QACrE,OAAO,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC;IACD,cAAc,CAAC,QAAQ,CAAC,CAAC;AAC3B,CAAC"}
1
+ {"version":3,"file":"deferHelpers.js","sourceRoot":"","sources":["../../src/runtime/deferHelpers.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAcF;;;;;;;GAOG;AACH,mLAAmL;AACnL,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,MAAqB,EACrB,SAAiB;IAEjB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE;YAChC,MAAM,CAAC,MAAM,EAAE,CAAC;YAChB,MAAM,CAAC,IAAI,KAAK,CAAC,6BAA6B,SAAS,IAAI,CAAC,CAAC,CAAC;QAChE,CAAC,EAAE,SAAS,CAAC,CAAC;QAEd,MAAM;aACH,IAAI,EAAE;aACN,IAAI,CAAC,MAAM,CAAC,EAAE;YACb,YAAY,CAAC,SAAS,CAAC,CAAC;YACxB,OAAO,CAAC,MAAM,CAAC,CAAC;QAClB,CAAC,CAAC;aACD,KAAK,CAAC,GAAG,CAAC,EAAE;YACX,YAAY,CAAC,SAAS,CAAC,CAAC;YACxB,MAAM,CAAC,GAAG,CAAC,CAAC;QACd,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,yMAAyM;AACzM,MAAM,UAAU,kBAAkB,CAChC,QAAoB,EACpB,QAAqC;IAErC,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;QACxB,QAAQ,EAAE,CAAC;QACX,OAAO;IACT,CAAC;IACD,IAAI,QAAQ,KAAK,KAAK,IAAI,OAAO,mBAAmB,KAAK,WAAW,EAAE,CAAC;QACrE,OAAO,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC;IACD,cAAc,CAAC,QAAQ,CAAC,CAAC;AAC3B,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.runtime.defer-helpers\",\n \"title\": \"Shared Defer Loading Helpers\",\n \"category\": \"runtime\"\n}\n*/\n\n/**\n * Shared helpers for lazy-loading defer directives.\n *\n * Used by both the JIT path (`bindDeferDirectives.ts`) and the AOT path\n * (`bindings/applyDefer.ts`) to avoid duplicating timeout and scheduling logic.\n *\n * @module runtime/deferHelpers\n */\n\nimport type { LoadingPriority } from '@pithyjs/compiler';\nimport type { LazyHandle } from './lazy';\n\n/**\n * Load a lazy handle with timeout support.\n * Rejects with a timeout error if loading exceeds the given duration.\n *\n * @param handle - The lazy handle to load\n * @param timeoutMs - Maximum time in milliseconds before timeout\n * @returns Promise resolving to the loaded module\n */\n/** @codexApi {\"parent\":\"pithy.runtime.defer-helpers\",\"name\":\"loadWithTimeout\",\"stability\":\"internal\",\"signature\":\"<T>(handle: LazyHandle<T>, timeoutMs: number) => Promise<T>\"} */\nexport async function loadWithTimeout<T>(\n handle: LazyHandle<T>,\n timeoutMs: number\n): Promise<T> {\n return new Promise((resolve, reject) => {\n const timeoutId = setTimeout(() => {\n handle.cancel();\n reject(new Error(`Lazy load timed out after ${timeoutMs}ms`));\n }, timeoutMs);\n\n handle\n .load()\n .then(result => {\n clearTimeout(timeoutId);\n resolve(result);\n })\n .catch(err => {\n clearTimeout(timeoutId);\n reject(err);\n });\n });\n}\n\n/**\n * Schedule a callback based on loading priority.\n *\n * - `\"high\"`: Execute synchronously (immediate)\n * - `\"low\"`: `requestIdleCallback` (fires when browser is idle)\n * - default (`undefined`): `queueMicrotask` (reliable, async enough for DOM settling)\n *\n * Deferring by default is critical: `bindDeferDirectives` runs BEFORE\n * `bindComponentTags.replaceWith()` moves the element into the real DOM.\n * Synchronous mount would capture a stale `parentNode` (the compilation fragment).\n *\n * NOTE: `requestIdleCallback` without a timeout can be starved indefinitely when\n * the page is busy (HMR, long-running tasks). Default priority uses\n * `queueMicrotask` which reliably fires after the current synchronous execution.\n *\n * @param callback - Function to execute\n * @param priority - Loading priority level\n * @returns Idle callback ID (if `\"low\"` priority), or `undefined`\n */\n/** @codexApi {\"parent\":\"pithy.runtime.defer-helpers\",\"name\":\"scheduleByPriority\",\"stability\":\"internal\",\"signature\":\"(callback: () => void, priority: LoadingPriority | undefined) => number | void\"} */\nexport function scheduleByPriority(\n callback: () => void,\n priority: LoadingPriority | undefined\n): number | void {\n if (priority === 'high') {\n callback();\n return;\n }\n if (priority === 'low' && typeof requestIdleCallback !== 'undefined') {\n return requestIdleCallback(callback);\n }\n queueMicrotask(callback);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../src/runtime/html.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAQF;;;;;;;;;GASG;AACH,wRAAwR;AACxR,wBAAgB,IAAI,CAClB,QAAQ,EAAE,oBAAoB,GAAG,MAAM,EACvC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,EAC/C,kBAAkB,CAAC,EAAE,MAAM,GAC1B;IAAE,EAAE,EAAE,WAAW,GAAG,gBAAgB,CAAC;IAAC,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,CAwF7D"}
1
+ {"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../src/runtime/html.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAQF;;;;;;;;;GASG;AACH,wRAAwR;AACxR,wBAAgB,IAAI,CAClB,QAAQ,EAAE,oBAAoB,GAAG,MAAM,EACvC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,EAC/C,kBAAkB,CAAC,EAAE,MAAM,GAC1B;IAAE,EAAE,EAAE,WAAW,GAAG,gBAAgB,CAAC;IAAC,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,CAyF7D"}
@@ -5,11 +5,11 @@
5
5
  "category": "runtime"
6
6
  }
7
7
  */
8
- import { compileTemplate } from '../compile/compileTemplate';
9
- import { createContextProxy } from './createContextProxy';
10
- import { parseIdentifiersFromTemplate } from './parseIdentifiersFromTemplate';
11
- import { mergeContexts } from './bindings/helpers';
12
- import { drainDestroyCallbacks } from './onDestroy';
8
+ import { compileTemplate } from '../compile/compileTemplate.js';
9
+ import { createContextProxy } from './createContextProxy.js';
10
+ import { parseIdentifiersFromTemplate } from './parseIdentifiersFromTemplate.js';
11
+ import { mergeContexts } from './bindings/helpers.js';
12
+ import { drainDestroyCallbacks } from './onDestroy.js';
13
13
  /**
14
14
  * Tagged template function for creating reactive DOM from HTML strings.
15
15
  * Parses the template, binds reactive directives, and returns a live DOM fragment.
@@ -91,6 +91,7 @@ export function html(template, contextOrCss, cssIfContextPassed) {
91
91
  /* ignore disposal errors */
92
92
  }
93
93
  }
94
+ destroyCallbacks.length = 0;
94
95
  },
95
96
  };
96
97
  }
@@ -1 +1 @@
1
- {"version":3,"file":"html.js","sourceRoot":"","sources":["../../src/runtime/html.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEpD;;;;;;;;;GASG;AACH,wRAAwR;AACxR,MAAM,UAAU,IAAI,CAClB,QAAuC,EACvC,YAA+C,EAC/C,kBAA2B;IAE3B,wEAAwE;IACxE,gFAAgF;IAChF,MAAM,gBAAgB,GAAG,qBAAqB,EAAE,CAAC;IAEjD,MAAM,OAAO,GACX,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAEjE,IAAI,OAAO,GAA4B,EAAE,CAAC;IAC1C,IAAI,GAAuB,CAAC;IAE5B,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE,CAAC;QACrC,OAAO,GAAG,YAAY,CAAC;QACvB,GAAG,GAAG,kBAAkB,CAAC;IAC3B,CAAC;SAAM,IAAI,OAAO,YAAY,KAAK,QAA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AAwE;QACxE,6DAA6D;QAC7D,KAAK,IAAI,CAAC,GAAG,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YACtD,IAAI,CAAC;gBACH,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC;YACxB,CAAC;YAAC,MAAM,CAAC;gBACP,YAAY;YACd,CAAC;QACH,CAAC;QACD,MAAM,GAAG,CAAC;IACZ,CAAC;IAED,uDAAuD;IACvD,IAAI,gBAAgB,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,MAAM,CAAC;IAEjD,OAAO;QACL,EAAE,EAAE,MAAM,CAAC,EAAE;QACb,OAAO;YACL,IAAI,CAAC;gBACH,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,CAAC;YAAC,MAAM,CAAC;gBACP,4BAA4B;YAC9B,CAAC;YACD,0CAA0C;YAC1C,KAAK,IAAI,CAAC,GAAG,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;gBACtD,IAAI,CAAC;oBACH,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC;gBACxB,CAAC;gBAAC,MAAM,CAAC;oBACP,4BAA4B;gBAC9B,CAAC;YACH,CAAC;YACD,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC;QAC9B,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.runtime.html\",\n \"title\": \"HTML Template Helper\",\n \"category\": \"runtime\"\n}\n*/\n\nimport { compileTemplate } from '../compile/compileTemplate';\nimport { createContextProxy } from './createContextProxy';\nimport { parseIdentifiersFromTemplate } from './parseIdentifiersFromTemplate';\nimport { mergeContexts } from './bindings/helpers';\nimport { drainDestroyCallbacks } from './onDestroy';\n\n/**\n * Tagged template function for creating reactive DOM from HTML strings.\n * Parses the template, binds reactive directives, and returns a live DOM fragment.\n * Requires `loadJITCompiler()` to be called first (to load parse5 dynamically).\n *\n * @param template - Template literal or raw HTML string\n * @param contextOrCss - Reactive context object or CSS string\n * @param cssIfContextPassed - CSS string when context is the second argument\n * @returns Object with `el` (live DOM) and `destroy` (cleanup function)\n */\n/** @codexApi {\"parent\":\"pithy.runtime.html\",\"name\":\"html\",\"stability\":\"stable\",\"signature\":\"(template: TemplateStringsArray | string, contextOrCss?: Record<string, unknown> | string, cssIfContextPassed?: string) => { el: HTMLElement | DocumentFragment; destroy: () => void }\"} */\nexport function html(\n template: TemplateStringsArray | string,\n contextOrCss?: Record<string, unknown> | string,\n cssIfContextPassed?: string\n): { el: HTMLElement | DocumentFragment; destroy: () => void } {\n // Drain onDestroy() callbacks BEFORE compileTemplate — child components\n // instantiated during compilation will drain their own callbacks independently.\n const destroyCallbacks = drainDestroyCallbacks();\n\n const rawHtml =\n typeof template === 'string' ? template : String.raw(template);\n\n let context: Record<string, unknown> = {};\n let css: string | undefined;\n\n if (typeof contextOrCss === 'object') {\n context = contextOrCss;\n css = cssIfContextPassed;\n } else if (typeof contextOrCss === 'string') {\n css = contextOrCss;\n }\n\n // Merge with component context if available (for content projection and\n // nested component resolution). Uses the shared mergeContexts helper\n // (single source of truth with applyBindings.ts).\n context = mergeContexts(context);\n\n // Dev fallback\n if (import.meta.env?.DEV && Object.keys(context).length === 0) {\n const identifiers = parseIdentifiersFromTemplate(rawHtml);\n identifiers.forEach(name => {\n context[name] = undefined;\n console.warn(\n `[PithyJS html()] Dev fallback: '${name}' will be undefined unless injected by plugin.`\n );\n });\n }\n\n // Extract imported identifiers from context if provided by Babel plugin\n const importedIdentifiers = context.__importedIdentifiers as\n | Set<string>\n | undefined;\n\n // Remove the special property from context before creating proxy\n const cleanContext = { ...context };\n delete cleanContext.__importedIdentifiers;\n\n const proxiedContext = createContextProxy([cleanContext]);\n\n let result: { el: HTMLElement | DocumentFragment; destroy: () => void };\n try {\n result = compileTemplate(\n rawHtml,\n proxiedContext,\n css,\n undefined,\n importedIdentifiers\n );\n } catch (err) {\n // Run drained callbacks LIFO before rethrowing so partially-initialized\n // resources (effects, event listeners) are still cleaned up.\n for (let i = destroyCallbacks.length - 1; i >= 0; i--) {\n try {\n destroyCallbacks[i]();\n } catch {\n /* ignore */\n }\n }\n throw err;\n }\n\n // Zero-overhead fast path when no onDestroy was called\n if (destroyCallbacks.length === 0) return result;\n\n return {\n el: result.el,\n destroy() {\n try {\n result.destroy();\n } catch {\n /* ignore disposal errors */\n }\n // LIFO order — last-registered runs first\n for (let i = destroyCallbacks.length - 1; i >= 0; i--) {\n try {\n destroyCallbacks[i]();\n } catch {\n /* ignore disposal errors */\n }\n }\n destroyCallbacks.length = 0;\n },\n };\n}\n"]}
@@ -1,9 +1,9 @@
1
- export { html } from './html';
2
- export { onDestroy } from './onDestroy';
3
- export { loadModule, getModuleRecord, invalidateModule, getResolvedModuleKeys, clearModuleCache, type ModuleRecord, } from './module-cache';
4
- export { lazy, isLazyHandle, preloadLazy, type LazyState, type LazyOptions, type LazyHandle, } from './lazy';
5
- export { createResource, createAction, type ResourceStatus, type ResourceFetcher, type ResourceOptions, type ResourceHandle, type ActionPerformer, type ActionOverlap, type ActionOptions, type ActionHandle, type ActionResult, } from './resource';
1
+ export { html } from './html.js';
2
+ export { onDestroy } from './onDestroy.js';
3
+ export { loadModule, getModuleRecord, invalidateModule, getResolvedModuleKeys, clearModuleCache, type ModuleRecord, } from './module-cache.js';
4
+ export { lazy, isLazyHandle, preloadLazy, type LazyState, type LazyOptions, type LazyHandle, } from './lazy.js';
5
+ export { createResource, createAction, type ResourceStatus, type ResourceFetcher, type ResourceOptions, type ResourceHandle, type ActionPerformer, type ActionOverlap, type ActionOptions, type ActionHandle, type ActionResult, } from './resource/index.js';
6
6
  export { DEFAULT_VISIBILITY_MARGIN, observeVisibilityOnce, } from '@pithyjs/shared';
7
- export { bootstrap, type BootstrapOptions } from './bootstrap';
7
+ export { bootstrap, type BootstrapOptions } from './bootstrap.js';
8
8
  export { defineConfig, type PithyConfig } from '@pithyjs/shared';
9
9
  //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,5 @@
1
- export { html } from './html';
2
- export { onDestroy } from './onDestroy';
1
+ export { html } from './html.js';
2
+ export { onDestroy } from './onDestroy.js';
3
3
  // JIT compiler loading is NOT re-exported from this barrel to prevent
4
4
  // parse5 from being pulled into production bundles via the barrel chain.
5
5
  // Use the dedicated subpath export:
@@ -9,15 +9,15 @@ export { onDestroy } from './onDestroy';
9
9
  // import { __applyBindings } from '@pithyjs/core/runtime/applyBindings'
10
10
  // Fully implemented in Phase 5 (Runtime Binder) — see applyBindings.ts.
11
11
  // Module cache (shared across router, prefetch, lazy components)
12
- export { loadModule, getModuleRecord, invalidateModule, getResolvedModuleKeys, clearModuleCache, } from './module-cache';
12
+ export { loadModule, getModuleRecord, invalidateModule, getResolvedModuleKeys, clearModuleCache, } from './module-cache.js';
13
13
  // Lazy loading
14
- export { lazy, isLazyHandle, preloadLazy, } from './lazy';
14
+ export { lazy, isLazyHandle, preloadLazy, } from './lazy.js';
15
15
  // Async state primitives (reactive query + mutation)
16
- export { createResource, createAction, } from './resource';
16
+ export { createResource, createAction, } from './resource/index.js';
17
17
  // Visibility trigger (IntersectionObserver pool) - from @pithyjs/shared
18
18
  export { DEFAULT_VISIBILITY_MARGIN, observeVisibilityOnce, } from '@pithyjs/shared';
19
19
  // App bootstrap (fresh mount, no hydration)
20
- export { bootstrap } from './bootstrap';
20
+ export { bootstrap } from './bootstrap.js';
21
21
  // App configuration (re-export from @pithyjs/shared for convenience)
22
22
  export { defineConfig } from '@pithyjs/shared';
23
23
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,sEAAsE;AACtE,yEAAyE;AACzE,oCAA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AC5C,OAAO,EAAE,SAAS,EAAyB,MAAM,aAAa,CAAC;AAE/D,qEAAqE;AACrE,OAAO,EAAE,YAAY,EAAoB,MAAM,iBAAiB,CAAC","sourcesContent":["export { html } from './html';\nexport { onDestroy } from './onDestroy';\n\n// JIT compiler loading is NOT re-exported from this barrel to prevent\n// parse5 from being pulled into production bundles via the barrel chain.\n// Use the dedicated subpath export:\n// import { loadJITCompiler } from '@pithyjs/core/compile/parseHtml'\n\n// NOTE: __applyBindings is NOT re-exported here — it's an internal API\n// consumed by AOT-generated code via direct subpath import:\n// import { __applyBindings } from '@pithyjs/core/runtime/applyBindings'\n// Fully implemented in Phase 5 (Runtime Binder) — see applyBindings.ts.\n\n// Module cache (shared across router, prefetch, lazy components)\nexport {\n loadModule,\n getModuleRecord,\n invalidateModule,\n getResolvedModuleKeys,\n clearModuleCache,\n type ModuleRecord,\n} from './module-cache';\n\n// Lazy loading\nexport {\n lazy,\n isLazyHandle,\n preloadLazy,\n type LazyState,\n type LazyOptions,\n type LazyHandle,\n} from './lazy';\n\n// Async state primitives (reactive query + mutation)\nexport {\n createResource,\n createAction,\n type ResourceStatus,\n type ResourceFetcher,\n type ResourceOptions,\n type ResourceHandle,\n type ActionPerformer,\n type ActionOverlap,\n type ActionOptions,\n type ActionHandle,\n type ActionResult,\n} from './resource';\n\n// Visibility trigger (IntersectionObserver pool) - from @pithyjs/shared\nexport {\n DEFAULT_VISIBILITY_MARGIN,\n observeVisibilityOnce,\n} from '@pithyjs/shared';\n\n// App bootstrap (fresh mount, no hydration)\nexport { bootstrap, type BootstrapOptions } from './bootstrap';\n\n// App configuration (re-export from @pithyjs/shared for convenience)\nexport { defineConfig, type PithyConfig } from '@pithyjs/shared';\n"]}
@@ -15,7 +15,7 @@
15
15
  */
16
16
  import { signal } from '@pithyjs/signals';
17
17
  import { DEFAULT_LAZY_TIMEOUT } from '@pithyjs/compiler';
18
- import { loadModule, invalidateModule, getModuleRecord } from './module-cache';
18
+ import { loadModule, invalidateModule, getModuleRecord } from './module-cache.js';
19
19
  /** Symbol used to identify LazyHandle instances (internal) */
20
20
  const LAZY_HANDLE_SYMBOL = Symbol('pithy-lazy-handle');
21
21
  /** Counter for generating unique keys when path isn't available */
@@ -1 +1 @@
1
- {"version":3,"file":"lazy.js","sourceRoot":"","sources":["../../src/runtime/lazy.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,EAAe,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAwB,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAE/E,8DAA8D;AAC9D,MAAM,kBAAkB,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC;AAsGvD,mEAAmE;AACnE,IAAI,aAAa,GAAG,CAAC,CAAC;AAEtB;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,oKAAoK;AACpK,MAAM,UAAU,IAAI,CAClB,MAAwB,EACxB,UAAuB,EAAE;IAEzB,MAAM,EACJ,GAAG,EAAE,SAAS,EACd,OAAO,EACP,SAAS,GAAG,oBAAoB,EAChC,QAAQ,GAAG,KAAK,GACjB,GAAG,OAAO,CAAC;IAEZ,8CAA8C;IAC9C,4DAA4D;IAC5D,oCAAoC;IACpC,MAAM,GAAG,GAAG,SAAS;QACnB,CAAC,CAAC,aAAa,SAAS,EAAE;QAC1B,CAAC,CAAC,kBAAkB,EAAE,aAAa,EAAE,CAAC;IAExC,+BAA+B;IAC/B,MAAM,KAAK,GAAG,MAAM,CAAY,MAAM,CAAC,CAAC;IAExC,iBAAiB;IACjB,MAAM,QAAQ,GAAoB;QAChC,MAAM,EAAE,IAAgC,EAAE,YAAY;QACtD,eAAe,EAAE,IAAI;QACrB,SAAS,EAAE,IAAI;QACf,WAAW,EAAE,IAAI;QACjB,UAAU,EAAE,CAAC;KACd,CAAC;IAE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,EAAE,IAAI;QAC1B,GAAG;QACH,IAAI;QACJ,KAAK;QACL,MAAM,EAAE,SAAS;QACjB,KAAK,EAAE,SAAS;QAChB,MAAM;QACN,KAAK;QACL,QAAQ;KACQ,CAAC;IAEnB,mCAAmC;IACnC,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC;IAEzB,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;GAMG;AACH,uJAAuJ;AACvJ,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACb,KAAiC,CAAC,kBAAkB,CAAC,KAAK,IAAI,CAChE,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,8IAA8I;AAC9I,MAAM,UAAU,WAAW,CAAI,MAAqB;IAClD,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;AACvB,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.core.lazy\",\n \"title\": \"Lazy Loading Runtime Helper\",\n \"category\": \"runtime\"\n}\n*/\n\n/**\n * Lazy Loading Runtime\n *\n * Provides the `lazy()` function for component-level lazy loading.\n * Components wrapped with lazy() are only loaded when triggered by @defer directive.\n *\n * @module runtime/lazy\n */\n\nimport { signal, type Signal } from '@pithyjs/signals';\nimport { DEFAULT_LAZY_TIMEOUT, type LoadingPriority } from '@pithyjs/compiler';\nimport { loadModule, invalidateModule, getModuleRecord } from './module-cache';\n\n/** Symbol used to identify LazyHandle instances (internal) */\nconst LAZY_HANDLE_SYMBOL = Symbol('pithy-lazy-handle');\n\n/** @codexApi {\"parent\":\"pithy.core.lazy\",\"name\":\"LazyState\",\"stability\":\"stable\",\"signature\":\"type LazyState = 'idle' | 'loading' | 'loaded' | 'error'\"} */\n/** Possible states for a lazy component */\nexport type LazyState = 'idle' | 'loading' | 'loaded' | 'error';\n\n/** @codexApi {\"parent\":\"pithy.core.lazy\",\"name\":\"LazyOptions\",\"stability\":\"stable\",\"signature\":\"interface LazyOptions\"} */\n/** Options for configuring lazy loading behavior */\nexport interface LazyOptions {\n /**\n * Custom key for this lazy component in the module cache.\n * Should start with 'lazy-' to match Vite chunk naming convention.\n *\n * @example\n * ```ts\n * // Use with Vite magic comment for chunk naming\n * const UserCard = lazy(\n * () => import(/* webpackChunkName: \"lazy-UserCard\" *\\/ './UserCard.pithy'),\n * { key: 'lazy-UserCard' }\n * );\n * ```\n */\n key?: string;\n\n /**\n * Callback invoked when loading fails.\n * Called with the error that occurred.\n */\n onError?: (error: unknown) => void;\n\n /**\n * Timeout in milliseconds before loading is considered failed.\n * @default DEFAULT_LAZY_TIMEOUT (30 seconds)\n */\n timeoutMs?: number;\n\n /**\n * Loading priority hint.\n * 'high' modules are loaded before 'low' priority modules.\n * @default 'low'\n */\n priority?: LoadingPriority;\n}\n\n/** @codexApi {\"parent\":\"pithy.core.lazy\",\"name\":\"LazyHandle\",\"stability\":\"stable\",\"signature\":\"interface LazyHandle<T>\"} */\n/** Handle returned by lazy() for controlling lazy component loading */\nexport interface LazyHandle<T> {\n /**\n * Unique key for this lazy component in the module cache.\n * Format: 'component:{path}'\n */\n readonly key: string;\n\n /**\n * Trigger the load (idempotent, returns cached promise).\n * Multiple calls return the same promise.\n */\n load: () => Promise<T>;\n\n /**\n * Current loading state as a reactive signal.\n * Subscribe to this for reactive UI updates.\n */\n state: Signal<LazyState>;\n\n /**\n * Resolved module value (undefined until loaded).\n */\n module: T | undefined;\n\n /**\n * Error if load failed (undefined otherwise).\n */\n error: Error | undefined;\n\n /**\n * Cancel an in-flight load.\n * Has no effect if already loaded or idle.\n */\n cancel: () => void;\n\n /**\n * Retry loading after an error.\n * Clears the error state and attempts to load again.\n */\n retry: () => Promise<T>;\n\n /**\n * Loading priority for this component.\n */\n readonly priority: LoadingPriority;\n}\n\n/** Internal tracking for lazy handles */\ninterface LazyInternal<T> {\n handle: LazyHandle<T>;\n abortController: AbortController | null;\n timeoutId: ReturnType<typeof setTimeout> | null;\n loadPromise: Promise<T> | null;\n retryCount: number;\n}\n\n/** Counter for generating unique keys when path isn't available */\nlet lazyIdCounter = 0;\n\n/**\n * Wrap a dynamic import for lazy loading.\n *\n * Creates a lazy handle that can be used with the @defer directive\n * to load components on-demand.\n *\n * @param loader - Function returning a dynamic import promise\n * @param options - Configuration options\n * @returns LazyHandle for controlling the lazy component\n *\n * @example\n * ```ts\n * // Basic usage\n * const UserCard = lazy(() => import('./UserCard.pithy'));\n *\n * // With options\n * const HeavyChart = lazy(() => import('./HeavyChart.pithy'), {\n * timeoutMs: 10000,\n * onError: (err) => console.error('Failed to load chart', err),\n * });\n * ```\n *\n * In template with the `@defer` directive:\n *\n * ```html\n * <div @defer=\"visible\" @load=\"UserCard\" @placeholder=\"Skeleton\"></div>\n * ```\n */\n/** @codexApi {\"parent\":\"pithy.core.lazy\",\"name\":\"lazy\",\"stability\":\"stable\",\"signature\":\"<T>(loader: () => Promise<T>, options?: LazyOptions) => LazyHandle<T>\"} */\nexport function lazy<T = unknown>(\n loader: () => Promise<T>,\n options: LazyOptions = {}\n): LazyHandle<T> {\n const {\n key: customKey,\n onError,\n timeoutMs = DEFAULT_LAZY_TIMEOUT,\n priority = 'low',\n } = options;\n\n // Generate unique key for this lazy component\n // Use custom key if provided (for predictable chunk naming)\n // Otherwise use a counter-based key\n const key = customKey\n ? `component:${customKey}`\n : `component:lazy-${++lazyIdCounter}`;\n\n // Create reactive state signal\n const state = signal<LazyState>('idle');\n\n // Internal state\n const internal: LazyInternal<T> = {\n handle: null as unknown as LazyHandle<T>, // Set below\n abortController: null,\n timeoutId: null,\n loadPromise: null,\n retryCount: 0,\n };\n\n /**\n * Cancel in-flight load\n */\n function cancel(): void {\n if (internal.abortController) {\n internal.abortController.abort();\n internal.abortController = null;\n }\n\n if (internal.timeoutId) {\n clearTimeout(internal.timeoutId);\n internal.timeoutId = null;\n }\n\n // Only reset to idle if we were loading\n if (state() === 'loading') {\n state.set('idle');\n }\n\n internal.loadPromise = null;\n }\n\n /**\n * Load the component\n */\n function load(): Promise<T> {\n // If already loaded, return cached module\n const cached = getModuleRecord<T>(key);\n if (cached?.status === 'resolved' && cached.value !== undefined) {\n internal.handle.module = cached.value;\n state.set('loaded');\n return Promise.resolve(cached.value);\n }\n\n // If already loading, return existing promise\n if (internal.loadPromise && state() === 'loading') {\n return internal.loadPromise;\n }\n\n // If there was an error, need to call retry() instead\n if (cached?.status === 'rejected') {\n return retry();\n }\n\n // Start new load\n state.set('loading');\n internal.abortController = new AbortController();\n\n // Set up timeout\n if (timeoutMs > 0) {\n internal.timeoutId = setTimeout(() => {\n const error = new Error(\n `Lazy load timeout: Component did not load within ${timeoutMs}ms`\n );\n handleError(error);\n }, timeoutMs);\n }\n\n // Create load promise\n internal.loadPromise = loadModule<T>(key, loader)\n .then(module => {\n // Clear timeout on success\n if (internal.timeoutId) {\n clearTimeout(internal.timeoutId);\n internal.timeoutId = null;\n }\n\n // Check if cancelled\n if (internal.abortController?.signal.aborted) {\n throw new Error('Load cancelled');\n }\n\n // Update handle\n internal.handle.module = module;\n internal.handle.error = undefined;\n state.set('loaded');\n\n return module;\n })\n .catch(err => {\n handleError(err);\n throw err;\n });\n\n return internal.loadPromise;\n }\n\n /**\n * Handle load error\n */\n function handleError(err: unknown): void {\n // Clear timeout\n if (internal.timeoutId) {\n clearTimeout(internal.timeoutId);\n internal.timeoutId = null;\n }\n\n // Don't update state if cancelled\n if (internal.abortController?.signal.aborted) {\n return;\n }\n\n // Update handle\n const error = err instanceof Error ? err : new Error(String(err));\n internal.handle.error = error;\n state.set('error');\n\n // Call error callback\n if (onError) {\n try {\n onError(error);\n } catch (callbackErr) {\n if (import.meta.env?.DEV) {\n console.error('[lazy] Error in onError callback:', callbackErr);\n }\n }\n }\n\n internal.loadPromise = null;\n }\n\n /**\n * Retry after error\n */\n function retry(): Promise<T> {\n // Extract URL from error message for cache busting\n // Browser caches dynamic imports, so we need to bust the cache with a new URL\n let cacheBustUrl: string | null = null;\n if (internal.handle.error) {\n const errorMsg = internal.handle.error.message || '';\n // Extract URL from \"Failed to fetch dynamically imported module: <url>\"\n const urlMatch = errorMsg.match(/module:\\s*(.+)$/);\n if (urlMatch) {\n const originalUrl = urlMatch[1].trim();\n // Add or update cache-bust parameter\n try {\n const url = new URL(originalUrl);\n url.searchParams.set('_retry', Date.now().toString());\n cacheBustUrl = url.href;\n } catch {\n // URL parsing failed, fall back to normal retry\n }\n }\n }\n\n // Clear previous error state\n internal.handle.error = undefined;\n\n // Invalidate cached error in our module cache\n invalidateModule(key);\n\n // Increment retry count\n internal.retryCount++;\n\n // Reset state\n state.set('idle');\n internal.loadPromise = null;\n\n // If we have a cache-bust URL, use it to bypass browser's import cache\n if (cacheBustUrl) {\n return loadWithCacheBust(cacheBustUrl);\n }\n\n // Fall back to normal load\n return load();\n }\n\n /**\n * Load with a cache-busted URL (for retry after failure)\n */\n function loadWithCacheBust(url: string): Promise<T> {\n // Start new load\n state.set('loading');\n internal.abortController = new AbortController();\n\n // Set up timeout\n if (timeoutMs > 0) {\n internal.timeoutId = setTimeout(() => {\n const error = new Error(\n `Lazy load timeout: Component did not load within ${timeoutMs}ms`\n );\n handleError(error);\n }, timeoutMs);\n }\n\n // Use dynamic import with cache-busted URL\n // This bypasses both our cache and the browser's import cache\n internal.loadPromise = import(/* @vite-ignore */ url)\n .then(module => {\n // Clear timeout on success\n if (internal.timeoutId) {\n clearTimeout(internal.timeoutId);\n internal.timeoutId = null;\n }\n\n // Check if cancelled\n if (internal.abortController?.signal.aborted) {\n throw new Error('Load cancelled');\n }\n\n // Update handle BEFORE setting state (effects run synchronously)\n internal.handle.module = module as T;\n internal.handle.error = undefined;\n\n // Update our module cache BEFORE setting state to 'loaded'\n // This is critical because effects run synchronously and may call load()\n // which needs to see the cached module\n loadModule(key, () => Promise.resolve(module as T));\n\n // Now set state to loaded (this triggers effects)\n state.set('loaded');\n\n return module as T;\n })\n .catch(err => {\n handleError(err);\n throw err;\n });\n\n return internal.loadPromise;\n }\n\n // Create the handle with symbol brand\n const handle = {\n [LAZY_HANDLE_SYMBOL]: true,\n key,\n load,\n state,\n module: undefined,\n error: undefined,\n cancel,\n retry,\n priority,\n } as LazyHandle<T>;\n\n // Store reference for internal use\n internal.handle = handle;\n\n return handle;\n}\n\n/**\n * Check if a value is a LazyHandle.\n * Uses Symbol-based branding for reliable type checking.\n *\n * @param value - Value to check\n * @returns True if value is a LazyHandle\n */\n/** @codexApi {\"parent\":\"pithy.core.lazy\",\"name\":\"isLazyHandle\",\"stability\":\"stable\",\"signature\":\"(value: unknown) => value is LazyHandle<unknown>\"} */\nexport function isLazyHandle(value: unknown): value is LazyHandle<unknown> {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as Record<symbol, unknown>)[LAZY_HANDLE_SYMBOL] === true\n );\n}\n\n/**\n * Preload a lazy component without mounting it.\n * Useful for prefetching on hover or when idle.\n *\n * @param handle - LazyHandle to preload\n * @returns Promise that resolves when loaded\n */\n/** @codexApi {\"parent\":\"pithy.core.lazy\",\"name\":\"preloadLazy\",\"stability\":\"stable\",\"signature\":\"<T>(handle: LazyHandle<T>) => Promise<T>\"} */\nexport function preloadLazy<T>(handle: LazyHandle<T>): Promise<T> {\n return handle.load();\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"module-cache.js","sourceRoot":"","sources":["../../src/runtime/module-cache.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAwBF,uDAAuD;AACvD,MAAM,WAAW,GAAG,IAAI,GAAG,EAAwB,CAAC;AAEpD;;;;;;;;;;;;;;;;GAgBG;AACH,qKAAqK;AACrK,MAAM,UAAU,UAAU,CACxB,GAAW,EACX,MAAwB;IAExB,IAAI,MAAM,GAAG,WAAW,CAAC,GAAG,CAAC,GAAG,CAAgC,CAAC;IAEjE,IAAI,MAAM,EAAE,CAAC;QACX,iEAAiE;QACjE,OAAO,MAAM,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,wCAAwC;IACxC,MAAM,OAAO,GAAG,MAAM,EAAE;SACrB,I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G,EAAE,GAAG,EAAE,CAAC;IACzB,6BAA6B;IAC5B,UAAsC,CAAC,sBAAsB,GAAG,WAAW,CAAC;AAC/E,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.core.module-cache\",\n \"title\": \"Shared Module Cache for Dynamic Imports\",\n \"category\": \"runtime\"\n}\n*/\n\n/**\n * Shared Module Cache\n *\n * Provides a centralized cache for all dynamic imports across the framework.\n * Used by router, prefetch, and lazy components to prevent duplicate loads.\n *\n * @module runtime/module-cache\n */\n\n/** Status of a cached module */\ntype ModuleStatus = 'pending' | 'resolved' | 'rejected';\n\n/** @codexApi {\"parent\":\"pithy.core.module-cache\",\"name\":\"ModuleRecord\",\"stability\":\"stable\",\"signature\":\"interface ModuleRecord<T>\"} */\nexport interface ModuleRecord<T = unknown> {\n status: ModuleStatus;\n promise: Promise<T>;\n value?: T;\n error?: unknown;\n /** Timestamp when the module was loaded (for cache invalidation) */\n loadedAt?: number;\n}\n\n/** Global module cache - shared across all features */\nconst moduleCache = new Map<string, ModuleRecord>();\n\n/**\n * Load a module by dynamic import with caching.\n * Same module (by key) is only loaded once.\n *\n * @param key - Unique identifier for the module (e.g., 'route:/dashboard', 'component:HeavyChart')\n * @param loader - Function that returns the dynamic import promise\n * @returns Promise resolving to the loaded module\n *\n * @example\n * ```ts\n * // Router uses it for route chunks\n * loadModule('route:/dashboard', () => import('./routes/dashboard.pithy'));\n *\n * // lazy() uses it for component chunks\n * loadModule('component:HeavyChart', () => import('./HeavyChart.pithy'));\n * ```\n */\n/** @codexApi {\"parent\":\"pithy.core.module-cache\",\"name\":\"loadModule\",\"stability\":\"stable\",\"signature\":\"<T>(key: string, loader: () => Promise<T>) => Promise<T>\"} */\nexport function loadModule<T>(\n key: string,\n loader: () => Promise<T>\n): Promise<T> {\n let record = moduleCache.get(key) as ModuleRecord<T> | undefined;\n\n if (record) {\n // Return cached promise (handles pending, resolved, or rejected)\n return record.promise;\n }\n\n // Create new record with pending status\n const promise = loader()\n .then(value => {\n // Update record on success\n const rec = moduleCache.get(key) as ModuleRecord<T>;\n if (rec) {\n rec.status = 'resolved';\n rec.value = value;\n rec.loadedAt = Date.now();\n }\n return value;\n })\n .catch(err => {\n // Update record on failure\n const rec = moduleCache.get(key) as ModuleRecord<T>;\n if (rec) {\n rec.status = 'rejected';\n rec.error = err;\n }\n throw err;\n });\n\n record = { status: 'pending', promise };\n moduleCache.set(key, record);\n\n return promise;\n}\n\n/**\n * Get current status of a cached module.\n *\n * @param key - Module identifier\n * @returns Module record or undefined if not cached\n */\n/** @codexApi {\"parent\":\"pithy.core.module-cache\",\"name\":\"getModuleRecord\",\"stability\":\"stable\",\"signature\":\"<T>(key: string) => ModuleRecord<T> | undefined\"} */\nexport function getModuleRecord<T = unknown>(\n key: string\n): ModuleRecord<T> | undefined {\n return moduleCache.get(key) as ModuleRecord<T> | undefined;\n}\n\n/**\n * Invalidate a specific module from the cache.\n * Used for HMR to force reload of updated modules.\n *\n * @param key - Module identifier to invalidate\n * @returns True if module was found and removed\n */\n/** @codexApi {\"parent\":\"pithy.core.module-cache\",\"name\":\"invalidateModule\",\"stability\":\"stable\",\"signature\":\"(key: string) => boolean\"} */\nexport function invalidateModule(key: string): boolean {\n return moduleCache.delete(key);\n}\n\n/**\n * Get all resolved module keys.\n * Used for SSR to track which chunks were used during render.\n *\n * @returns Array of module keys that have been successfully loaded\n */\n/** @codexApi {\"parent\":\"pithy.core.module-cache\",\"name\":\"getResolvedModuleKeys\",\"stability\":\"stable\",\"signature\":\"() => string[]\"} */\nexport function getResolvedModuleKeys(): string[] {\n const keys: string[] = [];\n for (const [key, record] of moduleCache.entries()) {\n if (record.status === 'resolved') {\n keys.push(key);\n }\n }\n return keys;\n}\n\n/**\n * Clear entire module cache.\n * Use with caution - typically only for testing or full app reload.\n */\n/** @codexApi {\"parent\":\"pithy.core.module-cache\",\"name\":\"clearModuleCache\",\"stability\":\"stable\",\"signature\":\"() => void\"} */\nexport function clearModuleCache(): void {\n moduleCache.clear();\n}\n\n// Development-only logging\nif (import.meta.env?.DEV) {\n // Expose cache for debugging\n (globalThis as Record<string, unknown>).__PITHY_MODULE_CACHE__ = moduleCache;\n}\n"]}
@@ -26,4 +26,11 @@ export declare function onDestroy(fn: () => void): void;
26
26
  * @internal Called by html(), __applyBindings(), and compileNodes() before processing
27
27
  */
28
28
  export declare function drainDestroyCallbacks(): (() => void)[];
29
+ /**
30
+ * Runs `fn` against an empty pending queue, then puts the callbacks that were
31
+ * pending before it back, so nothing `fn` renders can drain them.
32
+ *
33
+ * @internal
34
+ */
35
+ export declare function isolateDestroyCallbacks<T>(fn: () => T): T;
29
36
  //# sourceMappingURL=onDestroy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"onDestroy.d.ts","sourceRoot":"","sources":["../../src/runtime/onDestroy.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAmCF;;;;;;;;;;;GAWG;AACH,oIAAoI;AACpI,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI,CAE9C;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,IAAI,CAAC,MAAM,IAAI,CAAC,EAAE,CAItD"}
1
+ {"version":3,"file":"onDestroy.d.ts","sourceRoot":"","sources":["../../src/runtime/onDestroy.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAmCF;;;;;;;;;;;GAWG;AACH,oIAAoI;AACpI,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI,CAE9C;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,IAAI,CAAC,MAAM,IAAI,CAAC,EAAE,CAItD;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAOzD"}
@@ -5,7 +5,7 @@
5
5
  "category": "runtime"
6
6
  }
7
7
  */
8
- import { pithyGlobals } from '../types/globals';
8
+ import { pithyGlobals } from '../types/globals.js';
9
9
  /**
10
10
  * Module-scoped fallback for browser (single-threaded, no isolation needed).
11
11
  * In SSR, @pithyjs/ssr installs AsyncLocalStorage-backed getters via
@@ -63,4 +63,19 @@ export function drainDestroyCallbacks() {
63
63
  setPending([]);
64
64
  return drained;
65
65
  }
66
+ /**
67
+ * Runs `fn` against an empty pending queue, then puts the callbacks that were
68
+ * pending before it back, so nothing `fn` renders can drain them.
69
+ *
70
+ * @internal
71
+ */
72
+ export function isolateDestroyCallbacks(fn) {
73
+ const outer = drainDestroyCallbacks();
74
+ try {
75
+ return fn();
76
+ }
77
+ finally {
78
+ setPending(outer.concat(getPending()));
79
+ }
80
+ }
66
81
  //# sourceMappingURL=onDestroy.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"onDestroy.js","sourceRoot":"","sources":["../../src/runtime/onDestroy.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD;;;;;GAKG;AACH,IAAI,iBAAiB,GAAmB,EAAE,CAAC;AAE3C,uFAAuF;AACvF,SAAS,UAAU;IACjB,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC,0BAA0B,CAAC;IACzD,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE,CAAC;QACjC,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC;QACxB,IAAI,MAAM;YAAE,OAAO,MAAM,CAAC;IAC5B,CAAC;IACD,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAED,kDAAkD;AAClD,SAAS,UAAU,CAAC,GAAmB;IACrC,MAAM,CAAC,GAAG,YAAY,EAAE,CAAC;IACzB,MAAM,MAAM,GAAG,CAAC,CAAC,0BAA0B,CAAC;IAC5C,oFAAoF;IACpF,qFAAqF;IACrF,IAAI,OAAO,MAAM,KAAK,UAAU,IAAI,MAAM,EAAE,IAAI,IAAI,EAAE,CAAC;QACrD,CAAC,CAAC,0BAA2B,CAAC,GAAG,CAAC,CAAC;IACrC,CAAC;SAAM,CAAC;QACN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I;AACpI,MAAM,UAAU,SAAS,CAAC,EAAc;IACtC,UAAU,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACxB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB;IACnC,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,UAAU,CAAC,EAAE,CAAC,CAAC;IACf,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAI,EAAW;IACpD,MAAM,KAAK,GAAG,qBAAqB,EAAE,CAAC;IACtC,IAAI,CAAC;QACH,OAAO,EAAE,EAAE,CAAC;IACd,CAAC;YAAS,CAAC;QACT,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;IACzC,CAAC;AACH,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.runtime.onDestroy\",\n \"title\": \"Component Destroy Lifecycle Hook\",\n \"category\": \"runtime\"\n}\n*/\n\nimport { pithyGlobals } from '../types/globals';\n\n/**\n * Module-scoped fallback for browser (single-threaded, no isolation needed).\n * In SSR, @pithyjs/ssr installs AsyncLocalStorage-backed getters via\n * globalThis.__pithyGetDestroyCallbacks / __pithySetDestroyCallbacks\n * to isolate pending callbacks per request.\n */\nlet _defaultCallbacks: (() => void)[] = [];\n\n/** Get the current pending callbacks (per-request in SSR, module-scoped in browser) */\nfunction getPending(): (() => void)[] {\n const getter = pithyGlobals().__pithyGetDestroyCallbacks;\n if (typeof getter === 'function') {\n const result = getter();\n if (result) return result;\n }\n return _defaultCallbacks;\n}\n\n/** Replace the current pending callbacks array */\nfunction setPending(cbs: (() => void)[]): void {\n const g = pithyGlobals();\n const getter = g.__pithyGetDestroyCallbacks;\n // Only use SSR setter when inside an active render scope (getter returns non-null).\n // Outside a render scope the setter is a no-op, so fall back to module-scoped array.\n if (typeof getter === 'function' && getter() != null) {\n g.__pithySetDestroyCallbacks!(cbs);\n } else {\n _defaultCallbacks = cbs;\n }\n}\n\n/**\n * Registers a cleanup callback at component scope. When the component's\n * destroy() is called, all registered callbacks run in LIFO order\n * (last-registered first), after template disposers have executed.\n *\n * Must be called synchronously during component function execution,\n * before the template entry point. Pending callbacks are drained by\n * `html()`, `__applyBindings()` (AOT), or `compileNodes()` — whichever\n * runs next — and incorporated into the returned `destroy()` function.\n *\n * @param fn - Cleanup function to run on component destroy\n */\n/** @codexApi {\"parent\":\"pithy.runtime.onDestroy\",\"name\":\"onDestroy\",\"stability\":\"stable\",\"signature\":\"(fn: () => void) => void\"} */\nexport function onDestroy(fn: () => void): void {\n getPending().push(fn);\n}\n\n/**\n * Drains all pending destroy callbacks and returns them.\n * Replaces the internal array so the next component starts fresh.\n *\n * @internal Called by html(), __applyBindings(), and compileNodes() before processing\n */\nexport function drainDestroyCallbacks(): (() => void)[] {\n const drained = getPending();\n setPending([]);\n return drained;\n}\n\n/**\n * Runs `fn` against an empty pending queue, then puts the callbacks that were\n * pending before it back, so nothing `fn` renders can drain them.\n *\n * @internal\n */\nexport function isolateDestroyCallbacks<T>(fn: () => T): T {\n const outer = drainDestroyCallbacks();\n try {\n return fn();\n } finally {\n setPending(outer.concat(getPending()));\n }\n}\n"]}
@@ -5,7 +5,7 @@
5
5
  "category": "compiler"
6
6
  }
7
7
  */
8
- import { isJITLoaded, getParseFragmentFn } from '../compile/parseHtml';
8
+ import { isJITLoaded, getParseFragmentFn } from '../compile/parseHtml.js';
9
9
  import { escapeComponentTags } from '@pithyjs/compiler';
10
10
  /**
11
11
  * Extract variable identifiers from an HTML template string.
@@ -1 +1 @@
1
- {"version":3,"file":"parseIdentifiersFromTemplate.js","sourceRoot":"","sources":["../../src/runtime/parseIdentifiersFromTemplate.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD;;;;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I,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;oBACvD,IAAI,IAAI;wBAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC5D,CAAC;YACH,CAAC;QACH,CAAC;QAED,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;gBACpC,IAAI,CAAC,KAAK,CAAC,CAAC;YACd,CAAC;QACH,CAAC;IACH,CAAC,CAAC;IAEF,KAAK,MAAM,KAAK,IAAK,QAAuB,CAAC,UAAU,IAAI,EAAE,EAAE,CAAC;QAC9D,IAAI,CAAC,KAAK,CAAC,CAAC;IACd,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.compiler.identifier-parser\",\n \"title\": \"Template Identifier Parser\",\n \"category\": \"compiler\"\n}\n*/\n\nimport { isJITLoaded, getParseFragmentFn } from '../compile/parseHtml';\nimport { escapeComponentTags } from '@pithyjs/compiler';\n\n/**\n * Extract variable identifiers from an HTML template string.\n * DEV-only helper used by `html()` fallback when the Babel plugin hasn't\n * injected identifiers. Returns an empty set if parse5 is not loaded\n * (intentional — throwing would crash AOT apps in dev mode).\n * @internal\n */\n/** @codexApi {\"parent\":\"pithy.compiler.identifier-parser\",\"name\":\"parseIdentifiersFromTemplate\",\"stability\":\"internal\",\"signature\":\"(template: string) => Set<string>\"} */\nexport function parseIdentifiersFromTemplate(template: string): Set<string> {\n const identifiers = new Set<string>();\n\n // DEV-only fallback: if parse5 isn't loaded (AOT mode), return empty set\n // gracefully. The Babel plugin handles identifier extraction at build time.\n // Throwing here would crash AOT apps running in dev mode.\n const parseFn = isJITLoaded() ? getParseFragmentFn() : null;\n if (!parseFn) {\n return identifiers;\n }\n\n // Escape PascalCase component tags so parse5 doesn't enter special\n // insertion modes (e.g., \"in select\") that drop children from the tree.\n const escaped = escapeComponentTags(template);\n\n const fragment = parseFn(escaped, {\n sourceCodeLocationInfo: false,\n });\n\n interface ParsedNode {\n nodeName?: string;\n value?: string;\n attrs?: { value: string }[];\n childNodes?: ParsedNode[];\n }\n\n const walk = (node: ParsedNode) => {\n if (node.nodeName === '#text' && node.value) {\n const text = node.value;\n const matches = text.match(/{{\\s*(.*?)\\s*}}/g);\n if (matches) {\n matches.forEach((m: string) => {\n const inner = m.replace(/{{|}}/g, '').trim();\n const vars = inner.match(/\\b[a-zA-Z_][a-zA-Z0-9_]*\\b/g);\n if (vars) vars.forEach((v: string) => identifiers.add(v));\n });\n }\n }\n\n if (node.attrs) {\n for (const attr of node.attrs) {\n const expr = attr.value;\n\n // Skip literal strings like 'Hello world'\n if (!/^['\"].*['\"]$/.test(expr)) {\n const vars = expr.match(/\\b[a-zA-Z_][a-zA-Z0-9_]*\\b/g);\n if (vars) vars.forEach((v: string) => identifiers.add(v));\n }\n }\n }\n\n if (node.childNodes) {\n for (const child of node.childNodes) {\n walk(child);\n }\n }\n };\n\n for (const child of (fragment as ParsedNode).childNodes ?? []) {\n walk(child);\n }\n\n return identifiers;\n}\n"]}
@@ -6,7 +6,7 @@
6
6
  "risk": "high"
7
7
  }
8
8
  */
9
- import type { ActionHandle, ActionOptions, ActionPerformer } from './types';
9
+ import type { ActionHandle, ActionOptions, ActionPerformer } from './types.js';
10
10
  /**
11
11
  * Create a reactive async action.
12
12
  *
@@ -17,7 +17,7 @@
17
17
  * @module runtime/resource/createAction
18
18
  */
19
19
  import { onCleanup } from '@pithyjs/signals';
20
- import { createAsyncEngine, DROPPED } from './engine';
20
+ import { createAsyncEngine, DROPPED } from './engine.js';
21
21
  /**
22
22
  * Create a reactive async action.
23
23
  *
@@ -1 +1 @@
1
- {"version":3,"file":"createAction.js","sourceRoot":"","sources":["../../../src/runtime/resource/createAction.ts"],"names":[],"mappings":"AAAA;;;;;;;EAOE;AAEF;;;;;;;;;GAS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AK;QACnB,OAAO,EAAE,MAAM,CAAC,OAAO;KACxB,CAAC;IAEF,4EAA4E;IAC5E,yEAAyE;IACzE,oEAAoE;IACpE,+CAA+C;IAC/C,SAAS,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;IAElC,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.core.resource.action\",\n \"title\": \"Async Action Primitive\",\n \"category\": \"runtime\",\n \"risk\": \"high\"\n}\n*/\n\n/**\n * `createAction` — reactive async write (a mutation, triggered explicitly).\n *\n * Named `createAction` rather than `createMutation` on purpose: \"mutation\" is\n * already taken by the site-builder vocabulary (`mutation-vocabulary.ts`,\n * mutation envelopes, the mutation executor) and reusing it here would make\n * two unrelated concepts share a word.\n *\n * @module runtime/resource/createAction\n */\n\nimport { onCleanup } from '@pithyjs/signals';\nimport { createAsyncEngine, DROPPED } from './engine';\nimport type {\n ActionHandle,\n ActionOptions,\n ActionPerformer,\n ActionResult,\n} from './types';\n\n/**\n * Create a reactive async action.\n *\n * Unlike {@link createResource} an action never runs on its own — only an\n * explicit `run()` triggers it — and by default a concurrent `run()` is dropped\n * rather than restarted, so a double-clicked submit button fires once.\n *\n * There is no static-generation special case: an action only runs from an\n * explicit call, and prerendering never calls one, so there is no auto-run to\n * suppress.\n *\n * @typeParam T - Type of the resolved data.\n * @typeParam A - Tuple of arguments forwarded from `run()` to the performer.\n * @typeParam E - Type of the carried error (`unknown` by default).\n * @param performer - Function performing the side effect.\n * @param options - Behaviour options, see {@link ActionOptions}.\n * @returns An {@link ActionHandle} whose `destroy()` MUST be called from the\n * owning component's cleanup.\n *\n * @example\n * ```ts\n * const save = createAction((draft: Draft) =>\n * fetch('/api/posts', { method: 'POST', body: JSON.stringify(draft) })\n * );\n *\n * const result = await save.run(draft);\n * if (result.ok) toast('Saved');\n * else if (!result.dropped) toast(String(result.error));\n *\n * onDestroy(() => save.destroy());\n * ```\n */\n/** @codexApi {\"parent\":\"pithy.core.resource.action\",\"name\":\"createAction\",\"stability\":\"stable\",\"signature\":\"<T, A extends unknown[] = [], E = unknown>(performer: ActionPerformer<T, A>, options?: ActionOptions) => ActionHandle<T, A, E>\"} */\nexport function createAction<T, A extends unknown[] = [], E = unknown>(\n performer: ActionPerformer<T, A>,\n options: ActionOptions = {}\n): ActionHandle<T, A, E> {\n const { overlap = 'drop', keepPreviousData = true } = options;\n\n const engine = createAsyncEngine<T, E>({ keepPreviousData });\n\n /**\n * Perform the action.\n *\n * DIVERGENCE, ON PURPOSE: this RESOLVES a discriminated {@link ActionResult}\n * instead of rejecting. The house convention for async elsewhere in this repo\n * is to reject — the router's `executeLoader()` does. A failed mutation,\n * though, is an ordinary UI state (show the message, keep the form filled),\n * not an exception; making it reject forces a try/catch around every submit\n * handler and loses the type of the error. Rejections stay reserved for bugs.\n *\n * The performer receives only the caller's arguments — no `AbortSignal`. A\n * variadic argument tuple leaves no unambiguous slot for one, and adding it\n * would wreck inference of `A` for the common signal-less case. Correctness\n * does not depend on it: the engine's generation counter already guarantees a\n * superseded or destroyed run can never write state.\n */\n function run(...args: A): Promise<ActionResult<T, E>> {\n // Guards on whether a PERFORMER is still running, not on whether we still\n // want its result. `reset()` clears the latter — that is its job — but the\n // POST it abandoned is still in flight, and an action's performer never\n // receives the AbortSignal, so nothing stops it. Guarding on `isInFlight()`\n // meant Save -> dismiss error (reset) -> Save sent two concurrent requests\n // and could create a duplicate record: precisely what 'drop' prevents.\n if (overlap === 'drop' && engine.hasRunningTask()) {\n return Promise.resolve(DROPPED);\n }\n return engine.execute(() => performer(...args));\n }\n\n const handle: ActionHandle<T, A, E> = {\n data: engine.data,\n error: engine.error,\n status: engine.status,\n // Plain accessor rather than computed() — see createResource.ts.\n pending: () => engine.status() === 'loading',\n run,\n reset: engine.reset,\n destroy: engine.destroy,\n };\n\n // Best effort only — onCleanup() outside an effect is a silent no-op. Under\n // an owner it fires on a re-run as well as on the disposer, so an action\n // built inside an effect is destroyed when that effect re-runs. See\n // createResource.ts and the README for detail.\n onCleanup(() => engine.destroy());\n\n return handle;\n}\n"]}
@@ -6,7 +6,7 @@
6
6
  "risk": "high"
7
7
  }
8
8
  */
9
- import type { ResourceFetcher, ResourceHandle, ResourceOptions } from './types';
9
+ import type { ResourceFetcher, ResourceHandle, ResourceOptions } from './types.js';
10
10
  /**
11
11
  * Create a reactive async resource.
12
12
  *
@@ -1 +1 @@
1
- {"version":3,"file":"createResource.d.ts","sourceRoot":"","sources":["../../../src/runtime/resource/createResource.ts"],"names":[],"mappings":"AAAA;;;;;;;EAOE;AAeF,OAAO,KAAK,EAEV,eAAe,EACf,cAAc,EACd,eAAe,EAChB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,6MAA6M;AAC7M,wBAAgB,cAAc,CAAC,CAAC,EAAE,CAAC,GAAG,OAAO,EAC3C,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,EAC3B,OAAO,GAAE,eAAoB,GAC5B,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,CAyCtB"}
1
+ {"version":3,"file":"createResource.d.ts","sourceRoot":"","sources":["../../../src/runtime/resource/createResource.ts"],"names":[],"mappings":"AAAA;;;;;;;EAOE;AAeF,OAAO,KAAK,EAEV,eAAe,EACf,cAAc,EACd,eAAe,EAChB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,6MAA6M;AAC7M,wBAAgB,cAAc,CAAC,CAAC,EAAE,CAAC,GAAG,OAAO,EAC3C,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,EAC3B,OAAO,GAAE,eAAoB,GAC5B,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,CAwCtB"}
@@ -16,8 +16,8 @@
16
16
  * @module runtime/resource/createResource
17
17
  */
18
18
  import { onCleanup } from '@pithyjs/signals';
19
- import { isSSRMode } from '../../compile/ssrMode';
20
- import { createAsyncEngine, DROPPED } from './engine';
19
+ import { isSSRMode } from '../../compile/ssrMode.js';
20
+ import { createAsyncEngine, DROPPED } from './engine.js';
21
21
  /**
22
22
  * Create a reactive async resource.
23
23
  *
@@ -77,8 +77,7 @@ export function createResource(fetcher, options = {}) {
77
77
  error: engine.error,
78
78
  status: engine.status,
79
79
  // Plain accessor rather than computed(): it still tracks reactively because
80
- // it reads status() inside the caller's effect, and computed() leaks its
81
- // internal effect disposer.
80
+ // it reads status() inside the caller's effect.
82
81
  loading: () => engine.status() === 'loading',
83
82
  refetch,
84
83
  reset: engine.reset,
@@ -1 +1 @@
1
- {"version":3,"file":"createResource.js","sourceRoot":"","sources":["../../../src/runtime/resource/createResource.ts"],"names":[],"mappings":"AAAA;;;;;;;EAOE;AAEF;;;;;;;;GAQG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAQtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,6MAA6M;AAC7M,MAAM,UAAU,cAAc,CAC5B,OAA2B,EAC3B,UAA2B,EAAE;IAE7B,MAAM,EAAE,SAAS,GAAG,IAAI,EAAE,gBAAgB,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;IAE/D,MAAM,MAAM,GAAG,iBAAiB,CAAO,EAAE,gBAAgB,EAAE,CAAC,CAAC;IAE7D,SAAS,OAAO;QACd,sEAAsE;QACtE,IAAI,SAAS,EAAE;YAAE,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACjD,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IACnD,CAAC;IAED,MAAM,MAAM,GAA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C;IAE7D,SAAS,OAAO;QACd,sEAAsE;QACtE,IAAI,SAAS,EAAE;YAAE,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACjD,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IACnD,CAAC;IAED,MAAM,MAAM,GAAyB;QACnC,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,4EAA4E;QAC5E,gDAAgD;QAChD,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,SAAS;QAC5C,OAAO;QACP,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,OAAO,EAAE,MAAM,CAAC,OAAO;KACxB,CAAC;IAEF,IAAI,SAAS,EAAE,CAAC;QACd,KAAK,OAAO,EAAE,CAAC;IACjB,CAAC;IAED,6EAA6E;IAC7E,4EAA4E;IAC5E,0DAA0D;IAC1D,EAAE;IACF,4EAA4E;IAC5E,qEAAqE;IACrE,6EAA6E;IAC7E,4EAA4E;IAC5E,sEAAsE;IACtE,mEAAmE;IACnE,SAAS,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;IAElC,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.core.resource\",\n \"title\": \"Async State Primitive\",\n \"category\": \"runtime\",\n \"risk\": \"high\"\n}\n*/\n\n/**\n * `createResource` — reactive async read (a query).\n *\n * Wraps an async fetch in three signals (`data`, `error`, `status`) so a\n * template can bind to loading and error states directly instead of the app\n * hand-rolling `isLoading` booleans around every `await`.\n *\n * @module runtime/resource/createResource\n */\n\nimport { onCleanup } from '@pithyjs/signals';\nimport { isSSRMode } from '../../compile/ssrMode';\nimport { createAsyncEngine, DROPPED } from './engine';\nimport type {\n ActionResult,\n ResourceFetcher,\n ResourceHandle,\n ResourceOptions,\n} from './types';\n\n/**\n * Create a reactive async resource.\n *\n * The fetcher runs immediately by default and again on every `refetch()`. The\n * newest run always wins: a superseded response can never write state, even if\n * its fetcher ignored the abort signal (see `engine.ts`).\n *\n * ## Server rendering\n *\n * Under ANY server render the fetcher is NOT called and the resource resolves to\n * `'idle'` — deliberately not `'loading'`, so a prerendered page ships its\n * empty/idle markup rather than a spinner frozen into the HTML. `refetch()` is\n * inert there too.\n *\n * SCOPE: this covers static generation *and* per-request dynamic SSR. The gate\n * is `isSSRMode()`, and `@pithyjs/ssr` sets `__PITHY_SSR__` in `setupEnvironment()`,\n * which every `renderToString()` call runs — not only the SSG build. Suppression\n * is correct for both: the renderer awaits *route loaders*, which it discovers\n * declaratively from the route tree, and has no way to discover a resource\n * constructed inside a component body mid-render. Server-side data belongs in a\n * loader; a resource that fired here could never contribute to the HTML anyway.\n *\n * The flag is read at call time on purpose: it toggles per render while modules\n * stay cached across renders in one process, so capturing it in a module const\n * would poison every later render.\n *\n * @typeParam T - Type of the resolved data.\n * @typeParam E - Type of the carried error (`unknown` by default — thrown values\n * are carried by reference and never wrapped).\n * @param fetcher - Function producing the data. Receives an `AbortSignal` that is\n * aborted on refetch, reset and destroy.\n * @param options - Behaviour options, see {@link ResourceOptions}.\n * @returns A {@link ResourceHandle} whose `destroy()` MUST be called from the\n * owning component's cleanup.\n *\n * @example\n * ```ts\n * const user = createResource(signal => fetch('/api/me', { signal }).then(r => r.json()));\n *\n * // in a template: {{ user.loading() ? 'Loading…' : user.data()?.name }}\n *\n * onDestroy(() => user.destroy());\n * ```\n */\n/** @codexApi {\"parent\":\"pithy.core.resource\",\"name\":\"createResource\",\"stability\":\"stable\",\"signature\":\"<T, E = unknown>(fetcher: ResourceFetcher<T>, options?: ResourceOptions) => ResourceHandle<T, E>\"} */\nexport function createResource<T, E = unknown>(\n fetcher: ResourceFetcher<T>,\n options: ResourceOptions = {}\n): ResourceHandle<T, E> {\n const { immediate = true, keepPreviousData = false } = options;\n\n const engine = createAsyncEngine<T, E>({ keepPreviousData });\n\n function refetch(): Promise<ActionResult<T, E>> {\n // Read isSSRMode() at CALL time — never hoist it into a module const.\n if (isSSRMode()) return Promise.resolve(DROPPED);\n return engine.execute(signal => fetcher(signal));\n }\n\n const handle: ResourceHandle<T, E> = {\n data: engine.data,\n error: engine.error,\n status: engine.status,\n // Plain accessor rather than computed(): it still tracks reactively because\n // it reads status() inside the caller's effect.\n loading: () => engine.status() === 'loading',\n refetch,\n reset: engine.reset,\n destroy: engine.destroy,\n };\n\n if (immediate) {\n void refetch();\n }\n\n // Best effort only: onCleanup() outside an effect is a SILENT no-op, so this\n // helps when the resource happens to be created inside one and does nothing\n // otherwise. The explicit destroy() remains the contract.\n //\n // \"Best effort\" means only that `onCleanup()` outside an effect is a silent\n // no-op. Under an owner this now fires on a re-run as well as on the\n // disposer, so `effect(() => createResource(() => fetch(`/api/u/${id()}`)))`\n // destroys the previous resource on each `id` change instead of leaking one\n // per run. The resource still must not outlive that run: hold it in a\n // `createRoot` if it should. See the README's Async State section.\n onCleanup(() => engine.destroy());\n\n return handle;\n}\n"]}
@@ -72,7 +72,7 @@
72
72
  * @module runtime/resource/engine
73
73
  */
74
74
  import { type Signal } from '@pithyjs/signals';
75
- import type { ActionResult, ResourceStatus } from './types';
75
+ import type { ActionResult, ResourceStatus } from './types.js';
76
76
  /**
77
77
  * The single "nothing happened" result value.
78
78
  *