@solidjs/web 2.0.0-experimental.3 → 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 +70 -57
- package/dist/server.js +157 -658
- 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,9 +491,38 @@ 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
|
}
|
|
503
|
+
function mergeProps(...sources) {
|
|
504
|
+
const target = {};
|
|
505
|
+
for (let i = 0; i < sources.length; i++) {
|
|
506
|
+
let source = sources[i];
|
|
507
|
+
if (typeof source === "function") source = source();
|
|
508
|
+
if (source) {
|
|
509
|
+
const descriptors = Object.getOwnPropertyDescriptors(source);
|
|
510
|
+
for (const key in descriptors) {
|
|
511
|
+
if (key in target) continue;
|
|
512
|
+
Object.defineProperty(target, key, {
|
|
513
|
+
enumerable: true,
|
|
514
|
+
get() {
|
|
515
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
516
|
+
const v = (sources[i] || {})[key];
|
|
517
|
+
if (v !== undefined) return v;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
return target;
|
|
525
|
+
}
|
|
508
526
|
function getHydrationKey() {
|
|
509
527
|
const hydrate = solidJs.sharedConfig.context;
|
|
510
528
|
return hydrate && !hydrate.noHydrate && solidJs.sharedConfig.getNextContextId();
|
|
@@ -522,7 +540,7 @@ function generateHydrationScript({
|
|
|
522
540
|
eventNames = ["click", "input"],
|
|
523
541
|
nonce
|
|
524
542
|
} = {}) {
|
|
525
|
-
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-->`;
|
|
526
544
|
}
|
|
527
545
|
function Hydration(props) {
|
|
528
546
|
if (!solidJs.sharedConfig.context.noHydrate) return props.children;
|
|
@@ -538,8 +556,14 @@ function Hydration(props) {
|
|
|
538
556
|
return res;
|
|
539
557
|
}
|
|
540
558
|
function NoHydration(props) {
|
|
541
|
-
|
|
542
|
-
|
|
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;
|
|
543
567
|
}
|
|
544
568
|
function queue(fn) {
|
|
545
569
|
return Promise.resolve().then(fn);
|
|
@@ -599,8 +623,8 @@ const RequestContext = Symbol();
|
|
|
599
623
|
function getRequestEvent() {
|
|
600
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;
|
|
601
625
|
}
|
|
602
|
-
function
|
|
603
|
-
|
|
626
|
+
function renderToStringAsync(code, options = {}) {
|
|
627
|
+
return renderToStream(code, options).then(html => html);
|
|
604
628
|
}
|
|
605
629
|
function notSup() {
|
|
606
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>.");
|
|
@@ -618,11 +642,11 @@ function createDynamic(component, props) {
|
|
|
618
642
|
}
|
|
619
643
|
}
|
|
620
644
|
function Dynamic(props) {
|
|
621
|
-
const
|
|
645
|
+
const others = solidJs.omit(props, "component");
|
|
622
646
|
return createDynamic(() => props.component, others);
|
|
623
647
|
}
|
|
624
648
|
function Portal(props) {
|
|
625
|
-
|
|
649
|
+
throw new Error("Portal is not supported on the server");
|
|
626
650
|
}
|
|
627
651
|
|
|
628
652
|
Object.defineProperty(exports, "ErrorBoundary", {
|
|
@@ -633,14 +657,14 @@ Object.defineProperty(exports, "For", {
|
|
|
633
657
|
enumerable: true,
|
|
634
658
|
get: function () { return solidJs.For; }
|
|
635
659
|
});
|
|
636
|
-
Object.defineProperty(exports, "Index", {
|
|
637
|
-
enumerable: true,
|
|
638
|
-
get: function () { return solidJs.Index; }
|
|
639
|
-
});
|
|
640
660
|
Object.defineProperty(exports, "Match", {
|
|
641
661
|
enumerable: true,
|
|
642
662
|
get: function () { return solidJs.Match; }
|
|
643
663
|
});
|
|
664
|
+
Object.defineProperty(exports, "Repeat", {
|
|
665
|
+
enumerable: true,
|
|
666
|
+
get: function () { return solidJs.Repeat; }
|
|
667
|
+
});
|
|
644
668
|
Object.defineProperty(exports, "Show", {
|
|
645
669
|
enumerable: true,
|
|
646
670
|
get: function () { return solidJs.Show; }
|
|
@@ -649,10 +673,6 @@ Object.defineProperty(exports, "Suspense", {
|
|
|
649
673
|
enumerable: true,
|
|
650
674
|
get: function () { return solidJs.Suspense; }
|
|
651
675
|
});
|
|
652
|
-
Object.defineProperty(exports, "SuspenseList", {
|
|
653
|
-
enumerable: true,
|
|
654
|
-
get: function () { return solidJs.SuspenseList; }
|
|
655
|
-
});
|
|
656
676
|
Object.defineProperty(exports, "Switch", {
|
|
657
677
|
enumerable: true,
|
|
658
678
|
get: function () { return solidJs.Switch; }
|
|
@@ -669,19 +689,10 @@ Object.defineProperty(exports, "getOwner", {
|
|
|
669
689
|
enumerable: true,
|
|
670
690
|
get: function () { return solidJs.getOwner; }
|
|
671
691
|
});
|
|
672
|
-
Object.defineProperty(exports, "memo", {
|
|
673
|
-
enumerable: true,
|
|
674
|
-
get: function () { return solidJs.createMemo; }
|
|
675
|
-
});
|
|
676
|
-
Object.defineProperty(exports, "mergeProps", {
|
|
677
|
-
enumerable: true,
|
|
678
|
-
get: function () { return solidJs.mergeProps; }
|
|
679
|
-
});
|
|
680
692
|
Object.defineProperty(exports, "untrack", {
|
|
681
693
|
enumerable: true,
|
|
682
694
|
get: function () { return solidJs.untrack; }
|
|
683
695
|
});
|
|
684
|
-
exports.Assets = Assets;
|
|
685
696
|
exports.ChildProperties = ChildProperties;
|
|
686
697
|
exports.DOMElements = DOMElements;
|
|
687
698
|
exports.DelegatedEvents = DelegatedEvents;
|
|
@@ -713,6 +724,8 @@ exports.hydrate = notSup;
|
|
|
713
724
|
exports.insert = notSup;
|
|
714
725
|
exports.isDev = isDev;
|
|
715
726
|
exports.isServer = isServer;
|
|
727
|
+
exports.memo = memo;
|
|
728
|
+
exports.mergeProps = mergeProps;
|
|
716
729
|
exports.render = notSup;
|
|
717
730
|
exports.renderToStream = renderToStream;
|
|
718
731
|
exports.renderToString = renderToString;
|