Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add A type #136

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions lib/schemas/single-letter-shape-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,38 @@ export const TextShapeSchema = z
.transform(parseText)
.pipe(TextShapeOutputSchema)

const AngleShapeOutputSchema = z.object({
type: z.literal("ANGLE"),
angleData: z.string(),
position: PointSchema,
radius: z.number(),
angle: z.number(), // the angle of the arc or the direction in degrees
color: z.string(),
lineWidth: z.number(),
id: z.string(),
})

const parseAngle = (str: string): z.infer<typeof AngleShapeOutputSchema> => {
const [, angleData, x, y, radius, angle, color, lineWidth, , id] =
str.split("~")
return {
type: "ANGLE",
angleData,
position: { x: Number(x), y: Number(y) },
radius: Number(radius),
angle: Number(angle),
color,
lineWidth: Number(lineWidth),
id,
}
}

export const AngleShapeSchema = z
.string()
.startsWith("A~") // Assuming the shape starts with 'A~' to distinguish it from others
.transform(parseAngle)
.pipe(AngleShapeOutputSchema)

export const SingleLetterShapeSchema = z
.string()
.transform((x) => {
Expand All @@ -361,6 +393,8 @@ export const SingleLetterShapeSchema = z
if (x.startsWith("PG~")) return PolygonShapeSchema.parse(x)
if (x.startsWith("PT~")) return PathShapeSchema.parse(x)
if (x.startsWith("T~")) return TextShapeSchema.parse(x)
if (x.startsWith("A~")) return AngleShapeSchema.parse(x) // Add this line for AngleShape

throw new Error(`Invalid shape type: ${x}`)
})
.pipe(
Expand All @@ -372,6 +406,7 @@ export const SingleLetterShapeSchema = z
PolygonShapeOutputSchema,
PathShapeOutputSchema,
TextShapeOutputSchema,
AngleShapeOutputSchema, // Include AngleShapeOutputSchema here
]),
)

Expand Down
233 changes: 233 additions & 0 deletions tests/assets/C388629.raweasy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
{
"uuid": "2214622583dc4cfabd8f300f1661a259",
"title": "DC-C300-5.5A-2.0",
"description": "",
"docType": 2,
"type": 3,
"thumb": "//image.lceda.cn/components/2214622583dc4cfabd8f300f1661a259.png",
"lcsc": {
"id": 363899,
"number": "C388629",
"step": 1,
"min": 1,
"price": 0.4884,
"stock": 484,
"url": "https://lcsc.com/product-detail/New-Arrivals_XKB-Enterprise-DC-C300-5-5A-2-0_C388629.html"
},
"szlcsc": {
"id": "363899",
"number": "C388629",
"step": 1,
"min": 1,
"price": 3.07,
"stock": 870,
"url": "http://www.szlcsc.com/product/details_363899.html"
},
"owner": {
"uuid": "0819f05c4eef4c71ace90d822a990e87",
"username": "LCSC",
"nickname": "LCSC",
"avatar": "//image.lceda.cn/avatars/2018/6/kFlrasi7W06gTdBLAqW3fkrqbDhbowynuSzkjqso.png"
},
"tags": ["AC/DC Power Connectors"],
"updateTime": 1729741207,
"updated_at": "2024-12-21 12:55:37",
"dataStr": {
"head": {
"docType": "2",
"editorVersion": "6.3.20",
"x": 400,
"y": 300,
"c_para": {
"pre": "DC?",
"name": "DC-C300-5.5A-2.0",
"package": "DC-IN-TH_DC-C300-5.5A-2.0",
"Contributor": "LCSC",
"Supplier": "LCSC",
"Supplier Part": "C388629",
"Manufacturer": "XKB Connection(中国星坤)",
"Manufacturer Part": "DC-C300-5.5A-2.0",
"JLCPCB Part Class": "Extended Part"
},
"uuid": "2214622583dc4cfabd8f300f1661a259",
"puuid": "21024e9f56414473b92b664f1f0f678c",
"importFlag": 0,
"c_spiceCmd": null,
"hasIdFlag": true,
"utime": 1576761521
},
"canvas": "CA~1000~1000~#FFFFFF~yes~#CCCCCC~10~1000~1000~line~10~pixel~5~400~300",
"shape": [
"PL~410 300 404 300~#880000~1~0~none~gge3~0",
"R~400~294~~~4~12~#880000~1~0~none~gge4~0~",
"PL~400 296 380 296~#880000~1~0~none~gge5~0",
"PL~400 304 380 304~#880000~1~0~none~gge6~0",
"A~M 380 304 A 4 4 0 1 1 380 296~~#880000~1~0~none~gge7~0",
"PL~410 320 381 320 379 316 377 320~#880000~1~0~none~gge8~0",
"PL~410 310 393 310 393 320 392 315~#880000~1~0~none~gge9~0",
"PL~393 320 394 315~#880000~1~0~none~gge10~0",
"P~show~0~2~430~300~~gge11~0^^430~300^^M 430 300 h -20~#880000^^0~408~303~0~2~end~~~#0000FF^^1~415~299~0~2~start~~~#0000FF^^0~413~300^^0~M 410 297 L 407 300 L 410 303",
"P~show~0~3~430~320~~gge18~0^^430~320^^M 430 320 h -20~#880000^^0~408~323~0~3~end~~~#0000FF^^1~415~319~0~3~start~~~#0000FF^^0~413~320^^0~M 410 317 L 407 320 L 410 323",
"P~show~0~1~430~310~~gge25~0^^430~310^^M 430 310 h -20~#880000^^0~408~313~0~1~end~~~#0000FF^^1~415~309~0~1~start~~~#0000FF^^0~413~310^^0~M 410 307 L 407 310 L 410 313",
"PL~410 280 381 280 379 284 377 280~#880000~1~0~none~gge33~0",
"P~show~0~4~430~280~~gge36~0^^430~280^^M 430 280 h -20~#880000^^0~408~283~0~4~end~~~#0000FF^^1~415~279~0~4~start~~~#0000FF^^0~413~280^^0~M 410 277 L 407 280 L 410 283"
],
"BBox": {
"x": 376,
"y": 270,
"width": 56,
"height": 52
},
"colors": []
},
"verify": true,
"SMT": true,
"datastrid": "9f9f61a1a06448a2a0b973012e83c41b",
"jlcOnSale": 1,
"writable": false,
"isFavorite": false,
"packageDetail": {
"uuid": "21024e9f56414473b92b664f1f0f678c",
"title": "DC-IN-TH_DC-C300-5.5A-2.0",
"docType": 4,
"updateTime": 1639556704,
"owner": {
"uuid": "0819f05c4eef4c71ace90d822a990e87",
"username": "LCSC",
"nickname": "LCSC",
"avatar": "//image.lceda.cn/avatars/2018/6/kFlrasi7W06gTdBLAqW3fkrqbDhbowynuSzkjqso.png",
"team": true
},
"datastrid": "211cb77d5ab94183a4ee2eff743a3421",
"writable": false,
"dataStr": {
"head": {
"docType": "4",
"editorVersion": "6.4.27",
"c_para": {
"package": "DC-IN-TH_DC-C300-5.5A-2.0",
"pre": "U?",
"Contributor": "立创EDA官方封装库",
"link": "https://item.szlcsc.com/363899.html",
"3DModel": "DC-IN-TH_DC-C300-5.5A-2.0"
},
"hasIdFlag": true,
"x": 3999.5669,
"y": 3001.1929,
"uuid": "21024e9f56414473b92b664f1f0f678c",
"utime": 1639556687,
"importFlag": 0,
"transformList": ""
},
"canvas": "CA~1000~1000~#000000~yes~#FFFFFF~10~1000~1000~line~0.03937~mm~1~45~visible~0.5~3999.5669~3001.1929~0~none",
"shape": [
"CIRCLE~3973.1889~2980.7205~0.1181~0.2362~101~gge330~0~~",
"TRACK~1~10~~4014.78 2990.17 4019.65 2990.17 4019.65 2990.17 4019.65 3037.02 4019.65 3037.02~gge262~0",
"TRACK~1~10~~3983.28 2990.17 3978.66 2990.17 3978.66 3037.02~gge265~0",
"TRACK~1~10~~3983.2796 2990.1693 4014.7796 2990.1693~gge181~0",
"SOLIDREGION~100~~M 4025.9449 3016.5471 L 4025.9449 3022.8463 L 4024.7637 3022.8463 L 4024.7637 3016.5471 Z~solid~gge190~~~~0",
"SOLIDREGION~100~~M 3974.3701 3016.5471 L 3974.3701 3022.8463 L 3973.1889 3022.8463 L 3973.1889 3016.5471 Z~solid~gge193~~~~0",
"SOLIDREGION~100~~M 3975.1576 2991.1535 L 3975.1576 2996.2717 L 3973.9764 2996.2717 L 3973.9764 2991.1535 Z~solid~gge226~~~~0",
"SOLIDREGION~100~~M 4024.3702 2991.1533 L 4024.3702 2995.4841 L 4023.189 2995.4841 L 4023.189 2991.1533 Z ~solid~gge229~~~~0",
"SOLIDREGION~100~~M 4000.1575 2980.7205 L 4004.0945 2980.7205 L 4004.0945 2984.6575 L 4000.1575 2984.6575 Z~solid~gge241~~~~0",
"SOLIDREGION~100~~M 4024.37 2991.1536 L 4019.0157 2991.1536 L 4019.0157 2995.4843 L4024.37,2995.4843 Z~cutout~gge244~~~~0",
"SOLIDREGION~100~~M 4025.9448 3016.5472 L 4019.0157 3016.5472 L 4019.0157 3022.8464 L4025.9448,3022.8464 Z~cutout~gge247~~~~0",
"SOLIDREGION~100~~M 3973.189 3022.846 L 3980.1181 3022.846 L 3980.1181 3016.5468 L 3973.189 3016.5468 Z~cutout~gge253~~~~0",
"SOLIDREGION~100~~M 3973.9764 2991.1536 L 3979.3307 2991.1536 L 3979.3307 2996.2717 L3973.9764,2996.2717 Z~cutout~gge256~~~~0",
"SOLIDREGION~100~~M 4000.1575 2980.7205 L 4000.1575 2991.1929 L 4004.0944 2991.1929 L4004.0944,2980.7205 Z~cutout~gge259~~~~0",
"SOLIDREGION~99~~M 3979.2914 3037.0197 L 3979.2914 2991.1535 L 4019.0551 2991.1535 L 4019.0551 3037.0197 Z ~solid~gge139~~~~0",
"TRACK~1~3~~3978.036 2989.3819 3978.036 3036.626~gge313~0",
"TRACK~1~3~~4020.3102 2989.3819 4020.3102 3036.626~gge304~0",
"TRACK~1~3~~3995.6299 2989.3819 3978.036 2989.3819 4020.3102 2989.3819~gge298~0",
"CIRCLE~4002.0866~2979.1063~0.9843~1.9685~12~gge322~0~~",
"PAD~RECT~3973.7795~3019.6967~9.8425~5.9055~11~~4~1.7717~3970.8267 3024.6178 3970.8267 3014.7752 3976.7323 3014.7752 3976.7323 3024.6178~90~gge29~8.2678~3973.7795 3022.0587 3973.7795 3017.3343~Y~0~0~0.2~",
"PAD~RECT~4025.3543~3019.6967~9.8425~5.9055~11~~4~1.7717~4022.4011 3024.6178 4022.4011 3014.7752 4028.3067 3014.7752 4028.3067 3024.6178~90~gge30~8.2678~4025.3539 3022.0587 4025.3539 3017.3343~Y~0~0~0.2~",
"PAD~ELLIPSE~4002.126~2982.689~11.0236~11.0236~11~~2~3.3465~~0~gge31~0~~Y~0~0~0.2~4002.126,2982.6888",
"PAD~RECT~4023.7796~2993.3187~7.874~5.1181~11~~3~1.7717~4021.2202 2997.2557 4021.2202 2989.3817 4026.3384 2989.3817 4026.3384 2997.2557~90~gge32~5.9056~4023.7793 2994.4998 4023.7793 2992.1376~Y~0~0~0.2~",
"PAD~RECT~3974.567~2993.7126~9.8425~5.1181~11~~1~1.5748~3972.0078 2998.6335 3972.0078 2988.7909 3977.126 2988.7909 3977.126 2998.6335~90~gge33~7.0866~3974.5669 2995.6806 3974.5669 2991.7436~Y~0~0~0.2~",
"SVGNODE~{\"gId\":\"g1_outline\",\"nodeName\":\"g\",\"nodeType\":1,\"layerid\":\"19\",\"attrs\":{\"c_width\":\"53.1495\",\"c_height\":\"56.10225\",\"c_rotation\":\"0,0,0\",\"z\":\"-13.7795\",\"c_origin\":\"3999.075,3008.5906\",\"uuid\":\"1290c89544e4464fb2935b860b5e0308\",\"c_etype\":\"outline3D\",\"id\":\"g1_outline\",\"title\":\"DC-IN-TH_DC-C300-5.5A-2.0\",\"layerid\":\"19\",\"transform\":\"scale(1) translate(0, 0)\"},\"childNodes\":[{\"gId\":\"g1_outline_line0\",\"nodeName\":\"polyline\",\"nodeType\":1,\"attrs\":{\"fill\":\"none\",\"id\":\"g1_outline_line0\",\"c_shapetype\":\"line\",\"points\":\"3972.5002 3016.563 3972.5002 3022.8622 3972.6183 3022.8622 3972.697 3022.8622 3973.2876 3022.8622 3973.4057 3022.8622 3973.6813 3022.8622 3973.9175 3022.8622 3973.9568 3022.8622 3974.075 3022.8622 3974.6261 3022.8622 3974.7049 3022.8622 3974.823 3022.8622 3978.4057 3022.8622 3978.7994 3022.8622 3979.0749 3022.8622 3979.1931 3022.8622 3979.1931 3022.9409 3979.1931 3023.2165 3979.1931 3023.6102 3979.1931 3024.0827 3979.1931 3024.4764 3979.1931 3024.752 3979.1931 3024.8307 3979.1931 3028.7677 3979.1931 3036.6417 3979.6261 3036.6417 3979.9805 3036.6417 3980.2954 3036.6417 3980.3742 3036.6417 3980.6497 3036.6417 3980.7679 3036.6417 3980.9647 3036.6417 3981.1222 3036.6417 3981.1616 3036.6417 3981.3584 3036.6417 3982.3427 3036.6417 3990.256 3036.6417 3990.6497 3036.6417 3991.3584 3036.6417 3993.4056 3036.6417 3994.1143 3036.6417 3995.0985 3036.6417 3997.1458 3036.6417 3997.697 3036.6417 3999.2718 3036.6417 4002.8544 3036.6417 4002.8938 3036.6417 4003.0119 3036.6417 4003.0513 3036.6417 4003.0906 3036.6417 4004.7836 3036.6417 4006.9095 3036.6417 4008.9568 3036.6417 4009.941 3036.6417 4010.6497 3036.6417 4012.6969 3036.6417 4013.4056 3036.6417 4013.7993 3036.6417 4015.8072 3036.6417 4016.5552 3036.6417 4016.7914 3036.6417 4016.9883 3036.6417 4017.1851 3036.6417 4017.382 3036.6417 4017.6182 3036.6417 4017.7757 3036.6417 4017.8544 3036.6417 4018.1694 3036.6417 4018.5237 3036.6417 4018.9568 3036.6417 4018.9568 3028.7677 4018.9568 3024.8307 4018.9568 3024.7126 4018.9568 3024.3189 4018.9568 3023.8465 4018.9568 3023.3346 4018.9568 3022.9803 4018.9568 3022.8622 4019.0749 3022.8622 4019.3505 3022.8622 4019.7442 3022.8622 4023.3268 3022.8622 4023.4449 3022.8622 4023.563 3022.8622 4024.1142 3022.8622 4024.193 3022.8622 4024.2717 3022.8622 4024.4686 3022.8622 4024.7835 3022.8622 4024.8623 3022.8622 4025.4528 3022.8622 4025.5315 3022.8622 4025.6497 3022.8622 4025.6497 3019.7126 4025.6497 3016.563 4025.5315 3016.563 4025.4528 3016.563 4024.8623 3016.563 4024.7441 3016.563 4024.4686 3016.563 4024.2323 3016.563 4024.193 3016.563 4024.0749 3016.563 4023.5237 3016.563 4023.4449 3016.563 4023.3268 3016.563 4019.7442 3016.563 4019.3505 3016.563 4019.0749 3016.563 4018.9568 3016.563 4018.9568 3016.4843 4018.9568 3016.2087 4018.9568 3015.815 4018.9568 3015.3425 4018.9568 3014.9488 4018.9568 3014.6732 4018.9568 3014.5945 4018.9568 2998.6497 4018.9568 2995.5001 4022.4213 2995.5001 4022.815 2995.5001 4023.0906 2995.5001 4023.2087 2995.5001 4023.7993 2995.5001 4023.9961 2995.5001 4023.9961 2995.3819 4023.9961 2994.9882 4023.9961 2994.4764 4023.9961 2991.4056 4023.9961 2990.8938 4023.9961 2990.5001 4023.9961 2990.382 4023.7993 2990.382 4023.2087 2990.382 4023.0906 2990.382 4022.815 2990.382 4022.4213 2990.382 4009.5867 2990.382 4009.193 2990.382 4008.9174 2990.382 4008.7993 2990.382 4008.6024 2990.382 4008.2481 2990.382 4008.0119 2990.382 4007.9332 2990.382 4007.6182 2990.382 4007.2245 2990.382 4005.1773 2990.382 4003.9568 2989.2009 4003.9962 2985.6576 4003.9962 2984.6733 4003.9962 2983.8072 4003.9962 2983.0985 4003.9962 2982.6654 4003.9962 2982.508 4003.9568 2982.0749 4003.7206 2981.5237 4003.5631 2981.2875 4003.0119 2980.815 4002.8938 2980.7363 4002.0277 2980.5395 4001.1615 2980.7363 4001.0434 2980.815 4000.4922 2981.2875 4000.3347 2981.5237 4000.0985 2982.0749 4000.0592 2982.508 4000.0592 2982.6261 4000.0592 2982.7048 4000.0985 2982.7835 4000.0592 2982.6654 4000.0985 2982.7442 4000.0592 2982.7048 4000.0592 2982.6261 4000.0985 2982.5867 4000.0985 2982.6654 4000.0985 2982.7442 4000.0592 2982.6654 4000.0592 2982.508 4000.0985 2982.3505 4000.0985 2982.4686 4000.0592 2982.5867 4000.0592 2982.508 4000.0985 2982.0749 4000.0985 2982.3505 4000.0592 2982.508 4000.0592 2982.6654 4000.0592 2983.0985 4000.0592 2983.8072 4000.0592 2984.6733 4000.0592 2985.6576 4000.0985 2989.2009 3998.8781 2990.382 3997.1064 2990.382 3996.7127 2990.382 3996.4371 2990.382 3996.319 2990.382 3995.7285 2990.382 3995.5316 2990.382 3995.5316 2990.7757 3994.7442 2990.7757 3985.6891 2990.7757 3983.5238 2990.7757 3982.3427 2990.7757 3981.3584 2990.7757 3981.1616 2990.7757 3980.7679 2990.7757 3980.6497 2990.7757 3980.3742 2990.7757 3980.2954 2990.7757 3979.9805 2990.7757 3979.6261 2990.7757 3979.1931 2990.7757 3978.9962 2990.7757 3978.9962 2990.9725 3975.7285 2990.9725 3975.3348 2990.9725 3975.1379 2990.9725 3975.0592 2990.9725 3974.9411 2990.9725 3974.6261 2990.9725 3974.2718 2990.9725 3974.1537 2990.9725 3974.1537 2991.0512 3974.1537 2991.2875 3974.1537 2991.6024 3974.1537 2991.9961 3974.1537 2995.067 3974.1537 2995.4607 3974.1537 2995.7756 3974.1537 2996.0119 3974.1537 2996.0906 3974.2718 2996.0906 3974.6261 2996.0906 3974.9411 2996.0906 3975.0592 2996.0906 3975.1379 2996.0906 3975.3348 2996.0906 3975.7285 2996.0906 3979.1931 2996.0906 3979.1931 2998.6497 3979.1931 3014.5945 3979.1931 3014.7126 3979.1931 3015.0669 3979.1931 3015.5788 3979.1931 3016.0512 3979.1931 3016.4449 3979.1931 3016.563 3979.0749 3016.563 3978.7994 3016.563 3978.4057 3016.563 3974.823 3016.563 3974.7049 3016.563 3974.5868 3016.563 3974.0356 3016.563 3973.9568 3016.563 3973.8781 3016.563 3973.6813 3016.563 3973.3663 3016.563 3973.2876 3016.563 3972.697 3016.563 3972.6183 3016.563 3972.5002 3016.563 3972.5002 3016.563\"}}]}"
],
"layers": [
"1~TopLayer~#FF0000~true~false~true~",
"2~BottomLayer~#0000FF~true~false~true~",
"3~TopSilkLayer~#FFCC00~true~false~true~",
"4~BottomSilkLayer~#66CC33~true~false~true~",
"5~TopPasteMaskLayer~#808080~true~false~true~",
"6~BottomPasteMaskLayer~#800000~true~false~true~",
"7~TopSolderMaskLayer~#800080~true~false~true~0.3",
"8~BottomSolderMaskLayer~#AA00FF~true~false~true~0.3",
"9~Ratlines~#6464FF~true~false~true~",
"10~BoardOutLine~#FF00FF~true~false~true~",
"11~Multi-Layer~#FFFFFF~true~false~true~0.5",
"12~Document~#FFFFFF~true~true~true~",
"13~TopAssembly~#33CC99~true~false~true~",
"14~BottomAssembly~#5555FF~true~false~true~",
"15~Mechanical~#F022F0~true~false~true~",
"19~3DModel~#66CCFF~true~false~true~",
"21~Inner1~#800000~false~false~false~~",
"22~Inner2~#008000~false~false~false~~",
"23~Inner3~#00FF00~false~false~false~~",
"24~Inner4~#BC8E00~false~false~false~~",
"25~Inner5~#70DBFA~false~false~false~~",
"26~Inner6~#00CC66~false~false~false~~",
"27~Inner7~#9966FF~false~false~false~~",
"28~Inner8~#800080~false~false~false~~",
"29~Inner9~#008080~false~false~false~~",
"30~Inner10~#15935F~false~false~false~~",
"31~Inner11~#000080~false~false~false~~",
"32~Inner12~#00B400~false~false~false~~",
"33~Inner13~#2E4756~false~false~false~~",
"34~Inner14~#99842F~false~false~false~~",
"35~Inner15~#FFFFAA~false~false~false~~",
"36~Inner16~#99842F~false~false~false~~",
"37~Inner17~#2E4756~false~false~false~~",
"38~Inner18~#3535FF~false~false~false~~",
"39~Inner19~#8000BC~false~false~false~~",
"40~Inner20~#43AE5F~false~false~false~~",
"41~Inner21~#C3ECCE~false~false~false~~",
"42~Inner22~#728978~false~false~false~~",
"43~Inner23~#39503F~false~false~false~~",
"44~Inner24~#0C715D~false~false~false~~",
"45~Inner25~#5A8A80~false~false~false~~",
"46~Inner26~#2B937E~false~false~false~~",
"47~Inner27~#23999D~false~false~false~~",
"48~Inner28~#45B4E3~false~false~false~~",
"49~Inner29~#215DA1~false~false~false~~",
"50~Inner30~#4564D7~false~false~false~~",
"51~Inner31~#6969E9~false~false~false~~",
"52~Inner32~#9069E9~false~false~false~~",
"99~ComponentShapeLayer~#00CCCC~true~false~true~0.4",
"100~LeadShapeLayer~#CC9999~true~false~true~",
"101~ComponentPolarityLayer~#66FFCC~true~false~true~",
"Hole~Hole~#222222~false~false~true~",
"DRCError~DRCError~#FAD609~false~false~true~"
],
"objects": [
"All~true~false",
"Component~true~true",
"Prefix~true~true",
"Name~true~false",
"Track~true~true",
"Pad~true~true",
"Via~true~true",
"Hole~true~true",
"Copper_Area~true~true",
"Circle~true~true",
"Arc~true~true",
"Solid_Region~true~true",
"Text~true~true",
"Image~true~true",
"Rect~true~true",
"Dimension~true~true",
"Protractor~true~true"
],
"BBox": {
"x": 3970.8,
"y": 2977,
"width": 57.5,
"height": 60
},
"netColors": []
}
}
}
24 changes: 24 additions & 0 deletions tests/convert-to-soup-tests/c388629.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import c388629 from "tests/assets/C388629.raweasy.json"
import { expect, test } from "bun:test"
import { convertEasyEdaJsonToCircuitJson, EasyEdaJsonSchema } from "lib/index"
import { convertCircuitJsonToPcbSvg } from "circuit-to-svg"

test("C388629 should generate Circuit Json without errors", () => {
const bettereasy = EasyEdaJsonSchema.parse(c388629)
const circuitJson = convertEasyEdaJsonToCircuitJson(bettereasy)

expect(convertCircuitJsonToPcbSvg(circuitJson)).toMatchSvgSnapshot(
import.meta.path,
)
})

// Add a new test to specifically check the parsing of the PT shape
test("C388629 should parse PT shape correctly", () => {
const bettereasy = EasyEdaJsonSchema.parse(c388629)
const ptShape = bettereasy.dataStr.shape.find(
(shape) => shape.type === "ANGLE",
)
expect(ptShape).toBeDefined()
expect(ptShape?.type).toBe("ANGLE")
expect(ptShape?.angleData).toBe("M 380 304 A 4 4 0 1 1 380 296")
})
Loading