schematex 0.5.0 → 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 (90) hide show
  1. package/README.md +15 -7
  2. package/dist/ai/ai-sdk.cjs +18 -12
  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 +14 -8
  7. package/dist/ai/ai-sdk.js.map +1 -1
  8. package/dist/ai/index.cjs +15 -11
  9. package/dist/ai/index.d.cts +20 -153
  10. package/dist/ai/index.d.ts +20 -153
  11. package/dist/ai/index.js +3 -3
  12. package/dist/api-C5SECOxZ.d.cts +69 -0
  13. package/dist/api-Cr_MxttI.d.ts +69 -0
  14. package/dist/browser.cjs +23 -5
  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 +13 -5
  19. package/dist/browser.js.map +1 -1
  20. package/dist/{chunk-3YUUC6RN.cjs → chunk-4QPDZJAL.cjs} +1421 -37
  21. package/dist/chunk-4QPDZJAL.cjs.map +1 -0
  22. package/dist/{chunk-NWPCY65Z.cjs → chunk-HK56GQQP.cjs} +544 -61
  23. package/dist/chunk-HK56GQQP.cjs.map +1 -0
  24. package/dist/{chunk-GTDQAN2Z.js → chunk-OK5ZS3LU.js} +1419 -38
  25. package/dist/chunk-OK5ZS3LU.js.map +1 -0
  26. package/dist/{chunk-XRCY75UV.cjs → chunk-QMTWG6JL.cjs} +947 -916
  27. package/dist/chunk-QMTWG6JL.cjs.map +1 -0
  28. package/dist/{chunk-HUPDIRBX.js → chunk-VCH7RI5H.js} +947 -916
  29. package/dist/chunk-VCH7RI5H.js.map +1 -0
  30. package/dist/{chunk-IM4RCUHA.js → chunk-VKPCR7BG.js} +544 -62
  31. package/dist/chunk-VKPCR7BG.js.map +1 -0
  32. package/dist/diagrams/blockdiagram/index.d.cts +1 -1
  33. package/dist/diagrams/blockdiagram/index.d.ts +1 -1
  34. package/dist/diagrams/circuit/index.cjs +7 -7
  35. package/dist/diagrams/circuit/index.d.cts +1 -1
  36. package/dist/diagrams/circuit/index.d.ts +1 -1
  37. package/dist/diagrams/circuit/index.js +1 -1
  38. package/dist/diagrams/ecomap/index.d.cts +1 -1
  39. package/dist/diagrams/ecomap/index.d.ts +1 -1
  40. package/dist/diagrams/entity/index.d.cts +1 -1
  41. package/dist/diagrams/entity/index.d.ts +1 -1
  42. package/dist/diagrams/fishbone/index.d.cts +1 -1
  43. package/dist/diagrams/fishbone/index.d.ts +1 -1
  44. package/dist/diagrams/flowchart/index.d.cts +2 -2
  45. package/dist/diagrams/flowchart/index.d.ts +2 -2
  46. package/dist/diagrams/genogram/index.d.cts +1 -1
  47. package/dist/diagrams/genogram/index.d.ts +1 -1
  48. package/dist/diagrams/ladder/index.d.cts +1 -1
  49. package/dist/diagrams/ladder/index.d.ts +1 -1
  50. package/dist/diagrams/logic/index.d.cts +1 -1
  51. package/dist/diagrams/logic/index.d.ts +1 -1
  52. package/dist/diagrams/orgchart/index.d.cts +1 -1
  53. package/dist/diagrams/orgchart/index.d.ts +1 -1
  54. package/dist/diagrams/pedigree/index.d.cts +1 -1
  55. package/dist/diagrams/pedigree/index.d.ts +1 -1
  56. package/dist/diagrams/phylo/index.d.cts +1 -1
  57. package/dist/diagrams/phylo/index.d.ts +1 -1
  58. package/dist/diagrams/sld/index.d.cts +1 -1
  59. package/dist/diagrams/sld/index.d.ts +1 -1
  60. package/dist/diagrams/sociogram/index.d.cts +1 -1
  61. package/dist/diagrams/sociogram/index.d.ts +1 -1
  62. package/dist/diagrams/timing/index.d.cts +1 -1
  63. package/dist/diagrams/timing/index.d.ts +1 -1
  64. package/dist/diagrams/venn/index.d.cts +1 -1
  65. package/dist/diagrams/venn/index.d.ts +1 -1
  66. package/dist/{index-C9A0h-CB.d.cts → index-BD2yDfQM.d.cts} +1 -1
  67. package/dist/{index-CJai_TEZ.d.ts → index-C30zQWZI.d.ts} +1 -1
  68. package/dist/index.cjs +24 -12
  69. package/dist/index.d.cts +3 -3
  70. package/dist/index.d.ts +3 -3
  71. package/dist/index.js +2 -2
  72. package/dist/react.cjs +7 -9
  73. package/dist/react.cjs.map +1 -1
  74. package/dist/react.d.cts +3 -2
  75. package/dist/react.d.ts +3 -2
  76. package/dist/react.js +7 -9
  77. package/dist/react.js.map +1 -1
  78. package/dist/tools-BHWaJPOl.d.ts +153 -0
  79. package/dist/tools-DlpuE76u.d.cts +153 -0
  80. package/dist/{types-BOAsqHoU.d.cts → types-WTr9W5Ud.d.cts} +2 -2
  81. package/dist/{types-BOAsqHoU.d.ts → types-WTr9W5Ud.d.ts} +2 -2
  82. package/package.json +2 -2
  83. package/dist/api-C5UcmT7n.d.cts +0 -22
  84. package/dist/api-C5UcmT7n.d.ts +0 -22
  85. package/dist/chunk-3YUUC6RN.cjs.map +0 -1
  86. package/dist/chunk-GTDQAN2Z.js.map +0 -1
  87. package/dist/chunk-HUPDIRBX.js.map +0 -1
  88. package/dist/chunk-IM4RCUHA.js.map +0 -1
  89. package/dist/chunk-NWPCY65Z.cjs.map +0 -1
  90. package/dist/chunk-XRCY75UV.cjs.map +0 -1
@@ -1,155 +1,22 @@
1
- import { S as SchematexConfig } from '../api-C5UcmT7n.js';
2
- import { q as DiagramType } from '../types-BOAsqHoU.js';
1
+ export { D as DIAGRAM_REGISTRY, a as DiagramCluster, b as DiagramListItem, c as DiagramMeta, E as Example, G as GetExamplesOptions, d as GetExamplesResult, e as GetSyntaxOptions, f as GetSyntaxResult, R as RenderDslResult, S as SchematexValidationError, g as SyntaxDetail, h as SyntaxDoc, V as ValidateDslResult, i as getAllDiagramTypes, j as getDiagramMeta, k as getExamples, l as getSyntax, m as listDiagrams, r as renderDsl, n as resolveDiagramType, v as validateDsl } from '../tools-BHWaJPOl.js';
2
+ import { q as DiagramType } from '../types-WTr9W5Ud.js';
3
+ import '../api-Cr_MxttI.js';
3
4
 
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. */
5
+ interface GenerationProfile {
6
+ /** Canonical type id from `listDiagrams()`. */
14
7
  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 getDiagramMeta(type: string): DiagramMeta | undefined;
30
- declare function getAllDiagramTypes(): DiagramType[];
31
-
32
- /**
33
- * Structured error type returned by the AI tool layer.
34
- *
35
- * The underlying per-diagram parsers each throw their own error class
36
- * (genogram.ParseError, SLDParseError, PedigreeParseError, ...). Some
37
- * carry line/column, some don't. {@link extractError} normalises any
38
- * thrown value into this shape via structural extraction — no parser
39
- * refactor required.
40
- */
41
- interface SchematexValidationError {
42
- /** 1-based line number where the error occurred, if the parser reported it. */
43
- line?: number;
44
- /** 1-based column, if reported. */
45
- column?: number;
46
- /** Source snippet from the offending line, if the parser captured it. */
47
- source?: string;
48
- /** Human-readable error message. */
49
- message: string;
50
- /** Optional remediation hint. */
51
- hint?: string;
52
- }
53
-
54
- /**
55
- * AUTO-GENERATED by scripts/build-ai-content.mjs — do not edit by hand.
56
- * Regenerate with: npm run build:ai
57
- *
58
- * Compiled content bundle for the AI tool layer. Keeps MDX content
59
- * available to the published npm package without runtime fs access.
60
- */
61
- interface GeneratedExample {
62
- slug: string;
63
- diagram: string;
64
- title: string;
65
- description: string;
66
- standard: string;
67
- tags: readonly string[];
68
- complexity: number;
69
- featured: boolean;
70
- dsl: string;
71
- notes: string;
72
- }
73
- interface GeneratedSyntax {
74
- title: string;
75
- content: string;
76
- }
77
-
78
- /**
79
- * Example library — runtime lookup over the bundled MDX examples.
80
- */
81
-
82
- type Example = GeneratedExample;
83
- interface GetExamplesOptions {
84
- /** Maximum number of examples to return. Default 5. */
85
- limit?: number;
86
- /** Prefer examples marked `featured: true` when set. */
87
- preferFeatured?: boolean;
88
- /** Maximum complexity (1–5). */
89
- maxComplexity?: number;
90
- }
91
-
92
- /**
93
- * Syntax lookup — LLM-facing per-diagram grammar reference.
94
- *
95
- * v1: returns the stripped-MDX content from `website/content/docs/*.mdx`
96
- * (JSX components replaced with fenced DSL code blocks).
97
- *
98
- * Later: may be replaced with curated compact summaries per diagram if
99
- * the stripped docs prove too long for good LLM performance.
100
- */
101
-
102
- type SyntaxDoc = GeneratedSyntax & {
103
- key: string;
104
- };
105
-
106
- /**
107
- * AI-facing tool functions — the five tools an LLM uses to work with Schematex.
108
- *
109
- * Pure TypeScript, zero framework deps. Both the Vercel AI SDK adapter
110
- * (ai-sdk.ts) and the MCP server wrap these functions.
111
- */
112
-
113
- interface DiagramListItem {
114
- type: string;
115
- name: string;
116
- tagline: string;
117
- useWhen: string;
118
- cluster: DiagramMeta["cluster"];
119
- standard: string;
120
- }
121
- declare function listDiagrams(): DiagramListItem[];
122
- interface GetSyntaxResult {
123
- type: string;
124
- name: string;
125
- standard: string;
126
- syntax: SyntaxDoc;
127
- }
128
- declare function getSyntax(type: string): GetSyntaxResult;
129
- interface GetExamplesResult {
130
- type: string;
131
- count: number;
132
- examples: Example[];
133
- }
134
- declare function getExamples(type: string, opts?: GetExamplesOptions): GetExamplesResult;
135
- type ValidateDslResult = {
136
- ok: true;
137
- type: string | null;
138
- } | {
139
- ok: false;
140
- type: string | null;
141
- errors: SchematexValidationError[];
142
- };
143
- declare function validateDsl(type: string | undefined, dsl: string): ValidateDslResult;
144
- type RenderDslResult = {
145
- ok: true;
146
- type: string | null;
147
- svg: string;
148
- } | {
149
- ok: false;
150
- type: string | null;
151
- errors: SchematexValidationError[];
152
- };
153
- declare function renderDsl(type: string | undefined, dsl: string, options?: Omit<SchematexConfig, "type">): RenderDslResult;
154
-
155
- export { DIAGRAM_REGISTRY, type DiagramCluster, type DiagramListItem, type DiagramMeta, type Example, type GetExamplesOptions, type GetExamplesResult, type GetSyntaxResult, type RenderDslResult, type SchematexValidationError, type SyntaxDoc, type ValidateDslResult, getAllDiagramTypes, getDiagramMeta, getExamples, getSyntax, listDiagrams, renderDsl, validateDsl };
8
+ /** First line form preferred for generated DSL. */
9
+ header: string;
10
+ /** Short name for the preferred authoring mode when a parser has several. */
11
+ mode: string;
12
+ /** Forms that cover most first-shot generations for this type. */
13
+ forms: readonly string[];
14
+ /** Short grammar choices the model should make by default. */
15
+ prefer: readonly string[];
16
+ /** Accepted adapters / advanced paths to avoid unless explicitly needed. */
17
+ avoid: readonly string[];
18
+ /** Validation or semantic reminders that prevent common failed renders. */
19
+ repair: readonly string[];
20
+ }
21
+
22
+ export type { GenerationProfile };
package/dist/ai/index.js CHANGED
@@ -1,7 +1,7 @@
1
- export { DIAGRAM_REGISTRY, getAllDiagramTypes, getDiagramMeta, getExamples, getSyntax, listDiagrams, renderDsl, validateDsl } from '../chunk-IM4RCUHA.js';
2
- import '../chunk-GTDQAN2Z.js';
1
+ export { DIAGRAM_REGISTRY, getAllDiagramTypes, getDiagramMeta, getExamples, getSyntax, listDiagrams, renderDsl, resolveDiagramType, validateDsl } from '../chunk-VKPCR7BG.js';
2
+ import '../chunk-OK5ZS3LU.js';
3
3
  import '../chunk-I55HO32M.js';
4
- import '../chunk-HUPDIRBX.js';
4
+ import '../chunk-VCH7RI5H.js';
5
5
  import '../chunk-EPKIJEH7.js';
6
6
  import '../chunk-IBRW3UOA.js';
7
7
  import '../chunk-6OSUNBZY.js';
@@ -0,0 +1,69 @@
1
+ import { q as DiagramType } from './types-WTr9W5Ud.cjs';
2
+
3
+ type SchematexResultStatus = "valid" | "partial" | "invalid";
4
+ interface SchematexDiagnostic {
5
+ severity: "error" | "warning";
6
+ code: string;
7
+ message: string;
8
+ line?: number;
9
+ column?: number;
10
+ source?: string;
11
+ hint?: string;
12
+ fatal: boolean;
13
+ }
14
+ type SchematexParseResult = {
15
+ ok: true;
16
+ status: "valid" | "partial";
17
+ type: DiagramType;
18
+ ast: unknown;
19
+ diagnostics: SchematexDiagnostic[];
20
+ } | {
21
+ ok: false;
22
+ status: "invalid";
23
+ type: DiagramType | null;
24
+ diagnostics: SchematexDiagnostic[];
25
+ };
26
+ type SchematexRenderResult = {
27
+ ok: true;
28
+ status: "valid" | "partial";
29
+ type: DiagramType;
30
+ svg: string;
31
+ diagnostics: SchematexDiagnostic[];
32
+ } | {
33
+ ok: false;
34
+ status: "invalid";
35
+ type: DiagramType | null;
36
+ svg: string;
37
+ diagnostics: SchematexDiagnostic[];
38
+ };
39
+
40
+ interface SchematexConfig {
41
+ 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" | "prisma" | "usecase" | "pert" | "sequence";
42
+ width?: number;
43
+ height?: number;
44
+ padding?: number;
45
+ theme?: string;
46
+ fontFamily?: string;
47
+ /**
48
+ * `strict` preserves the historical throw-on-error API.
49
+ * `preview` returns a visible diagnostic SVG instead of an empty surface.
50
+ */
51
+ mode?: "strict" | "preview";
52
+ }
53
+ /**
54
+ * Parse DSL text to the diagram's AST and return it as a plain object.
55
+ * Useful for JSON serialization, programmatic inspection, or custom renderers.
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * const ast = parse('genogram\n alice [female]');
60
+ * console.log(JSON.stringify(ast, null, 2));
61
+ * ```
62
+ */
63
+ declare function parse(text: string, config?: SchematexConfig): unknown;
64
+ declare function parseResult(text: string, config?: SchematexConfig): SchematexParseResult;
65
+ declare function render(text: string, config?: SchematexConfig): string;
66
+ declare function renderResult(text: string, config?: SchematexConfig): SchematexRenderResult;
67
+ declare function renderPreview(text: string, config?: SchematexConfig): string;
68
+
69
+ export { type SchematexConfig as S, type SchematexDiagnostic as a, type SchematexParseResult as b, type SchematexRenderResult as c, type SchematexResultStatus as d, parseResult as e, renderPreview as f, renderResult as g, parse as p, render as r };
@@ -0,0 +1,69 @@
1
+ import { q as DiagramType } from './types-WTr9W5Ud.js';
2
+
3
+ type SchematexResultStatus = "valid" | "partial" | "invalid";
4
+ interface SchematexDiagnostic {
5
+ severity: "error" | "warning";
6
+ code: string;
7
+ message: string;
8
+ line?: number;
9
+ column?: number;
10
+ source?: string;
11
+ hint?: string;
12
+ fatal: boolean;
13
+ }
14
+ type SchematexParseResult = {
15
+ ok: true;
16
+ status: "valid" | "partial";
17
+ type: DiagramType;
18
+ ast: unknown;
19
+ diagnostics: SchematexDiagnostic[];
20
+ } | {
21
+ ok: false;
22
+ status: "invalid";
23
+ type: DiagramType | null;
24
+ diagnostics: SchematexDiagnostic[];
25
+ };
26
+ type SchematexRenderResult = {
27
+ ok: true;
28
+ status: "valid" | "partial";
29
+ type: DiagramType;
30
+ svg: string;
31
+ diagnostics: SchematexDiagnostic[];
32
+ } | {
33
+ ok: false;
34
+ status: "invalid";
35
+ type: DiagramType | null;
36
+ svg: string;
37
+ diagnostics: SchematexDiagnostic[];
38
+ };
39
+
40
+ interface SchematexConfig {
41
+ 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" | "prisma" | "usecase" | "pert" | "sequence";
42
+ width?: number;
43
+ height?: number;
44
+ padding?: number;
45
+ theme?: string;
46
+ fontFamily?: string;
47
+ /**
48
+ * `strict` preserves the historical throw-on-error API.
49
+ * `preview` returns a visible diagnostic SVG instead of an empty surface.
50
+ */
51
+ mode?: "strict" | "preview";
52
+ }
53
+ /**
54
+ * Parse DSL text to the diagram's AST and return it as a plain object.
55
+ * Useful for JSON serialization, programmatic inspection, or custom renderers.
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * const ast = parse('genogram\n alice [female]');
60
+ * console.log(JSON.stringify(ast, null, 2));
61
+ * ```
62
+ */
63
+ declare function parse(text: string, config?: SchematexConfig): unknown;
64
+ declare function parseResult(text: string, config?: SchematexConfig): SchematexParseResult;
65
+ declare function render(text: string, config?: SchematexConfig): string;
66
+ declare function renderResult(text: string, config?: SchematexConfig): SchematexRenderResult;
67
+ declare function renderPreview(text: string, config?: SchematexConfig): string;
68
+
69
+ export { type SchematexConfig as S, type SchematexDiagnostic as a, type SchematexParseResult as b, type SchematexRenderResult as c, type SchematexResultStatus as d, parseResult as e, renderPreview as f, renderResult as g, parse as p, render as r };
package/dist/browser.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunk3YUUC6RN_cjs = require('./chunk-3YUUC6RN.cjs');
3
+ var chunk4QPDZJAL_cjs = require('./chunk-4QPDZJAL.cjs');
4
4
  require('./chunk-QUKVGHN4.cjs');
5
- require('./chunk-XRCY75UV.cjs');
5
+ require('./chunk-QMTWG6JL.cjs');
6
6
  require('./chunk-SUIDD2C5.cjs');
7
7
  require('./chunk-N7W5KZK7.cjs');
8
8
  require('./chunk-3M6WB62Y.cjs');
@@ -26,7 +26,12 @@ require('./chunk-3WNW5Y7P.cjs');
26
26
 
27
27
  // src/browser.ts
28
28
  function renderToElement(text, config) {
29
- const svgString = chunk3YUUC6RN_cjs.render(text, config);
29
+ return svgStringToElement(chunk4QPDZJAL_cjs.render(text, config));
30
+ }
31
+ function renderPreviewToElement(text, config) {
32
+ return svgStringToElement(chunk4QPDZJAL_cjs.renderPreview(text, config));
33
+ }
34
+ function svgStringToElement(svgString) {
30
35
  const parser = new DOMParser();
31
36
  const doc = parser.parseFromString(svgString, "image/svg+xml");
32
37
  const el = doc.documentElement;
@@ -37,13 +42,26 @@ function renderToElement(text, config) {
37
42
  return el;
38
43
  }
39
44
  function renderToContainer(text, container, config) {
40
- container.innerHTML = chunk3YUUC6RN_cjs.render(text, config);
45
+ container.innerHTML = chunk4QPDZJAL_cjs.render(text, config);
46
+ }
47
+ function renderPreviewToContainer(text, container, config) {
48
+ container.innerHTML = chunk4QPDZJAL_cjs.renderPreview(text, config);
41
49
  }
42
50
 
43
51
  Object.defineProperty(exports, "render", {
44
52
  enumerable: true,
45
- get: function () { return chunk3YUUC6RN_cjs.render; }
53
+ get: function () { return chunk4QPDZJAL_cjs.render; }
54
+ });
55
+ Object.defineProperty(exports, "renderPreview", {
56
+ enumerable: true,
57
+ get: function () { return chunk4QPDZJAL_cjs.renderPreview; }
58
+ });
59
+ Object.defineProperty(exports, "renderResult", {
60
+ enumerable: true,
61
+ get: function () { return chunk4QPDZJAL_cjs.renderResult; }
46
62
  });
63
+ exports.renderPreviewToContainer = renderPreviewToContainer;
64
+ exports.renderPreviewToElement = renderPreviewToElement;
47
65
  exports.renderToContainer = renderToContainer;
48
66
  exports.renderToElement = renderToElement;
49
67
  //# sourceMappingURL=browser.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/browser.ts"],"names":["render"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBO,SAAS,eAAA,CACd,MACA,MAAA,EACe;AACf,EAAA,MAAM,SAAA,GAAYA,wBAAA,CAAO,IAAA,EAAM,MAAM,CAAA;AACrC,EAAA,MAAM,MAAA,GAAS,IAAI,SAAA,EAAU;AAC7B,EAAA,MAAM,GAAA,GAAM,MAAA,CAAO,eAAA,CAAgB,SAAA,EAAW,eAAe,CAAA;AAC7D,EAAA,MAAM,KAAK,GAAA,CAAI,eAAA;AACf,EAAA,MAAM,UAAA,GAAa,GAAA,CAAI,aAAA,CAAc,aAAa,CAAA;AAClD,EAAA,IAAI,UAAA,EAAY;AACd,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,iBAAA,EAAoB,UAAA,CAAW,WAAW,CAAA,CAAE,CAAA;AAAA,EAC9D;AACA,EAAA,OAAO,EAAA;AACT;AAKO,SAAS,iBAAA,CACd,IAAA,EACA,SAAA,EACA,MAAA,EACM;AACN,EAAA,SAAA,CAAU,SAAA,GAAYA,wBAAA,CAAO,IAAA,EAAM,MAAM,CAAA;AAC3C","file":"browser.cjs","sourcesContent":["/**\n * Browser-specific utilities for Schematex.\n *\n * These APIs require a DOM environment. Do not import in SSR/Node contexts.\n *\n * @example\n * ```ts\n * import { renderToElement, renderToContainer } from 'schematex/browser';\n *\n * const svg = renderToElement('genogram\\n alice [female]');\n * document.getElementById('diagram')!.appendChild(svg);\n * ```\n */\n\nimport { render, type SchematexConfig } from \"./core/api\";\n\n/**\n * Render DSL text to a live `SVGSVGElement` ready to insert into the DOM.\n */\nexport function renderToElement(\n text: string,\n config?: SchematexConfig\n): SVGSVGElement {\n const svgString = render(text, config);\n const parser = new DOMParser();\n const doc = parser.parseFromString(svgString, \"image/svg+xml\");\n const el = doc.documentElement;\n const parseError = doc.querySelector(\"parsererror\");\n if (parseError) {\n throw new Error(`SVG parse error: ${parseError.textContent}`);\n }\n return el as unknown as SVGSVGElement;\n}\n\n/**\n * Render DSL text and inject SVG into a container element (replaces innerHTML).\n */\nexport function renderToContainer(\n text: string,\n container: Element,\n config?: SchematexConfig\n): void {\n container.innerHTML = render(text, config);\n}\n\nexport { render, type SchematexConfig } from \"./core/api\";\n"]}
1
+ {"version":3,"sources":["../src/browser.ts"],"names":["render","renderPreview"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBO,SAAS,eAAA,CACd,MACA,MAAA,EACe;AACf,EAAA,OAAO,kBAAA,CAAmBA,wBAAA,CAAO,IAAA,EAAM,MAAM,CAAC,CAAA;AAChD;AAOO,SAAS,sBAAA,CACd,MACA,MAAA,EACe;AACf,EAAA,OAAO,kBAAA,CAAmBC,+BAAA,CAAc,IAAA,EAAM,MAAM,CAAC,CAAA;AACvD;AAEA,SAAS,mBAAmB,SAAA,EAAkC;AAC5D,EAAA,MAAM,MAAA,GAAS,IAAI,SAAA,EAAU;AAC7B,EAAA,MAAM,GAAA,GAAM,MAAA,CAAO,eAAA,CAAgB,SAAA,EAAW,eAAe,CAAA;AAC7D,EAAA,MAAM,KAAK,GAAA,CAAI,eAAA;AACf,EAAA,MAAM,UAAA,GAAa,GAAA,CAAI,aAAA,CAAc,aAAa,CAAA;AAClD,EAAA,IAAI,UAAA,EAAY;AACd,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,iBAAA,EAAoB,UAAA,CAAW,WAAW,CAAA,CAAE,CAAA;AAAA,EAC9D;AACA,EAAA,OAAO,EAAA;AACT;AAKO,SAAS,iBAAA,CACd,IAAA,EACA,SAAA,EACA,MAAA,EACM;AACN,EAAA,SAAA,CAAU,SAAA,GAAYD,wBAAA,CAAO,IAAA,EAAM,MAAM,CAAA;AAC3C;AAGO,SAAS,wBAAA,CACd,IAAA,EACA,SAAA,EACA,MAAA,EACM;AACN,EAAA,SAAA,CAAU,SAAA,GAAYC,+BAAA,CAAc,IAAA,EAAM,MAAM,CAAA;AAClD","file":"browser.cjs","sourcesContent":["/**\n * Browser-specific utilities for Schematex.\n *\n * These APIs require a DOM environment. Do not import in SSR/Node contexts.\n *\n * @example\n * ```ts\n * import { renderToElement, renderToContainer } from 'schematex/browser';\n *\n * const svg = renderToElement('genogram\\n alice [female]');\n * document.getElementById('diagram')!.appendChild(svg);\n * ```\n */\n\nimport {\n render,\n renderPreview,\n type SchematexConfig,\n} from \"./core/api\";\n\n/**\n * Render DSL text to a live `SVGSVGElement` ready to insert into the DOM.\n */\nexport function renderToElement(\n text: string,\n config?: SchematexConfig\n): SVGSVGElement {\n return svgStringToElement(render(text, config));\n}\n\n/**\n * Render a live SVG element for an editing/AI-preview surface.\n *\n * Invalid DSL is represented as a diagnostic SVG instead of an empty surface.\n */\nexport function renderPreviewToElement(\n text: string,\n config?: SchematexConfig\n): SVGSVGElement {\n return svgStringToElement(renderPreview(text, config));\n}\n\nfunction svgStringToElement(svgString: string): SVGSVGElement {\n const parser = new DOMParser();\n const doc = parser.parseFromString(svgString, \"image/svg+xml\");\n const el = doc.documentElement;\n const parseError = doc.querySelector(\"parsererror\");\n if (parseError) {\n throw new Error(`SVG parse error: ${parseError.textContent}`);\n }\n return el as unknown as SVGSVGElement;\n}\n\n/**\n * Render DSL text and inject SVG into a container element (replaces innerHTML).\n */\nexport function renderToContainer(\n text: string,\n container: Element,\n config?: SchematexConfig\n): void {\n container.innerHTML = render(text, config);\n}\n\n/** Replace a preview container with an SVG or a visible diagnostic fallback. */\nexport function renderPreviewToContainer(\n text: string,\n container: Element,\n config?: SchematexConfig\n): void {\n container.innerHTML = renderPreview(text, config);\n}\n\nexport {\n render,\n renderPreview,\n renderResult,\n type SchematexConfig,\n} from \"./core/api\";\n"]}
@@ -1,5 +1,6 @@
1
- import { S as SchematexConfig } from './api-C5UcmT7n.cjs';
2
- export { r as render } from './api-C5UcmT7n.cjs';
1
+ import { S as SchematexConfig } from './api-C5SECOxZ.cjs';
2
+ export { r as render, f as renderPreview, g as renderResult } from './api-C5SECOxZ.cjs';
3
+ import './types-WTr9W5Ud.cjs';
3
4
 
4
5
  /**
5
6
  * Browser-specific utilities for Schematex.
@@ -19,9 +20,17 @@ export { r as render } from './api-C5UcmT7n.cjs';
19
20
  * Render DSL text to a live `SVGSVGElement` ready to insert into the DOM.
20
21
  */
21
22
  declare function renderToElement(text: string, config?: SchematexConfig): SVGSVGElement;
23
+ /**
24
+ * Render a live SVG element for an editing/AI-preview surface.
25
+ *
26
+ * Invalid DSL is represented as a diagnostic SVG instead of an empty surface.
27
+ */
28
+ declare function renderPreviewToElement(text: string, config?: SchematexConfig): SVGSVGElement;
22
29
  /**
23
30
  * Render DSL text and inject SVG into a container element (replaces innerHTML).
24
31
  */
25
32
  declare function renderToContainer(text: string, container: Element, config?: SchematexConfig): void;
33
+ /** Replace a preview container with an SVG or a visible diagnostic fallback. */
34
+ declare function renderPreviewToContainer(text: string, container: Element, config?: SchematexConfig): void;
26
35
 
27
- export { SchematexConfig, renderToContainer, renderToElement };
36
+ export { SchematexConfig, renderPreviewToContainer, renderPreviewToElement, renderToContainer, renderToElement };
package/dist/browser.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { S as SchematexConfig } from './api-C5UcmT7n.js';
2
- export { r as render } from './api-C5UcmT7n.js';
1
+ import { S as SchematexConfig } from './api-Cr_MxttI.js';
2
+ export { r as render, f as renderPreview, g as renderResult } from './api-Cr_MxttI.js';
3
+ import './types-WTr9W5Ud.js';
3
4
 
4
5
  /**
5
6
  * Browser-specific utilities for Schematex.
@@ -19,9 +20,17 @@ export { r as render } from './api-C5UcmT7n.js';
19
20
  * Render DSL text to a live `SVGSVGElement` ready to insert into the DOM.
20
21
  */
21
22
  declare function renderToElement(text: string, config?: SchematexConfig): SVGSVGElement;
23
+ /**
24
+ * Render a live SVG element for an editing/AI-preview surface.
25
+ *
26
+ * Invalid DSL is represented as a diagnostic SVG instead of an empty surface.
27
+ */
28
+ declare function renderPreviewToElement(text: string, config?: SchematexConfig): SVGSVGElement;
22
29
  /**
23
30
  * Render DSL text and inject SVG into a container element (replaces innerHTML).
24
31
  */
25
32
  declare function renderToContainer(text: string, container: Element, config?: SchematexConfig): void;
33
+ /** Replace a preview container with an SVG or a visible diagnostic fallback. */
34
+ declare function renderPreviewToContainer(text: string, container: Element, config?: SchematexConfig): void;
26
35
 
27
- export { SchematexConfig, renderToContainer, renderToElement };
36
+ export { SchematexConfig, renderPreviewToContainer, renderPreviewToElement, renderToContainer, renderToElement };
package/dist/browser.js CHANGED
@@ -1,7 +1,7 @@
1
- import { render } from './chunk-GTDQAN2Z.js';
2
- export { render } from './chunk-GTDQAN2Z.js';
1
+ import { render, renderPreview } from './chunk-OK5ZS3LU.js';
2
+ export { render, renderPreview, renderResult } from './chunk-OK5ZS3LU.js';
3
3
  import './chunk-I55HO32M.js';
4
- import './chunk-HUPDIRBX.js';
4
+ import './chunk-VCH7RI5H.js';
5
5
  import './chunk-EPKIJEH7.js';
6
6
  import './chunk-IBRW3UOA.js';
7
7
  import './chunk-6OSUNBZY.js';
@@ -25,7 +25,12 @@ import './chunk-SYYBKDL7.js';
25
25
 
26
26
  // src/browser.ts
27
27
  function renderToElement(text, config) {
28
- const svgString = render(text, config);
28
+ return svgStringToElement(render(text, config));
29
+ }
30
+ function renderPreviewToElement(text, config) {
31
+ return svgStringToElement(renderPreview(text, config));
32
+ }
33
+ function svgStringToElement(svgString) {
29
34
  const parser = new DOMParser();
30
35
  const doc = parser.parseFromString(svgString, "image/svg+xml");
31
36
  const el = doc.documentElement;
@@ -38,7 +43,10 @@ function renderToElement(text, config) {
38
43
  function renderToContainer(text, container, config) {
39
44
  container.innerHTML = render(text, config);
40
45
  }
46
+ function renderPreviewToContainer(text, container, config) {
47
+ container.innerHTML = renderPreview(text, config);
48
+ }
41
49
 
42
- export { renderToContainer, renderToElement };
50
+ export { renderPreviewToContainer, renderPreviewToElement, renderToContainer, renderToElement };
43
51
  //# sourceMappingURL=browser.js.map
44
52
  //# sourceMappingURL=browser.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/browser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAmBO,SAAS,eAAA,CACd,MACA,MAAA,EACe;AACf,EAAA,MAAM,SAAA,GAAY,MAAA,CAAO,IAAA,EAAM,MAAM,CAAA;AACrC,EAAA,MAAM,MAAA,GAAS,IAAI,SAAA,EAAU;AAC7B,EAAA,MAAM,GAAA,GAAM,MAAA,CAAO,eAAA,CAAgB,SAAA,EAAW,eAAe,CAAA;AAC7D,EAAA,MAAM,KAAK,GAAA,CAAI,eAAA;AACf,EAAA,MAAM,UAAA,GAAa,GAAA,CAAI,aAAA,CAAc,aAAa,CAAA;AAClD,EAAA,IAAI,UAAA,EAAY;AACd,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,iBAAA,EAAoB,UAAA,CAAW,WAAW,CAAA,CAAE,CAAA;AAAA,EAC9D;AACA,EAAA,OAAO,EAAA;AACT;AAKO,SAAS,iBAAA,CACd,IAAA,EACA,SAAA,EACA,MAAA,EACM;AACN,EAAA,SAAA,CAAU,SAAA,GAAY,MAAA,CAAO,IAAA,EAAM,MAAM,CAAA;AAC3C","file":"browser.js","sourcesContent":["/**\n * Browser-specific utilities for Schematex.\n *\n * These APIs require a DOM environment. Do not import in SSR/Node contexts.\n *\n * @example\n * ```ts\n * import { renderToElement, renderToContainer } from 'schematex/browser';\n *\n * const svg = renderToElement('genogram\\n alice [female]');\n * document.getElementById('diagram')!.appendChild(svg);\n * ```\n */\n\nimport { render, type SchematexConfig } from \"./core/api\";\n\n/**\n * Render DSL text to a live `SVGSVGElement` ready to insert into the DOM.\n */\nexport function renderToElement(\n text: string,\n config?: SchematexConfig\n): SVGSVGElement {\n const svgString = render(text, config);\n const parser = new DOMParser();\n const doc = parser.parseFromString(svgString, \"image/svg+xml\");\n const el = doc.documentElement;\n const parseError = doc.querySelector(\"parsererror\");\n if (parseError) {\n throw new Error(`SVG parse error: ${parseError.textContent}`);\n }\n return el as unknown as SVGSVGElement;\n}\n\n/**\n * Render DSL text and inject SVG into a container element (replaces innerHTML).\n */\nexport function renderToContainer(\n text: string,\n container: Element,\n config?: SchematexConfig\n): void {\n container.innerHTML = render(text, config);\n}\n\nexport { render, type SchematexConfig } from \"./core/api\";\n"]}
1
+ {"version":3,"sources":["../src/browser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAuBO,SAAS,eAAA,CACd,MACA,MAAA,EACe;AACf,EAAA,OAAO,kBAAA,CAAmB,MAAA,CAAO,IAAA,EAAM,MAAM,CAAC,CAAA;AAChD;AAOO,SAAS,sBAAA,CACd,MACA,MAAA,EACe;AACf,EAAA,OAAO,kBAAA,CAAmB,aAAA,CAAc,IAAA,EAAM,MAAM,CAAC,CAAA;AACvD;AAEA,SAAS,mBAAmB,SAAA,EAAkC;AAC5D,EAAA,MAAM,MAAA,GAAS,IAAI,SAAA,EAAU;AAC7B,EAAA,MAAM,GAAA,GAAM,MAAA,CAAO,eAAA,CAAgB,SAAA,EAAW,eAAe,CAAA;AAC7D,EAAA,MAAM,KAAK,GAAA,CAAI,eAAA;AACf,EAAA,MAAM,UAAA,GAAa,GAAA,CAAI,aAAA,CAAc,aAAa,CAAA;AAClD,EAAA,IAAI,UAAA,EAAY;AACd,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,iBAAA,EAAoB,UAAA,CAAW,WAAW,CAAA,CAAE,CAAA;AAAA,EAC9D;AACA,EAAA,OAAO,EAAA;AACT;AAKO,SAAS,iBAAA,CACd,IAAA,EACA,SAAA,EACA,MAAA,EACM;AACN,EAAA,SAAA,CAAU,SAAA,GAAY,MAAA,CAAO,IAAA,EAAM,MAAM,CAAA;AAC3C;AAGO,SAAS,wBAAA,CACd,IAAA,EACA,SAAA,EACA,MAAA,EACM;AACN,EAAA,SAAA,CAAU,SAAA,GAAY,aAAA,CAAc,IAAA,EAAM,MAAM,CAAA;AAClD","file":"browser.js","sourcesContent":["/**\n * Browser-specific utilities for Schematex.\n *\n * These APIs require a DOM environment. Do not import in SSR/Node contexts.\n *\n * @example\n * ```ts\n * import { renderToElement, renderToContainer } from 'schematex/browser';\n *\n * const svg = renderToElement('genogram\\n alice [female]');\n * document.getElementById('diagram')!.appendChild(svg);\n * ```\n */\n\nimport {\n render,\n renderPreview,\n type SchematexConfig,\n} from \"./core/api\";\n\n/**\n * Render DSL text to a live `SVGSVGElement` ready to insert into the DOM.\n */\nexport function renderToElement(\n text: string,\n config?: SchematexConfig\n): SVGSVGElement {\n return svgStringToElement(render(text, config));\n}\n\n/**\n * Render a live SVG element for an editing/AI-preview surface.\n *\n * Invalid DSL is represented as a diagnostic SVG instead of an empty surface.\n */\nexport function renderPreviewToElement(\n text: string,\n config?: SchematexConfig\n): SVGSVGElement {\n return svgStringToElement(renderPreview(text, config));\n}\n\nfunction svgStringToElement(svgString: string): SVGSVGElement {\n const parser = new DOMParser();\n const doc = parser.parseFromString(svgString, \"image/svg+xml\");\n const el = doc.documentElement;\n const parseError = doc.querySelector(\"parsererror\");\n if (parseError) {\n throw new Error(`SVG parse error: ${parseError.textContent}`);\n }\n return el as unknown as SVGSVGElement;\n}\n\n/**\n * Render DSL text and inject SVG into a container element (replaces innerHTML).\n */\nexport function renderToContainer(\n text: string,\n container: Element,\n config?: SchematexConfig\n): void {\n container.innerHTML = render(text, config);\n}\n\n/** Replace a preview container with an SVG or a visible diagnostic fallback. */\nexport function renderPreviewToContainer(\n text: string,\n container: Element,\n config?: SchematexConfig\n): void {\n container.innerHTML = renderPreview(text, config);\n}\n\nexport {\n render,\n renderPreview,\n renderResult,\n type SchematexConfig,\n} from \"./core/api\";\n"]}