consoleMessage.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.ConsoleMessage = void 0;
  6. var util = _interopRequireWildcard(require("util"));
  7. var _jsHandle = require("./jsHandle");
  8. var _page = require("./page");
  9. let _util$inspect$custom;
  10. /**
  11. * Copyright (c) Microsoft Corporation.
  12. *
  13. * Licensed under the Apache License, Version 2.0 (the "License");
  14. * you may not use this file except in compliance with the License.
  15. * You may obtain a copy of the License at
  16. *
  17. * http://www.apache.org/licenses/LICENSE-2.0
  18. *
  19. * Unless required by applicable law or agreed to in writing, software
  20. * distributed under the License is distributed on an "AS IS" BASIS,
  21. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  22. * See the License for the specific language governing permissions and
  23. * limitations under the License.
  24. */
  25. function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
  26. function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  27. _util$inspect$custom = util.inspect.custom;
  28. class ConsoleMessage {
  29. constructor(event) {
  30. this._page = void 0;
  31. this._event = void 0;
  32. this._page = event.page ? _page.Page.from(event.page) : null;
  33. this._event = event;
  34. }
  35. page() {
  36. return this._page;
  37. }
  38. type() {
  39. return this._event.type;
  40. }
  41. text() {
  42. return this._event.text;
  43. }
  44. args() {
  45. return this._event.args.map(_jsHandle.JSHandle.from);
  46. }
  47. location() {
  48. return this._event.location;
  49. }
  50. [_util$inspect$custom]() {
  51. return this.text();
  52. }
  53. }
  54. exports.ConsoleMessage = ConsoleMessage;