@seamlet/astro 0.11.2 → 0.12.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 +18 -6
- package/components/RichLine.astro +2 -5
- package/components/RichText.astro +2 -4
- package/dist/bridge.d.ts +2 -3
- package/dist/bridge.js +598 -374
- package/dist/{chunk-DRDPKFHZ.js → chunk-7GYJS7ZT.js} +386 -203
- package/dist/{chunk-2E7VDSUK.js → chunk-MW3BE5O6.js} +34 -43
- package/dist/chunk-QCVWHHJC.js +14 -0
- package/dist/{chunk-P2OQOZBC.js → chunk-QL4K4HR6.js} +8 -0
- package/dist/{chunk-3BS5CE26.js → chunk-W2LIOR2C.js} +6 -2
- package/dist/cli.js +96 -37
- package/dist/client.js +4 -1
- package/dist/index.js +52 -19
- package/dist/{messages-Dx0jNy3N.d.ts → messages-CvZhLRSE.d.ts} +29 -52
- package/dist/{content-6k-E7NWf.d.ts → parse-content-Eg8yRq_t.d.ts} +69 -1
- package/dist/preview-requests.d.ts +6 -1
- package/dist/preview-requests.js +3 -1
- package/dist/protocol.d.ts +31 -5
- package/dist/protocol.js +4 -3
- package/dist/routes/media.js +26 -5
- package/dist/routes/own-photos.js +2 -1
- package/dist/schema.d.ts +13 -8
- package/dist/schema.js +13 -1
- package/dist/site-description-Cg5KNhhG.d.ts +112 -0
- package/dist/site.d.ts +2 -2
- package/dist/site.js +83 -9
- package/package.json +1 -1
- package/routes/preview.astro +8 -11
- package/dist/parse-content-C9ldnmvj.d.ts +0 -69
- package/dist/site-description-4Jx6Nq6X.d.ts +0 -36
package/routes/preview.astro
CHANGED
|
@@ -4,29 +4,26 @@
|
|
|
4
4
|
// content; POST shows the content in its JSON body, never saved: the bridge renders the editor's
|
|
5
5
|
// draft this way.
|
|
6
6
|
import { parseContent } from "@seamlet/astro/schema";
|
|
7
|
-
import { readDraft } from "@seamlet/astro/preview-requests";
|
|
7
|
+
import { previewHeadersOf, readDraft } from "@seamlet/astro/preview-requests";
|
|
8
8
|
import { cmsOrigin } from "virtual:seamlet/config";
|
|
9
9
|
import site from "virtual:seamlet/site";
|
|
10
10
|
|
|
11
11
|
const NOT_FOUND = 404;
|
|
12
12
|
|
|
13
|
+
const headers = previewHeadersOf(cmsOrigin);
|
|
14
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
15
|
+
Astro.response.headers.set(name, value);
|
|
16
|
+
}
|
|
17
|
+
|
|
13
18
|
const Page = site.pageAt(Astro.params.page);
|
|
14
19
|
if (Page === undefined) {
|
|
15
|
-
return new Response(null, { status: NOT_FOUND });
|
|
20
|
+
return new Response(null, { status: NOT_FOUND, headers });
|
|
16
21
|
}
|
|
17
22
|
|
|
18
|
-
// Only the CMS's editor frames the preview, and nobody indexes or keeps it.
|
|
19
|
-
Astro.response.headers.set(
|
|
20
|
-
"Content-Security-Policy",
|
|
21
|
-
`frame-ancestors ${cmsOrigin}`,
|
|
22
|
-
);
|
|
23
|
-
Astro.response.headers.set("X-Robots-Tag", "noindex");
|
|
24
|
-
Astro.response.headers.set("Cache-Control", "no-store");
|
|
25
|
-
|
|
26
23
|
const reading =
|
|
27
24
|
Astro.request.method === "POST" ? await readDraft(Astro.request) : undefined;
|
|
28
25
|
if (reading !== undefined && !reading.isRead) {
|
|
29
|
-
return reading.response;
|
|
26
|
+
return new Response(null, { status: reading.response.status, headers });
|
|
30
27
|
}
|
|
31
28
|
const content =
|
|
32
29
|
reading === undefined
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { F as Fields, C as ContentOf } from './content-6k-E7NWf.js';
|
|
2
|
-
|
|
3
|
-
/** Where a value lives in the content: field names and, inside a collection, record indexes. */
|
|
4
|
-
type FieldPath = readonly (string | number)[];
|
|
5
|
-
type ContentIssue = {
|
|
6
|
-
readonly path: FieldPath;
|
|
7
|
-
readonly code: "invalid-type";
|
|
8
|
-
} | {
|
|
9
|
-
readonly path: FieldPath;
|
|
10
|
-
readonly code: "invalid-date";
|
|
11
|
-
} | {
|
|
12
|
-
readonly path: FieldPath;
|
|
13
|
-
readonly code: "invalid-time";
|
|
14
|
-
} | {
|
|
15
|
-
readonly path: FieldPath;
|
|
16
|
-
readonly code: "too-long";
|
|
17
|
-
readonly maxLength: number;
|
|
18
|
-
} | {
|
|
19
|
-
readonly path: FieldPath;
|
|
20
|
-
readonly code: "below-min";
|
|
21
|
-
readonly min: number;
|
|
22
|
-
} | {
|
|
23
|
-
readonly path: FieldPath;
|
|
24
|
-
readonly code: "above-max";
|
|
25
|
-
readonly max: number;
|
|
26
|
-
} | {
|
|
27
|
-
readonly path: FieldPath;
|
|
28
|
-
readonly code: "missing-image-src";
|
|
29
|
-
} | {
|
|
30
|
-
readonly path: FieldPath;
|
|
31
|
-
readonly code: "missing-link-href";
|
|
32
|
-
} | {
|
|
33
|
-
readonly path: FieldPath;
|
|
34
|
-
readonly code: "unsupported-link-href";
|
|
35
|
-
} | {
|
|
36
|
-
readonly path: FieldPath;
|
|
37
|
-
readonly code: "unsupported-url";
|
|
38
|
-
} | {
|
|
39
|
-
readonly path: FieldPath;
|
|
40
|
-
readonly code: "unknown-choice";
|
|
41
|
-
readonly value: string;
|
|
42
|
-
} | {
|
|
43
|
-
readonly path: FieldPath;
|
|
44
|
-
readonly code: "missing-record";
|
|
45
|
-
readonly id: string;
|
|
46
|
-
};
|
|
47
|
-
interface ParsedContent<C> {
|
|
48
|
-
readonly content: C;
|
|
49
|
-
readonly issues: readonly ContentIssue[];
|
|
50
|
-
}
|
|
51
|
-
declare function formatFieldPath(path: FieldPath): string;
|
|
52
|
-
/**
|
|
53
|
-
* The length that `maxLength` limits: characters as people see them (grapheme clusters), so
|
|
54
|
-
* "й" and "👍🏽" are one character each, whatever number of code units they take.
|
|
55
|
-
*/
|
|
56
|
-
declare function countCharacters(text: string): number;
|
|
57
|
-
/**
|
|
58
|
-
* Brings any input to the shape of the schema, so the result is always content of that schema:
|
|
59
|
-
* - a field missing from the input (the schema grew after the content was saved) gets its default;
|
|
60
|
-
* - a value of the wrong type or format gets the default too, and an issue;
|
|
61
|
-
* - a value of the right type that breaks a rule of its field (too long, below the minimum) is
|
|
62
|
-
* kept, with an issue: nothing a person typed is lost;
|
|
63
|
-
* - keys the schema does not know are dropped; a record keeps its id (see withRecordIds);
|
|
64
|
-
* - a reference to a record its collection does not have (removed since) is kept, with an issue.
|
|
65
|
-
* Content with issues is valid to show and edit, but not to save.
|
|
66
|
-
*/
|
|
67
|
-
declare function parseContent<F extends Fields>(schema: F, input: unknown): ParsedContent<ContentOf<F>>;
|
|
68
|
-
|
|
69
|
-
export { type ContentIssue as C, type FieldPath as F, type ParsedContent as P, countCharacters as c, formatFieldPath as f, parseContent as p };
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { F as Fields, a as Content } from './content-6k-E7NWf.js';
|
|
2
|
-
|
|
3
|
-
/** Where a site hands out its description, on the origin of its preview. */
|
|
4
|
-
declare const SITE_DESCRIPTION_PATH = "/seamlet/site.json";
|
|
5
|
-
/** A page of a site, which the site renders itself. */
|
|
6
|
-
interface SitePageDescription {
|
|
7
|
-
/** The address of the page on the site: `/` for the first page, `/menu` for others. */
|
|
8
|
-
readonly path: string;
|
|
9
|
-
/** How the editor names the page in its list of pages. */
|
|
10
|
-
readonly title: string;
|
|
11
|
-
/**
|
|
12
|
-
* Where the content holds what search engines and link previews show for the page
|
|
13
|
-
* (`seo.menu`): a group of a `title` and a `description` text.
|
|
14
|
-
*/
|
|
15
|
-
readonly searchTexts?: string;
|
|
16
|
-
}
|
|
17
|
-
interface SiteDescription {
|
|
18
|
-
/** The address of the site in the CMS (`/sites/<id>`). */
|
|
19
|
-
readonly id: string;
|
|
20
|
-
/** How the CMS names the site. */
|
|
21
|
-
readonly title: string;
|
|
22
|
-
readonly schema: Fields;
|
|
23
|
-
/** The content shown and edited until the first save. */
|
|
24
|
-
readonly initialContent: Content;
|
|
25
|
-
/** The pages of the site; the first is the home page at `/`. */
|
|
26
|
-
readonly pages: readonly [SitePageDescription, ...SitePageDescription[]];
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* The description the input gives, or undefined when it is not a whole and sound one: a known
|
|
30
|
-
* schema, an initial content with nothing to fix, the home page first, each page once.
|
|
31
|
-
*/
|
|
32
|
-
declare function readSiteDescription(input: unknown): SiteDescription | undefined;
|
|
33
|
-
/** Whether the path names a group of a `title` and a `description` text. */
|
|
34
|
-
declare function isSearchTextsGroup(schema: Fields, path: string): boolean;
|
|
35
|
-
|
|
36
|
-
export { type SiteDescription as S, SITE_DESCRIPTION_PATH as a, type SitePageDescription as b, isSearchTextsGroup as i, readSiteDescription as r };
|