solid-js 1.6.10 → 1.7.0-beta.0
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 +45 -96
- package/dist/dev.js +45 -96
- package/dist/server.cjs +9 -8
- package/dist/server.js +9 -8
- package/dist/solid.cjs +24 -17
- package/dist/solid.js +24 -17
- package/h/jsx-runtime/dist/jsx.cjs +6 -3
- package/h/jsx-runtime/dist/jsx.js +5 -2
- package/h/jsx-runtime/types/index.d.ts +6 -2
- package/h/jsx-runtime/types/jsx.d.ts +1 -0
- package/package.json +3 -2
- package/store/dist/dev.cjs +26 -34
- package/store/dist/dev.js +26 -33
- package/store/dist/store.cjs +6 -7
- package/store/dist/store.js +6 -7
- package/store/types/index.d.ts +8 -7
- package/store/types/modifiers.d.ts +1 -1
- package/store/types/server.d.ts +2 -2
- package/store/types/store.d.ts +27 -26
- package/types/index.d.ts +6 -7
- package/types/jsx.d.ts +1 -4
- package/types/reactive/observable.d.ts +1 -1
- package/types/reactive/signal.d.ts +42 -47
- package/types/render/component.d.ts +18 -18
- package/types/render/flow.d.ts +8 -8
- package/types/render/hydration.d.ts +2 -2
- package/types/server/reactive.d.ts +10 -10
- package/types/server/rendering.d.ts +21 -21
- package/web/dist/server.cjs +8 -1
- package/web/dist/server.js +8 -1
- package/web/types/index.d.ts +3 -3
- package/web/types/server-mock.d.ts +1 -1
|
@@ -2,18 +2,18 @@ export declare const equalFn: <T>(a: T, b: T) => boolean;
|
|
|
2
2
|
export declare const $PROXY: unique symbol;
|
|
3
3
|
export declare const $TRACK: unique symbol;
|
|
4
4
|
export declare const $DEVCOMP: unique symbol;
|
|
5
|
-
export declare const DEV:
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
5
|
+
export declare const DEV: undefined;
|
|
6
|
+
export type Accessor<T> = () => T;
|
|
7
|
+
export type Setter<T> = undefined extends T ? <U extends T>(value?: (U extends Function ? never : U) | ((prev?: T) => U)) => U : <U extends T>(value: (U extends Function ? never : U) | ((prev: T) => U)) => U;
|
|
8
|
+
export type Signal<T> = [get: Accessor<T>, set: Setter<T>];
|
|
9
9
|
export declare const BRANCH: unique symbol;
|
|
10
|
-
export declare function castError(err:
|
|
10
|
+
export declare function castError(err: unknown): Error;
|
|
11
11
|
export declare let Owner: Owner | null;
|
|
12
12
|
interface Owner {
|
|
13
13
|
owner: Owner | null;
|
|
14
14
|
context: any | null;
|
|
15
15
|
}
|
|
16
|
-
export declare function createRoot<T>(fn: (dispose: () => void) => T, detachedOwner?: Owner): T;
|
|
16
|
+
export declare function createRoot<T>(fn: (dispose: () => void) => T, detachedOwner?: typeof Owner): T;
|
|
17
17
|
export declare function createSignal<T>(value: T, options?: {
|
|
18
18
|
equals?: false | ((prev: T, next: T) => boolean);
|
|
19
19
|
name?: string;
|
|
@@ -35,7 +35,7 @@ export declare function onCleanup(fn: () => void): () => void;
|
|
|
35
35
|
export declare function cleanNode(node: {
|
|
36
36
|
cleanups?: Function[] | null;
|
|
37
37
|
}): void;
|
|
38
|
-
export declare function onError(fn: (err:
|
|
38
|
+
export declare function onError(fn: (err: Error) => void): void;
|
|
39
39
|
export declare function getListener(): null;
|
|
40
40
|
export interface Context<T> {
|
|
41
41
|
id: symbol;
|
|
@@ -48,11 +48,11 @@ export interface Context<T> {
|
|
|
48
48
|
export declare function createContext<T>(defaultValue?: T): Context<T>;
|
|
49
49
|
export declare function useContext<T>(context: Context<T>): T;
|
|
50
50
|
export declare function getOwner(): Owner | null;
|
|
51
|
-
|
|
51
|
+
type ChildrenReturn = Accessor<any> & {
|
|
52
52
|
toArray: () => any[];
|
|
53
53
|
};
|
|
54
54
|
export declare function children(fn: () => any): ChildrenReturn;
|
|
55
|
-
export declare function runWithOwner<T>(o: Owner, fn: () => T): T | undefined;
|
|
55
|
+
export declare function runWithOwner<T>(o: typeof Owner, fn: () => T): T | undefined;
|
|
56
56
|
export declare function lookup(owner: Owner | null, key: symbol | string): any;
|
|
57
57
|
export interface Task {
|
|
58
58
|
id: number;
|
|
@@ -67,7 +67,7 @@ export declare function cancelCallback(task: Task): void;
|
|
|
67
67
|
export declare function mapArray<T, U>(list: () => T[], mapFn: (v: T, i: () => number) => U, options?: {
|
|
68
68
|
fallback?: () => any;
|
|
69
69
|
}): () => U[];
|
|
70
|
-
export
|
|
70
|
+
export type ObservableObserver<T> = ((v: T) => void) | {
|
|
71
71
|
next: (v: T) => void;
|
|
72
72
|
error?: (v: any) => void;
|
|
73
73
|
complete?: (v: boolean) => void;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { Setter, Signal } from "./reactive.js";
|
|
2
2
|
import type { JSX } from "../jsx.js";
|
|
3
|
-
export
|
|
4
|
-
export
|
|
3
|
+
export type Component<P = {}> = (props: P) => JSX.Element;
|
|
4
|
+
export type VoidProps<P = {}> = P & {
|
|
5
5
|
children?: never;
|
|
6
6
|
};
|
|
7
|
-
export
|
|
8
|
-
export
|
|
7
|
+
export type VoidComponent<P = {}> = Component<VoidProps<P>>;
|
|
8
|
+
export type ParentProps<P = {}> = P & {
|
|
9
9
|
children?: JSX.Element;
|
|
10
10
|
};
|
|
11
|
-
export
|
|
12
|
-
export
|
|
11
|
+
export type ParentComponent<P = {}> = Component<ParentProps<P>>;
|
|
12
|
+
export type FlowProps<P = {}, C = JSX.Element> = P & {
|
|
13
13
|
children: C;
|
|
14
14
|
};
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
|
|
15
|
+
export type FlowComponent<P = {}, C = JSX.Element> = Component<FlowProps<P, C>>;
|
|
16
|
+
export type Ref<T> = T | ((val: T) => void);
|
|
17
|
+
export type ValidComponent = keyof JSX.IntrinsicElements | Component<any> | (string & {});
|
|
18
|
+
export type ComponentProps<T extends ValidComponent> = T extends Component<infer P> ? P : T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T] : Record<string, unknown>;
|
|
19
|
+
type SharedConfig = {
|
|
20
20
|
context?: HydrationContext;
|
|
21
21
|
};
|
|
22
22
|
export declare const sharedConfig: SharedConfig;
|
|
@@ -57,7 +57,7 @@ export declare function Switch(props: {
|
|
|
57
57
|
fallback?: string;
|
|
58
58
|
children: MatchProps<unknown> | MatchProps<unknown>[];
|
|
59
59
|
}): string;
|
|
60
|
-
|
|
60
|
+
type MatchProps<T> = {
|
|
61
61
|
when: T | false;
|
|
62
62
|
keyed?: boolean;
|
|
63
63
|
children: string | ((item: T) => string);
|
|
@@ -77,25 +77,25 @@ export interface Resource<T> {
|
|
|
77
77
|
error: any;
|
|
78
78
|
latest: T | undefined;
|
|
79
79
|
}
|
|
80
|
-
|
|
80
|
+
type SuspenseContextType = {
|
|
81
81
|
resources: Map<string, {
|
|
82
82
|
loading: boolean;
|
|
83
83
|
error: any;
|
|
84
84
|
}>;
|
|
85
85
|
completed: () => void;
|
|
86
86
|
};
|
|
87
|
-
export
|
|
87
|
+
export type ResourceActions<T> = {
|
|
88
88
|
mutate: Setter<T>;
|
|
89
89
|
refetch: (info?: unknown) => void;
|
|
90
90
|
};
|
|
91
|
-
export
|
|
92
|
-
export
|
|
93
|
-
export
|
|
94
|
-
export
|
|
91
|
+
export type ResourceReturn<T> = [Resource<T>, ResourceActions<T>];
|
|
92
|
+
export type ResourceSource<S> = S | false | null | undefined | (() => S | false | null | undefined);
|
|
93
|
+
export type ResourceFetcher<S, T> = (k: S, info: ResourceFetcherInfo<T>) => T | Promise<T>;
|
|
94
|
+
export type ResourceFetcherInfo<T> = {
|
|
95
95
|
value: T | undefined;
|
|
96
96
|
refetching?: unknown;
|
|
97
97
|
};
|
|
98
|
-
export
|
|
98
|
+
export type ResourceOptions<T> = undefined extends T ? {
|
|
99
99
|
initialValue?: T;
|
|
100
100
|
name?: string;
|
|
101
101
|
deferStream?: boolean;
|
|
@@ -125,7 +125,7 @@ export declare function enableScheduling(): void;
|
|
|
125
125
|
export declare function enableHydration(): void;
|
|
126
126
|
export declare function startTransition(fn: () => any): void;
|
|
127
127
|
export declare function useTransition(): [() => boolean, (fn: () => any) => void];
|
|
128
|
-
|
|
128
|
+
type HydrationContext = {
|
|
129
129
|
id: string;
|
|
130
130
|
count: number;
|
|
131
131
|
writeResource: (id: string, v: Promise<any> | any, error?: boolean, deferStream?: boolean) => void;
|
|
@@ -146,7 +146,7 @@ export declare function SuspenseList(props: {
|
|
|
146
146
|
export declare function Suspense(props: {
|
|
147
147
|
fallback?: string;
|
|
148
148
|
children: string;
|
|
149
|
-
}): string | number | boolean | Node | JSX.ArrayElement |
|
|
149
|
+
}): string | number | boolean | Node | JSX.ArrayElement | {
|
|
150
150
|
t: string;
|
|
151
151
|
} | null | undefined;
|
|
152
152
|
export {};
|
package/web/dist/server.cjs
CHANGED
|
@@ -261,6 +261,7 @@ function toRefParam(index) {
|
|
|
261
261
|
return ref;
|
|
262
262
|
}
|
|
263
263
|
|
|
264
|
+
const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
|
|
264
265
|
const REPLACE_SCRIPT = `function $df(e,t,n,o,d){if(n=document.getElementById(e),o=document.getElementById("pl-"+e)){for(;o&&8!==o.nodeType&&o.nodeValue!=="pl-"+e;)d=o.nextSibling,o.remove(),o=d;o.replaceWith(n.content)}n.remove(),_$HY.set(e,t),_$HY.fe(e)}`;
|
|
265
266
|
function renderToString(code, options = {}) {
|
|
266
267
|
let scripts = "";
|
|
@@ -522,13 +523,14 @@ function ssrStyle(value) {
|
|
|
522
523
|
}
|
|
523
524
|
function ssrElement(tag, props, children, needsId) {
|
|
524
525
|
let result = `<${tag}${needsId ? ssrHydrationKey() : ""} `;
|
|
526
|
+
const skipChildren = VOID_ELEMENTS.test(tag);
|
|
525
527
|
if (props == null) props = {};else if (typeof props === "function") props = props();
|
|
526
528
|
const keys = Object.keys(props);
|
|
527
529
|
let classResolved;
|
|
528
530
|
for (let i = 0; i < keys.length; i++) {
|
|
529
531
|
const prop = keys[i];
|
|
530
532
|
if (ChildProperties.has(prop)) {
|
|
531
|
-
if (children === undefined) children = prop === "innerHTML" ? props[prop] : escape(props[prop]);
|
|
533
|
+
if (children === undefined && !skipChildren) children = prop === "innerHTML" ? props[prop] : escape(props[prop]);
|
|
532
534
|
continue;
|
|
533
535
|
}
|
|
534
536
|
const value = props[prop];
|
|
@@ -548,6 +550,11 @@ function ssrElement(tag, props, children, needsId) {
|
|
|
548
550
|
}
|
|
549
551
|
if (i !== keys.length - 1) result += " ";
|
|
550
552
|
}
|
|
553
|
+
if (skipChildren) {
|
|
554
|
+
return {
|
|
555
|
+
t: result + '/>'
|
|
556
|
+
};
|
|
557
|
+
}
|
|
551
558
|
return {
|
|
552
559
|
t: result + `>${resolveSSRNode(children)}</${tag}>`
|
|
553
560
|
};
|
package/web/dist/server.js
CHANGED
|
@@ -260,6 +260,7 @@ function toRefParam(index) {
|
|
|
260
260
|
return ref;
|
|
261
261
|
}
|
|
262
262
|
|
|
263
|
+
const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
|
|
263
264
|
const REPLACE_SCRIPT = `function $df(e,t,n,o,d){if(n=document.getElementById(e),o=document.getElementById("pl-"+e)){for(;o&&8!==o.nodeType&&o.nodeValue!=="pl-"+e;)d=o.nextSibling,o.remove(),o=d;o.replaceWith(n.content)}n.remove(),_$HY.set(e,t),_$HY.fe(e)}`;
|
|
264
265
|
function renderToString(code, options = {}) {
|
|
265
266
|
let scripts = "";
|
|
@@ -521,13 +522,14 @@ function ssrStyle(value) {
|
|
|
521
522
|
}
|
|
522
523
|
function ssrElement(tag, props, children, needsId) {
|
|
523
524
|
let result = `<${tag}${needsId ? ssrHydrationKey() : ""} `;
|
|
525
|
+
const skipChildren = VOID_ELEMENTS.test(tag);
|
|
524
526
|
if (props == null) props = {};else if (typeof props === "function") props = props();
|
|
525
527
|
const keys = Object.keys(props);
|
|
526
528
|
let classResolved;
|
|
527
529
|
for (let i = 0; i < keys.length; i++) {
|
|
528
530
|
const prop = keys[i];
|
|
529
531
|
if (ChildProperties.has(prop)) {
|
|
530
|
-
if (children === undefined) children = prop === "innerHTML" ? props[prop] : escape(props[prop]);
|
|
532
|
+
if (children === undefined && !skipChildren) children = prop === "innerHTML" ? props[prop] : escape(props[prop]);
|
|
531
533
|
continue;
|
|
532
534
|
}
|
|
533
535
|
const value = props[prop];
|
|
@@ -547,6 +549,11 @@ function ssrElement(tag, props, children, needsId) {
|
|
|
547
549
|
}
|
|
548
550
|
if (i !== keys.length - 1) result += " ";
|
|
549
551
|
}
|
|
552
|
+
if (skipChildren) {
|
|
553
|
+
return {
|
|
554
|
+
t: result + '/>'
|
|
555
|
+
};
|
|
556
|
+
}
|
|
550
557
|
return {
|
|
551
558
|
t: result + `>${resolveSSRNode(children)}</${tag}>`
|
|
552
559
|
};
|
package/web/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { hydrate as hydrateCore } from "./client.js";
|
|
2
|
-
import { JSX,
|
|
2
|
+
import { JSX, ComponentProps, ValidComponent } from "solid-js";
|
|
3
3
|
export * from "./client.js";
|
|
4
4
|
export { For, Show, Suspense, SuspenseList, Switch, Match, Index, ErrorBoundary, mergeProps } from "solid-js";
|
|
5
5
|
export * from "./server-mock.js";
|
|
@@ -21,7 +21,7 @@ export declare function Portal<T extends boolean = false, S extends boolean = fa
|
|
|
21
21
|
} : {}) & (S extends true ? SVGGElement : HTMLDivElement)) => void);
|
|
22
22
|
children: JSX.Element;
|
|
23
23
|
}): Text;
|
|
24
|
-
export
|
|
24
|
+
export type DynamicProps<T extends ValidComponent, P = ComponentProps<T>> = {
|
|
25
25
|
[K in keyof P]: P[K];
|
|
26
26
|
} & {
|
|
27
27
|
component: T | undefined;
|
|
@@ -33,4 +33,4 @@ export declare type DynamicProps<T extends ValidComponent, P = ComponentProps<T>
|
|
|
33
33
|
* ```
|
|
34
34
|
* @description https://www.solidjs.com/docs/latest/api#dynamic
|
|
35
35
|
*/
|
|
36
|
-
export declare function Dynamic<T extends ValidComponent>(props: DynamicProps<T>):
|
|
36
|
+
export declare function Dynamic<T extends ValidComponent>(props: DynamicProps<T>): JSX.Element;
|
|
@@ -42,7 +42,7 @@ export declare function escape(html: string): string;
|
|
|
42
42
|
* @deprecated Replaced by ssrElement
|
|
43
43
|
*/
|
|
44
44
|
export declare function ssrSpread(props: any, isSVG: boolean, skipChildren: boolean): void;
|
|
45
|
-
export
|
|
45
|
+
export type LegacyResults = {
|
|
46
46
|
startWriting: () => void;
|
|
47
47
|
};
|
|
48
48
|
/**
|