solid-js 1.8.23 → 1.9.1
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/h/jsx-runtime/types/index.d.ts +2 -2
- package/h/jsx-runtime/types/jsx.d.ts +22 -1
- package/h/types/index.d.ts +1 -1
- package/html/dist/html.cjs +4 -2
- package/html/dist/html.js +9 -4
- package/html/types/index.d.ts +1 -1
- package/html/types/lit.d.ts +6 -1
- package/package.json +1 -5
- package/store/dist/server.cjs +4 -0
- package/store/dist/server.js +4 -0
- package/store/package.json +0 -4
- package/store/types/server.d.ts +14 -1
- package/store/types/store.d.ts +1 -1
- package/types/jsx.d.ts +22 -1
- package/types/reactive/signal.d.ts +2 -2
- package/types/render/component.d.ts +14 -9
- package/web/dist/dev.cjs +56 -24
- package/web/dist/dev.js +62 -23
- package/web/dist/server.cjs +95 -14
- package/web/dist/server.js +472 -15
- package/web/dist/web.cjs +52 -23
- package/web/dist/web.js +54 -21
- package/web/package.json +0 -4
- package/web/types/client.d.ts +3 -1
- package/web/types/server.d.ts +88 -0
|
@@ -40,6 +40,7 @@ export namespace JSX {
|
|
|
40
40
|
}
|
|
41
41
|
): void;
|
|
42
42
|
}
|
|
43
|
+
|
|
43
44
|
interface BoundEventHandler<T, E extends Event> {
|
|
44
45
|
0: (
|
|
45
46
|
data: any,
|
|
@@ -52,6 +53,19 @@ export namespace JSX {
|
|
|
52
53
|
}
|
|
53
54
|
type EventHandlerUnion<T, E extends Event> = EventHandler<T, E> | BoundEventHandler<T, E>;
|
|
54
55
|
|
|
56
|
+
interface EventHandlerWithOptions<T, E extends Event> extends AddEventListenerOptions {
|
|
57
|
+
handleEvent: (
|
|
58
|
+
e: E & {
|
|
59
|
+
currentTarget: T;
|
|
60
|
+
target: Element;
|
|
61
|
+
}
|
|
62
|
+
) => void;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
type CustomEventHandlerUnion<T, E extends Event> =
|
|
66
|
+
| EventHandler<T, E>
|
|
67
|
+
| EventHandlerWithOptions<T, E>;
|
|
68
|
+
|
|
55
69
|
const SERIALIZABLE: unique symbol;
|
|
56
70
|
interface SerializableAttributeValue {
|
|
57
71
|
toString(): string;
|
|
@@ -75,7 +89,11 @@ export namespace JSX {
|
|
|
75
89
|
}
|
|
76
90
|
interface ExplicitProperties {}
|
|
77
91
|
interface ExplicitAttributes {}
|
|
92
|
+
interface ExplicitBoolAttributes {}
|
|
78
93
|
interface CustomEvents {}
|
|
94
|
+
/**
|
|
95
|
+
* @deprecated Replaced by CustomEvents
|
|
96
|
+
*/
|
|
79
97
|
interface CustomCaptureEvents {}
|
|
80
98
|
type DirectiveAttributes = {
|
|
81
99
|
[Key in keyof Directives as `use:${Key}`]?: Directives[Key];
|
|
@@ -102,8 +120,11 @@ export namespace JSX {
|
|
|
102
120
|
type AttrAttributes = {
|
|
103
121
|
[Key in keyof ExplicitAttributes as `attr:${Key}`]?: ExplicitAttributes[Key];
|
|
104
122
|
};
|
|
123
|
+
type BoolAttributes = {
|
|
124
|
+
[Key in keyof ExplicitBoolAttributes as `bool:${Key}`]?: ExplicitBoolAttributes[Key];
|
|
125
|
+
};
|
|
105
126
|
type OnAttributes<T> = {
|
|
106
|
-
[Key in keyof CustomEvents as `on:${Key}`]?:
|
|
127
|
+
[Key in keyof CustomEvents as `on:${Key}`]?: CustomEventHandlerUnion<T, CustomEvents[Key]>;
|
|
107
128
|
};
|
|
108
129
|
type OnCaptureAttributes<T> = {
|
|
109
130
|
[Key in keyof CustomCaptureEvents as `oncapture:${Key}`]?: EventHandler<
|
package/h/types/index.d.ts
CHANGED
package/html/dist/html.cjs
CHANGED
|
@@ -330,6 +330,7 @@ function createHTML(r, {
|
|
|
330
330
|
options.counter = childOptions.counter;
|
|
331
331
|
options.templateId = childOptions.templateId;
|
|
332
332
|
options.hasCustomElement = options.hasCustomElement || childOptions.hasCustomElement;
|
|
333
|
+
options.isImportNode = options.isImportNode || childOptions.isImportNode;
|
|
333
334
|
}
|
|
334
335
|
function processComponentProps(propGroups) {
|
|
335
336
|
let result = [];
|
|
@@ -440,8 +441,9 @@ function createHTML(r, {
|
|
|
440
441
|
const templateId = options.templateId;
|
|
441
442
|
options.decl.push(topDecl ? "" : `${tag} = ${options.path}.${options.first ? "firstChild" : "nextSibling"}`);
|
|
442
443
|
const isSVG = r.SVGElements.has(node.name);
|
|
443
|
-
const isCE = node.name.includes("-");
|
|
444
|
+
const isCE = node.name.includes("-") || node.attrs.some(e => e.name === "is");
|
|
444
445
|
options.hasCustomElement = isCE;
|
|
446
|
+
options.isImportNode = (node.name === 'img' || node.name === 'iframe') && node.attrs.some(e => e.name === "loading" && e.value === 'lazy');
|
|
445
447
|
if (node.attrs.some(e => e.name === "###")) {
|
|
446
448
|
const spreadArgs = [];
|
|
447
449
|
let current = "";
|
|
@@ -498,7 +500,7 @@ function createHTML(r, {
|
|
|
498
500
|
options.first = false;
|
|
499
501
|
processChildren(node, options);
|
|
500
502
|
if (topDecl) {
|
|
501
|
-
options.decl[0] = options.hasCustomElement ? `const ${tag} = r.untrack(() => document.importNode(tmpls[${templateId}].content.firstChild, true))` : `const ${tag} = tmpls[${templateId}].content.firstChild.cloneNode(true)`;
|
|
503
|
+
options.decl[0] = options.hasCustomElement || options.isImportNode ? `const ${tag} = r.untrack(() => document.importNode(tmpls[${templateId}].content.firstChild, true))` : `const ${tag} = tmpls[${templateId}].content.firstChild.cloneNode(true)`;
|
|
502
504
|
}
|
|
503
505
|
} else if (node.type === "text") {
|
|
504
506
|
const tag = `_$el${uuid++}`;
|
package/html/dist/html.js
CHANGED
|
@@ -408,6 +408,7 @@ function createHTML(
|
|
|
408
408
|
options.counter = childOptions.counter;
|
|
409
409
|
options.templateId = childOptions.templateId;
|
|
410
410
|
options.hasCustomElement = options.hasCustomElement || childOptions.hasCustomElement;
|
|
411
|
+
options.isImportNode = options.isImportNode || childOptions.isImportNode;
|
|
411
412
|
}
|
|
412
413
|
function processComponentProps(propGroups) {
|
|
413
414
|
let result = [];
|
|
@@ -543,8 +544,11 @@ function createHTML(
|
|
|
543
544
|
topDecl ? "" : `${tag} = ${options.path}.${options.first ? "firstChild" : "nextSibling"}`
|
|
544
545
|
);
|
|
545
546
|
const isSVG = r.SVGElements.has(node.name);
|
|
546
|
-
const isCE = node.name.includes("-");
|
|
547
|
+
const isCE = node.name.includes("-") || node.attrs.some(e => e.name === "is");
|
|
547
548
|
options.hasCustomElement = isCE;
|
|
549
|
+
options.isImportNode =
|
|
550
|
+
(node.name === "img" || node.name === "iframe") &&
|
|
551
|
+
node.attrs.some(e => e.name === "loading" && e.value === "lazy");
|
|
548
552
|
if (node.attrs.some(e => e.name === "###")) {
|
|
549
553
|
const spreadArgs = [];
|
|
550
554
|
let current = "";
|
|
@@ -601,9 +605,10 @@ function createHTML(
|
|
|
601
605
|
options.first = false;
|
|
602
606
|
processChildren(node, options);
|
|
603
607
|
if (topDecl) {
|
|
604
|
-
options.decl[0] =
|
|
605
|
-
|
|
606
|
-
|
|
608
|
+
options.decl[0] =
|
|
609
|
+
options.hasCustomElement || options.isImportNode
|
|
610
|
+
? `const ${tag} = r.untrack(() => document.importNode(tmpls[${templateId}].content.firstChild, true))`
|
|
611
|
+
: `const ${tag} = tmpls[${templateId}].content.firstChild.cloneNode(true)`;
|
|
607
612
|
}
|
|
608
613
|
} else if (node.type === "text") {
|
|
609
614
|
const tag = `_$el${uuid++}`;
|
package/html/types/index.d.ts
CHANGED
package/html/types/lit.d.ts
CHANGED
|
@@ -5,7 +5,12 @@ interface Runtime {
|
|
|
5
5
|
insert(parent: MountableElement, accessor: any, marker?: Node | null, init?: any): any;
|
|
6
6
|
spread<T>(node: Element, accessor: (() => T) | T, isSVG?: Boolean, skipChildren?: Boolean): void;
|
|
7
7
|
createComponent(Comp: (props: any) => any, props: any): any;
|
|
8
|
-
addEventListener(
|
|
8
|
+
addEventListener(
|
|
9
|
+
node: Element,
|
|
10
|
+
name: string,
|
|
11
|
+
handler: EventListener | EventListenerObject | (EventListenerObject & AddEventListenerOptions),
|
|
12
|
+
delegate: boolean
|
|
13
|
+
): void;
|
|
9
14
|
delegateEvents(eventNames: string[]): void;
|
|
10
15
|
classList(
|
|
11
16
|
node: Element,
|
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.
|
|
4
|
+
"version": "1.9.1",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://solidjs.com",
|
|
@@ -11,10 +11,6 @@
|
|
|
11
11
|
},
|
|
12
12
|
"main": "./dist/server.cjs",
|
|
13
13
|
"module": "./dist/server.js",
|
|
14
|
-
"browser": {
|
|
15
|
-
"./dist/server.cjs": "./dist/solid.cjs",
|
|
16
|
-
"./dist/server.js": "./dist/solid.js"
|
|
17
|
-
},
|
|
18
14
|
"unpkg": "./dist/solid.cjs",
|
|
19
15
|
"types": "types/index.d.ts",
|
|
20
16
|
"sideEffects": false,
|
package/store/dist/server.cjs
CHANGED
|
@@ -87,6 +87,9 @@ function createStore(state) {
|
|
|
87
87
|
function createMutable(state) {
|
|
88
88
|
return state;
|
|
89
89
|
}
|
|
90
|
+
function modifyMutable(state, modifier) {
|
|
91
|
+
modifier(state);
|
|
92
|
+
}
|
|
90
93
|
function reconcile(value, options = {}) {
|
|
91
94
|
return state => {
|
|
92
95
|
if (!isWrappable(state) || !isWrappable(value)) return value;
|
|
@@ -115,6 +118,7 @@ exports.DEV = DEV;
|
|
|
115
118
|
exports.createMutable = createMutable;
|
|
116
119
|
exports.createStore = createStore;
|
|
117
120
|
exports.isWrappable = isWrappable;
|
|
121
|
+
exports.modifyMutable = modifyMutable;
|
|
118
122
|
exports.produce = produce;
|
|
119
123
|
exports.reconcile = reconcile;
|
|
120
124
|
exports.setProperty = setProperty;
|
package/store/dist/server.js
CHANGED
|
@@ -85,6 +85,9 @@ function createStore(state) {
|
|
|
85
85
|
function createMutable(state) {
|
|
86
86
|
return state;
|
|
87
87
|
}
|
|
88
|
+
function modifyMutable(state, modifier) {
|
|
89
|
+
modifier(state);
|
|
90
|
+
}
|
|
88
91
|
function reconcile(value, options = {}) {
|
|
89
92
|
return state => {
|
|
90
93
|
if (!isWrappable(state) || !isWrappable(value)) return value;
|
|
@@ -114,6 +117,7 @@ export {
|
|
|
114
117
|
createMutable,
|
|
115
118
|
createStore,
|
|
116
119
|
isWrappable,
|
|
120
|
+
modifyMutable,
|
|
117
121
|
produce,
|
|
118
122
|
reconcile,
|
|
119
123
|
setProperty,
|
package/store/package.json
CHANGED
|
@@ -2,10 +2,6 @@
|
|
|
2
2
|
"name": "solid-js/store",
|
|
3
3
|
"main": "./dist/server.cjs",
|
|
4
4
|
"module": "./dist/server.js",
|
|
5
|
-
"browser": {
|
|
6
|
-
"./dist/server.cjs": "./dist/store.cjs",
|
|
7
|
-
"./dist/server.js": "./dist/store.js"
|
|
8
|
-
},
|
|
9
5
|
"unpkg": "./dist/store.cjs",
|
|
10
6
|
"types": "./types/index.d.ts",
|
|
11
7
|
"type": "module",
|
package/store/types/server.d.ts
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
import type { SetStoreFunction, Store } from "./store.js";
|
|
2
|
+
export type {
|
|
3
|
+
ArrayFilterFn,
|
|
4
|
+
DeepMutable,
|
|
5
|
+
DeepReadonly,
|
|
6
|
+
NotWrappable,
|
|
7
|
+
Part,
|
|
8
|
+
SetStoreFunction,
|
|
9
|
+
SolidStore,
|
|
10
|
+
Store,
|
|
11
|
+
StoreNode,
|
|
12
|
+
StorePathRange,
|
|
13
|
+
StoreSetter
|
|
14
|
+
} from "./store.js";
|
|
2
15
|
export declare const $RAW: unique symbol;
|
|
3
16
|
export declare function isWrappable(obj: any): boolean;
|
|
4
17
|
export declare function unwrap<T>(item: T): T;
|
|
@@ -11,6 +24,7 @@ export declare function setProperty(
|
|
|
11
24
|
export declare function updatePath(current: any, path: any[], traversed?: PropertyKey[]): void;
|
|
12
25
|
export declare function createStore<T>(state: T | Store<T>): [Store<T>, SetStoreFunction<T>];
|
|
13
26
|
export declare function createMutable<T>(state: T | Store<T>): T;
|
|
27
|
+
export declare function modifyMutable<T>(state: T, modifier: (state: T) => T): void;
|
|
14
28
|
type ReconcileOptions = {
|
|
15
29
|
key?: string | null;
|
|
16
30
|
merge?: boolean;
|
|
@@ -21,4 +35,3 @@ export declare function reconcile<T extends U, U extends object>(
|
|
|
21
35
|
): (state: U) => T;
|
|
22
36
|
export declare function produce<T>(fn: (state: T) => void): (state: T) => T;
|
|
23
37
|
export declare const DEV: undefined;
|
|
24
|
-
export {};
|
package/store/types/store.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ type DataNode = {
|
|
|
9
9
|
(): any;
|
|
10
10
|
$(value?: any): void;
|
|
11
11
|
};
|
|
12
|
-
type DataNodes = Record<PropertyKey, DataNode | undefined>;
|
|
12
|
+
export type DataNodes = Record<PropertyKey, DataNode | undefined>;
|
|
13
13
|
export type OnStoreNodeUpdate = (
|
|
14
14
|
state: StoreNode,
|
|
15
15
|
property: PropertyKey,
|
package/types/jsx.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export namespace JSX {
|
|
|
28
28
|
}
|
|
29
29
|
): void;
|
|
30
30
|
}
|
|
31
|
+
|
|
31
32
|
interface BoundEventHandler<T, E extends Event> {
|
|
32
33
|
0: (
|
|
33
34
|
data: any,
|
|
@@ -40,6 +41,19 @@ export namespace JSX {
|
|
|
40
41
|
}
|
|
41
42
|
type EventHandlerUnion<T, E extends Event> = EventHandler<T, E> | BoundEventHandler<T, E>;
|
|
42
43
|
|
|
44
|
+
interface EventHandlerWithOptions<T, E extends Event> extends AddEventListenerOptions {
|
|
45
|
+
handleEvent: (
|
|
46
|
+
e: E & {
|
|
47
|
+
currentTarget: T;
|
|
48
|
+
target: Element;
|
|
49
|
+
}
|
|
50
|
+
) => void;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
type CustomEventHandlerUnion<T, E extends Event> =
|
|
54
|
+
| EventHandler<T, E>
|
|
55
|
+
| EventHandlerWithOptions<T, E>;
|
|
56
|
+
|
|
43
57
|
interface InputEventHandler<T, E extends InputEvent> {
|
|
44
58
|
(
|
|
45
59
|
e: E & {
|
|
@@ -141,7 +155,11 @@ export namespace JSX {
|
|
|
141
155
|
}
|
|
142
156
|
interface ExplicitProperties {}
|
|
143
157
|
interface ExplicitAttributes {}
|
|
158
|
+
interface ExplicitBoolAttributes {}
|
|
144
159
|
interface CustomEvents {}
|
|
160
|
+
/**
|
|
161
|
+
* @deprecated Replaced by CustomEvents
|
|
162
|
+
*/
|
|
145
163
|
interface CustomCaptureEvents {}
|
|
146
164
|
type DirectiveAttributes = {
|
|
147
165
|
[Key in keyof Directives as `use:${Key}`]?: Directives[Key];
|
|
@@ -168,8 +186,11 @@ export namespace JSX {
|
|
|
168
186
|
type AttrAttributes = {
|
|
169
187
|
[Key in keyof ExplicitAttributes as `attr:${Key}`]?: ExplicitAttributes[Key];
|
|
170
188
|
};
|
|
189
|
+
type BoolAttributes = {
|
|
190
|
+
[Key in keyof ExplicitBoolAttributes as `bool:${Key}`]?: ExplicitBoolAttributes[Key];
|
|
191
|
+
};
|
|
171
192
|
type OnAttributes<T> = {
|
|
172
|
-
[Key in keyof CustomEvents as `on:${Key}`]?:
|
|
193
|
+
[Key in keyof CustomEvents as `on:${Key}`]?: CustomEventHandlerUnion<T, CustomEvents[Key]>;
|
|
173
194
|
};
|
|
174
195
|
type OnCaptureAttributes<T> = {
|
|
175
196
|
[Key in keyof CustomCaptureEvents as `oncapture:${Key}`]?: EventHandler<
|
|
@@ -102,12 +102,12 @@ export type RootFunction<T> = (dispose: () => void) => T;
|
|
|
102
102
|
export declare function createRoot<T>(fn: RootFunction<T>, detachedOwner?: typeof Owner): T;
|
|
103
103
|
export type Accessor<T> = () => T;
|
|
104
104
|
export type Setter<in out T> = {
|
|
105
|
+
<U extends T>(value: Exclude<U, Function> | ((prev: T) => U)): U;
|
|
105
106
|
<U extends T>(...args: undefined extends T ? [] : [value: (prev: T) => U]): undefined extends T
|
|
106
107
|
? undefined
|
|
107
108
|
: U;
|
|
108
|
-
<U extends T>(value: (prev: T) => U): U;
|
|
109
109
|
<U extends T>(value: Exclude<U, Function>): U;
|
|
110
|
-
<U extends T>(value:
|
|
110
|
+
<U extends T>(value: (prev: T) => U): U;
|
|
111
111
|
};
|
|
112
112
|
export type Signal<T> = [get: Accessor<T>, set: Setter<T>];
|
|
113
113
|
export interface SignalOptions<T> extends MemoOptions<T> {
|
|
@@ -4,13 +4,13 @@ export declare function enableHydration(): void;
|
|
|
4
4
|
* A general `Component` has no implicit `children` prop. If desired, you can
|
|
5
5
|
* specify one as in `Component<{name: String, children: JSX.Element}>`.
|
|
6
6
|
*/
|
|
7
|
-
export type Component<P = {}> = (props: P) => JSX.Element;
|
|
7
|
+
export type Component<P extends Record<string, any> = {}> = (props: P) => JSX.Element;
|
|
8
8
|
/**
|
|
9
9
|
* Extend props to forbid the `children` prop.
|
|
10
10
|
* Use this to prevent accidentally passing `children` to components that
|
|
11
11
|
* would silently throw them away.
|
|
12
12
|
*/
|
|
13
|
-
export type VoidProps<P = {}> = P & {
|
|
13
|
+
export type VoidProps<P extends Record<string, any> = {}> = P & {
|
|
14
14
|
children?: never;
|
|
15
15
|
};
|
|
16
16
|
/**
|
|
@@ -18,13 +18,13 @@ export type VoidProps<P = {}> = P & {
|
|
|
18
18
|
* Use this to prevent accidentally passing `children` to components that
|
|
19
19
|
* would silently throw them away.
|
|
20
20
|
*/
|
|
21
|
-
export type VoidComponent<P = {}> = Component<VoidProps<P>>;
|
|
21
|
+
export type VoidComponent<P extends Record<string, any> = {}> = Component<VoidProps<P>>;
|
|
22
22
|
/**
|
|
23
23
|
* Extend props to allow an optional `children` prop with the usual
|
|
24
24
|
* type in JSX, `JSX.Element` (which allows elements, arrays, functions, etc.).
|
|
25
25
|
* Use this for components that you want to accept children.
|
|
26
26
|
*/
|
|
27
|
-
export type ParentProps<P = {}> = P & {
|
|
27
|
+
export type ParentProps<P extends Record<string, any> = {}> = P & {
|
|
28
28
|
children?: JSX.Element;
|
|
29
29
|
};
|
|
30
30
|
/**
|
|
@@ -32,14 +32,14 @@ export type ParentProps<P = {}> = P & {
|
|
|
32
32
|
* type in JSX, `JSX.Element` (which allows elements, arrays, functions, etc.).
|
|
33
33
|
* Use this for components that you want to accept children.
|
|
34
34
|
*/
|
|
35
|
-
export type ParentComponent<P = {}> = Component<ParentProps<P>>;
|
|
35
|
+
export type ParentComponent<P extends Record<string, any> = {}> = Component<ParentProps<P>>;
|
|
36
36
|
/**
|
|
37
37
|
* Extend props to require a `children` prop with the specified type.
|
|
38
38
|
* Use this for components where you need a specific child type,
|
|
39
39
|
* typically a function that receives specific argument types.
|
|
40
40
|
* Note that all JSX <Elements> are of the type `JSX.Element`.
|
|
41
41
|
*/
|
|
42
|
-
export type FlowProps<P = {}, C = JSX.Element> = P & {
|
|
42
|
+
export type FlowProps<P extends Record<string, any> = {}, C = JSX.Element> = P & {
|
|
43
43
|
children: C;
|
|
44
44
|
};
|
|
45
45
|
/**
|
|
@@ -48,9 +48,11 @@ export type FlowProps<P = {}, C = JSX.Element> = P & {
|
|
|
48
48
|
* typically a function that receives specific argument types.
|
|
49
49
|
* Note that all JSX <Elements> are of the type `JSX.Element`.
|
|
50
50
|
*/
|
|
51
|
-
export type FlowComponent<P = {}, C = JSX.Element> = Component<
|
|
51
|
+
export type FlowComponent<P extends Record<string, any> = {}, C = JSX.Element> = Component<
|
|
52
|
+
FlowProps<P, C>
|
|
53
|
+
>;
|
|
52
54
|
/** @deprecated: use `ParentProps` instead */
|
|
53
|
-
export type PropsWithChildren<P = {}> = ParentProps<P>;
|
|
55
|
+
export type PropsWithChildren<P extends Record<string, any> = {}> = ParentProps<P>;
|
|
54
56
|
export type ValidComponent = keyof JSX.IntrinsicElements | Component<any> | (string & {});
|
|
55
57
|
/**
|
|
56
58
|
* Takes the props of the passed component and returns its type
|
|
@@ -70,7 +72,10 @@ export type ComponentProps<T extends ValidComponent> = T extends Component<infer
|
|
|
70
72
|
* @example Component<{ref: Ref<Element>}>
|
|
71
73
|
*/
|
|
72
74
|
export type Ref<T> = T | ((val: T) => void);
|
|
73
|
-
export declare function createComponent<T
|
|
75
|
+
export declare function createComponent<T extends Record<string, any>>(
|
|
76
|
+
Comp: Component<T>,
|
|
77
|
+
props: T
|
|
78
|
+
): JSX.Element;
|
|
74
79
|
type DistributeOverride<T, F> = T extends undefined ? F : T;
|
|
75
80
|
type Override<T, U> = T extends any
|
|
76
81
|
? U extends any
|
package/web/dist/dev.cjs
CHANGED
|
@@ -122,7 +122,7 @@ function render(code, element, init, options = {}) {
|
|
|
122
122
|
element.textContent = "";
|
|
123
123
|
};
|
|
124
124
|
}
|
|
125
|
-
function template(html,
|
|
125
|
+
function template(html, isImportNode, isSVG) {
|
|
126
126
|
let node;
|
|
127
127
|
const create = () => {
|
|
128
128
|
if (isHydrating()) throw new Error("Failed attempt to create new DOM elements during hydration. Check that the libraries you are using support hydration.");
|
|
@@ -130,7 +130,7 @@ function template(html, isCE, isSVG) {
|
|
|
130
130
|
t.innerHTML = html;
|
|
131
131
|
return isSVG ? t.content.firstChild.firstChild : t.content.firstChild;
|
|
132
132
|
};
|
|
133
|
-
const fn =
|
|
133
|
+
const fn = isImportNode ? () => solidJs.untrack(() => document.importNode(node || (node = create()), true)) : () => (node || (node = create())).cloneNode(true);
|
|
134
134
|
fn.cloneNode = fn;
|
|
135
135
|
return fn;
|
|
136
136
|
}
|
|
@@ -162,6 +162,10 @@ function setAttributeNS(node, namespace, name, value) {
|
|
|
162
162
|
if (isHydrating(node)) return;
|
|
163
163
|
if (value == null) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value);
|
|
164
164
|
}
|
|
165
|
+
function setBoolAttribute(node, name, value) {
|
|
166
|
+
if (isHydrating(node)) return;
|
|
167
|
+
value ? node.setAttribute(name, "") : node.removeAttribute(name);
|
|
168
|
+
}
|
|
165
169
|
function className(node, value) {
|
|
166
170
|
if (isHydrating(node)) return;
|
|
167
171
|
if (value == null) node.removeAttribute("class");else node.className = value;
|
|
@@ -175,7 +179,7 @@ function addEventListener(node, name, handler, delegate) {
|
|
|
175
179
|
} else if (Array.isArray(handler)) {
|
|
176
180
|
const handlerFn = handler[0];
|
|
177
181
|
node.addEventListener(name, handler[0] = e => handlerFn.call(node, handler[1], e));
|
|
178
|
-
} else node.addEventListener(name, handler);
|
|
182
|
+
} else node.addEventListener(name, handler, typeof handler !== "function" && handler);
|
|
179
183
|
}
|
|
180
184
|
function classList(node, value, prev = {}) {
|
|
181
185
|
const classKeys = Object.keys(value || {}),
|
|
@@ -249,7 +253,7 @@ function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = fals
|
|
|
249
253
|
for (const prop in prevProps) {
|
|
250
254
|
if (!(prop in props)) {
|
|
251
255
|
if (prop === "children") continue;
|
|
252
|
-
prevProps[prop] = assignProp(node, prop, null, prevProps[prop], isSVG, skipRef);
|
|
256
|
+
prevProps[prop] = assignProp(node, prop, null, prevProps[prop], isSVG, skipRef, props);
|
|
253
257
|
}
|
|
254
258
|
}
|
|
255
259
|
for (const prop in props) {
|
|
@@ -258,7 +262,7 @@ function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = fals
|
|
|
258
262
|
continue;
|
|
259
263
|
}
|
|
260
264
|
const value = props[prop];
|
|
261
|
-
prevProps[prop] = assignProp(node, prop, value, prevProps[prop], isSVG, skipRef);
|
|
265
|
+
prevProps[prop] = assignProp(node, prop, value, prevProps[prop], isSVG, skipRef, props);
|
|
262
266
|
}
|
|
263
267
|
}
|
|
264
268
|
function hydrate$1(code, element, options = {}) {
|
|
@@ -285,7 +289,10 @@ function getNextElement(template) {
|
|
|
285
289
|
key,
|
|
286
290
|
hydrating = isHydrating();
|
|
287
291
|
if (!hydrating || !(node = solidJs.sharedConfig.registry.get(key = getHydrationKey()))) {
|
|
288
|
-
if (hydrating)
|
|
292
|
+
if (hydrating) {
|
|
293
|
+
solidJs.sharedConfig.done = true;
|
|
294
|
+
throw new Error(`Hydration Mismatch. Unable to find DOM nodes for hydration key: ${key}\n${template ? template().outerHTML : ""}`);
|
|
295
|
+
}
|
|
289
296
|
return template();
|
|
290
297
|
}
|
|
291
298
|
if (solidJs.sharedConfig.completed) solidJs.sharedConfig.completed.add(node);
|
|
@@ -348,7 +355,7 @@ function toggleClassKey(node, key, value) {
|
|
|
348
355
|
const classNames = key.trim().split(/\s+/);
|
|
349
356
|
for (let i = 0, nameLen = classNames.length; i < nameLen; i++) node.classList.toggle(classNames[i], value);
|
|
350
357
|
}
|
|
351
|
-
function assignProp(node, prop, value, prev, isSVG, skipRef) {
|
|
358
|
+
function assignProp(node, prop, value, prev, isSVG, skipRef, props) {
|
|
352
359
|
let isCE, isProp, isChildProp, propAlias, forceProp;
|
|
353
360
|
if (prop === "style") return style(node, value, prev);
|
|
354
361
|
if (prop === "classList") return classList(node, value, prev);
|
|
@@ -357,8 +364,8 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
|
|
|
357
364
|
if (!skipRef) value(node);
|
|
358
365
|
} else if (prop.slice(0, 3) === "on:") {
|
|
359
366
|
const e = prop.slice(3);
|
|
360
|
-
prev && node.removeEventListener(e, prev);
|
|
361
|
-
value && node.addEventListener(e, value);
|
|
367
|
+
prev && node.removeEventListener(e, prev, typeof prev !== "function" && prev);
|
|
368
|
+
value && node.addEventListener(e, value, typeof value !== "function" && value);
|
|
362
369
|
} else if (prop.slice(0, 10) === "oncapture:") {
|
|
363
370
|
const e = prop.slice(10);
|
|
364
371
|
prev && node.removeEventListener(e, prev, true);
|
|
@@ -376,7 +383,9 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
|
|
|
376
383
|
}
|
|
377
384
|
} else if (prop.slice(0, 5) === "attr:") {
|
|
378
385
|
setAttribute(node, prop.slice(5), value);
|
|
379
|
-
} else if (
|
|
386
|
+
} else if (prop.slice(0, 5) === "bool:") {
|
|
387
|
+
setBoolAttribute(node, prop.slice(5), value);
|
|
388
|
+
} else if ((forceProp = prop.slice(0, 5) === "prop:") || (isChildProp = ChildProperties.has(prop)) || !isSVG && ((propAlias = getPropAlias(prop, node.tagName)) || (isProp = Properties.has(prop))) || (isCE = node.nodeName.includes("-") || 'is' in props)) {
|
|
380
389
|
if (forceProp) {
|
|
381
390
|
prop = prop.slice(5);
|
|
382
391
|
isProp = true;
|
|
@@ -392,30 +401,52 @@ function eventHandler(e) {
|
|
|
392
401
|
if (solidJs.sharedConfig.registry && solidJs.sharedConfig.events) {
|
|
393
402
|
if (solidJs.sharedConfig.events.find(([el, ev]) => ev === e)) return;
|
|
394
403
|
}
|
|
404
|
+
let node = e.target;
|
|
395
405
|
const key = `$$${e.type}`;
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
configurable: true,
|
|
400
|
-
value: node
|
|
401
|
-
});
|
|
402
|
-
}
|
|
403
|
-
Object.defineProperty(e, "currentTarget", {
|
|
406
|
+
const oriTarget = e.target;
|
|
407
|
+
const oriCurrentTarget = e.currentTarget;
|
|
408
|
+
const retarget = value => Object.defineProperty(e, "target", {
|
|
404
409
|
configurable: true,
|
|
405
|
-
|
|
406
|
-
return node || document;
|
|
407
|
-
}
|
|
410
|
+
value
|
|
408
411
|
});
|
|
409
|
-
|
|
410
|
-
while (node) {
|
|
412
|
+
const handleNode = () => {
|
|
411
413
|
const handler = node[key];
|
|
412
414
|
if (handler && !node.disabled) {
|
|
413
415
|
const data = node[`${key}Data`];
|
|
414
416
|
data !== undefined ? handler.call(node, data, e) : handler.call(node, e);
|
|
415
417
|
if (e.cancelBubble) return;
|
|
416
418
|
}
|
|
417
|
-
node
|
|
419
|
+
node.host && typeof node.host !== "string" && !node.host._$host && node.contains(e.target) && retarget(node.host);
|
|
420
|
+
return true;
|
|
421
|
+
};
|
|
422
|
+
const walkUpTree = () => {
|
|
423
|
+
while (handleNode() && (node = node._$host || node.parentNode || node.host));
|
|
424
|
+
};
|
|
425
|
+
Object.defineProperty(e, "currentTarget", {
|
|
426
|
+
configurable: true,
|
|
427
|
+
get() {
|
|
428
|
+
return node || document;
|
|
429
|
+
}
|
|
430
|
+
});
|
|
431
|
+
if (solidJs.sharedConfig.registry && !solidJs.sharedConfig.done) solidJs.sharedConfig.done = _$HY.done = true;
|
|
432
|
+
if (e.composedPath) {
|
|
433
|
+
const path = e.composedPath();
|
|
434
|
+
retarget(path[0]);
|
|
435
|
+
for (let i = 0; i < path.length - 2; i++) {
|
|
436
|
+
node = path[i];
|
|
437
|
+
if (!handleNode()) break;
|
|
438
|
+
if (node._$host) {
|
|
439
|
+
node = node._$host;
|
|
440
|
+
walkUpTree();
|
|
441
|
+
break;
|
|
442
|
+
}
|
|
443
|
+
if (node.parentNode === oriCurrentTarget) {
|
|
444
|
+
break;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
418
447
|
}
|
|
448
|
+
else walkUpTree();
|
|
449
|
+
retarget(oriTarget);
|
|
419
450
|
}
|
|
420
451
|
function insertExpression(parent, value, current, marker, unwrapArray) {
|
|
421
452
|
const hydrating = isHydrating(parent);
|
|
@@ -757,6 +788,7 @@ exports.resolveSSRNode = resolveSSRNode;
|
|
|
757
788
|
exports.runHydrationEvents = runHydrationEvents;
|
|
758
789
|
exports.setAttribute = setAttribute;
|
|
759
790
|
exports.setAttributeNS = setAttributeNS;
|
|
791
|
+
exports.setBoolAttribute = setBoolAttribute;
|
|
760
792
|
exports.setProperty = setProperty;
|
|
761
793
|
exports.spread = spread;
|
|
762
794
|
exports.ssr = ssr;
|