@driftsys/markspec 0.11.0 → 0.12.1
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/README.md +9 -0
- package/esm/ast/normalize.d.ts +4 -5
- package/esm/ast/normalize.d.ts.map +1 -1
- package/esm/ast/normalize.js +6 -37
- package/esm/collect/mod.d.ts +29 -9
- package/esm/collect/mod.d.ts.map +1 -1
- package/esm/collect/mod.js +36 -10
- package/esm/compiler/mod.d.ts.map +1 -1
- package/esm/compiler/mod.js +2 -6
- package/esm/config/markspec.d.ts +5 -3
- package/esm/config/markspec.d.ts.map +1 -1
- package/esm/config/mod.d.ts.map +1 -1
- package/esm/config/mod.js +47 -5
- package/esm/discovery/mod.d.ts +24 -8
- package/esm/discovery/mod.d.ts.map +1 -1
- package/esm/discovery/mod.js +57 -21
- package/esm/discovery/projects.d.ts +111 -0
- package/esm/discovery/projects.d.ts.map +1 -0
- package/esm/discovery/projects.js +242 -0
- package/esm/formatter/entry_body.d.ts +84 -0
- package/esm/formatter/entry_body.d.ts.map +1 -0
- package/esm/formatter/entry_body.js +291 -0
- package/esm/formatter/md_equiv.d.ts +6 -5
- package/esm/formatter/md_equiv.d.ts.map +1 -1
- package/esm/formatter/md_equiv.js +6 -5
- package/esm/formatter/mod.d.ts +16 -9
- package/esm/formatter/mod.d.ts.map +1 -1
- package/esm/formatter/mod.js +327 -53
- package/esm/formatter/tab_markers.d.ts +15 -0
- package/esm/formatter/tab_markers.d.ts.map +1 -0
- package/esm/formatter/tab_markers.js +133 -0
- package/esm/gates/mod.d.ts.map +1 -1
- package/esm/gates/mod.js +6 -5
- package/esm/lint/runner.d.ts.map +1 -1
- package/esm/lint/runner.js +4 -4
- package/esm/lock/check.d.ts.map +1 -1
- package/esm/lock/check.js +2 -1
- package/esm/lock/edge_drift.d.ts +2 -0
- package/esm/lock/edge_drift.d.ts.map +1 -1
- package/esm/lock/edge_drift.js +4 -0
- package/esm/lock/mod.d.ts +1 -1
- package/esm/lock/mod.d.ts.map +1 -1
- package/esm/lock/mod.js +1 -1
- package/esm/lock/upstream_deps.js +1 -1
- package/esm/mod.d.ts +11 -6
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +9 -6
- package/esm/model/mod.d.ts +22 -1
- package/esm/model/mod.d.ts.map +1 -1
- package/esm/model/mod.js +10 -0
- package/esm/parser/code_regions.d.ts +29 -0
- package/esm/parser/code_regions.d.ts.map +1 -0
- package/esm/parser/code_regions.js +38 -0
- package/esm/parser/markdown.d.ts.map +1 -1
- package/esm/parser/markdown.js +103 -40
- package/esm/parser/mod.d.ts.map +1 -1
- package/esm/parser/mod.js +7 -1
- package/esm/parser/translate.d.ts.map +1 -1
- package/esm/parser/translate.js +5 -0
- package/esm/refs/mod.d.ts +6 -2
- package/esm/refs/mod.d.ts.map +1 -1
- package/esm/refs/mod.js +15 -21
- package/esm/reporter/mod.d.ts.map +1 -1
- package/esm/reporter/mod.js +2 -2
- package/esm/sync/mapping.d.ts +4 -3
- package/esm/sync/mapping.d.ts.map +1 -1
- package/esm/sync/mapping.js +52 -9
- package/esm/util/display_id.d.ts +20 -0
- package/esm/util/display_id.d.ts.map +1 -0
- package/esm/util/display_id.js +19 -0
- package/esm/util/fence.d.ts +20 -29
- package/esm/util/fence.d.ts.map +1 -1
- package/esm/util/fence.js +42 -50
- package/esm/util/modals.d.ts +6 -0
- package/esm/util/modals.d.ts.map +1 -1
- package/esm/util/modals.js +37 -0
- package/esm/validator/body_blocks.d.ts +2 -1
- package/esm/validator/body_blocks.d.ts.map +1 -1
- package/esm/validator/body_blocks.js +80 -2
- package/esm/validator/corpus.d.ts +6 -0
- package/esm/validator/corpus.d.ts.map +1 -1
- package/esm/validator/corpus.js +16 -4
- package/esm/validator/mod.d.ts +1 -1
- package/esm/validator/mod.d.ts.map +1 -1
- package/esm/validator/mod.js +1 -1
- package/esm/validator/pipeline.d.ts +6 -4
- package/esm/validator/pipeline.d.ts.map +1 -1
- package/esm/validator/pipeline.js +24 -19
- package/package.json +1 -1
- package/script/ast/normalize.d.ts +4 -5
- package/script/ast/normalize.d.ts.map +1 -1
- package/script/ast/normalize.js +5 -36
- package/script/collect/mod.d.ts +29 -9
- package/script/collect/mod.d.ts.map +1 -1
- package/script/collect/mod.js +38 -10
- package/script/compiler/mod.d.ts.map +1 -1
- package/script/compiler/mod.js +1 -5
- package/script/config/markspec.d.ts +5 -3
- package/script/config/markspec.d.ts.map +1 -1
- package/script/config/mod.d.ts.map +1 -1
- package/script/config/mod.js +47 -5
- package/script/discovery/mod.d.ts +24 -8
- package/script/discovery/mod.d.ts.map +1 -1
- package/script/discovery/mod.js +56 -20
- package/script/discovery/projects.d.ts +111 -0
- package/script/discovery/projects.d.ts.map +1 -0
- package/script/discovery/projects.js +250 -0
- package/script/formatter/entry_body.d.ts +84 -0
- package/script/formatter/entry_body.d.ts.map +1 -0
- package/script/formatter/entry_body.js +296 -0
- package/script/formatter/md_equiv.d.ts +6 -5
- package/script/formatter/md_equiv.d.ts.map +1 -1
- package/script/formatter/md_equiv.js +6 -5
- package/script/formatter/mod.d.ts +16 -9
- package/script/formatter/mod.d.ts.map +1 -1
- package/script/formatter/mod.js +324 -50
- package/script/formatter/tab_markers.d.ts +15 -0
- package/script/formatter/tab_markers.d.ts.map +1 -0
- package/script/formatter/tab_markers.js +141 -0
- package/script/gates/mod.d.ts.map +1 -1
- package/script/gates/mod.js +15 -14
- package/script/lint/runner.d.ts.map +1 -1
- package/script/lint/runner.js +3 -3
- package/script/lock/check.d.ts.map +1 -1
- package/script/lock/check.js +2 -1
- package/script/lock/edge_drift.d.ts +2 -0
- package/script/lock/edge_drift.d.ts.map +1 -1
- package/script/lock/edge_drift.js +5 -0
- package/script/lock/mod.d.ts +1 -1
- package/script/lock/mod.d.ts.map +1 -1
- package/script/lock/mod.js +2 -1
- package/script/lock/upstream_deps.js +1 -1
- package/script/mod.d.ts +11 -6
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +23 -5
- package/script/model/mod.d.ts +22 -1
- package/script/model/mod.d.ts.map +1 -1
- package/script/model/mod.js +11 -0
- package/script/parser/code_regions.d.ts +29 -0
- package/script/parser/code_regions.d.ts.map +1 -0
- package/script/parser/code_regions.js +41 -0
- package/script/parser/markdown.d.ts.map +1 -1
- package/script/parser/markdown.js +102 -39
- package/script/parser/mod.d.ts.map +1 -1
- package/script/parser/mod.js +7 -1
- package/script/parser/translate.d.ts.map +1 -1
- package/script/parser/translate.js +5 -0
- package/script/refs/mod.d.ts +6 -2
- package/script/refs/mod.d.ts.map +1 -1
- package/script/refs/mod.js +14 -20
- package/script/reporter/mod.d.ts.map +1 -1
- package/script/reporter/mod.js +1 -1
- package/script/sync/mapping.d.ts +4 -3
- package/script/sync/mapping.d.ts.map +1 -1
- package/script/sync/mapping.js +52 -9
- package/script/util/display_id.d.ts +20 -0
- package/script/util/display_id.d.ts.map +1 -0
- package/script/util/display_id.js +22 -0
- package/script/util/fence.d.ts +20 -29
- package/script/util/fence.d.ts.map +1 -1
- package/script/util/fence.js +47 -54
- package/script/util/modals.d.ts +6 -0
- package/script/util/modals.d.ts.map +1 -1
- package/script/util/modals.js +38 -0
- package/script/validator/body_blocks.d.ts +2 -1
- package/script/validator/body_blocks.d.ts.map +1 -1
- package/script/validator/body_blocks.js +80 -2
- package/script/validator/corpus.d.ts +6 -0
- package/script/validator/corpus.d.ts.map +1 -1
- package/script/validator/corpus.js +16 -3
- package/script/validator/mod.d.ts +1 -1
- package/script/validator/mod.d.ts.map +1 -1
- package/script/validator/mod.js +2 -1
- package/script/validator/pipeline.d.ts +6 -4
- package/script/validator/pipeline.d.ts.map +1 -1
- package/script/validator/pipeline.js +24 -19
package/esm/sync/mapping.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* cache TTL.
|
|
8
8
|
*
|
|
9
9
|
* Diagnostic family is `MSL-S###`:
|
|
10
|
-
* - MSL-S001 — malformed YAML / unsupported schema
|
|
10
|
+
* - MSL-S001 — malformed YAML / invalid structure / unsupported schema
|
|
11
11
|
* - MSL-S002 — locked + outbound contradiction
|
|
12
12
|
* - MSL-S003 — unknown conflict policy (newest-wins removed pre-1.0)
|
|
13
13
|
* - MSL-S004 — system ≠ identity.external-id-scheme
|
|
@@ -23,8 +23,9 @@ const ALLOWED_POLICIES = new Set([
|
|
|
23
23
|
]);
|
|
24
24
|
/**
|
|
25
25
|
* Parse and validate one mapping.yaml. Returns the model when valid, or
|
|
26
|
-
* an MSL-S### diagnostic when not.
|
|
27
|
-
*
|
|
26
|
+
* an MSL-S### diagnostic when not. Never throws on invalid YAML or invalid
|
|
27
|
+
* field shapes. Single-shot — stops at the first integrity failure to keep
|
|
28
|
+
* the repair signal clear.
|
|
28
29
|
*/
|
|
29
30
|
export function parseMapping(yaml, sourcePath) {
|
|
30
31
|
let raw;
|
|
@@ -34,7 +35,16 @@ export function parseMapping(yaml, sourcePath) {
|
|
|
34
35
|
catch (e) {
|
|
35
36
|
return fail("MSL-S001", `Malformed mapping.yaml: ${e.message}`, sourcePath);
|
|
36
37
|
}
|
|
38
|
+
if (raw === null || raw === undefined) {
|
|
39
|
+
return fail("MSL-S001", "Mapping YAML is empty or null", sourcePath);
|
|
40
|
+
}
|
|
41
|
+
if (!isRecord(raw)) {
|
|
42
|
+
return fail("MSL-S001", "Mapping YAML must be an object", sourcePath);
|
|
43
|
+
}
|
|
37
44
|
const schema = raw.schema;
|
|
45
|
+
if (typeof schema !== "number") {
|
|
46
|
+
return fail("MSL-S001", "Missing or non-number `schema` field", sourcePath);
|
|
47
|
+
}
|
|
38
48
|
if (schema !== SUPPORTED_SCHEMA) {
|
|
39
49
|
return fail("MSL-S001", `Unsupported mapping schema: ${schema} (expected ${SUPPORTED_SCHEMA})`, sourcePath);
|
|
40
50
|
}
|
|
@@ -43,12 +53,18 @@ export function parseMapping(yaml, sourcePath) {
|
|
|
43
53
|
return fail("MSL-S001", "Missing or non-string `system` field", sourcePath);
|
|
44
54
|
}
|
|
45
55
|
const direction = raw.direction;
|
|
56
|
+
if (typeof direction !== "string") {
|
|
57
|
+
return fail("MSL-S001", "Missing or non-string `direction` field", sourcePath);
|
|
58
|
+
}
|
|
46
59
|
if (direction !== "outbound" && direction !== "inbound" &&
|
|
47
60
|
direction !== "bidirectional") {
|
|
48
61
|
return fail("MSL-S001", `Invalid top-level direction '${direction}' (expected outbound/inbound/bidirectional)`, sourcePath);
|
|
49
62
|
}
|
|
50
63
|
const identity = raw.identity;
|
|
51
|
-
|
|
64
|
+
if (!isRecord(identity)) {
|
|
65
|
+
return fail("MSL-S001", "Missing or non-object `identity` field", sourcePath);
|
|
66
|
+
}
|
|
67
|
+
const scheme = identity["external-id-scheme"];
|
|
52
68
|
if (typeof scheme !== "string") {
|
|
53
69
|
return fail("MSL-S001", "Missing identity.external-id-scheme", sourcePath);
|
|
54
70
|
}
|
|
@@ -56,19 +72,42 @@ export function parseMapping(yaml, sourcePath) {
|
|
|
56
72
|
return fail("MSL-S004", `system '${system}' does not match identity.external-id-scheme '${scheme}'`, sourcePath);
|
|
57
73
|
}
|
|
58
74
|
const conflict = raw.conflict;
|
|
75
|
+
if (conflict !== undefined && !isRecord(conflict)) {
|
|
76
|
+
return fail("MSL-S001", "Non-object `conflict` field", sourcePath);
|
|
77
|
+
}
|
|
59
78
|
const policy = conflict?.default;
|
|
79
|
+
if (policy !== undefined && typeof policy !== "string") {
|
|
80
|
+
return fail("MSL-S001", "Non-string conflict.default", sourcePath);
|
|
81
|
+
}
|
|
60
82
|
if (policy !== undefined && !ALLOWED_POLICIES.has(policy)) {
|
|
61
83
|
return fail("MSL-S003", `Unknown conflict policy '${policy}' (allowed: manual, local-wins, remote-wins; newest-wins removed pre-1.0)`, sourcePath);
|
|
62
84
|
}
|
|
63
85
|
const cacheRaw = raw.cache;
|
|
64
|
-
|
|
86
|
+
if (cacheRaw !== undefined && !isRecord(cacheRaw)) {
|
|
87
|
+
return fail("MSL-S001", "Non-object `cache` field", sourcePath);
|
|
88
|
+
}
|
|
89
|
+
const ttlStr = cacheRaw?.ttl === undefined ? "15m" : cacheRaw.ttl;
|
|
90
|
+
if (typeof ttlStr !== "string") {
|
|
91
|
+
return fail("MSL-S001", "Non-string cache.ttl", sourcePath);
|
|
92
|
+
}
|
|
65
93
|
const ttlMs = parseDurationMs(ttlStr);
|
|
66
94
|
if (ttlMs === null) {
|
|
67
95
|
return fail("MSL-S005", `Unparseable cache.ttl '${ttlStr}' (expected: 15m, 1h, 7d etc.)`, sourcePath);
|
|
68
96
|
}
|
|
69
|
-
const attrsRaw = raw.attributes
|
|
97
|
+
const attrsRaw = raw.attributes === undefined ? [] : raw.attributes;
|
|
98
|
+
if (!Array.isArray(attrsRaw)) {
|
|
99
|
+
return fail("MSL-S001", "Non-array `attributes` field", sourcePath);
|
|
100
|
+
}
|
|
70
101
|
const attributes = [];
|
|
71
102
|
for (const a of attrsRaw) {
|
|
103
|
+
if (!isRecord(a) || typeof a.markspec !== "string" ||
|
|
104
|
+
typeof a.external !== "string") {
|
|
105
|
+
return fail("MSL-S001", "Each attribute mapping requires an object with string 'markspec' and 'external' fields", sourcePath);
|
|
106
|
+
}
|
|
107
|
+
if ((a.direction !== undefined && typeof a.direction !== "string") ||
|
|
108
|
+
(a.locked !== undefined && typeof a.locked !== "boolean")) {
|
|
109
|
+
return fail("MSL-S001", "Attribute mapping requires a string 'direction' and boolean 'locked' when present", sourcePath);
|
|
110
|
+
}
|
|
72
111
|
const attrDir = (a.direction === "outbound" || a.direction === "inbound" ||
|
|
73
112
|
a.direction === "bidirectional")
|
|
74
113
|
? a.direction
|
|
@@ -77,9 +116,6 @@ export function parseMapping(yaml, sourcePath) {
|
|
|
77
116
|
if (locked && attrDir === "outbound") {
|
|
78
117
|
return fail("MSL-S002", `Attribute '${a.markspec}': locked: true contradicts direction: outbound`, sourcePath);
|
|
79
118
|
}
|
|
80
|
-
if (typeof a.markspec !== "string" || typeof a.external !== "string") {
|
|
81
|
-
return fail("MSL-S001", "Each attribute mapping requires string 'markspec' and 'external' fields", sourcePath);
|
|
82
|
-
}
|
|
83
119
|
attributes.push({
|
|
84
120
|
markspec: a.markspec,
|
|
85
121
|
external: a.external,
|
|
@@ -99,6 +135,13 @@ export function parseMapping(yaml, sourcePath) {
|
|
|
99
135
|
};
|
|
100
136
|
return { mapping, diagnostics: [] };
|
|
101
137
|
}
|
|
138
|
+
/** Whether a YAML value is a plain mapping rather than a scalar or sequence. */
|
|
139
|
+
function isRecord(value) {
|
|
140
|
+
if (typeof value !== "object" || value === null)
|
|
141
|
+
return false;
|
|
142
|
+
const prototype = Object.getPrototypeOf(value);
|
|
143
|
+
return prototype === Object.prototype || prototype === null;
|
|
144
|
+
}
|
|
102
145
|
/**
|
|
103
146
|
* Cross-system validation: at most one system writes locally per attribute.
|
|
104
147
|
* "Writes locally" = direction is `inbound` or `bidirectional`. Multiple
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Display-ID token characters are ASCII letters, digits, dots, slashes,
|
|
3
|
+
* underscores and hyphens. The LSP reads the whole token under the cursor,
|
|
4
|
+
* including trailing characters in this set, then applies DISPLAY_ID_TOKEN_RE.
|
|
5
|
+
* The renderer scans whole runs of the same characters and resolves each
|
|
6
|
+
* against the known IDs: exact match first, then split on slashes only if
|
|
7
|
+
* every segment is nonempty and a known ID. If neither resolves, remove one
|
|
8
|
+
* trailing period and repeat, leaving the removed period outside the link.
|
|
9
|
+
* A token with a trailing hyphen, such as SYS_A-, does not link SYS_A.
|
|
10
|
+
* With only A/B and C known, A/B/C links nothing: slash segments are not
|
|
11
|
+
* recursively grouped. A known short ID links wherever it stands alone.
|
|
12
|
+
* These recognition rules do not constrain the parser's entry IDs.
|
|
13
|
+
*/
|
|
14
|
+
export declare const DISPLAY_ID_CHAR_RE: RegExp;
|
|
15
|
+
/**
|
|
16
|
+
* An LSP display-ID token starts with an ASCII letter or digit and contains
|
|
17
|
+
* at least three characters. Any display-ID character may end the token.
|
|
18
|
+
*/
|
|
19
|
+
export declare const DISPLAY_ID_TOKEN_RE: RegExp;
|
|
20
|
+
//# sourceMappingURL=display_id.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"display_id.d.ts","sourceRoot":"","sources":["../../src/util/display_id.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,kBAAkB,QAAoB,CAAC;AAEpD;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAEjC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Display-ID token characters are ASCII letters, digits, dots, slashes,
|
|
3
|
+
* underscores and hyphens. The LSP reads the whole token under the cursor,
|
|
4
|
+
* including trailing characters in this set, then applies DISPLAY_ID_TOKEN_RE.
|
|
5
|
+
* The renderer scans whole runs of the same characters and resolves each
|
|
6
|
+
* against the known IDs: exact match first, then split on slashes only if
|
|
7
|
+
* every segment is nonempty and a known ID. If neither resolves, remove one
|
|
8
|
+
* trailing period and repeat, leaving the removed period outside the link.
|
|
9
|
+
* A token with a trailing hyphen, such as SYS_A-, does not link SYS_A.
|
|
10
|
+
* With only A/B and C known, A/B/C links nothing: slash segments are not
|
|
11
|
+
* recursively grouped. A known short ID links wherever it stands alone.
|
|
12
|
+
* These recognition rules do not constrain the parser's entry IDs.
|
|
13
|
+
*/
|
|
14
|
+
export const DISPLAY_ID_CHAR_RE = /[A-Za-z0-9._/-]/;
|
|
15
|
+
/**
|
|
16
|
+
* An LSP display-ID token starts with an ASCII letter or digit and contains
|
|
17
|
+
* at least three characters. Any display-ID character may end the token.
|
|
18
|
+
*/
|
|
19
|
+
export const DISPLAY_ID_TOKEN_RE = new RegExp(`^[A-Za-z0-9]${DISPLAY_ID_CHAR_RE.source}{2,}$`);
|
package/esm/util/fence.d.ts
CHANGED
|
@@ -1,38 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* Prose-line walker that skips lines inside fenced code blocks.
|
|
5
|
-
* Several validator and formatter passes (body-block exclusions,
|
|
6
|
-
* caption adjacency, `$Identifier` extraction, modal-keyword
|
|
7
|
-
* normalisation) all needed to walk an entry body line-by-line while
|
|
8
|
-
* treating fenced code as verbatim. This helper centralises that
|
|
9
|
-
* pattern so the fence-toggle semantics stay consistent.
|
|
10
|
-
*
|
|
11
|
-
* Fence detection follows CommonMark §4.5 — a line whose first
|
|
12
|
-
* non-whitespace content is three or more backticks or tildes opens
|
|
13
|
-
* (or closes) a fenced block. The language tag that may follow the
|
|
14
|
-
* opening fence does not affect detection: we toggle on every fence
|
|
15
|
-
* marker regardless. (Mismatched marker types — ``` opener / ~~~
|
|
16
|
-
* closer — are accepted by the walker because real Markdown parsers
|
|
17
|
-
* already reject those upstream.)
|
|
2
|
+
* Legacy fence-prefix candidate used by the LSP source-file scanner.
|
|
3
|
+
* Markdown fence membership uses the AST-backed helpers below.
|
|
18
4
|
*/
|
|
19
|
-
/** Three or more backticks or tildes at the start of a line. */
|
|
20
5
|
export declare const FENCE_RE: RegExp;
|
|
21
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Compute zero-based fenced-code lines, including opening and closing lines.
|
|
8
|
+
* Cache the sets for the 64 most recently queried exact document texts. Each
|
|
9
|
+
* call returns a new copy, so a caller that changes it cannot alter the cache.
|
|
10
|
+
* Callers making multiple membership queries should compute this set once and
|
|
11
|
+
* pass it to {@linkcode isLineFenced} or {@linkcode walkProseLines}.
|
|
12
|
+
*/
|
|
13
|
+
export declare function fencedCodeLines(body: string): ReadonlySet<number>;
|
|
14
|
+
/**
|
|
15
|
+
* Callback for {@linkcode walkProseLines}. Receives a line and its 0-based index.
|
|
16
|
+
* The LF delimiter is excluded; a CR from a CRLF delimiter is preserved.
|
|
17
|
+
*/
|
|
22
18
|
export type ProseLineCallback = (line: string, index: number) => void;
|
|
23
19
|
/**
|
|
24
|
-
* Walk
|
|
25
|
-
*
|
|
26
|
-
* the next closes it. The fence-marker lines themselves are also
|
|
27
|
-
* skipped (they're structural, not prose).
|
|
20
|
+
* Walk lines outside fenced code, using the cached CommonMark line set unless
|
|
21
|
+
* a precomputed set for this exact text is supplied. Indented code is yielded.
|
|
28
22
|
*/
|
|
29
|
-
export declare function walkProseLines(body: string, cb: ProseLineCallback): void;
|
|
23
|
+
export declare function walkProseLines(body: string, cb: ProseLineCallback, fencedLines?: ReadonlySet<number>): void;
|
|
30
24
|
/**
|
|
31
|
-
* Return whether
|
|
32
|
-
*
|
|
33
|
-
* fenced block. Single-line-membership counterpart to `walkProseLines`'s
|
|
34
|
-
* full-body callback walk, for callers that only need a yes/no answer for
|
|
35
|
-
* one position (e.g. an LSP request gating a cursor position, #680).
|
|
25
|
+
* Return whether a zero-based document line belongs to the fenced-line set.
|
|
26
|
+
* Supply the set for this exact text when querying multiple positions.
|
|
36
27
|
*/
|
|
37
|
-
export declare function isLineFenced(body: string, lineIndex: number): boolean;
|
|
28
|
+
export declare function isLineFenced(body: string, lineIndex: number, fencedLines?: ReadonlySet<number>): boolean;
|
|
38
29
|
//# sourceMappingURL=fence.d.ts.map
|
package/esm/util/fence.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fence.d.ts","sourceRoot":"","sources":["../../src/util/fence.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fence.d.ts","sourceRoot":"","sources":["../../src/util/fence.ts"],"names":[],"mappings":"AAUA;;;GAGG;AACH,eAAO,MAAM,QAAQ,QAAkB,CAAC;AAKxC;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAajE;AAED;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;AAEtE;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,iBAAiB,EACrB,WAAW,GAAE,WAAW,CAAC,MAAM,CAAyB,GACvD,IAAI,CAIN;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,WAAW,GAAE,WAAW,CAAC,MAAM,CAAyB,GACvD,OAAO,CAET"}
|
package/esm/util/fence.js
CHANGED
|
@@ -1,62 +1,54 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module core/util/fence
|
|
3
3
|
*
|
|
4
|
-
* Prose-line
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* (or closes) a fenced block. The language tag that may follow the
|
|
14
|
-
* opening fence does not affect detection: we toggle on every fence
|
|
15
|
-
* marker regardless. (Mismatched marker types — ``` opener / ~~~
|
|
16
|
-
* closer — are accepted by the walker because real Markdown parsers
|
|
17
|
-
* already reject those upstream.)
|
|
4
|
+
* Prose-line helpers using fenced-code boundaries from the CommonMark AST.
|
|
5
|
+
* Containers, matching delimiters and implicit container endings are handled
|
|
6
|
+
* by remark. Indented code is not fenced code: MarkSpec trailers must remain
|
|
7
|
+
* available to reference and validation passes.
|
|
8
|
+
*/
|
|
9
|
+
import { parseCodeRegions } from "../parser/code_regions.js";
|
|
10
|
+
/**
|
|
11
|
+
* Legacy fence-prefix candidate used by the LSP source-file scanner.
|
|
12
|
+
* Markdown fence membership uses the AST-backed helpers below.
|
|
18
13
|
*/
|
|
19
|
-
/** Three or more backticks or tildes at the start of a line. */
|
|
20
14
|
export const FENCE_RE = /^\s*(```|~~~)/;
|
|
15
|
+
const FENCE_CACHE_CAPACITY = 64;
|
|
16
|
+
const fencedLineCache = new Map();
|
|
21
17
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
18
|
+
* Compute zero-based fenced-code lines, including opening and closing lines.
|
|
19
|
+
* Cache the sets for the 64 most recently queried exact document texts. Each
|
|
20
|
+
* call returns a new copy, so a caller that changes it cannot alter the cache.
|
|
21
|
+
* Callers making multiple membership queries should compute this set once and
|
|
22
|
+
* pass it to {@linkcode isLineFenced} or {@linkcode walkProseLines}.
|
|
26
23
|
*/
|
|
27
|
-
export function
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
cb(line, i);
|
|
24
|
+
export function fencedCodeLines(body) {
|
|
25
|
+
const cached = fencedLineCache.get(body);
|
|
26
|
+
if (cached !== undefined) {
|
|
27
|
+
fencedLineCache.delete(body);
|
|
28
|
+
fencedLineCache.set(body, cached);
|
|
29
|
+
return new Set(cached);
|
|
30
|
+
}
|
|
31
|
+
const lines = parseCodeRegions(body).fencedLines;
|
|
32
|
+
fencedLineCache.set(body, lines);
|
|
33
|
+
if (fencedLineCache.size > FENCE_CACHE_CAPACITY) {
|
|
34
|
+
fencedLineCache.delete(fencedLineCache.keys().next().value);
|
|
39
35
|
}
|
|
36
|
+
return new Set(lines);
|
|
40
37
|
}
|
|
41
38
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* fenced block. Single-line-membership counterpart to `walkProseLines`'s
|
|
45
|
-
* full-body callback walk, for callers that only need a yes/no answer for
|
|
46
|
-
* one position (e.g. an LSP request gating a cursor position, #680).
|
|
39
|
+
* Walk lines outside fenced code, using the cached CommonMark line set unless
|
|
40
|
+
* a precomputed set for this exact text is supplied. Indented code is yielded.
|
|
47
41
|
*/
|
|
48
|
-
export function
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
return false;
|
|
42
|
+
export function walkProseLines(body, cb, fencedLines = fencedCodeLines(body)) {
|
|
43
|
+
body.split("\n").forEach((line, index) => {
|
|
44
|
+
if (!fencedLines.has(index))
|
|
45
|
+
cb(line, index);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Return whether a zero-based document line belongs to the fenced-line set.
|
|
50
|
+
* Supply the set for this exact text when querying multiple positions.
|
|
51
|
+
*/
|
|
52
|
+
export function isLineFenced(body, lineIndex, fencedLines = fencedCodeLines(body)) {
|
|
53
|
+
return fencedLines.has(lineIndex);
|
|
62
54
|
}
|
package/esm/util/modals.d.ts
CHANGED
|
@@ -26,4 +26,10 @@ export declare const EARS_KEYWORD_RE: RegExp;
|
|
|
26
26
|
* punctuation character (`.`, `!`, `?`).
|
|
27
27
|
*/
|
|
28
28
|
export declare function isSentenceInitial(line: string, offset: number): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Normalize modal keywords in prose while preserving CommonMark fenced and
|
|
31
|
+
* inline code. Four-space and tab-indented lines remain verbatim as before.
|
|
32
|
+
* The document is parsed once; both code exclusions use that same AST.
|
|
33
|
+
*/
|
|
34
|
+
export declare function normalizeProseModals(text: string): string;
|
|
29
35
|
//# sourceMappingURL=modals.d.ts.map
|
package/esm/util/modals.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modals.d.ts","sourceRoot":"","sources":["../../src/util/modals.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"modals.d.ts","sourceRoot":"","sources":["../../src/util/modals.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,QAA0C,CAAC;AAExE;;;;;GAKG;AACH,eAAO,MAAM,eAAe,QAAmC,CAAC;AAEhE;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAOvE;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CA4CzD"}
|
package/esm/util/modals.js
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
* `ast/` is a dependency of `formatter/`, so `formatter → ast` is OK but
|
|
7
7
|
* `ast → formatter` is not.
|
|
8
8
|
*/
|
|
9
|
+
import { parseCodeRegions } from "../parser/code_regions.js";
|
|
10
|
+
import { walkProseLines } from "./fence.js";
|
|
9
11
|
/**
|
|
10
12
|
* RFC 2119 modal keywords in uppercase form, with optional ` NOT` suffix.
|
|
11
13
|
* Captured for canonical-form normalisation per spec §3.4.1: uppercase
|
|
@@ -36,3 +38,38 @@ export function isSentenceInitial(line, offset) {
|
|
|
36
38
|
const prev = line[i];
|
|
37
39
|
return prev === "." || prev === "!" || prev === "?";
|
|
38
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Normalize modal keywords in prose while preserving CommonMark fenced and
|
|
43
|
+
* inline code. Four-space and tab-indented lines remain verbatim as before.
|
|
44
|
+
* The document is parsed once; both code exclusions use that same AST.
|
|
45
|
+
*/
|
|
46
|
+
export function normalizeProseModals(text) {
|
|
47
|
+
const { fencedLines, inlineCode } = parseCodeRegions(text);
|
|
48
|
+
const lines = text.split("\n");
|
|
49
|
+
let lineOffset = 0;
|
|
50
|
+
let rangeIndex = 0;
|
|
51
|
+
// Record offsets before walking: the callback skips fenced lines.
|
|
52
|
+
const offsets = lines.map((line) => {
|
|
53
|
+
const offset = lineOffset;
|
|
54
|
+
lineOffset += line.length + 1;
|
|
55
|
+
return offset;
|
|
56
|
+
});
|
|
57
|
+
walkProseLines(text, (line, i) => {
|
|
58
|
+
if (/^( {4}|\t)/.test(line))
|
|
59
|
+
return;
|
|
60
|
+
const start = offsets[i];
|
|
61
|
+
while (rangeIndex < inlineCode.length && inlineCode[rangeIndex].end <= start)
|
|
62
|
+
rangeIndex++;
|
|
63
|
+
const protectedRanges = [];
|
|
64
|
+
for (let j = rangeIndex; j < inlineCode.length && inlineCode[j].start < start + line.length; j++) {
|
|
65
|
+
protectedRanges.push(inlineCode[j]);
|
|
66
|
+
}
|
|
67
|
+
const isCode = (offset, length) => protectedRanges.some((range) => range.start < start + offset + length && range.end > start + offset);
|
|
68
|
+
let normalized = line.replace(RFC2119_MODAL_RE, (match, _keyword, _not, offset) => isCode(offset, match.length) ? match : match.toLowerCase());
|
|
69
|
+
normalized = normalized.replace(EARS_KEYWORD_RE, (match, _keyword, offset) => isCode(offset, match.length) || isSentenceInitial(normalized, offset)
|
|
70
|
+
? match
|
|
71
|
+
: match.toLowerCase());
|
|
72
|
+
lines[i] = normalized;
|
|
73
|
+
}, fencedLines);
|
|
74
|
+
return lines.join("\n");
|
|
75
|
+
}
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
* - Inline HTML — remains inside `ParagraphNode.content.text` (remark
|
|
21
21
|
* does not extract inline HTML nodes into block-level nodes); each
|
|
22
22
|
* paragraph's text is scanned line-by-line using the same regex
|
|
23
|
-
* approach as the old walkProseLines path
|
|
23
|
+
* approach as the old walkProseLines path (with inline code spans
|
|
24
|
+
* masked out first — they are literal text, never HTML), bounded to prose-only
|
|
24
25
|
* nodes (code/feature/math blocks are automatically excluded because
|
|
25
26
|
* the builder does not emit prose-bearing nodes for verbatim content).
|
|
26
27
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"body_blocks.d.ts","sourceRoot":"","sources":["../../src/validator/body_blocks.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"body_blocks.d.ts","sourceRoot":"","sources":["../../src/validator/body_blocks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AA0QzD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,UAAU,EAAE,CAsBtE"}
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
* - Inline HTML — remains inside `ParagraphNode.content.text` (remark
|
|
21
21
|
* does not extract inline HTML nodes into block-level nodes); each
|
|
22
22
|
* paragraph's text is scanned line-by-line using the same regex
|
|
23
|
-
* approach as the old walkProseLines path
|
|
23
|
+
* approach as the old walkProseLines path (with inline code spans
|
|
24
|
+
* masked out first — they are literal text, never HTML), bounded to prose-only
|
|
24
25
|
* nodes (code/feature/math blocks are automatically excluded because
|
|
25
26
|
* the builder does not emit prose-bearing nodes for verbatim content).
|
|
26
27
|
*
|
|
@@ -38,6 +39,15 @@ import { isMarkspecDirectiveComment } from "../parser/directives.js";
|
|
|
38
39
|
const HTML_TAG_RE = /<\/?[A-Za-z][A-Za-z0-9]*(\s[^>]*)?\/?>/;
|
|
39
40
|
/** Any HTML comment, `<!--…-->`. */
|
|
40
41
|
const HTML_COMMENT_RE = /<!--[\s\S]*?-->/;
|
|
42
|
+
/**
|
|
43
|
+
* A CommonMark raw HTML open or closing tag (§6.6) anchored at the scan
|
|
44
|
+
* position. Stricter than {@linkcode HTML_TAG_RE} on purpose: it decides
|
|
45
|
+
* code-span precedence, so `` a<b and `c>` `` must not read as a tag
|
|
46
|
+
* (a backtick cannot start an attribute name) and hide the code span.
|
|
47
|
+
*/
|
|
48
|
+
const HTML_TAG_AT_RE = /^(?:<[A-Za-z][A-Za-z0-9-]*(?:\s+[A-Za-z_:][\w.:-]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*\/?>|<\/[A-Za-z][A-Za-z0-9-]*\s*>)/;
|
|
49
|
+
/** {@linkcode HTML_COMMENT_RE} anchored at the scan position. */
|
|
50
|
+
const HTML_COMMENT_AT_RE = new RegExp(`^${HTML_COMMENT_RE.source}`);
|
|
41
51
|
/**
|
|
42
52
|
* Return `true` when `line` contains raw HTML the body model forbids:
|
|
43
53
|
* any tag, or any comment that isn't a standalone markspec directive.
|
|
@@ -70,6 +80,74 @@ const RAW_HTML_DIAG = {
|
|
|
70
80
|
severity: "error",
|
|
71
81
|
summary: "raw HTML inside entry body — only `<!-- markspec:* -->` directive comments are permitted (spec §2.4.1)",
|
|
72
82
|
};
|
|
83
|
+
/**
|
|
84
|
+
* Blank out every CommonMark code span in `text` (delimiters included),
|
|
85
|
+
* keeping newlines so line offsets are preserved. A code span is literal
|
|
86
|
+
* text, never HTML (CommonMark §6.1), so `` `tool --root <ws>` `` must
|
|
87
|
+
* not reach the tag regex.
|
|
88
|
+
*
|
|
89
|
+
* Follows the CommonMark rules the regex scan would otherwise ignore:
|
|
90
|
+
* a backslash-escaped backtick does not open a span; an opening run of N
|
|
91
|
+
* backticks closes only at the next run of exactly N; an unmatched run
|
|
92
|
+
* is literal. Raw HTML and code spans bind left-to-right, so a tag that
|
|
93
|
+
* starts before a backtick run is skipped intact and still flagged.
|
|
94
|
+
*/
|
|
95
|
+
function maskCodeSpans(text) {
|
|
96
|
+
const blank = (s) => s.replace(/[^\n]/g, " ");
|
|
97
|
+
let out = "";
|
|
98
|
+
let i = 0;
|
|
99
|
+
while (i < text.length) {
|
|
100
|
+
const ch = text[i];
|
|
101
|
+
if (ch === "\\" && i + 1 < text.length) {
|
|
102
|
+
out += text.slice(i, i + 2);
|
|
103
|
+
i += 2;
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (ch === "<") {
|
|
107
|
+
const rest = text.slice(i);
|
|
108
|
+
const tag = HTML_TAG_AT_RE.exec(rest) ?? HTML_COMMENT_AT_RE.exec(rest);
|
|
109
|
+
if (tag) {
|
|
110
|
+
out += tag[0];
|
|
111
|
+
i += tag[0].length;
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (ch !== "`") {
|
|
116
|
+
out += ch;
|
|
117
|
+
i++;
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
let runEnd = i;
|
|
121
|
+
while (runEnd < text.length && text[runEnd] === "`")
|
|
122
|
+
runEnd++;
|
|
123
|
+
const runLength = runEnd - i;
|
|
124
|
+
let close = -1;
|
|
125
|
+
let j = runEnd;
|
|
126
|
+
while (j < text.length) {
|
|
127
|
+
if (text[j] !== "`") {
|
|
128
|
+
j++;
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
let k = j;
|
|
132
|
+
while (k < text.length && text[k] === "`")
|
|
133
|
+
k++;
|
|
134
|
+
if (k - j === runLength) {
|
|
135
|
+
close = k;
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
j = k;
|
|
139
|
+
}
|
|
140
|
+
if (close < 0) {
|
|
141
|
+
// Unmatched opener — the backticks are literal text.
|
|
142
|
+
out += text.slice(i, runEnd);
|
|
143
|
+
i = runEnd;
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
out += blank(text.slice(i, close));
|
|
147
|
+
i = close;
|
|
148
|
+
}
|
|
149
|
+
return out;
|
|
150
|
+
}
|
|
73
151
|
/**
|
|
74
152
|
* Scan `text` line-by-line for forbidden inline HTML, starting at
|
|
75
153
|
* `startLine` (1-based body-relative). Returns one `{ diag, bodyLine }`
|
|
@@ -83,7 +161,7 @@ const RAW_HTML_DIAG = {
|
|
|
83
161
|
*/
|
|
84
162
|
function htmlViolations(text, startLine) {
|
|
85
163
|
const out = [];
|
|
86
|
-
const lines = text.split("\n");
|
|
164
|
+
const lines = maskCodeSpans(text).split("\n");
|
|
87
165
|
for (let li = 0; li < lines.length; li++) {
|
|
88
166
|
const line = lines[li];
|
|
89
167
|
if (line.trim() === "")
|
|
@@ -14,6 +14,12 @@
|
|
|
14
14
|
* collided tokens (MSL-R014 replaces them).
|
|
15
15
|
*/
|
|
16
16
|
import type { Diagnostic, Entry } from "../model/mod.js";
|
|
17
|
+
/**
|
|
18
|
+
* Attribute corpus findings and replace generic duplicate diagnostics with
|
|
19
|
+
* corpus collisions. Append collisions after attribution so MSL-R014 remains
|
|
20
|
+
* an error even when its location belongs to a read-only corpus.
|
|
21
|
+
*/
|
|
22
|
+
export declare function applyCorpusPostPass(diagnostics: readonly Diagnostic[], allEntries: readonly Entry[]): Diagnostic[];
|
|
17
23
|
/** Result of {@linkcode detectCorpusCollisions}. */
|
|
18
24
|
export interface CorpusCollisionResult {
|
|
19
25
|
readonly diagnostics: readonly Diagnostic[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"corpus.d.ts","sourceRoot":"","sources":["../../src/validator/corpus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAe,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"corpus.d.ts","sourceRoot":"","sources":["../../src/validator/corpus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAe,MAAM,iBAAiB,CAAC;AAOtE;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,SAAS,UAAU,EAAE,EAClC,UAAU,EAAE,SAAS,KAAK,EAAE,GAC3B,UAAU,EAAE,CAUd;AA2BD,oDAAoD;AACpD,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;IAC5C,qEAAqE;IACrE,QAAQ,CAAC,cAAc,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC9C;AAED,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,SAAS,KAAK,EAAE,GAC3B,qBAAqB,CAsFvB;AAED,wBAAgB,0BAA0B,CACxC,WAAW,EAAE,SAAS,UAAU,EAAE,EAClC,UAAU,EAAE,SAAS,KAAK,EAAE,EAC5B,cAAc,EAAE,WAAW,CAAC,MAAM,CAAC,GAClC,UAAU,EAAE,CAyCd"}
|
package/esm/validator/corpus.js
CHANGED
|
@@ -13,7 +13,19 @@
|
|
|
13
13
|
* delivering profile; generic duplicate codes are suppressed for
|
|
14
14
|
* collided tokens (MSL-R014 replaces them).
|
|
15
15
|
*/
|
|
16
|
-
import { formatEntryOrigin, sameOriginSource } from "../model/mod.js";
|
|
16
|
+
import { formatEntryOrigin, isCorpusEntry, sameOriginSource, } from "../model/mod.js";
|
|
17
|
+
/**
|
|
18
|
+
* Attribute corpus findings and replace generic duplicate diagnostics with
|
|
19
|
+
* corpus collisions. Append collisions after attribution so MSL-R014 remains
|
|
20
|
+
* an error even when its location belongs to a read-only corpus.
|
|
21
|
+
*/
|
|
22
|
+
export function applyCorpusPostPass(diagnostics, allEntries) {
|
|
23
|
+
const collisions = detectCorpusCollisions(allEntries);
|
|
24
|
+
return [
|
|
25
|
+
...attributeCorpusDiagnostics(diagnostics, allEntries, collisions.collidedTokens),
|
|
26
|
+
...collisions.diagnostics,
|
|
27
|
+
];
|
|
28
|
+
}
|
|
17
29
|
/**
|
|
18
30
|
* Remedy clause for an inter-tier MSL-R014 collision — both owners
|
|
19
31
|
* carry an origin (upstream and/or delivered profile), so the consumer
|
|
@@ -40,7 +52,7 @@ export function detectCorpusCollisions(allEntries) {
|
|
|
40
52
|
const corpusByDisplayId = new Map();
|
|
41
53
|
const corpusById = new Map();
|
|
42
54
|
for (const e of allEntries) {
|
|
43
|
-
if (!e
|
|
55
|
+
if (!isCorpusEntry(e))
|
|
44
56
|
continue;
|
|
45
57
|
if (!corpusByDisplayId.has(e.displayId)) {
|
|
46
58
|
corpusByDisplayId.set(e.displayId, e);
|
|
@@ -54,7 +66,7 @@ export function detectCorpusCollisions(allEntries) {
|
|
|
54
66
|
const diagnostics = [];
|
|
55
67
|
const collided = new Set();
|
|
56
68
|
for (const e of allEntries) {
|
|
57
|
-
if (!e
|
|
69
|
+
if (!isCorpusEntry(e)) {
|
|
58
70
|
const displayOwner = corpusByDisplayId.get(e.displayId);
|
|
59
71
|
if (displayOwner) {
|
|
60
72
|
collided.add(e.displayId);
|
|
@@ -124,7 +136,7 @@ export function detectCorpusCollisions(allEntries) {
|
|
|
124
136
|
export function attributeCorpusDiagnostics(diagnostics, allEntries, collidedTokens) {
|
|
125
137
|
const corpusFiles = new Map();
|
|
126
138
|
for (const e of allEntries) {
|
|
127
|
-
if (e
|
|
139
|
+
if (isCorpusEntry(e)) {
|
|
128
140
|
corpusFiles.set(e.location.file, e.origin);
|
|
129
141
|
}
|
|
130
142
|
}
|
package/esm/validator/mod.d.ts
CHANGED
|
@@ -43,6 +43,6 @@ export { validateValue } from "./value_types.js";
|
|
|
43
43
|
export type { ValueValidator } from "./value_types.js";
|
|
44
44
|
export { normalizeListValues } from "./normalize.js";
|
|
45
45
|
export { effectiveTraceRules, matchesAnyTarget, validateTraceabilityForEntry, } from "./traceability.js";
|
|
46
|
-
export { attributeCorpusDiagnostics, detectCorpusCollisions, } from "./corpus.js";
|
|
46
|
+
export { applyCorpusPostPass, attributeCorpusDiagnostics, detectCorpusCollisions, } from "./corpus.js";
|
|
47
47
|
export type { CorpusCollisionResult } from "./corpus.js";
|
|
48
48
|
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/validator/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAsCpE,mCAAmC;AACnC,MAAM,WAAW,cAAc;IAC7B,2CAA2C;IAC3C,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;IAC5C,gDAAgD;IAChD,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,GAAG,cAAc,CAuBlE;AAibD,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,SAAS,KAAK,EAAE,GACxB,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAM5B;AAGD,wBAAgB,QAAQ,CACtB,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,GAAG,EAAE,MAAM,GACV,SAAS,GAAG,SAAS,CAEvB;AAED,OAAO,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACtE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAErE,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AACxD,YAAY,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEpE,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACjE,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAC7E,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,4BAA4B,GAC7B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/validator/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAsCpE,mCAAmC;AACnC,MAAM,WAAW,cAAc;IAC7B,2CAA2C;IAC3C,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;IAC5C,gDAAgD;IAChD,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,GAAG,cAAc,CAuBlE;AAibD,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,SAAS,KAAK,EAAE,GACxB,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAM5B;AAGD,wBAAgB,QAAQ,CACtB,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,GAAG,EAAE,MAAM,GACV,SAAS,GAAG,SAAS,CAEvB;AAED,OAAO,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACtE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAErE,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AACxD,YAAY,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEpE,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACjE,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAC7E,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,4BAA4B,GAC7B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,mBAAmB,EACnB,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC"}
|
package/esm/validator/mod.js
CHANGED
|
@@ -487,4 +487,4 @@ export { effectiveScope, validateAttributesForEntry } from "./attributes.js";
|
|
|
487
487
|
export { validateValue } from "./value_types.js";
|
|
488
488
|
export { normalizeListValues } from "./normalize.js";
|
|
489
489
|
export { effectiveTraceRules, matchesAnyTarget, validateTraceabilityForEntry, } from "./traceability.js";
|
|
490
|
-
export { attributeCorpusDiagnostics, detectCorpusCollisions, } from "./corpus.js";
|
|
490
|
+
export { applyCorpusPostPass, attributeCorpusDiagnostics, detectCorpusCollisions, } from "./corpus.js";
|