@askrjs/askr 0.0.21 → 0.0.25
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.
- package/LICENSE +201 -201
- package/README.md +160 -46
- package/dist/_virtual/___vite-browser-external.js +1 -0
- package/dist/_virtual/__vite-browser-external.js +1 -0
- package/dist/_virtual/_commonjsHelpers.js +1 -0
- package/dist/_virtual/main.js +1 -0
- package/dist/_virtual/preload-helper.js +1 -0
- package/dist/{benchmark.d.ts → bench/benchmark-entry.d.ts} +3 -3
- package/dist/bench/benchmark-entry.d.ts.map +1 -0
- package/dist/benchmark.js +1 -1
- package/dist/boot/index.d.ts +70 -0
- package/dist/boot/index.d.ts.map +1 -0
- package/dist/boot/index.js +2 -0
- package/dist/common/component.d.ts +16 -0
- package/dist/common/component.d.ts.map +1 -0
- package/dist/common/errors.d.ts +53 -0
- package/dist/common/errors.d.ts.map +1 -0
- package/dist/common/index.d.ts +14 -0
- package/dist/common/index.d.ts.map +1 -0
- package/dist/common/jsx.d.ts +17 -0
- package/dist/common/jsx.d.ts.map +1 -0
- package/dist/common/jsx.js +1 -0
- package/dist/{jsx-CPjsGyEg.d.ts → common/props.d.ts} +6 -18
- package/dist/common/props.d.ts.map +1 -0
- package/dist/{router-DaGtH1Sq.d.ts → common/router.d.ts} +10 -7
- package/dist/common/router.d.ts.map +1 -0
- package/dist/common/ssr-errors.d.ts +8 -0
- package/dist/common/ssr-errors.d.ts.map +1 -0
- package/dist/common/ssr-errors.js +1 -0
- package/dist/common/ssr.d.ts +17 -0
- package/dist/common/ssr.d.ts.map +1 -0
- package/dist/common/vnode.d.ts +17 -0
- package/dist/common/vnode.d.ts.map +1 -0
- package/dist/common/vnode.js +1 -0
- package/dist/components/link.d.ts +56 -0
- package/dist/components/link.d.ts.map +1 -0
- package/dist/components/link.js +1 -0
- package/dist/dev/invariant.d.ts +83 -0
- package/dist/dev/invariant.d.ts.map +1 -0
- package/dist/dev/invariant.js +2 -0
- package/dist/dev/logger.d.ts +13 -0
- package/dist/dev/logger.d.ts.map +1 -0
- package/dist/dev/logger.js +1 -0
- package/dist/dev/vite-plugin-askr.d.ts +18 -0
- package/dist/dev/vite-plugin-askr.d.ts.map +1 -0
- package/dist/dev/warnings.d.ts +5 -0
- package/dist/dev/warnings.d.ts.map +1 -0
- package/dist/for/for.d.ts +16 -0
- package/dist/for/for.d.ts.map +1 -0
- package/dist/for/for.js +1 -0
- package/dist/for/index.d.ts +2 -63
- package/dist/for/index.d.ts.map +1 -0
- package/dist/for/index.js +1 -1
- package/dist/foundations/core.d.ts +23 -0
- package/dist/foundations/core.d.ts.map +1 -0
- package/dist/foundations/core.js +1 -0
- package/dist/foundations/index.d.ts +3 -669
- package/dist/foundations/index.d.ts.map +1 -0
- package/dist/foundations/index.js +1 -1
- package/dist/foundations/interactions/dismissable.d.ts +58 -0
- package/dist/foundations/interactions/dismissable.d.ts.map +1 -0
- package/dist/foundations/interactions/dismissable.js +1 -0
- package/dist/foundations/interactions/focusable.d.ts +16 -0
- package/dist/foundations/interactions/focusable.d.ts.map +1 -0
- package/dist/foundations/interactions/focusable.js +1 -0
- package/dist/foundations/interactions/hoverable.d.ts +19 -0
- package/dist/foundations/interactions/hoverable.d.ts.map +1 -0
- package/dist/foundations/interactions/hoverable.js +1 -0
- package/dist/foundations/interactions/index.d.ts +5 -0
- package/dist/foundations/interactions/index.d.ts.map +1 -0
- package/dist/foundations/interactions/interaction-policy.d.ts +96 -0
- package/dist/foundations/interactions/interaction-policy.d.ts.map +1 -0
- package/dist/foundations/interactions/interaction-policy.js +1 -0
- package/dist/foundations/interactions/pressable.d.ts +54 -0
- package/dist/foundations/interactions/pressable.d.ts.map +1 -0
- package/dist/foundations/interactions/pressable.js +1 -0
- package/dist/foundations/interactions/roving-focus.d.ts +117 -0
- package/dist/foundations/interactions/roving-focus.d.ts.map +1 -0
- package/dist/foundations/interactions/roving-focus.js +1 -0
- package/dist/foundations/state/controllable.d.ts +53 -0
- package/dist/foundations/state/controllable.d.ts.map +1 -0
- package/dist/foundations/state/controllable.js +1 -0
- package/dist/foundations/state/index.d.ts +2 -0
- package/dist/foundations/state/index.d.ts.map +1 -0
- package/dist/foundations/structures/collection.d.ts +67 -0
- package/dist/foundations/structures/collection.d.ts.map +1 -0
- package/dist/foundations/structures/collection.js +1 -0
- package/dist/foundations/structures/index.d.ts +5 -0
- package/dist/foundations/structures/index.d.ts.map +1 -0
- package/dist/foundations/structures/layer.d.ts +102 -0
- package/dist/foundations/structures/layer.d.ts.map +1 -0
- package/dist/foundations/structures/layer.js +1 -0
- package/dist/{layout-BINPv-nz.d.ts → foundations/structures/layout.d.ts} +3 -4
- package/dist/foundations/structures/layout.d.ts.map +1 -0
- package/dist/foundations/structures/layout.js +1 -0
- package/dist/foundations/structures/portal.d.ts +33 -0
- package/dist/foundations/structures/portal.d.ts.map +1 -0
- package/dist/foundations/structures/portal.js +1 -0
- package/dist/foundations/structures/presence.d.ts +30 -0
- package/dist/foundations/structures/presence.d.ts.map +1 -0
- package/dist/foundations/structures/presence.js +1 -0
- package/dist/foundations/structures/slot.d.ts +31 -0
- package/dist/foundations/structures/slot.d.ts.map +1 -0
- package/dist/foundations/structures/slot.js +1 -0
- package/dist/foundations/structures.d.ts +14 -0
- package/dist/foundations/structures.d.ts.map +1 -0
- package/dist/foundations/structures.js +1 -0
- package/dist/foundations/utilities/aria.d.ts +13 -0
- package/dist/foundations/utilities/aria.d.ts.map +1 -0
- package/dist/foundations/utilities/aria.js +1 -0
- package/dist/foundations/utilities/compose-handlers.d.ts +34 -0
- package/dist/foundations/utilities/compose-handlers.d.ts.map +1 -0
- package/dist/foundations/utilities/compose-handlers.js +1 -0
- package/dist/foundations/utilities/compose-ref.d.ts +24 -0
- package/dist/foundations/utilities/compose-ref.d.ts.map +1 -0
- package/dist/foundations/utilities/compose-ref.js +1 -0
- package/dist/foundations/utilities/event-types.d.ts +17 -0
- package/dist/foundations/utilities/event-types.d.ts.map +1 -0
- package/dist/foundations/utilities/index.d.ts +7 -0
- package/dist/foundations/utilities/index.d.ts.map +1 -0
- package/dist/foundations/utilities/merge-props.d.ts +2 -0
- package/dist/foundations/utilities/merge-props.d.ts.map +1 -0
- package/dist/foundations/utilities/merge-props.js +1 -0
- package/dist/foundations/utilities/use-id.d.ts +29 -0
- package/dist/foundations/utilities/use-id.d.ts.map +1 -0
- package/dist/foundations/utilities/use-id.js +1 -0
- package/dist/fx/fx.d.ts +30 -0
- package/dist/fx/fx.d.ts.map +1 -0
- package/dist/fx/fx.js +1 -0
- package/dist/fx/index.d.ts +5 -184
- package/dist/fx/index.d.ts.map +1 -0
- package/dist/fx/index.js +1 -1
- package/dist/fx/noop.d.ts +12 -0
- package/dist/fx/noop.d.ts.map +1 -0
- package/dist/fx/noop.js +1 -0
- package/dist/fx/timing.d.ts +155 -0
- package/dist/fx/timing.d.ts.map +1 -0
- package/dist/fx/timing.js +1 -0
- package/dist/index.d.ts +18 -37
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -1
- package/dist/jsx/index.d.ts +4 -0
- package/dist/jsx/index.d.ts.map +1 -0
- package/dist/jsx/index.js +1 -0
- package/dist/jsx/jsx-dev-runtime.d.ts +4 -0
- package/dist/jsx/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/jsx/jsx-runtime.d.ts +10 -0
- package/dist/jsx/jsx-runtime.d.ts.map +1 -0
- package/dist/{types-BTT0Fc9S.d.ts → jsx/types.d.ts} +6 -3
- package/dist/jsx/types.d.ts.map +1 -0
- package/dist/jsx/types.js +1 -0
- package/dist/jsx/utils.d.ts +4 -0
- package/dist/jsx/utils.d.ts.map +1 -0
- package/dist/jsx/utils.js +1 -0
- package/dist/jsx-dev-runtime.js +1 -1
- package/dist/jsx-runtime.js +1 -1
- package/dist/node_modules/esbuild/lib/main.js +65 -0
- package/dist/renderer/cleanup.d.ts +25 -0
- package/dist/renderer/cleanup.d.ts.map +1 -0
- package/dist/renderer/cleanup.js +1 -0
- package/dist/renderer/dom.d.ts +44 -0
- package/dist/renderer/dom.d.ts.map +1 -0
- package/dist/renderer/dom.js +1 -0
- package/dist/renderer/evaluate.d.ts +4 -0
- package/dist/renderer/evaluate.d.ts.map +1 -0
- package/dist/renderer/evaluate.js +1 -0
- package/dist/renderer/fastpath.d.ts +7 -0
- package/dist/renderer/fastpath.d.ts.map +1 -0
- package/dist/renderer/fastpath.js +1 -0
- package/dist/renderer/index.d.ts +6 -0
- package/dist/renderer/index.d.ts.map +1 -0
- package/dist/renderer/index.js +1 -0
- package/dist/renderer/keyed.d.ts +23 -0
- package/dist/renderer/keyed.d.ts.map +1 -0
- package/dist/renderer/keyed.js +1 -0
- package/dist/renderer/reconcile.d.ts +88 -0
- package/dist/renderer/reconcile.d.ts.map +1 -0
- package/dist/renderer/reconcile.js +1 -0
- package/dist/renderer/types.d.ts +3 -0
- package/dist/renderer/types.d.ts.map +1 -0
- package/dist/renderer/types.js +1 -0
- package/dist/renderer/utils.d.ts +63 -0
- package/dist/renderer/utils.d.ts.map +1 -0
- package/dist/renderer/utils.js +1 -0
- package/dist/resources/index.d.ts +7 -22
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/index.js +1 -1
- package/dist/router/index.d.ts +8 -87
- package/dist/router/index.d.ts.map +1 -0
- package/dist/router/index.js +1 -1
- package/dist/router/match.d.ts +22 -0
- package/dist/router/match.d.ts.map +1 -0
- package/dist/router/match.js +1 -0
- package/dist/router/navigate.d.ts +20 -0
- package/dist/router/navigate.d.ts.map +1 -0
- package/dist/router/navigate.js +1 -0
- package/dist/router/route.d.ts +52 -0
- package/dist/router/route.d.ts.map +1 -0
- package/dist/router/route.js +1 -0
- package/dist/runtime/component.d.ts +123 -0
- package/dist/runtime/component.d.ts.map +1 -0
- package/dist/runtime/component.js +1 -0
- package/dist/runtime/context.d.ts +80 -0
- package/dist/runtime/context.d.ts.map +1 -0
- package/dist/runtime/context.js +1 -0
- package/dist/runtime/derive.d.ts +7 -0
- package/dist/runtime/derive.d.ts.map +1 -0
- package/dist/runtime/derive.js +1 -0
- package/dist/runtime/dev-namespace.d.ts +31 -0
- package/dist/runtime/dev-namespace.d.ts.map +1 -0
- package/dist/runtime/dev-namespace.js +1 -0
- package/dist/runtime/events.d.ts +52 -0
- package/dist/runtime/events.d.ts.map +1 -0
- package/dist/runtime/events.js +1 -0
- package/dist/runtime/execution-model.d.ts +4 -0
- package/dist/runtime/execution-model.d.ts.map +1 -0
- package/dist/runtime/execution-model.js +1 -0
- package/dist/runtime/fastlane.d.ts +27 -0
- package/dist/runtime/fastlane.d.ts.map +1 -0
- package/dist/runtime/fastlane.js +1 -0
- package/dist/runtime/for.d.ts +52 -0
- package/dist/runtime/for.d.ts.map +1 -0
- package/dist/runtime/for.js +1 -0
- package/dist/runtime/hydration.d.ts +25 -0
- package/dist/runtime/hydration.d.ts.map +1 -0
- package/dist/runtime/operations.d.ts +39 -0
- package/dist/runtime/operations.d.ts.map +1 -0
- package/dist/runtime/operations.js +1 -0
- package/dist/runtime/resource-cell.d.ts +35 -0
- package/dist/runtime/resource-cell.d.ts.map +1 -0
- package/dist/runtime/resource-cell.js +1 -0
- package/dist/runtime/scheduler.d.ts +48 -0
- package/dist/runtime/scheduler.d.ts.map +1 -0
- package/dist/runtime/scheduler.js +1 -0
- package/dist/runtime/snapshot.d.ts +25 -0
- package/dist/runtime/snapshot.d.ts.map +1 -0
- package/dist/runtime/ssr-bridge.d.ts +10 -0
- package/dist/runtime/ssr-bridge.d.ts.map +1 -0
- package/dist/runtime/ssr-bridge.js +1 -0
- package/dist/runtime/state.d.ts +56 -0
- package/dist/runtime/state.d.ts.map +1 -0
- package/dist/runtime/state.js +1 -0
- package/dist/ssr/attrs.d.ts +26 -0
- package/dist/ssr/attrs.d.ts.map +1 -0
- package/dist/ssr/attrs.js +1 -0
- package/dist/ssr/context.d.ts +47 -0
- package/dist/ssr/context.d.ts.map +1 -0
- package/dist/ssr/context.js +1 -0
- package/dist/ssr/create-ssr.d.ts +19 -0
- package/dist/ssr/create-ssr.d.ts.map +1 -0
- package/dist/ssr/errors.d.ts +6 -0
- package/dist/ssr/errors.d.ts.map +1 -0
- package/dist/ssr/errors.js +1 -0
- package/dist/ssr/escape.d.ts +38 -0
- package/dist/ssr/escape.d.ts.map +1 -0
- package/dist/ssr/escape.js +1 -0
- package/dist/ssr/index.d.ts +18 -94
- package/dist/ssr/index.d.ts.map +1 -0
- package/dist/ssr/index.js +1 -1
- package/dist/ssr/render-keys.d.ts +39 -0
- package/dist/ssr/render-keys.d.ts.map +1 -0
- package/dist/ssr/render-keys.js +1 -0
- package/dist/ssr/sink.d.ts +23 -0
- package/dist/ssr/sink.d.ts.map +1 -0
- package/dist/ssr/sink.js +1 -0
- package/dist/ssr/stream-render.d.ts +7 -0
- package/dist/ssr/stream-render.d.ts.map +1 -0
- package/dist/ssr/stream-render.js +1 -0
- package/dist/ssr/types.d.ts +21 -0
- package/dist/ssr/types.d.ts.map +1 -0
- package/dist/vite/index.js +3 -1
- package/package.json +11 -10
- package/dist/chunk-37RC6ZT3.js +0 -1
- package/dist/chunk-3L6PFAJ3.js +0 -1
- package/dist/chunk-47D5SNYH.js +0 -1
- package/dist/chunk-4RTKQ7SC.js +0 -1
- package/dist/chunk-5PLQPS3O.js +0 -1
- package/dist/chunk-62D2TNHX.js +0 -1
- package/dist/chunk-BP2CKUO6.js +0 -1
- package/dist/chunk-D2JSJKCW.js +0 -1
- package/dist/chunk-EQ5S5GU4.js +0 -1
- package/dist/chunk-HGMOQ3I7.js +0 -1
- package/dist/chunk-HZKAD5DE.js +0 -1
- package/dist/chunk-ILZCMHZM.js +0 -2
- package/dist/chunk-NL44ANML.js +0 -2
- package/dist/chunk-YRY4OLQF.js +0 -1
- package/dist/component-AJMg1Gmv.d.ts +0 -177
- package/dist/jsx-dev-runtime.d.ts +0 -7
- package/dist/jsx-runtime.d.ts +0 -14
- package/dist/logger-NGZDJLVS.js +0 -1
- package/dist/main-EPE35NMW.js +0 -65
- package/dist/navigate-4VAVLF3A.js +0 -1
- package/dist/route-IVG3V65Y.js +0 -1
- package/dist/vite/index.d.ts +0 -17
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/runtime/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,UAAU,CAAC;IAClB,QAAQ,EAAE,UAAU,CAAC;IACrB,SAAS,EAAE,UAAU,CAAC;IACtB,OAAO,EAAE,UAAU,CAAC;IACpB,SAAS,EAAE,UAAU,CAAC;IACtB,QAAQ,EAAE,UAAU,CAAC;IACrB,SAAS,EAAE,UAAU,CAAC;IACtB,KAAK,EAAE,UAAU,CAAC;IAClB,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,UAAU,CAAC;IAClB,MAAM,EAAE,KAAK,CAAC;IACd,OAAO,EAAE,aAAa,CAAC;IACvB,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,aAAa,CAAC;IACxB,MAAM,EAAE,KAAK,CAAC;IACd,MAAM,EAAE,KAAK,CAAC;IACd,KAAK,EAAE,UAAU,CAAC;IAClB,UAAU,EAAE,UAAU,CAAC;IACvB,QAAQ,EAAE,UAAU,CAAC;IACrB,SAAS,EAAE,UAAU,CAAC;IACtB,WAAW,EAAE,UAAU,CAAC;CACzB;AA0BD,UAAU,gBAAgB;IACxB,OAAO,EAAE,aAAa,CAAC;IACvB,QAAQ,EAAE,aAAa,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,uBAAuB,CAAC;CACnC;AAYD,wBAAgB,wBAAwB,IAAI,OAAO,CAElD;AAED,wBAAgB,sBAAsB,IAAI,IAAI,CAG7C;AAED,wBAAgB,qBAAqB,CAAC,SAAS,CAAC,EAAE,OAAO,GAAG,IAAI,CAK/D;AAED,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,CAErE;AAgID,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,aAAa,EACtB,eAAe,EAAE,aAAa,EAC9B,OAAO,CAAC,EAAE,uBAAuB,GAChC,IAAI,CAcN;AAED,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,MAAM,GAChB,IAAI,CAQN;AAED,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,OAAO,GACf,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,GAAG,SAAS,CAE3C;AAED,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,MAAM,GAChB,OAAO,CAGT;AAED,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAEvE;AAED,wBAAgB,sBAAsB,IAAI,SAAS,CAAC,MAAM,iBAAiB,CAAC,EAAE,CAE7E;AAED,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAE3D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{globalScheduler as i}from"./scheduler.js";import{logger as M}from"../dev/logger.js";const H=["click","dblclick","mousedown","mouseup","mouseover","mouseout","mousemove","focus","blur","input","change","keydown","keyup","keypress","submit","scroll","wheel","touchstart","touchend","touchmove","touchcancel"],s=new WeakMap;let c=!1,f=null,g=null;const a=new Map;function I(){return c}function W(){c=!1,C()}function _(e){c=!0,e&&(f=e)}function z(e){g=e}function C(){for(const[e,n]of a)for(const[t,o]of n)e.removeEventListener(t,o);a.clear()}function O(){return g||f||(typeof document<"u"?document.body:null)}function A(e,n,t,o,r,l){a.has(e)||a.set(e,new Map);const h=a.get(e),m=`${t}`;if(!h.has(m)){const p=u=>{const E=u.target;if(!E)return;const w=S(e,E,t);for(const d of w){const b=s.get(d);if(b){const v=b.get(t);if(v){const y=u;i.setInHandler(!0);try{v.handler(y)}catch(L){M.error("[Askr] Delegated event error:",L)}finally{i.setInHandler(!1)}}}if(u.cancelBubble)break}const D=i.getState();(D.queueLength??0)>0&&!D.running&&queueMicrotask(()=>{try{i.isExecuting()||i.flush()}catch(d){setTimeout(()=>{throw d})}})},k=T(t)??l;e.addEventListener(t,p,k),h.set(m,p)}s.has(n)||s.set(n,new Map),s.get(n).set(t,{handler:o,original:r,element:n,eventName:t,options:l})}function S(e,n,t){const o=[];let r=n;for(;r&&r!==e;)o.push(r),r=r.parentElement;return o}function T(e){if(e==="wheel"||e==="scroll"||e.startsWith("touch"))return{passive:!0}}function B(e,n,t,o,r){if(!c)return;const l=O();l&&A(l,e,n,t,o,r)}function P(e,n){const t=s.get(e);t&&(t.delete(n),t.size===0&&s.delete(e))}function V(e){return s.get(e)}function $(e,n){const t=s.get(e);return t?t.has(n):!1}function j(e){s.delete(e)}function J(){return H}function K(e){return H.includes(e)}export{B as addDelegatedListener,j as clearDelegatedHandlersForElement,W as disableEventDelegation,_ as enableEventDelegation,J as getDelegatedEventNames,V as getDelegatedHandlersForElement,$ as hasDelegatedHandler,K as isDelegatedEvent,I as isEventDelegationEnabled,P as removeDelegatedListener,z as setGlobalDelegationContainer};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution-model.d.ts","sourceRoot":"","sources":["../../src/runtime/execution-model.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,SAAS,GAAG,KAAK,CAAC;AAIvD,wBAAgB,iBAAiB,IAAI,cAAc,GAAG,SAAS,CAG9D;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,CAYhE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const t=Symbol.for("__ASKR_EXECUTION_MODEL__");function r(){return globalThis[t]}function c(e){const n=globalThis,o=n[t];if(o&&o!==e)throw new Error(`[Askr] mixing execution models is not allowed (current: ${o}, attempted: ${e}). Choose exactly one: createSPA, createSSR, or createIslands.`);o||(n[t]=e)}export{c as assertExecutionModel,r as getExecutionModel};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ComponentInstance } from './component';
|
|
2
|
+
export declare function enterBulkCommit(): void;
|
|
3
|
+
export declare function exitBulkCommit(): void;
|
|
4
|
+
export declare function isBulkCommitActive(): boolean;
|
|
5
|
+
export declare function markFastPathApplied(parent: Element): void;
|
|
6
|
+
export declare function isFastPathApplied(parent: Element): boolean;
|
|
7
|
+
export declare function classifyUpdate(instance: ComponentInstance, result: unknown): {
|
|
8
|
+
useFastPath: boolean;
|
|
9
|
+
reason: string;
|
|
10
|
+
} | {
|
|
11
|
+
useFastPath: boolean;
|
|
12
|
+
reason: string;
|
|
13
|
+
totalKeyed: number;
|
|
14
|
+
moveCount: number;
|
|
15
|
+
lisLen: number;
|
|
16
|
+
hasPropChanges: boolean;
|
|
17
|
+
} | {
|
|
18
|
+
readonly useFastPath: true;
|
|
19
|
+
readonly totalKeyed: number;
|
|
20
|
+
readonly moveCount: number;
|
|
21
|
+
readonly lisLen: number;
|
|
22
|
+
readonly hasPropChanges: boolean;
|
|
23
|
+
reason?: undefined;
|
|
24
|
+
};
|
|
25
|
+
export declare function commitReorderOnly(instance: ComponentInstance, result: unknown): boolean;
|
|
26
|
+
export declare function tryRuntimeFastLaneSync(instance: ComponentInstance, result: unknown): boolean;
|
|
27
|
+
//# sourceMappingURL=fastlane.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fastlane.d.ts","sourceRoot":"","sources":["../../src/runtime/fastlane.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAYrD,wBAAgB,eAAe,IAAI,IAAI,CAatC;AAED,wBAAgB,cAAc,IAAI,IAAI,CAIrC;AAED,wBAAgB,kBAAkB,IAAI,OAAO,CAE5C;AAID,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAOzD;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAE1D;AA4ED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,iBAAiB,EAAE,MAAM,EAAE,OAAO;;;;;;;;;;;;;;;;;EAsE1E;AAED,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,iBAAiB,EAC3B,MAAM,EAAE,OAAO,GACd,OAAO,CAmDT;AAiGD,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,iBAAiB,EAC3B,MAAM,EAAE,OAAO,GACd,OAAO,CAgBT"}
|
|
@@ -0,0 +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};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* For primitive runtime
|
|
3
|
+
*
|
|
4
|
+
* Manages per-item component instances and array reconciliation
|
|
5
|
+
* to eliminate over-invalidation in list rendering.
|
|
6
|
+
*/
|
|
7
|
+
import { type State } from './state';
|
|
8
|
+
import { type ComponentInstance } from './component';
|
|
9
|
+
import type { VNode } from '../common/vnode';
|
|
10
|
+
interface BenchMetrics {
|
|
11
|
+
itemsCreated: number;
|
|
12
|
+
itemsReused: number;
|
|
13
|
+
itemsRemoved: number;
|
|
14
|
+
itemsMoved: number;
|
|
15
|
+
rowFactoryInvocations: number;
|
|
16
|
+
keyLookups: number;
|
|
17
|
+
keyHits: number;
|
|
18
|
+
keyMisses: number;
|
|
19
|
+
domInserts: number;
|
|
20
|
+
domRemoves: number;
|
|
21
|
+
domMoves: number;
|
|
22
|
+
domAttrSets: number;
|
|
23
|
+
domTextSets: number;
|
|
24
|
+
reconcilePhaseMs: number;
|
|
25
|
+
domCommitPhaseMs: number;
|
|
26
|
+
fastLaneName: string | null;
|
|
27
|
+
}
|
|
28
|
+
declare function getBenchMetrics(): BenchMetrics;
|
|
29
|
+
export { getBenchMetrics };
|
|
30
|
+
export interface ForItemInstance<T> {
|
|
31
|
+
key: string | number | null;
|
|
32
|
+
item: T;
|
|
33
|
+
indexSignal: State<number>;
|
|
34
|
+
componentInstance: ComponentInstance;
|
|
35
|
+
vnode: VNode | undefined;
|
|
36
|
+
_startStateIndex: number;
|
|
37
|
+
_dom?: Node;
|
|
38
|
+
}
|
|
39
|
+
export interface ForState<T> {
|
|
40
|
+
sourceState: State<T[]> | null;
|
|
41
|
+
items: Map<string | number | null, ForItemInstance<T>>;
|
|
42
|
+
orderedKeys: Array<string | number | null>;
|
|
43
|
+
byFn: (item: T, index: number) => string | number | null;
|
|
44
|
+
renderFn: (item: T, index: () => number) => VNode;
|
|
45
|
+
parentInstance: ComponentInstance | null;
|
|
46
|
+
mounted: boolean;
|
|
47
|
+
}
|
|
48
|
+
export declare function createForState<T>(source: State<T[]> | (() => T[]), byFn: (item: T, index: number) => string | number, renderFn: (item: T, index: () => number) => VNode): ForState<T>;
|
|
49
|
+
export declare function createItemInstance<T>(key: string | number | null, item: T, index: number, forState: ForState<T>): ForItemInstance<T>;
|
|
50
|
+
export declare function reconcileForItems<T>(forState: ForState<T>, newArray: T[]): VNode[];
|
|
51
|
+
export declare function evaluateForState<T>(forState: ForState<T>, source: State<T[]> | (() => T[])): VNode[];
|
|
52
|
+
//# sourceMappingURL=for.d.ts.map
|
|
@@ -0,0 +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;IACnB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAmHD,iBAAS,eAAe,IAAI,YAAY,CAEvC;AAED,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC5B,IAAI,EAAE,CAAC,CAAC;IACR,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3B,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,IAAI,CAAC;CACb;AAED,MAAM,WAAW,QAAQ,CAAC,CAAC;IACzB,WAAW,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;IAC/B,KAAK,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,GAAG,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IACvD,WAAW,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,CAAC;IAC3C,IAAI,EAAE,CAAC,IAAI,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;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EACrB,QAAQ,EAAE,CAAC,EAAE,GACZ,KAAK,EAAE,CAoVT;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"}
|
|
@@ -0,0 +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};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Selective Hydration Configuration for Askr
|
|
3
|
+
*
|
|
4
|
+
* Provides options for deferring or skipping hydration of certain parts of the page
|
|
5
|
+
* to improve time-to-interactive (TTI).
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* - Set options before calling hydrateSPA
|
|
9
|
+
* - Add data-skip-hydrate attribute to elements to skip
|
|
10
|
+
* - Use deferUntilIdle to wait for idle time
|
|
11
|
+
* - Use deferBelowFold to defer off-screen content
|
|
12
|
+
*/
|
|
13
|
+
export interface SelectiveHydrationOptions {
|
|
14
|
+
deferUntilIdle?: boolean;
|
|
15
|
+
deferBelowFold?: boolean;
|
|
16
|
+
foldThreshold?: number;
|
|
17
|
+
skipSelectors?: string[];
|
|
18
|
+
}
|
|
19
|
+
export declare function setSelectiveHydrationOptions(opts: SelectiveHydrationOptions): void;
|
|
20
|
+
export declare function getSelectiveHydrationOptions(): Readonly<SelectiveHydrationOptions>;
|
|
21
|
+
export declare function resetSelectiveHydrationOptions(): void;
|
|
22
|
+
export declare function shouldSkipHydrationOnElement(element: Element): boolean;
|
|
23
|
+
export declare function isElementAboveFold(element: Element): boolean;
|
|
24
|
+
export declare function getHydrationOptions(): SelectiveHydrationOptions;
|
|
25
|
+
//# sourceMappingURL=hydration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hydration.d.ts","sourceRoot":"","sources":["../../src/runtime/hydration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,MAAM,WAAW,yBAAyB;IACxC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAID,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,yBAAyB,GAC9B,IAAI,CAEN;AAED,wBAAgB,4BAA4B,IAAI,QAAQ,CAAC,yBAAyB,CAAC,CAElF;AAED,wBAAgB,8BAA8B,IAAI,IAAI,CAIrD;AAED,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAetE;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAM5D;AAED,wBAAgB,mBAAmB,IAAI,yBAAyB,CAE/D"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export interface ResourceResult<T> {
|
|
2
|
+
value: T | null;
|
|
3
|
+
pending: boolean;
|
|
4
|
+
error: Error | null;
|
|
5
|
+
refresh(): void;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Resource primitive — simple, deterministic async primitive
|
|
9
|
+
* Usage: resource(fn, deps)
|
|
10
|
+
* - fn receives { signal }
|
|
11
|
+
* - captures execution context once at creation (synchronous step only)
|
|
12
|
+
* - executes at most once per generation; stale async results are ignored
|
|
13
|
+
* - refresh() cancels in-flight execution, increments generation and re-runs
|
|
14
|
+
* - exposes { value, pending, error, refresh }
|
|
15
|
+
* - during SSR, async results are disallowed and will throw synchronously
|
|
16
|
+
*/
|
|
17
|
+
export declare function resource<T>(fn: (opts: {
|
|
18
|
+
signal: AbortSignal;
|
|
19
|
+
}) => Promise<T> | T, deps?: unknown[]): ResourceResult<T>;
|
|
20
|
+
export declare function on(target: EventTarget, event: string, handler: EventListener): void;
|
|
21
|
+
export declare function timer(intervalMs: number, fn: () => void): void;
|
|
22
|
+
export declare function stream<T>(_source: unknown, _options?: Record<string, unknown>): {
|
|
23
|
+
value: T | null;
|
|
24
|
+
pending: boolean;
|
|
25
|
+
error: Error | null;
|
|
26
|
+
};
|
|
27
|
+
export declare function task(fn: () => void | (() => void) | Promise<void | (() => void)>): void;
|
|
28
|
+
/**
|
|
29
|
+
* Capture the result of a synchronous expression at call time and return a
|
|
30
|
+
* thunk that returns the captured value later. This is a low-level helper for
|
|
31
|
+
* cases where async continuations need to observe a snapshot of values at the
|
|
32
|
+
* moment scheduling occurred.
|
|
33
|
+
*
|
|
34
|
+
* Usage (public API):
|
|
35
|
+
* const snapshot = capture(() => someState());
|
|
36
|
+
* Promise.resolve().then(() => { use(snapshot()); });
|
|
37
|
+
*/
|
|
38
|
+
export declare function capture<T>(fn: () => T): () => T;
|
|
39
|
+
//# sourceMappingURL=operations.d.ts.map
|
|
@@ -0,0 +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,EAAE,MAAM,CAAC,MAAM,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 @@
|
|
|
1
|
+
import{getCurrentComponentInstance as h,registerMountOperation as g}from"./component.js";import{getCurrentContextFrame as w}from"./context.js";import{ResourceCell as y}from"./resource-cell.js";import{state as m}from"./state.js";import{globalScheduler as v}from"./scheduler.js";import{getSSRBridge as R}from"./ssr-bridge.js";import{SSRDataMissingError as C}from"../common/ssr-errors.js";function _(u,t=[]){const i=h(),o=i;if(!i){const n=R(),e=n.getCurrentRenderData();if(e){const r=n.getNextKey();return r in e||n.throwSSRDataMissing(),{value:e[r],pending:!1,error:null,refresh:()=>{}}}throw n.getCurrentSSRContext()&&n.throwSSRDataMissing(),new Error("[Askr] resource() must be called during component render inside an app. Do not create resources at module scope or outside render.")}const d=R(),f=d.getCurrentRenderData();if(f){const n=d.getNextKey();n in f||d.throwSSRDataMissing();const e=f[n],p=m({cell:void 0,snapshot:{value:e,pending:!1,error:null,refresh:()=>{}}}),r=p();return r.snapshot.value=e,r.snapshot.pending=!1,r.snapshot.error=null,p.set(r),r.snapshot}const a=m({cell:void 0,snapshot:{value:null,pending:!0,error:null,refresh:()=>{}}}),l=a();if(!l.cell){const n=w(),e=new y(u,t,n);e.ownerName=o.fn?.name||"<anonymous>",l.cell=e,l.snapshot=e.snapshot;const p=e.subscribe(()=>{const r=a();r.snapshot.value=e.snapshot.value,r.snapshot.pending=e.snapshot.pending,r.snapshot.error=e.snapshot.error,a.set(r);try{o._enqueueRun?.()}catch{}});if(o.cleanupFns.push(()=>{p(),e.abort()}),o.ssr){if(e.start(!0,!1),!e.pending){const r=a();r.snapshot.value=e.value,r.snapshot.pending=e.pending,r.snapshot.error=e.error}}else v.enqueue(()=>{try{e.start(!1,!1)}catch(r){const c=a();c.snapshot.value=e.value,c.snapshot.pending=e.pending,c.snapshot.error=r??null,a.set(c),o._enqueueRun?.();return}if(!e.pending){const r=a();r.snapshot.value=e.value,r.snapshot.pending=e.pending,r.snapshot.error=e.error,a.set(r),o._enqueueRun?.()}})}const s=l.cell;if(!s.deps||s.deps.length!==t.length||s.deps.some((n,e)=>n!==t[e])){s.deps=t.slice(),s.generation++,s.pending=!0,s.error=null;try{if(o.ssr){if(s.start(!0,!1),!s.pending){const n=a();n.snapshot.value=s.value,n.snapshot.pending=s.pending,n.snapshot.error=s.error}}else v.enqueue(()=>{if(s.start(!1,!1),!s.pending){const n=a();n.snapshot.value=s.value,n.snapshot.pending=s.pending,n.snapshot.error=s.error,a.set(n),o._enqueueRun?.()}})}catch(n){if(n instanceof C)throw n;s.error=n,s.pending=!1;const e=a();e.snapshot.value=s.value,e.snapshot.pending=s.pending,e.snapshot.error=s.error}}return l.snapshot}function M(u,t,i){const o=h()?.isRoot??!1;g(()=>{if(!o)throw new Error("[Askr] on() may only be used in root components");return u.addEventListener(t,i),()=>{u.removeEventListener(t,i)}})}function A(u,t){const i=h()?.isRoot??!1;g(()=>{if(!i)throw new Error("[Askr] timer() may only be used in root components");const o=setInterval(t,u);return()=>{clearInterval(o)}})}function N(u,t){return{value:null,pending:!0,error:null}}function F(u){const t=h()?.isRoot??!1;g(async()=>{if(!t)throw new Error("[Askr] task() may only be used in root components");return await u()})}function K(u){const t=u();return()=>t}export{K as capture,M as on,_ as resource,N as stream,F as task,A as timer};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type ContextFrame } from './context';
|
|
2
|
+
/**
|
|
3
|
+
* Pure, component-agnostic ResourceCell state machine.
|
|
4
|
+
* - Holds value/pending/error/generation/controller
|
|
5
|
+
* - Exposes a stable `snapshot` object: { value, pending, error, refresh }
|
|
6
|
+
* - Uses `withAsyncResourceContext` to bind the synchronous execution step
|
|
7
|
+
* to a captured frame. Continuations after await do not see the frame.
|
|
8
|
+
*/
|
|
9
|
+
export declare class ResourceCell<U> {
|
|
10
|
+
value: U | null;
|
|
11
|
+
pending: boolean;
|
|
12
|
+
error: Error | null;
|
|
13
|
+
generation: number;
|
|
14
|
+
controller: AbortController | null;
|
|
15
|
+
deps: unknown[] | null;
|
|
16
|
+
resourceFrame: ContextFrame | null;
|
|
17
|
+
ownerName?: string;
|
|
18
|
+
private subscribers;
|
|
19
|
+
readonly snapshot: {
|
|
20
|
+
value: U | null;
|
|
21
|
+
pending: boolean;
|
|
22
|
+
error: Error | null;
|
|
23
|
+
refresh: () => void;
|
|
24
|
+
};
|
|
25
|
+
private readonly fn;
|
|
26
|
+
constructor(fn: (opts: {
|
|
27
|
+
signal: AbortSignal;
|
|
28
|
+
}) => Promise<U> | U, deps: unknown[] | null, resourceFrame: ContextFrame | null);
|
|
29
|
+
subscribe(cb: () => void): () => void;
|
|
30
|
+
private notifySubscribers;
|
|
31
|
+
start(ssr?: boolean, notify?: boolean): void;
|
|
32
|
+
refresh(): void;
|
|
33
|
+
abort(): void;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=resource-cell.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-cell.d.ts","sourceRoot":"","sources":["../../src/runtime/resource-cell.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AAIxE;;;;;;GAMG;AACH,qBAAa,YAAY,CAAC,CAAC;IACzB,KAAK,EAAE,CAAC,GAAG,IAAI,CAAQ;IACvB,OAAO,UAAQ;IACf,KAAK,EAAE,KAAK,GAAG,IAAI,CAAQ;IAC3B,UAAU,SAAK;IACf,UAAU,EAAE,eAAe,GAAG,IAAI,CAAQ;IAC1C,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAQ;IAC9B,aAAa,EAAE,YAAY,GAAG,IAAI,CAAQ;IAG1C,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,OAAO,CAAC,WAAW,CAAyB;IAE5C,QAAQ,CAAC,QAAQ,EAAE;QACjB,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;QAChB,OAAO,EAAE,OAAO,CAAC;QACjB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;QACpB,OAAO,EAAE,MAAM,IAAI,CAAC;KACrB,CAAC;IAEF,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAoD;gBAGrE,EAAE,EAAE,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,WAAW,CAAA;KAAE,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,EACrD,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,EACtB,aAAa,EAAE,YAAY,GAAG,IAAI;IAapC,SAAS,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;IAKrC,OAAO,CAAC,iBAAiB;IAOzB,KAAK,CAAC,GAAG,UAAQ,EAAE,MAAM,UAAO;IAkEhC,OAAO;IAMP,KAAK;CAGN"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{withAsyncResourceContext as h}from"./context.js";import{logger as o}from"../dev/logger.js";import{getSSRBridge as l}from"./ssr-bridge.js";class b{constructor(r,e,t){this.value=null,this.pending=!0,this.error=null,this.generation=0,this.controller=null,this.deps=null,this.resourceFrame=null,this.subscribers=new Set,this.fn=r,this.deps=e?e.slice():null,this.resourceFrame=t,this.snapshot={value:null,pending:!0,error:null,refresh:()=>this.refresh()}}subscribe(r){return this.subscribers.add(r),()=>this.subscribers.delete(r)}notifySubscribers(){this.snapshot.value=this.value,this.snapshot.pending=this.pending,this.snapshot.error=this.error;for(const r of this.subscribers)r()}start(r=!1,e=!0){const t=this.generation;this.controller?.abort();const i=new AbortController;this.controller=i,this.pending=!0,this.error=null,e&&this.notifySubscribers();let n;try{n=h(this.resourceFrame,()=>this.fn({signal:i.signal}))}catch(s){this.pending=!1,this.error=s,e&&this.notifySubscribers();return}if(!(n instanceof Promise)){this.value=n,this.pending=!1,this.error=null,e&&this.notifySubscribers();return}r&&l().throwSSRDataMissing(),n.then(s=>{this.generation===t&&this.controller===i&&(this.value=s,this.pending=!1,this.error=null,this.notifySubscribers())}).catch(s=>{if(this.generation===t&&this.controller===i){this.pending=!1,this.error=s;try{this.ownerName?o.error(`[Askr] Async resource error in ${this.ownerName}:`,s):o.error("[Askr] Async resource error:",s)}catch{}this.notifySubscribers()}})}refresh(){this.generation++,this.controller?.abort(),this.start()}abort(){this.controller?.abort()}}export{b as ResourceCell};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serialized update scheduler — safer design (no inline execution, explicit flush)
|
|
3
|
+
*
|
|
4
|
+
* Key ideas:
|
|
5
|
+
* - Never execute a task inline from `enqueue`.
|
|
6
|
+
* - `flush()` is explicit and non-reentrant.
|
|
7
|
+
* - `runWithSyncProgress()` allows enqueues temporarily but does not run tasks
|
|
8
|
+
* inline; it runs `fn` and then does an explicit `flush()`.
|
|
9
|
+
* - `waitForFlush()` is race-free with a monotonic `flushVersion`.
|
|
10
|
+
*/
|
|
11
|
+
type Task = () => void;
|
|
12
|
+
export declare class Scheduler {
|
|
13
|
+
private q;
|
|
14
|
+
private head;
|
|
15
|
+
private running;
|
|
16
|
+
private inHandler;
|
|
17
|
+
private depth;
|
|
18
|
+
private executionDepth;
|
|
19
|
+
private flushVersion;
|
|
20
|
+
private kickScheduled;
|
|
21
|
+
private allowSyncProgress;
|
|
22
|
+
private waiters;
|
|
23
|
+
private taskCount;
|
|
24
|
+
enqueue(task: Task): void;
|
|
25
|
+
flush(): void;
|
|
26
|
+
runWithSyncProgress<T>(fn: () => T): T;
|
|
27
|
+
waitForFlush(targetVersion?: number, timeoutMs?: number): Promise<void>;
|
|
28
|
+
getState(): {
|
|
29
|
+
queueLength: number;
|
|
30
|
+
running: boolean;
|
|
31
|
+
depth: number;
|
|
32
|
+
executionDepth: number;
|
|
33
|
+
taskCount: number;
|
|
34
|
+
flushVersion: number;
|
|
35
|
+
inHandler: boolean;
|
|
36
|
+
allowSyncProgress: boolean;
|
|
37
|
+
};
|
|
38
|
+
setInHandler(v: boolean): void;
|
|
39
|
+
isInHandler(): boolean;
|
|
40
|
+
isExecuting(): boolean;
|
|
41
|
+
clearPendingSyncTasks(): number;
|
|
42
|
+
private resolveWaiters;
|
|
43
|
+
}
|
|
44
|
+
export declare const globalScheduler: Scheduler;
|
|
45
|
+
export declare function isSchedulerExecuting(): boolean;
|
|
46
|
+
export declare function scheduleEventHandler(handler: EventListener): EventListener;
|
|
47
|
+
export {};
|
|
48
|
+
//# sourceMappingURL=scheduler.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +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};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* State snapshot for SSR and hydration
|
|
3
|
+
* Serializes per-component state indexed by (componentId, stateIndex)
|
|
4
|
+
* Enables deterministic serialization and replay
|
|
5
|
+
*/
|
|
6
|
+
import type { ComponentInstance } from './component';
|
|
7
|
+
export interface Snapshot {
|
|
8
|
+
[componentId: string]: {
|
|
9
|
+
[stateIndex: number]: unknown;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export declare function createSnapshot(): Snapshot;
|
|
13
|
+
/**
|
|
14
|
+
* Capture state from active component instances
|
|
15
|
+
* @param components Map of componentId -> ComponentInstance
|
|
16
|
+
* @returns Snapshot with structure { [componentId]: { [stateIndex]: value } }
|
|
17
|
+
*/
|
|
18
|
+
export declare function captureSnapshot(components: Map<string, ComponentInstance>): Snapshot;
|
|
19
|
+
/**
|
|
20
|
+
* Restore component state from snapshot
|
|
21
|
+
* @param snapshot Snapshot with structure { [componentId]: { [stateIndex]: value } }
|
|
22
|
+
* @param components Map of componentId -> ComponentInstance
|
|
23
|
+
*/
|
|
24
|
+
export declare function restoreSnapshot(snapshot: Snapshot, components: Map<string, ComponentInstance>): void;
|
|
25
|
+
//# sourceMappingURL=snapshot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../src/runtime/snapshot.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,MAAM,WAAW,QAAQ;IACvB,CAAC,WAAW,EAAE,MAAM,GAAG;QACrB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC;KAC/B,CAAC;CACH;AAED,wBAAgB,cAAc,IAAI,QAAQ,CAEzC;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,GACzC,QAAQ,CAcV;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,GACzC,IAAI,CAeN"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { RenderContext } from '../common/ssr';
|
|
2
|
+
export type SSRBridge = {
|
|
3
|
+
getCurrentSSRContext(): RenderContext | null;
|
|
4
|
+
throwSSRDataMissing(): never;
|
|
5
|
+
getCurrentRenderData(): Record<string, unknown> | null;
|
|
6
|
+
getNextKey(): string;
|
|
7
|
+
};
|
|
8
|
+
export declare function installSSRBridge(next: SSRBridge): void;
|
|
9
|
+
export declare function getSSRBridge(): SSRBridge;
|
|
10
|
+
//# sourceMappingURL=ssr-bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssr-bridge.d.ts","sourceRoot":"","sources":["../../src/runtime/ssr-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,MAAM,MAAM,SAAS,GAAG;IACtB,oBAAoB,IAAI,aAAa,GAAG,IAAI,CAAC;IAC7C,mBAAmB,IAAI,KAAK,CAAC;IAG7B,oBAAoB,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACvD,UAAU,IAAI,MAAM,CAAC;CACtB,CAAC;AAwBF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,CAEtD;AAED,wBAAgB,YAAY,IAAI,SAAS,CAExC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const t={getCurrentSSRContext(){return null},throwSSRDataMissing(){throw new Error("[Askr] SSR data missing (SSR bridge not installed). If you are rendering on the server, ensure you are using the askr SSR entrypoints.")},getCurrentRenderData(){return null},getNextKey(){throw new Error("[Askr] getNextKey() called outside SSR render phase (SSR bridge not installed).")}};let e=t;function n(r){e=r}function i(){return e}export{i as getSSRBridge,n as installSSRBridge};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* State primitive for Askr components
|
|
3
|
+
* Optimized for minimal overhead and fast updates
|
|
4
|
+
*
|
|
5
|
+
* INVARIANTS ENFORCED:
|
|
6
|
+
* - state() only callable during component render (currentInstance exists)
|
|
7
|
+
* - state() called at top-level only (indices must be monotonically increasing)
|
|
8
|
+
* - state values persist across re-renders (stored in stateValues array)
|
|
9
|
+
* - state.set() cannot be called during render (causes infinite loops)
|
|
10
|
+
* - state.set() always enqueues through scheduler (never direct mutation)
|
|
11
|
+
* - state.set() callback (notifyUpdate) always available
|
|
12
|
+
*/
|
|
13
|
+
import { type ComponentInstance } from './component';
|
|
14
|
+
/**
|
|
15
|
+
* State value holder - callable to read, has set method to update
|
|
16
|
+
* @example
|
|
17
|
+
* const count = state(0);
|
|
18
|
+
* count(); // read: 0
|
|
19
|
+
* count.set(1); // write: triggers re-render
|
|
20
|
+
*/
|
|
21
|
+
export interface State<T> {
|
|
22
|
+
(): T;
|
|
23
|
+
set(value: T): void;
|
|
24
|
+
set(updater: (prev: T) => T): void;
|
|
25
|
+
[Symbol.iterator](): Iterator<State<T> | State<T>['set']>;
|
|
26
|
+
_hasBeenRead?: boolean;
|
|
27
|
+
_readers?: Map<ComponentInstance, number>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Creates a local state value for a component
|
|
31
|
+
* Optimized for:
|
|
32
|
+
* - O(1) read performance
|
|
33
|
+
* - Minimal allocation per state
|
|
34
|
+
* - Fast scheduler integration
|
|
35
|
+
*
|
|
36
|
+
* IMPORTANT: state() must be called during component render execution.
|
|
37
|
+
* It captures the current component instance from context.
|
|
38
|
+
* Calling outside a component function will throw an error.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* // ✅ Correct: called during render
|
|
43
|
+
* export function Counter() {
|
|
44
|
+
* const count = state(0);
|
|
45
|
+
* return { type: 'button', children: [count()] };
|
|
46
|
+
* }
|
|
47
|
+
*
|
|
48
|
+
* // ❌ Wrong: called outside component
|
|
49
|
+
* const count = state(0);
|
|
50
|
+
* export function BadComponent() {
|
|
51
|
+
* return { type: 'div' };
|
|
52
|
+
* }
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare function state<T>(initialValue: T): State<T>;
|
|
56
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +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};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTML attribute rendering for SSR
|
|
3
|
+
*/
|
|
4
|
+
import type { Props } from '../common/props';
|
|
5
|
+
import type { RenderSink } from './sink';
|
|
6
|
+
/** Result of renderAttrs including any raw HTML from dangerouslySetInnerHTML */
|
|
7
|
+
export type AttrsResult = {
|
|
8
|
+
attrs: string;
|
|
9
|
+
dangerousHtml?: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Render attributes directly to a sink without intermediate string allocations.
|
|
13
|
+
* This is the hot path for streaming SSR.
|
|
14
|
+
*/
|
|
15
|
+
export declare function renderAttrsDirect(props: Props | undefined, sink: RenderSink): void;
|
|
16
|
+
/**
|
|
17
|
+
* Render attributes to HTML string, excluding event handlers
|
|
18
|
+
* Optimized for minimal allocations using push-based approach
|
|
19
|
+
*
|
|
20
|
+
* Returns both the attribute string and any dangerouslySetInnerHTML content.
|
|
21
|
+
*/
|
|
22
|
+
export declare function renderAttrs(props?: Props): string;
|
|
23
|
+
export declare function renderAttrs(props: Props | undefined, opts: {
|
|
24
|
+
returnDangerousHtml: true;
|
|
25
|
+
}): AttrsResult;
|
|
26
|
+
//# sourceMappingURL=attrs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attrs.d.ts","sourceRoot":"","sources":["../../src/ssr/attrs.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAGzC,gFAAgF;AAChF,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAaF;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,KAAK,GAAG,SAAS,EACxB,IAAI,EAAE,UAAU,GACf,IAAI,CA6DN;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;AACnD,wBAAgB,WAAW,CACzB,KAAK,EAAE,KAAK,GAAG,SAAS,EACxB,IAAI,EAAE;IAAE,mBAAmB,EAAE,IAAI,CAAA;CAAE,GAClC,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{styleObjToCss as d,needsEscapeAttr as a,escapeAttr as l}from"./escape.js";function h(r){return r.length>=3&&r.charCodeAt(0)===111&&r.charCodeAt(1)===110&&r.charCodeAt(2)>=65&&r.charCodeAt(2)<=90}function y(r,e){if(!r||typeof r!="object")return;const c=r;for(const i in c){const o=c[i];if(i==="children"||i==="key"||i==="ref"||i==="dangerouslySetInnerHTML"||h(i)||i.charCodeAt(0)===95)continue;const s=i==="className"?"class":i;if(s==="style"){const t=typeof o=="string"?o:d(o);if(!t)continue;e.write(' style="'),a(t)?e.write(l(t)):e.write(t),e.write('"');continue}if(o===!0){e.write(" "),e.write(s);continue}if(o===!1||o===null||o===void 0)continue;const n=String(o);e.write(" "),e.write(s),e.write('="'),a(n)?e.write(l(n)):e.write(n),e.write('"')}}function g(r,e){if(!r||typeof r!="object")return e?.returnDangerousHtml?{attrs:""}:"";const c=[];let i;const o=r;for(const n in o){const t=o[n];if(n==="children"||n==="key"||n==="ref")continue;if(n==="dangerouslySetInnerHTML"){t&&typeof t=="object"&&"__html"in t&&(i=String(t.__html));continue}if(h(n)||n.charCodeAt(0)===95)continue;const f=n==="class"||n==="className"?"class":n;if(f==="style"){const u=typeof t=="string"?t:d(t);if(u===null||u==="")continue;c.push(` style="${l(u)}"`);continue}if(t===!0)c.push(` ${f}`);else{if(t===!1||t===null||t===void 0)continue;{const u=String(t);c.push(` ${f}="${l(u)}"`)}}}const s=c.join("");return e?.returnDangerousHtml?{attrs:s,dangerousHtml:i}:s}export{g as renderAttrs,y as renderAttrsDirect};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SSR Context Management
|
|
3
|
+
*
|
|
4
|
+
* Provides concurrency-safe context for server-side rendering.
|
|
5
|
+
* In Node.js, uses AsyncLocalStorage for isolation between concurrent requests.
|
|
6
|
+
* Falls back to stack-based approach in non-Node environments.
|
|
7
|
+
*/
|
|
8
|
+
import { SSRDataMissingError } from './errors';
|
|
9
|
+
export type { SSRData } from '../common/ssr';
|
|
10
|
+
import type { SSRData } from '../common/ssr';
|
|
11
|
+
export interface RenderContext {
|
|
12
|
+
url: string;
|
|
13
|
+
seed: number;
|
|
14
|
+
data?: SSRData;
|
|
15
|
+
params?: Record<string, string>;
|
|
16
|
+
signal?: AbortSignal;
|
|
17
|
+
keyCounter: number;
|
|
18
|
+
renderData: Record<string, unknown> | null;
|
|
19
|
+
}
|
|
20
|
+
export type SSRContext = RenderContext;
|
|
21
|
+
export declare function createRenderContext(seed?: number, opts?: {
|
|
22
|
+
url?: string;
|
|
23
|
+
data?: SSRData;
|
|
24
|
+
params?: Record<string, string>;
|
|
25
|
+
signal?: AbortSignal;
|
|
26
|
+
}): RenderContext;
|
|
27
|
+
/**
|
|
28
|
+
* Run a function with the given render context.
|
|
29
|
+
* Concurrency-safe in Node.js via AsyncLocalStorage.
|
|
30
|
+
*/
|
|
31
|
+
export declare function withRenderContext<T>(ctx: RenderContext, fn: () => T): T;
|
|
32
|
+
/**
|
|
33
|
+
* Get the current render context.
|
|
34
|
+
* Returns null if not inside a render.
|
|
35
|
+
*/
|
|
36
|
+
export declare function getRenderContext(): RenderContext | null;
|
|
37
|
+
export declare const getSSRContext: typeof getRenderContext;
|
|
38
|
+
export declare const withSSRContext: typeof withRenderContext;
|
|
39
|
+
export declare const getCurrentSSRContext: typeof getRenderContext;
|
|
40
|
+
export declare function runWithSSRContext<T>(ctx: RenderContext, fn: () => T): T;
|
|
41
|
+
/**
|
|
42
|
+
* Centralized SSR enforcement helper — throws a consistent error when async
|
|
43
|
+
* data is encountered during synchronous SSR.
|
|
44
|
+
*/
|
|
45
|
+
export declare function throwSSRDataMissing(): never;
|
|
46
|
+
export { SSRDataMissingError };
|
|
47
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/ssr/context.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C,YAAY,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAG7C,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,MAAM,CAAC,EAAE,WAAW,CAAC;IAErB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CAC5C;AAGD,MAAM,MAAM,UAAU,GAAG,aAAa,CAAC;AA0BvC,wBAAgB,mBAAmB,CACjC,IAAI,SAAQ,EACZ,IAAI,GAAE;IACJ,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,MAAM,CAAC,EAAE,WAAW,CAAC;CACjB,GACL,aAAa,CAUf;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,GAAG,EAAE,aAAa,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAYvE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,aAAa,GAAG,IAAI,CAKvD;AAGD,eAAO,MAAM,aAAa,yBAAmB,CAAC;AAC9C,eAAO,MAAM,cAAc,0BAAoB,CAAC;AAChD,eAAO,MAAM,oBAAoB,yBAAmB,CAAC;AAErD,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,GAAG,EAAE,aAAa,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAGvE;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,KAAK,CAE3C;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./errors.js";import{SSRDataMissingError as c}from"../common/ssr-errors.js";let r=null;try{const t=require("async_hooks");t?.AsyncLocalStorage&&(r=new t.AsyncLocalStorage)}catch{}let e=null;function S(t=12345,n={}){return{url:n.url??"",seed:t,data:n.data,params:n.params,signal:n.signal,keyCounter:0,renderData:null}}function o(t,n){if(r)return r.run(t,n);const u=e;e=t;try{return n()}finally{e=u}}function a(){return r?r.getStore()??null:e}const s=a,g=o,f=a;function C(t,n){return o(t,n)}function R(){throw new c}export{c as SSRDataMissingError,S as createRenderContext,f as getCurrentSSRContext,a as getRenderContext,s as getSSRContext,C as runWithSSRContext,R as throwSSRDataMissing,o as withRenderContext,g as withSSRContext};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type SSRRoute } from './index';
|
|
2
|
+
export type SSRConfig = {
|
|
3
|
+
routes: SSRRoute[];
|
|
4
|
+
seed?: number;
|
|
5
|
+
};
|
|
6
|
+
export type SSRApp = {
|
|
7
|
+
/** Render a URL to HTML. SSR is synchronous; async during render throws. */
|
|
8
|
+
render(url: string, data?: Record<string, unknown> | null): string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* createSSR: constructs a strict SSR renderer.
|
|
12
|
+
*
|
|
13
|
+
* - Exactly one execution model (SSR)
|
|
14
|
+
* - Routes are required
|
|
15
|
+
* - Rendering is synchronous and deterministic
|
|
16
|
+
* - Each render call is concurrency-safe (isolated context)
|
|
17
|
+
*/
|
|
18
|
+
export declare function createSSR(config: SSRConfig): SSRApp;
|
|
19
|
+
//# sourceMappingURL=create-ssr.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-ssr.d.ts","sourceRoot":"","sources":["../../src/ssr/create-ssr.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAC;AAIxD,MAAM,MAAM,SAAS,GAAG;IACtB,MAAM,EAAE,QAAQ,EAAE,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACnB,4EAA4E;IAC5E,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,MAAM,CAAC;CACpE,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CA0BnD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/ssr/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,QAAQ,CAAC,IAAI,6BAA6B;gBAC9B,OAAO,EAAE,MAAM;CAK5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{SSRDataMissingError as s}from"../common/ssr-errors.js";class r extends Error{constructor(t){super(t),this.code="SSR_INVARIANT_VIOLATION",this.name="SSRInvariantError",Object.setPrototypeOf(this,r.prototype)}}export{s as SSRDataMissingError,r as SSRInvariantError};
|