easyeda 0.0.369 → 0.0.370

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.d.ts CHANGED
@@ -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;
package/dist/index.js CHANGED
@@ -16425,6 +16425,7 @@ var TextShapeOutputSchema = z217.object({
16425
16425
  fontDecoration: optionalEasyEdaTextField(z217.string().optional().default("")),
16426
16426
  content: z217.string(),
16427
16427
  textType: z217.string(),
16428
+ isReferenceDesignator: z217.boolean().optional(),
16428
16429
  visibility: z217.enum(["0", "1"]),
16429
16430
  mirror: z217.string(),
16430
16431
  id: z217.string()
@@ -16432,7 +16433,7 @@ var TextShapeOutputSchema = z217.object({
16432
16433
  var parseText = (str) => {
16433
16434
  const [
16434
16435
  ,
16435
- alignment,
16436
+ textMark,
16436
16437
  x,
16437
16438
  y,
16438
16439
  rotation2,
@@ -16450,8 +16451,11 @@ var parseText = (str) => {
16450
16451
  ] = str.split("~");
16451
16452
  return {
16452
16453
  type: "TEXT",
16453
- // Some EasyEDA component payloads use "P" for start-aligned text.
16454
- alignment: alignment === "P" ? "L" : alignment,
16454
+ // EasyEDA's second text field is a mark: L=label, N=name, P=reference prefix.
16455
+ // Text anchoring is a separate field (start/middle/end).
16456
+ // https://docs.easyeda.com/en/DocumentFormat/2-EasyEDA-Schematic-File-Format/#annotations
16457
+ // Preserve the existing normalized alignment representation for consumers.
16458
+ alignment: textMark === "P" ? "L" : textMark,
16455
16459
  x: Number(x),
16456
16460
  y: Number(y),
16457
16461
  rotation: Number(rotation2),
@@ -16463,6 +16467,7 @@ var parseText = (str) => {
16463
16467
  fontDecoration,
16464
16468
  content,
16465
16469
  textType,
16470
+ ...textMark === "P" ? { isReferenceDesignator: true } : {},
16466
16471
  visibility,
16467
16472
  mirror,
16468
16473
  id
@@ -16783,6 +16788,27 @@ var normalizeSymbolName = (name) => {
16783
16788
  return trimmedName.replace(/(?<=[A-Za-z0-9])-(?=[A-Za-z0-9])/g, "_");
16784
16789
  };
16785
16790
 
16791
+ // lib/websafe/convert-to-typescript-component/generate-symbol-reference-text.ts
16792
+ var REFERENCE_TEXT_MARGIN_SCHEMATIC_UNITS = 0.2;
16793
+ var generateSymbolReferenceText = ({
16794
+ shapes,
16795
+ bounds,
16796
+ transformPoint
16797
+ }) => {
16798
+ const hasVisibleReferenceText = shapes.some(
16799
+ (shape) => shape.type === "TEXT" && shape.visibility === "1" && (shape.isReferenceDesignator || /\{(?:NAME|REF|REFERENCE)\}/.test(shape.content))
16800
+ );
16801
+ if (hasVisibleReferenceText) return void 0;
16802
+ const position2 = transformPoint({
16803
+ x: bounds.x + bounds.width / 2,
16804
+ y: bounds.y
16805
+ });
16806
+ const schY = Number(
16807
+ (position2.y + REFERENCE_TEXT_MARGIN_SCHEMATIC_UNITS).toFixed(6)
16808
+ );
16809
+ return `<schematictext schX={${position2.x}} schY={${schY}} text="{NAME}" fontSize={0.2} anchor="bottom_center" />`;
16810
+ };
16811
+
16786
16812
  // lib/websafe/convert-to-typescript-component/generate-symbol-tsx.ts
16787
16813
  var round = (value) => Number(value.toFixed(6));
16788
16814
  var EASYEDA_SCHEMATIC_UNIT_TO_TSCIRCUIT_UNIT = 0.02;
@@ -17071,7 +17097,8 @@ var generateShapeTsx = ({
17071
17097
  if (shape.type === "TEXT") {
17072
17098
  if (shape.visibility !== "1") return void 0;
17073
17099
  const position2 = transformPoint({ x: shape.x, y: shape.y });
17074
- 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)}} />`;
17100
+ const text = shape.isReferenceDesignator ? "{NAME}" : shape.content;
17101
+ 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)}} />`;
17075
17102
  }
17076
17103
  if (shape.type === "PIN" && portMetadata) {
17077
17104
  if (shape.visibility !== "show") return void 0;
@@ -17122,6 +17149,12 @@ var generateSymbolTsx = (easyEdaJson, circuitJson, {
17122
17149
  })
17123
17150
  ).filter((tsx) => Boolean(tsx));
17124
17151
  if (shapeTsx.length === 0) return void 0;
17152
+ const referenceTextTsx = generateSymbolReferenceText({
17153
+ shapes,
17154
+ bounds,
17155
+ transformPoint
17156
+ });
17157
+ if (referenceTextTsx) shapeTsx.push(referenceTextTsx);
17125
17158
  return `<symbol>
17126
17159
  ${shapeTsx.map((tsx) => ` ${tsx}`).join("\n")}
17127
17160
  </symbol>`;