@solidjs/web 2.0.0-rc.11 → 2.0.0-rc.13
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 +533 -106
- package/dist/server.js +437 -79
- package/dist/server.observe.js +449 -79
- package/dist/web.dev.js +35 -9
- package/dist/web.js +35 -9
- package/dist/web.observe.js +35 -9
- package/frames/dist/client.dev.js +362 -107
- package/frames/dist/client.js +317 -104
- package/frames/dist/client.observe.js +318 -103
- package/frames/dist/server.dev.js +288 -55
- package/frames/dist/server.js +235 -55
- package/frames/dist/server.observe.js +235 -55
- package/package.json +4 -3
- package/server-functions/dist/client.dev.js +79 -11
- package/server-functions/dist/client.observe.js +79 -11
- package/server-functions/dist/server.dev.js +30 -6
- package/server-functions/dist/server.js +30 -6
- package/server-functions/dist/server.observe.js +30 -6
- package/skills/server-components/SKILL.md +206 -0
- package/types/client.d.ts +17 -2
- package/types/frames/client.d.ts +1 -1
- package/types/frames/frame-client.d.ts +0 -18
- package/types/frames/frame-container-plugin.d.ts +0 -8
- package/types/frames/server.d.ts +28 -0
- package/types/frames/tree-rewrite.d.ts +39 -0
- package/types/index.server.d.ts +1 -1
- package/types/jsx.d.ts +11 -1
- package/types/observe.d.ts +178 -10
- package/types/request-error-hook.d.ts +5 -0
- package/types/server-observe.d.ts +8 -0
- package/types/server.d.ts +95 -8
package/dist/server.dev.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { createRenderEffect, getOwner, createMemo, OBSERVE, DEV,
|
|
2
|
-
export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, merge as mergeProps,
|
|
3
|
-
import {
|
|
4
|
-
export { ssrScope as scope } from 'solid-js/internal';
|
|
1
|
+
import { createRenderEffect, getOwner, createMemo, OBSERVE, DEV, createRoot, $PROXY, onCleanup, runWithOwner, createComponent, omit, getNextChildId, untrack, NotReadyError } from 'solid-js';
|
|
2
|
+
export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
|
|
3
|
+
import { sharedConfig, viewOf, sourceOwners, reportServerError, ssrHandleError, inServerComponentScope, creationStamp, ssrSanitizeError, getProjectionTrace, shareAsyncIterable } from 'solid-js/internal';
|
|
4
|
+
export { ssrScope as scope, sharedConfig } from 'solid-js/internal';
|
|
5
5
|
import { Feature, createStream, Serializer, getCrossReferenceHeader } from 'seroval';
|
|
6
6
|
import { AbortSignalPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin } from 'seroval-plugins/web';
|
|
7
7
|
|
|
@@ -90,6 +90,15 @@ function memo(fn) {
|
|
|
90
90
|
return createMemo(() => fn(), syncOptions);
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
const REQUEST_ERROR_HOOK = Symbol.for("solid-js/server/request-error-hook");
|
|
94
|
+
function hooks() {
|
|
95
|
+
const g = globalThis;
|
|
96
|
+
return g[REQUEST_ERROR_HOOK] || (g[REQUEST_ERROR_HOOK] = new WeakMap());
|
|
97
|
+
}
|
|
98
|
+
function setRequestErrorHook(event, hook) {
|
|
99
|
+
if (hook !== undefined) hooks().set(event, hook);
|
|
100
|
+
}
|
|
101
|
+
|
|
93
102
|
const PROVIDER = Symbol.for("solid-js/observe/server/provider");
|
|
94
103
|
function currentProvider() {
|
|
95
104
|
if (OBSERVE === undefined) return undefined;
|
|
@@ -306,6 +315,7 @@ function observeRender(trace, mode, event) {
|
|
|
306
315
|
};
|
|
307
316
|
trace.render = record;
|
|
308
317
|
let settled = false;
|
|
318
|
+
let route;
|
|
309
319
|
return {
|
|
310
320
|
shell() {
|
|
311
321
|
if (!settled && record.shellMs === undefined) record.shellMs = performance.now() - record.at;
|
|
@@ -313,11 +323,21 @@ function observeRender(trace, mode, event) {
|
|
|
313
323
|
boundary() {
|
|
314
324
|
if (!settled) record.boundaries++;
|
|
315
325
|
},
|
|
326
|
+
route(ref) {
|
|
327
|
+
if (!settled) route = ref;
|
|
328
|
+
},
|
|
316
329
|
settle(outcome) {
|
|
317
330
|
if (settled) return;
|
|
318
331
|
settled = true;
|
|
319
332
|
record.durationMs = performance.now() - record.at;
|
|
320
333
|
record.outcome = outcome;
|
|
334
|
+
if (route !== undefined) {
|
|
335
|
+
const r = {};
|
|
336
|
+
if (route.name !== undefined) r.name = route.name;
|
|
337
|
+
if (route.to !== undefined) r.to = route.to;
|
|
338
|
+
if (route.params !== undefined) r.params = route.params;
|
|
339
|
+
record.route = r;
|
|
340
|
+
}
|
|
321
341
|
const channel = records();
|
|
322
342
|
if (!channel.observed("render")) return;
|
|
323
343
|
const live = {
|
|
@@ -329,6 +349,96 @@ function observeRender(trace, mode, event) {
|
|
|
329
349
|
};
|
|
330
350
|
}
|
|
331
351
|
|
|
352
|
+
const DESCEND = Symbol("descend");
|
|
353
|
+
const CYCLE = {};
|
|
354
|
+
const TRACK = 16;
|
|
355
|
+
function rewriteTree(value, visit, withPath) {
|
|
356
|
+
if (value === null || typeof value !== "object") return value;
|
|
357
|
+
const path = undefined;
|
|
358
|
+
const state = {
|
|
359
|
+
memo: undefined,
|
|
360
|
+
ancestors: undefined
|
|
361
|
+
};
|
|
362
|
+
try {
|
|
363
|
+
return cow(value, visit, path, 0, state);
|
|
364
|
+
} catch (err) {
|
|
365
|
+
if (err !== CYCLE) throw err;
|
|
366
|
+
}
|
|
367
|
+
return clone(value, visit, path, state.memo || (state.memo = new Map()));
|
|
368
|
+
}
|
|
369
|
+
function shape(value) {
|
|
370
|
+
return Array.isArray(value) ? 1 : Object.getPrototypeOf(value) === Object.prototype ? 2 : 0;
|
|
371
|
+
}
|
|
372
|
+
function cow(value, visit, path, depth, state) {
|
|
373
|
+
const memo = state.memo;
|
|
374
|
+
if (memo !== undefined && memo.has(value)) return memo.get(value);
|
|
375
|
+
const r = visit(value, path);
|
|
376
|
+
if (r !== DESCEND) {
|
|
377
|
+
if (r !== value) (memo || (state.memo = new Map())).set(value, r);
|
|
378
|
+
return r;
|
|
379
|
+
}
|
|
380
|
+
const s = shape(value);
|
|
381
|
+
if (s === 0) return value;
|
|
382
|
+
let ancestors;
|
|
383
|
+
if (depth >= TRACK) {
|
|
384
|
+
ancestors = state.ancestors || (state.ancestors = new Set());
|
|
385
|
+
if (ancestors.has(value)) throw CYCLE;
|
|
386
|
+
ancestors.add(value);
|
|
387
|
+
}
|
|
388
|
+
let out = value;
|
|
389
|
+
if (s === 1) {
|
|
390
|
+
for (let i = 0; i < value.length; i++) {
|
|
391
|
+
const c = value[i];
|
|
392
|
+
if (c === null || typeof c !== "object") continue;
|
|
393
|
+
const next = cow(c, visit, undefined , depth + 1, state);
|
|
394
|
+
if (next !== c) {
|
|
395
|
+
if (out === value) out = value.slice();
|
|
396
|
+
out[i] = next;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
} else {
|
|
400
|
+
for (const k of Object.keys(value)) {
|
|
401
|
+
const c = value[k];
|
|
402
|
+
if (c === null || typeof c !== "object") continue;
|
|
403
|
+
const next = cow(c, visit, undefined , depth + 1, state);
|
|
404
|
+
if (next !== c) {
|
|
405
|
+
if (out === value) out = {
|
|
406
|
+
...value
|
|
407
|
+
};
|
|
408
|
+
out[k] = next;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
if (ancestors !== undefined) ancestors.delete(value);
|
|
413
|
+
return out;
|
|
414
|
+
}
|
|
415
|
+
function clone(value, visit, path, memo) {
|
|
416
|
+
if (memo.has(value)) return memo.get(value);
|
|
417
|
+
const r = visit(value, path);
|
|
418
|
+
if (r !== DESCEND) {
|
|
419
|
+
memo.set(value, r);
|
|
420
|
+
return r;
|
|
421
|
+
}
|
|
422
|
+
const s = shape(value);
|
|
423
|
+
if (s === 0) return value;
|
|
424
|
+
const out = s === 1 ? value.slice() : {
|
|
425
|
+
...value
|
|
426
|
+
};
|
|
427
|
+
memo.set(value, out);
|
|
428
|
+
if (s === 1) {
|
|
429
|
+
for (let i = 0; i < value.length; i++) {
|
|
430
|
+
const c = value[i];
|
|
431
|
+
if (c !== null && typeof c === "object") out[i] = clone(c, visit, undefined , memo);
|
|
432
|
+
}
|
|
433
|
+
} else {
|
|
434
|
+
for (const k of Object.keys(value)) {
|
|
435
|
+
const c = value[k];
|
|
436
|
+
if (c !== null && typeof c === "object") out[k] = clone(c, visit, undefined , memo);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
return out;
|
|
440
|
+
}
|
|
441
|
+
|
|
332
442
|
const STATE = Symbol.for("solid.container-trace-state");
|
|
333
443
|
const state = globalThis[STATE] || (globalThis[STATE] = {
|
|
334
444
|
materialized: new WeakMap(),
|
|
@@ -348,32 +458,10 @@ function toBorderForm(value, envelopeContainers) {
|
|
|
348
458
|
if (value == null || typeof value !== "object") return value;
|
|
349
459
|
const share = state.shareIterable;
|
|
350
460
|
if (!share) return value;
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
const next = toBorderForm(value[i]);
|
|
356
|
-
if (next !== value[i]) {
|
|
357
|
-
if (out === value) out = value.slice();
|
|
358
|
-
out[i] = next;
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
return out;
|
|
362
|
-
}
|
|
363
|
-
if (Object.getPrototypeOf(value) === Object.prototype) {
|
|
364
|
-
let out = value;
|
|
365
|
-
for (const key of Object.keys(value)) {
|
|
366
|
-
const next = toBorderForm(value[key]);
|
|
367
|
-
if (next !== value[key]) {
|
|
368
|
-
if (out === value) out = {
|
|
369
|
-
...value
|
|
370
|
-
};
|
|
371
|
-
out[key] = next;
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
return out;
|
|
375
|
-
}
|
|
376
|
-
return value;
|
|
461
|
+
return rewriteTree(value, v => {
|
|
462
|
+
if (share && isShareableIterable(v)) return share(v);
|
|
463
|
+
return DESCEND;
|
|
464
|
+
});
|
|
377
465
|
}
|
|
378
466
|
function isShareableIterable(value) {
|
|
379
467
|
try {
|
|
@@ -833,6 +921,7 @@ function resolveHead(groups) {
|
|
|
833
921
|
return winners;
|
|
834
922
|
}
|
|
835
923
|
|
|
924
|
+
const renderConfig = sharedConfig;
|
|
836
925
|
function joinAssetPath(base, file) {
|
|
837
926
|
if (/^(?:[a-z][a-z0-9+.-]*:)?\/\//i.test(file)) return file;
|
|
838
927
|
if (typeof base !== "string" || !base) base = "/";
|
|
@@ -1014,6 +1103,7 @@ function applyAssetTracking(context, tracking, manifest, noScripts) {
|
|
|
1014
1103
|
});
|
|
1015
1104
|
context.registerModule = tracking.registerModule;
|
|
1016
1105
|
context.getBoundaryModules = tracking.getBoundaryModules;
|
|
1106
|
+
context._lazyAssets = new Map();
|
|
1017
1107
|
if (typeof manifest === "function") {
|
|
1018
1108
|
context.resolveAssets = guard(manifest);
|
|
1019
1109
|
} else if (manifest && typeof manifest.resolve === "function") {
|
|
@@ -1666,6 +1756,7 @@ function renderToString(code, options = {}) {
|
|
|
1666
1756
|
});
|
|
1667
1757
|
const tracking = createAssetTracking();
|
|
1668
1758
|
const headRegistry = createHeadRegistry();
|
|
1759
|
+
let closed = false;
|
|
1669
1760
|
sharedConfig.context = {
|
|
1670
1761
|
nonce: options.nonce,
|
|
1671
1762
|
escape: escape,
|
|
@@ -1676,7 +1767,7 @@ function renderToString(code, options = {}) {
|
|
|
1676
1767
|
registerHeadTags(headRegistry, sharedConfig.context, tracking, null, nonce, tags);
|
|
1677
1768
|
},
|
|
1678
1769
|
serialize(id, p) {
|
|
1679
|
-
if (
|
|
1770
|
+
if (closed) return;
|
|
1680
1771
|
if (p != null && typeof p === "object" && (typeof p.then === "function" || typeof p[Symbol.asyncIterator] === "function")) {
|
|
1681
1772
|
throw new Error("Cannot serialize async value in renderToString (id: " + id + "). " + "Use renderToStream for async data.");
|
|
1682
1773
|
}
|
|
@@ -1705,20 +1796,25 @@ function renderToString(code, options = {}) {
|
|
|
1705
1796
|
applyAssetTracking(sharedConfig.context, tracking, manifest, noScripts);
|
|
1706
1797
|
registerEntryAssets(manifest);
|
|
1707
1798
|
const context = sharedConfig.context;
|
|
1799
|
+
context.writer = createHydrationWriter(context, () => !closed);
|
|
1708
1800
|
const requestEvent = peekRequestEvent();
|
|
1801
|
+
if (requestEvent) setRequestErrorHook(requestEvent, options.onError);
|
|
1709
1802
|
context.trace = requestEvent ? traceForEvent(requestEvent) : traceFor(context, undefined);
|
|
1710
1803
|
const render = timeDocument(context, context.trace, "string", requestEvent);
|
|
1711
1804
|
let dispose;
|
|
1805
|
+
let rootOwner;
|
|
1712
1806
|
let rendered = false;
|
|
1713
1807
|
try {
|
|
1714
1808
|
const html = createRoot(d => {
|
|
1715
1809
|
dispose = d;
|
|
1810
|
+
rootOwner = claimRenderRoot(context);
|
|
1811
|
+
if (requestEvent) claimEventRender(requestEvent, context);
|
|
1716
1812
|
return resolveSSRSync(escape(code()));
|
|
1717
1813
|
}, {
|
|
1718
1814
|
id: renderId
|
|
1719
1815
|
});
|
|
1720
1816
|
serializeFragmentAssets("", tracking.boundaryModules, sharedConfig.context, renderId);
|
|
1721
|
-
|
|
1817
|
+
closed = true;
|
|
1722
1818
|
serializer.close();
|
|
1723
1819
|
const head = renderShellHead(headRegistry, nonce, null, noScripts, traceMetaMarkup(context.trace));
|
|
1724
1820
|
const document = assembleDocument(resolveSSRSelectValues(html), tracking.emittedAssets, tracking.preloadLinks, tracking.inlineStyles, scripts.length ? scripts : "", nonce, head, onHead);
|
|
@@ -1731,7 +1827,7 @@ function renderToString(code, options = {}) {
|
|
|
1731
1827
|
rendered = true;
|
|
1732
1828
|
return document;
|
|
1733
1829
|
} finally {
|
|
1734
|
-
if (render) render
|
|
1830
|
+
if (render) settleRender(render, rootOwner, rendered ? "complete" : "error");
|
|
1735
1831
|
context.trace = undefined;
|
|
1736
1832
|
if (dispose) dispose();
|
|
1737
1833
|
}
|
|
@@ -1747,9 +1843,11 @@ function renderToStream(code, options = {}) {
|
|
|
1747
1843
|
} = options;
|
|
1748
1844
|
const nonce = normalizeNonce(options.nonce);
|
|
1749
1845
|
const requestEvent = peekRequestEvent();
|
|
1846
|
+
if (requestEvent) setRequestErrorHook(requestEvent, options.onError);
|
|
1750
1847
|
let dispose;
|
|
1751
1848
|
let dead = false;
|
|
1752
1849
|
let render;
|
|
1850
|
+
let rootOwner;
|
|
1753
1851
|
let serializer;
|
|
1754
1852
|
let disconnected = false;
|
|
1755
1853
|
let failed = false;
|
|
@@ -1788,7 +1886,7 @@ function renderToStream(code, options = {}) {
|
|
|
1788
1886
|
dead = true;
|
|
1789
1887
|
completed = true;
|
|
1790
1888
|
if (disconnect) disconnected = true;
|
|
1791
|
-
if (render) render
|
|
1889
|
+
if (render) settleRender(render, rootOwner, disconnect ? "abandoned" : "error");
|
|
1792
1890
|
const sink = writable;
|
|
1793
1891
|
buffer = {
|
|
1794
1892
|
write() {}
|
|
@@ -1825,7 +1923,7 @@ function renderToStream(code, options = {}) {
|
|
|
1825
1923
|
reportServerError(err, {
|
|
1826
1924
|
kind: "render",
|
|
1827
1925
|
handling: "failed"
|
|
1828
|
-
}, null);
|
|
1926
|
+
}, null, options.onError);
|
|
1829
1927
|
if (!options.onError && ambientServerErrorHook() === undefined) console.error(err);
|
|
1830
1928
|
abandon();
|
|
1831
1929
|
};
|
|
@@ -1929,7 +2027,7 @@ function renderToStream(code, options = {}) {
|
|
|
1929
2027
|
});
|
|
1930
2028
|
writable && writable.end();
|
|
1931
2029
|
completed = true;
|
|
1932
|
-
if (render) render
|
|
2030
|
+
if (render) settleRender(render, rootOwner, "complete");
|
|
1933
2031
|
if (firstFlushed) dispose();
|
|
1934
2032
|
};
|
|
1935
2033
|
const sink = {
|
|
@@ -2211,7 +2309,6 @@ function renderToStream(code, options = {}) {
|
|
|
2211
2309
|
html = html.slice(0, first) + resolveSSRSync(escape(payloadFn())) + html.slice(last + placeholder.length + 1);
|
|
2212
2310
|
},
|
|
2213
2311
|
serialize(id, p, deferStream) {
|
|
2214
|
-
if (sharedConfig.context.noHydrate) return;
|
|
2215
2312
|
p = guardChannel(p);
|
|
2216
2313
|
if (p && typeof p === "object" && typeof p.then === "function") {
|
|
2217
2314
|
if (!firstFlushed && deferStream) {
|
|
@@ -2328,6 +2425,7 @@ function renderToStream(code, options = {}) {
|
|
|
2328
2425
|
context.trace = requestEvent ? traceForEvent(requestEvent) : traceFor(context, undefined);
|
|
2329
2426
|
render = timeDocument(context, context.trace, "stream", requestEvent);
|
|
2330
2427
|
registerEntryAssets(manifest);
|
|
2428
|
+
context.writer = createHydrationWriter(context, () => !completed);
|
|
2331
2429
|
const signal = options.signal;
|
|
2332
2430
|
const onAbort = signal ? () => abandon("signal") : undefined;
|
|
2333
2431
|
let html = createRoot(d => {
|
|
@@ -2336,6 +2434,8 @@ function renderToStream(code, options = {}) {
|
|
|
2336
2434
|
if (onAbort) signal.removeEventListener("abort", onAbort);
|
|
2337
2435
|
d();
|
|
2338
2436
|
};
|
|
2437
|
+
rootOwner = claimRenderRoot(context);
|
|
2438
|
+
if (requestEvent) claimEventRender(requestEvent, context);
|
|
2339
2439
|
const res = resolveSSRNode(escape(code()));
|
|
2340
2440
|
if (!res.h.length) return res.t[0];
|
|
2341
2441
|
rootHoles = [];
|
|
@@ -3250,14 +3350,16 @@ function ssrClassName(value) {
|
|
|
3250
3350
|
if (typeof value === "number") return "" + value;
|
|
3251
3351
|
if (!value) return "";
|
|
3252
3352
|
if (typeof value === "string") return escape(value, true);
|
|
3353
|
+
if (isSlotValue(value)) return slotValueInline("class", value) ?? "";
|
|
3253
3354
|
value = classListToObject(value);
|
|
3254
3355
|
let classKeys = Object.keys(value),
|
|
3255
3356
|
result = "";
|
|
3256
3357
|
for (let i = 0, len = classKeys.length; i < len; i++) {
|
|
3257
|
-
const key = classKeys[i]
|
|
3258
|
-
|
|
3358
|
+
const key = classKeys[i];
|
|
3359
|
+
let classValue = value[key];
|
|
3360
|
+
if (isSlotValue(classValue)) classValue = slotValueInline("class", classValue);
|
|
3259
3361
|
if (!key || key === "undefined" || !classValue) continue;
|
|
3260
|
-
|
|
3362
|
+
result && (result += " ");
|
|
3261
3363
|
result += escape(key, true);
|
|
3262
3364
|
}
|
|
3263
3365
|
return result;
|
|
@@ -3265,15 +3367,17 @@ function ssrClassName(value) {
|
|
|
3265
3367
|
function ssrStyle(value) {
|
|
3266
3368
|
if (!value) return "";
|
|
3267
3369
|
if (typeof value === "string") return escape(value, true);
|
|
3370
|
+
if (isSlotValue(value)) return slotValueInline("style", value) ?? "";
|
|
3268
3371
|
let result = "";
|
|
3269
3372
|
const k = Object.keys(value);
|
|
3270
3373
|
for (let i = 0; i < k.length; i++) {
|
|
3271
3374
|
const s = escape(k[i], true);
|
|
3272
|
-
|
|
3375
|
+
let v = value[k[i]];
|
|
3376
|
+
if (isSlotValue(v)) v = slotValueInline("style", v);
|
|
3273
3377
|
if (v != undefined) {
|
|
3274
|
-
if (i) result += ";";
|
|
3275
3378
|
const r = escape(v, true);
|
|
3276
3379
|
if (r != undefined && r !== "undefined") {
|
|
3380
|
+
if (result) result += ";";
|
|
3277
3381
|
result += `${s}:${r}`;
|
|
3278
3382
|
}
|
|
3279
3383
|
}
|
|
@@ -3281,28 +3385,31 @@ function ssrStyle(value) {
|
|
|
3281
3385
|
return result;
|
|
3282
3386
|
}
|
|
3283
3387
|
function ssrStyleProperty(name, value) {
|
|
3388
|
+
if (isSlotValue(value)) value = slotValueInline("style", value);
|
|
3284
3389
|
return value != null ? name + value : "";
|
|
3285
3390
|
}
|
|
3286
|
-
function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
3391
|
+
function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
|
|
3287
3392
|
const hk = needsId ? ssrHydrationKey() : "";
|
|
3288
3393
|
if (typeof props === "function") props = props();
|
|
3289
3394
|
let sources = null;
|
|
3290
3395
|
let proxy = false;
|
|
3291
3396
|
let viewKeys = null;
|
|
3292
3397
|
let owners = null;
|
|
3398
|
+
let ownerIndex = null;
|
|
3399
|
+
const ctx = renderConfig.context;
|
|
3400
|
+
const slots = ctx !== undefined && ctx.claims !== undefined;
|
|
3293
3401
|
if (Array.isArray(props)) {
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
if (s != null) sourceOwners(s, viewKeys, owners);
|
|
3402
|
+
if (slots && props.$slot === true) props = slotSpreadSource(tag, props);else {
|
|
3403
|
+
let i = 0;
|
|
3404
|
+
for (; i < props.length; i++) {
|
|
3405
|
+
const s = props[i];
|
|
3406
|
+
if (s == null || typeof s === "function" || $PROXY in s || slots && s.$slot === true) break;
|
|
3407
|
+
}
|
|
3408
|
+
if (i === props.length) sources = props;else {
|
|
3409
|
+
viewKeys = [];
|
|
3410
|
+
owners = [];
|
|
3411
|
+
if (slots) ownerIndex = [];
|
|
3412
|
+
collectSpreadSources(tag, props, viewKeys, owners, slots, ownerIndex);
|
|
3306
3413
|
}
|
|
3307
3414
|
}
|
|
3308
3415
|
} else if (props == null) {
|
|
@@ -3313,10 +3420,13 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
|
3313
3420
|
owners = [];
|
|
3314
3421
|
sourceOwners(props, viewKeys, owners);
|
|
3315
3422
|
} else proxy = true;
|
|
3423
|
+
} else if (slots && props.$slot === true) {
|
|
3424
|
+
props = slotSpreadSource(tag, props);
|
|
3316
3425
|
}
|
|
3317
3426
|
const info = tagInfo(tag);
|
|
3318
3427
|
const skipChildren = info.isVoid;
|
|
3319
3428
|
let result = info.open + hk;
|
|
3429
|
+
let behaviors = null;
|
|
3320
3430
|
const last = sources === null ? 0 : sources.length - 1;
|
|
3321
3431
|
let keysOf = null;
|
|
3322
3432
|
if (sources !== null) {
|
|
@@ -3343,22 +3453,20 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
|
3343
3453
|
continue;
|
|
3344
3454
|
}
|
|
3345
3455
|
const value = props[prop];
|
|
3346
|
-
if (value == undefined
|
|
3347
|
-
if (
|
|
3348
|
-
devCheck({
|
|
3349
|
-
code: "BEHAVIOR_CLAIM_DROPPED",
|
|
3350
|
-
kind: "ssr",
|
|
3351
|
-
severity: "warn",
|
|
3352
|
-
message: `[BEHAVIOR_CLAIM_DROPPED] A spread on a server-rendered <${tag}> carries \`${prop}\` from client props — ` + `spreads don't participate in behavior claims, so this drops. ` + `Write the position out: \`${prop}={props.${String(value[CLAIM_PROP])}}\`.`,
|
|
3353
|
-
data: {
|
|
3354
|
-
reason: "spread",
|
|
3355
|
-
tag,
|
|
3356
|
-
position: prop,
|
|
3357
|
-
prop: String(value[CLAIM_PROP])
|
|
3358
|
-
}
|
|
3359
|
-
});
|
|
3360
|
-
}
|
|
3456
|
+
if (value == undefined) {
|
|
3457
|
+
if (slots && claims !== undefined && (prop === "ref" || prop.startsWith("on"))) behaviors = spreadBehaviorPosition(behaviors, prop, value, ctx.claims, ownerIndex !== null ? ownerIndex[i] : s, true);
|
|
3361
3458
|
continue;
|
|
3459
|
+
}
|
|
3460
|
+
if (prop.startsWith("prop:")) {
|
|
3461
|
+
if (slots && typeof value === "object") spreadPropPosition(prop, value);
|
|
3462
|
+
continue;
|
|
3463
|
+
}
|
|
3464
|
+
if (prop === "ref" || prop.startsWith("on")) {
|
|
3465
|
+
if (slots) behaviors = spreadBehaviorPosition(behaviors, prop, value, ctx.claims, ownerIndex !== null ? ownerIndex[i] : s, claims !== undefined);
|
|
3466
|
+
continue;
|
|
3467
|
+
}
|
|
3468
|
+
if (slots && typeof value === "object") {
|
|
3469
|
+
result += spreadObjectAttribute(prop, value);
|
|
3362
3470
|
} else if (prop === "style") {
|
|
3363
3471
|
result += ` style="${ssrStyle(value)}"`;
|
|
3364
3472
|
} else if (prop === "class") {
|
|
@@ -3371,6 +3479,7 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
|
3371
3479
|
}
|
|
3372
3480
|
}
|
|
3373
3481
|
}
|
|
3482
|
+
if (slots && (behaviors !== null || claims !== undefined)) result += spreadBehaviorMarkers(behaviors, claims, ctx.claims);
|
|
3374
3483
|
if (attrs !== undefined) result += typeof attrs === "function" ? attrs() : attrs;
|
|
3375
3484
|
if (skipChildren) return {
|
|
3376
3485
|
t: result + " />"
|
|
@@ -3390,56 +3499,309 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
|
3390
3499
|
}
|
|
3391
3500
|
function ssrElementAttribute(key, value) {
|
|
3392
3501
|
if (value == undefined) return "";
|
|
3393
|
-
if (key === "style"
|
|
3394
|
-
|
|
3502
|
+
if (key === "style" || key === "class") {
|
|
3503
|
+
return typeof value === "object" ? slotClassOrStyle(key, value) : ` ${key}="${key === "class" ? ssrClassName(value) : ssrStyle(value)}"`;
|
|
3504
|
+
}
|
|
3505
|
+
if (isSlotValue(value)) return slotAttribute(key, value);
|
|
3395
3506
|
if (typeof value === "boolean") return value ? ` ${key}` : "";
|
|
3396
3507
|
return value === "" ? ` ${key}` : ` ${key}="${escape(value, true)}"`;
|
|
3397
3508
|
}
|
|
3398
3509
|
function ssrAttribute(key, value) {
|
|
3399
|
-
|
|
3510
|
+
if (value == null || value === false) return "";
|
|
3511
|
+
if (typeof value === "object") {
|
|
3512
|
+
return isSlotValue(value) ? slotAttribute(key, value) : ` ${key}="${escape(String(value), true)}"`;
|
|
3513
|
+
}
|
|
3514
|
+
return value === true ? ` ${key}` : ` ${key}="${value}"`;
|
|
3400
3515
|
}
|
|
3401
3516
|
function ssrHydrationKey() {
|
|
3402
3517
|
const hk = getHydrationKey();
|
|
3403
3518
|
return hk ? ` _hk=${hk}` : "";
|
|
3404
3519
|
}
|
|
3405
|
-
const CLAIM_PROP = /*#__PURE__*/Symbol.for("solid.claim-prop");
|
|
3406
3520
|
const CLAIMS_STREAM = 1;
|
|
3407
3521
|
const CLAIMS_DOCUMENT = 2;
|
|
3408
|
-
const
|
|
3409
|
-
|
|
3410
|
-
|
|
3522
|
+
const SLOT_VALUE = /*#__PURE__*/Symbol.for("solid.slot-value");
|
|
3523
|
+
const SLOT_MARKER = "_s:";
|
|
3524
|
+
const SLOT_FACE_STREAM = 0;
|
|
3525
|
+
const SLOT_FACE_DATA = 1;
|
|
3526
|
+
const SLOT_FACE_MARKUP = 2;
|
|
3527
|
+
const ATTRIBUTE_SLOT_POSITION = "ATTRIBUTE_SLOT_POSITION";
|
|
3528
|
+
function slotFinding(sv, reason, position, message, severity = "warn") {
|
|
3529
|
+
{
|
|
3530
|
+
const ctx = sharedConfig.context;
|
|
3531
|
+
if (ctx) {
|
|
3532
|
+
const id = `${sv[SLOT_VALUE]}\u0000${sv.k}\u0000${reason}\u0000${position || ""}`;
|
|
3533
|
+
const seen = ctx.slotFindings || (ctx.slotFindings = new Set());
|
|
3534
|
+
if (seen.has(id)) return;
|
|
3535
|
+
seen.add(id);
|
|
3536
|
+
}
|
|
3537
|
+
devCheck({
|
|
3538
|
+
code: ATTRIBUTE_SLOT_POSITION,
|
|
3539
|
+
kind: "ssr",
|
|
3540
|
+
severity,
|
|
3541
|
+
message,
|
|
3542
|
+
data: {
|
|
3543
|
+
reason,
|
|
3544
|
+
occurrence: sv[SLOT_VALUE],
|
|
3545
|
+
key: sv.k,
|
|
3546
|
+
position
|
|
3547
|
+
}
|
|
3548
|
+
});
|
|
3549
|
+
}
|
|
3411
3550
|
}
|
|
3412
|
-
function
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3551
|
+
function isSlotValue(value) {
|
|
3552
|
+
return value !== null && typeof value === "object" && value[SLOT_VALUE] !== undefined;
|
|
3553
|
+
}
|
|
3554
|
+
function slotValue(occurrence, key, value, face) {
|
|
3555
|
+
const sv = {
|
|
3556
|
+
[SLOT_VALUE]: occurrence,
|
|
3557
|
+
k: key,
|
|
3558
|
+
v: value,
|
|
3559
|
+
f: face
|
|
3560
|
+
};
|
|
3561
|
+
Object.defineProperty(sv, Symbol.toPrimitive, {
|
|
3562
|
+
value: hint => slotValueString(sv, hint === "string" ? "stringified" : "coerced")
|
|
3563
|
+
});
|
|
3564
|
+
Object.defineProperty(sv, "toString", {
|
|
3565
|
+
value: () => slotValueString(sv, "stringified")
|
|
3566
|
+
});
|
|
3567
|
+
return sv;
|
|
3568
|
+
}
|
|
3569
|
+
function slotValueString(sv, reason) {
|
|
3570
|
+
{
|
|
3571
|
+
const prop = propOfOccurrence(sv[SLOT_VALUE]);
|
|
3572
|
+
slotFinding(sv, reason, undefined, reason === "coerced" ? `[${ATTRIBUTE_SLOT_POSITION}] \`${prop}\`'s \`${sv.k}\` is an attribute-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 or ref; a decision that depends on it ` + `belongs in the client fill (return the decided value) or in a markup slot.` : `[${ATTRIBUTE_SLOT_POSITION}] \`${prop}\`'s \`${sv.k}\` is an attribute-slot value ` + `and was stringified outside a bindable position — it must be the WHOLE value of an attribute, ` + `class name, style property, handler or ref (\`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.`);
|
|
3573
|
+
}
|
|
3574
|
+
return "";
|
|
3575
|
+
}
|
|
3576
|
+
function slotTextPosition(sv) {
|
|
3577
|
+
{
|
|
3578
|
+
slotFinding(sv, "text", undefined, `[${ATTRIBUTE_SLOT_POSITION}] \`${sv.k}\` of slot \`${propOfOccurrence(sv[SLOT_VALUE])}\` is placed as TEXT. ` + `Text is not a bindable position yet: nothing renders here on either face. ` + `Bind it to an attribute, or render the text in a markup slot.`);
|
|
3579
|
+
}
|
|
3580
|
+
return "";
|
|
3581
|
+
}
|
|
3582
|
+
function slotMarkupRead(sv, position) {
|
|
3583
|
+
if (sv.f === SLOT_FACE_MARKUP) {
|
|
3584
|
+
slotFinding(sv, "markup", position, `[${ATTRIBUTE_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.`);
|
|
3416
3585
|
}
|
|
3586
|
+
}
|
|
3587
|
+
function slotValueInline(kind, sv) {
|
|
3588
|
+
{
|
|
3589
|
+
slotFinding(sv, "inline", kind, `[${ATTRIBUTE_SLOT_POSITION}] An attribute-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.`);
|
|
3590
|
+
}
|
|
3591
|
+
return undefined;
|
|
3592
|
+
}
|
|
3593
|
+
const SLOT_KEY_UNSAFE = /[^A-Za-z0-9_.!~*'()-]/g;
|
|
3594
|
+
function encodeSlotKey(key) {
|
|
3595
|
+
return String(key).replace(SLOT_KEY_UNSAFE, c => encodeURIComponent(c));
|
|
3596
|
+
}
|
|
3597
|
+
function slotEntry(sv, name) {
|
|
3598
|
+
return `${sv[SLOT_VALUE]}:${encodeSlotKey(sv.k)}${name !== undefined ? "=" + encodeSlotKey(name) : ""}`;
|
|
3599
|
+
}
|
|
3600
|
+
function slotMarker(position, entries) {
|
|
3601
|
+
return ` ${SLOT_MARKER}${position}="${entries}"`;
|
|
3602
|
+
}
|
|
3603
|
+
function propOfOccurrence(occurrence) {
|
|
3604
|
+
const i = occurrence.indexOf("#");
|
|
3605
|
+
return i === -1 ? occurrence : occurrence.slice(0, i);
|
|
3606
|
+
}
|
|
3607
|
+
function slotAttribute(key, sv) {
|
|
3608
|
+
slotMarkupRead(sv, key);
|
|
3417
3609
|
let out = "";
|
|
3418
|
-
|
|
3419
|
-
const
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3610
|
+
if (sv.f === SLOT_FACE_DATA) {
|
|
3611
|
+
const v = sv.v;
|
|
3612
|
+
if (v != null && v !== false) {
|
|
3613
|
+
out = v === true || v === "" ? ` ${key}` : ` ${key}="${escape(String(v), true)}"`;
|
|
3614
|
+
}
|
|
3615
|
+
}
|
|
3616
|
+
return out + slotMarker(key, slotEntry(sv));
|
|
3617
|
+
}
|
|
3618
|
+
function slotClassOrStyle(key, value) {
|
|
3619
|
+
const isClass = key === "class";
|
|
3620
|
+
if (isSlotValue(value)) {
|
|
3621
|
+
slotMarkupRead(value, key);
|
|
3622
|
+
let out = "";
|
|
3623
|
+
if (value.f === SLOT_FACE_DATA && value.v != null) {
|
|
3624
|
+
out = ` ${key}="${isClass ? ssrClassName(value.v) : ssrStyle(value.v)}"`;
|
|
3625
|
+
}
|
|
3626
|
+
return out + slotMarker(key, slotEntry(value));
|
|
3627
|
+
}
|
|
3628
|
+
if (typeof value === "object" && value !== null) {
|
|
3629
|
+
const obj = isClass ? classListToObject(value) : value;
|
|
3630
|
+
let entries = "";
|
|
3631
|
+
let inner = "";
|
|
3632
|
+
for (const name of Object.keys(obj)) {
|
|
3633
|
+
let v = obj[name];
|
|
3634
|
+
if (isSlotValue(v)) {
|
|
3635
|
+
slotMarkupRead(v, `${key}:${name}`);
|
|
3636
|
+
entries += (entries ? "," : "") + slotEntry(v, name);
|
|
3637
|
+
v = v.f === SLOT_FACE_DATA ? v.v : undefined;
|
|
3638
|
+
}
|
|
3639
|
+
if (isClass) {
|
|
3640
|
+
if (!name || name === "undefined" || !v) continue;
|
|
3641
|
+
inner += (inner ? " " : "") + escape(name, true);
|
|
3642
|
+
} else if (v != undefined) {
|
|
3643
|
+
const r = escape(v, true);
|
|
3644
|
+
if (r != undefined && r !== "undefined") {
|
|
3645
|
+
inner += (inner ? ";" : "") + `${escape(name, true)}:${r}`;
|
|
3436
3646
|
}
|
|
3437
|
-
continue;
|
|
3438
3647
|
}
|
|
3439
|
-
out += `${out ? "," : ""}${pos}=${encodeClaimKey(prop)}`;
|
|
3440
3648
|
}
|
|
3649
|
+
if (entries === "") return ` ${key}="${inner}"`;
|
|
3650
|
+
return (inner ? ` ${key}="${inner}"` : "") + slotMarker(key, entries);
|
|
3441
3651
|
}
|
|
3442
|
-
return
|
|
3652
|
+
return ` ${key}="${isClass ? ssrClassName(value) : ssrStyle(value)}"`;
|
|
3653
|
+
}
|
|
3654
|
+
function eventPosition(prop) {
|
|
3655
|
+
return prop.slice(2).toLowerCase();
|
|
3656
|
+
}
|
|
3657
|
+
function spreadBehaviorPosition(behaviors, prop, value, mode, index, settle) {
|
|
3658
|
+
const pos = prop === "ref" ? "ref" : eventPosition(prop);
|
|
3659
|
+
const entries = value == null ? "" : claimEntries(pos, value, mode);
|
|
3660
|
+
if (!settle) {
|
|
3661
|
+
if (entries) (behaviors ||= new Map()).set(pos, entries);
|
|
3662
|
+
return behaviors;
|
|
3663
|
+
}
|
|
3664
|
+
behaviors ||= new Map();
|
|
3665
|
+
const b = behaviors.get(pos);
|
|
3666
|
+
if (b === undefined) behaviors.set(pos, {
|
|
3667
|
+
e: entries,
|
|
3668
|
+
at: index
|
|
3669
|
+
});else {
|
|
3670
|
+
b.e = entries;
|
|
3671
|
+
b.at = index;
|
|
3672
|
+
}
|
|
3673
|
+
return behaviors;
|
|
3674
|
+
}
|
|
3675
|
+
function spreadBehaviorMarkers(behaviors, claims, mode) {
|
|
3676
|
+
if (claims !== undefined) {
|
|
3677
|
+
const segments = claims();
|
|
3678
|
+
for (const k in segments) {
|
|
3679
|
+
const map = segments[k];
|
|
3680
|
+
for (const pos in map) {
|
|
3681
|
+
const value = map[pos];
|
|
3682
|
+
behaviors ||= new Map();
|
|
3683
|
+
const b = behaviors.get(pos);
|
|
3684
|
+
if (pos === "ref") {
|
|
3685
|
+
if (value == null) continue;
|
|
3686
|
+
const entries = claimEntries("ref", value, mode);
|
|
3687
|
+
if (!entries) continue;
|
|
3688
|
+
if (b === undefined) behaviors.set("ref", {
|
|
3689
|
+
e: entries,
|
|
3690
|
+
at: -1
|
|
3691
|
+
});else b.e = b.e ? b.e + "," + entries : entries;
|
|
3692
|
+
continue;
|
|
3693
|
+
}
|
|
3694
|
+
if (b !== undefined && b.at >= +k) continue;
|
|
3695
|
+
const entries = value == null ? "" : claimEntries(pos, value, mode);
|
|
3696
|
+
if (b === undefined) behaviors.set(pos, {
|
|
3697
|
+
e: entries,
|
|
3698
|
+
at: -1
|
|
3699
|
+
});else b.e = entries;
|
|
3700
|
+
}
|
|
3701
|
+
}
|
|
3702
|
+
}
|
|
3703
|
+
let out = "";
|
|
3704
|
+
if (behaviors !== null) {
|
|
3705
|
+
for (const [pos, b] of behaviors) {
|
|
3706
|
+
const e = claims === undefined ? b : b.e;
|
|
3707
|
+
if (e) out += slotMarker(pos === "ref" ? "ref" : "on:" + pos, e);
|
|
3708
|
+
}
|
|
3709
|
+
}
|
|
3710
|
+
return out;
|
|
3711
|
+
}
|
|
3712
|
+
function collectSpreadSources(tag, props, viewKeys, owners, slots, ownerIndex) {
|
|
3713
|
+
for (let i = 0; i < props.length; i++) {
|
|
3714
|
+
let s = props[i];
|
|
3715
|
+
if (typeof s === "function") s = s();
|
|
3716
|
+
if (s != null) {
|
|
3717
|
+
if (slots && !($PROXY in s) && s.$slot === true) s = slotSpreadSource(tag, s);
|
|
3718
|
+
if (ownerIndex === null) sourceOwners(s, viewKeys, owners);else {
|
|
3719
|
+
const ks = [];
|
|
3720
|
+
const os = [];
|
|
3721
|
+
sourceOwners(s, ks, os);
|
|
3722
|
+
for (let j = 0; j < ks.length; j++) {
|
|
3723
|
+
const at = viewKeys.indexOf(ks[j]);
|
|
3724
|
+
if (at !== -1) {
|
|
3725
|
+
viewKeys.splice(at, 1);
|
|
3726
|
+
owners.splice(at, 1);
|
|
3727
|
+
ownerIndex.splice(at, 1);
|
|
3728
|
+
}
|
|
3729
|
+
viewKeys.push(ks[j]);
|
|
3730
|
+
owners.push(os[j]);
|
|
3731
|
+
ownerIndex.push(i);
|
|
3732
|
+
}
|
|
3733
|
+
}
|
|
3734
|
+
}
|
|
3735
|
+
}
|
|
3736
|
+
}
|
|
3737
|
+
function spreadPropPosition(prop, value) {
|
|
3738
|
+
if (isSlotValue(value)) {
|
|
3739
|
+
slotFinding(value, "prop", prop, `[${ATTRIBUTE_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.`);
|
|
3740
|
+
}
|
|
3741
|
+
}
|
|
3742
|
+
function spreadObjectAttribute(prop, value) {
|
|
3743
|
+
if (prop === "style" || prop === "class") return slotClassOrStyle(prop, value);
|
|
3744
|
+
if (value[SLOT_VALUE] !== undefined) return slotAttribute(attrName(prop), value);
|
|
3745
|
+
return ` ${attrName(prop)}="${escape(value, true)}"`;
|
|
3746
|
+
}
|
|
3747
|
+
function slotSpreadSource(tag, source) {
|
|
3748
|
+
{
|
|
3749
|
+
const occurrence = source.$occurrence;
|
|
3750
|
+
const text = `[${ATTRIBUTE_SLOT_POSITION}] A slot${occurrence ? ` (\`${propOfOccurrence(occurrence)}\`)` : ""} is spread ` + `onto a server-rendered <${tag}>. An attribute slot binds by position — name each one ` + `(\`class={row.rowClass} onClick={row.remove}\`) so the template shows what the client owns.`;
|
|
3751
|
+
recordFinding({
|
|
3752
|
+
code: ATTRIBUTE_SLOT_POSITION,
|
|
3753
|
+
kind: "ssr",
|
|
3754
|
+
severity: "error",
|
|
3755
|
+
message: text,
|
|
3756
|
+
data: {
|
|
3757
|
+
reason: "spread",
|
|
3758
|
+
tag,
|
|
3759
|
+
occurrence
|
|
3760
|
+
}
|
|
3761
|
+
});
|
|
3762
|
+
throw new Error(text);
|
|
3763
|
+
}
|
|
3764
|
+
}
|
|
3765
|
+
function ssrClaim(map) {
|
|
3766
|
+
const mode = sharedConfig.context && sharedConfig.context.claims;
|
|
3767
|
+
if (!mode) return "";
|
|
3768
|
+
let out = "";
|
|
3769
|
+
for (const pos in map) {
|
|
3770
|
+
const entries = claimEntries(pos, map[pos], mode);
|
|
3771
|
+
if (entries) out += slotMarker(pos === "ref" ? "ref" : "on:" + pos, entries);
|
|
3772
|
+
}
|
|
3773
|
+
return out;
|
|
3774
|
+
}
|
|
3775
|
+
function claimEntries(pos, value, mode) {
|
|
3776
|
+
if (Array.isArray(value)) {
|
|
3777
|
+
let entries = "";
|
|
3778
|
+
for (const v of value) {
|
|
3779
|
+
const inner = claimEntries(pos, v, mode);
|
|
3780
|
+
if (inner) entries += (entries ? "," : "") + inner;
|
|
3781
|
+
}
|
|
3782
|
+
return entries;
|
|
3783
|
+
}
|
|
3784
|
+
if (isSlotValue(value)) {
|
|
3785
|
+
slotMarkupRead(value, pos);
|
|
3786
|
+
return slotEntry(value);
|
|
3787
|
+
}
|
|
3788
|
+
if (typeof value === "function" && !value.$slotWarned && claimInScope(mode)) {
|
|
3789
|
+
value.$slotWarned = true;
|
|
3790
|
+
devCheck({
|
|
3791
|
+
code: ATTRIBUTE_SLOT_POSITION,
|
|
3792
|
+
kind: "ssr",
|
|
3793
|
+
severity: "warn",
|
|
3794
|
+
message: `[${ATTRIBUTE_SLOT_POSITION}] A \`${pos}\` position on a server-rendered element received a server-local ` + `function — it can never run. Bind an attribute 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=\`.`,
|
|
3795
|
+
data: {
|
|
3796
|
+
reason: "server-local",
|
|
3797
|
+
position: pos
|
|
3798
|
+
}
|
|
3799
|
+
});
|
|
3800
|
+
}
|
|
3801
|
+
return "";
|
|
3802
|
+
}
|
|
3803
|
+
function claimInScope(mode) {
|
|
3804
|
+
return mode === CLAIMS_STREAM || typeof inServerComponentScope === "function" && inServerComponentScope();
|
|
3443
3805
|
}
|
|
3444
3806
|
function decodeSSREntities(s) {
|
|
3445
3807
|
return s.indexOf("&") < 0 ? s : s.replace(/"/g, '"').replace(/</g, "<").replace(/&/g, "&");
|
|
@@ -3561,6 +3923,7 @@ function escape(s, attr) {
|
|
|
3561
3923
|
if (!attr && t === "function") return escapeLate(s);
|
|
3562
3924
|
if (attr) {
|
|
3563
3925
|
if (s == null || t === "boolean" || t === "number") return s;
|
|
3926
|
+
if (t === "object" && s[SLOT_VALUE] !== undefined) return s;
|
|
3564
3927
|
return escape(String(s), attr);
|
|
3565
3928
|
}
|
|
3566
3929
|
return s;
|
|
@@ -3928,6 +4291,10 @@ function resolveSSRNode(node, result = {
|
|
|
3928
4291
|
} else if (node.t !== undefined) {
|
|
3929
4292
|
result.t[result.t.length - 1] += node.t;
|
|
3930
4293
|
ssrTextTail = false;
|
|
4294
|
+
} else if (node[SLOT_VALUE] !== undefined) {
|
|
4295
|
+
const text = escape(slotTextPosition(node));
|
|
4296
|
+
result.t[result.t.length - 1] += ssrTextTail ? "<!--!$-->" + text : text;
|
|
4297
|
+
ssrTextTail = true;
|
|
3931
4298
|
} else unrecognizedInsert(node);
|
|
3932
4299
|
} else if (t === "function") {
|
|
3933
4300
|
const live = sharedConfig.context && sharedConfig.context.liveHoles;
|
|
@@ -3966,7 +4333,7 @@ function serializerErrorHook(hook) {
|
|
|
3966
4333
|
reportServerError(err, {
|
|
3967
4334
|
kind: "render",
|
|
3968
4335
|
handling: "serialize"
|
|
3969
|
-
}, null);
|
|
4336
|
+
}, null, hook);
|
|
3970
4337
|
};
|
|
3971
4338
|
}
|
|
3972
4339
|
function ambientServerErrorHook() {
|
|
@@ -3981,7 +4348,66 @@ function configureServerErrors(config) {
|
|
|
3981
4348
|
(g[ServerErrors] ||= {}).hook = config ? config.onError : undefined;
|
|
3982
4349
|
}
|
|
3983
4350
|
function getRequestEvent() {
|
|
3984
|
-
|
|
4351
|
+
const store = globalThis[RequestContext];
|
|
4352
|
+
if (!store) return undefined;
|
|
4353
|
+
const event = store.getStore();
|
|
4354
|
+
if (event) return event;
|
|
4355
|
+
const ctx = renderContextOf(getOwner());
|
|
4356
|
+
return ctx && ctx.event || console.warn("RequestEvent is missing. This is most likely due to accessing `getRequestEvent` non-managed async scope in a partially polyfilled environment. Try moving it above all `await` calls.");
|
|
4357
|
+
}
|
|
4358
|
+
const RENDER_ROOTS = Symbol.for("@solidjs/web/render-roots");
|
|
4359
|
+
function renderRoots() {
|
|
4360
|
+
const g = globalThis;
|
|
4361
|
+
return g[RENDER_ROOTS] || (g[RENDER_ROOTS] = new WeakMap());
|
|
4362
|
+
}
|
|
4363
|
+
function claimRenderRoot(context) {
|
|
4364
|
+
const owner = getOwner();
|
|
4365
|
+
const roots = renderRoots();
|
|
4366
|
+
roots.set(owner, context);
|
|
4367
|
+
onCleanup(() => roots.delete(owner));
|
|
4368
|
+
return owner;
|
|
4369
|
+
}
|
|
4370
|
+
function settleRender(render, root, outcome) {
|
|
4371
|
+
runWithOwner(root || null, () => render.settle(outcome));
|
|
4372
|
+
}
|
|
4373
|
+
const eventRenders = new WeakMap();
|
|
4374
|
+
function claimEventRender(event, context) {
|
|
4375
|
+
let renders = eventRenders.get(event);
|
|
4376
|
+
if (!renders) eventRenders.set(event, renders = new Set());
|
|
4377
|
+
renders.add(context);
|
|
4378
|
+
onCleanup(() => renders.delete(context));
|
|
4379
|
+
}
|
|
4380
|
+
function createHydrationWriter(context, isOpen) {
|
|
4381
|
+
const keys = new Set();
|
|
4382
|
+
return {
|
|
4383
|
+
async: !!context.async,
|
|
4384
|
+
write(key, value, options) {
|
|
4385
|
+
if (!isOpen() || keys.has(key)) return false;
|
|
4386
|
+
context.serialize(key, value, options && options.deferStream);
|
|
4387
|
+
keys.add(key);
|
|
4388
|
+
return true;
|
|
4389
|
+
}
|
|
4390
|
+
};
|
|
4391
|
+
}
|
|
4392
|
+
function getHydrationWriter() {
|
|
4393
|
+
let ctx = renderContextOf(getOwner());
|
|
4394
|
+
if (!ctx) {
|
|
4395
|
+
const event = peekRequestEvent();
|
|
4396
|
+
const renders = event && eventRenders.get(event);
|
|
4397
|
+
if (renders && renders.size === 1) for (const c of renders) ctx = c;
|
|
4398
|
+
}
|
|
4399
|
+
return ctx && ctx.writer;
|
|
4400
|
+
}
|
|
4401
|
+
function takeHydrationValue(_key) {
|
|
4402
|
+
return undefined;
|
|
4403
|
+
}
|
|
4404
|
+
function renderContextOf(owner) {
|
|
4405
|
+
const roots = globalThis[RENDER_ROOTS];
|
|
4406
|
+
if (!roots) return undefined;
|
|
4407
|
+
for (; owner; owner = owner._parent) {
|
|
4408
|
+
const context = roots.get(owner);
|
|
4409
|
+
if (context) return context;
|
|
4410
|
+
}
|
|
3985
4411
|
}
|
|
3986
4412
|
function peekRequestEvent() {
|
|
3987
4413
|
const store = globalThis[RequestContext];
|
|
@@ -3990,6 +4416,7 @@ function peekRequestEvent() {
|
|
|
3990
4416
|
function timeDocument(context, trace, mode, requestEvent) {
|
|
3991
4417
|
if (records() === undefined) return undefined;
|
|
3992
4418
|
const render = observeRender(trace, mode, requestEvent);
|
|
4419
|
+
if (render) context._declareRoute = ref => render.route(ref);
|
|
3993
4420
|
if (timesServerWork()) {
|
|
3994
4421
|
context._recordBoundary = event => {
|
|
3995
4422
|
trace.timing.push({
|
|
@@ -4004,7 +4431,7 @@ function timeDocument(context, trace, mode, requestEvent) {
|
|
|
4004
4431
|
function getTraceContext() {
|
|
4005
4432
|
const event = peekRequestEvent();
|
|
4006
4433
|
if (event) return traceForEvent(event).context;
|
|
4007
|
-
const ctx =
|
|
4434
|
+
const ctx = renderContextOf(getOwner());
|
|
4008
4435
|
return ctx && ctx.trace ? ctx.trace.context : undefined;
|
|
4009
4436
|
}
|
|
4010
4437
|
function traceForStub(stub, event) {
|
|
@@ -4469,4 +4896,4 @@ function httpHeader(name, value, options) {
|
|
|
4469
4896
|
}
|
|
4470
4897
|
}
|
|
4471
4898
|
|
|
4472
|
-
export { CLAIMS_DOCUMENT, CLAIMS_STREAM,
|
|
4899
|
+
export { CLAIMS_DOCUMENT, CLAIMS_STREAM, 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, SLOT_FACE_DATA, SLOT_FACE_MARKUP, SLOT_FACE_STREAM, SLOT_MARKER, SLOT_VALUE, 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, 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, httpHeader, httpStatus, notSup as hydrate, notSup as insert, isDev, isHref, isResponseEnvelope, isSafeError, isServer, isServerFunction, isSlotValue, markSafeError, memo, parseCookieHeader, notSup as readShallow, redirect, notSup as ref, notSup as registerDelegatedContainer, notSup as registerDelegatedRoot, registerElementClaim, reload, notSup as render, renderToStream, renderToString, resolveSSRNode, resolveSSRSelectValues, respond, notSup as runHydrationEvents, scriptNonce, serializeCookie, notSup as setAttribute, notSup as setAttributeNS, notSup as setProperty, notSup as setStyleProperty, slotValue, notSup as spread, ssr, ssrAttribute, ssrClaim, ssrClassName, ssrElement, ssrElementAttribute, ssrGroup, ssrHydrationKey, ssrSelectValues, ssrStyle, ssrStyleProperty, notSup as style, styleNonce, takeHydrationValue, notSup as template, notSup as unregisterDelegatedContainer, notSup as unregisterDelegatedRoot, useHead };
|