@askrjs/askr 0.0.26 → 0.0.28

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 (103) hide show
  1. package/README.md +62 -20
  2. package/dist/_virtual/_fs.js +1 -0
  3. package/dist/_virtual/_path.js +1 -0
  4. package/dist/bench/benchmark-entry.d.ts.map +1 -1
  5. package/dist/benchmark.js +1 -1
  6. package/dist/bin/askr-ssg.d.ts +32 -0
  7. package/dist/bin/askr-ssg.d.ts.map +1 -0
  8. package/dist/bin/askr-ssg.js +24 -0
  9. package/dist/boot/index.d.ts.map +1 -1
  10. package/dist/boot/index.js +2 -2
  11. package/dist/dev/vite-plugin-askr.d.ts +9 -2
  12. package/dist/dev/vite-plugin-askr.d.ts.map +1 -1
  13. package/dist/index.d.ts +3 -0
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +1 -1
  16. package/dist/node_modules/esbuild/lib/main.js +9 -9
  17. package/dist/renderer/cleanup.d.ts +3 -0
  18. package/dist/renderer/cleanup.d.ts.map +1 -1
  19. package/dist/renderer/cleanup.js +1 -1
  20. package/dist/renderer/dom.d.ts +2 -0
  21. package/dist/renderer/dom.d.ts.map +1 -1
  22. package/dist/renderer/dom.js +1 -1
  23. package/dist/renderer/evaluate.d.ts.map +1 -1
  24. package/dist/renderer/evaluate.js +1 -1
  25. package/dist/renderer/fastpath.d.ts.map +1 -1
  26. package/dist/renderer/fastpath.js +1 -1
  27. package/dist/renderer/index.js +1 -1
  28. package/dist/renderer/keyed.d.ts.map +1 -1
  29. package/dist/renderer/keyed.js +1 -1
  30. package/dist/renderer/reconcile.js +1 -1
  31. package/dist/renderer/utils.d.ts.map +1 -1
  32. package/dist/renderer/utils.js +1 -1
  33. package/dist/router/route.d.ts +1 -0
  34. package/dist/router/route.d.ts.map +1 -1
  35. package/dist/router/route.js +1 -1
  36. package/dist/runtime/component.d.ts +5 -2
  37. package/dist/runtime/component.d.ts.map +1 -1
  38. package/dist/runtime/component.js +1 -1
  39. package/dist/runtime/derive.d.ts +10 -4
  40. package/dist/runtime/derive.d.ts.map +1 -1
  41. package/dist/runtime/derive.js +1 -1
  42. package/dist/runtime/events.d.ts +1 -0
  43. package/dist/runtime/events.d.ts.map +1 -1
  44. package/dist/runtime/events.js +1 -1
  45. package/dist/runtime/fastlane.d.ts.map +1 -1
  46. package/dist/runtime/fastlane.js +1 -1
  47. package/dist/runtime/for.d.ts.map +1 -1
  48. package/dist/runtime/for.js +1 -1
  49. package/dist/runtime/operations.d.ts.map +1 -1
  50. package/dist/runtime/perf-metrics.d.ts +25 -0
  51. package/dist/runtime/perf-metrics.d.ts.map +1 -0
  52. package/dist/runtime/perf-metrics.js +1 -0
  53. package/dist/runtime/readable.d.ts +21 -0
  54. package/dist/runtime/readable.d.ts.map +1 -0
  55. package/dist/runtime/readable.js +1 -0
  56. package/dist/runtime/scheduler.d.ts +18 -2
  57. package/dist/runtime/scheduler.d.ts.map +1 -1
  58. package/dist/runtime/scheduler.js +1 -1
  59. package/dist/runtime/selector.d.ts +9 -0
  60. package/dist/runtime/selector.d.ts.map +1 -0
  61. package/dist/runtime/selector.js +1 -0
  62. package/dist/runtime/state.d.ts +2 -4
  63. package/dist/runtime/state.d.ts.map +1 -1
  64. package/dist/runtime/state.js +1 -1
  65. package/dist/ssg/batch-render.d.ts +16 -0
  66. package/dist/ssg/batch-render.d.ts.map +1 -0
  67. package/dist/ssg/batch-render.js +1 -0
  68. package/dist/ssg/create-static-gen.d.ts +51 -0
  69. package/dist/ssg/create-static-gen.d.ts.map +1 -0
  70. package/dist/ssg/create-static-gen.js +1 -0
  71. package/dist/ssg/discover-resources.d.ts +15 -0
  72. package/dist/ssg/discover-resources.d.ts.map +1 -0
  73. package/dist/ssg/generate-metadata.d.ts +27 -0
  74. package/dist/ssg/generate-metadata.d.ts.map +1 -0
  75. package/dist/ssg/generate-metadata.js +1 -0
  76. package/dist/ssg/incremental-manifest.d.ts +23 -0
  77. package/dist/ssg/incremental-manifest.d.ts.map +1 -0
  78. package/dist/ssg/incremental-manifest.js +1 -0
  79. package/dist/ssg/index.d.ts +28 -0
  80. package/dist/ssg/index.d.ts.map +1 -0
  81. package/dist/ssg/index.js +1 -0
  82. package/dist/ssg/resolve-ssg-data.d.ts +26 -0
  83. package/dist/ssg/resolve-ssg-data.d.ts.map +1 -0
  84. package/dist/ssg/resolve-ssg-data.js +1 -0
  85. package/dist/ssg/route-utils.d.ts +12 -0
  86. package/dist/ssg/route-utils.d.ts.map +1 -0
  87. package/dist/ssg/route-utils.js +1 -0
  88. package/dist/ssg/types.d.ts +164 -0
  89. package/dist/ssg/types.d.ts.map +1 -0
  90. package/dist/ssg/write-static-files.d.ts +21 -0
  91. package/dist/ssg/write-static-files.d.ts.map +1 -0
  92. package/dist/ssg/write-static-files.js +1 -0
  93. package/dist/ssr/attrs.d.ts +1 -1
  94. package/dist/ssr/attrs.d.ts.map +1 -1
  95. package/dist/ssr/attrs.js +1 -1
  96. package/dist/ssr/context.d.ts +3 -0
  97. package/dist/ssr/context.d.ts.map +1 -1
  98. package/dist/ssr/context.js +1 -1
  99. package/dist/ssr/index.d.ts +27 -0
  100. package/dist/ssr/index.d.ts.map +1 -1
  101. package/dist/ssr/index.js +1 -1
  102. package/dist/vite/index.js +4 -3
  103. package/package.json +34 -7
@@ -1 +1 @@
1
- import{globalScheduler as f}from"./scheduler.js";import{logger as A}from"../dev/logger.js";import{populateKeyMapForElement as _,getKeyMapForElement as S,isKeyedReorderFastPathEligible as g}from"../renderer/keyed.js";import{Fragment as y}from"../common/jsx.js";import{setDevValue as c,getDevValue as M,getDevNamespace as D}from"./dev-namespace.js";let d=!1,s=null;function p(){d=!0,s=new WeakSet;try{const e=f.clearPendingSyncTasks?.()??0;c("__ASKR_FASTLANE_CLEARED_TASKS",e)}catch{}}function h(){d=!1,s=null}function F(){return d}function T(e){if(s)try{s.add(e)}catch(t){}}function E(e){return!!(s&&s.has(e))}function w(e){const t=e._pendingReadStates??new Set,n=e._lastReadStates??new Set,r=e._currentRenderToken;if(r!==void 0){for(const o of n)if(!t.has(o)){const a=o._readers;a&&a.delete(e)}e.lastRenderToken=r;for(const o of t){let a=o._readers;a||(a=new Map,o._readers=a),a.set(e,e.lastRenderToken??0)}e._lastReadStates=t,e._pendingReadStates=new Set,e._currentRenderToken=void 0}}function v(e){if(!e||typeof e!="object"||!("type"in e))return e;const t=e;if(typeof t.type=="symbol"&&(t.type===y||String(t.type)==="Symbol(askr.fragment)")){const n=t.children||t.props?.children;if(Array.isArray(n)&&n.length>0){for(const r of n)if(r&&typeof r=="object"&&"type"in r&&typeof r.type=="string")return r}}return e}function k(e,t){const n=v(t);if(!n||typeof n!="object"||!("type"in n))return{useFastPath:!1,reason:"not-vnode"};const r=n;if(r==null||typeof r.type!="string")return{useFastPath:!1,reason:"not-intrinsic"};const o=e.target;if(!o)return{useFastPath:!1,reason:"no-root"};const a=o.children[0];if(!a)return{useFastPath:!1,reason:"no-first-child"};if(a.tagName.toLowerCase()!==String(r.type).toLowerCase())return{useFastPath:!1,reason:"root-tag-mismatch"};const u=r.children||r.props?.children;if(!Array.isArray(u))return{useFastPath:!1,reason:"no-children-array"};for(const l of u)if(typeof l=="object"&&l!==null&&"type"in l&&typeof l.type=="function")return{useFastPath:!1,reason:"component-child-present"};if(e.mountOperations.length>0)return{useFastPath:!1,reason:"pending-mounts"};try{_(a)}catch{}const m=S(a),i=g(a,u,m);return!i.useFastPath||i.totalKeyed<128?{...i,useFastPath:!1,reason:"renderer-declined"}:{...i,useFastPath:!0}}function L(e,t){const n=globalThis.__ASKR_RENDERER?.evaluate;if(typeof n!="function")return A.warn("[Tempo][FASTPATH][DEV] renderer.evaluate not available; declining fast-lane"),!1;const r=null;p();try{f.runWithSyncProgress(()=>{n(t,e.target);try{w(e)}catch{}});const o=f.clearPendingSyncTasks?.()??0;return c("__FASTLANE_CLEARED_AFTER",o),!0}finally{h()}}function P(e,t){if(!k(e,t).useFastPath)return c("__LAST_FASTPATH_STATS",void 0),c("__LAST_FASTPATH_COMMIT_COUNT",0),!1;try{return L(e,t)}catch{return!1}}typeof globalThis<"u"&&(globalThis.__ASKR_FASTLANE={isBulkCommitActive:F,enterBulkCommit:p,exitBulkCommit:h,tryRuntimeFastLaneSync:P,markFastPathApplied:T,isFastPathApplied:E});export{k as classifyUpdate,L as commitReorderOnly,p as enterBulkCommit,h as exitBulkCommit,F as isBulkCommitActive,E as isFastPathApplied,T as markFastPathApplied,P as tryRuntimeFastLaneSync};
1
+ import{globalScheduler as f}from"./scheduler.js";import{logger as A}from"../dev/logger.js";import{finalizeReadableSubscriptions as y}from"./readable.js";import{populateKeyMapForElement as g,getKeyMapForElement as F,isKeyedReorderFastPathEligible as S}from"../renderer/keyed.js";import{Fragment as _}from"../common/jsx.js";import{setDevValue as c,getDevValue as M,getDevNamespace as x}from"./dev-namespace.js";let d=!1,o=null;function p(){d=!0,o=new WeakSet;try{const e=f.clearPendingSyncTasks?.()??0;c("__ASKR_FASTLANE_CLEARED_TASKS",e)}catch{}}function m(){d=!1,o=null}function E(){return d}function T(e){if(o)try{o.add(e)}catch(t){}}function L(e){return!!(o&&o.has(e))}function P(e){y(e)}function v(e){if(!e||typeof e!="object"||!("type"in e))return e;const t=e;if(typeof t.type=="symbol"&&(t.type===_||String(t.type)==="Symbol(askr.fragment)")){const n=t.children||t.props?.children;if(Array.isArray(n)&&n.length>0){for(const r of n)if(r&&typeof r=="object"&&"type"in r&&typeof r.type=="string")return r}}return e}function w(e,t){const n=v(t);if(!n||typeof n!="object"||!("type"in n))return{useFastPath:!1,reason:"not-vnode"};const r=n;if(r==null||typeof r.type!="string")return{useFastPath:!1,reason:"not-intrinsic"};const i=e.target;if(!i)return{useFastPath:!1,reason:"no-root"};const a=i.children[0];if(!a)return{useFastPath:!1,reason:"no-first-child"};if(a.tagName.toLowerCase()!==String(r.type).toLowerCase())return{useFastPath:!1,reason:"root-tag-mismatch"};const u=r.children||r.props?.children;if(!Array.isArray(u))return{useFastPath:!1,reason:"no-children-array"};for(const l of u)if(typeof l=="object"&&l!==null&&"type"in l&&typeof l.type=="function")return{useFastPath:!1,reason:"component-child-present"};if(e.mountOperations.length>0)return{useFastPath:!1,reason:"pending-mounts"};try{g(a)}catch{}const h=F(a),s=S(a,u,h);return!s.useFastPath||s.totalKeyed<128?{...s,useFastPath:!1,reason:"renderer-declined"}:{...s,useFastPath:!0}}function C(e,t){const n=globalThis.__ASKR_RENDERER?.evaluate;if(typeof n!="function")return A.warn("[Tempo][FASTPATH][DEV] renderer.evaluate not available; declining fast-lane"),!1;const r=null;p();try{f.runWithSyncProgress(()=>{n(t,e.target);try{P(e)}catch{}});const i=f.clearPendingSyncTasks?.()??0;return c("__FASTLANE_CLEARED_AFTER",i),!0}finally{m()}}function b(e,t){if(!w(e,t).useFastPath)return c("__LAST_FASTPATH_STATS",void 0),c("__LAST_FASTPATH_COMMIT_COUNT",0),!1;try{return C(e,t)}catch{return!1}}typeof globalThis<"u"&&(globalThis.__ASKR_FASTLANE={isBulkCommitActive:E,enterBulkCommit:p,exitBulkCommit:m,tryRuntimeFastLaneSync:b,markFastPathApplied:T,isFastPathApplied:L});export{w as classifyUpdate,C as commitReorderOnly,p as enterBulkCommit,m as exitBulkCommit,E as isBulkCommitActive,L as isFastPathApplied,T as markFastPathApplied,b as tryRuntimeFastLaneSync};
@@ -1 +1 @@
1
- {"version":3,"file":"for.d.ts","sourceRoot":"","sources":["../../src/runtime/for.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EACL,KAAK,iBAAiB,EAOvB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAc,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAazD,UAAU,YAAY;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IAC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,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACzD,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,MAAM,KAAK,KAAK,CAAC;IAClD,cAAc,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACzC,OAAO,EAAE,OAAO,CAAC;CAClB;AAoCD,wBAAgB,cAAc,CAAC,CAAC,EAC9B,MAAM,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAChC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,MAAM,EACjD,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,MAAM,KAAK,KAAK,GAChD,QAAQ,CAAC,CAAC,CAAC,CAab;AAID,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,EAC3B,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GACpB,eAAe,CAAC,CAAC,CAAC,CAkJpB;AAkDD,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EACrB,QAAQ,EAAE,CAAC,EAAE,GACZ,KAAK,EAAE,CAmRT;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAChC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EACrB,MAAM,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,GAC/B,KAAK,EAAE,CAST"}
@@ -1 +1 @@
1
- import{getCurrentInstance as R,createComponentInstance as K,setCurrentComponentInstance as y,getCurrentStateIndex as H,finalizeReadSubscriptions as E,setStateIndex as L}from"./component.js";import{ELEMENT_TYPE as T}from"../common/jsx.js";const v=globalThis,s={itemsCreated:0,itemsReused:0,itemsRemoved:0,itemsMoved:0,rowFactoryInvocations:0,keyLookups:0,keyHits:0,keyMisses:0,domInserts:0,domRemoves:0,domMoves:0,domAttrSets:0,domTextSets:0,reconcilePhaseMs:0,domCommitPhaseMs:0,fastLaneName:null};function P(){v.__ASKR_BENCH__&&(s.itemsCreated=0,s.itemsReused=0,s.itemsRemoved=0,s.itemsMoved=0,s.rowFactoryInvocations=0,s.keyLookups=0,s.keyHits=0,s.keyMisses=0,s.domInserts=0,s.domRemoves=0,s.domMoves=0,s.domAttrSets=0,s.domTextSets=0,s.reconcilePhaseMs=0,s.domCommitPhaseMs=0,s.fastLaneName=null)}function l(r){if(v.__ASKR_BENCH__)switch(r){case"itemCreated":s.itemsCreated++;break;case"itemReused":s.itemsReused++;break;case"itemRemoved":s.itemsRemoved++;break;case"itemMoved":s.itemsMoved++;break;case"rowFactory":s.rowFactoryInvocations++;break;case"keyLookup":s.keyLookups++;break;case"keyHit":s.keyHits++;break;case"keyMiss":s.keyMisses++;break;case"domInsert":s.domInserts++;break;case"domRemove":s.domRemoves++;break;case"domMove":s.domMoves++;break;case"domAttrSet":s.domAttrSets++;break;case"domTextSet":s.domTextSets++;break}}function F(r){v.__ASKR_BENCH__&&(s.fastLaneName=r)}function M(r,i){v.__ASKR_BENCH__&&(r==="reconcile"?s.reconcilePhaseMs=i:s.domCommitPhaseMs=i)}function U(){return{...s}}function C(r){if(r&&typeof r=="object"&&"$$typeof"in r&&r.$$typeof===T){const i=r;if(typeof i.type=="function"){const u=i.type,m=u(i.props||{});return C(m)}return i}return r}function $(r,i,u){const m=typeof r=="function"?null:r,f=R();return{sourceState:m,items:new Map,orderedKeys:[],byFn:i,renderFn:u,parentInstance:f,mounted:!1}}let N=1;function w(r,i,u,m){l("itemCreated");let f=u;const p=Object.assign(()=>f,{set(t){const e=typeof t=="function"?t(f):t;e!==f&&(f=e)}});p[Symbol.iterator]=function*(){yield p,yield p.set};const _=()=>null,a=K(`for-item-${r}`,_,{},null);m.parentInstance&&(a.ownerFrame=m.parentInstance.ownerFrame);const b=R();y(a);const I=H();a._currentRenderToken=N++,a._pendingReadStates=new Set,l("rowFactory");const k=C(m.renderFn(i,()=>p()));if(k&&typeof k=="object"&&"type"in k){const t=k;t.key=r,typeof t.type=="string"&&(t.props||(t.props={}),t.props["data-key"]===void 0&&(t.props["data-key"]=String(r)))}E(a),y(b);const d={key:r,item:i,indexSignal:p,componentInstance:a,vnode:k,_startStateIndex:I};return a._pendingFlushTask=()=>{const t=R();y(a),a.stateIndexCheck=-1;const e=a.stateValues;for(let c=0;c<e.length;c++){const n=e[c];n&&(n._hasBeenRead=!1)}L(I),a._currentRenderToken=N++,a._pendingReadStates=new Set;try{const c=C(m.renderFn(i,()=>p()));d.vnode=c,E(a)}finally{y(t)}const o=m.parentInstance;o&&o._enqueueRun?.()},d}function A(r,i){v.__ASKR_BENCH__&&P();const u=v.__ASKR_BENCH__?performance.now():0,{items:m,orderedKeys:f,byFn:p}=r,_=f.length,a=i.length;if(_<=a){let d=!0;for(let t=0;t<_;t++)if(p(i[t],t)!==f[t]){d=!1;break}if(d){F("APPEND");const t=[];for(let e=0;e<_;e++){const o=i[e],c=f[e],n=m.get(c);l("itemReused");const g=n.item!==o,h=n.indexSignal()!==e;if(g){n.item=o;const S=R();y(n.componentInstance),l("rowFactory"),n.vnode=C(r.renderFn(o,()=>n.indexSignal()));try{n.vnode&&typeof n.vnode=="object"&&"type"in n.vnode&&(n.vnode.key=c)}catch(x){}y(S)}h&&n.indexSignal.set(e),t.push(n.vnode)}for(let e=_;e<a;e++){const o=i[e],c=p(o,e),n=w(c,o,e,r);m.set(c,n),t.push(n.vnode),f[e]=c}return v.__ASKR_BENCH__&&M("reconcile",performance.now()-u),t}}if(a<=_){let d=!0;for(let t=0;t<a;t++)if(p(i[t],t)!==f[t]){d=!1;break}if(d){F("TRUNCATE");const t=[];for(let e=0;e<a;e++){const o=i[e],c=f[e],n=m.get(c);l("itemReused");const g=n.item!==o,h=n.indexSignal()!==e;if(g){n.item=o;const S=R();y(n.componentInstance),l("rowFactory"),n.vnode=C(r.renderFn(o,()=>n.indexSignal()));try{n.vnode&&typeof n.vnode=="object"&&"type"in n.vnode&&(n.vnode.key=c)}catch(x){}y(S)}h&&n.indexSignal.set(e),t.push(n.vnode)}for(let e=a;e<_;e++){const o=f[e],c=m.get(o);if(c){l("itemRemoved");const n=c.componentInstance;n.abortController.abort();for(const g of n.cleanupFns)try{g()}catch{}m.delete(o)}}return f.length=a,r.orderedKeys=f,v.__ASKR_BENCH__&&M("reconcile",performance.now()-u),t}}if(_===a){let d=!0;for(let t=0;t<_;t++)if(p(i[t],t)!==f[t]){d=!1;break}if(d){F("NO_REORDER");const t=[];for(let e=0;e<_;e++){const o=i[e],c=f[e],n=m.get(c);l("itemReused");const g=n.item!==o,h=n.indexSignal()!==e;if(g){n.item=o;const S=R();y(n.componentInstance),l("rowFactory");const x=C(r.renderFn(o,()=>n.indexSignal()));n.vnode=x;try{n.vnode&&typeof n.vnode=="object"&&"type"in n.vnode&&(n.vnode.key=c)}catch(B){}y(S)}h&&n.indexSignal.set(e),t.push(n.vnode)}return v.__ASKR_BENCH__&&M("reconcile",performance.now()-u),t}}F("FULL_KEYED");const b=new Set(f),I=[],k=[];for(let d=0;d<i.length;d++){const t=i[d],e=p(t,d);l("keyLookup"),b.delete(e),I.push(e);const o=m.get(e);if(l(o?"keyHit":"keyMiss"),o){l("itemReused");const c=o.item!==t,n=o.indexSignal()!==d;if(c){o.item=t;const g=R();y(o.componentInstance),l("rowFactory"),o.vnode=C(r.renderFn(t,()=>o.indexSignal()));try{o.vnode&&typeof o.vnode=="object"&&"type"in o.vnode&&(o.vnode.key=e)}catch(h){}y(g)}n&&o.indexSignal.set(d),k.push(o.vnode)}else{const c=w(e,t,d,r);m.set(e,c),k.push(c.vnode)}}for(const d of b){const t=m.get(d);if(t){l("itemRemoved");const e=t.componentInstance;e.abortController.abort();for(const o of e.cleanupFns)try{o()}catch{}m.delete(d)}}return r.orderedKeys=I,v.__ASKR_BENCH__&&M("reconcile",performance.now()-u),k}function O(r,i){const u=i();if(!Array.isArray(u))throw new Error("For source must evaluate to an array");return A(r,u)}export{$ as createForState,w as createItemInstance,O as evaluateForState,U as getBenchMetrics,A as reconcileForItems};
1
+ import{getCurrentInstance as b,createComponentInstance as w,setCurrentComponentInstance as g,getCurrentStateIndex as T,finalizeReadSubscriptions as M,setStateIndex as F,cleanupComponent as B}from"./component.js";import{ELEMENT_TYPE as L}from"../common/jsx.js";import{teardownNodeSubtree as K}from"../renderer/cleanup.js";const y=globalThis,s={itemsCreated:0,itemsReused:0,itemsRemoved:0,itemsMoved:0,rowFactoryInvocations:0,keyLookups:0,keyHits:0,keyMisses:0,domInserts:0,domRemoves:0,domMoves:0,domAttrSets:0,domTextSets:0,reconcilePhaseMs:0,domCommitPhaseMs:0,fastLaneName:null};function P(){y.__ASKR_BENCH__&&(s.itemsCreated=0,s.itemsReused=0,s.itemsRemoved=0,s.itemsMoved=0,s.rowFactoryInvocations=0,s.keyLookups=0,s.keyHits=0,s.keyMisses=0,s.domInserts=0,s.domRemoves=0,s.domMoves=0,s.domAttrSets=0,s.domTextSets=0,s.reconcilePhaseMs=0,s.domCommitPhaseMs=0,s.fastLaneName=null)}function _(o){if(y.__ASKR_BENCH__)switch(o){case"itemCreated":s.itemsCreated++;break;case"itemReused":s.itemsReused++;break;case"itemRemoved":s.itemsRemoved++;break;case"itemMoved":s.itemsMoved++;break;case"rowFactory":s.rowFactoryInvocations++;break;case"keyLookup":s.keyLookups++;break;case"keyHit":s.keyHits++;break;case"keyMiss":s.keyMisses++;break;case"domInsert":s.domInserts++;break;case"domRemove":s.domRemoves++;break;case"domMove":s.domMoves++;break;case"domAttrSet":s.domAttrSets++;break;case"domTextSet":s.domTextSets++;break}}function S(o){y.__ASKR_BENCH__&&(s.fastLaneName=o)}function x(o,n){y.__ASKR_BENCH__&&(o==="reconcile"?s.reconcilePhaseMs=n:s.domCommitPhaseMs=n)}function $(){return{...s}}function E(o){if(o&&typeof o=="object"&&"$$typeof"in o&&o.$$typeof===L){const n=o;if(typeof n.type=="function"){const l=n.type,a=l(n.props||{});return E(a)}return n}return o}function O(o,n,l){const a=typeof o=="function"?null:o,f=b();return{sourceState:a,items:new Map,orderedKeys:[],byFn:n,renderFn:l,parentInstance:f,mounted:!1}}let N=1;function H(o,n,l,a){_("itemCreated");let f=l;const u=Object.assign(()=>f,{set(e){const t=typeof e=="function"?e(f):e;t!==f&&(f=t)}});u[Symbol.iterator]=function*(){yield u,yield u.set};const p=()=>null,c=w(`for-item-${o}`,p,{},null);a.parentInstance&&(c.ownerFrame=a.parentInstance.ownerFrame);const h=b();g(c);const R=T();c._currentRenderToken=N++,c._pendingReadSources=new Set,_("rowFactory");const k=E(a.renderFn(n,()=>u()));if(k&&typeof k=="object"&&"type"in k){const e=k;e.key=o,typeof e.type=="string"&&(e.props||(e.props={}),e.props["data-key"]===void 0&&(e.props["data-key"]=String(o)))}M(c),g(h);const m={key:o,item:n,indexSignal:u,componentInstance:c,vnode:k,_startStateIndex:R};return c._pendingFlushTask=()=>{const e=b();g(c),c.stateIndexCheck=-1;const t=c.stateValues;for(let d=0;d<t.length;d++){const i=t[d];i&&(i._hasBeenRead=!1)}F(R),c._currentRenderToken=N++,c._pendingReadSources=new Set;try{const d=E(a.renderFn(n,()=>u()));m.vnode=d,M(c)}finally{g(e)}const r=a.parentInstance;r&&r._enqueueRun?.()},m}function I(o,n,l){const a=n.componentInstance,f=b(),u=T();g(a),a.stateIndexCheck=-1;const p=a.stateValues;for(let c=0;c<p.length;c++){const h=p[c];h&&(h._hasBeenRead=!1)}F(n._startStateIndex),a._currentRenderToken=N++,a._pendingReadSources=new Set;try{_("rowFactory"),n.vnode=E(o.renderFn(l,()=>n.indexSignal()));try{n.vnode&&typeof n.vnode=="object"&&"type"in n.vnode&&(n.vnode.key=n.key)}catch(c){}M(a)}finally{F(u),g(f)}}function A(o,n){y.__ASKR_BENCH__&&P();const l=y.__ASKR_BENCH__?performance.now():0,{items:a,orderedKeys:f,byFn:u}=o,p=f.length,c=n.length;if(p<=c){let m=!0;for(let e=0;e<p;e++)if(u(n[e],e)!==f[e]){m=!1;break}if(m){S("APPEND");const e=[];for(let t=0;t<p;t++){const r=n[t],d=f[t],i=a.get(d);_("itemReused");const v=i.item!==r,C=i.indexSignal()!==t;v&&(i.item=r,I(o,i,r)),C&&i.indexSignal.set(t),e.push(i.vnode)}for(let t=p;t<c;t++){const r=n[t],d=u(r,t),i=H(d,r,t,o);a.set(d,i),e.push(i.vnode),f[t]=d}return y.__ASKR_BENCH__&&x("reconcile",performance.now()-l),e}}if(c<=p){let m=!0;for(let e=0;e<c;e++)if(u(n[e],e)!==f[e]){m=!1;break}if(m){S("TRUNCATE");const e=[];for(let t=0;t<c;t++){const r=n[t],d=f[t],i=a.get(d);_("itemReused");const v=i.item!==r,C=i.indexSignal()!==t;v&&(i.item=r,I(o,i,r)),C&&i.indexSignal.set(t),e.push(i.vnode)}for(let t=c;t<p;t++){const r=f[t],d=a.get(r);if(d){_("itemRemoved");const i=d.componentInstance;try{B(i)}catch{}d._dom instanceof Element&&K(d._dom),d.vnode=void 0,d._dom=void 0,a.delete(r)}}return f.length=c,o.orderedKeys=f,y.__ASKR_BENCH__&&x("reconcile",performance.now()-l),e}}if(p===c){let m=!0;for(let e=0;e<p;e++)if(u(n[e],e)!==f[e]){m=!1;break}if(m){S("NO_REORDER");const e=[];for(let t=0;t<p;t++){const r=n[t],d=f[t],i=a.get(d);_("itemReused");const v=i.item!==r,C=i.indexSignal()!==t;v&&(i.item=r,I(o,i,r)),C&&i.indexSignal.set(t),e.push(i.vnode)}return y.__ASKR_BENCH__&&x("reconcile",performance.now()-l),e}}S("FULL_KEYED");const h=new Set(f),R=[],k=[];for(let m=0;m<n.length;m++){const e=n[m],t=u(e,m);_("keyLookup"),h.delete(t),R.push(t);const r=a.get(t);if(_(r?"keyHit":"keyMiss"),r){_("itemReused");const d=r.item!==e,i=r.indexSignal()!==m;d&&(r.item=e,I(o,r,e)),i&&r.indexSignal.set(m),k.push(r.vnode)}else{const d=H(t,e,m,o);a.set(t,d),k.push(d.vnode)}}for(const m of h){const e=a.get(m);if(e){_("itemRemoved");const t=e.componentInstance;try{B(t)}catch{}e._dom instanceof Element&&K(e._dom),e.vnode=void 0,e._dom=void 0,a.delete(m)}}return o.orderedKeys=R,y.__ASKR_BENCH__&&x("reconcile",performance.now()-l),k}function D(o,n){const l=n();if(!Array.isArray(l))throw new Error("For source must evaluate to an array");return A(o,l)}export{O as createForState,H as createItemInstance,D as evaluateForState,$ as getBenchMetrics,A as reconcileForItems};
@@ -1 +1 @@
1
- {"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../src/runtime/operations.ts"],"names":[],"mappings":"AAcA,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,OAAO,IAAI,IAAI,CAAC;CACjB;AAED;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EACxB,EAAE,EAAE,CAAC,IAAI,EAAE;IAAE,MAAM,EAAE,WAAW,CAAA;CAAE,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,EACrD,IAAI,GAAE,OAAO,EAAO,GACnB,cAAc,CAAC,CAAC,CAAC,CAmNnB;AAED,wBAAgB,EAAE,CAChB,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,aAAa,GACrB,IAAI,CAcN;AAED,wBAAgB,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI,CAc9D;AAED,wBAAgB,MAAM,CAAC,CAAC,EACtB,OAAO,EAAE,OAAO,EAChB,QAAQ,CAAC,E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AAM,EAAE,OAAO,CAAC,GACjC;IAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAA;CAAE,CAG5D;AAED,wBAAgB,IAAI,CAClB,EAAE,EAAE,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,GAC3D,IAAI,CAWN;AAED;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,CAG/C"}
@@ -0,0 +1,25 @@
1
+ type PerfMetrics = {
2
+ selectorInvalidations: number;
3
+ selectorCandidateReads: number;
4
+ reactivePropReevaluations: number;
5
+ skippedDomPropWrites: number;
6
+ classListPatchOps: number;
7
+ delegatedAncestorHops: number;
8
+ hydrationBoundaryActivations: number;
9
+ ssrTagCacheHits: number;
10
+ lastSchedulerTaskCountPerFlush: number;
11
+ maxSchedulerTaskCountPerFlush: number;
12
+ schedulerFlushCount: number;
13
+ schedulerTaskExecutions: number;
14
+ ssgWorkerCount: number;
15
+ ssgRenderTimeMs: number;
16
+ ssgWorkerRenderTimeMs: number;
17
+ ssgWriteTimeMs: number;
18
+ };
19
+ export declare function incrementPerfMetric(key: 'selectorInvalidations' | 'selectorCandidateReads' | 'reactivePropReevaluations' | 'skippedDomPropWrites' | 'classListPatchOps' | 'delegatedAncestorHops' | 'hydrationBoundaryActivations' | 'ssrTagCacheHits' | 'ssgWorkerCount', delta?: number): void;
20
+ export declare function addPerfDuration(key: 'ssgRenderTimeMs' | 'ssgWorkerRenderTimeMs' | 'ssgWriteTimeMs', deltaMs: number): void;
21
+ export declare function recordSchedulerFlushTaskCount(taskCount: number): void;
22
+ export declare function getPerfMetrics(): Readonly<PerfMetrics> | undefined;
23
+ export declare function resetPerfMetrics(): void;
24
+ export {};
25
+ //# sourceMappingURL=perf-metrics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"perf-metrics.d.ts","sourceRoot":"","sources":["../../src/runtime/perf-metrics.ts"],"names":[],"mappings":"AAAA,KAAK,WAAW,GAAG;IACjB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,yBAAyB,EAAE,MAAM,CAAC;IAClC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,4BAA4B,EAAE,MAAM,CAAC;IACrC,eAAe,EAAE,MAAM,CAAC;IACxB,8BAA8B,EAAE,MAAM,CAAC;IACvC,6BAA6B,EAAE,MAAM,CAAC;IACtC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,uBAAuB,EAAE,MAAM,CAAC;IAChC,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAyDF,wBAAgB,mBAAmB,CACjC,GAAG,EACC,uBAAuB,GACvB,wBAAwB,GACxB,2BAA2B,GAC3B,sBAAsB,GACtB,mBAAmB,GACnB,uBAAuB,GACvB,8BAA8B,GAC9B,iBAAiB,GACjB,gBAAgB,EACpB,KAAK,SAAI,GACR,IAAI,CAIN;AAED,wBAAgB,eAAe,CAC7B,GAAG,EAAE,iBAAiB,GAAG,uBAAuB,GAAG,gBAAgB,EACnE,OAAO,EAAE,MAAM,GACd,IAAI,CAIN;AAED,wBAAgB,6BAA6B,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAUrE;AAED,wBAAgB,cAAc,IAAI,QAAQ,CAAC,WAAW,CAAC,GAAG,SAAS,CAGlE;AAED,wBAAgB,gBAAgB,IAAI,IAAI,CAOvC"}
@@ -0,0 +1 @@
1
+ function n(){return{selectorInvalidations:0,selectorCandidateReads:0,reactivePropReevaluations:0,skippedDomPropWrites:0,classListPatchOps:0,delegatedAncestorHops:0,hydrationBoundaryActivations:0,ssrTagCacheHits:0,lastSchedulerTaskCountPerFlush:0,maxSchedulerTaskCountPerFlush:0,schedulerFlushCount:0,schedulerTaskExecutions:0,ssgWorkerCount:0,ssgRenderTimeMs:0,ssgWorkerRenderTimeMs:0,ssgWriteTimeMs:0}}function u(){try{return!!globalThis.__ASKR_BENCH__}catch{return!1}}function s(){if(!u())return null;try{const e=globalThis;return e.__ASKR_PERF__||(e.__ASKR_PERF__=n()),e.__ASKR_PERF__}catch{return null}}function o(e,r=1){const t=s();t&&(t[e]+=r)}function c(e,r){const t=s();t&&(t[e]+=r)}function i(e){const r=s();r&&(r.lastSchedulerTaskCountPerFlush=e,r.maxSchedulerTaskCountPerFlush=Math.max(r.maxSchedulerTaskCountPerFlush,e),r.schedulerFlushCount+=1,r.schedulerTaskExecutions+=e)}function a(){const e=s();return e?{...e}:void 0}function l(){const e=s();if(!e)return;const r=n();Object.keys(r).forEach(t=>{e[t]=r[t]})}export{c as addPerfDuration,a as getPerfMetrics,o as incrementPerfMetric,i as recordSchedulerFlushTaskCount,l as resetPerfMetrics};
@@ -0,0 +1,21 @@
1
+ import { type ComponentInstance } from './component';
2
+ export interface DerivedSubscriber {
3
+ _markDirty(): void;
4
+ _pendingDependencySources?: Set<ReadableSource<unknown>>;
5
+ }
6
+ export interface ReadableSource<T = unknown> {
7
+ (): T;
8
+ _hasBeenRead?: boolean;
9
+ _readers?: Map<ComponentInstance, number>;
10
+ _derivedSubscribers?: Set<DerivedSubscriber>;
11
+ }
12
+ export declare function recordReadableRead(source: ReadableSource<unknown>): void;
13
+ export declare function finalizeReadableSubscriptions(instance: ComponentInstance): void;
14
+ export declare function cleanupReadableSubscriptions(instance: ComponentInstance): void;
15
+ export declare function withDerivedReadTracking<T>(subscriber: DerivedSubscriber, fn: () => T): T;
16
+ export declare function syncDerivedDependencySubscriptions(subscriber: DerivedSubscriber, prevSources: Set<ReadableSource<unknown>>, nextSources: Set<ReadableSource<unknown>>): void;
17
+ export declare function clearDerivedDependencySubscriptions(subscriber: DerivedSubscriber, sources: Set<ReadableSource<unknown>>): void;
18
+ export declare function markReadableDerivedSubscribersDirty(source: ReadableSource<unknown>): void;
19
+ export declare function markReactivePropsDirtySource(source: ReadableSource<unknown>): void;
20
+ export declare function notifyReadableReaders(source: ReadableSource<unknown>): boolean;
21
+ //# sourceMappingURL=readable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readable.d.ts","sourceRoot":"","sources":["../../src/runtime/readable.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEzE,MAAM,WAAW,iBAAiB;IAChC,UAAU,IAAI,IAAI,CAAC;IACnB,yBAAyB,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;CAC1D;AAED,MAAM,WAAW,cAAc,CAAC,CAAC,GAAG,OAAO;IACzC,IAAI,CAAC,CAAC;IACN,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,EAAE,GAAG,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;IAC1C,mBAAmB,CAAC,EAAE,GAAG,CAAC,iBAAiB,CAAC,CAAC;CAC9C;AASD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,cAAc,CAAC,OAAO,CAAC,GAAG,IAAI,CAqBxE;AAED,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,iBAAiB,GAC1B,IAAI,CA6BN;AAED,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,iBAAiB,GAC1B,IAAI,CASN;AAED,wBAAgB,uBAAuB,CAAC,CAAC,EACvC,UAAU,EAAE,iBAAiB,EAC7B,EAAE,EAAE,MAAM,CAAC,GACV,CAAC,CAWH;AAED,wBAAgB,kCAAkC,CAChD,UAAU,EAAE,iBAAiB,EAC7B,WAAW,EAAE,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,EACzC,WAAW,EAAE,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,GACxC,IAAI,CAeN;AAED,wBAAgB,mCAAmC,CACjD,UAAU,EAAE,iBAAiB,EAC7B,OAAO,EAAE,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,GACpC,IAAI,CAKN;AAED,wBAAgB,mCAAmC,CACjD,MAAM,EAAE,cAAc,CAAC,OAAO,CAAC,GAC9B,IAAI,CASN;AAED,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,cAAc,CAAC,OAAO,CAAC,GAC9B,IAAI,CAUN;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,cAAc,CAAC,OAAO,CAAC,GAC9B,OAAO,CA8BT"}
@@ -0,0 +1 @@
1
+ import{globalScheduler as c}from"./scheduler.js";import{getCurrentInstance as u}from"./component.js";let s=null,i=0;function l(e){if(s&&(s._pendingDependencySources||(s._pendingDependencySources=new Set),s._pendingDependencySources.add(e)),i>0)return;const r=u();!r||r._currentRenderToken===void 0||(r._pendingReadSources||(r._pendingReadSources=new Set),r._pendingReadSources.add(e))}function S(e){const r=e._pendingReadSources??new Set,o=e._lastReadSources??new Set,n=e._currentRenderToken;if(n!==void 0){for(const d of o)r.has(d)||d._readers?.delete(e);e.lastRenderToken=n;for(const d of r){let t=d._readers;t||(t=new Map,d._readers=t),t.set(e,e.lastRenderToken??0)}e._lastReadSources=r,e._pendingReadSources=new Set,e._currentRenderToken=void 0}}function p(e){if(e._lastReadSources){for(const r of e._lastReadSources)r._readers?.delete(e);e._lastReadSources=new Set}}function b(e,r){const o=s;s=e,i+=1;try{return r()}finally{i-=1,s=o}}function R(e,r,o){for(const n of r)o.has(n)||n._derivedSubscribers?.delete(e);for(const n of o){let d=n._derivedSubscribers;d||(d=new Set,n._derivedSubscribers=d),d.add(e)}}function _(e,r){for(const o of r)o._derivedSubscribers?.delete(e);r.clear()}function g(e){const r=e._derivedSubscribers;if(!(!r||r.size===0))for(const o of r)o._markDirty()}function v(e){try{globalThis.__ASKR_RENDERER?.markReactivePropsDirtySource?.(e)}catch{}}function D(e){const r=e._readers;let o=!1;if(!r||r.size===0)return!1;for(const[n,d]of r){if(n.lastRenderToken!==d||n.hasPendingUpdate)continue;n.hasPendingUpdate=!0;const t=n._pendingFlushTask;t?c.enqueue(t):c.enqueue(()=>{n.hasPendingUpdate=!1,n.notifyUpdate?.()}),o=!0}return o}export{p as cleanupReadableSubscriptions,_ as clearDerivedDependencySubscriptions,S as finalizeReadableSubscriptions,v as markReactivePropsDirtySource,g as markReadableDerivedSubscribersDirty,D as notifyReadableReaders,l as recordReadableRead,R as syncDerivedDependencySubscriptions,b as withDerivedReadTracking};
@@ -9,9 +9,9 @@
9
9
  * - `waitForFlush()` is race-free with a monotonic `flushVersion`.
10
10
  */
11
11
  type Task = () => void;
12
+ export type SchedulerLane = 'derived' | 'component' | 'reactive' | 'post';
12
13
  export declare class Scheduler {
13
- private q;
14
- private head;
14
+ private lanes;
15
15
  private running;
16
16
  private inHandler;
17
17
  private depth;
@@ -21,8 +21,15 @@ export declare class Scheduler {
21
21
  private allowSyncProgress;
22
22
  private waiters;
23
23
  private taskCount;
24
+ private hasPendingTasks;
25
+ private getPendingTaskCount;
26
+ private getNextPendingLane;
27
+ private compactLane;
28
+ private scheduleFlushKick;
24
29
  enqueue(task: Task): void;
30
+ enqueueInLane(lane: SchedulerLane, task: Task): void;
25
31
  flush(): void;
32
+ private finalizeFlush;
26
33
  runWithSyncProgress<T>(fn: () => T): T;
27
34
  waitForFlush(targetVersion?: number, timeoutMs?: number): Promise<void>;
28
35
  getState(): {
@@ -32,9 +39,18 @@ export declare class Scheduler {
32
39
  executionDepth: number;
33
40
  taskCount: number;
34
41
  flushVersion: number;
42
+ laneQueues: {
43
+ derived: number;
44
+ component: number;
45
+ reactive: number;
46
+ post: number;
47
+ };
35
48
  inHandler: boolean;
36
49
  allowSyncProgress: boolean;
37
50
  };
51
+ getFlushVersion(): number;
52
+ flushIfQueued(): void;
53
+ runInHandlerScope<T>(fn: () => T, flushMode?: 'defer' | 'sync'): T;
38
54
  setInHandler(v: boolean): void;
39
55
  isInHandler(): boolean;
40
56
  isExecuting(): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../../src/runtime/scheduler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAOH,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;AAkBvB,qBAAa,SAAS;IACpB,OAAO,CAAC,CAAC,CAAc;IACvB,OAAO,CAAC,IAAI,CAAK;IAEjB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,cAAc,CAAK;IAG3B,OAAO,CAAC,YAAY,CAAK;IAGzB,OAAO,CAAC,aAAa,CAAS;IAG9B,OAAO,CAAC,iBAAiB,CAAS;IAGlC,OAAO,CAAC,OAAO,CAKP;IAGR,OAAO,CAAC,SAAS,CAAK;IAEtB,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IA4CzB,KAAK,IAAI,IAAI;IAyEb,mBAAmB,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC;IAmEtC,YAAY,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,SAAS,SAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAgCrE,QAAQ;;;;;;;;;;IAeR,YAAY,CAAC,CAAC,EAAE,OAAO;IAIvB,WAAW,IAAI,OAAO;IAItB,WAAW,IAAI,OAAO;IAKtB,qBAAqB,IAAI,MAAM;IA0B/B,OAAO,CAAC,cAAc;CAiBvB;AAED,eAAO,MAAM,eAAe,WAAkB,CAAC;AAE/C,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,aAAa,GAAG,aAAa,CA0B1E"}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AC,CAAC,EAAE,OAAO;IAOvB,WAAW,IAAI,OAAO;IAItB,WAAW,IAAI,OAAO;IAKtB,qBAAqB,IAAI,MAAM;IAgC/B,OAAO,CAAC,cAAc;CAiBvB;AAED,eAAO,MAAM,eAAe,WAAkB,CAAC;AAE/C,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,aAAa,GAAG,aAAa,CAU1E"}
@@ -1 +1 @@
1
- import{assertSchedulingPrecondition as c,invariant as f}from"../dev/invariant.js";import{logger as d}from"../dev/logger.js";function h(){try{const s=globalThis.__ASKR_FASTLANE;return typeof s?.isBulkCommitActive=="function"?!!s.isBulkCommitActive():!1}catch(s){return!1}}class g{constructor(){this.q=[],this.head=0,this.running=!1,this.inHandler=!1,this.depth=0,this.executionDepth=0,this.flushVersion=0,this.kickScheduled=!1,this.allowSyncProgress=!1,this.waiters=[],this.taskCount=0}enqueue(t){c(typeof t=="function","enqueue() requires a function"),!(h()&&!this.allowSyncProgress)&&(this.q.push(t),this.taskCount++,!this.running&&!this.kickScheduled&&!this.inHandler&&!h()&&(this.kickScheduled=!0,queueMicrotask(()=>{if(this.kickScheduled=!1,!this.running&&!h())try{this.flush()}catch(i){setTimeout(()=>{throw i})}})))}flush(){f(!this.running,"[Scheduler] flush() called while already running"),this.running=!0,this.depth=0;let t=null;try{for(;this.head<this.q.length;){this.depth++;const i=this.q[this.head++];try{this.executionDepth++,i(),this.executionDepth--}catch(e){this.executionDepth>0&&(this.executionDepth=0),t=e;break}this.taskCount>0&&this.taskCount--}}finally{if(this.running=!1,this.depth=0,this.executionDepth=0,this.head>=this.q.length)this.q.length=0,this.head=0;else if(this.head>0){const i=this.q.length-this.head;for(let e=0;e<i;e++)this.q[e]=this.q[this.head+e];this.q.length=i,this.head=0}this.flushVersion++,this.resolveWaiters()}if(t)throw t}runWithSyncProgress(t){const i=this.allowSyncProgress;this.allowSyncProgress=!0;const e=globalThis,l=e.queueMicrotask,o=e.setTimeout,u=this.flushVersion;try{const n=t();return!this.running&&this.q.length-this.head>0&&this.flush(),n}finally{try{this.flushVersion===u&&(this.flushVersion++,this.resolveWaiters())}catch(n){}this.allowSyncProgress=i}}waitForFlush(t,i=2e3){const e=typeof t=="number"?t:this.flushVersion+1;return this.flushVersion>=e?Promise.resolve():new Promise((l,o)=>{const u=setTimeout(()=>{const n=globalThis.__ASKR__||{},a={flushVersion:this.flushVersion,queueLen:this.q.length-this.head,running:this.running,inHandler:this.inHandler,bulk:h(),namespace:n};o(new Error(`waitForFlush timeout ${i}ms: ${JSON.stringify(a)}`))},i);this.waiters.push({target:e,resolve:l,reject:o,timer:u})})}getState(){return{queueLength:this.q.length-this.head,running:this.running,depth:this.depth,executionDepth:this.executionDepth,taskCount:this.taskCount,flushVersion:this.flushVersion,inHandler:this.inHandler,allowSyncProgress:this.allowSyncProgress}}setInHandler(t){this.inHandler=t}isInHandler(){return this.inHandler}isExecuting(){return this.running||this.executionDepth>0}clearPendingSyncTasks(){const t=this.q.length-this.head;return t<=0?0:this.running?(this.q.length=this.head,this.taskCount=Math.max(0,this.taskCount-t),queueMicrotask(()=>{try{this.flushVersion++,this.resolveWaiters()}catch(i){}}),t):(this.q.length=0,this.head=0,this.taskCount=Math.max(0,this.taskCount-t),this.flushVersion++,this.resolveWaiters(),t)}resolveWaiters(){if(this.waiters.length===0)return;const t=[],i=[];for(const e of this.waiters)this.flushVersion>=e.target?(e.timer&&clearTimeout(e.timer),t.push(e.resolve)):i.push(e);this.waiters=i;for(const e of t)e()}}const r=new g;function k(){return r.isExecuting()}function S(s){return t=>{r.setInHandler(!0);try{s.call(null,t)}catch(i){d.error("[Askr] Event handler error:",i)}finally{r.setInHandler(!1);const i=r.getState();(i.queueLength??0)>0&&!i.running&&queueMicrotask(()=>{try{r.isExecuting()||r.flush()}catch(e){setTimeout(()=>{throw e})}})}}}export{g as Scheduler,r as globalScheduler,k as isSchedulerExecuting,S as scheduleEventHandler};
1
+ import{assertSchedulingPrecondition as d,invariant as f}from"../dev/invariant.js";import{logger as g}from"../dev/logger.js";import{recordSchedulerFlushTaskCount as k}from"./perf-metrics.js";const i=["derived","component","reactive","post"];function l(){try{const n=globalThis.__ASKR_FASTLANE;return typeof n?.isBulkCommitActive=="function"?!!n.isBulkCommitActive():!1}catch(n){return!1}}class m{constructor(){this.lanes={derived:{tasks:[],head:0},component:{tasks:[],head:0},reactive:{tasks:[],head:0},post:{tasks:[],head:0}},this.running=!1,this.inHandler=!1,this.depth=0,this.executionDepth=0,this.flushVersion=0,this.kickScheduled=!1,this.allowSyncProgress=!1,this.waiters=[],this.taskCount=0}hasPendingTasks(){for(const e of i){const t=this.lanes[e];if(t.head<t.tasks.length)return!0}return!1}getPendingTaskCount(){let e=0;for(const t of i){const s=this.lanes[t];e+=s.tasks.length-s.head}return e}getNextPendingLane(){for(const e of i){const t=this.lanes[e];if(t.head<t.tasks.length)return e}return null}compactLane(e){if(e.head>=e.tasks.length){e.tasks.length=0,e.head=0;return}if(e.head<=0)return;const t=e.tasks.length-e.head;for(let s=0;s<t;s++)e.tasks[s]=e.tasks[e.head+s];e.tasks.length=t,e.head=0}scheduleFlushKick(){this.running||this.kickScheduled||this.inHandler||l()||!this.hasPendingTasks()||(this.kickScheduled=!0,queueMicrotask(()=>{if(this.kickScheduled=!1,!(this.running||l()||!this.hasPendingTasks()))try{this.flush()}catch(e){setTimeout(()=>{throw e})}}))}enqueue(e){this.enqueueInLane("component",e)}enqueueInLane(e,t){d(typeof t=="function","enqueue() requires a function"),!(l()&&!this.allowSyncProgress)&&(this.lanes[e].tasks.push(t),this.taskCount++,this.scheduleFlushKick())}flush(){f(!this.running,"[Scheduler] flush() called while already running"),this.running=!0,this.depth=0;let e=null,t=0;try{for(;;){const s=this.getNextPendingLane();if(!s)break;this.depth++;const r=this.lanes[s],h=r.tasks[r.head++];try{this.executionDepth++,h(),this.executionDepth--,t++}catch(o){this.executionDepth>0&&(this.executionDepth=0),e=o;break}this.taskCount>0&&this.taskCount--}}finally{this.running=!1,this.depth=0,this.executionDepth=0;for(const s of i)this.compactLane(this.lanes[s]);this.flushVersion++,this.resolveWaiters(),k(t)}if(e)throw e}finalizeFlush(){}runWithSyncProgress(e){const t=this.allowSyncProgress;this.allowSyncProgress=!0;const s=globalThis,r=s.queueMicrotask,h=s.setTimeout,o=this.flushVersion;try{const a=e();return!this.running&&this.hasPendingTasks()&&this.flush(),a}finally{try{this.flushVersion===o&&(this.flushVersion++,this.resolveWaiters())}catch(a){}this.allowSyncProgress=t}}waitForFlush(e,t=2e3){const s=typeof e=="number"?e:this.flushVersion+1;return this.flushVersion>=s?Promise.resolve():new Promise((r,h)=>{const o=setTimeout(()=>{const a=globalThis.__ASKR__||{},c={flushVersion:this.flushVersion,queueLen:this.getPendingTaskCount(),running:this.running,inHandler:this.inHandler,bulk:l(),namespace:a};h(new Error(`waitForFlush timeout ${t}ms: ${JSON.stringify(c)}`))},t);this.waiters.push({target:s,resolve:r,reject:h,timer:o})})}getState(){return{queueLength:this.getPendingTaskCount(),running:this.running,depth:this.depth,executionDepth:this.executionDepth,taskCount:this.taskCount,flushVersion:this.flushVersion,laneQueues:{derived:this.lanes.derived.tasks.length-this.lanes.derived.head,component:this.lanes.component.tasks.length-this.lanes.component.head,reactive:this.lanes.reactive.tasks.length-this.lanes.reactive.head,post:this.lanes.post.tasks.length-this.lanes.post.head},inHandler:this.inHandler,allowSyncProgress:this.allowSyncProgress}}getFlushVersion(){return this.flushVersion}flushIfQueued(){!this.running&&this.hasPendingTasks()&&this.flush()}runInHandlerScope(e,t="defer"){const s=this.inHandler;this.inHandler=!0;try{return e()}finally{this.inHandler=s,this.inHandler||(t==="sync"?this.flushIfQueued():this.scheduleFlushKick())}}setInHandler(e){this.inHandler=e,e||this.scheduleFlushKick()}isInHandler(){return this.inHandler}isExecuting(){return this.running||this.executionDepth>0}clearPendingSyncTasks(){const e=this.getPendingTaskCount();if(e<=0)return 0;if(this.running){for(const t of i){const s=this.lanes[t];s.tasks.length=s.head}return this.taskCount=Math.max(0,this.taskCount-e),queueMicrotask(()=>{try{this.flushVersion++,this.resolveWaiters()}catch(t){}}),e}for(const t of i){const s=this.lanes[t];s.tasks.length=0,s.head=0}return this.taskCount=Math.max(0,this.taskCount-e),this.flushVersion++,this.resolveWaiters(),e}resolveWaiters(){if(this.waiters.length===0)return;const e=[],t=[];for(const s of this.waiters)this.flushVersion>=s.target?(s.timer&&clearTimeout(s.timer),e.push(s.resolve)):t.push(s);this.waiters=t;for(const s of e)s()}}const u=new m;function y(){return u.isExecuting()}function P(n){return e=>{try{u.runInHandlerScope(()=>{n.call(null,e)})}catch(t){g.error("[Askr] Event handler error:",t)}}}export{m as Scheduler,u as globalScheduler,y as isSchedulerExecuting,P as scheduleEventHandler};
@@ -0,0 +1,9 @@
1
+ export interface Selector<T> {
2
+ (candidate: T): boolean;
3
+ }
4
+ type SelectorEquals<T> = {
5
+ bivarianceHack(a: T, b: T): boolean;
6
+ }['bivarianceHack'];
7
+ export declare function selector<T>(source: () => T, equals?: SelectorEquals<T>): Selector<T>;
8
+ export {};
9
+ //# sourceMappingURL=selector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selector.d.ts","sourceRoot":"","sources":["../../src/runtime/selector.ts"],"names":[],"mappings":"AA4BA,MAAM,WAAW,QAAQ,CAAC,CAAC;IACzB,CAAC,SAAS,EAAE,CAAC,GAAG,OAAO,CAAC;CACzB;AAMD,KAAK,cAAc,CAAC,CAAC,IAAI;IACvB,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC;CACrC,CAAC,gBAAgB,CAAC,CAAC;AAuRpB,wBAAgB,QAAQ,CAAC,CAAC,EACxB,MAAM,EAAE,MAAM,CAAC,EACf,MAAM,GAAE,cAAc,CAAC,CAAC,CAAa,GACpC,QAAQ,CAAC,CAAC,CAAC,CAab"}
@@ -0,0 +1 @@
1
+ import{getCurrentInstance as v,claimHookIndex as h}from"./component.js";import{globalScheduler as C}from"./scheduler.js";import{markReadableDerivedSubscribersDirty as b,markReactivePropsDirtySource as g,notifyReadableReaders as m,withDerivedReadTracking as w,syncDerivedDependencySubscriptions as D,recordReadableRead as j,clearDerivedDependencySubscriptions as R}from"./readable.js";import{incrementPerfMetric as y}from"./perf-metrics.js";const f=new WeakMap,i=new Set;let _=!1;function k(e){let r=f.get(e);return r||(r=new Map,f.set(e,r)),r}function V(){_||(_=!0,C.enqueueInLane("derived",M))}function q(e){e._dirty=!0,!e._scheduled&&(e._scheduled=!0,i.add(e),V())}function M(){if(_=!1,i.size===0)return;const e=Array.from(i);i.clear();for(const r of e)r._scheduled=!1,r._dirty&&S(r,!0)}function O(e){return typeof e=="object"&&e!==null||typeof e=="function"}function x(e){return e===Object.is}function p(e){const r=(()=>!1);return r._candidate=e,r}function l(e,r){if(O(r)){const n=e._objectCandidates.get(r);if(n)return n;const s=p(r);return s._candidate=r,e._objectCandidates.set(r,s),e._objectCandidateSources.add(s),s}const o=r,a=e._primitiveCandidates.get(o);if(a)return a;const t=p(r);return t._candidate=r,e._primitiveCandidates.set(o,t),t}function c(e){y("selectorInvalidations"),b(e),g(e),m(e)}function P(e){for(const r of e._primitiveCandidates.values())c(r);for(const r of e._objectCandidateSources)c(r)}function E(e,r,o){if(!x(e._equals)){P(e);return}Object.is(r,o)||(c(l(e,r)),c(l(e,o)))}function S(e,r){if(!e._dirty&&e._hasValue)return e._value;if(e._evaluating)throw new Error("selector() cannot read itself recursively");e._evaluating=!0,e._dirty=!1,e._pendingDependencySources=new Set;const o=e._sources,a=e._hasValue,t=e._value;let n;try{n=w(e,e._source)}catch(d){throw e._dirty=!0,e._pendingDependencySources=void 0,d}finally{e._evaluating=!1}const s=e._pendingDependencySources??new Set;e._pendingDependencySources=void 0,D(e,o,s),e._sources=s;const u=!e._hasValue||!e._equals(t,n);return e._hasValue=!0,e._value=n,u&&r&&a&&E(e,t,n),e._value}function F(e,r,o,a){const t=function(s){const u=l(t,s);j(u),y("selectorCandidateReads");const d=S(t,t._scheduled);return t._equals(d,s)};return t._owner=e,t._hookIndex=r,t._source=o,t._equals=a,t._value=void 0,t._hasValue=!1,t._dirty=!0,t._scheduled=!1,t._evaluating=!1,t._sources=new Set,t._primitiveCandidates=new Map,t._objectCandidates=new WeakMap,t._objectCandidateSources=new Set,t._markDirty=()=>{q(t)},t._cleanup=()=>{t._scheduled=!1,t._dirty=!1,t._hasValue=!1,i.delete(t),R(t,t._sources);for(const n of t._primitiveCandidates.values())n._readers?.clear(),n._derivedSubscribers?.clear();for(const n of t._objectCandidateSources)n._readers?.clear(),n._derivedSubscribers?.clear();t._primitiveCandidates.clear(),t._objectCandidateSources.clear()},e.cleanupFns.push(()=>{t._cleanup(),f.get(e)?.delete(r)}),t}function I(e,r,o,a){const t=k(e),n=t.get(r);if(n)return n._source=o,n._equals=a,n._dirty=!0,n;const s=F(e,r,o,a);return t.set(r,s),s}function L(e,r=Object.is){const o=v();if(!o)throw new Error("selector() can only be called during component render execution. Move selector() calls to the top level of your component function.");const a=h(o,"selector"),t=I(o,a,e,r);return S(t,!1),t}export{L as selector};
@@ -10,7 +10,7 @@
10
10
  * - state.set() always enqueues through scheduler (never direct mutation)
11
11
  * - state.set() callback (notifyUpdate) always available
12
12
  */
13
- import { type ComponentInstance } from './component';
13
+ import { type ReadableSource } from './readable';
14
14
  /**
15
15
  * State value holder - callable to read, has set method to update
16
16
  * @example
@@ -18,13 +18,11 @@ import { type ComponentInstance } from './component';
18
18
  * count(); // read: 0
19
19
  * count.set(1); // write: triggers re-render
20
20
  */
21
- export interface State<T> {
21
+ export interface State<T> extends ReadableSource<T> {
22
22
  (): T;
23
23
  set(value: T): void;
24
24
  set(updater: (prev: T) => T): void;
25
25
  [Symbol.iterator](): Iterator<State<T> | State<T>['set']>;
26
- _hasBeenRead?: boolean;
27
- _readers?: Map<ComponentInstance, number>;
28
26
  }
29
27
  /**
30
28
  * Creates a local state value for a component
@@ -1 +1 @@
1
- {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/runtime/state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,aAAa,CAAC;AAIrB;;;;;;GAMG;AACH,MAAM,WAAW,KAAK,CAAC,CAAC;IACtB,IAAI,CAAC,CAAC;IACN,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IACpB,GAAG,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IACnC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IAC1D,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,EAAE,GAAG,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;CAC3C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAwElD"}
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/runtime/state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AASH,OAAO,EAEL,KAAK,cAAc,EAIpB,MAAM,YAAY,CAAC;AAEpB;;;;;;GAMG;AACH,MAAM,WAAW,KAAK,CAAC,CAAC,CAAE,SAAQ,cAAc,CAAC,CAAC,CAAC;IACjD,IAAI,CAAC,CAAC;IACN,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IACpB,GAAG,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IACnC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;CAC3D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAqClD"}
@@ -1 +1 @@
1
- import{globalScheduler as i}from"./scheduler.js";import{getCurrentInstance as c,getNextStateIndex as h}from"./component.js";import{invariant as m}from"../dev/invariant.js";import{isBulkCommitActive as w}from"./fastlane.js";function _(d){const e=c();if(!e)throw new Error("state() can only be called during component render execution. Move state() calls to the top level of your component function.");const t=h(),r=e.stateValues;if(t<e.stateIndexCheck)throw new Error(`State index violation: state() call at index ${t}, but previously saw index ${e.stateIndexCheck}. This happens when state() is called conditionally (inside if/for/etc). Move all state() calls to the top level of your component function, before any conditionals.`);if(m(t>=e.stateIndexCheck,"[State] State indices must increase monotonically"),e.stateIndexCheck=t,e.firstRenderComplete){if(!e.expectedStateIndices.includes(t))throw new Error(`Hook order violation: state() called at index ${t}, but this index was not in the first render's sequence [${e.expectedStateIndices.join(", ")}]. This usually means state() is inside a conditional or loop. Move all state() calls to the top level of your component function.`)}else e.expectedStateIndices.push(t);if(r[t]){const o=r[t];if(o._owner!==e)throw new Error(`State ownership violation: state() called at index ${t} is owned by a different component instance. State ownership is positional and immutable.`);return o}const n=g(d,e);return r[t]=n,n}function g(d,e){let t=d;const r=new Map;function n(){n._hasBeenRead=!0;const o=c();return o&&o._currentRenderToken!==void 0&&(o._pendingReadStates||(o._pendingReadStates=new Set),o._pendingReadStates.add(n)),t}return n._readers=r,n._owner=e,n.set=o=>{if(c()!==null)throw new Error("[Askr] state.set() cannot be called during component render. State mutations during render break the actor model and cause infinite loops. Move state updates to event handlers or use conditional rendering instead.");let s;if(typeof o=="function"?s=o(t):s=o,Object.is(t,s))return;if(w()){t=s;return}t=s;const l=n._readers;if(l){for(const[a,p]of l)if(a.lastRenderToken===p&&!a.hasPendingUpdate){a.hasPendingUpdate=!0;const f=a._pendingFlushTask;f?i.enqueue(f):i.enqueue(()=>{a.hasPendingUpdate=!1,a.notifyUpdate?.()})}}const u=l?.get(e);if(u!==void 0&&e.lastRenderToken===u&&!e.hasPendingUpdate){e.hasPendingUpdate=!0;const a=e._pendingFlushTask;a?i.enqueue(a):i.enqueue(()=>{e.hasPendingUpdate=!1,e.notifyUpdate?.()})}},n[Symbol.iterator]=function*(){yield n,yield n.set},n}export{_ as state};
1
+ import{globalScheduler as c}from"./scheduler.js";import{getCurrentInstance as d,claimHookIndex as u}from"./component.js";import{isBulkCommitActive as f}from"./fastlane.js";import{recordReadableRead as p,markReadableDerivedSubscribersDirty as m,markReactivePropsDirtySource as h,notifyReadableReaders as b}from"./readable.js";function I(s){const n=d();if(!n)throw new Error("state() can only be called during component render execution. Move state() calls to the top level of your component function.");const t=u(n,"state"),r=n.stateValues;if(r[t]){const e=r[t];if(e._owner!==n)throw new Error(`State ownership violation: state() called at index ${t} is owned by a different component instance. State ownership is positional and immutable.`);return e}const i=y(s,n);return r[t]=i,i}function y(s,n){let t=s,r=-1;const i=new Map;function e(){return e._hasBeenRead=!0,p(e),t}return e._readers=i,e._owner=n,e.set=a=>{if(d()!==null)throw new Error("[Askr] state.set() cannot be called during component render. State mutations during render break the actor model and cause infinite loops. Move state updates to event handlers or use conditional rendering instead.");let o;if(typeof a=="function"?o=a(t):o=a,Object.is(t,o))return;if(f()){t=o;return}t=o,m(e),h(e);const l=c.getFlushVersion();if(r===l&&!c.isExecuting())return;r=b(e)&&!c.isExecuting()?l:-1},e[Symbol.iterator]=function*(){yield e,yield e.set},e}export{I as state};
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Batch rendering of multiple routes for SSG
3
+ */
4
+ import type { RouteConfig, RouteRenderResult } from './types';
5
+ import type { SSRData } from '../common/ssr';
6
+ interface BatchRenderOptions {
7
+ seed?: number;
8
+ dataMap?: Record<string, SSRData>;
9
+ concurrency?: number;
10
+ }
11
+ /**
12
+ * Render multiple routes in parallel with error handling
13
+ */
14
+ export declare function batchRenderRoutes(routes: RouteConfig[], options?: BatchRenderOptions): Promise<RouteRenderResult[]>;
15
+ export {};
16
+ //# sourceMappingURL=batch-render.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"batch-render.d.ts","sourceRoot":"","sources":["../../src/ssg/batch-render.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAG9D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAG7C,UAAU,kBAAkB;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,WAAW,EAAE,EACrB,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAgF9B"}
@@ -0,0 +1 @@
1
+ import{renderResolvedToStringSync as b}from"../ssr/index.js";import{interpolateRoutePath as M,getOutputFilePath as m}from"./route-utils.js";async function k(a,u={}){const{seed:d=12345,dataMap:c={},concurrency:f=1}=u,g=Math.max(1,Math.min(f,a.length||1)),l=new Array(a.length);let h=0;const y=async e=>{const i=performance.now(),n=M(e.path,e.params),o=c[e.path]??c[n]??{},p=e.handler?e.handler:(t,r)=>{const s=e.component;return s({...e.props||{},...t||{}},r)};try{const t={path:e.path,handler:p,namespace:e.namespace},r=b({url:n,routes:[t],handler:p,params:e.params,options:{seed:d,data:o}}),s=performance.now()-i;return{path:n,filePath:m(n),html:r,fileSize:Buffer.byteLength(r,"utf8"),renderDuration:Math.round(s),resourceCount:Object.keys(o).length,status:"success",reason:"full",written:!1}}catch(t){const r=performance.now()-i;return{path:n,filePath:m(n),html:"",fileSize:0,renderDuration:Math.round(r),resourceCount:Object.keys(o).length,status:"error",reason:"full",written:!1,error:t instanceof Error?t.message:String(t)}}},w=async()=>{for(;;){const e=h;if(h+=1,e>=a.length)return;l[e]=await y(a[e])}};return await Promise.all(Array.from({length:g},()=>w())),l}export{k as batchRenderRoutes};
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Static Site Generation API
3
+ *
4
+ * Main orchestrator for batch rendering, file I/O, and metadata generation
5
+ */
6
+ import type { SSGGenerateOptions, SSGOptions, SSGResult } from './types';
7
+ /**
8
+ * Create a Static Site Generator
9
+ *
10
+ * Usage:
11
+ * ```ts
12
+ * const ssg = createStaticGen({
13
+ * routes: [
14
+ * { path: '/', component: HomePage },
15
+ * { path: '/about', component: AboutPage },
16
+ * ],
17
+ * outputDir: './dist',
18
+ * dataOverrides: {
19
+ * '/api/posts': { posts: [...] }
20
+ * }
21
+ * });
22
+ *
23
+ * const result = await ssg.generate();
24
+ * console.log(`Generated ${result.successful}/${result.totalRoutes} routes`);
25
+ * ```
26
+ */
27
+ export declare function createStaticGen(options: SSGOptions): {
28
+ /**
29
+ * Generate static HTML for all routes
30
+ * Writes to outputDir with metadata.json
31
+ * Returns detailed results
32
+ */
33
+ generate(generateOptions?: SSGGenerateOptions): Promise<SSGResult>;
34
+ /**
35
+ * Get effective config in a serializable form for diagnostics.
36
+ */
37
+ getConfig(): {
38
+ routeCount: number;
39
+ outputDir: string;
40
+ seed: number;
41
+ concurrency: number;
42
+ parallelism: number;
43
+ hasDataOverrides: boolean;
44
+ };
45
+ /**
46
+ * Get the last generation result
47
+ * Returns null if generate() hasn't been called
48
+ */
49
+ getResult(): SSGResult | null;
50
+ };
51
+ //# sourceMappingURL=create-static-gen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-static-gen.d.ts","sourceRoot":"","sources":["../../src/ssg/create-static-gen.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAGV,kBAAkB,EAElB,UAAU,EACV,SAAS,EACV,MAAM,SAAS,CAAC;AAyDjB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,UAAU;IAkB/C;;;;OAIG;+BAEgB,kBAAkB,GAClC,OAAO,CAAC,SAAS,CAAC;IAkMrB;;OAEG;;;;;;;;;IAYH;;;OAGG;iBACU,SAAS,GAAG,IAAI;EAIhC"}
@@ -0,0 +1 @@
1
+ import{validateRoutes as N,resolveSsgData as G}from"./resolve-ssg-data.js";import{batchRenderRoutes as W}from"./batch-render.js";import{writeStaticFiles as z}from"./write-static-files.js";import{generateSSGResult as V,resultToMetadata as q,writeMetadata as B}from"./generate-metadata.js";import{readIncrementalManifest as U,getExistingOutputFileSize as j,hashHtml as L,outputFileExists as Z,writeIncrementalManifest as $,SSG_MANIFEST_SCHEMA_VERSION as J}from"./incremental-manifest.js";import{resolveRouteDescriptor as Q}from"./route-utils.js";import{incrementPerfMetric as X,addPerfDuration as K}from"../runtime/perf-metrics.js";function Y(e){if(e!=="auto")return Math.max(1,e??1);const t=globalThis,a=Number(t.process?.env?.ASKR_SSG_WORKERS??t.process?.env?.NUMBER_OF_PROCESSORS??t.process?.env?.UV_THREADPOOL_SIZE);return Number.isFinite(a)&&a>0?Math.max(1,Math.trunc(a)):typeof t.navigator?.hardwareConcurrency=="number"?Math.max(1,t.navigator.hardwareConcurrency):1}function ie(e){let t=null;const a=e.seed??12345,o=Y(e.parallelism),l=Math.max(1,e.concurrency??o);if(!Array.isArray(e.routes)||e.routes.length===0)throw new Error("routes array is required");if(!e.outputDir||e.outputDir.trim().length===0)throw new Error("outputDir is required");return{async generate(s={}){N(e.routes);const p=C(s.changedKeys),w=C(s.changedRoutes),R=s.mode??"full",f=!s.forceFull&&R==="incremental"?U(e.outputDir,a):null,c=s.forceFull||R!=="incremental"||f===null?"full":"incremental",m=G(e.routes,{dataOverrides:e.dataOverrides}),S=e.routes.map(Q),H=new Map((f?.routes??[]).map(n=>[n.routeId,n])),x=new Set(S.map(n=>n.routeId)),y=S.map(n=>ee(n,H.get(n.routeId)??null,c,p,w)),g=y.filter(n=>n.reason!=="unchanged"),F=performance.now();X("ssgWorkerCount",o);const O=g.length>0?await W(g.map(n=>n.descriptor.route),{seed:a,dataMap:m,concurrency:l}):[];K("ssgRenderTimeMs",performance.now()-F);const T=new Map(O.map((n,r)=>[g[r].descriptor.routeId,n]));let v=0;const i=[],h=[];for(const n of y){const{descriptor:r,previous:u,reason:M}=n,k=m[r.route.path]??m[r.path]??{},D=Object.keys(k).length;if(M==="unchanged"){i.push({path:r.path,filePath:r.filePath,html:"",fileSize:u?.htmlHash!==null&&u!==null?j(e.outputDir,r.filePath):0,renderDuration:0,resourceCount:D,status:"skipped",reason:"unchanged",written:!1}),u&&h.push({...u,path:r.path,filePath:r.filePath,invalidationKeys:r.invalidationKeys.slice()});continue}const P=T.get(r.routeId);if(!P)throw new Error(`Missing rendered result for route "${r.path}"`);const d={...P,path:r.path,filePath:r.filePath,resourceCount:D,reason:M,written:!1};if(d.status==="success"){const I=L(d.html),E=c==="full"||!u||u.htmlHash!==I||!Z(e.outputDir,r.filePath);d.written=E,E||(v+=1),h.push({routeId:r.routeId,path:r.path,filePath:r.filePath,invalidationKeys:r.invalidationKeys.slice(),htmlHash:I,lastStatus:"success"})}else h.push({routeId:r.routeId,path:r.path,filePath:r.filePath,invalidationKeys:r.invalidationKeys.slice(),htmlHash:u?.htmlHash??null,lastStatus:"error"});i.push(d)}const _=te(f,x);i.push(..._);const b=performance.now();await z(i,e.outputDir,{concurrency:l}),K("ssgWriteTimeMs",performance.now()-b),t=V(i,{mode:c,cacheHits:v,invalidatedKeys:p,invalidatedRoutes:w});const A=q(t);return await B(A,e.outputDir),await $({schemaVersion:J,seed:a,mode:c,routes:h},e.outputDir),t},getConfig(){return{routeCount:e.routes.length,outputDir:e.outputDir,seed:a,concurrency:l,parallelism:o,hasDataOverrides:!!e.dataOverrides}},getResult(){return t}}}function C(e){return e?Array.from(new Set(e)):[]}function ee(e,t,a,o,l){return a==="full"?{descriptor:e,reason:"full",previous:t}:t?t.lastStatus==="error"||t.htmlHash===null?{descriptor:e,reason:"new-route",previous:t}:e.invalidationKeys.length===0?{descriptor:e,reason:"no-keys",previous:t}:l.includes(e.path)?{descriptor:e,reason:"changed-route",previous:t}:e.invalidationKeys.some(s=>o.includes(s))?{descriptor:e,reason:"changed-key",previous:t}:{descriptor:e,reason:"unchanged",previous:t}:{descriptor:e,reason:"new-route",previous:t}}function te(e,t){return e?e.routes.filter(a=>!t.has(a.routeId)).map(a=>({path:a.path,filePath:a.filePath,html:"",fileSize:0,renderDuration:0,resourceCount:0,status:"removed",reason:"deleted",written:!1})):[]}export{ie as createStaticGen};
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Resource auto-discovery for SSG
3
+ *
4
+ * Phase 1: Simplified version
5
+ * Phase 2: Can be extended to walk component tree and discover resources
6
+ */
7
+ import type { RouteConfig, DiscoveredResources } from './types';
8
+ /**
9
+ * Discover resources from a dry-run render
10
+ *
11
+ * In phase 1: returns empty map (users supply data manually)
12
+ * In phase 2: walk component tree to find resource() calls
13
+ */
14
+ export declare function discoverResources(_routes: RouteConfig[]): Promise<Record<string, DiscoveredResources>>;
15
+ //# sourceMappingURL=discover-resources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discover-resources.d.ts","sourceRoot":"","sources":["../../src/ssg/discover-resources.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEhE;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,WAAW,EAAE,GACrB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAI9C"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Metadata generation for SSG
3
+ *
4
+ * Generates and serializes metadata about generated static files.
5
+ * This module is Node-only and not intended for browser builds.
6
+ */
7
+ import type { RouteRenderResult, SSGMetadata, SSGMode, SSGResult } from './types';
8
+ interface GenerateResultOptions {
9
+ mode?: SSGMode;
10
+ cacheHits?: number;
11
+ invalidatedKeys?: string[];
12
+ invalidatedRoutes?: string[];
13
+ }
14
+ /**
15
+ * Generate SSGResult from render results
16
+ */
17
+ export declare function generateSSGResult(results: RouteRenderResult[], options?: GenerateResultOptions): SSGResult;
18
+ /**
19
+ * Convert SSGResult to metadata for JSON serialization
20
+ */
21
+ export declare function resultToMetadata(result: SSGResult): SSGMetadata;
22
+ /**
23
+ * Write metadata.json to output directory
24
+ */
25
+ export declare function writeMetadata(metadata: Record<string, unknown>, outputDir: string): Promise<void>;
26
+ export {};
27
+ //# sourceMappingURL=generate-metadata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-metadata.d.ts","sourceRoot":"","sources":["../../src/ssg/generate-metadata.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EACV,iBAAiB,EACjB,WAAW,EACX,OAAO,EACP,SAAS,EACV,MAAM,SAAS,CAAC;AAEjB,UAAU,qBAAqB;IAC7B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC9B;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,iBAAiB,EAAE,EAC5B,OAAO,GAAE,qBAA0B,GAClC,SAAS,CAyBX;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,GAAG,WAAW,CA0B/D;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC,CAQf"}
@@ -0,0 +1 @@
1
+ import"../_virtual/__vite-browser-external.js";import*as u from"node:path";function f(e,t={}){const i=e.filter(a=>a.status==="success").length,n=e.filter(a=>a.status==="error").length,o=e.reduce((a,c)=>a+c.renderDuration,0),d=e.filter(a=>a.status==="success"||a.status==="error").length,s=e.filter(a=>a.status==="skipped").length,r=e.filter(a=>a.status==="removed").length;return{generatedAt:new Date().toISOString(),totalRoutes:e.length,successful:i,failed:n,totalDuration:Math.round(o),mode:t.mode??"full",rebuilt:d,skipped:s,removed:r,cacheHits:t.cacheHits??0,invalidatedKeys:t.invalidatedKeys?.slice()??[],invalidatedRoutes:t.invalidatedRoutes?.slice()??[],routes:e}}function h(e){return{generatedAt:e.generatedAt,totalRoutes:e.totalRoutes,successful:e.successful,failed:e.failed,totalDuration:e.totalDuration,mode:e.mode,rebuilt:e.rebuilt,skipped:e.skipped,removed:e.removed,cacheHits:e.cacheHits,invalidatedKeys:e.invalidatedKeys.slice(),invalidatedRoutes:e.invalidatedRoutes.slice(),routes:e.routes.map(t=>({path:t.path,filePath:t.filePath,fileSize:t.fileSize,renderDuration:t.renderDuration,resourceCount:t.resourceCount,status:t.status,reason:t.reason,written:t.written,error:t.error}))}}async function m(e,t){const i=u.join(t,"metadata.json");await(void 0)(t,{recursive:!0}),await(void 0)(i,JSON.stringify(e,null,2),"utf8")}export{f as generateSSGResult,h as resultToMetadata,m as writeMetadata};
@@ -0,0 +1,23 @@
1
+ import type { RouteRenderStatus, SSGMode } from './types';
2
+ export declare const SSG_MANIFEST_SCHEMA_VERSION = 1;
3
+ export interface IncrementalManifestRouteEntry {
4
+ routeId: string;
5
+ path: string;
6
+ filePath: string;
7
+ invalidationKeys: string[];
8
+ htmlHash: string | null;
9
+ lastStatus: Extract<RouteRenderStatus, 'success' | 'error'>;
10
+ }
11
+ export interface IncrementalManifest {
12
+ schemaVersion: number;
13
+ seed: number;
14
+ mode: SSGMode;
15
+ routes: IncrementalManifestRouteEntry[];
16
+ }
17
+ export declare function hashHtml(html: string): string;
18
+ export declare function getIncrementalManifestPath(outputDir: string): string;
19
+ export declare function readIncrementalManifest(outputDir: string, seed: number): IncrementalManifest | null;
20
+ export declare function writeIncrementalManifest(manifest: IncrementalManifest, outputDir: string): Promise<void>;
21
+ export declare function getExistingOutputFileSize(outputDir: string, filePath: string): number;
22
+ export declare function outputFileExists(outputDir: string, filePath: string): boolean;
23
+ //# sourceMappingURL=incremental-manifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"incremental-manifest.d.ts","sourceRoot":"","sources":["../../src/ssg/incremental-manifest.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAE1D,eAAO,MAAM,2BAA2B,IAAI,CAAC;AAI7C,MAAM,WAAW,6BAA6B;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,OAAO,CAAC,iBAAiB,EAAE,SAAS,GAAG,OAAO,CAAC,CAAC;CAC7D;AAED,MAAM,WAAW,mBAAmB;IAClC,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,6BAA6B,EAAE,CAAC;CACzC;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQ7C;AAED,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEpE;AAED,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,GACX,mBAAmB,GAAG,IAAI,CA0C5B;AAED,wBAAsB,wBAAwB,CAC5C,QAAQ,EAAE,mBAAmB,EAC7B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC,CAQf;AAED,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACf,MAAM,CAWR;AAED,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAE7E"}
@@ -0,0 +1 @@
1
+ import*as i from"node:fs";import"../_virtual/__vite-browser-external.js";import*as a from"node:path";const u=1,f=".askr",h="ssg-manifest.json";function S(n){let t=2166136261;for(let e=0;e<n.length;e+=1)t^=n.charCodeAt(e),t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,"0")}function l(n){return a.join(n,f,h)}function d(n,t){const e=l(n);if(!i.existsSync(e))return null;try{const c=i.readFileSync(e,"utf8"),s=JSON.parse(c);if(s.schemaVersion!==u||s.seed!==t||!Array.isArray(s.routes))return null;const o=s.routes.filter(r=>!!r&&typeof r.routeId=="string"&&typeof r.path=="string"&&typeof r.filePath=="string"&&Array.isArray(r.invalidationKeys)&&(r.htmlHash===null||typeof r.htmlHash=="string")&&(r.lastStatus==="success"||r.lastStatus==="error"));return o.length!==s.routes.length?null:{schemaVersion:u,seed:t,mode:s.mode==="incremental"?"incremental":"full",routes:o}}catch{return null}}async function p(n,t){const e=l(t);await(void 0)(a.dirname(e),{recursive:!0}),await(void 0)(e,JSON.stringify(n,null,2),"utf8")}function g(n,t){const e=a.join(n,t);if(!i.existsSync(e))return 0;try{return i.statSync(e).size}catch{return 0}}function y(n,t){return i.existsSync(a.join(n,t))}export{u as SSG_MANIFEST_SCHEMA_VERSION,g as getExistingOutputFileSize,l as getIncrementalManifestPath,S as hashHtml,y as outputFileExists,d as readIncrementalManifest,p as writeIncrementalManifest};
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Static Site Generation (SSG)
3
+ *
4
+ * Generate static HTML files from Askr routes at build time.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * import { createStaticGen } from '@askrjs/askr/ssg';
9
+ *
10
+ * const ssg = createStaticGen({
11
+ * routes: [
12
+ * { path: '/', component: HomePage },
13
+ * { path: '/about', component: AboutPage },
14
+ * ],
15
+ * outputDir: './dist',
16
+ * });
17
+ *
18
+ * const result = await ssg.generate();
19
+ * console.log(`Generated ${result.successful} routes`);
20
+ * ```
21
+ */
22
+ export { createStaticGen } from './create-static-gen';
23
+ export type { RouteConfig, RouteRenderReason, SSGOptions, SSGGenerateOptions, SSGMode, SSGResult, SSGMetadata, RouteRenderResult, RouteRenderStatus, DiscoveredResources, } from './types';
24
+ export { batchRenderRoutes } from './batch-render';
25
+ export { writeStaticFiles, getOutputFilePath } from './write-static-files';
26
+ export { generateSSGResult, resultToMetadata, writeMetadata, } from './generate-metadata';
27
+ export { resolveSsgData, validateRoutes } from './resolve-ssg-data';
28
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ssg/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,YAAY,EACV,WAAW,EACX,iBAAiB,EACjB,UAAU,EACV,kBAAkB,EAClB,OAAO,EACP,SAAS,EACT,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,GACd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1 @@
1
+ import{createStaticGen as r}from"./create-static-gen.js";import{batchRenderRoutes as o}from"./batch-render.js";import{writeStaticFiles as p}from"./write-static-files.js";import{generateSSGResult as f,resultToMetadata as l,writeMetadata as m}from"./generate-metadata.js";import{resolveSsgData as x,validateRoutes as S}from"./resolve-ssg-data.js";import{getOutputFilePath as d}from"./route-utils.js";export{o as batchRenderRoutes,r as createStaticGen,f as generateSSGResult,d as getOutputFilePath,x as resolveSsgData,l as resultToMetadata,S as validateRoutes,m as writeMetadata,p as writeStaticFiles};
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Data resolution for SSG
3
+ *
4
+ * Merges user-supplied data overrides with any auto-discovered resources.
5
+ * In phase 1, primarily handles user-supplied data.
6
+ */
7
+ import type { SSRData } from '../common/ssr';
8
+ import type { RouteConfig } from './types';
9
+ interface DataResolutionOptions {
10
+ /** User-supplied data overrides per route path */
11
+ dataOverrides?: Record<string, unknown>;
12
+ }
13
+ /**
14
+ * Resolve and validate data for SSG routes
15
+ * Returns a map of route path -> SSRData
16
+ *
17
+ * In phase 1: accepts user-supplied dataOverrides
18
+ * In phase 2: can be extended to auto-discover resources
19
+ */
20
+ export declare function resolveSsgData(routes: RouteConfig[], options?: DataResolutionOptions): Record<string, SSRData>;
21
+ /**
22
+ * Validate routes are properly configured
23
+ */
24
+ export declare function validateRoutes(routes: RouteConfig[]): void;
25
+ export {};
26
+ //# sourceMappingURL=resolve-ssg-data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-ssg-data.d.ts","sourceRoot":"","sources":["../../src/ssg/resolve-ssg-data.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,UAAU,qBAAqB;IAC7B,kDAAkD;IAClD,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACzC;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,WAAW,EAAE,EACrB,OAAO,GAAE,qBAA0B,GAClC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAoBzB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAkE1D"}
@@ -0,0 +1 @@
1
+ function s(o,e={}){const{dataOverrides:t={}}=e,i={};for(const a of o)if(a.path in t){const r=t[a.path];if(typeof r!="object"||r===null||Array.isArray(r))throw new Error(`data for route "${a.path}" must be an object, got ${typeof r}`);i[a.path]=r}return i}function h(o){if(!Array.isArray(o))throw new Error("routes must be an array");if(o.length===0)throw new Error("routes array cannot be empty");const e=new Set;for(const t of o){if(typeof t.path!="string"||!t.path.startsWith("/"))throw new Error(`route path must be a string starting with "/", got "${t.path}"`);if(typeof(t.handler??t.component)!="function")throw new Error(`route handler must be a function for path "${t.path}"`);const a=`${t.path}::${JSON.stringify(t.params||{})}`;if(e.has(a))throw new Error(`duplicate route entry detected for path "${t.path}"`);if(e.add(a),t.path.includes("{")){const r=Array.from(t.path.matchAll(/\{([^}]+)\}/g)).map(n=>n[1]);if(!t.params)throw new Error(`route "${t.path}" uses path parameters and requires params`);for(const n of r)if(!(n in t.params))throw new Error(`route "${t.path}" missing required param "${n}"`)}if(t.invalidationKeys!==void 0){if(!Array.isArray(t.invalidationKeys))throw new Error(`route "${t.path}" invalidationKeys must be an array of strings`);for(const r of t.invalidationKeys)if(typeof r!="string"||r.length===0)throw new Error(`route "${t.path}" invalidationKeys must contain only non-empty strings`)}}}export{s as resolveSsgData,h as validateRoutes};