@ascribed/astro 0.1.2-next.4 → 0.1.2-next.6

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 CHANGED
@@ -31,12 +31,17 @@ import { schema } from "../.ascribe/build/site/site/_ascribe/schema.ts";
31
31
  export const collections = { docs: defineCollection(ascribeCollection({ schema })) };
32
32
  ```
33
33
 
34
+ If the Ascribe project is outside the Astro root (`project: "../docs"`), import `../.astro/integrations/_ascribed_astro/schema.ts` instead: the integration copies the schema there after each build, so TypeScript finds `astro/zod` from it.
35
+
34
36
  ```astro
35
37
  ---
36
38
  // A layout
37
39
  import Elements from "@ascribed/astro/Elements.astro";
40
+ import Availability from "@ascribed/astro/Availability.astro";
41
+ const { entry } = Astro.props;
38
42
  ---
39
43
  <head><Elements /></head>
44
+ <Availability available={entry.data.available} />
40
45
  ```
41
46
 
42
47
  The [Astro guide](https://ascribed-dev.com/guides/astro/) walks through a site: `ascribe.toml`, the collection, the route, the layout, the options, what `astro dev` does, and [review in the site preview](https://ascribed-dev.com/guides/astro/#review-in-the-site-preview). [Review](https://ascribed-dev.com/guides/review/) walks through reviewing a pull request on your site.
@@ -50,6 +55,7 @@ The [Astro guide](https://ascribed-dev.com/guides/astro/) walks through a site:
50
55
  | `binary` | The `ascribe` binary, relative to the Astro root. By default, `ASCRIBE_BIN`, then the binary `@ascribed/cli` installed. |
51
56
  | `anchors` | Source anchors (`ascribe build --anchors`), for review: `"dev"` in `astro dev` only, `true` always. By default, `false`, though `review` turns them on in `astro dev`. |
52
57
  | `review` | The **Ascribe review** app in `astro dev`'s toolbar: a pull request's changes and comments on the real page. `false` leaves it out. By default, `true`. Never in `astro build`. |
58
+ | `codeTitles` | A code block's title (`title="…"` in its info string, as `@snippet` writes it) above it: a Shiki transformer puts the block in a `<figure class="code-title">` with a `<figcaption>`. `false` leaves it out. By default, `true`. |
53
59
 
54
60
  ## Development
55
61
 
@@ -58,13 +64,16 @@ The [Astro guide](https://ascribed-dev.com/guides/astro/) walks through a site:
58
64
  | `src/index.ts` | The integration |
59
65
  | `src/content.ts` | `ascribeCollection`, for `content.config.ts` |
60
66
  | `src/Elements.astro` | Loads `@ascribed/elements` (stylesheet and script) |
67
+ | `src/Availability.astro` | A page's availability as the element library's badge |
68
+ | `src/code-titles.ts` | The Shiki transformer that shows code block titles |
69
+ | `src/schema.ts` | Copies the generated schema inside the Astro root |
61
70
  | `src/attributes.ts` | The attribute-marker and source-anchor rules, on a hast tree |
62
71
  | `src/rehype.ts`, `src/satteri.ts` | The rules applied in each of Astro's Markdown processors |
63
72
  | `src/project.ts`, `src/binary.ts`, `src/run.ts`, `src/files.ts`, `src/dev.ts` | `ascribe.toml`, the binary, running it, serving files, dev rebuilds |
64
73
  | `src/review/` | Review in the site preview, on the dev server's side: `ascribe diff`, the pull request (through `@ascribed/review/github` and `gh`), the routes, `.ascribe/dev.json`, and the toolbar channel's requests (`server.ts`, `protocol.ts`) |
65
74
  | `src/toolbar/` | The **Ascribe review** toolbar app, in the page: the panel, and the `@ascribed/review` overlay on the page's blocks |
66
75
 
67
- The site imports `schema` from the generated file by path, so the output directory and the build name appear there as well as in `ascribe.toml` and the integration's options. That's deliberate: Vite compiles the TypeScript file where it is, so the site keeps the schema's exact inferred types, which a virtual module re-exporting it would hide.
76
+ The site imports `schema` from the generated file by path, so the output directory and the build name appear there as well as in `ascribe.toml` and the integration's options. That's deliberate: Vite compiles the TypeScript file where it is, so the site keeps the schema's exact inferred types, which a virtual module re-exporting it would hide. For the same reason the copy in `.astro/` is a file, not a module the integration provides; TypeScript can't type a virtual module from a file without repeating its exports.
68
77
 
69
78
  ```sh
70
79
  pnpm --filter @ascribed/astro test
@@ -10,7 +10,7 @@ export interface HastNode {
10
10
  export type Attribute = readonly [name: string, value: string];
11
11
  /** What applying one marker changes. */
12
12
  export interface Edit {
13
- /** The heading or image that gets the attributes. */
13
+ /** The heading, image, or link that gets the attributes. */
14
14
  target: HastNode;
15
15
  /** The marker's attributes, in the order written. */
16
16
  attributes: Attribute[];
@@ -26,7 +26,7 @@ export interface Edit {
26
26
  value: string;
27
27
  }[];
28
28
  }
29
- /** Finds every marker that applies to a heading or an image in `root`. */
29
+ /** Finds every marker that applies to a heading, an image, or a link in `root`. */
30
30
  export declare function findEdits(root: HastNode): Edit[];
31
31
  /**
32
32
  * A marker attribute as a hast property: the property name hast and Astro use
@@ -4,7 +4,8 @@
4
4
  // Both markdown processors Astro 7.3 can run hand a user plugin the same tree
5
5
  // at the same point: after markdown became hast, before Astro's own image and
6
6
  // heading-id passes. A marker is then two adjacent `raw` nodes (an open tag and
7
- // a close tag), and the elements it applies to are `<h1>`–`<h6>` and `<img>`.
7
+ // a close tag), and the elements it applies to are `<h1>`–`<h6>`, `<img>`,
8
+ // and `<a>`.
8
9
  // An anchor comment is a `raw` node beside the block it names. So the rules
9
10
  // live here once, as pure functions from a tree to a list of edits, and each
10
11
  // processor's adapter applies the edits with its own means (`rehype.ts`
@@ -14,7 +15,7 @@ const OPEN = /^<ascribe-attributes((?: [a-z][a-z0-9-]*="[^"\r\n]*")*)>$/;
14
15
  const CLOSE = "</ascribe-attributes>";
15
16
  const ATTRIBUTE = / ([a-z][a-z0-9-]*)="([^"]*)"/g;
16
17
  const HEADING = /^h[1-6]$/;
17
- /** Finds every marker that applies to a heading or an image in `root`. */
18
+ /** Finds every marker that applies to a heading, an image, or a link in `root`. */
18
19
  export function findEdits(root) {
19
20
  const edits = [];
20
21
  visitParents(root, (parent) => {
@@ -28,8 +29,10 @@ export function findEdits(root) {
28
29
  const last = i + length - 1;
29
30
  const marker = children.slice(i, last + 1);
30
31
  const before = children[i - 1];
31
- if (before !== undefined && before.type === "element" && before.tagName === "img") {
32
- // Directly after an image, whatever else the marker ends.
32
+ if (before !== undefined &&
33
+ before.type === "element" &&
34
+ (before.tagName === "img" || before.tagName === "a")) {
35
+ // Directly after an image or a link, whatever else the marker ends.
33
36
  edits.push({ target: before, attributes, remove: marker, trim: [] });
34
37
  }
35
38
  else if (isHeading && last === children.length - 1) {
@@ -133,7 +136,15 @@ export function findAnchors(root) {
133
136
  next++;
134
137
  }
135
138
  const target = children[next];
136
- if (target?.type === "element" && target.tagName?.toLowerCase() === anchor.tag) {
139
+ if (anchor.tag === "pre" && target !== undefined && isCodeTitle(target)) {
140
+ // A titled code block, which the code-titles transformer put in a
141
+ // figure: the anchor marks the figure, so the mark holds the caption.
142
+ edit.targets.push({
143
+ node: target,
144
+ attributes: anchorAttributes(anchor.source, anchor.via),
145
+ });
146
+ }
147
+ else if (target?.type === "element" && target.tagName?.toLowerCase() === anchor.tag) {
137
148
  edit.targets.push({
138
149
  node: target,
139
150
  attributes: anchorAttributes(anchor.source, anchor.via),
@@ -159,6 +170,19 @@ export function findAnchors(root) {
159
170
  });
160
171
  return edits;
161
172
  }
173
+ /** Whether a node is a `<figure class="code-title">` holding a `<pre>` (`code-titles.ts`). */
174
+ function isCodeTitle(node) {
175
+ if (node.type !== "element" || node.tagName?.toLowerCase() !== "figure")
176
+ return false;
177
+ const className = node.properties?.["className"] ?? node.properties?.["class"];
178
+ const classes = Array.isArray(className)
179
+ ? className.map(String)
180
+ : typeof className === "string"
181
+ ? className.split(/\s+/)
182
+ : [];
183
+ return (classes.includes("code-title") &&
184
+ (node.children ?? []).some((child) => child.type === "element" && child.tagName?.toLowerCase() === "pre"));
185
+ }
162
186
  function parseAnchor(text) {
163
187
  const match = ANCHOR.exec(text);
164
188
  if (match === null)
@@ -1 +1 @@
1
- {"version":3,"file":"attributes.js","sourceRoot":"","sources":["../src/attributes.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,yEAAyE;AACzE,EAAE;AACF,8EAA8E;AAC9E,8EAA8E;AAC9E,gFAAgF;AAChF,8EAA8E;AAC9E,4EAA4E;AAC5E,6EAA6E;AAC7E,wEAAwE;AACxE,mDAAmD;AAEnD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AA8BlD,MAAM,IAAI,GAA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S,EAAE,CAAC,EAAE,EAAE,EAAE,CACrC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAC5E,CAAC;AACJ,CAAC","sourcesContent":["// The site output's attribute marker (`<ascribe-attributes>`) and source\n// anchors (`<!--ascribe-anchor …-->`), found and applied on a hast tree.\n//\n// Both markdown processors Astro 7.3 can run hand a user plugin the same tree\n// at the same point: after markdown became hast, before Astro's own image and\n// heading-id passes. A marker is then two adjacent `raw` nodes (an open tag and\n// a close tag), and the elements it applies to are `<h1>`–`<h6>`, `<img>`,\n// and `<a>`.\n// An anchor comment is a `raw` node beside the block it names. So the rules\n// live here once, as pure functions from a tree to a list of edits, and each\n// processor's adapter applies the edits with its own means (`rehype.ts`\n// mutates the tree, `satteri.ts` queues commands).\n\nimport { find, html } from \"property-information\";\n\n/** The parts of a hast node the rules read. Both processors' trees fit it. */\nexport interface HastNode {\n type: string;\n tagName?: string;\n value?: string;\n properties?: Record<string, unknown> | undefined;\n children?: HastNode[];\n}\n\n/** A marker's attribute: a name and its decoded value. */\nexport type Attribute = readonly [name: string, value: string];\n\n/** What applying one marker changes. */\nexport interface Edit {\n /** The heading, image, or link that gets the attributes. */\n target: HastNode;\n /** The marker's attributes, in the order written. */\n attributes: Attribute[];\n /** The marker's nodes, which are removed. */\n remove: HastNode[];\n /**\n * For a heading: the text nodes directly before the marker, whose trailing\n * whitespace is removed. A node whose text becomes empty is removed\n * (`value` is `\"\"`).\n */\n trim: { node: HastNode; value: string }[];\n}\n\nconst OPEN = /^<ascribe-attributes((?: [a-z][a-z0-9-]*=\"[^\"\\r\\n]*\")*)>$/;\nconst CLOSE = \"</ascribe-attributes>\";\nconst ATTRIBUTE = / ([a-z][a-z0-9-]*)=\"([^\"]*)\"/g;\nconst HEADING = /^h[1-6]$/;\n\n/** Finds every marker that applies to a heading, an image, or a link in `root`. */\nexport function findEdits(root: HastNode): Edit[] {\n const edits: Edit[] = [];\n visitParents(root, (parent) => {\n const children = parent.children ?? [];\n const isHeading = parent.type === \"element\" && HEADING.test(parent.tagName ?? \"\");\n for (let i = 0; i < children.length; i++) {\n const found = markerAt(children, i);\n if (found === undefined) continue;\n const { attributes, length } = found;\n const last = i + length - 1;\n const marker = children.slice(i, last + 1);\n const before = children[i - 1];\n if (\n before !== undefined &&\n before.type === \"element\" &&\n (before.tagName === \"img\" || before.tagName === \"a\")\n ) {\n // Directly after an image or a link, whatever else the marker ends.\n edits.push({ target: before, attributes, remove: marker, trim: [] });\n } else if (isHeading && last === children.length - 1) {\n edits.push({\n target: parent,\n attributes,\n remove: marker,\n trim: trailingWhitespace(children, i),\n });\n }\n i = last;\n }\n });\n return edits;\n}\n\n/** The marker starting at `children[i]`: its attributes and how many nodes it spans. */\nfunction markerAt(\n children: HastNode[],\n i: number,\n): { attributes: Attribute[]; length: number } | undefined {\n const first = children[i];\n if (first?.type !== \"raw\" || first.value === undefined) return undefined;\n if (first.value.endsWith(CLOSE)) {\n // One node holding both tags.\n const open = first.value.slice(0, -CLOSE.length);\n const attributes = parseOpen(open);\n return attributes && { attributes, length: 1 };\n }\n const second = children[i + 1];\n if (second?.type !== \"raw\" || second.value !== CLOSE) return undefined;\n const attributes = parseOpen(first.value);\n return attributes && { attributes, length: 2 };\n}\n\nfunction parseOpen(tag: string): Attribute[] | undefined {\n const match = OPEN.exec(tag);\n if (match === null) return undefined;\n const attributes: Attribute[] = [];\n for (const [, name, value] of (match[1] ?? \"\").matchAll(ATTRIBUTE)) {\n if (name !== undefined && value !== undefined) attributes.push([name, decode(value)]);\n }\n return attributes;\n}\n\n/** The marker's four escapes; any other `&` is literal. */\nfunction decode(value: string): string {\n return value.replace(/&(quot|amp|lt|gt);/g, (_, name: string) =>\n name === \"quot\" ? '\"' : name === \"amp\" ? \"&\" : name === \"lt\" ? \"<\" : \">\",\n );\n}\n\n/** The spaces, tabs, and line breaks directly before `children[i]`, which a heading's marker removes. */\nfunction trailingWhitespace(children: HastNode[], i: number): Edit[\"trim\"] {\n const trim: Edit[\"trim\"] = [];\n for (let j = i - 1; j >= 0; j--) {\n const node = children[j];\n if (node?.type !== \"text\" || node.value === undefined) break;\n const value = node.value.replace(/[ \\t\\r\\n]+$/, \"\");\n if (value === node.value) break;\n trim.push({ node, value });\n if (value !== \"\") break;\n }\n return trim;\n}\n\nfunction visitParents(node: HastNode, visit: (parent: HastNode) => void): void {\n if (node.children === undefined) return;\n visit(node);\n for (const child of node.children) visitParents(child, visit);\n}\n\n/**\n * A marker attribute as a hast property: the property name hast and Astro use\n * (`class` is `className`) and a value of the shape that property has.\n */\nexport function toProperty([name, value]: Attribute): [string, string | string[]] {\n const info = find(html, name);\n if (info.spaceSeparated) return [info.property, value.split(/\\s+/).filter((s) => s !== \"\")];\n if (info.commaSeparated) return [info.property, value.split(/\\s*,\\s*/)];\n return [info.property, value];\n}\n\n/** What applying one source anchor (site-render contract §7) changes. */\nexport interface AnchorEdit {\n /** The anchor comment, and the whitespace-only text directly after it, which are removed. */\n remove: HastNode[];\n /** Elements that get attributes: the block, and a list's items. Empty when the anchor applies to nothing. */\n targets: { node: HastNode; attributes: Attribute[] }[];\n /** Raw HTML whose first tag gets the anchor's attributes: the node and its new text. */\n replace?: { node: HastNode; value: string };\n}\n\nconst ANCHOR = /^<!--ascribe-anchor((?: [a-z][a-z0-9-]*=\"[^\"\\r\\n]*\")+)-->\\s*$/;\n\n/** Finds every source anchor comment in `root`, and what it applies to. */\nexport function findAnchors(root: HastNode): AnchorEdit[] {\n const edits: AnchorEdit[] = [];\n visitParents(root, (parent) => {\n const children = parent.children ?? [];\n for (let i = 0; i < children.length; i++) {\n const node = children[i];\n if (node?.type !== \"raw\" || node.value === undefined) continue;\n const anchor = parseAnchor(node.value);\n if (anchor === undefined) continue;\n const edit: AnchorEdit = { remove: [node], targets: [] };\n let next = i + 1;\n const after = children[next];\n if (after?.type === \"text\" && after.value?.trim() === \"\") {\n edit.remove.push(after);\n next++;\n }\n const target = children[next];\n if (anchor.tag === \"pre\" && target !== undefined && isCodeTitle(target)) {\n // A titled code block, which the code-titles transformer put in a\n // figure: the anchor marks the figure, so the mark holds the caption.\n edit.targets.push({\n node: target,\n attributes: anchorAttributes(anchor.source, anchor.via),\n });\n } else if (target?.type === \"element\" && target.tagName?.toLowerCase() === anchor.tag) {\n edit.targets.push({\n node: target,\n attributes: anchorAttributes(anchor.source, anchor.via),\n });\n if ((anchor.tag === \"ul\" || anchor.tag === \"ol\") && anchor.items.length > 0) {\n const items = (target.children ?? []).filter(\n (child) => child.type === \"element\" && child.tagName === \"li\",\n );\n const path = anchor.source.slice(0, anchor.source.lastIndexOf(\":\"));\n if (items.length === anchor.items.length) {\n items.forEach((item, n) =>\n edit.targets.push({\n node: item,\n attributes: anchorAttributes(`${path}:${anchor.items[n]}`, anchor.via),\n }),\n );\n }\n }\n } else if (target?.type === \"raw\" && target.value !== undefined) {\n const value = intoFirstTag(target.value, anchor);\n if (value !== undefined) edit.replace = { node: target, value };\n }\n edits.push(edit);\n }\n });\n return edits;\n}\n\n/** Whether a node is a `<figure class=\"code-title\">` holding a `<pre>` (`code-titles.ts`). */\nfunction isCodeTitle(node: HastNode): boolean {\n if (node.type !== \"element\" || node.tagName?.toLowerCase() !== \"figure\") return false;\n const className = node.properties?.[\"className\"] ?? node.properties?.[\"class\"];\n const classes = Array.isArray(className)\n ? className.map(String)\n : typeof className === \"string\"\n ? className.split(/\\s+/)\n : [];\n return (\n classes.includes(\"code-title\") &&\n (node.children ?? []).some(\n (child) => child.type === \"element\" && child.tagName?.toLowerCase() === \"pre\",\n )\n );\n}\n\ninterface Anchor {\n tag: string;\n source: string;\n via: string | undefined;\n items: string[];\n}\n\nfunction parseAnchor(text: string): Anchor | undefined {\n const match = ANCHOR.exec(text);\n if (match === null) return undefined;\n const attributes = new Map<string, string>();\n for (const [, name, value] of (match[1] ?? \"\").matchAll(ATTRIBUTE)) {\n if (name !== undefined && value !== undefined) attributes.set(name, decode(value));\n }\n const tag = attributes.get(\"tag\");\n const source = attributes.get(\"source\");\n if (tag === undefined || source === undefined) return undefined;\n const via = attributes.get(\"via\");\n return {\n tag: tag.toLowerCase(),\n source,\n via: via === \"\" ? undefined : via,\n items: (attributes.get(\"items\") ?? \"\").split(/\\s+/).filter((s) => s !== \"\"),\n };\n}\n\nfunction anchorAttributes(source: string, via: string | undefined): Attribute[] {\n const attributes: Attribute[] = [[\"data-ascribe-source\", source]];\n if (via !== undefined) attributes.push([\"data-ascribe-via\", via]);\n return attributes;\n}\n\n/** Raw HTML with the anchor's attributes after the name of its first tag, when that tag opens the element the anchor names. */\nfunction intoFirstTag(html: string, anchor: Anchor): string | undefined {\n const open = /^<([A-Za-z][A-Za-z0-9-]*)(?=[\\s>/])/.exec(html);\n if (open?.[1] === undefined || open[1].toLowerCase() !== anchor.tag) return undefined;\n const written = anchorAttributes(anchor.source, anchor.via)\n .map(([name, value]) => ` ${name}=\"${encode(value)}\"`)\n .join(\"\");\n return html.slice(0, open[0].length) + written + html.slice(open[0].length);\n}\n\nfunction encode(value: string): string {\n return value.replace(/[&<>\"]/g, (ch) =>\n ch === \"&\" ? \"&amp;\" : ch === \"<\" ? \"&lt;\" : ch === \">\" ? \"&gt;\" : \"&quot;\",\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"binary.js","sourceRoot":"","sources":["../src/binary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,iFAAiF;AACjF,MAAM,UAAU,UAAU,CAAC,OAAsD;IAC/E,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QACjC,MAAM,MAAM,GAAG,IAAI,CAA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AAO,KAAK,SAAS,IAAI,OAAO,KAAK,EAAE,EAAE,CAAC;QAC5C,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACrC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,sCAAsC,MAAM,wBAAwB,CAAC,CAAC;QACxF,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,OAAO,aAAa,EAAE,CAAC;AACzB,CAAC","sourcesContent":["import { resolveBinary } from \"@ascribed/cli/binary\";\nimport { existsSync } from \"node:fs\";\nimport path from \"node:path\";\n\n/** The path of the binary to run. Throws an error saying how to point at one. */\nexport function findBinary(options: { binary?: string | undefined; root: string }): string {\n if (options.binary !== undefined) {\n const binary = path.resolve(options.root, options.binary);\n if (!existsSync(binary))\n throw new Error(\n `@ascribed/astro: the \\`binary\\` option names ${binary}, which doesn't exist.`,\n );\n return binary;\n }\n const fromEnv = process.env[\"ASCRIBE_BIN\"];\n if (fromEnv !== undefined && fromEnv !== \"\") {\n const binary = path.resolve(fromEnv);\n if (!existsSync(binary))\n throw new Error(`@ascribed/astro: ASCRIBE_BIN names ${binary}, which doesn't exist.`);\n return binary;\n }\n return resolveBinary();\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import type { AstroUserConfig } from "astro";
2
+ type ShikiTransformer = NonNullable<NonNullable<NonNullable<AstroUserConfig["markdown"]>["shikiConfig"]>["transformers"]>[number];
3
+ /**
4
+ * The `title="…"` in a code block's meta, if it has one. The meta has its
5
+ * Markdown escapes taken off (`title="say \"hi\""` arrives as
6
+ * `title="say "hi""`), so the title ends at a quote followed by a space or the
7
+ * end, and a quote inside it survives.
8
+ */
9
+ export declare function codeTitle(meta: string): string | undefined;
10
+ export declare const codeTitles: ShikiTransformer;
11
+ export {};
@@ -0,0 +1,37 @@
1
+ /**
2
+ * The `title="…"` in a code block's meta, if it has one. The meta has its
3
+ * Markdown escapes taken off (`title="say \"hi\""` arrives as
4
+ * `title="say "hi""`), so the title ends at a quote followed by a space or the
5
+ * end, and a quote inside it survives.
6
+ */
7
+ export function codeTitle(meta) {
8
+ return /(?:^|\s)title="(.*?)"(?=\s|$)/.exec(meta)?.[1] || undefined;
9
+ }
10
+ export const codeTitles = {
11
+ name: "@ascribed/astro:code-titles",
12
+ root(root) {
13
+ const meta = this.options.meta?.__raw ?? "";
14
+ const title = codeTitle(meta);
15
+ const pre = root.children.find((node) => node.type === "element");
16
+ // A site's own transformer may have put it in a figure already.
17
+ if (title === undefined || pre === undefined || pre.tagName === "figure")
18
+ return;
19
+ root.children = [
20
+ {
21
+ type: "element",
22
+ tagName: "figure",
23
+ properties: { className: ["code-title"] },
24
+ children: [
25
+ {
26
+ type: "element",
27
+ tagName: "figcaption",
28
+ properties: {},
29
+ children: [{ type: "text", value: title }],
30
+ },
31
+ pre,
32
+ ],
33
+ },
34
+ ];
35
+ },
36
+ };
37
+ //# sourceMappingURL=code-titles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-titles.js","sourceRoot":"","sources":["../src/code-titles.ts"],"names":[],"mappings":"AAWA;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,OAAO,+BAA+B,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC;AACtE,CAAC;AAED,MAAM,CAAC,MAAM,UAAU,GAAqB;IAC1C,IAAI,EAAE,6BAA6B;IACnC,IAAI,CAAC,IAAI;QACP,MAAM,IAAI,GAAI,IAAI,CAAC,OAAO,CAAC,IAAuC,EAAE,KAAK,IAAI,EAAE,CAAC;QAChF,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;QAC9B,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;QAClE,gEAAgE;QAChE,IAAI,KAAK,KAAK,SAAS,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,CAAC,OAAO,KAAK,QAAQ;YAAE,OAAO;QACjF,IAAI,CAAC,QAAQ,GAAG;YACd;gBACE,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,QAAQ;gBACjB,UAAU,EAAE,EAAE,SAAS,EAAE,CAAC,YAAY,CAAC,EAAE;gBACzC,QAAQ,EAAE;oBACR;wBACE,IAAI,EAAE,SAAS;wBACf,OAAO,EAAE,YAAY;wBACrB,UAAU,EAAE,EAAE;wBACd,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;qBAC3C;oBACD,GAAG;iBACJ;aACF;SACF,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["// A code block's title, shown above it. A `@snippet`'s title is in the code\n// block's info string, as `title=\"…\"` (SPEC §4.8), and Astro's own code\n// highlighting ignores it (issue #106), so the integration adds this Shiki\n// transformer, which puts a titled block in a <figure class=\"code-title\"> with\n// the title as its <figcaption>.\nimport type { AstroUserConfig } from \"astro\";\n\ntype ShikiTransformer = NonNullable<\n NonNullable<NonNullable<AstroUserConfig[\"markdown\"]>[\"shikiConfig\"]>[\"transformers\"]\n>[number];\n\n/**\n * The `title=\"…\"` in a code block's meta, if it has one. The meta has its\n * Markdown escapes taken off (`title=\"say \\\"hi\\\"\"` arrives as\n * `title=\"say \"hi\"\"`), so the title ends at a quote followed by a space or the\n * end, and a quote inside it survives.\n */\nexport function codeTitle(meta: string): string | undefined {\n return /(?:^|\\s)title=\"(.*?)\"(?=\\s|$)/.exec(meta)?.[1] || undefined;\n}\n\nexport const codeTitles: ShikiTransformer = {\n name: \"@ascribed/astro:code-titles\",\n root(root) {\n const meta = (this.options.meta as { __raw?: string } | undefined)?.__raw ?? \"\";\n const title = codeTitle(meta);\n const pre = root.children.find((node) => node.type === \"element\");\n // A site's own transformer may have put it in a figure already.\n if (title === undefined || pre === undefined || pre.tagName === \"figure\") return;\n root.children = [\n {\n type: \"element\",\n tagName: \"figure\",\n properties: { className: [\"code-title\"] },\n children: [\n {\n type: \"element\",\n tagName: \"figcaption\",\n properties: {},\n children: [{ type: \"text\", value: title }],\n },\n pre,\n ],\n },\n ];\n },\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"content.js","sourceRoot":"","sources":["../src/content.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,6EAA6E;AAC7E,2EAA2E;AAC3E,EAAE;AACF,sDAAsD;AACtD,iEAAiE;AACjE,6EAA6E;AAC7E,0FAA0F;AAC1F,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAAI,OAAsB;IAIzD,iEAAiE;IACjE,MAAM,IAAI,GAAG,aAAa,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;IAChD,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC,SAAS,EAAE,cAAc,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;AAClG,CAAC"}
1
+ {"version":3,"file":"content.js","sourceRoot":"","sources":["../src/content.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,6EAA6E;AAC7E,2EAA2E;AAC3E,EAAE;AACF,sDAAsD;AACtD,iEAAiE;AACjE,6EAA6E;AAC7E,0FAA0F;AAC1F,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAAI,OAAsB;IAIzD,iEAAiE;IACjE,MAAM,IAAI,GAAG,aAAa,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;IAChD,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC,SAAS,EAAE,cAAc,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;AAClG,CAAC","sourcesContent":["// The content collection over a build's site output. Import it from\n// `content.config.ts`, which Vite loads, so it can read what the integration\n// resolved (`virtual:ascribe/site`) instead of finding the project itself.\n//\n// import { defineCollection } from \"astro:content\";\n// import { ascribeCollection } from \"@ascribed/astro/content\";\n// import { schema } from \"../.ascribe/build/site/site/_ascribe/schema.ts\";\n// export const collections = { docs: defineCollection(ascribeCollection({ schema })) };\nimport { pathToFileURL } from \"node:url\";\nimport path from \"node:path\";\nimport { glob } from \"astro/loaders\";\nimport { siteRoot } from \"virtual:ascribe/site\";\n\n/**\n * The collection's loader and schema: the `glob` loader on the site output's\n * pages, with the generated Zod schema (`_ascribe/schema.ts`'s `schema`).\n *\n * Entry ids are Astro's own (`guides/my-setup` for `Guides/My Setup.md`, `index`\n * for the root page), which is what `AstroRouter` in `tessera-resolve`\n * computes, so a page's route is the base path plus its id, and the root page is\n * at the base path itself.\n */\nexport function ascribeCollection<S>(options: { schema: S }): {\n loader: ReturnType<typeof glob>;\n schema: S;\n} {\n // `_ascribe/` holds the schema and published files, never pages.\n const base = pathToFileURL(siteRoot + path.sep);\n return { loader: glob({ pattern: [\"**/*.md\", \"!_ascribe/**\"], base }), schema: options.schema };\n}\n"]}
package/dist/dev.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"dev.js","sourceRoot":"","sources":["../src/dev.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ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ACH,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QACzC,IAAI,CAAC,KAAK,IAAI,CAAC,OAAO,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,EAAE,CAAC;QACjD,IAAI,KAAK,EAAE,CAAC;YACV,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,KAAK,GAAG,SAAS,CAAC;YAClB,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC;QACD,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE;YACrB,IAAI,MAAM,EAAE,CAAC;gBACX,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC;gBACrB,GAAG,CAAC,GAAG,CAAC,yDAAyD,CAAC,CAAC;YACrE,CAAC;;gBAAM,IAAI,EAAE,CAAC;QAChB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,OAAO;QACL,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;YACf,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC/B,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;YACrC,OAAO,GAAG,CAAC;QACb,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { readdirSync, readFileSync, statSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { AstroIntegration } from \"astro\";\nimport { consumerMismatches, readProject, type ProjectInfo } from \"./project.js\";\n\ntype ServerOptions = Parameters<NonNullable<AstroIntegration[\"hooks\"][\"astro:server:setup\"]>>[0];\n\n/**\n * The assets a build copied from outside the content root, as absolute paths,\n * read from the site output's manifest. Watching the content root doesn't\n * cover them. A manifest that's missing or unreadable gives none: the next\n * successful build writes one.\n */\nexport function outsideAssets(project: ProjectInfo, build: string): string[] {\n const manifest = path.join(path.dirname(project.siteRoot(build)), \"site.manifest.json\");\n let files: unknown;\n try {\n files = (JSON.parse(readFileSync(manifest, \"utf8\")) as { files?: unknown }).files;\n } catch {\n return [];\n }\n if (!Array.isArray(files)) return [];\n const assets = new Set<string>();\n for (const entry of files as { kind?: unknown; source?: unknown }[]) {\n if (entry.kind !== \"asset\" || typeof entry.source !== \"string\") continue;\n const absolute = path.resolve(project.contentRoot, entry.source);\n if (!absolute.startsWith(project.contentRoot + path.sep)) assets.add(absolute);\n }\n return [...assets].sort();\n}\n\n/**\n * Each watched file's size and modification time, as last seen. A watcher\n * can report an edit late, after a build already read it: macOS delivers\n * edits made just before the dev server started some seconds after it\n * started. An event that changes neither is no edit, and rebuilding for it\n * would reload the page under the reader.\n */\nexport class SeenFiles {\n private readonly stamps = new Map<string, string>();\n\n /** Records the files under `paths` (files or folders) as they are now. */\n prime(paths: readonly string[]): void {\n for (const at of paths) {\n let entries: string[];\n try {\n entries = statSync(at).isDirectory()\n ? readdirSync(at, { recursive: true, encoding: \"utf8\" }).map((f) => path.join(at, f))\n : [at];\n } catch {\n continue;\n }\n for (const file of entries) {\n const stamp = stampOf(file);\n if (stamp !== undefined && !this.stamps.has(file)) this.stamps.set(file, stamp);\n }\n }\n }\n\n /** Whether `file` differs from when it was last seen (or wasn't seen), and records it. */\n changed(file: string): boolean {\n const stamp = stampOf(file);\n const before = this.stamps.get(file);\n if (stamp === undefined) this.stamps.delete(file);\n else this.stamps.set(file, stamp);\n return stamp === undefined || stamp !== before;\n }\n}\n\nfunction stampOf(file: string): string | undefined {\n try {\n const stat = statSync(file);\n return stat.isFile() ? `${stat.size}:${stat.mtimeMs}` : undefined;\n } catch {\n return undefined;\n }\n}\n\n/** What `watchDev` gives back. */\nexport interface DevBuilds {\n /** Runs `task` in turn with the compiler runs, never during one. */\n inTurn(task: () => Promise<void>): Promise<void>;\n}\n\n/** Watch source files, serialize compiler runs, and refresh Astro after successful output. */\nexport function watchDev(options: {\n server: ServerOptions[\"server\"];\n refreshContent: () => Promise<void>;\n logger: ServerOptions[\"logger\"];\n project: ProjectInfo;\n astro: { base: string; trailingSlash: string; site: string | undefined };\n build: string;\n rebuild: () => Promise<void>;\n /** Called after each successful rebuild, before Astro reloads the page. */\n onBuilt?: () => void;\n /** The sources as the first build read them. */\n seen?: SeenFiles;\n}): DevBuilds {\n const { server, refreshContent, logger, rebuild } = options;\n let project = options.project;\n let timer: ReturnType<typeof setTimeout> | undefined;\n let pending: Promise<void> = Promise.resolve();\n let dirty = false;\n let running = false;\n let failed = false;\n let assets = new Set<string>();\n const seen = options.seen ?? new SeenFiles();\n const watchAssets = () => {\n assets = new Set(outsideAssets(project, options.build));\n if (assets.size > 0) server.watcher.add([...assets]);\n seen.prime([...assets]);\n };\n\n const drain = async () => {\n running = true;\n const previousProject = project;\n const previousSiteRoot = previousProject.siteRoot(options.build);\n while (dirty) {\n dirty = false;\n try {\n await rebuild();\n failed = false;\n } catch (error) {\n failed = true;\n logger.error(error instanceof Error ? error.message : String(error));\n }\n }\n if (!failed) {\n options.onBuilt?.();\n try {\n const reloaded = readProject(project.dir);\n if (reloaded.siteRoot(options.build) !== previousSiteRoot) {\n throw new Error(\n \"ascribe.toml changed output-dir; restart astro dev to reload the collection.\",\n );\n }\n const mismatches = consumerMismatches(reloaded, options.astro);\n if (mismatches.length > 0) {\n throw new Error(\n `@ascribed/astro: ascribe.toml and astro.config disagree:\\n- ${mismatches.join(\"\\n- \")}`,\n );\n }\n project = reloaded;\n server.watcher.add(project.contentRoot);\n server.watcher.add(project.configPath);\n watchAssets();\n await refreshContent();\n server.ws.send({ type: \"full-reload\" });\n } catch (error) {\n failed = true;\n logger.error(\n `could not refresh Ascribe content: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n }\n running = false;\n };\n const schedule = () => {\n if (timer) clearTimeout(timer);\n timer = setTimeout(() => {\n timer = undefined;\n pending = pending.then(drain);\n }, 50);\n };\n const onChange = (event: string, file: string) => {\n if (![\"add\", \"change\", \"unlink\"].includes(event)) return;\n const absolute = path.resolve(file);\n const source =\n absolute === project.configPath ||\n assets.has(absolute) ||\n (absolute.startsWith(project.contentRoot + path.sep) &&\n !absolute.startsWith(project.outputRoot + path.sep));\n if (!source) return;\n // A late report of an edit the last build already had.\n if (event !== \"unlink\" && !seen.changed(absolute)) return;\n dirty = true;\n schedule();\n };\n server.watcher.add(project.contentRoot);\n server.watcher.add(project.configPath);\n seen.prime([project.contentRoot, project.configPath]);\n watchAssets();\n server.watcher.on(\"all\", onChange);\n server.httpServer?.once(\"close\", () => {\n if (timer) clearTimeout(timer);\n server.watcher.off(\"all\", onChange);\n });\n server.middlewares.use((_req, res, next) => {\n if (!dirty && !running && !failed) return next();\n if (timer) {\n clearTimeout(timer);\n timer = undefined;\n pending = pending.then(drain);\n }\n void pending.then(() => {\n if (failed) {\n res.statusCode = 503;\n res.end(\"Ascribe build failed; fix the source and save to retry.\");\n } else next();\n });\n });\n return {\n inTurn: (task) => {\n const run = pending.then(task);\n pending = run.catch(() => undefined);\n return run;\n },\n };\n}\n"]}
package/dist/files.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"files.js","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,sDAAsD;AACtD,4EAA4E;AAC5E,8EAA8E;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,kEAAkE;AAClE,MAAM,UAAU,YAAY,CAAC,QAAgB;IAC3C,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;AAClD,CAAC;AAED,+GAA+G;AAC/G,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,QAAgB,EAAE,MAAW;IACpE,MAAM,IAAI,GAAG,Y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AC,UAAU,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC;YAAE,OAAO,IAAI,EAAE,CAAC;QACtE,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CACb,CAAC,IAAI,EAAE,EAAE;YACP,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;gBAAE,OAAO,IAAI,EAAE,CAAC;YAClC,GAAG,CAAC,SAAS,CACX,cAAc,EACd,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC,IAAI,0BAA0B,CACtE,CAAC;YACF,GAAG,CAAC,SAAS,CAAC,gBAAgB,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YAC3C,IAAI,GAAG,CAAC,MAAM,KAAK,MAAM;gBAAE,OAAO,KAAK,GAAG,CAAC,GAAG,EAAE,CAAC;YACjD,gBAAgB,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACnC,CAAC,EACD,GAAG,EAAE,CAAC,IAAI,EAAE,CACb,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC","sourcesContent":["// Serving `_ascribe/files/`: the files pages link to that aren't pages or\n// images. Astro doesn't copy them, so the integration\n// does: into the build's output directory, and in dev through a middleware.\n// Both put them at `<base>_ascribe/files/`, the URL the site output links to.\nimport { createReadStream } from \"node:fs\";\nimport { cp, stat } from \"node:fs/promises\";\nimport type { IncomingMessage, ServerResponse } from \"node:http\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\n/** The directory of published files inside a site output root. */\nexport function publishedDir(siteRoot: string): string {\n return path.join(siteRoot, \"_ascribe\", \"files\");\n}\n\n/** Copies the published files to `<outDir>/_ascribe/files/`. Returns how many top-level entries were there. */\nexport async function copyPublishedFiles(siteRoot: string, outDir: URL): Promise<boolean> {\n const from = publishedDir(siteRoot);\n if (\n !(await stat(from).then(\n (s) => s.isDirectory(),\n () => false,\n ))\n )\n return false;\n await cp(from, path.join(fileURLToPath(outDir), \"_ascribe\", \"files\"), { recursive: true });\n return true;\n}\n\nconst TYPES: Record<string, string> = {\n \".pdf\": \"application/pdf\",\n \".zip\": \"application/zip\",\n \".json\": \"application/json\",\n \".yaml\": \"text/yaml; charset=utf-8\",\n \".yml\": \"text/yaml; charset=utf-8\",\n \".txt\": \"text/plain; charset=utf-8\",\n \".csv\": \"text/csv; charset=utf-8\",\n \".md\": \"text/markdown; charset=utf-8\",\n \".html\": \"text/html; charset=utf-8\",\n \".css\": \"text/css; charset=utf-8\",\n \".js\": \"text/javascript; charset=utf-8\",\n \".png\": \"image/png\",\n \".jpg\": \"image/jpeg\",\n \".jpeg\": \"image/jpeg\",\n \".gif\": \"image/gif\",\n \".webp\": \"image/webp\",\n \".svg\": \"image/svg+xml\",\n};\n\n/** A dev-server middleware serving the published files at `<base>_ascribe/files/`. */\nexport function filesMiddleware(\n siteRoot: string,\n base: string,\n): (req: IncomingMessage, res: ServerResponse, next: () => void) => void {\n const root = publishedDir(siteRoot);\n // Only under the base path, as in the build. Vite strips the base from\n // `req.url` before a plugin's middleware runs, but connect keeps the original in `originalUrl`.\n const prefix = `${base}_ascribe/files/`;\n return (req, res, next) => {\n const pathname =\n ((req as { originalUrl?: string }).originalUrl ?? req.url ?? \"\").split(/[?#]/, 1)[0] ?? \"\";\n if (!pathname.startsWith(prefix) || (req.method !== \"GET\" && req.method !== \"HEAD\"))\n return next();\n let relative: string;\n try {\n relative = decodeURIComponent(pathname.slice(prefix.length));\n } catch {\n return next();\n }\n const file = path.resolve(root, relative);\n if (file !== root && !file.startsWith(root + path.sep)) return next();\n stat(file).then(\n (info) => {\n if (!info.isFile()) return next();\n res.setHeader(\n \"Content-Type\",\n TYPES[path.extname(file).toLowerCase()] ?? \"application/octet-stream\",\n );\n res.setHeader(\"Content-Length\", info.size);\n if (req.method === \"HEAD\") return void res.end();\n createReadStream(file).pipe(res);\n },\n () => next(),\n );\n };\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -25,6 +25,12 @@ export interface AscribeOptions {
25
25
  * removes the app. `astro build` never has it.
26
26
  */
27
27
  review?: boolean;
28
+ /**
29
+ * Show a code block's title (`title="…"` in its info string, as `@snippet`
30
+ * writes it) above it, with a Shiki transformer that puts the block in a
31
+ * `<figure class="code-title">` with a `<figcaption>`. Default `true`.
32
+ */
33
+ codeTitles?: boolean;
28
34
  }
29
35
  /** Runs `ascribe build`, checks the site's routing, adds the markdown plugin, and serves published files. */
30
36
  export default function ascribe(options: AscribeOptions): AstroIntegration;
package/dist/index.js CHANGED
@@ -11,14 +11,18 @@
11
11
  // // src/content.config.ts
12
12
  // import { defineCollection } from "astro:content";
13
13
  // import { ascribeCollection } from "@ascribed/astro/content";
14
+ // // The generated schema. With the project outside the Astro root, import the
15
+ // // copy inside it instead: "../.astro/integrations/_ascribed_astro/schema.ts".
14
16
  // import { schema } from "../.ascribe/build/site/site/_ascribe/schema.ts";
15
17
  // export const collections = { docs: defineCollection(ascribeCollection({ schema })) };
16
18
  //
17
- // // a layout's <head>
18
- // import Elements from "@ascribed/astro/Elements.astro"; // <Elements />
19
+ // // a layout
20
+ // import Elements from "@ascribed/astro/Elements.astro"; // <Elements /> in <head>
21
+ // import Availability from "@ascribed/astro/Availability.astro"; // the page's availability
19
22
  import path from "node:path";
20
23
  import { fileURLToPath } from "node:url";
21
24
  import { findBinary } from "./binary.js";
25
+ import { codeTitles } from "./code-titles.js";
22
26
  import { SeenFiles, watchDev } from "./dev.js";
23
27
  import { copyPublishedFiles, filesMiddleware } from "./files.js";
24
28
  import { consumerMismatches, readProject } from "./project.js";
@@ -28,8 +32,9 @@ import { runDiff } from "./review/diff.js";
28
32
  import { APP_ID } from "./review/protocol.js";
29
33
  import { readRoutes } from "./review/routes.js";
30
34
  import { channelProblem, ReviewServer } from "./review/server.js";
31
- import { anchorsFor, reviewFor, runBuild } from "./run.js";
35
+ import { anchorsFor, hasWarnings, reviewFor, runBuild } from "./run.js";
32
36
  import { satteriAscribeAttributes } from "./satteri.js";
37
+ import { copySchema } from "./schema.js";
33
38
  export { default as rehypeAscribeAttributes } from "./rehype.js";
34
39
  export { satteriAscribeAttributes } from "./satteri.js";
35
40
  /** The virtual module `content.ts` reads the resolved site output root from. */
@@ -51,7 +56,7 @@ export default function ascribe(options) {
51
56
  return {
52
57
  name: "@ascribed/astro",
53
58
  hooks: {
54
- "astro:config:setup": async ({ config, command, logger, updateConfig, addDevToolbarApp }) => {
59
+ "astro:config:setup": async ({ config, command, logger, updateConfig, addDevToolbarApp, createCodegenDir, }) => {
55
60
  const root = fileURLToPath(config.root);
56
61
  const project = readProject(path.resolve(root, options.project ?? "."));
57
62
  // An unknown build is `ascribe build`'s to report: it knows the implicit `site` build.
@@ -95,6 +100,8 @@ export default function ascribe(options) {
95
100
  if (command !== "preview") {
96
101
  const found = findBinary({ binary: options.binary, root });
97
102
  binary = found;
103
+ // The schema's copy inside the Astro root, for content.config.ts to import.
104
+ const codegen = fileURLToPath(createCodegenDir());
98
105
  rebuild = async () => {
99
106
  logger.info(`running ${path.basename(found)} build for "${options.build}"`);
100
107
  const result = await runBuild({
@@ -106,10 +113,13 @@ export default function ascribe(options) {
106
113
  // While review is on, the JSON output says which page is at each route.
107
114
  outputs: review?.active ? ["site", "json"] : ["site"],
108
115
  });
109
- if (result.diagnostics !== "")
116
+ if (hasWarnings(result.diagnostics))
110
117
  logger.warn(result.diagnostics);
118
+ else if (result.diagnostics !== "")
119
+ logger.info(result.diagnostics);
111
120
  if (result.summary !== "")
112
121
  logger.info(result.summary);
122
+ copySchema(siteRoot, codegen);
113
123
  };
114
124
  // The sources as the first build reads them: the watcher may report their edits late.
115
125
  if (command === "dev")
@@ -120,6 +130,9 @@ export default function ascribe(options) {
120
130
  }
121
131
  // Dev serving of `_ascribe/files/`; the build copies them in `astro:build:done`.
122
132
  updateConfig({
133
+ ...(options.codeTitles === false
134
+ ? {}
135
+ : { markdown: { shikiConfig: { transformers: [codeTitles] } } }),
123
136
  vite: {
124
137
  // `Elements.astro` is Astro source, so Vite must compile it, not load it as a Node module.
125
138
  ssr: { noExternal: ["@ascribed/astro"] },
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,SAAS;AACT,EAAE;AACF,wBAAwB;AACxB,2CAA2C;AAC3C,kCAAkC;AAClC,oFAAoF;AACpF,kDAAkD;AAClD,QAAQ;AACR,EAAE;AACF,6BAA6B;AAC7B,sDAAsD;AACtD,iEAAiE;AACjE,6EAA6E;AAC7E,0FAA0F;AAC1F,EAAE;AACF,yBAAyB;AACzB,6EAA6E;AAC7E,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,uBAAuB,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,YAAY,EAAuB,MAAM,oBAAoB,CAAC;AACvF,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAExD,OAAO,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAA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S,CAAC,IAAI,EAAE,CAAC;wBAChE,KAAK,EAAE,OAAO,CAAC,KAAK;wBACpB,GAAG,EAAE,OAAO,CAAC,GAAG;qBACjB,CAAC,CAAC;oBACH,0DAA0D;oBAC1D,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;gBAC9D,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,MAAM,CAAC,IAAI,CACT,iFAAiF,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAC1I,CAAC;gBACJ,CAAC;YACH,CAAC;YACD,mBAAmB,EAAE,GAAG,EAAE;gBACxB,MAAM,EAAE,OAAO,EAAE,CAAC;gBAClB,MAAM,GAAG,SAAS,CAAC;gBACnB,IAAI,UAAU;oBAAE,aAAa,CAAC,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;YAC7D,CAAC;YACD,kBAAkB,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE;gBAC5C,IAAI,MAAM,kBAAkB,CAAC,QAAQ,EAAE,GAAG,CAAC;oBAAE,MAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;YACrF,CAAC;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["// @ascribed/astro: the Astro integration for Ascribe. Written against Astro\n// 7.3.5.\n//\n// // astro.config.mjs\n// import ascribe from \"@ascribed/astro\";\n// export default defineConfig({\n// base: \"/docs\", trailingSlash: \"never\", // as in ascribe.toml's [consumer]\n// integrations: [ascribe({ build: \"site\" })],\n// });\n//\n// // src/content.config.ts\n// import { defineCollection } from \"astro:content\";\n// import { ascribeCollection } from \"@ascribed/astro/content\";\n// // The generated schema. With the project outside the Astro root, import the\n// // copy inside it instead: \"../.astro/integrations/_ascribed_astro/schema.ts\".\n// import { schema } from \"../.ascribe/build/site/site/_ascribe/schema.ts\";\n// export const collections = { docs: defineCollection(ascribeCollection({ schema })) };\n//\n// // a layout\n// import Elements from \"@ascribed/astro/Elements.astro\"; // <Elements /> in <head>\n// import Availability from \"@ascribed/astro/Availability.astro\"; // the page's availability\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type { AstroIntegration } from \"astro\";\nimport { findBinary } from \"./binary.js\";\nimport { codeTitles } from \"./code-titles.js\";\nimport { SeenFiles, watchDev } from \"./dev.js\";\nimport { copyPublishedFiles, filesMiddleware } from \"./files.js\";\nimport { consumerMismatches, readProject } from \"./project.js\";\nimport rehypeAscribeAttributes from \"./rehype.js\";\nimport { removeDevFile, siteUrl, writeDevFile } from \"./review/devfile.js\";\nimport { runDiff } from \"./review/diff.js\";\nimport { APP_ID } from \"./review/protocol.js\";\nimport { readRoutes } from \"./review/routes.js\";\nimport { channelProblem, ReviewServer, type ToolbarChannel } from \"./review/server.js\";\nimport { anchorsFor, hasWarnings, reviewFor, runBuild } from \"./run.js\";\nimport { satteriAscribeAttributes } from \"./satteri.js\";\nimport { copySchema } from \"./schema.js\";\n\nexport { default as rehypeAscribeAttributes } from \"./rehype.js\";\nexport { satteriAscribeAttributes } from \"./satteri.js\";\n\n/** The virtual module `content.ts` reads the resolved site output root from. */\nconst SITE_MODULE = \"virtual:ascribe/site\";\n\n/** Options of the integration. */\nexport interface AscribeOptions {\n /** The build whose site output is the collection (a name in `ascribe.toml`). */\n build: string;\n /** The directory holding `ascribe.toml`, relative to the Astro root. Default: the root. */\n project?: string;\n /**\n * The `ascribe` binary, relative to the Astro root. Default: `ASCRIBE_BIN`, then\n * the platform binary installed with `@ascribed/cli`.\n */\n binary?: string;\n /**\n * Mark each block of the site output with the source lines it came from\n * (source anchors), for review: `\"dev\"` in `astro dev` only, `true` always.\n * Default: `false`, though `review` has them in `astro dev`.\n */\n anchors?: boolean | \"dev\";\n /**\n * Review in the site preview: an **Ascribe review** app in `astro dev`'s\n * toolbar, which marks the page's changes and shows the pull request's\n * comments, with source anchors in `astro dev`. Default `true`; `false`\n * removes the app. `astro build` never has it.\n */\n review?: boolean;\n /**\n * Show a code block's title (`title=\"…\"` in its info string, as `@snippet`\n * writes it) above it, with a Shiki transformer that puts the block in a\n * `<figure class=\"code-title\">` with a `<figcaption>`. Default `true`.\n */\n codeTitles?: boolean;\n}\n\n/** The toolbar app's icon: a speech bubble over a page. */\nconst ICON =\n '<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M6 3h8l4 4v6\"/><path d=\"M14 3v4h4\"/><path d=\"M6 3v15\"/><path d=\"M11 14h10v6h-6l-3 2v-2h-1z\"/></svg>';\n\n/** Runs `ascribe build`, checks the site's routing, adds the markdown plugin, and serves published files. */\nexport default function ascribe(options: AscribeOptions): AstroIntegration {\n let siteRoot = \"\";\n let devProject: ReturnType<typeof readProject> | undefined;\n let devConfig:\n | {\n base: string;\n trailingSlash: string;\n site: string | undefined;\n }\n | undefined;\n let rebuild: (() => Promise<void>) | undefined;\n /** The dev server's sources as its first build read them. */\n const seen = new SeenFiles();\n let binary: string | undefined;\n let reviewing = false;\n let devHttps = false;\n let review: ReviewServer | undefined;\n return {\n name: \"@ascribed/astro\",\n hooks: {\n \"astro:config:setup\": async ({\n config,\n command,\n logger,\n updateConfig,\n addDevToolbarApp,\n createCodegenDir,\n }) => {\n const root = fileURLToPath(config.root);\n const project = readProject(path.resolve(root, options.project ?? \".\"));\n // An unknown build is `ascribe build`'s to report: it knows the implicit `site` build.\n siteRoot = project.siteRoot(options.build);\n\n // `ascribe.toml`'s routing must be Astro's, or every link Ascribe writes is wrong.\n const problems = consumerMismatches(project, {\n base: config.base,\n trailingSlash: config.trailingSlash,\n site: config.site,\n });\n if (problems.length > 0) {\n throw new Error(\n `@ascribed/astro: ascribe.toml and astro.config disagree:\\n- ${problems.join(\"\\n- \")}`,\n );\n }\n\n // Where a markdown plugin goes depends on the processor Astro 7.3 runs.\n const processor = config.markdown.processor;\n const pluginLists = processor.options as {\n rehypePlugins?: unknown[];\n hastPlugins?: unknown[];\n };\n if (processor.name === \"satteri\" && pluginLists.hastPlugins !== undefined) {\n pluginLists.hastPlugins.push(satteriAscribeAttributes());\n } else if (processor.name === \"unified\" && pluginLists.rehypePlugins !== undefined) {\n pluginLists.rehypePlugins.push(rehypeAscribeAttributes);\n } else {\n throw new Error(\n `@ascribed/astro: the markdown processor \"${processor.name}\" is not one it can add its plugin to. ` +\n \"Use Astro's default (satteri) or unified(), or add `rehypeAscribeAttributes` to your own.\",\n );\n }\n\n devConfig = {\n base: config.base,\n trailingSlash: config.trailingSlash,\n site: config.site,\n };\n\n reviewing = reviewFor(options.review, command);\n if (reviewing) {\n addDevToolbarApp({\n id: APP_ID,\n name: \"Ascribe review\",\n icon: ICON,\n entrypoint: new URL(\"./toolbar/app.js\", import.meta.url),\n });\n }\n\n if (command !== \"preview\") {\n const found = findBinary({ binary: options.binary, root });\n binary = found;\n // The schema's copy inside the Astro root, for content.config.ts to import.\n const codegen = fileURLToPath(createCodegenDir());\n rebuild = async () => {\n logger.info(`running ${path.basename(found)} build for \"${options.build}\"`);\n const result = await runBuild({\n binary: found,\n configPath: project.configPath,\n build: options.build,\n cwd: project.dir,\n anchors: anchorsFor(options.anchors, command, reviewing),\n // While review is on, the JSON output says which page is at each route.\n outputs: review?.active ? [\"site\", \"json\"] : [\"site\"],\n });\n if (hasWarnings(result.diagnostics)) logger.warn(result.diagnostics);\n else if (result.diagnostics !== \"\") logger.info(result.diagnostics);\n if (result.summary !== \"\") logger.info(result.summary);\n copySchema(siteRoot, codegen);\n };\n // The sources as the first build reads them: the watcher may report their edits late.\n if (command === \"dev\") seen.prime([project.contentRoot, project.configPath]);\n await rebuild();\n if (command === \"dev\") devProject = project;\n }\n\n // Dev serving of `_ascribe/files/`; the build copies them in `astro:build:done`.\n updateConfig({\n ...(options.codeTitles === false\n ? {}\n : { markdown: { shikiConfig: { transformers: [codeTitles] } } }),\n vite: {\n // `Elements.astro` is Astro source, so Vite must compile it, not load it as a Node module.\n ssr: { noExternal: [\"@ascribed/astro\"] },\n plugins: [\n {\n name: \"@ascribed/astro:site\",\n resolveId: (id) => (id === SITE_MODULE ? `\\0${SITE_MODULE}` : undefined),\n load: (id) =>\n id === `\\0${SITE_MODULE}`\n ? `export const siteRoot = ${JSON.stringify(siteRoot)};`\n : undefined,\n },\n {\n name: \"@ascribed/astro:files\",\n configureServer(server) {\n server.middlewares.use(\n filesMiddleware(\n siteRoot,\n config.base.endsWith(\"/\") ? config.base : `${config.base}/`,\n ),\n );\n },\n },\n ],\n },\n });\n },\n \"astro:server:setup\": ({ server, refreshContent, logger, toolbar }) => {\n if (devProject && rebuild && devConfig) {\n if (!refreshContent)\n throw new Error(\"@ascribed/astro: this Astro version does not support refreshContent.\");\n const project = devProject;\n devHttps = Boolean(server.config.server.https);\n const builds = watchDev({\n server,\n seen,\n refreshContent: () => refreshContent({}),\n logger,\n project,\n astro: devConfig,\n build: options.build,\n rebuild,\n onBuilt: () => review?.rebuilt(),\n });\n if (reviewing && binary !== undefined) {\n const found = binary;\n const run = { binary: found, configPath: project.configPath, cwd: project.dir };\n const jsonRoot = path.join(path.dirname(siteRoot), \"json\");\n review = new ReviewServer({\n channel: toolbar as ToolbarChannel,\n logger,\n build: options.build,\n contentRoot: project.contentRoot,\n channelProblem: channelProblem(server.config),\n diff: (base) => runDiff({ ...run, build: options.build, base }),\n connect: async () => (await import(\"./review/github.js\")).connect(project.dir),\n writeRoutes: () =>\n builds.inTurn(async () => {\n await runBuild({ ...run, build: options.build, outputs: [\"json\"] });\n }),\n readRoutes: () => readRoutes(jsonRoot),\n });\n }\n }\n },\n \"astro:server:start\": ({ address, logger }) => {\n review?.listening(address.address);\n if (!devProject || !devConfig) return;\n const dir = devProject.dir;\n try {\n writeDevFile(dir, {\n url: siteUrl(address, { https: devHttps, base: devConfig.base }),\n build: options.build,\n pid: process.pid,\n });\n // Vite exits on a signal before `astro:server:done` runs.\n process.once(\"exit\", () => removeDevFile(dir, process.pid));\n } catch (error) {\n logger.warn(\n `couldn't write .ascribe/dev.json, which the editor's Open Site Preview reads: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n \"astro:server:done\": () => {\n review?.dispose();\n review = undefined;\n if (devProject) removeDevFile(devProject.dir, process.pid);\n },\n \"astro:build:done\": async ({ dir, logger }) => {\n if (await copyPublishedFiles(siteRoot, dir)) logger.info(\"copied _ascribe/files/\");\n },\n },\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"project.js","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,uEAAuE;AACvE,oDAAoD;AACpD,yBAAyB;AACzB,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAkBlC,kFAAkF;AAClF,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;IAClD,IAAI,KAA8B,CAAC;IACnC,IAAI,CAAC;QACH,KAAK,GAAG,KAAK,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;IAClD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,8BAA8B,UAAU,KAAK,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EACrG,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;IACJ,CAAC;IACD,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,EA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MAAM,CAAC,GAAW;IACzB,IAAI,CAAC;QACH,OAAO,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,GAAG,CAAC;IACb,CAAC;AACH,CAAC","sourcesContent":["// What the integration needs from `ascribe.toml`: where a build's site output\n// goes, and the consumer settings that must agree with `astro.config`.\n// The compiler validates the whole file; this reads\n// only what it compiled.\nimport { readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { parse } from \"smol-toml\";\n\n/** The parts of an Ascribe project the integration reads. */\nexport interface ProjectInfo {\n /** The directory holding `ascribe.toml`. */\n dir: string;\n /** The path of `ascribe.toml`. */\n configPath: string;\n /** Source files and assets watched during development. */\n contentRoot: string;\n /** Generated output, never treated as a source change. */\n outputRoot: string;\n /** `[consumer]`, with the profile's defaults. */\n consumer: { site: string | undefined; basePath: string; trailingSlash: \"always\" | \"never\" };\n /** The site output's root for a build: `<output-dir>/<build>/site`. */\n siteRoot(build: string): string;\n}\n\n/** Reads `ascribe.toml` in `dir`. Throws a readable error if it can't be read. */\nexport function readProject(dir: string): ProjectInfo {\n const configPath = path.join(dir, \"ascribe.toml\");\n let table: Record<string, unknown>;\n try {\n table = parse(readFileSync(configPath, \"utf8\"));\n } catch (error) {\n throw new Error(\n `@ascribed/astro can't read ${configPath}: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n const project = section(table, \"project\");\n const consumer = section(table, \"consumer\");\n const outputDir =\n typeof project[\"output-dir\"] === \"string\" ? project[\"output-dir\"] : \".ascribe/build\";\n const contentDir = typeof project[\"content-root\"] === \"string\" ? project[\"content-root\"] : \"docs\";\n const trailingSlash = consumer[\"trailing-slash\"] === \"never\" ? \"never\" : \"always\";\n return {\n dir,\n configPath,\n contentRoot: path.resolve(dir, contentDir),\n outputRoot: path.resolve(dir, outputDir),\n consumer: {\n site: typeof consumer[\"site\"] === \"string\" ? consumer[\"site\"] : undefined,\n basePath: normalizeBase(\n typeof consumer[\"base-path\"] === \"string\" ? consumer[\"base-path\"] : \"/\",\n ),\n trailingSlash,\n },\n siteRoot: (build) => path.resolve(dir, outputDir, build, \"site\"),\n };\n}\n\nfunction section(table: Record<string, unknown>, name: string): Record<string, unknown> {\n const value = table[name];\n return typeof value === \"object\" && value !== null && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : {};\n}\n\n/** A base path with a leading and a trailing `/`, as Ascribe's router has it. */\nexport function normalizeBase(base: string): string {\n let result = base.trim();\n if (!result.startsWith(\"/\")) result = `/${result}`;\n if (!result.endsWith(\"/\")) result += \"/\";\n return result;\n}\n\n/**\n * The ways `ascribe.toml`'s `[consumer]` disagrees with Astro's configuration,\n * as sentences. Ascribe writes every link with its own settings, so a site\n * whose routes differ would have broken links.\n */\nexport function consumerMismatches(\n project: ProjectInfo,\n astro: { base: string; trailingSlash: string; site: string | undefined },\n): string[] {\n const problems: string[] = [];\n const { basePath, trailingSlash, site } = project.consumer;\n if (normalizeBase(astro.base) !== basePath) {\n problems.push(\n `[consumer] base-path is \"${basePath}\", but Astro's \\`base\\` is \"${astro.base}\". Set them to the same path.`,\n );\n }\n // Astro's \"ignore\" serves both forms, so Ascribe's links work either way.\n if (astro.trailingSlash !== \"ignore\" && astro.trailingSlash !== trailingSlash) {\n problems.push(\n `[consumer] trailing-slash is \"${trailingSlash}\", but Astro's \\`trailingSlash\\` is \"${astro.trailingSlash}\".`,\n );\n }\n if (site !== undefined && astro.site !== undefined && origin(site) !== origin(astro.site)) {\n problems.push(`[consumer] site is \"${site}\", but Astro's \\`site\\` is \"${astro.site}\".`);\n }\n return problems;\n}\n\nfunction origin(url: string): string {\n try {\n return new URL(url).origin;\n } catch {\n return url;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"rehype.js","sourceRoot":"","sources":["../src/rehype.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,+DAA+D;AAC/D,EAAE;AACF,gFAAgF;AAChF,4EAA4E;AA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K,EAAE,CAAC,CAAC;YACnD,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;gBACxC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;gBAC5C,UAAU,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;YAC3B,CAAC;YACD,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,MAAM;gBAAE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAClD,KAAK,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;gBACxC,IAAI,KAAK,KAAK,EAAE;oBAAE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;;oBAC/B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;YAC1B,CAAC;QACH,CAAC;QACD,SAAS,CAAC,IAAgB,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,SAAS,CAAC,IAAc,EAAE,OAAsB;IACvD,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS;QAAE,OAAO;IACxC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IACrE,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ;QAAE,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AAC/D,CAAC","sourcesContent":["// The attribute marker and source anchors as a rehype plugin, for Astro's\n// `unified()` markdown processor (`@astrojs/markdown-remark`).\n//\n// Astro builds that processor as: remark-parse, remark-gfm, remark-smartypants,\n// the user's remark plugins, remark-collect-images, remark-rehype (raw HTML\n// allowed), syntax highlighting, the user's rehype plugins, `rehypeImages`,\n// `rehypeHeadingIds`, and finally `rehype-raw`. A user rehype plugin therefore\n// runs where markers are still `raw` nodes and before both of Astro's passes:\n// `rehypeImages` copies an `<img>`'s properties into the image it optimizes,\n// and `rehypeHeadingIds` keeps an id a heading already has and records it for\n// the table of contents. A rehype plugin, not a remark one, so that both of\n// Astro's processors can share `findEdits`.\n\nimport type { Root } from \"hast\";\nimport { findAnchors, findEdits, toProperty, type HastNode } from \"./attributes.js\";\n\n/** Applies the site output's attribute markers (`ascribe-attributes`) and source anchors. */\nexport default function rehypeAscribeAttributes(): (tree: Root) => void {\n return (tree) => {\n const edits = findEdits(tree as HastNode);\n const anchors = findAnchors(tree as HastNode);\n if (edits.length === 0 && anchors.length === 0) return;\n const removed = new Set<HastNode>();\n for (const anchor of anchors) {\n for (const { node, attributes } of anchor.targets) {\n const properties = (node.properties ??= {});\n for (const attribute of attributes) {\n const [name, value] = toProperty(attribute);\n properties[name] = value;\n }\n }\n if (anchor.replace) anchor.replace.node.value = anchor.replace.value;\n for (const node of anchor.remove) removed.add(node);\n }\n for (const edit of edits) {\n const properties = (edit.target.properties ??= {});\n for (const attribute of edit.attributes) {\n const [name, value] = toProperty(attribute);\n properties[name] = value;\n }\n for (const node of edit.remove) removed.add(node);\n for (const { node, value } of edit.trim) {\n if (value === \"\") removed.add(node);\n else node.value = value;\n }\n }\n dropNodes(tree as HastNode, removed);\n };\n}\n\nfunction dropNodes(node: HastNode, removed: Set<HastNode>): void {\n if (node.children === undefined) return;\n node.children = node.children.filter((child) => !removed.has(child));\n for (const child of node.children) dropNodes(child, removed);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"devfile.js","sourceRoot":"","sources":["../../src/review/devfile.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,2EAA2E;AAC3E,2EAA2E;AAC3E,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAEzE,OAAO,IAAI,MAAM,WAAW,CAAC;AAY7B,qCAAqC;AACrC,MAAM,UAAU,WA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CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,GAAG,CAAC;IAC5E,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,MAAM,IAAI,IAAI,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,EAAE,CAAC;AACpH,CAAC;AAED,8FAA8F;AAC9F,MAAM,UAAU,YAAY,CAAC,UAAkB,EAAE,IAAa;IAC5D,MAAM,MAAM,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC;IACvC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACrD,aAAa,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;AAC9D,CAAC;AAED,mDAAmD;AACnD,MAAM,UAAU,aAAa,CAAC,UAAkB,EAAE,GAAW;IAC3D,MAAM,MAAM,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC;IACvC,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAAqB,CAAC;QAC7E,IAAI,OAAO,CAAC,GAAG,KAAK,GAAG;YAAE,OAAO;IAClC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO;IACT,CAAC;IACD,MAAM,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAClC,CAAC","sourcesContent":["// `.ascribe/dev.json`: where the dev server is, for the editor's Open Site\n// Preview. Written when the server starts, removed when it stops. A server\n// that crashed leaves it behind, so a reader checks the URL answers first.\nimport { mkdirSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\nimport type { AddressInfo } from \"node:net\";\nimport path from \"node:path\";\n\n/** What `dev.json` holds. */\nexport interface DevFile {\n /** The site's address: origin and base path, `http://localhost:4321/docs/`. */\n url: string;\n /** The build the dev server shows. */\n build: string;\n /** The dev server's process, so another server's file isn't removed. */\n pid: number;\n}\n\n/** `<project>/.ascribe/dev.json`. */\nexport function devFilePath(projectDir: string): string {\n return path.join(projectDir, \".ascribe\", \"dev.json\");\n}\n\n/** The site's address from the server's: a wildcard or loopback host is `localhost`. */\nexport function siteUrl(address: AddressInfo, options: { https: boolean; base: string }): string {\n let host = address.address;\n if ([\"::\", \"0.0.0.0\", \"::1\", \"\", \"localhost\"].includes(host)) host = \"localhost\";\n else if (host.includes(\":\")) host = `[${host}]`;\n const base = options.base.endsWith(\"/\") ? options.base : `${options.base}/`;\n return `${options.https ? \"https\" : \"http\"}://${host}:${address.port}${base.startsWith(\"/\") ? base : `/${base}`}`;\n}\n\n/** Writes `dev.json`. A failure is the caller's to log: it only costs the editor its link. */\nexport function writeDevFile(projectDir: string, file: DevFile): void {\n const target = devFilePath(projectDir);\n mkdirSync(path.dirname(target), { recursive: true });\n writeFileSync(target, `${JSON.stringify(file, null, 2)}\\n`);\n}\n\n/** Removes `dev.json` if this process wrote it. */\nexport function removeDevFile(projectDir: string, pid: number): void {\n const target = devFilePath(projectDir);\n try {\n const current = JSON.parse(readFileSync(target, \"utf8\")) as Partial<DevFile>;\n if (current.pid !== pid) return;\n } catch {\n return;\n }\n rmSync(target, { force: true });\n}\n"]}