solid-js 1.8.18 → 1.8.20

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.
package/dist/solid.cjs CHANGED
@@ -118,15 +118,27 @@ function workLoop(hasTimeRemaining, initialTime) {
118
118
 
119
119
  const sharedConfig = {
120
120
  context: undefined,
121
- registry: undefined
121
+ registry: undefined,
122
+ done: false,
123
+ getContextId() {
124
+ return getContextId(this.context.count);
125
+ },
126
+ getNextContextId() {
127
+ return getContextId(this.context.count++);
128
+ }
122
129
  };
130
+ function getContextId(count) {
131
+ const num = String(count),
132
+ len = num.length - 1;
133
+ return sharedConfig.context.id + (len ? String.fromCharCode(96 + len) : "") + num;
134
+ }
123
135
  function setHydrateContext(context) {
124
136
  sharedConfig.context = context;
125
137
  }
126
138
  function nextHydrateContext() {
127
139
  return {
128
140
  ...sharedConfig.context,
129
- id: `${sharedConfig.context.id}${sharedConfig.context.count++}-`,
141
+ id: sharedConfig.getNextContextId(),
130
142
  count: 0
131
143
  };
132
144
  }
@@ -267,9 +279,8 @@ function createResource(pSource, pFetcher, pOptions) {
267
279
  }),
268
280
  [state, setState] = createSignal(resolved ? "ready" : "unresolved");
269
281
  if (sharedConfig.context) {
270
- id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
271
- let v;
272
- if (options.ssrLoadFrom === "initial") initP = options.initialValue;else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v;
282
+ id = sharedConfig.getNextContextId();
283
+ if (options.ssrLoadFrom === "initial") initP = options.initialValue;else if (sharedConfig.load && sharedConfig.has(id)) initP = sharedConfig.load(id);
273
284
  }
274
285
  function loadEnd(p, v, error, key) {
275
286
  if (pr === p) {
@@ -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
  });
@@ -1395,7 +1400,7 @@ function lazy(fn) {
1395
1400
  sharedConfig.count || (sharedConfig.count = 0);
1396
1401
  sharedConfig.count++;
1397
1402
  (p || (p = fn())).then(mod => {
1398
- setHydrateContext(ctx);
1403
+ !sharedConfig.done && setHydrateContext(ctx);
1399
1404
  sharedConfig.count--;
1400
1405
  set(() => mod.default);
1401
1406
  setHydrateContext();
@@ -1406,15 +1411,15 @@ function lazy(fn) {
1406
1411
  comp = s;
1407
1412
  }
1408
1413
  let Comp;
1409
- return createMemo(() => (Comp = comp()) && untrack(() => {
1414
+ return createMemo(() => (Comp = comp()) ? untrack(() => {
1410
1415
  if (false) ;
1411
- if (!ctx) return Comp(props);
1416
+ if (!ctx || sharedConfig.done) return Comp(props);
1412
1417
  const c = sharedConfig.context;
1413
1418
  setHydrateContext(ctx);
1414
1419
  const r = Comp(props);
1415
1420
  setHydrateContext(c);
1416
1421
  return r;
1417
- }));
1422
+ }) : "");
1418
1423
  };
1419
1424
  wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
1420
1425
  return wrap;
@@ -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;
package/dist/solid.js CHANGED
@@ -118,15 +118,27 @@ function workLoop(hasTimeRemaining, initialTime) {
118
118
 
119
119
  const sharedConfig = {
120
120
  context: undefined,
121
- registry: undefined
121
+ registry: undefined,
122
+ done: false,
123
+ getContextId() {
124
+ return getContextId(this.context.count);
125
+ },
126
+ getNextContextId() {
127
+ return getContextId(this.context.count++);
128
+ }
122
129
  };
130
+ function getContextId(count) {
131
+ const num = String(count),
132
+ len = num.length - 1;
133
+ return sharedConfig.context.id + (len ? String.fromCharCode(96 + len) : "") + num;
134
+ }
123
135
  function setHydrateContext(context) {
124
136
  sharedConfig.context = context;
125
137
  }
126
138
  function nextHydrateContext() {
127
139
  return {
128
140
  ...sharedConfig.context,
129
- id: `${sharedConfig.context.id}${sharedConfig.context.count++}-`,
141
+ id: sharedConfig.getNextContextId(),
130
142
  count: 0
131
143
  };
132
144
  }
@@ -277,10 +289,9 @@ function createResource(pSource, pFetcher, pOptions) {
277
289
  }),
278
290
  [state, setState] = createSignal(resolved ? "ready" : "unresolved");
279
291
  if (sharedConfig.context) {
280
- id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
281
- let v;
292
+ id = sharedConfig.getNextContextId();
282
293
  if (options.ssrLoadFrom === "initial") initP = options.initialValue;
283
- else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v;
294
+ else if (sharedConfig.load && sharedConfig.has(id)) initP = sharedConfig.load(id);
284
295
  }
285
296
  function loadEnd(p, v, error, key) {
286
297
  if (pr === p) {
@@ -598,8 +609,9 @@ function createContext(defaultValue, options) {
598
609
  };
599
610
  }
600
611
  function useContext(context) {
601
- return Owner && Owner.context && Owner.context[context.id] !== undefined
602
- ? Owner.context[context.id]
612
+ let value;
613
+ return Owner && Owner.context && (value = Owner.context[context.id]) !== undefined
614
+ ? value
603
615
  : context.defaultValue;
604
616
  }
605
617
  function children(fn) {
@@ -1150,20 +1162,12 @@ function mapArray(list, mapFn, options = {}) {
1150
1162
  onCleanup(() => dispose(disposers));
1151
1163
  return () => {
1152
1164
  let newItems = list() || [],
1165
+ newLen = newItems.length,
1153
1166
  i,
1154
1167
  j;
1155
1168
  newItems[$TRACK];
1156
1169
  return untrack(() => {
1157
- let newLen = newItems.length,
1158
- newIndices,
1159
- newIndicesNext,
1160
- temp,
1161
- tempdisposers,
1162
- tempIndexes,
1163
- start,
1164
- end,
1165
- newEnd,
1166
- item;
1170
+ let newIndices, newIndicesNext, temp, tempdisposers, tempIndexes, start, end, newEnd, item;
1167
1171
  if (newLen === 0) {
1168
1172
  if (len !== 0) {
1169
1173
  dispose(disposers);
@@ -1260,10 +1264,11 @@ function indexArray(list, mapFn, options = {}) {
1260
1264
  i;
1261
1265
  onCleanup(() => dispose(disposers));
1262
1266
  return () => {
1263
- const newItems = list() || [];
1267
+ const newItems = list() || [],
1268
+ newLen = newItems.length;
1264
1269
  newItems[$TRACK];
1265
1270
  return untrack(() => {
1266
- if (newItems.length === 0) {
1271
+ if (newLen === 0) {
1267
1272
  if (len !== 0) {
1268
1273
  dispose(disposers);
1269
1274
  disposers = [];
@@ -1289,7 +1294,7 @@ function indexArray(list, mapFn, options = {}) {
1289
1294
  mapped = [];
1290
1295
  len = 0;
1291
1296
  }
1292
- for (i = 0; i < newItems.length; i++) {
1297
+ for (i = 0; i < newLen; i++) {
1293
1298
  if (i < items.length && items[i] !== newItems[i]) {
1294
1299
  signals[i](() => newItems[i]);
1295
1300
  } else if (i >= items.length) {
@@ -1299,7 +1304,7 @@ function indexArray(list, mapFn, options = {}) {
1299
1304
  for (; i < items.length; i++) {
1300
1305
  disposers[i]();
1301
1306
  }
1302
- len = signals.length = disposers.length = newItems.length;
1307
+ len = signals.length = disposers.length = newLen;
1303
1308
  items = newItems.slice(0);
1304
1309
  return (mapped = mapped.slice(0, len));
1305
1310
  });
@@ -1509,7 +1514,7 @@ function lazy(fn) {
1509
1514
  sharedConfig.count || (sharedConfig.count = 0);
1510
1515
  sharedConfig.count++;
1511
1516
  (p || (p = fn())).then(mod => {
1512
- setHydrateContext(ctx);
1517
+ !sharedConfig.done && setHydrateContext(ctx);
1513
1518
  sharedConfig.count--;
1514
1519
  set(() => mod.default);
1515
1520
  setHydrateContext();
@@ -1520,18 +1525,18 @@ function lazy(fn) {
1520
1525
  comp = s;
1521
1526
  }
1522
1527
  let Comp;
1523
- return createMemo(
1524
- () =>
1525
- (Comp = comp()) &&
1526
- untrack(() => {
1527
- if (false);
1528
- if (!ctx) return Comp(props);
1529
- const c = sharedConfig.context;
1530
- setHydrateContext(ctx);
1531
- const r = Comp(props);
1532
- setHydrateContext(c);
1533
- return r;
1534
- })
1528
+ return createMemo(() =>
1529
+ (Comp = comp())
1530
+ ? untrack(() => {
1531
+ if (false);
1532
+ if (!ctx || sharedConfig.done) return Comp(props);
1533
+ const c = sharedConfig.context;
1534
+ setHydrateContext(ctx);
1535
+ const r = Comp(props);
1536
+ setHydrateContext(c);
1537
+ return r;
1538
+ })
1539
+ : ""
1535
1540
  );
1536
1541
  };
1537
1542
  wrap.preload = () => p || ((p = fn()).then(mod => (comp = () => mod.default)), p);
@@ -1540,7 +1545,7 @@ function lazy(fn) {
1540
1545
  let counter = 0;
1541
1546
  function createUniqueId() {
1542
1547
  const ctx = sharedConfig.context;
1543
- return ctx ? `${ctx.id}${ctx.count++}` : `cl-${counter++}`;
1548
+ return ctx ? sharedConfig.getNextContextId() : `cl-${counter++}`;
1544
1549
  }
1545
1550
 
1546
1551
  const narrowedError = name => `Stale read from <${name}>.`;
@@ -1641,7 +1646,7 @@ function resetErrorBoundaries() {
1641
1646
  function ErrorBoundary(props) {
1642
1647
  let err;
1643
1648
  if (sharedConfig.context && sharedConfig.load)
1644
- err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
1649
+ err = sharedConfig.load(sharedConfig.getContextId());
1645
1650
  const [errored, setErrored] = createSignal(err, undefined);
1646
1651
  Errors || (Errors = new Set());
1647
1652
  Errors.add(setErrored);
@@ -1662,7 +1667,7 @@ function ErrorBoundary(props) {
1662
1667
 
1663
1668
  const suspenseListEquals = (a, b) =>
1664
1669
  a.showContent === b.showContent && a.showFallback === b.showFallback;
1665
- const SuspenseListContext = createContext();
1670
+ const SuspenseListContext = /* #__PURE__ */ createContext();
1666
1671
  function SuspenseList(props) {
1667
1672
  let [wrapper, setWrapper] = createSignal(() => ({
1668
1673
  inFallback: false
@@ -1759,7 +1764,7 @@ function Suspense(props) {
1759
1764
  },
1760
1765
  owner = getOwner();
1761
1766
  if (sharedConfig.context && sharedConfig.load) {
1762
- const key = sharedConfig.context.id + sharedConfig.context.count;
1767
+ const key = sharedConfig.getContextId();
1763
1768
  let ref = sharedConfig.load(key);
1764
1769
  if (ref) {
1765
1770
  if (typeof ref !== "object" || ref.status !== "success") p = ref;
@@ -1817,7 +1822,7 @@ function Suspense(props) {
1817
1822
  dispose = disposer;
1818
1823
  if (ctx) {
1819
1824
  setHydrateContext({
1820
- id: ctx.id + "f",
1825
+ id: ctx.id + "F",
1821
1826
  count: 0
1822
1827
  });
1823
1828
  ctx = undefined;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "solid-js",
3
3
  "description": "A declarative JavaScript library for building user interfaces.",
4
- "version": "1.8.18",
4
+ "version": "1.8.20",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "homepage": "https://solidjs.com",
@@ -219,8 +219,8 @@
219
219
  ],
220
220
  "dependencies": {
221
221
  "csstype": "^3.1.0",
222
- "seroval": "^1.0.4",
223
- "seroval-plugins": "^1.0.3"
222
+ "seroval": "^1.1.0",
223
+ "seroval-plugins": "^1.1.0"
224
224
  },
225
225
  "scripts": {
226
226
  "build": "npm-run-all -nl build:*",