@solidjs/signals 2.0.0-rc.0 → 2.0.0-rc.10
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 +1 -1
- package/dist/dev-shared.js +7138 -0
- package/dist/dev.attribution.js +3307 -0
- package/dist/dev.js +8076 -6692
- package/dist/observe/affects.js +129 -0
- package/dist/observe/attribution.js +7 -0
- package/dist/observe/boundaries.js +793 -0
- package/dist/observe/core/action.js +177 -0
- package/dist/observe/core/async.js +849 -0
- package/dist/observe/core/attribution-costs.js +66 -0
- package/dist/observe/core/attribution-feedback.js +280 -0
- package/dist/observe/core/attribution-hooks.js +83 -0
- package/dist/observe/core/attribution-queries.js +43 -0
- package/dist/observe/core/attribution.js +2904 -0
- package/dist/observe/core/constants.js +283 -0
- package/dist/{types-cjs/core/context.d.cts → observe/core/context.js} +37 -12
- package/dist/observe/core/core.js +1999 -0
- package/dist/observe/core/dev.js +343 -0
- package/dist/observe/core/effect.js +200 -0
- package/dist/observe/core/error-hooks.js +71 -0
- package/dist/observe/core/error.js +80 -0
- package/dist/observe/core/external.js +98 -0
- package/dist/observe/core/graph.js +155 -0
- package/dist/observe/core/heap.js +147 -0
- package/dist/observe/core/invariants.js +45 -0
- package/dist/observe/core/lanes.js +205 -0
- package/dist/observe/core/optimistic.js +627 -0
- package/dist/observe/core/owner.js +353 -0
- package/dist/observe/core/scheduler.js +1547 -0
- package/dist/observe/core/verdict.js +674 -0
- package/dist/observe/index.js +59 -0
- package/dist/observe/map.js +484 -0
- package/dist/observe/signals.js +731 -0
- package/dist/observe/store/index.js +44 -0
- package/dist/observe/store/next/optimistic.js +717 -0
- package/dist/observe/store/next/projection.js +266 -0
- package/dist/observe/store/next/reconcile.js +375 -0
- package/dist/observe/store/next/store.js +2480 -0
- package/dist/observe/store/next/target.js +51 -0
- package/dist/observe/store/store.js +331 -0
- package/dist/observe/store/storePath.js +103 -0
- package/dist/observe/store/utils.js +1070 -0
- package/dist/prod/affects.js +10 -9
- package/dist/prod/attribution.js +45 -0
- package/dist/prod/boundaries.js +388 -178
- package/dist/prod/core/action.js +65 -37
- package/dist/prod/core/async.js +477 -208
- package/dist/prod/core/attribution-hooks.js +3 -0
- package/dist/prod/core/constants.js +186 -1
- package/dist/prod/core/context.js +10 -16
- package/dist/prod/core/core.js +1556 -415
- package/dist/prod/core/dev.js +18 -1
- package/dist/prod/core/effect.js +119 -79
- package/dist/prod/core/error-hooks.js +71 -0
- package/dist/prod/core/error.js +13 -1
- package/dist/prod/core/external.js +4 -4
- package/dist/prod/core/graph.js +105 -54
- package/dist/prod/core/heap.js +72 -65
- package/dist/prod/core/invariants.js +3 -2
- package/dist/prod/core/lanes.js +117 -52
- package/dist/prod/core/optimistic.js +474 -103
- package/dist/prod/core/owner.js +131 -84
- package/dist/prod/core/scheduler.js +1013 -248
- package/dist/prod/core/verdict.js +418 -113
- package/dist/prod/index.js +25 -13
- package/dist/prod/map.js +314 -151
- package/dist/prod/signals.js +382 -32
- package/dist/prod/store/index.js +38 -0
- package/dist/prod/store/next/optimistic.js +710 -0
- package/dist/prod/store/next/projection.js +257 -0
- package/dist/prod/store/next/reconcile.js +373 -0
- package/dist/prod/store/next/store.js +2356 -0
- package/dist/prod/store/next/target.js +51 -0
- package/dist/prod/store/store.js +129 -881
- package/dist/prod/store/utils.js +982 -242
- package/dist/types/attribution.d.ts +19 -0
- package/dist/types/attribution.prod.d.ts +22 -0
- package/dist/types/boundaries.d.ts +78 -5
- package/dist/types/core/action.d.ts +12 -5
- package/dist/types/core/async.d.ts +3 -1
- package/dist/types/core/attribution-costs.d.ts +35 -0
- package/dist/types/core/attribution-feedback.d.ts +133 -0
- package/dist/types/core/attribution-hooks.d.ts +304 -0
- package/dist/types/core/attribution-queries.d.ts +24 -0
- package/dist/types/core/attribution.d.ts +892 -0
- package/dist/types/core/constants.d.ts +179 -0
- package/dist/types/core/core.d.ts +305 -23
- package/dist/types/core/dev.d.ts +421 -8
- package/dist/types/core/effect.d.ts +8 -1
- package/dist/types/core/error-hooks.d.ts +71 -0
- package/dist/types/core/error.d.ts +9 -0
- package/dist/types/core/graph.d.ts +23 -0
- package/dist/types/core/heap.d.ts +5 -3
- package/dist/types/core/index.d.ts +6 -3
- package/dist/types/core/invariants.d.ts +5 -1
- package/dist/types/core/lanes.d.ts +51 -19
- package/dist/types/core/owner.d.ts +15 -3
- package/dist/types/core/scheduler.d.ts +252 -3
- package/dist/types/core/types.d.ts +124 -41
- package/dist/types/index.d.ts +18 -5
- package/dist/types/map.d.ts +2 -0
- package/dist/types/signals.d.ts +164 -13
- package/dist/types/store/index.d.ts +16 -5
- package/dist/types/store/next/optimistic.d.ts +25 -0
- package/dist/types/store/next/projection.d.ts +27 -0
- package/dist/types/store/next/reconcile.d.ts +10 -0
- package/dist/types/store/next/store.d.ts +143 -0
- package/dist/types/store/next/target.d.ts +196 -0
- package/dist/types/store/store.d.ts +46 -112
- package/dist/types/store/utils.d.ts +188 -40
- package/package.json +32 -26
- package/dist/node.cjs +0 -7938
- package/dist/prod/store/optimistic.js +0 -217
- package/dist/prod/store/projection.js +0 -231
- package/dist/prod/store/reconcile.js +0 -707
- package/dist/types/store/optimistic.d.ts +0 -45
- package/dist/types/store/projection.d.ts +0 -70
- package/dist/types/store/reconcile.d.ts +0 -46
- package/dist/types-cjs/affects.d.cts +0 -47
- package/dist/types-cjs/boundaries.d.cts +0 -175
- package/dist/types-cjs/core/action.d.cts +0 -64
- package/dist/types-cjs/core/async.d.cts +0 -21
- package/dist/types-cjs/core/constants.d.cts +0 -71
- package/dist/types-cjs/core/core.d.cts +0 -148
- package/dist/types-cjs/core/dev.d.cts +0 -64
- package/dist/types-cjs/core/effect.d.cts +0 -30
- package/dist/types-cjs/core/error.d.cts +0 -47
- package/dist/types-cjs/core/external.d.cts +0 -15
- package/dist/types-cjs/core/graph.d.cts +0 -5
- package/dist/types-cjs/core/heap.d.cts +0 -22
- package/dist/types-cjs/core/index.d.cts +0 -13
- package/dist/types-cjs/core/invariants.d.cts +0 -59
- package/dist/types-cjs/core/lanes.d.cts +0 -56
- package/dist/types-cjs/core/optimistic.d.cts +0 -6
- package/dist/types-cjs/core/owner.d.cts +0 -124
- package/dist/types-cjs/core/scheduler.d.cts +0 -170
- package/dist/types-cjs/core/types.d.cts +0 -148
- package/dist/types-cjs/core/verdict.d.cts +0 -2
- package/dist/types-cjs/index.d.cts +0 -10
- package/dist/types-cjs/map.d.cts +0 -69
- package/dist/types-cjs/package.json +0 -3
- package/dist/types-cjs/signals.d.cts +0 -605
- package/dist/types-cjs/store/index.d.cts +0 -9
- package/dist/types-cjs/store/optimistic.d.cts +0 -45
- package/dist/types-cjs/store/projection.d.cts +0 -70
- package/dist/types-cjs/store/reconcile.d.cts +0 -46
- package/dist/types-cjs/store/store.d.cts +0 -213
- package/dist/types-cjs/store/storePath.d.cts +0 -58
- package/dist/types-cjs/store/utils.d.cts +0 -114
package/dist/prod/map.js
CHANGED
|
@@ -6,6 +6,8 @@ import "./core/scheduler.js";
|
|
|
6
6
|
|
|
7
7
|
import { CONFIG_AUTO_DISPOSE } from "./core/constants.js";
|
|
8
8
|
|
|
9
|
+
import { attrHooks } from "./core/attribution-hooks.js";
|
|
10
|
+
|
|
9
11
|
import "./core/invariants.js";
|
|
10
12
|
|
|
11
13
|
import "./core/verdict.js";
|
|
@@ -16,203 +18,364 @@ import { accessor } from "./signals.js";
|
|
|
16
18
|
|
|
17
19
|
import { $TRACK } from "./store/store.js";
|
|
18
20
|
|
|
21
|
+
import "./store/next/store.js";
|
|
22
|
+
|
|
19
23
|
function mapArray(t, s, i) {
|
|
20
24
|
const e = typeof i?.keyed === "function" ? i.keyed : undefined;
|
|
21
25
|
const r = s.length > 1;
|
|
22
26
|
const n = s;
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
const o = {
|
|
28
|
+
ie: createOwner(),
|
|
29
|
+
wt: 0,
|
|
30
|
+
Ot: t,
|
|
31
|
+
yt: [],
|
|
32
|
+
At: n,
|
|
33
|
+
St: [],
|
|
34
|
+
gt: [],
|
|
35
|
+
Kn: e,
|
|
36
|
+
Mt: e || i?.keyed === false ? [] : undefined,
|
|
37
|
+
jt: r && i?.keyed !== false ? [] : undefined,
|
|
38
|
+
kt: i?.keyed === false,
|
|
39
|
+
Wt: i?.fallback
|
|
36
40
|
};
|
|
37
|
-
const
|
|
41
|
+
const h = computed(updateKeyedMap.bind(o), undefined);
|
|
38
42
|
// Untracked reads inside the internal owner resolve via _parentComputed; routing
|
|
39
43
|
// them through node lets store-proxy lookups see pending writes (not stale _value).
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return accessor(
|
|
44
|
+
o.ie.qn = h;
|
|
45
|
+
h.C &= ~CONFIG_AUTO_DISPOSE;
|
|
46
|
+
return accessor(h);
|
|
43
47
|
}
|
|
44
48
|
|
|
45
49
|
const pureOptions = {
|
|
46
50
|
ownedWrite: true
|
|
47
51
|
};
|
|
48
52
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
//
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
function trySmallMove(t, s, i, e) {
|
|
54
|
+
const r = t.yt;
|
|
55
|
+
const n = t.wt - 1;
|
|
56
|
+
const o = [];
|
|
57
|
+
const h = [];
|
|
58
|
+
const f = [];
|
|
59
|
+
// flat triples: oldStart, newStart, length
|
|
60
|
+
let c = 256;
|
|
61
|
+
let a = e;
|
|
62
|
+
let l = e;
|
|
63
|
+
let u = false;
|
|
64
|
+
while (a <= n && l <= i - 1) {
|
|
65
|
+
const t = r[a];
|
|
66
|
+
const e = s[l];
|
|
67
|
+
if (t === e) {
|
|
68
|
+
if (!u) {
|
|
69
|
+
f.push(a, l, 0);
|
|
70
|
+
u = true;
|
|
71
|
+
}
|
|
72
|
+
f[f.length - 1]++;
|
|
73
|
+
a++;
|
|
74
|
+
l++;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
u = false;
|
|
78
|
+
// Bounded realignment lookahead, shorter distance wins.
|
|
79
|
+
let p = -1;
|
|
80
|
+
let d = Math.min(32 - o.length, n - a, c);
|
|
81
|
+
for (let t = 1; t <= d; t++) {
|
|
82
|
+
if (r[a + t] === e) {
|
|
83
|
+
p = t;
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
c -= p === -1 ? d : p;
|
|
88
|
+
let w = -1;
|
|
89
|
+
d = Math.min(32 - h.length, i - 1 - l, c);
|
|
90
|
+
for (let i = 1; i <= d; i++) {
|
|
91
|
+
if (s[l + i] === t) {
|
|
92
|
+
w = i;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
c -= w === -1 ? d : w;
|
|
97
|
+
if (p !== -1 && (w === -1 || p <= w)) {
|
|
98
|
+
while (p-- > 0) o.push(a++);
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (w !== -1) {
|
|
102
|
+
while (w-- > 0) h.push(l++);
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
if (c <= 0 || o.length === 32 || h.length === 32) return false;
|
|
106
|
+
o.push(a++);
|
|
107
|
+
h.push(l++);
|
|
108
|
+
}
|
|
109
|
+
for (;a <= n; a++) {
|
|
110
|
+
if (o.length === 32) return false;
|
|
111
|
+
o.push(a);
|
|
112
|
+
}
|
|
113
|
+
for (;l <= i - 1; l++) {
|
|
114
|
+
if (h.length === 32) return false;
|
|
115
|
+
h.push(l);
|
|
116
|
+
}
|
|
117
|
+
return commitSmallMove(t, s, i, o, h, f);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** PHASE 2 of the small-move path, in its OWN function so that a pass which
|
|
121
|
+
* only SCANS and bails (a full replace: the first structural pass of a page,
|
|
122
|
+
* typically) compiles nothing but the scan — V8 parses and compiles lazily
|
|
123
|
+
* per function, and cold `replace` measured +0.5 ms with both phases in one
|
|
124
|
+
* body. Pairs displaced sources with destinations (an unmatched destination
|
|
125
|
+
* is a replacement/insertion → general path), then commits: slice() the live
|
|
126
|
+
* arrays, copy shifted runs, patch displaced pairs, dispose leftovers. */ function commitSmallMove(t, s, i, e, r, n) {
|
|
127
|
+
const o = t.yt;
|
|
128
|
+
let h;
|
|
129
|
+
let f;
|
|
130
|
+
let c;
|
|
131
|
+
if (r.length !== 0) {
|
|
132
|
+
c = new Array(e.length);
|
|
133
|
+
for (f = 0; f < r.length; f++) {
|
|
134
|
+
let t = -1;
|
|
135
|
+
for (h = 0; h < e.length; h++) {
|
|
136
|
+
if (!c[h] && o[e[h]] === s[r[f]]) {
|
|
137
|
+
t = h;
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (t === -1) return false;
|
|
142
|
+
c[t] = true;
|
|
143
|
+
r[f] = r[f] << 6 | t;
|
|
144
|
+
// pack pairing (found < 32)
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
// DUPLICATES: the general path pairs equal identities by OCCURRENCE ORDER
|
|
148
|
+
// (the chained index map). Displaced↔displaced pairing above is ascending
|
|
149
|
+
// on both sides, so it agrees; but an aligned run was matched by POSITION,
|
|
150
|
+
// and if a displaced identity also occurs inside a run the two algorithms
|
|
151
|
+
// can hand different occurrences different owners (row-local state moves;
|
|
152
|
+
// a shrink could dispose the wrong one). Decline that case — general path.
|
|
153
|
+
if (e.length !== 0 || r.length !== 0) {
|
|
154
|
+
const t = new Set;
|
|
155
|
+
for (h = 0; h < e.length; h++) t.add(o[e[h]]);
|
|
156
|
+
for (f = 0; f < r.length; f++) t.add(s[r[f] >> 6]);
|
|
157
|
+
for (let s = 0; s < n.length; s += 3) {
|
|
158
|
+
const i = n[s];
|
|
159
|
+
for (let e = 0, r = n[s + 2]; e < r; e++) if (t.has(o[i + e])) return false;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
const a = t.St;
|
|
163
|
+
const l = t.gt;
|
|
164
|
+
const u = a.slice(0, i);
|
|
165
|
+
const p = l.slice(0, i);
|
|
166
|
+
for (let t = 0; t < n.length; t += 3) {
|
|
167
|
+
const s = n[t];
|
|
168
|
+
const i = n[t + 1];
|
|
169
|
+
if (s !== i) {
|
|
170
|
+
for (let e = 0; e < n[t + 2]; e++) {
|
|
171
|
+
u[i + e] = a[s + e];
|
|
172
|
+
p[i + e] = l[s + e];
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
for (f = 0; f < r.length; f++) {
|
|
177
|
+
const t = r[f] >> 6;
|
|
178
|
+
const s = e[r[f] & 63];
|
|
179
|
+
u[t] = a[s];
|
|
180
|
+
p[t] = l[s];
|
|
181
|
+
}
|
|
182
|
+
t.St = u;
|
|
183
|
+
t.gt = p;
|
|
184
|
+
t.wt = i;
|
|
185
|
+
t.yt = s.slice(0);
|
|
186
|
+
// Dispose unmatched sources LAST (general-path ordering).
|
|
187
|
+
for (h = 0; h < e.length; h++) {
|
|
188
|
+
if (c === undefined || !c[h]) l[e[h]].dispose();
|
|
189
|
+
}
|
|
190
|
+
return true;
|
|
191
|
+
}
|
|
192
|
+
|
|
58
193
|
function updateKeyedMap() {
|
|
59
|
-
const t = this.
|
|
194
|
+
const t = this.Ot() || [], s = t.length;
|
|
60
195
|
t[$TRACK];
|
|
61
196
|
// top level tracking
|
|
62
|
-
runWithOwner(this.
|
|
197
|
+
runWithOwner(this.ie, () => {
|
|
63
198
|
let i, e, r, n,
|
|
64
199
|
// Mappers write freshly-created row/index signals into the STAGE
|
|
65
200
|
// arrays (`rows`/`indexes`), never into `this._rows`/`this._indexes`.
|
|
66
|
-
|
|
201
|
+
o = this.Mt ? this.kt ? () => {
|
|
67
202
|
r[e] = signal(t[e], pureOptions);
|
|
68
|
-
return this.
|
|
203
|
+
return this.At(accessor(r[e]), e);
|
|
69
204
|
} : () => {
|
|
70
205
|
r[e] = signal(t[e], pureOptions);
|
|
71
206
|
n && (n[e] = signal(e, pureOptions));
|
|
72
|
-
return this.
|
|
73
|
-
} : this.
|
|
207
|
+
return this.At(accessor(r[e]), n ? accessor(n[e]) : undefined);
|
|
208
|
+
} : this.jt ? () => {
|
|
74
209
|
const s = t[e];
|
|
75
210
|
n[e] = signal(e, pureOptions);
|
|
76
|
-
return this.
|
|
211
|
+
return this.At(s, accessor(n[e]));
|
|
77
212
|
} : () => {
|
|
78
213
|
const s = t[e];
|
|
79
|
-
return this.
|
|
214
|
+
return this.At(s);
|
|
80
215
|
};
|
|
81
216
|
// fast path for empty arrays
|
|
82
217
|
if (s === 0) {
|
|
83
|
-
if (this.
|
|
84
|
-
this.
|
|
85
|
-
this.
|
|
86
|
-
this.
|
|
87
|
-
this.
|
|
88
|
-
this.
|
|
89
|
-
this.
|
|
90
|
-
this.
|
|
218
|
+
if (this.wt !== 0) {
|
|
219
|
+
this.ie.dispose(false);
|
|
220
|
+
this.gt = [];
|
|
221
|
+
this.yt = [];
|
|
222
|
+
this.St = [];
|
|
223
|
+
this.wt = 0;
|
|
224
|
+
this.Mt && (this.Mt = []);
|
|
225
|
+
this.jt && (this.jt = []);
|
|
91
226
|
}
|
|
92
|
-
if (this.
|
|
227
|
+
if (this.Wt && !this.St[0]) {
|
|
93
228
|
// an aborted fallback attempt leaves an owner without a mapping;
|
|
94
229
|
// dispose it before re-creating
|
|
95
|
-
this.
|
|
96
|
-
this.
|
|
230
|
+
this.gt[0]?.dispose();
|
|
231
|
+
this.St[0] = runWithOwner(this.gt[0] = createOwner(), this.Wt);
|
|
97
232
|
}
|
|
98
233
|
}
|
|
99
234
|
// fast path for new create
|
|
100
|
-
else if (this.
|
|
101
|
-
const
|
|
102
|
-
const
|
|
103
|
-
r = this.
|
|
104
|
-
n = this.
|
|
235
|
+
else if (this.wt === 0) {
|
|
236
|
+
const h = new Array(s);
|
|
237
|
+
const f = new Array(s);
|
|
238
|
+
r = this.Mt && new Array(s);
|
|
239
|
+
n = this.jt && new Array(s);
|
|
105
240
|
try {
|
|
106
|
-
for (e = 0; e < s; e++)
|
|
241
|
+
for (e = 0; e < s; e++) h[e] = runWithOwner(f[e] = createOwner(), o);
|
|
107
242
|
} catch (t) {
|
|
108
|
-
for (i = 0; i <= e; i++)
|
|
243
|
+
for (i = 0; i <= e; i++) f[i]?.dispose();
|
|
109
244
|
throw t;
|
|
110
245
|
}
|
|
111
246
|
// commit
|
|
112
|
-
if (this.
|
|
247
|
+
if (this.gt[0]) this.gt[0].dispose();
|
|
113
248
|
// previous fallback
|
|
114
|
-
this.
|
|
115
|
-
this.
|
|
116
|
-
r && (this.
|
|
117
|
-
n && (this.
|
|
118
|
-
this.
|
|
119
|
-
this.
|
|
249
|
+
this.St = h;
|
|
250
|
+
this.gt = f;
|
|
251
|
+
r && (this.Mt = r);
|
|
252
|
+
n && (this.jt = n);
|
|
253
|
+
this.yt = t.slice(0);
|
|
254
|
+
this.wt = s;
|
|
120
255
|
} else {
|
|
121
|
-
let
|
|
256
|
+
let h, f, c, a, l, u, p, d, w,
|
|
257
|
+
// Dev (attribution engine installed): the items behind the exited and
|
|
258
|
+
// entered rows, for the list-identity census.
|
|
259
|
+
m, O;
|
|
122
260
|
// skip common prefix
|
|
123
|
-
for (
|
|
124
|
-
if (this.
|
|
261
|
+
for (h = 0, f = Math.min(this.wt, s); h < f && (this.yt[h] === t[h] || this.Mt && compare(this.Kn, this.yt[h], t[h])); h++) {
|
|
262
|
+
if (this.Mt) setSignal(this.Mt[h], t[h]);
|
|
125
263
|
}
|
|
126
264
|
// skip common suffix — counted only; retained entries land in one pass
|
|
127
265
|
// at commit instead of being staged and copied twice
|
|
128
|
-
for (
|
|
129
|
-
|
|
266
|
+
for (f = this.wt - 1, c = s - 1; f >= h && c >= h && (this.yt[f] === t[c] || this.Mt && compare(this.Kn, this.yt[f], t[c])); f--,
|
|
267
|
+
c--) ;
|
|
130
268
|
// no structural change (every position matched in place at equal
|
|
131
269
|
// length — the common post-reconcile shape): keep the same mapped
|
|
132
270
|
// array identity so downstream consumers don't re-run at all
|
|
133
|
-
if (
|
|
134
|
-
this.
|
|
271
|
+
if (h === s && this.wt === s) {
|
|
272
|
+
this.yt = t.slice(0);
|
|
135
273
|
return;
|
|
136
274
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
275
|
+
// SMALL-MOVE FAST PATH: extracted to its own function — inlining it
|
|
276
|
+
// here bloats updateKeyedMap past the JIT's optimization budget and
|
|
277
|
+
// deoptimizes the GENERAL path (measured 2x on reverse). Gated to
|
|
278
|
+
// LARGE trimmed windows: when the trims already shrank the window
|
|
279
|
+
// (plain removals, tail edits), the general path is window-
|
|
280
|
+
// proportional and cheap — the fast path would only re-walk what the
|
|
281
|
+
// trims proved.
|
|
282
|
+
if (s <= this.wt && f - h > 64 && this.Mt === undefined && this.jt === undefined) {
|
|
283
|
+
// PROBE before the scan: a small move keeps a mid-window item within
|
|
284
|
+
// ±32 of its old position; a REPLACE (all fresh items — the shape
|
|
285
|
+
// every page's first structural pass usually is) has it nowhere.
|
|
286
|
+
// ~65 compares, no allocation, and the scan function is never
|
|
287
|
+
// compiled for a replace (its cold first-call compile was the cost).
|
|
288
|
+
const i = h + (c - h >> 1);
|
|
289
|
+
const e = t[i];
|
|
290
|
+
const r = Math.min(f, i + 32);
|
|
291
|
+
let n = Math.max(h, i - 32);
|
|
292
|
+
while (n <= r && this.yt[n] !== e) n++;
|
|
293
|
+
if (n <= r && trySmallMove(this, t, s, h)) return;
|
|
294
|
+
}
|
|
295
|
+
const _ = s - this.wt;
|
|
296
|
+
const y = new Array(s);
|
|
297
|
+
const A = new Array(s);
|
|
298
|
+
r = this.Mt ? new Array(s) : undefined;
|
|
299
|
+
n = this.jt ? new Array(s) : undefined;
|
|
142
300
|
// 0) prepare a map of all indices in the changed window of newItems,
|
|
143
301
|
// scanning backwards so we encounter them in natural order
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
for (e =
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
i =
|
|
150
|
-
|
|
151
|
-
|
|
302
|
+
u = new Map;
|
|
303
|
+
p = new Array(c + 1);
|
|
304
|
+
for (e = c; e >= h; e--) {
|
|
305
|
+
a = t[e];
|
|
306
|
+
l = this.Kn ? this.Kn(a) : a;
|
|
307
|
+
i = u.get(l);
|
|
308
|
+
p[e] = i === undefined ? -1 : i;
|
|
309
|
+
u.set(l, e);
|
|
152
310
|
}
|
|
153
311
|
// 1) step through the old changed window and see if items can be found
|
|
154
312
|
// in the new set; if so, stage them at their new positions; if not,
|
|
155
313
|
// queue them for disposal at commit
|
|
156
|
-
for (i =
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
e =
|
|
314
|
+
for (i = h; i <= f; i++) {
|
|
315
|
+
a = this.yt[i];
|
|
316
|
+
l = this.Kn ? this.Kn(a) : a;
|
|
317
|
+
e = u.get(l);
|
|
160
318
|
if (e !== undefined && e !== -1) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
r && (r[e] = this.
|
|
164
|
-
n && (n[e] = this.
|
|
165
|
-
e =
|
|
166
|
-
|
|
167
|
-
} else
|
|
319
|
+
y[e] = this.St[i];
|
|
320
|
+
A[e] = this.gt[i];
|
|
321
|
+
r && (r[e] = this.Mt[i]);
|
|
322
|
+
n && (n[e] = this.jt[i]);
|
|
323
|
+
e = p[e];
|
|
324
|
+
u.set(l, e);
|
|
325
|
+
} else {
|
|
326
|
+
(d ??= []).push(this.gt[i]);
|
|
327
|
+
if (false && attrHooks !== null) ;
|
|
328
|
+
}
|
|
168
329
|
}
|
|
169
330
|
// 2) create new rows into the temp arrays; an abort disposes only these
|
|
170
331
|
try {
|
|
171
|
-
for (e =
|
|
172
|
-
if (
|
|
173
|
-
(
|
|
174
|
-
|
|
332
|
+
for (e = h; e <= c; e++) {
|
|
333
|
+
if (A[e] !== undefined) continue;
|
|
334
|
+
(w ??= []).push(A[e] = createOwner());
|
|
335
|
+
if (false && attrHooks !== null) ;
|
|
336
|
+
y[e] = runWithOwner(A[e], o);
|
|
175
337
|
}
|
|
176
338
|
} catch (t) {
|
|
177
|
-
if (
|
|
339
|
+
if (w) for (i = 0; i < w.length; i++) w[i].dispose();
|
|
178
340
|
throw t;
|
|
179
341
|
}
|
|
180
342
|
// 3) commit: land the retained prefix and suffix plus the staged window
|
|
181
343
|
// into the fresh arrays, swap them in (new identity for downstream
|
|
182
344
|
// change propagation), then dispose exited rows
|
|
183
|
-
for (i = 0; i <
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
r && (r[i] = this.
|
|
187
|
-
n && (n[i] = this.
|
|
345
|
+
for (i = 0; i < h; i++) {
|
|
346
|
+
y[i] = this.St[i];
|
|
347
|
+
A[i] = this.gt[i];
|
|
348
|
+
r && (r[i] = this.Mt[i]);
|
|
349
|
+
n && (n[i] = this.jt[i]);
|
|
188
350
|
}
|
|
189
|
-
for (e =
|
|
351
|
+
for (e = h; e <= c; e++) {
|
|
190
352
|
if (r) setSignal(r[e], t[e]);
|
|
191
353
|
if (n) setSignal(n[e], e);
|
|
192
354
|
}
|
|
193
|
-
for (e =
|
|
194
|
-
|
|
195
|
-
|
|
355
|
+
for (e = c + 1; e < s; e++) {
|
|
356
|
+
y[e] = this.St[e - _];
|
|
357
|
+
A[e] = this.gt[e - _];
|
|
196
358
|
if (r) {
|
|
197
|
-
r[e] = this.
|
|
359
|
+
r[e] = this.Mt[e - _];
|
|
198
360
|
setSignal(r[e], t[e]);
|
|
199
361
|
}
|
|
200
362
|
if (n) {
|
|
201
|
-
n[e] = this.
|
|
202
|
-
if (
|
|
363
|
+
n[e] = this.jt[e - _];
|
|
364
|
+
if (_ !== 0) setSignal(n[e], e);
|
|
203
365
|
}
|
|
204
366
|
}
|
|
205
|
-
this.
|
|
206
|
-
this.
|
|
207
|
-
r && (this.
|
|
208
|
-
n && (this.
|
|
209
|
-
this.
|
|
367
|
+
this.St = y;
|
|
368
|
+
this.gt = A;
|
|
369
|
+
r && (this.Mt = r);
|
|
370
|
+
n && (this.jt = n);
|
|
371
|
+
this.wt = s;
|
|
210
372
|
// save a copy of the mapped items for the next update
|
|
211
|
-
this.
|
|
212
|
-
if (
|
|
373
|
+
this.yt = t.slice(0);
|
|
374
|
+
if (d) for (i = 0; i < d.length; i++) d[i].dispose();
|
|
375
|
+
if (false && attrHooks !== null && m !== undefined && O !== undefined) ;
|
|
213
376
|
}
|
|
214
377
|
});
|
|
215
|
-
return this.
|
|
378
|
+
return this.St;
|
|
216
379
|
}
|
|
217
380
|
|
|
218
381
|
/**
|
|
@@ -232,22 +395,22 @@ function updateKeyedMap() {
|
|
|
232
395
|
*/ function repeat(t, s, i) {
|
|
233
396
|
const e = s;
|
|
234
397
|
const r = {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
398
|
+
ie: createOwner(),
|
|
399
|
+
wt: 0,
|
|
400
|
+
bt: 0,
|
|
401
|
+
It: t,
|
|
402
|
+
At: e,
|
|
403
|
+
gt: [],
|
|
404
|
+
St: [],
|
|
405
|
+
vt: i?.from,
|
|
406
|
+
Wt: i?.fallback
|
|
244
407
|
};
|
|
245
408
|
const n = computed(updateRepeat.bind(r));
|
|
246
409
|
// Same as mapArray: untracked reads inside the internal owner resolve via
|
|
247
410
|
// _parentComputed, so async reads in row callbacks register with the node
|
|
248
411
|
// (pending tracking + post-settle retry) instead of vanishing.
|
|
249
|
-
r.
|
|
250
|
-
n.
|
|
412
|
+
r.ie.qn = n;
|
|
413
|
+
n.C &= ~CONFIG_AUTO_DISPOSE;
|
|
251
414
|
return accessor(n);
|
|
252
415
|
}
|
|
253
416
|
|
|
@@ -259,55 +422,55 @@ function updateKeyedMap() {
|
|
|
259
422
|
// for the post-settle retry. The overlap math also subsumes the previous
|
|
260
423
|
// disjoint-window/front-clear/end-clear/shift special cases.
|
|
261
424
|
function updateRepeat() {
|
|
262
|
-
const t = this.
|
|
263
|
-
const s = this.
|
|
264
|
-
runWithOwner(this.
|
|
425
|
+
const t = this.It();
|
|
426
|
+
const s = this.vt?.() || 0;
|
|
427
|
+
runWithOwner(this.ie, () => {
|
|
265
428
|
if (t === 0) {
|
|
266
|
-
if (this.
|
|
267
|
-
this.
|
|
268
|
-
this.
|
|
269
|
-
this.
|
|
270
|
-
this.
|
|
429
|
+
if (this.wt !== 0) {
|
|
430
|
+
this.ie.dispose(false);
|
|
431
|
+
this.gt = [];
|
|
432
|
+
this.St = [];
|
|
433
|
+
this.wt = 0;
|
|
271
434
|
// Reset offset to match the cleared data (#2767, repro 2).
|
|
272
|
-
this.
|
|
435
|
+
this.bt = 0;
|
|
273
436
|
}
|
|
274
|
-
if (this.
|
|
437
|
+
if (this.Wt && !this.St[0]) {
|
|
275
438
|
// an aborted fallback attempt leaves an owner without a mapping;
|
|
276
439
|
// dispose it before re-creating
|
|
277
|
-
this.
|
|
278
|
-
this.
|
|
440
|
+
this.gt[0]?.dispose();
|
|
441
|
+
this.St[0] = runWithOwner(this.gt[0] = createOwner(), this.Wt);
|
|
279
442
|
}
|
|
280
443
|
return;
|
|
281
444
|
}
|
|
282
445
|
const i = s + t;
|
|
283
|
-
const e = this.
|
|
446
|
+
const e = this.bt + this.wt;
|
|
284
447
|
// Retained overlap [keepStart, keepEnd) in global indexes; empty when the
|
|
285
448
|
// windows are disjoint or when coming from empty/fallback.
|
|
286
|
-
const r = Math.max(s, this.
|
|
449
|
+
const r = Math.max(s, this.bt);
|
|
287
450
|
const n = Math.min(i, e);
|
|
288
|
-
const h = new Array(t);
|
|
289
451
|
const o = new Array(t);
|
|
452
|
+
const h = new Array(t);
|
|
290
453
|
for (let t = r; t < n; t++) {
|
|
291
|
-
|
|
292
|
-
|
|
454
|
+
h[t - s] = this.gt[t - this.bt];
|
|
455
|
+
o[t - s] = this.St[t - this.bt];
|
|
293
456
|
}
|
|
294
457
|
try {
|
|
295
458
|
for (let t = s; t < i; t++) {
|
|
296
459
|
if (t >= r && t < n) continue;
|
|
297
|
-
|
|
460
|
+
o[t - s] = runWithOwner(h[t - s] = createOwner(), () => this.At(t));
|
|
298
461
|
}
|
|
299
462
|
} catch (t) {
|
|
300
|
-
for (let t = s; t < i; t++) if ((t < r || t >= n) &&
|
|
463
|
+
for (let t = s; t < i; t++) if ((t < r || t >= n) && h[t - s]) h[t - s].dispose();
|
|
301
464
|
throw t;
|
|
302
465
|
}
|
|
303
466
|
// commit: dispose the previous fallback or the rows leaving the window
|
|
304
|
-
if (this.
|
|
305
|
-
this.
|
|
306
|
-
this.
|
|
307
|
-
this.
|
|
308
|
-
this.
|
|
467
|
+
if (this.wt === 0) this.gt[0]?.dispose(); else for (let t = this.bt; t < e; t++) if (t < s || t >= i) this.gt[t - this.bt].dispose();
|
|
468
|
+
this.St = o;
|
|
469
|
+
this.gt = h;
|
|
470
|
+
this.bt = s;
|
|
471
|
+
this.wt = t;
|
|
309
472
|
});
|
|
310
|
-
return this.
|
|
473
|
+
return this.St;
|
|
311
474
|
}
|
|
312
475
|
|
|
313
476
|
function compare(t, s, i) {
|