patchright-core 1.51.3 → 1.52.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (303) hide show
  1. package/browsers.json +15 -13
  2. package/lib/androidServerImpl.js +42 -48
  3. package/lib/browserServerImpl.js +54 -67
  4. package/lib/cli/driver.js +71 -69
  5. package/lib/cli/program.js +312 -328
  6. package/lib/cli/programWithTestStub.js +51 -45
  7. package/lib/client/accessibility.js +31 -32
  8. package/lib/client/android.js +141 -228
  9. package/lib/client/api.js +135 -283
  10. package/lib/client/artifact.js +39 -36
  11. package/lib/client/browser.js +57 -61
  12. package/lib/client/browserContext.js +297 -326
  13. package/lib/client/browserType.js +92 -106
  14. package/lib/client/cdpSession.js +29 -31
  15. package/lib/client/channelOwner.js +82 -95
  16. package/lib/client/clientHelper.js +46 -38
  17. package/lib/client/clientInstrumentation.js +40 -37
  18. package/lib/client/clientStackTrace.js +41 -37
  19. package/lib/client/clock.js +36 -36
  20. package/lib/client/connection.js +190 -212
  21. package/lib/client/consoleMessage.js +31 -28
  22. package/lib/client/coverage.js +25 -22
  23. package/lib/client/dialog.js +30 -31
  24. package/lib/client/download.js +25 -25
  25. package/lib/client/electron.js +73 -75
  26. package/lib/client/elementHandle.js +111 -147
  27. package/lib/client/errors.js +53 -53
  28. package/lib/client/eventEmitter.js +124 -121
  29. package/lib/client/events.js +72 -68
  30. package/lib/client/fetch.js +135 -158
  31. package/lib/client/fileChooser.js +25 -24
  32. package/lib/client/fileUtils.js +31 -28
  33. package/lib/client/frame.js +187 -306
  34. package/lib/client/harRouter.js +42 -52
  35. package/lib/client/input.js +40 -69
  36. package/lib/client/jsHandle.js +56 -71
  37. package/lib/client/jsonPipe.js +27 -23
  38. package/lib/client/localUtils.js +29 -28
  39. package/lib/client/locator.js +161 -245
  40. package/lib/client/network.js +277 -295
  41. package/lib/client/page.js +270 -318
  42. package/lib/client/platform.js +46 -43
  43. package/lib/client/playwright.js +51 -66
  44. package/lib/client/selectors.js +48 -46
  45. package/lib/client/stream.js +29 -25
  46. package/lib/client/timeoutSettings.js +49 -39
  47. package/lib/client/tracing.js +48 -84
  48. package/lib/client/types.js +26 -22
  49. package/lib/client/video.js +35 -27
  50. package/lib/client/waiter.js +69 -88
  51. package/lib/client/webError.js +25 -23
  52. package/lib/client/webSocket.js +61 -56
  53. package/lib/client/worker.js +48 -58
  54. package/lib/client/writableStream.js +27 -23
  55. package/lib/generated/clockSource.js +26 -5
  56. package/lib/generated/consoleApiSource.js +26 -5
  57. package/lib/generated/injectedScriptSource.js +26 -5
  58. package/lib/generated/pollingRecorderSource.js +26 -5
  59. package/lib/generated/utilityScriptSource.js +26 -5
  60. package/lib/generated/webSocketMockSource.js +371 -4
  61. package/lib/inProcessFactory.js +53 -53
  62. package/lib/inprocess.js +2 -19
  63. package/lib/outofprocess.js +53 -46
  64. package/lib/protocol/debug.js +209 -25
  65. package/lib/protocol/serializers.js +153 -134
  66. package/lib/protocol/validator.js +2714 -2714
  67. package/lib/protocol/validatorPrimitives.js +114 -73
  68. package/lib/remote/playwrightConnection.js +140 -157
  69. package/lib/remote/playwrightServer.js +99 -84
  70. package/lib/server/accessibility.js +44 -37
  71. package/lib/server/android/android.js +216 -209
  72. package/lib/server/android/backendAdb.js +89 -82
  73. package/lib/server/artifact.js +78 -55
  74. package/lib/server/bidi/bidiBrowser.js +221 -155
  75. package/lib/server/bidi/bidiChromium.js +106 -79
  76. package/lib/server/bidi/bidiConnection.js +66 -83
  77. package/lib/server/bidi/bidiExecutionContext.js +128 -113
  78. package/lib/server/bidi/bidiFirefox.js +76 -69
  79. package/lib/server/bidi/bidiInput.js +86 -97
  80. package/lib/server/bidi/bidiNetworkManager.js +137 -154
  81. package/lib/server/bidi/bidiOverCdp.js +57 -58
  82. package/lib/server/bidi/bidiPage.js +247 -219
  83. package/lib/server/bidi/bidiPdf.js +52 -86
  84. package/lib/server/bidi/third_party/bidiCommands.d.js +22 -0
  85. package/lib/server/bidi/third_party/bidiDeserializer.js +55 -50
  86. package/lib/server/bidi/third_party/bidiKeyboard.js +236 -220
  87. package/lib/server/bidi/third_party/bidiProtocol.js +144 -131
  88. package/lib/server/bidi/third_party/bidiSerializer.js +67 -63
  89. package/lib/server/bidi/third_party/firefoxPrefs.js +141 -119
  90. package/lib/server/browser.js +76 -84
  91. package/lib/server/browserContext.js +321 -346
  92. package/lib/server/browserType.js +169 -182
  93. package/lib/server/callLog.js +47 -44
  94. package/lib/server/chromium/chromium.js +212 -190
  95. package/lib/server/chromium/chromiumSwitches.js +86 -64
  96. package/lib/server/chromium/crAccessibility.js +157 -131
  97. package/lib/server/chromium/crBrowser.js +253 -273
  98. package/lib/server/chromium/crConnection.js +91 -116
  99. package/lib/server/chromium/crCoverage.js +113 -127
  100. package/lib/server/chromium/crDevTools.js +59 -51
  101. package/lib/server/chromium/crDragDrop.js +62 -79
  102. package/lib/server/chromium/crExecutionContext.js +88 -83
  103. package/lib/server/chromium/crInput.js +97 -95
  104. package/lib/server/chromium/crNetworkManager.js +284 -404
  105. package/lib/server/chromium/crPage.js +522 -608
  106. package/lib/server/chromium/crPdf.js +54 -86
  107. package/lib/server/chromium/crProtocolHelper.js +92 -80
  108. package/lib/server/chromium/crServiceWorker.js +82 -67
  109. package/lib/server/chromium/defaultFontFamilies.js +152 -135
  110. package/lib/server/chromium/protocol.d.js +16 -0
  111. package/lib/server/chromium/videoRecorder.js +65 -99
  112. package/lib/server/clock.js +62 -50
  113. package/lib/server/codegen/csharp.js +185 -160
  114. package/lib/server/codegen/java.js +155 -128
  115. package/lib/server/codegen/javascript.js +163 -148
  116. package/lib/server/codegen/jsonl.js +32 -28
  117. package/lib/server/codegen/language.js +75 -52
  118. package/lib/server/codegen/languages.js +65 -27
  119. package/lib/server/codegen/python.js +140 -125
  120. package/lib/server/codegen/types.js +15 -4
  121. package/lib/server/console.js +28 -32
  122. package/lib/server/cookieStore.js +105 -86
  123. package/lib/server/debugController.js +97 -124
  124. package/lib/server/debugger.js +82 -78
  125. package/lib/server/deviceDescriptors.js +37 -24
  126. package/lib/server/deviceDescriptorsSource.json +50 -50
  127. package/lib/server/dialog.js +36 -35
  128. package/lib/server/dispatchers/androidDispatcher.js +196 -107
  129. package/lib/server/dispatchers/artifactDispatcher.js +62 -62
  130. package/lib/server/dispatchers/browserContextDispatcher.js +176 -205
  131. package/lib/server/dispatchers/browserDispatcher.js +78 -97
  132. package/lib/server/dispatchers/browserTypeDispatcher.js +35 -35
  133. package/lib/server/dispatchers/cdpSessionDispatcher.js +32 -36
  134. package/lib/server/dispatchers/debugControllerDispatcher.js +48 -66
  135. package/lib/server/dispatchers/dialogDispatcher.js +30 -27
  136. package/lib/server/dispatchers/dispatcher.js +169 -220
  137. package/lib/server/dispatchers/electronDispatcher.js +54 -57
  138. package/lib/server/dispatchers/elementHandlerDispatcher.js +77 -119
  139. package/lib/server/dispatchers/frameDispatcher.js +99 -163
  140. package/lib/server/dispatchers/jsHandleDispatcher.js +49 -66
  141. package/lib/server/dispatchers/jsonPipeDispatcher.js +35 -36
  142. package/lib/server/dispatchers/localUtilsDispatcher.js +95 -80
  143. package/lib/server/dispatchers/networkDispatchers.js +90 -107
  144. package/lib/server/dispatchers/pageDispatcher.js +128 -169
  145. package/lib/server/dispatchers/playwrightDispatcher.js +69 -76
  146. package/lib/server/dispatchers/selectorsDispatcher.js +28 -24
  147. package/lib/server/dispatchers/streamDispatcher.js +42 -45
  148. package/lib/server/dispatchers/tracingDispatcher.js +36 -41
  149. package/lib/server/dispatchers/webSocketRouteDispatcher.js +96 -131
  150. package/lib/server/dispatchers/writableStreamDispatcher.js +54 -38
  151. package/lib/server/dom.js +413 -443
  152. package/lib/server/download.js +45 -35
  153. package/lib/server/electron/electron.js +156 -176
  154. package/lib/server/electron/loader.js +8 -36
  155. package/lib/server/errors.js +47 -46
  156. package/lib/server/fetch.js +289 -323
  157. package/lib/server/fileChooser.js +25 -24
  158. package/lib/server/fileUploadUtils.js +65 -59
  159. package/lib/server/firefox/ffAccessibility.js +153 -131
  160. package/lib/server/firefox/ffBrowser.js +213 -277
  161. package/lib/server/firefox/ffConnection.js +63 -84
  162. package/lib/server/firefox/ffExecutionContext.js +91 -73
  163. package/lib/server/firefox/ffInput.js +67 -69
  164. package/lib/server/firefox/ffNetworkManager.js +131 -110
  165. package/lib/server/firefox/ffPage.js +236 -273
  166. package/lib/server/firefox/firefox.js +76 -67
  167. package/lib/server/firefox/protocol.d.js +16 -0
  168. package/lib/server/formData.js +107 -35
  169. package/lib/server/frameSelectors.js +221 -112
  170. package/lib/server/frames.js +731 -894
  171. package/lib/server/har/harRecorder.js +85 -77
  172. package/lib/server/har/harTracer.js +287 -222
  173. package/lib/server/harBackend.js +80 -80
  174. package/lib/server/helper.js +56 -59
  175. package/lib/server/index.js +59 -99
  176. package/lib/server/input.js +134 -163
  177. package/lib/server/instrumentation.js +49 -44
  178. package/lib/server/javascript.js +143 -134
  179. package/lib/server/launchApp.js +92 -73
  180. package/lib/server/localUtils.js +130 -122
  181. package/lib/server/macEditingCommands.js +141 -137
  182. package/lib/server/network.js +262 -296
  183. package/lib/server/page.js +326 -423
  184. package/lib/server/pageBinding.js +88 -0
  185. package/lib/server/pipeTransport.js +49 -45
  186. package/lib/server/playwright.js +60 -67
  187. package/lib/server/progress.js +56 -51
  188. package/lib/server/protocolError.js +34 -31
  189. package/lib/server/recorder/chat.js +70 -86
  190. package/lib/server/recorder/contextRecorder.js +134 -138
  191. package/lib/server/recorder/recorderApp.js +127 -136
  192. package/lib/server/recorder/recorderCollection.js +56 -44
  193. package/lib/server/recorder/recorderFrontend.js +15 -4
  194. package/lib/server/recorder/recorderRunner.js +79 -103
  195. package/lib/server/recorder/recorderUtils.js +56 -45
  196. package/lib/server/recorder/throttledFile.js +42 -30
  197. package/lib/server/recorder.js +177 -186
  198. package/lib/server/registry/browserFetcher.js +106 -101
  199. package/lib/server/registry/dependencies.js +245 -196
  200. package/lib/server/registry/index.js +904 -792
  201. package/lib/server/registry/nativeDeps.js +1073 -464
  202. package/lib/server/registry/oopDownloadBrowserMain.js +57 -75
  203. package/lib/server/screenshotter.js +166 -182
  204. package/lib/server/selectors.js +85 -46
  205. package/lib/server/socksClientCertificatesInterceptor.js +166 -185
  206. package/lib/server/socksInterceptor.js +62 -70
  207. package/lib/server/storageScript.js +94 -100
  208. package/lib/server/timeoutSettings.js +58 -43
  209. package/lib/server/trace/recorder/snapshotter.js +70 -89
  210. package/lib/server/trace/recorder/snapshotterInjected.js +238 -217
  211. package/lib/server/trace/recorder/tracing.js +321 -333
  212. package/lib/server/trace/test/inMemorySnapshotter.js +46 -52
  213. package/lib/server/trace/viewer/traceViewer.js +168 -146
  214. package/lib/server/transport.js +124 -133
  215. package/lib/server/types.js +26 -22
  216. package/lib/server/usKeyboardLayout.js +135 -545
  217. package/lib/server/utils/ascii.js +39 -26
  218. package/lib/server/utils/comparators.js +105 -103
  219. package/lib/server/utils/crypto.js +157 -112
  220. package/lib/server/utils/debug.js +37 -28
  221. package/lib/server/utils/debugLogger.js +69 -48
  222. package/lib/server/utils/env.js +52 -37
  223. package/lib/server/utils/eventsHelper.js +29 -28
  224. package/lib/server/utils/expectUtils.js +31 -26
  225. package/lib/server/utils/fileUtils.js +123 -136
  226. package/lib/server/utils/happyEyeballs.js +138 -123
  227. package/lib/server/utils/hostPlatform.js +84 -120
  228. package/lib/server/utils/httpServer.js +106 -121
  229. package/lib/server/utils/image_tools/colorUtils.js +42 -51
  230. package/lib/server/utils/image_tools/compare.js +44 -43
  231. package/lib/server/utils/image_tools/imageChannel.js +38 -30
  232. package/lib/server/utils/image_tools/stats.js +40 -40
  233. package/lib/server/utils/linuxUtils.js +50 -37
  234. package/lib/server/utils/network.js +143 -86
  235. package/lib/server/utils/nodePlatform.js +87 -79
  236. package/lib/server/utils/pipeTransport.js +44 -42
  237. package/lib/server/utils/processLauncher.js +111 -121
  238. package/lib/server/utils/profiler.js +52 -39
  239. package/lib/server/utils/socksProxy.js +280 -339
  240. package/lib/server/utils/spawnAsync.js +37 -41
  241. package/lib/server/utils/task.js +31 -38
  242. package/lib/server/utils/userAgent.js +73 -66
  243. package/lib/server/utils/wsServer.js +73 -69
  244. package/lib/server/utils/zipFile.js +36 -37
  245. package/lib/server/utils/zones.js +37 -34
  246. package/lib/server/webkit/protocol.d.js +16 -0
  247. package/lib/server/webkit/webkit.js +76 -63
  248. package/lib/server/webkit/wkAccessibility.js +161 -118
  249. package/lib/server/webkit/wkBrowser.js +159 -176
  250. package/lib/server/webkit/wkConnection.js +59 -83
  251. package/lib/server/webkit/wkExecutionContext.js +84 -70
  252. package/lib/server/webkit/wkInput.js +82 -80
  253. package/lib/server/webkit/wkInterceptableRequest.js +102 -95
  254. package/lib/server/webkit/wkPage.js +525 -619
  255. package/lib/server/webkit/wkProvisionalPage.js +45 -56
  256. package/lib/server/webkit/wkWorkers.js +77 -77
  257. package/lib/utils/isomorphic/ariaSnapshot.js +144 -152
  258. package/lib/utils/isomorphic/assert.js +28 -22
  259. package/lib/utils/isomorphic/builtins.js +86 -0
  260. package/lib/utils/isomorphic/colors.js +66 -59
  261. package/lib/utils/isomorphic/cssParser.js +121 -125
  262. package/lib/utils/isomorphic/cssTokenizer.js +436 -364
  263. package/lib/utils/isomorphic/headers.js +38 -37
  264. package/lib/utils/isomorphic/locatorGenerators.js +340 -357
  265. package/lib/utils/isomorphic/locatorParser.js +96 -105
  266. package/lib/utils/isomorphic/locatorUtils.js +63 -44
  267. package/lib/utils/isomorphic/manualPromise.js +47 -39
  268. package/lib/utils/isomorphic/mimeType.js +448 -25
  269. package/lib/utils/isomorphic/multimap.js +35 -27
  270. package/lib/utils/isomorphic/rtti.js +35 -33
  271. package/lib/utils/isomorphic/selectorParser.js +183 -193
  272. package/lib/utils/isomorphic/semaphore.js +27 -24
  273. package/lib/utils/isomorphic/stackTrace.js +87 -98
  274. package/lib/utils/isomorphic/stringUtils.js +113 -106
  275. package/lib/utils/isomorphic/time.js +41 -22
  276. package/lib/utils/isomorphic/timeoutRunner.js +55 -54
  277. package/lib/utils/isomorphic/traceUtils.js +38 -41
  278. package/lib/utils/isomorphic/types.js +15 -4
  279. package/lib/utils/isomorphic/urlMatch.js +112 -67
  280. package/lib/utils/isomorphic/utilityScriptSerializers.js +248 -0
  281. package/lib/utils.js +97 -443
  282. package/lib/utilsBundle.js +101 -52
  283. package/lib/vite/htmlReport/index.html +21 -15
  284. package/lib/vite/recorder/assets/{codeMirrorModule-B9YMkrwa.js → codeMirrorModule-CXVeovup.js} +1 -1
  285. package/lib/vite/recorder/assets/index-BsWQsSGl.js +184 -0
  286. package/lib/vite/recorder/index.html +1 -1
  287. package/lib/vite/traceViewer/assets/{codeMirrorModule-1DiydmYA.js → codeMirrorModule-_GLjJL-7.js} +1 -1
  288. package/lib/vite/traceViewer/assets/defaultSettingsView-DtCQiGHe.js +265 -0
  289. package/lib/vite/traceViewer/{defaultSettingsView.5fN5lw10.css → defaultSettingsView.QdHITyLI.css} +1 -1
  290. package/lib/vite/traceViewer/index.cFZzK9RN.js +2 -0
  291. package/lib/vite/traceViewer/index.html +3 -3
  292. package/lib/vite/traceViewer/sw.bundle.js +3 -3
  293. package/lib/vite/traceViewer/uiMode.XVPIqBeS.js +5 -0
  294. package/lib/vite/traceViewer/uiMode.html +3 -3
  295. package/lib/zipBundle.js +32 -23
  296. package/package.json +1 -1
  297. package/types/protocol.d.ts +436 -17
  298. package/types/types.d.ts +35 -16
  299. package/lib/server/isomorphic/utilityScriptSerializers.js +0 -229
  300. package/lib/vite/recorder/assets/index-ELPgmkwA.js +0 -184
  301. package/lib/vite/traceViewer/assets/defaultSettingsView-l0TyP_G8.js +0 -259
  302. package/lib/vite/traceViewer/index.BqUZLSro.js +0 -2
  303. package/lib/vite/traceViewer/uiMode.C1d2m5sF.js +0 -5
@@ -1,111 +1,94 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
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 crConnection_exports = {};
20
+ __export(crConnection_exports, {
21
+ CDPSession: () => CDPSession,
22
+ CRConnection: () => CRConnection,
23
+ CRSession: () => CRSession,
24
+ ConnectionEvents: () => ConnectionEvents,
25
+ kBrowserCloseMessageId: () => kBrowserCloseMessageId
5
26
  });
6
- exports.kBrowserCloseMessageId = exports.ConnectionEvents = exports.CRSession = exports.CRConnection = exports.CDPSession = void 0;
7
- var _events = require("events");
8
- var _utils = require("../../utils");
9
- var _debugLogger = require("../utils/debugLogger");
10
- var _helper = require("../helper");
11
- var _protocolError = require("../protocolError");
12
- /**
13
- * Copyright 2017 Google Inc. All rights reserved.
14
- * Modifications copyright (c) Microsoft Corporation.
15
- *
16
- * Licensed under the Apache License, Version 2.0 (the "License");
17
- * you may not use this file except in compliance with the License.
18
- * You may obtain a copy of the License at
19
- *
20
- * http://www.apache.org/licenses/LICENSE-2.0
21
- *
22
- * Unless required by applicable law or agreed to in writing, software
23
- * distributed under the License is distributed on an "AS IS" BASIS,
24
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25
- * See the License for the specific language governing permissions and
26
- * limitations under the License.
27
- */
28
-
29
- const ConnectionEvents = exports.ConnectionEvents = {
30
- Disconnected: Symbol('ConnectionEvents.Disconnected')
27
+ module.exports = __toCommonJS(crConnection_exports);
28
+ var import_events = require("events");
29
+ var import_utils = require("../../utils");
30
+ var import_debugLogger = require("../utils/debugLogger");
31
+ var import_helper = require("../helper");
32
+ var import_protocolError = require("../protocolError");
33
+ const ConnectionEvents = {
34
+ Disconnected: Symbol("ConnectionEvents.Disconnected")
31
35
  };
32
-
33
- // CRPlaywright uses this special id to issue Browser.close command which we
34
- // should ignore.
35
- const kBrowserCloseMessageId = exports.kBrowserCloseMessageId = -9999;
36
- class CRConnection extends _events.EventEmitter {
36
+ const kBrowserCloseMessageId = -9999;
37
+ class CRConnection extends import_events.EventEmitter {
37
38
  constructor(transport, protocolLogger, browserLogsCollector) {
38
39
  super();
39
40
  this._lastId = 0;
40
- this._transport = void 0;
41
- this._sessions = new Map();
42
- this._protocolLogger = void 0;
43
- this._browserLogsCollector = void 0;
44
- this._browserDisconnectedLogs = void 0;
45
- this.rootSession = void 0;
41
+ this._sessions = /* @__PURE__ */ new Map();
46
42
  this._closed = false;
47
43
  this.setMaxListeners(0);
48
44
  this._transport = transport;
49
45
  this._protocolLogger = protocolLogger;
50
46
  this._browserLogsCollector = browserLogsCollector;
51
- this.rootSession = new CRSession(this, null, '');
52
- this._sessions.set('', this.rootSession);
47
+ this.rootSession = new CRSession(this, null, "");
48
+ this._sessions.set("", this.rootSession);
53
49
  this._transport.onmessage = this._onMessage.bind(this);
54
- // onclose should be set last, since it can be immediately called.
55
50
  this._transport.onclose = this._onClose.bind(this);
56
51
  }
57
52
  _rawSend(sessionId, method, params) {
58
53
  const id = ++this._lastId;
59
- const message = {
60
- id,
61
- method,
62
- params
63
- };
64
- if (sessionId) message.sessionId = sessionId;
65
- this._protocolLogger('send', message);
54
+ const message = { id, method, params };
55
+ if (sessionId)
56
+ message.sessionId = sessionId;
57
+ this._protocolLogger("send", message);
66
58
  this._transport.send(message);
67
59
  return id;
68
60
  }
69
61
  async _onMessage(message) {
70
- this._protocolLogger('receive', message);
71
- if (message.id === kBrowserCloseMessageId) return;
72
- const session = this._sessions.get(message.sessionId || '');
73
- if (session) session._onMessage(message);
62
+ this._protocolLogger("receive", message);
63
+ if (message.id === kBrowserCloseMessageId)
64
+ return;
65
+ const session = this._sessions.get(message.sessionId || "");
66
+ if (session)
67
+ session._onMessage(message);
74
68
  }
75
69
  _onClose(reason) {
76
70
  this._closed = true;
77
- this._transport.onmessage = undefined;
78
- this._transport.onclose = undefined;
79
- this._browserDisconnectedLogs = _helper.helper.formatBrowserLogs(this._browserLogsCollector.recentLogs(), reason);
71
+ this._transport.onmessage = void 0;
72
+ this._transport.onclose = void 0;
73
+ this._browserDisconnectedLogs = import_helper.helper.formatBrowserLogs(this._browserLogsCollector.recentLogs(), reason);
80
74
  this.rootSession.dispose();
81
75
  Promise.resolve().then(() => this.emit(ConnectionEvents.Disconnected));
82
76
  }
83
77
  close() {
84
- if (!this._closed) this._transport.close();
78
+ if (!this._closed)
79
+ this._transport.close();
85
80
  }
86
81
  async createBrowserSession() {
87
- const {
88
- sessionId
89
- } = await this.rootSession.send('Target.attachToBrowserTarget');
82
+ const { sessionId } = await this.rootSession.send("Target.attachToBrowserTarget");
90
83
  return new CDPSession(this.rootSession, sessionId);
91
84
  }
92
85
  }
93
- exports.CRConnection = CRConnection;
94
- class CRSession extends _events.EventEmitter {
86
+ class CRSession extends import_events.EventEmitter {
95
87
  constructor(connection, parentSession, sessionId, eventListener) {
96
88
  super();
97
- this._connection = void 0;
98
- this._eventListener = void 0;
99
- this._callbacks = new Map();
100
- this._sessionId = void 0;
101
- this._parentSession = void 0;
89
+ this._callbacks = /* @__PURE__ */ new Map();
102
90
  this._crashed = false;
103
91
  this._closed = false;
104
- this.on = void 0;
105
- this.addListener = void 0;
106
- this.off = void 0;
107
- this.removeListener = void 0;
108
- this.once = void 0;
109
92
  this.setMaxListeners(0);
110
93
  this._connection = connection;
111
94
  this._parentSession = parentSession;
@@ -126,21 +109,17 @@ class CRSession extends _events.EventEmitter {
126
109
  return session;
127
110
  }
128
111
  async send(method, params) {
129
- if (this._crashed || this._closed || this._connection._closed || this._connection._browserDisconnectedLogs) throw new _protocolError.ProtocolError(this._crashed ? 'crashed' : 'closed', undefined, this._connection._browserDisconnectedLogs);
112
+ if (this._crashed || this._closed || this._connection._closed || this._connection._browserDisconnectedLogs)
113
+ throw new import_protocolError.ProtocolError(this._crashed ? "crashed" : "closed", void 0, this._connection._browserDisconnectedLogs);
130
114
  const id = this._connection._rawSend(this._sessionId, method, params);
131
115
  return new Promise((resolve, reject) => {
132
- this._callbacks.set(id, {
133
- resolve,
134
- reject,
135
- error: new _protocolError.ProtocolError('error', method)
136
- });
116
+ this._callbacks.set(id, { resolve, reject, error: new import_protocolError.ProtocolError("error", method) });
137
117
  });
138
118
  }
139
119
  _sendMayFail(method, params) {
140
- return this.send(method, params).catch(error => _debugLogger.debugLogger.log('error', error));
120
+ return this.send(method, params).catch((error) => import_debugLogger.debugLogger.log("error", error));
141
121
  }
142
122
  _onMessage(object) {
143
- var _object$error;
144
123
  if (object.id && this._callbacks.has(object.id)) {
145
124
  const callback = this._callbacks.get(object.id);
146
125
  this._callbacks.delete(object.id);
@@ -150,26 +129,23 @@ class CRSession extends _events.EventEmitter {
150
129
  } else {
151
130
  callback.resolve(object.result);
152
131
  }
153
- } else if (object.id && ((_object$error = object.error) === null || _object$error === void 0 ? void 0 : _object$error.code) === -32001) {
154
- // Message to a closed session, just ignore it.
132
+ } else if (object.id && object.error?.code === -32001) {
155
133
  } else {
156
- var _object$error2;
157
- (0, _utils.assert)(!object.id, (object === null || object === void 0 || (_object$error2 = object.error) === null || _object$error2 === void 0 ? void 0 : _object$error2.message) || undefined);
134
+ (0, import_utils.assert)(!object.id, object?.error?.message || void 0);
158
135
  Promise.resolve().then(() => {
159
- if (this._eventListener) this._eventListener(object.method, object.params);
136
+ if (this._eventListener)
137
+ this._eventListener(object.method, object.params);
160
138
  this.emit(object.method, object.params);
161
139
  });
162
140
  }
163
141
  }
164
142
  async detach() {
165
- if (this._closed) throw new Error(`Session already detached. Most likely the page has been closed.`);
166
- if (!this._parentSession) throw new Error('Root session cannot be closed');
167
- // Ideally, detaching should resume any target, but there is a bug in the backend,
168
- // so we must Runtime.runIfWaitingForDebugger first.
169
- await this._sendMayFail('Runtime.runIfWaitingForDebugger');
170
- await this._parentSession.send('Target.detachFromTarget', {
171
- sessionId: this._sessionId
172
- });
143
+ if (this._closed)
144
+ throw new Error(`Session already detached. Most likely the page has been closed.`);
145
+ if (!this._parentSession)
146
+ throw new Error("Root session cannot be closed");
147
+ await this._sendMayFail("Runtime.runIfWaitingForDebugger");
148
+ await this._parentSession.send("Target.detachFromTarget", { sessionId: this._sessionId });
173
149
  this.dispose();
174
150
  }
175
151
  dispose() {
@@ -177,29 +153,30 @@ class CRSession extends _events.EventEmitter {
177
153
  this._connection._sessions.delete(this._sessionId);
178
154
  for (const callback of this._callbacks.values()) {
179
155
  callback.error.setMessage(`Internal server error, session closed.`);
180
- callback.error.type = this._crashed ? 'crashed' : 'closed';
156
+ callback.error.type = this._crashed ? "crashed" : "closed";
181
157
  callback.error.logs = this._connection._browserDisconnectedLogs;
182
158
  callback.reject(callback.error);
183
159
  }
184
160
  this._callbacks.clear();
185
161
  }
186
162
  }
187
- exports.CRSession = CRSession;
188
- class CDPSession extends _events.EventEmitter {
163
+ class CDPSession extends import_events.EventEmitter {
189
164
  constructor(parentSession, sessionId) {
190
165
  super();
191
- this.guid = void 0;
192
- this._session = void 0;
193
166
  this._listeners = [];
194
167
  this.guid = `cdp-session@${sessionId}`;
195
- this._session = parentSession.createChildSession(sessionId, (method, params) => this.emit(CDPSession.Events.Event, {
196
- method,
197
- params
198
- }));
199
- this._listeners = [_utils.eventsHelper.addEventListener(parentSession, 'Target.detachedFromTarget', event => {
200
- if (event.sessionId === sessionId) this._onClose();
168
+ this._session = parentSession.createChildSession(sessionId, (method, params) => this.emit(CDPSession.Events.Event, { method, params }));
169
+ this._listeners = [import_utils.eventsHelper.addEventListener(parentSession, "Target.detachedFromTarget", (event) => {
170
+ if (event.sessionId === sessionId)
171
+ this._onClose();
201
172
  })];
202
173
  }
174
+ static {
175
+ this.Events = {
176
+ Event: "event",
177
+ Closed: "close"
178
+ };
179
+ }
203
180
  async send(method, params) {
204
181
  return await this._session.send(method, params);
205
182
  }
@@ -207,22 +184,20 @@ class CDPSession extends _events.EventEmitter {
207
184
  return await this._session.detach();
208
185
  }
209
186
  async attachToTarget(targetId) {
210
- const {
211
- sessionId
212
- } = await this.send('Target.attachToTarget', {
213
- targetId,
214
- flatten: true
215
- });
187
+ const { sessionId } = await this.send("Target.attachToTarget", { targetId, flatten: true });
216
188
  return new CDPSession(this._session, sessionId);
217
189
  }
218
190
  _onClose() {
219
- _utils.eventsHelper.removeEventListeners(this._listeners);
191
+ import_utils.eventsHelper.removeEventListeners(this._listeners);
220
192
  this._session.dispose();
221
193
  this.emit(CDPSession.Events.Closed);
222
194
  }
223
195
  }
224
- exports.CDPSession = CDPSession;
225
- CDPSession.Events = {
226
- Event: 'event',
227
- Closed: 'close'
228
- };
196
+ // Annotate the CommonJS export names for ESM import in node:
197
+ 0 && (module.exports = {
198
+ CDPSession,
199
+ CRConnection,
200
+ CRSession,
201
+ ConnectionEvents,
202
+ kBrowserCloseMessageId
203
+ });
@@ -1,32 +1,30 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
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 crCoverage_exports = {};
20
+ __export(crCoverage_exports, {
21
+ CRCoverage: () => CRCoverage
5
22
  });
6
- exports.CRCoverage = void 0;
7
- var _utils = require("../../utils");
8
- var _eventsHelper = require("../utils/eventsHelper");
9
- /**
10
- * Copyright 2017 Google Inc. All rights reserved.
11
- * Modifications 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
-
23
+ module.exports = __toCommonJS(crCoverage_exports);
24
+ var import_utils = require("../../utils");
25
+ var import_eventsHelper = require("../utils/eventsHelper");
26
26
  class CRCoverage {
27
27
  constructor(client) {
28
- this._jsCoverage = void 0;
29
- this._cssCoverage = void 0;
30
28
  this._jsCoverage = new JSCoverage(client);
31
29
  this._cssCoverage = new CSSCoverage(client);
32
30
  }
@@ -43,25 +41,18 @@ class CRCoverage {
43
41
  return await this._cssCoverage.stop();
44
42
  }
45
43
  }
46
- exports.CRCoverage = CRCoverage;
47
44
  class JSCoverage {
48
45
  constructor(client) {
49
- this._client = void 0;
50
- this._enabled = void 0;
51
- this._scriptIds = void 0;
52
- this._scriptSources = void 0;
53
- this._eventListeners = void 0;
54
- this._resetOnNavigation = void 0;
55
46
  this._reportAnonymousScripts = false;
56
47
  this._client = client;
57
48
  this._enabled = false;
58
- this._scriptIds = new Set();
59
- this._scriptSources = new Map();
49
+ this._scriptIds = /* @__PURE__ */ new Set();
50
+ this._scriptSources = /* @__PURE__ */ new Map();
60
51
  this._eventListeners = [];
61
52
  this._resetOnNavigation = false;
62
53
  }
63
54
  async start(options) {
64
- (0, _utils.assert)(!this._enabled, 'JSCoverage is already enabled');
55
+ (0, import_utils.assert)(!this._enabled, "JSCoverage is already enabled");
65
56
  const {
66
57
  resetOnNavigation = true,
67
58
  reportAnonymousScripts = false
@@ -71,106 +62,112 @@ class JSCoverage {
71
62
  this._enabled = true;
72
63
  this._scriptIds.clear();
73
64
  this._scriptSources.clear();
74
- this._eventListeners = [_eventsHelper.eventsHelper.addEventListener(this._client, 'Debugger.scriptParsed', this._onScriptParsed.bind(this)), _eventsHelper.eventsHelper.addEventListener(this._client, 'Runtime.executionContextsCleared', this._onExecutionContextsCleared.bind(this)), _eventsHelper.eventsHelper.addEventListener(this._client, 'Debugger.paused', this._onDebuggerPaused.bind(this))];
75
- await Promise.all([this._client.send('Profiler.enable'), this._client.send('Profiler.startPreciseCoverage', {
76
- callCount: true,
77
- detailed: true
78
- }), this._client.send('Debugger.enable'), this._client.send('Debugger.setSkipAllPauses', {
79
- skip: true
80
- })]);
65
+ this._eventListeners = [
66
+ import_eventsHelper.eventsHelper.addEventListener(this._client, "Debugger.scriptParsed", this._onScriptParsed.bind(this)),
67
+ import_eventsHelper.eventsHelper.addEventListener(this._client, "Runtime.executionContextsCleared", this._onExecutionContextsCleared.bind(this)),
68
+ import_eventsHelper.eventsHelper.addEventListener(this._client, "Debugger.paused", this._onDebuggerPaused.bind(this))
69
+ ];
70
+ await Promise.all([
71
+ this._client.send("Profiler.enable"),
72
+ this._client.send("Profiler.startPreciseCoverage", { callCount: true, detailed: true }),
73
+ this._client.send("Debugger.enable"),
74
+ this._client.send("Debugger.setSkipAllPauses", { skip: true })
75
+ ]);
81
76
  }
82
77
  _onDebuggerPaused() {
83
- this._client.send('Debugger.resume');
78
+ this._client.send("Debugger.resume");
84
79
  }
85
80
  _onExecutionContextsCleared() {
86
- if (!this._resetOnNavigation) return;
81
+ if (!this._resetOnNavigation)
82
+ return;
87
83
  this._scriptIds.clear();
88
84
  this._scriptSources.clear();
89
85
  }
90
86
  async _onScriptParsed(event) {
91
87
  this._scriptIds.add(event.scriptId);
92
- // Ignore other anonymous scripts unless the reportAnonymousScripts option is true.
93
- if (!event.url && !this._reportAnonymousScripts) return;
94
- // This might fail if the page has already navigated away.
95
- const response = await this._client._sendMayFail('Debugger.getScriptSource', {
96
- scriptId: event.scriptId
97
- });
98
- if (response) this._scriptSources.set(event.scriptId, response.scriptSource);
88
+ if (!event.url && !this._reportAnonymousScripts)
89
+ return;
90
+ const response = await this._client._sendMayFail("Debugger.getScriptSource", { scriptId: event.scriptId });
91
+ if (response)
92
+ this._scriptSources.set(event.scriptId, response.scriptSource);
99
93
  }
100
94
  async stop() {
101
- (0, _utils.assert)(this._enabled, 'JSCoverage is not enabled');
95
+ (0, import_utils.assert)(this._enabled, "JSCoverage is not enabled");
102
96
  this._enabled = false;
103
- const [profileResponse] = await Promise.all([this._client.send('Profiler.takePreciseCoverage'), this._client.send('Profiler.stopPreciseCoverage'), this._client.send('Profiler.disable'), this._client.send('Debugger.disable')]);
104
- _eventsHelper.eventsHelper.removeEventListeners(this._eventListeners);
105
- const coverage = {
106
- entries: []
107
- };
97
+ const [profileResponse] = await Promise.all([
98
+ this._client.send("Profiler.takePreciseCoverage"),
99
+ this._client.send("Profiler.stopPreciseCoverage"),
100
+ this._client.send("Profiler.disable"),
101
+ this._client.send("Debugger.disable")
102
+ ]);
103
+ import_eventsHelper.eventsHelper.removeEventListeners(this._eventListeners);
104
+ const coverage = { entries: [] };
108
105
  for (const entry of profileResponse.result) {
109
- if (!this._scriptIds.has(entry.scriptId)) continue;
110
- if (!entry.url && !this._reportAnonymousScripts) continue;
106
+ if (!this._scriptIds.has(entry.scriptId))
107
+ continue;
108
+ if (!entry.url && !this._reportAnonymousScripts)
109
+ continue;
111
110
  const source = this._scriptSources.get(entry.scriptId);
112
- if (source) coverage.entries.push({
113
- ...entry,
114
- source
115
- });else coverage.entries.push(entry);
111
+ if (source)
112
+ coverage.entries.push({ ...entry, source });
113
+ else
114
+ coverage.entries.push(entry);
116
115
  }
117
116
  return coverage;
118
117
  }
119
118
  }
120
119
  class CSSCoverage {
121
120
  constructor(client) {
122
- this._client = void 0;
123
- this._enabled = void 0;
124
- this._stylesheetURLs = void 0;
125
- this._stylesheetSources = void 0;
126
- this._eventListeners = void 0;
127
- this._resetOnNavigation = void 0;
128
121
  this._client = client;
129
122
  this._enabled = false;
130
- this._stylesheetURLs = new Map();
131
- this._stylesheetSources = new Map();
123
+ this._stylesheetURLs = /* @__PURE__ */ new Map();
124
+ this._stylesheetSources = /* @__PURE__ */ new Map();
132
125
  this._eventListeners = [];
133
126
  this._resetOnNavigation = false;
134
127
  }
135
128
  async start(options) {
136
- (0, _utils.assert)(!this._enabled, 'CSSCoverage is already enabled');
137
- const {
138
- resetOnNavigation = true
139
- } = options;
129
+ (0, import_utils.assert)(!this._enabled, "CSSCoverage is already enabled");
130
+ const { resetOnNavigation = true } = options;
140
131
  this._resetOnNavigation = resetOnNavigation;
141
132
  this._enabled = true;
142
133
  this._stylesheetURLs.clear();
143
134
  this._stylesheetSources.clear();
144
- this._eventListeners = [_eventsHelper.eventsHelper.addEventListener(this._client, 'CSS.styleSheetAdded', this._onStyleSheet.bind(this)), _eventsHelper.eventsHelper.addEventListener(this._client, 'Runtime.executionContextsCleared', this._onExecutionContextsCleared.bind(this))];
145
- await Promise.all([this._client.send('DOM.enable'), this._client.send('CSS.enable'), this._client.send('CSS.startRuleUsageTracking')]);
135
+ this._eventListeners = [
136
+ import_eventsHelper.eventsHelper.addEventListener(this._client, "CSS.styleSheetAdded", this._onStyleSheet.bind(this)),
137
+ import_eventsHelper.eventsHelper.addEventListener(this._client, "Runtime.executionContextsCleared", this._onExecutionContextsCleared.bind(this))
138
+ ];
139
+ await Promise.all([
140
+ this._client.send("DOM.enable"),
141
+ this._client.send("CSS.enable"),
142
+ this._client.send("CSS.startRuleUsageTracking")
143
+ ]);
146
144
  }
147
145
  _onExecutionContextsCleared() {
148
- if (!this._resetOnNavigation) return;
146
+ if (!this._resetOnNavigation)
147
+ return;
149
148
  this._stylesheetURLs.clear();
150
149
  this._stylesheetSources.clear();
151
150
  }
152
151
  async _onStyleSheet(event) {
153
152
  const header = event.header;
154
- // Ignore anonymous scripts
155
- if (!header.sourceURL) return;
156
- // This might fail if the page has already navigated away.
157
- const response = await this._client._sendMayFail('CSS.getStyleSheetText', {
158
- styleSheetId: header.styleSheetId
159
- });
153
+ if (!header.sourceURL)
154
+ return;
155
+ const response = await this._client._sendMayFail("CSS.getStyleSheetText", { styleSheetId: header.styleSheetId });
160
156
  if (response) {
161
157
  this._stylesheetURLs.set(header.styleSheetId, header.sourceURL);
162
158
  this._stylesheetSources.set(header.styleSheetId, response.text);
163
159
  }
164
160
  }
165
161
  async stop() {
166
- (0, _utils.assert)(this._enabled, 'CSSCoverage is not enabled');
162
+ (0, import_utils.assert)(this._enabled, "CSSCoverage is not enabled");
167
163
  this._enabled = false;
168
- const ruleTrackingResponse = await this._client.send('CSS.stopRuleUsageTracking');
169
- await Promise.all([this._client.send('CSS.disable'), this._client.send('DOM.disable')]);
170
- _eventsHelper.eventsHelper.removeEventListeners(this._eventListeners);
171
-
172
- // aggregate by styleSheetId
173
- const styleSheetIdToCoverage = new Map();
164
+ const ruleTrackingResponse = await this._client.send("CSS.stopRuleUsageTracking");
165
+ await Promise.all([
166
+ this._client.send("CSS.disable"),
167
+ this._client.send("DOM.disable")
168
+ ]);
169
+ import_eventsHelper.eventsHelper.removeEventListeners(this._eventListeners);
170
+ const styleSheetIdToCoverage = /* @__PURE__ */ new Map();
174
171
  for (const entry of ruleTrackingResponse.ruleUsage) {
175
172
  let ranges = styleSheetIdToCoverage.get(entry.styleSheetId);
176
173
  if (!ranges) {
@@ -183,18 +180,12 @@ class CSSCoverage {
183
180
  count: entry.used ? 1 : 0
184
181
  });
185
182
  }
186
- const coverage = {
187
- entries: []
188
- };
183
+ const coverage = { entries: [] };
189
184
  for (const styleSheetId of this._stylesheetURLs.keys()) {
190
185
  const url = this._stylesheetURLs.get(styleSheetId);
191
186
  const text = this._stylesheetSources.get(styleSheetId);
192
187
  const ranges = convertToDisjointRanges(styleSheetIdToCoverage.get(styleSheetId) || []);
193
- coverage.entries.push({
194
- url,
195
- ranges,
196
- text
197
- });
188
+ coverage.entries.push({ url, ranges, text });
198
189
  }
199
190
  return coverage;
200
191
  }
@@ -202,45 +193,40 @@ class CSSCoverage {
202
193
  function convertToDisjointRanges(nestedRanges) {
203
194
  const points = [];
204
195
  for (const range of nestedRanges) {
205
- points.push({
206
- offset: range.startOffset,
207
- type: 0,
208
- range
209
- });
210
- points.push({
211
- offset: range.endOffset,
212
- type: 1,
213
- range
214
- });
215
- }
216
- // Sort points to form a valid parenthesis sequence.
196
+ points.push({ offset: range.startOffset, type: 0, range });
197
+ points.push({ offset: range.endOffset, type: 1, range });
198
+ }
217
199
  points.sort((a, b) => {
218
- // Sort with increasing offsets.
219
- if (a.offset !== b.offset) return a.offset - b.offset;
220
- // All "end" points should go before "start" points.
221
- if (a.type !== b.type) return b.type - a.type;
200
+ if (a.offset !== b.offset)
201
+ return a.offset - b.offset;
202
+ if (a.type !== b.type)
203
+ return b.type - a.type;
222
204
  const aLength = a.range.endOffset - a.range.startOffset;
223
205
  const bLength = b.range.endOffset - b.range.startOffset;
224
- // For two "start" points, the one with longer range goes first.
225
- if (a.type === 0) return bLength - aLength;
226
- // For two "end" points, the one with shorter range goes first.
206
+ if (a.type === 0)
207
+ return bLength - aLength;
227
208
  return aLength - bLength;
228
209
  });
229
210
  const hitCountStack = [];
230
211
  const results = [];
231
212
  let lastOffset = 0;
232
- // Run scanning line to intersect all ranges.
233
213
  for (const point of points) {
234
214
  if (hitCountStack.length && lastOffset < point.offset && hitCountStack[hitCountStack.length - 1] > 0) {
235
215
  const lastResult = results.length ? results[results.length - 1] : null;
236
- if (lastResult && lastResult.end === lastOffset) lastResult.end = point.offset;else results.push({
237
- start: lastOffset,
238
- end: point.offset
239
- });
216
+ if (lastResult && lastResult.end === lastOffset)
217
+ lastResult.end = point.offset;
218
+ else
219
+ results.push({ start: lastOffset, end: point.offset });
240
220
  }
241
221
  lastOffset = point.offset;
242
- if (point.type === 0) hitCountStack.push(point.range.count);else hitCountStack.pop();
222
+ if (point.type === 0)
223
+ hitCountStack.push(point.range.count);
224
+ else
225
+ hitCountStack.pop();
243
226
  }
244
- // Filter out empty ranges.
245
- return results.filter(range => range.end - range.start > 1);
246
- }
227
+ return results.filter((range) => range.end - range.start > 1);
228
+ }
229
+ // Annotate the CommonJS export names for ESM import in node:
230
+ 0 && (module.exports = {
231
+ CRCoverage
232
+ });