solid-js 1.8.0-beta.2 → 1.8.1

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