@solidjs/web 2.0.0-beta.32 → 2.0.0-beta.34
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 +58 -16
- package/dist/dev.js +54 -17
- package/dist/server.cjs +714 -75
- package/dist/server.js +711 -78
- package/dist/web.cjs +58 -16
- package/dist/web.js +54 -17
- package/frames/dist/client.cjs +181 -64
- package/frames/dist/client.dev.cjs +185 -64
- package/frames/dist/client.dev.js +183 -62
- package/frames/dist/client.js +179 -62
- package/frames/dist/server.cjs +972 -136
- package/frames/dist/server.js +974 -138
- package/package.json +17 -6
- package/serialization/decode/package.json +20 -0
- package/serialization/dist/decode.cjs +110 -0
- package/serialization/dist/decode.js +104 -0
- package/serialization/dist/serialization.cjs +98 -43
- package/serialization/dist/serialization.js +99 -44
- package/serialization/types/index.d.ts +18 -160
- package/serialization/types/serializer-decode.d.ts +182 -0
- package/serialization/types-cjs/index.d.cts +18 -160
- package/serialization/types-cjs/serializer-decode.d.cts +182 -0
- package/server-functions/dist/client.cjs +101 -105
- package/server-functions/dist/client.js +101 -105
- package/server-functions/dist/server.cjs +131 -107
- package/server-functions/dist/server.dev.cjs +131 -107
- package/server-functions/dist/server.dev.js +132 -108
- package/server-functions/dist/server.js +132 -108
- package/types/client.d.ts +23 -1
- package/types/cookies.d.ts +93 -0
- package/types/core.d.ts +1 -1
- package/types/frames/frame-client.d.ts +26 -0
- package/types/frames/frame-transport.d.ts +1 -1
- package/types/frames/serializer.d.ts +18 -160
- package/types/serializer-decode.d.ts +182 -0
- package/types/serializer.d.ts +18 -160
- package/types/server-functions/client.d.ts +1 -1
- package/types/server-functions/server.d.ts +1 -1
- package/types/server-functions/shared.d.ts +57 -1
- package/types/server.d.ts +21 -1
- package/types-cjs/client.d.cts +23 -1
- package/types-cjs/cookies.d.cts +93 -0
- package/types-cjs/core.d.cts +1 -1
- package/types-cjs/frames/frame-client.d.cts +26 -0
- package/types-cjs/frames/frame-transport.d.cts +1 -1
- package/types-cjs/frames/serializer.d.cts +18 -160
- package/types-cjs/serializer-decode.d.cts +182 -0
- package/types-cjs/serializer.d.cts +18 -160
- package/types-cjs/server-functions/client.d.cts +1 -1
- package/types-cjs/server-functions/server.d.cts +1 -1
- package/types-cjs/server-functions/shared.d.cts +57 -1
- package/types-cjs/server.d.cts +21 -1
package/dist/server.cjs
CHANGED
|
@@ -64,15 +64,74 @@ const effect = (fn, effectFn, options) => solidJs.createRenderEffect(fn, effectF
|
|
|
64
64
|
} : transparentOptions);
|
|
65
65
|
const memo = fn => solidJs.createMemo(() => fn(), syncOptions);
|
|
66
66
|
|
|
67
|
-
const
|
|
68
|
-
const
|
|
69
|
-
|
|
67
|
+
const STATE = Symbol.for("dom-expressions.container-trace-state");
|
|
68
|
+
const state = globalThis[STATE] || (globalThis[STATE] = {
|
|
69
|
+
materialized: new WeakMap(),
|
|
70
|
+
materializedValues: new WeakSet()
|
|
71
|
+
});
|
|
72
|
+
function setContainerTraceResolver(fn) {
|
|
73
|
+
state.resolveTrace = fn;
|
|
74
|
+
}
|
|
75
|
+
const TRACE = Symbol.for("dom-expressions.container-trace");
|
|
76
|
+
function materialize(marker) {
|
|
77
|
+
let value = state.materialized.get(marker.$tr);
|
|
78
|
+
if (value === undefined) {
|
|
79
|
+
value = state.materializeTrace(marker);
|
|
80
|
+
state.materialized.set(marker.$tr, value);
|
|
81
|
+
if (value !== null && typeof value === "object") state.materializedValues.add(value);
|
|
82
|
+
}
|
|
83
|
+
return value;
|
|
84
|
+
}
|
|
85
|
+
function parseTrace(value, ctx) {
|
|
86
|
+
const trace = value[TRACE];
|
|
87
|
+
return {
|
|
88
|
+
a: trace.array ? 1 : 0,
|
|
89
|
+
i: ctx.parse(trace.subscribe())
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
const ContainerTracePlugin = {
|
|
93
|
+
tag: "dom-expressions/container-trace",
|
|
94
|
+
test(value) {
|
|
95
|
+
return value != null && typeof value === "object" && TRACE in value;
|
|
96
|
+
},
|
|
97
|
+
parse: {
|
|
98
|
+
sync() {
|
|
99
|
+
throw new Error("A reactive container can only be serialized by a streaming serializer.");
|
|
100
|
+
},
|
|
101
|
+
async async(value, ctx) {
|
|
102
|
+
const trace = value[TRACE];
|
|
103
|
+
return {
|
|
104
|
+
a: trace.array ? 1 : 0,
|
|
105
|
+
i: await ctx.parse(trace.subscribe())
|
|
106
|
+
};
|
|
107
|
+
},
|
|
108
|
+
stream: parseTrace
|
|
109
|
+
},
|
|
110
|
+
serialize(node, ctx) {
|
|
111
|
+
return "{$tr:" + ctx.serialize(node.i) + ",$ta:" + node.a + "}";
|
|
112
|
+
},
|
|
113
|
+
deserialize(node, ctx) {
|
|
114
|
+
const iterable = ctx.deserialize(node.i);
|
|
115
|
+
const marker = {
|
|
116
|
+
$tr: iterable,
|
|
117
|
+
$ta: node.a
|
|
118
|
+
};
|
|
119
|
+
return state.materializeTrace ? materialize(marker) : marker;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
70
123
|
const DEFAULT_WEB_PLUGINS = Object.freeze([web.AbortSignalPlugin,
|
|
71
124
|
web.CustomEventPlugin, web.DOMExceptionPlugin, web.EventPlugin,
|
|
72
|
-
web.FormDataPlugin, web.HeadersPlugin, web.ReadableStreamPlugin, web.RequestPlugin, web.ResponsePlugin, web.URLSearchParamsPlugin, web.URLPlugin
|
|
125
|
+
web.FormDataPlugin, web.HeadersPlugin, web.ReadableStreamPlugin, web.RequestPlugin, web.ResponsePlugin, web.URLSearchParamsPlugin, web.URLPlugin,
|
|
126
|
+
ContainerTracePlugin]);
|
|
73
127
|
function resolveSerializerPlugins(customPlugins) {
|
|
74
128
|
return customPlugins ? [...customPlugins, ...DEFAULT_WEB_PLUGINS] : [...DEFAULT_WEB_PLUGINS];
|
|
75
129
|
}
|
|
130
|
+
seroval.Feature.RegExp;
|
|
131
|
+
|
|
132
|
+
const DEFAULT_DISABLED_FEATURES = seroval.Feature.AggregateError | seroval.Feature.BigIntTypedArray;
|
|
133
|
+
const serializeOnlyDisabledFeatures = () => process.env.NODE_ENV === "development" ? 0 : seroval.Feature.ErrorPrototypeStack;
|
|
134
|
+
const HYDRATION_GLOBAL = "_$HY.r";
|
|
76
135
|
function createSerializer(options) {
|
|
77
136
|
return new seroval.Serializer({
|
|
78
137
|
...options,
|
|
@@ -99,16 +158,19 @@ function createHydrationSerializer({
|
|
|
99
158
|
function getLocalHeaderScript(id) {
|
|
100
159
|
return seroval.getCrossReferenceHeader(id) + ";";
|
|
101
160
|
}
|
|
102
|
-
seroval.Feature.RegExp;
|
|
103
161
|
|
|
104
162
|
const ENVELOPE = Symbol.for("solid.ResponseEnvelope");
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
163
|
+
// PURE-annotated factory (same convention as solid's MockPromise): the brand
|
|
164
|
+
const ResponseEnvelope = /* @__PURE__ */(() => {
|
|
165
|
+
class ResponseEnvelope {
|
|
166
|
+
constructor(response, value) {
|
|
167
|
+
this.response = response;
|
|
168
|
+
this.value = value;
|
|
169
|
+
}
|
|
109
170
|
}
|
|
110
|
-
|
|
111
|
-
ResponseEnvelope
|
|
171
|
+
ResponseEnvelope.prototype[ENVELOPE] = true;
|
|
172
|
+
return ResponseEnvelope;
|
|
173
|
+
})();
|
|
112
174
|
function isResponseEnvelope(value) {
|
|
113
175
|
return !!(value && typeof value === "object" && value[ENVELOPE]);
|
|
114
176
|
}
|
|
@@ -195,9 +257,18 @@ function respond(value, init = {}) {
|
|
|
195
257
|
}), value);
|
|
196
258
|
}
|
|
197
259
|
|
|
198
|
-
const
|
|
199
|
-
|
|
200
|
-
|
|
260
|
+
const SERVER_FUNCTION_METADATA = Symbol.for("solid.ServerFunctionMetadata");
|
|
261
|
+
function getServerFunctionMetadata(fn) {
|
|
262
|
+
if (typeof fn !== "function") return undefined;
|
|
263
|
+
return fn[SERVER_FUNCTION_METADATA] || undefined;
|
|
264
|
+
}
|
|
265
|
+
function isServerFunction(fn) {
|
|
266
|
+
return typeof fn === "function" && !!fn[SERVER_FUNCTION_METADATA];
|
|
267
|
+
}
|
|
268
|
+
const SERVER_FUNCTION_RPC = Symbol.for("solid.ServerFunctionRPC");
|
|
269
|
+
function getServerFunctionRPC() {
|
|
270
|
+
return globalThis[SERVER_FUNCTION_RPC];
|
|
271
|
+
}
|
|
201
272
|
|
|
202
273
|
function parseCookieHeader(header) {
|
|
203
274
|
const cookies = {};
|
|
@@ -235,6 +306,18 @@ function serializeCookie(name, value, options = {}) {
|
|
|
235
306
|
}
|
|
236
307
|
return cookie;
|
|
237
308
|
}
|
|
309
|
+
const FLASH_COOKIE = "flash";
|
|
310
|
+
const FLASH_MATCHER = new RegExp(`(?:^|;\\s*)${FLASH_COOKIE}=([^;]+)`);
|
|
311
|
+
function hasFlashCookie(cookieHeader) {
|
|
312
|
+
return !!cookieHeader && FLASH_MATCHER.test(cookieHeader);
|
|
313
|
+
}
|
|
314
|
+
function clearFlashCookie() {
|
|
315
|
+
return `${FLASH_COOKIE}=; Max-Age=0; Path=/`;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
const ERROR_HEADER = "X-Server-Function-Error";
|
|
319
|
+
const BODY_FORMAT_HEADER = "X-Server-Function-Format";
|
|
320
|
+
const SINGLE_FLIGHT_HEADER = "X-Single-Flight";
|
|
238
321
|
|
|
239
322
|
const HEAD_ELIGIBLE_TAGS = new Set(["title", "meta", "link", "style", "script", "base"]);
|
|
240
323
|
const HEAD_ATTR_NAME = /^[a-zA-Z_][a-zA-Z0-9_:.-]*$/;
|
|
@@ -306,7 +389,6 @@ function resolveHead(groups) {
|
|
|
306
389
|
}
|
|
307
390
|
for (const [identity, tags] of byIdentity) {
|
|
308
391
|
if (identity === "title") {
|
|
309
|
-
if (tags.length > 1) console.warn("Multiple <title> tags in one head group; the last one wins.");
|
|
310
392
|
winners.set(identity, {
|
|
311
393
|
seq: group.seq,
|
|
312
394
|
tags: [tags[tags.length - 1]]
|
|
@@ -496,7 +578,6 @@ function registerHeadTags(registry, context, tracking, emitResource, nonce, tags
|
|
|
496
578
|
for (let i = 0; i < tags.length; i++) {
|
|
497
579
|
const desc = tags[i];
|
|
498
580
|
if (!desc || !HEAD_ELIGIBLE_TAGS.has(desc.tag)) {
|
|
499
|
-
console.warn(`useHead: ignoring non-head tag`, desc);
|
|
500
581
|
continue;
|
|
501
582
|
}
|
|
502
583
|
const cls = classifyHeadTag(desc);
|
|
@@ -548,7 +629,6 @@ function headShellReady(registry, block) {
|
|
|
548
629
|
} : undefined);
|
|
549
630
|
} catch (err) {
|
|
550
631
|
if (pends(err)) continue;
|
|
551
|
-
console.warn(`useHead: error evaluating resource tag props`, err);
|
|
552
632
|
parked.splice(i, 1);
|
|
553
633
|
continue;
|
|
554
634
|
}
|
|
@@ -589,7 +669,6 @@ function emitHeadResource(registry, context, tracking, emitResource, nonce, desc
|
|
|
589
669
|
});
|
|
590
670
|
return;
|
|
591
671
|
}
|
|
592
|
-
console.warn(`useHead: error evaluating resource tag props`, err);
|
|
593
672
|
return;
|
|
594
673
|
}
|
|
595
674
|
const identity = resourceIdentity(desc.tag, props);
|
|
@@ -651,7 +730,6 @@ function commitHeadBoundary(registry, boundary, isPendingFragment) {
|
|
|
651
730
|
try {
|
|
652
731
|
resolved = reg.list();
|
|
653
732
|
} catch (err) {
|
|
654
|
-
console.warn(`useHead: error evaluating head group membership`, err);
|
|
655
733
|
continue;
|
|
656
734
|
}
|
|
657
735
|
if (!Array.isArray(resolved)) resolved = [resolved];
|
|
@@ -659,7 +737,6 @@ function commitHeadBoundary(registry, boundary, isPendingFragment) {
|
|
|
659
737
|
for (let j = 0; j < resolved.length; j++) {
|
|
660
738
|
const desc = resolved[j];
|
|
661
739
|
if (!desc || !HEAD_ELIGIBLE_TAGS.has(desc.tag)) {
|
|
662
|
-
console.warn(`useHead: ignoring non-head tag`, desc);
|
|
663
740
|
continue;
|
|
664
741
|
}
|
|
665
742
|
const cls = classifyHeadTag(desc);
|
|
@@ -685,12 +762,10 @@ function commitHeadBoundary(registry, boundary, isPendingFragment) {
|
|
|
685
762
|
} : undefined);
|
|
686
763
|
key = evalHeadValue(desc.key);
|
|
687
764
|
} catch (err) {
|
|
688
|
-
console.warn(`useHead: error evaluating tag props`, err);
|
|
689
765
|
continue;
|
|
690
766
|
}
|
|
691
767
|
const identity = replaceableIdentity(desc.tag, props, key, "u:" + registry.uniq++);
|
|
692
768
|
if ((identity === "base" || identity === "charset") && registry.shellFlushed) {
|
|
693
|
-
console.warn(`useHead: <${desc.tag}> (${identity}) registered after shell flush is ignored`);
|
|
694
769
|
continue;
|
|
695
770
|
}
|
|
696
771
|
tags.push({
|
|
@@ -772,7 +847,6 @@ function flushHeadFragment(registry, boundary) {
|
|
|
772
847
|
for (const name in t.props) {
|
|
773
848
|
if (name === "children" || name === "ref" || name.slice(0, 2) === "on") continue;
|
|
774
849
|
if (!HEAD_ATTR_NAME.test(name)) {
|
|
775
|
-
console.warn(`useHead: ignoring invalid attribute name "${name}"`);
|
|
776
850
|
continue;
|
|
777
851
|
}
|
|
778
852
|
const v = t.props[name];
|
|
@@ -790,7 +864,6 @@ function renderHeadAttrHtml(props) {
|
|
|
790
864
|
for (const name in props) {
|
|
791
865
|
if (name === "children" || name === "ref" || name.slice(0, 2) === "on") continue;
|
|
792
866
|
if (!HEAD_ATTR_NAME.test(name)) {
|
|
793
|
-
console.warn(`useHead: ignoring invalid attribute name "${name}"`);
|
|
794
867
|
continue;
|
|
795
868
|
}
|
|
796
869
|
const v = props[name];
|
|
@@ -823,7 +896,6 @@ function renderHeadTagMarkup(tag, props, identity, nonce) {
|
|
|
823
896
|
function useHead(tags) {
|
|
824
897
|
const ctx = solidJs.sharedConfig.context;
|
|
825
898
|
if (!ctx || !ctx.registerHeadTags) {
|
|
826
|
-
console.warn("useHead() called outside of a server render; registration ignored.");
|
|
827
899
|
return;
|
|
828
900
|
}
|
|
829
901
|
ctx.registerHeadTags(tags);
|
|
@@ -893,7 +965,7 @@ function renderToString(code, options = {}) {
|
|
|
893
965
|
}, {
|
|
894
966
|
id: renderId
|
|
895
967
|
});
|
|
896
|
-
serializeFragmentAssets("", tracking.boundaryModules, solidJs.sharedConfig.context);
|
|
968
|
+
serializeFragmentAssets("", tracking.boundaryModules, solidJs.sharedConfig.context, renderId);
|
|
897
969
|
solidJs.sharedConfig.context.noHydrate = true;
|
|
898
970
|
serializer.close();
|
|
899
971
|
const head = renderShellHead(headRegistry, nonce, null);
|
|
@@ -927,6 +999,12 @@ function renderToStream(code, options = {}) {
|
|
|
927
999
|
d();
|
|
928
1000
|
}
|
|
929
1001
|
};
|
|
1002
|
+
const failRender = err => {
|
|
1003
|
+
try {
|
|
1004
|
+
options.onError ? options.onError(err) : console.error(err);
|
|
1005
|
+
} catch (_) {}
|
|
1006
|
+
abandon();
|
|
1007
|
+
};
|
|
930
1008
|
const guardSink = w => ({
|
|
931
1009
|
write(payload) {
|
|
932
1010
|
if (dead) return;
|
|
@@ -1023,12 +1101,20 @@ function renderToStream(code, options = {}) {
|
|
|
1023
1101
|
const serializeRootAssets = () => {
|
|
1024
1102
|
if (rootAssetsSerialized) return;
|
|
1025
1103
|
rootAssetsSerialized = true;
|
|
1026
|
-
serializeFragmentAssets("", tracking.boundaryModules, context);
|
|
1104
|
+
serializeFragmentAssets("", tracking.boundaryModules, context, renderId);
|
|
1027
1105
|
};
|
|
1106
|
+
let holds = 0;
|
|
1028
1107
|
const flushEnd = () => {
|
|
1029
|
-
if (!registry.size) {
|
|
1108
|
+
if (!registry.size && !holds) {
|
|
1030
1109
|
serializeRootAssets();
|
|
1031
|
-
queue(() => queue(() =>
|
|
1110
|
+
queue(() => queue(() => {
|
|
1111
|
+
if (context.live.end) {
|
|
1112
|
+
const end = context.live.end;
|
|
1113
|
+
context.live.end = null;
|
|
1114
|
+
end();
|
|
1115
|
+
}
|
|
1116
|
+
serializer.flush();
|
|
1117
|
+
}));
|
|
1032
1118
|
}
|
|
1033
1119
|
};
|
|
1034
1120
|
const registry = new Map();
|
|
@@ -1089,6 +1175,7 @@ function renderToStream(code, options = {}) {
|
|
|
1089
1175
|
solidJs.sharedConfig.context = context = {
|
|
1090
1176
|
async: true,
|
|
1091
1177
|
nonce,
|
|
1178
|
+
live: {},
|
|
1092
1179
|
registerHeadTags(tags) {
|
|
1093
1180
|
registerHeadTags(headRegistry, context, tracking,
|
|
1094
1181
|
(markup, gateEntry) => {
|
|
@@ -1125,6 +1212,16 @@ function renderToStream(code, options = {}) {
|
|
|
1125
1212
|
block(p) {
|
|
1126
1213
|
if (!firstFlushed) blockingPromises.add(p);
|
|
1127
1214
|
},
|
|
1215
|
+
hold() {
|
|
1216
|
+
holds++;
|
|
1217
|
+
let released = false;
|
|
1218
|
+
return () => {
|
|
1219
|
+
if (released) return;
|
|
1220
|
+
released = true;
|
|
1221
|
+
holds--;
|
|
1222
|
+
if (!holds) queue(flushEnd);
|
|
1223
|
+
};
|
|
1224
|
+
},
|
|
1128
1225
|
replace(id, payloadFn) {
|
|
1129
1226
|
if (firstFlushed) return;
|
|
1130
1227
|
const placeholder = `<!--!$${id}-->`;
|
|
@@ -1233,6 +1330,7 @@ function renderToStream(code, options = {}) {
|
|
|
1233
1330
|
}
|
|
1234
1331
|
};
|
|
1235
1332
|
applyAssetTracking(context, tracking, manifest, noScripts);
|
|
1333
|
+
context.failRender = failRender;
|
|
1236
1334
|
registerEntryAssets(manifest);
|
|
1237
1335
|
let html = solidJs.createRoot(d => {
|
|
1238
1336
|
dispose = d;
|
|
@@ -1345,7 +1443,12 @@ function renderToStream(code, options = {}) {
|
|
|
1345
1443
|
allSettled(blockingPromises).then(() => {
|
|
1346
1444
|
scheduleFlush(() => {
|
|
1347
1445
|
if (dead) return resolve();
|
|
1348
|
-
|
|
1446
|
+
try {
|
|
1447
|
+
doShell();
|
|
1448
|
+
} catch (err) {
|
|
1449
|
+
failRender(err);
|
|
1450
|
+
return resolve();
|
|
1451
|
+
}
|
|
1349
1452
|
if (!shellCompleted) return flush();
|
|
1350
1453
|
const encoder = new TextEncoder();
|
|
1351
1454
|
const writer = w.getWriter();
|
|
@@ -1402,7 +1505,12 @@ function renderToStream(code, options = {}) {
|
|
|
1402
1505
|
function flush() {
|
|
1403
1506
|
allSettled(blockingPromises).then(() => {
|
|
1404
1507
|
scheduleFlush(() => {
|
|
1405
|
-
|
|
1508
|
+
try {
|
|
1509
|
+
if (!resolveRootHoles() || !headShellReady(headRegistry, p => blockingPromises.add(p))) return flush();
|
|
1510
|
+
} catch (err) {
|
|
1511
|
+
failRender(err);
|
|
1512
|
+
return resolve(tmp);
|
|
1513
|
+
}
|
|
1406
1514
|
queue(flushEnd);
|
|
1407
1515
|
});
|
|
1408
1516
|
});
|
|
@@ -1417,7 +1525,15 @@ function renderToStream(code, options = {}) {
|
|
|
1417
1525
|
allSettled(blockingPromises).then(() => {
|
|
1418
1526
|
scheduleFlush(() => {
|
|
1419
1527
|
if (dead) return;
|
|
1420
|
-
|
|
1528
|
+
try {
|
|
1529
|
+
doShell();
|
|
1530
|
+
} catch (err) {
|
|
1531
|
+
failRender(err);
|
|
1532
|
+
try {
|
|
1533
|
+
w.end();
|
|
1534
|
+
} catch (_) {}
|
|
1535
|
+
return;
|
|
1536
|
+
}
|
|
1421
1537
|
if (!shellCompleted) return flush();
|
|
1422
1538
|
buffer = writable = guardSink(w);
|
|
1423
1539
|
buffer.write(tmp);
|
|
@@ -1462,9 +1578,27 @@ function ssrGroup(fn, n) {
|
|
|
1462
1578
|
function buildAsyncWrap(err, node) {
|
|
1463
1579
|
const p = solidJs.ssrHandleError(err);
|
|
1464
1580
|
if (!p) return null;
|
|
1581
|
+
if (node.$rw) return {
|
|
1582
|
+
fn: node,
|
|
1583
|
+
p
|
|
1584
|
+
};
|
|
1465
1585
|
const owner = solidJs.getOwner();
|
|
1586
|
+
const live = solidJs.sharedConfig.context && solidJs.sharedConfig.context.liveHoles;
|
|
1587
|
+
const suppress = node.$lhSuppress || live && (live.suppressed || live.sweeping);
|
|
1588
|
+
if (!owner) {
|
|
1589
|
+
if (suppress) node.$lhSuppress = true;
|
|
1590
|
+
return {
|
|
1591
|
+
fn: node,
|
|
1592
|
+
p
|
|
1593
|
+
};
|
|
1594
|
+
}
|
|
1595
|
+
const fn = () => solidJs.runWithOwner(owner, node);
|
|
1596
|
+
fn.$rw = true;
|
|
1597
|
+
if (suppress) fn.$lhSuppress = true;
|
|
1598
|
+
if (node.$lhSkip) fn.$lhSkip = true;
|
|
1599
|
+
if (node.$lhBinding) fn.$lhBinding = node.$lhBinding;
|
|
1466
1600
|
return {
|
|
1467
|
-
fn
|
|
1601
|
+
fn,
|
|
1468
1602
|
p
|
|
1469
1603
|
};
|
|
1470
1604
|
}
|
|
@@ -1524,6 +1658,326 @@ function ssrGroupSlot(fn, idx) {
|
|
|
1524
1658
|
}
|
|
1525
1659
|
};
|
|
1526
1660
|
}
|
|
1661
|
+
const holePositionCache = new WeakMap();
|
|
1662
|
+
function holeContentPositions(t) {
|
|
1663
|
+
let cached = holePositionCache.get(t);
|
|
1664
|
+
if (cached) return cached;
|
|
1665
|
+
const pos = [];
|
|
1666
|
+
const openOff = [];
|
|
1667
|
+
const closeOff = [];
|
|
1668
|
+
let inTag = false;
|
|
1669
|
+
let quote = "";
|
|
1670
|
+
let curOpen = null;
|
|
1671
|
+
let scanningName = false;
|
|
1672
|
+
for (let i = 0; i < t.length; i++) {
|
|
1673
|
+
const seg = t[i];
|
|
1674
|
+
let close = -1;
|
|
1675
|
+
const openAtStart = inTag;
|
|
1676
|
+
let reopened = false;
|
|
1677
|
+
for (let j = 0; j < seg.length; j++) {
|
|
1678
|
+
const ch = seg[j];
|
|
1679
|
+
if (quote) {
|
|
1680
|
+
if (ch === quote) quote = "";
|
|
1681
|
+
} else if (inTag) {
|
|
1682
|
+
if (scanningName && (ch === " " || ch === "\t" || ch === "\n" || ch === ">" || ch === "/")) {
|
|
1683
|
+
scanningName = false;
|
|
1684
|
+
curOpen = {
|
|
1685
|
+
seg: i,
|
|
1686
|
+
off: j
|
|
1687
|
+
};
|
|
1688
|
+
}
|
|
1689
|
+
if (ch === '"' || ch === "'") quote = ch;else if (ch === ">") {
|
|
1690
|
+
inTag = false;
|
|
1691
|
+
if (openAtStart && !reopened && close === -1) close = j;
|
|
1692
|
+
curOpen = null;
|
|
1693
|
+
}
|
|
1694
|
+
} else if (ch === "<") {
|
|
1695
|
+
inTag = true;
|
|
1696
|
+
scanningName = true;
|
|
1697
|
+
reopened = true;
|
|
1698
|
+
curOpen = null;
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
if (inTag && scanningName) {
|
|
1702
|
+
scanningName = false;
|
|
1703
|
+
curOpen = {
|
|
1704
|
+
seg: i,
|
|
1705
|
+
off: seg.length
|
|
1706
|
+
};
|
|
1707
|
+
}
|
|
1708
|
+
closeOff.push(close);
|
|
1709
|
+
openOff.push(inTag && curOpen && curOpen.seg === i ? curOpen.off : -1);
|
|
1710
|
+
if (i < t.length - 1) pos.push(!inTag);
|
|
1711
|
+
}
|
|
1712
|
+
cached = {
|
|
1713
|
+
pos,
|
|
1714
|
+
openOff,
|
|
1715
|
+
closeOff
|
|
1716
|
+
};
|
|
1717
|
+
holePositionCache.set(t, cached);
|
|
1718
|
+
return cached;
|
|
1719
|
+
}
|
|
1720
|
+
function createLiveHoles(sink, scoped) {
|
|
1721
|
+
let nextId = 0;
|
|
1722
|
+
const stamp = typeof solidJs.creationStamp === "function" ? solidJs.creationStamp : () => 0;
|
|
1723
|
+
const inScope = scoped && typeof solidJs.inServerComponentScope === "function" ? solidJs.inServerComponentScope : null;
|
|
1724
|
+
const stripMarkers = html => html.replace(/<!--lh:\/?\d+-->/g, "");
|
|
1725
|
+
function resolveHoleValue(hole) {
|
|
1726
|
+
const result = {
|
|
1727
|
+
t: [""],
|
|
1728
|
+
h: [],
|
|
1729
|
+
p: []
|
|
1730
|
+
};
|
|
1731
|
+
try {
|
|
1732
|
+
resolveSSRNode(hole(), result);
|
|
1733
|
+
} catch (err) {
|
|
1734
|
+
const wrap = buildAsyncWrap(err, hole);
|
|
1735
|
+
if (!wrap) throw err;
|
|
1736
|
+
result.h.push(wrap.fn);
|
|
1737
|
+
result.p.push(wrap.p);
|
|
1738
|
+
result.t.push("");
|
|
1739
|
+
}
|
|
1740
|
+
return result;
|
|
1741
|
+
}
|
|
1742
|
+
function closeChildren(b) {
|
|
1743
|
+
for (const c of b.children) {
|
|
1744
|
+
c.closed = true;
|
|
1745
|
+
if (c.key) sink.closeBinding(c.key);
|
|
1746
|
+
closeChildren(c);
|
|
1747
|
+
}
|
|
1748
|
+
b.children.length = 0;
|
|
1749
|
+
}
|
|
1750
|
+
const engine = {
|
|
1751
|
+
suppressed: 0,
|
|
1752
|
+
sweeping: false,
|
|
1753
|
+
parent: null,
|
|
1754
|
+
recordStamp: 0,
|
|
1755
|
+
gateHit: false,
|
|
1756
|
+
content(hole) {
|
|
1757
|
+
if (hole.$lhSuppress) {
|
|
1758
|
+
const r = {
|
|
1759
|
+
t: [""],
|
|
1760
|
+
h: [],
|
|
1761
|
+
p: []
|
|
1762
|
+
};
|
|
1763
|
+
engine.suppressed++;
|
|
1764
|
+
try {
|
|
1765
|
+
try {
|
|
1766
|
+
resolveSSRNode(hole(), r);
|
|
1767
|
+
} catch (err) {
|
|
1768
|
+
const wrap = buildAsyncWrap(err, hole);
|
|
1769
|
+
if (wrap) {
|
|
1770
|
+
r.h.push(wrap.fn);
|
|
1771
|
+
r.p.push(wrap.p);
|
|
1772
|
+
r.t.push("");
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
} finally {
|
|
1776
|
+
engine.suppressed--;
|
|
1777
|
+
}
|
|
1778
|
+
const b = hole.$lhBinding;
|
|
1779
|
+
if (b && !b.closed && !r.h.length && !engine.sweeping) {
|
|
1780
|
+
b.last = stripMarkers(r.t[0]);
|
|
1781
|
+
}
|
|
1782
|
+
return r.h.length ? r : r.t[0];
|
|
1783
|
+
}
|
|
1784
|
+
if (engine.suppressed || engine.sweeping) return null;
|
|
1785
|
+
if (hole.$lhSkip) return null;
|
|
1786
|
+
if (inScope && !inScope()) return null;
|
|
1787
|
+
const recordsBefore = engine.recordStamp;
|
|
1788
|
+
const ownersBefore = stamp();
|
|
1789
|
+
const owner = solidJs.getOwner();
|
|
1790
|
+
const b = {
|
|
1791
|
+
key: null,
|
|
1792
|
+
children: [],
|
|
1793
|
+
last: null,
|
|
1794
|
+
closed: false,
|
|
1795
|
+
sweep() {
|
|
1796
|
+
if (b.closed) return;
|
|
1797
|
+
const prevSweeping = engine.sweeping;
|
|
1798
|
+
engine.sweeping = true;
|
|
1799
|
+
engine.gateHit = false;
|
|
1800
|
+
const sweepOwnersBefore = stamp();
|
|
1801
|
+
let res;
|
|
1802
|
+
try {
|
|
1803
|
+
res = owner ? solidJs.runWithOwner(owner, () => resolveHoleValue(hole)) : resolveHoleValue(hole);
|
|
1804
|
+
} catch (err) {
|
|
1805
|
+
b.closed = true;
|
|
1806
|
+
sink.closeBinding(b.key);
|
|
1807
|
+
sink.error(b.key, String(err && err.message || err));
|
|
1808
|
+
return;
|
|
1809
|
+
} finally {
|
|
1810
|
+
engine.sweeping = prevSweeping;
|
|
1811
|
+
}
|
|
1812
|
+
if (engine.gateHit || stamp() !== sweepOwnersBefore) {
|
|
1813
|
+
b.closed = true;
|
|
1814
|
+
sink.closeBinding(b.key);
|
|
1815
|
+
return;
|
|
1816
|
+
}
|
|
1817
|
+
if (res.h.length) return;
|
|
1818
|
+
const html = res.t[0];
|
|
1819
|
+
if (b.last === null || html === b.last) return;
|
|
1820
|
+
b.last = html;
|
|
1821
|
+
closeChildren(b);
|
|
1822
|
+
sink.hole(b.key, html);
|
|
1823
|
+
}
|
|
1824
|
+
};
|
|
1825
|
+
if (engine.parent) engine.parent.children.push(b);
|
|
1826
|
+
const prevParent = engine.parent;
|
|
1827
|
+
engine.parent = b;
|
|
1828
|
+
let value;
|
|
1829
|
+
let escalated = null;
|
|
1830
|
+
try {
|
|
1831
|
+
value = hole();
|
|
1832
|
+
} catch (err) {
|
|
1833
|
+
const wrap = buildAsyncWrap(err, hole);
|
|
1834
|
+
if (!wrap) {
|
|
1835
|
+
engine.parent = prevParent;
|
|
1836
|
+
closeChildren(b);
|
|
1837
|
+
return "";
|
|
1838
|
+
}
|
|
1839
|
+
escalated = wrap;
|
|
1840
|
+
}
|
|
1841
|
+
if (!escalated && (typeof value === "function" && value.$lhSkip || value !== null && typeof value === "object" && value.$slot)) {
|
|
1842
|
+
engine.parent = prevParent;
|
|
1843
|
+
const r = {
|
|
1844
|
+
t: [""],
|
|
1845
|
+
h: [],
|
|
1846
|
+
p: []
|
|
1847
|
+
};
|
|
1848
|
+
engine.suppressed++;
|
|
1849
|
+
try {
|
|
1850
|
+
resolveSSRNode(value, r);
|
|
1851
|
+
} finally {
|
|
1852
|
+
engine.suppressed--;
|
|
1853
|
+
}
|
|
1854
|
+
return r.h.length ? r : r.t[0];
|
|
1855
|
+
}
|
|
1856
|
+
let res;
|
|
1857
|
+
if (escalated) {
|
|
1858
|
+
closeChildren(b);
|
|
1859
|
+
escalated.fn.$lhSuppress = true;
|
|
1860
|
+
escalated.fn.$lhBinding = b;
|
|
1861
|
+
res = {
|
|
1862
|
+
t: ["", ""],
|
|
1863
|
+
h: [escalated.fn],
|
|
1864
|
+
p: [escalated.p]
|
|
1865
|
+
};
|
|
1866
|
+
} else {
|
|
1867
|
+
res = {
|
|
1868
|
+
t: [""],
|
|
1869
|
+
h: [],
|
|
1870
|
+
p: []
|
|
1871
|
+
};
|
|
1872
|
+
try {
|
|
1873
|
+
resolveSSRNode(value, res);
|
|
1874
|
+
} catch (_) {
|
|
1875
|
+
engine.parent = prevParent;
|
|
1876
|
+
closeChildren(b);
|
|
1877
|
+
return "";
|
|
1878
|
+
}
|
|
1879
|
+
}
|
|
1880
|
+
engine.parent = prevParent;
|
|
1881
|
+
if (engine.recordStamp !== recordsBefore || stamp() !== ownersBefore) {
|
|
1882
|
+
return res.h.length ? res : res.t[0];
|
|
1883
|
+
}
|
|
1884
|
+
const id = nextId++;
|
|
1885
|
+
const key = b.key = "lh:" + id;
|
|
1886
|
+
const open = `<!--lh:${id}-->`;
|
|
1887
|
+
const close = `<!--lh:/${id}-->`;
|
|
1888
|
+
if (!res.h.length) {
|
|
1889
|
+
b.last = stripMarkers(res.t[0]);
|
|
1890
|
+
sink.openBinding(key, b);
|
|
1891
|
+
return open + res.t[0] + close;
|
|
1892
|
+
}
|
|
1893
|
+
const t = res.t.slice();
|
|
1894
|
+
t[0] = open + t[0];
|
|
1895
|
+
t[t.length - 1] += close;
|
|
1896
|
+
sink.openBinding(key, b);
|
|
1897
|
+
return {
|
|
1898
|
+
t,
|
|
1899
|
+
h: res.h,
|
|
1900
|
+
p: res.p
|
|
1901
|
+
};
|
|
1902
|
+
},
|
|
1903
|
+
mint() {
|
|
1904
|
+
return nextId++;
|
|
1905
|
+
},
|
|
1906
|
+
active() {
|
|
1907
|
+
return !inScope || inScope();
|
|
1908
|
+
},
|
|
1909
|
+
attr(cap) {
|
|
1910
|
+
const owner = solidJs.getOwner();
|
|
1911
|
+
const b = {
|
|
1912
|
+
key: "lha:" + cap.id,
|
|
1913
|
+
children: [],
|
|
1914
|
+
last: cap.base,
|
|
1915
|
+
closed: false,
|
|
1916
|
+
sweep() {
|
|
1917
|
+
if (b.closed) return;
|
|
1918
|
+
const prevSweeping = engine.sweeping;
|
|
1919
|
+
engine.sweeping = true;
|
|
1920
|
+
engine.gateHit = false;
|
|
1921
|
+
const sweepOwnersBefore = stamp();
|
|
1922
|
+
let html = "";
|
|
1923
|
+
try {
|
|
1924
|
+
let group = null;
|
|
1925
|
+
let groupVal = null;
|
|
1926
|
+
const run = () => {
|
|
1927
|
+
for (const part of cap.parts) {
|
|
1928
|
+
if (typeof part === "string") {
|
|
1929
|
+
html += part;
|
|
1930
|
+
continue;
|
|
1931
|
+
}
|
|
1932
|
+
let v;
|
|
1933
|
+
if (part.g) {
|
|
1934
|
+
if (group !== part.g) {
|
|
1935
|
+
group = part.g;
|
|
1936
|
+
groupVal = part.g();
|
|
1937
|
+
}
|
|
1938
|
+
v = groupVal[part.i];
|
|
1939
|
+
} else {
|
|
1940
|
+
v = part.f();
|
|
1941
|
+
}
|
|
1942
|
+
const vt = typeof v;
|
|
1943
|
+
if (vt === "string" || vt === "number") html += v;
|
|
1944
|
+
}
|
|
1945
|
+
};
|
|
1946
|
+
owner ? solidJs.runWithOwner(owner, run) : run();
|
|
1947
|
+
} catch (err) {
|
|
1948
|
+
if (solidJs.ssrHandleError(err, true)) return;
|
|
1949
|
+
b.closed = true;
|
|
1950
|
+
sink.closeBinding(b.key);
|
|
1951
|
+
sink.error("lha:" + cap.id, String(err && err.message || err));
|
|
1952
|
+
return;
|
|
1953
|
+
} finally {
|
|
1954
|
+
engine.sweeping = prevSweeping;
|
|
1955
|
+
}
|
|
1956
|
+
if (engine.gateHit || stamp() !== sweepOwnersBefore) {
|
|
1957
|
+
b.closed = true;
|
|
1958
|
+
sink.closeBinding(b.key);
|
|
1959
|
+
return;
|
|
1960
|
+
}
|
|
1961
|
+
if (html === b.last) return;
|
|
1962
|
+
const before = attrNames(b.last);
|
|
1963
|
+
const after = attrNames(html);
|
|
1964
|
+
const removed = before.filter(n => !after.includes(n));
|
|
1965
|
+
b.last = html;
|
|
1966
|
+
sink.attr(String(cap.id), html, removed);
|
|
1967
|
+
}
|
|
1968
|
+
};
|
|
1969
|
+
sink.openBinding(b.key, b);
|
|
1970
|
+
}
|
|
1971
|
+
};
|
|
1972
|
+
return engine;
|
|
1973
|
+
}
|
|
1974
|
+
function attrNames(text) {
|
|
1975
|
+
const names = [];
|
|
1976
|
+
const re = /(?:^|\s)([^\s=/>"']+)(?:="[^"]*")?/g;
|
|
1977
|
+
let m;
|
|
1978
|
+
while (m = re.exec(text)) names.push(m[1]);
|
|
1979
|
+
return names;
|
|
1980
|
+
}
|
|
1527
1981
|
function ssr(t) {
|
|
1528
1982
|
const len = arguments.length;
|
|
1529
1983
|
if (len === 1) return {
|
|
@@ -1534,13 +1988,54 @@ function ssr(t) {
|
|
|
1534
1988
|
let lastGroup = null;
|
|
1535
1989
|
let lastGroupVal = null;
|
|
1536
1990
|
let lastGroupIdx = 0;
|
|
1991
|
+
const live = solidJs.sharedConfig.context && solidJs.sharedConfig.context.liveHoles;
|
|
1992
|
+
const hp = live ? holeContentPositions(t) : null;
|
|
1993
|
+
let lastOpen = null;
|
|
1994
|
+
let cap = null;
|
|
1995
|
+
if (live && hp.openOff[0] >= 0) lastOpen = {
|
|
1996
|
+
r: null,
|
|
1997
|
+
seg: -1,
|
|
1998
|
+
off: hp.openOff[0]
|
|
1999
|
+
};
|
|
2000
|
+
const captureStart = () => {
|
|
2001
|
+
if (cap) return true;
|
|
2002
|
+
if (!lastOpen || live.suppressed || live.sweeping || !live.active()) return false;
|
|
2003
|
+
if (lastOpen.r !== result || result !== null && lastOpen.seg !== result.t.length - 1) {
|
|
2004
|
+
return false;
|
|
2005
|
+
}
|
|
2006
|
+
const id = live.mint();
|
|
2007
|
+
const inject = ` data-lha="${id}"`;
|
|
2008
|
+
let prefix;
|
|
2009
|
+
if (result === null) {
|
|
2010
|
+
s = s.slice(0, lastOpen.off) + inject + s.slice(lastOpen.off);
|
|
2011
|
+
prefix = s.slice(lastOpen.off + inject.length);
|
|
2012
|
+
} else {
|
|
2013
|
+
const seg = result.t[lastOpen.seg];
|
|
2014
|
+
result.t[lastOpen.seg] = seg.slice(0, lastOpen.off) + inject + seg.slice(lastOpen.off);
|
|
2015
|
+
prefix = result.t[lastOpen.seg].slice(lastOpen.off + inject.length);
|
|
2016
|
+
}
|
|
2017
|
+
cap = {
|
|
2018
|
+
id,
|
|
2019
|
+
parts: [prefix],
|
|
2020
|
+
base: prefix
|
|
2021
|
+
};
|
|
2022
|
+
return true;
|
|
2023
|
+
};
|
|
1537
2024
|
for (let i = 1; i < len; i++) {
|
|
1538
2025
|
const hole = arguments[i];
|
|
1539
2026
|
const ht = typeof hole;
|
|
1540
2027
|
if (ht === "string") {
|
|
1541
2028
|
if (result === null) s += hole;else result.t[result.t.length - 1] += hole;
|
|
2029
|
+
if (cap) {
|
|
2030
|
+
cap.parts.push(hole);
|
|
2031
|
+
cap.base += hole;
|
|
2032
|
+
}
|
|
1542
2033
|
} else if (ht === "number") {
|
|
1543
2034
|
if (result === null) s += hole;else result.t[result.t.length - 1] += hole;
|
|
2035
|
+
if (cap) {
|
|
2036
|
+
cap.parts.push("" + hole);
|
|
2037
|
+
cap.base += hole;
|
|
2038
|
+
}
|
|
1544
2039
|
} else if (hole == null || ht === "boolean") ; else if (ht === "function" && hole.$g) {
|
|
1545
2040
|
let value;
|
|
1546
2041
|
let hasValue = false;
|
|
@@ -1564,7 +2059,14 @@ function ssr(t) {
|
|
|
1564
2059
|
if (Array.isArray(lastGroupVal)) {
|
|
1565
2060
|
value = lastGroupVal[lastGroupIdx++];
|
|
1566
2061
|
hasValue = true;
|
|
2062
|
+
if (live && !hp.pos[i - 1] && captureStart()) {
|
|
2063
|
+
cap.parts.push({
|
|
2064
|
+
g: hole,
|
|
2065
|
+
i: lastGroupIdx - 1
|
|
2066
|
+
});
|
|
2067
|
+
}
|
|
1567
2068
|
} else {
|
|
2069
|
+
cap = null;
|
|
1568
2070
|
result.h.push(ssrGroupSlot(lastGroupVal.fn, lastGroupIdx++));
|
|
1569
2071
|
result.p.push(lastGroupVal.p);
|
|
1570
2072
|
result.t.push("");
|
|
@@ -1574,6 +2076,7 @@ function ssr(t) {
|
|
|
1574
2076
|
const vt = typeof value;
|
|
1575
2077
|
if (vt === "string" || vt === "number") {
|
|
1576
2078
|
if (result === null) s += value;else result.t[result.t.length - 1] += value;
|
|
2079
|
+
if (cap && !hp.pos[i - 1]) cap.base += value;
|
|
1577
2080
|
} else if (value == null || vt === "boolean") ; else if (result !== null) {
|
|
1578
2081
|
resolveSSRNode(value, result);
|
|
1579
2082
|
} else {
|
|
@@ -1591,19 +2094,67 @@ function ssr(t) {
|
|
|
1591
2094
|
}
|
|
1592
2095
|
}
|
|
1593
2096
|
}
|
|
1594
|
-
} else if (result !== null) {
|
|
1595
|
-
resolveSSRNode(hole, result);
|
|
1596
2097
|
} else if (ht === "function") {
|
|
1597
|
-
|
|
1598
|
-
if (
|
|
1599
|
-
|
|
1600
|
-
t
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
2098
|
+
let liveNode = null;
|
|
2099
|
+
if (live && hp.pos[i - 1] && (liveNode = live.content(hole)) !== null) {
|
|
2100
|
+
if (typeof liveNode === "string") {
|
|
2101
|
+
if (result === null) s += liveNode;else result.t[result.t.length - 1] += liveNode;
|
|
2102
|
+
} else {
|
|
2103
|
+
if (result === null) {
|
|
2104
|
+
result = {
|
|
2105
|
+
t: [s],
|
|
2106
|
+
h: [],
|
|
2107
|
+
p: []
|
|
2108
|
+
};
|
|
2109
|
+
s = "";
|
|
2110
|
+
}
|
|
2111
|
+
resolveSSRNode(liveNode, result);
|
|
2112
|
+
}
|
|
2113
|
+
} else if (result !== null) {
|
|
2114
|
+
const inTag = live && !hp.pos[i - 1];
|
|
2115
|
+
const capturing = inTag && captureStart();
|
|
2116
|
+
const li = capturing ? result.t.length - 1 : 0;
|
|
2117
|
+
const before = capturing ? result.t[li].length : 0;
|
|
2118
|
+
if (live) live.suppressed++;
|
|
2119
|
+
try {
|
|
2120
|
+
resolveSSRNode(hole, result);
|
|
2121
|
+
} finally {
|
|
2122
|
+
if (live) live.suppressed--;
|
|
2123
|
+
}
|
|
2124
|
+
if (capturing) {
|
|
2125
|
+
if (result.t.length - 1 === li) {
|
|
2126
|
+
cap.base += result.t[li].slice(before);
|
|
2127
|
+
cap.parts.push({
|
|
2128
|
+
f: hole
|
|
2129
|
+
});
|
|
2130
|
+
} else {
|
|
2131
|
+
cap = null;
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2134
|
+
} else {
|
|
2135
|
+
const capturing = live && !hp.pos[i - 1] && captureStart();
|
|
2136
|
+
const r = tryResolveFunctionHole(hole);
|
|
2137
|
+
if (typeof r === "string") {
|
|
2138
|
+
s += r;
|
|
2139
|
+
if (capturing) {
|
|
2140
|
+
cap.base += r;
|
|
2141
|
+
cap.parts.push({
|
|
2142
|
+
f: hole
|
|
2143
|
+
});
|
|
2144
|
+
}
|
|
2145
|
+
} else {
|
|
2146
|
+
if (capturing) cap = null;
|
|
2147
|
+
result = {
|
|
2148
|
+
t: [s],
|
|
2149
|
+
h: [],
|
|
2150
|
+
p: []
|
|
2151
|
+
};
|
|
2152
|
+
s = "";
|
|
2153
|
+
appendResolvedNode(result, r);
|
|
2154
|
+
}
|
|
1606
2155
|
}
|
|
2156
|
+
} else if (result !== null) {
|
|
2157
|
+
resolveSSRNode(hole, result);
|
|
1607
2158
|
} else {
|
|
1608
2159
|
const r = tryResolveString(hole);
|
|
1609
2160
|
if (typeof r === "string") {
|
|
@@ -1619,6 +2170,32 @@ function ssr(t) {
|
|
|
1619
2170
|
}
|
|
1620
2171
|
}
|
|
1621
2172
|
const next = t[i];
|
|
2173
|
+
if (live) {
|
|
2174
|
+
if (cap) {
|
|
2175
|
+
const co = hp.closeOff[i];
|
|
2176
|
+
if (co >= 0) {
|
|
2177
|
+
const tail = next.slice(0, co);
|
|
2178
|
+
cap.parts.push(tail);
|
|
2179
|
+
cap.base += tail;
|
|
2180
|
+
live.attr(cap);
|
|
2181
|
+
cap = null;
|
|
2182
|
+
} else {
|
|
2183
|
+
cap.parts.push(next);
|
|
2184
|
+
cap.base += next;
|
|
2185
|
+
}
|
|
2186
|
+
}
|
|
2187
|
+
if (hp.openOff[i] >= 0) {
|
|
2188
|
+
lastOpen = result === null ? {
|
|
2189
|
+
r: null,
|
|
2190
|
+
seg: -1,
|
|
2191
|
+
off: s.length + hp.openOff[i]
|
|
2192
|
+
} : {
|
|
2193
|
+
r: result,
|
|
2194
|
+
seg: result.t.length - 1,
|
|
2195
|
+
off: result.t[result.t.length - 1].length + hp.openOff[i]
|
|
2196
|
+
};
|
|
2197
|
+
}
|
|
2198
|
+
}
|
|
1622
2199
|
if (result === null) s += next;else result.t[result.t.length - 1] += next;
|
|
1623
2200
|
}
|
|
1624
2201
|
if (result === null) return {
|
|
@@ -1843,10 +2420,10 @@ function renderHeadAssets(emittedAssets, inlineStyles, nonce) {
|
|
|
1843
2420
|
}
|
|
1844
2421
|
return head;
|
|
1845
2422
|
}
|
|
1846
|
-
function serializeFragmentAssets(key, boundaryModules, context) {
|
|
2423
|
+
function serializeFragmentAssets(key, boundaryModules, context, name = key) {
|
|
1847
2424
|
const map = boundaryModules.get(key);
|
|
1848
2425
|
if (!map || !Object.keys(map).length) return;
|
|
1849
|
-
context.serialize(
|
|
2426
|
+
context.serialize(name + "_assets", map);
|
|
1850
2427
|
}
|
|
1851
2428
|
function propagateBoundaryStyles(childKey, parentKey, tracking) {
|
|
1852
2429
|
const childStyles = tracking.getBoundaryStyles(childKey);
|
|
@@ -1954,7 +2531,6 @@ function tryResolveString(node) {
|
|
|
1954
2531
|
merge: node
|
|
1955
2532
|
};
|
|
1956
2533
|
if (node.t === undefined) {
|
|
1957
|
-
console.warn(`Unrecognized value. Skipped inserting`, node);
|
|
1958
2534
|
return "";
|
|
1959
2535
|
}
|
|
1960
2536
|
return Array.isArray(node.t) ? node.t[0] : node.t;
|
|
@@ -1979,13 +2555,19 @@ function resolveSSRNode(node, result = {
|
|
|
1979
2555
|
if (t === "string" || t === "number") {
|
|
1980
2556
|
result.t[result.t.length - 1] += node;
|
|
1981
2557
|
} else if (node == null || t === "boolean") ; else if (Array.isArray(node)) {
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
2558
|
+
const slotLive = node.$slot && solidJs.sharedConfig.context && solidJs.sharedConfig.context.liveHoles;
|
|
2559
|
+
if (slotLive) slotLive.suppressed++;
|
|
2560
|
+
try {
|
|
2561
|
+
let prevNonObj = false;
|
|
2562
|
+
for (let i = 0, len = node.length; i < len; i++) {
|
|
2563
|
+
const item = node[i];
|
|
2564
|
+
const itemNonObj = item !== null && typeof item !== "object";
|
|
2565
|
+
if (!top && prevNonObj && itemNonObj) result.t[result.t.length - 1] += `<!--!$-->`;
|
|
2566
|
+
prevNonObj = itemNonObj;
|
|
2567
|
+
resolveSSRNode(item, result);
|
|
2568
|
+
}
|
|
2569
|
+
} finally {
|
|
2570
|
+
if (slotLive) slotLive.suppressed--;
|
|
1989
2571
|
}
|
|
1990
2572
|
} else if (t === "object") {
|
|
1991
2573
|
if (node.h) {
|
|
@@ -1997,16 +2579,22 @@ function resolveSSRNode(node, result = {
|
|
|
1997
2579
|
}
|
|
1998
2580
|
} else if (node.t !== undefined) {
|
|
1999
2581
|
result.t[result.t.length - 1] += node.t;
|
|
2000
|
-
} else
|
|
2582
|
+
} else ;
|
|
2001
2583
|
} else if (t === "function") {
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2584
|
+
const live = solidJs.sharedConfig.context && solidJs.sharedConfig.context.liveHoles;
|
|
2585
|
+
let liveNode = null;
|
|
2586
|
+
if (live && (liveNode = live.content(node)) !== null) {
|
|
2587
|
+
if (typeof liveNode === "string") result.t[result.t.length - 1] += liveNode;else resolveSSRNode(liveNode, result);
|
|
2588
|
+
} else {
|
|
2589
|
+
try {
|
|
2590
|
+
resolveSSRNode(node(), result);
|
|
2591
|
+
} catch (err) {
|
|
2592
|
+
const wrap = buildAsyncWrap(err, node);
|
|
2593
|
+
if (wrap) {
|
|
2594
|
+
result.h.push(wrap.fn);
|
|
2595
|
+
result.p.push(wrap.p);
|
|
2596
|
+
result.t.push("");
|
|
2597
|
+
}
|
|
2010
2598
|
}
|
|
2011
2599
|
}
|
|
2012
2600
|
}
|
|
@@ -2039,7 +2627,7 @@ function createRequestEvent(request, init) {
|
|
|
2039
2627
|
}
|
|
2040
2628
|
function reportLostHeaderWrite(method, name) {
|
|
2041
2629
|
const message = `Response header write dropped: headers.${method}(${JSON.stringify(String(name))}) ` + "ran after the response head was sent. Write headers before the shell flushes " + "(or before the handler returns).";
|
|
2042
|
-
|
|
2630
|
+
console.error(message);
|
|
2043
2631
|
}
|
|
2044
2632
|
function commitResponseStub(stub, {
|
|
2045
2633
|
allowLateLocation = false
|
|
@@ -2243,6 +2831,7 @@ function notSup() {
|
|
|
2243
2831
|
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>.");
|
|
2244
2832
|
}
|
|
2245
2833
|
|
|
2834
|
+
setContainerTraceResolver(solidJs.getProjectionTrace);
|
|
2246
2835
|
const isServer = true;
|
|
2247
2836
|
const isDev = false;
|
|
2248
2837
|
function dynamic(source) {
|
|
@@ -2308,18 +2897,39 @@ function clientOnly(_fn, _options = {}, moduleUrl) {
|
|
|
2308
2897
|
return solidJs.createMemo(() => props.fallback);
|
|
2309
2898
|
};
|
|
2310
2899
|
}
|
|
2900
|
+
const statusLedgers = /* @__PURE__ */new WeakMap();
|
|
2901
|
+
const headerLedgers = /* @__PURE__ */new WeakMap();
|
|
2311
2902
|
function httpStatus(code, text) {
|
|
2312
2903
|
const event = getRequestEvent();
|
|
2313
2904
|
const response = event && event.response;
|
|
2314
2905
|
if (response && !response.committed) {
|
|
2315
|
-
|
|
2316
|
-
|
|
2906
|
+
let ledger = statusLedgers.get(response);
|
|
2907
|
+
if (!ledger) {
|
|
2908
|
+
ledger = {
|
|
2909
|
+
base: {
|
|
2910
|
+
status: response.status,
|
|
2911
|
+
statusText: response.statusText
|
|
2912
|
+
},
|
|
2913
|
+
live: []
|
|
2914
|
+
};
|
|
2915
|
+
statusLedgers.set(response, ledger);
|
|
2916
|
+
}
|
|
2917
|
+
const declaration = {
|
|
2918
|
+
status: code,
|
|
2919
|
+
statusText: text
|
|
2920
|
+
};
|
|
2921
|
+
ledger.live.push(declaration);
|
|
2317
2922
|
response.status = code;
|
|
2318
2923
|
response.statusText = text;
|
|
2319
2924
|
solidJs.onCleanup(() => {
|
|
2320
2925
|
if (response.committed) return;
|
|
2321
|
-
|
|
2322
|
-
|
|
2926
|
+
const index = ledger.live.indexOf(declaration);
|
|
2927
|
+
if (index < 0) return;
|
|
2928
|
+
ledger.live.splice(index, 1);
|
|
2929
|
+
const effective = ledger.live.length ? ledger.live[ledger.live.length - 1] : ledger.base;
|
|
2930
|
+
response.status = effective.status;
|
|
2931
|
+
response.statusText = effective.statusText;
|
|
2932
|
+
if (!ledger.live.length) statusLedgers.delete(response);
|
|
2323
2933
|
});
|
|
2324
2934
|
}
|
|
2325
2935
|
}
|
|
@@ -2328,16 +2938,39 @@ function httpHeader(name, value, options) {
|
|
|
2328
2938
|
const response = event && event.response;
|
|
2329
2939
|
if (response && !response.committed) {
|
|
2330
2940
|
const headers = response.headers;
|
|
2331
|
-
const
|
|
2332
|
-
const
|
|
2333
|
-
|
|
2334
|
-
if (
|
|
2941
|
+
const key = name.toLowerCase();
|
|
2942
|
+
const setCookie = key === "set-cookie";
|
|
2943
|
+
let ledgers = headerLedgers.get(response);
|
|
2944
|
+
if (!ledgers) headerLedgers.set(response, ledgers = new Map());
|
|
2945
|
+
let ledger = ledgers.get(key);
|
|
2946
|
+
if (!ledger) {
|
|
2947
|
+
ledger = {
|
|
2948
|
+
base: setCookie ? headers.getSetCookie() : headers.get(name),
|
|
2949
|
+
live: []
|
|
2950
|
+
};
|
|
2951
|
+
ledgers.set(key, ledger);
|
|
2952
|
+
}
|
|
2953
|
+
const declaration = {
|
|
2954
|
+
value,
|
|
2955
|
+
append: !!(options && options.append)
|
|
2956
|
+
};
|
|
2957
|
+
ledger.live.push(declaration);
|
|
2958
|
+
if (declaration.append) headers.append(name, value);else headers.set(name, value);
|
|
2335
2959
|
solidJs.onCleanup(() => {
|
|
2336
2960
|
if (response.committed) return;
|
|
2961
|
+
const index = ledger.live.indexOf(declaration);
|
|
2962
|
+
if (index < 0) return;
|
|
2963
|
+
ledger.live.splice(index, 1);
|
|
2964
|
+
headers.delete(name);
|
|
2337
2965
|
if (setCookie) {
|
|
2338
|
-
headers.
|
|
2339
|
-
|
|
2340
|
-
|
|
2966
|
+
for (const cookie of ledger.base) headers.append(name, cookie);
|
|
2967
|
+
} else if (ledger.base !== null) {
|
|
2968
|
+
headers.set(name, ledger.base);
|
|
2969
|
+
}
|
|
2970
|
+
for (const d of ledger.live) {
|
|
2971
|
+
if (d.append) headers.append(name, d.value);else headers.set(name, d.value);
|
|
2972
|
+
}
|
|
2973
|
+
if (!ledger.live.length) ledgers.delete(key);
|
|
2341
2974
|
});
|
|
2342
2975
|
}
|
|
2343
2976
|
}
|
|
@@ -2426,10 +3059,12 @@ exports.assign = notSup;
|
|
|
2426
3059
|
exports.claimElement = claimElement;
|
|
2427
3060
|
exports.claimElementTree = claimElementTree;
|
|
2428
3061
|
exports.className = notSup;
|
|
3062
|
+
exports.clearFlashCookie = clearFlashCookie;
|
|
2429
3063
|
exports.clientOnly = clientOnly;
|
|
2430
3064
|
exports.commitEventResponse = commitEventResponse;
|
|
2431
3065
|
exports.commitResponseStub = commitResponseStub;
|
|
2432
3066
|
exports.composeMiddleware = composeMiddleware;
|
|
3067
|
+
exports.createLiveHoles = createLiveHoles;
|
|
2433
3068
|
exports.createRequestEvent = createRequestEvent;
|
|
2434
3069
|
exports.createResponseStub = createResponseStub;
|
|
2435
3070
|
exports.createSSRResponse = createSSRResponse;
|
|
@@ -2446,6 +3081,9 @@ exports.getNextElement = notSup;
|
|
|
2446
3081
|
exports.getNextMarker = notSup;
|
|
2447
3082
|
exports.getNextMatch = notSup;
|
|
2448
3083
|
exports.getRequestEvent = getRequestEvent;
|
|
3084
|
+
exports.getServerFunctionMetadata = getServerFunctionMetadata;
|
|
3085
|
+
exports.getServerFunctionRPC = getServerFunctionRPC;
|
|
3086
|
+
exports.hasFlashCookie = hasFlashCookie;
|
|
2449
3087
|
exports.httpHeader = httpHeader;
|
|
2450
3088
|
exports.httpStatus = httpStatus;
|
|
2451
3089
|
exports.hydrate = notSup;
|
|
@@ -2455,6 +3093,7 @@ exports.isHref = isHref;
|
|
|
2455
3093
|
exports.isResponseEnvelope = isResponseEnvelope;
|
|
2456
3094
|
exports.isSafeError = isSafeError;
|
|
2457
3095
|
exports.isServer = isServer;
|
|
3096
|
+
exports.isServerFunction = isServerFunction;
|
|
2458
3097
|
exports.markSafeError = markSafeError;
|
|
2459
3098
|
exports.memo = memo;
|
|
2460
3099
|
exports.parseCookieHeader = parseCookieHeader;
|