@heroiclands/package-build 24.1.1 → 25.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/CHANGELOG.md +36 -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 +154 -11
  9. package/docs/authoring/links-and-markup.md +260 -473
  10. package/docs/commands.md +118 -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 +135 -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 +453 -569
  19. package/docs/reference/format-details.md +290 -380
  20. package/docs/reference/note-types.md +80 -62
  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 +21 -1
  25. package/engine/content-format.yaml +7 -2
  26. package/engine/content-index.mjs +6 -2
  27. package/engine/content-links.mjs +1 -0
  28. package/engine/content-scripts.mjs +658 -423
  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 +699 -0
  37. package/engine/encoding-notes.mjs +186 -0
  38. package/engine/encoding-standard.mjs +42 -0
  39. package/engine/encoding-template.mjs +313 -0
  40. package/engine/encoding-terms.mjs +141 -0
  41. package/engine/encoding.mjs +946 -0
  42. package/engine/extension-attributes.mjs +2 -0
  43. package/engine/helpers.mjs +1 -1
  44. package/engine/index.mjs +10 -0
  45. package/engine/language-data.mjs +4 -1
  46. package/engine/language-terms.mjs +23 -12
  47. package/engine/{logographic.mjs → language-writings.mjs} +29 -38
  48. package/engine/markup-validation.mjs +1 -1
  49. package/engine/note-vocabulary.mjs +4 -158
  50. package/engine/pdf-render.mjs +31 -3
  51. package/engine/roman-characters.mjs +232 -0
  52. package/engine/roman-run.mjs +149 -0
  53. package/engine/roman-verse.mjs +95 -0
  54. package/engine/run-rows.mjs +29 -31
  55. package/engine/run-words.mjs +2 -2
  56. package/engine/script-emphasis-terms.mjs +3 -0
  57. package/engine/script-emphasis.mjs +3 -10
  58. package/engine/script-font-delivery.mjs +9 -12
  59. package/engine/script-fonts.mjs +2 -1
  60. package/engine/site-build.mjs +14 -5
  61. package/engine/site-preview.mjs +12 -2
  62. package/engine/sql-tables.mjs +36 -31
  63. package/engine/verse-metre.mjs +1 -1
  64. package/engine/word-forms.mjs +1 -1
  65. package/engine/word-inflections.mjs +48 -0
  66. package/engine/word-rows.mjs +1 -1
  67. package/engine/word-terms.mjs +16 -17
  68. package/package.json +11 -5
  69. package/types/config.d.mts +5 -0
  70. package/types/convert.d.mts +44 -0
  71. package/types/e2e.d.mts +1 -1
  72. package/types/engine/base-compiler.d.mts +4 -2
  73. package/types/engine/content-charset.d.mts +8 -0
  74. package/types/engine/content-index.d.mts +4 -1
  75. package/types/engine/content-scripts.d.mts +108 -42
  76. package/types/engine/converter-data.d.mts +11 -0
  77. package/types/engine/dictionary-rows.d.mts +1 -25
  78. package/types/engine/encoding-integrity.d.mts +14 -0
  79. package/types/engine/encoding-language.d.mts +36 -0
  80. package/types/engine/encoding-lexicon.d.mts +259 -0
  81. package/types/engine/encoding-notes.d.mts +39 -0
  82. package/types/engine/encoding-standard.d.mts +11 -0
  83. package/types/engine/encoding-template.d.mts +43 -0
  84. package/types/engine/encoding-terms.d.mts +105 -0
  85. package/types/engine/encoding.d.mts +155 -0
  86. package/types/engine/helpers.d.mts +1 -1
  87. package/types/engine/index.d.mts +5 -0
  88. package/types/engine/language-terms.d.mts +1 -1
  89. package/types/engine/{logographic.d.mts → language-writings.d.mts} +6 -6
  90. package/types/engine/markup-validation.d.mts +1 -1
  91. package/types/engine/pdf-render.d.mts +1 -1
  92. package/types/engine/roman-characters.d.mts +45 -0
  93. package/types/engine/roman-run.d.mts +101 -0
  94. package/types/engine/roman-verse.d.mts +23 -0
  95. package/types/engine/run-rows.d.mts +13 -20
  96. package/types/engine/script-emphasis-terms.d.mts +2 -0
  97. package/types/engine/script-emphasis.d.mts +1 -1
  98. package/types/engine/script-font-delivery.d.mts +2 -3
  99. package/types/engine/script-fonts.d.mts +5 -0
  100. package/types/engine/site-preview.d.mts +1 -1
  101. package/types/engine/word-inflections.d.mts +25 -0
  102. package/engine/map-lexicon.mjs +0 -1034
  103. package/engine/text-maps.mjs +0 -654
  104. package/engine/written-in.mjs +0 -204
  105. package/types/engine/map-lexicon.d.mts +0 -330
  106. package/types/engine/text-maps.d.mts +0 -189
  107. package/types/engine/written-in.d.mts +0 -76
@@ -0,0 +1,39 @@
1
+ /** Complete an encoding reference with the document type and citing package.
2
+ * @param {unknown} value - Authored encoding Address or default.
3
+ * @param {string} [contentPackage] - The citing note's package.
4
+ * @returns {string|undefined} Canonical Address, default, or an invalid reference.
5
+ */
6
+ export function encodingAddress(value: unknown, contentPackage?: string): string | undefined;
7
+ /** The executable fields a document owns, excluding ordinary document metadata.
8
+ * @param {Record<string, any>} data - Authored document data.
9
+ * @returns {Record<string, any>} Only the compiler's fields.
10
+ */
11
+ export function encodingData(data: Record<string, any>): Record<string, any>;
12
+ /** Read this selected face's published glyph codes, with no external code tables.
13
+ * @param {import("./script-fonts.mjs").ScriptFonts|undefined} fonts - Consumer fonts.
14
+ * @param {string} font - The selected face's slug.
15
+ * @returns {Record<string,string>} Code-to-Unicode mapping for this font only.
16
+ */
17
+ export function fontCodes(fonts: import("./script-fonts.mjs").ScriptFonts | undefined, font: string): Record<string, string>;
18
+ /** Compile each encoding document once and resolve references by document Address.
19
+ * @param {Iterable<Record<string, any>>} records - Content index records.
20
+ * @param {{languages?: Record<string, any>, contentPackage?: string, rootDir?: string, paths?: {content?: string}}} [config] - Consumer context.
21
+ * @param {import("./script-fonts.mjs").ScriptFonts} [fonts] - Installed glyph metadata.
22
+ * @returns {{encodings: Map<string, ReturnType<typeof compileEncoding>>, definitions: Map<string,{data:Record<string,any>,codes:Record<string,string>}>, findings:object[]}} Runtime and serializable document inputs.
23
+ */
24
+ export function encodingsFromRecords(records: Iterable<Record<string, any>>, config?: {
25
+ languages?: Record<string, any>;
26
+ contentPackage?: string;
27
+ rootDir?: string;
28
+ paths?: {
29
+ content?: string;
30
+ };
31
+ }, fonts?: import("./script-fonts.mjs").ScriptFonts): {
32
+ encodings: Map<string, ReturnType<typeof compileEncoding>>;
33
+ definitions: Map<string, {
34
+ data: Record<string, any>;
35
+ codes: Record<string, string>;
36
+ }>;
37
+ findings: object[];
38
+ };
39
+ import { compileEncoding } from "./encoding.mjs";
@@ -0,0 +1,11 @@
1
+ /** Shared Roman punctuation and invisible structural controls for every encoding. */
2
+ export const STANDARD_ROWS: readonly Readonly<unknown>[];
3
+ /** Controls belong to the engine and never come from font encoding files. */
4
+ export const STANDARD_CONTROLS: Readonly<{
5
+ verseStanza: "󠄍";
6
+ verseCanto: "󠄎";
7
+ wordSeparator: " ";
8
+ literalOpen: "󠄒";
9
+ literalClose: "󠄓";
10
+ literalEscape: "󠄕";
11
+ }>;
@@ -0,0 +1,43 @@
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
+ vowels: any;
18
+ rows: Readonly<unknown>[];
19
+ codes: [string, string][];
20
+ controls: Readonly<{
21
+ verseStanza: "󠄍";
22
+ verseCanto: "󠄎";
23
+ wordSeparator: " ";
24
+ literalOpen: "󠄒";
25
+ literalClose: "󠄓";
26
+ literalEscape: "󠄕";
27
+ }>;
28
+ };
29
+ rowKeys: string[];
30
+ metadata: {
31
+ name: string;
32
+ language: any;
33
+ font: any;
34
+ template: Readonly<{
35
+ normalization: "NFC";
36
+ vowelGroups: any;
37
+ maxVowelGroup: number;
38
+ stress: "󠄔" | undefined;
39
+ diaeresis: boolean;
40
+ grave: boolean;
41
+ }>;
42
+ };
43
+ };
@@ -0,0 +1,105 @@
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
+ describe: string;
20
+ entries: {
21
+ kind: string;
22
+ shape: string;
23
+ fields: {
24
+ name: any;
25
+ kind: string;
26
+ shape: string;
27
+ describe: any;
28
+ required: boolean;
29
+ }[];
30
+ };
31
+ })[];
32
+ /** The additional data keys a document may use to define its encoding. */
33
+ export const ENCODING_NOTE_FIELDS: readonly ({
34
+ name: any;
35
+ kind: string;
36
+ shape: string;
37
+ describe: any;
38
+ required: boolean;
39
+ } | {
40
+ name: string;
41
+ kind: string;
42
+ shape: string;
43
+ entries: {
44
+ kind: string;
45
+ shape: string;
46
+ describe: string;
47
+ };
48
+ describe: string;
49
+ values?: undefined;
50
+ fields?: undefined;
51
+ } | {
52
+ name: string;
53
+ kind: string;
54
+ shape: string;
55
+ values: {
56
+ describe: string;
57
+ kind: string;
58
+ shape: string;
59
+ entries: {
60
+ kind: string;
61
+ shape: string;
62
+ describe: string;
63
+ };
64
+ };
65
+ describe: string;
66
+ entries?: undefined;
67
+ fields?: undefined;
68
+ } | {
69
+ name: string;
70
+ kind: string;
71
+ shape: string;
72
+ fields: readonly ({
73
+ allowed?: string[] | undefined;
74
+ kind: string;
75
+ shape: string;
76
+ name: any;
77
+ describe: any;
78
+ required: boolean;
79
+ } | {
80
+ name: any;
81
+ kind: string;
82
+ shape: string;
83
+ describe: any;
84
+ fields: any;
85
+ } | {
86
+ name: string;
87
+ kind: string;
88
+ shape: string;
89
+ describe: string;
90
+ entries: {
91
+ kind: string;
92
+ shape: string;
93
+ fields: {
94
+ name: any;
95
+ kind: string;
96
+ shape: string;
97
+ describe: any;
98
+ required: boolean;
99
+ }[];
100
+ };
101
+ })[];
102
+ describe: string;
103
+ entries?: undefined;
104
+ values?: undefined;
105
+ })[];
@@ -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 a note's uniquely decodable output, including nonprefix glyph sequences.
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
  */
@@ -65,6 +65,7 @@ export * as previewIndex from "./preview-index.mjs";
65
65
  export * as contentRender from "./content-render.mjs";
66
66
  export * as contentLint from "./content-lint.mjs";
67
67
  export * as contentCharset from "./content-charset.mjs";
68
+ export * as romanCharacters from "./roman-characters.mjs";
68
69
  export * as pathCharset from "./path-charset.mjs";
69
70
  export * as contentIcons from "./content-icons.mjs";
70
71
  export * as contentHtml from "./content-html.mjs";
@@ -96,4 +97,8 @@ export * as sceneLevels from "./scene-levels.mjs";
96
97
  export * as generate from "./generate.mjs";
97
98
  export * as compendiums from "./compendiums.mjs";
98
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";
99
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.
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Semantic problems in a supplied inventory. Shape belongs to the vocabulary.
3
+ * An empty string explicitly declares no written characters.
4
+ * @param {unknown} value - The authored `data.roman`.
5
+ * @returns {string[]} Findings at that field.
6
+ */
7
+ export function romanInventoryProblems(value: unknown): string[];
8
+ /**
9
+ * @typedef {object} RomanInventory
10
+ * @property {string} language - The configured language name.
11
+ * @property {ReadonlySet<string>|undefined} characters - Exact code points, absent for a missing declaration.
12
+ */
13
+ /**
14
+ * Each configured language note's own inventory, by alias and BCP 47 tag.
15
+ * Language-family ancestry does not supply an inventory. Unassociated external
16
+ * tags have no entry and keep their ordinary behavior.
17
+ * @param {ReadonlyMap<string, Record<string, any>>} records - Configured language notes.
18
+ * @param {Readonly<Record<string, {tag: string}>>} languages - Language configuration.
19
+ * @returns {Map<string, RomanInventory>}
20
+ */
21
+ export function romanInventoriesOf(records: ReadonlyMap<string, Record<string, any>>, languages?: Readonly<Record<string, {
22
+ tag: string;
23
+ }>>): Map<string, RomanInventory>;
24
+ /**
25
+ * Invalid source characters, retaining offsets in the supplied unescaped text.
26
+ * No punctuation, case or normalization repair is performed.
27
+ * @param {string} text - Visible Roman source.
28
+ * @param {RomanInventory} inventory - Its language's declared characters.
29
+ * @returns {Array<{offset: number, message: string}>}
30
+ */
31
+ export function romanTextProblems(text: string, inventory: RomanInventory): Array<{
32
+ offset: number;
33
+ message: string;
34
+ }>;
35
+ export function isRomanWhitespace(char: any): boolean;
36
+ export type RomanInventory = {
37
+ /**
38
+ * - The configured language name.
39
+ */
40
+ language: string;
41
+ /**
42
+ * - Exact code points, absent for a missing declaration.
43
+ */
44
+ characters: ReadonlySet<string> | undefined;
45
+ };
@@ -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";