@solidjs/web 2.0.0-rc.15 → 2.0.0-rc.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/server.dev.js +358 -479
- package/dist/server.js +343 -387
- package/dist/server.observe.js +343 -387
- package/dist/web.dev.js +57 -54
- package/dist/web.js +47 -49
- package/dist/web.observe.js +57 -54
- package/frames/dist/client.dev.js +610 -621
- package/frames/dist/client.js +540 -566
- package/frames/dist/client.observe.js +571 -573
- package/frames/dist/regions.js +43 -2
- package/frames/dist/server.dev.js +514 -423
- package/frames/dist/server.js +514 -370
- package/frames/dist/server.observe.js +514 -370
- package/frames/dist/wire.js +371 -6
- package/package.json +11 -11
- package/serialization/dist/decode.js +9 -7
- package/serialization/dist/serialization.js +9 -7
- package/serialization/types/serializer-decode.d.ts +2 -2
- package/server-functions/dist/client.dev.js +3 -1
- package/server-functions/dist/client.js +1 -1
- package/server-functions/dist/client.observe.js +3 -1
- package/server-functions/dist/rich-args.js +33 -1
- package/server-functions/dist/server.dev.js +127 -18
- package/server-functions/dist/server.js +127 -18
- package/server-functions/dist/server.observe.js +127 -18
- package/skills/server-components/SKILL.md +74 -185
- package/types/client.d.ts +15 -5
- package/types/frames/assets-tier.d.ts +2 -2
- package/types/frames/client.d.ts +8 -3
- package/types/frames/frame-client.d.ts +121 -157
- package/types/frames/frame-morph.d.ts +28 -0
- package/types/frames/frame-sink.d.ts +13 -9
- package/types/frames/frame-transport.d.ts +30 -1
- package/types/frames/regions-tier.d.ts +15 -0
- package/types/frames/serializer-decode.d.ts +2 -2
- package/types/frames/server.d.ts +0 -52
- package/types/frames/wire-tier.d.ts +54 -1
- package/types/index.d.ts +2 -2
- package/types/jsx.d.ts +11 -5
- package/types/observe.d.ts +14 -7
- package/types/render.d.ts +3 -1
- package/types/response.d.ts +5 -4
- package/types/serializer-decode.d.ts +2 -2
- package/types/server-functions/argument-codec.d.ts +21 -0
- package/types/server-functions/client.d.ts +14 -5
- package/types/server-functions/server.d.ts +6 -2
- package/types/server-functions/shared.d.ts +19 -0
- package/types/server-observe.d.ts +3 -2
- package/types/server.d.ts +57 -76
- package/frames/dist/bind.dev.js +0 -326
- package/frames/dist/bind.js +0 -295
- package/types/frames/bind-tier.d.ts +0 -60
package/dist/server.dev.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRenderEffect, getOwner, createMemo, OBSERVE, DEV, createRoot, $PROXY, onCleanup, runWithOwner, createComponent, omit, getNextChildId } from 'solid-js';
|
|
2
2
|
export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, dynamicComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
|
|
3
|
-
import { sharedConfig, ssrSanitizeError, reportServerError, viewOf, sourceOwners, ssrHandleError, inServerComponentScope, creationStamp, dynamicCore, getProjectionTrace, shareAsyncIterable } from 'solid-js/internal';
|
|
4
|
-
export { ssrScope as scope
|
|
3
|
+
import { sharedConfig, ssrSanitizeError, beginEdgesRender, reportServerError, viewOf, sourceOwners, ssrHandleError, inServerComponentScope, creationStamp, dynamicCore, getProjectionTrace, shareAsyncIterable } from 'solid-js/internal';
|
|
4
|
+
export { ssrScope as scope } from 'solid-js/internal';
|
|
5
5
|
import { createStream, Serializer, getCrossReferenceHeader, Feature } from 'seroval';
|
|
6
6
|
import { AbortSignalPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin } from 'seroval-plugins/web';
|
|
7
7
|
|
|
@@ -128,11 +128,9 @@ function parseTraceparent(value) {
|
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
130
|
function randomHex(bytes) {
|
|
131
|
-
const buffer = new Uint8Array(bytes);
|
|
132
|
-
crypto.getRandomValues(buffer);
|
|
133
131
|
let out = "";
|
|
134
|
-
for (let i = 0; i <
|
|
135
|
-
return out;
|
|
132
|
+
for (let i = 0; i < bytes; i += 4) out += (Math.random() * 0x100000000 >>> 0).toString(16).padStart(8, "0");
|
|
133
|
+
return out.length === bytes * 2 ? out : out.slice(0, bytes * 2);
|
|
136
134
|
}
|
|
137
135
|
function randomTraceId() {
|
|
138
136
|
let id = randomHex(16);
|
|
@@ -699,7 +697,12 @@ function respond(value, init = {}) {
|
|
|
699
697
|
}), value);
|
|
700
698
|
}
|
|
701
699
|
headers.set("Content-Type", "application/json");
|
|
702
|
-
return new ResponseEnvelope(new Response(
|
|
700
|
+
return new ResponseEnvelope(new Response(new ReadableStream({
|
|
701
|
+
pull(controller) {
|
|
702
|
+
controller.enqueue(new TextEncoder().encode(JSON.stringify(value)));
|
|
703
|
+
controller.close();
|
|
704
|
+
}
|
|
705
|
+
}), {
|
|
703
706
|
...responseInit,
|
|
704
707
|
headers
|
|
705
708
|
}), value);
|
|
@@ -1636,12 +1639,6 @@ function destinationNonce(nonce, destination) {
|
|
|
1636
1639
|
const value = typeof nonce === "string" ? nonce : nonce[destination];
|
|
1637
1640
|
return typeof value === "string" && value ? value : undefined;
|
|
1638
1641
|
}
|
|
1639
|
-
function scriptNonce(nonce) {
|
|
1640
|
-
return destinationNonce(nonce, "script");
|
|
1641
|
-
}
|
|
1642
|
-
function styleNonce(nonce) {
|
|
1643
|
-
return destinationNonce(nonce, "style");
|
|
1644
|
-
}
|
|
1645
1642
|
function hasNonceProp(props) {
|
|
1646
1643
|
for (const name in props) if (name.length === 5 && asciiLowerCase(name) === "nonce" && props[name] != null) return true;
|
|
1647
1644
|
return false;
|
|
@@ -1772,6 +1769,8 @@ function renderToString(code, options = {}) {
|
|
|
1772
1769
|
onHead
|
|
1773
1770
|
} = options;
|
|
1774
1771
|
const nonce = normalizeNonce(options.nonce);
|
|
1772
|
+
const requestEvent = peekRequestEvent();
|
|
1773
|
+
const errorScope = requestEvent || {};
|
|
1775
1774
|
let scripts = "";
|
|
1776
1775
|
const serializer = createHydrationSerializer({
|
|
1777
1776
|
scopeId: renderId,
|
|
@@ -1794,6 +1793,7 @@ function renderToString(code, options = {}) {
|
|
|
1794
1793
|
resolve: resolveSSRNode,
|
|
1795
1794
|
ssr: ssr,
|
|
1796
1795
|
errorPolicy: options.onError,
|
|
1796
|
+
_errorScope: errorScope,
|
|
1797
1797
|
registerHeadTags(tags) {
|
|
1798
1798
|
registerHeadTags(headRegistry, sharedConfig.context, tracking, null, nonce, tags);
|
|
1799
1799
|
},
|
|
@@ -1828,7 +1828,6 @@ function renderToString(code, options = {}) {
|
|
|
1828
1828
|
registerEntryAssets(manifest);
|
|
1829
1829
|
const context = sharedConfig.context;
|
|
1830
1830
|
context.writer = createHydrationWriter(context, () => !closed);
|
|
1831
|
-
const requestEvent = peekRequestEvent();
|
|
1832
1831
|
if (requestEvent) setRequestErrorHook(requestEvent, options.onError);
|
|
1833
1832
|
context.trace = requestEvent ? traceForEvent(requestEvent) : traceFor(context, undefined);
|
|
1834
1833
|
const render = timeDocument(context, context.trace, "string", requestEvent);
|
|
@@ -1848,7 +1847,7 @@ function renderToString(code, options = {}) {
|
|
|
1848
1847
|
closed = true;
|
|
1849
1848
|
serializer.close();
|
|
1850
1849
|
const head = renderShellHead(headRegistry, nonce, null, noScripts, traceMetaMarkup(context.trace));
|
|
1851
|
-
const document = assembleDocument(resolveSSRSelectValues(html), tracking.emittedAssets, tracking.preloadLinks, tracking.inlineStyles, scripts.length ? scripts : "", nonce, head, onHead)
|
|
1850
|
+
const document = withShellEnd(assembleDocument(resolveSSRSelectValues(html), tracking.emittedAssets, tracking.preloadLinks, tracking.inlineStyles, scripts.length ? scripts : "", nonce, head, onHead), context, renderId, nonce, noScripts);
|
|
1852
1851
|
if (render) render.shell();
|
|
1853
1852
|
if (requestEvent && requestEvent.response) {
|
|
1854
1853
|
commitResponseStub(requestEvent.response, {
|
|
@@ -1861,7 +1860,7 @@ function renderToString(code, options = {}) {
|
|
|
1861
1860
|
reportServerError(err, {
|
|
1862
1861
|
kind: "render",
|
|
1863
1862
|
handling: "failed"
|
|
1864
|
-
}, null, options.onError);
|
|
1863
|
+
}, null, options.onError, errorScope);
|
|
1865
1864
|
throw err;
|
|
1866
1865
|
} finally {
|
|
1867
1866
|
if (render) settleRender(render, rootOwner, rendered ? "complete" : "error");
|
|
@@ -1883,6 +1882,7 @@ function renderToStream(code, options = {}) {
|
|
|
1883
1882
|
const nonce = normalizeNonce(options.nonce);
|
|
1884
1883
|
const requestEvent = peekRequestEvent();
|
|
1885
1884
|
if (requestEvent) setRequestErrorHook(requestEvent, options.onError);
|
|
1885
|
+
const errorScope = requestEvent || {};
|
|
1886
1886
|
let dispose;
|
|
1887
1887
|
let dead = false;
|
|
1888
1888
|
let render;
|
|
@@ -1937,7 +1937,15 @@ function renderToStream(code, options = {}) {
|
|
|
1937
1937
|
if (dispose) {
|
|
1938
1938
|
const d = dispose;
|
|
1939
1939
|
dispose = () => {};
|
|
1940
|
-
|
|
1940
|
+
try {
|
|
1941
|
+
d();
|
|
1942
|
+
} catch (err) {
|
|
1943
|
+
reportServerError(err, {
|
|
1944
|
+
kind: "render",
|
|
1945
|
+
handling: "failed"
|
|
1946
|
+
}, null, options.onError, errorScope);
|
|
1947
|
+
if (!options.onError && ambientServerErrorHook() === undefined) console.error(err);
|
|
1948
|
+
}
|
|
1941
1949
|
}
|
|
1942
1950
|
if (serializer && typeof serializer.close === "function") {
|
|
1943
1951
|
try {
|
|
@@ -1946,7 +1954,7 @@ function renderToStream(code, options = {}) {
|
|
|
1946
1954
|
reportServerError(err, {
|
|
1947
1955
|
kind: "render",
|
|
1948
1956
|
handling: "serialize"
|
|
1949
|
-
}, null, options.onError);
|
|
1957
|
+
}, null, options.onError, errorScope);
|
|
1950
1958
|
}
|
|
1951
1959
|
}
|
|
1952
1960
|
serializer = abandonedSerializer;
|
|
@@ -1963,7 +1971,7 @@ function renderToStream(code, options = {}) {
|
|
|
1963
1971
|
reportServerError(err, {
|
|
1964
1972
|
kind: "render",
|
|
1965
1973
|
handling: "failed"
|
|
1966
|
-
}, null, options.onError);
|
|
1974
|
+
}, null, options.onError, errorScope);
|
|
1967
1975
|
if (!options.onError && ambientServerErrorHook() === undefined) console.error(err);
|
|
1968
1976
|
abandon();
|
|
1969
1977
|
};
|
|
@@ -2028,6 +2036,18 @@ function renderToStream(code, options = {}) {
|
|
|
2028
2036
|
const canBatchStubs = !options.serializer && !options.sink;
|
|
2029
2037
|
let stubBatch = null;
|
|
2030
2038
|
const STUB_BATCH_KEY = "$B";
|
|
2039
|
+
let stableOrder = false;
|
|
2040
|
+
let parkedWrites = null;
|
|
2041
|
+
const byKey = (a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0;
|
|
2042
|
+
const write = (id, value) => {
|
|
2043
|
+
if (stableOrder && !dead) (parkedWrites ||= []).push([id, value]);else serializer.write(id, value);
|
|
2044
|
+
};
|
|
2045
|
+
const flushParkedWrites = () => {
|
|
2046
|
+
if (!parkedWrites) return;
|
|
2047
|
+
const writes = parkedWrites.sort(byKey);
|
|
2048
|
+
parkedWrites = null;
|
|
2049
|
+
for (let i = 0; i < writes.length; i++) serializer.write(writes[i][0], writes[i][1]);
|
|
2050
|
+
};
|
|
2031
2051
|
const flushStubBatch = () => {
|
|
2032
2052
|
if (!stubBatch) return;
|
|
2033
2053
|
const batch = stubBatch;
|
|
@@ -2038,7 +2058,9 @@ function renderToStream(code, options = {}) {
|
|
|
2038
2058
|
return;
|
|
2039
2059
|
}
|
|
2040
2060
|
const obj = {};
|
|
2041
|
-
|
|
2061
|
+
const entries = [...batch];
|
|
2062
|
+
if (stableOrder) entries.sort(byKey);
|
|
2063
|
+
for (const [id, p] of entries) obj[id] = p;
|
|
2042
2064
|
serializer.write(STUB_BATCH_KEY, obj);
|
|
2043
2065
|
pushTask(`(b=>{for(var k in b)_$HY.r[k]=b[k];delete _$HY.r["${STUB_BATCH_KEY}"]})(_$HY.r["${STUB_BATCH_KEY}"])`);
|
|
2044
2066
|
};
|
|
@@ -2110,7 +2132,7 @@ function renderToStream(code, options = {}) {
|
|
|
2110
2132
|
}
|
|
2111
2133
|
},
|
|
2112
2134
|
shell(shellHtml, meta) {
|
|
2113
|
-
buffer.write(assembleDocument(shellHtml, meta.preloads, meta.preloadLinks, meta.inlineStyles, meta.tasks.length ? meta.tasks : "", nonce, meta.head, onHead)
|
|
2135
|
+
buffer.write(withShellEnd(assembleDocument(shellHtml, meta.preloads, meta.preloadLinks, meta.inlineStyles, meta.tasks.length ? meta.tasks : "", nonce, meta.head, onHead), context, renderId, nonce, noScripts));
|
|
2114
2136
|
},
|
|
2115
2137
|
...options.sink
|
|
2116
2138
|
};
|
|
@@ -2138,6 +2160,7 @@ function renderToStream(code, options = {}) {
|
|
|
2138
2160
|
end();
|
|
2139
2161
|
}
|
|
2140
2162
|
flushStubBatch();
|
|
2163
|
+
flushParkedWrites();
|
|
2141
2164
|
serializer.flush();
|
|
2142
2165
|
}));
|
|
2143
2166
|
}
|
|
@@ -2146,7 +2169,7 @@ function renderToStream(code, options = {}) {
|
|
|
2146
2169
|
const pendingSerialized = new Map();
|
|
2147
2170
|
const guardedChannels = new WeakMap();
|
|
2148
2171
|
const verdictNow = error => {
|
|
2149
|
-
throw ssrSanitizeError(error, null);
|
|
2172
|
+
throw ssrSanitizeError(error, null, undefined, undefined, errorScope);
|
|
2150
2173
|
};
|
|
2151
2174
|
const borderForm = value => toBorderForm(value);
|
|
2152
2175
|
const guardIterable = iterable => ({
|
|
@@ -2294,6 +2317,7 @@ function renderToStream(code, options = {}) {
|
|
|
2294
2317
|
async: true,
|
|
2295
2318
|
nonce: options.nonce,
|
|
2296
2319
|
document: !options.sink,
|
|
2320
|
+
edges: !!options.plugins && options.plugins.some(p => p.tag === "solid/server-component"),
|
|
2297
2321
|
live: {},
|
|
2298
2322
|
registerHeadTags(tags) {
|
|
2299
2323
|
registerHeadTags(headRegistry, context, tracking,
|
|
@@ -2359,7 +2383,7 @@ function renderToStream(code, options = {}) {
|
|
|
2359
2383
|
if (p && typeof p === "object" && typeof p.then === "function") {
|
|
2360
2384
|
if (!firstFlushed && deferStream) {
|
|
2361
2385
|
blockingPromises.add(p);
|
|
2362
|
-
p.then(d =>
|
|
2386
|
+
p.then(d => write(id, d)).catch(e => write(id, e));
|
|
2363
2387
|
return;
|
|
2364
2388
|
}
|
|
2365
2389
|
p = trackSerialized(id, p);
|
|
@@ -2368,7 +2392,7 @@ function renderToStream(code, options = {}) {
|
|
|
2368
2392
|
return;
|
|
2369
2393
|
}
|
|
2370
2394
|
}
|
|
2371
|
-
|
|
2395
|
+
write(id, p);
|
|
2372
2396
|
},
|
|
2373
2397
|
escape: escape,
|
|
2374
2398
|
resolve: resolveSSRNode,
|
|
@@ -2399,11 +2423,11 @@ function renderToStream(code, options = {}) {
|
|
|
2399
2423
|
defuse(p);
|
|
2400
2424
|
registry.set(key, {
|
|
2401
2425
|
resolve: err => queue(() => queue(() => {
|
|
2402
|
-
err ? reject(ssrSanitizeError(err, null)) : resolve(true);
|
|
2426
|
+
err ? reject(ssrSanitizeError(err, null, undefined, undefined, errorScope)) : resolve(true);
|
|
2403
2427
|
queue(flushEnd);
|
|
2404
2428
|
}))
|
|
2405
2429
|
});
|
|
2406
|
-
if (canBatchStubs && !shellCompleted && !dead) (stubBatch ||= new Map()).set(key + "_fr", p);else
|
|
2430
|
+
if (canBatchStubs && !shellCompleted && !dead) (stubBatch ||= new Map()).set(key + "_fr", p);else write(key + "_fr", p);
|
|
2407
2431
|
}
|
|
2408
2432
|
return (value, error, escaped) => {
|
|
2409
2433
|
if (registry.has(key)) {
|
|
@@ -2411,7 +2435,7 @@ function renderToStream(code, options = {}) {
|
|
|
2411
2435
|
registry.delete(key);
|
|
2412
2436
|
if (error) abandonSubtree(key, error);
|
|
2413
2437
|
if (error && escaped) {
|
|
2414
|
-
const wire = ssrSanitizeError(error, null);
|
|
2438
|
+
const wire = ssrSanitizeError(error, null, undefined, undefined, errorScope);
|
|
2415
2439
|
const message = wire instanceof Error ? wire.message : String(wire);
|
|
2416
2440
|
if (sink.error) sink.error("", message);else if (context.live && context.live.error) context.live.error(escaped.frame, message);
|
|
2417
2441
|
}
|
|
@@ -2445,7 +2469,7 @@ function renderToStream(code, options = {}) {
|
|
|
2445
2469
|
sink.fragment(key, resolveSSRSelectValues(value !== undefined ? value : " "), {
|
|
2446
2470
|
styles,
|
|
2447
2471
|
revealGroup,
|
|
2448
|
-
error: error ? ssrSanitizeError(error, null) : error
|
|
2472
|
+
error: error ? ssrSanitizeError(error, null, undefined, undefined, errorScope) : error
|
|
2449
2473
|
});
|
|
2450
2474
|
item.resolve(error);
|
|
2451
2475
|
}
|
|
@@ -2472,6 +2496,7 @@ function renderToStream(code, options = {}) {
|
|
|
2472
2496
|
applyAssetTracking(context, tracking, manifest, noScripts);
|
|
2473
2497
|
context.failRender = failRender;
|
|
2474
2498
|
context.errorPolicy = options.onError;
|
|
2499
|
+
context._errorScope = errorScope;
|
|
2475
2500
|
context.flushed = () => firstFlushed;
|
|
2476
2501
|
context.trace = requestEvent ? traceForEvent(requestEvent) : traceFor(context, undefined);
|
|
2477
2502
|
render = timeDocument(context, context.trace, "stream", requestEvent);
|
|
@@ -2479,40 +2504,48 @@ function renderToStream(code, options = {}) {
|
|
|
2479
2504
|
context.writer = createHydrationWriter(context, () => !completed);
|
|
2480
2505
|
const signal = options.signal;
|
|
2481
2506
|
const onAbort = signal ? () => abandon("signal", !!(signal.reason && signal.reason.quiet === true)) : undefined;
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
}
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
rootHoles
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2507
|
+
const endEdges = context.edges ? beginEdgesRender() : undefined;
|
|
2508
|
+
let html;
|
|
2509
|
+
try {
|
|
2510
|
+
html = createRoot(d => {
|
|
2511
|
+
dispose = () => {
|
|
2512
|
+
context.trace = undefined;
|
|
2513
|
+
if (onAbort) signal.removeEventListener("abort", onAbort);
|
|
2514
|
+
if (endEdges) endEdges();
|
|
2515
|
+
d();
|
|
2516
|
+
};
|
|
2517
|
+
rootOwner = claimRenderRoot(context);
|
|
2518
|
+
if (requestEvent) claimEventRender(requestEvent, context);
|
|
2519
|
+
let res;
|
|
2520
|
+
try {
|
|
2521
|
+
res = resolveSSRNode(escape(code()));
|
|
2522
|
+
} catch (err) {
|
|
2523
|
+
reportServerError(err, {
|
|
2524
|
+
kind: "render",
|
|
2525
|
+
handling: "failed"
|
|
2526
|
+
}, null, options.onError, errorScope);
|
|
2527
|
+
throw err;
|
|
2528
|
+
}
|
|
2529
|
+
if (!res.h.length) return res.t[0];
|
|
2530
|
+
rootHoles = [];
|
|
2531
|
+
let out = res.t[0];
|
|
2532
|
+
for (let i = 0; i < res.h.length; i++) {
|
|
2533
|
+
const id = nextHoleId++;
|
|
2534
|
+
rootHoles.push({
|
|
2535
|
+
id,
|
|
2536
|
+
fn: res.h[i]
|
|
2537
|
+
});
|
|
2538
|
+
out += `<!--rh${id}-->` + res.t[i + 1];
|
|
2539
|
+
}
|
|
2540
|
+
for (const p of res.p) blockingPromises.add(p);
|
|
2541
|
+
return out;
|
|
2542
|
+
}, {
|
|
2543
|
+
id: renderId
|
|
2544
|
+
});
|
|
2545
|
+
} catch (err) {
|
|
2546
|
+
if (endEdges) endEdges();
|
|
2547
|
+
throw err;
|
|
2548
|
+
}
|
|
2516
2549
|
if (onAbort) {
|
|
2517
2550
|
if (signal.aborted) onAbort();else signal.addEventListener("abort", onAbort, {
|
|
2518
2551
|
once: true
|
|
@@ -2591,21 +2624,30 @@ function renderToStream(code, options = {}) {
|
|
|
2591
2624
|
let lastBlockingSize = -1;
|
|
2592
2625
|
let lastRegistrySize = -1;
|
|
2593
2626
|
let drainTurn = 0;
|
|
2627
|
+
let graced = false;
|
|
2594
2628
|
const scheduleFlush = (fn, awaited) => {
|
|
2595
2629
|
const attempt = () => {
|
|
2596
|
-
flushStubBatch();
|
|
2630
|
+
if (!stableOrder) flushStubBatch();
|
|
2597
2631
|
if (registry.size !== lastRegistrySize || drainTurn++ < MIN_DRAIN_TURNS) {
|
|
2598
2632
|
if (registry.size !== lastRegistrySize) drainTurn = 0;
|
|
2599
2633
|
lastRegistrySize = registry.size;
|
|
2600
2634
|
queue(attempt);
|
|
2601
2635
|
return;
|
|
2602
2636
|
}
|
|
2637
|
+
if (!graced && registry.size) {
|
|
2638
|
+
graced = true;
|
|
2639
|
+
lastRegistrySize = -1;
|
|
2640
|
+
drainTurn = 0;
|
|
2641
|
+
deferFlush(attempt);
|
|
2642
|
+
return;
|
|
2643
|
+
}
|
|
2603
2644
|
fn();
|
|
2604
2645
|
};
|
|
2605
2646
|
const progressed = awaited !== lastBlockingSize;
|
|
2606
2647
|
lastBlockingSize = awaited;
|
|
2607
2648
|
lastRegistrySize = -1;
|
|
2608
2649
|
drainTurn = 0;
|
|
2650
|
+
graced = false;
|
|
2609
2651
|
progressed ? queue(attempt) : setTimeout(attempt);
|
|
2610
2652
|
};
|
|
2611
2653
|
let cachedReadable;
|
|
@@ -2672,6 +2714,7 @@ function renderToStream(code, options = {}) {
|
|
|
2672
2714
|
};
|
|
2673
2715
|
return {
|
|
2674
2716
|
then(onFulfilled, onRejected) {
|
|
2717
|
+
if (canBatchStubs) stableOrder = true;
|
|
2675
2718
|
const freezeHead = () => {
|
|
2676
2719
|
if (requestEvent && requestEvent.response) commitResponseStub(requestEvent.response, {
|
|
2677
2720
|
event: requestEvent
|
|
@@ -2770,7 +2813,7 @@ function HydrationScript(props) {
|
|
|
2770
2813
|
nonce: sharedConfig.context && sharedConfig.context.nonce,
|
|
2771
2814
|
...props
|
|
2772
2815
|
};
|
|
2773
|
-
return ssr(hydrationBootstrap(eventNames,
|
|
2816
|
+
return ssr(hydrationBootstrap(eventNames, destinationNonce(nonce, "script"), true));
|
|
2774
2817
|
}
|
|
2775
2818
|
function ssrGroup(fn, n) {
|
|
2776
2819
|
fn.$g = n;
|
|
@@ -2859,8 +2902,8 @@ function ssrGroupSlot(fn, idx) {
|
|
|
2859
2902
|
}
|
|
2860
2903
|
};
|
|
2861
2904
|
}
|
|
2862
|
-
function wireErrorMessage(err) {
|
|
2863
|
-
const wire = ssrSanitizeError(err, null);
|
|
2905
|
+
function wireErrorMessage(err, scope) {
|
|
2906
|
+
const wire = ssrSanitizeError(err, null, undefined, undefined, scope);
|
|
2864
2907
|
return String(wire && wire.message || wire);
|
|
2865
2908
|
}
|
|
2866
2909
|
const holePositionCache = new WeakMap();
|
|
@@ -2922,28 +2965,89 @@ function holeContentPositions(t) {
|
|
|
2922
2965
|
holePositionCache.set(t, cached);
|
|
2923
2966
|
return cached;
|
|
2924
2967
|
}
|
|
2925
|
-
function createLiveHoles(sink, scoped) {
|
|
2968
|
+
function createLiveHoles(sink, scoped, settled, errorScope) {
|
|
2926
2969
|
let nextId = 0;
|
|
2927
2970
|
const stamp = typeof creationStamp === "function" ? creationStamp : () => 0;
|
|
2928
2971
|
const inScope = scoped && typeof inServerComponentScope === "function" ? inServerComponentScope : null;
|
|
2929
2972
|
const stripMarkers = html => html.replace(/<!--lh:\/?\d+-->| data-lha="\d+"/g, "");
|
|
2973
|
+
const latched = (owner, cause, content) => {
|
|
2974
|
+
devCheck({
|
|
2975
|
+
code: "SSR_LIVE_HOLE_LATCHED",
|
|
2976
|
+
kind: "ssr",
|
|
2977
|
+
severity: "warn",
|
|
2978
|
+
message: cause === "records" ? `[SSR_LIVE_HOLE_LATCHED] A live attribute stopped updating: re-running it ` + `called a slot, which places a client component in markup, not in an ` + `attribute, so it keeps the value it last sent. Call the slot in the ` + `element's content instead.` : `[SSR_LIVE_HOLE_LATCHED] A live ${content ? "markup hole" : "attribute"} stopped updating: ` + `re-running it created a reactive scope that waits on async work (a memo over a fetch or a stream), ` + `so it cannot re-run and keeps the markup it last sent. ` + `Create async sources outside markup that re-renders from a live source ` + `(in the component body, not inside the hole's expression).`,
|
|
2979
|
+
data: {
|
|
2980
|
+
cause
|
|
2981
|
+
}
|
|
2982
|
+
}, owner);
|
|
2983
|
+
};
|
|
2930
2984
|
const swept = (owner, ctx, fn) => {
|
|
2931
2985
|
const prev = sharedConfig.context;
|
|
2932
2986
|
sharedConfig.context = ctx;
|
|
2987
|
+
let dispose;
|
|
2988
|
+
let before;
|
|
2989
|
+
const run = () => createRoot(d => {
|
|
2990
|
+
dispose = d;
|
|
2991
|
+
before = stamp();
|
|
2992
|
+
return fn();
|
|
2993
|
+
}, {
|
|
2994
|
+
transparent: true
|
|
2995
|
+
});
|
|
2933
2996
|
try {
|
|
2934
|
-
return owner ? runWithOwner(owner,
|
|
2997
|
+
return owner ? runWithOwner(owner, run) : run();
|
|
2935
2998
|
} finally {
|
|
2936
2999
|
sharedConfig.context = prev;
|
|
3000
|
+
engine.sweptOwners = before !== undefined && stamp() !== before;
|
|
3001
|
+
if (dispose) dispose();
|
|
2937
3002
|
}
|
|
2938
3003
|
};
|
|
3004
|
+
const stripRow = html => html.replace(/<!--lh:\/?\d+-->| data-lha="\d+"|<!--lr-->/g, "");
|
|
3005
|
+
const rowsOf = v => Array.isArray(v) && v.$rows ? v : null;
|
|
3006
|
+
function holeValue(hole) {
|
|
3007
|
+
const b = hole.$lhBinding;
|
|
3008
|
+
if (b) {
|
|
3009
|
+
const v = hole();
|
|
3010
|
+
return b.fn && rowsOf(b.fn()) || v;
|
|
3011
|
+
}
|
|
3012
|
+
if (!hole.$fn) return hole();
|
|
3013
|
+
const v = hole.$fn();
|
|
3014
|
+
return rowsOf(v) || escape(v);
|
|
3015
|
+
}
|
|
3016
|
+
function resolveValue(value, res) {
|
|
3017
|
+
if (!Array.isArray(value) || !value.$rows) {
|
|
3018
|
+
resolveSSRNode(value, res);
|
|
3019
|
+
return null;
|
|
3020
|
+
}
|
|
3021
|
+
let rows = [];
|
|
3022
|
+
for (const row of value) {
|
|
3023
|
+
const r = resolveSSRNode(escape(row));
|
|
3024
|
+
res.t[res.t.length - 1] += "<!--lr-->" + r.t[0];
|
|
3025
|
+
if (r.h.length) {
|
|
3026
|
+
res.t.push(...r.t.slice(1));
|
|
3027
|
+
res.h.push(...r.h);
|
|
3028
|
+
res.p.push(...r.p);
|
|
3029
|
+
rows = null;
|
|
3030
|
+
} else if (rows) rows.push(engine.sweeping ? r.t[0] : stripRow(r.t[0]));
|
|
3031
|
+
}
|
|
3032
|
+
return rows;
|
|
3033
|
+
}
|
|
3034
|
+
function rowOps(last, rows) {
|
|
3035
|
+
const ops = [];
|
|
3036
|
+
for (let i = 0; i < rows.length; i++) if (i >= last.length || rows[i] !== last[i]) ops.push([i, rows[i]]);
|
|
3037
|
+
return ops.length < rows.length ? {
|
|
3038
|
+
n: rows.length,
|
|
3039
|
+
r: ops
|
|
3040
|
+
} : null;
|
|
3041
|
+
}
|
|
2939
3042
|
function resolveHoleValue(hole) {
|
|
2940
3043
|
const result = {
|
|
2941
3044
|
t: [""],
|
|
2942
3045
|
h: [],
|
|
2943
|
-
p: []
|
|
3046
|
+
p: [],
|
|
3047
|
+
rows: null
|
|
2944
3048
|
};
|
|
2945
3049
|
try {
|
|
2946
|
-
|
|
3050
|
+
result.rows = resolveValue(holeValue(hole), result);
|
|
2947
3051
|
} catch (err) {
|
|
2948
3052
|
const wrap = buildAsyncWrap(err, hole);
|
|
2949
3053
|
if (!wrap) throw err;
|
|
@@ -2961,12 +3065,88 @@ function createLiveHoles(sink, scoped) {
|
|
|
2961
3065
|
}
|
|
2962
3066
|
b.children.length = 0;
|
|
2963
3067
|
}
|
|
3068
|
+
let tops = 0;
|
|
3069
|
+
const ids = new Map();
|
|
3070
|
+
const scopeFor = hole => {
|
|
3071
|
+
const p = engine.scope;
|
|
3072
|
+
return {
|
|
3073
|
+
id: undefined,
|
|
3074
|
+
p,
|
|
3075
|
+
i: p ? p.c++ : tops++,
|
|
3076
|
+
n: null,
|
|
3077
|
+
c: 0,
|
|
3078
|
+
h: hole
|
|
3079
|
+
};
|
|
3080
|
+
};
|
|
3081
|
+
const scopeId = s => s.id !== undefined ? s.id : s.id = s.p ? scopeId(s.p) + "." + s.i : String(s.i);
|
|
3082
|
+
const collect = (v, id, forget) => (v.occ || (v.occ = new Map())).set(id, forget);
|
|
3083
|
+
function rescope(b, hole, fn) {
|
|
3084
|
+
const prevScope = engine.scope;
|
|
3085
|
+
const prevVisit = engine.visit;
|
|
3086
|
+
engine.scope = {
|
|
3087
|
+
id: scopeId(b.scope),
|
|
3088
|
+
p: null,
|
|
3089
|
+
i: 0,
|
|
3090
|
+
n: null,
|
|
3091
|
+
c: 0,
|
|
3092
|
+
h: hole
|
|
3093
|
+
};
|
|
3094
|
+
const visit = engine.visit = {
|
|
3095
|
+
occ: null
|
|
3096
|
+
};
|
|
3097
|
+
try {
|
|
3098
|
+
return fn();
|
|
3099
|
+
} finally {
|
|
3100
|
+
engine.scope = prevScope;
|
|
3101
|
+
engine.visit = prevVisit;
|
|
3102
|
+
b.next = visit.occ;
|
|
3103
|
+
}
|
|
3104
|
+
}
|
|
3105
|
+
function settleOccurrences(b) {
|
|
3106
|
+
const occ = b.next;
|
|
3107
|
+
b.next = null;
|
|
3108
|
+
if (b.occ) for (const [id, forget] of b.occ) if (!occ || !occ.has(id)) forget();
|
|
3109
|
+
b.occ = occ;
|
|
3110
|
+
if (occ) for (let a = b.up; a; a = a.up) for (const [id, forget] of occ) collect(a, id, forget);
|
|
3111
|
+
}
|
|
3112
|
+
function leave(b, parent, scope, visit) {
|
|
3113
|
+
engine.parent = parent;
|
|
3114
|
+
engine.scope = scope;
|
|
3115
|
+
engine.visit = visit;
|
|
3116
|
+
if (visit && b.occ) for (const [id, forget] of b.occ) collect(visit, id, forget);
|
|
3117
|
+
}
|
|
2964
3118
|
const engine = {
|
|
2965
3119
|
suppressed: 0,
|
|
2966
3120
|
sweeping: false,
|
|
2967
3121
|
parent: null,
|
|
2968
|
-
recordStamp: 0,
|
|
2969
3122
|
gateHit: false,
|
|
3123
|
+
sweptOwners: false,
|
|
3124
|
+
scope: null,
|
|
3125
|
+
visit: null,
|
|
3126
|
+
dry: false,
|
|
3127
|
+
slotId(prop, given) {
|
|
3128
|
+
const s = engine.scope;
|
|
3129
|
+
if (!s) return given;
|
|
3130
|
+
const n = s.n || (s.n = Object.create(null));
|
|
3131
|
+
const i = n[prop] || 0;
|
|
3132
|
+
n[prop] = i + 1;
|
|
3133
|
+
const sid = scopeId(s);
|
|
3134
|
+
const at = sid + "." + i + "\0" + prop;
|
|
3135
|
+
if (given !== undefined) {
|
|
3136
|
+
ids.set(at, given);
|
|
3137
|
+
return given;
|
|
3138
|
+
}
|
|
3139
|
+
return ids.get(at) || `${prop}#~${sid}.${i}`;
|
|
3140
|
+
},
|
|
3141
|
+
seen(id, forget) {
|
|
3142
|
+
if (engine.visit) collect(engine.visit, id, forget);
|
|
3143
|
+
},
|
|
3144
|
+
nest(hole) {
|
|
3145
|
+
const s = engine.scope;
|
|
3146
|
+
if (!s || s.h === hole || hole.$lhSkip || inScope && !inScope()) return undefined;
|
|
3147
|
+
engine.scope = scopeFor(hole);
|
|
3148
|
+
return s;
|
|
3149
|
+
},
|
|
2970
3150
|
content(hole) {
|
|
2971
3151
|
if (hole.$lhSuppress) {
|
|
2972
3152
|
const r = {
|
|
@@ -2974,10 +3154,12 @@ function createLiveHoles(sink, scoped) {
|
|
|
2974
3154
|
h: [],
|
|
2975
3155
|
p: []
|
|
2976
3156
|
};
|
|
2977
|
-
|
|
2978
|
-
|
|
3157
|
+
let rows = null;
|
|
3158
|
+
const b = hole.$lhBinding;
|
|
3159
|
+
const run = () => {
|
|
3160
|
+
engine.suppressed++;
|
|
2979
3161
|
try {
|
|
2980
|
-
|
|
3162
|
+
rows = resolveValue(holeValue(hole), r);
|
|
2981
3163
|
} catch (err) {
|
|
2982
3164
|
const wrap = buildAsyncWrap(err, hole);
|
|
2983
3165
|
if (wrap) {
|
|
@@ -2985,20 +3167,21 @@ function createLiveHoles(sink, scoped) {
|
|
|
2985
3167
|
r.p.push(wrap.p);
|
|
2986
3168
|
r.t.push("");
|
|
2987
3169
|
}
|
|
3170
|
+
} finally {
|
|
3171
|
+
engine.suppressed--;
|
|
2988
3172
|
}
|
|
2989
|
-
}
|
|
2990
|
-
|
|
2991
|
-
}
|
|
2992
|
-
const b = hole.$lhBinding;
|
|
3173
|
+
};
|
|
3174
|
+
b && !engine.sweeping ? rescope(b, hole, run) : run();
|
|
2993
3175
|
if (b && !b.closed && !r.h.length && !engine.sweeping) {
|
|
2994
3176
|
b.last = stripMarkers(r.t[0]);
|
|
3177
|
+
b.rows = rows;
|
|
3178
|
+
settleOccurrences(b);
|
|
2995
3179
|
}
|
|
2996
3180
|
return r.h.length ? r : r.t[0];
|
|
2997
3181
|
}
|
|
2998
3182
|
if (engine.suppressed || engine.sweeping) return null;
|
|
2999
3183
|
if (hole.$lhSkip) return null;
|
|
3000
3184
|
if (inScope && !inScope()) return null;
|
|
3001
|
-
const recordsBefore = engine.recordStamp;
|
|
3002
3185
|
const ownersBefore = stamp();
|
|
3003
3186
|
const owner = getOwner();
|
|
3004
3187
|
const holeCtx = sharedConfig.context;
|
|
@@ -3006,25 +3189,32 @@ function createLiveHoles(sink, scoped) {
|
|
|
3006
3189
|
key: null,
|
|
3007
3190
|
children: [],
|
|
3008
3191
|
last: null,
|
|
3192
|
+
rows: null,
|
|
3193
|
+
fn: hole.$fn,
|
|
3009
3194
|
closed: false,
|
|
3195
|
+
scope: undefined,
|
|
3196
|
+
occ: null,
|
|
3197
|
+
next: null,
|
|
3198
|
+
up: engine.parent,
|
|
3010
3199
|
sweep() {
|
|
3011
3200
|
if (b.closed) return;
|
|
3012
3201
|
const prevSweeping = engine.sweeping;
|
|
3013
3202
|
engine.sweeping = true;
|
|
3014
|
-
engine.
|
|
3015
|
-
const sweepOwnersBefore = stamp();
|
|
3203
|
+
engine.dry = b.last === null;
|
|
3016
3204
|
let res;
|
|
3017
3205
|
try {
|
|
3018
|
-
res = swept(owner, holeCtx, () => resolveHoleValue(hole));
|
|
3206
|
+
res = rescope(b, hole, () => swept(owner, holeCtx, () => resolveHoleValue(hole)));
|
|
3019
3207
|
} catch (err) {
|
|
3020
3208
|
b.closed = true;
|
|
3021
3209
|
sink.closeBinding(b.key);
|
|
3022
|
-
sink.error(b.key, wireErrorMessage(err));
|
|
3210
|
+
sink.error(b.key, wireErrorMessage(err, errorScope));
|
|
3023
3211
|
return;
|
|
3024
3212
|
} finally {
|
|
3025
3213
|
engine.sweeping = prevSweeping;
|
|
3214
|
+
engine.dry = false;
|
|
3026
3215
|
}
|
|
3027
|
-
if (engine.
|
|
3216
|
+
if (engine.sweptOwners && res.h.length) {
|
|
3217
|
+
latched(owner, "owners", true);
|
|
3028
3218
|
b.closed = true;
|
|
3029
3219
|
sink.closeBinding(b.key);
|
|
3030
3220
|
return;
|
|
@@ -3032,29 +3222,38 @@ function createLiveHoles(sink, scoped) {
|
|
|
3032
3222
|
if (res.h.length) return;
|
|
3033
3223
|
const html = res.t[0];
|
|
3034
3224
|
if (b.last === null || html === b.last) return;
|
|
3225
|
+
const ops = b.rows && res.rows && rowOps(b.rows, res.rows);
|
|
3035
3226
|
b.last = html;
|
|
3227
|
+
if (ops && !ops.r.length && ops.n === b.rows.length) return;
|
|
3228
|
+
b.rows = res.rows;
|
|
3036
3229
|
closeChildren(b);
|
|
3037
|
-
|
|
3230
|
+
settleOccurrences(b);
|
|
3231
|
+
sink.hole(b.key, html, ops && !html.includes("<!--slot:") ? ops : null);
|
|
3038
3232
|
}
|
|
3039
3233
|
};
|
|
3040
3234
|
if (engine.parent) engine.parent.children.push(b);
|
|
3041
3235
|
const prevParent = engine.parent;
|
|
3236
|
+
const prevScope = engine.scope;
|
|
3237
|
+
const prevVisit = engine.visit;
|
|
3238
|
+
const scope = b.scope = scopeFor(hole);
|
|
3042
3239
|
engine.parent = b;
|
|
3240
|
+
engine.scope = scope;
|
|
3241
|
+
engine.visit = b;
|
|
3043
3242
|
let value;
|
|
3044
3243
|
let escalated = null;
|
|
3045
3244
|
try {
|
|
3046
|
-
value = hole
|
|
3245
|
+
value = holeValue(hole);
|
|
3047
3246
|
} catch (err) {
|
|
3048
3247
|
const wrap = buildAsyncWrap(err, hole);
|
|
3049
3248
|
if (!wrap) {
|
|
3050
|
-
|
|
3249
|
+
leave(b, prevParent, prevScope, prevVisit);
|
|
3051
3250
|
closeChildren(b);
|
|
3052
3251
|
return "";
|
|
3053
3252
|
}
|
|
3054
3253
|
escalated = wrap;
|
|
3055
3254
|
}
|
|
3056
3255
|
if (!escalated && (typeof value === "function" && value.$lhSkip || value !== null && typeof value === "object" && value.$slot)) {
|
|
3057
|
-
|
|
3256
|
+
leave(b, prevParent, prevScope, prevVisit);
|
|
3058
3257
|
const r = {
|
|
3059
3258
|
t: [""],
|
|
3060
3259
|
h: [],
|
|
@@ -3069,6 +3268,7 @@ function createLiveHoles(sink, scoped) {
|
|
|
3069
3268
|
return r.h.length ? r : r.t[0];
|
|
3070
3269
|
}
|
|
3071
3270
|
let res;
|
|
3271
|
+
let rows = null;
|
|
3072
3272
|
if (escalated) {
|
|
3073
3273
|
closeChildren(b);
|
|
3074
3274
|
escalated.fn.$lhSuppress = true;
|
|
@@ -3085,23 +3285,25 @@ function createLiveHoles(sink, scoped) {
|
|
|
3085
3285
|
p: []
|
|
3086
3286
|
};
|
|
3087
3287
|
try {
|
|
3088
|
-
|
|
3288
|
+
rows = resolveValue(value, res);
|
|
3089
3289
|
} catch (_) {
|
|
3090
|
-
|
|
3290
|
+
leave(b, prevParent, prevScope, prevVisit);
|
|
3091
3291
|
closeChildren(b);
|
|
3092
3292
|
return "";
|
|
3093
3293
|
}
|
|
3094
3294
|
}
|
|
3095
|
-
|
|
3096
|
-
if (
|
|
3295
|
+
leave(b, prevParent, prevScope, prevVisit);
|
|
3296
|
+
if (stamp() !== ownersBefore) {
|
|
3097
3297
|
return res.h.length ? res : res.t[0];
|
|
3098
3298
|
}
|
|
3299
|
+
if (!res.h.length && settled && settled()) return res.t[0];
|
|
3099
3300
|
const id = nextId++;
|
|
3100
3301
|
const key = b.key = "lh:" + id;
|
|
3101
3302
|
const open = `<!--lh:${id}-->`;
|
|
3102
3303
|
const close = `<!--lh:/${id}-->`;
|
|
3103
3304
|
if (!res.h.length) {
|
|
3104
3305
|
b.last = stripMarkers(res.t[0]);
|
|
3306
|
+
b.rows = rows;
|
|
3105
3307
|
sink.openBinding(key, b);
|
|
3106
3308
|
return open + res.t[0] + close;
|
|
3107
3309
|
}
|
|
@@ -3119,7 +3321,7 @@ function createLiveHoles(sink, scoped) {
|
|
|
3119
3321
|
return nextId++;
|
|
3120
3322
|
},
|
|
3121
3323
|
active() {
|
|
3122
|
-
return !inScope || inScope();
|
|
3324
|
+
return (!inScope || inScope()) && !(settled && settled());
|
|
3123
3325
|
},
|
|
3124
3326
|
attr(cap) {
|
|
3125
3327
|
const owner = getOwner();
|
|
@@ -3132,9 +3334,10 @@ function createLiveHoles(sink, scoped) {
|
|
|
3132
3334
|
sweep() {
|
|
3133
3335
|
if (b.closed) return;
|
|
3134
3336
|
const prevSweeping = engine.sweeping;
|
|
3337
|
+
const prevScope = engine.scope;
|
|
3135
3338
|
engine.sweeping = true;
|
|
3339
|
+
engine.scope = null;
|
|
3136
3340
|
engine.gateHit = false;
|
|
3137
|
-
const sweepOwnersBefore = stamp();
|
|
3138
3341
|
let html = "";
|
|
3139
3342
|
try {
|
|
3140
3343
|
let group = null;
|
|
@@ -3161,15 +3364,23 @@ function createLiveHoles(sink, scoped) {
|
|
|
3161
3364
|
};
|
|
3162
3365
|
swept(owner, holeCtx, run);
|
|
3163
3366
|
} catch (err) {
|
|
3164
|
-
if (ssrHandleError(err, true))
|
|
3367
|
+
if (ssrHandleError(err, true)) {
|
|
3368
|
+
if (!engine.sweptOwners) return;
|
|
3369
|
+
latched(owner, "owners", false);
|
|
3370
|
+
b.closed = true;
|
|
3371
|
+
sink.closeBinding(b.key);
|
|
3372
|
+
return;
|
|
3373
|
+
}
|
|
3165
3374
|
b.closed = true;
|
|
3166
3375
|
sink.closeBinding(b.key);
|
|
3167
|
-
sink.error("lha:" + cap.id, wireErrorMessage(err));
|
|
3376
|
+
sink.error("lha:" + cap.id, wireErrorMessage(err, errorScope));
|
|
3168
3377
|
return;
|
|
3169
3378
|
} finally {
|
|
3170
3379
|
engine.sweeping = prevSweeping;
|
|
3380
|
+
engine.scope = prevScope;
|
|
3171
3381
|
}
|
|
3172
|
-
if (engine.gateHit
|
|
3382
|
+
if (engine.gateHit) {
|
|
3383
|
+
latched(owner, "records", false);
|
|
3173
3384
|
b.closed = true;
|
|
3174
3385
|
sink.closeBinding(b.key);
|
|
3175
3386
|
return;
|
|
@@ -3234,7 +3445,9 @@ function ssr(t) {
|
|
|
3234
3445
|
cap = {
|
|
3235
3446
|
id,
|
|
3236
3447
|
parts: [prefix],
|
|
3237
|
-
base: prefix
|
|
3448
|
+
base: prefix,
|
|
3449
|
+
at: lastOpen.seg,
|
|
3450
|
+
inject
|
|
3238
3451
|
};
|
|
3239
3452
|
return true;
|
|
3240
3453
|
};
|
|
@@ -3283,7 +3496,10 @@ function ssr(t) {
|
|
|
3283
3496
|
});
|
|
3284
3497
|
}
|
|
3285
3498
|
} else {
|
|
3286
|
-
cap
|
|
3499
|
+
if (cap) {
|
|
3500
|
+
result.t[cap.at] = result.t[cap.at].replace(cap.inject, "");
|
|
3501
|
+
cap = null;
|
|
3502
|
+
}
|
|
3287
3503
|
result.h.push(ssrGroupSlot(lastGroupVal.fn, lastGroupIdx++));
|
|
3288
3504
|
result.p.push(lastGroupVal.p);
|
|
3289
3505
|
result.t.push("");
|
|
@@ -3346,12 +3562,15 @@ function ssr(t) {
|
|
|
3346
3562
|
f: hole
|
|
3347
3563
|
});
|
|
3348
3564
|
} else {
|
|
3565
|
+
result.t[cap.at] = result.t[cap.at].replace(cap.inject, "");
|
|
3349
3566
|
cap = null;
|
|
3350
3567
|
}
|
|
3351
3568
|
}
|
|
3352
3569
|
} else {
|
|
3353
3570
|
const capturing = live && !hp.pos[i - 1] && captureStart();
|
|
3571
|
+
const scope = live && hp.pos[i - 1] && live.nest(hole);
|
|
3354
3572
|
const r = tryResolveFunctionHole(hole);
|
|
3573
|
+
if (scope) live.scope = scope;
|
|
3355
3574
|
if (typeof r === "string") {
|
|
3356
3575
|
s += r;
|
|
3357
3576
|
if (capturing) {
|
|
@@ -3361,7 +3580,10 @@ function ssr(t) {
|
|
|
3361
3580
|
});
|
|
3362
3581
|
}
|
|
3363
3582
|
} else {
|
|
3364
|
-
if (capturing)
|
|
3583
|
+
if (capturing) {
|
|
3584
|
+
s = s.replace(cap.inject, "");
|
|
3585
|
+
cap = null;
|
|
3586
|
+
}
|
|
3365
3587
|
result = {
|
|
3366
3588
|
t: [s],
|
|
3367
3589
|
h: [],
|
|
@@ -3426,14 +3648,12 @@ function ssrClassName(value) {
|
|
|
3426
3648
|
if (typeof value === "number") return "" + value;
|
|
3427
3649
|
if (!value) return "";
|
|
3428
3650
|
if (typeof value === "string") return escape(value, true);
|
|
3429
|
-
if (isSlotValue(value)) return slotValueInline("class", value) ?? "";
|
|
3430
3651
|
value = classListToObject(value);
|
|
3431
3652
|
let classKeys = Object.keys(value),
|
|
3432
3653
|
result = "";
|
|
3433
3654
|
for (let i = 0, len = classKeys.length; i < len; i++) {
|
|
3434
3655
|
const key = classKeys[i];
|
|
3435
|
-
|
|
3436
|
-
if (isSlotValue(classValue)) classValue = slotValueInline("class", classValue);
|
|
3656
|
+
const classValue = value[key];
|
|
3437
3657
|
if (!key || key === "undefined" || !classValue) continue;
|
|
3438
3658
|
result && (result += " ");
|
|
3439
3659
|
result += escape(key, true);
|
|
@@ -3443,13 +3663,11 @@ function ssrClassName(value) {
|
|
|
3443
3663
|
function ssrStyle(value) {
|
|
3444
3664
|
if (!value) return "";
|
|
3445
3665
|
if (typeof value === "string") return escape(value, true);
|
|
3446
|
-
if (isSlotValue(value)) return slotValueInline("style", value) ?? "";
|
|
3447
3666
|
let result = "";
|
|
3448
3667
|
const k = Object.keys(value);
|
|
3449
3668
|
for (let i = 0; i < k.length; i++) {
|
|
3450
3669
|
const s = escape(k[i], true);
|
|
3451
|
-
|
|
3452
|
-
if (isSlotValue(v)) v = slotValueInline("style", v);
|
|
3670
|
+
const v = value[k[i]];
|
|
3453
3671
|
if (v != undefined) {
|
|
3454
3672
|
const r = escape(v, true);
|
|
3455
3673
|
if (r != undefined && r !== "undefined") {
|
|
@@ -3461,7 +3679,6 @@ function ssrStyle(value) {
|
|
|
3461
3679
|
return result;
|
|
3462
3680
|
}
|
|
3463
3681
|
function ssrStyleProperty(name, value) {
|
|
3464
|
-
if (isSlotValue(value)) value = slotValueInline("style", value);
|
|
3465
3682
|
return value != null ? name + value : "";
|
|
3466
3683
|
}
|
|
3467
3684
|
function ssrStyleProperties(...entries) {
|
|
@@ -3472,30 +3689,25 @@ function ssrStyleProperties(...entries) {
|
|
|
3472
3689
|
}
|
|
3473
3690
|
return result;
|
|
3474
3691
|
}
|
|
3475
|
-
function ssrElement(tag, props, children, needsId, skip, attrs
|
|
3692
|
+
function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
3476
3693
|
const hk = needsId ? ssrHydrationKey() : "";
|
|
3477
3694
|
if (typeof props === "function") props = props();
|
|
3478
3695
|
let sources = null;
|
|
3479
3696
|
let proxy = false;
|
|
3480
3697
|
let viewKeys = null;
|
|
3481
3698
|
let owners = null;
|
|
3482
|
-
let ownerIndex = null;
|
|
3483
3699
|
const ctx = renderConfig.context;
|
|
3484
|
-
const slots = ctx !== undefined && ctx.claims !== undefined;
|
|
3485
3700
|
const link = tag === "a" && ctx !== undefined && ctx.linkClaim !== undefined ? {} : null;
|
|
3486
3701
|
if (Array.isArray(props)) {
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
if (slots) ownerIndex = [];
|
|
3497
|
-
collectSpreadSources(tag, props, viewKeys, owners, slots, ownerIndex);
|
|
3498
|
-
}
|
|
3702
|
+
let i = 0;
|
|
3703
|
+
for (; i < props.length; i++) {
|
|
3704
|
+
const s = props[i];
|
|
3705
|
+
if (s == null || typeof s === "function" || $PROXY in s) break;
|
|
3706
|
+
}
|
|
3707
|
+
if (i === props.length) sources = props;else {
|
|
3708
|
+
viewKeys = [];
|
|
3709
|
+
owners = [];
|
|
3710
|
+
collectSpreadSources(props, viewKeys, owners);
|
|
3499
3711
|
}
|
|
3500
3712
|
} else if (props == null) {
|
|
3501
3713
|
props = {};
|
|
@@ -3505,13 +3717,10 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
|
|
|
3505
3717
|
owners = [];
|
|
3506
3718
|
sourceOwners(props, viewKeys, owners);
|
|
3507
3719
|
} else proxy = true;
|
|
3508
|
-
} else if (slots && props.$slot === true) {
|
|
3509
|
-
props = slotSpreadSource(tag, props);
|
|
3510
3720
|
}
|
|
3511
3721
|
const info = tagInfo(tag);
|
|
3512
3722
|
const skipChildren = info.isVoid;
|
|
3513
3723
|
let result = info.open + hk;
|
|
3514
|
-
let behaviors = null;
|
|
3515
3724
|
let childOwner = null;
|
|
3516
3725
|
const last = sources === null ? 0 : sources.length - 1;
|
|
3517
3726
|
let keysOf = null;
|
|
@@ -3546,22 +3755,9 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
|
|
|
3546
3755
|
if (prop === undefined) continue;
|
|
3547
3756
|
}
|
|
3548
3757
|
const value = props[key];
|
|
3549
|
-
if (value == undefined)
|
|
3550
|
-
if (slots && claims !== undefined && (prop === "ref" || isEventName(prop))) behaviors = spreadBehaviorPosition(behaviors, prop, value, ctx.claims, ownerIndex !== null ? ownerIndex[i] : s, true);
|
|
3551
|
-
continue;
|
|
3552
|
-
}
|
|
3553
|
-
if (prop.startsWith("prop:")) {
|
|
3554
|
-
if (slots && typeof value === "object") spreadPropPosition(prop, value);
|
|
3555
|
-
continue;
|
|
3556
|
-
}
|
|
3557
|
-
if (prop === "ref" || isEventName(prop)) {
|
|
3558
|
-
if (slots) behaviors = spreadBehaviorPosition(behaviors, prop, value, ctx.claims, ownerIndex !== null ? ownerIndex[i] : s, claims !== undefined);
|
|
3559
|
-
continue;
|
|
3560
|
-
}
|
|
3758
|
+
if (value == undefined || prop.startsWith("prop:") || prop === "ref" || isEventName(prop)) continue;
|
|
3561
3759
|
if (link !== null && LinkAttributes.has(prop)) link[prop] = value;
|
|
3562
|
-
if (
|
|
3563
|
-
result += spreadObjectAttribute(prop, value);
|
|
3564
|
-
} else if (prop === "style") {
|
|
3760
|
+
if (prop === "style") {
|
|
3565
3761
|
result += ` style="${ssrStyle(value)}"`;
|
|
3566
3762
|
} else if (prop === "class") {
|
|
3567
3763
|
result += ` class="${ssrClassName(value)}"`;
|
|
@@ -3572,7 +3768,6 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
|
|
|
3572
3768
|
}
|
|
3573
3769
|
}
|
|
3574
3770
|
}
|
|
3575
|
-
if (slots && (behaviors !== null || claims !== undefined)) result += spreadBehaviorMarkers(behaviors, claims, ctx.claims);
|
|
3576
3771
|
if (attrs !== undefined) result += typeof attrs === "function" ? attrs() : attrs;
|
|
3577
3772
|
if (link !== null && link.href !== undefined) result += ssrLinkClaim(link);
|
|
3578
3773
|
if (skipChildren) return {
|
|
@@ -3592,6 +3787,13 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
|
|
|
3592
3787
|
};
|
|
3593
3788
|
return ssr([result + ">", info.close], resolveSSRNode(children, undefined, true));
|
|
3594
3789
|
}
|
|
3790
|
+
function collectSpreadSources(props, viewKeys, owners) {
|
|
3791
|
+
for (let i = 0; i < props.length; i++) {
|
|
3792
|
+
let s = props[i];
|
|
3793
|
+
if (typeof s === "function") s = s();
|
|
3794
|
+
if (s != null) sourceOwners(s, viewKeys, owners);
|
|
3795
|
+
}
|
|
3796
|
+
}
|
|
3595
3797
|
function spreadFormAttribute(prop, info, keys, keysOf, skip) {
|
|
3596
3798
|
const defaultProp = info.formDefaults[prop];
|
|
3597
3799
|
if (defaultProp !== undefined && (skip === undefined || !skip(defaultProp))) {
|
|
@@ -3607,19 +3809,14 @@ function spreadFormAttribute(prop, info, keys, keysOf, skip) {
|
|
|
3607
3809
|
}
|
|
3608
3810
|
function ssrElementAttribute(key, value) {
|
|
3609
3811
|
if (value == undefined) return "";
|
|
3610
|
-
if (key === "style" || key === "class") {
|
|
3611
|
-
return typeof value === "object" ? slotClassOrStyle(key, value) : ` ${key}="${key === "class" ? ssrClassName(value) : ssrStyle(value)}"`;
|
|
3612
|
-
}
|
|
3613
|
-
if (isSlotValue(value)) return slotAttribute(key, value);
|
|
3812
|
+
if (key === "style" || key === "class") return ` ${key}="${key === "class" ? ssrClassName(value) : ssrStyle(value)}"`;
|
|
3614
3813
|
if (typeof value === "boolean") return value ? ` ${key}` : "";
|
|
3615
3814
|
return value === "" ? ` ${key}` : ` ${key}="${escape(value, true)}"`;
|
|
3616
3815
|
}
|
|
3617
3816
|
function ssrAttribute(key, value) {
|
|
3618
3817
|
if (typeof value === "string") return ` ${key}="${value}"`;
|
|
3619
3818
|
if (value == null || value === false) return "";
|
|
3620
|
-
if (typeof value === "object") {
|
|
3621
|
-
return isSlotValue(value) ? slotAttribute(key, value) : ` ${key}="${escape(String(value), true)}"`;
|
|
3622
|
-
}
|
|
3819
|
+
if (typeof value === "object") return ` ${key}="${escape(String(value), true)}"`;
|
|
3623
3820
|
if (typeof value === "function") return ` ${key}="${escape(String(value), true)}"`;
|
|
3624
3821
|
return value === true ? ` ${key}` : ` ${key}="${value}"`;
|
|
3625
3822
|
}
|
|
@@ -3627,319 +3824,6 @@ function ssrHydrationKey() {
|
|
|
3627
3824
|
const hk = getHydrationKey();
|
|
3628
3825
|
return hk ? ` _hk=${hk}` : "";
|
|
3629
3826
|
}
|
|
3630
|
-
const CLAIMS_STREAM = 1;
|
|
3631
|
-
const CLAIMS_DOCUMENT = 2;
|
|
3632
|
-
const SLOT_VALUE = /*#__PURE__*/Symbol.for("solid.slot-value");
|
|
3633
|
-
const SLOT_MARKER = "_s:";
|
|
3634
|
-
const SLOT_FACE_STREAM = 0;
|
|
3635
|
-
const SLOT_FACE_DATA = 1;
|
|
3636
|
-
const SLOT_FACE_MARKUP = 2;
|
|
3637
|
-
const BINDING_SLOT_POSITION = "BINDING_SLOT_POSITION";
|
|
3638
|
-
function slotFinding(sv, reason, position, message, severity = "warn") {
|
|
3639
|
-
{
|
|
3640
|
-
const ctx = sharedConfig.context;
|
|
3641
|
-
if (ctx) {
|
|
3642
|
-
const id = `${sv[SLOT_VALUE]}\u0000${sv.k}\u0000${reason}\u0000${position || ""}`;
|
|
3643
|
-
const seen = ctx.slotFindings || (ctx.slotFindings = new Set());
|
|
3644
|
-
if (seen.has(id)) return;
|
|
3645
|
-
seen.add(id);
|
|
3646
|
-
}
|
|
3647
|
-
devCheck({
|
|
3648
|
-
code: BINDING_SLOT_POSITION,
|
|
3649
|
-
kind: "ssr",
|
|
3650
|
-
severity,
|
|
3651
|
-
message,
|
|
3652
|
-
data: {
|
|
3653
|
-
reason,
|
|
3654
|
-
occurrence: sv[SLOT_VALUE],
|
|
3655
|
-
key: sv.k,
|
|
3656
|
-
position
|
|
3657
|
-
}
|
|
3658
|
-
});
|
|
3659
|
-
}
|
|
3660
|
-
}
|
|
3661
|
-
function isSlotValue(value) {
|
|
3662
|
-
return value !== null && typeof value === "object" && value[SLOT_VALUE] !== undefined;
|
|
3663
|
-
}
|
|
3664
|
-
function slotValue(occurrence, key, value, face) {
|
|
3665
|
-
const sv = {
|
|
3666
|
-
[SLOT_VALUE]: occurrence,
|
|
3667
|
-
k: key,
|
|
3668
|
-
v: value,
|
|
3669
|
-
f: face
|
|
3670
|
-
};
|
|
3671
|
-
Object.defineProperty(sv, Symbol.toPrimitive, {
|
|
3672
|
-
value: hint => slotValueString(sv, hint === "string" ? "stringified" : "coerced")
|
|
3673
|
-
});
|
|
3674
|
-
Object.defineProperty(sv, "toString", {
|
|
3675
|
-
value: () => slotValueString(sv, "stringified")
|
|
3676
|
-
});
|
|
3677
|
-
Object.defineProperty(sv, "w", {
|
|
3678
|
-
value: () => slotText(sv)
|
|
3679
|
-
});
|
|
3680
|
-
return sv;
|
|
3681
|
-
}
|
|
3682
|
-
function slotValueString(sv, reason) {
|
|
3683
|
-
{
|
|
3684
|
-
const prop = propOfOccurrence(sv[SLOT_VALUE]);
|
|
3685
|
-
slotFinding(sv, reason, undefined, reason === "coerced" ? `[${BINDING_SLOT_POSITION}] \`${prop}\`'s \`${sv.k}\` is a binding-slot value used in an expression ` + `(a comparison, arithmetic, or a branch on its result). The server does not have the value — ` + `the client owns it — so nothing can be computed from it here. It must be the WHOLE value of ` + `an attribute, class name, style property, handler, ref or text child; a decision that depends on it ` + `belongs in the client fill (return the decided value) or in a markup slot.` : `[${BINDING_SLOT_POSITION}] \`${prop}\`'s \`${sv.k}\` is a binding-slot value ` + `and was stringified outside a bindable position — it must be the WHOLE value of an attribute, ` + `class name, style property, handler, ref or text child (\`class={row.${sv.k}}\`, not \`class={\`x \${row.${sv.k}}\`}\`). ` + `If it is, the element was compiled without the \`serverComponents\` compiler option. ` + `Nothing renders here on either face.`);
|
|
3686
|
-
}
|
|
3687
|
-
return "";
|
|
3688
|
-
}
|
|
3689
|
-
function slotText(sv) {
|
|
3690
|
-
slotMarkupRead(sv, "text");
|
|
3691
|
-
const v = sv.f === SLOT_FACE_DATA ? sv.v : undefined;
|
|
3692
|
-
const text = typeof v === "string" || typeof v === "number" ? escape("" + v) : "";
|
|
3693
|
-
return `<!--${SLOT_MARKER}t=${slotEntry(sv)}-->${text}<!--/${SLOT_MARKER}t-->`;
|
|
3694
|
-
}
|
|
3695
|
-
function slotMarkupRead(sv, position) {
|
|
3696
|
-
if (sv.f === SLOT_FACE_MARKUP) {
|
|
3697
|
-
slotFinding(sv, "markup", position, `[${BINDING_SLOT_POSITION}] \`${position}\` reads \`${sv.k}\` off slot \`${propOfOccurrence(sv[SLOT_VALUE])}\`, ` + `but the client fill returned markup, not an object. A slot renders one or the other: ` + `return an object (\`{ ${sv.k}: … }\`) for positions, or place the slot as content.`);
|
|
3698
|
-
}
|
|
3699
|
-
}
|
|
3700
|
-
function slotValueInline(kind, sv) {
|
|
3701
|
-
{
|
|
3702
|
-
slotFinding(sv, "inline", kind, `[${BINDING_SLOT_POSITION}] A binding-slot value (\`${sv.k}\` of \`${propOfOccurrence(sv[SLOT_VALUE])}\`) ` + `reached \`${kind}\` inside template quotes, where its position marker cannot be emitted — the ` + `element was compiled without the \`serverComponents\` compiler option. Nothing renders here ` + `on either face.`);
|
|
3703
|
-
}
|
|
3704
|
-
return undefined;
|
|
3705
|
-
}
|
|
3706
|
-
const SLOT_KEY_UNSAFE = /[^A-Za-z0-9_.!~*'()-]/g;
|
|
3707
|
-
function encodeSlotKey(key) {
|
|
3708
|
-
return String(key).replace(SLOT_KEY_UNSAFE, c => encodeURIComponent(c));
|
|
3709
|
-
}
|
|
3710
|
-
function slotEntry(sv, name) {
|
|
3711
|
-
return `${sv[SLOT_VALUE]}:${encodeSlotKey(sv.k)}${name !== undefined ? "=" + encodeSlotKey(name) : ""}`;
|
|
3712
|
-
}
|
|
3713
|
-
function slotMarker(position, entries) {
|
|
3714
|
-
return ` ${SLOT_MARKER}${position}="${entries}"`;
|
|
3715
|
-
}
|
|
3716
|
-
function eventSlotStamp(mode) {
|
|
3717
|
-
return mode === CLAIMS_DOCUMENT ? " _hk" : "";
|
|
3718
|
-
}
|
|
3719
|
-
function propOfOccurrence(occurrence) {
|
|
3720
|
-
const i = occurrence.indexOf("#");
|
|
3721
|
-
return i === -1 ? occurrence : occurrence.slice(0, i);
|
|
3722
|
-
}
|
|
3723
|
-
function slotAttribute(key, sv) {
|
|
3724
|
-
slotMarkupRead(sv, key);
|
|
3725
|
-
let out = "";
|
|
3726
|
-
if (sv.f === SLOT_FACE_DATA) {
|
|
3727
|
-
const v = sv.v;
|
|
3728
|
-
if (v != null && v !== false) {
|
|
3729
|
-
out = v === true || v === "" ? ` ${key}` : ` ${key}="${escape(String(v), true)}"`;
|
|
3730
|
-
}
|
|
3731
|
-
}
|
|
3732
|
-
return out + slotMarker(key, slotEntry(sv));
|
|
3733
|
-
}
|
|
3734
|
-
function slotClassOrStyle(key, value) {
|
|
3735
|
-
const isClass = key === "class";
|
|
3736
|
-
if (isSlotValue(value)) {
|
|
3737
|
-
slotMarkupRead(value, key);
|
|
3738
|
-
let out = "";
|
|
3739
|
-
if (value.f === SLOT_FACE_DATA && value.v != null) {
|
|
3740
|
-
out = ` ${key}="${isClass ? ssrClassName(value.v) : ssrStyle(value.v)}"`;
|
|
3741
|
-
}
|
|
3742
|
-
return out + slotMarker(key, slotEntry(value));
|
|
3743
|
-
}
|
|
3744
|
-
if (typeof value === "object" && value !== null) {
|
|
3745
|
-
const obj = isClass ? classListToObject(value) : value;
|
|
3746
|
-
let entries = "";
|
|
3747
|
-
let inner = "";
|
|
3748
|
-
for (const name of Object.keys(obj)) {
|
|
3749
|
-
let v = obj[name];
|
|
3750
|
-
if (isSlotValue(v)) {
|
|
3751
|
-
slotMarkupRead(v, `${key}:${name}`);
|
|
3752
|
-
entries += (entries ? "," : "") + slotEntry(v, name);
|
|
3753
|
-
v = v.f === SLOT_FACE_DATA ? v.v : undefined;
|
|
3754
|
-
}
|
|
3755
|
-
if (isClass) {
|
|
3756
|
-
if (!name || name === "undefined" || !v) continue;
|
|
3757
|
-
inner += (inner ? " " : "") + escape(name, true);
|
|
3758
|
-
} else if (v != undefined) {
|
|
3759
|
-
const r = escape(v, true);
|
|
3760
|
-
if (r != undefined && r !== "undefined") {
|
|
3761
|
-
inner += (inner ? ";" : "") + `${escape(name, true)}:${r}`;
|
|
3762
|
-
}
|
|
3763
|
-
}
|
|
3764
|
-
}
|
|
3765
|
-
if (entries === "") return ` ${key}="${inner}"`;
|
|
3766
|
-
return (inner ? ` ${key}="${inner}"` : "") + slotMarker(key, entries);
|
|
3767
|
-
}
|
|
3768
|
-
return ` ${key}="${isClass ? ssrClassName(value) : ssrStyle(value)}"`;
|
|
3769
|
-
}
|
|
3770
|
-
function eventPosition(prop) {
|
|
3771
|
-
return prop.slice(2).toLowerCase();
|
|
3772
|
-
}
|
|
3773
|
-
function spreadBehaviorPosition(behaviors, prop, value, mode, index, settle) {
|
|
3774
|
-
if (!isAttrName(prop)) return behaviors;
|
|
3775
|
-
const pos = prop === "ref" ? "ref" : eventPosition(prop);
|
|
3776
|
-
const entries = value == null ? "" : claimEntries(pos, value, mode);
|
|
3777
|
-
if (!settle) {
|
|
3778
|
-
if (entries) (behaviors ||= new Map()).set(pos, entries);
|
|
3779
|
-
return behaviors;
|
|
3780
|
-
}
|
|
3781
|
-
behaviors ||= new Map();
|
|
3782
|
-
const b = behaviors.get(pos);
|
|
3783
|
-
if (b === undefined) behaviors.set(pos, {
|
|
3784
|
-
e: entries,
|
|
3785
|
-
at: index
|
|
3786
|
-
});else {
|
|
3787
|
-
b.e = entries;
|
|
3788
|
-
b.at = index;
|
|
3789
|
-
}
|
|
3790
|
-
return behaviors;
|
|
3791
|
-
}
|
|
3792
|
-
function spreadBehaviorMarkers(behaviors, claims, mode) {
|
|
3793
|
-
if (claims !== undefined) {
|
|
3794
|
-
const segments = claims();
|
|
3795
|
-
for (const k in segments) {
|
|
3796
|
-
const map = segments[k];
|
|
3797
|
-
for (const pos in map) {
|
|
3798
|
-
const value = map[pos];
|
|
3799
|
-
behaviors ||= new Map();
|
|
3800
|
-
const b = behaviors.get(pos);
|
|
3801
|
-
if (pos === "ref") {
|
|
3802
|
-
if (value == null) continue;
|
|
3803
|
-
const entries = claimEntries("ref", value, mode);
|
|
3804
|
-
if (!entries) continue;
|
|
3805
|
-
if (b === undefined) behaviors.set("ref", {
|
|
3806
|
-
e: entries,
|
|
3807
|
-
at: -1
|
|
3808
|
-
});else b.e = b.e ? b.e + "," + entries : entries;
|
|
3809
|
-
continue;
|
|
3810
|
-
}
|
|
3811
|
-
if (b !== undefined && b.at >= +k) continue;
|
|
3812
|
-
const entries = value == null ? "" : claimEntries(pos, value, mode);
|
|
3813
|
-
if (b === undefined) behaviors.set(pos, {
|
|
3814
|
-
e: entries,
|
|
3815
|
-
at: -1
|
|
3816
|
-
});else b.e = entries;
|
|
3817
|
-
}
|
|
3818
|
-
}
|
|
3819
|
-
}
|
|
3820
|
-
let out = "";
|
|
3821
|
-
let events = false;
|
|
3822
|
-
if (behaviors !== null) {
|
|
3823
|
-
for (const [pos, b] of behaviors) {
|
|
3824
|
-
const e = claims === undefined ? b : b.e;
|
|
3825
|
-
if (!e) continue;
|
|
3826
|
-
if (pos === "ref") out += slotMarker("ref", e);else {
|
|
3827
|
-
out += slotMarker("on:" + pos, e);
|
|
3828
|
-
events = true;
|
|
3829
|
-
}
|
|
3830
|
-
}
|
|
3831
|
-
}
|
|
3832
|
-
return events ? out + eventSlotStamp(mode) : out;
|
|
3833
|
-
}
|
|
3834
|
-
function collectSpreadSources(tag, props, viewKeys, owners, slots, ownerIndex) {
|
|
3835
|
-
for (let i = 0; i < props.length; i++) {
|
|
3836
|
-
let s = props[i];
|
|
3837
|
-
if (typeof s === "function") s = s();
|
|
3838
|
-
if (s != null) {
|
|
3839
|
-
if (slots && !($PROXY in s) && s.$slot === true) s = slotSpreadSource(tag, s);
|
|
3840
|
-
if (ownerIndex === null) sourceOwners(s, viewKeys, owners);else {
|
|
3841
|
-
const ks = [];
|
|
3842
|
-
const os = [];
|
|
3843
|
-
sourceOwners(s, ks, os);
|
|
3844
|
-
for (let j = 0; j < ks.length; j++) {
|
|
3845
|
-
const at = viewKeys.indexOf(ks[j]);
|
|
3846
|
-
if (at !== -1) {
|
|
3847
|
-
viewKeys.splice(at, 1);
|
|
3848
|
-
owners.splice(at, 1);
|
|
3849
|
-
ownerIndex.splice(at, 1);
|
|
3850
|
-
}
|
|
3851
|
-
viewKeys.push(ks[j]);
|
|
3852
|
-
owners.push(os[j]);
|
|
3853
|
-
ownerIndex.push(i);
|
|
3854
|
-
}
|
|
3855
|
-
}
|
|
3856
|
-
}
|
|
3857
|
-
}
|
|
3858
|
-
}
|
|
3859
|
-
function spreadPropPosition(prop, value) {
|
|
3860
|
-
if (isSlotValue(value)) {
|
|
3861
|
-
slotFinding(value, "prop", prop, `[${BINDING_SLOT_POSITION}] \`${value.k}\` of slot \`${propOfOccurrence(value[SLOT_VALUE])}\` is bound ` + `at \`${prop}\`. Property positions are not bindable (the server renders no properties): nothing ` + `renders here. Bind the attribute form (\`${prop.slice(5)}\`), or set the property in the client fill's ref.`);
|
|
3862
|
-
}
|
|
3863
|
-
}
|
|
3864
|
-
function spreadObjectAttribute(prop, value) {
|
|
3865
|
-
if (prop === "style" || prop === "class") return slotClassOrStyle(prop, value);
|
|
3866
|
-
if (!isAttrName(prop)) return "";
|
|
3867
|
-
if (value[SLOT_VALUE] !== undefined) return slotAttribute(prop, value);
|
|
3868
|
-
return ` ${prop}="${escape(value, true)}"`;
|
|
3869
|
-
}
|
|
3870
|
-
function slotSpreadSource(tag, source) {
|
|
3871
|
-
{
|
|
3872
|
-
const occurrence = source.$occurrence;
|
|
3873
|
-
const text = `[${BINDING_SLOT_POSITION}] A slot${occurrence ? ` (\`${propOfOccurrence(occurrence)}\`)` : ""} is spread ` + `onto a server-rendered <${tag}>. A binding slot binds by position — name each one ` + `(\`class={row.rowClass} onClick={row.remove}\`) so the template shows what the client owns.`;
|
|
3874
|
-
recordFinding({
|
|
3875
|
-
code: BINDING_SLOT_POSITION,
|
|
3876
|
-
kind: "ssr",
|
|
3877
|
-
severity: "error",
|
|
3878
|
-
message: text,
|
|
3879
|
-
data: {
|
|
3880
|
-
reason: "spread",
|
|
3881
|
-
tag,
|
|
3882
|
-
occurrence
|
|
3883
|
-
}
|
|
3884
|
-
});
|
|
3885
|
-
throw new Error(text);
|
|
3886
|
-
}
|
|
3887
|
-
}
|
|
3888
|
-
function ssrClaim(map) {
|
|
3889
|
-
const mode = sharedConfig.context && sharedConfig.context.claims;
|
|
3890
|
-
if (!mode) return "";
|
|
3891
|
-
let out = "";
|
|
3892
|
-
let events = false;
|
|
3893
|
-
for (const pos in map) {
|
|
3894
|
-
const entries = claimEntries(pos, map[pos], mode);
|
|
3895
|
-
if (!entries) continue;
|
|
3896
|
-
if (pos === "ref") out += slotMarker("ref", entries);else {
|
|
3897
|
-
out += slotMarker("on:" + pos, entries);
|
|
3898
|
-
events = true;
|
|
3899
|
-
}
|
|
3900
|
-
}
|
|
3901
|
-
return events ? out + eventSlotStamp(mode) : out;
|
|
3902
|
-
}
|
|
3903
|
-
function claimEntries(pos, value, mode) {
|
|
3904
|
-
if (Array.isArray(value) && pos !== "ref") {
|
|
3905
|
-
{
|
|
3906
|
-
const sv = value.find(isSlotValue);
|
|
3907
|
-
if (sv !== undefined) {
|
|
3908
|
-
slotFinding(sv, "tuple", pos, `[${BINDING_SLOT_POSITION}] A \`${pos}\` handler position on a server-rendered element received ` + `an array. A position marker names the slot's keys, never data, so a tuple's data cannot reach ` + `the client — nothing binds here. Return the tuple from the fill (\`[handler, data]\`) and ` + `bind that one property.`);
|
|
3909
|
-
} else claimEntries(pos, value[0], mode);
|
|
3910
|
-
}
|
|
3911
|
-
return "";
|
|
3912
|
-
}
|
|
3913
|
-
if (Array.isArray(value)) {
|
|
3914
|
-
let entries = "";
|
|
3915
|
-
for (const v of value) {
|
|
3916
|
-
const inner = claimEntries(pos, v, mode);
|
|
3917
|
-
if (inner) entries += (entries ? "," : "") + inner;
|
|
3918
|
-
}
|
|
3919
|
-
return entries;
|
|
3920
|
-
}
|
|
3921
|
-
if (isSlotValue(value)) {
|
|
3922
|
-
slotMarkupRead(value, pos);
|
|
3923
|
-
return slotEntry(value);
|
|
3924
|
-
}
|
|
3925
|
-
if (typeof value === "function" && !value.$slotWarned && claimInScope(mode)) {
|
|
3926
|
-
value.$slotWarned = true;
|
|
3927
|
-
devCheck({
|
|
3928
|
-
code: BINDING_SLOT_POSITION,
|
|
3929
|
-
kind: "ssr",
|
|
3930
|
-
severity: "warn",
|
|
3931
|
-
message: `[${BINDING_SLOT_POSITION}] A \`${pos}\` position on a server-rendered element received a server-local ` + `function — it can never run. Bind a slot's property there ` + `(\`const row = props.row(args); ${pos === "ref" ? "ref" : "onX"}={row.${pos === "ref" ? "ref" : "onX"}}\`) ` + `so the client supplies it, or bind a mutation to \`action=\`.`,
|
|
3932
|
-
data: {
|
|
3933
|
-
reason: "server-local",
|
|
3934
|
-
position: pos
|
|
3935
|
-
}
|
|
3936
|
-
});
|
|
3937
|
-
}
|
|
3938
|
-
return "";
|
|
3939
|
-
}
|
|
3940
|
-
function claimInScope(mode) {
|
|
3941
|
-
return mode === CLAIMS_STREAM || typeof inServerComponentScope === "function" && inServerComponentScope();
|
|
3942
|
-
}
|
|
3943
3827
|
function ssrLinkClaim(attrs) {
|
|
3944
3828
|
const ctx = renderConfig.context;
|
|
3945
3829
|
if (ctx === undefined || ctx.linkClaim === undefined || attrs["aria-current"] != null) return "";
|
|
@@ -4065,7 +3949,6 @@ function escape(s, attr) {
|
|
|
4065
3949
|
if (!attr && t === "function") return escapeLate(s);
|
|
4066
3950
|
if (attr) {
|
|
4067
3951
|
if (s == null || t === "boolean" || t === "number") return s;
|
|
4068
|
-
if (t === "object" && s[SLOT_VALUE] !== undefined) return s;
|
|
4069
3952
|
return escape(String(s), attr);
|
|
4070
3953
|
}
|
|
4071
3954
|
return s;
|
|
@@ -4078,10 +3961,8 @@ function escapeLate(fn) {
|
|
|
4078
3961
|
if (fn.$esc) return fn;
|
|
4079
3962
|
const w = () => escape(fn());
|
|
4080
3963
|
w.$esc = true;
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
w.$reg = devPeekId();
|
|
4084
|
-
}
|
|
3964
|
+
w.$fn = fn;
|
|
3965
|
+
w.$reg = devPeekId();
|
|
4085
3966
|
if (fn.$lhSkip) w.$lhSkip = true;
|
|
4086
3967
|
if (fn.$lhSuppress) w.$lhSuppress = true;
|
|
4087
3968
|
if (fn.$lhBinding) w.$lhBinding = fn.$lhBinding;
|
|
@@ -4177,7 +4058,7 @@ function generateHydrationScript({
|
|
|
4177
4058
|
eventNames,
|
|
4178
4059
|
nonce
|
|
4179
4060
|
} = {}) {
|
|
4180
|
-
return hydrationBootstrap(eventNames,
|
|
4061
|
+
return hydrationBootstrap(eventNames, destinationNonce(nonce, "script"), false);
|
|
4181
4062
|
}
|
|
4182
4063
|
function hydrationBootstrap(eventNames = ["click", "input"], nonce, ledger) {
|
|
4183
4064
|
return `<script${nonce ? ` nonce="${escape(String(nonce), true)}"` : ""}>window._$HY||(e=>{let t=e=>e&&e.hasAttribute&&(e.hasAttribute("_hk")?e:t(e.host&&e.host.nodeType?e.host:e.parentNode));["${eventNames.join('","')}"].forEach((o=>document.addEventListener(o,(o=>{if(!e.events)return;let s=t(o.composedPath&&o.composedPath()[0]||o.target);s&&!e.completed.has(s)&&e.events.push([s,o])}))))})(_$HY={events:[],completed:new WeakSet,r:new Proxy({},{set:(r,k,v)=>(v instanceof Promise&&v.catch(()=>{}),r[k]=v,!0)}),${ledger ? "s:{}," : ""}fe(){}});</script><!--xs-->`;
|
|
@@ -4193,10 +4074,12 @@ function allSettled(promises) {
|
|
|
4193
4074
|
return size;
|
|
4194
4075
|
});
|
|
4195
4076
|
}
|
|
4196
|
-
function
|
|
4197
|
-
if (noScripts || !context || !context.bootstrap) return
|
|
4077
|
+
function withShellEnd(html, context, renderId, nonce, noScripts) {
|
|
4078
|
+
if (noScripts || !context || !context.bootstrap) return html;
|
|
4198
4079
|
const id = JSON.stringify(renderId).replace(/</g, "\\u003C");
|
|
4199
|
-
|
|
4080
|
+
const marker = `<script${nonceAttr(nonce, "script")}>_$HY.s[${id}]=1,_$HY.sw&&_$HY.sw(${id})</script>`;
|
|
4081
|
+
const at = html.indexOf("</body>", html.length - 512);
|
|
4082
|
+
return at < 0 ? html + marker : html.slice(0, at) + marker + html.slice(at);
|
|
4200
4083
|
}
|
|
4201
4084
|
function assembleDocument(html, emittedAssets, preloadLinks, inlineStyles, scripts, nonce, headTags, onHead) {
|
|
4202
4085
|
const scriptTag = scripts ? `<script${nonceAttr(nonce, "script")}>${scripts}</script>` : "";
|
|
@@ -4388,10 +4271,6 @@ function tryResolveString(node, nested) {
|
|
|
4388
4271
|
if (node.h && node.h.length > 0) return {
|
|
4389
4272
|
merge: node
|
|
4390
4273
|
};
|
|
4391
|
-
if (node[SLOT_VALUE] !== undefined) {
|
|
4392
|
-
ssrTextTail = false;
|
|
4393
|
-
return node.w();
|
|
4394
|
-
}
|
|
4395
4274
|
if (node.t === undefined) {
|
|
4396
4275
|
unrecognizedInsert(node);
|
|
4397
4276
|
return "";
|
|
@@ -4445,9 +4324,6 @@ function resolveSSRNode(node, result = {
|
|
|
4445
4324
|
} else if (node.t !== undefined) {
|
|
4446
4325
|
result.t[result.t.length - 1] += node.t;
|
|
4447
4326
|
ssrTextTail = false;
|
|
4448
|
-
} else if (node[SLOT_VALUE] !== undefined) {
|
|
4449
|
-
result.t[result.t.length - 1] += node.w();
|
|
4450
|
-
ssrTextTail = false;
|
|
4451
4327
|
} else unrecognizedInsert(node);
|
|
4452
4328
|
} else if (t === "function") {
|
|
4453
4329
|
const live = sharedConfig.context && sharedConfig.context.liveHoles;
|
|
@@ -4458,6 +4334,7 @@ function resolveSSRNode(node, result = {
|
|
|
4458
4334
|
ssrTextTail = true;
|
|
4459
4335
|
} else resolveSSRNode(liveNode, result, false, true);
|
|
4460
4336
|
} else {
|
|
4337
|
+
const scope = live && live.nest(node);
|
|
4461
4338
|
try {
|
|
4462
4339
|
resolveSSRNode(node(), result, false, true);
|
|
4463
4340
|
} catch (err) {
|
|
@@ -4469,6 +4346,8 @@ function resolveSSRNode(node, result = {
|
|
|
4469
4346
|
result.t.push("");
|
|
4470
4347
|
ssrTextTail = true;
|
|
4471
4348
|
}
|
|
4349
|
+
} finally {
|
|
4350
|
+
if (scope) live.scope = scope;
|
|
4472
4351
|
}
|
|
4473
4352
|
}
|
|
4474
4353
|
}
|
|
@@ -4889,7 +4768,7 @@ function dispatchAsInteraction(_e, fn) {
|
|
|
4889
4768
|
return fn();
|
|
4890
4769
|
}
|
|
4891
4770
|
function notSup() {
|
|
4892
|
-
throw new Error("Client-only API called on the server side. Run client-only code in
|
|
4771
|
+
throw new Error("Client-only API called on the server side. Run client-only code in onSettled, or conditionally run client-only component with <Show>.");
|
|
4893
4772
|
}
|
|
4894
4773
|
|
|
4895
4774
|
setContainerTraceResolver(getProjectionTrace);
|
|
@@ -5028,4 +4907,4 @@ function httpHeader(name, value, options) {
|
|
|
5028
4907
|
}
|
|
5029
4908
|
}
|
|
5030
4909
|
|
|
5031
|
-
export {
|
|
4910
|
+
export { ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, HydrationScript, MathMLElements, NULL_BODY_STATUSES, Namespaces, Portal, RESPONSE_HEADER_VALUE_LIMIT, REVALIDATE_ALL, 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, configureServerErrors, createLiveHoles, createRequestEvent, createResponseStub, createSSRResponse, notSup as delegateEvents, dispatchAsInteraction, dynamic, notSup as dynamicProperty, effect, escape, generateHydrationScript, notSup as getDelegatedRoot, getExpectedRedirectStatus, getHydrationKey, getHydrationWriter, notSup as getNextElement, notSup as getNextMarker, notSup as getNextMatch, getRequestEvent, getServerFunctionMetadata, getServerFunctionRPC, getTraceContext, hasFlashCookie, hasServerLinkState, httpHeader, httpStatus, notSup as hydrate, notSup as insert, isDev, isHref, isResponseEnvelope, isSafeError, isServer, isServerFunction, markSafeError, memo, parseCookieHeader, notSup as readShallow, redirect, notSup as ref, notSup as registerDelegatedContainer, notSup as registerDelegatedRoot, registerElementClaim, reload, notSup as render, renderToStream, renderToString, reportRequestFailure, resolveSSRNode, resolveSSRSelectValues, respond, notSup as runHydrationEvents, serializeCookie, notSup as setAttribute, notSup as setAttributeNS, setLinkClaim, notSup as setProperty, notSup as setStyleProperty, notSup as spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrElementAttribute, ssrGroup, ssrHydrationKey, ssrLinkClaim, ssrSelectValues, ssrStyle, ssrStyleProperties, ssrStyleProperty, notSup as style, takeHydrationValue, notSup as template, notSup as unregisterDelegatedContainer, notSup as unregisterDelegatedRoot, useHead };
|