@solidjs/web 2.0.0-beta.7 → 2.0.0-beta.9
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/README.md +27 -4
- package/dist/dev.cjs +79 -44
- package/dist/dev.js +79 -46
- package/dist/server.cjs +43 -29
- package/dist/server.js +42 -30
- package/dist/web.cjs +74 -39
- package/dist/web.js +74 -41
- package/package.json +6 -7
- package/storage/types/src/index.d.ts +81 -18
- package/storage/types/src/server-mock.d.ts +57 -0
- package/storage/types-cjs/src/index.d.cts +81 -18
- package/storage/types-cjs/src/server-mock.d.cts +57 -0
- package/types/client.d.ts +20 -9
- package/types/core.d.ts +2 -2
- package/types/index.d.ts +81 -18
- package/types/server-mock.d.ts +57 -0
- package/types/server.d.ts +23 -10
- package/types-cjs/client.d.cts +20 -9
- package/types-cjs/core.d.cts +2 -2
- package/types-cjs/index.d.cts +81 -18
- package/types-cjs/server-mock.d.cts +57 -0
- package/types-cjs/server.d.cts +23 -10
package/README.md
CHANGED
|
@@ -1,7 +1,30 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @solidjs/web
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Solid 2.0's web platform runtime — DOM rendering, hydration, server-side rendering, and the web-only control-flow components (`Portal`, `Dynamic`).
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
> **Solid 2.0 (experimental beta).** In 1.x this package was the `solid-js/web` subpath; in 2.0 it's a separate `@solidjs/web` package.
|
|
6
|
+
>
|
|
7
|
+
> See [`solid-js`'s CHEATSHEET](https://github.com/solidjs/solid/blob/next/packages/solid/CHEATSHEET.md) and [MIGRATION guide](https://github.com/solidjs/solid/blob/next/documentation/solid-2.0/MIGRATION.md) for the 2.0 surface.
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
## Entry points
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
// Browser / hydration
|
|
13
|
+
import { render, hydrate, Portal, Dynamic, dynamic } from "@solidjs/web";
|
|
14
|
+
|
|
15
|
+
// Server (SSR)
|
|
16
|
+
import {
|
|
17
|
+
renderToString,
|
|
18
|
+
renderToStringAsync,
|
|
19
|
+
renderToStream,
|
|
20
|
+
isServer
|
|
21
|
+
} from "@solidjs/web";
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
The control-flow components from `solid-js` (`For`, `Show`, `Switch`/`Match`, `Loading`, `Errored`, `Repeat`, `Reveal`) are also re-exported from `@solidjs/web` for convenience.
|
|
25
|
+
|
|
26
|
+
## More
|
|
27
|
+
|
|
28
|
+
- [Documentation](https://docs.solidjs.com)
|
|
29
|
+
- [Cheatsheet (2.0 public API)](https://github.com/solidjs/solid/blob/next/packages/solid/CHEATSHEET.md)
|
|
30
|
+
- [Migration guide (1.x → 2.0)](https://github.com/solidjs/solid/blob/next/documentation/solid-2.0/MIGRATION.md)
|
package/dist/dev.cjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var solidJs = require('solid-js');
|
|
4
|
-
var signals = require('@solidjs/signals');
|
|
5
4
|
|
|
6
5
|
const DOMWithState = {
|
|
7
6
|
INPUT: {
|
|
@@ -45,16 +44,20 @@ const Namespaces = {
|
|
|
45
44
|
xlink: "http://www.w3.org/1999/xlink",
|
|
46
45
|
xml: "http://www.w3.org/XML/1998/namespace"
|
|
47
46
|
};
|
|
47
|
+
const VoidElements = /*#__PURE__*/new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]);
|
|
48
|
+
const RawTextElements = /*#__PURE__*/new Set(["style", "script", "noscript", "template", "textarea", "title"]);
|
|
48
49
|
const DOMElements = /*#__PURE__*/new Set(["html", "base", "head", "link", "meta", "style", "title", "body", "address", "article", "aside", "footer", "header", "main", "nav", "section", "body", "blockquote", "dd", "div", "dl", "dt", "figcaption", "figure", "hr", "li", "ol", "p", "pre", "ul", "a", "abbr", "b", "bdi", "bdo", "br", "cite", "code", "data", "dfn", "em", "i", "kbd", "mark", "q", "rp", "rt", "ruby", "s", "samp", "small", "span", "strong", "sub", "sup", "time", "u", "var", "wbr", "area", "audio", "img", "map", "track", "video", "embed", "iframe", "object", "param", "picture", "portal", "source", "svg", "math", "canvas", "noscript", "script", "del", "ins", "caption", "col", "colgroup", "table", "tbody", "td", "tfoot", "th", "thead", "tr", "button", "datalist", "fieldset", "form", "input", "label", "legend", "meter", "optgroup", "option", "output", "progress", "select", "textarea", "details", "dialog", "menu", "summary", "details", "slot", "template", "acronym", "applet", "basefont", "bgsound", "big", "blink", "center", "content", "dir", "font", "frame", "frameset", "hgroup", "image", "keygen", "marquee", "menuitem", "nobr", "noembed", "noframes", "plaintext", "rb", "rtc", "shadow", "spacer", "strike", "tt", "xmp", "a", "abbr", "acronym", "address", "applet", "area", "article", "aside", "audio", "b", "base", "basefont", "bdi", "bdo", "bgsound", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "em", "embed", "fieldset", "figcaption", "figure", "font", "footer", "form", "frame", "frameset", "head", "header", "hgroup", "hr", "html", "i", "iframe", "image", "img", "input", "ins", "kbd", "keygen", "label", "legend", "li", "link", "main", "map", "mark", "marquee", "menu", "menuitem", "meta", "meter", "nav", "nobr", "noembed", "noframes", "noscript", "object", "ol", "optgroup", "option", "output", "p", "param", "picture", "plaintext", "portal", "pre", "progress", "q", "rb", "rp", "rt", "rtc", "ruby", "s", "samp", "script", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "track", "tt", "u", "ul", "var", "video", "wbr", "xmp", "input", "h1", "h2", "h3", "h4", "h5", "h6",
|
|
49
50
|
"webview",
|
|
50
51
|
"isindex", "listing", "multicol", "nextid", "noindex", "search"]);
|
|
51
52
|
|
|
52
|
-
const
|
|
53
|
+
const transparentOptions = {
|
|
53
54
|
transparent: true
|
|
54
|
-
}
|
|
55
|
-
const
|
|
56
|
-
transparent: true
|
|
57
|
-
|
|
55
|
+
};
|
|
56
|
+
const effect = (fn, effectFn, options) => solidJs.createRenderEffect(fn, effectFn, options ? {
|
|
57
|
+
transparent: true,
|
|
58
|
+
...options
|
|
59
|
+
} : transparentOptions);
|
|
60
|
+
const memo = fn => solidJs.createMemo(() => fn());
|
|
58
61
|
|
|
59
62
|
function reconcileArrays(parentNode, a, b) {
|
|
60
63
|
let bLength = b.length,
|
|
@@ -114,6 +117,7 @@ function reconcileArrays(parentNode, a, b) {
|
|
|
114
117
|
}
|
|
115
118
|
|
|
116
119
|
const $$EVENTS = "_$DX_DELEGATE";
|
|
120
|
+
const INNER_OWNED = {};
|
|
117
121
|
function render$1(code, element, init, options = {}) {
|
|
118
122
|
if (!element) {
|
|
119
123
|
throw new Error("The `element` passed to `render(..., element)` doesn't exist. Make sure `element` exists in the document.");
|
|
@@ -122,7 +126,12 @@ function render$1(code, element, init, options = {}) {
|
|
|
122
126
|
let disposer;
|
|
123
127
|
solidJs.createRoot(dispose => {
|
|
124
128
|
disposer = dispose;
|
|
125
|
-
element === document
|
|
129
|
+
if (element === document) {
|
|
130
|
+
solidJs.flatten(code);
|
|
131
|
+
} else {
|
|
132
|
+
const tree = code();
|
|
133
|
+
insert(element, () => tree, renderRoot.firstChild ? null : undefined, init, options.insertOptions);
|
|
134
|
+
}
|
|
126
135
|
}, {
|
|
127
136
|
id: options.renderId
|
|
128
137
|
});
|
|
@@ -169,7 +178,7 @@ function setAttribute(node, name, value) {
|
|
|
169
178
|
}
|
|
170
179
|
function setAttributeNS(node, namespace, name, value) {
|
|
171
180
|
if (isHydrating(node)) return;
|
|
172
|
-
if (value == null || value === false) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value === true ? "" : value);
|
|
181
|
+
if (value == null || value === false) node.removeAttributeNS(namespace, name.indexOf(":") > -1 ? name.split(":").pop() : name);else node.setAttributeNS(namespace, name, value === true ? "" : value);
|
|
173
182
|
}
|
|
174
183
|
function className(node, value, prev) {
|
|
175
184
|
if (isHydrating(node)) return;
|
|
@@ -221,7 +230,6 @@ function style(node, value, prev) {
|
|
|
221
230
|
if (typeof value === "string") return nodeStyle.cssText = value;
|
|
222
231
|
typeof prev === "string" && (nodeStyle.cssText = prev = undefined);
|
|
223
232
|
prev || (prev = {});
|
|
224
|
-
value || (value = {});
|
|
225
233
|
let v, s;
|
|
226
234
|
for (s in value) {
|
|
227
235
|
v = value[s];
|
|
@@ -267,7 +275,7 @@ function ref(fn, element) {
|
|
|
267
275
|
const resolved = solidJs.untrack(fn);
|
|
268
276
|
solidJs.runWithOwner(null, () => applyRef(resolved, element));
|
|
269
277
|
}
|
|
270
|
-
function insert(parent, accessor, marker, initial) {
|
|
278
|
+
function insert(parent, accessor, marker, initial, options) {
|
|
271
279
|
const childRoot = getChildRoot(parent);
|
|
272
280
|
const multi = marker !== undefined;
|
|
273
281
|
if (multi && !initial) initial = [];
|
|
@@ -285,13 +293,25 @@ function insert(parent, accessor, marker, initial) {
|
|
|
285
293
|
accessor = normalize(accessor, initial, multi, true);
|
|
286
294
|
if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
|
|
287
295
|
}
|
|
288
|
-
accessor = memo(accessor, true);
|
|
289
296
|
if (multi && initial.length === 0) {
|
|
290
297
|
const placeholder = document.createTextNode("");
|
|
291
298
|
childRoot.insertBefore(placeholder, marker);
|
|
292
299
|
initial = [placeholder];
|
|
293
300
|
}
|
|
294
|
-
|
|
301
|
+
let current = initial;
|
|
302
|
+
effect(() => {
|
|
303
|
+
const value = normalize(accessor(), current, multi, true);
|
|
304
|
+
if (typeof value !== "function") return value;
|
|
305
|
+
effect(() => normalize(value, current, multi), inner => {
|
|
306
|
+
insertExpression(parent, inner, current, marker);
|
|
307
|
+
current = inner;
|
|
308
|
+
}, options);
|
|
309
|
+
return INNER_OWNED;
|
|
310
|
+
}, value => {
|
|
311
|
+
if (value === INNER_OWNED) return;
|
|
312
|
+
insertExpression(parent, value, current, marker);
|
|
313
|
+
current = value;
|
|
314
|
+
}, options);
|
|
295
315
|
}
|
|
296
316
|
function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
|
|
297
317
|
const nodeName = node.nodeName;
|
|
@@ -711,18 +731,22 @@ function ssrHydrationKey() {}
|
|
|
711
731
|
function resolveSSRNode(node) {}
|
|
712
732
|
function escape(html) {}
|
|
713
733
|
|
|
714
|
-
function render(...args) {
|
|
715
|
-
solidJs.enforceLoadingBoundary(true);
|
|
716
|
-
const result = render$1(...args);
|
|
717
|
-
solidJs.enforceLoadingBoundary(false);
|
|
718
|
-
return result;
|
|
719
|
-
}
|
|
720
734
|
const isServer = false;
|
|
721
735
|
const isDev = true;
|
|
722
|
-
function
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
736
|
+
function render(code, element, init, options = {}) {
|
|
737
|
+
solidJs.enforceLoadingBoundary(true);
|
|
738
|
+
try {
|
|
739
|
+
const dispose = render$1(code, element, init, {
|
|
740
|
+
...options,
|
|
741
|
+
insertOptions: {
|
|
742
|
+
schedule: true
|
|
743
|
+
}
|
|
744
|
+
});
|
|
745
|
+
solidJs.flush();
|
|
746
|
+
return dispose;
|
|
747
|
+
} finally {
|
|
748
|
+
solidJs.enforceLoadingBoundary(false);
|
|
749
|
+
}
|
|
726
750
|
}
|
|
727
751
|
const hydrate = (...args) => {
|
|
728
752
|
solidJs.enableHydration();
|
|
@@ -748,6 +772,36 @@ function Portal(props) {
|
|
|
748
772
|
});
|
|
749
773
|
return treeMarker;
|
|
750
774
|
}
|
|
775
|
+
function dynamic(source) {
|
|
776
|
+
const cached = solidJs.createMemo(source, {
|
|
777
|
+
lazy: true
|
|
778
|
+
});
|
|
779
|
+
return props => {
|
|
780
|
+
return solidJs.createMemo(() => {
|
|
781
|
+
const component = cached();
|
|
782
|
+
switch (typeof component) {
|
|
783
|
+
case "function":
|
|
784
|
+
Object.assign(component, {
|
|
785
|
+
[solidJs.$DEVCOMP]: true
|
|
786
|
+
});
|
|
787
|
+
return solidJs.untrack(() => component(props));
|
|
788
|
+
case "string":
|
|
789
|
+
const el = solidJs.sharedConfig.hydrating ? getNextElement() : createElement(component, solidJs.untrack(() => props.is));
|
|
790
|
+
spread(el, props);
|
|
791
|
+
return el;
|
|
792
|
+
}
|
|
793
|
+
});
|
|
794
|
+
};
|
|
795
|
+
}
|
|
796
|
+
function Dynamic(props) {
|
|
797
|
+
const Comp = dynamic(() => props.component);
|
|
798
|
+
return solidJs.createComponent(Comp, solidJs.omit(props, "component"));
|
|
799
|
+
}
|
|
800
|
+
function createElement(tagName, is = undefined) {
|
|
801
|
+
return SVGElements.has(tagName) ? document.createElementNS(Namespaces.svg, tagName) : MathMLElements.has(tagName) ? document.createElementNS(Namespaces.mathml, tagName) : document.createElement(tagName, {
|
|
802
|
+
is
|
|
803
|
+
});
|
|
804
|
+
}
|
|
751
805
|
function createElementProxy(el, marker) {
|
|
752
806
|
return new Proxy(el, {
|
|
753
807
|
get(target, prop) {
|
|
@@ -765,27 +819,6 @@ function createElementProxy(el, marker) {
|
|
|
765
819
|
}
|
|
766
820
|
});
|
|
767
821
|
}
|
|
768
|
-
function createDynamic(component, props) {
|
|
769
|
-
const cached = solidJs.createMemo(component);
|
|
770
|
-
return solidJs.createMemo(() => {
|
|
771
|
-
const component = cached();
|
|
772
|
-
switch (typeof component) {
|
|
773
|
-
case "function":
|
|
774
|
-
Object.assign(component, {
|
|
775
|
-
[solidJs.$DEVCOMP]: true
|
|
776
|
-
});
|
|
777
|
-
return solidJs.untrack(() => component(props));
|
|
778
|
-
case "string":
|
|
779
|
-
const el = solidJs.sharedConfig.hydrating ? getNextElement() : createElement(component, solidJs.untrack(() => props.is));
|
|
780
|
-
spread(el, props);
|
|
781
|
-
return el;
|
|
782
|
-
}
|
|
783
|
-
});
|
|
784
|
-
}
|
|
785
|
-
function Dynamic(props) {
|
|
786
|
-
const others = solidJs.omit(props, "component");
|
|
787
|
-
return createDynamic(() => props.component, others);
|
|
788
|
-
}
|
|
789
822
|
|
|
790
823
|
Object.defineProperty(exports, "Errored", {
|
|
791
824
|
enumerable: true,
|
|
@@ -853,15 +886,17 @@ exports.HydrationScript = voidFn;
|
|
|
853
886
|
exports.MathMLElements = MathMLElements;
|
|
854
887
|
exports.Namespaces = Namespaces;
|
|
855
888
|
exports.Portal = Portal;
|
|
889
|
+
exports.RawTextElements = RawTextElements;
|
|
856
890
|
exports.RequestContext = RequestContext;
|
|
857
891
|
exports.SVGElements = SVGElements;
|
|
892
|
+
exports.VoidElements = VoidElements;
|
|
858
893
|
exports.addEventListener = addEventListener;
|
|
859
894
|
exports.applyRef = applyRef;
|
|
860
895
|
exports.assign = assign;
|
|
861
896
|
exports.className = className;
|
|
862
897
|
exports.clearDelegatedEvents = clearDelegatedEvents;
|
|
863
|
-
exports.createDynamic = createDynamic;
|
|
864
898
|
exports.delegateEvents = delegateEvents;
|
|
899
|
+
exports.dynamic = dynamic;
|
|
865
900
|
exports.dynamicProperty = dynamicProperty;
|
|
866
901
|
exports.effect = effect;
|
|
867
902
|
exports.escape = escape;
|
package/dist/dev.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { createRenderEffect, createMemo
|
|
1
|
+
import { createRenderEffect, createMemo, sharedConfig, untrack, runWithOwner, flatten, createRoot, createComponent, omit, $DEVCOMP, enableHydration, enforceLoadingBoundary, flush } from 'solid-js';
|
|
2
2
|
export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
|
|
3
|
-
import { createMemo } from '@solidjs/signals';
|
|
4
3
|
|
|
5
4
|
const DOMWithState = {
|
|
6
5
|
INPUT: {
|
|
@@ -44,16 +43,20 @@ const Namespaces = {
|
|
|
44
43
|
xlink: "http://www.w3.org/1999/xlink",
|
|
45
44
|
xml: "http://www.w3.org/XML/1998/namespace"
|
|
46
45
|
};
|
|
46
|
+
const VoidElements = /*#__PURE__*/new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]);
|
|
47
|
+
const RawTextElements = /*#__PURE__*/new Set(["style", "script", "noscript", "template", "textarea", "title"]);
|
|
47
48
|
const DOMElements = /*#__PURE__*/new Set(["html", "base", "head", "link", "meta", "style", "title", "body", "address", "article", "aside", "footer", "header", "main", "nav", "section", "body", "blockquote", "dd", "div", "dl", "dt", "figcaption", "figure", "hr", "li", "ol", "p", "pre", "ul", "a", "abbr", "b", "bdi", "bdo", "br", "cite", "code", "data", "dfn", "em", "i", "kbd", "mark", "q", "rp", "rt", "ruby", "s", "samp", "small", "span", "strong", "sub", "sup", "time", "u", "var", "wbr", "area", "audio", "img", "map", "track", "video", "embed", "iframe", "object", "param", "picture", "portal", "source", "svg", "math", "canvas", "noscript", "script", "del", "ins", "caption", "col", "colgroup", "table", "tbody", "td", "tfoot", "th", "thead", "tr", "button", "datalist", "fieldset", "form", "input", "label", "legend", "meter", "optgroup", "option", "output", "progress", "select", "textarea", "details", "dialog", "menu", "summary", "details", "slot", "template", "acronym", "applet", "basefont", "bgsound", "big", "blink", "center", "content", "dir", "font", "frame", "frameset", "hgroup", "image", "keygen", "marquee", "menuitem", "nobr", "noembed", "noframes", "plaintext", "rb", "rtc", "shadow", "spacer", "strike", "tt", "xmp", "a", "abbr", "acronym", "address", "applet", "area", "article", "aside", "audio", "b", "base", "basefont", "bdi", "bdo", "bgsound", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "em", "embed", "fieldset", "figcaption", "figure", "font", "footer", "form", "frame", "frameset", "head", "header", "hgroup", "hr", "html", "i", "iframe", "image", "img", "input", "ins", "kbd", "keygen", "label", "legend", "li", "link", "main", "map", "mark", "marquee", "menu", "menuitem", "meta", "meter", "nav", "nobr", "noembed", "noframes", "noscript", "object", "ol", "optgroup", "option", "output", "p", "param", "picture", "plaintext", "portal", "pre", "progress", "q", "rb", "rp", "rt", "rtc", "ruby", "s", "samp", "script", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "track", "tt", "u", "ul", "var", "video", "wbr", "xmp", "input", "h1", "h2", "h3", "h4", "h5", "h6",
|
|
48
49
|
"webview",
|
|
49
50
|
"isindex", "listing", "multicol", "nextid", "noindex", "search"]);
|
|
50
51
|
|
|
51
|
-
const
|
|
52
|
+
const transparentOptions = {
|
|
52
53
|
transparent: true
|
|
53
|
-
}
|
|
54
|
-
const
|
|
55
|
-
transparent: true
|
|
56
|
-
|
|
54
|
+
};
|
|
55
|
+
const effect = (fn, effectFn, options) => createRenderEffect(fn, effectFn, options ? {
|
|
56
|
+
transparent: true,
|
|
57
|
+
...options
|
|
58
|
+
} : transparentOptions);
|
|
59
|
+
const memo = fn => createMemo(() => fn());
|
|
57
60
|
|
|
58
61
|
function reconcileArrays(parentNode, a, b) {
|
|
59
62
|
let bLength = b.length,
|
|
@@ -113,6 +116,7 @@ function reconcileArrays(parentNode, a, b) {
|
|
|
113
116
|
}
|
|
114
117
|
|
|
115
118
|
const $$EVENTS = "_$DX_DELEGATE";
|
|
119
|
+
const INNER_OWNED = {};
|
|
116
120
|
function render$1(code, element, init, options = {}) {
|
|
117
121
|
if (!element) {
|
|
118
122
|
throw new Error("The `element` passed to `render(..., element)` doesn't exist. Make sure `element` exists in the document.");
|
|
@@ -121,7 +125,12 @@ function render$1(code, element, init, options = {}) {
|
|
|
121
125
|
let disposer;
|
|
122
126
|
createRoot(dispose => {
|
|
123
127
|
disposer = dispose;
|
|
124
|
-
element === document
|
|
128
|
+
if (element === document) {
|
|
129
|
+
flatten(code);
|
|
130
|
+
} else {
|
|
131
|
+
const tree = code();
|
|
132
|
+
insert(element, () => tree, renderRoot.firstChild ? null : undefined, init, options.insertOptions);
|
|
133
|
+
}
|
|
125
134
|
}, {
|
|
126
135
|
id: options.renderId
|
|
127
136
|
});
|
|
@@ -168,7 +177,7 @@ function setAttribute(node, name, value) {
|
|
|
168
177
|
}
|
|
169
178
|
function setAttributeNS(node, namespace, name, value) {
|
|
170
179
|
if (isHydrating(node)) return;
|
|
171
|
-
if (value == null || value === false) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value === true ? "" : value);
|
|
180
|
+
if (value == null || value === false) node.removeAttributeNS(namespace, name.indexOf(":") > -1 ? name.split(":").pop() : name);else node.setAttributeNS(namespace, name, value === true ? "" : value);
|
|
172
181
|
}
|
|
173
182
|
function className(node, value, prev) {
|
|
174
183
|
if (isHydrating(node)) return;
|
|
@@ -220,7 +229,6 @@ function style(node, value, prev) {
|
|
|
220
229
|
if (typeof value === "string") return nodeStyle.cssText = value;
|
|
221
230
|
typeof prev === "string" && (nodeStyle.cssText = prev = undefined);
|
|
222
231
|
prev || (prev = {});
|
|
223
|
-
value || (value = {});
|
|
224
232
|
let v, s;
|
|
225
233
|
for (s in value) {
|
|
226
234
|
v = value[s];
|
|
@@ -266,7 +274,7 @@ function ref(fn, element) {
|
|
|
266
274
|
const resolved = untrack(fn);
|
|
267
275
|
runWithOwner(null, () => applyRef(resolved, element));
|
|
268
276
|
}
|
|
269
|
-
function insert(parent, accessor, marker, initial) {
|
|
277
|
+
function insert(parent, accessor, marker, initial, options) {
|
|
270
278
|
const childRoot = getChildRoot(parent);
|
|
271
279
|
const multi = marker !== undefined;
|
|
272
280
|
if (multi && !initial) initial = [];
|
|
@@ -284,13 +292,25 @@ function insert(parent, accessor, marker, initial) {
|
|
|
284
292
|
accessor = normalize(accessor, initial, multi, true);
|
|
285
293
|
if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
|
|
286
294
|
}
|
|
287
|
-
accessor = memo(accessor, true);
|
|
288
295
|
if (multi && initial.length === 0) {
|
|
289
296
|
const placeholder = document.createTextNode("");
|
|
290
297
|
childRoot.insertBefore(placeholder, marker);
|
|
291
298
|
initial = [placeholder];
|
|
292
299
|
}
|
|
293
|
-
|
|
300
|
+
let current = initial;
|
|
301
|
+
effect(() => {
|
|
302
|
+
const value = normalize(accessor(), current, multi, true);
|
|
303
|
+
if (typeof value !== "function") return value;
|
|
304
|
+
effect(() => normalize(value, current, multi), inner => {
|
|
305
|
+
insertExpression(parent, inner, current, marker);
|
|
306
|
+
current = inner;
|
|
307
|
+
}, options);
|
|
308
|
+
return INNER_OWNED;
|
|
309
|
+
}, value => {
|
|
310
|
+
if (value === INNER_OWNED) return;
|
|
311
|
+
insertExpression(parent, value, current, marker);
|
|
312
|
+
current = value;
|
|
313
|
+
}, options);
|
|
294
314
|
}
|
|
295
315
|
function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
|
|
296
316
|
const nodeName = node.nodeName;
|
|
@@ -710,18 +730,22 @@ function ssrHydrationKey() {}
|
|
|
710
730
|
function resolveSSRNode(node) {}
|
|
711
731
|
function escape(html) {}
|
|
712
732
|
|
|
713
|
-
function render(...args) {
|
|
714
|
-
enforceLoadingBoundary(true);
|
|
715
|
-
const result = render$1(...args);
|
|
716
|
-
enforceLoadingBoundary(false);
|
|
717
|
-
return result;
|
|
718
|
-
}
|
|
719
733
|
const isServer = false;
|
|
720
734
|
const isDev = true;
|
|
721
|
-
function
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
735
|
+
function render(code, element, init, options = {}) {
|
|
736
|
+
enforceLoadingBoundary(true);
|
|
737
|
+
try {
|
|
738
|
+
const dispose = render$1(code, element, init, {
|
|
739
|
+
...options,
|
|
740
|
+
insertOptions: {
|
|
741
|
+
schedule: true
|
|
742
|
+
}
|
|
743
|
+
});
|
|
744
|
+
flush();
|
|
745
|
+
return dispose;
|
|
746
|
+
} finally {
|
|
747
|
+
enforceLoadingBoundary(false);
|
|
748
|
+
}
|
|
725
749
|
}
|
|
726
750
|
const hydrate = (...args) => {
|
|
727
751
|
enableHydration();
|
|
@@ -732,7 +756,7 @@ function Portal(props) {
|
|
|
732
756
|
startMarker = document.createTextNode(""),
|
|
733
757
|
endMarker = document.createTextNode(""),
|
|
734
758
|
mount = () => createElementProxy(props.mount || document.body, treeMarker);
|
|
735
|
-
let content = createMemo
|
|
759
|
+
let content = createMemo(() => [startMarker, props.children]);
|
|
736
760
|
createRenderEffect(() => [mount(), content()], ([m, c]) => {
|
|
737
761
|
m.appendChild(endMarker);
|
|
738
762
|
insert(m, c, endMarker);
|
|
@@ -747,6 +771,36 @@ function Portal(props) {
|
|
|
747
771
|
});
|
|
748
772
|
return treeMarker;
|
|
749
773
|
}
|
|
774
|
+
function dynamic(source) {
|
|
775
|
+
const cached = createMemo(source, {
|
|
776
|
+
lazy: true
|
|
777
|
+
});
|
|
778
|
+
return props => {
|
|
779
|
+
return createMemo(() => {
|
|
780
|
+
const component = cached();
|
|
781
|
+
switch (typeof component) {
|
|
782
|
+
case "function":
|
|
783
|
+
Object.assign(component, {
|
|
784
|
+
[$DEVCOMP]: true
|
|
785
|
+
});
|
|
786
|
+
return untrack(() => component(props));
|
|
787
|
+
case "string":
|
|
788
|
+
const el = sharedConfig.hydrating ? getNextElement() : createElement(component, untrack(() => props.is));
|
|
789
|
+
spread(el, props);
|
|
790
|
+
return el;
|
|
791
|
+
}
|
|
792
|
+
});
|
|
793
|
+
};
|
|
794
|
+
}
|
|
795
|
+
function Dynamic(props) {
|
|
796
|
+
const Comp = dynamic(() => props.component);
|
|
797
|
+
return createComponent(Comp, omit(props, "component"));
|
|
798
|
+
}
|
|
799
|
+
function createElement(tagName, is = undefined) {
|
|
800
|
+
return SVGElements.has(tagName) ? document.createElementNS(Namespaces.svg, tagName) : MathMLElements.has(tagName) ? document.createElementNS(Namespaces.mathml, tagName) : document.createElement(tagName, {
|
|
801
|
+
is
|
|
802
|
+
});
|
|
803
|
+
}
|
|
750
804
|
function createElementProxy(el, marker) {
|
|
751
805
|
return new Proxy(el, {
|
|
752
806
|
get(target, prop) {
|
|
@@ -764,26 +818,5 @@ function createElementProxy(el, marker) {
|
|
|
764
818
|
}
|
|
765
819
|
});
|
|
766
820
|
}
|
|
767
|
-
function createDynamic(component, props) {
|
|
768
|
-
const cached = createMemo$1(component);
|
|
769
|
-
return createMemo$1(() => {
|
|
770
|
-
const component = cached();
|
|
771
|
-
switch (typeof component) {
|
|
772
|
-
case "function":
|
|
773
|
-
Object.assign(component, {
|
|
774
|
-
[$DEVCOMP]: true
|
|
775
|
-
});
|
|
776
|
-
return untrack(() => component(props));
|
|
777
|
-
case "string":
|
|
778
|
-
const el = sharedConfig.hydrating ? getNextElement() : createElement(component, untrack(() => props.is));
|
|
779
|
-
spread(el, props);
|
|
780
|
-
return el;
|
|
781
|
-
}
|
|
782
|
-
});
|
|
783
|
-
}
|
|
784
|
-
function Dynamic(props) {
|
|
785
|
-
const others = omit(props, "component");
|
|
786
|
-
return createDynamic(() => props.component, others);
|
|
787
|
-
}
|
|
788
821
|
|
|
789
|
-
export { voidFn as Assets, ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, voidFn as HydrationScript, MathMLElements, Namespaces, Portal, RequestContext, SVGElements, addEventListener, applyRef, assign, className, clearDelegatedEvents,
|
|
822
|
+
export { voidFn as Assets, ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, voidFn as HydrationScript, MathMLElements, Namespaces, Portal, RawTextElements, RequestContext, SVGElements, VoidElements, addEventListener, applyRef, assign, className, clearDelegatedEvents, delegateEvents, dynamic, dynamicProperty, effect, escape, voidFn as generateHydrationScript, voidFn as getAssets, getFirstChild, getHydrationKey, getNextElement, getNextMarker, getNextMatch, getNextSibling, voidFn as getRequestEvent, hydrate, insert, isDev, isServer, memo, ref, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrStyle, style, template, voidFn as useAssets };
|