solid-js 1.3.2 → 1.3.6

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/dev.cjs CHANGED
@@ -267,6 +267,7 @@ function createResource(source, fetcher, options) {
267
267
  initP = null,
268
268
  id = null,
269
269
  loadedUnderTransition = false,
270
+ scheduled = false,
270
271
  dynamic = typeof source === "function";
271
272
  if (sharedConfig.context) {
272
273
  id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
@@ -321,6 +322,8 @@ function createResource(source, fetcher, options) {
321
322
  return v;
322
323
  }
323
324
  function load(refetching = true) {
325
+ if (refetching && scheduled) return;
326
+ scheduled = false;
324
327
  setError(err = undefined);
325
328
  const lookup = dynamic ? source() : source;
326
329
  loadedUnderTransition = Transition && Transition.running;
@@ -338,6 +341,8 @@ function createResource(source, fetcher, options) {
338
341
  return p;
339
342
  }
340
343
  pr = p;
344
+ scheduled = true;
345
+ queueMicrotask(() => scheduled = false);
341
346
  batch(() => {
342
347
  setLoading(true);
343
348
  trigger();
@@ -1313,7 +1318,6 @@ function lazy(fn) {
1313
1318
  const wrap = props => {
1314
1319
  const ctx = sharedConfig.context;
1315
1320
  if (ctx) {
1316
- ctx.count++;
1317
1321
  const [s, set] = createSignal();
1318
1322
  (p || (p = fn())).then(mod => {
1319
1323
  setHydrateContext(ctx);
@@ -1332,6 +1336,9 @@ function lazy(fn) {
1332
1336
  }
1333
1337
  let Comp;
1334
1338
  return createMemo(() => (Comp = comp()) && untrack(() => {
1339
+ Object.assign(Comp, {
1340
+ [$DEVCOMP]: true
1341
+ });
1335
1342
  if (!ctx) return Comp(props);
1336
1343
  const c = sharedConfig.context;
1337
1344
  setHydrateContext(ctx);
@@ -1399,12 +1406,19 @@ function Switch(props) {
1399
1406
  function Match(props) {
1400
1407
  return props;
1401
1408
  }
1409
+ let Errors;
1410
+ function resetErrorBoundaries() {
1411
+ Errors && [...Errors].forEach(fn => fn());
1412
+ }
1402
1413
  function ErrorBoundary(props) {
1403
1414
  let err = undefined;
1404
1415
  if (sharedConfig.context && sharedConfig.load) {
1405
1416
  err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
1406
1417
  }
1407
1418
  const [errored, setErrored] = createSignal(err);
1419
+ Errors || (Errors = new Set());
1420
+ Errors.add(setErrored);
1421
+ onCleanup(() => Errors.delete(setErrored));
1408
1422
  let e;
1409
1423
  return createMemo(() => {
1410
1424
  if ((e = errored()) != null) {
@@ -1519,7 +1533,6 @@ function Suspense(props) {
1519
1533
  setHydrateContext(ctx);
1520
1534
  set();
1521
1535
  setHydrateContext();
1522
- p = undefined;
1523
1536
  });
1524
1537
  }
1525
1538
  }
@@ -1546,6 +1559,7 @@ function Suspense(props) {
1546
1559
  dispose && dispose();
1547
1560
  if ((!inFallback || p !== undefined) && visibleContent) {
1548
1561
  store.resolved = true;
1562
+ ctx = p = undefined;
1549
1563
  resumeEffects(store.effects);
1550
1564
  return rendered;
1551
1565
  }
@@ -1624,6 +1638,7 @@ exports.onError = onError;
1624
1638
  exports.onMount = onMount;
1625
1639
  exports.refetchResources = refetchResources;
1626
1640
  exports.requestCallback = requestCallback;
1641
+ exports.resetErrorBoundaries = resetErrorBoundaries;
1627
1642
  exports.runWithOwner = runWithOwner;
1628
1643
  exports.sharedConfig = sharedConfig;
1629
1644
  exports.splitProps = splitProps;
package/dist/dev.js CHANGED
@@ -263,6 +263,7 @@ function createResource(source, fetcher, options) {
263
263
  initP = null,
264
264
  id = null,
265
265
  loadedUnderTransition = false,
266
+ scheduled = false,
266
267
  dynamic = typeof source === "function";
267
268
  if (sharedConfig.context) {
268
269
  id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
@@ -317,6 +318,8 @@ function createResource(source, fetcher, options) {
317
318
  return v;
318
319
  }
319
320
  function load(refetching = true) {
321
+ if (refetching && scheduled) return;
322
+ scheduled = false;
320
323
  setError(err = undefined);
321
324
  const lookup = dynamic ? source() : source;
322
325
  loadedUnderTransition = Transition && Transition.running;
@@ -334,6 +337,8 @@ function createResource(source, fetcher, options) {
334
337
  return p;
335
338
  }
336
339
  pr = p;
340
+ scheduled = true;
341
+ queueMicrotask(() => scheduled = false);
337
342
  batch(() => {
338
343
  setLoading(true);
339
344
  trigger();
@@ -1309,7 +1314,6 @@ function lazy(fn) {
1309
1314
  const wrap = props => {
1310
1315
  const ctx = sharedConfig.context;
1311
1316
  if (ctx) {
1312
- ctx.count++;
1313
1317
  const [s, set] = createSignal();
1314
1318
  (p || (p = fn())).then(mod => {
1315
1319
  setHydrateContext(ctx);
@@ -1328,6 +1332,9 @@ function lazy(fn) {
1328
1332
  }
1329
1333
  let Comp;
1330
1334
  return createMemo(() => (Comp = comp()) && untrack(() => {
1335
+ Object.assign(Comp, {
1336
+ [$DEVCOMP]: true
1337
+ });
1331
1338
  if (!ctx) return Comp(props);
1332
1339
  const c = sharedConfig.context;
1333
1340
  setHydrateContext(ctx);
@@ -1395,12 +1402,19 @@ function Switch(props) {
1395
1402
  function Match(props) {
1396
1403
  return props;
1397
1404
  }
1405
+ let Errors;
1406
+ function resetErrorBoundaries() {
1407
+ Errors && [...Errors].forEach(fn => fn());
1408
+ }
1398
1409
  function ErrorBoundary(props) {
1399
1410
  let err = undefined;
1400
1411
  if (sharedConfig.context && sharedConfig.load) {
1401
1412
  err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
1402
1413
  }
1403
1414
  const [errored, setErrored] = createSignal(err);
1415
+ Errors || (Errors = new Set());
1416
+ Errors.add(setErrored);
1417
+ onCleanup(() => Errors.delete(setErrored));
1404
1418
  let e;
1405
1419
  return createMemo(() => {
1406
1420
  if ((e = errored()) != null) {
@@ -1515,7 +1529,6 @@ function Suspense(props) {
1515
1529
  setHydrateContext(ctx);
1516
1530
  set();
1517
1531
  setHydrateContext();
1518
- p = undefined;
1519
1532
  });
1520
1533
  }
1521
1534
  }
@@ -1542,6 +1555,7 @@ function Suspense(props) {
1542
1555
  dispose && dispose();
1543
1556
  if ((!inFallback || p !== undefined) && visibleContent) {
1544
1557
  store.resolved = true;
1558
+ ctx = p = undefined;
1545
1559
  resumeEffects(store.effects);
1546
1560
  return rendered;
1547
1561
  }
@@ -1576,4 +1590,4 @@ if (globalThis) {
1576
1590
  if (!globalThis.Solid$$) globalThis.Solid$$ = true;else console.warn("You appear to have multiple instances of Solid. This can lead to unexpected behavior.");
1577
1591
  }
1578
1592
 
1579
- export { $DEVCOMP, $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, cancelCallback, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createReaction, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, refetchResources, requestCallback, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
1593
+ export { $DEVCOMP, $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, cancelCallback, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createReaction, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, refetchResources, requestCallback, resetErrorBoundaries, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
package/dist/server.cjs CHANGED
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const equalFn = (a, b) => a === b;
6
6
  const $PROXY = Symbol("solid-proxy");
7
- const $DEVCOMP = Symbol('solid-dev-component');
7
+ const $DEVCOMP = Symbol("solid-dev-component");
8
8
  const DEV = {};
9
9
  const ERROR = Symbol("error");
10
10
  const UNOWNED = {
@@ -79,7 +79,7 @@ function createMemo(fn, value) {
79
79
  function createDeferred(source) {
80
80
  return source;
81
81
  }
82
- function createSelector(source, fn) {
82
+ function createSelector(source, fn = equalFn) {
83
83
  return k => fn(k, source());
84
84
  }
85
85
  function batch(fn) {
@@ -311,6 +311,7 @@ function Switch(props) {
311
311
  function Match(props) {
312
312
  return props;
313
313
  }
314
+ function resetErrorBoundaries() {}
314
315
  function ErrorBoundary(props) {
315
316
  let error, res;
316
317
  const ctx = sharedConfig.context;
@@ -349,7 +350,7 @@ function createResource(fn, fetcher, options = {}) {
349
350
  if (sharedConfig.context.async) {
350
351
  resource = sharedConfig.context.resources[id] || (sharedConfig.context.resources[id] = {});
351
352
  if (resource.ref) {
352
- if (!resource.data && !resource.ref[0].loading) resource.ref[1].refetch();
353
+ if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error) resource.ref[1].refetch();
353
354
  return resource.ref;
354
355
  }
355
356
  }
@@ -367,6 +368,7 @@ function createResource(fn, fetcher, options = {}) {
367
368
  return resolved ? sharedConfig.context.resources[id].data : value;
368
369
  };
369
370
  read.loading = false;
371
+ read.error = undefined;
370
372
  function load() {
371
373
  const ctx = sharedConfig.context;
372
374
  if (!ctx.async) return read.loading = !!(typeof fn === "function" ? fn() : fn);
@@ -395,7 +397,7 @@ function createResource(fn, fetcher, options = {}) {
395
397
  return res;
396
398
  }).catch(err => {
397
399
  read.loading = false;
398
- error = err;
400
+ read.error = error = err;
399
401
  p = null;
400
402
  notifySuspense(contexts);
401
403
  });
@@ -410,17 +412,19 @@ function createResource(fn, fetcher, options = {}) {
410
412
  mutate: v => value = v
411
413
  }];
412
414
  }
415
+ function refetchResources(info) {}
413
416
  function lazy(fn) {
414
417
  let resolved;
415
418
  const p = fn();
416
419
  const contexts = new Set();
417
420
  p.then(mod => resolved = mod.default);
418
421
  const wrap = props => {
419
- const id = sharedConfig.context.id + sharedConfig.context.count++;
422
+ const id = sharedConfig.context.id.slice(0, -1);
420
423
  if (resolved) return resolved(props);
421
424
  const ctx = useContext(SuspenseContext);
422
425
  const track = {
423
- loading: true
426
+ loading: true,
427
+ error: undefined
424
428
  };
425
429
  if (ctx) {
426
430
  ctx.resources.set(id, track);
@@ -556,7 +560,9 @@ exports.on = on;
556
560
  exports.onCleanup = onCleanup;
557
561
  exports.onError = onError;
558
562
  exports.onMount = onMount;
563
+ exports.refetchResources = refetchResources;
559
564
  exports.requestCallback = requestCallback;
565
+ exports.resetErrorBoundaries = resetErrorBoundaries;
560
566
  exports.runWithOwner = runWithOwner;
561
567
  exports.sharedConfig = sharedConfig;
562
568
  exports.splitProps = splitProps;
package/dist/server.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const equalFn = (a, b) => a === b;
2
2
  const $PROXY = Symbol("solid-proxy");
3
- const $DEVCOMP = Symbol('solid-dev-component');
3
+ const $DEVCOMP = Symbol("solid-dev-component");
4
4
  const DEV = {};
5
5
  const ERROR = Symbol("error");
6
6
  const UNOWNED = {
@@ -75,7 +75,7 @@ function createMemo(fn, value) {
75
75
  function createDeferred(source) {
76
76
  return source;
77
77
  }
78
- function createSelector(source, fn) {
78
+ function createSelector(source, fn = equalFn) {
79
79
  return k => fn(k, source());
80
80
  }
81
81
  function batch(fn) {
@@ -307,6 +307,7 @@ function Switch(props) {
307
307
  function Match(props) {
308
308
  return props;
309
309
  }
310
+ function resetErrorBoundaries() {}
310
311
  function ErrorBoundary(props) {
311
312
  let error, res;
312
313
  const ctx = sharedConfig.context;
@@ -345,7 +346,7 @@ function createResource(fn, fetcher, options = {}) {
345
346
  if (sharedConfig.context.async) {
346
347
  resource = sharedConfig.context.resources[id] || (sharedConfig.context.resources[id] = {});
347
348
  if (resource.ref) {
348
- if (!resource.data && !resource.ref[0].loading) resource.ref[1].refetch();
349
+ if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error) resource.ref[1].refetch();
349
350
  return resource.ref;
350
351
  }
351
352
  }
@@ -363,6 +364,7 @@ function createResource(fn, fetcher, options = {}) {
363
364
  return resolved ? sharedConfig.context.resources[id].data : value;
364
365
  };
365
366
  read.loading = false;
367
+ read.error = undefined;
366
368
  function load() {
367
369
  const ctx = sharedConfig.context;
368
370
  if (!ctx.async) return read.loading = !!(typeof fn === "function" ? fn() : fn);
@@ -391,7 +393,7 @@ function createResource(fn, fetcher, options = {}) {
391
393
  return res;
392
394
  }).catch(err => {
393
395
  read.loading = false;
394
- error = err;
396
+ read.error = error = err;
395
397
  p = null;
396
398
  notifySuspense(contexts);
397
399
  });
@@ -406,17 +408,19 @@ function createResource(fn, fetcher, options = {}) {
406
408
  mutate: v => value = v
407
409
  }];
408
410
  }
411
+ function refetchResources(info) {}
409
412
  function lazy(fn) {
410
413
  let resolved;
411
414
  const p = fn();
412
415
  const contexts = new Set();
413
416
  p.then(mod => resolved = mod.default);
414
417
  const wrap = props => {
415
- const id = sharedConfig.context.id + sharedConfig.context.count++;
418
+ const id = sharedConfig.context.id.slice(0, -1);
416
419
  if (resolved) return resolved(props);
417
420
  const ctx = useContext(SuspenseContext);
418
421
  const track = {
419
- loading: true
422
+ loading: true,
423
+ error: undefined
420
424
  };
421
425
  if (ctx) {
422
426
  ctx.resources.set(id, track);
@@ -511,4 +515,4 @@ function Suspense(props) {
511
515
  return props.fallback;
512
516
  }
513
517
 
514
- export { $DEVCOMP, $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, 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, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
518
+ export { $DEVCOMP, $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, 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, refetchResources, requestCallback, resetErrorBoundaries, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
package/dist/solid.cjs CHANGED
@@ -264,6 +264,7 @@ function createResource(source, fetcher, options) {
264
264
  initP = null,
265
265
  id = null,
266
266
  loadedUnderTransition = false,
267
+ scheduled = false,
267
268
  dynamic = typeof source === "function";
268
269
  if (sharedConfig.context) {
269
270
  id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
@@ -318,6 +319,8 @@ function createResource(source, fetcher, options) {
318
319
  return v;
319
320
  }
320
321
  function load(refetching = true) {
322
+ if (refetching && scheduled) return;
323
+ scheduled = false;
321
324
  setError(err = undefined);
322
325
  const lookup = dynamic ? source() : source;
323
326
  loadedUnderTransition = Transition && Transition.running;
@@ -335,6 +338,8 @@ function createResource(source, fetcher, options) {
335
338
  return p;
336
339
  }
337
340
  pr = p;
341
+ scheduled = true;
342
+ queueMicrotask(() => scheduled = false);
338
343
  batch(() => {
339
344
  setLoading(true);
340
345
  trigger();
@@ -1232,7 +1237,6 @@ function lazy(fn) {
1232
1237
  const wrap = props => {
1233
1238
  const ctx = sharedConfig.context;
1234
1239
  if (ctx) {
1235
- ctx.count++;
1236
1240
  const [s, set] = createSignal();
1237
1241
  (p || (p = fn())).then(mod => {
1238
1242
  setHydrateContext(ctx);
@@ -1318,12 +1322,19 @@ function Switch(props) {
1318
1322
  function Match(props) {
1319
1323
  return props;
1320
1324
  }
1325
+ let Errors;
1326
+ function resetErrorBoundaries() {
1327
+ Errors && [...Errors].forEach(fn => fn());
1328
+ }
1321
1329
  function ErrorBoundary(props) {
1322
1330
  let err = undefined;
1323
1331
  if (sharedConfig.context && sharedConfig.load) {
1324
1332
  err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
1325
1333
  }
1326
1334
  const [errored, setErrored] = createSignal(err);
1335
+ Errors || (Errors = new Set());
1336
+ Errors.add(setErrored);
1337
+ onCleanup(() => Errors.delete(setErrored));
1327
1338
  let e;
1328
1339
  return createMemo(() => {
1329
1340
  if ((e = errored()) != null) {
@@ -1438,7 +1449,6 @@ function Suspense(props) {
1438
1449
  setHydrateContext(ctx);
1439
1450
  set();
1440
1451
  setHydrateContext();
1441
- p = undefined;
1442
1452
  });
1443
1453
  }
1444
1454
  }
@@ -1465,6 +1475,7 @@ function Suspense(props) {
1465
1475
  dispose && dispose();
1466
1476
  if ((!inFallback || p !== undefined) && visibleContent) {
1467
1477
  store.resolved = true;
1478
+ ctx = p = undefined;
1468
1479
  resumeEffects(store.effects);
1469
1480
  return rendered;
1470
1481
  }
@@ -1533,6 +1544,7 @@ exports.onError = onError;
1533
1544
  exports.onMount = onMount;
1534
1545
  exports.refetchResources = refetchResources;
1535
1546
  exports.requestCallback = requestCallback;
1547
+ exports.resetErrorBoundaries = resetErrorBoundaries;
1536
1548
  exports.runWithOwner = runWithOwner;
1537
1549
  exports.sharedConfig = sharedConfig;
1538
1550
  exports.splitProps = splitProps;
package/dist/solid.js CHANGED
@@ -260,6 +260,7 @@ function createResource(source, fetcher, options) {
260
260
  initP = null,
261
261
  id = null,
262
262
  loadedUnderTransition = false,
263
+ scheduled = false,
263
264
  dynamic = typeof source === "function";
264
265
  if (sharedConfig.context) {
265
266
  id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
@@ -314,6 +315,8 @@ function createResource(source, fetcher, options) {
314
315
  return v;
315
316
  }
316
317
  function load(refetching = true) {
318
+ if (refetching && scheduled) return;
319
+ scheduled = false;
317
320
  setError(err = undefined);
318
321
  const lookup = dynamic ? source() : source;
319
322
  loadedUnderTransition = Transition && Transition.running;
@@ -331,6 +334,8 @@ function createResource(source, fetcher, options) {
331
334
  return p;
332
335
  }
333
336
  pr = p;
337
+ scheduled = true;
338
+ queueMicrotask(() => scheduled = false);
334
339
  batch(() => {
335
340
  setLoading(true);
336
341
  trigger();
@@ -1228,7 +1233,6 @@ function lazy(fn) {
1228
1233
  const wrap = props => {
1229
1234
  const ctx = sharedConfig.context;
1230
1235
  if (ctx) {
1231
- ctx.count++;
1232
1236
  const [s, set] = createSignal();
1233
1237
  (p || (p = fn())).then(mod => {
1234
1238
  setHydrateContext(ctx);
@@ -1314,12 +1318,19 @@ function Switch(props) {
1314
1318
  function Match(props) {
1315
1319
  return props;
1316
1320
  }
1321
+ let Errors;
1322
+ function resetErrorBoundaries() {
1323
+ Errors && [...Errors].forEach(fn => fn());
1324
+ }
1317
1325
  function ErrorBoundary(props) {
1318
1326
  let err = undefined;
1319
1327
  if (sharedConfig.context && sharedConfig.load) {
1320
1328
  err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
1321
1329
  }
1322
1330
  const [errored, setErrored] = createSignal(err);
1331
+ Errors || (Errors = new Set());
1332
+ Errors.add(setErrored);
1333
+ onCleanup(() => Errors.delete(setErrored));
1323
1334
  let e;
1324
1335
  return createMemo(() => {
1325
1336
  if ((e = errored()) != null) {
@@ -1434,7 +1445,6 @@ function Suspense(props) {
1434
1445
  setHydrateContext(ctx);
1435
1446
  set();
1436
1447
  setHydrateContext();
1437
- p = undefined;
1438
1448
  });
1439
1449
  }
1440
1450
  }
@@ -1461,6 +1471,7 @@ function Suspense(props) {
1461
1471
  dispose && dispose();
1462
1472
  if ((!inFallback || p !== undefined) && visibleContent) {
1463
1473
  store.resolved = true;
1474
+ ctx = p = undefined;
1464
1475
  resumeEffects(store.effects);
1465
1476
  return rendered;
1466
1477
  }
@@ -1484,4 +1495,4 @@ function Suspense(props) {
1484
1495
 
1485
1496
  let DEV;
1486
1497
 
1487
- export { $DEVCOMP, $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, cancelCallback, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createReaction, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, refetchResources, requestCallback, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
1498
+ export { $DEVCOMP, $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, cancelCallback, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createReaction, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, refetchResources, requestCallback, resetErrorBoundaries, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
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.3.2",
4
+ "version": "1.3.6",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "homepage": "https://solidjs.com",
@@ -144,5 +144,5 @@
144
144
  "compiler",
145
145
  "performance"
146
146
  ],
147
- "gitHead": "b0aa7b227de8a3b4dc686690207d54a8af244efc"
147
+ "gitHead": "10183a0ee2de5c685e4d4558cbe1b78a6ca4c48e"
148
148
  }
@@ -9,5 +9,27 @@
9
9
  "unpkg": "./dist/store.cjs",
10
10
  "types": "./types/index.d.ts",
11
11
  "type": "module",
12
- "sideEffects": false
12
+ "sideEffects": false,
13
+ "exports": {
14
+ ".": {
15
+ "browser": {
16
+ "development": {
17
+ "import": "./dist/dev.js",
18
+ "require": "./dist/dev.cjs"
19
+ },
20
+ "import": "./dist/store.js",
21
+ "require": "./dist/store.cjs"
22
+ },
23
+ "node": {
24
+ "import": "./dist/server.js",
25
+ "require": "./dist/server.cjs"
26
+ },
27
+ "development": {
28
+ "import": "./dist/dev.js",
29
+ "require": "./dist/dev.cjs"
30
+ },
31
+ "import": "./dist/store.js",
32
+ "require": "./dist/store.cjs"
33
+ }
34
+ }
13
35
  }
package/types/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { createRoot, createSignal, createEffect, createRenderEffect, createComputed, createReaction, createDeferred, createSelector, createMemo, createResource, onMount, onCleanup, onError, untrack, batch, on, enableScheduling, enableExternalSource, startTransition, useTransition, refetchResources, createContext, useContext, children, getListener, getOwner, runWithOwner, equalFn, $DEVCOMP, $PROXY } from "./reactive/signal";
2
- export type { Accessor, Setter, Resource, ResourceReturn, ResourceFetcher, ResourceFetcherInfo, Context, ReturnTypes } from "./reactive/signal";
2
+ export type { Accessor, Setter, Signal, Resource, ResourceReturn, ResourceFetcher, ResourceFetcherInfo, Context, ReturnTypes } from "./reactive/signal";
3
3
  export * from "./reactive/observable";
4
4
  export * from "./reactive/scheduler";
5
5
  export * from "./reactive/array";
package/types/jsx.d.ts CHANGED
@@ -2085,6 +2085,8 @@ export namespace JSX {
2085
2085
  }
2086
2086
  interface DetailsHtmlAttributes<T> extends HTMLAttributes<T> {
2087
2087
  open?: boolean;
2088
+ onToggle?: EventHandlerUnion<T, Event>;
2089
+ ontoggle?: EventHandlerUnion<T, Event>;
2088
2090
  }
2089
2091
  interface DialogHtmlAttributes<T> extends HTMLAttributes<T> {
2090
2092
  open?: boolean;
@@ -204,13 +204,13 @@ export declare type ResourceActions<T> = {
204
204
  refetch: (info?: unknown) => void;
205
205
  };
206
206
  export declare type ResourceReturn<T> = [Resource<T>, ResourceActions<T>];
207
- export declare type ResourceSource<S> = S | false | null | (() => S | false | null);
207
+ export declare type ResourceSource<S> = S | false | null | undefined | (() => S | false | null | undefined);
208
208
  export declare type ResourceFetcher<S, T> = (k: S, info: ResourceFetcherInfo<T>) => T | Promise<T>;
209
209
  export declare type ResourceFetcherInfo<T> = {
210
210
  value: T | undefined;
211
211
  refetching?: unknown;
212
212
  };
213
- export declare type ResourceOptions<T> = T extends undefined ? {
213
+ export declare type ResourceOptions<T> = undefined extends T ? {
214
214
  initialValue?: T;
215
215
  name?: string;
216
216
  globalRefetch?: boolean;
@@ -13,8 +13,9 @@ export declare type Component<P = {}> = (props: PropsWithChildren<P>) => JSX.Ele
13
13
  */
14
14
  export declare type ComponentProps<T extends keyof JSX.IntrinsicElements | Component<any>> = T extends Component<infer P> ? P : T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T] : {};
15
15
  export declare function createComponent<T>(Comp: (props: T) => JSX.Element, props: T): JSX.Element;
16
+ declare type UnboxLazy<T> = T extends () => infer U ? U : T;
16
17
  declare type BoxedTupleTypes<T extends any[]> = {
17
- [P in keyof T]: [T[P]];
18
+ [P in keyof T]: [UnboxLazy<T[P]>];
18
19
  }[Exclude<keyof T, keyof any[]>];
19
20
  declare type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
20
21
  declare type UnboxIntersection<T> = T extends {
@@ -77,6 +77,7 @@ export declare type MatchProps<T> = {
77
77
  * @description https://www.solidjs.com/docs/latest/api#%3Cswitch%3E%2F%3Cmatch%3E
78
78
  */
79
79
  export declare function Match<T>(props: MatchProps<T>): JSX.Element;
80
+ export declare function resetErrorBoundaries(): void;
80
81
  /**
81
82
  * catches uncaught errors inside components and renders a fallback content
82
83
  *
@@ -1,3 +1,3 @@
1
1
  export { createRoot, createSignal, createComputed, createRenderEffect, createEffect, createReaction, createDeferred, createSelector, createMemo, getListener, onMount, onCleanup, onError, untrack, batch, on, children, createContext, useContext, getOwner, runWithOwner, equalFn, requestCallback, mapArray, observable, from, $PROXY, $DEVCOMP, DEV, enableExternalSource } from "./reactive";
2
- export { mergeProps, splitProps, createComponent, For, Index, Show, Switch, Match, ErrorBoundary, Suspense, SuspenseList, createResource, enableScheduling, enableHydration, startTransition, useTransition, createUniqueId, lazy, sharedConfig } from "./rendering";
2
+ export { mergeProps, splitProps, createComponent, For, Index, Show, Switch, Match, ErrorBoundary, Suspense, SuspenseList, createResource, refetchResources, resetErrorBoundaries, enableScheduling, enableHydration, startTransition, useTransition, createUniqueId, lazy, sharedConfig } from "./rendering";
3
3
  export type { Component, Resource } from "./rendering";
@@ -19,7 +19,7 @@ export declare function createEffect<T>(fn: (v?: T) => T, value?: T): void;
19
19
  export declare function createReaction(fn: () => void): (fn: () => void) => void;
20
20
  export declare function createMemo<T>(fn: (v?: T) => T, value?: T): () => T;
21
21
  export declare function createDeferred<T>(source: () => T): () => T;
22
- export declare function createSelector<T>(source: () => T, fn: (k: T, value: T) => boolean): (k: T) => boolean;
22
+ export declare function createSelector<T>(source: () => T, fn?: (k: T, value: T) => boolean): (k: T) => boolean;
23
23
  export declare function batch<T>(fn: () => T): T;
24
24
  export declare const untrack: typeof batch;
25
25
  export declare function on<T, U>(deps: Array<() => T> | (() => T), fn: (value: Array<T> | T, prev?: Array<T> | T, prevResults?: U) => U, options?: {
@@ -55,6 +55,7 @@ declare type MatchProps<T> = {
55
55
  children: string | ((item: T) => string);
56
56
  };
57
57
  export declare function Match<T>(props: MatchProps<T>): MatchProps<T>;
58
+ export declare function resetErrorBoundaries(): void;
58
59
  export declare function ErrorBoundary(props: {
59
60
  fallback: string | ((err: any, reset: () => void) => string);
60
61
  children: string;
@@ -62,10 +63,12 @@ export declare function ErrorBoundary(props: {
62
63
  export interface Resource<T> {
63
64
  (): T | undefined;
64
65
  loading: boolean;
66
+ error: any;
65
67
  }
66
68
  declare type SuspenseContextType = {
67
69
  resources: Map<string, {
68
70
  loading: boolean;
71
+ error: any;
69
72
  }>;
70
73
  completed: () => void;
71
74
  };
@@ -4,5 +4,15 @@
4
4
  "module": "./dist/universal.js",
5
5
  "types": "./types/index.d.ts",
6
6
  "type": "module",
7
- "sideEffects": false
7
+ "sideEffects": false,
8
+ "exports": {
9
+ ".": {
10
+ "development": {
11
+ "import": "./dist/dev.js",
12
+ "require": "./dist/dev.cjs"
13
+ },
14
+ "import": "./dist/universal.js",
15
+ "require": "./dist/universal.cjs"
16
+ }
17
+ }
8
18
  }
package/web/dist/dev.cjs CHANGED
@@ -197,6 +197,9 @@ function dynamicProperty(props, key) {
197
197
  });
198
198
  return props;
199
199
  }
200
+ function innerHTML(parent, content) {
201
+ !solidJs.sharedConfig.context && (parent.innerHTML = content);
202
+ }
200
203
  function insert(parent, accessor, marker, initial) {
201
204
  if (marker !== undefined && !initial) initial = [];
202
205
  if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
@@ -389,28 +392,24 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
389
392
  return current;
390
393
  }
391
394
  if (array.length === 0) {
392
- current = cleanChildren(parent, current, marker);
393
- if (multi) return current;
395
+ cleanChildren(parent, current, marker);
396
+ } else if (Array.isArray(current)) {
397
+ if (current.length === 0) {
398
+ appendNodes(parent, array, marker);
399
+ } else reconcileArrays(parent, current, array);
394
400
  } else {
395
- if (Array.isArray(current)) {
396
- if (current.length === 0) {
397
- appendNodes(parent, array, marker);
398
- } else reconcileArrays(parent, current, array);
399
- } else if (current == null || current === "") {
400
- appendNodes(parent, array);
401
- } else {
402
- reconcileArrays(parent, multi && current || [parent.firstChild], array);
403
- }
401
+ current && cleanChildren(parent);
402
+ appendNodes(parent, array);
404
403
  }
405
404
  current = array;
406
405
  } else if (value instanceof Node) {
407
- if (solidJs.sharedConfig.context) return current = value.parentNode ? value : current;
406
+ if (solidJs.sharedConfig.context) return current = value.parentNode ? multi ? [value] : value : current;
408
407
  if (Array.isArray(current)) {
409
408
  if (multi) return current = cleanChildren(parent, current, marker, value);
410
409
  cleanChildren(parent, current, null, value);
411
410
  } else if (current == null || current === "" || !parent.firstChild) {
412
411
  parent.appendChild(value);
413
- } else parent.replaceChild(value, multi ? current : parent.firstChild);
412
+ } else parent.replaceChild(value, parent.firstChild);
414
413
  current = value;
415
414
  } else console.warn(`Unrecognized value. Skipped inserting`, value);
416
415
  return current;
@@ -453,7 +452,7 @@ function cleanChildren(parent, current, marker, replacement) {
453
452
  if (!inserted && !i) isParent ? parent.replaceChild(node, el) : parent.insertBefore(node, marker);else isParent && el.remove();
454
453
  } else inserted = true;
455
454
  }
456
- } else if (current instanceof Node) parent.replaceChild(node, current);else parent.insertBefore(node, marker);
455
+ } else parent.insertBefore(node, marker);
457
456
  return [node];
458
457
  }
459
458
  function gatherHydratable(element, root) {
@@ -540,6 +539,9 @@ function Dynamic(props) {
540
539
  const component = p.component;
541
540
  switch (typeof component) {
542
541
  case "function":
542
+ Object.assign(component, {
543
+ [solidJs.$DEVCOMP]: true
544
+ });
543
545
  return solidJs.untrack(() => component(others));
544
546
  case "string":
545
547
  const isSvg = SVGElements.has(component);
@@ -623,6 +625,7 @@ exports.getNextElement = getNextElement;
623
625
  exports.getNextMarker = getNextMarker;
624
626
  exports.getNextMatch = getNextMatch;
625
627
  exports.hydrate = hydrate;
628
+ exports.innerHTML = innerHTML;
626
629
  exports.insert = insert;
627
630
  exports.isServer = isServer;
628
631
  exports.memo = memo;
package/web/dist/dev.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createMemo, createRoot, createRenderEffect, sharedConfig, enableHydration, createSignal, onCleanup, splitProps, untrack } from 'solid-js';
1
+ import { createMemo, createRoot, createRenderEffect, sharedConfig, enableHydration, createSignal, onCleanup, splitProps, $DEVCOMP, untrack } from 'solid-js';
2
2
  export { ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, createComponent, createRenderEffect as effect, getOwner, mergeProps } from 'solid-js';
3
3
 
4
4
  const booleans = ["allowfullscreen", "async", "autofocus", "autoplay", "checked", "controls", "default", "disabled", "formnovalidate", "hidden", "indeterminate", "ismap", "loop", "multiple", "muted", "nomodule", "novalidate", "open", "playsinline", "readonly", "required", "reversed", "seamless", "selected"];
@@ -194,6 +194,9 @@ function dynamicProperty(props, key) {
194
194
  });
195
195
  return props;
196
196
  }
197
+ function innerHTML(parent, content) {
198
+ !sharedConfig.context && (parent.innerHTML = content);
199
+ }
197
200
  function insert(parent, accessor, marker, initial) {
198
201
  if (marker !== undefined && !initial) initial = [];
199
202
  if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
@@ -386,28 +389,24 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
386
389
  return current;
387
390
  }
388
391
  if (array.length === 0) {
389
- current = cleanChildren(parent, current, marker);
390
- if (multi) return current;
392
+ cleanChildren(parent, current, marker);
393
+ } else if (Array.isArray(current)) {
394
+ if (current.length === 0) {
395
+ appendNodes(parent, array, marker);
396
+ } else reconcileArrays(parent, current, array);
391
397
  } else {
392
- if (Array.isArray(current)) {
393
- if (current.length === 0) {
394
- appendNodes(parent, array, marker);
395
- } else reconcileArrays(parent, current, array);
396
- } else if (current == null || current === "") {
397
- appendNodes(parent, array);
398
- } else {
399
- reconcileArrays(parent, multi && current || [parent.firstChild], array);
400
- }
398
+ current && cleanChildren(parent);
399
+ appendNodes(parent, array);
401
400
  }
402
401
  current = array;
403
402
  } else if (value instanceof Node) {
404
- if (sharedConfig.context) return current = value.parentNode ? value : current;
403
+ if (sharedConfig.context) return current = value.parentNode ? multi ? [value] : value : current;
405
404
  if (Array.isArray(current)) {
406
405
  if (multi) return current = cleanChildren(parent, current, marker, value);
407
406
  cleanChildren(parent, current, null, value);
408
407
  } else if (current == null || current === "" || !parent.firstChild) {
409
408
  parent.appendChild(value);
410
- } else parent.replaceChild(value, multi ? current : parent.firstChild);
409
+ } else parent.replaceChild(value, parent.firstChild);
411
410
  current = value;
412
411
  } else console.warn(`Unrecognized value. Skipped inserting`, value);
413
412
  return current;
@@ -450,7 +449,7 @@ function cleanChildren(parent, current, marker, replacement) {
450
449
  if (!inserted && !i) isParent ? parent.replaceChild(node, el) : parent.insertBefore(node, marker);else isParent && el.remove();
451
450
  } else inserted = true;
452
451
  }
453
- } else if (current instanceof Node) parent.replaceChild(node, current);else parent.insertBefore(node, marker);
452
+ } else parent.insertBefore(node, marker);
454
453
  return [node];
455
454
  }
456
455
  function gatherHydratable(element, root) {
@@ -537,6 +536,9 @@ function Dynamic(props) {
537
536
  const component = p.component;
538
537
  switch (typeof component) {
539
538
  case "function":
539
+ Object.assign(component, {
540
+ [$DEVCOMP]: true
541
+ });
540
542
  return untrack(() => component(others));
541
543
  case "string":
542
544
  const isSvg = SVGElements.has(component);
@@ -547,4 +549,4 @@ function Dynamic(props) {
547
549
  });
548
550
  }
549
551
 
550
- export { Aliases, Assets, ChildProperties, DelegatedEvents, Dynamic, Assets as HydrationScript, NoHydration, Portal, PropAliases, Properties, SVGElements, SVGNamespace, addEventListener, assign, classList, clearDelegatedEvents, delegateEvents, dynamicProperty, escape, generateHydrationScript, getHydrationKey, getNextElement, getNextMarker, getNextMatch, hydrate, insert, isServer, memo, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, spread, ssr, ssrBoolean, ssrClassList, ssrHydrationKey, ssrSpread, ssrStyle, style, template };
552
+ export { Aliases, Assets, ChildProperties, DelegatedEvents, Dynamic, Assets as HydrationScript, NoHydration, Portal, PropAliases, Properties, SVGElements, SVGNamespace, addEventListener, assign, classList, clearDelegatedEvents, delegateEvents, dynamicProperty, escape, generateHydrationScript, getHydrationKey, getNextElement, getNextMarker, getNextMatch, hydrate, innerHTML, insert, isServer, memo, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, spread, ssr, ssrBoolean, ssrClassList, ssrHydrationKey, ssrSpread, ssrStyle, style, template };
@@ -232,7 +232,7 @@ function stringifyString(str) {
232
232
  return result;
233
233
  }
234
234
 
235
- const REPLACE_SCRIPT = `function $df(e,y,t){t=document.getElementById(e),document.getElementById("pl"+e).replaceWith(...t.childNodes),_$HY.set(e,y||null)}`;
235
+ const REPLACE_SCRIPT = `function $df(e,y,t,g){t=document.getElementById(e),g=document.getElementById("pl"+e),g&&g.replaceWith(...t.childNodes),_$HY.set(e,y||null)}`;
236
236
  const FRAGMENT_REPLACE = /<!\[([\d.]+)\]>/;
237
237
  function renderToString(code, options = {}) {
238
238
  let scripts = "";
@@ -322,12 +322,17 @@ function renderToStream(code, options = {}) {
322
322
  const dedupe = new WeakMap();
323
323
  const checkEnd = () => {
324
324
  if (!registry.size && !completed) {
325
- onCompleteAll && onCompleteAll(result);
325
+ writeTasks();
326
+ onCompleteAll && onCompleteAll({
327
+ write(v) {
328
+ !completed && buffer.write(v);
329
+ }
330
+ });
326
331
  writable && writable.end();
327
332
  completed = true;
328
333
  }
329
334
  };
330
- const writeInitialScript = () => {
335
+ const writeTasks = () => {
331
336
  if (tasks.length && !completed) {
332
337
  buffer.write(`<script${nonce ? ` nonce="${nonce}"` : ""}>${tasks.join(";")}</script>`);
333
338
  tasks.length = 0;
@@ -354,7 +359,7 @@ function renderToStream(code, options = {}) {
354
359
  nonce,
355
360
  writeResource(id, p, error) {
356
361
  if (!scheduled) {
357
- Promise.resolve().then(writeInitialScript);
362
+ Promise.resolve().then(writeTasks);
358
363
  scheduled = true;
359
364
  }
360
365
  if (error) return tasks.push(`_$HY.set("${id}", ${serializeError(p)})`);
@@ -369,17 +374,19 @@ function renderToStream(code, options = {}) {
369
374
  registerFragment(key) {
370
375
  registry.set(key, []);
371
376
  if (!scheduled) {
372
- Promise.resolve().then(writeInitialScript);
377
+ Promise.resolve().then(writeTasks);
373
378
  scheduled = true;
374
379
  }
375
380
  tasks.push(`_$HY.init("${key}")`);
376
381
  return (value, error) => {
377
- const keys = registry.get(key);
378
- registry.delete(key);
379
- if (waitForFragments(registry, key)) return;
380
- if ((value !== undefined || error) && !completed) {
381
- buffer.write(`<div hidden id="${key}">${value !== undefined ? value : " "}</div><script${nonce ? ` nonce="${nonce}"` : ""}>${!scriptFlushed ? REPLACE_SCRIPT : ""}${keys.length ? keys.map(k => `_$HY.unset("${k}");`) : ""}$df("${key}"${error ? "," + serializeError(error) : ""})</script>`);
382
- scriptFlushed = true;
382
+ if (registry.has(key)) {
383
+ const keys = registry.get(key);
384
+ registry.delete(key);
385
+ if (waitForFragments(registry, key)) return;
386
+ if ((value !== undefined || error) && !completed) {
387
+ buffer.write(`<div hidden id="${key}">${value !== undefined ? value : " "}</div><script${nonce ? ` nonce="${nonce}"` : ""}>${!scriptFlushed ? REPLACE_SCRIPT : ""}${keys.length ? keys.map(k => `_$HY.unset("${k}");`) : ""}$df("${key}"${error ? "," + serializeError(error) : ""})</script>`);
388
+ scriptFlushed = true;
389
+ }
383
390
  }
384
391
  checkEnd();
385
392
  return true;
@@ -393,7 +400,11 @@ function renderToStream(code, options = {}) {
393
400
  buffer.write(html);
394
401
  tasks.length = 0;
395
402
  scheduled = false;
396
- onCompleteShell && onCompleteShell();
403
+ onCompleteShell && onCompleteShell({
404
+ write(v) {
405
+ !completed && buffer.write(v);
406
+ }
407
+ });
397
408
  });
398
409
  return {
399
410
  pipe(w) {
@@ -612,8 +623,11 @@ function serializeSet(registry, key, value) {
612
623
  }
613
624
  function pipeToNodeWritable(code, writable, options = {}) {
614
625
  if (options.onReady) {
615
- options.onCompleteShell = () => {
626
+ options.onCompleteShell = ({
627
+ write
628
+ }) => {
616
629
  options.onReady({
630
+ write,
617
631
  startWriting() {
618
632
  stream.pipe(writable);
619
633
  }
@@ -625,8 +639,11 @@ function pipeToNodeWritable(code, writable, options = {}) {
625
639
  }
626
640
  function pipeToWritable(code, writable, options = {}) {
627
641
  if (options.onReady) {
628
- options.onCompleteShell = () => {
642
+ options.onCompleteShell = ({
643
+ write
644
+ }) => {
629
645
  options.onReady({
646
+ write,
630
647
  startWriting() {
631
648
  stream.pipeTo(writable);
632
649
  }
@@ -229,7 +229,7 @@ function stringifyString(str) {
229
229
  return result;
230
230
  }
231
231
 
232
- const REPLACE_SCRIPT = `function $df(e,y,t){t=document.getElementById(e),document.getElementById("pl"+e).replaceWith(...t.childNodes),_$HY.set(e,y||null)}`;
232
+ const REPLACE_SCRIPT = `function $df(e,y,t,g){t=document.getElementById(e),g=document.getElementById("pl"+e),g&&g.replaceWith(...t.childNodes),_$HY.set(e,y||null)}`;
233
233
  const FRAGMENT_REPLACE = /<!\[([\d.]+)\]>/;
234
234
  function renderToString(code, options = {}) {
235
235
  let scripts = "";
@@ -319,12 +319,17 @@ function renderToStream(code, options = {}) {
319
319
  const dedupe = new WeakMap();
320
320
  const checkEnd = () => {
321
321
  if (!registry.size && !completed) {
322
- onCompleteAll && onCompleteAll(result);
322
+ writeTasks();
323
+ onCompleteAll && onCompleteAll({
324
+ write(v) {
325
+ !completed && buffer.write(v);
326
+ }
327
+ });
323
328
  writable && writable.end();
324
329
  completed = true;
325
330
  }
326
331
  };
327
- const writeInitialScript = () => {
332
+ const writeTasks = () => {
328
333
  if (tasks.length && !completed) {
329
334
  buffer.write(`<script${nonce ? ` nonce="${nonce}"` : ""}>${tasks.join(";")}</script>`);
330
335
  tasks.length = 0;
@@ -351,7 +356,7 @@ function renderToStream(code, options = {}) {
351
356
  nonce,
352
357
  writeResource(id, p, error) {
353
358
  if (!scheduled) {
354
- Promise.resolve().then(writeInitialScript);
359
+ Promise.resolve().then(writeTasks);
355
360
  scheduled = true;
356
361
  }
357
362
  if (error) return tasks.push(`_$HY.set("${id}", ${serializeError(p)})`);
@@ -366,17 +371,19 @@ function renderToStream(code, options = {}) {
366
371
  registerFragment(key) {
367
372
  registry.set(key, []);
368
373
  if (!scheduled) {
369
- Promise.resolve().then(writeInitialScript);
374
+ Promise.resolve().then(writeTasks);
370
375
  scheduled = true;
371
376
  }
372
377
  tasks.push(`_$HY.init("${key}")`);
373
378
  return (value, error) => {
374
- const keys = registry.get(key);
375
- registry.delete(key);
376
- if (waitForFragments(registry, key)) return;
377
- if ((value !== undefined || error) && !completed) {
378
- buffer.write(`<div hidden id="${key}">${value !== undefined ? value : " "}</div><script${nonce ? ` nonce="${nonce}"` : ""}>${!scriptFlushed ? REPLACE_SCRIPT : ""}${keys.length ? keys.map(k => `_$HY.unset("${k}");`) : ""}$df("${key}"${error ? "," + serializeError(error) : ""})</script>`);
379
- scriptFlushed = true;
379
+ if (registry.has(key)) {
380
+ const keys = registry.get(key);
381
+ registry.delete(key);
382
+ if (waitForFragments(registry, key)) return;
383
+ if ((value !== undefined || error) && !completed) {
384
+ buffer.write(`<div hidden id="${key}">${value !== undefined ? value : " "}</div><script${nonce ? ` nonce="${nonce}"` : ""}>${!scriptFlushed ? REPLACE_SCRIPT : ""}${keys.length ? keys.map(k => `_$HY.unset("${k}");`) : ""}$df("${key}"${error ? "," + serializeError(error) : ""})</script>`);
385
+ scriptFlushed = true;
386
+ }
380
387
  }
381
388
  checkEnd();
382
389
  return true;
@@ -390,7 +397,11 @@ function renderToStream(code, options = {}) {
390
397
  buffer.write(html);
391
398
  tasks.length = 0;
392
399
  scheduled = false;
393
- onCompleteShell && onCompleteShell();
400
+ onCompleteShell && onCompleteShell({
401
+ write(v) {
402
+ !completed && buffer.write(v);
403
+ }
404
+ });
394
405
  });
395
406
  return {
396
407
  pipe(w) {
@@ -609,8 +620,11 @@ function serializeSet(registry, key, value) {
609
620
  }
610
621
  function pipeToNodeWritable(code, writable, options = {}) {
611
622
  if (options.onReady) {
612
- options.onCompleteShell = () => {
623
+ options.onCompleteShell = ({
624
+ write
625
+ }) => {
613
626
  options.onReady({
627
+ write,
614
628
  startWriting() {
615
629
  stream.pipe(writable);
616
630
  }
@@ -622,8 +636,11 @@ function pipeToNodeWritable(code, writable, options = {}) {
622
636
  }
623
637
  function pipeToWritable(code, writable, options = {}) {
624
638
  if (options.onReady) {
625
- options.onCompleteShell = () => {
639
+ options.onCompleteShell = ({
640
+ write
641
+ }) => {
626
642
  options.onReady({
643
+ write,
627
644
  startWriting() {
628
645
  stream.pipeTo(writable);
629
646
  }
package/web/dist/web.cjs CHANGED
@@ -196,6 +196,9 @@ function dynamicProperty(props, key) {
196
196
  });
197
197
  return props;
198
198
  }
199
+ function innerHTML(parent, content) {
200
+ !solidJs.sharedConfig.context && (parent.innerHTML = content);
201
+ }
199
202
  function insert(parent, accessor, marker, initial) {
200
203
  if (marker !== undefined && !initial) initial = [];
201
204
  if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
@@ -388,28 +391,24 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
388
391
  return current;
389
392
  }
390
393
  if (array.length === 0) {
391
- current = cleanChildren(parent, current, marker);
392
- if (multi) return current;
394
+ cleanChildren(parent, current, marker);
395
+ } else if (Array.isArray(current)) {
396
+ if (current.length === 0) {
397
+ appendNodes(parent, array, marker);
398
+ } else reconcileArrays(parent, current, array);
393
399
  } else {
394
- if (Array.isArray(current)) {
395
- if (current.length === 0) {
396
- appendNodes(parent, array, marker);
397
- } else reconcileArrays(parent, current, array);
398
- } else if (current == null || current === "") {
399
- appendNodes(parent, array);
400
- } else {
401
- reconcileArrays(parent, multi && current || [parent.firstChild], array);
402
- }
400
+ current && cleanChildren(parent);
401
+ appendNodes(parent, array);
403
402
  }
404
403
  current = array;
405
404
  } else if (value instanceof Node) {
406
- if (solidJs.sharedConfig.context) return current = value.parentNode ? value : current;
405
+ if (solidJs.sharedConfig.context) return current = value.parentNode ? multi ? [value] : value : current;
407
406
  if (Array.isArray(current)) {
408
407
  if (multi) return current = cleanChildren(parent, current, marker, value);
409
408
  cleanChildren(parent, current, null, value);
410
409
  } else if (current == null || current === "" || !parent.firstChild) {
411
410
  parent.appendChild(value);
412
- } else parent.replaceChild(value, multi ? current : parent.firstChild);
411
+ } else parent.replaceChild(value, parent.firstChild);
413
412
  current = value;
414
413
  } else ;
415
414
  return current;
@@ -452,7 +451,7 @@ function cleanChildren(parent, current, marker, replacement) {
452
451
  if (!inserted && !i) isParent ? parent.replaceChild(node, el) : parent.insertBefore(node, marker);else isParent && el.remove();
453
452
  } else inserted = true;
454
453
  }
455
- } else if (current instanceof Node) parent.replaceChild(node, current);else parent.insertBefore(node, marker);
454
+ } else parent.insertBefore(node, marker);
456
455
  return [node];
457
456
  }
458
457
  function gatherHydratable(element, root) {
@@ -622,6 +621,7 @@ exports.getNextElement = getNextElement;
622
621
  exports.getNextMarker = getNextMarker;
623
622
  exports.getNextMatch = getNextMatch;
624
623
  exports.hydrate = hydrate;
624
+ exports.innerHTML = innerHTML;
625
625
  exports.insert = insert;
626
626
  exports.isServer = isServer;
627
627
  exports.memo = memo;
package/web/dist/web.js CHANGED
@@ -193,6 +193,9 @@ function dynamicProperty(props, key) {
193
193
  });
194
194
  return props;
195
195
  }
196
+ function innerHTML(parent, content) {
197
+ !sharedConfig.context && (parent.innerHTML = content);
198
+ }
196
199
  function insert(parent, accessor, marker, initial) {
197
200
  if (marker !== undefined && !initial) initial = [];
198
201
  if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
@@ -385,28 +388,24 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
385
388
  return current;
386
389
  }
387
390
  if (array.length === 0) {
388
- current = cleanChildren(parent, current, marker);
389
- if (multi) return current;
391
+ cleanChildren(parent, current, marker);
392
+ } else if (Array.isArray(current)) {
393
+ if (current.length === 0) {
394
+ appendNodes(parent, array, marker);
395
+ } else reconcileArrays(parent, current, array);
390
396
  } else {
391
- if (Array.isArray(current)) {
392
- if (current.length === 0) {
393
- appendNodes(parent, array, marker);
394
- } else reconcileArrays(parent, current, array);
395
- } else if (current == null || current === "") {
396
- appendNodes(parent, array);
397
- } else {
398
- reconcileArrays(parent, multi && current || [parent.firstChild], array);
399
- }
397
+ current && cleanChildren(parent);
398
+ appendNodes(parent, array);
400
399
  }
401
400
  current = array;
402
401
  } else if (value instanceof Node) {
403
- if (sharedConfig.context) return current = value.parentNode ? value : current;
402
+ if (sharedConfig.context) return current = value.parentNode ? multi ? [value] : value : current;
404
403
  if (Array.isArray(current)) {
405
404
  if (multi) return current = cleanChildren(parent, current, marker, value);
406
405
  cleanChildren(parent, current, null, value);
407
406
  } else if (current == null || current === "" || !parent.firstChild) {
408
407
  parent.appendChild(value);
409
- } else parent.replaceChild(value, multi ? current : parent.firstChild);
408
+ } else parent.replaceChild(value, parent.firstChild);
410
409
  current = value;
411
410
  } else ;
412
411
  return current;
@@ -449,7 +448,7 @@ function cleanChildren(parent, current, marker, replacement) {
449
448
  if (!inserted && !i) isParent ? parent.replaceChild(node, el) : parent.insertBefore(node, marker);else isParent && el.remove();
450
449
  } else inserted = true;
451
450
  }
452
- } else if (current instanceof Node) parent.replaceChild(node, current);else parent.insertBefore(node, marker);
451
+ } else parent.insertBefore(node, marker);
453
452
  return [node];
454
453
  }
455
454
  function gatherHydratable(element, root) {
@@ -546,4 +545,4 @@ function Dynamic(props) {
546
545
  });
547
546
  }
548
547
 
549
- export { Aliases, Assets, ChildProperties, DelegatedEvents, Dynamic, Assets as HydrationScript, NoHydration, Portal, PropAliases, Properties, SVGElements, SVGNamespace, addEventListener, assign, classList, clearDelegatedEvents, delegateEvents, dynamicProperty, escape, generateHydrationScript, getHydrationKey, getNextElement, getNextMarker, getNextMatch, hydrate, insert, isServer, memo, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, spread, ssr, ssrBoolean, ssrClassList, ssrHydrationKey, ssrSpread, ssrStyle, style, template };
548
+ export { Aliases, Assets, ChildProperties, DelegatedEvents, Dynamic, Assets as HydrationScript, NoHydration, Portal, PropAliases, Properties, SVGElements, SVGNamespace, addEventListener, assign, classList, clearDelegatedEvents, delegateEvents, dynamicProperty, escape, generateHydrationScript, getHydrationKey, getNextElement, getNextMarker, getNextMatch, hydrate, innerHTML, insert, isServer, memo, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, spread, ssr, ssrBoolean, ssrClassList, ssrHydrationKey, ssrSpread, ssrStyle, style, template };
package/web/package.json CHANGED
@@ -9,5 +9,27 @@
9
9
  "unpkg": "./dist/web.cjs",
10
10
  "types": "./types/index.d.ts",
11
11
  "type": "module",
12
- "sideEffects": false
12
+ "sideEffects": false,
13
+ "exports": {
14
+ ".": {
15
+ "browser": {
16
+ "development": {
17
+ "import": "./dist/dev.js",
18
+ "require": "./dist/dev.cjs"
19
+ },
20
+ "import": "./dist/web.js",
21
+ "require": "./dist/web.cjs"
22
+ },
23
+ "node": {
24
+ "import": "./dist/server.js",
25
+ "require": "./dist/server.cjs"
26
+ },
27
+ "development": {
28
+ "import": "./dist/dev.js",
29
+ "require": "./dist/dev.cjs"
30
+ },
31
+ "import": "./dist/web.js",
32
+ "require": "./dist/web.cjs"
33
+ }
34
+ }
13
35
  }
@@ -30,6 +30,7 @@ export function spread<T>(
30
30
  export function assign(node: Element, props: any, isSVG?: Boolean, skipChildren?: Boolean): void;
31
31
  export function setAttribute(node: Element, name: string, value: string): void;
32
32
  export function setAttributeNS(node: Element, namespace: string, name: string, value: string): void;
33
+ export function innerHTML(node: Element, content: string): void;
33
34
  export function addEventListener(
34
35
  node: Element,
35
36
  name: string,