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,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkUHPGWO77_cjs = require('./chunk-UHPGWO77.cjs');
4
- var chunkQBS4F44Q_cjs = require('./chunk-QBS4F44Q.cjs');
4
+ var chunkJ3EPFZPX_cjs = require('./chunk-J3EPFZPX.cjs');
5
5
  var chunkSHMG7BVF_cjs = require('./chunk-SHMG7BVF.cjs');
6
6
  var chunkTACTEF2N_cjs = require('./chunk-TACTEF2N.cjs');
7
7
  var chunk34O3C6OC_cjs = require('./chunk-34O3C6OC.cjs');
@@ -14907,6 +14907,7 @@ function layoutUmlClass(ast) {
14907
14907
  n.box.layer = n.rank;
14908
14908
  }
14909
14909
  }
14910
+ applyDirectionTransform(direction, nodes, boxes);
14910
14911
  normaliseCoords(nodes, boxes);
14911
14912
  const packages = layoutPackages(ast, boxByID);
14912
14913
  shiftForPackages(nodes, boxes, packages);
@@ -14914,6 +14915,29 @@ function layoutUmlClass(ast) {
14914
14915
  const { edges, trees } = routeEdges(chains, nodes, boxByID, vertical);
14915
14916
  return { ast, boxes, packages, edges, trees, width, height };
14916
14917
  }
14918
+ function applyDirectionTransform(direction, nodes, boxes) {
14919
+ if (direction === "tb") return;
14920
+ const transform = (p) => {
14921
+ switch (direction) {
14922
+ case "bt":
14923
+ return { x: p.x, y: -p.y };
14924
+ case "lr":
14925
+ return { x: p.y, y: p.x };
14926
+ case "rl":
14927
+ return { x: -p.y, y: p.x };
14928
+ }
14929
+ };
14930
+ for (const n of nodes) {
14931
+ const p = transform({ x: n.cx, y: n.cy });
14932
+ n.cx = p.x;
14933
+ n.cy = p.y;
14934
+ }
14935
+ for (const b of boxes) {
14936
+ const c = transform({ x: b.x + b.width / 2, y: b.y + b.height / 2 });
14937
+ b.x = c.x - b.width / 2;
14938
+ b.y = c.y - b.height / 2;
14939
+ }
14940
+ }
14917
14941
  function topLevelPackageMap(ast) {
14918
14942
  const parentOf = /* @__PURE__ */ new Map();
14919
14943
  for (const p of ast.packages) parentOf.set(p.id, p.parentId);
@@ -16189,12 +16213,14 @@ function parseFaultTree(text2) {
16189
16213
  }
16190
16214
  if (/^layout\s*:/i.test(t)) {
16191
16215
  const v = afterColon2(t).toLowerCase();
16192
- if (v === "tb" || v === "bt") ast.direction = v;
16216
+ if (v === "tb") ast.direction = v;
16217
+ else if (v === "bt") ast.warnings.push(`Line ${lineNo}: layout: bt is reserved but not implemented yet; using layout: tb.`);
16193
16218
  continue;
16194
16219
  }
16195
16220
  if (/^style\s*:/i.test(t)) {
16196
16221
  const v = afterColon2(t).toLowerCase();
16197
- if (v === "ansi" || v === "iec") ast.gateStyle = v;
16222
+ if (v === "ansi") ast.gateStyle = v;
16223
+ else if (v === "iec") ast.warnings.push(`Line ${lineNo}: style: iec is reserved but not implemented yet; using style: ansi.`);
16198
16224
  continue;
16199
16225
  }
16200
16226
  if (/^transfer\b/i.test(t)) {
@@ -17228,6 +17254,7 @@ function summarise(layout) {
17228
17254
  if (analysis.topProb !== void 0) parts.push(`P(top) = ${fmtProb(analysis.topProb)} (${analysis.method}).`);
17229
17255
  else if (analysis.missingProb.length > 0) parts.push(`P(top) = n/a \u2014 missing p on ${analysis.missingProb.join(", ")}.`);
17230
17256
  }
17257
+ for (const w of ast.warnings) parts.push(w);
17231
17258
  for (const n of analysis.notes) parts.push(n);
17232
17259
  for (const w of analysis.warnings) parts.push(w);
17233
17260
  return parts.join(" ");
@@ -17324,7 +17351,8 @@ function parseBowtie(text2) {
17324
17351
  const lineNo = i + 1;
17325
17352
  if (/^layout\s*:/i.test(t)) {
17326
17353
  const v = afterColon3(t).toLowerCase();
17327
- if (v === "symmetric" || v === "compact") ast.layout = v;
17354
+ if (v === "symmetric") ast.layout = v;
17355
+ else if (v === "compact") ast.warnings.push(`Line ${lineNo}: layout: compact is reserved but not implemented yet; using layout: symmetric.`);
17328
17356
  continue;
17329
17357
  }
17330
17358
  if (/^legend\s*:/i.test(t)) {
@@ -26537,7 +26565,7 @@ var plugins = [
26537
26565
  chunk5FYPSIGD_cjs.sociogram,
26538
26566
  chunk2F45Y2ON_cjs.timing,
26539
26567
  chunkZ3A2UNK2_cjs.logic,
26540
- chunkQBS4F44Q_cjs.circuit,
26568
+ chunkJ3EPFZPX_cjs.circuit,
26541
26569
  chunkSHMG7BVF_cjs.blockdiagram,
26542
26570
  chunkTACTEF2N_cjs.ladder,
26543
26571
  chunk34O3C6OC_cjs.sld,
@@ -26579,8 +26607,33 @@ function detectPlugin(text2, config) {
26579
26607
  "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'."
26580
26608
  );
26581
26609
  }
26610
+ function stripCodeFences(text2) {
26611
+ let t = text2;
26612
+ t = t.replace(/^\uFEFF?[ \t]*```[A-Za-z0-9_-]*[ \t]*\r?\n/, "");
26613
+ t = t.replace(/\r?\n[ \t]*```[ \t]*$/, "");
26614
+ return t;
26615
+ }
26616
+ function normalizeHeader(text2, type) {
26617
+ const lines = text2.split("\n");
26618
+ for (let i = 0; i < lines.length; i++) {
26619
+ const trimmed = lines[i].trim();
26620
+ if (!trimmed) continue;
26621
+ const m = trimmed.match(/^([A-Za-z][A-Za-z0-9_-]*)/);
26622
+ if (!m) return text2;
26623
+ const tok = m[1];
26624
+ const lower = tok.toLowerCase();
26625
+ if (lower === type) return text2;
26626
+ if (lower.length >= 3 && type.startsWith(lower)) {
26627
+ const idx = lines[i].indexOf(tok);
26628
+ lines[i] = lines[i].slice(0, idx) + type + lines[i].slice(idx + tok.length);
26629
+ return lines.join("\n");
26630
+ }
26631
+ return text2;
26632
+ }
26633
+ return text2;
26634
+ }
26582
26635
  function preprocess8(text2) {
26583
- const { data, body } = chunk3KRL2EGN_cjs.parseFrontmatter(text2);
26636
+ const { data, body } = chunk3KRL2EGN_cjs.parseFrontmatter(stripCodeFences(text2));
26584
26637
  if (!data.title) return body;
26585
26638
  const safeTitle = data.title.replace(/"/g, '\\"');
26586
26639
  const lines = body.split("\n");
@@ -26594,8 +26647,9 @@ function preprocess8(text2) {
26594
26647
  return body;
26595
26648
  }
26596
26649
  function parse(text2, config) {
26597
- const prepared = preprocess8(text2);
26598
- const plugin = detectPlugin(prepared, config);
26650
+ const prepared0 = preprocess8(text2);
26651
+ const plugin = detectPlugin(prepared0, config);
26652
+ const prepared = normalizeHeader(prepared0, plugin.type);
26599
26653
  if (plugin.parse) return plugin.parse(prepared);
26600
26654
  throw new Error(
26601
26655
  `Diagram type '${plugin.type}' does not yet expose a parse() method.`
@@ -26604,13 +26658,14 @@ function parse(text2, config) {
26604
26658
  function parseResult(text2, config) {
26605
26659
  let plugin;
26606
26660
  try {
26607
- const prepared = preprocess8(text2);
26608
- plugin = detectPlugin(prepared, config);
26661
+ const prepared0 = preprocess8(text2);
26662
+ plugin = detectPlugin(prepared0, config);
26609
26663
  if (!plugin.parse) {
26610
26664
  throw new Error(
26611
26665
  `Diagram type '${plugin.type}' does not yet expose a parse() method.`
26612
26666
  );
26613
26667
  }
26668
+ const prepared = normalizeHeader(prepared0, plugin.type);
26614
26669
  const ast = plugin.parse(prepared);
26615
26670
  const diagnostics = runLint(plugin, prepared);
26616
26671
  return {
@@ -26639,15 +26694,17 @@ function runLint(plugin, prepared) {
26639
26694
  }
26640
26695
  function render(text2, config) {
26641
26696
  if (config?.mode === "preview") return renderResult(text2, config).svg;
26642
- const prepared = preprocess8(text2);
26643
- const plugin = detectPlugin(prepared, config);
26697
+ const prepared0 = preprocess8(text2);
26698
+ const plugin = detectPlugin(prepared0, config);
26699
+ const prepared = normalizeHeader(prepared0, plugin.type);
26644
26700
  return renderWithPlugin(prepared, plugin, config);
26645
26701
  }
26646
26702
  function renderResult(text2, config) {
26647
26703
  let plugin;
26648
26704
  try {
26649
- const prepared = preprocess8(text2);
26650
- plugin = detectPlugin(prepared, config);
26705
+ const prepared0 = preprocess8(text2);
26706
+ plugin = detectPlugin(prepared0, config);
26707
+ const prepared = normalizeHeader(prepared0, plugin.type);
26651
26708
  const svg = renderWithPlugin(prepared, plugin, config);
26652
26709
  const diagnostics = runLint(plugin, prepared);
26653
26710
  return {
@@ -26706,5 +26763,5 @@ exports.state = state;
26706
26763
  exports.timeline = timeline;
26707
26764
  exports.umlclass = umlclass;
26708
26765
  exports.usecase = usecase;
26709
- //# sourceMappingURL=chunk-LDONE225.cjs.map
26710
- //# sourceMappingURL=chunk-LDONE225.cjs.map
26766
+ //# sourceMappingURL=chunk-AGBY7KLL.cjs.map
26767
+ //# sourceMappingURL=chunk-AGBY7KLL.cjs.map