@conloca/cloud-astro 0.2.1 → 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.
- package/README.md +261 -207
- package/dist/.build-inputs.json +60 -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 +5 -13
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +5 -13
- package/dist/src/constants.js.map +1 -1
- package/dist/src/descriptors.d.ts +2 -2
- package/dist/src/descriptors.d.ts.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 +220 -188
- package/dist/src/doctor/checks-live.js.map +1 -1
- package/dist/src/doctor/checks-offline.d.ts +8 -23
- package/dist/src/doctor/checks-offline.d.ts.map +1 -1
- package/dist/src/doctor/checks-offline.js +22 -239
- package/dist/src/doctor/checks-offline.js.map +1 -1
- package/dist/src/doctor/config-scan.d.ts +6 -3
- package/dist/src/doctor/config-scan.d.ts.map +1 -1
- package/dist/src/doctor/config-scan.js +21 -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 +12 -10
- package/dist/src/doctor/run.js.map +1 -1
- package/dist/src/doctor/types.d.ts +7 -7
- package/dist/src/doctor/types.d.ts.map +1 -1
- package/dist/src/doctor/types.js +7 -7
- package/dist/src/doctor/types.js.map +1 -1
- package/dist/src/editor-page/bundle.d.ts +88 -0
- package/dist/src/editor-page/bundle.d.ts.map +1 -0
- package/dist/src/editor-page/bundle.js +370 -0
- package/dist/src/editor-page/bundle.js.map +1 -0
- package/dist/src/editor-page/emit.d.ts +33 -0
- package/dist/src/editor-page/emit.d.ts.map +1 -0
- package/dist/src/editor-page/emit.js +183 -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 +3 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +9 -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 +245 -396
- 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 +5 -2
- package/dist/src/preview/_dispatch.d.ts.map +1 -1
- package/dist/src/preview/_dispatch.js +2 -0
- package/dist/src/preview/_dispatch.js.map +1 -1
- package/dist/src/preview/_resolve-opts.d.ts +18 -10
- package/dist/src/preview/_resolve-opts.d.ts.map +1 -1
- package/dist/src/preview/_resolve-opts.js +24 -10
- package/dist/src/preview/_resolve-opts.js.map +1 -1
- package/dist/src/preview/banner.d.ts.map +1 -1
- package/dist/src/preview/banner.js +2 -4
- package/dist/src/preview/banner.js.map +1 -1
- package/dist/src/preview/cookie.d.ts +5 -2
- package/dist/src/preview/cookie.d.ts.map +1 -1
- package/dist/src/preview/cookie.js +5 -2
- package/dist/src/preview/cookie.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 +2 -2
- package/dist/src/preview/landing.js +2 -2
- package/dist/src/preview/middleware.d.ts +31 -20
- package/dist/src/preview/middleware.d.ts.map +1 -1
- package/dist/src/preview/middleware.js +56 -51
- package/dist/src/preview/middleware.js.map +1 -1
- package/dist/src/preview/preview-path.d.ts +18 -5
- package/dist/src/preview/preview-path.d.ts.map +1 -1
- package/dist/src/preview/preview-path.js +24 -8
- package/dist/src/preview/preview-path.js.map +1 -1
- 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 +17 -16
- package/dist/src/preview/site-middleware.js.map +1 -1
- package/dist/src/preview-build.d.ts +18 -15
- package/dist/src/preview-build.d.ts.map +1 -1
- package/dist/src/preview-build.js +36 -21
- 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/types.d.ts +21 -59
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +44 -15
- package/src/component-manifest.ts +11 -8
- package/src/constants.ts +5 -14
- package/src/descriptors.ts +2 -2
- package/src/doctor/checks-address.ts +190 -0
- package/src/doctor/checks-live.ts +256 -268
- package/src/doctor/checks-offline.ts +24 -262
- package/src/doctor/config-scan.ts +21 -9
- package/src/doctor/run.ts +14 -16
- package/src/doctor/types.ts +7 -7
- package/src/editor-page/bundle.ts +482 -0
- package/src/editor-page/emit.ts +246 -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 +20 -6
- package/src/integration.ts +255 -449
- package/src/node.ts +18 -2
- package/src/preview/_dispatch.ts +6 -2
- package/src/preview/_resolve-opts.ts +34 -11
- package/src/preview/banner.ts +2 -4
- package/src/preview/cookie.ts +5 -2
- package/src/preview/label.ts +12 -0
- package/src/preview/landing.ts +2 -2
- package/src/preview/middleware.ts +83 -66
- package/src/preview/preview-path.ts +26 -8
- package/src/preview/site-middleware.ts +17 -21
- package/src/preview-build.ts +42 -26
- package/src/preview-handler.astro +10 -8
- 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 +51 -55
- package/src/types.ts +21 -60
- package/src/virtual-modules.d.ts +5 -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 -173
- 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 -563
- package/src/discovery.ts +0 -183
- package/src/register.ts +0 -180
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,IAAI,GAA0C,EAAE,CAAC;IAEvD,MAAM,MAAM,GAAG,iBAAiB,CAAC;IACjC,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1C,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACrB,IAAI,CAAC,iCAAiC,CAAC,IAAI,CAAC,GAAG,CAAC;YAAE,SAAS;QAC3D,MAAM,IAAI,GAAG,GAA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OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;AAC5D,CAAC;AAED,6EAA6E;AAC7E,SAAS,KAAK,CAAC,IAAY,EAAE,GAAW;IACtC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC;AAC9C,CAAC"}
|
package/dist/src/register.d.ts
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Registration request (`POST {endpoint}/api/v1/registrations`). Auth is the
|
|
3
|
-
* build token (`cbt_<id>.<secret>`) the endpoint issued; the body carries build
|
|
4
|
-
* metadata only.
|
|
5
|
-
*/
|
|
6
|
-
export interface RegistrationInput {
|
|
7
|
-
/** Editor endpoint, e.g. 'https://cms.example.com'. */
|
|
8
|
-
endpoint: string;
|
|
9
|
-
/** Build token sent as `Authorization: Bearer <token>`. */
|
|
10
|
-
buildToken: string;
|
|
11
|
-
/** Auto-detected `owner/repo` identity of the build checkout. */
|
|
12
|
-
repoUri: string;
|
|
13
|
-
gitSha: string;
|
|
14
|
-
branch: string;
|
|
15
|
-
/** Deployable-site id (top-level siteId in the content root's
|
|
16
|
-
* sites.json, or the implicit 'default' for a zero-config repo). Resolved at
|
|
17
|
-
* build via resolveBuildSiteId — registration attaches, never defines. */
|
|
18
|
-
siteId: string;
|
|
19
|
-
/** Absolute URL the editor fetches the bundle from. */
|
|
20
|
-
editorBundleUrl: string;
|
|
21
|
-
/** Full sha-256 hex of the bundle bytes; the editor refuses non-matching bytes. */
|
|
22
|
-
bundleHash: string;
|
|
23
|
-
/** Absolute URL of the companion canvas stylesheet; absent when the config graph has no styles. */
|
|
24
|
-
stylesheetUrl?: string;
|
|
25
|
-
/** Full sha-256 hex of the stylesheet bytes; the editor skips non-matching bytes (fail-soft). */
|
|
26
|
-
stylesheetHash?: string;
|
|
27
|
-
/**
|
|
28
|
-
* Discovered content-wrapper shape of the fragmentPreviewRoute — inline
|
|
29
|
-
* because it is well under 1 KB; a URL+hash would add a
|
|
30
|
-
* fetch and a verification for nothing.
|
|
31
|
-
*/
|
|
32
|
-
hostWrappers?: {
|
|
33
|
-
content: {
|
|
34
|
-
tagName: string;
|
|
35
|
-
className: string;
|
|
36
|
-
} | null;
|
|
37
|
-
codeBlock: unknown;
|
|
38
|
-
};
|
|
39
|
-
/** Absolute URL of the discovery route's collected CSS; same artifact pattern as stylesheetUrl. */
|
|
40
|
-
routeCssUrl?: string;
|
|
41
|
-
/** Full sha-256 hex of the route-CSS bytes; the editor skips non-matching bytes (fail-soft). */
|
|
42
|
-
routeCssHash?: string;
|
|
43
|
-
/** Absolute URL of the build's component manifest; same artifact pattern as stylesheetUrl. */
|
|
44
|
-
componentManifestUrl?: string;
|
|
45
|
-
/** Full sha-256 hex of the manifest bytes; a reader refuses non-matching bytes. */
|
|
46
|
-
componentManifestHash?: string;
|
|
47
|
-
deploymentUrl?: string;
|
|
48
|
-
deploymentProvider?: string;
|
|
49
|
-
/**
|
|
50
|
-
* The commit the artifact was actually built from; differs from gitSha only when CI hands over the branch's
|
|
51
|
-
* latest commit.
|
|
52
|
-
*/
|
|
53
|
-
buildId?: string;
|
|
54
|
-
/**
|
|
55
|
-
* The `@conloca/cloud-astro` version that produced this build, so the endpoint and the doctor can say which
|
|
56
|
-
* package version built the editor bundle.
|
|
57
|
-
*/
|
|
58
|
-
clientVersion?: string;
|
|
59
|
-
}
|
|
60
|
-
export interface RegistrationResult {
|
|
61
|
-
/** Per-branch preview secret consumed by the recursive preview build. */
|
|
62
|
-
previewSecret: string;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* The minimal fetch surface this module relies on. A narrow seam (matching
|
|
66
|
-
* `PreviewBuildSpawn` in preview-build.ts) lets tests pass a tiny fake
|
|
67
|
-
* without reconstructing the full `fetch` typing.
|
|
68
|
-
*/
|
|
69
|
-
export type RegistrationFetch = (url: string, init: {
|
|
70
|
-
method: 'POST';
|
|
71
|
-
headers: Record<string, string>;
|
|
72
|
-
body: string;
|
|
73
|
-
}) => Promise<Response>;
|
|
74
|
-
/**
|
|
75
|
-
* Backoff before each retry; length + 1 = total attempts. Starts at 1 s,
|
|
76
|
-
* doubles to a 30 s ceiling and stops before the waits alone exceed the
|
|
77
|
-
* budget: an endpoint that has just been set up can answer 503 for a while,
|
|
78
|
-
* and a budget of about a second gives up long before it settles.
|
|
79
|
-
*/
|
|
80
|
-
export declare function _registrationRetryDelays(): number[];
|
|
81
|
-
/**
|
|
82
|
-
* POSTs the registration to the endpoint and returns the per-branch preview
|
|
83
|
-
* secret. Network errors and 5xx responses are retried with exponential
|
|
84
|
-
* backoff (1 s doubling to 30 s, ten attempts within a three-minute wait
|
|
85
|
-
* budget); 4xx responses throw immediately with the response body so
|
|
86
|
-
* the caller can surface the exact rejection reason (e.g. an invalid token).
|
|
87
|
-
*/
|
|
88
|
-
export declare function postRegistration(input: RegistrationInput): Promise<RegistrationResult>;
|
|
89
|
-
/**
|
|
90
|
-
* Internal seam that takes the fetch function (and retry backoff) as
|
|
91
|
-
* parameters so tests can substitute fakes. Public callers should use
|
|
92
|
-
* {@link postRegistration}.
|
|
93
|
-
*
|
|
94
|
-
* Exported with a leading underscore to signal that this is an internal API
|
|
95
|
-
* and not part of the package's public surface.
|
|
96
|
-
*/
|
|
97
|
-
export declare function _postRegistrationWith(fetchFn: RegistrationFetch, input: RegistrationInput, retryDelaysMs?: readonly number[]): Promise<RegistrationResult>;
|
|
98
|
-
//# sourceMappingURL=register.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../src/register.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,uDAAuD;IACvD,QAAQ,EAAE,MAAM,CAAC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MAAM,CAAA;CAAE,KACpE,OAAO,CAAC,QAAQ,CAAC,CAAC;AAMvB;;;;;GAKG;AACH,wBAAgB,wBAAwB,IAAI,MAAM,EAAE,CAUnD;AAID;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAE5F;AAED;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,iBAAiB,EAC1B,KAAK,EAAE,iBAAiB,EACxB,aAAa,GAAE,SAAS,MAAM,EAA4B,GACzD,OAAO,CAAC,kBAAkB,CAAC,CA6D7B"}
|
package/dist/src/register.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { PACKAGE_NAME } from './constants.js';
|
|
2
|
-
const INITIAL_RETRY_MS = 1_000;
|
|
3
|
-
const MAX_RETRY_MS = 30_000;
|
|
4
|
-
const RETRY_BUDGET_MS = 180_000;
|
|
5
|
-
/**
|
|
6
|
-
* Backoff before each retry; length + 1 = total attempts. Starts at 1 s,
|
|
7
|
-
* doubles to a 30 s ceiling and stops before the waits alone exceed the
|
|
8
|
-
* budget: an endpoint that has just been set up can answer 503 for a while,
|
|
9
|
-
* and a budget of about a second gives up long before it settles.
|
|
10
|
-
*/
|
|
11
|
-
export function _registrationRetryDelays() {
|
|
12
|
-
const delays = [];
|
|
13
|
-
let next = INITIAL_RETRY_MS;
|
|
14
|
-
let total = 0;
|
|
15
|
-
while (total + next <= RETRY_BUDGET_MS) {
|
|
16
|
-
delays.push(next);
|
|
17
|
-
total += next;
|
|
18
|
-
next = Math.min(next * 2, MAX_RETRY_MS);
|
|
19
|
-
}
|
|
20
|
-
return delays;
|
|
21
|
-
}
|
|
22
|
-
const DEFAULT_RETRY_DELAYS_MS = _registrationRetryDelays();
|
|
23
|
-
/**
|
|
24
|
-
* POSTs the registration to the endpoint and returns the per-branch preview
|
|
25
|
-
* secret. Network errors and 5xx responses are retried with exponential
|
|
26
|
-
* backoff (1 s doubling to 30 s, ten attempts within a three-minute wait
|
|
27
|
-
* budget); 4xx responses throw immediately with the response body so
|
|
28
|
-
* the caller can surface the exact rejection reason (e.g. an invalid token).
|
|
29
|
-
*/
|
|
30
|
-
export async function postRegistration(input) {
|
|
31
|
-
return _postRegistrationWith((url, init) => fetch(url, init), input);
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Internal seam that takes the fetch function (and retry backoff) as
|
|
35
|
-
* parameters so tests can substitute fakes. Public callers should use
|
|
36
|
-
* {@link postRegistration}.
|
|
37
|
-
*
|
|
38
|
-
* Exported with a leading underscore to signal that this is an internal API
|
|
39
|
-
* and not part of the package's public surface.
|
|
40
|
-
*/
|
|
41
|
-
export async function _postRegistrationWith(fetchFn, input, retryDelaysMs = DEFAULT_RETRY_DELAYS_MS) {
|
|
42
|
-
const url = `${input.endpoint}/api/v1/registrations`;
|
|
43
|
-
const init = {
|
|
44
|
-
method: 'POST',
|
|
45
|
-
headers: {
|
|
46
|
-
'content-type': 'application/json',
|
|
47
|
-
authorization: `Bearer ${input.buildToken}`,
|
|
48
|
-
},
|
|
49
|
-
// JSON.stringify drops undefined optional fields, matching the endpoint's
|
|
50
|
-
// "optional means absent" reading of the body.
|
|
51
|
-
body: JSON.stringify({
|
|
52
|
-
repoUri: input.repoUri,
|
|
53
|
-
gitSha: input.gitSha,
|
|
54
|
-
branch: input.branch,
|
|
55
|
-
siteId: input.siteId,
|
|
56
|
-
editorBundleUrl: input.editorBundleUrl,
|
|
57
|
-
bundleHash: input.bundleHash,
|
|
58
|
-
stylesheetUrl: input.stylesheetUrl,
|
|
59
|
-
stylesheetHash: input.stylesheetHash,
|
|
60
|
-
hostWrappers: input.hostWrappers,
|
|
61
|
-
routeCssUrl: input.routeCssUrl,
|
|
62
|
-
routeCssHash: input.routeCssHash,
|
|
63
|
-
componentManifestUrl: input.componentManifestUrl,
|
|
64
|
-
componentManifestHash: input.componentManifestHash,
|
|
65
|
-
deploymentUrl: input.deploymentUrl,
|
|
66
|
-
deploymentProvider: input.deploymentProvider,
|
|
67
|
-
buildId: input.buildId,
|
|
68
|
-
clientVersion: input.clientVersion,
|
|
69
|
-
}),
|
|
70
|
-
};
|
|
71
|
-
const attempts = retryDelaysMs.length + 1;
|
|
72
|
-
let lastFailure = '';
|
|
73
|
-
for (let attempt = 0; attempt < attempts; attempt++) {
|
|
74
|
-
if (attempt > 0 && retryDelaysMs[attempt - 1] > 0) {
|
|
75
|
-
await new Promise((resolve) => setTimeout(resolve, retryDelaysMs[attempt - 1]));
|
|
76
|
-
}
|
|
77
|
-
let response;
|
|
78
|
-
try {
|
|
79
|
-
response = await fetchFn(url, init);
|
|
80
|
-
}
|
|
81
|
-
catch (error) {
|
|
82
|
-
// Network-level failure (endpoint unreachable, DNS, reset) — retry.
|
|
83
|
-
lastFailure = error instanceof Error ? error.message : String(error);
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
if (response.ok) {
|
|
87
|
-
const payload = (await response.json().catch(() => null));
|
|
88
|
-
if (typeof payload?.previewSecret !== 'string' || payload.previewSecret === '') {
|
|
89
|
-
throw new Error(`${PACKAGE_NAME}: registration response is missing previewSecret`);
|
|
90
|
-
}
|
|
91
|
-
return { previewSecret: payload.previewSecret };
|
|
92
|
-
}
|
|
93
|
-
const text = await response.text().catch(() => '');
|
|
94
|
-
if (response.status < 500) {
|
|
95
|
-
// 4xx is deterministic (bad token, repo not covered, malformed body) —
|
|
96
|
-
// retrying cannot help, and the body carries the exact reason.
|
|
97
|
-
throw new Error(`${PACKAGE_NAME}: registration rejected: HTTP ${response.status} ${text}`);
|
|
98
|
-
}
|
|
99
|
-
lastFailure = `HTTP ${response.status} ${text}`;
|
|
100
|
-
}
|
|
101
|
-
throw new Error(`${PACKAGE_NAME}: registration failed after ${attempts} attempts: ${lastFailure}`);
|
|
102
|
-
}
|
|
103
|
-
//# sourceMappingURL=register.js.map
|
package/dist/src/register.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
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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
|
-
|
|
13
|
-
/** Resolves which commit the registration names and which commit produced the bundle. */
|
|
14
|
-
export function registrationCommits(input: {
|
|
15
|
-
/** The branch's latest commit, as CI hands it over through CF_PAGES_COMMIT_SHA. */
|
|
16
|
-
eventCommitSha: string | undefined;
|
|
17
|
-
/** git rev-parse HEAD in the build checkout. */
|
|
18
|
-
checkoutCommitSha: string | undefined;
|
|
19
|
-
}): RegistrationCommits {
|
|
20
|
-
const gitSha = input.eventCommitSha ?? input.checkoutCommitSha;
|
|
21
|
-
return { gitSha, buildId: input.checkoutCommitSha ?? gitSha };
|
|
22
|
-
}
|