@conloca/cloud-astro 0.2.4 → 0.2.6

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 (171) hide show
  1. package/README.md +69 -22
  2. package/dist/.build-inputs.json +36 -23
  3. package/dist/src/constants.d.ts +4 -4
  4. package/dist/src/constants.js +4 -4
  5. package/dist/src/d3-build.d.ts +6 -2
  6. package/dist/src/d3-build.d.ts.map +1 -1
  7. package/dist/src/d3-build.js +15 -11
  8. package/dist/src/d3-build.js.map +1 -1
  9. package/dist/src/d8-adapters.d.ts +10 -0
  10. package/dist/src/d8-adapters.d.ts.map +1 -0
  11. package/dist/src/d8-adapters.js +19 -0
  12. package/dist/src/d8-adapters.js.map +1 -0
  13. package/dist/src/d8-build.d.ts +99 -0
  14. package/dist/src/d8-build.d.ts.map +1 -0
  15. package/dist/src/d8-build.js +265 -0
  16. package/dist/src/d8-build.js.map +1 -0
  17. package/dist/src/d8-guards.d.ts +29 -0
  18. package/dist/src/d8-guards.d.ts.map +1 -0
  19. package/dist/src/d8-guards.js +145 -0
  20. package/dist/src/d8-guards.js.map +1 -0
  21. package/dist/src/d8-middleware.d.ts +7 -0
  22. package/dist/src/d8-middleware.d.ts.map +1 -0
  23. package/dist/src/d8-middleware.js +15 -0
  24. package/dist/src/d8-middleware.js.map +1 -0
  25. package/dist/src/d8-render.d.ts +9 -0
  26. package/dist/src/d8-render.d.ts.map +1 -0
  27. package/dist/src/d8-render.js +52 -0
  28. package/dist/src/d8-render.js.map +1 -0
  29. package/dist/src/doctor/checks-d8.d.ts +7 -0
  30. package/dist/src/doctor/checks-d8.d.ts.map +1 -0
  31. package/dist/src/doctor/checks-d8.js +240 -0
  32. package/dist/src/doctor/checks-d8.js.map +1 -0
  33. package/dist/src/doctor/checks-live.d.ts.map +1 -1
  34. package/dist/src/doctor/checks-live.js +3 -5
  35. package/dist/src/doctor/checks-live.js.map +1 -1
  36. package/dist/src/doctor/checks-offline.d.ts +2 -0
  37. package/dist/src/doctor/checks-offline.d.ts.map +1 -1
  38. package/dist/src/doctor/checks-offline.js +17 -8
  39. package/dist/src/doctor/checks-offline.js.map +1 -1
  40. package/dist/src/doctor/checks-preview-live.d.ts +7 -2
  41. package/dist/src/doctor/checks-preview-live.d.ts.map +1 -1
  42. package/dist/src/doctor/checks-preview-live.js +107 -7
  43. package/dist/src/doctor/checks-preview-live.js.map +1 -1
  44. package/dist/src/doctor/checks-preview.d.ts.map +1 -1
  45. package/dist/src/doctor/checks-preview.js +9 -4
  46. package/dist/src/doctor/checks-preview.js.map +1 -1
  47. package/dist/src/doctor/config-scan.d.ts +24 -6
  48. package/dist/src/doctor/config-scan.d.ts.map +1 -1
  49. package/dist/src/doctor/config-scan.js +89 -18
  50. package/dist/src/doctor/config-scan.js.map +1 -1
  51. package/dist/src/doctor/run.d.ts.map +1 -1
  52. package/dist/src/doctor/run.js +2 -0
  53. package/dist/src/doctor/run.js.map +1 -1
  54. package/dist/src/doctor/types.d.ts +7 -0
  55. package/dist/src/doctor/types.d.ts.map +1 -1
  56. package/dist/src/doctor/types.js +7 -0
  57. package/dist/src/doctor/types.js.map +1 -1
  58. package/dist/src/editor-page/emit.d.ts +4 -3
  59. package/dist/src/editor-page/emit.d.ts.map +1 -1
  60. package/dist/src/editor-page/emit.js +9 -9
  61. package/dist/src/editor-page/emit.js.map +1 -1
  62. package/dist/src/integration.d.ts.map +1 -1
  63. package/dist/src/integration.js +228 -124
  64. package/dist/src/integration.js.map +1 -1
  65. package/dist/src/node.d.ts +2 -0
  66. package/dist/src/node.d.ts.map +1 -1
  67. package/dist/src/node.js +4 -0
  68. package/dist/src/node.js.map +1 -1
  69. package/dist/src/preview/_resolve-opts.d.ts +26 -1
  70. package/dist/src/preview/_resolve-opts.d.ts.map +1 -1
  71. package/dist/src/preview/_resolve-opts.js.map +1 -1
  72. package/dist/src/preview/content-api.d.ts +15 -0
  73. package/dist/src/preview/content-api.d.ts.map +1 -1
  74. package/dist/src/preview/content-api.js +57 -6
  75. package/dist/src/preview/content-api.js.map +1 -1
  76. package/dist/src/preview/d8-middleware.d.ts +25 -0
  77. package/dist/src/preview/d8-middleware.d.ts.map +1 -0
  78. package/dist/src/preview/d8-middleware.js +94 -0
  79. package/dist/src/preview/d8-middleware.js.map +1 -0
  80. package/dist/src/preview/dispatcher.d.ts +3 -16
  81. package/dist/src/preview/dispatcher.d.ts.map +1 -1
  82. package/dist/src/preview/dispatcher.js +46 -134
  83. package/dist/src/preview/dispatcher.js.map +1 -1
  84. package/dist/src/preview/headers.d.ts +3 -0
  85. package/dist/src/preview/headers.d.ts.map +1 -1
  86. package/dist/src/preview/headers.js +10 -1
  87. package/dist/src/preview/headers.js.map +1 -1
  88. package/dist/src/preview/links.d.ts +23 -0
  89. package/dist/src/preview/links.d.ts.map +1 -0
  90. package/dist/src/preview/links.js +168 -0
  91. package/dist/src/preview/links.js.map +1 -0
  92. package/dist/src/preview/middleware.d.ts +9 -3
  93. package/dist/src/preview/middleware.d.ts.map +1 -1
  94. package/dist/src/preview/middleware.js +36 -16
  95. package/dist/src/preview/middleware.js.map +1 -1
  96. package/dist/src/preview/prefix-router.d.ts +67 -0
  97. package/dist/src/preview/prefix-router.d.ts.map +1 -0
  98. package/dist/src/preview/prefix-router.js +153 -0
  99. package/dist/src/preview/prefix-router.js.map +1 -0
  100. package/dist/src/preview/preview-path.d.ts +8 -3
  101. package/dist/src/preview/preview-path.d.ts.map +1 -1
  102. package/dist/src/preview/preview-path.js +16 -4
  103. package/dist/src/preview/preview-path.js.map +1 -1
  104. package/dist/src/preview/site-middleware.d.ts +8 -2
  105. package/dist/src/preview/site-middleware.d.ts.map +1 -1
  106. package/dist/src/preview/site-middleware.js +90 -31
  107. package/dist/src/preview/site-middleware.js.map +1 -1
  108. package/dist/src/preview/site-page-sources.d.ts +21 -0
  109. package/dist/src/preview/site-page-sources.d.ts.map +1 -0
  110. package/dist/src/preview/site-page-sources.js +129 -0
  111. package/dist/src/preview/site-page-sources.js.map +1 -0
  112. package/dist/src/preview/site-pages.d.ts +18 -0
  113. package/dist/src/preview/site-pages.d.ts.map +1 -0
  114. package/dist/src/preview/site-pages.js +7 -0
  115. package/dist/src/preview/site-pages.js.map +1 -0
  116. package/dist/src/preview-build.d.ts +17 -16
  117. package/dist/src/preview-build.d.ts.map +1 -1
  118. package/dist/src/preview-build.js +37 -40
  119. package/dist/src/preview-build.js.map +1 -1
  120. package/dist/src/preview-image-endpoint.d.ts +8 -0
  121. package/dist/src/preview-image-endpoint.d.ts.map +1 -0
  122. package/dist/src/preview-image-endpoint.js +34 -0
  123. package/dist/src/preview-image-endpoint.js.map +1 -0
  124. package/dist/src/preview-render-seams.d.ts +7 -0
  125. package/dist/src/preview-render-seams.d.ts.map +1 -0
  126. package/dist/src/preview-render-seams.js +27 -0
  127. package/dist/src/preview-render-seams.js.map +1 -0
  128. package/dist/src/site-middleware.d.ts +2 -4
  129. package/dist/src/site-middleware.d.ts.map +1 -1
  130. package/dist/src/site-middleware.js +6 -22
  131. package/dist/src/site-middleware.js.map +1 -1
  132. package/dist/src/types.d.ts +15 -16
  133. package/dist/src/types.d.ts.map +1 -1
  134. package/package.json +138 -6
  135. package/src/constants.ts +4 -4
  136. package/src/d3-build.ts +20 -14
  137. package/src/d8-adapters.ts +19 -0
  138. package/src/d8-build.ts +356 -0
  139. package/src/d8-guards.ts +177 -0
  140. package/src/d8-middleware.ts +17 -0
  141. package/src/d8-render.ts +61 -0
  142. package/src/doctor/checks-d8.ts +256 -0
  143. package/src/doctor/checks-live.ts +3 -4
  144. package/src/doctor/checks-offline.ts +21 -8
  145. package/src/doctor/checks-preview-live.ts +114 -8
  146. package/src/doctor/checks-preview.ts +9 -4
  147. package/src/doctor/config-scan.ts +86 -15
  148. package/src/doctor/run.ts +2 -0
  149. package/src/doctor/types.ts +8 -0
  150. package/src/editor-page/emit.ts +23 -14
  151. package/src/integration.ts +274 -135
  152. package/src/node.ts +4 -0
  153. package/src/preview/_resolve-opts.ts +17 -1
  154. package/src/preview/content-api.ts +60 -5
  155. package/src/preview/d8-middleware.ts +124 -0
  156. package/src/preview/dispatcher.ts +55 -150
  157. package/src/preview/headers.ts +10 -1
  158. package/src/preview/links.ts +175 -0
  159. package/src/preview/middleware.ts +41 -19
  160. package/src/preview/prefix-router.ts +197 -0
  161. package/src/preview/preview-path.ts +24 -6
  162. package/src/preview/site-middleware.ts +109 -38
  163. package/src/preview/site-page-sources.ts +146 -0
  164. package/src/preview/site-pages.ts +22 -0
  165. package/src/preview-build.ts +43 -42
  166. package/src/preview-image-endpoint.ts +35 -0
  167. package/src/preview-render-seams.ts +31 -0
  168. package/src/site-middleware.ts +6 -24
  169. package/src/skill/SKILL.md +19 -1
  170. package/src/types.ts +15 -16
  171. package/src/virtual-modules.d.ts +17 -2
@@ -2,29 +2,40 @@ import { spawn } from 'node:child_process';
2
2
  import { existsSync } from 'node:fs';
3
3
  import { join } from 'node:path';
4
4
  import { PACKAGE_NAME, PREVIEW_BUILD_ENV_FLAG, PREVIEW_MODE_ENV, PREVIEW_PRERENDERED_ENV, REFUSED_PREVIEW_ADAPTERS, } from './constants.js';
5
+ /** Why `separate: true` cannot work under an adapter that deploys from the project root. Doctor's CC26 reuses it. */
6
+ export function separateRefusal(adapterName) {
7
+ return (`previewBuild.separate is not supported with ${adapterName}: the separate preview build would write its output ` +
8
+ `where ${adapterName} deploys the live site. Remove separate: true; with ${adapterName} drafts render in the ` +
9
+ "site's own build.");
10
+ }
5
11
  /**
6
- * How the preview build serves, from the options and the adapter the preview server would build with
7
- * (`previewBuild.adapter`, else the project's own): off unless `previewBuild` is given as an object; D4 with
8
- * `separate: true`; D3 for a static site, whose preview server runs next to it on Cloudflare Workers; D2 when an
9
- * adapter is named, since the site's own server deploy serves the drafts. Throws for a refused adapter, so the build
10
- * fails before it deploys anything.
12
+ * How drafts are served, from the options and the project's adapter: off unless `previewBuild` is given as an
13
+ * object; D4 with `separate: true`; D3 for a static site, whose preview server runs next to it on Cloudflare
14
+ * Workers; D8 when an adapter is named, since drafts render in the site's own build. Throws for options that cannot
15
+ * work: `separate` under an adapter that deploys from the project root, and `previewBuild.adapter`
16
+ * (`previewAdapterName`) at all.
11
17
  */
12
- export function previewBuildMode(previewBuild, adapterName) {
18
+ export function previewBuildMode(previewBuild, adapterName, previewAdapterName) {
13
19
  if (!previewBuild)
14
20
  return 'off';
15
- if (adapterName !== undefined && REFUSED_PREVIEW_ADAPTERS.includes(adapterName)) {
16
- throw new Error(`${PACKAGE_NAME}: previewBuild is not supported with ${adapterName} yet: that adapter writes its deployable ` +
17
- 'output at the project root, so the preview build could replace the live site. ' +
18
- 'Remove previewBuild from conlocaCloud(...).');
21
+ if (previewAdapterName !== undefined) {
22
+ throw new Error(`${PACKAGE_NAME}: previewBuild.adapter has no effect: drafts render in the site's own build, through the ` +
23
+ 'adapter in astro.config. Remove previewBuild.adapter.');
19
24
  }
20
- if (previewBuild.separate === true)
25
+ if (previewBuild.separate === true) {
26
+ if (adapterName !== undefined && REFUSED_PREVIEW_ADAPTERS.includes(adapterName)) {
27
+ throw new Error(`${PACKAGE_NAME}: ${separateRefusal(adapterName)}`);
28
+ }
21
29
  return 'd4';
22
- return adapterName === undefined ? 'd3' : 'd2';
30
+ }
31
+ return adapterName === undefined ? 'd3' : 'd8';
23
32
  }
24
- /** The mode a preview build serves in: the site's build names D2 or D3; the flag alone is a separate preview deploy (D4). */
33
+ /**
34
+ * The mode a preview build serves in: the site's build names D3; anything else is a separate preview deploy (D4),
35
+ * the flag alone included. A `d2` from an older release's parent is no child mode any more.
36
+ */
25
37
  export function previewChildMode(env) {
26
- const named = env[PREVIEW_MODE_ENV];
27
- return named === 'd2' || named === 'd3' ? named : 'd4';
38
+ return env[PREVIEW_MODE_ENV] === 'd3' ? 'd3' : 'd4';
28
39
  }
29
40
  /**
30
41
  * One route the site's build prerendered, as a D3 child matches it: pattern and component together, since one
@@ -57,13 +68,13 @@ export function previewChildPrerendered(env) {
57
68
  * build vars (CF_PAGES_*, WORKERS_CI_*, GITHUB_*) reach the child, which reads
58
69
  * the branch and commit it serves from them.
59
70
  */
60
- export function buildPreviewChildEnv(parentEnv, mode = 'd2', prerendered = []) {
61
- const env = { ...parentEnv, [PREVIEW_BUILD_ENV_FLAG]: '1', [PREVIEW_MODE_ENV]: mode };
62
- // Only a D3 child reads it; a stale one from the environment must not reach a D2 child.
63
- delete env[PREVIEW_PRERENDERED_ENV];
64
- if (mode === 'd3')
65
- env[PREVIEW_PRERENDERED_ENV] = JSON.stringify(prerendered);
66
- return env;
71
+ export function buildPreviewChildEnv(parentEnv, mode, prerendered = []) {
72
+ return {
73
+ ...parentEnv,
74
+ [PREVIEW_BUILD_ENV_FLAG]: '1',
75
+ [PREVIEW_MODE_ENV]: mode,
76
+ [PREVIEW_PRERENDERED_ENV]: JSON.stringify(prerendered),
77
+ };
67
78
  }
68
79
  /**
69
80
  * Locate the `astro` CLI binary in the site's `node_modules/.bin/`. We
@@ -102,12 +113,9 @@ export function resolveAstroBin(cwd = process.cwd()) {
102
113
  * env flag is already set to `'1'`), it returns immediately without spawning,
103
114
  * which is the outermost layer of the recursion guard.
104
115
  *
105
- * On a non-zero child exit, behaviour depends on {@link PreviewBuildOptions.required}:
106
- * - `true` (default) → rejects with an error naming the exit code.
107
- * - `false` → resolves and logs a warning so onboarding setups can continue
108
- * when the preview build is not yet wired correctly.
116
+ * A non-zero child exit rejects with an error naming the exit code; the caller decides whether the site's build fails.
109
117
  */
110
- export async function spawnPreviewBuild(opts, mode = 'd2', prerendered = []) {
118
+ export async function spawnPreviewBuild(opts, mode, prerendered = []) {
111
119
  await _spawnPreviewBuildWith(spawn, opts, mode, prerendered);
112
120
  }
113
121
  /**
@@ -119,14 +127,13 @@ export async function spawnPreviewBuild(opts, mode = 'd2', prerendered = []) {
119
127
  * `src/index.ts` or `src/node.ts`.
120
128
  */
121
129
  // oxlint-disable-next-line no-underscore-dangle -- the internal test seam.
122
- export async function _spawnPreviewBuildWith(spawnFn, opts, mode = 'd2', prerendered = []) {
130
+ export async function _spawnPreviewBuildWith(spawnFn, opts, mode, prerendered = []) {
123
131
  // Recursion guard: bail out before doing any work if we're already inside
124
132
  // a recursive preview build. This matches the short-circuit in the
125
133
  // integration's `astro:build:done` hook.
126
134
  if (process.env[PREVIEW_BUILD_ENV_FLAG] === '1') {
127
135
  return;
128
136
  }
129
- const required = opts.required ?? true;
130
137
  const astroBin = resolveAstroBin();
131
138
  const child = spawnFn(astroBin, ['build'], {
132
139
  env: buildPreviewChildEnv(process.env, mode, prerendered),
@@ -139,17 +146,7 @@ export async function _spawnPreviewBuildWith(spawnFn, opts, mode = 'd2', prerend
139
146
  return;
140
147
  }
141
148
  const reason = code === null ? 'signal' : `exit ${code}`;
142
- if (required) {
143
- reject(new Error(`${PACKAGE_NAME}: preview build failed (${reason})`));
144
- return;
145
- }
146
- // Soft-fail path — opt-in via `previewBuild.required = false`. Use
147
- // console.warn rather than the Astro logger because the spawn helper is
148
- // pure: the integration's `astro:build:done` may evolve to pass a
149
- // logger down, but until it does, warn keeps the signal
150
- // visible without leaking a logger dependency into the spawn module.
151
- console.warn(`${PACKAGE_NAME}: preview build failed (${reason}); previewBuild.required=false, continuing`);
152
- resolve();
149
+ reject(new Error(`${PACKAGE_NAME}: preview build failed (${reason})`));
153
150
  });
154
151
  });
155
152
  }
@@ -1 +1 @@
1
- {"version":3,"file":"preview-build.js","sourceRoot":"","sources":["../../src/preview-build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EACL,YAAY,EACZ,sBAAsB,EACtB,gBAAgB,EAChB,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,gBAAgB,CAAC;AAIxB;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAC9B,YAAqD,EACrD,WAA+B;IAE/B,IAAI,C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B,CAC1C,OAA0B,EAC1B,IAAyB,EACzB,IAAU,EACV,WAAW,GAAsB,EAAE;IAEnC,0EAA0E;IAC1E,mEAAmE;IACnE,yCAAyC;IACzC,IAAI,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,KAAK,GAAG,EAAE,CAAC;QAChD,OAAO;IACT,CAAC;IAED,MAAM,QAAQ,GAAG,eAAe,EAAE,CAAC;IACnC,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE;QACzC,GAAG,EAAE,oBAAoB,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,WAAW,CAAC;QACzD,KAAK,EAAE,SAAS;KACjB,CAAC,CAAC;IAEH,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC1C,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAmB,EAAE,EAAE;YACvC,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;gBACf,OAAO,EAAE,CAAC;gBACV,OAAO;YACT,CAAC;YACD,MAAM,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,IAAI,EAAE,CAAC;YACzD,MAAM,CAAC,IAAI,KAAK,CAAC,GAAG,YAAY,2BAA2B,MAAM,GAAG,CAAC,CAAC,CAAC;QACzE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The image endpoint a d8 draft page uses, at `<base>_conloca/preview/_image` on Vercel, Netlify and Node: it answers
3
+ * with a redirect to the original image, so drafts get untransformed images and the site's own `/_image` stays as it
4
+ * was. It never fetches: only a same-origin path or a host the site's `image` config allows is redirected to.
5
+ */
6
+ import type { APIContext } from 'astro';
7
+ export declare const GET: ({ url }: Pick<APIContext, 'url'>) => Response;
8
+ //# sourceMappingURL=preview-image-endpoint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview-image-endpoint.d.ts","sourceRoot":"","sources":["../../src/preview-image-endpoint.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAY,MAAM,OAAO,CAAC;AAIlD,eAAO,MAAM,GAAG,YAAc,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,aAehC,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * The image endpoint a d8 draft page uses, at `<base>_conloca/preview/_image` on Vercel, Netlify and Node: it answers
3
+ * with a redirect to the original image, so drafts get untransformed images and the site's own `/_image` stays as it
4
+ * was. It never fetches: only a same-origin path or a host the site's `image` config allows is redirected to.
5
+ */
6
+ import { imageConfig } from 'astro:assets';
7
+ import { isRemoteAllowed } from 'astro/assets/utils';
8
+ import { applyPreviewHeaders } from './preview/headers.js';
9
+ export const GET = (({ url }) => {
10
+ const href = url.searchParams.get('href') ?? '';
11
+ const target = URL.canParse(href, url.href) ? new URL(href, url) : null;
12
+ // `//host` and `/\host` resolve off-origin, so the origin check catches them; decoded, `%5Fimage` is our own route.
13
+ const local = href.startsWith('/') && target?.origin === url.origin && safeDecode(target.pathname) !== safeDecode(url.pathname);
14
+ const remote = /^https?:\/\//iu.test(href) && isRemoteAllowed(href, imageConfig);
15
+ try {
16
+ // The Location comes from the parsed URL, so no raw input reaches the header.
17
+ const location = local ? `${target.pathname}${target.search}` : remote && target ? target.href : null;
18
+ if (location !== null)
19
+ return applyPreviewHeaders(new Response(null, { status: 302, headers: { location } }));
20
+ }
21
+ catch {
22
+ // An invalid header value: refused below.
23
+ }
24
+ return applyPreviewHeaders(new Response(null, { status: 403 }));
25
+ });
26
+ function safeDecode(path) {
27
+ try {
28
+ return decodeURIComponent(path);
29
+ }
30
+ catch {
31
+ return null;
32
+ }
33
+ }
34
+ //# sourceMappingURL=preview-image-endpoint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview-image-endpoint.js","sourceRoot":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G,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC;IAChH,CAAC;IAAC,MAAM,CAAC;QACP,0CAA0C;IAC5C,CAAC;IACD,OAAO,mBAAmB,CAAC,IAAI,QAAQ,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;AAClE,CAAC,CAAoB,CAAC;AAEtB,SAAS,UAAU,CAAC,IAAY;IAC9B,IAAI,CAAC;QACH,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The render seams a preview render takes from the site's own build graph: `astro:content` and the routing-config
3
+ * virtual module only resolve there, so the D2/D3 site middleware and the d8 render both build them here.
4
+ */
5
+ import type { PreviewRenderSeams } from './preview/site-middleware.js';
6
+ export declare function previewRenderSeams(): Promise<PreviewRenderSeams>;
7
+ //# sourceMappingURL=preview-render-seams.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview-render-seams.d.ts","sourceRoot":"","sources":["../../src/preview-render-seams.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAavE,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAOtE"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * The render seams a preview render takes from the site's own build graph: `astro:content` and the routing-config
3
+ * virtual module only resolve there, so the D2/D3 site middleware and the d8 render both build them here.
4
+ */
5
+ import { getCollection } from 'astro:content';
6
+ import routingConfig from 'virtual:conloca-routing-config';
7
+ import { createCollectionBackedContentAPI } from '@conloca/astro-cms';
8
+ import { resolveEndpointFetch } from './preview/_resolve-opts.js';
9
+ // One baseline per process: the built collections are immutable at runtime,
10
+ // and constructing the collection-backed reader walks every collection.
11
+ let baselinePromise;
12
+ function baselineApi() {
13
+ baselinePromise ??= createCollectionBackedContentAPI({
14
+ getCollection: (name) => getCollection(name),
15
+ routing: routingConfig,
16
+ });
17
+ return baselinePromise;
18
+ }
19
+ export async function previewRenderSeams() {
20
+ return {
21
+ baselineApi,
22
+ site: routingConfig.siteName,
23
+ locale: routingConfig.locale,
24
+ fetchFn: await resolveEndpointFetch(),
25
+ };
26
+ }
27
+ //# sourceMappingURL=preview-render-seams.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview-render-seams.js","sourceRoot":"","sources":["../../src/preview-render-seams.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,aAAa,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,gCAAgC,EAAE,MAAM,oBAAoB,CAAC;AAEtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAGlE,4EAA4E;AAC5E,wEAAwE;AACxE,IAAI,eAAgD,CAAC;AACrD,SAAS,WAAW;IAClB,eAAe,KAAK,gCAAgC,CAAC;QACnD,aAAa,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC;QAC5C,OAAO,EAAE,aAAa;KACvB,CAAC,CAAC;IACH,OAAO,eAAe,CAAC;AACzB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB;IACtC,OAAO;QACL,WAAW;QACX,IAAI,EAAE,aAAa,CAAC,QAAQ;QAC5B,MAAM,EAAE,aAAa,CAAC,MAAM;QAC5B,OAAO,EAAE,MAAM,oBAAoB,EAAE;KACtC,CAAC;AACJ,CAAC"}
@@ -5,10 +5,8 @@
5
5
  * the integration resolves to this module, so it must export `onRequest` —
6
6
  * Astro's middleware contract. The verdict/render logic lives in
7
7
  * `./preview/site-middleware.ts`, which is env-free and unit-testable; this
8
- * file binds it to the runtime env resolution and to the site's own build
9
- * graph: `astro:content` and the routing-config virtual module only resolve
10
- * here, so the collection-backed baseline is constructed here and injected as
11
- * a seam.
8
+ * file binds it to the runtime env resolution and to the render seams built
9
+ * from the site's own build graph (`./preview-render-seams.ts`).
12
10
  *
13
11
  * Mounted ONLY inside the preview build (see `integration.ts`), never in the
14
12
  * site's production build.
@@ -1 +1 @@
1
- {"version":3,"file":"site-middleware.d.ts","sourceRoot":"","sources":["../../src/site-middleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAQH,OAAO,EAEL,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,EAC3B,MAAM,8BAA8B,CAAC;AAoBtC,wBAAsB,SAAS,CAAC,OAAO,EAAE,wBAAwB,EAAE,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAQjH"}
1
+ {"version":3,"file":"site-middleware.d.ts","sourceRoot":"","sources":["../../src/site-middleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,EAEL,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,EAC3B,MAAM,8BAA8B,CAAC;AAUtC,wBAAsB,SAAS,CAAC,OAAO,EAAE,wBAAwB,EAAE,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAMjH"}
@@ -5,42 +5,26 @@
5
5
  * the integration resolves to this module, so it must export `onRequest` —
6
6
  * Astro's middleware contract. The verdict/render logic lives in
7
7
  * `./preview/site-middleware.ts`, which is env-free and unit-testable; this
8
- * file binds it to the runtime env resolution and to the site's own build
9
- * graph: `astro:content` and the routing-config virtual module only resolve
10
- * here, so the collection-backed baseline is constructed here and injected as
11
- * a seam.
8
+ * file binds it to the runtime env resolution and to the render seams built
9
+ * from the site's own build graph (`./preview-render-seams.ts`).
12
10
  *
13
11
  * Mounted ONLY inside the preview build (see `integration.ts`), never in the
14
12
  * site's production build.
15
13
  */
16
- import { getCollection } from 'astro:content';
17
14
  import baked from 'virtual:conloca-preview-opts';
18
- import routingConfig from 'virtual:conloca-routing-config';
19
- import { createCollectionBackedContentAPI } from '@conloca/astro-cms';
20
- import { resolveEndpointFetch, resolveFromBaked } from './preview/_resolve-opts.js';
15
+ import { resolveFromBaked } from './preview/_resolve-opts.js';
21
16
  import { createPreviewSiteMiddleware, } from './preview/site-middleware.js';
22
17
  import { untagWorkerdProcess } from './preview/workerd-shim.js';
18
+ import { previewRenderSeams } from './preview-render-seams.js';
23
19
  // At Cloudflare Worker start-up, before any render: workerd's nodejs_compat
24
20
  // process can masquerade as Node's, sending Astro down a streaming branch whose
25
21
  // body the Cloudflare Workers Response cannot consume — every on-demand page then renders as the
26
22
  // literal string "[object Object]". See the shim's doc for the full chain.
27
23
  untagWorkerdProcess();
28
- // One baseline per process: the built collections are immutable at runtime,
29
- // and constructing the collection-backed reader walks every collection.
30
- let baselinePromise;
31
- function baselineApi() {
32
- baselinePromise ??= createCollectionBackedContentAPI({
33
- getCollection: (name) => getCollection(name),
34
- routing: routingConfig,
35
- });
36
- return baselinePromise;
37
- }
38
24
  export async function onRequest(context, next) {
39
25
  const handler = createPreviewSiteMiddleware(() => resolveFromBaked(baked, (name) => process.env[name]), {
40
- baselineApi,
41
- site: routingConfig.siteName,
42
- locale: routingConfig.locale,
43
- fetchFn: await resolveEndpointFetch(),
26
+ ...(await previewRenderSeams()),
27
+ baked,
44
28
  });
45
29
  return handler(context, next);
46
30
  }
@@ -1 +1 @@
1
- {"version":3,"file":"site-middleware.js","sourceRoot":"","sources":["../../src/site-middleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,MAAM,8BAA8B,CAAC;AACjD,OAAO,aAAa,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,gCAAgC,EAAE,MAAM,oBAAoB,CAAC;AAEtE,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACpF,OA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,4EAA4E;AAC5E,gFAAgF;AAChF,iGAAiG;AACjG,2EAA2E;AAC3E,mBAAmB,EAAE,CAAC;AAEtB,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,OAAiC,EAAE,IAA2B;IAC5F,MAAM,OAAO,GAAG,2BAA2B,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE;QACtG,GAAG,CAAC,MAAM,kBAAkB,EAAE,CAAC;QAC/B,KAAK;KACN,CAAC,CAAC;IACH,OAAO,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AAChC,CAAC"}
@@ -1,31 +1,30 @@
1
1
  import type { AstroIntegration } from 'astro';
2
2
  /**
3
- * The second build that serves draft previews. Off unless given as an object. A static site's preview server runs on
4
- * Cloudflare Workers under `/_conloca/preview/` next to the site (it needs `@astrojs/cloudflare` installed); a site
5
- * with an adapter serves drafts from its own server deploy; `separate: true` builds a separate preview deploy.
6
- * Refused under `@astrojs/vercel` and `@astrojs/netlify`.
3
+ * Draft previews. Off unless given as an object. A static site's preview server is a second build that runs on
4
+ * Cloudflare Workers under `/_conloca/preview/` next to the site (D3; it needs `@astrojs/cloudflare` installed); a site
5
+ * with an adapter renders drafts in its own build (D8); `separate: true` builds a separate preview deploy (D4).
6
+ * `config` and `outDir` belong to D3 and D4 only (a D8 build warns they have no effect); `required` is ignored in every
7
+ * mode, with a warning. `separate` is
8
+ * refused under `@astrojs/vercel` and `@astrojs/netlify`.
7
9
  */
8
10
  export interface PreviewBuildOptions {
9
- /**
10
- * Optional alternative Astro adapter to use for the preview build.
11
- * Falls back to the project's default adapter when omitted.
12
- */
11
+ /** Refused: drafts render through the adapter in astro.config. Kept in the type so the refusal can name it. */
13
12
  adapter?: AstroIntegration;
14
13
  /**
15
- * Adapter-specific config overrides forwarded to the recursive build.
14
+ * Adapter-specific config overrides forwarded to the D3 or D4 preview build.
16
15
  */
17
16
  config?: Record<string, unknown>;
18
17
  /**
19
- * Output directory for the preview build. Defaults to `.conloca/preview-server`
18
+ * Output directory for the D3 or D4 preview build. Defaults to `.conloca/preview-server`
20
19
  * — outside `dist/`, so the preview server can never ride a wholesale static
21
20
  * upload of the site and Astro's dist-clearing cannot wipe it.
22
21
  */
23
22
  outDir?: string;
24
23
  /**
25
- * If true, fail the site's build when a D2 preview build fails. Defaults to true; set false while setting up.
26
- * A failed D3 preview build fails the site's build only when its server also serves the live site (`run_worker_first`
27
- * lists routes beyond the preview route, or `not_found_handling` is `"none"`); otherwise the site ships and its
28
- * preview route answers "preview unavailable". This option changes neither.
24
+ * Ignored in every mode (the build warns). A failed D3 preview build fails the site's build only when its server also
25
+ * serves the live site (`run_worker_first` lists routes beyond the preview route, or `not_found_handling` is
26
+ * `"none"`); otherwise the site ships and its preview route answers "preview unavailable". A D4 build is its deploy's
27
+ * own.
29
28
  */
30
29
  required?: boolean;
31
30
  /**
@@ -77,8 +76,8 @@ export interface ConlocaCloudOptions {
77
76
  */
78
77
  siteStyles?: string | string[];
79
78
  /**
80
- * Off unless given as an object; the second build that serves draft
81
- * previews. Refused under @astrojs/vercel and @astrojs/netlify.
79
+ * Off unless given as an object: draft previews in the site's own build (d8, with an adapter), next to a static
80
+ * site (D3) or from a separate deploy (D4). `separate` is refused under @astrojs/vercel and @astrojs/netlify.
82
81
  */
83
82
  previewBuild?: PreviewBuildOptions | false;
84
83
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACj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AC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;;;;;OAUG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC/B;;;OAGG;IACH,YAAY,CAAC,EAAE,mBAAmB,GAAG,KAAK,CAAC;IAC3C;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@conloca/cloud-astro",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -43,6 +43,16 @@
43
43
  "import": "./dist/src/site-middleware.js",
44
44
  "default": "./dist/src/site-middleware.js"
45
45
  },
46
+ "./d8-middleware": {
47
+ "types": "./dist/src/d8-middleware.d.ts",
48
+ "import": "./dist/src/d8-middleware.js",
49
+ "default": "./dist/src/d8-middleware.js"
50
+ },
51
+ "./preview-image-endpoint": {
52
+ "types": "./dist/src/preview-image-endpoint.d.ts",
53
+ "import": "./dist/src/preview-image-endpoint.js",
54
+ "default": "./dist/src/preview-image-endpoint.js"
55
+ },
46
56
  "./dispatcher": {
47
57
  "types": "./dist/src/preview/dispatcher.d.ts",
48
58
  "import": "./dist/src/preview/dispatcher.js",
@@ -74,14 +84,15 @@
74
84
  },
75
85
  "peerDependencies": {
76
86
  "@astrojs/react": "^6.0.5",
77
- "@conloca/astro-cms": "0.2.4",
87
+ "@conloca/astro-cms": "0.2.6",
78
88
  "astro": "^7.3.1",
79
89
  "vite": "^8.2.2"
80
90
  },
81
91
  "dependencies": {
82
- "@conloca/content-api": "0.2.4",
83
- "@conloca/mdx": "0.2.4",
92
+ "@conloca/content-api": "0.2.6",
93
+ "@conloca/mdx": "0.2.6",
84
94
  "hast-util-from-html": "^2.0.3",
95
+ "htmlparser2": "^10.1.0",
85
96
  "jose": "^6.2.10",
86
97
  "jsonc-parser": "^3.3.1",
87
98
  "sass": "^1.103.1",
@@ -90,9 +101,13 @@
90
101
  "devDependencies": {
91
102
  "@astrojs/check": "^0.9.10",
92
103
  "@astrojs/cloudflare": "14.3.2",
104
+ "@astrojs/netlify": "8.2.11",
105
+ "@astrojs/node": "11.1.9",
93
106
  "@astrojs/sitemap": "^3.7.3",
94
- "@conloca/astro-cms": "0.2.4",
107
+ "@astrojs/vercel": "11.0.18",
108
+ "@conloca/astro-cms": "0.2.6",
95
109
  "astro": "^7.3.1",
110
+ "sharp": "^0.35.4",
96
111
  "typescript": "^6.0.3",
97
112
  "vite": "^8.2.2",
98
113
  "wrangler": "^4.130.0"
@@ -154,7 +169,11 @@
154
169
  "build",
155
170
  "test-packed",
156
171
  "test-editor-build",
157
- "test-preview-build"
172
+ "test-preview-build",
173
+ "test-preview-vercel",
174
+ "test-preview-netlify",
175
+ "test-preview-node",
176
+ "test-preview-cloudflare"
158
177
  ],
159
178
  "inputs": [
160
179
  "{projectRoot}/**/*",
@@ -207,6 +226,119 @@
207
226
  "killAfterMs": 10000
208
227
  }
209
228
  },
229
+ "test-preview-vercel": {
230
+ "//": "Real d8 builds of every fixture shape with @astrojs/vercel, preview on and off, asserted on the output.",
231
+ "executor": "@smoothbricks/nx-plugin:bounded-exec",
232
+ "cache": true,
233
+ "inputs": [
234
+ "default",
235
+ "^production",
236
+ "{workspaceRoot}/bun.lock"
237
+ ],
238
+ "dependsOn": [
239
+ "build",
240
+ "^build"
241
+ ],
242
+ "options": {
243
+ "command": "bun test --timeout=600000 ./test-preview-hosts",
244
+ "cwd": "{projectRoot}",
245
+ "env": {
246
+ "CONLOCA_FIXTURE_ADAPTER": "vercel"
247
+ },
248
+ "timeoutMs": 900000,
249
+ "killAfterMs": 10000
250
+ }
251
+ },
252
+ "test-preview-netlify": {
253
+ "//": "Real d8 builds of every fixture shape with @astrojs/netlify, preview on and off, asserted on the output.",
254
+ "executor": "@smoothbricks/nx-plugin:bounded-exec",
255
+ "cache": true,
256
+ "inputs": [
257
+ "default",
258
+ "^production",
259
+ "{workspaceRoot}/bun.lock"
260
+ ],
261
+ "dependsOn": [
262
+ "build",
263
+ "^build"
264
+ ],
265
+ "options": {
266
+ "command": "bun test --timeout=600000 ./test-preview-hosts",
267
+ "cwd": "{projectRoot}",
268
+ "env": {
269
+ "CONLOCA_FIXTURE_ADAPTER": "netlify"
270
+ },
271
+ "timeoutMs": 900000,
272
+ "killAfterMs": 10000
273
+ }
274
+ },
275
+ "test-preview-node": {
276
+ "//": "Real d8 builds of every fixture shape with @astrojs/node, preview on and off, asserted on the output.",
277
+ "executor": "@smoothbricks/nx-plugin:bounded-exec",
278
+ "cache": true,
279
+ "inputs": [
280
+ "default",
281
+ "^production",
282
+ "{workspaceRoot}/bun.lock"
283
+ ],
284
+ "dependsOn": [
285
+ "build",
286
+ "^build"
287
+ ],
288
+ "options": {
289
+ "command": "bun test --timeout=600000 ./test-preview-hosts",
290
+ "cwd": "{projectRoot}",
291
+ "env": {
292
+ "CONLOCA_FIXTURE_ADAPTER": "node"
293
+ },
294
+ "timeoutMs": 900000,
295
+ "killAfterMs": 10000
296
+ }
297
+ },
298
+ "test-preview-cloudflare": {
299
+ "//": "Real d8 builds of every fixture shape with @astrojs/cloudflare, preview on and off, asserted on the output.",
300
+ "executor": "@smoothbricks/nx-plugin:bounded-exec",
301
+ "cache": true,
302
+ "inputs": [
303
+ "default",
304
+ "^production",
305
+ "{workspaceRoot}/bun.lock"
306
+ ],
307
+ "dependsOn": [
308
+ "build",
309
+ "^build"
310
+ ],
311
+ "options": {
312
+ "command": "bun test --timeout=600000 ./test-preview-hosts",
313
+ "cwd": "{projectRoot}",
314
+ "env": {
315
+ "CONLOCA_FIXTURE_ADAPTER": "cloudflare"
316
+ },
317
+ "timeoutMs": 900000,
318
+ "killAfterMs": 10000
319
+ }
320
+ },
321
+ "test-preview-timing": {
322
+ "//": "The d8 build-time guard (under 3x the no-preview build, every adapter). A wall-clock ratio needs a quiet machine, so it runs with no other task beside it and is not a dependency of `test`: the release lane runs `test` on a shared runner. tooling:test depends on it, so CI runs it whenever this package changes.",
323
+ "executor": "@smoothbricks/nx-plugin:bounded-exec",
324
+ "cache": true,
325
+ "parallelism": false,
326
+ "inputs": [
327
+ "default",
328
+ "^production",
329
+ "{workspaceRoot}/bun.lock"
330
+ ],
331
+ "dependsOn": [
332
+ "build",
333
+ "^build"
334
+ ],
335
+ "options": {
336
+ "command": "bun test --timeout=600000 ./test-preview-timing",
337
+ "cwd": "{projectRoot}",
338
+ "timeoutMs": 900000,
339
+ "killAfterMs": 10000
340
+ }
341
+ },
210
342
  "test-packed": {
211
343
  "//": "The packed shape is a function of the built outputs, the manifest and the locked dependency closure; cached on exactly those.",
212
344
  "executor": "nx:run-commands",
package/src/constants.ts CHANGED
@@ -11,7 +11,7 @@ export const PACKAGE_NAME = '@conloca/cloud-astro';
11
11
  export const PREVIEW_BUILD_ENV_FLAG = 'CONLOCA_PREVIEW_BUILD';
12
12
 
13
13
  /**
14
- * Environment variable the site's build names the child's mode in (`d2` or `d3`). A build started with
14
+ * Environment variable the site's build names the child's mode in (`d3`). A build started with
15
15
  * {@link PREVIEW_BUILD_ENV_FLAG} alone, as a separate preview deploy runs it, has none: it is D4.
16
16
  */
17
17
  export const PREVIEW_MODE_ENV = 'CONLOCA_PREVIEW_MODE';
@@ -23,8 +23,8 @@ export const PREVIEW_MODE_ENV = 'CONLOCA_PREVIEW_MODE';
23
23
  export const PREVIEW_PRERENDERED_ENV = 'CONLOCA_PREVIEW_PRERENDERED';
24
24
 
25
25
  /**
26
- * Adapters the preview build is refused under: they write their deployable
27
- * output at the project root whatever `outDir` says, so the preview build
28
- * could replace the live site.
26
+ * Adapters the separate preview build (D4) is refused under: they write their
27
+ * deployable output at the project root whatever `outDir` says, so the
28
+ * preview build could replace the live site.
29
29
  */
30
30
  export const REFUSED_PREVIEW_ADAPTERS: readonly string[] = ['@astrojs/vercel', '@astrojs/netlify'];