mirror of
https://codeberg.org/vlw/monkeydo.git
synced 2025-09-14 08:03:41 +02:00
Compare commits
No commits in common. "master" and "0.4.0" have entirely different histories.
2 changed files with 34 additions and 29 deletions
|
@ -75,17 +75,19 @@ class Monkey {
|
||||||
|
|
||||||
// Install a Monkeydo manifest
|
// Install a Monkeydo manifest
|
||||||
async loadManifest(manifest) {
|
async loadManifest(manifest) {
|
||||||
|
return await new Promise((resolve,reject) => {
|
||||||
if(typeof manifest !== "object") {
|
if(typeof manifest !== "object") {
|
||||||
try {
|
try {
|
||||||
manifest = JSON.parse(manifest);
|
manifest = JSON.parse(manifest);
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Promise.reject("Failed to load manifest");
|
reject("Failed to load manifest");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.tasks.manifest = manifest.tasks;
|
this.tasks.manifest = manifest.tasks;
|
||||||
this.flags[0] = 1; // Manifest loaded: true
|
this.flags[0] = 1; // Manifest loaded: true
|
||||||
return true;
|
resolve();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,12 +48,14 @@ export default class MonkeyMaster {
|
||||||
this.comlink = await new Monkey();
|
this.comlink = await new Monkey();
|
||||||
|
|
||||||
// Wait for comlink to spin up
|
// Wait for comlink to spin up
|
||||||
if(!this.comlink) Promise.reject("Failed to establish Comlink with worker");
|
return await new Promise((resolve,reject) => {
|
||||||
|
if(!this.comlink) reject("Failed to establish Comlink with worker");
|
||||||
|
|
||||||
this.ready = true;
|
this.ready = true;
|
||||||
// Send queued flags when worker is ready
|
// Send queued flags when worker is ready
|
||||||
this.queue.sendAllFlags();
|
this.queue.sendAllFlags();
|
||||||
return true;
|
resolve();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return a flag array index by name
|
// Return a flag array index by name
|
||||||
|
@ -102,6 +104,7 @@ export default class MonkeyMaster {
|
||||||
// Load a Monkeydo manifest by URL or JSON string
|
// Load a Monkeydo manifest by URL or JSON string
|
||||||
async loadManifest(manifest) {
|
async loadManifest(manifest) {
|
||||||
if(!this.ready) await this.init();
|
if(!this.ready) await this.init();
|
||||||
|
return await new Promise((resolve,reject) => {
|
||||||
let load = null;
|
let load = null;
|
||||||
// Attempt load string as URL and fetch manifest
|
// Attempt load string as URL and fetch manifest
|
||||||
try {
|
try {
|
||||||
|
@ -113,9 +116,9 @@ export default class MonkeyMaster {
|
||||||
catch {
|
catch {
|
||||||
load = this.comlink.loadManifest(manifest);
|
load = this.comlink.loadManifest(manifest);
|
||||||
}
|
}
|
||||||
|
load.then(() => resolve())
|
||||||
load.then(() => Promise.resolve())
|
.catch(() => reject("Failed to load manifest"));
|
||||||
.catch(() => Promise.reject("Failed to load manifest"));
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async stop() {
|
async stop() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue