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,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var chunkWK36Z63Y_cjs = require('../chunk-WK36Z63Y.cjs');
4
- require('../chunk-LDONE225.cjs');
3
+ var chunkEDXDFKYO_cjs = require('../chunk-EDXDFKYO.cjs');
4
+ require('../chunk-AGBY7KLL.cjs');
5
5
  require('../chunk-UHPGWO77.cjs');
6
- require('../chunk-QBS4F44Q.cjs');
6
+ require('../chunk-J3EPFZPX.cjs');
7
7
  require('../chunk-SHMG7BVF.cjs');
8
8
  require('../chunk-TACTEF2N.cjs');
9
9
  require('../chunk-34O3C6OC.cjs');
@@ -31,7 +31,7 @@ var schematexTools = {
31
31
  listDiagrams: ai.tool({
32
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.",
33
33
  inputSchema: zod.z.object({}),
34
- execute: async () => chunkWK36Z63Y_cjs.listDiagrams()
34
+ execute: async () => chunkEDXDFKYO_cjs.listDiagrams()
35
35
  }),
36
36
  getSyntax: ai.tool({
37
37
  description: "Return syntax for one diagram type. Default `detail: canonical` is the compact first-shot generation path: canonical header, preferred forms, rules, and repair checks. Request `detail: reference` only for advanced forms or imported adapters after choosing a type.",
@@ -46,7 +46,7 @@ var schematexTools = {
46
46
  execute: async ({
47
47
  type,
48
48
  detail
49
- }) => chunkWK36Z63Y_cjs.getSyntax(type, { detail })
49
+ }) => chunkEDXDFKYO_cjs.getSyntax(type, { detail })
50
50
  }),
51
51
  getExamples: ai.tool({
52
52
  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.",
@@ -56,7 +56,7 @@ var schematexTools = {
56
56
  preferFeatured: zod.z.boolean().optional().describe("Rank featured examples first."),
57
57
  maxComplexity: zod.z.number().int().min(1).max(5).optional().describe("Only return examples with complexity <= this value (1=simplest).")
58
58
  }),
59
- execute: async (args) => chunkWK36Z63Y_cjs.getExamples(args.type, {
59
+ execute: async (args) => chunkEDXDFKYO_cjs.getExamples(args.type, {
60
60
  limit: args.limit,
61
61
  preferFeatured: args.preferFeatured,
62
62
  maxComplexity: args.maxComplexity
@@ -70,7 +70,7 @@ var schematexTools = {
70
70
  ),
71
71
  dsl: zod.z.string().describe("The DSL source text to validate.")
72
72
  }),
73
- execute: async ({ type, dsl }) => chunkWK36Z63Y_cjs.validateDsl(type, dsl)
73
+ execute: async ({ type, dsl }) => chunkEDXDFKYO_cjs.validateDsl(type, dsl)
74
74
  }),
75
75
  renderDsl: ai.tool({
76
76
  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.",
@@ -85,7 +85,7 @@ var schematexTools = {
85
85
  dsl,
86
86
  theme,
87
87
  padding
88
- }) => chunkWK36Z63Y_cjs.renderDsl(type, dsl, { theme, padding })
88
+ }) => chunkEDXDFKYO_cjs.renderDsl(type, dsl, { theme, padding })
89
89
  })
90
90
  };
91
91
 
@@ -7,7 +7,7 @@ declare const schematexTools: {
7
7
  readonly listDiagrams: ai.Tool<{}, DiagramListItem[]>;
8
8
  readonly getSyntax: ai.Tool<{
9
9
  type: string;
10
- detail?: "canonical" | "reference" | undefined;
10
+ detail?: "reference" | "canonical" | undefined;
11
11
  }, GetSyntaxResult>;
12
12
  readonly getExamples: ai.Tool<{
13
13
  type: string;
@@ -7,7 +7,7 @@ declare const schematexTools: {
7
7
  readonly listDiagrams: ai.Tool<{}, DiagramListItem[]>;
8
8
  readonly getSyntax: ai.Tool<{
9
9
  type: string;
10
- detail?: "canonical" | "reference" | undefined;
10
+ detail?: "reference" | "canonical" | undefined;
11
11
  }, GetSyntaxResult>;
12
12
  readonly getExamples: ai.Tool<{
13
13
  type: string;
package/dist/ai/ai-sdk.js CHANGED
@@ -1,7 +1,7 @@
1
- import { renderDsl, validateDsl, getExamples, getSyntax, listDiagrams } from '../chunk-EVEPI423.js';
2
- import '../chunk-TRUJ4Q6V.js';
1
+ import { renderDsl, validateDsl, getExamples, getSyntax, listDiagrams } from '../chunk-QZ2OBNAS.js';
2
+ import '../chunk-J2TT7PGI.js';
3
3
  import '../chunk-MPCSWRZC.js';
4
- import '../chunk-WAKRRGAV.js';
4
+ import '../chunk-2TUZ3QJA.js';
5
5
  import '../chunk-C7V57V6O.js';
6
6
  import '../chunk-WU2N6ZVM.js';
7
7
  import '../chunk-JTGTWBAD.js';
package/dist/ai/index.cjs CHANGED
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var chunkWK36Z63Y_cjs = require('../chunk-WK36Z63Y.cjs');
4
- require('../chunk-LDONE225.cjs');
3
+ var chunkEDXDFKYO_cjs = require('../chunk-EDXDFKYO.cjs');
4
+ require('../chunk-AGBY7KLL.cjs');
5
5
  require('../chunk-UHPGWO77.cjs');
6
- require('../chunk-QBS4F44Q.cjs');
6
+ require('../chunk-J3EPFZPX.cjs');
7
7
  require('../chunk-SHMG7BVF.cjs');
8
8
  require('../chunk-TACTEF2N.cjs');
9
9
  require('../chunk-34O3C6OC.cjs');
@@ -29,47 +29,47 @@ require('../chunk-3WNW5Y7P.cjs');
29
29
 
30
30
  Object.defineProperty(exports, "DIAGRAM_REGISTRY", {
31
31
  enumerable: true,
32
- get: function () { return chunkWK36Z63Y_cjs.DIAGRAM_REGISTRY; }
32
+ get: function () { return chunkEDXDFKYO_cjs.DIAGRAM_REGISTRY; }
33
33
  });
34
34
  Object.defineProperty(exports, "DIAGRAM_SINCE", {
35
35
  enumerable: true,
36
- get: function () { return chunkWK36Z63Y_cjs.DIAGRAM_SINCE; }
36
+ get: function () { return chunkEDXDFKYO_cjs.DIAGRAM_SINCE; }
37
37
  });
38
38
  Object.defineProperty(exports, "getAllDiagramTypes", {
39
39
  enumerable: true,
40
- get: function () { return chunkWK36Z63Y_cjs.getAllDiagramTypes; }
40
+ get: function () { return chunkEDXDFKYO_cjs.getAllDiagramTypes; }
41
41
  });
42
42
  Object.defineProperty(exports, "getDiagramMeta", {
43
43
  enumerable: true,
44
- get: function () { return chunkWK36Z63Y_cjs.getDiagramMeta; }
44
+ get: function () { return chunkEDXDFKYO_cjs.getDiagramMeta; }
45
45
  });
46
46
  Object.defineProperty(exports, "getDiagramSince", {
47
47
  enumerable: true,
48
- get: function () { return chunkWK36Z63Y_cjs.getDiagramSince; }
48
+ get: function () { return chunkEDXDFKYO_cjs.getDiagramSince; }
49
49
  });
50
50
  Object.defineProperty(exports, "getExamples", {
51
51
  enumerable: true,
52
- get: function () { return chunkWK36Z63Y_cjs.getExamples; }
52
+ get: function () { return chunkEDXDFKYO_cjs.getExamples; }
53
53
  });
54
54
  Object.defineProperty(exports, "getSyntax", {
55
55
  enumerable: true,
56
- get: function () { return chunkWK36Z63Y_cjs.getSyntax; }
56
+ get: function () { return chunkEDXDFKYO_cjs.getSyntax; }
57
57
  });
58
58
  Object.defineProperty(exports, "listDiagrams", {
59
59
  enumerable: true,
60
- get: function () { return chunkWK36Z63Y_cjs.listDiagrams; }
60
+ get: function () { return chunkEDXDFKYO_cjs.listDiagrams; }
61
61
  });
62
62
  Object.defineProperty(exports, "renderDsl", {
63
63
  enumerable: true,
64
- get: function () { return chunkWK36Z63Y_cjs.renderDsl; }
64
+ get: function () { return chunkEDXDFKYO_cjs.renderDsl; }
65
65
  });
66
66
  Object.defineProperty(exports, "resolveDiagramType", {
67
67
  enumerable: true,
68
- get: function () { return chunkWK36Z63Y_cjs.resolveDiagramType; }
68
+ get: function () { return chunkEDXDFKYO_cjs.resolveDiagramType; }
69
69
  });
70
70
  Object.defineProperty(exports, "validateDsl", {
71
71
  enumerable: true,
72
- get: function () { return chunkWK36Z63Y_cjs.validateDsl; }
72
+ get: function () { return chunkEDXDFKYO_cjs.validateDsl; }
73
73
  });
74
74
  //# sourceMappingURL=index.cjs.map
75
75
  //# sourceMappingURL=index.cjs.map
package/dist/ai/index.js CHANGED
@@ -1,7 +1,7 @@
1
- export { DIAGRAM_REGISTRY, DIAGRAM_SINCE, getAllDiagramTypes, getDiagramMeta, getDiagramSince, getExamples, getSyntax, listDiagrams, renderDsl, resolveDiagramType, validateDsl } from '../chunk-EVEPI423.js';
2
- import '../chunk-TRUJ4Q6V.js';
1
+ export { DIAGRAM_REGISTRY, DIAGRAM_SINCE, getAllDiagramTypes, getDiagramMeta, getDiagramSince, getExamples, getSyntax, listDiagrams, renderDsl, resolveDiagramType, validateDsl } from '../chunk-QZ2OBNAS.js';
2
+ import '../chunk-J2TT7PGI.js';
3
3
  import '../chunk-MPCSWRZC.js';
4
- import '../chunk-WAKRRGAV.js';
4
+ import '../chunk-2TUZ3QJA.js';
5
5
  import '../chunk-C7V57V6O.js';
6
6
  import '../chunk-WU2N6ZVM.js';
7
7
  import '../chunk-JTGTWBAD.js';
package/dist/browser.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunkLDONE225_cjs = require('./chunk-LDONE225.cjs');
3
+ var chunkAGBY7KLL_cjs = require('./chunk-AGBY7KLL.cjs');
4
4
  require('./chunk-UHPGWO77.cjs');
5
- require('./chunk-QBS4F44Q.cjs');
5
+ require('./chunk-J3EPFZPX.cjs');
6
6
  require('./chunk-SHMG7BVF.cjs');
7
7
  require('./chunk-TACTEF2N.cjs');
8
8
  require('./chunk-34O3C6OC.cjs');
@@ -26,10 +26,10 @@ require('./chunk-3WNW5Y7P.cjs');
26
26
 
27
27
  // src/browser.ts
28
28
  function renderToElement(text, config) {
29
- return svgStringToElement(chunkLDONE225_cjs.render(text, config));
29
+ return svgStringToElement(chunkAGBY7KLL_cjs.render(text, config));
30
30
  }
31
31
  function renderPreviewToElement(text, config) {
32
- return svgStringToElement(chunkLDONE225_cjs.renderPreview(text, config));
32
+ return svgStringToElement(chunkAGBY7KLL_cjs.renderPreview(text, config));
33
33
  }
34
34
  function svgStringToElement(svgString) {
35
35
  const parser = new DOMParser();
@@ -42,23 +42,23 @@ function svgStringToElement(svgString) {
42
42
  return el;
43
43
  }
44
44
  function renderToContainer(text, container, config) {
45
- container.innerHTML = chunkLDONE225_cjs.render(text, config);
45
+ container.innerHTML = chunkAGBY7KLL_cjs.render(text, config);
46
46
  }
47
47
  function renderPreviewToContainer(text, container, config) {
48
- container.innerHTML = chunkLDONE225_cjs.renderPreview(text, config);
48
+ container.innerHTML = chunkAGBY7KLL_cjs.renderPreview(text, config);
49
49
  }
50
50
 
51
51
  Object.defineProperty(exports, "render", {
52
52
  enumerable: true,
53
- get: function () { return chunkLDONE225_cjs.render; }
53
+ get: function () { return chunkAGBY7KLL_cjs.render; }
54
54
  });
55
55
  Object.defineProperty(exports, "renderPreview", {
56
56
  enumerable: true,
57
- get: function () { return chunkLDONE225_cjs.renderPreview; }
57
+ get: function () { return chunkAGBY7KLL_cjs.renderPreview; }
58
58
  });
59
59
  Object.defineProperty(exports, "renderResult", {
60
60
  enumerable: true,
61
- get: function () { return chunkLDONE225_cjs.renderResult; }
61
+ get: function () { return chunkAGBY7KLL_cjs.renderResult; }
62
62
  });
63
63
  exports.renderPreviewToContainer = renderPreviewToContainer;
64
64
  exports.renderPreviewToElement = renderPreviewToElement;
package/dist/browser.js CHANGED
@@ -1,7 +1,7 @@
1
- import { render, renderPreview } from './chunk-TRUJ4Q6V.js';
2
- export { render, renderPreview, renderResult } from './chunk-TRUJ4Q6V.js';
1
+ import { render, renderPreview } from './chunk-J2TT7PGI.js';
2
+ export { render, renderPreview, renderResult } from './chunk-J2TT7PGI.js';
3
3
  import './chunk-MPCSWRZC.js';
4
- import './chunk-WAKRRGAV.js';
4
+ import './chunk-2TUZ3QJA.js';
5
5
  import './chunk-C7V57V6O.js';
6
6
  import './chunk-WU2N6ZVM.js';
7
7
  import './chunk-JTGTWBAD.js';
@@ -2007,6 +2007,53 @@ function parseCircuit(text2) {
2007
2007
  }
2008
2008
 
2009
2009
  // src/diagrams/circuit/lint.ts
2010
+ var INTENTIONAL_SINGLE_PIN = /* @__PURE__ */ new Set([
2011
+ "ground",
2012
+ "gnd_signal",
2013
+ "gnd_chassis",
2014
+ "gnd_digital",
2015
+ "vcc",
2016
+ "antenna",
2017
+ "no_connect",
2018
+ "test_point",
2019
+ "label",
2020
+ "port"
2021
+ ]);
2022
+ var SOURCE_TYPES = /* @__PURE__ */ new Set([
2023
+ "voltage_source",
2024
+ "ac_source",
2025
+ "battery",
2026
+ "current_source"
2027
+ ]);
2028
+ var GROUND_TYPES = /* @__PURE__ */ new Set([
2029
+ "ground",
2030
+ "gnd_signal",
2031
+ "gnd_chassis",
2032
+ "gnd_digital"
2033
+ ]);
2034
+ var NC_NET = /_nc\d+$/;
2035
+ function componentIdOfAnchor(anchor) {
2036
+ const dot = anchor.lastIndexOf(".");
2037
+ return dot < 0 ? anchor : anchor.slice(0, dot);
2038
+ }
2039
+ function editDistanceWithin(a, b, max) {
2040
+ if (Math.abs(a.length - b.length) > max) return false;
2041
+ const prev = new Array(b.length + 1);
2042
+ const curr = new Array(b.length + 1);
2043
+ for (let j = 0; j <= b.length; j++) prev[j] = j;
2044
+ for (let i = 1; i <= a.length; i++) {
2045
+ curr[0] = i;
2046
+ let rowMin = curr[0];
2047
+ for (let j = 1; j <= b.length; j++) {
2048
+ const cost = a[i - 1] === b[j - 1] ? 0 : 1;
2049
+ curr[j] = Math.min(prev[j] + 1, curr[j - 1] + 1, prev[j - 1] + cost);
2050
+ if (curr[j] < rowMin) rowMin = curr[j];
2051
+ }
2052
+ if (rowMin > max) return false;
2053
+ for (let j = 0; j <= b.length; j++) prev[j] = curr[j];
2054
+ }
2055
+ return prev[b.length] <= max;
2056
+ }
2010
2057
  function lintCircuit(text2) {
2011
2058
  let ast;
2012
2059
  try {
@@ -2015,6 +2062,22 @@ function lintCircuit(text2) {
2015
2062
  return [];
2016
2063
  }
2017
2064
  const out = [];
2065
+ const idCounts = /* @__PURE__ */ new Map();
2066
+ for (const c of ast.components) {
2067
+ if (c.id.startsWith("_")) continue;
2068
+ idCounts.set(c.id, (idCounts.get(c.id) ?? 0) + 1);
2069
+ }
2070
+ for (const [id, n] of idCounts) {
2071
+ if (n > 1) {
2072
+ out.push({
2073
+ severity: "error",
2074
+ code: "CIRCUIT_DUPLICATE_ID",
2075
+ message: `component id "${id}" is declared ${n} times; each reference designator must be unique`,
2076
+ hint: `Rename the duplicates (e.g. ${id}, ${id}B). With a repeated id only the last line's connections are kept.`,
2077
+ fatal: false
2078
+ });
2079
+ }
2080
+ }
2018
2081
  for (const u of ast.recovered?.underspecified ?? []) {
2019
2082
  out.push({
2020
2083
  severity: "warning",
@@ -2024,6 +2087,51 @@ function lintCircuit(text2) {
2024
2087
  fatal: false
2025
2088
  });
2026
2089
  }
2090
+ if (ast.mode !== "netlist") return out;
2091
+ const compById = /* @__PURE__ */ new Map();
2092
+ for (const c of ast.components) compById.set(c.id, c);
2093
+ const hasGround = ast.nets.some((n) => n.id === "GND") || ast.components.some((c) => GROUND_TYPES.has(c.componentType));
2094
+ const sources = ast.components.filter((c) => SOURCE_TYPES.has(c.componentType));
2095
+ if (sources.length > 0 && !hasGround) {
2096
+ out.push({
2097
+ severity: "warning",
2098
+ code: "CIRCUIT_NO_GROUND",
2099
+ message: `circuit has ${sources.length} source(s) (e.g. ${sources[0].id}) but no ground reference; node voltages are undefined`,
2100
+ hint: `Tie a return node to ground \u2014 name a net \`0\`/\`GND\` (e.g. \`${sources[0].id} ${sources[0].id.toLowerCase()}_out 0\`) or add a ground symbol.`,
2101
+ fatal: false
2102
+ });
2103
+ }
2104
+ const wired = ast.nets.filter(
2105
+ (n) => n.anchors.length >= 2 && !NC_NET.test(n.id)
2106
+ );
2107
+ for (const net of ast.nets) {
2108
+ if (net.id === "GND") continue;
2109
+ if (NC_NET.test(net.id)) continue;
2110
+ if (net.anchors.length !== 1) continue;
2111
+ const comp = compById.get(componentIdOfAnchor(net.anchors[0]));
2112
+ if (comp && INTENTIONAL_SINGLE_PIN.has(comp.componentType)) continue;
2113
+ const lower = net.id.toLowerCase();
2114
+ const typoTarget = wired.find(
2115
+ (w) => w.id.toLowerCase() !== lower && Math.max(w.id.length, net.id.length) >= 3 && editDistanceWithin(lower, w.id.toLowerCase(), 1)
2116
+ );
2117
+ if (typoTarget) {
2118
+ out.push({
2119
+ severity: "warning",
2120
+ code: "CIRCUIT_NET_TYPO",
2121
+ message: `net "${net.id}" connects to only one pin and is one character from "${typoTarget.id}" \u2014 likely a misspelled connection`,
2122
+ hint: `If they are the same node, rename "${net.id}" to "${typoTarget.id}" so the pins join.`,
2123
+ fatal: false
2124
+ });
2125
+ } else {
2126
+ out.push({
2127
+ severity: "warning",
2128
+ code: "CIRCUIT_FLOATING_NET",
2129
+ message: `net "${net.id}" connects to only one pin (${net.anchors[0]}); nothing else joins this node`,
2130
+ hint: `Wire "${net.id}" to another pin, or mark the pin as intentionally open with a no-connect.`,
2131
+ fatal: false
2132
+ });
2133
+ }
2134
+ }
2027
2135
  return out;
2028
2136
  }
2029
2137
 
@@ -2581,5 +2689,5 @@ var circuit = {
2581
2689
  };
2582
2690
 
2583
2691
  export { EXTRA_SYMBOLS, SYMBOLS, circuit, layoutCircuit, layoutCircuitNetlist, lintCircuit, parseCircuit, parseNetlist, renderCircuit };
2584
- //# sourceMappingURL=chunk-WAKRRGAV.js.map
2585
- //# sourceMappingURL=chunk-WAKRRGAV.js.map
2692
+ //# sourceMappingURL=chunk-2TUZ3QJA.js.map
2693
+ //# sourceMappingURL=chunk-2TUZ3QJA.js.map