@solidjs/signals 2.0.0-rc.11 → 2.0.0-rc.14
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/dev-shared.js +2056 -3773
- package/dist/dev.attribution.js +159 -91
- package/dist/dev.js +7263 -8384
- package/dist/observe/affects.js +125 -104
- package/dist/observe/boundaries.js +458 -665
- package/dist/observe/core/action.js +63 -66
- package/dist/observe/core/async.js +240 -383
- package/dist/observe/core/attribution-queries.js +1 -1
- package/dist/observe/core/attribution.js +271 -199
- package/dist/observe/core/constants.js +115 -178
- package/dist/observe/core/context.js +3 -3
- package/dist/observe/core/core.js +840 -1428
- package/dist/observe/core/dev.js +41 -18
- package/dist/observe/core/effect.js +75 -86
- package/dist/observe/core/external.js +5 -5
- package/dist/observe/core/graph.js +61 -70
- package/dist/observe/core/heap.js +75 -98
- package/dist/observe/core/invariants.js +1 -34
- package/dist/observe/core/lanes.js +704 -181
- package/dist/observe/core/owner.js +80 -101
- package/dist/observe/core/scheduler.js +708 -1351
- package/dist/observe/core/verdict.js +302 -621
- package/dist/observe/flatten.js +79 -0
- package/dist/observe/index.js +15 -13
- package/dist/observe/map.js +232 -235
- package/dist/observe/reveal.js +212 -0
- package/dist/observe/signals.js +133 -215
- package/dist/observe/store/affects.js +135 -0
- package/dist/observe/store/index.js +29 -24
- package/dist/observe/store/optimistic.js +538 -0
- package/dist/observe/store/projection.js +302 -0
- package/dist/observe/store/reconcile.js +257 -0
- package/dist/observe/store/store.js +1945 -277
- package/dist/observe/store/storePath.js +1 -1
- package/dist/{prod/store/next → observe/store}/target.js +17 -18
- package/dist/observe/store/types.js +73 -0
- package/dist/observe/store/utils.js +1 -13
- package/dist/prod/affects.js +127 -106
- package/dist/prod/boundaries.js +442 -654
- package/dist/prod/core/action.js +71 -74
- package/dist/prod/core/async.js +307 -442
- package/dist/prod/core/constants.js +112 -177
- package/dist/prod/core/context.js +3 -3
- package/dist/prod/core/core.js +852 -1448
- package/dist/prod/core/effect.js +88 -99
- package/dist/prod/core/external.js +5 -5
- package/dist/prod/core/graph.js +61 -70
- package/dist/prod/core/heap.js +75 -98
- package/dist/prod/core/invariants.js +1 -32
- package/dist/prod/core/lanes.js +666 -181
- package/dist/prod/core/owner.js +75 -96
- package/dist/prod/core/scheduler.js +677 -1332
- package/dist/prod/core/verdict.js +297 -621
- package/dist/prod/flatten.js +77 -0
- package/dist/prod/index.js +15 -13
- package/dist/prod/map.js +143 -146
- package/dist/prod/reveal.js +212 -0
- package/dist/prod/signals.js +144 -226
- package/dist/prod/store/affects.js +135 -0
- package/dist/prod/store/index.js +28 -19
- package/dist/prod/store/optimistic.js +533 -0
- package/dist/prod/store/projection.js +295 -0
- package/dist/prod/store/reconcile.js +257 -0
- package/dist/prod/store/store.js +1840 -272
- package/dist/prod/store/storePath.js +1 -1
- package/dist/{observe/store/next → prod/store}/target.js +13 -17
- package/dist/prod/store/types.js +73 -0
- package/dist/prod/store/utils.js +1 -11
- package/dist/types/affects.d.ts +11 -30
- package/dist/types/boundaries.d.ts +62 -176
- package/dist/types/carved.d.ts +1 -0
- package/dist/types/core/action.d.ts +5 -6
- package/dist/types/core/async.d.ts +10 -5
- package/dist/types/core/attribution-hooks.d.ts +48 -1
- package/dist/types/core/attribution.d.ts +29 -9
- package/dist/types/core/constants.d.ts +125 -171
- package/dist/types/core/core.d.ts +104 -264
- package/dist/types/core/dev.d.ts +60 -7
- package/dist/types/core/effect.d.ts +0 -7
- package/dist/types/core/graph.d.ts +7 -1
- package/dist/types/core/heap.d.ts +5 -7
- package/dist/types/core/index.d.ts +6 -6
- package/dist/types/core/invariants.d.ts +0 -29
- package/dist/types/core/lanes.d.ts +65 -87
- package/dist/types/core/owner.d.ts +3 -3
- package/dist/types/core/scheduler.d.ts +249 -331
- package/dist/types/core/types.d.ts +51 -85
- package/dist/types/core/verdict.d.ts +3 -0
- package/dist/types/flatten.d.ts +8 -0
- package/dist/types/index.d.ts +7 -5
- package/dist/types/reveal.d.ts +19 -0
- package/dist/types/signals.d.ts +53 -92
- package/dist/types/store/affects.d.ts +1 -0
- package/dist/types/store/index.d.ts +35 -15
- package/dist/types/store/optimistic.d.ts +23 -0
- package/dist/types/store/projection.d.ts +18 -0
- package/dist/types/store/reconcile.d.ts +3 -0
- package/dist/types/store/store.d.ts +165 -143
- package/dist/types/store/storePath.d.ts +1 -1
- package/dist/types/store/target.d.ts +151 -0
- package/dist/types/store/types.d.ts +84 -0
- package/package.json +1 -1
- package/dist/observe/core/optimistic.js +0 -669
- package/dist/observe/store/next/optimistic.js +0 -717
- package/dist/observe/store/next/projection.js +0 -266
- package/dist/observe/store/next/reconcile.js +0 -375
- package/dist/observe/store/next/store.js +0 -2480
- package/dist/prod/core/optimistic.js +0 -658
- package/dist/prod/store/next/optimistic.js +0 -710
- package/dist/prod/store/next/projection.js +0 -257
- package/dist/prod/store/next/reconcile.js +0 -373
- package/dist/prod/store/next/store.js +0 -2356
- package/dist/types/core/optimistic.d.ts +0 -6
- package/dist/types/store/next/optimistic.d.ts +0 -25
- package/dist/types/store/next/projection.d.ts +0 -27
- package/dist/types/store/next/reconcile.d.ts +0 -10
- package/dist/types/store/next/store.d.ts +0 -143
- package/dist/types/store/next/target.d.ts +0 -196
package/dist/observe/map.js
CHANGED
|
@@ -1,54 +1,45 @@
|
|
|
1
|
-
import { computed, runWithOwner, signal,
|
|
1
|
+
import { computed, runWithOwner, signal, setSignal } from "./core/core.js";
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import { createOwner } from "./core/owner.js";
|
|
6
|
-
|
|
7
|
-
import { GlobalQueue } from "./core/scheduler.js";
|
|
3
|
+
import "./core/verdict.js";
|
|
8
4
|
|
|
9
5
|
import { CONFIG_AUTO_DISPOSE } from "./core/constants.js";
|
|
10
6
|
|
|
11
7
|
import { attrHooks } from "./core/attribution-hooks.js";
|
|
12
8
|
|
|
13
|
-
import "./core/invariants.js";
|
|
14
|
-
|
|
15
9
|
import "./core/dev.js";
|
|
16
10
|
|
|
17
|
-
import "./core/
|
|
11
|
+
import "./core/scheduler.js";
|
|
12
|
+
|
|
13
|
+
import { createOwner, getOwner } from "./core/owner.js";
|
|
18
14
|
|
|
19
15
|
import "./core/effect.js";
|
|
20
16
|
|
|
21
17
|
import { accessor } from "./signals.js";
|
|
22
18
|
|
|
23
|
-
import { $TRACK } from "./store/
|
|
19
|
+
import { $TRACK } from "./store/types.js";
|
|
24
20
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
function mapArray(t, e, i) {
|
|
28
|
-
const s = typeof i?.keyed === "function" ? i.keyed : undefined;
|
|
21
|
+
function mapArray(t, e, s) {
|
|
22
|
+
const i = typeof s?.keyed === "function" ? s.keyed : undefined;
|
|
29
23
|
const r = e.length > 1;
|
|
30
24
|
const n = e;
|
|
31
25
|
const o = {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
26
|
+
H: createOwner(),
|
|
27
|
+
wt: 0,
|
|
28
|
+
Mt: t,
|
|
29
|
+
$t: [],
|
|
30
|
+
qt: n,
|
|
31
|
+
zt: [],
|
|
32
|
+
nn: [],
|
|
33
|
+
bt: i,
|
|
34
|
+
Jt: i || s?.keyed === false ? [] : undefined,
|
|
35
|
+
Xt: r && s?.keyed !== false ? [] : undefined,
|
|
36
|
+
Yt: s?.keyed === false,
|
|
37
|
+
P: s?.fallback
|
|
44
38
|
};
|
|
45
|
-
const h = computed(updateKeyedMap.bind(o),
|
|
46
|
-
name:
|
|
39
|
+
const h = computed(updateKeyedMap.bind(o), s?.name ? {
|
|
40
|
+
name: s.name
|
|
47
41
|
} : undefined);
|
|
48
|
-
|
|
49
|
-
// them through node lets store-proxy lookups see pending writes (not stale _value).
|
|
50
|
-
o.ie.Yt = h;
|
|
51
|
-
h.C &= ~CONFIG_AUTO_DISPOSE;
|
|
42
|
+
h.u &= ~CONFIG_AUTO_DISPOSE;
|
|
52
43
|
return accessor(h);
|
|
53
44
|
}
|
|
54
45
|
|
|
@@ -56,21 +47,21 @@ const pureOptions = {
|
|
|
56
47
|
ownedWrite: true
|
|
57
48
|
};
|
|
58
49
|
|
|
59
|
-
function trySmallMove(t, e,
|
|
60
|
-
const r = t
|
|
61
|
-
const n = t.
|
|
50
|
+
function trySmallMove(t, e, s, i) {
|
|
51
|
+
const r = t.$t;
|
|
52
|
+
const n = t.wt - 1;
|
|
62
53
|
const o = [];
|
|
63
54
|
const h = [];
|
|
64
55
|
const f = [];
|
|
65
56
|
// flat triples: oldStart, newStart, length
|
|
66
57
|
let c = 256;
|
|
67
|
-
let a =
|
|
68
|
-
let u =
|
|
58
|
+
let a = i;
|
|
59
|
+
let u = i;
|
|
69
60
|
let l = false;
|
|
70
|
-
while (a <= n && u <=
|
|
61
|
+
while (a <= n && u <= s - 1) {
|
|
71
62
|
const t = r[a];
|
|
72
|
-
const
|
|
73
|
-
if (t ===
|
|
63
|
+
const i = e[u];
|
|
64
|
+
if (t === i) {
|
|
74
65
|
if (!l) {
|
|
75
66
|
f.push(a, u, 0);
|
|
76
67
|
l = true;
|
|
@@ -82,30 +73,30 @@ function trySmallMove(t, e, i, s) {
|
|
|
82
73
|
}
|
|
83
74
|
l = false;
|
|
84
75
|
// Bounded realignment lookahead, shorter distance wins.
|
|
85
|
-
let
|
|
86
|
-
let
|
|
87
|
-
for (let t = 1; t <=
|
|
88
|
-
if (r[a + t] ===
|
|
89
|
-
|
|
76
|
+
let d = -1;
|
|
77
|
+
let p = Math.min(32 - o.length, n - a, c);
|
|
78
|
+
for (let t = 1; t <= p; t++) {
|
|
79
|
+
if (r[a + t] === i) {
|
|
80
|
+
d = t;
|
|
90
81
|
break;
|
|
91
82
|
}
|
|
92
83
|
}
|
|
93
|
-
c -=
|
|
94
|
-
let
|
|
95
|
-
|
|
96
|
-
for (let
|
|
97
|
-
if (e[u +
|
|
98
|
-
|
|
84
|
+
c -= d === -1 ? p : d;
|
|
85
|
+
let w = -1;
|
|
86
|
+
p = Math.min(32 - h.length, s - 1 - u, c);
|
|
87
|
+
for (let s = 1; s <= p; s++) {
|
|
88
|
+
if (e[u + s] === t) {
|
|
89
|
+
w = s;
|
|
99
90
|
break;
|
|
100
91
|
}
|
|
101
92
|
}
|
|
102
|
-
c -=
|
|
103
|
-
if (
|
|
104
|
-
while (
|
|
93
|
+
c -= w === -1 ? p : w;
|
|
94
|
+
if (d !== -1 && (w === -1 || d <= w)) {
|
|
95
|
+
while (d-- > 0) o.push(a++);
|
|
105
96
|
continue;
|
|
106
97
|
}
|
|
107
|
-
if (
|
|
108
|
-
while (
|
|
98
|
+
if (w !== -1) {
|
|
99
|
+
while (w-- > 0) h.push(u++);
|
|
109
100
|
continue;
|
|
110
101
|
}
|
|
111
102
|
if (c <= 0 || o.length === 32 || h.length === 32) return false;
|
|
@@ -116,11 +107,11 @@ function trySmallMove(t, e, i, s) {
|
|
|
116
107
|
if (o.length === 32) return false;
|
|
117
108
|
o.push(a);
|
|
118
109
|
}
|
|
119
|
-
for (;u <=
|
|
110
|
+
for (;u <= s - 1; u++) {
|
|
120
111
|
if (h.length === 32) return false;
|
|
121
112
|
h.push(u);
|
|
122
113
|
}
|
|
123
|
-
return commitSmallMove(t, e,
|
|
114
|
+
return commitSmallMove(t, e, s, o, h, f);
|
|
124
115
|
}
|
|
125
116
|
|
|
126
117
|
/** PHASE 2 of the small-move path, in its OWN function so that a pass which
|
|
@@ -129,17 +120,17 @@ function trySmallMove(t, e, i, s) {
|
|
|
129
120
|
* per function, and cold `replace` measured +0.5 ms with both phases in one
|
|
130
121
|
* body. Pairs displaced sources with destinations (an unmatched destination
|
|
131
122
|
* is a replacement/insertion → general path), then commits: slice() the live
|
|
132
|
-
* arrays, copy shifted runs, patch displaced pairs, dispose leftovers. */ function commitSmallMove(t, e,
|
|
133
|
-
const o = t
|
|
123
|
+
* arrays, copy shifted runs, patch displaced pairs, dispose leftovers. */ function commitSmallMove(t, e, s, i, r, n) {
|
|
124
|
+
const o = t.$t;
|
|
134
125
|
let h;
|
|
135
126
|
let f;
|
|
136
127
|
let c;
|
|
137
128
|
if (r.length !== 0) {
|
|
138
|
-
c = new Array(
|
|
129
|
+
c = new Array(i.length);
|
|
139
130
|
for (f = 0; f < r.length; f++) {
|
|
140
131
|
let t = -1;
|
|
141
|
-
for (h = 0; h <
|
|
142
|
-
if (!c[h] && o[
|
|
132
|
+
for (h = 0; h < i.length; h++) {
|
|
133
|
+
if (!c[h] && o[i[h]] === e[r[f]]) {
|
|
143
134
|
t = h;
|
|
144
135
|
break;
|
|
145
136
|
}
|
|
@@ -156,113 +147,120 @@ function trySmallMove(t, e, i, s) {
|
|
|
156
147
|
// and if a displaced identity also occurs inside a run the two algorithms
|
|
157
148
|
// can hand different occurrences different owners (row-local state moves;
|
|
158
149
|
// a shrink could dispose the wrong one). Decline that case — general path.
|
|
159
|
-
if (
|
|
150
|
+
if (i.length !== 0 || r.length !== 0) {
|
|
160
151
|
const t = new Set;
|
|
161
|
-
for (h = 0; h <
|
|
152
|
+
for (h = 0; h < i.length; h++) t.add(o[i[h]]);
|
|
162
153
|
for (f = 0; f < r.length; f++) t.add(e[r[f] >> 6]);
|
|
163
154
|
for (let e = 0; e < n.length; e += 3) {
|
|
164
|
-
const
|
|
165
|
-
for (let
|
|
155
|
+
const s = n[e];
|
|
156
|
+
for (let i = 0, r = n[e + 2]; i < r; i++) if (t.has(o[s + i])) return false;
|
|
166
157
|
}
|
|
167
158
|
}
|
|
168
|
-
const a = t.
|
|
169
|
-
const u = t.
|
|
170
|
-
const l = a.slice(0,
|
|
171
|
-
const
|
|
159
|
+
const a = t.zt;
|
|
160
|
+
const u = t.nn;
|
|
161
|
+
const l = a.slice(0, s);
|
|
162
|
+
const d = u.slice(0, s);
|
|
172
163
|
for (let t = 0; t < n.length; t += 3) {
|
|
173
164
|
const e = n[t];
|
|
174
|
-
const
|
|
175
|
-
if (e !==
|
|
176
|
-
for (let
|
|
177
|
-
l[
|
|
178
|
-
|
|
165
|
+
const s = n[t + 1];
|
|
166
|
+
if (e !== s) {
|
|
167
|
+
for (let i = 0; i < n[t + 2]; i++) {
|
|
168
|
+
l[s + i] = a[e + i];
|
|
169
|
+
d[s + i] = u[e + i];
|
|
179
170
|
}
|
|
180
171
|
}
|
|
181
172
|
}
|
|
182
173
|
for (f = 0; f < r.length; f++) {
|
|
183
174
|
const t = r[f] >> 6;
|
|
184
|
-
const e =
|
|
175
|
+
const e = i[r[f] & 63];
|
|
185
176
|
l[t] = a[e];
|
|
186
|
-
|
|
177
|
+
d[t] = u[e];
|
|
187
178
|
}
|
|
188
|
-
t.
|
|
189
|
-
t.
|
|
190
|
-
t.
|
|
191
|
-
t
|
|
179
|
+
t.zt = l;
|
|
180
|
+
t.nn = d;
|
|
181
|
+
t.wt = s;
|
|
182
|
+
t.$t = e.slice(0);
|
|
192
183
|
// Dispose unmatched sources LAST (general-path ordering).
|
|
193
|
-
for (h = 0; h <
|
|
194
|
-
if (c === undefined || !c[h]) u[
|
|
184
|
+
for (h = 0; h < i.length; h++) {
|
|
185
|
+
if (c === undefined || !c[h]) u[i[h]].dispose();
|
|
195
186
|
}
|
|
196
187
|
return true;
|
|
197
188
|
}
|
|
198
189
|
|
|
199
190
|
function updateKeyedMap() {
|
|
200
|
-
|
|
191
|
+
// Untracked reads inside the internal owner resolve via _parentComputed:
|
|
192
|
+
// routed through the node, a store-proxy lookup sees pending writes (not a
|
|
193
|
+
// stale _value) and an async read in a row callback registers the node as
|
|
194
|
+
// the flight's reader (pending tracking + post-settle retry) instead of
|
|
195
|
+
// vanishing. Set per pass: the first pass runs inside `computed()`, before
|
|
196
|
+
// the node exists to the caller.
|
|
197
|
+
this.H.gt = getOwner();
|
|
198
|
+
const t = this.Mt() || [], e = t.length;
|
|
201
199
|
t[$TRACK];
|
|
202
|
-
// top level tracking
|
|
203
|
-
runWithOwner(this.
|
|
204
|
-
let
|
|
200
|
+
// top level tracking (a store array's container node)
|
|
201
|
+
runWithOwner(this.H, () => {
|
|
202
|
+
let s, i, r, n,
|
|
205
203
|
// Mappers write freshly-created row/index signals into the STAGE
|
|
206
204
|
// arrays (`rows`/`indexes`), never into `this._rows`/`this._indexes`.
|
|
207
|
-
o = this.
|
|
208
|
-
r[
|
|
209
|
-
return this.
|
|
205
|
+
o = this.Jt ? this.Yt ? () => {
|
|
206
|
+
r[i] = signal(t[i], pureOptions);
|
|
207
|
+
return this.qt(accessor(r[i]), i);
|
|
210
208
|
} : () => {
|
|
211
|
-
r[
|
|
212
|
-
n && (n[
|
|
213
|
-
return this.
|
|
214
|
-
} : this.
|
|
215
|
-
const e = t[
|
|
216
|
-
n[
|
|
217
|
-
return this.
|
|
209
|
+
r[i] = signal(t[i], pureOptions);
|
|
210
|
+
n && (n[i] = signal(i, pureOptions));
|
|
211
|
+
return this.qt(accessor(r[i]), n ? accessor(n[i]) : undefined);
|
|
212
|
+
} : this.Xt ? () => {
|
|
213
|
+
const e = t[i];
|
|
214
|
+
n[i] = signal(i, pureOptions);
|
|
215
|
+
return this.qt(e, accessor(n[i]));
|
|
218
216
|
} : () => {
|
|
219
|
-
const e = t[
|
|
220
|
-
return this.
|
|
217
|
+
const e = t[i];
|
|
218
|
+
return this.qt(e);
|
|
221
219
|
};
|
|
222
220
|
// fast path for empty arrays
|
|
223
221
|
if (e === 0) {
|
|
224
|
-
if (this.
|
|
225
|
-
this.
|
|
226
|
-
this.
|
|
227
|
-
this
|
|
228
|
-
this.
|
|
229
|
-
this.
|
|
230
|
-
this.
|
|
231
|
-
this.
|
|
222
|
+
if (this.wt !== 0) {
|
|
223
|
+
this.H.dispose(false);
|
|
224
|
+
this.nn = [];
|
|
225
|
+
this.$t = [];
|
|
226
|
+
this.zt = [];
|
|
227
|
+
this.wt = 0;
|
|
228
|
+
this.Jt && (this.Jt = []);
|
|
229
|
+
this.Xt && (this.Xt = []);
|
|
232
230
|
}
|
|
233
|
-
if (this.
|
|
231
|
+
if (this.P && !this.zt[0]) {
|
|
234
232
|
// an aborted fallback attempt leaves an owner without a mapping;
|
|
235
233
|
// dispose it before re-creating
|
|
236
|
-
this.
|
|
237
|
-
this.
|
|
234
|
+
this.nn[0]?.dispose();
|
|
235
|
+
this.zt[0] = runWithOwner(this.nn[0] = createOwner(), this.P);
|
|
238
236
|
}
|
|
239
237
|
}
|
|
240
238
|
// fast path for new create
|
|
241
|
-
else if (this.
|
|
239
|
+
else if (this.wt === 0) {
|
|
242
240
|
const h = new Array(e);
|
|
243
241
|
const f = new Array(e);
|
|
244
|
-
r = this.
|
|
245
|
-
n = this.
|
|
242
|
+
r = this.Jt && new Array(e);
|
|
243
|
+
n = this.Xt && new Array(e);
|
|
246
244
|
try {
|
|
247
|
-
for (
|
|
245
|
+
for (i = 0; i < e; i++) h[i] = runWithOwner(f[i] = createOwner(), o);
|
|
248
246
|
} catch (t) {
|
|
249
|
-
for (
|
|
247
|
+
for (s = 0; s <= i; s++) f[s]?.dispose();
|
|
250
248
|
throw t;
|
|
251
249
|
}
|
|
252
250
|
// commit
|
|
253
|
-
if (this.
|
|
251
|
+
if (this.nn[0]) this.nn[0].dispose();
|
|
254
252
|
// previous fallback
|
|
255
|
-
this.
|
|
256
|
-
this.
|
|
257
|
-
r && (this.
|
|
258
|
-
n && (this.
|
|
259
|
-
this
|
|
260
|
-
this.
|
|
253
|
+
this.zt = h;
|
|
254
|
+
this.nn = f;
|
|
255
|
+
r && (this.Jt = r);
|
|
256
|
+
n && (this.Xt = n);
|
|
257
|
+
this.$t = t.slice(0);
|
|
258
|
+
this.wt = e;
|
|
261
259
|
} else {
|
|
262
|
-
let h, f, c, a, u, l,
|
|
260
|
+
let h, f, c, a, u, l, d, p, w,
|
|
263
261
|
// Dev (attribution engine installed): the items behind the exited and
|
|
264
262
|
// entered rows, for the list-identity census.
|
|
265
|
-
|
|
263
|
+
m, O;
|
|
266
264
|
// The pass's write to a per-slot signal (a row accessor in index mode,
|
|
267
265
|
// an index accessor in keyed mode). The list's frame lives in these
|
|
268
266
|
// writes as much as in the computed's result, so under a LANE pass they
|
|
@@ -283,20 +281,21 @@ function updateKeyedMap() {
|
|
|
283
281
|
// knows the slots are clean and drops the mark — and an unmarked map
|
|
284
282
|
// takes `setSignal` directly. The engine is installed whenever a lane
|
|
285
283
|
// is active.
|
|
286
|
-
|
|
284
|
+
// CARVE 2: the lane-slot arm (`_landOnOverride`, F1) went with the engine.
|
|
285
|
+
const _ = setSignal;
|
|
287
286
|
// skip common prefix
|
|
288
|
-
for (h = 0, f = Math.min(this.
|
|
289
|
-
if (this.
|
|
287
|
+
for (h = 0, f = Math.min(this.wt, e); h < f && (this.$t[h] === t[h] || this.Jt && compare(this.bt, this.$t[h], t[h])); h++) {
|
|
288
|
+
if (this.Jt) _(this.Jt[h], t[h]);
|
|
290
289
|
}
|
|
291
290
|
// skip common suffix — counted only; retained entries land in one pass
|
|
292
291
|
// at commit instead of being staged and copied twice
|
|
293
|
-
for (f = this.
|
|
292
|
+
for (f = this.wt - 1, c = e - 1; f >= h && c >= h && (this.$t[f] === t[c] || this.Jt && compare(this.bt, this.$t[f], t[c])); f--,
|
|
294
293
|
c--) ;
|
|
295
294
|
// no structural change (every position matched in place at equal
|
|
296
295
|
// length — the common post-reconcile shape): keep the same mapped
|
|
297
296
|
// array identity so downstream consumers don't re-run at all
|
|
298
|
-
if (h === e && this.
|
|
299
|
-
this
|
|
297
|
+
if (h === e && this.wt === e) {
|
|
298
|
+
this.$t = t.slice(0);
|
|
300
299
|
return;
|
|
301
300
|
}
|
|
302
301
|
// SMALL-MOVE FAST PATH: extracted to its own function — inlining it
|
|
@@ -306,103 +305,103 @@ function updateKeyedMap() {
|
|
|
306
305
|
// (plain removals, tail edits), the general path is window-
|
|
307
306
|
// proportional and cheap — the fast path would only re-walk what the
|
|
308
307
|
// trims proved.
|
|
309
|
-
if (e <= this.
|
|
308
|
+
if (e <= this.wt && f - h > 64 && this.Jt === undefined && this.Xt === undefined) {
|
|
310
309
|
// PROBE before the scan: a small move keeps a mid-window item within
|
|
311
310
|
// ±32 of its old position; a REPLACE (all fresh items — the shape
|
|
312
311
|
// every page's first structural pass usually is) has it nowhere.
|
|
313
312
|
// ~65 compares, no allocation, and the scan function is never
|
|
314
313
|
// compiled for a replace (its cold first-call compile was the cost).
|
|
315
|
-
const
|
|
316
|
-
const
|
|
317
|
-
const r = Math.min(f,
|
|
318
|
-
let n = Math.max(h,
|
|
319
|
-
while (n <= r && this
|
|
314
|
+
const s = h + (c - h >> 1);
|
|
315
|
+
const i = t[s];
|
|
316
|
+
const r = Math.min(f, s + 32);
|
|
317
|
+
let n = Math.max(h, s - 32);
|
|
318
|
+
while (n <= r && this.$t[n] !== i) n++;
|
|
320
319
|
if (n <= r && trySmallMove(this, t, e, h)) return;
|
|
321
320
|
}
|
|
322
|
-
const y = e - this.
|
|
321
|
+
const y = e - this.wt;
|
|
323
322
|
const A = new Array(e);
|
|
324
323
|
const M = new Array(e);
|
|
325
|
-
r = this.
|
|
326
|
-
n = this.
|
|
324
|
+
r = this.Jt ? new Array(e) : undefined;
|
|
325
|
+
n = this.Xt ? new Array(e) : undefined;
|
|
327
326
|
// 0) prepare a map of all indices in the changed window of newItems,
|
|
328
327
|
// scanning backwards so we encounter them in natural order
|
|
329
328
|
l = new Map;
|
|
330
|
-
|
|
331
|
-
for (
|
|
332
|
-
a = t[
|
|
333
|
-
u = this.
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
l.set(u,
|
|
329
|
+
d = new Array(c + 1);
|
|
330
|
+
for (i = c; i >= h; i--) {
|
|
331
|
+
a = t[i];
|
|
332
|
+
u = this.bt ? this.bt(a) : a;
|
|
333
|
+
s = l.get(u);
|
|
334
|
+
d[i] = s === undefined ? -1 : s;
|
|
335
|
+
l.set(u, i);
|
|
337
336
|
}
|
|
338
337
|
// 1) step through the old changed window and see if items can be found
|
|
339
338
|
// in the new set; if so, stage them at their new positions; if not,
|
|
340
339
|
// queue them for disposal at commit
|
|
341
|
-
for (
|
|
342
|
-
a = this
|
|
343
|
-
u = this.
|
|
344
|
-
|
|
345
|
-
if (
|
|
346
|
-
A[
|
|
347
|
-
M[
|
|
348
|
-
r && (r[
|
|
349
|
-
n && (n[
|
|
350
|
-
|
|
351
|
-
l.set(u,
|
|
340
|
+
for (s = h; s <= f; s++) {
|
|
341
|
+
a = this.$t[s];
|
|
342
|
+
u = this.bt ? this.bt(a) : a;
|
|
343
|
+
i = l.get(u);
|
|
344
|
+
if (i !== undefined && i !== -1) {
|
|
345
|
+
A[i] = this.zt[s];
|
|
346
|
+
M[i] = this.nn[s];
|
|
347
|
+
r && (r[i] = this.Jt[s]);
|
|
348
|
+
n && (n[i] = this.Xt[s]);
|
|
349
|
+
i = d[i];
|
|
350
|
+
l.set(u, i);
|
|
352
351
|
} else {
|
|
353
|
-
(
|
|
354
|
-
if (true && attrHooks !== null) (
|
|
352
|
+
(p ??= []).push(this.nn[s]);
|
|
353
|
+
if (true && attrHooks !== null) (m ??= []).push(a);
|
|
355
354
|
}
|
|
356
355
|
}
|
|
357
356
|
// 2) create new rows into the temp arrays; an abort disposes only these
|
|
358
357
|
try {
|
|
359
|
-
for (
|
|
360
|
-
if (M[
|
|
361
|
-
(
|
|
362
|
-
if (true && attrHooks !== null) (O ??= []).push(t[
|
|
363
|
-
A[
|
|
358
|
+
for (i = h; i <= c; i++) {
|
|
359
|
+
if (M[i] !== undefined) continue;
|
|
360
|
+
(w ??= []).push(M[i] = createOwner());
|
|
361
|
+
if (true && attrHooks !== null) (O ??= []).push(t[i]);
|
|
362
|
+
A[i] = runWithOwner(M[i], o);
|
|
364
363
|
}
|
|
365
364
|
} catch (t) {
|
|
366
|
-
if (
|
|
365
|
+
if (w) for (s = 0; s < w.length; s++) w[s].dispose();
|
|
367
366
|
throw t;
|
|
368
367
|
}
|
|
369
368
|
// 3) commit: land the retained prefix and suffix plus the staged window
|
|
370
369
|
// into the fresh arrays, swap them in (new identity for downstream
|
|
371
370
|
// change propagation), then dispose exited rows
|
|
372
|
-
for (
|
|
373
|
-
A[
|
|
374
|
-
M[
|
|
375
|
-
r && (r[
|
|
376
|
-
n && (n[
|
|
371
|
+
for (s = 0; s < h; s++) {
|
|
372
|
+
A[s] = this.zt[s];
|
|
373
|
+
M[s] = this.nn[s];
|
|
374
|
+
r && (r[s] = this.Jt[s]);
|
|
375
|
+
n && (n[s] = this.Xt[s]);
|
|
377
376
|
}
|
|
378
|
-
for (
|
|
379
|
-
if (r) _(r[
|
|
380
|
-
if (n) _(n[
|
|
377
|
+
for (i = h; i <= c; i++) {
|
|
378
|
+
if (r) _(r[i], t[i]);
|
|
379
|
+
if (n) _(n[i], i);
|
|
381
380
|
}
|
|
382
|
-
for (
|
|
383
|
-
A[
|
|
384
|
-
M[
|
|
381
|
+
for (i = c + 1; i < e; i++) {
|
|
382
|
+
A[i] = this.zt[i - y];
|
|
383
|
+
M[i] = this.nn[i - y];
|
|
385
384
|
if (r) {
|
|
386
|
-
r[
|
|
387
|
-
_(r[
|
|
385
|
+
r[i] = this.Jt[i - y];
|
|
386
|
+
_(r[i], t[i]);
|
|
388
387
|
}
|
|
389
388
|
if (n) {
|
|
390
|
-
n[
|
|
391
|
-
if (y !== 0) _(n[
|
|
389
|
+
n[i] = this.Xt[i - y];
|
|
390
|
+
if (y !== 0) _(n[i], i);
|
|
392
391
|
}
|
|
393
392
|
}
|
|
394
|
-
this.
|
|
395
|
-
this.
|
|
396
|
-
r && (this.
|
|
397
|
-
n && (this.
|
|
398
|
-
this.
|
|
393
|
+
this.zt = A;
|
|
394
|
+
this.nn = M;
|
|
395
|
+
r && (this.Jt = r);
|
|
396
|
+
n && (this.Xt = n);
|
|
397
|
+
this.wt = e;
|
|
399
398
|
// save a copy of the mapped items for the next update
|
|
400
|
-
this
|
|
401
|
-
if (
|
|
402
|
-
if (true && attrHooks !== null &&
|
|
399
|
+
this.$t = t.slice(0);
|
|
400
|
+
if (p) for (s = 0; s < p.length; s++) p[s].dispose();
|
|
401
|
+
if (true && attrHooks !== null && m !== undefined && O !== undefined) attrHooks.listChurn(this.H.gt, m, O, e, this.bt !== undefined);
|
|
403
402
|
}
|
|
404
403
|
});
|
|
405
|
-
return this.
|
|
404
|
+
return this.zt;
|
|
406
405
|
}
|
|
407
406
|
|
|
408
407
|
/**
|
|
@@ -419,25 +418,21 @@ function updateKeyedMap() {
|
|
|
419
418
|
* ```
|
|
420
419
|
*
|
|
421
420
|
* @description https://docs.solidjs.com/reference/reactive-utilities/repeat
|
|
422
|
-
*/ function repeat(t, e,
|
|
423
|
-
const
|
|
421
|
+
*/ function repeat(t, e, s) {
|
|
422
|
+
const i = e;
|
|
424
423
|
const r = {
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
424
|
+
H: createOwner(),
|
|
425
|
+
wt: 0,
|
|
426
|
+
ts: 0,
|
|
427
|
+
es: t,
|
|
428
|
+
qt: i,
|
|
429
|
+
nn: [],
|
|
430
|
+
zt: [],
|
|
431
|
+
ss: s?.from,
|
|
432
|
+
P: s?.fallback
|
|
434
433
|
};
|
|
435
434
|
const n = computed(updateRepeat.bind(r));
|
|
436
|
-
|
|
437
|
-
// _parentComputed, so async reads in row callbacks register with the node
|
|
438
|
-
// (pending tracking + post-settle retry) instead of vanishing.
|
|
439
|
-
r.ie.Yt = n;
|
|
440
|
-
n.C &= ~CONFIG_AUTO_DISPOSE;
|
|
435
|
+
n.u &= ~CONFIG_AUTO_DISPOSE;
|
|
441
436
|
return accessor(n);
|
|
442
437
|
}
|
|
443
438
|
|
|
@@ -449,59 +444,61 @@ function updateKeyedMap() {
|
|
|
449
444
|
// for the post-settle retry. The overlap math also subsumes the previous
|
|
450
445
|
// disjoint-window/front-clear/end-clear/shift special cases.
|
|
451
446
|
function updateRepeat() {
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
447
|
+
// As in updateKeyedMap: the node is the row callbacks' reader, per pass.
|
|
448
|
+
this.H.gt = getOwner();
|
|
449
|
+
const t = this.es();
|
|
450
|
+
const e = this.ss?.() || 0;
|
|
451
|
+
runWithOwner(this.H, () => {
|
|
455
452
|
if (t === 0) {
|
|
456
|
-
if (this.
|
|
457
|
-
this.
|
|
458
|
-
this.
|
|
459
|
-
this.
|
|
460
|
-
this.
|
|
453
|
+
if (this.wt !== 0) {
|
|
454
|
+
this.H.dispose(false);
|
|
455
|
+
this.nn = [];
|
|
456
|
+
this.zt = [];
|
|
457
|
+
this.wt = 0;
|
|
461
458
|
// Reset offset to match the cleared data (#2767, repro 2).
|
|
462
|
-
this.
|
|
459
|
+
this.ts = 0;
|
|
463
460
|
}
|
|
464
|
-
if (this.
|
|
461
|
+
if (this.P && !this.zt[0]) {
|
|
465
462
|
// an aborted fallback attempt leaves an owner without a mapping;
|
|
466
463
|
// dispose it before re-creating
|
|
467
|
-
this.
|
|
468
|
-
this.
|
|
464
|
+
this.nn[0]?.dispose();
|
|
465
|
+
this.zt[0] = runWithOwner(this.nn[0] = createOwner(), this.P);
|
|
469
466
|
}
|
|
470
467
|
return;
|
|
471
468
|
}
|
|
472
|
-
const
|
|
473
|
-
const
|
|
469
|
+
const s = e + t;
|
|
470
|
+
const i = this.ts + this.wt;
|
|
474
471
|
// Retained overlap [keepStart, keepEnd) in global indexes; empty when the
|
|
475
472
|
// windows are disjoint or when coming from empty/fallback.
|
|
476
|
-
const r = Math.max(e, this.
|
|
477
|
-
const n = Math.min(
|
|
473
|
+
const r = Math.max(e, this.ts);
|
|
474
|
+
const n = Math.min(s, i);
|
|
478
475
|
const o = new Array(t);
|
|
479
476
|
const h = new Array(t);
|
|
480
477
|
for (let t = r; t < n; t++) {
|
|
481
|
-
h[t - e] = this.
|
|
482
|
-
o[t - e] = this.
|
|
478
|
+
h[t - e] = this.nn[t - this.ts];
|
|
479
|
+
o[t - e] = this.zt[t - this.ts];
|
|
483
480
|
}
|
|
484
481
|
try {
|
|
485
|
-
for (let t = e; t <
|
|
482
|
+
for (let t = e; t < s; t++) {
|
|
486
483
|
if (t >= r && t < n) continue;
|
|
487
|
-
o[t - e] = runWithOwner(h[t - e] = createOwner(), () => this.
|
|
484
|
+
o[t - e] = runWithOwner(h[t - e] = createOwner(), () => this.qt(t));
|
|
488
485
|
}
|
|
489
486
|
} catch (t) {
|
|
490
|
-
for (let t = e; t <
|
|
487
|
+
for (let t = e; t < s; t++) if ((t < r || t >= n) && h[t - e]) h[t - e].dispose();
|
|
491
488
|
throw t;
|
|
492
489
|
}
|
|
493
490
|
// commit: dispose the previous fallback or the rows leaving the window
|
|
494
|
-
if (this.
|
|
495
|
-
this.
|
|
496
|
-
this.
|
|
497
|
-
this.
|
|
498
|
-
this.
|
|
491
|
+
if (this.wt === 0) this.nn[0]?.dispose(); else for (let t = this.ts; t < i; t++) if (t < e || t >= s) this.nn[t - this.ts].dispose();
|
|
492
|
+
this.zt = o;
|
|
493
|
+
this.nn = h;
|
|
494
|
+
this.ts = e;
|
|
495
|
+
this.wt = t;
|
|
499
496
|
});
|
|
500
|
-
return this.
|
|
497
|
+
return this.zt;
|
|
501
498
|
}
|
|
502
499
|
|
|
503
|
-
function compare(t, e,
|
|
504
|
-
return t ? t(e) === t(
|
|
500
|
+
function compare(t, e, s) {
|
|
501
|
+
return t ? t(e) === t(s) : true;
|
|
505
502
|
}
|
|
506
503
|
|
|
507
504
|
export { mapArray, repeat };
|