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.
- package/README.md +101 -6
- package/README.zh-CN.md +783 -0
- package/dist/ai/ai-sdk.cjs +8 -8
- package/dist/ai/ai-sdk.d.cts +1 -1
- package/dist/ai/ai-sdk.d.ts +1 -1
- package/dist/ai/ai-sdk.js +3 -3
- package/dist/ai/index.cjs +14 -14
- package/dist/ai/index.js +3 -3
- package/dist/browser.cjs +9 -9
- package/dist/browser.js +3 -3
- package/dist/{chunk-WK36Z63Y.cjs → chunk-25TO5A4F.cjs} +5 -5
- package/dist/{chunk-WK36Z63Y.cjs.map → chunk-25TO5A4F.cjs.map} +1 -1
- package/dist/{chunk-WAKRRGAV.js → chunk-2TUZ3QJA.js} +110 -2
- package/dist/chunk-2TUZ3QJA.js.map +1 -0
- package/dist/{chunk-TRUJ4Q6V.js → chunk-3DPWFWQU.js} +41 -12
- package/dist/{chunk-TRUJ4Q6V.js.map → chunk-3DPWFWQU.js.map} +1 -1
- package/dist/{chunk-LDONE225.cjs → chunk-5IZL57YJ.cjs} +42 -13
- package/dist/{chunk-LDONE225.cjs.map → chunk-5IZL57YJ.cjs.map} +1 -1
- package/dist/{chunk-QBS4F44Q.cjs → chunk-J3EPFZPX.cjs} +110 -2
- package/dist/chunk-J3EPFZPX.cjs.map +1 -0
- package/dist/{chunk-EVEPI423.js → chunk-Q5V4LUQR.js} +3 -3
- package/dist/{chunk-EVEPI423.js.map → chunk-Q5V4LUQR.js.map} +1 -1
- package/dist/diagrams/circuit/index.cjs +8 -8
- package/dist/diagrams/circuit/index.d.cts +0 -9
- package/dist/diagrams/circuit/index.d.ts +0 -9
- package/dist/diagrams/circuit/index.js +1 -1
- package/dist/index.cjs +27 -27
- package/dist/index.js +4 -4
- package/dist/react.cjs +3 -3
- package/dist/react.js +2 -2
- package/package.json +5 -5
- package/dist/chunk-QBS4F44Q.cjs.map +0 -1
- package/dist/chunk-WAKRRGAV.js.map +0 -1
|
@@ -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-
|
|
2585
|
-
//# sourceMappingURL=chunk-
|
|
2692
|
+
//# sourceMappingURL=chunk-2TUZ3QJA.js.map
|
|
2693
|
+
//# sourceMappingURL=chunk-2TUZ3QJA.js.map
|