solid-js 1.8.11 → 1.8.12

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 (46) hide show
  1. package/dist/dev.js +544 -307
  2. package/dist/server.js +170 -75
  3. package/dist/solid.js +471 -265
  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 +47 -33
  10. package/package.json +1 -1
  11. package/store/dist/dev.cjs +12 -2
  12. package/store/dist/dev.js +133 -44
  13. package/store/dist/server.js +19 -8
  14. package/store/dist/store.cjs +12 -2
  15. package/store/dist/store.js +124 -41
  16. package/store/types/index.d.ts +21 -7
  17. package/store/types/modifiers.d.ts +6 -3
  18. package/store/types/mutable.d.ts +5 -2
  19. package/store/types/server.d.ts +12 -4
  20. package/store/types/store.d.ts +218 -61
  21. package/types/index.d.ts +75 -10
  22. package/types/reactive/array.d.ts +12 -4
  23. package/types/reactive/observable.d.ts +25 -17
  24. package/types/reactive/scheduler.d.ts +9 -6
  25. package/types/reactive/signal.d.ts +233 -142
  26. package/types/render/Suspense.d.ts +5 -5
  27. package/types/render/component.d.ts +64 -33
  28. package/types/render/flow.d.ts +43 -31
  29. package/types/render/hydration.d.ts +13 -13
  30. package/types/server/index.d.ts +57 -2
  31. package/types/server/reactive.d.ts +73 -42
  32. package/types/server/rendering.d.ts +167 -96
  33. package/universal/dist/dev.js +28 -12
  34. package/universal/dist/universal.js +28 -12
  35. package/universal/types/index.d.ts +3 -1
  36. package/universal/types/universal.d.ts +0 -1
  37. package/web/dist/dev.cjs +3 -0
  38. package/web/dist/dev.js +625 -81
  39. package/web/dist/server.cjs +10 -15
  40. package/web/dist/server.js +216 -107
  41. package/web/dist/storage.js +3 -3
  42. package/web/dist/web.js +614 -80
  43. package/web/types/client.d.ts +2 -2
  44. package/web/types/core.d.ts +10 -1
  45. package/web/types/index.d.ts +27 -10
  46. package/web/types/server-mock.d.ts +47 -32
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,19 +35,23 @@ function createOwner() {
35
35
  cleanups: null
36
36
  };
37
37
  if (Owner) {
38
- if (!Owner.owned) Owner.owned = [o];else Owner.owned.push(o);
38
+ if (!Owner.owned) Owner.owned = [o];
39
+ else Owner.owned.push(o);
39
40
  }
40
41
  return o;
41
42
  }
42
43
  function createRoot(fn, detachedOwner) {
43
44
  const owner = Owner,
44
45
  current = detachedOwner === undefined ? owner : detachedOwner,
45
- root = fn.length === 0 ? UNOWNED : {
46
- context: current ? current.context : null,
47
- owner: current,
48
- owned: null,
49
- cleanups: null
50
- };
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
+ };
51
55
  Owner = root;
52
56
  let result;
53
57
  try {
@@ -60,9 +64,12 @@ function createRoot(fn, detachedOwner) {
60
64
  return result;
61
65
  }
62
66
  function createSignal(value, options) {
63
- return [() => value, v => {
64
- return value = typeof v === "function" ? v(value) : v;
65
- }];
67
+ return [
68
+ () => value,
69
+ v => {
70
+ return (value = typeof v === "function" ? v(value) : v);
71
+ }
72
+ ];
66
73
  }
67
74
  function createComputed(fn, value) {
68
75
  Owner = createOwner();
@@ -119,7 +126,8 @@ function on(deps, fn, options = {}) {
119
126
  function onMount(fn) {}
120
127
  function onCleanup(fn) {
121
128
  if (Owner) {
122
- if (!Owner.cleanups) Owner.cleanups = [fn];else Owner.cleanups.push(fn);
129
+ if (!Owner.cleanups) Owner.cleanups = [fn];
130
+ else Owner.cleanups.push(fn);
123
131
  }
124
132
  return fn;
125
133
  }
@@ -160,7 +168,9 @@ function createContext(defaultValue) {
160
168
  };
161
169
  }
162
170
  function useContext(context) {
163
- return Owner && Owner.context && Owner.context[context.id] !== undefined ? Owner.context[context.id] : context.defaultValue;
171
+ return Owner && Owner.context && Owner.context[context.id] !== undefined
172
+ ? Owner.context[context.id]
173
+ : context.defaultValue;
164
174
  }
165
175
  function getOwner() {
166
176
  return Owner;
@@ -237,7 +247,8 @@ function observable(input) {
237
247
  if (!(observer instanceof Object) || observer == null) {
238
248
  throw new TypeError("Expected the observer to be an object.");
239
249
  }
240
- const handler = typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
250
+ const handler =
251
+ typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
241
252
  if (!handler) {
242
253
  return {
243
254
  unsubscribe() {}
@@ -266,7 +277,7 @@ function from(producer) {
266
277
  const [s, set] = createSignal(undefined);
267
278
  if ("subscribe" in producer) {
268
279
  const unsub = producer.subscribe(v => set(() => v));
269
- onCleanup(() => "unsubscribe" in unsub ? unsub.unsubscribe() : unsub());
280
+ onCleanup(() => ("unsubscribe" in unsub ? unsub.unsubscribe() : unsub()));
270
281
  } else {
271
282
  const clean = producer(set);
272
283
  onCleanup(clean);
@@ -318,11 +329,13 @@ function setHydrateContext(context) {
318
329
  sharedConfig.context = context;
319
330
  }
320
331
  function nextHydrateContext() {
321
- return sharedConfig.context ? {
322
- ...sharedConfig.context,
323
- id: `${sharedConfig.context.id}${sharedConfig.context.count++}-`,
324
- count: 0
325
- } : undefined;
332
+ return sharedConfig.context
333
+ ? {
334
+ ...sharedConfig.context,
335
+ id: `${sharedConfig.context.id}${sharedConfig.context.count++}-`,
336
+ count: 0
337
+ }
338
+ : undefined;
326
339
  }
327
340
  function createUniqueId() {
328
341
  const ctx = sharedConfig.context;
@@ -399,7 +412,11 @@ function Index(props) {
399
412
  }
400
413
  function Show(props) {
401
414
  let c;
402
- return props.when ? typeof (c = props.children) === "function" ? c(props.keyed ? props.when : () => props.when) : c : props.fallback || "";
415
+ return props.when
416
+ ? typeof (c = props.children) === "function"
417
+ ? c(props.keyed ? props.when : () => props.when)
418
+ : c
419
+ : props.fallback || "";
403
420
  }
404
421
  function Switch(props) {
405
422
  let conditions = props.children;
@@ -436,11 +453,14 @@ function ErrorBoundary(props) {
436
453
  }
437
454
  createMemo(() => {
438
455
  clean = Owner;
439
- return catchError(() => res = props.children, err => {
440
- error = err;
441
- !sync && ctx.replace("e" + id, displayFallback);
442
- sync = true;
443
- });
456
+ return catchError(
457
+ () => (res = props.children),
458
+ err => {
459
+ error = err;
460
+ !sync && ctx.replace("e" + id, displayFallback);
461
+ sync = true;
462
+ }
463
+ );
444
464
  });
445
465
  if (error) return displayFallback();
446
466
  sync = false;
@@ -470,14 +490,18 @@ function createResource(source, fetcher, options = {}) {
470
490
  if (sharedConfig.context.async && options.ssrLoadFrom !== "initial") {
471
491
  resource = sharedConfig.context.resources[id] || (sharedConfig.context.resources[id] = {});
472
492
  if (resource.ref) {
473
- if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error) resource.ref[1].refetch();
493
+ if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error)
494
+ resource.ref[1].refetch();
474
495
  return resource.ref;
475
496
  }
476
497
  }
477
498
  const read = () => {
478
499
  if (error) throw error;
479
500
  if (resourceContext && p) resourceContext.push(p);
480
- const resolved = options.ssrLoadFrom !== "initial" && sharedConfig.context.async && "data" in sharedConfig.context.resources[id];
501
+ const resolved =
502
+ options.ssrLoadFrom !== "initial" &&
503
+ sharedConfig.context.async &&
504
+ "data" in sharedConfig.context.resources[id];
481
505
  if (!resolved && read.loading) {
482
506
  const ctx = useContext(SuspenseContext);
483
507
  if (ctx) {
@@ -497,7 +521,7 @@ function createResource(source, fetcher, options = {}) {
497
521
  });
498
522
  function load() {
499
523
  const ctx = sharedConfig.context;
500
- if (!ctx.async) return read.loading = !!(typeof source === "function" ? source() : source);
524
+ if (!ctx.async) return (read.loading = !!(typeof source === "function" ? source() : source));
501
525
  if (ctx.resources && id in ctx.resources && "data" in ctx.resources[id]) {
502
526
  value = ctx.resources[id].data;
503
527
  return;
@@ -505,9 +529,11 @@ function createResource(source, fetcher, options = {}) {
505
529
  resourceContext = [];
506
530
  const lookup = typeof source === "function" ? source() : source;
507
531
  if (resourceContext.length) {
508
- p = Promise.all(resourceContext).then(() => fetcher(source(), {
509
- value
510
- }));
532
+ p = Promise.all(resourceContext).then(() =>
533
+ fetcher(source(), {
534
+ value
535
+ })
536
+ );
511
537
  }
512
538
  resourceContext = null;
513
539
  if (!p) {
@@ -519,21 +545,23 @@ function createResource(source, fetcher, options = {}) {
519
545
  if (p != undefined && typeof p === "object" && "then" in p) {
520
546
  read.loading = true;
521
547
  read.state = "pending";
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
- });
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
+ });
537
565
  if (ctx.serialize) ctx.serialize(id, p, options.deferStream);
538
566
  return p;
539
567
  }
@@ -543,17 +571,20 @@ function createResource(source, fetcher, options = {}) {
543
571
  return ctx.resources[id].data;
544
572
  }
545
573
  if (options.ssrLoadFrom !== "initial") load();
546
- return resource.ref = [read, {
547
- refetch: load,
548
- mutate: v => value = v
549
- }];
574
+ return (resource.ref = [
575
+ read,
576
+ {
577
+ refetch: load,
578
+ mutate: v => (value = v)
579
+ }
580
+ ]);
550
581
  }
551
582
  function lazy(fn) {
552
583
  let p;
553
584
  let load = id => {
554
585
  if (!p) {
555
586
  p = fn();
556
- p.then(mod => p.resolved = mod.default);
587
+ p.then(mod => (p.resolved = mod.default));
557
588
  if (id) sharedConfig.context.lazy[id] = p;
558
589
  }
559
590
  return p;
@@ -562,7 +593,8 @@ function lazy(fn) {
562
593
  const wrap = props => {
563
594
  const id = sharedConfig.context.id.slice(0, -1);
564
595
  let ref = sharedConfig.context.lazy[id];
565
- if (ref) p = ref;else load(id);
596
+ if (ref) p = ref;
597
+ else load(id);
566
598
  if (p.resolved) return p.resolved(props);
567
599
  const ctx = useContext(SuspenseContext);
568
600
  const track = {
@@ -574,10 +606,12 @@ function lazy(fn) {
574
606
  contexts.add(ctx);
575
607
  }
576
608
  if (sharedConfig.context.async) {
577
- sharedConfig.context.block(p.then(() => {
578
- track.loading = false;
579
- notifySuspense(contexts);
580
- }));
609
+ sharedConfig.context.block(
610
+ p.then(() => {
611
+ track.loading = false;
612
+ notifySuspense(contexts);
613
+ })
614
+ );
581
615
  }
582
616
  return "";
583
617
  };
@@ -605,9 +639,12 @@ function startTransition(fn) {
605
639
  fn();
606
640
  }
607
641
  function useTransition() {
608
- return [() => false, fn => {
609
- fn();
610
- }];
642
+ return [
643
+ () => false,
644
+ fn => {
645
+ fn();
646
+ }
647
+ ];
611
648
  }
612
649
  function SuspenseList(props) {
613
650
  return props.children;
@@ -617,15 +654,17 @@ function Suspense(props) {
617
654
  const ctx = sharedConfig.context;
618
655
  const id = ctx.id + ctx.count;
619
656
  const o = createOwner();
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));
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
+ }
626
666
  }
627
- }
628
- });
667
+ });
629
668
  function suspenseError(err) {
630
669
  if (!done || !done(undefined, err)) {
631
670
  runWithOwner(o.owner, () => {
@@ -639,12 +678,14 @@ function Suspense(props) {
639
678
  count: 0
640
679
  });
641
680
  cleanNode(o);
642
- return runWithOwner(o, () => createComponent(SuspenseContext.Provider, {
643
- value,
644
- get children() {
645
- return catchError(() => props.children, suspenseError);
646
- }
647
- }));
681
+ return runWithOwner(o, () =>
682
+ createComponent(SuspenseContext.Provider, {
683
+ value,
684
+ get children() {
685
+ return catchError(() => props.children, suspenseError);
686
+ }
687
+ })
688
+ );
648
689
  }
649
690
  const res = runSuspense();
650
691
  if (suspenseComplete(value)) {
@@ -676,4 +717,58 @@ function Suspense(props) {
676
717
  }, suspenseError);
677
718
  }
678
719
 
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 };
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
+ };