solid-js 1.3.3 → 1.3.4

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
@@ -1313,7 +1313,6 @@ function lazy(fn) {
1313
1313
  const wrap = props => {
1314
1314
  const ctx = sharedConfig.context;
1315
1315
  if (ctx) {
1316
- ctx.count++;
1317
1316
  const [s, set] = createSignal();
1318
1317
  (p || (p = fn())).then(mod => {
1319
1318
  setHydrateContext(ctx);
@@ -1402,12 +1401,19 @@ function Switch(props) {
1402
1401
  function Match(props) {
1403
1402
  return props;
1404
1403
  }
1404
+ let Errors;
1405
+ function resetErrorBoundaries() {
1406
+ Errors && [...Errors].forEach(fn => fn());
1407
+ }
1405
1408
  function ErrorBoundary(props) {
1406
1409
  let err = undefined;
1407
1410
  if (sharedConfig.context && sharedConfig.load) {
1408
1411
  err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
1409
1412
  }
1410
1413
  const [errored, setErrored] = createSignal(err);
1414
+ Errors || (Errors = new Set());
1415
+ Errors.add(setErrored);
1416
+ onCleanup(() => Errors.delete(setErrored));
1411
1417
  let e;
1412
1418
  return createMemo(() => {
1413
1419
  if ((e = errored()) != null) {
@@ -1627,6 +1633,7 @@ exports.onError = onError;
1627
1633
  exports.onMount = onMount;
1628
1634
  exports.refetchResources = refetchResources;
1629
1635
  exports.requestCallback = requestCallback;
1636
+ exports.resetErrorBoundaries = resetErrorBoundaries;
1630
1637
  exports.runWithOwner = runWithOwner;
1631
1638
  exports.sharedConfig = sharedConfig;
1632
1639
  exports.splitProps = splitProps;
package/dist/dev.js CHANGED
@@ -1309,7 +1309,6 @@ function lazy(fn) {
1309
1309
  const wrap = props => {
1310
1310
  const ctx = sharedConfig.context;
1311
1311
  if (ctx) {
1312
- ctx.count++;
1313
1312
  const [s, set] = createSignal();
1314
1313
  (p || (p = fn())).then(mod => {
1315
1314
  setHydrateContext(ctx);
@@ -1398,12 +1397,19 @@ function Switch(props) {
1398
1397
  function Match(props) {
1399
1398
  return props;
1400
1399
  }
1400
+ let Errors;
1401
+ function resetErrorBoundaries() {
1402
+ Errors && [...Errors].forEach(fn => fn());
1403
+ }
1401
1404
  function ErrorBoundary(props) {
1402
1405
  let err = undefined;
1403
1406
  if (sharedConfig.context && sharedConfig.load) {
1404
1407
  err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
1405
1408
  }
1406
1409
  const [errored, setErrored] = createSignal(err);
1410
+ Errors || (Errors = new Set());
1411
+ Errors.add(setErrored);
1412
+ onCleanup(() => Errors.delete(setErrored));
1407
1413
  let e;
1408
1414
  return createMemo(() => {
1409
1415
  if ((e = errored()) != null) {
@@ -1579,4 +1585,4 @@ if (globalThis) {
1579
1585
  if (!globalThis.Solid$$) globalThis.Solid$$ = true;else console.warn("You appear to have multiple instances of Solid. This can lead to unexpected behavior.");
1580
1586
  }
1581
1587
 
1582
- 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 };
1588
+ 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
@@ -349,7 +349,7 @@ function createResource(fn, fetcher, options = {}) {
349
349
  if (sharedConfig.context.async) {
350
350
  resource = sharedConfig.context.resources[id] || (sharedConfig.context.resources[id] = {});
351
351
  if (resource.ref) {
352
- if (!resource.data && !resource.ref[0].loading) resource.ref[1].refetch();
352
+ if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error) resource.ref[1].refetch();
353
353
  return resource.ref;
354
354
  }
355
355
  }
@@ -367,6 +367,7 @@ function createResource(fn, fetcher, options = {}) {
367
367
  return resolved ? sharedConfig.context.resources[id].data : value;
368
368
  };
369
369
  read.loading = false;
370
+ read.error = undefined;
370
371
  function load() {
371
372
  const ctx = sharedConfig.context;
372
373
  if (!ctx.async) return read.loading = !!(typeof fn === "function" ? fn() : fn);
@@ -395,7 +396,7 @@ function createResource(fn, fetcher, options = {}) {
395
396
  return res;
396
397
  }).catch(err => {
397
398
  read.loading = false;
398
- error = err;
399
+ read.error = error = err;
399
400
  p = null;
400
401
  notifySuspense(contexts);
401
402
  });
@@ -416,11 +417,12 @@ function lazy(fn) {
416
417
  const contexts = new Set();
417
418
  p.then(mod => resolved = mod.default);
418
419
  const wrap = props => {
419
- const id = sharedConfig.context.id + sharedConfig.context.count++;
420
+ const id = sharedConfig.context.id.slice(0, -1);
420
421
  if (resolved) return resolved(props);
421
422
  const ctx = useContext(SuspenseContext);
422
423
  const track = {
423
- loading: true
424
+ loading: true,
425
+ error: undefined
424
426
  };
425
427
  if (ctx) {
426
428
  ctx.resources.set(id, track);
package/dist/server.js CHANGED
@@ -345,7 +345,7 @@ function createResource(fn, fetcher, options = {}) {
345
345
  if (sharedConfig.context.async) {
346
346
  resource = sharedConfig.context.resources[id] || (sharedConfig.context.resources[id] = {});
347
347
  if (resource.ref) {
348
- if (!resource.data && !resource.ref[0].loading) resource.ref[1].refetch();
348
+ if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error) resource.ref[1].refetch();
349
349
  return resource.ref;
350
350
  }
351
351
  }
@@ -363,6 +363,7 @@ function createResource(fn, fetcher, options = {}) {
363
363
  return resolved ? sharedConfig.context.resources[id].data : value;
364
364
  };
365
365
  read.loading = false;
366
+ read.error = undefined;
366
367
  function load() {
367
368
  const ctx = sharedConfig.context;
368
369
  if (!ctx.async) return read.loading = !!(typeof fn === "function" ? fn() : fn);
@@ -391,7 +392,7 @@ function createResource(fn, fetcher, options = {}) {
391
392
  return res;
392
393
  }).catch(err => {
393
394
  read.loading = false;
394
- error = err;
395
+ read.error = error = err;
395
396
  p = null;
396
397
  notifySuspense(contexts);
397
398
  });
@@ -412,11 +413,12 @@ function lazy(fn) {
412
413
  const contexts = new Set();
413
414
  p.then(mod => resolved = mod.default);
414
415
  const wrap = props => {
415
- const id = sharedConfig.context.id + sharedConfig.context.count++;
416
+ const id = sharedConfig.context.id.slice(0, -1);
416
417
  if (resolved) return resolved(props);
417
418
  const ctx = useContext(SuspenseContext);
418
419
  const track = {
419
- loading: true
420
+ loading: true,
421
+ error: undefined
420
422
  };
421
423
  if (ctx) {
422
424
  ctx.resources.set(id, track);
package/dist/solid.cjs CHANGED
@@ -1232,7 +1232,6 @@ function lazy(fn) {
1232
1232
  const wrap = props => {
1233
1233
  const ctx = sharedConfig.context;
1234
1234
  if (ctx) {
1235
- ctx.count++;
1236
1235
  const [s, set] = createSignal();
1237
1236
  (p || (p = fn())).then(mod => {
1238
1237
  setHydrateContext(ctx);
@@ -1318,12 +1317,19 @@ function Switch(props) {
1318
1317
  function Match(props) {
1319
1318
  return props;
1320
1319
  }
1320
+ let Errors;
1321
+ function resetErrorBoundaries() {
1322
+ Errors && [...Errors].forEach(fn => fn());
1323
+ }
1321
1324
  function ErrorBoundary(props) {
1322
1325
  let err = undefined;
1323
1326
  if (sharedConfig.context && sharedConfig.load) {
1324
1327
  err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
1325
1328
  }
1326
1329
  const [errored, setErrored] = createSignal(err);
1330
+ Errors || (Errors = new Set());
1331
+ Errors.add(setErrored);
1332
+ onCleanup(() => Errors.delete(setErrored));
1327
1333
  let e;
1328
1334
  return createMemo(() => {
1329
1335
  if ((e = errored()) != null) {
@@ -1533,6 +1539,7 @@ exports.onError = onError;
1533
1539
  exports.onMount = onMount;
1534
1540
  exports.refetchResources = refetchResources;
1535
1541
  exports.requestCallback = requestCallback;
1542
+ exports.resetErrorBoundaries = resetErrorBoundaries;
1536
1543
  exports.runWithOwner = runWithOwner;
1537
1544
  exports.sharedConfig = sharedConfig;
1538
1545
  exports.splitProps = splitProps;
package/dist/solid.js CHANGED
@@ -1228,7 +1228,6 @@ function lazy(fn) {
1228
1228
  const wrap = props => {
1229
1229
  const ctx = sharedConfig.context;
1230
1230
  if (ctx) {
1231
- ctx.count++;
1232
1231
  const [s, set] = createSignal();
1233
1232
  (p || (p = fn())).then(mod => {
1234
1233
  setHydrateContext(ctx);
@@ -1314,12 +1313,19 @@ function Switch(props) {
1314
1313
  function Match(props) {
1315
1314
  return props;
1316
1315
  }
1316
+ let Errors;
1317
+ function resetErrorBoundaries() {
1318
+ Errors && [...Errors].forEach(fn => fn());
1319
+ }
1317
1320
  function ErrorBoundary(props) {
1318
1321
  let err = undefined;
1319
1322
  if (sharedConfig.context && sharedConfig.load) {
1320
1323
  err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
1321
1324
  }
1322
1325
  const [errored, setErrored] = createSignal(err);
1326
+ Errors || (Errors = new Set());
1327
+ Errors.add(setErrored);
1328
+ onCleanup(() => Errors.delete(setErrored));
1323
1329
  let e;
1324
1330
  return createMemo(() => {
1325
1331
  if ((e = errored()) != null) {
@@ -1484,4 +1490,4 @@ function Suspense(props) {
1484
1490
 
1485
1491
  let DEV;
1486
1492
 
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 };
1493
+ 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.3",
4
+ "version": "1.3.4",
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": "58f98c55a3573b23f683978c8828bbda563ae666"
147
+ "gitHead": "4c08b520a8cb3ed03886fba160154a679dfab8a6"
148
148
  }
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";
@@ -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
  *
@@ -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
  };
@@ -322,12 +322,13 @@ function renderToStream(code, options = {}) {
322
322
  const dedupe = new WeakMap();
323
323
  const checkEnd = () => {
324
324
  if (!registry.size && !completed) {
325
+ writeTasks();
325
326
  onCompleteAll && onCompleteAll(result);
326
327
  writable && writable.end();
327
328
  completed = true;
328
329
  }
329
330
  };
330
- const writeInitialScript = () => {
331
+ const writeTasks = () => {
331
332
  if (tasks.length && !completed) {
332
333
  buffer.write(`<script${nonce ? ` nonce="${nonce}"` : ""}>${tasks.join(";")}</script>`);
333
334
  tasks.length = 0;
@@ -354,7 +355,7 @@ function renderToStream(code, options = {}) {
354
355
  nonce,
355
356
  writeResource(id, p, error) {
356
357
  if (!scheduled) {
357
- Promise.resolve().then(writeInitialScript);
358
+ Promise.resolve().then(writeTasks);
358
359
  scheduled = true;
359
360
  }
360
361
  if (error) return tasks.push(`_$HY.set("${id}", ${serializeError(p)})`);
@@ -369,7 +370,7 @@ function renderToStream(code, options = {}) {
369
370
  registerFragment(key) {
370
371
  registry.set(key, []);
371
372
  if (!scheduled) {
372
- Promise.resolve().then(writeInitialScript);
373
+ Promise.resolve().then(writeTasks);
373
374
  scheduled = true;
374
375
  }
375
376
  tasks.push(`_$HY.init("${key}")`);
@@ -319,12 +319,13 @@ function renderToStream(code, options = {}) {
319
319
  const dedupe = new WeakMap();
320
320
  const checkEnd = () => {
321
321
  if (!registry.size && !completed) {
322
+ writeTasks();
322
323
  onCompleteAll && onCompleteAll(result);
323
324
  writable && writable.end();
324
325
  completed = true;
325
326
  }
326
327
  };
327
- const writeInitialScript = () => {
328
+ const writeTasks = () => {
328
329
  if (tasks.length && !completed) {
329
330
  buffer.write(`<script${nonce ? ` nonce="${nonce}"` : ""}>${tasks.join(";")}</script>`);
330
331
  tasks.length = 0;
@@ -351,7 +352,7 @@ function renderToStream(code, options = {}) {
351
352
  nonce,
352
353
  writeResource(id, p, error) {
353
354
  if (!scheduled) {
354
- Promise.resolve().then(writeInitialScript);
355
+ Promise.resolve().then(writeTasks);
355
356
  scheduled = true;
356
357
  }
357
358
  if (error) return tasks.push(`_$HY.set("${id}", ${serializeError(p)})`);
@@ -366,7 +367,7 @@ function renderToStream(code, options = {}) {
366
367
  registerFragment(key) {
367
368
  registry.set(key, []);
368
369
  if (!scheduled) {
369
- Promise.resolve().then(writeInitialScript);
370
+ Promise.resolve().then(writeTasks);
370
371
  scheduled = true;
371
372
  }
372
373
  tasks.push(`_$HY.init("${key}")`);