mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-06-03 19:29:32 +00:00
refactoring: UIQueryString UserPrefs, moved createNewPersistentStore, es2017, fixed tests, style changes for embed
This commit is contained in:
parent
ef01639a06
commit
8f6432f0d4
|
@ -225,7 +225,7 @@ if (window.location.host.endsWith('8bitworkshop.com')) {
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<img id="compile_spinner" src="images/spinner.gif" style="visibility:hidden;margin-left:8px;margin-right:8px;height:2em">
|
<img id="compile_spinner" src="images/spinner.gif" style="visibility:hidden;margin-left:8px;margin-right:8px;height:2em">
|
||||||
<span id="toolbar" class="hidden-xs"></span>
|
<span id="toolbar"></span>
|
||||||
<span class="btn_group view_group hidden-sm hidden-xs" id="speed_bar" style="display:none">
|
<span class="btn_group view_group hidden-sm hidden-xs" id="speed_bar" style="display:none">
|
||||||
<button id="dbg_slowest" class="btn" title="Slowest"><span class="glyphicon glyphicon-fast-backward" aria-hidden="true"></span></button>
|
<button id="dbg_slowest" class="btn" title="Slowest"><span class="glyphicon glyphicon-fast-backward" aria-hidden="true"></span></button>
|
||||||
<button id="dbg_slower" class="btn" title="Slower"><span class="glyphicon glyphicon-backward" aria-hidden="true"></span></button>
|
<button id="dbg_slower" class="btn" title="Slower"><span class="glyphicon glyphicon-backward" aria-hidden="true"></span></button>
|
||||||
|
@ -271,7 +271,7 @@ if (window.location.host.endsWith('8bitworkshop.com')) {
|
||||||
</ul>
|
</ul>
|
||||||
</span>
|
</span>
|
||||||
<!-- 8bitworkshop logo -->
|
<!-- 8bitworkshop logo -->
|
||||||
<span class="logo-gradient hidden-xs pull-right" style="margin-left:auto" onclick="window.open('/','_8bitws');">8bitworkshop</span>
|
<span class="logo-gradient pull-right" style="margin-left:auto" onclick="window.open('https://8bitworkshop.com/','_8bitws');">8bitworkshop</span>
|
||||||
</div><!-- controls_dynamic -->
|
</div><!-- controls_dynamic -->
|
||||||
</div><!-- controls_top -->
|
</div><!-- controls_top -->
|
||||||
|
|
||||||
|
|
|
@ -239,7 +239,7 @@ export class AnimationTimer {
|
||||||
running : boolean = false;
|
running : boolean = false;
|
||||||
pulsing : boolean = false;
|
pulsing : boolean = false;
|
||||||
lastts = 0;
|
lastts = 0;
|
||||||
useReqAnimFrame = true; // may be deactivated in browers?
|
useReqAnimFrame = typeof window.requestAnimationFrame === 'function'; // need for unit test
|
||||||
nframes;
|
nframes;
|
||||||
startts; // for FPS calc
|
startts; // for FPS calc
|
||||||
frameRate;
|
frameRate;
|
||||||
|
|
|
@ -516,3 +516,25 @@ export function loadScript(scriptfn:string) : Promise<Event> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function decodeQueryString(qs : string) : {} {
|
||||||
|
if (qs.startsWith('?')) qs = qs.substr(1);
|
||||||
|
var a = qs.split('&');
|
||||||
|
if (!a || a.length == 0)
|
||||||
|
return {};
|
||||||
|
var b = {};
|
||||||
|
for (var i = 0; i < a.length; ++i) {
|
||||||
|
var p = a[i].split('=', 2);
|
||||||
|
if (p.length == 1)
|
||||||
|
b[p[0]] = "";
|
||||||
|
else
|
||||||
|
b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
|
||||||
|
}
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function parseBool(s : string) : boolean {
|
||||||
|
if (!s) return false;
|
||||||
|
if (s == 'false' || s == '0') return false;
|
||||||
|
if (s == 'true' || s == '1') return true;
|
||||||
|
return s ? true : false;
|
||||||
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
import { FileData, Dependency, SourceLine, SourceFile, CodeListing, CodeListingMap, WorkerError, Segment, WorkerResult } from "../common/workertypes";
|
import { FileData, Dependency, SourceLine, SourceFile, CodeListing, CodeListingMap, WorkerError, Segment, WorkerResult } from "../common/workertypes";
|
||||||
import { getFilenamePrefix, getFolderForPath, isProbablyBinary, getBasePlatform, getWithBinary } from "../common/util";
|
import { getFilenamePrefix, getFolderForPath, isProbablyBinary, getBasePlatform, getWithBinary } from "../common/util";
|
||||||
import { Platform } from "../common/baseplatform";
|
import { Platform } from "../common/baseplatform";
|
||||||
|
import localforage from "localforage";
|
||||||
|
|
||||||
export interface ProjectFilesystem {
|
export interface ProjectFilesystem {
|
||||||
getFileData(path: string) : Promise<FileData>;
|
getFileData(path: string) : Promise<FileData>;
|
||||||
|
@ -411,3 +412,12 @@ export class CodeProject {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function createNewPersistentStore(storeid:string) : LocalForage {
|
||||||
|
var store = localforage.createInstance({
|
||||||
|
name: "__" + storeid,
|
||||||
|
version: 2.0
|
||||||
|
});
|
||||||
|
return store;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
230
src/ide/ui.ts
230
src/ide/ui.ts
|
@ -2,14 +2,14 @@
|
||||||
// 8bitworkshop IDE user interface
|
// 8bitworkshop IDE user interface
|
||||||
|
|
||||||
import * as localforage from "localforage";
|
import * as localforage from "localforage";
|
||||||
import { CodeProject, LocalForageFilesystem, OverlayFilesystem, ProjectFilesystem, WebPresetsFileSystem } from "./project";
|
import { CodeProject, createNewPersistentStore, LocalForageFilesystem, OverlayFilesystem, ProjectFilesystem, WebPresetsFileSystem } from "./project";
|
||||||
import { WorkerResult, WorkerOutput, VerilogOutput, SourceFile, WorkerError, FileData } from "../common/workertypes";
|
import { WorkerResult, WorkerOutput, VerilogOutput, SourceFile, WorkerError, FileData } from "../common/workertypes";
|
||||||
import { ProjectWindows } from "./windows";
|
import { ProjectWindows } from "./windows";
|
||||||
import { Platform, Preset, DebugSymbols, DebugEvalCondition, isDebuggable, EmuState, BasePlatform } from "../common/baseplatform";
|
import { Platform, Preset, DebugSymbols, DebugEvalCondition, isDebuggable, EmuState, BasePlatform } from "../common/baseplatform";
|
||||||
import { PLATFORMS, EmuHalt, Toolbar } from "../common/emu";
|
import { PLATFORMS, EmuHalt, Toolbar } from "../common/emu";
|
||||||
import * as Views from "./views";
|
import * as Views from "./views";
|
||||||
import { getFilenameForPath, getFilenamePrefix, highlightDifferences, invertMap, byteArrayToString, compressLZG, stringToByteArray,
|
import { getFilenameForPath, getFilenamePrefix, highlightDifferences, invertMap, byteArrayToString, compressLZG, stringToByteArray,
|
||||||
byteArrayToUTF8, isProbablyBinary, getWithBinary, getBasePlatform, getRootBasePlatform, hex, loadScript } from "../common/util";
|
byteArrayToUTF8, isProbablyBinary, getWithBinary, getBasePlatform, getRootBasePlatform, hex, loadScript, decodeQueryString, parseBool } from "../common/util";
|
||||||
import { StateRecorderImpl } from "../common/recorder";
|
import { StateRecorderImpl } from "../common/recorder";
|
||||||
import { GHSession, GithubService, getRepos, parseGithubURL, FirebaseProjectFilesystem } from "./services";
|
import { GHSession, GithubService, getRepos, parseGithubURL, FirebaseProjectFilesystem } from "./services";
|
||||||
import Split = require('split.js');
|
import Split = require('split.js');
|
||||||
|
@ -25,6 +25,32 @@ declare var $ : JQueryStatic; // use browser jquery
|
||||||
// make sure VCS doesn't start
|
// make sure VCS doesn't start
|
||||||
if (window['Javatari']) window['Javatari'].AUTO_START = false;
|
if (window['Javatari']) window['Javatari'].AUTO_START = false;
|
||||||
|
|
||||||
|
// query string
|
||||||
|
|
||||||
|
interface UIQueryString {
|
||||||
|
platform? : string;
|
||||||
|
repo? : string;
|
||||||
|
file? : string;
|
||||||
|
electron? : string;
|
||||||
|
importURL? : string;
|
||||||
|
githubURL? : string;
|
||||||
|
localfs? : string;
|
||||||
|
newfile? : string;
|
||||||
|
embed? : string;
|
||||||
|
ignore? : string;
|
||||||
|
force? : string;
|
||||||
|
file0_name? : string;
|
||||||
|
file0_data? : string;
|
||||||
|
file0_type? : string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export var qs : UIQueryString = decodeQueryString(window.location.search||'?') as UIQueryString;
|
||||||
|
|
||||||
|
const isElectron = parseBool(qs.electron);
|
||||||
|
const isEmbed = parseBool(qs.embed);
|
||||||
|
|
||||||
|
/// GLOBALS (TODO: remove)
|
||||||
|
|
||||||
var PRESETS : Preset[]; // presets array
|
var PRESETS : Preset[]; // presets array
|
||||||
|
|
||||||
export var platform_id : string; // platform ID string (platform)
|
export var platform_id : string; // platform ID string (platform)
|
||||||
|
@ -98,19 +124,11 @@ const TOOL_TO_HELPURL = {
|
||||||
'fastbasic': 'https://github.com/dmsc/fastbasic/blob/master/manual.md'
|
'fastbasic': 'https://github.com/dmsc/fastbasic/blob/master/manual.md'
|
||||||
}
|
}
|
||||||
|
|
||||||
function createNewPersistentStore(storeid:string) {
|
|
||||||
var store = localforage.createInstance({
|
|
||||||
name: "__" + storeid,
|
|
||||||
version: 2.0
|
|
||||||
});
|
|
||||||
return store;
|
|
||||||
}
|
|
||||||
|
|
||||||
function gaEvent(category:string, action:string, label?:string, value?:string) {
|
function gaEvent(category:string, action:string, label?:string, value?:string) {
|
||||||
if (window['ga']) ga('send', 'event', category, action, label, value);
|
if (window['ga']) ga('send', 'event', category, action, label, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function alertError(s:string) {
|
function alertError(s:string) {
|
||||||
gaEvent('error', platform_id||'error', s);
|
|
||||||
setWaitDialog(false);
|
setWaitDialog(false);
|
||||||
bootbox.alert({
|
bootbox.alert({
|
||||||
title: '<span class="glyphicon glyphicon-alert" aria-hidden="true"></span> Alert',
|
title: '<span class="glyphicon glyphicon-alert" aria-hidden="true"></span> Alert',
|
||||||
|
@ -121,6 +139,10 @@ function alertInfo(s:string) {
|
||||||
setWaitDialog(false);
|
setWaitDialog(false);
|
||||||
bootbox.alert(s);
|
bootbox.alert(s);
|
||||||
}
|
}
|
||||||
|
function fatalError(s:string) {
|
||||||
|
alertError(s);
|
||||||
|
throw new Error(s);
|
||||||
|
}
|
||||||
|
|
||||||
function newWorker() : Worker {
|
function newWorker() : Worker {
|
||||||
return new Worker("./gen/worker/bundle.js");
|
return new Worker("./gen/worker/bundle.js");
|
||||||
|
@ -138,6 +160,43 @@ const hasLocalStorage : boolean = function() {
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
|
|
||||||
|
// wrapper for localstorage
|
||||||
|
class UserPrefs {
|
||||||
|
setLastPreset(id:string) {
|
||||||
|
if (hasLocalStorage && !isEmbed) {
|
||||||
|
if (repo_id && platform_id && !isElectron)
|
||||||
|
localStorage.setItem("__lastrepo_" + platform_id, repo_id);
|
||||||
|
else
|
||||||
|
localStorage.removeItem("__lastrepo_" + platform_id);
|
||||||
|
localStorage.setItem("__lastplatform", platform_id);
|
||||||
|
localStorage.setItem("__lastid_" + store_id, id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unsetLastPreset() {
|
||||||
|
if (hasLocalStorage && !isEmbed) {
|
||||||
|
delete qs.file;
|
||||||
|
localStorage.removeItem("__lastid_"+store_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getLastPreset() {
|
||||||
|
return hasLocalStorage && !isEmbed && localStorage.getItem("__lastid_"+store_id);
|
||||||
|
}
|
||||||
|
getLastPlatformID() {
|
||||||
|
return hasLocalStorage && !isEmbed && localStorage.getItem("__lastplatform");
|
||||||
|
}
|
||||||
|
getLastRepoID() {
|
||||||
|
return hasLocalStorage && !isEmbed && localStorage.getItem("__lastrepo_" + platform_id);
|
||||||
|
}
|
||||||
|
shouldCompleteTour() {
|
||||||
|
return hasLocalStorage && !isEmbed && !localStorage.getItem("8bitworkshop.hello");
|
||||||
|
}
|
||||||
|
completedTour() {
|
||||||
|
if (hasLocalStorage && !isEmbed) localStorage.setItem("8bitworkshop.hello", "true");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var userPrefs = new UserPrefs();
|
||||||
|
|
||||||
// https://developers.google.com/web/updates/2016/06/persistent-storage
|
// https://developers.google.com/web/updates/2016/06/persistent-storage
|
||||||
function requestPersistPermission(interactive: boolean, failureonly: boolean) {
|
function requestPersistPermission(interactive: boolean, failureonly: boolean) {
|
||||||
if (navigator.storage && navigator.storage.persist) {
|
if (navigator.storage && navigator.storage.persist) {
|
||||||
|
@ -161,32 +220,14 @@ function getCurrentPresetTitle() : string {
|
||||||
return current_preset.title || current_preset.name || current_project.mainPath || "ROM";
|
return current_preset.title || current_preset.name || current_project.mainPath || "ROM";
|
||||||
}
|
}
|
||||||
|
|
||||||
function setLastPreset(id:string) {
|
|
||||||
if (hasLocalStorage) {
|
|
||||||
if (repo_id && platform_id && !isElectron)
|
|
||||||
localStorage.setItem("__lastrepo_" + platform_id, repo_id);
|
|
||||||
else
|
|
||||||
localStorage.removeItem("__lastrepo_" + platform_id);
|
|
||||||
localStorage.setItem("__lastplatform", platform_id);
|
|
||||||
localStorage.setItem("__lastid_" + store_id, id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function unsetLastPreset() {
|
|
||||||
if (hasLocalStorage) {
|
|
||||||
delete qs['file'];
|
|
||||||
localStorage.removeItem("__lastid_"+store_id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function initProject() {
|
async function initProject() {
|
||||||
var basefs : ProjectFilesystem = new WebPresetsFileSystem(platform_id);
|
var basefs : ProjectFilesystem = new WebPresetsFileSystem(platform_id);
|
||||||
//basefs = new FirebaseProjectFilesystem("TEST", "TEST");
|
//basefs = new FirebaseProjectFilesystem("TEST", "TEST");
|
||||||
if (isElectron) {
|
if (isElectron) {
|
||||||
console.log('using electron with local filesystem', alternateLocalFilesystem);
|
console.log('using electron with local filesystem', alternateLocalFilesystem);
|
||||||
var filesystem = new OverlayFilesystem(basefs, alternateLocalFilesystem);
|
var filesystem = new OverlayFilesystem(basefs, alternateLocalFilesystem);
|
||||||
} else if (qs['localfs'] != null) {
|
} else if (qs.localfs != null) {
|
||||||
var filesystem = new OverlayFilesystem(basefs, await getLocalFilesystem(qs['localfs']));
|
var filesystem = new OverlayFilesystem(basefs, await getLocalFilesystem(qs.localfs));
|
||||||
} else {
|
} else {
|
||||||
var filesystem = new OverlayFilesystem(basefs, new LocalForageFilesystem(store));
|
var filesystem = new OverlayFilesystem(basefs, new LocalForageFilesystem(store));
|
||||||
}
|
}
|
||||||
|
@ -354,7 +395,7 @@ async function loadProject(preset_id:string) {
|
||||||
// set current file ID
|
// set current file ID
|
||||||
// TODO: this is done twice (mainPath and mainpath!)
|
// TODO: this is done twice (mainPath and mainpath!)
|
||||||
current_project.mainPath = preset_id;
|
current_project.mainPath = preset_id;
|
||||||
setLastPreset(preset_id);
|
userPrefs.setLastPreset(preset_id);
|
||||||
// load files from storage or web URLs
|
// load files from storage or web URLs
|
||||||
var result = await current_project.loadFiles([preset_id]);
|
var result = await current_project.loadFiles([preset_id]);
|
||||||
measureTimeLoad = new Date(); // for timing calc.
|
measureTimeLoad = new Date(); // for timing calc.
|
||||||
|
@ -366,12 +407,12 @@ async function loadProject(preset_id:string) {
|
||||||
current_project.filedata[preset_id] = skel || "\n";
|
current_project.filedata[preset_id] = skel || "\n";
|
||||||
loadMainWindow(preset_id);
|
loadMainWindow(preset_id);
|
||||||
// don't alert if we selected "new file"
|
// don't alert if we selected "new file"
|
||||||
if (!qs['newfile']) {
|
if (!qs.newfile) {
|
||||||
alertInfo("Could not find file \"" + preset_id + "\". Loading default file.");
|
alertInfo("Could not find file \"" + preset_id + "\". Loading default file.");
|
||||||
} else {
|
} else {
|
||||||
requestPersistPermission(true, true);
|
requestPersistPermission(true, true);
|
||||||
}
|
}
|
||||||
delete qs['newfile'];
|
delete qs.newfile;
|
||||||
replaceURLState();
|
replaceURLState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -386,8 +427,8 @@ function reloadProject(id:string) {
|
||||||
qs = {repo:urlparse.repopath};
|
qs = {repo:urlparse.repopath};
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qs['platform'] = platform_id;
|
qs.platform = platform_id;
|
||||||
qs['file'] = id;
|
qs.file = id;
|
||||||
}
|
}
|
||||||
gotoNewLocation();
|
gotoNewLocation();
|
||||||
}
|
}
|
||||||
|
@ -422,7 +463,7 @@ function _createNewFile(e) {
|
||||||
}
|
}
|
||||||
var path = filename;
|
var path = filename;
|
||||||
gaEvent('workspace', 'file', 'new');
|
gaEvent('workspace', 'file', 'new');
|
||||||
qs['newfile'] = '1';
|
qs.newfile = '1';
|
||||||
reloadProject(path);
|
reloadProject(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -446,9 +487,9 @@ function handleFileUpload(files: File[]) {
|
||||||
alertInfo("Files uploaded.");
|
alertInfo("Files uploaded.");
|
||||||
setTimeout(updateSelector, 1000); // TODO: wait for files to upload
|
setTimeout(updateSelector, 1000); // TODO: wait for files to upload
|
||||||
} else {
|
} else {
|
||||||
qs['file'] = files[0].name;
|
qs.file = files[0].name;
|
||||||
bootbox.confirm({
|
bootbox.confirm({
|
||||||
message: "Open '" + qs['file'] + "' as main project file?",
|
message: "Open '" + qs.file + "' as main project file?",
|
||||||
buttons: {
|
buttons: {
|
||||||
confirm: { label: "Open As New Project" },
|
confirm: { label: "Open As New Project" },
|
||||||
cancel: { label: "Include/Link With Project Later" },
|
cancel: { label: "Include/Link With Project Later" },
|
||||||
|
@ -680,7 +721,7 @@ function _publishProjectToGithub(e) {
|
||||||
}).then( (_sess) => {
|
}).then( (_sess) => {
|
||||||
sess = _sess;
|
sess = _sess;
|
||||||
setWaitProgress(0.5);
|
setWaitProgress(0.5);
|
||||||
repo_id = qs['repo'] = sess.repopath;
|
repo_id = qs.repo = sess.repopath;
|
||||||
return pushChangesToGithub('initial import from 8bitworkshop.com');
|
return pushChangesToGithub('initial import from 8bitworkshop.com');
|
||||||
}).then( () => {
|
}).then( () => {
|
||||||
gaEvent('sync', 'publish', priv?"":name);
|
gaEvent('sync', 'publish', priv?"":name);
|
||||||
|
@ -977,8 +1018,8 @@ function _deleteFile(e) {
|
||||||
if (ok) {
|
if (ok) {
|
||||||
store.removeItem(fn).then( () => {
|
store.removeItem(fn).then( () => {
|
||||||
// if we delete what is selected
|
// if we delete what is selected
|
||||||
if (qs['file'] == fn) {
|
if (qs.file == fn) {
|
||||||
unsetLastPreset();
|
userPrefs.unsetLastPreset();
|
||||||
gotoNewLocation();
|
gotoNewLocation();
|
||||||
} else {
|
} else {
|
||||||
updateSelector();
|
updateSelector();
|
||||||
|
@ -1929,9 +1970,8 @@ function isLandscape() {
|
||||||
return window.innerWidth > window.innerHeight;
|
return window.innerWidth > window.innerHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
function showWelcomeMessage() {
|
async function showWelcomeMessage() {
|
||||||
if (hasLocalStorage && !localStorage.getItem("8bitworkshop.hello")) {
|
if (userPrefs.shouldCompleteTour()) {
|
||||||
// Instance the tour
|
|
||||||
var is_vcs = platform_id.startsWith('vcs');
|
var is_vcs = platform_id.startsWith('vcs');
|
||||||
var steps = [
|
var steps = [
|
||||||
{
|
{
|
||||||
|
@ -2015,31 +2055,16 @@ function showWelcomeMessage() {
|
||||||
//storage:false,
|
//storage:false,
|
||||||
steps:steps,
|
steps:steps,
|
||||||
onEnd: () => {
|
onEnd: () => {
|
||||||
|
userPrefs.completedTour();
|
||||||
//requestPersistPermission(false, true);
|
//requestPersistPermission(false, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
setTimeout(() => { tour.start(); }, 2000);
|
setTimeout(() => { tour.start(); }, 2500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////
|
///////////////////////////////////////////////////
|
||||||
|
|
||||||
export var qs = (function (a : string[]) {
|
|
||||||
if (!a || a.length == 0)
|
|
||||||
return {};
|
|
||||||
var b = {};
|
|
||||||
for (var i = 0; i < a.length; ++i) {
|
|
||||||
var p = a[i].split('=', 2);
|
|
||||||
if (p.length == 1)
|
|
||||||
b[p[0]] = "";
|
|
||||||
else
|
|
||||||
b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
|
|
||||||
}
|
|
||||||
return b;
|
|
||||||
})(window.location.search.substr(1).split('&'));
|
|
||||||
|
|
||||||
const isElectron = !!qs['electron'];
|
|
||||||
|
|
||||||
function globalErrorHandler(msgevent) {
|
function globalErrorHandler(msgevent) {
|
||||||
var msg = (msgevent.message || msgevent.error || msgevent)+"";
|
var msg = (msgevent.message || msgevent.error || msgevent)+"";
|
||||||
// storage quota full? (Chrome) try to expand it
|
// storage quota full? (Chrome) try to expand it
|
||||||
|
@ -2080,7 +2105,7 @@ function gotoNewLocation(replaceHistory? : boolean) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function replaceURLState() {
|
function replaceURLState() {
|
||||||
if (platform_id) qs['platform'] = platform_id;
|
if (platform_id) qs.platform = platform_id;
|
||||||
delete qs['']; // remove null parameter
|
delete qs['']; // remove null parameter
|
||||||
history.replaceState({}, "", "?" + $.param(qs));
|
history.replaceState({}, "", "?" + $.param(qs));
|
||||||
}
|
}
|
||||||
|
@ -2139,7 +2164,7 @@ function installGAHooks() {
|
||||||
gaEvent('menu', e.target.id);
|
gaEvent('menu', e.target.id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ga('send', 'pageview', location.pathname+'?platform='+platform_id+(repo_id?('&repo='+repo_id):('&file='+qs['file'])));
|
ga('send', 'pageview', location.pathname+'?platform='+platform_id+(repo_id?('&repo='+repo_id):('&file='+qs.file)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2149,22 +2174,19 @@ async function startPlatform() {
|
||||||
setPlatformUI();
|
setPlatformUI();
|
||||||
stateRecorder = new StateRecorderImpl(platform);
|
stateRecorder = new StateRecorderImpl(platform);
|
||||||
PRESETS = platform.getPresets ? platform.getPresets() : [];
|
PRESETS = platform.getPresets ? platform.getPresets() : [];
|
||||||
if (!qs['file']) {
|
if (!qs.file) {
|
||||||
// try to load last file (redirect)
|
// try to load last file (redirect)
|
||||||
var lastid;
|
var lastid = userPrefs.getLastPreset();
|
||||||
if (hasLocalStorage) {
|
|
||||||
lastid = localStorage.getItem("__lastid_"+store_id);
|
|
||||||
}
|
|
||||||
// load first preset file, unless we're in a repo
|
// load first preset file, unless we're in a repo
|
||||||
var defaultfile = lastid || (repo_id ? null : PRESETS[0].id);
|
var defaultfile = lastid || (repo_id ? null : PRESETS[0].id);
|
||||||
qs['file'] = defaultfile || 'DEFAULT';
|
qs.file = defaultfile || 'DEFAULT';
|
||||||
if (!defaultfile) {
|
if (!defaultfile) {
|
||||||
alertError("There is no default main file for this project. Try selecting one from the pulldown.");
|
alertError("There is no default main file for this project. Try selecting one from the pulldown.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// legacy vcs stuff
|
// legacy vcs stuff
|
||||||
if (platform_id == 'vcs' && qs['file'].startsWith('examples/') && !qs['file'].endsWith('.a')) {
|
if (platform_id == 'vcs' && qs.file.startsWith('examples/') && !qs.file.endsWith('.a')) {
|
||||||
qs['file'] += '.a';
|
qs.file += '.a';
|
||||||
}
|
}
|
||||||
// start platform and load file
|
// start platform and load file
|
||||||
replaceURLState();
|
replaceURLState();
|
||||||
|
@ -2173,12 +2195,12 @@ async function startPlatform() {
|
||||||
await platform.start();
|
await platform.start();
|
||||||
await loadBIOSFromProject();
|
await loadBIOSFromProject();
|
||||||
await initProject();
|
await initProject();
|
||||||
await loadProject(qs['file']);
|
await loadProject(qs.file);
|
||||||
platform.sourceFileFetch = (path) => current_project.filedata[path];
|
platform.sourceFileFetch = (path) => current_project.filedata[path];
|
||||||
setupDebugControls();
|
setupDebugControls();
|
||||||
addPageFocusHandlers();
|
addPageFocusHandlers();
|
||||||
showInstructions();
|
showInstructions();
|
||||||
if (qs['embed']) {
|
if (isEmbed) {
|
||||||
hideControlsForEmbed();
|
hideControlsForEmbed();
|
||||||
} else {
|
} else {
|
||||||
updateSelector();
|
updateSelector();
|
||||||
|
@ -2206,11 +2228,12 @@ function revealTopBar() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setupSplits() {
|
export function setupSplits() {
|
||||||
const splitName = 'workspace-split3-' + platform_id;
|
var splitName = 'workspace-split3-' + platform_id;
|
||||||
|
if (isEmbed) splitName = 'embed-' + splitName;
|
||||||
var sizes;
|
var sizes;
|
||||||
if (platform_id.startsWith('vcs'))
|
if (platform_id.startsWith('vcs'))
|
||||||
sizes = [0, 50, 50];
|
sizes = [0, 50, 50];
|
||||||
else if (qs['embed'] || Views.isMobileDevice)
|
else if (isEmbed || Views.isMobileDevice)
|
||||||
sizes = [0, 60, 40];
|
sizes = [0, 60, 40];
|
||||||
else
|
else
|
||||||
sizes = [12, 44, 44];
|
sizes = [12, 44, 44];
|
||||||
|
@ -2227,8 +2250,7 @@ export function setupSplits() {
|
||||||
if (platform && platform.resize) platform.resize();
|
if (platform && platform.resize) platform.resize();
|
||||||
},
|
},
|
||||||
onDragEnd: () => {
|
onDragEnd: () => {
|
||||||
if (hasLocalStorage)
|
if (hasLocalStorage) localStorage.setItem(splitName, JSON.stringify(split.getSizes()))
|
||||||
localStorage.setItem(splitName, JSON.stringify(split.getSizes()))
|
|
||||||
if (projectWindows) projectWindows.resize();
|
if (projectWindows) projectWindows.resize();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -2248,8 +2270,8 @@ function loadImportedURL(url : string) {
|
||||||
if (err)
|
if (err)
|
||||||
alert(err+""); // need to wait
|
alert(err+""); // need to wait
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
delete qs['importURL'];
|
delete qs.importURL;
|
||||||
qs['file'] = path;
|
qs.file = path;
|
||||||
replaceURLState();
|
replaceURLState();
|
||||||
loadAndStartPlatform();
|
loadAndStartPlatform();
|
||||||
}
|
}
|
||||||
|
@ -2264,8 +2286,13 @@ function loadImportedURL(url : string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadFormDataUpload() {
|
async function loadFormDataUpload() {
|
||||||
var ignore = !!qs['ignore'];
|
var ignore = parseBool(qs.ignore);
|
||||||
var force = !!qs['force'];
|
var force = parseBool(qs.force);
|
||||||
|
if (isEmbed) {
|
||||||
|
ignore = !force; // ignore is default when embed=1 unless force=1
|
||||||
|
} else {
|
||||||
|
force = false; // can't use force w/o embed=1
|
||||||
|
}
|
||||||
for (var i=0; i<20; i++) {
|
for (var i=0; i<20; i++) {
|
||||||
let path = qs['file'+i+'_name'];
|
let path = qs['file'+i+'_name'];
|
||||||
let dataenc = qs['file'+i+'_data'];
|
let dataenc = qs['file'+i+'_data'];
|
||||||
|
@ -2280,13 +2307,13 @@ async function loadFormDataUpload() {
|
||||||
await store.setItem(path, value);
|
await store.setItem(path, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i == 0) { qs['file'] = path; } // set main filename
|
if (i == 0) { qs.file = path; } // set main filename
|
||||||
delete qs['file'+i+'_name'];
|
delete qs['file'+i+'_name'];
|
||||||
delete qs['file'+i+'_data'];
|
delete qs['file'+i+'_data'];
|
||||||
delete qs['file'+i+'_type'];
|
delete qs['file'+i+'_type'];
|
||||||
}
|
}
|
||||||
delete qs['ignore'];
|
delete qs.ignore;
|
||||||
delete qs['force'];
|
delete qs.force;
|
||||||
replaceURLState();
|
replaceURLState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2303,33 +2330,34 @@ function setPlatformUI() {
|
||||||
export function getPlatformAndRepo() {
|
export function getPlatformAndRepo() {
|
||||||
// add default platform?
|
// add default platform?
|
||||||
// TODO: do this after repo_id
|
// TODO: do this after repo_id
|
||||||
platform_id = qs['platform'] || (hasLocalStorage && localStorage.getItem("__lastplatform"));
|
platform_id = qs.platform || userPrefs.getLastPlatformID();
|
||||||
if (!platform_id) {
|
if (!platform_id) {
|
||||||
platform_id = qs['platform'] = "vcs";
|
if (isEmbed) fatalError(`The 'platform' must be specified when embed=1`);
|
||||||
|
platform_id = qs.platform = "vcs";
|
||||||
}
|
}
|
||||||
// lookup repository for this platform
|
// lookup repository for this platform
|
||||||
repo_id = qs['repo'] || (hasLocalStorage && localStorage.getItem("__lastrepo_" + platform_id));
|
repo_id = qs.repo || userPrefs.getLastRepoID();
|
||||||
if (hasLocalStorage && repo_id && repo_id !== '/') {
|
if (hasLocalStorage && repo_id && repo_id !== '/') {
|
||||||
var repo = getRepos()[repo_id];
|
var repo = getRepos()[repo_id];
|
||||||
if (repo) {
|
if (repo) {
|
||||||
qs['repo'] = repo_id;
|
qs.repo = repo_id;
|
||||||
if (repo.platform_id && !qs['platform'])
|
if (repo.platform_id && !qs.platform)
|
||||||
qs['platform'] = platform_id = repo.platform_id;
|
qs.platform = platform_id = repo.platform_id;
|
||||||
if (!qs['file'])
|
if (!qs.file)
|
||||||
qs['file'] = repo.mainPath;
|
qs.file = repo.mainPath;
|
||||||
requestPersistPermission(true, true);
|
requestPersistPermission(true, true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
repo_id = '';
|
repo_id = '';
|
||||||
delete qs['repo'];
|
delete qs.repo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// start
|
// start
|
||||||
export async function startUI() {
|
export async function startUI() {
|
||||||
// import from github?
|
// import from github?
|
||||||
if (qs['githubURL']) {
|
if (qs.githubURL) {
|
||||||
importProjectFromGithub(qs['githubURL'], true);
|
importProjectFromGithub(qs.githubURL, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
getPlatformAndRepo();
|
getPlatformAndRepo();
|
||||||
|
@ -2337,16 +2365,18 @@ export async function startUI() {
|
||||||
// get store ID, repo id or platform id
|
// get store ID, repo id or platform id
|
||||||
store_id = repo_id || getBasePlatform(platform_id);
|
store_id = repo_id || getBasePlatform(platform_id);
|
||||||
// are we embedded?
|
// are we embedded?
|
||||||
if (qs['embed']) store_id = (document.referrer || document.location.href) + store_id;
|
if (isEmbed) {
|
||||||
|
store_id = (document.referrer || document.location.href) + store_id;
|
||||||
|
}
|
||||||
// create store
|
// create store
|
||||||
store = createNewPersistentStore(store_id);
|
store = createNewPersistentStore(store_id);
|
||||||
// is this an importURL?
|
// is this an importURL?
|
||||||
if (qs['importURL']) {
|
if (qs.importURL) {
|
||||||
loadImportedURL(qs['importURL']);
|
loadImportedURL(qs.importURL);
|
||||||
return; // TODO: make async
|
return; // TODO: make async
|
||||||
}
|
}
|
||||||
// is this a file POST?
|
// is this a file POST?
|
||||||
if (qs['file0_name']) {
|
if (qs.file0_name) {
|
||||||
await loadFormDataUpload();
|
await loadFormDataUpload();
|
||||||
}
|
}
|
||||||
// load and start platform object
|
// load and start platform object
|
||||||
|
|
|
@ -7,7 +7,6 @@ var assert = require('assert');
|
||||||
var wtu = require('./workertestutils.js'); // loads localStorage
|
var wtu = require('./workertestutils.js'); // loads localStorage
|
||||||
global.localforage = require("lib/localforage.min.js");
|
global.localforage = require("lib/localforage.min.js");
|
||||||
var util = require("gen/common/util.js");
|
var util = require("gen/common/util.js");
|
||||||
var mstore = require("gen/ide/store.js");
|
|
||||||
var prj = require("gen/ide/project.js");
|
var prj = require("gen/ide/project.js");
|
||||||
var serv = require("gen/ide/services.js");
|
var serv = require("gen/ide/services.js");
|
||||||
var Octokat = require('octokat');
|
var Octokat = require('octokat');
|
||||||
|
@ -25,12 +24,18 @@ function newGH(store, platform_id) {
|
||||||
return new serv.GithubService(Octokat, process.env.TEST8BIT_GITHUB_TOKEN, store, project);
|
return new serv.GithubService(Octokat, process.env.TEST8BIT_GITHUB_TOKEN, store, project);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createNewPersistentStore(platform_id, callback) {
|
||||||
|
var store = prj.createNewPersistentStore(platform_id);
|
||||||
|
callback(store);
|
||||||
|
return store;
|
||||||
|
}
|
||||||
|
|
||||||
const t0 = new Date().getTime();
|
const t0 = new Date().getTime();
|
||||||
|
|
||||||
describe('Github', function() {
|
describe('Github', function() {
|
||||||
|
|
||||||
it('Should import from Github (check README)', function(done) {
|
it('Should import from Github (check README)', function(done) {
|
||||||
var store = mstore.createNewPersistentStore('vcs', function(store) {
|
var store = createNewPersistentStore('vcs', function(store) {
|
||||||
var gh = newGH(store, 'vcs');
|
var gh = newGH(store, 'vcs');
|
||||||
gh.importAndPull('https://github.com/pzpinfo/test123123/').then( (sess) => {
|
gh.importAndPull('https://github.com/pzpinfo/test123123/').then( (sess) => {
|
||||||
console.log(sess.paths);
|
console.log(sess.paths);
|
||||||
|
@ -48,7 +53,7 @@ describe('Github', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should import from Github (default branch)', function(done) {
|
it('Should import from Github (default branch)', function(done) {
|
||||||
var store = mstore.createNewPersistentStore('nes', function(store) {
|
var store = createNewPersistentStore('nes', function(store) {
|
||||||
var gh = newGH(store, 'nes');
|
var gh = newGH(store, 'nes');
|
||||||
gh.importAndPull('https://github.com/sehugg/mdf2020-nes').then( (sess) => {
|
gh.importAndPull('https://github.com/sehugg/mdf2020-nes').then( (sess) => {
|
||||||
console.log(sess.paths);
|
console.log(sess.paths);
|
||||||
|
@ -58,7 +63,7 @@ describe('Github', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should import from Github (explicit branch)', function(done) {
|
it('Should import from Github (explicit branch)', function(done) {
|
||||||
var store = mstore.createNewPersistentStore('nes', function(store) {
|
var store = createNewPersistentStore('nes', function(store) {
|
||||||
var gh = newGH(store, 'nes');
|
var gh = newGH(store, 'nes');
|
||||||
gh.importAndPull('https://github.com/sehugg/mdf2020-nes/tree/main').then( (sess) => {
|
gh.importAndPull('https://github.com/sehugg/mdf2020-nes/tree/main').then( (sess) => {
|
||||||
console.log(sess.paths);
|
console.log(sess.paths);
|
||||||
|
@ -68,7 +73,7 @@ describe('Github', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should import from Github (binary files)', function(done) {
|
it('Should import from Github (binary files)', function(done) {
|
||||||
var store = mstore.createNewPersistentStore('vcs', function(store) {
|
var store = createNewPersistentStore('vcs', function(store) {
|
||||||
var gh = newGH(store, 'vcs');
|
var gh = newGH(store, 'vcs');
|
||||||
gh.importAndPull('https://github.com/pzpinfo/testrepo3').then( (sess) => {
|
gh.importAndPull('https://github.com/pzpinfo/testrepo3').then( (sess) => {
|
||||||
console.log(sess.paths);
|
console.log(sess.paths);
|
||||||
|
@ -84,7 +89,7 @@ describe('Github', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should import from Github (wrong platform)', function(done) {
|
it('Should import from Github (wrong platform)', function(done) {
|
||||||
var store = mstore.createNewPersistentStore('_FOO', function(store) {
|
var store = createNewPersistentStore('_FOO', function(store) {
|
||||||
var gh = newGH(store, '_FOO');
|
var gh = newGH(store, '_FOO');
|
||||||
gh.importAndPull('https://github.com/pzpinfo/testrepo1557326056720').catch( (e) => {
|
gh.importAndPull('https://github.com/pzpinfo/testrepo1557326056720').catch( (e) => {
|
||||||
assert.ok(e.message.startsWith('Platform mismatch'));
|
assert.ok(e.message.startsWith('Platform mismatch'));
|
||||||
|
@ -94,7 +99,7 @@ describe('Github', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should import from Github (invalid URL)', function(done) {
|
it('Should import from Github (invalid URL)', function(done) {
|
||||||
var store = mstore.createNewPersistentStore('_FOO', function(store) {
|
var store = createNewPersistentStore('_FOO', function(store) {
|
||||||
var gh = newGH(store, '_FOO');
|
var gh = newGH(store, '_FOO');
|
||||||
gh.importAndPull('https://github.com/pzpinfo/NOEXISTSREPO').catch( (e) => {
|
gh.importAndPull('https://github.com/pzpinfo/NOEXISTSREPO').catch( (e) => {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
|
@ -105,7 +110,7 @@ describe('Github', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should import from Github (subdirectory tree)', function(done) {
|
it('Should import from Github (subdirectory tree)', function(done) {
|
||||||
var store = mstore.createNewPersistentStore('nes', function(store) {
|
var store = createNewPersistentStore('nes', function(store) {
|
||||||
var gh = newGH(store, 'nes');
|
var gh = newGH(store, 'nes');
|
||||||
gh.importAndPull('https://github.com/brovador/NESnake/tree/master/src').then( (sess) => {
|
gh.importAndPull('https://github.com/brovador/NESnake/tree/master/src').then( (sess) => {
|
||||||
console.log(sess.paths);
|
console.log(sess.paths);
|
||||||
|
@ -116,7 +121,7 @@ describe('Github', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should publish (fail) on Github', function(done) {
|
it('Should publish (fail) on Github', function(done) {
|
||||||
var store = mstore.createNewPersistentStore(test_platform_id, function(store) {
|
var store = createNewPersistentStore(test_platform_id, function(store) {
|
||||||
var gh = newGH(store);
|
var gh = newGH(store);
|
||||||
// should fail
|
// should fail
|
||||||
gh.publish('testrepo1').catch( (e) => {
|
gh.publish('testrepo1').catch( (e) => {
|
||||||
|
@ -126,7 +131,7 @@ describe('Github', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should publish new repository on Github', function(done) {
|
it('Should publish new repository on Github', function(done) {
|
||||||
var store = mstore.createNewPersistentStore(test_platform_id, function(store) {
|
var store = createNewPersistentStore(test_platform_id, function(store) {
|
||||||
var gh = newGH(store);
|
var gh = newGH(store);
|
||||||
var reponame = 'testrepo'+t0;
|
var reponame = 'testrepo'+t0;
|
||||||
// should fail
|
// should fail
|
||||||
|
@ -140,7 +145,7 @@ describe('Github', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should commit/push to Github', function(done) {
|
it('Should commit/push to Github', function(done) {
|
||||||
var store = mstore.createNewPersistentStore(test_platform_id, function(store) {
|
var store = createNewPersistentStore(test_platform_id, function(store) {
|
||||||
var gh = newGH(store);
|
var gh = newGH(store);
|
||||||
var binfile = new Uint8Array(256);
|
var binfile = new Uint8Array(256);
|
||||||
for (var i=0; i<256; i++)
|
for (var i=0; i<256; i++)
|
||||||
|
@ -160,7 +165,7 @@ describe('Github', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should commit/push to Github (subdirectory tree)', function(done) {
|
it('Should commit/push to Github (subdirectory tree)', function(done) {
|
||||||
var store = mstore.createNewPersistentStore(test_platform_id, function(store) {
|
var store = createNewPersistentStore(test_platform_id, function(store) {
|
||||||
var gh = newGH(store);
|
var gh = newGH(store);
|
||||||
var files = [
|
var files = [
|
||||||
{path:'text.txt', data:'hello world'}
|
{path:'text.txt', data:'hello world'}
|
||||||
|
@ -178,7 +183,7 @@ describe('Github', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should bind paths to Github', function(done) {
|
it('Should bind paths to Github', function(done) {
|
||||||
var store = mstore.createNewPersistentStore(test_platform_id, function(store) {
|
var store = createNewPersistentStore(test_platform_id, function(store) {
|
||||||
var gh = newGH(store);
|
var gh = newGH(store);
|
||||||
var sess = {repopath:'foo/bar', url:'_', platform_id:'vcs',mainPath:'test.c'};
|
var sess = {repopath:'foo/bar', url:'_', platform_id:'vcs',mainPath:'test.c'};
|
||||||
gh.bind(sess, true);
|
gh.bind(sess, true);
|
||||||
|
|
|
@ -7,7 +7,6 @@ var assert = require('assert');
|
||||||
var wtu = require('./workertestutils.js'); // loads localStorage
|
var wtu = require('./workertestutils.js'); // loads localStorage
|
||||||
global.localforage = require("lib/localforage.min.js");
|
global.localforage = require("lib/localforage.min.js");
|
||||||
var util = require("gen/common/util.js");
|
var util = require("gen/common/util.js");
|
||||||
var mstore = require("gen/ide/store.js");
|
|
||||||
var prj = require("gen/ide/project.js");
|
var prj = require("gen/ide/project.js");
|
||||||
|
|
||||||
var test_platform_id = "_TEST";
|
var test_platform_id = "_TEST";
|
||||||
|
@ -21,7 +20,7 @@ function newFilesystem(store, platform_id) {
|
||||||
describe('Store', function () {
|
describe('Store', function () {
|
||||||
|
|
||||||
it('Should load local project', function (done) {
|
it('Should load local project', function (done) {
|
||||||
var store = mstore.createNewPersistentStore(test_platform_id);
|
var store = prj.createNewPersistentStore(test_platform_id);
|
||||||
store.setItem('local/test', 'a');
|
store.setItem('local/test', 'a');
|
||||||
var worker = {};
|
var worker = {};
|
||||||
var platform = {};
|
var platform = {};
|
||||||
|
@ -47,7 +46,7 @@ describe('Store', function () {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
var store = mstore.createNewPersistentStore(test_platform_id);
|
var store = prj.createNewPersistentStore(test_platform_id);
|
||||||
var worker = {
|
var worker = {
|
||||||
postMessage: function (m) { msgs.push(m); },
|
postMessage: function (m) { msgs.push(m); },
|
||||||
};
|
};
|
||||||
|
@ -74,7 +73,7 @@ describe('Store', function () {
|
||||||
|
|
||||||
it('Should build asm project', function (done) {
|
it('Should build asm project', function (done) {
|
||||||
var msgs = [];
|
var msgs = [];
|
||||||
var store = mstore.createNewPersistentStore(test_platform_id);
|
var store = prj.createNewPersistentStore(test_platform_id);
|
||||||
var worker = {
|
var worker = {
|
||||||
};
|
};
|
||||||
var platform = {
|
var platform = {
|
||||||
|
|
|
@ -6,7 +6,7 @@ var vm = require('vm');
|
||||||
|
|
||||||
var worker = {};
|
var worker = {};
|
||||||
|
|
||||||
process.exit = function() { console.log("arggh you can't exit when i pass noExitRuntime! lol process.exit() go brrr") }
|
//process.exit = function() { console.log("arggh you can't exit when i pass noExitRuntime! lol process.exit() go brrr") }
|
||||||
|
|
||||||
global.window = global;
|
global.window = global;
|
||||||
global.exports = {};
|
global.exports = {};
|
||||||
|
|
|
@ -1,23 +1,34 @@
|
||||||
|
|
||||||
|
// https://nightwatchjs.org/js/app/api/method.html
|
||||||
|
|
||||||
//var IDEURL = 'https://8bitworkshop.com/dev/';
|
//var IDEURL = 'https://8bitworkshop.com/dev/';
|
||||||
var IDEURL = 'http://localhost:8000/';
|
var IDEURL = 'http://localhost:8000/';
|
||||||
var QS = '?embed=1&ignore=1&platform=c64&file0_name=test.dasm&file0_data=%0A%20%20%20%20%20 processor 6502%0A%20%20%20%20%20 org %24803%0AFoo%3A%20 lda %231%0A%20%20%20%20%20 rts';
|
var QS = '?embed=1&platform=c64&file0_name=test.dasm&file0_data=%0A%20%20%20%20%20 processor 6502%0A%20%20%20%20%20 org %24803%0AFoo%3A%20 lda %231%0A%20%20%20%20%20 rts';
|
||||||
var EMBEDURL = 'http://localhost:8000/';
|
var EMBEDURL = 'http://localhost:8000/embed.html?p=c64&r=TFpHAAAAagAAAGPy6Sf6AQECBQYAgAmAJYDDws04MI4W0CCj%2FSBQ%2FSAV%2FSBb%2F1jqBgl4oACMINC5W4DwCRhpwJkpBMjQ8q0R0DD7rRLQzRLQ8PtKShhlA40g0AUNEOsFI8YDTDmASEVMTE9gV09STERhAA%3D%3D';
|
||||||
|
|
||||||
exports['test iframe'] = function(browser) {
|
exports['test embed iframe'] = function(browser) {
|
||||||
|
|
||||||
browser.url(IDEURL + QS)
|
browser.url(IDEURL + QS)
|
||||||
|
.waitForElementNotPresent('#step-0')
|
||||||
.waitForElementNotVisible('#compile_spinner', time=10000)
|
.waitForElementNotVisible('#compile_spinner', time=10000)
|
||||||
.waitForElementNotVisible('#error_alert')
|
.waitForElementNotVisible('#error_alert')
|
||||||
.waitForElementVisible('#emuscreen')
|
.waitForElementVisible('#emuscreen')
|
||||||
.waitForElementVisible('.emuvideo')
|
.waitForElementVisible('.emuvideo')
|
||||||
|
|
||||||
|
browser.url(IDEURL + QS + "&ignore=1")
|
||||||
|
.waitForElementNotVisible('#compile_spinner', time=10000)
|
||||||
|
.waitForElementNotVisible('#error_alert')
|
||||||
|
.waitForElementVisible('#emuscreen')
|
||||||
|
.waitForElementVisible('.emuvideo')
|
||||||
|
|
||||||
|
browser.url(IDEURL + "?embed=1")
|
||||||
|
.waitForElementVisible('.bootbox-alert')
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exports['test embed.html'] = function(browser) {
|
exports['test embed.html'] = function(browser) {
|
||||||
|
|
||||||
browser.url(EMBEDURL)
|
browser.url(EMBEDURL)
|
||||||
.waitForElementNotVisible('#error_alert')
|
|
||||||
.waitForElementVisible('.emuvideo')
|
.waitForElementVisible('.emuvideo')
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,11 +7,12 @@
|
||||||
"allowJs": false,
|
"allowJs": false,
|
||||||
"checkJs": false,
|
"checkJs": false,
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"target": "es5",
|
"target": "es2017",
|
||||||
"lib": [
|
"lib": [
|
||||||
"es2017",
|
"es2017",
|
||||||
"dom"
|
"dom"
|
||||||
],
|
],
|
||||||
|
"module": "CommonJS",
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"isolatedModules": true,
|
"isolatedModules": true,
|
||||||
"noImplicitThis": false,
|
"noImplicitThis": false,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user