solid-js 1.8.4 → 1.8.5

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.
Files changed (44) hide show
  1. package/dist/dev.cjs +1 -1
  2. package/dist/dev.js +299 -534
  3. package/dist/server.js +75 -170
  4. package/dist/solid.cjs +1 -1
  5. package/dist/solid.js +257 -461
  6. package/h/dist/h.js +8 -34
  7. package/h/jsx-runtime/dist/jsx.js +1 -1
  8. package/h/jsx-runtime/types/index.d.ts +8 -11
  9. package/h/types/hyperscript.d.ts +11 -11
  10. package/html/dist/html.js +94 -216
  11. package/html/types/lit.d.ts +33 -47
  12. package/package.json +1 -1
  13. package/store/dist/dev.js +42 -114
  14. package/store/dist/server.js +8 -19
  15. package/store/dist/store.js +39 -105
  16. package/store/types/index.d.ts +7 -21
  17. package/store/types/modifiers.d.ts +3 -6
  18. package/store/types/mutable.d.ts +2 -5
  19. package/store/types/server.d.ts +4 -12
  20. package/store/types/store.d.ts +61 -218
  21. package/types/index.d.ts +9 -72
  22. package/types/reactive/array.d.ts +4 -12
  23. package/types/reactive/observable.d.ts +17 -25
  24. package/types/reactive/scheduler.d.ts +6 -9
  25. package/types/reactive/signal.d.ts +140 -228
  26. package/types/render/Suspense.d.ts +5 -5
  27. package/types/render/component.d.ts +31 -62
  28. package/types/render/flow.d.ts +31 -43
  29. package/types/render/hydration.d.ts +13 -13
  30. package/types/server/index.d.ts +2 -57
  31. package/types/server/reactive.d.ts +42 -73
  32. package/types/server/rendering.d.ts +95 -166
  33. package/universal/dist/dev.js +12 -28
  34. package/universal/dist/universal.js +12 -28
  35. package/universal/types/index.d.ts +1 -3
  36. package/universal/types/universal.d.ts +1 -0
  37. package/web/dist/dev.js +81 -619
  38. package/web/dist/server.js +94 -177
  39. package/web/dist/storage.js +3 -3
  40. package/web/dist/web.js +80 -613
  41. package/web/types/client.d.ts +2 -2
  42. package/web/types/core.d.ts +1 -10
  43. package/web/types/index.d.ts +10 -27
  44. package/web/types/server-mock.d.ts +32 -47
package/dist/solid.js CHANGED
@@ -52,11 +52,9 @@ function enqueue(taskQueue, task) {
52
52
  let m = 0;
53
53
  let n = taskQueue.length - 1;
54
54
  while (m <= n) {
55
- const k = (n + m) >> 1;
55
+ const k = n + m >> 1;
56
56
  const cmp = task.expirationTime - taskQueue[k].expirationTime;
57
- if (cmp > 0) m = k + 1;
58
- else if (cmp < 0) n = k - 1;
59
- else return k;
57
+ if (cmp > 0) m = k + 1;else if (cmp < 0) n = k - 1;else return k;
60
58
  }
61
59
  return m;
62
60
  }
@@ -157,20 +155,18 @@ let Listener = null;
157
155
  let Updates = null;
158
156
  let Effects = null;
159
157
  let ExecCount = 0;
160
- const [transPending, setTransPending] = /*@__PURE__*/ createSignal(false);
158
+ const [transPending, setTransPending] = /*@__PURE__*/createSignal(false);
161
159
  function createRoot(fn, detachedOwner) {
162
160
  const listener = Listener,
163
161
  owner = Owner,
164
162
  unowned = fn.length === 0,
165
163
  current = detachedOwner === undefined ? owner : detachedOwner,
166
- root = unowned
167
- ? UNOWNED
168
- : {
169
- owned: null,
170
- cleanups: null,
171
- context: current ? current.context : null,
172
- owner: current
173
- },
164
+ root = unowned ? UNOWNED : {
165
+ owned: null,
166
+ cleanups: null,
167
+ context: current ? current.context : null,
168
+ owner: current
169
+ },
174
170
  updateFn = unowned ? fn : () => fn(() => untrack(() => cleanNode(root)));
175
171
  Owner = root;
176
172
  Listener = null;
@@ -191,8 +187,7 @@ function createSignal(value, options) {
191
187
  };
192
188
  const setter = value => {
193
189
  if (typeof value === "function") {
194
- if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.tValue);
195
- else value = value(s.value);
190
+ if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.tValue);else value = value(s.value);
196
191
  }
197
192
  return writeSignal(s, value);
198
193
  };
@@ -200,13 +195,11 @@ function createSignal(value, options) {
200
195
  }
201
196
  function createComputed(fn, value, options) {
202
197
  const c = createComputation(fn, value, true, STALE);
203
- if (Scheduler && Transition && Transition.running) Updates.push(c);
204
- else updateComputation(c);
198
+ if (Scheduler && Transition && Transition.running) Updates.push(c);else updateComputation(c);
205
199
  }
206
200
  function createRenderEffect(fn, value, options) {
207
201
  const c = createComputation(fn, value, false, STALE);
208
- if (Scheduler && Transition && Transition.running) Updates.push(c);
209
- else updateComputation(c);
202
+ if (Scheduler && Transition && Transition.running) Updates.push(c);else updateComputation(c);
210
203
  }
211
204
  function createEffect(fn, value, options) {
212
205
  runEffects = runUserEffects;
@@ -218,15 +211,10 @@ function createEffect(fn, value, options) {
218
211
  }
219
212
  function createReaction(onInvalidate, options) {
220
213
  let fn;
221
- const c = createComputation(
222
- () => {
223
- fn ? fn() : untrack(onInvalidate);
224
- fn = undefined;
225
- },
226
- undefined,
227
- false,
228
- 0
229
- ),
214
+ const c = createComputation(() => {
215
+ fn ? fn() : untrack(onInvalidate);
216
+ fn = undefined;
217
+ }, undefined, false, 0),
230
218
  s = SuspenseContext && useContext(SuspenseContext);
231
219
  if (s) c.suspense = s;
232
220
  c.user = true;
@@ -254,7 +242,7 @@ function createResource(pSource, pFetcher, pOptions) {
254
242
  let source;
255
243
  let fetcher;
256
244
  let options;
257
- if ((arguments.length === 2 && typeof pFetcher === "object") || arguments.length === 1) {
245
+ if (arguments.length === 2 && typeof pFetcher === "object" || arguments.length === 1) {
258
246
  source = true;
259
247
  fetcher = pSource;
260
248
  options = pFetcher || {};
@@ -268,7 +256,7 @@ function createResource(pSource, pFetcher, pOptions) {
268
256
  id = null,
269
257
  loadedUnderTransition = false,
270
258
  scheduled = false,
271
- resolved = "initialValue" in options,
259
+ resolved = ("initialValue" in options),
272
260
  dynamic = typeof source === "function" && createMemo(source);
273
261
  const contexts = new Set(),
274
262
  [value, setValue] = (options.storage || createSignal)(options.initialValue),
@@ -280,19 +268,15 @@ function createResource(pSource, pFetcher, pOptions) {
280
268
  if (sharedConfig.context) {
281
269
  id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
282
270
  let v;
283
- if (options.ssrLoadFrom === "initial") initP = options.initialValue;
284
- else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v;
271
+ if (options.ssrLoadFrom === "initial") initP = options.initialValue;else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v;
285
272
  }
286
273
  function loadEnd(p, v, error, key) {
287
274
  if (pr === p) {
288
275
  pr = null;
289
276
  key !== undefined && (resolved = true);
290
- if ((p === initP || v === initP) && options.onHydrated)
291
- queueMicrotask(() =>
292
- options.onHydrated(key, {
293
- value: v
294
- })
295
- );
277
+ if ((p === initP || v === initP) && options.onHydrated) queueMicrotask(() => options.onHydrated(key, {
278
+ value: v
279
+ }));
296
280
  initP = NO_INIT;
297
281
  if (Transition && p && loadedUnderTransition) {
298
282
  Transition.promises.delete(p);
@@ -323,8 +307,7 @@ function createResource(pSource, pFetcher, pOptions) {
323
307
  createComputed(() => {
324
308
  track();
325
309
  if (pr) {
326
- if (c.resolved && Transition && loadedUnderTransition) Transition.promises.add(pr);
327
- else if (!contexts.has(c)) {
310
+ if (c.resolved && Transition && loadedUnderTransition) Transition.promises.add(pr);else if (!contexts.has(c)) {
328
311
  c.increment();
329
312
  contexts.add(c);
330
313
  }
@@ -343,35 +326,26 @@ function createResource(pSource, pFetcher, pOptions) {
343
326
  return;
344
327
  }
345
328
  if (Transition && pr) Transition.promises.delete(pr);
346
- const p =
347
- initP !== NO_INIT
348
- ? initP
349
- : untrack(() =>
350
- fetcher(lookup, {
351
- value: value(),
352
- refetching
353
- })
354
- );
329
+ const p = initP !== NO_INIT ? initP : untrack(() => fetcher(lookup, {
330
+ value: value(),
331
+ refetching
332
+ }));
355
333
  if (!isPromise(p)) {
356
334
  loadEnd(pr, p, undefined, lookup);
357
335
  return p;
358
336
  }
337
+ pr = p;
359
338
  if ("value" in p) {
360
- if (p.status === "success") loadEnd(pr, p.value, undefined, lookup);
361
- else loadEnd(pr, undefined, undefined, lookup);
339
+ if (p.status === "success") loadEnd(pr, p.value, undefined, lookup);else loadEnd(pr, undefined, undefined, lookup);
362
340
  return p;
363
341
  }
364
- pr = p;
365
342
  scheduled = true;
366
- queueMicrotask(() => (scheduled = false));
343
+ queueMicrotask(() => scheduled = false);
367
344
  runUpdates(() => {
368
345
  setState(resolved ? "refreshing" : "pending");
369
346
  trigger();
370
347
  }, false);
371
- return p.then(
372
- v => loadEnd(p, v, undefined, lookup),
373
- e => loadEnd(p, undefined, castError(e), lookup)
374
- );
348
+ return p.then(v => loadEnd(p, v, undefined, lookup), e => loadEnd(p, undefined, castError(e), lookup));
375
349
  }
376
350
  Object.defineProperties(read, {
377
351
  state: {
@@ -395,80 +369,50 @@ function createResource(pSource, pFetcher, pOptions) {
395
369
  }
396
370
  }
397
371
  });
398
- if (dynamic) createComputed(() => load(false));
399
- else load(false);
400
- return [
401
- read,
402
- {
403
- refetch: load,
404
- mutate: setValue
405
- }
406
- ];
372
+ if (dynamic) createComputed(() => load(false));else load(false);
373
+ return [read, {
374
+ refetch: load,
375
+ mutate: setValue
376
+ }];
407
377
  }
408
378
  function createDeferred(source, options) {
409
379
  let t,
410
380
  timeout = options ? options.timeoutMs : undefined;
411
- const node = createComputation(
412
- () => {
413
- if (!t || !t.fn)
414
- t = requestCallback(
415
- () => setDeferred(() => node.value),
416
- timeout !== undefined
417
- ? {
418
- timeout
419
- }
420
- : undefined
421
- );
422
- return source();
423
- },
424
- undefined,
425
- true
426
- );
427
- const [deferred, setDeferred] = createSignal(
428
- Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
429
- options
430
- );
381
+ const node = createComputation(() => {
382
+ if (!t || !t.fn) t = requestCallback(() => setDeferred(() => node.value), timeout !== undefined ? {
383
+ timeout
384
+ } : undefined);
385
+ return source();
386
+ }, undefined, true);
387
+ const [deferred, setDeferred] = createSignal(Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value, options);
431
388
  updateComputation(node);
432
- setDeferred(() =>
433
- Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value
434
- );
389
+ setDeferred(() => Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value);
435
390
  return deferred;
436
391
  }
437
392
  function createSelector(source, fn = equalFn, options) {
438
393
  const subs = new Map();
439
- const node = createComputation(
440
- p => {
441
- const v = source();
442
- for (const [key, val] of subs.entries())
443
- if (fn(key, v) !== fn(key, p)) {
444
- for (const c of val.values()) {
445
- c.state = STALE;
446
- if (c.pure) Updates.push(c);
447
- else Effects.push(c);
448
- }
449
- }
450
- return v;
451
- },
452
- undefined,
453
- true,
454
- STALE
455
- );
394
+ const node = createComputation(p => {
395
+ const v = source();
396
+ for (const [key, val] of subs.entries()) if (fn(key, v) !== fn(key, p)) {
397
+ for (const c of val.values()) {
398
+ c.state = STALE;
399
+ if (c.pure) Updates.push(c);else Effects.push(c);
400
+ }
401
+ }
402
+ return v;
403
+ }, undefined, true, STALE);
456
404
  updateComputation(node);
457
405
  return key => {
458
406
  const listener = Listener;
459
407
  if (listener) {
460
408
  let l;
461
- if ((l = subs.get(key))) l.add(listener);
462
- else subs.set(key, (l = new Set([listener])));
409
+ if (l = subs.get(key)) l.add(listener);else subs.set(key, l = new Set([listener]));
463
410
  onCleanup(() => {
464
411
  l.delete(listener);
465
412
  !l.size && subs.delete(key);
466
413
  });
467
414
  }
468
- return fn(
469
- key,
470
- Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value
471
- );
415
+ return fn(key, Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value);
472
416
  };
473
417
  }
474
418
  function batch(fn) {
@@ -507,9 +451,7 @@ function onMount(fn) {
507
451
  createEffect(() => untrack(fn));
508
452
  }
509
453
  function onCleanup(fn) {
510
- if (Owner === null);
511
- else if (Owner.cleanups === null) Owner.cleanups = [fn];
512
- else Owner.cleanups.push(fn);
454
+ if (Owner === null) ;else if (Owner.cleanups === null) Owner.cleanups = [fn];else Owner.cleanups.push(fn);
513
455
  return fn;
514
456
  }
515
457
  function catchError(fn, handler) {
@@ -563,17 +505,15 @@ function startTransition(fn) {
563
505
  Owner = o;
564
506
  let t;
565
507
  if (Scheduler || SuspenseContext) {
566
- t =
567
- Transition ||
568
- (Transition = {
569
- sources: new Set(),
570
- effects: [],
571
- promises: new Set(),
572
- disposed: new Set(),
573
- queue: new Set(),
574
- running: true
575
- });
576
- t.done || (t.done = new Promise(res => (t.resolve = res)));
508
+ t = Transition || (Transition = {
509
+ sources: new Set(),
510
+ effects: [],
511
+ promises: new Set(),
512
+ disposed: new Set(),
513
+ queue: new Set(),
514
+ running: true
515
+ });
516
+ t.done || (t.done = new Promise(res => t.resolve = res));
577
517
  t.running = true;
578
518
  }
579
519
  runUpdates(fn, false);
@@ -597,9 +537,7 @@ function createContext(defaultValue, options) {
597
537
  };
598
538
  }
599
539
  function useContext(context) {
600
- return Owner && Owner.context && Owner.context[context.id] !== undefined
601
- ? Owner.context[context.id]
602
- : context.defaultValue;
540
+ return Owner && Owner.context && Owner.context[context.id] !== undefined ? Owner.context[context.id] : context.defaultValue;
603
541
  }
604
542
  function children(fn) {
605
543
  const children = createMemo(fn);
@@ -635,8 +573,7 @@ function enableExternalSource(factory) {
635
573
  function readSignal() {
636
574
  const runningTransition = Transition && Transition.running;
637
575
  if (this.sources && (runningTransition ? this.tState : this.state)) {
638
- if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);
639
- else {
576
+ if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);else {
640
577
  const updates = Updates;
641
578
  Updates = null;
642
579
  runUpdates(() => lookUpstream(this), false);
@@ -664,12 +601,11 @@ function readSignal() {
664
601
  return this.value;
665
602
  }
666
603
  function writeSignal(node, value, isComp) {
667
- let current =
668
- Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value;
604
+ let current = Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value;
669
605
  if (!node.comparator || !node.comparator(current, value)) {
670
606
  if (Transition) {
671
607
  const TransitionRunning = Transition.running;
672
- if (TransitionRunning || (!isComp && Transition.sources.has(node))) {
608
+ if (TransitionRunning || !isComp && Transition.sources.has(node)) {
673
609
  Transition.sources.add(node);
674
610
  node.tValue = value;
675
611
  }
@@ -682,16 +618,14 @@ function writeSignal(node, value, isComp) {
682
618
  const TransitionRunning = Transition && Transition.running;
683
619
  if (TransitionRunning && Transition.disposed.has(o)) continue;
684
620
  if (TransitionRunning ? !o.tState : !o.state) {
685
- if (o.pure) Updates.push(o);
686
- else Effects.push(o);
621
+ if (o.pure) Updates.push(o);else Effects.push(o);
687
622
  if (o.observers) markDownstream(o);
688
623
  }
689
- if (!TransitionRunning) o.state = STALE;
690
- else o.tState = STALE;
624
+ if (!TransitionRunning) o.state = STALE;else o.tState = STALE;
691
625
  }
692
626
  if (Updates.length > 10e5) {
693
627
  Updates = [];
694
- if (false);
628
+ if (false) ;
695
629
  throw new Error();
696
630
  }
697
631
  }, false);
@@ -706,11 +640,7 @@ function updateComputation(node) {
706
640
  listener = Listener,
707
641
  time = ExecCount;
708
642
  Listener = Owner = node;
709
- runComputation(
710
- node,
711
- Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
712
- time
713
- );
643
+ runComputation(node, Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value, time);
714
644
  if (Transition && !Transition.running && Transition.sources.has(node)) {
715
645
  queueMicrotask(() => {
716
646
  runUpdates(() => {
@@ -771,14 +701,11 @@ function createComputation(fn, init, pure, state = STALE, options) {
771
701
  c.state = 0;
772
702
  c.tState = state;
773
703
  }
774
- if (Owner === null);
775
- else if (Owner !== UNOWNED) {
704
+ if (Owner === null) ;else if (Owner !== UNOWNED) {
776
705
  if (Transition && Transition.running && Owner.pure) {
777
- if (!Owner.tOwned) Owner.tOwned = [c];
778
- else Owner.tOwned.push(c);
706
+ if (!Owner.tOwned) Owner.tOwned = [c];else Owner.tOwned.push(c);
779
707
  } else {
780
- if (!Owner.owned) Owner.owned = [c];
781
- else Owner.owned.push(c);
708
+ if (!Owner.owned) Owner.owned = [c];else Owner.owned.push(c);
782
709
  }
783
710
  }
784
711
  if (ExternalSourceFactory) {
@@ -829,8 +756,7 @@ function runUpdates(fn, init) {
829
756
  if (Updates) return fn();
830
757
  let wait = false;
831
758
  if (!init) Updates = [];
832
- if (Effects) wait = true;
833
- else Effects = [];
759
+ if (Effects) wait = true;else Effects = [];
834
760
  ExecCount++;
835
761
  try {
836
762
  const res = fn();
@@ -844,8 +770,7 @@ function runUpdates(fn, init) {
844
770
  }
845
771
  function completeUpdates(wait) {
846
772
  if (Updates) {
847
- if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);
848
- else runQueue(Updates);
773
+ if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);else runQueue(Updates);
849
774
  Updates = null;
850
775
  }
851
776
  if (wait) return;
@@ -913,8 +838,7 @@ function runUserEffects(queue) {
913
838
  userLength = 0;
914
839
  for (i = 0; i < queue.length; i++) {
915
840
  const e = queue[i];
916
- if (!e.user) runTop(e);
917
- else queue[userLength++] = e;
841
+ if (!e.user) runTop(e);else queue[userLength++] = e;
918
842
  }
919
843
  if (sharedConfig.context) {
920
844
  if (sharedConfig.count) {
@@ -932,15 +856,13 @@ function runUserEffects(queue) {
932
856
  }
933
857
  function lookUpstream(node, ignore) {
934
858
  const runningTransition = Transition && Transition.running;
935
- if (runningTransition) node.tState = 0;
936
- else node.state = 0;
859
+ if (runningTransition) node.tState = 0;else node.state = 0;
937
860
  for (let i = 0; i < node.sources.length; i += 1) {
938
861
  const source = node.sources[i];
939
862
  if (source.sources) {
940
863
  const state = runningTransition ? source.tState : source.state;
941
864
  if (state === STALE) {
942
- if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
943
- runTop(source);
865
+ if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount)) runTop(source);
944
866
  } else if (state === PENDING) lookUpstream(source, ignore);
945
867
  }
946
868
  }
@@ -950,10 +872,8 @@ function markDownstream(node) {
950
872
  for (let i = 0; i < node.observers.length; i += 1) {
951
873
  const o = node.observers[i];
952
874
  if (runningTransition ? !o.tState : !o.state) {
953
- if (runningTransition) o.tState = PENDING;
954
- else o.state = PENDING;
955
- if (o.pure) Updates.push(o);
956
- else Effects.push(o);
875
+ if (runningTransition) o.tState = PENDING;else o.state = PENDING;
876
+ if (o.pure) Updates.push(o);else Effects.push(o);
957
877
  o.observers && markDownstream(o);
958
878
  }
959
879
  }
@@ -990,8 +910,7 @@ function cleanNode(node) {
990
910
  for (i = node.cleanups.length - 1; i >= 0; i--) node.cleanups[i]();
991
911
  node.cleanups = null;
992
912
  }
993
- if (Transition && Transition.running) node.tState = 0;
994
- else node.state = 0;
913
+ if (Transition && Transition.running) node.tState = 0;else node.state = 0;
995
914
  }
996
915
  function reset(node, top) {
997
916
  if (!top) {
@@ -1012,21 +931,19 @@ function runErrors(err, fns, owner) {
1012
931
  try {
1013
932
  for (const f of fns) f(err);
1014
933
  } catch (e) {
1015
- handleError(e, (owner && owner.owner) || null);
934
+ handleError(e, owner && owner.owner || null);
1016
935
  }
1017
936
  }
1018
937
  function handleError(err, owner = Owner) {
1019
938
  const fns = ERROR && owner && owner.context && owner.context[ERROR];
1020
939
  const error = castError(err);
1021
940
  if (!fns) throw error;
1022
- if (Effects)
1023
- Effects.push({
1024
- fn() {
1025
- runErrors(error, fns, owner);
1026
- },
1027
- state: STALE
1028
- });
1029
- else runErrors(error, fns, owner);
941
+ if (Effects) Effects.push({
942
+ fn() {
943
+ runErrors(error, fns, owner);
944
+ },
945
+ state: STALE
946
+ });else runErrors(error, fns, owner);
1030
947
  }
1031
948
  function resolveChildren(children) {
1032
949
  if (typeof children === "function" && !children.length) return resolveChildren(children());
@@ -1043,24 +960,19 @@ function resolveChildren(children) {
1043
960
  function createProvider(id, options) {
1044
961
  return function provider(props) {
1045
962
  let res;
1046
- createRenderEffect(
1047
- () =>
1048
- (res = untrack(() => {
1049
- Owner.context = {
1050
- ...Owner.context,
1051
- [id]: props.value
1052
- };
1053
- return children(() => props.children);
1054
- })),
1055
- undefined
1056
- );
963
+ createRenderEffect(() => res = untrack(() => {
964
+ Owner.context = {
965
+ ...Owner.context,
966
+ [id]: props.value
967
+ };
968
+ return children(() => props.children);
969
+ }), undefined);
1057
970
  return res;
1058
971
  };
1059
972
  }
1060
973
  function onError(fn) {
1061
974
  ERROR || (ERROR = Symbol("error"));
1062
- if (Owner === null);
1063
- else if (Owner.context === null || !Owner.context[ERROR]) {
975
+ if (Owner === null) ;else if (Owner.context === null || !Owner.context[ERROR]) {
1064
976
  Owner.context = {
1065
977
  ...Owner.context,
1066
978
  [ERROR]: [fn]
@@ -1089,8 +1001,7 @@ function observable(input) {
1089
1001
  if (!(observer instanceof Object) || observer == null) {
1090
1002
  throw new TypeError("Expected the observer to be an object.");
1091
1003
  }
1092
- const handler =
1093
- typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
1004
+ const handler = typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
1094
1005
  if (!handler) {
1095
1006
  return {
1096
1007
  unsubscribe() {}
@@ -1121,7 +1032,7 @@ function from(producer) {
1121
1032
  });
1122
1033
  if ("subscribe" in producer) {
1123
1034
  const unsub = producer.subscribe(v => set(() => v));
1124
- onCleanup(() => ("unsubscribe" in unsub ? unsub.unsubscribe() : unsub()));
1035
+ onCleanup(() => "unsubscribe" in unsub ? unsub.unsubscribe() : unsub());
1125
1036
  } else {
1126
1037
  const clean = producer(set);
1127
1038
  onCleanup(clean);
@@ -1173,7 +1084,8 @@ function mapArray(list, mapFn, options = {}) {
1173
1084
  });
1174
1085
  len = 1;
1175
1086
  }
1176
- } else if (len === 0) {
1087
+ }
1088
+ else if (len === 0) {
1177
1089
  mapped = new Array(newLen);
1178
1090
  for (j = 0; j < newLen; j++) {
1179
1091
  items[j] = newItems[j];
@@ -1184,16 +1096,8 @@ function mapArray(list, mapFn, options = {}) {
1184
1096
  temp = new Array(newLen);
1185
1097
  tempdisposers = new Array(newLen);
1186
1098
  indexes && (tempIndexes = new Array(newLen));
1187
- for (
1188
- start = 0, end = Math.min(len, newLen);
1189
- start < end && items[start] === newItems[start];
1190
- start++
1191
- );
1192
- for (
1193
- end = len - 1, newEnd = newLen - 1;
1194
- end >= start && newEnd >= start && items[end] === newItems[newEnd];
1195
- end--, newEnd--
1196
- ) {
1099
+ for (start = 0, end = Math.min(len, newLen); start < end && items[start] === newItems[start]; start++);
1100
+ for (end = len - 1, newEnd = newLen - 1; end >= start && newEnd >= start && items[end] === newItems[newEnd]; end--, newEnd--) {
1197
1101
  temp[newEnd] = mapped[end];
1198
1102
  tempdisposers[newEnd] = disposers[end];
1199
1103
  indexes && (tempIndexes[newEnd] = indexes[end]);
@@ -1227,7 +1131,7 @@ function mapArray(list, mapFn, options = {}) {
1227
1131
  }
1228
1132
  } else mapped[j] = createRoot(mapper);
1229
1133
  }
1230
- mapped = mapped.slice(0, (len = newLen));
1134
+ mapped = mapped.slice(0, len = newLen);
1231
1135
  items = newItems.slice(0);
1232
1136
  }
1233
1137
  return mapped;
@@ -1293,7 +1197,7 @@ function indexArray(list, mapFn, options = {}) {
1293
1197
  }
1294
1198
  len = signals.length = disposers.length = newItems.length;
1295
1199
  items = newItems.slice(0);
1296
- return (mapped = mapped.slice(0, len));
1200
+ return mapped = mapped.slice(0, len);
1297
1201
  });
1298
1202
  function mapper(disposer) {
1299
1203
  disposers[i] = disposer;
@@ -1362,33 +1266,29 @@ function mergeProps(...sources) {
1362
1266
  let proxy = false;
1363
1267
  for (let i = 0; i < sources.length; i++) {
1364
1268
  const s = sources[i];
1365
- proxy = proxy || (!!s && $PROXY in s);
1366
- sources[i] = typeof s === "function" ? ((proxy = true), createMemo(s)) : s;
1269
+ proxy = proxy || !!s && $PROXY in s;
1270
+ sources[i] = typeof s === "function" ? (proxy = true, createMemo(s)) : s;
1367
1271
  }
1368
1272
  if (proxy) {
1369
- return new Proxy(
1370
- {
1371
- get(property) {
1372
- for (let i = sources.length - 1; i >= 0; i--) {
1373
- const v = resolveSource(sources[i])[property];
1374
- if (v !== undefined) return v;
1375
- }
1376
- },
1377
- has(property) {
1378
- for (let i = sources.length - 1; i >= 0; i--) {
1379
- if (property in resolveSource(sources[i])) return true;
1380
- }
1381
- return false;
1382
- },
1383
- keys() {
1384
- const keys = [];
1385
- for (let i = 0; i < sources.length; i++)
1386
- keys.push(...Object.keys(resolveSource(sources[i])));
1387
- return [...new Set(keys)];
1273
+ return new Proxy({
1274
+ get(property) {
1275
+ for (let i = sources.length - 1; i >= 0; i--) {
1276
+ const v = resolveSource(sources[i])[property];
1277
+ if (v !== undefined) return v;
1388
1278
  }
1389
1279
  },
1390
- propTraps
1391
- );
1280
+ has(property) {
1281
+ for (let i = sources.length - 1; i >= 0; i--) {
1282
+ if (property in resolveSource(sources[i])) return true;
1283
+ }
1284
+ return false;
1285
+ },
1286
+ keys() {
1287
+ const keys = [];
1288
+ for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(resolveSource(sources[i])));
1289
+ return [...new Set(keys)];
1290
+ }
1291
+ }, propTraps);
1392
1292
  }
1393
1293
  const target = {};
1394
1294
  const sourcesMap = {};
@@ -1407,7 +1307,7 @@ function mergeProps(...sources) {
1407
1307
  Object.defineProperty(target, key, {
1408
1308
  enumerable: true,
1409
1309
  configurable: true,
1410
- get: resolveSources.bind((sourcesMap[key] = [desc.get.bind(source)]))
1310
+ get: resolveSources.bind(sourcesMap[key] = [desc.get.bind(source)])
1411
1311
  });
1412
1312
  } else {
1413
1313
  if (desc.value !== undefined) defined.add(key);
@@ -1431,60 +1331,47 @@ function splitProps(props, ...keys) {
1431
1331
  if ($PROXY in props) {
1432
1332
  const blocked = new Set(keys.length > 1 ? keys.flat() : keys[0]);
1433
1333
  const res = keys.map(k => {
1434
- return new Proxy(
1435
- {
1436
- get(property) {
1437
- return k.includes(property) ? props[property] : undefined;
1438
- },
1439
- has(property) {
1440
- return k.includes(property) && property in props;
1441
- },
1442
- keys() {
1443
- return k.filter(property => property in props);
1444
- }
1334
+ return new Proxy({
1335
+ get(property) {
1336
+ return k.includes(property) ? props[property] : undefined;
1445
1337
  },
1446
- propTraps
1447
- );
1448
- });
1449
- res.push(
1450
- new Proxy(
1451
- {
1452
- get(property) {
1453
- return blocked.has(property) ? undefined : props[property];
1454
- },
1455
- has(property) {
1456
- return blocked.has(property) ? false : property in props;
1457
- },
1458
- keys() {
1459
- return Object.keys(props).filter(k => !blocked.has(k));
1460
- }
1338
+ has(property) {
1339
+ return k.includes(property) && property in props;
1461
1340
  },
1462
- propTraps
1463
- )
1464
- );
1341
+ keys() {
1342
+ return k.filter(property => property in props);
1343
+ }
1344
+ }, propTraps);
1345
+ });
1346
+ res.push(new Proxy({
1347
+ get(property) {
1348
+ return blocked.has(property) ? undefined : props[property];
1349
+ },
1350
+ has(property) {
1351
+ return blocked.has(property) ? false : property in props;
1352
+ },
1353
+ keys() {
1354
+ return Object.keys(props).filter(k => !blocked.has(k));
1355
+ }
1356
+ }, propTraps));
1465
1357
  return res;
1466
1358
  }
1467
1359
  const otherObject = {};
1468
1360
  const objects = keys.map(() => ({}));
1469
1361
  for (const propName of Object.getOwnPropertyNames(props)) {
1470
1362
  const desc = Object.getOwnPropertyDescriptor(props, propName);
1471
- const isDefaultDesc =
1472
- !desc.get && !desc.set && desc.enumerable && desc.writable && desc.configurable;
1363
+ const isDefaultDesc = !desc.get && !desc.set && desc.enumerable && desc.writable && desc.configurable;
1473
1364
  let blocked = false;
1474
1365
  let objectIndex = 0;
1475
1366
  for (const k of keys) {
1476
1367
  if (k.includes(propName)) {
1477
1368
  blocked = true;
1478
- isDefaultDesc
1479
- ? (objects[objectIndex][propName] = desc.value)
1480
- : Object.defineProperty(objects[objectIndex], propName, desc);
1369
+ isDefaultDesc ? objects[objectIndex][propName] = desc.value : Object.defineProperty(objects[objectIndex], propName, desc);
1481
1370
  }
1482
1371
  ++objectIndex;
1483
1372
  }
1484
1373
  if (!blocked) {
1485
- isDefaultDesc
1486
- ? (otherObject[propName] = desc.value)
1487
- : Object.defineProperty(otherObject, propName, desc);
1374
+ isDefaultDesc ? otherObject[propName] = desc.value : Object.defineProperty(otherObject, propName, desc);
1488
1375
  }
1489
1376
  }
1490
1377
  return [...objects, otherObject];
@@ -1510,21 +1397,17 @@ function lazy(fn) {
1510
1397
  comp = s;
1511
1398
  }
1512
1399
  let Comp;
1513
- return createMemo(
1514
- () =>
1515
- (Comp = comp()) &&
1516
- untrack(() => {
1517
- if (false);
1518
- if (!ctx) return Comp(props);
1519
- const c = sharedConfig.context;
1520
- setHydrateContext(ctx);
1521
- const r = Comp(props);
1522
- setHydrateContext(c);
1523
- return r;
1524
- })
1525
- );
1400
+ return createMemo(() => (Comp = comp()) && untrack(() => {
1401
+ if (false) ;
1402
+ if (!ctx) return Comp(props);
1403
+ const c = sharedConfig.context;
1404
+ setHydrateContext(ctx);
1405
+ const r = Comp(props);
1406
+ setHydrateContext(c);
1407
+ return r;
1408
+ }));
1526
1409
  };
1527
- wrap.preload = () => p || ((p = fn()).then(mod => (comp = () => mod.default)), p);
1410
+ wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
1528
1411
  return wrap;
1529
1412
  }
1530
1413
  let counter = 0;
@@ -1549,78 +1432,49 @@ function Index(props) {
1549
1432
  function Show(props) {
1550
1433
  const keyed = props.keyed;
1551
1434
  const condition = createMemo(() => props.when, undefined, {
1552
- equals: (a, b) => (keyed ? a === b : !a === !b)
1435
+ equals: (a, b) => keyed ? a === b : !a === !b
1553
1436
  });
1554
- return createMemo(
1555
- () => {
1556
- const c = condition();
1557
- if (c) {
1558
- const child = props.children;
1559
- const fn = typeof child === "function" && child.length > 0;
1560
- return fn
1561
- ? untrack(() =>
1562
- child(
1563
- keyed
1564
- ? c
1565
- : () => {
1566
- if (!untrack(condition)) throw narrowedError("Show");
1567
- return props.when;
1568
- }
1569
- )
1570
- )
1571
- : child;
1572
- }
1573
- return props.fallback;
1574
- },
1575
- undefined,
1576
- undefined
1577
- );
1437
+ return createMemo(() => {
1438
+ const c = condition();
1439
+ if (c) {
1440
+ const child = props.children;
1441
+ const fn = typeof child === "function" && child.length > 0;
1442
+ return fn ? untrack(() => child(keyed ? c : () => {
1443
+ if (!untrack(condition)) throw narrowedError("Show");
1444
+ return props.when;
1445
+ })) : child;
1446
+ }
1447
+ return props.fallback;
1448
+ }, undefined, undefined);
1578
1449
  }
1579
1450
  function Switch(props) {
1580
1451
  let keyed = false;
1581
- const equals = (a, b) =>
1582
- a[0] === b[0] && (keyed ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2];
1452
+ const equals = (a, b) => a[0] === b[0] && (keyed ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2];
1583
1453
  const conditions = children(() => props.children),
1584
- evalConditions = createMemo(
1585
- () => {
1586
- let conds = conditions();
1587
- if (!Array.isArray(conds)) conds = [conds];
1588
- for (let i = 0; i < conds.length; i++) {
1589
- const c = conds[i].when;
1590
- if (c) {
1591
- keyed = !!conds[i].keyed;
1592
- return [i, c, conds[i]];
1593
- }
1454
+ evalConditions = createMemo(() => {
1455
+ let conds = conditions();
1456
+ if (!Array.isArray(conds)) conds = [conds];
1457
+ for (let i = 0; i < conds.length; i++) {
1458
+ const c = conds[i].when;
1459
+ if (c) {
1460
+ keyed = !!conds[i].keyed;
1461
+ return [i, c, conds[i]];
1594
1462
  }
1595
- return [-1];
1596
- },
1597
- undefined,
1598
- {
1599
- equals
1600
1463
  }
1601
- );
1602
- return createMemo(
1603
- () => {
1604
- const [index, when, cond] = evalConditions();
1605
- if (index < 0) return props.fallback;
1606
- const c = cond.children;
1607
- const fn = typeof c === "function" && c.length > 0;
1608
- return fn
1609
- ? untrack(() =>
1610
- c(
1611
- keyed
1612
- ? when
1613
- : () => {
1614
- if (untrack(evalConditions)[0] !== index) throw narrowedError("Match");
1615
- return cond.when;
1616
- }
1617
- )
1618
- )
1619
- : c;
1620
- },
1621
- undefined,
1622
- undefined
1623
- );
1464
+ return [-1];
1465
+ }, undefined, {
1466
+ equals
1467
+ });
1468
+ return createMemo(() => {
1469
+ const [index, when, cond] = evalConditions();
1470
+ if (index < 0) return props.fallback;
1471
+ const c = cond.children;
1472
+ const fn = typeof c === "function" && c.length > 0;
1473
+ return fn ? untrack(() => c(keyed ? when : () => {
1474
+ if (untrack(evalConditions)[0] !== index) throw narrowedError("Match");
1475
+ return cond.when;
1476
+ })) : c;
1477
+ }, undefined, undefined);
1624
1478
  }
1625
1479
  function Match(props) {
1626
1480
  return props;
@@ -1631,28 +1485,22 @@ function resetErrorBoundaries() {
1631
1485
  }
1632
1486
  function ErrorBoundary(props) {
1633
1487
  let err;
1634
- if (sharedConfig.context && sharedConfig.load)
1635
- err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
1488
+ if (sharedConfig.context && sharedConfig.load) err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
1636
1489
  const [errored, setErrored] = createSignal(err, undefined);
1637
1490
  Errors || (Errors = new Set());
1638
1491
  Errors.add(setErrored);
1639
1492
  onCleanup(() => Errors.delete(setErrored));
1640
- return createMemo(
1641
- () => {
1642
- let e;
1643
- if ((e = errored())) {
1644
- const f = props.fallback;
1645
- return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored())) : f;
1646
- }
1647
- return catchError(() => props.children, setErrored);
1648
- },
1649
- undefined,
1650
- undefined
1651
- );
1493
+ return createMemo(() => {
1494
+ let e;
1495
+ if (e = errored()) {
1496
+ const f = props.fallback;
1497
+ return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored())) : f;
1498
+ }
1499
+ return catchError(() => props.children, setErrored);
1500
+ }, undefined, undefined);
1652
1501
  }
1653
1502
 
1654
- const suspenseListEquals = (a, b) =>
1655
- a.showContent === b.showContent && a.showFallback === b.showFallback;
1503
+ const suspenseListEquals = (a, b) => a.showContent === b.showContent && a.showFallback === b.showFallback;
1656
1504
  const SuspenseListContext = createContext();
1657
1505
  function SuspenseList(props) {
1658
1506
  let [wrapper, setWrapper] = createSignal(() => ({
@@ -1664,51 +1512,51 @@ function SuspenseList(props) {
1664
1512
  if (listContext) {
1665
1513
  show = listContext.register(createMemo(() => wrapper()().inFallback));
1666
1514
  }
1667
- const resolved = createMemo(
1668
- prev => {
1669
- const reveal = props.revealOrder,
1670
- tail = props.tail,
1671
- { showContent = true, showFallback = true } = show ? show() : {},
1672
- reg = registry(),
1673
- reverse = reveal === "backwards";
1674
- if (reveal === "together") {
1675
- const all = reg.every(inFallback => !inFallback());
1676
- const res = reg.map(() => ({
1677
- showContent: all && showContent,
1515
+ const resolved = createMemo(prev => {
1516
+ const reveal = props.revealOrder,
1517
+ tail = props.tail,
1518
+ {
1519
+ showContent = true,
1520
+ showFallback = true
1521
+ } = show ? show() : {},
1522
+ reg = registry(),
1523
+ reverse = reveal === "backwards";
1524
+ if (reveal === "together") {
1525
+ const all = reg.every(inFallback => !inFallback());
1526
+ const res = reg.map(() => ({
1527
+ showContent: all && showContent,
1528
+ showFallback
1529
+ }));
1530
+ res.inFallback = !all;
1531
+ return res;
1532
+ }
1533
+ let stop = false;
1534
+ let inFallback = prev.inFallback;
1535
+ const res = [];
1536
+ for (let i = 0, len = reg.length; i < len; i++) {
1537
+ const n = reverse ? len - i - 1 : i,
1538
+ s = reg[n]();
1539
+ if (!stop && !s) {
1540
+ res[n] = {
1541
+ showContent,
1678
1542
  showFallback
1679
- }));
1680
- res.inFallback = !all;
1681
- return res;
1682
- }
1683
- let stop = false;
1684
- let inFallback = prev.inFallback;
1685
- const res = [];
1686
- for (let i = 0, len = reg.length; i < len; i++) {
1687
- const n = reverse ? len - i - 1 : i,
1688
- s = reg[n]();
1689
- if (!stop && !s) {
1690
- res[n] = {
1691
- showContent,
1692
- showFallback
1693
- };
1694
- } else {
1695
- const next = !stop;
1696
- if (next) inFallback = true;
1697
- res[n] = {
1698
- showContent: next,
1699
- showFallback: !tail || (next && tail === "collapsed") ? showFallback : false
1700
- };
1701
- stop = true;
1702
- }
1543
+ };
1544
+ } else {
1545
+ const next = !stop;
1546
+ if (next) inFallback = true;
1547
+ res[n] = {
1548
+ showContent: next,
1549
+ showFallback: !tail || next && tail === "collapsed" ? showFallback : false
1550
+ };
1551
+ stop = true;
1703
1552
  }
1704
- if (!stop) inFallback = false;
1705
- res.inFallback = inFallback;
1706
- return res;
1707
- },
1708
- {
1709
- inFallback: false
1710
1553
  }
1711
- );
1554
+ if (!stop) inFallback = false;
1555
+ res.inFallback = inFallback;
1556
+ return res;
1557
+ }, {
1558
+ inFallback: false
1559
+ });
1712
1560
  setWrapper(() => resolved);
1713
1561
  return createComponent(SuspenseListContext.Provider, {
1714
1562
  value: {
@@ -1783,14 +1631,17 @@ function Suspense(props) {
1783
1631
  ctx = sharedConfig.context;
1784
1632
  if (flicker) {
1785
1633
  flicker();
1786
- return (flicker = undefined);
1634
+ return flicker = undefined;
1787
1635
  }
1788
1636
  if (ctx && p === "$$f") setHydrateContext();
1789
1637
  const rendered = createMemo(() => props.children);
1790
1638
  return createMemo(prev => {
1791
1639
  const inFallback = store.inFallback(),
1792
- { showContent = true, showFallback = true } = show ? show() : {};
1793
- if ((!inFallback || (p && p !== "$$f")) && showContent) {
1640
+ {
1641
+ showContent = true,
1642
+ showFallback = true
1643
+ } = show ? show() : {};
1644
+ if ((!inFallback || p && p !== "$$f") && showContent) {
1794
1645
  store.resolved = true;
1795
1646
  dispose && dispose();
1796
1647
  dispose = ctx = p = undefined;
@@ -1818,59 +1669,4 @@ function Suspense(props) {
1818
1669
 
1819
1670
  const DEV = undefined;
1820
1671
 
1821
- export {
1822
- $DEVCOMP,
1823
- $PROXY,
1824
- $TRACK,
1825
- DEV,
1826
- ErrorBoundary,
1827
- For,
1828
- Index,
1829
- Match,
1830
- Show,
1831
- Suspense,
1832
- SuspenseList,
1833
- Switch,
1834
- batch,
1835
- cancelCallback,
1836
- catchError,
1837
- children,
1838
- createComponent,
1839
- createComputed,
1840
- createContext,
1841
- createDeferred,
1842
- createEffect,
1843
- createMemo,
1844
- createReaction,
1845
- createRenderEffect,
1846
- createResource,
1847
- createRoot,
1848
- createSelector,
1849
- createSignal,
1850
- createUniqueId,
1851
- enableExternalSource,
1852
- enableHydration,
1853
- enableScheduling,
1854
- equalFn,
1855
- from,
1856
- getListener,
1857
- getOwner,
1858
- indexArray,
1859
- lazy,
1860
- mapArray,
1861
- mergeProps,
1862
- observable,
1863
- on,
1864
- onCleanup,
1865
- onError,
1866
- onMount,
1867
- requestCallback,
1868
- resetErrorBoundaries,
1869
- runWithOwner,
1870
- sharedConfig,
1871
- splitProps,
1872
- startTransition,
1873
- untrack,
1874
- useContext,
1875
- useTransition
1876
- };
1672
+ export { $DEVCOMP, $PROXY, $TRACK, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, cancelCallback, catchError, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createReaction, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, resetErrorBoundaries, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };