@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
@@ -2,33 +2,23 @@
2
2
  * @module typl/bullet
3
3
  *
4
4
  * Bullet-glossary surface adapter — recognises CommonMark bullet list
5
- * items whose first paragraph matches typl syntax (`$X : ...` binding
6
- * or `type X = ...` typedef). Mixed lists are supported: items that
7
- * match are treated as typl declarations; non-matching bullets are
8
- * left alone.
9
- *
10
- * Each matching item produces one TyplBulletExtraction; the parser
11
- * integration calls parseTyplBlock on each `source` independently.
12
- * Per-item position-bridging uses the item's range and formula
13
- * documented in bridgeTyplDiagnostic.
5
+ * items whose first paragraph is a typl declaration (`$X : …` binding or
6
+ * `type X = …` typedef). 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 TyplBulletExtraction}. Mixed lists are supported — matching
10
+ * items are extracted, non-matching bullets are left alone.
14
11
  *
15
12
  * See ADR-019.
16
13
  */
17
- import type { BodyBlock, SourceRange } from "../ast/nodes.js";
18
- /** A single typl bullet item found inside a body. */
19
- export interface TyplBulletExtraction {
20
- /** The typl source from one matching bullet item (paragraph text). */
21
- readonly source: string;
22
- /** Source range of the bullet's first paragraph. */
23
- readonly range: SourceRange;
24
- }
14
+ import type { BodyBlock } from "../ast/nodes.js";
15
+ import { type BlockDeclaration } from "../decl/mod.js";
16
+ /** A single typl bullet item found inside a body: `{ source, range }`. */
17
+ export type TyplBulletExtraction = BlockDeclaration;
25
18
  /**
26
- * Walk a body AST and return every bullet-list item whose first
27
- * paragraph matches typl syntax. Recurses through ListNode →
28
- * ListItemNode.blocks for nested lists (typl bullets inside a nested
29
- * list are picked up).
30
- *
31
- * Returns matches in source order (depth-first).
19
+ * Walk a body AST and return every bullet-list item whose first paragraph
20
+ * is a typl declaration, in source order (depth-first, recursing into
21
+ * nested lists). Delegates traversal to {@linkcode extractBulletDeclarations}.
32
22
  */
33
23
  export declare function extractTyplBullets(blocks: readonly BodyBlock[]): readonly TyplBulletExtraction[];
34
24
  //# sourceMappingURL=bullet.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bullet.d.ts","sourceRoot":"","sources":["../../src/typl/bullet.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,SAAS,EAAiB,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE7E,qDAAqD;AACrD,MAAM,WAAW,oBAAoB;IACnC,sEAAsE;IACtE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,oDAAoD;IACpD,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;CAC7B;AAYD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,SAAS,SAAS,EAAE,GAC3B,SAAS,oBAAoB,EAAE,CA0BjC"}
1
+ {"version":3,"file":"bullet.d.ts","sourceRoot":"","sources":["../../src/typl/bullet.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EACL,KAAK,gBAAgB,EAEtB,MAAM,gBAAgB,CAAC;AAGxB,0EAA0E;AAC1E,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,CAAC;AAEpD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,SAAS,SAAS,EAAE,GAC3B,SAAS,oBAAoB,EAAE,CAEjC"}
@@ -1,47 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.extractTyplBullets = extractTyplBullets;
4
- /** Matches a typl binding bullet (paragraph text). */
5
- const BULLET_BINDING_RE = /^\$[A-Za-z_][A-Za-z0-9_]*\s*:/;
6
- /** Matches a typl typedef bullet (paragraph text). */
7
- const BULLET_TYPEDEF_RE = /^type\s+[A-Za-z_][A-Za-z0-9_]*\s*=/;
8
- function isTyplBulletText(text) {
9
- return BULLET_BINDING_RE.test(text) || BULLET_TYPEDEF_RE.test(text);
10
- }
4
+ const mod_js_1 = require("../decl/mod.js");
5
+ const recognize_js_1 = require("./recognize.js");
11
6
  /**
12
- * Walk a body AST and return every bullet-list item whose first
13
- * paragraph matches typl syntax. Recurses through ListNode →
14
- * ListItemNode.blocks for nested lists (typl bullets inside a nested
15
- * list are picked up).
16
- *
17
- * Returns matches in source order (depth-first).
7
+ * Walk a body AST and return every bullet-list item whose first paragraph
8
+ * is a typl declaration, in source order (depth-first, recursing into
9
+ * nested lists). Delegates traversal to {@linkcode extractBulletDeclarations}.
18
10
  */
19
11
  function extractTyplBullets(blocks) {
20
- const results = [];
21
- for (const block of blocks) {
22
- if (block.kind === "list") {
23
- for (const item of block.items) {
24
- if (item.blocks.length === 0)
25
- continue;
26
- const first = item.blocks[0];
27
- if (first.kind === "paragraph") {
28
- const para = first;
29
- if (isTyplBulletText(para.content.text)) {
30
- results.push({
31
- source: para.content.text,
32
- range: para.range,
33
- });
34
- }
35
- }
36
- // Recurse into nested blocks (the item may itself contain a list)
37
- if (item.blocks.length > 1) {
38
- results.push(...extractTyplBullets(item.blocks.slice(1)));
39
- }
40
- else if (first.kind === "list") {
41
- results.push(...extractTyplBullets([first]));
42
- }
43
- }
44
- }
45
- }
46
- return results;
12
+ return (0, mod_js_1.extractBulletDeclarations)(blocks, recognize_js_1.isTyplDeclarationText);
47
13
  }
@@ -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"}
@@ -1,27 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.extractTyplFences = extractTyplFences;
4
+ const mod_js_1 = require("../decl/mod.js");
4
5
  /**
5
- * Walk a body AST and return every typl fence found. Recurses into
6
- * container nodes (ListNode via ListItemNode.blocks) so typl fences
7
- * nested inside list items are discovered.
8
- *
9
- * BlockquoteNode and NoteNode carry only InlineContent (not nested
10
- * BodyBlock[]), so they are not recursed into.
11
- *
12
- * Returns fences in source order (depth-first traversal).
6
+ * Walk a body AST and return every typl fence (```typl) found, in source
7
+ * order (depth-first, recursing into list items). Delegates traversal to
8
+ * {@linkcode extractFenceDeclarations}.
13
9
  */
14
10
  function extractTyplFences(blocks) {
15
- const results = [];
16
- for (const block of blocks) {
17
- if (block.kind === "code" && block.lang === "typl") {
18
- results.push({ source: block.text, range: block.range });
19
- }
20
- else if (block.kind === "list") {
21
- for (const item of block.items) {
22
- results.push(...extractTyplFences(item.blocks));
23
- }
24
- }
25
- }
26
- return results;
11
+ return (0, mod_js_1.extractFenceDeclarations)(blocks, (lang) => lang === "typl");
27
12
  }
@@ -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,51 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.extractTyplInlines = extractTyplInlines;
4
- /** Matches a typl binding span (code-span text). */
5
- const INLINE_BINDING_RE = /^\$[A-Za-z_][A-Za-z0-9_]*\s*:/;
6
- /** Matches a typl typedef span (code-span text). */
7
- const INLINE_TYPEDEF_RE = /^type\s+[A-Za-z_][A-Za-z0-9_]*\s*=/;
8
- function isTyplInlineText(text) {
9
- return INLINE_BINDING_RE.test(text) || INLINE_TYPEDEF_RE.test(text);
10
- }
11
- /**
12
- * Strip the surrounding backtick delimiter(s) from an inline-code token's
13
- * `text` field. `body_tokens.ts` stores inline-code text as `` `value` ``
14
- * (with backtick delimiters). The typl patterns and `parseTyplBlock` need
15
- * the inner value only.
16
- *
17
- * Handles both single-backtick (`` `…` ``) and double-backtick (` ``…`` `)
18
- * delimiters. Returns the original string unchanged when it does not start
19
- * and end with a matching backtick fence.
20
- */
21
- function stripBackticks(text) {
22
- if (text.startsWith("``") && text.endsWith("``") && text.length > 4) {
23
- return text.slice(2, -2);
24
- }
25
- if (text.startsWith("`") && text.endsWith("`") && text.length > 2) {
26
- return text.slice(1, -1);
27
- }
28
- return text;
29
- }
4
+ const mod_js_1 = require("../decl/mod.js");
5
+ const recognize_js_1 = require("./recognize.js");
30
6
  /**
31
- * Filter bodyTokens to inline-code spans whose contents match typl
32
- * syntax. Returns extractions in source order (the bodyTokens contract
33
- * guarantees source order).
34
- *
35
- * `inline-code` tokens in `bodyTokens` store their `text` field with
36
- * surrounding backtick delimiters (e.g., `` `$X : signal` ``). This
37
- * function strips those delimiters before pattern-matching and before
38
- * setting `source`, so `parseTyplBlock` receives the raw typl source.
7
+ * Filter `Entry.bodyTokens` to inline-code spans whose contents are typl
8
+ * declarations, in source order. Delegates to
9
+ * {@linkcode extractInlineDeclarations}.
39
10
  */
40
11
  function extractTyplInlines(bodyTokens) {
41
- const results = [];
42
- for (const token of bodyTokens) {
43
- if (token.kind !== "inline-code")
44
- continue;
45
- const inner = stripBackticks(token.text);
46
- if (!isTyplInlineText(inner))
47
- continue;
48
- results.push({ source: inner, location: token.location });
49
- }
50
- return results;
12
+ return (0, mod_js_1.extractInlineDeclarations)(bodyTokens, recognize_js_1.isTyplDeclarationText);
51
13
  }
@@ -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,22 @@
1
+ "use strict";
2
+ /**
3
+ * @module typl/recognize
4
+ *
5
+ * typl declaration recognizer — the DSL-specific predicate the shared
6
+ * declaration-surface machinery (core/decl) is parameterized by. A typl
7
+ * declaration is a binding (`$Name : …`) or a typedef (`type Name = …`).
8
+ * The bullet and inline surfaces share this text recognizer; the fence
9
+ * surface is recognized by its `typl` info-string (see fence.ts).
10
+ *
11
+ * See ADR-019.
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.isTyplDeclarationText = isTyplDeclarationText;
15
+ /** Matches a typl binding: `$Name :`. */
16
+ const BINDING_RE = /^\$[A-Za-z_][A-Za-z0-9_]*\s*:/;
17
+ /** Matches a typl typedef: `type Name =`. */
18
+ const TYPEDEF_RE = /^type\s+[A-Za-z_][A-Za-z0-9_]*\s*=/;
19
+ /** True when `text` begins a typl binding or typedef declaration. */
20
+ function isTyplDeclarationText(text) {
21
+ return BINDING_RE.test(text) || TYPEDEF_RE.test(text);
22
+ }
@@ -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"}
@@ -20,6 +20,7 @@
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.FENCE_RE = void 0;
22
22
  exports.walkProseLines = walkProseLines;
23
+ exports.isLineFenced = isLineFenced;
23
24
  /** Three or more backticks or tildes at the start of a line. */
24
25
  exports.FENCE_RE = /^\s*(```|~~~)/;
25
26
  /**
@@ -42,3 +43,25 @@ function walkProseLines(body, cb) {
42
43
  cb(line, i);
43
44
  }
44
45
  }
46
+ /**
47
+ * Return whether `lineIndex` (0-based) is a line {@linkcode walkProseLines}
48
+ * would skip — either a fence-marker line itself, or content inside a
49
+ * fenced block. Single-line-membership counterpart to `walkProseLines`'s
50
+ * full-body callback walk, for callers that only need a yes/no answer for
51
+ * one position (e.g. an LSP request gating a cursor position, #680).
52
+ */
53
+ function isLineFenced(body, lineIndex) {
54
+ const lines = body.split("\n");
55
+ let inFence = false;
56
+ for (let i = 0; i <= lineIndex && i < lines.length; i++) {
57
+ if (exports.FENCE_RE.test(lines[i])) {
58
+ inFence = !inFence;
59
+ if (i === lineIndex)
60
+ return true;
61
+ continue;
62
+ }
63
+ if (i === lineIndex)
64
+ return inFence;
65
+ }
66
+ return false;
67
+ }
@@ -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"}
@@ -30,6 +30,7 @@
30
30
  */
31
31
  Object.defineProperty(exports, "__esModule", { value: true });
32
32
  exports.validateBodyBlocks = validateBodyBlocks;
33
+ const directives_js_1 = require("../parser/directives.js");
33
34
  /**
34
35
  * HTML tag detection. Matches an opening, closing, or self-closing tag
35
36
  * (`<tag>`, `</tag>`, `<tag/>`). Doesn't match HTML comments — those
@@ -40,13 +41,6 @@ exports.validateBodyBlocks = validateBodyBlocks;
40
41
  const HTML_TAG_RE = /<\/?[A-Za-z][A-Za-z0-9]*(\s[^>]*)?\/?>/;
41
42
  /** Any HTML comment, `<!--…-->`. */
42
43
  const HTML_COMMENT_RE = /<!--[\s\S]*?-->/;
43
- /**
44
- * A whole-line markspec directive comment: `<!-- markspec:<rest> -->`
45
- * occupying the line on its own (optional leading/trailing
46
- * whitespace). The directive form is the one exception spec §2.4.1
47
- * carves out from the "no raw HTML" rule.
48
- */
49
- const MARKSPEC_DIRECTIVE_LINE_RE = /^\s*<!--\s*markspec:[\s\S]*?-->\s*$/;
50
44
  /**
51
45
  * Return `true` when `line` contains raw HTML the body model forbids:
52
46
  * any tag, or any comment that isn't a standalone markspec directive.
@@ -54,7 +48,7 @@ const MARKSPEC_DIRECTIVE_LINE_RE = /^\s*<!--\s*markspec:[\s\S]*?-->\s*$/;
54
48
  function hasForbiddenHtml(line) {
55
49
  if (HTML_TAG_RE.test(line))
56
50
  return true;
57
- if (HTML_COMMENT_RE.test(line) && !MARKSPEC_DIRECTIVE_LINE_RE.test(line)) {
51
+ if (HTML_COMMENT_RE.test(line) && !(0, directives_js_1.isMarkspecDirectiveComment)(line)) {
58
52
  return true;
59
53
  }
60
54
  return false;
@@ -126,7 +120,7 @@ function violationsFromBlock(block) {
126
120
  else if (block.subkind === "html") {
127
121
  // Block-level HTML: check if it is a markspec directive (exempt)
128
122
  // or forbidden HTML. The `raw` field carries the verbatim source.
129
- if (!MARKSPEC_DIRECTIVE_LINE_RE.test(block.raw)) {
123
+ if (!(0, directives_js_1.isMarkspecDirectiveComment)(block.raw)) {
130
124
  out.push({ diag: RAW_HTML_DIAG, bodyLine });
131
125
  }
132
126
  }
@@ -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"}
@@ -17,6 +17,7 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.detectCorpusCollisions = detectCorpusCollisions;
19
19
  exports.attributeCorpusDiagnostics = attributeCorpusDiagnostics;
20
+ const mod_js_1 = require("../model/mod.js");
20
21
  /** Generic duplicate detectors superseded by MSL-R014 for corpus collisions. */
21
22
  const GENERIC_DUP_CODES = new Set([
22
23
  "MSL-R005",
@@ -50,8 +51,7 @@ function detectCorpusCollisions(allEntries) {
50
51
  code: "MSL-R014",
51
52
  severity: "error",
52
53
  message: `display ID '${e.displayId}' is already delivered by ` +
53
- `${displayOwner.origin.profileId}@` +
54
- `${displayOwner.origin.profileVersion}; rename this entry — ` +
54
+ `${(0, mod_js_1.formatEntryOrigin)(displayOwner.origin)}; rename this entry — ` +
55
55
  `delivered corpus entries are read-only`,
56
56
  location: e.location,
57
57
  });
@@ -64,8 +64,7 @@ function detectCorpusCollisions(allEntries) {
64
64
  code: "MSL-R014",
65
65
  severity: "error",
66
66
  message: `Id '${e.id}' is already delivered by ` +
67
- `${idOwner.origin.profileId}@` +
68
- `${idOwner.origin.profileVersion}; rename this entry — ` +
67
+ `${(0, mod_js_1.formatEntryOrigin)(idOwner.origin)}; rename this entry — ` +
69
68
  `delivered corpus entries are read-only`,
70
69
  location: e.location,
71
70
  });
@@ -86,8 +85,7 @@ function detectCorpusCollisions(allEntries) {
86
85
  code: "MSL-R014",
87
86
  severity: "error",
88
87
  message: `display ID '${e.displayId}' is already delivered by ` +
89
- `${displayOwner.origin.profileId}@` +
90
- `${displayOwner.origin.profileVersion}; delivered corpus ` +
88
+ `${(0, mod_js_1.formatEntryOrigin)(displayOwner.origin)}; delivered corpus ` +
91
89
  `entries are read-only`,
92
90
  location: e.location,
93
91
  });
@@ -101,8 +99,7 @@ function detectCorpusCollisions(allEntries) {
101
99
  code: "MSL-R014",
102
100
  severity: "error",
103
101
  message: `Id '${e.id}' is already delivered by ` +
104
- `${idOwner.origin.profileId}@` +
105
- `${idOwner.origin.profileVersion}; delivered corpus entries ` +
102
+ `${(0, mod_js_1.formatEntryOrigin)(idOwner.origin)}; delivered corpus entries ` +
106
103
  `are read-only`,
107
104
  location: e.location,
108
105
  });
@@ -115,14 +112,19 @@ function attributeCorpusDiagnostics(diagnostics, allEntries, collidedTokens) {
115
112
  const corpusFiles = new Map();
116
113
  for (const e of allEntries) {
117
114
  if (e.origin) {
118
- corpusFiles.set(e.location.file, `${e.origin.profileId}@${e.origin.profileVersion}`);
115
+ corpusFiles.set(e.location.file, (0, mod_js_1.formatEntryOrigin)(e.origin));
119
116
  }
120
117
  }
121
118
  const out = [];
122
119
  for (const d of diagnostics) {
123
- // Suppress the generic duplicate codes for corpus collisions; the
124
- // validator embeds the offending token in single quotes, which is what
125
- // this containment check keys on.
120
+ // Suppress the generic duplicate codes for a corpus collision (MSL-R014
121
+ // has already replaced them). This is a load-bearing coupling with the
122
+ // duplicate validators' message format: MSL-R005/R006/I007/I008 all embed
123
+ // the offending token wrapped in single quotes (`'<token>'`), and the
124
+ // containment check below keys on that exact `'${t}'` shape. If any of
125
+ // those producers stops single-quoting the token, the generic duplicate
126
+ // would leak through alongside the MSL-R014 — `corpus_test.ts` pins all
127
+ // four codes to this contract.
126
128
  if (GENERIC_DUP_CODES.has(d.code) &&
127
129
  [...collidedTokens].some((t) => d.message.includes(`'${t}'`))) {
128
130
  continue;