solid-js 1.6.8 → 1.6.10

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/server.js CHANGED
@@ -23,10 +23,10 @@ let Owner = null;
23
23
  function createRoot(fn, detachedOwner) {
24
24
  detachedOwner && (Owner = detachedOwner);
25
25
  const owner = Owner,
26
- root = fn.length === 0 ? UNOWNED : {
27
- context: null,
28
- owner
29
- };
26
+ root = fn.length === 0 ? UNOWNED : {
27
+ context: null,
28
+ owner
29
+ };
30
30
  Owner = root;
31
31
  let result;
32
32
  try {
@@ -262,7 +262,8 @@ function setHydrateContext(context) {
262
262
  sharedConfig.context = context;
263
263
  }
264
264
  function nextHydrateContext() {
265
- return sharedConfig.context ? { ...sharedConfig.context,
265
+ return sharedConfig.context ? {
266
+ ...sharedConfig.context,
266
267
  id: `${sharedConfig.context.id}${sharedConfig.context.count++}-`,
267
268
  count: 0
268
269
  } : undefined;
@@ -309,23 +310,23 @@ function mergeProps(...sources) {
309
310
  }
310
311
  function splitProps(props, ...keys) {
311
312
  const descriptors = Object.getOwnPropertyDescriptors(props),
312
- split = k => {
313
- const clone = {};
314
- for (let i = 0; i < k.length; i++) {
315
- const key = k[i];
316
- if (descriptors[key]) {
317
- Object.defineProperty(clone, key, descriptors[key]);
318
- delete descriptors[key];
313
+ split = k => {
314
+ const clone = {};
315
+ for (let i = 0; i < k.length; i++) {
316
+ const key = k[i];
317
+ if (descriptors[key]) {
318
+ Object.defineProperty(clone, key, descriptors[key]);
319
+ delete descriptors[key];
320
+ }
319
321
  }
320
- }
321
- return clone;
322
- };
322
+ return clone;
323
+ };
323
324
  return keys.map(split).concat(split(Object.keys(descriptors)));
324
325
  }
325
326
  function simpleMap(props, wrap) {
326
327
  const list = props.each || [],
327
- len = list.length,
328
- fn = props.children;
328
+ len = list.length,
329
+ fn = props.children;
329
330
  if (len) {
330
331
  let mapped = Array(len);
331
332
  for (let i = 0; i < len; i++) mapped[i] = wrap(fn, list[i], i);
@@ -361,15 +362,16 @@ function Match(props) {
361
362
  function resetErrorBoundaries() {}
362
363
  function ErrorBoundary(props) {
363
364
  let error,
364
- res,
365
- clean,
366
- sync = true;
365
+ res,
366
+ clean,
367
+ sync = true;
367
368
  const ctx = sharedConfig.context;
368
369
  const id = ctx.id + ctx.count;
369
370
  function displayFallback() {
370
371
  cleanNode(clean);
371
372
  ctx.writeResource(id, error, true);
372
- setHydrateContext({ ...ctx,
373
+ setHydrateContext({
374
+ ...ctx,
373
375
  count: 0
374
376
  });
375
377
  const f = props.fallback;
@@ -576,7 +578,8 @@ function Suspense(props) {
576
578
  }
577
579
  });
578
580
  function runSuspense() {
579
- setHydrateContext({ ...ctx,
581
+ setHydrateContext({
582
+ ...ctx,
580
583
  count: 0
581
584
  });
582
585
  return runWithOwner(o, () => {
@@ -600,18 +603,20 @@ function Suspense(props) {
600
603
  });
601
604
  done = ctx.async ? ctx.registerFragment(id) : undefined;
602
605
  if (ctx.async) {
603
- setHydrateContext({ ...ctx,
606
+ setHydrateContext({
607
+ ...ctx,
604
608
  count: 0,
605
609
  id: ctx.id + "0.f",
606
610
  noHydrate: true
607
611
  });
608
612
  const res = {
609
- t: `<span id="pl-${id}">${resolveSSRNode(props.fallback)}</span>`
613
+ t: `<template id="pl-${id}"></template>${resolveSSRNode(props.fallback)}<!pl-${id}>`
610
614
  };
611
615
  setHydrateContext(ctx);
612
616
  return res;
613
617
  }
614
- setHydrateContext({ ...ctx,
618
+ setHydrateContext({
619
+ ...ctx,
615
620
  count: 0,
616
621
  id: ctx.id + "0.f"
617
622
  });
package/dist/solid.cjs CHANGED
@@ -1,20 +1,20 @@
1
1
  'use strict';
2
2
 
3
3
  let taskIdCounter = 1,
4
- isCallbackScheduled = false,
5
- isPerformingWork = false,
6
- taskQueue = [],
7
- currentTask = null,
8
- shouldYieldToHost = null,
9
- yieldInterval = 5,
10
- deadline = 0,
11
- maxYieldInterval = 300,
12
- scheduleCallback = null,
13
- scheduledCallback = null;
4
+ isCallbackScheduled = false,
5
+ isPerformingWork = false,
6
+ taskQueue = [],
7
+ currentTask = null,
8
+ shouldYieldToHost = null,
9
+ yieldInterval = 5,
10
+ deadline = 0,
11
+ maxYieldInterval = 300,
12
+ scheduleCallback = null,
13
+ scheduledCallback = null;
14
14
  const maxSigned31BitInt = 1073741823;
15
15
  function setupScheduler() {
16
16
  const channel = new MessageChannel(),
17
- port = channel.port2;
17
+ port = channel.port2;
18
18
  scheduleCallback = () => port.postMessage(null);
19
19
  channel.port1.onmessage = () => {
20
20
  if (scheduledCallback !== null) {
@@ -65,7 +65,7 @@ function enqueue(taskQueue, task) {
65
65
  function requestCallback(fn, options) {
66
66
  if (!scheduleCallback) setupScheduler();
67
67
  let startTime = performance.now(),
68
- timeout = maxSigned31BitInt;
68
+ timeout = maxSigned31BitInt;
69
69
  if (options && options.timeout) timeout = options.timeout;
70
70
  const newTask = {
71
71
  id: taskIdCounter++,
@@ -121,7 +121,8 @@ function setHydrateContext(context) {
121
121
  sharedConfig.context = context;
122
122
  }
123
123
  function nextHydrateContext() {
124
- return { ...sharedConfig.context,
124
+ return {
125
+ ...sharedConfig.context,
125
126
  id: `${sharedConfig.context.id}${sharedConfig.context.count++}-`,
126
127
  count: 0
127
128
  };
@@ -156,15 +157,15 @@ let ExecCount = 0;
156
157
  const [transPending, setTransPending] = /*@__PURE__*/createSignal(false);
157
158
  function createRoot(fn, detachedOwner) {
158
159
  const listener = Listener,
159
- owner = Owner,
160
- unowned = fn.length === 0,
161
- root = unowned ? UNOWNED : {
162
- owned: null,
163
- cleanups: null,
164
- context: null,
165
- owner: detachedOwner || owner
166
- },
167
- updateFn = unowned ? fn : () => fn(() => untrack(() => cleanNode(root)));
160
+ owner = Owner,
161
+ unowned = fn.length === 0,
162
+ root = unowned ? UNOWNED : {
163
+ owned: null,
164
+ cleanups: null,
165
+ context: null,
166
+ owner: detachedOwner || owner
167
+ },
168
+ updateFn = unowned ? fn : () => fn(() => untrack(() => cleanNode(root)));
168
169
  Owner = root;
169
170
  Listener = null;
170
171
  try {
@@ -201,7 +202,7 @@ function createRenderEffect(fn, value, options) {
201
202
  function createEffect(fn, value, options) {
202
203
  runEffects = runUserEffects;
203
204
  const c = createComputation(fn, value, false, STALE),
204
- s = SuspenseContext && lookup(Owner, SuspenseContext.id);
205
+ s = SuspenseContext && lookup(Owner, SuspenseContext.id);
205
206
  if (s) c.suspense = s;
206
207
  c.user = true;
207
208
  Effects ? Effects.push(c) : updateComputation(c);
@@ -209,10 +210,10 @@ function createEffect(fn, value, options) {
209
210
  function createReaction(onInvalidate, options) {
210
211
  let fn;
211
212
  const c = createComputation(() => {
212
- fn ? fn() : untrack(onInvalidate);
213
- fn = undefined;
214
- }, undefined, false, 0),
215
- s = SuspenseContext && lookup(Owner, SuspenseContext.id);
213
+ fn ? fn() : untrack(onInvalidate);
214
+ fn = undefined;
215
+ }, undefined, false, 0),
216
+ s = SuspenseContext && lookup(Owner, SuspenseContext.id);
216
217
  if (s) c.suspense = s;
217
218
  c.user = true;
218
219
  return tracking => {
@@ -246,19 +247,19 @@ function createResource(pSource, pFetcher, pOptions) {
246
247
  options = pOptions || {};
247
248
  }
248
249
  let pr = null,
249
- initP = NO_INIT,
250
- id = null,
251
- loadedUnderTransition = false,
252
- scheduled = false,
253
- resolved = ("initialValue" in options),
254
- dynamic = typeof source === "function" && createMemo(source);
250
+ initP = NO_INIT,
251
+ id = null,
252
+ loadedUnderTransition = false,
253
+ scheduled = false,
254
+ resolved = ("initialValue" in options),
255
+ dynamic = typeof source === "function" && createMemo(source);
255
256
  const contexts = new Set(),
256
- [value, setValue] = (options.storage || createSignal)(options.initialValue),
257
- [error, setError] = createSignal(undefined),
258
- [track, trigger] = createSignal(undefined, {
259
- equals: false
260
- }),
261
- [state, setState] = createSignal(resolved ? "ready" : "unresolved");
257
+ [value, setValue] = (options.storage || createSignal)(options.initialValue),
258
+ [error, setError] = createSignal(undefined),
259
+ [track, trigger] = createSignal(undefined, {
260
+ equals: false
261
+ }),
262
+ [state, setState] = createSignal(resolved ? "ready" : "unresolved");
262
263
  if (sharedConfig.context) {
263
264
  id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
264
265
  let v;
@@ -294,8 +295,8 @@ function createResource(pSource, pFetcher, pOptions) {
294
295
  }
295
296
  function read() {
296
297
  const c = SuspenseContext && lookup(Owner, SuspenseContext.id),
297
- v = value(),
298
- err = error();
298
+ v = value(),
299
+ err = error();
299
300
  if (err && !pr) throw err;
300
301
  if (Listener && !Listener.user && c) {
301
302
  createComputed(() => {
@@ -367,7 +368,7 @@ function createResource(pSource, pFetcher, pOptions) {
367
368
  }
368
369
  function createDeferred(source, options) {
369
370
  let t,
370
- timeout = options ? options.timeoutMs : undefined;
371
+ timeout = options ? options.timeoutMs : undefined;
371
372
  const node = createComputation(() => {
372
373
  if (!t || !t.fn) t = requestCallback(() => setDeferred(() => node.value), timeout !== undefined ? {
373
374
  timeout
@@ -457,13 +458,16 @@ function getOwner() {
457
458
  }
458
459
  function runWithOwner(o, fn) {
459
460
  const prev = Owner;
461
+ const prevListener = Listener;
460
462
  Owner = o;
463
+ Listener = null;
461
464
  try {
462
465
  return runUpdates(fn, true);
463
466
  } catch (err) {
464
467
  handleError(err);
465
468
  } finally {
466
469
  Owner = prev;
470
+ Listener = prevListener;
467
471
  }
468
472
  }
469
473
  function enableScheduling(scheduler = requestCallback) {
@@ -614,8 +618,8 @@ function updateComputation(node) {
614
618
  if (!node.fn) return;
615
619
  cleanNode(node);
616
620
  const owner = Owner,
617
- listener = Listener,
618
- time = ExecCount;
621
+ listener = Listener,
622
+ time = ExecCount;
619
623
  Listener = Owner = node;
620
624
  runComputation(node, Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value, time);
621
625
  if (Transition && !Transition.running && Transition.sources.has(node)) {
@@ -636,7 +640,17 @@ function runComputation(node, value, time) {
636
640
  try {
637
641
  nextValue = node.fn(value);
638
642
  } catch (err) {
639
- if (node.pure) Transition && Transition.running ? node.tState = STALE : node.state = STALE;
643
+ if (node.pure) {
644
+ if (Transition && Transition.running) {
645
+ node.tState = STALE;
646
+ node.tOwned && node.tOwned.forEach(cleanNode);
647
+ node.tOwned = undefined;
648
+ } else {
649
+ node.state = STALE;
650
+ node.owned && node.owned.forEach(cleanNode);
651
+ node.owned = null;
652
+ }
653
+ }
640
654
  handleError(err);
641
655
  }
642
656
  if (!node.updatedAt || node.updatedAt <= time) {
@@ -703,7 +717,7 @@ function runTop(node) {
703
717
  node = ancestors[i];
704
718
  if (runningTransition) {
705
719
  let top = node,
706
- prev = ancestors[i + 1];
720
+ prev = ancestors[i + 1];
707
721
  while ((top = top.owner) && top !== prev) {
708
722
  if (Transition.disposed.has(top)) return;
709
723
  }
@@ -730,6 +744,7 @@ function runUpdates(fn, init) {
730
744
  return res;
731
745
  } catch (err) {
732
746
  if (!Updates) Effects = null;
747
+ Updates = null;
733
748
  handleError(err);
734
749
  }
735
750
  }
@@ -800,7 +815,7 @@ function scheduleQueue(queue) {
800
815
  }
801
816
  function runUserEffects(queue) {
802
817
  let i,
803
- userLength = 0;
818
+ userLength = 0;
804
819
  for (i = 0; i < queue.length; i++) {
805
820
  const e = queue[i];
806
821
  if (!e.user) runTop(e);else queue[userLength++] = e;
@@ -836,11 +851,11 @@ function cleanNode(node) {
836
851
  if (node.sources) {
837
852
  while (node.sources.length) {
838
853
  const source = node.sources.pop(),
839
- index = node.sourceSlots.pop(),
840
- obs = source.observers;
854
+ index = node.sourceSlots.pop(),
855
+ obs = source.observers;
841
856
  if (obs && obs.length) {
842
857
  const n = obs.pop(),
843
- s = source.observerSlots.pop();
858
+ s = source.observerSlots.pop();
844
859
  if (index < obs.length) {
845
860
  n.sourceSlots[s] = index;
846
861
  obs[index] = n;
@@ -964,27 +979,27 @@ function dispose(d) {
964
979
  }
965
980
  function mapArray(list, mapFn, options = {}) {
966
981
  let items = [],
967
- mapped = [],
968
- disposers = [],
969
- len = 0,
970
- indexes = mapFn.length > 1 ? [] : null;
982
+ mapped = [],
983
+ disposers = [],
984
+ len = 0,
985
+ indexes = mapFn.length > 1 ? [] : null;
971
986
  onCleanup(() => dispose(disposers));
972
987
  return () => {
973
988
  let newItems = list() || [],
974
- i,
975
- j;
989
+ i,
990
+ j;
976
991
  newItems[$TRACK];
977
992
  return untrack(() => {
978
993
  let newLen = newItems.length,
979
- newIndices,
980
- newIndicesNext,
981
- temp,
982
- tempdisposers,
983
- tempIndexes,
984
- start,
985
- end,
986
- newEnd,
987
- item;
994
+ newIndices,
995
+ newIndicesNext,
996
+ temp,
997
+ tempdisposers,
998
+ tempIndexes,
999
+ start,
1000
+ end,
1001
+ newEnd,
1002
+ item;
988
1003
  if (newLen === 0) {
989
1004
  if (len !== 0) {
990
1005
  dispose(disposers);
@@ -1067,11 +1082,11 @@ function mapArray(list, mapFn, options = {}) {
1067
1082
  }
1068
1083
  function indexArray(list, mapFn, options = {}) {
1069
1084
  let items = [],
1070
- mapped = [],
1071
- disposers = [],
1072
- signals = [],
1073
- len = 0,
1074
- i;
1085
+ mapped = [],
1086
+ disposers = [],
1087
+ signals = [],
1088
+ len = 0,
1089
+ i;
1075
1090
  onCleanup(() => dispose(disposers));
1076
1091
  return () => {
1077
1092
  const newItems = list() || [];
@@ -1342,20 +1357,20 @@ function Switch(props) {
1342
1357
  let keyed = false;
1343
1358
  const equals = (a, b) => a[0] === b[0] && (strictEqual ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2];
1344
1359
  const conditions = children(() => props.children),
1345
- evalConditions = createMemo(() => {
1346
- let conds = conditions();
1347
- if (!Array.isArray(conds)) conds = [conds];
1348
- for (let i = 0; i < conds.length; i++) {
1349
- const c = conds[i].when;
1350
- if (c) {
1351
- keyed = !!conds[i].keyed;
1352
- return [i, c, conds[i]];
1360
+ evalConditions = createMemo(() => {
1361
+ let conds = conditions();
1362
+ if (!Array.isArray(conds)) conds = [conds];
1363
+ for (let i = 0; i < conds.length; i++) {
1364
+ const c = conds[i].when;
1365
+ if (c) {
1366
+ keyed = !!conds[i].keyed;
1367
+ return [i, c, conds[i]];
1368
+ }
1353
1369
  }
1354
- }
1355
- return [-1];
1356
- }, undefined, {
1357
- equals
1358
- });
1370
+ return [-1];
1371
+ }, undefined, {
1372
+ equals
1373
+ });
1359
1374
  return createMemo(() => {
1360
1375
  const [index, when, cond] = evalConditions();
1361
1376
  if (index < 0) return props.fallback;
@@ -1397,9 +1412,9 @@ const suspenseListEquals = (a, b) => a.showContent === b.showContent && a.showFa
1397
1412
  const SuspenseListContext = createContext();
1398
1413
  function SuspenseList(props) {
1399
1414
  let [wrapper, setWrapper] = createSignal(() => ({
1400
- inFallback: false
1401
- })),
1402
- show;
1415
+ inFallback: false
1416
+ })),
1417
+ show;
1403
1418
  const listContext = useContext(SuspenseListContext);
1404
1419
  const [registry, setRegistry] = createSignal([]);
1405
1420
  if (listContext) {
@@ -1407,13 +1422,13 @@ function SuspenseList(props) {
1407
1422
  }
1408
1423
  const resolved = createMemo(prev => {
1409
1424
  const reveal = props.revealOrder,
1410
- tail = props.tail,
1411
- {
1412
- showContent = true,
1413
- showFallback = true
1414
- } = show ? show() : {},
1415
- reg = registry(),
1416
- reverse = reveal === "backwards";
1425
+ tail = props.tail,
1426
+ {
1427
+ showContent = true,
1428
+ showFallback = true
1429
+ } = show ? show() : {},
1430
+ reg = registry(),
1431
+ reverse = reveal === "backwards";
1417
1432
  if (reveal === "together") {
1418
1433
  const all = reg.every(inFallback => !inFallback());
1419
1434
  const res = reg.map(() => ({
@@ -1428,7 +1443,7 @@ function SuspenseList(props) {
1428
1443
  const res = [];
1429
1444
  for (let i = 0, len = reg.length; i < len; i++) {
1430
1445
  const n = reverse ? len - i - 1 : i,
1431
- s = reg[n]();
1446
+ s = reg[n]();
1432
1447
  if (!stop && !s) {
1433
1448
  res[n] = {
1434
1449
  showContent,
@@ -1471,25 +1486,25 @@ function SuspenseList(props) {
1471
1486
  }
1472
1487
  function Suspense(props) {
1473
1488
  let counter = 0,
1474
- show,
1475
- ctx,
1476
- p,
1477
- flicker,
1478
- error;
1489
+ show,
1490
+ ctx,
1491
+ p,
1492
+ flicker,
1493
+ error;
1479
1494
  const [inFallback, setFallback] = createSignal(false),
1480
- SuspenseContext = getSuspenseContext(),
1481
- store = {
1482
- increment: () => {
1483
- if (++counter === 1) setFallback(true);
1484
- },
1485
- decrement: () => {
1486
- if (--counter === 0) setFallback(false);
1495
+ SuspenseContext = getSuspenseContext(),
1496
+ store = {
1497
+ increment: () => {
1498
+ if (++counter === 1) setFallback(true);
1499
+ },
1500
+ decrement: () => {
1501
+ if (--counter === 0) setFallback(false);
1502
+ },
1503
+ inFallback,
1504
+ effects: [],
1505
+ resolved: false
1487
1506
  },
1488
- inFallback,
1489
- effects: [],
1490
- resolved: false
1491
- },
1492
- owner = getOwner();
1507
+ owner = getOwner();
1493
1508
  if (sharedConfig.context && sharedConfig.load) {
1494
1509
  const key = sharedConfig.context.id + sharedConfig.context.count;
1495
1510
  let ref = sharedConfig.load(key);
@@ -1529,10 +1544,10 @@ function Suspense(props) {
1529
1544
  const rendered = createMemo(() => props.children);
1530
1545
  return createMemo(prev => {
1531
1546
  const inFallback = store.inFallback(),
1532
- {
1533
- showContent = true,
1534
- showFallback = true
1535
- } = show ? show() : {};
1547
+ {
1548
+ showContent = true,
1549
+ showFallback = true
1550
+ } = show ? show() : {};
1536
1551
  if ((!inFallback || p && p !== "$$f") && showContent) {
1537
1552
  store.resolved = true;
1538
1553
  dispose && dispose();