@solidjs/web 2.0.0-rc.21 → 2.0.0-rc.22
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/server.dev.js +380 -239
- package/dist/server.js +377 -238
- package/dist/server.observe.js +377 -238
- package/dist/web.dev.js +125 -82
- package/dist/web.js +103 -81
- package/dist/web.observe.js +103 -81
- package/frames/dist/client.dev.js +7 -2
- package/frames/dist/client.js +7 -2
- package/frames/dist/client.observe.js +7 -2
- package/frames/dist/server.dev.js +122 -62
- package/frames/dist/server.js +122 -62
- package/frames/dist/server.observe.js +122 -62
- package/frames/dist/wire.js +1 -1
- package/package.json +2 -2
- package/serialization/dist/serialization.js +5 -4
- package/serialization/types/index.d.ts +8 -1
- package/serialization/types/serializer.d.ts +8 -1
- package/server-functions/dist/client.dev.js +5 -3
- package/server-functions/dist/client.js +5 -3
- package/server-functions/dist/client.observe.js +5 -3
- package/types/client.d.ts +54 -3
- package/types/constants.d.ts +2 -1
- package/types/frames/frame-client.d.ts +2 -0
- package/types/frames/serializer.d.ts +8 -1
- package/types/frames/tree-rewrite.d.ts +7 -0
- package/types/serializer.d.ts +8 -1
- package/types/server-functions/shared.d.ts +3 -2
- package/types/server.d.ts +48 -7
package/dist/server.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createRenderEffect, createMemo, getOwner, createRoot, $PROXY,
|
|
1
|
+
import { createRenderEffect, createMemo, getOwner, createRoot, $PROXY, runWithOwner, createOwner, onCleanup, 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
3
|
import { sharedConfig, ssrSanitizeError, beginEdgesRender, reportServerError, viewOf, sourceOwners, ssrHandleError, inServerComponentScope, creationStamp, dynamicCore, getProjectionTrace, shareAsyncIterable } from 'solid-js/internal';
|
|
4
4
|
export { ssrScope as scope } from 'solid-js/internal';
|
|
@@ -271,7 +271,15 @@ function rewriteTree(value, visit, withPath) {
|
|
|
271
271
|
} catch (err) {
|
|
272
272
|
if (err !== CYCLE) throw err;
|
|
273
273
|
}
|
|
274
|
-
|
|
274
|
+
const memo = state.memo || (state.memo = new Map());
|
|
275
|
+
const marks = {
|
|
276
|
+
at: new Map(),
|
|
277
|
+
stack: [],
|
|
278
|
+
changed: new Set(),
|
|
279
|
+
next: 0
|
|
280
|
+
};
|
|
281
|
+
mark(value, visit, path, memo, marks);
|
|
282
|
+
return clone(value, memo, marks.changed);
|
|
275
283
|
}
|
|
276
284
|
function shape(value) {
|
|
277
285
|
return Array.isArray(value) ? 1 : Object.getPrototypeOf(value) === Object.prototype ? 2 : 0;
|
|
@@ -319,28 +327,73 @@ function cow(value, visit, path, depth, state) {
|
|
|
319
327
|
if (ancestors !== undefined) ancestors.delete(value);
|
|
320
328
|
return out;
|
|
321
329
|
}
|
|
322
|
-
function
|
|
323
|
-
|
|
330
|
+
function mark(value, visit, path, memo, m) {
|
|
331
|
+
const seen = m.at.get(value);
|
|
332
|
+
if (seen !== undefined) return seen;
|
|
333
|
+
if (memo.has(value)) return -1;
|
|
324
334
|
const r = visit(value, path);
|
|
325
335
|
if (r !== DESCEND) {
|
|
326
336
|
memo.set(value, r);
|
|
327
|
-
return
|
|
337
|
+
return -1;
|
|
328
338
|
}
|
|
329
339
|
const s = shape(value);
|
|
330
|
-
if (s === 0) return
|
|
331
|
-
const
|
|
340
|
+
if (s === 0) return -1;
|
|
341
|
+
const index = m.next++;
|
|
342
|
+
let low = index;
|
|
343
|
+
let changed = false;
|
|
344
|
+
let open = false;
|
|
345
|
+
const keys = s === 1 ? value : Object.keys(value);
|
|
346
|
+
for (let i = 0; i < keys.length; i++) {
|
|
347
|
+
const k = s === 1 ? i : keys[i];
|
|
348
|
+
const c = value[k];
|
|
349
|
+
if (c === null || typeof c !== "object") continue;
|
|
350
|
+
if (!open) {
|
|
351
|
+
open = true;
|
|
352
|
+
m.at.set(value, index);
|
|
353
|
+
m.stack.push(value);
|
|
354
|
+
}
|
|
355
|
+
const l = mark(c, visit, undefined , memo, m);
|
|
356
|
+
if (l >= 0 && l < low) low = l;
|
|
357
|
+
if (memo.has(c) && memo.get(c) !== c || l === Infinity && m.changed.has(c)) changed = true;
|
|
358
|
+
}
|
|
359
|
+
if (!open) return -1;
|
|
360
|
+
if (low === index) {
|
|
361
|
+
m.at.set(value, Infinity);
|
|
362
|
+
if (m.stack[m.stack.length - 1] === value) {
|
|
363
|
+
m.stack.pop();
|
|
364
|
+
if (changed) m.changed.add(value);
|
|
365
|
+
return Infinity;
|
|
366
|
+
}
|
|
367
|
+
const members = m.stack.splice(m.stack.lastIndexOf(value));
|
|
368
|
+
if (!changed) for (const n of members) if (m.changed.has(n)) {
|
|
369
|
+
changed = true;
|
|
370
|
+
break;
|
|
371
|
+
}
|
|
372
|
+
for (const n of members) {
|
|
373
|
+
m.at.set(n, Infinity);
|
|
374
|
+
if (changed) m.changed.add(n);
|
|
375
|
+
}
|
|
376
|
+
return Infinity;
|
|
377
|
+
}
|
|
378
|
+
if (changed) m.changed.add(value);
|
|
379
|
+
return low;
|
|
380
|
+
}
|
|
381
|
+
function clone(value, memo, changed) {
|
|
382
|
+
if (memo.has(value)) return memo.get(value);
|
|
383
|
+
if (!changed.has(value)) return value;
|
|
384
|
+
const out = Array.isArray(value) ? value.slice() : {
|
|
332
385
|
...value
|
|
333
386
|
};
|
|
334
387
|
memo.set(value, out);
|
|
335
|
-
if (
|
|
388
|
+
if (Array.isArray(value)) {
|
|
336
389
|
for (let i = 0; i < value.length; i++) {
|
|
337
390
|
const c = value[i];
|
|
338
|
-
if (c !== null && typeof c === "object") out[i] = clone(c,
|
|
391
|
+
if (c !== null && typeof c === "object") out[i] = clone(c, memo, changed);
|
|
339
392
|
}
|
|
340
393
|
} else {
|
|
341
394
|
for (const k of Object.keys(value)) {
|
|
342
395
|
const c = value[k];
|
|
343
|
-
if (c !== null && typeof c === "object") out[k] = clone(c,
|
|
396
|
+
if (c !== null && typeof c === "object") out[k] = clone(c, memo, changed);
|
|
344
397
|
}
|
|
345
398
|
}
|
|
346
399
|
return out;
|
|
@@ -480,7 +533,7 @@ function createKeyedSerializer(serialize, onError, onDone) {
|
|
|
480
533
|
stream = serialize(key, value, {
|
|
481
534
|
onError: onError && (err => {
|
|
482
535
|
failed = true;
|
|
483
|
-
onError(err);
|
|
536
|
+
onError(err, key);
|
|
484
537
|
if (cancel) {
|
|
485
538
|
cancel();
|
|
486
539
|
settle();
|
|
@@ -553,7 +606,7 @@ function createHydrationSerializer({
|
|
|
553
606
|
});
|
|
554
607
|
return createKeyedSerializer(late ? late(serialize, refs, onData, scopeId) : serialize, onError, onDone);
|
|
555
608
|
}
|
|
556
|
-
function rejectUnserializedKey(serialize, refs, onData, scopeId) {
|
|
609
|
+
function rejectUnserializedKey(serialize, refs, onData, scopeId, plain) {
|
|
557
610
|
let taken = 0;
|
|
558
611
|
let fresh = [];
|
|
559
612
|
const set = refs.set;
|
|
@@ -576,8 +629,9 @@ function rejectUnserializedKey(serialize, refs, onData, scopeId) {
|
|
|
576
629
|
if (ref instanceof Promise) ids.add(id + 1);else if (isStream(ref) || Object.getPrototypeOf(ref) === Object.prototype && !Object.keys(ref).length) ids.add(id);
|
|
577
630
|
}
|
|
578
631
|
if (!ids.size) return;
|
|
579
|
-
const
|
|
580
|
-
const
|
|
632
|
+
const text = plain && plain(key);
|
|
633
|
+
const body = "for(const i of[" + [...ids] + "]){const v=$R[i];v&&(v.f?" + (text === undefined ? "v.f(e)" : "(v.f(e),v.p.s||(v.p.s=2,v.p.v=e))") + ":v.throw&&v.throw(e))}";
|
|
634
|
+
const message = JSON.stringify(text === undefined ? "Serialization failed: the hydration value for key " + JSON.stringify(key) + " could not be serialized on the server" : text).replace(/[<\u2028\u2029]/g, c => KEY_ESCAPES[c]);
|
|
581
635
|
onData("($R=>{const e=new Error(" + message + ");" + body + "})(" + (scopeId == null ? "$R" : '$R["' + serializeKey(scopeId) + '"]') + ")");
|
|
582
636
|
};
|
|
583
637
|
return serialize(key, value, {
|
|
@@ -1080,6 +1134,7 @@ function isSetAttr(value) {
|
|
|
1080
1134
|
return value != null && value !== false && value !== "";
|
|
1081
1135
|
}
|
|
1082
1136
|
const PRELOAD_LINK_ATTRIBUTES = ["type", "crossorigin", "integrity", "referrerpolicy", "fetchpriority", "media", "imagesrcset", "imagesizes"];
|
|
1137
|
+
const SSR_NODE = /*#__PURE__*/Symbol.for("solid.ssrNode");
|
|
1083
1138
|
function registerPreloadLink(tracking, headRegistry, link, nonce) {
|
|
1084
1139
|
if (!link || typeof link !== "object") {
|
|
1085
1140
|
return null;
|
|
@@ -1610,7 +1665,8 @@ function tagInfo(tag) {
|
|
|
1610
1665
|
textarea: tag === "textarea",
|
|
1611
1666
|
raw: tag === "script" || tag === "style",
|
|
1612
1667
|
formDefaults,
|
|
1613
|
-
formAttributes
|
|
1668
|
+
formAttributes,
|
|
1669
|
+
sel: tag === "select" ? 1 : tag === "option" ? 2 : 0
|
|
1614
1670
|
};
|
|
1615
1671
|
if (tagInfos.size < 512) tagInfos.set(tag, info);
|
|
1616
1672
|
}
|
|
@@ -1712,7 +1768,7 @@ function renderToString(code, options = {}) {
|
|
|
1712
1768
|
closed = true;
|
|
1713
1769
|
serializer.close();
|
|
1714
1770
|
const head = renderShellHead(headRegistry, nonce, null, noScripts, traceMetaMarkup(context.trace));
|
|
1715
|
-
const document = withShellEnd(assembleDocument(
|
|
1771
|
+
const document = withShellEnd(assembleDocument(html, tracking.emittedAssets, tracking.preloadLinks, tracking.inlineStyles, scripts.length ? scripts : "", nonce, head, onHead, tracking.lowModules), context, renderId, nonce, noScripts);
|
|
1716
1772
|
if (render) render.shell();
|
|
1717
1773
|
if (requestEvent && requestEvent.response) {
|
|
1718
1774
|
commitResponseStub(requestEvent.response, {
|
|
@@ -1788,7 +1844,8 @@ function renderToStream(code, options = {}) {
|
|
|
1788
1844
|
if (render) settleRender(render, rootOwner, disconnect ? "abandoned" : "error");
|
|
1789
1845
|
const sink = writable;
|
|
1790
1846
|
buffer = {
|
|
1791
|
-
write() {}
|
|
1847
|
+
write() {},
|
|
1848
|
+
flush() {}
|
|
1792
1849
|
};
|
|
1793
1850
|
writable = {
|
|
1794
1851
|
end() {}
|
|
@@ -1872,24 +1929,64 @@ function renderToStream(code, options = {}) {
|
|
|
1872
1929
|
let stableOrder = false;
|
|
1873
1930
|
let parkedWrites = null;
|
|
1874
1931
|
const byKey = (a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0;
|
|
1875
|
-
let writing = 0;
|
|
1876
1932
|
let stranded = false;
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1933
|
+
let writingRecord = false;
|
|
1934
|
+
let recordFailed = false;
|
|
1935
|
+
const plainRecords = new WeakMap();
|
|
1936
|
+
const caught = new Set();
|
|
1937
|
+
let unclaimed = null;
|
|
1938
|
+
const rejected = new Map();
|
|
1939
|
+
const plainMessage = (id, value) => value != null && typeof value.message === "string" ? value.message : `The error record for key ${JSON.stringify(id)} could not be serialized on the server`;
|
|
1940
|
+
const plainFor = (id, value) => {
|
|
1941
|
+
const keyed = value !== null && typeof value === "object";
|
|
1942
|
+
let plain = keyed && plainRecords.get(value);
|
|
1943
|
+
if (!plain) {
|
|
1944
|
+
plain = new Error(plainMessage(id, value));
|
|
1945
|
+
if (keyed) plainRecords.set(value, plain);
|
|
1946
|
+
}
|
|
1947
|
+
return plain;
|
|
1948
|
+
};
|
|
1949
|
+
const claim = () => {
|
|
1950
|
+
if (unclaimed) {
|
|
1951
|
+
for (const reason of unclaimed) if (!caught.has(reason)) stranded = true;
|
|
1952
|
+
unclaimed = null;
|
|
1953
|
+
}
|
|
1954
|
+
return stranded;
|
|
1955
|
+
};
|
|
1956
|
+
const claimLater = reason => {
|
|
1957
|
+
if (firstFlushed || stranded || caught.has(reason)) return;
|
|
1958
|
+
if (!unclaimed) {
|
|
1959
|
+
unclaimed = new Set();
|
|
1960
|
+
deferFlush(() => {
|
|
1961
|
+
if (!rootHoles && claim()) abandon();
|
|
1962
|
+
});
|
|
1963
|
+
}
|
|
1964
|
+
unclaimed.add(reason);
|
|
1965
|
+
};
|
|
1966
|
+
const handOver = (id, value, error) => {
|
|
1967
|
+
if (!error || options.serializer) return serializer.write(id, value);
|
|
1968
|
+
let plain = value !== null && typeof value === "object" && plainRecords.get(value);
|
|
1969
|
+
if (!plain) {
|
|
1970
|
+
recordFailed = false;
|
|
1971
|
+
writingRecord = true;
|
|
1972
|
+
try {
|
|
1973
|
+
serializer.write(id, value);
|
|
1974
|
+
} finally {
|
|
1975
|
+
writingRecord = false;
|
|
1976
|
+
}
|
|
1977
|
+
if (!recordFailed) return;
|
|
1978
|
+
plain = plainFor(id, value);
|
|
1883
1979
|
}
|
|
1980
|
+
serializer.write(id, plain);
|
|
1884
1981
|
};
|
|
1885
|
-
const write = (id, value) => {
|
|
1886
|
-
if (stableOrder && !dead) (parkedWrites ||= []).push([id, value]);else handOver(id, value);
|
|
1982
|
+
const write = (id, value, error) => {
|
|
1983
|
+
if (stableOrder && !dead) (parkedWrites ||= []).push([id, value, error]);else handOver(id, value, error);
|
|
1887
1984
|
};
|
|
1888
1985
|
const flushParkedWrites = () => {
|
|
1889
1986
|
if (!parkedWrites) return;
|
|
1890
1987
|
const writes = parkedWrites.sort(byKey);
|
|
1891
1988
|
parkedWrites = null;
|
|
1892
|
-
for (let i = 0; i < writes.length; i++) handOver(writes[i][0], writes[i][1]);
|
|
1989
|
+
for (let i = 0; i < writes.length; i++) handOver(writes[i][0], writes[i][1], writes[i][2]);
|
|
1893
1990
|
};
|
|
1894
1991
|
const flushStubBatch = () => {
|
|
1895
1992
|
if (!stubBatch) return;
|
|
@@ -1914,7 +2011,7 @@ function renderToStream(code, options = {}) {
|
|
|
1914
2011
|
const onDone = () => {
|
|
1915
2012
|
if (dead) return;
|
|
1916
2013
|
writeTasks();
|
|
1917
|
-
if (
|
|
2014
|
+
if (claim()) return abandon();
|
|
1918
2015
|
lastBlockingSize = blockingPromises.size;
|
|
1919
2016
|
doShell();
|
|
1920
2017
|
onCompleteAll && onCompleteAll({
|
|
@@ -1977,11 +2074,19 @@ function renderToStream(code, options = {}) {
|
|
|
1977
2074
|
plugins: options.plugins,
|
|
1978
2075
|
onData: payload => sink.data(payload),
|
|
1979
2076
|
onDone,
|
|
1980
|
-
onError: err => {
|
|
1981
|
-
|
|
1982
|
-
|
|
2077
|
+
onError: (err, key) => {
|
|
2078
|
+
const rejection = !options.serializer && !writingRecord && rejected.has(key);
|
|
2079
|
+
const reason = rejection && rejected.get(key);
|
|
2080
|
+
if (!rejection || reason === null || typeof reason !== "object" || !plainRecords.has(reason)) reportFailure(err, "serialize");
|
|
2081
|
+
if (writingRecord) recordFailed = true;else if (rejection) {
|
|
2082
|
+
plainFor(key, reason);
|
|
2083
|
+
claimLater(reason);
|
|
2084
|
+
} else if (!options.serializer && !firstFlushed && !stranded) {
|
|
2085
|
+
stranded = true;
|
|
2086
|
+
deferFlush(() => abandon());
|
|
2087
|
+
}
|
|
1983
2088
|
},
|
|
1984
|
-
late: rejectUnserializedKey
|
|
2089
|
+
late: (serialize, refs, onData, scopeId) => rejectUnserializedKey(serialize, refs, onData, scopeId, key => !firstFlushed && rejected.has(key) ? plainMessage(key, rejected.get(key)) : undefined)
|
|
1985
2090
|
});
|
|
1986
2091
|
let rootAssetsSerialized = false;
|
|
1987
2092
|
const serializeRootAssets = () => {
|
|
@@ -2060,7 +2165,10 @@ function renderToStream(code, options = {}) {
|
|
|
2060
2165
|
raced.catch(() => {});
|
|
2061
2166
|
pendingSerialized.set(id, settle);
|
|
2062
2167
|
const drop = () => pendingSerialized.delete(id);
|
|
2063
|
-
p.then(drop,
|
|
2168
|
+
p.then(drop, reason => {
|
|
2169
|
+
drop();
|
|
2170
|
+
rejected.set(id, reason);
|
|
2171
|
+
});
|
|
2064
2172
|
return raced;
|
|
2065
2173
|
};
|
|
2066
2174
|
const abandonSubtree = (key, error) => {
|
|
@@ -2207,12 +2315,17 @@ function renderToStream(code, options = {}) {
|
|
|
2207
2315
|
const last = html.indexOf(`<!--!$/${id}-->`, first + placeholder.length);
|
|
2208
2316
|
html = html.slice(0, first) + resolveSSRSync(escape(payloadFn())) + html.slice(last + placeholder.length + 1);
|
|
2209
2317
|
},
|
|
2210
|
-
serialize(id, p, deferStream) {
|
|
2318
|
+
serialize(id, p, deferStream, errorRecord) {
|
|
2211
2319
|
p = guardChannel(p);
|
|
2212
2320
|
if (p && typeof p === "object" && typeof p.then === "function") {
|
|
2213
2321
|
if (!firstFlushed && deferStream) {
|
|
2214
2322
|
blockingPromises.add(p);
|
|
2215
|
-
p.then(d => write(id, d)).catch(e =>
|
|
2323
|
+
p.then(d => write(id, d)).catch(e => {
|
|
2324
|
+
rejected.set(id, e);
|
|
2325
|
+
const r = Promise.reject(e);
|
|
2326
|
+
r.catch(() => {});
|
|
2327
|
+
write(id, r);
|
|
2328
|
+
});
|
|
2216
2329
|
return;
|
|
2217
2330
|
}
|
|
2218
2331
|
p = trackSerialized(id, p);
|
|
@@ -2221,7 +2334,7 @@ function renderToStream(code, options = {}) {
|
|
|
2221
2334
|
return;
|
|
2222
2335
|
}
|
|
2223
2336
|
}
|
|
2224
|
-
write(id, p);
|
|
2337
|
+
write(id, p, errorRecord);
|
|
2225
2338
|
},
|
|
2226
2339
|
escape: escape,
|
|
2227
2340
|
resolve: resolveSSRNode,
|
|
@@ -2295,7 +2408,7 @@ function renderToStream(code, options = {}) {
|
|
|
2295
2408
|
const styles = collectStreamStyles(key, tracking, headStyles);
|
|
2296
2409
|
const headOps = error ? null : flushHeadFragment(headRegistry, key, nonce);
|
|
2297
2410
|
if (headOps) emitHeadOps(key, headOps);
|
|
2298
|
-
sink.fragment(key,
|
|
2411
|
+
sink.fragment(key, value !== undefined ? value : error ? "" : " ", {
|
|
2299
2412
|
styles,
|
|
2300
2413
|
revealGroup,
|
|
2301
2414
|
error: error ? ssrSanitizeError(error, null, undefined, undefined, errorScope) : error
|
|
@@ -2326,6 +2439,10 @@ function renderToStream(code, options = {}) {
|
|
|
2326
2439
|
context.failRender = failRender;
|
|
2327
2440
|
context.errorPolicy = options.onError;
|
|
2328
2441
|
context._errorScope = errorScope;
|
|
2442
|
+
context.contained = (error, wire) => {
|
|
2443
|
+
caught.add(error);
|
|
2444
|
+
caught.add(wire);
|
|
2445
|
+
};
|
|
2329
2446
|
context.flushed = () => firstFlushed;
|
|
2330
2447
|
context.trace = requestEvent ? traceForEvent(requestEvent) : traceFor(context, undefined);
|
|
2331
2448
|
render = timeDocument(context, context.trace);
|
|
@@ -2443,7 +2560,7 @@ function renderToStream(code, options = {}) {
|
|
|
2443
2560
|
flushStubBatch();
|
|
2444
2561
|
const head = renderShellHead(headRegistry, nonce, k => registry.has(k), noScripts, traceMetaMarkup(context.trace));
|
|
2445
2562
|
if (render) render.shell();
|
|
2446
|
-
sink.shell(
|
|
2563
|
+
sink.shell(html, {
|
|
2447
2564
|
preloads: tracking.emittedAssets,
|
|
2448
2565
|
preloadLinks: tracking.preloadLinks,
|
|
2449
2566
|
inlineStyles: tracking.inlineStyles,
|
|
@@ -2519,7 +2636,7 @@ function renderToStream(code, options = {}) {
|
|
|
2519
2636
|
return;
|
|
2520
2637
|
}
|
|
2521
2638
|
if (!shellCompleted) return flush();
|
|
2522
|
-
if (
|
|
2639
|
+
if (claim()) return abandon();
|
|
2523
2640
|
const encoder = new TextEncoder();
|
|
2524
2641
|
const writer = w.getWriter();
|
|
2525
2642
|
let pendingWrites = Promise.resolve();
|
|
@@ -2619,7 +2736,7 @@ function renderToStream(code, options = {}) {
|
|
|
2619
2736
|
return;
|
|
2620
2737
|
}
|
|
2621
2738
|
if (!shellCompleted) return flush();
|
|
2622
|
-
if (
|
|
2739
|
+
if (claim()) return abandon();
|
|
2623
2740
|
const sink = guardSink(w);
|
|
2624
2741
|
buffer = writable = coalesceWrites(sink.write, sink.end);
|
|
2625
2742
|
buffer.write(tmp);
|
|
@@ -2685,6 +2802,8 @@ function buildAsyncWrap(err, node) {
|
|
|
2685
2802
|
fn.$rw = true;
|
|
2686
2803
|
if (suppress) fn.$lhSuppress = true;
|
|
2687
2804
|
if (node.$lhSkip) fn.$lhSkip = true;
|
|
2805
|
+
if (node.$lhInTag) fn.$lhInTag = true;
|
|
2806
|
+
if (node.$lhAttr) fn.$lhAttr = node.$lhAttr;
|
|
2688
2807
|
if (node.$lhBinding) fn.$lhBinding = node.$lhBinding;
|
|
2689
2808
|
return {
|
|
2690
2809
|
fn,
|
|
@@ -2886,7 +3005,8 @@ function createLiveHoles(sink, scoped, settled, errorScope) {
|
|
|
2886
3005
|
t: [""],
|
|
2887
3006
|
h: [],
|
|
2888
3007
|
p: [],
|
|
2889
|
-
rows: null
|
|
3008
|
+
rows: null,
|
|
3009
|
+
$: SSR_NODE
|
|
2890
3010
|
};
|
|
2891
3011
|
try {
|
|
2892
3012
|
result.rows = resolveValue(holeValue(hole), result);
|
|
@@ -2985,16 +3105,41 @@ function createLiveHoles(sink, scoped, settled, errorScope) {
|
|
|
2985
3105
|
},
|
|
2986
3106
|
nest(hole) {
|
|
2987
3107
|
const s = engine.scope;
|
|
2988
|
-
if (!s || s.h === hole || hole.$lhSkip || inScope && !inScope()) return undefined;
|
|
3108
|
+
if (!s || s.h === hole || hole.$lhSkip || hole.$lhInTag || inScope && !inScope()) return undefined;
|
|
2989
3109
|
engine.scope = scopeFor(hole);
|
|
2990
3110
|
return s;
|
|
2991
3111
|
},
|
|
2992
3112
|
content(hole) {
|
|
3113
|
+
if (hole.$lhInTag) {
|
|
3114
|
+
const cap = hole.$lhAttr;
|
|
3115
|
+
if (!cap || cap.adopted || engine.suppressed || engine.sweeping) return null;
|
|
3116
|
+
const r = tryResolveFunctionHole(hole);
|
|
3117
|
+
if (typeof r !== "string") {
|
|
3118
|
+
const res = {
|
|
3119
|
+
t: [""],
|
|
3120
|
+
h: [],
|
|
3121
|
+
p: [],
|
|
3122
|
+
$: SSR_NODE
|
|
3123
|
+
};
|
|
3124
|
+
appendResolvedNode(res, r);
|
|
3125
|
+
return res;
|
|
3126
|
+
}
|
|
3127
|
+
if (--cap.waiting === 0 && !cap.closed) {
|
|
3128
|
+
try {
|
|
3129
|
+
cap.base = attrPartsText(cap.parts);
|
|
3130
|
+
} catch (err) {
|
|
3131
|
+
cap.base = null;
|
|
3132
|
+
}
|
|
3133
|
+
if (cap.base !== null) engine.attr(cap);
|
|
3134
|
+
}
|
|
3135
|
+
return r;
|
|
3136
|
+
}
|
|
2993
3137
|
if (hole.$lhSuppress) {
|
|
2994
3138
|
const r = {
|
|
2995
3139
|
t: [""],
|
|
2996
3140
|
h: [],
|
|
2997
|
-
p: []
|
|
3141
|
+
p: [],
|
|
3142
|
+
$: SSR_NODE
|
|
2998
3143
|
};
|
|
2999
3144
|
let rows = null;
|
|
3000
3145
|
const b = hole.$lhBinding;
|
|
@@ -3098,7 +3243,8 @@ function createLiveHoles(sink, scoped, settled, errorScope) {
|
|
|
3098
3243
|
const r = {
|
|
3099
3244
|
t: [""],
|
|
3100
3245
|
h: [],
|
|
3101
|
-
p: []
|
|
3246
|
+
p: [],
|
|
3247
|
+
$: SSR_NODE
|
|
3102
3248
|
};
|
|
3103
3249
|
engine.suppressed++;
|
|
3104
3250
|
try {
|
|
@@ -3117,13 +3263,15 @@ function createLiveHoles(sink, scoped, settled, errorScope) {
|
|
|
3117
3263
|
res = {
|
|
3118
3264
|
t: ["", ""],
|
|
3119
3265
|
h: [escalated.fn],
|
|
3120
|
-
p: [escalated.p]
|
|
3266
|
+
p: [escalated.p],
|
|
3267
|
+
$: SSR_NODE
|
|
3121
3268
|
};
|
|
3122
3269
|
} else {
|
|
3123
3270
|
res = {
|
|
3124
3271
|
t: [""],
|
|
3125
3272
|
h: [],
|
|
3126
|
-
p: []
|
|
3273
|
+
p: [],
|
|
3274
|
+
$: SSR_NODE
|
|
3127
3275
|
};
|
|
3128
3276
|
try {
|
|
3129
3277
|
rows = resolveValue(value, res);
|
|
@@ -3153,20 +3301,59 @@ function createLiveHoles(sink, scoped, settled, errorScope) {
|
|
|
3153
3301
|
t[t.length - 1] += close;
|
|
3154
3302
|
sink.openBinding(key, b);
|
|
3155
3303
|
return {
|
|
3156
|
-
t,
|
|
3304
|
+
t: t,
|
|
3157
3305
|
h: res.h,
|
|
3158
|
-
p: res.p
|
|
3306
|
+
p: res.p,
|
|
3307
|
+
$: SSR_NODE
|
|
3159
3308
|
};
|
|
3160
3309
|
},
|
|
3161
3310
|
mint() {
|
|
3162
3311
|
return nextId++;
|
|
3163
3312
|
},
|
|
3313
|
+
open(text, off, hole) {
|
|
3314
|
+
const pending = hole && hole.$lhAttr;
|
|
3315
|
+
let inject;
|
|
3316
|
+
let id;
|
|
3317
|
+
if (pending && !pending.adopted && text.startsWith(pending.inject, off)) {
|
|
3318
|
+
pending.adopted = true;
|
|
3319
|
+
({
|
|
3320
|
+
id,
|
|
3321
|
+
inject
|
|
3322
|
+
} = pending);
|
|
3323
|
+
} else {
|
|
3324
|
+
id = nextId++;
|
|
3325
|
+
inject = ` data-lha="${id}"`;
|
|
3326
|
+
text = text.slice(0, off) + inject + text.slice(off);
|
|
3327
|
+
}
|
|
3328
|
+
const prefix = text.slice(off + inject.length);
|
|
3329
|
+
return {
|
|
3330
|
+
id,
|
|
3331
|
+
parts: [prefix],
|
|
3332
|
+
base: prefix,
|
|
3333
|
+
inject,
|
|
3334
|
+
waiting: 0,
|
|
3335
|
+
text
|
|
3336
|
+
};
|
|
3337
|
+
},
|
|
3338
|
+
retry(fn, cap) {
|
|
3339
|
+
if (typeof fn !== "function") return;
|
|
3340
|
+
fn.$lhInTag = true;
|
|
3341
|
+
if (cap) {
|
|
3342
|
+
fn.$lhAttr = cap;
|
|
3343
|
+
cap.waiting++;
|
|
3344
|
+
}
|
|
3345
|
+
},
|
|
3164
3346
|
active() {
|
|
3165
3347
|
return (!inScope || inScope()) && !(settled && settled());
|
|
3166
3348
|
},
|
|
3167
3349
|
attr(cap) {
|
|
3168
|
-
|
|
3169
|
-
|
|
3350
|
+
if (cap.waiting) {
|
|
3351
|
+
cap.owner = getOwner();
|
|
3352
|
+
cap.ctx = sharedConfig.context;
|
|
3353
|
+
return;
|
|
3354
|
+
}
|
|
3355
|
+
const owner = cap.owner !== undefined ? cap.owner : getOwner();
|
|
3356
|
+
const holeCtx = cap.ctx !== undefined ? cap.ctx : sharedConfig.context;
|
|
3170
3357
|
const b = {
|
|
3171
3358
|
key: "lha:" + cap.id,
|
|
3172
3359
|
children: [],
|
|
@@ -3181,29 +3368,7 @@ function createLiveHoles(sink, scoped, settled, errorScope) {
|
|
|
3181
3368
|
engine.gateHit = false;
|
|
3182
3369
|
let html = "";
|
|
3183
3370
|
try {
|
|
3184
|
-
|
|
3185
|
-
let groupVal = null;
|
|
3186
|
-
const run = () => {
|
|
3187
|
-
for (const part of cap.parts) {
|
|
3188
|
-
if (typeof part === "string") {
|
|
3189
|
-
html += part;
|
|
3190
|
-
continue;
|
|
3191
|
-
}
|
|
3192
|
-
let v;
|
|
3193
|
-
if (part.g) {
|
|
3194
|
-
if (group !== part.g) {
|
|
3195
|
-
group = part.g;
|
|
3196
|
-
groupVal = part.g();
|
|
3197
|
-
}
|
|
3198
|
-
v = groupVal[part.i];
|
|
3199
|
-
} else {
|
|
3200
|
-
v = part.f();
|
|
3201
|
-
}
|
|
3202
|
-
const vt = typeof v;
|
|
3203
|
-
if (vt === "string" || vt === "number") html += v;
|
|
3204
|
-
}
|
|
3205
|
-
};
|
|
3206
|
-
swept(owner, holeCtx, run);
|
|
3371
|
+
swept(owner, holeCtx, () => html = attrPartsText(cap.parts));
|
|
3207
3372
|
} catch (err) {
|
|
3208
3373
|
if (ssrHandleError(err, true)) {
|
|
3209
3374
|
if (!engine.sweptOwners) return;
|
|
@@ -3310,10 +3475,35 @@ function rowPatch(a, b) {
|
|
|
3310
3475
|
}
|
|
3311
3476
|
}
|
|
3312
3477
|
}
|
|
3478
|
+
function attrPartsText(parts) {
|
|
3479
|
+
let html = "";
|
|
3480
|
+
let group = null;
|
|
3481
|
+
let groupVal = null;
|
|
3482
|
+
for (const part of parts) {
|
|
3483
|
+
if (typeof part === "string") {
|
|
3484
|
+
html += part;
|
|
3485
|
+
continue;
|
|
3486
|
+
}
|
|
3487
|
+
let v;
|
|
3488
|
+
if (part.g) {
|
|
3489
|
+
if (group !== part.g) {
|
|
3490
|
+
group = part.g;
|
|
3491
|
+
groupVal = part.g();
|
|
3492
|
+
}
|
|
3493
|
+
v = groupVal[part.i];
|
|
3494
|
+
} else {
|
|
3495
|
+
v = part.f();
|
|
3496
|
+
}
|
|
3497
|
+
const vt = typeof v;
|
|
3498
|
+
if (vt === "string" || vt === "number") html += v;
|
|
3499
|
+
}
|
|
3500
|
+
return html;
|
|
3501
|
+
}
|
|
3313
3502
|
function ssr(t) {
|
|
3314
3503
|
const len = arguments.length;
|
|
3315
3504
|
if (len === 1) return {
|
|
3316
|
-
t
|
|
3505
|
+
t: t,
|
|
3506
|
+
$: SSR_NODE
|
|
3317
3507
|
};
|
|
3318
3508
|
let s = t[0];
|
|
3319
3509
|
let result = null;
|
|
@@ -3329,30 +3519,18 @@ function ssr(t) {
|
|
|
3329
3519
|
seg: -1,
|
|
3330
3520
|
off: hp.openOff[0]
|
|
3331
3521
|
};
|
|
3332
|
-
const captureStart =
|
|
3522
|
+
const captureStart = hole => {
|
|
3333
3523
|
if (cap) return true;
|
|
3334
3524
|
if (!lastOpen || live.suppressed || live.sweeping || !live.active()) return false;
|
|
3525
|
+
if (lastOpen.r === null && result !== null && result.t.length === 1) {
|
|
3526
|
+
lastOpen.r = result;
|
|
3527
|
+
lastOpen.seg = 0;
|
|
3528
|
+
}
|
|
3335
3529
|
if (lastOpen.r !== result || result !== null && lastOpen.seg !== result.t.length - 1) {
|
|
3336
3530
|
return false;
|
|
3337
3531
|
}
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
let prefix;
|
|
3341
|
-
if (result === null) {
|
|
3342
|
-
s = s.slice(0, lastOpen.off) + inject + s.slice(lastOpen.off);
|
|
3343
|
-
prefix = s.slice(lastOpen.off + inject.length);
|
|
3344
|
-
} else {
|
|
3345
|
-
const seg = result.t[lastOpen.seg];
|
|
3346
|
-
result.t[lastOpen.seg] = seg.slice(0, lastOpen.off) + inject + seg.slice(lastOpen.off);
|
|
3347
|
-
prefix = result.t[lastOpen.seg].slice(lastOpen.off + inject.length);
|
|
3348
|
-
}
|
|
3349
|
-
cap = {
|
|
3350
|
-
id,
|
|
3351
|
-
parts: [prefix],
|
|
3352
|
-
base: prefix,
|
|
3353
|
-
at: lastOpen.seg,
|
|
3354
|
-
inject
|
|
3355
|
-
};
|
|
3532
|
+
cap = live.open(result === null ? s : result.t[lastOpen.seg], lastOpen.off, hole);
|
|
3533
|
+
if (result === null) s = cap.text;else result.t[lastOpen.seg] = cap.text;
|
|
3356
3534
|
return true;
|
|
3357
3535
|
};
|
|
3358
3536
|
for (let i = 1; i < len; i++) {
|
|
@@ -3383,7 +3561,8 @@ function ssr(t) {
|
|
|
3383
3561
|
result = {
|
|
3384
3562
|
t: [s],
|
|
3385
3563
|
h: [],
|
|
3386
|
-
p: []
|
|
3564
|
+
p: [],
|
|
3565
|
+
$: SSR_NODE
|
|
3387
3566
|
};
|
|
3388
3567
|
s = "";
|
|
3389
3568
|
}
|
|
@@ -3393,18 +3572,23 @@ function ssr(t) {
|
|
|
3393
3572
|
if (Array.isArray(lastGroupVal)) {
|
|
3394
3573
|
value = lastGroupVal[lastGroupIdx++];
|
|
3395
3574
|
hasValue = true;
|
|
3396
|
-
if (live && !hp.pos[i - 1] && captureStart()) {
|
|
3575
|
+
if (live && !hp.pos[i - 1] && captureStart(hole)) {
|
|
3397
3576
|
cap.parts.push({
|
|
3398
3577
|
g: hole,
|
|
3399
3578
|
i: lastGroupIdx - 1
|
|
3400
3579
|
});
|
|
3401
3580
|
}
|
|
3402
3581
|
} else {
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3582
|
+
const slot = ssrGroupSlot(lastGroupVal.fn, lastGroupIdx++);
|
|
3583
|
+
if (live && !hp.pos[i - 1]) {
|
|
3584
|
+
const capturing = captureStart(hole);
|
|
3585
|
+
if (capturing) cap.parts.push({
|
|
3586
|
+
g: hole,
|
|
3587
|
+
i: lastGroupIdx - 1
|
|
3588
|
+
});
|
|
3589
|
+
live.retry(slot, capturing && cap);
|
|
3406
3590
|
}
|
|
3407
|
-
result.h.push(
|
|
3591
|
+
result.h.push(slot);
|
|
3408
3592
|
result.p.push(lastGroupVal.p);
|
|
3409
3593
|
result.t.push("");
|
|
3410
3594
|
}
|
|
@@ -3424,7 +3608,8 @@ function ssr(t) {
|
|
|
3424
3608
|
result = {
|
|
3425
3609
|
t: [s],
|
|
3426
3610
|
h: [],
|
|
3427
|
-
p: []
|
|
3611
|
+
p: [],
|
|
3612
|
+
$: SSR_NODE
|
|
3428
3613
|
};
|
|
3429
3614
|
s = "";
|
|
3430
3615
|
if (rs.merge !== undefined) mergeTemplateInto(result, rs.merge);else resolveSSRNode(rs.bail, result);
|
|
@@ -3441,7 +3626,8 @@ function ssr(t) {
|
|
|
3441
3626
|
result = {
|
|
3442
3627
|
t: [s],
|
|
3443
3628
|
h: [],
|
|
3444
|
-
p: []
|
|
3629
|
+
p: [],
|
|
3630
|
+
$: SSR_NODE
|
|
3445
3631
|
};
|
|
3446
3632
|
s = "";
|
|
3447
3633
|
}
|
|
@@ -3449,28 +3635,27 @@ function ssr(t) {
|
|
|
3449
3635
|
}
|
|
3450
3636
|
} else if (result !== null) {
|
|
3451
3637
|
const inTag = live && !hp.pos[i - 1];
|
|
3452
|
-
const capturing = inTag && captureStart();
|
|
3638
|
+
const capturing = inTag && captureStart(hole);
|
|
3453
3639
|
const li = capturing ? result.t.length - 1 : 0;
|
|
3454
3640
|
const before = capturing ? result.t[li].length : 0;
|
|
3641
|
+
const pushed = result.h.length;
|
|
3455
3642
|
if (live) live.suppressed++;
|
|
3456
3643
|
try {
|
|
3457
3644
|
resolveSSRNode(hole, result);
|
|
3458
3645
|
} finally {
|
|
3459
3646
|
if (live) live.suppressed--;
|
|
3460
3647
|
}
|
|
3648
|
+
if (inTag) {
|
|
3649
|
+
for (let k = pushed; k < result.h.length; k++) live.retry(result.h[k], capturing && cap);
|
|
3650
|
+
}
|
|
3461
3651
|
if (capturing) {
|
|
3462
|
-
if (result.t.length - 1 === li)
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
});
|
|
3467
|
-
} else {
|
|
3468
|
-
result.t[cap.at] = result.t[cap.at].replace(cap.inject, "");
|
|
3469
|
-
cap = null;
|
|
3470
|
-
}
|
|
3652
|
+
if (result.t.length - 1 === li) cap.base += result.t[li].slice(before);
|
|
3653
|
+
cap.parts.push({
|
|
3654
|
+
f: hole
|
|
3655
|
+
});
|
|
3471
3656
|
}
|
|
3472
3657
|
} else {
|
|
3473
|
-
const capturing = live && !hp.pos[i - 1] && captureStart();
|
|
3658
|
+
const capturing = live && !hp.pos[i - 1] && captureStart(hole);
|
|
3474
3659
|
const scope = live && hp.pos[i - 1] && live.nest(hole);
|
|
3475
3660
|
const r = tryResolveFunctionHole(hole);
|
|
3476
3661
|
if (scope) live.scope = scope;
|
|
@@ -3483,17 +3668,18 @@ function ssr(t) {
|
|
|
3483
3668
|
});
|
|
3484
3669
|
}
|
|
3485
3670
|
} else {
|
|
3486
|
-
if (capturing) {
|
|
3487
|
-
s = s.replace(cap.inject, "");
|
|
3488
|
-
cap = null;
|
|
3489
|
-
}
|
|
3490
3671
|
result = {
|
|
3491
3672
|
t: [s],
|
|
3492
3673
|
h: [],
|
|
3493
|
-
p: []
|
|
3674
|
+
p: [],
|
|
3675
|
+
$: SSR_NODE
|
|
3494
3676
|
};
|
|
3495
3677
|
s = "";
|
|
3496
3678
|
appendResolvedNode(result, r);
|
|
3679
|
+
if (capturing) cap.parts.push({
|
|
3680
|
+
f: hole
|
|
3681
|
+
});
|
|
3682
|
+
if (live && !hp.pos[i - 1]) for (const h of result.h) live.retry(h, capturing && cap);
|
|
3497
3683
|
}
|
|
3498
3684
|
}
|
|
3499
3685
|
} else if (result !== null) {
|
|
@@ -3506,7 +3692,8 @@ function ssr(t) {
|
|
|
3506
3692
|
result = {
|
|
3507
3693
|
t: [s],
|
|
3508
3694
|
h: [],
|
|
3509
|
-
p: []
|
|
3695
|
+
p: [],
|
|
3696
|
+
$: SSR_NODE
|
|
3510
3697
|
};
|
|
3511
3698
|
s = "";
|
|
3512
3699
|
appendResolvedNode(result, r);
|
|
@@ -3542,7 +3729,8 @@ function ssr(t) {
|
|
|
3542
3729
|
if (result === null) s += next;else result.t[result.t.length - 1] += next;
|
|
3543
3730
|
}
|
|
3544
3731
|
if (result === null) return {
|
|
3545
|
-
t: s
|
|
3732
|
+
t: s,
|
|
3733
|
+
$: SSR_NODE
|
|
3546
3734
|
};
|
|
3547
3735
|
return result;
|
|
3548
3736
|
}
|
|
@@ -3622,6 +3810,7 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
|
3622
3810
|
}
|
|
3623
3811
|
const info = tagInfo(tag);
|
|
3624
3812
|
const skipChildren = info.isVoid;
|
|
3813
|
+
let sel, optValue, optOwn;
|
|
3625
3814
|
let result = info.open + hk;
|
|
3626
3815
|
let childOwner = null;
|
|
3627
3816
|
const last = sources === null ? 0 : sources.length - 1;
|
|
@@ -3640,6 +3829,11 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
|
3640
3829
|
for (let j = s + 1; j <= last; j++) {
|
|
3641
3830
|
if (keysOf[j].includes(prop)) continue nextKey;
|
|
3642
3831
|
}
|
|
3832
|
+
if (info.sel === 1 && prop === "value") {
|
|
3833
|
+
const value = props[prop];
|
|
3834
|
+
sel = ssrSelect(value);
|
|
3835
|
+
continue;
|
|
3836
|
+
}
|
|
3643
3837
|
if (info.textarea && (prop === "value" || prop === "defaultValue")) {
|
|
3644
3838
|
const value = props[prop];
|
|
3645
3839
|
if (value !== null) children = escape(value);
|
|
@@ -3659,6 +3853,9 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
|
3659
3853
|
const value = props[key];
|
|
3660
3854
|
if (value == undefined || prop.startsWith("prop:") || prop === "ref" || isEventName(prop)) continue;
|
|
3661
3855
|
if (link !== null && LinkAttributes.has(prop)) link[prop] = value;
|
|
3856
|
+
if (info.sel === 2) {
|
|
3857
|
+
if (prop === "value") optValue = value;else if (prop === "selected" && value) optOwn = true;
|
|
3858
|
+
}
|
|
3662
3859
|
if (prop === "style") {
|
|
3663
3860
|
result += ` style="${ssrStyle(value)}"`;
|
|
3664
3861
|
} else if (prop === "class") {
|
|
@@ -3673,10 +3870,11 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
|
3673
3870
|
if (attrs !== undefined) result += typeof attrs === "function" ? attrs() : attrs;
|
|
3674
3871
|
if (link !== null && link.href !== undefined) result += ssrLinkClaim(link);
|
|
3675
3872
|
if (skipChildren) return {
|
|
3676
|
-
t: result + " />"
|
|
3873
|
+
t: result + " />",
|
|
3874
|
+
$: SSR_NODE
|
|
3677
3875
|
};
|
|
3678
|
-
if (
|
|
3679
|
-
if (typeof children
|
|
3876
|
+
if (sel !== undefined) children = ssrIn(sel, () => spreadChildren(info, childOwner, children));else children = spreadChildren(info, childOwner, children);
|
|
3877
|
+
if (info.sel === 2) result += ssrOption(optValue !== undefined || typeof children !== "string" ? optValue : children.replace(/</g, "<").replace(/&/g, "&").replace(/\s+/g, " ").trim(), undefined, optOwn);
|
|
3680
3878
|
let thunk = null;
|
|
3681
3879
|
if (typeof children === "function" && (ctx === undefined || !ctx.liveHoles)) {
|
|
3682
3880
|
thunk = children;
|
|
@@ -3687,7 +3885,8 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
|
3687
3885
|
const res = {
|
|
3688
3886
|
t: [""],
|
|
3689
3887
|
h: [],
|
|
3690
|
-
p: []
|
|
3888
|
+
p: [],
|
|
3889
|
+
$: SSR_NODE
|
|
3691
3890
|
};
|
|
3692
3891
|
pushSSRAsyncHole(res, err, thunk);
|
|
3693
3892
|
return ssr([result + ">", info.close], res);
|
|
@@ -3695,19 +3894,23 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
|
3695
3894
|
}
|
|
3696
3895
|
const ct = typeof children;
|
|
3697
3896
|
if (ct === "string" || ct === "number") return {
|
|
3698
|
-
t: result + ">" + children + info.close
|
|
3897
|
+
t: result + ">" + children + info.close,
|
|
3898
|
+
$: SSR_NODE
|
|
3699
3899
|
};
|
|
3700
3900
|
if (children == null || ct === "boolean") return {
|
|
3701
|
-
t: result + ">" + info.close
|
|
3901
|
+
t: result + ">" + info.close,
|
|
3902
|
+
$: SSR_NODE
|
|
3702
3903
|
};
|
|
3703
|
-
if (ct === "object" && !children.h && typeof children.t === "string") return {
|
|
3704
|
-
t: result + ">" + children.t + info.close
|
|
3904
|
+
if (ct === "object" && children.$ === SSR_NODE && !children.h && typeof children.t === "string") return {
|
|
3905
|
+
t: result + ">" + children.t + info.close,
|
|
3906
|
+
$: SSR_NODE
|
|
3705
3907
|
};
|
|
3706
3908
|
if (thunk === null) return ssr([result + ">", info.close], resolveSSRNode(children, undefined, true));
|
|
3707
3909
|
const res = {
|
|
3708
3910
|
t: [""],
|
|
3709
3911
|
h: [],
|
|
3710
|
-
p: []
|
|
3912
|
+
p: [],
|
|
3913
|
+
$: SSR_NODE
|
|
3711
3914
|
};
|
|
3712
3915
|
try {
|
|
3713
3916
|
resolveSSRNode(children, res, false, true);
|
|
@@ -3716,6 +3919,10 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
|
3716
3919
|
}
|
|
3717
3920
|
return ssr([result + ">", info.close], res);
|
|
3718
3921
|
}
|
|
3922
|
+
function spreadChildren(info, childOwner, children) {
|
|
3923
|
+
if (childOwner !== null) children = info.raw ? childOwner.children : escape(childOwner.children);
|
|
3924
|
+
return typeof children === "function" ? children() : children;
|
|
3925
|
+
}
|
|
3719
3926
|
function collectSpreadSources(props, viewKeys, owners) {
|
|
3720
3927
|
for (let i = 0; i < props.length; i++) {
|
|
3721
3928
|
let s = props[i];
|
|
@@ -3758,110 +3965,37 @@ function ssrLinkClaim(attrs) {
|
|
|
3758
3965
|
if (ctx === undefined || ctx.linkClaim === undefined || attrs["aria-current"] != null) return "";
|
|
3759
3966
|
return ctx.linkClaim(attrs);
|
|
3760
3967
|
}
|
|
3761
|
-
|
|
3762
|
-
|
|
3968
|
+
const SELECT = Symbol();
|
|
3969
|
+
function ssrSelect(value) {
|
|
3970
|
+
const owner = createOwner({
|
|
3971
|
+
transparent: true
|
|
3972
|
+
});
|
|
3973
|
+
const state = {
|
|
3974
|
+
v: value,
|
|
3975
|
+
d: false,
|
|
3976
|
+
o: owner
|
|
3977
|
+
};
|
|
3978
|
+
owner._context = {
|
|
3979
|
+
...owner._context,
|
|
3980
|
+
[SELECT]: state
|
|
3981
|
+
};
|
|
3982
|
+
return state;
|
|
3763
3983
|
}
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
for (let j = i + 1; j < html.length; j++) {
|
|
3767
|
-
const c = html.charCodeAt(j);
|
|
3768
|
-
if (c === 34) {
|
|
3769
|
-
j = html.indexOf('"', j + 1);
|
|
3770
|
-
if (j < 0) return -1;
|
|
3771
|
-
} else if (c === 62) return j;
|
|
3772
|
-
}
|
|
3773
|
-
return -1;
|
|
3984
|
+
function ssrIn(state, fn) {
|
|
3985
|
+
return runWithOwner(state.o, fn);
|
|
3774
3986
|
}
|
|
3775
|
-
function
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
const lt = html.indexOf("<", i);
|
|
3780
|
-
if (lt < 0) return t + html.slice(i);
|
|
3781
|
-
t += html.slice(i, lt);
|
|
3782
|
-
if (!html.startsWith("<!--", lt)) return t;
|
|
3783
|
-
const ce = html.indexOf("-->", lt);
|
|
3784
|
-
if (ce < 0) return t;
|
|
3785
|
-
i = ce + 3;
|
|
3786
|
-
}
|
|
3787
|
-
}
|
|
3788
|
-
function tagIs(html, i, name) {
|
|
3789
|
-
if (!html.startsWith(name, i + 1)) return false;
|
|
3790
|
-
const c = html.charCodeAt(i + 1 + name.length);
|
|
3791
|
-
return c === 32 || c === 62 || c === 9 || c === 10 || c === 13;
|
|
3792
|
-
}
|
|
3793
|
-
let selectValuesActive = false;
|
|
3794
|
-
function ssrSelectValues() {
|
|
3795
|
-
selectValuesActive = true;
|
|
3796
|
-
}
|
|
3797
|
-
function resolveSSRSelectValues(html) {
|
|
3798
|
-
if (!selectValuesActive) return html;
|
|
3799
|
-
let cand = html.indexOf("<select");
|
|
3800
|
-
if (cand < 0) return html;
|
|
3801
|
-
let out = "";
|
|
3802
|
-
let idx = 0;
|
|
3803
|
-
while (cand >= 0) {
|
|
3804
|
-
if (!tagIs(html, cand, "select")) {
|
|
3805
|
-
cand = html.indexOf("<select", cand + 7);
|
|
3806
|
-
continue;
|
|
3807
|
-
}
|
|
3808
|
-
const e0 = tagEnd(html, cand);
|
|
3809
|
-
if (e0 < 0) break;
|
|
3810
|
-
const open = html.slice(cand, e0 + 1);
|
|
3811
|
-
const m = SELECT_VALUE_ATTR.exec(open);
|
|
3812
|
-
if (!m) {
|
|
3813
|
-
cand = html.indexOf("<select", e0 + 1);
|
|
3814
|
-
continue;
|
|
3815
|
-
}
|
|
3816
|
-
const bound = decodeSSREntities(m[1] ?? "");
|
|
3817
|
-
const sel = {
|
|
3818
|
-
values: /\smultiple(?=[\s>=])/.test(open) ? bound.split(",") : [bound],
|
|
3819
|
-
strip: cand + m.index,
|
|
3820
|
-
stripEnd: cand + m.index + m[0].length,
|
|
3821
|
-
body: e0 + 1,
|
|
3822
|
-
marks: [],
|
|
3823
|
-
defaulted: false
|
|
3824
|
-
};
|
|
3825
|
-
let committed = false;
|
|
3826
|
-
let i = html.indexOf("<", e0 + 1);
|
|
3827
|
-
while (i >= 0) {
|
|
3828
|
-
let e;
|
|
3829
|
-
if (html.charCodeAt(i + 1) === 33) {
|
|
3830
|
-
e = html.charCodeAt(i + 2) === 45 ? html.indexOf("-->", i) : html.indexOf(">", i);
|
|
3831
|
-
if (e < 0) break;
|
|
3832
|
-
if (html.charCodeAt(i + 2) === 45) e += 2;
|
|
3833
|
-
} else {
|
|
3834
|
-
e = tagEnd(html, i);
|
|
3835
|
-
if (e < 0) break;
|
|
3836
|
-
if (html.startsWith("</select>", i)) {
|
|
3837
|
-
out += html.slice(idx, sel.strip) + html.slice(sel.stripEnd, sel.body);
|
|
3838
|
-
let seg = sel.body;
|
|
3839
|
-
if (!sel.defaulted) {
|
|
3840
|
-
for (let k = 0; k < sel.marks.length; k++) {
|
|
3841
|
-
out += html.slice(seg, sel.marks[k]) + " selected";
|
|
3842
|
-
seg = sel.marks[k];
|
|
3843
|
-
}
|
|
3844
|
-
}
|
|
3845
|
-
out += html.slice(seg, i);
|
|
3846
|
-
idx = i;
|
|
3847
|
-
committed = true;
|
|
3848
|
-
break;
|
|
3849
|
-
} else if (tagIs(html, i, "option")) {
|
|
3850
|
-
const attrs = html.slice(i + 7, e);
|
|
3851
|
-
if (/\sselected(?=[\s=]|$)/.test(attrs)) sel.defaulted = true;else {
|
|
3852
|
-
const vm = SELECT_VALUE_ATTR.exec(attrs);
|
|
3853
|
-
const value = vm ? decodeSSREntities(vm[1] ?? "") : decodeSSREntities(optionText(html, e + 1)).replace(/\s+/g, " ").trim();
|
|
3854
|
-
if (sel.values.includes(value)) sel.marks.push(e);
|
|
3855
|
-
}
|
|
3856
|
-
}
|
|
3857
|
-
}
|
|
3858
|
-
i = html.indexOf("<", e + 1);
|
|
3859
|
-
}
|
|
3860
|
-
if (!committed) break;
|
|
3861
|
-
cand = html.indexOf("<select", idx);
|
|
3987
|
+
function ssrOption(value, state, own) {
|
|
3988
|
+
if (state === undefined) {
|
|
3989
|
+
const o = getOwner();
|
|
3990
|
+
if (!o || !(state = o._context[SELECT])) return "";
|
|
3862
3991
|
}
|
|
3863
|
-
if (
|
|
3864
|
-
|
|
3992
|
+
if (own) return state.d = true, "";
|
|
3993
|
+
if (state.d) return "";
|
|
3994
|
+
if (typeof value === "function") value = value();
|
|
3995
|
+
if (value == null) return "";
|
|
3996
|
+
value = String(value);
|
|
3997
|
+
const v = state.v;
|
|
3998
|
+
return v != null && (v.map ? v.some(x => x != null && String(x) === value) : String(v) === value) ? " selected" : "";
|
|
3865
3999
|
}
|
|
3866
4000
|
function escape(s, attr) {
|
|
3867
4001
|
const t = typeof s;
|
|
@@ -3968,7 +4102,7 @@ function tryJoinPlainSSRArray(nodes) {
|
|
|
3968
4102
|
let out = "";
|
|
3969
4103
|
for (let i = 0, len = nodes.length; i < len; i++) {
|
|
3970
4104
|
const node = nodes[i];
|
|
3971
|
-
if (node == null || typeof node !== "object" || node.h || typeof node.t !== "string") {
|
|
4105
|
+
if (node == null || typeof node !== "object" || node.$ !== SSR_NODE || node.h || typeof node.t !== "string") {
|
|
3972
4106
|
return undefined;
|
|
3973
4107
|
}
|
|
3974
4108
|
out += node.t;
|
|
@@ -4196,12 +4330,12 @@ function tryResolveString(node, nested) {
|
|
|
4196
4330
|
}
|
|
4197
4331
|
return s;
|
|
4198
4332
|
}
|
|
4333
|
+
if (node.$ !== SSR_NODE) {
|
|
4334
|
+
return "";
|
|
4335
|
+
}
|
|
4199
4336
|
if (node.h && node.h.length > 0) return {
|
|
4200
4337
|
merge: node
|
|
4201
4338
|
};
|
|
4202
|
-
if (node.t === undefined) {
|
|
4203
|
-
return "";
|
|
4204
|
-
}
|
|
4205
4339
|
ssrTextTail = false;
|
|
4206
4340
|
return Array.isArray(node.t) ? node.t[0] : node.t;
|
|
4207
4341
|
}
|
|
@@ -4221,7 +4355,8 @@ function tryResolveString(node, nested) {
|
|
|
4221
4355
|
function resolveSSRNode(node, result = {
|
|
4222
4356
|
t: [""],
|
|
4223
4357
|
h: [],
|
|
4224
|
-
p: []
|
|
4358
|
+
p: [],
|
|
4359
|
+
$: SSR_NODE
|
|
4225
4360
|
}, top, nested) {
|
|
4226
4361
|
if (!nested) ssrTextTail = false;
|
|
4227
4362
|
const t = typeof node;
|
|
@@ -4240,7 +4375,7 @@ function resolveSSRNode(node, result = {
|
|
|
4240
4375
|
if (slotLive) slotLive.suppressed--;
|
|
4241
4376
|
}
|
|
4242
4377
|
} else if (t === "object") {
|
|
4243
|
-
if (node.h) {
|
|
4378
|
+
if (node.$ !== SSR_NODE) ; else if (node.h) {
|
|
4244
4379
|
result.t[result.t.length - 1] += node.t[0];
|
|
4245
4380
|
if (node.t.length > 1) {
|
|
4246
4381
|
result.t.push(...node.t.slice(1));
|
|
@@ -4248,10 +4383,10 @@ function resolveSSRNode(node, result = {
|
|
|
4248
4383
|
result.p.push(...node.p);
|
|
4249
4384
|
}
|
|
4250
4385
|
ssrTextTail = false;
|
|
4251
|
-
} else
|
|
4386
|
+
} else {
|
|
4252
4387
|
result.t[result.t.length - 1] += node.t;
|
|
4253
4388
|
ssrTextTail = false;
|
|
4254
|
-
}
|
|
4389
|
+
}
|
|
4255
4390
|
} else if (t === "function") {
|
|
4256
4391
|
const live = sharedConfig.context && sharedConfig.context.liveHoles;
|
|
4257
4392
|
let liveNode = null;
|
|
@@ -4665,6 +4800,10 @@ function registerElementClaim() {
|
|
|
4665
4800
|
return noopCleanup;
|
|
4666
4801
|
}
|
|
4667
4802
|
function noopCleanup() {}
|
|
4803
|
+
function setTrustedTypesPolicy() {}
|
|
4804
|
+
function trustedHTML(html) {
|
|
4805
|
+
return html;
|
|
4806
|
+
}
|
|
4668
4807
|
function claimElement(node) {
|
|
4669
4808
|
return node;
|
|
4670
4809
|
}
|
|
@@ -4814,4 +4953,4 @@ function httpHeader(name, value, options) {
|
|
|
4814
4953
|
}
|
|
4815
4954
|
}
|
|
4816
4955
|
|
|
4817
|
-
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,
|
|
4956
|
+
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, notSup as heldRead, 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, respond, notSup as runHydrationEvents, serializeCookie, notSup as setAttribute, notSup as setAttributeNS, setLinkClaim, notSup as setProperty, notSup as setStatefulProperty, notSup as setStyleProperty, setTrustedTypesPolicy, notSup as spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrElementAttribute, ssrGroup, ssrHydrationKey, ssrIn, ssrLinkClaim, ssrOption, ssrSelect, ssrStyle, ssrStyleProperties, ssrStyleProperty, notSup as strictHandler, notSup as style, takeHydrationValue, notSup as template, trustedHTML, notSup as unregisterDelegatedContainer, notSup as unregisterDelegatedRoot, useHead };
|