solid-js 1.9.1 → 1.9.2

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 (50) hide show
  1. package/README.md +1 -1
  2. package/dist/dev.cjs +1 -1
  3. package/dist/dev.js +318 -559
  4. package/dist/server.js +74 -168
  5. package/dist/solid.cjs +1 -1
  6. package/dist/solid.js +276 -486
  7. package/h/dist/h.js +9 -40
  8. package/h/jsx-runtime/dist/jsx.js +1 -1
  9. package/h/jsx-runtime/types/index.d.ts +8 -11
  10. package/h/jsx-runtime/types/jsx.d.ts +196 -59
  11. package/h/types/hyperscript.d.ts +11 -11
  12. package/html/dist/html.cjs +1 -1
  13. package/html/dist/html.js +94 -219
  14. package/html/types/lit.d.ts +33 -52
  15. package/package.json +1 -1
  16. package/store/dist/dev.js +43 -123
  17. package/store/dist/server.js +8 -20
  18. package/store/dist/store.js +40 -114
  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 +5 -25
  23. package/store/types/store.d.ts +61 -218
  24. package/types/index.d.ts +10 -75
  25. package/types/jsx.d.ts +195 -47
  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 -233
  30. package/types/render/Suspense.d.ts +5 -5
  31. package/types/render/component.d.ts +35 -71
  32. package/types/render/flow.d.ts +31 -43
  33. package/types/render/hydration.d.ts +15 -15
  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 +98 -169
  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.cjs +14 -14
  42. package/web/dist/dev.js +89 -639
  43. package/web/dist/server.cjs +14 -14
  44. package/web/dist/server.js +108 -635
  45. package/web/dist/web.cjs +14 -14
  46. package/web/dist/web.js +87 -627
  47. package/web/storage/dist/storage.js +3 -3
  48. package/web/types/core.d.ts +1 -10
  49. package/web/types/index.d.ts +10 -27
  50. 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);
@@ -320,7 +309,7 @@ function resolveSSRNode(node) {
320
309
  let mapped = "";
321
310
  for (let i = 0, len = node.length; i < len; i++) {
322
311
  if (typeof prev !== "object" && typeof node[i] !== "object") mapped += `<!--!$-->`;
323
- mapped += resolveSSRNode((prev = node[i]));
312
+ mapped += resolveSSRNode(prev = node[i]);
324
313
  }
325
314
  return mapped;
326
315
  }
@@ -335,8 +324,7 @@ const sharedConfig = {
335
324
  return getContextId(this.context.count);
336
325
  },
337
326
  getNextContextId() {
338
- if (!this.context)
339
- throw new Error(`getNextContextId cannot be used under non-hydrating context`);
327
+ if (!this.context) throw new Error(`getNextContextId cannot be used under non-hydrating context`);
340
328
  return getContextId(this.context.count++);
341
329
  }
342
330
  };
@@ -349,13 +337,11 @@ function setHydrateContext(context) {
349
337
  sharedConfig.context = context;
350
338
  }
351
339
  function nextHydrateContext() {
352
- return sharedConfig.context
353
- ? {
354
- ...sharedConfig.context,
355
- id: sharedConfig.getNextContextId(),
356
- count: 0
357
- }
358
- : undefined;
340
+ return sharedConfig.context ? {
341
+ ...sharedConfig.context,
342
+ id: sharedConfig.getNextContextId(),
343
+ count: 0
344
+ } : undefined;
359
345
  }
360
346
  function createUniqueId() {
361
347
  return sharedConfig.getNextContextId();
@@ -430,11 +416,7 @@ function Index(props) {
430
416
  }
431
417
  function Show(props) {
432
418
  let c;
433
- return props.when
434
- ? typeof (c = props.children) === "function"
435
- ? c(props.keyed ? props.when : () => props.when)
436
- : c
437
- : props.fallback || "";
419
+ return props.when ? typeof (c = props.children) === "function" ? c(props.keyed ? props.when : () => props.when) : c : props.fallback || "";
438
420
  }
439
421
  function Switch(props) {
440
422
  let conditions = props.children;
@@ -471,14 +453,11 @@ function ErrorBoundary(props) {
471
453
  }
472
454
  createMemo(() => {
473
455
  clean = Owner;
474
- return catchError(
475
- () => (res = props.children),
476
- err => {
477
- error = err;
478
- !sync && ctx.replace("e" + id, displayFallback);
479
- sync = true;
480
- }
481
- );
456
+ return catchError(() => res = props.children, err => {
457
+ error = err;
458
+ !sync && ctx.replace("e" + id, displayFallback);
459
+ sync = true;
460
+ });
482
461
  });
483
462
  if (error) return displayFallback();
484
463
  sync = false;
@@ -508,17 +487,13 @@ function createResource(source, fetcher, options = {}) {
508
487
  if (sharedConfig.context.async && options.ssrLoadFrom !== "initial") {
509
488
  resource = sharedConfig.context.resources[id] || (sharedConfig.context.resources[id] = {});
510
489
  if (resource.ref) {
511
- if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error)
512
- resource.ref[1].refetch();
490
+ if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error) resource.ref[1].refetch();
513
491
  return resource.ref;
514
492
  }
515
493
  }
516
494
  const read = () => {
517
495
  if (error) throw error;
518
- const resolved =
519
- options.ssrLoadFrom !== "initial" &&
520
- sharedConfig.context.async &&
521
- "data" in sharedConfig.context.resources[id];
496
+ const resolved = options.ssrLoadFrom !== "initial" && sharedConfig.context.async && "data" in sharedConfig.context.resources[id];
522
497
  if (!resolved && resourceContext) resourceContext.push(id);
523
498
  if (!resolved && read.loading) {
524
499
  const ctx = useContext(SuspenseContext);
@@ -539,7 +514,7 @@ function createResource(source, fetcher, options = {}) {
539
514
  });
540
515
  function load() {
541
516
  const ctx = sharedConfig.context;
542
- if (!ctx.async) return (read.loading = !!(typeof source === "function" ? source() : source));
517
+ if (!ctx.async) return read.loading = !!(typeof source === "function" ? source() : source);
543
518
  if (ctx.resources && id in ctx.resources && "data" in ctx.resources[id]) {
544
519
  value = ctx.resources[id].data;
545
520
  return;
@@ -561,23 +536,21 @@ function createResource(source, fetcher, options = {}) {
561
536
  if (p != undefined && typeof p === "object" && "then" in p) {
562
537
  read.loading = true;
563
538
  read.state = "pending";
564
- p = p
565
- .then(res => {
566
- read.loading = false;
567
- read.state = "ready";
568
- ctx.resources[id].data = res;
569
- p = null;
570
- notifySuspense(contexts);
571
- return res;
572
- })
573
- .catch(err => {
574
- read.loading = false;
575
- read.state = "errored";
576
- read.error = error = castError(err);
577
- p = null;
578
- notifySuspense(contexts);
579
- throw error;
580
- });
539
+ p = p.then(res => {
540
+ read.loading = false;
541
+ read.state = "ready";
542
+ ctx.resources[id].data = res;
543
+ p = null;
544
+ notifySuspense(contexts);
545
+ return res;
546
+ }).catch(err => {
547
+ read.loading = false;
548
+ read.state = "errored";
549
+ read.error = error = castError(err);
550
+ p = null;
551
+ notifySuspense(contexts);
552
+ throw error;
553
+ });
581
554
  if (ctx.serialize) ctx.serialize(id, p, options.deferStream);
582
555
  return p;
583
556
  }
@@ -587,20 +560,17 @@ function createResource(source, fetcher, options = {}) {
587
560
  return ctx.resources[id].data;
588
561
  }
589
562
  if (options.ssrLoadFrom !== "initial") load();
590
- return (resource.ref = [
591
- read,
592
- {
593
- refetch: load,
594
- mutate: v => (value = v)
595
- }
596
- ]);
563
+ return resource.ref = [read, {
564
+ refetch: load,
565
+ mutate: v => value = v
566
+ }];
597
567
  }
598
568
  function lazy(fn) {
599
569
  let p;
600
570
  let load = id => {
601
571
  if (!p) {
602
572
  p = fn();
603
- p.then(mod => (p.resolved = mod.default));
573
+ p.then(mod => p.resolved = mod.default);
604
574
  if (id) sharedConfig.context.lazy[id] = p;
605
575
  }
606
576
  return p;
@@ -609,8 +579,7 @@ function lazy(fn) {
609
579
  const wrap = props => {
610
580
  const id = sharedConfig.context.id;
611
581
  let ref = sharedConfig.context.lazy[id];
612
- if (ref) p = ref;
613
- else load(id);
582
+ if (ref) p = ref;else load(id);
614
583
  if (p.resolved) return p.resolved(props);
615
584
  const ctx = useContext(SuspenseContext);
616
585
  const track = {
@@ -622,12 +591,10 @@ function lazy(fn) {
622
591
  contexts.add(ctx);
623
592
  }
624
593
  if (sharedConfig.context.async) {
625
- sharedConfig.context.block(
626
- p.then(() => {
627
- track.loading = false;
628
- notifySuspense(contexts);
629
- })
630
- );
594
+ sharedConfig.context.block(p.then(() => {
595
+ track.loading = false;
596
+ notifySuspense(contexts);
597
+ }));
631
598
  }
632
599
  return "";
633
600
  };
@@ -655,12 +622,9 @@ function startTransition(fn) {
655
622
  fn();
656
623
  }
657
624
  function useTransition() {
658
- return [
659
- () => false,
660
- fn => {
661
- fn();
662
- }
663
- ];
625
+ return [() => false, fn => {
626
+ fn();
627
+ }];
664
628
  }
665
629
  function SuspenseList(props) {
666
630
  return props.children;
@@ -670,17 +634,15 @@ function Suspense(props) {
670
634
  const ctx = sharedConfig.context;
671
635
  const id = sharedConfig.getContextId();
672
636
  const o = createOwner();
673
- const value =
674
- ctx.suspense[id] ||
675
- (ctx.suspense[id] = {
676
- resources: new Map(),
677
- completed: () => {
678
- const res = runSuspense();
679
- if (suspenseComplete(value)) {
680
- done(resolveSSRNode(res));
681
- }
637
+ const value = ctx.suspense[id] || (ctx.suspense[id] = {
638
+ resources: new Map(),
639
+ completed: () => {
640
+ const res = runSuspense();
641
+ if (suspenseComplete(value)) {
642
+ done(resolveSSRNode(res));
682
643
  }
683
- });
644
+ }
645
+ });
684
646
  function suspenseError(err) {
685
647
  if (!done || !done(undefined, err)) {
686
648
  runWithOwner(o.owner, () => {
@@ -694,14 +656,12 @@ function Suspense(props) {
694
656
  count: 0
695
657
  });
696
658
  cleanNode(o);
697
- return runWithOwner(o, () =>
698
- createComponent(SuspenseContext.Provider, {
699
- value,
700
- get children() {
701
- return catchError(() => props.children, suspenseError);
702
- }
703
- })
704
- );
659
+ return runWithOwner(o, () => createComponent(SuspenseContext.Provider, {
660
+ value,
661
+ get children() {
662
+ return catchError(() => props.children, suspenseError);
663
+ }
664
+ }));
705
665
  }
706
666
  const res = runSuspense();
707
667
  if (suspenseComplete(value)) {
@@ -733,58 +693,4 @@ function Suspense(props) {
733
693
  }, suspenseError);
734
694
  }
735
695
 
736
- export {
737
- $DEVCOMP,
738
- $PROXY,
739
- $TRACK,
740
- DEV,
741
- ErrorBoundary,
742
- For,
743
- Index,
744
- Match,
745
- Show,
746
- Suspense,
747
- SuspenseList,
748
- Switch,
749
- batch,
750
- catchError,
751
- children,
752
- createComponent,
753
- createComputed,
754
- createContext,
755
- createDeferred,
756
- createEffect,
757
- createMemo,
758
- createReaction,
759
- createRenderEffect,
760
- createResource,
761
- createRoot,
762
- createSelector,
763
- createSignal,
764
- createUniqueId,
765
- enableExternalSource,
766
- enableHydration,
767
- enableScheduling,
768
- equalFn,
769
- from,
770
- getListener,
771
- getOwner,
772
- indexArray,
773
- lazy,
774
- mapArray,
775
- mergeProps,
776
- observable,
777
- on,
778
- onCleanup,
779
- onError,
780
- onMount,
781
- requestCallback,
782
- resetErrorBoundaries,
783
- runWithOwner,
784
- sharedConfig,
785
- splitProps,
786
- startTransition,
787
- untrack,
788
- useContext,
789
- useTransition
790
- };
696
+ 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
@@ -271,7 +271,7 @@ function createResource(pSource, pFetcher, pOptions) {
271
271
  id = null,
272
272
  loadedUnderTransition = false,
273
273
  scheduled = false,
274
- resolved = ("initialValue" in options),
274
+ resolved = "initialValue" in options,
275
275
  dynamic = typeof source === "function" && createMemo(source);
276
276
  const contexts = new Set(),
277
277
  [value, setValue] = (options.storage || createSignal)(options.initialValue),