chinchang / chinchang/web-maker

Provide "copy as base64" option in uploaded assets

Open
#560 9 comments 0 reactions 1 assignee Claimed by @chinchang View on GitHub
enhancement
Dominant language
JavaScript
Stars
2.7k
Forks
323
PR merge metrics
No merged PRs in 30d

Description

Yes, I'd be looking for at a minimum images to be inlined; Kaboom does accept base64 strings in loadSprite and that is how I was using the npm inlining package to do so. I don't know how you've currently got Web Maker set up to inline its javascript when downloading a Web Maker project, but the inlining package I use (and I think most of the npm inlining packages I looked at) automatically converts src attributes for css, js, and img tags to base 64. I would then do:
```
loadSprite("bean", document.getElementByID('idOfImgSource').src)
```
or something similar.

If Web Maker converted html audio tags that would be a bonus and could loadSound() similarly.

Alternatively, if Web Maker somehow just converted any Asset I uploaded to a base64 dataURL (perhaps by identifying the proper daraURL format by the uploaded file's extension?) and then let me know how I could access the dataURL in the javascript section of my Web Maker project that even be a better solution (e.g.: upload oceanSounds.wav to Web Maker 'assets' and then access that sound file by inserting an alias like dataURLoceanSounds into a function by writing something like:
```
loadSound("ocean", dataURLoceanSounds)
```
A Web Maker user could then load other Assets into Kaboom the same way and use it to upload Assets into projects containing non-Kaboom libraries to be inlined in other Web Maker projects.

PS,

On a related request, would you also consider (perhaps in 'settings') enabling an option to inline the kaboom.js engine itsel into the downloaded single-file html instead of a http: url to download the kaboom.engine? Would enlarge the size of the download single-file html but enables Web Maker to be my 'one' IDE to create web apps that don't require any internet connection at all to run.

😊

_Originally posted by @SugarRayLua in https://github.com/chinchang/web-maker/issues/554#issuecomment-2100770608_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.