@decocms/tanstack 8.1.0-next.0 → 8.5.1
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/README.md +79 -0
- package/dist/draft.d.ts +33 -0
- package/dist/draft.d.ts.map +1 -0
- package/dist/draft.js +41 -0
- package/dist/draft.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/react/DecoDocument.d.ts +61 -0
- package/dist/react/DecoDocument.d.ts.map +1 -0
- package/dist/react/DecoDocument.js +96 -0
- package/dist/react/DecoDocument.js.map +1 -0
- package/dist/react/Image.d.ts +96 -0
- package/dist/react/Image.d.ts.map +1 -0
- package/dist/react/Image.js +79 -0
- package/dist/react/Image.js.map +1 -0
- package/dist/react/index.d.ts +7 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +7 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/pageValues.d.ts +10 -0
- package/dist/react/pageValues.d.ts.map +1 -0
- package/dist/react/pageValues.js +29 -0
- package/dist/react/pageValues.js.map +1 -0
- package/dist/react/scripts.d.ts +14 -0
- package/dist/react/scripts.d.ts.map +1 -0
- package/dist/react/scripts.js +96 -0
- package/dist/react/scripts.js.map +1 -0
- package/dist/router/index.d.ts +38 -0
- package/dist/router/index.d.ts.map +1 -0
- package/dist/router/index.js +60 -0
- package/dist/router/index.js.map +1 -0
- package/dist/scope/browser.d.ts +11 -0
- package/dist/scope/browser.d.ts.map +1 -0
- package/dist/scope/browser.js +8 -0
- package/dist/scope/browser.js.map +1 -0
- package/dist/scope/server.d.ts +13 -0
- package/dist/scope/server.d.ts.map +1 -0
- package/dist/scope/server.js +26 -0
- package/dist/scope/server.js.map +1 -0
- package/dist/server/index.d.ts +27 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +31 -0
- package/dist/server/index.js.map +1 -0
- package/dist/shared.d.ts +26 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +26 -0
- package/dist/shared.js.map +1 -0
- package/dist/start/index.d.ts +9 -0
- package/dist/start/index.d.ts.map +1 -0
- package/dist/start/index.js +33 -0
- package/dist/start/index.js.map +1 -0
- package/dist/studio.d.ts +28 -0
- package/dist/studio.d.ts.map +1 -0
- package/dist/studio.js +53 -0
- package/dist/studio.js.map +1 -0
- package/dist/vite/index.d.ts +15 -0
- package/dist/vite/index.d.ts.map +1 -0
- package/dist/vite/index.js +95 -0
- package/dist/vite/index.js.map +1 -0
- package/dist/worker/cacheProfiles.d.ts +43 -0
- package/dist/worker/cacheProfiles.d.ts.map +1 -0
- package/dist/worker/cacheProfiles.js +162 -0
- package/dist/worker/cacheProfiles.js.map +1 -0
- package/dist/worker/cookies.d.ts +20 -0
- package/dist/worker/cookies.d.ts.map +1 -0
- package/dist/worker/cookies.js +69 -0
- package/dist/worker/cookies.js.map +1 -0
- package/dist/worker/drafts.d.ts +59 -0
- package/dist/worker/drafts.d.ts.map +1 -0
- package/dist/worker/drafts.js +140 -0
- package/dist/worker/drafts.js.map +1 -0
- package/dist/worker/index.d.ts +111 -0
- package/dist/worker/index.d.ts.map +1 -0
- package/dist/worker/index.js +618 -0
- package/dist/worker/index.js.map +1 -0
- package/dist/worker/security.d.ts +14 -0
- package/dist/worker/security.d.ts.map +1 -0
- package/dist/worker/security.js +48 -0
- package/dist/worker/security.js.map +1 -0
- package/dist/worker/segment.d.ts +21 -0
- package/dist/worker/segment.d.ts.map +1 -0
- package/dist/worker/segment.js +43 -0
- package/dist/worker/segment.js.map +1 -0
- package/package.json +85 -37
- package/src/draft.ts +43 -0
- package/src/index.ts +8 -61
- package/src/react/DecoDocument.tsx +234 -0
- package/src/react/Image.tsx +213 -0
- package/src/react/index.ts +24 -0
- package/src/react/pageValues.ts +35 -0
- package/src/react/scripts.ts +98 -0
- package/src/router/index.ts +80 -0
- package/src/scope/browser.ts +18 -0
- package/src/scope/server.ts +37 -0
- package/src/server/index.ts +43 -0
- package/src/shared.ts +29 -0
- package/src/start/index.ts +31 -0
- package/src/studio.ts +52 -0
- package/src/vite/index.ts +105 -0
- package/src/worker/cacheProfiles.ts +180 -0
- package/src/worker/cookies.ts +65 -0
- package/src/worker/drafts.ts +157 -0
- package/src/worker/index.ts +784 -0
- package/src/worker/security.ts +63 -0
- package/src/worker/segment.ts +49 -0
- package/src/__conformance__/observability.test.ts +0 -221
- package/src/cms/kvBlockSource.test.ts +0 -82
- package/src/cms/kvBlockSource.ts +0 -68
- package/src/daemon/auth.ts +0 -204
- package/src/daemon/fs.ts +0 -238
- package/src/daemon/index.ts +0 -8
- package/src/daemon/middleware.ts +0 -156
- package/src/daemon/tunnel.ts +0 -129
- package/src/daemon/volumes.ts +0 -366
- package/src/daemon/watch.ts +0 -272
- package/src/hooks/CdnSegmentMarker.tsx +0 -38
- package/src/hooks/DecoPageRenderer.tsx +0 -750
- package/src/hooks/DecoRootLayout.tsx +0 -192
- package/src/hooks/DraftPreviewIndicator.test.tsx +0 -60
- package/src/hooks/DraftPreviewIndicator.tsx +0 -64
- package/src/hooks/NavigationProgress.test.tsx +0 -58
- package/src/hooks/NavigationProgress.tsx +0 -63
- package/src/hooks/PreviewProviders.test.tsx +0 -42
- package/src/hooks/PreviewProviders.tsx +0 -45
- package/src/hooks/StableOutlet.tsx +0 -30
- package/src/hooks/deferredObserverTiming.test.tsx +0 -91
- package/src/hooks/index.ts +0 -10
- package/src/routes/adminRoutes.test.ts +0 -99
- package/src/routes/adminRoutes.ts +0 -153
- package/src/routes/cmsRoute.test.ts +0 -267
- package/src/routes/cmsRoute.ts +0 -1053
- package/src/routes/components.tsx +0 -57
- package/src/routes/index.ts +0 -24
- package/src/routes/pageUrl.test.ts +0 -70
- package/src/routes/pageUrl.ts +0 -55
- package/src/routes/withSiteGlobals.test.ts +0 -243
- package/src/routes/withSiteGlobals.ts +0 -243
- package/src/sdk/backgroundTasks.test.ts +0 -68
- package/src/sdk/backgroundTasks.ts +0 -38
- package/src/sdk/cdnSegment.test.ts +0 -67
- package/src/sdk/cdnSegment.ts +0 -71
- package/src/sdk/cookiePassthrough.ts +0 -58
- package/src/sdk/createInvoke.ts +0 -77
- package/src/sdk/deferredSectionLoader.test.ts +0 -94
- package/src/sdk/deferredSectionLoader.ts +0 -46
- package/src/sdk/draft.test.ts +0 -341
- package/src/sdk/draft.ts +0 -277
- package/src/sdk/draftShared.ts +0 -16
- package/src/sdk/kvHydration.test.ts +0 -371
- package/src/sdk/kvHydration.ts +0 -263
- package/src/sdk/kvRedirects.test.ts +0 -132
- package/src/sdk/kvRedirects.ts +0 -125
- package/src/sdk/outboundHeaders.test.ts +0 -113
- package/src/sdk/outboundHeaders.ts +0 -81
- package/src/sdk/router.ts +0 -101
- package/src/sdk/serverFnFetch.ts +0 -59
- package/src/sdk/speculationRules.test.ts +0 -82
- package/src/sdk/speculationRules.ts +0 -136
- package/src/sdk/startEntry.ts +0 -31
- package/src/sdk/useHydrated.ts +0 -19
- package/src/sdk/workerEntry.cacheStorage.test.ts +0 -147
- package/src/sdk/workerEntry.test.ts +0 -1033
- package/src/sdk/workerEntry.trackingCache.test.ts +0 -328
- package/src/sdk/workerEntry.ts +0 -3154
- package/src/setupFastDeploy.ts +0 -13
- package/src/v8/__conformance__/delivery.test.ts +0 -100
- package/src/v8/binding.ts +0 -70
- package/src/v8/kvLoader.bundle.test.ts +0 -42
- package/src/v8/kvLoader.test.ts +0 -74
- package/src/v8/kvLoader.ts +0 -43
- package/src/vite/plugin-scaffold-gen.test.js +0 -106
- package/src/vite/plugin.js +0 -1022
- package/src/vite/plugin.test.js +0 -238
- package/src/vite/plugin.test.ts +0 -176
- package/tsconfig.json +0 -7
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pageValues.js","sourceRoot":"","sources":["../../src/react/pageValues.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAC;AAO3C,+FAA+F;AAC/F,MAAM,UAAU,UAAU;IACxB,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,MAAM,CAAC,GAAG,MAA4C,CAAC;QACvD,MAAM,IAAI,GAAG,CAAC,CAAS,EAAE,EAAE,CACzB,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,CAAY,CAAC,CAAC,CAAC,SAAS,CAAC;QACzE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC;IAChE,CAAC;IACD,MAAM,KAAK,GAAG,YAAY,EAAE,CAAC;IAC7B,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AACzD,CAAC;AAED,kGAAkG;AAClG,MAAM,UAAU,aAAa,CAAC,MAAkB;IAC9C,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,wFAAwF;IACxF,MAAM,OAAO,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC1E,IAAI,MAAM,CAAC,IAAI;QAAE,KAAK,CAAC,IAAI,CAAC,UAAU,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC7E,IAAI,MAAM,CAAC,KAAK;QAAE,KAAK,CAAC,IAAI,CAAC,UAAU,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAChF,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The inline scripts every Deco page runs, as v7's root layout ran them
|
|
3
|
+
* (`@decocms/tanstack` 7.x `DecoRootLayout`, `@decocms/blocks` 7.x
|
|
4
|
+
* `sdk/analytics.ts`).
|
|
5
|
+
*/
|
|
6
|
+
/** The `DECO.events` bus. Events dispatched before a subscriber exists are replayed to it. */
|
|
7
|
+
export declare function eventsBootstrap(account: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* Dispatches the events elements declare with `data-event`, on view or click.
|
|
10
|
+
* It waits for a Speculation Rules prerender to activate before observing.
|
|
11
|
+
*/
|
|
12
|
+
export declare const DATA_EVENT_OBSERVER = "\n(function() {\n function start() {\n function dispatch(event) {\n if (window.dataLayer) {\n window.dataLayer.push({ event: event.name, ...event.params });\n }\n if (window.DECO && window.DECO.events) {\n window.DECO.events.dispatch(event);\n }\n }\n\n function getEvent(el) {\n var raw = el.getAttribute(\"data-event\");\n if (!raw) return null;\n try { return JSON.parse(decodeURIComponent(raw)); } catch(e) { return null; }\n }\n\n var viewObserver = new IntersectionObserver(function(entries) {\n entries.forEach(function(entry) {\n if (entry.isIntersecting) {\n var event = getEvent(entry.target);\n if (event) dispatch(event);\n viewObserver.unobserve(entry.target);\n }\n });\n }, { threshold: 0.5 });\n\n document.addEventListener(\"click\", function(e) {\n var el = e.target.closest(\"[data-event-trigger='click']\");\n if (el) {\n var event = getEvent(el);\n if (event) dispatch(event);\n }\n });\n\n function observeAll() {\n document.querySelectorAll(\"[data-event-trigger='view']\").forEach(function(el) {\n viewObserver.observe(el);\n });\n }\n\n observeAll();\n var mo = new MutationObserver(observeAll);\n if (typeof requestIdleCallback !== 'undefined') {\n requestIdleCallback(function() { mo.observe(document.body, { childList: true, subtree: true }); });\n } else {\n setTimeout(function() { mo.observe(document.body, { childList: true, subtree: true }); }, 0);\n }\n }\n\n if (document.prerendering) {\n document.addEventListener('prerenderingchange', start, { once: true });\n } else {\n start();\n }\n})();\n";
|
|
13
|
+
export declare const PROGRESS_CSS = "\n@keyframes progressSlide { from { transform: translateX(-100%); } to { transform: translateX(100%); } }\n.nav-progress-bar { animation: progressSlide 1s ease-in-out infinite; }\n";
|
|
14
|
+
//# sourceMappingURL=scripts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scripts.d.ts","sourceRoot":"","sources":["../../src/react/scripts.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,8FAA8F;AAC9F,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAsBvD;AAED;;;GAGG;AACH,eAAO,MAAM,mBAAmB,koDAyD/B,CAAC;AAEF,eAAO,MAAM,YAAY,yLAGxB,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The inline scripts every Deco page runs, as v7's root layout ran them
|
|
3
|
+
* (`@decocms/tanstack` 7.x `DecoRootLayout`, `@decocms/blocks` 7.x
|
|
4
|
+
* `sdk/analytics.ts`).
|
|
5
|
+
*/
|
|
6
|
+
/** The `DECO.events` bus. Events dispatched before a subscriber exists are replayed to it. */
|
|
7
|
+
export function eventsBootstrap(account) {
|
|
8
|
+
return `
|
|
9
|
+
window.__RUNTIME__ = window.__RUNTIME__ || { account: ${JSON.stringify(account)} };
|
|
10
|
+
window.DECO = window.DECO || {};
|
|
11
|
+
window.DECO.events = window.DECO.events || {
|
|
12
|
+
_q: [],
|
|
13
|
+
_subs: [],
|
|
14
|
+
dispatch: function(e) {
|
|
15
|
+
this._q.push(e);
|
|
16
|
+
for (var i = 0; i < this._subs.length; i++) {
|
|
17
|
+
try { this._subs[i](e); } catch(err) { console.error('[DECO.events]', err); }
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
subscribe: function(fn) {
|
|
21
|
+
this._subs.push(fn);
|
|
22
|
+
for (var i = 0; i < this._q.length; i++) {
|
|
23
|
+
try { fn(this._q[i]); } catch(err) {}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
window.dataLayer = window.dataLayer || [];
|
|
28
|
+
`;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Dispatches the events elements declare with `data-event`, on view or click.
|
|
32
|
+
* It waits for a Speculation Rules prerender to activate before observing.
|
|
33
|
+
*/
|
|
34
|
+
export const DATA_EVENT_OBSERVER = `
|
|
35
|
+
(function() {
|
|
36
|
+
function start() {
|
|
37
|
+
function dispatch(event) {
|
|
38
|
+
if (window.dataLayer) {
|
|
39
|
+
window.dataLayer.push({ event: event.name, ...event.params });
|
|
40
|
+
}
|
|
41
|
+
if (window.DECO && window.DECO.events) {
|
|
42
|
+
window.DECO.events.dispatch(event);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function getEvent(el) {
|
|
47
|
+
var raw = el.getAttribute("data-event");
|
|
48
|
+
if (!raw) return null;
|
|
49
|
+
try { return JSON.parse(decodeURIComponent(raw)); } catch(e) { return null; }
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
var viewObserver = new IntersectionObserver(function(entries) {
|
|
53
|
+
entries.forEach(function(entry) {
|
|
54
|
+
if (entry.isIntersecting) {
|
|
55
|
+
var event = getEvent(entry.target);
|
|
56
|
+
if (event) dispatch(event);
|
|
57
|
+
viewObserver.unobserve(entry.target);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}, { threshold: 0.5 });
|
|
61
|
+
|
|
62
|
+
document.addEventListener("click", function(e) {
|
|
63
|
+
var el = e.target.closest("[data-event-trigger='click']");
|
|
64
|
+
if (el) {
|
|
65
|
+
var event = getEvent(el);
|
|
66
|
+
if (event) dispatch(event);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
function observeAll() {
|
|
71
|
+
document.querySelectorAll("[data-event-trigger='view']").forEach(function(el) {
|
|
72
|
+
viewObserver.observe(el);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
observeAll();
|
|
77
|
+
var mo = new MutationObserver(observeAll);
|
|
78
|
+
if (typeof requestIdleCallback !== 'undefined') {
|
|
79
|
+
requestIdleCallback(function() { mo.observe(document.body, { childList: true, subtree: true }); });
|
|
80
|
+
} else {
|
|
81
|
+
setTimeout(function() { mo.observe(document.body, { childList: true, subtree: true }); }, 0);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (document.prerendering) {
|
|
86
|
+
document.addEventListener('prerenderingchange', start, { once: true });
|
|
87
|
+
} else {
|
|
88
|
+
start();
|
|
89
|
+
}
|
|
90
|
+
})();
|
|
91
|
+
`;
|
|
92
|
+
export const PROGRESS_CSS = `
|
|
93
|
+
@keyframes progressSlide { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
|
|
94
|
+
.nav-progress-bar { animation: progressSlide 1s ease-in-out infinite; }
|
|
95
|
+
`;
|
|
96
|
+
//# sourceMappingURL=scripts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scripts.js","sourceRoot":"","sources":["../../src/react/scripts.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,8FAA8F;AAC9F,MAAM,UAAU,eAAe,CAAC,OAAe;IAC7C,OAAO;wDAC+C,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;;;;;;;;;;;;;;;;;;;CAmB9E,CAAC;AACF,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyDlC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG;;;CAG3B,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The router factory every Deco TanStack site uses (isomorphic).
|
|
3
|
+
*
|
|
4
|
+
* Search params use plain `URLSearchParams`, not TanStack's JSON format, so
|
|
5
|
+
* commerce URLs such as `?filter.size=M&filter.size=L` round-trip unchanged.
|
|
6
|
+
*/
|
|
7
|
+
import { type AnyRoute, type SearchParser, type SearchSerializer, type TrailingSlashOption } from "@tanstack/react-router";
|
|
8
|
+
import type { JSX } from "react";
|
|
9
|
+
export { PAGE_STATUS_HEADER } from "../shared.ts";
|
|
10
|
+
export declare const decoParseSearch: SearchParser;
|
|
11
|
+
/**
|
|
12
|
+
* The inverse of {@link decoParseSearch}, and a fixed point of it: on the
|
|
13
|
+
* server, TanStack Router compares the request's URL with
|
|
14
|
+
* `stringifySearch(parseSearch(...))` and redirects (307) when they differ, so
|
|
15
|
+
* an empty value (`?q=`, `?sort=`) must be kept, as v7 #646 fixed.
|
|
16
|
+
* `undefined` and `null` still remove a param (`navigate({ search: { q: undefined } })`).
|
|
17
|
+
*/
|
|
18
|
+
export declare const decoStringifySearch: SearchSerializer;
|
|
19
|
+
export interface DecoRouterOptions<TRouteTree extends AnyRoute> {
|
|
20
|
+
routeTree: TRouteTree;
|
|
21
|
+
/** Router context for every route (e.g. `{ queryClient }`). */
|
|
22
|
+
context?: Record<string, unknown>;
|
|
23
|
+
/** A provider around the whole app (non-DOM only, e.g. `QueryClientProvider`). */
|
|
24
|
+
Wrap?: (props: {
|
|
25
|
+
children: any;
|
|
26
|
+
}) => JSX.Element;
|
|
27
|
+
/** The CSP nonce TanStack stamps on its own scripts, when the site enforces one. */
|
|
28
|
+
nonce?: string;
|
|
29
|
+
/** Default `"intent"`. */
|
|
30
|
+
defaultPreload?: "intent" | "viewport" | "render" | false;
|
|
31
|
+
trailingSlash?: TrailingSlashOption;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* `createRouter` with Deco's defaults: `URLSearchParams` search params that
|
|
35
|
+
* keep empty values, scroll restoration, preload on intent.
|
|
36
|
+
*/
|
|
37
|
+
export declare function createDecoRouter<TRouteTree extends AnyRoute>(options: DecoRouterOptions<TRouteTree>): import("@tanstack/router-core").RouterCore<TRouteTree, "always" | "never" | "preserve", false, import("@tanstack/history").RouterHistory, Record<string, any>>;
|
|
38
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/router/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,KAAK,QAAQ,EAEb,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACzB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD,eAAO,MAAM,eAAe,EAAE,YAU7B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,EAAE,gBASjC,CAAC;AAEF,MAAM,WAAW,iBAAiB,CAAC,UAAU,SAAS,QAAQ;IAC5D,SAAS,EAAE,UAAU,CAAC;IACtB,+DAA+D;IAC/D,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,kFAAkF;IAClF,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,QAAQ,EAAE,GAAG,CAAA;KAAE,KAAK,GAAG,CAAC,OAAO,CAAC;IACjD,oFAAoF;IACpF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0BAA0B;IAC1B,cAAc,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,QAAQ,GAAG,KAAK,CAAC;IAC1D,aAAa,CAAC,EAAE,mBAAmB,CAAC;CACrC;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,SAAS,QAAQ,EAC1D,OAAO,EAAE,iBAAiB,CAAC,UAAU,CAAC,kKAcvC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The router factory every Deco TanStack site uses (isomorphic).
|
|
3
|
+
*
|
|
4
|
+
* Search params use plain `URLSearchParams`, not TanStack's JSON format, so
|
|
5
|
+
* commerce URLs such as `?filter.size=M&filter.size=L` round-trip unchanged.
|
|
6
|
+
*/
|
|
7
|
+
import { createRouter, } from "@tanstack/react-router";
|
|
8
|
+
export { PAGE_STATUS_HEADER } from "../shared.js";
|
|
9
|
+
export const decoParseSearch = (searchStr) => {
|
|
10
|
+
const str = searchStr.startsWith("?") ? searchStr.slice(1) : searchStr;
|
|
11
|
+
if (!str)
|
|
12
|
+
return {};
|
|
13
|
+
const params = new URLSearchParams(str);
|
|
14
|
+
const result = {};
|
|
15
|
+
for (const key of new Set(params.keys())) {
|
|
16
|
+
const values = params.getAll(key);
|
|
17
|
+
result[key] = values.length === 1 ? values[0] : values;
|
|
18
|
+
}
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* The inverse of {@link decoParseSearch}, and a fixed point of it: on the
|
|
23
|
+
* server, TanStack Router compares the request's URL with
|
|
24
|
+
* `stringifySearch(parseSearch(...))` and redirects (307) when they differ, so
|
|
25
|
+
* an empty value (`?q=`, `?sort=`) must be kept, as v7 #646 fixed.
|
|
26
|
+
* `undefined` and `null` still remove a param (`navigate({ search: { q: undefined } })`).
|
|
27
|
+
*/
|
|
28
|
+
export const decoStringifySearch = (search) => {
|
|
29
|
+
const params = new URLSearchParams();
|
|
30
|
+
for (const [key, value] of Object.entries(search)) {
|
|
31
|
+
if (value === undefined || value === null)
|
|
32
|
+
continue;
|
|
33
|
+
if (Array.isArray(value))
|
|
34
|
+
for (const v of value)
|
|
35
|
+
params.append(key, String(v));
|
|
36
|
+
else
|
|
37
|
+
params.append(key, String(value));
|
|
38
|
+
}
|
|
39
|
+
const str = params.toString();
|
|
40
|
+
return str ? `?${str}` : "";
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* `createRouter` with Deco's defaults: `URLSearchParams` search params that
|
|
44
|
+
* keep empty values, scroll restoration, preload on intent.
|
|
45
|
+
*/
|
|
46
|
+
export function createDecoRouter(options) {
|
|
47
|
+
const { routeTree, context, Wrap, nonce, defaultPreload = "intent", trailingSlash } = options;
|
|
48
|
+
return createRouter({
|
|
49
|
+
routeTree,
|
|
50
|
+
context: context,
|
|
51
|
+
Wrap,
|
|
52
|
+
scrollRestoration: true,
|
|
53
|
+
defaultPreload,
|
|
54
|
+
trailingSlash,
|
|
55
|
+
parseSearch: decoParseSearch,
|
|
56
|
+
stringifySearch: decoStringifySearch,
|
|
57
|
+
...(nonce ? { ssr: { nonce } } : {}),
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/router/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAEL,YAAY,GAIb,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD,MAAM,CAAC,MAAM,eAAe,GAAiB,CAAC,SAAS,EAAE,EAAE;IACzD,MAAM,GAAG,GAAG,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACvE,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC;IACpB,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,GAAG,CAAC,CAAC;IACxC,MAAM,MAAM,GAAsC,EAAE,CAAC;IACrD,KAAK,MAAM,GAAG,IAAI,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;QACzC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAClC,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAE,MAAM,CAAC,CAAC,CAAY,CAAC,CAAC,CAAC,MAAM,CAAC;IACrE,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAqB,CAAC,MAAM,EAAE,EAAE;IAC9D,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;IACrC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;YAAE,SAAS;QACpD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;YAAE,KAAK,MAAM,CAAC,IAAI,KAAK;gBAAE,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;;YAC1E,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACzC,CAAC;IACD,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;IAC9B,OAAO,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AAC9B,CAAC,CAAC;AAeF;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAC9B,OAAsC;IAEtC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,cAAc,GAAG,QAAQ,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;IAC9F,OAAO,YAAY,CAAC;QAClB,SAAS;QACT,OAAO,EAAE,OAAc;QACvB,IAAI;QACJ,iBAAiB,EAAE,IAAI;QACvB,cAAc;QACd,aAAa;QACb,WAAW,EAAE,eAAe;QAC5B,eAAe,EAAE,mBAAmB;QACpC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACrC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The browser's copy of `./server.ts`: the same shape, and no request scope
|
|
3
|
+
* (nothing renders inside a worker request there), so no `node:async_hooks`
|
|
4
|
+
* in the client bundle.
|
|
5
|
+
*/
|
|
6
|
+
import type { RequestScope } from "./server.ts";
|
|
7
|
+
export type { RequestScope };
|
|
8
|
+
export declare function runInScope<T>(_scope: RequestScope, fn: () => T): T;
|
|
9
|
+
export declare function currentScope(): RequestScope | undefined;
|
|
10
|
+
export declare const SCOPE_IMPLEMENTATION: "async-local-storage" | "browser-stub";
|
|
11
|
+
//# sourceMappingURL=browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/scope/browser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,YAAY,EAAE,YAAY,EAAE,CAAC;AAE7B,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAElE;AAED,wBAAgB,YAAY,IAAI,YAAY,GAAG,SAAS,CAEvD;AAED,eAAO,MAAM,oBAAoB,EAAqB,qBAAqB,GAAG,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../../src/scope/browser.ts"],"names":[],"mappings":"AASA,MAAM,UAAU,UAAU,CAAI,MAAoB,EAAE,EAAW;IAC7D,OAAO,EAAE,EAAE,CAAC;AACd,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,cAAwD,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface RequestScope {
|
|
2
|
+
/** The CDN segment token for this request's page, or undefined when it may not be cached. */
|
|
3
|
+
csegToken?: string;
|
|
4
|
+
/** The draft this request renders (after the worker's host check). */
|
|
5
|
+
draft?: string;
|
|
6
|
+
}
|
|
7
|
+
/** Runs `fn` with `scope` as the request's scope. */
|
|
8
|
+
export declare function runInScope<T>(scope: RequestScope, fn: () => T): T;
|
|
9
|
+
/** The scope of the request being served, or undefined outside one (and in the browser). */
|
|
10
|
+
export declare function currentScope(): RequestScope | undefined;
|
|
11
|
+
/** Which implementation this is: the conditional-export test asserts it. */
|
|
12
|
+
export declare const SCOPE_IMPLEMENTATION: "async-local-storage" | "browser-stub";
|
|
13
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/scope/server.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,YAAY;IAC3B,6FAA6F;IAC7F,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sEAAsE;IACtE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAQD,qDAAqD;AACrD,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAEjE;AAED,4FAA4F;AAC5F,wBAAgB,YAAY,IAAI,YAAY,GAAG,SAAS,CAEvD;AAED,4EAA4E;AAC5E,eAAO,MAAM,oBAAoB,EAA4B,qBAAqB,GAAG,cAAc,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Values `createDecoWorker` hands to the render of the request it is serving
|
|
3
|
+
* (the `__cseg` token and the draft `DecoDocument` publishes), through
|
|
4
|
+
* `AsyncLocalStorage`. The browser build resolves `./browser.ts` instead (the
|
|
5
|
+
* package's `./scope` export is conditional: `workerd` and `node` come before
|
|
6
|
+
* `browser`, because a Workers build turns `browser` on too).
|
|
7
|
+
*
|
|
8
|
+
* One storage per process even if a bundler duplicates this module: it lives
|
|
9
|
+
* on `globalThis` under a registered symbol.
|
|
10
|
+
*/
|
|
11
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
12
|
+
const KEY = Symbol.for("decocms.tanstack.requestScope");
|
|
13
|
+
const holder = globalThis;
|
|
14
|
+
const storage = holder[KEY] ?? new AsyncLocalStorage();
|
|
15
|
+
holder[KEY] = storage;
|
|
16
|
+
/** Runs `fn` with `scope` as the request's scope. */
|
|
17
|
+
export function runInScope(scope, fn) {
|
|
18
|
+
return storage.run(scope, fn);
|
|
19
|
+
}
|
|
20
|
+
/** The scope of the request being served, or undefined outside one (and in the browser). */
|
|
21
|
+
export function currentScope() {
|
|
22
|
+
return storage.getStore();
|
|
23
|
+
}
|
|
24
|
+
/** Which implementation this is: the conditional-export test asserts it. */
|
|
25
|
+
export const SCOPE_IMPLEMENTATION = "async-local-storage";
|
|
26
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/scope/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AASrD,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;AACxD,MAAM,MAAM,GAAG,UAAoF,CAAC;AACpG,MAAM,OAAO,GACX,MAAM,CAAC,GAAG,CAAC,IAAI,IAAI,iBAAiB,EAAgB,CAAC;AACvD,MAAM,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC;AAEtB,qDAAqD;AACrD,MAAM,UAAU,UAAU,CAAI,KAAmB,EAAE,EAAW;IAC5D,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAChC,CAAC;AAED,4FAA4F;AAC5F,MAAM,UAAU,YAAY;IAC1B,OAAO,OAAO,CAAC,QAAQ,EAAE,CAAC;AAC5B,CAAC;AAED,4EAA4E;AAC5E,MAAM,CAAC,MAAM,oBAAoB,GAAG,qBAA+D,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-only helpers for a site's server functions and page loader. Never
|
|
3
|
+
* import this from a component that ships to the browser.
|
|
4
|
+
*
|
|
5
|
+
* The draft a request renders is decided once, by `createDecoWorker` (its host
|
|
6
|
+
* allowlist), and handed to the app in the `x-deco-draft` request header; the
|
|
7
|
+
* worker removes any copy that arrives from outside. These read that header.
|
|
8
|
+
*/
|
|
9
|
+
import type { Client, CMS } from "@decocms/blocks";
|
|
10
|
+
/** The draft `request` renders (checked by the worker), or `null` for the release. */
|
|
11
|
+
export declare function requestDraft(request?: Request): string | null;
|
|
12
|
+
/**
|
|
13
|
+
* The content client for a request: its draft's, or the release's. Without
|
|
14
|
+
* `request`, the request being served (`getRequest()`).
|
|
15
|
+
*/
|
|
16
|
+
export declare function contentClient(cms: CMS, request?: Request): Client;
|
|
17
|
+
/** True when the browser called a server function over HTTP; false while a document renders. */
|
|
18
|
+
export declare function isServerFnCall(request?: Request): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Marks a server function's response as per-visitor (`Cache-Control: private,
|
|
21
|
+
* no-store`): the worker never stores it and the CDN never keeps it. Only when
|
|
22
|
+
* the browser called the function over HTTP; while a document renders the
|
|
23
|
+
* function is a plain call and the header would land on the page.
|
|
24
|
+
*/
|
|
25
|
+
export declare function markPrivate(): void;
|
|
26
|
+
export { DEGRADED_HEADER, PAGE_STATUS_HEADER } from "../shared.ts";
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAInD,sFAAsF;AACtF,wBAAgB,YAAY,CAAC,OAAO,GAAE,OAAsB,GAAG,MAAM,GAAG,IAAI,CAE3E;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,GAAE,OAAsB,GAAG,MAAM,CAG/E;AAED,gGAAgG;AAChG,wBAAgB,cAAc,CAAC,OAAO,GAAE,OAAsB,GAAG,OAAO,CAEvE;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAGlC;AAED,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { getRequest, setResponseHeader } from "@tanstack/react-start/server";
|
|
2
|
+
import { DRAFT_HEADER } from "../draft.js";
|
|
3
|
+
/** The draft `request` renders (checked by the worker), or `null` for the release. */
|
|
4
|
+
export function requestDraft(request = getRequest()) {
|
|
5
|
+
return request.headers.get(DRAFT_HEADER) || null;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The content client for a request: its draft's, or the release's. Without
|
|
9
|
+
* `request`, the request being served (`getRequest()`).
|
|
10
|
+
*/
|
|
11
|
+
export function contentClient(cms, request = getRequest()) {
|
|
12
|
+
const pointer = requestDraft(request);
|
|
13
|
+
return pointer ? cms.forDraft(pointer) : cms.forRelease();
|
|
14
|
+
}
|
|
15
|
+
/** True when the browser called a server function over HTTP; false while a document renders. */
|
|
16
|
+
export function isServerFnCall(request = getRequest()) {
|
|
17
|
+
return new URL(request.url).pathname.startsWith("/_serverFn/");
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Marks a server function's response as per-visitor (`Cache-Control: private,
|
|
21
|
+
* no-store`): the worker never stores it and the CDN never keeps it. Only when
|
|
22
|
+
* the browser called the function over HTTP; while a document renders the
|
|
23
|
+
* function is a plain call and the header would land on the page.
|
|
24
|
+
*/
|
|
25
|
+
export function markPrivate() {
|
|
26
|
+
if (!isServerFnCall())
|
|
27
|
+
return;
|
|
28
|
+
setResponseHeader("Cache-Control", "private, no-store");
|
|
29
|
+
}
|
|
30
|
+
export { DEGRADED_HEADER, PAGE_STATUS_HEADER } from "../shared.js";
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,sFAAsF;AACtF,MAAM,UAAU,YAAY,CAAC,OAAO,GAAY,UAAU,EAAE;IAC1D,OAAO,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,IAAI,CAAC;AACnD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,GAAQ,EAAE,OAAO,GAAY,UAAU,EAAE;IACrE,MAAM,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;IACtC,OAAO,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC;AAC5D,CAAC;AAED,gGAAgG;AAChG,MAAM,UAAU,cAAc,CAAC,OAAO,GAAY,UAAU,EAAE;IAC5D,OAAO,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;AACjE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW;IACzB,IAAI,CAAC,cAAc,EAAE;QAAE,OAAO;IAC9B,iBAAiB,CAAC,eAAe,EAAE,mBAAmB,CAAC,CAAC;AAC1D,CAAC;AAED,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/shared.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Names the worker, the router and the browser code share. No imports, no
|
|
3
|
+
* state: safe in every bundle.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* The query parameter `decoServerFnFetch` adds to a server-function URL: the
|
|
7
|
+
* page's CDN segment token, which the worker checks before it lets the CDN
|
|
8
|
+
* cache the response. `__d` is avoided: v7 used it as a debug flag.
|
|
9
|
+
*/
|
|
10
|
+
export declare const CSEG_PARAM = "__cseg";
|
|
11
|
+
/** The `window` property the page publishes the token on. */
|
|
12
|
+
export declare const CSEG_GLOBAL = "__DECO_CSEG";
|
|
13
|
+
/**
|
|
14
|
+
* The response header a route sets to give the document another status (a CMS
|
|
15
|
+
* page that renders the site's 404 page): the worker turns it into the
|
|
16
|
+
* response's status and removes it. A route's `headers` reach the document
|
|
17
|
+
* response, a status set while rendering does not.
|
|
18
|
+
*/
|
|
19
|
+
export declare const PAGE_STATUS_HEADER = "x-page-status";
|
|
20
|
+
/**
|
|
21
|
+
* The response header a page sets when a loader it depends on failed: the
|
|
22
|
+
* worker never stores that response, and serves a stale copy instead when it
|
|
23
|
+
* has one.
|
|
24
|
+
*/
|
|
25
|
+
export declare const DEGRADED_HEADER = "x-deco-degraded";
|
|
26
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AACH,eAAO,MAAM,UAAU,WAAW,CAAC;AAEnC,6DAA6D;AAC7D,eAAO,MAAM,WAAW,gBAAgB,CAAC;AAEzC;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,kBAAkB,CAAC;AAElD;;;;GAIG;AACH,eAAO,MAAM,eAAe,oBAAoB,CAAC"}
|
package/dist/shared.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Names the worker, the router and the browser code share. No imports, no
|
|
3
|
+
* state: safe in every bundle.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* The query parameter `decoServerFnFetch` adds to a server-function URL: the
|
|
7
|
+
* page's CDN segment token, which the worker checks before it lets the CDN
|
|
8
|
+
* cache the response. `__d` is avoided: v7 used it as a debug flag.
|
|
9
|
+
*/
|
|
10
|
+
export const CSEG_PARAM = "__cseg";
|
|
11
|
+
/** The `window` property the page publishes the token on. */
|
|
12
|
+
export const CSEG_GLOBAL = "__DECO_CSEG";
|
|
13
|
+
/**
|
|
14
|
+
* The response header a route sets to give the document another status (a CMS
|
|
15
|
+
* page that renders the site's 404 page): the worker turns it into the
|
|
16
|
+
* response's status and removes it. A route's `headers` reach the document
|
|
17
|
+
* response, a status set while rendering does not.
|
|
18
|
+
*/
|
|
19
|
+
export const PAGE_STATUS_HEADER = "x-page-status";
|
|
20
|
+
/**
|
|
21
|
+
* The response header a page sets when a loader it depends on failed: the
|
|
22
|
+
* worker never stores that response, and serves a stale copy instead when it
|
|
23
|
+
* has one.
|
|
24
|
+
*/
|
|
25
|
+
export const DEGRADED_HEADER = "x-deco-degraded";
|
|
26
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC;AAEnC,6DAA6D;AAC7D,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,eAAe,CAAC;AAElD;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `fetch` for server-function calls: adds the CDN segment token the page
|
|
3
|
+
* published (`__cseg`), so the CDN can cache client-side navigation data. The
|
|
4
|
+
* token is a hint: the worker recomputes it from the request and keeps
|
|
5
|
+
* `CDN-Cache-Control: no-store` unless they match. With no token on the page,
|
|
6
|
+
* a plain `fetch`.
|
|
7
|
+
*/
|
|
8
|
+
export declare const decoServerFnFetch: typeof fetch;
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/start/index.ts"],"names":[],"mappings":"AAgBA;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,EAAE,OAAO,KAOtC,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Safe in the browser bundle: the `serverFns.fetch` hook for `createStart`.
|
|
3
|
+
*
|
|
4
|
+
* ```ts
|
|
5
|
+
* // src/start.ts
|
|
6
|
+
* export const startInstance = createStart(() => ({ serverFns: { fetch: decoServerFnFetch } }));
|
|
7
|
+
* ```
|
|
8
|
+
*/
|
|
9
|
+
import { CSEG_GLOBAL, CSEG_PARAM } from "../shared.js";
|
|
10
|
+
function publishedToken() {
|
|
11
|
+
if (typeof window === "undefined")
|
|
12
|
+
return null;
|
|
13
|
+
const value = window[CSEG_GLOBAL];
|
|
14
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* `fetch` for server-function calls: adds the CDN segment token the page
|
|
18
|
+
* published (`__cseg`), so the CDN can cache client-side navigation data. The
|
|
19
|
+
* token is a hint: the worker recomputes it from the request and keeps
|
|
20
|
+
* `CDN-Cache-Control: no-store` unless they match. With no token on the page,
|
|
21
|
+
* a plain `fetch`.
|
|
22
|
+
*/
|
|
23
|
+
export const decoServerFnFetch = (input, init) => {
|
|
24
|
+
// TanStack's server-function fetcher passes the URL as a string; anything else goes through as is.
|
|
25
|
+
if (typeof input !== "string")
|
|
26
|
+
return fetch(input, init);
|
|
27
|
+
const token = publishedToken();
|
|
28
|
+
if (!token)
|
|
29
|
+
return fetch(input, init);
|
|
30
|
+
const sep = input.includes("?") ? "&" : "?";
|
|
31
|
+
return fetch(`${input}${sep}${CSEG_PARAM}=${encodeURIComponent(token)}`, init);
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/start/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAEvD,SAAS,cAAc;IACrB,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO,IAAI,CAAC;IAC/C,MAAM,KAAK,GAAI,MAA6C,CAAC,WAAW,CAAC,CAAC;IAC1E,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AACtE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAiB,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;IAC7D,mGAAmG;IACnG,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACzD,MAAM,KAAK,GAAG,cAAc,EAAE,CAAC;IAC/B,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACtC,MAAM,GAAG,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;IAC5C,OAAO,KAAK,CAAC,GAAG,KAAK,GAAG,GAAG,GAAG,UAAU,IAAI,kBAAkB,CAAC,KAAK,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;AACjF,CAAC,CAAC"}
|
package/dist/studio.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where Deco Studio runs: the origins its site editor frames a site from and
|
|
3
|
+
* talks to it from (`postMessage`). One list, so the worker's
|
|
4
|
+
* `frame-ancestors` and the Studio bridge `DecoDocument` mounts never drift
|
|
5
|
+
* apart.
|
|
6
|
+
*
|
|
7
|
+
* No module state and no framework code: safe in a browser bundle.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Studio's origins, in the CSP source form (`https://*.decocms.com` matches
|
|
11
|
+
* any subdomain). Test an origin with {@link isStudioOrigin}: the list holds a
|
|
12
|
+
* wildcard, so `includes()` isn't the check.
|
|
13
|
+
*/
|
|
14
|
+
export declare const STUDIO_ORIGINS: readonly string[];
|
|
15
|
+
/**
|
|
16
|
+
* The `frame-ancestors` sources a site sends so Studio can show it in the
|
|
17
|
+
* site editor: the site itself, {@link STUDIO_ORIGINS}, and v7's
|
|
18
|
+
* `https://*.deco.studio`. A binding adds the loopback origins in local
|
|
19
|
+
* development (`http://localhost:*`), where a Studio runs on the same machine.
|
|
20
|
+
*/
|
|
21
|
+
export declare const STUDIO_FRAME_ANCESTORS: readonly string[];
|
|
22
|
+
/**
|
|
23
|
+
* Whether `origin` (a `MessageEvent.origin`, an `Origin` header) is one of
|
|
24
|
+
* {@link STUDIO_ORIGINS}: `https`, the default port, and `decocms.com` or a
|
|
25
|
+
* name under it.
|
|
26
|
+
*/
|
|
27
|
+
export declare function isStudioOrigin(origin: string | null | undefined): boolean;
|
|
28
|
+
//# sourceMappingURL=studio.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"studio.d.ts","sourceRoot":"","sources":["../src/studio.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,SAAS,MAAM,EAK1C,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,EAAE,SAAS,MAAM,EAIlD,CAAC;AAEH;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAazE"}
|
package/dist/studio.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where Deco Studio runs: the origins its site editor frames a site from and
|
|
3
|
+
* talks to it from (`postMessage`). One list, so the worker's
|
|
4
|
+
* `frame-ancestors` and the Studio bridge `DecoDocument` mounts never drift
|
|
5
|
+
* apart.
|
|
6
|
+
*
|
|
7
|
+
* No module state and no framework code: safe in a browser bundle.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Studio's origins, in the CSP source form (`https://*.decocms.com` matches
|
|
11
|
+
* any subdomain). Test an origin with {@link isStudioOrigin}: the list holds a
|
|
12
|
+
* wildcard, so `includes()` isn't the check.
|
|
13
|
+
*/
|
|
14
|
+
export const STUDIO_ORIGINS = Object.freeze([
|
|
15
|
+
"https://studio.decocms.com",
|
|
16
|
+
"https://studio-stg.decocms.com",
|
|
17
|
+
"https://decocms.com",
|
|
18
|
+
"https://*.decocms.com",
|
|
19
|
+
]);
|
|
20
|
+
/**
|
|
21
|
+
* The `frame-ancestors` sources a site sends so Studio can show it in the
|
|
22
|
+
* site editor: the site itself, {@link STUDIO_ORIGINS}, and v7's
|
|
23
|
+
* `https://*.deco.studio`. A binding adds the loopback origins in local
|
|
24
|
+
* development (`http://localhost:*`), where a Studio runs on the same machine.
|
|
25
|
+
*/
|
|
26
|
+
export const STUDIO_FRAME_ANCESTORS = Object.freeze([
|
|
27
|
+
"'self'",
|
|
28
|
+
...STUDIO_ORIGINS,
|
|
29
|
+
"https://*.deco.studio",
|
|
30
|
+
]);
|
|
31
|
+
/**
|
|
32
|
+
* Whether `origin` (a `MessageEvent.origin`, an `Origin` header) is one of
|
|
33
|
+
* {@link STUDIO_ORIGINS}: `https`, the default port, and `decocms.com` or a
|
|
34
|
+
* name under it.
|
|
35
|
+
*/
|
|
36
|
+
export function isStudioOrigin(origin) {
|
|
37
|
+
if (typeof origin !== "string" || origin === "")
|
|
38
|
+
return false;
|
|
39
|
+
let url;
|
|
40
|
+
try {
|
|
41
|
+
url = new URL(origin);
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
// An origin is the scheme and host alone: `https://decocms.com/x` or one with
|
|
47
|
+
// credentials isn't one.
|
|
48
|
+
if (url.origin !== origin || url.protocol !== "https:" || url.port !== "")
|
|
49
|
+
return false;
|
|
50
|
+
const host = url.hostname;
|
|
51
|
+
return host === "decocms.com" || host.endsWith(".decocms.com");
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=studio.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"studio.js","sourceRoot":"","sources":["../src/studio.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAsB,MAAM,CAAC,MAAM,CAAC;IAC7D,4BAA4B;IAC5B,gCAAgC;IAChC,qBAAqB;IACrB,uBAAuB;CACxB,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAsB,MAAM,CAAC,MAAM,CAAC;IACrE,QAAQ;IACR,GAAG,cAAc;IACjB,uBAAuB;CACxB,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,MAAiC;IAC9D,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,EAAE;QAAE,OAAO,KAAK,CAAC;IAC9D,IAAI,GAAQ,CAAC;IACb,IAAI,CAAC;QACH,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;IACxB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;IACD,8EAA8E;IAC9E,yBAAyB;IACzB,IAAI,GAAG,CAAC,MAAM,KAAK,MAAM,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,KAAK,EAAE;QAAE,OAAO,KAAK,CAAC;IACxF,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC;IAC1B,OAAO,IAAI,KAAK,aAAa,IAAI,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;AACjE,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Plugin } from "vite";
|
|
2
|
+
/**
|
|
3
|
+
* The commit this build is made from (`git rev-parse --short=12 HEAD`), or the
|
|
4
|
+
* time when git can't say (no git, not a repository), so two builds never share
|
|
5
|
+
* a key by accident.
|
|
6
|
+
*/
|
|
7
|
+
export declare function gitBuildHash(cwd?: string): string;
|
|
8
|
+
/** The build hash for `vite build`: the CI's sha (shortened), else {@link gitBuildHash}. */
|
|
9
|
+
export declare function resolveBuildHash(ciSha: string | undefined, cwd?: string): string;
|
|
10
|
+
export interface DecoTanstackOptions {
|
|
11
|
+
/** The CI's commit sha (e.g. `process.env.WORKERS_CI_COMMIT_SHA`); without it, git's. */
|
|
12
|
+
buildHash?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function decoTanstack(options?: DecoTanstackOptions): Plugin[];
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vite/index.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAInC;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAYjD;AAED,4FAA4F;AAC5F,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAGhF;AA2BD,MAAM,WAAW,mBAAmB;IAClC,yFAAyF;IACzF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,YAAY,CAAC,OAAO,GAAE,mBAAwB,GAAG,MAAM,EAAE,CAuBxE"}
|