solid-js 1.7.10 → 1.7.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.cjs +3 -3
  2. package/dist/dev.js +298 -531
  3. package/dist/server.cjs +3 -2
  4. package/dist/server.js +77 -170
  5. package/dist/solid.cjs +3 -3
  6. package/dist/solid.js +256 -458
  7. package/h/dist/h.js +8 -34
  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 +1 -0
  11. package/h/types/hyperscript.d.ts +11 -11
  12. package/html/dist/html.js +94 -216
  13. package/html/types/lit.d.ts +31 -45
  14. package/package.json +1 -1
  15. package/store/dist/dev.js +42 -114
  16. package/store/dist/server.js +8 -19
  17. package/store/dist/store.js +39 -105
  18. package/store/types/index.d.ts +7 -21
  19. package/store/types/modifiers.d.ts +3 -6
  20. package/store/types/mutable.d.ts +2 -5
  21. package/store/types/server.d.ts +4 -12
  22. package/store/types/store.d.ts +61 -218
  23. package/types/index.d.ts +9 -72
  24. package/types/jsx.d.ts +2 -1
  25. package/types/reactive/array.d.ts +4 -12
  26. package/types/reactive/observable.d.ts +17 -25
  27. package/types/reactive/scheduler.d.ts +6 -9
  28. package/types/reactive/signal.d.ts +140 -226
  29. package/types/render/Suspense.d.ts +5 -5
  30. package/types/render/component.d.ts +31 -62
  31. package/types/render/flow.d.ts +31 -43
  32. package/types/render/hydration.d.ts +12 -12
  33. package/types/server/index.d.ts +2 -56
  34. package/types/server/reactive.d.ts +40 -67
  35. package/types/server/rendering.d.ts +95 -171
  36. package/universal/dist/dev.js +12 -28
  37. package/universal/dist/universal.js +12 -28
  38. package/universal/types/index.d.ts +1 -3
  39. package/universal/types/universal.d.ts +1 -0
  40. package/web/dist/dev.js +79 -610
  41. package/web/dist/server.js +78 -177
  42. package/web/dist/web.js +79 -610
  43. package/web/types/client.d.ts +2 -2
  44. package/web/types/core.d.ts +1 -10
  45. package/web/types/index.d.ts +10 -27
  46. package/web/types/server-mock.d.ts +32 -47
package/dist/server.cjs CHANGED
@@ -346,9 +346,10 @@ function mergeProps(...sources) {
346
346
  enumerable: true,
347
347
  get() {
348
348
  for (let i = sources.length - 1; i >= 0; i--) {
349
- let s = sources[i] || {};
349
+ let v,
350
+ s = sources[i];
350
351
  if (typeof s === "function") s = s();
351
- const v = s[key];
352
+ v = (s || {})[key];
352
353
  if (v !== undefined) return v;
353
354
  }
354
355
  }
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;
@@ -239,8 +229,7 @@ function observable(input) {
239
229
  if (!(observer instanceof Object) || observer == null) {
240
230
  throw new TypeError("Expected the observer to be an object.");
241
231
  }
242
- const handler =
243
- typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
232
+ const handler = typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
244
233
  if (!handler) {
245
234
  return {
246
235
  unsubscribe() {}
@@ -269,7 +258,7 @@ function from(producer) {
269
258
  const [s, set] = createSignal(undefined);
270
259
  if ("subscribe" in producer) {
271
260
  const unsub = producer.subscribe(v => set(() => v));
272
- onCleanup(() => ("unsubscribe" in unsub ? unsub.unsubscribe() : unsub()));
261
+ onCleanup(() => "unsubscribe" in unsub ? unsub.unsubscribe() : unsub());
273
262
  } else {
274
263
  const clean = producer(set);
275
264
  onCleanup(clean);
@@ -321,13 +310,11 @@ function setHydrateContext(context) {
321
310
  sharedConfig.context = context;
322
311
  }
323
312
  function nextHydrateContext() {
324
- return sharedConfig.context
325
- ? {
326
- ...sharedConfig.context,
327
- id: `${sharedConfig.context.id}${sharedConfig.context.count++}-`,
328
- count: 0
329
- }
330
- : undefined;
313
+ return sharedConfig.context ? {
314
+ ...sharedConfig.context,
315
+ id: `${sharedConfig.context.id}${sharedConfig.context.count++}-`,
316
+ count: 0
317
+ } : undefined;
331
318
  }
332
319
  function createUniqueId() {
333
320
  const ctx = sharedConfig.context;
@@ -357,9 +344,10 @@ function mergeProps(...sources) {
357
344
  enumerable: true,
358
345
  get() {
359
346
  for (let i = sources.length - 1; i >= 0; i--) {
360
- let s = sources[i] || {};
347
+ let v,
348
+ s = sources[i];
361
349
  if (typeof s === "function") s = s();
362
- const v = s[key];
350
+ v = (s || {})[key];
363
351
  if (v !== undefined) return v;
364
352
  }
365
353
  }
@@ -403,11 +391,7 @@ function Index(props) {
403
391
  }
404
392
  function Show(props) {
405
393
  let c;
406
- return props.when
407
- ? typeof (c = props.children) === "function"
408
- ? c(props.keyed ? props.when : () => props.when)
409
- : c
410
- : props.fallback || "";
394
+ return props.when ? typeof (c = props.children) === "function" ? c(props.keyed ? props.when : () => props.when) : c : props.fallback || "";
411
395
  }
412
396
  function Switch(props) {
413
397
  let conditions = props.children;
@@ -444,14 +428,11 @@ function ErrorBoundary(props) {
444
428
  }
445
429
  createMemo(() => {
446
430
  clean = Owner;
447
- return catchError(
448
- () => (res = props.children),
449
- err => {
450
- error = err;
451
- !sync && ctx.replace("e" + id, displayFallback);
452
- sync = true;
453
- }
454
- );
431
+ return catchError(() => res = props.children, err => {
432
+ error = err;
433
+ !sync && ctx.replace("e" + id, displayFallback);
434
+ sync = true;
435
+ });
455
436
  });
456
437
  if (error) return displayFallback();
457
438
  sync = false;
@@ -481,18 +462,14 @@ function createResource(source, fetcher, options = {}) {
481
462
  if (sharedConfig.context.async && options.ssrLoadFrom !== "initial") {
482
463
  resource = sharedConfig.context.resources[id] || (sharedConfig.context.resources[id] = {});
483
464
  if (resource.ref) {
484
- if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error)
485
- resource.ref[1].refetch();
465
+ if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error) resource.ref[1].refetch();
486
466
  return resource.ref;
487
467
  }
488
468
  }
489
469
  const read = () => {
490
470
  if (error) throw error;
491
471
  if (resourceContext && p) resourceContext.push(p);
492
- const resolved =
493
- options.ssrLoadFrom !== "initial" &&
494
- sharedConfig.context.async &&
495
- "data" in sharedConfig.context.resources[id];
472
+ const resolved = options.ssrLoadFrom !== "initial" && sharedConfig.context.async && "data" in sharedConfig.context.resources[id];
496
473
  if (!resolved && read.loading) {
497
474
  const ctx = useContext(SuspenseContext);
498
475
  if (ctx) {
@@ -512,7 +489,7 @@ function createResource(source, fetcher, options = {}) {
512
489
  });
513
490
  function load() {
514
491
  const ctx = sharedConfig.context;
515
- if (!ctx.async) return (read.loading = !!(typeof source === "function" ? source() : source));
492
+ if (!ctx.async) return read.loading = !!(typeof source === "function" ? source() : source);
516
493
  if (ctx.resources && id in ctx.resources && "data" in ctx.resources[id]) {
517
494
  value = ctx.resources[id].data;
518
495
  return;
@@ -520,11 +497,9 @@ function createResource(source, fetcher, options = {}) {
520
497
  resourceContext = [];
521
498
  const lookup = typeof source === "function" ? source() : source;
522
499
  if (resourceContext.length) {
523
- p = Promise.all(resourceContext).then(() =>
524
- fetcher(source(), {
525
- value
526
- })
527
- );
500
+ p = Promise.all(resourceContext).then(() => fetcher(source(), {
501
+ value
502
+ }));
528
503
  }
529
504
  resourceContext = null;
530
505
  if (!p) {
@@ -537,22 +512,20 @@ function createResource(source, fetcher, options = {}) {
537
512
  read.loading = true;
538
513
  read.state = "pending";
539
514
  if (ctx.writeResource) ctx.writeResource(id, p, undefined, options.deferStream);
540
- return p
541
- .then(res => {
542
- read.loading = false;
543
- read.state = "ready";
544
- ctx.resources[id].data = res;
545
- p = null;
546
- notifySuspense(contexts);
547
- return res;
548
- })
549
- .catch(err => {
550
- read.loading = false;
551
- read.state = "errored";
552
- read.error = error = castError(err);
553
- p = null;
554
- notifySuspense(contexts);
555
- });
515
+ return p.then(res => {
516
+ read.loading = false;
517
+ read.state = "ready";
518
+ ctx.resources[id].data = res;
519
+ p = null;
520
+ notifySuspense(contexts);
521
+ return res;
522
+ }).catch(err => {
523
+ read.loading = false;
524
+ read.state = "errored";
525
+ read.error = error = castError(err);
526
+ p = null;
527
+ notifySuspense(contexts);
528
+ });
556
529
  }
557
530
  ctx.resources[id].data = p;
558
531
  if (ctx.writeResource) ctx.writeResource(id, p);
@@ -560,20 +533,17 @@ function createResource(source, fetcher, options = {}) {
560
533
  return ctx.resources[id].data;
561
534
  }
562
535
  if (options.ssrLoadFrom !== "initial") load();
563
- return (resource.ref = [
564
- read,
565
- {
566
- refetch: load,
567
- mutate: v => (value = v)
568
- }
569
- ]);
536
+ return resource.ref = [read, {
537
+ refetch: load,
538
+ mutate: v => value = v
539
+ }];
570
540
  }
571
541
  function lazy(fn) {
572
542
  let p;
573
543
  let load = id => {
574
544
  if (!p) {
575
545
  p = fn();
576
- p.then(mod => (p.resolved = mod.default));
546
+ p.then(mod => p.resolved = mod.default);
577
547
  if (id) sharedConfig.context.lazy[id] = p;
578
548
  }
579
549
  return p;
@@ -582,8 +552,7 @@ function lazy(fn) {
582
552
  const wrap = props => {
583
553
  const id = sharedConfig.context.id.slice(0, -1);
584
554
  let ref = sharedConfig.context.lazy[id];
585
- if (ref) p = ref;
586
- else load(id);
555
+ if (ref) p = ref;else load(id);
587
556
  if (p.resolved) return p.resolved(props);
588
557
  const ctx = useContext(SuspenseContext);
589
558
  const track = {
@@ -595,12 +564,10 @@ function lazy(fn) {
595
564
  contexts.add(ctx);
596
565
  }
597
566
  if (sharedConfig.context.async) {
598
- sharedConfig.context.block(
599
- p.then(() => {
600
- track.loading = false;
601
- notifySuspense(contexts);
602
- })
603
- );
567
+ sharedConfig.context.block(p.then(() => {
568
+ track.loading = false;
569
+ notifySuspense(contexts);
570
+ }));
604
571
  }
605
572
  return "";
606
573
  };
@@ -628,12 +595,9 @@ function startTransition(fn) {
628
595
  fn();
629
596
  }
630
597
  function useTransition() {
631
- return [
632
- () => false,
633
- fn => {
634
- fn();
635
- }
636
- ];
598
+ return [() => false, fn => {
599
+ fn();
600
+ }];
637
601
  }
638
602
  function SuspenseList(props) {
639
603
  return props.children;
@@ -643,17 +607,15 @@ function Suspense(props) {
643
607
  const ctx = sharedConfig.context;
644
608
  const id = ctx.id + ctx.count;
645
609
  const o = createOwner();
646
- const value =
647
- ctx.suspense[id] ||
648
- (ctx.suspense[id] = {
649
- resources: new Map(),
650
- completed: () => {
651
- const res = runSuspense();
652
- if (suspenseComplete(value)) {
653
- done(resolveSSRNode(res));
654
- }
610
+ const value = ctx.suspense[id] || (ctx.suspense[id] = {
611
+ resources: new Map(),
612
+ completed: () => {
613
+ const res = runSuspense();
614
+ if (suspenseComplete(value)) {
615
+ done(resolveSSRNode(res));
655
616
  }
656
- });
617
+ }
618
+ });
657
619
  function suspenseError(err) {
658
620
  if (!done || !done(undefined, err)) {
659
621
  runWithOwner(o.owner, () => {
@@ -667,14 +629,12 @@ function Suspense(props) {
667
629
  count: 0
668
630
  });
669
631
  cleanNode(o);
670
- return runWithOwner(o, () =>
671
- createComponent(SuspenseContext.Provider, {
672
- value,
673
- get children() {
674
- return catchError(() => props.children, suspenseError);
675
- }
676
- })
677
- );
632
+ return runWithOwner(o, () => createComponent(SuspenseContext.Provider, {
633
+ value,
634
+ get children() {
635
+ return catchError(() => props.children, suspenseError);
636
+ }
637
+ }));
678
638
  }
679
639
  const res = runSuspense();
680
640
  if (suspenseComplete(value)) return res;
@@ -703,57 +663,4 @@ function Suspense(props) {
703
663
  }, suspenseError);
704
664
  }
705
665
 
706
- export {
707
- $DEVCOMP,
708
- $PROXY,
709
- $TRACK,
710
- DEV,
711
- ErrorBoundary,
712
- For,
713
- Index,
714
- Match,
715
- Show,
716
- Suspense,
717
- SuspenseList,
718
- Switch,
719
- batch,
720
- catchError,
721
- children,
722
- createComponent,
723
- createComputed,
724
- createContext,
725
- createDeferred,
726
- createEffect,
727
- createMemo,
728
- createReaction,
729
- createRenderEffect,
730
- createResource,
731
- createRoot,
732
- createSelector,
733
- createSignal,
734
- createUniqueId,
735
- enableExternalSource,
736
- enableHydration,
737
- enableScheduling,
738
- equalFn,
739
- from,
740
- getListener,
741
- getOwner,
742
- lazy,
743
- mapArray,
744
- mergeProps,
745
- observable,
746
- on,
747
- onCleanup,
748
- onError,
749
- onMount,
750
- requestCallback,
751
- resetErrorBoundaries,
752
- runWithOwner,
753
- sharedConfig,
754
- splitProps,
755
- startTransition,
756
- untrack,
757
- useContext,
758
- useTransition
759
- };
666
+ 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, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, resetErrorBoundaries, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
package/dist/solid.cjs CHANGED
@@ -379,9 +379,9 @@ function createDeferred(source, options) {
379
379
  } : undefined);
380
380
  return source();
381
381
  }, undefined, true);
382
- const [deferred, setDeferred] = createSignal(node.value, options);
382
+ const [deferred, setDeferred] = createSignal(Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value, options);
383
383
  updateComputation(node);
384
- setDeferred(() => node.value);
384
+ setDeferred(() => Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value);
385
385
  return deferred;
386
386
  }
387
387
  function createSelector(source, fn = equalFn, options) {
@@ -545,7 +545,7 @@ function children(fn) {
545
545
  }
546
546
  let SuspenseContext;
547
547
  function getSuspenseContext() {
548
- return SuspenseContext || (SuspenseContext = createContext({}));
548
+ return SuspenseContext || (SuspenseContext = createContext());
549
549
  }
550
550
  function enableExternalSource(factory) {
551
551
  if (ExternalSourceFactory) {