easyeda 0.0.381 → 0.0.383
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.js +112 -78
- package/dist/browser/index.js.map +1 -1
- package/dist/index.js +112 -78
- package/dist/index.js.map +1 -1
- package/dist/main.cjs +113 -79
- package/dist/main.cjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -15820,8 +15820,10 @@ var Polygon$1 = class Polygon {
|
|
|
15820
15820
|
return edge;
|
|
15821
15821
|
}
|
|
15822
15822
|
/**
|
|
15823
|
-
* Split polygon into array of
|
|
15824
|
-
*
|
|
15823
|
+
* Split polygon into an array of islands with their contained holes.
|
|
15824
|
+
* The largest face defines the outer orientation; opposite-oriented faces represent voids.
|
|
15825
|
+
* Holes not contained in any island are omitted from the result, without changing
|
|
15826
|
+
* their orientation or the input polygon. This method does not clip overlapping faces.
|
|
15825
15827
|
* @returns {Flatten.Polygon[]}
|
|
15826
15828
|
*/
|
|
15827
15829
|
splitToIslands() {
|
|
@@ -15866,7 +15868,7 @@ var Polygon$1 = class Polygon {
|
|
|
15866
15868
|
}
|
|
15867
15869
|
/**
|
|
15868
15870
|
* Helper method to check if face is outer face of the polygon
|
|
15869
|
-
* @param face
|
|
15871
|
+
* @param {Flatten.Face} face - face to check
|
|
15870
15872
|
* @returns {boolean}
|
|
15871
15873
|
*/
|
|
15872
15874
|
isOuter(face) {
|
|
@@ -16651,14 +16653,41 @@ var Distance = class _Distance {
|
|
|
16651
16653
|
};
|
|
16652
16654
|
Flatten.Distance = Distance;
|
|
16653
16655
|
var { Multiline: Multiline2, Point: Point2, Segment: Segment2, Polygon: Polygon2 } = Flatten;
|
|
16656
|
+
function splitComponents(str) {
|
|
16657
|
+
const components = [];
|
|
16658
|
+
let depth = 0;
|
|
16659
|
+
let start = 0;
|
|
16660
|
+
for (let i = 0; i < str.length; i++) {
|
|
16661
|
+
if (str[i] === "(") depth++;
|
|
16662
|
+
if (str[i] === ")") depth--;
|
|
16663
|
+
if (depth < 0) throw Flatten.Errors.ILLEGAL_PARAMETERS;
|
|
16664
|
+
if (str[i] === "," && depth === 0) {
|
|
16665
|
+
components.push(str.slice(start, i).trim());
|
|
16666
|
+
start = i + 1;
|
|
16667
|
+
}
|
|
16668
|
+
}
|
|
16669
|
+
if (depth !== 0) throw Flatten.Errors.ILLEGAL_PARAMETERS;
|
|
16670
|
+
components.push(str.slice(start).trim());
|
|
16671
|
+
return components;
|
|
16672
|
+
}
|
|
16673
|
+
function unwrap(str) {
|
|
16674
|
+
str = str.trim();
|
|
16675
|
+
if (str === "EMPTY") throw new Error("Empty geometry not supported");
|
|
16676
|
+
if (!str.startsWith("(") || !str.endsWith(")")) {
|
|
16677
|
+
throw Flatten.Errors.ILLEGAL_PARAMETERS;
|
|
16678
|
+
}
|
|
16679
|
+
return str.slice(1, -1).trim();
|
|
16680
|
+
}
|
|
16654
16681
|
function parseSinglePoint(pointStr) {
|
|
16655
|
-
|
|
16682
|
+
pointStr = pointStr.trim();
|
|
16683
|
+
if (pointStr === "EMPTY") throw new Error("Empty geometry not supported");
|
|
16684
|
+
return new Point2(pointStr.split(/\s+/).map(Number));
|
|
16656
16685
|
}
|
|
16657
16686
|
function parseMultiPoint(multipointStr) {
|
|
16658
|
-
return multipointStr.
|
|
16687
|
+
return splitComponents(multipointStr).map((str) => parseSinglePoint(str.startsWith("(") ? unwrap(str) : str));
|
|
16659
16688
|
}
|
|
16660
16689
|
function parseLineString(lineStr) {
|
|
16661
|
-
const points =
|
|
16690
|
+
const points = splitComponents(lineStr).map(parseSinglePoint);
|
|
16662
16691
|
let segments = [];
|
|
16663
16692
|
for (let i = 0; i < points.length - 1; i++) {
|
|
16664
16693
|
segments.push(new Segment2(points[i], points[i + 1]));
|
|
@@ -16666,45 +16695,31 @@ function parseLineString(lineStr) {
|
|
|
16666
16695
|
return new Multiline2(segments);
|
|
16667
16696
|
}
|
|
16668
16697
|
function parseMultiLineString(multilineStr) {
|
|
16669
|
-
|
|
16670
|
-
return lineStrings.map(parseLineString);
|
|
16698
|
+
return splitComponents(multilineStr).map((str) => parseLineString(unwrap(str)));
|
|
16671
16699
|
}
|
|
16672
16700
|
function parseSinglePolygon(polygonStr) {
|
|
16673
|
-
const facesStr = polygonStr.replace(/\(\(/, "").replace(/\)\)$/, "").split("), (");
|
|
16674
16701
|
const polygon2 = new Polygon2();
|
|
16702
|
+
if (polygonStr.trim() === "EMPTY") return polygon2;
|
|
16703
|
+
const facesStr = splitComponents(unwrap(polygonStr));
|
|
16675
16704
|
let orientation2;
|
|
16676
|
-
facesStr.forEach((
|
|
16677
|
-
|
|
16678
|
-
return new Point2(coordStr.split(" ").map(Number));
|
|
16679
|
-
});
|
|
16705
|
+
facesStr.forEach((faceStr, idx) => {
|
|
16706
|
+
const points = splitComponents(unwrap(faceStr)).map(parseSinglePoint);
|
|
16680
16707
|
const face = polygon2.addFace(points);
|
|
16681
16708
|
if (idx === 0) {
|
|
16682
16709
|
orientation2 = face.orientation();
|
|
16683
|
-
} else {
|
|
16684
|
-
|
|
16685
|
-
face.reverse();
|
|
16686
|
-
}
|
|
16710
|
+
} else if (face.orientation() === orientation2) {
|
|
16711
|
+
face.reverse();
|
|
16687
16712
|
}
|
|
16688
16713
|
});
|
|
16689
16714
|
return polygon2;
|
|
16690
16715
|
}
|
|
16691
|
-
function
|
|
16692
|
-
const polygonStrings = multiPolygonString.split(/\)\), \(\(/).map((polygon3) => "((" + polygon3 + "))");
|
|
16693
|
-
const polygons = polygonStrings.map(parseSinglePolygon);
|
|
16716
|
+
function parseMultiPolygon(multiPolygonStr) {
|
|
16694
16717
|
const polygon2 = new Polygon2();
|
|
16695
|
-
|
|
16696
|
-
|
|
16718
|
+
splitComponents(multiPolygonStr).map(parseSinglePolygon).forEach((part) => {
|
|
16719
|
+
part.faces.forEach((face) => polygon2.addFace([...face.shapes]));
|
|
16720
|
+
});
|
|
16697
16721
|
return polygon2;
|
|
16698
16722
|
}
|
|
16699
|
-
function parsePolygon(wkt) {
|
|
16700
|
-
if (wkt.startsWith("POLYGON")) {
|
|
16701
|
-
const polygonStr = wkt.replace(/^POLYGON /, "");
|
|
16702
|
-
return parseSinglePolygon(polygonStr);
|
|
16703
|
-
} else {
|
|
16704
|
-
const multiPolygonString = wkt.replace(/^MULTIPOLYGON \(\(\((.*)\)\)\)$/, "$1");
|
|
16705
|
-
return parseMutliPolygon(multiPolygonString);
|
|
16706
|
-
}
|
|
16707
|
-
}
|
|
16708
16723
|
function parseArrayOfPoints(str) {
|
|
16709
16724
|
const arr = str.split("\n").map((x) => x.match(/\(([^)]+)\)/)[1]);
|
|
16710
16725
|
return arr.map(parseSinglePoint);
|
|
@@ -16714,28 +16729,39 @@ function parseArrayOfLineStrings(str) {
|
|
|
16714
16729
|
return arr.map(parseLineString).reduce((acc, x) => [...acc, ...x], []);
|
|
16715
16730
|
}
|
|
16716
16731
|
function parseWKT(str) {
|
|
16717
|
-
|
|
16718
|
-
|
|
16719
|
-
|
|
16720
|
-
|
|
16721
|
-
|
|
16722
|
-
|
|
16723
|
-
|
|
16724
|
-
|
|
16725
|
-
|
|
16726
|
-
|
|
16727
|
-
|
|
16728
|
-
|
|
16729
|
-
|
|
16730
|
-
|
|
16731
|
-
|
|
16732
|
-
|
|
16733
|
-
const
|
|
16734
|
-
|
|
16735
|
-
|
|
16736
|
-
|
|
16737
|
-
|
|
16738
|
-
|
|
16732
|
+
const records = str.trim().split("\n");
|
|
16733
|
+
if (records.length > 1) {
|
|
16734
|
+
if (records.every((record) => /^\s*POINT\s*\([^()]*\)\s*$/.test(record))) {
|
|
16735
|
+
return parseArrayOfPoints(str.trim());
|
|
16736
|
+
}
|
|
16737
|
+
if (records.every((record) => /^\s*LINESTRING\s*\([^()]*\)\s*$/.test(record))) {
|
|
16738
|
+
return parseArrayOfLineStrings(str.trim());
|
|
16739
|
+
}
|
|
16740
|
+
}
|
|
16741
|
+
const geometry = str.trim().match(/^(POINT|MULTIPOINT|LINESTRING|MULTILINESTRING|POLYGON|MULTIPOLYGON|GEOMETRYCOLLECTION)\s*(EMPTY|\([\s\S]*\))$/);
|
|
16742
|
+
if (geometry) {
|
|
16743
|
+
const [, type, body] = geometry;
|
|
16744
|
+
if (body === "EMPTY") {
|
|
16745
|
+
if (type === "POLYGON") return new Polygon2();
|
|
16746
|
+
throw new Error("Empty geometry not supported");
|
|
16747
|
+
}
|
|
16748
|
+
const content = unwrap(body);
|
|
16749
|
+
switch (type) {
|
|
16750
|
+
case "POINT":
|
|
16751
|
+
return parseSinglePoint(content);
|
|
16752
|
+
case "MULTIPOINT":
|
|
16753
|
+
return parseMultiPoint(content);
|
|
16754
|
+
case "LINESTRING":
|
|
16755
|
+
return parseLineString(content);
|
|
16756
|
+
case "MULTILINESTRING":
|
|
16757
|
+
return parseMultiLineString(content);
|
|
16758
|
+
case "POLYGON":
|
|
16759
|
+
return parseSinglePolygon(body);
|
|
16760
|
+
case "MULTIPOLYGON":
|
|
16761
|
+
return parseMultiPolygon(content);
|
|
16762
|
+
case "GEOMETRYCOLLECTION":
|
|
16763
|
+
return splitComponents(content).map(parseWKT).reduce((acc, shapes) => acc.concat(shapes), []);
|
|
16764
|
+
}
|
|
16739
16765
|
} else if (isArrayOfPoints(str)) {
|
|
16740
16766
|
return parseArrayOfPoints(str);
|
|
16741
16767
|
} else if (isArrayOfLines(str)) {
|
|
@@ -18300,30 +18326,37 @@ var expandEasyEdaPathData = (pathData) => {
|
|
|
18300
18326
|
const command = commandMatch[1]?.toUpperCase();
|
|
18301
18327
|
const values = commandMatch[2]?.match(/[-+]?(?:\d*\.\d+|\d+\.?)(?:[eE][-+]?\d+)?/g)?.map(Number) ?? [];
|
|
18302
18328
|
if ((command === "M" || command === "L") && values.length >= 2) {
|
|
18303
|
-
|
|
18304
|
-
|
|
18329
|
+
for (let offset = 0; offset + 1 < values.length; offset += 2) {
|
|
18330
|
+
currentPoint = { x: values[offset], y: values[offset + 1] };
|
|
18331
|
+
rawRoute.push(currentPoint);
|
|
18332
|
+
}
|
|
18305
18333
|
} else if (command === "A" && currentPoint && values.length >= 7) {
|
|
18306
|
-
|
|
18307
|
-
|
|
18308
|
-
|
|
18309
|
-
|
|
18310
|
-
|
|
18311
|
-
|
|
18312
|
-
|
|
18313
|
-
|
|
18314
|
-
|
|
18315
|
-
|
|
18316
|
-
|
|
18317
|
-
|
|
18318
|
-
|
|
18319
|
-
|
|
18320
|
-
|
|
18321
|
-
|
|
18334
|
+
for (let offset = 0; offset + 6 < values.length; offset += 7) {
|
|
18335
|
+
const [radiusX, , , largeArcFlag, sweepFlag, endX, endY] = values.slice(
|
|
18336
|
+
offset,
|
|
18337
|
+
offset + 7
|
|
18338
|
+
);
|
|
18339
|
+
const generatedArcRoute = generateArcFromSweep(
|
|
18340
|
+
currentPoint.x,
|
|
18341
|
+
currentPoint.y,
|
|
18342
|
+
endX,
|
|
18343
|
+
endY,
|
|
18344
|
+
radiusX,
|
|
18345
|
+
largeArcFlag === 1,
|
|
18346
|
+
sweepFlag === 1
|
|
18347
|
+
);
|
|
18348
|
+
const maxArcSegments = 16;
|
|
18349
|
+
const arcRoute = generatedArcRoute.length <= maxArcSegments + 1 ? generatedArcRoute : Array.from(
|
|
18350
|
+
{ length: maxArcSegments + 1 },
|
|
18351
|
+
(_, pointIndex) => generatedArcRoute.at(
|
|
18352
|
+
Math.round(
|
|
18353
|
+
pointIndex * (generatedArcRoute.length - 1) / maxArcSegments
|
|
18354
|
+
)
|
|
18322
18355
|
)
|
|
18323
|
-
)
|
|
18324
|
-
|
|
18325
|
-
|
|
18326
|
-
|
|
18356
|
+
).filter((point4) => !!point4);
|
|
18357
|
+
rawRoute.push(...arcRoute.slice(1));
|
|
18358
|
+
currentPoint = { x: endX, y: endY };
|
|
18359
|
+
}
|
|
18327
18360
|
}
|
|
18328
18361
|
}
|
|
18329
18362
|
return rawRoute;
|
|
@@ -20170,7 +20203,7 @@ var PolygonShapeOutputSchema = external_exports.object({
|
|
|
20170
20203
|
lineColor: external_exports.string(),
|
|
20171
20204
|
id: external_exports.string()
|
|
20172
20205
|
});
|
|
20173
|
-
var
|
|
20206
|
+
var parsePolygon = (str) => {
|
|
20174
20207
|
const [, ...rest] = str.split("~");
|
|
20175
20208
|
const [pointsStr, lineColor, lineWidth, , fillColor, id] = rest;
|
|
20176
20209
|
return {
|
|
@@ -20182,7 +20215,7 @@ var parsePolygon2 = (str) => {
|
|
|
20182
20215
|
id
|
|
20183
20216
|
};
|
|
20184
20217
|
};
|
|
20185
|
-
var PolygonShapeSchema = external_exports.string().startsWith("PG~").transform(
|
|
20218
|
+
var PolygonShapeSchema = external_exports.string().startsWith("PG~").transform(parsePolygon).pipe(PolygonShapeOutputSchema);
|
|
20186
20219
|
var PathShapeOutputSchema = external_exports.object({
|
|
20187
20220
|
type: external_exports.literal("PATH"),
|
|
20188
20221
|
pathData: external_exports.string(),
|
|
@@ -21638,7 +21671,8 @@ var isInductorComponent = (betterEasy) => {
|
|
|
21638
21671
|
const componentParameters = betterEasy.dataStr.head.c_para;
|
|
21639
21672
|
const packageName = componentParameters.package;
|
|
21640
21673
|
const value = componentParameters.Value;
|
|
21641
|
-
|
|
21674
|
+
const hasInductorIdentity = componentParameters.pre?.toUpperCase() === "L?" || packageName?.toUpperCase().startsWith("IND-") === true;
|
|
21675
|
+
return hasInductorIdentity && typeof value === "string" && inductancePattern.test(value.trim());
|
|
21642
21676
|
};
|
|
21643
21677
|
|
|
21644
21678
|
// lib/websafe/convert-to-typescript-component/is-micro-usb-connector-component.ts
|