@solidjs/web 2.0.0-rc.16 → 2.0.0-rc.18
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 +195 -35
- package/dist/server.js +190 -35
- package/dist/server.observe.js +190 -35
- package/dist/web.dev.js +53 -1
- package/dist/web.js +4 -1
- package/dist/web.observe.js +4 -1
- package/frames/dist/server.dev.js +356 -43
- package/frames/dist/server.js +355 -43
- package/frames/dist/server.observe.js +355 -43
- package/frames/dist/wire.js +110 -14
- package/package.json +4 -4
- package/serialization/dist/decode.js +10 -5
- package/serialization/dist/serialization.js +121 -61
- package/serialization/types/index.d.ts +12 -4
- package/serialization/types/serializer.d.ts +12 -4
- package/server-functions/dist/client.dev.js +10 -21
- package/server-functions/dist/client.js +10 -21
- package/server-functions/dist/client.observe.js +10 -21
- package/server-functions/dist/rich-args.js +54 -3
- package/server-functions/dist/server.dev.js +313 -11
- package/server-functions/dist/server.js +313 -11
- package/server-functions/dist/server.observe.js +313 -11
- package/types/client.d.ts +12 -0
- package/types/diagnostics.d.ts +16 -0
- package/types/frames/frame-morph.d.ts +1 -0
- package/types/frames/serializer.d.ts +12 -4
- package/types/serializer.d.ts +12 -4
- package/types/server-functions/argument-codec.d.ts +11 -2
- package/types/server-functions/client.d.ts +13 -4
- package/types/server-functions/server.d.ts +33 -0
- package/types/server-functions/shared.d.ts +9 -0
- package/types/server-functions/uploads.d.ts +50 -0
- package/types/server.d.ts +1 -1
package/dist/server.dev.js
CHANGED
|
@@ -2,7 +2,7 @@ import { createRenderEffect, getOwner, createMemo, OBSERVE, DEV, createRoot, $PR
|
|
|
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';
|
|
5
|
-
import { createStream,
|
|
5
|
+
import { createStream, Feature, getCrossReferenceHeader, crossSerializeStream } from 'seroval';
|
|
6
6
|
import { AbortSignalPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin } from 'seroval-plugins/web';
|
|
7
7
|
|
|
8
8
|
const DOMWithState = {
|
|
@@ -543,15 +543,92 @@ function resolveSerializerPlugins(customPlugins) {
|
|
|
543
543
|
}
|
|
544
544
|
|
|
545
545
|
const defaultDisabledFeatures = () => Feature.AggregateError | Feature.BigIntTypedArray;
|
|
546
|
-
const serializeOnlyDisabledFeatures = serializeErrorStacks => (
|
|
546
|
+
const serializeOnlyDisabledFeatures = serializeErrorStacks => (process.env.NODE_ENV === "development" ) ? 0 : Feature.ErrorPrototypeStack;
|
|
547
547
|
const HYDRATION_GLOBAL = "_$HY.r";
|
|
548
|
-
function
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
548
|
+
function createKeyedSerializer(serialize, onError, onDone) {
|
|
549
|
+
const cancels = new Set();
|
|
550
|
+
let pendingWrites = 0;
|
|
551
|
+
let flushed = false;
|
|
552
|
+
let done = false;
|
|
553
|
+
let closed = false;
|
|
554
|
+
const maybeDone = () => {
|
|
555
|
+
if (flushed && pendingWrites === 0 && !done) {
|
|
556
|
+
done = true;
|
|
557
|
+
onDone && onDone();
|
|
558
|
+
}
|
|
559
|
+
};
|
|
560
|
+
return {
|
|
561
|
+
write(key, value) {
|
|
562
|
+
if (flushed) return;
|
|
563
|
+
pendingWrites++;
|
|
564
|
+
let settled = false;
|
|
565
|
+
let failed = false;
|
|
566
|
+
let started = false;
|
|
567
|
+
let cancel = null;
|
|
568
|
+
const settle = () => {
|
|
569
|
+
if (settled) return;
|
|
570
|
+
settled = true;
|
|
571
|
+
if (cancel) cancels.delete(cancel);
|
|
572
|
+
pendingWrites--;
|
|
573
|
+
maybeDone();
|
|
574
|
+
};
|
|
575
|
+
let stream;
|
|
576
|
+
try {
|
|
577
|
+
stream = serialize(key, value, {
|
|
578
|
+
onError: onError && (err => {
|
|
579
|
+
failed = true;
|
|
580
|
+
onError(err);
|
|
581
|
+
if (cancel) {
|
|
582
|
+
cancel();
|
|
583
|
+
settle();
|
|
584
|
+
}
|
|
585
|
+
}),
|
|
586
|
+
onDone: settle
|
|
587
|
+
}, initial => {
|
|
588
|
+
if (initial) started = true;
|
|
589
|
+
return !closed;
|
|
590
|
+
});
|
|
591
|
+
} catch (err) {
|
|
592
|
+
settle();
|
|
593
|
+
throw err;
|
|
594
|
+
}
|
|
595
|
+
if (settled) return;
|
|
596
|
+
if (closed || failed) {
|
|
597
|
+
stream();
|
|
598
|
+
settle();
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
cancel = stream;
|
|
602
|
+
cancels.add(cancel);
|
|
603
|
+
},
|
|
604
|
+
flush() {
|
|
605
|
+
flushed = true;
|
|
606
|
+
maybeDone();
|
|
607
|
+
},
|
|
608
|
+
close() {
|
|
609
|
+
closed = flushed = true;
|
|
610
|
+
for (const cancel of cancels) cancel();
|
|
611
|
+
cancels.clear();
|
|
612
|
+
if (!done) {
|
|
613
|
+
done = true;
|
|
614
|
+
onDone && onDone();
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
};
|
|
554
618
|
}
|
|
619
|
+
const KEY_ESCAPES = {
|
|
620
|
+
'"': '\\"',
|
|
621
|
+
"\\": "\\\\",
|
|
622
|
+
"\n": "\\n",
|
|
623
|
+
"\r": "\\r",
|
|
624
|
+
"\b": "\\b",
|
|
625
|
+
"\t": "\\t",
|
|
626
|
+
"\f": "\\f",
|
|
627
|
+
"<": "\\x3C",
|
|
628
|
+
"\u2028": "\\u2028",
|
|
629
|
+
"\u2029": "\\u2029"
|
|
630
|
+
};
|
|
631
|
+
const serializeKey = key => ("" + key).replace(/["\\\n\r\b\t\f<\u2028\u2029]/g, c => KEY_ESCAPES[c]);
|
|
555
632
|
function createHydrationSerializer({
|
|
556
633
|
onData,
|
|
557
634
|
onDone,
|
|
@@ -559,14 +636,20 @@ function createHydrationSerializer({
|
|
|
559
636
|
onError,
|
|
560
637
|
plugins
|
|
561
638
|
}) {
|
|
562
|
-
|
|
639
|
+
const resolvedPlugins = resolveSerializerPlugins(plugins);
|
|
640
|
+
const disabledFeatures = defaultDisabledFeatures() | serializeOnlyDisabledFeatures();
|
|
641
|
+
const refs = new Map();
|
|
642
|
+
return createKeyedSerializer((key, value, callbacks, live) => crossSerializeStream(value, {
|
|
563
643
|
scopeId,
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
644
|
+
refs,
|
|
645
|
+
plugins: resolvedPlugins,
|
|
646
|
+
disabledFeatures,
|
|
647
|
+
onSerialize(data, initial) {
|
|
648
|
+
if (!live(initial)) return;
|
|
649
|
+
onData(initial ? HYDRATION_GLOBAL + '["' + serializeKey(key) + '"]=' + data : data);
|
|
650
|
+
},
|
|
651
|
+
...callbacks
|
|
652
|
+
}), onError, onDone);
|
|
570
653
|
}
|
|
571
654
|
function getLocalHeaderScript(id) {
|
|
572
655
|
return getCrossReferenceHeader(id) + ";";
|
|
@@ -1883,6 +1966,13 @@ function renderToStream(code, options = {}) {
|
|
|
1883
1966
|
const requestEvent = peekRequestEvent();
|
|
1884
1967
|
if (requestEvent) setRequestErrorHook(requestEvent, options.onError);
|
|
1885
1968
|
const errorScope = requestEvent || {};
|
|
1969
|
+
const reportFailure = (err, handling) => {
|
|
1970
|
+
reportServerError(err, {
|
|
1971
|
+
kind: "render",
|
|
1972
|
+
handling
|
|
1973
|
+
}, null, options.onError, errorScope);
|
|
1974
|
+
if (!options.onError && ambientServerErrorHook() === undefined) console.error(err);
|
|
1975
|
+
};
|
|
1886
1976
|
let dispose;
|
|
1887
1977
|
let dead = false;
|
|
1888
1978
|
let render;
|
|
@@ -1937,15 +2027,7 @@ function renderToStream(code, options = {}) {
|
|
|
1937
2027
|
if (dispose) {
|
|
1938
2028
|
const d = dispose;
|
|
1939
2029
|
dispose = () => {};
|
|
1940
|
-
|
|
1941
|
-
d();
|
|
1942
|
-
} catch (err) {
|
|
1943
|
-
reportServerError(err, {
|
|
1944
|
-
kind: "render",
|
|
1945
|
-
handling: "failed"
|
|
1946
|
-
}, null, options.onError, errorScope);
|
|
1947
|
-
if (!options.onError && ambientServerErrorHook() === undefined) console.error(err);
|
|
1948
|
-
}
|
|
2030
|
+
d();
|
|
1949
2031
|
}
|
|
1950
2032
|
if (serializer && typeof serializer.close === "function") {
|
|
1951
2033
|
try {
|
|
@@ -1968,11 +2050,7 @@ function renderToStream(code, options = {}) {
|
|
|
1968
2050
|
} else if (!sink && onDisconnectedBeforeShell) onDisconnectedBeforeShell();
|
|
1969
2051
|
};
|
|
1970
2052
|
const failRender = err => {
|
|
1971
|
-
|
|
1972
|
-
kind: "render",
|
|
1973
|
-
handling: "failed"
|
|
1974
|
-
}, null, options.onError, errorScope);
|
|
1975
|
-
if (!options.onError && ambientServerErrorHook() === undefined) console.error(err);
|
|
2053
|
+
reportFailure(err, "failed");
|
|
1976
2054
|
abandon();
|
|
1977
2055
|
};
|
|
1978
2056
|
const failRootRender = err => {
|
|
@@ -2141,7 +2219,7 @@ function renderToStream(code, options = {}) {
|
|
|
2141
2219
|
plugins: options.plugins,
|
|
2142
2220
|
onData: payload => sink.data(payload),
|
|
2143
2221
|
onDone,
|
|
2144
|
-
onError:
|
|
2222
|
+
onError: err => reportFailure(err, "serialize")
|
|
2145
2223
|
});
|
|
2146
2224
|
let rootAssetsSerialized = false;
|
|
2147
2225
|
const serializeRootAssets = () => {
|
|
@@ -2512,7 +2590,11 @@ function renderToStream(code, options = {}) {
|
|
|
2512
2590
|
context.trace = undefined;
|
|
2513
2591
|
if (onAbort) signal.removeEventListener("abort", onAbort);
|
|
2514
2592
|
if (endEdges) endEdges();
|
|
2515
|
-
|
|
2593
|
+
try {
|
|
2594
|
+
d();
|
|
2595
|
+
} catch (err) {
|
|
2596
|
+
reportFailure(err, "failed");
|
|
2597
|
+
}
|
|
2516
2598
|
};
|
|
2517
2599
|
rootOwner = claimRenderRoot(context);
|
|
2518
2600
|
if (requestEvent) claimEventRender(requestEvent, context);
|
|
@@ -3033,11 +3115,19 @@ function createLiveHoles(sink, scoped, settled, errorScope) {
|
|
|
3033
3115
|
}
|
|
3034
3116
|
function rowOps(last, rows) {
|
|
3035
3117
|
const ops = [];
|
|
3036
|
-
|
|
3037
|
-
|
|
3118
|
+
const html = [];
|
|
3119
|
+
for (let i = 0; i < rows.length; i++) if (i >= last.length || rows[i] !== last[i]) {
|
|
3120
|
+
const patch = i < last.length ? rowPatch(last[i], rows[i]) : null;
|
|
3121
|
+
ops.push(patch ? [i, patch.p, patch.h] : [i, rows[i]]);
|
|
3122
|
+
html.push(rows[i]);
|
|
3123
|
+
}
|
|
3124
|
+
if (ops.length >= rows.length) return null;
|
|
3125
|
+
return Object.defineProperty({
|
|
3038
3126
|
n: rows.length,
|
|
3039
3127
|
r: ops
|
|
3040
|
-
}
|
|
3128
|
+
}, ROW_HTML, {
|
|
3129
|
+
value: html
|
|
3130
|
+
});
|
|
3041
3131
|
}
|
|
3042
3132
|
function resolveHoleValue(hole) {
|
|
3043
3133
|
const result = {
|
|
@@ -3406,6 +3496,76 @@ function attrNames(text) {
|
|
|
3406
3496
|
while (m = re.exec(text)) names.push(m[1]);
|
|
3407
3497
|
return names;
|
|
3408
3498
|
}
|
|
3499
|
+
const ROW_HTML = Symbol.for("solid.rowHtml");
|
|
3500
|
+
const ROW_TOKEN = /<(\/?)([a-zA-Z][^\s/>]*)((?:[^>"']|"[^"]*"|'[^']*')*)>|<!--([\s\S]*?)-->/g;
|
|
3501
|
+
const ROW_VOID = /^(?:area|base|br|col|embed|hr|img|input|link|meta|source|track|wbr)$/i;
|
|
3502
|
+
const ROW_FOREIGN = /^(?:svg|math)$/i;
|
|
3503
|
+
const ROW_RAW = /^(?:script|style|textarea|title|template)$/i;
|
|
3504
|
+
const ROW_KEY = /\s_key(?:="[^"]*")?(?![^\s/])/;
|
|
3505
|
+
const rowKey = attrs => (ROW_KEY.exec(attrs) || [""])[0];
|
|
3506
|
+
const ROW_ENTITY = /&(?:amp|lt|gt|quot|#39);/g;
|
|
3507
|
+
const ROW_ENTITIES = {
|
|
3508
|
+
"&": "&",
|
|
3509
|
+
"<": "<",
|
|
3510
|
+
">": ">",
|
|
3511
|
+
""": '"',
|
|
3512
|
+
"'": "'"
|
|
3513
|
+
};
|
|
3514
|
+
function rowText(text) {
|
|
3515
|
+
if (!text.includes("&")) return text;
|
|
3516
|
+
if (text.replace(ROW_ENTITY, "").includes("&")) return null;
|
|
3517
|
+
return text.replace(ROW_ENTITY, e => ROW_ENTITIES[e]);
|
|
3518
|
+
}
|
|
3519
|
+
const ROW_HASH_SEED = 0x811c9dc5;
|
|
3520
|
+
function rowShape(h, tag, parent) {
|
|
3521
|
+
for (let i = 0; i < tag.length; i++) h = Math.imul(h ^ (tag.charCodeAt(i) | 32), 16777619);
|
|
3522
|
+
return Math.imul(h ^ parent + 2, 16777619);
|
|
3523
|
+
}
|
|
3524
|
+
function rowPatch(a, b) {
|
|
3525
|
+
const ra = new RegExp(ROW_TOKEN);
|
|
3526
|
+
const rb = new RegExp(ROW_TOKEN);
|
|
3527
|
+
const p = [];
|
|
3528
|
+
const stack = [[-1, 0, false]];
|
|
3529
|
+
let el = -1;
|
|
3530
|
+
let h = ROW_HASH_SEED;
|
|
3531
|
+
let ia = 0;
|
|
3532
|
+
let ib = 0;
|
|
3533
|
+
for (;;) {
|
|
3534
|
+
const ma = ra.exec(a);
|
|
3535
|
+
const mb = rb.exec(b);
|
|
3536
|
+
const ta = a.slice(ia, ma ? ma.index : a.length);
|
|
3537
|
+
const tb = b.slice(ib, mb ? mb.index : b.length);
|
|
3538
|
+
const top = stack[stack.length - 1];
|
|
3539
|
+
if (ta !== tb) {
|
|
3540
|
+
const text = rowText(tb);
|
|
3541
|
+
if (text === null) return null;
|
|
3542
|
+
p.push([top[0], top[1], text]);
|
|
3543
|
+
}
|
|
3544
|
+
if (!ma || !mb) return !ma && !mb ? {
|
|
3545
|
+
p,
|
|
3546
|
+
h: h >>> 0
|
|
3547
|
+
} : null;
|
|
3548
|
+
ia = ra.lastIndex;
|
|
3549
|
+
ib = rb.lastIndex;
|
|
3550
|
+
if (ma[4] !== undefined || mb[4] !== undefined) {
|
|
3551
|
+
if (ma[4] !== mb[4]) return null;
|
|
3552
|
+
top[1]++;
|
|
3553
|
+
} else if (ma[1] !== mb[1] || ma[2] !== mb[2]) return null;else if (ROW_RAW.test(ma[2])) return null;else if (ma[1]) {
|
|
3554
|
+
if (stack.length === 1) return null;
|
|
3555
|
+
stack.pop();
|
|
3556
|
+
} else {
|
|
3557
|
+
el++;
|
|
3558
|
+
h = rowShape(h, ma[2], top[0]);
|
|
3559
|
+
top[1]++;
|
|
3560
|
+
const foreign = top[2] || ROW_FOREIGN.test(ma[2]);
|
|
3561
|
+
if (ma[3] !== mb[3]) {
|
|
3562
|
+
if (foreign || rowKey(ma[3]) !== rowKey(mb[3])) return null;
|
|
3563
|
+
p.push([el, mb[3].replace(/\/$/, "")]);
|
|
3564
|
+
}
|
|
3565
|
+
if (!ROW_VOID.test(ma[2]) && !ma[3].endsWith("/")) stack.push([el, 0, foreign]);
|
|
3566
|
+
}
|
|
3567
|
+
}
|
|
3568
|
+
}
|
|
3409
3569
|
function ssr(t) {
|
|
3410
3570
|
const len = arguments.length;
|
|
3411
3571
|
if (len === 1) return {
|
|
@@ -4907,4 +5067,4 @@ function httpHeader(name, value, options) {
|
|
|
4907
5067
|
}
|
|
4908
5068
|
}
|
|
4909
5069
|
|
|
4910
|
-
export { ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, HydrationScript, MathMLElements, NULL_BODY_STATUSES, Namespaces, Portal, RESPONSE_HEADER_VALUE_LIMIT, REVALIDATE_ALL, REVALIDATE_HEADER, RawTextElements, RequestContext, ResponseEnvelope, SAFE_ERROR, SVGElements, VoidElements, notSup as acquireAsset, notSup as addEvent, applyRef, notSup as assign, claimElement, claimElementTree, notSup as className, clearFlashCookie, clientOnly, commitEventResponse, commitResponseStub, composeMiddleware, configureServerErrors, createLiveHoles, createRequestEvent, createResponseStub, createSSRResponse, notSup as delegateEvents, dispatchAsInteraction, dynamic, notSup as dynamicProperty, effect, escape, generateHydrationScript, notSup as getDelegatedRoot, getExpectedRedirectStatus, getHydrationKey, getHydrationWriter, notSup as getNextElement, notSup as getNextMarker, notSup as getNextMatch, getRequestEvent, getServerFunctionMetadata, getServerFunctionRPC, getTraceContext, hasFlashCookie, hasServerLinkState, httpHeader, httpStatus, notSup as hydrate, notSup as insert, isDev, isHref, isResponseEnvelope, isSafeError, isServer, isServerFunction, markSafeError, memo, parseCookieHeader, notSup as readShallow, redirect, notSup as ref, notSup as registerDelegatedContainer, notSup as registerDelegatedRoot, registerElementClaim, reload, notSup as render, renderToStream, renderToString, reportRequestFailure, resolveSSRNode, resolveSSRSelectValues, respond, notSup as runHydrationEvents, serializeCookie, notSup as setAttribute, notSup as setAttributeNS, setLinkClaim, notSup as setProperty, notSup as setStyleProperty, notSup as spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrElementAttribute, ssrGroup, ssrHydrationKey, ssrLinkClaim, ssrSelectValues, ssrStyle, ssrStyleProperties, ssrStyleProperty, notSup as style, takeHydrationValue, notSup as template, notSup as unregisterDelegatedContainer, notSup as unregisterDelegatedRoot, useHead };
|
|
5070
|
+
export { ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, HydrationScript, MathMLElements, NULL_BODY_STATUSES, Namespaces, Portal, RESPONSE_HEADER_VALUE_LIMIT, REVALIDATE_ALL, REVALIDATE_HEADER, RawTextElements, RequestContext, ResponseEnvelope, SAFE_ERROR, SVGElements, VoidElements, notSup as acquireAsset, notSup as addEvent, applyRef, notSup as assign, claimElement, claimElementTree, notSup as className, clearFlashCookie, clientOnly, commitEventResponse, commitResponseStub, composeMiddleware, configureServerErrors, createLiveHoles, createRequestEvent, createResponseStub, createSSRResponse, notSup as delegateEvents, dispatchAsInteraction, dynamic, notSup as dynamicProperty, effect, escape, generateHydrationScript, notSup as getDelegatedRoot, getExpectedRedirectStatus, getHydrationKey, getHydrationWriter, notSup as getNextElement, notSup as getNextMarker, notSup as getNextMatch, getRequestEvent, getServerFunctionMetadata, getServerFunctionRPC, getTraceContext, hasFlashCookie, hasServerLinkState, httpHeader, httpStatus, notSup as hydrate, notSup as insert, isDev, isHref, isResponseEnvelope, isSafeError, isServer, isServerFunction, markSafeError, memo, parseCookieHeader, notSup as readShallow, redirect, notSup as ref, notSup as registerDelegatedContainer, notSup as registerDelegatedRoot, registerElementClaim, reload, notSup as render, renderToStream, renderToString, reportRequestFailure, resolveSSRNode, resolveSSRSelectValues, respond, notSup as runHydrationEvents, serializeCookie, notSup as setAttribute, notSup as setAttributeNS, setLinkClaim, notSup as setProperty, notSup as setStatefulProperty, notSup as setStyleProperty, notSup as spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrElementAttribute, ssrGroup, ssrHydrationKey, ssrLinkClaim, ssrSelectValues, ssrStyle, ssrStyleProperties, ssrStyleProperty, notSup as style, takeHydrationValue, notSup as template, notSup as unregisterDelegatedContainer, notSup as unregisterDelegatedRoot, useHead };
|
package/dist/server.js
CHANGED
|
@@ -2,7 +2,7 @@ import { createRenderEffect, createMemo, getOwner, createRoot, $PROXY, onCleanup
|
|
|
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';
|
|
5
|
-
import { createStream,
|
|
5
|
+
import { createStream, Feature, getCrossReferenceHeader, crossSerializeStream } from 'seroval';
|
|
6
6
|
import { AbortSignalPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin } from 'seroval-plugins/web';
|
|
7
7
|
|
|
8
8
|
const DOMWithState = {
|
|
@@ -447,15 +447,92 @@ function resolveSerializerPlugins(customPlugins) {
|
|
|
447
447
|
}
|
|
448
448
|
|
|
449
449
|
const defaultDisabledFeatures = () => Feature.AggregateError | Feature.BigIntTypedArray;
|
|
450
|
-
const serializeOnlyDisabledFeatures = serializeErrorStacks => (
|
|
450
|
+
const serializeOnlyDisabledFeatures = serializeErrorStacks => (process.env.NODE_ENV === "development" ) ? 0 : Feature.ErrorPrototypeStack;
|
|
451
451
|
const HYDRATION_GLOBAL = "_$HY.r";
|
|
452
|
-
function
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
452
|
+
function createKeyedSerializer(serialize, onError, onDone) {
|
|
453
|
+
const cancels = new Set();
|
|
454
|
+
let pendingWrites = 0;
|
|
455
|
+
let flushed = false;
|
|
456
|
+
let done = false;
|
|
457
|
+
let closed = false;
|
|
458
|
+
const maybeDone = () => {
|
|
459
|
+
if (flushed && pendingWrites === 0 && !done) {
|
|
460
|
+
done = true;
|
|
461
|
+
onDone && onDone();
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
return {
|
|
465
|
+
write(key, value) {
|
|
466
|
+
if (flushed) return;
|
|
467
|
+
pendingWrites++;
|
|
468
|
+
let settled = false;
|
|
469
|
+
let failed = false;
|
|
470
|
+
let started = false;
|
|
471
|
+
let cancel = null;
|
|
472
|
+
const settle = () => {
|
|
473
|
+
if (settled) return;
|
|
474
|
+
settled = true;
|
|
475
|
+
if (cancel) cancels.delete(cancel);
|
|
476
|
+
pendingWrites--;
|
|
477
|
+
maybeDone();
|
|
478
|
+
};
|
|
479
|
+
let stream;
|
|
480
|
+
try {
|
|
481
|
+
stream = serialize(key, value, {
|
|
482
|
+
onError: onError && (err => {
|
|
483
|
+
failed = true;
|
|
484
|
+
onError(err);
|
|
485
|
+
if (cancel) {
|
|
486
|
+
cancel();
|
|
487
|
+
settle();
|
|
488
|
+
}
|
|
489
|
+
}),
|
|
490
|
+
onDone: settle
|
|
491
|
+
}, initial => {
|
|
492
|
+
if (initial) started = true;
|
|
493
|
+
return !closed;
|
|
494
|
+
});
|
|
495
|
+
} catch (err) {
|
|
496
|
+
settle();
|
|
497
|
+
throw err;
|
|
498
|
+
}
|
|
499
|
+
if (settled) return;
|
|
500
|
+
if (closed || failed) {
|
|
501
|
+
stream();
|
|
502
|
+
settle();
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
cancel = stream;
|
|
506
|
+
cancels.add(cancel);
|
|
507
|
+
},
|
|
508
|
+
flush() {
|
|
509
|
+
flushed = true;
|
|
510
|
+
maybeDone();
|
|
511
|
+
},
|
|
512
|
+
close() {
|
|
513
|
+
closed = flushed = true;
|
|
514
|
+
for (const cancel of cancels) cancel();
|
|
515
|
+
cancels.clear();
|
|
516
|
+
if (!done) {
|
|
517
|
+
done = true;
|
|
518
|
+
onDone && onDone();
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
};
|
|
458
522
|
}
|
|
523
|
+
const KEY_ESCAPES = {
|
|
524
|
+
'"': '\\"',
|
|
525
|
+
"\\": "\\\\",
|
|
526
|
+
"\n": "\\n",
|
|
527
|
+
"\r": "\\r",
|
|
528
|
+
"\b": "\\b",
|
|
529
|
+
"\t": "\\t",
|
|
530
|
+
"\f": "\\f",
|
|
531
|
+
"<": "\\x3C",
|
|
532
|
+
"\u2028": "\\u2028",
|
|
533
|
+
"\u2029": "\\u2029"
|
|
534
|
+
};
|
|
535
|
+
const serializeKey = key => ("" + key).replace(/["\\\n\r\b\t\f<\u2028\u2029]/g, c => KEY_ESCAPES[c]);
|
|
459
536
|
function createHydrationSerializer({
|
|
460
537
|
onData,
|
|
461
538
|
onDone,
|
|
@@ -463,14 +540,20 @@ function createHydrationSerializer({
|
|
|
463
540
|
onError,
|
|
464
541
|
plugins
|
|
465
542
|
}) {
|
|
466
|
-
|
|
543
|
+
const resolvedPlugins = resolveSerializerPlugins(plugins);
|
|
544
|
+
const disabledFeatures = defaultDisabledFeatures() | serializeOnlyDisabledFeatures();
|
|
545
|
+
const refs = new Map();
|
|
546
|
+
return createKeyedSerializer((key, value, callbacks, live) => crossSerializeStream(value, {
|
|
467
547
|
scopeId,
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
548
|
+
refs,
|
|
549
|
+
plugins: resolvedPlugins,
|
|
550
|
+
disabledFeatures,
|
|
551
|
+
onSerialize(data, initial) {
|
|
552
|
+
if (!live(initial)) return;
|
|
553
|
+
onData(initial ? HYDRATION_GLOBAL + '["' + serializeKey(key) + '"]=' + data : data);
|
|
554
|
+
},
|
|
555
|
+
...callbacks
|
|
556
|
+
}), onError, onDone);
|
|
474
557
|
}
|
|
475
558
|
function getLocalHeaderScript(id) {
|
|
476
559
|
return getCrossReferenceHeader(id) + ";";
|
|
@@ -1618,6 +1701,13 @@ function renderToStream(code, options = {}) {
|
|
|
1618
1701
|
const requestEvent = peekRequestEvent();
|
|
1619
1702
|
if (requestEvent) setRequestErrorHook(requestEvent, options.onError);
|
|
1620
1703
|
const errorScope = requestEvent || {};
|
|
1704
|
+
const reportFailure = (err, handling) => {
|
|
1705
|
+
reportServerError(err, {
|
|
1706
|
+
kind: "render",
|
|
1707
|
+
handling
|
|
1708
|
+
}, null, options.onError, errorScope);
|
|
1709
|
+
if (!options.onError && ambientServerErrorHook() === undefined) console.error(err);
|
|
1710
|
+
};
|
|
1621
1711
|
let dispose;
|
|
1622
1712
|
let dead = false;
|
|
1623
1713
|
let render;
|
|
@@ -1661,15 +1751,7 @@ function renderToStream(code, options = {}) {
|
|
|
1661
1751
|
if (dispose) {
|
|
1662
1752
|
const d = dispose;
|
|
1663
1753
|
dispose = () => {};
|
|
1664
|
-
|
|
1665
|
-
d();
|
|
1666
|
-
} catch (err) {
|
|
1667
|
-
reportServerError(err, {
|
|
1668
|
-
kind: "render",
|
|
1669
|
-
handling: "failed"
|
|
1670
|
-
}, null, options.onError, errorScope);
|
|
1671
|
-
if (!options.onError && ambientServerErrorHook() === undefined) console.error(err);
|
|
1672
|
-
}
|
|
1754
|
+
d();
|
|
1673
1755
|
}
|
|
1674
1756
|
if (serializer && typeof serializer.close === "function") {
|
|
1675
1757
|
try {
|
|
@@ -1692,11 +1774,7 @@ function renderToStream(code, options = {}) {
|
|
|
1692
1774
|
} else if (!sink && onDisconnectedBeforeShell) onDisconnectedBeforeShell();
|
|
1693
1775
|
};
|
|
1694
1776
|
const failRender = err => {
|
|
1695
|
-
|
|
1696
|
-
kind: "render",
|
|
1697
|
-
handling: "failed"
|
|
1698
|
-
}, null, options.onError, errorScope);
|
|
1699
|
-
if (!options.onError && ambientServerErrorHook() === undefined) console.error(err);
|
|
1777
|
+
reportFailure(err, "failed");
|
|
1700
1778
|
abandon();
|
|
1701
1779
|
};
|
|
1702
1780
|
const failRootRender = err => {
|
|
@@ -1855,7 +1933,7 @@ function renderToStream(code, options = {}) {
|
|
|
1855
1933
|
plugins: options.plugins,
|
|
1856
1934
|
onData: payload => sink.data(payload),
|
|
1857
1935
|
onDone,
|
|
1858
|
-
onError:
|
|
1936
|
+
onError: err => reportFailure(err, "serialize")
|
|
1859
1937
|
});
|
|
1860
1938
|
let rootAssetsSerialized = false;
|
|
1861
1939
|
const serializeRootAssets = () => {
|
|
@@ -2210,7 +2288,11 @@ function renderToStream(code, options = {}) {
|
|
|
2210
2288
|
context.trace = undefined;
|
|
2211
2289
|
if (onAbort) signal.removeEventListener("abort", onAbort);
|
|
2212
2290
|
if (endEdges) endEdges();
|
|
2213
|
-
|
|
2291
|
+
try {
|
|
2292
|
+
d();
|
|
2293
|
+
} catch (err) {
|
|
2294
|
+
reportFailure(err, "failed");
|
|
2295
|
+
}
|
|
2214
2296
|
};
|
|
2215
2297
|
rootOwner = claimRenderRoot(context);
|
|
2216
2298
|
if (requestEvent) claimEventRender(requestEvent, context);
|
|
@@ -2720,11 +2802,19 @@ function createLiveHoles(sink, scoped, settled, errorScope) {
|
|
|
2720
2802
|
}
|
|
2721
2803
|
function rowOps(last, rows) {
|
|
2722
2804
|
const ops = [];
|
|
2723
|
-
|
|
2724
|
-
|
|
2805
|
+
const html = [];
|
|
2806
|
+
for (let i = 0; i < rows.length; i++) if (i >= last.length || rows[i] !== last[i]) {
|
|
2807
|
+
const patch = i < last.length ? rowPatch(last[i], rows[i]) : null;
|
|
2808
|
+
ops.push(patch ? [i, patch.p] : [i, rows[i]]);
|
|
2809
|
+
html.push(rows[i]);
|
|
2810
|
+
}
|
|
2811
|
+
if (ops.length >= rows.length) return null;
|
|
2812
|
+
return Object.defineProperty({
|
|
2725
2813
|
n: rows.length,
|
|
2726
2814
|
r: ops
|
|
2727
|
-
}
|
|
2815
|
+
}, ROW_HTML, {
|
|
2816
|
+
value: html
|
|
2817
|
+
});
|
|
2728
2818
|
}
|
|
2729
2819
|
function resolveHoleValue(hole) {
|
|
2730
2820
|
const result = {
|
|
@@ -3090,6 +3180,71 @@ function attrNames(text) {
|
|
|
3090
3180
|
while (m = re.exec(text)) names.push(m[1]);
|
|
3091
3181
|
return names;
|
|
3092
3182
|
}
|
|
3183
|
+
const ROW_HTML = Symbol.for("solid.rowHtml");
|
|
3184
|
+
const ROW_TOKEN = /<(\/?)([a-zA-Z][^\s/>]*)((?:[^>"']|"[^"]*"|'[^']*')*)>|<!--([\s\S]*?)-->/g;
|
|
3185
|
+
const ROW_VOID = /^(?:area|base|br|col|embed|hr|img|input|link|meta|source|track|wbr)$/i;
|
|
3186
|
+
const ROW_FOREIGN = /^(?:svg|math)$/i;
|
|
3187
|
+
const ROW_RAW = /^(?:script|style|textarea|title|template)$/i;
|
|
3188
|
+
const ROW_KEY = /\s_key(?:="[^"]*")?(?![^\s/])/;
|
|
3189
|
+
const rowKey = attrs => (ROW_KEY.exec(attrs) || [""])[0];
|
|
3190
|
+
const ROW_ENTITY = /&(?:amp|lt|gt|quot|#39);/g;
|
|
3191
|
+
const ROW_ENTITIES = {
|
|
3192
|
+
"&": "&",
|
|
3193
|
+
"<": "<",
|
|
3194
|
+
">": ">",
|
|
3195
|
+
""": '"',
|
|
3196
|
+
"'": "'"
|
|
3197
|
+
};
|
|
3198
|
+
function rowText(text) {
|
|
3199
|
+
if (!text.includes("&")) return text;
|
|
3200
|
+
if (text.replace(ROW_ENTITY, "").includes("&")) return null;
|
|
3201
|
+
return text.replace(ROW_ENTITY, e => ROW_ENTITIES[e]);
|
|
3202
|
+
}
|
|
3203
|
+
const ROW_HASH_SEED = 0x811c9dc5;
|
|
3204
|
+
function rowPatch(a, b) {
|
|
3205
|
+
const ra = new RegExp(ROW_TOKEN);
|
|
3206
|
+
const rb = new RegExp(ROW_TOKEN);
|
|
3207
|
+
const p = [];
|
|
3208
|
+
const stack = [[-1, 0, false]];
|
|
3209
|
+
let el = -1;
|
|
3210
|
+
let h = ROW_HASH_SEED;
|
|
3211
|
+
let ia = 0;
|
|
3212
|
+
let ib = 0;
|
|
3213
|
+
for (;;) {
|
|
3214
|
+
const ma = ra.exec(a);
|
|
3215
|
+
const mb = rb.exec(b);
|
|
3216
|
+
const ta = a.slice(ia, ma ? ma.index : a.length);
|
|
3217
|
+
const tb = b.slice(ib, mb ? mb.index : b.length);
|
|
3218
|
+
const top = stack[stack.length - 1];
|
|
3219
|
+
if (ta !== tb) {
|
|
3220
|
+
const text = rowText(tb);
|
|
3221
|
+
if (text === null) return null;
|
|
3222
|
+
p.push([top[0], top[1], text]);
|
|
3223
|
+
}
|
|
3224
|
+
if (!ma || !mb) return !ma && !mb ? {
|
|
3225
|
+
p,
|
|
3226
|
+
h: h >>> 0
|
|
3227
|
+
} : null;
|
|
3228
|
+
ia = ra.lastIndex;
|
|
3229
|
+
ib = rb.lastIndex;
|
|
3230
|
+
if (ma[4] !== undefined || mb[4] !== undefined) {
|
|
3231
|
+
if (ma[4] !== mb[4]) return null;
|
|
3232
|
+
top[1]++;
|
|
3233
|
+
} else if (ma[1] !== mb[1] || ma[2] !== mb[2]) return null;else if (ROW_RAW.test(ma[2])) return null;else if (ma[1]) {
|
|
3234
|
+
if (stack.length === 1) return null;
|
|
3235
|
+
stack.pop();
|
|
3236
|
+
} else {
|
|
3237
|
+
el++;
|
|
3238
|
+
top[1]++;
|
|
3239
|
+
const foreign = top[2] || ROW_FOREIGN.test(ma[2]);
|
|
3240
|
+
if (ma[3] !== mb[3]) {
|
|
3241
|
+
if (foreign || rowKey(ma[3]) !== rowKey(mb[3])) return null;
|
|
3242
|
+
p.push([el, mb[3].replace(/\/$/, "")]);
|
|
3243
|
+
}
|
|
3244
|
+
if (!ROW_VOID.test(ma[2]) && !ma[3].endsWith("/")) stack.push([el, 0, foreign]);
|
|
3245
|
+
}
|
|
3246
|
+
}
|
|
3247
|
+
}
|
|
3093
3248
|
function ssr(t) {
|
|
3094
3249
|
const len = arguments.length;
|
|
3095
3250
|
if (len === 1) return {
|
|
@@ -4564,4 +4719,4 @@ function httpHeader(name, value, options) {
|
|
|
4564
4719
|
}
|
|
4565
4720
|
}
|
|
4566
4721
|
|
|
4567
|
-
export { ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, HydrationScript, MathMLElements, NULL_BODY_STATUSES, Namespaces, Portal, RESPONSE_HEADER_VALUE_LIMIT, REVALIDATE_ALL, REVALIDATE_HEADER, RawTextElements, RequestContext, ResponseEnvelope, SAFE_ERROR, SVGElements, VoidElements, notSup as acquireAsset, notSup as addEvent, applyRef, notSup as assign, claimElement, claimElementTree, notSup as className, clearFlashCookie, clientOnly, commitEventResponse, commitResponseStub, composeMiddleware, configureServerErrors, createLiveHoles, createRequestEvent, createResponseStub, createSSRResponse, notSup as delegateEvents, dispatchAsInteraction, dynamic, notSup as dynamicProperty, effect, escape, generateHydrationScript, notSup as getDelegatedRoot, getExpectedRedirectStatus, getHydrationKey, getHydrationWriter, notSup as getNextElement, notSup as getNextMarker, notSup as getNextMatch, getRequestEvent, getServerFunctionMetadata, getServerFunctionRPC, getTraceContext, hasFlashCookie, hasServerLinkState, httpHeader, httpStatus, notSup as hydrate, notSup as insert, isDev, isHref, isResponseEnvelope, isSafeError, isServer, isServerFunction, markSafeError, memo, parseCookieHeader, notSup as readShallow, redirect, notSup as ref, notSup as registerDelegatedContainer, notSup as registerDelegatedRoot, registerElementClaim, reload, notSup as render, renderToStream, renderToString, reportRequestFailure, resolveSSRNode, resolveSSRSelectValues, respond, notSup as runHydrationEvents, serializeCookie, notSup as setAttribute, notSup as setAttributeNS, setLinkClaim, notSup as setProperty, notSup as setStyleProperty, notSup as spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrElementAttribute, ssrGroup, ssrHydrationKey, ssrLinkClaim, ssrSelectValues, ssrStyle, ssrStyleProperties, ssrStyleProperty, notSup as style, takeHydrationValue, notSup as template, notSup as unregisterDelegatedContainer, notSup as unregisterDelegatedRoot, useHead };
|
|
4722
|
+
export { ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, HydrationScript, MathMLElements, NULL_BODY_STATUSES, Namespaces, Portal, RESPONSE_HEADER_VALUE_LIMIT, REVALIDATE_ALL, REVALIDATE_HEADER, RawTextElements, RequestContext, ResponseEnvelope, SAFE_ERROR, SVGElements, VoidElements, notSup as acquireAsset, notSup as addEvent, applyRef, notSup as assign, claimElement, claimElementTree, notSup as className, clearFlashCookie, clientOnly, commitEventResponse, commitResponseStub, composeMiddleware, configureServerErrors, createLiveHoles, createRequestEvent, createResponseStub, createSSRResponse, notSup as delegateEvents, dispatchAsInteraction, dynamic, notSup as dynamicProperty, effect, escape, generateHydrationScript, notSup as getDelegatedRoot, getExpectedRedirectStatus, getHydrationKey, getHydrationWriter, notSup as getNextElement, notSup as getNextMarker, notSup as getNextMatch, getRequestEvent, getServerFunctionMetadata, getServerFunctionRPC, getTraceContext, hasFlashCookie, hasServerLinkState, httpHeader, httpStatus, notSup as hydrate, notSup as insert, isDev, isHref, isResponseEnvelope, isSafeError, isServer, isServerFunction, markSafeError, memo, parseCookieHeader, notSup as readShallow, redirect, notSup as ref, notSup as registerDelegatedContainer, notSup as registerDelegatedRoot, registerElementClaim, reload, notSup as render, renderToStream, renderToString, reportRequestFailure, resolveSSRNode, resolveSSRSelectValues, respond, notSup as runHydrationEvents, serializeCookie, notSup as setAttribute, notSup as setAttributeNS, setLinkClaim, notSup as setProperty, notSup as setStatefulProperty, notSup as setStyleProperty, notSup as spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrElementAttribute, ssrGroup, ssrHydrationKey, ssrLinkClaim, ssrSelectValues, ssrStyle, ssrStyleProperties, ssrStyleProperty, notSup as style, takeHydrationValue, notSup as template, notSup as unregisterDelegatedContainer, notSup as unregisterDelegatedRoot, useHead };
|