html-pdf-chrome
Version:
HTML to PDF and image converter via Chrome/Chromium
38 lines • 1.19 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.Callback = void 0;
const CompletionTrigger_1 = require("./CompletionTrigger");
/**
* Waits for a callback to be called.
*
* @export
* @class Callback
* @extends {CompletionTrigger}
*/
class Callback extends CompletionTrigger_1.CompletionTrigger {
/**
* Creates an instance of the Callback CompletionTrigger.
* @param {string} [callbackName] the name of the callback to listen for.
* Defaults to htmlPdfCb.
* @param {number} [timeout] ms to wait until timing out.
* @memberof Callback
*/
constructor(callbackName, timeout) {
super(timeout);
this.callbackName = callbackName;
}
async wait(client) {
const { Runtime } = client;
const cbName = this.callbackName || 'htmlPdfCb';
return Runtime.evaluate({
awaitPromise: true,
expression: `
new Promise((resolve, reject) => {
${cbName} = resolve;
setTimeout(() => reject('${this.timeoutMessage}'), ${this.timeout});
})`,
});
}
}
exports.Callback = Callback;
//# sourceMappingURL=Callback.js.map
;