@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.
Files changed (150) hide show
  1. package/README.md +79 -0
  2. package/dist/draft.d.ts +33 -0
  3. package/dist/draft.d.ts.map +1 -0
  4. package/dist/draft.js +41 -0
  5. package/dist/draft.js.map +1 -0
  6. package/dist/index.d.ts +9 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +9 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/react/DecoDocument.d.ts +61 -0
  11. package/dist/react/DecoDocument.d.ts.map +1 -0
  12. package/dist/react/DecoDocument.js +96 -0
  13. package/dist/react/DecoDocument.js.map +1 -0
  14. package/dist/react/Image.d.ts +96 -0
  15. package/dist/react/Image.d.ts.map +1 -0
  16. package/dist/react/Image.js +79 -0
  17. package/dist/react/Image.js.map +1 -0
  18. package/dist/react/index.d.ts +7 -0
  19. package/dist/react/index.d.ts.map +1 -0
  20. package/dist/react/index.js +7 -0
  21. package/dist/react/index.js.map +1 -0
  22. package/dist/react/pageValues.d.ts +10 -0
  23. package/dist/react/pageValues.d.ts.map +1 -0
  24. package/dist/react/pageValues.js +29 -0
  25. package/dist/react/pageValues.js.map +1 -0
  26. package/dist/react/scripts.d.ts +14 -0
  27. package/dist/react/scripts.d.ts.map +1 -0
  28. package/dist/react/scripts.js +96 -0
  29. package/dist/react/scripts.js.map +1 -0
  30. package/dist/router/index.d.ts +38 -0
  31. package/dist/router/index.d.ts.map +1 -0
  32. package/dist/router/index.js +60 -0
  33. package/dist/router/index.js.map +1 -0
  34. package/dist/scope/browser.d.ts +11 -0
  35. package/dist/scope/browser.d.ts.map +1 -0
  36. package/dist/scope/browser.js +8 -0
  37. package/dist/scope/browser.js.map +1 -0
  38. package/dist/scope/server.d.ts +13 -0
  39. package/dist/scope/server.d.ts.map +1 -0
  40. package/dist/scope/server.js +26 -0
  41. package/dist/scope/server.js.map +1 -0
  42. package/dist/server/index.d.ts +27 -0
  43. package/dist/server/index.d.ts.map +1 -0
  44. package/dist/server/index.js +31 -0
  45. package/dist/server/index.js.map +1 -0
  46. package/dist/shared.d.ts +26 -0
  47. package/dist/shared.d.ts.map +1 -0
  48. package/dist/shared.js +26 -0
  49. package/dist/shared.js.map +1 -0
  50. package/dist/start/index.d.ts +9 -0
  51. package/dist/start/index.d.ts.map +1 -0
  52. package/dist/start/index.js +33 -0
  53. package/dist/start/index.js.map +1 -0
  54. package/dist/studio.d.ts +28 -0
  55. package/dist/studio.d.ts.map +1 -0
  56. package/dist/studio.js +53 -0
  57. package/dist/studio.js.map +1 -0
  58. package/dist/vite/index.d.ts +15 -0
  59. package/dist/vite/index.d.ts.map +1 -0
  60. package/dist/vite/index.js +95 -0
  61. package/dist/vite/index.js.map +1 -0
  62. package/dist/worker/cacheProfiles.d.ts +43 -0
  63. package/dist/worker/cacheProfiles.d.ts.map +1 -0
  64. package/dist/worker/cacheProfiles.js +162 -0
  65. package/dist/worker/cacheProfiles.js.map +1 -0
  66. package/dist/worker/cookies.d.ts +20 -0
  67. package/dist/worker/cookies.d.ts.map +1 -0
  68. package/dist/worker/cookies.js +69 -0
  69. package/dist/worker/cookies.js.map +1 -0
  70. package/dist/worker/drafts.d.ts +59 -0
  71. package/dist/worker/drafts.d.ts.map +1 -0
  72. package/dist/worker/drafts.js +140 -0
  73. package/dist/worker/drafts.js.map +1 -0
  74. package/dist/worker/index.d.ts +107 -0
  75. package/dist/worker/index.d.ts.map +1 -0
  76. package/dist/worker/index.js +511 -0
  77. package/dist/worker/index.js.map +1 -0
  78. package/dist/worker/security.d.ts +14 -0
  79. package/dist/worker/security.d.ts.map +1 -0
  80. package/dist/worker/security.js +48 -0
  81. package/dist/worker/security.js.map +1 -0
  82. package/dist/worker/segment.d.ts +21 -0
  83. package/dist/worker/segment.d.ts.map +1 -0
  84. package/dist/worker/segment.js +43 -0
  85. package/dist/worker/segment.js.map +1 -0
  86. package/package.json +86 -31
  87. package/src/draft.ts +43 -0
  88. package/src/index.ts +8 -44
  89. package/src/react/DecoDocument.tsx +234 -0
  90. package/src/react/Image.tsx +213 -0
  91. package/src/react/index.ts +24 -0
  92. package/src/react/pageValues.ts +35 -0
  93. package/src/react/scripts.ts +98 -0
  94. package/src/router/index.ts +80 -0
  95. package/src/scope/browser.ts +18 -0
  96. package/src/scope/server.ts +37 -0
  97. package/src/server/index.ts +43 -0
  98. package/src/shared.ts +29 -0
  99. package/src/start/index.ts +31 -0
  100. package/src/studio.ts +52 -0
  101. package/src/vite/index.ts +105 -0
  102. package/src/worker/cacheProfiles.ts +180 -0
  103. package/src/worker/cookies.ts +65 -0
  104. package/src/worker/drafts.ts +157 -0
  105. package/src/worker/index.ts +648 -0
  106. package/src/worker/security.ts +63 -0
  107. package/src/worker/segment.ts +49 -0
  108. package/src/cms/kvBlockSource.test.ts +0 -82
  109. package/src/cms/kvBlockSource.ts +0 -68
  110. package/src/daemon/auth.ts +0 -204
  111. package/src/daemon/fs.ts +0 -238
  112. package/src/daemon/index.ts +0 -8
  113. package/src/daemon/middleware.ts +0 -156
  114. package/src/daemon/tunnel.ts +0 -129
  115. package/src/daemon/volumes.ts +0 -366
  116. package/src/daemon/watch.ts +0 -272
  117. package/src/hooks/DecoPageRenderer.tsx +0 -688
  118. package/src/hooks/DecoRootLayout.tsx +0 -111
  119. package/src/hooks/NavigationProgress.tsx +0 -21
  120. package/src/hooks/PreviewProviders.tsx +0 -26
  121. package/src/hooks/StableOutlet.tsx +0 -30
  122. package/src/hooks/index.ts +0 -9
  123. package/src/routes/adminRoutes.test.ts +0 -99
  124. package/src/routes/adminRoutes.ts +0 -153
  125. package/src/routes/cmsRoute.test.ts +0 -100
  126. package/src/routes/cmsRoute.ts +0 -944
  127. package/src/routes/components.tsx +0 -57
  128. package/src/routes/index.ts +0 -24
  129. package/src/routes/pageUrl.test.ts +0 -70
  130. package/src/routes/pageUrl.ts +0 -54
  131. package/src/routes/withSiteGlobals.test.ts +0 -206
  132. package/src/routes/withSiteGlobals.ts +0 -222
  133. package/src/sdk/cookiePassthrough.ts +0 -58
  134. package/src/sdk/createInvoke.ts +0 -77
  135. package/src/sdk/deferredSectionLoader.test.ts +0 -94
  136. package/src/sdk/deferredSectionLoader.ts +0 -46
  137. package/src/sdk/kvHydration.test.ts +0 -215
  138. package/src/sdk/kvHydration.ts +0 -193
  139. package/src/sdk/outboundHeaders.test.ts +0 -113
  140. package/src/sdk/outboundHeaders.ts +0 -81
  141. package/src/sdk/router.ts +0 -92
  142. package/src/sdk/useHydrated.ts +0 -19
  143. package/src/sdk/workerEntry.test.ts +0 -495
  144. package/src/sdk/workerEntry.ts +0 -2307
  145. package/src/setupFastDeploy.ts +0 -13
  146. package/src/vite/plugin-scaffold-gen.test.js +0 -106
  147. package/src/vite/plugin.js +0 -850
  148. package/src/vite/plugin.test.js +0 -113
  149. package/src/vite/plugin.test.ts +0 -52
  150. package/tsconfig.json +0 -7
@@ -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
- });
@@ -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
- });
package/tsconfig.json DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "compilerOptions": {
4
- "outDir": "dist"
5
- },
6
- "include": ["src/**/*", "package.json"]
7
- }