easyeda 0.0.262 → 0.0.264
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 -1
- package/dist/browser/index.js +206 -98
- package/dist/browser/index.js.map +1 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.js +206 -98
- package/dist/index.js.map +1 -1
- package/dist/main.cjs +238 -124
- package/dist/main.cjs.map +1 -1
- package/package.json +27 -26
package/dist/browser/index.d.ts
CHANGED
|
@@ -4892,8 +4892,20 @@ interface Options {
|
|
|
4892
4892
|
cadPositionXMm?: number;
|
|
4893
4893
|
cadPositionYMm?: number;
|
|
4894
4894
|
cadPositionZMm?: number;
|
|
4895
|
+
cadModelBounds?: {
|
|
4896
|
+
min: {
|
|
4897
|
+
x: number;
|
|
4898
|
+
y: number;
|
|
4899
|
+
z: number;
|
|
4900
|
+
};
|
|
4901
|
+
max: {
|
|
4902
|
+
x: number;
|
|
4903
|
+
y: number;
|
|
4904
|
+
z: number;
|
|
4905
|
+
};
|
|
4906
|
+
};
|
|
4895
4907
|
showDesignator?: boolean;
|
|
4896
4908
|
}
|
|
4897
|
-
declare const convertEasyEdaJsonToCircuitJson: (easyEdaJson: BetterEasyEdaJson, { useModelCdn, shouldRecenter, cadPositionXMm, cadPositionYMm, cadPositionZMm, showDesignator, }?: Options) => AnyCircuitElement[];
|
|
4909
|
+
declare const convertEasyEdaJsonToCircuitJson: (easyEdaJson: BetterEasyEdaJson, { useModelCdn, shouldRecenter, cadPositionXMm, cadPositionYMm, cadPositionZMm, cadModelBounds, showDesignator, }?: Options) => AnyCircuitElement[];
|
|
4898
4910
|
|
|
4899
4911
|
export { BBoxSchema, type BetterEasyEdaJson, DataStrSchema, EasyEdaJsonSchema, HeadSchema, LayerItemSchema, LcscSchema, ModelBoundsSchema, ObjectItemSchema, OwnerSchema, PackageDetailDataStrSchema, PackageDetailSchema, type RawEasyEdaJson, SzlcscSchema, convertBetterEasyToTsx, convertEasyEdaJsonToCircuitJson, convertRawEasyToTsx, fetchEasyEDAComponent, generateFootprintTsx, getModelCdnUrl, getModelObjCdnUrl, getModelStepCdnUrl, maybeNumber };
|
package/dist/browser/index.js
CHANGED
|
@@ -8916,11 +8916,11 @@ function generateArcFromSweep(startX, startY, endX, endY, radius, largeArcFlag,
|
|
|
8916
8916
|
const midY = (startY + endY) / 2;
|
|
8917
8917
|
const dx = endX - startX;
|
|
8918
8918
|
const dy = endY - startY;
|
|
8919
|
-
const
|
|
8920
|
-
if (
|
|
8919
|
+
const distance3 = Math.sqrt(dx * dx + dy * dy);
|
|
8920
|
+
if (distance3 === 0 || radius < distance3 / 2) {
|
|
8921
8921
|
return [start, end];
|
|
8922
8922
|
}
|
|
8923
|
-
const h = Math.sqrt(radius * radius -
|
|
8923
|
+
const h = Math.sqrt(radius * radius - distance3 * distance3 / 4);
|
|
8924
8924
|
const angle = Math.atan2(dy, dx);
|
|
8925
8925
|
const centerX = midX + h * Math.sin(angle) * (sweepFlag ? -1 : 1);
|
|
8926
8926
|
const centerY = midY - h * Math.cos(angle) * (sweepFlag ? -1 : 1);
|
|
@@ -8956,6 +8956,142 @@ function generateArcFromSweep(startX, startY, endX, endY, radius, largeArcFlag,
|
|
|
8956
8956
|
// lib/utils/easyeda-unit-to-mm.ts
|
|
8957
8957
|
var mil10ToMm = (value) => value * 10 * 0.0254;
|
|
8958
8958
|
|
|
8959
|
+
// node_modules/@tscircuit/math-utils/dist/chunk-3WCUPG5S.js
|
|
8960
|
+
var getBoundsCenter = (bounds) => ({
|
|
8961
|
+
x: (bounds.minX + bounds.maxX) / 2,
|
|
8962
|
+
y: (bounds.minY + bounds.maxY) / 2
|
|
8963
|
+
});
|
|
8964
|
+
|
|
8965
|
+
// node_modules/@tscircuit/math-utils/dist/chunk-5N7UJNVK.js
|
|
8966
|
+
var getBoundsFromPoints = (points) => {
|
|
8967
|
+
if (points.length === 0) {
|
|
8968
|
+
return null;
|
|
8969
|
+
}
|
|
8970
|
+
let minX = points[0].x;
|
|
8971
|
+
let minY = points[0].y;
|
|
8972
|
+
let maxX = points[0].x;
|
|
8973
|
+
let maxY = points[0].y;
|
|
8974
|
+
for (let i = 1; i < points.length; i++) {
|
|
8975
|
+
const point2 = points[i];
|
|
8976
|
+
if (point2.x < minX) minX = point2.x;
|
|
8977
|
+
if (point2.y < minY) minY = point2.y;
|
|
8978
|
+
if (point2.x > maxX) maxX = point2.x;
|
|
8979
|
+
if (point2.y > maxY) maxY = point2.y;
|
|
8980
|
+
}
|
|
8981
|
+
return { minX, minY, maxX, maxY };
|
|
8982
|
+
};
|
|
8983
|
+
|
|
8984
|
+
// lib/websafe/get-easyeda-cad-placement-helpers.ts
|
|
8985
|
+
var getCadSvgNode = (easyEdaJson) => {
|
|
8986
|
+
const svgNode = easyEdaJson.packageDetail.dataStr.shape.find(
|
|
8987
|
+
(shape) => shape.type === "SVGNODE" && shape.svgData.attrs?.uuid
|
|
8988
|
+
);
|
|
8989
|
+
return svgNode?.type === "SVGNODE" ? svgNode : null;
|
|
8990
|
+
};
|
|
8991
|
+
var isSvgChildNodeWithAttrs = (childNode) => typeof childNode === "object" && childNode !== null;
|
|
8992
|
+
var getXyBoundsFromModelBounds = (bounds) => ({
|
|
8993
|
+
minX: bounds.min.x,
|
|
8994
|
+
minY: bounds.min.y,
|
|
8995
|
+
maxX: bounds.max.x,
|
|
8996
|
+
maxY: bounds.max.y
|
|
8997
|
+
});
|
|
8998
|
+
var rotateScenePoint = (point2, rotationDeg) => {
|
|
8999
|
+
switch (rotationDeg) {
|
|
9000
|
+
case 0:
|
|
9001
|
+
return point2;
|
|
9002
|
+
case 90:
|
|
9003
|
+
return { x: point2.y, y: -point2.x };
|
|
9004
|
+
case 180:
|
|
9005
|
+
return { x: -point2.x, y: -point2.y };
|
|
9006
|
+
case 270:
|
|
9007
|
+
return { x: -point2.y, y: point2.x };
|
|
9008
|
+
}
|
|
9009
|
+
};
|
|
9010
|
+
var getEasyEdaModelOriginOnBoardMm = ({
|
|
9011
|
+
svgNode,
|
|
9012
|
+
footprintCenterMm
|
|
9013
|
+
}) => {
|
|
9014
|
+
const points = [];
|
|
9015
|
+
for (const childNode of svgNode.svgData.childNodes ?? []) {
|
|
9016
|
+
if (!isSvgChildNodeWithAttrs(childNode)) continue;
|
|
9017
|
+
const rawPoints = childNode.attrs?.points;
|
|
9018
|
+
if (!rawPoints) continue;
|
|
9019
|
+
const values = String(rawPoints).trim().split(/\s+/).map(Number);
|
|
9020
|
+
for (let i = 0; i + 1 < values.length; i += 2) {
|
|
9021
|
+
const x = values[i];
|
|
9022
|
+
const y = values[i + 1];
|
|
9023
|
+
if (Number.isFinite(x) && Number.isFinite(y)) {
|
|
9024
|
+
points.push({ x: mil10ToMm(x), y: mil10ToMm(y) });
|
|
9025
|
+
}
|
|
9026
|
+
}
|
|
9027
|
+
}
|
|
9028
|
+
let modelOriginMm = null;
|
|
9029
|
+
if (points.length > 0) {
|
|
9030
|
+
const bounds = getBoundsFromPoints(points);
|
|
9031
|
+
modelOriginMm = bounds ? getBoundsCenter(bounds) : null;
|
|
9032
|
+
} else {
|
|
9033
|
+
const [originX, originY] = String(svgNode.svgData.attrs?.c_origin ?? "0,0").split(",").map((value) => Number(value.trim()));
|
|
9034
|
+
if (Number.isFinite(originX) && Number.isFinite(originY)) {
|
|
9035
|
+
modelOriginMm = { x: mil10ToMm(originX), y: mil10ToMm(originY) };
|
|
9036
|
+
}
|
|
9037
|
+
}
|
|
9038
|
+
if (!modelOriginMm) return null;
|
|
9039
|
+
return {
|
|
9040
|
+
x: modelOriginMm.x - footprintCenterMm.x,
|
|
9041
|
+
y: footprintCenterMm.y - modelOriginMm.y
|
|
9042
|
+
};
|
|
9043
|
+
};
|
|
9044
|
+
var snapZero = (value) => Math.abs(value) < 1e-6 ? 0 : value;
|
|
9045
|
+
var normalizePoint = (point2) => ({
|
|
9046
|
+
x: snapZero(point2.x),
|
|
9047
|
+
y: snapZero(point2.y)
|
|
9048
|
+
});
|
|
9049
|
+
var getCadModelOffsetMm = (easyEdaJson) => {
|
|
9050
|
+
const svgNode = getCadSvgNode(easyEdaJson);
|
|
9051
|
+
return getCadModelOffsetMmFromBounds(
|
|
9052
|
+
easyEdaJson,
|
|
9053
|
+
easyEdaJson._objMetadata?.bounds
|
|
9054
|
+
);
|
|
9055
|
+
};
|
|
9056
|
+
var getCadModelOffsetMmFromBounds = (easyEdaJson, bounds, {
|
|
9057
|
+
footprintBoundsCenterMm
|
|
9058
|
+
} = {}) => {
|
|
9059
|
+
const svgNode = getCadSvgNode(easyEdaJson);
|
|
9060
|
+
if (!svgNode || !bounds) return null;
|
|
9061
|
+
const [, , rotationZRaw] = String(
|
|
9062
|
+
svgNode.svgData.attrs?.c_rotation ?? "0,0,0"
|
|
9063
|
+
).split(",").map((value) => Number(value.trim()));
|
|
9064
|
+
const rotationDeg = (rotationZRaw % 360 + 360) % 360;
|
|
9065
|
+
if (![0, 90, 180, 270].includes(rotationDeg)) return null;
|
|
9066
|
+
const modelCenter = getBoundsCenter(getXyBoundsFromModelBounds(bounds));
|
|
9067
|
+
const footprintCenter = easyEdaJson.packageDetail.dataStr.head;
|
|
9068
|
+
const footprintCenterMm = footprintBoundsCenterMm ?? {
|
|
9069
|
+
x: mil10ToMm(footprintCenter.x),
|
|
9070
|
+
y: mil10ToMm(footprintCenter.y)
|
|
9071
|
+
};
|
|
9072
|
+
const targetOriginOnBoardMm = getEasyEdaModelOriginOnBoardMm({
|
|
9073
|
+
svgNode,
|
|
9074
|
+
footprintCenterMm
|
|
9075
|
+
});
|
|
9076
|
+
if (!targetOriginOnBoardMm) return null;
|
|
9077
|
+
const targetOriginInModelFrame = rotateScenePoint(
|
|
9078
|
+
targetOriginOnBoardMm,
|
|
9079
|
+
rotationDeg
|
|
9080
|
+
);
|
|
9081
|
+
return normalizePoint({
|
|
9082
|
+
x: modelCenter.x - targetOriginInModelFrame.x,
|
|
9083
|
+
y: modelCenter.y - targetOriginInModelFrame.y
|
|
9084
|
+
});
|
|
9085
|
+
};
|
|
9086
|
+
var getCadSvgNodeZOffsetMm = (easyEdaJson) => {
|
|
9087
|
+
const svgNode = getCadSvgNode(easyEdaJson);
|
|
9088
|
+
if (!svgNode) return null;
|
|
9089
|
+
const svgNodeZ = Number(svgNode.svgData.attrs?.z ?? 0);
|
|
9090
|
+
if (!Number.isFinite(svgNodeZ)) return null;
|
|
9091
|
+
return mil10ToMm(svgNodeZ);
|
|
9092
|
+
};
|
|
9093
|
+
var getCadSvgNodeModelUuid = (easyEdaJson) => getCadSvgNode(easyEdaJson)?.svgData.attrs?.uuid ?? null;
|
|
9094
|
+
|
|
8959
9095
|
// lib/utils/normalize-pin-labels.ts
|
|
8960
9096
|
var normalizePinLabels = (inputPinLabels) => {
|
|
8961
9097
|
const uniqueInputPinLabels = inputPinLabels.map((labels) => [
|
|
@@ -9172,6 +9308,7 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
|
|
|
9172
9308
|
cadPositionXMm,
|
|
9173
9309
|
cadPositionYMm,
|
|
9174
9310
|
cadPositionZMm,
|
|
9311
|
+
cadModelBounds,
|
|
9175
9312
|
showDesignator = false
|
|
9176
9313
|
} = {}) => {
|
|
9177
9314
|
const resolvedCadPositionZMm = cadPositionZMm ?? getCadPositionZMmFromMetadata(easyEdaJson);
|
|
@@ -9524,6 +9661,14 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
|
|
|
9524
9661
|
if (!cad.model_origin_position) {
|
|
9525
9662
|
cad.model_origin_position = { x: 0, y: 0, z: 0 };
|
|
9526
9663
|
}
|
|
9664
|
+
const resolvedCadModelBounds = cadModelBounds ?? easyEdaJson._objMetadata?.bounds;
|
|
9665
|
+
const recenteredCadOffset = resolvedCadModelBounds && getCadModelOffsetMmFromBounds(easyEdaJson, resolvedCadModelBounds, {
|
|
9666
|
+
footprintBoundsCenterMm: bounds.center
|
|
9667
|
+
});
|
|
9668
|
+
if (recenteredCadOffset) {
|
|
9669
|
+
cad.model_origin_position.x = recenteredCadOffset.x;
|
|
9670
|
+
cad.model_origin_position.y = recenteredCadOffset.y;
|
|
9671
|
+
}
|
|
9527
9672
|
const side = pcb_component2.layer ?? "top";
|
|
9528
9673
|
const t = DEFAULT_PCB_THICKNESS_MM / 2;
|
|
9529
9674
|
const attrs = svgNode?.svgData?.attrs ?? {};
|
|
@@ -10343,98 +10488,6 @@ function normalizeManufacturerPartNumber(partNumber) {
|
|
|
10343
10488
|
return normalized;
|
|
10344
10489
|
}
|
|
10345
10490
|
|
|
10346
|
-
// lib/websafe/get-easyeda-cad-placement-helpers.ts
|
|
10347
|
-
var milToMm = (mil) => mil * 0.0254;
|
|
10348
|
-
var getBoundsCenter = (bounds) => ({
|
|
10349
|
-
x: (bounds.min.x + bounds.max.x) / 2,
|
|
10350
|
-
y: (bounds.min.y + bounds.max.y) / 2
|
|
10351
|
-
});
|
|
10352
|
-
var getCadSvgNode = (easyEdaJson) => {
|
|
10353
|
-
const svgNode = easyEdaJson.packageDetail.dataStr.shape.find(
|
|
10354
|
-
(shape) => shape.type === "SVGNODE" && shape.svgData.attrs?.uuid
|
|
10355
|
-
);
|
|
10356
|
-
return svgNode?.type === "SVGNODE" ? svgNode : null;
|
|
10357
|
-
};
|
|
10358
|
-
var parseMil10Value = (value) => Number(String(value).replace("mil", "")) / 10;
|
|
10359
|
-
var isZeroishModelCenter = (value) => Math.abs(value) < 1e-6;
|
|
10360
|
-
var isZeroishFootprintDelta = (value) => Math.abs(value) < 1e-3;
|
|
10361
|
-
var getPadCenter = (easyEdaJson) => {
|
|
10362
|
-
const pads = easyEdaJson.packageDetail.dataStr.shape.filter(
|
|
10363
|
-
(shape) => shape.type === "PAD"
|
|
10364
|
-
);
|
|
10365
|
-
if (pads.length === 0) return null;
|
|
10366
|
-
const xs = pads.map((pad) => parseMil10Value(pad.center.x));
|
|
10367
|
-
const ys = pads.map((pad) => parseMil10Value(pad.center.y));
|
|
10368
|
-
return {
|
|
10369
|
-
x: (Math.min(...xs) + Math.max(...xs)) / 2,
|
|
10370
|
-
y: (Math.min(...ys) + Math.max(...ys)) / 2
|
|
10371
|
-
};
|
|
10372
|
-
};
|
|
10373
|
-
var getRotatedOffsetMm = ({
|
|
10374
|
-
bounds,
|
|
10375
|
-
rawOffsetMil,
|
|
10376
|
-
rotationDeg
|
|
10377
|
-
}) => {
|
|
10378
|
-
const center = getBoundsCenter(bounds);
|
|
10379
|
-
const offsetX = milToMm(rawOffsetMil.x);
|
|
10380
|
-
const offsetY = milToMm(rawOffsetMil.y);
|
|
10381
|
-
switch (rotationDeg) {
|
|
10382
|
-
case 0:
|
|
10383
|
-
return { x: center.x + offsetX, y: center.y + offsetY };
|
|
10384
|
-
case 90:
|
|
10385
|
-
return { x: center.x + offsetY, y: center.y + offsetX };
|
|
10386
|
-
case 180:
|
|
10387
|
-
return { x: center.x - offsetX, y: center.y - offsetY };
|
|
10388
|
-
case 270:
|
|
10389
|
-
return { x: center.x - offsetY, y: center.y - offsetX };
|
|
10390
|
-
}
|
|
10391
|
-
};
|
|
10392
|
-
var getCadModelOffsetMm = (easyEdaJson) => {
|
|
10393
|
-
const svgNode = getCadSvgNode(easyEdaJson);
|
|
10394
|
-
return getCadModelOffsetMmFromBounds(
|
|
10395
|
-
easyEdaJson,
|
|
10396
|
-
easyEdaJson._objMetadata?.bounds
|
|
10397
|
-
);
|
|
10398
|
-
};
|
|
10399
|
-
var getCadModelOffsetMmFromBounds = (easyEdaJson, bounds) => {
|
|
10400
|
-
const svgNode = getCadSvgNode(easyEdaJson);
|
|
10401
|
-
if (!svgNode || !bounds) return null;
|
|
10402
|
-
const [originX, originY] = String(svgNode.svgData.attrs?.c_origin ?? "0,0").split(",").map((value) => Number(value.trim()));
|
|
10403
|
-
if (!Number.isFinite(originX) || !Number.isFinite(originY)) return null;
|
|
10404
|
-
const [, , rotationZRaw] = String(
|
|
10405
|
-
svgNode.svgData.attrs?.c_rotation ?? "0,0,0"
|
|
10406
|
-
).split(",").map((value) => Number(value.trim()));
|
|
10407
|
-
const rotationDeg = (rotationZRaw % 360 + 360) % 360;
|
|
10408
|
-
if (![0, 90, 180, 270].includes(rotationDeg)) return null;
|
|
10409
|
-
const modelCenter = getBoundsCenter(bounds);
|
|
10410
|
-
const footprintCenter = easyEdaJson.packageDetail.dataStr.head;
|
|
10411
|
-
const padCenter = getPadCenter(easyEdaJson);
|
|
10412
|
-
const padCenterDelta = padCenter ? {
|
|
10413
|
-
x: padCenter.x - footprintCenter.x,
|
|
10414
|
-
y: padCenter.y - footprintCenter.y
|
|
10415
|
-
} : null;
|
|
10416
|
-
const rawOffsetMil = {
|
|
10417
|
-
x: (originX - footprintCenter.x) * 10,
|
|
10418
|
-
y: (originY - footprintCenter.y) * 10
|
|
10419
|
-
};
|
|
10420
|
-
if (padCenter && padCenterDelta && isZeroishModelCenter(modelCenter.x) && isZeroishModelCenter(modelCenter.y) && isZeroishFootprintDelta(padCenterDelta.x) && isZeroishFootprintDelta(padCenterDelta.y)) {
|
|
10421
|
-
return { x: 0, y: 0 };
|
|
10422
|
-
}
|
|
10423
|
-
return getRotatedOffsetMm({
|
|
10424
|
-
bounds,
|
|
10425
|
-
rawOffsetMil,
|
|
10426
|
-
rotationDeg
|
|
10427
|
-
});
|
|
10428
|
-
};
|
|
10429
|
-
var getCadSvgNodeZOffsetMm = (easyEdaJson) => {
|
|
10430
|
-
const svgNode = getCadSvgNode(easyEdaJson);
|
|
10431
|
-
if (!svgNode) return null;
|
|
10432
|
-
const svgNodeZ = Number(svgNode.svgData.attrs?.z ?? 0);
|
|
10433
|
-
if (!Number.isFinite(svgNodeZ)) return null;
|
|
10434
|
-
return mil10ToMm(svgNodeZ);
|
|
10435
|
-
};
|
|
10436
|
-
var getCadSvgNodeModelUuid = (easyEdaJson) => getCadSvgNode(easyEdaJson)?.svgData.attrs?.uuid ?? null;
|
|
10437
|
-
|
|
10438
10491
|
// lib/websafe/get-model-cdn-url.ts
|
|
10439
10492
|
var getModelObjCdnUrl = ({
|
|
10440
10493
|
easyedaModelUuid,
|
|
@@ -10644,7 +10697,7 @@ var getPinLabelValues = (labels) => {
|
|
|
10644
10697
|
if (typeof labels === "string") return [labels];
|
|
10645
10698
|
return [...labels];
|
|
10646
10699
|
};
|
|
10647
|
-
var
|
|
10700
|
+
var getPolarizedPortHintsMap = (pinLabels) => {
|
|
10648
10701
|
const labelsByPin = Object.entries(pinLabels ?? {}).map(([pin, labels]) => ({
|
|
10649
10702
|
pin,
|
|
10650
10703
|
labels: getPinLabelValues(labels).map((label) => label.toLowerCase())
|
|
@@ -10675,7 +10728,7 @@ var generateTypescriptComponent = ({
|
|
|
10675
10728
|
const cadComponent = circuitJson.find((item) => item.type === "cad_component");
|
|
10676
10729
|
const footprintTsx = generateFootprintTsx(
|
|
10677
10730
|
circuitJson,
|
|
10678
|
-
componentType === "diode" ? { portHintsMap:
|
|
10731
|
+
componentType === "diode" || componentType === "led" ? { portHintsMap: getPolarizedPortHintsMap(safePinLabels) } : void 0
|
|
10679
10732
|
);
|
|
10680
10733
|
const simplifiedPinLabels = Object.fromEntries(
|
|
10681
10734
|
Object.entries(safePinLabels).map(([pin, labels]) => {
|
|
@@ -10712,6 +10765,28 @@ ${cadModelLines}
|
|
|
10712
10765
|
/>
|
|
10713
10766
|
)
|
|
10714
10767
|
}
|
|
10768
|
+
`.trim();
|
|
10769
|
+
}
|
|
10770
|
+
if (componentType === "led") {
|
|
10771
|
+
return `
|
|
10772
|
+
import type { LedProps } from "@tscircuit/props"
|
|
10773
|
+
|
|
10774
|
+
export const ${componentName} = (props: LedProps) => {
|
|
10775
|
+
const { name = "LED1", ...restProps } = props
|
|
10776
|
+
|
|
10777
|
+
return (
|
|
10778
|
+
<led
|
|
10779
|
+
name={name}
|
|
10780
|
+
supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
10781
|
+
manufacturerPartNumber="${manufacturerPartNumber}"
|
|
10782
|
+
footprint={${footprintTsx}}
|
|
10783
|
+
${objUrl || stepUrl ? `cadModel={{
|
|
10784
|
+
${cadModelLines}
|
|
10785
|
+
}}` : ""}
|
|
10786
|
+
{...restProps}
|
|
10787
|
+
/>
|
|
10788
|
+
)
|
|
10789
|
+
}
|
|
10715
10790
|
`.trim();
|
|
10716
10791
|
}
|
|
10717
10792
|
return `
|
|
@@ -10765,7 +10840,39 @@ var isDiodeCategoryComponent = (betterEasy) => {
|
|
|
10765
10840
|
].some(categoryValueContainsDiode);
|
|
10766
10841
|
};
|
|
10767
10842
|
|
|
10843
|
+
// lib/websafe/convert-to-typescript-component/category-value-contains-led.ts
|
|
10844
|
+
var categoryValueContainsLed = (value) => {
|
|
10845
|
+
if (typeof value === "string") {
|
|
10846
|
+
return /(^|[^a-z])leds?([^a-z]|$)/i.test(value) || /light[-\s]?emitting\s+diodes?/i.test(value);
|
|
10847
|
+
}
|
|
10848
|
+
if (Array.isArray(value)) {
|
|
10849
|
+
return value.some(categoryValueContainsLed);
|
|
10850
|
+
}
|
|
10851
|
+
if (value && typeof value === "object") {
|
|
10852
|
+
return Object.values(value).some(categoryValueContainsLed);
|
|
10853
|
+
}
|
|
10854
|
+
return false;
|
|
10855
|
+
};
|
|
10856
|
+
|
|
10857
|
+
// lib/websafe/convert-to-typescript-component/is-led-category-component.ts
|
|
10858
|
+
var isLedCategoryComponent = (betterEasy) => {
|
|
10859
|
+
const cPara = betterEasy.dataStr.head.c_para;
|
|
10860
|
+
return [
|
|
10861
|
+
betterEasy.tags,
|
|
10862
|
+
cPara.category,
|
|
10863
|
+
cPara.Category,
|
|
10864
|
+
cPara["LCSC Category"],
|
|
10865
|
+
cPara["JLCPCB Category"],
|
|
10866
|
+
betterEasy.category
|
|
10867
|
+
].some(categoryValueContainsLed);
|
|
10868
|
+
};
|
|
10869
|
+
|
|
10768
10870
|
// lib/websafe/convert-to-typescript-component/index.tsx
|
|
10871
|
+
var getGeneratedComponentType = (betterEasy) => {
|
|
10872
|
+
if (isLedCategoryComponent(betterEasy)) return "led";
|
|
10873
|
+
if (isDiodeCategoryComponent(betterEasy)) return "diode";
|
|
10874
|
+
return "chip";
|
|
10875
|
+
};
|
|
10769
10876
|
var convertRawEasyToTsx = async ({ rawEasy }) => {
|
|
10770
10877
|
const betterEasy = EasyEdaJsonSchema.parse(rawEasy);
|
|
10771
10878
|
const result = await convertBetterEasyToTsx({
|
|
@@ -10783,6 +10890,7 @@ var convertBetterEasyToTsx = async ({
|
|
|
10783
10890
|
cadPositionXMm: cadPlacement?.positionXMm,
|
|
10784
10891
|
cadPositionYMm: cadPlacement?.positionYMm,
|
|
10785
10892
|
cadPositionZMm: cadPlacement?.positionZMm,
|
|
10893
|
+
cadModelBounds: cadPlacement?.bounds,
|
|
10786
10894
|
showDesignator: true
|
|
10787
10895
|
});
|
|
10788
10896
|
const [cadComponent] = su(circuitJson).cad_component.list();
|
|
@@ -10830,7 +10938,7 @@ var convertBetterEasyToTsx = async ({
|
|
|
10830
10938
|
stepUrl: modelStepUrl,
|
|
10831
10939
|
circuitJson,
|
|
10832
10940
|
supplierPartNumbers,
|
|
10833
|
-
componentType:
|
|
10941
|
+
componentType: getGeneratedComponentType(betterEasy)
|
|
10834
10942
|
});
|
|
10835
10943
|
};
|
|
10836
10944
|
var checkModelObjUrlValidity = async (url) => {
|