@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
package/src/vite/plugin.test.js
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
-
import { decoVitePlugin } from "./plugin.js";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* The Vite plugin's `resolveId` / `load` hooks are pure functions over their
|
|
6
|
-
* inputs, so we can exercise them without spinning up a Vite environment.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
function getPlugin() {
|
|
10
|
-
const result = decoVitePlugin();
|
|
11
|
-
// decoVitePlugin returns a single plugin object today, but the type is
|
|
12
|
-
// `PluginOption` which permits arrays — handle both.
|
|
13
|
-
return Array.isArray(result) ? result[0] : result;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
describe("decoVitePlugin SSR stubs", () => {
|
|
17
|
-
it("rewrites bare `fs` to a virtual module on SSR", () => {
|
|
18
|
-
const p = getPlugin();
|
|
19
|
-
const id = p.resolveId.call({}, "fs", undefined, { ssr: true });
|
|
20
|
-
expect(id).toBe("\0stub:bare-fs");
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it("does NOT rewrite bare `fs` on client (browser builds don't import fs)", () => {
|
|
24
|
-
const p = getPlugin();
|
|
25
|
-
const id = p.resolveId.call({}, "fs", undefined, { ssr: false });
|
|
26
|
-
expect(id).toBeUndefined();
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it("loads an empty surface for the bare-fs virtual module", () => {
|
|
30
|
-
const p = getPlugin();
|
|
31
|
-
const src = p.load.call({}, "\0stub:bare-fs", { ssr: true });
|
|
32
|
-
expect(src).toContain("export const promises = {}");
|
|
33
|
-
expect(src).toContain("export default");
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it("does not interfere with real SSR modules", () => {
|
|
37
|
-
const p = getPlugin();
|
|
38
|
-
expect(p.resolveId.call({}, "@decocms/start/cms", undefined, { ssr: true })).toBeUndefined();
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
describe("decoVitePlugin client stubs (regression guard)", () => {
|
|
43
|
-
it("still rewrites node:async_hooks on the client build", () => {
|
|
44
|
-
const p = getPlugin();
|
|
45
|
-
const id = p.resolveId.call({}, "node:async_hooks", undefined, { ssr: false });
|
|
46
|
-
expect(id).toBe("\0stub:node-async-hooks");
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it("does not rewrite client stubs on SSR", () => {
|
|
50
|
-
const p = getPlugin();
|
|
51
|
-
const id = p.resolveId.call({}, "react-dom/server", undefined, { ssr: true });
|
|
52
|
-
expect(id).toBeUndefined();
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
describe("decoVitePlugin __DECO_BUILD_HASH__ injection", () => {
|
|
57
|
-
let originalEnv;
|
|
58
|
-
|
|
59
|
-
beforeEach(() => {
|
|
60
|
-
originalEnv = { ...process.env };
|
|
61
|
-
delete process.env.WORKERS_CI_COMMIT_SHA;
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
afterEach(() => {
|
|
65
|
-
process.env = originalEnv;
|
|
66
|
-
vi.restoreAllMocks();
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
function callConfig(command) {
|
|
70
|
-
const p = getPlugin();
|
|
71
|
-
return p.config({}, { command });
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
it("injects the literal 'dev' for non-build commands", () => {
|
|
75
|
-
const cfg = callConfig("serve");
|
|
76
|
-
expect(cfg.define.__DECO_BUILD_HASH__).toBe(JSON.stringify("dev"));
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it("uses WORKERS_CI_COMMIT_SHA (sliced to 12 chars) when set on a build", () => {
|
|
80
|
-
process.env.WORKERS_CI_COMMIT_SHA = "abcdef1234567890fedcba";
|
|
81
|
-
const cfg = callConfig("build");
|
|
82
|
-
expect(cfg.define.__DECO_BUILD_HASH__).toBe(JSON.stringify("abcdef123456"));
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it("falls back to git rev-parse when WORKERS_CI_COMMIT_SHA is unset", async () => {
|
|
86
|
-
// The plugin module imports execFileSync at top-level, so we can't easily
|
|
87
|
-
// mock it after the fact. Instead, exercise the real git binary against
|
|
88
|
-
// this repo (CI runs in the repo working tree). Assert the value is a
|
|
89
|
-
// 12-char lowercase hex SHA — that proves git was consulted, not that
|
|
90
|
-
// the time-based fallback was hit.
|
|
91
|
-
const cfg = callConfig("build");
|
|
92
|
-
const value = JSON.parse(cfg.define.__DECO_BUILD_HASH__);
|
|
93
|
-
// Either git produced a SHA (CI / dev machine inside a repo) or the
|
|
94
|
-
// time-based fallback ran. Both are acceptable; we just assert non-empty
|
|
95
|
-
// and length sanity.
|
|
96
|
-
expect(typeof value).toBe("string");
|
|
97
|
-
expect(value.length).toBeGreaterThan(0);
|
|
98
|
-
// Time-based fallback produces base36 characters; git short SHAs are
|
|
99
|
-
// 12 hex chars. Both fit in this superset regex.
|
|
100
|
-
expect(value).toMatch(/^[0-9a-z]+$/);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it("preserves allowedHosts behaviour (regression: define is additive, not replacing)", () => {
|
|
104
|
-
process.env.DECO_SITE_NAME = "test-site";
|
|
105
|
-
try {
|
|
106
|
-
const cfg = callConfig("serve");
|
|
107
|
-
expect(cfg.server?.allowedHosts).toContain(".deco.studio");
|
|
108
|
-
expect(cfg.define.__DECO_BUILD_HASH__).toBeDefined();
|
|
109
|
-
} finally {
|
|
110
|
-
delete process.env.DECO_SITE_NAME;
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
});
|
package/src/vite/plugin.test.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { decoVitePlugin } from "./plugin.js";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Permanent regression test for the site-action/loader bundle leak.
|
|
6
|
-
*
|
|
7
|
-
* `.deco/loaders.gen.ts` registers every site loader/action behind a dynamic
|
|
8
|
-
* `import()` and is reachable from the CLIENT entry (router -> setup ->
|
|
9
|
-
* commerce-loaders -> loaders.gen). Without the client stub, Vite emits each
|
|
10
|
-
* loader/action module as a public client chunk, leaking the module source
|
|
11
|
-
* (including any hardcoded credential in it) into the browser assets.
|
|
12
|
-
*
|
|
13
|
-
* The load() hook must replace loaders.gen.ts with an empty `siteLoaders` on
|
|
14
|
-
* the client so those dynamic imports vanish from the client graph, while SSR
|
|
15
|
-
* keeps the real module (invoke runs server-side only). If this ever regresses,
|
|
16
|
-
* a token hardcoded in a site action becomes publicly downloadable again.
|
|
17
|
-
*/
|
|
18
|
-
describe("decoVitePlugin — loaders.gen client stub", () => {
|
|
19
|
-
// The plugin's load hook is a plain function that uses no `this`.
|
|
20
|
-
const plugin = decoVitePlugin() as {
|
|
21
|
-
load: (id: string, options?: { ssr?: boolean }) => string | undefined;
|
|
22
|
-
};
|
|
23
|
-
const id = "/repo/.deco/loaders.gen.ts";
|
|
24
|
-
|
|
25
|
-
it("stubs loaders.gen.ts to an empty siteLoaders in the CLIENT build", () => {
|
|
26
|
-
const out = plugin.load(id, { ssr: false });
|
|
27
|
-
expect(out).toBe("export const siteLoaders = {};");
|
|
28
|
-
// The stub must carry no dynamic import — that's the whole point.
|
|
29
|
-
expect(out).not.toMatch(/import\s*\(/);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it("leaves loaders.gen.ts untouched in the SSR build (real registry)", () => {
|
|
33
|
-
expect(plugin.load(id, { ssr: true })).toBeUndefined();
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it("defaults to the client (stubbed) behavior when ssr is unset", () => {
|
|
37
|
-
// Rollup/Vite may call load() without an options.ssr flag; the guard is
|
|
38
|
-
// `!options?.ssr`, so an absent flag must be treated as client.
|
|
39
|
-
expect(plugin.load(id)).toBe("export const siteLoaders = {};");
|
|
40
|
-
expect(plugin.load(id, {})).toBe("export const siteLoaders = {};");
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it("still stubs blocks.gen.ts on the client (existing behavior intact)", () => {
|
|
44
|
-
const out = plugin.load("/repo/.deco/blocks.gen.ts", { ssr: false });
|
|
45
|
-
expect(out).toBe("export const blocks = {};");
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it("does not touch unrelated modules", () => {
|
|
49
|
-
expect(plugin.load("/repo/src/sections/Hero.tsx", { ssr: false })).toBeUndefined();
|
|
50
|
-
expect(plugin.load("/repo/src/actions/foo.ts", { ssr: false })).toBeUndefined();
|
|
51
|
-
});
|
|
52
|
-
});
|