@heroiclands/package-build 23.13.0 → 24.0.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 (233) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +2 -1
  3. package/assets/preview/gitea.ini +12 -7
  4. package/assets/styles/content-base.css +150 -1
  5. package/bin/content-commands.mjs +356 -210
  6. package/bin/package-build.mjs +3 -2
  7. package/ci/check-banners.mjs +7 -7
  8. package/config.mjs +21 -6
  9. package/content-config.mjs +199 -80
  10. package/docs/api.md +93 -72
  11. package/docs/authoring/links-and-markup.md +316 -78
  12. package/docs/commands.md +244 -78
  13. package/docs/configuration.md +210 -102
  14. package/docs/content-format.md +2 -2
  15. package/docs/diagnostics.md +2 -2
  16. package/docs/getting-started.md +1 -1
  17. package/docs/guides/icons.md +1 -1
  18. package/docs/guides/module-project.md +5 -8
  19. package/docs/guides/release-and-deploy.md +2 -2
  20. package/docs/guides/site.md +112 -23
  21. package/docs/guides/system-project.md +1 -1
  22. package/docs/guides/writing-in-invented-scripts.md +1247 -0
  23. package/docs/index.md +1 -0
  24. package/docs/project-setup.md +28 -30
  25. package/docs/reference/format-details.md +589 -308
  26. package/docs/reference/note-types.md +40 -10
  27. package/docs/reference/theme-pages.md +127 -108
  28. package/docs/source-preview.md +15 -1
  29. package/engine/asset-shipping.mjs +22 -10
  30. package/engine/base-compiler.mjs +62 -104
  31. package/engine/changelog-lint.mjs +1 -1
  32. package/engine/content-address.mjs +1 -1
  33. package/engine/content-alerts.mjs +8 -4
  34. package/engine/content-blocks.mjs +26 -11
  35. package/engine/content-embeds.mjs +1 -1
  36. package/engine/content-expand.mjs +376 -0
  37. package/engine/content-figures.mjs +13 -6
  38. package/engine/content-format.yaml +8 -0
  39. package/engine/content-glyphs.mjs +213 -0
  40. package/engine/content-images.mjs +6 -7
  41. package/engine/content-links.mjs +3 -3
  42. package/engine/content-lint.mjs +1 -1
  43. package/engine/content-render.mjs +453 -0
  44. package/engine/content-scripts.mjs +326 -27
  45. package/engine/content-spans.mjs +4 -1
  46. package/engine/content-styles.mjs +91 -0
  47. package/engine/content-symbols.mjs +186 -0
  48. package/engine/content-verse.mjs +6 -18
  49. package/engine/core-report.mjs +169 -0
  50. package/engine/core-vocabulary.mjs +208 -0
  51. package/engine/dictionary-html.mjs +119 -0
  52. package/engine/field-reference.mjs +1 -1
  53. package/engine/frontmatter-lint.mjs +1 -1
  54. package/engine/heading-attributes.mjs +89 -0
  55. package/engine/helpers.mjs +61 -101
  56. package/engine/homepage.mjs +17 -29
  57. package/engine/html-minify.mjs +70 -0
  58. package/engine/index.mjs +8 -5
  59. package/engine/language-rows.mjs +8 -2
  60. package/engine/language-terms.mjs +115 -14
  61. package/engine/language-words.mjs +12 -0
  62. package/engine/logographic.mjs +255 -0
  63. package/engine/map-lexicon.mjs +221 -25
  64. package/engine/map-places.mjs +5 -4
  65. package/engine/markdown-expressions.mjs +0 -2
  66. package/engine/markdownlint-run.mjs +9 -3
  67. package/engine/markup-validation.mjs +21 -0
  68. package/engine/metre-declaration.mjs +134 -0
  69. package/engine/note-matter.mjs +2 -2
  70. package/engine/note-vocabulary.mjs +187 -3
  71. package/engine/pdf-build.mjs +68 -133
  72. package/engine/pdf-render.mjs +102 -44
  73. package/engine/post-fields.mjs +157 -0
  74. package/engine/preview-index.mjs +130 -0
  75. package/engine/preview-source.mjs +450 -0
  76. package/engine/project-init.mjs +5 -12
  77. package/engine/prose-config.mjs +3 -3
  78. package/engine/run-words.mjs +3 -2
  79. package/engine/script-emphasis-terms.mjs +38 -0
  80. package/engine/script-emphasis.mjs +295 -0
  81. package/engine/script-font-delivery.mjs +4 -4
  82. package/engine/site-build.mjs +259 -314
  83. package/engine/site-config.mjs +26 -238
  84. package/engine/site-files.mjs +175 -0
  85. package/engine/site-index.mjs +9 -4
  86. package/engine/site-preview.mjs +50 -523
  87. package/engine/site-render.mjs +593 -0
  88. package/engine/site-root.mjs +22 -13
  89. package/engine/site-search.mjs +161 -0
  90. package/engine/site-serve.mjs +273 -0
  91. package/engine/site-theme-banner.mjs +154 -0
  92. package/engine/site-theme-urls.mjs +125 -0
  93. package/engine/site-theme.mjs +926 -0
  94. package/engine/text-maps.mjs +57 -10
  95. package/engine/typographer.mjs +248 -0
  96. package/engine/verse-metre.mjs +357 -0
  97. package/engine/wikilink-syntax.mjs +29 -47
  98. package/engine/wikilinks.mjs +758 -279
  99. package/engine/word-forms.mjs +39 -24
  100. package/engine/word-rows.mjs +12 -2
  101. package/engine/word-terms.mjs +29 -4
  102. package/manifest.mjs +3 -4
  103. package/package.json +10 -7
  104. package/{hugo-theme → site-theme}/data/banners.yaml +6 -10
  105. package/site-theme/layouts/base.hbs +31 -0
  106. package/site-theme/layouts/blog-list.hbs +30 -0
  107. package/site-theme/layouts/blog-post.hbs +40 -0
  108. package/site-theme/layouts/home.hbs +35 -0
  109. package/site-theme/layouts/list.hbs +20 -0
  110. package/site-theme/layouts/not-found.hbs +31 -0
  111. package/site-theme/layouts/page.hbs +7 -0
  112. package/site-theme/partials/copy-buttons.hbs +37 -0
  113. package/site-theme/partials/draft-notice.hbs +5 -0
  114. package/site-theme/partials/exturl.hbs +2 -0
  115. package/{hugo-theme/layouts/partials/footer.html → site-theme/partials/footer.hbs} +10 -7
  116. package/site-theme/partials/header.hbs +44 -0
  117. package/site-theme/partials/hero-banner.hbs +11 -0
  118. package/site-theme/partials/infobox-entry.hbs +2 -0
  119. package/site-theme/partials/infobox-section.hbs +31 -0
  120. package/site-theme/partials/infobox-value.hbs +2 -0
  121. package/site-theme/partials/infobox.hbs +18 -0
  122. package/site-theme/partials/list-members.hbs +9 -0
  123. package/site-theme/partials/nav-links.hbs +5 -0
  124. package/site-theme/partials/page-body.hbs +48 -0
  125. package/site-theme/partials/page-list.hbs +14 -0
  126. package/site-theme/partials/related.hbs +24 -0
  127. package/site-theme/partials/search-meta.hbs +6 -0
  128. package/site-theme/partials/search-names.hbs +2 -0
  129. package/site-theme/partials/search.hbs +52 -0
  130. package/site-theme/partials/tags.hbs +4 -0
  131. package/site-theme/partials/toc.hbs +7 -0
  132. package/{hugo-theme → site-theme}/static/css/style.css +14 -0
  133. package/stage.mjs +1 -2
  134. package/types/config.d.mts +8 -4
  135. package/types/content-config.d.mts +15 -15
  136. package/types/engine/asset-shipping.d.mts +5 -2
  137. package/types/engine/base-compiler.d.mts +20 -2
  138. package/types/engine/content-address.d.mts +1 -1
  139. package/types/engine/content-alerts.d.mts +8 -2
  140. package/types/engine/content-blocks.d.mts +11 -4
  141. package/types/engine/content-expand.d.mts +288 -0
  142. package/types/engine/content-figures.d.mts +11 -3
  143. package/types/engine/content-glyphs.d.mts +85 -0
  144. package/types/engine/content-images.d.mts +6 -7
  145. package/types/engine/content-links.d.mts +1 -1
  146. package/types/engine/content-render.d.mts +199 -0
  147. package/types/engine/content-scripts.d.mts +62 -0
  148. package/types/engine/content-spans.d.mts +1 -1
  149. package/types/engine/content-styles.d.mts +33 -0
  150. package/types/engine/content-symbols.d.mts +35 -0
  151. package/types/engine/core-report.d.mts +45 -0
  152. package/types/engine/core-vocabulary.d.mts +53 -0
  153. package/types/engine/dictionary-html.d.mts +8 -0
  154. package/types/engine/field-reference.d.mts +1 -1
  155. package/types/engine/heading-attributes.d.mts +20 -0
  156. package/types/engine/helpers.d.mts +3 -10
  157. package/types/engine/homepage.d.mts +11 -24
  158. package/types/engine/html-minify.d.mts +9 -0
  159. package/types/engine/index.d.mts +2 -1
  160. package/types/engine/language-terms.d.mts +24 -2
  161. package/types/engine/logographic.d.mts +45 -0
  162. package/types/engine/map-lexicon.d.mts +48 -8
  163. package/types/engine/map-places.d.mts +8 -0
  164. package/types/engine/markdown-expressions.d.mts +0 -2
  165. package/types/engine/metre-declaration.d.mts +39 -0
  166. package/types/engine/pdf-render.d.mts +6 -2
  167. package/types/engine/post-fields.d.mts +44 -0
  168. package/types/engine/preview-index.d.mts +72 -0
  169. package/types/engine/preview-source.d.mts +51 -0
  170. package/types/engine/script-emphasis-terms.d.mts +21 -0
  171. package/types/engine/script-emphasis.d.mts +84 -0
  172. package/types/engine/script-font-delivery.d.mts +4 -4
  173. package/types/engine/site-build.d.mts +71 -113
  174. package/types/engine/site-config.d.mts +14 -134
  175. package/types/engine/site-files.d.mts +73 -0
  176. package/types/engine/site-index.d.mts +11 -3
  177. package/types/engine/site-preview.d.mts +15 -19
  178. package/types/engine/site-render.d.mts +171 -0
  179. package/types/engine/site-root.d.mts +12 -4
  180. package/types/engine/site-search.d.mts +54 -0
  181. package/types/engine/site-serve.d.mts +44 -0
  182. package/types/engine/site-theme-banner.d.mts +51 -0
  183. package/types/engine/site-theme-urls.d.mts +60 -0
  184. package/types/engine/site-theme.d.mts +127 -0
  185. package/types/engine/text-maps.d.mts +17 -3
  186. package/types/engine/typographer.d.mts +11 -0
  187. package/types/engine/verse-metre.d.mts +131 -0
  188. package/types/engine/wikilink-syntax.d.mts +30 -48
  189. package/types/engine/wikilinks.d.mts +330 -14
  190. package/types/engine/word-forms.d.mts +3 -2
  191. package/types/manifest.d.mts +3 -4
  192. package/types/stage.d.mts +1 -2
  193. package/types/vendor/markdownlint.d.mts +8 -0
  194. package/vendor/markdownlint.mjs +20388 -0
  195. package/engine/web-wikilinks.mjs +0 -594
  196. package/hugo-theme/layouts/404.html +0 -85
  197. package/hugo-theme/layouts/_default/baseof.html +0 -67
  198. package/hugo-theme/layouts/_default/list.html +0 -139
  199. package/hugo-theme/layouts/_default/single.html +0 -4
  200. package/hugo-theme/layouts/blog/list.html +0 -54
  201. package/hugo-theme/layouts/blog-post/single.html +0 -36
  202. package/hugo-theme/layouts/index.html +0 -75
  203. package/hugo-theme/layouts/partials/banner-url.html +0 -141
  204. package/hugo-theme/layouts/partials/cdn-url.html +0 -36
  205. package/hugo-theme/layouts/partials/dictionary-lists.html +0 -58
  206. package/hugo-theme/layouts/partials/draft-notice.html +0 -41
  207. package/hugo-theme/layouts/partials/draft-state.html +0 -26
  208. package/hugo-theme/layouts/partials/header.html +0 -35
  209. package/hugo-theme/layouts/partials/hero-banner.html +0 -85
  210. package/hugo-theme/layouts/partials/infobox/entry.html +0 -18
  211. package/hugo-theme/layouts/partials/infobox/items.html +0 -26
  212. package/hugo-theme/layouts/partials/infobox/section.html +0 -56
  213. package/hugo-theme/layouts/partials/infobox/value.html +0 -43
  214. package/hugo-theme/layouts/partials/infobox.html +0 -57
  215. package/hugo-theme/layouts/partials/page-body.html +0 -152
  216. package/hugo-theme/layouts/partials/related.html +0 -138
  217. package/hugo-theme/layouts/partials/search.html +0 -84
  218. package/hugo-theme/layouts/partials/site-url.html +0 -32
  219. package/hugo-theme/layouts/partials/tags.html +0 -30
  220. package/hugo-theme/layouts/partials/toc.html +0 -28
  221. package/hugo-theme/layouts/partials/warn-missing-banner.html +0 -3
  222. package/hugo-theme/layouts/shortcodes/cartouche.html +0 -64
  223. package/hugo-theme/layouts/shortcodes/exturl.html +0 -12
  224. package/hugo-theme/layouts/shortcodes/glyph.html +0 -43
  225. package/hugo-theme/layouts/shortcodes/pagelist.html +0 -63
  226. package/hugo-theme/theme.toml +0 -11
  227. package/types/engine/web-wikilinks.d.mts +0 -107
  228. /package/{hugo-theme → site-theme}/data/banner-kinds.yaml +0 -0
  229. /package/{hugo-theme → site-theme}/static/css/sohl-icons.css +0 -0
  230. /package/{hugo-theme → site-theme}/static/fonts/game-icons-kb.woff2 +0 -0
  231. /package/{hugo-theme → site-theme}/static/img/banners/takheperu-hieroglyphs.svg +0 -0
  232. /package/{hugo-theme → site-theme}/static/img/cartouches/takheperu.svg +0 -0
  233. /package/{hugo-theme → site-theme}/static/js/inline-spoilers.js +0 -0
@@ -1,14 +1,24 @@
1
1
  /**
2
- * Render one complete buffer with no configuration, index, filesystem or database.
2
+ * Render one complete buffer.
3
+ *
4
+ * Without `index` the buffer is rendered with no configuration, content index,
5
+ * filesystem or database: wikilinks, spans and expressions show as highlighted
6
+ * authored source. With `index` the buffer is expanded as the website expands
7
+ * a page and rendered as every target renders it, so links, embeds, marked
8
+ * text, icons and figure numbers read as they will on the page; only what a
9
+ * buffer cannot answer, such as a query, stays highlighted source.
10
+ *
3
11
  * @param {string} text - Markdown, optionally beginning with YAML frontmatter.
4
- * @param {{dark?: boolean, infobox?: boolean, file?: string, currentDate?: string}} [options] - Explicit palette, profile visibility, diagnostic filename and neutral current date (default "720.1").
12
+ * @param {{dark?: boolean, infobox?: boolean, file?: string, currentDate?: string,
13
+ * index?: import("./preview-index.mjs").PreviewIndex}} [options] - Explicit palette, profile visibility, diagnostic filename, neutral current date (default "720.1") and the content index, from {@link module:engine/preview-index.previewIndex}.
5
14
  * @returns {{ok: boolean, html: string, frontmatter: object, findings: object[]}} HTML and metadata with locally calculable ages; unavailable ages remain absent or null.
6
15
  */
7
- export function renderPreview(text: string, { dark, infobox, file, currentDate }?: {
16
+ export function renderPreview(text: string, { dark, infobox, file, currentDate, index }?: {
8
17
  dark?: boolean;
9
18
  infobox?: boolean;
10
19
  file?: string;
11
20
  currentDate?: string;
21
+ index?: import("./preview-index.mjs").PreviewIndex;
12
22
  }): {
13
23
  ok: boolean;
14
24
  html: string;
@@ -23,19 +33,5 @@ export function renderPreview(text: string, { dark, infobox, file, currentDate }
23
33
  export function readPreviewCurrentDate(root: string): Promise<string>;
24
34
  /** Both explicit palettes, scoped to the preview container. */
25
35
  export function previewStyles(): string;
26
- /** Explicit dependency policy: a new registered helper requires a preview decision. */
27
- export const PREVIEW_HELPERS: Readonly<{
28
- eq: "local";
29
- gt: "local";
30
- gte: "local";
31
- lt: "local";
32
- lte: "local";
33
- not: "local";
34
- and: "local";
35
- or: "local";
36
- words: "local";
37
- digits: "local";
38
- sql: "dependent";
39
- dateformat: "dependent";
40
- ref: "reference";
41
- }>;
36
+ export { PREVIEW_HELPERS };
37
+ import { PREVIEW_HELPERS } from "./preview-source.mjs";
@@ -0,0 +1,171 @@
1
+ /**
2
+ * Pages in the order a reader walks them: by `weight`, lightest first and an
3
+ * unweighted page last; then newest first by `date`; then by title; then by
4
+ * address. A page's own `weight` and `date` are read before its `params`'.
5
+ *
6
+ * @template {{title?: string, url: string, date?: unknown, weight?: number, params?: object}} T
7
+ * @param {readonly T[]} pages - The pages.
8
+ * @returns {T[]} A sorted copy.
9
+ */
10
+ export function siteOrder<T extends {
11
+ title?: string;
12
+ url: string;
13
+ date?: unknown;
14
+ weight?: number;
15
+ params?: object;
16
+ }>(pages: readonly T[]): T[];
17
+ /**
18
+ * Every page of a site: the pages it is given, with their siblings, and the
19
+ * listings derived from them.
20
+ *
21
+ * @param {object} site - The site, as {@link writeSite} takes it.
22
+ * @param {readonly object[]} pages - The home page, the regular pages and any
23
+ * authored section pages.
24
+ * @returns {object[]} Every page, home first, then the regular pages, the
25
+ * sections, and the tag pages.
26
+ */
27
+ export function siteTree(site: object, pages: readonly object[]): object[];
28
+ /**
29
+ * Write the files the layouts link: the theme's own, and the code stylesheet.
30
+ *
31
+ * @param {string} out - The directory the site is written to.
32
+ * @param {string} [staticDir] - The theme's own files.
33
+ * @returns {string[]} The files the theme generates, each written. The theme's
34
+ * own files are copied as a tree and not listed.
35
+ */
36
+ export function writeThemeFiles(out: string, staticDir?: string): string[];
37
+ /**
38
+ * Draw a site and write it.
39
+ *
40
+ * @param {object} options - The inputs.
41
+ * @param {object} options.site - The site, as
42
+ * {@link module:engine/site-theme.createSiteTheme} takes it, with `tagPages`,
43
+ * `feed` and `sitemaps` as the module description sets out. `pages` and
44
+ * `pageExists` are filled in here.
45
+ * @param {readonly object[]} options.pages - The home page, the regular pages
46
+ * and any authored section pages, each as a layout is given it.
47
+ * @param {string} options.out - The directory written to. Emptied first.
48
+ * @param {(finding: import("./site-theme.mjs").Finding) => void} [options.report] -
49
+ * Receives each finding the layouts make.
50
+ * @param {string} [options.staticDir] - The theme's own files, copied first.
51
+ * @param {ReadonlySet<string>} [options.only] - The addresses of the pages to
52
+ * draw again into a site already written. Nothing else is touched.
53
+ * @returns {{files: string[], pages: string[], findings: object[]}} Every file
54
+ * written, the address of every page, and the layouts' findings.
55
+ * @throws {Error} When a page's address is outside the site, or a site served
56
+ * under a path asks for a sitemap index.
57
+ */
58
+ export function writeSite({ site, pages, out, report, staticDir, only }: {
59
+ site: object;
60
+ pages: readonly object[];
61
+ out: string;
62
+ report?: ((finding: import("./site-theme.mjs").Finding) => void) | undefined;
63
+ staticDir?: string | undefined;
64
+ only?: ReadonlySet<string> | undefined;
65
+ }): {
66
+ files: string[];
67
+ pages: string[];
68
+ findings: object[];
69
+ };
70
+ /**
71
+ * A package's pages, from its site build.
72
+ *
73
+ * Each body is rendered by the `web` renderer from the markdown the build
74
+ * expanded, and each page carries what it tells the search; see
75
+ * {@link module:engine/site-search}. The site carries what the configuration
76
+ * asks for: `site.tags` as `tagPages`, `site.feed` as the feed's section, each
77
+ * package of `site.sitemaps` as its sitemap's address on the site's origin,
78
+ * and each of `site.mergeIndexes` as the path of its search bundle.
79
+ *
80
+ * @param {object} options - The inputs.
81
+ * @param {object} options.config - The resolved configuration.
82
+ * @param {object} options.built - What `buildSite` returned with `write: false`.
83
+ * @param {{baseURL: string, title: string, params: object}} options.settings -
84
+ * From {@link module:engine/site-config.siteSettings}.
85
+ * @param {readonly {name: string, url: string, children?: object[]}[]} [options.navigation] -
86
+ * The menu.
87
+ * @param {number} [options.year] - The year the footer states.
88
+ * @returns {{site: object, pages: object[], pageOf: (entry: object) => object}}
89
+ * What {@link writeSite} is given, and how one note the build rendered again
90
+ * becomes its page.
91
+ */
92
+ export function packageSite({ config, built, settings, navigation, year }: {
93
+ config: object;
94
+ built: object;
95
+ settings: {
96
+ baseURL: string;
97
+ title: string;
98
+ params: object;
99
+ };
100
+ navigation?: readonly {
101
+ name: string;
102
+ url: string;
103
+ children?: object[];
104
+ }[] | undefined;
105
+ year?: number | undefined;
106
+ }): {
107
+ site: object;
108
+ pages: object[];
109
+ pageOf: (entry: object) => object;
110
+ };
111
+ /**
112
+ * The directory a package's site is written to: its base path under the
113
+ * deployed root, so a site served at `/` is written at the root itself.
114
+ *
115
+ * @param {object} config - The resolved configuration.
116
+ * @param {string} root - The deployed root.
117
+ * @returns {string} The directory.
118
+ */
119
+ export function siteDirectory(config: object, root: string): string;
120
+ /**
121
+ * Copy the script fonts the site's pages set their marked text in.
122
+ *
123
+ * @param {object} config - The resolved configuration.
124
+ * @param {string} out - The directory the site is written to.
125
+ * @returns {{findings: object[], count: number, dest?: string}} What checking
126
+ * the installed fonts found, and how many files were copied where. Nothing is
127
+ * copied when there is a finding, or when the package sets no script.
128
+ */
129
+ export function deliverSiteFonts(config: object, out: string): {
130
+ findings: object[];
131
+ count: number;
132
+ dest?: string;
133
+ };
134
+ /**
135
+ * Build a package's site from its content tree and write it.
136
+ *
137
+ * The site's address, title and menu are read before the tree is, so a site
138
+ * that cannot be described fails before anything is built. A gate that fires
139
+ * stops the build before anything is written; a note in error is written as
140
+ * its page shows it, with the finding in what is returned, which
141
+ * `siteBuildFailed` reads.
142
+ *
143
+ * @param {object} options - The inputs.
144
+ * @param {object} options.config - The resolved configuration.
145
+ * @param {string} options.out - The directory the site is written to, which
146
+ * is the package's own directory under the deployed root.
147
+ * @param {number} [options.year] - The year the footer states.
148
+ * @returns {Promise<{built: object, written: object|null, fonts: object|null,
149
+ * site?: object, pages?: object[], pageOf?: (entry: object) => object}>}
150
+ * What the build found, and, when it found nothing that stops it, what was
151
+ * written, the pages it was written from and how a note rendered again
152
+ * becomes its page. `written` is `null` when a gate fired.
153
+ * @throws {Error} When the site's settings or its cached menu cannot be read.
154
+ */
155
+ export function buildPackageSite({ config, out, year }: {
156
+ config: object;
157
+ out: string;
158
+ year?: number | undefined;
159
+ }): Promise<{
160
+ built: object;
161
+ written: object | null;
162
+ fonts: object | null;
163
+ site?: object;
164
+ pages?: object[];
165
+ pageOf?: (entry: object) => object;
166
+ }>;
167
+ /**
168
+ * The files the layouts link that the theme ships as they are: the site and
169
+ * icon stylesheets, the spoiler script, the icon font and the theme's images.
170
+ */
171
+ export const SITE_STATIC_DIR: string;
@@ -27,12 +27,16 @@ export function noindexHeaders(): string[];
27
27
  * that names their version, so a year's lifetime never serves a stale file.
28
28
  *
29
29
  * @param {object} [options] - Options.
30
- * @param {string} [options.pkg] - The content package, which is the prefix.
30
+ * @param {string} [options.pkg] - The content package, whose site is served at
31
+ * `/<pkg>/` unless `base` says otherwise.
32
+ * @param {string} [options.base] - The path the site is served at, beginning
33
+ * and ending with `/`.
31
34
  * @param {boolean} [options.fonts] - Whether the site carries the fonts.
32
35
  * @returns {string} The file's contents.
33
36
  */
34
- export function headers({ pkg, fonts }?: {
37
+ export function headers({ pkg, base, fonts }?: {
35
38
  pkg?: string | undefined;
39
+ base?: string | undefined;
36
40
  fonts?: boolean | undefined;
37
41
  }): string;
38
42
  export function indexSite(where: {
@@ -59,7 +63,10 @@ export function indexSite(where: {
59
63
  *
60
64
  * @param {object} options - Options.
61
65
  * @param {string} options.pkg - The content package name, which is also the
62
- * directory Hugo rendered into.
66
+ * directory the site is rendered into unless `base` says otherwise.
67
+ * @param {string} [options.base] - The path the site is served at, beginning
68
+ * and ending with `/`; the site is rendered into that path under `out`, so
69
+ * a site served at `/` is rendered at `out` itself.
63
70
  * @param {string} options.out - The directory that is deployed.
64
71
  * @param {boolean} [options.search] - Whether to build the search index;
65
72
  * `site.search` in the configuration. Default `true`.
@@ -73,8 +80,9 @@ export function indexSite(where: {
73
80
  * under the prefix; or, located at the rendered site, when the indexer
74
81
  * fails.
75
82
  */
76
- export function writeSiteRoot({ pkg, out, search, indexer }: {
83
+ export function writeSiteRoot({ pkg, base, out, search, indexer }: {
77
84
  pkg: string;
85
+ base?: string | undefined;
78
86
  out: string;
79
87
  search?: boolean | undefined;
80
88
  indexer?: SiteIndexer | undefined;
@@ -0,0 +1,54 @@
1
+ /**
2
+ * The continents and regions every place lies in.
3
+ *
4
+ * @param {Map<string, {shortcode: string, name: string, subType?: string, parents: string[]}>} places -
5
+ * Every place, by shortcode, as {@link module:engine/map-places.mapWorld} reads them.
6
+ * @returns {(shortcodes: Iterable<string>) => {continents: string[], regions: string[]}}
7
+ * The names of the continents and the outermost regions the given places lie
8
+ * in, each sorted.
9
+ */
10
+ export function placeGeography(places: Map<string, {
11
+ shortcode: string;
12
+ name: string;
13
+ subType?: string;
14
+ parents: string[];
15
+ }>): (shortcodes: Iterable<string>) => {
16
+ continents: string[];
17
+ regions: string[];
18
+ };
19
+ /**
20
+ * The places a note lies in: itself for a place, its `homes` and its
21
+ * `locations` otherwise.
22
+ *
23
+ * @param {object} fm - The note's frontmatter.
24
+ * @returns {string[]} Shortcodes, lower case.
25
+ */
26
+ export function notePlaces(fm: object): string[];
27
+ /**
28
+ * What a note's page tells the search.
29
+ *
30
+ * @param {object} fm - The page's frontmatter: the note's, with its `package`.
31
+ * @param {object} options - What the values resolve against.
32
+ * @param {(shortcodes: Iterable<string>) => {continents: string[], regions: string[]}} options.geography -
33
+ * From {@link placeGeography}.
34
+ * @param {object} [options.index] - The site's address index, which names the
35
+ * culture `data.culture` names.
36
+ * @returns {{filters: Array<{name: string, values: string[]}>, names: string[]}}
37
+ * Each filter with a value, in {@link SEARCH_FILTERS} order, and the names a
38
+ * search weights.
39
+ */
40
+ export function searchMetadata(fm: object, { geography, index }: {
41
+ geography: (shortcodes: Iterable<string>) => {
42
+ continents: string[];
43
+ regions: string[];
44
+ };
45
+ index?: object | undefined;
46
+ }): {
47
+ filters: Array<{
48
+ name: string;
49
+ values: string[];
50
+ }>;
51
+ names: string[];
52
+ };
53
+ /** The filters a note's page carries, in the order a reader is offered them. */
54
+ export const SEARCH_FILTERS: readonly string[];
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Serve a package's site, and keep it current.
3
+ *
4
+ * @param {object} options - The inputs.
5
+ * @param {object} options.config - The resolved configuration.
6
+ * @param {string} options.out - The site's directory under the deployed
7
+ * root, which the site is written to.
8
+ * @param {string} [options.root] - The deployed root, which is served. The
9
+ * directory above `out` by default; `out` itself for a site served at `/`.
10
+ * @param {string} [options.host] - The address to listen on.
11
+ * @param {number} [options.port] - The port; `0` takes any free one.
12
+ * @param {boolean} [options.search] - Build the search index after the first
13
+ * build, where the site has one.
14
+ * @param {number} [options.year] - The year the footer states.
15
+ * @param {(event: {kind: string, built?: object, files?: string[], findings?: object[], error?: unknown}) => void} [options.report] -
16
+ * Told of each build: `built` for a whole build, `page` for one note's page,
17
+ * `theme` for the theme, `failed` with what the build found, `error` with
18
+ * what it threw.
19
+ * @returns {Promise<{url: string, close: () => Promise<void>, settled: () => Promise<void>}>}
20
+ * The address of the site's home page, how to stop serving, and a promise
21
+ * for the moment every change seen so far has been written.
22
+ */
23
+ export function serveSite({ config, out, root, host, port, search, year, report, }: {
24
+ config: object;
25
+ out: string;
26
+ root?: string | undefined;
27
+ host?: string | undefined;
28
+ port?: number | undefined;
29
+ search?: boolean | undefined;
30
+ year?: number | undefined;
31
+ report?: ((event: {
32
+ kind: string;
33
+ built?: object;
34
+ files?: string[];
35
+ findings?: object[];
36
+ error?: unknown;
37
+ }) => void) | undefined;
38
+ }): Promise<{
39
+ url: string;
40
+ close: () => Promise<void>;
41
+ settled: () => Promise<void>;
42
+ }>;
43
+ /** The address a served page listens on for the server's reloads. */
44
+ export const RELOAD_PATH: "/__package-build/reload";
@@ -0,0 +1,51 @@
1
+ /**
2
+ * The banner data the theme ships.
3
+ *
4
+ * @returns {{banners: object, kinds: object}} The inventory and the kind mapping.
5
+ */
6
+ export function shippedBannerData(): {
7
+ banners: object;
8
+ kinds: object;
9
+ };
10
+ /**
11
+ * The address of a page's banner.
12
+ *
13
+ * @param {object} site - The site: `params.cdnBaseURL` and `basePath`.
14
+ * @param {object} fields - What the page states.
15
+ * @param {object} [fields.data] - The page's `data`, read for the resolved `banner`.
16
+ * @param {unknown} [fields.banner] - The hand-authored `banner` value.
17
+ * @param {string} [fields.type] - The note `type`.
18
+ * @param {string} [fields.subType] - The note `subType`.
19
+ * @param {string} [fields.category] - The page's `category`.
20
+ * @param {string} [fields.subtype] - The name to default to when no `type` is given.
21
+ * @param {string} [fields.context] - The page address, named in a report.
22
+ * @param {object} [options] - Options.
23
+ * @param {{banners: object, kinds: object}} [options.data] - The inventory and the
24
+ * kind mapping. The shipped ones by default.
25
+ * @param {(finding: {severity: string, message: string, page?: string}) => void} [options.report] -
26
+ * Receives each name that misses the inventory, once.
27
+ * @param {Set<string>} [options.reported] - The names already reported.
28
+ * @returns {string} The address, or `""` when the page has no banner.
29
+ */
30
+ export function bannerUrl(site: object, fields: {
31
+ data?: object | undefined;
32
+ banner?: unknown;
33
+ type?: string | undefined;
34
+ subType?: string | undefined;
35
+ category?: string | undefined;
36
+ subtype?: string | undefined;
37
+ context?: string | undefined;
38
+ }, { data, report, reported }?: {
39
+ data?: {
40
+ banners: object;
41
+ kinds: object;
42
+ } | undefined;
43
+ report?: ((finding: {
44
+ severity: string;
45
+ message: string;
46
+ page?: string;
47
+ }) => void) | undefined;
48
+ reported?: Set<string> | undefined;
49
+ }): string;
50
+ /** The directory holding the banner inventory and the kind mapping. */
51
+ export const BANNER_DATA_DIR: string;
@@ -0,0 +1,60 @@
1
+ /** Whether an address names a host: `http://`, `https://` or `//`. */
2
+ export function isAbsoluteUrl(url: any): boolean;
3
+ /**
4
+ * The path a site is served under, with a leading and a trailing slash.
5
+ *
6
+ * @param {object} site - The site; `baseURL` is its address.
7
+ * @returns {string} `/` for a site at its origin's root, `/thalorna/` for one under a prefix.
8
+ */
9
+ export function basePath(site: object): string;
10
+ /**
11
+ * A path inside the site, under its base path.
12
+ *
13
+ * A leading slash is dropped first: it would otherwise read as "from the
14
+ * origin" and leave the base path off.
15
+ *
16
+ * @param {object} site - The site.
17
+ * @param {string} [target] - The path; empty for the site's root.
18
+ * @returns {string} The address.
19
+ */
20
+ export function relUrl(site: object, target?: string): string;
21
+ /**
22
+ * An asset path, resolved against the site's asset host.
23
+ *
24
+ * An absolute address is returned as written. Otherwise the path is joined onto
25
+ * `params.cdnBaseURL`, and with none set it is a path inside the site.
26
+ *
27
+ * @param {object} site - The site; `params.cdnBaseURL` is the asset root.
28
+ * @param {string} target - The asset path.
29
+ * @returns {string} The address.
30
+ */
31
+ export function cdnUrl(site: object, target: string): string;
32
+ /**
33
+ * A link a consuming site supplied, resolved against the site it is rendered on.
34
+ *
35
+ * An absolute address, a fragment and a query are returned as written; anything
36
+ * else is a path inside the site.
37
+ *
38
+ * @param {object} site - The site.
39
+ * @param {string} [url] - The link; empty for the site's root.
40
+ * @returns {string} The address.
41
+ */
42
+ export function siteUrl(site: object, url?: string): string;
43
+ /**
44
+ * A link from a page's data, with a scheme that could run script refused.
45
+ *
46
+ * @param {unknown} url - The link as the data states it.
47
+ * @returns {string} The link, or `#` when its scheme is not one a reader should follow.
48
+ */
49
+ export function safeUrl(url: unknown): string;
50
+ /**
51
+ * The address of a tag's listing page.
52
+ *
53
+ * One function writes it for the link in a page's tag row and for the page the
54
+ * site build writes, so the two cannot disagree.
55
+ *
56
+ * @param {object} site - The site.
57
+ * @param {string} tag - The tag.
58
+ * @returns {string} The address.
59
+ */
60
+ export function tagUrl(site: object, tag: string): string;
@@ -0,0 +1,127 @@
1
+ /** A string with its first letter capitalised and its separators read as spaces. */
2
+ export function humanize(value: any): string;
3
+ /** The text of HTML: tags dropped, character references decoded, whitespace collapsed. */
4
+ export function plainText(html: any): string;
5
+ /** Whether a page states it is a draft. */
6
+ export function isDraft(params?: {}): any;
7
+ /**
8
+ * The subject tags of a page: every tag but the one that marks a draft.
9
+ *
10
+ * @param {object} params - The page's frontmatter.
11
+ * @returns {string[]} The tags.
12
+ */
13
+ export function subjectTags(params?: object): string[];
14
+ /**
15
+ * The headings of rendered HTML that a contents list names.
16
+ *
17
+ * @param {string} html - A page's body.
18
+ * @returns {Array<{level: number, id: string, text: string}>} The `h2` and `h3`
19
+ * headings in document order, the footnote list's own heading left out; `id`
20
+ * is empty for a heading that has none.
21
+ */
22
+ export function pageHeadings(html: string): Array<{
23
+ level: number;
24
+ id: string;
25
+ text: string;
26
+ }>;
27
+ /**
28
+ * A contents list for a page's headings.
29
+ *
30
+ * @param {Array<{level: number, id: string, text: string}>} headings - From {@link pageHeadings}.
31
+ * @returns {string} A `nav` of nested lists, or `""` when there are no headings. A
32
+ * heading with no id is listed without a link.
33
+ */
34
+ export function tableOfContents(headings: Array<{
35
+ level: number;
36
+ id: string;
37
+ text: string;
38
+ }>): string;
39
+ /**
40
+ * The page before and the page after this one.
41
+ *
42
+ * `siblings` is in the order a reader walks. Where the section holds more than
43
+ * one catalog, the siblings are narrowed to the pages sharing this page's
44
+ * catalog key: `type`, or for a `doc` its `subType` or `category`. A section
45
+ * holding one catalog is left alone, as is a page declaring none.
46
+ *
47
+ * @param {object} page - The page.
48
+ * @param {boolean} [narrow] - Whether to narrow to the page's catalog.
49
+ * @returns {{prev?: object, next?: object}} The neighbours; `prev` is the entry
50
+ * after this one in `siblings`, and `next` the entry before it.
51
+ */
52
+ export function neighbours(page: object, narrow?: boolean): {
53
+ prev?: object;
54
+ next?: object;
55
+ };
56
+ /**
57
+ * @typedef {object} Finding
58
+ * @property {"warning"|"error"} severity
59
+ * @property {string} message
60
+ * @property {string} [page] - The address of the page the finding is about.
61
+ * @property {string} [file] - The file the page was written in.
62
+ * @property {Array<string|number>} [param] - The path of the site parameter
63
+ * the finding is about, such as `["notfound", "links", 1, "url"]`.
64
+ */
65
+ /**
66
+ * Create the layouts for one site.
67
+ *
68
+ * @param {object} options - The inputs.
69
+ * @param {object} options.site - The site; see the module description.
70
+ * @param {string} [options.dir] - The directory holding `layouts/` and
71
+ * `partials/`. The shipped theme by default.
72
+ * @param {{banners: object, kinds: object}} [options.bannerData] - The banner
73
+ * inventory and kind mapping. The shipped ones by default.
74
+ * @param {(finding: Finding) => void} [options.report] - Receives each finding
75
+ * as it is made. Every finding is also kept in `findings`.
76
+ * @returns {{
77
+ * render: (page: object) => string,
78
+ * layoutFor: (page: object) => string,
79
+ * partial: (name: string, context?: object) => string,
80
+ * findings: Finding[],
81
+ * }} The theme.
82
+ */
83
+ export function createSiteTheme({ site, dir, bannerData, report }: {
84
+ site: object;
85
+ dir?: string | undefined;
86
+ bannerData?: {
87
+ banners: object;
88
+ kinds: object;
89
+ } | undefined;
90
+ report?: ((finding: Finding) => void) | undefined;
91
+ }): {
92
+ render: (page: object) => string;
93
+ layoutFor: (page: object) => string;
94
+ partial: (name: string, context?: object) => string;
95
+ findings: Finding[];
96
+ };
97
+ /**
98
+ * The files the layouts link that the theme generates.
99
+ *
100
+ * @returns {Array<{path: string, content: string}>} Each file's path under the
101
+ * site and its contents.
102
+ */
103
+ export function siteThemeAssets(): Array<{
104
+ path: string;
105
+ content: string;
106
+ }>;
107
+ /** The directory the layouts and partials are read from. */
108
+ export const SITE_THEME_DIR: string;
109
+ /** The layouts a page can be drawn by. */
110
+ export const LAYOUTS: readonly string[];
111
+ export type Finding = {
112
+ severity: "warning" | "error";
113
+ message: string;
114
+ /**
115
+ * - The address of the page the finding is about.
116
+ */
117
+ page?: string | undefined;
118
+ /**
119
+ * - The file the page was written in.
120
+ */
121
+ file?: string | undefined;
122
+ /**
123
+ * - The path of the site parameter
124
+ * the finding is about, such as `["notfound", "links", 1, "url"]`.
125
+ */
126
+ param?: (string | number)[] | undefined;
127
+ };
@@ -39,14 +39,16 @@ export function capitalNative(map: TextMap, font: string | undefined, word: stri
39
39
  * as it is.
40
40
  * @param {string} text - The text, with no escapes in it.
41
41
  * @param {MapOptions} [options] - The face, and the native forms of words.
42
- * @returns {{text: string, pieces: Array<{at: number, from: string, to: string, row: boolean, native?: boolean}>}}
42
+ * @returns {{text: string, pieces: Array<{at: number, from: string, to: string, row: boolean, native?: boolean, unwritten?: object}>}}
43
43
  * The rewritten text, and each piece of it with the UTF-16 offset in `text`
44
44
  * it came from: a matched row's `from` and what it wrote, a word and its
45
45
  * native form (`native: true`), or one character that passed through. A
46
46
  * capitalised word whose native form the rows cannot capitalise is written
47
47
  * as stated and carries `uncapitalised`, the lowercase form it was found by.
48
+ * Under a logographic map, a word with no writing is written as typed and
49
+ * carries `unwritten`, why it has none.
48
50
  */
49
- export function applyMap(map: TextMap | undefined, text: string, { font, native }?: MapOptions): {
51
+ export function applyMap(map: TextMap | undefined, text: string, { font, native, writing }?: MapOptions): {
50
52
  text: string;
51
53
  pieces: Array<{
52
54
  at: number;
@@ -54,6 +56,7 @@ export function applyMap(map: TextMap | undefined, text: string, { font, native
54
56
  to: string;
55
57
  row: boolean;
56
58
  native?: boolean;
59
+ unwritten?: object;
57
60
  }>;
58
61
  };
59
62
  /**
@@ -78,7 +81,8 @@ export function mapRows(records: Iterable<Record<string, any>>, ownerOf: (record
78
81
  /**
79
82
  * Check a note's `data.map`: its name, that no other note declares it, each
80
83
  * row written as a list, a `before` condition on a map with no `vowels`, an
81
- * empty `fonts`, and a generic family in it. The data-key check owns every
84
+ * empty `fonts`, a generic family in it, and a row of a logographic map that
85
+ * matches a letter. The data-key check owns every
82
86
  * key, its kind and the words a condition takes; whether a listed face is
83
87
  * installed, and draws what the map writes, is
84
88
  * {@link module:engine/map-lexicon.checkMapFonts}'s.
@@ -136,6 +140,11 @@ export type TextMap = {
136
140
  * - Its name.
137
141
  */
138
142
  name: string;
143
+ /**
144
+ * - Whether it writes words from the lexicon
145
+ * alone, its rows only between them.
146
+ */
147
+ logographic: boolean;
139
148
  /**
140
149
  * - The characters `before: vowel` reads.
141
150
  */
@@ -172,4 +181,9 @@ export type MapOptions = {
172
181
  * form, for the word exactly as given, or `undefined` where it states none.
173
182
  */
174
183
  native?: ((word: string) => string | undefined) | undefined;
184
+ /**
185
+ * -
186
+ * A word's writing under a logographic map; without one, no word has one.
187
+ */
188
+ writing?: ((word: string) => import("./logographic.mjs").Writing) | undefined;
175
189
  };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Set typographic punctuation in every inline run.
3
+ *
4
+ * @param {import("markdown-it")} md - Markdown parser to extend.
5
+ */
6
+ export function typographerPlugin(md: typeof import("markdown-it")): void;
7
+ /**
8
+ * The token a typographic character is written as. It is a token of its own,
9
+ * not text, so a reader of a heading's text can tell where it stands.
10
+ */
11
+ export const TYPOGRAPHIC: "typographic";