schematex 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/ai-sdk.cjs +16 -14
- package/dist/ai/ai-sdk.cjs.map +1 -1
- package/dist/ai/ai-sdk.d.cts +1 -1
- package/dist/ai/ai-sdk.d.ts +1 -1
- package/dist/ai/ai-sdk.js +11 -9
- package/dist/ai/ai-sdk.js.map +1 -1
- package/dist/ai/index.cjs +19 -17
- package/dist/ai/index.d.cts +1 -1
- package/dist/ai/index.d.ts +1 -1
- package/dist/ai/index.js +11 -9
- package/dist/browser.cjs +13 -11
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.js +11 -9
- package/dist/browser.js.map +1 -1
- package/dist/chunk-2KTQ75LN.js +67 -0
- package/dist/chunk-2KTQ75LN.js.map +1 -0
- package/dist/chunk-3KRL2EGN.cjs +70 -0
- package/dist/chunk-3KRL2EGN.cjs.map +1 -0
- package/dist/{chunk-YWDODCW2.js → chunk-3M6T7KB4.js} +60 -14
- package/dist/chunk-3M6T7KB4.js.map +1 -0
- package/dist/{chunk-OIZ4MYSF.cjs → chunk-3M6WB62Y.cjs} +43 -9
- package/dist/chunk-3M6WB62Y.cjs.map +1 -0
- package/dist/{chunk-KVP7AORH.js → chunk-6IGSKU6D.js} +61 -12
- package/dist/chunk-6IGSKU6D.js.map +1 -0
- package/dist/{chunk-JDBG5DU2.js → chunk-6OSUNBZY.js} +43 -9
- package/dist/chunk-6OSUNBZY.js.map +1 -0
- package/dist/{chunk-O5POCPXZ.cjs → chunk-EGSUMHCS.cjs} +21 -10
- package/dist/chunk-EGSUMHCS.cjs.map +1 -0
- package/dist/{chunk-5FF2IT3C.js → chunk-IBRW3UOA.js} +51 -10
- package/dist/chunk-IBRW3UOA.js.map +1 -0
- package/dist/{chunk-LPKVIRYT.js → chunk-JHDR56XO.js} +18 -9
- package/dist/chunk-JHDR56XO.js.map +1 -0
- package/dist/{chunk-Z5NGIM4Z.js → chunk-KWQTF6ZL.js} +30 -13
- package/dist/chunk-KWQTF6ZL.js.map +1 -0
- package/dist/{chunk-Z5UECSNM.cjs → chunk-N3SLYVNW.cjs} +47 -1785
- package/dist/chunk-N3SLYVNW.cjs.map +1 -0
- package/dist/{chunk-GZY4CJ23.cjs → chunk-N7W5KZK7.cjs} +51 -10
- package/dist/chunk-N7W5KZK7.cjs.map +1 -0
- package/dist/chunk-PIV2A3HG.js +55 -0
- package/dist/chunk-PIV2A3HG.js.map +1 -0
- package/dist/chunk-SBB6C4OP.cjs +57 -0
- package/dist/chunk-SBB6C4OP.cjs.map +1 -0
- package/dist/{chunk-DHHVYSQX.cjs → chunk-SMXU3KYA.cjs} +38 -21
- package/dist/chunk-SMXU3KYA.cjs.map +1 -0
- package/dist/{chunk-K6RAUXRQ.cjs → chunk-TZTCIAYW.cjs} +7 -6
- package/dist/chunk-TZTCIAYW.cjs.map +1 -0
- package/dist/{chunk-YTLGK5BZ.js → chunk-UBTKM2TB.js} +45 -1783
- package/dist/chunk-UBTKM2TB.js.map +1 -0
- package/dist/{chunk-6WORZSL3.cjs → chunk-VFZOPRQP.cjs} +60 -14
- package/dist/chunk-VFZOPRQP.cjs.map +1 -0
- package/dist/{chunk-E2EJRVWS.cjs → chunk-VITE3MZQ.cjs} +61 -12
- package/dist/chunk-VITE3MZQ.cjs.map +1 -0
- package/dist/{chunk-WHNIK4LK.js → chunk-VJGMEGMR.js} +7 -6
- package/dist/chunk-VJGMEGMR.js.map +1 -0
- package/dist/{chunk-3MJKJX27.cjs → chunk-VZ5LDNHK.cjs} +18 -9
- package/dist/chunk-VZ5LDNHK.cjs.map +1 -0
- package/dist/{chunk-6XGSEG3K.js → chunk-ZL5RB4UV.js} +21 -10
- package/dist/chunk-ZL5RB4UV.js.map +1 -0
- package/dist/diagrams/blockdiagram/index.d.cts +1 -1
- package/dist/diagrams/blockdiagram/index.d.ts +1 -1
- package/dist/diagrams/circuit/index.d.cts +1 -1
- package/dist/diagrams/circuit/index.d.ts +1 -1
- package/dist/diagrams/ecomap/index.cjs +7 -6
- package/dist/diagrams/ecomap/index.d.cts +1 -1
- package/dist/diagrams/ecomap/index.d.ts +1 -1
- package/dist/diagrams/ecomap/index.js +2 -1
- package/dist/diagrams/entity/index.d.cts +1 -1
- package/dist/diagrams/entity/index.d.ts +1 -1
- package/dist/diagrams/fishbone/index.cjs +8 -7
- package/dist/diagrams/fishbone/index.d.cts +1 -1
- package/dist/diagrams/fishbone/index.d.ts +1 -1
- package/dist/diagrams/fishbone/index.js +2 -1
- package/dist/diagrams/flowchart/index.cjs +8 -7
- package/dist/diagrams/flowchart/index.d.cts +2 -2
- package/dist/diagrams/flowchart/index.d.ts +2 -2
- package/dist/diagrams/flowchart/index.js +2 -1
- package/dist/diagrams/genogram/index.cjs +9 -8
- package/dist/diagrams/genogram/index.d.cts +1 -1
- package/dist/diagrams/genogram/index.d.ts +1 -1
- package/dist/diagrams/genogram/index.js +2 -1
- package/dist/diagrams/ladder/index.cjs +7 -5
- package/dist/diagrams/ladder/index.d.cts +1 -1
- package/dist/diagrams/ladder/index.d.ts +1 -1
- package/dist/diagrams/ladder/index.js +3 -1
- package/dist/diagrams/logic/index.d.cts +1 -1
- package/dist/diagrams/logic/index.d.ts +1 -1
- package/dist/diagrams/orgchart/index.d.cts +1 -1
- package/dist/diagrams/orgchart/index.d.ts +1 -1
- package/dist/diagrams/pedigree/index.cjs +7 -6
- package/dist/diagrams/pedigree/index.d.cts +1 -1
- package/dist/diagrams/pedigree/index.d.ts +1 -1
- package/dist/diagrams/pedigree/index.js +2 -1
- package/dist/diagrams/phylo/index.d.cts +1 -1
- package/dist/diagrams/phylo/index.d.ts +1 -1
- package/dist/diagrams/sld/index.cjs +7 -5
- package/dist/diagrams/sld/index.d.cts +1 -1
- package/dist/diagrams/sld/index.d.ts +1 -1
- package/dist/diagrams/sld/index.js +3 -1
- package/dist/diagrams/sociogram/index.d.cts +1 -1
- package/dist/diagrams/sociogram/index.d.ts +1 -1
- package/dist/diagrams/timing/index.d.cts +1 -1
- package/dist/diagrams/timing/index.d.ts +1 -1
- package/dist/diagrams/venn/index.d.cts +1 -1
- package/dist/diagrams/venn/index.d.ts +1 -1
- package/dist/{index-CGK0xVls.d.ts → index-BeUVaQiD.d.ts} +1 -2
- package/dist/{index-OW8eDrKj.d.cts → index-DYpJXJcy.d.cts} +1 -2
- package/dist/index.cjs +23 -21
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +10 -8
- package/dist/react.cjs +11 -9
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +10 -8
- package/dist/react.js.map +1 -1
- package/dist/{types-Gkyab1sL.d.ts → types-DKdo-Ua_.d.cts} +1 -1
- package/dist/{types-Gkyab1sL.d.cts → types-DKdo-Ua_.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/chunk-3MJKJX27.cjs.map +0 -1
- package/dist/chunk-5FF2IT3C.js.map +0 -1
- package/dist/chunk-6WORZSL3.cjs.map +0 -1
- package/dist/chunk-6XGSEG3K.js.map +0 -1
- package/dist/chunk-DHHVYSQX.cjs.map +0 -1
- package/dist/chunk-E2EJRVWS.cjs.map +0 -1
- package/dist/chunk-GZY4CJ23.cjs.map +0 -1
- package/dist/chunk-JDBG5DU2.js.map +0 -1
- package/dist/chunk-K6RAUXRQ.cjs.map +0 -1
- package/dist/chunk-KVP7AORH.js.map +0 -1
- package/dist/chunk-LPKVIRYT.js.map +0 -1
- package/dist/chunk-O5POCPXZ.cjs.map +0 -1
- package/dist/chunk-OIZ4MYSF.cjs.map +0 -1
- package/dist/chunk-WHNIK4LK.js.map +0 -1
- package/dist/chunk-YTLGK5BZ.js.map +0 -1
- package/dist/chunk-YWDODCW2.js.map +0 -1
- package/dist/chunk-Z5NGIM4Z.js.map +0 -1
- package/dist/chunk-Z5UECSNM.cjs.map +0 -1
package/dist/ai/ai-sdk.cjs
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
3
|
+
var chunkN3SLYVNW_cjs = require('../chunk-N3SLYVNW.cjs');
|
|
4
|
+
require('../chunk-SMXU3KYA.cjs');
|
|
5
5
|
require('../chunk-QUKVGHN4.cjs');
|
|
6
6
|
require('../chunk-2Z543TC3.cjs');
|
|
7
7
|
require('../chunk-SUIDD2C5.cjs');
|
|
8
|
-
require('../chunk-
|
|
9
|
-
require('../chunk-
|
|
8
|
+
require('../chunk-N7W5KZK7.cjs');
|
|
9
|
+
require('../chunk-3M6WB62Y.cjs');
|
|
10
|
+
require('../chunk-SBB6C4OP.cjs');
|
|
10
11
|
require('../chunk-RYVV5UVI.cjs');
|
|
11
|
-
require('../chunk-
|
|
12
|
+
require('../chunk-VFZOPRQP.cjs');
|
|
12
13
|
require('../chunk-BW4KGTV7.cjs');
|
|
13
|
-
require('../chunk-
|
|
14
|
-
require('../chunk-
|
|
15
|
-
require('../chunk-
|
|
16
|
-
require('../chunk-
|
|
14
|
+
require('../chunk-VITE3MZQ.cjs');
|
|
15
|
+
require('../chunk-TZTCIAYW.cjs');
|
|
16
|
+
require('../chunk-VZ5LDNHK.cjs');
|
|
17
|
+
require('../chunk-EGSUMHCS.cjs');
|
|
18
|
+
require('../chunk-3KRL2EGN.cjs');
|
|
17
19
|
require('../chunk-S2KJRHDZ.cjs');
|
|
18
20
|
require('../chunk-UUBNQV2T.cjs');
|
|
19
21
|
require('../chunk-5UCXMYE7.cjs');
|
|
@@ -29,7 +31,7 @@ var schematexTools = {
|
|
|
29
31
|
listDiagrams: ai.tool({
|
|
30
32
|
description: "List every Schematex diagram type with a tagline, 'use when' hint, domain cluster, and authoritative standard. Call this first to discover what's available.",
|
|
31
33
|
inputSchema: zod.z.object({}),
|
|
32
|
-
execute: async () =>
|
|
34
|
+
execute: async () => chunkN3SLYVNW_cjs.listDiagrams()
|
|
33
35
|
}),
|
|
34
36
|
getSyntax: ai.tool({
|
|
35
37
|
description: "Return a compact syntax reference for one diagram type \u2014 rules, grammar (EBNF), and inline examples. Trimmed for LLM consumption (~2,000\u20134,000 tokens). Call after listDiagrams once you've chosen a type.",
|
|
@@ -38,7 +40,7 @@ var schematexTools = {
|
|
|
38
40
|
"Diagram type id from listDiagrams (e.g. 'genogram', 'sld', 'fishbone')."
|
|
39
41
|
)
|
|
40
42
|
}),
|
|
41
|
-
execute: async ({ type }) =>
|
|
43
|
+
execute: async ({ type }) => chunkN3SLYVNW_cjs.getSyntax(type)
|
|
42
44
|
}),
|
|
43
45
|
getExamples: ai.tool({
|
|
44
46
|
description: "Return curated real-world DSL examples for a diagram type, each with scenario notes and tags. Use as few-shot context before generating DSL.",
|
|
@@ -48,7 +50,7 @@ var schematexTools = {
|
|
|
48
50
|
preferFeatured: zod.z.boolean().optional().describe("Rank featured examples first."),
|
|
49
51
|
maxComplexity: zod.z.number().int().min(1).max(5).optional().describe("Only return examples with complexity <= this value (1=simplest).")
|
|
50
52
|
}),
|
|
51
|
-
execute: async (args) =>
|
|
53
|
+
execute: async (args) => chunkN3SLYVNW_cjs.getExamples(args.type, {
|
|
52
54
|
limit: args.limit,
|
|
53
55
|
preferFeatured: args.preferFeatured,
|
|
54
56
|
maxComplexity: args.maxComplexity
|
|
@@ -62,7 +64,7 @@ var schematexTools = {
|
|
|
62
64
|
),
|
|
63
65
|
dsl: zod.z.string().describe("The DSL source text to validate.")
|
|
64
66
|
}),
|
|
65
|
-
execute: async ({ type, dsl }) =>
|
|
67
|
+
execute: async ({ type, dsl }) => chunkN3SLYVNW_cjs.validateDsl(type, dsl)
|
|
66
68
|
}),
|
|
67
69
|
renderDsl: ai.tool({
|
|
68
70
|
description: "Render Schematex DSL to an SVG string. Returns { ok: true, svg } or { ok: false, errors }. Use when the caller needs the actual diagram output, not just validation.",
|
|
@@ -77,7 +79,7 @@ var schematexTools = {
|
|
|
77
79
|
dsl,
|
|
78
80
|
theme,
|
|
79
81
|
padding
|
|
80
|
-
}) =>
|
|
82
|
+
}) => chunkN3SLYVNW_cjs.renderDsl(type, dsl, { theme, padding })
|
|
81
83
|
})
|
|
82
84
|
};
|
|
83
85
|
|
package/dist/ai/ai-sdk.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ai/ai-sdk.ts"],"names":["tool","z","listDiagrams","getSyntax","getExamples","validateDsl","renderDsl"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/ai/ai-sdk.ts"],"names":["tool","z","listDiagrams","getSyntax","getExamples","validateDsl","renderDsl"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCO,IAAM,cAAA,GAAiB;AAAA,EAC5B,cAAcA,OAAA,CAAK;AAAA,IACjB,WAAA,EACE,8JAAA;AAAA,IACF,WAAA,EAAaC,KAAA,CAAE,MAAA,CAAO,EAAE,CAAA;AAAA,IACxB,OAAA,EAAS,YAAYC,8BAAA;AAAiB,GACvC,CAAA;AAAA,EAED,WAAWF,OAAA,CAAK;AAAA,IACd,WAAA,EACE,sNAAA;AAAA,IACF,WAAA,EAAaC,MAAE,MAAA,CAAO;AAAA,MACpB,IAAA,EAAMA,KAAA,CACH,MAAA,EAAO,CACP,QAAA;AAAA,QACC;AAAA;AACF,KACH,CAAA;AAAA,IACD,SAAS,OAAO,EAAE,IAAA,EAAK,KAAwBE,4BAAc,IAAI;AAAA,GAClE,CAAA;AAAA,EAED,aAAaH,OAAA,CAAK;AAAA,IAChB,WAAA,EACE,8IAAA;AAAA,IACF,WAAA,EAAaC,MAAE,MAAA,CAAO;AAAA,MACpB,IAAA,EAAMA,KAAA,CAAE,MAAA,EAAO,CAAE,SAAS,kBAAkB,CAAA;AAAA,MAC5C,KAAA,EAAOA,KAAA,CACJ,MAAA,EAAO,CACP,KAAI,CACJ,GAAA,CAAI,CAAC,CAAA,CACL,IAAI,EAAE,CAAA,CACN,QAAA,EAAS,CACT,SAAS,qCAAqC,CAAA;AAAA,MACjD,gBAAgBA,KAAA,CACb,OAA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AAA,KACnE,CAAA;AAAA,IACD,SAAS,OAAO;AAAA,MACd,IAAA;AAAA,MACA,GAAA;AAAA,MACA,KAAA;AAAA,MACA;AAAA,UAMIK,2BAAA,CAAc,IAAA,EAAM,KAAK,EAAE,KAAA,EAAO,SAAS;AAAA,GAClD;AACH","file":"ai-sdk.cjs","sourcesContent":["/**\n * Vercel AI SDK adapter — ready-to-use `tools` object for `generateText` /\n * `streamText`.\n *\n * @example\n * ```ts\n * import { streamText } from 'ai';\n * import { schematexTools } from 'schematex/ai/sdk';\n *\n * const result = streamText({\n * model: 'anthropic/claude-opus-4-7',\n * tools: schematexTools,\n * maxSteps: 5,\n * system: `You write Schematex DSL. Discover types with listDiagrams,\n * then fetch getSyntax + getExamples before writing. Call validateDsl\n * before returning DSL to the user.`,\n * prompt: userMessage,\n * });\n * ```\n *\n * Peer-deps `ai` and `zod` are optional — this module only loads if both\n * are installed.\n */\nimport { tool } from \"ai\";\nimport { z } from \"zod\";\n\nimport {\n listDiagrams as listDiagramsImpl,\n getSyntax as getSyntaxImpl,\n getExamples as getExamplesImpl,\n validateDsl as validateDslImpl,\n renderDsl as renderDslImpl,\n} from \"./tools\";\n\nexport const schematexTools = {\n listDiagrams: tool({\n description:\n \"List every Schematex diagram type with a tagline, 'use when' hint, domain cluster, and authoritative standard. Call this first to discover what's available.\",\n inputSchema: z.object({}),\n execute: async () => listDiagramsImpl(),\n }),\n\n getSyntax: tool({\n description:\n \"Return a compact syntax reference for one diagram type — rules, grammar (EBNF), and inline examples. Trimmed for LLM consumption (~2,000–4,000 tokens). Call after listDiagrams once you've chosen a type.\",\n inputSchema: z.object({\n type: z\n .string()\n .describe(\n \"Diagram type id from listDiagrams (e.g. 'genogram', 'sld', 'fishbone').\"\n ),\n }),\n execute: async ({ type }: { type: string }) => getSyntaxImpl(type),\n }),\n\n getExamples: tool({\n description:\n \"Return curated real-world DSL examples for a diagram type, each with scenario notes and tags. Use as few-shot context before generating DSL.\",\n inputSchema: z.object({\n type: z.string().describe(\"Diagram type id.\"),\n limit: z\n .number()\n .int()\n .min(1)\n .max(10)\n .optional()\n .describe(\"Max examples to return (default 5).\"),\n preferFeatured: z\n .boolean()\n .optional()\n .describe(\"Rank featured examples first.\"),\n maxComplexity: z\n .number()\n .int()\n .min(1)\n .max(5)\n .optional()\n .describe(\"Only return examples with complexity <= this value (1=simplest).\"),\n }),\n execute: async (args: {\n type: string;\n limit?: number;\n preferFeatured?: boolean;\n maxComplexity?: number;\n }) =>\n getExamplesImpl(args.type, {\n limit: args.limit,\n preferFeatured: args.preferFeatured,\n maxComplexity: args.maxComplexity,\n }),\n }),\n\n validateDsl: tool({\n description:\n \"Validate Schematex DSL. Returns { ok: true } or { ok: false, errors: [{line, column, message, source}] }. Call before returning DSL to the user and self-correct on errors.\",\n inputSchema: z.object({\n type: z\n .string()\n .optional()\n .describe(\n \"Diagram type. Optional — Schematex auto-detects from the first line if omitted.\"\n ),\n dsl: z.string().describe(\"The DSL source text to validate.\"),\n }),\n execute: async ({ type, dsl }: { type?: string; dsl: string }) =>\n validateDslImpl(type, dsl),\n }),\n\n renderDsl: tool({\n description:\n \"Render Schematex DSL to an SVG string. Returns { ok: true, svg } or { ok: false, errors }. Use when the caller needs the actual diagram output, not just validation.\",\n inputSchema: z.object({\n type: z.string().optional().describe(\"Diagram type (auto-detected if omitted).\"),\n dsl: z.string().describe(\"The DSL source text to render.\"),\n theme: z.string().optional().describe(\"Theme name, e.g. 'default' or 'dark'.\"),\n padding: z.number().optional().describe(\"Outer padding in pixels.\"),\n }),\n execute: async ({\n type,\n dsl,\n theme,\n padding,\n }: {\n type?: string;\n dsl: string;\n theme?: string;\n padding?: number;\n }) => renderDslImpl(type, dsl, { theme, padding }),\n }),\n} as const;\n\nexport type SchematexTools = typeof schematexTools;\n"]}
|
package/dist/ai/ai-sdk.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as ai from 'ai';
|
|
2
2
|
import { DiagramListItem, GetSyntaxResult, GetExamplesResult, ValidateDslResult, RenderDslResult } from './index.cjs';
|
|
3
3
|
import '../api-BIj9t4Oc.cjs';
|
|
4
|
-
import '../types-
|
|
4
|
+
import '../types-DKdo-Ua_.cjs';
|
|
5
5
|
|
|
6
6
|
declare const schematexTools: {
|
|
7
7
|
readonly listDiagrams: ai.Tool<{}, DiagramListItem[]>;
|
package/dist/ai/ai-sdk.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as ai from 'ai';
|
|
2
2
|
import { DiagramListItem, GetSyntaxResult, GetExamplesResult, ValidateDslResult, RenderDslResult } from './index.js';
|
|
3
3
|
import '../api-BIj9t4Oc.js';
|
|
4
|
-
import '../types-
|
|
4
|
+
import '../types-DKdo-Ua_.js';
|
|
5
5
|
|
|
6
6
|
declare const schematexTools: {
|
|
7
7
|
readonly listDiagrams: ai.Tool<{}, DiagramListItem[]>;
|
package/dist/ai/ai-sdk.js
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import { renderDsl, validateDsl, getExamples, getSyntax, listDiagrams } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
import { renderDsl, validateDsl, getExamples, getSyntax, listDiagrams } from '../chunk-UBTKM2TB.js';
|
|
2
|
+
import '../chunk-KWQTF6ZL.js';
|
|
3
3
|
import '../chunk-I55HO32M.js';
|
|
4
4
|
import '../chunk-J7JWMQD5.js';
|
|
5
5
|
import '../chunk-EPKIJEH7.js';
|
|
6
|
-
import '../chunk-
|
|
7
|
-
import '../chunk-
|
|
6
|
+
import '../chunk-IBRW3UOA.js';
|
|
7
|
+
import '../chunk-6OSUNBZY.js';
|
|
8
|
+
import '../chunk-PIV2A3HG.js';
|
|
8
9
|
import '../chunk-SZK376QB.js';
|
|
9
|
-
import '../chunk-
|
|
10
|
+
import '../chunk-3M6T7KB4.js';
|
|
10
11
|
import '../chunk-L3CTXXVZ.js';
|
|
11
|
-
import '../chunk-
|
|
12
|
-
import '../chunk-
|
|
13
|
-
import '../chunk-
|
|
14
|
-
import '../chunk-
|
|
12
|
+
import '../chunk-6IGSKU6D.js';
|
|
13
|
+
import '../chunk-VJGMEGMR.js';
|
|
14
|
+
import '../chunk-JHDR56XO.js';
|
|
15
|
+
import '../chunk-ZL5RB4UV.js';
|
|
16
|
+
import '../chunk-2KTQ75LN.js';
|
|
15
17
|
import '../chunk-VDSYMSUY.js';
|
|
16
18
|
import '../chunk-ZX74KJPM.js';
|
|
17
19
|
import '../chunk-FO7BLCEW.js';
|
package/dist/ai/ai-sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ai/ai-sdk.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/ai/ai-sdk.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCO,IAAM,cAAA,GAAiB;AAAA,EAC5B,cAAc,IAAA,CAAK;AAAA,IACjB,WAAA,EACE,8JAAA;AAAA,IACF,WAAA,EAAa,CAAA,CAAE,MAAA,CAAO,EAAE,CAAA;AAAA,IACxB,OAAA,EAAS,YAAY,YAAA;AAAiB,GACvC,CAAA;AAAA,EAED,WAAW,IAAA,CAAK;AAAA,IACd,WAAA,EACE,sNAAA;AAAA,IACF,WAAA,EAAa,EAAE,MAAA,CAAO;AAAA,MACpB,IAAA,EAAM,CAAA,CACH,MAAA,EAAO,CACP,QAAA;AAAA,QACC;AAAA;AACF,KACH,CAAA;AAAA,IACD,SAAS,OAAO,EAAE,IAAA,EAAK,KAAwB,UAAc,IAAI;AAAA,GAClE,CAAA;AAAA,EAED,aAAa,IAAA,CAAK;AAAA,IAChB,WAAA,EACE,8IAAA;AAAA,IACF,WAAA,EAAa,EAAE,MAAA,CAAO;AAAA,MACpB,IAAA,EAAM,CAAA,CAAE,MAAA,EAAO,CAAE,SAAS,kBAAkB,CAAA;AAAA,MAC5C,KAAA,EAAO,CAAA,CACJ,MAAA,EAAO,CACP,KAAI,CACJ,GAAA,CAAI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AS,uCAAuC,CAAA;AAAA,MAC7E,SAAS,CAAA,CAAE,MAAA,GAAS,QAAA,EAAS,CAAE,SAAS,0BAA0B;AAAA,KACnE,CAAA;AAAA,IACD,SAAS,OAAO;AAAA,MACd,IAAA;AAAA,MACA,GAAA;AAAA,MACA,KAAA;AAAA,MACA;AAAA,UAMI,SAAA,CAAc,IAAA,EAAM,KAAK,EAAE,KAAA,EAAO,SAAS;AAAA,GAClD;AACH","file":"ai-sdk.js","sourcesContent":["/**\n * Vercel AI SDK adapter — ready-to-use `tools` object for `generateText` /\n * `streamText`.\n *\n * @example\n * ```ts\n * import { streamText } from 'ai';\n * import { schematexTools } from 'schematex/ai/sdk';\n *\n * const result = streamText({\n * model: 'anthropic/claude-opus-4-7',\n * tools: schematexTools,\n * maxSteps: 5,\n * system: `You write Schematex DSL. Discover types with listDiagrams,\n * then fetch getSyntax + getExamples before writing. Call validateDsl\n * before returning DSL to the user.`,\n * prompt: userMessage,\n * });\n * ```\n *\n * Peer-deps `ai` and `zod` are optional — this module only loads if both\n * are installed.\n */\nimport { tool } from \"ai\";\nimport { z } from \"zod\";\n\nimport {\n listDiagrams as listDiagramsImpl,\n getSyntax as getSyntaxImpl,\n getExamples as getExamplesImpl,\n validateDsl as validateDslImpl,\n renderDsl as renderDslImpl,\n} from \"./tools\";\n\nexport const schematexTools = {\n listDiagrams: tool({\n description:\n \"List every Schematex diagram type with a tagline, 'use when' hint, domain cluster, and authoritative standard. Call this first to discover what's available.\",\n inputSchema: z.object({}),\n execute: async () => listDiagramsImpl(),\n }),\n\n getSyntax: tool({\n description:\n \"Return a compact syntax reference for one diagram type — rules, grammar (EBNF), and inline examples. Trimmed for LLM consumption (~2,000–4,000 tokens). Call after listDiagrams once you've chosen a type.\",\n inputSchema: z.object({\n type: z\n .string()\n .describe(\n \"Diagram type id from listDiagrams (e.g. 'genogram', 'sld', 'fishbone').\"\n ),\n }),\n execute: async ({ type }: { type: string }) => getSyntaxImpl(type),\n }),\n\n getExamples: tool({\n description:\n \"Return curated real-world DSL examples for a diagram type, each with scenario notes and tags. Use as few-shot context before generating DSL.\",\n inputSchema: z.object({\n type: z.string().describe(\"Diagram type id.\"),\n limit: z\n .number()\n .int()\n .min(1)\n .max(10)\n .optional()\n .describe(\"Max examples to return (default 5).\"),\n preferFeatured: z\n .boolean()\n .optional()\n .describe(\"Rank featured examples first.\"),\n maxComplexity: z\n .number()\n .int()\n .min(1)\n .max(5)\n .optional()\n .describe(\"Only return examples with complexity <= this value (1=simplest).\"),\n }),\n execute: async (args: {\n type: string;\n limit?: number;\n preferFeatured?: boolean;\n maxComplexity?: number;\n }) =>\n getExamplesImpl(args.type, {\n limit: args.limit,\n preferFeatured: args.preferFeatured,\n maxComplexity: args.maxComplexity,\n }),\n }),\n\n validateDsl: tool({\n description:\n \"Validate Schematex DSL. Returns { ok: true } or { ok: false, errors: [{line, column, message, source}] }. Call before returning DSL to the user and self-correct on errors.\",\n inputSchema: z.object({\n type: z\n .string()\n .optional()\n .describe(\n \"Diagram type. Optional — Schematex auto-detects from the first line if omitted.\"\n ),\n dsl: z.string().describe(\"The DSL source text to validate.\"),\n }),\n execute: async ({ type, dsl }: { type?: string; dsl: string }) =>\n validateDslImpl(type, dsl),\n }),\n\n renderDsl: tool({\n description:\n \"Render Schematex DSL to an SVG string. Returns { ok: true, svg } or { ok: false, errors }. Use when the caller needs the actual diagram output, not just validation.\",\n inputSchema: z.object({\n type: z.string().optional().describe(\"Diagram type (auto-detected if omitted).\"),\n dsl: z.string().describe(\"The DSL source text to render.\"),\n theme: z.string().optional().describe(\"Theme name, e.g. 'default' or 'dark'.\"),\n padding: z.number().optional().describe(\"Outer padding in pixels.\"),\n }),\n execute: async ({\n type,\n dsl,\n theme,\n padding,\n }: {\n type?: string;\n dsl: string;\n theme?: string;\n padding?: number;\n }) => renderDslImpl(type, dsl, { theme, padding }),\n }),\n} as const;\n\nexport type SchematexTools = typeof schematexTools;\n"]}
|
package/dist/ai/index.cjs
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
3
|
+
var chunkN3SLYVNW_cjs = require('../chunk-N3SLYVNW.cjs');
|
|
4
|
+
require('../chunk-SMXU3KYA.cjs');
|
|
5
5
|
require('../chunk-QUKVGHN4.cjs');
|
|
6
6
|
require('../chunk-2Z543TC3.cjs');
|
|
7
7
|
require('../chunk-SUIDD2C5.cjs');
|
|
8
|
-
require('../chunk-
|
|
9
|
-
require('../chunk-
|
|
8
|
+
require('../chunk-N7W5KZK7.cjs');
|
|
9
|
+
require('../chunk-3M6WB62Y.cjs');
|
|
10
|
+
require('../chunk-SBB6C4OP.cjs');
|
|
10
11
|
require('../chunk-RYVV5UVI.cjs');
|
|
11
|
-
require('../chunk-
|
|
12
|
+
require('../chunk-VFZOPRQP.cjs');
|
|
12
13
|
require('../chunk-BW4KGTV7.cjs');
|
|
13
|
-
require('../chunk-
|
|
14
|
-
require('../chunk-
|
|
15
|
-
require('../chunk-
|
|
16
|
-
require('../chunk-
|
|
14
|
+
require('../chunk-VITE3MZQ.cjs');
|
|
15
|
+
require('../chunk-TZTCIAYW.cjs');
|
|
16
|
+
require('../chunk-VZ5LDNHK.cjs');
|
|
17
|
+
require('../chunk-EGSUMHCS.cjs');
|
|
18
|
+
require('../chunk-3KRL2EGN.cjs');
|
|
17
19
|
require('../chunk-S2KJRHDZ.cjs');
|
|
18
20
|
require('../chunk-UUBNQV2T.cjs');
|
|
19
21
|
require('../chunk-5UCXMYE7.cjs');
|
|
@@ -27,35 +29,35 @@ require('../chunk-3WNW5Y7P.cjs');
|
|
|
27
29
|
|
|
28
30
|
Object.defineProperty(exports, "DIAGRAM_REGISTRY", {
|
|
29
31
|
enumerable: true,
|
|
30
|
-
get: function () { return
|
|
32
|
+
get: function () { return chunkN3SLYVNW_cjs.DIAGRAM_REGISTRY; }
|
|
31
33
|
});
|
|
32
34
|
Object.defineProperty(exports, "getAllDiagramTypes", {
|
|
33
35
|
enumerable: true,
|
|
34
|
-
get: function () { return
|
|
36
|
+
get: function () { return chunkN3SLYVNW_cjs.getAllDiagramTypes; }
|
|
35
37
|
});
|
|
36
38
|
Object.defineProperty(exports, "getDiagramMeta", {
|
|
37
39
|
enumerable: true,
|
|
38
|
-
get: function () { return
|
|
40
|
+
get: function () { return chunkN3SLYVNW_cjs.getDiagramMeta; }
|
|
39
41
|
});
|
|
40
42
|
Object.defineProperty(exports, "getExamples", {
|
|
41
43
|
enumerable: true,
|
|
42
|
-
get: function () { return
|
|
44
|
+
get: function () { return chunkN3SLYVNW_cjs.getExamples; }
|
|
43
45
|
});
|
|
44
46
|
Object.defineProperty(exports, "getSyntax", {
|
|
45
47
|
enumerable: true,
|
|
46
|
-
get: function () { return
|
|
48
|
+
get: function () { return chunkN3SLYVNW_cjs.getSyntax; }
|
|
47
49
|
});
|
|
48
50
|
Object.defineProperty(exports, "listDiagrams", {
|
|
49
51
|
enumerable: true,
|
|
50
|
-
get: function () { return
|
|
52
|
+
get: function () { return chunkN3SLYVNW_cjs.listDiagrams; }
|
|
51
53
|
});
|
|
52
54
|
Object.defineProperty(exports, "renderDsl", {
|
|
53
55
|
enumerable: true,
|
|
54
|
-
get: function () { return
|
|
56
|
+
get: function () { return chunkN3SLYVNW_cjs.renderDsl; }
|
|
55
57
|
});
|
|
56
58
|
Object.defineProperty(exports, "validateDsl", {
|
|
57
59
|
enumerable: true,
|
|
58
|
-
get: function () { return
|
|
60
|
+
get: function () { return chunkN3SLYVNW_cjs.validateDsl; }
|
|
59
61
|
});
|
|
60
62
|
//# sourceMappingURL=index.cjs.map
|
|
61
63
|
//# sourceMappingURL=index.cjs.map
|
package/dist/ai/index.d.cts
CHANGED
package/dist/ai/index.d.ts
CHANGED
package/dist/ai/index.js
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
export { DIAGRAM_REGISTRY, getAllDiagramTypes, getDiagramMeta, getExamples, getSyntax, listDiagrams, renderDsl, validateDsl } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
export { DIAGRAM_REGISTRY, getAllDiagramTypes, getDiagramMeta, getExamples, getSyntax, listDiagrams, renderDsl, validateDsl } from '../chunk-UBTKM2TB.js';
|
|
2
|
+
import '../chunk-KWQTF6ZL.js';
|
|
3
3
|
import '../chunk-I55HO32M.js';
|
|
4
4
|
import '../chunk-J7JWMQD5.js';
|
|
5
5
|
import '../chunk-EPKIJEH7.js';
|
|
6
|
-
import '../chunk-
|
|
7
|
-
import '../chunk-
|
|
6
|
+
import '../chunk-IBRW3UOA.js';
|
|
7
|
+
import '../chunk-6OSUNBZY.js';
|
|
8
|
+
import '../chunk-PIV2A3HG.js';
|
|
8
9
|
import '../chunk-SZK376QB.js';
|
|
9
|
-
import '../chunk-
|
|
10
|
+
import '../chunk-3M6T7KB4.js';
|
|
10
11
|
import '../chunk-L3CTXXVZ.js';
|
|
11
|
-
import '../chunk-
|
|
12
|
-
import '../chunk-
|
|
13
|
-
import '../chunk-
|
|
14
|
-
import '../chunk-
|
|
12
|
+
import '../chunk-6IGSKU6D.js';
|
|
13
|
+
import '../chunk-VJGMEGMR.js';
|
|
14
|
+
import '../chunk-JHDR56XO.js';
|
|
15
|
+
import '../chunk-ZL5RB4UV.js';
|
|
16
|
+
import '../chunk-2KTQ75LN.js';
|
|
15
17
|
import '../chunk-VDSYMSUY.js';
|
|
16
18
|
import '../chunk-ZX74KJPM.js';
|
|
17
19
|
import '../chunk-FO7BLCEW.js';
|
package/dist/browser.cjs
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkSMXU3KYA_cjs = require('./chunk-SMXU3KYA.cjs');
|
|
4
4
|
require('./chunk-QUKVGHN4.cjs');
|
|
5
5
|
require('./chunk-2Z543TC3.cjs');
|
|
6
6
|
require('./chunk-SUIDD2C5.cjs');
|
|
7
|
-
require('./chunk-
|
|
8
|
-
require('./chunk-
|
|
7
|
+
require('./chunk-N7W5KZK7.cjs');
|
|
8
|
+
require('./chunk-3M6WB62Y.cjs');
|
|
9
|
+
require('./chunk-SBB6C4OP.cjs');
|
|
9
10
|
require('./chunk-RYVV5UVI.cjs');
|
|
10
|
-
require('./chunk-
|
|
11
|
+
require('./chunk-VFZOPRQP.cjs');
|
|
11
12
|
require('./chunk-BW4KGTV7.cjs');
|
|
12
|
-
require('./chunk-
|
|
13
|
-
require('./chunk-
|
|
14
|
-
require('./chunk-
|
|
15
|
-
require('./chunk-
|
|
13
|
+
require('./chunk-VITE3MZQ.cjs');
|
|
14
|
+
require('./chunk-TZTCIAYW.cjs');
|
|
15
|
+
require('./chunk-VZ5LDNHK.cjs');
|
|
16
|
+
require('./chunk-EGSUMHCS.cjs');
|
|
17
|
+
require('./chunk-3KRL2EGN.cjs');
|
|
16
18
|
require('./chunk-S2KJRHDZ.cjs');
|
|
17
19
|
require('./chunk-UUBNQV2T.cjs');
|
|
18
20
|
require('./chunk-5UCXMYE7.cjs');
|
|
@@ -24,7 +26,7 @@ require('./chunk-3WNW5Y7P.cjs');
|
|
|
24
26
|
|
|
25
27
|
// src/browser.ts
|
|
26
28
|
function renderToElement(text, config) {
|
|
27
|
-
const svgString =
|
|
29
|
+
const svgString = chunkSMXU3KYA_cjs.render(text, config);
|
|
28
30
|
const parser = new DOMParser();
|
|
29
31
|
const doc = parser.parseFromString(svgString, "image/svg+xml");
|
|
30
32
|
const el = doc.documentElement;
|
|
@@ -35,12 +37,12 @@ function renderToElement(text, config) {
|
|
|
35
37
|
return el;
|
|
36
38
|
}
|
|
37
39
|
function renderToContainer(text, container, config) {
|
|
38
|
-
container.innerHTML =
|
|
40
|
+
container.innerHTML = chunkSMXU3KYA_cjs.render(text, config);
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
Object.defineProperty(exports, "render", {
|
|
42
44
|
enumerable: true,
|
|
43
|
-
get: function () { return
|
|
45
|
+
get: function () { return chunkSMXU3KYA_cjs.render; }
|
|
44
46
|
});
|
|
45
47
|
exports.renderToContainer = renderToContainer;
|
|
46
48
|
exports.renderToElement = renderToElement;
|
package/dist/browser.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/browser.ts"],"names":["render"],"mappings":"
|
|
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"]}
|
package/dist/browser.js
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import { render } from './chunk-
|
|
2
|
-
export { render } from './chunk-
|
|
1
|
+
import { render } from './chunk-KWQTF6ZL.js';
|
|
2
|
+
export { render } from './chunk-KWQTF6ZL.js';
|
|
3
3
|
import './chunk-I55HO32M.js';
|
|
4
4
|
import './chunk-J7JWMQD5.js';
|
|
5
5
|
import './chunk-EPKIJEH7.js';
|
|
6
|
-
import './chunk-
|
|
7
|
-
import './chunk-
|
|
6
|
+
import './chunk-IBRW3UOA.js';
|
|
7
|
+
import './chunk-6OSUNBZY.js';
|
|
8
|
+
import './chunk-PIV2A3HG.js';
|
|
8
9
|
import './chunk-SZK376QB.js';
|
|
9
|
-
import './chunk-
|
|
10
|
+
import './chunk-3M6T7KB4.js';
|
|
10
11
|
import './chunk-L3CTXXVZ.js';
|
|
11
|
-
import './chunk-
|
|
12
|
-
import './chunk-
|
|
13
|
-
import './chunk-
|
|
14
|
-
import './chunk-
|
|
12
|
+
import './chunk-6IGSKU6D.js';
|
|
13
|
+
import './chunk-VJGMEGMR.js';
|
|
14
|
+
import './chunk-JHDR56XO.js';
|
|
15
|
+
import './chunk-ZL5RB4UV.js';
|
|
16
|
+
import './chunk-2KTQ75LN.js';
|
|
15
17
|
import './chunk-VDSYMSUY.js';
|
|
16
18
|
import './chunk-ZX74KJPM.js';
|
|
17
19
|
import './chunk-FO7BLCEW.js';
|
package/dist/browser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/browser.ts"],"names":[],"mappings":"
|
|
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"]}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// src/core/dsl-preprocess.ts
|
|
2
|
+
var FRONTMATTER_DELIM = /^-{3,}\s*$/;
|
|
3
|
+
function parseFrontmatter(text) {
|
|
4
|
+
const lines = text.split(/\r?\n/);
|
|
5
|
+
let i = 0;
|
|
6
|
+
while (i < lines.length && lines[i].trim() === "") i++;
|
|
7
|
+
if (i >= lines.length || !FRONTMATTER_DELIM.test(lines[i])) {
|
|
8
|
+
return { data: {}, body: text };
|
|
9
|
+
}
|
|
10
|
+
const openIdx = i;
|
|
11
|
+
i++;
|
|
12
|
+
const data = {};
|
|
13
|
+
while (i < lines.length && !FRONTMATTER_DELIM.test(lines[i])) {
|
|
14
|
+
const line = lines[i];
|
|
15
|
+
const trimmed = line.trim();
|
|
16
|
+
if (trimmed === "" || trimmed.startsWith("#")) {
|
|
17
|
+
i++;
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
const colonIdx = trimmed.indexOf(":");
|
|
21
|
+
if (colonIdx <= 0) {
|
|
22
|
+
return { data: {}, body: text };
|
|
23
|
+
}
|
|
24
|
+
const key = trimmed.slice(0, colonIdx).trim();
|
|
25
|
+
let value = trimmed.slice(colonIdx + 1).trim();
|
|
26
|
+
if (value.length >= 2 && (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'") || value.startsWith("\u201C") && value.endsWith("\u201D"))) {
|
|
27
|
+
value = value.slice(1, -1);
|
|
28
|
+
}
|
|
29
|
+
data[key] = value;
|
|
30
|
+
i++;
|
|
31
|
+
}
|
|
32
|
+
if (i >= lines.length) {
|
|
33
|
+
return { data: {}, body: text };
|
|
34
|
+
}
|
|
35
|
+
const body = lines.slice(i + 1).join("\n");
|
|
36
|
+
if (Object.keys(data).length === 0 && openIdx === 0) {
|
|
37
|
+
return { data: {}, body: text };
|
|
38
|
+
}
|
|
39
|
+
return { data, body };
|
|
40
|
+
}
|
|
41
|
+
function stripLineComment(line) {
|
|
42
|
+
let inQuote = false;
|
|
43
|
+
for (let i = 0; i < line.length; i++) {
|
|
44
|
+
const ch = line[i];
|
|
45
|
+
if (ch === '"') {
|
|
46
|
+
if (i > 0 && line[i - 1] === "\\") continue;
|
|
47
|
+
inQuote = !inQuote;
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (inQuote) continue;
|
|
51
|
+
if (ch === "%" && line[i + 1] === "%") return line.slice(0, i);
|
|
52
|
+
if (ch === "/" && line[i + 1] === "/") return line.slice(0, i);
|
|
53
|
+
if (ch === "#") return line.slice(0, i);
|
|
54
|
+
}
|
|
55
|
+
return line;
|
|
56
|
+
}
|
|
57
|
+
function firstContentLine(text) {
|
|
58
|
+
for (const raw of text.split(/\r?\n/)) {
|
|
59
|
+
const line = stripLineComment(raw).trim();
|
|
60
|
+
if (line !== "") return line;
|
|
61
|
+
}
|
|
62
|
+
return void 0;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export { firstContentLine, parseFrontmatter };
|
|
66
|
+
//# sourceMappingURL=chunk-2KTQ75LN.js.map
|
|
67
|
+
//# sourceMappingURL=chunk-2KTQ75LN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/dsl-preprocess.ts"],"names":[],"mappings":";AAoCA,IAAM,iBAAA,GAAoB,YAAA;AAWnB,SAAS,iBAAiB,IAAA,EAA8B;AAC7D,EAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,KAAA,CAAM,OAAO,CAAA;AAChC,EAAA,IAAI,CAAA,GAAI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GAAA,IAAO,IAAA,CAAK,CAAA,GAAI,CAAC,CAAA,KAAM,GAAA,EAAK,OAAO,IAAA,CAAK,KAAA,CAAM,CAAA,EAAG,CAAC,CAAA;AAC7D,IAAA,IAAI,EAAA,KAAO,GAAA,IAAO,IAAA,CAAK,CAAA,GAAI,CAAC,CAAA,KAAM,GAAA,EAAK,OAAO,IAAA,CAAK,KAAA,CAAM,CAAA,EAAG,CAAC,CAAA;AAC7D,IAAA,IAAI,OAAO,GAAA,EAAK,OAAO,IAAA,CAAK,KAAA,CAAM,GAAG,CAAC,CAAA;AAAA,EACxC;AACA,EAAA,OAAO,IAAA;AACT;AAQO,SAAS,iBAAiB,IAAA,EAAkC;AACjE,EAAA,KAAA,MAAW,GAAA,IAAO,IAAA,CAAK,KAAA,CAAM,OAAO,CAAA,EAAG;AACrC,IAAA,MAAM,IAAA,GAAO,gBAAA,CAAiB,GAAG,CAAA,CAAE,IAAA,EAAK;AACxC,IAAA,IAAI,IAAA,KAAS,IAAI,OAAO,IAAA;AAAA,EAC1B;AACA,EAAA,OAAO,MAAA;AACT","file":"chunk-2KTQ75LN.js","sourcesContent":["/**\n * DSL preprocessing shared across all diagram parsers.\n *\n * Two cross-cutting Mermaid-compat features are normalized here so each\n * per-diagram parser sees a consistent surface:\n *\n * 1. **Frontmatter** — Mermaid allows a YAML-style block at the top of\n * the input:\n *\n * ---\n * title: My diagram\n * ---\n * flowchart TD\n * ...\n *\n * We strip the block before the parser runs and return the parsed\n * keys as a metadata bag. Parsers that already accept an inline title\n * (`flowchart TD \"...\"`, `genogram \"...\"`) can merge the frontmatter\n * title in if no inline one was provided.\n *\n * 2. **Comments** — different parsers historically supported different\n * comment markers (`#`, `//`, Mermaid's `%%`). {@link stripLineComment}\n * strips all three, respecting double-quoted regions so URLs with `//`\n * and CSS-style values containing `#` don't get truncated.\n *\n * Both helpers are intentionally narrow: they only do what every parser\n * needs. Diagram-specific lexing stays in each parser.\n */\n\nexport interface DslFrontmatter {\n /** Parsed key/value pairs from the `---` block. Empty if no block found. */\n data: Record<string, string>;\n /** Input with the frontmatter block removed, ready for the diagram parser. */\n body: string;\n}\n\nconst FRONTMATTER_DELIM = /^-{3,}\\s*$/;\n\n/**\n * Strip a Mermaid-style YAML frontmatter block from the start of `text`.\n *\n * Accepts any whitespace-only or blank lines before the opening `---`. The\n * parser is deliberately tiny: one `key: value` per line, no nesting, no\n * quoted/multiline values. Anything fancier we treat as \"not a frontmatter\n * block\" and return the original text unchanged — better to no-op than\n * to silently swallow malformed YAML.\n */\nexport function parseFrontmatter(text: string): DslFrontmatter {\n const lines = text.split(/\\r?\\n/);\n let i = 0;\n while (i < lines.length && lines[i]!.trim() === \"\") i++;\n if (i >= lines.length || !FRONTMATTER_DELIM.test(lines[i]!)) {\n return { data: {}, body: text };\n }\n const openIdx = i;\n i++;\n const data: Record<string, string> = {};\n while (i < lines.length && !FRONTMATTER_DELIM.test(lines[i]!)) {\n const line = lines[i]!;\n const trimmed = line.trim();\n if (trimmed === \"\" || trimmed.startsWith(\"#\")) {\n i++;\n continue;\n }\n const colonIdx = trimmed.indexOf(\":\");\n if (colonIdx <= 0) {\n // Malformed line inside the block — bail out, treat the whole thing\n // as not-a-frontmatter so the user sees their original input back.\n return { data: {}, body: text };\n }\n const key = trimmed.slice(0, colonIdx).trim();\n let value = trimmed.slice(colonIdx + 1).trim();\n // Strip matching surrounding quotes (single, double, or smart) without\n // pulling in the full quotes.ts helpers — frontmatter values are dumb.\n if (\n value.length >= 2 &&\n ((value.startsWith('\"') && value.endsWith('\"')) ||\n (value.startsWith(\"'\") && value.endsWith(\"'\")) ||\n (value.startsWith(\"“\") && value.endsWith(\"”\")))\n ) {\n value = value.slice(1, -1);\n }\n data[key] = value;\n i++;\n }\n if (i >= lines.length) {\n // Opened a `---` block but never closed it — leave input untouched.\n return { data: {}, body: text };\n }\n // i now points at the closing `---`; body starts on the next line.\n const body = lines.slice(i + 1).join(\"\\n\");\n // If we found an opening delim but the body is empty and data is empty,\n // it was probably just a separator someone typed. Return raw text.\n if (Object.keys(data).length === 0 && openIdx === 0) {\n return { data: {}, body: text };\n }\n return { data, body };\n}\n\n/**\n * Strip an inline comment from a line.\n *\n * Recognized markers (in order of precedence):\n * - `%%` — Mermaid's comment style\n * - `//` — C-style line comment\n * - `#` — shell/python style\n *\n * Markers inside ASCII double-quoted regions are preserved verbatim so URLs\n * (`\"https://...\"`) and CSS-color values (`\"#ff0\"`) survive. Smart-quoted\n * regions are NOT special-cased — they're rare inside attribute strings,\n * and the cost of full Unicode quote tracking for every line isn't worth\n * the protection.\n */\nexport function stripLineComment(line: string): string {\n let inQuote = false;\n for (let i = 0; i < line.length; i++) {\n const ch = line[i]!;\n if (ch === '\"') {\n // Respect a backslash escape so `\"foo\\\"\"` stays inside the quote.\n if (i > 0 && line[i - 1] === \"\\\\\") continue;\n inQuote = !inQuote;\n continue;\n }\n if (inQuote) continue;\n if (ch === \"%\" && line[i + 1] === \"%\") return line.slice(0, i);\n if (ch === \"/\" && line[i + 1] === \"/\") return line.slice(0, i);\n if (ch === \"#\") return line.slice(0, i);\n }\n return line;\n}\n\n/** Returns true if the trimmed line is blank or a pure comment. */\nexport function isBlankOrComment(line: string): boolean {\n return stripLineComment(line).trim() === \"\";\n}\n\n/** Return the first non-blank, non-comment line after comment stripping. */\nexport function firstContentLine(text: string): string | undefined {\n for (const raw of text.split(/\\r?\\n/)) {\n const line = stripLineComment(raw).trim();\n if (line !== \"\") return line;\n }\n return undefined;\n}\n"]}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/core/dsl-preprocess.ts
|
|
4
|
+
var FRONTMATTER_DELIM = /^-{3,}\s*$/;
|
|
5
|
+
function parseFrontmatter(text) {
|
|
6
|
+
const lines = text.split(/\r?\n/);
|
|
7
|
+
let i = 0;
|
|
8
|
+
while (i < lines.length && lines[i].trim() === "") i++;
|
|
9
|
+
if (i >= lines.length || !FRONTMATTER_DELIM.test(lines[i])) {
|
|
10
|
+
return { data: {}, body: text };
|
|
11
|
+
}
|
|
12
|
+
const openIdx = i;
|
|
13
|
+
i++;
|
|
14
|
+
const data = {};
|
|
15
|
+
while (i < lines.length && !FRONTMATTER_DELIM.test(lines[i])) {
|
|
16
|
+
const line = lines[i];
|
|
17
|
+
const trimmed = line.trim();
|
|
18
|
+
if (trimmed === "" || trimmed.startsWith("#")) {
|
|
19
|
+
i++;
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
const colonIdx = trimmed.indexOf(":");
|
|
23
|
+
if (colonIdx <= 0) {
|
|
24
|
+
return { data: {}, body: text };
|
|
25
|
+
}
|
|
26
|
+
const key = trimmed.slice(0, colonIdx).trim();
|
|
27
|
+
let value = trimmed.slice(colonIdx + 1).trim();
|
|
28
|
+
if (value.length >= 2 && (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'") || value.startsWith("\u201C") && value.endsWith("\u201D"))) {
|
|
29
|
+
value = value.slice(1, -1);
|
|
30
|
+
}
|
|
31
|
+
data[key] = value;
|
|
32
|
+
i++;
|
|
33
|
+
}
|
|
34
|
+
if (i >= lines.length) {
|
|
35
|
+
return { data: {}, body: text };
|
|
36
|
+
}
|
|
37
|
+
const body = lines.slice(i + 1).join("\n");
|
|
38
|
+
if (Object.keys(data).length === 0 && openIdx === 0) {
|
|
39
|
+
return { data: {}, body: text };
|
|
40
|
+
}
|
|
41
|
+
return { data, body };
|
|
42
|
+
}
|
|
43
|
+
function stripLineComment(line) {
|
|
44
|
+
let inQuote = false;
|
|
45
|
+
for (let i = 0; i < line.length; i++) {
|
|
46
|
+
const ch = line[i];
|
|
47
|
+
if (ch === '"') {
|
|
48
|
+
if (i > 0 && line[i - 1] === "\\") continue;
|
|
49
|
+
inQuote = !inQuote;
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (inQuote) continue;
|
|
53
|
+
if (ch === "%" && line[i + 1] === "%") return line.slice(0, i);
|
|
54
|
+
if (ch === "/" && line[i + 1] === "/") return line.slice(0, i);
|
|
55
|
+
if (ch === "#") return line.slice(0, i);
|
|
56
|
+
}
|
|
57
|
+
return line;
|
|
58
|
+
}
|
|
59
|
+
function firstContentLine(text) {
|
|
60
|
+
for (const raw of text.split(/\r?\n/)) {
|
|
61
|
+
const line = stripLineComment(raw).trim();
|
|
62
|
+
if (line !== "") return line;
|
|
63
|
+
}
|
|
64
|
+
return void 0;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
exports.firstContentLine = firstContentLine;
|
|
68
|
+
exports.parseFrontmatter = parseFrontmatter;
|
|
69
|
+
//# sourceMappingURL=chunk-3KRL2EGN.cjs.map
|
|
70
|
+
//# sourceMappingURL=chunk-3KRL2EGN.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/dsl-preprocess.ts"],"names":[],"mappings":";;;AAoCA,IAAM,iBAAA,GAAoB,YAAA;AAWnB,SAAS,iBAAiB,IAAA,EAA8B;AAC7D,EAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,KAAA,CAAM,OAAO,CAAA;AAChC,EAAA,IAAI,CAAA,GAAI,CAAA;AACR,EAAA,OAAO,CAAA,GAAI,MAAM,MAAA,IAAU,KAAA,CAAM,CAAC,CAAA,CAAG,IAAA,OAAW,EAAA,EAAI,CAAA,EAAA;AACpD,EAAA,IAAI,CAAA,IAAK,MAAM,MAAA,IAAU,CAAC,kBAAkB,IAAA,CAAK,KAAA,CAAM,CAAC,CAAE,CAAA,EAAG;AAC3D,IAAA,OAAO,EAAE,IAAA,EAAM,EAAC,EAAG,MAAM,IAAA,EAAK;AAAA,EAChC;AACA,EAAA,MAAM,OAAA,GAAU,CAAA;AAChB,EAAA,CAAA,EAAA;AACA,EAAA,MAAM,OAA+B,EAAC;AACtC,EAAA,OAAO,CAAA,GAAI,MAAM,MAAA,IAAU,CAAC,kBAAkB,IAAA,CAAK,KAAA,CAAM,CAAC,CAAE,CAAA,EAAG;AAC7D,I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A,MAAM,IAAA,GAAO,gBAAA,CAAiB,GAAG,CAAA,CAAE,IAAA,EAAK;AACxC,IAAA,IAAI,IAAA,KAAS,IAAI,OAAO,IAAA;AAAA,EAC1B;AACA,EAAA,OAAO,MAAA;AACT","file":"chunk-3KRL2EGN.cjs","sourcesContent":["/**\n * DSL preprocessing shared across all diagram parsers.\n *\n * Two cross-cutting Mermaid-compat features are normalized here so each\n * per-diagram parser sees a consistent surface:\n *\n * 1. **Frontmatter** — Mermaid allows a YAML-style block at the top of\n * the input:\n *\n * ---\n * title: My diagram\n * ---\n * flowchart TD\n * ...\n *\n * We strip the block before the parser runs and return the parsed\n * keys as a metadata bag. Parsers that already accept an inline title\n * (`flowchart TD \"...\"`, `genogram \"...\"`) can merge the frontmatter\n * title in if no inline one was provided.\n *\n * 2. **Comments** — different parsers historically supported different\n * comment markers (`#`, `//`, Mermaid's `%%`). {@link stripLineComment}\n * strips all three, respecting double-quoted regions so URLs with `//`\n * and CSS-style values containing `#` don't get truncated.\n *\n * Both helpers are intentionally narrow: they only do what every parser\n * needs. Diagram-specific lexing stays in each parser.\n */\n\nexport interface DslFrontmatter {\n /** Parsed key/value pairs from the `---` block. Empty if no block found. */\n data: Record<string, string>;\n /** Input with the frontmatter block removed, ready for the diagram parser. */\n body: string;\n}\n\nconst FRONTMATTER_DELIM = /^-{3,}\\s*$/;\n\n/**\n * Strip a Mermaid-style YAML frontmatter block from the start of `text`.\n *\n * Accepts any whitespace-only or blank lines before the opening `---`. The\n * parser is deliberately tiny: one `key: value` per line, no nesting, no\n * quoted/multiline values. Anything fancier we treat as \"not a frontmatter\n * block\" and return the original text unchanged — better to no-op than\n * to silently swallow malformed YAML.\n */\nexport function parseFrontmatter(text: string): DslFrontmatter {\n const lines = text.split(/\\r?\\n/);\n let i = 0;\n while (i < lines.length && lines[i]!.trim() === \"\") i++;\n if (i >= lines.length || !FRONTMATTER_DELIM.test(lines[i]!)) {\n return { data: {}, body: text };\n }\n const openIdx = i;\n i++;\n const data: Record<string, string> = {};\n while (i < lines.length && !FRONTMATTER_DELIM.test(lines[i]!)) {\n const line = lines[i]!;\n const trimmed = line.trim();\n if (trimmed === \"\" || trimmed.startsWith(\"#\")) {\n i++;\n continue;\n }\n const colonIdx = trimmed.indexOf(\":\");\n if (colonIdx <= 0) {\n // Malformed line inside the block — bail out, treat the whole thing\n // as not-a-frontmatter so the user sees their original input back.\n return { data: {}, body: text };\n }\n const key = trimmed.slice(0, colonIdx).trim();\n let value = trimmed.slice(colonIdx + 1).trim();\n // Strip matching surrounding quotes (single, double, or smart) without\n // pulling in the full quotes.ts helpers — frontmatter values are dumb.\n if (\n value.length >= 2 &&\n ((value.startsWith('\"') && value.endsWith('\"')) ||\n (value.startsWith(\"'\") && value.endsWith(\"'\")) ||\n (value.startsWith(\"“\") && value.endsWith(\"”\")))\n ) {\n value = value.slice(1, -1);\n }\n data[key] = value;\n i++;\n }\n if (i >= lines.length) {\n // Opened a `---` block but never closed it — leave input untouched.\n return { data: {}, body: text };\n }\n // i now points at the closing `---`; body starts on the next line.\n const body = lines.slice(i + 1).join(\"\\n\");\n // If we found an opening delim but the body is empty and data is empty,\n // it was probably just a separator someone typed. Return raw text.\n if (Object.keys(data).length === 0 && openIdx === 0) {\n return { data: {}, body: text };\n }\n return { data, body };\n}\n\n/**\n * Strip an inline comment from a line.\n *\n * Recognized markers (in order of precedence):\n * - `%%` — Mermaid's comment style\n * - `//` — C-style line comment\n * - `#` — shell/python style\n *\n * Markers inside ASCII double-quoted regions are preserved verbatim so URLs\n * (`\"https://...\"`) and CSS-color values (`\"#ff0\"`) survive. Smart-quoted\n * regions are NOT special-cased — they're rare inside attribute strings,\n * and the cost of full Unicode quote tracking for every line isn't worth\n * the protection.\n */\nexport function stripLineComment(line: string): string {\n let inQuote = false;\n for (let i = 0; i < line.length; i++) {\n const ch = line[i]!;\n if (ch === '\"') {\n // Respect a backslash escape so `\"foo\\\"\"` stays inside the quote.\n if (i > 0 && line[i - 1] === \"\\\\\") continue;\n inQuote = !inQuote;\n continue;\n }\n if (inQuote) continue;\n if (ch === \"%\" && line[i + 1] === \"%\") return line.slice(0, i);\n if (ch === \"/\" && line[i + 1] === \"/\") return line.slice(0, i);\n if (ch === \"#\") return line.slice(0, i);\n }\n return line;\n}\n\n/** Returns true if the trimmed line is blank or a pure comment. */\nexport function isBlankOrComment(line: string): boolean {\n return stripLineComment(line).trim() === \"\";\n}\n\n/** Return the first non-blank, non-comment line after comment stripping. */\nexport function firstContentLine(text: string): string | undefined {\n for (const raw of text.split(/\\r?\\n/)) {\n const line = stripLineComment(raw).trim();\n if (line !== \"\") return line;\n }\n return undefined;\n}\n"]}
|