@leo-studio/leo-markup 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +20 -0
  2. package/dist/fence.d.ts +6 -1
  3. package/dist/fence.d.ts.map +1 -1
  4. package/dist/fence.js +27 -4
  5. package/dist/fence.js.map +1 -1
  6. package/dist/index.d.ts +1 -0
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +1 -0
  9. package/dist/index.js.map +1 -1
  10. package/dist/infra/index.d.ts +2 -0
  11. package/dist/infra/index.d.ts.map +1 -0
  12. package/dist/infra/index.js +2 -0
  13. package/dist/infra/index.js.map +1 -0
  14. package/dist/infra/infra-diagram.d.ts +150 -0
  15. package/dist/infra/infra-diagram.d.ts.map +1 -0
  16. package/dist/infra/infra-diagram.js +1373 -0
  17. package/dist/infra/infra-diagram.js.map +1 -0
  18. package/dist/infra/raster.d.ts +13 -0
  19. package/dist/infra/raster.d.ts.map +1 -0
  20. package/dist/infra/raster.js +46 -0
  21. package/dist/infra/raster.js.map +1 -0
  22. package/dist/infra/standalone-style.d.ts +5 -0
  23. package/dist/infra/standalone-style.d.ts.map +1 -0
  24. package/dist/infra/standalone-style.js +101 -0
  25. package/dist/infra/standalone-style.js.map +1 -0
  26. package/dist/product-spec.d.ts.map +1 -1
  27. package/dist/product-spec.js +8 -0
  28. package/dist/product-spec.js.map +1 -1
  29. package/dist/references.d.ts +74 -0
  30. package/dist/references.d.ts.map +1 -0
  31. package/dist/references.js +132 -0
  32. package/dist/references.js.map +1 -0
  33. package/dist/registry.d.ts.map +1 -1
  34. package/dist/registry.js +28 -3
  35. package/dist/registry.js.map +1 -1
  36. package/dist/scanner.d.ts.map +1 -1
  37. package/dist/scanner.js +4 -3
  38. package/dist/scanner.js.map +1 -1
  39. package/dist/schema/vocabulary.json +16 -5
  40. package/dist/vocabulary.d.ts +18 -4
  41. package/dist/vocabulary.d.ts.map +1 -1
  42. package/dist/vocabulary.js +78 -14
  43. package/dist/vocabulary.js.map +1 -1
  44. package/package.json +30 -5
package/README.md CHANGED
@@ -10,6 +10,26 @@ import { isIslandSpan, scan } from '@leo-studio/leo-markup';
10
10
  const islands = scan('Stability: <leo.badge value="Stable" />').filter(isIslandSpan);
11
11
  ```
12
12
 
13
+ ### Conversation references
14
+
15
+ `<leo.ref target="…">Label</leo.ref>` is an inline reference; without `relation`
16
+ it is neutral. `<leo.card target="…" />` is a block card. Both name a
17
+ `path/<repo-path>` or `repo/<repo-id>/<repo-path>` target with at most one
18
+ fragment: `#L<a>[-L<b>]`, `#<heading-slug>`, `#phase/<id>` or `#todo/<id>`
19
+ (plan files only). A target-backed card uses no `type`, `ref`, `path` or `href`.
20
+
21
+ ```typescript
22
+ import { scanConversationReferences } from '@leo-studio/leo-markup';
23
+
24
+ const { references, pendingFrom } = scanConversationReferences(message);
25
+ // references[i].destination → { path, canonical, document: 'plan', anchor: { kind: 'todo', id } }
26
+ ```
27
+
28
+ Tags in code spans, fences and comments stay text. `pendingFrom` marks an
29
+ unfinished trailing tag in a streamed message. Swift exposes the same contract
30
+ as `LeoConversationReferences.scan` and `LeoReferenceDestination.resolve`;
31
+ `fixtures/conversation-references.json` keeps both in agreement.
32
+
13
33
  ## Development
14
34
 
15
35
  ```sh
package/dist/fence.d.ts CHANGED
@@ -8,7 +8,12 @@ export interface FenceOpen {
8
8
  }
9
9
  /** Read a fenced-code opener at a physical line start (up to 3 spaces indented). */
10
10
  export declare function readFence(source: string, lineStart: number): FenceOpen | null;
11
+ /** Locate the content of a physical line and count its Markdown quote markers. */
12
+ export declare function quotedLine(source: string, lineStart: number): {
13
+ start: number;
14
+ depth: number;
15
+ };
11
16
  /** Find the byte immediately after a matching fenced-code closer. */
12
- export declare function findFenceEnd(source: string, from: number, marker: '`' | '~', length: number): number;
17
+ export declare function findFenceEnd(source: string, from: number, marker: '`' | '~', length: number, quoteDepth?: number): number;
13
18
  export declare function countRun(source: string, from: number, char: '`' | '~'): number;
14
19
  //# sourceMappingURL=fence.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fence.d.ts","sourceRoot":"","sources":["../src/fence.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAE9F,MAAM,WAAW,SAAS;IACtB,QAAQ,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,qDAAqD;IACrD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACzB;AAED,oFAAoF;AACpF,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAoB7E;AAED,qEAAqE;AACrE,wBAAgB,YAAY,CACxB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,GAAG,GAAG,GAAG,EACjB,MAAM,EAAE,MAAM,GACf,MAAM,CAsBR;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,GAAG,GAAG,MAAM,CAM9E"}
1
+ {"version":3,"file":"fence.d.ts","sourceRoot":"","sources":["../src/fence.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAE9F,MAAM,WAAW,SAAS;IACtB,QAAQ,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,qDAAqD;IACrD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACzB;AAED,oFAAoF;AACpF,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAoB7E;AAED,kFAAkF;AAClF,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAiB9F;AAED,qEAAqE;AACrE,wBAAgB,YAAY,CACxB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,GAAG,GAAG,GAAG,EACjB,MAAM,EAAE,MAAM,EACd,UAAU,SAAI,GACf,MAAM,CA0BR;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,GAAG,GAAG,MAAM,CAM9E"}
package/dist/fence.js CHANGED
@@ -21,16 +21,39 @@ export function readFence(source, lineStart) {
21
21
  info: source.slice(markerStart + length, lineEnd === -1 ? source.length : lineEnd).trim(),
22
22
  };
23
23
  }
24
+ /** Locate the content of a physical line and count its Markdown quote markers. */
25
+ export function quotedLine(source, lineStart) {
26
+ let start = lineStart;
27
+ let depth = 0;
28
+ while (true) {
29
+ let marker = start;
30
+ while (marker < start + 3 && source[marker] === ' ') {
31
+ marker++;
32
+ }
33
+ if (source[marker] !== '>') {
34
+ return { start, depth };
35
+ }
36
+ depth++;
37
+ start = marker + 1;
38
+ if (source[start] === ' ' || source[start] === '\t') {
39
+ start++;
40
+ }
41
+ }
42
+ }
24
43
  /** Find the byte immediately after a matching fenced-code closer. */
25
- export function findFenceEnd(source, from, marker, length) {
44
+ export function findFenceEnd(source, from, marker, length, quoteDepth = 0) {
26
45
  let lineStart = from;
27
46
  while (lineStart < source.length) {
28
- let markerStart = lineStart;
29
- while (markerStart < lineStart + 3 && source[markerStart] === ' ') {
47
+ const line = quoteDepth ? quotedLine(source, lineStart) : { start: lineStart, depth: 0 };
48
+ if (line.depth < quoteDepth) {
49
+ return lineStart;
50
+ }
51
+ let markerStart = line.start;
52
+ while (markerStart < line.start + 3 && source[markerStart] === ' ') {
30
53
  markerStart++;
31
54
  }
32
55
  const runLength = countRun(source, markerStart, marker);
33
- if (runLength >= length) {
56
+ if (line.depth === quoteDepth && runLength >= length) {
34
57
  const lineEnd = source.indexOf('\n', markerStart + runLength);
35
58
  const remainderEnd = lineEnd === -1 ? source.length : lineEnd;
36
59
  if (source.slice(markerStart + runLength, remainderEnd).trim() === '') {
package/dist/fence.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"fence.js","sourceRoot":"","sources":["../src/fence.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAU9F,oFAAoF;AACpF,MAAM,UAAU,SAAS,CAAC,MAAc,EAAE,SAAiB;IACvD,IAAI,WAAW,GAAG,SAAS,CAAC;IAC5B,OAAO,WAAW,GAAG,SAAS,GAAG,CAAC,IAAI,MAAM,CAAC,WAAW,CAAC,KAAK,GAAG,EAAE,CAAC;QAChE,WAAW,EAAE,CAAC;IAClB,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;IACnC,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;QACnC,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;IACrD,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;QACb,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,CAAC,CAAC;IAC3D,OAAO;QACH,MAAM;QACN,MAAM;QACN,YAAY,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC;QAC1D,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,WAAW,GAAG,MAAM,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC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D,OAAO,CAAC,CAAC,CAAC;AACd,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,MAAc,EAAE,IAAY,EAAE,IAAe;IAClE,IAAI,GAAG,GAAG,IAAI,CAAC;IACf,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;QAC1B,GAAG,EAAE,CAAC;IACV,CAAC;IACD,OAAO,GAAG,GAAG,IAAI,CAAC;AACtB,CAAC","sourcesContent":["/** CommonMark fenced-code delimiters, shared by the scanner and the fence-form projection. */\n\nexport interface FenceOpen {\n readonly marker: '`' | '~';\n readonly length: number;\n readonly contentStart: number;\n /** The trimmed info string after the opening run. */\n readonly info: string;\n}\n\n/** Read a fenced-code opener at a physical line start (up to 3 spaces indented). */\nexport function readFence(source: string, lineStart: number): FenceOpen | null {\n let markerStart = lineStart;\n while (markerStart < lineStart + 3 && source[markerStart] === ' ') {\n markerStart++;\n }\n const marker = source[markerStart];\n if (marker !== '`' && marker !== '~') {\n return null;\n }\n const length = countRun(source, markerStart, marker);\n if (length < 3) {\n return null;\n }\n const lineEnd = source.indexOf('\\n', markerStart + length);\n return {\n marker,\n length,\n contentStart: lineEnd === -1 ? source.length : lineEnd + 1,\n info: source.slice(markerStart + length, lineEnd === -1 ? source.length : lineEnd).trim(),\n };\n}\n\n/** Find the byte immediately after a matching fenced-code closer. */\nexport function findFenceEnd(\n source: string,\n from: number,\n marker: '`' | '~',\n length: number\n): number {\n let lineStart = from;\n while (lineStart < source.length) {\n let markerStart = lineStart;\n while (markerStart < lineStart + 3 && source[markerStart] === ' ') {\n markerStart++;\n }\n const runLength = countRun(source, markerStart, marker);\n if (runLength >= length) {\n const lineEnd = source.indexOf('\\n', markerStart + runLength);\n const remainderEnd = lineEnd === -1 ? source.length : lineEnd;\n if (source.slice(markerStart + runLength, remainderEnd).trim() === '') {\n return lineEnd === -1 ? source.length : lineEnd + 1;\n }\n }\n const nextLine = source.indexOf('\\n', lineStart);\n if (nextLine === -1) {\n return -1;\n }\n lineStart = nextLine + 1;\n }\n return -1;\n}\n\nexport function countRun(source: string, from: number, char: '`' | '~'): number {\n let end = from;\n while (source[end] === char) {\n end++;\n }\n return end - from;\n}\n"]}
1
+ {"version":3,"file":"fence.js","sourceRoot":"","sources":["../src/fence.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAU9F,oFAAoF;AACpF,MAAM,UAAU,SAAS,CAAC,MAAc,EAAE,SAAiB;IACvD,IAAI,WAAW,GAAG,SAAS,CAAC;IAC5B,OAAO,WAAW,GAAG,SAAS,GAAG,CAAC,IAAI,MAAM,CAAC,WAAW,CAAC,KAAK,GAAG,EAAE,CAAC;QAChE,WAAW,EAAE,CAAC;IAClB,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;IACnC,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;QACnC,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;IACrD,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;QACb,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,CAAC,CAAC;IAC3D,OAAO;QACH,MAAM;QACN,MAAM;QACN,YAAY,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC;QAC1D,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,WAAW,GAAG,MAAM,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE;KAC5F,CAAC;AACN,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,UAAU,CAAC,MAAc,E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;YACjE,WAAW,EAAE,CAAC;QAClB,CAAC;QACD,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;QACxD,IAAI,IAAI,CAAC,KAAK,KAAK,UAAU,IAAI,SAAS,IAAI,MAAM,EAAE,CAAC;YACnD,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,SAAS,CAAC,CAAC;YAC9D,MAAM,YAAY,GAAG,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;YAC9D,IAAI,MAAM,CAAC,KAAK,CAAC,WAAW,GAAG,SAAS,EAAE,YAAY,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;gBACpE,OAAO,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC;YACxD,CAAC;QACL,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QACjD,IAAI,QAAQ,KAAK,CAAC,CAAC,EAAE,CAAC;YAClB,OAAO,CAAC,CAAC,CAAC;QACd,CAAC;QACD,SAAS,GAAG,QAAQ,GAAG,CAAC,CAAC;IAC7B,CAAC;IACD,OAAO,CAAC,CAAC,CAAC;AACd,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,MAAc,EAAE,IAAY,EAAE,IAAe;IAClE,IAAI,GAAG,GAAG,IAAI,CAAC;IACf,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;QAC1B,GAAG,EAAE,CAAC;IACV,CAAC;IACD,OAAO,GAAG,GAAG,IAAI,CAAC;AACtB,CAAC","sourcesContent":["/** CommonMark fenced-code delimiters, shared by the scanner and the fence-form projection. */\n\nexport interface FenceOpen {\n readonly marker: '`' | '~';\n readonly length: number;\n readonly contentStart: number;\n /** The trimmed info string after the opening run. */\n readonly info: string;\n}\n\n/** Read a fenced-code opener at a physical line start (up to 3 spaces indented). */\nexport function readFence(source: string, lineStart: number): FenceOpen | null {\n let markerStart = lineStart;\n while (markerStart < lineStart + 3 && source[markerStart] === ' ') {\n markerStart++;\n }\n const marker = source[markerStart];\n if (marker !== '`' && marker !== '~') {\n return null;\n }\n const length = countRun(source, markerStart, marker);\n if (length < 3) {\n return null;\n }\n const lineEnd = source.indexOf('\\n', markerStart + length);\n return {\n marker,\n length,\n contentStart: lineEnd === -1 ? source.length : lineEnd + 1,\n info: source.slice(markerStart + length, lineEnd === -1 ? source.length : lineEnd).trim(),\n };\n}\n\n/** Locate the content of a physical line and count its Markdown quote markers. */\nexport function quotedLine(source: string, lineStart: number): { start: number; depth: number } {\n let start = lineStart;\n let depth = 0;\n while (true) {\n let marker = start;\n while (marker < start + 3 && source[marker] === ' ') {\n marker++;\n }\n if (source[marker] !== '>') {\n return { start, depth };\n }\n depth++;\n start = marker + 1;\n if (source[start] === ' ' || source[start] === '\\t') {\n start++;\n }\n }\n}\n\n/** Find the byte immediately after a matching fenced-code closer. */\nexport function findFenceEnd(\n source: string,\n from: number,\n marker: '`' | '~',\n length: number,\n quoteDepth = 0\n): number {\n let lineStart = from;\n while (lineStart < source.length) {\n const line = quoteDepth ? quotedLine(source, lineStart) : { start: lineStart, depth: 0 };\n if (line.depth < quoteDepth) {\n return lineStart;\n }\n let markerStart = line.start;\n while (markerStart < line.start + 3 && source[markerStart] === ' ') {\n markerStart++;\n }\n const runLength = countRun(source, markerStart, marker);\n if (line.depth === quoteDepth && runLength >= length) {\n const lineEnd = source.indexOf('\\n', markerStart + runLength);\n const remainderEnd = lineEnd === -1 ? source.length : lineEnd;\n if (source.slice(markerStart + runLength, remainderEnd).trim() === '') {\n return lineEnd === -1 ? source.length : lineEnd + 1;\n }\n }\n const nextLine = source.indexOf('\\n', lineStart);\n if (nextLine === -1) {\n return -1;\n }\n lineStart = nextLine + 1;\n }\n return -1;\n}\n\nexport function countRun(source: string, from: number, char: '`' | '~'): number {\n let end = from;\n while (source[end] === char) {\n end++;\n }\n return end - from;\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -12,6 +12,7 @@ export * from './authoring-lints.js';
12
12
  export * from './block-inline.js';
13
13
  export * from './parity.js';
14
14
  export * from './product-spec.js';
15
+ export * from './references.js';
15
16
  export * from './registry.js';
16
17
  export * from './scanner.js';
17
18
  export * from './tree-text.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC"}
package/dist/index.js CHANGED
@@ -12,6 +12,7 @@ export * from './authoring-lints.js';
12
12
  export * from './block-inline.js';
13
13
  export * from './parity.js';
14
14
  export * from './product-spec.js';
15
+ export * from './references.js';
15
16
  export * from './registry.js';
16
17
  export * from './scanner.js';
17
18
  export * from './tree-text.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC","sourcesContent":["/**\n * @leo-studio/leo-markup\n *\n * Pure-contract doc engine: the shared `<leo.*>` vocabulary, the island scanner,\n * the leo registry + canonical prop schemas, the block/inline body rule, the\n * PageContext type, and the parity test harness. No React, no ANSI — the web and\n * terminal emitters are injected by leo-doc-web and leo-pty-renderer.\n */\n\nexport * from './agent-support.js';\nexport * from './ast-json.js';\nexport * from './authoring-lints.js';\nexport * from './block-inline.js';\nexport * from './parity.js';\nexport * from './product-spec.js';\nexport * from './registry.js';\nexport * from './scanner.js';\nexport * from './tree-text.js';\nexport * from './types.js';\nexport * from './vocabulary.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC","sourcesContent":["/**\n * @leo-studio/leo-markup\n *\n * Pure-contract doc engine: the shared `<leo.*>` vocabulary, the island scanner,\n * the leo registry + canonical prop schemas, the block/inline body rule, the\n * PageContext type, and the parity test harness. No React, no ANSI — the web and\n * terminal emitters are injected by leo-doc-web and leo-pty-renderer.\n */\n\nexport * from './agent-support.js';\nexport * from './ast-json.js';\nexport * from './authoring-lints.js';\nexport * from './block-inline.js';\nexport * from './parity.js';\nexport * from './product-spec.js';\nexport * from './references.js';\nexport * from './registry.js';\nexport * from './scanner.js';\nexport * from './tree-text.js';\nexport * from './types.js';\nexport * from './vocabulary.js';\n"]}
@@ -0,0 +1,2 @@
1
+ export * from './infra-diagram.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/infra/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './infra-diagram.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/infra/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC","sourcesContent":["export * from './infra-diagram.js';\n"]}
@@ -0,0 +1,150 @@
1
+ /**
2
+ * Infrastructure diagrams from a Mermaid-style source.
3
+ *
4
+ * The author declares where things live (hosts, groups, and components on a
5
+ * column grid) and what talks to what (links). Placement follows the grid;
6
+ * width and gaps are minimums, expanded when routing or annotations need room.
7
+ * Links are routed orthogonally around components and titles, crossings get a
8
+ * halo, and every link gets a numbered badge. The output is a static SVG that
9
+ * the host-provided `.infra` styles theme.
10
+ *
11
+ * infra badges letters
12
+ * title "Inside one host"
13
+ * host app "App host" "always on" cols 2
14
+ * api[API | http · auth]:::wf
15
+ * db[Database | rows]:::cap
16
+ * end
17
+ * gh[GitHub | events]:::ext
18
+ * api -->|SQL| db
19
+ * api & db -->|HTTPS| gh :::ext
20
+ *
21
+ * Statements: `infra` header options (`width N`, `gap N`, `badges letters|numbers`),
22
+ * `title "…"`, `desc "…"`, containers `host id "Title" "sub"`, `group id "label"`,
23
+ * and frameless `grid`, each closed by `end`; components `id[Name | sub]:::plane`;
24
+ * `.` for an empty cell; links `a & b -->|label| c :::plane` (`<->` draws arrows at both ends,
25
+ * `---` draws an unlabelled bus line). Options: `cols N`, `span N`, `gap N`, `stack`, `bus`,
26
+ * `bus-right`, `h N`. `%%` starts a comment.
27
+ */
28
+ import { type InfraTheme } from './standalone-style.js';
29
+ export type { InfraTheme } from './standalone-style.js';
30
+ export type Plane = 'wf' | 'cap' | 'ses' | 'pol' | 'ext';
31
+ export interface Rect {
32
+ x: number;
33
+ y: number;
34
+ w: number;
35
+ h: number;
36
+ }
37
+ export interface CompNode {
38
+ kind: 'comp';
39
+ id: string;
40
+ name: string;
41
+ sub: string;
42
+ plane: Plane;
43
+ span: number;
44
+ stack: boolean;
45
+ h: number;
46
+ rect: Rect;
47
+ }
48
+ export interface EmptyNode {
49
+ kind: 'empty';
50
+ span: number;
51
+ rect: Rect;
52
+ }
53
+ export interface ContainerNode {
54
+ kind: 'host' | 'group' | 'grid';
55
+ id: string;
56
+ title: string;
57
+ sub: string;
58
+ plane: Plane;
59
+ cols: number;
60
+ span: number;
61
+ gap: number;
62
+ stack: boolean;
63
+ bus: '' | 'left' | 'right';
64
+ children: DiagramNode[];
65
+ rect: Rect;
66
+ }
67
+ export type DiagramNode = CompNode | EmptyNode | ContainerNode;
68
+ export interface LinkSpec {
69
+ sources: string[];
70
+ targets: string[];
71
+ label: string;
72
+ plane: Plane | null;
73
+ arrow: boolean;
74
+ bidirectional?: true;
75
+ }
76
+ export interface Diagram {
77
+ title: string;
78
+ desc: string;
79
+ width: number;
80
+ badges: 'numbers' | 'letters';
81
+ root: ContainerNode;
82
+ links: LinkSpec[];
83
+ }
84
+ export interface RoutedLink {
85
+ from: string;
86
+ to: string;
87
+ badge: string;
88
+ plane: Plane;
89
+ arrow: boolean;
90
+ bidirectional?: true;
91
+ halo: boolean;
92
+ label: string;
93
+ points: [number, number][];
94
+ }
95
+ interface Placed {
96
+ badges: {
97
+ x: number;
98
+ y: number;
99
+ text: string;
100
+ plane: Plane;
101
+ link: number;
102
+ }[];
103
+ labels: {
104
+ x: number;
105
+ y: number;
106
+ text: string;
107
+ anchor: 'start' | 'middle' | 'end';
108
+ rect: Rect;
109
+ link: number;
110
+ }[];
111
+ }
112
+ export declare function parseInfra(source: string): Diagram;
113
+ export interface InfraLayout {
114
+ width: number;
115
+ height: number;
116
+ comps: {
117
+ id: string;
118
+ rect: Rect;
119
+ }[];
120
+ titles: Rect[];
121
+ links: RoutedLink[];
122
+ badges: Placed['badges'];
123
+ labels: Placed['labels'];
124
+ }
125
+ /** Geometry for checks: where every component, link, badge, and label landed. */
126
+ export declare function layoutInfra(source: string): InfraLayout;
127
+ export interface InfraRenderOptions {
128
+ /** Embed scoped styles so the SVG can be displayed without host CSS. */
129
+ standalone?: {
130
+ theme: InfraTheme;
131
+ };
132
+ }
133
+ /**
134
+ * Render a diagram to SVG. `marks` highlights components, containers (by id),
135
+ * and links (by "from->to") for architecture diffs; see `diffInfra`.
136
+ */
137
+ export declare function renderInfra(source: string, idPrefix: string, marks?: Marks, options?: InfraRenderOptions): string;
138
+ export type DiffMark = 'added' | 'removed' | 'changed' | 'ghost';
139
+ export type Marks = Record<string, DiffMark>;
140
+ export interface InfraChange {
141
+ /** Component or container id, or "from->to" for a link. */
142
+ key: string;
143
+ kind: 'comp' | 'host' | 'group' | 'link';
144
+ status: 'added' | 'removed' | 'changed';
145
+ name: string;
146
+ details: string[];
147
+ }
148
+ /** What changed between two versions of a diagram, matched by id. */
149
+ export declare function diffInfra(before: string, after: string): InfraChange[];
150
+ //# sourceMappingURL=infra-diagram.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"infra-diagram.d.ts","sourceRoot":"","sources":["../../src/infra/infra-diagram.ts"],"names":[],"mappings":"AAAA;;;;;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