{"version":3,"sources":["src/CompletionTriggers/Variable.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD;;;;;;GAMG;AACH,qBAAa,QAAS,SAAQ,iBAAiB;IASjC,SAAS,CAAC,YAAY,CAAC,EAAE,MAAM;IAP3C;;;;;;OAMG;gBACmB,YAAY,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;IAIhD,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;CAe7C","file":"Variable.d.ts","sourcesContent":["'use strict';\n\nimport { CompletionTrigger } from './CompletionTrigger';\n\n/**\n * Waits for a variable to be true.\n *\n * @export\n * @class Variable\n * @extends {CompletionTrigger}\n */\nexport class Variable extends CompletionTrigger {\n\n  /**\n   * Creates an instance of the Variable CompletionTrigger.\n   * @param {string} [variableName] the variable to listen on.\n   *  Defaults to htmlPdfDone.\n   * @param {number} [timeout] ms to wait until timing out.\n   * @memberof Variable\n   */\n  constructor(protected variableName?: string, timeout?: number) {\n    super(timeout);\n  }\n\n  public async wait(client: any): Promise<any> {\n    const {Runtime} = client;\n    const varName = this.variableName || 'htmlPdfDone';\n    return Runtime.evaluate({\n      awaitPromise: true,\n      expression: `\n        new Promise((resolve, reject) => {\n          Object.defineProperty(window, '${varName}', {\n            set: (val) => { if (val === true) resolve(); }\n          });\n          setTimeout(() => reject('${this.timeoutMessage}'), ${this.timeout});\n        })`,\n    });\n  }\n\n}\n"],"sourceRoot":"../../.."}