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
@@ -2009,6 +2009,53 @@ function parseCircuit(text2) {
2009
2009
  }
2010
2010
 
2011
2011
  // src/diagrams/circuit/lint.ts
2012
+ var INTENTIONAL_SINGLE_PIN = /* @__PURE__ */ new Set([
2013
+ "ground",
2014
+ "gnd_signal",
2015
+ "gnd_chassis",
2016
+ "gnd_digital",
2017
+ "vcc",
2018
+ "antenna",
2019
+ "no_connect",
2020
+ "test_point",
2021
+ "label",
2022
+ "port"
2023
+ ]);
2024
+ var SOURCE_TYPES = /* @__PURE__ */ new Set([
2025
+ "voltage_source",
2026
+ "ac_source",
2027
+ "battery",
2028
+ "current_source"
2029
+ ]);
2030
+ var GROUND_TYPES = /* @__PURE__ */ new Set([
2031
+ "ground",
2032
+ "gnd_signal",
2033
+ "gnd_chassis",
2034
+ "gnd_digital"
2035
+ ]);
2036
+ var NC_NET = /_nc\d+$/;
2037
+ function componentIdOfAnchor(anchor) {
2038
+ const dot = anchor.lastIndexOf(".");
2039
+ return dot < 0 ? anchor : anchor.slice(0, dot);
2040
+ }
2041
+ function editDistanceWithin(a, b, max) {
2042
+ if (Math.abs(a.length - b.length) > max) return false;
2043
+ const prev = new Array(b.length + 1);
2044
+ const curr = new Array(b.length + 1);
2045
+ for (let j = 0; j <= b.length; j++) prev[j] = j;
2046
+ for (let i = 1; i <= a.length; i++) {
2047
+ curr[0] = i;
2048
+ let rowMin = curr[0];
2049
+ for (let j = 1; j <= b.length; j++) {
2050
+ const cost = a[i - 1] === b[j - 1] ? 0 : 1;
2051
+ curr[j] = Math.min(prev[j] + 1, curr[j - 1] + 1, prev[j - 1] + cost);
2052
+ if (curr[j] < rowMin) rowMin = curr[j];
2053
+ }
2054
+ if (rowMin > max) return false;
2055
+ for (let j = 0; j <= b.length; j++) prev[j] = curr[j];
2056
+ }
2057
+ return prev[b.length] <= max;
2058
+ }
2012
2059
  function lintCircuit(text2) {
2013
2060
  let ast;
2014
2061
  try {
@@ -2017,6 +2064,22 @@ function lintCircuit(text2) {
2017
2064
  return [];
2018
2065
  }
2019
2066
  const out = [];
2067
+ const idCounts = /* @__PURE__ */ new Map();
2068
+ for (const c of ast.components) {
2069
+ if (c.id.startsWith("_")) continue;
2070
+ idCounts.set(c.id, (idCounts.get(c.id) ?? 0) + 1);
2071
+ }
2072
+ for (const [id, n] of idCounts) {
2073
+ if (n > 1) {
2074
+ out.push({
2075
+ severity: "error",
2076
+ code: "CIRCUIT_DUPLICATE_ID",
2077
+ message: `component id "${id}" is declared ${n} times; each reference designator must be unique`,
2078
+ hint: `Rename the duplicates (e.g. ${id}, ${id}B). With a repeated id only the last line's connections are kept.`,
2079
+ fatal: false
2080
+ });
2081
+ }
2082
+ }
2020
2083
  for (const u of ast.recovered?.underspecified ?? []) {
2021
2084
  out.push({
2022
2085
  severity: "warning",
@@ -2026,6 +2089,51 @@ function lintCircuit(text2) {
2026
2089
  fatal: false
2027
2090
  });
2028
2091
  }
2092
+ if (ast.mode !== "netlist") return out;
2093
+ const compById = /* @__PURE__ */ new Map();
2094
+ for (const c of ast.components) compById.set(c.id, c);
2095
+ const hasGround = ast.nets.some((n) => n.id === "GND") || ast.components.some((c) => GROUND_TYPES.has(c.componentType));
2096
+ const sources = ast.components.filter((c) => SOURCE_TYPES.has(c.componentType));
2097
+ if (sources.length > 0 && !hasGround) {
2098
+ out.push({
2099
+ severity: "warning",
2100
+ code: "CIRCUIT_NO_GROUND",
2101
+ message: `circuit has ${sources.length} source(s) (e.g. ${sources[0].id}) but no ground reference; node voltages are undefined`,
2102
+ 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.`,
2103
+ fatal: false
2104
+ });
2105
+ }
2106
+ const wired = ast.nets.filter(
2107
+ (n) => n.anchors.length >= 2 && !NC_NET.test(n.id)
2108
+ );
2109
+ for (const net of ast.nets) {
2110
+ if (net.id === "GND") continue;
2111
+ if (NC_NET.test(net.id)) continue;
2112
+ if (net.anchors.length !== 1) continue;
2113
+ const comp = compById.get(componentIdOfAnchor(net.anchors[0]));
2114
+ if (comp && INTENTIONAL_SINGLE_PIN.has(comp.componentType)) continue;
2115
+ const lower = net.id.toLowerCase();
2116
+ const typoTarget = wired.find(
2117
+ (w) => w.id.toLowerCase() !== lower && Math.max(w.id.length, net.id.length) >= 3 && editDistanceWithin(lower, w.id.toLowerCase(), 1)
2118
+ );
2119
+ if (typoTarget) {
2120
+ out.push({
2121
+ severity: "warning",
2122
+ code: "CIRCUIT_NET_TYPO",
2123
+ message: `net "${net.id}" connects to only one pin and is one character from "${typoTarget.id}" \u2014 likely a misspelled connection`,
2124
+ hint: `If they are the same node, rename "${net.id}" to "${typoTarget.id}" so the pins join.`,
2125
+ fatal: false
2126
+ });
2127
+ } else {
2128
+ out.push({
2129
+ severity: "warning",
2130
+ code: "CIRCUIT_FLOATING_NET",
2131
+ message: `net "${net.id}" connects to only one pin (${net.anchors[0]}); nothing else joins this node`,
2132
+ hint: `Wire "${net.id}" to another pin, or mark the pin as intentionally open with a no-connect.`,
2133
+ fatal: false
2134
+ });
2135
+ }
2136
+ }
2029
2137
  return out;
2030
2138
  }
2031
2139
 
@@ -2591,5 +2699,5 @@ exports.lintCircuit = lintCircuit;
2591
2699
  exports.parseCircuit = parseCircuit;
2592
2700
  exports.parseNetlist = parseNetlist;
2593
2701
  exports.renderCircuit = renderCircuit;
2594
- //# sourceMappingURL=chunk-QBS4F44Q.cjs.map
2595
- //# sourceMappingURL=chunk-QBS4F44Q.cjs.map
2702
+ //# sourceMappingURL=chunk-J3EPFZPX.cjs.map
2703
+ //# sourceMappingURL=chunk-J3EPFZPX.cjs.map