@heroiclands/package-build 24.0.0 → 24.0.2

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.
Files changed (61) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/assets/preview/gitea.ini +1 -1
  3. package/assets/styles/content-base.css +33 -0
  4. package/bin/content-commands.mjs +9 -7
  5. package/docs/api.md +6 -5
  6. package/docs/authoring/links-and-markup.md +164 -16
  7. package/docs/commands.md +23 -19
  8. package/docs/configuration.md +16 -0
  9. package/docs/content-format.md +4 -2
  10. package/docs/guides/site.md +43 -0
  11. package/docs/guides/writing-in-invented-scripts.md +68 -6
  12. package/docs/reference/format-details.md +143 -49
  13. package/docs/reference/note-types.md +47 -28
  14. package/docs/source-preview.md +2 -2
  15. package/engine/content-blocks.mjs +6 -2
  16. package/engine/content-format.yaml +2 -0
  17. package/engine/content-index.mjs +5 -1
  18. package/engine/content-render.mjs +2 -1
  19. package/engine/content-scripts.mjs +268 -21
  20. package/engine/content-scroll.mjs +389 -0
  21. package/engine/font-outlines.mjs +394 -0
  22. package/engine/language-data.mjs +154 -63
  23. package/engine/language-rows.mjs +32 -6
  24. package/engine/language-terms.mjs +32 -8
  25. package/engine/map-lexicon.mjs +31 -6
  26. package/engine/note-vocabulary.mjs +58 -6
  27. package/engine/pdf-fonts.mjs +1 -1
  28. package/engine/pdf-render.mjs +52 -11
  29. package/engine/run-rows.mjs +45 -3
  30. package/engine/script-direction.mjs +67 -0
  31. package/engine/script-emphasis-terms.mjs +11 -3
  32. package/engine/script-font-delivery.mjs +42 -9
  33. package/engine/script-fonts.mjs +7 -0
  34. package/engine/site-build.mjs +8 -1
  35. package/engine/site-reach.mjs +213 -0
  36. package/engine/site-render.mjs +120 -45
  37. package/engine/site-root.mjs +68 -26
  38. package/engine/site-serve.mjs +2 -1
  39. package/engine/site-theme.mjs +19 -6
  40. package/engine/sql-tables.mjs +9 -6
  41. package/engine/verse-metre.mjs +1 -0
  42. package/engine/written-in.mjs +208 -0
  43. package/package.json +1 -1
  44. package/site-theme/static/css/style.css +7 -0
  45. package/types/engine/content-scripts.d.mts +31 -6
  46. package/types/engine/content-scroll.d.mts +179 -0
  47. package/types/engine/font-outlines.d.mts +67 -0
  48. package/types/engine/language-data.d.mts +13 -0
  49. package/types/engine/language-rows.d.mts +4 -3
  50. package/types/engine/language-terms.d.mts +7 -0
  51. package/types/engine/map-lexicon.d.mts +4 -3
  52. package/types/engine/pdf-fonts.d.mts +10 -0
  53. package/types/engine/run-rows.d.mts +28 -6
  54. package/types/engine/script-direction.d.mts +10 -0
  55. package/types/engine/script-emphasis-terms.d.mts +10 -3
  56. package/types/engine/script-font-delivery.d.mts +5 -3
  57. package/types/engine/script-fonts.d.mts +9 -0
  58. package/types/engine/site-reach.d.mts +76 -0
  59. package/types/engine/site-render.d.mts +4 -2
  60. package/types/engine/site-root.d.mts +2 -0
  61. package/types/engine/written-in.d.mts +76 -0
@@ -0,0 +1,179 @@
1
+ /**
2
+ * Read every `scroll` fence in a source, and every fault in its opening.
3
+ *
4
+ * A fence inside a block quote or an HTML block is not read, and neither is a
5
+ * fence quoted inside another fence.
6
+ *
7
+ * @param {string} source - Markdown.
8
+ * @returns {{blocks: Scroll[], errors: Array<{line: number, column: number, message: string}>}}
9
+ * The fences, and each finding at its 1-based position.
10
+ */
11
+ export function scanScrolls(source: string): {
12
+ blocks: Scroll[];
13
+ errors: Array<{
14
+ line: number;
15
+ column: number;
16
+ message: string;
17
+ }>;
18
+ };
19
+ /**
20
+ * A scroll's paragraphs: each run of nonblank lines, its lines trimmed and
21
+ * joined by a space.
22
+ *
23
+ * @param {string[]} lines - The body's lines.
24
+ * @returns {string[]} The paragraphs, in order.
25
+ */
26
+ export function scrollParagraphs(lines: string[]): string[];
27
+ /**
28
+ * Replace each well-formed `scroll` fence with the HTML block the site, the
29
+ * preview and Foundry show: a `<div class="scroll">` holding a `<p>` for each
30
+ * paragraph, its size carried as `--scroll-rows` and `--scroll-cols`. A fence
31
+ * with a finding in its opening is left as a code fence.
32
+ *
33
+ * @param {string} source - Markdown, its marked text already rewritten.
34
+ * @returns {{markdown: string}} The Markdown.
35
+ */
36
+ export function renderScroll(source: string): {
37
+ markdown: string;
38
+ };
39
+ /**
40
+ * One character of a scroll as the book draws it.
41
+ *
42
+ * @typedef {object} ScrollCell
43
+ * @property {string} text - The character, one code point.
44
+ * @property {string} roman - The source text it was written from: the text of
45
+ * the piece of the map it begins, with the text of any piece before it that
46
+ * wrote nothing; `""` for a later character of the same piece.
47
+ * @property {"rubric"|"overline"} [emphasis] - The convention it is set by.
48
+ */
49
+ /**
50
+ * A scroll's text, as the book lays it out.
51
+ *
52
+ * @typedef {object} ScrollLayout
53
+ * @property {ScrollCell[][]} paragraphs - Each paragraph's characters.
54
+ * @property {import("./script-fonts.mjs").Face|undefined} face - The face it
55
+ * is drawn in.
56
+ */
57
+ /**
58
+ * Lay a scroll's paragraphs into columns and the columns into panels.
59
+ *
60
+ * Each paragraph starts a fresh column, filled from the top, `rows` characters
61
+ * to a column; the columns are read from the right and grouped `cols` to a
62
+ * panel. Without `rows`, a column is as long as the longest paragraph, up to
63
+ * {@link BOOK_SCROLL_ROWS}; without `cols`, each column is a panel of its own,
64
+ * so the book sets as many beside one another as fit its measure.
65
+ *
66
+ * @param {ScrollCell[][]} paragraphs - The characters of each paragraph.
67
+ * @param {{rows?: number, cols?: number}} size - The fence's size.
68
+ * @returns {{rows: number, panels: ScrollCell[][][]}} The column length, and
69
+ * each panel's columns, the first column the rightmost.
70
+ */
71
+ export function scrollPanels(paragraphs: ScrollCell[][], { rows, cols }?: {
72
+ rows?: number;
73
+ cols?: number;
74
+ }): {
75
+ rows: number;
76
+ panels: ScrollCell[][][];
77
+ };
78
+ /**
79
+ * The roman text a panel was written from, as its alt text: each paragraph's
80
+ * source text, a space between paragraphs, its spacing collapsed.
81
+ *
82
+ * @param {ScrollCell[][]} panel - The panel's columns.
83
+ * @param {ScrollCell[][]} paragraphs - The scroll's paragraphs, so a column
84
+ * that begins a paragraph is told from one that continues it.
85
+ * @returns {string} The text.
86
+ */
87
+ export function panelRoman(panel: ScrollCell[][], paragraphs: ScrollCell[][]): string;
88
+ /**
89
+ * The keys a scroll fence's attribute block takes. `lang`, `font` and `map`
90
+ * are read by `scanRuns`; `data-pagefind-ignore` is written on the site by its
91
+ * rewrite of a fence set in a face, and reaches the element as written.
92
+ */
93
+ export const SCROLL_KEYS: readonly string[];
94
+ /**
95
+ * The distance from one column to the next, in ems: the character's one em
96
+ * and a gap of half an em.
97
+ */
98
+ export const SCROLL_PITCH: 1.5;
99
+ /**
100
+ * The longest column the book sets when a fence states no `rows=`: each
101
+ * paragraph is one column as long as the longest, up to this many characters.
102
+ */
103
+ export const BOOK_SCROLL_ROWS: 40;
104
+ /** The class every scroll carries. */
105
+ export const SCROLL_CLASS: "scroll";
106
+ /**
107
+ * One `scroll` fence.
108
+ */
109
+ export type Scroll = {
110
+ /**
111
+ * - The 0-based line of its opening.
112
+ */
113
+ start: number;
114
+ /**
115
+ * - The 0-based line of its closing.
116
+ */
117
+ end: number;
118
+ /**
119
+ * - Its fence marker.
120
+ */
121
+ fence: string;
122
+ /**
123
+ * - The opening line's indentation.
124
+ */
125
+ indent: string;
126
+ /**
127
+ * - Its `key=value` attributes.
128
+ */
129
+ attributes: Record<string, string>;
130
+ /**
131
+ * - Its classes.
132
+ */
133
+ classes: string[];
134
+ /**
135
+ * - Its `rows=`, where it is valid.
136
+ */
137
+ rows: number | undefined;
138
+ /**
139
+ * - Its `cols=`, where it is valid.
140
+ */
141
+ cols: number | undefined;
142
+ /**
143
+ * - Whether its opening has a finding.
144
+ */
145
+ invalid: boolean;
146
+ };
147
+ /**
148
+ * One character of a scroll as the book draws it.
149
+ */
150
+ export type ScrollCell = {
151
+ /**
152
+ * - The character, one code point.
153
+ */
154
+ text: string;
155
+ /**
156
+ * - The source text it was written from: the text of
157
+ * the piece of the map it begins, with the text of any piece before it that
158
+ * wrote nothing; `""` for a later character of the same piece.
159
+ */
160
+ roman: string;
161
+ /**
162
+ * - The convention it is set by.
163
+ */
164
+ emphasis?: "rubric" | "overline" | undefined;
165
+ };
166
+ /**
167
+ * A scroll's text, as the book lays it out.
168
+ */
169
+ export type ScrollLayout = {
170
+ /**
171
+ * - Each paragraph's characters.
172
+ */
173
+ paragraphs: ScrollCell[][];
174
+ /**
175
+ * - The face it
176
+ * is drawn in.
177
+ */
178
+ face: import("./script-fonts.mjs").Face | undefined;
179
+ };
@@ -0,0 +1,67 @@
1
+ /**
2
+ * The outlines of a TrueType face, read once per file.
3
+ *
4
+ * @param {string} file - The `.ttf`.
5
+ * @returns {Outlines} Its outlines.
6
+ * @throws {Error} When the file is not a TrueType face with outlines.
7
+ */
8
+ export function fontOutlines(file: string): Outlines;
9
+ /**
10
+ * One panel of a scroll as SVG: its columns read from the right, `rows` ems
11
+ * tall, each character centred in its column, in red where it is set in the
12
+ * rubric and with a line beside it, on the right, where it is overlined.
13
+ *
14
+ * @param {import("./content-scroll.mjs").ScrollCell[][]} panel - Its columns,
15
+ * the first the rightmost.
16
+ * @param {number} rows - The characters in a column.
17
+ * @param {Outlines} outlines - The face.
18
+ * @returns {string} The SVG.
19
+ */
20
+ export function scrollPanelSvg(panel: import("./content-scroll.mjs").ScrollCell[][], rows: number, outlines: Outlines): string;
21
+ /** The book's rubric red, which its preamble names `book-rubric`. */
22
+ export const BOOK_RUBRIC: "#9c281b";
23
+ /** The book's ink, which its preamble names `book-ink`. */
24
+ export const BOOK_INK: "#241f1a";
25
+ /**
26
+ * A point of a contour.
27
+ */
28
+ export type Point = {
29
+ x: number;
30
+ y: number;
31
+ on: boolean;
32
+ };
33
+ /**
34
+ * One glyph, in font units, its y axis pointing down from the baseline.
35
+ */
36
+ export type Glyph = {
37
+ /**
38
+ * - Its glyph index.
39
+ */
40
+ index: number;
41
+ /**
42
+ * - Its outline as SVG path data; `""` for none.
43
+ */
44
+ d: string;
45
+ /**
46
+ * - Its horizontal advance.
47
+ */
48
+ advance: number;
49
+ /**
50
+ * - From the top of its cell to its baseline.
51
+ */
52
+ top: number;
53
+ };
54
+ /**
55
+ * A face's outlines.
56
+ */
57
+ export type Outlines = {
58
+ /**
59
+ * - Its units per em.
60
+ */
61
+ unitsPerEm: number;
62
+ /**
63
+ * - The glyph a code
64
+ * point is drawn with, or `undefined` when the face does not draw it.
65
+ */
66
+ glyph: (point: number) => Glyph | undefined;
67
+ };
@@ -6,6 +6,19 @@
6
6
  * @returns {boolean}
7
7
  */
8
8
  export function tongueDeclared(tag: string, declared: Set<string>): boolean;
9
+ /**
10
+ * Check a `doc` note's `data.sounds`, a spelling guide's letters and marks:
11
+ * each letter row's `tongue` names language notes. The data-key check owns
12
+ * the keys, so a sound rule a guide does not state is refused there.
13
+ *
14
+ * @param {object} note - A `doc` note: `file`, `raw` and parsed `fm`.
15
+ * @param {object} [context]
16
+ * @param {object} [context.index] - The index, for whether an Address resolves.
17
+ * @returns {object[]} The findings.
18
+ */
19
+ export function checkGuideSounds(note: object, { index }?: {
20
+ index?: object | undefined;
21
+ }): object[];
9
22
  /**
10
23
  * Check a `skill` note's language data against what it means.
11
24
  *
@@ -42,8 +42,8 @@ export function tongueRows(records: Iterable<Record<string, any>>): object[];
42
42
  */
43
43
  export function scopeRows(records: Iterable<Record<string, any>>): object[];
44
44
  /**
45
- * The `letters` rows: one per `data.sounds.letters` entry, `letters` and
46
- * `tongue` lists.
45
+ * The `letters` rows: one per `data.sounds.letters` entry of a language note
46
+ * or a spelling guide, `letters` and `tongue` lists.
47
47
  *
48
48
  * @param {Iterable<Record<string, any>>} records - Index records.
49
49
  * @returns {object[]}
@@ -207,7 +207,8 @@ export function joiningRows(records: Iterable<Record<string, any>>): object[];
207
207
  */
208
208
  export function joinRows(records: Iterable<Record<string, any>>): object[];
209
209
  /**
210
- * The `marks` rows: one per `data.sounds.marks` entry.
210
+ * The `marks` rows: one per `data.sounds.marks` entry of a language note or a
211
+ * spelling guide.
211
212
  *
212
213
  * @param {Iterable<Record<string, any>>} records - Index records.
213
214
  * @returns {object[]}
@@ -233,6 +233,13 @@ export const MUTATION_FIELDS: readonly import("./data-keys.mjs").InnerKeySpec[];
233
233
  * @type {readonly import("./data-keys.mjs").InnerKeySpec[]}
234
234
  */
235
235
  export const SOUND_FIELDS: readonly import("./data-keys.mjs").InnerKeySpec[];
236
+ /**
237
+ * The keys of a spelling guide's `data.sounds`: a `doc` note stating the
238
+ * letters and marks every tongue of a setting is written by.
239
+ *
240
+ * @type {readonly import("./data-keys.mjs").InnerKeySpec[]}
241
+ */
242
+ export const GUIDE_SOUND_FIELDS: readonly import("./data-keys.mjs").InnerKeySpec[];
236
243
  /**
237
244
  * The keys of one `data.soundChanges` entry.
238
245
  *
@@ -151,14 +151,15 @@ export function transliterate(ctx: object, keys: {
151
151
  * writing, the signs a run writes directly for that sense.
152
152
  *
153
153
  * @param {object} ctx - The run context.
154
- * @param {{lang: string, map: string, font?: string, derived?: boolean}} keys -
155
- * The language, the map, the face, and whether to list derived forms.
154
+ * @param {{lang: string, map?: string, font?: string, derived?: boolean}} keys -
155
+ * The language, the map, the face, and whether to list derived forms. A map
156
+ * or a face left out is the one the language's `data.writtenIn` names.
156
157
  * @returns {{entries: Array<{form: string, native: string, exception?: boolean, source?: "own"|"parts"|"none", ambiguous?: true, class: string|null, gloss: string|null, from?: string}>}|{problem: string, about: string}}
157
158
  * The words in `data.words` order, then any derived forms, or the problem.
158
159
  */
159
160
  export function lexiconEntries(ctx: object, { lang, map, font, derived }: {
160
161
  lang: string;
161
- map: string;
162
+ map?: string;
162
163
  font?: string;
163
164
  derived?: boolean;
164
165
  }): {
@@ -1,3 +1,13 @@
1
+ /**
2
+ * The tables an sfnt file holds, by tag.
3
+ *
4
+ * @param {Buffer} buf - The font file.
5
+ * @returns {Map<string, {offset: number, length: number}>} Its table directory.
6
+ */
7
+ export function tableDirectory(buf: Buffer): Map<string, {
8
+ offset: number;
9
+ length: number;
10
+ }>;
1
11
  /**
2
12
  * Every glyph name a font carries, with the codepoint that reaches it.
3
13
  *
@@ -2,12 +2,14 @@
2
2
  * One run as an index record carries it.
3
3
  *
4
4
  * @typedef {object} RecordRun
5
- * @property {"span"|"block"|"verse"} kind - The construct.
5
+ * @property {"span"|"block"|"verse"|"scroll"} kind - The construct.
6
6
  * @property {string|null} lang - The language it is set in, as written: its
7
7
  * own `lang=`, else the one the div or fence around it states.
8
8
  * @property {string|null} tag - The BCP 47 tag it resolves to, or null.
9
- * @property {string|null} font - Its font, as written and inherited the same way.
10
- * @property {string|null} map - Its map, as written and inherited the same way.
9
+ * @property {string|null} font - Its font, as written and inherited the same
10
+ * way, else its language's script's.
11
+ * @property {string|null} map - Its map, as written and inherited the same way,
12
+ * else its language's script's.
11
13
  * @property {number} line - 1-based file line of its opening.
12
14
  * @property {number} column - 1-based UTF-16 file column of its opening.
13
15
  */
@@ -33,6 +35,24 @@ export function recordRuns(body: string, { context, bodyLine, bodyColumn, syntax
33
35
  bodyColumn?: number | undefined;
34
36
  syntax?: import("./content-session.mjs").ContentSyntax | undefined;
35
37
  }): RecordRun[];
38
+ /**
39
+ * Give every recorded run the map and face its language's note names in
40
+ * `data.writtenIn`, where the run leaves them unstated, as a run is set. Read
41
+ * once every record exists, since a run's language note may be recorded after
42
+ * the note that marks it.
43
+ *
44
+ * @param {Record<string, any>[]} records - The package's index records; each
45
+ * note record's `runs` is updated in place.
46
+ * @param {{languages?: Readonly<Record<string, {tag: string, note?: string}>>, contentPackage?: string}} config -
47
+ * The configured languages, whose `note` names each language note.
48
+ */
49
+ export function fillWrittenIn(records: Record<string, any>[], config: {
50
+ languages?: Readonly<Record<string, {
51
+ tag: string;
52
+ note?: string;
53
+ }>>;
54
+ contentPackage?: string;
55
+ }): void;
36
56
  /**
37
57
  * The containing page's NOTE identity.
38
58
  *
@@ -57,7 +77,7 @@ export type RecordRun = {
57
77
  /**
58
78
  * - The construct.
59
79
  */
60
- kind: "span" | "block" | "verse";
80
+ kind: "span" | "block" | "verse" | "scroll";
61
81
  /**
62
82
  * - The language it is set in, as written: its
63
83
  * own `lang=`, else the one the div or fence around it states.
@@ -68,11 +88,13 @@ export type RecordRun = {
68
88
  */
69
89
  tag: string | null;
70
90
  /**
71
- * - Its font, as written and inherited the same way.
91
+ * - Its font, as written and inherited the same
92
+ * way, else its language's script's.
72
93
  */
73
94
  font: string | null;
74
95
  /**
75
- * - Its map, as written and inherited the same way.
96
+ * - Its map, as written and inherited the same way,
97
+ * else its language's script's.
76
98
  */
77
99
  map: string | null;
78
100
  /**
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Each face's direction, from the script notes among the index records. The
3
+ * first note to list a face keeps it; a face whose note states no direction,
4
+ * or one the build does not know, is absent.
5
+ *
6
+ * @param {Iterable<Record<string, any>>|undefined} records - Index records.
7
+ * @returns {Map<string, "vertical-rl">} The directions, by face slug.
8
+ */
9
+ export function directionsFromRecords(records: Iterable<Record<string, any>> | undefined): Map<string, "vertical-rl">;
10
+ export { SCRIPT_DIRECTIONS } from "./script-emphasis-terms.mjs";
@@ -1,7 +1,8 @@
1
1
  /**
2
- * **The words a script note and a language note state emphasis by.** Read by
3
- * the vocabulary as it is declared, so this module imports nothing; the
4
- * checks and the conventions' use are in {@link module:engine/script-emphasis}.
2
+ * **The words a script note and a language note state emphasis and direction
3
+ * by.** Read by the vocabulary as it is declared, so this module imports
4
+ * nothing; the checks and the conventions' use are in
5
+ * {@link module:engine/script-emphasis} and {@link module:engine/script-direction}.
5
6
  *
6
7
  * @module
7
8
  */
@@ -17,5 +18,11 @@ export const EMPHASIS_CLASSES: Readonly<{
17
18
  * `words` marks emphasis with a word, so a mark in its text is a finding.
18
19
  */
19
20
  export const LANGUAGE_EMPHASES: readonly string[];
21
+ /**
22
+ * The directions a script states it is written in. `vertical-rl` is columns,
23
+ * top to bottom, read from the right; a script stating none is written in
24
+ * lines.
25
+ */
26
+ export const SCRIPT_DIRECTIONS: readonly string[];
20
27
  /** The `subType` of a script note. */
21
28
  export const SCRIPT_SUBTYPE: "script";
@@ -1,7 +1,9 @@
1
1
  /**
2
- * The faces the package's notes set text in with `font=`, read from the
3
- * notes themselves: every Markdown file under the content tree that writes
4
- * `font=` is scanned for its runs.
2
+ * The faces the package's notes set text in, read from the notes
3
+ * themselves: every Markdown file under the content tree that writes `font=`
4
+ * is scanned for its runs, and the face every language note names in
5
+ * `data.writtenIn` counts, since a run marked with the language alone is set
6
+ * in it.
5
7
  *
6
8
  * @param {DeliveryConfig} config - The resolved configuration.
7
9
  * @param {import("./script-fonts.mjs").ScriptFonts} installed - The fonts package.
@@ -28,6 +28,9 @@
28
28
  * @property {string} direction - `ltr` or `rtl`.
29
29
  * @property {string[]} features - OpenType features it turns on.
30
30
  * @property {ReadonlySet<number>} draws - Every code point it draws.
31
+ * @property {string|undefined} file - The absolute path of its TrueType file,
32
+ * which the book draws a `scroll` fence's outlines from; `undefined` when the
33
+ * manifest lists none.
31
34
  */
32
35
  /**
33
36
  * The installed fonts package, as a consumer sees it.
@@ -140,6 +143,12 @@ export type Face = {
140
143
  * - Every code point it draws.
141
144
  */
142
145
  draws: ReadonlySet<number>;
146
+ /**
147
+ * - The absolute path of its TrueType file,
148
+ * which the book draws a `scroll` fence's outlines from; `undefined` when the
149
+ * manifest lists none.
150
+ */
151
+ file: string | undefined;
143
152
  };
144
153
  /**
145
154
  * The installed fonts package, as a consumer sees it.
@@ -0,0 +1,76 @@
1
+ /**
2
+ * The internal targets a page links.
3
+ *
4
+ * @param {string} html - A rendered page.
5
+ * @param {string} from - The page's own address, beginning with `/`.
6
+ * @param {string} base - The site's base path, beginning and ending with `/`.
7
+ * @returns {string[]} Absolute paths inside the base, without fragment or query.
8
+ */
9
+ export function internalLinks(html: string, from: string, base: string): string[];
10
+ /**
11
+ * The address a link to a file names a page by: `…/index.html` is its
12
+ * directory, and a bare directory ends in a slash.
13
+ *
14
+ * @param {string} pathname - An absolute path.
15
+ * @returns {string} The page address it would be keyed by.
16
+ */
17
+ export function pageAddress(pathname: string): string;
18
+ /**
19
+ * The pages reachable from the homepage.
20
+ *
21
+ * @param {object} options - The inputs.
22
+ * @param {string} options.base - The site's base path, beginning and ending
23
+ * with `/`; the homepage is at the base.
24
+ * @param {(url: string) => string|undefined} options.html - A page's rendered
25
+ * HTML by its address, or `undefined` where the site has no such page.
26
+ * @param {(pathname: string) => readonly string[]} [options.expand] - The page
27
+ * addresses a linked non-page file, such as a feed, lists.
28
+ * @returns {Set<string>} The address of every reachable page, the homepage
29
+ * included.
30
+ */
31
+ export function reachablePages({ base, html, expand }: {
32
+ base: string;
33
+ html: (url: string) => string | undefined;
34
+ expand?: ((pathname: string) => readonly string[]) | undefined;
35
+ }): Set<string>;
36
+ /**
37
+ * The page addresses an Atom feed lists, as paths.
38
+ *
39
+ * @param {string} xml - The feed.
40
+ * @returns {string[]} The `href` of every `<link>` that is an absolute URL,
41
+ * as its path.
42
+ */
43
+ export function feedPaths(xml: string): string[];
44
+ /**
45
+ * A page body split at {@link GENERATED_MARK}.
46
+ *
47
+ * @param {string} html - A page body.
48
+ * @returns {{authored: string, generated: string}} The author's text, and the
49
+ * generated sections after it, `""` where there are none.
50
+ */
51
+ export function splitContent(html: string): {
52
+ authored: string;
53
+ generated: string;
54
+ };
55
+ /**
56
+ * Generated sections with the entries that lead outside a set of pages taken
57
+ * out.
58
+ *
59
+ * An entry is a list item, a table row, or a link in a paragraph's comma
60
+ * separated run; a paragraph, list or table left with no entry goes, and so
61
+ * does a section left with nothing under its heading. A link to anything that
62
+ * is not a page of the site is kept, and so is text that was never a link.
63
+ *
64
+ * @param {string} html - The generated sections, rendered.
65
+ * @param {(href: string) => boolean} outside - Whether an `href` names a page
66
+ * of the site that is not reachable.
67
+ * @returns {string} The sections, or `""` when nothing is left.
68
+ */
69
+ export function pruneGenerated(html: string, outside: (href: string) => boolean): string;
70
+ /**
71
+ * The comment that separates a page's authored text from the sections the
72
+ * build generated after it, in the HTML the renderer writes.
73
+ *
74
+ * @type {string}
75
+ */
76
+ export const GENERATED_MARK: string;
@@ -50,8 +50,9 @@ export function writeThemeFiles(out: string, staticDir?: string): string[];
50
50
  * @param {string} [options.staticDir] - The theme's own files, copied first.
51
51
  * @param {ReadonlySet<string>} [options.only] - The addresses of the pages to
52
52
  * draw again into a site already written. Nothing else is touched.
53
- * @returns {{files: string[], pages: string[], findings: object[]}} Every file
54
- * written, the address of every page, and the layouts' findings.
53
+ * @returns {{files: string[], pages: string[], reachable: string[],
54
+ * findings: object[]}} Every file written, the address of every page, the
55
+ * address of each page reachable from the homepage, and the layouts' findings.
55
56
  * @throws {Error} When a page's address is outside the site, or a site served
56
57
  * under a path asks for a sitemap index.
57
58
  */
@@ -65,6 +66,7 @@ export function writeSite({ site, pages, out, report, staticDir, only }: {
65
66
  }): {
66
67
  files: string[];
67
68
  pages: string[];
69
+ reachable: string[];
68
70
  findings: object[];
69
71
  };
70
72
  /**
@@ -42,6 +42,7 @@ export function headers({ pkg, base, fonts }?: {
42
42
  export function indexSite(where: {
43
43
  site: string;
44
44
  output: string;
45
+ base?: string;
45
46
  }): Promise<{
46
47
  pages: number;
47
48
  }>;
@@ -125,6 +126,7 @@ export const ORIGIN_SUFFIX: string;
125
126
  export type SiteIndexer = (where: {
126
127
  site: string;
127
128
  output: string;
129
+ base?: string;
128
130
  }) => Promise<{
129
131
  pages: number;
130
132
  }>;
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Whether a map is drawn in a face: it lists the face, or lists none.
3
+ *
4
+ * @param {import("./text-maps.mjs").TextMap} map - The map.
5
+ * @param {string} font - The face's slug.
6
+ * @returns {boolean} Whether the map may set text in it.
7
+ */
8
+ export function drawnIn(map: import("./text-maps.mjs").TextMap, font: string): boolean;
9
+ /**
10
+ * The script each configured language's note names, where the map is known
11
+ * and is drawn in the face. A default that names an unknown map or a face its
12
+ * map is not drawn in is the note's finding, and fills no run.
13
+ *
14
+ * @param {ReadonlyMap<string, Record<string, any>>} byName - Each configured
15
+ * language's note record, by language name, from
16
+ * {@link module:engine/map-lexicon.languageRecordsByName}.
17
+ * @param {ReadonlyMap<string, import("./text-maps.mjs").TextMap>} maps - The
18
+ * maps by name.
19
+ * @returns {Map<string, WrittenIn>} The scripts, by language name.
20
+ */
21
+ export function writtenInOf(byName: ReadonlyMap<string, Record<string, any>>, maps: ReadonlyMap<string, import("./text-maps.mjs").TextMap>): Map<string, WrittenIn>;
22
+ /**
23
+ * The keys a run takes from its language's script: each of `map` and `font`
24
+ * the run does not state, where it agrees with the one the run does.
25
+ *
26
+ * @param {{lang?: string, map?: string, font?: string}} keys - The run's keys,
27
+ * its own and those it inherits.
28
+ * @param {ReadonlyMap<string, WrittenIn>|undefined} scripts - Each language's
29
+ * script, from {@link writtenInOf}.
30
+ * @param {ReadonlyMap<string, import("./text-maps.mjs").TextMap>|undefined} maps -
31
+ * The maps by name.
32
+ * @returns {{map?: string, font?: string}} What the run takes; empty when it
33
+ * takes nothing.
34
+ */
35
+ export function fromWrittenIn(keys: {
36
+ lang?: string;
37
+ map?: string;
38
+ font?: string;
39
+ }, scripts: ReadonlyMap<string, WrittenIn> | undefined, maps: ReadonlyMap<string, import("./text-maps.mjs").TextMap> | undefined): {
40
+ map?: string;
41
+ font?: string;
42
+ };
43
+ /**
44
+ * Check a note's `data.writtenIn`: that the note is a language, that `map`
45
+ * names a map a mapping note declares, and that the map is drawn in `font`.
46
+ * The data-key check owns the keys and their kinds.
47
+ *
48
+ * @param {{file: string, raw?: string, fm?: Record<string, any>}} note - The note.
49
+ * @param {{index?: {notes?: Iterable<object>}}} [context] - The lint index;
50
+ * without one, only the note's `subType` is checked.
51
+ * @returns {object[]} The findings, each at its key or value.
52
+ */
53
+ export function checkWrittenIn(note: {
54
+ file: string;
55
+ raw?: string;
56
+ fm?: Record<string, any>;
57
+ }, { index }?: {
58
+ index?: {
59
+ notes?: Iterable<object>;
60
+ };
61
+ }): object[];
62
+ /** The `data` key a language note names its script in. */
63
+ export const WRITTEN_IN_KEY: "writtenIn";
64
+ /**
65
+ * A language's script.
66
+ */
67
+ export type WrittenIn = {
68
+ /**
69
+ * - The `data.map.name` of the mapping note.
70
+ */
71
+ map: string;
72
+ /**
73
+ * - The slug of the face, one the map is drawn in.
74
+ */
75
+ font: string;
76
+ };