@solidjs/signals 2.0.0-beta.13 → 2.0.0-beta.15

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.js CHANGED
@@ -140,107 +140,6 @@ function getObservers(node) {
140
140
  }
141
141
  return observers;
142
142
  }
143
- function actualInsertIntoHeap(n, heap) {
144
- const parentHeight =
145
- (n._parent?._root ? n._parent._parentComputed?._height : n._parent?._height) ?? -1;
146
- if (parentHeight >= n._height) n._height = parentHeight + 1;
147
- const height = n._height;
148
- const heapAtHeight = heap._heap[height];
149
- if (heapAtHeight === undefined) heap._heap[height] = n;
150
- else {
151
- const tail = heapAtHeight._prevHeap;
152
- tail._nextHeap = n;
153
- n._prevHeap = tail;
154
- heapAtHeight._prevHeap = n;
155
- }
156
- if (height > heap._max) heap._max = height;
157
- }
158
- function insertIntoHeap(n, heap) {
159
- let flags = n._flags;
160
- if (flags & (REACTIVE_IN_HEAP | REACTIVE_RECOMPUTING_DEPS | REACTIVE_MANUAL_WRITE)) return;
161
- if (flags & REACTIVE_CHECK) {
162
- n._flags = (flags & -4) | REACTIVE_DIRTY | REACTIVE_IN_HEAP;
163
- } else n._flags = flags | REACTIVE_IN_HEAP;
164
- if (!(flags & REACTIVE_IN_HEAP_HEIGHT)) actualInsertIntoHeap(n, heap);
165
- }
166
- function insertIntoHeapHeight(n, heap) {
167
- let flags = n._flags;
168
- if (
169
- flags &
170
- (REACTIVE_IN_HEAP | REACTIVE_RECOMPUTING_DEPS | REACTIVE_IN_HEAP_HEIGHT | REACTIVE_MANUAL_WRITE)
171
- )
172
- return;
173
- n._flags = flags | REACTIVE_IN_HEAP_HEIGHT;
174
- actualInsertIntoHeap(n, heap);
175
- }
176
- function deleteFromHeap(n, heap) {
177
- const flags = n._flags;
178
- if (!(flags & (REACTIVE_IN_HEAP | REACTIVE_IN_HEAP_HEIGHT))) return;
179
- n._flags = flags & -25;
180
- const height = n._height;
181
- if (n._prevHeap === n) heap._heap[height] = undefined;
182
- else {
183
- const next = n._nextHeap;
184
- const dhh = heap._heap[height];
185
- const end = next ?? dhh;
186
- if (n === dhh) heap._heap[height] = next;
187
- else n._prevHeap._nextHeap = next;
188
- end._prevHeap = n._prevHeap;
189
- }
190
- n._prevHeap = n;
191
- n._nextHeap = undefined;
192
- }
193
- function markHeap(heap) {
194
- if (heap._marked) return;
195
- heap._marked = true;
196
- for (let i = 0; i <= heap._max; i++) {
197
- for (let el = heap._heap[i]; el !== undefined; el = el._nextHeap) {
198
- if (el._flags & REACTIVE_IN_HEAP) markNode(el);
199
- }
200
- }
201
- }
202
- function markNode(el, newState = REACTIVE_DIRTY) {
203
- const flags = el._flags;
204
- if ((flags & (REACTIVE_CHECK | REACTIVE_DIRTY)) >= newState) return;
205
- el._flags = (flags & -4) | newState;
206
- for (let link = el._subs; link !== null; link = link._nextSub) {
207
- markNode(link._sub, REACTIVE_CHECK);
208
- }
209
- if (el._child !== null) {
210
- for (let child = el._child; child !== null; child = child._nextChild) {
211
- for (let link = child._subs; link !== null; link = link._nextSub) {
212
- markNode(link._sub, REACTIVE_CHECK);
213
- }
214
- }
215
- }
216
- }
217
- function runHeap(heap, recompute) {
218
- heap._marked = false;
219
- for (heap._min = 0; heap._min <= heap._max; heap._min++) {
220
- let el = heap._heap[heap._min];
221
- while (el !== undefined) {
222
- if (el._flags & REACTIVE_IN_HEAP) recompute(el);
223
- else adjustHeight(el, heap);
224
- el = heap._heap[heap._min];
225
- }
226
- }
227
- heap._max = 0;
228
- }
229
- function adjustHeight(el, heap) {
230
- deleteFromHeap(el, heap);
231
- let newHeight = el._height;
232
- for (let d = el._deps; d; d = d._nextDep) {
233
- const dep1 = d._dep;
234
- const dep = dep1._firewall || dep1;
235
- if (dep._fn && dep._height >= newHeight) newHeight = dep._height + 1;
236
- }
237
- if (el._height !== newHeight) {
238
- el._height = newHeight;
239
- for (let s = el._subs; s !== null; s = s._nextSub) {
240
- insertIntoHeapHeight(s._sub, heap);
241
- }
242
- }
243
- }
244
143
  const signalLanes = new WeakMap();
245
144
  const activeLanes = new Set();
246
145
  function getOrCreateLane(signal) {
@@ -796,8 +695,11 @@ function flush(fn) {
796
695
  try {
797
696
  return fn();
798
697
  } finally {
799
- flush();
800
- syncDepth--;
698
+ try {
699
+ flush();
700
+ } finally {
701
+ syncDepth--;
702
+ }
801
703
  }
802
704
  }
803
705
  if (globalQueue._running) {
@@ -886,24 +788,127 @@ function runInTransition(transition, fn) {
886
788
  activeTransition = prevTransition;
887
789
  }
888
790
  }
791
+ function actualInsertIntoHeap(n, heap) {
792
+ const parentHeight =
793
+ (n._parent?._root ? n._parent._parentComputed?._height : n._parent?._height) ?? -1;
794
+ if (parentHeight >= n._height) n._height = parentHeight + 1;
795
+ const height = n._height;
796
+ const heapAtHeight = heap._heap[height];
797
+ if (heapAtHeight === undefined) heap._heap[height] = n;
798
+ else {
799
+ const tail = heapAtHeight._prevHeap;
800
+ tail._nextHeap = n;
801
+ n._prevHeap = tail;
802
+ heapAtHeight._prevHeap = n;
803
+ }
804
+ if (height > heap._max) heap._max = height;
805
+ }
806
+ function insertIntoHeap(n, heap) {
807
+ let flags = n._flags;
808
+ if (flags & (REACTIVE_IN_HEAP | REACTIVE_RECOMPUTING_DEPS | REACTIVE_MANUAL_WRITE)) return;
809
+ if (flags & REACTIVE_CHECK) {
810
+ n._flags = (flags & -4) | REACTIVE_DIRTY | REACTIVE_IN_HEAP;
811
+ } else n._flags = flags | REACTIVE_IN_HEAP;
812
+ if (!(flags & REACTIVE_IN_HEAP_HEIGHT)) actualInsertIntoHeap(n, heap);
813
+ }
814
+ function insertIntoHeapHeight(n, heap) {
815
+ let flags = n._flags;
816
+ if (
817
+ flags &
818
+ (REACTIVE_IN_HEAP | REACTIVE_RECOMPUTING_DEPS | REACTIVE_IN_HEAP_HEIGHT | REACTIVE_MANUAL_WRITE)
819
+ )
820
+ return;
821
+ n._flags = flags | REACTIVE_IN_HEAP_HEIGHT;
822
+ actualInsertIntoHeap(n, heap);
823
+ }
824
+ function deleteFromHeap(n, heap) {
825
+ const flags = n._flags;
826
+ if (!(flags & (REACTIVE_IN_HEAP | REACTIVE_IN_HEAP_HEIGHT))) return;
827
+ n._flags = flags & -25;
828
+ const height = n._height;
829
+ if (n._prevHeap === n) heap._heap[height] = undefined;
830
+ else {
831
+ const next = n._nextHeap;
832
+ const dhh = heap._heap[height];
833
+ const end = next ?? dhh;
834
+ if (n === dhh) heap._heap[height] = next;
835
+ else n._prevHeap._nextHeap = next;
836
+ end._prevHeap = n._prevHeap;
837
+ }
838
+ n._prevHeap = n;
839
+ n._nextHeap = undefined;
840
+ }
841
+ function markHeap(heap) {
842
+ if (heap._marked) return;
843
+ heap._marked = true;
844
+ for (let i = 0; i <= heap._max; i++) {
845
+ for (let el = heap._heap[i]; el !== undefined; el = el._nextHeap) {
846
+ if (el._flags & REACTIVE_IN_HEAP) markNode(el);
847
+ }
848
+ }
849
+ }
850
+ function markNode(el, newState = REACTIVE_DIRTY) {
851
+ const flags = el._flags;
852
+ if ((flags & (REACTIVE_CHECK | REACTIVE_DIRTY)) >= newState) return;
853
+ el._flags = (flags & -4) | newState;
854
+ for (let link = el._subs; link !== null; link = link._nextSub) {
855
+ markNode(link._sub, REACTIVE_CHECK);
856
+ }
857
+ if (el._child !== null) {
858
+ for (let child = el._child; child !== null; child = child._nextChild) {
859
+ for (let link = child._subs; link !== null; link = link._nextSub) {
860
+ markNode(link._sub, REACTIVE_CHECK);
861
+ }
862
+ }
863
+ }
864
+ }
865
+ function runHeap(heap, recompute) {
866
+ heap._marked = false;
867
+ for (heap._min = 0; heap._min <= heap._max; heap._min++) {
868
+ let el = heap._heap[heap._min];
869
+ while (el !== undefined) {
870
+ if (el._flags & REACTIVE_IN_HEAP) recompute(el);
871
+ else adjustHeight(el, heap);
872
+ el = heap._heap[heap._min];
873
+ }
874
+ }
875
+ heap._max = 0;
876
+ }
877
+ function adjustHeight(el, heap) {
878
+ deleteFromHeap(el, heap);
879
+ let newHeight = el._height;
880
+ for (let d = el._deps; d; d = d._nextDep) {
881
+ const dep1 = d._dep;
882
+ const dep = dep1._firewall || dep1;
883
+ if (dep._fn && dep._height >= newHeight) newHeight = dep._height + 1;
884
+ }
885
+ if (el._height !== newHeight) {
886
+ el._height = newHeight;
887
+ for (let s = el._subs; s !== null; s = s._nextSub) {
888
+ insertIntoHeapHeight(s._sub, s._sub._flags & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
889
+ }
890
+ }
891
+ }
889
892
  const PENDING_OWNER = {};
890
893
  function markDisposal(el) {
891
894
  let child = el._firstChild;
892
895
  while (child) {
893
- child._flags |= REACTIVE_ZOMBIE;
894
- if (child._flags & REACTIVE_IN_HEAP) {
895
- deleteFromHeap(child, dirtyQueue);
896
- insertIntoHeap(child, zombieQueue);
896
+ const flags = child._flags;
897
+ child._flags = flags | REACTIVE_ZOMBIE;
898
+ if (flags & (REACTIVE_IN_HEAP | REACTIVE_IN_HEAP_HEIGHT)) {
899
+ deleteFromHeap(child, flags & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
900
+ if (flags & REACTIVE_IN_HEAP) insertIntoHeap(child, zombieQueue);
901
+ else insertIntoHeapHeight(child, zombieQueue);
897
902
  }
898
903
  markDisposal(child);
899
904
  child = child._nextSibling;
900
905
  }
901
906
  }
902
907
  function dispose(node) {
903
- let toRemove = node._deps || null;
904
- do {
908
+ let toRemove = node._deps;
909
+ while (toRemove !== null) {
905
910
  toRemove = unlinkSubs(toRemove);
906
- } while (toRemove !== null);
911
+ }
907
912
  node._deps = null;
908
913
  node._depsTail = null;
909
914
  disposeChildren(node, true);
@@ -1264,8 +1269,10 @@ function handleAsync(el, result, setter) {
1264
1269
  clearStatus(el);
1265
1270
  const lane = resolveLane(el);
1266
1271
  if (lane) lane._pendingAsync.delete(el);
1267
- if (setter) setter(value);
1268
- else if (el._overrideValue !== undefined) {
1272
+ if (setter) {
1273
+ setter(value);
1274
+ if (wasUninitialized) clearStatus(el, true);
1275
+ } else if (el._overrideValue !== undefined) {
1269
1276
  if (el._overrideValue !== undefined && el._overrideValue !== NOT_PENDING)
1270
1277
  el._pendingValue = value;
1271
1278
  else {
@@ -1461,15 +1468,20 @@ GlobalQueue._update = recompute;
1461
1468
  GlobalQueue._dispose = disposeChildren;
1462
1469
  const PRIMITIVE_IN_FORBIDDEN_SCOPE_MESSAGE =
1463
1470
  "[PRIMITIVE_IN_FORBIDDEN_SCOPE] Cannot create reactive primitives inside createTrackedEffect or owner-backed onSettled";
1471
+ const REACTIVE_WRITE_IN_OWNED_SCOPE_SIGNAL_MESSAGE =
1472
+ "[REACTIVE_WRITE_IN_OWNED_SCOPE] Writing to reactive state inside an owned scope (component, computation) is not allowed. " +
1473
+ "Move the write outside or set the `ownedWrite` option if this is intentional.";
1474
+ const REACTIVE_WRITE_IN_OWNED_SCOPE_REFRESH_MESSAGE =
1475
+ "[REACTIVE_WRITE_IN_OWNED_SCOPE] Calling refresh() inside an owned scope (component, computation) is not allowed. " +
1476
+ "Move the invalidation outside pure computation.";
1464
1477
  let tracking = false;
1465
1478
  let stale = false;
1466
- let refreshing = false;
1467
1479
  let pendingCheckActive = false;
1468
1480
  let foundPending = false;
1469
1481
  let latestReadActive = false;
1470
1482
  let context = null;
1471
1483
  let currentOptimisticLane = null;
1472
- let pendingCheckLoadingPath = false;
1484
+ let pendingCheckSources = null;
1473
1485
  let snapshotCaptureActive = false;
1474
1486
  let snapshotSources = null;
1475
1487
  function ownerInSnapshotScope(owner) {
@@ -1931,15 +1943,23 @@ function read(el) {
1931
1943
  const firewall = el._firewall;
1932
1944
  const prevCheck = pendingCheckActive;
1933
1945
  pendingCheckActive = false;
1946
+ let c = context;
1947
+ if (c?._root) c = c._parentComputed;
1934
1948
  const owner = firewall || el;
1935
- if (
1936
- pendingCheckLoadingPath &&
1937
- owner._statusFlags & STATUS_PENDING &&
1938
- owner._statusFlags & STATUS_UNINITIALIZED
1939
- ) {
1940
- let c = context;
1941
- if (c?._root) c = c._parentComputed;
1942
- if (c && tracking) link(el, c);
1949
+ const pendingComputed = el;
1950
+ if (typeof pendingComputed._fn === "function") {
1951
+ const comp = el;
1952
+ if (comp._flags & REACTIVE_LAZY) {
1953
+ comp._flags &= ~REACTIVE_LAZY;
1954
+ recompute(comp, true);
1955
+ } else if (comp._flags & REACTIVE_DISPOSED) {
1956
+ recompute(comp, true);
1957
+ } else {
1958
+ updateIfNecessary(comp);
1959
+ }
1960
+ }
1961
+ if (c && owner._statusFlags & STATUS_PENDING && owner._statusFlags & STATUS_UNINITIALIZED) {
1962
+ if (tracking && el !== c) link(el, c);
1943
1963
  pendingCheckActive = prevCheck;
1944
1964
  throw owner._error;
1945
1965
  }
@@ -1950,17 +1970,14 @@ function read(el) {
1950
1970
  ) {
1951
1971
  foundPending = true;
1952
1972
  }
1953
- let c = context;
1954
- if (c?._root) c = c._parentComputed;
1973
+ collectPendingSources(el);
1974
+ collectPendingSources(firewall);
1955
1975
  if (c && tracking) link(el, c);
1956
- read(getPendingSignal(el));
1957
- read(getPendingSignal(firewall));
1958
1976
  } else {
1959
- if (read(getPendingSignal(el))) foundPending = true;
1960
- if (firewall && read(getPendingSignal(firewall))) foundPending = true;
1977
+ collectPendingSources(el);
1978
+ if (firewall) collectPendingSources(firewall);
1961
1979
  }
1962
1980
  pendingCheckActive = prevCheck;
1963
- return el._value;
1964
1981
  }
1965
1982
  let c = context;
1966
1983
  if (c?._root) c = c._parentComputed;
@@ -2094,7 +2111,7 @@ function read(el) {
2094
2111
  currentOptimisticLane !== null &&
2095
2112
  !latestReadActive &&
2096
2113
  el._pendingValue !== NOT_PENDING &&
2097
- owner === el &&
2114
+ (owner === el || !!(owner._flags & REACTIVE_MANUAL_WRITE)) &&
2098
2115
  !el._fn &&
2099
2116
  c
2100
2117
  ) {
@@ -2131,19 +2148,17 @@ function setSignal(el, v) {
2131
2148
  context &&
2132
2149
  el._firewall !== context
2133
2150
  ) {
2134
- const message =
2135
- "[SIGNAL_WRITE_IN_OWNED_SCOPE] Writing to a Signal inside an owned scope (component, computation) is not allowed. " +
2136
- "Move the write outside or set the `ownedWrite` option if this is intentional.";
2137
2151
  emitDiagnostic({
2138
- code: "SIGNAL_WRITE_IN_OWNED_SCOPE",
2152
+ code: "REACTIVE_WRITE_IN_OWNED_SCOPE",
2139
2153
  kind: "write",
2140
2154
  severity: "error",
2141
- message: message,
2155
+ message: REACTIVE_WRITE_IN_OWNED_SCOPE_SIGNAL_MESSAGE,
2142
2156
  ownerId: context.id,
2143
2157
  ownerName: context._name,
2144
- nodeName: el._name
2158
+ nodeName: el._name,
2159
+ data: { operation: "setSignal" }
2145
2160
  });
2146
- throw new Error(message);
2161
+ throw new Error(REACTIVE_WRITE_IN_OWNED_SCOPE_SIGNAL_MESSAGE);
2147
2162
  }
2148
2163
  if (el._transition && activeTransition !== el._transition)
2149
2164
  globalQueue.initTransition(el._transition);
@@ -2160,9 +2175,13 @@ function setSignal(el, v) {
2160
2175
  const valueChanged =
2161
2176
  !el._equals || !el._equals(currentValue, v) || !!(el._statusFlags & STATUS_UNINITIALIZED);
2162
2177
  if (!valueChanged) {
2163
- if (isOptimistic && hasOverride && el._fn) {
2164
- insertSubs(el, true);
2165
- schedule();
2178
+ if (isOptimistic && hasOverride) {
2179
+ const transition = resolveTransition(el);
2180
+ if (transition && activeTransition !== transition) globalQueue.initTransition(transition);
2181
+ if (el._fn) {
2182
+ insertSubs(el, true);
2183
+ schedule();
2184
+ }
2166
2185
  }
2167
2186
  return v;
2168
2187
  }
@@ -2192,8 +2211,10 @@ function setSignal(el, v) {
2192
2211
  }
2193
2212
  function suppressComputedRecompute(el) {
2194
2213
  deleteFromHeap(el, el._flags & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
2195
- if (!(el._flags & REACTIVE_MANUAL_WRITE) && el._pendingValue === NOT_PENDING)
2214
+ if (!(el._flags & REACTIVE_MANUAL_WRITE) && el._pendingValue === NOT_PENDING) {
2196
2215
  queuePendingNode(el);
2216
+ schedule();
2217
+ }
2197
2218
  el._flags = (el._flags & -4) | REACTIVE_MANUAL_WRITE;
2198
2219
  }
2199
2220
  function setMemo(el, v) {
@@ -2236,11 +2257,25 @@ function getPendingSignal(el) {
2236
2257
  }
2237
2258
  return el._pendingSignal;
2238
2259
  }
2260
+ function collectPendingSources(el) {
2261
+ pendingCheckSources?.add(el);
2262
+ const owner = el._firewall || el;
2263
+ if (owner !== el) pendingCheckSources?.add(owner);
2264
+ }
2239
2265
  function computePendingState(el) {
2240
2266
  const comp = el;
2241
2267
  const firewall = el._firewall;
2268
+ if (el._parentSource) {
2269
+ const parent = el._parentSource;
2270
+ if (parent._statusFlags & STATUS_PENDING && !(parent._statusFlags & STATUS_UNINITIALIZED))
2271
+ return true;
2272
+ return el._pendingValue !== NOT_PENDING && !(comp._statusFlags & STATUS_UNINITIALIZED);
2273
+ }
2242
2274
  if (firewall && el._pendingValue !== NOT_PENDING) {
2243
- return !firewall._inFlight && !(firewall._statusFlags & STATUS_PENDING);
2275
+ return (
2276
+ !!(firewall._flags & REACTIVE_MANUAL_WRITE) ||
2277
+ (!firewall._inFlight && !(firewall._statusFlags & STATUS_PENDING))
2278
+ );
2244
2279
  }
2245
2280
  if (el._overrideValue !== undefined && el._overrideValue !== NOT_PENDING) {
2246
2281
  if (comp._statusFlags & STATUS_PENDING && !(comp._statusFlags & STATUS_UNINITIALIZED))
@@ -2309,32 +2344,47 @@ function latest(fn) {
2309
2344
  latestReadActive = prevLatest;
2310
2345
  }
2311
2346
  }
2312
- function isPending(fn, loading) {
2347
+ function isPending(fn) {
2313
2348
  const prevPendingCheck = pendingCheckActive;
2314
- const prevPendingCheckLoadingPath = pendingCheckLoadingPath;
2315
2349
  const prevFoundPending = foundPending;
2316
- const checkLoading = loading === true;
2350
+ const prevPendingCheckSources = pendingCheckSources;
2317
2351
  pendingCheckActive = true;
2318
- pendingCheckLoadingPath = checkLoading;
2319
2352
  foundPending = false;
2353
+ pendingCheckSources = new Set();
2354
+ const collectPending = () => {
2355
+ pendingCheckActive = false;
2356
+ const prevStrictRead = strictRead;
2357
+ strictRead = false;
2358
+ try {
2359
+ pendingCheckSources.forEach(source => {
2360
+ if (read(getPendingSignal(source))) foundPending = true;
2361
+ });
2362
+ } finally {
2363
+ strictRead = prevStrictRead;
2364
+ pendingCheckActive = true;
2365
+ }
2366
+ };
2320
2367
  try {
2321
2368
  fn();
2369
+ collectPending();
2322
2370
  return foundPending;
2323
2371
  } catch (e) {
2324
- if (checkLoading && e instanceof NotReadyError) throw e;
2372
+ collectPending();
2373
+ if (e instanceof NotReadyError) {
2374
+ if (foundPending && !(e.source?._statusFlags & STATUS_UNINITIALIZED)) return true;
2375
+ if (context) throw e;
2376
+ }
2325
2377
  return foundPending;
2326
2378
  } finally {
2327
2379
  pendingCheckActive = prevPendingCheck;
2328
- pendingCheckLoadingPath = prevPendingCheckLoadingPath;
2329
2380
  foundPending = prevFoundPending;
2381
+ pendingCheckSources = prevPendingCheckSources;
2330
2382
  }
2331
2383
  }
2332
2384
  function refresh(target) {
2333
- let prevRefreshing = refreshing;
2334
- refreshing = true;
2335
- try {
2336
- const node = target?.[$REFRESH];
2337
- if (true && !node) {
2385
+ const node = target?.[$REFRESH];
2386
+ if (!node) {
2387
+ {
2338
2388
  const message =
2339
2389
  "[INVALID_REFRESH_TARGET] refresh() expects a Solid source accessor or refreshable store. " +
2340
2390
  "Pass the original source target, not a wrapper function or derived property read.";
@@ -2346,18 +2396,32 @@ function refresh(target) {
2346
2396
  });
2347
2397
  throw new Error(message);
2348
2398
  }
2349
- if (node && typeof node._fn === "function" && !(node._flags & REACTIVE_DISPOSED)) {
2350
- recompute(node);
2351
- }
2352
- } finally {
2353
- refreshing = prevRefreshing;
2354
- if (!prevRefreshing) {
2355
- schedule();
2356
- }
2357
2399
  }
2358
- }
2359
- function isRefreshing() {
2360
- return refreshing;
2400
+ if (
2401
+ context &&
2402
+ !((node._config ?? 0) & CONFIG_OWNED_WRITE) &&
2403
+ !(context._config & CONFIG_CHILDREN_FORBIDDEN)
2404
+ ) {
2405
+ emitDiagnostic({
2406
+ code: "REACTIVE_WRITE_IN_OWNED_SCOPE",
2407
+ kind: "write",
2408
+ severity: "error",
2409
+ message: REACTIVE_WRITE_IN_OWNED_SCOPE_REFRESH_MESSAGE,
2410
+ ownerId: context.id,
2411
+ ownerName: context._name,
2412
+ nodeName: node._name,
2413
+ data: { operation: "refresh" }
2414
+ });
2415
+ throw new Error(REACTIVE_WRITE_IN_OWNED_SCOPE_REFRESH_MESSAGE);
2416
+ }
2417
+ if (
2418
+ typeof node._fn === "function" &&
2419
+ !(node._flags & (REACTIVE_DISPOSED | REACTIVE_MANUAL_WRITE))
2420
+ ) {
2421
+ node._flags = (node._flags & ~REACTIVE_CHECK) | REACTIVE_DIRTY;
2422
+ insertIntoHeap(node, node._flags & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
2423
+ schedule();
2424
+ }
2361
2425
  }
2362
2426
  function createContext(defaultValue, description) {
2363
2427
  return { id: Symbol(description), defaultValue: defaultValue };
@@ -2756,6 +2820,7 @@ function applyState(next, state, keyFn) {
2756
2820
  function applyStateFast(next, target, keyFn) {
2757
2821
  const previous = target[STORE_VALUE];
2758
2822
  if (next === previous) return;
2823
+ const arrayNodes = target[STORE_NODE];
2759
2824
  (target[STORE_LOOKUP] || storeLookup).set(next, target[$PROXY]);
2760
2825
  target[STORE_VALUE] = next;
2761
2826
  if (Array.isArray(previous)) {
@@ -2787,18 +2852,18 @@ function applyStateFast(next, target, keyFn) {
2787
2852
  if (start > newEnd || start > end) {
2788
2853
  for (j = start; j <= newEnd; j++) {
2789
2854
  changed = true;
2790
- target[STORE_NODE][j] && setSignal(target[STORE_NODE][j], wrap(next[j], target));
2855
+ arrayNodes?.[j] && setSignal(arrayNodes[j], wrap(next[j], target));
2791
2856
  }
2792
2857
  for (; j < next.length; j++) {
2793
2858
  changed = true;
2794
2859
  const wrapped = wrap(temp[j], target);
2795
- target[STORE_NODE][j] && setSignal(target[STORE_NODE][j], wrapped);
2860
+ arrayNodes?.[j] && setSignal(arrayNodes[j], wrapped);
2796
2861
  applyState(next[j], wrapped, keyFn);
2797
2862
  }
2798
- changed && target[STORE_NODE][$TRACK] && setSignal(target[STORE_NODE][$TRACK], void 0);
2863
+ changed && notifySelf(target);
2799
2864
  prevLength !== next.length &&
2800
- target[STORE_NODE].length &&
2801
- setSignal(target[STORE_NODE].length, next.length);
2865
+ arrayNodes?.length &&
2866
+ setSignal(arrayNodes.length, next.length);
2802
2867
  return;
2803
2868
  }
2804
2869
  newIndicesNext = new Array(newEnd + 1);
@@ -2822,24 +2887,26 @@ function applyStateFast(next, target, keyFn) {
2822
2887
  for (j = start; j < next.length; j++) {
2823
2888
  if (j in temp) {
2824
2889
  const wrapped = wrap(temp[j], target);
2825
- target[STORE_NODE][j] && setSignal(target[STORE_NODE][j], wrapped);
2890
+ arrayNodes?.[j] && setSignal(arrayNodes[j], wrapped);
2826
2891
  applyState(next[j], wrapped, keyFn);
2827
- } else target[STORE_NODE][j] && setSignal(target[STORE_NODE][j], wrap(next[j], target));
2892
+ } else arrayNodes?.[j] && setSignal(arrayNodes[j], wrap(next[j], target));
2828
2893
  }
2829
2894
  if (start < next.length) changed = true;
2830
2895
  } else if (next.length) {
2831
2896
  for (let i = 0, len = next.length; i < len; i++) {
2832
2897
  const item = previous[i];
2833
- isWrappable(item)
2834
- ? applyState(next[i], wrap(item, target), keyFn)
2835
- : target[STORE_NODE][i] && setSignal(target[STORE_NODE][i], next[i]);
2898
+ if (isWrappable(item)) applyState(next[i], wrap(item, target), keyFn);
2899
+ else {
2900
+ if (item !== next[i]) changed = true;
2901
+ arrayNodes?.[i] && setSignal(arrayNodes[i], next[i]);
2902
+ }
2836
2903
  }
2837
2904
  }
2838
2905
  if (prevLength !== next.length) {
2839
2906
  changed = true;
2840
- target[STORE_NODE].length && setSignal(target[STORE_NODE].length, next.length);
2907
+ arrayNodes?.length && setSignal(arrayNodes.length, next.length);
2841
2908
  }
2842
- changed && target[STORE_NODE][$TRACK] && setSignal(target[STORE_NODE][$TRACK], void 0);
2909
+ changed && notifySelf(target);
2843
2910
  return;
2844
2911
  }
2845
2912
  let nodes = target[STORE_NODE];
@@ -2908,18 +2975,17 @@ function applyStateSlow(next, target, keyFn) {
2908
2975
  if (start > newEnd || start > end) {
2909
2976
  for (j = start; j <= newEnd; j++) {
2910
2977
  changed = true;
2911
- target[STORE_NODE][j] && setSignal(target[STORE_NODE][j], wrap(next[j], target));
2978
+ nodes?.[j] && setSignal(nodes[j], wrap(next[j], target));
2912
2979
  }
2913
2980
  for (; j < next.length; j++) {
2914
2981
  changed = true;
2915
2982
  const wrapped = wrap(temp[j], target);
2916
- target[STORE_NODE][j] && setSignal(target[STORE_NODE][j], wrapped);
2983
+ nodes?.[j] && setSignal(nodes[j], wrapped);
2917
2984
  applyState(next[j], wrapped, keyFn);
2918
2985
  }
2919
- changed && target[STORE_NODE][$TRACK] && setSignal(target[STORE_NODE][$TRACK], void 0);
2920
- prevLength !== next.length &&
2921
- target[STORE_NODE].length &&
2922
- setSignal(target[STORE_NODE].length, next.length);
2986
+ const nextLength = next.length;
2987
+ changed && notifySelf(target);
2988
+ prevLength !== nextLength && nodes?.length && setSignal(nodes.length, nextLength);
2923
2989
  return;
2924
2990
  }
2925
2991
  newIndicesNext = new Array(newEnd + 1);
@@ -2943,24 +3009,27 @@ function applyStateSlow(next, target, keyFn) {
2943
3009
  for (j = start; j < next.length; j++) {
2944
3010
  if (j in temp) {
2945
3011
  const wrapped = wrap(temp[j], target);
2946
- target[STORE_NODE][j] && setSignal(target[STORE_NODE][j], wrapped);
3012
+ nodes?.[j] && setSignal(nodes[j], wrapped);
2947
3013
  applyState(next[j], wrapped, keyFn);
2948
- } else target[STORE_NODE][j] && setSignal(target[STORE_NODE][j], wrap(next[j], target));
3014
+ } else nodes?.[j] && setSignal(nodes[j], wrap(next[j], target));
2949
3015
  }
2950
3016
  if (start < next.length) changed = true;
2951
3017
  } else if (next.length) {
2952
3018
  for (let i = 0, len = next.length; i < len; i++) {
2953
3019
  const item = getOverrideValue(previous, override, i, optOverride);
2954
- isWrappable(item)
2955
- ? applyState(next[i], wrap(item, target), keyFn)
2956
- : target[STORE_NODE][i] && setSignal(target[STORE_NODE][i], next[i]);
3020
+ if (isWrappable(item)) applyState(next[i], wrap(item, target), keyFn);
3021
+ else {
3022
+ if (item !== next[i]) changed = true;
3023
+ nodes?.[i] && setSignal(nodes[i], next[i]);
3024
+ }
2957
3025
  }
2958
3026
  }
2959
- if (prevLength !== next.length) {
3027
+ const nextLength = next.length;
3028
+ if (prevLength !== nextLength) {
2960
3029
  changed = true;
2961
- target[STORE_NODE].length && setSignal(target[STORE_NODE].length, next.length);
3030
+ nodes?.length && setSignal(nodes.length, nextLength);
2962
3031
  }
2963
- changed && target[STORE_NODE][$TRACK] && setSignal(target[STORE_NODE][$TRACK], void 0);
3032
+ changed && notifySelf(target);
2964
3033
  return;
2965
3034
  }
2966
3035
  if (nodes) {
@@ -2996,7 +3065,7 @@ function reconcile(value, key) {
2996
3065
  if (state == null) throw new Error("Cannot reconcile null or undefined state");
2997
3066
  const keyFn = typeof key === "string" ? item => item[key] : key;
2998
3067
  const eq = keyFn(state);
2999
- if (eq !== undefined && keyFn(value) !== keyFn(state))
3068
+ if (eq !== undefined && keyFn(value) !== eq)
3000
3069
  throw new Error("Cannot reconcile states with different identity");
3001
3070
  applyState(value, state, keyFn);
3002
3071
  };
@@ -3035,13 +3104,13 @@ function createProjectionInternal(fn, seed, options) {
3035
3104
  function createProjection(fn, seed, options) {
3036
3105
  return createProjectionInternal(fn, seed, options).store;
3037
3106
  }
3038
- function runProjectionComputed(wrappedStore, fn, key, wrapCommit) {
3107
+ function runProjectionComputed(wrappedStore, fn, key, wrapCommit, onDraftWrite) {
3039
3108
  const owner = getOwner();
3040
3109
  let settled = false;
3041
3110
  let result;
3042
3111
  const draft = new Proxy(
3043
3112
  wrappedStore,
3044
- createWriteTraps(() => !settled || owner._inFlight === result)
3113
+ createWriteTraps(() => !settled || owner._inFlight === result, onDraftWrite)
3045
3114
  );
3046
3115
  storeSetter(draft, s => {
3047
3116
  result = fn(s);
@@ -3055,7 +3124,7 @@ function runProjectionComputed(wrappedStore, fn, key, wrapCommit) {
3055
3124
  });
3056
3125
  return owner;
3057
3126
  }
3058
- function createWriteTraps(isActive) {
3127
+ function createWriteTraps(isActive, onDraftWrite) {
3059
3128
  const traps = {
3060
3129
  get(_, prop) {
3061
3130
  let value;
@@ -3067,6 +3136,7 @@ function createWriteTraps(isActive) {
3067
3136
  setWriteOverride(false);
3068
3137
  setProjectionWriteActive(false);
3069
3138
  }
3139
+ if (prop === $TARGET) return value;
3070
3140
  return typeof value === "object" && value !== null ? new Proxy(value, traps) : value;
3071
3141
  },
3072
3142
  has(_, prop) {
@@ -3087,6 +3157,7 @@ function createWriteTraps(isActive) {
3087
3157
  setProjectionWriteActive(true);
3088
3158
  try {
3089
3159
  _[prop] = value;
3160
+ onDraftWrite?.();
3090
3161
  } finally {
3091
3162
  setWriteOverride(false);
3092
3163
  setProjectionWriteActive(false);
@@ -3099,6 +3170,7 @@ function createWriteTraps(isActive) {
3099
3170
  setProjectionWriteActive(true);
3100
3171
  try {
3101
3172
  delete _[prop];
3173
+ onDraftWrite?.();
3102
3174
  } finally {
3103
3175
  setWriteOverride(false);
3104
3176
  setProjectionWriteActive(false);
@@ -3122,6 +3194,7 @@ const STORE_VALUE = "v",
3122
3194
  STORE_LOOKUP = "l",
3123
3195
  STORE_FIREWALL = "f",
3124
3196
  STORE_OPTIMISTIC = "p";
3197
+ const STORE_SELF_PENDING = Symbol("STORE_SELF_PENDING");
3125
3198
  function createStoreProxy(value, traps = storeTraps, extend) {
3126
3199
  let newTarget;
3127
3200
  if (Array.isArray(value)) {
@@ -3156,8 +3229,45 @@ function setWriteOverride(value) {
3156
3229
  function writeOnly(proxy) {
3157
3230
  return writeOverride || !!Writing?.has(proxy);
3158
3231
  }
3159
- function unwrapStoreValue(value) {
3160
- return value?.[$TARGET]?.[STORE_VALUE] ?? value;
3232
+ function unwrapStoreValue(value, map, lookup) {
3233
+ const target = value?.[$TARGET] || lookup?.get(value)?.[$TARGET];
3234
+ if (!target) return value;
3235
+ const override = target[STORE_OVERRIDE];
3236
+ if (!override) return target[STORE_VALUE];
3237
+ if (!map) map = new Map();
3238
+ if (map.has(value)) return map.get(value);
3239
+ const source = target[STORE_VALUE];
3240
+ const isArray = Array.isArray(source);
3241
+ const result = isArray ? [] : Object.create(Object.getPrototypeOf(source));
3242
+ map.set(value, result);
3243
+ lookup = target[STORE_LOOKUP] ?? storeLookup;
3244
+ for (const key of getKeys(source, override)) {
3245
+ if (isArray && key === "length") continue;
3246
+ const next = key in override ? override[key] : source[key];
3247
+ if (next !== $DELETED) result[key] = unwrapStoreValue(next, map, lookup);
3248
+ }
3249
+ if (isArray) result.length = override.length ?? source.length;
3250
+ return result;
3251
+ }
3252
+ function isPrototypePollutionKey$1(property) {
3253
+ return property === "__proto__" || property === "constructor" || property === "prototype";
3254
+ }
3255
+ function hasOwnStoreProperty(target, property) {
3256
+ const optimisticOverride = target[STORE_OPTIMISTIC_OVERRIDE];
3257
+ if (
3258
+ optimisticOverride &&
3259
+ Object.prototype.hasOwnProperty.call(optimisticOverride, property) &&
3260
+ optimisticOverride[property] !== $DELETED
3261
+ )
3262
+ return true;
3263
+ const override = target[STORE_OVERRIDE];
3264
+ if (
3265
+ override &&
3266
+ Object.prototype.hasOwnProperty.call(override, property) &&
3267
+ override[property] !== $DELETED
3268
+ )
3269
+ return true;
3270
+ return Object.prototype.hasOwnProperty.call(unwrapStoreValue(target[STORE_VALUE]), property);
3161
3271
  }
3162
3272
  function hasInheritedAccessor(source, property) {
3163
3273
  let current = Object.getPrototypeOf(source);
@@ -3208,6 +3318,14 @@ function trackSelf(target, symbol = $TRACK) {
3208
3318
  )
3209
3319
  );
3210
3320
  }
3321
+ function notifySelf(target) {
3322
+ const node = target[STORE_NODE]?.[$TRACK];
3323
+ node &&
3324
+ setSignal(
3325
+ node,
3326
+ target[STORE_OPTIMISTIC] && !projectionWriteActive ? STORE_SELF_PENDING : undefined
3327
+ );
3328
+ }
3211
3329
  function getKeys(source, override, enumerable = true) {
3212
3330
  const baseKeys = untrack(() => (enumerable ? Object.keys(source) : Reflect.ownKeys(source)));
3213
3331
  if (!override) return baseKeys;
@@ -3300,7 +3418,7 @@ function notifyStoreProperty(target, property, mode, value, prev, prevHas) {
3300
3418
  setSignal(node, undefined);
3301
3419
  }
3302
3420
  }
3303
- nodes[$TRACK] && setSignal(nodes[$TRACK], undefined);
3421
+ notifySelf(target);
3304
3422
  }
3305
3423
  let Writing = null;
3306
3424
  const storeTraps = {
@@ -3312,8 +3430,9 @@ const storeTraps = {
3312
3430
  trackSelf(target);
3313
3431
  return receiver;
3314
3432
  }
3433
+ const selfRead = getObserver() === target[STORE_FIREWALL];
3315
3434
  const nodes = getNodes(target, STORE_NODE);
3316
- const tracked = nodes[property];
3435
+ const tracked = selfRead ? undefined : nodes[property];
3317
3436
  const source = target[STORE_VALUE];
3318
3437
  if (
3319
3438
  !tracked &&
@@ -3325,6 +3444,7 @@ const storeTraps = {
3325
3444
  !source[$TARGET] &&
3326
3445
  !(property in source) &&
3327
3446
  getObserver() &&
3447
+ !selfRead &&
3328
3448
  !writeOnly(receiver)
3329
3449
  ) {
3330
3450
  return read(getNode(nodes, property, undefined, target[STORE_FIREWALL]));
@@ -3350,6 +3470,8 @@ const storeTraps = {
3350
3470
  }
3351
3471
  }
3352
3472
  if (writeOnly(receiver)) {
3473
+ if (isPrototypePollutionKey$1(property) && !hasOwnStoreProperty(target, property))
3474
+ return undefined;
3353
3475
  let value =
3354
3476
  tracked && (overridden || !proxySource)
3355
3477
  ? tracked._overrideValue !== undefined && tracked._overrideValue !== NOT_PENDING
@@ -3378,7 +3500,7 @@ const storeTraps = {
3378
3500
  proto !== Object.prototype
3379
3501
  ? value.bind(storeValue)
3380
3502
  : value;
3381
- } else if (getObserver()) {
3503
+ } else if (getObserver() && !selfRead) {
3382
3504
  return read(
3383
3505
  getNode(
3384
3506
  nodes,
@@ -3416,7 +3538,7 @@ const storeTraps = {
3416
3538
  : target[STORE_OVERRIDE] && property in target[STORE_OVERRIDE]
3417
3539
  ? target[STORE_OVERRIDE][property] !== $DELETED
3418
3540
  : property in target[STORE_VALUE];
3419
- if (writeOnly(target[$PROXY])) return has;
3541
+ if (writeOnly(target[$PROXY]) || getObserver() === target[STORE_FIREWALL]) return has;
3420
3542
  const nodes = getNodes(target, STORE_HAS);
3421
3543
  if (nodes[property]) return read(nodes[property]);
3422
3544
  if (getObserver()) {
@@ -3427,6 +3549,7 @@ const storeTraps = {
3427
3549
  return has;
3428
3550
  },
3429
3551
  set(target, property, rawValue) {
3552
+ if (property === "__proto__") return true;
3430
3553
  const store = target[$PROXY];
3431
3554
  if (writeOnly(store)) {
3432
3555
  untrack(() => {
@@ -3488,6 +3611,7 @@ const storeTraps = {
3488
3611
  return true;
3489
3612
  },
3490
3613
  defineProperty(target, property, descriptor) {
3614
+ if (property === "__proto__") return true;
3491
3615
  const store = target[$PROXY];
3492
3616
  if (writeOnly(store)) {
3493
3617
  untrack(() => {
@@ -3514,6 +3638,7 @@ const storeTraps = {
3514
3638
  return true;
3515
3639
  },
3516
3640
  deleteProperty(target, property) {
3641
+ if (property === "__proto__") return true;
3517
3642
  const optDeleted = target[STORE_OPTIMISTIC_OVERRIDE]?.[property] === $DELETED;
3518
3643
  const regDeleted = target[STORE_OVERRIDE]?.[property] === $DELETED;
3519
3644
  if (writeOnly(target[$PROXY]) && !optDeleted && !regDeleted) {
@@ -3541,7 +3666,7 @@ const storeTraps = {
3541
3666
  return true;
3542
3667
  },
3543
3668
  ownKeys(target) {
3544
- trackSelf(target);
3669
+ if (getObserver() !== target[STORE_FIREWALL]) trackSelf(target);
3545
3670
  let keys = getKeys(target[STORE_VALUE], target[STORE_OVERRIDE], false);
3546
3671
  if (target[STORE_OPTIMISTIC_OVERRIDE]) {
3547
3672
  const keySet = new Set(keys);
@@ -3606,7 +3731,10 @@ function createStore(first, second, options) {
3606
3731
  return [
3607
3732
  wrappedStore,
3608
3733
  derived
3609
- ? fn => (storeSetter(wrappedStore, fn), suppressComputedRecompute(wrappedStore[$REFRESH]))
3734
+ ? fn => {
3735
+ suppressComputedRecompute(wrappedStore[$REFRESH]);
3736
+ storeSetter(wrappedStore, fn);
3737
+ }
3610
3738
  : fn => storeSetter(wrappedStore, fn)
3611
3739
  ];
3612
3740
  }
@@ -3621,31 +3749,50 @@ function createOptimisticStore(first, second, options) {
3621
3749
  function clearOptimisticStore(store) {
3622
3750
  const target = store[$TARGET];
3623
3751
  if (!target || !target[STORE_OPTIMISTIC_OVERRIDE]) return;
3752
+ clearOptimisticOverride(target);
3753
+ }
3754
+ function clearOptimisticOverride(target) {
3624
3755
  const override = target[STORE_OPTIMISTIC_OVERRIDE];
3756
+ if (!override) return;
3625
3757
  const nodes = target[STORE_NODE];
3758
+ delete target[STORE_OPTIMISTIC_OVERRIDE];
3759
+ const wasProjectionWriteActive = projectionWriteActive;
3626
3760
  setProjectionWriteActive(true);
3627
3761
  try {
3628
3762
  if (nodes) {
3629
3763
  for (const key of Reflect.ownKeys(override)) {
3630
3764
  if (nodes[key]) {
3631
- nodes[key]._optimisticLane = undefined;
3765
+ const node = nodes[key];
3766
+ node._optimisticLane = undefined;
3632
3767
  const baseValue =
3633
3768
  target[STORE_OVERRIDE] && key in target[STORE_OVERRIDE]
3634
3769
  ? target[STORE_OVERRIDE][key]
3635
3770
  : target[STORE_VALUE][key];
3636
3771
  const value = baseValue === $DELETED ? undefined : baseValue;
3637
- setSignal(nodes[key], isWrappable(value) ? wrap(value, target) : value);
3772
+ const next = isWrappable(value) ? wrap(value, target) : value;
3773
+ const prev =
3774
+ node._overrideValue !== undefined && node._overrideValue !== NOT_PENDING
3775
+ ? node._overrideValue
3776
+ : node._pendingValue !== NOT_PENDING
3777
+ ? node._pendingValue
3778
+ : node._value;
3779
+ node._overrideValue = NOT_PENDING;
3780
+ node._pendingValue = NOT_PENDING;
3781
+ node._value = next;
3782
+ if (!node._equals || !node._equals(prev, next)) {
3783
+ insertSubs(node, true);
3784
+ schedule();
3785
+ }
3638
3786
  }
3639
3787
  }
3640
3788
  if (nodes[$TRACK]) {
3641
3789
  nodes[$TRACK]._optimisticLane = undefined;
3642
- setSignal(nodes[$TRACK], undefined);
3790
+ notifySelf(target);
3643
3791
  }
3644
3792
  }
3645
3793
  } finally {
3646
- setProjectionWriteActive(false);
3794
+ setProjectionWriteActive(wasProjectionWriteActive);
3647
3795
  }
3648
- delete target[STORE_OPTIMISTIC_OVERRIDE];
3649
3796
  }
3650
3797
  function createOptimisticProjectionInternal(fn, initialValue, options) {
3651
3798
  let node;
@@ -3670,19 +3817,31 @@ function createOptimisticProjectionInternal(fn, initialValue, options) {
3670
3817
  };
3671
3818
  const wrappedStore = wrapProjection(initialValue);
3672
3819
  if (fn) {
3820
+ const clearProjectionOverride = () => {
3821
+ const target = wrappedStore[$TARGET];
3822
+ if (target?.[STORE_OPTIMISTIC_OVERRIDE]) clearOptimisticOverride(target);
3823
+ };
3673
3824
  const wrapCommit = write => {
3825
+ const wasProjectionWriteActive = projectionWriteActive;
3674
3826
  setProjectionWriteActive(true);
3675
3827
  try {
3676
3828
  write();
3829
+ clearProjectionOverride();
3677
3830
  } finally {
3678
- setProjectionWriteActive(false);
3831
+ setProjectionWriteActive(wasProjectionWriteActive);
3679
3832
  }
3680
3833
  };
3681
3834
  node = computed(
3682
3835
  () => {
3683
3836
  setProjectionWriteActive(true);
3684
3837
  try {
3685
- runProjectionComputed(wrappedStore, fn, options?.key || "id", wrapCommit);
3838
+ runProjectionComputed(
3839
+ wrappedStore,
3840
+ fn,
3841
+ options?.key || "id",
3842
+ wrapCommit,
3843
+ clearProjectionOverride
3844
+ );
3686
3845
  } finally {
3687
3846
  setProjectionWriteActive(false);
3688
3847
  }
@@ -3784,13 +3943,13 @@ function snapshotImpl(item, track, map, lookup) {
3784
3943
  : target[STORE_VALUE]
3785
3944
  );
3786
3945
  item = target[STORE_VALUE];
3787
- lookup = storeLookup;
3946
+ lookup = target[STORE_LOOKUP] ?? storeLookup;
3788
3947
  } else {
3789
3948
  isArray = Array.isArray(item);
3790
3949
  map.set(item, item);
3791
3950
  }
3792
3951
  if (isArray) {
3793
- const len = override?.length || item.length;
3952
+ const len = override?.length ?? item.length;
3794
3953
  for (let i = 0; i < len; i++) {
3795
3954
  v = override && i in override ? override[i] : item[i];
3796
3955
  if (v === $DELETED) continue;
@@ -4162,6 +4321,7 @@ function updateRepeat() {
4162
4321
  this._nodes = [];
4163
4322
  this._mappings = [];
4164
4323
  this._len = 0;
4324
+ this._offset = 0;
4165
4325
  }
4166
4326
  if (this._fallback && !this._mappings[0]) {
4167
4327
  this._mappings[0] = runWithOwner((this._nodes[0] = createOwner()), this._fallback);
@@ -4173,10 +4333,10 @@ function updateRepeat() {
4173
4333
  if (this._len === 0 && this._nodes[0]) this._nodes[0].dispose();
4174
4334
  for (let i = to; i < prevTo; i++) this._nodes[i - this._offset].dispose();
4175
4335
  if (this._offset < from) {
4176
- let i = this._offset;
4177
- while (i < from && i < this._len) this._nodes[i++].dispose();
4178
- this._nodes.splice(0, from - this._offset);
4179
- this._mappings.splice(0, from - this._offset);
4336
+ const removed = from - this._offset;
4337
+ for (let i = 0; i < removed && i < this._len; i++) this._nodes[i].dispose();
4338
+ this._nodes.splice(0, removed);
4339
+ this._mappings.splice(0, removed);
4180
4340
  } else if (this._offset > from) {
4181
4341
  let i = prevTo - this._offset - 1;
4182
4342
  let difference = this._offset - from;
@@ -4225,7 +4385,7 @@ function createBoundChildren(owner, fn, queue, mask) {
4225
4385
  cleanup(() => parentQueue.removeChild(owner._queue));
4226
4386
  return runWithOwner(owner, () => {
4227
4387
  const c = computed(fn);
4228
- return boundaryComputed(() => staleValues(() => flatten(read(c))), mask);
4388
+ return boundaryComputed(() => flatten(read(c)), mask);
4229
4389
  });
4230
4390
  }
4231
4391
  const ON_INIT = Symbol();
@@ -4636,7 +4796,6 @@ export {
4636
4796
  isDisposed,
4637
4797
  isEqual,
4638
4798
  isPending,
4639
- isRefreshing,
4640
4799
  isWrappable,
4641
4800
  latest,
4642
4801
  mapArray,