@heroiclands/package-build 20.3.1 → 20.5.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 (195) hide show
  1. package/CHANGELOG.md +351 -0
  2. package/CONTENT.md +322 -110
  3. package/README.md +21 -10
  4. package/bin/content-build.mjs +204 -92
  5. package/bin/package-build.mjs +48 -15
  6. package/config.mjs +6 -8
  7. package/content-config.mjs +518 -151
  8. package/docs/api.md +1352 -0
  9. package/docs/commands.md +1609 -0
  10. package/docs/configuration.md +1432 -0
  11. package/docs/content-format.md +73 -74
  12. package/docs/diagnostics.md +356 -0
  13. package/docs/getting-started.md +813 -0
  14. package/docs/project-setup.md +469 -0
  15. package/e2e.mjs +4 -4
  16. package/engine/actor-compiler.mjs +64 -61
  17. package/engine/address-charset.mjs +6 -6
  18. package/engine/address-diff.mjs +57 -52
  19. package/engine/anchored-sections.mjs +1 -1
  20. package/engine/anchors.mjs +1 -1
  21. package/engine/base-compiler.mjs +42 -38
  22. package/engine/bundle-notes.mjs +4 -4
  23. package/engine/bundles.mjs +17 -8
  24. package/engine/code-fences.mjs +3 -3
  25. package/engine/compendiums.mjs +8 -8
  26. package/engine/compile-corpus.mjs +4 -5
  27. package/engine/content-address.mjs +24 -24
  28. package/engine/content-charset.mjs +1 -1
  29. package/engine/content-format-check.mjs +24 -25
  30. package/engine/content-format.mjs +8 -8
  31. package/engine/content-html.mjs +202 -0
  32. package/engine/content-icons.mjs +196 -165
  33. package/engine/content-index.mjs +61 -40
  34. package/engine/content-links.mjs +74 -41
  35. package/engine/content-lint.mjs +64 -34
  36. package/engine/content-package.mjs +7 -9
  37. package/engine/content-slug.mjs +2 -2
  38. package/engine/content-tables.mjs +38 -34
  39. package/engine/content-tree.mjs +1 -1
  40. package/engine/derived-fields.mjs +174 -0
  41. package/engine/diagnostics.mjs +3 -4
  42. package/engine/document-subtypes.mjs +6 -7
  43. package/engine/field-reference.mjs +8 -8
  44. package/engine/field-spec.mjs +29 -30
  45. package/engine/folder-notes.mjs +18 -16
  46. package/engine/foreign-catalog.mjs +8 -9
  47. package/engine/foundry-entries.mjs +19 -20
  48. package/engine/frontmatter-lint.mjs +95 -103
  49. package/engine/frontmatter.mjs +11 -11
  50. package/engine/generate.mjs +44 -39
  51. package/engine/helpers.mjs +147 -84
  52. package/engine/homepage.mjs +20 -22
  53. package/engine/ids.mjs +15 -15
  54. package/engine/index-records.mjs +4 -4
  55. package/engine/index.mjs +26 -10
  56. package/engine/item-compiler.mjs +54 -29
  57. package/engine/item-docs.mjs +11 -13
  58. package/engine/item-registry.mjs +13 -13
  59. package/engine/journals.mjs +24 -15
  60. package/engine/macros.mjs +3 -3
  61. package/engine/map-notes.mjs +6 -6
  62. package/engine/metadata-index.mjs +5 -5
  63. package/engine/note-claims.mjs +51 -41
  64. package/engine/note-ids.mjs +5 -5
  65. package/engine/note-package.mjs +4 -4
  66. package/engine/note-renames.mjs +3 -3
  67. package/engine/note-schemas.mjs +3 -8
  68. package/engine/note-vocabulary.mjs +56 -54
  69. package/engine/pack-config.mjs +39 -25
  70. package/engine/pack-router.mjs +0 -0
  71. package/engine/pdf-build.mjs +464 -0
  72. package/engine/pdf-fonts.mjs +420 -0
  73. package/engine/pdf-render.mjs +798 -0
  74. package/engine/pdf-toc.mjs +525 -0
  75. package/engine/prose-config.mjs +9 -9
  76. package/engine/prose-lint.mjs +12 -13
  77. package/engine/region-events.mjs +2 -2
  78. package/engine/retired-fields.mjs +24 -22
  79. package/engine/runtime-only-fields.mjs +1 -1
  80. package/engine/scene-levels.mjs +1 -1
  81. package/engine/scenes.mjs +33 -25
  82. package/engine/schema-check.mjs +21 -21
  83. package/engine/schema-extract.mjs +1 -1
  84. package/engine/site-build.mjs +66 -50
  85. package/engine/site-index.mjs +17 -18
  86. package/engine/sql-tables.mjs +21 -13
  87. package/engine/subtype-registry.mjs +5 -4
  88. package/engine/system-block.mjs +18 -19
  89. package/engine/systems.mjs +2 -2
  90. package/engine/web-wikilinks.mjs +41 -38
  91. package/engine/wikilink-syntax.mjs +16 -16
  92. package/engine/wikilinks.mjs +40 -42
  93. package/hm3/actors.mjs +30 -22
  94. package/hm3/document-subtypes.mjs +5 -5
  95. package/hm3/index.mjs +2 -2
  96. package/hm3/item-builders.mjs +1 -1
  97. package/hm3/item-fields.mjs +3 -3
  98. package/hm3/items.mjs +28 -8
  99. package/hm3/template-priority.mjs +2 -2
  100. package/lang.mjs +3 -3
  101. package/manifest.mjs +17 -20
  102. package/package.json +1 -2
  103. package/release.mjs +66 -6
  104. package/sohl/actors.mjs +36 -28
  105. package/sohl/affiliation-standings.mjs +2 -2
  106. package/sohl/being-info.mjs +5 -5
  107. package/sohl/default-item-art.mjs +5 -5
  108. package/sohl/document-subtypes.mjs +5 -5
  109. package/sohl/index.mjs +3 -3
  110. package/sohl/item-builders.mjs +7 -7
  111. package/sohl/item-fields.mjs +8 -9
  112. package/sohl/items.mjs +28 -6
  113. package/sohl/kb-passes.mjs +5 -5
  114. package/sohl/note-schemas.mjs +12 -12
  115. package/sohl/skill-base.mjs +1 -1
  116. package/types/content-config.d.mts +91 -39
  117. package/types/e2e.d.mts +3 -3
  118. package/types/engine/actor-compiler.d.mts +45 -40
  119. package/types/engine/address-charset.d.mts +6 -6
  120. package/types/engine/address-diff.d.mts +60 -6
  121. package/types/engine/base-compiler.d.mts +27 -21
  122. package/types/engine/bundle-notes.d.mts +3 -3
  123. package/types/engine/bundles.d.mts +10 -1
  124. package/types/engine/code-fences.d.mts +3 -3
  125. package/types/engine/compendiums.d.mts +3 -3
  126. package/types/engine/compile-corpus.d.mts +1 -1
  127. package/types/engine/content-address.d.mts +20 -20
  128. package/types/engine/content-format-check.d.mts +6 -6
  129. package/types/engine/content-format.d.mts +2 -2
  130. package/types/engine/content-html.d.mts +78 -0
  131. package/types/engine/content-icons.d.mts +139 -92
  132. package/types/engine/content-index.d.mts +59 -15
  133. package/types/engine/content-links.d.mts +8 -8
  134. package/types/engine/content-lint.d.mts +8 -6
  135. package/types/engine/content-package.d.mts +6 -8
  136. package/types/engine/content-tables.d.mts +49 -18
  137. package/types/engine/derived-fields.d.mts +101 -0
  138. package/types/engine/diagnostics.d.mts +2 -2
  139. package/types/engine/document-subtypes.d.mts +3 -3
  140. package/types/engine/field-spec.d.mts +37 -39
  141. package/types/engine/folder-notes.d.mts +4 -5
  142. package/types/engine/foreign-catalog.d.mts +3 -3
  143. package/types/engine/foundry-entries.d.mts +6 -7
  144. package/types/engine/frontmatter-lint.d.mts +10 -9
  145. package/types/engine/frontmatter.d.mts +7 -7
  146. package/types/engine/generate.d.mts +7 -7
  147. package/types/engine/helpers.d.mts +128 -56
  148. package/types/engine/homepage.d.mts +16 -18
  149. package/types/engine/ids.d.mts +13 -13
  150. package/types/engine/index-records.d.mts +3 -3
  151. package/types/engine/index.d.mts +6 -0
  152. package/types/engine/item-compiler.d.mts +21 -5
  153. package/types/engine/item-docs.d.mts +2 -2
  154. package/types/engine/item-registry.d.mts +6 -6
  155. package/types/engine/journals.d.mts +12 -3
  156. package/types/engine/map-notes.d.mts +2 -2
  157. package/types/engine/metadata-index.d.mts +4 -4
  158. package/types/engine/note-claims.d.mts +30 -22
  159. package/types/engine/note-ids.d.mts +4 -4
  160. package/types/engine/note-package.d.mts +1 -1
  161. package/types/engine/note-renames.d.mts +3 -3
  162. package/types/engine/note-vocabulary.d.mts +31 -203
  163. package/types/engine/pack-config.d.mts +7 -7
  164. package/types/engine/pack-router.d.mts +1 -1
  165. package/types/engine/pdf-build.d.mts +42 -0
  166. package/types/engine/pdf-fonts.d.mts +30 -0
  167. package/types/engine/pdf-render.d.mts +144 -0
  168. package/types/engine/pdf-toc.d.mts +114 -0
  169. package/types/engine/prose-config.d.mts +9 -9
  170. package/types/engine/prose-lint.d.mts +3 -4
  171. package/types/engine/region-events.d.mts +2 -2
  172. package/types/engine/retired-fields.d.mts +10 -9
  173. package/types/engine/scenes.d.mts +10 -1
  174. package/types/engine/schema-check.d.mts +13 -13
  175. package/types/engine/site-build.d.mts +52 -25
  176. package/types/engine/site-index.d.mts +3 -4
  177. package/types/engine/sql-tables.d.mts +11 -5
  178. package/types/engine/subtype-registry.d.mts +3 -3
  179. package/types/engine/system-block.d.mts +3 -3
  180. package/types/engine/web-wikilinks.d.mts +7 -7
  181. package/types/engine/wikilink-syntax.d.mts +17 -17
  182. package/types/engine/wikilinks.d.mts +14 -14
  183. package/types/hm3/actors.d.mts +9 -1
  184. package/types/hm3/document-subtypes.d.mts +1 -1
  185. package/types/hm3/items.d.mts +9 -2
  186. package/types/hm3/template-priority.d.mts +1 -1
  187. package/types/manifest.d.mts +8 -8
  188. package/types/release.d.mts +15 -4
  189. package/types/sohl/actors.d.mts +12 -4
  190. package/types/sohl/affiliation-standings.d.mts +2 -2
  191. package/types/sohl/being-info.d.mts +2 -2
  192. package/types/sohl/document-subtypes.d.mts +1 -1
  193. package/types/sohl/items.d.mts +9 -2
  194. package/types/sohl/note-schemas.d.mts +1 -1
  195. package/MIGRATING.md +0 -608
@@ -6,7 +6,7 @@
6
6
  * key's **last two segments** — which is what makes a manifest entry's `path`
7
7
  * derivable from the key it is filed under rather than transported beside it.
8
8
  *
9
- * It was once the key's whole tail, and #59 ended that: the key gained a
9
+ * It is not the key's whole tail: the key carries a
10
10
  * `<system>` segment, so its tail is now `system-type-shortcode` and a slug is
11
11
  * the tail with that segment dropped. The behaviour here is unchanged, and
12
12
  * deliberately — a page has no system to name (see the module note above), so
@@ -14,11 +14,11 @@
14
14
  * consumer deriving a `path` from a key drops the *package and the system*, not
15
15
  * the package alone.
16
16
  *
17
- * The hyphen is a separator and never occurs inside a segment: a shortcode is
18
- * `^[A-Za-z0-9]+$` (`ADDRESS_SEGMENT_PATTERN`, enforced by `content-lint.mjs`)
19
- * and a type is a bare word. That is the same charset guarantee positional key
20
- * parsing rests on, so the address and the key cannot disagree about where one
21
- * ends and the other begins.
17
+ * The hyphen is a separator and never occurs inside a segment: a shortcode
18
+ * matches `ADDRESS_SEGMENT_PATTERN` (`engine/address-charset.mjs`, enforced by
19
+ * `content-lint.mjs`) and a type is a bare word. That is the same charset
20
+ * guarantee positional key parsing rests on, so the address and the key
21
+ * cannot disagree about where one ends and the other begins.
22
22
  *
23
23
  * @param {object} fm - Parsed frontmatter.
24
24
  * @returns {string} The address segment, e.g. `weapongear-dagger`.
@@ -50,9 +50,9 @@ export function addressSlug(fm: object): string;
50
50
  *
51
51
  * **It is a pure function of the frontmatter**, and takes no options. Nothing
52
52
  * about the file the note was read from reaches it: the `README.md` convention
53
- * that made one note address a whole section is retired with the section itself
54
- * (#204), so every note is addressed alike and there is one rule and no branch.
55
- * It took an address scheme until #215, to validate a `landing` rule it then
53
+ * that made one note address a whole section is retired with the section itself,
54
+ * so every note is addressed alike and there is one rule and no branch.
55
+ * It takes no address scheme; the `landing` rule it once validated is
56
56
  * discarded; with that key retired, `prefix` was the only thing left in the
57
57
  * scheme and the paragraph above is the reason it never applied.
58
58
  *
@@ -85,9 +85,9 @@ export function packageAddress(fm: object): string;
85
85
  * merge is a real conflict rather than an artefact of two packages sharing a
86
86
  * namespace. `(type, shortcode)` alone is unique only *within* a package, and
87
87
  * two independently authored packages reaching for the same short string is a
88
- * matter of time (#1499).
88
+ * matter of time.
89
89
  *
90
- * **The system segment (#59).** A package may ship content for more than one
90
+ * **The system segment.** A package may ship content for more than one
91
91
  * system, and one note then compiles into a document per system — an actor in
92
92
  * `actors-sohl` *and* an actor in `actors-hm3`. Without a system segment both
93
93
  * land on one key, so the address cannot name either of them. `harn-ensemble`
@@ -137,7 +137,7 @@ export function blockSystem(keyPath?: string): string;
137
137
  /**
138
138
  * Expand a written address to the one canonical address it names.
139
139
  *
140
- * **An omitted segment defaults from where the link is written** (#336) — it is
140
+ * **An omitted segment defaults from where the link is written** — it is
141
141
  * not a wildcard, and resolution is not a search. Package omitted means the
142
142
  * citing note's own; system omitted means {@link blockSystem} of the key path it
143
143
  * was written under. So every short form has exactly one expansion, computed
@@ -182,12 +182,12 @@ export function expandAddress(read: {
182
182
  *
183
183
  * Parsing is plain positional counting: split on the separator, require
184
184
  * {@link CANONICAL_KEY_SEGMENTS} of them, and assign each position its field.
185
- * **The charset rule is what makes that sound** — every segment is
186
- * `^[A-Za-z0-9]+$` (`ADDRESS_SEGMENT_PATTERN` in `engine/address-charset.mjs`),
187
- * so the hyphen is purely a separator and the count alone determines every
188
- * field. That is enforced at each of the three sources rather than assumed of
189
- * the data: shortcodes by `content-lint.mjs` (#1397), `contentPackage` by
190
- * `defineConfig` (#59), and types are bare words. Were any of them free to
185
+ * **The charset rule is what makes that sound** — every segment matches
186
+ * `ADDRESS_SEGMENT_PATTERN` (`engine/address-charset.mjs`), so the hyphen is
187
+ * purely a separator and the count alone determines every field. That is
188
+ * enforced at each of the three sources rather than assumed of
189
+ * the data: shortcodes by `content-lint.mjs`, `contentPackage` by
190
+ * `defineConfig`, and types are bare words. Were any of them free to
191
191
  * carry a hyphen, no amount of counting would recover the fields and the reader
192
192
  * would need a vocabulary to match against instead.
193
193
  *
@@ -251,7 +251,7 @@ export function packageRelative(url: string, base: string): string;
251
251
  export function resolvePackageUrl(rel: string, base: string): string;
252
252
  /**
253
253
  * The Foundry `_id` of the document a note compiles into, derived from its
254
- * canonical address (#270).
254
+ * canonical address.
255
255
  *
256
256
  * A note used to author this — an opaque 16-character string, one per note,
257
257
  * that said nothing its address did not and that no check guaranteed. The
@@ -278,7 +278,7 @@ export function resolvePackageUrl(rel: string, base: string): string;
278
278
  * @returns {string} A 16-character Foundry id.
279
279
  */
280
280
  export function documentId(pkg: string, system: string, type: string, shortcode: string): string;
281
- /** The knowledgebase's mount within this package's site (#1470). */
281
+ /** The knowledgebase's mount within this package's site. */
282
282
  export const KB_PREFIX: "kb/";
283
283
  /**
284
284
  * How many segments a canonical key has, and therefore how many the reader
@@ -22,7 +22,7 @@ export function declaredPaths(artifact: object): Set<string>;
22
22
  *
23
23
  * A shared row names no type, so it is placed rather than typed: "in the shared
24
24
  * mappings" instead of "on a `weapongear`". Reading `on a \`the shared
25
- * mappings\`` would be the alternative, and a diagnostic is prose (#275).
25
+ * mappings\`` would be the alternative, and a diagnostic is prose.
26
26
  *
27
27
  * @param {object} finding - `{system, systemVersion, noteType, source, target, shared}`.
28
28
  * @returns {string} The message.
@@ -79,16 +79,16 @@ export function measureNote(note: object, format: import("./content-format.mjs")
79
79
  /**
80
80
  * Measure a corpus, and count what it finds by class.
81
81
  *
82
- * The counts are the point as much as the findings: #127 promotes a class to
83
- * fatal when its count reaches zero, so a run that prints them is the epic's
84
- * progress bar.
82
+ * The counts are the point as much as the findings: a class is promoted to
83
+ * fatal when its count reaches zero, so a run that prints them is the
84
+ * migration's progress bar.
85
85
  *
86
86
  * @param {Iterable<object>} notes - `{file, raw, fm}` for each authored note.
87
87
  * @param {import("./content-format.mjs").ContentFormat} format - The parsed
88
88
  * specification.
89
89
  * @param {object} [opts]
90
90
  * @param {boolean} [opts.strict=false] - Report the findings as errors rather
91
- * than warnings. #127 turns this on one slice at a time.
91
+ * than warnings. Turned on one slice at a time.
92
92
  * @returns {{findings: object[], notes: number, byClass: Record<string, number>}}
93
93
  */
94
94
  export function measureCorpus(notes: Iterable<object>, format: import("./content-format.mjs").ContentFormat, { strict }?: {
@@ -107,7 +107,7 @@ export function measureCorpus(notes: Iterable<object>, format: import("./content
107
107
  export function fieldDriftMessage({ noteType, source, target, name, to }: object): string;
108
108
  /**
109
109
  * Check the specification's per-type tables against the field declarations that
110
- * compile them (#136).
110
+ * compile them.
111
111
  *
112
112
  * @param {object} opts
113
113
  * @param {import("./content-format.mjs").ContentFormat} opts.format - The
@@ -52,7 +52,7 @@ export const CONTENT_FORMAT_PATH: string;
52
52
  * `the shared mappings` for a row of the shared tables — see `shared`.
53
53
  * @property {boolean} [shared] - Whether the row came from a **shared** mapping
54
54
  * table, which stands before the first `### type:` heading and states what
55
- * every type maps identically (#275). Absent on a per-type row, so the two
55
+ * every type maps identically. Absent on a per-type row, so the two
56
56
  * never mix: only a per-type row has a field declaration to be checked
57
57
  * against.
58
58
  * @property {string} system - The system column it sits under, from the header.
@@ -121,7 +121,7 @@ export type MappingClaim = {
121
121
  /**
122
122
  * - Whether the row came from a **shared** mapping
123
123
  * table, which stands before the first `### type:` heading and states what
124
- * every type maps identically (#275). Absent on a per-type row, so the two
124
+ * every type maps identically. Absent on a per-type row, so the two
125
125
  * never mix: only a per-type row has a field declaration to be checked
126
126
  * against.
127
127
  */
@@ -0,0 +1,78 @@
1
+ /**
2
+ * What a note carrying raw HTML is told.
3
+ *
4
+ * It names the tag, because a file with several is fixed one at a time, and it
5
+ * says why rather than only what: an author who does not know the book cannot
6
+ * render it will read the finding as pedantry about a tag that plainly works.
7
+ *
8
+ * @param {string} tag - The matched markup, as written.
9
+ * @returns {string} The message, unpunctuated at the end as a finding is.
10
+ */
11
+ export function htmlMessage(tag: string): string;
12
+ /**
13
+ * Every raw HTML tag in one note's body.
14
+ *
15
+ * @param {string} body - The note's markdown, without its frontmatter.
16
+ * @param {string} file - The note's path, for the finding.
17
+ * @param {object} [opts]
18
+ * @param {number} [opts.bodyLine=1] - The 1-based file line the body starts on.
19
+ * @param {number} [opts.bodyColumn=1] - The 1-based file column it starts at.
20
+ * @returns {Array<{file: string, line: number, column: number,
21
+ * severity: "warning", message: string}>} One finding per tag, in source
22
+ * order.
23
+ */
24
+ export function checkHtml(body: string, file: string, { bodyLine, bodyColumn }?: {
25
+ bodyLine?: number | undefined;
26
+ bodyColumn?: number | undefined;
27
+ }): Array<{
28
+ file: string;
29
+ line: number;
30
+ column: number;
31
+ severity: "warning";
32
+ message: string;
33
+ }>;
34
+ /**
35
+ * Walk a content tree and report raw HTML in every note's prose.
36
+ *
37
+ * The frontmatter fence is taken off first, so what is scanned is the body and
38
+ * the positions are still the file's. A file with no frontmatter is scanned
39
+ * whole: it is not a note, but a stray `.md` in the tree carrying markup is the
40
+ * same problem for the same reason.
41
+ *
42
+ * @param {string} contentBase - Root of the content tree.
43
+ * @param {object} [opts]
44
+ * @param {readonly string[]} [opts.skipDirectories] - Directory names to ignore
45
+ * in addition to the dot-directories always skipped.
46
+ * @returns {{findings: Array<{file: string, line: number, column: number,
47
+ * severity: "warning", message: string}>, files: number}} The findings, and
48
+ * how many files were read.
49
+ */
50
+ export function lintContentHtml(contentBase: string, { skipDirectories }?: {
51
+ skipDirectories?: readonly string[] | undefined;
52
+ }): {
53
+ findings: Array<{
54
+ file: string;
55
+ line: number;
56
+ column: number;
57
+ severity: "warning";
58
+ message: string;
59
+ }>;
60
+ files: number;
61
+ };
62
+ /**
63
+ * A raw HTML tag, opening, closing or self-closing.
64
+ *
65
+ * The name must start a tag for the match to begin, which is what keeps
66
+ * markdown's own angle brackets out of it: an autolink is `<https://…>`, and
67
+ * `https` is followed by `:` rather than whitespace or `>`, so the pattern
68
+ * stops. A comparison written in prose — `a < b` — has no name after the
69
+ * bracket at all.
70
+ *
71
+ * Attributes are consumed as "anything but a bracket", deliberately loosely: a
72
+ * finding names the tag, and a pattern that tried to parse attribute syntax
73
+ * would be a second HTML parser with its own bugs, in a module whose whole
74
+ * point is that nothing here should be parsing HTML.
75
+ *
76
+ * @type {RegExp}
77
+ */
78
+ export const HTML_TAG: RegExp;
@@ -2,11 +2,13 @@
2
2
  * The family an entry draws from, named or defaulted.
3
3
  *
4
4
  * @param {{family?: string}} entry - A registry entry.
5
- * @returns {string} The family name.
5
+ * @param {IconRegistry} [registry] - The registry it came from.
6
+ * @returns {string|undefined} The family name, or nothing when neither the
7
+ * entry nor the registry says.
6
8
  */
7
9
  export function familyOf(entry: {
8
10
  family?: string;
9
- }): string;
11
+ }, registry?: IconRegistry): string | undefined;
10
12
  /**
11
13
  * Read the brace of an icon token.
12
14
  *
@@ -26,15 +28,11 @@ export function parseIconAttributes(raw?: string): {
26
28
  * Look one name up.
27
29
  *
28
30
  * @param {string} name - The name written between the colons, without `icon-`.
29
- * @param {Record<string, object>} [registry] - Defaults to {@link DEFAULT_ICONS}.
30
- * @returns {{style: string, icon: string, label: string}|null} The entry, or
31
- * `null` when the registry does not declare it.
31
+ * @param {IconRegistry} [registry] - The package's registry.
32
+ * @returns {object|null} The entry, or `null` when the registry does not
33
+ * declare it.
32
34
  */
33
- export function resolveIcon(name: string, registry?: Record<string, object>): {
34
- style: string;
35
- icon: string;
36
- label: string;
37
- } | null;
35
+ export function resolveIcon(name: string, registry?: IconRegistry): object | null;
38
36
  /**
39
37
  * The HTML the journals and the website emit — what the system already renders.
40
38
  *
@@ -43,14 +41,13 @@ export function resolveIcon(name: string, registry?: Record<string, object>): {
43
41
  * an icon dropped into a sentence has no such parent, and "the ☆ toggles it"
44
42
  * read aloud as "the toggles it" is a sentence with a hole in it.
45
43
  *
46
- * @param {{style: string, icon: string, label: string}} entry - A registry entry.
44
+ * @param {object} entry - A registry entry.
45
+ * @param {Record<string, string>} [attrs] - The token's attributes.
46
+ * @param {IconRegistry} [registry] - The registry the entry came from, which is
47
+ * what says how its family spells a class.
47
48
  * @returns {string} An `<i>` element.
48
49
  */
49
- export function iconHtml(entry: {
50
- style: string;
51
- icon: string;
52
- label: string;
53
- }, attrs?: {}): string;
50
+ export function iconHtml(entry: object, attrs?: Record<string, string>, registry?: IconRegistry): string;
54
51
  /**
55
52
  * Every icon a string names, in the order written.
56
53
  *
@@ -71,11 +68,11 @@ export function iconsIn(text: string): Array<{
71
68
  *
72
69
  * @param {string} text - The file's contents.
73
70
  * @param {string} file - Path to report.
74
- * @param {Record<string, object>} [registry] - Defaults to {@link DEFAULT_ICONS}.
71
+ * @param {IconRegistry} [registry] - The package's registry.
75
72
  * @returns {Array<{file: string, line: number, column: number,
76
73
  * severity: "warning", message: string}>} The unknown names.
77
74
  */
78
- export function lintIcons(text: string, file: string, registry?: Record<string, object>): Array<{
75
+ export function lintIcons(text: string, file: string, registry?: IconRegistry): Array<{
79
76
  file: string;
80
77
  line: number;
81
78
  column: number;
@@ -83,13 +80,27 @@ export function lintIcons(text: string, file: string, registry?: Record<string,
83
80
  message: string;
84
81
  }>;
85
82
  /**
86
- * Refuse a registry that names a style Font Awesome Free does not ship.
83
+ * What is wrong with a package's declared registry.
87
84
  *
88
- * @param {Record<string, object>} registry - A package's icon table.
85
+ * Both halves are checked, because either alone is unusable: an icon naming a
86
+ * family nothing declares has no class prefix, and a family nothing names is a
87
+ * font declared for no reason.
88
+ *
89
+ * A **style** is checked against the family's own `styles`, not against a list
90
+ * here. Font Awesome Free ships three weights and another font ships none or
91
+ * five, and only the declaration knows which — so a `duotone` entry is refused
92
+ * because the family that entry belongs to does not list `duotone`, which is a
93
+ * statement the consumer made about the font it actually ships.
94
+ *
95
+ * @param {{families?: object, icons?: object}} registry - A package's declared
96
+ * registry, before it is resolved.
89
97
  * @param {string} [where="icons"] - Where to say the fault is.
90
98
  * @returns {Array<{severity: "warning", message: string}>} What is wrong with it.
91
99
  */
92
- export function checkIconRegistry(registry: Record<string, object>, where?: string): Array<{
100
+ export function checkIconRegistry(registry: {
101
+ families?: object;
102
+ icons?: object;
103
+ }, where?: string): Array<{
93
104
  severity: "warning";
94
105
  message: string;
95
106
  }>;
@@ -103,13 +114,13 @@ export function checkIconRegistry(registry: Record<string, object>, where?: stri
103
114
  * @param {string} contentBase - Root of the content tree.
104
115
  * @param {object} [opts]
105
116
  * @param {readonly string[]} [opts.skipDirectories] - Directory names to ignore.
106
- * @param {Record<string, object>} [opts.registry] - The package's icon table.
117
+ * @param {IconRegistry} [opts.registry] - The package's registry.
107
118
  * @returns {{findings: Array<{file: string, line: number, column: number,
108
119
  * severity: "warning", message: string}>, files: number}} What it found.
109
120
  */
110
121
  export function lintContentIcons(contentBase: string, { skipDirectories, registry }?: {
111
122
  skipDirectories?: readonly string[] | undefined;
112
- registry?: Record<string, object> | undefined;
123
+ registry?: IconRegistry | undefined;
113
124
  }): {
114
125
  findings: Array<{
115
126
  file: string;
@@ -127,52 +138,69 @@ export function lintContentIcons(contentBase: string, { skipDirectories, registr
127
138
  * is reported by {@link lintIcons}, and a rendered page that still shows
128
139
  * `:icon-stra:` is how the author finds it without reading a log.
129
140
  *
130
- * @param {Record<string, object>} [registry] - Defaults to {@link DEFAULT_ICONS}.
141
+ * **A function is accepted as well as a table**, and resolved per render. The
142
+ * shared markdown-it instance is a module-level constant, so it is built before
143
+ * any configuration is read; a getter lets it draw the package's own registry
144
+ * without the module load order deciding whether that registry exists yet.
145
+ *
146
+ * @param {Record<string, object>|(() => Record<string, object>)} [registry] -
147
+ * The registry, or something that returns it.
131
148
  * @returns {(md: object) => void} A markdown-it plugin.
132
149
  */
133
- export function iconPlugin(registry?: Record<string, object>): (md: object) => void;
150
+ export function iconPlugin(registry?: Record<string, object> | (() => Record<string, object>)): (md: object) => void;
134
151
  /**
135
- * The Font Awesome styles a registry entry may name.
136
- *
137
- * Free ships these three and no others, so a `light` or `duotone` entry would
138
- * name a glyph the shipped font does not contain refused here rather than
139
- * discovered as a blank space in a printed book.
140
- *
141
- * @type {readonly string[]}
152
+ * A **family** is an icon font, and a consumer declares the ones it ships.
153
+ *
154
+ * Nothing here names Font Awesome, or Game-Icons, or any other font. A registry
155
+ * entry is a promise that a glyph will render, and only the package that ships
156
+ * the font can keep it: the Game-Icons webfont is built by a consumer from its
157
+ * own templates, and even Font Awesome — which Foundry supplies in-app — is
158
+ * present on neither the knowledgebase nor the page of a book unless somebody
159
+ * puts it there. A toolchain that shipped a table would be promising on a
160
+ * consumer's behalf.
161
+ *
162
+ * The vocabulary is the consumer's for a second reason, independent of fonts. A
163
+ * name like `victory-star-tester` is one game system's concept; another system
164
+ * compiled by this same toolchain has different icons meaning different things.
165
+ * What is shared is the *mechanism* — the syntax, the resolution, the checks —
166
+ * and that is what lives here.
167
+ *
168
+ * A family declares:
169
+ *
170
+ * - `class` — the prefix its stylesheet uses (`fa`, `ginf`, `bi`).
171
+ * - `styles` — the weights it ships, in the spelling its classes use. An empty
172
+ * list means the font has none, and then a `style` on an entry names
173
+ * something that does not exist and is reported rather than rendered.
174
+ * - `describe` — one line, so a finding can say which font it means.
175
+ *
176
+ * @typedef {object} IconFamily
177
+ * @property {string} class - The stylesheet's class prefix.
178
+ * @property {readonly string[]} styles - The weights it ships; empty for none.
179
+ * @property {string} describe - One line, for a finding.
142
180
  */
143
- export const ICON_STYLES: readonly string[];
144
181
  /**
145
- * The icon families a registry entry may draw from.
146
- *
147
- * **Two, because the interface uses two.** The SoHL icon legend says so in its
148
- * own prose: Font Awesome for most things, and Game-Icons.net *"for the arms,
149
- * gear, and condition glyphs that Font Awesome does not cover"* — eighteen of
150
- * them, `ginf-broadsword` and its kin (#391).
182
+ * A resolved registry: the families a package ships, and the icons it names.
151
183
  *
152
- * They differ in more than a class prefix, which is why this is a family rather
153
- * than a naming convention:
184
+ * `defaultFamily` is what an entry that names none belongs to. It is optional,
185
+ * and where a package declares exactly one family that one is it — so a
186
+ * single-font package writes no `family` anywhere.
154
187
  *
155
- * - Font Awesome has **weights**, so an entry names a `style` and a filled and
156
- * hollow pair is one icon twice. Game-Icons has none, so a `style` on such an
157
- * entry names something that does not exist.
158
- * - They resolve to **different fonts**. A PDF has to embed both, and find each
159
- * codepoint in its own table — Font Awesome's from the file it ships,
160
- * Game-Icons' from the `game-icons-codepoints.json` the consumer's own
161
- * `build-icon-font.mjs` writes.
188
+ * @typedef {object} IconRegistry
189
+ * @property {Readonly<Record<string, IconFamily>>} families
190
+ * @property {string|undefined} defaultFamily
191
+ * @property {Readonly<Record<string, object>>} icons
192
+ */
193
+ /**
194
+ * The registry a package that declares none gets: nothing at all.
162
195
  *
163
- * `class` is the prefix the web surfaces use. `styled` says whether a `style`
164
- * belongs on the entry at all, which is what lets a mistake be reported rather
165
- * than rendered as a class nobody defined.
196
+ * Empty rather than a starter set, because a starter set is a promise about
197
+ * fonts this package does not ship. A tree with no `icons:` configured names no
198
+ * icons, and `:icon-star:` in one of its notes renders as its own literal text
199
+ * and is reported — which is the visible failure, not a silent one.
166
200
  *
167
- * @type {Readonly<Record<string, {class: string, styled: boolean, describe: string}>>}
201
+ * @type {IconRegistry}
168
202
  */
169
- export const ICON_FAMILIES: Readonly<Record<string, {
170
- class: string;
171
- styled: boolean;
172
- describe: string;
173
- }>>;
174
- /** The family an entry that does not name one belongs to. */
175
- export const DEFAULT_ICON_FAMILY: "fontawesome";
203
+ export const EMPTY_ICON_REGISTRY: IconRegistry;
176
204
  /**
177
205
  * The sizes a note may ask for, and what each means on a page.
178
206
  *
@@ -208,38 +236,6 @@ export const ICON_ATTRIBUTES: Readonly<Record<string, {
208
236
  values: readonly string[];
209
237
  describe: string;
210
238
  }>>;
211
- /**
212
- * The icons the user guide already depicts, under the names it should call them.
213
- *
214
- * Each entry is read off the interface it describes rather than invented, and
215
- * that is meant literally — the table was checked against the system's own
216
- * templates, which is how `delete` came to be `fa-trash` rather than the
217
- * `fa-trash-can` first written here. The sheets draw `fa-trash` twenty-five
218
- * times and `fa-trash-can` never, so the first spelling would have printed an
219
- * icon the reader has never seen on screen. A registry that is not checked
220
- * against the interface is just a second place to be wrong.
221
- *
222
- * The names are what a *writer* would reach for — `delete`, not `trash` —
223
- * because the writer is the one typing them; the Font Awesome spelling is this
224
- * table's business, not theirs.
225
- *
226
- * **Three entries share `xmark`, and that is the point of naming rather than
227
- * drawing.** A `✕` in the guide means "not applicable" in a Healing Rate
228
- * column, "remove this row" on a control, and "close" on a dialog's corner. One
229
- * glyph, three sentences, three different things for a reader who cannot see
230
- * it — so they are three names with three labels, and the fact that Font
231
- * Awesome happens to draw them identically stays in this table.
232
- *
233
- * `run` and `expand` are likewise distinct: `▶` runs an action, and its label
234
- * should say so. `fa-play` is what the sheets use for it.
235
- *
236
- * @type {Readonly<Record<string, {style: string, icon: string, label: string}>>}
237
- */
238
- export const DEFAULT_ICONS: Readonly<Record<string, {
239
- style: string;
240
- icon: string;
241
- label: string;
242
- }>>;
243
239
  /**
244
240
  * The shape a note writes, and the one this module claims.
245
241
  *
@@ -247,7 +243,7 @@ export const DEFAULT_ICONS: Readonly<Record<string, {
247
243
  * surface that also renders `:smile:` can tell the two apart without a lookup,
248
244
  * and a reader can tell what `:icon-star:` is without knowing this module
249
245
  * exists. Names are lowercase, digits and hyphens — the charset an address
250
- * segment already uses (#59), so nothing new has to be explained.
246
+ * segment already uses, so nothing new has to be explained.
251
247
  *
252
248
  * Not `:name[content]`. That is remark-directive syntax, and this toolchain
253
249
  * parses with markdown-it; a directive would render as its own literal text.
@@ -270,3 +266,54 @@ export const DEFAULT_ICONS: Readonly<Record<string, {
270
266
  * @type {RegExp}
271
267
  */
272
268
  export const ICON_PATTERN: RegExp;
269
+ /**
270
+ * A **family** is an icon font, and a consumer declares the ones it ships.
271
+ *
272
+ * Nothing here names Font Awesome, or Game-Icons, or any other font. A registry
273
+ * entry is a promise that a glyph will render, and only the package that ships
274
+ * the font can keep it: the Game-Icons webfont is built by a consumer from its
275
+ * own templates, and even Font Awesome — which Foundry supplies in-app — is
276
+ * present on neither the knowledgebase nor the page of a book unless somebody
277
+ * puts it there. A toolchain that shipped a table would be promising on a
278
+ * consumer's behalf.
279
+ *
280
+ * The vocabulary is the consumer's for a second reason, independent of fonts. A
281
+ * name like `victory-star-tester` is one game system's concept; another system
282
+ * compiled by this same toolchain has different icons meaning different things.
283
+ * What is shared is the *mechanism* — the syntax, the resolution, the checks —
284
+ * and that is what lives here.
285
+ *
286
+ * A family declares:
287
+ *
288
+ * - `class` — the prefix its stylesheet uses (`fa`, `ginf`, `bi`).
289
+ * - `styles` — the weights it ships, in the spelling its classes use. An empty
290
+ * list means the font has none, and then a `style` on an entry names
291
+ * something that does not exist and is reported rather than rendered.
292
+ * - `describe` — one line, so a finding can say which font it means.
293
+ */
294
+ export type IconFamily = {
295
+ /**
296
+ * - The stylesheet's class prefix.
297
+ */
298
+ class: string;
299
+ /**
300
+ * - The weights it ships; empty for none.
301
+ */
302
+ styles: readonly string[];
303
+ /**
304
+ * - One line, for a finding.
305
+ */
306
+ describe: string;
307
+ };
308
+ /**
309
+ * A resolved registry: the families a package ships, and the icons it names.
310
+ *
311
+ * `defaultFamily` is what an entry that names none belongs to. It is optional,
312
+ * and where a package declares exactly one family that one is it — so a
313
+ * single-font package writes no `family` anywhere.
314
+ */
315
+ export type IconRegistry = {
316
+ families: Readonly<Record<string, IconFamily>>;
317
+ defaultFamily: string | undefined;
318
+ icons: Readonly<Record<string, object>>;
319
+ };
@@ -91,21 +91,65 @@ export function asciiName(name: unknown): string | null;
91
91
  * a consumer iterating it should not have to check first.
92
92
  */
93
93
  export function asciiAliases(aliases: unknown): Array<string>;
94
+ /**
95
+ * Build one index record from a note's frontmatter and its place in the tree.
96
+ *
97
+ * The frontmatter as authored, plus what the index derives from it: the package
98
+ * it compiles as, its address, ASCII folds of its name and aliases, the anchors
99
+ * of its body, its Foundry block, the address of its documentation journal, and
100
+ * where the file sits within the tree.
101
+ *
102
+ * @param {object} options - Options.
103
+ * @param {Record<string, any>} options.frontmatter - The note's parsed frontmatter.
104
+ * @param {string} options.relPath - Its path below the content root, POSIX-separated.
105
+ * @param {string} [options.absPath] - The file, read only on the failing path to
106
+ * locate the offending key.
107
+ * @param {string} options.contentPackage - The package the tree compiles as.
108
+ * @param {string} [options.body] - The note's markdown body, for its anchors.
109
+ * @param {number} [options.bodyLine] - The 1-based file line the body starts on.
110
+ * @param {object} [options.manifest] - The package manifest, which the Foundry
111
+ * entries are derived against.
112
+ * @returns {Record<string, any>} The record, keys sorted at every depth.
113
+ * @throws {Error} When the note carries a key this module derives, which would
114
+ * otherwise be overwritten without a word. `file` and, where the file was
115
+ * read, `position` ride on the error.
116
+ */
94
117
  export function buildIndexRecord({ frontmatter, relPath, absPath, contentPackage, body, bodyLine, manifest, }: {
95
- frontmatter: any;
96
- relPath: any;
97
- absPath: any;
98
- contentPackage: any;
99
- body: any;
100
- bodyLine: any;
101
- manifest: any;
118
+ frontmatter: Record<string, any>;
119
+ relPath: string;
120
+ absPath?: string | undefined;
121
+ contentPackage: string;
122
+ body?: string | undefined;
123
+ bodyLine?: number | undefined;
124
+ manifest?: object | undefined;
102
125
  }): Record<string, any>;
103
- export function collectContentIndex(contentBase: any, { contentPackage, skipDirectories, manifest, problems }: {
104
- contentPackage: any;
105
- skipDirectories: any;
106
- manifest: any;
107
- problems: any;
108
- }): Record<string, any>[];
126
+ /**
127
+ * Read a content tree into index records, in the order they will be written.
128
+ *
129
+ * An item note yields two records — the item, and the documentation journal
130
+ * that is a document in its own right.
131
+ *
132
+ * @param {string} contentBase - The content tree to walk.
133
+ * @param {object} options - Options.
134
+ * @param {string} options.contentPackage - The package the tree compiles as.
135
+ * @param {readonly string[]} options.skipDirectories - The walk's scope, stated
136
+ * by the caller. An absent one is the caller's omission, and
137
+ * {@link module:engine/helpers.walkMarkdownTree} throws on it.
138
+ * @param {object} [options.manifest] - The package manifest, which the Foundry
139
+ * entries are derived against.
140
+ * @param {object[]} [options.problems] - Supplied by a **reader**: a note that
141
+ * cannot be recorded is pushed here as a diagnostic and skipped. Omitted, the
142
+ * note throws — the contract the emitter needs, since an index missing a note
143
+ * asserts that it does not exist.
144
+ * @returns {Array<Record<string, any>>} The records, in a total order that does
145
+ * not depend on directory-read order.
146
+ */
147
+ export function collectContentIndex(contentBase: string, { contentPackage, skipDirectories, manifest, problems }: {
148
+ contentPackage: string;
149
+ skipDirectories: readonly string[];
150
+ manifest?: object | undefined;
151
+ problems?: object[] | undefined;
152
+ }): Array<Record<string, any>>;
109
153
  /**
110
154
  * Serialize records as JSON Lines.
111
155
  *
@@ -120,7 +164,7 @@ export function serializeContentIndex(records: Array<Record<string, any>>): stri
120
164
  *
121
165
  * The half of {@link emitContentIndex} that derives rather than emits, so a
122
166
  * pass that needs the corpus in memory — a SQL content table, the link check,
123
- * and in time every reader #243 converts — builds it the same way the artifact
167
+ * and in time every converted reader — builds it the same way the artifact
124
168
  * is built, rather than by walking and parsing again with its own idea of the
125
169
  * scope.
126
170
  *
@@ -131,7 +175,7 @@ export function serializeContentIndex(records: Array<Record<string, any>>): stri
131
175
  * caller that resolved one of its own; defaults to the resolved
132
176
  * configuration's. Stated separately from `config` because a caller that was
133
177
  * *handed* a scope must be able to pass it on rather than have it silently
134
- * replaced by the one its configuration happens to carry (#243).
178
+ * replaced by the one its configuration happens to carry.
135
179
  * @param {object[]} [opts.problems] - Supplied by a **reader**: a note that
136
180
  * cannot be recorded is pushed here as a diagnostic and skipped, instead of
137
181
  * aborting the derivation. Omitted, the note throws — which is the contract