@tscircuit/cli 0.1.1948 → 0.1.1949

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/cli/main.js CHANGED
@@ -136044,7 +136044,7 @@ var import_perfect_cli = __toESM2(require_dist2(), 1);
136044
136044
  // lib/getVersion.ts
136045
136045
  import { createRequire as createRequire2 } from "node:module";
136046
136046
  // package.json
136047
- var version = "0.1.1947";
136047
+ var version = "0.1.1948";
136048
136048
  var package_default = {
136049
136049
  name: "@tscircuit/cli",
136050
136050
  version,
@@ -136105,7 +136105,7 @@ var package_default = {
136105
136105
  debug: "^4.4.0",
136106
136106
  delay: "^6.0.0",
136107
136107
  "dsn-converter": "^0.0.90",
136108
- easyeda: "^0.0.301",
136108
+ easyeda: "^0.0.305",
136109
136109
  "fuse.js": "^7.1.0",
136110
136110
  "get-port": "^7.1.0",
136111
136111
  globby: "^14.1.0",
@@ -327021,6 +327021,23 @@ var isLedCategoryComponent = (betterEasy) => {
327021
327021
  betterEasy.category
327022
327022
  ].some(categoryValueContainsLed);
327023
327023
  };
327024
+ function distance211(p12, p22) {
327025
+ const dx3 = p12.x - p22.x;
327026
+ const dy3 = p12.y - p22.y;
327027
+ return Math.sqrt(dx3 * dx3 + dy3 * dy3);
327028
+ }
327029
+ var getUnitVectorFromDirection2 = (direction2) => {
327030
+ switch (direction2) {
327031
+ case "up":
327032
+ return { x: 0, y: 1 };
327033
+ case "down":
327034
+ return { x: 0, y: -1 };
327035
+ case "left":
327036
+ return { x: -1, y: 0 };
327037
+ case "right":
327038
+ return { x: 1, y: 0 };
327039
+ }
327040
+ };
327024
327041
  var getBoundsCenter3 = (bounds) => ({
327025
327042
  x: (bounds.minX + bounds.maxX) / 2,
327026
327043
  y: (bounds.minY + bounds.maxY) / 2
@@ -327775,7 +327792,7 @@ var SolidRegionSchema = BaseShapeSchema.extend({
327775
327792
  type: external_exports2.literal("SOLIDREGION"),
327776
327793
  layermask: external_exports2.number(),
327777
327794
  points: external_exports2.array(PointSchema),
327778
- fillStyle: external_exports2.string()
327795
+ fillStyle: external_exports2.string().default("none")
327779
327796
  });
327780
327797
  var SVGNodeSchema = BaseShapeSchema.extend({
327781
327798
  type: external_exports2.literal("SVGNODE"),
@@ -327806,7 +327823,7 @@ var RectSchema = BaseShapeSchema.extend({
327806
327823
  width: tenthmil,
327807
327824
  height: tenthmil,
327808
327825
  lineWidth: external_exports2.number(),
327809
- fillStyle: external_exports2.string(),
327826
+ fillStyle: external_exports2.string().default("none"),
327810
327827
  rotation: external_exports2.number().optional()
327811
327828
  });
327812
327829
  var TextSchema = BaseShapeSchema.extend({
@@ -327964,7 +327981,7 @@ var ShapeItemSchema = external_exports2.object({
327964
327981
  type: "SOLIDREGION",
327965
327982
  layermask: Number(layermask),
327966
327983
  points,
327967
- fillStyle,
327984
+ fillStyle: fillStyle || undefined,
327968
327985
  id: id2
327969
327986
  });
327970
327987
  }
@@ -328212,6 +328229,17 @@ var parsePath = (str) => {
328212
328229
  };
328213
328230
  };
328214
328231
  var PathShapeSchema = external_exports2.string().startsWith("PT~").transform(parsePath).pipe(PathShapeOutputSchema);
328232
+ var IgnoredShapeOutputSchema = external_exports2.object({
328233
+ type: external_exports2.literal("IGNORED"),
328234
+ sourceType: external_exports2.enum(["AR", "I"])
328235
+ });
328236
+ var IgnoredShapeSchema = external_exports2.string().transform((shape) => {
328237
+ const sourceType = shape.startsWith("AR~") ? "AR" : shape.startsWith("I~") ? "I" : undefined;
328238
+ if (!sourceType) {
328239
+ throw new Error(`Invalid ignored shape: ${shape}`);
328240
+ }
328241
+ return { type: "IGNORED", sourceType };
328242
+ }).pipe(IgnoredShapeOutputSchema);
328215
328243
  var optionalEasyEdaTextField = (fieldSchema) => external_exports2.preprocess((textField) => {
328216
328244
  if (textField == null)
328217
328245
  return;
@@ -328295,6 +328323,9 @@ var SingleLetterShapeSchema = external_exports2.string().transform((x4) => {
328295
328323
  return PathShapeSchema.parse(x4);
328296
328324
  if (x4.startsWith("T~"))
328297
328325
  return TextShapeSchema.parse(x4);
328326
+ if (x4.startsWith("AR~") || x4.startsWith("I~")) {
328327
+ return IgnoredShapeSchema.parse(x4);
328328
+ }
328298
328329
  if (x4.startsWith("A~"))
328299
328330
  return ArcShapeSchema.parse(x4);
328300
328331
  throw new Error(`Invalid shape type: ${x4}`);
@@ -328306,9 +328337,17 @@ var SingleLetterShapeSchema = external_exports2.string().transform((x4) => {
328306
328337
  PolygonShapeOutputSchema,
328307
328338
  PathShapeOutputSchema,
328308
328339
  TextShapeOutputSchema,
328340
+ IgnoredShapeOutputSchema,
328309
328341
  ArcShapeOutputSchema
328310
328342
  ]));
328311
328343
  var maybeNumber = external_exports2.any().transform((k4) => k4 === "nan" || Number.isNaN(k4) ? null : k4).pipe(external_exports2.number().nullable().optional());
328344
+ var optionalNumberWithNumericString = external_exports2.preprocess((value) => {
328345
+ if (typeof value !== "string")
328346
+ return value;
328347
+ if (value.trim() === "")
328348
+ return;
328349
+ return Number(value);
328350
+ }, external_exports2.number().optional());
328312
328351
  var SzlcscSchema = external_exports2.object({
328313
328352
  id: external_exports2.preprocess((value) => {
328314
328353
  if (typeof value === "string" && /^\d+$/.test(value)) {
@@ -328319,7 +328358,7 @@ var SzlcscSchema = external_exports2.object({
328319
328358
  number: external_exports2.string(),
328320
328359
  step: external_exports2.number().optional(),
328321
328360
  min: external_exports2.number().optional(),
328322
- price: external_exports2.number().optional(),
328361
+ price: optionalNumberWithNumericString,
328323
328362
  stock: external_exports2.number().optional(),
328324
328363
  url: external_exports2.string().url().optional(),
328325
328364
  image: external_exports2.string().optional().optional()
@@ -328329,7 +328368,7 @@ var LcscSchema = external_exports2.object({
328329
328368
  number: external_exports2.string(),
328330
328369
  step: external_exports2.number().optional(),
328331
328370
  min: external_exports2.number().optional(),
328332
- price: external_exports2.number().optional(),
328371
+ price: optionalNumberWithNumericString,
328333
328372
  stock: external_exports2.number().optional(),
328334
328373
  url: external_exports2.string().url().optional()
328335
328374
  });
@@ -328606,7 +328645,7 @@ var generateFootprintTsx2 = (circuitJson, options = {}) => {
328606
328645
  if (hole.hole_shape === "circle") {
328607
328646
  elementStrings.push(`<hole pcbX="${mmStr2(hole.x)}" pcbY="${mmStr2(hole.y)}" diameter="${mmStr2(hole.hole_diameter)}" />`);
328608
328647
  } else if (hole.hole_shape === "oval") {
328609
- console.warn("Unhandled oval hole in conversion (needs implementation)");
328648
+ elementStrings.push(`<hole pcbX="${mmStr2(hole.x)}" pcbY="${mmStr2(hole.y)}" width="${mmStr2(hole.hole_width)}" height="${mmStr2(hole.hole_height)}" shape="oval" />`);
328610
328649
  }
328611
328650
  }
328612
328651
  for (const platedHole of platedHoles) {
@@ -329214,6 +329253,40 @@ var getPinStemLength = (path72) => {
329214
329253
  return;
329215
329254
  return toSchematicUnits(Math.abs(Number(segment2[1])));
329216
329255
  };
329256
+ var getOpenPolylineEndpoints = (shapes, transformPoint2) => shapes.flatMap((shape) => {
329257
+ if (shape.type !== "POLYLINE" || shape.points.length < 2)
329258
+ return [];
329259
+ const first = shape.points[0];
329260
+ const last = shape.points[shape.points.length - 1];
329261
+ if (first.x === last.x && first.y === last.y)
329262
+ return [];
329263
+ return [transformPoint2(first), transformPoint2(last)];
329264
+ });
329265
+ var alignPortToDrawing = ({
329266
+ position: position2,
329267
+ direction: direction2,
329268
+ stemLength,
329269
+ drawingEndpoints
329270
+ }) => {
329271
+ if (stemLength === undefined)
329272
+ return position2;
329273
+ const outwardDirection = getUnitVectorFromDirection2(direction2);
329274
+ const expectedBodyConnection = {
329275
+ x: position2.x - outwardDirection.x * stemLength,
329276
+ y: position2.y - outwardDirection.y * stemLength
329277
+ };
329278
+ const alignmentTolerance = Math.max(0.02, stemLength * 0.25);
329279
+ const nearestEndpoint = drawingEndpoints.map((endpoint) => ({
329280
+ endpoint,
329281
+ distance: distance211(endpoint, expectedBodyConnection)
329282
+ })).filter((candidate) => candidate.distance <= alignmentTolerance).sort((a2, b3) => a2.distance - b3.distance)[0]?.endpoint;
329283
+ if (!nearestEndpoint)
329284
+ return position2;
329285
+ return {
329286
+ x: round(nearestEndpoint.x + outwardDirection.x * stemLength),
329287
+ y: round(nearestEndpoint.y + outwardDirection.y * stemLength)
329288
+ };
329289
+ };
329217
329290
  var getTextFontSize = (fontSize) => {
329218
329291
  const numericFontSize = Number.parseFloat(fontSize);
329219
329292
  if (!Number.isFinite(numericFontSize))
@@ -329280,7 +329353,8 @@ var getPortMetadataByShapeId = (easyEdaJson, circuitJson) => {
329280
329353
  var generateShapeTsx = ({
329281
329354
  shape,
329282
329355
  origin,
329283
- portMetadata
329356
+ portMetadata,
329357
+ drawingEndpoints = []
329284
329358
  }) => {
329285
329359
  const transformPoint2 = getPointTransformer(origin);
329286
329360
  if (shape.type === "RECTANGLE") {
@@ -329320,16 +329394,27 @@ var generateShapeTsx = ({
329320
329394
  return `<schematictext schX={${position2.x}} schY={${position2.y}} text=${JSON.stringify(shape.content)} fontSize={${getTextFontSize(shape.fontSize)}} anchor=${JSON.stringify(getTextAnchor(shape.alignment))} color=${JSON.stringify(shape.fontColor)} schRotation={${round(-shape.rotation)}} />`;
329321
329395
  }
329322
329396
  if (shape.type === "PIN" && portMetadata) {
329323
- const position2 = transformPoint2({ x: shape.x, y: shape.y });
329397
+ const direction2 = getPinDirection3(shape.rotation);
329398
+ const stemLength = getPinStemLength(shape.path);
329399
+ const position2 = alignPortToDrawing({
329400
+ position: transformPoint2({ x: shape.x, y: shape.y }),
329401
+ direction: direction2,
329402
+ stemLength,
329403
+ drawingEndpoints
329404
+ });
329324
329405
  const pinNumberProp = portMetadata.pinNumber === undefined ? "" : ` pinNumber={${portMetadata.pinNumber}}`;
329325
329406
  const aliasesProp = portMetadata.aliases.length === 0 ? "" : ` aliases={${JSON.stringify(portMetadata.aliases)}}`;
329326
- const stemLength = getPinStemLength(shape.path);
329327
329407
  const stemLengthProp = stemLength === undefined ? "" : ` schStemLength={${stemLength}}`;
329328
- return `<port name=${JSON.stringify(portMetadata.name)}${pinNumberProp}${aliasesProp} direction=${JSON.stringify(getPinDirection3(shape.rotation))} schX={${position2.x}} schY={${position2.y}}${stemLengthProp} />`;
329408
+ return `<port name=${JSON.stringify(portMetadata.name)}${pinNumberProp}${aliasesProp} direction=${JSON.stringify(direction2)} schX={${position2.x}} schY={${position2.y}}${stemLengthProp} />`;
329329
329409
  }
329410
+ if (shape.type === "IGNORED")
329411
+ return;
329330
329412
  return;
329331
329413
  };
329332
- var generateSymbolTsx2 = (easyEdaJson, circuitJson, { includePorts = true } = {}) => {
329414
+ var generateSymbolTsx2 = (easyEdaJson, circuitJson, {
329415
+ includePorts = true,
329416
+ alignPortsToDrawing = false
329417
+ } = {}) => {
329333
329418
  const shapes = easyEdaJson.dataStr.shape;
329334
329419
  if (shapes.length === 0)
329335
329420
  return;
@@ -329344,10 +329429,13 @@ var generateSymbolTsx2 = (easyEdaJson, circuitJson, { includePorts = true } = {}
329344
329429
  y: bounds.y + bounds.height / 2
329345
329430
  };
329346
329431
  const portMetadataByShapeId = getPortMetadataByShapeId(easyEdaJson, circuitJson);
329432
+ const transformPoint2 = getPointTransformer(origin);
329433
+ const drawingEndpoints = alignPortsToDrawing ? getOpenPolylineEndpoints(shapes, transformPoint2) : [];
329347
329434
  const shapeTsx = shapes.filter((shape) => includePorts || shape.type !== "PIN").map((shape) => generateShapeTsx({
329348
329435
  shape,
329349
329436
  origin,
329350
- portMetadata: shape.type === "PIN" ? portMetadataByShapeId.get(shape.id) : undefined
329437
+ portMetadata: shape.type === "PIN" ? portMetadataByShapeId.get(shape.id) : undefined,
329438
+ drawingEndpoints
329351
329439
  })).filter((tsx) => Boolean(tsx));
329352
329440
  if (shapeTsx.length === 0)
329353
329441
  return;
@@ -329357,7 +329445,7 @@ ${shapeTsx.map((tsx) => ` ${tsx}`).join(`
329357
329445
  </symbol>`;
329358
329446
  };
329359
329447
  var hasNonBoxSchematicSymbol = (easyEdaJson) => {
329360
- const drawableShapes = easyEdaJson.dataStr.shape.filter((shape) => shape.type !== "PIN" && shape.type !== "TEXT");
329448
+ const drawableShapes = easyEdaJson.dataStr.shape.filter((shape) => shape.type !== "PIN" && shape.type !== "TEXT" && shape.type !== "IGNORED");
329361
329449
  if (drawableShapes.length === 0)
329362
329450
  return false;
329363
329451
  const rectangles = drawableShapes.filter((shape) => shape.type === "RECTANGLE");
@@ -329452,7 +329540,7 @@ var convertBetterEasyToTsx = async ({
329452
329540
  const isMultiPinDiode = isDiodeCategoryComponent(betterEasy) && sourcePorts.length !== 2;
329453
329541
  const isPassiveWithCustomSymbol = componentType === "capacitor" || componentType === "resistor";
329454
329542
  const symbolTsx = isPassiveWithCustomSymbol || componentType === "chip" && !isMultiPinDiode && hasNonBoxSchematicSymbol(betterEasy) ? generateSymbolTsx2(betterEasy, circuitJson, {
329455
- includePorts: !isPassiveWithCustomSymbol
329543
+ alignPortsToDrawing: isPassiveWithCustomSymbol
329456
329544
  }) : undefined;
329457
329545
  return generateTypescriptComponent({
329458
329546
  componentName,
@@ -335802,7 +335890,7 @@ var SolidRegionSchema2 = BaseShapeSchema2.extend({
335802
335890
  type: z179.literal("SOLIDREGION"),
335803
335891
  layermask: z179.number(),
335804
335892
  points: z179.array(PointSchema3),
335805
- fillStyle: z179.string()
335893
+ fillStyle: z179.string().default("none")
335806
335894
  });
335807
335895
  var SVGNodeSchema2 = BaseShapeSchema2.extend({
335808
335896
  type: z179.literal("SVGNODE"),
@@ -335833,7 +335921,7 @@ var RectSchema2 = BaseShapeSchema2.extend({
335833
335921
  width: tenthmil2,
335834
335922
  height: tenthmil2,
335835
335923
  lineWidth: z179.number(),
335836
- fillStyle: z179.string(),
335924
+ fillStyle: z179.string().default("none"),
335837
335925
  rotation: z179.number().optional()
335838
335926
  });
335839
335927
  var TextSchema2 = BaseShapeSchema2.extend({
@@ -335991,7 +336079,7 @@ var ShapeItemSchema2 = z179.object({
335991
336079
  type: "SOLIDREGION",
335992
336080
  layermask: Number(layermask),
335993
336081
  points,
335994
- fillStyle,
336082
+ fillStyle: fillStyle || undefined,
335995
336083
  id: id2
335996
336084
  });
335997
336085
  }
@@ -336239,6 +336327,17 @@ var parsePath2 = (str) => {
336239
336327
  };
336240
336328
  };
336241
336329
  var PathShapeSchema2 = z180.string().startsWith("PT~").transform(parsePath2).pipe(PathShapeOutputSchema2);
336330
+ var IgnoredShapeOutputSchema2 = z180.object({
336331
+ type: z180.literal("IGNORED"),
336332
+ sourceType: z180.enum(["AR", "I"])
336333
+ });
336334
+ var IgnoredShapeSchema2 = z180.string().transform((shape) => {
336335
+ const sourceType = shape.startsWith("AR~") ? "AR" : shape.startsWith("I~") ? "I" : undefined;
336336
+ if (!sourceType) {
336337
+ throw new Error(`Invalid ignored shape: ${shape}`);
336338
+ }
336339
+ return { type: "IGNORED", sourceType };
336340
+ }).pipe(IgnoredShapeOutputSchema2);
336242
336341
  var optionalEasyEdaTextField2 = (fieldSchema) => z180.preprocess((textField) => {
336243
336342
  if (textField == null)
336244
336343
  return;
@@ -336322,6 +336421,9 @@ var SingleLetterShapeSchema2 = z180.string().transform((x4) => {
336322
336421
  return PathShapeSchema2.parse(x4);
336323
336422
  if (x4.startsWith("T~"))
336324
336423
  return TextShapeSchema2.parse(x4);
336424
+ if (x4.startsWith("AR~") || x4.startsWith("I~")) {
336425
+ return IgnoredShapeSchema2.parse(x4);
336426
+ }
336325
336427
  if (x4.startsWith("A~"))
336326
336428
  return ArcShapeSchema2.parse(x4);
336327
336429
  throw new Error(`Invalid shape type: ${x4}`);
@@ -336333,9 +336435,17 @@ var SingleLetterShapeSchema2 = z180.string().transform((x4) => {
336333
336435
  PolygonShapeOutputSchema2,
336334
336436
  PathShapeOutputSchema2,
336335
336437
  TextShapeOutputSchema2,
336438
+ IgnoredShapeOutputSchema2,
336336
336439
  ArcShapeOutputSchema2
336337
336440
  ]));
336338
336441
  var maybeNumber2 = z181.any().transform((k4) => k4 === "nan" || Number.isNaN(k4) ? null : k4).pipe(z181.number().nullable().optional());
336442
+ var optionalNumberWithNumericString2 = z181.preprocess((value) => {
336443
+ if (typeof value !== "string")
336444
+ return value;
336445
+ if (value.trim() === "")
336446
+ return;
336447
+ return Number(value);
336448
+ }, z181.number().optional());
336339
336449
  var SzlcscSchema2 = z181.object({
336340
336450
  id: z181.preprocess((value) => {
336341
336451
  if (typeof value === "string" && /^\d+$/.test(value)) {
@@ -336346,7 +336456,7 @@ var SzlcscSchema2 = z181.object({
336346
336456
  number: z181.string(),
336347
336457
  step: z181.number().optional(),
336348
336458
  min: z181.number().optional(),
336349
- price: z181.number().optional(),
336459
+ price: optionalNumberWithNumericString2,
336350
336460
  stock: z181.number().optional(),
336351
336461
  url: z181.string().url().optional(),
336352
336462
  image: z181.string().optional().optional()
@@ -336356,7 +336466,7 @@ var LcscSchema2 = z181.object({
336356
336466
  number: z181.string(),
336357
336467
  step: z181.number().optional(),
336358
336468
  min: z181.number().optional(),
336359
- price: z181.number().optional(),
336469
+ price: optionalNumberWithNumericString2,
336360
336470
  stock: z181.number().optional(),
336361
336471
  url: z181.string().url().optional()
336362
336472
  });
package/dist/lib/index.js CHANGED
@@ -65757,7 +65757,7 @@ var getNodeHandler = (winterSpec, { port, middleware = [] }) => {
65757
65757
  }));
65758
65758
  };
65759
65759
  // package.json
65760
- var version = "0.1.1947";
65760
+ var version = "0.1.1948";
65761
65761
  var package_default = {
65762
65762
  name: "@tscircuit/cli",
65763
65763
  version,
@@ -65818,7 +65818,7 @@ var package_default = {
65818
65818
  debug: "^4.4.0",
65819
65819
  delay: "^6.0.0",
65820
65820
  "dsn-converter": "^0.0.90",
65821
- easyeda: "^0.0.301",
65821
+ easyeda: "^0.0.305",
65822
65822
  "fuse.js": "^7.1.0",
65823
65823
  "get-port": "^7.1.0",
65824
65824
  globby: "^14.1.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.1.1948",
3
+ "version": "0.1.1949",
4
4
  "main": "dist/cli/main.js",
5
5
  "exports": {
6
6
  ".": "./dist/cli/main.js",
@@ -58,7 +58,7 @@
58
58
  "debug": "^4.4.0",
59
59
  "delay": "^6.0.0",
60
60
  "dsn-converter": "^0.0.90",
61
- "easyeda": "^0.0.301",
61
+ "easyeda": "^0.0.305",
62
62
  "fuse.js": "^7.1.0",
63
63
  "get-port": "^7.1.0",
64
64
  "globby": "^14.1.0",