@solidjs/web 2.0.0-rc.6 → 2.0.0-rc.7
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.cjs +105 -35
- package/dist/server.dev.cjs +3794 -0
- package/dist/server.dev.js +3627 -0
- package/dist/server.js +106 -36
- package/dist/web.cjs +39 -385
- package/dist/{dev.cjs → web.dev.cjs} +91 -396
- package/dist/{dev.js → web.dev.js} +93 -393
- package/dist/web.js +41 -382
- package/frames/dist/client.cjs +11 -3
- package/frames/dist/client.dev.cjs +11 -3
- package/frames/dist/client.dev.js +11 -3
- package/frames/dist/client.js +11 -3
- package/frames/dist/server.cjs +234 -32
- package/frames/dist/server.dev.cjs +4584 -0
- package/frames/dist/server.dev.js +4571 -0
- package/frames/dist/server.js +234 -32
- package/frames/package.json +10 -0
- package/package.json +78 -8
- package/serialization/dist/decode.cjs +18 -4
- package/serialization/dist/decode.js +18 -4
- package/serialization/dist/serialization.cjs +18 -4
- package/serialization/dist/serialization.js +18 -4
- package/server-functions/dist/client.cjs +13 -14
- package/server-functions/dist/client.js +13 -14
- package/server-functions/dist/server.cjs +331 -83
- package/server-functions/dist/server.dev.cjs +338 -82
- package/server-functions/dist/server.dev.js +338 -82
- package/server-functions/dist/server.js +331 -83
- package/types/client.d.ts +0 -3
- package/types/frames/frame-client.d.ts +1 -1
- package/types/head.d.ts +3 -0
- package/types/index.d.ts +18 -7
- package/types/index.server.d.ts +31 -9
- package/types/render.d.ts +3 -1
- package/types/server-functions/flash.d.ts +12 -3
- package/types/server-functions/server.d.ts +27 -3
- package/types/server-mock.d.ts +43 -7
- package/types/server.d.ts +47 -5
- package/types-cjs/client.d.cts +0 -3
- package/types-cjs/frames/frame-client.d.cts +1 -1
- package/types-cjs/head.d.cts +3 -0
- package/types-cjs/index.d.cts +18 -7
- package/types-cjs/index.server.d.cts +31 -9
- package/types-cjs/render.d.cts +3 -1
- package/types-cjs/server-functions/flash.d.cts +12 -3
- package/types-cjs/server-functions/server.d.cts +27 -3
- package/types-cjs/server-mock.d.cts +43 -7
- package/types-cjs/server.d.cts +47 -5
- package/types/patch-driver.d.ts +0 -3
- package/types-cjs/patch-driver.d.cts +0 -3
package/dist/server.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createRenderEffect, createMemo, sharedConfig, createRoot, inServerComponentScope, getOwner, ssrHandleError, creationStamp, runWithOwner, createComponent, omit, getNextChildId, onCleanup, getProjectionTrace } from 'solid-js';
|
|
1
|
+
import { createRenderEffect, createMemo, sharedConfig, createRoot, inServerComponentScope, getOwner, ssrHandleError, creationStamp, runWithOwner, createComponent, omit, getNextChildId, NotReadyError, onCleanup, getProjectionTrace } from 'solid-js';
|
|
2
2
|
export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, merge as mergeProps, ssrScope as scope, sharedConfig, untrack } from 'solid-js';
|
|
3
3
|
import { Feature, createStream, Serializer, getCrossReferenceHeader } from 'seroval';
|
|
4
4
|
import { AbortSignalPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin } from 'seroval-plugins/web';
|
|
@@ -66,11 +66,12 @@ const syncOptions = {
|
|
|
66
66
|
sync: true
|
|
67
67
|
};
|
|
68
68
|
function effect(fn, effectFn, options) {
|
|
69
|
-
|
|
69
|
+
const nodeOptions = options ? {
|
|
70
70
|
sync: true,
|
|
71
71
|
...options,
|
|
72
72
|
transparent: !options.scope
|
|
73
|
-
} : transparentOptions
|
|
73
|
+
} : transparentOptions;
|
|
74
|
+
createRenderEffect(fn, effectFn, nodeOptions);
|
|
74
75
|
}
|
|
75
76
|
function memo(fn) {
|
|
76
77
|
return createMemo(() => fn(), syncOptions);
|
|
@@ -404,12 +405,24 @@ function classifyHeadTag(desc) {
|
|
|
404
405
|
resource: false
|
|
405
406
|
};
|
|
406
407
|
}
|
|
408
|
+
function qualifierValue(name, value) {
|
|
409
|
+
if (value == null || value === false) return null;
|
|
410
|
+
if (name === "imagesrcset" || name === "imagesizes") return typeof value === "string" && value !== "" ? value : null;
|
|
411
|
+
const v = value === true ? "" : String(value);
|
|
412
|
+
if (name === "as") return asciiLowerCase(v);
|
|
413
|
+
if (name !== "crossorigin") return v;
|
|
414
|
+
return v.length === 15 && v.toLowerCase() === "use-credentials" ? v.toLowerCase() : "anonymous";
|
|
415
|
+
}
|
|
416
|
+
function asciiLowerCase(value) {
|
|
417
|
+
return value.replace(/[A-Z]/g, c => String.fromCharCode(c.charCodeAt(0) + 32));
|
|
418
|
+
}
|
|
407
419
|
function resourceIdentity(tag, props) {
|
|
408
|
-
|
|
420
|
+
const url = String(props.href || props.src || "");
|
|
421
|
+
let id = "res:" + tag + ":" + (props.rel || "") + ":" + url.length + ":" + url;
|
|
409
422
|
for (let i = 0; i < RESOURCE_QUALIFIERS.length; i++) {
|
|
410
423
|
const q = RESOURCE_QUALIFIERS[i];
|
|
411
|
-
const value = props[q];
|
|
412
|
-
if (value
|
|
424
|
+
const value = qualifierValue(q, props[q]);
|
|
425
|
+
if (value !== null) id += ":" + q + "=" + value.length + ":" + value;
|
|
413
426
|
}
|
|
414
427
|
return id;
|
|
415
428
|
}
|
|
@@ -483,12 +496,20 @@ function resolveAssets(moduleUrl, manifest) {
|
|
|
483
496
|
if (e.preloads) {
|
|
484
497
|
for (let i = 0; i < e.preloads.length; i++) {
|
|
485
498
|
const link = e.preloads[i];
|
|
486
|
-
|
|
499
|
+
const href = link && typeof link.href === "string" && link.href;
|
|
500
|
+
const srcset = link && typeof link.imagesrcset === "string" && link.imagesrcset;
|
|
501
|
+
if (!href && !srcset) continue;
|
|
487
502
|
if (!preloads) preloads = [];
|
|
488
|
-
preloads.push({
|
|
503
|
+
if (href) preloads.push({
|
|
489
504
|
...link,
|
|
490
|
-
href: joinAssetPath(base,
|
|
491
|
-
});
|
|
505
|
+
href: joinAssetPath(base, href)
|
|
506
|
+
});else {
|
|
507
|
+
const {
|
|
508
|
+
href: bad,
|
|
509
|
+
...rest
|
|
510
|
+
} = link;
|
|
511
|
+
preloads.push(rest);
|
|
512
|
+
}
|
|
492
513
|
}
|
|
493
514
|
}
|
|
494
515
|
if (e.imports) for (let i = 0; i < e.imports.length; i++) walk(e.imports[i]);
|
|
@@ -620,9 +641,13 @@ function isCssUrl(url) {
|
|
|
620
641
|
const q = url.search(/[?#]/);
|
|
621
642
|
return (q === -1 ? url : url.slice(0, q)).endsWith(".css");
|
|
622
643
|
}
|
|
623
|
-
const
|
|
644
|
+
const RESPONSIVE_ATTRIBUTES = ["imagesrcset", "imagesizes"];
|
|
645
|
+
function isSetAttr(value) {
|
|
646
|
+
return value != null && value !== false && value !== "";
|
|
647
|
+
}
|
|
648
|
+
const PRELOAD_LINK_ATTRIBUTES = ["type", "crossorigin", "integrity", "referrerpolicy", "fetchpriority", "media", "imagesrcset", "imagesizes"];
|
|
624
649
|
function registerPreloadLink(tracking, headRegistry, link, nonce) {
|
|
625
|
-
if (!link || typeof link !== "object"
|
|
650
|
+
if (!link || typeof link !== "object") {
|
|
626
651
|
return null;
|
|
627
652
|
}
|
|
628
653
|
if (typeof link.as !== "string") {
|
|
@@ -643,13 +668,35 @@ function registerPreloadLink(tracking, headRegistry, link, nonce) {
|
|
|
643
668
|
default:
|
|
644
669
|
return null;
|
|
645
670
|
}
|
|
671
|
+
const responsive = as === "image";
|
|
672
|
+
let srcset = null;
|
|
673
|
+
let sizes = null;
|
|
674
|
+
if (responsive) {
|
|
675
|
+
for (const name of RESPONSIVE_ATTRIBUTES) {
|
|
676
|
+
const value = link[name];
|
|
677
|
+
if (!isSetAttr(value)) continue;
|
|
678
|
+
if (typeof value !== "string") {
|
|
679
|
+
continue;
|
|
680
|
+
}
|
|
681
|
+
if (name === "imagesrcset") srcset = value;else sizes = value;
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
const href = typeof link.href === "string" && link.href ? link.href : null;
|
|
685
|
+
if (!href && !srcset) {
|
|
686
|
+
return null;
|
|
687
|
+
}
|
|
646
688
|
const props = {
|
|
647
|
-
rel: "preload"
|
|
648
|
-
href: link.href,
|
|
649
|
-
as
|
|
689
|
+
rel: "preload"
|
|
650
690
|
};
|
|
691
|
+
if (href) props.href = href;
|
|
692
|
+
props.as = as;
|
|
651
693
|
for (let i = 0; i < PRELOAD_LINK_ATTRIBUTES.length; i++) {
|
|
652
694
|
const name = PRELOAD_LINK_ATTRIBUTES[i];
|
|
695
|
+
if (RESPONSIVE_ATTRIBUTES.indexOf(name) !== -1) {
|
|
696
|
+
const value = name === "imagesrcset" ? srcset : sizes;
|
|
697
|
+
if (value !== null) props[name] = value;
|
|
698
|
+
continue;
|
|
699
|
+
}
|
|
653
700
|
const value = link[name];
|
|
654
701
|
if (value == null || value === false) continue;
|
|
655
702
|
props[name] = value === true ? "" : String(value);
|
|
@@ -1026,9 +1073,6 @@ function scriptNonce(nonce) {
|
|
|
1026
1073
|
function styleNonce(nonce) {
|
|
1027
1074
|
return destinationNonce(nonce, "style");
|
|
1028
1075
|
}
|
|
1029
|
-
function asciiLowerCase(value) {
|
|
1030
|
-
return value.replace(/[A-Z]/g, c => String.fromCharCode(c.charCodeAt(0) + 32));
|
|
1031
|
-
}
|
|
1032
1076
|
function hasNonceProp(props) {
|
|
1033
1077
|
for (const name in props) if (name.length === 5 && asciiLowerCase(name) === "nonce" && props[name] != null) return true;
|
|
1034
1078
|
return false;
|
|
@@ -1189,6 +1233,7 @@ function renderToStream(code, options = {}) {
|
|
|
1189
1233
|
onHead
|
|
1190
1234
|
} = options;
|
|
1191
1235
|
const nonce = normalizeNonce(options.nonce);
|
|
1236
|
+
const requestEvent = peekRequestEvent();
|
|
1192
1237
|
let dispose;
|
|
1193
1238
|
let dead = false;
|
|
1194
1239
|
const abandon = () => {
|
|
@@ -1290,6 +1335,7 @@ function renderToStream(code, options = {}) {
|
|
|
1290
1335
|
};
|
|
1291
1336
|
const onDone = () => {
|
|
1292
1337
|
writeTasks();
|
|
1338
|
+
lastBlockingSize = blockingPromises.size;
|
|
1293
1339
|
doShell();
|
|
1294
1340
|
onCompleteAll && onCompleteAll({
|
|
1295
1341
|
write(v) {
|
|
@@ -1679,9 +1725,9 @@ function renderToStream(code, options = {}) {
|
|
|
1679
1725
|
function doShell() {
|
|
1680
1726
|
if (shellCompleted) return;
|
|
1681
1727
|
sharedConfig.context = context;
|
|
1682
|
-
|
|
1728
|
+
if (blockingPromises.size !== lastBlockingSize) return;
|
|
1683
1729
|
if (!resolveRootHoles()) return;
|
|
1684
|
-
if (blockingPromises.size !==
|
|
1730
|
+
if (blockingPromises.size !== lastBlockingSize) return;
|
|
1685
1731
|
if (!headShellReady(headRegistry, p => blockingPromises.add(p))) return;
|
|
1686
1732
|
headStyles = new Set();
|
|
1687
1733
|
for (const url of tracking.emittedAssets) {
|
|
@@ -1709,7 +1755,7 @@ function renderToStream(code, options = {}) {
|
|
|
1709
1755
|
let lastBlockingSize = -1;
|
|
1710
1756
|
let lastRegistrySize = -1;
|
|
1711
1757
|
let drainTurn = 0;
|
|
1712
|
-
const scheduleFlush = fn => {
|
|
1758
|
+
const scheduleFlush = (fn, awaited) => {
|
|
1713
1759
|
const attempt = () => {
|
|
1714
1760
|
flushStubBatch();
|
|
1715
1761
|
if (registry.size !== lastRegistrySize || drainTurn++ < MIN_DRAIN_TURNS) {
|
|
@@ -1720,8 +1766,8 @@ function renderToStream(code, options = {}) {
|
|
|
1720
1766
|
}
|
|
1721
1767
|
fn();
|
|
1722
1768
|
};
|
|
1723
|
-
const progressed =
|
|
1724
|
-
lastBlockingSize =
|
|
1769
|
+
const progressed = awaited !== lastBlockingSize;
|
|
1770
|
+
lastBlockingSize = awaited;
|
|
1725
1771
|
lastRegistrySize = -1;
|
|
1726
1772
|
drainTurn = 0;
|
|
1727
1773
|
progressed ? queue(attempt) : setTimeout(attempt);
|
|
@@ -1738,7 +1784,7 @@ function renderToStream(code, options = {}) {
|
|
|
1738
1784
|
let resolve;
|
|
1739
1785
|
const p = new Promise(r => resolve = r);
|
|
1740
1786
|
function flush() {
|
|
1741
|
-
allSettled(blockingPromises).then(
|
|
1787
|
+
allSettled(blockingPromises).then(awaited => {
|
|
1742
1788
|
scheduleFlush(() => {
|
|
1743
1789
|
if (dead) return resolve();
|
|
1744
1790
|
try {
|
|
@@ -1776,7 +1822,7 @@ function renderToStream(code, options = {}) {
|
|
|
1776
1822
|
dispose();
|
|
1777
1823
|
writable.end();
|
|
1778
1824
|
} else flushEnd();
|
|
1779
|
-
});
|
|
1825
|
+
}, awaited);
|
|
1780
1826
|
});
|
|
1781
1827
|
}
|
|
1782
1828
|
flush();
|
|
@@ -1784,8 +1830,12 @@ function renderToStream(code, options = {}) {
|
|
|
1784
1830
|
};
|
|
1785
1831
|
return {
|
|
1786
1832
|
then(onFulfilled, onRejected) {
|
|
1833
|
+
const freezeHead = () => {
|
|
1834
|
+
if (requestEvent && requestEvent.response) commitResponseStub(requestEvent.response);
|
|
1835
|
+
};
|
|
1787
1836
|
const p = new Promise(resolve => {
|
|
1788
1837
|
function complete() {
|
|
1838
|
+
freezeHead();
|
|
1789
1839
|
dispose();
|
|
1790
1840
|
resolve(tmp);
|
|
1791
1841
|
}
|
|
@@ -1797,17 +1847,16 @@ function renderToStream(code, options = {}) {
|
|
|
1797
1847
|
};
|
|
1798
1848
|
} else onCompleteAll = complete;
|
|
1799
1849
|
function flush() {
|
|
1800
|
-
allSettled(blockingPromises).then(
|
|
1850
|
+
allSettled(blockingPromises).then(awaited => {
|
|
1801
1851
|
scheduleFlush(() => {
|
|
1802
1852
|
try {
|
|
1803
|
-
|
|
1804
|
-
if (!resolveRootHoles() || blockingPromises.size !== blockersBefore || !headShellReady(headRegistry, p => blockingPromises.add(p))) return flush();
|
|
1853
|
+
if (blockingPromises.size !== lastBlockingSize || !resolveRootHoles() || blockingPromises.size !== lastBlockingSize || !headShellReady(headRegistry, p => blockingPromises.add(p))) return flush();
|
|
1805
1854
|
} catch (err) {
|
|
1806
1855
|
failRender(err);
|
|
1807
1856
|
return resolve(tmp);
|
|
1808
1857
|
}
|
|
1809
1858
|
queue(flushEnd);
|
|
1810
|
-
});
|
|
1859
|
+
}, awaited);
|
|
1811
1860
|
});
|
|
1812
1861
|
}
|
|
1813
1862
|
flush();
|
|
@@ -1817,7 +1866,7 @@ function renderToStream(code, options = {}) {
|
|
|
1817
1866
|
pipe(w) {
|
|
1818
1867
|
claimConsumer("pipe");
|
|
1819
1868
|
function flush() {
|
|
1820
|
-
allSettled(blockingPromises).then(
|
|
1869
|
+
allSettled(blockingPromises).then(awaited => {
|
|
1821
1870
|
scheduleFlush(() => {
|
|
1822
1871
|
if (dead) return;
|
|
1823
1872
|
try {
|
|
@@ -1839,7 +1888,7 @@ function renderToStream(code, options = {}) {
|
|
|
1839
1888
|
dispose();
|
|
1840
1889
|
writable.end();
|
|
1841
1890
|
} else flushEnd();
|
|
1842
|
-
});
|
|
1891
|
+
}, awaited);
|
|
1843
1892
|
});
|
|
1844
1893
|
}
|
|
1845
1894
|
flush();
|
|
@@ -2548,17 +2597,22 @@ function ssrStyleProperty(name, value) {
|
|
|
2548
2597
|
}
|
|
2549
2598
|
function ssrElement(tag, props, children, needsId) {
|
|
2550
2599
|
const hk = needsId ? ssrHydrationKey() : "";
|
|
2551
|
-
if (
|
|
2600
|
+
if (typeof props === "function") props = props();
|
|
2601
|
+
if (props == null) props = {};
|
|
2552
2602
|
const skipChildren = VOID_ELEMENTS.test(tag);
|
|
2553
2603
|
const keys = Object.keys(props);
|
|
2554
2604
|
let result = `<${tag}${hk} `;
|
|
2555
2605
|
for (let i = 0; i < keys.length; i++) {
|
|
2556
2606
|
const prop = keys[i];
|
|
2607
|
+
const value = props[prop];
|
|
2608
|
+
if (tag === "textarea" && (prop === "value" || prop === "defaultValue")) {
|
|
2609
|
+
if (value !== null) children = escape(value);
|
|
2610
|
+
continue;
|
|
2611
|
+
}
|
|
2557
2612
|
if (ChildProperties.has(prop)) {
|
|
2558
2613
|
if (children === undefined && !skipChildren) children = tag === "script" || tag === "style" || prop === "innerHTML" ? props[prop] : escape(props[prop]);
|
|
2559
2614
|
continue;
|
|
2560
2615
|
}
|
|
2561
|
-
const value = props[prop];
|
|
2562
2616
|
if (prop === "style") {
|
|
2563
2617
|
result += `style="${ssrStyle(value)}"`;
|
|
2564
2618
|
} else if (prop === "class") {
|
|
@@ -2837,7 +2891,7 @@ function allSettled(promises) {
|
|
|
2837
2891
|
let size = promises.size;
|
|
2838
2892
|
return Promise.allSettled(promises).then(() => {
|
|
2839
2893
|
if (promises.size !== size) return allSettled(promises);
|
|
2840
|
-
return;
|
|
2894
|
+
return size;
|
|
2841
2895
|
});
|
|
2842
2896
|
}
|
|
2843
2897
|
function assembleDocument(html, emittedAssets, preloadLinks, inlineStyles, scripts, nonce, headTags, onHead) {
|
|
@@ -3106,6 +3160,10 @@ const RequestContext = Symbol.for("solid.RequestContext");
|
|
|
3106
3160
|
function getRequestEvent() {
|
|
3107
3161
|
return globalThis[RequestContext] ? globalThis[RequestContext].getStore() || sharedConfig.context && sharedConfig.context.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.") : undefined;
|
|
3108
3162
|
}
|
|
3163
|
+
function peekRequestEvent() {
|
|
3164
|
+
const store = globalThis[RequestContext];
|
|
3165
|
+
return store ? store.getStore() : undefined;
|
|
3166
|
+
}
|
|
3109
3167
|
function createResponseStub() {
|
|
3110
3168
|
return {
|
|
3111
3169
|
status: undefined,
|
|
@@ -3322,13 +3380,25 @@ function notSup() {
|
|
|
3322
3380
|
setContainerTraceResolver(getProjectionTrace);
|
|
3323
3381
|
const isServer = true;
|
|
3324
3382
|
const isDev = false;
|
|
3325
|
-
function dynamic(source) {
|
|
3383
|
+
function dynamic(source, options) {
|
|
3326
3384
|
const cached = createMemo(source, {
|
|
3327
3385
|
serialize: false
|
|
3328
3386
|
});
|
|
3387
|
+
const deferStream = !!options?.deferStream;
|
|
3329
3388
|
return props => {
|
|
3389
|
+
const ctx = sharedConfig.context;
|
|
3390
|
+
let gated = !deferStream || !ctx?.async;
|
|
3330
3391
|
return createMemo(() => {
|
|
3331
|
-
|
|
3392
|
+
let c;
|
|
3393
|
+
try {
|
|
3394
|
+
c = cached();
|
|
3395
|
+
} catch (err) {
|
|
3396
|
+
if (!gated && err instanceof NotReadyError) {
|
|
3397
|
+
gated = true;
|
|
3398
|
+
ctx.block(Promise.resolve(err.source).then(() => {}, () => {}));
|
|
3399
|
+
}
|
|
3400
|
+
throw err;
|
|
3401
|
+
}
|
|
3332
3402
|
if (c) {
|
|
3333
3403
|
if (typeof c === "function") return c(props);
|
|
3334
3404
|
if (typeof c === "string") {
|