xsrf / easyeda-svg-import

Simple SVG Importer for EasyEDA PCB that doesn't convert everything to Comic Sans 😄
85 stars 8 forks source link

Uncaught TypeError: svgDocument.matchAll(...) #5

Closed vlrmprjct closed 3 years ago

vlrmprjct commented 3 years ago

After selecting a svg file and hit the "Import"-Button , nothing happens. As you can see in the screenshot below I tried this with different images.

Console Error Output: Uncaught TypeError: svgDocument.matchAll(...) is not a function or its return value is not iterable

image

xsrf commented 3 years ago

Okay, the regex won't match any <path ... > tags within the svg. I should add a proper error message for that. Can you provide an example svg?

vlrmprjct commented 3 years ago

Sure.

dd_normalized.zip

xsrf commented 3 years ago

Thank you. The image you provided consists of a lot of <line ... > segments which are not yet supported. But it also contains three <path ... > segments which import fine for me:

2020-11-24 15_24_50-Window

You can however convert the missing lines to paths using the free software Inkscape. Just open the SVG with Inkscape, select everything (CTRL+A) and then convert outlines to paths (Path -> Stroke to Path; CTRL+ALT+C) and save it. After that, the complete image imports fine for me. I've attached the converted image.

2020-11-24 15_34_08-Window

dd_normalized_out2path.zip

vlrmprjct commented 3 years ago

Ok. Thank you for your response.

But the point is the posted samplefile is a valid SVG and it is created with Inkscape. So can you please provide some DOES and DONT's for SVGs for a successful import ?

Maybe the readme.md ?

xsrf commented 3 years ago

There is a reference.svg in the root of the project. Also, I cannot reproduce the issue shown in your screenshot even with an empty string loaded as SVG. I guess the browser may be the issue. Are you using the desktop version of EasyEDA? I've actually not tested that yet, I use it with Chrome in the Browser. I've read that the Desktop Version ships with an older Browser version. Maybe that is the issue?

xsrf commented 3 years ago

Okay, confirmed that. The Desktop Version of EasyEDA ships with Chrome/69.0.3497.128 ... String.matchAll() requires at least Chrome/73 which was released in march 2019. So, for now, the extension will only work in the Browser. I'll have a look if I can find some polyfills to make it also work with that old version.

vlrmprjct commented 3 years ago

You are right. It depends on the browser version. I testet it in the latest Edge Browser and its working fine with the sample svg above without any changes.

xsrf commented 3 years ago

I found some polyfills and fixed the issue with d926c84e60e1aa75819e7403c79157be11e808c7 ... Now it should also work in the Desktop Client.