@heroiclands/package-build 25.0.0 → 25.1.1

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 (105) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +1 -0
  3. package/bin/content-commands.mjs +30 -96
  4. package/bin/encoding-commands.mjs +146 -0
  5. package/bin/package-build.mjs +35 -24
  6. package/config.mjs +25 -0
  7. package/convert.mjs +182 -0
  8. package/docs/api.md +144 -6
  9. package/docs/authoring/links-and-markup.md +260 -481
  10. package/docs/commands.md +110 -119
  11. package/docs/configuration.md +31 -13
  12. package/docs/content-format.md +11 -4
  13. package/docs/diagnostics.md +43 -16
  14. package/docs/encoding-core.md +193 -0
  15. package/docs/guides/book.md +2 -2
  16. package/docs/guides/module-project.md +23 -1
  17. package/docs/guides/site.md +2 -2
  18. package/docs/guides/writing-in-invented-scripts.md +458 -575
  19. package/docs/reference/format-details.md +292 -404
  20. package/docs/reference/note-types.md +83 -63
  21. package/docs/source-preview.md +8 -0
  22. package/e2e.mjs +1 -1
  23. package/engine/base-compiler.mjs +27 -9
  24. package/engine/content-charset.mjs +13 -1
  25. package/engine/content-format.yaml +6 -2
  26. package/engine/content-index.mjs +6 -2
  27. package/engine/content-links.mjs +1 -0
  28. package/engine/content-scripts.mjs +614 -459
  29. package/engine/content-scroll.mjs +4 -4
  30. package/engine/content-spans.mjs +40 -9
  31. package/engine/content-verse.mjs +1 -1
  32. package/engine/converter-data.mjs +70 -0
  33. package/engine/dictionary-rows.mjs +2 -34
  34. package/engine/encoding-integrity.mjs +94 -0
  35. package/engine/encoding-language.mjs +506 -0
  36. package/engine/encoding-lexicon.mjs +701 -0
  37. package/engine/encoding-notes.mjs +186 -0
  38. package/engine/encoding-standard.mjs +42 -0
  39. package/engine/encoding-template.mjs +370 -0
  40. package/engine/encoding-terms.mjs +178 -0
  41. package/engine/encoding.mjs +952 -0
  42. package/engine/extension-attributes.mjs +2 -0
  43. package/engine/helpers.mjs +1 -1
  44. package/engine/index.mjs +7 -0
  45. package/engine/language-terms.mjs +17 -16
  46. package/engine/{logographic.mjs → language-writings.mjs} +29 -38
  47. package/engine/markup-validation.mjs +1 -1
  48. package/engine/note-vocabulary.mjs +4 -158
  49. package/engine/pdf-render.mjs +31 -3
  50. package/engine/roman-characters.mjs +135 -16
  51. package/engine/roman-run.mjs +149 -0
  52. package/engine/roman-verse.mjs +95 -0
  53. package/engine/run-rows.mjs +29 -31
  54. package/engine/run-words.mjs +2 -2
  55. package/engine/script-emphasis-terms.mjs +3 -0
  56. package/engine/script-emphasis.mjs +3 -10
  57. package/engine/script-font-delivery.mjs +9 -12
  58. package/engine/script-fonts.mjs +2 -1
  59. package/engine/site-build.mjs +14 -5
  60. package/engine/site-preview.mjs +12 -2
  61. package/engine/sql-tables.mjs +36 -31
  62. package/engine/verse-metre.mjs +1 -1
  63. package/engine/word-forms.mjs +1 -1
  64. package/engine/word-inflections.mjs +48 -0
  65. package/engine/word-rows.mjs +1 -1
  66. package/engine/word-terms.mjs +16 -17
  67. package/package.json +11 -5
  68. package/types/config.d.mts +5 -0
  69. package/types/convert.d.mts +44 -0
  70. package/types/e2e.d.mts +1 -1
  71. package/types/engine/base-compiler.d.mts +4 -2
  72. package/types/engine/content-index.d.mts +4 -1
  73. package/types/engine/content-scripts.d.mts +103 -42
  74. package/types/engine/converter-data.d.mts +11 -0
  75. package/types/engine/dictionary-rows.d.mts +1 -25
  76. package/types/engine/encoding-integrity.d.mts +14 -0
  77. package/types/engine/encoding-language.d.mts +36 -0
  78. package/types/engine/encoding-lexicon.d.mts +259 -0
  79. package/types/engine/encoding-notes.d.mts +39 -0
  80. package/types/engine/encoding-standard.d.mts +11 -0
  81. package/types/engine/encoding-template.d.mts +44 -0
  82. package/types/engine/encoding-terms.d.mts +143 -0
  83. package/types/engine/encoding.d.mts +155 -0
  84. package/types/engine/helpers.d.mts +1 -1
  85. package/types/engine/index.d.mts +4 -0
  86. package/types/engine/language-terms.d.mts +1 -1
  87. package/types/engine/{logographic.d.mts → language-writings.d.mts} +6 -6
  88. package/types/engine/markup-validation.d.mts +1 -1
  89. package/types/engine/pdf-render.d.mts +1 -1
  90. package/types/engine/roman-characters.d.mts +2 -2
  91. package/types/engine/roman-run.d.mts +101 -0
  92. package/types/engine/roman-verse.d.mts +23 -0
  93. package/types/engine/run-rows.d.mts +13 -20
  94. package/types/engine/script-emphasis-terms.d.mts +2 -0
  95. package/types/engine/script-emphasis.d.mts +1 -1
  96. package/types/engine/script-font-delivery.d.mts +2 -3
  97. package/types/engine/script-fonts.d.mts +5 -0
  98. package/types/engine/site-preview.d.mts +1 -1
  99. package/types/engine/word-inflections.d.mts +25 -0
  100. package/engine/map-lexicon.mjs +0 -1045
  101. package/engine/text-maps.mjs +0 -654
  102. package/engine/written-in.mjs +0 -204
  103. package/types/engine/map-lexicon.d.mts +0 -330
  104. package/types/engine/text-maps.d.mts +0 -189
  105. package/types/engine/written-in.d.mts +0 -76
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Validate note data and resolve its code references without reading files.
3
+ * @param {any} data - Encoding-note data, excluding ordinary document metadata.
4
+ * @param {{codes?: Record<string,string>, name?: string}} options - Selected font codes and document identity.
5
+ * @param {(key:string,message:string)=>never} fault - Schema-error constructor supplied by the engine.
6
+ */
7
+ export function templateProgram(data: any, options: {
8
+ codes?: Record<string, string>;
9
+ name?: string;
10
+ }, fault: (key: string, message: string) => never): {
11
+ definition: {
12
+ groupCase?: string | undefined;
13
+ name: string;
14
+ fonts: any[];
15
+ accepts: any[];
16
+ separator: string;
17
+ roundTrip: string;
18
+ vowels: any;
19
+ rows: Readonly<unknown>[];
20
+ codes: [string, string][];
21
+ controls: Readonly<{
22
+ verseStanza: "󠄍";
23
+ verseCanto: "󠄎";
24
+ wordSeparator: " ";
25
+ literalOpen: "󠄒";
26
+ literalClose: "󠄓";
27
+ literalEscape: "󠄕";
28
+ }>;
29
+ };
30
+ rowKeys: string[];
31
+ metadata: {
32
+ name: string;
33
+ language: any;
34
+ font: any;
35
+ template: Readonly<{
36
+ normalization: "NFC";
37
+ vowelGroups: any;
38
+ maxVowelGroup: number;
39
+ stress: "󠄔" | undefined;
40
+ diaeresis: boolean;
41
+ grave: boolean;
42
+ }>;
43
+ };
44
+ };
@@ -0,0 +1,143 @@
1
+ /** Closed nested keys, also documented by the generated note reference. */
2
+ export const ENCODING_RULE_FIELDS: readonly ({
3
+ allowed?: string[] | undefined;
4
+ kind: string;
5
+ shape: string;
6
+ name: any;
7
+ describe: any;
8
+ required: boolean;
9
+ } | {
10
+ name: any;
11
+ kind: string;
12
+ shape: string;
13
+ describe: any;
14
+ fields: any;
15
+ } | {
16
+ name: string;
17
+ kind: string;
18
+ shape: string;
19
+ entries: {
20
+ kind: string;
21
+ shape: string;
22
+ describe: string;
23
+ fields?: undefined;
24
+ };
25
+ describe: string;
26
+ } | {
27
+ name: string;
28
+ kind: string;
29
+ shape: string;
30
+ describe: string;
31
+ entries: {
32
+ kind: string;
33
+ shape: string;
34
+ fields: ({
35
+ name: any;
36
+ kind: string;
37
+ shape: string;
38
+ describe: any;
39
+ required: boolean;
40
+ } | {
41
+ allowed: string[];
42
+ name: any;
43
+ kind: string;
44
+ shape: string;
45
+ describe: any;
46
+ required: boolean;
47
+ })[];
48
+ describe?: undefined;
49
+ };
50
+ })[];
51
+ /** The additional data keys a document may use to define its encoding. */
52
+ export const ENCODING_NOTE_FIELDS: readonly ({
53
+ name: any;
54
+ kind: string;
55
+ shape: string;
56
+ describe: any;
57
+ required: boolean;
58
+ } | {
59
+ name: string;
60
+ kind: string;
61
+ shape: string;
62
+ entries: {
63
+ kind: string;
64
+ shape: string;
65
+ describe: string;
66
+ };
67
+ describe: string;
68
+ values?: undefined;
69
+ fields?: undefined;
70
+ } | {
71
+ name: string;
72
+ kind: string;
73
+ shape: string;
74
+ values: {
75
+ describe: string;
76
+ kind: string;
77
+ shape: string;
78
+ entries: {
79
+ kind: string;
80
+ shape: string;
81
+ describe: string;
82
+ };
83
+ };
84
+ describe: string;
85
+ entries?: undefined;
86
+ fields?: undefined;
87
+ } | {
88
+ name: string;
89
+ kind: string;
90
+ shape: string;
91
+ fields: readonly ({
92
+ allowed?: string[] | undefined;
93
+ kind: string;
94
+ shape: string;
95
+ name: any;
96
+ describe: any;
97
+ required: boolean;
98
+ } | {
99
+ name: any;
100
+ kind: string;
101
+ shape: string;
102
+ describe: any;
103
+ fields: any;
104
+ } | {
105
+ name: string;
106
+ kind: string;
107
+ shape: string;
108
+ entries: {
109
+ kind: string;
110
+ shape: string;
111
+ describe: string;
112
+ fields?: undefined;
113
+ };
114
+ describe: string;
115
+ } | {
116
+ name: string;
117
+ kind: string;
118
+ shape: string;
119
+ describe: string;
120
+ entries: {
121
+ kind: string;
122
+ shape: string;
123
+ fields: ({
124
+ name: any;
125
+ kind: string;
126
+ shape: string;
127
+ describe: any;
128
+ required: boolean;
129
+ } | {
130
+ allowed: string[];
131
+ name: any;
132
+ kind: string;
133
+ shape: string;
134
+ describe: any;
135
+ required: boolean;
136
+ })[];
137
+ describe?: undefined;
138
+ };
139
+ })[];
140
+ describe: string;
141
+ entries?: undefined;
142
+ values?: undefined;
143
+ })[];
@@ -0,0 +1,155 @@
1
+ /**
2
+ * Validate and compile an encoding note with a separately resolved font code table.
3
+ * @param {any} data Encoding-note data with mappings and executable rules.
4
+ * @param {{codes?: Record<string,string>, name?: string}} [options] Font glyph codes and canonical note identity.
5
+ */
6
+ export function compileEncoding(data: any, options?: {
7
+ codes?: Record<string, string>;
8
+ name?: string;
9
+ }): Readonly<{
10
+ name: any;
11
+ language?: any;
12
+ font?: any;
13
+ template?: Readonly<{
14
+ normalization: "NFC";
15
+ vowelGroups: any;
16
+ maxVowelGroup: number;
17
+ stress: "󠄔" | undefined;
18
+ diaeresis: boolean;
19
+ grave: boolean;
20
+ }> | undefined;
21
+ fonts: readonly any[];
22
+ separator: any;
23
+ separatorRow: {
24
+ from: string;
25
+ to: any;
26
+ key: string;
27
+ };
28
+ vowels: Set<any>;
29
+ accepted: Set<any>;
30
+ controls: any;
31
+ groupCase: any;
32
+ roundTrip: any;
33
+ shared: {
34
+ rows: any;
35
+ index: Map<any, any>;
36
+ readings: Map<any, any>;
37
+ };
38
+ faces: Map<any, any>;
39
+ codes: {
40
+ rows: any;
41
+ index: Map<any, any>;
42
+ readings: Map<any, any>;
43
+ };
44
+ }>;
45
+ /**
46
+ * Compile the internal row program, including isolated execution conformance fixtures.
47
+ * Application inputs go through compileEncoding's closed note schema.
48
+ * @internal
49
+ * @param {any} definition Fully resolved internal rows.
50
+ * @param {Partial<ReturnType<typeof templateProgram>["metadata"]>} [metadata] Validated note metadata, supplied by the template compiler.
51
+ */
52
+ export function compileRows(definition: any, metadata?: Partial<ReturnType<typeof templateProgram>["metadata"]>): Readonly<{
53
+ name: any;
54
+ language?: any;
55
+ font?: any;
56
+ template?: Readonly<{
57
+ normalization: "NFC";
58
+ vowelGroups: any;
59
+ maxVowelGroup: number;
60
+ stress: "󠄔" | undefined;
61
+ diaeresis: boolean;
62
+ grave: boolean;
63
+ }> | undefined;
64
+ fonts: readonly any[];
65
+ separator: any;
66
+ separatorRow: {
67
+ from: string;
68
+ to: any;
69
+ key: string;
70
+ };
71
+ vowels: Set<any>;
72
+ accepted: Set<any>;
73
+ controls: any;
74
+ groupCase: any;
75
+ roundTrip: any;
76
+ shared: {
77
+ rows: any;
78
+ index: Map<any, any>;
79
+ readings: Map<any, any>;
80
+ };
81
+ faces: Map<any, any>;
82
+ codes: {
83
+ rows: any;
84
+ index: Map<any, any>;
85
+ readings: Map<any, any>;
86
+ };
87
+ }>;
88
+ /**
89
+ * Validate Roman spelling and literal syntax without requiring ordinary mapping coverage.
90
+ * Accepted words may instead have authoritative native writings in the language note.
91
+ * @param {ReturnType<typeof compileEncoding>} enc - Compiled encoding and its font codes.
92
+ * @param {string} text - Authored Roman source, normalized to NFC for template rules.
93
+ * @param {{font?:string,start?:number,end?:number}} [options] - Face and authored UTF-16 bounds.
94
+ * @returns {void} Throws EncodingError at the authored UTF-16 offset and code-point column.
95
+ */
96
+ export function validateSource(enc: ReturnType<typeof compileEncoding>, text: string, options?: {
97
+ font?: string;
98
+ start?: number;
99
+ end?: number;
100
+ }): void;
101
+ /**
102
+ * Encode matched pieces while preserving offsets into the original source.
103
+ * @param {ReturnType<typeof compileEncoding>} enc - Compiled encoding note.
104
+ * @param {string} text - Authored Roman source.
105
+ * @param {{font?: string, verse?: boolean, start?: number, end?: number}} [options] - Source bounds and presentation.
106
+ */
107
+ export function encodePieces(enc: ReturnType<typeof compileEncoding>, text: string, options?: {
108
+ font?: string;
109
+ verse?: boolean;
110
+ start?: number;
111
+ end?: number;
112
+ }): {
113
+ from: any;
114
+ to: any;
115
+ start: any;
116
+ end: any;
117
+ row: any;
118
+ }[];
119
+ /**
120
+ * Encode text using exactly the rows of its compiled encoding. Unknown input is refused.
121
+ * @param {ReturnType<typeof compileEncoding>} enc
122
+ * @param {string} text
123
+ * @param {{font?: string, verse?: boolean}} [options]
124
+ * @returns {string}
125
+ */
126
+ export function encodeText(enc: ReturnType<typeof compileEncoding>, text: string, options?: {
127
+ font?: string;
128
+ verse?: boolean;
129
+ }): string;
130
+ /**
131
+ * Decode exact output or the conventional reading of an explicitly canonical note.
132
+ * @param {ReturnType<typeof compileEncoding>} enc - Compiled encoding note.
133
+ * @param {string} text - Native text with optional literal spans.
134
+ * @param {{font?: string}} [options] - Selected encoding face.
135
+ * @returns {string} Roman source, with literals kept between their visible markers.
136
+ */
137
+ export function decodeText(enc: ReturnType<typeof compileEncoding>, text: string, options?: {
138
+ font?: string;
139
+ }): string;
140
+ /**
141
+ * A schema fault or text refusal. Text offsets are UTF-16; columns count code points.
142
+ */
143
+ export class EncodingError extends Error {
144
+ /** @param {string} message @param {{text?: string, offset?: number, key?: string}} [details] */
145
+ constructor(message: string, { text, offset, key }?: {
146
+ text?: string;
147
+ offset?: number;
148
+ key?: string;
149
+ });
150
+ key: string | undefined;
151
+ offset: number | undefined;
152
+ line: number | undefined;
153
+ column: number | undefined;
154
+ }
155
+ import { templateProgram } from "./encoding-template.mjs";
@@ -12,7 +12,7 @@
12
12
  * {@link module:engine/content-figures.scanFigures}.
13
13
  * @param {import("./content-scripts.mjs").RunContext} [runs] - The package's
14
14
  * languages, faces and maps. Given, text marked with `lang=`, `font=` and
15
- * `map=` is rewritten first, so it is tagged for its language, mapped and
15
+ * `enc=` is rewritten first, so it is tagged for its language, mapped and
16
16
  * set in its font.
17
17
  * @returns {string} The rendered HTML.
18
18
  */
@@ -97,4 +97,8 @@ export * as sceneLevels from "./scene-levels.mjs";
97
97
  export * as generate from "./generate.mjs";
98
98
  export * as compendiums from "./compendiums.mjs";
99
99
  export * as regionEvents from "./region-events.mjs";
100
+ export * as encoding from "./encoding.mjs";
101
+ export * as encodingLanguage from "./encoding-language.mjs";
102
+ export * as encodingNotes from "./encoding-notes.mjs";
103
+ export * as encodingLexicon from "./encoding-lexicon.mjs";
100
104
  export { CURATED_REGION_EVENTS, EXCLUDED_REGION_EVENTS, REGION_EVENT_TO_TRIGGER } from "./region-events.mjs";
@@ -352,7 +352,7 @@ export const NAMING_FIELDS: readonly import("./data-keys.mjs").InnerKeySpec[];
352
352
  */
353
353
  export const VERB_PERSON_FIELDS: readonly import("./data-keys.mjs").InnerKeySpec[];
354
354
  /**
355
- * The endings `data.grammar.native` writes under a logographic map: the noun
355
+ * The endings `data.grammar.native` writes under a encoding: the noun
356
356
  * plural, then the six persons of the verb pattern.
357
357
  */
358
358
  export const WRITTEN_ENDINGS: readonly string[];
@@ -6,25 +6,25 @@
6
6
  * | {ambiguous: {form: string, glosses: string[]}}} Writing
7
7
  */
8
8
  /**
9
- * The text a list of native entries states for a map in a face: the entry for
9
+ * The text a list of native entries states for a enc in a face: the entry for
10
10
  * the face, else the entry for no face.
11
11
  *
12
12
  * @param {unknown} natives - A `native` list as authored.
13
- * @param {string} map - The map's name.
13
+ * @param {string} enc - The encoding's name.
14
14
  * @param {string|undefined} font - The face.
15
15
  * @returns {string|undefined} The text.
16
16
  */
17
- export function nativeText(natives: unknown, map: string, font: string | undefined): string | undefined;
17
+ export function nativeText(natives: unknown, enc: string, font: string | undefined): string | undefined;
18
18
  /**
19
- * The writings of a language's words under one logographic map in one face.
19
+ * The writings of a language's words under one encoding in one face.
20
20
  *
21
21
  * @param {Record<string, any>|undefined} data - The language note's `data`.
22
- * @param {string} map - The map's name.
22
+ * @param {string} enc - The encoding's name.
23
23
  * @param {string|undefined} font - The face.
24
24
  * @returns {{word: (word: string) => Writing, entry: (index: number) => Writing}}
25
25
  * The writing of a run's word, and of the `data.words` entry at an index.
26
26
  */
27
- export function writingsOf(data: Record<string, any> | undefined, map: string, font: string | undefined): {
27
+ export function writingsOf(data: Record<string, any> | undefined, enc: string, font: string | undefined): {
28
28
  word: (word: string) => Writing;
29
29
  entry: (index: number) => Writing;
30
30
  };
@@ -6,7 +6,7 @@
6
6
  * @param {import("./content-session.mjs").ContentSyntax} [syntax] - Exact-text scanner projections.
7
7
  * @param {import("./content-scripts.mjs").RunContext} [runs] - The package's
8
8
  * languages, faces and maps. Given, text marked with `lang=`, `font=` and
9
- * `map=` is checked against them; a caller with no package configuration
9
+ * `enc=` is checked against them; a caller with no package configuration
10
10
  * leaves it out.
11
11
  * @returns {Array<{file: string, line: number, column: number, severity: string, message: string}>} Syntax errors,
12
12
  * then warnings.
@@ -91,7 +91,7 @@ export function stripHtmlComments(markdown: string): string;
91
91
  * finding.
92
92
  * @param {import("./content-scripts.mjs").RunContext} [opts.runs] - The
93
93
  * package's languages, faces and maps, which text marked with `lang=`,
94
- * `font=` and `map=` is checked against and set by.
94
+ * `font=` and `enc=` is checked against and set by.
95
95
  * @param {number} [opts.bodyLine] - The 1-based file line the body starts on, so
96
96
  * a finding's line is the file's rather than the body's.
97
97
  * @param {number} [opts.bodyColumn] - The 1-based column the body starts at.
@@ -26,13 +26,13 @@ export function romanInventoriesOf(records: ReadonlyMap<string, Record<string, a
26
26
  * No punctuation, case or normalization repair is performed.
27
27
  * @param {string} text - Visible Roman source.
28
28
  * @param {RomanInventory} inventory - Its language's declared characters.
29
- * @param {(char: string) => boolean} [native] - Whether a directly typed native sign is drawn in the selected native face.
30
29
  * @returns {Array<{offset: number, message: string}>}
31
30
  */
32
- export function romanTextProblems(text: string, inventory: RomanInventory, native?: (char: string) => boolean): Array<{
31
+ export function romanTextProblems(text: string, inventory: RomanInventory): Array<{
33
32
  offset: number;
34
33
  message: string;
35
34
  }>;
35
+ export function isRomanWhitespace(char: any): boolean;
36
36
  export type RomanInventory = {
37
37
  /**
38
38
  * - The configured language name.
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Project an authored run to logical Roman text while retaining source offsets.
3
+ * Presentation-only children contribute their text; names contribute standard
4
+ * braces. The caller decides which children are independent runs and which
5
+ * ranges are layout or emphasis delimiters.
6
+ * @module
7
+ */
8
+ /**
9
+ * @typedef {object} RomanSpan
10
+ * @property {number} start - Opening bracket offset.
11
+ * @property {number} end - Offset past the attribute block.
12
+ * @property {number} contentEnd - Closing bracket offset.
13
+ * @property {Array<[string, string]>} [attrs] - Authored attributes.
14
+ */
15
+ /**
16
+ * @typedef {object} ProjectedSpan
17
+ * @property {RomanSpan} source - The authored child.
18
+ * @property {number} from - Its first logical UTF-16 offset, including name braces.
19
+ * @property {number} to - Offset past its logical text and braces.
20
+ * @property {number} contentFrom - Logical text after its opening name brace.
21
+ * @property {number} contentTo - Offset past the logical text, before its closing name brace.
22
+ * @property {boolean} name - Whether this child marks a name.
23
+ * @property {boolean} included - Whether this child contributes its own text.
24
+ */
25
+ /**
26
+ * Remove Markdown escapes, inline presentation syntax and excluded layout.
27
+ * The returned offsets refer to the original source, in UTF-16 units, matching
28
+ * the source scanner. A supplementary character has two entries, both pointing
29
+ * at its original first unit. Synthetic braces point at the name's brackets.
30
+ * @param {string} source - Complete authored source.
31
+ * @param {object} [options] - Bounds and projections chosen by the run scanner.
32
+ * @param {number} [options.from] - First included source offset.
33
+ * @param {number} [options.to] - Offset past the included source.
34
+ * @param {readonly RomanSpan[]} [options.spans] - Scanned spans, with absolute offsets.
35
+ * @param {(span: RomanSpan) => boolean} [options.includeSpan] - Whether a child inherits this run.
36
+ * @param {(span: RomanSpan) => string} [options.opaqueSpan] - Placeholder for an independent child. The default empty name keeps sentence state without introducing that child's letters.
37
+ * @param {ReadonlyArray<readonly [number, number]>} [options.exclude] - Absolute source ranges that carry layout or presentation syntax.
38
+ * @param {boolean} [options.markNames] - Whether name children contribute braces.
39
+ * @returns {{text: string, offsets: number[], spans: ProjectedSpan[]}} Logical text and source locations, with child ranges for presentation.
40
+ */
41
+ export function plainRomanRun(source: string, { from, to, spans, includeSpan, opaqueSpan, exclude, markNames, }?: {
42
+ from?: number | undefined;
43
+ to?: number | undefined;
44
+ spans?: readonly RomanSpan[] | undefined;
45
+ includeSpan?: ((span: RomanSpan) => boolean) | undefined;
46
+ opaqueSpan?: ((span: RomanSpan) => string) | undefined;
47
+ exclude?: readonly (readonly [number, number])[] | undefined;
48
+ markNames?: boolean | undefined;
49
+ }): {
50
+ text: string;
51
+ offsets: number[];
52
+ spans: ProjectedSpan[];
53
+ };
54
+ export type RomanSpan = {
55
+ /**
56
+ * - Opening bracket offset.
57
+ */
58
+ start: number;
59
+ /**
60
+ * - Offset past the attribute block.
61
+ */
62
+ end: number;
63
+ /**
64
+ * - Closing bracket offset.
65
+ */
66
+ contentEnd: number;
67
+ /**
68
+ * - Authored attributes.
69
+ */
70
+ attrs?: [string, string][] | undefined;
71
+ };
72
+ export type ProjectedSpan = {
73
+ /**
74
+ * - The authored child.
75
+ */
76
+ source: RomanSpan;
77
+ /**
78
+ * - Its first logical UTF-16 offset, including name braces.
79
+ */
80
+ from: number;
81
+ /**
82
+ * - Offset past its logical text and braces.
83
+ */
84
+ to: number;
85
+ /**
86
+ * - Logical text after its opening name brace.
87
+ */
88
+ contentFrom: number;
89
+ /**
90
+ * - Offset past the logical text, before its closing name brace.
91
+ */
92
+ contentTo: number;
93
+ /**
94
+ * - Whether this child marks a name.
95
+ */
96
+ name: boolean;
97
+ /**
98
+ * - Whether this child contributes its own text.
99
+ */
100
+ included: boolean;
101
+ };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Remove visual indentation before checking or encoding Roman verse. Each
3
+ * content line keeps its own boundary, including the last line before a stanza
4
+ * or canto; those extra structural controls do not consume its line boundary.
5
+ * The caller writes the boundaries through its selected encoding.
6
+ * @param {string} source - Complete authored source.
7
+ * @param {Parameters<typeof plainRomanRun>[1] & {isCantoLine?: (line: string) => boolean}} [options] - Run bounds, spans and layout projection.
8
+ * @returns {ReturnType<typeof plainRomanRun> & {boundaries: Array<{kind: "line"|"stanza"|"canto", at: number, sourceOffset: number}>, errors: Array<{offset: number, message: string}>}} Visible text, positions and structural events.
9
+ */
10
+ export function plainRomanVerse(source: string, options?: Parameters<typeof plainRomanRun>[1] & {
11
+ isCantoLine?: (line: string) => boolean;
12
+ }): ReturnType<typeof plainRomanRun> & {
13
+ boundaries: Array<{
14
+ kind: "line" | "stanza" | "canto";
15
+ at: number;
16
+ sourceOffset: number;
17
+ }>;
18
+ errors: Array<{
19
+ offset: number;
20
+ message: string;
21
+ }>;
22
+ };
23
+ import { plainRomanRun } from "./roman-run.mjs";
@@ -7,11 +7,8 @@
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
9
  * @property {string|null} font - Its explicit font, an inherited ordinary
10
- * prose family, or the configured default for an opted-in native run.
11
- * @property {string|null} map - Its explicit map or the configured map of an
12
- * opted-in native run; null for Roman language-only text.
13
- * @property {boolean} [nativefont] - Explicit native opt-in on this construct;
14
- * absent on Roman runs. This internal flag is not a SQL column.
10
+ * prose family, or the font of the selected encoding document.
11
+ * @property {string|null} enc - Its resolved encoding document, or default for Roman text.
15
12
  * @property {number} line - 1-based file line of its opening.
16
13
  * @property {number} column - 1-based UTF-16 file column of its opening.
17
14
  */
@@ -38,22 +35,24 @@ export function recordRuns(body: string, { context, bodyLine, bodyColumn, syntax
38
35
  syntax?: import("./content-session.mjs").ContentSyntax | undefined;
39
36
  }): RecordRun[];
40
37
  /**
41
- * Give explicitly native recorded runs the map and face their language names in
42
- * `data.writtenIn`, where the run leaves them unstated, as a run is set. Read
43
- * once every record exists, since a run's language note may be recorded after
44
- * the note that marks it.
38
+ * Resolve recorded encoding Addresses and fill the language and font supplied
39
+ * by each selected document, once every index record exists.
45
40
  *
46
41
  * @param {Record<string, any>[]} records - The package's index records; each
47
42
  * note record's `runs` is updated in place.
48
- * @param {{languages?: Readonly<Record<string, {tag: string, note?: string}>>, contentPackage?: string}} config -
43
+ * @param {{languages?: Readonly<Record<string, {tag: string, note?: string}>>, contentPackage?: string, rootDir?:string, paths?:{content?:string}}} config -
49
44
  * The configured languages, whose `note` names each language note.
50
45
  */
51
- export function fillWrittenIn(records: Record<string, any>[], config: {
46
+ export function fillEncodingRuns(records: Record<string, any>[], config: {
52
47
  languages?: Readonly<Record<string, {
53
48
  tag: string;
54
49
  note?: string;
55
50
  }>>;
56
51
  contentPackage?: string;
52
+ rootDir?: string;
53
+ paths?: {
54
+ content?: string;
55
+ };
57
56
  }): void;
58
57
  /**
59
58
  * The containing page's NOTE identity.
@@ -91,19 +90,13 @@ export type RecordRun = {
91
90
  tag: string | null;
92
91
  /**
93
92
  * - Its explicit font, an inherited ordinary
94
- * prose family, or the configured default for an opted-in native run.
93
+ * prose family, or the font of the selected encoding document.
95
94
  */
96
95
  font: string | null;
97
96
  /**
98
- * - Its explicit map or the configured map of an
99
- * opted-in native run; null for Roman language-only text.
97
+ * - Its resolved encoding document, or default for Roman text.
100
98
  */
101
- map: string | null;
102
- /**
103
- * - Explicit native opt-in on this construct;
104
- * absent on Roman runs. This internal flag is not a SQL column.
105
- */
106
- nativefont?: boolean | undefined;
99
+ enc: string | null;
107
100
  /**
108
101
  * - 1-based file line of its opening.
109
102
  */
@@ -26,3 +26,5 @@ export const LANGUAGE_EMPHASES: readonly string[];
26
26
  export const SCRIPT_DIRECTIONS: readonly string[];
27
27
  /** The `subType` of a script note. */
28
28
  export const SCRIPT_SUBTYPE: "script";
29
+ /** The ordinary prose families accepted by font=. */
30
+ export const GENERIC_FAMILIES: readonly string[];
@@ -12,7 +12,7 @@ export function emphasesFromRecords(records: Iterable<Record<string, any>> | und
12
12
  *
13
13
  * @param {ReadonlyMap<string, Record<string, any>>} byName - Each configured
14
14
  * language's note record, by language name, from
15
- * {@link module:engine/map-lexicon.languageRecordsByName}.
15
+ * {@link module:engine/encoding-lexicon.languageRecordsByName}.
16
16
  * @returns {Map<string, LanguageEmphasis>} The conventions, by language name;
17
17
  * a language whose note states none, or one the build does not know, is
18
18
  * absent.
@@ -1,9 +1,8 @@
1
1
  /**
2
2
  * The faces the package's notes set text in, read from the notes
3
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.
4
+ * is scanned for its runs, and encoding documents supply the fonts their
5
+ * encoded runs infer.
7
6
  *
8
7
  * @param {DeliveryConfig} config - The resolved configuration.
9
8
  * @param {import("./script-fonts.mjs").ScriptFonts} installed - The fonts package.