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