@heroiclands/package-build 20.3.1 → 20.4.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 (178) hide show
  1. package/CHANGELOG.md +75 -0
  2. package/CONTENT.md +111 -92
  3. package/README.md +2 -9
  4. package/bin/content-build.mjs +70 -61
  5. package/bin/package-build.mjs +2 -2
  6. package/config.mjs +6 -8
  7. package/content-config.mjs +187 -64
  8. package/docs/content-format.md +57 -68
  9. package/e2e.mjs +4 -4
  10. package/engine/actor-compiler.mjs +36 -36
  11. package/engine/address-charset.mjs +6 -6
  12. package/engine/address-diff.mjs +12 -11
  13. package/engine/anchored-sections.mjs +1 -1
  14. package/engine/anchors.mjs +1 -1
  15. package/engine/base-compiler.mjs +36 -38
  16. package/engine/bundle-notes.mjs +4 -4
  17. package/engine/bundles.mjs +8 -8
  18. package/engine/code-fences.mjs +3 -3
  19. package/engine/compendiums.mjs +8 -8
  20. package/engine/compile-corpus.mjs +4 -5
  21. package/engine/content-address.mjs +15 -15
  22. package/engine/content-charset.mjs +1 -1
  23. package/engine/content-format-check.mjs +24 -25
  24. package/engine/content-format.mjs +8 -8
  25. package/engine/content-html.mjs +202 -0
  26. package/engine/content-icons.mjs +196 -165
  27. package/engine/content-index.mjs +17 -17
  28. package/engine/content-links.mjs +30 -30
  29. package/engine/content-lint.mjs +20 -24
  30. package/engine/content-package.mjs +7 -9
  31. package/engine/content-slug.mjs +2 -2
  32. package/engine/content-tables.mjs +7 -8
  33. package/engine/content-tree.mjs +1 -1
  34. package/engine/derived-fields.mjs +174 -0
  35. package/engine/diagnostics.mjs +3 -4
  36. package/engine/document-subtypes.mjs +6 -7
  37. package/engine/field-reference.mjs +8 -8
  38. package/engine/field-spec.mjs +29 -30
  39. package/engine/folder-notes.mjs +14 -14
  40. package/engine/foreign-catalog.mjs +8 -9
  41. package/engine/foundry-entries.mjs +19 -20
  42. package/engine/frontmatter-lint.mjs +64 -69
  43. package/engine/frontmatter.mjs +11 -11
  44. package/engine/generate.mjs +39 -39
  45. package/engine/helpers.mjs +63 -54
  46. package/engine/homepage.mjs +20 -22
  47. package/engine/ids.mjs +15 -15
  48. package/engine/index-records.mjs +4 -4
  49. package/engine/index.mjs +14 -8
  50. package/engine/item-compiler.mjs +54 -29
  51. package/engine/item-docs.mjs +11 -13
  52. package/engine/item-registry.mjs +13 -13
  53. package/engine/journals.mjs +15 -15
  54. package/engine/macros.mjs +3 -3
  55. package/engine/map-notes.mjs +6 -6
  56. package/engine/metadata-index.mjs +5 -5
  57. package/engine/note-claims.mjs +36 -34
  58. package/engine/note-ids.mjs +5 -5
  59. package/engine/note-package.mjs +4 -4
  60. package/engine/note-renames.mjs +3 -3
  61. package/engine/note-schemas.mjs +3 -3
  62. package/engine/note-vocabulary.mjs +27 -26
  63. package/engine/pack-config.mjs +13 -13
  64. package/engine/pack-router.mjs +0 -0
  65. package/engine/prose-config.mjs +9 -9
  66. package/engine/prose-lint.mjs +12 -13
  67. package/engine/region-events.mjs +2 -2
  68. package/engine/retired-fields.mjs +24 -22
  69. package/engine/runtime-only-fields.mjs +1 -1
  70. package/engine/scene-levels.mjs +1 -1
  71. package/engine/scenes.mjs +19 -20
  72. package/engine/schema-check.mjs +20 -20
  73. package/engine/schema-extract.mjs +1 -1
  74. package/engine/site-build.mjs +45 -47
  75. package/engine/site-index.mjs +17 -18
  76. package/engine/sql-tables.mjs +21 -13
  77. package/engine/subtype-registry.mjs +5 -4
  78. package/engine/system-block.mjs +18 -19
  79. package/engine/systems.mjs +2 -2
  80. package/engine/web-wikilinks.mjs +35 -35
  81. package/engine/wikilink-syntax.mjs +16 -16
  82. package/engine/wikilinks.mjs +39 -39
  83. package/hm3/actors.mjs +22 -22
  84. package/hm3/document-subtypes.mjs +5 -5
  85. package/hm3/index.mjs +2 -2
  86. package/hm3/item-builders.mjs +1 -1
  87. package/hm3/item-fields.mjs +3 -3
  88. package/hm3/items.mjs +20 -8
  89. package/hm3/template-priority.mjs +2 -2
  90. package/lang.mjs +3 -3
  91. package/manifest.mjs +17 -20
  92. package/package.json +1 -2
  93. package/release.mjs +3 -3
  94. package/sohl/actors.mjs +28 -28
  95. package/sohl/affiliation-standings.mjs +2 -2
  96. package/sohl/being-info.mjs +5 -5
  97. package/sohl/default-item-art.mjs +5 -5
  98. package/sohl/document-subtypes.mjs +5 -5
  99. package/sohl/index.mjs +3 -3
  100. package/sohl/item-builders.mjs +7 -7
  101. package/sohl/item-fields.mjs +8 -9
  102. package/sohl/items.mjs +20 -6
  103. package/sohl/kb-passes.mjs +5 -5
  104. package/sohl/note-schemas.mjs +7 -7
  105. package/sohl/skill-base.mjs +1 -1
  106. package/types/content-config.d.mts +25 -24
  107. package/types/e2e.d.mts +3 -3
  108. package/types/engine/actor-compiler.d.mts +14 -13
  109. package/types/engine/address-charset.d.mts +6 -6
  110. package/types/engine/address-diff.d.mts +3 -3
  111. package/types/engine/base-compiler.d.mts +17 -19
  112. package/types/engine/bundle-notes.d.mts +3 -3
  113. package/types/engine/bundles.d.mts +1 -1
  114. package/types/engine/code-fences.d.mts +3 -3
  115. package/types/engine/compendiums.d.mts +3 -3
  116. package/types/engine/compile-corpus.d.mts +1 -1
  117. package/types/engine/content-address.d.mts +11 -11
  118. package/types/engine/content-format-check.d.mts +6 -6
  119. package/types/engine/content-format.d.mts +2 -2
  120. package/types/engine/content-html.d.mts +78 -0
  121. package/types/engine/content-icons.d.mts +139 -92
  122. package/types/engine/content-index.d.mts +2 -2
  123. package/types/engine/content-links.d.mts +8 -8
  124. package/types/engine/content-lint.d.mts +2 -2
  125. package/types/engine/content-package.d.mts +6 -8
  126. package/types/engine/derived-fields.d.mts +101 -0
  127. package/types/engine/diagnostics.d.mts +2 -2
  128. package/types/engine/document-subtypes.d.mts +3 -3
  129. package/types/engine/field-spec.d.mts +37 -39
  130. package/types/engine/folder-notes.d.mts +4 -5
  131. package/types/engine/foreign-catalog.d.mts +3 -3
  132. package/types/engine/foundry-entries.d.mts +6 -7
  133. package/types/engine/frontmatter-lint.d.mts +7 -7
  134. package/types/engine/frontmatter.d.mts +7 -7
  135. package/types/engine/generate.d.mts +7 -7
  136. package/types/engine/helpers.d.mts +25 -27
  137. package/types/engine/homepage.d.mts +16 -18
  138. package/types/engine/ids.d.mts +13 -13
  139. package/types/engine/index-records.d.mts +3 -3
  140. package/types/engine/index.d.mts +2 -0
  141. package/types/engine/item-compiler.d.mts +21 -5
  142. package/types/engine/item-docs.d.mts +2 -2
  143. package/types/engine/item-registry.d.mts +6 -6
  144. package/types/engine/journals.d.mts +3 -3
  145. package/types/engine/map-notes.d.mts +2 -2
  146. package/types/engine/metadata-index.d.mts +4 -4
  147. package/types/engine/note-claims.d.mts +16 -15
  148. package/types/engine/note-ids.d.mts +4 -4
  149. package/types/engine/note-package.d.mts +1 -1
  150. package/types/engine/note-renames.d.mts +3 -3
  151. package/types/engine/note-vocabulary.d.mts +9 -8
  152. package/types/engine/pack-config.d.mts +3 -3
  153. package/types/engine/pack-router.d.mts +1 -1
  154. package/types/engine/prose-config.d.mts +9 -9
  155. package/types/engine/prose-lint.d.mts +3 -4
  156. package/types/engine/region-events.d.mts +2 -2
  157. package/types/engine/retired-fields.d.mts +10 -9
  158. package/types/engine/schema-check.d.mts +11 -11
  159. package/types/engine/site-build.d.mts +18 -19
  160. package/types/engine/site-index.d.mts +3 -4
  161. package/types/engine/sql-tables.d.mts +11 -5
  162. package/types/engine/subtype-registry.d.mts +3 -3
  163. package/types/engine/system-block.d.mts +3 -3
  164. package/types/engine/web-wikilinks.d.mts +7 -7
  165. package/types/engine/wikilink-syntax.d.mts +17 -17
  166. package/types/engine/wikilinks.d.mts +13 -12
  167. package/types/hm3/actors.d.mts +1 -1
  168. package/types/hm3/document-subtypes.d.mts +1 -1
  169. package/types/hm3/items.d.mts +1 -2
  170. package/types/hm3/template-priority.d.mts +1 -1
  171. package/types/manifest.d.mts +8 -8
  172. package/types/sohl/actors.d.mts +2 -2
  173. package/types/sohl/affiliation-standings.d.mts +2 -2
  174. package/types/sohl/being-info.d.mts +2 -2
  175. package/types/sohl/document-subtypes.d.mts +1 -1
  176. package/types/sohl/items.d.mts +1 -2
  177. package/types/sohl/note-schemas.d.mts +1 -1
  178. package/MIGRATING.md +0 -608
@@ -13,7 +13,7 @@
13
13
 
14
14
  /**
15
15
  * The package homepage — a note that compiles to a **page** rather than to a
16
- * compendium document (#51).
16
+ * compendium document.
17
17
  *
18
18
  * Every HeroicLands package is reachable at `https://www.heroiclands.org/<contentPackage>/`,
19
19
  * and what a reader finds there is one markdown file in the content tree,
@@ -49,11 +49,11 @@
49
49
  *
50
50
  * **Addressed like every other note.** A homepage declares a `shortcode` —
51
51
  * conventionally {@link HOMEPAGE_SHORTCODE} — and publishes at its address,
52
- * `/<package>/<type>-<shortcode>/`, written by the same rule as everything else
53
- * (#182). It used to publish at `/<package>/` from a fixed destination, and
52
+ * `/<package>/<type>-<shortcode>/`, written by the same rule as everything else.
53
+ * It used to publish at `/<package>/` from a fixed destination, and
54
54
  * that is why it refused `name` and `shortcode`: a URL derived from `name.full`
55
55
  * while the destination did not, so `[[homepage-<shortcode>]]` resolved *green*
56
- * to a page nothing wrote. A page's URL is its address now (#181), so the
56
+ * to a page nothing wrote. A page's URL is its address now, so the
57
57
  * computed address is the published one and there is nothing left to refuse.
58
58
  * The package's own `/<package>/` becomes a redirect its repository authors —
59
59
  * see `CONTENT.md` — rather than a page this build writes.
@@ -108,7 +108,7 @@ export const HOMEPAGE_SHORTCODE = "root";
108
108
  * The file a homepage is written to, relative to the package's site root.
109
109
  *
110
110
  * Its **address**, flat at the package root, and stated in the page's own `url`
111
- * — the same separation every other page has since #181, where the directory
111
+ * — the same separation every other page has, where the directory
112
112
  * decides the Hugo section and the front matter decides the URL. Flat rather
113
113
  * than inside a `homepage/` section directory, because a homepage is not one of
114
114
  * a kind: a section holding exactly one page would publish a landing at
@@ -133,14 +133,14 @@ export function isHomepage(fm) {
133
133
  }
134
134
 
135
135
  /**
136
- * The top-level field a homepage refuses, and what it would decide (#53).
136
+ * The top-level field a homepage refuses, and what it would decide.
137
137
  *
138
- * **One field, where there used to be three.** `name` and `shortcode` were
138
+ * **One field rather than three.** `name` and `shortcode` are
139
139
  * refused because a page's URL derived from `name.full` while a homepage's
140
140
  * destination was fixed, so the address a `shortcode` computed named a page the
141
- * site build never wrote. A page's URL is its address now (#181) and a homepage
141
+ * site build never wrote. A page's URL is its address now and a homepage
142
142
  * publishes at its own, so both fields decide exactly what they decide
143
- * everywhere else and are permitted (#182).
143
+ * everywhere else and are permitted.
144
144
  *
145
145
  * `id` is untouched by that, and stays: it is the Foundry document id a
146
146
  * compendium UUID is built from, and a homepage compiles into no document.
@@ -153,7 +153,7 @@ export function isHomepage(fm) {
153
153
  * package-build release.
154
154
  *
155
155
  * `aliases` is deliberately not in the class: it is a **retired** field, refused
156
- * on every note whatever its type (#180), so it is answered there rather than
156
+ * on every note whatever its type, so it is answered there rather than
157
157
  * here.
158
158
  *
159
159
  * @type {ReadonlyMap<string, string>}
@@ -195,8 +195,8 @@ export const HOMEPAGE_REFUSED_FIELDS = Object.freeze(
195
195
  * **A refused field must be one the note *wrote*.** `resolveNoteId` fills
196
196
  * `fm.id` **in place** so every downstream reader sees one derived value —
197
197
  * deliberately, and documented as such — and this ran over the same object, so
198
- * a homepage that authors no `id` was told to delete one that is not there
199
- * (#319). Since the caller already owns the raw note text, it also answers
198
+ * a homepage that authors no `id` was told to delete one that is not there.
199
+ * Since the caller already owns the raw note text, it also answers
200
200
  * which keys the note actually declared; without an answer every key in `fm`
201
201
  * counts, which is the old behaviour and right for a caller holding authored
202
202
  * frontmatter only.
@@ -238,19 +238,17 @@ export function checkHomepageAddressFields(fm, { isAuthored } = {}) {
238
238
  }
239
239
 
240
240
  /**
241
- * Require exactly one homepage note in a content tree (#52).
241
+ * Require exactly one homepage note in a content tree.
242
242
  *
243
243
  * "Exactly one" is two rules, and they are **one severity** because they are
244
244
  * one defect: a package whose front page is not the page a person chose.
245
245
  *
246
246
  * - _None_ and the package serves nothing at `/<package>/`. That is the failure
247
- * #50 exists to prevent, and it is silent — the site build reports `wrote 0
247
+ * this exists to prevent, and it is silent — the site build reports `wrote 0
248
248
  * homepage(s)` and exits 0.
249
249
  * - _Two_ and it serves a page nobody chose. **This is a cardinality rule, and
250
- * since #182 it is only that.** It used to rest on the fixed destination
251
- * every homepage shared the second overwrote the first — so the address
252
- * rule enforced it as a side effect. A homepage is written at its own address
253
- * now, so two of them publish two pages and collide over nothing; the
250
+ * only that.** A homepage is written at its own address, so two of them
251
+ * publish two pages and collide over nothing; the
254
252
  * duplicate-address check catches only the pair that happen to share a
255
253
  * shortcode, and says nothing at all about a `homepage-root` beside a
256
254
  * `homepage-front`. Which of the two the redirect at `/<package>/` should
@@ -375,17 +373,17 @@ export function homepageTitle(fm, config) {
375
373
  *
376
374
  * The note's own, plus the derived values every emitted page carries: the
377
375
  * resolved `title`, the package the build derived — no note declares one
378
- * (`package:` is retired, #56) and the theme's breadcrumb partial reads
376
+ * (`package:` is retired) and the theme's breadcrumb partial reads
379
377
  * `.Params.package` — and its **address**.
380
378
  *
381
379
  * The address is stated as `url` for the same reason every other page states
382
- * one (#181): Hugo publishes a page where its file sits unless told otherwise,
380
+ * one: Hugo publishes a page where its file sits unless told otherwise,
383
381
  * and a homepage's file sits at the package's site root. `slug` is written
384
382
  * beside it because it is the last segment of that address and Hugo's own key
385
383
  * for one; it decides nothing while `url` is present, but a page carrying only
386
384
  * `url` would report a slug Hugo had inferred from the filename.
387
385
  *
388
- * **Site-root relative, and so carrying no package base** (#217), exactly as
386
+ * **Site-root relative, and so carrying no package base**, exactly as
389
387
  * `pageFrontmatter` states a content page's: Hugo resolves a `url`
390
388
  * against `baseURL`, whose path is already where the package is served, so a
391
389
  * stated base was written twice and published the landing at
@@ -394,7 +392,7 @@ export function homepageTitle(fm, config) {
394
392
  *
395
393
  * An authored `aliases` is dropped for the same reason it is on every other
396
394
  * page: Hugo reads it as URL redirects, so passing it through would publish a
397
- * redirect stub at each one. The field is retired (#180) and refused before a
395
+ * redirect stub at each one. The field is retired and refused before a
398
396
  * build reaches here, which makes this a guard rather than a working path.
399
397
  *
400
398
  * @param {object} fm - The note's frontmatter.
package/engine/ids.mjs CHANGED
@@ -40,8 +40,8 @@ export function makeId(namespace, value) {
40
40
  }
41
41
 
42
42
  /**
43
- * Every content type that compiles into a Foundry `Scene` — a **map note**
44
- * (#1525). The three differ only in derived canvas defaults, which is the map
43
+ * Every content type that compiles into a Foundry `Scene` — a **map note**.
44
+ * The three differ only in derived canvas defaults, which is the map
45
45
  * compiler's business; everything else treats them alike.
46
46
  *
47
47
  * Declared in this leaf module because several passes that must not depend on
@@ -56,7 +56,7 @@ export const MAP_TYPES = Object.freeze(new Set(["map"]));
56
56
  /**
57
57
  * The map subTypes, which differ only in the canvas defaults derived for them.
58
58
  *
59
- * They were three *types* until #174, which cost three entries in the pack
59
+ * As three *types* they would cost three entries in the pack
60
60
  * router, three in the claims set and three in every consumer's section config
61
61
  * — for one idea that the specification had always described as one type.
62
62
  *
@@ -74,8 +74,8 @@ export const MAP_SUBTYPES = Object.freeze(["battlemap", "localmap", "regionalmap
74
74
  * addressed as `<type>` and `doc<type>`. These are one, so there is no
75
75
  * `docplace` and nothing synthesizes one.
76
76
  *
77
- * `doc` was the only member until #241. `place`, `lore` and `scenario` are in
78
- * the published content format and were declared for validation in #233, but
77
+ * `doc` was the only member until. `place`, `lore` and `scenario` are in
78
+ * the published content format and are declared for validation, but
79
79
  * nothing routed them: a note of one lint-ed clean and then compiled into
80
80
  * nothing, because {@link PACK_BY_TYPE} did not name it and the open-set
81
81
  * default sent it to the items pack. `sohl-thalorna` could not compile a single
@@ -95,7 +95,7 @@ export const JOURNAL_TYPES = Object.freeze(new Set(["doc", "place", "lore", "sce
95
95
  * building and not of the content: the same notes compiled by a different
96
96
  * repository belong to a different package. Baking the package into these
97
97
  * values is what made every link emitted by `sohl-thalorna` address the `sohl`
98
- * system (#1498) — correct here only by coincidence.
98
+ * system — correct here only by coincidence.
99
99
  *
100
100
  * @type {Readonly<Record<string, {pack: string, docType: string}>>}
101
101
  */
@@ -106,7 +106,7 @@ export const PACK_BY_TYPE = Object.freeze({
106
106
  macro: { pack: "macros", docType: "Macro" },
107
107
  being: { pack: "actors", docType: "Actor" },
108
108
  // A bundle is Foundry's `Adventure` — a set of document *copies* packaged
109
- // for one-shot import (#259). The conventional name is `adventures`, which
109
+ // for one-shot import. The conventional name is `adventures`, which
110
110
  // is also what the scenes pass calls its **companion**; the two are
111
111
  // different packs and a repository shipping both names them apart, since
112
112
  // the router refuses a note that addresses a companion.
@@ -120,7 +120,7 @@ export const PACK_BY_TYPE = Object.freeze({
120
120
  * Content types that no longer exist, and what replaced each one.
121
121
  *
122
122
  * `character` and `creature` were retired in favour of the single `being` they
123
- * had always compiled into (SoHL#1580). They are recorded here rather than
123
+ * had always compiled into. They are recorded here rather than
124
124
  * simply deleted because deleting them is the one change that fails *quietly*:
125
125
  * every type not named in {@link PACK_BY_TYPE} falls through to the open item
126
126
  * set below, so a note or a link left on the old spelling would be routed to
@@ -137,7 +137,7 @@ export const RETIRED_TYPES = Object.freeze({
137
137
  character: "being",
138
138
  creature: "being",
139
139
  // The three map spellings, retired in favour of the single `map` whose
140
- // subType they became (#174). Recorded rather than deleted for the same
140
+ // subType they became. Recorded rather than deleted for the same
141
141
  // reason as the two above: an unnamed type falls through to the open item
142
142
  // set, so a note or link left on one would be routed to the items pack.
143
143
  battlemap: "map",
@@ -178,7 +178,7 @@ export function assertTypeNotRetired(type, where) {
178
178
  * old one compiles into exactly the document it always did: refusing it would
179
179
  * fail a build over a note that is not wrong.
180
180
  *
181
- * So these retire in the three steps `package:` took (#56), and this table is
181
+ * So these retire in the three steps `package:` took, and this table is
182
182
  * the **first**: both spellings resolve, the current one is canonical, and the
183
183
  * retired one is *reported* — never refused. The sweep of the content trees and
184
184
  * the refusal come after, once no tree writes the old name. That is the same
@@ -186,7 +186,7 @@ export function assertTypeNotRetired(type, where) {
186
186
  * reason: a consumer must be able to adopt the new toolchain before its content
187
187
  * moves, and there are some 31,000 references to move.
188
188
  *
189
- * **Why these three, and why the other way round now.** #78 renamed
189
+ * **Why these three, and why this way round.** The specification renamed
190
190
  * `armorgear`, `concoctiongear` and `projectilegear` to `armor`, `concoction`
191
191
  * and `projectile`, on the argument that the suffix named the *SoHL document
192
192
  * subtype* a note compiled into rather than the thing the note is about. That
@@ -283,12 +283,12 @@ export const ITEM_PACK = Object.freeze({ pack: "items", docType: "Item" });
283
283
  * Item types are the open set — a new one is added whenever the system grows a
284
284
  * document type — so they are the **default** rather than an enumerated list. A
285
285
  * hand-maintained list is what made an entire content directory silently
286
- * unlinkable once (#1276); nothing to maintain, nothing to forget.
286
+ * unlinkable once; nothing to maintain, nothing to forget.
287
287
  *
288
288
  * The `docType` is the authority: it is a property of the *content type* and
289
289
  * holds however a repository names or splits its packs. The `pack` is the
290
290
  * conventional name only — a repository may rename its packs, or ship several
291
- * of one type (#1566), in which case the pack a particular note's document
291
+ * of one type, in which case the pack a particular note's document
292
292
  * lands in comes from `engine/pack-router.mjs` and is passed to
293
293
  * {@link compendiumUuid} explicitly. This module stays free of the
294
294
  * configuration so the link resolver above it can stay pure.
@@ -322,8 +322,8 @@ export function packForType(type) {
322
322
  * @param {string} id - The document's id.
323
323
  * @param {string} [packName] - The pack the document actually landed in, from
324
324
  * the pack router. Supplied wherever the note is known, because a repository
325
- * may ship several packs of one type and a UUID carries the pack name
326
- * (#1566). Omitted only where there is no note to route — the conventional
325
+ * may ship several packs of one type and a UUID carries the pack name.
326
+ * Omitted only where there is no note to route — the conventional
327
327
  * name from {@link packForType} then stands in.
328
328
  * @returns {string} `Compendium.<packageId>.<pack>.<DocumentType>.<id>`
329
329
  */
@@ -13,7 +13,7 @@
13
13
 
14
14
  /**
15
15
  * The shape of a content-index record, and the accessors every reader of one
16
- * needs (#243).
16
+ * needs.
17
17
  *
18
18
  * **Why these live apart from the index that builds them.** Deriving records
19
19
  * reaches the pack router and the manifest emitter, and those reach the
@@ -38,7 +38,7 @@ import path from "node:path";
38
38
  * carry itself.
39
39
  *
40
40
  * `package` is the note's distribution unit — the configured `contentPackage`,
41
- * since a note declaring its own is a hard error (#56) — and it matches what
41
+ * since a note declaring its own is a hard error — and it matches what
42
42
  * the content-table expander puts on the same field, so a query reads the same
43
43
  * value from either. `file` namespaces the note's place in the tree, again
44
44
  * matching the expander's `file.*`.
@@ -69,9 +69,9 @@ export const DERIVED_KEYS = Object.freeze([
69
69
  * the machine that built the index, would differ between two checkouts of the
70
70
  * same tree, and would put someone's home directory in a published artifact. So
71
71
  * every pass that reads the index and then needs to open a note has to compose
72
- * the absolute form, and each of the readers converted for #243 had written its
72
+ * the absolute form, and each converted reader had written its
73
73
  * own `path.join(base, ...record.file.path.split("/"))`. Four copies of one
74
- * rule is what #243 exists to remove, so here it is once.
74
+ * rule is what this exists to remove, so here it is once.
75
75
  *
76
76
  * The split is on `"/"` rather than `path.sep` because the recorded path is
77
77
  * always POSIX — that is what makes the index identical on every platform.
package/engine/index.mjs CHANGED
@@ -19,7 +19,7 @@
19
19
  * The content walk, frontmatter parsing, table generation, wikilink
20
20
  * resolution, id and folder derivation, the link manifest and the web-address
21
21
  * rule, `BasePackCompiler`, and the generic Foundry document compilers
22
- * (journals, macros, scenes) all live here (#1512).
22
+ * (journals, macros, scenes) all live here.
23
23
  *
24
24
  * **Each module is re-exported as its own namespace, not flattened.** Several
25
25
  * of them deliberately re-export a neighbour's symbol so a caller keeps one
@@ -51,13 +51,13 @@ export * as contentTree from "./content-tree.mjs";
51
51
  /** The consuming repository's resolved `package-build.config.yaml`. */
52
52
  export * as packConfig from "./pack-config.mjs";
53
53
 
54
- /** Which pack of a document type a note's document lands in (#1566). */
54
+ /** Which pack of a document type a note's document lands in. */
55
55
  export * as packRouter from "./pack-router.mjs";
56
56
 
57
- /** Which note types a configuration compiles, and the notes nothing claims (#146). */
57
+ /** Which note types a configuration compiles, and the notes nothing claims. */
58
58
  export * as noteClaims from "./note-claims.mjs";
59
59
 
60
- /** Folders as notes: the address index, the parent chain, and the emitted `Folder` (#256). */
60
+ /** Folders as notes: the address index, the parent chain, and the emitted `Folder`. */
61
61
  export * as folderNotes from "./folder-notes.mjs";
62
62
 
63
63
  /** The content package a build compiles, and the Foundry package it ships in. */
@@ -72,6 +72,9 @@ export * as retiredFields from "./retired-fields.mjs";
72
72
  /** Schema fields a note may never declare, because play writes them. */
73
73
  export * as runtimeOnlyFields from "./runtime-only-fields.mjs";
74
74
 
75
+ /** `system` keys a note may never declare, because the compiler derives them. */
76
+ export * as derivedFields from "./derived-fields.mjs";
77
+
75
78
  /** The package homepage: the note type that compiles to a page, not a document. */
76
79
  export * as homepage from "./homepage.mjs";
77
80
 
@@ -95,13 +98,13 @@ export * as contentAddress from "./content-address.mjs";
95
98
  /** Which note-type → document-subtype maps this toolchain ships. */
96
99
  export * as subtypeRegistry from "./subtype-registry.mjs";
97
100
 
98
- /** The id a note's document is filed under: its pin, or its address (#270). */
101
+ /** The id a note's document is filed under: its pin, or its address. */
99
102
  export * as noteIds from "./note-ids.mjs";
100
103
 
101
- /** The shortcodes a note declares it used to be published under (#278). */
104
+ /** The shortcodes a note declares it used to be published under. */
102
105
  export * as noteRenames from "./note-renames.mjs";
103
106
 
104
- /** The published content index packages exchange addresses through (#239). */
107
+ /** The published content index packages exchange addresses through. */
105
108
  export * as metadataIndex from "./metadata-index.mjs";
106
109
 
107
110
  /** Deriving this package's own link manifest from its content tree. */
@@ -122,6 +125,9 @@ export * as contentCharset from "./content-charset.mjs";
122
125
  /** Naming an interface icon in a note, without drawing one there. */
123
126
  export * as contentIcons from "./content-icons.mjs";
124
127
 
128
+ /** Raw HTML in a note's prose, which no book renderer can read. */
129
+ export * as contentHtml from "./content-html.mjs";
130
+
125
131
  /** Resolving every link in a tree, and the ones that land nowhere. */
126
132
  export * as contentLinks from "./content-links.mjs";
127
133
 
@@ -185,7 +191,7 @@ export * as compendiums from "./compendiums.mjs";
185
191
  // The region-event vocabulary stays flat as well as namespaced: the Foundry
186
192
  // runtime imports these three by name through
187
193
  // `@heroiclands/package-build/engine/region-events`, and they were part of this
188
- // barrel's surface before the pipeline arrived (#1510).
194
+ // barrel's surface before the pipeline arrived.
189
195
  export {
190
196
  CURATED_REGION_EVENTS,
191
197
  EXCLUDED_REGION_EVENTS,
@@ -14,7 +14,7 @@
14
14
  /**
15
15
  * **The Item pass, for any system** — everything about compiling a note into a
16
16
  * Foundry Item that is a fact about the *note format* rather than about a
17
- * particular game system (#139).
17
+ * particular game system.
18
18
  *
19
19
  * `sohl/items.mjs` was the whole of it, and every system-specific thing in it
20
20
  * was reached through one module-level constant read off SoHL's map. That is
@@ -55,24 +55,24 @@ import { foundryPackageId } from "./content-package.mjs";
55
55
  import { itemDocEntryId, itemDocPointer } from "./item-docs.mjs";
56
56
  // The whitelist and the per-type `system` builders both come from the resolved
57
57
  // configuration, so the types this pass claims and the builders it compiles
58
- // them with are one table — the consuming repository's, not this package's
59
- // (#1504/#1563).
58
+ // them with are one table — the consuming repository's, not this package's.
60
59
  import { itemTypes, itemBuilder, itemArt, itemFields } from "./item-registry.mjs";
61
60
  import { currentType } from "./ids.mjs";
62
61
  // Which Foundry Item subtype a note's `type` compiles into. Looked up in the
63
- // system's declared map, never inferred from the type itself (#79).
62
+ // system's declared map, never inferred from the type itself.
64
63
  import { documentSubtype, subtypeRow } from "./document-subtypes.mjs";
65
64
  // The note-level `<system>:` block: `<system>.system` onto the document's
66
65
  // `system` verbatim, and `<system>.img` / `.effects` / `.flags` overriding
67
- // their shared top-level forms for this system alone (#58).
66
+ // their shared top-level forms for this system alone.
68
67
  import { blockField, blockProperty, claimedPaths, mergeSystemData } from "./system-block.mjs";
69
68
  // The other direction of the same declaration: a field the *document* writes in
70
- // play, which a note may not author and the builder does not emit (#330).
69
+ // play, which a note may not author and the builder does not emit.
70
+ import { assertNoDerivedFields } from "./derived-fields.mjs";
71
71
  import { assertNoRuntimeOnlyFields } from "./runtime-only-fields.mjs";
72
72
 
73
73
  /**
74
74
  * The description an item carries: a pointer to its **item doc**, the
75
- * JournalEntry the journals pass compiles this same body into (#1348).
75
+ * JournalEntry the journals pass compiles this same body into.
76
76
  *
77
77
  * The prose is not rendered into the item at all. Carrying it would duplicate
78
78
  * it onto every actor holding the item — 7.59 MB of copies across the actors
@@ -112,7 +112,7 @@ export class SystemItemCompiler extends BasePackCompiler {
112
112
 
113
113
  /**
114
114
  * An Item **is** a system's data, so this pack takes only notes carrying
115
- * this system's block (#58).
115
+ * this system's block.
116
116
  */
117
117
  static requiresSystemBlock = true;
118
118
 
@@ -168,10 +168,10 @@ export class SystemItemCompiler extends BasePackCompiler {
168
168
  /**
169
169
  * Every content type that compiles into an item **for this system**.
170
170
  *
171
- * The whitelist is the consuming repository's `itemBuilders` keys (#1504),
171
+ * The whitelist is the consuming repository's `itemBuilders` keys,
172
172
  * and the system's own map is a second filter on top of it: a type this
173
173
  * system maps onto some *other* document class is not an item however a
174
- * registry spells it, which is the "no wrongly-typed document" half of #79.
174
+ * registry spells it, which is the "no wrongly-typed document" half of.
175
175
  * A type the map does not name at all is left to the registry — see
176
176
  * {@link SystemItemCompiler#itemSubtype}.
177
177
  *
@@ -181,7 +181,7 @@ export class SystemItemCompiler extends BasePackCompiler {
181
181
  selects(fm) {
182
182
  // Through {@link currentType}: the registry is keyed by the current
183
183
  // spelling, and a note still on a renamed one compiles unchanged
184
- // during the retirement window (#78).
184
+ // during the retirement window.
185
185
  if (!fm.type || !itemTypes().has(currentType(fm.type))) return false;
186
186
  const map = /** @type {typeof SystemItemCompiler} */ (this.constructor).documentSubtypes;
187
187
  const row = subtypeRow(/** @type {never} */ (map), fm.type);
@@ -189,16 +189,36 @@ export class SystemItemCompiler extends BasePackCompiler {
189
189
  }
190
190
 
191
191
  /**
192
- * Refuse a note authoring one of its type's **runtime-only** fields (#330).
192
+ * The `system` keys this pass writes for itself, and where each is read
193
+ * from.
193
194
  *
194
- * A schema declares fields the document writes for itself an affliction's
195
- * `onsetDate` is the world time its onset fired at and a note authoring
196
- * one used to compile, because `<system>.system` is a verbatim passthrough
197
- * and the field really is in the schema. The result was shipped content
198
- * carrying one world's play state, with the build reporting success.
195
+ * A note authoring one is refused, because the compiler writes the key
196
+ * unconditionally: the authored value is overwritten, or survives as the
197
+ * wrong type in a shipped document. Declared here rather than named in the
198
+ * refusal so that a second system states its own see
199
+ * {@link module:engine/derived-fields}.
199
200
  *
200
- * The declaration says which, so nothing here knows a field name; see
201
- * {@link module:engine/runtime-only-fields}.
201
+ * @type {readonly {key: string, from: string}[]}
202
+ */
203
+ static derivedSystemKeys = Object.freeze([]);
204
+
205
+ /**
206
+ * Refuse a note authoring a field it may not write.
207
+ *
208
+ * Two rules, which differ in where the value would have come from:
209
+ *
210
+ * - **Runtime-only.** A schema declares fields the document writes for
211
+ * itself — an affliction's `onsetDate` is the world time its onset fired
212
+ * at. A note authoring one compiles, because `<system>.system` is a
213
+ * verbatim passthrough and the field really is in the schema, and the
214
+ * result is shipped content carrying one world's play state with the
215
+ * build reporting success.
216
+ * - **Derived.** This pass writes some keys from the note itself, so an
217
+ * authored one is overwritten or ships the wrong type.
218
+ *
219
+ * Both declarations say which fields, so nothing here knows a field name;
220
+ * see {@link module:engine/runtime-only-fields} and
221
+ * {@link module:engine/derived-fields}.
202
222
  *
203
223
  * @param {object} fm - The note's frontmatter.
204
224
  * @returns {void}
@@ -209,6 +229,11 @@ export class SystemItemCompiler extends BasePackCompiler {
209
229
  block: this.system,
210
230
  absPath: this.currentNote?.absPath,
211
231
  });
232
+ assertNoDerivedFields(
233
+ fm,
234
+ /** @type {typeof SystemItemCompiler} */ (this.constructor).derivedSystemKeys,
235
+ { block: this.system, absPath: this.currentNote?.absPath },
236
+ );
212
237
  }
213
238
 
214
239
  /**
@@ -217,7 +242,7 @@ export class SystemItemCompiler extends BasePackCompiler {
217
242
  * **Looked up, not inferred.** For every type this system declares, the
218
243
  * emitted subtype is the map's, so the note vocabulary and the document
219
244
  * vocabulary are two separately-stated things rather than one string
220
- * written twice (#79).
245
+ * written twice.
221
246
  *
222
247
  * **A type the map does not name belongs to the consumer**, and its
223
248
  * registry entry is the declaration: a repository shipping an item type of
@@ -226,7 +251,7 @@ export class SystemItemCompiler extends BasePackCompiler {
226
251
  * subtype of. That is an authored statement in the consumer's own
227
252
  * configuration, not a coincidence inside this package's source — and
228
253
  * refusing it here would silently drop every document of a type this system
229
- * has no opinion about (#7/#1563).
254
+ * has no opinion about.
230
255
  *
231
256
  * @param {object} fm - The note's frontmatter.
232
257
  * @returns {string} The document's `type`.
@@ -251,7 +276,7 @@ export class SystemItemCompiler extends BasePackCompiler {
251
276
  * Nothing by default, which is the honest position for a system that has
252
277
  * not said otherwise: a key written here lands on every document of every
253
278
  * type, so inventing one that the receiving DataModel does not declare
254
- * would be a finding on the whole pack (#155).
279
+ * would be a finding on the whole pack.
255
280
  *
256
281
  * @param {object} fm - The note's frontmatter.
257
282
  * @param {object} at - What the pass already knows about this note.
@@ -278,7 +303,7 @@ export class SystemItemCompiler extends BasePackCompiler {
278
303
  * field for it and an undeclared `system` key is discarded at load without
279
304
  * a word.
280
305
  *
281
- * **This is the one emitted key nothing else can check** (#283). A `system`
306
+ * **This is the one emitted key nothing else can check**. A `system`
282
307
  * key this pass invents is caught by the emitted-`system` check against the
283
308
  * receiving schema, but a flag is declared by no schema — so an omission
284
309
  * here is silent, and was: the Actor pass wrote the priority and this one
@@ -313,14 +338,14 @@ export class SystemItemCompiler extends BasePackCompiler {
313
338
  // Whatever the note authors under `<system>.system`, at the DataModel's
314
339
  // own paths. A path a declared field already writes is left to that
315
340
  // field: its value came from the same authored place and went through
316
- // the field's own coercion (#58).
341
+ // the field's own coercion.
317
342
  mergeSystemData(built, fm, {
318
343
  block: system,
319
344
  claimed: claimedPaths(itemFields(type, system)),
320
345
  });
321
346
  this.reportUndeclaredSystemData(fm, system, "Item", subType);
322
347
  // And what *this* pass wrote on its own initiative, which no field
323
- // declaration states and so no other check can see (#155). Read off the
348
+ // declaration states and so no other check can see. Read off the
324
349
  // assembled block, so a key added to `commonSystem` is checked without
325
350
  // anyone remembering to list it.
326
351
  this.reportEmittedSystemData(built, {
@@ -336,7 +361,7 @@ export class SystemItemCompiler extends BasePackCompiler {
336
361
  // Read through the system block like every other item field. There is
337
362
  // one spelling: `packFolder` names a folder note by its address, the
338
363
  // `folder:` id spelling having been retired with the per-pack YAML it
339
- // resolved against (#251, #255, #260).
364
+ // resolved against.
340
365
  const folder = this.folderResolver(blockField(fm, system, "packFolder", null), {
341
366
  isAddress: true,
342
367
  });
@@ -345,9 +370,9 @@ export class SystemItemCompiler extends BasePackCompiler {
345
370
  name,
346
371
  // The note's `type` addresses the builder and the default art —
347
372
  // both registries are keyed by content type — while the document's
348
- // own subtype comes from the system's map (#79).
373
+ // own subtype comes from the system's map.
349
374
  type: subType,
350
- // Nullish, not `||` (#218): `resolveImg` returns `null` for a
375
+ // Nullish, not `||`: `resolveImg` returns `null` for a
351
376
  // note that names no art and `""` for one that wants none, and only
352
377
  // the first may be replaced by the type's default.
353
378
  img: resolveImg(blockProperty(fm, system, "img")) ?? itemArt(type, system),
@@ -355,7 +380,7 @@ export class SystemItemCompiler extends BasePackCompiler {
355
380
  system: built,
356
381
  effects: Array.isArray(effects) ? [...effects] : [],
357
382
  // Whatever the note authors, plus whatever this system records in
358
- // flags because its data model has nowhere else for it (#283).
383
+ // flags because its data model has nowhere else for it.
359
384
  flags: this.commonFlags(fm),
360
385
  _stats: this.stats,
361
386
  ownership: { default: 0 },
@@ -18,13 +18,13 @@
18
18
  * An item note's body describes what the thing *is*. That is documentation, and
19
19
  * documentation belongs in the journals pack, so each item note compiles into a
20
20
  * JournalEntry and the item's `system.docHtml` becomes nothing but a `@UUID`
21
- * link to that entry's first page — the description-as-pointer convention
22
- * (#1356), which {@link sohl.utils.descriptionLinkTarget} recognises and
21
+ * link to that entry's first page — the description-as-pointer convention,
22
+ * which {@link sohl.utils.descriptionLinkTarget} recognises and
23
23
  * Display Description follows.
24
24
  *
25
25
  * The prose then exists once. Previously every actor carrying an item carried
26
26
  * its own copy of that item's description: 7.59 MB across the actors pack, of
27
- * which only 133 KB was distinct text (#1348). Nothing about actors changes —
27
+ * which only 133 KB was distinct text. Nothing about actors changes —
28
28
  * they embed whatever the item carries, and what the item carries is now a link.
29
29
  *
30
30
  * **Two passes, no shared state.** The items pass writes the pointer; the
@@ -34,9 +34,9 @@
34
34
  *
35
35
  * **The shape generalises.** A `macro` note is the same arrangement: it
36
36
  * compiles into a Macro, and its prose into a JournalEntry addressed
37
- * `docmacro/<shortcode>` (#1514). So is a **map note**, which compiles into a
38
- * Scene and whose prose becomes the place description its map pins point at
39
- * (#1525). {@link docEntryTypes} is the one set both the compilers and the
37
+ * `docmacro/<shortcode>`. So is a **map note**, which compiles into a
38
+ * Scene and whose prose becomes the place description its map pins point at.
39
+ * {@link docEntryTypes} is the one set both the compilers and the
40
40
  * link manifest read to know which types work this way.
41
41
  *
42
42
  * Plain ESM with no Foundry and no filesystem access, so it is unit-testable.
@@ -56,8 +56,7 @@ import { packRouter } from "./pack-router.mjs";
56
56
  *
57
57
  * It is the consuming repository's `itemBuilders` keys, resolved once in
58
58
  * `item-registry.mjs` alongside the builder lookup the Item compiler dispatches
59
- * through — one object, so the whitelist and the table cannot disagree
60
- * (#1504/#1563).
59
+ * through — one object, so the whitelist and the table cannot disagree.
61
60
  */
62
61
  export { itemTypes };
63
62
 
@@ -66,7 +65,7 @@ export { itemTypes };
66
65
  * addressed by the virtual `doc<type>` qualifier.
67
66
  *
68
67
  * Every item type, plus `macro` — a macro note's body documents the script the
69
- * note also compiles into a Macro (#1514), which is the same shape as an item
68
+ * note also compiles into a Macro, which is the same shape as an item
70
69
  * and its description: one note, two documents, the prose living in the
71
70
  * journals pack.
72
71
  *
@@ -102,7 +101,7 @@ export function hasDocEntry(type) {
102
101
  // registry's keys and those are the *current* spelling of a note type. A
103
102
  // note still on a renamed one carries its documentation journal exactly as
104
103
  // before — this is the one lookup between an item compiling and its prose
105
- // silently compiling into nothing (#78).
104
+ // silently compiling into nothing.
106
105
  return docEntryTypes().has(String(currentType(type)));
107
106
  }
108
107
 
@@ -136,7 +135,7 @@ export function itemDocEntryId(itemId) {
136
135
  * happens to contain a link, which the runtime would then show verbatim.
137
136
  *
138
137
  * @param {string} packageId - The Foundry package shipping the journals pack.
139
- * Supplied rather than assumed (#1498).
138
+ * Supplied rather than assumed.
140
139
  * @param {string} itemId - The item note's `id` frontmatter.
141
140
  * @param {string} name - The item's name, used as the link's label. It shows
142
141
  * only if the target ever fails to resolve, where a broken link naming the
@@ -147,8 +146,7 @@ export function itemDocEntryId(itemId) {
147
146
  */
148
147
  export function itemDocPointer(packageId, itemId, name, firstPageId) {
149
148
  // An item doc is a *derived* document: it lands in the default
150
- // JournalEntry pack whatever Item pack the item itself was routed to
151
- // (#1566).
149
+ // JournalEntry pack whatever Item pack the item itself was routed to.
152
150
  const entryUuid = compendiumUuid(
153
151
  packageId,
154
152
  "doc",