@driftsys/markspec 0.4.0 → 0.5.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/esm/ast/build.d.ts +70 -0
- package/esm/ast/build.d.ts.map +1 -0
- package/esm/ast/build.js +605 -0
- package/esm/ast/equivalence.d.ts +18 -0
- package/esm/ast/equivalence.d.ts.map +1 -0
- package/esm/ast/equivalence.js +56 -0
- package/esm/ast/nodes.d.ts +221 -0
- package/esm/ast/nodes.d.ts.map +1 -0
- package/esm/ast/nodes.js +12 -0
- package/esm/ast/normalize.d.ts +67 -0
- package/esm/ast/normalize.d.ts.map +1 -0
- package/esm/ast/normalize.js +255 -0
- package/esm/ast/render.d.ts +34 -0
- package/esm/ast/render.d.ts.map +1 -0
- package/esm/ast/render.js +215 -0
- package/esm/compiler/inverses.d.ts +2 -8
- package/esm/compiler/inverses.d.ts.map +1 -1
- package/esm/compiler/inverses.js +50 -14
- package/esm/compiler/manifest.d.ts +59 -0
- package/esm/compiler/manifest.d.ts.map +1 -0
- package/esm/compiler/manifest.js +48 -0
- package/esm/compiler/mod.d.ts +9 -1
- package/esm/compiler/mod.d.ts.map +1 -1
- package/esm/compiler/mod.js +21 -2
- package/esm/compiler/ndjson_writer.d.ts +50 -0
- package/esm/compiler/ndjson_writer.d.ts.map +1 -0
- package/esm/compiler/ndjson_writer.js +73 -0
- package/esm/compiler/schema.d.ts +18 -1
- package/esm/compiler/schema.d.ts.map +1 -1
- package/esm/compiler/schema.js +18 -9
- package/esm/config/mod.d.ts.map +1 -1
- package/esm/config/mod.js +54 -0
- package/esm/formatter/mod.d.ts +49 -4
- package/esm/formatter/mod.d.ts.map +1 -1
- package/esm/formatter/mod.js +362 -33
- package/esm/formatter/synth_ulid.d.ts +21 -0
- package/esm/formatter/synth_ulid.d.ts.map +1 -0
- package/esm/formatter/synth_ulid.js +64 -0
- package/esm/lint/mod.d.ts +10 -0
- package/esm/lint/mod.d.ts.map +1 -0
- package/esm/lint/mod.js +7 -0
- package/esm/lint/rules/lexicon.d.ts +24 -0
- package/esm/lint/rules/lexicon.d.ts.map +1 -0
- package/esm/lint/rules/lexicon.js +236 -0
- package/esm/lint/rules/struct.d.ts +17 -0
- package/esm/lint/rules/struct.d.ts.map +1 -0
- package/esm/lint/rules/struct.js +55 -0
- package/esm/lint/rules/suppression.d.ts +19 -0
- package/esm/lint/rules/suppression.d.ts.map +1 -0
- package/esm/lint/rules/suppression.js +75 -0
- package/esm/lint/runner.d.ts +39 -0
- package/esm/lint/runner.d.ts.map +1 -0
- package/esm/lint/runner.js +112 -0
- package/esm/lint/types.d.ts +19 -0
- package/esm/lint/types.d.ts.map +1 -0
- package/esm/lint/types.js +9 -0
- package/esm/mod.d.ts +19 -6
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +14 -3
- package/esm/model/attributes.d.ts.map +1 -1
- package/esm/model/attributes.js +163 -2
- package/esm/model/discriminating_attr.d.ts +33 -0
- package/esm/model/discriminating_attr.d.ts.map +1 -0
- package/esm/model/discriminating_attr.js +74 -0
- package/esm/model/mod.d.ts +98 -3
- package/esm/model/mod.d.ts.map +1 -1
- package/esm/model/mod.js +57 -2
- package/esm/model/profile.d.ts +33 -27
- package/esm/model/profile.d.ts.map +1 -1
- package/esm/model/source_introspection.d.ts +26 -0
- package/esm/model/source_introspection.d.ts.map +1 -0
- package/esm/model/source_introspection.js +77 -0
- package/esm/model/type_hierarchy.d.ts +51 -0
- package/esm/model/type_hierarchy.d.ts.map +1 -0
- package/esm/model/type_hierarchy.js +126 -0
- package/esm/model/uri_scheme_map.d.ts +21 -0
- package/esm/model/uri_scheme_map.d.ts.map +1 -0
- package/esm/model/uri_scheme_map.js +66 -0
- package/esm/parser/attributes.d.ts.map +1 -1
- package/esm/parser/attributes.js +9 -6
- package/esm/parser/entity_refs.d.ts +53 -0
- package/esm/parser/entity_refs.d.ts.map +1 -0
- package/esm/parser/entity_refs.js +151 -0
- package/esm/parser/glossary.d.ts +43 -0
- package/esm/parser/glossary.d.ts.map +1 -0
- package/esm/parser/glossary.js +217 -0
- package/esm/parser/markdown.d.ts.map +1 -1
- package/esm/parser/markdown.js +223 -7
- package/esm/parser/mod.d.ts +1 -0
- package/esm/parser/mod.d.ts.map +1 -1
- package/esm/parser/mod.js +1 -0
- package/esm/parser/source.d.ts +20 -0
- package/esm/parser/source.d.ts.map +1 -1
- package/esm/parser/source.js +3 -3
- package/esm/profile/chain.js +3 -13
- package/esm/profile/colors.js +1 -1
- package/esm/profile/introspect.d.ts +135 -0
- package/esm/profile/introspect.d.ts.map +1 -0
- package/esm/profile/introspect.js +378 -0
- package/esm/profile/load.d.ts.map +1 -1
- package/esm/profile/load.js +67 -0
- package/esm/profile/manifest.d.ts.map +1 -1
- package/esm/profile/manifest.js +277 -88
- package/esm/profile/merge.js +139 -39
- package/esm/profile/mod.d.ts +2 -4
- package/esm/profile/mod.d.ts.map +1 -1
- package/esm/profile/mod.js +5 -2
- package/esm/reporter/mod.js +4 -4
- package/esm/util/fence.d.ts +30 -0
- package/esm/util/fence.d.ts.map +1 -0
- package/esm/util/fence.js +40 -0
- package/esm/validator/attributes.d.ts +3 -3
- package/esm/validator/attributes.d.ts.map +1 -1
- package/esm/validator/attributes.js +1 -18
- package/esm/validator/body_blocks.d.ts +38 -0
- package/esm/validator/body_blocks.d.ts.map +1 -0
- package/esm/validator/body_blocks.js +218 -0
- package/esm/validator/caption_convention.d.ts +29 -0
- package/esm/validator/caption_convention.d.ts.map +1 -0
- package/esm/validator/caption_convention.js +58 -0
- package/esm/validator/captions.d.ts +22 -0
- package/esm/validator/captions.d.ts.map +1 -0
- package/esm/validator/captions.js +137 -0
- package/esm/validator/component_schemes.d.ts +73 -0
- package/esm/validator/component_schemes.d.ts.map +1 -0
- package/esm/validator/component_schemes.js +375 -0
- package/esm/validator/feature_ac.d.ts +28 -0
- package/esm/validator/feature_ac.d.ts.map +1 -0
- package/esm/validator/feature_ac.js +102 -0
- package/esm/validator/listing.d.ts +42 -0
- package/esm/validator/listing.d.ts.map +1 -0
- package/esm/validator/listing.js +295 -0
- package/esm/validator/mod.d.ts +2 -0
- package/esm/validator/mod.d.ts.map +1 -1
- package/esm/validator/mod.js +253 -12
- package/esm/validator/modal_keywords.d.ts +23 -0
- package/esm/validator/modal_keywords.d.ts.map +1 -0
- package/esm/validator/modal_keywords.js +137 -0
- package/esm/validator/per_type_attrs.d.ts +29 -0
- package/esm/validator/per_type_attrs.d.ts.map +1 -0
- package/esm/validator/per_type_attrs.js +75 -0
- package/esm/validator/pipeline.d.ts +7 -2
- package/esm/validator/pipeline.d.ts.map +1 -1
- package/esm/validator/pipeline.js +40 -7
- package/esm/validator/trace_types.d.ts +26 -0
- package/esm/validator/trace_types.d.ts.map +1 -0
- package/esm/validator/trace_types.js +232 -0
- package/esm/validator/traceability.d.ts +3 -4
- package/esm/validator/traceability.d.ts.map +1 -1
- package/esm/validator/traceability.js +5 -10
- package/esm/validator/type_resolution.d.ts +67 -0
- package/esm/validator/type_resolution.d.ts.map +1 -0
- package/esm/validator/type_resolution.js +140 -0
- package/esm/validator/types.d.ts +45 -0
- package/esm/validator/types.d.ts.map +1 -1
- package/esm/validator/types.js +128 -16
- package/esm/validator/value_types.d.ts +8 -0
- package/esm/validator/value_types.d.ts.map +1 -1
- package/esm/validator/value_types.js +8 -1
- package/package.json +1 -1
- package/script/ast/build.d.ts +70 -0
- package/script/ast/build.d.ts.map +1 -0
- package/script/ast/build.js +610 -0
- package/script/ast/equivalence.d.ts +18 -0
- package/script/ast/equivalence.d.ts.map +1 -0
- package/script/ast/equivalence.js +59 -0
- package/script/ast/nodes.d.ts +221 -0
- package/script/ast/nodes.d.ts.map +1 -0
- package/script/ast/nodes.js +13 -0
- package/script/ast/normalize.d.ts +67 -0
- package/script/ast/normalize.d.ts.map +1 -0
- package/script/ast/normalize.js +258 -0
- package/script/ast/render.d.ts +34 -0
- package/script/ast/render.d.ts.map +1 -0
- package/script/ast/render.js +218 -0
- package/script/compiler/inverses.d.ts +2 -8
- package/script/compiler/inverses.d.ts.map +1 -1
- package/script/compiler/inverses.js +50 -14
- package/script/compiler/manifest.d.ts +59 -0
- package/script/compiler/manifest.d.ts.map +1 -0
- package/script/compiler/manifest.js +51 -0
- package/script/compiler/mod.d.ts +9 -1
- package/script/compiler/mod.d.ts.map +1 -1
- package/script/compiler/mod.js +21 -2
- package/script/compiler/ndjson_writer.d.ts +50 -0
- package/script/compiler/ndjson_writer.d.ts.map +1 -0
- package/script/compiler/ndjson_writer.js +78 -0
- package/script/compiler/schema.d.ts +18 -1
- package/script/compiler/schema.d.ts.map +1 -1
- package/script/compiler/schema.js +18 -8
- package/script/config/mod.d.ts.map +1 -1
- package/script/config/mod.js +54 -0
- package/script/formatter/mod.d.ts +49 -4
- package/script/formatter/mod.d.ts.map +1 -1
- package/script/formatter/mod.js +365 -33
- package/script/formatter/synth_ulid.d.ts +21 -0
- package/script/formatter/synth_ulid.d.ts.map +1 -0
- package/script/formatter/synth_ulid.js +67 -0
- package/script/lint/mod.d.ts +10 -0
- package/script/lint/mod.d.ts.map +1 -0
- package/script/lint/mod.js +12 -0
- package/script/lint/rules/lexicon.d.ts +24 -0
- package/script/lint/rules/lexicon.d.ts.map +1 -0
- package/script/lint/rules/lexicon.js +240 -0
- package/script/lint/rules/struct.d.ts +17 -0
- package/script/lint/rules/struct.d.ts.map +1 -0
- package/script/lint/rules/struct.js +59 -0
- package/script/lint/rules/suppression.d.ts +19 -0
- package/script/lint/rules/suppression.d.ts.map +1 -0
- package/script/lint/rules/suppression.js +80 -0
- package/script/lint/runner.d.ts +39 -0
- package/script/lint/runner.d.ts.map +1 -0
- package/script/lint/runner.js +116 -0
- package/script/lint/types.d.ts +19 -0
- package/script/lint/types.d.ts.map +1 -0
- package/script/lint/types.js +10 -0
- package/script/mod.d.ts +19 -6
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +56 -32
- package/script/model/attributes.d.ts.map +1 -1
- package/script/model/attributes.js +163 -2
- package/script/model/discriminating_attr.d.ts +33 -0
- package/script/model/discriminating_attr.d.ts.map +1 -0
- package/script/model/discriminating_attr.js +77 -0
- package/script/model/mod.d.ts +98 -3
- package/script/model/mod.d.ts.map +1 -1
- package/script/model/mod.js +64 -3
- package/script/model/profile.d.ts +33 -27
- package/script/model/profile.d.ts.map +1 -1
- package/script/model/source_introspection.d.ts +26 -0
- package/script/model/source_introspection.d.ts.map +1 -0
- package/script/model/source_introspection.js +80 -0
- package/script/model/type_hierarchy.d.ts +51 -0
- package/script/model/type_hierarchy.d.ts.map +1 -0
- package/script/model/type_hierarchy.js +130 -0
- package/script/model/uri_scheme_map.d.ts +21 -0
- package/script/model/uri_scheme_map.d.ts.map +1 -0
- package/script/model/uri_scheme_map.js +69 -0
- package/script/parser/attributes.d.ts.map +1 -1
- package/script/parser/attributes.js +9 -6
- package/script/parser/entity_refs.d.ts +53 -0
- package/script/parser/entity_refs.d.ts.map +1 -0
- package/script/parser/entity_refs.js +155 -0
- package/script/parser/glossary.d.ts +43 -0
- package/script/parser/glossary.d.ts.map +1 -0
- package/script/parser/glossary.js +221 -0
- package/script/parser/markdown.d.ts.map +1 -1
- package/script/parser/markdown.js +222 -6
- package/script/parser/mod.d.ts +1 -0
- package/script/parser/mod.d.ts.map +1 -1
- package/script/parser/mod.js +5 -1
- package/script/parser/source.d.ts +20 -0
- package/script/parser/source.d.ts.map +1 -1
- package/script/parser/source.js +3 -0
- package/script/profile/chain.js +3 -13
- package/script/profile/colors.js +1 -1
- package/script/profile/introspect.d.ts +135 -0
- package/script/profile/introspect.d.ts.map +1 -0
- package/script/profile/introspect.js +381 -0
- package/script/profile/load.d.ts.map +1 -1
- package/script/profile/load.js +67 -0
- package/script/profile/manifest.d.ts.map +1 -1
- package/script/profile/manifest.js +276 -87
- package/script/profile/merge.js +139 -39
- package/script/profile/mod.d.ts +2 -4
- package/script/profile/mod.d.ts.map +1 -1
- package/script/profile/mod.js +7 -6
- package/script/reporter/mod.js +4 -4
- package/script/util/fence.d.ts +30 -0
- package/script/util/fence.d.ts.map +1 -0
- package/script/util/fence.js +44 -0
- package/script/validator/attributes.d.ts +3 -3
- package/script/validator/attributes.d.ts.map +1 -1
- package/script/validator/attributes.js +1 -18
- package/script/validator/body_blocks.d.ts +38 -0
- package/script/validator/body_blocks.d.ts.map +1 -0
- package/script/validator/body_blocks.js +221 -0
- package/script/validator/caption_convention.d.ts +29 -0
- package/script/validator/caption_convention.d.ts.map +1 -0
- package/script/validator/caption_convention.js +61 -0
- package/script/validator/captions.d.ts +22 -0
- package/script/validator/captions.d.ts.map +1 -0
- package/script/validator/captions.js +140 -0
- package/script/validator/component_schemes.d.ts +73 -0
- package/script/validator/component_schemes.d.ts.map +1 -0
- package/script/validator/component_schemes.js +384 -0
- package/script/validator/feature_ac.d.ts +28 -0
- package/script/validator/feature_ac.d.ts.map +1 -0
- package/script/validator/feature_ac.js +105 -0
- package/script/validator/listing.d.ts +42 -0
- package/script/validator/listing.d.ts.map +1 -0
- package/script/validator/listing.js +298 -0
- package/script/validator/mod.d.ts +2 -0
- package/script/validator/mod.d.ts.map +1 -1
- package/script/validator/mod.js +256 -14
- package/script/validator/modal_keywords.d.ts +23 -0
- package/script/validator/modal_keywords.d.ts.map +1 -0
- package/script/validator/modal_keywords.js +140 -0
- package/script/validator/per_type_attrs.d.ts +29 -0
- package/script/validator/per_type_attrs.d.ts.map +1 -0
- package/script/validator/per_type_attrs.js +78 -0
- package/script/validator/pipeline.d.ts +7 -2
- package/script/validator/pipeline.d.ts.map +1 -1
- package/script/validator/pipeline.js +39 -6
- package/script/validator/trace_types.d.ts +26 -0
- package/script/validator/trace_types.d.ts.map +1 -0
- package/script/validator/trace_types.js +235 -0
- package/script/validator/traceability.d.ts +3 -4
- package/script/validator/traceability.d.ts.map +1 -1
- package/script/validator/traceability.js +5 -10
- package/script/validator/type_resolution.d.ts +67 -0
- package/script/validator/type_resolution.d.ts.map +1 -0
- package/script/validator/type_resolution.js +146 -0
- package/script/validator/types.d.ts +45 -0
- package/script/validator/types.d.ts.map +1 -1
- package/script/validator/types.js +131 -16
- package/script/validator/value_types.d.ts +8 -0
- package/script/validator/value_types.d.ts.map +1 -1
- package/script/validator/value_types.js +10 -2
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module compiler/ndjson_writer
|
|
4
|
+
*
|
|
5
|
+
* NDJSON stream builders for the streaming compile output format.
|
|
6
|
+
*
|
|
7
|
+
* Three pure, Deno-free functions — callers perform the actual file I/O:
|
|
8
|
+
* - {@linkcode buildEntriesNdjson}: entries sorted by displayId
|
|
9
|
+
* - {@linkcode buildEdgesNdjson}: all links (authored + generated)
|
|
10
|
+
* - {@linkcode indexToJson}: compact byte-offset index JSON
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.buildEntriesNdjson = buildEntriesNdjson;
|
|
14
|
+
exports.indexToJson = indexToJson;
|
|
15
|
+
exports.buildEdgesNdjson = buildEdgesNdjson;
|
|
16
|
+
const schema_js_1 = require("./schema.js");
|
|
17
|
+
const enc = new TextEncoder();
|
|
18
|
+
/**
|
|
19
|
+
* Build the `entries.ndjson` byte stream and byte-offset index.
|
|
20
|
+
*
|
|
21
|
+
* Entries are sorted by `displayId` before serialization so that the output
|
|
22
|
+
* is deterministic regardless of `Map` insertion order. Each line is a
|
|
23
|
+
* compact JSON-serialized entry terminated by `\n`. Byte offsets use
|
|
24
|
+
* UTF-8 byte counting, not JavaScript `.length`.
|
|
25
|
+
*/
|
|
26
|
+
function buildEntriesNdjson(entries) {
|
|
27
|
+
const sorted = [...entries.entries()].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
28
|
+
const chunks = [];
|
|
29
|
+
const index = new Map();
|
|
30
|
+
let offset = 0;
|
|
31
|
+
for (const [displayId, entry] of sorted) {
|
|
32
|
+
const line = JSON.stringify((0, schema_js_1.serializeEntry)(entry)) + "\n";
|
|
33
|
+
const bytes = enc.encode(line);
|
|
34
|
+
chunks.push(bytes);
|
|
35
|
+
index.set(displayId, { offset, length: bytes.length });
|
|
36
|
+
offset += bytes.length;
|
|
37
|
+
}
|
|
38
|
+
return { ndjson: concat(chunks), index };
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Convert a byte-offset index to compact single-line JSON with
|
|
42
|
+
* lexicographically sorted keys — suitable for `entries.idx`.
|
|
43
|
+
*/
|
|
44
|
+
function indexToJson(index) {
|
|
45
|
+
const sorted = [...index.entries()].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
46
|
+
return JSON.stringify(Object.fromEntries(sorted));
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Build the `edges.ndjson` byte stream.
|
|
50
|
+
*
|
|
51
|
+
* All links (both authored and generated) are written. Each line is a
|
|
52
|
+
* compact JSON object with `from`, `to`, `kind`, and `origin` — the
|
|
53
|
+
* `location` field is omitted as it is not needed for interchange.
|
|
54
|
+
*/
|
|
55
|
+
function buildEdgesNdjson(links) {
|
|
56
|
+
const chunks = [];
|
|
57
|
+
for (const link of links) {
|
|
58
|
+
const record = {
|
|
59
|
+
from: link.from,
|
|
60
|
+
to: link.to,
|
|
61
|
+
kind: link.kind,
|
|
62
|
+
origin: link.origin,
|
|
63
|
+
};
|
|
64
|
+
chunks.push(enc.encode(JSON.stringify(record) + "\n"));
|
|
65
|
+
}
|
|
66
|
+
return concat(chunks);
|
|
67
|
+
}
|
|
68
|
+
/** Concatenate a list of Uint8Array chunks into one. */
|
|
69
|
+
function concat(chunks) {
|
|
70
|
+
const totalLength = chunks.reduce((sum, c) => sum + c.length, 0);
|
|
71
|
+
const out = new Uint8Array(totalLength);
|
|
72
|
+
let pos = 0;
|
|
73
|
+
for (const chunk of chunks) {
|
|
74
|
+
out.set(chunk, pos);
|
|
75
|
+
pos += chunk.length;
|
|
76
|
+
}
|
|
77
|
+
return out;
|
|
78
|
+
}
|
|
@@ -7,6 +7,16 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { CompileResult } from "./mod.js";
|
|
9
9
|
import type { Diagnostic, Entry, Link } from "../model/mod.js";
|
|
10
|
+
/**
|
|
11
|
+
* JSON-serializable form of {@linkcode Entry}.
|
|
12
|
+
*
|
|
13
|
+
* Identical to `Entry` except `typedAttributes` is a plain
|
|
14
|
+
* `Record<string, readonly string[]>` instead of a `ReadonlyMap` — Maps are
|
|
15
|
+
* not JSON-serializable. All other fields are passed through unchanged.
|
|
16
|
+
*/
|
|
17
|
+
export type SerializedEntry = Omit<Entry, "typedAttributes"> & {
|
|
18
|
+
readonly typedAttributes?: Record<string, readonly string[]>;
|
|
19
|
+
};
|
|
10
20
|
/**
|
|
11
21
|
* Serialized form of {@linkcode CompileResult}.
|
|
12
22
|
*
|
|
@@ -15,7 +25,7 @@ import type { Diagnostic, Entry, Link } from "../model/mod.js";
|
|
|
15
25
|
*/
|
|
16
26
|
export interface SerializedCompileResult {
|
|
17
27
|
/** Entries keyed by display ID. */
|
|
18
|
-
readonly entries: Record<string,
|
|
28
|
+
readonly entries: Record<string, SerializedEntry>;
|
|
19
29
|
/** All traceability links. */
|
|
20
30
|
readonly links: readonly Link[];
|
|
21
31
|
/** Outgoing links per entry (entry -> targets). */
|
|
@@ -35,4 +45,11 @@ export interface SerializedCompileResult {
|
|
|
35
45
|
* @returns A plain object safe for `JSON.stringify`
|
|
36
46
|
*/
|
|
37
47
|
export declare function serializeCompileResult(result: CompileResult): SerializedCompileResult;
|
|
48
|
+
/**
|
|
49
|
+
* Convert an {@linkcode Entry} to a JSON-safe {@linkcode SerializedEntry} by
|
|
50
|
+
* replacing `typedAttributes` (a `ReadonlyMap`) with a plain
|
|
51
|
+
* `Record<string, readonly string[]>`, and stripping `properties.sync`
|
|
52
|
+
* (privacy rule — never publish connector state).
|
|
53
|
+
*/
|
|
54
|
+
export declare function serializeEntry(entry: Entry): SerializedEntry;
|
|
38
55
|
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/compiler/schema.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE/D;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB;IACtC,mCAAmC;IACnC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/compiler/schema.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE/D;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,KAAK,EAAE,iBAAiB,CAAC,GAAG;IAC7D,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC;CAC9D,CAAC;AAEF;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB;IACtC,mCAAmC;IACnC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAClD,8BAA8B;IAC9B,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC;IAChC,mDAAmD;IACnD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,IAAI,EAAE,CAAC,CAAC;IAClD,kEAAkE;IAClE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,IAAI,EAAE,CAAC,CAAC;IAClD,+CAA+C;IAC/C,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;CAC7C;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,aAAa,GACpB,uBAAuB,CAYzB;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,eAAe,CAoB5D"}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.serializeCompileResult = serializeCompileResult;
|
|
11
|
+
exports.serializeEntry = serializeEntry;
|
|
11
12
|
/**
|
|
12
13
|
* Convert a {@linkcode CompileResult} to a plain JSON-serializable object.
|
|
13
14
|
*
|
|
@@ -18,9 +19,8 @@ exports.serializeCompileResult = serializeCompileResult;
|
|
|
18
19
|
* @returns A plain object safe for `JSON.stringify`
|
|
19
20
|
*/
|
|
20
21
|
function serializeCompileResult(result) {
|
|
21
|
-
const rawEntries = Object.fromEntries(result.entries);
|
|
22
22
|
const entries = {};
|
|
23
|
-
for (const [key, entry] of
|
|
23
|
+
for (const [key, entry] of result.entries) {
|
|
24
24
|
entries[key] = serializeEntry(entry);
|
|
25
25
|
}
|
|
26
26
|
return {
|
|
@@ -32,16 +32,26 @@ function serializeCompileResult(result) {
|
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
|
-
* Convert an {@linkcode Entry} to a JSON-safe
|
|
36
|
-
* `typedAttributes` (a `ReadonlyMap`) with a plain
|
|
35
|
+
* Convert an {@linkcode Entry} to a JSON-safe {@linkcode SerializedEntry} by
|
|
36
|
+
* replacing `typedAttributes` (a `ReadonlyMap`) with a plain
|
|
37
|
+
* `Record<string, readonly string[]>`, and stripping `properties.sync`
|
|
38
|
+
* (privacy rule — never publish connector state).
|
|
37
39
|
*/
|
|
38
40
|
function serializeEntry(entry) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
// Replace the ReadonlyMap with a plain Record when populated; omit when empty
|
|
42
|
+
// so JSON output stays compact.
|
|
43
|
+
const typedAttributes = entry.typedAttributes && entry.typedAttributes.size > 0
|
|
44
|
+
? Object.fromEntries(entry.typedAttributes)
|
|
45
|
+
: undefined;
|
|
46
|
+
// Strip properties.sync (connector state must not be published).
|
|
47
|
+
let properties = entry.properties;
|
|
48
|
+
if (properties?.sync !== undefined) {
|
|
49
|
+
const { sync: _sync, ...rest } = properties;
|
|
50
|
+
properties = Object.keys(rest).length > 0 ? rest : undefined;
|
|
41
51
|
}
|
|
42
|
-
const typedObj = Object.fromEntries(entry.typedAttributes);
|
|
43
52
|
return {
|
|
44
53
|
...entry,
|
|
45
|
-
typedAttributes
|
|
54
|
+
typedAttributes,
|
|
55
|
+
properties,
|
|
46
56
|
};
|
|
47
57
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/config/mod.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/config/mod.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAML,KAAK,aAAa,EACnB,MAAM,iBAAiB,CAAC;AAEzB,4DAA4D;AAC5D,eAAO,MAAM,gBAAgB,iBAAiB,CAAC;AAE/C,iDAAiD;AACjD,MAAM,WAAW,gBAAgB;IAC/B,8CAA8C;IAC9C,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,mDAAmD;IACnD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,gDAAgD;IAChD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,yFAAyF;AACzF,MAAM,MAAM,QAAQ,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;AAMrE;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAU7B;AAsBD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GACf,aAAa,CAqMf;AAMD;;GAEG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAiBxD;AAMD;;;;;GAKG;AACH,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAUvC"}
|
package/script/config/mod.js
CHANGED
|
@@ -179,6 +179,59 @@ function parseProjectConfig(yaml, filePath) {
|
|
|
179
179
|
parentFallback = val;
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
|
+
// caption-conventions: optional mapping of keyword → "above" | "below"
|
|
183
|
+
let captionConventions = mod_js_1.DEFAULT_PROJECT_CONFIG.captionConventions;
|
|
184
|
+
const captionConventionsKey = "caption-conventions";
|
|
185
|
+
if (obj[captionConventionsKey] !== undefined &&
|
|
186
|
+
obj[captionConventionsKey] !== null) {
|
|
187
|
+
const raw = obj[captionConventionsKey];
|
|
188
|
+
if (typeof raw !== "object" || Array.isArray(raw)) {
|
|
189
|
+
errors.push({
|
|
190
|
+
field: captionConventionsKey,
|
|
191
|
+
message: `expected a mapping of caption-keyword: above|below, got ${Array.isArray(raw) ? "array" : typeof raw}`,
|
|
192
|
+
line: findLineNumber(yaml, captionConventionsKey),
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
const rawMap = raw;
|
|
197
|
+
const VALID_KEYWORDS = new Set([
|
|
198
|
+
"Figure",
|
|
199
|
+
"Table",
|
|
200
|
+
"Listing",
|
|
201
|
+
"Feature",
|
|
202
|
+
"Equation",
|
|
203
|
+
"List",
|
|
204
|
+
]);
|
|
205
|
+
const parsed = {};
|
|
206
|
+
let badKey;
|
|
207
|
+
const captionErrsBefore = errors.length;
|
|
208
|
+
for (const [kw, pos] of Object.entries(rawMap)) {
|
|
209
|
+
if (!VALID_KEYWORDS.has(kw)) {
|
|
210
|
+
badKey = kw;
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
if (pos !== "above" && pos !== "below") {
|
|
214
|
+
errors.push({
|
|
215
|
+
field: `${captionConventionsKey}.${kw}`,
|
|
216
|
+
message: `expected "above" or "below", got ${JSON.stringify(pos)}`,
|
|
217
|
+
line: findLineNumber(yaml, captionConventionsKey),
|
|
218
|
+
});
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
parsed[kw] = pos;
|
|
222
|
+
}
|
|
223
|
+
if (badKey !== undefined) {
|
|
224
|
+
errors.push({
|
|
225
|
+
field: `${captionConventionsKey}.${badKey}`,
|
|
226
|
+
message: `unknown caption keyword '${badKey}'; valid keywords: ${[...VALID_KEYWORDS].join(", ")}`,
|
|
227
|
+
line: findLineNumber(yaml, captionConventionsKey),
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
if (errors.length === captionErrsBefore) {
|
|
231
|
+
captionConventions = parsed;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
182
235
|
if (errors.length > 0) {
|
|
183
236
|
throw new mod_js_1.ConfigError(filePath, errors);
|
|
184
237
|
}
|
|
@@ -188,6 +241,7 @@ function parseProjectConfig(yaml, filePath) {
|
|
|
188
241
|
labels,
|
|
189
242
|
parents,
|
|
190
243
|
parentFallback,
|
|
244
|
+
captionConventions,
|
|
191
245
|
};
|
|
192
246
|
}
|
|
193
247
|
// ---------------------------------------------------------------------------
|
|
@@ -6,6 +6,37 @@
|
|
|
6
6
|
* and requirement block insertion.
|
|
7
7
|
*/
|
|
8
8
|
import type { Attribute, Diagnostic } from "../model/mod.js";
|
|
9
|
+
/**
|
|
10
|
+
* Decide whether the EARS keyword at `offset` in `line` is at sentence
|
|
11
|
+
* start (return value true). Walks left over whitespace and reports true
|
|
12
|
+
* when it hits the beginning of the line or a sentence-terminating
|
|
13
|
+
* punctuation character (`.`, `!`, `?`).
|
|
14
|
+
*/
|
|
15
|
+
export declare function isSentenceInitial(line: string, offset: number): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Normalise modal keywords to canonical case in body prose (§3.4.1):
|
|
18
|
+
*
|
|
19
|
+
* - RFC 2119 (`SHALL`, `SHOULD`, `MAY`, `MUST`, optionally `… NOT`) —
|
|
20
|
+
* always lowercased.
|
|
21
|
+
* - EARS (`When`, `While`, `Where`, `Unless`) — lowercased mid-sentence,
|
|
22
|
+
* preserved sentence-initial.
|
|
23
|
+
*
|
|
24
|
+
* The pass skips:
|
|
25
|
+
*
|
|
26
|
+
* - Fenced code blocks (between paired ``` or ~~~ markers) — code is
|
|
27
|
+
* verbatim per round-trip invariants (spec §5.1).
|
|
28
|
+
* - Lines indented by four or more spaces (or a tab) — conservatively
|
|
29
|
+
* captures indented code blocks and attribute trailers, both of which
|
|
30
|
+
* are not prose.
|
|
31
|
+
*
|
|
32
|
+
* @remarks Not called by `format()` as of SP3 Task 5 — body modal
|
|
33
|
+
* normalization moved to `normalizeBodyAst` in the AST pass (spec-correct
|
|
34
|
+
* verbatim-boundary handling). Retained as an exported symbol because
|
|
35
|
+
* `mod_test.ts` tests it directly and `core/ast/normalize.ts` documents
|
|
36
|
+
* the intentional duplication until a follow-up collapses the two. Do NOT
|
|
37
|
+
* delete — external callers may depend on this export.
|
|
38
|
+
*/
|
|
39
|
+
export declare function normalizeModalKeywords(markdown: string): string;
|
|
9
40
|
/** Options for {@linkcode format}. */
|
|
10
41
|
export interface FormatOptions {
|
|
11
42
|
/** File path for diagnostic messages. */
|
|
@@ -39,11 +70,25 @@ export declare function format(markdown: string, options?: FormatOptions): Forma
|
|
|
39
70
|
*/
|
|
40
71
|
export declare function expandCsvValues(attrs: Attribute[]): Attribute[];
|
|
41
72
|
/**
|
|
42
|
-
*
|
|
73
|
+
* Canonicalise a trailer key to TitleCase-Hyphenated per spec §3.3.4.
|
|
74
|
+
* First character of the key uppercase, every other character
|
|
75
|
+
* lowercase; hyphens preserved. Examples (from the spec):
|
|
76
|
+
*
|
|
77
|
+
* `Id`, `Derived-from`, `Reference-url`, `Bus-protocol`.
|
|
78
|
+
*
|
|
79
|
+
* Inputs like `ID`, `BUS-PROTOCOL`, `reference-URL`, `Derived-From`
|
|
80
|
+
* all canonicalise to the spec form regardless of casing in source.
|
|
81
|
+
*/
|
|
82
|
+
export declare function canonicalizeKey(key: string): string;
|
|
83
|
+
/**
|
|
84
|
+
* Sort attributes to canonical trailer order per spec §3.3.2 and
|
|
85
|
+
* re-case each key per spec §3.3.4.
|
|
43
86
|
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
87
|
+
* Known core keys appear in their {@linkcode CANONICAL_ORDER} slot
|
|
88
|
+
* (lookup is case-insensitive via {@linkcode canonicalizeKey}).
|
|
89
|
+
* Unknown / profile-declared keys (group 6) are appended at the end
|
|
90
|
+
* in source order — `fmt` never deletes a key it doesn't own
|
|
91
|
+
* (§3.3.6). Every emitted attribute carries the canonical key form.
|
|
47
92
|
*/
|
|
48
93
|
export declare function sortAttributes(attributes: Attribute[]): Attribute[];
|
|
49
94
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/formatter/mod.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EAGX,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/formatter/mod.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EAGX,MAAM,iBAAiB,CAAC;AAsCzB;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAOvE;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAc/D;AA+ND,sCAAsC;AACtC,MAAM,WAAW,aAAa;IAC5B,yCAAyC;IACzC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,6CAA6C;IAC7C,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,MAAM,CAAC;CACtC;AAED,oCAAoC;AACpC,MAAM,WAAW,YAAY;IAC3B,mCAAmC;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,sEAAsE;IACtE,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;IAC5C,qCAAqC;IACrC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;;GAOG;AACH,wBAAgB,MAAM,CACpB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,aAAa,GACtB,YAAY,CAiId;AA4DD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,CAmB/D;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAGnD;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,UAAU,EAAE,SAAS,EAAE,GACtB,SAAS,EAAE,CA2Bb;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,SAAS,EAAE,EACvB,MAAM,EAAE,MAAM,GACb,MAAM,CAKR;AA2BD;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM,GACb;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CA2B5C"}
|