schematex 0.6.7 → 0.6.9

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 (33) hide show
  1. package/README.md +101 -6
  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-WK36Z63Y.cjs → chunk-25TO5A4F.cjs} +5 -5
  12. package/dist/{chunk-WK36Z63Y.cjs.map → chunk-25TO5A4F.cjs.map} +1 -1
  13. package/dist/{chunk-WAKRRGAV.js → chunk-2TUZ3QJA.js} +110 -2
  14. package/dist/chunk-2TUZ3QJA.js.map +1 -0
  15. package/dist/{chunk-TRUJ4Q6V.js → chunk-3DPWFWQU.js} +41 -12
  16. package/dist/{chunk-TRUJ4Q6V.js.map → chunk-3DPWFWQU.js.map} +1 -1
  17. package/dist/{chunk-LDONE225.cjs → chunk-5IZL57YJ.cjs} +42 -13
  18. package/dist/{chunk-LDONE225.cjs.map → chunk-5IZL57YJ.cjs.map} +1 -1
  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-Q5V4LUQR.js} +3 -3
  22. package/dist/{chunk-EVEPI423.js.map → chunk-Q5V4LUQR.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 +5 -5
  32. package/dist/chunk-QBS4F44Q.cjs.map +0 -1
  33. 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';
@@ -26577,8 +26577,33 @@ function detectPlugin(text2, config) {
26577
26577
  "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
26578
  );
26579
26579
  }
26580
+ function stripCodeFences(text2) {
26581
+ let t = text2;
26582
+ t = t.replace(/^\uFEFF?[ \t]*```[A-Za-z0-9_-]*[ \t]*\r?\n/, "");
26583
+ t = t.replace(/\r?\n[ \t]*```[ \t]*$/, "");
26584
+ return t;
26585
+ }
26586
+ function normalizeHeader(text2, type) {
26587
+ const lines = text2.split("\n");
26588
+ for (let i = 0; i < lines.length; i++) {
26589
+ const trimmed = lines[i].trim();
26590
+ if (!trimmed) continue;
26591
+ const m = trimmed.match(/^([A-Za-z][A-Za-z0-9_-]*)/);
26592
+ if (!m) return text2;
26593
+ const tok = m[1];
26594
+ const lower = tok.toLowerCase();
26595
+ if (lower === type) return text2;
26596
+ if (lower.length >= 3 && type.startsWith(lower)) {
26597
+ const idx = lines[i].indexOf(tok);
26598
+ lines[i] = lines[i].slice(0, idx) + type + lines[i].slice(idx + tok.length);
26599
+ return lines.join("\n");
26600
+ }
26601
+ return text2;
26602
+ }
26603
+ return text2;
26604
+ }
26580
26605
  function preprocess8(text2) {
26581
- const { data, body } = parseFrontmatter(text2);
26606
+ const { data, body } = parseFrontmatter(stripCodeFences(text2));
26582
26607
  if (!data.title) return body;
26583
26608
  const safeTitle = data.title.replace(/"/g, '\\"');
26584
26609
  const lines = body.split("\n");
@@ -26592,8 +26617,9 @@ function preprocess8(text2) {
26592
26617
  return body;
26593
26618
  }
26594
26619
  function parse(text2, config) {
26595
- const prepared = preprocess8(text2);
26596
- const plugin = detectPlugin(prepared, config);
26620
+ const prepared0 = preprocess8(text2);
26621
+ const plugin = detectPlugin(prepared0, config);
26622
+ const prepared = normalizeHeader(prepared0, plugin.type);
26597
26623
  if (plugin.parse) return plugin.parse(prepared);
26598
26624
  throw new Error(
26599
26625
  `Diagram type '${plugin.type}' does not yet expose a parse() method.`
@@ -26602,13 +26628,14 @@ function parse(text2, config) {
26602
26628
  function parseResult(text2, config) {
26603
26629
  let plugin;
26604
26630
  try {
26605
- const prepared = preprocess8(text2);
26606
- plugin = detectPlugin(prepared, config);
26631
+ const prepared0 = preprocess8(text2);
26632
+ plugin = detectPlugin(prepared0, config);
26607
26633
  if (!plugin.parse) {
26608
26634
  throw new Error(
26609
26635
  `Diagram type '${plugin.type}' does not yet expose a parse() method.`
26610
26636
  );
26611
26637
  }
26638
+ const prepared = normalizeHeader(prepared0, plugin.type);
26612
26639
  const ast = plugin.parse(prepared);
26613
26640
  const diagnostics = runLint(plugin, prepared);
26614
26641
  return {
@@ -26637,15 +26664,17 @@ function runLint(plugin, prepared) {
26637
26664
  }
26638
26665
  function render(text2, config) {
26639
26666
  if (config?.mode === "preview") return renderResult(text2, config).svg;
26640
- const prepared = preprocess8(text2);
26641
- const plugin = detectPlugin(prepared, config);
26667
+ const prepared0 = preprocess8(text2);
26668
+ const plugin = detectPlugin(prepared0, config);
26669
+ const prepared = normalizeHeader(prepared0, plugin.type);
26642
26670
  return renderWithPlugin(prepared, plugin, config);
26643
26671
  }
26644
26672
  function renderResult(text2, config) {
26645
26673
  let plugin;
26646
26674
  try {
26647
- const prepared = preprocess8(text2);
26648
- plugin = detectPlugin(prepared, config);
26675
+ const prepared0 = preprocess8(text2);
26676
+ plugin = detectPlugin(prepared0, config);
26677
+ const prepared = normalizeHeader(prepared0, plugin.type);
26649
26678
  const svg = renderWithPlugin(prepared, plugin, config);
26650
26679
  const diagnostics = runLint(plugin, prepared);
26651
26680
  return {
@@ -26683,5 +26712,5 @@ function renderWithPlugin(prepared, plugin, config) {
26683
26712
  }
26684
26713
 
26685
26714
  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
26715
+ //# sourceMappingURL=chunk-3DPWFWQU.js.map
26716
+ //# sourceMappingURL=chunk-3DPWFWQU.js.map