solid-js 1.8.22 → 1.9.0

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 (59) hide show
  1. package/dist/dev.cjs +7 -6
  2. package/dist/dev.js +567 -325
  3. package/dist/server.cjs +1 -1
  4. package/dist/server.js +169 -75
  5. package/dist/solid.cjs +7 -6
  6. package/dist/solid.js +494 -283
  7. package/h/dist/h.js +40 -9
  8. package/h/jsx-runtime/dist/jsx.js +1 -1
  9. package/h/jsx-runtime/types/index.d.ts +13 -10
  10. package/h/jsx-runtime/types/jsx.d.ts +22 -1
  11. package/h/types/hyperscript.d.ts +11 -11
  12. package/h/types/index.d.ts +1 -1
  13. package/html/dist/html.cjs +4 -2
  14. package/html/dist/html.js +222 -95
  15. package/html/types/index.d.ts +1 -1
  16. package/html/types/lit.d.ts +52 -33
  17. package/package.json +1 -5
  18. package/store/dist/dev.cjs +1 -1
  19. package/store/dist/dev.js +123 -43
  20. package/store/dist/server.cjs +4 -0
  21. package/store/dist/server.js +23 -8
  22. package/store/dist/store.cjs +1 -1
  23. package/store/dist/store.js +114 -40
  24. package/store/package.json +0 -4
  25. package/store/types/index.d.ts +21 -7
  26. package/store/types/modifiers.d.ts +6 -3
  27. package/store/types/mutable.d.ts +5 -2
  28. package/store/types/server.d.ts +26 -5
  29. package/store/types/store.d.ts +219 -62
  30. package/types/index.d.ts +75 -10
  31. package/types/jsx.d.ts +35 -8
  32. package/types/reactive/array.d.ts +12 -4
  33. package/types/reactive/observable.d.ts +25 -17
  34. package/types/reactive/scheduler.d.ts +9 -6
  35. package/types/reactive/signal.d.ts +236 -143
  36. package/types/render/Suspense.d.ts +5 -5
  37. package/types/render/component.d.ts +64 -33
  38. package/types/render/flow.d.ts +43 -31
  39. package/types/render/hydration.d.ts +15 -15
  40. package/types/server/index.d.ts +57 -2
  41. package/types/server/reactive.d.ts +73 -42
  42. package/types/server/rendering.d.ts +169 -98
  43. package/universal/dist/dev.js +28 -12
  44. package/universal/dist/universal.js +28 -12
  45. package/universal/types/index.d.ts +3 -1
  46. package/universal/types/universal.d.ts +0 -1
  47. package/web/dist/dev.cjs +57 -24
  48. package/web/dist/dev.js +679 -101
  49. package/web/dist/server.cjs +96 -15
  50. package/web/dist/server.js +676 -105
  51. package/web/dist/web.cjs +53 -23
  52. package/web/dist/web.js +664 -99
  53. package/web/package.json +0 -4
  54. package/web/storage/dist/storage.js +3 -3
  55. package/web/types/client.d.ts +5 -3
  56. package/web/types/core.d.ts +10 -1
  57. package/web/types/index.d.ts +27 -10
  58. package/web/types/server-mock.d.ts +47 -32
  59. package/web/types/server.d.ts +88 -0
package/dist/server.cjs CHANGED
@@ -579,7 +579,7 @@ function lazy(fn) {
579
579
  };
580
580
  const contexts = new Set();
581
581
  const wrap = props => {
582
- const id = sharedConfig.context.id.slice(0, -1);
582
+ const id = sharedConfig.context.id;
583
583
  let ref = sharedConfig.context.lazy[id];
584
584
  if (ref) p = ref;else load(id);
585
585
  if (p.resolved) return p.resolved(props);
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);
@@ -309,7 +320,7 @@ function resolveSSRNode(node) {
309
320
  let mapped = "";
310
321
  for (let i = 0, len = node.length; i < len; i++) {
311
322
  if (typeof prev !== "object" && typeof node[i] !== "object") mapped += `<!--!$-->`;
312
- mapped += resolveSSRNode(prev = node[i]);
323
+ mapped += resolveSSRNode((prev = node[i]));
313
324
  }
314
325
  return mapped;
315
326
  }
@@ -324,7 +335,8 @@ const sharedConfig = {
324
335
  return getContextId(this.context.count);
325
336
  },
326
337
  getNextContextId() {
327
- if (!this.context) throw new Error(`getNextContextId cannot be used under non-hydrating context`);
338
+ if (!this.context)
339
+ throw new Error(`getNextContextId cannot be used under non-hydrating context`);
328
340
  return getContextId(this.context.count++);
329
341
  }
330
342
  };
@@ -337,11 +349,13 @@ function setHydrateContext(context) {
337
349
  sharedConfig.context = context;
338
350
  }
339
351
  function nextHydrateContext() {
340
- return sharedConfig.context ? {
341
- ...sharedConfig.context,
342
- id: sharedConfig.getNextContextId(),
343
- count: 0
344
- } : undefined;
352
+ return sharedConfig.context
353
+ ? {
354
+ ...sharedConfig.context,
355
+ id: sharedConfig.getNextContextId(),
356
+ count: 0
357
+ }
358
+ : undefined;
345
359
  }
346
360
  function createUniqueId() {
347
361
  return sharedConfig.getNextContextId();
@@ -416,7 +430,11 @@ function Index(props) {
416
430
  }
417
431
  function Show(props) {
418
432
  let c;
419
- return props.when ? typeof (c = props.children) === "function" ? c(props.keyed ? props.when : () => props.when) : c : props.fallback || "";
433
+ return props.when
434
+ ? typeof (c = props.children) === "function"
435
+ ? c(props.keyed ? props.when : () => props.when)
436
+ : c
437
+ : props.fallback || "";
420
438
  }
421
439
  function Switch(props) {
422
440
  let conditions = props.children;
@@ -453,11 +471,14 @@ function ErrorBoundary(props) {
453
471
  }
454
472
  createMemo(() => {
455
473
  clean = Owner;
456
- return catchError(() => res = props.children, err => {
457
- error = err;
458
- !sync && ctx.replace("e" + id, displayFallback);
459
- sync = true;
460
- });
474
+ return catchError(
475
+ () => (res = props.children),
476
+ err => {
477
+ error = err;
478
+ !sync && ctx.replace("e" + id, displayFallback);
479
+ sync = true;
480
+ }
481
+ );
461
482
  });
462
483
  if (error) return displayFallback();
463
484
  sync = false;
@@ -487,13 +508,17 @@ function createResource(source, fetcher, options = {}) {
487
508
  if (sharedConfig.context.async && options.ssrLoadFrom !== "initial") {
488
509
  resource = sharedConfig.context.resources[id] || (sharedConfig.context.resources[id] = {});
489
510
  if (resource.ref) {
490
- if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error) resource.ref[1].refetch();
511
+ if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error)
512
+ resource.ref[1].refetch();
491
513
  return resource.ref;
492
514
  }
493
515
  }
494
516
  const read = () => {
495
517
  if (error) throw error;
496
- const resolved = options.ssrLoadFrom !== "initial" && sharedConfig.context.async && "data" in sharedConfig.context.resources[id];
518
+ const resolved =
519
+ options.ssrLoadFrom !== "initial" &&
520
+ sharedConfig.context.async &&
521
+ "data" in sharedConfig.context.resources[id];
497
522
  if (!resolved && resourceContext) resourceContext.push(id);
498
523
  if (!resolved && read.loading) {
499
524
  const ctx = useContext(SuspenseContext);
@@ -514,7 +539,7 @@ function createResource(source, fetcher, options = {}) {
514
539
  });
515
540
  function load() {
516
541
  const ctx = sharedConfig.context;
517
- if (!ctx.async) return read.loading = !!(typeof source === "function" ? source() : source);
542
+ if (!ctx.async) return (read.loading = !!(typeof source === "function" ? source() : source));
518
543
  if (ctx.resources && id in ctx.resources && "data" in ctx.resources[id]) {
519
544
  value = ctx.resources[id].data;
520
545
  return;
@@ -536,21 +561,23 @@ function createResource(source, fetcher, options = {}) {
536
561
  if (p != undefined && typeof p === "object" && "then" in p) {
537
562
  read.loading = true;
538
563
  read.state = "pending";
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
- });
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
+ });
554
581
  if (ctx.serialize) ctx.serialize(id, p, options.deferStream);
555
582
  return p;
556
583
  }
@@ -560,26 +587,30 @@ function createResource(source, fetcher, options = {}) {
560
587
  return ctx.resources[id].data;
561
588
  }
562
589
  if (options.ssrLoadFrom !== "initial") load();
563
- return resource.ref = [read, {
564
- refetch: load,
565
- mutate: v => value = v
566
- }];
590
+ return (resource.ref = [
591
+ read,
592
+ {
593
+ refetch: load,
594
+ mutate: v => (value = v)
595
+ }
596
+ ]);
567
597
  }
568
598
  function lazy(fn) {
569
599
  let p;
570
600
  let load = id => {
571
601
  if (!p) {
572
602
  p = fn();
573
- p.then(mod => p.resolved = mod.default);
603
+ p.then(mod => (p.resolved = mod.default));
574
604
  if (id) sharedConfig.context.lazy[id] = p;
575
605
  }
576
606
  return p;
577
607
  };
578
608
  const contexts = new Set();
579
609
  const wrap = props => {
580
- const id = sharedConfig.context.id.slice(0, -1);
610
+ const id = sharedConfig.context.id;
581
611
  let ref = sharedConfig.context.lazy[id];
582
- if (ref) p = ref;else load(id);
612
+ if (ref) p = ref;
613
+ else load(id);
583
614
  if (p.resolved) return p.resolved(props);
584
615
  const ctx = useContext(SuspenseContext);
585
616
  const track = {
@@ -591,10 +622,12 @@ function lazy(fn) {
591
622
  contexts.add(ctx);
592
623
  }
593
624
  if (sharedConfig.context.async) {
594
- sharedConfig.context.block(p.then(() => {
595
- track.loading = false;
596
- notifySuspense(contexts);
597
- }));
625
+ sharedConfig.context.block(
626
+ p.then(() => {
627
+ track.loading = false;
628
+ notifySuspense(contexts);
629
+ })
630
+ );
598
631
  }
599
632
  return "";
600
633
  };
@@ -622,9 +655,12 @@ function startTransition(fn) {
622
655
  fn();
623
656
  }
624
657
  function useTransition() {
625
- return [() => false, fn => {
626
- fn();
627
- }];
658
+ return [
659
+ () => false,
660
+ fn => {
661
+ fn();
662
+ }
663
+ ];
628
664
  }
629
665
  function SuspenseList(props) {
630
666
  return props.children;
@@ -634,15 +670,17 @@ function Suspense(props) {
634
670
  const ctx = sharedConfig.context;
635
671
  const id = sharedConfig.getContextId();
636
672
  const o = createOwner();
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));
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
+ }
643
682
  }
644
- }
645
- });
683
+ });
646
684
  function suspenseError(err) {
647
685
  if (!done || !done(undefined, err)) {
648
686
  runWithOwner(o.owner, () => {
@@ -656,12 +694,14 @@ function Suspense(props) {
656
694
  count: 0
657
695
  });
658
696
  cleanNode(o);
659
- return runWithOwner(o, () => createComponent(SuspenseContext.Provider, {
660
- value,
661
- get children() {
662
- return catchError(() => props.children, suspenseError);
663
- }
664
- }));
697
+ return runWithOwner(o, () =>
698
+ createComponent(SuspenseContext.Provider, {
699
+ value,
700
+ get children() {
701
+ return catchError(() => props.children, suspenseError);
702
+ }
703
+ })
704
+ );
665
705
  }
666
706
  const res = runSuspense();
667
707
  if (suspenseComplete(value)) {
@@ -693,4 +733,58 @@ function Suspense(props) {
693
733
  }, suspenseError);
694
734
  }
695
735
 
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 };
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
+ };
package/dist/solid.cjs CHANGED
@@ -146,6 +146,7 @@ function nextHydrateContext() {
146
146
 
147
147
  const equalFn = (a, b) => a === b;
148
148
  const $PROXY = Symbol("solid-proxy");
149
+ const SUPPORTS_PROXY = typeof Proxy === "function";
149
150
  const $TRACK = Symbol("solid-track");
150
151
  const $DEVCOMP = Symbol("solid-dev-component");
151
152
  const signalOptions = {
@@ -923,11 +924,11 @@ function cleanNode(node) {
923
924
  }
924
925
  }
925
926
  }
927
+ if (node.tOwned) {
928
+ for (i = node.tOwned.length - 1; i >= 0; i--) cleanNode(node.tOwned[i]);
929
+ delete node.tOwned;
930
+ }
926
931
  if (Transition && Transition.running && node.pure) {
927
- if (node.tOwned) {
928
- for (i = node.tOwned.length - 1; i >= 0; i--) cleanNode(node.tOwned[i]);
929
- delete node.tOwned;
930
- }
931
932
  reset(node, true);
932
933
  } else if (node.owned) {
933
934
  for (i = node.owned.length - 1; i >= 0; i--) cleanNode(node.owned[i]);
@@ -1289,7 +1290,7 @@ function mergeProps(...sources) {
1289
1290
  proxy = proxy || !!s && $PROXY in s;
1290
1291
  sources[i] = typeof s === "function" ? (proxy = true, createMemo(s)) : s;
1291
1292
  }
1292
- if (proxy) {
1293
+ if (SUPPORTS_PROXY && proxy) {
1293
1294
  return new Proxy({
1294
1295
  get(property) {
1295
1296
  for (let i = sources.length - 1; i >= 0; i--) {
@@ -1344,7 +1345,7 @@ function mergeProps(...sources) {
1344
1345
  return target;
1345
1346
  }
1346
1347
  function splitProps(props, ...keys) {
1347
- if ($PROXY in props) {
1348
+ if (SUPPORTS_PROXY && $PROXY in props) {
1348
1349
  const blocked = new Set(keys.length > 1 ? keys.flat() : keys[0]);
1349
1350
  const res = keys.map(k => {
1350
1351
  return new Proxy({