solid-js 2.0.0-beta.4 → 2.0.0-beta.5

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.
@@ -1,5 +1,8 @@
1
1
  import type { Accessor } from "@solidjs/signals";
2
2
  import type { JSX } from "../jsx.js";
3
+ type NonZeroParams<T extends (...args: any[]) => any> = Parameters<T>["length"] extends 0 ? never : T;
4
+ type ConditionalRenderCallback<T> = (item: Accessor<NonNullable<T>>) => JSX.Element;
5
+ type ConditionalRenderChildren<T, F extends ConditionalRenderCallback<T> = ConditionalRenderCallback<T>> = JSX.Element | NonZeroParams<F>;
3
6
  /**
4
7
  * Creates a list of elements from a list
5
8
  *
@@ -40,11 +43,11 @@ export declare function Repeat<T extends JSX.Element>(props: {
40
43
  * Conditionally render its children or an optional fallback component
41
44
  * @description https://docs.solidjs.com/reference/components/show
42
45
  */
43
- export declare function Show<T>(props: {
46
+ export declare function Show<T, F extends ConditionalRenderCallback<T>>(props: {
44
47
  when: T | undefined | null | false;
45
48
  keyed?: boolean;
46
49
  fallback?: JSX.Element;
47
- children: JSX.Element | ((item: Accessor<NonNullable<T>>) => JSX.Element);
50
+ children: ConditionalRenderChildren<T, F>;
48
51
  }): JSX.Element;
49
52
  /**
50
53
  * Switches between content based on mutually exclusive conditions
@@ -64,10 +67,10 @@ export declare function Switch(props: {
64
67
  fallback?: JSX.Element;
65
68
  children: JSX.Element;
66
69
  }): JSX.Element;
67
- export type MatchProps<T> = {
70
+ export type MatchProps<T, F extends ConditionalRenderCallback<T> = ConditionalRenderCallback<T>> = {
68
71
  when: T | undefined | null | false;
69
72
  keyed?: boolean;
70
- children: JSX.Element | ((item: Accessor<NonNullable<T>>) => JSX.Element);
73
+ children: ConditionalRenderChildren<T, F>;
71
74
  };
72
75
  /**
73
76
  * Selects a content based on condition when inside a `<Switch>` control flow
@@ -78,7 +81,7 @@ export type MatchProps<T> = {
78
81
  * ```
79
82
  * @description https://docs.solidjs.com/reference/components/switch-and-match
80
83
  */
81
- export declare function Match<T>(props: MatchProps<T>): JSX.Element;
84
+ export declare function Match<T, F extends ConditionalRenderCallback<T>>(props: MatchProps<T, F>): JSX.Element;
82
85
  /**
83
86
  * Catches uncaught errors inside components and renders a fallback content
84
87
  *
@@ -98,3 +101,20 @@ export declare function Errored(props: {
98
101
  fallback: JSX.Element | ((err: any, reset: () => void) => JSX.Element);
99
102
  children: JSX.Element;
100
103
  }): JSX.Element;
104
+ /**
105
+ * Tracks all resources inside a component and renders a fallback until they are all resolved
106
+ * ```typescript
107
+ * const AsyncComponent = lazy(() => import('./component'));
108
+ *
109
+ * <Loading fallback={<LoadingIndicator />}>
110
+ * <AsyncComponent />
111
+ * </Loading>
112
+ * ```
113
+ * @description https://docs.solidjs.com/reference/components/suspense
114
+ */
115
+ export declare function Loading(props: {
116
+ fallback?: JSX.Element;
117
+ on?: any;
118
+ children: JSX.Element;
119
+ }): JSX.Element;
120
+ export {};
@@ -1,17 +1,15 @@
1
1
  import { createErrorBoundary as coreErrorBoundary, createMemo as coreMemo, createSignal as coreSignal, createOptimistic as coreOptimistic, createRenderEffect as coreRenderEffect, createEffect as coreEffect, $REFRESH, type ProjectionOptions, type Store, type StoreSetter, type Context } from "@solidjs/signals";
2
2
  import { JSX } from "../jsx.js";
3
+ type HydrationSsrFields = {
4
+ deferStream?: boolean;
5
+ ssrSource?: "server" | "hybrid" | "initial" | "client";
6
+ };
3
7
  declare module "@solidjs/signals" {
4
- interface MemoOptions<T> {
5
- deferStream?: boolean;
6
- ssrSource?: "server" | "hybrid" | "initial" | "client";
8
+ interface MemoOptions<T> extends HydrationSsrFields {
7
9
  }
8
- interface SignalOptions<T> {
9
- deferStream?: boolean;
10
- ssrSource?: "server" | "hybrid" | "initial" | "client";
10
+ interface SignalOptions<T> extends HydrationSsrFields {
11
11
  }
12
- interface EffectOptions {
13
- deferStream?: boolean;
14
- ssrSource?: "server" | "hybrid" | "initial" | "client";
12
+ interface EffectOptions extends HydrationSsrFields {
15
13
  }
16
14
  }
17
15
  export type HydrationProjectionOptions = ProjectionOptions & {
@@ -76,11 +74,9 @@ export declare const createEffect: typeof coreEffect;
76
74
  * ```
77
75
  * @description https://docs.solidjs.com/reference/components/suspense
78
76
  */
79
- export declare function Loading(props: {
80
- fallback?: JSX.Element;
77
+ export declare function createLoadingBoundary(fn: () => any, fallback: () => any, options?: {
81
78
  on?: () => any;
82
- children: JSX.Element;
83
- }): JSX.Element;
79
+ }): () => unknown;
84
80
  /**
85
81
  * Disables hydration for its children on the client.
86
82
  * During hydration, skips the subtree entirely (returns undefined so DOM is left untouched).
package/types/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- export { $PROXY, $REFRESH, $TRACK, action, createErrorBoundary, createLoadingBoundary, createOwner, createReaction, createRoot, createTrackedEffect, deep, flatten, flush, getNextChildId, getObserver, getOwner, isEqual, isRefreshing, isPending, isWrappable, mapArray, merge, omit, onCleanup, onSettled, latest, reconcile, refresh, repeat, resolve, NotReadyError, runWithOwner, enableExternalSource, enforceLoadingBoundary, snapshot, storePath, untrack } from "@solidjs/signals";
1
+ export { $PROXY, $REFRESH, $TRACK, action, createOwner, createReaction, createRoot, createTrackedEffect, deep, flatten, flush, getNextChildId, getObserver, getOwner, isEqual, isRefreshing, isPending, isWrappable, mapArray, merge, omit, onCleanup, onSettled, latest, reconcile, refresh, repeat, resolve, NotReadyError, runWithOwner, enableExternalSource, enforceLoadingBoundary, snapshot, storePath, untrack } from "@solidjs/signals";
2
2
  export type { Accessor, ComputeFunction, EffectFunction, EffectOptions, ExternalSource, ExternalSourceConfig, ExternalSourceFactory, Merge, NoInfer, NotWrappable, Omit, Owner, Signal, SignalOptions, Setter, Store, SolidStore, StoreNode, StoreSetter, StorePathRange, ArrayFilterFn, CustomPartial, Part, PathSetter } from "@solidjs/signals";
3
3
  export { $DEVCOMP, children, createContext, useContext } from "./client/core.js";
4
4
  export type { ChildrenReturn, Context, ContextProviderComponent, ResolvedChildren, ResolvedJSXElement } from "./client/core.js";
5
5
  export * from "./client/component.js";
6
6
  export * from "./client/flow.js";
7
- export { sharedConfig, Loading, enableHydration, createMemo, createSignal, createStore, createProjection, createOptimistic, createOptimisticStore, createRenderEffect, createEffect, NoHydration, Hydration, NoHydrateContext } from "./client/hydration.js";
7
+ export { sharedConfig, enableHydration, createErrorBoundary, createLoadingBoundary, createMemo, createSignal, createStore, createProjection, createOptimistic, createOptimisticStore, createRenderEffect, createEffect, NoHydration, Hydration, NoHydrateContext } from "./client/hydration.js";
8
8
  export declare function ssrHandleError(): void;
9
9
  export declare function ssrRunInScope(): void;
10
10
  import type { JSX } from "./jsx.js";
package/types/jsx.d.ts CHANGED
@@ -277,12 +277,16 @@ export namespace JSX {
277
277
 
278
278
  type BooleanAttribute = true | false | "";
279
279
 
280
+ type BooleanProperty = true | false;
281
+
280
282
  type EnumeratedPseudoBoolean = "false" | "true";
281
283
 
282
284
  type EnumeratedAcceptsEmpty = "" | true;
283
285
 
284
286
  type RemoveAttribute = undefined | false;
285
287
 
288
+ type RemoveProperty = undefined;
289
+
286
290
  // ARIA
287
291
 
288
292
  // All the WAI-ARIA 1.1 attributes from https://www.w3.org/TR/wai-aria-1.1/
@@ -1523,6 +1527,7 @@ export namespace JSX {
1523
1527
  autocomplete?: HTMLAutocomplete | RemoveAttribute;
1524
1528
  capture?: "user" | "environment" | RemoveAttribute;
1525
1529
  checked?: BooleanAttribute | RemoveAttribute;
1530
+ "prop:checked"?: BooleanProperty | RemoveProperty;
1526
1531
  colorspace?: string | RemoveAttribute;
1527
1532
  dirname?: string | RemoveAttribute;
1528
1533
  disabled?: BooleanAttribute | RemoveAttribute;
@@ -1577,6 +1582,7 @@ export namespace JSX {
1577
1582
  | (string & {})
1578
1583
  | RemoveAttribute;
1579
1584
  value?: string | string[] | number | RemoveAttribute;
1585
+ "prop:value"?: string | string[] | number | RemoveProperty;
1580
1586
  width?: number | string | RemoveAttribute;
1581
1587
 
1582
1588
  /** @non-standard */
@@ -1656,6 +1662,7 @@ export namespace JSX {
1656
1662
  disableremoteplayback?: BooleanAttribute | RemoveAttribute;
1657
1663
  loop?: BooleanAttribute | RemoveAttribute;
1658
1664
  muted?: BooleanAttribute | RemoveAttribute;
1665
+ "prop:muted"?: BooleanProperty | RemoveProperty;
1659
1666
  preload?: "none" | "metadata" | "auto" | EnumeratedAcceptsEmpty | RemoveAttribute;
1660
1667
  src?: string | RemoveAttribute;
1661
1668
 
@@ -1759,7 +1766,9 @@ export namespace JSX {
1759
1766
  disabled?: BooleanAttribute | RemoveAttribute;
1760
1767
  label?: string | RemoveAttribute;
1761
1768
  selected?: BooleanAttribute | RemoveAttribute;
1769
+ "prop:selected"?: BooleanProperty | RemoveProperty;
1762
1770
  value?: string | string[] | number | RemoveAttribute;
1771
+ "prop:value"?: string | string[] | number | RemoveProperty;
1763
1772
  }
1764
1773
  interface OutputHTMLAttributes<T> extends HTMLAttributes<T> {
1765
1774
  for?: string | RemoveAttribute;
@@ -1812,6 +1821,7 @@ export namespace JSX {
1812
1821
  required?: BooleanAttribute | RemoveAttribute;
1813
1822
  size?: number | string | RemoveAttribute;
1814
1823
  value?: string | string[] | number | RemoveAttribute;
1824
+ "prop:value"?: string | string[] | number | RemoveProperty;
1815
1825
  }
1816
1826
  interface HTMLSlotElementAttributes<T> extends HTMLAttributes<T> {
1817
1827
  name?: string | RemoveAttribute;
@@ -1886,6 +1896,7 @@ export namespace JSX {
1886
1896
  required?: BooleanAttribute | RemoveAttribute;
1887
1897
  rows?: number | string | RemoveAttribute;
1888
1898
  value?: string | string[] | number | RemoveAttribute;
1899
+ "prop:value"?: string | string[] | number | RemoveProperty;
1889
1900
  wrap?: "hard" | "soft" | "off" | RemoveAttribute;
1890
1901
  }
1891
1902
  interface ThHTMLAttributes<T> extends HTMLAttributes<T> {
@@ -1,5 +1,8 @@
1
1
  import type { Accessor } from "./signals.js";
2
2
  import type { JSX } from "../jsx.js";
3
+ type NonZeroParams<T extends (...args: any[]) => any> = Parameters<T>["length"] extends 0 ? never : T;
4
+ type ConditionalRenderCallback<T> = (item: Accessor<NonNullable<T>>) => JSX.Element;
5
+ type ConditionalRenderChildren<T, F extends ConditionalRenderCallback<T> = ConditionalRenderCallback<T>> = JSX.Element | NonZeroParams<F>;
3
6
  /**
4
7
  * Creates a list of elements from a list
5
8
  *
@@ -26,11 +29,11 @@ export declare function Repeat<T extends JSX.Element>(props: {
26
29
  * Conditionally render its children or an optional fallback component
27
30
  * @description https://docs.solidjs.com/reference/components/show
28
31
  */
29
- export declare function Show<T>(props: {
32
+ export declare function Show<T, F extends ConditionalRenderCallback<T>>(props: {
30
33
  when: T | undefined | null | false;
31
34
  keyed?: boolean;
32
35
  fallback?: JSX.Element;
33
- children: JSX.Element | ((item: Accessor<NonNullable<T>>) => JSX.Element);
36
+ children: ConditionalRenderChildren<T, F>;
34
37
  }): JSX.Element;
35
38
  /**
36
39
  * Switches between content based on mutually exclusive conditions
@@ -40,16 +43,16 @@ export declare function Switch(props: {
40
43
  fallback?: JSX.Element;
41
44
  children: JSX.Element;
42
45
  }): JSX.Element;
43
- export type MatchProps<T> = {
46
+ export type MatchProps<T, F extends ConditionalRenderCallback<T> = ConditionalRenderCallback<T>> = {
44
47
  when: T | undefined | null | false;
45
48
  keyed?: boolean;
46
- children: JSX.Element | ((item: Accessor<NonNullable<T>>) => JSX.Element);
49
+ children: ConditionalRenderChildren<T, F>;
47
50
  };
48
51
  /**
49
52
  * Selects a content based on condition when inside a `<Switch>` control flow
50
53
  * @description https://docs.solidjs.com/reference/components/switch-and-match
51
54
  */
52
- export declare function Match<T>(props: MatchProps<T>): JSX.Element;
55
+ export declare function Match<T, F extends ConditionalRenderCallback<T>>(props: MatchProps<T, F>): JSX.Element;
53
56
  /**
54
57
  * Catches uncaught errors inside components and renders a fallback content
55
58
  * @description https://docs.solidjs.com/reference/components/error-boundary
@@ -58,3 +61,13 @@ export declare function Errored(props: {
58
61
  fallback: JSX.Element | ((err: any, reset: () => void) => JSX.Element);
59
62
  children: JSX.Element;
60
63
  }): JSX.Element;
64
+ /**
65
+ * Tracks all resources inside a component and renders a fallback until they are all resolved
66
+ * @description https://docs.solidjs.com/reference/components/suspense
67
+ */
68
+ export declare function Loading(props: {
69
+ fallback?: JSX.Element;
70
+ on?: any;
71
+ children: JSX.Element;
72
+ }): JSX.Element;
73
+ export {};
@@ -15,11 +15,9 @@ export declare function ssrHandleError(err: any): Promise<any> | undefined;
15
15
  *
16
16
  * @description https://docs.solidjs.com/reference/components/suspense
17
17
  */
18
- export declare function Loading(props: {
19
- fallback?: JSX.Element;
18
+ export declare function createLoadingBoundary(fn: () => any, fallback: () => any, options?: {
20
19
  on?: () => any;
21
- children: JSX.Element;
22
- }): JSX.Element;
20
+ }): () => unknown;
23
21
  /**
24
22
  * Disables hydration for its children during SSR.
25
23
  * Elements inside will not receive hydration keys (`_hk`) and signals will not be serialized.
@@ -1,10 +1,10 @@
1
- export { $PROXY, $REFRESH, $TRACK, action, createEffect, createMemo, createOptimistic, createOptimisticStore, createErrorBoundary, createLoadingBoundary, createOwner, createProjection, createReaction, createRenderEffect, createRoot, createSignal, createStore, createTrackedEffect, deep, flatten, flush, getNextChildId, getObserver, getOwner, isEqual, isRefreshing, isPending, isWrappable, mapArray, merge, omit, onCleanup, onSettled, latest, reconcile, refresh, repeat, resolve, NotReadyError, runWithOwner, snapshot, storePath, createDeepProxy, enableExternalSource, enforceLoadingBoundary, untrack } from "./signals.js";
1
+ export { $PROXY, $REFRESH, $TRACK, action, createEffect, createMemo, createOptimistic, createOptimisticStore, createErrorBoundary, createOwner, createProjection, createReaction, createRenderEffect, createRoot, createSignal, createStore, createTrackedEffect, deep, flatten, flush, getNextChildId, getObserver, getOwner, isEqual, isRefreshing, isPending, isWrappable, mapArray, merge, omit, onCleanup, onSettled, latest, reconcile, refresh, repeat, resolve, NotReadyError, runWithOwner, snapshot, storePath, createDeepProxy, enableExternalSource, enforceLoadingBoundary, untrack } from "./signals.js";
2
2
  export type { Accessor, ComputeFunction, EffectFunction, EffectOptions, ExternalSource, ExternalSourceConfig, ExternalSourceFactory, Merge, NoInfer, NotWrappable, Omit, Owner, Signal, SignalOptions, Setter, Store, SolidStore, StoreNode, StoreSetter, StorePathRange, ArrayFilterFn, CustomPartial, Part, PathSetter, PatchOp } from "./signals.js";
3
3
  export { $DEVCOMP, children, createContext, useContext, ssrRunInScope } from "./core.js";
4
4
  export type { ChildrenReturn, Context, ContextProviderComponent, ResolvedChildren, ResolvedJSXElement } from "./core.js";
5
5
  export * from "./component.js";
6
6
  export * from "./flow.js";
7
- export { sharedConfig, Loading, ssrHandleError, NoHydration, Hydration, NoHydrateContext } from "./hydration.js";
7
+ export { sharedConfig, createLoadingBoundary, ssrHandleError, NoHydration, Hydration, NoHydrateContext } from "./hydration.js";
8
8
  export type { HydrationContext } from "./hydration.js";
9
9
  import type { JSX } from "../jsx.js";
10
10
  type JSXElement = JSX.Element;
@@ -3,7 +3,7 @@ export { flatten } from "@solidjs/signals";
3
3
  export { snapshot, merge, omit, storePath, $PROXY, $REFRESH, $TRACK } from "@solidjs/signals";
4
4
  export type { Accessor, ComputeFunction, EffectFunction, EffectBundle, EffectOptions, ExternalSource, ExternalSourceConfig, ExternalSourceFactory, MemoOptions, NoInfer, SignalOptions, Setter, Signal, Owner, Maybe, Store, StoreSetter, StoreNode, NotWrappable, SolidStore, Merge, Omit, Context, ContextRecord, IQueue, StorePathRange, ArrayFilterFn, CustomPartial, Part, PathSetter } from "@solidjs/signals";
5
5
  import type { Accessor, ComputeFunction, EffectFunction, EffectBundle, EffectOptions, MemoOptions, SignalOptions, Signal, Owner, Store, StoreSetter, Context } from "@solidjs/signals";
6
- import { NoHydrateContext } from "./shared.js";
6
+ import { sharedConfig, NoHydrateContext } from "./shared.js";
7
7
  interface ServerComputation<T = any> {
8
8
  owner: Owner;
9
9
  value: T;
@@ -47,6 +47,7 @@ export declare function repeat<T>(count: Accessor<number>, mapFn: (i: number) =>
47
47
  }): () => T[];
48
48
  declare const ErrorContext: Context<((err: any) => void) | null>;
49
49
  export { ErrorContext };
50
+ export declare function runWithBoundaryErrorContext<T>(owner: Owner, render: () => T, onError: (err: any, parentHandler: ((err: any) => void) | null) => void, context?: NonNullable<typeof sharedConfig.context>, boundaryId?: string): T;
50
51
  export { NoHydrateContext };
51
52
  export declare function createErrorBoundary<U>(fn: () => any, fallback: (error: unknown, reset: () => void) => U): () => unknown;
52
53
  export declare function createLoadingBoundary(fn: () => any, fallback: () => any, options?: {