@gmb/bitmark-parser 7.2.0 → 7.4.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 (47) hide show
  1. package/README.md +163 -23
  2. package/config/bitmark-json.tsp +439 -0
  3. package/config/bitmark.json +85074 -0
  4. package/dist/browser/bitmark-parser.min.js +6 -4
  5. package/dist/browser/bitmark-parser.min.js.map +1 -1
  6. package/dist/browser/cjs/index.cjs +140 -72
  7. package/dist/browser/cjs/index.cjs.map +1 -1
  8. package/dist/browser/cjs/index.d.cts +6299 -6806
  9. package/dist/browser/esm/index.d.ts +6299 -6806
  10. package/dist/browser/esm/index.js +139 -72
  11. package/dist/browser/esm/index.js.map +1 -1
  12. package/dist/browser/esm/worker-entry.js +86 -57
  13. package/dist/browser/esm/worker-entry.js.map +1 -1
  14. package/dist/browser/wasm/bitmark_browser_full_wasm_bg.wasm +0 -0
  15. package/dist/browser/wasm/bitmark_json_wasm_bg.wasm +0 -0
  16. package/dist/browser/wasm/bitmark_wasm_bg.wasm +0 -0
  17. package/dist/index.cjs +76 -29
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +6299 -6806
  20. package/dist/index.d.ts +6299 -6806
  21. package/dist/index.js +75 -29
  22. package/dist/index.js.map +1 -1
  23. package/dist/legacy.cjs +4 -3
  24. package/dist/legacy.cjs.map +1 -1
  25. package/dist/legacy.d.cts +9 -1
  26. package/dist/legacy.d.ts +9 -1
  27. package/dist/legacy.js +4 -3
  28. package/dist/legacy.js.map +1 -1
  29. package/dist/worker-entry.cjs +23 -15
  30. package/dist/worker-entry.cjs.map +1 -1
  31. package/package.json +11 -7
  32. package/schema/bitmark.schema.json +10459 -14050
  33. package/wasm/bitmark_wasm.d.ts +12 -3
  34. package/wasm/bitmark_wasm.js +34 -15
  35. package/wasm/bitmark_wasm_bg.wasm +0 -0
  36. package/wasm/bitmark_wasm_bg.wasm.d.ts +2 -2
  37. package/wasm/package.json +1 -1
  38. package/wasm-bitmark-json/bitmark_json_wasm.d.ts +12 -3
  39. package/wasm-bitmark-json/bitmark_json_wasm.js +34 -15
  40. package/wasm-bitmark-json/bitmark_json_wasm_bg.wasm +0 -0
  41. package/wasm-bitmark-json/bitmark_json_wasm_bg.wasm.d.ts +2 -2
  42. package/wasm-bitmark-json/package.json +1 -1
  43. package/wasm-browser-full/bitmark_browser_full_wasm.d.ts +12 -3
  44. package/wasm-browser-full/bitmark_browser_full_wasm.js +34 -15
  45. package/wasm-browser-full/bitmark_browser_full_wasm_bg.wasm +0 -0
  46. package/wasm-browser-full/bitmark_browser_full_wasm_bg.wasm.d.ts +2 -2
  47. package/wasm-browser-full/package.json +1 -1
@@ -0,0 +1,439 @@
1
+ /**
2
+ * bitmark.json — the resolved bitmark configuration document.
3
+ *
4
+ * `bitmark-confgen` resolves the hand-edited jsonc config tree
5
+ * (`resources/bitmark-configurator/config`) plus `manifest.jsonc` into this
6
+ * one document at build time (PLAN-144, PLAN-207). The parser's lookup tables,
7
+ * the JSON Schema, the TypeScript types and the docs site are all generated
8
+ * from it, and the npm package ships the exact document its parser was
9
+ * compiled against as `@gmb/bitmark-parser/bitmark.json`, with this file
10
+ * beside it as `@gmb/bitmark-parser/bitmark-json.tsp`.
11
+ *
12
+ * Prose spec with the derivation algorithms: `.zen/specs/BITMARK-JSON-FORMAT.md`.
13
+ * Shape source of truth: `crates/app/bitmark_confgen/src/model.rs` — any change
14
+ * there updates this file in the same PR.
15
+ *
16
+ * Conventions:
17
+ * - Identity is text. Root entities are keyed by name in sorted maps; every
18
+ * single-parent construct nests inside its owner. There are no numeric ids.
19
+ * - Optional members are omitted when absent, never `null`. Two exceptions:
20
+ * flag booleans (`bodyRequired`, `alwaysEmit`, …) are present only when
21
+ * `true`, and `TagDef.default` is `null` to mean "omit".
22
+ * - Arrays are in semantic (declaration) order; maps are sorted by key.
23
+ * - Derived members (`allTags`, `usedBy`, `parentOverrides`, `resources`) are
24
+ * computed by confgen, never authored.
25
+ */
26
+ namespace BitmarkConfig;
27
+
28
+ /** A mapping-id → key-pattern record. Ids are registered in `mappingTypes`;
29
+ * a pattern is the verbatim authored JSON value (string, object or array of
30
+ * predicate records — see `crates/lib/jsonkey_parser/doc/`). */
31
+ model MappingKeys is Record<unknown>;
32
+
33
+ /** The document. */
34
+ model BitmarkJson {
35
+ /** App semver, from `manifest.jsonc` (kept in lockstep with the packages). */
36
+ version: string;
37
+
38
+ /** Provenance: `fnv1a64:<16 hex>` over every input file keyed by its
39
+ * config-relative path, plus the manifest. Independent of where the tree
40
+ * lives on disk; no wall clock. */
41
+ label: string;
42
+
43
+ /** Manifest order, verbatim. */
44
+ locales: Locale[];
45
+
46
+ /** Manifest order, verbatim. */
47
+ mappingTypes: MappingType[];
48
+
49
+ /** Bits by technical name (sorted). Abstract base definitions are absent. */
50
+ bits: Record<Bit>;
51
+
52
+ /** Tag groups by name (sorted). */
53
+ groups: Record<Group>;
54
+
55
+ /** Card sets by key (sorted). */
56
+ cardSets: Record<CardSet>;
57
+
58
+ /** Resource catalog by resource type (sorted); derived from the
59
+ * `resource-<type>` groups minus the manifest's `resourceUtilityGroups`. */
60
+ resources: Record<Resource>;
61
+
62
+ /** Bit-group registry by key (sorted). Metadata only: membership lives on
63
+ * each bit's `bitGroups`. */
64
+ bitGroups: Record<BitGroup>;
65
+
66
+ /** Resource-group registry by key (sorted). Here the member list is
67
+ * authoritative. */
68
+ resourceGroups: Record<ResourceGroup>;
69
+
70
+ /** Text tags by JSON type (sorted): the heads of inline property lists
71
+ * (`==text==|head:value|child:value|…|`) and the JSON-only marks
72
+ * (PLAN-217). Group references are expanded. */
73
+ textTags: Record<TextTag>;
74
+
75
+ /** ProseMirror nodes that are not text tags (sorted): mappings only. */
76
+ textNodes: Record<TextNode>;
77
+ }
78
+
79
+ model Locale {
80
+ /** BCP-47 language code, e.g. "en". */
81
+ code: string;
82
+ isBase: boolean;
83
+ /** English label, e.g. "English". */
84
+ label: string;
85
+ }
86
+
87
+ /** A registered mapping id and its representation type. */
88
+ model MappingType {
89
+ /** Mapping id used as a key in every `mappingKeys` record, e.g. "json". */
90
+ id: string;
91
+
92
+ /** Representation type: "json" | "html" | "xml" (open set); informational. */
93
+ type: string;
94
+
95
+ /** Parent mapping id: key lookups under this id fall back to the base
96
+ * (publisher overrides). */
97
+ `extends`?: string;
98
+ }
99
+
100
+ model Bit {
101
+ description: string;
102
+
103
+ /** English display name; other languages come from `translations.json`.
104
+ * Absent when unauthored. */
105
+ title?: string;
106
+
107
+ /** Bit-group memberships, sorted — the single home of that fact. Omitted
108
+ * when the bit is deliberately ungrouped. */
109
+ bitGroups?: string[];
110
+
111
+ /** Author-facing usage notes, one bullet per entry; docs-only. */
112
+ usageNotes?: string[];
113
+
114
+ /** "bitmark" | "text" | "latex" | "json" | "xml". */
115
+ bodyFormat: string;
116
+
117
+ /** Flag booleans: present only when `true`. */
118
+ bodyRequired?: true;
119
+ bodyForbidden?: true;
120
+ footerRequired?: true;
121
+ footerForbidden?: true;
122
+
123
+ /** Version string at which the bit was deprecated; docs-only. */
124
+ deprecated?: string;
125
+
126
+ /** Migration target: engines re-emit input using this (deprecated) bit
127
+ * type under the named bit. */
128
+ migrateTo?: string;
129
+
130
+ /** "all" | "none". */
131
+ resourceAttachmentAllowed: string;
132
+
133
+ /** Required resource type (a key of `resources`); omitted when none. */
134
+ resourceRequired?: string;
135
+
136
+ /** Key of `cardSets`; omitted when the bit has no card set. */
137
+ cardSet?: string;
138
+
139
+ /** Bit-level named element keys for markup import; omitted when empty. */
140
+ mappingKeys?: MappingKeys;
141
+
142
+ /** Ordered declaration list: inline tag definitions and group references. */
143
+ tags: TagRef[];
144
+
145
+ /** Computed transitive closure of tags, as scoped keys, in declaration-DFS
146
+ * order with name dedup (first position kept, later declaration wins).
147
+ * A scoped key is `<kind>:<ownerPath>.<tag>` — `bit:article.#`,
148
+ * `group:article.#`, `variant:flashcard.default.question.1.@example` —
149
+ * and a chain child appends to its parent's key. */
150
+ allTags: string[];
151
+ }
152
+
153
+ /** One entry of a `tags` / `chain` array: an inline definition or a group
154
+ * reference, told apart by which of `tag` / `group` is present. */
155
+ union TagRef {
156
+ TagDef,
157
+ GroupRef,
158
+ }
159
+
160
+ model TagDef {
161
+ /** Config key including its sigil (`@example`, `#`, `&image`, `%`, …) —
162
+ * the identity within the owner scope. */
163
+ tag: string;
164
+
165
+ description: string;
166
+
167
+ /** "string" | "bitmark+" | "boolean" | "number" | "numberList4" | "enum". */
168
+ format: string;
169
+
170
+ /** Enum vocabulary: present (non-empty, unique) exactly when `format` is
171
+ * "enum". */
172
+ values?: string[];
173
+
174
+ min: int64;
175
+
176
+ /** -1 = unlimited. */
177
+ max: int64;
178
+
179
+ /** Always present. `null` means OMIT: absence is the canonical state and a
180
+ * present value is never stripped nor an absent one materialised.
181
+ * Otherwise the format's natural value ("false" / "0" / "") or an
182
+ * authored non-natural value, which requires `alwaysEmit`. */
183
+ default: string | null;
184
+
185
+ /** Flag boolean: pin the key even in optimised mode, materialising the
186
+ * default when absent. */
187
+ alwaysEmit?: true;
188
+
189
+ /** Version string at which the tag was deprecated; docs-only. */
190
+ deprecated?: string;
191
+
192
+ /** Omitted when none. A `json` member may be the string "@ignore": the
193
+ * tag takes no value. */
194
+ mappingKeys?: MappingKeys;
195
+
196
+ /** Ordered chain children; omitted when empty. */
197
+ chain?: TagRef[];
198
+
199
+ /** Computed: overrides this tag receives from each parent context, sorted
200
+ * by (parentType, parent). Omitted when empty. */
201
+ parentOverrides?: ParentOverride[];
202
+ }
203
+
204
+ /** A reference to a group, with optional link overrides. */
205
+ model GroupRef {
206
+ /** A key of `groups`. */
207
+ group: string;
208
+ mappingKeys?: MappingKeys;
209
+ min?: int64;
210
+ max?: int64;
211
+ }
212
+
213
+ model ParentOverride {
214
+ /** "bit" | "group" | "tag" | "variant" (never "cardSet"). */
215
+ parentType: string;
216
+
217
+ /** Name (bit / group), variant path, or — for `tag` — the parent tag's
218
+ * scoped key (`group:person.@partner`). */
219
+ parent: string;
220
+
221
+ /** At least one of the three is present. */
222
+ mappingKeys?: MappingKeys;
223
+ min?: int64;
224
+ max?: int64;
225
+ }
226
+
227
+ model Group {
228
+ description: string;
229
+ tags: TagRef[];
230
+ allTags: string[];
231
+
232
+ /** Computed reverse references; omitted when nothing references the group. */
233
+ usedBy?: UsedBy;
234
+ }
235
+
236
+ /** Reverse references; each member sorted lexicographically and omitted when
237
+ * empty. */
238
+ model UsedBy {
239
+ bits?: string[];
240
+ cardSets?: string[];
241
+ /** `<cardSetKey>.<cardName>.<sideName>.<variantIndex>` (1-based). */
242
+ variants?: string[];
243
+ groups?: string[];
244
+ /** Scoped keys (`group:person.@partner`) of the tags whose chains
245
+ * reference the group. */
246
+ tags?: string[];
247
+ }
248
+
249
+ model CardSet {
250
+ mappingKeys?: MappingKeys;
251
+
252
+ /** Card-set-level references; omitted when empty. */
253
+ tags?: TagRef[];
254
+ allTags?: string[];
255
+
256
+ /** Bits using this card set, sorted; omitted when none. */
257
+ usedBy?: UsedBy;
258
+
259
+ /** Ordered. */
260
+ cards: Card[];
261
+ }
262
+
263
+ model Card {
264
+ name: string;
265
+ isDefault: boolean;
266
+
267
+ /** 0 = no lower bound. */
268
+ min: int64;
269
+
270
+ /** 0 = unbounded (cards use 0, not -1). */
271
+ max: int64;
272
+
273
+ mappingKeys?: MappingKeys;
274
+
275
+ /** Ordered. */
276
+ sides: Side[];
277
+ }
278
+
279
+ model Side {
280
+ name: string;
281
+
282
+ /** -1 = repeat forever; omitted when none. */
283
+ repeatCount?: int64;
284
+
285
+ mappingKeys?: MappingKeys;
286
+
287
+ /** Ordered; a variant's identity is its 1-based index. */
288
+ variants: Variant[];
289
+ }
290
+
291
+ model Variant {
292
+ bodyFormat: string;
293
+ bodyRequired?: true;
294
+ bodyForbidden?: true;
295
+
296
+ /** -1 = infinite; omitted when none. */
297
+ repeatCount?: int64;
298
+
299
+ mappingKeys?: MappingKeys;
300
+ tags: TagRef[];
301
+ allTags: string[];
302
+ }
303
+
304
+ model Resource {
305
+ /** Name of the defining `resource-<type>` group. */
306
+ group: string;
307
+
308
+ /** Component resource types of a composed resource; omitted when empty. */
309
+ composedOf?: string[];
310
+ }
311
+
312
+ /** A search/filter category over bit types. Deliberately no member list:
313
+ * membership is authored per bit (`Bit.bitGroups`). */
314
+ model BitGroup {
315
+ /** English display name; other languages come from `translations.json`. */
316
+ title: string;
317
+ description: string;
318
+
319
+ /** Alternative keys accepted by lookups; omitted when empty. */
320
+ aliases?: string[];
321
+
322
+ /** Informational parent group; never implies membership. */
323
+ subgroupOf?: string;
324
+
325
+ /** Flag boolean: the group is allowed to have no members. */
326
+ allowEmpty?: true;
327
+ }
328
+
329
+ /** A value format of a text tag or child. `none`: no value. `duration`: `P`
330
+ * followed by anything (the 8.41.1 grammar rule). */
331
+ union TextFormat {
332
+ "none",
333
+ "string",
334
+ "bitmark+",
335
+ "boolean",
336
+ "number",
337
+ "enum",
338
+ "duration",
339
+ }
340
+
341
+ /** What an invalid value or a missing required child does: `warn` keeps it
342
+ * and reports; `invalid` rejects the segment and ends the chain. */
343
+ union OnInvalid {
344
+ "warn",
345
+ "invalid",
346
+ }
347
+
348
+ /** A text tag (PLAN-217). */
349
+ model TextTag {
350
+ description: string;
351
+
352
+ /** `mark` decorates the text run; `node` replaces it. */
353
+ kind: "mark" | "node";
354
+
355
+ /** Source spelling of the head; omitted → no bitmark form. An identifier
356
+ * (letters, digits and `*`, starting with a letter) followed by `:value`,
357
+ * or a sigil — one non-letter BMP character outside the chain syntax
358
+ * (`|:^@=*`) — that runs straight into its value (`#`, `►`, `?`). */
359
+ key?: string;
360
+
361
+ format: TextFormat;
362
+
363
+ /** Enum vocabulary; emitted only for `enum`. */
364
+ values?: string[];
365
+
366
+ /** `null` = omit (absence is its own state); always `null` for `none`. */
367
+ default: string | null;
368
+
369
+ /** Flag boolean (PLAN-152). */
370
+ alwaysEmit?: true;
371
+
372
+ /** Always emitted: `invalid` for `none`, else `warn` unless authored. */
373
+ onInvalid: OnInvalid;
374
+
375
+ /** `first`: valid only as the first segment; omitted = any position. */
376
+ headPosition?: "first";
377
+
378
+ /** Text tags that may start after this head's chain; omitted = any. */
379
+ followingHeads?: string[];
380
+
381
+ /** A named value transform applied on read. */
382
+ transform?: "lowercase";
383
+
384
+ /** JSON input of this (legacy) type is read as the named text tag. */
385
+ migrateTo?: string;
386
+
387
+ /** `json`: `{"type": <name>, …fields}` — a field value is `"$"` (the
388
+ * head's value), `"$text"` (the text between `==`) or a constant. A head
389
+ * with a value places it exactly once (`"$"`); a `none` head places none;
390
+ * no two fields of the head and its chain write the same path. */
391
+ mappingKeys?: MappingKeys;
392
+
393
+ /** Children in canonical order (D16); omitted when empty. */
394
+ chain?: TextChild[];
395
+ }
396
+
397
+ /** A child of a text tag. */
398
+ model TextChild {
399
+ /** Source spelling (`?`, `►`, `provider`, …); same rules as
400
+ * `TextTag.key`. */
401
+ tag: string;
402
+ description: string;
403
+
404
+ /** Never `none`: a child always takes a value. */
405
+ format: TextFormat;
406
+ values?: string[];
407
+ min: int64;
408
+
409
+ /** `-1` = unlimited. */
410
+ max: int64;
411
+ default: string | null;
412
+ alwaysEmit?: true;
413
+
414
+ /** Emitted only when `min >= 1`. Always `invalid` for now: `warn` needs
415
+ * the `text-tag-missing` warning, added with its first use (D13). */
416
+ onMissing?: OnInvalid;
417
+ onInvalid: OnInvalid;
418
+
419
+ /** Always has `json`: one field — `"$"` or `["$"]` (append) under
420
+ * `attrs` or at the top level. */
421
+ mappingKeys: MappingKeys;
422
+ }
423
+
424
+ /** A ProseMirror node that is not a text tag. */
425
+ model TextNode {
426
+ description: string;
427
+ mappingKeys?: MappingKeys;
428
+ }
429
+
430
+ /** A search/filter category over resource types. The member list is the
431
+ * single home of that fact. */
432
+ model ResourceGroup {
433
+ title: string;
434
+ description: string;
435
+ aliases?: string[];
436
+
437
+ /** Member resource types, sorted; each is a key of `resources`. */
438
+ resourceTypes: string[];
439
+ }