@conloca/cloud-astro 0.2.2 → 0.2.3

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 (176) hide show
  1. package/README.md +261 -208
  2. package/dist/.build-inputs.json +60 -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 +5 -13
  8. package/dist/src/constants.d.ts.map +1 -1
  9. package/dist/src/constants.js +5 -13
  10. package/dist/src/constants.js.map +1 -1
  11. package/dist/src/descriptors.d.ts +2 -2
  12. package/dist/src/descriptors.d.ts.map +1 -1
  13. package/dist/src/doctor/checks-address.d.ts +18 -0
  14. package/dist/src/doctor/checks-address.d.ts.map +1 -0
  15. package/dist/src/doctor/checks-address.js +163 -0
  16. package/dist/src/doctor/checks-address.js.map +1 -0
  17. package/dist/src/doctor/checks-live.d.ts +8 -5
  18. package/dist/src/doctor/checks-live.d.ts.map +1 -1
  19. package/dist/src/doctor/checks-live.js +220 -188
  20. package/dist/src/doctor/checks-live.js.map +1 -1
  21. package/dist/src/doctor/checks-offline.d.ts +8 -23
  22. package/dist/src/doctor/checks-offline.d.ts.map +1 -1
  23. package/dist/src/doctor/checks-offline.js +22 -239
  24. package/dist/src/doctor/checks-offline.js.map +1 -1
  25. package/dist/src/doctor/config-scan.d.ts +6 -3
  26. package/dist/src/doctor/config-scan.d.ts.map +1 -1
  27. package/dist/src/doctor/config-scan.js +21 -11
  28. package/dist/src/doctor/config-scan.js.map +1 -1
  29. package/dist/src/doctor/run.d.ts.map +1 -1
  30. package/dist/src/doctor/run.js +12 -10
  31. package/dist/src/doctor/run.js.map +1 -1
  32. package/dist/src/doctor/types.d.ts +7 -7
  33. package/dist/src/doctor/types.d.ts.map +1 -1
  34. package/dist/src/doctor/types.js +7 -7
  35. package/dist/src/doctor/types.js.map +1 -1
  36. package/dist/src/editor-page/bundle.d.ts +88 -0
  37. package/dist/src/editor-page/bundle.d.ts.map +1 -0
  38. package/dist/src/editor-page/bundle.js +370 -0
  39. package/dist/src/editor-page/bundle.js.map +1 -0
  40. package/dist/src/editor-page/emit.d.ts +33 -0
  41. package/dist/src/editor-page/emit.d.ts.map +1 -0
  42. package/dist/src/editor-page/emit.js +183 -0
  43. package/dist/src/editor-page/emit.js.map +1 -0
  44. package/dist/src/editor-page/framing.d.ts +23 -0
  45. package/dist/src/editor-page/framing.d.ts.map +1 -0
  46. package/dist/src/editor-page/framing.js +39 -0
  47. package/dist/src/editor-page/framing.js.map +1 -0
  48. package/dist/src/editor-page/page.d.ts +9 -0
  49. package/dist/src/editor-page/page.d.ts.map +1 -0
  50. package/dist/src/editor-page/page.js +31 -0
  51. package/dist/src/editor-page/page.js.map +1 -0
  52. package/dist/src/editor-page/site-base.d.ts +4 -0
  53. package/dist/src/editor-page/site-base.d.ts.map +1 -0
  54. package/dist/src/editor-page/site-base.js +13 -0
  55. package/dist/src/editor-page/site-base.js.map +1 -0
  56. package/dist/src/git.d.ts +11 -8
  57. package/dist/src/git.d.ts.map +1 -1
  58. package/dist/src/git.js +25 -8
  59. package/dist/src/git.js.map +1 -1
  60. package/dist/src/index.d.ts +3 -1
  61. package/dist/src/index.d.ts.map +1 -1
  62. package/dist/src/index.js +9 -6
  63. package/dist/src/index.js.map +1 -1
  64. package/dist/src/integration.d.ts +1 -1
  65. package/dist/src/integration.d.ts.map +1 -1
  66. package/dist/src/integration.js +245 -408
  67. package/dist/src/integration.js.map +1 -1
  68. package/dist/src/node.d.ts +3 -1
  69. package/dist/src/node.d.ts.map +1 -1
  70. package/dist/src/node.js +7 -2
  71. package/dist/src/node.js.map +1 -1
  72. package/dist/src/preview/_resolve-opts.d.ts +16 -10
  73. package/dist/src/preview/_resolve-opts.d.ts.map +1 -1
  74. package/dist/src/preview/_resolve-opts.js +21 -10
  75. package/dist/src/preview/_resolve-opts.js.map +1 -1
  76. package/dist/src/preview/banner.d.ts.map +1 -1
  77. package/dist/src/preview/banner.js +2 -4
  78. package/dist/src/preview/banner.js.map +1 -1
  79. package/dist/src/preview/cookie.d.ts +5 -2
  80. package/dist/src/preview/cookie.d.ts.map +1 -1
  81. package/dist/src/preview/cookie.js +5 -2
  82. package/dist/src/preview/cookie.js.map +1 -1
  83. package/dist/src/preview/label.d.ts +8 -0
  84. package/dist/src/preview/label.d.ts.map +1 -0
  85. package/dist/src/preview/label.js +14 -0
  86. package/dist/src/preview/label.js.map +1 -0
  87. package/dist/src/preview/landing.d.ts +2 -2
  88. package/dist/src/preview/landing.js +2 -2
  89. package/dist/src/preview/middleware.d.ts +25 -20
  90. package/dist/src/preview/middleware.d.ts.map +1 -1
  91. package/dist/src/preview/middleware.js +56 -51
  92. package/dist/src/preview/middleware.js.map +1 -1
  93. package/dist/src/preview/preview-path.d.ts +18 -5
  94. package/dist/src/preview/preview-path.d.ts.map +1 -1
  95. package/dist/src/preview/preview-path.js +24 -8
  96. package/dist/src/preview/preview-path.js.map +1 -1
  97. package/dist/src/preview/site-middleware.d.ts +5 -5
  98. package/dist/src/preview/site-middleware.d.ts.map +1 -1
  99. package/dist/src/preview/site-middleware.js +16 -16
  100. package/dist/src/preview/site-middleware.js.map +1 -1
  101. package/dist/src/preview-build.d.ts +18 -15
  102. package/dist/src/preview-build.d.ts.map +1 -1
  103. package/dist/src/preview-build.js +36 -21
  104. package/dist/src/preview-build.js.map +1 -1
  105. package/dist/src/preview.d.ts +1 -1
  106. package/dist/src/preview.d.ts.map +1 -1
  107. package/dist/src/preview.js +1 -1
  108. package/dist/src/preview.js.map +1 -1
  109. package/dist/src/repository.d.ts +1 -1
  110. package/dist/src/repository.js +1 -1
  111. package/dist/src/resolve-options.d.ts +17 -0
  112. package/dist/src/resolve-options.d.ts.map +1 -0
  113. package/dist/src/resolve-options.js +21 -0
  114. package/dist/src/resolve-options.js.map +1 -0
  115. package/dist/src/site-id.d.ts +0 -2
  116. package/dist/src/site-id.d.ts.map +1 -1
  117. package/dist/src/site-id.js +2 -3
  118. package/dist/src/site-id.js.map +1 -1
  119. package/dist/src/types.d.ts +21 -69
  120. package/dist/src/types.d.ts.map +1 -1
  121. package/package.json +37 -13
  122. package/src/component-manifest.ts +11 -8
  123. package/src/constants.ts +5 -14
  124. package/src/descriptors.ts +2 -2
  125. package/src/doctor/checks-address.ts +190 -0
  126. package/src/doctor/checks-live.ts +256 -268
  127. package/src/doctor/checks-offline.ts +24 -262
  128. package/src/doctor/config-scan.ts +21 -9
  129. package/src/doctor/run.ts +14 -16
  130. package/src/doctor/types.ts +7 -7
  131. package/src/editor-page/bundle.ts +482 -0
  132. package/src/editor-page/emit.ts +246 -0
  133. package/src/editor-page/framing.ts +62 -0
  134. package/src/editor-page/page.ts +37 -0
  135. package/src/editor-page/site-base.ts +11 -0
  136. package/src/git.ts +29 -10
  137. package/src/index.ts +20 -6
  138. package/src/integration.ts +255 -461
  139. package/src/node.ts +18 -2
  140. package/src/preview/_resolve-opts.ts +29 -11
  141. package/src/preview/banner.ts +2 -4
  142. package/src/preview/cookie.ts +5 -2
  143. package/src/preview/label.ts +12 -0
  144. package/src/preview/landing.ts +2 -2
  145. package/src/preview/middleware.ts +77 -66
  146. package/src/preview/preview-path.ts +26 -8
  147. package/src/preview/site-middleware.ts +16 -21
  148. package/src/preview-build.ts +42 -26
  149. package/src/preview-handler.astro +10 -8
  150. package/src/preview.ts +0 -1
  151. package/src/repository.ts +1 -1
  152. package/src/resolve-options.ts +37 -0
  153. package/src/site-id.ts +2 -4
  154. package/src/skill/SKILL.md +51 -55
  155. package/src/types.ts +21 -70
  156. package/src/virtual-modules.d.ts +4 -1
  157. package/dist/src/build-commit.d.ts +0 -19
  158. package/dist/src/build-commit.d.ts.map +0 -1
  159. package/dist/src/build-commit.js +0 -6
  160. package/dist/src/build-commit.js.map +0 -1
  161. package/dist/src/bundle.d.ts +0 -181
  162. package/dist/src/bundle.d.ts.map +0 -1
  163. package/dist/src/bundle.js +0 -413
  164. package/dist/src/bundle.js.map +0 -1
  165. package/dist/src/discovery.d.ts +0 -58
  166. package/dist/src/discovery.d.ts.map +0 -1
  167. package/dist/src/discovery.js +0 -133
  168. package/dist/src/discovery.js.map +0 -1
  169. package/dist/src/register.d.ts +0 -98
  170. package/dist/src/register.d.ts.map +0 -1
  171. package/dist/src/register.js +0 -103
  172. package/dist/src/register.js.map +0 -1
  173. package/src/build-commit.ts +0 -22
  174. package/src/bundle.ts +0 -570
  175. package/src/discovery.ts +0 -183
  176. package/src/register.ts +0 -180
@@ -0,0 +1,88 @@
1
+ import type { TemplateConfig } from '@conloca/astro-cms';
2
+ import type { EditorDataBindings } from '@conloca/content-api';
3
+ import { type UserConfig } from 'vite';
4
+ /**
5
+ * Modules the editor bundle must NEVER contain. The editor page maps them to
6
+ * the workspace editor's own copies, so the site's components
7
+ * execute on the editor's React instance — a second bundled React breaks
8
+ * hooks/context. `@puckeditor/core` is the puck editor package the site's
9
+ * config builds its component definitions against.
10
+ *
11
+ * KEEP IN SYNC with `EDITOR_UI_MODULE_FILES`: every specifier externalized
12
+ * here needs a file there or the site's bundle fails bare-specifier resolution
13
+ * in the browser. The editor page tests pin the two lists to each other.
14
+ */
15
+ export declare const EDITOR_BUNDLE_EXTERNALS: readonly ['react', 'react-dom', 'react/jsx-runtime', 'react/jsx-dev-runtime', 'react-dom/client', '@puckeditor/core'];
16
+ /**
17
+ * Editor descriptors compiled into the bundle, next to the puck config and
18
+ * the site styles. Sourced from what `conlocaCMS` resolved and published —
19
+ * this package never grows its own option for them.
20
+ */
21
+ export interface EditorBundleDescriptors {
22
+ /**
23
+ * Absolute path of the host's schemas module (conlocaCMS `schemasPath`).
24
+ * Its `pageSchemas` / `dataSchemas` / `mdxComponents` exports are
25
+ * re-exported by the bundle.
26
+ */
27
+ schemasPath?: string;
28
+ /**
29
+ * Auto-discovered MDX descriptors (conlocaCMS `mdxComponentFolders`),
30
+ * serialized into the bundle verbatim. Opaque here on purpose: the shape
31
+ * is cms-spa's contract and this package only transports it.
32
+ */
33
+ discoveredMdxComponents?: readonly unknown[];
34
+ /**
35
+ * Page-creation templates (conlocaCMS `templates`), serialized into the
36
+ * bundle verbatim. Typed by the `@conloca/astro-cms` peer, whose
37
+ * `readEditorDescriptors` produced the value this package transports.
38
+ */
39
+ templates?: Record<string, TemplateConfig>;
40
+ /**
41
+ * The routing data bindings (conlocaCMS `routing`), serialized into the
42
+ * bundle verbatim, so the editor builds each page's data context from the
43
+ * same routes the published page resolves with.
44
+ */
45
+ dataBindings?: EditorDataBindings;
46
+ }
47
+ export interface EditorPageBundleInput {
48
+ /** Build output directory (Astro's `dir`, as a filesystem path). */
49
+ dir: string;
50
+ /** The Astro project root, as a filesystem path: styles resolve against it. */
51
+ root: string;
52
+ /** The site's Vite config, including the transforms needed by components and schemas. */
53
+ vite: UserConfig;
54
+ /** Entry module of the site's puck config. */
55
+ puckConfigPath: string;
56
+ /**
57
+ * Stylesheets for the editing canvas, siteStyles then editorStyles, compiled
58
+ * in this order ahead of the component modules so component rules keep the
59
+ * final word.
60
+ */
61
+ styles: string[];
62
+ /** Editor descriptors published by conlocaCMS for this build. */
63
+ descriptors?: EditorBundleDescriptors;
64
+ logger: {
65
+ info(message: string): void;
66
+ warn(message: string): void;
67
+ };
68
+ }
69
+ export interface EditorPageBundle {
70
+ /** File name in `<dir>/_conloca/editor/`, `site.<first 16 hex of its sha-256>.js`. */
71
+ site: string;
72
+ /** `site.<first 16 hex of its sha-256>.css` in the same folder, or null when there is no CSS. */
73
+ css: string | null;
74
+ }
75
+ /**
76
+ * Compiles the puck config, its components and the schemas module through the
77
+ * site's Vite config into `<dir>/_conloca/editor/`: one ESM file plus, when the
78
+ * graph or `styles` carry CSS, one stylesheet, each named by the first 16 hex
79
+ * chars of its sha-256. Every file they reference is written under
80
+ * `_conloca/editor/assets/` and addressed relative to them. Content-file and
81
+ * `astro:` imports are refused.
82
+ *
83
+ * `styles` compile first so component rules keep the final word. Component Sass
84
+ * keeps its warn-and-strip fallback; configured JavaScript transforms and
85
+ * `styles` failures fail the build.
86
+ */
87
+ export declare function bundleEditorPage(input: EditorPageBundleInput): Promise<EditorPageBundle>;
88
+ //# sourceMappingURL=bundle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../../src/editor-page/bundle.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,OAAO,EAAoD,KAAK,UAAU,EAAE,MAAM,MAAM,CAAC;AAIzF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,uBAAuB,YAClC,OAAO,EACP,WAAW,EACX,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,EAClB,kBAAkB,CACV,CAAC;AAEX;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,uBAAuB,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;IAC7C;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC3C;;;;OAIG;IACH,YAAY,CAAC,EAAE,kBAAkB,CAAC;CACnC;AAED,MAAM,WAAW,qBAAqB;IACpC,oEAAoE;IACpE,GAAG,EAAE,MAAM,CAAC;IACZ,+EAA+E;IAC/E,IAAI,EAAE,MAAM,CAAC;IACb,yFAAyF;IACzF,IAAI,EAAE,UAAU,CAAC;IACjB,8CAA8C;IAC9C,cAAc,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,iEAAiE;IACjE,WAAW,CAAC,EAAE,uBAAuB,CAAC;IACtC,MAAM,EAAE;QAAE,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;CACtE;AAED,MAAM,WAAW,gBAAgB;IAC/B,sFAAsF;IACtF,IAAI,EAAE,MAAM,CAAC;IACb,iGAAiG;IACjG,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CACpB;AAsDD;;;;;;;;;;;GAWG;AACH,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAyI9F"}
@@ -0,0 +1,370 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { mkdir, readFile, writeFile } from 'node:fs/promises';
3
+ import { dirname, extname, join, resolve } from 'node:path';
4
+ import { compile as compileSass } from 'sass';
5
+ import { build as buildWithVite, mergeConfig } from 'vite';
6
+ import { PACKAGE_NAME } from '../constants.js';
7
+ import { messageOf } from '../message-of.js';
8
+ /**
9
+ * Modules the editor bundle must NEVER contain. The editor page maps them to
10
+ * the workspace editor's own copies, so the site's components
11
+ * execute on the editor's React instance — a second bundled React breaks
12
+ * hooks/context. `@puckeditor/core` is the puck editor package the site's
13
+ * config builds its component definitions against.
14
+ *
15
+ * KEEP IN SYNC with `EDITOR_UI_MODULE_FILES`: every specifier externalized
16
+ * here needs a file there or the site's bundle fails bare-specifier resolution
17
+ * in the browser. The editor page tests pin the two lists to each other.
18
+ */
19
+ export const EDITOR_BUNDLE_EXTERNALS = [
20
+ 'react',
21
+ 'react-dom',
22
+ 'react/jsx-runtime',
23
+ 'react/jsx-dev-runtime',
24
+ 'react-dom/client',
25
+ '@puckeditor/core',
26
+ ];
27
+ /** File extensions a component imports as a file, written beside the bundle. */
28
+ const EDITOR_ASSET_EXTENSIONS = [
29
+ 'woff',
30
+ 'woff2',
31
+ 'ttf',
32
+ 'otf',
33
+ 'eot',
34
+ 'png',
35
+ 'jpg',
36
+ 'jpeg',
37
+ 'gif',
38
+ 'svg',
39
+ 'webp',
40
+ 'avif',
41
+ ];
42
+ /** The asset extensions a component imports as an image, which the site's build hands over as Astro's image object. */
43
+ const IMAGE_EXTENSIONS = new Set(['png', 'jpg', 'jpeg', 'gif', 'svg', 'webp', 'avif']);
44
+ /**
45
+ * Optional exports transported from the site's schemas module to the editor.
46
+ * A namespace copy keeps absent names optional without generating missing-export
47
+ * diagnostics; the build plugin reports a module that declares none of them.
48
+ */
49
+ const SCHEMA_MODULE_EXPORTS = ['pageSchemas', 'dataSchemas', 'mdxComponents'];
50
+ /** The folder, relative to the build output, that holds every file of the editor page. */
51
+ const EDITOR_DIR = '_conloca/editor';
52
+ /** Where Vite writes the files the bundle and its stylesheets reference. */
53
+ const EDITOR_ASSETS_DIR = `${EDITOR_DIR}/assets`;
54
+ /** Stylesheets go beside the bundle, where the combined stylesheet is written, so their relative `url()`s stay valid. */
55
+ function editorAssetFileNames(info) {
56
+ return info.names.some((name) => name.endsWith('.css'))
57
+ ? `${EDITOR_DIR}/[name][extname]`
58
+ : `${EDITOR_ASSETS_DIR}/[name]-[hash][extname]`;
59
+ }
60
+ /**
61
+ * Compiles the puck config, its components and the schemas module through the
62
+ * site's Vite config into `<dir>/_conloca/editor/`: one ESM file plus, when the
63
+ * graph or `styles` carry CSS, one stylesheet, each named by the first 16 hex
64
+ * chars of its sha-256. Every file they reference is written under
65
+ * `_conloca/editor/assets/` and addressed relative to them. Content-file and
66
+ * `astro:` imports are refused.
67
+ *
68
+ * `styles` compile first so component rules keep the final word. Component Sass
69
+ * keeps its warn-and-strip fallback; configured JavaScript transforms and
70
+ * `styles` failures fail the build.
71
+ */
72
+ export async function bundleEditorPage(input) {
73
+ const stylesCss = await compileSiteStyles({
74
+ root: input.root,
75
+ vite: input.vite,
76
+ styles: input.styles,
77
+ dir: input.dir,
78
+ });
79
+ const entryPath = resolve(input.root, input.puckConfigPath);
80
+ const descriptors = input.descriptors;
81
+ const discovered = descriptors?.discoveredMdxComponents ?? [];
82
+ const virtualEntry = [
83
+ `export { default } from ${JSON.stringify(entryPath)};`,
84
+ // Copy the namespace before selecting optional names: a direct named
85
+ // re-export would reject schemas modules that declare only some of them.
86
+ ...(descriptors?.schemasPath
87
+ ? [
88
+ `import * as __conlocaSchemas from ${JSON.stringify(resolve(descriptors.schemasPath))};`,
89
+ 'const __conlocaDescriptors = { ...__conlocaSchemas };',
90
+ ...SCHEMA_MODULE_EXPORTS.map((name) => `export const ${name} = __conlocaDescriptors.${name};`),
91
+ ]
92
+ : []),
93
+ ...(discovered.length > 0 ? [`export const discoveredMdxComponents = ${JSON.stringify(discovered)};`] : []),
94
+ ...(descriptors?.templates ? [`export const templates = ${JSON.stringify(descriptors.templates)};`] : []),
95
+ ...(descriptors?.dataBindings ? [`export const dataBindings = ${JSON.stringify(descriptors.dataBindings)};`] : []),
96
+ ].join('\n');
97
+ const jsAssets = [];
98
+ const entryId = '\0conloca-editor-page-entry.js';
99
+ const bundlePlugin = {
100
+ name: 'conloca-editor-entry',
101
+ resolveId(id) {
102
+ return id === entryId ? id : null;
103
+ },
104
+ load(id) {
105
+ return id === entryId ? virtualEntry : null;
106
+ },
107
+ async generateBundle() {
108
+ if (!descriptors?.schemasPath)
109
+ return;
110
+ // Vite resolves symlinks (macOS's /var → /private/var), so look the module up by its resolved id.
111
+ const schemasId = (await this.resolve(resolve(descriptors.schemasPath)))?.id;
112
+ const exports = (schemasId && this.getModuleInfo(schemasId)?.exports) || [];
113
+ if (!SCHEMA_MODULE_EXPORTS.some((name) => exports.includes(name))) {
114
+ input.logger.warn(`${PACKAGE_NAME}: the schemas module at ${descriptors.schemasPath} exports none of ` +
115
+ 'pageSchemas, dataSchemas or mdxComponents — check the path and the export names.');
116
+ }
117
+ },
118
+ };
119
+ const siteConfig = {
120
+ ...normalizeBundlerOptions(input.vite),
121
+ plugins: [importedFiles(jsAssets), componentStyles(input.logger), bundlePlugin, ...(input.vite.plugins ?? [])],
122
+ };
123
+ const config = mergeConfig(siteConfig, {
124
+ configFile: false,
125
+ root: input.root,
126
+ base: './',
127
+ logLevel: 'warn',
128
+ oxc: { jsx: { runtime: 'automatic' } },
129
+ build: {
130
+ write: false,
131
+ copyPublicDir: false,
132
+ outDir: input.dir,
133
+ assetsDir: EDITOR_ASSETS_DIR,
134
+ assetsInlineLimit: 0,
135
+ cssCodeSplit: false,
136
+ minify: true,
137
+ sourcemap: false,
138
+ ssr: false,
139
+ watch: null,
140
+ lib: false,
141
+ manifest: false,
142
+ ssrManifest: false,
143
+ rolldownOptions: {
144
+ preserveEntrySignatures: 'strict',
145
+ onwarn(warning) {
146
+ input.logger.warn(`vite: ${warning.message}`);
147
+ },
148
+ },
149
+ },
150
+ });
151
+ // The editor page is one browser entry, not the site's configured app or
152
+ // library outputs. Keep all site plugins, but replace its output topology.
153
+ config.build.rolldownOptions.input = entryId;
154
+ config.build.rolldownOptions.external = editorExternal;
155
+ const configuredOutput = config.build.rolldownOptions.output;
156
+ if (Array.isArray(configuredOutput) && configuredOutput.length > 1) {
157
+ throw new Error(`${PACKAGE_NAME}: the editor page bundle requires a single Vite output configuration.`);
158
+ }
159
+ const output = Array.isArray(configuredOutput) ? configuredOutput[0] : configuredOutput;
160
+ config.build.rolldownOptions.output = {
161
+ plugins: output?.plugins,
162
+ format: 'es',
163
+ codeSplitting: false,
164
+ entryFileNames: `${EDITOR_DIR}/site.js`,
165
+ assetFileNames: editorAssetFileNames,
166
+ };
167
+ const result = await buildWithVite(config);
168
+ const files = [result].flat().flatMap((bundle) => ('output' in bundle ? bundle.output : []));
169
+ const jsFiles = files.filter((file) => file.type === 'chunk');
170
+ const cssFiles = files.filter((file) => file.type === 'asset' && file.fileName.endsWith('.css'));
171
+ const assetFiles = files.filter((file) => file.type === 'asset' && !file.fileName.endsWith('.css'));
172
+ if (jsFiles.length !== 1 || cssFiles.length > 1) {
173
+ throw new Error(`${PACKAGE_NAME}: expected the puck config to bundle to one ESM file (plus at most one stylesheet), ` +
174
+ `got ${files.map((file) => file.fileName).join(', ')}.`);
175
+ }
176
+ const outDir = join(input.dir, EDITOR_DIR);
177
+ await mkdir(outDir, { recursive: true });
178
+ await Promise.all([
179
+ ...assetFiles.map((file) => writeOutputFile(join(input.dir, file.fileName), file.source)),
180
+ ...jsAssets.map((asset) => writeOutputFile(join(input.dir, EDITOR_ASSETS_DIR, `${asset.sha256}.${asset.ext}`), asset.bytes)),
181
+ ]);
182
+ const bytes = new TextEncoder().encode(jsFiles[0].code);
183
+ const site = `site.${createHash('sha256').update(bytes).digest('hex').slice(0, 16)}.js`;
184
+ await writeFile(join(outDir, site), bytes);
185
+ input.logger.info(`editor page bundle written: ${EDITOR_DIR}/${site} (${bytes.byteLength} bytes)`);
186
+ const cssSource = cssFiles[0]?.source;
187
+ const componentCss = typeof cssSource === 'string' ? cssSource : new TextDecoder().decode(cssSource);
188
+ // Styles first, so component rules keep the final word.
189
+ const rawCss = [stylesCss, componentCss].filter(Boolean).join('\n');
190
+ if (rawCss === '')
191
+ return { site, css: null };
192
+ const cssBytes = new TextEncoder().encode(rawCss);
193
+ const css = `site.${createHash('sha256').update(cssBytes).digest('hex').slice(0, 16)}.css`;
194
+ await writeFile(join(outDir, css), cssBytes);
195
+ input.logger.info(`editor page stylesheet written: ${EDITOR_DIR}/${css} (${cssBytes.byteLength} bytes)`);
196
+ return { site, css };
197
+ }
198
+ async function writeOutputFile(path, source) {
199
+ await mkdir(dirname(path), { recursive: true });
200
+ await writeFile(path, source);
201
+ }
202
+ /** The virtual module for a file a component imports. */
203
+ const ASSET_MODULE_PREFIX = '\0conloca-editor-file:';
204
+ /** MDX pages and content files are user content, never bundle code. */
205
+ const CONTENT_FILE = /\.(mdx|vxjson)$/i;
206
+ /**
207
+ * Rolldown checks unresolved imports before calling resolvers, then resolved
208
+ * imports too. Reject content and Astro's virtual modules here so a site's pre
209
+ * resolver or Vite alias cannot turn them into executable JavaScript first.
210
+ */
211
+ function editorExternal(id, importer) {
212
+ if (CONTENT_FILE.test(id)) {
213
+ throw new Error(`${PACKAGE_NAME}: ${id} is an MDX page or a content file, which the editor's users write; ` +
214
+ 'the editor page never runs one as code. Keep it out of the puck config graph.');
215
+ }
216
+ if (id.startsWith('astro:')) {
217
+ throw new Error(`${PACKAGE_NAME}: ${importer ?? 'the puck config'} imports ${id}, an Astro module that exists only inside ` +
218
+ "Astro's own build. The editor page cannot load it; keep it out of the puck config graph.");
219
+ }
220
+ return EDITOR_BUNDLE_EXTERNALS.some((specifier) => specifier === id);
221
+ }
222
+ /**
223
+ * Turns a file a component imports into a module that addresses it beside the
224
+ * bundle, the way Astro hands an image import over as an image object.
225
+ * Stylesheet references stay with Vite's CSS pipeline.
226
+ */
227
+ function importedFiles(collected) {
228
+ const assetFile = new RegExp(`\\.(${EDITOR_ASSET_EXTENSIONS.join('|')})$`, 'i');
229
+ return {
230
+ name: 'conloca-editor-files',
231
+ enforce: 'pre',
232
+ async resolveId(id, importer) {
233
+ if (!assetFile.test(id) || (importer && /\.(css|scss|sass|less|styl)(?:\?|$)/.test(importer)))
234
+ return null;
235
+ const resolved = await this.resolve(id, importer, { skipSelf: true });
236
+ if (!resolved)
237
+ throw new Error(`${PACKAGE_NAME}: cannot resolve editor asset ${id}`);
238
+ if (resolved.external)
239
+ return resolved;
240
+ return ASSET_MODULE_PREFIX + resolved.id;
241
+ },
242
+ async load(id) {
243
+ return id.startsWith(ASSET_MODULE_PREFIX) ? assetModule(id.slice(ASSET_MODULE_PREFIX.length), collected) : null;
244
+ },
245
+ };
246
+ }
247
+ /**
248
+ * Preserve the component-style contract: Sass compiles once, failing softly;
249
+ * unsupported Less/Stylus imports remain empty. Give the resulting CSS to Vite
250
+ * at the original directory so CSS modules and relative assets resolve together.
251
+ * `styles` do not pass through this plugin.
252
+ */
253
+ function componentStyles(logger) {
254
+ const suffix = '.conloca-editor.css';
255
+ const moduleSuffix = '.conloca-editor.module.css';
256
+ return {
257
+ name: 'conloca-editor-component-styles',
258
+ enforce: 'pre',
259
+ async resolveId(id, importer) {
260
+ if (!/\.(scss|sass|less|styl)$/.test(id))
261
+ return null;
262
+ const resolved = await this.resolve(id, importer, { skipSelf: true });
263
+ if (!resolved || resolved.external)
264
+ return resolved;
265
+ return resolved.id + (/\.module\.(scss|sass|less|styl)$/.test(id) ? moduleSuffix : suffix);
266
+ },
267
+ async load(id) {
268
+ const ending = id.endsWith(moduleSuffix) ? moduleSuffix : id.endsWith(suffix) ? suffix : undefined;
269
+ if (!ending)
270
+ return null;
271
+ const path = id.slice(0, -ending.length);
272
+ if (/\.(less|styl)$/.test(path))
273
+ return '';
274
+ try {
275
+ return compileSass(path, { style: 'expanded' }).css;
276
+ }
277
+ catch (error) {
278
+ logger.warn(`stylesheet stripped from the editor page (${path}): ${messageOf(error)}`);
279
+ return '';
280
+ }
281
+ },
282
+ };
283
+ }
284
+ /** The module a file import evaluates to: its address, resolved against the bundle's own URL. */
285
+ async function assetModule(path, collected) {
286
+ const bytes = new Uint8Array(await readFile(path));
287
+ const ext = extname(path).slice(1).toLowerCase();
288
+ const sha256 = createHash('sha256').update(bytes).digest('hex');
289
+ if (!collected.some((asset) => asset.sha256 === sha256 && asset.ext === ext))
290
+ collected.push({ sha256, ext, bytes });
291
+ // @vite-ignore keeps Vite from resolving the name against this virtual module at build time.
292
+ const lines = [
293
+ `const src = new URL(/* @vite-ignore */ ${JSON.stringify(`./assets/${sha256}.${ext}`)}, import.meta.url).href;`,
294
+ ];
295
+ if (IMAGE_EXTENSIONS.has(ext)) {
296
+ lines.push(`export default { src, ...${JSON.stringify(await imageFacts(bytes, path))} };`);
297
+ }
298
+ else {
299
+ lines.push('export default src;');
300
+ }
301
+ return lines.join('\n');
302
+ }
303
+ /** An image's width, height and format as Astro reports them for an import; none of them when unreadable. */
304
+ async function imageFacts(bytes, path) {
305
+ const { imageMetadata } = await import('astro/assets/utils');
306
+ try {
307
+ const { width, height, format } = await imageMetadata(bytes, path);
308
+ return { width, height, format };
309
+ }
310
+ catch {
311
+ return {};
312
+ }
313
+ }
314
+ /** Normalize Vite's deprecated alias before adding either editor build's options. */
315
+ function normalizeBundlerOptions(vite) {
316
+ const { rollupOptions, ...build } = vite.build ?? {};
317
+ return { ...vite, build: { ...build, rolldownOptions: build.rolldownOptions ?? rollupOptions } };
318
+ }
319
+ /**
320
+ * Compiles `styles` through the site's own Vite pipeline (its plugins, PostCSS
321
+ * config and preprocessors) in a CSS-only build. The only files it writes are
322
+ * the assets the stylesheets reference (fonts, images), under
323
+ * `<dir>/_conloca/editor/assets/`, addressed relative to the stylesheet.
324
+ * Returns the compiled CSS with the entries in listed order.
325
+ *
326
+ * A failure is rethrown naming the entries: the site's own build fails on the
327
+ * same stylesheet, and a canvas stylesheet silently missing its site styles
328
+ * must not ship.
329
+ */
330
+ async function compileSiteStyles({ root, vite, styles, dir, }) {
331
+ if (styles.length === 0)
332
+ return '';
333
+ const entryNames = styles.map((_, index) => `site-style-${index}`);
334
+ let result;
335
+ try {
336
+ result = await buildWithVite(mergeConfig(normalizeBundlerOptions(vite), {
337
+ configFile: false,
338
+ root,
339
+ base: './',
340
+ logLevel: 'warn',
341
+ build: {
342
+ write: false,
343
+ copyPublicDir: false,
344
+ assetsDir: EDITOR_ASSETS_DIR,
345
+ rolldownOptions: {
346
+ input: Object.fromEntries(styles.map((entry, index) => [entryNames[index], resolve(root, entry)])),
347
+ output: { assetFileNames: editorAssetFileNames },
348
+ },
349
+ },
350
+ }));
351
+ }
352
+ catch (cause) {
353
+ throw new Error(`${PACKAGE_NAME}: siteStyles failed to compile (${styles.join(', ')}): ${messageOf(cause)}`, {
354
+ cause,
355
+ });
356
+ }
357
+ const assets = [result]
358
+ .flat()
359
+ .flatMap((bundle) => ('output' in bundle ? bundle.output : []))
360
+ .filter((file) => file.type === 'asset');
361
+ await Promise.all(assets
362
+ .filter((asset) => !asset.fileName.endsWith('.css'))
363
+ .map((asset) => writeOutputFile(join(dir, asset.fileName), asset.source)));
364
+ return entryNames
365
+ .map((name) => assets.find((asset) => asset.names.includes(`${name}.css`))?.source)
366
+ .map((source) => (source instanceof Uint8Array ? new TextDecoder().decode(source) : (source ?? '')))
367
+ .filter(Boolean)
368
+ .join('\n');
369
+ }
370
+ //# sourceMappingURL=bundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle.js","sourceRoot":"","sources":["../../../src/editor-page/bundle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAG5D,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,EAAE,KAAK,IAAI,aAAa,EAAE,WAAW,EAAgC,MAAM,MAAM,CAAC;AACzF,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,OAAO;IACP,WAAW;IACX,mBAAmB;IACnB,uBAAuB;IACvB,kBAAkB;IAClB,kBAAkB;CACV,CAAC;AA6DX,gFAAgF;AAChF,MAAM,uBAAuB,GAAsB;IACjD,MAAM;IACN,OAAO;IACP,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,MAAM;IACN,KAAK;IACL,KAAK;IACL,MAAM;IACN,MAAM;CACP,CAAC;AAEF,uHAAuH;AACvH,MAAM,gBAAgB,GAAwB,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAE5G;;;;GAIG;AACH,MAAM,qBAAqB,GAAG,CAAC,aAAa,EAAE,aAAa,EAAE,eAAe,CAAU,CAAC;AAEvF,0FAA0F;AAC1F,MAAM,UAAU,GAAG,iBAAiB,CAAC;A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CAAC;SACnG,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { type BranchDeploys } from '@conloca/content-api/editor-host';
2
+ import type { UserConfig } from 'vite';
3
+ import type { InheritedOptions } from '../resolve-options.js';
4
+ export interface EmitEditorPageInput {
5
+ /** Build output directory (Astro's `dir`, as a filesystem path). */
6
+ dir: string;
7
+ /** The Astro project root, as a filesystem path. */
8
+ root: string;
9
+ /** Astro's `base`, with or without its trailing slash. */
10
+ base: string;
11
+ /** The site's Vite config as Astro's config hooks see it, which holds no Astro core plugin. */
12
+ vite: UserConfig;
13
+ endpoint: string | undefined;
14
+ inherited: InheritedOptions;
15
+ repoUri: string | undefined;
16
+ siteIdOverride: string | undefined;
17
+ logger: {
18
+ info(message: string): void;
19
+ warn(message: string): void;
20
+ };
21
+ }
22
+ /** Writes <dir>/_conloca/editor/. The endpoint was already checked to be an app. address at config load. */
23
+ export declare function emitEditorPage(input: EmitEditorPageInput): Promise<void>;
24
+ /** Copies <from>/_conloca/editor into <to>, for a preview child whose client folder serves the site. */
25
+ export declare function mirrorEditorPage(fromDir: string, toDir: string): Promise<void>;
26
+ /**
27
+ * The Cloudflare Pages project that serves this site's branch builds: `CONLOCA_PAGES_PROJECT` (direct upload with
28
+ * wrangler) wins, else the project in a Pages build's `CF_PAGES_URL` (`https://<hash>.<project>.pages.dev`).
29
+ */
30
+ export declare function branchDeploysFromEnv(env: Record<string, string | undefined>): BranchDeploys | undefined;
31
+ /** Each content path under the repository root, written from that root ('' for the root itself); others are dropped. */
32
+ export declare function contentPathsFromBuild(paths: readonly string[], repoRoot: string | undefined): string[] | undefined;
33
+ //# sourceMappingURL=emit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../../../src/editor-page/emit.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,KAAK,aAAa,EASnB,MAAM,kCAAkC,CA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