1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-11-25 03:34:05 +00:00

moved clipboard, jszip, FileSaver libs to import(), fixed embed

This commit is contained in:
Steven Hugg 2021-08-03 12:13:59 -05:00
parent e00819da59
commit a1e2e2aafc
10 changed files with 64 additions and 98 deletions

View File

@ -377,7 +377,6 @@ body {
<!-- UI-only stuff -->
<link rel="stylesheet" href="lib/bootstrap-tourist.css">
<script src="lib/bootstrap-tourist.js"></script>
<script src="lib/FileSaver.min.js"></script>
<script src="lib/octokat.js"></script>
<script src="tss/js/tss/PsgDeviceChannel.js"></script>

View File

@ -57,7 +57,6 @@ if (window.location.host.endsWith('8bitworkshop.com')) {
<script src="javatari.js/release/javatari/javatari.js"></script>
<script src="src/common/cpu/6809.js"></script>
<script src="lib/FileSaver.min.js"></script>
<script src="tss/js/tss/PsgDeviceChannel.js"></script>
<script src="tss/js/tss/MasterChannel.js"></script>

View File

@ -561,7 +561,6 @@ if (window.location.host.endsWith('8bitworkshop.com')) {
<!-- UI-only stuff -->
<link rel="stylesheet" href="lib/bootstrap-tourist.css">
<script src="lib/bootstrap-tourist.js"></script>
<script src="lib/FileSaver.min.js"></script>
<script src="lib/octokat.js"></script>
<script src="tss/js/tss/PsgDeviceChannel.js"></script>

View File

@ -1,3 +0,0 @@
(function(a,b){if("function"==typeof define&&define.amd)define([],b);else if("undefined"!=typeof exports)b();else{b(),a.FileSaver={exports:{}}.exports}})(this,function(){"use strict";function b(a,b){return"undefined"==typeof b?b={autoBom:!1}:"object"!=typeof b&&(console.warn("Deprecated: Expected third argument to be a object"),b={autoBom:!b}),b.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(a.type)?new Blob(["\uFEFF",a],{type:a.type}):a}function c(a,b,c){var d=new XMLHttpRequest;d.open("GET",a),d.responseType="blob",d.onload=function(){g(d.response,b,c)},d.onerror=function(){console.error("could not download file")},d.send()}function d(a){var b=new XMLHttpRequest;b.open("HEAD",a,!1);try{b.send()}catch(a){}return 200<=b.status&&299>=b.status}function e(a){try{a.dispatchEvent(new MouseEvent("click"))}catch(c){var b=document.createEvent("MouseEvents");b.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),a.dispatchEvent(b)}}var f="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof global&&global.global===global?global:void 0,a=f.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),g=f.saveAs||("object"!=typeof window||window!==f?function(){}:"download"in HTMLAnchorElement.prototype&&!a?function(b,g,h){var i=f.URL||f.webkitURL,j=document.createElement("a");g=g||b.name||"download",j.download=g,j.rel="noopener","string"==typeof b?(j.href=b,j.origin===location.origin?e(j):d(j.href)?c(b,g,h):e(j,j.target="_blank")):(j.href=i.createObjectURL(b),setTimeout(function(){i.revokeObjectURL(j.href)},4E4),setTimeout(function(){e(j)},0))}:"msSaveOrOpenBlob"in navigator?function(f,g,h){if(g=g||f.name||"download","string"!=typeof f)navigator.msSaveOrOpenBlob(b(f,h),g);else if(d(f))c(f,g,h);else{var i=document.createElement("a");i.href=f,i.target="_blank",setTimeout(function(){e(i)})}}:function(b,d,e,g){if(g=g||open("","_blank"),g&&(g.document.title=g.document.body.innerText="downloading..."),"string"==typeof b)return c(b,d,e);var h="application/octet-stream"===b.type,i=/constructor/i.test(f.HTMLElement)||f.safari,j=/CriOS\/[\d]+/.test(navigator.userAgent);if((j||h&&i||a)&&"undefined"!=typeof FileReader){var k=new FileReader;k.onloadend=function(){var a=k.result;a=j?a:a.replace(/^data:[^;]*;/,"data:attachment/file;"),g?g.location.href=a:location=a,g=null},k.readAsDataURL(b)}else{var l=f.URL||f.webkitURL,m=l.createObjectURL(b);g?g.location=m:location.href=m,g=null,setTimeout(function(){l.revokeObjectURL(m)},4E4)}});f.saveAs=g.saveAs=g,"undefined"!=typeof module&&(module.exports=g)});
//# sourceMappingURL=FileSaver.min.js.map

File diff suppressed because one or more lines are too long

13
lib/jszip.min.js vendored

File diff suppressed because one or more lines are too long

56
package-lock.json generated
View File

@ -14,7 +14,9 @@
"@wasmer/wasmfs": "^0.12.0",
"binaryen": "^101.0.0",
"chokidar": "^3.5.0",
"clipboard": "^2.0.6",
"jquery": "^3.6.0",
"jszip": "^3.7.0",
"localforage": "^1.9.0",
"mousetrap": "^1.6.5",
"reflect-metadata": "^0.1.13",
@ -24,7 +26,7 @@
"devDependencies": {
"@types/bootbox": "^5.1.3",
"@types/bootstrap": "^3.4.0",
"@types/file-saver": "^2.0.1",
"@types/file-saver": "^2.0.3",
"@types/jquery": "^3.5.5",
"@types/node": "^14.14.20",
"atob": "^2.1.x",
@ -32,7 +34,6 @@
"bootstrap-tourist": "^0.2.1",
"btoa": "^1.2.x",
"chromedriver": "^92.0.0",
"clipboard": "^2.0.6",
"command-exists": "^1.2.9",
"electron": "^9.4.0",
"electron-builder": "^22.11.7",
@ -42,7 +43,6 @@
"heapdump": "^0.3.15",
"jsdom": "^12.2.0",
"jsfuzz": "^1.0.14",
"jszip": "^3.5.0",
"lzg": "^1.0.x",
"mocha": "^7.2.0",
"mocha-simple-html-reporter": "^2.0.0",
@ -686,8 +686,9 @@
"dev": true
},
"node_modules/@types/file-saver": {
"version": "2.0.2",
"integrity": "sha512-xbqnZmGrCEqi/KUzOkeUSe77p7APvLuyellGaAoeww3CHJ1AbjQWjPSCFtKIzZn8L7LpEax4NXnC+gfa6nM7IA==",
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/@types/file-saver/-/file-saver-2.0.3.tgz",
"integrity": "sha512-MBIou8pd/41jkff7s97B47bc9+p0BszqqDJsO51yDm49uUxeKzrfuNl5fSLC6BpLEWKA8zlwyqALVmXrFwoBHQ==",
"dev": true
},
"node_modules/@types/fs-extra": {
@ -2053,7 +2054,6 @@
"node_modules/clipboard": {
"version": "2.0.8",
"integrity": "sha512-Y6WO0unAIQp5bLmk1zdThRhgJt/x3ks6f30s3oE3H1mgIEU33XyQjEf8gsf6DxC7NPX8Y1SsNWjUjL/ywLnnbQ==",
"dev": true,
"dependencies": {
"good-listener": "^1.2.2",
"select": "^1.1.2",
@ -2525,8 +2525,7 @@
},
"node_modules/delegate": {
"version": "3.2.0",
"integrity": "sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw==",
"dev": true
"integrity": "sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw=="
},
"node_modules/depd": {
"version": "1.1.2",
@ -4229,7 +4228,6 @@
"node_modules/good-listener": {
"version": "1.2.2",
"integrity": "sha1-1TswzfkxPf+33JoNR3CWqm0UXFA=",
"dev": true,
"dependencies": {
"delegate": "^3.1.2"
}
@ -5296,9 +5294,9 @@
}
},
"node_modules/jszip": {
"version": "3.6.0",
"integrity": "sha512-jgnQoG9LKnWO3mnVNBnfhkh0QknICd1FGSrXcgrl67zioyJ4wgx25o9ZqwNtrROSflGBCGYnJfjrIyRIby1OoQ==",
"dev": true,
"version": "3.7.0",
"resolved": "https://registry.npmjs.org/jszip/-/jszip-3.7.0.tgz",
"integrity": "sha512-Y2OlFIzrDOPWUnpU0LORIcDn2xN7rC9yKffFM/7pGhQuhO+SUhfm2trkJ/S5amjFvem0Y+1EALz/MEPkvHXVNw==",
"dependencies": {
"lie": "~3.3.0",
"pako": "~1.0.2",
@ -5352,7 +5350,6 @@
"node_modules/lie": {
"version": "3.3.0",
"integrity": "sha512-UaiMJzeWRlEujzAuw5LokY1L5ecNQYZKfmyZ9L7wDHb/p5etKaxXhohBcrw0EYby+G/NA52vRSN4N39dxHAIwQ==",
"dev": true,
"dependencies": {
"immediate": "~3.0.5"
}
@ -7692,8 +7689,7 @@
},
"node_modules/select": {
"version": "1.1.2",
"integrity": "sha1-DnNQrN7ICxEIUoeG7B1EGNEbOW0=",
"dev": true
"integrity": "sha1-DnNQrN7ICxEIUoeG7B1EGNEbOW0="
},
"node_modules/semver": {
"version": "6.3.0",
@ -7751,7 +7747,6 @@
"node_modules/set-immediate-shim": {
"version": "1.0.1",
"integrity": "sha1-SysbJ+uAip+NzEgaWOXlb1mfP2E=",
"dev": true,
"engines": {
"node": ">=0.10.0"
}
@ -8259,8 +8254,7 @@
},
"node_modules/tiny-emitter": {
"version": "2.1.0",
"integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==",
"dev": true
"integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q=="
},
"node_modules/tmp": {
"version": "0.2.1",
@ -9691,8 +9685,9 @@
"dev": true
},
"@types/file-saver": {
"version": "2.0.2",
"integrity": "sha512-xbqnZmGrCEqi/KUzOkeUSe77p7APvLuyellGaAoeww3CHJ1AbjQWjPSCFtKIzZn8L7LpEax4NXnC+gfa6nM7IA==",
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/@types/file-saver/-/file-saver-2.0.3.tgz",
"integrity": "sha512-MBIou8pd/41jkff7s97B47bc9+p0BszqqDJsO51yDm49uUxeKzrfuNl5fSLC6BpLEWKA8zlwyqALVmXrFwoBHQ==",
"dev": true
},
"@types/fs-extra": {
@ -10726,7 +10721,6 @@
"clipboard": {
"version": "2.0.8",
"integrity": "sha512-Y6WO0unAIQp5bLmk1zdThRhgJt/x3ks6f30s3oE3H1mgIEU33XyQjEf8gsf6DxC7NPX8Y1SsNWjUjL/ywLnnbQ==",
"dev": true,
"requires": {
"good-listener": "^1.2.2",
"select": "^1.1.2",
@ -11104,8 +11098,7 @@
},
"delegate": {
"version": "3.2.0",
"integrity": "sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw==",
"dev": true
"integrity": "sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw=="
},
"depd": {
"version": "1.1.2",
@ -12416,7 +12409,6 @@
"good-listener": {
"version": "1.2.2",
"integrity": "sha1-1TswzfkxPf+33JoNR3CWqm0UXFA=",
"dev": true,
"requires": {
"delegate": "^3.1.2"
}
@ -13178,9 +13170,9 @@
}
},
"jszip": {
"version": "3.6.0",
"integrity": "sha512-jgnQoG9LKnWO3mnVNBnfhkh0QknICd1FGSrXcgrl67zioyJ4wgx25o9ZqwNtrROSflGBCGYnJfjrIyRIby1OoQ==",
"dev": true,
"version": "3.7.0",
"resolved": "https://registry.npmjs.org/jszip/-/jszip-3.7.0.tgz",
"integrity": "sha512-Y2OlFIzrDOPWUnpU0LORIcDn2xN7rC9yKffFM/7pGhQuhO+SUhfm2trkJ/S5amjFvem0Y+1EALz/MEPkvHXVNw==",
"requires": {
"lie": "~3.3.0",
"pako": "~1.0.2",
@ -13225,7 +13217,6 @@
"lie": {
"version": "3.3.0",
"integrity": "sha512-UaiMJzeWRlEujzAuw5LokY1L5ecNQYZKfmyZ9L7wDHb/p5etKaxXhohBcrw0EYby+G/NA52vRSN4N39dxHAIwQ==",
"dev": true,
"requires": {
"immediate": "~3.0.5"
}
@ -15040,8 +15031,7 @@
},
"select": {
"version": "1.1.2",
"integrity": "sha1-DnNQrN7ICxEIUoeG7B1EGNEbOW0=",
"dev": true
"integrity": "sha1-DnNQrN7ICxEIUoeG7B1EGNEbOW0="
},
"semver": {
"version": "6.3.0",
@ -15082,8 +15072,7 @@
},
"set-immediate-shim": {
"version": "1.0.1",
"integrity": "sha1-SysbJ+uAip+NzEgaWOXlb1mfP2E=",
"dev": true
"integrity": "sha1-SysbJ+uAip+NzEgaWOXlb1mfP2E="
},
"setprototypeof": {
"version": "1.1.1",
@ -15487,8 +15476,7 @@
},
"tiny-emitter": {
"version": "2.1.0",
"integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==",
"dev": true
"integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q=="
},
"tmp": {
"version": "0.2.1",

View File

@ -16,7 +16,9 @@
"@wasmer/wasmfs": "^0.12.0",
"binaryen": "^101.0.0",
"chokidar": "^3.5.0",
"clipboard": "^2.0.6",
"jquery": "^3.6.0",
"jszip": "^3.7.0",
"localforage": "^1.9.0",
"mousetrap": "^1.6.5",
"reflect-metadata": "^0.1.13",
@ -26,7 +28,7 @@
"devDependencies": {
"@types/bootbox": "^5.1.3",
"@types/bootstrap": "^3.4.0",
"@types/file-saver": "^2.0.1",
"@types/file-saver": "^2.0.3",
"@types/jquery": "^3.5.5",
"@types/node": "^14.14.20",
"atob": "^2.1.x",
@ -34,7 +36,6 @@
"bootstrap-tourist": "^0.2.1",
"btoa": "^1.2.x",
"chromedriver": "^92.0.0",
"clipboard": "^2.0.6",
"command-exists": "^1.2.9",
"electron": "^9.4.0",
"electron-builder": "^22.11.7",
@ -44,7 +45,6 @@
"heapdump": "^0.3.15",
"jsdom": "^12.2.0",
"jsfuzz": "^1.0.14",
"jszip": "^3.5.0",
"lzg": "^1.0.x",
"mocha": "^7.2.0",
"mocha-simple-html-reporter": "^2.0.0",

View File

@ -1,6 +1,7 @@
window['Javatari'].AUTO_START = false;
import { lzgmini } from "../common/util";
import { PLATFORMS } from "../common/emu";
import { Platform } from "../common/baseplatform";
import { stringToByteArray, getWithBinary, loadScript, getRootBasePlatform } from "../common/util";
@ -12,7 +13,7 @@ export var platform : Platform; // platform object
export var stateRecorder : StateRecorderImpl;
// external libs (TODO)
declare var ga, lzgmini, GIF, saveAs;
declare var ga, GIF;
var _qs = (function (a) {
if (!a || a.length == 0)

View File

@ -16,7 +16,7 @@ import Split = require('split.js');
import { importPlatform } from "../platform/_index";
// external libs (TODO)
declare var Tour, GIF, saveAs, JSZip, firebase;
declare var Tour, GIF, firebase;
declare var ga;
// in index.html
declare var exports;
@ -855,8 +855,10 @@ function _shareEmbedLink(e) {
}
function loadClipboardLibrary() {
loadScript('lib/clipboard.min.js').then( () => {
var ClipboardJS = exports['ClipboardJS'];
// can happen in background because it won't be used until user clicks
console.log('clipboard');
import('clipboard').then( (clipmod) => {
let ClipboardJS = clipmod.default;
new ClipboardJS(".btn");
});
}
@ -1045,40 +1047,41 @@ function _downloadSourceFile(e) {
saveAs(blob, getCurrentEditorFilename(), {autoBom:false});
}
function _downloadProjectZipFile(e) {
loadScript('lib/jszip.min.js').then( () => {
var zip = new JSZip();
current_project.iterateFiles( (id, data) => {
if (data) {
zip.file(getFilenameForPath(id), data);
}
});
zip.generateAsync({type:"blob"}).then( (content) => {
saveAs(content, getCurrentMainFilename() + "-" + getBasePlatform(platform_id) + ".zip");
});
async function newJSZip() {
let JSZip = (await import('jszip')).default;
return new JSZip();
}
async function _downloadProjectZipFile(e) {
var zip = await newJSZip();
current_project.iterateFiles( (id, data) => {
if (data) {
zip.file(getFilenameForPath(id), data);
}
});
zip.generateAsync({type:"blob"}).then( (content) => {
saveAs(content, getCurrentMainFilename() + "-" + getBasePlatform(platform_id) + ".zip");
});
}
function _downloadAllFilesZipFile(e) {
loadScript('lib/jszip.min.js').then( () => {
var zip = new JSZip();
store.keys( (err, keys : string[]) => {
setWaitDialog(true);
var i = 0;
return Promise.all(keys.map( (path) => {
return store.getItem(path).then( (text) => {
setWaitProgress(i++/(keys.length+1));
if (text) {
zip.file(path, text);
}
});
})).then(() => {
return zip.generateAsync({type:"blob"});
}).then( (content) => {
return saveAs(content, getBasePlatform(platform_id) + "-all.zip");
}).finally(() => setWaitDialog(false));
});
})
async function _downloadAllFilesZipFile(e) {
var zip = await newJSZip();
store.keys( (err, keys : string[]) => {
setWaitDialog(true);
var i = 0;
return Promise.all(keys.map( (path) => {
return store.getItem(path).then( (text) => {
setWaitProgress(i++/(keys.length+1));
if (text) {
zip.file(path, text as any);
}
});
})).then(() => {
return zip.generateAsync({type:"blob"});
}).then( (content) => {
return saveAs(content, getBasePlatform(platform_id) + "-all.zip");
}).finally(() => setWaitDialog(false));
});
}
function populateExamples(sel) {