@tscircuit/core 0.0.99 → 0.0.101
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.js +59 -3
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -328,6 +328,33 @@ function isMatchingSelector(component, selector) {
|
|
|
328
328
|
});
|
|
329
329
|
}
|
|
330
330
|
|
|
331
|
+
// lib/errors/InvalidProps.ts
|
|
332
|
+
var InvalidProps = class extends Error {
|
|
333
|
+
constructor(componentName, originalProps, formattedError) {
|
|
334
|
+
let message;
|
|
335
|
+
const propsWithError = Object.keys(formattedError).filter(
|
|
336
|
+
(k) => k !== "_errors"
|
|
337
|
+
);
|
|
338
|
+
const propMessage = propsWithError.map((k) => {
|
|
339
|
+
if (formattedError[k]._errors[0]) {
|
|
340
|
+
return `${k} (${formattedError[k]._errors[0]})`;
|
|
341
|
+
}
|
|
342
|
+
return `${k} (${JSON.stringify(formattedError[k])})`;
|
|
343
|
+
}).join(", ");
|
|
344
|
+
if ("name" in originalProps) {
|
|
345
|
+
message = `Invalid props for ${componentName} "${originalProps.name}": ${propMessage}`;
|
|
346
|
+
} else if ("footprint" in originalProps && typeof originalProps.footprint === "string") {
|
|
347
|
+
message = `Invalid props for ${componentName} (unnamed ${originalProps.footprint} component): ${propMessage}`;
|
|
348
|
+
} else {
|
|
349
|
+
message = `Invalid props for ${componentName} (unnamed): ${propMessage}`;
|
|
350
|
+
}
|
|
351
|
+
super(message);
|
|
352
|
+
this.componentName = componentName;
|
|
353
|
+
this.originalProps = originalProps;
|
|
354
|
+
this.formattedError = formattedError;
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
|
|
331
358
|
// lib/components/base-components/PrimitiveComponent.ts
|
|
332
359
|
var PrimitiveComponent = class extends Renderable {
|
|
333
360
|
parent = null;
|
|
@@ -380,9 +407,16 @@ var PrimitiveComponent = class extends Renderable {
|
|
|
380
407
|
this.childrenPendingRemoval = [];
|
|
381
408
|
this.props = props ?? {};
|
|
382
409
|
this.externallyAddedAliases = [];
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
410
|
+
const parsePropsResult = this.config.zodProps.safeParse(props ?? {});
|
|
411
|
+
if (parsePropsResult.success) {
|
|
412
|
+
this._parsedProps = parsePropsResult.data;
|
|
413
|
+
} else {
|
|
414
|
+
throw new InvalidProps(
|
|
415
|
+
this.lowercaseComponentName,
|
|
416
|
+
this.props,
|
|
417
|
+
parsePropsResult.error.format()
|
|
418
|
+
);
|
|
419
|
+
}
|
|
386
420
|
}
|
|
387
421
|
setProps(props) {
|
|
388
422
|
const newProps = this.config.zodProps.parse({
|
|
@@ -952,6 +986,16 @@ var SmtPad = class extends PrimitiveComponent {
|
|
|
952
986
|
x: position.x,
|
|
953
987
|
y: position.y
|
|
954
988
|
});
|
|
989
|
+
db.pcb_solder_paste.insert({
|
|
990
|
+
layer: pcb_smtpad.layer,
|
|
991
|
+
shape: "circle",
|
|
992
|
+
// @ts-ignore: no idea why this is triggering
|
|
993
|
+
radius: pcb_smtpad.radius * 0.7,
|
|
994
|
+
x: pcb_smtpad.x,
|
|
995
|
+
y: pcb_smtpad.y,
|
|
996
|
+
pcb_component_id: pcb_smtpad.pcb_component_id,
|
|
997
|
+
pcb_smtpad_id: pcb_smtpad.pcb_smtpad_id
|
|
998
|
+
});
|
|
955
999
|
} else if (props.shape === "rect") {
|
|
956
1000
|
pcb_smtpad = db.pcb_smtpad.insert({
|
|
957
1001
|
pcb_component_id,
|
|
@@ -964,6 +1008,18 @@ var SmtPad = class extends PrimitiveComponent {
|
|
|
964
1008
|
x: position.x,
|
|
965
1009
|
y: position.y
|
|
966
1010
|
});
|
|
1011
|
+
if (pcb_smtpad.shape === "rect")
|
|
1012
|
+
db.pcb_solder_paste.insert({
|
|
1013
|
+
layer: pcb_smtpad.layer,
|
|
1014
|
+
shape: "rect",
|
|
1015
|
+
// @ts-ignore: no idea why this is triggering
|
|
1016
|
+
width: pcb_smtpad.width * 0.7,
|
|
1017
|
+
height: pcb_smtpad.height * 0.7,
|
|
1018
|
+
x: pcb_smtpad.x,
|
|
1019
|
+
y: pcb_smtpad.y,
|
|
1020
|
+
pcb_component_id: pcb_smtpad.pcb_component_id,
|
|
1021
|
+
pcb_smtpad_id: pcb_smtpad.pcb_smtpad_id
|
|
1022
|
+
});
|
|
967
1023
|
}
|
|
968
1024
|
if (pcb_smtpad) {
|
|
969
1025
|
this.pcb_smtpad_id = pcb_smtpad.pcb_smtpad_id;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.101",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"@lume/kiwi": "^0.4.3",
|
|
39
39
|
"@tscircuit/infgrid-ijump-astar": "^0.0.21",
|
|
40
40
|
"@tscircuit/math-utils": "^0.0.4",
|
|
41
|
-
"@tscircuit/props": "^0.0.
|
|
41
|
+
"@tscircuit/props": "^0.0.68",
|
|
42
42
|
"@tscircuit/soup-util": "^0.0.31",
|
|
43
|
-
"circuit-json": "^0.0.
|
|
43
|
+
"circuit-json": "^0.0.83",
|
|
44
44
|
"circuit-json-to-connectivity-map": "^0.0.17",
|
|
45
45
|
"footprinter": "^0.0.44",
|
|
46
46
|
"nanoid": "^5.0.7",
|