@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.
- package/README.md +378 -207
- package/dist/.build-inputs.json +69 -0
- package/dist/src/component-manifest.d.ts +5 -3
- package/dist/src/component-manifest.d.ts.map +1 -1
- package/dist/src/component-manifest.js +7 -7
- package/dist/src/component-manifest.js.map +1 -1
- package/dist/src/constants.d.ts +14 -13
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +14 -13
- package/dist/src/constants.js.map +1 -1
- package/dist/src/d3-build.d.ts +70 -0
- package/dist/src/d3-build.d.ts.map +1 -0
- package/dist/src/d3-build.js +272 -0
- package/dist/src/d3-build.js.map +1 -0
- package/dist/src/descriptors.d.ts +2 -2
- package/dist/src/descriptors.d.ts.map +1 -1
- package/dist/src/descriptors.js +4 -2
- package/dist/src/descriptors.js.map +1 -1
- package/dist/src/doctor/checks-address.d.ts +18 -0
- package/dist/src/doctor/checks-address.d.ts.map +1 -0
- package/dist/src/doctor/checks-address.js +163 -0
- package/dist/src/doctor/checks-address.js.map +1 -0
- package/dist/src/doctor/checks-live.d.ts +8 -5
- package/dist/src/doctor/checks-live.d.ts.map +1 -1
- package/dist/src/doctor/checks-live.js +226 -188
- package/dist/src/doctor/checks-live.js.map +1 -1
- package/dist/src/doctor/checks-offline.d.ts +6 -25
- package/dist/src/doctor/checks-offline.d.ts.map +1 -1
- package/dist/src/doctor/checks-offline.js +30 -259
- package/dist/src/doctor/checks-offline.js.map +1 -1
- package/dist/src/doctor/checks-preview-limits.d.ts +11 -0
- package/dist/src/doctor/checks-preview-limits.d.ts.map +1 -0
- package/dist/src/doctor/checks-preview-limits.js +133 -0
- package/dist/src/doctor/checks-preview-limits.js.map +1 -0
- package/dist/src/doctor/checks-preview-live.d.ts +14 -0
- package/dist/src/doctor/checks-preview-live.d.ts.map +1 -0
- package/dist/src/doctor/checks-preview-live.js +72 -0
- package/dist/src/doctor/checks-preview-live.js.map +1 -0
- package/dist/src/doctor/checks-preview.d.ts +7 -0
- package/dist/src/doctor/checks-preview.d.ts.map +1 -0
- package/dist/src/doctor/checks-preview.js +287 -0
- package/dist/src/doctor/checks-preview.js.map +1 -0
- package/dist/src/doctor/config-scan.d.ts +12 -3
- package/dist/src/doctor/config-scan.d.ts.map +1 -1
- package/dist/src/doctor/config-scan.js +38 -11
- package/dist/src/doctor/config-scan.js.map +1 -1
- package/dist/src/doctor/run.d.ts.map +1 -1
- package/dist/src/doctor/run.js +16 -10
- package/dist/src/doctor/run.js.map +1 -1
- package/dist/src/doctor/types.d.ts +17 -7
- package/dist/src/doctor/types.d.ts.map +1 -1
- package/dist/src/doctor/types.js +17 -7
- package/dist/src/doctor/types.js.map +1 -1
- package/dist/src/editor-page/bundle.d.ts +90 -0
- package/dist/src/editor-page/bundle.d.ts.map +1 -0
- package/dist/src/editor-page/bundle.js +373 -0
- package/dist/src/editor-page/bundle.js.map +1 -0
- package/dist/src/editor-page/data-schemas.d.ts +16 -0
- package/dist/src/editor-page/data-schemas.d.ts.map +1 -0
- package/dist/src/editor-page/data-schemas.js +39 -0
- package/dist/src/editor-page/data-schemas.js.map +1 -0
- package/dist/src/editor-page/emit.d.ts +69 -0
- package/dist/src/editor-page/emit.d.ts.map +1 -0
- package/dist/src/editor-page/emit.js +254 -0
- package/dist/src/editor-page/emit.js.map +1 -0
- package/dist/src/editor-page/framing.d.ts +23 -0
- package/dist/src/editor-page/framing.d.ts.map +1 -0
- package/dist/src/editor-page/framing.js +39 -0
- package/dist/src/editor-page/framing.js.map +1 -0
- package/dist/src/editor-page/page.d.ts +9 -0
- package/dist/src/editor-page/page.d.ts.map +1 -0
- package/dist/src/editor-page/page.js +31 -0
- package/dist/src/editor-page/page.js.map +1 -0
- package/dist/src/editor-page/site-base.d.ts +4 -0
- package/dist/src/editor-page/site-base.d.ts.map +1 -0
- package/dist/src/editor-page/site-base.js +13 -0
- package/dist/src/editor-page/site-base.js.map +1 -0
- package/dist/src/git.d.ts +11 -8
- package/dist/src/git.d.ts.map +1 -1
- package/dist/src/git.js +25 -8
- package/dist/src/git.js.map +1 -1
- package/dist/src/index.d.ts +4 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +11 -6
- package/dist/src/index.js.map +1 -1
- package/dist/src/integration.d.ts +1 -1
- package/dist/src/integration.d.ts.map +1 -1
- package/dist/src/integration.js +377 -416
- package/dist/src/integration.js.map +1 -1
- package/dist/src/node.d.ts +3 -1
- package/dist/src/node.d.ts.map +1 -1
- package/dist/src/node.js +7 -2
- package/dist/src/node.js.map +1 -1
- package/dist/src/preview/_dispatch.d.ts +12 -0
- package/dist/src/preview/_dispatch.d.ts.map +1 -1
- package/dist/src/preview/_dispatch.js +31 -0
- package/dist/src/preview/_dispatch.js.map +1 -1
- package/dist/src/preview/_resolve-opts.d.ts +19 -10
- package/dist/src/preview/_resolve-opts.d.ts.map +1 -1
- package/dist/src/preview/_resolve-opts.js +24 -11
- package/dist/src/preview/_resolve-opts.js.map +1 -1
- package/dist/src/preview/banner.d.ts +12 -9
- package/dist/src/preview/banner.d.ts.map +1 -1
- package/dist/src/preview/banner.js +46 -43
- package/dist/src/preview/banner.js.map +1 -1
- package/dist/src/preview/cloudflare-adapter.d.ts +35 -0
- package/dist/src/preview/cloudflare-adapter.d.ts.map +1 -0
- package/dist/src/preview/cloudflare-adapter.js +92 -0
- package/dist/src/preview/cloudflare-adapter.js.map +1 -0
- package/dist/src/preview/cookie.d.ts +13 -14
- package/dist/src/preview/cookie.d.ts.map +1 -1
- package/dist/src/preview/cookie.js +19 -26
- package/dist/src/preview/cookie.js.map +1 -1
- package/dist/src/preview/dispatcher.d.ts +73 -0
- package/dist/src/preview/dispatcher.d.ts.map +1 -0
- package/dist/src/preview/dispatcher.js +329 -0
- package/dist/src/preview/dispatcher.js.map +1 -0
- package/dist/src/preview/entry-code.d.ts +33 -0
- package/dist/src/preview/entry-code.d.ts.map +1 -0
- package/dist/src/preview/entry-code.js +33 -0
- package/dist/src/preview/entry-code.js.map +1 -0
- package/dist/src/preview/headers.d.ts +24 -4
- package/dist/src/preview/headers.d.ts.map +1 -1
- package/dist/src/preview/headers.js +35 -7
- package/dist/src/preview/headers.js.map +1 -1
- package/dist/src/preview/label.d.ts +8 -0
- package/dist/src/preview/label.d.ts.map +1 -0
- package/dist/src/preview/label.js +14 -0
- package/dist/src/preview/label.js.map +1 -0
- package/dist/src/preview/landing.d.ts +23 -2
- package/dist/src/preview/landing.d.ts.map +1 -1
- package/dist/src/preview/landing.js +105 -37
- package/dist/src/preview/landing.js.map +1 -1
- package/dist/src/preview/middleware.d.ts +49 -22
- package/dist/src/preview/middleware.d.ts.map +1 -1
- package/dist/src/preview/middleware.js +259 -100
- package/dist/src/preview/middleware.js.map +1 -1
- package/dist/src/preview/preview-path.d.ts +47 -5
- package/dist/src/preview/preview-path.d.ts.map +1 -1
- package/dist/src/preview/preview-path.js +65 -8
- package/dist/src/preview/preview-path.js.map +1 -1
- package/dist/src/preview/redeem-url.d.ts +7 -0
- package/dist/src/preview/redeem-url.d.ts.map +1 -0
- package/dist/src/preview/redeem-url.js +14 -0
- package/dist/src/preview/redeem-url.js.map +1 -0
- package/dist/src/preview/site-middleware.d.ts +5 -5
- package/dist/src/preview/site-middleware.d.ts.map +1 -1
- package/dist/src/preview/site-middleware.js +53 -26
- package/dist/src/preview/site-middleware.js.map +1 -1
- package/dist/src/preview-build.d.ts +29 -15
- package/dist/src/preview-build.d.ts.map +1 -1
- package/dist/src/preview-build.js +66 -25
- package/dist/src/preview-build.js.map +1 -1
- package/dist/src/preview.d.ts +1 -1
- package/dist/src/preview.d.ts.map +1 -1
- package/dist/src/preview.js +1 -1
- package/dist/src/preview.js.map +1 -1
- package/dist/src/repository.d.ts +1 -1
- package/dist/src/repository.js +1 -1
- package/dist/src/resolve-options.d.ts +17 -0
- package/dist/src/resolve-options.d.ts.map +1 -0
- package/dist/src/resolve-options.js +21 -0
- package/dist/src/resolve-options.js.map +1 -0
- package/dist/src/site-id.d.ts +0 -2
- package/dist/src/site-id.d.ts.map +1 -1
- package/dist/src/site-id.js +2 -3
- package/dist/src/site-id.js.map +1 -1
- package/dist/src/skill.d.ts +11 -0
- package/dist/src/skill.d.ts.map +1 -1
- package/dist/src/skill.js +32 -9
- package/dist/src/skill.js.map +1 -1
- package/dist/src/types.d.ts +33 -78
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +63 -13
- package/src/component-manifest.ts +11 -8
- package/src/constants.ts +15 -13
- package/src/d3-build.ts +315 -0
- package/src/descriptors.ts +6 -4
- package/src/doctor/checks-address.ts +190 -0
- package/src/doctor/checks-live.ts +262 -268
- package/src/doctor/checks-offline.ts +32 -279
- package/src/doctor/checks-preview-limits.ts +137 -0
- package/src/doctor/checks-preview-live.ts +77 -0
- package/src/doctor/checks-preview.ts +302 -0
- package/src/doctor/config-scan.ts +35 -9
- package/src/doctor/run.ts +18 -16
- package/src/doctor/types.ts +17 -7
- package/src/editor-page/bundle.ts +487 -0
- package/src/editor-page/data-schemas.ts +47 -0
- package/src/editor-page/emit.ts +362 -0
- package/src/editor-page/framing.ts +62 -0
- package/src/editor-page/page.ts +37 -0
- package/src/editor-page/site-base.ts +11 -0
- package/src/git.ts +29 -10
- package/src/index.ts +22 -6
- package/src/integration.ts +399 -469
- package/src/node.ts +18 -2
- package/src/preview/_dispatch.ts +36 -1
- package/src/preview/_resolve-opts.ts +35 -12
- package/src/preview/banner.ts +61 -43
- package/src/preview/cloudflare-adapter.ts +103 -0
- package/src/preview/cookie.ts +18 -24
- package/src/preview/dispatcher.ts +407 -0
- package/src/preview/entry-code.ts +51 -0
- package/src/preview/headers.ts +35 -7
- package/src/preview/label.ts +12 -0
- package/src/preview/landing.ts +117 -39
- package/src/preview/middleware.ts +302 -115
- package/src/preview/preview-path.ts +83 -8
- package/src/preview/redeem-url.ts +14 -0
- package/src/preview/site-middleware.ts +60 -30
- package/src/preview-build.ts +85 -26
- package/src/preview-handler.astro +12 -9
- package/src/preview.ts +0 -1
- package/src/repository.ts +1 -1
- package/src/resolve-options.ts +37 -0
- package/src/site-id.ts +2 -4
- package/src/skill/SKILL.md +63 -55
- package/src/skill.ts +36 -8
- package/src/types.ts +33 -79
- package/src/virtual-modules.d.ts +4 -1
- package/dist/src/build-commit.d.ts +0 -19
- package/dist/src/build-commit.d.ts.map +0 -1
- package/dist/src/build-commit.js +0 -6
- package/dist/src/build-commit.js.map +0 -1
- package/dist/src/bundle.d.ts +0 -181
- package/dist/src/bundle.d.ts.map +0 -1
- package/dist/src/bundle.js +0 -413
- package/dist/src/bundle.js.map +0 -1
- package/dist/src/discovery.d.ts +0 -58
- package/dist/src/discovery.d.ts.map +0 -1
- package/dist/src/discovery.js +0 -133
- package/dist/src/discovery.js.map +0 -1
- package/dist/src/register.d.ts +0 -98
- package/dist/src/register.d.ts.map +0 -1
- package/dist/src/register.js +0 -103
- package/dist/src/register.js.map +0 -1
- package/src/build-commit.ts +0 -22
- package/src/bundle.ts +0 -570
- package/src/discovery.ts +0 -183
- package/src/register.ts +0 -180
package/dist/src/bundle.js
DELETED
|
@@ -1,413 +0,0 @@
|
|
|
1
|
-
import { createHash } from 'node:crypto';
|
|
2
|
-
import { cp, mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
3
|
-
import { dirname, join, resolve } from 'node:path';
|
|
4
|
-
import { build } from 'esbuild';
|
|
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 (served from
|
|
10
|
-
* `endpoint`) supplies them at runtime so the site's components
|
|
11
|
-
* execute on the editor's own 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 the modules the editor at the endpoint supplies: the two lists
|
|
16
|
-
* are one contract, so every specifier externalized here needs an entry there
|
|
17
|
-
* or the site's bundle fails bare-specifier resolution in the browser. Each side
|
|
18
|
-
* pins the list in its own tests.
|
|
19
|
-
*/
|
|
20
|
-
export const EDITOR_BUNDLE_EXTERNALS = [
|
|
21
|
-
'react',
|
|
22
|
-
'react-dom',
|
|
23
|
-
'react/jsx-runtime',
|
|
24
|
-
'react/jsx-dev-runtime',
|
|
25
|
-
'react-dom/client',
|
|
26
|
-
'@puckeditor/core',
|
|
27
|
-
];
|
|
28
|
-
/**
|
|
29
|
-
* Asset references inside component stylesheets are never pulled INTO the
|
|
30
|
-
* bundle — inlining would balloon the registered stylesheet and drag binary
|
|
31
|
-
* assets through the hash pipeline. They are instead re-pointed at the
|
|
32
|
-
* deployed site (see `rewriteStylesheetAssetUrls`), because the registered
|
|
33
|
-
* stylesheet is injected as text into the editor's canvas: left as-authored, a
|
|
34
|
-
* root-relative `url(/fonts/x.otf)` would resolve against the EDITOR's origin
|
|
35
|
-
* and 404.
|
|
36
|
-
*/
|
|
37
|
-
const STYLESHEET_ASSET_EXTERNALS = [
|
|
38
|
-
'*.woff',
|
|
39
|
-
'*.woff2',
|
|
40
|
-
'*.ttf',
|
|
41
|
-
'*.otf',
|
|
42
|
-
'*.eot',
|
|
43
|
-
'*.png',
|
|
44
|
-
'*.jpg',
|
|
45
|
-
'*.jpeg',
|
|
46
|
-
'*.gif',
|
|
47
|
-
'*.svg',
|
|
48
|
-
'*.webp',
|
|
49
|
-
'*.avif',
|
|
50
|
-
];
|
|
51
|
-
/**
|
|
52
|
-
* Cloudflare Pages `_headers` rule that lets the editor load an asset
|
|
53
|
-
* cross-origin. Part of the site-side contract: without it the browser
|
|
54
|
-
* blocks the fetch from the editor's origin. Applied to `/_conloca/*` for the
|
|
55
|
-
* bundle itself, and to the directories the stylesheet's assets live in —
|
|
56
|
-
* webfonts are CORS-gated, so a 200 without this header still renders the
|
|
57
|
-
* fallback face.
|
|
58
|
-
*/
|
|
59
|
-
function corsRule(path) {
|
|
60
|
-
return `${path}\n Access-Control-Allow-Origin: *\n`;
|
|
61
|
-
}
|
|
62
|
-
const BUNDLE_CORS_PATH = '/_conloca/*';
|
|
63
|
-
/**
|
|
64
|
-
* The named exports the bundle re-exports from the host's schemas module
|
|
65
|
-
* (conlocaCMS `schemasPath`). One list drives the virtual entry's re-export
|
|
66
|
-
* lines, the always-undefined warning absorption, and the all-absent check —
|
|
67
|
-
* three places that must never disagree on a name.
|
|
68
|
-
*/
|
|
69
|
-
const SCHEMA_MODULE_EXPORTS = ['pageSchemas', 'dataSchemas', 'mdxComponents'];
|
|
70
|
-
/** esbuild's per-name notice for a schemas-module export the module doesn't declare (absorbed below). */
|
|
71
|
-
const SCHEMA_EXPORT_ABSENCE = new RegExp(`^Import "(${SCHEMA_MODULE_EXPORTS.join('|')})" will always be undefined\\b`);
|
|
72
|
-
/**
|
|
73
|
-
* Bundles the site's puck config into a browser ESM file plus (when the
|
|
74
|
-
* graph carries styles) a companion stylesheet, both under `<dir>/_conloca/`,
|
|
75
|
-
* content-addressed by the first 16 hex chars of their sha-256, and ensures
|
|
76
|
-
* `<dir>/_headers` carries the CORS rule the editor needs to load them
|
|
77
|
-
* cross-origin.
|
|
78
|
-
*
|
|
79
|
-
* The siteStyles compile first, through the site's own Vite pipeline (see
|
|
80
|
-
* `compileSiteStyles`); one that fails to compile fails the build.
|
|
81
|
-
*
|
|
82
|
-
* Component styles compile in the SAME esbuild pass as the JS: CSS-module
|
|
83
|
-
* class names are hashed consistently across both outputs, so `styles.foo` in
|
|
84
|
-
* a component always matches a selector in the emitted stylesheet. SCSS
|
|
85
|
-
* compiles through `sass`; a component stylesheet that fails to compile is
|
|
86
|
-
* stripped with a warning instead of failing the build (one broken component
|
|
87
|
-
* stylesheet must not cost the site its registration).
|
|
88
|
-
*/
|
|
89
|
-
export async function bundleEditorAssets(input) {
|
|
90
|
-
const siteCss = await compileSiteStyles({
|
|
91
|
-
root: input.root,
|
|
92
|
-
vite: input.vite,
|
|
93
|
-
siteStyles: typeof input.siteStyles === 'string' ? [input.siteStyles] : (input.siteStyles ?? []),
|
|
94
|
-
dir: input.dir,
|
|
95
|
-
});
|
|
96
|
-
const entryPath = resolve(input.puckConfigPath);
|
|
97
|
-
const descriptors = input.descriptors;
|
|
98
|
-
const discovered = descriptors?.discoveredMdxComponents ?? [];
|
|
99
|
-
const virtualEntry = [
|
|
100
|
-
`export { default } from ${JSON.stringify(entryPath)};`,
|
|
101
|
-
// Third bundle leg: editor descriptors ride next to the puck
|
|
102
|
-
// config as named exports. The namespace import is deliberate — an
|
|
103
|
-
// `export { x } from` of a name the host's schemas module doesn't
|
|
104
|
-
// declare fails esbuild, so a partial module cannot fail the
|
|
105
|
-
// site's build; missing names just export undefined.
|
|
106
|
-
...(descriptors?.schemasPath
|
|
107
|
-
? [
|
|
108
|
-
`import * as __conlocaSchemas from ${JSON.stringify(resolve(descriptors.schemasPath))};`,
|
|
109
|
-
...SCHEMA_MODULE_EXPORTS.map((name) => `export const ${name} = __conlocaSchemas.${name};`),
|
|
110
|
-
]
|
|
111
|
-
: []),
|
|
112
|
-
...(discovered.length > 0 ? [`export const discoveredMdxComponents = ${JSON.stringify(discovered)};`] : []),
|
|
113
|
-
...(descriptors?.templates ? [`export const templates = ${JSON.stringify(descriptors.templates)};`] : []),
|
|
114
|
-
...(descriptors?.dataBindings ? [`export const dataBindings = ${JSON.stringify(descriptors.dataBindings)};`] : []),
|
|
115
|
-
].join('\n');
|
|
116
|
-
const result = await build({
|
|
117
|
-
stdin: {
|
|
118
|
-
contents: virtualEntry,
|
|
119
|
-
resolveDir: dirname(entryPath),
|
|
120
|
-
sourcefile: 'conloca-canvas-entry.js',
|
|
121
|
-
loader: 'js',
|
|
122
|
-
},
|
|
123
|
-
bundle: true,
|
|
124
|
-
format: 'esm',
|
|
125
|
-
platform: 'browser',
|
|
126
|
-
minify: true,
|
|
127
|
-
treeShaking: true,
|
|
128
|
-
write: false,
|
|
129
|
-
// Never written (write: false) — gives the stdin entry's outputs real
|
|
130
|
-
// .js/.css extensions so they can be told apart.
|
|
131
|
-
outdir: join(input.dir, '_conloca'),
|
|
132
|
-
// Automatic JSX so .tsx configs compile against react/jsx-runtime —
|
|
133
|
-
// which is externalized and supplied by the editor.
|
|
134
|
-
jsx: 'automatic',
|
|
135
|
-
external: [...EDITOR_BUNDLE_EXTERNALS, ...STYLESHEET_ASSET_EXTERNALS],
|
|
136
|
-
plugins: [sassCompiler(input.logger), ...(input.plugins ?? [])],
|
|
137
|
-
// No compiler is wired for these preprocessors in the component graph;
|
|
138
|
-
// strip them like all stylesheets used to be stripped (`{}` module, no
|
|
139
|
-
// rules) rather than failing the site's registration over one exotic
|
|
140
|
-
// import. siteStyles never reach here: the site's Vite pipeline compiles them.
|
|
141
|
-
loader: { '.less': 'empty', '.styl': 'empty' },
|
|
142
|
-
// esbuild would print warnings straight to stderr, outside the build's
|
|
143
|
-
// log stream; silence it and forward them through the Astro logger below.
|
|
144
|
-
logLevel: 'silent',
|
|
145
|
-
});
|
|
146
|
-
// The virtual entry re-exports the three descriptor names through a
|
|
147
|
-
// namespace import so a schemas module that declares only some of them
|
|
148
|
-
// cannot fail the site's build — absent names export undefined by
|
|
149
|
-
// design, and esbuild flags each one with an always-undefined warning on
|
|
150
|
-
// every build. Absence of an OPTIONAL name is the contract working, not a
|
|
151
|
-
// diagnostic; a schemas module yielding NONE of the names is one (a wrong
|
|
152
|
-
// path, or misspelled exports), so exactly that case is reported once, in
|
|
153
|
-
// this package's own words.
|
|
154
|
-
const softContractAbsences = new Set();
|
|
155
|
-
for (const warning of result.warnings) {
|
|
156
|
-
const absentName = warning.location?.file.endsWith('conloca-canvas-entry.js')
|
|
157
|
-
? SCHEMA_EXPORT_ABSENCE.exec(warning.text)?.[1]
|
|
158
|
-
: undefined;
|
|
159
|
-
if (absentName) {
|
|
160
|
-
softContractAbsences.add(absentName);
|
|
161
|
-
continue;
|
|
162
|
-
}
|
|
163
|
-
const location = warning.location;
|
|
164
|
-
input.logger.warn(`esbuild: ${warning.text}${location ? ` (${location.file}:${location.line}:${location.column})` : ''}`);
|
|
165
|
-
}
|
|
166
|
-
if (softContractAbsences.size === SCHEMA_MODULE_EXPORTS.length && descriptors?.schemasPath) {
|
|
167
|
-
input.logger.warn(`${PACKAGE_NAME}: the schemas module at ${descriptors.schemasPath} exports none of ` +
|
|
168
|
-
'pageSchemas, dataSchemas or mdxComponents — check the path and the export names.');
|
|
169
|
-
}
|
|
170
|
-
const jsFiles = result.outputFiles.filter((file) => file.path.endsWith('.js'));
|
|
171
|
-
const cssFiles = result.outputFiles.filter((file) => file.path.endsWith('.css'));
|
|
172
|
-
if (jsFiles.length !== 1 || cssFiles.length > 1 || jsFiles.length + cssFiles.length !== result.outputFiles.length) {
|
|
173
|
-
throw new Error(`${PACKAGE_NAME}: expected the puck config to bundle to one ESM file (plus at most one stylesheet), ` +
|
|
174
|
-
`got ${result.outputFiles.map((file) => file.path).join(', ')}. A non-JS import that esbuild emits ` +
|
|
175
|
-
'as its own asset (e.g. an image or font) is not supported in the editor bundle ' +
|
|
176
|
-
'— keep it out of the puck config graph.');
|
|
177
|
-
}
|
|
178
|
-
const outDir = join(input.dir, '_conloca');
|
|
179
|
-
await mkdir(outDir, { recursive: true });
|
|
180
|
-
const bytes = jsFiles[0].contents;
|
|
181
|
-
const hash = createHash('sha256').update(bytes).digest('hex');
|
|
182
|
-
const filename = `editor-bundle.${hash.slice(0, 16)}.js`;
|
|
183
|
-
await writeFile(join(outDir, filename), bytes);
|
|
184
|
-
let stylesheet;
|
|
185
|
-
let assetCorsPaths = [];
|
|
186
|
-
const componentCss = cssFiles[0] ? new TextDecoder().decode(cssFiles[0].contents) : '';
|
|
187
|
-
// Site styles first, so component rules keep the final word. esbuild emits
|
|
188
|
-
// an empty CSS file when every component stylesheet was stripped, and an
|
|
189
|
-
// empty registered stylesheet would only add a wasted fetch.
|
|
190
|
-
const rawCss = [siteCss, componentCss].filter(Boolean).join('\n');
|
|
191
|
-
if (rawCss !== '') {
|
|
192
|
-
// Asset URLs are rewritten BEFORE hashing: the editor hash-verifies the
|
|
193
|
-
// stylesheet it fetches, so the rewrite has to be part of the bytes that
|
|
194
|
-
// get hashed, written, and registered.
|
|
195
|
-
let css = rawCss;
|
|
196
|
-
if (input.publicBaseUrl) {
|
|
197
|
-
const rewritten = rewriteStylesheetAssetUrls(rawCss, input.publicBaseUrl, input.logger);
|
|
198
|
-
css = rewritten.css;
|
|
199
|
-
assetCorsPaths = rewritten.assetCorsPaths;
|
|
200
|
-
}
|
|
201
|
-
const cssBytes = new TextEncoder().encode(css);
|
|
202
|
-
const cssHash = createHash('sha256').update(cssBytes).digest('hex');
|
|
203
|
-
const cssFilename = `editor-bundle.${cssHash.slice(0, 16)}.css`;
|
|
204
|
-
await writeFile(join(outDir, cssFilename), cssBytes);
|
|
205
|
-
stylesheet = { url: `/_conloca/${cssFilename}`, hash: cssHash, bytes: cssBytes };
|
|
206
|
-
input.logger.info(`editor stylesheet written: ${stylesheet.url} (${cssBytes.byteLength} bytes)`);
|
|
207
|
-
}
|
|
208
|
-
await ensureCorsHeaders(input.dir, assetCorsPaths);
|
|
209
|
-
const url = `/_conloca/${filename}`;
|
|
210
|
-
input.logger.info(`editor bundle written: ${url} (${bytes.byteLength} bytes)`);
|
|
211
|
-
return { url, hash, bytes, stylesheet, assetCorsPaths };
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Compiles the siteStyles through the site's own Vite pipeline (its plugins,
|
|
215
|
-
* PostCSS config and preprocessors), the way conlocaCMS's dev editor compiles
|
|
216
|
-
* the same option, in a CSS-only build. The only files it writes are the
|
|
217
|
-
* assets the stylesheets reference (fonts, images), under `<dir>/_conloca/`.
|
|
218
|
-
* Returns the compiled CSS with the entries in listed order.
|
|
219
|
-
*
|
|
220
|
-
* A failure is rethrown naming the entries: the site's own build fails on the
|
|
221
|
-
* same stylesheet, and a canvas stylesheet silently missing its site styles
|
|
222
|
-
* must not register.
|
|
223
|
-
*/
|
|
224
|
-
async function compileSiteStyles({ root, vite, siteStyles, dir, }) {
|
|
225
|
-
if (siteStyles.length === 0)
|
|
226
|
-
return '';
|
|
227
|
-
const entryNames = siteStyles.map((_, index) => `site-style-${index}`);
|
|
228
|
-
let result;
|
|
229
|
-
try {
|
|
230
|
-
result = await buildWithVite(mergeConfig(vite, {
|
|
231
|
-
configFile: false,
|
|
232
|
-
root,
|
|
233
|
-
// The assets are written under `dir`, which the site serves at its
|
|
234
|
-
// origin root, so the URLs pointing at them must start there too.
|
|
235
|
-
base: '/',
|
|
236
|
-
logLevel: 'warn',
|
|
237
|
-
build: {
|
|
238
|
-
write: false,
|
|
239
|
-
copyPublicDir: false,
|
|
240
|
-
assetsDir: '_conloca',
|
|
241
|
-
rolldownOptions: {
|
|
242
|
-
input: Object.fromEntries(siteStyles.map((entry, index) => [entryNames[index], resolve(root, entry)])),
|
|
243
|
-
},
|
|
244
|
-
},
|
|
245
|
-
}));
|
|
246
|
-
}
|
|
247
|
-
catch (cause) {
|
|
248
|
-
throw new Error(`${PACKAGE_NAME}: siteStyles failed to compile (${siteStyles.join(', ')}): ${messageOf(cause)}`, {
|
|
249
|
-
cause,
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
const assets = [result]
|
|
253
|
-
.flat()
|
|
254
|
-
.flatMap((bundle) => ('output' in bundle ? bundle.output : []))
|
|
255
|
-
.filter((file) => file.type === 'asset');
|
|
256
|
-
await Promise.all(assets
|
|
257
|
-
.filter((asset) => !asset.fileName.endsWith('.css'))
|
|
258
|
-
.map(async (asset) => {
|
|
259
|
-
const target = join(dir, asset.fileName);
|
|
260
|
-
await mkdir(dirname(target), { recursive: true });
|
|
261
|
-
await writeFile(target, asset.source);
|
|
262
|
-
}));
|
|
263
|
-
return entryNames
|
|
264
|
-
.map((name) => assets.find((asset) => asset.names.includes(`${name}.css`))?.source)
|
|
265
|
-
.map((source) => (source instanceof Uint8Array ? new TextDecoder().decode(source) : (source ?? '')))
|
|
266
|
-
.filter(Boolean)
|
|
267
|
-
.join('\n');
|
|
268
|
-
}
|
|
269
|
-
/** Matches one `url(…)` token, with or without quotes (esbuild's minifier
|
|
270
|
-
* drops the quotes, but an unminified or quote-requiring value keeps them). */
|
|
271
|
-
const CSS_URL_TOKEN = /url\(\s*(['"]?)([^'")]+)\1\s*\)/g;
|
|
272
|
-
/**
|
|
273
|
-
* Re-points the registered stylesheet's asset references at the deployed site.
|
|
274
|
-
*
|
|
275
|
-
* Only ROOT-relative URLs (`/fonts/x.otf`) are rewritten — those name a path
|
|
276
|
-
* on the site and nothing else. That includes the `/_conloca/` assets the
|
|
277
|
-
* siteStyles build emitted, since Vite resolves their relative references.
|
|
278
|
-
* Path-relative ones (`./x.otf`, `../x.otf`, `x.otf`) cannot be resolved here
|
|
279
|
-
* and are reported instead of guessed: esbuild flattens every component
|
|
280
|
-
* stylesheet into ONE output and copies url() paths through verbatim, so by
|
|
281
|
-
* this point the emitted text no longer records WHICH source directory each
|
|
282
|
-
* one was relative to. Absolute, protocol-relative, `data:` and fragment
|
|
283
|
-
* (`#filter`) refs already resolve correctly and are left alone.
|
|
284
|
-
*
|
|
285
|
-
* Returns the rewritten CSS plus the `_headers` globs its assets need — one
|
|
286
|
-
* per distinct directory rather than one per file, which keeps a font family
|
|
287
|
-
* of forty weights to a single rule.
|
|
288
|
-
*/
|
|
289
|
-
export function rewriteStylesheetAssetUrls(css, publicBaseUrl, logger) {
|
|
290
|
-
const base = publicBaseUrl.replace(/\/+$/, '');
|
|
291
|
-
const dirs = new Set();
|
|
292
|
-
const unresolved = new Set();
|
|
293
|
-
const rewritten = css.replace(CSS_URL_TOKEN, (token, _quote, ref) => {
|
|
294
|
-
const value = ref.trim();
|
|
295
|
-
if (value.startsWith('//') || value.startsWith('#') || /^[a-z][a-z0-9+.-]*:/i.test(value))
|
|
296
|
-
return token;
|
|
297
|
-
if (!value.startsWith('/')) {
|
|
298
|
-
unresolved.add(value);
|
|
299
|
-
return token;
|
|
300
|
-
}
|
|
301
|
-
const dir = value.slice(0, value.lastIndexOf('/'));
|
|
302
|
-
dirs.add(`${dir === '' ? '' : dir}/*`);
|
|
303
|
-
return `url(${base}${value})`;
|
|
304
|
-
});
|
|
305
|
-
if (unresolved.size > 0) {
|
|
306
|
-
logger.warn('path-relative asset URLs in the registered stylesheet cannot be pointed at the deployed ' +
|
|
307
|
-
`site and will not load in the editing canvas — make them root-relative: ${[...unresolved].join(', ')}`);
|
|
308
|
-
}
|
|
309
|
-
return { css: rewritten, assetCorsPaths: [...dirs] };
|
|
310
|
-
}
|
|
311
|
-
/**
|
|
312
|
-
* Compiles the component graph's `.scss`/`.sass` imports with `sass`, mapping
|
|
313
|
-
* `*.module.*` files to esbuild's local-css semantics (hashed class names
|
|
314
|
-
* exported to the JS side). A file that fails to compile degrades to the
|
|
315
|
-
* pre-styled-canvas behavior — `{}` for a module (classNames become
|
|
316
|
-
* undefined), no rules for a global — with a warning naming the file and the
|
|
317
|
-
* compiler's reason. siteStyles never reach it: the site's Vite pipeline
|
|
318
|
-
* compiles them, and a failure there fails the build.
|
|
319
|
-
*/
|
|
320
|
-
function sassCompiler(logger) {
|
|
321
|
-
return {
|
|
322
|
-
name: 'conloca-sass',
|
|
323
|
-
setup(build) {
|
|
324
|
-
build.onLoad({ filter: /\.(scss|sass)$/ }, async (args) => {
|
|
325
|
-
const isModule = /\.module\.(scss|sass)$/.test(args.path);
|
|
326
|
-
try {
|
|
327
|
-
const sass = await import('sass');
|
|
328
|
-
const compiled = sass.compile(args.path, { style: 'expanded' });
|
|
329
|
-
return { contents: compiled.css, loader: isModule ? 'local-css' : 'css' };
|
|
330
|
-
}
|
|
331
|
-
catch (error) {
|
|
332
|
-
logger.warn(`stylesheet stripped from the editor bundle (${args.path}): ` +
|
|
333
|
-
(error instanceof Error ? error.message : String(error)));
|
|
334
|
-
return isModule ? { contents: '', loader: 'empty' } : { contents: '', loader: 'css' };
|
|
335
|
-
}
|
|
336
|
-
});
|
|
337
|
-
},
|
|
338
|
-
};
|
|
339
|
-
}
|
|
340
|
-
/**
|
|
341
|
-
* Writes the discovery route's collected CSS as a content-addressed artifact
|
|
342
|
-
* next to the editor bundle: `_conloca/route-css.<hash16>.css`.
|
|
343
|
-
* Same serving story as the editor stylesheet — the `/_conloca/*` CORS rule
|
|
344
|
-
* already covers it, and `mirrorEditorAssets` copies the whole dir.
|
|
345
|
-
*/
|
|
346
|
-
export async function emitRouteCssArtifact(dir, css, publicBaseUrl, logger) {
|
|
347
|
-
if (css.trim() === '')
|
|
348
|
-
return undefined;
|
|
349
|
-
// The discovered CSS is the site's FULL page CSS, so it carries the
|
|
350
|
-
// site's asset URLs (fonts especially) as authored — root-relative. Applied
|
|
351
|
-
// in the editor those resolve against the EDITOR's origin and 404, the same
|
|
352
|
-
// failure the editor stylesheet had; same fix, same helper, and the same
|
|
353
|
-
// CORS grant for the directories they live in.
|
|
354
|
-
let assetCorsPaths = [];
|
|
355
|
-
let text = css;
|
|
356
|
-
if (publicBaseUrl) {
|
|
357
|
-
const rewritten = rewriteStylesheetAssetUrls(css, publicBaseUrl, logger);
|
|
358
|
-
text = rewritten.css;
|
|
359
|
-
assetCorsPaths = rewritten.assetCorsPaths;
|
|
360
|
-
}
|
|
361
|
-
const bytes = new TextEncoder().encode(text);
|
|
362
|
-
const outDir = join(dir, '_conloca');
|
|
363
|
-
await mkdir(outDir, { recursive: true });
|
|
364
|
-
const hash = createHash('sha256').update(bytes).digest('hex');
|
|
365
|
-
const filename = `route-css.${hash.slice(0, 16)}.css`;
|
|
366
|
-
await writeFile(join(outDir, filename), bytes);
|
|
367
|
-
await ensureCorsHeaders(dir, assetCorsPaths);
|
|
368
|
-
logger.info(`discovered route CSS written: /_conloca/${filename} (${bytes.byteLength} bytes)`);
|
|
369
|
-
return { stylesheet: { url: `/_conloca/${filename}`, hash, bytes }, assetCorsPaths };
|
|
370
|
-
}
|
|
371
|
-
/**
|
|
372
|
-
* Mirrors the emitted editor assets (`_conloca/` + the CORS rule) from the
|
|
373
|
-
* primary build's output into another asset directory — the recursive preview
|
|
374
|
-
* build's client dir. The bundle is only ever compiled into the PRIMARY
|
|
375
|
-
* build's dist (the child build short-circuits `astro:build:done` to avoid
|
|
376
|
-
* registration recursion), but in a deployment that serves the site and the
|
|
377
|
-
* preview from one Cloudflare Worker, the child's client dir is the asset set
|
|
378
|
-
* that actually serves the site, so without this mirror the editor at the
|
|
379
|
-
* endpoint cannot load its component bundle.
|
|
380
|
-
*/
|
|
381
|
-
export async function mirrorEditorAssets(fromDir, toDir, assetCorsPaths = []) {
|
|
382
|
-
await cp(join(fromDir, '_conloca'), join(toDir, '_conloca'), { recursive: true });
|
|
383
|
-
await ensureCorsHeaders(toDir, assetCorsPaths);
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* Adds the bundle's CORS rule — plus one per stylesheet asset directory — to
|
|
387
|
-
* `<dir>/_headers`, appending to an existing file without clobbering other
|
|
388
|
-
* rules and without duplicating any of ours. Each rule is checked
|
|
389
|
-
* individually, so a dist that already carries `/_conloca/*` from an earlier
|
|
390
|
-
* build still picks up newly referenced asset directories.
|
|
391
|
-
*/
|
|
392
|
-
async function ensureCorsHeaders(dir, assetCorsPaths = []) {
|
|
393
|
-
const headersPath = join(dir, '_headers');
|
|
394
|
-
let existing = '';
|
|
395
|
-
try {
|
|
396
|
-
existing = await readFile(headersPath, 'utf8');
|
|
397
|
-
}
|
|
398
|
-
catch (error) {
|
|
399
|
-
if (error.code !== 'ENOENT')
|
|
400
|
-
throw error;
|
|
401
|
-
}
|
|
402
|
-
let updated = existing;
|
|
403
|
-
for (const path of [BUNDLE_CORS_PATH, ...assetCorsPaths]) {
|
|
404
|
-
if (updated.includes(`${path}\n`))
|
|
405
|
-
continue;
|
|
406
|
-
const separator = updated === '' || updated.endsWith('\n') ? '' : '\n';
|
|
407
|
-
updated = `${updated}${separator}${corsRule(path)}`;
|
|
408
|
-
}
|
|
409
|
-
if (updated === existing)
|
|
410
|
-
return;
|
|
411
|
-
await writeFile(headersPath, updated);
|
|
412
|
-
}
|
|
413
|
-
//# sourceMappingURL=bundle.js.map
|
package/dist/src/bundle.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bundle.js","sourceRoot":"","sources":["../../src/bundle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGnD,OAAO,EAAE,KAAK,EAAe,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,KAAK,IAAI,aAAa,EAAE,WAAW,EAAmB,MAAM,MAAM,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,OAAO;IACP,WAAW;IACX,mBAAmB;IACnB,uBAAuB;IACvB,kBAAkB;IAClB,kBAAkB;CACV,CAAC;AAEX;;;;;;;;GAQG;AACH,MAAM,0BAA0B,GAAG;IACjC,QAAQ;IACR,SAAS;IACT,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,QAAQ;IACR,OAAO;IACP,OAAO;IACP,QAAQ;IACR,QAAQ;CACA,CAAC;AAEX;;;;;;;GAOG;AACH,SAAS,QAAQ,CAAC,IAAY;IAC5B,OAAO,GAAG,IAAI,sCAAsC,CAAC;AACvD,CAAC;AAED,MAAM,gBAAgB,GAAG,aAAa,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,qBAAqB,GAAG,CAAC,aAAa,EAAE,aAAa,EAAE,eAAe,CAAU,CAAC;AAEvF,yGAAyG;AACzG,MA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E,SAAS;QAC5C,MAAM,SAAS,GAAG,OAAO,KAAK,EAAE,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QACvE,OAAO,GAAG,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;IACtD,CAAC;IACD,IAAI,OAAO,KAAK,QAAQ;QAAE,OAAO;IACjC,MAAM,SAAS,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;AACxC,CAAC"}
|
package/dist/src/discovery.d.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import type { DiscoveredWrappers } from '@conloca/astro-cms/node';
|
|
2
|
-
/**
|
|
3
|
-
* Build-time style discovery. The editor at the endpoint cannot run the
|
|
4
|
-
* discovery flow conlocaCMS runs on the site's dev server — no Vite graph to
|
|
5
|
-
* ask for a route's CSS, and cross-origin computed styles are browser-blocked
|
|
6
|
-
* — but every mechanism only produces plain data, and the build is the moment
|
|
7
|
-
* this pipeline stands inside the site. So: read the discovery route's
|
|
8
|
-
* rendered page, collect its stylesheets, run the SAME wrapper heuristic the
|
|
9
|
-
* dev server runs (`findContentWrapper`, imported — not duplicated), and hand
|
|
10
|
-
* the results to registration.
|
|
11
|
-
*
|
|
12
|
-
* Where the rendered page comes from, in order:
|
|
13
|
-
* 1. a prerendered file in the client dir (static routes);
|
|
14
|
-
* 2. the built server entry, booted for one request (the node adapter's
|
|
15
|
-
* `dist/server/entry.mjs` honors HOST/PORT) — covers `output: 'server'`
|
|
16
|
-
* sites, which is what real CMS deployments are;
|
|
17
|
-
* 3. nothing → warn and skip; registration proceeds without the artifacts
|
|
18
|
-
* (fail-soft, like every other optional registration input).
|
|
19
|
-
*
|
|
20
|
-
* ponytail: only the node adapter's entry is bootable in v1 — a
|
|
21
|
-
* workerd-targeted build (Cloudflare adapter) skips discovery with the
|
|
22
|
-
* warning. A site whose prose is `.conloca-prose`-scoped is already covered
|
|
23
|
-
* by the derived tier; boot-via-wrangler is the upgrade path if a
|
|
24
|
-
* workerd-targeted site ever needs heuristic discovery.
|
|
25
|
-
*/
|
|
26
|
-
export interface DiscoveredStyleContext {
|
|
27
|
-
hostWrappers: DiscoveredWrappers;
|
|
28
|
-
/** The route's stylesheets concatenated in document order (links + inline). */
|
|
29
|
-
routeCss: string;
|
|
30
|
-
}
|
|
31
|
-
export type CssRef = {
|
|
32
|
-
kind: 'link';
|
|
33
|
-
href: string;
|
|
34
|
-
} | {
|
|
35
|
-
kind: 'inline';
|
|
36
|
-
css: string;
|
|
37
|
-
};
|
|
38
|
-
/**
|
|
39
|
-
* Stylesheet references of a rendered page in document order. Regex-level on
|
|
40
|
-
* purpose: build-output HTML is machine-generated, and the only shapes that
|
|
41
|
-
* matter are `<link rel="stylesheet">` and `<style>` blocks.
|
|
42
|
-
*/
|
|
43
|
-
export declare function extractRouteCssRefs(html: string): CssRef[];
|
|
44
|
-
interface DiscoverInput {
|
|
45
|
-
/** The build's client output dir (where `_conloca/` also lands). */
|
|
46
|
-
clientDir: string;
|
|
47
|
-
/** The built SSR entry, when the adapter produces a bootable one. */
|
|
48
|
-
serverEntry?: string;
|
|
49
|
-
/** The representative content route (the shared `fragmentPreviewRoute`). */
|
|
50
|
-
route: string;
|
|
51
|
-
logger: {
|
|
52
|
-
info(message: string): void;
|
|
53
|
-
warn(message: string): void;
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
export declare function discoverStyleContext(input: DiscoverInput): Promise<DiscoveredStyleContext | undefined>;
|
|
57
|
-
export {};
|
|
58
|
-
//# sourceMappingURL=discovery.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../src/discovery.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAGlE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,MAAM,WAAW,sBAAsB;IACrC,YAAY,EAAE,kBAAkB,CAAC;IACjC,+EAA+E;IAC/E,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtF;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAkB1D;AAED,UAAU,aAAa;IACrB,oEAAoE;IACpE,SAAS,EAAE,MAAM,CAAC;IAClB,qEAAqE;IACrE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4EAA4E;IAC5E,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE;QAAE,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;CACtE;AAED,wBAAsB,oBAAoB,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,sBAAsB,GAAG,SAAS,CAAC,CAsB5G"}
|
package/dist/src/discovery.js
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { spawn } from 'node:child_process';
|
|
2
|
-
import { readFile } from 'node:fs/promises';
|
|
3
|
-
import { findContentWrapper } from '@conloca/astro-cms/node';
|
|
4
|
-
/**
|
|
5
|
-
* Stylesheet references of a rendered page in document order. Regex-level on
|
|
6
|
-
* purpose: build-output HTML is machine-generated, and the only shapes that
|
|
7
|
-
* matter are `<link rel="stylesheet">` and `<style>` blocks.
|
|
8
|
-
*/
|
|
9
|
-
export function extractRouteCssRefs(html) {
|
|
10
|
-
const refs = [];
|
|
11
|
-
const linkRe = /<link\b[^>]*>/gi;
|
|
12
|
-
for (const match of html.matchAll(linkRe)) {
|
|
13
|
-
const tag = match[0];
|
|
14
|
-
if (!/rel\s*=\s*["']?stylesheet["']?/i.test(tag))
|
|
15
|
-
continue;
|
|
16
|
-
const href = tag.match(/href\s*=\s*["']([^"']+)["']/i)?.[1];
|
|
17
|
-
if (href)
|
|
18
|
-
refs.push({ index: match.index ?? 0, ref: { kind: 'link', href } });
|
|
19
|
-
}
|
|
20
|
-
const styleRe = /<style\b[^>]*>([\s\S]*?)<\/style>/gi;
|
|
21
|
-
for (const match of html.matchAll(styleRe)) {
|
|
22
|
-
const css = match[1].trim();
|
|
23
|
-
if (css)
|
|
24
|
-
refs.push({ index: match.index ?? 0, ref: { kind: 'inline', css } });
|
|
25
|
-
}
|
|
26
|
-
return refs.sort((a, b) => a.index - b.index).map((entry) => entry.ref);
|
|
27
|
-
}
|
|
28
|
-
export async function discoverStyleContext(input) {
|
|
29
|
-
const fromFile = await readPrerenderedPage(input);
|
|
30
|
-
if (fromFile)
|
|
31
|
-
return fromFile;
|
|
32
|
-
if (input.serverEntry) {
|
|
33
|
-
try {
|
|
34
|
-
return await bootAndDiscover(input);
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
37
|
-
input.logger.warn(`style discovery: booting the server entry failed — skipping (${error instanceof Error ? error.message : String(error)})`);
|
|
38
|
-
return undefined;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
input.logger.warn(`style discovery: no built page for ${input.route} and no bootable server entry — ` +
|
|
42
|
-
'skipping; the editor falls back to the prose-safe tier.');
|
|
43
|
-
return undefined;
|
|
44
|
-
}
|
|
45
|
-
/** Try `<route>/index.html` then `<route>.html` under the client dir. */
|
|
46
|
-
async function readPrerenderedPage(input) {
|
|
47
|
-
const slug = input.route.replace(/^\/+|\/+$/g, '');
|
|
48
|
-
for (const candidate of [`${slug}/index.html`, `${slug}.html`]) {
|
|
49
|
-
let html;
|
|
50
|
-
try {
|
|
51
|
-
html = await readFile(join2(input.clientDir, candidate), 'utf8');
|
|
52
|
-
}
|
|
53
|
-
catch {
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
const routeCss = await assembleCss(extractRouteCssRefs(html), async (href) => {
|
|
57
|
-
try {
|
|
58
|
-
return await readFile(join2(input.clientDir, href.replace(/^\/+/, '')), 'utf8');
|
|
59
|
-
}
|
|
60
|
-
catch {
|
|
61
|
-
input.logger.warn(`style discovery: stylesheet ${href} not found in the client dir — skipped.`);
|
|
62
|
-
return '';
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
return { hostWrappers: findContentWrapper(html), routeCss };
|
|
66
|
-
}
|
|
67
|
-
return undefined;
|
|
68
|
-
}
|
|
69
|
-
/** Boot the built entry on a loopback port, fetch the route + its CSS, kill. */
|
|
70
|
-
async function bootAndDiscover(input) {
|
|
71
|
-
if (!input.serverEntry)
|
|
72
|
-
return undefined;
|
|
73
|
-
const port = 41000 + Math.floor(Math.random() * 20000);
|
|
74
|
-
const origin = `http://127.0.0.1:${port}`;
|
|
75
|
-
const child = spawn(process.execPath, [input.serverEntry], {
|
|
76
|
-
env: { ...process.env, HOST: '127.0.0.1', PORT: String(port) },
|
|
77
|
-
stdio: 'ignore',
|
|
78
|
-
});
|
|
79
|
-
try {
|
|
80
|
-
await waitForServer(origin);
|
|
81
|
-
const page = await fetch(`${origin}${input.route}`);
|
|
82
|
-
if (!page.ok) {
|
|
83
|
-
input.logger.warn(`style discovery: ${input.route} answered ${page.status} on the booted entry — skipping.`);
|
|
84
|
-
return undefined;
|
|
85
|
-
}
|
|
86
|
-
const html = await page.text();
|
|
87
|
-
const routeCss = await assembleCss(extractRouteCssRefs(html), async (href) => {
|
|
88
|
-
const res = await fetch(new URL(href, origin));
|
|
89
|
-
if (!res.ok) {
|
|
90
|
-
input.logger.warn(`style discovery: stylesheet ${href} answered ${res.status} — skipped.`);
|
|
91
|
-
return '';
|
|
92
|
-
}
|
|
93
|
-
return res.text();
|
|
94
|
-
});
|
|
95
|
-
return { hostWrappers: findContentWrapper(html), routeCss };
|
|
96
|
-
}
|
|
97
|
-
finally {
|
|
98
|
-
child.kill('SIGTERM');
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
async function assembleCss(refs, loadHref) {
|
|
102
|
-
const parts = [];
|
|
103
|
-
for (const ref of refs) {
|
|
104
|
-
if (ref.kind === 'inline') {
|
|
105
|
-
parts.push(ref.css);
|
|
106
|
-
continue;
|
|
107
|
-
}
|
|
108
|
-
const css = await loadHref(ref.href);
|
|
109
|
-
if (css)
|
|
110
|
-
parts.push(css);
|
|
111
|
-
}
|
|
112
|
-
return parts.join('\n');
|
|
113
|
-
}
|
|
114
|
-
async function waitForServer(origin) {
|
|
115
|
-
// A design-time boot of the SSR entry; on a saturated CI runner the first
|
|
116
|
-
// answer took >15s while a full parallel gate ran beside it.
|
|
117
|
-
const deadline = Date.now() + 60_000;
|
|
118
|
-
while (Date.now() < deadline) {
|
|
119
|
-
try {
|
|
120
|
-
await fetch(origin, { method: 'HEAD' });
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
catch {
|
|
124
|
-
await new Promise((r) => setTimeout(r, 150));
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
throw new Error('server entry did not answer within 60s');
|
|
128
|
-
}
|
|
129
|
-
/** node:path join without importing path twice under bundling edge cases. */
|
|
130
|
-
function join2(base, rel) {
|
|
131
|
-
return `${base.replace(/\/+$/, '')}/${rel}`;
|
|
132
|
-
}
|
|
133
|
-
//# sourceMappingURL=discovery.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.js","sourceRoot":"","sources":["../../src/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAmC7D;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAY;IAC9C,MAAM,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