@heroiclands/package-build 22.21.0 → 22.23.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 (152) hide show
  1. package/CHANGELOG.md +223 -0
  2. package/assets/styles/content-base.css +162 -0
  3. package/bin/content-commands.mjs +77 -17
  4. package/bin/package-build.mjs +15 -2
  5. package/ci/content-format-reference.mjs +68 -1
  6. package/config.mjs +26 -0
  7. package/content-config.mjs +153 -6
  8. package/docs/api.md +120 -89
  9. package/docs/authoring/assets.md +14 -0
  10. package/docs/authoring/dates-and-calendars.md +41 -3
  11. package/docs/authoring/frontmatter.md +2 -2
  12. package/docs/authoring/links-and-markup.md +325 -35
  13. package/docs/commands.md +12 -10
  14. package/docs/configuration.md +117 -14
  15. package/docs/content-format.md +4 -2
  16. package/docs/guides/book.md +5 -4
  17. package/docs/guides/reference-pages.md +15 -0
  18. package/docs/reference/format-details.md +545 -104
  19. package/docs/reference/note-types.md +30 -13
  20. package/engine/actor-compiler.mjs +23 -0
  21. package/engine/anchored-sections.mjs +35 -4
  22. package/engine/anchors.mjs +26 -30
  23. package/engine/art-fields.mjs +118 -0
  24. package/engine/art-slots.mjs +7 -1
  25. package/engine/asset-index.mjs +160 -10
  26. package/engine/asset-replacement.mjs +93 -0
  27. package/engine/asset-types.mjs +240 -0
  28. package/engine/base-compiler.mjs +139 -22
  29. package/engine/base-styles.mjs +149 -0
  30. package/engine/bundles.mjs +13 -2
  31. package/engine/compendiums.mjs +8 -1
  32. package/engine/content-blocks.mjs +410 -0
  33. package/engine/content-embeds.mjs +19 -0
  34. package/engine/content-figures.mjs +468 -0
  35. package/engine/content-footnotes.mjs +197 -0
  36. package/engine/content-format-check.mjs +15 -12
  37. package/engine/content-format.yaml +1 -1
  38. package/engine/content-images.mjs +126 -25
  39. package/engine/content-index.mjs +38 -12
  40. package/engine/content-links.mjs +14 -6
  41. package/engine/content-tables.mjs +45 -4
  42. package/engine/content-tasklists.mjs +189 -0
  43. package/engine/docs-checks.mjs +4 -4
  44. package/engine/extension-attributes.mjs +48 -2
  45. package/engine/field-reference.mjs +31 -10
  46. package/engine/field-spec.mjs +10 -8
  47. package/engine/foreign-catalog.mjs +143 -18
  48. package/engine/frontmatter-lint.mjs +120 -65
  49. package/engine/frontmatter.mjs +3 -3
  50. package/engine/heading-attributes.mjs +321 -0
  51. package/engine/helpers.mjs +109 -41
  52. package/engine/homepage.mjs +8 -8
  53. package/engine/index.mjs +3 -0
  54. package/engine/infobox-registry.mjs +4 -1
  55. package/engine/infobox-render.mjs +15 -3
  56. package/engine/infobox.mjs +129 -15
  57. package/engine/itinerary-scenes.mjs +4 -10
  58. package/engine/journals.mjs +294 -50
  59. package/engine/lore-events.mjs +197 -0
  60. package/engine/macros.mjs +1 -1
  61. package/engine/markdown-expressions.mjs +434 -59
  62. package/engine/note-dates.mjs +354 -12
  63. package/engine/note-frontmatter.mjs +7 -16
  64. package/engine/note-vocabulary.mjs +183 -42
  65. package/engine/page-lists.mjs +358 -0
  66. package/engine/pathnames.mjs +36 -0
  67. package/engine/pdf-build.mjs +431 -74
  68. package/engine/pdf-images.mjs +64 -0
  69. package/engine/pdf-render.mjs +563 -66
  70. package/engine/rank-ladder.mjs +198 -0
  71. package/engine/reckoning-markers.mjs +1 -1
  72. package/engine/retired-fields.mjs +8 -13
  73. package/engine/scenes.mjs +26 -7
  74. package/engine/site-build.mjs +166 -23
  75. package/engine/site-config.mjs +10 -1
  76. package/engine/site-index.mjs +90 -3
  77. package/engine/site-preview.mjs +20 -7
  78. package/engine/social-ties.mjs +52 -14
  79. package/engine/sql-tables.mjs +66 -9
  80. package/engine/standings.mjs +89 -6
  81. package/engine/system-block.mjs +56 -30
  82. package/engine/web-wikilinks.mjs +48 -1
  83. package/hm3/actors.mjs +8 -5
  84. package/manifest.mjs +43 -24
  85. package/package.json +1 -1
  86. package/packagebuild-metadata.jsonl +13 -13
  87. package/sohl/actors.mjs +22 -99
  88. package/sohl/item-fields.mjs +5 -5
  89. package/sohl/items.mjs +1 -1
  90. package/sohl/note-schemas.mjs +11 -21
  91. package/types/config.d.mts +9 -0
  92. package/types/content-config.d.mts +48 -1
  93. package/types/engine/actor-compiler.d.mts +11 -0
  94. package/types/engine/anchored-sections.d.mts +24 -0
  95. package/types/engine/anchors.d.mts +9 -4
  96. package/types/engine/art-fields.d.mts +64 -0
  97. package/types/engine/asset-index.d.mts +43 -0
  98. package/types/engine/asset-replacement.d.mts +22 -0
  99. package/types/engine/asset-types.d.mts +18 -0
  100. package/types/engine/base-compiler.d.mts +19 -17
  101. package/types/engine/base-styles.d.mts +93 -0
  102. package/types/engine/content-blocks.d.mts +87 -0
  103. package/types/engine/content-embeds.d.mts +16 -0
  104. package/types/engine/content-figures.d.mts +101 -0
  105. package/types/engine/content-footnotes.d.mts +80 -0
  106. package/types/engine/content-format-check.d.mts +8 -6
  107. package/types/engine/content-images.d.mts +78 -12
  108. package/types/engine/content-index.d.mts +8 -2
  109. package/types/engine/content-tables.d.mts +12 -4
  110. package/types/engine/content-tasklists.d.mts +72 -0
  111. package/types/engine/extension-attributes.d.mts +22 -1
  112. package/types/engine/field-reference.d.mts +21 -0
  113. package/types/engine/field-spec.d.mts +20 -16
  114. package/types/engine/foreign-catalog.d.mts +39 -0
  115. package/types/engine/frontmatter.d.mts +1 -1
  116. package/types/engine/heading-attributes.d.mts +179 -0
  117. package/types/engine/helpers.d.mts +29 -10
  118. package/types/engine/homepage.d.mts +7 -7
  119. package/types/engine/index.d.mts +1 -0
  120. package/types/engine/infobox-registry.d.mts +4 -1
  121. package/types/engine/infobox-render.d.mts +6 -1
  122. package/types/engine/infobox.d.mts +6 -0
  123. package/types/engine/journals.d.mts +41 -12
  124. package/types/engine/lore-events.d.mts +14 -0
  125. package/types/engine/markdown-expressions.d.mts +46 -2
  126. package/types/engine/note-dates.d.mts +64 -1
  127. package/types/engine/note-frontmatter.d.mts +1 -4
  128. package/types/engine/note-vocabulary.d.mts +82 -6
  129. package/types/engine/page-lists.d.mts +126 -0
  130. package/types/engine/pathnames.d.mts +26 -0
  131. package/types/engine/pdf-build.d.mts +28 -6
  132. package/types/engine/pdf-images.d.mts +52 -0
  133. package/types/engine/pdf-render.d.mts +84 -2
  134. package/types/engine/rank-ladder.d.mts +32 -0
  135. package/types/engine/retired-fields.d.mts +4 -6
  136. package/types/engine/site-build.d.mts +27 -4
  137. package/types/engine/site-config.d.mts +9 -0
  138. package/types/engine/site-index.d.mts +67 -1
  139. package/types/engine/site-preview.d.mts +1 -1
  140. package/types/engine/sql-tables.d.mts +31 -7
  141. package/types/engine/standings.d.mts +21 -3
  142. package/types/engine/system-block.d.mts +37 -14
  143. package/types/engine/web-wikilinks.d.mts +3 -1
  144. package/types/hm3/actors.d.mts +21 -3
  145. package/types/manifest.d.mts +19 -23
  146. package/types/sohl/actors.d.mts +6 -7
  147. package/engine/content-admonitions.mjs +0 -114
  148. package/engine/content-captions.mjs +0 -181
  149. package/engine/content-secrets.mjs +0 -112
  150. package/types/engine/content-admonitions.d.mts +0 -24
  151. package/types/engine/content-captions.d.mts +0 -45
  152. package/types/engine/content-secrets.d.mts +0 -17
@@ -30,16 +30,28 @@ export function parseImageDirective(raw?: string): {
30
30
  problems: string[];
31
31
  };
32
32
  /**
33
- * The classes a figure carries, from a parsed directive.
33
+ * The class a picture's role names, or `""` for no role or one outside the
34
+ * closed set — the same silent-degrade rule every other unrecognised value
35
+ * here gets, since a role this far downstream has already been validated or
36
+ * dropped by the asset record that carries it.
34
37
  *
35
- * @param {{classes?: string[], size?: string, float?: string}} [directive] - As parsed.
38
+ * @param {string} [role] - The role, from the resolved asset record.
39
+ * @returns {string} The class, or `""`.
40
+ */
41
+ export function roleClass(role?: string): string;
42
+ /**
43
+ * The classes a figure carries, from a parsed directive and its asset's role.
44
+ *
45
+ * @param {{classes?: string[], size?: string, float?: string, role?: string}} [directive] -
46
+ * As parsed, plus the role the resolved asset record carries, if any.
36
47
  * @returns {string} A space-separated class list, always naming
37
48
  * {@link IMAGE_FIGURE_CLASS} first.
38
49
  */
39
- export function figureClasses({ classes, size, float }?: {
50
+ export function figureClasses({ classes, size, float, role }?: {
40
51
  classes?: string[];
41
52
  size?: string;
42
53
  float?: string;
54
+ role?: string;
43
55
  }): string;
44
56
  /**
45
57
  * Text going inside an HTML attribute or between tags.
@@ -55,28 +67,57 @@ export function escapeHtml(text: string): string;
55
67
  * function, so the two cannot drift into styling the same directive through
56
68
  * different class names.
57
69
  *
70
+ * **No `<figcaption>` is emitted here.** A `:::figure` fence draws its own
71
+ * label and authored caption around whatever this returns; the alt text stays
72
+ * on the `img` element alone.
73
+ *
74
+ * **The role class and the `width`/`height` attributes are what a stylesheet
75
+ * elsewhere keys a role's size on.** This module states none — the measure a
76
+ * `portrait` fills on a page is a Hugo theme's or a Foundry system's own
77
+ * decision — and emits only what the resolved asset record states: a role
78
+ * class when the picture declares one, and the attributes whenever the
79
+ * picture resolved to an asset record at all, blank for a vector. The
80
+ * attributes reserve the picture's own layout space before it loads, which is
81
+ * what lets a page avoid reflowing as pictures load in.
82
+ *
58
83
  * @param {object} image - The image.
59
84
  * @param {string} image.src - The address, resolved for the surface.
60
- * @param {string} [image.alt] - The alt text, which is also the caption.
85
+ * @param {string} [image.alt] - The alt text, for a reader who cannot see the
86
+ * picture.
61
87
  * @param {string[]} [image.classes] - Width classes, from the directive.
62
88
  * @param {string} [image.size] - Named display size, from the directive.
63
89
  * @param {string} [image.float] - The float position, from the directive.
90
+ * @param {string} [image.role] - The picture's declared role, from the
91
+ * resolved asset record.
92
+ * @param {number|""} [image.width] - The file's own pixel width, from the
93
+ * resolved asset record; `""` for a vector. Omitted entirely when the
94
+ * address resolved to no asset record at all.
95
+ * @param {number|""} [image.height] - As `width`.
64
96
  * @returns {string} The figure, as one HTML block.
65
97
  */
66
- export function imageFigureHtml({ src, alt, classes, size, float }: {
98
+ export function imageFigureHtml({ src, alt, classes, size, float, role, width, height, }: {
67
99
  src: string;
68
100
  alt?: string | undefined;
69
101
  classes?: string[] | undefined;
70
102
  size?: string | undefined;
71
103
  float?: string | undefined;
104
+ role?: string | undefined;
105
+ width?: number | "" | undefined;
106
+ height?: number | "" | undefined;
72
107
  }): string;
73
108
  /**
74
109
  * Whether a match sits alone in its own paragraph.
75
110
  *
76
- * "Alone" is the whole of a block: nothing else on its line, and a blank line
77
- * or the end of the body either side of it. A leading `>` or list marker
78
- * disqualifies it for the same reason a word does — the paragraph it belongs to
79
- * holds something the figure would have to be lifted out of.
111
+ * "Alone" is the whole of a block: nothing else on its line, and a blank line,
112
+ * a body-extension delimiter or the end of the body either side of it. A
113
+ * leading `>` or list marker disqualifies it for the same reason a word does —
114
+ * the paragraph it belongs to holds something the figure would have to be
115
+ * lifted out of.
116
+ *
117
+ * **A footnote reference trailing the match is not "other text."** `[^note]`
118
+ * annotates the picture rather than sitting beside it in prose, the same
119
+ * standing its own directive already has, so `![A ranger](r.webp)[^note]` is
120
+ * still alone.
80
121
  *
81
122
  * @param {string} text - The body the match indexes into.
82
123
  * @param {number} start - Where the match begins.
@@ -127,6 +168,9 @@ export function imageSourcesIn(body: string): string[];
127
168
  * @param {object} [opts]
128
169
  * @param {number} [opts.bodyLine=1] - The 1-based file line the body starts on.
129
170
  * @param {number} [opts.bodyColumn=1] - The 1-based file column it starts at.
171
+ * @param {Array<{line: number, generated: boolean}>} [opts.lineMap] - From
172
+ * table expansion, mapping each line of `body` back to the line an author
173
+ * wrote, for a caller handing in a body whose tables already expanded.
130
174
  * @param {object} [opts.config] - The resolved build configuration. Supplied,
131
175
  * an address is also held to the one surface a pathname can be dead on
132
176
  * without any other pass noticing — see the Foundry address below. Omitted,
@@ -136,9 +180,13 @@ export function imageSourcesIn(body: string): string[];
136
180
  * severity: "error", message: string}>} One finding per defect, in source
137
181
  * order.
138
182
  */
139
- export function checkImages(body: string, file: string, { bodyLine, bodyColumn, config }?: {
183
+ export function checkImages(body: string, file: string, { bodyLine, bodyColumn, lineMap, config }?: {
140
184
  bodyLine?: number | undefined;
141
185
  bodyColumn?: number | undefined;
186
+ lineMap?: {
187
+ line: number;
188
+ generated: boolean;
189
+ }[] | undefined;
142
190
  config?: object | undefined;
143
191
  }): Array<{
144
192
  file: string;
@@ -201,9 +249,18 @@ export function lintContentImages(contentBase: string, { skipDirectories, config
201
249
  * @param {(src: string) => string} [resolveSrc] - Translates an authored
202
250
  * pathname into the address this surface serves. The default is the identity,
203
251
  * for a caller rendering the format rather than publishing it.
252
+ * @param {(src: string) => {type?: string, role?: string, width?: number|"", height?: number|""}|undefined}
253
+ * [lookupAsset] - What the resolved asset record says about the address, as
254
+ * authored — before `resolveSrc` translates it. The default answers nothing,
255
+ * which is what an address resolving to no asset record gets anyway.
204
256
  * @returns {string} The same body, with each block image as a `<figure>`.
205
257
  */
206
- export function renderImageFigures(body: string, resolveSrc?: (src: string) => string): string;
258
+ export function renderImageFigures(body: string, resolveSrc?: (src: string) => string, lookupAsset?: (src: string) => {
259
+ type?: string;
260
+ role?: string;
261
+ width?: number | "";
262
+ height?: number | "";
263
+ } | undefined): string;
207
264
  /**
208
265
  * A markdown-it plugin that reads an image's directive and renders its figure.
209
266
  *
@@ -226,9 +283,18 @@ export function renderImageFigures(body: string, resolveSrc?: (src: string) => s
226
283
  * address into the one this surface serves. Foundry is handed the path inside
227
284
  * the install; a renderer that resolves the address itself — the book stages
228
285
  * its own copy — passes nothing and gets the address as authored.
286
+ * @param {(src: string) => {type?: string, role?: string, width?: number|"", height?: number|""}|undefined}
287
+ * [lookupAsset] - What the resolved asset record says about the address, as
288
+ * authored — before `resolveSrc` runs. The default answers nothing, which is
289
+ * what an address resolving to no asset record gets anyway.
229
290
  * @returns {(md: object) => void} A markdown-it plugin.
230
291
  */
231
- export function imagePlugin(resolveSrc?: (src: string) => string): (md: object) => void;
292
+ export function imagePlugin(resolveSrc?: (src: string) => string, lookupAsset?: (src: string) => {
293
+ type?: string;
294
+ role?: string;
295
+ width?: number | "";
296
+ height?: number | "";
297
+ } | undefined): (md: object) => void;
232
298
  /**
233
299
  * The width classes an image may carry, and what each means to a renderer.
234
300
  *
@@ -103,6 +103,10 @@ export function asciiAliases(aliases: unknown): Array<string>;
103
103
  * entries are derived against.
104
104
  * @param {object} [options.addressContext] - Address resolution context.
105
105
  * @param {object} [options.dateContext] - Calendar conversion context.
106
+ * @param {(address: string) => string|undefined} [options.resolveRole] - From
107
+ * a picture's address to the role its asset declares, so a figure anchor's
108
+ * `name` reads `Map 1` rather than `Figure 1` where it is due — see
109
+ * {@link module:engine/content-figures.scanFigures}.
106
110
  * @returns {Record<string, any>} The record, keys sorted at every depth. A
107
111
  * **stub** — a note with an empty body, on a type an empty body suppresses —
108
112
  * carries `address` and `anchors` as `null`: it publishes no page, so it
@@ -114,7 +118,7 @@ export function asciiAliases(aliases: unknown): Array<string>;
114
118
  * otherwise be overwritten without a word. `file` and, where the file was
115
119
  * read, `position` ride on the error.
116
120
  */
117
- export function buildIndexRecord({ frontmatter, relPath, absPath, contentPackage, body, bodyLine, manifest, addressContext, dateContext, }: {
121
+ export function buildIndexRecord({ frontmatter, relPath, absPath, contentPackage, body, bodyLine, manifest, addressContext, dateContext, resolveRole, }: {
118
122
  frontmatter: Record<string, any>;
119
123
  relPath: string;
120
124
  absPath?: string | undefined;
@@ -124,9 +128,10 @@ export function buildIndexRecord({ frontmatter, relPath, absPath, contentPackage
124
128
  manifest?: object | undefined;
125
129
  addressContext?: object | undefined;
126
130
  dateContext?: object | undefined;
131
+ resolveRole?: ((address: string) => string | undefined) | undefined;
127
132
  }): Record<string, any>;
128
133
  /** Derive every index record belonging to one parsed note. */
129
- export function indexRecordsForNote({ frontmatter, body, bodyLine, relPath, absPath, contentPackage, manifest, addressContext, dateContext, }: {
134
+ export function indexRecordsForNote({ frontmatter, body, bodyLine, relPath, absPath, contentPackage, manifest, addressContext, dateContext, resolveRole, }: {
130
135
  frontmatter: any;
131
136
  body: any;
132
137
  bodyLine: any;
@@ -136,6 +141,7 @@ export function indexRecordsForNote({ frontmatter, body, bodyLine, relPath, absP
136
141
  manifest: any;
137
142
  addressContext: any;
138
143
  dateContext: any;
144
+ resolveRole: any;
139
145
  }): object[];
140
146
  /**
141
147
  * Read a content tree into index records, in the order they will be written.
@@ -1,13 +1,21 @@
1
1
  /**
2
- * Replace prepared SQL fences with Markdown tables while retaining source lines.
3
- * Query execution happens in the asynchronous SQL preparation pass.
2
+ * Replace prepared SQL fences and page lists with Markdown while retaining
3
+ * source lines.
4
+ *
5
+ * Both directives read the content index, so both are answered before this
6
+ * pass runs — query execution in the asynchronous SQL preparation pass, page
7
+ * lists in {@link module:engine/page-lists.preparePageLists} — and each is
8
+ * looked up by the ordinal of its own kind of fence within the body.
9
+ *
4
10
  * @param {string} markdown - The authored body.
5
- * @param {{source?: string, sqlTables?: object[]}} [context] - Prepared results.
11
+ * @param {{source?: string, sqlTables?: object[], pageLists?: object[]}} [context] -
12
+ * Prepared results.
6
13
  * @returns {{markdown: string, errors: object[], warnings: object[], lineMap: object[]}}
7
14
  */
8
- export function expandContentTables(markdown: string, { source, sqlTables }?: {
15
+ export function expandContentTables(markdown: string, { source, sqlTables, pageLists }?: {
9
16
  source?: string;
10
17
  sqlTables?: object[];
18
+ pageLists?: object[];
11
19
  }): {
12
20
  markdown: string;
13
21
  errors: object[];
@@ -0,0 +1,72 @@
1
+ /**
2
+ * What a note opening a list item with `[ ]` or `[x]` is told.
3
+ *
4
+ * @param {string} marker - The matched marker, as written.
5
+ * @returns {string} The message, unpunctuated at the end as a finding is.
6
+ */
7
+ export function taskListMessage(marker: string): string;
8
+ /**
9
+ * Every list item opened with `[ ]` or `[x]` in one note's body.
10
+ *
11
+ * @param {string} body - The note's markdown, without its frontmatter.
12
+ * @param {string} file - The note's path, for the finding.
13
+ * @param {object} [opts]
14
+ * @param {number} [opts.bodyLine=1] - The 1-based file line the body starts on.
15
+ * @param {number} [opts.bodyColumn=1] - The 1-based file column it starts at.
16
+ * @returns {Array<{file: string, line: number, column: number,
17
+ * severity: "warning", message: string}>} One finding per item, in source
18
+ * order.
19
+ */
20
+ export function checkTaskLists(body: string, file: string, { bodyLine, bodyColumn }?: {
21
+ bodyLine?: number | undefined;
22
+ bodyColumn?: number | undefined;
23
+ }): Array<{
24
+ file: string;
25
+ line: number;
26
+ column: number;
27
+ severity: "warning";
28
+ message: string;
29
+ }>;
30
+ /**
31
+ * Walk a content tree and report every list item opened with `[ ]` or `[x]`.
32
+ *
33
+ * The frontmatter fence is taken off first, so what is scanned is the body and
34
+ * the positions are still the file's. A file with no frontmatter is scanned
35
+ * whole: it is not a note, but a stray `.md` in the tree carrying the marker is
36
+ * the same problem for the same reason.
37
+ *
38
+ * A finding names its file **relative to the working directory**, which is
39
+ * where a reader is standing and what `formatDiagnostic` emits. The content
40
+ * root is where the walk starts, not what a path is measured from.
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 lintContentTaskLists(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 list item's marker, immediately followed by `[ ]` or `[x]` and a space —
64
+ * bulleted (`-`, `*`, `+`) or ordered (`1.` or `1)`), at the start of a line.
65
+ *
66
+ * The leading indentation is a lookbehind rather than part of the match, so a
67
+ * nested item's finding points at the marker itself, not at the line's first
68
+ * column.
69
+ *
70
+ * @type {RegExp}
71
+ */
72
+ export const TASK_LIST_MARKER: RegExp;
@@ -2,9 +2,15 @@
2
2
  * Read the shared braced attribute grammar used by body extensions.
3
3
  * Callers validate which names and classes their extension understands.
4
4
  * @param {string} source - Text inside the braces.
5
+ * @param {object} [options={}]
6
+ * @param {RegExp} [options.idPattern=NAME] - What an `#id` may be named. A
7
+ * construct whose id is published as an HTML `id` admits a digit first and
8
+ * passes a looser pattern; the default is the pattern every other name takes.
5
9
  * @returns {{id: string, classes: string[], values: Record<string, string>, problems: string[]}}
6
10
  */
7
- export function parseExtensionAttributes(source: string): {
11
+ export function parseExtensionAttributes(source: string, { idPattern }?: {
12
+ idPattern?: RegExp | undefined;
13
+ }): {
8
14
  id: string;
9
15
  classes: string[];
10
16
  values: Record<string, string>;
@@ -12,3 +18,18 @@ export function parseExtensionAttributes(source: string): {
12
18
  };
13
19
  /** A Boolean attribute is spelled exactly `true` or `false`. */
14
20
  export function booleanAttribute(value: any, key: any): boolean;
21
+ /**
22
+ * The attribute keys no construct writes onto an element.
23
+ *
24
+ * `id=` and `class=` are refused in favour of `#id` and `.class`, which the
25
+ * grammar already states; a key beginning `on` is an event handler, and nothing
26
+ * authored in a note becomes code on a published page.
27
+ *
28
+ * Shared by every construct that writes an author's attributes onto an element,
29
+ * because a refusal that held on one and not the next would be the hole the
30
+ * other construct is checked for.
31
+ *
32
+ * @param {Record<string, string>} values - The `key=value` attributes parsed.
33
+ * @returns {string[]} One message per refused key, in the order written.
34
+ */
35
+ export function refusedAttributes(values: Record<string, string>): string[];
@@ -1,3 +1,24 @@
1
+ /**
2
+ * The one line explaining why a single field's shared top-level fallback is
3
+ * off.
4
+ *
5
+ * **The field's reason stands on its own** — a complete sentence, or more
6
+ * than one — rather than completing a clause the frame starts. A field that
7
+ * collides with a top-level spelling meaning something else can say so
8
+ * ("`weight` is the item's own, independent of the note's."); a field whose
9
+ * top-level spelling is refused outright by the closed vocabulary can say
10
+ * that instead, honestly, which "there it means …" cannot: a refused key
11
+ * carries no meaning to report.
12
+ *
13
+ * Exported so a guard can walk every field declaring `topLevelMeans` across
14
+ * every registry and check that each one composes into a grammatical
15
+ * sentence, without reimplementing the frame it is checking.
16
+ *
17
+ * @param {import("./field-spec.mjs").FieldSpec} field - A field declaring
18
+ * `topLevelMeans`.
19
+ * @returns {string} The composed markdown line.
20
+ */
21
+ export function topLevelExemptionLine(field: import("./field-spec.mjs").FieldSpec): string;
1
22
  /**
2
23
  * Render the per-type item frontmatter reference.
3
24
  *
@@ -213,19 +213,21 @@ export function runtimeOnlyFields(fields: readonly FieldSpec[]): FieldSpec[];
213
213
  * retiring one — so a field can move into `data:` while the corpus catches
214
214
  * up, instead of on a flag day across four repositories. A declaration that
215
215
  * names one is mid-sweep by construction; see {@link readsLegacyKey}.
216
- * @property {string} [topLevelMeans] - **What the note's top-level key of this
217
- * name means instead** — declared only where it means something else, and
218
- * stating it removes the shared top-level position from this field's
219
- * resolution order.
216
+ * @property {string} [topLevelMeans] - **Why the note's top-level key of this
217
+ * name is not this field's source** — declared wherever that key's spelling
218
+ * means something else at the note level, or the closed top-level
219
+ * vocabulary refuses it outright, and stating either removes the shared
220
+ * top-level position from this field's resolution order.
220
221
  *
221
222
  * A field's `name` doubles as its identity and as the shared property it
222
223
  * draws from, which is right wherever the two levels state the same quantity
223
224
  * — `data.weight` is the weight, whoever reads it. It is wrong wherever a
224
- * spelling collides across the two vocabularies. An `affiliation` item's
225
+ * spelling collides across the two vocabularies, or names a key the closed
226
+ * top-level vocabulary does not admit at all. An `affiliation` item's
225
227
  * `system.title` is the style of address an office carries; a note's
226
- * top-level `title` is the note's own heading. Nothing relates them, and
227
- * before this key one silently fed the other, stringifying an authored
228
- * `title: null` into fifteen documents.
228
+ * top-level `title` is refused outright. Nothing relates them, and before
229
+ * this key one silently fed the other, stringifying an authored `title:
230
+ * null` into fifteen documents.
229
231
  *
230
232
  * **The value is the reason**, not a flag with a comment beside it. A boolean
231
233
  * would record the decision and lose the case for it, and the next person
@@ -466,19 +468,21 @@ export type FieldSpec = {
466
468
  */
467
469
  legacyKey?: string | undefined;
468
470
  /**
469
- * - **What the note's top-level key of this
470
- * name means instead** — declared only where it means something else, and
471
- * stating it removes the shared top-level position from this field's
472
- * resolution order.
471
+ * - **Why the note's top-level key of this
472
+ * name is not this field's source** — declared wherever that key's spelling
473
+ * means something else at the note level, or the closed top-level
474
+ * vocabulary refuses it outright, and stating either removes the shared
475
+ * top-level position from this field's resolution order.
473
476
  *
474
477
  * A field's `name` doubles as its identity and as the shared property it
475
478
  * draws from, which is right wherever the two levels state the same quantity
476
479
  * — `data.weight` is the weight, whoever reads it. It is wrong wherever a
477
- * spelling collides across the two vocabularies. An `affiliation` item's
480
+ * spelling collides across the two vocabularies, or names a key the closed
481
+ * top-level vocabulary does not admit at all. An `affiliation` item's
478
482
  * `system.title` is the style of address an office carries; a note's
479
- * top-level `title` is the note's own heading. Nothing relates them, and
480
- * before this key one silently fed the other, stringifying an authored
481
- * `title: null` into fifteen documents.
483
+ * top-level `title` is refused outright. Nothing relates them, and before
484
+ * this key one silently fed the other, stringifying an authored `title:
485
+ * null` into fifteen documents.
482
486
  *
483
487
  * **The value is the reason**, not a flag with a comment beside it. A boolean
484
488
  * would record the decision and lose the case for it, and the next person
@@ -11,6 +11,20 @@ export function itemCatalogRelationships(config: object): Array<{
11
11
  kind: string;
12
12
  verified: string | undefined;
13
13
  }>;
14
+ /**
15
+ * Every declared relationship that opted into supplying its release archive
16
+ * for asset bytes alone, with no item catalogue built from it.
17
+ *
18
+ * @param {object} config - The resolved build configuration.
19
+ * @returns {Array<{id: string, manifest: string, kind: string, verified: string|undefined}>}
20
+ * The opted-in relationships, in declaration order.
21
+ */
22
+ export function assetArchiveRelationships(config: object): Array<{
23
+ id: string;
24
+ manifest: string;
25
+ kind: string;
26
+ verified: string | undefined;
27
+ }>;
14
28
  /**
15
29
  * The cache directory for one dependency at one version.
16
30
  *
@@ -95,6 +109,26 @@ export function fetchCatalog(config: object, rel: {
95
109
  id: string;
96
110
  manifest: string;
97
111
  }): Promise<string>;
112
+ /**
113
+ * Fetch one dependency's release archive for its asset bytes alone, building
114
+ * no item catalogue from it.
115
+ *
116
+ * Idempotent: a complete cache for the resolved version is left alone. Where a
117
+ * relationship also declares `itemCatalog: true`, {@link fetchCatalog} already
118
+ * unpacked this same archive into this same cache directory, and
119
+ * {@link fetchAllCatalogs} does not call this function for it — the two never
120
+ * download the same bytes twice.
121
+ *
122
+ * @param {object} config - The resolved build configuration.
123
+ * @param {{id: string, manifest: string, verified?: string}} rel - The
124
+ * declared relationship.
125
+ * @returns {Promise<string>} The dependency's cache directory.
126
+ */
127
+ export function fetchAssetArchive(config: object, rel: {
128
+ id: string;
129
+ manifest: string;
130
+ verified?: string;
131
+ }): Promise<string>;
98
132
  /**
99
133
  * Fill the cache from a locally built artifact rather than a release.
100
134
  *
@@ -167,6 +201,11 @@ export function fetchAllMetadata(config: object): Promise<number>;
167
201
  /**
168
202
  * Fetch every opted-in dependency. The `deps fetch` command.
169
203
  *
204
+ * A relationship declaring both `itemCatalog: true` and `assetArchive: true`
205
+ * is fetched once: {@link fetchCatalog} already unpacks the archive on its
206
+ * way to extracting the item catalogue, so this skips the archive-only fetch
207
+ * for any id {@link fetchCatalog} already handled.
208
+ *
170
209
  * @param {object} config - The resolved build configuration.
171
210
  * @returns {Promise<number>} How many dependencies were fetched.
172
211
  */
@@ -137,7 +137,7 @@ export function resolveRelation(fm: object, ctx?: string): Record<string, string
137
137
  *
138
138
  * @param {object} fm - The item frontmatter.
139
139
  * @param {string} [ctx] - Optional label for the error (defaults to the item's
140
- * title/name, else "item").
140
+ * display name, else "item").
141
141
  * @returns {string} The declared subType.
142
142
  * @throws {Error} When `subType` is missing or blank.
143
143
  */