@driftsys/markspec 0.10.1 → 0.10.3

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 (135) hide show
  1. package/esm/collect/mod.d.ts +34 -0
  2. package/esm/collect/mod.d.ts.map +1 -0
  3. package/esm/collect/mod.js +37 -0
  4. package/esm/decl/mod.d.ts +18 -0
  5. package/esm/decl/mod.d.ts.map +1 -0
  6. package/esm/decl/mod.js +14 -0
  7. package/esm/decl/resolve.d.ts +104 -0
  8. package/esm/decl/resolve.d.ts.map +1 -0
  9. package/esm/decl/resolve.js +66 -0
  10. package/esm/decl/surfaces.d.ts +96 -0
  11. package/esm/decl/surfaces.d.ts.map +1 -0
  12. package/esm/decl/surfaces.js +122 -0
  13. package/esm/decl/table.d.ts +50 -0
  14. package/esm/decl/table.d.ts.map +1 -0
  15. package/esm/decl/table.js +124 -0
  16. package/esm/formatter/mod.d.ts.map +1 -1
  17. package/esm/formatter/mod.js +29 -1
  18. package/esm/gates/mod.d.ts +82 -0
  19. package/esm/gates/mod.d.ts.map +1 -0
  20. package/esm/gates/mod.js +139 -0
  21. package/esm/lint/runner.d.ts +26 -3
  22. package/esm/lint/runner.d.ts.map +1 -1
  23. package/esm/lint/runner.js +39 -9
  24. package/esm/lock/edge_drift.d.ts +31 -0
  25. package/esm/lock/edge_drift.d.ts.map +1 -0
  26. package/esm/lock/edge_drift.js +29 -0
  27. package/esm/lock/mod.d.ts +2 -0
  28. package/esm/lock/mod.d.ts.map +1 -1
  29. package/esm/lock/mod.js +1 -0
  30. package/esm/mod.d.ts +11 -6
  31. package/esm/mod.d.ts.map +1 -1
  32. package/esm/mod.js +10 -4
  33. package/esm/model/mod.d.ts +8 -0
  34. package/esm/model/mod.d.ts.map +1 -1
  35. package/esm/model/mod.js +10 -0
  36. package/esm/model/profile.d.ts +8 -0
  37. package/esm/model/profile.d.ts.map +1 -1
  38. package/esm/parser/directives.d.ts +6 -0
  39. package/esm/parser/directives.d.ts.map +1 -1
  40. package/esm/parser/directives.js +17 -0
  41. package/esm/parser/markdown.d.ts.map +1 -1
  42. package/esm/parser/markdown.js +47 -11
  43. package/esm/profile/delivered.d.ts +22 -1
  44. package/esm/profile/delivered.d.ts.map +1 -1
  45. package/esm/profile/delivered.js +44 -1
  46. package/esm/profile/merge.js +1 -0
  47. package/esm/reporter/mod.d.ts.map +1 -1
  48. package/esm/reporter/mod.js +2 -3
  49. package/esm/typl/bullet.d.ts +13 -23
  50. package/esm/typl/bullet.d.ts.map +1 -1
  51. package/esm/typl/bullet.js +6 -40
  52. package/esm/typl/fence.d.ts +12 -21
  53. package/esm/typl/fence.d.ts.map +1 -1
  54. package/esm/typl/fence.js +5 -20
  55. package/esm/typl/inline.d.ts +15 -24
  56. package/esm/typl/inline.d.ts.map +1 -1
  57. package/esm/typl/inline.js +6 -44
  58. package/esm/typl/recognize.d.ts +14 -0
  59. package/esm/typl/recognize.d.ts.map +1 -0
  60. package/esm/typl/recognize.js +19 -0
  61. package/esm/util/fence.d.ts +8 -0
  62. package/esm/util/fence.d.ts.map +1 -1
  63. package/esm/util/fence.js +22 -0
  64. package/esm/validator/body_blocks.d.ts.map +1 -1
  65. package/esm/validator/body_blocks.js +3 -9
  66. package/esm/validator/corpus.d.ts.map +1 -1
  67. package/esm/validator/corpus.js +14 -12
  68. package/package.json +1 -1
  69. package/script/collect/mod.d.ts +34 -0
  70. package/script/collect/mod.d.ts.map +1 -0
  71. package/script/collect/mod.js +40 -0
  72. package/script/decl/mod.d.ts +18 -0
  73. package/script/decl/mod.d.ts.map +1 -0
  74. package/script/decl/mod.js +24 -0
  75. package/script/decl/resolve.d.ts +104 -0
  76. package/script/decl/resolve.d.ts.map +1 -0
  77. package/script/decl/resolve.js +70 -0
  78. package/script/decl/surfaces.d.ts +96 -0
  79. package/script/decl/surfaces.d.ts.map +1 -0
  80. package/script/decl/surfaces.js +128 -0
  81. package/script/decl/table.d.ts +50 -0
  82. package/script/decl/table.d.ts.map +1 -0
  83. package/script/decl/table.js +127 -0
  84. package/script/formatter/mod.d.ts.map +1 -1
  85. package/script/formatter/mod.js +29 -1
  86. package/script/gates/mod.d.ts +82 -0
  87. package/script/gates/mod.d.ts.map +1 -0
  88. package/script/gates/mod.js +144 -0
  89. package/script/lint/runner.d.ts +26 -3
  90. package/script/lint/runner.d.ts.map +1 -1
  91. package/script/lint/runner.js +39 -9
  92. package/script/lock/edge_drift.d.ts +31 -0
  93. package/script/lock/edge_drift.d.ts.map +1 -0
  94. package/script/lock/edge_drift.js +32 -0
  95. package/script/lock/mod.d.ts +2 -0
  96. package/script/lock/mod.d.ts.map +1 -1
  97. package/script/lock/mod.js +3 -1
  98. package/script/mod.d.ts +11 -6
  99. package/script/mod.d.ts.map +1 -1
  100. package/script/mod.js +45 -29
  101. package/script/model/mod.d.ts +8 -0
  102. package/script/model/mod.d.ts.map +1 -1
  103. package/script/model/mod.js +11 -0
  104. package/script/model/profile.d.ts +8 -0
  105. package/script/model/profile.d.ts.map +1 -1
  106. package/script/parser/directives.d.ts +6 -0
  107. package/script/parser/directives.d.ts.map +1 -1
  108. package/script/parser/directives.js +18 -0
  109. package/script/parser/markdown.d.ts.map +1 -1
  110. package/script/parser/markdown.js +47 -11
  111. package/script/profile/delivered.d.ts +22 -1
  112. package/script/profile/delivered.d.ts.map +1 -1
  113. package/script/profile/delivered.js +45 -1
  114. package/script/profile/merge.js +1 -0
  115. package/script/reporter/mod.d.ts.map +1 -1
  116. package/script/reporter/mod.js +2 -3
  117. package/script/typl/bullet.d.ts +13 -23
  118. package/script/typl/bullet.d.ts.map +1 -1
  119. package/script/typl/bullet.js +6 -40
  120. package/script/typl/fence.d.ts +12 -21
  121. package/script/typl/fence.d.ts.map +1 -1
  122. package/script/typl/fence.js +5 -20
  123. package/script/typl/inline.d.ts +15 -24
  124. package/script/typl/inline.d.ts.map +1 -1
  125. package/script/typl/inline.js +6 -44
  126. package/script/typl/recognize.d.ts +14 -0
  127. package/script/typl/recognize.d.ts.map +1 -0
  128. package/script/typl/recognize.js +22 -0
  129. package/script/util/fence.d.ts +8 -0
  130. package/script/util/fence.d.ts.map +1 -1
  131. package/script/util/fence.js +23 -0
  132. package/script/validator/body_blocks.d.ts.map +1 -1
  133. package/script/validator/body_blocks.js +3 -9
  134. package/script/validator/corpus.d.ts.map +1 -1
  135. package/script/validator/corpus.js +14 -12
@@ -1,44 +1,10 @@
1
- /** Matches a typl binding bullet (paragraph text). */
2
- const BULLET_BINDING_RE = /^\$[A-Za-z_][A-Za-z0-9_]*\s*:/;
3
- /** Matches a typl typedef bullet (paragraph text). */
4
- const BULLET_TYPEDEF_RE = /^type\s+[A-Za-z_][A-Za-z0-9_]*\s*=/;
5
- function isTyplBulletText(text) {
6
- return BULLET_BINDING_RE.test(text) || BULLET_TYPEDEF_RE.test(text);
7
- }
1
+ import { extractBulletDeclarations, } from "../decl/mod.js";
2
+ import { isTyplDeclarationText } from "./recognize.js";
8
3
  /**
9
- * Walk a body AST and return every bullet-list item whose first
10
- * paragraph matches typl syntax. Recurses through ListNode →
11
- * ListItemNode.blocks for nested lists (typl bullets inside a nested
12
- * list are picked up).
13
- *
14
- * Returns matches in source order (depth-first).
4
+ * Walk a body AST and return every bullet-list item whose first paragraph
5
+ * is a typl declaration, in source order (depth-first, recursing into
6
+ * nested lists). Delegates traversal to {@linkcode extractBulletDeclarations}.
15
7
  */
16
8
  export function extractTyplBullets(blocks) {
17
- const results = [];
18
- for (const block of blocks) {
19
- if (block.kind === "list") {
20
- for (const item of block.items) {
21
- if (item.blocks.length === 0)
22
- continue;
23
- const first = item.blocks[0];
24
- if (first.kind === "paragraph") {
25
- const para = first;
26
- if (isTyplBulletText(para.content.text)) {
27
- results.push({
28
- source: para.content.text,
29
- range: para.range,
30
- });
31
- }
32
- }
33
- // Recurse into nested blocks (the item may itself contain a list)
34
- if (item.blocks.length > 1) {
35
- results.push(...extractTyplBullets(item.blocks.slice(1)));
36
- }
37
- else if (first.kind === "list") {
38
- results.push(...extractTyplBullets([first]));
39
- }
40
- }
41
- }
42
- }
43
- return results;
9
+ return extractBulletDeclarations(blocks, isTyplDeclarationText);
44
10
  }
@@ -2,30 +2,21 @@
2
2
  * @module typl/fence
3
3
  *
4
4
  * Fence surface adapter — extracts typl source from fenced code blocks
5
- * whose info-string is "typl". Operates on the canonical body AST
6
- * (BodyBlock[]) produced by core/ast/build.ts.
5
+ * whose info-string is "typl". A thin wrapper over the shared
6
+ * declaration-surface machinery (core/decl): it supplies typl's fence
7
+ * recognizer and re-exports the common declaration node as
8
+ * {@linkcode TyplFenceExtraction}.
7
9
  *
8
- * This module is parser-side only — it returns the raw typl source and
9
- * its source range. PR 3 will wire the extracted source through
10
- * parseTyplBlock and attach results to Entry.types.
10
+ * See ADR-019.
11
11
  */
12
- import type { BodyBlock, SourceRange } from "../ast/nodes.js";
13
- /** A single typl fence found inside a body. */
14
- export interface TyplFenceExtraction {
15
- /** The verbatim typl source from inside the fence (CodeNode.text). */
16
- readonly source: string;
17
- /** Source range of the whole fence (opening ``` through closing ```). */
18
- readonly range: SourceRange;
19
- }
12
+ import type { BodyBlock } from "../ast/nodes.js";
13
+ import { type BlockDeclaration } from "../decl/mod.js";
14
+ /** A single typl fence found inside a body: `{ source, range }`. */
15
+ export type TyplFenceExtraction = BlockDeclaration;
20
16
  /**
21
- * Walk a body AST and return every typl fence found. Recurses into
22
- * container nodes (ListNode via ListItemNode.blocks) so typl fences
23
- * nested inside list items are discovered.
24
- *
25
- * BlockquoteNode and NoteNode carry only InlineContent (not nested
26
- * BodyBlock[]), so they are not recursed into.
27
- *
28
- * Returns fences in source order (depth-first traversal).
17
+ * Walk a body AST and return every typl fence (```typl) found, in source
18
+ * order (depth-first, recursing into list items). Delegates traversal to
19
+ * {@linkcode extractFenceDeclarations}.
29
20
  */
30
21
  export declare function extractTyplFences(blocks: readonly BodyBlock[]): readonly TyplFenceExtraction[];
31
22
  //# sourceMappingURL=fence.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fence.d.ts","sourceRoot":"","sources":["../../src/typl/fence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9D,+CAA+C;AAC/C,MAAM,WAAW,mBAAmB;IAClC,sEAAsE;IACtE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,yEAAyE;IACzE,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;CAC7B;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,SAAS,SAAS,EAAE,GAC3B,SAAS,mBAAmB,EAAE,CAYhC"}
1
+ {"version":3,"file":"fence.d.ts","sourceRoot":"","sources":["../../src/typl/fence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EACL,KAAK,gBAAgB,EAEtB,MAAM,gBAAgB,CAAC;AAExB,oEAAoE;AACpE,MAAM,MAAM,mBAAmB,GAAG,gBAAgB,CAAC;AAEnD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,SAAS,SAAS,EAAE,GAC3B,SAAS,mBAAmB,EAAE,CAEhC"}
package/esm/typl/fence.js CHANGED
@@ -1,24 +1,9 @@
1
+ import { extractFenceDeclarations, } from "../decl/mod.js";
1
2
  /**
2
- * Walk a body AST and return every typl fence found. Recurses into
3
- * container nodes (ListNode via ListItemNode.blocks) so typl fences
4
- * nested inside list items are discovered.
5
- *
6
- * BlockquoteNode and NoteNode carry only InlineContent (not nested
7
- * BodyBlock[]), so they are not recursed into.
8
- *
9
- * Returns fences in source order (depth-first traversal).
3
+ * Walk a body AST and return every typl fence (```typl) found, in source
4
+ * order (depth-first, recursing into list items). Delegates traversal to
5
+ * {@linkcode extractFenceDeclarations}.
10
6
  */
11
7
  export function extractTyplFences(blocks) {
12
- const results = [];
13
- for (const block of blocks) {
14
- if (block.kind === "code" && block.lang === "typl") {
15
- results.push({ source: block.text, range: block.range });
16
- }
17
- else if (block.kind === "list") {
18
- for (const item of block.items) {
19
- results.push(...extractTyplFences(item.blocks));
20
- }
21
- }
22
- }
23
- return results;
8
+ return extractFenceDeclarations(blocks, (lang) => lang === "typl");
24
9
  }
@@ -1,34 +1,25 @@
1
1
  /**
2
2
  * @module typl/inline
3
3
  *
4
- * Inline backtick surface adapter — recognises typl declarations
5
- * wrapped in CommonMark code spans, e.g. `` `$X : signal float[0..300]` ``
6
- * scattered through entry prose.
7
- *
8
- * Filters Entry.bodyTokens (ADR-016) for `inline-code` tokens whose text
9
- * matches typl syntax. Each matching span produces one
10
- * TyplInlineExtraction; the parser integration calls parseTyplBlock on
11
- * each `source` independently.
4
+ * Inline backtick surface adapter — recognises typl declarations wrapped
5
+ * in CommonMark code spans, e.g. `` `$X : signal float[0..300]` ``
6
+ * scattered through entry prose. A thin wrapper over the shared
7
+ * declaration-surface machinery (core/decl): it supplies typl's text
8
+ * recognizer and re-exports the common declaration node as
9
+ * {@linkcode TyplInlineExtraction}. The shared machinery strips the
10
+ * backtick delimiters `Entry.bodyTokens` (ADR-016) records before
11
+ * recognizing, so `source` is the raw typl text.
12
12
  *
13
13
  * See ADR-019.
14
14
  */
15
- import type { BodyToken, SourceLocation } from "../model/mod.js";
16
- /** A single typl inline-code declaration found in an entry body. */
17
- export interface TyplInlineExtraction {
18
- /** The typl source from one matching code span (text between backticks). */
19
- readonly source: string;
20
- /** File-relative location of the code span. */
21
- readonly location: SourceLocation;
22
- }
15
+ import type { BodyToken } from "../model/mod.js";
16
+ import { type InlineDeclaration } from "../decl/mod.js";
17
+ /** A single typl inline-code declaration: `{ source, location }`. */
18
+ export type TyplInlineExtraction = InlineDeclaration;
23
19
  /**
24
- * Filter bodyTokens to inline-code spans whose contents match typl
25
- * syntax. Returns extractions in source order (the bodyTokens contract
26
- * guarantees source order).
27
- *
28
- * `inline-code` tokens in `bodyTokens` store their `text` field with
29
- * surrounding backtick delimiters (e.g., `` `$X : signal` ``). This
30
- * function strips those delimiters before pattern-matching and before
31
- * setting `source`, so `parseTyplBlock` receives the raw typl source.
20
+ * Filter `Entry.bodyTokens` to inline-code spans whose contents are typl
21
+ * declarations, in source order. Delegates to
22
+ * {@linkcode extractInlineDeclarations}.
32
23
  */
33
24
  export declare function extractTyplInlines(bodyTokens: readonly BodyToken[]): readonly TyplInlineExtraction[];
34
25
  //# sourceMappingURL=inline.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"inline.d.ts","sourceRoot":"","sources":["../../src/typl/inline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjE,oEAAoE;AACpE,MAAM,WAAW,oBAAoB;IACnC,4EAA4E;IAC5E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,+CAA+C;IAC/C,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;CACnC;AAgCD;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,SAAS,SAAS,EAAE,GAC/B,SAAS,oBAAoB,EAAE,CASjC"}
1
+ {"version":3,"file":"inline.d.ts","sourceRoot":"","sources":["../../src/typl/inline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,gBAAgB,CAAC;AAGxB,qEAAqE;AACrE,MAAM,MAAM,oBAAoB,GAAG,iBAAiB,CAAC;AAErD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,SAAS,SAAS,EAAE,GAC/B,SAAS,oBAAoB,EAAE,CAEjC"}
@@ -1,48 +1,10 @@
1
- /** Matches a typl binding span (code-span text). */
2
- const INLINE_BINDING_RE = /^\$[A-Za-z_][A-Za-z0-9_]*\s*:/;
3
- /** Matches a typl typedef span (code-span text). */
4
- const INLINE_TYPEDEF_RE = /^type\s+[A-Za-z_][A-Za-z0-9_]*\s*=/;
5
- function isTyplInlineText(text) {
6
- return INLINE_BINDING_RE.test(text) || INLINE_TYPEDEF_RE.test(text);
7
- }
8
- /**
9
- * Strip the surrounding backtick delimiter(s) from an inline-code token's
10
- * `text` field. `body_tokens.ts` stores inline-code text as `` `value` ``
11
- * (with backtick delimiters). The typl patterns and `parseTyplBlock` need
12
- * the inner value only.
13
- *
14
- * Handles both single-backtick (`` `…` ``) and double-backtick (` ``…`` `)
15
- * delimiters. Returns the original string unchanged when it does not start
16
- * and end with a matching backtick fence.
17
- */
18
- function stripBackticks(text) {
19
- if (text.startsWith("``") && text.endsWith("``") && text.length > 4) {
20
- return text.slice(2, -2);
21
- }
22
- if (text.startsWith("`") && text.endsWith("`") && text.length > 2) {
23
- return text.slice(1, -1);
24
- }
25
- return text;
26
- }
1
+ import { extractInlineDeclarations, } from "../decl/mod.js";
2
+ import { isTyplDeclarationText } from "./recognize.js";
27
3
  /**
28
- * Filter bodyTokens to inline-code spans whose contents match typl
29
- * syntax. Returns extractions in source order (the bodyTokens contract
30
- * guarantees source order).
31
- *
32
- * `inline-code` tokens in `bodyTokens` store their `text` field with
33
- * surrounding backtick delimiters (e.g., `` `$X : signal` ``). This
34
- * function strips those delimiters before pattern-matching and before
35
- * setting `source`, so `parseTyplBlock` receives the raw typl source.
4
+ * Filter `Entry.bodyTokens` to inline-code spans whose contents are typl
5
+ * declarations, in source order. Delegates to
6
+ * {@linkcode extractInlineDeclarations}.
36
7
  */
37
8
  export function extractTyplInlines(bodyTokens) {
38
- const results = [];
39
- for (const token of bodyTokens) {
40
- if (token.kind !== "inline-code")
41
- continue;
42
- const inner = stripBackticks(token.text);
43
- if (!isTyplInlineText(inner))
44
- continue;
45
- results.push({ source: inner, location: token.location });
46
- }
47
- return results;
9
+ return extractInlineDeclarations(bodyTokens, isTyplDeclarationText);
48
10
  }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @module typl/recognize
3
+ *
4
+ * typl declaration recognizer — the DSL-specific predicate the shared
5
+ * declaration-surface machinery (core/decl) is parameterized by. A typl
6
+ * declaration is a binding (`$Name : …`) or a typedef (`type Name = …`).
7
+ * The bullet and inline surfaces share this text recognizer; the fence
8
+ * surface is recognized by its `typl` info-string (see fence.ts).
9
+ *
10
+ * See ADR-019.
11
+ */
12
+ /** True when `text` begins a typl binding or typedef declaration. */
13
+ export declare function isTyplDeclarationText(text: string): boolean;
14
+ //# sourceMappingURL=recognize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recognize.d.ts","sourceRoot":"","sources":["../../src/typl/recognize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAQH,qEAAqE;AACrE,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE3D"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @module typl/recognize
3
+ *
4
+ * typl declaration recognizer — the DSL-specific predicate the shared
5
+ * declaration-surface machinery (core/decl) is parameterized by. A typl
6
+ * declaration is a binding (`$Name : …`) or a typedef (`type Name = …`).
7
+ * The bullet and inline surfaces share this text recognizer; the fence
8
+ * surface is recognized by its `typl` info-string (see fence.ts).
9
+ *
10
+ * See ADR-019.
11
+ */
12
+ /** Matches a typl binding: `$Name :`. */
13
+ const BINDING_RE = /^\$[A-Za-z_][A-Za-z0-9_]*\s*:/;
14
+ /** Matches a typl typedef: `type Name =`. */
15
+ const TYPEDEF_RE = /^type\s+[A-Za-z_][A-Za-z0-9_]*\s*=/;
16
+ /** True when `text` begins a typl binding or typedef declaration. */
17
+ export function isTyplDeclarationText(text) {
18
+ return BINDING_RE.test(text) || TYPEDEF_RE.test(text);
19
+ }
@@ -27,4 +27,12 @@ export type ProseLineCallback = (line: string, index: number) => void;
27
27
  * skipped (they're structural, not prose).
28
28
  */
29
29
  export declare function walkProseLines(body: string, cb: ProseLineCallback): void;
30
+ /**
31
+ * Return whether `lineIndex` (0-based) is a line {@linkcode walkProseLines}
32
+ * would skip — either a fence-marker line itself, or content inside a
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).
36
+ */
37
+ export declare function isLineFenced(body: string, lineIndex: number): boolean;
30
38
  //# sourceMappingURL=fence.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fence.d.ts","sourceRoot":"","sources":["../../src/util/fence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,gEAAgE;AAChE,eAAO,MAAM,QAAQ,QAAkB,CAAC;AAExC,sFAAsF;AACtF,MAAM,MAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;AAEtE;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,iBAAiB,GAAG,IAAI,CAYxE"}
1
+ {"version":3,"file":"fence.d.ts","sourceRoot":"","sources":["../../src/util/fence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,gEAAgE;AAChE,eAAO,MAAM,QAAQ,QAAkB,CAAC;AAExC,sFAAsF;AACtF,MAAM,MAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;AAEtE;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,iBAAiB,GAAG,IAAI,CAYxE;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAYrE"}
package/esm/util/fence.js CHANGED
@@ -38,3 +38,25 @@ export function walkProseLines(body, cb) {
38
38
  cb(line, i);
39
39
  }
40
40
  }
41
+ /**
42
+ * Return whether `lineIndex` (0-based) is a line {@linkcode walkProseLines}
43
+ * would skip — either a fence-marker line itself, or content inside a
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).
47
+ */
48
+ export function isLineFenced(body, lineIndex) {
49
+ const lines = body.split("\n");
50
+ let inFence = false;
51
+ for (let i = 0; i <= lineIndex && i < lines.length; i++) {
52
+ if (FENCE_RE.test(lines[i])) {
53
+ inFence = !inFence;
54
+ if (i === lineIndex)
55
+ return true;
56
+ continue;
57
+ }
58
+ if (i === lineIndex)
59
+ return inFence;
60
+ }
61
+ return false;
62
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"body_blocks.d.ts","sourceRoot":"","sources":["../../src/validator/body_blocks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAkMzD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,UAAU,EAAE,CAsBtE"}
1
+ {"version":3,"file":"body_blocks.d.ts","sourceRoot":"","sources":["../../src/validator/body_blocks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AA2LzD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,UAAU,EAAE,CAsBtE"}
@@ -27,6 +27,7 @@
27
27
  * Code, Feature, and Math blocks are automatically excluded because the
28
28
  * builder emits opaque nodes for verbatim content — no prose text to scan.
29
29
  */
30
+ import { isMarkspecDirectiveComment } from "../parser/directives.js";
30
31
  /**
31
32
  * HTML tag detection. Matches an opening, closing, or self-closing tag
32
33
  * (`<tag>`, `</tag>`, `<tag/>`). Doesn't match HTML comments — those
@@ -37,13 +38,6 @@
37
38
  const HTML_TAG_RE = /<\/?[A-Za-z][A-Za-z0-9]*(\s[^>]*)?\/?>/;
38
39
  /** Any HTML comment, `<!--…-->`. */
39
40
  const HTML_COMMENT_RE = /<!--[\s\S]*?-->/;
40
- /**
41
- * A whole-line markspec directive comment: `<!-- markspec:<rest> -->`
42
- * occupying the line on its own (optional leading/trailing
43
- * whitespace). The directive form is the one exception spec §2.4.1
44
- * carves out from the "no raw HTML" rule.
45
- */
46
- const MARKSPEC_DIRECTIVE_LINE_RE = /^\s*<!--\s*markspec:[\s\S]*?-->\s*$/;
47
41
  /**
48
42
  * Return `true` when `line` contains raw HTML the body model forbids:
49
43
  * any tag, or any comment that isn't a standalone markspec directive.
@@ -51,7 +45,7 @@ const MARKSPEC_DIRECTIVE_LINE_RE = /^\s*<!--\s*markspec:[\s\S]*?-->\s*$/;
51
45
  function hasForbiddenHtml(line) {
52
46
  if (HTML_TAG_RE.test(line))
53
47
  return true;
54
- if (HTML_COMMENT_RE.test(line) && !MARKSPEC_DIRECTIVE_LINE_RE.test(line)) {
48
+ if (HTML_COMMENT_RE.test(line) && !isMarkspecDirectiveComment(line)) {
55
49
  return true;
56
50
  }
57
51
  return false;
@@ -123,7 +117,7 @@ function violationsFromBlock(block) {
123
117
  else if (block.subkind === "html") {
124
118
  // Block-level HTML: check if it is a markspec directive (exempt)
125
119
  // or forbidden HTML. The `raw` field carries the verbatim source.
126
- if (!MARKSPEC_DIRECTIVE_LINE_RE.test(block.raw)) {
120
+ if (!isMarkspecDirectiveComment(block.raw)) {
127
121
  out.push({ diag: RAW_HTML_DIAG, bodyLine });
128
122
  }
129
123
  }
@@ -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;AAUzD,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,CAwFvB;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,CAiCd"}
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;AAWzD,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,CAoFvB;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,CAmCd"}
@@ -13,6 +13,7 @@
13
13
  * delivering profile; generic duplicate codes are suppressed for
14
14
  * collided tokens (MSL-R014 replaces them).
15
15
  */
16
+ import { formatEntryOrigin } from "../model/mod.js";
16
17
  /** Generic duplicate detectors superseded by MSL-R014 for corpus collisions. */
17
18
  const GENERIC_DUP_CODES = new Set([
18
19
  "MSL-R005",
@@ -46,8 +47,7 @@ export function detectCorpusCollisions(allEntries) {
46
47
  code: "MSL-R014",
47
48
  severity: "error",
48
49
  message: `display ID '${e.displayId}' is already delivered by ` +
49
- `${displayOwner.origin.profileId}@` +
50
- `${displayOwner.origin.profileVersion}; rename this entry — ` +
50
+ `${formatEntryOrigin(displayOwner.origin)}; rename this entry — ` +
51
51
  `delivered corpus entries are read-only`,
52
52
  location: e.location,
53
53
  });
@@ -60,8 +60,7 @@ export function detectCorpusCollisions(allEntries) {
60
60
  code: "MSL-R014",
61
61
  severity: "error",
62
62
  message: `Id '${e.id}' is already delivered by ` +
63
- `${idOwner.origin.profileId}@` +
64
- `${idOwner.origin.profileVersion}; rename this entry — ` +
63
+ `${formatEntryOrigin(idOwner.origin)}; rename this entry — ` +
65
64
  `delivered corpus entries are read-only`,
66
65
  location: e.location,
67
66
  });
@@ -82,8 +81,7 @@ export function detectCorpusCollisions(allEntries) {
82
81
  code: "MSL-R014",
83
82
  severity: "error",
84
83
  message: `display ID '${e.displayId}' is already delivered by ` +
85
- `${displayOwner.origin.profileId}@` +
86
- `${displayOwner.origin.profileVersion}; delivered corpus ` +
84
+ `${formatEntryOrigin(displayOwner.origin)}; delivered corpus ` +
87
85
  `entries are read-only`,
88
86
  location: e.location,
89
87
  });
@@ -97,8 +95,7 @@ export function detectCorpusCollisions(allEntries) {
97
95
  code: "MSL-R014",
98
96
  severity: "error",
99
97
  message: `Id '${e.id}' is already delivered by ` +
100
- `${idOwner.origin.profileId}@` +
101
- `${idOwner.origin.profileVersion}; delivered corpus entries ` +
98
+ `${formatEntryOrigin(idOwner.origin)}; delivered corpus entries ` +
102
99
  `are read-only`,
103
100
  location: e.location,
104
101
  });
@@ -111,14 +108,19 @@ export function attributeCorpusDiagnostics(diagnostics, allEntries, collidedToke
111
108
  const corpusFiles = new Map();
112
109
  for (const e of allEntries) {
113
110
  if (e.origin) {
114
- corpusFiles.set(e.location.file, `${e.origin.profileId}@${e.origin.profileVersion}`);
111
+ corpusFiles.set(e.location.file, formatEntryOrigin(e.origin));
115
112
  }
116
113
  }
117
114
  const out = [];
118
115
  for (const d of diagnostics) {
119
- // Suppress the generic duplicate codes for corpus collisions; the
120
- // validator embeds the offending token in single quotes, which is what
121
- // this containment check keys on.
116
+ // Suppress the generic duplicate codes for a corpus collision (MSL-R014
117
+ // has already replaced them). This is a load-bearing coupling with the
118
+ // duplicate validators' message format: MSL-R005/R006/I007/I008 all embed
119
+ // the offending token wrapped in single quotes (`'<token>'`), and the
120
+ // containment check below keys on that exact `'${t}'` shape. If any of
121
+ // those producers stops single-quoting the token, the generic duplicate
122
+ // would leak through alongside the MSL-R014 — `corpus_test.ts` pins all
123
+ // four codes to this contract.
122
124
  if (GENERIC_DUP_CODES.has(d.code) &&
123
125
  [...collidedTokens].some((t) => d.message.includes(`'${t}'`))) {
124
126
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@driftsys/markspec",
3
- "version": "0.10.1",
3
+ "version": "0.10.3",
4
4
  "description": "Markdown flavor and toolchain for traceable industrial documentation",
5
5
  "keywords": [
6
6
  "markdown",
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @module core/collect
3
+ *
4
+ * Project-entry collection: discover every MarkSpec-relevant file under a
5
+ * root and parse it into a flat `Entry[]`. The single source of truth for
6
+ * "the set of entries whose trace edges the lockfile pins" — shared by
7
+ * `markspec lock` (the pinner) and its checkers (`compile`, `fmt`, `doctor`)
8
+ * so they cannot disagree on which files count. Previously each of those
9
+ * commands hand-rolled the same discover→parse loop (a `cli/commands/lock.ts`
10
+ * private helper the others reached into), which had to stay byte-identical
11
+ * by hand or the lockfile edge-hash comparison would drift spuriously.
12
+ */
13
+ import type { Entry } from "../model/mod.js";
14
+ import { type DiscoveryIO } from "../discovery/mod.js";
15
+ /** Options for {@linkcode collectProjectEntries}. */
16
+ export interface CollectOptions {
17
+ /** Gitignore-syntax patterns (e.g. `project.yaml` `exclude:`), anchored at
18
+ * `root`. Applied after `.gitignore` rules. Defaults to none. */
19
+ readonly exclude?: readonly string[];
20
+ }
21
+ /**
22
+ * Walk `root` via {@linkcode discoverFiles} — relying on its default
23
+ * extension set (`RELEVANT_EXTENSIONS`), the parity point every caller
24
+ * depends on — and parse each discovered file, returning the flattened
25
+ * entry list. Unreadable files are skipped. Parse diagnostics are not
26
+ * surfaced here: this collector exists to give the lockfile pinner and its
27
+ * checkers one definition of the file set; callers that need diagnostics
28
+ * re-parse.
29
+ *
30
+ * @param io Injected filesystem surface (keeps `core/` Node-compatible; CLI
31
+ * entry points pass a Deno-backed implementation).
32
+ */
33
+ export declare function collectProjectEntries(root: string, io: DiscoveryIO, opts?: CollectOptions): Promise<Entry[]>;
34
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/collect/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGtE,qDAAqD;AACrD,MAAM,WAAW,cAAc;IAC7B;qEACiE;IACjE,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,WAAW,EACf,IAAI,GAAE,cAAmB,GACxB,OAAO,CAAC,KAAK,EAAE,CAAC,CASlB"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ /**
3
+ * @module core/collect
4
+ *
5
+ * Project-entry collection: discover every MarkSpec-relevant file under a
6
+ * root and parse it into a flat `Entry[]`. The single source of truth for
7
+ * "the set of entries whose trace edges the lockfile pins" — shared by
8
+ * `markspec lock` (the pinner) and its checkers (`compile`, `fmt`, `doctor`)
9
+ * so they cannot disagree on which files count. Previously each of those
10
+ * commands hand-rolled the same discover→parse loop (a `cli/commands/lock.ts`
11
+ * private helper the others reached into), which had to stay byte-identical
12
+ * by hand or the lockfile edge-hash comparison would drift spuriously.
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.collectProjectEntries = collectProjectEntries;
16
+ const mod_js_1 = require("../discovery/mod.js");
17
+ const mod_js_2 = require("../parser/mod.js");
18
+ /**
19
+ * Walk `root` via {@linkcode discoverFiles} — relying on its default
20
+ * extension set (`RELEVANT_EXTENSIONS`), the parity point every caller
21
+ * depends on — and parse each discovered file, returning the flattened
22
+ * entry list. Unreadable files are skipped. Parse diagnostics are not
23
+ * surfaced here: this collector exists to give the lockfile pinner and its
24
+ * checkers one definition of the file set; callers that need diagnostics
25
+ * re-parse.
26
+ *
27
+ * @param io Injected filesystem surface (keeps `core/` Node-compatible; CLI
28
+ * entry points pass a Deno-backed implementation).
29
+ */
30
+ async function collectProjectEntries(root, io, opts = {}) {
31
+ const out = [];
32
+ for await (const file of (0, mod_js_1.discoverFiles)(root, io, { exclude: opts.exclude })) {
33
+ const content = await io.readFile(file);
34
+ if (content === undefined)
35
+ continue;
36
+ const result = await (0, mod_js_2.parseFile)(content, { file });
37
+ out.push(...result.entries);
38
+ }
39
+ return out;
40
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @module core/decl
3
+ *
4
+ * Shared declaration-surface machinery (uxil epic #717 §A). DSL-agnostic
5
+ * walkers that extract declaration sites from an entry body's four
6
+ * embedding surfaces — fenced code blocks, bullet paragraphs, inline code
7
+ * spans, and table rows — parameterized by a recognizer, plus the
8
+ * entry-local base-resolution engine (S4) that resolves relative refs
9
+ * against the base an enclosing declaration establishes. typl consumes
10
+ * these today; uxil (§B) rides on the same substrate.
11
+ */
12
+ export type { BlockDeclaration, FenceRecognizer, InlineDeclaration, TextRecognizer, } from "./surfaces.js";
13
+ export { extractBulletDeclarations, extractFenceDeclarations, extractInlineDeclarations, stripCodeSpanDelimiters, } from "./surfaces.js";
14
+ export type { RowRecognizer, TableRowDeclaration } from "./table.js";
15
+ export { extractTableDeclarations } from "./table.js";
16
+ export type { BaseScope, RefOps, RefResolution, RootCheck } from "./resolve.js";
17
+ export { checkSingleRoot, resolveRef } from "./resolve.js";
18
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/decl/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,YAAY,EACV,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,cAAc,GACf,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,yBAAyB,EACzB,wBAAwB,EACxB,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,eAAe,CAAC;AAEvB,YAAY,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAEtD,YAAY,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ /**
3
+ * @module core/decl
4
+ *
5
+ * Shared declaration-surface machinery (uxil epic #717 §A). DSL-agnostic
6
+ * walkers that extract declaration sites from an entry body's four
7
+ * embedding surfaces — fenced code blocks, bullet paragraphs, inline code
8
+ * spans, and table rows — parameterized by a recognizer, plus the
9
+ * entry-local base-resolution engine (S4) that resolves relative refs
10
+ * against the base an enclosing declaration establishes. typl consumes
11
+ * these today; uxil (§B) rides on the same substrate.
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.resolveRef = exports.checkSingleRoot = exports.extractTableDeclarations = exports.stripCodeSpanDelimiters = exports.extractInlineDeclarations = exports.extractFenceDeclarations = exports.extractBulletDeclarations = void 0;
15
+ var surfaces_js_1 = require("./surfaces.js");
16
+ Object.defineProperty(exports, "extractBulletDeclarations", { enumerable: true, get: function () { return surfaces_js_1.extractBulletDeclarations; } });
17
+ Object.defineProperty(exports, "extractFenceDeclarations", { enumerable: true, get: function () { return surfaces_js_1.extractFenceDeclarations; } });
18
+ Object.defineProperty(exports, "extractInlineDeclarations", { enumerable: true, get: function () { return surfaces_js_1.extractInlineDeclarations; } });
19
+ Object.defineProperty(exports, "stripCodeSpanDelimiters", { enumerable: true, get: function () { return surfaces_js_1.stripCodeSpanDelimiters; } });
20
+ var table_js_1 = require("./table.js");
21
+ Object.defineProperty(exports, "extractTableDeclarations", { enumerable: true, get: function () { return table_js_1.extractTableDeclarations; } });
22
+ var resolve_js_1 = require("./resolve.js");
23
+ Object.defineProperty(exports, "checkSingleRoot", { enumerable: true, get: function () { return resolve_js_1.checkSingleRoot; } });
24
+ Object.defineProperty(exports, "resolveRef", { enumerable: true, get: function () { return resolve_js_1.resolveRef; } });