@solidjs/web 2.0.0-beta.30 → 2.0.0-beta.32
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 +1 -6
- package/dist/dev.cjs +284 -82
- package/dist/dev.js +271 -79
- package/dist/server.cjs +555 -135
- package/dist/server.js +544 -132
- package/dist/web.cjs +281 -79
- package/dist/web.js +268 -76
- package/frames/dist/client.cjs +413 -360
- package/frames/dist/client.dev.cjs +413 -360
- package/frames/dist/client.dev.js +414 -361
- package/frames/dist/client.js +414 -361
- package/frames/dist/server.cjs +604 -199
- package/frames/dist/server.js +605 -201
- package/package.json +56 -6
- package/serialization/dist/serialization.cjs +8 -0
- package/serialization/dist/serialization.js +1 -0
- package/serialization/types/index.d.ts +173 -6
- package/serialization/types-cjs/index.d.cts +173 -6
- package/server-functions/dist/client.cjs +46 -9
- package/server-functions/dist/client.js +47 -11
- package/server-functions/dist/rich-args.cjs +11 -0
- package/server-functions/dist/rich-args.js +9 -0
- package/server-functions/dist/server.cjs +275 -126
- package/server-functions/dist/server.dev.cjs +1053 -0
- package/server-functions/dist/server.dev.js +1021 -0
- package/server-functions/dist/server.js +273 -127
- package/server-functions/package.json +10 -0
- package/server-functions/rich-args/package.json +20 -0
- package/storage/types/index.d.ts +1 -1
- package/storage/types-cjs/index.d.cts +1 -1
- package/types/client.d.ts +134 -11
- package/types/core.d.ts +3 -1
- package/types/frames/client.d.ts +24 -8
- package/types/frames/frame-client.d.ts +49 -7
- package/types/frames/frame-sink.d.ts +32 -6
- package/types/frames/frame-transport.d.ts +88 -62
- package/types/frames/serializer.d.ts +173 -6
- package/types/frames/server.d.ts +22 -0
- package/types/index.d.ts +2 -3
- package/types/jsx.d.ts +3 -3
- package/types/response.d.ts +45 -0
- package/types/serializer.d.ts +173 -6
- package/types/server-functions/client.d.ts +1 -0
- package/types/server-functions/rich-args.d.ts +10 -0
- package/types/server-functions/server.d.ts +98 -0
- package/types/server-functions/shared.d.ts +22 -0
- package/types/server-mock.d.ts +171 -59
- package/types/server.d.ts +196 -42
- package/types-cjs/client.d.cts +134 -11
- package/types-cjs/core.d.cts +3 -1
- package/types-cjs/frames/client.d.cts +24 -8
- package/types-cjs/frames/frame-client.d.cts +49 -7
- package/types-cjs/frames/frame-sink.d.cts +32 -6
- package/types-cjs/frames/frame-transport.d.cts +88 -62
- package/types-cjs/frames/serializer.d.cts +173 -6
- package/types-cjs/frames/server.d.cts +22 -0
- package/types-cjs/index.d.cts +2 -3
- package/types-cjs/jsx.d.cts +3 -3
- package/types-cjs/response.d.cts +45 -0
- package/types-cjs/serializer.d.cts +173 -6
- package/types-cjs/server-functions/client.d.cts +1 -0
- package/types-cjs/server-functions/rich-args.d.cts +10 -0
- package/types-cjs/server-functions/server.d.cts +98 -0
- package/types-cjs/server-functions/shared.d.cts +22 -0
- package/types-cjs/server-mock.d.cts +171 -59
- package/types-cjs/server.d.cts +196 -42
package/dist/web.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createRenderEffect, createMemo, sharedConfig, untrack,
|
|
1
|
+
import { createRenderEffect, createMemo, runWithOwner, sharedConfig, untrack, flatten, createRoot, merge, createComponent, omit, createOwner, createSignal, onCleanup, enableHydration, flush, getOwner, createEffect } from 'solid-js';
|
|
2
2
|
export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, untrack } from 'solid-js';
|
|
3
3
|
|
|
4
4
|
const DOMWithState = {
|
|
@@ -62,6 +62,17 @@ const effect = (fn, effectFn, options) => createRenderEffect(fn, effectFn, optio
|
|
|
62
62
|
transparent: !options.scope
|
|
63
63
|
} : transparentOptions);
|
|
64
64
|
const memo = fn => createMemo(() => fn(), syncOptions);
|
|
65
|
+
const assetGates = new WeakMap();
|
|
66
|
+
const waitAsset = promise => {
|
|
67
|
+
let gate = assetGates.get(promise);
|
|
68
|
+
if (!gate) {
|
|
69
|
+
runWithOwner(null, () => {
|
|
70
|
+
gate = createMemo(() => promise);
|
|
71
|
+
});
|
|
72
|
+
assetGates.set(promise, gate);
|
|
73
|
+
}
|
|
74
|
+
gate();
|
|
75
|
+
};
|
|
65
76
|
|
|
66
77
|
function reconcileArrays(parentNode, a, b, marker) {
|
|
67
78
|
let bLength = b.length,
|
|
@@ -171,8 +182,9 @@ function reconcileArrays(parentNode, a, b, marker) {
|
|
|
171
182
|
|
|
172
183
|
const HEAD_ELIGIBLE_TAGS = new Set(["title", "meta", "link", "style", "script", "base"]);
|
|
173
184
|
const HEAD_ATTR_NAME = /^[a-zA-Z_][a-zA-Z0-9_:.-]*$/;
|
|
174
|
-
const RESOURCE_LINK_RELS = new Set(["preload", "modulepreload", "prefetch", "preconnect", "dns-prefetch", "
|
|
185
|
+
const RESOURCE_LINK_RELS = new Set(["preload", "modulepreload", "prefetch", "preconnect", "dns-prefetch", "stylesheet"]);
|
|
175
186
|
const RESOURCE_QUALIFIERS = ["as", "crossorigin", "type", "media", "imagesrcset", "imagesizes"];
|
|
187
|
+
const STYLESHEET_FETCH_META = new Set(["crossorigin", "integrity", "referrerpolicy", "fetchpriority"]);
|
|
176
188
|
function evalHeadValue(v) {
|
|
177
189
|
return typeof v === "function" ? v() : v;
|
|
178
190
|
}
|
|
@@ -214,12 +226,14 @@ function replaceableIdentity(tag, props, key, unique) {
|
|
|
214
226
|
if (tag === "meta" && props.charset != null) return "charset";
|
|
215
227
|
if (key != null) return tag + ":key:" + key;
|
|
216
228
|
if (tag === "meta") {
|
|
217
|
-
if (props
|
|
218
|
-
if (props.property != null) return "meta:property:" + props.property;
|
|
219
|
-
if (props["http-equiv"] != null) return "meta:http-equiv:" + props["http-equiv"];
|
|
229
|
+
for (const ns of ["name", "property", "http-equiv"]) if (props[ns] != null) return "meta:" + ns + ":" + props[ns] + (props.media != null ? ":media=" + props.media : "");
|
|
220
230
|
return unique;
|
|
221
231
|
}
|
|
222
|
-
if (tag === "link")
|
|
232
|
+
if (tag === "link") {
|
|
233
|
+
const rel = props.rel || "";
|
|
234
|
+
if (rel === "icon" || rel === "apple-touch-icon") return "link:" + rel + (props.sizes != null ? ":sizes=" + props.sizes : "") + (props.type != null ? ":type=" + props.type : "");
|
|
235
|
+
return "link:" + rel + ":" + (props.href || "");
|
|
236
|
+
}
|
|
223
237
|
return unique;
|
|
224
238
|
}
|
|
225
239
|
function resolveHead(groups) {
|
|
@@ -251,6 +265,43 @@ function resolveHead(groups) {
|
|
|
251
265
|
return winners;
|
|
252
266
|
}
|
|
253
267
|
|
|
268
|
+
function parseCookieHeader(header) {
|
|
269
|
+
const cookies = {};
|
|
270
|
+
if (!header) return cookies;
|
|
271
|
+
for (const part of header.split(";")) {
|
|
272
|
+
const eq = part.indexOf("=");
|
|
273
|
+
if (eq < 0) continue;
|
|
274
|
+
const name = decodeSafe(part.slice(0, eq).trim());
|
|
275
|
+
let value = part.slice(eq + 1).trim();
|
|
276
|
+
if (value.length > 1 && value[0] === '"' && value[value.length - 1] === '"') {
|
|
277
|
+
value = value.slice(1, -1);
|
|
278
|
+
}
|
|
279
|
+
cookies[name] = decodeSafe(value);
|
|
280
|
+
}
|
|
281
|
+
return cookies;
|
|
282
|
+
}
|
|
283
|
+
function decodeSafe(text) {
|
|
284
|
+
try {
|
|
285
|
+
return decodeURIComponent(text);
|
|
286
|
+
} catch {
|
|
287
|
+
return text;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
function serializeCookie(name, value, options = {}) {
|
|
291
|
+
let cookie = `${encodeURIComponent(name)}=${encodeURIComponent(value)}`;
|
|
292
|
+
cookie += `; Path=${options.path === undefined ? "/" : options.path}`;
|
|
293
|
+
if (options.domain) cookie += `; Domain=${options.domain}`;
|
|
294
|
+
if (options.maxAge !== undefined) cookie += `; Max-Age=${Math.trunc(options.maxAge)}`;
|
|
295
|
+
if (options.expires) cookie += `; Expires=${options.expires.toUTCString()}`;
|
|
296
|
+
if (options.httpOnly) cookie += "; HttpOnly";
|
|
297
|
+
if (options.secure) cookie += "; Secure";
|
|
298
|
+
if (options.sameSite) {
|
|
299
|
+
const sameSite = options.sameSite.toLowerCase();
|
|
300
|
+
cookie += `; SameSite=${sameSite === "none" ? "None" : sameSite === "strict" ? "Strict" : "Lax"}`;
|
|
301
|
+
}
|
|
302
|
+
return cookie;
|
|
303
|
+
}
|
|
304
|
+
|
|
254
305
|
const $$EVENT_OWNER = "_$DX_EVENT_OWNER";
|
|
255
306
|
const INNER_OWNED = {};
|
|
256
307
|
const delegatedEvents = new Set();
|
|
@@ -649,6 +700,9 @@ function findAssetElement(selector, attr, value) {
|
|
|
649
700
|
}
|
|
650
701
|
return null;
|
|
651
702
|
}
|
|
703
|
+
function setAssetAttrs(el, attrs) {
|
|
704
|
+
for (const name in attrs) el.setAttribute(name, attrs[name]);
|
|
705
|
+
}
|
|
652
706
|
function mountAssetElement(descriptor) {
|
|
653
707
|
let el;
|
|
654
708
|
if (descriptor.type === "inline-style") {
|
|
@@ -667,12 +721,77 @@ function mountAssetElement(descriptor) {
|
|
|
667
721
|
el.href = descriptor.href;
|
|
668
722
|
}
|
|
669
723
|
}
|
|
670
|
-
if (descriptor.attrs)
|
|
671
|
-
for (const name in descriptor.attrs) el.setAttribute(name, descriptor.attrs[name]);
|
|
672
|
-
}
|
|
724
|
+
if (descriptor.attrs) setAssetAttrs(el, descriptor.attrs);
|
|
673
725
|
if (!el.isConnected) document.head.appendChild(el);
|
|
674
726
|
return el;
|
|
675
727
|
}
|
|
728
|
+
const assetLoadSettled = /*#__PURE__*/Promise.resolve();
|
|
729
|
+
function trackAssetLoad(entry, adopted) {
|
|
730
|
+
if (entry.loadPromise) return;
|
|
731
|
+
const el = entry.element;
|
|
732
|
+
let settled = el.sheet != null;
|
|
733
|
+
if (!settled && adopted && typeof performance !== "undefined" && performance.getEntriesByName) {
|
|
734
|
+
settled = performance.getEntriesByName(el.href).length > 0;
|
|
735
|
+
}
|
|
736
|
+
if (settled) {
|
|
737
|
+
entry.loadState = "loaded";
|
|
738
|
+
entry.loadPromise = assetLoadSettled;
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
741
|
+
entry.loadState = "pending";
|
|
742
|
+
entry.loadPromise = new Promise(resolve => {
|
|
743
|
+
const settle = state => {
|
|
744
|
+
entry.loadState = state;
|
|
745
|
+
resolve();
|
|
746
|
+
};
|
|
747
|
+
el.addEventListener("load", () => settle("loaded"), {
|
|
748
|
+
once: true
|
|
749
|
+
});
|
|
750
|
+
el.addEventListener("error", () => settle("errored"), {
|
|
751
|
+
once: true
|
|
752
|
+
});
|
|
753
|
+
});
|
|
754
|
+
}
|
|
755
|
+
function warmAsset(descriptor) {
|
|
756
|
+
if (descriptor.policy === "exclusive" || descriptor.type === "inline-style") return;
|
|
757
|
+
const key = assetEntryKey(descriptor);
|
|
758
|
+
let entry = assetRegistry.get(key);
|
|
759
|
+
if (!entry) {
|
|
760
|
+
entry = {
|
|
761
|
+
count: 0,
|
|
762
|
+
element: null,
|
|
763
|
+
timer: null
|
|
764
|
+
};
|
|
765
|
+
assetRegistry.set(key, entry);
|
|
766
|
+
}
|
|
767
|
+
let adopted = true;
|
|
768
|
+
if (!entry.element || !entry.element.isConnected) {
|
|
769
|
+
const rel = descriptor.type === "module" ? "modulepreload" : "stylesheet";
|
|
770
|
+
let el = findAssetElement(`link[rel="${rel}"]`, "href", descriptor.href);
|
|
771
|
+
if (!el && descriptor.type === "style") {
|
|
772
|
+
el = findAssetElement('link[rel="preload"][as="style"]', "href", descriptor.href);
|
|
773
|
+
}
|
|
774
|
+
if (!el) {
|
|
775
|
+
adopted = false;
|
|
776
|
+
el = document.createElement("link");
|
|
777
|
+
if (descriptor.type === "style") {
|
|
778
|
+
el.setAttribute("rel", "preload");
|
|
779
|
+
el.setAttribute("as", "style");
|
|
780
|
+
} else {
|
|
781
|
+
el.setAttribute("rel", "modulepreload");
|
|
782
|
+
}
|
|
783
|
+
el.setAttribute("href", descriptor.href);
|
|
784
|
+
if (!document.body) el.setAttribute("blocking", "render");
|
|
785
|
+
}
|
|
786
|
+
if (descriptor.attrs) setAssetAttrs(el, descriptor.attrs);
|
|
787
|
+
if (!el.isConnected) document.head.appendChild(el);
|
|
788
|
+
entry.element = el;
|
|
789
|
+
entry.loadState = undefined;
|
|
790
|
+
entry.loadPromise = undefined;
|
|
791
|
+
}
|
|
792
|
+
if (descriptor.type === "style") trackAssetLoad(entry, adopted);
|
|
793
|
+
return entry;
|
|
794
|
+
}
|
|
676
795
|
function acquireAsset(descriptor) {
|
|
677
796
|
const key = assetEntryKey(descriptor);
|
|
678
797
|
let entry = assetRegistry.get(key);
|
|
@@ -719,7 +838,12 @@ function acquireAsset(descriptor) {
|
|
|
719
838
|
entry.timer = null;
|
|
720
839
|
}
|
|
721
840
|
entry.count++;
|
|
722
|
-
if (!entry.element || !entry.element.isConnected)
|
|
841
|
+
if (!entry.element || !entry.element.isConnected) {
|
|
842
|
+
entry.element = mountAssetElement(descriptor);
|
|
843
|
+
} else if (descriptor.type === "style" && entry.element.getAttribute("rel") === "preload") {
|
|
844
|
+
entry.element.removeAttribute("as");
|
|
845
|
+
entry.element.setAttribute("rel", "stylesheet");
|
|
846
|
+
}
|
|
723
847
|
let released = false;
|
|
724
848
|
return () => {
|
|
725
849
|
if (released) return;
|
|
@@ -830,21 +954,25 @@ function flushHeadRegistry() {
|
|
|
830
954
|
headOwned.set(identity, els);
|
|
831
955
|
}
|
|
832
956
|
}
|
|
833
|
-
function
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
}
|
|
837
|
-
const el = document.createElement(t.tag);
|
|
838
|
-
for (const name in t.props) {
|
|
957
|
+
function createHeadElement(tag, props) {
|
|
958
|
+
const el = document.createElement(tag);
|
|
959
|
+
for (const name in props) {
|
|
839
960
|
if (name === "children" || name === "ref" || name.slice(0, 2) === "on") continue;
|
|
840
961
|
if (!HEAD_ATTR_NAME.test(name)) {
|
|
841
962
|
continue;
|
|
842
963
|
}
|
|
843
|
-
const v =
|
|
964
|
+
const v = props[name];
|
|
844
965
|
if (v == null || v === false) continue;
|
|
845
966
|
el.setAttribute(name, v === true ? "" : String(v));
|
|
846
967
|
}
|
|
847
|
-
if (
|
|
968
|
+
if (props.children != null) el.textContent = String(props.children);
|
|
969
|
+
return el;
|
|
970
|
+
}
|
|
971
|
+
function renderHeadElement(t, identity, existing) {
|
|
972
|
+
for (let i = 0; i < existing.length; i++) {
|
|
973
|
+
if (headElementMatches(existing[i], t)) return existing.splice(i, 1)[0];
|
|
974
|
+
}
|
|
975
|
+
const el = createHeadElement(t.tag, t.props);
|
|
848
976
|
el.setAttribute("data-dh", identity);
|
|
849
977
|
document.head.appendChild(el);
|
|
850
978
|
return el;
|
|
@@ -862,48 +990,39 @@ function headElementMatches(el, t) {
|
|
|
862
990
|
const children = t.props.children;
|
|
863
991
|
return (children == null ? "" : String(children)) === el.textContent;
|
|
864
992
|
}
|
|
865
|
-
function
|
|
866
|
-
if (tag === "link" && (props.rel === "stylesheet" || props.rel === "modulepreload")) {
|
|
867
|
-
const descriptor = {
|
|
868
|
-
type: props.rel === "stylesheet" ? "style" : "module",
|
|
869
|
-
href: props.href
|
|
870
|
-
};
|
|
871
|
-
let attrs = null;
|
|
872
|
-
for (const name in props) {
|
|
873
|
-
if (name === "rel" || name === "href") continue;
|
|
874
|
-
if (!HEAD_ATTR_NAME.test(name)) continue;
|
|
875
|
-
const v = props[name];
|
|
876
|
-
if (v == null || v === false) continue;
|
|
877
|
-
(attrs || (attrs = {}))[name] = v === true ? "" : String(v);
|
|
878
|
-
}
|
|
879
|
-
if (attrs) descriptor.attrs = attrs;
|
|
880
|
-
return acquireAsset(descriptor);
|
|
881
|
-
}
|
|
993
|
+
function mountHeadResource(tag, props) {
|
|
882
994
|
const identity = resourceIdentity(tag, props);
|
|
883
|
-
if (headMountedResources.has(identity)) return
|
|
995
|
+
if (headMountedResources.has(identity)) return;
|
|
884
996
|
headMountedResources.add(identity);
|
|
885
997
|
const url = props.href || props.src;
|
|
886
998
|
let el = null;
|
|
887
999
|
if (url != null) {
|
|
888
1000
|
if (tag === "link") el = findAssetElement(`link[rel="${props.rel}"]`, "href", url);else if (tag === "script") el = findAssetElement("script[src]", "src", url);else el = findAssetElement("style[href]", "href", url);
|
|
889
1001
|
}
|
|
890
|
-
if (!el)
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
1002
|
+
if (!el) document.head.appendChild(createHeadElement(tag, props));
|
|
1003
|
+
}
|
|
1004
|
+
function gateHeadResource(props) {
|
|
1005
|
+
const descriptor = {
|
|
1006
|
+
type: props.rel === "stylesheet" ? "style" : "module",
|
|
1007
|
+
href: props.href
|
|
1008
|
+
};
|
|
1009
|
+
let gateable = props.rel === "stylesheet" && props.href != null;
|
|
1010
|
+
let attrs = null;
|
|
1011
|
+
for (const name in props) {
|
|
1012
|
+
if (name === "rel" || name === "href") continue;
|
|
1013
|
+
if (!STYLESHEET_FETCH_META.has(name)) gateable = false;
|
|
1014
|
+
if (!HEAD_ATTR_NAME.test(name)) continue;
|
|
1015
|
+
const v = props[name];
|
|
1016
|
+
if (v == null || v === false) continue;
|
|
1017
|
+
(attrs || (attrs = {}))[name] = v === true ? "" : String(v);
|
|
901
1018
|
}
|
|
902
|
-
|
|
1019
|
+
if (attrs) descriptor.attrs = attrs;
|
|
1020
|
+
effect(() => {
|
|
1021
|
+
const entry = warmAsset(descriptor);
|
|
1022
|
+
if (gateable && entry.loadState === "pending" && typeof waitAsset === "function") waitAsset(entry.loadPromise);
|
|
1023
|
+
}, () => acquireAsset(descriptor));
|
|
903
1024
|
}
|
|
904
|
-
function noopFn() {}
|
|
905
1025
|
function useHead(tags) {
|
|
906
|
-
const list = Array.isArray(tags) ? tags : [tags];
|
|
907
1026
|
initHeadRegistry();
|
|
908
1027
|
const reg = {
|
|
909
1028
|
seq: -1,
|
|
@@ -911,6 +1030,8 @@ function useHead(tags) {
|
|
|
911
1030
|
};
|
|
912
1031
|
const uid = ++headUid;
|
|
913
1032
|
effect(() => {
|
|
1033
|
+
let list = typeof tags === "function" ? tags() : tags;
|
|
1034
|
+
if (!Array.isArray(list)) list = [list];
|
|
914
1035
|
const replaceable = [];
|
|
915
1036
|
const resources = [];
|
|
916
1037
|
for (let i = 0; i < list.length; i++) {
|
|
@@ -923,10 +1044,16 @@ function useHead(tags) {
|
|
|
923
1044
|
rel: cls.rel
|
|
924
1045
|
} : undefined);
|
|
925
1046
|
if (cls.resource) {
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
1047
|
+
if (desc.tag === "link" && (props.rel === "stylesheet" || props.rel === "modulepreload")) {
|
|
1048
|
+
gateHeadResource(props);
|
|
1049
|
+
} else if (desc.tag === "link") {
|
|
1050
|
+
mountHeadResource(desc.tag, props);
|
|
1051
|
+
} else {
|
|
1052
|
+
resources.push({
|
|
1053
|
+
tag: desc.tag,
|
|
1054
|
+
props
|
|
1055
|
+
});
|
|
1056
|
+
}
|
|
930
1057
|
} else {
|
|
931
1058
|
const key = evalHeadValue(desc.key);
|
|
932
1059
|
replaceable.push({
|
|
@@ -941,9 +1068,8 @@ function useHead(tags) {
|
|
|
941
1068
|
resources
|
|
942
1069
|
};
|
|
943
1070
|
}, evaluated => {
|
|
944
|
-
const releases = [];
|
|
945
1071
|
for (let i = 0; i < evaluated.resources.length; i++) {
|
|
946
|
-
|
|
1072
|
+
mountHeadResource(evaluated.resources[i].tag, evaluated.resources[i].props);
|
|
947
1073
|
}
|
|
948
1074
|
reg.tags = evaluated.replaceable;
|
|
949
1075
|
if (reg.seq < 0) reg.seq = ++headSeq;
|
|
@@ -952,7 +1078,6 @@ function useHead(tags) {
|
|
|
952
1078
|
return () => {
|
|
953
1079
|
const idx = headRegistrations.indexOf(reg);
|
|
954
1080
|
if (idx > -1) headRegistrations.splice(idx, 1);
|
|
955
|
-
for (let i = 0; i < releases.length; i++) releases[i]();
|
|
956
1081
|
scheduleHeadApply();
|
|
957
1082
|
};
|
|
958
1083
|
});
|
|
@@ -1388,7 +1513,13 @@ function gatherHydratable(element, root) {
|
|
|
1388
1513
|
for (let i = 0; i < templates.length; i++) {
|
|
1389
1514
|
const node = templates[i];
|
|
1390
1515
|
const key = node.getAttribute("_hk");
|
|
1391
|
-
if (
|
|
1516
|
+
if (root) {
|
|
1517
|
+
if (!key.startsWith(root)) continue;
|
|
1518
|
+
} else {
|
|
1519
|
+
const frame = node.closest("[data-fid]");
|
|
1520
|
+
if (frame && frame !== element && element.contains(frame)) continue;
|
|
1521
|
+
}
|
|
1522
|
+
if (!sharedConfig.registry.has(key)) sharedConfig.registry.set(key, node);
|
|
1392
1523
|
}
|
|
1393
1524
|
}
|
|
1394
1525
|
function getHydrationKey() {
|
|
@@ -1404,20 +1535,37 @@ function throwInBrowser(func) {
|
|
|
1404
1535
|
function renderToString(fn, options) {
|
|
1405
1536
|
throwInBrowser(renderToString);
|
|
1406
1537
|
}
|
|
1407
|
-
function renderToStringAsync(fn, options) {
|
|
1408
|
-
throwInBrowser(renderToStringAsync);
|
|
1409
|
-
}
|
|
1410
1538
|
function renderToStream(fn, options) {
|
|
1411
1539
|
throwInBrowser(renderToStream);
|
|
1412
1540
|
}
|
|
1541
|
+
function createResponseStub() {
|
|
1542
|
+
throwInBrowser(createResponseStub);
|
|
1543
|
+
}
|
|
1544
|
+
function createRequestEvent(request, init) {
|
|
1545
|
+
throwInBrowser(createRequestEvent);
|
|
1546
|
+
}
|
|
1547
|
+
function getExpectedRedirectStatus(response) {
|
|
1548
|
+
throwInBrowser(getExpectedRedirectStatus);
|
|
1549
|
+
}
|
|
1550
|
+
function createSSRResponse() {
|
|
1551
|
+
throwInBrowser(createSSRResponse);
|
|
1552
|
+
}
|
|
1553
|
+
function commitEventResponse(response, event) {
|
|
1554
|
+
throwInBrowser(commitEventResponse);
|
|
1555
|
+
}
|
|
1556
|
+
function composeMiddleware(middlewares) {
|
|
1557
|
+
throwInBrowser(composeMiddleware);
|
|
1558
|
+
}
|
|
1413
1559
|
function ssr(template, ...nodes) {}
|
|
1414
1560
|
function ssrElement(name, props, children, needsId) {}
|
|
1415
|
-
function
|
|
1561
|
+
function ssrClassName(value) {}
|
|
1416
1562
|
function ssrStyle(value) {}
|
|
1563
|
+
function ssrStyleProperty(name, value) {}
|
|
1417
1564
|
function ssrAttribute(key, value) {}
|
|
1565
|
+
function ssrGroup(fn, n) {}
|
|
1418
1566
|
function ssrHydrationKey() {}
|
|
1419
|
-
function resolveSSRNode(node) {}
|
|
1420
|
-
function escape(
|
|
1567
|
+
function resolveSSRNode(node, result, top) {}
|
|
1568
|
+
function escape(s, attr) {}
|
|
1421
1569
|
|
|
1422
1570
|
const ENVELOPE = Symbol.for("solid.ResponseEnvelope");
|
|
1423
1571
|
class ResponseEnvelope {
|
|
@@ -1434,13 +1582,38 @@ const HREF = Symbol.for("solid.Href");
|
|
|
1434
1582
|
function isHref(value) {
|
|
1435
1583
|
return !!(value && (typeof value === "object" || typeof value === "function") && value[HREF]);
|
|
1436
1584
|
}
|
|
1585
|
+
const SAFE_ERROR = Symbol.for("solid.SafeError");
|
|
1586
|
+
function markSafeError(error) {
|
|
1587
|
+
if (error && (typeof error === "object" || typeof error === "function")) {
|
|
1588
|
+
Object.defineProperty(error, SAFE_ERROR, {
|
|
1589
|
+
value: true,
|
|
1590
|
+
enumerable: false,
|
|
1591
|
+
configurable: true
|
|
1592
|
+
});
|
|
1593
|
+
}
|
|
1594
|
+
return error;
|
|
1595
|
+
}
|
|
1596
|
+
function isSafeError(value) {
|
|
1597
|
+
return !!(value && (typeof value === "object" || typeof value === "function") && value[SAFE_ERROR]);
|
|
1598
|
+
}
|
|
1437
1599
|
const REVALIDATE_HEADER = "X-Revalidate";
|
|
1438
1600
|
function initWithRevalidate(init) {
|
|
1439
1601
|
const {
|
|
1440
1602
|
revalidate,
|
|
1441
1603
|
...responseInit
|
|
1442
1604
|
} = init;
|
|
1443
|
-
|
|
1605
|
+
let headers;
|
|
1606
|
+
if (responseInit.headers && responseInit.headers.getSetCookie) {
|
|
1607
|
+
headers = new Headers();
|
|
1608
|
+
responseInit.headers.forEach((value, key) => {
|
|
1609
|
+
if (key !== "set-cookie") headers.append(key, value);
|
|
1610
|
+
});
|
|
1611
|
+
for (const cookie of responseInit.headers.getSetCookie()) {
|
|
1612
|
+
headers.append("Set-Cookie", cookie);
|
|
1613
|
+
}
|
|
1614
|
+
} else {
|
|
1615
|
+
headers = new Headers(responseInit.headers);
|
|
1616
|
+
}
|
|
1444
1617
|
revalidate !== undefined && headers.set(REVALIDATE_HEADER, revalidate.toString());
|
|
1445
1618
|
return {
|
|
1446
1619
|
responseInit,
|
|
@@ -1558,19 +1731,31 @@ function portalImpl(props) {
|
|
|
1558
1731
|
});
|
|
1559
1732
|
return treeMarker;
|
|
1560
1733
|
}
|
|
1561
|
-
const
|
|
1562
|
-
function
|
|
1563
|
-
|
|
1564
|
-
return handoff && handoff.take(prev) ? prev : next;
|
|
1734
|
+
const COMPONENT_BINDING = Symbol.for("dom-expressions.component-binding");
|
|
1735
|
+
function bindingOf(value) {
|
|
1736
|
+
return value !== null && (typeof value === "function" || typeof value === "object") && value[COMPONENT_BINDING] || undefined;
|
|
1565
1737
|
}
|
|
1566
1738
|
function dynamic(source) {
|
|
1567
1739
|
let latest = 0;
|
|
1740
|
+
const sites = new Set();
|
|
1741
|
+
let deliveredAddress;
|
|
1742
|
+
const resolveBinding = (next, prev) => {
|
|
1743
|
+
const binding = bindingOf(next);
|
|
1744
|
+
if (!binding) return next;
|
|
1745
|
+
deliveredAddress = binding.address;
|
|
1746
|
+
const prevBinding = bindingOf(prev);
|
|
1747
|
+
if (prevBinding && prevBinding.component === binding.component) {
|
|
1748
|
+
for (const deliver of sites) deliver(binding.address);
|
|
1749
|
+
return prev;
|
|
1750
|
+
}
|
|
1751
|
+
return next;
|
|
1752
|
+
};
|
|
1568
1753
|
const cached = createMemo(prev => {
|
|
1569
1754
|
const next = source();
|
|
1570
|
-
if (!next || typeof next.then !== "function") return
|
|
1755
|
+
if (!next || typeof next.then !== "function") return resolveBinding(next, prev);
|
|
1571
1756
|
const token = ++latest;
|
|
1572
1757
|
return {
|
|
1573
|
-
then: (onFulfilled, onRejected) => next.then(resolved => onFulfilled(token === latest ?
|
|
1758
|
+
then: (onFulfilled, onRejected) => next.then(resolved => onFulfilled(token === latest ? resolveBinding(resolved, prev) : resolved), onRejected)
|
|
1574
1759
|
};
|
|
1575
1760
|
}, {
|
|
1576
1761
|
lazy: true
|
|
@@ -1580,7 +1765,16 @@ function dynamic(source) {
|
|
|
1580
1765
|
const component = cached();
|
|
1581
1766
|
switch (typeof component) {
|
|
1582
1767
|
case "function":
|
|
1583
|
-
|
|
1768
|
+
{
|
|
1769
|
+
const binding = bindingOf(component);
|
|
1770
|
+
if (binding) {
|
|
1771
|
+
const [address, setAddress] = createSignal(deliveredAddress ?? binding.address);
|
|
1772
|
+
sites.add(setAddress);
|
|
1773
|
+
onCleanup(() => sites.delete(setAddress));
|
|
1774
|
+
return untrack(() => binding.component(props, address));
|
|
1775
|
+
}
|
|
1776
|
+
return untrack(() => component(props));
|
|
1777
|
+
}
|
|
1584
1778
|
case "string":
|
|
1585
1779
|
const el = sharedConfig.hydrating ? getNextElement() : createElement(component, untrack(() => props.is));
|
|
1586
1780
|
spread(el, props);
|
|
@@ -1617,13 +1811,11 @@ _moduleUrl) {
|
|
|
1617
1811
|
if ((Comp = untrack(comp)) && !sharedConfig.hydrating) return Comp(rest);
|
|
1618
1812
|
const [mounted, setMounted] = createSignal(!sharedConfig.hydrating);
|
|
1619
1813
|
const gate = createMemo(() => (Comp = comp(), m = mounted(), untrack(() => Comp && m ? Comp(rest) : props.fallback)));
|
|
1620
|
-
|
|
1621
|
-
setMounted(true);
|
|
1622
|
-
});
|
|
1814
|
+
sharedConfig.onHydrationEnd(() => setMounted(true));
|
|
1623
1815
|
return gate;
|
|
1624
1816
|
};
|
|
1625
1817
|
}
|
|
1626
1818
|
function httpStatus(_code, _text) {}
|
|
1627
1819
|
function httpHeader(_name, _value, _options) {}
|
|
1628
1820
|
|
|
1629
|
-
export {
|
|
1821
|
+
export { ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, voidFn as HydrationScript, MathMLElements, Namespaces, Portal, REVALIDATE_HEADER, RawTextElements, RequestContext, ResponseEnvelope, SAFE_ERROR, SVGElements, VoidElements, acquireAsset, addEvent, applyRef, assign, claimElement, claimElementTree, className, clientOnly, commitEventResponse, composeMiddleware, createRequestEvent, createResponseStub, createSSRResponse, delegateEvents, dynamic, dynamicProperty, effect, escape, voidFn as generateHydrationScript, getDelegatedRoot, getExpectedRedirectStatus, getFirstChild, getHydrationKey, getNextElement, getNextMarker, getNextMatch, getNextSibling, voidFn as getRequestEvent, httpHeader, httpStatus, hydrate, insert, installHydrationRuntime, isDev, isHref, isResponseEnvelope, isSafeError, isServer, markSafeError, memo, mergeProps, parseCookieHeader, redirect, ref, registerDelegatedContainer, registerDelegatedRoot, registerElementClaim, reload, render, renderToStream, renderToString, resolveSSRNode, respond, runHydrationEvents, scope, serializeCookie, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrGroup, ssrHydrationKey, ssrStyle, ssrStyleProperty, style, template, unregisterDelegatedContainer, unregisterDelegatedRoot, useHead, warmAsset };
|