solid-js 1.8.6 → 1.8.8

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 (49) hide show
  1. package/dist/dev.cjs +31 -21
  2. package/dist/dev.js +327 -552
  3. package/dist/server.js +75 -170
  4. package/dist/solid.cjs +31 -21
  5. package/dist/solid.js +285 -479
  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/jsx-runtime/types/jsx.d.ts +15 -1
  10. package/h/types/hyperscript.d.ts +11 -11
  11. package/html/dist/html.js +94 -216
  12. package/html/types/lit.d.ts +33 -47
  13. package/package.json +2 -2
  14. package/store/dist/dev.cjs +3 -2
  15. package/store/dist/dev.js +44 -115
  16. package/store/dist/server.js +8 -19
  17. package/store/dist/store.cjs +3 -2
  18. package/store/dist/store.js +41 -106
  19. package/store/types/index.d.ts +7 -21
  20. package/store/types/modifiers.d.ts +3 -6
  21. package/store/types/mutable.d.ts +2 -5
  22. package/store/types/server.d.ts +4 -12
  23. package/store/types/store.d.ts +61 -218
  24. package/types/index.d.ts +10 -75
  25. package/types/jsx.d.ts +15 -1
  26. package/types/reactive/array.d.ts +4 -12
  27. package/types/reactive/observable.d.ts +17 -25
  28. package/types/reactive/scheduler.d.ts +6 -9
  29. package/types/reactive/signal.d.ts +142 -231
  30. package/types/render/Suspense.d.ts +5 -5
  31. package/types/render/component.d.ts +33 -62
  32. package/types/render/flow.d.ts +31 -43
  33. package/types/render/hydration.d.ts +13 -13
  34. package/types/server/index.d.ts +2 -57
  35. package/types/server/reactive.d.ts +42 -73
  36. package/types/server/rendering.d.ts +96 -166
  37. package/universal/dist/dev.js +12 -28
  38. package/universal/dist/universal.js +12 -28
  39. package/universal/types/index.d.ts +1 -3
  40. package/universal/types/universal.d.ts +1 -0
  41. package/web/dist/dev.js +81 -620
  42. package/web/dist/server.cjs +23 -15
  43. package/web/dist/server.js +117 -191
  44. package/web/dist/storage.js +3 -3
  45. package/web/dist/web.js +80 -614
  46. package/web/types/client.d.ts +2 -2
  47. package/web/types/core.d.ts +1 -10
  48. package/web/types/index.d.ts +10 -27
  49. package/web/types/server-mock.d.ts +32 -47
package/dist/server.js CHANGED
@@ -17,7 +17,7 @@ function handleError(err, owner = Owner) {
17
17
  try {
18
18
  for (const f of fns) f(error);
19
19
  } catch (e) {
20
- handleError(e, (owner && owner.owner) || null);
20
+ handleError(e, owner && owner.owner || null);
21
21
  }
22
22
  }
23
23
  const UNOWNED = {
@@ -35,23 +35,19 @@ function createOwner() {
35
35
  cleanups: null
36
36
  };
37
37
  if (Owner) {
38
- if (!Owner.owned) Owner.owned = [o];
39
- else Owner.owned.push(o);
38
+ if (!Owner.owned) Owner.owned = [o];else Owner.owned.push(o);
40
39
  }
41
40
  return o;
42
41
  }
43
42
  function createRoot(fn, detachedOwner) {
44
43
  const owner = Owner,
45
44
  current = detachedOwner === undefined ? owner : detachedOwner,
46
- root =
47
- fn.length === 0
48
- ? UNOWNED
49
- : {
50
- context: current ? current.context : null,
51
- owner: current,
52
- owned: null,
53
- cleanups: null
54
- };
45
+ root = fn.length === 0 ? UNOWNED : {
46
+ context: current ? current.context : null,
47
+ owner: current,
48
+ owned: null,
49
+ cleanups: null
50
+ };
55
51
  Owner = root;
56
52
  let result;
57
53
  try {
@@ -64,12 +60,9 @@ function createRoot(fn, detachedOwner) {
64
60
  return result;
65
61
  }
66
62
  function createSignal(value, options) {
67
- return [
68
- () => value,
69
- v => {
70
- return (value = typeof v === "function" ? v(value) : v);
71
- }
72
- ];
63
+ return [() => value, v => {
64
+ return value = typeof v === "function" ? v(value) : v;
65
+ }];
73
66
  }
74
67
  function createComputed(fn, value) {
75
68
  Owner = createOwner();
@@ -126,8 +119,7 @@ function on(deps, fn, options = {}) {
126
119
  function onMount(fn) {}
127
120
  function onCleanup(fn) {
128
121
  if (Owner) {
129
- if (!Owner.cleanups) Owner.cleanups = [fn];
130
- else Owner.cleanups.push(fn);
122
+ if (!Owner.cleanups) Owner.cleanups = [fn];else Owner.cleanups.push(fn);
131
123
  }
132
124
  return fn;
133
125
  }
@@ -168,9 +160,7 @@ function createContext(defaultValue) {
168
160
  };
169
161
  }
170
162
  function useContext(context) {
171
- return Owner && Owner.context && Owner.context[context.id] !== undefined
172
- ? Owner.context[context.id]
173
- : context.defaultValue;
163
+ return Owner && Owner.context && Owner.context[context.id] !== undefined ? Owner.context[context.id] : context.defaultValue;
174
164
  }
175
165
  function getOwner() {
176
166
  return Owner;
@@ -247,8 +237,7 @@ function observable(input) {
247
237
  if (!(observer instanceof Object) || observer == null) {
248
238
  throw new TypeError("Expected the observer to be an object.");
249
239
  }
250
- const handler =
251
- typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
240
+ const handler = typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
252
241
  if (!handler) {
253
242
  return {
254
243
  unsubscribe() {}
@@ -277,7 +266,7 @@ function from(producer) {
277
266
  const [s, set] = createSignal(undefined);
278
267
  if ("subscribe" in producer) {
279
268
  const unsub = producer.subscribe(v => set(() => v));
280
- onCleanup(() => ("unsubscribe" in unsub ? unsub.unsubscribe() : unsub()));
269
+ onCleanup(() => "unsubscribe" in unsub ? unsub.unsubscribe() : unsub());
281
270
  } else {
282
271
  const clean = producer(set);
283
272
  onCleanup(clean);
@@ -329,13 +318,11 @@ function setHydrateContext(context) {
329
318
  sharedConfig.context = context;
330
319
  }
331
320
  function nextHydrateContext() {
332
- return sharedConfig.context
333
- ? {
334
- ...sharedConfig.context,
335
- id: `${sharedConfig.context.id}${sharedConfig.context.count++}-`,
336
- count: 0
337
- }
338
- : undefined;
321
+ return sharedConfig.context ? {
322
+ ...sharedConfig.context,
323
+ id: `${sharedConfig.context.id}${sharedConfig.context.count++}-`,
324
+ count: 0
325
+ } : undefined;
339
326
  }
340
327
  function createUniqueId() {
341
328
  const ctx = sharedConfig.context;
@@ -412,11 +399,7 @@ function Index(props) {
412
399
  }
413
400
  function Show(props) {
414
401
  let c;
415
- return props.when
416
- ? typeof (c = props.children) === "function"
417
- ? c(props.keyed ? props.when : () => props.when)
418
- : c
419
- : props.fallback || "";
402
+ return props.when ? typeof (c = props.children) === "function" ? c(props.keyed ? props.when : () => props.when) : c : props.fallback || "";
420
403
  }
421
404
  function Switch(props) {
422
405
  let conditions = props.children;
@@ -453,14 +436,11 @@ function ErrorBoundary(props) {
453
436
  }
454
437
  createMemo(() => {
455
438
  clean = Owner;
456
- return catchError(
457
- () => (res = props.children),
458
- err => {
459
- error = err;
460
- !sync && ctx.replace("e" + id, displayFallback);
461
- sync = true;
462
- }
463
- );
439
+ return catchError(() => res = props.children, err => {
440
+ error = err;
441
+ !sync && ctx.replace("e" + id, displayFallback);
442
+ sync = true;
443
+ });
464
444
  });
465
445
  if (error) return displayFallback();
466
446
  sync = false;
@@ -490,18 +470,14 @@ function createResource(source, fetcher, options = {}) {
490
470
  if (sharedConfig.context.async && options.ssrLoadFrom !== "initial") {
491
471
  resource = sharedConfig.context.resources[id] || (sharedConfig.context.resources[id] = {});
492
472
  if (resource.ref) {
493
- if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error)
494
- resource.ref[1].refetch();
473
+ if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error) resource.ref[1].refetch();
495
474
  return resource.ref;
496
475
  }
497
476
  }
498
477
  const read = () => {
499
478
  if (error) throw error;
500
479
  if (resourceContext && p) resourceContext.push(p);
501
- const resolved =
502
- options.ssrLoadFrom !== "initial" &&
503
- sharedConfig.context.async &&
504
- "data" in sharedConfig.context.resources[id];
480
+ const resolved = options.ssrLoadFrom !== "initial" && sharedConfig.context.async && "data" in sharedConfig.context.resources[id];
505
481
  if (!resolved && read.loading) {
506
482
  const ctx = useContext(SuspenseContext);
507
483
  if (ctx) {
@@ -521,7 +497,7 @@ function createResource(source, fetcher, options = {}) {
521
497
  });
522
498
  function load() {
523
499
  const ctx = sharedConfig.context;
524
- if (!ctx.async) return (read.loading = !!(typeof source === "function" ? source() : source));
500
+ if (!ctx.async) return read.loading = !!(typeof source === "function" ? source() : source);
525
501
  if (ctx.resources && id in ctx.resources && "data" in ctx.resources[id]) {
526
502
  value = ctx.resources[id].data;
527
503
  return;
@@ -529,11 +505,9 @@ function createResource(source, fetcher, options = {}) {
529
505
  resourceContext = [];
530
506
  const lookup = typeof source === "function" ? source() : source;
531
507
  if (resourceContext.length) {
532
- p = Promise.all(resourceContext).then(() =>
533
- fetcher(source(), {
534
- value
535
- })
536
- );
508
+ p = Promise.all(resourceContext).then(() => fetcher(source(), {
509
+ value
510
+ }));
537
511
  }
538
512
  resourceContext = null;
539
513
  if (!p) {
@@ -545,23 +519,21 @@ function createResource(source, fetcher, options = {}) {
545
519
  if (p != undefined && typeof p === "object" && "then" in p) {
546
520
  read.loading = true;
547
521
  read.state = "pending";
548
- p = p
549
- .then(res => {
550
- read.loading = false;
551
- read.state = "ready";
552
- ctx.resources[id].data = res;
553
- p = null;
554
- notifySuspense(contexts);
555
- return res;
556
- })
557
- .catch(err => {
558
- read.loading = false;
559
- read.state = "errored";
560
- read.error = error = castError(err);
561
- p = null;
562
- notifySuspense(contexts);
563
- throw error;
564
- });
522
+ p = p.then(res => {
523
+ read.loading = false;
524
+ read.state = "ready";
525
+ ctx.resources[id].data = res;
526
+ p = null;
527
+ notifySuspense(contexts);
528
+ return res;
529
+ }).catch(err => {
530
+ read.loading = false;
531
+ read.state = "errored";
532
+ read.error = error = castError(err);
533
+ p = null;
534
+ notifySuspense(contexts);
535
+ throw error;
536
+ });
565
537
  if (ctx.serialize) ctx.serialize(id, p, options.deferStream);
566
538
  return p;
567
539
  }
@@ -571,20 +543,17 @@ function createResource(source, fetcher, options = {}) {
571
543
  return ctx.resources[id].data;
572
544
  }
573
545
  if (options.ssrLoadFrom !== "initial") load();
574
- return (resource.ref = [
575
- read,
576
- {
577
- refetch: load,
578
- mutate: v => (value = v)
579
- }
580
- ]);
546
+ return resource.ref = [read, {
547
+ refetch: load,
548
+ mutate: v => value = v
549
+ }];
581
550
  }
582
551
  function lazy(fn) {
583
552
  let p;
584
553
  let load = id => {
585
554
  if (!p) {
586
555
  p = fn();
587
- p.then(mod => (p.resolved = mod.default));
556
+ p.then(mod => p.resolved = mod.default);
588
557
  if (id) sharedConfig.context.lazy[id] = p;
589
558
  }
590
559
  return p;
@@ -593,8 +562,7 @@ function lazy(fn) {
593
562
  const wrap = props => {
594
563
  const id = sharedConfig.context.id.slice(0, -1);
595
564
  let ref = sharedConfig.context.lazy[id];
596
- if (ref) p = ref;
597
- else load(id);
565
+ if (ref) p = ref;else load(id);
598
566
  if (p.resolved) return p.resolved(props);
599
567
  const ctx = useContext(SuspenseContext);
600
568
  const track = {
@@ -606,12 +574,10 @@ function lazy(fn) {
606
574
  contexts.add(ctx);
607
575
  }
608
576
  if (sharedConfig.context.async) {
609
- sharedConfig.context.block(
610
- p.then(() => {
611
- track.loading = false;
612
- notifySuspense(contexts);
613
- })
614
- );
577
+ sharedConfig.context.block(p.then(() => {
578
+ track.loading = false;
579
+ notifySuspense(contexts);
580
+ }));
615
581
  }
616
582
  return "";
617
583
  };
@@ -639,12 +605,9 @@ function startTransition(fn) {
639
605
  fn();
640
606
  }
641
607
  function useTransition() {
642
- return [
643
- () => false,
644
- fn => {
645
- fn();
646
- }
647
- ];
608
+ return [() => false, fn => {
609
+ fn();
610
+ }];
648
611
  }
649
612
  function SuspenseList(props) {
650
613
  return props.children;
@@ -654,17 +617,15 @@ function Suspense(props) {
654
617
  const ctx = sharedConfig.context;
655
618
  const id = ctx.id + ctx.count;
656
619
  const o = createOwner();
657
- const value =
658
- ctx.suspense[id] ||
659
- (ctx.suspense[id] = {
660
- resources: new Map(),
661
- completed: () => {
662
- const res = runSuspense();
663
- if (suspenseComplete(value)) {
664
- done(resolveSSRNode(res));
665
- }
620
+ const value = ctx.suspense[id] || (ctx.suspense[id] = {
621
+ resources: new Map(),
622
+ completed: () => {
623
+ const res = runSuspense();
624
+ if (suspenseComplete(value)) {
625
+ done(resolveSSRNode(res));
666
626
  }
667
- });
627
+ }
628
+ });
668
629
  function suspenseError(err) {
669
630
  if (!done || !done(undefined, err)) {
670
631
  runWithOwner(o.owner, () => {
@@ -678,14 +639,12 @@ function Suspense(props) {
678
639
  count: 0
679
640
  });
680
641
  cleanNode(o);
681
- return runWithOwner(o, () =>
682
- createComponent(SuspenseContext.Provider, {
683
- value,
684
- get children() {
685
- return catchError(() => props.children, suspenseError);
686
- }
687
- })
688
- );
642
+ return runWithOwner(o, () => createComponent(SuspenseContext.Provider, {
643
+ value,
644
+ get children() {
645
+ return catchError(() => props.children, suspenseError);
646
+ }
647
+ }));
689
648
  }
690
649
  const res = runSuspense();
691
650
  if (suspenseComplete(value)) {
@@ -717,58 +676,4 @@ function Suspense(props) {
717
676
  }, suspenseError);
718
677
  }
719
678
 
720
- export {
721
- $DEVCOMP,
722
- $PROXY,
723
- $TRACK,
724
- DEV,
725
- ErrorBoundary,
726
- For,
727
- Index,
728
- Match,
729
- Show,
730
- Suspense,
731
- SuspenseList,
732
- Switch,
733
- batch,
734
- catchError,
735
- children,
736
- createComponent,
737
- createComputed,
738
- createContext,
739
- createDeferred,
740
- createEffect,
741
- createMemo,
742
- createReaction,
743
- createRenderEffect,
744
- createResource,
745
- createRoot,
746
- createSelector,
747
- createSignal,
748
- createUniqueId,
749
- enableExternalSource,
750
- enableHydration,
751
- enableScheduling,
752
- equalFn,
753
- from,
754
- getListener,
755
- getOwner,
756
- indexArray,
757
- lazy,
758
- mapArray,
759
- mergeProps,
760
- observable,
761
- on,
762
- onCleanup,
763
- onError,
764
- onMount,
765
- requestCallback,
766
- resetErrorBoundaries,
767
- runWithOwner,
768
- sharedConfig,
769
- splitProps,
770
- startTransition,
771
- untrack,
772
- useContext,
773
- useTransition
774
- };
679
+ export { $DEVCOMP, $PROXY, $TRACK, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, 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 };
package/dist/solid.cjs CHANGED
@@ -152,12 +152,11 @@ const NO_INIT = {};
152
152
  var Owner = null;
153
153
  let Transition = null;
154
154
  let Scheduler = null;
155
- let ExternalSourceFactory = null;
155
+ let ExternalSourceConfig = null;
156
156
  let Listener = null;
157
157
  let Updates = null;
158
158
  let Effects = null;
159
159
  let ExecCount = 0;
160
- const [transPending, setTransPending] = /*@__PURE__*/createSignal(false);
161
160
  function createRoot(fn, detachedOwner) {
162
161
  const listener = Listener,
163
162
  owner = Owner,
@@ -421,10 +420,11 @@ function batch(fn) {
421
420
  return runUpdates(fn, false);
422
421
  }
423
422
  function untrack(fn) {
424
- if (Listener === null) return fn();
423
+ if (!ExternalSourceConfig && Listener === null) return fn();
425
424
  const listener = Listener;
426
425
  Listener = null;
427
426
  try {
427
+ if (ExternalSourceConfig) return ExternalSourceConfig.untrack(fn);
428
428
  return fn();
429
429
  } finally {
430
430
  Listener = listener;
@@ -523,6 +523,7 @@ function startTransition(fn) {
523
523
  return t ? t.done : undefined;
524
524
  });
525
525
  }
526
+ const [transPending, setTransPending] = /*@__PURE__*/createSignal(false);
526
527
  function useTransition() {
527
528
  return [transPending, startTransition];
528
529
  }
@@ -554,22 +555,31 @@ let SuspenseContext;
554
555
  function getSuspenseContext() {
555
556
  return SuspenseContext || (SuspenseContext = createContext());
556
557
  }
557
- function enableExternalSource(factory) {
558
- if (ExternalSourceFactory) {
559
- const oldFactory = ExternalSourceFactory;
560
- ExternalSourceFactory = (fn, trigger) => {
561
- const oldSource = oldFactory(fn, trigger);
562
- const source = factory(x => oldSource.track(x), trigger);
563
- return {
564
- track: x => source.track(x),
565
- dispose() {
566
- source.dispose();
567
- oldSource.dispose();
568
- }
569
- };
558
+ function enableExternalSource(factory, untrack = fn => fn()) {
559
+ if (ExternalSourceConfig) {
560
+ const {
561
+ factory: oldFactory,
562
+ untrack: oldUntrack
563
+ } = ExternalSourceConfig;
564
+ ExternalSourceConfig = {
565
+ factory: (fn, trigger) => {
566
+ const oldSource = oldFactory(fn, trigger);
567
+ const source = factory(x => oldSource.track(x), trigger);
568
+ return {
569
+ track: x => source.track(x),
570
+ dispose() {
571
+ source.dispose();
572
+ oldSource.dispose();
573
+ }
574
+ };
575
+ },
576
+ untrack: fn => oldUntrack(() => untrack(fn))
570
577
  };
571
578
  } else {
572
- ExternalSourceFactory = factory;
579
+ ExternalSourceConfig = {
580
+ factory,
581
+ untrack
582
+ };
573
583
  }
574
584
  }
575
585
  function readSignal() {
@@ -711,14 +721,14 @@ function createComputation(fn, init, pure, state = STALE, options) {
711
721
  if (!Owner.owned) Owner.owned = [c];else Owner.owned.push(c);
712
722
  }
713
723
  }
714
- if (ExternalSourceFactory) {
724
+ if (ExternalSourceConfig && c.fn) {
715
725
  const [track, trigger] = createSignal(undefined, {
716
726
  equals: false
717
727
  });
718
- const ordinary = ExternalSourceFactory(c.fn, trigger);
728
+ const ordinary = ExternalSourceConfig.factory(c.fn, trigger);
719
729
  onCleanup(() => ordinary.dispose());
720
730
  const triggerInTransition = () => startTransition(trigger).then(() => inTransition.dispose());
721
- const inTransition = ExternalSourceFactory(c.fn, triggerInTransition);
731
+ const inTransition = ExternalSourceConfig.factory(c.fn, triggerInTransition);
722
732
  c.fn = x => {
723
733
  track();
724
734
  return Transition && Transition.running ? inTransition.track(x) : ordinary.track(x);
@@ -1452,7 +1462,7 @@ function Show(props) {
1452
1462
  }
1453
1463
  function Switch(props) {
1454
1464
  let keyed = false;
1455
- const equals = (a, b) => a[0] === b[0] && (keyed ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2];
1465
+ const equals = (a, b) => (keyed ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2];
1456
1466
  const conditions = children(() => props.children),
1457
1467
  evalConditions = createMemo(() => {
1458
1468
  let conds = conditions();