@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
package/src/skill.ts CHANGED
@@ -2,10 +2,18 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
2
2
  import { createRequire } from 'node:module';
3
3
  import { dirname, join } from 'node:path';
4
4
  import { pathToFileURL } from 'node:url';
5
+ import { stampSkill } from '@conloca/content-api/skill-stamp';
5
6
  import { messageOf } from './message-of.js';
7
+ import { packageVersion } from './package-version.js';
6
8
 
7
9
  export const SKILL_RELATIVE_PATH = join('.claude', 'skills', 'conloca-cloud', 'SKILL.md');
8
10
 
11
+ /** The sha256 of every unstamped page a release wrote, so an upgrade can tell an untouched old page from an edited one. */
12
+ export const LEGACY_SKILL_CHECKSUMS: readonly string[] = [
13
+ '201dc9a1fe57038c32a46448228ab432cce060b0079225007ec6dec74ba46959', // 0.2.1, 0.2.2
14
+ '82edfffa022797265bee87289a491e7af12d8e13423f541892e281c416f0554a', // 0.2.3
15
+ ];
16
+
9
17
  /**
10
18
  * The canonical page, located from the package root (through the package's own `./package.json` export) so the
11
19
  * built `dist/src/skill.js` and the source `src/skill.ts` reach the same shipped `src/skill/SKILL.md`. Resolved on
@@ -39,21 +47,41 @@ export function findClaudeHome(projectRoot: string): string | undefined {
39
47
  }
40
48
  }
41
49
 
50
+ /**
51
+ * Where the site's agent skill page belongs and the text this release writes there, stamped with the release and the
52
+ * template's checksum. Null without a `.claude/` home or a readable package version.
53
+ */
54
+ export function agentSkill(
55
+ projectRoot: string,
56
+ ): { path: string; text: string; legacyChecksums: readonly string[] } | null {
57
+ const home = findClaudeHome(projectRoot);
58
+ const version = packageVersion();
59
+ if (home === undefined || version === undefined) return null;
60
+ return {
61
+ path: join(home, SKILL_RELATIVE_PATH),
62
+ text: stampSkill(readFileSync(skillTemplateUrl(), 'utf8'), version),
63
+ legacyChecksums: LEGACY_SKILL_CHECKSUMS,
64
+ };
65
+ }
66
+
42
67
  /**
43
68
  * Write the skill page once — never overwrite, never throw. A read-only CI
44
69
  * checkout must not break a build over documentation.
45
70
  */
46
71
  export function scaffoldSkill(projectRoot: string, logger: SkillLogger): 'written' | 'exists' | 'skipped' | 'failed' {
47
- const home = findClaudeHome(projectRoot);
48
- if (home === undefined) {
49
- logger.debug('no .claude/ directory between the project and the git root — agent skill not scaffolded');
50
- return 'skipped';
51
- }
52
- const target = join(home, SKILL_RELATIVE_PATH);
53
- if (existsSync(target)) return 'exists';
72
+ let target = SKILL_RELATIVE_PATH;
54
73
  try {
74
+ const skill = agentSkill(projectRoot);
75
+ if (skill === null) {
76
+ logger.debug(
77
+ 'no .claude/ directory between the project and the git root, or no readable package version — agent skill not scaffolded',
78
+ );
79
+ return 'skipped';
80
+ }
81
+ target = skill.path;
82
+ if (existsSync(target)) return 'exists';
55
83
  mkdirSync(dirname(target), { recursive: true });
56
- writeFileSync(target, readFileSync(skillTemplateUrl(), 'utf8'), { flag: 'wx' });
84
+ writeFileSync(target, skill.text, { flag: 'wx' });
57
85
  logger.info(`agent skill written to ${target}`);
58
86
  return 'written';
59
87
  } catch (error) {
package/src/types.ts CHANGED
@@ -1,13 +1,10 @@
1
1
  import type { AstroIntegration } from 'astro';
2
- import type { Plugin as EsbuildPlugin } from 'esbuild';
3
2
 
4
3
  /**
5
- * Configuration for a recursive preview build that runs immediately after the
6
- * site's production build completes. The preview build emits the SSR routes
7
- * that serve draft preview.
8
- *
9
- * Set to `false` to explicitly opt out of preview builds for sites that do not
10
- * need a draft/preview pipeline.
4
+ * The second build that serves draft previews. Off unless given as an object. A static site's preview server runs on
5
+ * Cloudflare Workers under `/_conloca/preview/` next to the site (it needs `@astrojs/cloudflare` installed); a site
6
+ * with an adapter serves drafts from its own server deploy; `separate: true` builds a separate preview deploy.
7
+ * Refused under `@astrojs/vercel` and `@astrojs/netlify`.
11
8
  */
12
9
  export interface PreviewBuildOptions {
13
10
  /**
@@ -21,32 +18,39 @@ export interface PreviewBuildOptions {
21
18
  config?: Record<string, unknown>;
22
19
  /**
23
20
  * Output directory for the preview build. Defaults to `.conloca/preview-server`
24
- * — outside `dist/`, so the secret-baked artifact can never ride a wholesale
25
- * static upload of the site and Astro's dist-clearing cannot wipe it.
21
+ * — outside `dist/`, so the preview server can never ride a wholesale static
22
+ * upload of the site and Astro's dist-clearing cannot wipe it.
26
23
  */
27
24
  outDir?: string;
28
25
  /**
29
- * If true, fail the parent build when the preview build fails. Defaults to
30
- * true; set false while setting up.
26
+ * If true, fail the site's build when a D2 preview build fails. Defaults to true; set false while setting up.
27
+ * A failed D3 preview build fails the site's build only when its server also serves the live site (`run_worker_first`
28
+ * lists routes beyond the preview route, or `not_found_handling` is `"none"`); otherwise the site ships and its
29
+ * preview route answers "preview unavailable". This option changes neither.
31
30
  */
32
31
  required?: boolean;
32
+ /**
33
+ * Serve previews from a separate deploy (D4) instead of next to the site. The site's build then runs no preview
34
+ * build; a second deploy builds with `CONLOCA_PREVIEW_BUILD=1`, and its address goes in sites.json `previewUrl`.
35
+ */
36
+ separate?: boolean;
33
37
  }
34
38
 
35
39
  /**
36
- * Options accepted by {@link conlocaCloud}.
37
- *
38
- * Registration authenticates with one build token (`cbt_<id>.<secret>`)
39
- * issued by the endpoint. Repository identity is normally detected from CI metadata or the Git
40
- * checkout.
40
+ * Options accepted by {@link conlocaCloud}. Every one is optional: repository
41
+ * identity is normally detected from CI metadata or the Git checkout, and the
42
+ * editor options come from `conlocaCMS`.
41
43
  */
42
44
  export interface ConlocaCloudOptions {
43
- /** Editor endpoint, e.g. 'https://cms.example.com', no trailing slash. */
44
- endpoint: string;
45
+ /**
46
+ * The workspace editor's address, no trailing slash. Defaults to
47
+ * 'https://app.conloca.com'. Its host must start with `app.`.
48
+ */
49
+ endpoint?: string;
45
50
  /**
46
51
  * Advanced override for repository identity, normalized to `owner/repo`.
47
52
  * Normally omit this: Conloca detects GitHub, Vercel, or GitLab CI metadata,
48
- * then falls back to the checkout's `remote.origin.url`. Registration is
49
- * rejected when the token does not cover the detected repo.
53
+ * then falls back to the checkout's `remote.origin.url`.
50
54
  */
51
55
  repoUri?: string;
52
56
  /**
@@ -56,82 +60,32 @@ export interface ConlocaCloudOptions {
56
60
  * that contradicts it fails the build — never a silent pick.
57
61
  */
58
62
  siteId?: string;
59
- /**
60
- * Build token issued by the endpoint. Prefer injecting it via the
61
- * CONLOCA_BUILD_TOKEN environment variable instead of committing it here;
62
- * when neither is present the build skips registration (fail soft, unless
63
- * `requireRegistration` is set).
64
- */
65
- buildToken?: string;
66
63
  /**
67
64
  * Entry module of the puck config to compile into the editor bundle,
68
65
  * e.g. './src/puck.config.tsx'. Same option name as @conloca/astro-cms.
66
+ * Defaults to the `conlocaCMS` value.
69
67
  */
70
- puckConfigPath: string;
68
+ puckConfigPath?: string;
71
69
  /**
72
70
  * Site CSS for accurate preview rendering — same option name and shape
73
71
  * as `conlocaCMS({ siteStyles })`, and compiled the same way: by the site's
74
72
  * own Vite pipeline (its plugins, PostCSS config and preprocessors), into
75
- * the canvas stylesheet each build registers, ahead of the
73
+ * the editor page's canvas stylesheet, ahead of the
76
74
  * component modules, e.g. './src/styles/index.scss'. Paths resolve against
77
75
  * the project root. The assets these stylesheets reference are emitted under
78
- * `/_conloca/`, and an entry that fails to compile fails the build. Component
76
+ * `/_conloca/editor/`, and an entry that fails to compile fails the build. Component
79
77
  * `*.module.(s)css` imports compile in automatically — list here only what
80
- * lives outside the component graph.
78
+ * lives outside the component graph. Defaults to the `conlocaCMS` value.
81
79
  */
82
80
  siteStyles?: string | string[];
83
81
  /**
84
- * esbuild plugins for the editor bundle (puck config, its components and the
85
- * conlocaCMS schemas module). That bundle is built with esbuild, outside the
86
- * site's Vite pipeline, so a source transform the site's Vite plugins apply
87
- * — e.g. Typia's `createValidate<T>()` generation in page schemas — must be
88
- * passed here in its esbuild form too, or the bundle carries untransformed
89
- * calls that throw when the editor loads it.
90
- */
91
- editorBundlePlugins?: EsbuildPlugin[];
92
- /**
93
- * Representative content route for build-time style discovery — the SAME
94
- * name and meaning as `conlocaCMS`'s option: the page whose styles and
95
- * content-wrapper shape prose editing should adopt. When set, the build
96
- * reads that route's rendered page (a prerendered file, or the booted node
97
- * server entry), collects its CSS and wrapper shape, and registers them
98
- * alongside the bundle. Unset: discovery is skipped and the editor falls
99
- * back to the prose-safe derived tier.
100
- *
101
- * @example '/blog/welcome-post'
102
- */
103
- fragmentPreviewRoute?: string;
104
-
105
- /**
106
- * Public base URL of the deployed site, used to absolutize the editor
107
- * bundle URL when no dedicated preview domain is configured. Falls back to
108
- * the CF_PAGES_URL env var; without either, registration is skipped.
109
- */
110
- publicBaseUrl?: string;
111
- /**
112
- * Optional dedicated preview deployment as a hostname or absolute URL. A
113
- * hostname is normalized to HTTPS. When set, editor assets and preview links
114
- * use this deployment instead of the production site's public base URL.
115
- */
116
- previewDomain?: string;
117
- /**
118
- * Recursive preview build configuration. Set to `false` to opt out.
119
- * Defaults to enabled with project defaults.
82
+ * Off unless given as an object; the second build that serves draft
83
+ * previews. Refused under @astrojs/vercel and @astrojs/netlify.
120
84
  */
121
85
  previewBuild?: PreviewBuildOptions | false;
122
86
  /**
123
- * The token issuer (the JWT `iss` the preview middleware pins).
124
- * Set it to bake the value into the preview artifact; otherwise the
125
- * deployment must supply `CONLOCA_SAAS_ISSUER` at runtime.
87
+ * The token issuer (the JWT `iss`) every pass must name. Unset, the preview server checks the pass against the
88
+ * endpoint's published keys alone, so a site sets nothing at runtime; set it (or `CONLOCA_SAAS_ISSUER`) to pin it.
126
89
  */
127
90
  saasIssuer?: string;
128
- /**
129
- * Fail the build when registration is SKIPPED for a missing prerequisite
130
- * (no build token, no repository identity, no git sha/branch, no public
131
- * base URL). Default false, so a plain `astro build` without the token
132
- * stays untouched. Turn it on in CI once setup is done: a deploy can
133
- * then never silently leave the editor at the endpoint stale. An ATTEMPTED
134
- * registration that fails always fails the build, regardless of this.
135
- */
136
- requireRegistration?: boolean;
137
91
  }
@@ -11,11 +11,14 @@
11
11
  */
12
12
  declare module 'virtual:conloca-preview-opts' {
13
13
  const baked: {
14
- secret?: string;
15
14
  saasEndpoint?: string;
16
15
  saasIssuer?: string;
17
16
  saasAudience?: string;
18
17
  buildCommit?: string;
18
+ repo?: string;
19
+ siteId?: string;
20
+ branch?: string;
21
+ base?: string;
19
22
  };
20
23
  export default baked;
21
24
  }
@@ -1,19 +0,0 @@
1
- /**
2
- * The commit a registration names and the commit the artifact was built from.
3
- * They differ only when CI hands over the branch's latest commit
4
- * (`CF_PAGES_COMMIT_SHA`) while building another commit — a pull request's
5
- * merge commit — because the endpoint can only serve a commit the branch
6
- * actually carries.
7
- */
8
- export interface RegistrationCommits {
9
- gitSha: string | undefined;
10
- buildId: string | undefined;
11
- }
12
- /** Resolves which commit the registration names and which commit produced the bundle. */
13
- export declare function registrationCommits(input: {
14
- /** The branch's latest commit, as CI hands it over through CF_PAGES_COMMIT_SHA. */
15
- eventCommitSha: string | undefined;
16
- /** git rev-parse HEAD in the build checkout. */
17
- checkoutCommitSha: string | undefined;
18
- }): RegistrationCommits;
19
- //# sourceMappingURL=build-commit.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build-commit.d.ts","sourceRoot":"","sources":["../../src/build-commit.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B;AAED,yFAAyF;AACzF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE;IACzC,mFAAmF;IACnF,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,gDAAgD;IAChD,iBAAiB,EAAE,MAAM,GAAG,SAAS,CAAC;CACvC,GAAG,mBAAmB,CAGtB"}
@@ -1,6 +0,0 @@
1
- /** Resolves which commit the registration names and which commit produced the bundle. */
2
- export function registrationCommits(input) {
3
- const gitSha = input.eventCommitSha ?? input.checkoutCommitSha;
4
- return { gitSha, buildId: input.checkoutCommitSha ?? gitSha };
5
- }
6
- //# sourceMappingURL=build-commit.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build-commit.js","sourceRoot":"","sources":["../../src/build-commit.ts"],"names":[],"mappings":"AAYA,yFAAyF;AACzF,MAAM,UAAU,mBAAmB,CAAC,KAKnC;IACC,MAAM,MAAM,GAAG,KAAK,CAAC,cAAc,IAAI,KAAK,CAAC,iBAAiB,CAAC;IAC/D,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,iBAAiB,IAAI,MAAM,EAAE,CAAC;AAChE,CAAC"}
@@ -1,181 +0,0 @@
1
- import type { TemplateConfig } from '@conloca/astro-cms';
2
- import type { EditorDataBindings } from '@conloca/content-api';
3
- import { type Plugin } from 'esbuild';
4
- import { type UserConfig } from 'vite';
5
- /**
6
- * Modules the editor bundle must NEVER contain. The editor (served from
7
- * `endpoint`) supplies them at runtime so the site's components
8
- * execute on the editor's own React instance — a second bundled React breaks
9
- * hooks/context. `@puckeditor/core` is the puck editor package the site's
10
- * config builds its component definitions against.
11
- *
12
- * KEEP IN SYNC with the modules the editor at the endpoint supplies: the two lists
13
- * are one contract, so every specifier externalized here needs an entry there
14
- * or the site's bundle fails bare-specifier resolution in the browser. Each side
15
- * pins the list in its own tests.
16
- */
17
- export declare const EDITOR_BUNDLE_EXTERNALS: readonly ['react', 'react-dom', 'react/jsx-runtime', 'react/jsx-dev-runtime', 'react-dom/client', '@puckeditor/core'];
18
- /**
19
- * Editor descriptors compiled into the bundle, next to the puck config and
20
- * the site styles. Sourced from what `conlocaCMS` resolved and published —
21
- * this package never grows its own option for them.
22
- */
23
- export interface EditorBundleDescriptors {
24
- /**
25
- * Absolute path of the host's schemas module (conlocaCMS `schemasPath`).
26
- * Its `pageSchemas` / `dataSchemas` / `mdxComponents` exports are
27
- * re-exported by the bundle, so the editor at the endpoint reads them off bytes it
28
- * already hash-verified — no second fetch, no second trust decision.
29
- */
30
- schemasPath?: string;
31
- /**
32
- * Auto-discovered MDX descriptors (conlocaCMS `mdxComponentFolders`),
33
- * serialized into the bundle verbatim. Opaque here on purpose: the shape
34
- * is cms-spa's contract and this package only transports it.
35
- */
36
- discoveredMdxComponents?: readonly unknown[];
37
- /**
38
- * Page-creation templates (conlocaCMS `templates`), serialized into the
39
- * bundle verbatim. Typed by the `@conloca/astro-cms` peer, whose
40
- * `readEditorDescriptors` produced the value this package transports.
41
- */
42
- templates?: Record<string, TemplateConfig>;
43
- /**
44
- * The routing data bindings (conlocaCMS `routing`), serialized into the
45
- * bundle verbatim, so the editor at the endpoint builds each page's data context from
46
- * the same routes the published page resolves with.
47
- */
48
- dataBindings?: EditorDataBindings;
49
- }
50
- export interface BundleEditorAssetsInput {
51
- /** Build output directory (Astro's `dir`, as a filesystem path). */
52
- dir: string;
53
- /** The Astro project root, as a filesystem path: siteStyles resolve against it. */
54
- root: string;
55
- /** The site's own Vite config (Astro's `config.vite`), which compiles siteStyles. */
56
- vite: UserConfig;
57
- /** Entry module of the site's puck config (same option name as @conloca/astro-cms). */
58
- puckConfigPath: string;
59
- /**
60
- * Site CSS for accurate preview rendering (the `siteStyles` option),
61
- * compiled by the site's own Vite pipeline into the same registered
62
- * stylesheet AHEAD of the component modules, so component rules keep the
63
- * final word.
64
- */
65
- siteStyles?: string | string[];
66
- /**
67
- * Public origin the deployed site answers on (the `publicBaseUrl` option).
68
- * Root-relative asset URLs in the registered stylesheet are absolutized
69
- * against it, since that stylesheet is applied inside the editor's canvas
70
- * rather than on the site. Omitted: URLs stay as authored.
71
- */
72
- publicBaseUrl?: string;
73
- /**
74
- * Editor descriptors published by conlocaCMS for this build. Absent for a
75
- * CMS-less build, or when there is nothing to carry (no schemas module,
76
- * discoverable MDX component, page template or data binding) — in which case
77
- * the emitted bytes are identical to a pre-descriptor build (no gratuitous
78
- * hash churn).
79
- */
80
- descriptors?: EditorBundleDescriptors;
81
- /**
82
- * Extra esbuild plugins for the editor bundle (the `editorBundlePlugins`
83
- * option), run after the built-in stylesheet compiler: the site's own Vite
84
- * plugins never see this graph, so a source transform the schemas module or
85
- * a component needs (e.g. Typia's) has to be supplied in esbuild form.
86
- */
87
- plugins?: Plugin[];
88
- logger: {
89
- info(message: string): void;
90
- warn(message: string): void;
91
- };
92
- }
93
- export interface BundledStylesheet {
94
- /** Site-relative URL of the emitted stylesheet, e.g. `/_conloca/editor-bundle.<hash16>.css`. */
95
- url: string;
96
- /** FULL sha-256 hex of the stylesheet bytes — the editor hash-verifies against this. */
97
- hash: string;
98
- /** The emitted stylesheet bytes. */
99
- bytes: Uint8Array;
100
- }
101
- export interface BundleEditorAssetsResult {
102
- /** Site-relative URL of the emitted bundle, e.g. `/_conloca/editor-bundle.<hash16>.js`. */
103
- url: string;
104
- /** FULL sha-256 hex of the bundle bytes — the editor hash-verifies against this. */
105
- hash: string;
106
- /** The emitted bundle bytes. */
107
- bytes: Uint8Array;
108
- /**
109
- * Companion stylesheet for the editing canvas (styled canvas):
110
- * any siteStyles, then the config graph's compiled CSS/SCSS modules.
111
- * Absent when neither carries styles.
112
- */
113
- stylesheet?: BundledStylesheet;
114
- /**
115
- * `_headers` paths granted CORS for the stylesheet's own assets, so the
116
- * mirrored asset set (a deployment that serves the site and the preview from
117
- * one Cloudflare Worker) can be given the same rules.
118
- */
119
- assetCorsPaths: string[];
120
- }
121
- /**
122
- * Bundles the site's puck config into a browser ESM file plus (when the
123
- * graph carries styles) a companion stylesheet, both under `<dir>/_conloca/`,
124
- * content-addressed by the first 16 hex chars of their sha-256, and ensures
125
- * `<dir>/_headers` carries the CORS rule the editor needs to load them
126
- * cross-origin.
127
- *
128
- * The siteStyles compile first, through the site's own Vite pipeline (see
129
- * `compileSiteStyles`); one that fails to compile fails the build.
130
- *
131
- * Component styles compile in the SAME esbuild pass as the JS: CSS-module
132
- * class names are hashed consistently across both outputs, so `styles.foo` in
133
- * a component always matches a selector in the emitted stylesheet. SCSS
134
- * compiles through `sass`; a component stylesheet that fails to compile is
135
- * stripped with a warning instead of failing the build (one broken component
136
- * stylesheet must not cost the site its registration).
137
- */
138
- export declare function bundleEditorAssets(input: BundleEditorAssetsInput): Promise<BundleEditorAssetsResult>;
139
- /**
140
- * Re-points the registered stylesheet's asset references at the deployed site.
141
- *
142
- * Only ROOT-relative URLs (`/fonts/x.otf`) are rewritten — those name a path
143
- * on the site and nothing else. That includes the `/_conloca/` assets the
144
- * siteStyles build emitted, since Vite resolves their relative references.
145
- * Path-relative ones (`./x.otf`, `../x.otf`, `x.otf`) cannot be resolved here
146
- * and are reported instead of guessed: esbuild flattens every component
147
- * stylesheet into ONE output and copies url() paths through verbatim, so by
148
- * this point the emitted text no longer records WHICH source directory each
149
- * one was relative to. Absolute, protocol-relative, `data:` and fragment
150
- * (`#filter`) refs already resolve correctly and are left alone.
151
- *
152
- * Returns the rewritten CSS plus the `_headers` globs its assets need — one
153
- * per distinct directory rather than one per file, which keeps a font family
154
- * of forty weights to a single rule.
155
- */
156
- export declare function rewriteStylesheetAssetUrls(css: string, publicBaseUrl: string, logger: BundleEditorAssetsInput['logger']): {
157
- css: string;
158
- assetCorsPaths: string[];
159
- };
160
- /**
161
- * Writes the discovery route's collected CSS as a content-addressed artifact
162
- * next to the editor bundle: `_conloca/route-css.<hash16>.css`.
163
- * Same serving story as the editor stylesheet — the `/_conloca/*` CORS rule
164
- * already covers it, and `mirrorEditorAssets` copies the whole dir.
165
- */
166
- export declare function emitRouteCssArtifact(dir: string, css: string, publicBaseUrl: string | undefined, logger: BundleEditorAssetsInput['logger']): Promise<{
167
- stylesheet: BundledStylesheet;
168
- assetCorsPaths: string[];
169
- } | undefined>;
170
- /**
171
- * Mirrors the emitted editor assets (`_conloca/` + the CORS rule) from the
172
- * primary build's output into another asset directory — the recursive preview
173
- * build's client dir. The bundle is only ever compiled into the PRIMARY
174
- * build's dist (the child build short-circuits `astro:build:done` to avoid
175
- * registration recursion), but in a deployment that serves the site and the
176
- * preview from one Cloudflare Worker, the child's client dir is the asset set
177
- * that actually serves the site, so without this mirror the editor at the
178
- * endpoint cannot load its component bundle.
179
- */
180
- export declare function mirrorEditorAssets(fromDir: string, toDir: string, assetCorsPaths?: string[]): Promise<void>;
181
- //# sourceMappingURL=bundle.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../src/bundle.ts"],"names":[],"mappings":"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"}