@askrjs/askr 0.0.27 → 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.
- package/README.md +56 -20
- package/dist/_virtual/_fs.js +1 -0
- package/dist/_virtual/_path.js +1 -0
- package/dist/bench/benchmark-entry.d.ts.map +1 -1
- package/dist/benchmark.js +1 -1
- package/dist/bin/askr-ssg.d.ts +32 -0
- package/dist/bin/askr-ssg.d.ts.map +1 -0
- package/dist/bin/askr-ssg.js +24 -0
- package/dist/boot/index.d.ts.map +1 -1
- package/dist/boot/index.js +2 -2
- package/dist/dev/vite-plugin-askr.d.ts +9 -2
- package/dist/dev/vite-plugin-askr.d.ts.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/node_modules/esbuild/lib/main.js +9 -9
- package/dist/renderer/cleanup.d.ts +3 -0
- package/dist/renderer/cleanup.d.ts.map +1 -1
- package/dist/renderer/cleanup.js +1 -1
- package/dist/renderer/dom.d.ts +2 -0
- package/dist/renderer/dom.d.ts.map +1 -1
- package/dist/renderer/dom.js +1 -1
- package/dist/renderer/index.js +1 -1
- package/dist/renderer/reconcile.js +1 -1
- package/dist/renderer/utils.d.ts.map +1 -1
- package/dist/renderer/utils.js +1 -1
- package/dist/router/route.d.ts +1 -0
- package/dist/router/route.d.ts.map +1 -1
- package/dist/router/route.js +1 -1
- package/dist/runtime/component.d.ts +5 -2
- package/dist/runtime/component.d.ts.map +1 -1
- package/dist/runtime/component.js +1 -1
- package/dist/runtime/derive.d.ts +10 -4
- package/dist/runtime/derive.d.ts.map +1 -1
- package/dist/runtime/derive.js +1 -1
- package/dist/runtime/events.d.ts +1 -0
- package/dist/runtime/events.d.ts.map +1 -1
- package/dist/runtime/events.js +1 -1
- package/dist/runtime/fastlane.d.ts.map +1 -1
- package/dist/runtime/fastlane.js +1 -1
- package/dist/runtime/for.d.ts.map +1 -1
- package/dist/runtime/for.js +1 -1
- package/dist/runtime/operations.d.ts.map +1 -1
- package/dist/runtime/perf-metrics.d.ts +25 -0
- package/dist/runtime/perf-metrics.d.ts.map +1 -0
- package/dist/runtime/perf-metrics.js +1 -0
- package/dist/runtime/readable.d.ts +21 -0
- package/dist/runtime/readable.d.ts.map +1 -0
- package/dist/runtime/readable.js +1 -0
- package/dist/runtime/scheduler.d.ts +17 -2
- package/dist/runtime/scheduler.d.ts.map +1 -1
- package/dist/runtime/scheduler.js +1 -1
- package/dist/runtime/selector.d.ts +9 -0
- package/dist/runtime/selector.d.ts.map +1 -0
- package/dist/runtime/selector.js +1 -0
- package/dist/runtime/state.d.ts +2 -4
- package/dist/runtime/state.d.ts.map +1 -1
- package/dist/runtime/state.js +1 -1
- package/dist/ssg/batch-render.d.ts +16 -0
- package/dist/ssg/batch-render.d.ts.map +1 -0
- package/dist/ssg/batch-render.js +1 -0
- package/dist/ssg/create-static-gen.d.ts +51 -0
- package/dist/ssg/create-static-gen.d.ts.map +1 -0
- package/dist/ssg/create-static-gen.js +1 -0
- package/dist/ssg/discover-resources.d.ts +15 -0
- package/dist/ssg/discover-resources.d.ts.map +1 -0
- package/dist/ssg/generate-metadata.d.ts +27 -0
- package/dist/ssg/generate-metadata.d.ts.map +1 -0
- package/dist/ssg/generate-metadata.js +1 -0
- package/dist/ssg/incremental-manifest.d.ts +23 -0
- package/dist/ssg/incremental-manifest.d.ts.map +1 -0
- package/dist/ssg/incremental-manifest.js +1 -0
- package/dist/ssg/index.d.ts +28 -0
- package/dist/ssg/index.d.ts.map +1 -0
- package/dist/ssg/index.js +1 -0
- package/dist/ssg/resolve-ssg-data.d.ts +26 -0
- package/dist/ssg/resolve-ssg-data.d.ts.map +1 -0
- package/dist/ssg/resolve-ssg-data.js +1 -0
- package/dist/ssg/route-utils.d.ts +12 -0
- package/dist/ssg/route-utils.d.ts.map +1 -0
- package/dist/ssg/route-utils.js +1 -0
- package/dist/ssg/types.d.ts +164 -0
- package/dist/ssg/types.d.ts.map +1 -0
- package/dist/ssg/write-static-files.d.ts +21 -0
- package/dist/ssg/write-static-files.d.ts.map +1 -0
- package/dist/ssg/write-static-files.js +1 -0
- package/dist/ssr/attrs.d.ts +1 -1
- package/dist/ssr/attrs.d.ts.map +1 -1
- package/dist/ssr/attrs.js +1 -1
- package/dist/ssr/context.d.ts +3 -0
- package/dist/ssr/context.d.ts.map +1 -1
- package/dist/ssr/context.js +1 -1
- package/dist/ssr/index.d.ts +27 -0
- package/dist/ssr/index.d.ts.map +1 -1
- package/dist/ssr/index.js +1 -1
- package/dist/vite/index.js +4 -3
- package/package.json +32 -7
|
@@ -8,6 +8,9 @@ export declare function cleanupInstanceIfPresent(node: Node | null, opts?: {
|
|
|
8
8
|
export declare function cleanupInstancesUnder(node: Node | null, opts?: {
|
|
9
9
|
strict?: boolean;
|
|
10
10
|
}): void;
|
|
11
|
+
export declare function teardownNodeSubtree(node: Node | null, opts?: {
|
|
12
|
+
strict?: boolean;
|
|
13
|
+
}): void;
|
|
11
14
|
export interface ListenerMapEntry {
|
|
12
15
|
handler: EventListener;
|
|
13
16
|
original: EventListener;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cleanup.d.ts","sourceRoot":"","sources":["../../src/renderer/cleanup.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cleanup.d.ts","sourceRoot":"","sources":["../../src/renderer/cleanup.ts"],"names":[],"mappings":"AAoGA;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,IAAI,GAAG,IAAI,EACjB,IAAI,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GAC1B,IAAI,CAwCN;AAKD,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,IAAI,GAAG,IAAI,EACjB,IAAI,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GAC1B,IAAI,CAEN;AAED,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,IAAI,GAAG,IAAI,EACjB,IAAI,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GAC1B,IAAI,CAkBN;AAGD,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,aAAa,CAAC;IACvB,QAAQ,EAAE,aAAa,CAAC;IACxB,OAAO,CAAC,EAAE,OAAO,GAAG,uBAAuB,CAAC;IAC5C,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AACD,eAAO,MAAM,gBAAgB,iDAG1B,CAAC;AAGJ,eAAO,MAAM,2BAA2B;aAEf,MAAM,IAAI;WAAS,MAAM,OAAO;GACtD,CAAC;AAEJ,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAYjE;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAgB7D;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,GAAG,IAAI,CAQ7D"}
|
package/dist/renderer/cleanup.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cleanupComponent as
|
|
1
|
+
import{cleanupComponent as w}from"../runtime/component.js";import{logger as c}from"../dev/logger.js";import{removeDelegatedListener as g,clearDelegatedHandlersForElement as u}from"../runtime/events.js";function i(n,t,r){const e=n.__ASKR_INSTANCE;if(e){try{w(e)}catch(a){r?t.push(a):c.warn("[Askr] cleanupComponent failed:",a)}try{delete n.__ASKR_INSTANCE}catch(a){r&&t.push(a)}}}function E(n,t,r){try{m(n)}catch(e){r?t.push(e):c.warn("[Askr] removeElementListeners failed:",e)}try{h(n)}catch(e){r?t.push(e):c.warn("[Askr] removeElementReactiveProps failed:",e)}try{i(n,t,r)}catch(e){r?t.push(e):c.warn("[Askr] cleanupSingleInstance failed:",e)}}function p(n,t){try{const e=n.ownerDocument,a=e?.createTreeWalker;if(typeof a=="function"){const s=a.call(e,n,1);let l=s.firstChild();for(;l;)t(l),l=s.nextNode();return}}catch{}const r=n.querySelectorAll("*");for(let e=0;e<r.length;e++)t(r[e])}function d(n,t){t(n),p(n,t)}function A(n,t){if(!n||!(n instanceof Element))return;const r=t?.strict??!1,e=r?[]:null;try{i(n,e,r)}catch(a){r?e.push(a):c.warn("[Askr] cleanupInstanceIfPresent failed:",a)}try{p(n,a=>{try{i(a,e,r)}catch(s){r?e.push(s):c.warn("[Askr] cleanupInstanceIfPresent descendant cleanup failed:",s)}})}catch(a){r?e.push(a):c.warn("[Askr] cleanupInstanceIfPresent descendant query failed:",a)}if(e&&e.length>0)throw new AggregateError(e,"cleanupInstanceIfPresent failed")}function k(n,t){A(n,t)}function S(n,t){if(!n||!(n instanceof Element))return;const r=t?.strict??!1,e=r?[]:null;try{d(n,a=>{E(a,e,r)})}catch(a){r?e.push(a):c.warn("[Askr] teardownNodeSubtree failed:",a)}if(e&&e.length>0)throw new AggregateError(e,"teardownNodeSubtree failed")}const o=new WeakMap,f=new WeakMap;function h(n){const t=f.get(n);if(t){for(const r of t.values())try{r.cleanup()}catch(e){c.warn("[Askr] reactive prop cleanup failed:",e)}f.delete(n)}}function m(n){const t=o.get(n);if(t){for(const[r,e]of t)e.isDelegated?g(n,r):e.options!==void 0?n.removeEventListener(r,e.handler,e.options):n.removeEventListener(r,e.handler);o.delete(n)}u(n)}function N(n){n&&d(n,t=>{m(t),h(t),u(t)})}export{A as cleanupInstanceIfPresent,k as cleanupInstancesUnder,o as elementListeners,f as elementReactivePropsCleanup,N as removeAllListeners,m as removeElementListeners,h as removeElementReactiveProps,S as teardownNodeSubtree};
|
package/dist/renderer/dom.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type DOMElement, type VNode } from './types';
|
|
2
|
+
import type { ReadableSource } from '../runtime/readable';
|
|
2
3
|
export declare const IS_DOM_AVAILABLE: boolean;
|
|
4
|
+
export declare function markReactivePropsDirtySource(source: ReadableSource<unknown>): void;
|
|
3
5
|
/**
|
|
4
6
|
* Create a DOM node from a VNode
|
|
5
7
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../src/renderer/dom.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../src/renderer/dom.ts"],"names":[],"mappings":"AA8BA,OAAO,EAAiB,KAAK,UAAU,EAAE,KAAK,KAAK,EAAE,MAAM,SAAS,CAAC;AAiBrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAgB1D,eAAO,MAAM,gBAAgB,SAAkC,CAAC;AA4NhE,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,cAAc,CAAC,OAAO,CAAC,GAC9B,IAAI,CAmBN;AAoTD;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,GAAG,IAAI,CAkExD;AA4JD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,UAAU,EAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,gBAAgB,CA6DlB;AAMD;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,EAAE,EAAE,OAAO,EACX,KAAK,EAAE,KAAK,EACZ,cAAc,UAAO,GACpB,IAAI,CAgON;AAED,wBAAgB,qBAAqB,CACnC,EAAE,EAAE,OAAO,EACX,QAAQ,EAAE,KAAK,GAAG,KAAK,EAAE,GAAG,SAAS,GACpC,IAAI,CA+EN;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,OAAO,EACf,WAAW,EAAE,OAAO,EAAE,GACrB,IAAI,CA0KN;AAED;;;;;GAKG;AACH,wBAAgB,oCAAoC,CAClD,MAAM,EAAE,OAAO,EACf,WAAW,EAAE,KAAK,CAAC;IAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC;;;;;EAgE3D;AA4MD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE;;;;;;EA6B3E;AA4GD;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,OAAO,EACf,WAAW,EAAE,KAAK,EAAE,WAyCrB"}
|
package/dist/renderer/dom.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{logger as Oe}from"../dev/logger.js";import"../jsx-runtime.js";import{CONTEXT_FRAME_SYMBOL as re,getCurrentContextFrame as oe,withContext as K}from"../runtime/context.js";import{getCurrentInstance as V,setCurrentComponentInstance as D,createComponentInstance as ie,renderComponentInline as se,mountInstanceInline as U}from"../runtime/component.js";import{elementListeners as h,elementReactivePropsCleanup as A,removeAllListeners as y,cleanupInstanceIfPresent as g}from"./cleanup.js";import{incDevCounter as q,getDevValue as ce,setDevValue as N}from"../runtime/dev-namespace.js";import"./types.js";import{__FOR_BOUNDARY__ as j,_isDOMElement as S}from"../common/vnode.js";import{evaluateForState as z}from"../runtime/for.js";import{keyedElements as v}from"./keyed.js";import{reconcileKeyedChildren as ae}from"./reconcile.js";import{createWrappedHandler as G,getPassiveOptions as X,isSkippedProp as $,parseEventName as Y,now as F,logFastPathDebug as I,recordFastPathStats as fe,hasNonTrivialProps as B,recordDOMReplace as le}from"./utils.js";import{globalScheduler as O}from"../runtime/scheduler.js";import{isEventDelegationEnabled as W,isDelegatedEvent as J,addDelegatedListener as Q,getDelegatedHandlersForElement as ue,removeDelegatedListener as k}from"../runtime/events.js";import{Fragment as de}from"../common/jsx.js";var P={};const pe=typeof document<"u";let H=0;function me(){const e="__COMPONENT_INSTANCE_ID";try{q(e);const t=ce(e);if(typeof t=="number"&&Number.isFinite(t))return`comp-${t}`}catch{}return H++,`comp-${H}`}function ge(e,t,n){const r=W()&&J(t);r&&Q(e,t,n,n,void 0);const o=G(n,!0),a=X(t);r||(a!==void 0?e.addEventListener(t,o,a):e.addEventListener(t,o)),h.has(e)||h.set(e,new Map),h.get(e).set(t,{handler:Z(r,e,t,o),original:n,options:a,isDelegated:r})}function Z(e,t,n,r){if(!e)return r;const o=ue(t);if(o){const a=o.get(n);if(a)return a.handler}return r}const E=new Set;let d=null,x=!1;function ye(){if(!d){d={id:"reactive-props-coordinator",lastRenderToken:0,hasPendingUpdate:!1,notifyUpdate:null,abortController:new AbortController};const e=()=>{if(!x)return;x=!1;const t=V();try{for(const n of E){if(!n.isActive)continue;for(const a of n.readStates)a._readers&&a._readers.delete(d);n.readStates.clear();const r=new Set,o={_pendingReadStates:r,_currentRenderToken:d.lastRenderToken};D(o);try{const a=n.propFn();te(n.el,n.propName,a,n.tagName),n.readStates=r}catch{}}d&&(d.lastRenderToken=(d.lastRenderToken??0)+1);for(const n of E)if(n.isActive)for(const r of n.readStates)r._readers||(r._readers=new Map),r._readers.set(d,d.lastRenderToken??0)}finally{D(t)}};d.notifyUpdate=()=>{x||(x=!0,O.isExecuting()?e():O.enqueue(e))},d._pendingFlushTask=()=>{d.hasPendingUpdate=!1,d.notifyUpdate()}}return d}function ee(e,t,n,r){const o=ye(),a={el:e,propName:t,propFn:n,tagName:r,readStates:new Set,isActive:!0};E.add(a);const s=V(),i=new Set,f={_pendingReadStates:i,_currentRenderToken:o.lastRenderToken};D(f);try{const c=n();te(e,t,c,r),a.readStates=i;for(const l of i)l._readers||(l._readers=new Map),l._readers.set(o,o.lastRenderToken??0)}finally{D(s)}return()=>{if(a.isActive=!1,E.delete(a),d)for(const c of a.readStates)c._readers&&c._readers.delete(d);a.readStates.clear(),E.size===0&&d&&(d.abortController.abort(),d=null)}}function te(e,t,n,r){if(n==null||n===!1){t==="class"||t==="className"?e.className="":e.removeAttribute(t);return}t==="class"||t==="className"?e.className=String(n):t==="value"||t==="checked"?ne(e,t,n,r):e.setAttribute(t,String(n))}function he(e,t,n){for(const r in t){const o=t[r];if(r==="ref"){Se(e,o);continue}if($(r)||o==null||o===!1)continue;const a=Y(r);if(a){ge(e,a,o);continue}if(typeof o=="function"&&!a&&r!=="ref"){const s=ee(e,r,o,n);A.has(e)||A.set(e,new Map),A.get(e).set(r,{cleanup:s,fnRef:o});continue}r==="class"||r==="className"?e.className=String(o):r==="value"||r==="checked"?ne(e,r,o,n):e.setAttribute(r,String(o))}}function Se(e,t){const n=t;if(n){if(typeof n=="function"){n(e);return}Object.isExtensible(n)&&(n.current=e)}}function ne(e,t,n,r){t==="value"?((b(r,"input")||b(r,"textarea")||b(r,"select"))&&(e.value=String(n)),e.setAttribute("value",String(n))):t==="checked"&&(b(r,"input")&&(e.checked=!!n),e.setAttribute("checked",String(!!n)))}function R(e,t,n){const r=t.key??n?.key;r!==void 0&&e.setAttribute("data-key",String(r))}function p(e){if(!pe)return null;if(typeof e=="string")return document.createTextNode(e);if(typeof e=="number")return document.createTextNode(String(e));if(!e)return null;if(Array.isArray(e)){const t=document.createDocumentFragment();for(const n of e){const r=p(n);r&&t.appendChild(r)}return t}if(typeof e=="object"&&e!==null&&"type"in e){const t=e.type,n=e.props||{};if(typeof t=="string")return Ae(e,t,n);if(typeof t=="function")return Ce(e,t,n);if(t===j)return be(e,n);if(typeof t=="symbol"&&(t===de||String(t)==="Symbol(Fragment)"))return Te(e,n)}return null}function Ae(e,t,n){const r=document.createElement(t);R(r,e,n),he(r,n,t);const o=n.children??e.children;if(o!=null)if(Array.isArray(o)){for(const a of o){const s=p(a);s&&r.appendChild(s)}}else{const a=p(o);a&&r.appendChild(a)}return r}function Ce(e,t,n){const o=e[re]||oe(),a=t;if(a.constructor.name==="AsyncFunction")throw new Error("Async components are not supported. Use resource() for async work.");let i=e.__instance;i||(i=ie(me(),a,n||{},null),e.__instance=i),o&&(i.ownerFrame=o);const f=K(o,()=>se(i));if(f instanceof Promise)throw new Error("Async components are not supported. Components must return synchronously.");const c=K(o,()=>p(f));if(c instanceof Element)return U(i,c),R(c,e,n),c;if(!c){const u=document.createComment("");return i._placeholder=u,i.mounted=!0,i.notifyUpdate=i._enqueueRun,u}const l=document.createElement("div");return l.appendChild(c),U(i,l),R(l,e,n),l}function Te(e,t){const n=document.createDocumentFragment(),r=t.children||e.children;if(r)if(Array.isArray(r))for(const o of r){const a=p(o);a&&n.appendChild(a)}else{const o=p(r);o&&n.appendChild(o)}return n}function _e(e,t){if(!S(t)||!(e instanceof Element))return!0;const n=t.type;return typeof n!="string"?!0:e.tagName.toLowerCase()!==n.toLowerCase()}function be(e,t){const n=e._forState;if(!n)return document.createDocumentFragment();const r=t.source,o=z(n,r),a=document.createDocumentFragment();for(let s=0;s<o.length;s++){const i=o[s],f=n.orderedKeys[s],c=f!=null?n.items.get(f):null;let l=null;if(c&&c._dom){const u=c._dom;_e(u,i)||(l=u)}l||(l=p(i),c&&(c._dom=l??void 0)),l&&(l instanceof Element&&C(l,i,!0),a.appendChild(l))}return a}function C(e,t,n=!0){if(!S(t))return;const r=t.props||{};R(e,t,r);const o=h.get(e);let a=null;for(const s in r){const i=r[s];if($(s))continue;const f=Y(s);if(i==null||i===!1){if(s==="class"||s==="className")e.className="";else if(f&&o?.has(f)){const c=o.get(f);c.isDelegated?k(e,f):c.options!==void 0?e.removeEventListener(f,c.handler,c.options):e.removeEventListener(f,c.handler),o.delete(f)}else e.removeAttribute(s);continue}if(typeof i=="function"&&!f&&s!=="ref"){const l=A.get(e)?.get(s);if(l&&l.fnRef===i)continue;l&&l.cleanup();const u=ee(e,s,i,t.type);A.has(e)||A.set(e,new Map),A.get(e).set(s,{cleanup:u,fnRef:i});continue}if(s==="class"||s==="className")e.className=String(i);else if(s==="value"||s==="checked")e[s]=i;else if(f){o&&o.size>0&&(a??=new Set).add(f);const c=W()&&J(f),l=o?.get(f);if(l&&l.original===i)continue;l&&(l.isDelegated?k(e,f):l.options!==void 0?e.removeEventListener(f,l.handler,l.options):e.removeEventListener(f,l.handler)),c&&Q(e,f,i,i,void 0);const u=G(i,!0),m=X(f);c||(m!==void 0?e.addEventListener(f,u,m):e.addEventListener(f,u)),h.has(e)||h.set(e,new Map),h.get(e).set(f,{handler:Z(c,e,f,u),original:i,options:m,isDelegated:c})}else e.setAttribute(s,String(i))}if(o&&o.size>0)if(a===null){for(const[s,i]of o)i.isDelegated?k(e,s):i.options!==void 0?e.removeEventListener(s,i.handler,i.options):e.removeEventListener(s,i.handler);h.delete(e)}else{for(const[s,i]of o)a.has(s)||(i.isDelegated?k(e,s):i.options!==void 0?e.removeEventListener(s,i.handler,i.options):e.removeEventListener(s,i.handler),o.delete(s));o.size===0&&h.delete(e)}if(n){const s=t.children||r.children;Ee(e,s)}}function Ee(e,t){if(t==null){for(let r=e.firstChild;r;){const o=r.nextSibling;r instanceof Element&&(y(r),g(r)),r=o}e.textContent="";return}if(!Array.isArray(t)&&(typeof t=="string"||typeof t=="number")){if(e.childNodes.length===1&&e.firstChild?.nodeType===3)e.firstChild.data=String(t);else{for(let r=e.firstChild;r;){const o=r.nextSibling;r instanceof Element&&(y(r),g(r)),r=o}e.textContent=String(t)}return}if(Array.isArray(t)&&t.length===1&&S(t[0])&&t[0].type===j){const r=t[0],o=r._forState;if(!o)throw new Error("[updateElementChildren] For boundary missing _forState");const a=(r.props||{}).source,s=z(o,a),i=v.get(e),f=ae(e,s,i||new Map);v.set(e,f);return}if(Array.isArray(t)){ve(e,t);return}for(let r=e.firstChild;r;){const o=r.nextSibling;r instanceof Element&&(y(r),g(r)),r=o}e.textContent="";const n=p(t);n&&e.appendChild(n)}function ve(e,t){const n=Array.from(e.children),r=t.some(s=>typeof s=="string"||typeof s=="number"),o=t.some(s=>S(s));if(r&&o){const s=Array.from(e.childNodes),i=Math.max(s.length,t.length);for(let f=0;f<i;f++){const c=s[f],l=t[f];if(l===void 0&&c){c.nodeType===1&&g(c),c.remove();continue}if(!c&&l!==void 0){const u=p(l);u&&e.appendChild(u);continue}if(!(!c||l===void 0)){if(typeof l=="string"||typeof l=="number")if(c.nodeType===3)c.data=String(l);else{const u=document.createTextNode(String(l));e.replaceChild(u,c)}else if(S(l))if(c.nodeType===1){const u=c;if(typeof l.type=="string")if(_(u.tagName,l.type))C(u,l);else{const m=p(l);m&&(y(u),g(u),e.replaceChild(m,c))}}else{const u=p(l);u&&e.replaceChild(u,c)}}}return}if(t.length===1&&n.length===0&&e.childNodes.length===1){const s=t[0],i=e.firstChild;if((typeof s=="string"||typeof s=="number")&&i?.nodeType===3){i.data=String(s);return}}if(n.length===0&&e.childNodes.length>0){for(let s=e.firstChild;s;){const i=s.nextSibling;s instanceof Element&&(y(s),g(s)),s=i}e.textContent=""}const a=Math.max(n.length,t.length);for(let s=0;s<a;s++){const i=n[s],f=t[s];if(f===void 0&&i){g(i),i.remove();continue}if(!i&&f!==void 0){const c=p(f);c&&e.appendChild(c);continue}if(!(!i||f===void 0))if(typeof f=="string"||typeof f=="number"){if(i instanceof Element&&i.childNodes.length>0)for(let c=i.firstChild;c;){const l=c.nextSibling;c instanceof Element&&(y(c),g(c)),c=l}i.textContent=String(f)}else if(S(f))if(typeof f.type=="string")if(_(i.tagName,f.type))C(i,f);else{const c=p(f);c&&(i instanceof Element&&y(i),g(i),e.replaceChild(c,i))}else{const c=p(f);c&&(i instanceof Element&&y(i),g(i),e.replaceChild(c,i))}else{const c=p(f);c&&(i instanceof Element&&y(i),g(i),e.replaceChild(c,i))}}}function tt(e,t){const n=t.length;let r=0,o=0;const a=F(),s=P.ASKR_FASTPATH_DEBUG==="1"||P.ASKR_FASTPATH_DEBUG==="true";for(let c=0;c<n;c++){const{key:l,vnode:u}=t[c],m=e.children[c];if(m&&S(u)&&typeof u.type=="string"){const L=u.type;if(_(m.tagName,L)){const w=u.children||u.props?.children;s&&I("positional idx",c,{chTag:m.tagName,vnodeType:L,chChildNodes:m.childNodes.length,childrenType:Array.isArray(w)?"array":typeof w}),ke(m,w,u),Ne(m,l,()=>o++),r++;continue}else s&&I("positional tag mismatch",c,{chTag:m.tagName,vnodeType:L})}else s&&I("positional missing or invalid",c,{ch:!!m});Fe(e,c,u)}const i=F()-a;Pe(e,t);const f={n,reused:r,updatedKeys:o,t:i};return fe(f,"bulkKeyedPositionalHits"),f}function ke(e,t,n){typeof t=="string"||typeof t=="number"?(T(e,String(t)),n.props&&B(n.props)&&C(e,n,!1)):Array.isArray(t)&&t.length===1&&(typeof t[0]=="string"||typeof t[0]=="number")?(T(e,String(t[0])),n.props&&B(n.props)&&C(e,n,!1)):xe(e,n)||C(e,n)}function xe(e,t){const n=t.children||t.props?.children;if(!Array.isArray(n)||n.length!==2)return!1;const r=n[0],o=n[1];if(!S(r)||!S(o)||typeof r.type!="string"||typeof o.type!="string")return!1;const a=e.children[0],s=e.children[1];if(!a||!s||!_(a.tagName,r.type)||!_(s.tagName,o.type))return!1;const i=r.children||r.props?.children,f=o.children||o.props?.children;if(typeof i=="string"||typeof i=="number")T(a,String(i));else if(Array.isArray(i)&&i.length===1&&(typeof i[0]=="string"||typeof i[0]=="number"))T(a,String(i[0]));else return!1;if(typeof f=="string"||typeof f=="number")T(s,String(f));else if(Array.isArray(f)&&f.length===1&&(typeof f[0]=="string"||typeof f[0]=="number"))T(s,String(f[0]));else return!1;return!0}function T(e,t){e.childNodes.length===1&&e.firstChild?.nodeType===3?e.firstChild.data=t:e.textContent=t}function Ne(e,t,n){try{const r=String(t);if(e.getAttribute("data-key")===r)return;e.setAttribute("data-key",r),n()}catch{}}function De(e){switch(e){case"div":return"DIV";case"span":return"SPAN";case"p":return"P";case"a":return"A";case"button":return"BUTTON";case"input":return"INPUT";case"ul":return"UL";case"ol":return"OL";case"li":return"LI";default:return null}}function b(e,t){if(e===t)return!0;const n=e.length;if(n!==t.length)return!1;for(let r=0;r<n;r++){const o=e.charCodeAt(r),a=t.charCodeAt(r);if(o===a)continue;const s=o>=65&&o<=90?o+32:o,i=a>=65&&a<=90?a+32:a;if(s!==i)return!1}return!0}function _(e,t){const n=De(t);return n!==null&&e===n?!0:b(e,t)}function Fe(e,t,n){const r=p(n);if(r){const o=e.children[t];o?(g(o),e.replaceChild(r,o)):e.appendChild(r)}}function Pe(e,t){try{const n=v.get(e),r=n?(n.clear(),n):new Map;for(let o=0;o<t.length;o++){const a=t[o].key,s=e.children[o];s&&r.set(a,s)}v.set(e,r)}catch{}}function nt(e,t){const n=F(),r=Array.from(e.childNodes),o=[];let a=0,s=0;for(let l=0;l<t.length;l++){const u=Re(t[l],r[l],o);u==="reused"?a++:u==="created"&&s++}const i=F()-n,f=Ie(e,o);v.delete(e);const c={n:t.length,reused:a,created:s,tBuild:i,tCommit:f};return Me(c),c}function Re(e,t,n){return typeof e=="string"||typeof e=="number"?Le(String(e),t,n):typeof e=="object"&&e!==null&&"type"in e?we(e,t,n):"skipped"}function Le(e,t,n){return t&&t.nodeType===3?(t.data=e,n.push(t),"reused"):(n.push(document.createTextNode(e)),"created")}function we(e,t,n){const r=e;if(typeof r.type=="string"){const a=r.type;if(t&&t.nodeType===1&&_(t.tagName,a))return C(t,e),n.push(t),"reused"}const o=p(e);return o?(n.push(o),"created"):"skipped"}function Ie(e,t){const n=Date.now(),r=document.createDocumentFragment();for(let o=0;o<t.length;o++)r.appendChild(t[o]);try{for(let o=e.firstChild;o;){const a=o.nextSibling;o instanceof Element&&y(o),g(o),o=a}}catch{}return le("bulk-text-replace"),e.replaceChildren(r),Date.now()-n}function Me(e){try{N("__LAST_BULK_TEXT_FASTPATH_STATS",e),N("__LAST_FASTPATH_STATS",e),N("__LAST_FASTPATH_COMMIT_COUNT",1),q("bulkTextFastpathHits")}catch{}}function rt(e,t){const n=Number(P.ASKR_BULK_TEXT_THRESHOLD)||1024,r=.8,o=Array.isArray(t)?t.length:0;if(o<n)return M({phase:"bulk-unkeyed-eligible",reason:"too-small",total:o,threshold:n}),!1;const a=Ke(t);if(a.componentFound!==void 0)return M({phase:"bulk-unkeyed-eligible",reason:"component-child",index:a.componentFound}),!1;const s=a.simple/o,i=s>=r&&e.childNodes.length>=o;return M({phase:"bulk-unkeyed-eligible",total:o,simple:a.simple,fraction:s,requiredFraction:r,eligible:i}),i}function Ke(e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];if(typeof r=="string"||typeof r=="number"){t++;continue}if(typeof r=="object"&&r!==null&&"type"in r){const o=r;if(typeof o.type=="function")return{simple:t,componentFound:n};typeof o.type=="string"&&Ue(o)&&t++}}return{simple:t}}function Ue(e){const t=e.children||e.props?.children;return!!(t==null||typeof t=="string"||typeof t=="number"||Array.isArray(t)&&t.length===1&&(typeof t[0]=="string"||typeof t[0]=="number"))}function M(e){if(P.ASKR_FASTPATH_DEBUG==="1")try{N("__BULK_DIAG",e)}catch{}}export{pe as IS_DOM_AVAILABLE,p as createDOMNode,be as createForBoundary,rt as isBulkTextFastPathEligible,tt as performBulkPositionalKeyedTextUpdate,nt as performBulkTextReplace,Ee as updateElementChildren,C as updateElementFromVnode,ve as updateUnkeyedChildren};
|
|
1
|
+
import{logger as et}from"../dev/logger.js";import"../jsx-runtime.js";import{CONTEXT_FRAME_SYMBOL as fe,getCurrentContextFrame as ue,withContext as K}from"../runtime/context.js";import{getCurrentInstance as le,setCurrentComponentInstance as B,createComponentInstance as de,renderComponentInline as pe,mountInstanceInline as O}from"../runtime/component.js";import{removeAllListeners as me,removeElementReactiveProps as ye,elementListeners as y,elementReactivePropsCleanup as g,teardownNodeSubtree as m}from"./cleanup.js";import{incDevCounter as q,getDevValue as ge,setDevValue as P}from"../runtime/dev-namespace.js";import"./types.js";import{__FOR_BOUNDARY__ as W,_isDOMElement as h}from"../common/vnode.js";import{evaluateForState as G}from"../runtime/for.js";import{keyedElements as _}from"./keyed.js";import{reconcileKeyedChildren as he}from"./reconcile.js";import{getPassiveOptions as X,createWrappedHandler as $,isSkippedProp as Y,parseEventName as J,now as x,logFastPathDebug as w,recordFastPathStats as Se,hasNonTrivialProps as V,recordDOMReplace as ve}from"./utils.js";import{globalScheduler as Ae}from"../runtime/scheduler.js";import{incrementPerfMetric as D}from"../runtime/perf-metrics.js";import{isEventDelegationEnabled as Q,isDelegatedEvent as Z,addDelegatedListener as ee,removeDelegatedListener as N}from"../runtime/events.js";import{Fragment as Ce}from"../common/jsx.js";var L={};const Te=typeof document<"u";function te(e){return e.closest('[data-skip-hydrate="true"]')}function ne(e){return te(e)!==null}function be(e){const t=te(e);t&&t===e&&(me(e),ye(e))}let H=0;function ke(){const e="__COMPONENT_INSTANCE_ID";try{q(e);const t=ge(e);if(typeof t=="number"&&Number.isFinite(t))return`comp-${t}`}catch{}return H++,`comp-${H}`}function Ee(e,t,n){const r=Q()&&Z(t);r&&ee(e,t,n,n,void 0);const i=X(t),o=r?n:$(n,!0);r||(i!==void 0?e.addEventListener(t,o,i):e.addEventListener(t,o)),y.has(e)||y.set(e,new Map),y.get(e).set(t,{handler:o,original:n,options:i,isDelegated:r})}const U=new Set,T=new Set,F=new WeakMap;let I=!1,z=0;const k={_pendingReadSources:new Set,_currentRenderToken:0};function _e(e,t){let n=F.get(e);n||(n=new Set,F.set(e,n)),n.add(t)}function re(e,t){F.get(e)?.delete(t)}function ie(e,t){for(const n of e.readSources)t.has(n)||re(n,e);for(const n of t)e.readSources.has(n)||_e(n,e);e.readSources=t}function Ne(e){for(const t of e.readSources)re(t,e);e.readSources.clear()}function oe(e){const t=le(),n=new Set;z+=1,k._pendingReadSources=n,k._currentRenderToken=z,B(k);try{return{value:e.propFn(),readSources:n}}finally{k._pendingReadSources=new Set,k._currentRenderToken=0,B(t)}}function Pe(){if(I=!1,T.size===0)return;const e=Array.from(T);T.clear();for(const t of e)if(t.isActive){D("reactivePropReevaluations");try{const{value:n,readSources:r}=oe(t);if(ie(t,r),Object.is(t.lastValue,n)){D("skippedDomPropWrites");continue}ce(t.el,t.propName,n,t.tagName,t.lastValue,t),t.lastValue=n}catch{}}}function gt(e){const t=F.get(e);if(!t||t.size===0)return;let n=!1;for(const r of t)!r.isActive||T.has(r)||(T.add(r),n=!0);n&&!I&&(I=!0,Ae.enqueueInLane("reactive",Pe))}function se(e,t,n,r){const i={el:e,propName:t,propFn:n,tagName:r,readSources:new Set,isActive:!0,lastValue:void 0,lastClassTokens:null};U.add(i);const{value:o,readSources:a}=oe(i);return ie(i,a),ce(e,t,o,r,void 0,i),i.lastValue=o,()=>{i.isActive=!1,U.delete(i),T.delete(i),Ne(i)}}function ce(e,t,n,r,i,o){if(n==null||n===!1){if(t==="class"||t==="className"){const a=o?.lastClassTokens;a&&a.length>0?(e.classList.remove(...a),D("classListPatchOps")):e.className="",o&&(o.lastClassTokens=[])}else e.removeAttribute(t);return}t==="class"||t==="className"?De(e,n,i,o):t==="value"||t==="checked"?ae(e,t,n,r):e.setAttribute(t,String(n))}function j(e){if(typeof e!="string")return null;const t=e.trim();return t.length===0?[]:t.split(/\s+/)}function xe(e,t,n){const r=new Set(n),i=new Set(t);for(const o of t)r.has(o)||e.classList.remove(o);for(const o of n)i.has(o)||e.classList.add(o);D("classListPatchOps")}function De(e,t,n,r){const i=String(t),o=j(i),a=r?.lastClassTokens??j(n);if(o&&a){xe(e,a,o),r&&(r.lastClassTokens=o);return}e.className=i,r&&(r.lastClassTokens=o)}function Le(e,t,n){if(!ne(e))for(const r in t){const i=t[r];if(r==="ref"){Fe(e,i);continue}if(Y(r)||i==null||i===!1)continue;const o=J(r);if(o){Ee(e,o,i);continue}if(typeof i=="function"&&!o&&r!=="ref"){const a=se(e,r,i,n);g.has(e)||g.set(e,new Map),g.get(e).set(r,{cleanup:a,fnRef:i});continue}r==="class"||r==="className"?e.className=String(i):r==="value"||r==="checked"?ae(e,r,i,n):e.setAttribute(r,String(i))}}function Fe(e,t){const n=t;if(n){if(typeof n=="function"){n(e);return}Object.isExtensible(n)&&(n.current=e)}}function ae(e,t,n,r){t==="value"?((E(r,"input")||E(r,"textarea")||E(r,"select"))&&(e.value=String(n)),e.setAttribute("value",String(n))):t==="checked"&&(E(r,"input")&&(e.checked=!!n),e.setAttribute("checked",String(!!n)))}function R(e,t,n){const r=t.key??n?.key;r!==void 0&&e.setAttribute("data-key",String(r))}function p(e){if(!Te)return null;if(typeof e=="string")return document.createTextNode(e);if(typeof e=="number")return document.createTextNode(String(e));if(!e)return null;if(Array.isArray(e)){const t=document.createDocumentFragment();for(const n of e){const r=p(n);r&&t.appendChild(r)}return t}if(typeof e=="object"&&e!==null&&"type"in e){const t=e.type,n=e.props||{};if(typeof t=="string")return Re(e,t,n);if(typeof t=="function")return we(e,t,n);if(t===W)return Ke(e,n);if(typeof t=="symbol"&&(t===Ce||String(t)==="Symbol(Fragment)"))return Me(e,n)}return null}function Re(e,t,n){const r=document.createElement(t);R(r,e,n),Le(r,n,t);const i=n.children??e.children;if(i!=null)if(Array.isArray(i)){for(const o of i){const a=p(o);a&&r.appendChild(a)}}else{const o=p(i);o&&r.appendChild(o)}return r}function we(e,t,n){const i=e[fe]||ue(),o=t;if(o.constructor.name==="AsyncFunction")throw new Error("Async components are not supported. Use resource() for async work.");let f=e.__instance;f||(f=de(ke(),o,n||{},null),e.__instance=f),i&&(f.ownerFrame=i);const c=K(i,()=>pe(f));if(c instanceof Promise)throw new Error("Async components are not supported. Components must return synchronously.");const s=K(i,()=>p(c));if(s instanceof Element)return O(f,s),R(s,e,n),s;if(!s){const l=document.createComment("");return f._placeholder=l,f.mounted=!0,f.notifyUpdate=f._enqueueRun,l}const u=document.createElement("div");return u.appendChild(s),O(f,u),R(u,e,n),u}function Me(e,t){const n=document.createDocumentFragment(),r=t.children||e.children;if(r)if(Array.isArray(r))for(const i of r){const o=p(i);o&&n.appendChild(o)}else{const i=p(r);i&&n.appendChild(i)}return n}function Ie(e,t){if(!h(t)||!(e instanceof Element))return!0;const n=t.type;return typeof n!="string"?!0:e.tagName.toLowerCase()!==n.toLowerCase()}function Ke(e,t){const n=e._forState;if(!n)return document.createDocumentFragment();const r=t.source,i=G(n,r),o=document.createDocumentFragment();for(let a=0;a<i.length;a++){const f=i[a],c=n.orderedKeys[a],s=c!=null?n.items.get(c):null;let u=null;if(s&&s._dom){const l=s._dom;Ie(l,f)||(u=l)}u||(u=p(f),s&&(s._dom=u??void 0)),u&&(u instanceof Element&&A(u,f,!0),o.appendChild(u))}return o}function A(e,t,n=!0){if(!h(t))return;const r=t.props||{};if(ne(e)){be(e);return}R(e,t,r);const i=y.get(e),o=g.get(e);let a=null,f=null;for(const c in r){const s=r[c];if(Y(c))continue;const u=J(c);if(s==null||s===!1){if(c==="class"||c==="className")e.className="";else if(u&&i?.has(u)){const l=i.get(u);l.isDelegated?N(e,u):l.options!==void 0?e.removeEventListener(u,l.handler,l.options):e.removeEventListener(u,l.handler),i.delete(u)}else o?.has(c)?(o.get(c).cleanup(),o.delete(c)):e.removeAttribute(c);continue}if(typeof s=="function"&&!u&&c!=="ref"){const l=o?.get(c);if(o&&o.size>0&&(f??=new Set).add(c),l&&l.fnRef===s)continue;l&&l.cleanup();const d=se(e,c,s,t.type);g.has(e)||g.set(e,new Map),g.get(e).set(c,{cleanup:d,fnRef:s});continue}if(o?.has(c)&&(o.get(c).cleanup(),o.delete(c)),c==="class"||c==="className")e.className=String(s);else if(c==="value"||c==="checked")e[c]=s;else if(u){i&&i.size>0&&(a??=new Set).add(u);const l=Q()&&Z(u),d=i?.get(u);if(d&&d.original===s)continue;d&&(d.isDelegated?N(e,u):d.options!==void 0?e.removeEventListener(u,d.handler,d.options):e.removeEventListener(u,d.handler)),l&&ee(e,u,s,s,void 0);const S=X(u),v=l?s:$(s,!0);l||(S!==void 0?e.addEventListener(u,v,S):e.addEventListener(u,v)),y.has(e)||y.set(e,new Map),y.get(e).set(u,{handler:v,original:s,options:S,isDelegated:l})}else e.setAttribute(c,String(s))}if(i&&i.size>0)if(a===null){for(const[c,s]of i)s.isDelegated?N(e,c):s.options!==void 0?e.removeEventListener(c,s.handler,s.options):e.removeEventListener(c,s.handler);y.delete(e)}else{for(const[c,s]of i)a.has(c)||(s.isDelegated?N(e,c):s.options!==void 0?e.removeEventListener(c,s.handler,s.options):e.removeEventListener(c,s.handler),i.delete(c));i.size===0&&y.delete(e)}if(o&&o.size>0)if(f===null){for(const[,c]of o)c.cleanup();g.delete(e)}else{for(const[c,s]of o)f.has(c)||(s.cleanup(),o.delete(c));o.size===0&&g.delete(e)}if(n){const c=t.children||r.children;Be(e,c)}}function Be(e,t){if(t==null){for(let r=e.firstChild;r;){const i=r.nextSibling;r instanceof Element&&m(r),r=i}e.textContent="";return}if(!Array.isArray(t)&&(typeof t=="string"||typeof t=="number")){if(e.childNodes.length===1&&e.firstChild?.nodeType===3)e.firstChild.data=String(t);else{for(let r=e.firstChild;r;){const i=r.nextSibling;r instanceof Element&&m(r),r=i}e.textContent=String(t)}return}if(Array.isArray(t)&&t.length===1&&h(t[0])&&t[0].type===W){const r=t[0],i=r._forState;if(!i)throw new Error("[updateElementChildren] For boundary missing _forState");const o=(r.props||{}).source,a=G(i,o),f=_.get(e),c=he(e,a,f||new Map);_.set(e,c);return}if(Array.isArray(t)){Oe(e,t);return}for(let r=e.firstChild;r;){const i=r.nextSibling;r instanceof Element&&m(r),r=i}e.textContent="";const n=p(t);n&&e.appendChild(n)}function Oe(e,t){const n=Array.from(e.children),r=t.some(a=>typeof a=="string"||typeof a=="number"),i=t.some(a=>h(a));if(r&&i){const a=Array.from(e.childNodes),f=Math.max(a.length,t.length);for(let c=0;c<f;c++){const s=a[c],u=t[c];if(u===void 0&&s){m(s),s.remove();continue}if(!s&&u!==void 0){const l=p(u);l&&e.appendChild(l);continue}if(!(!s||u===void 0)){if(typeof u=="string"||typeof u=="number")if(s.nodeType===3)s.data=String(u);else{const l=document.createTextNode(String(u));e.replaceChild(l,s)}else if(h(u))if(s.nodeType===1){const l=s;if(typeof u.type=="string")if(b(l.tagName,u.type))A(l,u);else{const d=p(u);d&&(m(l),e.replaceChild(d,s))}}else{const l=p(u);l&&e.replaceChild(l,s)}}}return}if(t.length===1&&n.length===0&&e.childNodes.length===1){const a=t[0],f=e.firstChild;if((typeof a=="string"||typeof a=="number")&&f?.nodeType===3){f.data=String(a);return}}if(n.length===0&&e.childNodes.length>0){for(let a=e.firstChild;a;){const f=a.nextSibling;a instanceof Element&&m(a),a=f}e.textContent=""}const o=Math.max(n.length,t.length);for(let a=0;a<o;a++){const f=n[a],c=t[a];if(c===void 0&&f){m(f),f.remove();continue}if(!f&&c!==void 0){const s=p(c);s&&e.appendChild(s);continue}if(!(!f||c===void 0))if(typeof c=="string"||typeof c=="number"){if(f instanceof Element&&f.childNodes.length>0)for(let s=f.firstChild;s;){const u=s.nextSibling;s instanceof Element&&m(s),s=u}f.textContent=String(c)}else if(h(c))if(typeof c.type=="string")if(b(f.tagName,c.type))A(f,c);else{const s=p(c);s&&(m(f),e.replaceChild(s,f))}else{const s=p(c);s&&(m(f),e.replaceChild(s,f))}else{const s=p(c);s&&(m(f),e.replaceChild(s,f))}}}function ht(e,t){const n=t.length;let r=0,i=0;const o=x(),a=L.ASKR_FASTPATH_DEBUG==="1"||L.ASKR_FASTPATH_DEBUG==="true";for(let s=0;s<n;s++){const{key:u,vnode:l}=t[s],d=e.children[s];if(d&&h(l)&&typeof l.type=="string"){const S=l.type;if(b(d.tagName,S)){const v=l.children||l.props?.children;a&&w("positional idx",s,{chTag:d.tagName,vnodeType:S,chChildNodes:d.childNodes.length,childrenType:Array.isArray(v)?"array":typeof v}),Ve(d,v,l),Ue(d,u,()=>i++),r++;continue}else a&&w("positional tag mismatch",s,{chTag:d.tagName,vnodeType:S})}else a&&w("positional missing or invalid",s,{ch:!!d});je(e,s,l)}const f=x()-o;qe(e,t);const c={n,reused:r,updatedKeys:i,t:f};return Se(c,"bulkKeyedPositionalHits"),c}function Ve(e,t,n){typeof t=="string"||typeof t=="number"?(C(e,String(t)),n.props&&V(n.props)&&A(e,n,!1)):Array.isArray(t)&&t.length===1&&(typeof t[0]=="string"||typeof t[0]=="number")?(C(e,String(t[0])),n.props&&V(n.props)&&A(e,n,!1)):He(e,n)||A(e,n)}function He(e,t){const n=t.children||t.props?.children;if(!Array.isArray(n)||n.length!==2)return!1;const r=n[0],i=n[1];if(!h(r)||!h(i)||typeof r.type!="string"||typeof i.type!="string")return!1;const o=e.children[0],a=e.children[1];if(!o||!a||!b(o.tagName,r.type)||!b(a.tagName,i.type))return!1;const f=r.children||r.props?.children,c=i.children||i.props?.children;if(typeof f=="string"||typeof f=="number")C(o,String(f));else if(Array.isArray(f)&&f.length===1&&(typeof f[0]=="string"||typeof f[0]=="number"))C(o,String(f[0]));else return!1;if(typeof c=="string"||typeof c=="number")C(a,String(c));else if(Array.isArray(c)&&c.length===1&&(typeof c[0]=="string"||typeof c[0]=="number"))C(a,String(c[0]));else return!1;return!0}function C(e,t){e.childNodes.length===1&&e.firstChild?.nodeType===3?e.firstChild.data=t:e.textContent=t}function Ue(e,t,n){try{const r=String(t);if(e.getAttribute("data-key")===r)return;e.setAttribute("data-key",r),n()}catch{}}function ze(e){switch(e){case"div":return"DIV";case"span":return"SPAN";case"p":return"P";case"a":return"A";case"button":return"BUTTON";case"input":return"INPUT";case"ul":return"UL";case"ol":return"OL";case"li":return"LI";default:return null}}function E(e,t){if(e===t)return!0;const n=e.length;if(n!==t.length)return!1;for(let r=0;r<n;r++){const i=e.charCodeAt(r),o=t.charCodeAt(r);if(i===o)continue;const a=i>=65&&i<=90?i+32:i,f=o>=65&&o<=90?o+32:o;if(a!==f)return!1}return!0}function b(e,t){const n=ze(t);return n!==null&&e===n?!0:E(e,t)}function je(e,t,n){const r=p(n);if(r){const i=e.children[t];i?(m(i),e.replaceChild(r,i)):e.appendChild(r)}}function qe(e,t){try{const n=_.get(e),r=n?(n.clear(),n):new Map;for(let i=0;i<t.length;i++){const o=t[i].key,a=e.children[i];a&&r.set(o,a)}_.set(e,r)}catch{}}function St(e,t){const n=x(),r=Array.from(e.childNodes),i=[];let o=0,a=0;for(let u=0;u<t.length;u++){const l=We(t[u],r[u],i);l==="reused"?o++:l==="created"&&a++}const f=x()-n,c=$e(e,i);_.delete(e);const s={n:t.length,reused:o,created:a,tBuild:f,tCommit:c};return Ye(s),s}function We(e,t,n){return typeof e=="string"||typeof e=="number"?Ge(String(e),t,n):typeof e=="object"&&e!==null&&"type"in e?Xe(e,t,n):"skipped"}function Ge(e,t,n){return t&&t.nodeType===3?(t.data=e,n.push(t),"reused"):(n.push(document.createTextNode(e)),"created")}function Xe(e,t,n){const r=e;if(typeof r.type=="string"){const o=r.type;if(t&&t.nodeType===1&&b(t.tagName,o))return A(t,e),n.push(t),"reused"}const i=p(e);return i?(n.push(i),"created"):"skipped"}function $e(e,t){const n=Date.now(),r=document.createDocumentFragment();for(let i=0;i<t.length;i++)r.appendChild(t[i]);try{for(let i=e.firstChild;i;){const o=i.nextSibling;m(i),i=o}}catch{}return ve("bulk-text-replace"),e.replaceChildren(r),Date.now()-n}function Ye(e){try{P("__LAST_BULK_TEXT_FASTPATH_STATS",e),P("__LAST_FASTPATH_STATS",e),P("__LAST_FASTPATH_COMMIT_COUNT",1),q("bulkTextFastpathHits")}catch{}}function vt(e,t){const n=Number(L.ASKR_BULK_TEXT_THRESHOLD)||1024,r=.8,i=Array.isArray(t)?t.length:0;if(i<n)return M({phase:"bulk-unkeyed-eligible",reason:"too-small",total:i,threshold:n}),!1;const o=Je(t);if(o.componentFound!==void 0)return M({phase:"bulk-unkeyed-eligible",reason:"component-child",index:o.componentFound}),!1;const a=o.simple/i,f=a>=r&&e.childNodes.length>=i;return M({phase:"bulk-unkeyed-eligible",total:i,simple:o.simple,fraction:a,requiredFraction:r,eligible:f}),f}function Je(e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];if(typeof r=="string"||typeof r=="number"){t++;continue}if(typeof r=="object"&&r!==null&&"type"in r){const i=r;if(typeof i.type=="function")return{simple:t,componentFound:n};typeof i.type=="string"&&Qe(i)&&t++}}return{simple:t}}function Qe(e){const t=e.children||e.props?.children;return!!(t==null||typeof t=="string"||typeof t=="number"||Array.isArray(t)&&t.length===1&&(typeof t[0]=="string"||typeof t[0]=="number"))}function M(e){if(L.ASKR_FASTPATH_DEBUG==="1")try{P("__BULK_DIAG",e)}catch{}}export{Te as IS_DOM_AVAILABLE,p as createDOMNode,Ke as createForBoundary,vt as isBulkTextFastPathEligible,gt as markReactivePropsDirtySource,ht as performBulkPositionalKeyedTextUpdate,St as performBulkTextReplace,Be as updateElementChildren,A as updateElementFromVnode,Oe as updateUnkeyedChildren};
|
package/dist/renderer/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./types.js";import{cleanupInstanceIfPresent as
|
|
1
|
+
import"./types.js";import{cleanupInstanceIfPresent as d,cleanupInstancesUnder as c,elementListeners as u,elementReactivePropsCleanup as f,removeAllListeners as E,removeElementListeners as R,removeElementReactiveProps as y,teardownNodeSubtree as v}from"./cleanup.js";import{getKeyMapForElement as r,isKeyedReorderFastPathEligible as t}from"./keyed.js";import{_reconcilerRecordedParents as x,keyedElements as g,populateKeyMapForElement as k}from"./keyed.js";import{markReactivePropsDirtySource as o}from"./dom.js";import{IS_DOM_AVAILABLE as h,createDOMNode as D,createForBoundary as F,isBulkTextFastPathEligible as b,performBulkPositionalKeyedTextUpdate as A,performBulkTextReplace as B,updateElementChildren as I,updateElementFromVnode as K,updateUnkeyedChildren as L}from"./dom.js";import{evaluate as a}from"./evaluate.js";import{clearDOMRange as S}from"./evaluate.js";if(typeof globalThis<"u"){const e=globalThis;e.__ASKR_RENDERER={evaluate:a,isKeyedReorderFastPathEligible:t,getKeyMapForElement:r,markReactivePropsDirtySource:o}}export{h as IS_DOM_AVAILABLE,x as _reconcilerRecordedParents,d as cleanupInstanceIfPresent,c as cleanupInstancesUnder,S as clearDOMRange,D as createDOMNode,F as createForBoundary,u as elementListeners,f as elementReactivePropsCleanup,a as evaluate,r as getKeyMapForElement,b as isBulkTextFastPathEligible,t as isKeyedReorderFastPathEligible,g as keyedElements,o as markReactivePropsDirtySource,A as performBulkPositionalKeyedTextUpdate,B as performBulkTextReplace,k as populateKeyMapForElement,E as removeAllListeners,R as removeElementListeners,y as removeElementReactiveProps,v as teardownNodeSubtree,I as updateElementChildren,K as updateElementFromVnode,L as updateUnkeyedChildren};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{performBulkPositionalKeyedTextUpdate as d,updateElementFromVnode as a,createDOMNode as y}from"./dom.js";import{isKeyedReorderFastPathEligible as p,keyedElements as s}from"./keyed.js";import{
|
|
1
|
+
import{performBulkPositionalKeyedTextUpdate as d,updateElementFromVnode as a,createDOMNode as y}from"./dom.js";import{isKeyedReorderFastPathEligible as p,keyedElements as s}from"./keyed.js";import{teardownNodeSubtree as b}from"./cleanup.js";import{isBulkCommitActive as N}from"../runtime/fastlane.js";import{applyRendererFastPath as C}from"./fastpath.js";import{extractKey as h,recordFastPathStats as k,checkPropChanges as S,recordDOMReplace as A}from"./utils.js";const Q=typeof document<"u";function l(e,n){if(e===n)return!0;if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++){const r=e.charCodeAt(t),o=n.charCodeAt(t);if(r===o)continue;const i=r>=65&&r<=90?r+32:r,c=o>=65&&o<=90?o+32:o;if(i!==c)return!1}return!0}function X(e,n,t){const{keyedVnodes:r,unkeyedVnodes:o}=R(n),i=t||P(e),c=F(e,n,r,o,i);return c||j(e,n,r,i)}function P(e){const n=new Map;try{for(let t=e.firstElementChild;t;t=t.nextElementSibling){const r=t.getAttribute("data-key");if(r!==null){n.set(r,t);const o=Number(r);Number.isNaN(o)||n.set(o,t)}}}catch{}return n}function R(e){const n=[],t=[];for(let r=0;r<e.length;r++){const o=e[r],i=h(o);i!==void 0?n.push({key:i,vnode:o}):t.push(o)}return{keyedVnodes:n,unkeyedVnodes:t}}function F(e,n,t,r,o){try{const i=x(e,n,t,r,o);if(i)return i;const c=E(e,t);if(c)return c}catch{}return null}function x(e,n,t,r,o){if(p(e,n,o).useFastPath&&t.length>=64||N())try{const c=C(e,t,o,r);if(c)return s.set(e,c),c}catch{}return null}function E(e,n){const t=n.length;if(t<10||e.children.length!==t)return null;const r=K(e,n),o=r/t;if(n.length>0){if(r!==t&&o>=.1)return null}else if(o<.9)return null;if(v(e,n))return null;try{const i=d(e,n);return k(i,"bulkKeyedPositionalHits"),M(e),s.get(e)}catch{return null}}function K(e,n){let t=0;try{for(let r=0;r<n.length;r++){const o=n[r].vnode,i=n[r].key;if(!o||typeof o!="object"||typeof o.type!="string")continue;const c=e.children[r];if(c&&l(c.tagName,o.type)){const u=c.getAttribute("data-key");(u===String(i)||u!==null&&!Number.isNaN(Number(u))&&Number(u)===i)&&t++}}}catch{}return t}function v(e,n){try{for(let t=0;t<n.length;t++){const r=n[t].vnode,o=e.children[t];if(!(!o||!r||typeof r!="object")&&S(o,r.props||{}))return!0}}catch{return!0}return!1}function M(e){try{const n=new Map;for(let t=e.firstElementChild;t;t=t.nextElementSibling){const r=t.getAttribute("data-key");if(r!==null){n.set(r,t);const o=Number(r);Number.isNaN(o)||n.set(o,t)}}s.set(e,n)}catch{}}function j(e,n,t,r){const o=new Map,i=[],c=new WeakSet,u=B(e,r,c);for(let f=0;f<n.length;f++){const g=n[f],m=U(g,f,e,u,c,o);m&&i.push(m)}return typeof document>"u"||(w(e,i),s.delete(e)),o}function B(e,n,t){return r=>{if(!n)return;const o=n.get(r);if(o&&!t.has(o))return t.add(o),o;const i=String(r),c=n.get(i);if(c&&!t.has(c))return t.add(c),c;const u=Number(i);if(!Number.isNaN(u)){const f=n.get(u);if(f&&!t.has(f))return t.add(f),f}return D(e,r,i,t)}}function D(e,n,t,r){try{for(let o=e.firstElementChild;o;o=o.nextElementSibling){if(r.has(o))continue;const i=o.getAttribute("data-key");if(i===t)return r.add(o),o;if(i!==null){const c=Number(i);if(!Number.isNaN(c)&&c===n)return r.add(o),o}}}catch{}}function U(e,n,t,r,o,i){const c=h(e);return c!==void 0?I(e,c,t,r,i):L(e,n,t,o)}function I(e,n,t,r,o){const i=r(n);if(i&&i.parentElement===t)try{const u=e;if(u&&typeof u=="object"&&typeof u.type=="string"&&l(i.tagName,u.type))return a(i,e),o.set(n,i),i}catch{}const c=y(e);return c?(c instanceof Element&&o.set(n,c),c):null}function L(e,n,t,r){try{const i=t.childNodes[n];if((typeof e=="string"||typeof e=="number")&&i&&i.nodeType===3)return i.data=String(e),r.add(i),i;if(i instanceof Element&&T(i,e))return a(i,e),r.add(i),i;const c=_(t,r);if(c){const u=q(c,e,r);if(u)return u}}catch{}return y(e)}function T(e,n){if(!e||typeof n!="object"||n===null||!("type"in n))return!1;const t=n,r=e.getAttribute("data-key");return r==null&&typeof t.type=="string"&&l(e.tagName,t.type)}function _(e,n){for(let t=e.firstElementChild;t;t=t.nextElementSibling)if(!n.has(t)&&t.getAttribute("data-key")===null)return t}function q(e,n,t){if(typeof n=="string"||typeof n=="number")return e.textContent=String(n),t.add(e),e;if(typeof n=="object"&&n!==null&&"type"in n){const r=n;if(typeof r.type=="string"&&l(e.tagName,r.type))return a(e,n),t.add(e),e}return null}function w(e,n){const t=document.createDocumentFragment();for(let r=0;r<n.length;r++)t.appendChild(n[r]);try{for(let r=e.firstChild;r;){const o=r.nextSibling;b(r),r=o}}catch{}A("reconcile"),e.replaceChildren(t)}export{Q as IS_DOM_AVAILABLE,X as reconcileKeyedChildren};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/renderer/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,aAAa,CAAC;IACvB,QAAQ,EAAE,aAAa,CAAC;IACxB,OAAO,CAAC,EAAE,OAAO,GAAG,uBAAuB,CAAC;CAC7C;AAYD;;GAEG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAK9D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,GAChB,uBAAuB,GAAG,SAAS,CASrC;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,aAAa,EACtB,UAAU,UAAQ,GACjB,aAAa,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/renderer/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,aAAa,CAAC;IACvB,QAAQ,EAAE,aAAa,CAAC;IACxB,OAAO,C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W,CAAC,EAAE,MAAM,GACnB,IAAI,CAUN;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,EAC9B,IAAI,CAAC,EAAE,OAAO,GACb,IAAI,CAaN;AAMD;;GAEG;AACH,wBAAgB,GAAG,IAAI,MAAM,CAI5B"}
|
package/dist/renderer/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{globalScheduler as
|
|
1
|
+
import{globalScheduler as A}from"../runtime/scheduler.js";import{logger as i}from"../dev/logger.js";import{incDevCounter as l,setDevValue as u}from"../runtime/dev-namespace.js";var a={};const s=new WeakMap;let f=0;const _=1e3;function g(r){return!r.startsWith("on")||r.length<=2?null:r.slice(2).charAt(0).toLowerCase()+r.slice(3).toLowerCase()}function w(r){if(r==="wheel"||r==="scroll"||r.startsWith("touch"))return{passive:!0}}function C(r,t=!1){const e=s.get(r);if(e){const o=e.get(t);if(o)return o}const n=o=>{try{A.runInHandlerScope(()=>{try{r(o)}catch(c){i.error("[Askr] Event handler error:",c)}},t?"sync":"defer")}catch(c){t?queueMicrotask(()=>{throw c}):i.error("[Askr] Event handler error:",c)}};try{s.has(r)||f>=_||(f++,s.set(r,new Map)),s.get(r)?.set(t,n)}catch{}return n}function P(r){return r==="children"||r==="key"||r==="ref"}function h(r){return!!(r==="children"||r==="key"||r.startsWith("on")&&r.length>2||r.startsWith("data-"))}function d(r,t,e){try{if(t==="class"||t==="className")return r.className!==String(e);if(t==="value"||t==="checked")return r[t]!==e;const n=r.getAttribute(t);return e==null||e===!1?n!==null:String(e)!==n}catch{return!0}}function E(r){for(const t of Object.keys(r))if(!h(t))return!0;return!1}function b(r,t){for(const e of Object.keys(t))if(!h(e)&&d(r,e,t[e]))return!0;return!1}function F(r){if(typeof r!="object"||r===null)return;const t=r,e=t.key??t.props?.key;if(e!==void 0)return typeof e=="symbol"?String(e):e}function m(r){const t=new Map;for(let e=r.firstElementChild;e;e=e.nextElementSibling){const n=e.getAttribute("data-key");if(n!==null){t.set(n,e);const o=Number(n);Number.isNaN(o)||t.set(o,e)}}return t}function y(r){try{l("__DOM_REPLACE_COUNT"),u(`__LAST_DOM_REPLACE_STACK_${r}`,new Error().stack)}catch{}}function M(r,t){try{u("__LAST_FASTPATH_STATS",r),u("__LAST_FASTPATH_COMMIT_COUNT",1),t&&l(t)}catch{}}function k(r,t,e){(a.ASKR_FASTPATH_DEBUG==="1"||a.ASKR_FASTPATH_DEBUG==="true")&&(e!==void 0?i.warn(`[Askr][FASTPATH] ${r}`,t,e):t!==void 0?i.warn(`[Askr][FASTPATH] ${r}`,t):i.warn(`[Askr][FASTPATH] ${r}`))}function H(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}export{m as buildKeyMapFromChildren,b as checkPropChanges,C as createWrappedHandler,F as extractKey,w as getPassiveOptions,E as hasNonTrivialProps,d as hasPropChanged,h as isIgnoredForPropChanges,P as isSkippedProp,k as logFastPathDebug,H as now,g as parseEventName,y as recordDOMReplace,M as recordFastPathStats};
|
package/dist/router/route.d.ts
CHANGED
|
@@ -49,4 +49,5 @@ export declare function getLoadedNamespaces(): string[];
|
|
|
49
49
|
* Routes are matched by specificity: literals > parameters > wildcards > catch-all
|
|
50
50
|
*/
|
|
51
51
|
export declare function resolveRoute(pathname: string): ResolvedRoute | null;
|
|
52
|
+
export declare function resolveRouteFromRoutes(pathname: string, routeList: readonly Route[]): ResolvedRoute | null;
|
|
52
53
|
//# sourceMappingURL=route.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../src/router/route.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../src/router/route.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,YAAY,EACV,YAAY,EACZ,KAAK,EACL,aAAa,EACb,UAAU,EACV,UAAU,EACV,a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,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAEnE;AAED,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,SAAS,KAAK,EAAE,GAC1B,aAAa,GAAG,IAAI,CAyDtB"}
|
package/dist/router/route.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{match as
|
|
1
|
+
import{match as R}from"./match.js";import{getCurrentComponentInstance as b}from"../runtime/component.js";import{getExecutionModel as N}from"../runtime/execution-model.js";import{getRenderContext as k}from"../ssr/context.js";const a=[],m=new Set,P=Symbol.for("__ASKR_HAS_ROUTES__");function y(e){try{const o=globalThis;o[P]=e}catch{}}y(!1);const h=new Map;function x(e){const o=e.endsWith("/")&&e!=="/"?e.slice(0,-1):e;return o==="/"?0:o.split("/").filter(Boolean).length}function v(e){const o=e.endsWith("/")&&e!=="/"?e.slice(0,-1):e;if(o==="/*")return 0;const r=o.split("/").filter(Boolean);let i=0;for(const t of r)t.startsWith("{")&&t.endsWith("}")?i+=2:t==="*"?i+=1:i+=3;return i}let w=null;function q(e){w=e}function z(e){try{const o=new URL(e,"http://localhost");return{pathname:o.pathname,search:o.search,hash:o.hash}}catch{return{pathname:"/",search:"",hash:""}}}function g(e){if(e&&typeof e=="object"&&!Object.isFrozen(e)){Object.freeze(e);for(const o of Object.keys(e)){const r=e[o];r&&typeof r=="object"&&g(r)}}return e}function C(e){const o=new URLSearchParams(e||""),r=new Map;for(const[t,s]of o.entries()){const n=r.get(t);n?n.push(s):r.set(t,[s])}return g({get(t){const s=r.get(t);return s?s[0]:null},getAll(t){const s=r.get(t);return s?[...s]:[]},has(t){return r.has(t)},toJSON(){const t={};for(const[s,n]of r.entries())t[s]=n.length>1?[...n]:n[0];return t}})}function B(e,o){const r=[];function i(t){const s=t.endsWith("/")&&t!=="/"?t.slice(0,-1):t;if(s==="/*")return 0;const n=s.split("/").filter(Boolean);let c=0;for(const u of n)u.startsWith("{")&&u.endsWith("}")?c+=2:u==="*"?c+=1:c+=3;return c}for(const t of o){const s=R(e,t.path);s.matched&&r.push({pattern:t.path,params:s.params,name:t.name,namespace:t.namespace,specificity:i(t.path)})}return r.sort((t,s)=>s.specificity-t.specificity),r.map(t=>({path:t.pattern,params:g({...t.params}),name:t.name,namespace:t.namespace}))}function F(){return k()?.routes??a}let p=!1;function D(){p=!0}function V(){p=!0}function X(){p=!1}function E(e,o,r){if(N()==="islands")throw new Error("Routes are not supported with islands. Use createSPA (client) or createSSR (server) instead.");if(typeof e>"u"){const c=b();if(!c)throw new Error("route() can only be called during component render execution. Call route() from inside your component function.");let u="/",l="",d="";const S=k();if(c.ssr&&S?.url){const f=z(S.url);u=f.pathname,l=f.search,d=f.hash}else if(typeof window<"u"&&window.location)u=window.location.pathname||"/",l=window.location.search||"",d=window.location.hash||"";else if(w){const f=z(w);u=f.pathname,l=f.search,d=f.hash}const O=g({...c.props||{}}),W=C(l),A=B(u,F());return Object.freeze({path:u,params:O,query:W,hash:d||null,matches:Object.freeze(A)})}const i=b();if(i&&i.ssr)throw new Error("route() cannot be called during SSR rendering. Register routes at module load time instead.");if(p)throw new Error("Route registration is locked after app startup. Register routes at module load time before calling createSPA or createSSR.");if(typeof o!="function")throw new Error("route(path, handler) requires a function handler that returns a VNode (e.g. () => <Page />). Passing JSX elements or VNodes directly is not supported.");const t={path:e,handler:o,namespace:r};a.push(t),y(!0);const s=x(e);let n=h.get(s);n||(n=[],h.set(s,n)),n.push(t),r&&m.add(r)}function $(){return[...a]}function I(e){return a.filter(o=>o.namespace===e)}function K(e){const o=a.length;for(let r=a.length-1;r>=0;r--)if(a[r].namespace===e){const i=a[r];a.splice(r,1);const t=x(i.path),s=h.get(t);if(s){const n=s.indexOf(i);n>=0&&s.splice(n,1)}}return m.delete(e),o-a.length}function Q(){a.length=0,m.clear(),h.clear(),p=!1,y(!1)}function _(e){if(e!=null&&typeof e=="function")return(o,r)=>{try{return e(o,r)}catch{return e(o)}}}function L(e,o,...r){const i=!e.startsWith("/"),t={path:e,handler:o,children:r.filter(Boolean),_isDescriptor:!0};if(!i){const s=_(o);if(o!=null&&!s)throw new Error("registerRoute(path, handler) requires a function handler. Passing JSX elements or VNodes directly is not supported.");s&&E(e,s);for(const n of t.children||[]){const u=`${e==="/"?"":e.replace(/\/$/,"")}/${n.path.replace(/^\//,"")}`.replace(/\/\//g,"/");if(n.handler){const l=_(n.handler);if(!l)throw new Error("registerRoute child handler must be a function. Passing JSX elements directly is not supported.");l&&E(u,l)}n.children&&n.children.length&&L(u,null,...n.children)}return t}return t}function Y(){return Array.from(m)}function G(e){return T(e,a)}function T(e,o){const r=e.endsWith("/")&&e!=="/"?e.slice(0,-1):e,i=r==="/"?0:r.split("/").filter(Boolean).length,t=[],s=o===a?h.get(i):void 0;if(s)for(const n of s){const c=R(r,n.path);c.matched&&t.push({route:n,specificity:v(n.path),params:c.params})}for(const n of o){if(s?.includes(n))continue;const c=R(r,n.path);c.matched&&t.push({route:n,specificity:v(n.path),params:c.params})}if(t.sort((n,c)=>c.specificity-n.specificity),t.length>0){const n=t[0];return{handler:n.route.handler,params:n.params}}return null}export{V as _lockRouteRegistrationForTests,X as _unlockRouteRegistrationForTests,Q as clearRoutes,Y as getLoadedNamespaces,I as getNamespaceRoutes,$ as getRoutes,D as lockRouteRegistration,L as registerRoute,G as resolveRoute,T as resolveRouteFromRoutes,E as route,q as setServerLocation,K as unloadNamespace};
|
|
@@ -6,6 +6,7 @@ import { type State } from './state';
|
|
|
6
6
|
import type { Props } from '../common/props';
|
|
7
7
|
import type { ComponentFunction } from '../common/component';
|
|
8
8
|
import { type ContextFrame } from './context';
|
|
9
|
+
import { type ReadableSource } from './readable';
|
|
9
10
|
export type { ComponentFunction } from '../common/component';
|
|
10
11
|
export interface ComponentInstance {
|
|
11
12
|
id: string;
|
|
@@ -32,8 +33,9 @@ export interface ComponentInstance {
|
|
|
32
33
|
isRoot?: boolean;
|
|
33
34
|
_currentRenderToken?: number;
|
|
34
35
|
lastRenderToken?: number;
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
_pendingReadSources?: Set<ReadableSource<unknown>>;
|
|
37
|
+
_lastReadSources?: Set<ReadableSource<unknown>>;
|
|
38
|
+
devWarningsEmitted: Set<string>;
|
|
37
39
|
_placeholder?: Comment;
|
|
38
40
|
}
|
|
39
41
|
export declare function createComponentInstance(id: string, fn: ComponentFunction, props: Props, target: Element | null): ComponentInstance;
|
|
@@ -106,6 +108,7 @@ export declare function getSignal(): AbortSignal;
|
|
|
106
108
|
*/
|
|
107
109
|
export declare function finalizeReadSubscriptions(instance: ComponentInstance): void;
|
|
108
110
|
export declare function getNextStateIndex(): number;
|
|
111
|
+
export declare function claimHookIndex(instance: ComponentInstance, hookName: string): number;
|
|
109
112
|
export declare function getCurrentStateIndex(): number;
|
|
110
113
|
export declare function resetStateIndex(): void;
|
|
111
114
|
export declare function setStateIndex(value: number): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/runtime/component.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/runtime/component.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,KAAK,cAAc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EAAE,iBAAiB,EAC3B,QAAQ,EAAE,MAAM,GACf,MAAM,CA6BR;AAED,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C;AAED,wBAAgB,eAAe,IAAI,IAAI,CAEtC;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAEjD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAEhE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAwClE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{globalScheduler as
|
|
1
|
+
import{globalScheduler as p}from"./scheduler.js";import{withContext as T}from"./context.js";import{finalizeReadableSubscriptions as v,cleanupReadableSubscriptions as k}from"./readable.js";import{logger as f}from"../dev/logger.js";import{incDevCounter as m,setDevValue as h}from"./dev-namespace.js";import{isBulkCommitActive as x}from"./fastlane.js";import"../renderer/index.js";import{evaluate as g}from"../renderer/evaluate.js";import{cleanupInstancesUnder as _}from"../renderer/cleanup.js";function D(e,t,r,u){const n={id:e,fn:t,props:r,target:u,mounted:!1,abortController:new AbortController,stateValues:[],evaluationGeneration:0,notifyUpdate:null,_pendingFlushTask:void 0,_pendingRunTask:void 0,_enqueueRun:void 0,stateIndexCheck:-1,expectedStateIndices:[],firstRenderComplete:!1,mountOperations:[],cleanupFns:[],hasPendingUpdate:!1,ownerFrame:null,ssr:!1,cleanupStrict:!1,isRoot:!1,_currentRenderToken:void 0,lastRenderToken:0,_pendingReadSources:new Set,_lastReadSources:new Set,devWarningsEmitted:new Set};return n._pendingRunTask=()=>{n.hasPendingUpdate=!1,I(n)},n._enqueueRun=()=>{n.hasPendingUpdate||(n.hasPendingUpdate=!0,p.enqueue(n._pendingRunTask))},n._pendingFlushTask=n._pendingRunTask,n}let l=null,s=0;function E(){return l}function K(e){l=e}function B(e){const t=E();if(t){if(x())return;t.mountOperations.push(e)}}function C(e){if(e.isRoot){for(const t of e.mountOperations){const r=t();r instanceof Promise?r.then(u=>{typeof u=="function"&&e.cleanupFns.push(u)}):typeof r=="function"&&e.cleanupFns.push(r)}e.mountOperations=[]}}function H(e,t){e.target=t;try{t instanceof Element&&(t.__ASKR_INSTANCE=e)}catch(u){}e.notifyUpdate=e._enqueueRun;const r=!e.mounted;e.mounted=!0,r&&e.mountOperations.length>0&&C(e)}let S=0;function I(e){e.notifyUpdate=e._enqueueRun,e._currentRenderToken=++S,e._pendingReadSources=new Set;const t=e.target?e.target.innerHTML:"",r=R(e);if(r instanceof Promise)throw new Error("Async components are not supported. Components must be synchronous.");{const u=globalThis.__ASKR_FASTLANE;try{if(u?.tryRuntimeFastLaneSync?.(e,r))return}catch{}p.enqueue(()=>{if(!e.target&&e._placeholder){if(r==null){c(e);return}const n=e._placeholder,d=n.parentNode;if(!d){f.warn("[Askr] placeholder no longer in DOM, cannot render component");return}const o=document.createElement("div"),i=l;l=e;try{g(r,o),d.replaceChild(o,n),e.target=o,e._placeholder=void 0,o.__ASKR_INSTANCE=e,c(e)}finally{l=i}return}if(e.target){let n=[];try{const d=!e.mounted,o=l;l=e,n=Array.from(e.target.childNodes);try{g(r,e.target)}catch(i){try{const a=Array.from(e.target.childNodes);for(const w of a)try{_(w)}catch(y){f.warn("[Askr] error cleaning up failed commit children:",y)}}catch(a){}try{m("__DOM_REPLACE_COUNT"),h("__LAST_DOM_REPLACE_STACK_COMPONENT_RESTORE",new Error().stack)}catch(a){}throw e.target.replaceChildren(...n),i}finally{l=o}c(e),e.mounted=!0,d&&e.mountOperations.length>0&&C(e)}catch(d){try{const o=Array.from(e.target.childNodes);for(const i of o)try{_(i)}catch(a){f.warn("[Askr] error cleaning up partial children during rollback:",a)}}catch(o){}try{try{m("__DOM_REPLACE_COUNT"),h("__LAST_DOM_REPLACE_STACK_COMPONENT_ROLLBACK",new Error().stack)}catch(o){}e.target.replaceChildren(...n)}catch{e.target.innerHTML=t}throw d}}})}}function V(e){const t=e._currentRenderToken!==void 0,r=e._currentRenderToken,u=e._pendingReadSources;t||(e._currentRenderToken=++S,e._pendingReadSources=new Set);try{const n=R(e);return t||c(e),n}finally{e._currentRenderToken=r,e._pendingReadSources=u??new Set}}function R(e){e.stateIndexCheck=-1;for(const t of e.stateValues)t&&(t._hasBeenRead=!1);e._pendingReadSources=new Set,l=e,s=0;try{const r={signal:e.abortController.signal},u={parent:e.ownerFrame,values:null},n=T(u,()=>e.fn(e.props,r)),d=Date.now()-0;d>5&&(`${d}`,void 0),e.firstRenderComplete||(e.firstRenderComplete=!0);for(let o=0;o<e.stateValues.length;o++){const i=e.stateValues[o];if(i&&!i._hasBeenRead)try{const a=e.fn?.name||"<anonymous>";`${o}`,`${a}${o}`}catch{`${o}`}}return n}finally{l=null}}function A(e){e.abortController=new AbortController,e.notifyUpdate=e._enqueueRun,p.enqueue(e._pendingRunTask)}function z(){return l}function W(){if(!l)throw new Error("getSignal() can only be called during component render execution. Ensure you are calling this from inside your component function.");return l.abortController.signal}function c(e){v(e)}function b(){return s++}function j(e,t){const r=b();if(r<e.stateIndexCheck)throw new Error(`Hook index violation: ${t}() call at index ${r}, but previously saw index ${e.stateIndexCheck}. This happens when render-scoped hooks are called conditionally (inside if/for/etc). Move all ${t}() calls to the top level of your component function, before any conditionals.`);if(e.stateIndexCheck=r,e.firstRenderComplete){if(!e.expectedStateIndices.includes(r))throw new Error(`Hook order violation: ${t}() called at index ${r}, but this index was not in the first render's sequence [${e.expectedStateIndices.join(", ")}]. This usually means ${t}() is inside a conditional or loop. Move all render-scoped hooks to the top level of your component function.`)}else e.expectedStateIndices.push(r);return r}function G(){return s}function J(){s=0}function Q(e){s=e}function X(e){A(e)}function Y(e){const t=[];for(const r of e.cleanupFns)try{r()}catch(u){e.cleanupStrict&&t.push(u)}if(e.cleanupFns=[],t.length>0)throw new AggregateError(t,`Cleanup failed for component ${e.id}`);k(e),e.abortController.abort(),e.notifyUpdate=null,e.mounted=!1}export{j as claimHookIndex,Y as cleanupComponent,D as createComponentInstance,A as executeComponent,c as finalizeReadSubscriptions,E as getCurrentComponentInstance,z as getCurrentInstance,G as getCurrentStateIndex,b as getNextStateIndex,W as getSignal,X as mountComponent,H as mountInstanceInline,B as registerMountOperation,V as renderComponentInline,J as resetStateIndex,K as setCurrentComponentInstance,Q as setStateIndex};
|
package/dist/runtime/derive.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
1
|
+
import { type ReadableSource } from './readable';
|
|
2
|
+
export interface Derived<T> extends ReadableSource<T> {
|
|
3
|
+
(): T;
|
|
4
|
+
}
|
|
5
|
+
type SnapshotSource<T> = {
|
|
6
|
+
value: T | null;
|
|
4
7
|
pending?: boolean;
|
|
5
8
|
error?: Error | null;
|
|
6
|
-
}
|
|
9
|
+
};
|
|
10
|
+
export declare function derive<TOut>(fn: () => TOut): Derived<TOut>;
|
|
11
|
+
export declare function derive<TIn, TOut>(source: SnapshotSource<TIn> | TIn | (() => TIn), map: (value: TIn) => TOut): Derived<TOut | null>;
|
|
12
|
+
export {};
|
|
7
13
|
//# sourceMappingURL=derive.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"derive.d.ts","sourceRoot":"","sources":["../../src/runtime/derive.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"derive.d.ts","sourceRoot":"","sources":["../../src/runtime/derive.ts"],"names":[],"mappings":"AAMA,OAAO,EAQL,KAAK,cAAc,EAEpB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,OAAO,CAAC,CAAC,CAAE,SAAQ,cAAc,CAAC,CAAC,CAAC;IACnD,IAAI,CAAC,CAAC;CACP;AAgBD,KAAK,cAAc,CAAC,CAAC,IAAI;IACvB,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;CACtB,CAAC;AA0LF,wBAAgB,MAAM,CAAC,IAAI,EAAE,EAAE,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE5D,wBAAgB,MAAM,CAAC,GAAG,EAAE,IAAI,EAC9B,MAAM,EAAE,cAAc,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,EAC/C,GAAG,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,GACxB,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC"}
|
package/dist/runtime/derive.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{getCurrentInstance as f,claimHookIndex as _}from"./component.js";import{globalScheduler as l}from"./scheduler.js";import{withDerivedReadTracking as v,syncDerivedDependencySubscriptions as p,markReadableDerivedSubscribersDirty as y,markReactivePropsDirtySource as D,notifyReadableReaders as h,recordReadableRead as g,clearDerivedDependencySubscriptions as S}from"./readable.js";const o=new WeakMap,a=new Set;let d=!1;function m(e){let t=o.get(e);return t||(t=new Map,o.set(e,t)),t}function w(e){e._dirty=!0,!e._scheduled&&(e._scheduled=!0,a.add(e),d||(d=!0,l.enqueueInLane("derived",b)))}function b(){if(d=!1,a.size===0)return;const e=Array.from(a);a.clear();for(const t of e)t._scheduled=!1,t._dirty&&s(t,!0)}function s(e,t){if(!e._dirty&&e._hasValue)return e._value;if(e._evaluating)throw new Error("derive() cannot read itself recursively");e._evaluating=!0,e._dirty=!1,e._pendingDependencySources=new Set;const n=e._sources;let r;try{r=v(e,e._compute)}catch(c){throw e._dirty=!0,e._pendingDependencySources=void 0,c}finally{e._evaluating=!1}const i=e._pendingDependencySources??new Set;e._pendingDependencySources=void 0,p(e,n,i),e._sources=i;const u=!e._hasValue||!Object.is(e._value,r);return e._hasValue=!0,e._value=r,u&&t&&(y(e),D(e),h(e)),e._value}function C(e,t,n){const r=function(){return g(r),s(r,r._scheduled)};return r._owner=e,r._hookIndex=t,r._compute=n,r._value=void 0,r._hasValue=!1,r._dirty=!0,r._scheduled=!1,r._evaluating=!1,r._sources=new Set,r._markDirty=()=>{w(r)},r._cleanup=()=>{r._scheduled=!1,r._dirty=!1,r._hasValue=!1,a.delete(r),S(r,r._sources),r._derivedSubscribers?.clear(),r._readers?.clear()},e.cleanupFns.push(()=>{r._cleanup(),o.get(e)?.delete(t)}),r}function R(e,t,n){const r=m(e),i=r.get(t);if(i)return i._compute=n,i._dirty=!0,i;const u=C(e,t,n);return r.set(t,u),u}function k(e,t){return()=>{let n;return typeof e=="function"&&!("value"in e)?n=e():n=e?.value??e,n==null?null:t(n)}}function E(e,t){const n=f();if(!n)throw new Error("derive() can only be called during component render execution. Move derive() calls to the top level of your component function.");const r=_(n,"derive"),i=t===void 0?e:k(e,t),u=R(n,r,i);return s(u,!1),u}export{E as derive};
|
package/dist/runtime/events.d.ts
CHANGED
|
@@ -43,6 +43,7 @@ export declare function enableEventDelegation(container?: Element): void;
|
|
|
43
43
|
export declare function setGlobalDelegationContainer(container: Element): void;
|
|
44
44
|
export declare function addDelegatedListener(element: Element, eventName: string, handler: EventListener, originalHandler: EventListener, options?: AddEventListenerOptions): void;
|
|
45
45
|
export declare function removeDelegatedListener(element: Element, eventName: string): void;
|
|
46
|
+
export declare function getDelegatedHandlerForElement(element: Element, eventName: string): DelegatedHandler | undefined;
|
|
46
47
|
export declare function getDelegatedHandlersForElement(element: Element): Map<string, DelegatedHandler> | undefined;
|
|
47
48
|
export declare function hasDelegatedHandler(element: Element, eventName: string): boolean;
|
|
48
49
|
export declare function clearDelegatedHandlersForElement(element: Element): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/runtime/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/runtime/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,MAA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AAED,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,MAAM,GAChB,IAAI,CAsBN;AAED,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,MAAM,GAChB,gBAAgB,GAAG,SAAS,CAK9B;AAED,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,OAAO,GACf,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,GAAG,SAAS,CAK3C;AAED,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,MAAM,GAChB,OAAO,CAET;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"}
|
package/dist/runtime/events.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{globalScheduler as
|
|
1
|
+
import{globalScheduler as M}from"./scheduler.js";import{logger as w}from"../dev/logger.js";import{incrementPerfMetric as H}from"./perf-metrics.js";const h=["click","dblclick","mousedown","mouseup","mouseover","mouseout","mousemove","focus","blur","input","change","keydown","keyup","keypress","submit","scroll","wheel","touchstart","touchend","touchmove","touchcancel"],r=new WeakMap;let u=!1,d=null,g=null;const l=new Map;function G(){return u}function N(){u=!1,L()}function P(e){u=!0,e&&(d=e)}function T(e){g=e}function L(){for(const[e,n]of l)for(const[t,o]of n)e.removeEventListener(t,o);l.clear()}function k(){return g||d||(typeof document<"u"?document.body:null)}function x(e,n,t,o,c,i){l.has(e)||l.set(e,new Map);const p=l.get(e);if(!p.has(t)){const v=f=>{const D=f.target;D&&M.runInHandlerScope(()=>{let s=D;for(;s&&s!==e;){H("delegatedAncestorHops");const a=r.get(s),E=a?a instanceof Map?a.get(t):a.eventName===t?a:void 0:void 0;if(E)try{E.handler(f)}catch(b){w.error("[Askr] Delegated event error:",b)}if(f.cancelBubble)break;s=s.parentElement}})},m=C(t)??i;e.addEventListener(t,v,m),p.set(t,v)}A(n,{handler:o,original:c,element:n,eventName:t,options:i})}function A(e,n){const t=r.get(e);if(!t){r.set(e,n);return}if(t instanceof Map){t.set(n.eventName,n);return}if(t.eventName===n.eventName){r.set(e,n);return}const o=new Map;o.set(t.eventName,t),o.set(n.eventName,n),r.set(e,o)}function C(e){if(e==="wheel"||e==="scroll"||e.startsWith("touch"))return{passive:!0}}function W(e,n,t,o,c){if(!u)return;const i=k();i&&x(i,e,n,t,o,c)}function B(e,n){const t=r.get(e);if(t){if(t instanceof Map){if(t.delete(n),t.size===0){r.delete(e);return}if(t.size===1){const o=t.values().next().value;r.set(e,o)}return}t.eventName===n&&r.delete(e)}}function F(e,n){const t=r.get(e);if(t)return t instanceof Map?t.get(n):t.eventName===n?t:void 0}function I(e){const n=r.get(e);if(n)return n instanceof Map?n:new Map([[n.eventName,n]])}function V(e,n){return F(e,n)!==void 0}function _(e){r.delete(e)}function j(){return h}function q(e){return h.includes(e)}export{W as addDelegatedListener,_ as clearDelegatedHandlersForElement,N as disableEventDelegation,P as enableEventDelegation,j as getDelegatedEventNames,F as getDelegatedHandlerForElement,I as getDelegatedHandlersForElement,V as hasDelegatedHandler,q as isDelegatedEvent,G as isEventDelegationEnabled,B as removeDelegatedListener,T as setGlobalDelegationContainer};
|
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"fastlane.d.ts","sourceRoot":"","sources":["../../src/runtime/fastlane.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAarD,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;AA8CD,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"}
|
package/dist/runtime/fastlane.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{globalScheduler as f}from"./scheduler.js";import{logger as A}from"../dev/logger.js";import{populateKeyMapForElement as
|
|
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/run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,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"}
|
package/dist/runtime/for.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getCurrentInstance as
|
|
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":"
|
|
1
|
+
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../src/runtime/operations.ts"],"names":[],"mappings":"AAYA,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,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