@askrjs/askr 0.0.26 → 0.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -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/evaluate.d.ts.map +1 -1
- package/dist/renderer/evaluate.js +1 -1
- package/dist/renderer/fastpath.d.ts.map +1 -1
- package/dist/renderer/fastpath.js +1 -1
- package/dist/renderer/index.js +1 -1
- package/dist/renderer/keyed.d.ts.map +1 -1
- package/dist/renderer/keyed.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 +18 -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 +34 -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 x,createComponentInstance as ie,renderComponentInline as se,mountInstanceInline as U}from"../runtime/component.js";import{elementListeners as y,elementReactivePropsCleanup as A,cleanupInstanceIfPresent as h,removeAllListeners as C}from"./cleanup.js";import{incDevCounter as q,getDevValue as ce,setDevValue as D}from"../runtime/dev-namespace.js";import"./types.js";import{__FOR_BOUNDARY__ as j,_isDOMElement as g}from"../common/vnode.js";import{evaluateForState as z}from"../runtime/for.js";import{keyedElements as E}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 ye(e,t,n){const o=W()&&J(t);o&&Q(e,t,n,n,void 0);const r=G(n,!0),c=X(t);o||(c!==void 0?e.addEventListener(t,r,c):e.addEventListener(t,r)),y.has(e)||y.set(e,new Map),y.get(e).set(t,{handler:Z(o,e,t,r),original:n,options:c,isDelegated:o})}function Z(e,t,n,o){if(!e)return o;const r=ue(t);if(r){const c=r.get(n);if(c)return c.handler}return o}const v=new Set;let d=null,N=!1;function ge(){if(!d){d={id:"reactive-props-coordinator",lastRenderToken:0,hasPendingUpdate:!1,notifyUpdate:null,abortController:new AbortController};const e=()=>{if(!N)return;N=!1;const t=V();try{for(const n of v){if(!n.isActive)continue;for(const c of n.readStates)c._readers&&c._readers.delete(d);n.readStates.clear();const o=new Set,r={_pendingReadStates:o,_currentRenderToken:d.lastRenderToken};x(r);try{const c=n.propFn();te(n.el,n.propName,c,n.tagName),n.readStates=o}catch{}}d&&(d.lastRenderToken=(d.lastRenderToken??0)+1);for(const n of v)if(n.isActive)for(const o of n.readStates)o._readers||(o._readers=new Map),o._readers.set(d,d.lastRenderToken??0)}finally{x(t)}};d.notifyUpdate=()=>{N||(N=!0,O.isExecuting()?e():O.enqueue(e))},d._pendingFlushTask=()=>{d.hasPendingUpdate=!1,d.notifyUpdate()}}return d}function ee(e,t,n,o){const r=ge(),c={el:e,propName:t,propFn:n,tagName:o,readStates:new Set,isActive:!0};v.add(c);const s=V(),i=new Set,f={_pendingReadStates:i,_currentRenderToken:r.lastRenderToken};x(f);try{const a=n();te(e,t,a,o),c.readStates=i;for(const l of i)l._readers||(l._readers=new Map),l._readers.set(r,r.lastRenderToken??0)}finally{x(s)}return()=>{if(c.isActive=!1,v.delete(c),d)for(const a of c.readStates)a._readers&&a._readers.delete(d);c.readStates.clear(),v.size===0&&d&&(d.abortController.abort(),d=null)}}function te(e,t,n,o){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,o):e.setAttribute(t,String(n))}function he(e,t,n){for(const o in t){const r=t[o];if(o==="ref"){Ae(e,r);continue}if($(o)||r==null||r===!1)continue;const c=Y(o);if(c){ye(e,c,r);continue}if(typeof r=="function"&&!c&&o!=="ref"){const s=ee(e,o,r,n);A.has(e)||A.set(e,new Map),A.get(e).set(o,{cleanup:s,fnRef:r});continue}o==="class"||o==="className"?e.className=String(r):o==="value"||o==="checked"?ne(e,o,r,n):e.setAttribute(o,String(r))}}function Ae(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,o){t==="value"?((b(o,"input")||b(o,"textarea")||b(o,"select"))&&(e.value=String(n)),e.setAttribute("value",String(n))):t==="checked"&&(b(o,"input")&&(e.checked=!!n),e.setAttribute("checked",String(!!n)))}function R(e,t,n){const o=t.key??n?.key;o!==void 0&&e.setAttribute("data-key",String(o))}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 o=p(n);o&&t.appendChild(o)}return t}if(typeof e=="object"&&e!==null&&"type"in e){const t=e.type,n=e.props||{};if(typeof t=="string")return Se(e,t,n);if(typeof t=="function")return Te(e,t,n);if(t===j)return be(e,n);if(typeof t=="symbol"&&(t===de||String(t)==="Symbol(Fragment)"))return _e(e,n)}return null}function Se(e,t,n){const o=document.createElement(t);R(o,e,n),he(o,n,t);const r=n.children??e.children;if(r!=null)if(Array.isArray(r)){for(const c of r){const s=p(c);s&&o.appendChild(s)}}else{const c=p(r);c&&o.appendChild(c)}return o}function Te(e,t,n){const r=e[re]||oe(),c=t;if(c.constructor.name==="AsyncFunction")throw new Error("Async components are not supported. Use resource() for async work.");let i=e.__instance;i||(i=ie(me(),c,n||{},null),e.__instance=i),r&&(i.ownerFrame=r);const f=K(r,()=>se(i));if(f instanceof Promise)throw new Error("Async components are not supported. Components must return synchronously.");const a=K(r,()=>p(f));if(a instanceof Element)return U(i,a),R(a,e,n),a;if(!a){const u=document.createComment("");return i._placeholder=u,i.mounted=!0,i.notifyUpdate=i._enqueueRun,u}const l=document.createElement("div");return l.appendChild(a),U(i,l),R(l,e,n),l}function _e(e,t){const n=document.createDocumentFragment(),o=t.children||e.children;if(o)if(Array.isArray(o))for(const r of o){const c=p(r);c&&n.appendChild(c)}else{const r=p(o);r&&n.appendChild(r)}return n}function Ce(e,t){if(!g(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 o=t.source,r=z(n,o),c=document.createDocumentFragment();for(let s=0;s<r.length;s++){const i=r[s],f=n.orderedKeys[s],a=f!=null?n.items.get(f):null;let l=null;if(a&&a._dom){const u=a._dom;Ce(u,i)||(l=u)}l||(l=p(i),a&&(a._dom=l??void 0)),l&&(l instanceof Element&&S(l,i,!0),c.appendChild(l))}return c}function S(e,t,n=!0){if(!g(t))return;const o=t.props||{};R(e,t,o);const r=y.get(e);let c=null;for(const s in o){const i=o[s];if($(s))continue;const f=Y(s);if(i==null||i===!1){if(s==="class"||s==="className")e.className="";else if(f&&r?.has(f)){const a=r.get(f);a.isDelegated?k(e,f):a.options!==void 0?e.removeEventListener(f,a.handler,a.options):e.removeEventListener(f,a.handler),r.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){r&&r.size>0&&(c??=new Set).add(f);const a=W()&&J(f),l=r?.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)),a&&Q(e,f,i,i,void 0);const u=G(i,!0),m=X(f);a||(m!==void 0?e.addEventListener(f,u,m):e.addEventListener(f,u)),y.has(e)||y.set(e,new Map),y.get(e).set(f,{handler:Z(a,e,f,u),original:i,options:m,isDelegated:a})}else e.setAttribute(s,String(i))}if(r&&r.size>0)if(c===null){for(const[s,i]of r)i.isDelegated?k(e,s):i.options!==void 0?e.removeEventListener(s,i.handler,i.options):e.removeEventListener(s,i.handler);y.delete(e)}else{for(const[s,i]of r)c.has(s)||(i.isDelegated?k(e,s):i.options!==void 0?e.removeEventListener(s,i.handler,i.options):e.removeEventListener(s,i.handler),r.delete(s));r.size===0&&y.delete(e)}if(n){const s=t.children||o.children;ve(e,s)}}function ve(e,t){if(t==null){e.textContent="";return}if(!Array.isArray(t)&&(typeof t=="string"||typeof t=="number")){e.childNodes.length===1&&e.firstChild?.nodeType===3?e.firstChild.data=String(t):e.textContent=String(t);return}if(Array.isArray(t)&&t.length===1&&g(t[0])&&t[0].type===j){const o=t[0],r=o._forState;if(!r)throw new Error("[updateElementChildren] For boundary missing _forState");const c=(o.props||{}).source,s=z(r,c),i=E.get(e),f=ae(e,s,i||new Map);E.set(e,f);return}if(Array.isArray(t)){Ee(e,t);return}e.textContent="";const n=p(t);n&&e.appendChild(n)}function Ee(e,t){const n=Array.from(e.children),o=t.some(s=>typeof s=="string"||typeof s=="number"),r=t.some(s=>g(s));if(o&&r){const s=Array.from(e.childNodes),i=Math.max(s.length,t.length);for(let f=0;f<i;f++){const a=s[f],l=t[f];if(l===void 0&&a){a.nodeType===1&&h(a),a.remove();continue}if(!a&&l!==void 0){const u=p(l);u&&e.appendChild(u);continue}if(!(!a||l===void 0)){if(typeof l=="string"||typeof l=="number")if(a.nodeType===3)a.data=String(l);else{const u=document.createTextNode(String(l));e.replaceChild(u,a)}else if(g(l))if(a.nodeType===1){const u=a;if(typeof l.type=="string")if(_(u.tagName,l.type))S(u,l);else{const m=p(l);m&&(C(u),h(u),e.replaceChild(m,a))}}else{const u=p(l);u&&e.replaceChild(u,a)}}}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}}n.length===0&&e.childNodes.length>0&&(e.textContent="");const c=Math.max(n.length,t.length);for(let s=0;s<c;s++){const i=n[s],f=t[s];if(f===void 0&&i){h(i),i.remove();continue}if(!i&&f!==void 0){const a=p(f);a&&e.appendChild(a);continue}if(!(!i||f===void 0))if(typeof f=="string"||typeof f=="number")i.textContent=String(f);else if(g(f))if(typeof f.type=="string")if(_(i.tagName,f.type))S(i,f);else{const a=p(f);a&&(i instanceof Element&&C(i),h(i),e.replaceChild(a,i))}else{const a=p(f);a&&(i instanceof Element&&C(i),h(i),e.replaceChild(a,i))}else{const a=p(f);a&&(i instanceof Element&&C(i),h(i),e.replaceChild(a,i))}}}function tt(e,t){const n=t.length;let o=0,r=0;const c=F(),s=P.ASKR_FASTPATH_DEBUG==="1"||P.ASKR_FASTPATH_DEBUG==="true";for(let a=0;a<n;a++){const{key:l,vnode:u}=t[a],m=e.children[a];if(m&&g(u)&&typeof u.type=="string"){const L=u.type;if(_(m.tagName,L)){const w=u.children||u.props?.children;s&&I("positional idx",a,{chTag:m.tagName,vnodeType:L,chChildNodes:m.childNodes.length,childrenType:Array.isArray(w)?"array":typeof w}),ke(m,w,u),De(m,l,()=>r++),o++;continue}else s&&I("positional tag mismatch",a,{chTag:m.tagName,vnodeType:L})}else s&&I("positional missing or invalid",a,{ch:!!m});Fe(e,a,u)}const i=F()-c;Pe(e,t);const f={n,reused:o,updatedKeys:r,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)&&S(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)&&S(e,n,!1)):Ne(e,n)||S(e,n)}function Ne(e,t){const n=t.children||t.props?.children;if(!Array.isArray(n)||n.length!==2)return!1;const o=n[0],r=n[1];if(!g(o)||!g(r)||typeof o.type!="string"||typeof r.type!="string")return!1;const c=e.children[0],s=e.children[1];if(!c||!s||!_(c.tagName,o.type)||!_(s.tagName,r.type))return!1;const i=o.children||o.props?.children,f=r.children||r.props?.children;if(typeof i=="string"||typeof i=="number")T(c,String(i));else if(Array.isArray(i)&&i.length===1&&(typeof i[0]=="string"||typeof i[0]=="number"))T(c,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 De(e,t,n){try{const o=String(t);if(e.getAttribute("data-key")===o)return;e.setAttribute("data-key",o),n()}catch{}}function xe(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 o=0;o<n;o++){const r=e.charCodeAt(o),c=t.charCodeAt(o);if(r===c)continue;const s=r>=65&&r<=90?r+32:r,i=c>=65&&c<=90?c+32:c;if(s!==i)return!1}return!0}function _(e,t){const n=xe(t);return n!==null&&e===n?!0:b(e,t)}function Fe(e,t,n){const o=p(n);if(o){const r=e.children[t];r?(h(r),e.replaceChild(o,r)):e.appendChild(o)}}function Pe(e,t){try{const n=E.get(e),o=n?(n.clear(),n):new Map;for(let r=0;r<t.length;r++){const c=t[r].key,s=e.children[r];s&&o.set(c,s)}E.set(e,o)}catch{}}function nt(e,t){const n=F(),o=Array.from(e.childNodes),r=[];let c=0,s=0;for(let l=0;l<t.length;l++){const u=Re(t[l],o[l],r);u==="reused"?c++:u==="created"&&s++}const i=F()-n,f=Ie(e,r);E.delete(e);const a={n:t.length,reused:c,created:s,tBuild:i,tCommit:f};return Me(a),a}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 o=e;if(typeof o.type=="string"){const c=o.type;if(t&&t.nodeType===1&&_(t.tagName,c))return S(t,e),n.push(t),"reused"}const r=p(e);return r?(n.push(r),"created"):"skipped"}function Ie(e,t){const n=Date.now(),o=document.createDocumentFragment();for(let r=0;r<t.length;r++)o.appendChild(t[r]);try{for(let r=e.firstChild;r;){const c=r.nextSibling;r instanceof Element&&C(r),h(r),r=c}}catch{}return le("bulk-text-replace"),e.replaceChildren(o),Date.now()-n}function Me(e){try{D("__LAST_BULK_TEXT_FASTPATH_STATS",e),D("__LAST_FASTPATH_STATS",e),D("__LAST_FASTPATH_COMMIT_COUNT",1),q("bulkTextFastpathHits")}catch{}}function rt(e,t){const n=Number(P.ASKR_BULK_TEXT_THRESHOLD)||1024,o=.8,r=Array.isArray(t)?t.length:0;if(r<n)return M({phase:"bulk-unkeyed-eligible",reason:"too-small",total:r,threshold:n}),!1;const c=Ke(t);if(c.componentFound!==void 0)return M({phase:"bulk-unkeyed-eligible",reason:"component-child",index:c.componentFound}),!1;const s=c.simple/r,i=s>=o&&e.childNodes.length>=r;return M({phase:"bulk-unkeyed-eligible",total:r,simple:c.simple,fraction:s,requiredFraction:o,eligible:i}),i}function Ke(e){let t=0;for(let n=0;n<e.length;n++){const o=e[n];if(typeof o=="string"||typeof o=="number"){t++;continue}if(typeof o=="object"&&o!==null&&"type"in o){const r=o;if(typeof r.type=="function")return{simple:t,componentFound:n};typeof r.type=="string"&&Ue(r)&&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{D("__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,ve as updateElementChildren,S as updateElementFromVnode,Ee 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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluate.d.ts","sourceRoot":"","sources":["../../src/renderer/evaluate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"evaluate.d.ts","sourceRoot":"","sources":["../../src/renderer/evaluate.ts"],"names":[],"mappings":"AAuCA,eAAO,MAAM,gBAAgB,SAAkC,CAAC;AA0lBhE,wBAAgB,QAAQ,CACtB,IAAI,EAAE,OAAO,EACb,MAAM,EAAE,OAAO,GAAG,IAAI,EACtB,OAAO,CAAC,EAAE,MAAM,GACf,IAAI,CA8IN;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAEnD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{logger as
|
|
1
|
+
import{logger as b}from"../dev/logger.js";import{removeAllListeners as y,cleanupInstanceIfPresent as h,elementListeners as _}from"./cleanup.js";import{keyedElements as a}from"./keyed.js";import{reconcileKeyedChildren as C}from"./reconcile.js";import"./types.js";import{_isDOMElement as l,__FOR_BOUNDARY__ as T}from"../common/vnode.js";import{evaluateForState as D}from"../runtime/for.js";import{performBulkPositionalKeyedTextUpdate as B,isBulkTextFastPathEligible as P,performBulkTextReplace as R,updateUnkeyedChildren as O,createDOMNode as p,updateElementFromVnode as k}from"./dom.js";import{setDevValue as K,incDevCounter as U}from"../runtime/dev-namespace.js";import{Fragment as H}from"../common/jsx.js";import{extractKey as I,parseEventName as L,createWrappedHandler as v,getPassiveOptions as V}from"./utils.js";var d={};const pe=typeof document<"u",S=new WeakMap;function E(e,n){if(e===n)return!0;if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++){const i=e.charCodeAt(t),r=n.charCodeAt(t);if(i===r)continue;const s=i>=65&&i<=90?i+32:i,f=r>=65&&r<=90?r+32:r;if(s!==f)return!1}return!0}function G(e){if(Array.isArray(e)){if(e.length===1){const n=e[0];if(typeof n=="string"||typeof n=="number")return{isSimple:!0,text:String(n)}}}else if(typeof e=="string"||typeof e=="number")return{isSimple:!0,text:String(e)};return{isSimple:!1}}function W(e,n){return e.childNodes.length===1&&e.firstChild?.nodeType===3?(e.firstChild.data=n,!0):!1}function M(e){const n=new Map;for(let t=e.firstElementChild;t;t=t.nextElementSibling){const i=t.getAttribute("data-key");if(i!==null){n.set(i,t);const r=Number(i);Number.isNaN(r)||n.set(r,t)}}return n}function z(e){let n=a.get(e);return n||(n=M(e),n.size>0&&a.set(e,n)),n.size>0?n:void 0}function w(e){for(let n=0;n<e.length;n++)if(I(e[n])!==void 0)return!0;return!1}function j(e,n,t){if(d.ASKR_FORCE_BULK_POSREUSE==="1"&&q(e,n))return;const i=C(e,n,t);a.set(e,i)}function q(e,n){try{const t=[];for(const s of n)l(s)&&s.key!==void 0&&t.push({key:s.key,vnode:s});if(t.length===0||t.length!==n.length)return!1;(d.ASKR_FASTPATH_DEBUG==="1"||d.ASKR_FASTPATH_DEBUG==="true")&&b.warn("[Askr][FASTPATH] forced positional bulk keyed reuse (evaluate-level)");const i=B(e,t);if(d.ASKR_FASTPATH_DEBUG==="1")try{K("__LAST_FASTPATH_STATS",i),K("__LAST_FASTPATH_COMMIT_COUNT",1),U("bulkKeyedPositionalForced")}catch{}const r=M(e);return a.set(e,r),!0}catch(t){return(d.ASKR_FASTPATH_DEBUG==="1"||d.ASKR_FASTPATH_DEBUG==="true")&&b.warn("[Askr][FASTPATH] forced bulk path failed, falling back",t),!1}}function X(e,n){if(P(e,n)){const t=R(e,n);}else O(e,n);a.delete(e)}function N(e,n){const t=n._forState;if(!t)return;const i=(n.props||{}).source,r=D(t,i),s=o=>{o instanceof Element&&(y(o),h(o));let c=o.firstChild;for(;c;){const A=c.nextSibling;s(c),c=A}};let f=e.firstChild;for(;f;){const o=f.nextSibling;s(f),e.removeChild(f),f=o}for(let o=0;o<r.length;o++){const c=r[o],A=t.orderedKeys[o],m=A!=null?t.items.get(A):null;let u=null;if(m&&m._dom){const g=m._dom;(!(g instanceof Element)||!c?.type||typeof c.type!="string"||g.tagName.toLowerCase()===c.type.toLowerCase())&&(u=g)}u||(u=p(c),m&&(m._dom=u??void 0)),u&&(u instanceof Element&&l(c)&&k(u,c,!0),e.appendChild(u))}a.delete(e)}function F(e,n){if(n==null){for(let t=e.firstChild;t;){const i=t.nextSibling;t instanceof Element&&(y(t),h(t)),t=i}e.textContent="",a.delete(e);return}if(!Array.isArray(n)&&l(n)&&n.type===T){N(e,n);return}if(!Array.isArray(n)){for(let i=e.firstChild;i;){const r=i.nextSibling;i instanceof Element&&(y(i),h(i)),i=r}e.textContent="";const t=p(n);t&&e.appendChild(t),a.delete(e);return}if(n.length===1&&l(n[0])&&n[0].type===T){N(e,n[0]);return}if(w(n)){const t=z(e);try{j(e,n,t)}catch{const i=C(e,n,t);a.set(e,i)}}else X(e,n)}function x(e,n){let t=n.children||n.props?.children;if(t&&l(t)&&t.type===T){F(e,t),k(e,n,!1);return}t&&!Array.isArray(t)&&(t=[t]);const i=G(t);i.isSimple&&W(e,i.text)||F(e,t),k(e,n,!1)}function Y(e,n){let t=e.firstElementChild;for(let i=0;i<n.length;i++){const r=n[i],s=t?t.nextElementSibling:null;if(t&&l(r)&&typeof r.type=="string"&&E(t.tagName,r.type)){x(t,r),t=s;continue}const f=p(r);f&&(t?(y(t),h(t),e.replaceChild(f,t)):e.appendChild(f)),t=s}for(;t;){const i=t.nextElementSibling;y(t),h(t),e.removeChild(t),t=i}}function J(e,n){for(const[t,i]of Object.entries(n)){if(t==="children"||t==="key"||i==null||i===!1)continue;if(t==="ref"){Q(e,i);continue}const r=L(t);if(r){const s=v(i,!0),f=V(r);f!==void 0?e.addEventListener(r,s,f):e.addEventListener(r,s),_.has(e)||_.set(e,new Map),_.get(e).set(r,{handler:s,original:i,options:f});continue}t==="class"||t==="className"?e.className=String(i):t==="value"||t==="checked"?e[t]=i:e.setAttribute(t,String(i))}}function Q(e,n){const t=n;if(t){if(typeof t=="function"){t(e);return}try{t.current=e}catch{}}}function Z(e,n){const t=n.children;if(!Array.isArray(t)||!w(t))return!1;const i=document.createElement(n.type);e.appendChild(i),J(i,n.props||{});const r=C(i,t,void 0);return a.set(i,r),!0}function $(e){return l(e)&&typeof e.type=="symbol"&&(e.type===H||String(e.type)==="Symbol(askr.fragment)")}function ee(e){const n=e.props?.children||e.children||[];return Array.isArray(n)?n:[n]}function de(e,n,t){if(n&&!(typeof document>"u"))if(t&&S.has(t)){const i=S.get(t);let r=i.start.nextSibling;for(;r&&r!==i.end;){const f=r.nextSibling;r.remove(),r=f}const s=p(e);s&&n.insertBefore(s,i.end)}else if(t){const i=document.createComment("component-start"),r=document.createComment("component-end");n.appendChild(i),n.appendChild(r),S.set(t,{start:i,end:r});const s=p(e);s&&n.insertBefore(s,r)}else{let i=e;if($(i)){const o=ee(i);if(o.length===1&&l(o[0])&&typeof o[0].type=="string")i=o[0];else{Y(n,o);return}}const s=n.__ASKR_INSTANCE;if(s&&s.target===n)if(l(i)&&typeof i.type=="string"&&E(n.tagName,i.type)){x(n,i);return}else{const o=p(i);if(o&&n.parentNode){o instanceof Element&&(o.__ASKR_INSTANCE=s,s.target=o),y(n),n.parentNode.replaceChild(o,n);return}}const f=n.children[0];if(f&&l(i)&&typeof i.type=="string"&&E(f.tagName,i.type))x(f,i);else{if(n.textContent="",l(i)&&typeof i.type=="string"&&Z(n,i))return;const o=p(i);o&&n.appendChild(o)}}}function ye(e){S.delete(e)}export{pe as IS_DOM_AVAILABLE,ye as clearDOMRange,de as evaluate};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fastpath.d.ts","sourceRoot":"","sources":["../../src/renderer/fastpath.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AASrC,eAAO,MAAM,gBAAgB,SAAkC,CAAC;AAMhE,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,OAAO,EACf,WAAW,EAAE,KAAK,CAAC;IAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC,EAC1D,SAAS,CAAC,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,EACzC,aAAa,CAAC,EAAE,KAAK,EAAE,GACtB,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"fastpath.d.ts","sourceRoot":"","sources":["../../src/renderer/fastpath.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AASrC,eAAO,MAAM,gBAAgB,SAAkC,CAAC;AAMhE,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,OAAO,EACf,WAAW,EAAE,KAAK,CAAC;IAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC,EAC1D,SAAS,CAAC,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,EACzC,aAAa,CAAC,EAAE,KAAK,EAAE,GACtB,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAqMtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createDOMNode as S}from"./dom.js";import{_reconcilerRecordedParents as
|
|
1
|
+
import{createDOMNode as S}from"./dom.js";import{_reconcilerRecordedParents as P}from"./keyed.js";import{logger as v}from"../dev/logger.js";import{removeAllListeners as y,cleanupInstanceIfPresent as D}from"./cleanup.js";import{incDevCounter as E,setDevValue as p}from"../runtime/dev-namespace.js";import{isSchedulerExecuting as F}from"../runtime/scheduler.js";import{isBulkCommitActive as k,markFastPathApplied as w}from"../runtime/fastlane.js";var C={};const x=typeof document<"u";function I(l,a,h,f){if(typeof document>"u")return null;const A=a.length;if(A===0&&(!f||f.length===0))return null;F()||v.warn("[Askr][FASTPATH][DEV] Fast-path reconciliation invoked outside scheduler execution");let c,m;if(A<=20)try{const e=l.children;c=new Array(e.length);for(let n=0;n<e.length;n++)c[n]=e[n]}catch(e){c=void 0}else if(!h||h.size===0){m=new Map;try{for(let e=l.firstElementChild;e;e=e.nextElementSibling){const n=e.getAttribute("data-key");if(n!==null){m.set(n,e);const o=Number(n);Number.isNaN(o)||m.set(o,e)}}}catch(e){m=void 0}}const s=[];let T=0,_=0,d=0;for(let e=0;e<a.length;e++){const{key:n,vnode:o}=a[e];T++;let r;if(A<=20&&c){const t=String(n);for(let i=0;i<c.length;i++){const u=c[i],g=u.getAttribute("data-key");if(g!==null&&(g===t||Number(g)===n)){r=u;break}}r||(r=h?.get(n))}else r=m?.get(n)??h?.get(n);if(r)s.push(r),d++;else{const t=S(o);t&&(s.push(t),_++)}}if(f&&f.length)for(const e of f){const n=S(e);n&&(s.push(n),_++)}try{const e=Date.now(),n=document.createDocumentFragment();let o=0;for(let t=0;t<s.length;t++)n.appendChild(s[t]),o++;try{for(let t=l.firstChild;t;){const i=t.nextSibling;t instanceof Element&&y(t),D(t),t=i}}catch(t){}try{E("__DOM_REPLACE_COUNT"),p("__LAST_DOM_REPLACE_STACK_FASTPATH",new Error().stack)}catch(t){}l.replaceChildren(n);try{p("__LAST_FASTPATH_COMMIT_COUNT",1)}catch(t){}try{k()&&w(l)}catch(t){}const r=new Map;for(let t=0;t<a.length;t++){const i=a[t].key,u=s[t];u instanceof Element&&r.set(i,u)}try{const t={n:A,moves:0,lisLen:0,t_lookup:0,t_fragment:Date.now()-e,t_commit:0,t_bookkeeping:0,fragmentAppendCount:o,mapLookups:T,createdNodes:_,reusedCount:d};typeof globalThis<"u"&&(p("__LAST_FASTPATH_STATS",t),p("__LAST_FASTPATH_REUSED",d>0),E("fastpathHistoryPush")),(C.ASKR_FASTPATH_DEBUG==="1"||C.ASKR_FASTPATH_DEBUG==="true")&&v.warn("[Askr][FASTPATH]",JSON.stringify({n:A,createdNodes:_,reusedCount:d}))}catch(t){}try{P.add(l)}catch(t){}return r}catch(e){return null}}export{x as IS_DOM_AVAILABLE,I as applyRendererFastPath};
|
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
|
-
{"version":3,"file":"keyed.d.ts","sourceRoot":"","sources":["../../src/renderer/keyed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"keyed.d.ts","sourceRoot":"","sources":["../../src/renderer/keyed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAYrC,eAAO,MAAM,aAAa,iDAGvB,CAAC;AAEJ;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,OAAO,6CAE9C;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAwB9D;AAKD,eAAO,MAAM,0BAA0B,kBAAyB,CAAC;AAsEjE;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,OAAO,EACf,WAAW,EAAE,KAAK,EAAE,EACpB,SAAS,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;;;;;;EAwDrD"}
|
package/dist/renderer/keyed.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{buildKeyMapFromChildren as E,extractKey as O,
|
|
1
|
+
import{buildKeyMapFromChildren as E,extractKey as O,isIgnoredForPropChanges as _,hasPropChanged as S}from"./utils.js";const h=new WeakMap;function R(r){return h.get(r)}function b(r){try{if(h.has(r))return;let t=E(r);if(t.size===0){t=new Map;const n=Array.from(r.children);for(const e of n){const o=(e.textContent||"").trim();if(o){t.set(o,e);const s=Number(o);Number.isNaN(s)||t.set(s,e)}}}t.size>0&&h.set(r,t)}catch{}}const C=new WeakSet,p=64;function k(r){const t=[];for(const n of r){const e=O(n);e!==void 0&&t.push({key:e,vnode:n})}return t}function F(r){const t=[];for(const n of r){if(n===-1)continue;let e=0,o=t.length;for(;e<o;){const s=e+o>>1;t[s]<n?e=s+1:o=s}e===t.length?t.push(n):t[e]=n}return t.length}function L(r,t){for(const{key:n,vnode:e}of r){const o=t?.get(n);if(!o||typeof e!="object"||e===null)continue;const l=e.props||{};for(const i of Object.keys(l))if(!_(i)&&S(o,i,l[i]))return!0}return!1}function P(r,t,n){const e=k(t),o=e.length,s=e.map(c=>c.key),l=n?Array.from(n.keys()):[];let i=0;for(let c=0;c<s.length;c++){const f=s[c];(c>=l.length||l[c]!==f||!n?.has(f))&&i++}const m=o>=p&&l.length>0&&i>Math.max(64,Math.floor(o*.1));let u=!1,a=0;if(o>=p){const c=Array.from(r.children),f=e.map(({key:y})=>{const g=n?.get(y);return g?.parentElement===r?c.indexOf(g):-1});a=F(f),u=a<Math.floor(o*.5)}const d=L(e,n);return{useFastPath:(m||u)&&!d,totalKeyed:o,moveCount:i,lisLen:a,hasPropChanges:d}}export{C as _reconcilerRecordedParents,R as getKeyMapForElement,P as isKeyedReorderFastPathEligible,h as keyedElements,b as populateKeyMapForElement};
|
|
@@ -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,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,CAgDf;AAMD,+DAA+D;AAC/D,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAElD;AAED,gEAAgE;AAChE,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAK5D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,EAAE,EAAE,OAAO,EACX,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,OAAO,GACb,OAAO,CAgBT;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAM1E;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,EAAE,EAAE,OAAO,EACX,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,OAAO,CAQT;AAMD;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAStE;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,OAAO,GACd,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,CAW/B;AAMD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAOrD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,WAAW,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,aAAa,GACd,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EACV,YAAY,EACZ,KAAK,EACL,aAAa,EAGb,aAAa,EACd,MAAM,kBAAkB,CAAC;AAqE1B,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAE1D;AA0HD,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C;AAGD,wBAAgB,8BAA8B,IAAI,IAAI,CAErD;AAED,wBAAgB,gCAAgC,IAAI,IAAI,CAEvD;AAED,wBAAgB,KAAK,IAAI,aAAa,CAAC;AACvC,wBAAgB,KAAK,CACnB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,YAAY,EACtB,SAAS,CAAC,EAAE,MAAM,GACjB,IAAI,CAAC;AA2GR;;GAEG;AACH,wBAAgB,SAAS,IAAI,KAAK,EAAE,CAEnC;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,KAAK,EAAE,CAE7D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAuBzD;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAMlC;AAED;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC;IACjC,QAAQ,CAAC,EAAE,eAAe,EAAE,CAAC;IAC7B,aAAa,CAAC,EAAE,IAAI,CAAC;CACtB,CAAC;AAiCF,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,OAAO,EACjB,GAAG,QAAQ,EAAE,KAAK,CAAC,eAAe,GAAG,SAAS,CAAC,GAC9C,eAAe,CAuDjB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,EAAE,CAE9C;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,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,EAGpB,MAAM,YAAY,CAAC;AAIpB,YAAY,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,iBAAiB,CAAC;IACtB,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,EAAE,eAAe,CAAC;IACjC,GAAG,CAAC,EAAE,OAAO,CAAC;IAEd,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;IAC9B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,YAAY,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC;IAElC,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAC;IAC/B,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,eAAe,EAAE,KAAK,CACpB,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,CACzD,CAAC;IACF,UAAU,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC;IAC9B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,UAAU,EAAE,YAAY,GAAG,IAAI,CAAC;IAChC,MAAM,CAAC,EAAE,OAAO,CAAC;IAGjB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,mBAAmB,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;IACnD,gBAAgB,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;IAChD,kBAAkB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAIhC,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,wBAAgB,uBAAuB,CACrC,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,iBAAiB,EACrB,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,OAAO,GAAG,IAAI,GACrB,iBAAiB,CAuDnB;AAMD,wBAAgB,2BAA2B,IAAI,iBAAiB,GAAG,IAAI,CAEtE;AAGD,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,GACjC,IAAI,CAEN;AASD,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,GAClE,IAAI,CAgBN;AA4BD,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,iBAAiB,EAC3B,MAAM,EAAE,OAAO,GAAG,IAAI,GACrB,IAAI,CAuBN;AAoND;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,iBAAiB,GAC1B,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CA4B5B;AAwFD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAUlE;AAED,wBAAgB,kBAAkB,IAAI,iBAAiB,GAAG,IAAI,CAE7D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAgB,SAAS,IAAI,WAAW,CAQvC;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAE3E;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,cAAc,CAC5B,QAAQ,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,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;AAcD,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;AAwHD,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,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"}
|