|
@@ -67,6 +67,10 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
const RESOURCES_INITIALIZED = "resources-initialized";
|
|
const RESOURCES_INITIALIZED = "resources-initialized";
|
|
|
const RESOURCE_LOADED = "resource-loaded";
|
|
const RESOURCE_LOADED = "resource-loaded";
|
|
|
const PAGE_ENDED = "page-ended";
|
|
const PAGE_ENDED = "page-ended";
|
|
|
|
|
+ const STAGE_STARTED = "stage-started";
|
|
|
|
|
+ const STAGE_ENDED = "stage-ended";
|
|
|
|
|
+ const STAGE_TASK_STARTED = "stage-task-started";
|
|
|
|
|
+ const STAGE_TASK_ENDED = "stage-task-ended";
|
|
|
|
|
|
|
|
class ProgressEvent {
|
|
class ProgressEvent {
|
|
|
constructor(type, details) {
|
|
constructor(type, details) {
|
|
@@ -200,13 +204,16 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
if (DEBUG) {
|
|
if (DEBUG) {
|
|
|
log("**** STARTED STAGE", step, "****");
|
|
log("**** STARTED STAGE", step, "****");
|
|
|
}
|
|
}
|
|
|
|
|
+ this.onprogress(new ProgressEvent(STAGE_STARTED, { pageURL: this.options.url, step }));
|
|
|
STAGES[step].sequential.forEach(task => {
|
|
STAGES[step].sequential.forEach(task => {
|
|
|
let startTime;
|
|
let startTime;
|
|
|
if (DEBUG) {
|
|
if (DEBUG) {
|
|
|
startTime = Date.now();
|
|
startTime = Date.now();
|
|
|
log(" -- STARTED task =", task.action);
|
|
log(" -- STARTED task =", task.action);
|
|
|
}
|
|
}
|
|
|
|
|
+ this.onprogress(new ProgressEvent(STAGE_TASK_STARTED, { pageURL: this.options.url, task: task.action }));
|
|
|
this.executeTask(task);
|
|
this.executeTask(task);
|
|
|
|
|
+ this.onprogress(new ProgressEvent(STAGE_TASK_ENDED, { pageURL: this.options.url, step, task: task.action }));
|
|
|
if (DEBUG) {
|
|
if (DEBUG) {
|
|
|
log(" -- ENDED task =", task.action, "delay =", Date.now() - startTime);
|
|
log(" -- ENDED task =", task.action, "delay =", Date.now() - startTime);
|
|
|
}
|
|
}
|
|
@@ -218,13 +225,16 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
startTime = Date.now();
|
|
startTime = Date.now();
|
|
|
log(" // STARTED task =", task.action);
|
|
log(" // STARTED task =", task.action);
|
|
|
}
|
|
}
|
|
|
|
|
+ this.onprogress(new ProgressEvent(STAGE_TASK_STARTED, { pageURL: this.options.url, task: task.action }));
|
|
|
const promise = this.executeTask(task);
|
|
const promise = this.executeTask(task);
|
|
|
|
|
+ promise.then(() => this.onprogress(new ProgressEvent(STAGE_TASK_ENDED, { pageURL: this.options.url, step, task: task.action })));
|
|
|
if (DEBUG) {
|
|
if (DEBUG) {
|
|
|
promise.then(() => log(" // ENDED task =", task.action, "delay =", Date.now() - startTime));
|
|
promise.then(() => log(" // ENDED task =", task.action, "delay =", Date.now() - startTime));
|
|
|
}
|
|
}
|
|
|
return promise;
|
|
return promise;
|
|
|
}));
|
|
}));
|
|
|
}
|
|
}
|
|
|
|
|
+ this.onprogress(new ProgressEvent(STAGE_ENDED, { pageURL: this.options.url, step }));
|
|
|
if (DEBUG) {
|
|
if (DEBUG) {
|
|
|
log("**** ENDED STAGE", step, "****");
|
|
log("**** ENDED STAGE", step, "****");
|
|
|
}
|
|
}
|