schematex 0.6.7 → 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 (35) hide show
  1. package/README.md +115 -3
  2. package/README.zh-CN.md +783 -0
  3. package/dist/ai/ai-sdk.cjs +8 -8
  4. package/dist/ai/ai-sdk.d.cts +1 -1
  5. package/dist/ai/ai-sdk.d.ts +1 -1
  6. package/dist/ai/ai-sdk.js +3 -3
  7. package/dist/ai/index.cjs +14 -14
  8. package/dist/ai/index.js +3 -3
  9. package/dist/browser.cjs +9 -9
  10. package/dist/browser.js +3 -3
  11. package/dist/{chunk-WAKRRGAV.js → chunk-2TUZ3QJA.js} +110 -2
  12. package/dist/chunk-2TUZ3QJA.js.map +1 -0
  13. package/dist/{chunk-LDONE225.cjs → chunk-AGBY7KLL.cjs} +73 -16
  14. package/dist/chunk-AGBY7KLL.cjs.map +1 -0
  15. package/dist/{chunk-WK36Z63Y.cjs → chunk-EDXDFKYO.cjs} +7 -7
  16. package/dist/{chunk-WK36Z63Y.cjs.map → chunk-EDXDFKYO.cjs.map} +1 -1
  17. package/dist/{chunk-TRUJ4Q6V.js → chunk-J2TT7PGI.js} +72 -15
  18. package/dist/chunk-J2TT7PGI.js.map +1 -0
  19. package/dist/{chunk-QBS4F44Q.cjs → chunk-J3EPFZPX.cjs} +110 -2
  20. package/dist/chunk-J3EPFZPX.cjs.map +1 -0
  21. package/dist/{chunk-EVEPI423.js → chunk-QZ2OBNAS.js} +5 -5
  22. package/dist/{chunk-EVEPI423.js.map → chunk-QZ2OBNAS.js.map} +1 -1
  23. package/dist/diagrams/circuit/index.cjs +8 -8
  24. package/dist/diagrams/circuit/index.d.cts +0 -9
  25. package/dist/diagrams/circuit/index.d.ts +0 -9
  26. package/dist/diagrams/circuit/index.js +1 -1
  27. package/dist/index.cjs +27 -27
  28. package/dist/index.js +4 -4
  29. package/dist/react.cjs +3 -3
  30. package/dist/react.js +2 -2
  31. package/package.json +2 -2
  32. package/dist/chunk-LDONE225.cjs.map +0 -1
  33. package/dist/chunk-QBS4F44Q.cjs.map +0 -1
  34. package/dist/chunk-TRUJ4Q6V.js.map +0 -1
  35. package/dist/chunk-WAKRRGAV.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { orgchart } from './chunk-MPCSWRZC.js';
2
- import { circuit } from './chunk-WAKRRGAV.js';
2
+ import { circuit } from './chunk-2TUZ3QJA.js';
3
3
  import { blockdiagram } from './chunk-C7V57V6O.js';
4
4
  import { ladder } from './chunk-WU2N6ZVM.js';
5
5
  import { sld } from './chunk-JTGTWBAD.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)) {
@@ -26577,8 +26605,33 @@ function detectPlugin(text2, config) {
26577
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'."
26578
26606
  );
26579
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
+ }
26580
26633
  function preprocess8(text2) {
26581
- const { data, body } = parseFrontmatter(text2);
26634
+ const { data, body } = parseFrontmatter(stripCodeFences(text2));
26582
26635
  if (!data.title) return body;
26583
26636
  const safeTitle = data.title.replace(/"/g, '\\"');
26584
26637
  const lines = body.split("\n");
@@ -26592,8 +26645,9 @@ function preprocess8(text2) {
26592
26645
  return body;
26593
26646
  }
26594
26647
  function parse(text2, config) {
26595
- const prepared = preprocess8(text2);
26596
- const plugin = detectPlugin(prepared, config);
26648
+ const prepared0 = preprocess8(text2);
26649
+ const plugin = detectPlugin(prepared0, config);
26650
+ const prepared = normalizeHeader(prepared0, plugin.type);
26597
26651
  if (plugin.parse) return plugin.parse(prepared);
26598
26652
  throw new Error(
26599
26653
  `Diagram type '${plugin.type}' does not yet expose a parse() method.`
@@ -26602,13 +26656,14 @@ function parse(text2, config) {
26602
26656
  function parseResult(text2, config) {
26603
26657
  let plugin;
26604
26658
  try {
26605
- const prepared = preprocess8(text2);
26606
- plugin = detectPlugin(prepared, config);
26659
+ const prepared0 = preprocess8(text2);
26660
+ plugin = detectPlugin(prepared0, config);
26607
26661
  if (!plugin.parse) {
26608
26662
  throw new Error(
26609
26663
  `Diagram type '${plugin.type}' does not yet expose a parse() method.`
26610
26664
  );
26611
26665
  }
26666
+ const prepared = normalizeHeader(prepared0, plugin.type);
26612
26667
  const ast = plugin.parse(prepared);
26613
26668
  const diagnostics = runLint(plugin, prepared);
26614
26669
  return {
@@ -26637,15 +26692,17 @@ function runLint(plugin, prepared) {
26637
26692
  }
26638
26693
  function render(text2, config) {
26639
26694
  if (config?.mode === "preview") return renderResult(text2, config).svg;
26640
- const prepared = preprocess8(text2);
26641
- const plugin = detectPlugin(prepared, config);
26695
+ const prepared0 = preprocess8(text2);
26696
+ const plugin = detectPlugin(prepared0, config);
26697
+ const prepared = normalizeHeader(prepared0, plugin.type);
26642
26698
  return renderWithPlugin(prepared, plugin, config);
26643
26699
  }
26644
26700
  function renderResult(text2, config) {
26645
26701
  let plugin;
26646
26702
  try {
26647
- const prepared = preprocess8(text2);
26648
- plugin = detectPlugin(prepared, config);
26703
+ const prepared0 = preprocess8(text2);
26704
+ plugin = detectPlugin(prepared0, config);
26705
+ const prepared = normalizeHeader(prepared0, plugin.type);
26649
26706
  const svg = renderWithPlugin(prepared, plugin, config);
26650
26707
  const diagnostics = runLint(plugin, prepared);
26651
26708
  return {
@@ -26683,5 +26740,5 @@ function renderWithPlugin(prepared, plugin, config) {
26683
26740
  }
26684
26741
 
26685
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 };
26686
- //# sourceMappingURL=chunk-TRUJ4Q6V.js.map
26687
- //# sourceMappingURL=chunk-TRUJ4Q6V.js.map
26743
+ //# sourceMappingURL=chunk-J2TT7PGI.js.map
26744
+ //# sourceMappingURL=chunk-J2TT7PGI.js.map