@solidjs/web 2.0.0-experimental.4 → 2.0.0-experimental.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.
- package/dist/dev.cjs +20 -16
- package/dist/dev.js +94 -634
- package/dist/server.cjs +40 -43
- package/dist/server.js +132 -655
- package/dist/web.cjs +20 -16
- package/dist/web.js +92 -622
- package/package.json +3 -3
- package/storage/dist/storage.js +3 -3
- package/types/client.d.ts +2 -11
- package/types/core.d.ts +2 -11
- package/types/index.d.ts +5 -8
- package/types/server-mock.d.ts +26 -33
package/dist/server.cjs
CHANGED
|
@@ -49,6 +49,8 @@ const SVGNamespace = {
|
|
|
49
49
|
};
|
|
50
50
|
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"]);
|
|
51
51
|
|
|
52
|
+
const memo = fn => solidJs.createMemo(() => fn());
|
|
53
|
+
|
|
52
54
|
const ES2017FLAG = seroval.Feature.AggregateError
|
|
53
55
|
| seroval.Feature.BigIntTypedArray;
|
|
54
56
|
const GLOBAL_IDENTIFIER = '_$HY.r';
|
|
@@ -78,12 +80,15 @@ const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menui
|
|
|
78
80
|
const REPLACE_SCRIPT = `function $df(e,n,o,t){if(n=document.getElementById(e),o=document.getElementById("pl-"+e)){for(;o&&8!==o.nodeType&&o.nodeValue!=="pl-"+e;)t=o.nextSibling,o.remove(),o=t;_$HY.done?o.remove():o.replaceWith(n.content)}n.remove(),_$HY.fe(e)}`;
|
|
79
81
|
function renderToString(code, options = {}) {
|
|
80
82
|
const {
|
|
81
|
-
renderId
|
|
83
|
+
renderId = "",
|
|
84
|
+
nonce,
|
|
85
|
+
noScripts
|
|
82
86
|
} = options;
|
|
83
87
|
let scripts = "";
|
|
84
88
|
const serializer = createSerializer({
|
|
85
89
|
scopeId: renderId,
|
|
86
90
|
onData(script) {
|
|
91
|
+
if (noScripts) return;
|
|
87
92
|
if (!scripts) {
|
|
88
93
|
scripts = getLocalHeaderScript(renderId);
|
|
89
94
|
}
|
|
@@ -92,23 +97,22 @@ function renderToString(code, options = {}) {
|
|
|
92
97
|
onError: options.onError
|
|
93
98
|
});
|
|
94
99
|
solidJs.sharedConfig.context = {
|
|
95
|
-
id: renderId
|
|
96
|
-
|
|
97
|
-
suspense: {},
|
|
98
|
-
lazy: {},
|
|
100
|
+
id: renderId,
|
|
101
|
+
resources: {},
|
|
99
102
|
assets: [],
|
|
100
|
-
nonce
|
|
103
|
+
nonce,
|
|
104
|
+
resolve(value) {
|
|
105
|
+
return resolveSSRNode(escape(value));
|
|
106
|
+
},
|
|
101
107
|
serialize(id, p) {
|
|
102
108
|
!solidJs.sharedConfig.context.noHydrate && serializer.write(id, p);
|
|
103
|
-
},
|
|
104
|
-
roots: 0,
|
|
105
|
-
nextRoot() {
|
|
106
|
-
return this.renderId + "i-" + this.roots++;
|
|
107
109
|
}
|
|
108
110
|
};
|
|
109
111
|
let html = solidJs.createRoot(d => {
|
|
110
112
|
setTimeout(d);
|
|
111
113
|
return resolveSSRNode(escape(code()));
|
|
114
|
+
}, {
|
|
115
|
+
id: renderId
|
|
112
116
|
});
|
|
113
117
|
solidJs.sharedConfig.context.noHydrate = true;
|
|
114
118
|
serializer.close();
|
|
@@ -116,25 +120,12 @@ function renderToString(code, options = {}) {
|
|
|
116
120
|
if (scripts.length) html = injectScripts(html, scripts, options.nonce);
|
|
117
121
|
return html;
|
|
118
122
|
}
|
|
119
|
-
function renderToStringAsync(code, options = {}) {
|
|
120
|
-
const {
|
|
121
|
-
timeoutMs = 30000
|
|
122
|
-
} = options;
|
|
123
|
-
let timeoutHandle;
|
|
124
|
-
const timeout = new Promise((_, reject) => {
|
|
125
|
-
timeoutHandle = setTimeout(() => reject("renderToString timed out"), timeoutMs);
|
|
126
|
-
});
|
|
127
|
-
return Promise.race([renderToStream(code, options), timeout]).then(html => {
|
|
128
|
-
clearTimeout(timeoutHandle);
|
|
129
|
-
return html;
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
123
|
function renderToStream(code, options = {}) {
|
|
133
124
|
let {
|
|
134
125
|
nonce,
|
|
135
126
|
onCompleteShell,
|
|
136
127
|
onCompleteAll,
|
|
137
|
-
renderId,
|
|
128
|
+
renderId = "",
|
|
138
129
|
noScripts
|
|
139
130
|
} = options;
|
|
140
131
|
let dispose;
|
|
@@ -196,12 +187,9 @@ function renderToStream(code, options = {}) {
|
|
|
196
187
|
}
|
|
197
188
|
};
|
|
198
189
|
solidJs.sharedConfig.context = context = {
|
|
199
|
-
id: renderId
|
|
200
|
-
count: 0,
|
|
190
|
+
id: renderId,
|
|
201
191
|
async: true,
|
|
202
192
|
resources: {},
|
|
203
|
-
lazy: {},
|
|
204
|
-
suspense: {},
|
|
205
193
|
assets: [],
|
|
206
194
|
nonce,
|
|
207
195
|
block(p) {
|
|
@@ -226,9 +214,8 @@ function renderToStream(code, options = {}) {
|
|
|
226
214
|
});
|
|
227
215
|
} else if (!serverOnly) serializer.write(id, p);
|
|
228
216
|
},
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
return this.renderId + "i-" + this.roots++;
|
|
217
|
+
resolve(value) {
|
|
218
|
+
return resolveSSRNode(escape(value));
|
|
232
219
|
},
|
|
233
220
|
registerFragment(key) {
|
|
234
221
|
if (!registry.has(key)) {
|
|
@@ -267,6 +254,8 @@ function renderToStream(code, options = {}) {
|
|
|
267
254
|
let html = solidJs.createRoot(d => {
|
|
268
255
|
dispose = d;
|
|
269
256
|
return resolveSSRNode(escape(code()));
|
|
257
|
+
}, {
|
|
258
|
+
id: renderId
|
|
270
259
|
});
|
|
271
260
|
function doShell() {
|
|
272
261
|
if (shellCompleted) return;
|
|
@@ -440,7 +429,7 @@ function ssrAttribute(key, value, isBoolean) {
|
|
|
440
429
|
}
|
|
441
430
|
function ssrHydrationKey() {
|
|
442
431
|
const hk = getHydrationKey();
|
|
443
|
-
return hk ? `
|
|
432
|
+
return hk ? ` _hk=${hk}` : "";
|
|
444
433
|
}
|
|
445
434
|
function escape(s, attr) {
|
|
446
435
|
const t = typeof s;
|
|
@@ -502,7 +491,13 @@ function resolveSSRNode(node, top) {
|
|
|
502
491
|
return mapped;
|
|
503
492
|
}
|
|
504
493
|
if (t === "object") return node.t;
|
|
505
|
-
if (t === "function")
|
|
494
|
+
if (t === "function") {
|
|
495
|
+
try {
|
|
496
|
+
return resolveSSRNode(node());
|
|
497
|
+
} catch (err) {
|
|
498
|
+
if (!solidJs.ssrHandleError(err)) throw err;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
506
501
|
return String(node);
|
|
507
502
|
}
|
|
508
503
|
function mergeProps(...sources) {
|
|
@@ -545,7 +540,7 @@ function generateHydrationScript({
|
|
|
545
540
|
eventNames = ["click", "input"],
|
|
546
541
|
nonce
|
|
547
542
|
} = {}) {
|
|
548
|
-
return `<script${nonce ? ` nonce="${nonce}"` : ""}>window._$HY||(e=>{let t=e=>e&&e.hasAttribute&&(e.hasAttribute("
|
|
543
|
+
return `<script${nonce ? ` nonce="${nonce}"` : ""}>window._$HY||(e=>{let t=e=>e&&e.hasAttribute&&(e.hasAttribute("_hk")?e:t(e.host&&e.host.nodeType?e.host:e.parentNode));["${eventNames.join('", "')}"].forEach((o=>document.addEventListener(o,(o=>{if(!e.events)return;let s=t(o.composedPath&&o.composedPath()[0]||o.target);s&&!e.completed.has(s)&&e.events.push([s,o])}))))})(_$HY={events:[],completed:new WeakSet,r:{},fe(){}});</script><!--xs-->`;
|
|
549
544
|
}
|
|
550
545
|
function Hydration(props) {
|
|
551
546
|
if (!solidJs.sharedConfig.context.noHydrate) return props.children;
|
|
@@ -561,8 +556,14 @@ function Hydration(props) {
|
|
|
561
556
|
return res;
|
|
562
557
|
}
|
|
563
558
|
function NoHydration(props) {
|
|
564
|
-
|
|
565
|
-
|
|
559
|
+
let context = solidJs.sharedConfig.context;
|
|
560
|
+
if (context) solidJs.sharedConfig.context = {
|
|
561
|
+
...context,
|
|
562
|
+
noHydrate: true
|
|
563
|
+
};
|
|
564
|
+
const res = props.children;
|
|
565
|
+
if (context) solidJs.sharedConfig.context = context;
|
|
566
|
+
return res;
|
|
566
567
|
}
|
|
567
568
|
function queue(fn) {
|
|
568
569
|
return Promise.resolve().then(fn);
|
|
@@ -622,8 +623,8 @@ const RequestContext = Symbol();
|
|
|
622
623
|
function getRequestEvent() {
|
|
623
624
|
return globalThis[RequestContext] ? globalThis[RequestContext].getStore() || solidJs.sharedConfig.context && solidJs.sharedConfig.context.event || console.log("RequestEvent is missing. This is most likely due to accessing `getRequestEvent` non-managed async scope in a partially polyfilled environment. Try moving it above all `await` calls.") : undefined;
|
|
624
625
|
}
|
|
625
|
-
function
|
|
626
|
-
|
|
626
|
+
function renderToStringAsync(code, options = {}) {
|
|
627
|
+
return renderToStream(code, options).then(html => html);
|
|
627
628
|
}
|
|
628
629
|
function notSup() {
|
|
629
630
|
throw new Error("Client-only API called on the server side. Run client-only code in onMount, or conditionally run client-only component with <Show>.");
|
|
@@ -688,15 +689,10 @@ Object.defineProperty(exports, "getOwner", {
|
|
|
688
689
|
enumerable: true,
|
|
689
690
|
get: function () { return solidJs.getOwner; }
|
|
690
691
|
});
|
|
691
|
-
Object.defineProperty(exports, "memo", {
|
|
692
|
-
enumerable: true,
|
|
693
|
-
get: function () { return solidJs.createMemo; }
|
|
694
|
-
});
|
|
695
692
|
Object.defineProperty(exports, "untrack", {
|
|
696
693
|
enumerable: true,
|
|
697
694
|
get: function () { return solidJs.untrack; }
|
|
698
695
|
});
|
|
699
|
-
exports.Assets = Assets;
|
|
700
696
|
exports.ChildProperties = ChildProperties;
|
|
701
697
|
exports.DOMElements = DOMElements;
|
|
702
698
|
exports.DelegatedEvents = DelegatedEvents;
|
|
@@ -728,6 +724,7 @@ exports.hydrate = notSup;
|
|
|
728
724
|
exports.insert = notSup;
|
|
729
725
|
exports.isDev = isDev;
|
|
730
726
|
exports.isServer = isServer;
|
|
727
|
+
exports.memo = memo;
|
|
731
728
|
exports.mergeProps = mergeProps;
|
|
732
729
|
exports.render = notSup;
|
|
733
730
|
exports.renderToStream = renderToStream;
|