mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-06-25 15:29:34 +00:00
can use binary file as main
This commit is contained in:
parent
c2eb32ce35
commit
fdb4117579
|
@ -32,6 +32,11 @@ export class CodeProject {
|
||||||
this.store = store;
|
this.store = store;
|
||||||
|
|
||||||
worker.onmessage = (e) => {
|
worker.onmessage = (e) => {
|
||||||
|
this.receiveWorkerMessage(e.data);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
receiveWorkerMessage(data : WorkerResult) {
|
||||||
var notfinal = this.pendingWorkerMessages > 1;
|
var notfinal = this.pendingWorkerMessages > 1;
|
||||||
if (notfinal) {
|
if (notfinal) {
|
||||||
this.sendBuild();
|
this.sendBuild();
|
||||||
|
@ -42,11 +47,10 @@ export class CodeProject {
|
||||||
this.isCompiling = false;
|
this.isCompiling = false;
|
||||||
this.pendingWorkerMessages = 0;
|
this.pendingWorkerMessages = 0;
|
||||||
}
|
}
|
||||||
if (e.data && !e.data.unchanged) {
|
if (data && !data.unchanged) {
|
||||||
this.processBuildResult(e.data);
|
this.processBuildResult(data);
|
||||||
if (this.callbackBuildResult) this.callbackBuildResult(e.data); // call with data when changed
|
if (this.callbackBuildResult) this.callbackBuildResult(data); // call with data when changed
|
||||||
}
|
}
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
preloadWorker(path:string) {
|
preloadWorker(path:string) {
|
||||||
|
@ -235,6 +239,19 @@ export class CodeProject {
|
||||||
sendBuild() {
|
sendBuild() {
|
||||||
if (!this.mainpath) throw "need to call setMainFile first";
|
if (!this.mainpath) throw "need to call setMainFile first";
|
||||||
var maindata = this.getFile(this.mainpath);
|
var maindata = this.getFile(this.mainpath);
|
||||||
|
// if binary blob, just return it as ROM
|
||||||
|
if (maindata instanceof Uint8Array) {
|
||||||
|
this.isCompiling = true;
|
||||||
|
this.receiveWorkerMessage({
|
||||||
|
output:maindata,
|
||||||
|
errors:[],
|
||||||
|
listings:null,
|
||||||
|
symbolmap:null,
|
||||||
|
params:{}
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// otherwise, make it a string
|
||||||
var text = typeof maindata === "string" ? maindata : '';
|
var text = typeof maindata === "string" ? maindata : '';
|
||||||
// TODO: load dependencies of non-main files
|
// TODO: load dependencies of non-main files
|
||||||
this.loadFileDependencies(text, (err, depends) => {
|
this.loadFileDependencies(text, (err, depends) => {
|
||||||
|
|
|
@ -206,7 +206,6 @@ function loadProject(preset_id:string) {
|
||||||
alert(err);
|
alert(err);
|
||||||
} else if (result && result.length) {
|
} else if (result && result.length) {
|
||||||
// we need this to build create functions for the editor
|
// we need this to build create functions for the editor
|
||||||
// TODO: can't use binary file as main
|
|
||||||
refreshWindowList();
|
refreshWindowList();
|
||||||
// show main file
|
// show main file
|
||||||
projectWindows.createOrShow(preset_id);
|
projectWindows.createOrShow(preset_id);
|
||||||
|
|
|
@ -25,7 +25,6 @@ export interface ProjectView {
|
||||||
setTimingResult?(result:CodeAnalyzer) : void;
|
setTimingResult?(result:CodeAnalyzer) : void;
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: move to different namespace
|
|
||||||
declare var CodeMirror;
|
declare var CodeMirror;
|
||||||
declare var VirtualList;
|
declare var VirtualList;
|
||||||
|
|
||||||
|
@ -36,8 +35,9 @@ function jumpToLine(ed, i:number) {
|
||||||
ed.scrollTo(null, t - middleHeight - 5);
|
ed.scrollTo(null, t - middleHeight - 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: https://stackoverflow.com/questions/10463518/converting-em-to-px-in-javascript-and-getting-default-font-size
|
||||||
function getVisibleEditorLineHeight() : number{
|
function getVisibleEditorLineHeight() : number{
|
||||||
return $(".CodeMirror-line:visible").first().height();
|
return $("#booksMenuButton").first().height();
|
||||||
}
|
}
|
||||||
|
|
||||||
/////
|
/////
|
||||||
|
|
|
@ -94,4 +94,6 @@ export interface WorkerResult {
|
||||||
listings:CodeListingMap,
|
listings:CodeListingMap,
|
||||||
symbolmap:{[sym:string]:number},
|
symbolmap:{[sym:string]:number},
|
||||||
params:{},
|
params:{},
|
||||||
|
unchanged?:boolean,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user