easyeda 0.0.369 → 0.0.371

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.
@@ -297,6 +297,7 @@ declare const DataStrSchema: z.ZodEffects<z.ZodObject<{
297
297
  textType: string;
298
298
  mirror: string;
299
299
  backgroundColor?: string | undefined;
300
+ isReferenceDesignator?: boolean | undefined;
300
301
  }, string>, z.ZodUnion<[z.ZodObject<{
301
302
  type: z.ZodLiteral<"RECTANGLE">;
302
303
  position: z.ZodObject<{
@@ -521,6 +522,7 @@ declare const DataStrSchema: z.ZodEffects<z.ZodObject<{
521
522
  fontDecoration: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodString>>, string, unknown>;
522
523
  content: z.ZodString;
523
524
  textType: z.ZodString;
525
+ isReferenceDesignator: z.ZodOptional<z.ZodBoolean>;
524
526
  visibility: z.ZodEnum<["0", "1"]>;
525
527
  mirror: z.ZodString;
526
528
  id: z.ZodString;
@@ -541,6 +543,7 @@ declare const DataStrSchema: z.ZodEffects<z.ZodObject<{
541
543
  textType: string;
542
544
  mirror: string;
543
545
  backgroundColor?: string | undefined;
546
+ isReferenceDesignator?: boolean | undefined;
544
547
  }, {
545
548
  type: "TEXT";
546
549
  x: number;
@@ -558,6 +561,7 @@ declare const DataStrSchema: z.ZodEffects<z.ZodObject<{
558
561
  fontWeight?: unknown;
559
562
  fontStyle?: unknown;
560
563
  fontDecoration?: unknown;
564
+ isReferenceDesignator?: boolean | undefined;
561
565
  }>, z.ZodObject<{
562
566
  type: z.ZodLiteral<"IGNORED">;
563
567
  sourceType: z.ZodEnum<["AR", "I"]>;
@@ -744,6 +748,7 @@ declare const DataStrSchema: z.ZodEffects<z.ZodObject<{
744
748
  textType: string;
745
749
  mirror: string;
746
750
  backgroundColor?: string | undefined;
751
+ isReferenceDesignator?: boolean | undefined;
747
752
  })[];
748
753
  head: {
749
754
  x: number;
@@ -894,6 +899,7 @@ declare const DataStrSchema: z.ZodEffects<z.ZodObject<{
894
899
  textType: string;
895
900
  mirror: string;
896
901
  backgroundColor?: string | undefined;
902
+ isReferenceDesignator?: boolean | undefined;
897
903
  })[];
898
904
  head: {
899
905
  x: number;
@@ -3077,6 +3083,7 @@ declare const EasyEdaJsonSchema: z.ZodObject<{
3077
3083
  textType: string;
3078
3084
  mirror: string;
3079
3085
  backgroundColor?: string | undefined;
3086
+ isReferenceDesignator?: boolean | undefined;
3080
3087
  }, string>, z.ZodUnion<[z.ZodObject<{
3081
3088
  type: z.ZodLiteral<"RECTANGLE">;
3082
3089
  position: z.ZodObject<{
@@ -3301,6 +3308,7 @@ declare const EasyEdaJsonSchema: z.ZodObject<{
3301
3308
  fontDecoration: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodString>>, string, unknown>;
3302
3309
  content: z.ZodString;
3303
3310
  textType: z.ZodString;
3311
+ isReferenceDesignator: z.ZodOptional<z.ZodBoolean>;
3304
3312
  visibility: z.ZodEnum<["0", "1"]>;
3305
3313
  mirror: z.ZodString;
3306
3314
  id: z.ZodString;
@@ -3321,6 +3329,7 @@ declare const EasyEdaJsonSchema: z.ZodObject<{
3321
3329
  textType: string;
3322
3330
  mirror: string;
3323
3331
  backgroundColor?: string | undefined;
3332
+ isReferenceDesignator?: boolean | undefined;
3324
3333
  }, {
3325
3334
  type: "TEXT";
3326
3335
  x: number;
@@ -3338,6 +3347,7 @@ declare const EasyEdaJsonSchema: z.ZodObject<{
3338
3347
  fontWeight?: unknown;
3339
3348
  fontStyle?: unknown;
3340
3349
  fontDecoration?: unknown;
3350
+ isReferenceDesignator?: boolean | undefined;
3341
3351
  }>, z.ZodObject<{
3342
3352
  type: z.ZodLiteral<"IGNORED">;
3343
3353
  sourceType: z.ZodEnum<["AR", "I"]>;
@@ -3524,6 +3534,7 @@ declare const EasyEdaJsonSchema: z.ZodObject<{
3524
3534
  textType: string;
3525
3535
  mirror: string;
3526
3536
  backgroundColor?: string | undefined;
3537
+ isReferenceDesignator?: boolean | undefined;
3527
3538
  })[];
3528
3539
  head: {
3529
3540
  x: number;
@@ -3674,6 +3685,7 @@ declare const EasyEdaJsonSchema: z.ZodObject<{
3674
3685
  textType: string;
3675
3686
  mirror: string;
3676
3687
  backgroundColor?: string | undefined;
3688
+ isReferenceDesignator?: boolean | undefined;
3677
3689
  })[];
3678
3690
  head: {
3679
3691
  x: number;
@@ -4975,6 +4987,7 @@ declare const EasyEdaJsonSchema: z.ZodObject<{
4975
4987
  textType: string;
4976
4988
  mirror: string;
4977
4989
  backgroundColor?: string | undefined;
4990
+ isReferenceDesignator?: boolean | undefined;
4978
4991
  })[];
4979
4992
  head: {
4980
4993
  x: number;
@@ -18100,6 +18100,43 @@ function generateArcFromSweep(startX, startY, endX, endY, radius, largeArcFlag,
18100
18100
  // lib/utils/easyeda-unit-to-mm.ts
18101
18101
  var mil10ToMm = (value) => value * 10 * 0.0254;
18102
18102
 
18103
+ // lib/utils/expand-easyeda-path-data.ts
18104
+ var expandEasyEdaPathData = (pathData) => {
18105
+ const rawRoute = [];
18106
+ let currentPoint;
18107
+ for (const commandMatch of pathData.matchAll(/([MLAZ])([^MLAZ]*)/gi)) {
18108
+ const command = commandMatch[1]?.toUpperCase();
18109
+ const values = commandMatch[2]?.match(/[-+]?(?:\d*\.\d+|\d+\.?)(?:[eE][-+]?\d+)?/g)?.map(Number) ?? [];
18110
+ if ((command === "M" || command === "L") && values.length >= 2) {
18111
+ currentPoint = { x: values[0], y: values[1] };
18112
+ rawRoute.push(currentPoint);
18113
+ } else if (command === "A" && currentPoint && values.length >= 7) {
18114
+ const [radiusX, , , largeArcFlag, sweepFlag, endX, endY] = values;
18115
+ const generatedArcRoute = generateArcFromSweep(
18116
+ currentPoint.x,
18117
+ currentPoint.y,
18118
+ endX,
18119
+ endY,
18120
+ radiusX,
18121
+ largeArcFlag === 1,
18122
+ sweepFlag === 1
18123
+ );
18124
+ const maxArcSegments = 16;
18125
+ const arcRoute = generatedArcRoute.length <= maxArcSegments + 1 ? generatedArcRoute : Array.from(
18126
+ { length: maxArcSegments + 1 },
18127
+ (_, pointIndex) => generatedArcRoute.at(
18128
+ Math.round(
18129
+ pointIndex * (generatedArcRoute.length - 1) / maxArcSegments
18130
+ )
18131
+ )
18132
+ ).filter((point4) => !!point4);
18133
+ rawRoute.push(...arcRoute.slice(1));
18134
+ currentPoint = { x: endX, y: endY };
18135
+ }
18136
+ }
18137
+ return rawRoute;
18138
+ };
18139
+
18103
18140
  // node_modules/@tscircuit/math-utils/dist/chunk-EFLPMB4J.js
18104
18141
  function orientation(p, q, r) {
18105
18142
  const val = (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
@@ -18215,6 +18252,22 @@ var getBoardOutlinePolygons = (tracks) => {
18215
18252
  return polygons;
18216
18253
  };
18217
18254
 
18255
+ // lib/utils/get-easyeda-npth-slot-geometry.ts
18256
+ var getEasyEdaNpthSlotGeometry = (solidRegion) => {
18257
+ const rawRoute = expandEasyEdaPathData(solidRegion.pathData);
18258
+ if (rawRoute.length < 2) return null;
18259
+ const points = rawRoute.map((point4) => ({
18260
+ x: mil2mm(point4.x) * 10,
18261
+ y: mil2mm(point4.y) * 10
18262
+ }));
18263
+ const firstPoint = points[0];
18264
+ const lastPoint = points.at(-1);
18265
+ if (firstPoint.x !== lastPoint.x || firstPoint.y !== lastPoint.y) {
18266
+ points.push({ ...firstPoint });
18267
+ }
18268
+ return { points };
18269
+ };
18270
+
18218
18271
  // lib/utils/normalize-pin-labels.ts
18219
18272
  var normalizeActiveLowPinLabel = (label) => {
18220
18273
  const hasActiveLowMarker = label.startsWith("#") || label.endsWith("#");
@@ -18803,40 +18856,7 @@ var handleFabricationNotePath = (track, index) => pcb_fabrication_note_path.pars
18803
18856
  stroke_width: mil10ToMm(track.width)
18804
18857
  });
18805
18858
  var handleFabricationNoteSolidRegion = (solidRegion, index) => {
18806
- const rawRoute = [];
18807
- let currentPoint;
18808
- for (const commandMatch of solidRegion.pathData.matchAll(
18809
- /([MLAZ])([^MLAZ]*)/gi
18810
- )) {
18811
- const command = commandMatch[1]?.toUpperCase();
18812
- const values = commandMatch[2]?.match(/[-+]?(?:\d*\.\d+|\d+\.?)(?:[eE][-+]?\d+)?/g)?.map(Number) ?? [];
18813
- if ((command === "M" || command === "L") && values.length >= 2) {
18814
- currentPoint = { x: values[0], y: values[1] };
18815
- rawRoute.push(currentPoint);
18816
- } else if (command === "A" && currentPoint && values.length >= 7) {
18817
- const [radiusX, , , largeArcFlag, sweepFlag, endX, endY] = values;
18818
- const generatedArcRoute = generateArcFromSweep(
18819
- currentPoint.x,
18820
- currentPoint.y,
18821
- endX,
18822
- endY,
18823
- radiusX,
18824
- largeArcFlag === 1,
18825
- sweepFlag === 1
18826
- );
18827
- const maxArcSegments = 16;
18828
- const arcRoute = generatedArcRoute.length <= maxArcSegments + 1 ? generatedArcRoute : Array.from(
18829
- { length: maxArcSegments + 1 },
18830
- (_, pointIndex) => generatedArcRoute.at(
18831
- Math.round(
18832
- pointIndex * (generatedArcRoute.length - 1) / maxArcSegments
18833
- )
18834
- )
18835
- ).filter((point4) => !!point4);
18836
- rawRoute.push(...arcRoute.slice(1));
18837
- currentPoint = { x: endX, y: endY };
18838
- }
18839
- }
18859
+ const rawRoute = expandEasyEdaPathData(solidRegion.pathData);
18840
18860
  const route = rawRoute.map((point4) => ({
18841
18861
  x: mil10ToMm(point4.x),
18842
18862
  y: mil10ToMm(point4.y)
@@ -18967,9 +18987,11 @@ var handleCutout = (solidRegion, index) => {
18967
18987
  });
18968
18988
  };
18969
18989
  var LEAD_SHAPE_LAYER = 100;
18990
+ var NPTH_FILL_STYLE = "npth";
18970
18991
  var isPcbSolidRegionCutout = (shape) => {
18971
18992
  return shape.fillStyle === "cutout" && shape.layermask !== LEAD_SHAPE_LAYER;
18972
18993
  };
18994
+ var isPcbSolidRegionNpth = (shape) => shape.fillStyle === NPTH_FILL_STYLE && shape.layermask !== LEAD_SHAPE_LAYER;
18973
18995
  var getCadPositionZMmFromMetadata = (easyEdaJson) => {
18974
18996
  const svgNode = easyEdaJson.packageDetail.dataStr.shape.find(
18975
18997
  (shape) => shape.type === "SVGNODE" && shape.svgData.attrs?.uuid
@@ -19165,6 +19187,20 @@ var convertEasyEdaJsonToCircuitJsonWithPinAttributes = (easyEdaJson, {
19165
19187
  ).forEach((sr, index) => {
19166
19188
  circuitElements.push(handleCutout(sr, index));
19167
19189
  });
19190
+ easyEdaJson.packageDetail.dataStr.shape.filter(
19191
+ (shape) => shape.type === "SOLIDREGION" && isPcbSolidRegionNpth(shape)
19192
+ ).forEach((sr, index) => {
19193
+ const geometry = getEasyEdaNpthSlotGeometry(sr);
19194
+ if (!geometry) return;
19195
+ circuitElements.push(
19196
+ pcb_cutout.parse({
19197
+ type: "pcb_cutout",
19198
+ pcb_cutout_id: `pcb_cutout_npth_${index + 1}`,
19199
+ shape: "polygon",
19200
+ points: geometry.points
19201
+ })
19202
+ );
19203
+ });
19168
19204
  const boardOutlineTracks = easyEdaJson.packageDetail.dataStr.shape.filter(
19169
19205
  (shape) => shape.type === "TRACK" && shape.layer === 10
19170
19206
  );
@@ -20021,6 +20057,7 @@ var TextShapeOutputSchema = external_exports.object({
20021
20057
  fontDecoration: optionalEasyEdaTextField(external_exports.string().optional().default("")),
20022
20058
  content: external_exports.string(),
20023
20059
  textType: external_exports.string(),
20060
+ isReferenceDesignator: external_exports.boolean().optional(),
20024
20061
  visibility: external_exports.enum(["0", "1"]),
20025
20062
  mirror: external_exports.string(),
20026
20063
  id: external_exports.string()
@@ -20028,7 +20065,7 @@ var TextShapeOutputSchema = external_exports.object({
20028
20065
  var parseText = (str) => {
20029
20066
  const [
20030
20067
  ,
20031
- alignment,
20068
+ textMark,
20032
20069
  x,
20033
20070
  y,
20034
20071
  rotation2,
@@ -20046,8 +20083,11 @@ var parseText = (str) => {
20046
20083
  ] = str.split("~");
20047
20084
  return {
20048
20085
  type: "TEXT",
20049
- // Some EasyEDA component payloads use "P" for start-aligned text.
20050
- alignment: alignment === "P" ? "L" : alignment,
20086
+ // EasyEDA's second text field is a mark: L=label, N=name, P=reference prefix.
20087
+ // Text anchoring is a separate field (start/middle/end).
20088
+ // https://docs.easyeda.com/en/DocumentFormat/2-EasyEDA-Schematic-File-Format/#annotations
20089
+ // Preserve the existing normalized alignment representation for consumers.
20090
+ alignment: textMark === "P" ? "L" : textMark,
20051
20091
  x: Number(x),
20052
20092
  y: Number(y),
20053
20093
  rotation: Number(rotation2),
@@ -20059,6 +20099,7 @@ var parseText = (str) => {
20059
20099
  fontDecoration,
20060
20100
  content,
20061
20101
  textType,
20102
+ ...textMark === "P" ? { isReferenceDesignator: true } : {},
20062
20103
  visibility,
20063
20104
  mirror,
20064
20105
  id
@@ -20394,6 +20435,27 @@ var normalizeSymbolName = (name) => {
20394
20435
  return trimmedName.replace(/(?<=[A-Za-z0-9])-(?=[A-Za-z0-9])/g, "_");
20395
20436
  };
20396
20437
 
20438
+ // lib/websafe/convert-to-typescript-component/generate-symbol-reference-text.ts
20439
+ var REFERENCE_TEXT_MARGIN_SCHEMATIC_UNITS = 0.2;
20440
+ var generateSymbolReferenceText = ({
20441
+ shapes,
20442
+ bounds,
20443
+ transformPoint
20444
+ }) => {
20445
+ const hasVisibleReferenceText = shapes.some(
20446
+ (shape) => shape.type === "TEXT" && shape.visibility === "1" && (shape.isReferenceDesignator || /\{(?:NAME|REF|REFERENCE)\}/.test(shape.content))
20447
+ );
20448
+ if (hasVisibleReferenceText) return void 0;
20449
+ const position2 = transformPoint({
20450
+ x: bounds.x + bounds.width / 2,
20451
+ y: bounds.y
20452
+ });
20453
+ const schY = Number(
20454
+ (position2.y + REFERENCE_TEXT_MARGIN_SCHEMATIC_UNITS).toFixed(6)
20455
+ );
20456
+ return `<schematictext schX={${position2.x}} schY={${schY}} text="{NAME}" fontSize={0.2} anchor="bottom_center" />`;
20457
+ };
20458
+
20397
20459
  // lib/websafe/convert-to-typescript-component/generate-symbol-tsx.ts
20398
20460
  var round = (value) => Number(value.toFixed(6));
20399
20461
  var EASYEDA_SCHEMATIC_UNIT_TO_TSCIRCUIT_UNIT = 0.02;
@@ -20682,7 +20744,8 @@ var generateShapeTsx = ({
20682
20744
  if (shape.type === "TEXT") {
20683
20745
  if (shape.visibility !== "1") return void 0;
20684
20746
  const position2 = transformPoint({ x: shape.x, y: shape.y });
20685
- 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)}} />`;
20747
+ const text = shape.isReferenceDesignator ? "{NAME}" : shape.content;
20748
+ return `<schematictext schX={${position2.x}} schY={${position2.y}} text=${JSON.stringify(text)} fontSize={${getTextFontSize(shape.fontSize)}} anchor=${JSON.stringify(getTextAnchor(shape.alignment))} color=${JSON.stringify(shape.fontColor)} schRotation={${round(-shape.rotation)}} />`;
20686
20749
  }
20687
20750
  if (shape.type === "PIN" && portMetadata) {
20688
20751
  if (shape.visibility !== "show") return void 0;
@@ -20733,6 +20796,12 @@ var generateSymbolTsx = (easyEdaJson, circuitJson, {
20733
20796
  })
20734
20797
  ).filter((tsx) => Boolean(tsx));
20735
20798
  if (shapeTsx.length === 0) return void 0;
20799
+ const referenceTextTsx = generateSymbolReferenceText({
20800
+ shapes,
20801
+ bounds,
20802
+ transformPoint
20803
+ });
20804
+ if (referenceTextTsx) shapeTsx.push(referenceTextTsx);
20736
20805
  return `<symbol>
20737
20806
  ${shapeTsx.map((tsx) => ` ${tsx}`).join("\n")}
20738
20807
  </symbol>`;