solid-js 1.7.8 → 1.7.9

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.js +534 -296
  2. package/dist/server.js +175 -77
  3. package/dist/solid.js +461 -254
  4. package/h/dist/h.cjs +2 -2
  5. package/h/dist/h.js +36 -10
  6. package/h/jsx-runtime/dist/jsx.js +1 -1
  7. package/h/jsx-runtime/types/index.d.ts +11 -8
  8. package/h/jsx-runtime/types/jsx.d.ts +3 -0
  9. package/h/types/hyperscript.d.ts +11 -11
  10. package/h/types/index.d.ts +3 -2
  11. package/html/dist/html.cjs +2 -2
  12. package/html/dist/html.js +218 -96
  13. package/html/types/index.d.ts +3 -2
  14. package/html/types/lit.d.ts +45 -31
  15. package/package.json +1 -1
  16. package/store/dist/dev.cjs +34 -32
  17. package/store/dist/dev.js +141 -67
  18. package/store/dist/server.js +19 -8
  19. package/store/dist/store.cjs +34 -32
  20. package/store/dist/store.js +132 -64
  21. package/store/types/index.d.ts +21 -7
  22. package/store/types/modifiers.d.ts +6 -3
  23. package/store/types/mutable.d.ts +5 -2
  24. package/store/types/server.d.ts +12 -4
  25. package/store/types/store.d.ts +217 -63
  26. package/types/index.d.ts +69 -9
  27. package/types/jsx.d.ts +3 -0
  28. package/types/reactive/array.d.ts +12 -4
  29. package/types/reactive/observable.d.ts +25 -17
  30. package/types/reactive/scheduler.d.ts +9 -6
  31. package/types/reactive/signal.d.ts +227 -136
  32. package/types/render/Suspense.d.ts +5 -5
  33. package/types/render/component.d.ts +62 -31
  34. package/types/render/flow.d.ts +43 -31
  35. package/types/render/hydration.d.ts +12 -12
  36. package/types/server/index.d.ts +55 -2
  37. package/types/server/reactive.d.ts +67 -40
  38. package/types/server/rendering.d.ts +171 -95
  39. package/universal/dist/dev.js +28 -12
  40. package/universal/dist/universal.js +28 -12
  41. package/universal/types/index.d.ts +3 -1
  42. package/universal/types/universal.d.ts +0 -1
  43. package/web/dist/dev.js +610 -79
  44. package/web/dist/server.js +176 -77
  45. package/web/dist/web.js +610 -79
  46. package/web/types/client.d.ts +2 -2
  47. package/web/types/core.d.ts +10 -1
  48. package/web/types/index.d.ts +27 -10
  49. 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,18 +35,22 @@ 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
- root = fn.length === 0 ? UNOWNED : {
45
- context: null,
46
- owner: detachedOwner === undefined ? owner : detachedOwner,
47
- owned: null,
48
- cleanups: null
49
- };
45
+ root =
46
+ fn.length === 0
47
+ ? UNOWNED
48
+ : {
49
+ context: null,
50
+ owner: detachedOwner === undefined ? owner : detachedOwner,
51
+ owned: null,
52
+ cleanups: null
53
+ };
50
54
  Owner = root;
51
55
  let result;
52
56
  try {
@@ -59,9 +63,12 @@ function createRoot(fn, detachedOwner) {
59
63
  return result;
60
64
  }
61
65
  function createSignal(value, options) {
62
- return [() => value, v => {
63
- return value = typeof v === "function" ? v(value) : v;
64
- }];
66
+ return [
67
+ () => value,
68
+ v => {
69
+ return (value = typeof v === "function" ? v(value) : v);
70
+ }
71
+ ];
65
72
  }
66
73
  function createComputed(fn, value) {
67
74
  Owner = createOwner();
@@ -118,7 +125,8 @@ function on(deps, fn, options = {}) {
118
125
  function onMount(fn) {}
119
126
  function onCleanup(fn) {
120
127
  if (Owner) {
121
- if (!Owner.cleanups) Owner.cleanups = [fn];else Owner.cleanups.push(fn);
128
+ if (!Owner.cleanups) Owner.cleanups = [fn];
129
+ else Owner.cleanups.push(fn);
122
130
  }
123
131
  return fn;
124
132
  }
@@ -151,9 +159,12 @@ function catchError(fn, handler) {
151
159
  }
152
160
  function onError(fn) {
153
161
  if (Owner) {
154
- if (Owner.context === null) Owner.context = {
155
- [ERROR]: [fn]
156
- };else if (!Owner.context[ERROR]) Owner.context[ERROR] = [fn];else Owner.context[ERROR].push(fn);
162
+ if (Owner.context === null)
163
+ Owner.context = {
164
+ [ERROR]: [fn]
165
+ };
166
+ else if (!Owner.context[ERROR]) Owner.context[ERROR] = [fn];
167
+ else Owner.context[ERROR].push(fn);
157
168
  }
158
169
  }
159
170
  function getListener() {
@@ -194,7 +205,11 @@ function runWithOwner(o, fn) {
194
205
  }
195
206
  }
196
207
  function lookup(owner, key) {
197
- return owner ? owner.context && owner.context[key] !== undefined ? owner.context[key] : lookup(owner.owner, key) : undefined;
208
+ return owner
209
+ ? owner.context && owner.context[key] !== undefined
210
+ ? owner.context[key]
211
+ : lookup(owner.owner, key)
212
+ : undefined;
198
213
  }
199
214
  function resolveChildren(children) {
200
215
  if (typeof children === "function" && !children.length) return resolveChildren(children());
@@ -240,7 +255,8 @@ function observable(input) {
240
255
  if (!(observer instanceof Object) || observer == null) {
241
256
  throw new TypeError("Expected the observer to be an object.");
242
257
  }
243
- const handler = typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
258
+ const handler =
259
+ typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
244
260
  if (!handler) {
245
261
  return {
246
262
  unsubscribe() {}
@@ -269,7 +285,7 @@ function from(producer) {
269
285
  const [s, set] = createSignal(undefined);
270
286
  if ("subscribe" in producer) {
271
287
  const unsub = producer.subscribe(v => set(() => v));
272
- onCleanup(() => "unsubscribe" in unsub ? unsub.unsubscribe() : unsub());
288
+ onCleanup(() => ("unsubscribe" in unsub ? unsub.unsubscribe() : unsub()));
273
289
  } else {
274
290
  const clean = producer(set);
275
291
  onCleanup(clean);
@@ -296,11 +312,13 @@ function setHydrateContext(context) {
296
312
  sharedConfig.context = context;
297
313
  }
298
314
  function nextHydrateContext() {
299
- return sharedConfig.context ? {
300
- ...sharedConfig.context,
301
- id: `${sharedConfig.context.id}${sharedConfig.context.count++}-`,
302
- count: 0
303
- } : undefined;
315
+ return sharedConfig.context
316
+ ? {
317
+ ...sharedConfig.context,
318
+ id: `${sharedConfig.context.id}${sharedConfig.context.count++}-`,
319
+ count: 0
320
+ }
321
+ : undefined;
304
322
  }
305
323
  function createUniqueId() {
306
324
  const ctx = sharedConfig.context;
@@ -376,7 +394,11 @@ function Index(props) {
376
394
  }
377
395
  function Show(props) {
378
396
  let c;
379
- return props.when ? typeof (c = props.children) === "function" ? c(props.keyed ? props.when : () => props.when) : c : props.fallback || "";
397
+ return props.when
398
+ ? typeof (c = props.children) === "function"
399
+ ? c(props.keyed ? props.when : () => props.when)
400
+ : c
401
+ : props.fallback || "";
380
402
  }
381
403
  function Switch(props) {
382
404
  let conditions = props.children;
@@ -413,11 +435,14 @@ function ErrorBoundary(props) {
413
435
  }
414
436
  createMemo(() => {
415
437
  clean = Owner;
416
- return catchError(() => res = props.children, err => {
417
- error = err;
418
- !sync && ctx.replace("e" + id, displayFallback);
419
- sync = true;
420
- });
438
+ return catchError(
439
+ () => (res = props.children),
440
+ err => {
441
+ error = err;
442
+ !sync && ctx.replace("e" + id, displayFallback);
443
+ sync = true;
444
+ }
445
+ );
421
446
  });
422
447
  if (error) return displayFallback();
423
448
  sync = false;
@@ -447,14 +472,18 @@ function createResource(source, fetcher, options = {}) {
447
472
  if (sharedConfig.context.async && options.ssrLoadFrom !== "initial") {
448
473
  resource = sharedConfig.context.resources[id] || (sharedConfig.context.resources[id] = {});
449
474
  if (resource.ref) {
450
- if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error) resource.ref[1].refetch();
475
+ if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error)
476
+ resource.ref[1].refetch();
451
477
  return resource.ref;
452
478
  }
453
479
  }
454
480
  const read = () => {
455
481
  if (error) throw error;
456
482
  if (resourceContext && p) resourceContext.push(p);
457
- const resolved = options.ssrLoadFrom !== "initial" && sharedConfig.context.async && "data" in sharedConfig.context.resources[id];
483
+ const resolved =
484
+ options.ssrLoadFrom !== "initial" &&
485
+ sharedConfig.context.async &&
486
+ "data" in sharedConfig.context.resources[id];
458
487
  if (!resolved && read.loading) {
459
488
  const ctx = useContext(SuspenseContext);
460
489
  if (ctx) {
@@ -474,7 +503,7 @@ function createResource(source, fetcher, options = {}) {
474
503
  });
475
504
  function load() {
476
505
  const ctx = sharedConfig.context;
477
- if (!ctx.async) return read.loading = !!(typeof source === "function" ? source() : source);
506
+ if (!ctx.async) return (read.loading = !!(typeof source === "function" ? source() : source));
478
507
  if (ctx.resources && id in ctx.resources && "data" in ctx.resources[id]) {
479
508
  value = ctx.resources[id].data;
480
509
  return;
@@ -482,9 +511,11 @@ function createResource(source, fetcher, options = {}) {
482
511
  resourceContext = [];
483
512
  const lookup = typeof source === "function" ? source() : source;
484
513
  if (resourceContext.length) {
485
- p = Promise.all(resourceContext).then(() => fetcher(source(), {
486
- value
487
- }));
514
+ p = Promise.all(resourceContext).then(() =>
515
+ fetcher(source(), {
516
+ value
517
+ })
518
+ );
488
519
  }
489
520
  resourceContext = null;
490
521
  if (!p) {
@@ -497,20 +528,22 @@ function createResource(source, fetcher, options = {}) {
497
528
  read.loading = true;
498
529
  read.state = "pending";
499
530
  if (ctx.writeResource) ctx.writeResource(id, p, undefined, options.deferStream);
500
- return p.then(res => {
501
- read.loading = false;
502
- read.state = "ready";
503
- ctx.resources[id].data = res;
504
- p = null;
505
- notifySuspense(contexts);
506
- return res;
507
- }).catch(err => {
508
- read.loading = false;
509
- read.state = "errored";
510
- read.error = error = castError(err);
511
- p = null;
512
- notifySuspense(contexts);
513
- });
531
+ return p
532
+ .then(res => {
533
+ read.loading = false;
534
+ read.state = "ready";
535
+ ctx.resources[id].data = res;
536
+ p = null;
537
+ notifySuspense(contexts);
538
+ return res;
539
+ })
540
+ .catch(err => {
541
+ read.loading = false;
542
+ read.state = "errored";
543
+ read.error = error = castError(err);
544
+ p = null;
545
+ notifySuspense(contexts);
546
+ });
514
547
  }
515
548
  ctx.resources[id].data = p;
516
549
  if (ctx.writeResource) ctx.writeResource(id, p);
@@ -518,17 +551,20 @@ function createResource(source, fetcher, options = {}) {
518
551
  return ctx.resources[id].data;
519
552
  }
520
553
  if (options.ssrLoadFrom !== "initial") load();
521
- return resource.ref = [read, {
522
- refetch: load,
523
- mutate: v => value = v
524
- }];
554
+ return (resource.ref = [
555
+ read,
556
+ {
557
+ refetch: load,
558
+ mutate: v => (value = v)
559
+ }
560
+ ]);
525
561
  }
526
562
  function lazy(fn) {
527
563
  let p;
528
564
  let load = id => {
529
565
  if (!p) {
530
566
  p = fn();
531
- p.then(mod => p.resolved = mod.default);
567
+ p.then(mod => (p.resolved = mod.default));
532
568
  if (id) sharedConfig.context.lazy[id] = p;
533
569
  }
534
570
  return p;
@@ -537,7 +573,8 @@ function lazy(fn) {
537
573
  const wrap = props => {
538
574
  const id = sharedConfig.context.id.slice(0, -1);
539
575
  let ref = sharedConfig.context.lazy[id];
540
- if (ref) p = ref;else load(id);
576
+ if (ref) p = ref;
577
+ else load(id);
541
578
  if (p.resolved) return p.resolved(props);
542
579
  const ctx = useContext(SuspenseContext);
543
580
  const track = {
@@ -549,10 +586,12 @@ function lazy(fn) {
549
586
  contexts.add(ctx);
550
587
  }
551
588
  if (sharedConfig.context.async) {
552
- sharedConfig.context.block(p.then(() => {
553
- track.loading = false;
554
- notifySuspense(contexts);
555
- }));
589
+ sharedConfig.context.block(
590
+ p.then(() => {
591
+ track.loading = false;
592
+ notifySuspense(contexts);
593
+ })
594
+ );
556
595
  }
557
596
  return "";
558
597
  };
@@ -580,9 +619,12 @@ function startTransition(fn) {
580
619
  fn();
581
620
  }
582
621
  function useTransition() {
583
- return [() => false, fn => {
584
- fn();
585
- }];
622
+ return [
623
+ () => false,
624
+ fn => {
625
+ fn();
626
+ }
627
+ ];
586
628
  }
587
629
  function SuspenseList(props) {
588
630
  return props.children;
@@ -592,15 +634,17 @@ function Suspense(props) {
592
634
  const ctx = sharedConfig.context;
593
635
  const id = ctx.id + ctx.count;
594
636
  const o = createOwner();
595
- const value = ctx.suspense[id] || (ctx.suspense[id] = {
596
- resources: new Map(),
597
- completed: () => {
598
- const res = runSuspense();
599
- if (suspenseComplete(value)) {
600
- done(resolveSSRNode(res));
637
+ const value =
638
+ ctx.suspense[id] ||
639
+ (ctx.suspense[id] = {
640
+ resources: new Map(),
641
+ completed: () => {
642
+ const res = runSuspense();
643
+ if (suspenseComplete(value)) {
644
+ done(resolveSSRNode(res));
645
+ }
601
646
  }
602
- }
603
- });
647
+ });
604
648
  function suspenseError(err) {
605
649
  if (!done || !done(undefined, err)) {
606
650
  runWithOwner(o.owner, () => {
@@ -614,12 +658,14 @@ function Suspense(props) {
614
658
  count: 0
615
659
  });
616
660
  cleanNode(o);
617
- return runWithOwner(o, () => createComponent(SuspenseContext.Provider, {
618
- value,
619
- get children() {
620
- return catchError(() => props.children, suspenseError);
621
- }
622
- }));
661
+ return runWithOwner(o, () =>
662
+ createComponent(SuspenseContext.Provider, {
663
+ value,
664
+ get children() {
665
+ return catchError(() => props.children, suspenseError);
666
+ }
667
+ })
668
+ );
623
669
  }
624
670
  const res = runSuspense();
625
671
  if (suspenseComplete(value)) return res;
@@ -648,4 +694,56 @@ function Suspense(props) {
648
694
  }, suspenseError);
649
695
  }
650
696
 
651
- export { $DEVCOMP, $PROXY, $TRACK, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createReaction, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, resetErrorBoundaries, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
697
+ export {
698
+ $DEVCOMP,
699
+ $PROXY,
700
+ $TRACK,
701
+ DEV,
702
+ ErrorBoundary,
703
+ For,
704
+ Index,
705
+ Match,
706
+ Show,
707
+ Suspense,
708
+ SuspenseList,
709
+ Switch,
710
+ batch,
711
+ children,
712
+ createComponent,
713
+ createComputed,
714
+ createContext,
715
+ createDeferred,
716
+ createEffect,
717
+ createMemo,
718
+ createReaction,
719
+ createRenderEffect,
720
+ createResource,
721
+ createRoot,
722
+ createSelector,
723
+ createSignal,
724
+ createUniqueId,
725
+ enableExternalSource,
726
+ enableHydration,
727
+ enableScheduling,
728
+ equalFn,
729
+ from,
730
+ getListener,
731
+ getOwner,
732
+ lazy,
733
+ mapArray,
734
+ mergeProps,
735
+ observable,
736
+ on,
737
+ onCleanup,
738
+ onError,
739
+ onMount,
740
+ requestCallback,
741
+ resetErrorBoundaries,
742
+ runWithOwner,
743
+ sharedConfig,
744
+ splitProps,
745
+ startTransition,
746
+ untrack,
747
+ useContext,
748
+ useTransition
749
+ };