@decocms/tanstack 8.0.0 → 8.4.0
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 +107 -0
- package/dist/worker/index.d.ts.map +1 -0
- package/dist/worker/index.js +511 -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 +86 -31
- package/src/draft.ts +43 -0
- package/src/index.ts +8 -44
- 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 +648 -0
- package/src/worker/security.ts +63 -0
- package/src/worker/segment.ts +49 -0
- 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/DecoPageRenderer.tsx +0 -688
- package/src/hooks/DecoRootLayout.tsx +0 -111
- package/src/hooks/NavigationProgress.tsx +0 -21
- package/src/hooks/PreviewProviders.tsx +0 -26
- package/src/hooks/StableOutlet.tsx +0 -30
- package/src/hooks/index.ts +0 -9
- package/src/routes/adminRoutes.test.ts +0 -99
- package/src/routes/adminRoutes.ts +0 -153
- package/src/routes/cmsRoute.test.ts +0 -100
- package/src/routes/cmsRoute.ts +0 -944
- 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 -54
- package/src/routes/withSiteGlobals.test.ts +0 -206
- package/src/routes/withSiteGlobals.ts +0 -222
- 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/kvHydration.test.ts +0 -215
- package/src/sdk/kvHydration.ts +0 -193
- package/src/sdk/outboundHeaders.test.ts +0 -113
- package/src/sdk/outboundHeaders.ts +0 -81
- package/src/sdk/router.ts +0 -92
- package/src/sdk/useHydrated.ts +0 -19
- package/src/sdk/workerEntry.test.ts +0 -495
- package/src/sdk/workerEntry.ts +0 -2307
- package/src/setupFastDeploy.ts +0 -13
- package/src/vite/plugin-scaffold-gen.test.js +0 -106
- package/src/vite/plugin.js +0 -850
- package/src/vite/plugin.test.js +0 -113
- package/src/vite/plugin.test.ts +0 -52
- package/tsconfig.json +0 -7
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
_uninstallDefaultUserAgentForTests,
|
|
4
|
-
DECO_POWERED_BY,
|
|
5
|
-
DECO_USER_AGENT,
|
|
6
|
-
installDefaultUserAgent,
|
|
7
|
-
} from "./outboundHeaders";
|
|
8
|
-
|
|
9
|
-
/** Headers the wrapped baseFetch would put on the wire for a given call. */
|
|
10
|
-
function wireHeaders(call: readonly [RequestInfo | URL, RequestInit?]): Headers {
|
|
11
|
-
const [input, init] = call;
|
|
12
|
-
if (init?.headers !== undefined) return new Headers(init.headers);
|
|
13
|
-
if (input instanceof Request) return new Headers(input.headers);
|
|
14
|
-
return new Headers();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
describe("installDefaultUserAgent", () => {
|
|
18
|
-
const realFetch = globalThis.fetch;
|
|
19
|
-
|
|
20
|
-
afterEach(() => {
|
|
21
|
-
_uninstallDefaultUserAgentForTests();
|
|
22
|
-
globalThis.fetch = realFetch;
|
|
23
|
-
vi.restoreAllMocks();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
function install(userAgent?: string) {
|
|
27
|
-
const baseFetch = vi.fn(
|
|
28
|
-
async (_input: RequestInfo | URL, _init?: RequestInit) => new Response("ok"),
|
|
29
|
-
);
|
|
30
|
-
globalThis.fetch = baseFetch as unknown as typeof fetch;
|
|
31
|
-
installDefaultUserAgent(userAgent);
|
|
32
|
-
return baseFetch;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
it("sets the default UA on a bare string fetch", async () => {
|
|
36
|
-
const baseFetch = install();
|
|
37
|
-
await fetch("https://api.example.com/products");
|
|
38
|
-
|
|
39
|
-
const headers = wireHeaders(baseFetch.mock.calls[0]);
|
|
40
|
-
expect(headers.get("user-agent")).toBe(DECO_USER_AGENT);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it("keeps the caller's UA from init.headers", async () => {
|
|
44
|
-
const baseFetch = install();
|
|
45
|
-
await fetch("https://api.example.com/", {
|
|
46
|
-
headers: { "user-agent": "deco-aws-app/1.0" },
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
// Untouched call: init passed through verbatim.
|
|
50
|
-
expect(baseFetch.mock.calls[0][1]).toEqual({
|
|
51
|
-
headers: { "user-agent": "deco-aws-app/1.0" },
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it("keeps the UA of a Request input", async () => {
|
|
56
|
-
const baseFetch = install();
|
|
57
|
-
const req = new Request("https://api.example.com/", {
|
|
58
|
-
headers: { "User-Agent": "decocx/1.0" },
|
|
59
|
-
});
|
|
60
|
-
await fetch(req);
|
|
61
|
-
|
|
62
|
-
expect(baseFetch.mock.calls[0][0]).toBe(req);
|
|
63
|
-
expect(baseFetch.mock.calls[0][1]).toBeUndefined();
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it("preserves a Request's other headers when injecting the UA", async () => {
|
|
67
|
-
const baseFetch = install();
|
|
68
|
-
await fetch(
|
|
69
|
-
new Request("https://api.example.com/", {
|
|
70
|
-
headers: { accept: "application/json", "x-api-key": "k" },
|
|
71
|
-
}),
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
const headers = wireHeaders(baseFetch.mock.calls[0]);
|
|
75
|
-
expect(headers.get("user-agent")).toBe(DECO_USER_AGENT);
|
|
76
|
-
expect(headers.get("accept")).toBe("application/json");
|
|
77
|
-
expect(headers.get("x-api-key")).toBe("k");
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it("preserves non-header init members (method, body, signal)", async () => {
|
|
81
|
-
const baseFetch = install();
|
|
82
|
-
const controller = new AbortController();
|
|
83
|
-
await fetch("https://api.example.com/", {
|
|
84
|
-
method: "POST",
|
|
85
|
-
body: "{}",
|
|
86
|
-
signal: controller.signal,
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
const init = baseFetch.mock.calls[0][1]!;
|
|
90
|
-
expect(init.method).toBe("POST");
|
|
91
|
-
expect(init.body).toBe("{}");
|
|
92
|
-
expect(init.signal).toBe(controller.signal);
|
|
93
|
-
expect(new Headers(init.headers).get("user-agent")).toBe(DECO_USER_AGENT);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it("honors a custom UA value", async () => {
|
|
97
|
-
const baseFetch = install("MyStore-Migration/1.0");
|
|
98
|
-
await fetch("https://api.example.com/");
|
|
99
|
-
|
|
100
|
-
expect(wireHeaders(baseFetch.mock.calls[0]).get("user-agent")).toBe("MyStore-Migration/1.0");
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it("is idempotent — a second install does not re-wrap", () => {
|
|
104
|
-
install();
|
|
105
|
-
const wrapped = globalThis.fetch;
|
|
106
|
-
installDefaultUserAgent();
|
|
107
|
-
expect(globalThis.fetch).toBe(wrapped);
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it("exposes the old-runtime-parity x-powered-by value", () => {
|
|
111
|
-
expect(DECO_POWERED_BY).toMatch(/^deco@\d+\.\d+\.\d+/);
|
|
112
|
-
});
|
|
113
|
-
});
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Runtime identification headers.
|
|
3
|
-
*
|
|
4
|
-
* Outbound: Cloudflare Workers' `fetch` sends NO `User-Agent` header at
|
|
5
|
-
* all — unlike the old Deno runtime, where every outbound request carried
|
|
6
|
-
* Deno's implicit `User-Agent: Deno/x.y.z`. UA-less requests are a strong
|
|
7
|
-
* bot signal: Cloudflare managed WAF rules and Bot Fight Mode on partner
|
|
8
|
-
* origins block them outright. `installDefaultUserAgent()` restores the
|
|
9
|
-
* pre-migration behavior with an honest, allowlistable value, applied only
|
|
10
|
-
* when the caller didn't set a User-Agent of its own.
|
|
11
|
-
*
|
|
12
|
-
* Responses: the old runtime stamped `x-powered-by: deco@<version>` on
|
|
13
|
-
* every response (deco-cx/deco `utils/http.ts` defaultHeaders). The worker
|
|
14
|
-
* entry reuses `DECO_POWERED_BY` for parity.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import pkg from "../../package.json";
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Default outbound User-Agent. Stable prefix (`Deco/`) so partners can
|
|
21
|
-
* write one WAF allowlist rule that survives version bumps and platform
|
|
22
|
-
* changes; the URL comment tells whoever reads an access log who we are.
|
|
23
|
-
*/
|
|
24
|
-
export const DECO_USER_AGENT = `Deco/${pkg.version} (+https://deco.cx)`;
|
|
25
|
-
|
|
26
|
-
/** Response identification header value — parity with deco-cx/deco. */
|
|
27
|
-
export const DECO_POWERED_BY = `deco@${pkg.version}`;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Cross-module guard on `globalThis` (same trick as logger.ts STATE_KEY):
|
|
31
|
-
* bundlers may duplicate this module across chunks, so a module-local
|
|
32
|
-
* boolean would not prevent double-wrapping.
|
|
33
|
-
*/
|
|
34
|
-
const INSTALLED_KEY = Symbol.for("deco.outboundHeaders.installed");
|
|
35
|
-
|
|
36
|
-
let restoreBaseFetch: (() => void) | undefined;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Patch `globalThis.fetch` so every outbound request carries a User-Agent.
|
|
40
|
-
*
|
|
41
|
-
* Set-if-absent only: app-specific UAs (`deco-aws-app/1.0`, `decocx/1.0`,
|
|
42
|
-
* ...) always win, matching the old runtime where Deno's default applied
|
|
43
|
-
* only when unset. All other RequestInit members (method, body, signal,
|
|
44
|
-
* `cf`, ...) pass through untouched. Idempotent — safe to call more than
|
|
45
|
-
* once (e.g. worker entry + tests).
|
|
46
|
-
*/
|
|
47
|
-
export function installDefaultUserAgent(userAgent: string = DECO_USER_AGENT): void {
|
|
48
|
-
const g = globalThis as Record<symbol, unknown>;
|
|
49
|
-
if (g[INSTALLED_KEY]) return;
|
|
50
|
-
g[INSTALLED_KEY] = true;
|
|
51
|
-
|
|
52
|
-
const baseFetch = globalThis.fetch;
|
|
53
|
-
restoreBaseFetch = () => {
|
|
54
|
-
globalThis.fetch = baseFetch;
|
|
55
|
-
delete g[INSTALLED_KEY];
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
globalThis.fetch = ((input: RequestInfo | URL, init?: RequestInit): Promise<Response> => {
|
|
59
|
-
// Fetch-spec semantics (same rule instrumentedFetch.ts documents):
|
|
60
|
-
// when both a Request and `init.headers` are passed, `init.headers`
|
|
61
|
-
// REPLACES the Request's headers — they do not union. So the headers
|
|
62
|
-
// that will actually hit the wire are init.headers if present, else
|
|
63
|
-
// the Request's own headers, else none.
|
|
64
|
-
const base =
|
|
65
|
-
init?.headers !== undefined
|
|
66
|
-
? init.headers
|
|
67
|
-
: input instanceof Request
|
|
68
|
-
? input.headers
|
|
69
|
-
: undefined;
|
|
70
|
-
const headers = new Headers(base ?? undefined);
|
|
71
|
-
if (headers.has("user-agent")) return baseFetch(input, init);
|
|
72
|
-
headers.set("user-agent", userAgent);
|
|
73
|
-
return baseFetch(input, { ...init, headers });
|
|
74
|
-
}) as typeof fetch;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/** Test-only: restore the unpatched fetch. Do not call from app code. */
|
|
78
|
-
export function _uninstallDefaultUserAgentForTests(): void {
|
|
79
|
-
restoreBaseFetch?.();
|
|
80
|
-
restoreBaseFetch = undefined;
|
|
81
|
-
}
|
package/src/sdk/router.ts
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Deco-flavored TanStack Router factory.
|
|
3
|
-
*
|
|
4
|
-
* Uses standard URLSearchParams serialization instead of TanStack's default
|
|
5
|
-
* JSON-based format. Required because VTEX (and most commerce platforms) uses
|
|
6
|
-
* filter URLs like `?filter.brand=Nike&filter.brand=Adidas` which must
|
|
7
|
-
* round-trip correctly through the router's search system.
|
|
8
|
-
*/
|
|
9
|
-
import { createRouter as createTanStackRouter } from "@tanstack/react-router";
|
|
10
|
-
import type {
|
|
11
|
-
SearchSerializer,
|
|
12
|
-
SearchParser,
|
|
13
|
-
AnyRoute,
|
|
14
|
-
TrailingSlashOption,
|
|
15
|
-
} from "@tanstack/react-router";
|
|
16
|
-
|
|
17
|
-
export const decoParseSearch: SearchParser = (searchStr) => {
|
|
18
|
-
const str = searchStr.startsWith("?") ? searchStr.slice(1) : searchStr;
|
|
19
|
-
if (!str) return {};
|
|
20
|
-
|
|
21
|
-
const params = new URLSearchParams(str);
|
|
22
|
-
const result: Record<string, string | string[]> = {};
|
|
23
|
-
|
|
24
|
-
for (const key of new Set(params.keys())) {
|
|
25
|
-
const values = params.getAll(key);
|
|
26
|
-
result[key] = values.length === 1 ? values[0] : values;
|
|
27
|
-
}
|
|
28
|
-
return result;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export const decoStringifySearch: SearchSerializer = (search) => {
|
|
32
|
-
const params = new URLSearchParams();
|
|
33
|
-
for (const [key, value] of Object.entries(search)) {
|
|
34
|
-
if (value === undefined || value === null || value === "") continue;
|
|
35
|
-
if (Array.isArray(value)) {
|
|
36
|
-
for (const v of value) params.append(key, String(v));
|
|
37
|
-
} else {
|
|
38
|
-
params.append(key, String(value));
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
const str = params.toString();
|
|
42
|
-
return str ? `?${str}` : "";
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export interface CreateDecoRouterOptions {
|
|
46
|
-
routeTree: AnyRoute;
|
|
47
|
-
scrollRestoration?: boolean;
|
|
48
|
-
defaultPreload?: "intent" | "viewport" | "render" | false;
|
|
49
|
-
trailingSlash?: TrailingSlashOption;
|
|
50
|
-
/**
|
|
51
|
-
* Router context — passed to all route loaders/components via routeContext.
|
|
52
|
-
* Commonly used for { queryClient } per TanStack Query integration docs.
|
|
53
|
-
*/
|
|
54
|
-
context?: Record<string, unknown>;
|
|
55
|
-
/**
|
|
56
|
-
* Non-DOM provider component to wrap the entire router.
|
|
57
|
-
* Per TanStack docs, only non-DOM-rendering components (providers) should
|
|
58
|
-
* be used — anything else causes hydration errors.
|
|
59
|
-
*
|
|
60
|
-
* Example: QueryClientProvider wrapping
|
|
61
|
-
* Wrap: ({ children }) => <QueryClientProvider client={qc}>{children}</QueryClientProvider>
|
|
62
|
-
*/
|
|
63
|
-
Wrap?: (props: { children: any }) => any;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Create a TanStack Router with Deco defaults:
|
|
68
|
-
* - URLSearchParams-based search serialization (not JSON)
|
|
69
|
-
* - Scroll restoration enabled
|
|
70
|
-
* - Preload on intent
|
|
71
|
-
*/
|
|
72
|
-
export function createDecoRouter(options: CreateDecoRouterOptions) {
|
|
73
|
-
const {
|
|
74
|
-
routeTree,
|
|
75
|
-
scrollRestoration = true,
|
|
76
|
-
defaultPreload = "intent",
|
|
77
|
-
trailingSlash,
|
|
78
|
-
context,
|
|
79
|
-
Wrap,
|
|
80
|
-
} = options;
|
|
81
|
-
|
|
82
|
-
return createTanStackRouter({
|
|
83
|
-
routeTree,
|
|
84
|
-
scrollRestoration,
|
|
85
|
-
defaultPreload,
|
|
86
|
-
trailingSlash,
|
|
87
|
-
context: context as any,
|
|
88
|
-
Wrap,
|
|
89
|
-
parseSearch: decoParseSearch,
|
|
90
|
-
stringifySearch: decoStringifySearch,
|
|
91
|
-
});
|
|
92
|
-
}
|
package/src/sdk/useHydrated.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Re-export of TanStack Router's `useHydrated` hook.
|
|
3
|
-
*
|
|
4
|
-
* Returns `false` during SSR and on the first client render (before hydration),
|
|
5
|
-
* then `true` for all subsequent renders. Use this instead of
|
|
6
|
-
* `typeof document === "undefined"` checks for conditional rendering.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```tsx
|
|
10
|
-
* import { useHydrated } from "@decocms/start/sdk/useHydrated";
|
|
11
|
-
*
|
|
12
|
-
* function CartButton() {
|
|
13
|
-
* const hydrated = useHydrated();
|
|
14
|
-
* if (!hydrated) return <CartSkeleton />;
|
|
15
|
-
* return <InteractiveCart />;
|
|
16
|
-
* }
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
export { useHydrated } from "@tanstack/react-router";
|