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.
@@ -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;
@@ -20021,6 +20021,7 @@ var TextShapeOutputSchema = external_exports.object({
20021
20021
  fontDecoration: optionalEasyEdaTextField(external_exports.string().optional().default("")),
20022
20022
  content: external_exports.string(),
20023
20023
  textType: external_exports.string(),
20024
+ isReferenceDesignator: external_exports.boolean().optional(),
20024
20025
  visibility: external_exports.enum(["0", "1"]),
20025
20026
  mirror: external_exports.string(),
20026
20027
  id: external_exports.string()
@@ -20028,7 +20029,7 @@ var TextShapeOutputSchema = external_exports.object({
20028
20029
  var parseText = (str) => {
20029
20030
  const [
20030
20031
  ,
20031
- alignment,
20032
+ textMark,
20032
20033
  x,
20033
20034
  y,
20034
20035
  rotation2,
@@ -20046,8 +20047,11 @@ var parseText = (str) => {
20046
20047
  ] = str.split("~");
20047
20048
  return {
20048
20049
  type: "TEXT",
20049
- // Some EasyEDA component payloads use "P" for start-aligned text.
20050
- alignment: alignment === "P" ? "L" : alignment,
20050
+ // EasyEDA's second text field is a mark: L=label, N=name, P=reference prefix.
20051
+ // Text anchoring is a separate field (start/middle/end).
20052
+ // https://docs.easyeda.com/en/DocumentFormat/2-EasyEDA-Schematic-File-Format/#annotations
20053
+ // Preserve the existing normalized alignment representation for consumers.
20054
+ alignment: textMark === "P" ? "L" : textMark,
20051
20055
  x: Number(x),
20052
20056
  y: Number(y),
20053
20057
  rotation: Number(rotation2),
@@ -20059,6 +20063,7 @@ var parseText = (str) => {
20059
20063
  fontDecoration,
20060
20064
  content,
20061
20065
  textType,
20066
+ ...textMark === "P" ? { isReferenceDesignator: true } : {},
20062
20067
  visibility,
20063
20068
  mirror,
20064
20069
  id
@@ -20394,6 +20399,27 @@ var normalizeSymbolName = (name) => {
20394
20399
  return trimmedName.replace(/(?<=[A-Za-z0-9])-(?=[A-Za-z0-9])/g, "_");
20395
20400
  };
20396
20401
 
20402
+ // lib/websafe/convert-to-typescript-component/generate-symbol-reference-text.ts
20403
+ var REFERENCE_TEXT_MARGIN_SCHEMATIC_UNITS = 0.2;
20404
+ var generateSymbolReferenceText = ({
20405
+ shapes,
20406
+ bounds,
20407
+ transformPoint
20408
+ }) => {
20409
+ const hasVisibleReferenceText = shapes.some(
20410
+ (shape) => shape.type === "TEXT" && shape.visibility === "1" && (shape.isReferenceDesignator || /\{(?:NAME|REF|REFERENCE)\}/.test(shape.content))
20411
+ );
20412
+ if (hasVisibleReferenceText) return void 0;
20413
+ const position2 = transformPoint({
20414
+ x: bounds.x + bounds.width / 2,
20415
+ y: bounds.y
20416
+ });
20417
+ const schY = Number(
20418
+ (position2.y + REFERENCE_TEXT_MARGIN_SCHEMATIC_UNITS).toFixed(6)
20419
+ );
20420
+ return `<schematictext schX={${position2.x}} schY={${schY}} text="{NAME}" fontSize={0.2} anchor="bottom_center" />`;
20421
+ };
20422
+
20397
20423
  // lib/websafe/convert-to-typescript-component/generate-symbol-tsx.ts
20398
20424
  var round = (value) => Number(value.toFixed(6));
20399
20425
  var EASYEDA_SCHEMATIC_UNIT_TO_TSCIRCUIT_UNIT = 0.02;
@@ -20682,7 +20708,8 @@ var generateShapeTsx = ({
20682
20708
  if (shape.type === "TEXT") {
20683
20709
  if (shape.visibility !== "1") return void 0;
20684
20710
  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)}} />`;
20711
+ const text = shape.isReferenceDesignator ? "{NAME}" : shape.content;
20712
+ 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
20713
  }
20687
20714
  if (shape.type === "PIN" && portMetadata) {
20688
20715
  if (shape.visibility !== "show") return void 0;
@@ -20733,6 +20760,12 @@ var generateSymbolTsx = (easyEdaJson, circuitJson, {
20733
20760
  })
20734
20761
  ).filter((tsx) => Boolean(tsx));
20735
20762
  if (shapeTsx.length === 0) return void 0;
20763
+ const referenceTextTsx = generateSymbolReferenceText({
20764
+ shapes,
20765
+ bounds,
20766
+ transformPoint
20767
+ });
20768
+ if (referenceTextTsx) shapeTsx.push(referenceTextTsx);
20736
20769
  return `<symbol>
20737
20770
  ${shapeTsx.map((tsx) => ` ${tsx}`).join("\n")}
20738
20771
  </symbol>`;