@conloca/cloud-astro 0.2.2 → 0.2.4

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 (241) hide show
  1. package/README.md +378 -207
  2. package/dist/.build-inputs.json +69 -0
  3. package/dist/src/component-manifest.d.ts +5 -3
  4. package/dist/src/component-manifest.d.ts.map +1 -1
  5. package/dist/src/component-manifest.js +7 -7
  6. package/dist/src/component-manifest.js.map +1 -1
  7. package/dist/src/constants.d.ts +14 -13
  8. package/dist/src/constants.d.ts.map +1 -1
  9. package/dist/src/constants.js +14 -13
  10. package/dist/src/constants.js.map +1 -1
  11. package/dist/src/d3-build.d.ts +70 -0
  12. package/dist/src/d3-build.d.ts.map +1 -0
  13. package/dist/src/d3-build.js +272 -0
  14. package/dist/src/d3-build.js.map +1 -0
  15. package/dist/src/descriptors.d.ts +2 -2
  16. package/dist/src/descriptors.d.ts.map +1 -1
  17. package/dist/src/descriptors.js +4 -2
  18. package/dist/src/descriptors.js.map +1 -1
  19. package/dist/src/doctor/checks-address.d.ts +18 -0
  20. package/dist/src/doctor/checks-address.d.ts.map +1 -0
  21. package/dist/src/doctor/checks-address.js +163 -0
  22. package/dist/src/doctor/checks-address.js.map +1 -0
  23. package/dist/src/doctor/checks-live.d.ts +8 -5
  24. package/dist/src/doctor/checks-live.d.ts.map +1 -1
  25. package/dist/src/doctor/checks-live.js +226 -188
  26. package/dist/src/doctor/checks-live.js.map +1 -1
  27. package/dist/src/doctor/checks-offline.d.ts +6 -25
  28. package/dist/src/doctor/checks-offline.d.ts.map +1 -1
  29. package/dist/src/doctor/checks-offline.js +30 -259
  30. package/dist/src/doctor/checks-offline.js.map +1 -1
  31. package/dist/src/doctor/checks-preview-limits.d.ts +11 -0
  32. package/dist/src/doctor/checks-preview-limits.d.ts.map +1 -0
  33. package/dist/src/doctor/checks-preview-limits.js +133 -0
  34. package/dist/src/doctor/checks-preview-limits.js.map +1 -0
  35. package/dist/src/doctor/checks-preview-live.d.ts +14 -0
  36. package/dist/src/doctor/checks-preview-live.d.ts.map +1 -0
  37. package/dist/src/doctor/checks-preview-live.js +72 -0
  38. package/dist/src/doctor/checks-preview-live.js.map +1 -0
  39. package/dist/src/doctor/checks-preview.d.ts +7 -0
  40. package/dist/src/doctor/checks-preview.d.ts.map +1 -0
  41. package/dist/src/doctor/checks-preview.js +287 -0
  42. package/dist/src/doctor/checks-preview.js.map +1 -0
  43. package/dist/src/doctor/config-scan.d.ts +12 -3
  44. package/dist/src/doctor/config-scan.d.ts.map +1 -1
  45. package/dist/src/doctor/config-scan.js +38 -11
  46. package/dist/src/doctor/config-scan.js.map +1 -1
  47. package/dist/src/doctor/run.d.ts.map +1 -1
  48. package/dist/src/doctor/run.js +16 -10
  49. package/dist/src/doctor/run.js.map +1 -1
  50. package/dist/src/doctor/types.d.ts +17 -7
  51. package/dist/src/doctor/types.d.ts.map +1 -1
  52. package/dist/src/doctor/types.js +17 -7
  53. package/dist/src/doctor/types.js.map +1 -1
  54. package/dist/src/editor-page/bundle.d.ts +90 -0
  55. package/dist/src/editor-page/bundle.d.ts.map +1 -0
  56. package/dist/src/editor-page/bundle.js +373 -0
  57. package/dist/src/editor-page/bundle.js.map +1 -0
  58. package/dist/src/editor-page/data-schemas.d.ts +16 -0
  59. package/dist/src/editor-page/data-schemas.d.ts.map +1 -0
  60. package/dist/src/editor-page/data-schemas.js +39 -0
  61. package/dist/src/editor-page/data-schemas.js.map +1 -0
  62. package/dist/src/editor-page/emit.d.ts +69 -0
  63. package/dist/src/editor-page/emit.d.ts.map +1 -0
  64. package/dist/src/editor-page/emit.js +254 -0
  65. package/dist/src/editor-page/emit.js.map +1 -0
  66. package/dist/src/editor-page/framing.d.ts +23 -0
  67. package/dist/src/editor-page/framing.d.ts.map +1 -0
  68. package/dist/src/editor-page/framing.js +39 -0
  69. package/dist/src/editor-page/framing.js.map +1 -0
  70. package/dist/src/editor-page/page.d.ts +9 -0
  71. package/dist/src/editor-page/page.d.ts.map +1 -0
  72. package/dist/src/editor-page/page.js +31 -0
  73. package/dist/src/editor-page/page.js.map +1 -0
  74. package/dist/src/editor-page/site-base.d.ts +4 -0
  75. package/dist/src/editor-page/site-base.d.ts.map +1 -0
  76. package/dist/src/editor-page/site-base.js +13 -0
  77. package/dist/src/editor-page/site-base.js.map +1 -0
  78. package/dist/src/git.d.ts +11 -8
  79. package/dist/src/git.d.ts.map +1 -1
  80. package/dist/src/git.js +25 -8
  81. package/dist/src/git.js.map +1 -1
  82. package/dist/src/index.d.ts +4 -1
  83. package/dist/src/index.d.ts.map +1 -1
  84. package/dist/src/index.js +11 -6
  85. package/dist/src/index.js.map +1 -1
  86. package/dist/src/integration.d.ts +1 -1
  87. package/dist/src/integration.d.ts.map +1 -1
  88. package/dist/src/integration.js +377 -416
  89. package/dist/src/integration.js.map +1 -1
  90. package/dist/src/node.d.ts +3 -1
  91. package/dist/src/node.d.ts.map +1 -1
  92. package/dist/src/node.js +7 -2
  93. package/dist/src/node.js.map +1 -1
  94. package/dist/src/preview/_dispatch.d.ts +12 -0
  95. package/dist/src/preview/_dispatch.d.ts.map +1 -1
  96. package/dist/src/preview/_dispatch.js +31 -0
  97. package/dist/src/preview/_dispatch.js.map +1 -1
  98. package/dist/src/preview/_resolve-opts.d.ts +19 -10
  99. package/dist/src/preview/_resolve-opts.d.ts.map +1 -1
  100. package/dist/src/preview/_resolve-opts.js +24 -11
  101. package/dist/src/preview/_resolve-opts.js.map +1 -1
  102. package/dist/src/preview/banner.d.ts +12 -9
  103. package/dist/src/preview/banner.d.ts.map +1 -1
  104. package/dist/src/preview/banner.js +46 -43
  105. package/dist/src/preview/banner.js.map +1 -1
  106. package/dist/src/preview/cloudflare-adapter.d.ts +35 -0
  107. package/dist/src/preview/cloudflare-adapter.d.ts.map +1 -0
  108. package/dist/src/preview/cloudflare-adapter.js +92 -0
  109. package/dist/src/preview/cloudflare-adapter.js.map +1 -0
  110. package/dist/src/preview/cookie.d.ts +13 -14
  111. package/dist/src/preview/cookie.d.ts.map +1 -1
  112. package/dist/src/preview/cookie.js +19 -26
  113. package/dist/src/preview/cookie.js.map +1 -1
  114. package/dist/src/preview/dispatcher.d.ts +73 -0
  115. package/dist/src/preview/dispatcher.d.ts.map +1 -0
  116. package/dist/src/preview/dispatcher.js +329 -0
  117. package/dist/src/preview/dispatcher.js.map +1 -0
  118. package/dist/src/preview/entry-code.d.ts +33 -0
  119. package/dist/src/preview/entry-code.d.ts.map +1 -0
  120. package/dist/src/preview/entry-code.js +33 -0
  121. package/dist/src/preview/entry-code.js.map +1 -0
  122. package/dist/src/preview/headers.d.ts +24 -4
  123. package/dist/src/preview/headers.d.ts.map +1 -1
  124. package/dist/src/preview/headers.js +35 -7
  125. package/dist/src/preview/headers.js.map +1 -1
  126. package/dist/src/preview/label.d.ts +8 -0
  127. package/dist/src/preview/label.d.ts.map +1 -0
  128. package/dist/src/preview/label.js +14 -0
  129. package/dist/src/preview/label.js.map +1 -0
  130. package/dist/src/preview/landing.d.ts +23 -2
  131. package/dist/src/preview/landing.d.ts.map +1 -1
  132. package/dist/src/preview/landing.js +105 -37
  133. package/dist/src/preview/landing.js.map +1 -1
  134. package/dist/src/preview/middleware.d.ts +49 -22
  135. package/dist/src/preview/middleware.d.ts.map +1 -1
  136. package/dist/src/preview/middleware.js +259 -100
  137. package/dist/src/preview/middleware.js.map +1 -1
  138. package/dist/src/preview/preview-path.d.ts +47 -5
  139. package/dist/src/preview/preview-path.d.ts.map +1 -1
  140. package/dist/src/preview/preview-path.js +65 -8
  141. package/dist/src/preview/preview-path.js.map +1 -1
  142. package/dist/src/preview/redeem-url.d.ts +7 -0
  143. package/dist/src/preview/redeem-url.d.ts.map +1 -0
  144. package/dist/src/preview/redeem-url.js +14 -0
  145. package/dist/src/preview/redeem-url.js.map +1 -0
  146. package/dist/src/preview/site-middleware.d.ts +5 -5
  147. package/dist/src/preview/site-middleware.d.ts.map +1 -1
  148. package/dist/src/preview/site-middleware.js +53 -26
  149. package/dist/src/preview/site-middleware.js.map +1 -1
  150. package/dist/src/preview-build.d.ts +29 -15
  151. package/dist/src/preview-build.d.ts.map +1 -1
  152. package/dist/src/preview-build.js +66 -25
  153. package/dist/src/preview-build.js.map +1 -1
  154. package/dist/src/preview.d.ts +1 -1
  155. package/dist/src/preview.d.ts.map +1 -1
  156. package/dist/src/preview.js +1 -1
  157. package/dist/src/preview.js.map +1 -1
  158. package/dist/src/repository.d.ts +1 -1
  159. package/dist/src/repository.js +1 -1
  160. package/dist/src/resolve-options.d.ts +17 -0
  161. package/dist/src/resolve-options.d.ts.map +1 -0
  162. package/dist/src/resolve-options.js +21 -0
  163. package/dist/src/resolve-options.js.map +1 -0
  164. package/dist/src/site-id.d.ts +0 -2
  165. package/dist/src/site-id.d.ts.map +1 -1
  166. package/dist/src/site-id.js +2 -3
  167. package/dist/src/site-id.js.map +1 -1
  168. package/dist/src/skill.d.ts +11 -0
  169. package/dist/src/skill.d.ts.map +1 -1
  170. package/dist/src/skill.js +32 -9
  171. package/dist/src/skill.js.map +1 -1
  172. package/dist/src/types.d.ts +33 -78
  173. package/dist/src/types.d.ts.map +1 -1
  174. package/package.json +63 -13
  175. package/src/component-manifest.ts +11 -8
  176. package/src/constants.ts +15 -13
  177. package/src/d3-build.ts +315 -0
  178. package/src/descriptors.ts +6 -4
  179. package/src/doctor/checks-address.ts +190 -0
  180. package/src/doctor/checks-live.ts +262 -268
  181. package/src/doctor/checks-offline.ts +32 -279
  182. package/src/doctor/checks-preview-limits.ts +137 -0
  183. package/src/doctor/checks-preview-live.ts +77 -0
  184. package/src/doctor/checks-preview.ts +302 -0
  185. package/src/doctor/config-scan.ts +35 -9
  186. package/src/doctor/run.ts +18 -16
  187. package/src/doctor/types.ts +17 -7
  188. package/src/editor-page/bundle.ts +487 -0
  189. package/src/editor-page/data-schemas.ts +47 -0
  190. package/src/editor-page/emit.ts +362 -0
  191. package/src/editor-page/framing.ts +62 -0
  192. package/src/editor-page/page.ts +37 -0
  193. package/src/editor-page/site-base.ts +11 -0
  194. package/src/git.ts +29 -10
  195. package/src/index.ts +22 -6
  196. package/src/integration.ts +399 -469
  197. package/src/node.ts +18 -2
  198. package/src/preview/_dispatch.ts +36 -1
  199. package/src/preview/_resolve-opts.ts +35 -12
  200. package/src/preview/banner.ts +61 -43
  201. package/src/preview/cloudflare-adapter.ts +103 -0
  202. package/src/preview/cookie.ts +18 -24
  203. package/src/preview/dispatcher.ts +407 -0
  204. package/src/preview/entry-code.ts +51 -0
  205. package/src/preview/headers.ts +35 -7
  206. package/src/preview/label.ts +12 -0
  207. package/src/preview/landing.ts +117 -39
  208. package/src/preview/middleware.ts +302 -115
  209. package/src/preview/preview-path.ts +83 -8
  210. package/src/preview/redeem-url.ts +14 -0
  211. package/src/preview/site-middleware.ts +60 -30
  212. package/src/preview-build.ts +85 -26
  213. package/src/preview-handler.astro +12 -9
  214. package/src/preview.ts +0 -1
  215. package/src/repository.ts +1 -1
  216. package/src/resolve-options.ts +37 -0
  217. package/src/site-id.ts +2 -4
  218. package/src/skill/SKILL.md +63 -55
  219. package/src/skill.ts +36 -8
  220. package/src/types.ts +33 -79
  221. package/src/virtual-modules.d.ts +4 -1
  222. package/dist/src/build-commit.d.ts +0 -19
  223. package/dist/src/build-commit.d.ts.map +0 -1
  224. package/dist/src/build-commit.js +0 -6
  225. package/dist/src/build-commit.js.map +0 -1
  226. package/dist/src/bundle.d.ts +0 -181
  227. package/dist/src/bundle.d.ts.map +0 -1
  228. package/dist/src/bundle.js +0 -413
  229. package/dist/src/bundle.js.map +0 -1
  230. package/dist/src/discovery.d.ts +0 -58
  231. package/dist/src/discovery.d.ts.map +0 -1
  232. package/dist/src/discovery.js +0 -133
  233. package/dist/src/discovery.js.map +0 -1
  234. package/dist/src/register.d.ts +0 -98
  235. package/dist/src/register.d.ts.map +0 -1
  236. package/dist/src/register.js +0 -103
  237. package/dist/src/register.js.map +0 -1
  238. package/src/build-commit.ts +0 -22
  239. package/src/bundle.ts +0 -570
  240. package/src/discovery.ts +0 -183
  241. package/src/register.ts +0 -180
@@ -1,19 +1,76 @@
1
1
  /**
2
- * Strip a leading `/conloca_preview_<secret>` segment from a pathname.
2
+ * The fixed preview route and the names it uses.
3
3
  *
4
4
  * Lives in its own module because the entry-hop middleware, the site
5
5
  * middleware and the page-status client all need it without depending on
6
6
  * each other.
7
7
  *
8
- * The match is anchored at the FIRST segment only — a path like
9
- * `/posts/conloca_preview_x/about` is left untouched, so a page that merely
10
- * mentions the prefix mid-tree is never re-anchored to a different page.
8
+ * The route is public and the same on every site: the signed pass is the
9
+ * lock, checked against the repository, site and branch the preview build
10
+ * was made from.
11
11
  */
12
- export function stripPreviewPrefix(pathname) {
13
- const match = /^\/conloca_preview_[^/]+(\/.*)?$/.exec(pathname);
14
- if (!match)
12
+ export const PREVIEW_ROUTE_SEGMENT = '/_conloca/preview';
13
+ export const PREVIEW_QUERY_PARAM = 'conloca_preview';
14
+ export const PREVIEW_COOKIE_NAME = '__Host-conloca_preview';
15
+ /** Protocol 2: the single-use code a preview link carries instead of the pass. */
16
+ export const PREVIEW_CODE_PARAM = 'conloca_code';
17
+ /** The share link a viewer's pass came from (D4 only), so an expired pass can renew through it. */
18
+ export const PREVIEW_GRANT_COOKIE_NAME = '__Host-conloca_grant';
19
+ /** Response header on the exit route's redirect that carries the public label. */
20
+ export const PREVIEW_LABEL_HEADER = 'conloca-preview';
21
+ /** Response header on the exit route's redirect that names the preview protocol this build speaks. */
22
+ export const PREVIEW_PROTOCOL_HEADER = 'conloca-preview-protocol';
23
+ /** D3: the request header the dispatcher names the requested branch slug in. It strips any the browser sent. */
24
+ export const PREVIEW_SLUG_HEADER = 'conloca-preview-slug';
25
+ /** Response header on the exit route's redirect that names how this build serves previews. */
26
+ export const PREVIEW_MODE_HEADER = 'conloca-preview-mode';
27
+ /**
28
+ * D3 scopes both cookies to `<base>_conloca/preview/<slug>`, so two tabs on two branches keep two passes. D2 and D4
29
+ * keep the `__Host-` names on `Path=/`, which is what lets the pass follow every same-origin link there.
30
+ */
31
+ export function previewScope(mode, base, slug) {
32
+ const prefix = previewRoutePrefix(base);
33
+ if (mode !== 'd3') {
34
+ return {
35
+ pass: PREVIEW_COOKIE_NAME,
36
+ grant: mode === 'd4' ? PREVIEW_GRANT_COOKIE_NAME : null,
37
+ path: '/',
38
+ route: prefix,
39
+ };
40
+ }
41
+ if (slug === undefined)
42
+ throw new Error('@conloca/cloud-astro: a d3 preview scope needs the branch slug');
43
+ const route = `${prefix}/${slug}`;
44
+ return { pass: `__Secure-conloca_preview_${slug}`, grant: `__Secure-conloca_grant_${slug}`, path: route, route };
45
+ }
46
+ /** The preview route under Astro's `base` (`'/'` → `/_conloca/preview`, `'/docs/'` → `/docs/_conloca/preview`). */
47
+ export function previewRoutePrefix(base) {
48
+ return `${base.replace(/\/+$/u, '')}${PREVIEW_ROUTE_SEGMENT}`;
49
+ }
50
+ /** The `run_worker_first` entries that belong to the preview, not the site: its route, and the image endpoint drafts use. */
51
+ export function previewOwnEntries(base) {
52
+ const prefix = previewRoutePrefix(base);
53
+ return [prefix, `${prefix}/*`, `${base.replace(/\/+$/u, '')}/_image`];
54
+ }
55
+ /**
56
+ * Strip the preview route from a pathname, leaving the page path under the
57
+ * base. Only the route at the base matches: `/blog/_conloca/preview/x` and
58
+ * `/_conloca/previewer/x` are left untouched, so a page that merely mentions
59
+ * the route is never re-anchored to a different page.
60
+ */
61
+ export function stripPreviewPrefix(pathname, base) {
62
+ const prefix = previewRoutePrefix(base);
63
+ if (pathname !== prefix && !pathname.startsWith(`${prefix}/`))
15
64
  return pathname;
16
- return match[1] ?? '/';
65
+ const rest = pathname.slice(prefix.length);
66
+ return `${base.replace(/\/+$/u, '')}${rest === '' ? '/' : rest}`;
67
+ }
68
+ /** A site path without the base, as the editor names pages (`/docs/guide` under `/docs/` → `/guide`). */
69
+ export function pathUnderBase(path, base) {
70
+ const root = base.replace(/\/+$/u, '');
71
+ if (root === '' || (path !== root && !path.startsWith(`${root}/`)))
72
+ return path;
73
+ return path.slice(root.length) || '/';
17
74
  }
18
75
  /**
19
76
  * Canonical path form for page-status lookups and production rewrites: no
@@ -1 +1 @@
1
- {"version":3,"file":"preview-path.js","sourceRoot":"","sources":["../../../src/preview/preview-path.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAAgB;IACjD,MAAM,KAAK,GAAG,kCAAkC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAChE,IAAI,CAAC,KAAK;QAAE,OAAO,QAAQ,CAAC;IAC5B,OAAO,KAAK,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC;AACzB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,QAAgB;IACrD,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAC/C,OAAO,QAAQ,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC1C,CAAC"}
1
+ {"version":3,"file":"preview-path.js","sourceRoot":"","sources":["../../../src/preview/preview-path.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,mBAAmB,CAAC;AACzD,MAAM,CAAC,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;AACrD,MAAM,CAAC,MAAM,mBAAmB,GAAG,wBAAwB,CAAC;AAC5D,kFAAkF;AAClF,MAAM,CAAC,MAAM,kBAAkB,GAAG,cAAc,CAAC;AACjD,mGAAmG;AACnG,MAAM,CAAC,MAAM,yBAAyB,GAAG,sBAAsB,CAAC;AAChE,kFAAkF;AAClF,MAAM,CAAC,MAAM,oBAAoB,GAAG,iBAAiB,CAAC;AAEtD,sGAAsG;AACtG,MAAM,CAAC,MAAM,uBAAuB,GAAG,0BAA0B,CAAC;AAElE,gHAAgH;AAChH,MAAM,CAAC,MAAM,mBAAmB,GAAG,sBAAsB,CAAC;AA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,CAAC,IAAI,CAAC,CAAC;IACxC,IAAI,QAAQ,KAAK,MAAM,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,MAAM,GAAG,CAAC;QAAE,OAAO,QAAQ,CAAC;IAC/E,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC3C,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AACnE,CAAC;AAED,yGAAyG;AACzG,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,IAAY;IACtD,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IACvC,IAAI,IAAI,KAAK,EAAE,IAAI,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IAChF,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC;AACxC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,QAAgB;IACrD,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAC/C,OAAO,QAAQ,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC1C,CAAC"}
@@ -0,0 +1,7 @@
1
+ /** The org id as unpadded base64url: the form share links, entry codes and the grant cookie carry it in. */
2
+ export declare function orgToken(org: string): string;
3
+ /** `<orgToken>.<grantId>`: names one share link without naming the org in clear. */
4
+ export declare function grantRef(org: string, grantId: string): string;
5
+ /** A grant reference as the grant cookie holds it. */
6
+ export declare const GRANT_REF_RE: RegExp;
7
+ //# sourceMappingURL=redeem-url.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redeem-url.d.ts","sourceRoot":"","sources":["../../../src/preview/redeem-url.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAC5G,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAI5C;AAED,oFAAoF;AACpF,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED,sDAAsD;AACtD,eAAO,MAAM,YAAY,QAAyC,CAAC"}
@@ -0,0 +1,14 @@
1
+ /** The org id as unpadded base64url: the form share links, entry codes and the grant cookie carry it in. */
2
+ export function orgToken(org) {
3
+ let binary = '';
4
+ for (const byte of new TextEncoder().encode(org))
5
+ binary += String.fromCharCode(byte);
6
+ return btoa(binary).replace(/\+/gu, '-').replace(/\//gu, '_').replace(/=+$/u, '');
7
+ }
8
+ /** `<orgToken>.<grantId>`: names one share link without naming the org in clear. */
9
+ export function grantRef(org, grantId) {
10
+ return `${orgToken(org)}.${grantId}`;
11
+ }
12
+ /** A grant reference as the grant cookie holds it. */
13
+ export const GRANT_REF_RE = /^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]{22}$/u;
14
+ //# sourceMappingURL=redeem-url.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redeem-url.js","sourceRoot":"","sources":["../../../src/preview/redeem-url.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAC5G,MAAM,UAAU,QAAQ,CAAC,GAAW;IAClC,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,MAAM,IAAI,IAAI,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC;QAAE,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IACtF,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AACpF,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,QAAQ,CAAC,GAAW,EAAE,OAAe;IACnD,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,OAAO,EAAE,CAAC;AACvC,CAAC;AAED,sDAAsD;AACtD,MAAM,CAAC,MAAM,YAAY,GAAG,sCAAsC,CAAC"}
@@ -2,15 +2,15 @@
2
2
  * Site-wide preview middleware for the recursive preview build — the SERVING
3
3
  * SURFACE of draft preview.
4
4
  *
5
- * WHY THIS EXISTS — the secret path prefix is an entry door, not the serving
5
+ * WHY THIS EXISTS — the fixed preview route is an entry door, not the serving
6
6
  * surface. Without this, preview survives exactly one page view: the visitor
7
- * lands on `/conloca_preview_<secret>/about`, clicks a link, and the
8
- * root-absolute `/blog` the site's template emitted drops the prefix and
9
- * silently serves the PUBLISHED page. The preview cookie is already `Path=/`,
7
+ * lands on `/_conloca/preview/about`, clicks a link, and the root-absolute
8
+ * `/blog` the site's template emitted drops the route and silently serves the
9
+ * PUBLISHED page. The preview cookie is already `Path=/`,
10
10
  * so the browser is sending the credential on that request — this listens.
11
11
  *
12
12
  * WHY THE RENDER HAPPENS HERE, VIA `next()` — a middleware rewrite onto the
13
- * secret-prefixed handler (the previous design) forced the render through
13
+ * preview route's handler (an earlier design) forced the render through
14
14
  * `Astro.rewrite`, whose route matching does not fall through prerendered
15
15
  * routes: with two root catch-alls (the CMS pages route on demand, a docs
16
16
  * integration's route prerendered) the rewrite matched the prerendered one
@@ -1 +1 @@
1
- {"version":3,"file":"site-middleware.d.ts","sourceRoot":"","sources":["../../../src/preview/site-middleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAKvD,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,wBA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AAqB,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,CAAC;AAE5D;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,sFAAsF;IACtF,WAAW,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC;IACvC,+EAA+E;IAC/E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,OAAO,KAAK,CAAC;CACxB;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,MAAM,wBAAwB,EAAE,KAAK,EAAE,kBAAkB,aACvE,wBAAwB,QAAQ,qBAAqB,KAAG,OAAO,CAAC,QAAQ,CAAC,CA0InH"}
@@ -2,15 +2,15 @@
2
2
  * Site-wide preview middleware for the recursive preview build — the SERVING
3
3
  * SURFACE of draft preview.
4
4
  *
5
- * WHY THIS EXISTS — the secret path prefix is an entry door, not the serving
5
+ * WHY THIS EXISTS — the fixed preview route is an entry door, not the serving
6
6
  * surface. Without this, preview survives exactly one page view: the visitor
7
- * lands on `/conloca_preview_<secret>/about`, clicks a link, and the
8
- * root-absolute `/blog` the site's template emitted drops the prefix and
9
- * silently serves the PUBLISHED page. The preview cookie is already `Path=/`,
7
+ * lands on `/_conloca/preview/about`, clicks a link, and the root-absolute
8
+ * `/blog` the site's template emitted drops the route and silently serves the
9
+ * PUBLISHED page. The preview cookie is already `Path=/`,
10
10
  * so the browser is sending the credential on that request — this listens.
11
11
  *
12
12
  * WHY THE RENDER HAPPENS HERE, VIA `next()` — a middleware rewrite onto the
13
- * secret-prefixed handler (the previous design) forced the render through
13
+ * preview route's handler (an earlier design) forced the render through
14
14
  * `Astro.rewrite`, whose route matching does not fall through prerendered
15
15
  * routes: with two root catch-alls (the CMS pages route on demand, a docs
16
16
  * integration's route prerendered) the rewrite matched the prerendered one
@@ -25,12 +25,13 @@
25
25
  * production build. Deliberately fail-open: any request without a valid
26
26
  * preview credential passes straight through to the ordinary page.
27
27
  */
28
- import { fetchPageStatus } from './_dispatch.js';
28
+ import { fetchPageStatus, isShareEndedKind } from './_dispatch.js';
29
29
  import { injectPreviewBanner } from './banner.js';
30
30
  import { PreviewContentAPI } from './content-api.js';
31
- import { applyPreviewHeaders } from './headers.js';
32
- import { handlePreviewRequest, previewParamName, } from './middleware.js';
33
- import { normalizeTrailingSlash, stripPreviewPrefix } from './preview-path.js';
31
+ import { applyPreviewHeaders, PREVIEW_CACHE_HEADERS } from './headers.js';
32
+ import { renderPreviewUnavailable, renderShareEnded } from './landing.js';
33
+ import { handlePreviewRequest } from './middleware.js';
34
+ import { normalizeTrailingSlash, PREVIEW_SLUG_HEADER, pathUnderBase, previewScope, stripPreviewPrefix, } from './preview-path.js';
34
35
  /**
35
36
  * Builds the Astro middleware `onRequest` handler.
36
37
  *
@@ -47,8 +48,8 @@ export function createPreviewSiteMiddleware(resolveOpts, seams) {
47
48
  // ALSO at build time, where Astro runs middleware while prerendering pages
48
49
  // and the deployer's runtime vars do not exist yet. Neither is a reason to
49
50
  // break the site's build or the whole site over a feature it may
50
- // not use, so pass through and warn once. The secret-prefixed entry route
51
- // still fails loudly: reaching it means someone explicitly asked to preview.
51
+ // not use, so pass through and warn once. The preview entry route still
52
+ // fails loudly: reaching it means someone explicitly asked to preview.
52
53
  let opts;
53
54
  try {
54
55
  opts = resolveOpts();
@@ -57,30 +58,38 @@ export function createPreviewSiteMiddleware(resolveOpts, seams) {
57
58
  warnUnconfiguredOnce(error);
58
59
  return next();
59
60
  }
61
+ // Under D3 the dispatcher names the requested branch's slug, after stripping any the browser sent.
62
+ const slug = opts.mode === 'd3' ? (context.request.headers.get(PREVIEW_SLUG_HEADER) ?? undefined) : undefined;
60
63
  const verdict = await handlePreviewRequest(context.request, {
61
64
  ...opts,
62
- onMiss: 'pass-through',
65
+ ...(slug === undefined ? {} : { slug }),
66
+ // No silent fallback: under the slug, a pass that doesn't verify gets the landing page, never the
67
+ // published page at the draft URL. Only the live site's own requests (no slug) pass through.
68
+ onMiss: slug === undefined ? 'pass-through' : 'landing',
63
69
  fetchFn: opts.fetchFn ?? seams.fetchFn,
64
70
  });
65
71
  if (verdict.kind === 'response')
66
72
  return verdict.response;
67
73
  if (verdict.kind !== 'preview')
68
74
  return next();
69
- // A valid credential on the LITERAL secret-prefixed URL: canonicalize to
70
- // the clean site path instead of rendering under the prefix — links,
71
- // assets and the page lookup all assume clean paths.
75
+ // A preview verdict under D3 means the slug was named, so the scope always resolves.
76
+ const exitPath = `${previewScope(opts.mode ?? 'd2', opts.base, slug).route}/__exit`;
77
+ // A valid credential on the preview route itself: canonicalize to the
78
+ // clean site path instead of rendering under the route — links, assets
79
+ // and the page lookup all assume clean paths.
72
80
  const rawPath = context.url.pathname;
73
- const path = normalizeTrailingSlash(stripPreviewPrefix(rawPath));
74
- if (stripPreviewPrefix(rawPath) !== rawPath) {
81
+ const path = normalizeTrailingSlash(stripPreviewPrefix(rawPath, opts.base));
82
+ if (stripPreviewPrefix(rawPath, opts.base) !== rawPath) {
75
83
  return new Response(null, {
76
84
  status: 302,
77
- headers: { location: path, 'cache-control': 'private, no-store' },
85
+ headers: { location: path, ...PREVIEW_CACHE_HEADERS },
78
86
  });
79
87
  }
80
88
  context.locals.conlocaPreview = verdict.ctx;
81
- // An endpoint failure (5xx mid-deploy, auth envelope, network) must not 500
82
- // the whole site for a visitor holding the HttpOnly cookie they cannot
83
- // remove — degrade to published bytes, keeping the preview headers.
89
+ // An endpoint failure (5xx mid-deploy, auth envelope, network) must neither
90
+ // 500 the site nor pass published bytes off as the draft: answer with a
91
+ // retry page that also offers Exit, since the visitor can't remove the
92
+ // HttpOnly cookie.
84
93
  let status;
85
94
  try {
86
95
  status = await fetchPageStatus({
@@ -94,9 +103,19 @@ export function createPreviewSiteMiddleware(resolveOpts, seams) {
94
103
  });
95
104
  }
96
105
  catch (error) {
97
- console.warn(`[@conloca/cloud-astro] preview page-status failed for ${path} — serving the published page instead: ` +
106
+ console.warn(`[@conloca/cloud-astro] preview page-status failed for ${path} — showing the retry page: ` +
98
107
  `${error instanceof Error ? error.message : String(error)}`);
99
- return applyPreviewHeaders(await next());
108
+ return renderPreviewUnavailable({
109
+ // Collapse leading slashes: `//evil.test/x` would otherwise be a cross-origin link.
110
+ retryHref: `/${rawPath.replace(/^\/+/u, '')}${context.url.search}`,
111
+ exitHref: `${exitPath}?to=${encodeURIComponent(rawPath)}`,
112
+ });
113
+ }
114
+ if (isShareEndedKind(status.kind) && 'sharedBy' in status) {
115
+ return renderShareEnded(status.kind, {
116
+ sharedBy: status.sharedBy,
117
+ liveHref: `${exitPath}?to=${encodeURIComponent(path)}`,
118
+ });
100
119
  }
101
120
  if (status.kind === 'unchanged') {
102
121
  // Production-equivalent bytes: render the ordinary route against the
@@ -109,7 +128,7 @@ export function createPreviewSiteMiddleware(resolveOpts, seams) {
109
128
  // redirect can never be cached by intermediaries.
110
129
  return new Response(null, {
111
130
  status: 302,
112
- headers: { location: status.target, 'cache-control': 'private, no-store' },
131
+ headers: { location: status.target, ...PREVIEW_CACHE_HEADERS },
113
132
  });
114
133
  }
115
134
  // 'changed' and 'deleted' both render through the site's own route with
@@ -136,7 +155,15 @@ export function createPreviewSiteMiddleware(resolveOpts, seams) {
136
155
  // through with the preview headers only.
137
156
  return applyPreviewHeaders(rendered);
138
157
  }
139
- const html = injectPreviewBanner(await rendered.text(), verdict.ctx, opts.saasEndpoint, `/${previewParamName(opts.secret)}/__exit`);
158
+ let shareUrl;
159
+ if (verdict.ctx.editorUrl !== undefined) {
160
+ const url = new URL(verdict.ctx.editorUrl);
161
+ url.searchParams.set('share', pathUnderBase(path, opts.base));
162
+ shareUrl = url.toString();
163
+ }
164
+ const html = injectPreviewBanner(await rendered.text(), verdict.ctx, opts.saasEndpoint, exitPath, shareUrl,
165
+ // The page's own path: under D3 the address bar holds the route, which Edit and Exit must not carry.
166
+ rawPath);
140
167
  return applyPreviewHeaders(new Response(html, { status: rendered.status, headers: rendered.headers }));
141
168
  };
142
169
  }
@@ -154,7 +181,7 @@ function warnUnconfiguredOnce(error) {
154
181
  const detail = error instanceof Error ? error.message : String(error);
155
182
  console.warn(`[@conloca/cloud-astro] draft preview is INERT — ${detail}\n` +
156
183
  ' Requests are being served as the ordinary published site.\n' +
157
- ' Draft previews on your own deployment are not available yet: keep previewBuild: false ' +
184
+ ' The preview server is missing its baked settings: rebuild with previewBuild given as an object ' +
158
185
  '(see the cloud-astro README "Draft previews").');
159
186
  }
160
187
  //# sourceMappingURL=site-middleware.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"site-middleware.js","sourceRoot":"","sources":["../../../src/preview/site-middleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAGH,OAAO,EAAE,eAAe,EAAmB,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EACL,oBAAoB,EAGpB,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAiC/E;;;;;;GAMG;AACH,MAAM,UAAU,2BAA2B,CAAC,WAA2C,EAAE,KAAyB;IAChH,OAAO,KAAK,UAAU,SAAS,CAAC,OAAiC,EAAE,IAA2B;QAC5F,uEAAuE;QACvE,IAAI,OAAO,CAAC,MAAM,CAAC,cAAc;YAAE,OAAO,IAAI,EAAE,CAAC;QAEjD,2EAA2E;QAC3E,2EAA2E;QAC3E,2EAA2E;QAC3E,iEAAiE;QACjE,0EAA0E;QAC1E,6EAA6E;QAC7E,IAAI,IAA8B,CAAC;QACnC,IAAI,CAAC;YACH,IAAI,GAAG,WAAW,EAAE,CAAC;QACvB,CAAC;QAAC,OAAO,KAAK,EA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I,OAAO,CAAC,GAAG,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;YACxC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YAC3C,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YAC9D,QAAQ,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC;QAC5B,CAAC;QACD,MAAM,IAAI,GAAG,mBAAmB,CAC9B,MAAM,QAAQ,CAAC,IAAI,EAAE,EACrB,OAAO,CAAC,GAAG,EACX,IAAI,CAAC,YAAY,EACjB,QAAQ,EACR,QAAQ;QACR,qGAAqG;QACrG,OAAO,CACR,CAAC;QACF,OAAO,mBAAmB,CAAC,IAAI,QAAQ,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IACzG,CAAC,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,IAAI,MAAM,GAAG,KAAK,CAAC;AACnB,SAAS,oBAAoB,CAAC,KAAc;IAC1C,IAAI,MAAM;QAAE,OAAO;IACnB,MAAM,GAAG,IAAI,CAAC;IACd,MAAM,MAAM,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACtE,OAAO,CAAC,IAAI,CACV,mDAAmD,MAAM,IAAI;QAC3D,+DAA+D;QAC/D,mGAAmG;QACnG,gDAAgD,CACnD,CAAC;AACJ,CAAC"}
@@ -1,6 +1,22 @@
1
- import { PREVIEW_SECRET_ENV_FLAG } from './constants.js';
1
+ import type { PreviewServeMode } from './preview/preview-path.js';
2
2
  import type { PreviewBuildOptions } from './types.js';
3
- export { PREVIEW_SECRET_ENV_FLAG };
3
+ /**
4
+ * How the preview build serves, from the options and the adapter the preview server would build with
5
+ * (`previewBuild.adapter`, else the project's own): off unless `previewBuild` is given as an object; D4 with
6
+ * `separate: true`; D3 for a static site, whose preview server runs next to it on Cloudflare Workers; D2 when an
7
+ * adapter is named, since the site's own server deploy serves the drafts. Throws for a refused adapter, so the build
8
+ * fails before it deploys anything.
9
+ */
10
+ export declare function previewBuildMode(previewBuild: PreviewBuildOptions | false | undefined, adapterName: string | undefined): 'off' | PreviewServeMode;
11
+ /** The mode a preview build serves in: the site's build names D2 or D3; the flag alone is a separate preview deploy (D4). */
12
+ export declare function previewChildMode(env: NodeJS.ProcessEnv): PreviewServeMode;
13
+ /**
14
+ * One route the site's build prerendered, as a D3 child matches it: pattern and component together, since one
15
+ * entrypoint can be injected at two patterns, one published and one only the preview build has.
16
+ */
17
+ export declare function prerenderedKey(pattern: string, component: string): string;
18
+ /** The routes (`prerenderedKey`) a D3 child's site build prerendered (`buildPreviewChildEnv`); none for any other child. */
19
+ export declare function previewChildPrerendered(env: NodeJS.ProcessEnv): Set<string>;
4
20
  /**
5
21
  * The minimal child-process surface this module relies on. Letting
6
22
  * {@link _spawnPreviewBuildWith} accept any function that produces a process
@@ -17,14 +33,15 @@ export type PreviewBuildSpawn = (command: string, args: readonly string[], optio
17
33
  }) => PreviewBuildChildProcess;
18
34
  /**
19
35
  * Pure constructor for the child-process environment passed to the recursive
20
- * preview build. Extracted so tests can verify the contract (env flag + secret
21
- * + parent-env inheritance) without spinning up a child process — and so the
36
+ * preview build. Extracted so tests can verify the contract (env flag +
37
+ * parent-env inheritance) without spinning up a child process — and so the
22
38
  * real-process smoke test can call it the same way the integration does.
23
39
  *
24
40
  * Inherits the parent environment so PATH, credentials, and any host-specific
25
- * build vars (CF_PAGES_*, GITHUB_*) reach the child.
41
+ * build vars (CF_PAGES_*, WORKERS_CI_*, GITHUB_*) reach the child, which reads
42
+ * the branch and commit it serves from them.
26
43
  */
27
- export declare function buildPreviewChildEnv(parentEnv: NodeJS.ProcessEnv, previewSecret: string): NodeJS.ProcessEnv;
44
+ export declare function buildPreviewChildEnv(parentEnv: NodeJS.ProcessEnv, mode?: 'd2' | 'd3', prerendered?: readonly string[]): NodeJS.ProcessEnv;
28
45
  /**
29
46
  * Locate the `astro` CLI binary in the site's `node_modules/.bin/`. We
30
47
  * resolve relative to the current working directory (where `astro build` is
@@ -41,13 +58,10 @@ export declare function resolveAstroBin(cwd?: string): string;
41
58
  * Spawns the recursive preview `astro build` from the primary build's
42
59
  * `astro:build:done` hook.
43
60
  *
44
- * The child process inherits the parent environment and additionally receives:
45
- * - {@link PREVIEW_BUILD_ENV_FLAG} set to `'1'` so the integration's own
46
- * `astro:build:done` short-circuits inside the child (recursion guard
47
- * contract).
48
- * - {@link PREVIEW_SECRET_ENV_FLAG} set to the per-branch secret so the
49
- * child's `astro:config:setup` can inject the literal secret-scoped
50
- * preview route (`/conloca_preview_${SECRET}/[...path]`).
61
+ * The child process inherits the parent environment and additionally receives
62
+ * {@link PREVIEW_BUILD_ENV_FLAG} set to `'1'`: the child's `astro:config:setup`
63
+ * mounts the preview route on it, and its `astro:build:done` short-circuits
64
+ * on it (recursion guard contract).
51
65
  *
52
66
  * If this function is itself called from within a recursive build (i.e. the
53
67
  * env flag is already set to `'1'`), it returns immediately without spawning,
@@ -58,7 +72,7 @@ export declare function resolveAstroBin(cwd?: string): string;
58
72
  * - `false` → resolves and logs a warning so onboarding setups can continue
59
73
  * when the preview build is not yet wired correctly.
60
74
  */
61
- export declare function spawnPreviewBuild(previewSecret: string, opts: PreviewBuildOptions): Promise<void>;
75
+ export declare function spawnPreviewBuild(opts: PreviewBuildOptions, mode?: 'd2' | 'd3', prerendered?: readonly string[]): Promise<void>;
62
76
  /**
63
77
  * Internal seam that takes the spawn function as a parameter so tests can
64
78
  * substitute a fake. Public callers should use {@link spawnPreviewBuild}.
@@ -67,5 +81,5 @@ export declare function spawnPreviewBuild(previewSecret: string, opts: PreviewBu
67
81
  * and not part of the package's public surface; it is not re-exported from
68
82
  * `src/index.ts` or `src/node.ts`.
69
83
  */
70
- export declare function _spawnPreviewBuildWith(spawnFn: PreviewBuildSpawn, previewSecret: string, opts: PreviewBuildOptions): Promise<void>;
84
+ export declare function _spawnPreviewBuildWith(spawnFn: PreviewBuildSpawn, opts: PreviewBuildOptions, mode?: 'd2' | 'd3', prerendered?: readonly string[]): Promise<void>;
71
85
  //# sourceMappingURL=preview-build.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"preview-build.d.ts","sourceRoot":"","sources":["../../src/preview-build.ts"],"names":[],"mappings":"AAGA,OAAO,EAAwC,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAC/F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD,OAAO,EAAE,uBAAuB,EAAE,CAAC;AAEnC;;;;;;GAMG;AACH,MAAM,WAAW,wBAAwB;IACvC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,GAAG,OAAO,CAAC;CACrE;AAED,MAAM,MAAM,iBAAiB,GAAG,CAC9B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,OAAO,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,KAClD,wBAAwB,CAAC;AAE9B;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,CAAC,UAAU,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAAC,UAAU,CAM3G;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,GAAG,GAAE,MAAsB,GAAG,MAAM,CAcnE;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,iBAAiB,CAAC,aAAa,EAAE,MAAM,EAAE,IAAI,EAAE,mBAAmB,GAAG,O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;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,MAAM,CAAC,UAAU,EAC5B,IAAI,GAAE,IAAI,GAAG,IAAW,EACxB,WAAW,GAAE,SAAS,MAAM,EAAO,GAClC,MAAM,CAAC,UAAU,CAMnB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,GAAG,GAAE,MAAsB,GAAG,MAAM,CAcnE;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,mBAAmB,EACzB,IAAI,GAAE,IAAI,GAAG,IAAW,EACxB,WAAW,GAAE,SAAS,MAAM,EAAO,GAClC,OAAO,CAAC,IAAI,CAAC,CAEf;AAED;;;;;;;GAOG;AAEH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,iBAAiB,EAC1B,IAAI,EAAE,mBAAmB,EACzB,IAAI,GAAE,IAAI,GAAG,IAAW,EACxB,WAAW,GAAE,SAAS,MAAM,EAAO,GAClC,OAAO,CAAC,IAAI,CAAC,CAoCf"}
@@ -1,23 +1,69 @@
1
1
  import { spawn } from 'node:child_process';
2
2
  import { existsSync } from 'node:fs';
3
3
  import { join } from 'node:path';
4
- import { PACKAGE_NAME, PREVIEW_BUILD_ENV_FLAG, PREVIEW_SECRET_ENV_FLAG } from './constants.js';
5
- export { PREVIEW_SECRET_ENV_FLAG };
4
+ import { PACKAGE_NAME, PREVIEW_BUILD_ENV_FLAG, PREVIEW_MODE_ENV, PREVIEW_PRERENDERED_ENV, REFUSED_PREVIEW_ADAPTERS, } from './constants.js';
5
+ /**
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.
11
+ */
12
+ export function previewBuildMode(previewBuild, adapterName) {
13
+ if (!previewBuild)
14
+ 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(...).');
19
+ }
20
+ if (previewBuild.separate === true)
21
+ return 'd4';
22
+ return adapterName === undefined ? 'd3' : 'd2';
23
+ }
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). */
25
+ export function previewChildMode(env) {
26
+ const named = env[PREVIEW_MODE_ENV];
27
+ return named === 'd2' || named === 'd3' ? named : 'd4';
28
+ }
29
+ /**
30
+ * One route the site's build prerendered, as a D3 child matches it: pattern and component together, since one
31
+ * entrypoint can be injected at two patterns, one published and one only the preview build has.
32
+ */
33
+ export function prerenderedKey(pattern, component) {
34
+ return JSON.stringify([pattern, component]);
35
+ }
36
+ /** The routes (`prerenderedKey`) a D3 child's site build prerendered (`buildPreviewChildEnv`); none for any other child. */
37
+ export function previewChildPrerendered(env) {
38
+ const text = env[PREVIEW_PRERENDERED_ENV];
39
+ if (previewChildMode(env) !== 'd3' || text === undefined)
40
+ return new Set();
41
+ let value;
42
+ try {
43
+ value = JSON.parse(text);
44
+ }
45
+ catch {
46
+ return new Set();
47
+ }
48
+ return new Set(Array.isArray(value) ? value.filter((item) => typeof item === 'string') : []);
49
+ }
6
50
  /**
7
51
  * Pure constructor for the child-process environment passed to the recursive
8
- * preview build. Extracted so tests can verify the contract (env flag + secret
9
- * + parent-env inheritance) without spinning up a child process — and so the
52
+ * preview build. Extracted so tests can verify the contract (env flag +
53
+ * parent-env inheritance) without spinning up a child process — and so the
10
54
  * real-process smoke test can call it the same way the integration does.
11
55
  *
12
56
  * Inherits the parent environment so PATH, credentials, and any host-specific
13
- * build vars (CF_PAGES_*, GITHUB_*) reach the child.
57
+ * build vars (CF_PAGES_*, WORKERS_CI_*, GITHUB_*) reach the child, which reads
58
+ * the branch and commit it serves from them.
14
59
  */
15
- export function buildPreviewChildEnv(parentEnv, previewSecret) {
16
- return {
17
- ...parentEnv,
18
- [PREVIEW_BUILD_ENV_FLAG]: '1',
19
- [PREVIEW_SECRET_ENV_FLAG]: previewSecret,
20
- };
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;
21
67
  }
22
68
  /**
23
69
  * Locate the `astro` CLI binary in the site's `node_modules/.bin/`. We
@@ -47,13 +93,10 @@ export function resolveAstroBin(cwd = process.cwd()) {
47
93
  * Spawns the recursive preview `astro build` from the primary build's
48
94
  * `astro:build:done` hook.
49
95
  *
50
- * The child process inherits the parent environment and additionally receives:
51
- * - {@link PREVIEW_BUILD_ENV_FLAG} set to `'1'` so the integration's own
52
- * `astro:build:done` short-circuits inside the child (recursion guard
53
- * contract).
54
- * - {@link PREVIEW_SECRET_ENV_FLAG} set to the per-branch secret so the
55
- * child's `astro:config:setup` can inject the literal secret-scoped
56
- * preview route (`/conloca_preview_${SECRET}/[...path]`).
96
+ * The child process inherits the parent environment and additionally receives
97
+ * {@link PREVIEW_BUILD_ENV_FLAG} set to `'1'`: the child's `astro:config:setup`
98
+ * mounts the preview route on it, and its `astro:build:done` short-circuits
99
+ * on it (recursion guard contract).
57
100
  *
58
101
  * If this function is itself called from within a recursive build (i.e. the
59
102
  * env flag is already set to `'1'`), it returns immediately without spawning,
@@ -64,8 +107,8 @@ export function resolveAstroBin(cwd = process.cwd()) {
64
107
  * - `false` → resolves and logs a warning so onboarding setups can continue
65
108
  * when the preview build is not yet wired correctly.
66
109
  */
67
- export async function spawnPreviewBuild(previewSecret, opts) {
68
- await _spawnPreviewBuildWith(spawn, previewSecret, opts);
110
+ export async function spawnPreviewBuild(opts, mode = 'd2', prerendered = []) {
111
+ await _spawnPreviewBuildWith(spawn, opts, mode, prerendered);
69
112
  }
70
113
  /**
71
114
  * Internal seam that takes the spawn function as a parameter so tests can
@@ -75,20 +118,18 @@ export async function spawnPreviewBuild(previewSecret, opts) {
75
118
  * and not part of the package's public surface; it is not re-exported from
76
119
  * `src/index.ts` or `src/node.ts`.
77
120
  */
78
- export async function _spawnPreviewBuildWith(spawnFn, previewSecret, opts) {
121
+ // oxlint-disable-next-line no-underscore-dangle -- the internal test seam.
122
+ export async function _spawnPreviewBuildWith(spawnFn, opts, mode = 'd2', prerendered = []) {
79
123
  // Recursion guard: bail out before doing any work if we're already inside
80
124
  // a recursive preview build. This matches the short-circuit in the
81
125
  // integration's `astro:build:done` hook.
82
126
  if (process.env[PREVIEW_BUILD_ENV_FLAG] === '1') {
83
127
  return;
84
128
  }
85
- if (!previewSecret) {
86
- throw new Error(`${PACKAGE_NAME}: preview secret is required to spawn the preview build`);
87
- }
88
129
  const required = opts.required ?? true;
89
130
  const astroBin = resolveAstroBin();
90
131
  const child = spawnFn(astroBin, ['build'], {
91
- env: buildPreviewChildEnv(process.env, previewSecret),
132
+ env: buildPreviewChildEnv(process.env, mode, prerendered),
92
133
  stdio: 'inherit',
93
134
  });
94
135
  await new Promise((resolve, reject) => {
@@ -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,EAAE,YAAY,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CA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,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,IAAI,QAAQ,EAAE,CAAC;gBACb,MAAM,CAAC,IAAI,KAAK,CAAC,GAAG,YAAY,2BAA2B,MAAM,GAAG,CAAC,CAAC,CAAC;gBACvE,OAAO;YACT,CAAC;YACD,mEAAmE;YACnE,wEAAwE;YACxE,kEAAkE;YAClE,wDAAwD;YACxD,qEAAqE;YACrE,OAAO,CAAC,IAAI,CAAC,GAAG,YAAY,2BAA2B,MAAM,4CAA4C,CAAC,CAAC;YAC3G,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -2,5 +2,5 @@ export { getBannerScriptText, injectPreviewBanner } from './preview/banner.js';
2
2
  export { embeddedKey, PreviewContentAPI, type PreviewContentAPIOptions, } from './preview/content-api.js';
3
3
  export { applyPreviewHeaders } from './preview/headers.js';
4
4
  export { renderNoPreviewLanding } from './preview/landing.js';
5
- export { handlePreviewRequest, type PreviewContext, type PreviewMiddlewareOptions, type PreviewVerdict, previewParamName, } from './preview/middleware.js';
5
+ export { handlePreviewRequest, type PreviewContext, type PreviewMiddlewareOptions, type PreviewVerdict, } from './preview/middleware.js';
6
6
  //# sourceMappingURL=preview.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../src/preview.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,KAAK,wBAAwB,GAC9B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EACL,oBAAoB,EACpB,KAAK,cAAc,EACnB,KAAK,wBAAwB,EAC7B,KAAK,cAAc,EACnB,gBAAgB,GACjB,MAAM,yBAAyB,CAAC"}
1
+ {"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../src/preview.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,KAAK,wBAAwB,GAC9B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EACL,oBAAoB,EACpB,KAAK,cAAc,EACnB,KAAK,wBAAwB,EAC7B,KAAK,cAAc,GACpB,MAAM,yBAAyB,CAAC"}
@@ -8,5 +8,5 @@ export { getBannerScriptText, injectPreviewBanner } from './preview/banner.js';
8
8
  export { embeddedKey, PreviewContentAPI, } from './preview/content-api.js';
9
9
  export { applyPreviewHeaders } from './preview/headers.js';
10
10
  export { renderNoPreviewLanding } from './preview/landing.js';
11
- export { handlePreviewRequest, previewParamName, } from './preview/middleware.js';
11
+ export { handlePreviewRequest, } from './preview/middleware.js';
12
12
  //# sourceMappingURL=preview.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"preview.js","sourceRoot":"","sources":["../../src/preview.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,EAAE;AACF,0EAA0E;AAC1E,oEAAoE;AACpE,6EAA6E;AAC7E,6DAA6D;AAE7D,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EACL,WAAW,EACX,iBAAiB,GAElB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EACL,oBAAoB,EAIpB,gBAAgB,GACjB,MAAM,yBAAyB,CAAC"}
1
+ {"version":3,"file":"preview.js","sourceRoot":"","sources":["../../src/preview.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,EAAE;AACF,0EAA0E;AAC1E,oEAAoE;AACpE,6EAA6E;AAC7E,6DAA6D;AAE7D,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EACL,WAAW,EACX,iBAAiB,GAElB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EACL,oBAAoB,GAIrB,MAAM,yBAAyB,CAAC"}