@tscircuit/core 0.0.100 → 0.0.102

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 (2) hide show
  1. package/dist/index.js +42 -3
  2. package/package.json +1 -1
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
- this._parsedProps = this.config.zodProps.parse(
384
- props ?? {}
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({
@@ -1036,6 +1070,11 @@ var SmtPad = class extends PrimitiveComponent {
1036
1070
  x: newCenter.x,
1037
1071
  y: newCenter.y
1038
1072
  });
1073
+ const solderPaste = db.pcb_solder_paste.list().find((elm) => elm.pcb_smtpad_id === this.pcb_smtpad_id);
1074
+ db.pcb_solder_paste.update(solderPaste?.pcb_solder_paste_id, {
1075
+ x: newCenter.x,
1076
+ y: newCenter.y
1077
+ });
1039
1078
  this.matchedPort?._setPositionFromLayout(newCenter);
1040
1079
  }
1041
1080
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.100",
4
+ "version": "0.0.102",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",