@solidjs/web 2.0.0-rc.17 → 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 +179 -18
- package/dist/server.js +174 -18
- package/dist/server.observe.js +174 -18
- package/frames/dist/server.dev.js +75 -40
- package/frames/dist/server.js +75 -40
- package/frames/dist/server.observe.js +75 -40
- 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/server.dev.js +245 -8
- package/server-functions/dist/server.js +245 -8
- package/server-functions/dist/server.observe.js +245 -8
- 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/server.d.ts +19 -3
- package/types/server-functions/shared.d.ts +9 -0
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) + ";";
|
|
@@ -3032,11 +3115,19 @@ function createLiveHoles(sink, scoped, settled, errorScope) {
|
|
|
3032
3115
|
}
|
|
3033
3116
|
function rowOps(last, rows) {
|
|
3034
3117
|
const ops = [];
|
|
3035
|
-
|
|
3036
|
-
|
|
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({
|
|
3037
3126
|
n: rows.length,
|
|
3038
3127
|
r: ops
|
|
3039
|
-
}
|
|
3128
|
+
}, ROW_HTML, {
|
|
3129
|
+
value: html
|
|
3130
|
+
});
|
|
3040
3131
|
}
|
|
3041
3132
|
function resolveHoleValue(hole) {
|
|
3042
3133
|
const result = {
|
|
@@ -3405,6 +3496,76 @@ function attrNames(text) {
|
|
|
3405
3496
|
while (m = re.exec(text)) names.push(m[1]);
|
|
3406
3497
|
return names;
|
|
3407
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
|
+
}
|
|
3408
3569
|
function ssr(t) {
|
|
3409
3570
|
const len = arguments.length;
|
|
3410
3571
|
if (len === 1) return {
|
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) + ";";
|
|
@@ -2719,11 +2802,19 @@ function createLiveHoles(sink, scoped, settled, errorScope) {
|
|
|
2719
2802
|
}
|
|
2720
2803
|
function rowOps(last, rows) {
|
|
2721
2804
|
const ops = [];
|
|
2722
|
-
|
|
2723
|
-
|
|
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({
|
|
2724
2813
|
n: rows.length,
|
|
2725
2814
|
r: ops
|
|
2726
|
-
}
|
|
2815
|
+
}, ROW_HTML, {
|
|
2816
|
+
value: html
|
|
2817
|
+
});
|
|
2727
2818
|
}
|
|
2728
2819
|
function resolveHoleValue(hole) {
|
|
2729
2820
|
const result = {
|
|
@@ -3089,6 +3180,71 @@ function attrNames(text) {
|
|
|
3089
3180
|
while (m = re.exec(text)) names.push(m[1]);
|
|
3090
3181
|
return names;
|
|
3091
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
|
+
}
|
|
3092
3248
|
function ssr(t) {
|
|
3093
3249
|
const len = arguments.length;
|
|
3094
3250
|
if (len === 1) return {
|
package/dist/server.observe.js
CHANGED
|
@@ -2,7 +2,7 @@ import { createRenderEffect, createMemo, OBSERVE, getOwner, createRoot, $PROXY,
|
|
|
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 = {
|
|
@@ -531,15 +531,92 @@ function resolveSerializerPlugins(customPlugins) {
|
|
|
531
531
|
}
|
|
532
532
|
|
|
533
533
|
const defaultDisabledFeatures = () => Feature.AggregateError | Feature.BigIntTypedArray;
|
|
534
|
-
const serializeOnlyDisabledFeatures = serializeErrorStacks => (
|
|
534
|
+
const serializeOnlyDisabledFeatures = serializeErrorStacks => (process.env.NODE_ENV === "development" ) ? 0 : Feature.ErrorPrototypeStack;
|
|
535
535
|
const HYDRATION_GLOBAL = "_$HY.r";
|
|
536
|
-
function
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
536
|
+
function createKeyedSerializer(serialize, onError, onDone) {
|
|
537
|
+
const cancels = new Set();
|
|
538
|
+
let pendingWrites = 0;
|
|
539
|
+
let flushed = false;
|
|
540
|
+
let done = false;
|
|
541
|
+
let closed = false;
|
|
542
|
+
const maybeDone = () => {
|
|
543
|
+
if (flushed && pendingWrites === 0 && !done) {
|
|
544
|
+
done = true;
|
|
545
|
+
onDone && onDone();
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
return {
|
|
549
|
+
write(key, value) {
|
|
550
|
+
if (flushed) return;
|
|
551
|
+
pendingWrites++;
|
|
552
|
+
let settled = false;
|
|
553
|
+
let failed = false;
|
|
554
|
+
let started = false;
|
|
555
|
+
let cancel = null;
|
|
556
|
+
const settle = () => {
|
|
557
|
+
if (settled) return;
|
|
558
|
+
settled = true;
|
|
559
|
+
if (cancel) cancels.delete(cancel);
|
|
560
|
+
pendingWrites--;
|
|
561
|
+
maybeDone();
|
|
562
|
+
};
|
|
563
|
+
let stream;
|
|
564
|
+
try {
|
|
565
|
+
stream = serialize(key, value, {
|
|
566
|
+
onError: onError && (err => {
|
|
567
|
+
failed = true;
|
|
568
|
+
onError(err);
|
|
569
|
+
if (cancel) {
|
|
570
|
+
cancel();
|
|
571
|
+
settle();
|
|
572
|
+
}
|
|
573
|
+
}),
|
|
574
|
+
onDone: settle
|
|
575
|
+
}, initial => {
|
|
576
|
+
if (initial) started = true;
|
|
577
|
+
return !closed;
|
|
578
|
+
});
|
|
579
|
+
} catch (err) {
|
|
580
|
+
settle();
|
|
581
|
+
throw err;
|
|
582
|
+
}
|
|
583
|
+
if (settled) return;
|
|
584
|
+
if (closed || failed) {
|
|
585
|
+
stream();
|
|
586
|
+
settle();
|
|
587
|
+
return;
|
|
588
|
+
}
|
|
589
|
+
cancel = stream;
|
|
590
|
+
cancels.add(cancel);
|
|
591
|
+
},
|
|
592
|
+
flush() {
|
|
593
|
+
flushed = true;
|
|
594
|
+
maybeDone();
|
|
595
|
+
},
|
|
596
|
+
close() {
|
|
597
|
+
closed = flushed = true;
|
|
598
|
+
for (const cancel of cancels) cancel();
|
|
599
|
+
cancels.clear();
|
|
600
|
+
if (!done) {
|
|
601
|
+
done = true;
|
|
602
|
+
onDone && onDone();
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
};
|
|
542
606
|
}
|
|
607
|
+
const KEY_ESCAPES = {
|
|
608
|
+
'"': '\\"',
|
|
609
|
+
"\\": "\\\\",
|
|
610
|
+
"\n": "\\n",
|
|
611
|
+
"\r": "\\r",
|
|
612
|
+
"\b": "\\b",
|
|
613
|
+
"\t": "\\t",
|
|
614
|
+
"\f": "\\f",
|
|
615
|
+
"<": "\\x3C",
|
|
616
|
+
"\u2028": "\\u2028",
|
|
617
|
+
"\u2029": "\\u2029"
|
|
618
|
+
};
|
|
619
|
+
const serializeKey = key => ("" + key).replace(/["\\\n\r\b\t\f<\u2028\u2029]/g, c => KEY_ESCAPES[c]);
|
|
543
620
|
function createHydrationSerializer({
|
|
544
621
|
onData,
|
|
545
622
|
onDone,
|
|
@@ -547,14 +624,20 @@ function createHydrationSerializer({
|
|
|
547
624
|
onError,
|
|
548
625
|
plugins
|
|
549
626
|
}) {
|
|
550
|
-
|
|
627
|
+
const resolvedPlugins = resolveSerializerPlugins(plugins);
|
|
628
|
+
const disabledFeatures = defaultDisabledFeatures() | serializeOnlyDisabledFeatures();
|
|
629
|
+
const refs = new Map();
|
|
630
|
+
return createKeyedSerializer((key, value, callbacks, live) => crossSerializeStream(value, {
|
|
551
631
|
scopeId,
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
632
|
+
refs,
|
|
633
|
+
plugins: resolvedPlugins,
|
|
634
|
+
disabledFeatures,
|
|
635
|
+
onSerialize(data, initial) {
|
|
636
|
+
if (!live(initial)) return;
|
|
637
|
+
onData(initial ? HYDRATION_GLOBAL + '["' + serializeKey(key) + '"]=' + data : data);
|
|
638
|
+
},
|
|
639
|
+
...callbacks
|
|
640
|
+
}), onError, onDone);
|
|
558
641
|
}
|
|
559
642
|
function getLocalHeaderScript(id) {
|
|
560
643
|
return getCrossReferenceHeader(id) + ";";
|
|
@@ -2852,11 +2935,19 @@ function createLiveHoles(sink, scoped, settled, errorScope) {
|
|
|
2852
2935
|
}
|
|
2853
2936
|
function rowOps(last, rows) {
|
|
2854
2937
|
const ops = [];
|
|
2855
|
-
|
|
2856
|
-
|
|
2938
|
+
const html = [];
|
|
2939
|
+
for (let i = 0; i < rows.length; i++) if (i >= last.length || rows[i] !== last[i]) {
|
|
2940
|
+
const patch = i < last.length ? rowPatch(last[i], rows[i]) : null;
|
|
2941
|
+
ops.push(patch ? [i, patch.p] : [i, rows[i]]);
|
|
2942
|
+
html.push(rows[i]);
|
|
2943
|
+
}
|
|
2944
|
+
if (ops.length >= rows.length) return null;
|
|
2945
|
+
return Object.defineProperty({
|
|
2857
2946
|
n: rows.length,
|
|
2858
2947
|
r: ops
|
|
2859
|
-
}
|
|
2948
|
+
}, ROW_HTML, {
|
|
2949
|
+
value: html
|
|
2950
|
+
});
|
|
2860
2951
|
}
|
|
2861
2952
|
function resolveHoleValue(hole) {
|
|
2862
2953
|
const result = {
|
|
@@ -3222,6 +3313,71 @@ function attrNames(text) {
|
|
|
3222
3313
|
while (m = re.exec(text)) names.push(m[1]);
|
|
3223
3314
|
return names;
|
|
3224
3315
|
}
|
|
3316
|
+
const ROW_HTML = Symbol.for("solid.rowHtml");
|
|
3317
|
+
const ROW_TOKEN = /<(\/?)([a-zA-Z][^\s/>]*)((?:[^>"']|"[^"]*"|'[^']*')*)>|<!--([\s\S]*?)-->/g;
|
|
3318
|
+
const ROW_VOID = /^(?:area|base|br|col|embed|hr|img|input|link|meta|source|track|wbr)$/i;
|
|
3319
|
+
const ROW_FOREIGN = /^(?:svg|math)$/i;
|
|
3320
|
+
const ROW_RAW = /^(?:script|style|textarea|title|template)$/i;
|
|
3321
|
+
const ROW_KEY = /\s_key(?:="[^"]*")?(?![^\s/])/;
|
|
3322
|
+
const rowKey = attrs => (ROW_KEY.exec(attrs) || [""])[0];
|
|
3323
|
+
const ROW_ENTITY = /&(?:amp|lt|gt|quot|#39);/g;
|
|
3324
|
+
const ROW_ENTITIES = {
|
|
3325
|
+
"&": "&",
|
|
3326
|
+
"<": "<",
|
|
3327
|
+
">": ">",
|
|
3328
|
+
""": '"',
|
|
3329
|
+
"'": "'"
|
|
3330
|
+
};
|
|
3331
|
+
function rowText(text) {
|
|
3332
|
+
if (!text.includes("&")) return text;
|
|
3333
|
+
if (text.replace(ROW_ENTITY, "").includes("&")) return null;
|
|
3334
|
+
return text.replace(ROW_ENTITY, e => ROW_ENTITIES[e]);
|
|
3335
|
+
}
|
|
3336
|
+
const ROW_HASH_SEED = 0x811c9dc5;
|
|
3337
|
+
function rowPatch(a, b) {
|
|
3338
|
+
const ra = new RegExp(ROW_TOKEN);
|
|
3339
|
+
const rb = new RegExp(ROW_TOKEN);
|
|
3340
|
+
const p = [];
|
|
3341
|
+
const stack = [[-1, 0, false]];
|
|
3342
|
+
let el = -1;
|
|
3343
|
+
let h = ROW_HASH_SEED;
|
|
3344
|
+
let ia = 0;
|
|
3345
|
+
let ib = 0;
|
|
3346
|
+
for (;;) {
|
|
3347
|
+
const ma = ra.exec(a);
|
|
3348
|
+
const mb = rb.exec(b);
|
|
3349
|
+
const ta = a.slice(ia, ma ? ma.index : a.length);
|
|
3350
|
+
const tb = b.slice(ib, mb ? mb.index : b.length);
|
|
3351
|
+
const top = stack[stack.length - 1];
|
|
3352
|
+
if (ta !== tb) {
|
|
3353
|
+
const text = rowText(tb);
|
|
3354
|
+
if (text === null) return null;
|
|
3355
|
+
p.push([top[0], top[1], text]);
|
|
3356
|
+
}
|
|
3357
|
+
if (!ma || !mb) return !ma && !mb ? {
|
|
3358
|
+
p,
|
|
3359
|
+
h: h >>> 0
|
|
3360
|
+
} : null;
|
|
3361
|
+
ia = ra.lastIndex;
|
|
3362
|
+
ib = rb.lastIndex;
|
|
3363
|
+
if (ma[4] !== undefined || mb[4] !== undefined) {
|
|
3364
|
+
if (ma[4] !== mb[4]) return null;
|
|
3365
|
+
top[1]++;
|
|
3366
|
+
} 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]) {
|
|
3367
|
+
if (stack.length === 1) return null;
|
|
3368
|
+
stack.pop();
|
|
3369
|
+
} else {
|
|
3370
|
+
el++;
|
|
3371
|
+
top[1]++;
|
|
3372
|
+
const foreign = top[2] || ROW_FOREIGN.test(ma[2]);
|
|
3373
|
+
if (ma[3] !== mb[3]) {
|
|
3374
|
+
if (foreign || rowKey(ma[3]) !== rowKey(mb[3])) return null;
|
|
3375
|
+
p.push([el, mb[3].replace(/\/$/, "")]);
|
|
3376
|
+
}
|
|
3377
|
+
if (!ROW_VOID.test(ma[2]) && !ma[3].endsWith("/")) stack.push([el, 0, foreign]);
|
|
3378
|
+
}
|
|
3379
|
+
}
|
|
3380
|
+
}
|
|
3225
3381
|
function ssr(t) {
|
|
3226
3382
|
const len = arguments.length;
|
|
3227
3383
|
if (len === 1) return {
|