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

View File

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

View File

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

View File

@ -40,6 +40,18 @@ exports['test embed IDE in iframe'] = function(browser) {
.waitForElementVisible('#emuscreen') .waitForElementVisible('#emuscreen')
.waitForElementVisible('.emuvideo') .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") browser.url(IDEURL + "?embed=1")
.waitForElementVisible('.bootbox-alert') .waitForElementVisible('.bootbox-alert')