@conloca/cloud-astro 0.2.6 → 0.3.0
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 +6 -2
- package/dist/.build-inputs.json +18 -13
- package/dist/src/component-manifest.d.ts +11 -0
- package/dist/src/component-manifest.d.ts.map +1 -1
- package/dist/src/component-manifest.js +20 -2
- package/dist/src/component-manifest.js.map +1 -1
- package/dist/src/descriptors.d.ts.map +1 -1
- package/dist/src/descriptors.js +6 -2
- package/dist/src/descriptors.js.map +1 -1
- package/dist/src/doctor/ancestor-chain.d.ts +14 -0
- package/dist/src/doctor/ancestor-chain.d.ts.map +1 -0
- package/dist/src/doctor/ancestor-chain.js +57 -0
- package/dist/src/doctor/ancestor-chain.js.map +1 -0
- package/dist/src/doctor/checks-frames.d.ts +5 -0
- package/dist/src/doctor/checks-frames.d.ts.map +1 -0
- package/dist/src/doctor/checks-frames.js +78 -0
- package/dist/src/doctor/checks-frames.js.map +1 -0
- package/dist/src/doctor/checks-live.d.ts +5 -14
- package/dist/src/doctor/checks-live.d.ts.map +1 -1
- package/dist/src/doctor/checks-live.js +8 -18
- package/dist/src/doctor/checks-live.js.map +1 -1
- package/dist/src/doctor/request.d.ts +14 -0
- package/dist/src/doctor/request.d.ts.map +1 -0
- package/dist/src/doctor/request.js +17 -0
- package/dist/src/doctor/request.js.map +1 -0
- package/dist/src/doctor/types.d.ts +1 -0
- package/dist/src/doctor/types.d.ts.map +1 -1
- package/dist/src/doctor/types.js +1 -0
- package/dist/src/doctor/types.js.map +1 -1
- package/dist/src/editor-page/bundle.d.ts +4 -0
- package/dist/src/editor-page/bundle.d.ts.map +1 -1
- package/dist/src/editor-page/bundle.js +55 -7
- package/dist/src/editor-page/bundle.js.map +1 -1
- package/dist/src/editor-page/data-schemas.d.ts +19 -5
- package/dist/src/editor-page/data-schemas.d.ts.map +1 -1
- package/dist/src/editor-page/data-schemas.js +17 -13
- package/dist/src/editor-page/data-schemas.js.map +1 -1
- package/dist/src/editor-page/emit.d.ts +3 -0
- package/dist/src/editor-page/emit.d.ts.map +1 -1
- package/dist/src/editor-page/emit.js +27 -10
- package/dist/src/editor-page/emit.js.map +1 -1
- package/dist/src/editor-page/frame-chains.d.ts +51 -0
- package/dist/src/editor-page/frame-chains.d.ts.map +1 -0
- package/dist/src/editor-page/frame-chains.js +121 -0
- package/dist/src/editor-page/frame-chains.js.map +1 -0
- package/dist/src/editor-page/page.d.ts +1 -3
- package/dist/src/editor-page/page.d.ts.map +1 -1
- package/dist/src/editor-page/page.js +3 -5
- package/dist/src/editor-page/page.js.map +1 -1
- package/dist/src/integration.d.ts.map +1 -1
- package/dist/src/integration.js +3 -0
- package/dist/src/integration.js.map +1 -1
- package/dist/src/preview/banner.d.ts +3 -2
- package/dist/src/preview/banner.d.ts.map +1 -1
- package/dist/src/preview/banner.js +15 -6
- package/dist/src/preview/banner.js.map +1 -1
- package/dist/src/preview/content-api.d.ts +8 -1
- package/dist/src/preview/content-api.d.ts.map +1 -1
- package/dist/src/preview/content-api.js +16 -1
- package/dist/src/preview/content-api.js.map +1 -1
- package/dist/src/preview/dispatcher.d.ts.map +1 -1
- package/dist/src/preview/dispatcher.js +10 -4
- package/dist/src/preview/dispatcher.js.map +1 -1
- package/dist/src/preview/site-middleware.d.ts.map +1 -1
- package/dist/src/preview/site-middleware.js +9 -4
- package/dist/src/preview/site-middleware.js.map +1 -1
- package/dist/src/preview/unready-pages.d.ts +21 -0
- package/dist/src/preview/unready-pages.d.ts.map +1 -0
- package/dist/src/preview/unready-pages.js +54 -0
- package/dist/src/preview/unready-pages.js.map +1 -0
- package/package.json +5 -5
- package/src/component-manifest.ts +30 -4
- package/src/descriptors.ts +6 -2
- package/src/doctor/ancestor-chain.ts +58 -0
- package/src/doctor/checks-frames.ts +84 -0
- package/src/doctor/checks-live.ts +9 -37
- package/src/doctor/request.ts +27 -0
- package/src/doctor/types.ts +1 -0
- package/src/editor-page/bundle.ts +65 -7
- package/src/editor-page/data-schemas.ts +30 -16
- package/src/editor-page/emit.ts +29 -10
- package/src/editor-page/frame-chains.ts +143 -0
- package/src/editor-page/page.ts +3 -4
- package/src/integration.ts +3 -0
- package/src/preview/banner.ts +17 -4
- package/src/preview/content-api.ts +18 -1
- package/src/preview/dispatcher.ts +10 -5
- package/src/preview/site-middleware.ts +9 -4
- package/src/preview/unready-pages.ts +65 -0
- package/src/skill/SKILL.md +7 -2
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { ContentManifest } from '@conloca/content-api';
|
|
2
|
+
|
|
3
|
+
/** A page a push would hold back, as the preview banner names it. */
|
|
4
|
+
export type UnreadyPage = { title: string; path?: string; reason: 'conflict' | 'lfs' };
|
|
5
|
+
export type UnreadyKey = { id: string; locale: string; reason: 'conflict' | 'lfs' };
|
|
6
|
+
|
|
7
|
+
function isUnreadyKey(value: unknown): value is UnreadyKey {
|
|
8
|
+
if (typeof value !== 'object' || value === null || !('id' in value && 'locale' in value && 'reason' in value))
|
|
9
|
+
return false;
|
|
10
|
+
return (
|
|
11
|
+
typeof value.id === 'string' &&
|
|
12
|
+
typeof value.locale === 'string' &&
|
|
13
|
+
(value.reason === 'conflict' || value.reason === 'lfs')
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** The pages `/preview/unready-pages` names; `[]` on any failure, so the page renders without the banner line. */
|
|
18
|
+
export async function fetchUnreadyKeys(fetchImpl: typeof fetch, endpoint: string, jwt: string): Promise<UnreadyKey[]> {
|
|
19
|
+
try {
|
|
20
|
+
const response = await fetchImpl(`${endpoint}/preview/unready-pages`, {
|
|
21
|
+
headers: { authorization: `Bearer ${jwt}` },
|
|
22
|
+
});
|
|
23
|
+
if (!response.ok) return [];
|
|
24
|
+
const body: unknown = await response.json();
|
|
25
|
+
const pages = typeof body === 'object' && body !== null && 'pages' in body ? body.pages : undefined;
|
|
26
|
+
return Array.isArray(pages) ? pages.filter(isUnreadyKey) : [];
|
|
27
|
+
} catch {
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function titleUnreadyPages(keys: readonly UnreadyKey[], manifests: readonly ContentManifest[]): UnreadyPage[] {
|
|
33
|
+
return keys.map(({ id, locale, reason }) => {
|
|
34
|
+
const entry = manifests.find((m) => m.id === id)?.locales[locale];
|
|
35
|
+
const path = entry?.pathname;
|
|
36
|
+
return { title: entry?.meta?.title || entry?.name || id, ...(path === undefined ? {} : { path }), reason };
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The pages a push would hold back, for a page served without a {@link PreviewContentAPI} (one the preview build
|
|
42
|
+
* prerendered). `[]` on any failure.
|
|
43
|
+
*/
|
|
44
|
+
export async function loadUnreadyPages(fetchImpl: typeof fetch, endpoint: string, jwt: string): Promise<UnreadyPage[]> {
|
|
45
|
+
const listing = fetchImpl(`${endpoint}/preview/manifests`, { headers: { authorization: `Bearer ${jwt}` } })
|
|
46
|
+
.then(async (r) => {
|
|
47
|
+
const data: unknown = r.ok ? await r.json() : [];
|
|
48
|
+
return Array.isArray(data) ? data.filter(isListed) : [];
|
|
49
|
+
})
|
|
50
|
+
.catch((): ContentManifest[] => []);
|
|
51
|
+
const [keys, manifests] = await Promise.all([fetchUnreadyKeys(fetchImpl, endpoint, jwt), listing]);
|
|
52
|
+
return titleUnreadyPages(keys, manifests);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Enough of a manifest for {@link titleUnreadyPages}: an id and its locales. */
|
|
56
|
+
function isListed(value: unknown): value is ContentManifest {
|
|
57
|
+
return (
|
|
58
|
+
typeof value === 'object' &&
|
|
59
|
+
value !== null &&
|
|
60
|
+
'id' in value &&
|
|
61
|
+
'locales' in value &&
|
|
62
|
+
typeof value.locales === 'object' &&
|
|
63
|
+
value.locales !== null
|
|
64
|
+
);
|
|
65
|
+
}
|
package/src/skill/SKILL.md
CHANGED
|
@@ -36,7 +36,7 @@ conloca doctor --live # sends no credential: only your site's host and the e
|
|
|
36
36
|
conloca doctor # offline: wiring, sites.json host, committed framing headers, key leftovers
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
This package's checks are `CC1` and `CC8`–`
|
|
39
|
+
This package's checks are `CC1` and `CC8`–`CC30`:
|
|
40
40
|
|
|
41
41
|
- **CC9** — `sites.json`: the site named `default` (or the only one) has a bare host in `domains[defaultLocale]` and a
|
|
42
42
|
valid `base`. The editor opens `https://<host><base>_conloca/editor/`; it refuses IPs, `localhost`, `*.conloca.com`.
|
|
@@ -66,6 +66,10 @@ This package's checks are `CC1` and `CC8`–`CC29`:
|
|
|
66
66
|
`security.allowedDomains` on `@astrojs/node`. Fix: `npx @conloca/cli connect` (adds the adapter and its options).
|
|
67
67
|
- **CC29** (live) — `<host><base>_conloca/preview/__exit` answers 302, uncached, as the configured mode. A failure names
|
|
68
68
|
where the host keeps logs; a 401/403/429 means something in front of the site blocks `/_conloca/preview/*`.
|
|
69
|
+
- **CC30** (live) — a routing entry with an `editorFrame`: for each route in `_conloca/editor/frames.json`, the
|
|
70
|
+
published page wraps its `data-conloca-page-root` element in the same elements and classes the frame renders. The
|
|
71
|
+
canvas renders fragments inline inside that frame, so a drift shows the editor's prose in a different wrapper than the
|
|
72
|
+
page. Fix: change the frame or the layout so both wrap the page root alike. Only warns.
|
|
69
73
|
|
|
70
74
|
## Draft previews in the site's own build (d8)
|
|
71
75
|
|
|
@@ -82,7 +86,8 @@ This package's checks are `CC1` and `CC8`–`CC29`:
|
|
|
82
86
|
|
|
83
87
|
A site sending no `X-Frame-Options` and no `frame-ancestors` needs nothing (GitHub Pages included). Otherwise
|
|
84
88
|
`/_conloca/editor/*` needs `Content-Security-Policy: frame-ancestors 'self' https://*.conloca.com`, plus
|
|
85
|
-
`/_conloca/editor/sandbox-frame.html` → `Content-Security-Policy: sandbox allow-scripts
|
|
89
|
+
`/_conloca/editor/sandbox-frame.html` → `Content-Security-Policy: sandbox allow-scripts` (the frame for a component's
|
|
90
|
+
raw HTML; its own CSP has no `unsafe-eval`, and fragments render inline in the editor page). Cloudflare `_headers` also
|
|
86
91
|
detaches the site's headers on that path (`! X-Frame-Options`, `! Content-Security-Policy`); Netlify cannot detach;
|
|
87
92
|
Vercel uses `source: "/_conloca/editor/:path*"`. A site-wide CSP with `frame-ancestors` must be narrowed by hand — a
|
|
88
93
|
second policy cannot loosen it.
|