Commit 416a8823 authored by Fred Chasen's avatar Fred Chasen

Add logger to polyfill

parent c706ce40
......@@ -31,7 +31,8 @@
"test": "node test/test.js",
"compile": "./node_modules/.bin/babel src/ -d lib/",
"pretest": "npm run build",
"prepare": "npm run build && npm run compile"
"prepare": "npm run build && npm run compile",
"watch": "./node_modules/.bin/rollup -w -c"
},
"repository": {
"type": "git",
......
......@@ -65,6 +65,8 @@ class Chunker {
if (content) {
return this.flow(content, styler);
}
return this;
}
async flow(content, styler) {
......@@ -195,6 +197,7 @@ class Chunker {
// section.create(this.sectionsTotal, this.total);
section.on("page", (page) => {
this.styles && this.styles.counters(this.pagesArea);
this.emit("page", page);
})
return section.render(sectionContent);
......
......@@ -58,6 +58,14 @@ ready.then(async function () {
// Chunk contents
let chunker = new Chunker(undefined, body, styles, preview);
let counter = 0;
chunker.on("page", () => {
counter += 1;
if (typeof window.PuppeteerLogger !== "undefined") {
window.PuppeteerLogger("page");
}
})
let startTime = performance.now();
// Render flow
......@@ -66,8 +74,6 @@ ready.then(async function () {
let endTime = performance.now();
let msg = "Rendering " + flow.total + " pages took " + (endTime - startTime) + " milliseconds.";
console.log(msg);
if (typeof window.onPagesRendered !== "undefined") {
window.onPagesRendered(msg, styles.width.value + styles.width.unit, styles.height.value + styles.height.unit, styles.orientation);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment