@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.cjs
CHANGED
|
@@ -67,11 +67,12 @@ const syncOptions = {
|
|
|
67
67
|
sync: true
|
|
68
68
|
};
|
|
69
69
|
function effect(fn, effectFn, options) {
|
|
70
|
-
|
|
70
|
+
const nodeOptions = options ? {
|
|
71
71
|
sync: true,
|
|
72
72
|
...options,
|
|
73
73
|
transparent: !options.scope
|
|
74
|
-
} : transparentOptions
|
|
74
|
+
} : transparentOptions;
|
|
75
|
+
solidJs.createRenderEffect(fn, effectFn, nodeOptions);
|
|
75
76
|
}
|
|
76
77
|
function memo(fn) {
|
|
77
78
|
return solidJs.createMemo(() => fn(), syncOptions);
|
|
@@ -405,12 +406,24 @@ function classifyHeadTag(desc) {
|
|
|
405
406
|
resource: false
|
|
406
407
|
};
|
|
407
408
|
}
|
|
409
|
+
function qualifierValue(name, value) {
|
|
410
|
+
if (value == null || value === false) return null;
|
|
411
|
+
if (name === "imagesrcset" || name === "imagesizes") return typeof value === "string" && value !== "" ? value : null;
|
|
412
|
+
const v = value === true ? "" : String(value);
|
|
413
|
+
if (name === "as") return asciiLowerCase(v);
|
|
414
|
+
if (name !== "crossorigin") return v;
|
|
415
|
+
return v.length === 15 && v.toLowerCase() === "use-credentials" ? v.toLowerCase() : "anonymous";
|
|
416
|
+
}
|
|
417
|
+
function asciiLowerCase(value) {
|
|
418
|
+
return value.replace(/[A-Z]/g, c => String.fromCharCode(c.charCodeAt(0) + 32));
|
|
419
|
+
}
|
|
408
420
|
function resourceIdentity(tag, props) {
|
|
409
|
-
|
|
421
|
+
const url = String(props.href || props.src || "");
|
|
422
|
+
let id = "res:" + tag + ":" + (props.rel || "") + ":" + url.length + ":" + url;
|
|
410
423
|
for (let i = 0; i < RESOURCE_QUALIFIERS.length; i++) {
|
|
411
424
|
const q = RESOURCE_QUALIFIERS[i];
|
|
412
|
-
const value = props[q];
|
|
413
|
-
if (value
|
|
425
|
+
const value = qualifierValue(q, props[q]);
|
|
426
|
+
if (value !== null) id += ":" + q + "=" + value.length + ":" + value;
|
|
414
427
|
}
|
|
415
428
|
return id;
|
|
416
429
|
}
|
|
@@ -484,12 +497,20 @@ function resolveAssets(moduleUrl, manifest) {
|
|
|
484
497
|
if (e.preloads) {
|
|
485
498
|
for (let i = 0; i < e.preloads.length; i++) {
|
|
486
499
|
const link = e.preloads[i];
|
|
487
|
-
|
|
500
|
+
const href = link && typeof link.href === "string" && link.href;
|
|
501
|
+
const srcset = link && typeof link.imagesrcset === "string" && link.imagesrcset;
|
|
502
|
+
if (!href && !srcset) continue;
|
|
488
503
|
if (!preloads) preloads = [];
|
|
489
|
-
preloads.push({
|
|
504
|
+
if (href) preloads.push({
|
|
490
505
|
...link,
|
|
491
|
-
href: joinAssetPath(base,
|
|
492
|
-
});
|
|
506
|
+
href: joinAssetPath(base, href)
|
|
507
|
+
});else {
|
|
508
|
+
const {
|
|
509
|
+
href: bad,
|
|
510
|
+
...rest
|
|
511
|
+
} = link;
|
|
512
|
+
preloads.push(rest);
|
|
513
|
+
}
|
|
493
514
|
}
|
|
494
515
|
}
|
|
495
516
|
if (e.imports) for (let i = 0; i < e.imports.length; i++) walk(e.imports[i]);
|
|
@@ -621,9 +642,13 @@ function isCssUrl(url) {
|
|
|
621
642
|
const q = url.search(/[?#]/);
|
|
622
643
|
return (q === -1 ? url : url.slice(0, q)).endsWith(".css");
|
|
623
644
|
}
|
|
624
|
-
const
|
|
645
|
+
const RESPONSIVE_ATTRIBUTES = ["imagesrcset", "imagesizes"];
|
|
646
|
+
function isSetAttr(value) {
|
|
647
|
+
return value != null && value !== false && value !== "";
|
|
648
|
+
}
|
|
649
|
+
const PRELOAD_LINK_ATTRIBUTES = ["type", "crossorigin", "integrity", "referrerpolicy", "fetchpriority", "media", "imagesrcset", "imagesizes"];
|
|
625
650
|
function registerPreloadLink(tracking, headRegistry, link, nonce) {
|
|
626
|
-
if (!link || typeof link !== "object"
|
|
651
|
+
if (!link || typeof link !== "object") {
|
|
627
652
|
return null;
|
|
628
653
|
}
|
|
629
654
|
if (typeof link.as !== "string") {
|
|
@@ -644,13 +669,35 @@ function registerPreloadLink(tracking, headRegistry, link, nonce) {
|
|
|
644
669
|
default:
|
|
645
670
|
return null;
|
|
646
671
|
}
|
|
672
|
+
const responsive = as === "image";
|
|
673
|
+
let srcset = null;
|
|
674
|
+
let sizes = null;
|
|
675
|
+
if (responsive) {
|
|
676
|
+
for (const name of RESPONSIVE_ATTRIBUTES) {
|
|
677
|
+
const value = link[name];
|
|
678
|
+
if (!isSetAttr(value)) continue;
|
|
679
|
+
if (typeof value !== "string") {
|
|
680
|
+
continue;
|
|
681
|
+
}
|
|
682
|
+
if (name === "imagesrcset") srcset = value;else sizes = value;
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
const href = typeof link.href === "string" && link.href ? link.href : null;
|
|
686
|
+
if (!href && !srcset) {
|
|
687
|
+
return null;
|
|
688
|
+
}
|
|
647
689
|
const props = {
|
|
648
|
-
rel: "preload"
|
|
649
|
-
href: link.href,
|
|
650
|
-
as
|
|
690
|
+
rel: "preload"
|
|
651
691
|
};
|
|
692
|
+
if (href) props.href = href;
|
|
693
|
+
props.as = as;
|
|
652
694
|
for (let i = 0; i < PRELOAD_LINK_ATTRIBUTES.length; i++) {
|
|
653
695
|
const name = PRELOAD_LINK_ATTRIBUTES[i];
|
|
696
|
+
if (RESPONSIVE_ATTRIBUTES.indexOf(name) !== -1) {
|
|
697
|
+
const value = name === "imagesrcset" ? srcset : sizes;
|
|
698
|
+
if (value !== null) props[name] = value;
|
|
699
|
+
continue;
|
|
700
|
+
}
|
|
654
701
|
const value = link[name];
|
|
655
702
|
if (value == null || value === false) continue;
|
|
656
703
|
props[name] = value === true ? "" : String(value);
|
|
@@ -1027,9 +1074,6 @@ function scriptNonce(nonce) {
|
|
|
1027
1074
|
function styleNonce(nonce) {
|
|
1028
1075
|
return destinationNonce(nonce, "style");
|
|
1029
1076
|
}
|
|
1030
|
-
function asciiLowerCase(value) {
|
|
1031
|
-
return value.replace(/[A-Z]/g, c => String.fromCharCode(c.charCodeAt(0) + 32));
|
|
1032
|
-
}
|
|
1033
1077
|
function hasNonceProp(props) {
|
|
1034
1078
|
for (const name in props) if (name.length === 5 && asciiLowerCase(name) === "nonce" && props[name] != null) return true;
|
|
1035
1079
|
return false;
|
|
@@ -1190,6 +1234,7 @@ function renderToStream(code, options = {}) {
|
|
|
1190
1234
|
onHead
|
|
1191
1235
|
} = options;
|
|
1192
1236
|
const nonce = normalizeNonce(options.nonce);
|
|
1237
|
+
const requestEvent = peekRequestEvent();
|
|
1193
1238
|
let dispose;
|
|
1194
1239
|
let dead = false;
|
|
1195
1240
|
const abandon = () => {
|
|
@@ -1291,6 +1336,7 @@ function renderToStream(code, options = {}) {
|
|
|
1291
1336
|
};
|
|
1292
1337
|
const onDone = () => {
|
|
1293
1338
|
writeTasks();
|
|
1339
|
+
lastBlockingSize = blockingPromises.size;
|
|
1294
1340
|
doShell();
|
|
1295
1341
|
onCompleteAll && onCompleteAll({
|
|
1296
1342
|
write(v) {
|
|
@@ -1680,9 +1726,9 @@ function renderToStream(code, options = {}) {
|
|
|
1680
1726
|
function doShell() {
|
|
1681
1727
|
if (shellCompleted) return;
|
|
1682
1728
|
solidJs.sharedConfig.context = context;
|
|
1683
|
-
|
|
1729
|
+
if (blockingPromises.size !== lastBlockingSize) return;
|
|
1684
1730
|
if (!resolveRootHoles()) return;
|
|
1685
|
-
if (blockingPromises.size !==
|
|
1731
|
+
if (blockingPromises.size !== lastBlockingSize) return;
|
|
1686
1732
|
if (!headShellReady(headRegistry, p => blockingPromises.add(p))) return;
|
|
1687
1733
|
headStyles = new Set();
|
|
1688
1734
|
for (const url of tracking.emittedAssets) {
|
|
@@ -1710,7 +1756,7 @@ function renderToStream(code, options = {}) {
|
|
|
1710
1756
|
let lastBlockingSize = -1;
|
|
1711
1757
|
let lastRegistrySize = -1;
|
|
1712
1758
|
let drainTurn = 0;
|
|
1713
|
-
const scheduleFlush = fn => {
|
|
1759
|
+
const scheduleFlush = (fn, awaited) => {
|
|
1714
1760
|
const attempt = () => {
|
|
1715
1761
|
flushStubBatch();
|
|
1716
1762
|
if (registry.size !== lastRegistrySize || drainTurn++ < MIN_DRAIN_TURNS) {
|
|
@@ -1721,8 +1767,8 @@ function renderToStream(code, options = {}) {
|
|
|
1721
1767
|
}
|
|
1722
1768
|
fn();
|
|
1723
1769
|
};
|
|
1724
|
-
const progressed =
|
|
1725
|
-
lastBlockingSize =
|
|
1770
|
+
const progressed = awaited !== lastBlockingSize;
|
|
1771
|
+
lastBlockingSize = awaited;
|
|
1726
1772
|
lastRegistrySize = -1;
|
|
1727
1773
|
drainTurn = 0;
|
|
1728
1774
|
progressed ? queue(attempt) : setTimeout(attempt);
|
|
@@ -1739,7 +1785,7 @@ function renderToStream(code, options = {}) {
|
|
|
1739
1785
|
let resolve;
|
|
1740
1786
|
const p = new Promise(r => resolve = r);
|
|
1741
1787
|
function flush() {
|
|
1742
|
-
allSettled(blockingPromises).then(
|
|
1788
|
+
allSettled(blockingPromises).then(awaited => {
|
|
1743
1789
|
scheduleFlush(() => {
|
|
1744
1790
|
if (dead) return resolve();
|
|
1745
1791
|
try {
|
|
@@ -1777,7 +1823,7 @@ function renderToStream(code, options = {}) {
|
|
|
1777
1823
|
dispose();
|
|
1778
1824
|
writable.end();
|
|
1779
1825
|
} else flushEnd();
|
|
1780
|
-
});
|
|
1826
|
+
}, awaited);
|
|
1781
1827
|
});
|
|
1782
1828
|
}
|
|
1783
1829
|
flush();
|
|
@@ -1785,8 +1831,12 @@ function renderToStream(code, options = {}) {
|
|
|
1785
1831
|
};
|
|
1786
1832
|
return {
|
|
1787
1833
|
then(onFulfilled, onRejected) {
|
|
1834
|
+
const freezeHead = () => {
|
|
1835
|
+
if (requestEvent && requestEvent.response) commitResponseStub(requestEvent.response);
|
|
1836
|
+
};
|
|
1788
1837
|
const p = new Promise(resolve => {
|
|
1789
1838
|
function complete() {
|
|
1839
|
+
freezeHead();
|
|
1790
1840
|
dispose();
|
|
1791
1841
|
resolve(tmp);
|
|
1792
1842
|
}
|
|
@@ -1798,17 +1848,16 @@ function renderToStream(code, options = {}) {
|
|
|
1798
1848
|
};
|
|
1799
1849
|
} else onCompleteAll = complete;
|
|
1800
1850
|
function flush() {
|
|
1801
|
-
allSettled(blockingPromises).then(
|
|
1851
|
+
allSettled(blockingPromises).then(awaited => {
|
|
1802
1852
|
scheduleFlush(() => {
|
|
1803
1853
|
try {
|
|
1804
|
-
|
|
1805
|
-
if (!resolveRootHoles() || blockingPromises.size !== blockersBefore || !headShellReady(headRegistry, p => blockingPromises.add(p))) return flush();
|
|
1854
|
+
if (blockingPromises.size !== lastBlockingSize || !resolveRootHoles() || blockingPromises.size !== lastBlockingSize || !headShellReady(headRegistry, p => blockingPromises.add(p))) return flush();
|
|
1806
1855
|
} catch (err) {
|
|
1807
1856
|
failRender(err);
|
|
1808
1857
|
return resolve(tmp);
|
|
1809
1858
|
}
|
|
1810
1859
|
queue(flushEnd);
|
|
1811
|
-
});
|
|
1860
|
+
}, awaited);
|
|
1812
1861
|
});
|
|
1813
1862
|
}
|
|
1814
1863
|
flush();
|
|
@@ -1818,7 +1867,7 @@ function renderToStream(code, options = {}) {
|
|
|
1818
1867
|
pipe(w) {
|
|
1819
1868
|
claimConsumer("pipe");
|
|
1820
1869
|
function flush() {
|
|
1821
|
-
allSettled(blockingPromises).then(
|
|
1870
|
+
allSettled(blockingPromises).then(awaited => {
|
|
1822
1871
|
scheduleFlush(() => {
|
|
1823
1872
|
if (dead) return;
|
|
1824
1873
|
try {
|
|
@@ -1840,7 +1889,7 @@ function renderToStream(code, options = {}) {
|
|
|
1840
1889
|
dispose();
|
|
1841
1890
|
writable.end();
|
|
1842
1891
|
} else flushEnd();
|
|
1843
|
-
});
|
|
1892
|
+
}, awaited);
|
|
1844
1893
|
});
|
|
1845
1894
|
}
|
|
1846
1895
|
flush();
|
|
@@ -2549,17 +2598,22 @@ function ssrStyleProperty(name, value) {
|
|
|
2549
2598
|
}
|
|
2550
2599
|
function ssrElement(tag, props, children, needsId) {
|
|
2551
2600
|
const hk = needsId ? ssrHydrationKey() : "";
|
|
2552
|
-
if (
|
|
2601
|
+
if (typeof props === "function") props = props();
|
|
2602
|
+
if (props == null) props = {};
|
|
2553
2603
|
const skipChildren = VOID_ELEMENTS.test(tag);
|
|
2554
2604
|
const keys = Object.keys(props);
|
|
2555
2605
|
let result = `<${tag}${hk} `;
|
|
2556
2606
|
for (let i = 0; i < keys.length; i++) {
|
|
2557
2607
|
const prop = keys[i];
|
|
2608
|
+
const value = props[prop];
|
|
2609
|
+
if (tag === "textarea" && (prop === "value" || prop === "defaultValue")) {
|
|
2610
|
+
if (value !== null) children = escape(value);
|
|
2611
|
+
continue;
|
|
2612
|
+
}
|
|
2558
2613
|
if (ChildProperties.has(prop)) {
|
|
2559
2614
|
if (children === undefined && !skipChildren) children = tag === "script" || tag === "style" || prop === "innerHTML" ? props[prop] : escape(props[prop]);
|
|
2560
2615
|
continue;
|
|
2561
2616
|
}
|
|
2562
|
-
const value = props[prop];
|
|
2563
2617
|
if (prop === "style") {
|
|
2564
2618
|
result += `style="${ssrStyle(value)}"`;
|
|
2565
2619
|
} else if (prop === "class") {
|
|
@@ -2838,7 +2892,7 @@ function allSettled(promises) {
|
|
|
2838
2892
|
let size = promises.size;
|
|
2839
2893
|
return Promise.allSettled(promises).then(() => {
|
|
2840
2894
|
if (promises.size !== size) return allSettled(promises);
|
|
2841
|
-
return;
|
|
2895
|
+
return size;
|
|
2842
2896
|
});
|
|
2843
2897
|
}
|
|
2844
2898
|
function assembleDocument(html, emittedAssets, preloadLinks, inlineStyles, scripts, nonce, headTags, onHead) {
|
|
@@ -3107,6 +3161,10 @@ const RequestContext = Symbol.for("solid.RequestContext");
|
|
|
3107
3161
|
function getRequestEvent() {
|
|
3108
3162
|
return globalThis[RequestContext] ? globalThis[RequestContext].getStore() || solidJs.sharedConfig.context && solidJs.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;
|
|
3109
3163
|
}
|
|
3164
|
+
function peekRequestEvent() {
|
|
3165
|
+
const store = globalThis[RequestContext];
|
|
3166
|
+
return store ? store.getStore() : undefined;
|
|
3167
|
+
}
|
|
3110
3168
|
function createResponseStub() {
|
|
3111
3169
|
return {
|
|
3112
3170
|
status: undefined,
|
|
@@ -3323,13 +3381,25 @@ function notSup() {
|
|
|
3323
3381
|
setContainerTraceResolver(solidJs.getProjectionTrace);
|
|
3324
3382
|
const isServer = true;
|
|
3325
3383
|
const isDev = false;
|
|
3326
|
-
function dynamic(source) {
|
|
3384
|
+
function dynamic(source, options) {
|
|
3327
3385
|
const cached = solidJs.createMemo(source, {
|
|
3328
3386
|
serialize: false
|
|
3329
3387
|
});
|
|
3388
|
+
const deferStream = !!options?.deferStream;
|
|
3330
3389
|
return props => {
|
|
3390
|
+
const ctx = solidJs.sharedConfig.context;
|
|
3391
|
+
let gated = !deferStream || !ctx?.async;
|
|
3331
3392
|
return solidJs.createMemo(() => {
|
|
3332
|
-
|
|
3393
|
+
let c;
|
|
3394
|
+
try {
|
|
3395
|
+
c = cached();
|
|
3396
|
+
} catch (err) {
|
|
3397
|
+
if (!gated && err instanceof solidJs.NotReadyError) {
|
|
3398
|
+
gated = true;
|
|
3399
|
+
ctx.block(Promise.resolve(err.source).then(() => {}, () => {}));
|
|
3400
|
+
}
|
|
3401
|
+
throw err;
|
|
3402
|
+
}
|
|
3333
3403
|
if (c) {
|
|
3334
3404
|
if (typeof c === "function") return c(props);
|
|
3335
3405
|
if (typeof c === "string") {
|