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/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
@@ -336,11 +336,11 @@ function createResource(pSource, pFetcher, pOptions) {
336
336
  loadEnd(pr, p, undefined, lookup);
337
337
  return p;
338
338
  }
339
+ pr = p;
339
340
  if ("value" in p) {
340
341
  if (p.status === "success") loadEnd(pr, p.value, undefined, lookup);else loadEnd(pr, undefined, undefined, lookup);
341
342
  return p;
342
343
  }
343
- pr = p;
344
344
  scheduled = true;
345
345
  queueMicrotask(() => scheduled = false);
346
346
  runUpdates(() => {