@askrjs/askr 0.0.21 → 0.0.24

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 (294) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +160 -46
  3. package/dist/_virtual/___vite-browser-external.js +1 -0
  4. package/dist/_virtual/__vite-browser-external.js +1 -0
  5. package/dist/_virtual/_commonjsHelpers.js +1 -0
  6. package/dist/_virtual/main.js +1 -0
  7. package/dist/_virtual/preload-helper.js +1 -0
  8. package/dist/{benchmark.d.ts → bench/benchmark-entry.d.ts} +3 -3
  9. package/dist/bench/benchmark-entry.d.ts.map +1 -0
  10. package/dist/benchmark.js +1 -1
  11. package/dist/boot/index.d.ts +70 -0
  12. package/dist/boot/index.d.ts.map +1 -0
  13. package/dist/boot/index.js +2 -0
  14. package/dist/common/component.d.ts +16 -0
  15. package/dist/common/component.d.ts.map +1 -0
  16. package/dist/common/errors.d.ts +53 -0
  17. package/dist/common/errors.d.ts.map +1 -0
  18. package/dist/common/index.d.ts +14 -0
  19. package/dist/common/index.d.ts.map +1 -0
  20. package/dist/common/jsx.d.ts +17 -0
  21. package/dist/common/jsx.d.ts.map +1 -0
  22. package/dist/common/jsx.js +1 -0
  23. package/dist/{jsx-CPjsGyEg.d.ts → common/props.d.ts} +6 -18
  24. package/dist/common/props.d.ts.map +1 -0
  25. package/dist/{router-DaGtH1Sq.d.ts → common/router.d.ts} +10 -7
  26. package/dist/common/router.d.ts.map +1 -0
  27. package/dist/common/ssr-errors.d.ts +8 -0
  28. package/dist/common/ssr-errors.d.ts.map +1 -0
  29. package/dist/common/ssr-errors.js +1 -0
  30. package/dist/common/ssr.d.ts +17 -0
  31. package/dist/common/ssr.d.ts.map +1 -0
  32. package/dist/common/vnode.d.ts +17 -0
  33. package/dist/common/vnode.d.ts.map +1 -0
  34. package/dist/common/vnode.js +1 -0
  35. package/dist/components/link.d.ts +56 -0
  36. package/dist/components/link.d.ts.map +1 -0
  37. package/dist/components/link.js +1 -0
  38. package/dist/dev/invariant.d.ts +83 -0
  39. package/dist/dev/invariant.d.ts.map +1 -0
  40. package/dist/dev/invariant.js +2 -0
  41. package/dist/dev/logger.d.ts +13 -0
  42. package/dist/dev/logger.d.ts.map +1 -0
  43. package/dist/dev/logger.js +1 -0
  44. package/dist/dev/vite-plugin-askr.d.ts +18 -0
  45. package/dist/dev/vite-plugin-askr.d.ts.map +1 -0
  46. package/dist/dev/warnings.d.ts +5 -0
  47. package/dist/dev/warnings.d.ts.map +1 -0
  48. package/dist/for/for.d.ts +16 -0
  49. package/dist/for/for.d.ts.map +1 -0
  50. package/dist/for/for.js +1 -0
  51. package/dist/for/index.d.ts +2 -63
  52. package/dist/for/index.d.ts.map +1 -0
  53. package/dist/for/index.js +1 -1
  54. package/dist/foundations/core.d.ts +23 -0
  55. package/dist/foundations/core.d.ts.map +1 -0
  56. package/dist/foundations/core.js +1 -0
  57. package/dist/foundations/index.d.ts +3 -669
  58. package/dist/foundations/index.d.ts.map +1 -0
  59. package/dist/foundations/index.js +1 -1
  60. package/dist/foundations/interactions/dismissable.d.ts +58 -0
  61. package/dist/foundations/interactions/dismissable.d.ts.map +1 -0
  62. package/dist/foundations/interactions/dismissable.js +1 -0
  63. package/dist/foundations/interactions/focusable.d.ts +16 -0
  64. package/dist/foundations/interactions/focusable.d.ts.map +1 -0
  65. package/dist/foundations/interactions/focusable.js +1 -0
  66. package/dist/foundations/interactions/hoverable.d.ts +19 -0
  67. package/dist/foundations/interactions/hoverable.d.ts.map +1 -0
  68. package/dist/foundations/interactions/hoverable.js +1 -0
  69. package/dist/foundations/interactions/index.d.ts +5 -0
  70. package/dist/foundations/interactions/index.d.ts.map +1 -0
  71. package/dist/foundations/interactions/interaction-policy.d.ts +96 -0
  72. package/dist/foundations/interactions/interaction-policy.d.ts.map +1 -0
  73. package/dist/foundations/interactions/interaction-policy.js +1 -0
  74. package/dist/foundations/interactions/pressable.d.ts +54 -0
  75. package/dist/foundations/interactions/pressable.d.ts.map +1 -0
  76. package/dist/foundations/interactions/pressable.js +1 -0
  77. package/dist/foundations/interactions/roving-focus.d.ts +117 -0
  78. package/dist/foundations/interactions/roving-focus.d.ts.map +1 -0
  79. package/dist/foundations/interactions/roving-focus.js +1 -0
  80. package/dist/foundations/state/controllable.d.ts +53 -0
  81. package/dist/foundations/state/controllable.d.ts.map +1 -0
  82. package/dist/foundations/state/controllable.js +1 -0
  83. package/dist/foundations/state/index.d.ts +2 -0
  84. package/dist/foundations/state/index.d.ts.map +1 -0
  85. package/dist/foundations/structures/collection.d.ts +67 -0
  86. package/dist/foundations/structures/collection.d.ts.map +1 -0
  87. package/dist/foundations/structures/collection.js +1 -0
  88. package/dist/foundations/structures/index.d.ts +5 -0
  89. package/dist/foundations/structures/index.d.ts.map +1 -0
  90. package/dist/foundations/structures/layer.d.ts +102 -0
  91. package/dist/foundations/structures/layer.d.ts.map +1 -0
  92. package/dist/foundations/structures/layer.js +1 -0
  93. package/dist/{layout-BINPv-nz.d.ts → foundations/structures/layout.d.ts} +3 -4
  94. package/dist/foundations/structures/layout.d.ts.map +1 -0
  95. package/dist/foundations/structures/layout.js +1 -0
  96. package/dist/foundations/structures/portal.d.ts +33 -0
  97. package/dist/foundations/structures/portal.d.ts.map +1 -0
  98. package/dist/foundations/structures/portal.js +1 -0
  99. package/dist/foundations/structures/presence.d.ts +30 -0
  100. package/dist/foundations/structures/presence.d.ts.map +1 -0
  101. package/dist/foundations/structures/presence.js +1 -0
  102. package/dist/foundations/structures/slot.d.ts +31 -0
  103. package/dist/foundations/structures/slot.d.ts.map +1 -0
  104. package/dist/foundations/structures/slot.js +1 -0
  105. package/dist/foundations/structures.d.ts +14 -0
  106. package/dist/foundations/structures.d.ts.map +1 -0
  107. package/dist/foundations/structures.js +1 -0
  108. package/dist/foundations/utilities/aria.d.ts +13 -0
  109. package/dist/foundations/utilities/aria.d.ts.map +1 -0
  110. package/dist/foundations/utilities/aria.js +1 -0
  111. package/dist/foundations/utilities/compose-handlers.d.ts +34 -0
  112. package/dist/foundations/utilities/compose-handlers.d.ts.map +1 -0
  113. package/dist/foundations/utilities/compose-handlers.js +1 -0
  114. package/dist/foundations/utilities/compose-ref.d.ts +24 -0
  115. package/dist/foundations/utilities/compose-ref.d.ts.map +1 -0
  116. package/dist/foundations/utilities/compose-ref.js +1 -0
  117. package/dist/foundations/utilities/event-types.d.ts +17 -0
  118. package/dist/foundations/utilities/event-types.d.ts.map +1 -0
  119. package/dist/foundations/utilities/index.d.ts +7 -0
  120. package/dist/foundations/utilities/index.d.ts.map +1 -0
  121. package/dist/foundations/utilities/merge-props.d.ts +2 -0
  122. package/dist/foundations/utilities/merge-props.d.ts.map +1 -0
  123. package/dist/foundations/utilities/merge-props.js +1 -0
  124. package/dist/foundations/utilities/use-id.d.ts +29 -0
  125. package/dist/foundations/utilities/use-id.d.ts.map +1 -0
  126. package/dist/foundations/utilities/use-id.js +1 -0
  127. package/dist/fx/fx.d.ts +30 -0
  128. package/dist/fx/fx.d.ts.map +1 -0
  129. package/dist/fx/fx.js +1 -0
  130. package/dist/fx/index.d.ts +5 -184
  131. package/dist/fx/index.d.ts.map +1 -0
  132. package/dist/fx/index.js +1 -1
  133. package/dist/fx/noop.d.ts +12 -0
  134. package/dist/fx/noop.d.ts.map +1 -0
  135. package/dist/fx/noop.js +1 -0
  136. package/dist/fx/timing.d.ts +155 -0
  137. package/dist/fx/timing.d.ts.map +1 -0
  138. package/dist/fx/timing.js +1 -0
  139. package/dist/index.d.ts +18 -37
  140. package/dist/index.d.ts.map +1 -0
  141. package/dist/index.js +1 -1
  142. package/dist/jsx/index.d.ts +4 -0
  143. package/dist/jsx/index.d.ts.map +1 -0
  144. package/dist/jsx/index.js +1 -0
  145. package/dist/jsx/jsx-dev-runtime.d.ts +4 -0
  146. package/dist/jsx/jsx-dev-runtime.d.ts.map +1 -0
  147. package/dist/jsx/jsx-runtime.d.ts +10 -0
  148. package/dist/jsx/jsx-runtime.d.ts.map +1 -0
  149. package/dist/{types-BTT0Fc9S.d.ts → jsx/types.d.ts} +6 -3
  150. package/dist/jsx/types.d.ts.map +1 -0
  151. package/dist/jsx/types.js +1 -0
  152. package/dist/jsx/utils.d.ts +4 -0
  153. package/dist/jsx/utils.d.ts.map +1 -0
  154. package/dist/jsx/utils.js +1 -0
  155. package/dist/jsx-dev-runtime.js +1 -1
  156. package/dist/jsx-runtime.js +1 -1
  157. package/dist/node_modules/esbuild/lib/main.js +65 -0
  158. package/dist/renderer/cleanup.d.ts +25 -0
  159. package/dist/renderer/cleanup.d.ts.map +1 -0
  160. package/dist/renderer/cleanup.js +1 -0
  161. package/dist/renderer/dom.d.ts +44 -0
  162. package/dist/renderer/dom.d.ts.map +1 -0
  163. package/dist/renderer/dom.js +1 -0
  164. package/dist/renderer/evaluate.d.ts +4 -0
  165. package/dist/renderer/evaluate.d.ts.map +1 -0
  166. package/dist/renderer/evaluate.js +1 -0
  167. package/dist/renderer/fastpath.d.ts +7 -0
  168. package/dist/renderer/fastpath.d.ts.map +1 -0
  169. package/dist/renderer/fastpath.js +1 -0
  170. package/dist/renderer/index.d.ts +6 -0
  171. package/dist/renderer/index.d.ts.map +1 -0
  172. package/dist/renderer/index.js +1 -0
  173. package/dist/renderer/keyed.d.ts +23 -0
  174. package/dist/renderer/keyed.d.ts.map +1 -0
  175. package/dist/renderer/keyed.js +1 -0
  176. package/dist/renderer/reconcile.d.ts +88 -0
  177. package/dist/renderer/reconcile.d.ts.map +1 -0
  178. package/dist/renderer/reconcile.js +1 -0
  179. package/dist/renderer/types.d.ts +3 -0
  180. package/dist/renderer/types.d.ts.map +1 -0
  181. package/dist/renderer/types.js +1 -0
  182. package/dist/renderer/utils.d.ts +63 -0
  183. package/dist/renderer/utils.d.ts.map +1 -0
  184. package/dist/renderer/utils.js +1 -0
  185. package/dist/resources/index.d.ts +7 -22
  186. package/dist/resources/index.d.ts.map +1 -0
  187. package/dist/resources/index.js +1 -1
  188. package/dist/router/index.d.ts +8 -87
  189. package/dist/router/index.d.ts.map +1 -0
  190. package/dist/router/index.js +1 -1
  191. package/dist/router/match.d.ts +22 -0
  192. package/dist/router/match.d.ts.map +1 -0
  193. package/dist/router/match.js +1 -0
  194. package/dist/router/navigate.d.ts +20 -0
  195. package/dist/router/navigate.d.ts.map +1 -0
  196. package/dist/router/navigate.js +1 -0
  197. package/dist/router/route.d.ts +52 -0
  198. package/dist/router/route.d.ts.map +1 -0
  199. package/dist/router/route.js +1 -0
  200. package/dist/runtime/component.d.ts +123 -0
  201. package/dist/runtime/component.d.ts.map +1 -0
  202. package/dist/runtime/component.js +1 -0
  203. package/dist/runtime/context.d.ts +80 -0
  204. package/dist/runtime/context.d.ts.map +1 -0
  205. package/dist/runtime/context.js +1 -0
  206. package/dist/runtime/derive.d.ts +7 -0
  207. package/dist/runtime/derive.d.ts.map +1 -0
  208. package/dist/runtime/derive.js +1 -0
  209. package/dist/runtime/dev-namespace.d.ts +31 -0
  210. package/dist/runtime/dev-namespace.d.ts.map +1 -0
  211. package/dist/runtime/dev-namespace.js +1 -0
  212. package/dist/runtime/events.d.ts +52 -0
  213. package/dist/runtime/events.d.ts.map +1 -0
  214. package/dist/runtime/events.js +1 -0
  215. package/dist/runtime/execution-model.d.ts +4 -0
  216. package/dist/runtime/execution-model.d.ts.map +1 -0
  217. package/dist/runtime/execution-model.js +1 -0
  218. package/dist/runtime/fastlane.d.ts +27 -0
  219. package/dist/runtime/fastlane.d.ts.map +1 -0
  220. package/dist/runtime/fastlane.js +1 -0
  221. package/dist/runtime/for.d.ts +52 -0
  222. package/dist/runtime/for.d.ts.map +1 -0
  223. package/dist/runtime/for.js +1 -0
  224. package/dist/runtime/hydration.d.ts +25 -0
  225. package/dist/runtime/hydration.d.ts.map +1 -0
  226. package/dist/runtime/operations.d.ts +39 -0
  227. package/dist/runtime/operations.d.ts.map +1 -0
  228. package/dist/runtime/operations.js +1 -0
  229. package/dist/runtime/resource-cell.d.ts +35 -0
  230. package/dist/runtime/resource-cell.d.ts.map +1 -0
  231. package/dist/runtime/resource-cell.js +1 -0
  232. package/dist/runtime/scheduler.d.ts +48 -0
  233. package/dist/runtime/scheduler.d.ts.map +1 -0
  234. package/dist/runtime/scheduler.js +1 -0
  235. package/dist/runtime/snapshot.d.ts +25 -0
  236. package/dist/runtime/snapshot.d.ts.map +1 -0
  237. package/dist/runtime/ssr-bridge.d.ts +10 -0
  238. package/dist/runtime/ssr-bridge.d.ts.map +1 -0
  239. package/dist/runtime/ssr-bridge.js +1 -0
  240. package/dist/runtime/state.d.ts +56 -0
  241. package/dist/runtime/state.d.ts.map +1 -0
  242. package/dist/runtime/state.js +1 -0
  243. package/dist/ssr/attrs.d.ts +26 -0
  244. package/dist/ssr/attrs.d.ts.map +1 -0
  245. package/dist/ssr/attrs.js +1 -0
  246. package/dist/ssr/context.d.ts +47 -0
  247. package/dist/ssr/context.d.ts.map +1 -0
  248. package/dist/ssr/context.js +1 -0
  249. package/dist/ssr/create-ssr.d.ts +19 -0
  250. package/dist/ssr/create-ssr.d.ts.map +1 -0
  251. package/dist/ssr/errors.d.ts +6 -0
  252. package/dist/ssr/errors.d.ts.map +1 -0
  253. package/dist/ssr/errors.js +1 -0
  254. package/dist/ssr/escape.d.ts +38 -0
  255. package/dist/ssr/escape.d.ts.map +1 -0
  256. package/dist/ssr/escape.js +1 -0
  257. package/dist/ssr/index.d.ts +18 -94
  258. package/dist/ssr/index.d.ts.map +1 -0
  259. package/dist/ssr/index.js +1 -1
  260. package/dist/ssr/render-keys.d.ts +39 -0
  261. package/dist/ssr/render-keys.d.ts.map +1 -0
  262. package/dist/ssr/render-keys.js +1 -0
  263. package/dist/ssr/sink.d.ts +23 -0
  264. package/dist/ssr/sink.d.ts.map +1 -0
  265. package/dist/ssr/sink.js +1 -0
  266. package/dist/ssr/stream-render.d.ts +7 -0
  267. package/dist/ssr/stream-render.d.ts.map +1 -0
  268. package/dist/ssr/stream-render.js +1 -0
  269. package/dist/ssr/types.d.ts +21 -0
  270. package/dist/ssr/types.d.ts.map +1 -0
  271. package/dist/vite/index.js +3 -1
  272. package/package.json +11 -10
  273. package/dist/chunk-37RC6ZT3.js +0 -1
  274. package/dist/chunk-3L6PFAJ3.js +0 -1
  275. package/dist/chunk-47D5SNYH.js +0 -1
  276. package/dist/chunk-4RTKQ7SC.js +0 -1
  277. package/dist/chunk-5PLQPS3O.js +0 -1
  278. package/dist/chunk-62D2TNHX.js +0 -1
  279. package/dist/chunk-BP2CKUO6.js +0 -1
  280. package/dist/chunk-D2JSJKCW.js +0 -1
  281. package/dist/chunk-EQ5S5GU4.js +0 -1
  282. package/dist/chunk-HGMOQ3I7.js +0 -1
  283. package/dist/chunk-HZKAD5DE.js +0 -1
  284. package/dist/chunk-ILZCMHZM.js +0 -2
  285. package/dist/chunk-NL44ANML.js +0 -2
  286. package/dist/chunk-YRY4OLQF.js +0 -1
  287. package/dist/component-AJMg1Gmv.d.ts +0 -177
  288. package/dist/jsx-dev-runtime.d.ts +0 -7
  289. package/dist/jsx-runtime.d.ts +0 -14
  290. package/dist/logger-NGZDJLVS.js +0 -1
  291. package/dist/main-EPE35NMW.js +0 -65
  292. package/dist/navigate-4VAVLF3A.js +0 -1
  293. package/dist/route-IVG3V65Y.js +0 -1
  294. package/dist/vite/index.d.ts +0 -17
@@ -1,24 +1,9 @@
1
- export { g as getSignal } from '../component-AJMg1Gmv.js';
2
- import '../jsx-CPjsGyEg.js';
3
-
4
- interface ResourceResult<T> {
5
- value: T | null;
6
- pending: boolean;
7
- error: Error | null;
8
- refresh(): void;
9
- }
10
1
  /**
11
- * Resource primitive simple, deterministic async primitive
12
- * Usage: resource(fn, deps)
13
- * - fn receives { signal }
14
- * - captures execution context once at creation (synchronous step only)
15
- * - executes at most once per generation; stale async results are ignored
16
- * - refresh() cancels in-flight execution, increments generation and re-runs
17
- * - exposes { value, pending, error, refresh }
18
- * - during SSR, async results are disallowed and will throw synchronously
2
+ * askr/resourcesasync data policy (resources)
3
+ *
4
+ * This tier exists to make async data intent explicit in import paths.
19
5
  */
20
- declare function resource<T>(fn: (opts: {
21
- signal: AbortSignal;
22
- }) => Promise<T> | T, deps?: unknown[]): ResourceResult<T>;
23
-
24
- export { type ResourceResult as DataResult, resource };
6
+ export { resource } from '../runtime/operations';
7
+ export type { ResourceResult as DataResult } from '../runtime/operations';
8
+ export { getSignal } from '../runtime/component';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/resources/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,YAAY,EAAE,cAAc,IAAI,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAE1E,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC"}
@@ -1 +1 @@
1
- import {a}from'../chunk-3L6PFAJ3.js';import {c,a as a$1}from'../chunk-YRY4OLQF.js';import {j,d as d$1,b,c as c$1}from'../chunk-ILZCMHZM.js';export{m as getSignal}from'../chunk-ILZCMHZM.js';import {a as a$2}from'../chunk-HGMOQ3I7.js';import'../chunk-BP2CKUO6.js';import'../chunk-37RC6ZT3.js';import'../chunk-62D2TNHX.js';var d=class{constructor(o,a,i){this.value=null;this.pending=true;this.error=null;this.generation=0;this.controller=null;this.deps=null;this.resourceFrame=null;this.subscribers=new Set;this.fn=o,this.deps=a?a.slice():null,this.resourceFrame=i,this.snapshot={value:null,pending:true,error:null,refresh:()=>this.refresh()};}subscribe(o){return this.subscribers.add(o),()=>this.subscribers.delete(o)}notifySubscribers(){this.snapshot.value=this.value,this.snapshot.pending=this.pending,this.snapshot.error=this.error;for(let o of this.subscribers)o();}start(o=false,a=true){let i=this.generation;this.controller?.abort();let l=new AbortController;this.controller=l,this.pending=true,this.error=null,a&&this.notifySubscribers();let u;try{u=c$1(this.resourceFrame,()=>this.fn({signal:l.signal}));}catch(t){this.pending=false,this.error=t,a&&this.notifySubscribers();return}if(!(u instanceof Promise)){this.value=u,this.pending=false,this.error=null,a&&this.notifySubscribers();return}o&&c().throwSSRDataMissing(),u.then(t=>{this.generation===i&&this.controller===l&&(this.value=t,this.pending=false,this.error=null,this.notifySubscribers());}).catch(t=>{if(this.generation===i&&this.controller===l){this.pending=false,this.error=t;try{this.ownerName?a$2.error(`[Askr] Async resource error in ${this.ownerName}:`,t):a$2.error("[Askr] Async resource error:",t);}catch{}this.notifySubscribers();}});}refresh(){this.generation++,this.controller?.abort(),this.start();}abort(){this.controller?.abort();}};function x(b$1,o=[]){let a$2=j(),i=a$2;if(!a$2){let r=c(),e=r.getCurrentRenderData();if(e){let n=r.getNextKey();return n in e||r.throwSSRDataMissing(),{value:e[n],pending:false,error:null,refresh:()=>{}}}throw r.getCurrentSSRContext()&&r.throwSSRDataMissing(),new Error("[Askr] resource() must be called during component render inside an app. Do not create resources at module scope or outside render.")}let l=c(),u=l.getCurrentRenderData();if(u){let r=l.getNextKey();r in u||l.throwSSRDataMissing();let e=u[r],p=a({cell:void 0,snapshot:{value:e,pending:false,error:null,refresh:()=>{}}}),n=p();return n.snapshot.value=e,n.snapshot.pending=false,n.snapshot.error=null,p.set(n),n.snapshot}let t=a({cell:void 0,snapshot:{value:null,pending:true,error:null,refresh:()=>{}}}),c$1=t();if(!c$1.cell){let r=d$1(),e=new d(b$1,o,r);e.ownerName=i.fn?.name||"<anonymous>",c$1.cell=e,c$1.snapshot=e.snapshot;let p=e.subscribe(()=>{let n=t();n.snapshot.value=e.snapshot.value,n.snapshot.pending=e.snapshot.pending,n.snapshot.error=e.snapshot.error,t.set(n);try{i._enqueueRun?.();}catch{}});if(i.cleanupFns.push(()=>{p(),e.abort();}),i.ssr){if(e.start(true,false),!e.pending){let n=t();n.snapshot.value=e.value,n.snapshot.pending=e.pending,n.snapshot.error=e.error;}}else b.enqueue(()=>{try{e.start(!1,!1);}catch(n){let h=t();h.snapshot.value=e.value,h.snapshot.pending=e.pending,h.snapshot.error=n??null,t.set(h),i._enqueueRun?.();return}if(!e.pending){let n=t();n.snapshot.value=e.value,n.snapshot.pending=e.pending,n.snapshot.error=e.error,t.set(n),i._enqueueRun?.();}});}let s=c$1.cell;if(!s.deps||s.deps.length!==o.length||s.deps.some((r,e)=>r!==o[e])){s.deps=o.slice(),s.generation++,s.pending=true,s.error=null;try{if(i.ssr){if(s.start(!0,!1),!s.pending){let r=t();r.snapshot.value=s.value,r.snapshot.pending=s.pending,r.snapshot.error=s.error;}}else b.enqueue(()=>{if(s.start(!1,!1),!s.pending){let r=t();r.snapshot.value=s.value,r.snapshot.pending=s.pending,r.snapshot.error=s.error,t.set(r),i._enqueueRun?.();}});}catch(r){if(r instanceof a$1)throw r;s.error=r,s.pending=false;let e=t();e.snapshot.value=s.value,e.snapshot.pending=s.pending,e.snapshot.error=s.error;}}return c$1.snapshot}export{x as resource};
1
+ import{resource as o}from"../runtime/operations.js";import{getSignal as f}from"../runtime/component.js";export{f as getSignal,o as resource};
@@ -1,89 +1,10 @@
1
- import { R as Route, a as RouteSnapshot, b as RouteHandler } from '../router-DaGtH1Sq.js';
2
- export { c as RouteMatch, d as RouteQuery } from '../router-DaGtH1Sq.js';
3
- export { l as layout } from '../layout-BINPv-nz.js';
4
-
5
1
  /**
6
- * Route definition and matching
7
- * Supports dynamic route registration for micro frontends
8
- *
9
- * Optimization: Index by depth but maintain insertion order within each depth
2
+ * askr/router routing surface (explicit tier)
10
3
  */
11
-
12
- declare function route(): RouteSnapshot;
13
- declare function route(path: string, handler?: RouteHandler, namespace?: string): void;
14
- /**
15
- * Get all registered routes
16
- */
17
- declare function getRoutes(): Route[];
18
- /**
19
- * Clear all registered routes (mainly for testing)
20
- */
21
- declare function clearRoutes(): void;
22
-
23
- /**
24
- * Client-side navigation with History API
25
- */
26
-
27
- /**
28
- * Navigate to a new path
29
- * Updates URL, resolves route, and re-mounts app with new handler
30
- */
31
- declare function navigate(path: string): void;
32
-
33
- /**
34
- * Link component for client-side navigation
35
- */
36
- interface LinkProps {
37
- href: string;
38
- class?: string;
39
- children?: unknown;
40
- /**
41
- * Optional rel attribute for link relationships.
42
- * Common values: "noopener", "noreferrer", "nofollow"
43
- */
44
- rel?: string;
45
- /**
46
- * Optional target attribute.
47
- * Use "_blank" for new tab/window.
48
- */
49
- target?: string;
50
- /**
51
- * Optional aria-current attribute for indicating current page/location.
52
- * Use "page" for the current page in navigation.
53
- */
54
- 'aria-current'?: 'page' | 'step' | 'location' | 'date' | 'time' | 'true' | 'false';
55
- /**
56
- * Optional aria-label for accessibility when link text isn't descriptive enough.
57
- */
58
- 'aria-label'?: string;
59
- }
60
- /**
61
- * Link component that prevents default navigation and uses navigate()
62
- * Provides declarative way to navigate between routes
63
- *
64
- * Accessibility features:
65
- * - Proper semantic <a> element (not a button)
66
- * - Supports aria-current for indicating active page
67
- * - Supports aria-label for descriptive labels
68
- * - Keyboard accessible (Enter key handled by native <a> element)
69
- *
70
- * Respects native browser behaviors:
71
- * - Middle-click (opens in new tab)
72
- * - Ctrl/Cmd+click (opens in new tab)
73
- * - Shift+click (opens in new window)
74
- * - Alt+click (downloads link)
75
- * - Right-click context menu
76
- *
77
- * Best practices:
78
- * - Use target="_blank" with rel="noopener noreferrer" for external links
79
- * - Use aria-current="page" for the current page in navigation
80
- * - Provide descriptive link text or aria-label
81
- *
82
- * Uses applyInteractionPolicy to enforce pit-of-success principles:
83
- * - Interaction behavior centralized in foundations
84
- * - Keyboard handling automatic
85
- * - Composable via mergeProps
86
- */
87
- declare function Link({ href, class: className, children, rel, target, 'aria-current': ariaCurrent, 'aria-label': ariaLabel, }: LinkProps): JSX.Element;
88
-
89
- export { Link, type LinkProps, Route, RouteHandler, RouteSnapshot, clearRoutes, getRoutes, navigate, route };
4
+ export { route, getRoutes, clearRoutes } from './route';
5
+ export type { Route, RouteHandler, RouteSnapshot, RouteMatch, RouteQuery, } from '../common/router';
6
+ export { navigate } from './navigate';
7
+ export { Link } from '../components/link';
8
+ export type { LinkProps } from '../components/link';
9
+ export { layout } from '../foundations/structures/layout';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/router/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACxD,YAAY,EACV,KAAK,EACL,YAAY,EACZ,aAAa,EACb,UAAU,EACV,UAAU,GACX,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,YAAY,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC"}
@@ -1 +1 @@
1
- import {b}from'../chunk-EQ5S5GU4.js';export{b as navigate}from'../chunk-EQ5S5GU4.js';import {i,b as b$2}from'../chunk-HZKAD5DE.js';export{k as layout}from'../chunk-HZKAD5DE.js';export{i as clearRoutes,f as getRoutes,e as route}from'../chunk-NL44ANML.js';import'../chunk-D2JSJKCW.js';import'../chunk-ILZCMHZM.js';import'../chunk-HGMOQ3I7.js';import {b as b$1}from'../chunk-BP2CKUO6.js';import'../chunk-37RC6ZT3.js';import'../chunk-62D2TNHX.js';function k({href:r,class:s,children:u,rel:l,target:o,"aria-current":p,"aria-label":c}){let m=i({isNative:true,disabled:false,onPress:f=>{let t=f;(t.button??0)!==0||t.ctrlKey||t.metaKey||t.shiftKey||t.altKey||o||(t.preventDefault(),b(r));}});return b$1("a",b$2(m,{href:r,class:s,rel:l,target:o,"aria-current":p,"aria-label":c,children:u}))}export{k as Link};
1
+ import{clearRoutes as r,getRoutes as t,route as a}from"./route.js";import{navigate as m}from"./navigate.js";import{Link as u}from"../components/link.js";import{layout as g}from"../foundations/structures/layout.js";export{u as Link,r as clearRoutes,t as getRoutes,g as layout,m as navigate,a as route};
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Path matching and parameter extraction
3
+ */
4
+ export interface MatchResult {
5
+ matched: boolean;
6
+ params: Record<string, string>;
7
+ }
8
+ /**
9
+ * Match a path against a route pattern and extract params
10
+ *
11
+ * @example
12
+ * match('/users/123', '/users/{id}')
13
+ * // → { matched: true, params: { id: '123' } }
14
+ *
15
+ * match('/posts/hello-world/edit', '/posts/{slug}/{action}')
16
+ * // → { matched: true, params: { slug: 'hello-world', action: 'edit' } }
17
+ *
18
+ * match('/users', '/posts/{id}')
19
+ * // → { matched: false, params: {} }
20
+ */
21
+ export declare function match(path: string, pattern: string): MatchResult;
22
+ //# sourceMappingURL=match.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"match.d.ts","sourceRoot":"","sources":["../../src/router/match.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,WAAW,CAiDhE"}
@@ -0,0 +1 @@
1
+ function h(n,s){const o=n.endsWith("/")&&n!=="/"?n.slice(0,-1):n,c=s.endsWith("/")&&s!=="/"?s.slice(0,-1):s,a=o.split("/").filter(Boolean),e=c.split("/").filter(Boolean);if(e.length===1&&e[0]==="*")return{matched:!0,params:{"*":a.length>1?o:a[0]}};if(a.length!==e.length)return{matched:!1,params:{}};const l={};for(let r=0;r<e.length;r++){const t=e[r],i=a[r];if(t.startsWith("{")&&t.endsWith("}")){const m=t.slice(1,-1);l[m]=decodeURIComponent(i)}else if(t==="*")l["*"]=i;else if(t!==i)return{matched:!1,params:{}}}return{matched:!0,params:l}}export{h as match};
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Client-side navigation with History API
3
+ */
4
+ import { type ComponentInstance } from '../runtime/component';
5
+ /** Register the current app instance (called by createSPA/hydrateSPA). */
6
+ export declare function registerAppInstance(instance: ComponentInstance, _path: string): void;
7
+ /**
8
+ * Navigate to a new path
9
+ * Updates URL, resolves route, and re-mounts app with new handler
10
+ */
11
+ export declare function navigate(path: string): void;
12
+ /**
13
+ * Setup popstate listener for browser navigation
14
+ */
15
+ export declare function initializeNavigation(): void;
16
+ /**
17
+ * Cleanup navigation listeners
18
+ */
19
+ export declare function cleanupNavigation(): void;
20
+ //# sourceMappingURL=navigate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigate.d.ts","sourceRoot":"","sources":["../../src/router/navigate.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,sBAAsB,CAAC;AAM9B,0EAA0E;AAC1E,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,iBAAiB,EAC3B,KAAK,EAAE,MAAM,GACZ,IAAI,CAON;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CA8C3C;AAsCD;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAI3C;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAIxC"}
@@ -0,0 +1 @@
1
+ import{lockRouteRegistration as f,resolveRoute as r}from"./route.js";import{cleanupComponent as i,mountComponent as a}from"../runtime/component.js";import"../dev/logger.js";let e=null;function c(t,n){e=t,f()}function w(t){if(typeof window>"u")return;const n=r(t);n&&(window.history.pushState({path:t},"",t),e&&(i(e),e.fn=n.handler,e.props=n.params,e.stateValues=[],e.expectedStateIndices=[],e.firstRenderComplete=!1,e.stateIndexCheck=-1,e.evaluationGeneration++,e.notifyUpdate=null,e.abortController=new AbortController,a(e)))}function l(t){const n=window.location.pathname;if(!e)return;const o=r(n);o&&(i(e),e.fn=o.handler,e.props=o.params,e.stateValues=[],e.expectedStateIndices=[],e.firstRenderComplete=!1,e.stateIndexCheck=-1,e.evaluationGeneration++,e.notifyUpdate=null,e.abortController=new AbortController,a(e))}function m(){typeof window<"u"&&window.addEventListener("popstate",l)}function v(){typeof window<"u"&&window.removeEventListener("popstate",l)}export{v as cleanupNavigation,m as initializeNavigation,w as navigate,c as registerAppInstance};
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Route definition and matching
3
+ * Supports dynamic route registration for micro frontends
4
+ *
5
+ * Optimization: Index by depth but maintain insertion order within each depth
6
+ */
7
+ export type { RouteHandler, Route, ResolvedRoute, RouteMatch, RouteQuery, RouteSnapshot, } from '../common/router';
8
+ import type { RouteHandler, Route, ResolvedRoute, RouteSnapshot } from '../common/router';
9
+ export declare function setServerLocation(url: string | null): void;
10
+ export declare function lockRouteRegistration(): void;
11
+ export declare function _lockRouteRegistrationForTests(): void;
12
+ export declare function _unlockRouteRegistrationForTests(): void;
13
+ export declare function route(): RouteSnapshot;
14
+ export declare function route(path: string, handler?: RouteHandler, namespace?: string): void;
15
+ /**
16
+ * Get all registered routes
17
+ */
18
+ export declare function getRoutes(): Route[];
19
+ /**
20
+ * Get routes for a specific namespace
21
+ */
22
+ export declare function getNamespaceRoutes(namespace: string): Route[];
23
+ /**
24
+ * Unload all routes from a namespace (for MFE unmounting)
25
+ */
26
+ export declare function unloadNamespace(namespace: string): number;
27
+ /**
28
+ * Clear all registered routes (mainly for testing)
29
+ */
30
+ export declare function clearRoutes(): void;
31
+ /**
32
+ * RouteDescriptor type — used by `registerRoute` for nested descriptors.
33
+ *
34
+ * Note: `registerRouteTree` helper was removed; prefer explicit `route()` registrations.
35
+ */
36
+ export type RouteDescriptor = {
37
+ path: string;
38
+ handler?: RouteHandler | unknown;
39
+ children?: RouteDescriptor[];
40
+ _isDescriptor?: true;
41
+ };
42
+ export declare function registerRoute(path: string, handler?: unknown, ...children: Array<RouteDescriptor | undefined>): RouteDescriptor;
43
+ /**
44
+ * Get all loaded namespaces (MFE identifiers)
45
+ */
46
+ export declare function getLoadedNamespaces(): string[];
47
+ /**
48
+ * Resolve a path to a route handler with optimized lookup
49
+ * Routes are matched by specificity: literals > parameters > wildcards > catch-all
50
+ */
51
+ export declare function resolveRoute(pathname: string): ResolvedRoute | null;
52
+ //# sourceMappingURL=route.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../src/router/route.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,YAAY,EACV,YAAY,EACZ,KAAK,EACL,aAAa,EACb,UAAU,EACV,UAAU,EACV,aAAa,GACd,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EACV,YAAY,EACZ,KAAK,EACL,aAAa,EAGb,aAAa,EACd,MAAM,kBAAkB,CAAC;AAqE1B,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAE1D;AAmHD,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C;AAGD,wBAAgB,8BAA8B,IAAI,IAAI,CAErD;AAED,wBAAgB,gCAAgC,IAAI,IAAI,CAEvD;AAED,wBAAgB,KAAK,IAAI,aAAa,CAAC;AACvC,wBAAgB,KAAK,CACnB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,YAAY,EACtB,SAAS,CAAC,EAAE,MAAM,GACjB,IAAI,CAAC;AAoGR;;GAEG;AACH,wBAAgB,SAAS,IAAI,KAAK,EAAE,CAEnC;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,KAAK,EAAE,CAE7D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAuBzD;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAMlC;AAED;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC;IACjC,QAAQ,CAAC,EAAE,eAAe,EAAE,CAAC;IAC7B,aAAa,CAAC,EAAE,IAAI,CAAC;CACtB,CAAC;AAiCF,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,OAAO,EACjB,GAAG,QAAQ,EAAE,KAAK,CAAC,eAAe,GAAG,SAAS,CAAC,GAC9C,eAAe,CAuDjB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,EAAE,CAE9C;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAwDnE"}
@@ -0,0 +1 @@
1
+ import{match as w}from"./match.js";import{getCurrentComponentInstance as S}from"../runtime/component.js";import{getExecutionModel as W}from"../runtime/execution-model.js";const a=[],p=new Set,L=Symbol.for("__ASKR_HAS_ROUTES__");function R(e){try{const r=globalThis;r[L]=e}catch{}}R(!1);const f=new Map;function _(e){const r=e.endsWith("/")&&e!=="/"?e.slice(0,-1):e;return r==="/"?0:r.split("/").filter(Boolean).length}function b(e){const r=e.endsWith("/")&&e!=="/"?e.slice(0,-1):e;if(r==="/*")return 0;const o=r.split("/").filter(Boolean);let i=0;for(const t of o)t.startsWith("{")&&t.endsWith("}")?i+=2:t==="*"?i+=1:i+=3;return i}let y=null;function H(e){y=e}function N(e){try{const r=new URL(e,"http://localhost");return{pathname:r.pathname,search:r.search,hash:r.hash}}catch{return{pathname:"/",search:"",hash:""}}}function d(e){if(e&&typeof e=="object"&&!Object.isFrozen(e)){Object.freeze(e);for(const r of Object.keys(e)){const o=e[r];o&&typeof o=="object"&&d(o)}}return e}function P(e){const r=new URLSearchParams(e||""),o=new Map;for(const[t,n]of r.entries()){const s=o.get(t);s?s.push(n):o.set(t,[n])}return d({get(t){const n=o.get(t);return n?n[0]:null},getAll(t){const n=o.get(t);return n?[...n]:[]},has(t){return o.has(t)},toJSON(){const t={};for(const[n,s]of o.entries())t[n]=s.length>1?[...s]:s[0];return t}})}function A(e){const r=x(),o=[];function i(t){const n=t.endsWith("/")&&t!=="/"?t.slice(0,-1):t;if(n==="/*")return 0;const s=n.split("/").filter(Boolean);let l=0;for(const c of s)c.startsWith("{")&&c.endsWith("}")?l+=2:c==="*"?l+=1:l+=3;return l}for(const t of r){const n=w(e,t.path);n.matched&&o.push({pattern:t.path,params:n.params,name:t.name,namespace:t.namespace,specificity:i(t.path)})}return o.sort((t,n)=>n.specificity-t.specificity),o.map(t=>({path:t.pattern,params:d({...t.params}),name:t.name,namespace:t.namespace}))}let h=!1;function J(){h=!0}function M(){h=!0}function q(){h=!1}function z(e,r,o){if(W()==="islands")throw new Error("Routes are not supported with islands. Use createSPA (client) or createSSR (server) instead.");if(typeof e>"u"){const l=S();if(!l)throw new Error("route() can only be called during component render execution. Call route() from inside your component function.");let c="/",u="",m="";if(typeof window<"u"&&window.location)c=window.location.pathname||"/",u=window.location.search||"",m=window.location.hash||"";else if(y){const g=N(y);c=g.pathname,u=g.search,m=g.hash}const k=d({...l.props||{}}),v=P(u),O=A(c);return Object.freeze({path:c,params:k,query:v,hash:m||null,matches:Object.freeze(O)})}const i=S();if(i&&i.ssr)throw new Error("route() cannot be called during SSR rendering. Register routes at module load time instead.");if(h)throw new Error("Route registration is locked after app startup. Register routes at module load time before calling createSPA or createSSR.");if(typeof r!="function")throw new Error("route(path, handler) requires a function handler that returns a VNode (e.g. () => <Page />). Passing JSX elements or VNodes directly is not supported.");const t={path:e,handler:r,namespace:o};a.push(t),R(!0);const n=_(e);let s=f.get(n);s||(s=[],f.set(n,s)),s.push(t),o&&p.add(o)}function x(){return[...a]}function C(e){return a.filter(r=>r.namespace===e)}function D(e){const r=a.length;for(let o=a.length-1;o>=0;o--)if(a[o].namespace===e){const i=a[o];a.splice(o,1);const t=_(i.path),n=f.get(t);if(n){const s=n.indexOf(i);s>=0&&n.splice(s,1)}}return p.delete(e),r-a.length}function V(){a.length=0,p.clear(),f.clear(),h=!1,R(!1)}function E(e){if(e!=null&&typeof e=="function")return(r,o)=>{try{return e(r,o)}catch{return e(r)}}}function B(e,r,...o){const i=!e.startsWith("/"),t={path:e,handler:r,children:o.filter(Boolean),_isDescriptor:!0};if(!i){const n=E(r);if(r!=null&&!n)throw new Error("registerRoute(path, handler) requires a function handler. Passing JSX elements or VNodes directly is not supported.");n&&z(e,n);for(const s of t.children||[]){const c=`${e==="/"?"":e.replace(/\/$/,"")}/${s.path.replace(/^\//,"")}`.replace(/\/\//g,"/");if(s.handler){const u=E(s.handler);if(!u)throw new Error("registerRoute child handler must be a function. Passing JSX elements directly is not supported.");u&&z(c,u)}s.children&&s.children.length&&B(c,null,...s.children)}return t}return t}function X(){return Array.from(p)}function $(e){const r=e.endsWith("/")&&e!=="/"?e.slice(0,-1):e,o=r==="/"?0:r.split("/").filter(Boolean).length,i=[],t=f.get(o);if(t)for(const n of t){const s=w(e,n.path);s.matched&&i.push({route:n,specificity:b(n.path),params:s.params})}for(const n of a){if(t?.includes(n))continue;const s=w(e,n.path);s.matched&&i.push({route:n,specificity:b(n.path),params:s.params})}if(i.sort((n,s)=>s.specificity-n.specificity),i.length>0){const n=i[0];return{handler:n.route.handler,params:n.params}}return null}export{M as _lockRouteRegistrationForTests,q as _unlockRouteRegistrationForTests,V as clearRoutes,X as getLoadedNamespaces,C as getNamespaceRoutes,x as getRoutes,J as lockRouteRegistration,B as registerRoute,$ as resolveRoute,z as route,H as setServerLocation,D as unloadNamespace};
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Component instance lifecycle management
3
+ * Internal only — users never see this
4
+ */
5
+ import { type State } from './state';
6
+ import type { Props } from '../common/props';
7
+ import type { ComponentFunction } from '../common/component';
8
+ import { type ContextFrame } from './context';
9
+ export type { ComponentFunction } from '../common/component';
10
+ export interface ComponentInstance {
11
+ id: string;
12
+ fn: ComponentFunction;
13
+ props: Props;
14
+ target: Element | null;
15
+ mounted: boolean;
16
+ abortController: AbortController;
17
+ ssr?: boolean;
18
+ cleanupStrict?: boolean;
19
+ stateValues: State<unknown>[];
20
+ evaluationGeneration: number;
21
+ notifyUpdate: (() => void) | null;
22
+ _pendingFlushTask?: () => void;
23
+ _pendingRunTask?: () => void;
24
+ _enqueueRun?: () => void;
25
+ stateIndexCheck: number;
26
+ expectedStateIndices: number[];
27
+ firstRenderComplete: boolean;
28
+ mountOperations: Array<() => void | (() => void) | Promise<void | (() => void)>>;
29
+ cleanupFns: Array<() => void>;
30
+ hasPendingUpdate: boolean;
31
+ ownerFrame: ContextFrame | null;
32
+ isRoot?: boolean;
33
+ _currentRenderToken?: number;
34
+ lastRenderToken?: number;
35
+ _pendingReadStates?: Set<State<unknown>>;
36
+ _lastReadStates?: Set<State<unknown>>;
37
+ _placeholder?: Comment;
38
+ }
39
+ export declare function createComponentInstance(id: string, fn: ComponentFunction, props: Props, target: Element | null): ComponentInstance;
40
+ export declare function getCurrentComponentInstance(): ComponentInstance | null;
41
+ export declare function setCurrentComponentInstance(instance: ComponentInstance | null): void;
42
+ export declare function registerMountOperation(operation: () => void | (() => void) | Promise<void | (() => void)>): void;
43
+ export declare function mountInstanceInline(instance: ComponentInstance, target: Element | null): void;
44
+ /**
45
+ * Execute a component's render function synchronously.
46
+ * Returns either a vnode/promise immediately (does NOT render).
47
+ * Rendering happens separately through runComponent.
48
+ */
49
+ export declare function renderComponentInline(instance: ComponentInstance): unknown | Promise<unknown>;
50
+ /**
51
+ * Public entry point: Execute component with full lifecycle (execute + render)
52
+ * Handles both initial mount and re-execution. Always enqueues through scheduler.
53
+ * Single entry point to avoid lifecycle divergence.
54
+ */
55
+ export declare function executeComponent(instance: ComponentInstance): void;
56
+ export declare function getCurrentInstance(): ComponentInstance | null;
57
+ /**
58
+ * Get the abort signal for the current component
59
+ * Used to cancel async operations on unmount/navigation
60
+ *
61
+ * The signal is guaranteed to be aborted when:
62
+ * - Component unmounts
63
+ * - Navigation occurs (different route)
64
+ * - Parent is destroyed
65
+ *
66
+ * IMPORTANT: getSignal() must be called during component render execution.
67
+ * It captures the current component instance from context.
68
+ *
69
+ * @returns AbortSignal that will be aborted when component unmounts
70
+ * @throws Error if called outside component execution
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * // ✅ Correct: called during render, used in async operation
75
+ * export async function UserPage({ id }: { id: string }) {
76
+ * const signal = getSignal();
77
+ * const user = await fetch(`/api/users/${id}`, { signal });
78
+ * return <div>{user.name}</div>;
79
+ * }
80
+ *
81
+ * // ✅ Correct: passed to event handler
82
+ * export function Button() {
83
+ * const signal = getSignal();
84
+ * return {
85
+ * type: 'button',
86
+ * props: {
87
+ * onClick: async () => {
88
+ * const data = await fetch(url, { signal });
89
+ * }
90
+ * }
91
+ * };
92
+ * }
93
+ *
94
+ * // ❌ Wrong: called outside component context
95
+ * const signal = getSignal(); // Error: not in component
96
+ * ```
97
+ */
98
+ export declare function getSignal(): AbortSignal;
99
+ /**
100
+ * Finalize read subscriptions for an instance after a successful commit.
101
+ * - Update per-state readers map to point to this instance's last committed token
102
+ * - Remove this instance from states it no longer reads
103
+ * This is deterministic and runs synchronously with commit to ensure
104
+ * subscribers are only notified when they actually read a state in their
105
+ * last committed render.
106
+ */
107
+ export declare function finalizeReadSubscriptions(instance: ComponentInstance): void;
108
+ export declare function getNextStateIndex(): number;
109
+ export declare function getCurrentStateIndex(): number;
110
+ export declare function resetStateIndex(): void;
111
+ export declare function setStateIndex(value: number): void;
112
+ /**
113
+ * Mount a component instance.
114
+ * This is just an alias to executeComponent() to maintain API compatibility.
115
+ * All lifecycle logic is unified in executeComponent().
116
+ */
117
+ export declare function mountComponent(instance: ComponentInstance): void;
118
+ /**
119
+ * Clean up component — abort pending operations
120
+ * Called on unmount or route change
121
+ */
122
+ export declare function cleanupComponent(instance: ComponentInstance): void;
123
+ //# sourceMappingURL=component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/runtime/component.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,WAAW,CAAC;AAInB,YAAY,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,iBAAiB,CAAC;IACtB,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,EAAE,eAAe,CAAC;IACjC,GAAG,CAAC,EAAE,OAAO,CAAC;IAEd,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;IAC9B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,YAAY,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC;IAElC,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAC;IAC/B,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,eAAe,EAAE,KAAK,CACpB,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,CACzD,CAAC;IACF,UAAU,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC;IAC9B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,UAAU,EAAE,YAAY,GAAG,IAAI,CAAC;IAChC,MAAM,CAAC,EAAE,OAAO,CAAC;IAGjB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,kBAAkB,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IACzC,eAAe,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAItC,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,wBAAgB,uBAAuB,CACrC,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,iBAAiB,EACrB,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,OAAO,GAAG,IAAI,GACrB,iBAAiB,CAyDnB;AAMD,wBAAgB,2BAA2B,IAAI,iBAAiB,GAAG,IAAI,CAEtE;AAGD,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,GACjC,IAAI,CAEN;AASD,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,GAClE,IAAI,CAgBN;AA4BD,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,iBAAiB,EAC3B,MAAM,EAAE,OAAO,GAAG,IAAI,GACrB,IAAI,CAuBN;AAoND;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,iBAAiB,GAC1B,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CA4B5B;AAmFD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAUlE;AAED,wBAAgB,kBAAkB,IAAI,iBAAiB,GAAG,IAAI,CAE7D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAgB,SAAS,IAAI,WAAW,CAQvC;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAgC3E;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C;AAED,wBAAgB,eAAe,IAAI,IAAI,CAEtC;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAEjD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAEhE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CA8ClE"}
@@ -0,0 +1 @@
1
+ import{globalScheduler as c}from"./scheduler.js";import{withContext as k}from"./context.js";import{logger as f}from"../dev/logger.js";import{incDevCounter as m,setDevValue as _}from"./dev-namespace.js";import{isBulkCommitActive as A}from"./fastlane.js";import"../renderer/index.js";import{evaluate as g}from"../renderer/evaluate.js";import{cleanupInstancesUnder as h}from"../renderer/cleanup.js";function P(e,t,o,n){const r={id:e,fn:t,props:o,target:n,mounted:!1,abortController:new AbortController,stateValues:[],evaluationGeneration:0,notifyUpdate:null,_pendingFlushTask:void 0,_pendingRunTask:void 0,_enqueueRun:void 0,stateIndexCheck:-1,expectedStateIndices:[],firstRenderComplete:!1,mountOperations:[],cleanupFns:[],hasPendingUpdate:!1,ownerFrame:null,ssr:!1,cleanupStrict:!1,isRoot:!1,_currentRenderToken:void 0,lastRenderToken:0,_pendingReadStates:new Set,_lastReadStates:new Set};return r._pendingRunTask=()=>{r.hasPendingUpdate=!1,C(r)},r._enqueueRun=()=>{r.hasPendingUpdate||(r.hasPendingUpdate=!0,c.enqueue(r._pendingRunTask))},r._pendingFlushTask=()=>{r.hasPendingUpdate=!1,r._enqueueRun?.()},r}let u=null,i=0;function v(){return u}function L(e){u=e}function q(e){const t=v();if(t){if(A())return;t.mountOperations.push(e)}}function S(e){if(e.isRoot){for(const t of e.mountOperations){const o=t();o instanceof Promise?o.then(n=>{typeof n=="function"&&e.cleanupFns.push(n)}):typeof o=="function"&&e.cleanupFns.push(o)}e.mountOperations=[]}}function D(e,t){e.target=t;try{t instanceof Element&&(t.__ASKR_INSTANCE=e)}catch(n){}e.notifyUpdate=e._enqueueRun;const o=!e.mounted;e.mounted=!0,o&&e.mountOperations.length>0&&S(e)}let R=0;function C(e){e.notifyUpdate=e._enqueueRun,e._currentRenderToken=++R,e._pendingReadStates=new Set;const t=e.target?e.target.innerHTML:"",o=w(e);if(o instanceof Promise)throw new Error("Async components are not supported. Components must be synchronous.");{const n=globalThis.__ASKR_FASTLANE;try{if(n?.tryRuntimeFastLaneSync?.(e,o))return}catch{}c.enqueue(()=>{if(!e.target&&e._placeholder){if(o==null){p(e);return}const r=e._placeholder,a=r.parentNode;if(!a){f.warn("[Askr] placeholder no longer in DOM, cannot render component");return}const l=document.createElement("div"),s=u;u=e;try{g(o,l),a.replaceChild(l,r),e.target=l,e._placeholder=void 0,l.__ASKR_INSTANCE=e,p(e)}finally{u=s}return}if(e.target){let r=[];try{const a=!e.mounted,l=u;u=e,r=Array.from(e.target.childNodes);try{g(o,e.target)}catch(s){try{const d=Array.from(e.target.childNodes);for(const y of d)try{h(y)}catch(T){f.warn("[Askr] error cleaning up failed commit children:",T)}}catch(d){}try{m("__DOM_REPLACE_COUNT"),_("__LAST_DOM_REPLACE_STACK_COMPONENT_RESTORE",new Error().stack)}catch(d){}throw e.target.replaceChildren(...r),s}finally{u=l}p(e),e.mounted=!0,a&&e.mountOperations.length>0&&S(e)}catch(a){try{const l=Array.from(e.target.childNodes);for(const s of l)try{h(s)}catch(d){f.warn("[Askr] error cleaning up partial children during rollback:",d)}}catch(l){}try{try{m("__DOM_REPLACE_COUNT"),_("__LAST_DOM_REPLACE_STACK_COMPONENT_ROLLBACK",new Error().stack)}catch(l){}e.target.replaceChildren(...r)}catch{e.target.innerHTML=t}throw a}}})}}function K(e){const t=e._currentRenderToken!==void 0,o=e._currentRenderToken,n=e._pendingReadStates;t||(e._currentRenderToken=++R,e._pendingReadStates=new Set);try{const r=w(e);return t||p(e),r}finally{e._currentRenderToken=o,e._pendingReadStates=n??new Set}}function w(e){e.stateIndexCheck=-1;for(const t of e.stateValues)t&&(t._hasBeenRead=!1);e._pendingReadStates=new Set,u=e,i=0;try{const o={signal:e.abortController.signal},n={parent:e.ownerFrame,values:null},r=k(n,()=>e.fn(e.props,o)),a=Date.now()-0;a>5&&f.warn(`[askr] Slow render detected: ${a}ms. Consider optimizing component performance.`),e.firstRenderComplete||(e.firstRenderComplete=!0);for(let l=0;l<e.stateValues.length;l++){const s=e.stateValues[l];if(s&&!s._hasBeenRead)try{const d=e.fn?.name||"<anonymous>";f.warn(`[askr] Unused state variable detected in ${d} at index ${l}. State should be read during render or removed.`)}catch{f.warn("[askr] Unused state variable detected. State should be read during render or removed.")}}return r}finally{u=null}}function E(e){e.abortController=new AbortController,e.notifyUpdate=e._enqueueRun,c.enqueue(()=>C(e))}function B(){return u}function V(){if(!u)throw new Error("getSignal() can only be called during component render execution. Ensure you are calling this from inside your component function.");return u.abortController.signal}function p(e){const t=e._pendingReadStates??new Set,o=e._lastReadStates??new Set,n=e._currentRenderToken;if(n!==void 0){for(const r of o)if(!t.has(r)){const a=r._readers;a&&a.delete(e)}e.lastRenderToken=n;for(const r of t){let a=r._readers;a||(a=new Map,r._readers=a),a.set(e,e.lastRenderToken??0)}e._lastReadStates=t,e._pendingReadStates=new Set,e._currentRenderToken=void 0}}function $(){return i++}function z(){return i}function H(){i=0}function G(e){i=e}function j(e){E(e)}function J(e){const t=[];for(const o of e.cleanupFns)try{o()}catch(n){e.cleanupStrict&&t.push(n)}if(e.cleanupFns=[],t.length>0)throw new AggregateError(t,`Cleanup failed for component ${e.id}`);if(e._lastReadStates){for(const o of e._lastReadStates){const n=o._readers;n&&n.delete(e)}e._lastReadStates=new Set}e.abortController.abort(),e.notifyUpdate=null,e.mounted=!1}export{J as cleanupComponent,P as createComponentInstance,E as executeComponent,p as finalizeReadSubscriptions,v as getCurrentComponentInstance,B as getCurrentInstance,z as getCurrentStateIndex,$ as getNextStateIndex,V as getSignal,j as mountComponent,D as mountInstanceInline,q as registerMountOperation,K as renderComponentInline,H as resetStateIndex,L as setCurrentComponentInstance,G as setStateIndex};
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Context system: lexical scope + render-time snapshots
3
+ *
4
+ * CORE SEMANTIC (Option A — Snapshot-Based):
5
+ * ============================================
6
+ * An async resource observes the context of the render that created it.
7
+ * Context changes only take effect via re-render, not magically mid-await.
8
+ *
9
+ * This ensures:
10
+ * - Deterministic behavior
11
+ * - Concurrency safety
12
+ * - Replayable execution
13
+ * - Debuggability
14
+ *
15
+ * INVARIANTS:
16
+ * - readContext() only works during component render (has currentContextFrame)
17
+ * - Each render captures a context snapshot
18
+ * - Async continuations see the snapshot from render start (frozen)
19
+ * - Provider (Scope) creates a new frame that shadows parent
20
+ * - Context updates require re-render to take effect
21
+ */
22
+ import type { JSXElement } from '../common/jsx';
23
+ export type ContextKey = symbol;
24
+ export interface Context<T> {
25
+ readonly key: ContextKey;
26
+ readonly defaultValue: T;
27
+ readonly Scope: (props: {
28
+ value: unknown;
29
+ children?: unknown;
30
+ }) => JSXElement;
31
+ }
32
+ export interface ContextFrame {
33
+ parent: ContextFrame | null;
34
+ values: Map<ContextKey, unknown> | null;
35
+ }
36
+ export declare const CONTEXT_FRAME_SYMBOL: unique symbol;
37
+ /**
38
+ * Execute a function within a specific context frame.
39
+ *
40
+ * CORE PRIMITIVE for context restoration:
41
+ * - Saves the current context
42
+ * - Sets the provided frame as current
43
+ * - Executes the function
44
+ * - Restores the previous context in finally
45
+ *
46
+ * This ensures no context frame remains globally active across await.
47
+ */
48
+ export declare function withContext<T>(frame: ContextFrame | null, fn: () => T): T;
49
+ /**
50
+ * Execute an async resource step within its frozen context snapshot.
51
+ *
52
+ * CRITICAL: This wrapper is applied only to synchronous execution steps of
53
+ * an async resource (the initial call). We intentionally DO NOT restore
54
+ * the resource frame for post-await continuations — continuations must not
55
+ * observe or rely on a live resource frame. This keeps semantics simple and
56
+ * deterministic: async resources see only their creation-time snapshot.
57
+ */
58
+ export declare function withAsyncResourceContext<T>(frame: ContextFrame | null, fn: () => T): T;
59
+ export declare function defineContext<T>(defaultValue: T): Context<T>;
60
+ export declare function readContext<T>(context: Context<T>): T;
61
+ /**
62
+ * Push a new context frame (for render entry)
63
+ * Called by component runtime when render starts
64
+ */
65
+ export declare function pushContextFrame(): ContextFrame;
66
+ /**
67
+ * Pop context frame (for render exit)
68
+ * Called by component runtime when render ends
69
+ */
70
+ export declare function popContextFrame(): void;
71
+ /**
72
+ * Get the current context frame for inspection (used by tests/diagnostics only)
73
+ */
74
+ export declare function getCurrentContextFrame(): ContextFrame | null;
75
+ /**
76
+ * Get the top of the context snapshot stack (used by runtime when deciding
77
+ * how to link snapshots for async continuations). Returns null if stack empty.
78
+ */
79
+ export declare function getTopContextSnapshot(): ContextFrame | null;
80
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/runtime/context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAMhD,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAmBhC,MAAM,WAAW,OAAO,CAAC,CAAC;IACxB,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC;IACzB,QAAQ,CAAC,YAAY,EAAE,CAAC,CAAC;IAEzB,QAAQ,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,UAAU,CAAC;CAC/E;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;IAE5B,MAAM,EAAE,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CACzC;AAGD,eAAO,MAAM,oBAAoB,eAAkC,CAAC;AAWpE;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,GAAG,IAAI,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAQzE;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,EACxC,KAAK,EAAE,YAAY,GAAG,IAAI,EAC1B,EAAE,EAAE,MAAM,CAAC,GACV,CAAC,CAUH;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAmB5D;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAqBrD;AAsID;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,YAAY,CAU/C;AAED;;;GAGG;AACH,wBAAgB,eAAe,IAAI,IAAI,CAItC;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,YAAY,GAAG,IAAI,CAE5D;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,YAAY,GAAG,IAAI,CAE3D"}
@@ -0,0 +1 @@
1
+ import{ELEMENT_TYPE as C}from"../common/jsx.js";import{getCurrentComponentInstance as s}from"./component.js";const h=Symbol("__tempoContextFrame__");let o=null,a=null;function F(n,r){const t=o;o=n;try{return r()}finally{o=t}}function v(n,r){const t=a;a=n;try{return r()}finally{a=t}}function w(n){const r=Symbol("AskrContext");return{key:r,defaultValue:n,Scope:t=>{const e=t.value;return{$$typeof:C,type:d,props:{key:r,value:e,children:t.children},key:null}}}}function A(n){const r=o||a;if(!r)throw new Error("readContext() can only be called during component render or async resource execution. Ensure you are calling this from inside your component or resource function.");let t=r;for(;t;){const e=t.values;if(e&&e.has(n.key))return e.get(n.key);t=t.parent}return n.defaultValue}function d(n){const r=n.key,t=n.value,e=n.children,u=s(),l={parent:o||(u&&u.ownerFrame?u.ownerFrame:null),values:new Map([[r,t]])};function m(c,y,p){return{type:x,props:{fn:c,__frame:y,__owner:p}}}return Array.isArray(e)?e.map(c=>typeof c=="function"?m(c,l,s()):i(c,l)):typeof e=="function"?m(e,l,s()):e?i(e,l):null}function i(n,r){if(typeof n=="object"&&n!==null){const t=n;t[h]=r;const e=t.children;if(Array.isArray(e))for(let u=0;u<e.length;u++){const f=e[u];f&&(e[u]=i(f,r))}else e&&(t.children=i(e,r))}return n}function x(n){const{fn:r,__frame:t}=n,e=F(t,()=>r());return e?i(e,t):null}function E(){const n={parent:o,values:null};return o=n,n}function g(){o&&(o=o.parent)}function S(){return o}function b(){return o}export{h as CONTEXT_FRAME_SYMBOL,w as defineContext,S as getCurrentContextFrame,b as getTopContextSnapshot,g as popContextFrame,E as pushContextFrame,A as readContext,v as withAsyncResourceContext,F as withContext};
@@ -0,0 +1,7 @@
1
+ export declare function derive<TOut>(fn: () => TOut): TOut | null;
2
+ export declare function derive<TIn, TOut>(source: {
3
+ value: TIn | null;
4
+ pending?: boolean;
5
+ error?: Error | null;
6
+ } | TIn | (() => TIn), map: (value: TIn) => TOut): TOut | null;
7
+ //# sourceMappingURL=derive.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"derive.d.ts","sourceRoot":"","sources":["../../src/runtime/derive.ts"],"names":[],"mappings":"AAeA,wBAAgB,MAAM,CAAC,IAAI,EAAE,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAG1D,wBAAgB,MAAM,CAAC,GAAG,EAAE,IAAI,EAC9B,MAAM,EACF;IAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAAA;CAAE,GAC9D,GAAG,GACH,CAAC,MAAM,GAAG,CAAC,EACf,GAAG,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,GACxB,IAAI,GAAG,IAAI,CAAC"}
@@ -0,0 +1 @@
1
+ import{getCurrentComponentInstance as a}from"./component.js";const f=new WeakMap;function o(e){let n=f.get(e);return n||(n=new Map,f.set(e,n)),n}function v(e,n){if(n===void 0&&typeof e=="function"){const u=e();return u??null}let t;if(typeof e=="function"&&!("value"in e)?t=e():t=e?.value??e,t==null)return null;const r=a();if(!r)return n(t);const i=o(r);if(i.has(t))return i.get(t);const l=n(t);return i.set(t,l),l}export{v as derive};
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Dev-only namespace helpers for diagnostics
3
+ *
4
+ * Centralizes the repetitive globalThis.__ASKR__ access pattern
5
+ * used throughout runtime for dev-mode diagnostics.
6
+ */
7
+ type DevNamespace = Record<string, unknown>;
8
+ /**
9
+ * Get or create the __ASKR__ dev namespace on globalThis.
10
+ * Returns empty object in production to avoid allocations.
11
+ */
12
+ export declare function getDevNamespace(): DevNamespace;
13
+ /**
14
+ * Set a value in the dev namespace (no-op in production).
15
+ */
16
+ export declare function setDevValue(key: string, value: unknown): void;
17
+ /**
18
+ * Get a value from the dev namespace (returns undefined in production).
19
+ */
20
+ export declare function getDevValue<T>(key: string): T | undefined;
21
+ /**
22
+ * Delete a value from the dev namespace (no-op in production).
23
+ */
24
+ export declare function deleteDevValue(key: string): void;
25
+ /**
26
+ * Increment a counter in the dev namespace (no-op in production).
27
+ * Safely handles non-number values by resetting to 1.
28
+ */
29
+ export declare function incDevCounter(key: string): void;
30
+ export {};
31
+ //# sourceMappingURL=dev-namespace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev-namespace.d.ts","sourceRoot":"","sources":["../../src/runtime/dev-namespace.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,KAAK,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE5C;;;GAGG;AACH,wBAAgB,eAAe,IAAI,YAAY,CAS9C;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAO7D;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAOzD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAOhD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAS/C"}
@@ -0,0 +1 @@
1
+ function r(){return{}}function u(t,e){}function c(t){}function i(t){}function o(t){}export{i as deleteDevValue,r as getDevNamespace,c as getDevValue,o as incDevCounter,u as setDevValue};
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Event delegation system for Askr
3
+ *
4
+ * Provides efficient event handling by attaching listeners to a container
5
+ * instead of individual elements. This significantly reduces memory usage
6
+ * and improves performance when many elements have the same event type.
7
+ *
8
+ * OPT-IN: Call enableEventDelegation() to use delegated event handling.
9
+ */
10
+ export interface DelegatedEventMap {
11
+ click: MouseEvent;
12
+ dblclick: MouseEvent;
13
+ mousedown: MouseEvent;
14
+ mouseup: MouseEvent;
15
+ mouseover: MouseEvent;
16
+ mouseout: MouseEvent;
17
+ mousemove: MouseEvent;
18
+ focus: FocusEvent;
19
+ blur: FocusEvent;
20
+ input: InputEvent;
21
+ change: Event;
22
+ keydown: KeyboardEvent;
23
+ keyup: KeyboardEvent;
24
+ keypress: KeyboardEvent;
25
+ submit: Event;
26
+ scroll: Event;
27
+ wheel: WheelEvent;
28
+ touchstart: TouchEvent;
29
+ touchend: TouchEvent;
30
+ touchmove: TouchEvent;
31
+ touchcancel: TouchEvent;
32
+ }
33
+ interface DelegatedHandler {
34
+ handler: EventListener;
35
+ original: EventListener;
36
+ element: Element;
37
+ eventName: string;
38
+ options?: AddEventListenerOptions;
39
+ }
40
+ export declare function isEventDelegationEnabled(): boolean;
41
+ export declare function disableEventDelegation(): void;
42
+ export declare function enableEventDelegation(container?: Element): void;
43
+ export declare function setGlobalDelegationContainer(container: Element): void;
44
+ export declare function addDelegatedListener(element: Element, eventName: string, handler: EventListener, originalHandler: EventListener, options?: AddEventListenerOptions): void;
45
+ export declare function removeDelegatedListener(element: Element, eventName: string): void;
46
+ export declare function getDelegatedHandlersForElement(element: Element): Map<string, DelegatedHandler> | undefined;
47
+ export declare function hasDelegatedHandler(element: Element, eventName: string): boolean;
48
+ export declare function clearDelegatedHandlersForElement(element: Element): void;
49
+ export declare function getDelegatedEventNames(): readonly (keyof DelegatedEventMap)[];
50
+ export declare function isDelegatedEvent(eventName: string): boolean;
51
+ export {};
52
+ //# sourceMappingURL=events.d.ts.map