@heroiclands/package-build 22.4.5 → 22.4.7
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 +16 -0
- package/CONTENT.md +109 -0
- package/bin/content-build.mjs +36 -8
- package/content-config.mjs +8 -3
- package/docs/api.md +86 -46
- package/docs/commands.md +64 -24
- package/docs/configuration.md +20 -1
- package/docs/content-format.md +71 -0
- package/engine/frontmatter-lint.mjs +2 -0
- package/engine/holdings.mjs +391 -0
- package/engine/index.mjs +9 -0
- package/engine/map-build.mjs +41 -11
- package/engine/map-dot.mjs +84 -24
- package/engine/map-graphviz.mjs +12 -3
- package/engine/map-layout.mjs +283 -101
- package/engine/map-places.mjs +33 -3
- package/engine/market-class.mjs +178 -0
- package/engine/metadata-index.mjs +7 -4
- package/engine/note-vocabulary.mjs +19 -0
- package/engine/site-build.mjs +88 -10
- package/engine/site-maps.mjs +165 -0
- package/package.json +1 -1
- package/types/engine/holdings.d.mts +146 -0
- package/types/engine/index.d.mts +3 -0
- package/types/engine/map-build.d.mts +13 -7
- package/types/engine/map-dot.d.mts +22 -9
- package/types/engine/map-graphviz.d.mts +8 -1
- package/types/engine/map-layout.d.mts +117 -49
- package/types/engine/map-places.d.mts +26 -0
- package/types/engine/market-class.d.mts +62 -0
- package/types/engine/note-vocabulary.d.mts +10 -0
- package/types/engine/site-build.d.mts +37 -6
- package/types/engine/site-maps.d.mts +81 -0
|
@@ -176,7 +176,10 @@ export function tableUniverse(pages: object[]): Map<string, object[]>;
|
|
|
176
176
|
* about every other page, known only once the whole tree has resolved — see
|
|
177
177
|
* {@link module:engine/related-pages} — so an authored value is dropped the
|
|
178
178
|
* way `aliases` is, and {@link renderPages} writes the derived block once it
|
|
179
|
-
* holds the graph.
|
|
179
|
+
* holds the graph. `contains`, `held_by` and `holdings` are dropped for the
|
|
180
|
+
* same reason — see {@link module:engine/holdings}. **So is `map`**: the
|
|
181
|
+
* file a place page names is the one the build drew beside it — see
|
|
182
|
+
* {@link module:engine/site-maps} — and a page with no drawing names none.
|
|
180
183
|
*
|
|
181
184
|
* @param {object} page - The page.
|
|
182
185
|
* @param {object} options
|
|
@@ -210,10 +213,21 @@ export function pageFrontmatter(page: object, { decorate, webSrc, artSrc }: {
|
|
|
210
213
|
* `doc` note's `subType` may be spelled the same as another note's `type`, and
|
|
211
214
|
* `doc-gear.md` and `weapongear-gear.md` are distinct.
|
|
212
215
|
*
|
|
216
|
+
* **A page that carries a file beside itself is a leaf bundle**, `<slug>/index.md`,
|
|
217
|
+
* because that is the one shape under which Hugo hands a page its own
|
|
218
|
+
* resources — the map from a place, inlined by the theme through
|
|
219
|
+
* `.Resources.Get`. The directory is the page, not a section: it holds no
|
|
220
|
+
* `_index.md`, and the page's stated `url` keeps its address exactly where the
|
|
221
|
+
* flat file's was.
|
|
222
|
+
*
|
|
213
223
|
* @param {object} page - The page.
|
|
224
|
+
* @param {object} [opts]
|
|
225
|
+
* @param {boolean} [opts.bundle=false] - Whether the page carries a resource.
|
|
214
226
|
* @returns {string} The file, relative to the mount.
|
|
215
227
|
*/
|
|
216
|
-
export function pageDestination(page: object
|
|
228
|
+
export function pageDestination(page: object, { bundle }?: {
|
|
229
|
+
bundle?: boolean | undefined;
|
|
230
|
+
}): string;
|
|
217
231
|
/**
|
|
218
232
|
* Renders and writes every page.
|
|
219
233
|
*
|
|
@@ -236,16 +250,25 @@ export function pageDestination(page: object): string;
|
|
|
236
250
|
* point the resolver answers, and inverted once between them. Nothing is
|
|
237
251
|
* resolved twice.
|
|
238
252
|
*
|
|
253
|
+
* **A map is written with its page.** The drawing from a place is made before
|
|
254
|
+
* this render — see {@link module:engine/site-maps} — and handed in keyed by
|
|
255
|
+
* page URL; the page that owns one is written as a leaf bundle, the file is
|
|
256
|
+
* copied beside it, and the front matter names it as `map`. Every other page
|
|
257
|
+
* is written flat, and carries no such key.
|
|
258
|
+
*
|
|
239
259
|
* @param {object[]} pages - Every page.
|
|
240
260
|
* @param {object} options - Everything the render needs. `homepages` is the
|
|
241
261
|
* homepage as the index knows it — `{ fm, body, url, title }` — which takes
|
|
242
262
|
* no part in the render and every part in the graph: a content page links
|
|
243
|
-
* it by wikilink, and its own markdown links name content pages.
|
|
263
|
+
* it by wikilink, and its own markdown links name content pages. `maps` is
|
|
264
|
+
* each drawing by the URL of the page that carries it.
|
|
244
265
|
* @returns {{written: number, byKind: Record<string, number>, tableErrors: object[],
|
|
245
266
|
* wikiErrors: object[], imageErrors: object[],
|
|
246
|
-
* related: Map<string, import("./related-pages.mjs").Related
|
|
267
|
+
* related: Map<string, import("./related-pages.mjs").Related>,
|
|
268
|
+
* maps: number}} `related`
|
|
247
269
|
* is keyed by page URL, and holds the homepage's block beside every content
|
|
248
270
|
* page's, so the caller can write it on the page this render does not.
|
|
271
|
+
* `maps` counts the pages written with one.
|
|
249
272
|
*/
|
|
250
273
|
export function renderPages(pages: object[], options: object): {
|
|
251
274
|
written: number;
|
|
@@ -254,6 +277,7 @@ export function renderPages(pages: object[], options: object): {
|
|
|
254
277
|
wikiErrors: object[];
|
|
255
278
|
imageErrors: object[];
|
|
256
279
|
related: Map<string, import("./related-pages.mjs").Related>;
|
|
280
|
+
maps: number;
|
|
257
281
|
};
|
|
258
282
|
/**
|
|
259
283
|
* Resolves `site.pass` to its bundle.
|
|
@@ -281,18 +305,25 @@ export function resolveSitePass(name: string | undefined, options: object): {
|
|
|
281
305
|
* {@link module:engine/sql-tables.prepareSqlTables}. A page authoring an
|
|
282
306
|
* `sql` directive with none prepared is a table error: nothing here runs a
|
|
283
307
|
* query.
|
|
308
|
+
* @param {(engine: string) => string|undefined} [options.locate] - How a
|
|
309
|
+
* GraphViz engine's binary is found, for the maps; the real lookup by
|
|
310
|
+
* default.
|
|
284
311
|
* @returns {{gates: object, stats: object|null, tableErrors: object[],
|
|
285
|
-
* wikiErrors: object[], imageErrors: object[],
|
|
312
|
+
* wikiErrors: object[], imageErrors: object[], mapFindings: object[],
|
|
313
|
+
* manifests: object|null}} `mapFindings` is what drawing the maps found —
|
|
314
|
+
* warnings, never a reason to fail the build.
|
|
286
315
|
*/
|
|
287
|
-
export function buildSite({ config, sqlTables }?: {
|
|
316
|
+
export function buildSite({ config, sqlTables, locate }?: {
|
|
288
317
|
config?: object | undefined;
|
|
289
318
|
sqlTables?: Map<string, object[]> | undefined;
|
|
319
|
+
locate?: ((engine: string) => string | undefined) | undefined;
|
|
290
320
|
}): {
|
|
291
321
|
gates: object;
|
|
292
322
|
stats: object | null;
|
|
293
323
|
tableErrors: object[];
|
|
294
324
|
wikiErrors: object[];
|
|
295
325
|
imageErrors: object[];
|
|
326
|
+
mapFindings: object[];
|
|
296
327
|
manifests: object | null;
|
|
297
328
|
};
|
|
298
329
|
export { formatUnaddressableFinding };
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A drawing as the page writer receives it.
|
|
3
|
+
*
|
|
4
|
+
* @typedef {object} SiteMap
|
|
5
|
+
* @property {string} name - The file's name in the page's bundle, and the
|
|
6
|
+
* value of the page's `map` key: `from-<shortcode>.svg`.
|
|
7
|
+
* @property {string} file - Where the drawing is, absolute.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* A GraphViz SVG rewritten for inlining in an HTML page.
|
|
11
|
+
*
|
|
12
|
+
* GraphViz writes a standalone document: an XML declaration, a DOCTYPE naming
|
|
13
|
+
* the SVG 1.1 DTD by URL, generator comments, a root sized in points beside
|
|
14
|
+
* its `viewBox`, and links through the `xlink` namespace. Inline in HTML the
|
|
15
|
+
* prologue is invalid, the DTD reference is the one external reference the
|
|
16
|
+
* drawing would carry, the fixed size fights the column it sits in, and
|
|
17
|
+
* `xlink:` is the pre-SVG-2 spelling. So the prologue and the comments go,
|
|
18
|
+
* the root keeps its `viewBox` and loses `width` and `height`, and
|
|
19
|
+
* `xlink:href` and `xlink:title` become `href` and `title`, with the
|
|
20
|
+
* namespace declaration they needed.
|
|
21
|
+
*
|
|
22
|
+
* @param {string} svg - The SVG as GraphViz wrote it.
|
|
23
|
+
* @returns {string} The SVG to inline, starting at `<svg`.
|
|
24
|
+
*/
|
|
25
|
+
export function inlineSvg(svg: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Draw the map from every related place of this package.
|
|
28
|
+
*
|
|
29
|
+
* @param {object} opts
|
|
30
|
+
* @param {Array<Record<string, any>>} opts.records - The package's index
|
|
31
|
+
* records, as the site build read them.
|
|
32
|
+
* @param {Map<string, object>} opts.foreignIndex - The fetched indexes the
|
|
33
|
+
* site build resolved links against.
|
|
34
|
+
* @param {object} opts.config - The resolved configuration.
|
|
35
|
+
* @param {string} opts.base - The site base every page is served under,
|
|
36
|
+
* ending in a slash: what every name in a drawing links through.
|
|
37
|
+
* @param {(engine: string) => string|undefined} [opts.locate] - How the
|
|
38
|
+
* engine's binary is found; the real lookup by default.
|
|
39
|
+
* @returns {{maps: Map<string, SiteMap>, findings: Array<{file: string,
|
|
40
|
+
* line?: number, column?: number, severity: "error"|"warning",
|
|
41
|
+
* message: string}>}} The drawings, keyed by the URL of the page each
|
|
42
|
+
* belongs to, and what the drawing found — one warning naming what to
|
|
43
|
+
* install when GraphViz is absent, and a warning for each relation that
|
|
44
|
+
* names no place.
|
|
45
|
+
*/
|
|
46
|
+
export function drawSiteMaps({ records, foreignIndex, config, base, locate }: {
|
|
47
|
+
records: Array<Record<string, any>>;
|
|
48
|
+
foreignIndex: Map<string, object>;
|
|
49
|
+
config: object;
|
|
50
|
+
base: string;
|
|
51
|
+
locate?: ((engine: string) => string | undefined) | undefined;
|
|
52
|
+
}): {
|
|
53
|
+
maps: Map<string, SiteMap>;
|
|
54
|
+
findings: Array<{
|
|
55
|
+
file: string;
|
|
56
|
+
line?: number;
|
|
57
|
+
column?: number;
|
|
58
|
+
severity: "error" | "warning";
|
|
59
|
+
message: string;
|
|
60
|
+
}>;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Where the site build draws, below the package root.
|
|
64
|
+
*
|
|
65
|
+
* @type {string}
|
|
66
|
+
*/
|
|
67
|
+
export const SITE_MAP_DIR: string;
|
|
68
|
+
/**
|
|
69
|
+
* A drawing as the page writer receives it.
|
|
70
|
+
*/
|
|
71
|
+
export type SiteMap = {
|
|
72
|
+
/**
|
|
73
|
+
* - The file's name in the page's bundle, and the
|
|
74
|
+
* value of the page's `map` key: `from-<shortcode>.svg`.
|
|
75
|
+
*/
|
|
76
|
+
name: string;
|
|
77
|
+
/**
|
|
78
|
+
* - Where the drawing is, absolute.
|
|
79
|
+
*/
|
|
80
|
+
file: string;
|
|
81
|
+
};
|