@firsthandjs/dom 0.9.0 → 0.10.0
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/dist/chunk-467WEPXM.js +1 -0
- package/dist/chunk-J5525WK6.js +1 -0
- package/dist/{chunk-26MSEGYG.js → chunk-YX6HJXS6.js} +1 -1
- package/dist/claim.d.ts +10 -0
- package/dist/claim.d.ts.map +1 -1
- package/dist/{dev-chunk-5QV3XALZ.js → dev-chunk-KJHYMOKB.js} +1 -1
- package/dist/{dev-chunk-HCAUM4JK.js → dev-chunk-O5KFGWVZ.js} +160 -63
- package/dist/{dev-chunk-HTXIHAW7.js → dev-chunk-U46CIJCO.js} +242 -308
- package/dist/hydrate.d.ts +11 -0
- package/dist/hydrate.d.ts.map +1 -1
- package/dist/hydrate.dev.js +36 -25
- package/dist/hydrate.js +1 -1
- package/dist/index.dev.js +3 -3
- package/dist/index.js +1 -1
- package/dist/insert.d.ts +58 -108
- package/dist/insert.d.ts.map +1 -1
- package/dist/internal.d.ts +5 -2
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.dev.js +121 -11
- package/dist/internal.js +1 -1
- package/dist/list.d.ts.map +1 -1
- package/dist/nodes.d.ts +36 -0
- package/dist/nodes.d.ts.map +1 -0
- package/dist/props.d.ts.map +1 -1
- package/dist/reconcile.d.ts +30 -0
- package/dist/reconcile.d.ts.map +1 -0
- package/dist/store.d.ts +105 -0
- package/dist/store.d.ts.map +1 -0
- package/package.json +2 -2
- package/dist/chunk-NNHZJMZS.js +0 -1
- package/dist/chunk-TZRPGQ3R.js +0 -1
package/dist/hydrate.dev.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
mount
|
|
3
|
-
} from "./dev-chunk-
|
|
3
|
+
} from "./dev-chunk-KJHYMOKB.js";
|
|
4
4
|
import {
|
|
5
5
|
hydration
|
|
6
|
-
} from "./dev-chunk-
|
|
6
|
+
} from "./dev-chunk-U46CIJCO.js";
|
|
7
7
|
|
|
8
8
|
// packages/dom/src/hydrate.ts
|
|
9
9
|
var COMMENT_NODE = 8;
|
|
@@ -65,43 +65,53 @@ 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
|
|
85
|
-
} else if (fromTheTop) {
|
|
86
|
-
start = node;
|
|
87
|
-
end = marker;
|
|
88
|
-
} else {
|
|
89
|
-
return null;
|
|
103
|
+
return { start: open.nextSibling, end };
|
|
90
104
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
start = null;
|
|
105
|
+
if (fromTheTop) {
|
|
106
|
+
return { start: node, end: marker };
|
|
94
107
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
text: only !== null && only.nodeType === TEXT_NODE ? only.data : void 0,
|
|
103
|
-
region: { node: start, end }
|
|
104
|
-
};
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
function place(anchor) {
|
|
111
|
+
const node = claim === null ? null : claim.node;
|
|
112
|
+
const parent = node?.parentNode ?? null;
|
|
113
|
+
parent?.insertBefore(anchor, node);
|
|
114
|
+
return parent;
|
|
105
115
|
}
|
|
106
116
|
function within(region, body) {
|
|
107
117
|
const outer = claim;
|
|
@@ -143,11 +153,12 @@ function keep(slot, parent, anchor, claimed) {
|
|
|
143
153
|
slot.node = claimed.nodes === null ? anchor : [...Array.isArray(claimed.nodes) ? claimed.nodes : [claimed.nodes], anchor];
|
|
144
154
|
offers.set(anchor, claimed);
|
|
145
155
|
}
|
|
146
|
-
var claimer = { tag: tagOf, adopt, claim: claimRegion, within, keep, step };
|
|
156
|
+
var claimer = { tag: tagOf, adopt, claim: claimRegion, within, keep, step, place };
|
|
147
157
|
export {
|
|
148
158
|
adopt,
|
|
149
159
|
claimRegion,
|
|
150
160
|
hydrate,
|
|
151
161
|
hydrateWith,
|
|
162
|
+
place,
|
|
152
163
|
within
|
|
153
164
|
};
|
package/dist/hydrate.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as
|
|
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.dev.js
CHANGED
|
@@ -10,11 +10,11 @@ import {
|
|
|
10
10
|
setComponentAdapter,
|
|
11
11
|
setElementPrefix,
|
|
12
12
|
view
|
|
13
|
-
} from "./dev-chunk-
|
|
13
|
+
} from "./dev-chunk-O5KFGWVZ.js";
|
|
14
14
|
import {
|
|
15
15
|
render
|
|
16
|
-
} from "./dev-chunk-
|
|
17
|
-
import "./dev-chunk-
|
|
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-
|
|
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-J5525WK6.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 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};
|
package/dist/insert.d.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
4
|
-
export type ChildSlot
|
|
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
|
*
|
|
@@ -21,6 +28,16 @@ declare const PART: unique symbol;
|
|
|
21
28
|
* allocation and ten thousand steps for a list of ten thousand rows.
|
|
22
29
|
*/
|
|
23
30
|
export declare const FLAT: unique symbol;
|
|
31
|
+
/**
|
|
32
|
+
* What a keyed list still has to do once its nodes are in the document.
|
|
33
|
+
*
|
|
34
|
+
* A row whose component handed back a render function is a part like any
|
|
35
|
+
* other, and a part cannot be bound where it is made: the list has an array,
|
|
36
|
+
* not a place in the document. So the list puts the row's anchor among its
|
|
37
|
+
* nodes and leaves the binding here, to be run with the parent that was
|
|
38
|
+
* missing — the same two steps `flatten` takes for a fragment's children.
|
|
39
|
+
*/
|
|
40
|
+
export declare const PENDING: unique symbol;
|
|
24
41
|
/**
|
|
25
42
|
* A dynamic child inside an array, carrying the scope it was written in.
|
|
26
43
|
*
|
|
@@ -43,89 +60,34 @@ export type DynamicChild = {
|
|
|
43
60
|
};
|
|
44
61
|
/** Marks a dynamic child of a fragment. Emitted by the compiler. */
|
|
45
62
|
export declare function part(thunk: () => unknown): DynamicChild;
|
|
63
|
+
export declare function isDynamicChild(value: object): value is DynamicChild;
|
|
46
64
|
/**
|
|
47
|
-
*
|
|
65
|
+
* What only the runtime passes, and the compiler never does.
|
|
48
66
|
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
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.
|
|
53
72
|
*/
|
|
54
|
-
export type
|
|
55
|
-
/**
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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;
|
|
67
90
|
};
|
|
68
|
-
/**
|
|
69
|
-
* Where a run keeps its sites.
|
|
70
|
-
*
|
|
71
|
-
* One per instance, made in the setup — which runs once, so there is nothing
|
|
72
|
-
* to look up and nothing ambient. What a site makes belongs to `owner`, the
|
|
73
|
-
* component's own, rather than to the run that happened to make it: a run's
|
|
74
|
-
* scope is cleared before it runs again, and anything left there would be
|
|
75
|
-
* disposed by the second run.
|
|
76
|
-
*/
|
|
77
|
-
export type Store = {
|
|
78
|
-
slots: (Slot | undefined)[];
|
|
79
|
-
owner: Owner | null;
|
|
80
|
-
/** Which run is in progress, so that what it did not reach can be found. */
|
|
81
|
-
generation: number;
|
|
82
|
-
/** The component this belongs to, for what development has to say about it. */
|
|
83
|
-
name: string;
|
|
84
|
-
/** Whether this run has changed anything. Development only. */
|
|
85
|
-
busy?: boolean;
|
|
86
|
-
/** How many runs in a row have changed nothing. Development only. */
|
|
87
|
-
quiet?: number;
|
|
88
|
-
};
|
|
89
|
-
/** Declared once per instance by the compiler, in the setup. */
|
|
90
|
-
export declare function store(name?: string): Store;
|
|
91
|
-
/** Notes that this run has actually changed something. */
|
|
92
|
-
export declare function wrote(store: Store): void;
|
|
93
|
-
/** The record for one site, made the first time a run reaches it. */
|
|
94
|
-
export declare function site(store: Store, index: number): Slot;
|
|
95
|
-
/**
|
|
96
|
-
* Opens a site: what it makes now belongs to the instance, not to this run.
|
|
97
|
-
*
|
|
98
|
-
* Returns the owner to restore, which the compiler hands back to `close`.
|
|
99
|
-
*/
|
|
100
|
-
export declare function open(store: Store, slot: Slot): Owner | null;
|
|
101
|
-
export declare function close(previous: Owner | null): void;
|
|
102
|
-
/**
|
|
103
|
-
* Ends a run, and disposes what it did not reach.
|
|
104
|
-
*
|
|
105
|
-
* A branch the run has left is gone, not hidden: its components run their
|
|
106
|
-
* cleanups and its parts stop, exactly as if the markup had never been there.
|
|
107
|
-
* Coming back builds it again. That is what the control flow says, so it is
|
|
108
|
-
* what happens.
|
|
109
|
-
*/
|
|
110
|
-
export declare function ran<T>(store: Store, value: T): T;
|
|
111
|
-
/**
|
|
112
|
-
* A prop whose value belongs to the run, as something the child can hold.
|
|
113
|
-
*
|
|
114
|
-
* The child keeps its instance across runs, so its props cannot be getters
|
|
115
|
-
* over the run that made them — that value belongs to one call. It gets a cell
|
|
116
|
-
* instead, made the first time and written afterwards, so a prop that did not
|
|
117
|
-
* change wakes nothing.
|
|
118
|
-
*/
|
|
119
|
-
export declare function cell(store: Store, index: number, value: unknown): Signal<unknown>;
|
|
120
|
-
/**
|
|
121
|
-
* Writes a child position a run owns.
|
|
122
|
-
*
|
|
123
|
-
* The same text twice is not a write: `data` would accept it, and measuring
|
|
124
|
-
* says that comparing a remembered string costs half what setting one does.
|
|
125
|
-
* Anything else goes through `applyChild`, where a node that has not moved is
|
|
126
|
-
* recognised and left where it is.
|
|
127
|
-
*/
|
|
128
|
-
export declare function writeChild(store: Store, index: number, parent: Node, marker: Node | null, value: unknown): void;
|
|
129
91
|
/**
|
|
130
92
|
* Binds a dynamic child position.
|
|
131
93
|
*
|
|
@@ -133,37 +95,25 @@ export declare function writeChild(store: Store, index: number, parent: Node, ma
|
|
|
133
95
|
* The thunk is evaluated once inside a tracking scope; if it read nothing
|
|
134
96
|
* reactive, no effect is retained (ADR-0009).
|
|
135
97
|
*/
|
|
136
|
-
export declare function insert(parent: Node, value: unknown, marker?: Node | 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;
|
|
137
101
|
/**
|
|
138
|
-
*
|
|
102
|
+
* Applies one value to a child slot and returns the slot's new contents.
|
|
139
103
|
*
|
|
140
|
-
* The
|
|
141
|
-
*
|
|
142
|
-
*
|
|
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.
|
|
143
108
|
*/
|
|
144
|
-
seed?: Claimed | null): void;
|
|
145
|
-
/** Applies one value to a child slot and returns the slot's new contents. */
|
|
146
109
|
export declare function applyChild(parent: Node, marker: Node | null, current: ChildSlot, value: unknown): ChildSlot;
|
|
147
110
|
/**
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
* Keyed lists reuse their rows' DOM nodes across reorders, so identity is
|
|
151
|
-
* exactly the right key here: a row that survived is the same node, and only
|
|
152
|
-
* nodes that genuinely moved are touched.
|
|
153
|
-
*
|
|
154
|
-
* The algorithm is a common-prefix/suffix trim, then a longest-increasing-
|
|
155
|
-
* subsequence over the surviving nodes, moving only the ones outside it — the
|
|
156
|
-
* provably minimal number of `insertBefore` calls.
|
|
111
|
+
* Binds parts whose anchors are now in the document.
|
|
157
112
|
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
* naive baseline) and decisively where moves are few and far apart — a swap at
|
|
163
|
-
* 10 000 rows costs it 2 moves instead of 9 997. It loses one case: a full
|
|
164
|
-
* reverse, where the subsequence is length 1 and the analysis buys nothing.
|
|
165
|
-
* That trade is published in `benchmarks/results/reconcilers.json`.
|
|
113
|
+
* Each runs under the owner it was written in, which is what keeps context,
|
|
114
|
+
* disposal and error ownership lexical. A part created outside any scope —
|
|
115
|
+
* runtime JSX at module level, say — is bound under the scope doing the
|
|
116
|
+
* inserting, so that it is still disposed by something rather than by nothing.
|
|
166
117
|
*/
|
|
167
|
-
export declare function
|
|
168
|
-
export {};
|
|
118
|
+
export declare function bindPart(child: DynamicChild, parent: Node, report?: Report): void;
|
|
169
119
|
//# sourceMappingURL=insert.d.ts.map
|
package/dist/insert.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insert.d.ts","sourceRoot":"","sources":["../src/insert.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"insert.d.ts","sourceRoot":"","sources":["../src/insert.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAA2C,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAExF,OAAO,EAAa,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAIrD,OAAO,EAA6C,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAIvF,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAiB5C;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,IAAI,GAAG,IAAI,CAO9C;AAED,QAAA,MAAM,IAAI,EAAE,OAAO,MAAiC,CAAC;AAErD;;;;;;;;GAQG;AACH,eAAO,MAAM,IAAI,EAAE,OAAO,MAAiC,CAAC;AAE5D;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO,EAAE,OAAO,MAAoC,CAAC;AAElE;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,OAAO,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CAC9B,CAAC;AAgBF,oEAAoE;AACpE,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,OAAO,GAAG,YAAY,CAEvD;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,YAAY,CAEnE;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACtB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,MAAM,CACpB,MAAM,EAAE,IAAI,EACZ,KAAK,EAAE,OAAO,EACd,MAAM,GAAE,IAAI,GAAG,IAAW,EAC1B,OAAO,CAAC,EAAE,aAAa,GACtB,IAAI,CA4EN;AAED,yEAAyE;AACzE,MAAM,MAAM,MAAM,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC;AAgD7C;;;;;;;GAOG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,IAAI,EACZ,MAAM,EAAE,IAAI,GAAG,IAAI,EACnB,OAAO,EAAE,SAAS,EAClB,KAAK,EAAE,OAAO,GACb,SAAS,CAuBX;AAyED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAajF"}
|
package/dist/internal.d.ts
CHANGED
|
@@ -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,
|
|
16
|
-
export
|
|
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';
|
package/dist/internal.d.ts.map
CHANGED
|
@@ -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,
|
|
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,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACpF,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC3D,YAAY,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAC9C,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,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,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"}
|
package/dist/internal.dev.js
CHANGED
|
@@ -19,26 +19,21 @@ import {
|
|
|
19
19
|
setStyleObject,
|
|
20
20
|
spread,
|
|
21
21
|
view
|
|
22
|
-
} from "./dev-chunk-
|
|
22
|
+
} from "./dev-chunk-O5KFGWVZ.js";
|
|
23
23
|
import {
|
|
24
24
|
applyChild,
|
|
25
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
site,
|
|
38
|
-
store,
|
|
39
|
-
writeChild,
|
|
40
|
-
wrote
|
|
41
|
-
} from "./dev-chunk-HTXIHAW7.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
|
|
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-J5525WK6.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};
|
package/dist/list.d.ts.map
CHANGED
|
@@ -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;
|
|
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"}
|
package/dist/nodes.d.ts
ADDED
|
@@ -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"}
|
package/dist/props.d.ts.map
CHANGED
|
@@ -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,
|
|
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
|