schematex 0.6.6 → 0.6.8

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 (105) hide show
  1. package/README.md +115 -3
  2. package/README.zh-CN.md +783 -0
  3. package/dist/ai/ai-sdk.cjs +11 -11
  4. package/dist/ai/ai-sdk.d.cts +4 -4
  5. package/dist/ai/ai-sdk.d.ts +4 -4
  6. package/dist/ai/ai-sdk.js +6 -6
  7. package/dist/ai/index.cjs +17 -17
  8. package/dist/ai/index.d.cts +3 -3
  9. package/dist/ai/index.d.ts +3 -3
  10. package/dist/ai/index.js +6 -6
  11. package/dist/{api-QFMTlIi7.d.ts → api-DIJM_mqp.d.ts} +1 -1
  12. package/dist/{api-DA4-U-jn.d.cts → api-JaBtsUT8.d.cts} +1 -1
  13. package/dist/browser.cjs +12 -12
  14. package/dist/browser.d.cts +3 -3
  15. package/dist/browser.d.ts +3 -3
  16. package/dist/browser.js +6 -6
  17. package/dist/{chunk-KJZCRHNR.js → chunk-2TUZ3QJA.js} +623 -9
  18. package/dist/chunk-2TUZ3QJA.js.map +1 -0
  19. package/dist/{chunk-EUVUO3CL.cjs → chunk-34O3C6OC.cjs} +2 -2
  20. package/dist/{chunk-EUVUO3CL.cjs.map → chunk-34O3C6OC.cjs.map} +1 -1
  21. package/dist/{chunk-MLLARXOI.cjs → chunk-AGBY7KLL.cjs} +131 -27
  22. package/dist/chunk-AGBY7KLL.cjs.map +1 -0
  23. package/dist/{chunk-EPKIJEH7.js → chunk-C7V57V6O.js} +54 -8
  24. package/dist/chunk-C7V57V6O.js.map +1 -0
  25. package/dist/{chunk-CMZKAASF.cjs → chunk-EDXDFKYO.cjs} +16 -8
  26. package/dist/chunk-EDXDFKYO.cjs.map +1 -0
  27. package/dist/{chunk-FOPOOV2P.js → chunk-J2TT7PGI.js} +127 -23
  28. package/dist/chunk-J2TT7PGI.js.map +1 -0
  29. package/dist/{chunk-DO2DDHTQ.cjs → chunk-J3EPFZPX.cjs} +623 -8
  30. package/dist/chunk-J3EPFZPX.cjs.map +1 -0
  31. package/dist/{chunk-KCHUQXS3.js → chunk-JTGTWBAD.js} +2 -2
  32. package/dist/{chunk-KCHUQXS3.js.map → chunk-JTGTWBAD.js.map} +1 -1
  33. package/dist/{chunk-7DAIEDQP.js → chunk-MPCSWRZC.js} +75 -13
  34. package/dist/chunk-MPCSWRZC.js.map +1 -0
  35. package/dist/{chunk-3HZW6K5I.js → chunk-QZ2OBNAS.js} +14 -6
  36. package/dist/chunk-QZ2OBNAS.js.map +1 -0
  37. package/dist/{chunk-SUIDD2C5.cjs → chunk-SHMG7BVF.cjs} +54 -8
  38. package/dist/chunk-SHMG7BVF.cjs.map +1 -0
  39. package/dist/{chunk-XYHCAJMI.cjs → chunk-UHPGWO77.cjs} +75 -12
  40. package/dist/chunk-UHPGWO77.cjs.map +1 -0
  41. package/dist/{diagnostics-CSznf_sl.d.cts → diagnostics-BKRow1ur.d.cts} +14 -0
  42. package/dist/{diagnostics-CSznf_sl.d.ts → diagnostics-BKRow1ur.d.ts} +14 -0
  43. package/dist/diagrams/blockdiagram/index.cjs +5 -5
  44. package/dist/diagrams/blockdiagram/index.d.cts +1 -1
  45. package/dist/diagrams/blockdiagram/index.d.ts +1 -1
  46. package/dist/diagrams/blockdiagram/index.js +1 -1
  47. package/dist/diagrams/circuit/index.cjs +11 -7
  48. package/dist/diagrams/circuit/index.d.cts +4 -2
  49. package/dist/diagrams/circuit/index.d.ts +4 -2
  50. package/dist/diagrams/circuit/index.js +1 -1
  51. package/dist/diagrams/ecomap/index.d.cts +1 -1
  52. package/dist/diagrams/ecomap/index.d.ts +1 -1
  53. package/dist/diagrams/entity/index.d.cts +1 -1
  54. package/dist/diagrams/entity/index.d.ts +1 -1
  55. package/dist/diagrams/fishbone/index.d.cts +1 -1
  56. package/dist/diagrams/fishbone/index.d.ts +1 -1
  57. package/dist/diagrams/flowchart/index.d.cts +2 -2
  58. package/dist/diagrams/flowchart/index.d.ts +2 -2
  59. package/dist/diagrams/genogram/index.d.cts +1 -1
  60. package/dist/diagrams/genogram/index.d.ts +1 -1
  61. package/dist/diagrams/ladder/index.d.cts +1 -1
  62. package/dist/diagrams/ladder/index.d.ts +1 -1
  63. package/dist/diagrams/logic/index.d.cts +1 -1
  64. package/dist/diagrams/logic/index.d.ts +1 -1
  65. package/dist/diagrams/orgchart/index.cjs +10 -6
  66. package/dist/diagrams/orgchart/index.d.cts +27 -2
  67. package/dist/diagrams/orgchart/index.d.ts +27 -2
  68. package/dist/diagrams/orgchart/index.js +1 -1
  69. package/dist/diagrams/pedigree/index.d.cts +1 -1
  70. package/dist/diagrams/pedigree/index.d.ts +1 -1
  71. package/dist/diagrams/phylo/index.d.cts +1 -1
  72. package/dist/diagrams/phylo/index.d.ts +1 -1
  73. package/dist/diagrams/sld/index.cjs +7 -7
  74. package/dist/diagrams/sld/index.d.cts +1 -1
  75. package/dist/diagrams/sld/index.d.ts +1 -1
  76. package/dist/diagrams/sld/index.js +1 -1
  77. package/dist/diagrams/sociogram/index.d.cts +1 -1
  78. package/dist/diagrams/sociogram/index.d.ts +1 -1
  79. package/dist/diagrams/timing/index.d.cts +1 -1
  80. package/dist/diagrams/timing/index.d.ts +1 -1
  81. package/dist/diagrams/venn/index.d.cts +1 -1
  82. package/dist/diagrams/venn/index.d.ts +1 -1
  83. package/dist/{index-CDpYuU7l.d.cts → index-DU2h1Y-a.d.cts} +1 -1
  84. package/dist/{index-jTwjudTW.d.ts → index-Dq3Mfxay.d.ts} +1 -1
  85. package/dist/index.cjs +35 -35
  86. package/dist/index.d.cts +4 -4
  87. package/dist/index.d.ts +4 -4
  88. package/dist/index.js +8 -8
  89. package/dist/react.cjs +6 -6
  90. package/dist/react.d.cts +2 -2
  91. package/dist/react.d.ts +2 -2
  92. package/dist/react.js +5 -5
  93. package/dist/{tools-CbuSbW6B.d.cts → tools-A0HRZ8jj.d.ts} +11 -2
  94. package/dist/{tools-D344vOzR.d.ts → tools-OzOQnlnV.d.cts} +11 -2
  95. package/package.json +2 -2
  96. package/dist/chunk-3HZW6K5I.js.map +0 -1
  97. package/dist/chunk-7DAIEDQP.js.map +0 -1
  98. package/dist/chunk-CMZKAASF.cjs.map +0 -1
  99. package/dist/chunk-DO2DDHTQ.cjs.map +0 -1
  100. package/dist/chunk-EPKIJEH7.js.map +0 -1
  101. package/dist/chunk-FOPOOV2P.js.map +0 -1
  102. package/dist/chunk-KJZCRHNR.js.map +0 -1
  103. package/dist/chunk-MLLARXOI.cjs.map +0 -1
  104. package/dist/chunk-SUIDD2C5.cjs.map +0 -1
  105. package/dist/chunk-XYHCAJMI.cjs.map +0 -1
@@ -1,8 +1,8 @@
1
- import { orgchart } from './chunk-7DAIEDQP.js';
2
- import { circuit } from './chunk-KJZCRHNR.js';
3
- import { blockdiagram } from './chunk-EPKIJEH7.js';
1
+ import { orgchart } from './chunk-MPCSWRZC.js';
2
+ import { circuit } from './chunk-2TUZ3QJA.js';
3
+ import { blockdiagram } from './chunk-C7V57V6O.js';
4
4
  import { ladder } from './chunk-WU2N6ZVM.js';
5
- import { sld } from './chunk-KCHUQXS3.js';
5
+ import { sld } from './chunk-JTGTWBAD.js';
6
6
  import { entity } from './chunk-YMZTXOUG.js';
7
7
  import { fishbone } from './chunk-YTGOLTLJ.js';
8
8
  import { venn } from './chunk-T3FV73LM.js';
@@ -14905,6 +14905,7 @@ function layoutUmlClass(ast) {
14905
14905
  n.box.layer = n.rank;
14906
14906
  }
14907
14907
  }
14908
+ applyDirectionTransform(direction, nodes, boxes);
14908
14909
  normaliseCoords(nodes, boxes);
14909
14910
  const packages = layoutPackages(ast, boxByID);
14910
14911
  shiftForPackages(nodes, boxes, packages);
@@ -14912,6 +14913,29 @@ function layoutUmlClass(ast) {
14912
14913
  const { edges, trees } = routeEdges(chains, nodes, boxByID, vertical);
14913
14914
  return { ast, boxes, packages, edges, trees, width, height };
14914
14915
  }
14916
+ function applyDirectionTransform(direction, nodes, boxes) {
14917
+ if (direction === "tb") return;
14918
+ const transform = (p) => {
14919
+ switch (direction) {
14920
+ case "bt":
14921
+ return { x: p.x, y: -p.y };
14922
+ case "lr":
14923
+ return { x: p.y, y: p.x };
14924
+ case "rl":
14925
+ return { x: -p.y, y: p.x };
14926
+ }
14927
+ };
14928
+ for (const n of nodes) {
14929
+ const p = transform({ x: n.cx, y: n.cy });
14930
+ n.cx = p.x;
14931
+ n.cy = p.y;
14932
+ }
14933
+ for (const b of boxes) {
14934
+ const c = transform({ x: b.x + b.width / 2, y: b.y + b.height / 2 });
14935
+ b.x = c.x - b.width / 2;
14936
+ b.y = c.y - b.height / 2;
14937
+ }
14938
+ }
14915
14939
  function topLevelPackageMap(ast) {
14916
14940
  const parentOf = /* @__PURE__ */ new Map();
14917
14941
  for (const p of ast.packages) parentOf.set(p.id, p.parentId);
@@ -16187,12 +16211,14 @@ function parseFaultTree(text2) {
16187
16211
  }
16188
16212
  if (/^layout\s*:/i.test(t)) {
16189
16213
  const v = afterColon2(t).toLowerCase();
16190
- if (v === "tb" || v === "bt") ast.direction = v;
16214
+ if (v === "tb") ast.direction = v;
16215
+ else if (v === "bt") ast.warnings.push(`Line ${lineNo}: layout: bt is reserved but not implemented yet; using layout: tb.`);
16191
16216
  continue;
16192
16217
  }
16193
16218
  if (/^style\s*:/i.test(t)) {
16194
16219
  const v = afterColon2(t).toLowerCase();
16195
- if (v === "ansi" || v === "iec") ast.gateStyle = v;
16220
+ if (v === "ansi") ast.gateStyle = v;
16221
+ else if (v === "iec") ast.warnings.push(`Line ${lineNo}: style: iec is reserved but not implemented yet; using style: ansi.`);
16196
16222
  continue;
16197
16223
  }
16198
16224
  if (/^transfer\b/i.test(t)) {
@@ -17226,6 +17252,7 @@ function summarise(layout) {
17226
17252
  if (analysis.topProb !== void 0) parts.push(`P(top) = ${fmtProb(analysis.topProb)} (${analysis.method}).`);
17227
17253
  else if (analysis.missingProb.length > 0) parts.push(`P(top) = n/a \u2014 missing p on ${analysis.missingProb.join(", ")}.`);
17228
17254
  }
17255
+ for (const w of ast.warnings) parts.push(w);
17229
17256
  for (const n of analysis.notes) parts.push(n);
17230
17257
  for (const w of analysis.warnings) parts.push(w);
17231
17258
  return parts.join(" ");
@@ -17322,7 +17349,8 @@ function parseBowtie(text2) {
17322
17349
  const lineNo = i + 1;
17323
17350
  if (/^layout\s*:/i.test(t)) {
17324
17351
  const v = afterColon3(t).toLowerCase();
17325
- if (v === "symmetric" || v === "compact") ast.layout = v;
17352
+ if (v === "symmetric") ast.layout = v;
17353
+ else if (v === "compact") ast.warnings.push(`Line ${lineNo}: layout: compact is reserved but not implemented yet; using layout: symmetric.`);
17326
17354
  continue;
17327
17355
  }
17328
17356
  if (/^legend\s*:/i.test(t)) {
@@ -18247,14 +18275,23 @@ function parseMindmap(text2) {
18247
18275
  const lines = allLines;
18248
18276
  const directives = { style: "map", maxLabelWidth: DEFAULT_MAX_LABEL_WIDTH };
18249
18277
  let root = null;
18278
+ let rootInferred;
18250
18279
  let idCounter2 = 0;
18251
18280
  const nextId2 = () => `n${idCounter2++}`;
18252
18281
  const stack = [];
18253
18282
  let lastHeadingDepth = 0;
18254
- const attach = (node, depth, lineNo, source) => {
18283
+ const ensurePlaceholderRoot = () => {
18284
+ if (root) return root;
18285
+ root = makeNode(nextId2(), "Mindmap", 0);
18286
+ rootInferred = "placeholder";
18287
+ stack.length = 0;
18288
+ stack.push({ node: root, depth: 0 });
18289
+ lastHeadingDepth = 0;
18290
+ return root;
18291
+ };
18292
+ const attach = (node, depth, _lineNo, _source) => {
18255
18293
  while (stack.length && stack[stack.length - 1].depth >= depth) stack.pop();
18256
- const parent = stack[stack.length - 1]?.node;
18257
- if (!parent) throw new MindmapParseError("orphan node \u2014 expected root # heading first", lineNo, void 0, source);
18294
+ const parent = stack[stack.length - 1]?.node ?? ensurePlaceholderRoot();
18258
18295
  node.depth = parent.depth + 1;
18259
18296
  parent.children.push(node);
18260
18297
  stack.push({ node, depth });
@@ -18280,7 +18317,7 @@ function parseMindmap(text2) {
18280
18317
  stack.length = 0;
18281
18318
  stack.push({ node, depth: 0 });
18282
18319
  } else {
18283
- attach(node, depth, lineNo, line2);
18320
+ attach(node, depth);
18284
18321
  }
18285
18322
  lastHeadingDepth = depth;
18286
18323
  continue;
@@ -18291,7 +18328,14 @@ function parseMindmap(text2) {
18291
18328
  const depth = lastHeadingDepth + 1 + Math.floor(indent / 2);
18292
18329
  const label = bullet[2].trim();
18293
18330
  const node = makeNode(nextId2(), label, depth);
18294
- attach(node, depth, lineNo, line2);
18331
+ attach(node, depth);
18332
+ continue;
18333
+ }
18334
+ if (!root && stack.length === 0) {
18335
+ root = makeNode(nextId2(), trimmed, 0);
18336
+ rootInferred = "line";
18337
+ stack.push({ node: root, depth: 0 });
18338
+ lastHeadingDepth = 0;
18295
18339
  continue;
18296
18340
  }
18297
18341
  }
@@ -18302,10 +18346,40 @@ function parseMindmap(text2) {
18302
18346
  root,
18303
18347
  maxLabelWidth: directives.maxLabelWidth
18304
18348
  };
18349
+ if (rootInferred) ast.rootInferred = rootInferred;
18305
18350
  if (directives.themeOverride) ast.themeOverride = directives.themeOverride;
18306
18351
  return ast;
18307
18352
  }
18308
18353
 
18354
+ // src/diagrams/mindmap/lint.ts
18355
+ function lintMindmap(text2) {
18356
+ let ast;
18357
+ try {
18358
+ ast = parseMindmap(text2);
18359
+ } catch {
18360
+ return [];
18361
+ }
18362
+ const out = [];
18363
+ if (ast.rootInferred === "line") {
18364
+ out.push({
18365
+ severity: "warning",
18366
+ code: "MINDMAP_SYNTHESIZED_ROOT",
18367
+ message: `no \`# Title\` heading found; adopted the first line "${ast.root.label}" as the central topic`,
18368
+ hint: "Mark the central topic explicitly with a single leading `# Title` line, e.g. `# My Topic`.",
18369
+ fatal: false
18370
+ });
18371
+ } else if (ast.rootInferred === "placeholder") {
18372
+ out.push({
18373
+ severity: "warning",
18374
+ code: "MINDMAP_SYNTHESIZED_ROOT",
18375
+ message: "no central topic found; inserted a placeholder root over the top-level branches",
18376
+ hint: "Start the mindmap with a single `# Title` line to name the center, e.g. `# My Topic`, with branches as `- item` bullets below it.",
18377
+ fatal: false
18378
+ });
18379
+ }
18380
+ return out;
18381
+ }
18382
+
18309
18383
  // src/diagrams/mindmap/layout.ts
18310
18384
  var PADDING2 = 40;
18311
18385
  var SIBLING_GAP = 18;
@@ -18810,6 +18884,7 @@ var mindmap = {
18810
18884
  return false;
18811
18885
  },
18812
18886
  parse: parseMindmap,
18887
+ lint: lintMindmap,
18813
18888
  render(text2, config) {
18814
18889
  return renderMindmap(text2, {
18815
18890
  theme: config?.theme,
@@ -26530,8 +26605,33 @@ function detectPlugin(text2, config) {
26530
26605
  "Cannot detect diagram type. Start your text with 'genogram', 'ecomap', 'pedigree', 'phylo', 'sociogram', 'timing', 'logic', 'circuit', 'blockdiagram', 'ladder', 'sld', 'entity-structure', 'fishbone', 'venn', 'flowchart', 'mindmap', 'matrix', 'orgchart', 'state', 'pid', 'erd', 'breadboard', 'bpmn', 'fbd', 'sfc', 'prisma', 'usecase', 'pert', 'sequence', 'petri', 'network', 'umlclass', 'faulttree', or 'bowtie'."
26531
26606
  );
26532
26607
  }
26608
+ function stripCodeFences(text2) {
26609
+ let t = text2;
26610
+ t = t.replace(/^\uFEFF?[ \t]*```[A-Za-z0-9_-]*[ \t]*\r?\n/, "");
26611
+ t = t.replace(/\r?\n[ \t]*```[ \t]*$/, "");
26612
+ return t;
26613
+ }
26614
+ function normalizeHeader(text2, type) {
26615
+ const lines = text2.split("\n");
26616
+ for (let i = 0; i < lines.length; i++) {
26617
+ const trimmed = lines[i].trim();
26618
+ if (!trimmed) continue;
26619
+ const m = trimmed.match(/^([A-Za-z][A-Za-z0-9_-]*)/);
26620
+ if (!m) return text2;
26621
+ const tok = m[1];
26622
+ const lower = tok.toLowerCase();
26623
+ if (lower === type) return text2;
26624
+ if (lower.length >= 3 && type.startsWith(lower)) {
26625
+ const idx = lines[i].indexOf(tok);
26626
+ lines[i] = lines[i].slice(0, idx) + type + lines[i].slice(idx + tok.length);
26627
+ return lines.join("\n");
26628
+ }
26629
+ return text2;
26630
+ }
26631
+ return text2;
26632
+ }
26533
26633
  function preprocess8(text2) {
26534
- const { data, body } = parseFrontmatter(text2);
26634
+ const { data, body } = parseFrontmatter(stripCodeFences(text2));
26535
26635
  if (!data.title) return body;
26536
26636
  const safeTitle = data.title.replace(/"/g, '\\"');
26537
26637
  const lines = body.split("\n");
@@ -26545,8 +26645,9 @@ function preprocess8(text2) {
26545
26645
  return body;
26546
26646
  }
26547
26647
  function parse(text2, config) {
26548
- const prepared = preprocess8(text2);
26549
- const plugin = detectPlugin(prepared, config);
26648
+ const prepared0 = preprocess8(text2);
26649
+ const plugin = detectPlugin(prepared0, config);
26650
+ const prepared = normalizeHeader(prepared0, plugin.type);
26550
26651
  if (plugin.parse) return plugin.parse(prepared);
26551
26652
  throw new Error(
26552
26653
  `Diagram type '${plugin.type}' does not yet expose a parse() method.`
@@ -26555,13 +26656,14 @@ function parse(text2, config) {
26555
26656
  function parseResult(text2, config) {
26556
26657
  let plugin;
26557
26658
  try {
26558
- const prepared = preprocess8(text2);
26559
- plugin = detectPlugin(prepared, config);
26659
+ const prepared0 = preprocess8(text2);
26660
+ plugin = detectPlugin(prepared0, config);
26560
26661
  if (!plugin.parse) {
26561
26662
  throw new Error(
26562
26663
  `Diagram type '${plugin.type}' does not yet expose a parse() method.`
26563
26664
  );
26564
26665
  }
26666
+ const prepared = normalizeHeader(prepared0, plugin.type);
26565
26667
  const ast = plugin.parse(prepared);
26566
26668
  const diagnostics = runLint(plugin, prepared);
26567
26669
  return {
@@ -26590,15 +26692,17 @@ function runLint(plugin, prepared) {
26590
26692
  }
26591
26693
  function render(text2, config) {
26592
26694
  if (config?.mode === "preview") return renderResult(text2, config).svg;
26593
- const prepared = preprocess8(text2);
26594
- const plugin = detectPlugin(prepared, config);
26695
+ const prepared0 = preprocess8(text2);
26696
+ const plugin = detectPlugin(prepared0, config);
26697
+ const prepared = normalizeHeader(prepared0, plugin.type);
26595
26698
  return renderWithPlugin(prepared, plugin, config);
26596
26699
  }
26597
26700
  function renderResult(text2, config) {
26598
26701
  let plugin;
26599
26702
  try {
26600
- const prepared = preprocess8(text2);
26601
- plugin = detectPlugin(prepared, config);
26703
+ const prepared0 = preprocess8(text2);
26704
+ plugin = detectPlugin(prepared0, config);
26705
+ const prepared = normalizeHeader(prepared0, plugin.type);
26602
26706
  const svg = renderWithPlugin(prepared, plugin, config);
26603
26707
  const diagnostics = runLint(plugin, prepared);
26604
26708
  return {
@@ -26636,5 +26740,5 @@ function renderWithPlugin(prepared, plugin, config) {
26636
26740
  }
26637
26741
 
26638
26742
  export { GEOMETRY, bowtie2 as bowtie, decisiontree, drawDeviceIcon, faulttree, iconSize, network, parse, parseResult, pert, petri, pid, prisma, render, renderEquip, renderPreview, renderResult, sequence, state, timeline, umlclass, usecase };
26639
- //# sourceMappingURL=chunk-FOPOOV2P.js.map
26640
- //# sourceMappingURL=chunk-FOPOOV2P.js.map
26743
+ //# sourceMappingURL=chunk-J2TT7PGI.js.map
26744
+ //# sourceMappingURL=chunk-J2TT7PGI.js.map