@heroiclands/package-build 23.8.0 → 23.10.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.
- package/CHANGELOG.md +53 -0
- package/README.md +2 -0
- package/bin/content-commands.mjs +207 -70
- package/docs/api.md +646 -78
- package/docs/authoring/first-note.md +1 -1
- package/docs/authoring/links-and-markup.md +253 -102
- package/docs/commands.md +111 -13
- package/docs/content-format.md +7 -2
- package/docs/diagnostics.md +1 -1
- package/docs/guides/packs.md +2 -1
- package/docs/guides/reference-pages.md +86 -63
- package/docs/reference/format-details.md +398 -137
- package/docs/reference/note-types.md +188 -174
- package/engine/anchors.mjs +15 -26
- package/engine/base-compiler.mjs +6 -4
- package/engine/changelog-group.mjs +58 -34
- package/engine/changelog-lint.mjs +6 -2
- package/engine/compendiums.mjs +15 -1
- package/engine/compile-corpus.mjs +17 -3
- package/engine/content-charset.mjs +13 -1
- package/engine/content-format.yaml +1 -0
- package/engine/content-html.mjs +18 -4
- package/engine/content-icons.mjs +15 -1
- package/engine/content-images.mjs +28 -9
- package/engine/content-index.mjs +496 -16
- package/engine/content-links.mjs +70 -27
- package/engine/content-session.mjs +247 -0
- package/engine/content-sources.mjs +110 -0
- package/engine/content-spans.mjs +87 -8
- package/engine/content-tables.mjs +9 -4
- package/engine/content-tasklists.mjs +20 -4
- package/engine/culture-reach.mjs +61 -34
- package/engine/data-keys.mjs +3 -1
- package/engine/diagnostics.mjs +17 -6
- package/engine/dictionary-layout.mjs +151 -19
- package/engine/dictionary-rows.mjs +129 -79
- package/engine/extension-attributes.mjs +28 -5
- package/engine/first-use.mjs +371 -0
- package/engine/foundry-entries.mjs +29 -8
- package/engine/generate.mjs +13 -4
- package/engine/glossary-entries.mjs +11 -11
- package/engine/heading-attributes.mjs +21 -28
- package/engine/helpers.mjs +54 -19
- package/engine/index-records.mjs +1 -0
- package/engine/index.mjs +3 -0
- package/engine/journals.mjs +13 -6
- package/engine/language-data.mjs +55 -2
- package/engine/language-rows.mjs +4 -4
- package/engine/language-terms.mjs +90 -4
- package/engine/language-words.mjs +2 -2
- package/engine/lexical-sections.mjs +247 -0
- package/engine/markup-validation.mjs +7 -2
- package/engine/metadata-index.mjs +1 -0
- package/engine/name-markup.mjs +114 -0
- package/engine/name-rows.mjs +70 -0
- package/engine/names.mjs +460 -0
- package/engine/note-addresses.mjs +25 -4
- package/engine/note-claims.mjs +2 -0
- package/engine/note-state.mjs +9 -3
- package/engine/note-vocabulary.mjs +7 -6
- package/engine/path-charset.mjs +24 -1
- package/engine/pdf-build.mjs +9 -9
- package/engine/pdf-render.mjs +15 -1
- package/engine/site-build.mjs +16 -2
- package/engine/site-index.mjs +5 -1
- package/engine/sql-tables.mjs +324 -44
- package/engine/stub-lint.mjs +10 -5
- package/engine/web-wikilinks.mjs +8 -6
- package/engine/word-rows.mjs +20 -12
- package/engine/word-terms.mjs +15 -6
- package/engine/yaml-lint.mjs +3 -5
- package/hugo-theme/static/css/style.css +4 -0
- package/package.json +1 -1
- package/types/engine/anchors.d.mts +4 -2
- package/types/engine/compendiums.d.mts +5 -1
- package/types/engine/compile-corpus.d.mts +5 -2
- package/types/engine/content-charset.d.mts +5 -1
- package/types/engine/content-html.d.mts +5 -1
- package/types/engine/content-icons.d.mts +5 -1
- package/types/engine/content-images.d.mts +5 -1
- package/types/engine/content-index.d.mts +102 -18
- package/types/engine/content-links.d.mts +22 -8
- package/types/engine/content-session.d.mts +108 -0
- package/types/engine/content-sources.d.mts +32 -0
- package/types/engine/content-spans.d.mts +3 -5
- package/types/engine/content-tables.d.mts +2 -1
- package/types/engine/content-tasklists.d.mts +5 -1
- package/types/engine/culture-reach.d.mts +22 -2
- package/types/engine/data-keys.d.mts +7 -0
- package/types/engine/diagnostics.d.mts +10 -0
- package/types/engine/dictionary-layout.d.mts +35 -4
- package/types/engine/dictionary-rows.d.mts +9 -0
- package/types/engine/extension-attributes.d.mts +16 -2
- package/types/engine/first-use.d.mts +31 -0
- package/types/engine/foundry-entries.d.mts +14 -5
- package/types/engine/generate.d.mts +5 -1
- package/types/engine/heading-attributes.d.mts +2 -2
- package/types/engine/helpers.d.mts +33 -7
- package/types/engine/index.d.mts +1 -0
- package/types/engine/journals.d.mts +5 -2
- package/types/engine/language-terms.d.mts +7 -0
- package/types/engine/lexical-sections.d.mts +96 -0
- package/types/engine/markup-validation.d.mts +2 -1
- package/types/engine/name-markup.d.mts +176 -0
- package/types/engine/name-rows.d.mts +35 -0
- package/types/engine/names.d.mts +356 -0
- package/types/engine/note-addresses.d.mts +3 -3
- package/types/engine/note-state.d.mts +2 -1
- package/types/engine/path-charset.d.mts +16 -1
- package/types/engine/site-build.d.mts +6 -3
- package/types/engine/site-index.d.mts +3 -1
- package/types/engine/sql-tables.d.mts +39 -4
- package/types/engine/stub-lint.d.mts +3 -1
- package/types/engine/word-rows.d.mts +9 -7
package/engine/word-rows.mjs
CHANGED
|
@@ -82,15 +82,17 @@ const isMap = (value) => Boolean(value) && typeof value === "object" && !Array.i
|
|
|
82
82
|
const bare = (form) => String(form).replace(/^-+|-+$/g, "");
|
|
83
83
|
|
|
84
84
|
/**
|
|
85
|
-
* A lookup from a built piece to its gloss, over the words (stems included)
|
|
86
|
-
* and
|
|
85
|
+
* A lookup from a built piece to its gloss, over the words (stems included),
|
|
86
|
+
* affixes and elements of one or more languages.
|
|
87
87
|
*
|
|
88
|
-
*
|
|
89
|
-
* affixes, then the next language's
|
|
90
|
-
*
|
|
91
|
-
*
|
|
88
|
+
* For each spelling, languages are given nearest first: a language's own
|
|
89
|
+
* words, then its affixes and elements, then the next language's. A piece
|
|
90
|
+
* matches an exact spelling across the lineage first, and failing that one
|
|
91
|
+
* written with the same letters and different joining hyphens, so
|
|
92
92
|
* `wulf-` finds the word `wulf`. Within a language a word's own gloss wins over
|
|
93
|
-
* an affix's.
|
|
93
|
+
* an affix's, and both precede an element's sense. Elements also match their
|
|
94
|
+
* declared variants; affixes also match their front-vowel forms. Spelling,
|
|
95
|
+
* including case and accents, is preserved.
|
|
94
96
|
*
|
|
95
97
|
* @param {...object} datas - Each language note's `data`, nearest first.
|
|
96
98
|
* @returns {(piece: string) => string|null} The gloss, or `null` where none resolves.
|
|
@@ -98,18 +100,24 @@ const bare = (form) => String(form).replace(/^-+|-+$/g, "");
|
|
|
98
100
|
export function pieceGlosses(...datas) {
|
|
99
101
|
const exact = new Map();
|
|
100
102
|
const loose = new Map();
|
|
101
|
-
const take = (entries) => {
|
|
103
|
+
const take = (entries, key = "gloss", alternateKey = "") => {
|
|
102
104
|
for (const entry of Array.isArray(entries) ? entries : []) {
|
|
103
105
|
if (!isMap(entry) || typeof entry.form !== "string") continue;
|
|
104
|
-
const gloss = glossText(entry
|
|
106
|
+
const gloss = glossText(entry[key]);
|
|
105
107
|
if (gloss === null) continue;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
+
const alternate = entry[alternateKey];
|
|
109
|
+
const forms = [entry.form, ...(Array.isArray(alternate) ? alternate : [alternate])];
|
|
110
|
+
for (const form of forms) {
|
|
111
|
+
if (typeof form !== "string") continue;
|
|
112
|
+
if (!exact.has(form)) exact.set(form, gloss);
|
|
113
|
+
if (!loose.has(bare(form))) loose.set(bare(form), gloss);
|
|
114
|
+
}
|
|
108
115
|
}
|
|
109
116
|
};
|
|
110
117
|
for (const data of datas) {
|
|
111
118
|
take(data?.words);
|
|
112
|
-
take(data?.affixes);
|
|
119
|
+
take(data?.affixes, "gloss", "front");
|
|
120
|
+
take(data?.elements, "sense", "variants");
|
|
113
121
|
}
|
|
114
122
|
return (piece) => exact.get(piece) ?? loose.get(bare(piece)) ?? null;
|
|
115
123
|
}
|
package/engine/word-terms.mjs
CHANGED
|
@@ -136,12 +136,20 @@ export const WORD_FIELDS = Object.freeze([
|
|
|
136
136
|
"A class from the master word classes: a base, then the modifiers the language " +
|
|
137
137
|
"declares in `classModifiers`.",
|
|
138
138
|
}),
|
|
139
|
+
Object.freeze({
|
|
140
|
+
name: "plural",
|
|
141
|
+
kind: "string",
|
|
142
|
+
shape: "a string",
|
|
143
|
+
describe:
|
|
144
|
+
"The noun's explicit plural, where it differs from the language's optional plural " +
|
|
145
|
+
"rule. A dictionary uses this form before the rule; no rule agreement is checked.",
|
|
146
|
+
}),
|
|
139
147
|
Object.freeze({
|
|
140
148
|
name: "field",
|
|
141
149
|
kind: "string",
|
|
142
150
|
required: true,
|
|
143
151
|
shape: "one of the language's `fields` names",
|
|
144
|
-
describe: "The field
|
|
152
|
+
describe: "The field tag beside the dictionary entry, named in the language's `fields`.",
|
|
145
153
|
}),
|
|
146
154
|
Object.freeze({
|
|
147
155
|
name: "gloss",
|
|
@@ -376,27 +384,28 @@ export const GLOSSARY_ENTRY_FIELDS = Object.freeze([
|
|
|
376
384
|
name: "name_sort",
|
|
377
385
|
kind: "string",
|
|
378
386
|
shape: "a string",
|
|
379
|
-
describe: "Its sort key; the name when unstated.",
|
|
387
|
+
describe: "Its sort key; the dictionary word's sort key, or the name, when unstated.",
|
|
380
388
|
}),
|
|
381
389
|
Object.freeze({
|
|
382
390
|
name: "common",
|
|
383
391
|
kind: "boolean",
|
|
384
392
|
shape: "`true` or `false`",
|
|
385
|
-
describe: "
|
|
393
|
+
describe: "Core vocabulary for this glossary's owner; `false` when unstated.",
|
|
386
394
|
}),
|
|
387
395
|
Object.freeze({
|
|
388
396
|
name: "definition",
|
|
389
397
|
kind: "string",
|
|
390
398
|
shape: "a string",
|
|
391
399
|
describe:
|
|
392
|
-
"The sense text
|
|
393
|
-
"
|
|
400
|
+
"The sense text, overriding the word's or governance sources' senses. Unstated, " +
|
|
401
|
+
"a named dictionary word supplies all its senses and class; a named rank or office supplies its descriptions.",
|
|
394
402
|
}),
|
|
395
403
|
Object.freeze({
|
|
396
404
|
name: "pronunciation",
|
|
397
405
|
kind: "string",
|
|
398
406
|
shape: "a respelling such as `sol-MEH-reh`",
|
|
399
|
-
describe:
|
|
407
|
+
describe:
|
|
408
|
+
"A respelling, held to the same rule as a word's; the dictionary word's when unstated.",
|
|
400
409
|
}),
|
|
401
410
|
Object.freeze({
|
|
402
411
|
name: "language",
|
package/engine/yaml-lint.mjs
CHANGED
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
import { execFileSync } from "node:child_process";
|
|
30
30
|
import fs from "node:fs";
|
|
31
31
|
import path from "node:path";
|
|
32
|
+
import { splitFrontmatter } from "./diagnostics.mjs";
|
|
32
33
|
|
|
33
34
|
/** File extensions that carry YAML, either wholly or in a frontmatter fence. */
|
|
34
35
|
export const YAML_GLOBS = Object.freeze(["*.md", "*.yaml", "*.yml"]);
|
|
@@ -42,9 +43,6 @@ export const YAML_GLOBS = Object.freeze(["*.md", "*.yaml", "*.yml"]);
|
|
|
42
43
|
*/
|
|
43
44
|
const ALWAYS_SKIP = Object.freeze([".git/", ".claude/"]);
|
|
44
45
|
|
|
45
|
-
/** A markdown file's leading frontmatter fence. Mirrors `parseMarkdownFile`. */
|
|
46
|
-
const FENCE = /^---\n([\s\S]*?)\n---/;
|
|
47
|
-
|
|
48
46
|
/**
|
|
49
47
|
* Present a markdown file to ESLint as the YAML it begins with.
|
|
50
48
|
*
|
|
@@ -68,8 +66,8 @@ export const frontmatterProcessor = {
|
|
|
68
66
|
// container file. Nothing is gained by claiming support for it.
|
|
69
67
|
supportsAutofix: false,
|
|
70
68
|
preprocess(text) {
|
|
71
|
-
const fence =
|
|
72
|
-
return fence ? [{ text: fence
|
|
69
|
+
const fence = splitFrontmatter(text);
|
|
70
|
+
return fence ? [{ text: fence.yaml, filename: "0.yaml" }] : [];
|
|
73
71
|
},
|
|
74
72
|
postprocess(messages) {
|
|
75
73
|
return (messages[0] ?? []).map((message) => ({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heroiclands/package-build",
|
|
3
|
-
"version": "23.
|
|
3
|
+
"version": "23.10.0",
|
|
4
4
|
"description": "Shared toolchain for building and shipping a HeroicLands Foundry VTT package — content compilation, manifest, localization, staging, bundle, release and deployment.",
|
|
5
5
|
"license": "GPL-3.0-or-later",
|
|
6
6
|
"type": "module",
|
|
@@ -12,10 +12,11 @@
|
|
|
12
12
|
* picture's address to the role its asset declares, so a figure anchor's
|
|
13
13
|
* `name` reads `Map 1` rather than `Figure 1` where it is due — see
|
|
14
14
|
* {@link module:engine/content-figures.scanFigures}.
|
|
15
|
+
* @param {import("./content-session.mjs").ContentSyntax} [syntax] - Exact-text scanner projections.
|
|
15
16
|
* @returns {Array<{slug: string, name: string, level: number, line: number,
|
|
16
17
|
* kind: string}>} In document order.
|
|
17
18
|
*/
|
|
18
|
-
export function collectAnchors(body: string, bodyLine?: number, resolveRole?: (address: string) => string | undefined): Array<{
|
|
19
|
+
export function collectAnchors(body: string, bodyLine?: number, resolveRole?: (address: string) => string | undefined, syntax?: import("./content-session.mjs").ContentSyntax): Array<{
|
|
19
20
|
slug: string;
|
|
20
21
|
name: string;
|
|
21
22
|
level: number;
|
|
@@ -25,9 +26,10 @@ export function collectAnchors(body: string, bodyLine?: number, resolveRole?: (a
|
|
|
25
26
|
/** Collisions involving a div, verse or inline-span anchor.
|
|
26
27
|
* Heading and caption collisions are diagnosed by their existing scanners.
|
|
27
28
|
* @param {string} body - Authored Markdown.
|
|
29
|
+
* @param {import("./content-session.mjs").ContentSyntax} [syntax] - Exact-text scanner projections.
|
|
28
30
|
* @returns {Array<{line: number, column: number, message: string}>} Located collisions.
|
|
29
31
|
*/
|
|
30
|
-
export function markupAnchorFindings(body: string): Array<{
|
|
32
|
+
export function markupAnchorFindings(body: string, syntax?: import("./content-session.mjs").ContentSyntax): Array<{
|
|
31
33
|
line: number;
|
|
32
34
|
column: number;
|
|
33
35
|
message: string;
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
* @param {string} [opts.stageDest] Directory the LevelDB packs are built
|
|
13
13
|
* into, one subdirectory per pack. Defaults to the configured stage.
|
|
14
14
|
* @param {string} [opts.packName] Restrict the run to a single pack.
|
|
15
|
+
* @param {import("./content-session.mjs").ContentSession} [opts.session] - Captured context shared with other operations.
|
|
16
|
+
* @param {boolean} [opts.reportPreparation=true] - Emit shared preparation findings unless the caller already reported them.
|
|
15
17
|
* @throws {Error} If pack JSON generation reported any error. Packs compiled
|
|
16
18
|
* from incomplete or empty JSON ship blank or short compendiums, and the
|
|
17
19
|
* omission is invisible until a player looks for content that is not there
|
|
@@ -23,11 +25,13 @@
|
|
|
23
25
|
* map image is gone before anyone notices it was ever at risk. See
|
|
24
26
|
* {@link verifyPackSceneLevels}.
|
|
25
27
|
*/
|
|
26
|
-
export function compilePacks({ config, sourcePacks, stageDest, packName, }?: {
|
|
28
|
+
export function compilePacks({ config, sourcePacks, stageDest, packName, session, reportPreparation, }?: {
|
|
27
29
|
config?: object | undefined;
|
|
28
30
|
sourcePacks?: string[] | undefined;
|
|
29
31
|
stageDest?: string | undefined;
|
|
30
32
|
packName?: string | undefined;
|
|
33
|
+
session?: import("./content-session.mjs").ContentSession | undefined;
|
|
34
|
+
reportPreparation?: boolean | undefined;
|
|
31
35
|
}): Promise<void>;
|
|
32
36
|
/**
|
|
33
37
|
* Cleans and formats source JSON files, removing unnecessary permissions and flags and adding the proper spacing.
|
|
@@ -15,20 +15,23 @@
|
|
|
15
15
|
* created when none is passed, and returned on the corpus either way — a note
|
|
16
16
|
* the index refuses is a note the compile must still *report*, exactly as the
|
|
17
17
|
* compile loop reported it when the loop was the first to see it.
|
|
18
|
-
* @
|
|
18
|
+
* @param {import("./content-session.mjs").ContentSession} [opts.session] - Captured context shared with other operations.
|
|
19
|
+
* @returns {Promise<{records: object[], parsed: Map<string, object>, linkIndex: object, sqlTables: Map<string, object[]>|undefined, problems: object[], syntax?: import("./content-session.mjs").ContentSyntax}>} The corpus,
|
|
19
20
|
* its indexes, and the notes it could not record.
|
|
20
21
|
*/
|
|
21
|
-
export function buildCompileCorpus({ contentBase, assetsBase, skipDirectories, router, config, problems, }: {
|
|
22
|
+
export function buildCompileCorpus({ contentBase, assetsBase, skipDirectories, router, config, problems, session, }: {
|
|
22
23
|
contentBase: string;
|
|
23
24
|
assetsBase?: string | undefined;
|
|
24
25
|
skipDirectories: readonly string[];
|
|
25
26
|
router: object;
|
|
26
27
|
config?: object | undefined;
|
|
27
28
|
problems?: object[] | undefined;
|
|
29
|
+
session?: import("./content-session.mjs").ContentSession | undefined;
|
|
28
30
|
}): Promise<{
|
|
29
31
|
records: object[];
|
|
30
32
|
parsed: Map<string, object>;
|
|
31
33
|
linkIndex: object;
|
|
32
34
|
sqlTables: Map<string, object[]> | undefined;
|
|
33
35
|
problems: object[];
|
|
36
|
+
syntax?: import("./content-session.mjs").ContentSyntax;
|
|
34
37
|
}>;
|
|
@@ -87,13 +87,17 @@ export function checkText(text: string, file: string): Array<{
|
|
|
87
87
|
* @param {readonly string[]} [opts.skipDirectories] - Directory names to ignore
|
|
88
88
|
* in addition to the dot-directories always skipped.
|
|
89
89
|
* @param {readonly string[]} [opts.extensions] - File extensions to read.
|
|
90
|
+
* @param {Map<string, {raw: string}>} [opts.sources] - Exact captured source strings; omitted, walks and reads the tree.
|
|
90
91
|
* @returns {{findings: Array<{file: string, line: number, column: number,
|
|
91
92
|
* severity: "warning", message: string}>, files: number}} The findings, and how
|
|
92
93
|
* many files produced them.
|
|
93
94
|
*/
|
|
94
|
-
export function lintContentCharset(contentBase: string, { skipDirectories, extensions }?: {
|
|
95
|
+
export function lintContentCharset(contentBase: string, { skipDirectories, extensions, sources }?: {
|
|
95
96
|
skipDirectories?: readonly string[] | undefined;
|
|
96
97
|
extensions?: readonly string[] | undefined;
|
|
98
|
+
sources?: Map<string, {
|
|
99
|
+
raw: string;
|
|
100
|
+
}> | undefined;
|
|
97
101
|
}): {
|
|
98
102
|
findings: Array<{
|
|
99
103
|
file: string;
|
|
@@ -47,12 +47,16 @@ export function checkHtml(body: string, file: string, { bodyLine, bodyColumn }?:
|
|
|
47
47
|
* @param {object} [opts]
|
|
48
48
|
* @param {readonly string[]} [opts.skipDirectories] - Directory names to ignore
|
|
49
49
|
* in addition to the dot-directories always skipped.
|
|
50
|
+
* @param {Map<string, {raw: string}>} [opts.sources] - Exact captured source strings; omitted, walks and reads the tree.
|
|
50
51
|
* @returns {{findings: Array<{file: string, line: number, column: number,
|
|
51
52
|
* severity: "warning", message: string}>, files: number}} The findings, and
|
|
52
53
|
* how many files were read.
|
|
53
54
|
*/
|
|
54
|
-
export function lintContentHtml(contentBase: string, { skipDirectories }?: {
|
|
55
|
+
export function lintContentHtml(contentBase: string, { skipDirectories, sources }?: {
|
|
55
56
|
skipDirectories?: readonly string[] | undefined;
|
|
57
|
+
sources?: Map<string, {
|
|
58
|
+
raw: string;
|
|
59
|
+
}> | undefined;
|
|
56
60
|
}): {
|
|
57
61
|
findings: Array<{
|
|
58
62
|
file: string;
|
|
@@ -119,12 +119,16 @@ export function checkIconRegistry(registry: {
|
|
|
119
119
|
* @param {object} [opts]
|
|
120
120
|
* @param {readonly string[]} [opts.skipDirectories] - Directory names to ignore.
|
|
121
121
|
* @param {IconRegistry} [opts.registry] - The package's registry.
|
|
122
|
+
* @param {Map<string, {raw: string}>} [opts.sources] - Exact captured source strings; omitted, walks and reads the tree.
|
|
122
123
|
* @returns {{findings: Array<{file: string, line: number, column: number,
|
|
123
124
|
* severity: "warning", message: string}>, files: number}} What it found.
|
|
124
125
|
*/
|
|
125
|
-
export function lintContentIcons(contentBase: string, { skipDirectories, registry }?: {
|
|
126
|
+
export function lintContentIcons(contentBase: string, { skipDirectories, registry, sources }?: {
|
|
126
127
|
skipDirectories?: readonly string[] | undefined;
|
|
127
128
|
registry?: IconRegistry | undefined;
|
|
129
|
+
sources?: Map<string, {
|
|
130
|
+
raw: string;
|
|
131
|
+
}> | undefined;
|
|
128
132
|
}): {
|
|
129
133
|
findings: Array<{
|
|
130
134
|
file: string;
|
|
@@ -215,13 +215,17 @@ export function checkImages(body: string, file: string, { bodyLine, bodyColumn,
|
|
|
215
215
|
* in addition to the dot-directories always skipped.
|
|
216
216
|
* @param {object} [opts.config] - The resolved build configuration, passed to
|
|
217
217
|
* {@link checkImages} so an address is held to the Foundry surface too.
|
|
218
|
+
* @param {Map<string, {raw: string}>} [opts.sources] - Exact captured source strings; omitted, walks and reads the tree.
|
|
218
219
|
* @returns {{findings: Array<{file: string, line: number, column: number|undefined,
|
|
219
220
|
* severity: "error", message: string}>, files: number}} The findings, and how
|
|
220
221
|
* many files were read.
|
|
221
222
|
*/
|
|
222
|
-
export function lintContentImages(contentBase: string, { skipDirectories, config }?: {
|
|
223
|
+
export function lintContentImages(contentBase: string, { skipDirectories, config, sources }?: {
|
|
223
224
|
skipDirectories?: readonly string[] | undefined;
|
|
224
225
|
config?: object | undefined;
|
|
226
|
+
sources?: Map<string, {
|
|
227
|
+
raw: string;
|
|
228
|
+
}> | undefined;
|
|
225
229
|
}): {
|
|
226
230
|
findings: Array<{
|
|
227
231
|
file: string;
|
|
@@ -100,6 +100,8 @@ export function asciiAliases(aliases: unknown): Array<string>;
|
|
|
100
100
|
* and for the one question that decides whether the note publishes a page. A
|
|
101
101
|
* caller that states no body is stating an empty one, and the note is a stub.
|
|
102
102
|
* @param {number} [options.bodyLine] - The 1-based file line the body starts on.
|
|
103
|
+
* @param {number} [options.bodyColumn] - The 1-based UTF-16 column of its first character.
|
|
104
|
+
* @param {Iterable<string>} [options.nameTypes] - Additional bare name kinds from configured type declarations.
|
|
103
105
|
* @param {object} [options.manifest] - The package manifest, which the Foundry
|
|
104
106
|
* entries are derived against.
|
|
105
107
|
* @param {object} [options.addressContext] - Address resolution context.
|
|
@@ -108,6 +110,7 @@ export function asciiAliases(aliases: unknown): Array<string>;
|
|
|
108
110
|
* a picture's address to the role its asset declares, so a figure anchor's
|
|
109
111
|
* `name` reads `Map 1` rather than `Figure 1` where it is due — see
|
|
110
112
|
* {@link module:engine/content-figures.scanFigures}.
|
|
113
|
+
* @param {import("./content-session.mjs").ContentSyntax} [options.syntax] - Session scanner projections.
|
|
111
114
|
* @returns {Record<string, any>} The record, keys sorted at every depth. A
|
|
112
115
|
* **stub** — a note with an empty body, on a type an empty body suppresses —
|
|
113
116
|
* carries `address` and `anchors` as `null`: it publishes no page, so it
|
|
@@ -119,7 +122,7 @@ export function asciiAliases(aliases: unknown): Array<string>;
|
|
|
119
122
|
* otherwise be overwritten without a word. `file` and, where the file was
|
|
120
123
|
* read, `position` ride on the error.
|
|
121
124
|
*/
|
|
122
|
-
export function buildIndexRecord({ frontmatter, relPath, absPath, raw, contentPackage, body, bodyLine, manifest, addressContext, dateContext, resolveRole, }: {
|
|
125
|
+
export function buildIndexRecord({ frontmatter, relPath, absPath, raw, contentPackage, body, bodyLine, bodyColumn, nameTypes, manifest, addressContext, dateContext, resolveRole, syntax, }: {
|
|
123
126
|
frontmatter: Record<string, any>;
|
|
124
127
|
relPath: string;
|
|
125
128
|
absPath?: string | undefined;
|
|
@@ -127,25 +130,19 @@ export function buildIndexRecord({ frontmatter, relPath, absPath, raw, contentPa
|
|
|
127
130
|
contentPackage: string;
|
|
128
131
|
body?: string | undefined;
|
|
129
132
|
bodyLine?: number | undefined;
|
|
133
|
+
bodyColumn?: number | undefined;
|
|
134
|
+
nameTypes?: Iterable<string> | undefined;
|
|
130
135
|
manifest?: object | undefined;
|
|
131
136
|
addressContext?: object | undefined;
|
|
132
137
|
dateContext?: object | undefined;
|
|
133
138
|
resolveRole?: ((address: string) => string | undefined) | undefined;
|
|
139
|
+
syntax?: import("./content-session.mjs").ContentSyntax | undefined;
|
|
134
140
|
}): Record<string, any>;
|
|
135
|
-
/**
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
relPath: any;
|
|
141
|
-
absPath: any;
|
|
142
|
-
raw: any;
|
|
143
|
-
contentPackage: any;
|
|
144
|
-
manifest: any;
|
|
145
|
-
addressContext: any;
|
|
146
|
-
dateContext: any;
|
|
147
|
-
resolveRole: any;
|
|
148
|
-
}): object[];
|
|
141
|
+
/**
|
|
142
|
+
* Derive every index record belonging to one parsed note.
|
|
143
|
+
* @param {Parameters<typeof buildIndexRecord>[0]} options - Authored note and its context.
|
|
144
|
+
*/
|
|
145
|
+
export function indexRecordsForNote({ frontmatter, body, bodyLine, bodyColumn, nameTypes, relPath, absPath, raw, contentPackage, manifest, addressContext, dateContext, resolveRole, syntax, }: Parameters<typeof buildIndexRecord>[0]): object[];
|
|
149
146
|
/**
|
|
150
147
|
* Write each note's resolved culture into its record, as `data.culture`.
|
|
151
148
|
*
|
|
@@ -243,10 +240,13 @@ export function resolveCultures(records: Array<Record<string, any>>, { contentPa
|
|
|
243
240
|
* @param {Map<string, {body: string, frontmatter: object|null, raw: string, bodyLine?: number, bodyColumn?: number}>} [options.parsed] -
|
|
244
241
|
* Filled with each note's source text, body coordinates and frontmatter as
|
|
245
242
|
* authored, keyed by file, for reuse throughout the command.
|
|
243
|
+
* @param {Map<string, {raw: string}>} [options.sources] - Selected captured source strings.
|
|
244
|
+
* @param {import("./content-session.mjs").ContentSyntax} [options.syntax] - Session scanner projections.
|
|
245
|
+
* @param {Iterable<string>} [options.nameTypes] - Additional bare name kinds from configured type declarations.
|
|
246
246
|
* @returns {Array<Record<string, any>>} The records, in a total order that does
|
|
247
247
|
* not depend on directory-read order.
|
|
248
248
|
*/
|
|
249
|
-
export function collectContentIndex(contentBase: string, { contentPackage, skipDirectories, assetsBase, manifest, problems, addressContext, foreignRecord, parsed, }: {
|
|
249
|
+
export function collectContentIndex(contentBase: string, { contentPackage, skipDirectories, assetsBase, manifest, problems, addressContext, foreignRecord, parsed, sources, syntax, nameTypes, }: {
|
|
250
250
|
contentPackage: string;
|
|
251
251
|
skipDirectories: readonly string[];
|
|
252
252
|
assetsBase?: string | undefined;
|
|
@@ -263,6 +263,11 @@ export function collectContentIndex(contentBase: string, { contentPackage, skipD
|
|
|
263
263
|
bodyLine?: number;
|
|
264
264
|
bodyColumn?: number;
|
|
265
265
|
}> | undefined;
|
|
266
|
+
sources?: Map<string, {
|
|
267
|
+
raw: string;
|
|
268
|
+
}> | undefined;
|
|
269
|
+
syntax?: import("./content-session.mjs").ContentSyntax | undefined;
|
|
270
|
+
nameTypes?: Iterable<string> | undefined;
|
|
266
271
|
}): Array<Record<string, any>>;
|
|
267
272
|
/**
|
|
268
273
|
* Serialize records as JSON Lines.
|
|
@@ -303,9 +308,13 @@ export function serializeContentIndex(records: Array<Record<string, any>>): stri
|
|
|
303
308
|
* Filled with each note's body and authored frontmatter, keyed by the note's
|
|
304
309
|
* file. Handed to {@link module:engine/sql-tables.prepareTreeSqlTables}, it
|
|
305
310
|
* spares that pass reading and parsing every note again.
|
|
311
|
+
* @param {Map<string, {raw: string}>} [opts.sources] - Selected source strings, in index walk order.
|
|
312
|
+
* @param {import("./content-session.mjs").ContentSyntax} [opts.syntax] - Session scanner projections.
|
|
313
|
+
* @param {Iterable<string>} [opts.nameTypes] - Bare name kinds, defaulting to configured item types.
|
|
314
|
+
* @param {Map<string, object>} [opts.foreignIndex] - Captured dependency address view.
|
|
306
315
|
* @returns {object[]} One record per note, plus one per documentation entry.
|
|
307
316
|
*/
|
|
308
|
-
export function indexRecordsFor({ contentBase, assetsBase, config, skipDirectories, problems, parsed, }?: {
|
|
317
|
+
export function indexRecordsFor({ contentBase, assetsBase, config, skipDirectories, problems, parsed, sources, syntax, nameTypes, foreignIndex, }?: {
|
|
309
318
|
contentBase?: string | undefined;
|
|
310
319
|
assetsBase?: string | undefined;
|
|
311
320
|
config?: object | undefined;
|
|
@@ -318,7 +327,27 @@ export function indexRecordsFor({ contentBase, assetsBase, config, skipDirectori
|
|
|
318
327
|
bodyLine?: number;
|
|
319
328
|
bodyColumn?: number;
|
|
320
329
|
}> | undefined;
|
|
330
|
+
sources?: Map<string, {
|
|
331
|
+
raw: string;
|
|
332
|
+
}> | undefined;
|
|
333
|
+
syntax?: import("./content-session.mjs").ContentSyntax | undefined;
|
|
334
|
+
nameTypes?: Iterable<string> | undefined;
|
|
335
|
+
foreignIndex?: Map<string, object> | undefined;
|
|
321
336
|
}): object[];
|
|
337
|
+
/**
|
|
338
|
+
* Prepare the complete bodies a content-index publication describes.
|
|
339
|
+
* Prose declarations use each source's audience. Native SQL uses the complete
|
|
340
|
+
* corpus, with target maps limited to that source's declared prose slugs.
|
|
341
|
+
* No output files are written, and the returned inputs are read-only to the emitter.
|
|
342
|
+
*
|
|
343
|
+
* @param {{contentBase?: string, config?: object, session?: import("./content-session.mjs").ContentSession}} [options]
|
|
344
|
+
* @returns {Promise<PreparedContentIndex>}
|
|
345
|
+
*/
|
|
346
|
+
export function prepareContentIndex({ contentBase, config, session }?: {
|
|
347
|
+
contentBase?: string;
|
|
348
|
+
config?: object;
|
|
349
|
+
session?: import("./content-session.mjs").ContentSession;
|
|
350
|
+
}): Promise<PreparedContentIndex>;
|
|
322
351
|
/**
|
|
323
352
|
* Emit this package's content index.
|
|
324
353
|
*
|
|
@@ -328,6 +357,7 @@ export function indexRecordsFor({ contentBase, assetsBase, config, skipDirectori
|
|
|
328
357
|
* @param {string} [options.outDir] - Where to write; defaults to the configured
|
|
329
358
|
* `paths.contentIndex`.
|
|
330
359
|
* @param {object} [options.config] - A resolved configuration; loaded when omitted.
|
|
360
|
+
* @param {PreparedContentIndex} [options.publication] - Complete preparation for this tree and configuration.
|
|
331
361
|
* @returns {{file: string, notes: number, assets: number, records: number,
|
|
332
362
|
* bytes: number, full: number, draft: number, stub: number,
|
|
333
363
|
* dictionary: {file: string, rows: number}, terms: {file: string, rows: number}}}
|
|
@@ -341,10 +371,11 @@ export function indexRecordsFor({ contentBase, assetsBase, config, skipDirectori
|
|
|
341
371
|
* reader would take it as the authoritative statement that this package has
|
|
342
372
|
* no content.
|
|
343
373
|
*/
|
|
344
|
-
export function emitContentIndex({ contentBase, outDir, config }?: {
|
|
374
|
+
export function emitContentIndex({ contentBase, outDir, config, publication }?: {
|
|
345
375
|
contentBase?: string | undefined;
|
|
346
376
|
outDir?: string | undefined;
|
|
347
377
|
config?: object | undefined;
|
|
378
|
+
publication?: PreparedContentIndex | undefined;
|
|
348
379
|
}): {
|
|
349
380
|
file: string;
|
|
350
381
|
notes: number;
|
|
@@ -363,6 +394,59 @@ export function emitContentIndex({ contentBase, outDir, config }?: {
|
|
|
363
394
|
rows: number;
|
|
364
395
|
};
|
|
365
396
|
};
|
|
397
|
+
/**
|
|
398
|
+
* A captured source context, consumed without mutation by the synchronous emitter.
|
|
399
|
+
*/
|
|
400
|
+
export type PreparedContentIndex = {
|
|
401
|
+
/**
|
|
402
|
+
* - The exact resolved configuration for preparation.
|
|
403
|
+
*/
|
|
404
|
+
config: object;
|
|
405
|
+
/**
|
|
406
|
+
* - The absolute captured source root.
|
|
407
|
+
*/
|
|
408
|
+
contentBase: string;
|
|
409
|
+
/**
|
|
410
|
+
* - Complete index records, including hidden providers.
|
|
411
|
+
*/
|
|
412
|
+
records: object[];
|
|
413
|
+
/**
|
|
414
|
+
* - Authored sources by absolute file.
|
|
415
|
+
*/
|
|
416
|
+
parsed: Map<string, {
|
|
417
|
+
frontmatter: object | null;
|
|
418
|
+
body: string;
|
|
419
|
+
raw: string;
|
|
420
|
+
bodyLine?: number;
|
|
421
|
+
bodyColumn?: number;
|
|
422
|
+
}>;
|
|
423
|
+
/**
|
|
424
|
+
* - Complete rendered bodies in each note's audience.
|
|
425
|
+
*/
|
|
426
|
+
expandedBodies: Map<string, {
|
|
427
|
+
markdown: string;
|
|
428
|
+
lineMap: Array<{
|
|
429
|
+
line: number;
|
|
430
|
+
generated: boolean;
|
|
431
|
+
}>;
|
|
432
|
+
generatedFrom?: number;
|
|
433
|
+
}>;
|
|
434
|
+
/**
|
|
435
|
+
* - Complete native bodies with explicit SQL using the ALL corpus.
|
|
436
|
+
*/
|
|
437
|
+
foundryBodies: Map<string, {
|
|
438
|
+
markdown: string;
|
|
439
|
+
lineMap: Array<{
|
|
440
|
+
line: number;
|
|
441
|
+
generated: boolean;
|
|
442
|
+
}>;
|
|
443
|
+
generatedFrom?: number;
|
|
444
|
+
}>;
|
|
445
|
+
/**
|
|
446
|
+
* - Session-local exact-text scanner projections.
|
|
447
|
+
*/
|
|
448
|
+
syntax?: import("./content-session.mjs").ContentSyntax | undefined;
|
|
449
|
+
};
|
|
366
450
|
import { collectAnchors } from "./anchors.mjs";
|
|
367
451
|
import { authoredFrontmatter } from "./index-records.mjs";
|
|
368
452
|
import { DERIVED_KEYS } from "./index-records.mjs";
|
|
@@ -31,13 +31,11 @@ export function anchorsOf(body: string): Set<string>;
|
|
|
31
31
|
* not hypothetical: this module carried its own anchor reader until the anchor
|
|
32
32
|
* anchor half, and the two disagreed about which anchors existed.
|
|
33
33
|
*
|
|
34
|
-
* **
|
|
35
|
-
* carries no note
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* before, since the walk read the file and it then read it again for the raw
|
|
40
|
-
* text.
|
|
34
|
+
* **Raw sources can come from the caller's capture.** The published index
|
|
35
|
+
* carries no note body, while a link lives in the prose. A caller that already
|
|
36
|
+
* captured the sources supplies `parsed`, so this pass uses those exact raw
|
|
37
|
+
* strings. Without a captured string, it opens the file for its bytes.
|
|
38
|
+
* Frontmatter, addresses and anchors still come from the records.
|
|
41
39
|
*
|
|
42
40
|
* The index holds each compiled document under its complete Address. Readable
|
|
43
41
|
* content uses `note`, and system documents use their declared system.
|
|
@@ -55,17 +53,33 @@ export function anchorsOf(body: string): Set<string>;
|
|
|
55
53
|
* @param {object[]} [opts.records] - Index records the caller already derived,
|
|
56
54
|
* so a command that also needs them — every one of them does, to answer its
|
|
57
55
|
* `sql` tables — enumerates the corpus once rather than twice.
|
|
56
|
+
* @param {Map<string, {raw: string}>} [opts.parsed] - Sources captured alongside
|
|
57
|
+
* `records` in this invocation, keyed by absolute note path. A raw string is
|
|
58
|
+
* used verbatim; a missing string falls back to reading the file. The caller
|
|
59
|
+
* owns the map, which this function only reads.
|
|
58
60
|
* @param {object[]} [opts.problems] - Collects the notes the index cannot
|
|
59
61
|
* record, as diagnostics, instead of letting one of them abort the check
|
|
60
62
|
* before it has reported anything else.
|
|
63
|
+
* @param {ReturnType<import("./metadata-index.mjs").loadForeignIndexes>} [opts.foreign] - Captured dependency address and reference views.
|
|
61
64
|
* @returns {object} The notes, the index, and the resolvers built over it.
|
|
62
65
|
*/
|
|
63
|
-
export function buildLinkIndex(contentBase: string, { config, skipDirectories, sqlTables, records, problems }?: {
|
|
66
|
+
export function buildLinkIndex(contentBase: string, { config, skipDirectories, sqlTables, records, parsed, problems, foreign: capturedForeign, }?: {
|
|
64
67
|
config?: object | undefined;
|
|
65
68
|
skipDirectories?: readonly string[] | undefined;
|
|
66
69
|
sqlTables?: Map<string, object[]> | undefined;
|
|
67
70
|
records?: object[] | undefined;
|
|
71
|
+
parsed?: Map<string, {
|
|
72
|
+
raw: string;
|
|
73
|
+
}> | undefined;
|
|
68
74
|
problems?: object[] | undefined;
|
|
75
|
+
foreign?: {
|
|
76
|
+
index: Map<string, object>;
|
|
77
|
+
packages: Set<string>;
|
|
78
|
+
stale: Array<{
|
|
79
|
+
package: string;
|
|
80
|
+
reason: string;
|
|
81
|
+
}>;
|
|
82
|
+
} | undefined;
|
|
69
83
|
}): object;
|
|
70
84
|
/**
|
|
71
85
|
* Every defect in the addresses a package homepage carries.
|