@heroiclands/package-build 22.12.2 → 22.13.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.
@@ -1,14 +1,9 @@
1
1
  /**
2
- * A complete Address: four segments, and nothing else.
3
- *
4
- * `type` is the segment the canonical string carries, after the `doc<type>`
5
- * redirect. There is no fifth field recording the written form, because the
6
- * written form is a rendering rather than part of the value.
2
+ * A complete Address: four segments, with no memory of the authored form.
7
3
  *
8
4
  * @typedef {object} AddressTuple
9
5
  * @property {string} package - The owning **content** package.
10
- * @property {string} system - The system whose document this addresses, or
11
- * `none`.
6
+ * @property {string} system - `note`, `none`, or a game system id.
12
7
  * @property {string} type - The type segment of the canonical Address.
13
8
  * @property {string} shortcode - The note's `shortcode`.
14
9
  */
@@ -33,29 +28,8 @@
33
28
  * @typedef {{reason: string, package?: string}} AddressProblem
34
29
  */
35
30
  /**
36
- * Every content type whose **prose compiles into a JournalEntry of its own**,
37
- * addressed by the virtual `doc<type>` qualifier.
38
- *
39
- * Every item type, every actor type, every map type, plus `macro` — a macro
40
- * note's body documents the script the note also compiles into a Macro, which
41
- * is the same shape as an item and its description: one note, two documents,
42
- * the prose living in the journals pack.
43
- *
44
- * **One set, read by the compilers and by the grammar alike.** The journals
45
- * pass decides what to compile from it, the link manifest decides what to
46
- * publish a `doc<type>` entry for, and the parser decides whether `doc<type>`
47
- * is a legal type segment. Held apart, the three drift into a manifest that
48
- * asserts documentation nothing compiled, a compiled entry no consumer can
49
- * address, or an authored `doc<type>` link that stops parsing. It is composed
50
- * exactly once, in `defineConfig`, and read from there — never recomposed at a
51
- * call site.
52
- *
53
- * `doc` notes are absent, for the reason that applies to them alone: a `doc`
54
- * note's single document *is* its prose, so there is no second document for a
55
- * `doc<type>` address to name.
56
- *
57
- * An accessor rather than a hoisted constant, so that importing this module
58
- * needs no configuration.
31
+ * The configured types whose prose compiles into a separate JournalEntry.
32
+ * The journal has a `note` Address with the authored type segment.
59
33
  *
60
34
  * @returns {ReadonlySet<string>} The configured doc-carrying types.
61
35
  */
@@ -69,30 +43,15 @@ export function docEntryTypes(): ReadonlySet<string>;
69
43
  * `macro`; false for `doc`.
70
44
  */
71
45
  export function hasDocEntry(type: string): boolean;
46
+ /** The segment of a note's own document. */
47
+ export function ownDocumentSystem(type: any): string;
72
48
  /**
73
- * Reads a qualifier as the **virtual `doc<type>`** form, or reports that it is
74
- * not one.
75
- *
76
- * A document and its documentation are two documents in two packs, so they need
77
- * two addresses. `skill-wpnc` is the item; `docskill-wpnc` is the JournalEntry
78
- * its prose compiled into, and `docmacro-autoattack` is the same arrangement
79
- * for a macro.
80
- *
81
- * The virtual form exists for a type that carries separate documentation
82
- * ({@link docEntryTypes} — the set the journals compiler and the link manifest
83
- * read too), **or** for one that routes to the items pack. The second clause
84
- * covers the open, unenumerated set: types that compile into items are not
85
- * enumerated anywhere, and a foreign package may publish an item type this
86
- * build has never heard of. Dropping it would silently unlink every `doc<type>`
87
- * address into such a package.
88
- *
89
- * A **real** type of the same name always wins: the virtual reading is only
90
- * consulted for a qualifier no authored note claims.
91
- *
92
- * @param {string} qualifier - The already-normalised type segment.
93
- * @param {Set<string>} types - Every type the content tree contains.
94
- * @returns {string|null} The underlying document type, or `null` when the
95
- * qualifier is not a virtual one.
49
+ * Read a `doc<type>` input qualifier as the underlying authored type.
50
+ * A real type with that spelling takes precedence.
51
+ *
52
+ * @param {string} qualifier - The type segment from the input.
53
+ * @param {Set<string>} types - Types in the content tree.
54
+ * @returns {string|null} The underlying type, or `null`.
96
55
  */
97
56
  export function resolveItemDocType(qualifier: string, types: Set<string>): string | null;
98
57
  /**
@@ -164,29 +123,17 @@ export function isAddressTuple(value: unknown): boolean;
164
123
  */
165
124
  export function renderAddress(tuple: AddressTuple): string;
166
125
  /**
167
- * Whether the type an Address names is one this position accepts.
126
+ * Whether the canonical type an Address names is accepted at this position.
168
127
  *
169
- * The second of the two questions, and separate from the first because the
170
- * accepted **set** is a property of the position while the grammar is not.
171
- *
172
- * **An accepted type carries its documentation form with it.** A position
173
- * accepting `weapongear` accepts `docweapongear`, because the journal that
174
- * documents a weapon is the same thing to a position that wanted a weapon — and
175
- * a prose address of one *is* the journal, so refusing it would refuse the form
176
- * an author most often writes. It is the widening `defineConfig` applies to the
177
- * types a package may claim, applied here to the types a position may take.
178
- *
179
- * @param {AddressTuple} tuple - A parsed Address.
180
- * @param {Iterable<string>} allowed - The types this position accepts.
181
- * @returns {boolean} True when the Address names one of them.
128
+ * @param {AddressTuple} tuple - A complete Address.
129
+ * @param {Iterable<string>} allowed - Accepted types.
130
+ * @returns {boolean} Whether the type is accepted.
182
131
  */
183
132
  export function acceptsType(tuple: AddressTuple, allowed: Iterable<string>): boolean;
184
133
  /**
185
134
  * Apply the defaults to a partial reading, giving a complete Address.
186
135
  *
187
- * The three rules of the module note, applied in the order they depend on each
188
- * other: the package, then the system the type may fix, then the redirect the
189
- * system may force.
136
+ * Complete a parsed Address using the citing position's package and system.
190
137
  *
191
138
  * @param {{type: string, shortcode: string, package?: string, system?: string,
192
139
  * itemDoc?: boolean}} read - A partial reading, as {@link readQualifier}
@@ -351,23 +298,10 @@ export const ADDRESS_SEPARATOR: string;
351
298
  * @type {number}
352
299
  */
353
300
  export const CANONICAL_KEY_SEGMENTS: number;
301
+ /** The accepted `doc<type>` input prefix for readable note links. */
302
+ export const ITEM_DOC_PREFIX: "doc";
354
303
  /**
355
- * The qualifier prefix that addresses a note's **documentation** rather than
356
- * the note's own document: `docskill-wpnc` is the JournalEntry that
357
- * `skill-wpnc`'s prose compiled into.
358
- *
359
- * Every doc-carrying type has a `doc<type>` counterpart, formed by prefix and
360
- * never enumerated, so the prefix itself is the whole of that vocabulary.
361
- *
362
- * @type {string}
363
- */
364
- export const ITEM_DOC_PREFIX: string;
365
- /**
366
- * A complete Address: four segments, and nothing else.
367
- *
368
- * `type` is the segment the canonical string carries, after the `doc<type>`
369
- * redirect. There is no fifth field recording the written form, because the
370
- * written form is a rendering rather than part of the value.
304
+ * A complete Address: four segments, with no memory of the authored form.
371
305
  */
372
306
  export type AddressTuple = {
373
307
  /**
@@ -375,8 +309,7 @@ export type AddressTuple = {
375
309
  */
376
310
  package: string;
377
311
  /**
378
- * - The system whose document this addresses, or
379
- * `none`.
312
+ * - `note`, `none`, or a game system id.
380
313
  */
381
314
  system: string;
382
315
  /**
@@ -69,12 +69,9 @@ export function packageAddress(fm: object): string;
69
69
  *
70
70
  * The **enclosing system block** decides, at any depth within it, and nothing
71
71
  * else does: `sohl.items[3].model` and `sohl.system.body.structure` are both
72
- * `sohl` because both sit under `sohl:`. Everywhere else is {@link NO_SYSTEM} —
73
- * top-level frontmatter, the shared `data:` container, and body prose, which has
74
- * no key path at all and passes `undefined`.
75
- *
76
- * It is the block rather than the field, so an `Address` field needs no opinion
77
- * about systems and no per-field table has to be kept in step with the schema.
72
+ * `sohl` because both sit under `sohl:`. Everywhere else takes
73
+ * {@link NOTE_SYSTEM}; fields declared for assets or folders supply their own
74
+ * `none` default at the field parser.
78
75
  *
79
76
  * The first segment must **be** a declared system, not merely look like one:
80
77
  * `sohlish.items` is a key called `sohlish`, and `notes.sohl.thing` names no
@@ -39,12 +39,8 @@ export function anchorsOf(body: string): Set<string>;
39
39
  * before, since the walk read the file and it then read it again for the raw
40
40
  * text.
41
41
  *
42
- * The index mirrors what both builds construct, including the two addresses a
43
- * doc-carrying note answers to: `type/shortcode` for the document, and
44
- * `doc<type>/shortcode` for the JournalEntry its prose compiles into. Once a
45
- * manifest publishes `doc<type>` entries that prefix is a *known type*, and the
46
- * virtual reading that used to answer for it no longer fires — a real type owns
47
- * its own name — so the note is indexed under both.
42
+ * The index holds each compiled document under its complete Address. Readable
43
+ * content uses `note`, and system documents use their declared system.
48
44
  *
49
45
  * @param {string} contentBase - Root of the content tree.
50
46
  * @param {object} [opts]
@@ -30,6 +30,7 @@ export const STRUCTURED_ADDRESSES: readonly ({
30
30
  shape: string;
31
31
  type: string;
32
32
  accepts: string[];
33
+ system: string;
33
34
  noteType?: undefined;
34
35
  } | {
35
36
  noteType: string;
@@ -37,5 +38,6 @@ export const STRUCTURED_ADDRESSES: readonly ({
37
38
  shape: string;
38
39
  type: string;
39
40
  accepts: string[];
41
+ system?: undefined;
40
42
  })[];
41
43
  export { AddressEntries, encodeAddresses, cloneAddressState } from "./address-values.mjs";
@@ -80,6 +80,8 @@ export function assertSystemCharset(segments: Iterable<string>, where?: string):
80
80
  * @type {string}
81
81
  */
82
82
  export const NO_SYSTEM: string;
83
+ /** The Address segment for a note's readable content. */
84
+ export const NOTE_SYSTEM: "note";
83
85
  /**
84
86
  * Every game system this toolchain compiles for.
85
87
  *