solid-js 1.8.18 → 1.8.19

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 (48) hide show
  1. package/dist/dev.cjs +28 -23
  2. package/dist/dev.js +344 -580
  3. package/dist/server.cjs +33 -11
  4. package/dist/server.js +105 -176
  5. package/dist/solid.cjs +28 -23
  6. package/dist/solid.js +302 -507
  7. package/h/dist/h.js +9 -38
  8. package/h/jsx-runtime/dist/jsx.js +1 -1
  9. package/h/jsx-runtime/types/index.d.ts +8 -11
  10. package/h/types/hyperscript.d.ts +11 -11
  11. package/html/dist/html.js +94 -216
  12. package/html/types/lit.d.ts +33 -47
  13. package/package.json +3 -3
  14. package/store/dist/dev.js +43 -122
  15. package/store/dist/server.js +8 -19
  16. package/store/dist/store.js +40 -113
  17. package/store/types/index.d.ts +7 -21
  18. package/store/types/modifiers.d.ts +3 -6
  19. package/store/types/mutable.d.ts +2 -5
  20. package/store/types/server.d.ts +4 -12
  21. package/store/types/store.d.ts +61 -218
  22. package/types/index.d.ts +10 -75
  23. package/types/reactive/array.d.ts +4 -12
  24. package/types/reactive/observable.d.ts +17 -25
  25. package/types/reactive/scheduler.d.ts +6 -9
  26. package/types/reactive/signal.d.ts +142 -233
  27. package/types/render/Suspense.d.ts +5 -5
  28. package/types/render/component.d.ts +33 -64
  29. package/types/render/flow.d.ts +31 -43
  30. package/types/render/hydration.d.ts +15 -13
  31. package/types/server/index.d.ts +2 -57
  32. package/types/server/reactive.d.ts +42 -73
  33. package/types/server/rendering.d.ts +98 -167
  34. package/universal/dist/dev.js +12 -28
  35. package/universal/dist/universal.js +12 -28
  36. package/universal/types/index.d.ts +1 -3
  37. package/universal/types/universal.d.ts +1 -0
  38. package/web/dist/dev.cjs +2 -3
  39. package/web/dist/dev.js +84 -629
  40. package/web/dist/server.cjs +3 -3
  41. package/web/dist/server.js +99 -213
  42. package/web/dist/web.cjs +2 -3
  43. package/web/dist/web.js +82 -620
  44. package/web/storage/dist/storage.js +3 -3
  45. package/web/types/client.d.ts +2 -2
  46. package/web/types/core.d.ts +1 -10
  47. package/web/types/index.d.ts +10 -27
  48. package/web/types/server-mock.d.ts +32 -47
package/dist/solid.cjs CHANGED
@@ -118,15 +118,26 @@ function workLoop(hasTimeRemaining, initialTime) {
118
118
 
119
119
  const sharedConfig = {
120
120
  context: undefined,
121
- registry: undefined
121
+ registry: undefined,
122
+ getContextId() {
123
+ return getContextId(this.context.count);
124
+ },
125
+ getNextContextId() {
126
+ return getContextId(this.context.count++);
127
+ }
122
128
  };
129
+ function getContextId(count) {
130
+ const num = String(count),
131
+ len = num.length - 1;
132
+ return sharedConfig.context.id + (len ? String.fromCharCode(96 + len) : "") + num;
133
+ }
123
134
  function setHydrateContext(context) {
124
135
  sharedConfig.context = context;
125
136
  }
126
137
  function nextHydrateContext() {
127
138
  return {
128
139
  ...sharedConfig.context,
129
- id: `${sharedConfig.context.id}${sharedConfig.context.count++}-`,
140
+ id: sharedConfig.getNextContextId(),
130
141
  count: 0
131
142
  };
132
143
  }
@@ -267,7 +278,7 @@ function createResource(pSource, pFetcher, pOptions) {
267
278
  }),
268
279
  [state, setState] = createSignal(resolved ? "ready" : "unresolved");
269
280
  if (sharedConfig.context) {
270
- id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
281
+ id = sharedConfig.getNextContextId();
271
282
  let v;
272
283
  if (options.ssrLoadFrom === "initial") initP = options.initialValue;else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v;
273
284
  }
@@ -540,7 +551,8 @@ function createContext(defaultValue, options) {
540
551
  };
541
552
  }
542
553
  function useContext(context) {
543
- return Owner && Owner.context && Owner.context[context.id] !== undefined ? Owner.context[context.id] : context.defaultValue;
554
+ let value;
555
+ return Owner && Owner.context && (value = Owner.context[context.id]) !== undefined ? value : context.defaultValue;
544
556
  }
545
557
  function children(fn) {
546
558
  const children = createMemo(fn);
@@ -1066,20 +1078,12 @@ function mapArray(list, mapFn, options = {}) {
1066
1078
  onCleanup(() => dispose(disposers));
1067
1079
  return () => {
1068
1080
  let newItems = list() || [],
1081
+ newLen = newItems.length,
1069
1082
  i,
1070
1083
  j;
1071
1084
  newItems[$TRACK];
1072
1085
  return untrack(() => {
1073
- let newLen = newItems.length,
1074
- newIndices,
1075
- newIndicesNext,
1076
- temp,
1077
- tempdisposers,
1078
- tempIndexes,
1079
- start,
1080
- end,
1081
- newEnd,
1082
- item;
1086
+ let newIndices, newIndicesNext, temp, tempdisposers, tempIndexes, start, end, newEnd, item;
1083
1087
  if (newLen === 0) {
1084
1088
  if (len !== 0) {
1085
1089
  dispose(disposers);
@@ -1169,10 +1173,11 @@ function indexArray(list, mapFn, options = {}) {
1169
1173
  i;
1170
1174
  onCleanup(() => dispose(disposers));
1171
1175
  return () => {
1172
- const newItems = list() || [];
1176
+ const newItems = list() || [],
1177
+ newLen = newItems.length;
1173
1178
  newItems[$TRACK];
1174
1179
  return untrack(() => {
1175
- if (newItems.length === 0) {
1180
+ if (newLen === 0) {
1176
1181
  if (len !== 0) {
1177
1182
  dispose(disposers);
1178
1183
  disposers = [];
@@ -1198,7 +1203,7 @@ function indexArray(list, mapFn, options = {}) {
1198
1203
  mapped = [];
1199
1204
  len = 0;
1200
1205
  }
1201
- for (i = 0; i < newItems.length; i++) {
1206
+ for (i = 0; i < newLen; i++) {
1202
1207
  if (i < items.length && items[i] !== newItems[i]) {
1203
1208
  signals[i](() => newItems[i]);
1204
1209
  } else if (i >= items.length) {
@@ -1208,7 +1213,7 @@ function indexArray(list, mapFn, options = {}) {
1208
1213
  for (; i < items.length; i++) {
1209
1214
  disposers[i]();
1210
1215
  }
1211
- len = signals.length = disposers.length = newItems.length;
1216
+ len = signals.length = disposers.length = newLen;
1212
1217
  items = newItems.slice(0);
1213
1218
  return mapped = mapped.slice(0, len);
1214
1219
  });
@@ -1422,7 +1427,7 @@ function lazy(fn) {
1422
1427
  let counter = 0;
1423
1428
  function createUniqueId() {
1424
1429
  const ctx = sharedConfig.context;
1425
- return ctx ? `${ctx.id}${ctx.count++}` : `cl-${counter++}`;
1430
+ return ctx ? sharedConfig.getNextContextId() : `cl-${counter++}`;
1426
1431
  }
1427
1432
 
1428
1433
  const narrowedError = name => `Stale read from <${name}>.`;
@@ -1494,7 +1499,7 @@ function resetErrorBoundaries() {
1494
1499
  }
1495
1500
  function ErrorBoundary(props) {
1496
1501
  let err;
1497
- if (sharedConfig.context && sharedConfig.load) err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
1502
+ if (sharedConfig.context && sharedConfig.load) err = sharedConfig.load(sharedConfig.getContextId());
1498
1503
  const [errored, setErrored] = createSignal(err, undefined);
1499
1504
  Errors || (Errors = new Set());
1500
1505
  Errors.add(setErrored);
@@ -1510,7 +1515,7 @@ function ErrorBoundary(props) {
1510
1515
  }
1511
1516
 
1512
1517
  const suspenseListEquals = (a, b) => a.showContent === b.showContent && a.showFallback === b.showFallback;
1513
- const SuspenseListContext = createContext();
1518
+ const SuspenseListContext = /* #__PURE__ */createContext();
1514
1519
  function SuspenseList(props) {
1515
1520
  let [wrapper, setWrapper] = createSignal(() => ({
1516
1521
  inFallback: false
@@ -1607,7 +1612,7 @@ function Suspense(props) {
1607
1612
  },
1608
1613
  owner = getOwner();
1609
1614
  if (sharedConfig.context && sharedConfig.load) {
1610
- const key = sharedConfig.context.id + sharedConfig.context.count;
1615
+ const key = sharedConfig.getContextId();
1611
1616
  let ref = sharedConfig.load(key);
1612
1617
  if (ref) {
1613
1618
  if (typeof ref !== "object" || ref.status !== "success") p = ref;else sharedConfig.gather(key);
@@ -1664,7 +1669,7 @@ function Suspense(props) {
1664
1669
  dispose = disposer;
1665
1670
  if (ctx) {
1666
1671
  setHydrateContext({
1667
- id: ctx.id + "f",
1672
+ id: ctx.id + "F",
1668
1673
  count: 0
1669
1674
  });
1670
1675
  ctx = undefined;