single-file-core 1.3.32 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/index.js +2 -8
- package/package.json +1 -1
- package/single-file.js +4 -2
package/core/index.js
CHANGED
|
@@ -86,12 +86,10 @@ const RESOURCE_LOADED = "resource-loaded";
|
|
|
86
86
|
const PAGE_ENDED = "page-ended";
|
|
87
87
|
const STAGE_STARTED = "stage-started";
|
|
88
88
|
const STAGE_ENDED = "stage-ended";
|
|
89
|
-
const STAGE_TASK_STARTED = "stage-task-started";
|
|
90
|
-
const STAGE_TASK_ENDED = "stage-task-ended";
|
|
91
89
|
|
|
92
90
|
class ProgressEvent {
|
|
93
91
|
constructor(type, detail) {
|
|
94
|
-
return { type, detail, PAGE_LOADING, PAGE_LOADED, RESOURCES_INITIALIZING, RESOURCES_INITIALIZED, RESOURCE_LOADED, PAGE_ENDED, STAGE_STARTED, STAGE_ENDED
|
|
92
|
+
return { type, detail, PAGE_LOADING, PAGE_LOADED, RESOURCES_INITIALIZING, RESOURCES_INITIALIZED, RESOURCE_LOADED, PAGE_ENDED, STAGE_STARTED, STAGE_ENDED };
|
|
95
93
|
}
|
|
96
94
|
}
|
|
97
95
|
|
|
@@ -268,7 +266,7 @@ class Runner {
|
|
|
268
266
|
|
|
269
267
|
async getPageData() {
|
|
270
268
|
if (this.root) {
|
|
271
|
-
await this.onprogress(new ProgressEvent(PAGE_ENDED, { pageURL: this.options.url, options: this.options
|
|
269
|
+
await this.onprogress(new ProgressEvent(PAGE_ENDED, { pageURL: this.options.url, options: this.options }));
|
|
272
270
|
}
|
|
273
271
|
return this.processor.getPageData();
|
|
274
272
|
}
|
|
@@ -285,11 +283,9 @@ class Runner {
|
|
|
285
283
|
startTime = Date.now();
|
|
286
284
|
log(" -- STARTED task =", task.action);
|
|
287
285
|
}
|
|
288
|
-
await this.onprogress(new ProgressEvent(STAGE_TASK_STARTED, { pageURL: this.options.url, step, task: task.action, frame, options: this.options }));
|
|
289
286
|
if (!this.cancelled) {
|
|
290
287
|
this.executeTask(task);
|
|
291
288
|
}
|
|
292
|
-
await this.onprogress(new ProgressEvent(STAGE_TASK_ENDED, { pageURL: this.options.url, step, task: task.action, frame, options: this.options }));
|
|
293
289
|
if (DEBUG) {
|
|
294
290
|
log(" -- ENDED task =", task.action, "delay =", Date.now() - startTime);
|
|
295
291
|
}
|
|
@@ -302,11 +298,9 @@ class Runner {
|
|
|
302
298
|
startTime = Date.now();
|
|
303
299
|
log(" // STARTED task =", task.action);
|
|
304
300
|
}
|
|
305
|
-
await this.onprogress(new ProgressEvent(STAGE_TASK_STARTED, { pageURL: this.options.url, step, task: task.action, frame, options: this.options }));
|
|
306
301
|
if (!this.cancelled) {
|
|
307
302
|
await this.executeTask(task);
|
|
308
303
|
}
|
|
309
|
-
await this.onprogress(new ProgressEvent(STAGE_TASK_ENDED, { pageURL: this.options.url, step, task: task.action, frame, options: this.options }));
|
|
310
304
|
if (DEBUG) {
|
|
311
305
|
log(" // ENDED task =", task.action, "delay =", Date.now() - startTime);
|
|
312
306
|
}
|
package/package.json
CHANGED
package/single-file.js
CHANGED
|
@@ -90,12 +90,14 @@ async function getPageData(options = {}, initOptions, doc = globalThis.document,
|
|
|
90
90
|
options.insertCanonicalLink = true;
|
|
91
91
|
|
|
92
92
|
const externalOnProgress = options.onprogress;
|
|
93
|
-
options.onprogress = event => {
|
|
93
|
+
options.onprogress = async event => {
|
|
94
94
|
if (event.type === event.RESOURCES_INITIALIZED && doc && win && options.loadDeferredImages) {
|
|
95
95
|
processors.lazy.resetZoomLevel(options);
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
if (externalOnProgress)
|
|
98
|
+
if (externalOnProgress) {
|
|
99
|
+
await externalOnProgress(event);
|
|
100
|
+
}
|
|
99
101
|
};
|
|
100
102
|
|
|
101
103
|
const processor = new SingleFile(options);
|