solid-js 1.6.7 → 1.6.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.
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;
@@ -492,31 +494,21 @@ function createResource(source, fetcher, options = {}) {
492
494
  }];
493
495
  }
494
496
  function lazy(fn) {
495
- let resolved;
496
497
  let p;
497
498
  let load = id => {
498
499
  if (!p) {
499
- if (id) {
500
- let ref = sharedConfig.context.resources[id] = {
501
- ref: p = fn()
502
- };
503
- p.then(mod => ref.data = resolved = mod.default);
504
- return p;
505
- }
506
500
  p = fn();
507
- p.then(mod => resolved = mod.default);
501
+ p.then(mod => p.resolved = mod.default);
502
+ if (id) sharedConfig.context.lazy[id] = p;
508
503
  }
509
504
  return p;
510
505
  };
511
506
  const contexts = new Set();
512
507
  const wrap = props => {
513
508
  const id = sharedConfig.context.id.slice(0, -1);
514
- let ref = sharedConfig.context.resources[id];
515
- if (ref) {
516
- p = ref.ref;
517
- resolved = ref.data;
518
- } else load(id);
519
- if (resolved) return resolved(props);
509
+ let ref = sharedConfig.context.lazy[id];
510
+ if (ref) p = ref;else load(id);
511
+ if (p.resolved) return p.resolved(props);
520
512
  const ctx = useContext(SuspenseContext);
521
513
  const track = {
522
514
  loading: true,
@@ -586,7 +578,8 @@ function Suspense(props) {
586
578
  }
587
579
  });
588
580
  function runSuspense() {
589
- setHydrateContext({ ...ctx,
581
+ setHydrateContext({
582
+ ...ctx,
590
583
  count: 0
591
584
  });
592
585
  return runWithOwner(o, () => {
@@ -610,18 +603,20 @@ function Suspense(props) {
610
603
  });
611
604
  done = ctx.async ? ctx.registerFragment(id) : undefined;
612
605
  if (ctx.async) {
613
- setHydrateContext({ ...ctx,
606
+ setHydrateContext({
607
+ ...ctx,
614
608
  count: 0,
615
609
  id: ctx.id + "0.f",
616
610
  noHydrate: true
617
611
  });
618
612
  const res = {
619
- t: `<span id="pl-${id}">${resolveSSRNode(props.fallback)}</span>`
613
+ t: `<template id="pl-${id}"></template>${resolveSSRNode(props.fallback)}<!pl-${id}>`
620
614
  };
621
615
  setHydrateContext(ctx);
622
616
  return res;
623
617
  }
624
- setHydrateContext({ ...ctx,
618
+ setHydrateContext({
619
+ ...ctx,
625
620
  count: 0,
626
621
  id: ctx.id + "0.f"
627
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
@@ -614,8 +615,8 @@ function updateComputation(node) {
614
615
  if (!node.fn) return;
615
616
  cleanNode(node);
616
617
  const owner = Owner,
617
- listener = Listener,
618
- time = ExecCount;
618
+ listener = Listener,
619
+ time = ExecCount;
619
620
  Listener = Owner = node;
620
621
  runComputation(node, Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value, time);
621
622
  if (Transition && !Transition.running && Transition.sources.has(node)) {
@@ -636,7 +637,17 @@ function runComputation(node, value, time) {
636
637
  try {
637
638
  nextValue = node.fn(value);
638
639
  } catch (err) {
639
- if (node.pure) Transition && Transition.running ? node.tState = STALE : node.state = STALE;
640
+ if (node.pure) {
641
+ if (Transition && Transition.running) {
642
+ node.tState = STALE;
643
+ node.tOwned && node.tOwned.forEach(cleanNode);
644
+ node.tOwned = undefined;
645
+ } else {
646
+ node.state = STALE;
647
+ node.owned && node.owned.forEach(cleanNode);
648
+ node.owned = null;
649
+ }
650
+ }
640
651
  handleError(err);
641
652
  }
642
653
  if (!node.updatedAt || node.updatedAt <= time) {
@@ -703,7 +714,7 @@ function runTop(node) {
703
714
  node = ancestors[i];
704
715
  if (runningTransition) {
705
716
  let top = node,
706
- prev = ancestors[i + 1];
717
+ prev = ancestors[i + 1];
707
718
  while ((top = top.owner) && top !== prev) {
708
719
  if (Transition.disposed.has(top)) return;
709
720
  }
@@ -800,7 +811,7 @@ function scheduleQueue(queue) {
800
811
  }
801
812
  function runUserEffects(queue) {
802
813
  let i,
803
- userLength = 0;
814
+ userLength = 0;
804
815
  for (i = 0; i < queue.length; i++) {
805
816
  const e = queue[i];
806
817
  if (!e.user) runTop(e);else queue[userLength++] = e;
@@ -836,11 +847,11 @@ function cleanNode(node) {
836
847
  if (node.sources) {
837
848
  while (node.sources.length) {
838
849
  const source = node.sources.pop(),
839
- index = node.sourceSlots.pop(),
840
- obs = source.observers;
850
+ index = node.sourceSlots.pop(),
851
+ obs = source.observers;
841
852
  if (obs && obs.length) {
842
853
  const n = obs.pop(),
843
- s = source.observerSlots.pop();
854
+ s = source.observerSlots.pop();
844
855
  if (index < obs.length) {
845
856
  n.sourceSlots[s] = index;
846
857
  obs[index] = n;
@@ -964,27 +975,27 @@ function dispose(d) {
964
975
  }
965
976
  function mapArray(list, mapFn, options = {}) {
966
977
  let items = [],
967
- mapped = [],
968
- disposers = [],
969
- len = 0,
970
- indexes = mapFn.length > 1 ? [] : null;
978
+ mapped = [],
979
+ disposers = [],
980
+ len = 0,
981
+ indexes = mapFn.length > 1 ? [] : null;
971
982
  onCleanup(() => dispose(disposers));
972
983
  return () => {
973
984
  let newItems = list() || [],
974
- i,
975
- j;
985
+ i,
986
+ j;
976
987
  newItems[$TRACK];
977
988
  return untrack(() => {
978
989
  let newLen = newItems.length,
979
- newIndices,
980
- newIndicesNext,
981
- temp,
982
- tempdisposers,
983
- tempIndexes,
984
- start,
985
- end,
986
- newEnd,
987
- item;
990
+ newIndices,
991
+ newIndicesNext,
992
+ temp,
993
+ tempdisposers,
994
+ tempIndexes,
995
+ start,
996
+ end,
997
+ newEnd,
998
+ item;
988
999
  if (newLen === 0) {
989
1000
  if (len !== 0) {
990
1001
  dispose(disposers);
@@ -1067,11 +1078,11 @@ function mapArray(list, mapFn, options = {}) {
1067
1078
  }
1068
1079
  function indexArray(list, mapFn, options = {}) {
1069
1080
  let items = [],
1070
- mapped = [],
1071
- disposers = [],
1072
- signals = [],
1073
- len = 0,
1074
- i;
1081
+ mapped = [],
1082
+ disposers = [],
1083
+ signals = [],
1084
+ len = 0,
1085
+ i;
1075
1086
  onCleanup(() => dispose(disposers));
1076
1087
  return () => {
1077
1088
  const newItems = list() || [];
@@ -1342,20 +1353,20 @@ function Switch(props) {
1342
1353
  let keyed = false;
1343
1354
  const equals = (a, b) => a[0] === b[0] && (strictEqual ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2];
1344
1355
  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]];
1356
+ evalConditions = createMemo(() => {
1357
+ let conds = conditions();
1358
+ if (!Array.isArray(conds)) conds = [conds];
1359
+ for (let i = 0; i < conds.length; i++) {
1360
+ const c = conds[i].when;
1361
+ if (c) {
1362
+ keyed = !!conds[i].keyed;
1363
+ return [i, c, conds[i]];
1364
+ }
1353
1365
  }
1354
- }
1355
- return [-1];
1356
- }, undefined, {
1357
- equals
1358
- });
1366
+ return [-1];
1367
+ }, undefined, {
1368
+ equals
1369
+ });
1359
1370
  return createMemo(() => {
1360
1371
  const [index, when, cond] = evalConditions();
1361
1372
  if (index < 0) return props.fallback;
@@ -1397,9 +1408,9 @@ const suspenseListEquals = (a, b) => a.showContent === b.showContent && a.showFa
1397
1408
  const SuspenseListContext = createContext();
1398
1409
  function SuspenseList(props) {
1399
1410
  let [wrapper, setWrapper] = createSignal(() => ({
1400
- inFallback: false
1401
- })),
1402
- show;
1411
+ inFallback: false
1412
+ })),
1413
+ show;
1403
1414
  const listContext = useContext(SuspenseListContext);
1404
1415
  const [registry, setRegistry] = createSignal([]);
1405
1416
  if (listContext) {
@@ -1407,13 +1418,13 @@ function SuspenseList(props) {
1407
1418
  }
1408
1419
  const resolved = createMemo(prev => {
1409
1420
  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";
1421
+ tail = props.tail,
1422
+ {
1423
+ showContent = true,
1424
+ showFallback = true
1425
+ } = show ? show() : {},
1426
+ reg = registry(),
1427
+ reverse = reveal === "backwards";
1417
1428
  if (reveal === "together") {
1418
1429
  const all = reg.every(inFallback => !inFallback());
1419
1430
  const res = reg.map(() => ({
@@ -1428,7 +1439,7 @@ function SuspenseList(props) {
1428
1439
  const res = [];
1429
1440
  for (let i = 0, len = reg.length; i < len; i++) {
1430
1441
  const n = reverse ? len - i - 1 : i,
1431
- s = reg[n]();
1442
+ s = reg[n]();
1432
1443
  if (!stop && !s) {
1433
1444
  res[n] = {
1434
1445
  showContent,
@@ -1471,25 +1482,25 @@ function SuspenseList(props) {
1471
1482
  }
1472
1483
  function Suspense(props) {
1473
1484
  let counter = 0,
1474
- show,
1475
- ctx,
1476
- p,
1477
- flicker,
1478
- error;
1485
+ show,
1486
+ ctx,
1487
+ p,
1488
+ flicker,
1489
+ error;
1479
1490
  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);
1491
+ SuspenseContext = getSuspenseContext(),
1492
+ store = {
1493
+ increment: () => {
1494
+ if (++counter === 1) setFallback(true);
1495
+ },
1496
+ decrement: () => {
1497
+ if (--counter === 0) setFallback(false);
1498
+ },
1499
+ inFallback,
1500
+ effects: [],
1501
+ resolved: false
1487
1502
  },
1488
- inFallback,
1489
- effects: [],
1490
- resolved: false
1491
- },
1492
- owner = getOwner();
1503
+ owner = getOwner();
1493
1504
  if (sharedConfig.context && sharedConfig.load) {
1494
1505
  const key = sharedConfig.context.id + sharedConfig.context.count;
1495
1506
  let ref = sharedConfig.load(key);
@@ -1529,10 +1540,10 @@ function Suspense(props) {
1529
1540
  const rendered = createMemo(() => props.children);
1530
1541
  return createMemo(prev => {
1531
1542
  const inFallback = store.inFallback(),
1532
- {
1533
- showContent = true,
1534
- showFallback = true
1535
- } = show ? show() : {};
1543
+ {
1544
+ showContent = true,
1545
+ showFallback = true
1546
+ } = show ? show() : {};
1536
1547
  if ((!inFallback || p && p !== "$$f") && showContent) {
1537
1548
  store.resolved = true;
1538
1549
  dispose && dispose();