1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-11-28 08:50:22 +00:00

fixed saveAs; more async usage; importURL ignores if embed=1/ignore=1

This commit is contained in:
Steven Hugg 2021-08-06 11:51:40 -05:00
parent 42f3febb29
commit 79b1d8ba4b
4 changed files with 52 additions and 59 deletions

46
package-lock.json generated
View File

@ -15,10 +15,12 @@
"binaryen": "^101.0.0",
"chokidar": "^3.5.0",
"clipboard": "^2.0.6",
"file-saver": "^2.0.5",
"jquery": "^3.6.0",
"jszip": "^3.7.0",
"localforage": "^1.9.0",
"mousetrap": "^1.6.5",
"octokat": "^0.10.0",
"reflect-metadata": "^0.1.13",
"split.js": "^1.6.2",
"update-electron-app": "^2.0.1"
@ -39,7 +41,6 @@
"electron-builder": "^22.11.7",
"electron-packager": "^15.2.0",
"esbuild": "^0.12.16",
"file-saver": "^2.0.5",
"heapdump": "^0.3.15",
"jsdom": "^12.2.0",
"jsfuzz": "^1.0.14",
@ -47,7 +48,6 @@
"mocha": "^7.2.0",
"mocha-simple-html-reporter": "^2.0.0",
"nightwatch": "^1.6.4",
"octokat": "^0.10.0",
"pngjs": "^3.4.0",
"rgbquant": "^1.1.2",
"typedoc": "^0.21.0",
@ -3370,7 +3370,6 @@
"node_modules/encoding": {
"version": "0.1.13",
"integrity": "sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==",
"dev": true,
"dependencies": {
"iconv-lite": "^0.6.2"
}
@ -3378,7 +3377,6 @@
"node_modules/encoding/node_modules/iconv-lite": {
"version": "0.6.3",
"integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==",
"dev": true,
"dependencies": {
"safer-buffer": ">= 2.1.2 < 3.0.0"
},
@ -3655,7 +3653,6 @@
"node_modules/fetch-vcr": {
"version": "1.1.2",
"integrity": "sha512-bFOx3+5YtViximcqhG05tqMlsyPRXNOmiToDCf6TyVUCKHYP/vGPmn0HUhGVNd1jI0KpElwz+RH3X/ZQo0Asfg==",
"dev": true,
"dependencies": {
"node-fetch": "^1.6.3",
"whatwg-fetch": "^2.0.3"
@ -3664,7 +3661,6 @@
"node_modules/fetch-vcr/node_modules/node-fetch": {
"version": "1.7.3",
"integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==",
"dev": true,
"dependencies": {
"encoding": "^0.1.11",
"is-stream": "^1.0.1"
@ -3672,8 +3668,7 @@
},
"node_modules/file-saver": {
"version": "2.0.5",
"integrity": "sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA==",
"dev": true
"integrity": "sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA=="
},
"node_modules/file-uri-to-path": {
"version": "2.0.0",
@ -4852,7 +4847,6 @@
"node_modules/is-stream": {
"version": "1.1.0",
"integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=",
"dev": true,
"engines": {
"node": ">=0.10.0"
}
@ -5404,8 +5398,7 @@
},
"node_modules/lodash": {
"version": "4.17.21",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
"devOptional": true
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
},
"node_modules/lodash._arraycopy": {
"version": "3.0.0",
@ -6301,7 +6294,6 @@
"node_modules/node-fetch": {
"version": "2.6.1",
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==",
"dev": true,
"engines": {
"node": "4.x || >=6.0.0"
}
@ -6563,7 +6555,6 @@
"node_modules/octokat": {
"version": "0.10.0",
"integrity": "sha512-VJ21L1gMlByYMurduLYiOcI8AwlZkUV8OXRN8pMXsbkIqIVqn0tgdTfxzWM9spX4VJTTG02OgqwDTqQsOmDing==",
"dev": true,
"dependencies": {
"fetch-vcr": "^1.1.0",
"lodash": "^4.16.4",
@ -7660,8 +7651,7 @@
},
"node_modules/safer-buffer": {
"version": "2.1.2",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
"dev": true
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
},
"node_modules/sanitize-filename": {
"version": "1.6.3",
@ -8776,8 +8766,7 @@
},
"node_modules/whatwg-fetch": {
"version": "2.0.4",
"integrity": "sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng==",
"dev": true
"integrity": "sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng=="
},
"node_modules/whatwg-mimetype": {
"version": "2.3.0",
@ -11746,7 +11735,6 @@
"encoding": {
"version": "0.1.13",
"integrity": "sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==",
"dev": true,
"requires": {
"iconv-lite": "^0.6.2"
},
@ -11754,7 +11742,6 @@
"iconv-lite": {
"version": "0.6.3",
"integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==",
"dev": true,
"requires": {
"safer-buffer": ">= 2.1.2 < 3.0.0"
}
@ -11956,7 +11943,6 @@
"fetch-vcr": {
"version": "1.1.2",
"integrity": "sha512-bFOx3+5YtViximcqhG05tqMlsyPRXNOmiToDCf6TyVUCKHYP/vGPmn0HUhGVNd1jI0KpElwz+RH3X/ZQo0Asfg==",
"dev": true,
"requires": {
"node-fetch": "^1.6.3",
"whatwg-fetch": "^2.0.3"
@ -11965,7 +11951,6 @@
"node-fetch": {
"version": "1.7.3",
"integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==",
"dev": true,
"requires": {
"encoding": "^0.1.11",
"is-stream": "^1.0.1"
@ -11975,8 +11960,7 @@
},
"file-saver": {
"version": "2.0.5",
"integrity": "sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA==",
"dev": true
"integrity": "sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA=="
},
"file-uri-to-path": {
"version": "2.0.0",
@ -12823,8 +12807,7 @@
},
"is-stream": {
"version": "1.1.0",
"integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=",
"dev": true
"integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ="
},
"is-string": {
"version": "1.0.6",
@ -13266,8 +13249,7 @@
},
"lodash": {
"version": "4.17.21",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
"devOptional": true
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
},
"lodash._arraycopy": {
"version": "3.0.0",
@ -13993,8 +13975,7 @@
},
"node-fetch": {
"version": "2.6.1",
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==",
"dev": true
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
},
"normalize-package-data": {
"version": "2.5.0",
@ -14194,7 +14175,6 @@
"octokat": {
"version": "0.10.0",
"integrity": "sha512-VJ21L1gMlByYMurduLYiOcI8AwlZkUV8OXRN8pMXsbkIqIVqn0tgdTfxzWM9spX4VJTTG02OgqwDTqQsOmDing==",
"dev": true,
"requires": {
"fetch-vcr": "^1.1.0",
"lodash": "^4.16.4",
@ -15005,8 +14985,7 @@
},
"safer-buffer": {
"version": "2.1.2",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
"dev": true
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
},
"sanitize-filename": {
"version": "1.6.3",
@ -15863,8 +15842,7 @@
},
"whatwg-fetch": {
"version": "2.0.4",
"integrity": "sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng==",
"dev": true
"integrity": "sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng=="
},
"whatwg-mimetype": {
"version": "2.3.0",

View File

@ -17,6 +17,7 @@
"binaryen": "^101.0.0",
"chokidar": "^3.5.0",
"clipboard": "^2.0.6",
"file-saver": "^2.0.5",
"jquery": "^3.6.0",
"jszip": "^3.7.0",
"localforage": "^1.9.0",
@ -42,7 +43,6 @@
"electron-builder": "^22.11.7",
"electron-packager": "^15.2.0",
"esbuild": "^0.12.16",
"file-saver": "^2.0.5",
"heapdump": "^0.3.15",
"jsdom": "^12.2.0",
"jsfuzz": "^1.0.14",

View File

@ -18,6 +18,7 @@ import { AddressHeatMapView, BinaryFileView, MemoryMapView, MemoryView, ProbeLog
import { AssetEditorView } from "./views/asseteditor";
import { isMobileDevice } from "./views/baseviews";
import { CallStackView, DebugBrowserView } from "./views/treeviews";
import { saveAs } from "file-saver";
// external libs (TODO)
declare var Tour, GIF;
@ -1131,22 +1132,23 @@ async function _downloadProjectZipFile(e) {
async function _downloadAllFilesZipFile(e) {
var zip = await newJSZip();
store.keys( (err, keys : string[]) => {
setWaitDialog(true);
var keys = await store.keys();
setWaitDialog(true);
try {
var i = 0;
return Promise.all(keys.map( (path) => {
await 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));
});
}));
var content = await zip.generateAsync({type:"blob"});
saveAs(content, getBasePlatform(platform_id) + "-all.zip");
} finally {
setWaitDialog(false);
}
}
function populateExamples(sel) {
@ -2287,26 +2289,27 @@ export function setupSplits() {
function loadImportedURL(url : string) {
// TODO: zip file?
const ignore = parseBool(qs.ignore) || isEmbed;
setWaitDialog(true);
getWithBinary(url, (data) => {
getWithBinary(url, async (data) => {
if (data) {
var path = 'shared/' + getFilenameForPath(url);
var path = getFilenameForPath(url);
console.log("Importing " + data.length + " bytes as " + path);
store.getItem(path, (err, olddata) => {
try {
var olddata = await store.getItem(path);
setWaitDialog(false);
if (!olddata || confirm("Replace existing file '" + path + "'?")) {
store.setItem(path, data, (err, result) => {
if (err)
alert(err+""); // need to wait
if (result != null) {
delete qs.importURL;
qs.file = path;
replaceURLState();
loadAndStartPlatform();
}
});
if (olddata != null && ignore) {
// ignore=1, do nothing
} else if (olddata == null || confirm("Replace existing file '" + path + "'?")) {
await store.setItem(path, data);
}
});
delete qs.importURL;
qs.file = path;
replaceURLState();
loadAndStartPlatform();
} finally {
setWaitDialog(false);
}
} else {
alertError("Could not load source code from URL: " + url);
setWaitDialog(false);

View File

@ -40,6 +40,18 @@ exports['test embed IDE in iframe'] = function(browser) {
.waitForElementVisible('#emuscreen')
.waitForElementVisible('.emuvideo')
browser.url(IDEURL + "?embed=1&platform=c64&importURL=/presets/c64/hello.dasm")
.waitForElementNotVisible('#compile_spinner', time=10000)
.waitForElementNotVisible('#error_alert')
.waitForElementVisible('#emuscreen')
.waitForElementVisible('.emuvideo')
browser.url(IDEURL + "?embed=1&platform=c64&importURL=/presets/c64/hello.dasm")
.waitForElementNotVisible('#compile_spinner', time=10000)
.waitForElementNotVisible('#error_alert')
.waitForElementVisible('#emuscreen')
.waitForElementVisible('.emuvideo')
browser.url(IDEURL + "?embed=1")
.waitForElementVisible('.bootbox-alert')