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/browser/index.d.ts +13 -0
- package/dist/browser/index.js +37 -4
- package/dist/browser/index.js.map +1 -1
- package/dist/index.d.ts +13 -0
- package/dist/index.js +37 -4
- package/dist/index.js.map +1 -1
- package/dist/main.cjs +38 -5
- package/dist/main.cjs.map +1 -1
- package/package.json +1 -1
package/dist/main.cjs
CHANGED
|
@@ -1078,7 +1078,7 @@ var import_promises = __toESM(require("fs/promises"), 1);
|
|
|
1078
1078
|
var package_default = {
|
|
1079
1079
|
name: "easyeda",
|
|
1080
1080
|
type: "module",
|
|
1081
|
-
version: "0.0.
|
|
1081
|
+
version: "0.0.369",
|
|
1082
1082
|
files: [
|
|
1083
1083
|
"dist"
|
|
1084
1084
|
],
|
|
@@ -17330,6 +17330,7 @@ var TextShapeOutputSchema = import_zod217.z.object({
|
|
|
17330
17330
|
fontDecoration: optionalEasyEdaTextField(import_zod217.z.string().optional().default("")),
|
|
17331
17331
|
content: import_zod217.z.string(),
|
|
17332
17332
|
textType: import_zod217.z.string(),
|
|
17333
|
+
isReferenceDesignator: import_zod217.z.boolean().optional(),
|
|
17333
17334
|
visibility: import_zod217.z.enum(["0", "1"]),
|
|
17334
17335
|
mirror: import_zod217.z.string(),
|
|
17335
17336
|
id: import_zod217.z.string()
|
|
@@ -17337,7 +17338,7 @@ var TextShapeOutputSchema = import_zod217.z.object({
|
|
|
17337
17338
|
var parseText = (str) => {
|
|
17338
17339
|
const [
|
|
17339
17340
|
,
|
|
17340
|
-
|
|
17341
|
+
textMark,
|
|
17341
17342
|
x,
|
|
17342
17343
|
y,
|
|
17343
17344
|
rotation2,
|
|
@@ -17355,8 +17356,11 @@ var parseText = (str) => {
|
|
|
17355
17356
|
] = str.split("~");
|
|
17356
17357
|
return {
|
|
17357
17358
|
type: "TEXT",
|
|
17358
|
-
//
|
|
17359
|
-
|
|
17359
|
+
// EasyEDA's second text field is a mark: L=label, N=name, P=reference prefix.
|
|
17360
|
+
// Text anchoring is a separate field (start/middle/end).
|
|
17361
|
+
// https://docs.easyeda.com/en/DocumentFormat/2-EasyEDA-Schematic-File-Format/#annotations
|
|
17362
|
+
// Preserve the existing normalized alignment representation for consumers.
|
|
17363
|
+
alignment: textMark === "P" ? "L" : textMark,
|
|
17360
17364
|
x: Number(x),
|
|
17361
17365
|
y: Number(y),
|
|
17362
17366
|
rotation: Number(rotation2),
|
|
@@ -17368,6 +17372,7 @@ var parseText = (str) => {
|
|
|
17368
17372
|
fontDecoration,
|
|
17369
17373
|
content,
|
|
17370
17374
|
textType,
|
|
17375
|
+
...textMark === "P" ? { isReferenceDesignator: true } : {},
|
|
17371
17376
|
visibility,
|
|
17372
17377
|
mirror,
|
|
17373
17378
|
id
|
|
@@ -17688,6 +17693,27 @@ var normalizeSymbolName = (name) => {
|
|
|
17688
17693
|
return trimmedName.replace(/(?<=[A-Za-z0-9])-(?=[A-Za-z0-9])/g, "_");
|
|
17689
17694
|
};
|
|
17690
17695
|
|
|
17696
|
+
// lib/websafe/convert-to-typescript-component/generate-symbol-reference-text.ts
|
|
17697
|
+
var REFERENCE_TEXT_MARGIN_SCHEMATIC_UNITS = 0.2;
|
|
17698
|
+
var generateSymbolReferenceText = ({
|
|
17699
|
+
shapes,
|
|
17700
|
+
bounds,
|
|
17701
|
+
transformPoint
|
|
17702
|
+
}) => {
|
|
17703
|
+
const hasVisibleReferenceText = shapes.some(
|
|
17704
|
+
(shape) => shape.type === "TEXT" && shape.visibility === "1" && (shape.isReferenceDesignator || /\{(?:NAME|REF|REFERENCE)\}/.test(shape.content))
|
|
17705
|
+
);
|
|
17706
|
+
if (hasVisibleReferenceText) return void 0;
|
|
17707
|
+
const position2 = transformPoint({
|
|
17708
|
+
x: bounds.x + bounds.width / 2,
|
|
17709
|
+
y: bounds.y
|
|
17710
|
+
});
|
|
17711
|
+
const schY = Number(
|
|
17712
|
+
(position2.y + REFERENCE_TEXT_MARGIN_SCHEMATIC_UNITS).toFixed(6)
|
|
17713
|
+
);
|
|
17714
|
+
return `<schematictext schX={${position2.x}} schY={${schY}} text="{NAME}" fontSize={0.2} anchor="bottom_center" />`;
|
|
17715
|
+
};
|
|
17716
|
+
|
|
17691
17717
|
// lib/websafe/convert-to-typescript-component/generate-symbol-tsx.ts
|
|
17692
17718
|
var round = (value) => Number(value.toFixed(6));
|
|
17693
17719
|
var EASYEDA_SCHEMATIC_UNIT_TO_TSCIRCUIT_UNIT = 0.02;
|
|
@@ -17976,7 +18002,8 @@ var generateShapeTsx = ({
|
|
|
17976
18002
|
if (shape.type === "TEXT") {
|
|
17977
18003
|
if (shape.visibility !== "1") return void 0;
|
|
17978
18004
|
const position2 = transformPoint({ x: shape.x, y: shape.y });
|
|
17979
|
-
|
|
18005
|
+
const text = shape.isReferenceDesignator ? "{NAME}" : shape.content;
|
|
18006
|
+
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)}} />`;
|
|
17980
18007
|
}
|
|
17981
18008
|
if (shape.type === "PIN" && portMetadata) {
|
|
17982
18009
|
if (shape.visibility !== "show") return void 0;
|
|
@@ -18027,6 +18054,12 @@ var generateSymbolTsx = (easyEdaJson, circuitJson, {
|
|
|
18027
18054
|
})
|
|
18028
18055
|
).filter((tsx) => Boolean(tsx));
|
|
18029
18056
|
if (shapeTsx.length === 0) return void 0;
|
|
18057
|
+
const referenceTextTsx = generateSymbolReferenceText({
|
|
18058
|
+
shapes,
|
|
18059
|
+
bounds,
|
|
18060
|
+
transformPoint
|
|
18061
|
+
});
|
|
18062
|
+
if (referenceTextTsx) shapeTsx.push(referenceTextTsx);
|
|
18030
18063
|
return `<symbol>
|
|
18031
18064
|
${shapeTsx.map((tsx) => ` ${tsx}`).join("\n")}
|
|
18032
18065
|
</symbol>`;
|