stub in zip library

This commit is contained in:
Stewart Allen 2021-02-01 16:39:22 -05:00
commit bab0a13a14
6 changed files with 31 additions and 2 deletions

View file

@ -15,7 +15,9 @@ let KIRI = self.kiri = self.kiri || {},
syncd = {},
running = {},
slicing = {},
worker = null;
worker = null
// occ = new Worker("/kiri/ext/occ-worker.js", {type:"module"}),
;
/**
* @param {Function} fn name of function in KIRI.worker
@ -243,6 +245,12 @@ KIRI.work = {
output(reply.done);
}
}, [ data.png ]);
},
zip: function(files) {
send("zip", {files}, reply => {
console.log({zip_said: reply});
});
}
};

View file

@ -536,6 +536,24 @@ KIRI.worker = {
// send.done({done: {verts, faces, bigv, vi, ii}}, [ bigv.buffer ]);
send.done({done: {bigv}}, [ bigv.buffer ]);
});
},
zip: function(data, send) {
let { files } = data;
let zip = new JSZip();
for (let file of files) {
zip.file(file.name, file.data);
}
zip.generateAsync({
type: "uint8array",
compression: "DEFLATE",
compressionOptions: { level: 3 },
streamFiles: true
}, progress => {
send.data(progress);
}).then(output => {
send.done(output);
});
}
};