@heroiclands/package-build 24.0.1 → 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 (50) hide show
  1. package/CHANGELOG.md +14 -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 +16 -14
  8. package/docs/configuration.md +16 -0
  9. package/docs/content-format.md +4 -2
  10. package/docs/guides/writing-in-invented-scripts.md +68 -6
  11. package/docs/reference/format-details.md +143 -49
  12. package/docs/reference/note-types.md +47 -28
  13. package/docs/source-preview.md +2 -2
  14. package/engine/content-blocks.mjs +6 -2
  15. package/engine/content-format.yaml +2 -0
  16. package/engine/content-index.mjs +5 -1
  17. package/engine/content-render.mjs +2 -1
  18. package/engine/content-scripts.mjs +268 -21
  19. package/engine/content-scroll.mjs +389 -0
  20. package/engine/font-outlines.mjs +394 -0
  21. package/engine/language-data.mjs +154 -63
  22. package/engine/language-rows.mjs +32 -6
  23. package/engine/language-terms.mjs +32 -8
  24. package/engine/map-lexicon.mjs +31 -6
  25. package/engine/note-vocabulary.mjs +58 -6
  26. package/engine/pdf-fonts.mjs +1 -1
  27. package/engine/pdf-render.mjs +52 -11
  28. package/engine/run-rows.mjs +45 -3
  29. package/engine/script-direction.mjs +67 -0
  30. package/engine/script-emphasis-terms.mjs +11 -3
  31. package/engine/script-font-delivery.mjs +42 -9
  32. package/engine/script-fonts.mjs +7 -0
  33. package/engine/verse-metre.mjs +1 -0
  34. package/engine/written-in.mjs +208 -0
  35. package/package.json +1 -1
  36. package/site-theme/static/css/style.css +7 -0
  37. package/types/engine/content-scripts.d.mts +31 -6
  38. package/types/engine/content-scroll.d.mts +179 -0
  39. package/types/engine/font-outlines.d.mts +67 -0
  40. package/types/engine/language-data.d.mts +13 -0
  41. package/types/engine/language-rows.d.mts +4 -3
  42. package/types/engine/language-terms.d.mts +7 -0
  43. package/types/engine/map-lexicon.d.mts +4 -3
  44. package/types/engine/pdf-fonts.d.mts +10 -0
  45. package/types/engine/run-rows.d.mts +28 -6
  46. package/types/engine/script-direction.d.mts +10 -0
  47. package/types/engine/script-emphasis-terms.d.mts +10 -3
  48. package/types/engine/script-font-delivery.d.mts +5 -3
  49. package/types/engine/script-fonts.d.mts +9 -0
  50. package/types/engine/written-in.d.mts +76 -0
@@ -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
+ * 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
+ };