solid-js 2.0.0-experimental.14 → 2.0.0-experimental.16

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.cjs CHANGED
@@ -19,13 +19,16 @@ function useContext(context) {
19
19
  return signals.getContext(context);
20
20
  }
21
21
  function children(fn) {
22
- const children = signals.createMemo(fn);
23
- const memo = signals.createMemo(() => signals.flatten(children()), undefined, {
24
- name: "children"
25
- }) ;
22
+ const c = signals.createMemo(fn, undefined, {
23
+ lazy: true
24
+ });
25
+ const memo = signals.createMemo(() => signals.flatten(c()), undefined, {
26
+ name: "children",
27
+ lazy: true
28
+ } );
26
29
  memo.toArray = () => {
27
- const c = memo();
28
- return Array.isArray(c) ? c : c != null ? [c] : [];
30
+ const v = memo();
31
+ return Array.isArray(v) ? v : v != null ? [v] : [];
29
32
  };
30
33
  return memo;
31
34
  }
@@ -39,8 +42,15 @@ function devComponent(Comp, props) {
39
42
  Object.assign(Comp, {
40
43
  [$DEVCOMP]: true
41
44
  });
42
- return Comp(props);
45
+ signals.setStrictRead(`<${Comp.name || "Anonymous"}>`);
46
+ try {
47
+ return Comp(props);
48
+ } finally {
49
+ signals.setStrictRead(false);
50
+ }
43
51
  });
52
+ }, {
53
+ transparent: true
44
54
  });
45
55
  }
46
56
  function registerGraph(value) {
@@ -60,8 +70,47 @@ const sharedConfig = {
60
70
  return signals.getNextChildId(o);
61
71
  }
62
72
  };
73
+ let _hydrationEndCallbacks = null;
74
+ let _pendingBoundaries = 0;
75
+ let _hydrationDone = false;
76
+ let _snapshotRootOwner = null;
77
+ function markTopLevelSnapshotScope() {
78
+ if (_snapshotRootOwner) return;
79
+ let owner = signals.getOwner();
80
+ if (!owner) return;
81
+ while (owner._parent) owner = owner._parent;
82
+ signals.markSnapshotScope(owner);
83
+ _snapshotRootOwner = owner;
84
+ }
85
+ function drainHydrationCallbacks() {
86
+ if (_hydrationDone) return;
87
+ _hydrationDone = true;
88
+ _doneValue = true;
89
+ signals.clearSnapshots();
90
+ signals.setSnapshotCapture(false);
91
+ signals.flush();
92
+ const cbs = _hydrationEndCallbacks;
93
+ _hydrationEndCallbacks = null;
94
+ if (cbs) for (const cb of cbs) cb();
95
+ setTimeout(() => {
96
+ if (sharedConfig.verifyHydration) sharedConfig.verifyHydration();
97
+ if (globalThis._$HY) globalThis._$HY.done = true;
98
+ });
99
+ }
100
+ function checkHydrationComplete() {
101
+ if (_pendingBoundaries === 0) drainHydrationCallbacks();
102
+ }
103
+ let _hydratingValue = false;
104
+ let _doneValue = false;
63
105
  let _createMemo;
64
106
  let _createSignal;
107
+ let _createErrorBoundary;
108
+ let _createOptimistic;
109
+ let _createProjection;
110
+ let _createStore;
111
+ let _createOptimisticStore;
112
+ let _createRenderEffect;
113
+ let _createEffect;
65
114
  class MockPromise {
66
115
  static all() {
67
116
  return new MockPromise();
@@ -97,14 +146,110 @@ function subFetch(fn, prev) {
97
146
  try {
98
147
  window.fetch = () => new MockPromise();
99
148
  Promise = MockPromise;
100
- return fn(prev);
149
+ const result = fn(prev);
150
+ if (result && typeof result[Symbol.asyncIterator] === "function") {
151
+ result[Symbol.asyncIterator]().next();
152
+ }
153
+ return result;
101
154
  } finally {
102
155
  window.fetch = ogFetch;
103
156
  Promise = ogPromise;
104
157
  }
105
158
  }
159
+ function consumeFirstSync(ai) {
160
+ const iter = ai[Symbol.asyncIterator]();
161
+ const r = iter.next();
162
+ const value = !(r instanceof Promise) && !r.done ? r.value : undefined;
163
+ return [value, iter];
164
+ }
165
+ function applyPatches(target, patches) {
166
+ for (const patch of patches) {
167
+ const path = patch[0];
168
+ let current = target;
169
+ for (let i = 0; i < path.length - 1; i++) current = current[path[i]];
170
+ const key = path[path.length - 1];
171
+ if (patch.length === 1) {
172
+ Array.isArray(current) ? current.splice(key, 1) : delete current[key];
173
+ } else if (patch.length === 3) {
174
+ current.splice(key, 0, patch[1]);
175
+ } else {
176
+ current[key] = patch[1];
177
+ }
178
+ }
179
+ }
180
+ function scheduleIteratorConsumption(iter, apply) {
181
+ const consume = () => {
182
+ while (true) {
183
+ const n = iter.next();
184
+ if (n instanceof Promise) {
185
+ n.then(r => {
186
+ if (r.done) return;
187
+ apply(r.value);
188
+ consume();
189
+ });
190
+ return;
191
+ }
192
+ if (n.done) break;
193
+ apply(n.value);
194
+ }
195
+ };
196
+ consume();
197
+ }
198
+ function isAsyncIterable(v) {
199
+ return v != null && typeof v[Symbol.asyncIterator] === "function";
200
+ }
201
+ function hydrateSignalFromAsyncIterable(coreFn, compute, value, options) {
202
+ const parent = signals.getOwner();
203
+ const expectedId = signals.peekNextChildId(parent);
204
+ if (!sharedConfig.has(expectedId)) return null;
205
+ const initP = sharedConfig.load(expectedId);
206
+ if (!isAsyncIterable(initP)) return null;
207
+ const [firstValue, iter] = consumeFirstSync(initP);
208
+ const [get, set] = signals.createSignal(firstValue);
209
+ const result = coreFn(() => get(), firstValue, options);
210
+ scheduleIteratorConsumption(iter, v => {
211
+ set(() => v);
212
+ signals.flush();
213
+ });
214
+ return result;
215
+ }
216
+ function hydrateStoreFromAsyncIterable(coreFn, initialValue, options) {
217
+ const parent = signals.getOwner();
218
+ const expectedId = signals.peekNextChildId(parent);
219
+ if (!sharedConfig.has(expectedId)) return null;
220
+ const initP = sharedConfig.load(expectedId);
221
+ if (!isAsyncIterable(initP)) return null;
222
+ const [firstState, iter] = consumeFirstSync(initP);
223
+ const [store, setStore] = coreFn(() => {}, firstState ?? initialValue, options);
224
+ scheduleIteratorConsumption(iter, patches => {
225
+ setStore(d => {
226
+ applyPatches(d, patches);
227
+ });
228
+ });
229
+ return [store, setStore];
230
+ }
106
231
  function hydratedCreateMemo(compute, value, options) {
107
232
  if (!sharedConfig.hydrating) return signals.createMemo(compute, value, options);
233
+ markTopLevelSnapshotScope();
234
+ const ssrSource = options?.ssrSource;
235
+ if (ssrSource === "client") {
236
+ const [hydrated, setHydrated] = signals.createSignal(false);
237
+ const memo = signals.createMemo(prev => {
238
+ if (!hydrated()) return prev ?? value;
239
+ return compute(prev);
240
+ }, value, options);
241
+ setHydrated(true);
242
+ return memo;
243
+ }
244
+ if (ssrSource === "initial") {
245
+ return signals.createMemo(prev => {
246
+ if (!sharedConfig.hydrating) return compute(prev);
247
+ subFetch(compute, prev);
248
+ return prev ?? value;
249
+ }, value, options);
250
+ }
251
+ const aiResult = hydrateSignalFromAsyncIterable(signals.createMemo, compute, value, options);
252
+ if (aiResult !== null) return aiResult;
108
253
  return signals.createMemo(prev => {
109
254
  const o = signals.getOwner();
110
255
  if (!sharedConfig.hydrating) return compute(prev);
@@ -116,6 +261,26 @@ function hydratedCreateMemo(compute, value, options) {
116
261
  }
117
262
  function hydratedCreateSignal(fn, second, third) {
118
263
  if (typeof fn !== "function" || !sharedConfig.hydrating) return signals.createSignal(fn, second, third);
264
+ markTopLevelSnapshotScope();
265
+ const ssrSource = third?.ssrSource;
266
+ if (ssrSource === "client") {
267
+ const [hydrated, setHydrated] = signals.createSignal(false);
268
+ const sig = signals.createSignal(prev => {
269
+ if (!hydrated()) return prev ?? second;
270
+ return fn(prev);
271
+ }, second, third);
272
+ setHydrated(true);
273
+ return sig;
274
+ }
275
+ if (ssrSource === "initial") {
276
+ return signals.createSignal(prev => {
277
+ if (!sharedConfig.hydrating) return fn(prev);
278
+ subFetch(fn, prev);
279
+ return prev ?? second;
280
+ }, second, third);
281
+ }
282
+ const aiResult = hydrateSignalFromAsyncIterable(signals.createSignal, fn, second, third);
283
+ if (aiResult !== null) return aiResult;
119
284
  return signals.createSignal(prev => {
120
285
  if (!sharedConfig.hydrating) return fn(prev);
121
286
  const o = signals.getOwner();
@@ -125,17 +290,260 @@ function hydratedCreateSignal(fn, second, third) {
125
290
  return init != null ? (subFetch(fn, prev), init) : fn(prev);
126
291
  }, second, third);
127
292
  }
293
+ function hydratedCreateErrorBoundary(fn, fallback) {
294
+ if (!sharedConfig.hydrating) return signals.createErrorBoundary(fn, fallback);
295
+ markTopLevelSnapshotScope();
296
+ const parent = signals.getOwner();
297
+ const expectedId = signals.peekNextChildId(parent);
298
+ if (sharedConfig.has(expectedId)) {
299
+ const err = sharedConfig.load(expectedId);
300
+ if (err !== undefined) {
301
+ let hydrated = true;
302
+ return signals.createErrorBoundary(() => {
303
+ if (hydrated) {
304
+ hydrated = false;
305
+ throw err;
306
+ }
307
+ return fn();
308
+ }, fallback);
309
+ }
310
+ }
311
+ return signals.createErrorBoundary(fn, fallback);
312
+ }
313
+ function hydratedCreateOptimistic(fn, second, third) {
314
+ if (typeof fn !== "function" || !sharedConfig.hydrating) return signals.createOptimistic(fn, second, third);
315
+ markTopLevelSnapshotScope();
316
+ const ssrSource = third?.ssrSource;
317
+ if (ssrSource === "client") {
318
+ const [hydrated, setHydrated] = signals.createSignal(false);
319
+ const sig = signals.createOptimistic(prev => {
320
+ if (!hydrated()) return prev ?? second;
321
+ return fn(prev);
322
+ }, second, third);
323
+ setHydrated(true);
324
+ return sig;
325
+ }
326
+ if (ssrSource === "initial") {
327
+ return signals.createOptimistic(prev => {
328
+ if (!sharedConfig.hydrating) return fn(prev);
329
+ subFetch(fn, prev);
330
+ return prev ?? second;
331
+ }, second, third);
332
+ }
333
+ const aiResult = hydrateSignalFromAsyncIterable(signals.createOptimistic, fn, second, third);
334
+ if (aiResult !== null) return aiResult;
335
+ return signals.createOptimistic(prev => {
336
+ const o = signals.getOwner();
337
+ if (!sharedConfig.hydrating) return fn(prev);
338
+ let initP;
339
+ if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
340
+ const init = initP?.v ?? initP;
341
+ return init != null ? (subFetch(fn, prev), init) : fn(prev);
342
+ }, second, third);
343
+ }
344
+ function wrapStoreFn(fn, ssrSource) {
345
+ if (ssrSource === "initial") {
346
+ return draft => {
347
+ if (!sharedConfig.hydrating) return fn(draft);
348
+ subFetch(fn, draft);
349
+ return undefined;
350
+ };
351
+ }
352
+ return draft => {
353
+ const o = signals.getOwner();
354
+ if (!sharedConfig.hydrating) return fn(draft);
355
+ let initP;
356
+ if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
357
+ const init = initP?.v ?? initP;
358
+ return init != null ? (subFetch(fn, draft), init) : fn(draft);
359
+ };
360
+ }
361
+ function hydratedCreateStore(first, second, third) {
362
+ if (typeof first !== "function" || !sharedConfig.hydrating) return signals.createStore(first, second, third);
363
+ markTopLevelSnapshotScope();
364
+ const ssrSource = third?.ssrSource;
365
+ if (ssrSource === "client" || ssrSource === "initial") {
366
+ return signals.createStore(second ?? {}, undefined, third);
367
+ }
368
+ const aiResult = hydrateStoreFromAsyncIterable(signals.createStore, second ?? {}, third);
369
+ if (aiResult !== null) return aiResult;
370
+ return signals.createStore(wrapStoreFn(first, ssrSource), second, third);
371
+ }
372
+ function hydratedCreateOptimisticStore(first, second, third) {
373
+ if (typeof first !== "function" || !sharedConfig.hydrating) return signals.createOptimisticStore(first, second, third);
374
+ markTopLevelSnapshotScope();
375
+ const ssrSource = third?.ssrSource;
376
+ if (ssrSource === "client" || ssrSource === "initial") {
377
+ return signals.createOptimisticStore(second ?? {}, undefined, third);
378
+ }
379
+ const aiResult = hydrateStoreFromAsyncIterable(signals.createOptimisticStore, second ?? {}, third);
380
+ if (aiResult !== null) return aiResult;
381
+ return signals.createOptimisticStore(wrapStoreFn(first, ssrSource), second, third);
382
+ }
383
+ function hydratedCreateProjection(fn, initialValue, options) {
384
+ if (!sharedConfig.hydrating) return signals.createProjection(fn, initialValue, options);
385
+ markTopLevelSnapshotScope();
386
+ const ssrSource = options?.ssrSource;
387
+ if (ssrSource === "client" || ssrSource === "initial") {
388
+ return signals.createProjection(draft => draft, initialValue, options);
389
+ }
390
+ const aiResult = hydrateStoreFromAsyncIterable(signals.createStore, initialValue, options);
391
+ if (aiResult !== null) return aiResult[0];
392
+ return signals.createProjection(wrapStoreFn(fn, ssrSource), initialValue, options);
393
+ }
394
+ function hydratedEffect(coreFn, compute, effectFn, value, options) {
395
+ if (!sharedConfig.hydrating) return coreFn(compute, effectFn, value, options);
396
+ const ssrSource = options?.ssrSource;
397
+ if (ssrSource === "client") {
398
+ const [hydrated, setHydrated] = signals.createSignal(false);
399
+ let active = false;
400
+ coreFn(prev => {
401
+ if (!hydrated()) return value;
402
+ active = true;
403
+ return compute(prev);
404
+ }, (next, prev) => {
405
+ if (!active) return;
406
+ return effectFn(next, prev);
407
+ }, value, options);
408
+ setHydrated(true);
409
+ return;
410
+ }
411
+ if (ssrSource === "initial") {
412
+ coreFn(prev => {
413
+ if (!sharedConfig.hydrating) return compute(prev);
414
+ subFetch(compute, prev);
415
+ return prev ?? value;
416
+ }, effectFn, value, options);
417
+ return;
418
+ }
419
+ markTopLevelSnapshotScope();
420
+ coreFn(prev => {
421
+ const o = signals.getOwner();
422
+ if (!sharedConfig.hydrating) return compute(prev);
423
+ let initP;
424
+ if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
425
+ const init = initP?.v ?? initP;
426
+ return init != null ? (subFetch(compute, prev), init) : compute(prev);
427
+ }, effectFn, value, options);
428
+ }
429
+ function hydratedCreateRenderEffect(compute, effectFn, value, options) {
430
+ return hydratedEffect(signals.createRenderEffect, compute, effectFn, value, options);
431
+ }
432
+ function hydratedCreateEffect(compute, effectFn, value, options) {
433
+ return hydratedEffect(signals.createEffect, compute, effectFn, value, options);
434
+ }
128
435
  function enableHydration() {
129
436
  _createMemo = hydratedCreateMemo;
130
437
  _createSignal = hydratedCreateSignal;
438
+ _createErrorBoundary = hydratedCreateErrorBoundary;
439
+ _createOptimistic = hydratedCreateOptimistic;
440
+ _createProjection = hydratedCreateProjection;
441
+ _createStore = hydratedCreateStore;
442
+ _createOptimisticStore = hydratedCreateOptimisticStore;
443
+ _createRenderEffect = hydratedCreateRenderEffect;
444
+ _createEffect = hydratedCreateEffect;
445
+ _hydratingValue = sharedConfig.hydrating;
446
+ _doneValue = sharedConfig.done;
447
+ Object.defineProperty(sharedConfig, "hydrating", {
448
+ get() {
449
+ return _hydratingValue;
450
+ },
451
+ set(v) {
452
+ const was = _hydratingValue;
453
+ _hydratingValue = v;
454
+ if (!was && v) {
455
+ _hydrationDone = false;
456
+ _doneValue = false;
457
+ _pendingBoundaries = 0;
458
+ signals.setSnapshotCapture(true);
459
+ _snapshotRootOwner = null;
460
+ } else if (was && !v) {
461
+ if (_snapshotRootOwner) {
462
+ signals.releaseSnapshotScope(_snapshotRootOwner);
463
+ _snapshotRootOwner = null;
464
+ }
465
+ checkHydrationComplete();
466
+ }
467
+ },
468
+ configurable: true,
469
+ enumerable: true
470
+ });
471
+ Object.defineProperty(sharedConfig, "done", {
472
+ get() {
473
+ return _doneValue;
474
+ },
475
+ set(v) {
476
+ _doneValue = v;
477
+ if (v) drainHydrationCallbacks();
478
+ },
479
+ configurable: true,
480
+ enumerable: true
481
+ });
131
482
  }
132
483
  const createMemo = (...args) => (_createMemo || signals.createMemo)(...args);
133
484
  const createSignal = (...args) => (_createSignal || signals.createSignal)(...args);
485
+ const createErrorBoundary = (...args) => (_createErrorBoundary || signals.createErrorBoundary)(...args);
486
+ const createOptimistic = (...args) => (_createOptimistic || signals.createOptimistic)(...args);
487
+ const createProjection = (...args) => (_createProjection || signals.createProjection)(...args);
488
+ const createStore = (...args) => (_createStore || signals.createStore)(...args);
489
+ const createOptimisticStore = (...args) => (_createOptimisticStore || signals.createOptimisticStore)(...args);
490
+ const createRenderEffect = (...args) => (_createRenderEffect || signals.createRenderEffect)(...args);
491
+ const createEffect = (...args) => (_createEffect || signals.createEffect)(...args);
492
+ function loadModuleAssets(mapping) {
493
+ const hy = globalThis._$HY;
494
+ if (!hy) return;
495
+ if (!hy.modules) hy.modules = {};
496
+ if (!hy.loading) hy.loading = {};
497
+ const pending = [];
498
+ for (const moduleUrl in mapping) {
499
+ if (hy.modules[moduleUrl]) continue;
500
+ const entryUrl = mapping[moduleUrl];
501
+ if (!hy.loading[moduleUrl]) {
502
+ hy.loading[moduleUrl] = import(entryUrl).then(mod => {
503
+ hy.modules[moduleUrl] = mod;
504
+ });
505
+ }
506
+ pending.push(hy.loading[moduleUrl]);
507
+ }
508
+ return pending.length ? Promise.all(pending).then(() => {}) : undefined;
509
+ }
510
+ function createBoundaryTrigger() {
511
+ signals.setSnapshotCapture(false);
512
+ const [s, set] = signals.createSignal(undefined, {
513
+ equals: false
514
+ });
515
+ s();
516
+ signals.setSnapshotCapture(true);
517
+ return set;
518
+ }
519
+ function resumeBoundaryHydration(o, id, set) {
520
+ _pendingBoundaries--;
521
+ if (signals.isDisposed(o)) {
522
+ checkHydrationComplete();
523
+ return;
524
+ }
525
+ sharedConfig.gather(id);
526
+ _hydratingValue = true;
527
+ signals.markSnapshotScope(o);
528
+ _snapshotRootOwner = o;
529
+ set();
530
+ signals.flush();
531
+ _snapshotRootOwner = null;
532
+ _hydratingValue = false;
533
+ signals.releaseSnapshotScope(o);
534
+ signals.flush();
535
+ checkHydrationComplete();
536
+ }
134
537
  function Loading(props) {
135
538
  if (!sharedConfig.hydrating) return signals.createLoadBoundary(() => props.children, () => props.fallback);
136
539
  return signals.createMemo(() => {
137
540
  const o = signals.getOwner();
138
541
  const id = o.id;
542
+ let assetPromise;
543
+ if (sharedConfig.hydrating && sharedConfig.has(id + "_assets")) {
544
+ const mapping = sharedConfig.load(id + "_assets");
545
+ if (mapping && typeof mapping === "object") assetPromise = loadModuleAssets(mapping);
546
+ }
139
547
  if (sharedConfig.hydrating && sharedConfig.has(id)) {
140
548
  let ref = sharedConfig.load(id);
141
549
  let p;
@@ -143,24 +551,38 @@ function Loading(props) {
143
551
  if (typeof ref !== "object" || ref.s !== 1) p = ref;else sharedConfig.gather(id);
144
552
  }
145
553
  if (p) {
146
- const [s, set] = signals.createSignal(undefined, {
147
- equals: false
554
+ _pendingBoundaries++;
555
+ signals.onCleanup(() => {
556
+ if (!signals.isDisposed(o)) return;
557
+ sharedConfig.cleanupFragment?.(id);
148
558
  });
149
- s();
559
+ const set = createBoundaryTrigger();
150
560
  if (p !== "$$f") {
151
- p.then(() => {
152
- sharedConfig.gather(id);
153
- sharedConfig.hydrating = true;
561
+ const waitFor = assetPromise ? Promise.all([p, assetPromise]) : p;
562
+ waitFor.then(() => resumeBoundaryHydration(o, id, set), err => {
563
+ _pendingBoundaries--;
564
+ checkHydrationComplete();
565
+ signals.runWithOwner(o, () => {
566
+ throw err;
567
+ });
568
+ });
569
+ } else {
570
+ const afterAssets = () => {
571
+ _pendingBoundaries--;
154
572
  set();
155
- signals.flush();
156
- sharedConfig.hydrating = false;
157
- }, err => signals.runWithOwner(o, () => {
158
- throw err;
159
- }));
160
- } else queueMicrotask(set);
573
+ checkHydrationComplete();
574
+ };
575
+ if (assetPromise) assetPromise.then(() => queueMicrotask(afterAssets));else queueMicrotask(afterAssets);
576
+ }
161
577
  return props.fallback;
162
578
  }
163
579
  }
580
+ if (assetPromise) {
581
+ _pendingBoundaries++;
582
+ const set = createBoundaryTrigger();
583
+ assetPromise.then(() => resumeBoundaryHydration(o, id, set));
584
+ return undefined;
585
+ }
164
586
  return signals.createLoadBoundary(() => props.children, () => props.fallback);
165
587
  });
166
588
  }
@@ -168,11 +590,24 @@ function Loading(props) {
168
590
  function createComponent(Comp, props) {
169
591
  return devComponent(Comp, props || {});
170
592
  }
171
- function lazy(fn) {
593
+ function lazy(fn, moduleUrl) {
172
594
  let comp;
173
595
  let p;
174
596
  const wrap = props => {
175
- comp = signals.createMemo(() => (p || (p = fn())).then(mod => mod.default));
597
+ if (sharedConfig.hydrating && moduleUrl) {
598
+ const cached = globalThis._$HY?.modules?.[moduleUrl];
599
+ if (!cached) {
600
+ throw new Error(`lazy() module "${moduleUrl}" was not preloaded before hydration. ` + "Ensure it is inside a Loading boundary.");
601
+ }
602
+ comp = () => cached.default;
603
+ }
604
+ if (!comp) {
605
+ p || (p = fn());
606
+ p.then(mod => {
607
+ comp = () => mod.default;
608
+ });
609
+ comp = signals.createMemo(() => p.then(mod => mod.default));
610
+ }
176
611
  let Comp;
177
612
  return signals.createMemo(() => (Comp = comp()) ? signals.untrack(() => {
178
613
  Object.assign(Comp, {
@@ -197,6 +632,7 @@ function For(props) {
197
632
  } : {
198
633
  keyed: props.keyed
199
634
  };
635
+ options.name = "<For>";
200
636
  return signals.mapArray(() => props.each, props.children, options);
201
637
  }
202
638
  function Repeat(props) {
@@ -204,6 +640,7 @@ function Repeat(props) {
204
640
  fallback: () => props.fallback
205
641
  } : {};
206
642
  options.from = () => props.from;
643
+ options.name = "<Repeat>";
207
644
  return signals.repeat(() => props.count, index => typeof props.children === "function" ? props.children(index) : props.children, options);
208
645
  }
209
646
  function Show(props) {
@@ -220,10 +657,17 @@ function Show(props) {
220
657
  if (c) {
221
658
  const child = props.children;
222
659
  const fn = typeof child === "function" && child.length > 0;
223
- return fn ? signals.untrack(() => child(() => {
224
- if (!signals.untrack(condition)) throw narrowedError("Show");
225
- return conditionValue();
226
- })) : child;
660
+ return fn ? signals.untrack(() => {
661
+ signals.setStrictRead("<Show>");
662
+ try {
663
+ return child(() => {
664
+ if (!signals.untrack(condition)) throw narrowedError("Show");
665
+ return conditionValue();
666
+ });
667
+ } finally {
668
+ signals.setStrictRead(false);
669
+ }
670
+ }) : child;
227
671
  }
228
672
  return props.fallback;
229
673
  }, undefined, {
@@ -256,10 +700,17 @@ function Switch(props) {
256
700
  const [index, conditionValue, mp] = sel;
257
701
  const child = mp.children;
258
702
  const fn = typeof child === "function" && child.length > 0;
259
- return fn ? signals.untrack(() => child(() => {
260
- if (signals.untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match");
261
- return conditionValue();
262
- })) : child;
703
+ return fn ? signals.untrack(() => {
704
+ signals.setStrictRead("<Match>");
705
+ try {
706
+ return child(() => {
707
+ if (signals.untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match");
708
+ return conditionValue();
709
+ });
710
+ } finally {
711
+ signals.setStrictRead(false);
712
+ }
713
+ }) : child;
263
714
  }, undefined, {
264
715
  name: "eval conditions"
265
716
  } );
@@ -268,7 +719,7 @@ function Match(props) {
268
719
  return props;
269
720
  }
270
721
  function Errored(props) {
271
- return signals.createErrorBoundary(() => props.children, (err, reset) => {
722
+ return createErrorBoundary(() => props.children, (err, reset) => {
272
723
  const f = props.fallback;
273
724
  if ((typeof f !== "function" || f.length == 0)) console.error(err);
274
725
  return typeof f === "function" && f.length ? f(err, reset) : f;
@@ -302,38 +753,18 @@ Object.defineProperty(exports, "action", {
302
753
  enumerable: true,
303
754
  get: function () { return signals.action; }
304
755
  });
305
- Object.defineProperty(exports, "createEffect", {
306
- enumerable: true,
307
- get: function () { return signals.createEffect; }
308
- });
309
- Object.defineProperty(exports, "createOptimistic", {
310
- enumerable: true,
311
- get: function () { return signals.createOptimistic; }
312
- });
313
- Object.defineProperty(exports, "createOptimisticStore", {
314
- enumerable: true,
315
- get: function () { return signals.createOptimisticStore; }
316
- });
317
- Object.defineProperty(exports, "createProjection", {
756
+ Object.defineProperty(exports, "createOwner", {
318
757
  enumerable: true,
319
- get: function () { return signals.createProjection; }
758
+ get: function () { return signals.createOwner; }
320
759
  });
321
760
  Object.defineProperty(exports, "createReaction", {
322
761
  enumerable: true,
323
762
  get: function () { return signals.createReaction; }
324
763
  });
325
- Object.defineProperty(exports, "createRenderEffect", {
326
- enumerable: true,
327
- get: function () { return signals.createRenderEffect; }
328
- });
329
764
  Object.defineProperty(exports, "createRoot", {
330
765
  enumerable: true,
331
766
  get: function () { return signals.createRoot; }
332
767
  });
333
- Object.defineProperty(exports, "createStore", {
334
- enumerable: true,
335
- get: function () { return signals.createStore; }
336
- });
337
768
  Object.defineProperty(exports, "createTrackedEffect", {
338
769
  enumerable: true,
339
770
  get: function () { return signals.createTrackedEffect; }
@@ -350,6 +781,10 @@ Object.defineProperty(exports, "flush", {
350
781
  enumerable: true,
351
782
  get: function () { return signals.flush; }
352
783
  });
784
+ Object.defineProperty(exports, "getNextChildId", {
785
+ enumerable: true,
786
+ get: function () { return signals.getNextChildId; }
787
+ });
353
788
  Object.defineProperty(exports, "getObserver", {
354
789
  enumerable: true,
355
790
  get: function () { return signals.getObserver; }
@@ -374,6 +809,10 @@ Object.defineProperty(exports, "isWrappable", {
374
809
  enumerable: true,
375
810
  get: function () { return signals.isWrappable; }
376
811
  });
812
+ Object.defineProperty(exports, "latest", {
813
+ enumerable: true,
814
+ get: function () { return signals.latest; }
815
+ });
377
816
  Object.defineProperty(exports, "mapArray", {
378
817
  enumerable: true,
379
818
  get: function () { return signals.mapArray; }
@@ -394,10 +833,6 @@ Object.defineProperty(exports, "onSettled", {
394
833
  enumerable: true,
395
834
  get: function () { return signals.onSettled; }
396
835
  });
397
- Object.defineProperty(exports, "pending", {
398
- enumerable: true,
399
- get: function () { return signals.pending; }
400
- });
401
836
  Object.defineProperty(exports, "reconcile", {
402
837
  enumerable: true,
403
838
  get: function () { return signals.reconcile; }
@@ -422,6 +857,10 @@ Object.defineProperty(exports, "snapshot", {
422
857
  enumerable: true,
423
858
  get: function () { return signals.snapshot; }
424
859
  });
860
+ Object.defineProperty(exports, "storePath", {
861
+ enumerable: true,
862
+ get: function () { return signals.storePath; }
863
+ });
425
864
  Object.defineProperty(exports, "untrack", {
426
865
  enumerable: true,
427
866
  get: function () { return signals.untrack; }
@@ -438,8 +877,14 @@ exports.Switch = Switch;
438
877
  exports.children = children;
439
878
  exports.createComponent = createComponent;
440
879
  exports.createContext = createContext;
880
+ exports.createEffect = createEffect;
441
881
  exports.createMemo = createMemo;
882
+ exports.createOptimistic = createOptimistic;
883
+ exports.createOptimisticStore = createOptimisticStore;
884
+ exports.createProjection = createProjection;
885
+ exports.createRenderEffect = createRenderEffect;
442
886
  exports.createSignal = createSignal;
887
+ exports.createStore = createStore;
443
888
  exports.createUniqueId = createUniqueId;
444
889
  exports.enableHydration = enableHydration;
445
890
  exports.lazy = lazy;