schematex 0.4.3 → 0.5.2

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 (98) hide show
  1. package/README.md +36 -7
  2. package/dist/ai/ai-sdk.cjs +19 -13
  3. package/dist/ai/ai-sdk.cjs.map +1 -1
  4. package/dist/ai/ai-sdk.d.cts +4 -3
  5. package/dist/ai/ai-sdk.d.ts +4 -3
  6. package/dist/ai/ai-sdk.js +15 -9
  7. package/dist/ai/ai-sdk.js.map +1 -1
  8. package/dist/ai/index.cjs +16 -12
  9. package/dist/ai/index.d.cts +20 -153
  10. package/dist/ai/index.d.ts +20 -153
  11. package/dist/ai/index.js +4 -4
  12. package/dist/api-C5SECOxZ.d.cts +69 -0
  13. package/dist/api-Cr_MxttI.d.ts +69 -0
  14. package/dist/browser.cjs +24 -6
  15. package/dist/browser.cjs.map +1 -1
  16. package/dist/browser.d.cts +12 -3
  17. package/dist/browser.d.ts +12 -3
  18. package/dist/browser.js +14 -6
  19. package/dist/browser.js.map +1 -1
  20. package/dist/{chunk-SMXU3KYA.cjs → chunk-4QPDZJAL.cjs} +6337 -120
  21. package/dist/chunk-4QPDZJAL.cjs.map +1 -0
  22. package/dist/{chunk-N3SLYVNW.cjs → chunk-HK56GQQP.cjs} +751 -80
  23. package/dist/chunk-HK56GQQP.cjs.map +1 -0
  24. package/dist/{chunk-KWQTF6ZL.js → chunk-OK5ZS3LU.js} +6330 -119
  25. package/dist/chunk-OK5ZS3LU.js.map +1 -0
  26. package/dist/{chunk-2Z543TC3.cjs → chunk-QMTWG6JL.cjs} +1297 -1151
  27. package/dist/chunk-QMTWG6JL.cjs.map +1 -0
  28. package/dist/{chunk-VITE3MZQ.cjs → chunk-QTNPMIO2.cjs} +99 -5
  29. package/dist/chunk-QTNPMIO2.cjs.map +1 -0
  30. package/dist/{chunk-6IGSKU6D.js → chunk-UFTYX73U.js} +99 -5
  31. package/dist/chunk-UFTYX73U.js.map +1 -0
  32. package/dist/{chunk-J7JWMQD5.js → chunk-VCH7RI5H.js} +1297 -1151
  33. package/dist/chunk-VCH7RI5H.js.map +1 -0
  34. package/dist/{chunk-UBTKM2TB.js → chunk-VKPCR7BG.js} +751 -81
  35. package/dist/chunk-VKPCR7BG.js.map +1 -0
  36. package/dist/diagrams/blockdiagram/index.d.cts +1 -1
  37. package/dist/diagrams/blockdiagram/index.d.ts +1 -1
  38. package/dist/diagrams/circuit/index.cjs +7 -7
  39. package/dist/diagrams/circuit/index.d.cts +1 -1
  40. package/dist/diagrams/circuit/index.d.ts +1 -1
  41. package/dist/diagrams/circuit/index.js +1 -1
  42. package/dist/diagrams/ecomap/index.d.cts +1 -1
  43. package/dist/diagrams/ecomap/index.d.ts +1 -1
  44. package/dist/diagrams/entity/index.d.cts +1 -1
  45. package/dist/diagrams/entity/index.d.ts +1 -1
  46. package/dist/diagrams/fishbone/index.d.cts +1 -1
  47. package/dist/diagrams/fishbone/index.d.ts +1 -1
  48. package/dist/diagrams/flowchart/index.cjs +7 -7
  49. package/dist/diagrams/flowchart/index.d.cts +2 -2
  50. package/dist/diagrams/flowchart/index.d.ts +2 -2
  51. package/dist/diagrams/flowchart/index.js +1 -1
  52. package/dist/diagrams/genogram/index.d.cts +1 -1
  53. package/dist/diagrams/genogram/index.d.ts +1 -1
  54. package/dist/diagrams/ladder/index.d.cts +1 -1
  55. package/dist/diagrams/ladder/index.d.ts +1 -1
  56. package/dist/diagrams/logic/index.d.cts +1 -1
  57. package/dist/diagrams/logic/index.d.ts +1 -1
  58. package/dist/diagrams/orgchart/index.d.cts +1 -1
  59. package/dist/diagrams/orgchart/index.d.ts +1 -1
  60. package/dist/diagrams/pedigree/index.d.cts +1 -1
  61. package/dist/diagrams/pedigree/index.d.ts +1 -1
  62. package/dist/diagrams/phylo/index.d.cts +1 -1
  63. package/dist/diagrams/phylo/index.d.ts +1 -1
  64. package/dist/diagrams/sld/index.d.cts +1 -1
  65. package/dist/diagrams/sld/index.d.ts +1 -1
  66. package/dist/diagrams/sociogram/index.d.cts +1 -1
  67. package/dist/diagrams/sociogram/index.d.ts +1 -1
  68. package/dist/diagrams/timing/index.d.cts +1 -1
  69. package/dist/diagrams/timing/index.d.ts +1 -1
  70. package/dist/diagrams/venn/index.d.cts +1 -1
  71. package/dist/diagrams/venn/index.d.ts +1 -1
  72. package/dist/{index-DYpJXJcy.d.cts → index-BD2yDfQM.d.cts} +1 -1
  73. package/dist/{index-BeUVaQiD.d.ts → index-C30zQWZI.d.ts} +1 -1
  74. package/dist/index.cjs +35 -11
  75. package/dist/index.d.cts +10 -4
  76. package/dist/index.d.ts +10 -4
  77. package/dist/index.js +3 -3
  78. package/dist/react.cjs +8 -10
  79. package/dist/react.cjs.map +1 -1
  80. package/dist/react.d.cts +3 -2
  81. package/dist/react.d.ts +3 -2
  82. package/dist/react.js +8 -10
  83. package/dist/react.js.map +1 -1
  84. package/dist/tools-BHWaJPOl.d.ts +153 -0
  85. package/dist/tools-DlpuE76u.d.cts +153 -0
  86. package/dist/{types-DKdo-Ua_.d.cts → types-WTr9W5Ud.d.cts} +3 -3
  87. package/dist/{types-DKdo-Ua_.d.ts → types-WTr9W5Ud.d.ts} +3 -3
  88. package/package.json +2 -2
  89. package/dist/api-BIj9t4Oc.d.cts +0 -22
  90. package/dist/api-BIj9t4Oc.d.ts +0 -22
  91. package/dist/chunk-2Z543TC3.cjs.map +0 -1
  92. package/dist/chunk-6IGSKU6D.js.map +0 -1
  93. package/dist/chunk-J7JWMQD5.js.map +0 -1
  94. package/dist/chunk-KWQTF6ZL.js.map +0 -1
  95. package/dist/chunk-N3SLYVNW.cjs.map +0 -1
  96. package/dist/chunk-SMXU3KYA.cjs.map +0 -1
  97. package/dist/chunk-UBTKM2TB.js.map +0 -1
  98. package/dist/chunk-VITE3MZQ.cjs.map +0 -1
package/dist/react.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { S as SchematexConfig } from './api-BIj9t4Oc.js';
2
+ import { S as SchematexConfig } from './api-Cr_MxttI.js';
3
+ import './types-WTr9W5Ud.js';
3
4
 
4
5
  interface SchematexDiagramProps {
5
6
  /** DSL text to render */
@@ -16,7 +17,7 @@ interface SchematexDiagramProps {
16
17
  className?: string;
17
18
  /** Inline style for the wrapper div */
18
19
  style?: React.CSSProperties;
19
- /** Called when render throws a parse/layout error */
20
+ /** Called when strict parsing/layout fails before the preview SVG fallback. */
20
21
  onError?: (error: Error) => void;
21
22
  }
22
23
  declare function SchematexDiagram({ dsl, type, theme, fontFamily, padding, className, style, onError, }: SchematexDiagramProps): react_jsx_runtime.JSX.Element;
package/dist/react.js CHANGED
@@ -1,6 +1,6 @@
1
- import { render } from './chunk-KWQTF6ZL.js';
1
+ import { renderResult } from './chunk-OK5ZS3LU.js';
2
2
  import './chunk-I55HO32M.js';
3
- import './chunk-J7JWMQD5.js';
3
+ import './chunk-VCH7RI5H.js';
4
4
  import './chunk-EPKIJEH7.js';
5
5
  import './chunk-IBRW3UOA.js';
6
6
  import './chunk-6OSUNBZY.js';
@@ -8,7 +8,7 @@ import './chunk-PIV2A3HG.js';
8
8
  import './chunk-SZK376QB.js';
9
9
  import './chunk-3M6T7KB4.js';
10
10
  import './chunk-L3CTXXVZ.js';
11
- import './chunk-6IGSKU6D.js';
11
+ import './chunk-UFTYX73U.js';
12
12
  import './chunk-VJGMEGMR.js';
13
13
  import './chunk-JHDR56XO.js';
14
14
  import './chunk-ZL5RB4UV.js';
@@ -35,20 +35,18 @@ function SchematexDiagram({
35
35
  onError
36
36
  }) {
37
37
  const svg = useMemo(() => {
38
- try {
39
- return render(dsl, { type, theme, fontFamily, padding });
40
- } catch (err) {
41
- const e = err instanceof Error ? err : new Error(String(err));
42
- onError?.(e);
43
- return null;
38
+ const result = renderResult(dsl, { type, theme, fontFamily, padding });
39
+ if (!result.ok) {
40
+ onError?.(new Error(result.diagnostics[0]?.message ?? "Schematex render failed"));
44
41
  }
42
+ return result.svg;
45
43
  }, [dsl, type, theme, fontFamily, padding]);
46
44
  return /* @__PURE__ */ jsx(
47
45
  "div",
48
46
  {
49
47
  className,
50
48
  style,
51
- dangerouslySetInnerHTML: { __html: svg ?? "" }
49
+ dangerouslySetInnerHTML: { __html: svg }
52
50
  }
53
51
  );
54
52
  }
package/dist/react.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/react.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAqCO,SAAS,gBAAA,CAAiB;AAAA,EAC/B,GAAA;AAAA,EACA,IAAA;AAAA,EACA,KAAA;AAAA,EACA,UAAA;AAAA,EACA,OAAA;AAAA,EACA,SAAA;AAAA,EACA,KAAA;AAAA,EACA;AACF,CAAA,EAA0B;AACxB,EAAA,MAAM,GAAA,GAAM,QAAQ,MAAM;AACxB,IAAA,IAAI;AACF,MAAA,OAAO,OAAO,GAAA,EAAK,EAAE,MAAM,KAAA,EAAO,UAAA,EAAY,SAAS,CAAA;AAAA,IACzD,SAAS,GAAA,EAAK;AACZ,MAAA,MAAM,CAAA,GAAI,eAAe,KAAA,GAAQ,GAAA,GAAM,IAAI,KAAA,CAAM,MAAA,CAAO,GAAG,CAAC,CAAA;AAC5D,MAAA,OAAA,GAAU,CAAC,CAAA;AACX,MAAA,OAAO,IAAA;AAAA,IACT;AAAA,EAEF,GAAG,CAAC,GAAA,EAAK,MAAM,KAAA,EAAO,UAAA,EAAY,OAAO,CAAC,CAAA;AAE1C,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,SAAA;AAAA,MACA,KAAA;AAAA,MAEA,uBAAA,EAAyB,EAAE,MAAA,EAAQ,GAAA,IAAO,EAAA;AAAG;AAAA,GAC/C;AAEJ","file":"react.js","sourcesContent":["/**\n * React component for Schematex diagrams.\n *\n * @example\n * ```tsx\n * import { SchematexDiagram } from 'schematex/react';\n *\n * <SchematexDiagram\n * dsl=\"genogram\\n alice [female]\"\n * theme=\"monochrome\"\n * className=\"my-diagram\"\n * />\n * ```\n */\n\nimport { useMemo } from \"react\";\nimport { render, type SchematexConfig } from \"./core/api\";\n\nexport interface SchematexDiagramProps {\n /** DSL text to render */\n dsl: string;\n /** Diagram type override (auto-detected from DSL if omitted) */\n type?: SchematexConfig[\"type\"];\n /** Theme name: 'default' | 'monochrome' | 'dark' */\n theme?: string;\n /** Font family override */\n fontFamily?: string;\n /** Canvas padding in px */\n padding?: number;\n /** className for the wrapper div */\n className?: string;\n /** Inline style for the wrapper div */\n style?: React.CSSProperties;\n /** Called when render throws a parse/layout error */\n onError?: (error: Error) => void;\n}\n\nexport function SchematexDiagram({\n dsl,\n type,\n theme,\n fontFamily,\n padding,\n className,\n style,\n onError,\n}: SchematexDiagramProps) {\n const svg = useMemo(() => {\n try {\n return render(dsl, { type, theme, fontFamily, padding });\n } catch (err) {\n const e = err instanceof Error ? err : new Error(String(err));\n onError?.(e);\n return null;\n }\n // onError excluded — a fresh callback shouldn't bust the memo.\n }, [dsl, type, theme, fontFamily, padding]);\n\n return (\n <div\n className={className}\n style={style}\n // SVG is generated by our own renderer — safe\n dangerouslySetInnerHTML={{ __html: svg ?? \"\" }}\n />\n );\n}\n"]}
1
+ {"version":3,"sources":["../src/react.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAqCO,SAAS,gBAAA,CAAiB;AAAA,EAC/B,GAAA;AAAA,EACA,IAAA;AAAA,EACA,KAAA;AAAA,EACA,UAAA;AAAA,EACA,OAAA;AAAA,EACA,SAAA;AAAA,EACA,KAAA;AAAA,EACA;AACF,CAAA,EAA0B;AACxB,EAAA,MAAM,GAAA,GAAM,QAAQ,MAAM;AACxB,IAAA,MAAM,MAAA,GAAS,aAAa,GAAA,EAAK,EAAE,MAAM,KAAA,EAAO,UAAA,EAAY,SAAS,CAAA;AACrE,IAAA,IAAI,CAAC,OAAO,EAAA,EAAI;AACd,MAAA,OAAA,GAAU,IAAI,MAAM,MAAA,CAAO,WAAA,CAAY,CAAC,CAAA,EAAG,OAAA,IAAW,yBAAyB,CAAC,CAAA;AAAA,IAClF;AACA,IAAA,OAAO,MAAA,CAAO,GAAA;AAAA,EAEhB,GAAG,CAAC,GAAA,EAAK,MAAM,KAAA,EAAO,UAAA,EAAY,OAAO,CAAC,CAAA;AAE1C,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,SAAA;AAAA,MACA,KAAA;AAAA,MAEA,uBAAA,EAAyB,EAAE,MAAA,EAAQ,GAAA;AAAI;AAAA,GACzC;AAEJ","file":"react.js","sourcesContent":["/**\n * React component for Schematex diagrams.\n *\n * @example\n * ```tsx\n * import { SchematexDiagram } from 'schematex/react';\n *\n * <SchematexDiagram\n * dsl=\"genogram\\n alice [female]\"\n * theme=\"monochrome\"\n * className=\"my-diagram\"\n * />\n * ```\n */\n\nimport { useMemo } from \"react\";\nimport { renderResult, type SchematexConfig } from \"./core/api\";\n\nexport interface SchematexDiagramProps {\n /** DSL text to render */\n dsl: string;\n /** Diagram type override (auto-detected from DSL if omitted) */\n type?: SchematexConfig[\"type\"];\n /** Theme name: 'default' | 'monochrome' | 'dark' */\n theme?: string;\n /** Font family override */\n fontFamily?: string;\n /** Canvas padding in px */\n padding?: number;\n /** className for the wrapper div */\n className?: string;\n /** Inline style for the wrapper div */\n style?: React.CSSProperties;\n /** Called when strict parsing/layout fails before the preview SVG fallback. */\n onError?: (error: Error) => void;\n}\n\nexport function SchematexDiagram({\n dsl,\n type,\n theme,\n fontFamily,\n padding,\n className,\n style,\n onError,\n}: SchematexDiagramProps) {\n const svg = useMemo(() => {\n const result = renderResult(dsl, { type, theme, fontFamily, padding });\n if (!result.ok) {\n onError?.(new Error(result.diagnostics[0]?.message ?? \"Schematex render failed\"));\n }\n return result.svg;\n // onError excluded — a fresh callback shouldn't bust the memo.\n }, [dsl, type, theme, fontFamily, padding]);\n\n return (\n <div\n className={className}\n style={style}\n // SVG is generated by our own renderer — safe\n dangerouslySetInnerHTML={{ __html: svg }}\n />\n );\n}\n"]}
@@ -0,0 +1,153 @@
1
+ import { S as SchematexConfig } from './api-Cr_MxttI.js';
2
+ import { q as DiagramType } from './types-WTr9W5Ud.js';
3
+
4
+ /**
5
+ * Diagram registry — metadata for every diagram type Schematex supports.
6
+ *
7
+ * This is the index an LLM sees when calling `listDiagrams()`. Descriptions
8
+ * are tuned to help the model pick the right type for a user request.
9
+ */
10
+
11
+ type DiagramCluster = "relationships" | "electrical-industrial" | "corporate-legal" | "causality-analysis" | "generic" | "strategy" | "knowledge" | "behavior-modeling" | "research" | "project-management";
12
+ interface DiagramMeta {
13
+ /** Canonical type id — matches `DiagramType` and plugin keys. */
14
+ type: DiagramType;
15
+ /** Human-readable name. */
16
+ name: string;
17
+ /** One-sentence tagline. */
18
+ tagline: string;
19
+ /** When should an LLM pick this diagram? Written in "use X when …" form. */
20
+ useWhen: string;
21
+ /** Domain cluster for grouping. */
22
+ cluster: DiagramCluster;
23
+ /** Published standard the parser and layout follow. */
24
+ standard: string;
25
+ /** Path to the syntax doc key in the generated content bundle. */
26
+ syntaxKey: string;
27
+ }
28
+ declare const DIAGRAM_REGISTRY: readonly DiagramMeta[];
29
+ declare function resolveDiagramType(type: string): DiagramType | undefined;
30
+ declare function getDiagramMeta(type: string): DiagramMeta | undefined;
31
+ declare function getAllDiagramTypes(): DiagramType[];
32
+
33
+ /** Structured error type returned by the AI tool layer. */
34
+ interface SchematexValidationError {
35
+ /** 1-based line number where the error occurred, if the parser reported it. */
36
+ line?: number;
37
+ /** 1-based column, if reported. */
38
+ column?: number;
39
+ /** Source snippet from the offending line, if the parser captured it. */
40
+ source?: string;
41
+ /** Human-readable error message. */
42
+ message: string;
43
+ /** Optional remediation hint. */
44
+ hint?: string;
45
+ }
46
+
47
+ /**
48
+ * AUTO-GENERATED by scripts/build-ai-content.mjs — do not edit by hand.
49
+ * Regenerate with: npm run build:ai
50
+ *
51
+ * Compiled content bundle for the AI tool layer. Keeps MDX content
52
+ * available to the published npm package without runtime fs access.
53
+ */
54
+ interface GeneratedExample {
55
+ slug: string;
56
+ diagram: string;
57
+ title: string;
58
+ description: string;
59
+ standard: string;
60
+ tags: readonly string[];
61
+ complexity: number;
62
+ featured: boolean;
63
+ dsl: string;
64
+ notes: string;
65
+ }
66
+
67
+ /**
68
+ * Example library — runtime lookup over the bundled MDX examples.
69
+ */
70
+
71
+ type Example = GeneratedExample;
72
+ interface GetExamplesOptions {
73
+ /** Maximum number of examples to return. Default 5. */
74
+ limit?: number;
75
+ /** Prefer examples marked `featured: true` when set. */
76
+ preferFeatured?: boolean;
77
+ /** Maximum complexity (1–5). */
78
+ maxComplexity?: number;
79
+ }
80
+
81
+ /**
82
+ * Syntax lookup — LLM-facing per-diagram grammar reference.
83
+ *
84
+ * The default "canonical" view stays intentionally narrow for first-shot
85
+ * generation. The "reference" view preserves the fuller stripped-MDX docs
86
+ * when a caller needs advanced syntax or adapter coverage.
87
+ */
88
+
89
+ type SyntaxDetail = "canonical" | "reference";
90
+ interface SyntaxDoc {
91
+ key: string;
92
+ title: string;
93
+ detail: SyntaxDetail;
94
+ content: string;
95
+ }
96
+
97
+ /**
98
+ * AI-facing tool functions — the five tools an LLM uses to work with Schematex.
99
+ *
100
+ * Pure TypeScript, zero framework deps. Both the Vercel AI SDK adapter
101
+ * (ai-sdk.ts) and the MCP server wrap these functions.
102
+ */
103
+
104
+ interface DiagramListItem {
105
+ type: string;
106
+ name: string;
107
+ tagline: string;
108
+ useWhen: string;
109
+ cluster: DiagramMeta["cluster"];
110
+ standard: string;
111
+ }
112
+ declare function listDiagrams(): DiagramListItem[];
113
+ interface GetSyntaxResult {
114
+ type: string;
115
+ name: string;
116
+ standard: string;
117
+ syntax: SyntaxDoc;
118
+ }
119
+ interface GetSyntaxOptions {
120
+ /** `canonical` is the compact first-shot generation surface. */
121
+ detail?: SyntaxDetail;
122
+ }
123
+ declare function getSyntax(type: string, opts?: GetSyntaxOptions): GetSyntaxResult;
124
+ interface GetExamplesResult {
125
+ type: string;
126
+ count: number;
127
+ examples: Example[];
128
+ }
129
+ declare function getExamples(type: string, opts?: GetExamplesOptions): GetExamplesResult;
130
+ type ValidateDslResult = {
131
+ ok: true;
132
+ type: string | null;
133
+ } | {
134
+ ok: false;
135
+ type: string | null;
136
+ errors: SchematexValidationError[];
137
+ };
138
+ declare function validateDsl(type: string | undefined, dsl: string): ValidateDslResult;
139
+ type RenderDslResult = {
140
+ ok: true;
141
+ status: "valid" | "partial";
142
+ type: string | null;
143
+ svg: string;
144
+ } | {
145
+ ok: false;
146
+ status: "invalid";
147
+ type: string | null;
148
+ svg: string;
149
+ errors: SchematexValidationError[];
150
+ };
151
+ declare function renderDsl(type: string | undefined, dsl: string, options?: Omit<SchematexConfig, "type">): RenderDslResult;
152
+
153
+ export { DIAGRAM_REGISTRY as D, type Example as E, type GetExamplesOptions as G, type RenderDslResult as R, type SchematexValidationError as S, type ValidateDslResult as V, type DiagramCluster as a, type DiagramListItem as b, type DiagramMeta as c, type GetExamplesResult as d, type GetSyntaxOptions as e, type GetSyntaxResult as f, type SyntaxDetail as g, type SyntaxDoc as h, getAllDiagramTypes as i, getDiagramMeta as j, getExamples as k, getSyntax as l, listDiagrams as m, resolveDiagramType as n, renderDsl as r, validateDsl as v };
@@ -0,0 +1,153 @@
1
+ import { S as SchematexConfig } from './api-C5SECOxZ.cjs';
2
+ import { q as DiagramType } from './types-WTr9W5Ud.cjs';
3
+
4
+ /**
5
+ * Diagram registry — metadata for every diagram type Schematex supports.
6
+ *
7
+ * This is the index an LLM sees when calling `listDiagrams()`. Descriptions
8
+ * are tuned to help the model pick the right type for a user request.
9
+ */
10
+
11
+ type DiagramCluster = "relationships" | "electrical-industrial" | "corporate-legal" | "causality-analysis" | "generic" | "strategy" | "knowledge" | "behavior-modeling" | "research" | "project-management";
12
+ interface DiagramMeta {
13
+ /** Canonical type id — matches `DiagramType` and plugin keys. */
14
+ type: DiagramType;
15
+ /** Human-readable name. */
16
+ name: string;
17
+ /** One-sentence tagline. */
18
+ tagline: string;
19
+ /** When should an LLM pick this diagram? Written in "use X when …" form. */
20
+ useWhen: string;
21
+ /** Domain cluster for grouping. */
22
+ cluster: DiagramCluster;
23
+ /** Published standard the parser and layout follow. */
24
+ standard: string;
25
+ /** Path to the syntax doc key in the generated content bundle. */
26
+ syntaxKey: string;
27
+ }
28
+ declare const DIAGRAM_REGISTRY: readonly DiagramMeta[];
29
+ declare function resolveDiagramType(type: string): DiagramType | undefined;
30
+ declare function getDiagramMeta(type: string): DiagramMeta | undefined;
31
+ declare function getAllDiagramTypes(): DiagramType[];
32
+
33
+ /** Structured error type returned by the AI tool layer. */
34
+ interface SchematexValidationError {
35
+ /** 1-based line number where the error occurred, if the parser reported it. */
36
+ line?: number;
37
+ /** 1-based column, if reported. */
38
+ column?: number;
39
+ /** Source snippet from the offending line, if the parser captured it. */
40
+ source?: string;
41
+ /** Human-readable error message. */
42
+ message: string;
43
+ /** Optional remediation hint. */
44
+ hint?: string;
45
+ }
46
+
47
+ /**
48
+ * AUTO-GENERATED by scripts/build-ai-content.mjs — do not edit by hand.
49
+ * Regenerate with: npm run build:ai
50
+ *
51
+ * Compiled content bundle for the AI tool layer. Keeps MDX content
52
+ * available to the published npm package without runtime fs access.
53
+ */
54
+ interface GeneratedExample {
55
+ slug: string;
56
+ diagram: string;
57
+ title: string;
58
+ description: string;
59
+ standard: string;
60
+ tags: readonly string[];
61
+ complexity: number;
62
+ featured: boolean;
63
+ dsl: string;
64
+ notes: string;
65
+ }
66
+
67
+ /**
68
+ * Example library — runtime lookup over the bundled MDX examples.
69
+ */
70
+
71
+ type Example = GeneratedExample;
72
+ interface GetExamplesOptions {
73
+ /** Maximum number of examples to return. Default 5. */
74
+ limit?: number;
75
+ /** Prefer examples marked `featured: true` when set. */
76
+ preferFeatured?: boolean;
77
+ /** Maximum complexity (1–5). */
78
+ maxComplexity?: number;
79
+ }
80
+
81
+ /**
82
+ * Syntax lookup — LLM-facing per-diagram grammar reference.
83
+ *
84
+ * The default "canonical" view stays intentionally narrow for first-shot
85
+ * generation. The "reference" view preserves the fuller stripped-MDX docs
86
+ * when a caller needs advanced syntax or adapter coverage.
87
+ */
88
+
89
+ type SyntaxDetail = "canonical" | "reference";
90
+ interface SyntaxDoc {
91
+ key: string;
92
+ title: string;
93
+ detail: SyntaxDetail;
94
+ content: string;
95
+ }
96
+
97
+ /**
98
+ * AI-facing tool functions — the five tools an LLM uses to work with Schematex.
99
+ *
100
+ * Pure TypeScript, zero framework deps. Both the Vercel AI SDK adapter
101
+ * (ai-sdk.ts) and the MCP server wrap these functions.
102
+ */
103
+
104
+ interface DiagramListItem {
105
+ type: string;
106
+ name: string;
107
+ tagline: string;
108
+ useWhen: string;
109
+ cluster: DiagramMeta["cluster"];
110
+ standard: string;
111
+ }
112
+ declare function listDiagrams(): DiagramListItem[];
113
+ interface GetSyntaxResult {
114
+ type: string;
115
+ name: string;
116
+ standard: string;
117
+ syntax: SyntaxDoc;
118
+ }
119
+ interface GetSyntaxOptions {
120
+ /** `canonical` is the compact first-shot generation surface. */
121
+ detail?: SyntaxDetail;
122
+ }
123
+ declare function getSyntax(type: string, opts?: GetSyntaxOptions): GetSyntaxResult;
124
+ interface GetExamplesResult {
125
+ type: string;
126
+ count: number;
127
+ examples: Example[];
128
+ }
129
+ declare function getExamples(type: string, opts?: GetExamplesOptions): GetExamplesResult;
130
+ type ValidateDslResult = {
131
+ ok: true;
132
+ type: string | null;
133
+ } | {
134
+ ok: false;
135
+ type: string | null;
136
+ errors: SchematexValidationError[];
137
+ };
138
+ declare function validateDsl(type: string | undefined, dsl: string): ValidateDslResult;
139
+ type RenderDslResult = {
140
+ ok: true;
141
+ status: "valid" | "partial";
142
+ type: string | null;
143
+ svg: string;
144
+ } | {
145
+ ok: false;
146
+ status: "invalid";
147
+ type: string | null;
148
+ svg: string;
149
+ errors: SchematexValidationError[];
150
+ };
151
+ declare function renderDsl(type: string | undefined, dsl: string, options?: Omit<SchematexConfig, "type">): RenderDslResult;
152
+
153
+ export { DIAGRAM_REGISTRY as D, type Example as E, type GetExamplesOptions as G, type RenderDslResult as R, type SchematexValidationError as S, type ValidateDslResult as V, type DiagramCluster as a, type DiagramListItem as b, type DiagramMeta as c, type GetExamplesResult as d, type GetSyntaxOptions as e, type GetSyntaxResult as f, type SyntaxDetail as g, type SyntaxDoc as h, getAllDiagramTypes as i, getDiagramMeta as j, getExamples as k, getSyntax as l, listDiagrams as m, resolveDiagramType as n, renderDsl as r, validateDsl as v };
@@ -8,7 +8,7 @@
8
8
  * - Layout: DiagramAST → LayoutResult
9
9
  * - Renderer: LayoutResult → SVG string
10
10
  */
11
- type DiagramType = "genogram" | "ecomap" | "pedigree" | "phylo" | "sociogram" | "timing" | "logic" | "circuit" | "blockdiagram" | "ladder" | "sld" | "entity" | "fishbone" | "venn" | "flowchart" | "mindmap" | "matrix" | "orgchart" | "decisiontree" | "timeline" | "state" | "pid" | "erd" | "breadboard" | "bpmn" | "fbd" | "sfc";
11
+ type DiagramType = "genogram" | "ecomap" | "pedigree" | "phylo" | "sociogram" | "timing" | "logic" | "circuit" | "blockdiagram" | "ladder" | "sld" | "entity" | "fishbone" | "venn" | "flowchart" | "mindmap" | "matrix" | "orgchart" | "decisiontree" | "timeline" | "state" | "pid" | "erd" | "breadboard" | "bpmn" | "fbd" | "sfc" | "prisma" | "usecase" | "pert" | "sequence";
12
12
  type GenogramMode = "medical" | "heritage";
13
13
  /**
14
14
  * Standard legend positions:
@@ -410,7 +410,7 @@ interface LogicGateAST {
410
410
  /** Non-fatal parser warnings (e.g. signals auto-declared as inputs). */
411
411
  warnings?: string[];
412
412
  }
413
- type CircuitComponentType = "resistor" | "potentiometer" | "rheostat" | "thermistor_ntc" | "thermistor_ptc" | "ldr" | "varistor" | "fuse" | "fuse_slow" | "capacitor" | "electrolytic_cap" | "variable_cap" | "inductor" | "inductor_iron" | "inductor_ferrite" | "variable_inductor" | "ferrite_bead" | "crystal" | "transformer" | "diode" | "zener" | "schottky" | "led" | "photodiode" | "varactor" | "tvs_diode" | "bridge_rectifier" | "npn" | "pnp" | "darlington_npn" | "darlington_pnp" | "nmos" | "pmos" | "nmos_depletion" | "jfet_n" | "jfet_p" | "igbt" | "scr" | "triac" | "diac" | "phototransistor" | "optocoupler" | "opamp" | "comparator" | "schmitt_buffer" | "tri_state_buffer" | "instrumentation_amp" | "generic_ic" | "voltage_regulator" | "dc_dc_converter" | "555_timer" | "terminal_block" | "voltage_source" | "current_source" | "ac_source" | "battery" | "vcc" | "ground" | "gnd_signal" | "gnd_chassis" | "gnd_digital" | "switch_spst" | "switch_spdt" | "switch_dpdt" | "push_no" | "push_nc" | "relay_coil" | "relay_no" | "relay_nc" | "motor" | "speaker" | "microphone" | "buzzer" | "ammeter" | "voltmeter" | "wattmeter" | "oscilloscope" | "wire" | "dot" | "label" | "port" | "test_point" | "no_connect" | "antenna";
413
+ type CircuitComponentType = "resistor" | "potentiometer" | "rheostat" | "thermistor_ntc" | "thermistor_ptc" | "ldr" | "varistor" | "fuse" | "fuse_slow" | "capacitor" | "electrolytic_cap" | "variable_cap" | "inductor" | "inductor_iron" | "inductor_ferrite" | "variable_inductor" | "ferrite_bead" | "crystal" | "transformer" | "diode" | "zener" | "schottky" | "led" | "photodiode" | "varactor" | "tvs_diode" | "bridge_rectifier" | "npn" | "pnp" | "darlington_npn" | "darlington_pnp" | "nmos" | "pmos" | "nmos_depletion" | "jfet_n" | "jfet_p" | "igbt" | "scr" | "triac" | "diac" | "phototransistor" | "optocoupler" | "opamp" | "comparator" | "schmitt_buffer" | "tri_state_buffer" | "instrumentation_amp" | "generic_ic" | "voltage_regulator" | "dc_dc_converter" | "555_timer" | "terminal_block" | "voltage_source" | "current_source" | "ac_source" | "battery" | "vcc" | "ground" | "gnd_signal" | "gnd_chassis" | "gnd_digital" | "switch_spst" | "switch_spdt" | "switch_dpdt" | "push_no" | "push_nc" | "relay_coil" | "relay_no" | "relay_nc" | "contactor" | "solenoid_valve" | "thermal_overload" | "disconnect_switch" | "motor" | "speaker" | "microphone" | "buzzer" | "ammeter" | "voltmeter" | "wattmeter" | "oscilloscope" | "wire" | "dot" | "label" | "port" | "test_point" | "no_connect" | "antenna";
414
414
  type CircuitDirection = "right" | "left" | "up" | "down";
415
415
  interface CircuitComponent {
416
416
  id: string;
@@ -823,4 +823,4 @@ interface FlowchartLayoutResult {
823
823
  clusters: FlowchartLayoutCluster[];
824
824
  }
825
825
 
826
- export type { BlockAST as B, CircuitAST as C, DiagramPlugin as D, EntityAST as E, FishboneAST as F, Individual as I, LayoutConfig as L, PhyloTreeAST as P, RenderConfig as R, SLDAST as S, TimingAST as T, VennAST as V, DiagramAST as a, LayoutResult as b, PhyloLayoutNode as c, LegendOverrides as d, LadderAST as e, LadderRung as f, LadderElement as g, SLDNode as h, SLDNodeType as i, EntityNode as j, EntityEdge as k, VennLayoutResult as l, LogicGateAST as m, FlowchartAST as n, FlowchartLayoutResult as o, CircuitComponent as p, DiagramType as q };
826
+ export type { BlockAST as B, CircuitAST as C, DiagramPlugin as D, EntityAST as E, FishboneAST as F, Individual as I, LayoutConfig as L, PhyloTreeAST as P, RenderConfig as R, SLDAST as S, TimingAST as T, VennAST as V, DiagramAST as a, LayoutResult as b, PhyloLayoutNode as c, LegendOverrides as d, LogicGateAST as e, CircuitComponent as f, LadderAST as g, LadderRung as h, LadderElement as i, SLDNode as j, SLDNodeType as k, EntityNode as l, EntityEdge as m, VennLayoutResult as n, FlowchartAST as o, FlowchartLayoutResult as p, DiagramType as q };
@@ -8,7 +8,7 @@
8
8
  * - Layout: DiagramAST → LayoutResult
9
9
  * - Renderer: LayoutResult → SVG string
10
10
  */
11
- type DiagramType = "genogram" | "ecomap" | "pedigree" | "phylo" | "sociogram" | "timing" | "logic" | "circuit" | "blockdiagram" | "ladder" | "sld" | "entity" | "fishbone" | "venn" | "flowchart" | "mindmap" | "matrix" | "orgchart" | "decisiontree" | "timeline" | "state" | "pid" | "erd" | "breadboard" | "bpmn" | "fbd" | "sfc";
11
+ type DiagramType = "genogram" | "ecomap" | "pedigree" | "phylo" | "sociogram" | "timing" | "logic" | "circuit" | "blockdiagram" | "ladder" | "sld" | "entity" | "fishbone" | "venn" | "flowchart" | "mindmap" | "matrix" | "orgchart" | "decisiontree" | "timeline" | "state" | "pid" | "erd" | "breadboard" | "bpmn" | "fbd" | "sfc" | "prisma" | "usecase" | "pert" | "sequence";
12
12
  type GenogramMode = "medical" | "heritage";
13
13
  /**
14
14
  * Standard legend positions:
@@ -410,7 +410,7 @@ interface LogicGateAST {
410
410
  /** Non-fatal parser warnings (e.g. signals auto-declared as inputs). */
411
411
  warnings?: string[];
412
412
  }
413
- type CircuitComponentType = "resistor" | "potentiometer" | "rheostat" | "thermistor_ntc" | "thermistor_ptc" | "ldr" | "varistor" | "fuse" | "fuse_slow" | "capacitor" | "electrolytic_cap" | "variable_cap" | "inductor" | "inductor_iron" | "inductor_ferrite" | "variable_inductor" | "ferrite_bead" | "crystal" | "transformer" | "diode" | "zener" | "schottky" | "led" | "photodiode" | "varactor" | "tvs_diode" | "bridge_rectifier" | "npn" | "pnp" | "darlington_npn" | "darlington_pnp" | "nmos" | "pmos" | "nmos_depletion" | "jfet_n" | "jfet_p" | "igbt" | "scr" | "triac" | "diac" | "phototransistor" | "optocoupler" | "opamp" | "comparator" | "schmitt_buffer" | "tri_state_buffer" | "instrumentation_amp" | "generic_ic" | "voltage_regulator" | "dc_dc_converter" | "555_timer" | "terminal_block" | "voltage_source" | "current_source" | "ac_source" | "battery" | "vcc" | "ground" | "gnd_signal" | "gnd_chassis" | "gnd_digital" | "switch_spst" | "switch_spdt" | "switch_dpdt" | "push_no" | "push_nc" | "relay_coil" | "relay_no" | "relay_nc" | "motor" | "speaker" | "microphone" | "buzzer" | "ammeter" | "voltmeter" | "wattmeter" | "oscilloscope" | "wire" | "dot" | "label" | "port" | "test_point" | "no_connect" | "antenna";
413
+ type CircuitComponentType = "resistor" | "potentiometer" | "rheostat" | "thermistor_ntc" | "thermistor_ptc" | "ldr" | "varistor" | "fuse" | "fuse_slow" | "capacitor" | "electrolytic_cap" | "variable_cap" | "inductor" | "inductor_iron" | "inductor_ferrite" | "variable_inductor" | "ferrite_bead" | "crystal" | "transformer" | "diode" | "zener" | "schottky" | "led" | "photodiode" | "varactor" | "tvs_diode" | "bridge_rectifier" | "npn" | "pnp" | "darlington_npn" | "darlington_pnp" | "nmos" | "pmos" | "nmos_depletion" | "jfet_n" | "jfet_p" | "igbt" | "scr" | "triac" | "diac" | "phototransistor" | "optocoupler" | "opamp" | "comparator" | "schmitt_buffer" | "tri_state_buffer" | "instrumentation_amp" | "generic_ic" | "voltage_regulator" | "dc_dc_converter" | "555_timer" | "terminal_block" | "voltage_source" | "current_source" | "ac_source" | "battery" | "vcc" | "ground" | "gnd_signal" | "gnd_chassis" | "gnd_digital" | "switch_spst" | "switch_spdt" | "switch_dpdt" | "push_no" | "push_nc" | "relay_coil" | "relay_no" | "relay_nc" | "contactor" | "solenoid_valve" | "thermal_overload" | "disconnect_switch" | "motor" | "speaker" | "microphone" | "buzzer" | "ammeter" | "voltmeter" | "wattmeter" | "oscilloscope" | "wire" | "dot" | "label" | "port" | "test_point" | "no_connect" | "antenna";
414
414
  type CircuitDirection = "right" | "left" | "up" | "down";
415
415
  interface CircuitComponent {
416
416
  id: string;
@@ -823,4 +823,4 @@ interface FlowchartLayoutResult {
823
823
  clusters: FlowchartLayoutCluster[];
824
824
  }
825
825
 
826
- export type { BlockAST as B, CircuitAST as C, DiagramPlugin as D, EntityAST as E, FishboneAST as F, Individual as I, LayoutConfig as L, PhyloTreeAST as P, RenderConfig as R, SLDAST as S, TimingAST as T, VennAST as V, DiagramAST as a, LayoutResult as b, PhyloLayoutNode as c, LegendOverrides as d, LadderAST as e, LadderRung as f, LadderElement as g, SLDNode as h, SLDNodeType as i, EntityNode as j, EntityEdge as k, VennLayoutResult as l, LogicGateAST as m, FlowchartAST as n, FlowchartLayoutResult as o, CircuitComponent as p, DiagramType as q };
826
+ export type { BlockAST as B, CircuitAST as C, DiagramPlugin as D, EntityAST as E, FishboneAST as F, Individual as I, LayoutConfig as L, PhyloTreeAST as P, RenderConfig as R, SLDAST as S, TimingAST as T, VennAST as V, DiagramAST as a, LayoutResult as b, PhyloLayoutNode as c, LegendOverrides as d, LogicGateAST as e, CircuitComponent as f, LadderAST as g, LadderRung as h, LadderElement as i, SLDNode as j, SLDNodeType as k, EntityNode as l, EntityEdge as m, VennLayoutResult as n, FlowchartAST as o, FlowchartLayoutResult as p, DiagramType as q };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "schematex",
3
- "version": "0.4.3",
4
- "description": "Every diagram a doctor, engineer, or lawyer would actually use. 27 industry-standard diagrams (genogram, pedigree, ladder logic, SLD, FBD, SFC, P&ID, UML state diagram, phylo, fishbone, entity structure, ...) from a text DSL. Free, fully open source, made for AI. Pure SVG, zero dependencies.",
3
+ "version": "0.5.2",
4
+ "description": "Every diagram a doctor, engineer, or lawyer would actually use. 31 industry-standard diagrams (genogram, pedigree, ladder logic, SLD, FBD, SFC, P&ID, UML use case, UML sequence, PRISMA, phylo, fishbone, entity structure, ...) from a text DSL. Free, fully open source, made for AI. Pure SVG, zero dependencies.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/index.js",
@@ -1,22 +0,0 @@
1
- interface SchematexConfig {
2
- type?: "genogram" | "ecomap" | "pedigree" | "phylo" | "sociogram" | "timing" | "logic" | "circuit" | "blockdiagram" | "ladder" | "sld" | "entity" | "fishbone" | "venn" | "flowchart" | "mindmap" | "matrix" | "orgchart" | "decisiontree" | "timeline" | "state" | "pid" | "erd" | "breadboard" | "bpmn" | "fbd" | "sfc";
3
- width?: number;
4
- height?: number;
5
- padding?: number;
6
- theme?: string;
7
- fontFamily?: string;
8
- }
9
- /**
10
- * Parse DSL text to the diagram's AST and return it as a plain object.
11
- * Useful for JSON serialization, programmatic inspection, or custom renderers.
12
- *
13
- * @example
14
- * ```ts
15
- * const ast = parse('genogram\n alice [female]');
16
- * console.log(JSON.stringify(ast, null, 2));
17
- * ```
18
- */
19
- declare function parse(text: string, config?: SchematexConfig): unknown;
20
- declare function render(text: string, config?: SchematexConfig): string;
21
-
22
- export { type SchematexConfig as S, parse as p, render as r };
@@ -1,22 +0,0 @@
1
- interface SchematexConfig {
2
- type?: "genogram" | "ecomap" | "pedigree" | "phylo" | "sociogram" | "timing" | "logic" | "circuit" | "blockdiagram" | "ladder" | "sld" | "entity" | "fishbone" | "venn" | "flowchart" | "mindmap" | "matrix" | "orgchart" | "decisiontree" | "timeline" | "state" | "pid" | "erd" | "breadboard" | "bpmn" | "fbd" | "sfc";
3
- width?: number;
4
- height?: number;
5
- padding?: number;
6
- theme?: string;
7
- fontFamily?: string;
8
- }
9
- /**
10
- * Parse DSL text to the diagram's AST and return it as a plain object.
11
- * Useful for JSON serialization, programmatic inspection, or custom renderers.
12
- *
13
- * @example
14
- * ```ts
15
- * const ast = parse('genogram\n alice [female]');
16
- * console.log(JSON.stringify(ast, null, 2));
17
- * ```
18
- */
19
- declare function parse(text: string, config?: SchematexConfig): unknown;
20
- declare function render(text: string, config?: SchematexConfig): string;
21
-
22
- export { type SchematexConfig as S, parse as p, render as r };