cdpSession.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. "use strict";
  2. var __defProp = Object.defineProperty;
  3. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  4. var __getOwnPropNames = Object.getOwnPropertyNames;
  5. var __hasOwnProp = Object.prototype.hasOwnProperty;
  6. var __export = (target, all) => {
  7. for (var name in all)
  8. __defProp(target, name, { get: all[name], enumerable: true });
  9. };
  10. var __copyProps = (to, from, except, desc) => {
  11. if (from && typeof from === "object" || typeof from === "function") {
  12. for (let key of __getOwnPropNames(from))
  13. if (!__hasOwnProp.call(to, key) && key !== except)
  14. __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  15. }
  16. return to;
  17. };
  18. var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  19. var cdpSession_exports = {};
  20. __export(cdpSession_exports, {
  21. CDPSession: () => CDPSession
  22. });
  23. module.exports = __toCommonJS(cdpSession_exports);
  24. var import_channelOwner = require("./channelOwner");
  25. class CDPSession extends import_channelOwner.ChannelOwner {
  26. static from(cdpSession) {
  27. return cdpSession._object;
  28. }
  29. constructor(parent, type, guid, initializer) {
  30. super(parent, type, guid, initializer);
  31. this._channel.on("event", ({ method, params }) => {
  32. this.emit(method, params);
  33. });
  34. this.on = super.on;
  35. this.addListener = super.addListener;
  36. this.off = super.removeListener;
  37. this.removeListener = super.removeListener;
  38. this.once = super.once;
  39. }
  40. async send(method, params) {
  41. const result = await this._channel.send({ method, params });
  42. return result.result;
  43. }
  44. async detach() {
  45. return await this._channel.detach();
  46. }
  47. }
  48. // Annotate the CommonJS export names for ESM import in node:
  49. 0 && (module.exports = {
  50. CDPSession
  51. });