@seamlet/astro 0.12.0 → 1.0.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/CHANGELOG.md ADDED
@@ -0,0 +1,28 @@
1
+ # Changelog
2
+
3
+ ## 1.0.0
4
+
5
+ The first stable version. From here the package follows semver: what a site writes against it keeps building until the next major version.
6
+
7
+ What is stable:
8
+
9
+ - `@seamlet/astro` — the integration `seamlet()`, with the site's id, title and CMS in `seamlet.json` (`CMS_ORIGIN` takes the place of `cms`).
10
+ - `@seamlet/astro/site` — `defineSeamletSite({ schema, initialContent, pages, photos })` with `pageAt`, `loadPublishedContent`, `ownPhotoAt` and `description`.
11
+ - `@seamlet/astro/schema` — the field kinds and their builders, `ContentOf`, `defaultContent`, `parseContent`, `editable`, `resolveFieldPath`, formatted text (`richTextOf`, `plainTextOf`, `linesOf`), `safeHref`, `imagePosition`, the presets, record ids, `readSiteConfig`, `readSiteDescription`, `checkSiteDescription` and `checkFields`.
12
+ - `@seamlet/astro/components/RichText.astro` and the routes the integration adds: the preview (`/preview`), the site's description (`/seamlet/site.json`), the photos taken from the CMS (`/media/<site>/<file>`) and the site's own photos for the editor (`/seamlet-photos/<address>`).
13
+ - `@seamlet/astro/protocol` — the messages between the bridge and the CMS's editor at `PROTOCOL_VERSION` 2. A change the other side cannot read raises it; the editor speaks with the bridges of earlier versions it lists.
14
+ - `npx @seamlet/astro init`.
15
+
16
+ Since 0.12.1 nothing changed in the code.
17
+
18
+ ## 0.12.1
19
+
20
+ - A field that became plain text keeps the words of a formatted text saved in it.
21
+
22
+ ## 0.12.0
23
+
24
+ - `safeHref`: an address no link may have never reaches markup; `RichText` and the bridge use it.
25
+ - A site the CMS would refuse stops its build with every reason (`checkSiteDescription`, `checkFields`); `readFields` refuses names with a dot or of digits, options of the wrong kind, references to a missing collection and an `itemTitle` that is no text or link.
26
+ - Requests to the CMS are bounded in time and number; `/media` answers 502 when the CMS does not.
27
+ - A draft rendered while a text is typed or the page pressed is shown once that is over.
28
+ - `init` starts a site with a title of any length and writes its modules all or none.
package/README.md CHANGED
@@ -178,7 +178,7 @@ export default defineSeamletSite({
178
178
  });
179
179
  ```
180
180
 
181
- A text with a link in a sentence, bold words or a list is one `richText` field, not a text cut around the link. Its value is data, never HTML: paragraphs (`{ kind: "paragraph", spans }`) and lists (`{ kind: "list", items }`) of pieces `{ text, bold?, italic?, href? }`, where `href` leads where a `link` may. `inline` keeps it one paragraph without lists, for a text inside an element that holds one line. A saved plain string is read as paragraphs, so a `text` field turned into `richText` keeps its words. Render it with the component of the package, which puts out paragraphs and lists (or, with `inline`, the words alone) and never raw HTML; style its elements from around it:
181
+ A text with a link in a sentence, bold words or a list is one `richText` field, not a text cut around the link. Its value is data, never HTML: paragraphs (`{ kind: "paragraph", spans }`) and lists (`{ kind: "list", items }`) of pieces `{ text, bold?, italic?, href? }`, where `href` leads where a `link` may. `inline` keeps it one paragraph without lists, for a text inside an element that holds one line. A saved plain string is read as paragraphs, so a `text` field turned into `richText` keeps its words, and a `richText` turned into `text` keeps them too, without their marks. Which texts to make formatted: prose (a lead, a description, a paragraph about the place) is `richText`; headings, names of records, the words of buttons and links, contacts and short labels stay `text`, so the owner meets one rule: a paragraph can be formatted, the rest is typed as it is. Give every mark a style the site's fonts can show: a font without an italic needs another way to show `<em>` (another family's italic, a colour), or the owner presses «К» and sees nothing. Render it with the component of the package, which puts out paragraphs and lists (or, with `inline`, the words alone) and never raw HTML; style its elements from around it:
182
182
 
183
183
  ```astro
184
184
  ---
package/dist/bridge.js CHANGED
@@ -18,7 +18,7 @@ import {
18
18
  shortcutOf,
19
19
  toggleList,
20
20
  toggleMark
21
- } from "./chunk-MW3BE5O6.js";
21
+ } from "./chunk-SSECNMAD.js";
22
22
  import {
23
23
  FIELD_PATH_ATTRIBUTE,
24
24
  REVEALED_ATTRIBUTE,
@@ -28,7 +28,7 @@ import {
28
28
  readRichText,
29
29
  resolveFieldPath,
30
30
  safeHref
31
- } from "./chunk-7GYJS7ZT.js";
31
+ } from "./chunk-ZS32CW5F.js";
32
32
 
33
33
  // src/bridge/typed-fields.ts
34
34
  function typedKindAt(schema, path) {
@@ -6,7 +6,7 @@ import {
6
6
  readRichText,
7
7
  resolveFieldPath,
8
8
  safeHref
9
- } from "./chunk-7GYJS7ZT.js";
9
+ } from "./chunk-ZS32CW5F.js";
10
10
 
11
11
  // src/bridge/editor-shortcuts.ts
12
12
  function shortcutOf(event) {
@@ -558,17 +558,23 @@ function parseField(field, input, path) {
558
558
  }
559
559
  }
560
560
  function parseText(field, input, path) {
561
- if (typeof input !== "string") {
561
+ const typed = typedTextOf(input);
562
+ if (typed === void 0) {
562
563
  return invalidType(defaultValue(field), path);
563
564
  }
564
- const isTooLong = field.maxLength !== void 0 && countCharacters(input) > field.maxLength;
565
+ const isTooLong = field.maxLength !== void 0 && countCharacters(typed) > field.maxLength;
565
566
  if (isTooLong) {
566
567
  return {
567
- value: input,
568
+ value: typed,
568
569
  issues: [{ path, code: "too-long", maxLength: field.maxLength }]
569
570
  };
570
571
  }
571
- return valid(input);
572
+ return valid(typed);
573
+ }
574
+ function typedTextOf(input) {
575
+ if (typeof input === "string") return input;
576
+ const formatted = readRichText(input);
577
+ return formatted === void 0 ? void 0 : plainTextOf(formatted);
572
578
  }
573
579
  function parseRichText(field, input, path) {
574
580
  const read2 = typeof input === "string" ? richTextOf(input) : readRichText(input);
package/dist/cli.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  SITE_CONFIG_FILE,
4
4
  isSiteId,
5
5
  readSiteConfig
6
- } from "./chunk-7GYJS7ZT.js";
6
+ } from "./chunk-ZS32CW5F.js";
7
7
  import {
8
8
  SITE_MODULE_FILE
9
9
  } from "./chunk-QCVWHHJC.js";
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  SITE_DESCRIPTION_PATH,
7
7
  isJsonObject,
8
8
  readSiteConfig
9
- } from "./chunk-7GYJS7ZT.js";
9
+ } from "./chunk-ZS32CW5F.js";
10
10
  import {
11
11
  PREVIEW_PATH,
12
12
  SITE_MODULE_FILE,
package/dist/protocol.js CHANGED
@@ -22,8 +22,8 @@ import {
22
22
  shortcutOf,
23
23
  toggleList,
24
24
  toggleMark
25
- } from "./chunk-MW3BE5O6.js";
26
- import "./chunk-7GYJS7ZT.js";
25
+ } from "./chunk-SSECNMAD.js";
26
+ import "./chunk-ZS32CW5F.js";
27
27
  import "./chunk-QCVWHHJC.js";
28
28
  export {
29
29
  OWN_PHOTOS_PATH,
package/dist/schema.js CHANGED
@@ -57,7 +57,7 @@ import {
57
57
  toggle,
58
58
  url,
59
59
  withRecordIds
60
- } from "./chunk-7GYJS7ZT.js";
60
+ } from "./chunk-ZS32CW5F.js";
61
61
  export {
62
62
  FIELD_PATH_ATTRIBUTE,
63
63
  HOME_PAGE_PATH,
package/dist/site.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  checkSiteDescription,
4
4
  formatFieldPath,
5
5
  parseContent
6
- } from "./chunk-7GYJS7ZT.js";
6
+ } from "./chunk-ZS32CW5F.js";
7
7
  import {
8
8
  SITE_MODULE_FILE
9
9
  } from "./chunk-QCVWHHJC.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seamlet/astro",
3
- "version": "0.12.0",
3
+ "version": "1.0.0",
4
4
  "description": "Connects an Astro site to the Seamlet CMS: the schema of its content, the preview the editor frames, and its published content.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -59,7 +59,8 @@
59
59
  "files": [
60
60
  "dist",
61
61
  "routes",
62
- "components"
62
+ "components",
63
+ "CHANGELOG.md"
63
64
  ],
64
65
  "scripts": {
65
66
  "build": "tsup"