Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

Feature Request: Download manual file from CDN #3

Open
jonlepage opened this issue Apr 12, 2019 · 1 comment
Open

Feature Request: Download manual file from CDN #3

jonlepage opened this issue Apr 12, 2019 · 1 comment
Labels
enhancement New feature or request

Comments

@jonlepage
Copy link

jonlepage commented Apr 12, 2019

Download pixijs pack by promise and GZIP packerer
Some people want manual download
you just need to sync the selected link in the build and found a way to add in the array pixiJSbuild

var Promise = window.Promise;
function multiImport(modules) {
  return Promise.all(modules.map(function(m) {
    return import('https://unsafe-production.jspm.io/' + (m.name?m.name:m))
        .then(({default: module}) => ([(m.varName ? m.varName : m), module]))}))
        .then((modules) => {
            let mods = {};
            modules.forEach((mod) => mods[mod[0]] = mod[1]);
            return mods
         });
}

multiImport(
    [
        { name: "file-saver" , varName: "fileSaver"  },
        { name: "jszip"      , varName: "JSZip"      },
        { name: "jszip-utils", varName: "JSZipUtils" }
    ])
    .then((modules) => {
        const JSZip = modules.JSZip;
        const JSZipUtils = modules.JSZipUtils;
        const saveAs = modules.fileSaver.saveAs;
        const zip = new JSZip();
        // store here the selected js files
        const pixiJSbuild = [
            "https://pixijs.download/dev/packages/prepare.min.js",
            "https://pixijs.download/dev/packages/settings.min.js",
            "https://pixijs.download/dev/packages/mesh.min.js",
        ];
        pixiJSbuild.forEach(url=>{
            zip.file(url.replace(/.*\//, ""), new Promise((resolve, reject) => JSZipUtils.getBinaryContent(url, (err, data) => (err) ? reject(err) : resolve(String.fromCharCode.apply(null, new Uint8Array(data))))))
        });
        zip.generateAsync({type:"blob"}).then((pixiZip) => saveAs(pixiZip, "pixiJS.zip"), (e) => console.log(e));
   });
@bigtimebuddy bigtimebuddy added the enhancement New feature or request label Apr 12, 2019
@bigtimebuddy
Copy link
Contributor

Good idea, thanks @djmisterjon.

@bigtimebuddy bigtimebuddy changed the title download manual file from CDN Feature Request: Download manual file from CDN Apr 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants