@tscircuit/circuit-json-util 0.0.77 → 0.0.79
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/dist/index.d.ts +7251 -321
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -160,6 +160,29 @@ var cju = ((circuitJsonInput, options = {}) => {
|
|
|
160
160
|
if (prop === "subtree") {
|
|
161
161
|
return (opts) => cju(buildSubtree(circuitJson, opts), options);
|
|
162
162
|
}
|
|
163
|
+
if (prop === "insert") {
|
|
164
|
+
return (elm) => {
|
|
165
|
+
const component_type2 = elm.type;
|
|
166
|
+
if (!component_type2) {
|
|
167
|
+
throw new Error("insert requires an element with a type");
|
|
168
|
+
}
|
|
169
|
+
internalStore.counts[component_type2] ??= -1;
|
|
170
|
+
internalStore.counts[component_type2]++;
|
|
171
|
+
const index = internalStore.counts[component_type2];
|
|
172
|
+
const newElm = {
|
|
173
|
+
...elm,
|
|
174
|
+
type: component_type2,
|
|
175
|
+
[`${component_type2}_id`]: `${component_type2}_${index}`
|
|
176
|
+
};
|
|
177
|
+
if (options.validateInserts) {
|
|
178
|
+
const parser = Soup[component_type2] ?? Soup.any_soup_element;
|
|
179
|
+
parser.parse(newElm);
|
|
180
|
+
}
|
|
181
|
+
circuitJson.push(newElm);
|
|
182
|
+
internalStore.editCount++;
|
|
183
|
+
return newElm;
|
|
184
|
+
};
|
|
185
|
+
}
|
|
163
186
|
const component_type = prop;
|
|
164
187
|
return {
|
|
165
188
|
get: (id) => circuitJson.find(
|
|
@@ -1809,6 +1832,10 @@ function getElementRenderLayers(element) {
|
|
|
1809
1832
|
const layer = element.layer;
|
|
1810
1833
|
return [`${layer}_fabrication_note`];
|
|
1811
1834
|
}
|
|
1835
|
+
if (element.type === "pcb_courtyard_circle" || element.type === "pcb_courtyard_polygon" || element.type === "pcb_courtyard_rect" || element.type === "pcb_courtyard_outline") {
|
|
1836
|
+
const layer = element.layer;
|
|
1837
|
+
return [`${layer}_courtyard`];
|
|
1838
|
+
}
|
|
1812
1839
|
return [];
|
|
1813
1840
|
}
|
|
1814
1841
|
export {
|