easyeda 0.0.302 → 0.0.304

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/main.cjs CHANGED
@@ -3528,7 +3528,7 @@ var import_promises = __toESM(require("fs/promises"), 1);
3528
3528
  var package_default = {
3529
3529
  name: "easyeda",
3530
3530
  type: "module",
3531
- version: "0.0.301",
3531
+ version: "0.0.303",
3532
3532
  files: [
3533
3533
  "dist"
3534
3534
  ],
@@ -10261,7 +10261,7 @@ var SolidRegionSchema = BaseShapeSchema.extend({
10261
10261
  type: import_zod179.z.literal("SOLIDREGION"),
10262
10262
  layermask: import_zod179.z.number(),
10263
10263
  points: import_zod179.z.array(PointSchema),
10264
- fillStyle: import_zod179.z.string()
10264
+ fillStyle: import_zod179.z.string().default("none")
10265
10265
  });
10266
10266
  var SVGNodeSchema = BaseShapeSchema.extend({
10267
10267
  type: import_zod179.z.literal("SVGNODE"),
@@ -10292,7 +10292,7 @@ var RectSchema = BaseShapeSchema.extend({
10292
10292
  width: tenthmil,
10293
10293
  height: tenthmil,
10294
10294
  lineWidth: import_zod179.z.number(),
10295
- fillStyle: import_zod179.z.string(),
10295
+ fillStyle: import_zod179.z.string().default("none"),
10296
10296
  rotation: import_zod179.z.number().optional()
10297
10297
  });
10298
10298
  var TextSchema = BaseShapeSchema.extend({
@@ -10455,7 +10455,7 @@ var ShapeItemSchema = import_zod179.z.object({
10455
10455
  type: "SOLIDREGION",
10456
10456
  layermask: Number(layermask),
10457
10457
  points,
10458
- fillStyle,
10458
+ fillStyle: fillStyle || void 0,
10459
10459
  id
10460
10460
  });
10461
10461
  }
@@ -10703,6 +10703,17 @@ var parsePath = (str) => {
10703
10703
  };
10704
10704
  };
10705
10705
  var PathShapeSchema = import_zod180.z.string().startsWith("PT~").transform(parsePath).pipe(PathShapeOutputSchema);
10706
+ var IgnoredShapeOutputSchema = import_zod180.z.object({
10707
+ type: import_zod180.z.literal("IGNORED"),
10708
+ sourceType: import_zod180.z.enum(["AR", "I"])
10709
+ });
10710
+ var IgnoredShapeSchema = import_zod180.z.string().transform((shape) => {
10711
+ const sourceType = shape.startsWith("AR~") ? "AR" : shape.startsWith("I~") ? "I" : void 0;
10712
+ if (!sourceType) {
10713
+ throw new Error(`Invalid ignored shape: ${shape}`);
10714
+ }
10715
+ return { type: "IGNORED", sourceType };
10716
+ }).pipe(IgnoredShapeOutputSchema);
10706
10717
  var optionalEasyEdaTextField = (fieldSchema) => import_zod180.z.preprocess((textField) => {
10707
10718
  if (textField == null) return void 0;
10708
10719
  if (typeof textField === "string") {
@@ -10781,6 +10792,9 @@ var SingleLetterShapeSchema = import_zod180.z.string().transform((x) => {
10781
10792
  if (x.startsWith("PG~")) return PolygonShapeSchema.parse(x);
10782
10793
  if (x.startsWith("PT~")) return PathShapeSchema.parse(x);
10783
10794
  if (x.startsWith("T~")) return TextShapeSchema.parse(x);
10795
+ if (x.startsWith("AR~") || x.startsWith("I~")) {
10796
+ return IgnoredShapeSchema.parse(x);
10797
+ }
10784
10798
  if (x.startsWith("A~")) return ArcShapeSchema.parse(x);
10785
10799
  throw new Error(`Invalid shape type: ${x}`);
10786
10800
  }).pipe(
@@ -10792,12 +10806,18 @@ var SingleLetterShapeSchema = import_zod180.z.string().transform((x) => {
10792
10806
  PolygonShapeOutputSchema,
10793
10807
  PathShapeOutputSchema,
10794
10808
  TextShapeOutputSchema,
10809
+ IgnoredShapeOutputSchema,
10795
10810
  ArcShapeOutputSchema
10796
10811
  ])
10797
10812
  );
10798
10813
 
10799
10814
  // lib/schemas/easy-eda-json-schema.ts
10800
10815
  var maybeNumber = import_zod181.z.any().transform((k) => k === "nan" || Number.isNaN(k) ? null : k).pipe(import_zod181.z.number().nullable().optional());
10816
+ var optionalNumberWithNumericString = import_zod181.z.preprocess((value) => {
10817
+ if (typeof value !== "string") return value;
10818
+ if (value.trim() === "") return void 0;
10819
+ return Number(value);
10820
+ }, import_zod181.z.number().optional());
10801
10821
  var SzlcscSchema = import_zod181.z.object({
10802
10822
  id: import_zod181.z.preprocess((value) => {
10803
10823
  if (typeof value === "string" && /^\d+$/.test(value)) {
@@ -10808,7 +10828,7 @@ var SzlcscSchema = import_zod181.z.object({
10808
10828
  number: import_zod181.z.string(),
10809
10829
  step: import_zod181.z.number().optional(),
10810
10830
  min: import_zod181.z.number().optional(),
10811
- price: import_zod181.z.number().optional(),
10831
+ price: optionalNumberWithNumericString,
10812
10832
  stock: import_zod181.z.number().optional(),
10813
10833
  url: import_zod181.z.string().url().optional(),
10814
10834
  image: import_zod181.z.string().optional().optional()
@@ -10818,7 +10838,7 @@ var LcscSchema = import_zod181.z.object({
10818
10838
  number: import_zod181.z.string(),
10819
10839
  step: import_zod181.z.number().optional(),
10820
10840
  min: import_zod181.z.number().optional(),
10821
- price: import_zod181.z.number().optional(),
10841
+ price: optionalNumberWithNumericString,
10822
10842
  stock: import_zod181.z.number().optional(),
10823
10843
  url: import_zod181.z.string().url().optional()
10824
10844
  });
@@ -11090,7 +11110,9 @@ var generateFootprintTsx = (circuitJson, options = {}) => {
11090
11110
  `<hole pcbX="${mmStr(hole.x)}" pcbY="${mmStr(hole.y)}" diameter="${mmStr(hole.hole_diameter)}" />`
11091
11111
  );
11092
11112
  } else if (hole.hole_shape === "oval") {
11093
- console.warn("Unhandled oval hole in conversion (needs implementation)");
11113
+ elementStrings.push(
11114
+ `<hole pcbX="${mmStr(hole.x)}" pcbY="${mmStr(hole.y)}" width="${mmStr(hole.hole_width)}" height="${mmStr(hole.hole_height)}" shape="oval" />`
11115
+ );
11094
11116
  }
11095
11117
  }
11096
11118
  for (const platedHole of platedHoles) {
@@ -11862,6 +11884,7 @@ var generateShapeTsx = ({
11862
11884
  const stemLengthProp = stemLength === void 0 ? "" : ` schStemLength={${stemLength}}`;
11863
11885
  return `<port name=${JSON.stringify(portMetadata.name)}${pinNumberProp}${aliasesProp} direction=${JSON.stringify(getPinDirection(shape.rotation))} schX={${position2.x}} schY={${position2.y}}${stemLengthProp} />`;
11864
11886
  }
11887
+ if (shape.type === "IGNORED") return void 0;
11865
11888
  return void 0;
11866
11889
  };
11867
11890
  var generateSymbolTsx = (easyEdaJson, circuitJson, { includePorts = true } = {}) => {
@@ -11895,7 +11918,7 @@ ${shapeTsx.map((tsx) => ` ${tsx}`).join("\n")}
11895
11918
  };
11896
11919
  var hasNonBoxSchematicSymbol = (easyEdaJson) => {
11897
11920
  const drawableShapes = easyEdaJson.dataStr.shape.filter(
11898
- (shape) => shape.type !== "PIN" && shape.type !== "TEXT"
11921
+ (shape) => shape.type !== "PIN" && shape.type !== "TEXT" && shape.type !== "IGNORED"
11899
11922
  );
11900
11923
  if (drawableShapes.length === 0) return false;
11901
11924
  const rectangles = drawableShapes.filter(