@firsthandjs/dom 0.9.1 → 0.10.1

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.
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  mount
3
- } from "./dev-chunk-6V32MCOI.js";
3
+ } from "./dev-chunk-KJHYMOKB.js";
4
4
  import {
5
5
  hydration
6
- } from "./dev-chunk-ADHDPKZW.js";
6
+ } from "./dev-chunk-U46CIJCO.js";
7
7
 
8
8
  // packages/dom/src/hydrate.ts
9
9
  var COMMENT_NODE = 8;
@@ -65,43 +65,47 @@ function claimRegion(parent, marker) {
65
65
  return offered;
66
66
  }
67
67
  }
68
+ const bounds = boundsOf(parent, marker);
69
+ if (bounds === null) {
70
+ return null;
71
+ }
72
+ const { end } = bounds;
73
+ cursors.set(parent, end === null ? null : end.nextSibling);
74
+ return claimedOf(bounds.start === end ? null : bounds.start, end);
75
+ }
76
+ function claimedOf(start, end) {
77
+ const nodes = [];
78
+ for (let one = start; one !== null && one !== end; one = one.nextSibling) {
79
+ nodes.push(one);
80
+ }
81
+ const only = nodes.length === 1 ? nodes[0] : null;
82
+ return {
83
+ nodes: nodes.length === 0 ? null : only ?? nodes,
84
+ text: only !== null && only.nodeType === TEXT_NODE ? only.data : void 0,
85
+ region: { node: start, end }
86
+ };
87
+ }
88
+ function boundsOf(parent, marker) {
68
89
  const held = cursors.get(parent);
69
90
  const fromTheTop = held === void 0;
70
91
  const node = fromTheTop ? parent.firstChild : held;
71
- let start;
72
- let end;
73
92
  const stop = fromTheTop ? marker : null;
74
93
  let open = node;
75
94
  while (open !== null && open !== stop && !isOpen(open)) {
76
95
  open = open.nextSibling;
77
96
  }
78
97
  if (open !== null && open !== stop) {
79
- end = closeOf(open);
98
+ const end = closeOf(open);
80
99
  if (marker !== null && marker !== end) {
81
100
  return null;
82
101
  }
83
102
  openers.push(open);
84
- start = open.nextSibling;
85
- } else if (fromTheTop) {
86
- start = node;
87
- end = marker;
88
- } else {
89
- return null;
90
- }
91
- cursors.set(parent, end === null ? null : end.nextSibling);
92
- if (start === end) {
93
- start = null;
103
+ return { start: open.nextSibling, end };
94
104
  }
95
- const nodes = [];
96
- for (let one = start; one !== null && one !== end; one = one.nextSibling) {
97
- nodes.push(one);
105
+ if (fromTheTop) {
106
+ return { start: node, end: marker };
98
107
  }
99
- const only = nodes.length === 1 ? nodes[0] : null;
100
- return {
101
- nodes: nodes.length === 0 ? null : only ?? nodes,
102
- text: only !== null && only.nodeType === TEXT_NODE ? only.data : void 0,
103
- region: { node: start, end }
104
- };
108
+ return null;
105
109
  }
106
110
  function place(anchor) {
107
111
  const node = claim === null ? null : claim.node;
package/dist/hydrate.js CHANGED
@@ -1 +1 @@
1
- import{b as T}from"./chunk-6BRSYQCI.js";import{b as a}from"./chunk-P4PXTIUD.js";var m=8,C=3,w="[",t=null,p=0,g=new WeakMap,c=[],N=new Map;function F(e,n=document.body){return T(e,n,o=>{M(n,o)})}function M(e,n){let o=t,l=p;p++,a.current=j,t={node:e.firstChild,end:null};try{return n()}finally{t=o,p=l,p===0&&(a.current=null,O())}}function O(){for(let e=0;e<c.length;e++){let n=c[e];n.parentNode?.removeChild(n)}c=[],g=new WeakMap,N=new Map}function S(e){if(t===null)return null;let n=t.node;if(n===null||n.nodeName!==e)return null;let o=n.nextSibling;return t.node=o===t.end?null:o,n}function v(e,n){if(n!==null){let r=N.get(n);if(r!==void 0)return N.delete(n),r}let o=g.get(e),l=o===void 0,h=l?e.firstChild:o,d,u,x=l?n:null,i=h;for(;i!==null&&i!==x&&!y(i);)i=i.nextSibling;if(i!==null&&i!==x){if(u=b(i),n!==null&&n!==u)return null;c.push(i),d=i.nextSibling}else if(l)d=h,u=n;else return null;g.set(e,u===null?null:u.nextSibling),d===u&&(d=null);let s=[];for(let r=d;r!==null&&r!==u;r=r.nextSibling)s.push(r);let f=s.length===1?s[0]:null;return{nodes:s.length===0?null:f??s,text:f!==null&&f.nodeType===C?f.data:void 0,region:{node:d,end:u}}}function E(e){let n=t===null?null:t.node,o=n?.parentNode??null;return o?.insertBefore(e,n),o}function D(e,n){let o=t;t=e;try{return n()}finally{t=o}}function y(e){return e!==null&&e.nodeType===m&&e.nodeValue===w}function b(e){let n=0;for(let o=e.nextSibling;o!==null;o=o.nextSibling)if(o.nodeType===m){if(y(o)){n++;continue}if(n===0)return o;n--}return null}function R(e){return y(e)?b(e):e}function W(e){return e.slice(1,e.search(/[\s/>]/)).toUpperCase()}function V(e,n,o,l){n.insertBefore(o,l.region.end),e.node=l.nodes===null?o:[...Array.isArray(l.nodes)?l.nodes:[l.nodes],o],N.set(o,l)}var j={tag:W,adopt:S,claim:v,within:D,keep:V,step:R,place:E};export{S as adopt,v as claimRegion,F as hydrate,M as hydrateWith,E as place,D as within};
1
+ import{b as g}from"./chunk-YX6HJXS6.js";import{b as f}from"./chunk-467WEPXM.js";var y=8,x=3,T="[",l=null,r=0,c=new WeakMap,d=[],s=new Map;function A(n,o=document.body){return g(n,o,e=>{m(o,e)})}function m(n,o){let e=l,t=r;r++,f.current=W,l={node:n.firstChild,end:null};try{return o()}finally{l=e,r=t,r===0&&(f.current=null,b())}}function b(){for(let n=0;n<d.length;n++){let o=d[n];o.parentNode?.removeChild(o)}d=[],c=new WeakMap,s=new Map}function C(n){if(l===null)return null;let o=l.node;if(o===null||o.nodeName!==n)return null;let e=o.nextSibling;return l.node=e===l.end?null:e,o}function O(n,o){if(o!==null){let u=s.get(o);if(u!==void 0)return s.delete(o),u}let e=M(n,o);if(e===null)return null;let{end:t}=e;return c.set(n,t===null?null:t.nextSibling),w(e.start===t?null:e.start,t)}function w(n,o){let e=[];for(let u=n;u!==null&&u!==o;u=u.nextSibling)e.push(u);let t=e.length===1?e[0]:null;return{nodes:e.length===0?null:t??e,text:t!==null&&t.nodeType===x?t.data:void 0,region:{node:n,end:o}}}function M(n,o){let e=c.get(n),t=e===void 0,u=t?n.firstChild:e,N=t?o:null,i=u;for(;i!==null&&i!==N&&!p(i);)i=i.nextSibling;if(i!==null&&i!==N){let a=h(i);return o!==null&&o!==a?null:(d.push(i),{start:i.nextSibling,end:a})}return t?{start:u,end:o}:null}function S(n){let o=l===null?null:l.node,e=o?.parentNode??null;return e?.insertBefore(n,o),e}function v(n,o){let e=l;l=n;try{return o()}finally{l=e}}function p(n){return n!==null&&n.nodeType===y&&n.nodeValue===T}function h(n){let o=0;for(let e=n.nextSibling;e!==null;e=e.nextSibling)if(e.nodeType===y){if(p(e)){o++;continue}if(o===0)return e;o--}return null}function E(n){return p(n)?h(n):n}function D(n){return n.slice(1,n.search(/[\s/>]/)).toUpperCase()}function R(n,o,e,t){o.insertBefore(e,t.region.end),n.node=t.nodes===null?e:[...Array.isArray(t.nodes)?t.nodes:[t.nodes],e],s.set(e,t)}var W={tag:D,adopt:C,claim:O,within:v,keep:R,step:E,place:S};export{C as adopt,O as claimRegion,A as hydrate,m as hydrateWith,S as place,v as within};
package/dist/index.d.ts CHANGED
@@ -4,7 +4,8 @@
4
4
  * Re-exports the reactive core so that applications have one import site.
5
5
  */
6
6
  export { component, defineElement, setElementPrefix, createComponent, view } from './component.js';
7
- export { setComponentAdapter, FirsthandComponentError } from './adapter.js';
7
+ export { setComponentAdapter } from './adapter.js';
8
+ export { FirsthandComponentError } from './errors.js';
8
9
  export type { ComponentAdapter } from './adapter.js';
9
10
  export type { Component, ComponentOptions, AttributeCodec, View, Render } from './component.js';
10
11
  export { render } from './render.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,gBAAgB,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACnG,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC5E,YAAY,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,SAAS,EAAE,gBAAgB,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OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EACL,MAAM,EACN,QAAQ,EACR,MAAM,EACN,KAAK,EACL,OAAO,EACP,SAAS,EACT,UAAU,EACV,UAAU,EACV,YAAY,EACZ,aAAa,EACb,OAAO,EACP,UAAU,EACV,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,WAAW,EACX,OAAO,EACP,YAAY,EACZ,OAAO,EACP,YAAY,EACZ,aAAa,EACb,MAAM,GACP,MAAM,mBAAmB,CAAC"}
package/dist/index.dev.js CHANGED
@@ -10,11 +10,11 @@ import {
10
10
  setComponentAdapter,
11
11
  setElementPrefix,
12
12
  view
13
- } from "./dev-chunk-MKONDKMD.js";
13
+ } from "./dev-chunk-HLMVSIC4.js";
14
14
  import {
15
15
  render
16
- } from "./dev-chunk-6V32MCOI.js";
17
- import "./dev-chunk-ADHDPKZW.js";
16
+ } from "./dev-chunk-KJHYMOKB.js";
17
+ import "./dev-chunk-U46CIJCO.js";
18
18
 
19
19
  // packages/dom/src/portal.ts
20
20
  import { onCleanup } from "@firsthandjs/core";
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{a as d,b as i,e as f,f as s,h as a,i as m,j as l,k as x,l as C,m as h,x as y}from"./chunk-E4GAI5XA.js";import{a as c}from"./chunk-6BRSYQCI.js";import"./chunk-P4PXTIUD.js";import{onCleanup as u}from"@firsthandjs/core";function N(e,t){let o=[];p(e,o);for(let r=0;r<o.length;r++)t.appendChild(o[r]);return u(()=>{for(let r=0;r<o.length;r++){let n=o[r];n.parentNode?.removeChild(n)}}),null}function p(e,t){if(!(e==null||typeof e=="boolean")){if(Array.isArray(e)){for(let o=0;o<e.length;o++)p(e[o],t);return}if(typeof e=="object"&&typeof e.nodeType=="number"){t.push(e);return}t.push(document.createTextNode(String(e)))}}import{signal as D,computed as S,effect as T,batch as V,untrack as W,onCleanup as q,createRoot as z,catchError as B,runWithOwner as G,createContext as H,provide as I,useContext as J,FirsthandContextError as K,FirsthandCycleError as L,FirsthandReadonlyError as M}from"@firsthandjs/core";export{i as FirsthandComponentError,K as FirsthandContextError,L as FirsthandCycleError,M as FirsthandReadonlyError,V as batch,B as catchError,s as component,S as computed,m as createComponent,H as createContext,z as createRoot,l as defineElement,T as effect,x as list,y as mergeProps,h as off,C as on,q as onCleanup,N as portal,I as provide,c as render,G as runWithOwner,d as setComponentAdapter,f as setElementPrefix,D as signal,W as untrack,J as useContext,a as view};
1
+ import{a as d,b as i,e as f,f as s,h as m,i as a,j as l,k as x,l as C,m as h,x as y}from"./chunk-MWEKNBIC.js";import{a as c}from"./chunk-YX6HJXS6.js";import"./chunk-467WEPXM.js";import{onCleanup as u}from"@firsthandjs/core";function N(e,t){let o=[];p(e,o);for(let r=0;r<o.length;r++)t.appendChild(o[r]);return u(()=>{for(let r=0;r<o.length;r++){let n=o[r];n.parentNode?.removeChild(n)}}),null}function p(e,t){if(!(e==null||typeof e=="boolean")){if(Array.isArray(e)){for(let o=0;o<e.length;o++)p(e[o],t);return}if(typeof e=="object"&&typeof e.nodeType=="number"){t.push(e);return}t.push(document.createTextNode(String(e)))}}import{signal as S,computed as T,effect as V,batch as W,untrack as q,onCleanup as z,createRoot as B,catchError as G,runWithOwner as H,createContext as I,provide as J,useContext as K,FirsthandContextError as L,FirsthandCycleError as M,FirsthandReadonlyError as Q}from"@firsthandjs/core";export{d as FirsthandComponentError,L as FirsthandContextError,M as FirsthandCycleError,Q as FirsthandReadonlyError,W as batch,G as catchError,s as component,T as computed,a as createComponent,I as createContext,B as createRoot,l as defineElement,V as effect,x as list,y as mergeProps,h as off,C as on,z as onCleanup,N as portal,J as provide,c as render,H as runWithOwner,i as setComponentAdapter,f as setElementPrefix,S as signal,q as untrack,K as useContext,m as view};
package/dist/insert.d.ts CHANGED
@@ -1,7 +1,14 @@
1
- import { type Owner, type Signal } from '@firsthandjs/core';
1
+ /**
2
+ * A dynamic child position: what fills it, and when it is filled again.
3
+ *
4
+ * `insert` binds one; `applyChild` writes whatever a part produced into one.
5
+ * The two are mutually recursive by nature — an array of children is children —
6
+ * which is why they are one module rather than two.
7
+ */
8
+ import { type Owner } from '@firsthandjs/core';
2
9
  import { type Claimed } from './claim.js';
3
- /** What a child part currently owns in the DOM. */
4
- export type ChildSlot = Node | Node[] | null;
10
+ import { type ChildSlot } from './nodes.js';
11
+ export type { ChildSlot } from './nodes.js';
5
12
  /**
6
13
  * Runs `body` with the parts inside it excused from removing their nodes.
7
14
  *
@@ -55,88 +62,32 @@ export type DynamicChild = {
55
62
  export declare function part(thunk: () => unknown): DynamicChild;
56
63
  export declare function isDynamicChild(value: object): value is DynamicChild;
57
64
  /**
58
- * One place a run writes to, and what it last put there.
59
- *
60
- * A render function runs as a whole, so the DOM it describes has to be the DOM
61
- * it already made: created on the first run, written on every one after. These
62
- * records are what survives between runs — the node, and the last value, so a
63
- * run that produces what is already on screen writes nothing.
64
- */
65
- export type Slot = {
66
- /** What this site made, or what a write currently owns. */
67
- node?: ChildSlot;
68
- /** The last primitive written here, when the last thing written was one. */
69
- text?: string | undefined;
70
- /** The last value written to an attribute or a property. */
71
- last?: unknown;
72
- /** What the site made besides its node: parts, listeners, components. */
73
- owner?: Owner;
74
- /** The run that last reached this site. */
75
- seen?: number;
76
- /** A prop a run feeds a child, held so the child keeps its instance. */
77
- cell?: Signal<unknown>;
78
- };
79
- /**
80
- * Where a run keeps its sites.
65
+ * What only the runtime passes, and the compiler never does.
81
66
  *
82
- * One per instance, made in the setup which runs once, so there is nothing
83
- * to look up and nothing ambient. What a site makes belongs to `owner`, the
84
- * component's own, rather than to the run that happened to make it: a run's
85
- * scope is cleared before it runs again, and anything left there would be
86
- * disposed by the second run.
67
+ * Two hand-offs that exist for one caller each, grouped rather than added to
68
+ * the signature: `insert` is the compiler/runtime protocol, and its arity is
69
+ * part of that protocol (ARCHITECTURE section 1.1). Both paths that pass this
70
+ * happen once per part rather than once per row, so the object costs nothing
71
+ * anybody can measure.
87
72
  */
88
- export type Store = {
89
- slots: (Slot | undefined)[];
90
- owner: Owner | null;
91
- /** Which run is in progress, so that what it did not reach can be found. */
92
- generation: number;
93
- /** The component this belongs to, for what development has to say about it. */
94
- name: string;
95
- /** Whether this run has changed anything. Development only. */
96
- busy?: boolean;
97
- /** How many runs in a row have changed nothing. Development only. */
98
- quiet?: number;
73
+ export type InsertOptions = {
74
+ /**
75
+ * A region already claimed, handed down rather than looked up.
76
+ *
77
+ * How a part that turns out to produce another part gives the markup it
78
+ * claimed to the part that will actually own it see the `function` branch
79
+ * in `run` below.
80
+ */
81
+ seed?: Claimed | null;
82
+ /**
83
+ * Told what this part currently has in the document, after every run.
84
+ *
85
+ * A keyed list needs it: a row that is a view owns nodes that change without
86
+ * the list running, and a reorder has to move what the row has now rather
87
+ * than what it had when it was made.
88
+ */
89
+ report?: Report;
99
90
  };
100
- /** Declared once per instance by the compiler, in the setup. */
101
- export declare function store(name?: string): Store;
102
- /** Notes that this run has actually changed something. */
103
- export declare function wrote(store: Store): void;
104
- /** The record for one site, made the first time a run reaches it. */
105
- export declare function site(store: Store, index: number): Slot;
106
- /**
107
- * Opens a site: what it makes now belongs to the instance, not to this run.
108
- *
109
- * Returns the owner to restore, which the compiler hands back to `close`.
110
- */
111
- export declare function open(store: Store, slot: Slot): Owner | null;
112
- export declare function close(previous: Owner | null): void;
113
- /**
114
- * Ends a run, and disposes what it did not reach.
115
- *
116
- * A branch the run has left is gone, not hidden: its components run their
117
- * cleanups and its parts stop, exactly as if the markup had never been there.
118
- * Coming back builds it again. That is what the control flow says, so it is
119
- * what happens.
120
- */
121
- export declare function ran<T>(store: Store, value: T): T;
122
- /**
123
- * A prop whose value belongs to the run, as something the child can hold.
124
- *
125
- * The child keeps its instance across runs, so its props cannot be getters
126
- * over the run that made them — that value belongs to one call. It gets a cell
127
- * instead, made the first time and written afterwards, so a prop that did not
128
- * change wakes nothing.
129
- */
130
- export declare function cell(store: Store, index: number, value: unknown): Signal<unknown>;
131
- /**
132
- * Writes a child position a run owns.
133
- *
134
- * The same text twice is not a write: `data` would accept it, and measuring
135
- * says that comparing a remembered string costs half what setting one does.
136
- * Anything else goes through `applyChild`, where a node that has not moved is
137
- * recognised and left where it is.
138
- */
139
- export declare function writeChild(store: Store, index: number, parent: Node, marker: Node | null, value: unknown): void;
140
91
  /**
141
92
  * Binds a dynamic child position.
142
93
  *
@@ -144,27 +95,17 @@ export declare function writeChild(store: Store, index: number, parent: Node, ma
144
95
  * The thunk is evaluated once inside a tracking scope; if it read nothing
145
96
  * reactive, no effect is retained (ADR-0009).
146
97
  */
147
- export declare function insert(parent: Node, value: unknown, marker?: Node | null,
148
- /**
149
- * A region already claimed, handed down rather than looked up.
150
- *
151
- * The compiler never passes this. It is how a part that turns out to
152
- * produce another part gives the markup it claimed to the part that will
153
- * actually own it — see the `function` branch below.
154
- */
155
- seed?: Claimed | null,
98
+ export declare function insert(parent: Node, value: unknown, marker?: Node | null, options?: InsertOptions): void;
99
+ /** Told what a part has in the document, when somebody needs to know. */
100
+ export type Report = (nodes: Node[]) => void;
156
101
  /**
157
- * Told what this part currently has in the document, after every run.
102
+ * Applies one value to a child slot and returns the slot's new contents.
158
103
  *
159
- * The compiler never passes this either. A keyed list needs it: a row that
160
- * is a view owns nodes that change without the list running, and a reorder
161
- * has to move what the row has now rather than what it had when it was
162
- * made.
104
+ * The two branches that answer for almost every write are first and inline:
105
+ * nothing, and a primitive. Everything else is a shape that costs more than the
106
+ * call to reach it, so it lives in `applyOther` and this function stays small
107
+ * enough to read in one go.
163
108
  */
164
- report?: Report): void;
165
- /** Told what a part has in the document, when somebody needs to know. */
166
- export type Report = (nodes: Node[]) => void;
167
- /** Applies one value to a child slot and returns the slot's new contents. */
168
109
  export declare function applyChild(parent: Node, marker: Node | null, current: ChildSlot, value: unknown): ChildSlot;
169
110
  /**
170
111
  * Binds parts whose anchors are now in the document.
@@ -173,33 +114,6 @@ export declare function applyChild(parent: Node, marker: Node | null, current: C
173
114
  * disposal and error ownership lexical. A part created outside any scope —
174
115
  * runtime JSX at module level, say — is bound under the scope doing the
175
116
  * inserting, so that it is still disposed by something rather than by nothing.
176
- *
177
- * A part that is already mounted is left alone. A run hands back what it made
178
- * rather than making it again, so the same part arrives here on every run of
179
- * the run that owns it, and binding it twice would put a second copy of the
180
- * whole child on the page beside the first.
181
117
  */
182
118
  export declare function bindPart(child: DynamicChild, parent: Node, report?: Report): void;
183
- /**
184
- * Reconciles two node lists in place, by node identity.
185
- *
186
- * Keyed lists reuse their rows' DOM nodes across reorders, so identity is
187
- * exactly the right key here: a row that survived is the same node, and only
188
- * nodes that genuinely moved are touched.
189
- *
190
- * The algorithm is a common-prefix/suffix trim, then a longest-increasing-
191
- * subsequence over the surviving nodes, moving only the ones outside it — the
192
- * provably minimal number of `insertBefore` calls.
193
- *
194
- * This is the outcome of the comparison ADR-0010 required, not an assumption:
195
- * three candidates were measured over ten operations at two sizes, with the
196
- * order rotated per repetition and correctness asserted on every run. LIS came
197
- * out ahead overall (1.02 against 1.17 for the two-ended scan and 1.49 for the
198
- * naive baseline) and decisively where moves are few and far apart — a swap at
199
- * 10 000 rows costs it 2 moves instead of 9 997. It loses one case: a full
200
- * reverse, where the subsequence is length 1 and the analysis buys nothing.
201
- * That trade is published in `benchmarks/results/reconcilers.json`.
202
- */
203
- export declare function reconcile(parent: Node, marker: Node | null, a: Node[], b: Node[]): void;
204
- export {};
205
119
  //# sourceMappingURL=insert.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"insert.d.ts","sourceRoot":"","sources":["../src/insert.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,KAAK,KAAK,EACV,KAAK,MAAM,EACZ,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAa,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAErD,mDAAmD;AACnD,MAAM,MAAM,SAAS,GAAG,IAAI,G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AI,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAajF"}
@@ -12,8 +12,11 @@
12
12
  export declare const PROTOCOL_VERSION = 1;
13
13
  export { template, path } from './template.js';
14
14
  export { first, next } from './claim.js';
15
- export { insert, applyChild, reconcile, part, store, site, open, close, ran, wrote, cell, writeChild, } from './insert.js';
16
- export type { DynamicChild, ChildSlot, Slot, Store } from './insert.js';
15
+ export { insert, applyChild, part } from './insert.js';
16
+ export { reconcile } from './reconcile.js';
17
+ export { store, site, open, close, ran, wrote, cell, writeChild } from './store.js';
18
+ export type { DynamicChild, ChildSlot } from './insert.js';
19
+ export type { Slot, Store } from './store.js';
17
20
  export { setAttribute, setAttributeNS, setProperty, setBoolean, setClass, setClassList, setStyle, setStyleObject, } from './attributes.js';
18
21
  export { on, off } from './events.js';
19
22
  export { applyProp, spread, mergeProps, rest } from './props.js';
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAElC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EACL,MAAM,EACN,UAAU,EACV,SAAS,EACT,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,GAAG,EACH,KAAK,EACL,IAAI,EACJ,UAAU,GACX,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EACL,YAAY,EACZ,cAAc,EACd,WAAW,EACX,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,cAAc,GACf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,EAAE,EAAE,GAAG,EA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I,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAGzC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC"}
@@ -19,26 +19,21 @@ import {
19
19
  setStyleObject,
20
20
  spread,
21
21
  view
22
- } from "./dev-chunk-MKONDKMD.js";
22
+ } from "./dev-chunk-HLMVSIC4.js";
23
23
  import {
24
24
  applyChild,
25
- cell,
26
- close,
25
+ devHandedNewFunction,
27
26
  devHydrationMismatch,
27
+ devRan,
28
28
  first,
29
29
  hydration,
30
30
  insert,
31
+ isDynamicChild,
31
32
  label,
32
33
  next,
33
- open,
34
34
  part,
35
- ran,
36
- reconcile,
37
- site,
38
- store,
39
- writeChild,
40
- wrote
41
- } from "./dev-chunk-ADHDPKZW.js";
35
+ reconcile
36
+ } from "./dev-chunk-U46CIJCO.js";
42
37
 
43
38
  // packages/dom/src/template.ts
44
39
  function template(html, isFragment = false) {
@@ -74,6 +69,121 @@ function path(root, ...indices) {
74
69
  return node;
75
70
  }
76
71
 
72
+ // packages/dom/src/store.ts
73
+ import {
74
+ createOwner,
75
+ disposeOwner,
76
+ getOwner,
77
+ runWithOwner,
78
+ setOwner,
79
+ signal
80
+ } from "@firsthandjs/core";
81
+ function store(name = "") {
82
+ return { slots: [], owner: getOwner(), generation: 0, name };
83
+ }
84
+ function wrote(store2) {
85
+ store2.busy = true;
86
+ }
87
+ function site(store2, index) {
88
+ const existing = store2.slots[index];
89
+ if (existing !== void 0) {
90
+ existing.seen = store2.generation;
91
+ return existing;
92
+ }
93
+ const slot = { seen: store2.generation };
94
+ store2.slots[index] = slot;
95
+ return slot;
96
+ }
97
+ function open(store2, slot) {
98
+ const owner = createOwner(store2.owner);
99
+ slot.owner = owner;
100
+ return setOwner(owner);
101
+ }
102
+ function close(previous) {
103
+ setOwner(previous);
104
+ }
105
+ function ran(store2, value) {
106
+ devRan(store2);
107
+ const generation = store2.generation;
108
+ const slots = store2.slots;
109
+ for (let i = 0; i < slots.length; i++) {
110
+ const slot = slots[i];
111
+ if (slot === void 0 || slot.seen === generation) {
112
+ continue;
113
+ }
114
+ if (slot.owner !== void 0) {
115
+ disposeOwner(slot.owner);
116
+ }
117
+ slots[i] = void 0;
118
+ }
119
+ store2.generation = generation + 1;
120
+ return value;
121
+ }
122
+ function cell(store2, index, value) {
123
+ const slot = site(store2, index);
124
+ const existing = slot.cell;
125
+ if (existing === void 0) {
126
+ const made = signal(value);
127
+ slot.cell = made;
128
+ return made;
129
+ }
130
+ if (existing.peek() !== value) {
131
+ devHandedNewFunction(store2, value);
132
+ wrote(store2);
133
+ existing.value = value;
134
+ }
135
+ return existing;
136
+ }
137
+ function writeChild(store2, index, parent, marker, value) {
138
+ const slot = site(store2, index);
139
+ if (slot.node === void 0 && hydration.current !== null && adopt(slot, parent, marker, value)) {
140
+ return;
141
+ }
142
+ const type = typeof value;
143
+ if (type === "string" || type === "number") {
144
+ const text = String(value);
145
+ if (text === slot.text) {
146
+ return;
147
+ }
148
+ wrote(store2);
149
+ slot.text = text;
150
+ slot.node = applyChild(parent, marker, slot.node ?? null, text);
151
+ return;
152
+ }
153
+ slot.text = void 0;
154
+ if (value === slot.last) {
155
+ return;
156
+ }
157
+ wrote(store2);
158
+ slot.last = value;
159
+ slot.node = applyChild(parent, marker, slot.node ?? null, value);
160
+ }
161
+ function adopt(slot, parent, marker, value) {
162
+ const claimed = hydration.current.claim(
163
+ parent,
164
+ marker
165
+ );
166
+ if (claimed === null) {
167
+ return false;
168
+ }
169
+ if (typeof value === "object" && value !== null && isDynamicChild(value)) {
170
+ slot.last = value;
171
+ hydration.current.keep(
172
+ slot,
173
+ parent,
174
+ value.anchor,
175
+ claimed
176
+ );
177
+ runWithOwner(value.owner, () => {
178
+ insert(parent, value.thunk, value.anchor);
179
+ });
180
+ return true;
181
+ }
182
+ slot.node = claimed.nodes;
183
+ slot.text = claimed.text;
184
+ return false;
185
+ }
186
+
77
187
  // packages/dom/src/internal.ts
78
188
  import { bind } from "@firsthandjs/core";
79
189
  var PROTOCOL_VERSION = 1;
package/dist/internal.js CHANGED
@@ -1 +1 @@
1
- import{c as O,d as g,g as E,h as P,i as T,k as w,l as L,m as M,n as j,o as v,p as A,q as F,r as H,s as I,t as R,u as V,v as B,w as D,x as W,y as _}from"./chunk-E4GAI5XA.js";import{a as p,b as i,c as s,d as a,h as d,j as m,k as f,l as c,m as u,n as x,o as y,p as C,q as N,r as h,s as b,u as S}from"./chunk-P4PXTIUD.js";function k(n,l=!1){let t,o;return()=>{let r=i.current;if(r!==null){o??=r.tag(n);let e=r.adopt(o);if(e!==null)return e}if(t===void 0){let e=document.createElement("template");e.innerHTML=n,t=l?e.content:e.content.firstChild}return t.cloneNode(!0)}}function q(n,...l){let t=n;for(let o=0;o<l.length;o++){let r=t.firstChild;for(let e=l[o];e>0;e--)r=r.nextSibling;t=r}return t}import{bind as oe}from"@firsthandjs/core";var Q=1;export{O as COMPONENT,Q as PROTOCOL_VERSION,g as VIEW,b as applyChild,B as applyProp,oe as bind,C as cell,x as close,T as createComponent,s as first,h as insert,E as isComponent,p as label,w as list,W as mergeProps,a as next,M as off,L as on,u as open,d as part,q as path,y as ran,S as reconcile,_ as rest,j as setAttribute,v as setAttributeNS,F as setBoolean,H as setClass,I as setClassList,A as setProperty,R as setStyle,V as setStyleObject,c as site,D as spread,m as store,k as template,P as view,N as writeChild,f as wrote};
1
+ import{c as h,d as b,g as N,h as C,i as O,k as T,l as k,m as j,n as E,o as P,p as F,q as H,r as L,s as M,t as R,u as A,v as D,w as I,x as V,y as W}from"./chunk-MWEKNBIC.js";import{a as x,b as l,c as w,d as y,e as S,i as g,j as a,k as f,l as s}from"./chunk-467WEPXM.js";function q(e,i=!1){let r,n;return()=>{let o=l.current;if(o!==null){n??=o.tag(e);let t=o.adopt(n);if(t!==null)return t}if(r===void 0){let t=document.createElement("template");t.innerHTML=e,r=i?t.content:t.content.firstChild}return r.cloneNode(!0)}}function B(e,...i){let r=e;for(let n=0;n<i.length;n++){let o=r.firstChild;for(let t=i[n];t>0;t--)o=o.nextSibling;r=o}return r}import{createOwner as _,disposeOwner as z,getOwner as G,runWithOwner as J,setOwner as m,signal as K}from"@firsthandjs/core";function Q(e=""){return{slots:[],owner:G(),generation:0,name:e}}function d(e){e.busy=!0}function p(e,i){let r=e.slots[i];if(r!==void 0)return r.seen=e.generation,r;let n={seen:e.generation};return e.slots[i]=n,n}function U(e,i){let r=_(e.owner);return i.owner=r,m(r)}function X(e){m(e)}function Y(e,i){let r=e.generation,n=e.slots;for(let o=0;o<n.length;o++){let t=n[o];t===void 0||t.seen===r||(t.owner!==void 0&&z(t.owner),n[o]=void 0)}return e.generation=r+1,i}function Z(e,i,r){let n=p(e,i),o=n.cell;if(o===void 0){let t=K(r);return n.cell=t,t}return o.peek()!==r&&(d(e),o.value=r),o}function $(e,i,r,n,o){let t=p(e,i);if(t.node===void 0&&l.current!==null&&v(t,r,n,o))return;let c=typeof o;if(c==="string"||c==="number"){let u=String(o);if(u===t.text)return;d(e),t.text=u,t.node=s(r,n,t.node??null,u);return}t.text=void 0,o!==t.last&&(d(e),t.last=o,t.node=s(r,n,t.node??null,o))}function v(e,i,r,n){let o=l.current.claim(i,r);return o===null?!1:typeof n=="object"&&n!==null&&a(n)?(e.last=n,l.current.keep(e,i,n.anchor,o),J(n.owner,()=>{f(i,n.thunk,n.anchor)}),!0):(e.node=o.nodes,e.text=o.text,!1)}import{bind as Ne}from"@firsthandjs/core";var pe=1;export{h as COMPONENT,pe as PROTOCOL_VERSION,b as VIEW,s as applyChild,D as applyProp,Ne as bind,Z as cell,X as close,O as createComponent,w as first,f as insert,N as isComponent,x as label,T as list,V as mergeProps,y as next,j as off,k as on,U as open,g as part,B as path,Y as ran,S as reconcile,W as rest,E as setAttribute,P as setAttributeNS,H as setBoolean,L as setClass,M as setClassList,F as setProperty,R as setStyle,A as setStyleObject,p as site,I as spread,Q as store,q as template,C as view,$ as writeChild,d as wrote};
@@ -1 +1 @@
1
- {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../src/list.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,KAAK,YAAY,EAElB,MAAM,mBAAmB,CAAC;AAmC3B;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,IAAI,CAAC,CAAC,EACpB,IAAI,EAAE,MAAM,SAAS,CAAC,EAAE,EACxB,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,EAC1C,MAAM,EAAE,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,CAAC,MAAM,CAAC,KAAK,OAAO,GACtE,MAAM,IAAI,EAAE,CA2Gd"}
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../src/list.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,KAAK,YAAY,EAElB,MAAM,mBAAmB,CAAC;AAmC3B;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,IAAI,CAAC,CAAC,EACpB,IAAI,EAAE,MAAM,SAAS,CAAC,EAAE,EACxB,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,EAC1C,MAAM,EAAE,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,CAAC,MAAM,CAAC,KAAK,OAAO,GACtE,MAAM,IAAI,EAAE,CAyDd"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Putting nodes where they belong, and taking them away again.
3
+ *
4
+ * The four calls every child position eventually makes, with the measured
5
+ * reasons each one is shaped the way it is. Nothing here knows what a part is
6
+ * or what a run is: it is given a slot's current contents and a node, and it
7
+ * performs the mutation.
8
+ */
9
+ /** What a child part currently owns in the DOM. */
10
+ export type ChildSlot = Node | Node[] | null;
11
+ export declare const TEXT_NODE = 3;
12
+ export declare function isNode(value: object): value is Node;
13
+ /**
14
+ * Removes a node from wherever it currently is.
15
+ *
16
+ * Usually that is `parent`, but a node can legitimately have been moved — an
17
+ * element host relocated in the document, for instance — and disposal must
18
+ * still clean up rather than throw.
19
+ */
20
+ export declare function detach(node: Node): void;
21
+ /**
22
+ * Empties a child slot that is everything its parent has.
23
+ *
24
+ * Removing ten thousand rows one at a time is ten thousand mutations, each one
25
+ * a chance for the engine to do bookkeeping it is about to throw away. When
26
+ * the slot *is* the parent's content — no marker after it, nothing beside it —
27
+ * the platform has one call that says so, and it is what clearing a table
28
+ * actually costs: `removeChild` was 85 % of that scenario before this.
29
+ *
30
+ * Falls back to removing them one by one whenever the slot is anything less
31
+ * than the whole, including when a node has been moved out from under it.
32
+ */
33
+ export declare function clearIn(parent: Node, marker: Node | null, current: ChildSlot): null;
34
+ export declare function clear(current: ChildSlot): null;
35
+ export declare function single(parent: Node, marker: Node | null, current: ChildSlot, node: Node): Node;
36
+ //# sourceMappingURL=nodes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../src/nodes.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,mDAAmD;AACnD,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;AAE7C,eAAO,MAAM,SAAS,IAAI,CAAC;AAE3B,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,IAAI,CAEnD;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAKvC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,GAAG,IAAI,EAAE,OAAO,EAAE,SAAS,GAAG,IAAI,CAWnF;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,SAAS,GAAG,IAAI,CAW9C;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,GAAG,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAW9F"}
@@ -1 +1 @@
1
- {"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../src/props.ts"],"names":[],"mappings":"AAUA;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CA8C3E;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAa5E;AAED,+CAA+C;AAC/C,wBAAgB,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAM1E;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAazF;AAED;;;;;;;GAOG;AACH,wBAAgB,IAAI,CAClB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,IAAI,EAAE,SAAS,MAAM,EAAE,GACtB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAWzB"}
1
+ {"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../src/props.ts"],"names":[],"mappings":"AAUA;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CA8B3E;AA+BD;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAa5E;AAED,+CAA+C;AAC/C,wBAAgB,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAM1E;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAazF;AAED;;;;;;;GAOG;AACH,wBAAgB,IAAI,CAClB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,IAAI,EAAE,SAAS,MAAM,EAAE,GACtB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAWzB"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Two node lists, made the same in the fewest moves (ADR-0010).
3
+ *
4
+ * Its own module because it is its own algorithm and its own decision: which
5
+ * reconciler this is was settled by measurement, the comparison is published
6
+ * in `benchmarks/results/reconcilers.json`, and changing it means running that
7
+ * comparison again rather than reading the code around it.
8
+ */
9
+ /**
10
+ * Reconciles two node lists in place, by node identity.
11
+ *
12
+ * Keyed lists reuse their rows' DOM nodes across reorders, so identity is
13
+ * exactly the right key here: a row that survived is the same node, and only
14
+ * nodes that genuinely moved are touched.
15
+ *
16
+ * The algorithm is a common-prefix/suffix trim, then a longest-increasing-
17
+ * subsequence over the surviving nodes, moving only the ones outside it — the
18
+ * provably minimal number of `insertBefore` calls.
19
+ *
20
+ * This is the outcome of the comparison ADR-0010 required, not an assumption:
21
+ * three candidates were measured over ten operations at two sizes, with the
22
+ * order rotated per repetition and correctness asserted on every run. LIS came
23
+ * out ahead overall (1.02 against 1.17 for the two-ended scan and 1.49 for the
24
+ * naive baseline) and decisively where moves are few and far apart — a swap at
25
+ * 10 000 rows costs it 2 moves instead of 9 997. It loses one case: a full
26
+ * reverse, where the subsequence is length 1 and the analysis buys nothing.
27
+ * That trade is published in `benchmarks/results/reconcilers.json`.
28
+ */
29
+ export declare function reconcile(parent: Node, marker: Node | null, a: Node[], b: Node[]): void;
30
+ //# sourceMappingURL=reconcile.d.ts.map