solid-js 1.8.22 → 1.9.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 +7 -6
- package/dist/dev.js +567 -325
- package/dist/server.cjs +1 -1
- package/dist/server.js +169 -75
- package/dist/solid.cjs +7 -6
- package/dist/solid.js +494 -283
- package/h/dist/h.js +40 -9
- package/h/jsx-runtime/dist/jsx.js +1 -1
- package/h/jsx-runtime/types/index.d.ts +13 -10
- package/h/jsx-runtime/types/jsx.d.ts +22 -1
- package/h/types/hyperscript.d.ts +11 -11
- package/h/types/index.d.ts +1 -1
- package/html/dist/html.cjs +4 -2
- package/html/dist/html.js +222 -95
- package/html/types/index.d.ts +1 -1
- package/html/types/lit.d.ts +52 -33
- package/package.json +1 -5
- package/store/dist/dev.cjs +1 -1
- package/store/dist/dev.js +123 -43
- package/store/dist/server.cjs +4 -0
- package/store/dist/server.js +23 -8
- package/store/dist/store.cjs +1 -1
- package/store/dist/store.js +114 -40
- package/store/package.json +0 -4
- package/store/types/index.d.ts +21 -7
- package/store/types/modifiers.d.ts +6 -3
- package/store/types/mutable.d.ts +5 -2
- package/store/types/server.d.ts +26 -5
- package/store/types/store.d.ts +219 -62
- package/types/index.d.ts +75 -10
- package/types/jsx.d.ts +35 -8
- package/types/reactive/array.d.ts +12 -4
- package/types/reactive/observable.d.ts +25 -17
- package/types/reactive/scheduler.d.ts +9 -6
- package/types/reactive/signal.d.ts +236 -143
- package/types/render/Suspense.d.ts +5 -5
- package/types/render/component.d.ts +64 -33
- package/types/render/flow.d.ts +43 -31
- package/types/render/hydration.d.ts +15 -15
- package/types/server/index.d.ts +57 -2
- package/types/server/reactive.d.ts +73 -42
- package/types/server/rendering.d.ts +169 -98
- package/universal/dist/dev.js +28 -12
- package/universal/dist/universal.js +28 -12
- package/universal/types/index.d.ts +3 -1
- package/universal/types/universal.d.ts +0 -1
- package/web/dist/dev.cjs +57 -24
- package/web/dist/dev.js +679 -101
- package/web/dist/server.cjs +96 -15
- package/web/dist/server.js +676 -105
- package/web/dist/web.cjs +53 -23
- package/web/dist/web.js +664 -99
- package/web/package.json +0 -4
- package/web/storage/dist/storage.js +3 -3
- package/web/types/client.d.ts +5 -3
- package/web/types/core.d.ts +10 -1
- package/web/types/index.d.ts +27 -10
- package/web/types/server-mock.d.ts +47 -32
- package/web/types/server.d.ts +88 -0
package/h/dist/h.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
spread,
|
|
3
|
+
assign,
|
|
4
|
+
insert,
|
|
5
|
+
createComponent,
|
|
6
|
+
dynamicProperty,
|
|
7
|
+
SVGElements
|
|
8
|
+
} from "solid-js/web";
|
|
2
9
|
|
|
3
10
|
const $ELEMENT = Symbol("hyper-element");
|
|
4
11
|
function createHyperScript(r) {
|
|
@@ -19,9 +26,18 @@ function createHyperScript(r) {
|
|
|
19
26
|
return ret;
|
|
20
27
|
function item(l) {
|
|
21
28
|
const type = typeof l;
|
|
22
|
-
if (l == null)
|
|
23
|
-
|
|
24
|
-
|
|
29
|
+
if (l == null);
|
|
30
|
+
else if ("string" === type) {
|
|
31
|
+
if (!e) parseClass(l);
|
|
32
|
+
else e.appendChild(document.createTextNode(l));
|
|
33
|
+
} else if (
|
|
34
|
+
"number" === type ||
|
|
35
|
+
"boolean" === type ||
|
|
36
|
+
"bigint" === type ||
|
|
37
|
+
"symbol" === type ||
|
|
38
|
+
l instanceof Date ||
|
|
39
|
+
l instanceof RegExp
|
|
40
|
+
) {
|
|
25
41
|
e.appendChild(document.createTextNode(l.toString()));
|
|
26
42
|
} else if (Array.isArray(l)) {
|
|
27
43
|
for (let i = 0; i < l.length; i++) item(l[i]);
|
|
@@ -33,7 +49,10 @@ function createHyperScript(r) {
|
|
|
33
49
|
for (const k in d) {
|
|
34
50
|
if (k === "class" && classes.length !== 0) {
|
|
35
51
|
const fixedClasses = classes.join(" "),
|
|
36
|
-
value =
|
|
52
|
+
value =
|
|
53
|
+
typeof d["class"].value === "function"
|
|
54
|
+
? () => fixedClasses + " " + d["class"].value()
|
|
55
|
+
: fixedClasses + " " + l["class"];
|
|
37
56
|
Object.defineProperty(l, "class", {
|
|
38
57
|
...d[k],
|
|
39
58
|
value
|
|
@@ -45,12 +64,18 @@ function createHyperScript(r) {
|
|
|
45
64
|
dynamic = true;
|
|
46
65
|
} else if (d[k].get) dynamic = true;
|
|
47
66
|
}
|
|
48
|
-
dynamic
|
|
67
|
+
dynamic
|
|
68
|
+
? r.spread(e, l, e instanceof SVGElement, !!args.length)
|
|
69
|
+
: r.assign(e, l, e instanceof SVGElement, !!args.length);
|
|
49
70
|
} else if ("function" === type) {
|
|
50
71
|
if (!e) {
|
|
51
72
|
let props,
|
|
52
73
|
next = args[0];
|
|
53
|
-
if (
|
|
74
|
+
if (
|
|
75
|
+
next == null ||
|
|
76
|
+
(typeof next === "object" && !Array.isArray(next) && !(next instanceof Element))
|
|
77
|
+
)
|
|
78
|
+
props = args.shift();
|
|
54
79
|
props || (props = {});
|
|
55
80
|
if (args.length) {
|
|
56
81
|
props.children = args.length > 1 ? args : args[0];
|
|
@@ -66,7 +91,8 @@ function createHyperScript(r) {
|
|
|
66
91
|
return list;
|
|
67
92
|
};
|
|
68
93
|
r.dynamicProperty(props, k);
|
|
69
|
-
} else if (typeof d[k].value === "function" && !d[k].value.length)
|
|
94
|
+
} else if (typeof d[k].value === "function" && !d[k].value.length)
|
|
95
|
+
r.dynamicProperty(props, k);
|
|
70
96
|
}
|
|
71
97
|
e = r.createComponent(l, props);
|
|
72
98
|
args = [];
|
|
@@ -83,7 +109,12 @@ function createHyperScript(r) {
|
|
|
83
109
|
const v = m[i],
|
|
84
110
|
s = v.substring(1, v.length);
|
|
85
111
|
if (!v) continue;
|
|
86
|
-
if (!e)
|
|
112
|
+
if (!e)
|
|
113
|
+
e = r.SVGElements.has(v)
|
|
114
|
+
? document.createElementNS("http://www.w3.org/2000/svg", v)
|
|
115
|
+
: document.createElement(v);
|
|
116
|
+
else if (v[0] === ".") classes.push(s);
|
|
117
|
+
else if (v[0] === "#") e.setAttribute("id", s);
|
|
87
118
|
}
|
|
88
119
|
}
|
|
89
120
|
function detectMultiExpression(list) {
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
export type { JSX } from "./jsx";
|
|
2
|
-
import type { JSX } from "./jsx";
|
|
3
|
-
declare function Fragment(props: {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
})
|
|
1
|
+
export type { JSX } from "./jsx.d.ts";
|
|
2
|
+
import type { JSX } from "./jsx.d.ts";
|
|
3
|
+
declare function Fragment(props: { children: JSX.Element }): JSX.Element;
|
|
4
|
+
declare function jsx(
|
|
5
|
+
type: any,
|
|
6
|
+
props: any
|
|
7
|
+
): () =>
|
|
8
|
+
| (Node & {
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
})
|
|
11
|
+
| (Node & {
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
})[];
|
|
11
14
|
export { jsx, jsx as jsxs, jsx as jsxDEV, Fragment };
|
|
@@ -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/hyperscript.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
type MountableElement = Element | Document | ShadowRoot | DocumentFragment | Node;
|
|
2
2
|
interface Runtime {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
insert(parent: MountableElement, accessor: any, marker?: Node | null, init?: any): any;
|
|
4
|
+
spread(node: Element, accessor: any, isSVG?: Boolean, skipChildren?: Boolean): void;
|
|
5
|
+
assign(node: Element, props: any, isSVG?: Boolean, skipChildren?: Boolean): void;
|
|
6
|
+
createComponent(Comp: (props: any) => any, props: any): any;
|
|
7
|
+
dynamicProperty(props: any, key: string): any;
|
|
8
|
+
SVGElements: Set<string>;
|
|
9
9
|
}
|
|
10
10
|
type ExpandableNode = Node & {
|
|
11
|
-
|
|
11
|
+
[key: string]: any;
|
|
12
12
|
};
|
|
13
13
|
export type HyperScript = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
(...args: any[]): () => ExpandableNode | ExpandableNode[];
|
|
15
|
+
Fragment: (props: {
|
|
16
|
+
children: (() => ExpandableNode) | (() => ExpandableNode)[];
|
|
17
|
+
}) => ExpandableNode[];
|
|
18
18
|
};
|
|
19
19
|
export declare function createHyperScript(r: Runtime): HyperScript;
|
|
20
20
|
export {};
|
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++}`;
|