easyeda 0.0.351 → 0.0.352

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 CHANGED
@@ -7474,6 +7474,60 @@ var getModelStepCdnUrl = ({
7474
7474
  };
7475
7475
  var getModelCdnUrl = getModelObjCdnUrl;
7476
7476
 
7477
+ // lib/websafe/parse-easyeda-search-response.ts
7478
+ import { z as z199 } from "zod";
7479
+ var searchEnvelopeSchema = z199.object({
7480
+ success: z199.boolean(),
7481
+ code: z199.number().optional(),
7482
+ message: z199.string().optional()
7483
+ });
7484
+ var supplierNumberSchema = z199.object({ number: z199.string().nullish() }).nullish();
7485
+ var searchResultsSchema = z199.object({
7486
+ result: z199.object({
7487
+ lists: z199.object({
7488
+ lcsc: z199.array(
7489
+ z199.object({
7490
+ uuid: z199.string().min(1),
7491
+ lcsc: supplierNumberSchema,
7492
+ szlcsc: supplierNumberSchema,
7493
+ dataStr: z199.object({
7494
+ head: z199.object({
7495
+ c_para: z199.object({ "Supplier Part": z199.string().nullish() }).nullish()
7496
+ }).nullish()
7497
+ }).nullish()
7498
+ })
7499
+ )
7500
+ })
7501
+ })
7502
+ });
7503
+ var parseEasyEdaSearchResponse = (searchResponse, jlcpcbPartNumber) => {
7504
+ const envelope = searchEnvelopeSchema.safeParse(searchResponse);
7505
+ if (!envelope.success) {
7506
+ throw new Error(
7507
+ `Invalid EasyEDA search response for "${jlcpcbPartNumber}": expected a boolean success field`
7508
+ );
7509
+ }
7510
+ if (!envelope.data.success) {
7511
+ const { code, message } = envelope.data;
7512
+ throw new Error(
7513
+ `EasyEDA API rejected the component search for "${jlcpcbPartNumber}"${code === void 0 ? "" : ` (code ${code})`}${message ? `: ${message}` : ""}`
7514
+ );
7515
+ }
7516
+ const searchResults = searchResultsSchema.safeParse(searchResponse);
7517
+ if (!searchResults.success) {
7518
+ throw new Error(
7519
+ `Invalid EasyEDA search response for "${jlcpcbPartNumber}": expected result.lists.lcsc containing component UUIDs and supplier metadata`
7520
+ );
7521
+ }
7522
+ const components = searchResults.data.result.lists.lcsc;
7523
+ if (components.length === 0) {
7524
+ throw new Error(
7525
+ `Component not found in EasyEDA library search for "${jlcpcbPartNumber}". A supplier catalog listing does not guarantee importable symbol/footprint data.`
7526
+ );
7527
+ }
7528
+ return components;
7529
+ };
7530
+
7477
7531
  // lib/websafe/fetch-easyeda-json.ts
7478
7532
  var getModelUuidFromRawPackageDetail = (result) => {
7479
7533
  const shapes = result.packageDetail?.dataStr?.shape;
@@ -7506,17 +7560,17 @@ var parseObjBounds = (objText) => {
7506
7560
  const [, xStr, yStr, zStr] = trimmed.split(/\s+/, 4);
7507
7561
  const x = Number(xStr);
7508
7562
  const y = Number(yStr);
7509
- const z202 = Number(zStr);
7510
- if (!Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(z202)) {
7563
+ const z203 = Number(zStr);
7564
+ if (!Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(z203)) {
7511
7565
  continue;
7512
7566
  }
7513
7567
  vertexCount += 1;
7514
7568
  minX = Math.min(minX, x);
7515
7569
  minY = Math.min(minY, y);
7516
- minZ = Math.min(minZ, z202);
7570
+ minZ = Math.min(minZ, z203);
7517
7571
  maxX = Math.max(maxX, x);
7518
7572
  maxY = Math.max(maxY, y);
7519
- maxZ = Math.max(maxZ, z202);
7573
+ maxZ = Math.max(maxZ, z203);
7520
7574
  }
7521
7575
  if (vertexCount === 0) return null;
7522
7576
  return {
@@ -7562,23 +7616,21 @@ async function fetchEasyEDAComponent(jlcpcbPartNumber, {
7562
7616
  `Failed to search for the component (HTTP ${searchResponse.status})`
7563
7617
  );
7564
7618
  }
7565
- const searchResult = await searchResponse.json();
7566
- if (!searchResult.success || !searchResult.result.lists.lcsc.length) {
7567
- throw new Error("Component not found");
7568
- }
7569
- const requestedPartNumber = jlcpcbPartNumber.trim().toUpperCase();
7570
- const bestMatchComponent = searchResult.result.lists.lcsc.find(
7571
- (component) => {
7572
- const candidatePartNumbers = [
7573
- component.dataStr?.head?.c_para?.["Supplier Part"],
7574
- component.lcsc?.number,
7575
- component.szlcsc?.number
7576
- ];
7577
- return candidatePartNumbers.some(
7578
- (partNumber) => typeof partNumber === "string" && partNumber.trim().toUpperCase() === requestedPartNumber
7579
- );
7580
- }
7619
+ const searchComponents = parseEasyEdaSearchResponse(
7620
+ await searchResponse.json(),
7621
+ jlcpcbPartNumber
7581
7622
  );
7623
+ const requestedPartNumber = jlcpcbPartNumber.trim().toUpperCase();
7624
+ const bestMatchComponent = searchComponents.find((component) => {
7625
+ const candidatePartNumbers = [
7626
+ component.dataStr?.head?.c_para?.["Supplier Part"],
7627
+ component.lcsc?.number,
7628
+ component.szlcsc?.number
7629
+ ];
7630
+ return candidatePartNumbers.some(
7631
+ (partNumber) => typeof partNumber === "string" && partNumber.trim().toUpperCase() === requestedPartNumber
7632
+ );
7633
+ });
7582
7634
  if (!bestMatchComponent) {
7583
7635
  throw new Error(
7584
7636
  `No exact EasyEDA component match for "${jlcpcbPartNumber}"`
@@ -7634,18 +7686,18 @@ async function fetchEasyEDAComponent(jlcpcbPartNumber, {
7634
7686
  }
7635
7687
 
7636
7688
  // lib/schemas/easy-eda-json-schema.ts
7637
- import { z as z201 } from "zod";
7689
+ import { z as z202 } from "zod";
7638
7690
 
7639
7691
  // lib/schemas/package-detail-shape-schema.ts
7640
- import { z as z199 } from "zod";
7641
- var safeNumber = (defaultValue = 0) => z199.union([z199.number(), z199.string()]).transform((val) => {
7692
+ import { z as z200 } from "zod";
7693
+ var safeNumber = (defaultValue = 0) => z200.union([z200.number(), z200.string()]).transform((val) => {
7642
7694
  const num = Number(val);
7643
7695
  return Number.isNaN(num) ? defaultValue : num;
7644
7696
  }).default(defaultValue);
7645
- var tenthmil = z199.union([z199.number(), z199.string()]).optional().transform(
7697
+ var tenthmil = z200.union([z200.number(), z200.string()]).optional().transform(
7646
7698
  (n) => typeof n === "string" && n.endsWith("mil") ? n : `${Number.parseFloat(n) * 10}mil`
7647
- ).pipe(z199.string());
7648
- var PointSchema = z199.any().transform((p) => {
7699
+ ).pipe(z200.string());
7700
+ var PointSchema = z200.any().transform((p) => {
7649
7701
  if (Array.isArray(p)) {
7650
7702
  const [x, y] = p;
7651
7703
  return { x, y };
@@ -7655,106 +7707,106 @@ var PointSchema = z199.any().transform((p) => {
7655
7707
  }
7656
7708
  throw new Error(`Invalid point: ${p}`);
7657
7709
  }).pipe(
7658
- z199.object({
7659
- x: z199.number(),
7660
- y: z199.number()
7710
+ z200.object({
7711
+ x: z200.number(),
7712
+ y: z200.number()
7661
7713
  })
7662
7714
  );
7663
- var BaseShapeSchema = z199.object({
7664
- type: z199.string(),
7665
- id: z199.string().optional(),
7666
- layer: z199.coerce.number().optional()
7715
+ var BaseShapeSchema = z200.object({
7716
+ type: z200.string(),
7717
+ id: z200.string().optional(),
7718
+ layer: z200.coerce.number().optional()
7667
7719
  });
7668
7720
  var TrackSchema = BaseShapeSchema.extend({
7669
- type: z199.literal("TRACK"),
7670
- width: z199.coerce.number(),
7671
- points: z199.array(PointSchema)
7721
+ type: z200.literal("TRACK"),
7722
+ width: z200.coerce.number(),
7723
+ points: z200.array(PointSchema)
7672
7724
  });
7673
7725
  var PadSchema = BaseShapeSchema.extend({
7674
- type: z199.literal("PAD"),
7675
- shape: z199.enum(["RECT", "ELLIPSE", "OVAL", "POLYGON"]),
7676
- center: z199.object({
7726
+ type: z200.literal("PAD"),
7727
+ shape: z200.enum(["RECT", "ELLIPSE", "OVAL", "POLYGON"]),
7728
+ center: z200.object({
7677
7729
  x: tenthmil,
7678
7730
  y: tenthmil
7679
7731
  }),
7680
7732
  width: tenthmil,
7681
7733
  height: tenthmil,
7682
- layermask: z199.number(),
7683
- net: z199.union([z199.string(), z199.number()]).optional(),
7684
- number: z199.union([z199.string(), z199.number()]),
7734
+ layermask: z200.number(),
7735
+ net: z200.union([z200.string(), z200.number()]).optional(),
7736
+ number: z200.union([z200.string(), z200.number()]),
7685
7737
  holeRadius: tenthmil,
7686
- points: z199.array(PointSchema).optional(),
7738
+ points: z200.array(PointSchema).optional(),
7687
7739
  rotation: safeNumber(0),
7688
7740
  // Will default to 0 if NaN or missing
7689
- plated: z199.boolean()
7741
+ plated: z200.boolean()
7690
7742
  });
7691
7743
  var ArcSchema = BaseShapeSchema.extend({
7692
- type: z199.literal("ARC"),
7693
- width: z199.number(),
7744
+ type: z200.literal("ARC"),
7745
+ width: z200.number(),
7694
7746
  start: PointSchema,
7695
7747
  end: PointSchema,
7696
- radiusX: z199.number(),
7697
- radiusY: z199.number(),
7698
- largeArc: z199.boolean(),
7699
- sweepDirection: z199.enum(["CW", "CCW"])
7748
+ radiusX: z200.number(),
7749
+ radiusY: z200.number(),
7750
+ largeArc: z200.boolean(),
7751
+ sweepDirection: z200.enum(["CW", "CCW"])
7700
7752
  });
7701
7753
  var CircleSchema = BaseShapeSchema.extend({
7702
- type: z199.literal("CIRCLE"),
7754
+ type: z200.literal("CIRCLE"),
7703
7755
  center: PointSchema,
7704
- radius: z199.number(),
7705
- width: z199.number()
7756
+ radius: z200.number(),
7757
+ width: z200.number()
7706
7758
  });
7707
7759
  var SolidRegionSchema = BaseShapeSchema.extend({
7708
- type: z199.literal("SOLIDREGION"),
7709
- layermask: z199.number(),
7710
- pathData: z199.string(),
7711
- points: z199.array(PointSchema),
7712
- fillStyle: z199.string().default("none")
7760
+ type: z200.literal("SOLIDREGION"),
7761
+ layermask: z200.number(),
7762
+ pathData: z200.string(),
7763
+ points: z200.array(PointSchema),
7764
+ fillStyle: z200.string().default("none")
7713
7765
  });
7714
7766
  var SVGNodeSchema = BaseShapeSchema.extend({
7715
- type: z199.literal("SVGNODE"),
7716
- svgData: z199.object({
7717
- gId: z199.string(),
7718
- nodeName: z199.string(),
7719
- nodeType: z199.number(),
7720
- layerid: z199.string(),
7721
- attrs: z199.record(z199.string(), z199.string()),
7722
- childNodes: z199.array(z199.unknown())
7767
+ type: z200.literal("SVGNODE"),
7768
+ svgData: z200.object({
7769
+ gId: z200.string(),
7770
+ nodeName: z200.string(),
7771
+ nodeType: z200.number(),
7772
+ layerid: z200.string(),
7773
+ attrs: z200.record(z200.string(), z200.string()),
7774
+ childNodes: z200.array(z200.unknown())
7723
7775
  })
7724
7776
  });
7725
7777
  var HoleSchema = BaseShapeSchema.extend({
7726
- type: z199.literal("HOLE"),
7778
+ type: z200.literal("HOLE"),
7727
7779
  center: PointSchema,
7728
- radius: z199.number()
7780
+ radius: z200.number()
7729
7781
  });
7730
7782
  var ViaSchema = BaseShapeSchema.extend({
7731
- type: z199.literal("VIA"),
7783
+ type: z200.literal("VIA"),
7732
7784
  center: PointSchema,
7733
- outerDiameter: z199.number(),
7734
- holeRadius: z199.number()
7785
+ outerDiameter: z200.number(),
7786
+ holeRadius: z200.number()
7735
7787
  });
7736
7788
  var RectSchema = BaseShapeSchema.extend({
7737
- type: z199.literal("RECT"),
7789
+ type: z200.literal("RECT"),
7738
7790
  x: tenthmil,
7739
7791
  y: tenthmil,
7740
7792
  width: tenthmil,
7741
7793
  height: tenthmil,
7742
- lineWidth: z199.number(),
7743
- fillStyle: z199.string().default("none"),
7744
- rotation: z199.number().optional()
7794
+ lineWidth: z200.number(),
7795
+ fillStyle: z200.string().default("none"),
7796
+ rotation: z200.number().optional()
7745
7797
  });
7746
7798
  var TextSchema = BaseShapeSchema.extend({
7747
- type: z199.literal("TEXT"),
7748
- text: z199.string(),
7799
+ type: z200.literal("TEXT"),
7800
+ text: z200.string(),
7749
7801
  x: tenthmil,
7750
7802
  y: tenthmil,
7751
- size_mm: z199.number(),
7752
- rotation: z199.number().optional(),
7753
- layer: z199.number().optional(),
7754
- textAnchor: z199.enum(["L", "C", "R", ""]).optional().transform((val) => val === "" ? void 0 : val),
7755
- font: z199.string().optional()
7803
+ size_mm: z200.number(),
7804
+ rotation: z200.number().optional(),
7805
+ layer: z200.number().optional(),
7806
+ textAnchor: z200.enum(["L", "C", "R", ""]).optional().transform((val) => val === "" ? void 0 : val),
7807
+ font: z200.string().optional()
7756
7808
  });
7757
- var PackageDetailShapeSchema = z199.discriminatedUnion("type", [
7809
+ var PackageDetailShapeSchema = z200.discriminatedUnion("type", [
7758
7810
  TrackSchema,
7759
7811
  PadSchema,
7760
7812
  ArcSchema,
@@ -7776,9 +7828,9 @@ var pairs = (arr) => {
7776
7828
  var parsePoints = (pointsStr) => pairs(
7777
7829
  pointsStr.trim().split(" ").map((n) => Number(n))
7778
7830
  );
7779
- var ShapeItemSchema = z199.object({
7780
- type: z199.string(),
7781
- data: z199.string()
7831
+ var ShapeItemSchema = z200.object({
7832
+ type: z200.string(),
7833
+ data: z200.string()
7782
7834
  }).transform((shape) => {
7783
7835
  switch (shape.type) {
7784
7836
  case "TRACK": {
@@ -7959,23 +8011,23 @@ var ShapeItemSchema = z199.object({
7959
8011
  throw new Error(`Unknown shape type: ${shape.type}`);
7960
8012
  }
7961
8013
  }).pipe(PackageDetailShapeSchema);
7962
- var ShapesArraySchema = z199.array(ShapeItemSchema);
8014
+ var ShapesArraySchema = z200.array(ShapeItemSchema);
7963
8015
 
7964
8016
  // lib/schemas/single-letter-shape-schema.ts
7965
- import { z as z200 } from "zod";
7966
- var PointSchema2 = z200.object({
7967
- x: z200.number(),
7968
- y: z200.number()
8017
+ import { z as z201 } from "zod";
8018
+ var PointSchema2 = z201.object({
8019
+ x: z201.number(),
8020
+ y: z201.number()
7969
8021
  });
7970
- var RectangleShapeOutputSchema = z200.object({
7971
- type: z200.literal("RECTANGLE"),
8022
+ var RectangleShapeOutputSchema = z201.object({
8023
+ type: z201.literal("RECTANGLE"),
7972
8024
  position: PointSchema2,
7973
- width: z200.number(),
7974
- height: z200.number(),
7975
- color: z200.string(),
7976
- lineWidth: z200.number(),
7977
- fillColor: z200.string().optional(),
7978
- id: z200.string()
8025
+ width: z201.number(),
8026
+ height: z201.number(),
8027
+ color: z201.string(),
8028
+ lineWidth: z201.number(),
8029
+ fillColor: z201.string().optional(),
8030
+ id: z201.string()
7979
8031
  });
7980
8032
  var parseRectangle = (str) => {
7981
8033
  const [, x, y, , , width, height, color, lineWidth, , fillColor, id] = str.split("~");
@@ -7990,16 +8042,16 @@ var parseRectangle = (str) => {
7990
8042
  id
7991
8043
  };
7992
8044
  };
7993
- var RectangleShapeSchema = z200.string().startsWith("R~").transform(parseRectangle).pipe(RectangleShapeOutputSchema);
7994
- var EllipseShapeOutputSchema = z200.object({
7995
- type: z200.literal("ELLIPSE"),
8045
+ var RectangleShapeSchema = z201.string().startsWith("R~").transform(parseRectangle).pipe(RectangleShapeOutputSchema);
8046
+ var EllipseShapeOutputSchema = z201.object({
8047
+ type: z201.literal("ELLIPSE"),
7996
8048
  center: PointSchema2,
7997
- radiusX: z200.number(),
7998
- radiusY: z200.number(),
7999
- color: z200.string(),
8000
- lineWidth: z200.number(),
8001
- fillColor: z200.string().optional(),
8002
- id: z200.string()
8049
+ radiusX: z201.number(),
8050
+ radiusY: z201.number(),
8051
+ color: z201.string(),
8052
+ lineWidth: z201.number(),
8053
+ fillColor: z201.string().optional(),
8054
+ id: z201.string()
8003
8055
  });
8004
8056
  var parseEllipse = (str) => {
8005
8057
  const [, x, y, radiusX, radiusY, color, lineWidth, , fillColor, id] = str.split("~");
@@ -8014,17 +8066,17 @@ var parseEllipse = (str) => {
8014
8066
  id
8015
8067
  };
8016
8068
  };
8017
- var EllipseShapeSchema = z200.string().startsWith("E~").transform(parseEllipse).pipe(EllipseShapeOutputSchema);
8018
- var ArcShapeOutputSchema = z200.object({
8019
- type: z200.literal("ARC"),
8020
- pathData: z200.string(),
8069
+ var EllipseShapeSchema = z201.string().startsWith("E~").transform(parseEllipse).pipe(EllipseShapeOutputSchema);
8070
+ var ArcShapeOutputSchema = z201.object({
8071
+ type: z201.literal("ARC"),
8072
+ pathData: z201.string(),
8021
8073
  start: PointSchema2,
8022
8074
  end: PointSchema2,
8023
- radius: z200.number(),
8024
- sweepFlag: z200.boolean(),
8025
- color: z200.string(),
8026
- lineWidth: z200.number(),
8027
- id: z200.string()
8075
+ radius: z201.number(),
8076
+ sweepFlag: z201.boolean(),
8077
+ color: z201.string(),
8078
+ lineWidth: z201.number(),
8079
+ id: z201.string()
8028
8080
  });
8029
8081
  var parseArc = (str) => {
8030
8082
  const [, pathData, ...fields] = str.split("~");
@@ -8048,19 +8100,19 @@ var parseArc = (str) => {
8048
8100
  id
8049
8101
  };
8050
8102
  };
8051
- var ArcShapeSchema = z200.string().startsWith("A~").transform(parseArc).pipe(ArcShapeOutputSchema);
8052
- var PinShapeOutputSchema = z200.object({
8053
- type: z200.literal("PIN"),
8054
- visibility: z200.enum(["show", "hide", "none"]),
8055
- pinNumber: z200.union([z200.string(), z200.number()]),
8056
- x: z200.number(),
8057
- y: z200.number(),
8058
- rotation: z200.number(),
8059
- id: z200.string(),
8060
- label: z200.string(),
8061
- labelColor: z200.string(),
8062
- path: z200.string(),
8063
- arrow: z200.string()
8103
+ var ArcShapeSchema = z201.string().startsWith("A~").transform(parseArc).pipe(ArcShapeOutputSchema);
8104
+ var PinShapeOutputSchema = z201.object({
8105
+ type: z201.literal("PIN"),
8106
+ visibility: z201.enum(["show", "hide", "none"]),
8107
+ pinNumber: z201.union([z201.string(), z201.number()]),
8108
+ x: z201.number(),
8109
+ y: z201.number(),
8110
+ rotation: z201.number(),
8111
+ id: z201.string(),
8112
+ label: z201.string(),
8113
+ labelColor: z201.string(),
8114
+ path: z201.string(),
8115
+ arrow: z201.string()
8064
8116
  });
8065
8117
  var parsePin = (pinString) => {
8066
8118
  const parts = pinString.split("~");
@@ -8093,13 +8145,13 @@ var parsePin = (pinString) => {
8093
8145
  arrow
8094
8146
  };
8095
8147
  };
8096
- var PinShapeSchema = z200.string().startsWith("P~").transform(parsePin).pipe(PinShapeOutputSchema);
8097
- var PolylineShapeOutputSchema = z200.object({
8098
- type: z200.literal("POLYLINE"),
8099
- points: z200.array(PointSchema2),
8100
- color: z200.string(),
8101
- lineWidth: z200.number(),
8102
- id: z200.string()
8148
+ var PinShapeSchema = z201.string().startsWith("P~").transform(parsePin).pipe(PinShapeOutputSchema);
8149
+ var PolylineShapeOutputSchema = z201.object({
8150
+ type: z201.literal("POLYLINE"),
8151
+ points: z201.array(PointSchema2),
8152
+ color: z201.string(),
8153
+ lineWidth: z201.number(),
8154
+ id: z201.string()
8103
8155
  });
8104
8156
  var parsePoints2 = (pointsStr) => {
8105
8157
  return pointsStr.split(" ").reduce((acc, value, index) => {
@@ -8122,14 +8174,14 @@ var parsePolyline = (str) => {
8122
8174
  id
8123
8175
  };
8124
8176
  };
8125
- var PolylineShapeSchema = z200.string().startsWith("PL~").transform(parsePolyline).pipe(PolylineShapeOutputSchema);
8126
- var PolygonShapeOutputSchema = z200.object({
8127
- type: z200.literal("POLYGON"),
8128
- points: z200.array(PointSchema2),
8129
- fillColor: z200.string(),
8130
- lineWidth: z200.number(),
8131
- lineColor: z200.string(),
8132
- id: z200.string()
8177
+ var PolylineShapeSchema = z201.string().startsWith("PL~").transform(parsePolyline).pipe(PolylineShapeOutputSchema);
8178
+ var PolygonShapeOutputSchema = z201.object({
8179
+ type: z201.literal("POLYGON"),
8180
+ points: z201.array(PointSchema2),
8181
+ fillColor: z201.string(),
8182
+ lineWidth: z201.number(),
8183
+ lineColor: z201.string(),
8184
+ id: z201.string()
8133
8185
  });
8134
8186
  var parsePolygon = (str) => {
8135
8187
  const [, ...rest] = str.split("~");
@@ -8143,14 +8195,14 @@ var parsePolygon = (str) => {
8143
8195
  id
8144
8196
  };
8145
8197
  };
8146
- var PolygonShapeSchema = z200.string().startsWith("PG~").transform(parsePolygon).pipe(PolygonShapeOutputSchema);
8147
- var PathShapeOutputSchema = z200.object({
8148
- type: z200.literal("PATH"),
8149
- pathData: z200.string(),
8150
- fillColor: z200.string(),
8151
- strokeWidth: z200.number(),
8152
- strokeColor: z200.string(),
8153
- id: z200.string()
8198
+ var PolygonShapeSchema = z201.string().startsWith("PG~").transform(parsePolygon).pipe(PolygonShapeOutputSchema);
8199
+ var PathShapeOutputSchema = z201.object({
8200
+ type: z201.literal("PATH"),
8201
+ pathData: z201.string(),
8202
+ fillColor: z201.string(),
8203
+ strokeWidth: z201.number(),
8204
+ strokeColor: z201.string(),
8205
+ id: z201.string()
8154
8206
  });
8155
8207
  var parsePath = (str) => {
8156
8208
  const [, pathData, strokeColor, strokeWidth, , fillColor, id] = str.split("~");
@@ -8163,19 +8215,19 @@ var parsePath = (str) => {
8163
8215
  id
8164
8216
  };
8165
8217
  };
8166
- var PathShapeSchema = z200.string().startsWith("PT~").transform(parsePath).pipe(PathShapeOutputSchema);
8167
- var IgnoredShapeOutputSchema = z200.object({
8168
- type: z200.literal("IGNORED"),
8169
- sourceType: z200.enum(["AR", "I"])
8218
+ var PathShapeSchema = z201.string().startsWith("PT~").transform(parsePath).pipe(PathShapeOutputSchema);
8219
+ var IgnoredShapeOutputSchema = z201.object({
8220
+ type: z201.literal("IGNORED"),
8221
+ sourceType: z201.enum(["AR", "I"])
8170
8222
  });
8171
- var IgnoredShapeSchema = z200.string().transform((shape) => {
8223
+ var IgnoredShapeSchema = z201.string().transform((shape) => {
8172
8224
  const sourceType = shape.startsWith("AR~") ? "AR" : shape.startsWith("I~") ? "I" : void 0;
8173
8225
  if (!sourceType) {
8174
8226
  throw new Error(`Invalid ignored shape: ${shape}`);
8175
8227
  }
8176
8228
  return { type: "IGNORED", sourceType };
8177
8229
  }).pipe(IgnoredShapeOutputSchema);
8178
- var optionalEasyEdaTextField = (fieldSchema) => z200.preprocess((textField) => {
8230
+ var optionalEasyEdaTextField = (fieldSchema) => z201.preprocess((textField) => {
8179
8231
  if (textField == null) return void 0;
8180
8232
  if (typeof textField === "string") {
8181
8233
  const trimmedTextField = textField.trim();
@@ -8185,25 +8237,25 @@ var optionalEasyEdaTextField = (fieldSchema) => z200.preprocess((textField) => {
8185
8237
  }
8186
8238
  return textField;
8187
8239
  }, fieldSchema);
8188
- var TextShapeOutputSchema = z200.object({
8189
- type: z200.literal("TEXT"),
8190
- alignment: z200.enum(["L", "C", "R"]),
8191
- x: z200.number(),
8192
- y: z200.number(),
8193
- rotation: z200.number(),
8194
- fontColor: z200.string(),
8195
- backgroundColor: optionalEasyEdaTextField(z200.string().optional()),
8196
- fontSize: z200.string(),
8197
- fontWeight: optionalEasyEdaTextField(z200.string().optional().default("normal")),
8240
+ var TextShapeOutputSchema = z201.object({
8241
+ type: z201.literal("TEXT"),
8242
+ alignment: z201.enum(["L", "C", "R"]),
8243
+ x: z201.number(),
8244
+ y: z201.number(),
8245
+ rotation: z201.number(),
8246
+ fontColor: z201.string(),
8247
+ backgroundColor: optionalEasyEdaTextField(z201.string().optional()),
8248
+ fontSize: z201.string(),
8249
+ fontWeight: optionalEasyEdaTextField(z201.string().optional().default("normal")),
8198
8250
  fontStyle: optionalEasyEdaTextField(
8199
- z200.enum(["normal", "italic"]).optional().default("normal")
8251
+ z201.enum(["normal", "italic"]).optional().default("normal")
8200
8252
  ),
8201
- fontDecoration: optionalEasyEdaTextField(z200.string().optional().default("")),
8202
- content: z200.string(),
8203
- textType: z200.string(),
8204
- visibility: z200.enum(["0", "1"]),
8205
- mirror: z200.string(),
8206
- id: z200.string()
8253
+ fontDecoration: optionalEasyEdaTextField(z201.string().optional().default("")),
8254
+ content: z201.string(),
8255
+ textType: z201.string(),
8256
+ visibility: z201.enum(["0", "1"]),
8257
+ mirror: z201.string(),
8258
+ id: z201.string()
8207
8259
  });
8208
8260
  var parseText = (str) => {
8209
8261
  const [
@@ -8244,8 +8296,8 @@ var parseText = (str) => {
8244
8296
  id
8245
8297
  };
8246
8298
  };
8247
- var TextShapeSchema = z200.string().startsWith("T~").transform(parseText).pipe(TextShapeOutputSchema);
8248
- var SingleLetterShapeSchema = z200.string().transform((x) => {
8299
+ var TextShapeSchema = z201.string().startsWith("T~").transform(parseText).pipe(TextShapeOutputSchema);
8300
+ var SingleLetterShapeSchema = z201.string().transform((x) => {
8249
8301
  if (x.startsWith("R~")) return RectangleShapeSchema.parse(x);
8250
8302
  if (x.startsWith("E~")) return EllipseShapeSchema.parse(x);
8251
8303
  if (x.startsWith("P~")) return PinShapeSchema.parse(x);
@@ -8259,7 +8311,7 @@ var SingleLetterShapeSchema = z200.string().transform((x) => {
8259
8311
  if (x.startsWith("A~")) return ArcShapeSchema.parse(x);
8260
8312
  throw new Error(`Invalid shape type: ${x}`);
8261
8313
  }).pipe(
8262
- z200.union([
8314
+ z201.union([
8263
8315
  RectangleShapeOutputSchema,
8264
8316
  EllipseShapeOutputSchema,
8265
8317
  PinShapeOutputSchema,
@@ -8273,84 +8325,84 @@ var SingleLetterShapeSchema = z200.string().transform((x) => {
8273
8325
  );
8274
8326
 
8275
8327
  // lib/schemas/easy-eda-json-schema.ts
8276
- var maybeNumber = z201.any().transform((k) => k === "nan" || Number.isNaN(k) ? null : k).pipe(z201.number().nullable().optional());
8277
- var optionalNumberWithNumericString = z201.preprocess((value) => {
8328
+ var maybeNumber = z202.any().transform((k) => k === "nan" || Number.isNaN(k) ? null : k).pipe(z202.number().nullable().optional());
8329
+ var optionalNumberWithNumericString = z202.preprocess((value) => {
8278
8330
  if (typeof value !== "string") return value;
8279
8331
  if (value.trim() === "") return void 0;
8280
8332
  return Number(value);
8281
- }, z201.number().optional());
8282
- var SzlcscSchema = z201.object({
8283
- id: z201.preprocess((value) => {
8333
+ }, z202.number().optional());
8334
+ var SzlcscSchema = z202.object({
8335
+ id: z202.preprocess((value) => {
8284
8336
  if (typeof value === "string" && /^\d+$/.test(value)) {
8285
8337
  return Number(value);
8286
8338
  }
8287
8339
  return value;
8288
- }, z201.number()),
8289
- number: z201.string(),
8290
- step: z201.number().optional(),
8291
- min: z201.number().optional(),
8340
+ }, z202.number()),
8341
+ number: z202.string(),
8342
+ step: z202.number().optional(),
8343
+ min: z202.number().optional(),
8292
8344
  price: optionalNumberWithNumericString,
8293
- stock: z201.number().optional(),
8294
- url: z201.string().url().optional(),
8295
- image: z201.string().optional().optional()
8296
- });
8297
- var LcscSchema = z201.object({
8298
- id: z201.number(),
8299
- number: z201.string(),
8300
- step: z201.number().optional(),
8301
- min: z201.number().optional(),
8345
+ stock: z202.number().optional(),
8346
+ url: z202.string().url().optional(),
8347
+ image: z202.string().optional().optional()
8348
+ });
8349
+ var LcscSchema = z202.object({
8350
+ id: z202.number(),
8351
+ number: z202.string(),
8352
+ step: z202.number().optional(),
8353
+ min: z202.number().optional(),
8302
8354
  price: optionalNumberWithNumericString,
8303
- stock: z201.number().optional(),
8304
- url: z201.string().url().optional()
8305
- });
8306
- var OwnerSchema = z201.object({
8307
- uuid: z201.string(),
8308
- username: z201.string(),
8309
- nickname: z201.string(),
8310
- avatar: z201.string()
8311
- });
8312
- var HeadSchema = z201.object({
8313
- docType: z201.preprocess((val) => val == null ? val : String(val), z201.string()),
8314
- editorVersion: z201.string().default(""),
8315
- c_para: z201.record(z201.string(), z201.string().nullable()),
8316
- x: z201.number(),
8317
- y: z201.number(),
8318
- puuid: z201.string().optional(),
8319
- uuid: z201.string(),
8320
- utime: z201.preprocess((val) => {
8355
+ stock: z202.number().optional(),
8356
+ url: z202.string().url().optional()
8357
+ });
8358
+ var OwnerSchema = z202.object({
8359
+ uuid: z202.string(),
8360
+ username: z202.string(),
8361
+ nickname: z202.string(),
8362
+ avatar: z202.string()
8363
+ });
8364
+ var HeadSchema = z202.object({
8365
+ docType: z202.preprocess((val) => val == null ? val : String(val), z202.string()),
8366
+ editorVersion: z202.string().default(""),
8367
+ c_para: z202.record(z202.string(), z202.string().nullable()),
8368
+ x: z202.number(),
8369
+ y: z202.number(),
8370
+ puuid: z202.string().optional(),
8371
+ uuid: z202.string(),
8372
+ utime: z202.preprocess((val) => {
8321
8373
  if (val == null || val === "") return void 0;
8322
8374
  if (typeof val === "string") return Number(val);
8323
8375
  return val;
8324
- }, z201.number().optional()),
8325
- importFlag: z201.number().optional(),
8326
- c_spiceCmd: z201.any().optional(),
8327
- hasIdFlag: z201.boolean().default(false)
8328
- });
8329
- var BBoxSchema = z201.object({
8330
- x: z201.number(),
8331
- y: z201.number(),
8332
- width: z201.number(),
8333
- height: z201.number()
8334
- });
8335
- var LayerItemSchema = z201.object({
8336
- name: z201.string(),
8337
- color: z201.string(),
8338
- visible: z201.boolean(),
8339
- active: z201.boolean(),
8340
- config: z201.boolean(),
8341
- transparency: z201.boolean()
8342
- });
8343
- var ObjectItemSchema = z201.object({
8344
- name: z201.string(),
8345
- visible: z201.boolean(),
8346
- locked: z201.boolean()
8347
- });
8348
- var DataStrSchema = z201.object({
8376
+ }, z202.number().optional()),
8377
+ importFlag: z202.number().optional(),
8378
+ c_spiceCmd: z202.any().optional(),
8379
+ hasIdFlag: z202.boolean().default(false)
8380
+ });
8381
+ var BBoxSchema = z202.object({
8382
+ x: z202.number(),
8383
+ y: z202.number(),
8384
+ width: z202.number(),
8385
+ height: z202.number()
8386
+ });
8387
+ var LayerItemSchema = z202.object({
8388
+ name: z202.string(),
8389
+ color: z202.string(),
8390
+ visible: z202.boolean(),
8391
+ active: z202.boolean(),
8392
+ config: z202.boolean(),
8393
+ transparency: z202.boolean()
8394
+ });
8395
+ var ObjectItemSchema = z202.object({
8396
+ name: z202.string(),
8397
+ visible: z202.boolean(),
8398
+ locked: z202.boolean()
8399
+ });
8400
+ var DataStrSchema = z202.object({
8349
8401
  head: HeadSchema,
8350
- canvas: z201.string(),
8351
- shape: z201.array(SingleLetterShapeSchema),
8402
+ canvas: z202.string(),
8403
+ shape: z202.array(SingleLetterShapeSchema),
8352
8404
  BBox: BBoxSchema.optional(),
8353
- colors: z201.union([z201.array(z201.string()), z201.record(z201.string())]).default([])
8405
+ colors: z202.union([z202.array(z202.string()), z202.record(z202.string())]).default([])
8354
8406
  }).transform((data) => ({
8355
8407
  ...data,
8356
8408
  BBox: data.BBox ?? {
@@ -8360,16 +8412,16 @@ var DataStrSchema = z201.object({
8360
8412
  height: 0
8361
8413
  }
8362
8414
  }));
8363
- var PackageDetailDataStrSchema = z201.object({
8415
+ var PackageDetailDataStrSchema = z202.object({
8364
8416
  head: HeadSchema,
8365
- canvas: z201.string(),
8366
- shape: z201.array(z201.string()).transform(
8417
+ canvas: z202.string(),
8418
+ shape: z202.array(z202.string()).transform(
8367
8419
  (shapes) => shapes.map((shape) => {
8368
8420
  const [type, ...data] = shape.split("~");
8369
8421
  return ShapeItemSchema.parse({ type, data: data.join("~") });
8370
8422
  })
8371
- ).pipe(z201.array(PackageDetailShapeSchema)),
8372
- layers: z201.array(z201.string()).transform(
8423
+ ).pipe(z202.array(PackageDetailShapeSchema)),
8424
+ layers: z202.array(z202.string()).transform(
8373
8425
  (layers) => layers.map((layer) => {
8374
8426
  const [name, color, visible, active, config, transparency] = layer.split("~");
8375
8427
  return LayerItemSchema.parse({
@@ -8382,7 +8434,7 @@ var PackageDetailDataStrSchema = z201.object({
8382
8434
  });
8383
8435
  })
8384
8436
  ),
8385
- objects: z201.array(z201.string()).transform(
8437
+ objects: z202.array(z202.string()).transform(
8386
8438
  (objects) => objects.map((obj) => {
8387
8439
  const [name, visible, locked] = obj.split("~");
8388
8440
  return ObjectItemSchema.parse({
@@ -8393,52 +8445,52 @@ var PackageDetailDataStrSchema = z201.object({
8393
8445
  })
8394
8446
  ),
8395
8447
  BBox: BBoxSchema,
8396
- netColors: z201.array(z201.unknown()).optional()
8448
+ netColors: z202.array(z202.unknown()).optional()
8397
8449
  });
8398
- var PackageDetailSchema = z201.object({
8399
- uuid: z201.string(),
8400
- title: z201.string(),
8401
- docType: z201.number(),
8402
- updateTime: z201.number(),
8450
+ var PackageDetailSchema = z202.object({
8451
+ uuid: z202.string(),
8452
+ title: z202.string(),
8453
+ docType: z202.number(),
8454
+ updateTime: z202.number(),
8403
8455
  owner: OwnerSchema,
8404
- datastrid: z201.string(),
8405
- writable: z201.boolean(),
8456
+ datastrid: z202.string(),
8457
+ writable: z202.boolean(),
8406
8458
  dataStr: PackageDetailDataStrSchema
8407
8459
  });
8408
- var ModelBoundsSchema = z201.object({
8409
- min: z201.object({
8410
- x: z201.number(),
8411
- y: z201.number(),
8412
- z: z201.number()
8460
+ var ModelBoundsSchema = z202.object({
8461
+ min: z202.object({
8462
+ x: z202.number(),
8463
+ y: z202.number(),
8464
+ z: z202.number()
8413
8465
  }),
8414
- max: z201.object({
8415
- x: z201.number(),
8416
- y: z201.number(),
8417
- z: z201.number()
8466
+ max: z202.object({
8467
+ x: z202.number(),
8468
+ y: z202.number(),
8469
+ z: z202.number()
8418
8470
  })
8419
8471
  });
8420
- var EasyEdaJsonSchema = z201.object({
8421
- uuid: z201.string(),
8422
- title: z201.string(),
8423
- description: z201.string(),
8424
- docType: z201.number(),
8425
- type: z201.number(),
8472
+ var EasyEdaJsonSchema = z202.object({
8473
+ uuid: z202.string(),
8474
+ title: z202.string(),
8475
+ description: z202.string(),
8476
+ docType: z202.number(),
8477
+ type: z202.number(),
8426
8478
  szlcsc: SzlcscSchema,
8427
8479
  lcsc: LcscSchema,
8428
8480
  owner: OwnerSchema,
8429
- tags: z201.array(z201.string()),
8430
- category: z201.string().optional(),
8431
- updateTime: z201.number(),
8432
- updated_at: z201.string(),
8481
+ tags: z202.array(z202.string()),
8482
+ category: z202.string().optional(),
8483
+ updateTime: z202.number(),
8484
+ updated_at: z202.string(),
8433
8485
  dataStr: DataStrSchema,
8434
- verify: z201.boolean(),
8435
- SMT: z201.boolean().optional(),
8436
- datastrid: z201.string(),
8437
- jlcOnSale: z201.number().optional(),
8438
- writable: z201.boolean(),
8439
- isFavorite: z201.boolean(),
8486
+ verify: z202.boolean(),
8487
+ SMT: z202.boolean().optional(),
8488
+ datastrid: z202.string(),
8489
+ jlcOnSale: z202.number().optional(),
8490
+ writable: z202.boolean(),
8491
+ isFavorite: z202.boolean(),
8440
8492
  packageDetail: PackageDetailSchema,
8441
- _objMetadata: z201.object({
8493
+ _objMetadata: z202.object({
8442
8494
  bounds: ModelBoundsSchema
8443
8495
  }).optional()
8444
8496
  });
@@ -8468,17 +8520,17 @@ var parseObjBounds2 = (objText) => {
8468
8520
  const [, xStr, yStr, zStr] = trimmed.split(/\s+/, 4);
8469
8521
  const x = Number(xStr);
8470
8522
  const y = Number(yStr);
8471
- const z202 = Number(zStr);
8472
- if (!Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(z202)) {
8523
+ const z203 = Number(zStr);
8524
+ if (!Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(z203)) {
8473
8525
  continue;
8474
8526
  }
8475
8527
  vertexCount += 1;
8476
8528
  minX = Math.min(minX, x);
8477
8529
  minY = Math.min(minY, y);
8478
- minZ = Math.min(minZ, z202);
8530
+ minZ = Math.min(minZ, z203);
8479
8531
  maxX = Math.max(maxX, x);
8480
8532
  maxY = Math.max(maxY, y);
8481
- maxZ = Math.max(maxZ, z202);
8533
+ maxZ = Math.max(maxZ, z203);
8482
8534
  }
8483
8535
  if (vertexCount === 0) return null;
8484
8536
  return {