DOPΣ - umm what todo here, in cli, its passing ...

umm what todo here, in cli, its passing url like that, unlike runframe
No description
32 Replies
Seve
Seve2w ago
yea that's correct i think you didn't add core support i have no idea how it's working in RunFrame ehhhh wait so does it accept a url or no? basically if the user passes in a path, you have to load it as a url
DOPΣ
DOPΣOP2w ago
eval should transform that url to circuitjson as per working and u guided, thats how working in runframe
Seve
Seve2w ago
ehhh i think core doesn't recognize it as a url so it doesn't get sent to eval do u see what i'm saying it's not a major thing, it's like a simple "is this a url" thing i think unless core doesn't have async load support, which is what i originally thought, but then i was like "ehh i think core has async load and it's just confused and thinks the path isn't a url" does that make sense basically core should be like "oh this is a url" and send to platformConfig.kicad_mod.loadFromUrl
DOPΣ
DOPΣOP2w ago
is this ok?
No description
Seve
Seve2w ago
yea that looks right! did you fix it w/o modifying core?
DOPΣ
DOPΣOP2w ago
runframe api, doesnt pass raw static assets
No description
DOPΣ
DOPΣOP2w ago
thats problem any fix? or this ok
Seve
Seve2w ago
oh ok but you identified another bug because the error is really really bad in this case
DOPΣ
DOPΣOP2w ago
No description
Seve
Seve2w ago
wait kicad_mod is a static asset
DOPΣ
DOPΣOP2w ago
yup, thats dillema
Seve
Seve2w ago
it's not a dynamic file extension (that name sucks)
DOPΣ
DOPΣOP2w ago
with marking it static, it isnt working
Seve
Seve2w ago
ik you didn't come up w/ the name but that's a dumb name (i probably wrote it) yea i think it's the issue i mentioned where core doesn't handle urls that are absolute paths
DOPΣ
DOPΣOP2w ago
umm????? but core doesnt handle urls, isnt eval does? too confusion 😢
No description
DOPΣ
DOPΣOP2w ago
importLocalFile is in eval
Seve
Seve2w ago
yea there's something weird going on, you should just do:
import kicadMod from "./whatever.kicad_mod"

console.log(kicadMod)
import kicadMod from "./whatever.kicad_mod"

console.log(kicadMod)
it should be a url or a path if it's __STATIC_ASSET__ then something weird is happening also fwiw that core error is really bad and we'd probably be happier if we made the error better here it might make understanding easier e.g. it seems like core might have failed to parse something but i'm not sure
DOPΣ
DOPΣOP2w ago
cos thats passed by our runframe not by core cant see logs, as circuit is working in runframe
Seve
Seve2w ago
throw new Error("...") maybe
DOPΣ
DOPΣOP2w ago
No description
DOPΣ
DOPΣOP2w ago
this url is coming, ig its wrong. it should be /footprint,kicad_mod prolly something wrong with runframewithapi, doesnt pass raw assets you added support for STATIC_ASSET, did u know where u added logic to handle it?
Seve
Seve2w ago
no that looks correct the issue is in core i think i think core isn't fetching the asset
DOPΣ
DOPΣOP2w ago
..
No description
Seve
Seve2w ago
hehe you can ignore __STATIC_ASSET__ it's literally a placeholder because the file is never requested *the string is never requested or used etc. you need to handle /api/..../whatever.kicad_mod in core core doesn't know that it's a url
DOPΣ
DOPΣOP2w ago
ahh kk understood, pretty confusion ill try it then kicad parser should also be added to core would that be ok?
Seve
Seve2w ago
no it shouldn't be that's the point of platformConfig.kicad_mod.loadFromUrl in your test, you can just mock it and provide a platform config that returns a simple footprint or whatever
DOPΣ
DOPΣOP2w ago
ohohohohoohoh
DOPΣ
DOPΣOP2w ago
its for tests?
No description
DOPΣ
DOPΣOP2w ago
whats alternate?
No description
Seve
Seve2w ago
const isUrl = isThisUrl(footprintString)

if (isUrl) {
const fileExtension = getFileExt(footprintString)

if (fileHandlers[fileExtension].loadFromUrl) {
// queue async effect for async footprint loading using fileHandler[fileExtension].loadFromUrl(footprintString)
}
}
const isUrl = isThisUrl(footprintString)

if (isUrl) {
const fileExtension = getFileExt(footprintString)

if (fileHandlers[fileExtension].loadFromUrl) {
// queue async effect for async footprint loading using fileHandler[fileExtension].loadFromUrl(footprintString)
}
}

Did you find this page helpful?