rebrowser-playwright-core 1.49.1 → 1.64.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 (393) hide show
  1. package/ThirdPartyNotices.txt +7 -1228
  2. package/bin/install_webkit_wsl.ps1 +33 -0
  3. package/bin/reinstall_chrome_beta_linux.sh +1 -1
  4. package/bin/reinstall_chrome_beta_mac.sh +1 -1
  5. package/bin/reinstall_chrome_stable_linux.sh +1 -1
  6. package/bin/reinstall_chrome_stable_mac.sh +1 -1
  7. package/bin/reinstall_msedge_beta_linux.sh +7 -1
  8. package/bin/reinstall_msedge_beta_mac.sh +1 -1
  9. package/bin/reinstall_msedge_dev_linux.sh +7 -1
  10. package/bin/reinstall_msedge_dev_mac.sh +1 -1
  11. package/bin/reinstall_msedge_stable_linux.sh +7 -1
  12. package/bin/reinstall_msedge_stable_mac.sh +1 -1
  13. package/browsers.json +21 -34
  14. package/cli.js +5 -1
  15. package/index.js +2 -18
  16. package/lib/bootstrap.js +149 -0
  17. package/lib/coreBundle.js +78218 -0
  18. package/lib/entry/cliDaemon.js +5 -0
  19. package/lib/entry/dashboardApp.js +3 -0
  20. package/lib/entry/mcp.js +10 -0
  21. package/lib/entry/oopBrowserDownload.js +3 -0
  22. package/lib/package.js +50 -0
  23. package/lib/server/electron/loader.js +109 -43
  24. package/lib/serverRegistry.js +1939 -0
  25. package/lib/serverRegistry.js.LICENSE +65 -0
  26. package/lib/tools/cli-client/channelSessions.js +141 -0
  27. package/lib/tools/cli-client/cli.js +7 -0
  28. package/lib/tools/cli-client/help.json +808 -0
  29. package/lib/tools/cli-client/minimist.js +128 -0
  30. package/lib/tools/cli-client/output.js +352 -0
  31. package/lib/tools/cli-client/program.js +422 -0
  32. package/lib/tools/cli-client/registry.js +180 -0
  33. package/lib/tools/cli-client/session.js +261 -0
  34. package/lib/tools/dashboard/appIcon.png +0 -0
  35. package/lib/tools/skills/playwright-cli/SKILL.md +493 -0
  36. package/lib/tools/skills/playwright-cli/references/element-attributes.md +23 -0
  37. package/lib/tools/skills/playwright-cli/references/playwright-tests.md +39 -0
  38. package/lib/tools/skills/playwright-cli/references/pr-attachments.md +60 -0
  39. package/lib/tools/skills/playwright-cli/references/request-mocking.md +87 -0
  40. package/lib/tools/skills/playwright-cli/references/running-code.md +245 -0
  41. package/lib/tools/skills/playwright-cli/references/session-management.md +227 -0
  42. package/lib/tools/skills/playwright-cli/references/storage-state.md +275 -0
  43. package/lib/tools/skills/playwright-cli/references/test-generation.md +433 -0
  44. package/lib/tools/skills/playwright-cli/references/tracing.md +139 -0
  45. package/lib/tools/skills/playwright-cli/references/video-recording.md +216 -0
  46. package/lib/tools/skills/playwright-component-testing/SKILL.md +136 -0
  47. package/lib/tools/skills/playwright-component-testing/references/gallery-spec.md +144 -0
  48. package/lib/tools/skills/playwright-component-testing/references/migration.md +89 -0
  49. package/lib/tools/skills/playwright-component-testing/references/react.md +69 -0
  50. package/lib/tools/skills/playwright-component-testing/references/typing.md +173 -0
  51. package/lib/tools/skills/playwright-component-testing/references/vue.md +77 -0
  52. package/lib/tools/skills/playwright-trace/SKILL.md +174 -0
  53. package/lib/tools/utils/extension.js +112 -0
  54. package/lib/tools/utils/socketConnection.js +108 -0
  55. package/lib/utilsBundle.js +86076 -79
  56. package/lib/utilsBundle.js.LICENSE +1890 -0
  57. package/lib/vite/dashboard/assets/codeMirrorModule--QdMvsKi.css +1 -0
  58. package/lib/vite/dashboard/assets/codeMirrorModule-CQ8RZGBm.js +32 -0
  59. package/lib/vite/dashboard/assets/codicon-DCmgc-ay.ttf +0 -0
  60. package/lib/vite/dashboard/assets/firefox-1bWoP6pv.svg +1 -0
  61. package/lib/vite/dashboard/assets/firefox-beta-k3eOH_eK.svg +1 -0
  62. package/lib/vite/dashboard/assets/firefox-nightly-Cp5nfeDT.svg +1 -0
  63. package/lib/vite/dashboard/assets/index-AwgwcYie.css +1 -0
  64. package/lib/vite/dashboard/assets/index-hRvO4yU2.js +12 -0
  65. package/lib/vite/dashboard/assets/safari-na3_-uQk.svg +1 -0
  66. package/lib/vite/dashboard/index.html +29 -0
  67. package/lib/vite/dashboard/playwright-logo.svg +24 -0
  68. package/lib/vite/htmlReport/index.html +3 -56
  69. package/lib/vite/htmlReport/report.css +2 -0
  70. package/lib/vite/htmlReport/report.js +32 -0
  71. package/lib/vite/recorder/assets/codeMirrorModule--QdMvsKi.css +1 -0
  72. package/lib/vite/recorder/assets/codeMirrorModule-DK72OMRi.js +32 -0
  73. package/lib/vite/recorder/assets/index-BZpYJZ-P.css +1 -0
  74. package/lib/vite/recorder/assets/index-Cn0mmDuv.js +129 -0
  75. package/lib/vite/recorder/index.html +3 -3
  76. package/lib/vite/traceViewer/assets/codeMirrorModule-BEB2e8M3.js +32 -0
  77. package/lib/vite/traceViewer/assets/defaultSettingsView-D-g2vrvf.js +184 -0
  78. package/lib/vite/traceViewer/assets/urlMatch-L3liM589.js +1 -0
  79. package/lib/vite/traceViewer/assets/xtermModule-B794rD2Z.js +7 -0
  80. package/lib/vite/traceViewer/codeMirrorModule.-QdMvsKi.css +1 -0
  81. package/lib/vite/traceViewer/defaultSettingsView.C8BeHuxd.css +1 -0
  82. package/lib/vite/traceViewer/index.B_TqY17P.css +1 -0
  83. package/lib/vite/traceViewer/index.html +9 -11
  84. package/lib/vite/traceViewer/index.oNry3Hjv.js +1 -0
  85. package/lib/vite/traceViewer/manifest.webmanifest +16 -0
  86. package/lib/vite/traceViewer/snapshot.B_Jk1wbt.js +1 -0
  87. package/lib/vite/traceViewer/snapshot.html +4 -15
  88. package/lib/vite/traceViewer/sw.bundle.js +4 -3
  89. package/lib/vite/traceViewer/uiMode.CYwC_gH1.js +5 -0
  90. package/lib/vite/traceViewer/uiMode.CyMfwkXJ.css +1 -0
  91. package/lib/vite/traceViewer/uiMode.html +6 -8
  92. package/lib/vite/traceViewer/xtermModule.kHJ-D0s7.css +1 -0
  93. package/lib/webp_codec.LICENSE +173 -0
  94. package/lib/webp_codec.wasm +0 -0
  95. package/lib/{utilsBundleImpl/xdg-open → xdg-open} +338 -137
  96. package/package.json +6 -16
  97. package/types/protocol.d.ts +9357 -6200
  98. package/types/structs.d.ts +8 -1
  99. package/types/types.d.ts +9490 -4947
  100. package/bin/PrintDeps.exe +0 -0
  101. package/bin/README.md +0 -2
  102. package/lib/androidServerImpl.js +0 -69
  103. package/lib/browserServerImpl.js +0 -92
  104. package/lib/cli/driver.js +0 -95
  105. package/lib/cli/program.js +0 -607
  106. package/lib/cli/programWithTestStub.js +0 -67
  107. package/lib/client/accessibility.js +0 -50
  108. package/lib/client/android.js +0 -473
  109. package/lib/client/api.js +0 -285
  110. package/lib/client/artifact.js +0 -79
  111. package/lib/client/browser.js +0 -145
  112. package/lib/client/browserContext.js +0 -559
  113. package/lib/client/browserType.js +0 -241
  114. package/lib/client/cdpSession.js +0 -53
  115. package/lib/client/channelOwner.js +0 -235
  116. package/lib/client/clientHelper.js +0 -57
  117. package/lib/client/clientInstrumentation.js +0 -50
  118. package/lib/client/clock.js +0 -68
  119. package/lib/client/connection.js +0 -333
  120. package/lib/client/consoleMessage.js +0 -55
  121. package/lib/client/coverage.js +0 -41
  122. package/lib/client/dialog.js +0 -57
  123. package/lib/client/download.js +0 -62
  124. package/lib/client/electron.js +0 -135
  125. package/lib/client/elementHandle.js +0 -321
  126. package/lib/client/errors.js +0 -77
  127. package/lib/client/eventEmitter.js +0 -314
  128. package/lib/client/events.js +0 -94
  129. package/lib/client/fetch.js +0 -391
  130. package/lib/client/fileChooser.js +0 -45
  131. package/lib/client/frame.js +0 -504
  132. package/lib/client/harRouter.js +0 -99
  133. package/lib/client/input.js +0 -111
  134. package/lib/client/jsHandle.js +0 -121
  135. package/lib/client/jsonPipe.js +0 -35
  136. package/lib/client/localUtils.js +0 -36
  137. package/lib/client/locator.js +0 -448
  138. package/lib/client/network.js +0 -767
  139. package/lib/client/page.js +0 -748
  140. package/lib/client/playwright.js +0 -80
  141. package/lib/client/selectors.js +0 -67
  142. package/lib/client/stream.js +0 -54
  143. package/lib/client/tracing.js +0 -147
  144. package/lib/client/types.js +0 -24
  145. package/lib/client/video.js +0 -51
  146. package/lib/client/waiter.js +0 -162
  147. package/lib/client/webError.js +0 -37
  148. package/lib/client/worker.js +0 -71
  149. package/lib/client/writableStream.js +0 -54
  150. package/lib/common/socksProxy.js +0 -569
  151. package/lib/common/timeoutSettings.js +0 -73
  152. package/lib/common/types.js +0 -5
  153. package/lib/generated/clockSource.js +0 -7
  154. package/lib/generated/consoleApiSource.js +0 -7
  155. package/lib/generated/injectedScriptSource.js +0 -7
  156. package/lib/generated/pollingRecorderSource.js +0 -7
  157. package/lib/generated/utilityScriptSource.js +0 -7
  158. package/lib/generated/webSocketMockSource.js +0 -7
  159. package/lib/image_tools/colorUtils.js +0 -98
  160. package/lib/image_tools/compare.js +0 -108
  161. package/lib/image_tools/imageChannel.js +0 -70
  162. package/lib/image_tools/stats.js +0 -102
  163. package/lib/inProcessFactory.js +0 -54
  164. package/lib/inprocess.js +0 -20
  165. package/lib/outofprocess.js +0 -67
  166. package/lib/protocol/debug.js +0 -27
  167. package/lib/protocol/serializers.js +0 -173
  168. package/lib/protocol/transport.js +0 -82
  169. package/lib/protocol/validator.js +0 -2780
  170. package/lib/protocol/validatorPrimitives.js +0 -139
  171. package/lib/remote/playwrightConnection.js +0 -274
  172. package/lib/remote/playwrightServer.js +0 -110
  173. package/lib/server/accessibility.js +0 -62
  174. package/lib/server/android/android.js +0 -441
  175. package/lib/server/android/backendAdb.js +0 -172
  176. package/lib/server/ariaSnapshot.js +0 -33
  177. package/lib/server/artifact.js +0 -104
  178. package/lib/server/bidi/bidiBrowser.js +0 -311
  179. package/lib/server/bidi/bidiChromium.js +0 -124
  180. package/lib/server/bidi/bidiConnection.js +0 -204
  181. package/lib/server/bidi/bidiExecutionContext.js +0 -156
  182. package/lib/server/bidi/bidiFirefox.js +0 -104
  183. package/lib/server/bidi/bidiInput.js +0 -158
  184. package/lib/server/bidi/bidiNetworkManager.js +0 -338
  185. package/lib/server/bidi/bidiOverCdp.js +0 -103
  186. package/lib/server/bidi/bidiPage.js +0 -529
  187. package/lib/server/bidi/bidiPdf.js +0 -140
  188. package/lib/server/bidi/third_party/bidiDeserializer.js +0 -93
  189. package/lib/server/bidi/third_party/bidiKeyboard.js +0 -238
  190. package/lib/server/bidi/third_party/bidiProtocol.js +0 -139
  191. package/lib/server/bidi/third_party/bidiSerializer.js +0 -144
  192. package/lib/server/bidi/third_party/firefoxPrefs.js +0 -221
  193. package/lib/server/browser.js +0 -148
  194. package/lib/server/browserContext.js +0 -667
  195. package/lib/server/browserType.js +0 -338
  196. package/lib/server/chromium/chromium.js +0 -354
  197. package/lib/server/chromium/chromiumSwitches.js +0 -46
  198. package/lib/server/chromium/crAccessibility.js +0 -237
  199. package/lib/server/chromium/crBrowser.js +0 -516
  200. package/lib/server/chromium/crConnection.js +0 -381
  201. package/lib/server/chromium/crCoverage.js +0 -246
  202. package/lib/server/chromium/crDevTools.js +0 -108
  203. package/lib/server/chromium/crDragDrop.js +0 -143
  204. package/lib/server/chromium/crExecutionContext.js +0 -136
  205. package/lib/server/chromium/crInput.js +0 -171
  206. package/lib/server/chromium/crNetworkManager.js +0 -767
  207. package/lib/server/chromium/crPage.js +0 -1143
  208. package/lib/server/chromium/crPdf.js +0 -153
  209. package/lib/server/chromium/crProtocolHelper.js +0 -133
  210. package/lib/server/chromium/crServiceWorker.js +0 -114
  211. package/lib/server/chromium/defaultFontFamilies.js +0 -145
  212. package/lib/server/chromium/videoRecorder.js +0 -155
  213. package/lib/server/clock.js +0 -125
  214. package/lib/server/codegen/csharp.js +0 -294
  215. package/lib/server/codegen/java.js +0 -232
  216. package/lib/server/codegen/javascript.js +0 -245
  217. package/lib/server/codegen/jsonl.js +0 -47
  218. package/lib/server/codegen/language.js +0 -88
  219. package/lib/server/codegen/languages.js +0 -30
  220. package/lib/server/codegen/python.js +0 -261
  221. package/lib/server/codegen/types.js +0 -5
  222. package/lib/server/console.js +0 -57
  223. package/lib/server/cookieStore.js +0 -185
  224. package/lib/server/debugController.js +0 -237
  225. package/lib/server/debugger.js +0 -132
  226. package/lib/server/deviceDescriptors.js +0 -26
  227. package/lib/server/deviceDescriptorsSource.json +0 -1669
  228. package/lib/server/dialog.js +0 -71
  229. package/lib/server/dispatchers/androidDispatcher.js +0 -204
  230. package/lib/server/dispatchers/artifactDispatcher.js +0 -118
  231. package/lib/server/dispatchers/browserContextDispatcher.js +0 -368
  232. package/lib/server/dispatchers/browserDispatcher.js +0 -170
  233. package/lib/server/dispatchers/browserTypeDispatcher.js +0 -55
  234. package/lib/server/dispatchers/cdpSessionDispatcher.js +0 -48
  235. package/lib/server/dispatchers/debugControllerDispatcher.js +0 -103
  236. package/lib/server/dispatchers/dialogDispatcher.js +0 -44
  237. package/lib/server/dispatchers/dispatcher.js +0 -395
  238. package/lib/server/dispatchers/electronDispatcher.js +0 -93
  239. package/lib/server/dispatchers/elementHandlerDispatcher.js +0 -228
  240. package/lib/server/dispatchers/frameDispatcher.js +0 -293
  241. package/lib/server/dispatchers/jsHandleDispatcher.js +0 -97
  242. package/lib/server/dispatchers/jsonPipeDispatcher.js +0 -59
  243. package/lib/server/dispatchers/localUtilsDispatcher.js +0 -413
  244. package/lib/server/dispatchers/networkDispatchers.js +0 -221
  245. package/lib/server/dispatchers/pageDispatcher.js +0 -367
  246. package/lib/server/dispatchers/playwrightDispatcher.js +0 -107
  247. package/lib/server/dispatchers/selectorsDispatcher.js +0 -36
  248. package/lib/server/dispatchers/streamDispatcher.js +0 -62
  249. package/lib/server/dispatchers/tracingDispatcher.js +0 -64
  250. package/lib/server/dispatchers/webSocketRouteDispatcher.js +0 -189
  251. package/lib/server/dispatchers/writableStreamDispatcher.js +0 -58
  252. package/lib/server/dom.js +0 -888
  253. package/lib/server/download.js +0 -60
  254. package/lib/server/electron/electron.js +0 -296
  255. package/lib/server/errors.js +0 -68
  256. package/lib/server/fetch.js +0 -669
  257. package/lib/server/fileChooser.js +0 -42
  258. package/lib/server/fileUploadUtils.js +0 -75
  259. package/lib/server/firefox/ffAccessibility.js +0 -216
  260. package/lib/server/firefox/ffBrowser.js +0 -460
  261. package/lib/server/firefox/ffConnection.js +0 -168
  262. package/lib/server/firefox/ffExecutionContext.js +0 -123
  263. package/lib/server/firefox/ffInput.js +0 -150
  264. package/lib/server/firefox/ffNetworkManager.js +0 -233
  265. package/lib/server/firefox/ffPage.js +0 -559
  266. package/lib/server/firefox/firefox.js +0 -99
  267. package/lib/server/formData.js +0 -75
  268. package/lib/server/frameSelectors.js +0 -171
  269. package/lib/server/frames.js +0 -1691
  270. package/lib/server/har/harRecorder.js +0 -139
  271. package/lib/server/har/harTracer.js +0 -542
  272. package/lib/server/helper.js +0 -103
  273. package/lib/server/index.js +0 -108
  274. package/lib/server/input.js +0 -310
  275. package/lib/server/instrumentation.js +0 -70
  276. package/lib/server/isomorphic/utilityScriptSerializers.js +0 -226
  277. package/lib/server/javascript.js +0 -293
  278. package/lib/server/launchApp.js +0 -91
  279. package/lib/server/macEditingCommands.js +0 -139
  280. package/lib/server/network.js +0 -617
  281. package/lib/server/page.js +0 -873
  282. package/lib/server/pipeTransport.js +0 -85
  283. package/lib/server/playwright.js +0 -88
  284. package/lib/server/progress.js +0 -99
  285. package/lib/server/protocolError.js +0 -49
  286. package/lib/server/recorder/contextRecorder.js +0 -299
  287. package/lib/server/recorder/recorderApp.js +0 -187
  288. package/lib/server/recorder/recorderCollection.js +0 -116
  289. package/lib/server/recorder/recorderFrontend.js +0 -5
  290. package/lib/server/recorder/recorderInTraceViewer.js +0 -144
  291. package/lib/server/recorder/recorderRunner.js +0 -155
  292. package/lib/server/recorder/recorderUtils.js +0 -113
  293. package/lib/server/recorder/throttledFile.js +0 -46
  294. package/lib/server/recorder.js +0 -364
  295. package/lib/server/registry/browserFetcher.js +0 -168
  296. package/lib/server/registry/dependencies.js +0 -322
  297. package/lib/server/registry/index.js +0 -1052
  298. package/lib/server/registry/nativeDeps.js +0 -493
  299. package/lib/server/registry/oopDownloadBrowserMain.js +0 -138
  300. package/lib/server/screenshotter.js +0 -348
  301. package/lib/server/selectors.js +0 -73
  302. package/lib/server/socksClientCertificatesInterceptor.js +0 -340
  303. package/lib/server/socksInterceptor.js +0 -100
  304. package/lib/server/trace/recorder/snapshotter.js +0 -161
  305. package/lib/server/trace/recorder/snapshotterInjected.js +0 -511
  306. package/lib/server/trace/recorder/tracing.js +0 -596
  307. package/lib/server/trace/test/inMemorySnapshotter.js +0 -93
  308. package/lib/server/trace/viewer/traceViewer.js +0 -214
  309. package/lib/server/transport.js +0 -191
  310. package/lib/server/types.js +0 -24
  311. package/lib/server/usKeyboardLayout.js +0 -555
  312. package/lib/server/webkit/webkit.js +0 -87
  313. package/lib/server/webkit/wkAccessibility.js +0 -194
  314. package/lib/server/webkit/wkBrowser.js +0 -329
  315. package/lib/server/webkit/wkConnection.js +0 -173
  316. package/lib/server/webkit/wkExecutionContext.js +0 -130
  317. package/lib/server/webkit/wkInput.js +0 -169
  318. package/lib/server/webkit/wkInterceptableRequest.js +0 -162
  319. package/lib/server/webkit/wkPage.js +0 -1225
  320. package/lib/server/webkit/wkProvisionalPage.js +0 -94
  321. package/lib/server/webkit/wkWorkers.js +0 -104
  322. package/lib/third_party/pixelmatch.js +0 -255
  323. package/lib/utils/ascii.js +0 -31
  324. package/lib/utils/comparators.js +0 -153
  325. package/lib/utils/crypto.js +0 -171
  326. package/lib/utils/debug.js +0 -46
  327. package/lib/utils/debugLogger.js +0 -91
  328. package/lib/utils/env.js +0 -49
  329. package/lib/utils/eventsHelper.js +0 -38
  330. package/lib/utils/expectUtils.js +0 -33
  331. package/lib/utils/fileUtils.js +0 -205
  332. package/lib/utils/happy-eyeballs.js +0 -194
  333. package/lib/utils/headers.js +0 -52
  334. package/lib/utils/hostPlatform.js +0 -139
  335. package/lib/utils/httpServer.js +0 -237
  336. package/lib/utils/index.js +0 -368
  337. package/lib/utils/isomorphic/ariaSnapshot.js +0 -267
  338. package/lib/utils/isomorphic/cssParser.js +0 -250
  339. package/lib/utils/isomorphic/cssTokenizer.js +0 -979
  340. package/lib/utils/isomorphic/locatorGenerators.js +0 -660
  341. package/lib/utils/isomorphic/locatorParser.js +0 -179
  342. package/lib/utils/isomorphic/locatorUtils.js +0 -62
  343. package/lib/utils/isomorphic/mimeType.js +0 -29
  344. package/lib/utils/isomorphic/recorderUtils.js +0 -227
  345. package/lib/utils/isomorphic/selectorParser.js +0 -397
  346. package/lib/utils/isomorphic/stringUtils.js +0 -169
  347. package/lib/utils/isomorphic/traceUtils.js +0 -39
  348. package/lib/utils/isomorphic/urlMatch.js +0 -124
  349. package/lib/utils/linuxUtils.js +0 -78
  350. package/lib/utils/manualPromise.js +0 -109
  351. package/lib/utils/multimap.js +0 -75
  352. package/lib/utils/network.js +0 -160
  353. package/lib/utils/processLauncher.js +0 -248
  354. package/lib/utils/profiler.js +0 -53
  355. package/lib/utils/rtti.js +0 -44
  356. package/lib/utils/semaphore.js +0 -51
  357. package/lib/utils/sequence.js +0 -64
  358. package/lib/utils/spawnAsync.js +0 -45
  359. package/lib/utils/stackTrace.js +0 -134
  360. package/lib/utils/task.js +0 -58
  361. package/lib/utils/time.js +0 -37
  362. package/lib/utils/timeoutRunner.js +0 -66
  363. package/lib/utils/traceUtils.js +0 -44
  364. package/lib/utils/userAgent.js +0 -105
  365. package/lib/utils/wsServer.js +0 -127
  366. package/lib/utils/zipFile.js +0 -75
  367. package/lib/utils/zones.js +0 -71
  368. package/lib/utilsBundleImpl/index.js +0 -210
  369. package/lib/vite/recorder/assets/codeMirrorModule-C5j27SYZ.js +0 -24
  370. package/lib/vite/recorder/assets/codeMirrorModule-ez37Vkbh.css +0 -1
  371. package/lib/vite/recorder/assets/index-iA1aAGZg.css +0 -1
  372. package/lib/vite/recorder/assets/index-m0XdVJHe.js +0 -184
  373. package/lib/vite/traceViewer/assets/codeMirrorModule-BBCX0spr.js +0 -24
  374. package/lib/vite/traceViewer/assets/inspectorTab-B4Iw34Ow.js +0 -68
  375. package/lib/vite/traceViewer/assets/testServerConnection-DeE2kSzz.js +0 -1
  376. package/lib/vite/traceViewer/assets/workbench-DFlGYqou.js +0 -9
  377. package/lib/vite/traceViewer/assets/xtermModule-BeNbaIVa.js +0 -9
  378. package/lib/vite/traceViewer/codeMirrorModule.ez37Vkbh.css +0 -1
  379. package/lib/vite/traceViewer/embedded.CmarehFk.js +0 -2
  380. package/lib/vite/traceViewer/embedded.html +0 -18
  381. package/lib/vite/traceViewer/embedded.w7WN2u1R.css +0 -1
  382. package/lib/vite/traceViewer/index.CrbWWHbf.css +0 -1
  383. package/lib/vite/traceViewer/index.FBucu_gE.js +0 -2
  384. package/lib/vite/traceViewer/inspectorTab.DEOUW62d.css +0 -1
  385. package/lib/vite/traceViewer/recorder.B_SY1GJM.css +0 -0
  386. package/lib/vite/traceViewer/recorder.CW_rzcEp.js +0 -2
  387. package/lib/vite/traceViewer/recorder.html +0 -17
  388. package/lib/vite/traceViewer/uiMode.CDUVjusr.js +0 -5
  389. package/lib/vite/traceViewer/uiMode.voC1ZiOQ.css +0 -1
  390. package/lib/vite/traceViewer/workbench.C-zR9ysA.css +0 -1
  391. package/lib/vite/traceViewer/xtermModule.DSXBckUd.css +0 -32
  392. package/lib/zipBundle.js +0 -25
  393. package/lib/zipBundleImpl.js +0 -5
@@ -0,0 +1,1939 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // packages/playwright-core/src/serverRegistry.ts
31
+ var serverRegistry_exports = {};
32
+ __export(serverRegistry_exports, {
33
+ serverRegistry: () => serverRegistry
34
+ });
35
+ module.exports = __toCommonJS(serverRegistry_exports);
36
+ var import_events2 = require("events");
37
+ var import_fs3 = __toESM(require("fs"));
38
+ var import_net = __toESM(require("net"));
39
+ var import_path2 = __toESM(require("path"));
40
+ var import_os2 = __toESM(require("os"));
41
+
42
+ // node_modules/chokidar/esm/index.js
43
+ var import_fs2 = require("fs");
44
+ var import_promises3 = require("fs/promises");
45
+ var import_events = require("events");
46
+ var sysPath2 = __toESM(require("path"), 1);
47
+
48
+ // node_modules/readdirp/esm/index.js
49
+ var import_promises = require("node:fs/promises");
50
+ var import_node_stream = require("node:stream");
51
+ var import_node_path = require("node:path");
52
+ var EntryTypes = {
53
+ FILE_TYPE: "files",
54
+ DIR_TYPE: "directories",
55
+ FILE_DIR_TYPE: "files_directories",
56
+ EVERYTHING_TYPE: "all"
57
+ };
58
+ var defaultOptions = {
59
+ root: ".",
60
+ fileFilter: (_entryInfo) => true,
61
+ directoryFilter: (_entryInfo) => true,
62
+ type: EntryTypes.FILE_TYPE,
63
+ lstat: false,
64
+ depth: 2147483648,
65
+ alwaysStat: false,
66
+ highWaterMark: 4096
67
+ };
68
+ Object.freeze(defaultOptions);
69
+ var RECURSIVE_ERROR_CODE = "READDIRP_RECURSIVE_ERROR";
70
+ var NORMAL_FLOW_ERRORS = /* @__PURE__ */ new Set(["ENOENT", "EPERM", "EACCES", "ELOOP", RECURSIVE_ERROR_CODE]);
71
+ var ALL_TYPES = [
72
+ EntryTypes.DIR_TYPE,
73
+ EntryTypes.EVERYTHING_TYPE,
74
+ EntryTypes.FILE_DIR_TYPE,
75
+ EntryTypes.FILE_TYPE
76
+ ];
77
+ var DIR_TYPES = /* @__PURE__ */ new Set([
78
+ EntryTypes.DIR_TYPE,
79
+ EntryTypes.EVERYTHING_TYPE,
80
+ EntryTypes.FILE_DIR_TYPE
81
+ ]);
82
+ var FILE_TYPES = /* @__PURE__ */ new Set([
83
+ EntryTypes.EVERYTHING_TYPE,
84
+ EntryTypes.FILE_DIR_TYPE,
85
+ EntryTypes.FILE_TYPE
86
+ ]);
87
+ var isNormalFlowError = (error) => NORMAL_FLOW_ERRORS.has(error.code);
88
+ var wantBigintFsStats = process.platform === "win32";
89
+ var emptyFn = (_entryInfo) => true;
90
+ var normalizeFilter = (filter) => {
91
+ if (filter === void 0)
92
+ return emptyFn;
93
+ if (typeof filter === "function")
94
+ return filter;
95
+ if (typeof filter === "string") {
96
+ const fl = filter.trim();
97
+ return (entry) => entry.basename === fl;
98
+ }
99
+ if (Array.isArray(filter)) {
100
+ const trItems = filter.map((item) => item.trim());
101
+ return (entry) => trItems.some((f) => entry.basename === f);
102
+ }
103
+ return emptyFn;
104
+ };
105
+ var ReaddirpStream = class extends import_node_stream.Readable {
106
+ constructor(options = {}) {
107
+ super({
108
+ objectMode: true,
109
+ autoDestroy: true,
110
+ highWaterMark: options.highWaterMark
111
+ });
112
+ const opts = { ...defaultOptions, ...options };
113
+ const { root, type } = opts;
114
+ this._fileFilter = normalizeFilter(opts.fileFilter);
115
+ this._directoryFilter = normalizeFilter(opts.directoryFilter);
116
+ const statMethod = opts.lstat ? import_promises.lstat : import_promises.stat;
117
+ if (wantBigintFsStats) {
118
+ this._stat = (path3) => statMethod(path3, { bigint: true });
119
+ } else {
120
+ this._stat = statMethod;
121
+ }
122
+ this._maxDepth = opts.depth ?? defaultOptions.depth;
123
+ this._wantsDir = type ? DIR_TYPES.has(type) : false;
124
+ this._wantsFile = type ? FILE_TYPES.has(type) : false;
125
+ this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;
126
+ this._root = (0, import_node_path.resolve)(root);
127
+ this._isDirent = !opts.alwaysStat;
128
+ this._statsProp = this._isDirent ? "dirent" : "stats";
129
+ this._rdOptions = { encoding: "utf8", withFileTypes: this._isDirent };
130
+ this.parents = [this._exploreDir(root, 1)];
131
+ this.reading = false;
132
+ this.parent = void 0;
133
+ }
134
+ async _read(batch) {
135
+ if (this.reading)
136
+ return;
137
+ this.reading = true;
138
+ try {
139
+ while (!this.destroyed && batch > 0) {
140
+ const par = this.parent;
141
+ const fil = par && par.files;
142
+ if (fil && fil.length > 0) {
143
+ const { path: path3, depth } = par;
144
+ const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path3));
145
+ const awaited = await Promise.all(slice);
146
+ for (const entry of awaited) {
147
+ if (!entry)
148
+ continue;
149
+ if (this.destroyed)
150
+ return;
151
+ const entryType = await this._getEntryType(entry);
152
+ if (entryType === "directory" && this._directoryFilter(entry)) {
153
+ if (depth <= this._maxDepth) {
154
+ this.parents.push(this._exploreDir(entry.fullPath, depth + 1));
155
+ }
156
+ if (this._wantsDir) {
157
+ this.push(entry);
158
+ batch--;
159
+ }
160
+ } else if ((entryType === "file" || this._includeAsFile(entry)) && this._fileFilter(entry)) {
161
+ if (this._wantsFile) {
162
+ this.push(entry);
163
+ batch--;
164
+ }
165
+ }
166
+ }
167
+ } else {
168
+ const parent = this.parents.pop();
169
+ if (!parent) {
170
+ this.push(null);
171
+ break;
172
+ }
173
+ this.parent = await parent;
174
+ if (this.destroyed)
175
+ return;
176
+ }
177
+ }
178
+ } catch (error) {
179
+ this.destroy(error);
180
+ } finally {
181
+ this.reading = false;
182
+ }
183
+ }
184
+ async _exploreDir(path3, depth) {
185
+ let files;
186
+ try {
187
+ files = await (0, import_promises.readdir)(path3, this._rdOptions);
188
+ } catch (error) {
189
+ this._onError(error);
190
+ }
191
+ return { files, depth, path: path3 };
192
+ }
193
+ async _formatEntry(dirent, path3) {
194
+ let entry;
195
+ const basename3 = this._isDirent ? dirent.name : dirent;
196
+ try {
197
+ const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(path3, basename3));
198
+ entry = { path: (0, import_node_path.relative)(this._root, fullPath), fullPath, basename: basename3 };
199
+ entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
200
+ } catch (err) {
201
+ this._onError(err);
202
+ return;
203
+ }
204
+ return entry;
205
+ }
206
+ _onError(err) {
207
+ if (isNormalFlowError(err) && !this.destroyed) {
208
+ this.emit("warn", err);
209
+ } else {
210
+ this.destroy(err);
211
+ }
212
+ }
213
+ async _getEntryType(entry) {
214
+ if (!entry && this._statsProp in entry) {
215
+ return "";
216
+ }
217
+ const stats = entry[this._statsProp];
218
+ if (stats.isFile())
219
+ return "file";
220
+ if (stats.isDirectory())
221
+ return "directory";
222
+ if (stats && stats.isSymbolicLink()) {
223
+ const full = entry.fullPath;
224
+ try {
225
+ const entryRealPath = await (0, import_promises.realpath)(full);
226
+ const entryRealPathStats = await (0, import_promises.lstat)(entryRealPath);
227
+ if (entryRealPathStats.isFile()) {
228
+ return "file";
229
+ }
230
+ if (entryRealPathStats.isDirectory()) {
231
+ const len = entryRealPath.length;
232
+ if (full.startsWith(entryRealPath) && full.substr(len, 1) === import_node_path.sep) {
233
+ const recursiveError = new Error(`Circular symlink detected: "${full}" points to "${entryRealPath}"`);
234
+ recursiveError.code = RECURSIVE_ERROR_CODE;
235
+ return this._onError(recursiveError);
236
+ }
237
+ return "directory";
238
+ }
239
+ } catch (error) {
240
+ this._onError(error);
241
+ return "";
242
+ }
243
+ }
244
+ }
245
+ _includeAsFile(entry) {
246
+ const stats = entry && entry[this._statsProp];
247
+ return stats && this._wantsEverything && !stats.isDirectory();
248
+ }
249
+ };
250
+ function readdirp(root, options = {}) {
251
+ let type = options.entryType || options.type;
252
+ if (type === "both")
253
+ type = EntryTypes.FILE_DIR_TYPE;
254
+ if (type)
255
+ options.type = type;
256
+ if (!root) {
257
+ throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");
258
+ } else if (typeof root !== "string") {
259
+ throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");
260
+ } else if (type && !ALL_TYPES.includes(type)) {
261
+ throw new Error(`readdirp: Invalid type passed. Use one of ${ALL_TYPES.join(", ")}`);
262
+ }
263
+ options.root = root;
264
+ return new ReaddirpStream(options);
265
+ }
266
+
267
+ // node_modules/chokidar/esm/handler.js
268
+ var import_fs = require("fs");
269
+ var import_promises2 = require("fs/promises");
270
+ var sysPath = __toESM(require("path"), 1);
271
+ var import_os = require("os");
272
+ var STR_DATA = "data";
273
+ var STR_END = "end";
274
+ var STR_CLOSE = "close";
275
+ var EMPTY_FN = () => {
276
+ };
277
+ var pl = process.platform;
278
+ var isWindows = pl === "win32";
279
+ var isMacos = pl === "darwin";
280
+ var isLinux = pl === "linux";
281
+ var isFreeBSD = pl === "freebsd";
282
+ var isIBMi = (0, import_os.type)() === "OS400";
283
+ var EVENTS = {
284
+ ALL: "all",
285
+ READY: "ready",
286
+ ADD: "add",
287
+ CHANGE: "change",
288
+ ADD_DIR: "addDir",
289
+ UNLINK: "unlink",
290
+ UNLINK_DIR: "unlinkDir",
291
+ RAW: "raw",
292
+ ERROR: "error"
293
+ };
294
+ var EV = EVENTS;
295
+ var THROTTLE_MODE_WATCH = "watch";
296
+ var statMethods = { lstat: import_promises2.lstat, stat: import_promises2.stat };
297
+ var KEY_LISTENERS = "listeners";
298
+ var KEY_ERR = "errHandlers";
299
+ var KEY_RAW = "rawEmitters";
300
+ var HANDLER_KEYS = [KEY_LISTENERS, KEY_ERR, KEY_RAW];
301
+ var binaryExtensions = /* @__PURE__ */ new Set([
302
+ "3dm",
303
+ "3ds",
304
+ "3g2",
305
+ "3gp",
306
+ "7z",
307
+ "a",
308
+ "aac",
309
+ "adp",
310
+ "afdesign",
311
+ "afphoto",
312
+ "afpub",
313
+ "ai",
314
+ "aif",
315
+ "aiff",
316
+ "alz",
317
+ "ape",
318
+ "apk",
319
+ "appimage",
320
+ "ar",
321
+ "arj",
322
+ "asf",
323
+ "au",
324
+ "avi",
325
+ "bak",
326
+ "baml",
327
+ "bh",
328
+ "bin",
329
+ "bk",
330
+ "bmp",
331
+ "btif",
332
+ "bz2",
333
+ "bzip2",
334
+ "cab",
335
+ "caf",
336
+ "cgm",
337
+ "class",
338
+ "cmx",
339
+ "cpio",
340
+ "cr2",
341
+ "cur",
342
+ "dat",
343
+ "dcm",
344
+ "deb",
345
+ "dex",
346
+ "djvu",
347
+ "dll",
348
+ "dmg",
349
+ "dng",
350
+ "doc",
351
+ "docm",
352
+ "docx",
353
+ "dot",
354
+ "dotm",
355
+ "dra",
356
+ "DS_Store",
357
+ "dsk",
358
+ "dts",
359
+ "dtshd",
360
+ "dvb",
361
+ "dwg",
362
+ "dxf",
363
+ "ecelp4800",
364
+ "ecelp7470",
365
+ "ecelp9600",
366
+ "egg",
367
+ "eol",
368
+ "eot",
369
+ "epub",
370
+ "exe",
371
+ "f4v",
372
+ "fbs",
373
+ "fh",
374
+ "fla",
375
+ "flac",
376
+ "flatpak",
377
+ "fli",
378
+ "flv",
379
+ "fpx",
380
+ "fst",
381
+ "fvt",
382
+ "g3",
383
+ "gh",
384
+ "gif",
385
+ "graffle",
386
+ "gz",
387
+ "gzip",
388
+ "h261",
389
+ "h263",
390
+ "h264",
391
+ "icns",
392
+ "ico",
393
+ "ief",
394
+ "img",
395
+ "ipa",
396
+ "iso",
397
+ "jar",
398
+ "jpeg",
399
+ "jpg",
400
+ "jpgv",
401
+ "jpm",
402
+ "jxr",
403
+ "key",
404
+ "ktx",
405
+ "lha",
406
+ "lib",
407
+ "lvp",
408
+ "lz",
409
+ "lzh",
410
+ "lzma",
411
+ "lzo",
412
+ "m3u",
413
+ "m4a",
414
+ "m4v",
415
+ "mar",
416
+ "mdi",
417
+ "mht",
418
+ "mid",
419
+ "midi",
420
+ "mj2",
421
+ "mka",
422
+ "mkv",
423
+ "mmr",
424
+ "mng",
425
+ "mobi",
426
+ "mov",
427
+ "movie",
428
+ "mp3",
429
+ "mp4",
430
+ "mp4a",
431
+ "mpeg",
432
+ "mpg",
433
+ "mpga",
434
+ "mxu",
435
+ "nef",
436
+ "npx",
437
+ "numbers",
438
+ "nupkg",
439
+ "o",
440
+ "odp",
441
+ "ods",
442
+ "odt",
443
+ "oga",
444
+ "ogg",
445
+ "ogv",
446
+ "otf",
447
+ "ott",
448
+ "pages",
449
+ "pbm",
450
+ "pcx",
451
+ "pdb",
452
+ "pdf",
453
+ "pea",
454
+ "pgm",
455
+ "pic",
456
+ "png",
457
+ "pnm",
458
+ "pot",
459
+ "potm",
460
+ "potx",
461
+ "ppa",
462
+ "ppam",
463
+ "ppm",
464
+ "pps",
465
+ "ppsm",
466
+ "ppsx",
467
+ "ppt",
468
+ "pptm",
469
+ "pptx",
470
+ "psd",
471
+ "pya",
472
+ "pyc",
473
+ "pyo",
474
+ "pyv",
475
+ "qt",
476
+ "rar",
477
+ "ras",
478
+ "raw",
479
+ "resources",
480
+ "rgb",
481
+ "rip",
482
+ "rlc",
483
+ "rmf",
484
+ "rmvb",
485
+ "rpm",
486
+ "rtf",
487
+ "rz",
488
+ "s3m",
489
+ "s7z",
490
+ "scpt",
491
+ "sgi",
492
+ "shar",
493
+ "snap",
494
+ "sil",
495
+ "sketch",
496
+ "slk",
497
+ "smv",
498
+ "snk",
499
+ "so",
500
+ "stl",
501
+ "suo",
502
+ "sub",
503
+ "swf",
504
+ "tar",
505
+ "tbz",
506
+ "tbz2",
507
+ "tga",
508
+ "tgz",
509
+ "thmx",
510
+ "tif",
511
+ "tiff",
512
+ "tlz",
513
+ "ttc",
514
+ "ttf",
515
+ "txz",
516
+ "udf",
517
+ "uvh",
518
+ "uvi",
519
+ "uvm",
520
+ "uvp",
521
+ "uvs",
522
+ "uvu",
523
+ "viv",
524
+ "vob",
525
+ "war",
526
+ "wav",
527
+ "wax",
528
+ "wbmp",
529
+ "wdp",
530
+ "weba",
531
+ "webm",
532
+ "webp",
533
+ "whl",
534
+ "wim",
535
+ "wm",
536
+ "wma",
537
+ "wmv",
538
+ "wmx",
539
+ "woff",
540
+ "woff2",
541
+ "wrm",
542
+ "wvx",
543
+ "xbm",
544
+ "xif",
545
+ "xla",
546
+ "xlam",
547
+ "xls",
548
+ "xlsb",
549
+ "xlsm",
550
+ "xlsx",
551
+ "xlt",
552
+ "xltm",
553
+ "xltx",
554
+ "xm",
555
+ "xmind",
556
+ "xpi",
557
+ "xpm",
558
+ "xwd",
559
+ "xz",
560
+ "z",
561
+ "zip",
562
+ "zipx"
563
+ ]);
564
+ var isBinaryPath = (filePath) => binaryExtensions.has(sysPath.extname(filePath).slice(1).toLowerCase());
565
+ var foreach = (val, fn) => {
566
+ if (val instanceof Set) {
567
+ val.forEach(fn);
568
+ } else {
569
+ fn(val);
570
+ }
571
+ };
572
+ var addAndConvert = (main, prop, item) => {
573
+ let container = main[prop];
574
+ if (!(container instanceof Set)) {
575
+ main[prop] = container = /* @__PURE__ */ new Set([container]);
576
+ }
577
+ container.add(item);
578
+ };
579
+ var clearItem = (cont) => (key) => {
580
+ const set = cont[key];
581
+ if (set instanceof Set) {
582
+ set.clear();
583
+ } else {
584
+ delete cont[key];
585
+ }
586
+ };
587
+ var delFromSet = (main, prop, item) => {
588
+ const container = main[prop];
589
+ if (container instanceof Set) {
590
+ container.delete(item);
591
+ } else if (container === item) {
592
+ delete main[prop];
593
+ }
594
+ };
595
+ var isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val;
596
+ var FsWatchInstances = /* @__PURE__ */ new Map();
597
+ function createFsWatchInstance(path3, options, listener, errHandler, emitRaw) {
598
+ const handleEvent = (rawEvent, evPath) => {
599
+ listener(path3);
600
+ emitRaw(rawEvent, evPath, { watchedPath: path3 });
601
+ if (evPath && path3 !== evPath) {
602
+ fsWatchBroadcast(sysPath.resolve(path3, evPath), KEY_LISTENERS, sysPath.join(path3, evPath));
603
+ }
604
+ };
605
+ try {
606
+ return (0, import_fs.watch)(path3, {
607
+ persistent: options.persistent
608
+ }, handleEvent);
609
+ } catch (error) {
610
+ errHandler(error);
611
+ return void 0;
612
+ }
613
+ }
614
+ var fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
615
+ const cont = FsWatchInstances.get(fullPath);
616
+ if (!cont)
617
+ return;
618
+ foreach(cont[listenerType], (listener) => {
619
+ listener(val1, val2, val3);
620
+ });
621
+ };
622
+ var setFsWatchListener = (path3, fullPath, options, handlers) => {
623
+ const { listener, errHandler, rawEmitter } = handlers;
624
+ let cont = FsWatchInstances.get(fullPath);
625
+ let watcher;
626
+ if (!options.persistent) {
627
+ watcher = createFsWatchInstance(path3, options, listener, errHandler, rawEmitter);
628
+ if (!watcher)
629
+ return;
630
+ return watcher.close.bind(watcher);
631
+ }
632
+ if (cont) {
633
+ addAndConvert(cont, KEY_LISTENERS, listener);
634
+ addAndConvert(cont, KEY_ERR, errHandler);
635
+ addAndConvert(cont, KEY_RAW, rawEmitter);
636
+ } else {
637
+ watcher = createFsWatchInstance(
638
+ path3,
639
+ options,
640
+ fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
641
+ errHandler,
642
+ // no need to use broadcast here
643
+ fsWatchBroadcast.bind(null, fullPath, KEY_RAW)
644
+ );
645
+ if (!watcher)
646
+ return;
647
+ watcher.on(EV.ERROR, async (error) => {
648
+ const broadcastErr = fsWatchBroadcast.bind(null, fullPath, KEY_ERR);
649
+ if (cont)
650
+ cont.watcherUnusable = true;
651
+ if (isWindows && error.code === "EPERM") {
652
+ try {
653
+ const fd = await (0, import_promises2.open)(path3, "r");
654
+ await fd.close();
655
+ broadcastErr(error);
656
+ } catch (err) {
657
+ }
658
+ } else {
659
+ broadcastErr(error);
660
+ }
661
+ });
662
+ cont = {
663
+ listeners: listener,
664
+ errHandlers: errHandler,
665
+ rawEmitters: rawEmitter,
666
+ watcher
667
+ };
668
+ FsWatchInstances.set(fullPath, cont);
669
+ }
670
+ return () => {
671
+ delFromSet(cont, KEY_LISTENERS, listener);
672
+ delFromSet(cont, KEY_ERR, errHandler);
673
+ delFromSet(cont, KEY_RAW, rawEmitter);
674
+ if (isEmptySet(cont.listeners)) {
675
+ cont.watcher.close();
676
+ FsWatchInstances.delete(fullPath);
677
+ HANDLER_KEYS.forEach(clearItem(cont));
678
+ cont.watcher = void 0;
679
+ Object.freeze(cont);
680
+ }
681
+ };
682
+ };
683
+ var FsWatchFileInstances = /* @__PURE__ */ new Map();
684
+ var setFsWatchFileListener = (path3, fullPath, options, handlers) => {
685
+ const { listener, rawEmitter } = handlers;
686
+ let cont = FsWatchFileInstances.get(fullPath);
687
+ const copts = cont && cont.options;
688
+ if (copts && (copts.persistent < options.persistent || copts.interval > options.interval)) {
689
+ (0, import_fs.unwatchFile)(fullPath);
690
+ cont = void 0;
691
+ }
692
+ if (cont) {
693
+ addAndConvert(cont, KEY_LISTENERS, listener);
694
+ addAndConvert(cont, KEY_RAW, rawEmitter);
695
+ } else {
696
+ cont = {
697
+ listeners: listener,
698
+ rawEmitters: rawEmitter,
699
+ options,
700
+ watcher: (0, import_fs.watchFile)(fullPath, options, (curr, prev) => {
701
+ foreach(cont.rawEmitters, (rawEmitter2) => {
702
+ rawEmitter2(EV.CHANGE, fullPath, { curr, prev });
703
+ });
704
+ const currmtime = curr.mtimeMs;
705
+ if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
706
+ foreach(cont.listeners, (listener2) => listener2(path3, curr));
707
+ }
708
+ })
709
+ };
710
+ FsWatchFileInstances.set(fullPath, cont);
711
+ }
712
+ return () => {
713
+ delFromSet(cont, KEY_LISTENERS, listener);
714
+ delFromSet(cont, KEY_RAW, rawEmitter);
715
+ if (isEmptySet(cont.listeners)) {
716
+ FsWatchFileInstances.delete(fullPath);
717
+ (0, import_fs.unwatchFile)(fullPath);
718
+ cont.options = cont.watcher = void 0;
719
+ Object.freeze(cont);
720
+ }
721
+ };
722
+ };
723
+ var NodeFsHandler = class {
724
+ constructor(fsW) {
725
+ this.fsw = fsW;
726
+ this._boundHandleError = (error) => fsW._handleError(error);
727
+ }
728
+ /**
729
+ * Watch file for changes with fs_watchFile or fs_watch.
730
+ * @param path to file or dir
731
+ * @param listener on fs change
732
+ * @returns closer for the watcher instance
733
+ */
734
+ _watchWithNodeFs(path3, listener) {
735
+ const opts = this.fsw.options;
736
+ const directory = sysPath.dirname(path3);
737
+ const basename3 = sysPath.basename(path3);
738
+ const parent = this.fsw._getWatchedDir(directory);
739
+ parent.add(basename3);
740
+ const absolutePath = sysPath.resolve(path3);
741
+ const options = {
742
+ persistent: opts.persistent
743
+ };
744
+ if (!listener)
745
+ listener = EMPTY_FN;
746
+ let closer;
747
+ if (opts.usePolling) {
748
+ const enableBin = opts.interval !== opts.binaryInterval;
749
+ options.interval = enableBin && isBinaryPath(basename3) ? opts.binaryInterval : opts.interval;
750
+ closer = setFsWatchFileListener(path3, absolutePath, options, {
751
+ listener,
752
+ rawEmitter: this.fsw._emitRaw
753
+ });
754
+ } else {
755
+ closer = setFsWatchListener(path3, absolutePath, options, {
756
+ listener,
757
+ errHandler: this._boundHandleError,
758
+ rawEmitter: this.fsw._emitRaw
759
+ });
760
+ }
761
+ return closer;
762
+ }
763
+ /**
764
+ * Watch a file and emit add event if warranted.
765
+ * @returns closer for the watcher instance
766
+ */
767
+ _handleFile(file, stats, initialAdd) {
768
+ if (this.fsw.closed) {
769
+ return;
770
+ }
771
+ const dirname3 = sysPath.dirname(file);
772
+ const basename3 = sysPath.basename(file);
773
+ const parent = this.fsw._getWatchedDir(dirname3);
774
+ let prevStats = stats;
775
+ if (parent.has(basename3))
776
+ return;
777
+ const listener = async (path3, newStats) => {
778
+ if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5))
779
+ return;
780
+ if (!newStats || newStats.mtimeMs === 0) {
781
+ try {
782
+ const newStats2 = await (0, import_promises2.stat)(file);
783
+ if (this.fsw.closed)
784
+ return;
785
+ const at = newStats2.atimeMs;
786
+ const mt = newStats2.mtimeMs;
787
+ if (!at || at <= mt || mt !== prevStats.mtimeMs) {
788
+ this.fsw._emit(EV.CHANGE, file, newStats2);
789
+ }
790
+ if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
791
+ this.fsw._closeFile(path3);
792
+ prevStats = newStats2;
793
+ const closer2 = this._watchWithNodeFs(file, listener);
794
+ if (closer2)
795
+ this.fsw._addPathCloser(path3, closer2);
796
+ } else {
797
+ prevStats = newStats2;
798
+ }
799
+ } catch (error) {
800
+ this.fsw._remove(dirname3, basename3);
801
+ }
802
+ } else if (parent.has(basename3)) {
803
+ const at = newStats.atimeMs;
804
+ const mt = newStats.mtimeMs;
805
+ if (!at || at <= mt || mt !== prevStats.mtimeMs) {
806
+ this.fsw._emit(EV.CHANGE, file, newStats);
807
+ }
808
+ prevStats = newStats;
809
+ }
810
+ };
811
+ const closer = this._watchWithNodeFs(file, listener);
812
+ if (!(initialAdd && this.fsw.options.ignoreInitial) && this.fsw._isntIgnored(file)) {
813
+ if (!this.fsw._throttle(EV.ADD, file, 0))
814
+ return;
815
+ this.fsw._emit(EV.ADD, file, stats);
816
+ }
817
+ return closer;
818
+ }
819
+ /**
820
+ * Handle symlinks encountered while reading a dir.
821
+ * @param entry returned by readdirp
822
+ * @param directory path of dir being read
823
+ * @param path of this item
824
+ * @param item basename of this item
825
+ * @returns true if no more processing is needed for this entry.
826
+ */
827
+ async _handleSymlink(entry, directory, path3, item) {
828
+ if (this.fsw.closed) {
829
+ return;
830
+ }
831
+ const full = entry.fullPath;
832
+ const dir = this.fsw._getWatchedDir(directory);
833
+ if (!this.fsw.options.followSymlinks) {
834
+ this.fsw._incrReadyCount();
835
+ let linkPath;
836
+ try {
837
+ linkPath = await (0, import_promises2.realpath)(path3);
838
+ } catch (e) {
839
+ this.fsw._emitReady();
840
+ return true;
841
+ }
842
+ if (this.fsw.closed)
843
+ return;
844
+ if (dir.has(item)) {
845
+ if (this.fsw._symlinkPaths.get(full) !== linkPath) {
846
+ this.fsw._symlinkPaths.set(full, linkPath);
847
+ this.fsw._emit(EV.CHANGE, path3, entry.stats);
848
+ }
849
+ } else {
850
+ dir.add(item);
851
+ this.fsw._symlinkPaths.set(full, linkPath);
852
+ this.fsw._emit(EV.ADD, path3, entry.stats);
853
+ }
854
+ this.fsw._emitReady();
855
+ return true;
856
+ }
857
+ if (this.fsw._symlinkPaths.has(full)) {
858
+ return true;
859
+ }
860
+ this.fsw._symlinkPaths.set(full, true);
861
+ }
862
+ _handleRead(directory, initialAdd, wh, target, dir, depth, throttler) {
863
+ directory = sysPath.join(directory, "");
864
+ throttler = this.fsw._throttle("readdir", directory, 1e3);
865
+ if (!throttler)
866
+ return;
867
+ const previous = this.fsw._getWatchedDir(wh.path);
868
+ const current = /* @__PURE__ */ new Set();
869
+ let stream = this.fsw._readdirp(directory, {
870
+ fileFilter: (entry) => wh.filterPath(entry),
871
+ directoryFilter: (entry) => wh.filterDir(entry)
872
+ });
873
+ if (!stream)
874
+ return;
875
+ stream.on(STR_DATA, async (entry) => {
876
+ if (this.fsw.closed) {
877
+ stream = void 0;
878
+ return;
879
+ }
880
+ const item = entry.path;
881
+ let path3 = sysPath.join(directory, item);
882
+ current.add(item);
883
+ if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path3, item)) {
884
+ return;
885
+ }
886
+ if (this.fsw.closed) {
887
+ stream = void 0;
888
+ return;
889
+ }
890
+ if (item === target || !target && !previous.has(item)) {
891
+ this.fsw._incrReadyCount();
892
+ path3 = sysPath.join(dir, sysPath.relative(dir, path3));
893
+ this._addToNodeFs(path3, initialAdd, wh, depth + 1);
894
+ }
895
+ }).on(EV.ERROR, this._boundHandleError);
896
+ return new Promise((resolve3, reject) => {
897
+ if (!stream)
898
+ return reject();
899
+ stream.once(STR_END, () => {
900
+ if (this.fsw.closed) {
901
+ stream = void 0;
902
+ return;
903
+ }
904
+ const wasThrottled = throttler ? throttler.clear() : false;
905
+ resolve3(void 0);
906
+ previous.getChildren().filter((item) => {
907
+ return item !== directory && !current.has(item);
908
+ }).forEach((item) => {
909
+ this.fsw._remove(directory, item);
910
+ });
911
+ stream = void 0;
912
+ if (wasThrottled)
913
+ this._handleRead(directory, false, wh, target, dir, depth, throttler);
914
+ });
915
+ });
916
+ }
917
+ /**
918
+ * Read directory to add / remove files from `@watched` list and re-read it on change.
919
+ * @param dir fs path
920
+ * @param stats
921
+ * @param initialAdd
922
+ * @param depth relative to user-supplied path
923
+ * @param target child path targeted for watch
924
+ * @param wh Common watch helpers for this path
925
+ * @param realpath
926
+ * @returns closer for the watcher instance.
927
+ */
928
+ async _handleDir(dir, stats, initialAdd, depth, target, wh, realpath2) {
929
+ const parentDir = this.fsw._getWatchedDir(sysPath.dirname(dir));
930
+ const tracked = parentDir.has(sysPath.basename(dir));
931
+ if (!(initialAdd && this.fsw.options.ignoreInitial) && !target && !tracked) {
932
+ this.fsw._emit(EV.ADD_DIR, dir, stats);
933
+ }
934
+ parentDir.add(sysPath.basename(dir));
935
+ this.fsw._getWatchedDir(dir);
936
+ let throttler;
937
+ let closer;
938
+ const oDepth = this.fsw.options.depth;
939
+ if ((oDepth == null || depth <= oDepth) && !this.fsw._symlinkPaths.has(realpath2)) {
940
+ if (!target) {
941
+ await this._handleRead(dir, initialAdd, wh, target, dir, depth, throttler);
942
+ if (this.fsw.closed)
943
+ return;
944
+ }
945
+ closer = this._watchWithNodeFs(dir, (dirPath, stats2) => {
946
+ if (stats2 && stats2.mtimeMs === 0)
947
+ return;
948
+ this._handleRead(dirPath, false, wh, target, dir, depth, throttler);
949
+ });
950
+ }
951
+ return closer;
952
+ }
953
+ /**
954
+ * Handle added file, directory, or glob pattern.
955
+ * Delegates call to _handleFile / _handleDir after checks.
956
+ * @param path to file or ir
957
+ * @param initialAdd was the file added at watch instantiation?
958
+ * @param priorWh depth relative to user-supplied path
959
+ * @param depth Child path actually targeted for watch
960
+ * @param target Child path actually targeted for watch
961
+ */
962
+ async _addToNodeFs(path3, initialAdd, priorWh, depth, target) {
963
+ const ready = this.fsw._emitReady;
964
+ if (this.fsw._isIgnored(path3) || this.fsw.closed) {
965
+ ready();
966
+ return false;
967
+ }
968
+ const wh = this.fsw._getWatchHelpers(path3);
969
+ if (priorWh) {
970
+ wh.filterPath = (entry) => priorWh.filterPath(entry);
971
+ wh.filterDir = (entry) => priorWh.filterDir(entry);
972
+ }
973
+ try {
974
+ const stats = await statMethods[wh.statMethod](wh.watchPath);
975
+ if (this.fsw.closed)
976
+ return;
977
+ if (this.fsw._isIgnored(wh.watchPath, stats)) {
978
+ ready();
979
+ return false;
980
+ }
981
+ const follow = this.fsw.options.followSymlinks;
982
+ let closer;
983
+ if (stats.isDirectory()) {
984
+ const absPath = sysPath.resolve(path3);
985
+ const targetPath = follow ? await (0, import_promises2.realpath)(path3) : path3;
986
+ if (this.fsw.closed)
987
+ return;
988
+ closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
989
+ if (this.fsw.closed)
990
+ return;
991
+ if (absPath !== targetPath && targetPath !== void 0) {
992
+ this.fsw._symlinkPaths.set(absPath, targetPath);
993
+ }
994
+ } else if (stats.isSymbolicLink()) {
995
+ const targetPath = follow ? await (0, import_promises2.realpath)(path3) : path3;
996
+ if (this.fsw.closed)
997
+ return;
998
+ const parent = sysPath.dirname(wh.watchPath);
999
+ this.fsw._getWatchedDir(parent).add(wh.watchPath);
1000
+ this.fsw._emit(EV.ADD, wh.watchPath, stats);
1001
+ closer = await this._handleDir(parent, stats, initialAdd, depth, path3, wh, targetPath);
1002
+ if (this.fsw.closed)
1003
+ return;
1004
+ if (targetPath !== void 0) {
1005
+ this.fsw._symlinkPaths.set(sysPath.resolve(path3), targetPath);
1006
+ }
1007
+ } else {
1008
+ closer = this._handleFile(wh.watchPath, stats, initialAdd);
1009
+ }
1010
+ ready();
1011
+ if (closer)
1012
+ this.fsw._addPathCloser(path3, closer);
1013
+ return false;
1014
+ } catch (error) {
1015
+ if (this.fsw._handleError(error)) {
1016
+ ready();
1017
+ return path3;
1018
+ }
1019
+ }
1020
+ }
1021
+ };
1022
+
1023
+ // node_modules/chokidar/esm/index.js
1024
+ var SLASH = "/";
1025
+ var SLASH_SLASH = "//";
1026
+ var ONE_DOT = ".";
1027
+ var TWO_DOTS = "..";
1028
+ var STRING_TYPE = "string";
1029
+ var BACK_SLASH_RE = /\\/g;
1030
+ var DOUBLE_SLASH_RE = /\/\//;
1031
+ var DOT_RE = /\..*\.(sw[px])$|~$|\.subl.*\.tmp/;
1032
+ var REPLACER_RE = /^\.[/\\]/;
1033
+ function arrify(item) {
1034
+ return Array.isArray(item) ? item : [item];
1035
+ }
1036
+ var isMatcherObject = (matcher) => typeof matcher === "object" && matcher !== null && !(matcher instanceof RegExp);
1037
+ function createPattern(matcher) {
1038
+ if (typeof matcher === "function")
1039
+ return matcher;
1040
+ if (typeof matcher === "string")
1041
+ return (string) => matcher === string;
1042
+ if (matcher instanceof RegExp)
1043
+ return (string) => matcher.test(string);
1044
+ if (typeof matcher === "object" && matcher !== null) {
1045
+ return (string) => {
1046
+ if (matcher.path === string)
1047
+ return true;
1048
+ if (matcher.recursive) {
1049
+ const relative3 = sysPath2.relative(matcher.path, string);
1050
+ if (!relative3) {
1051
+ return false;
1052
+ }
1053
+ return !relative3.startsWith("..") && !sysPath2.isAbsolute(relative3);
1054
+ }
1055
+ return false;
1056
+ };
1057
+ }
1058
+ return () => false;
1059
+ }
1060
+ function normalizePath(path3) {
1061
+ if (typeof path3 !== "string")
1062
+ throw new Error("string expected");
1063
+ path3 = sysPath2.normalize(path3);
1064
+ path3 = path3.replace(/\\/g, "/");
1065
+ let prepend = false;
1066
+ if (path3.startsWith("//"))
1067
+ prepend = true;
1068
+ const DOUBLE_SLASH_RE2 = /\/\//;
1069
+ while (path3.match(DOUBLE_SLASH_RE2))
1070
+ path3 = path3.replace(DOUBLE_SLASH_RE2, "/");
1071
+ if (prepend)
1072
+ path3 = "/" + path3;
1073
+ return path3;
1074
+ }
1075
+ function matchPatterns(patterns, testString, stats) {
1076
+ const path3 = normalizePath(testString);
1077
+ for (let index = 0; index < patterns.length; index++) {
1078
+ const pattern = patterns[index];
1079
+ if (pattern(path3, stats)) {
1080
+ return true;
1081
+ }
1082
+ }
1083
+ return false;
1084
+ }
1085
+ function anymatch(matchers, testString) {
1086
+ if (matchers == null) {
1087
+ throw new TypeError("anymatch: specify first argument");
1088
+ }
1089
+ const matchersArray = arrify(matchers);
1090
+ const patterns = matchersArray.map((matcher) => createPattern(matcher));
1091
+ if (testString == null) {
1092
+ return (testString2, stats) => {
1093
+ return matchPatterns(patterns, testString2, stats);
1094
+ };
1095
+ }
1096
+ return matchPatterns(patterns, testString);
1097
+ }
1098
+ var unifyPaths = (paths_) => {
1099
+ const paths = arrify(paths_).flat();
1100
+ if (!paths.every((p) => typeof p === STRING_TYPE)) {
1101
+ throw new TypeError(`Non-string provided as watch path: ${paths}`);
1102
+ }
1103
+ return paths.map(normalizePathToUnix);
1104
+ };
1105
+ var toUnix = (string) => {
1106
+ let str = string.replace(BACK_SLASH_RE, SLASH);
1107
+ let prepend = false;
1108
+ if (str.startsWith(SLASH_SLASH)) {
1109
+ prepend = true;
1110
+ }
1111
+ while (str.match(DOUBLE_SLASH_RE)) {
1112
+ str = str.replace(DOUBLE_SLASH_RE, SLASH);
1113
+ }
1114
+ if (prepend) {
1115
+ str = SLASH + str;
1116
+ }
1117
+ return str;
1118
+ };
1119
+ var normalizePathToUnix = (path3) => toUnix(sysPath2.normalize(toUnix(path3)));
1120
+ var normalizeIgnored = (cwd = "") => (path3) => {
1121
+ if (typeof path3 === "string") {
1122
+ return normalizePathToUnix(sysPath2.isAbsolute(path3) ? path3 : sysPath2.join(cwd, path3));
1123
+ } else {
1124
+ return path3;
1125
+ }
1126
+ };
1127
+ var getAbsolutePath = (path3, cwd) => {
1128
+ if (sysPath2.isAbsolute(path3)) {
1129
+ return path3;
1130
+ }
1131
+ return sysPath2.join(cwd, path3);
1132
+ };
1133
+ var EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
1134
+ var DirEntry = class {
1135
+ constructor(dir, removeWatcher) {
1136
+ this.path = dir;
1137
+ this._removeWatcher = removeWatcher;
1138
+ this.items = /* @__PURE__ */ new Set();
1139
+ }
1140
+ add(item) {
1141
+ const { items } = this;
1142
+ if (!items)
1143
+ return;
1144
+ if (item !== ONE_DOT && item !== TWO_DOTS)
1145
+ items.add(item);
1146
+ }
1147
+ async remove(item) {
1148
+ const { items } = this;
1149
+ if (!items)
1150
+ return;
1151
+ items.delete(item);
1152
+ if (items.size > 0)
1153
+ return;
1154
+ const dir = this.path;
1155
+ try {
1156
+ await (0, import_promises3.readdir)(dir);
1157
+ } catch (err) {
1158
+ if (this._removeWatcher) {
1159
+ this._removeWatcher(sysPath2.dirname(dir), sysPath2.basename(dir));
1160
+ }
1161
+ }
1162
+ }
1163
+ has(item) {
1164
+ const { items } = this;
1165
+ if (!items)
1166
+ return;
1167
+ return items.has(item);
1168
+ }
1169
+ getChildren() {
1170
+ const { items } = this;
1171
+ if (!items)
1172
+ return [];
1173
+ return [...items.values()];
1174
+ }
1175
+ dispose() {
1176
+ this.items.clear();
1177
+ this.path = "";
1178
+ this._removeWatcher = EMPTY_FN;
1179
+ this.items = EMPTY_SET;
1180
+ Object.freeze(this);
1181
+ }
1182
+ };
1183
+ var STAT_METHOD_F = "stat";
1184
+ var STAT_METHOD_L = "lstat";
1185
+ var WatchHelper = class {
1186
+ constructor(path3, follow, fsw) {
1187
+ this.fsw = fsw;
1188
+ const watchPath = path3;
1189
+ this.path = path3 = path3.replace(REPLACER_RE, "");
1190
+ this.watchPath = watchPath;
1191
+ this.fullWatchPath = sysPath2.resolve(watchPath);
1192
+ this.dirParts = [];
1193
+ this.dirParts.forEach((parts) => {
1194
+ if (parts.length > 1)
1195
+ parts.pop();
1196
+ });
1197
+ this.followSymlinks = follow;
1198
+ this.statMethod = follow ? STAT_METHOD_F : STAT_METHOD_L;
1199
+ }
1200
+ entryPath(entry) {
1201
+ return sysPath2.join(this.watchPath, sysPath2.relative(this.watchPath, entry.fullPath));
1202
+ }
1203
+ filterPath(entry) {
1204
+ const { stats } = entry;
1205
+ if (stats && stats.isSymbolicLink())
1206
+ return this.filterDir(entry);
1207
+ const resolvedPath = this.entryPath(entry);
1208
+ return this.fsw._isntIgnored(resolvedPath, stats) && this.fsw._hasReadPermissions(stats);
1209
+ }
1210
+ filterDir(entry) {
1211
+ return this.fsw._isntIgnored(this.entryPath(entry), entry.stats);
1212
+ }
1213
+ };
1214
+ var FSWatcher = class extends import_events.EventEmitter {
1215
+ // Not indenting methods for history sake; for now.
1216
+ constructor(_opts = {}) {
1217
+ super();
1218
+ this.closed = false;
1219
+ this._closers = /* @__PURE__ */ new Map();
1220
+ this._ignoredPaths = /* @__PURE__ */ new Set();
1221
+ this._throttled = /* @__PURE__ */ new Map();
1222
+ this._streams = /* @__PURE__ */ new Set();
1223
+ this._symlinkPaths = /* @__PURE__ */ new Map();
1224
+ this._watched = /* @__PURE__ */ new Map();
1225
+ this._pendingWrites = /* @__PURE__ */ new Map();
1226
+ this._pendingUnlinks = /* @__PURE__ */ new Map();
1227
+ this._readyCount = 0;
1228
+ this._readyEmitted = false;
1229
+ const awf = _opts.awaitWriteFinish;
1230
+ const DEF_AWF = { stabilityThreshold: 2e3, pollInterval: 100 };
1231
+ const opts = {
1232
+ // Defaults
1233
+ persistent: true,
1234
+ ignoreInitial: false,
1235
+ ignorePermissionErrors: false,
1236
+ interval: 100,
1237
+ binaryInterval: 300,
1238
+ followSymlinks: true,
1239
+ usePolling: false,
1240
+ // useAsync: false,
1241
+ atomic: true,
1242
+ // NOTE: overwritten later (depends on usePolling)
1243
+ ..._opts,
1244
+ // Change format
1245
+ ignored: _opts.ignored ? arrify(_opts.ignored) : arrify([]),
1246
+ awaitWriteFinish: awf === true ? DEF_AWF : typeof awf === "object" ? { ...DEF_AWF, ...awf } : false
1247
+ };
1248
+ if (isIBMi)
1249
+ opts.usePolling = true;
1250
+ if (opts.atomic === void 0)
1251
+ opts.atomic = !opts.usePolling;
1252
+ const envPoll = process.env.CHOKIDAR_USEPOLLING;
1253
+ if (envPoll !== void 0) {
1254
+ const envLower = envPoll.toLowerCase();
1255
+ if (envLower === "false" || envLower === "0")
1256
+ opts.usePolling = false;
1257
+ else if (envLower === "true" || envLower === "1")
1258
+ opts.usePolling = true;
1259
+ else
1260
+ opts.usePolling = !!envLower;
1261
+ }
1262
+ const envInterval = process.env.CHOKIDAR_INTERVAL;
1263
+ if (envInterval)
1264
+ opts.interval = Number.parseInt(envInterval, 10);
1265
+ let readyCalls = 0;
1266
+ this._emitReady = () => {
1267
+ readyCalls++;
1268
+ if (readyCalls >= this._readyCount) {
1269
+ this._emitReady = EMPTY_FN;
1270
+ this._readyEmitted = true;
1271
+ process.nextTick(() => this.emit(EVENTS.READY));
1272
+ }
1273
+ };
1274
+ this._emitRaw = (...args) => this.emit(EVENTS.RAW, ...args);
1275
+ this._boundRemove = this._remove.bind(this);
1276
+ this.options = opts;
1277
+ this._nodeFsHandler = new NodeFsHandler(this);
1278
+ Object.freeze(opts);
1279
+ }
1280
+ _addIgnoredPath(matcher) {
1281
+ if (isMatcherObject(matcher)) {
1282
+ for (const ignored of this._ignoredPaths) {
1283
+ if (isMatcherObject(ignored) && ignored.path === matcher.path && ignored.recursive === matcher.recursive) {
1284
+ return;
1285
+ }
1286
+ }
1287
+ }
1288
+ this._ignoredPaths.add(matcher);
1289
+ }
1290
+ _removeIgnoredPath(matcher) {
1291
+ this._ignoredPaths.delete(matcher);
1292
+ if (typeof matcher === "string") {
1293
+ for (const ignored of this._ignoredPaths) {
1294
+ if (isMatcherObject(ignored) && ignored.path === matcher) {
1295
+ this._ignoredPaths.delete(ignored);
1296
+ }
1297
+ }
1298
+ }
1299
+ }
1300
+ // Public methods
1301
+ /**
1302
+ * Adds paths to be watched on an existing FSWatcher instance.
1303
+ * @param paths_ file or file list. Other arguments are unused
1304
+ */
1305
+ add(paths_, _origAdd, _internal) {
1306
+ const { cwd } = this.options;
1307
+ this.closed = false;
1308
+ this._closePromise = void 0;
1309
+ let paths = unifyPaths(paths_);
1310
+ if (cwd) {
1311
+ paths = paths.map((path3) => {
1312
+ const absPath = getAbsolutePath(path3, cwd);
1313
+ return absPath;
1314
+ });
1315
+ }
1316
+ paths.forEach((path3) => {
1317
+ this._removeIgnoredPath(path3);
1318
+ });
1319
+ this._userIgnored = void 0;
1320
+ if (!this._readyCount)
1321
+ this._readyCount = 0;
1322
+ this._readyCount += paths.length;
1323
+ Promise.all(paths.map(async (path3) => {
1324
+ const res = await this._nodeFsHandler._addToNodeFs(path3, !_internal, void 0, 0, _origAdd);
1325
+ if (res)
1326
+ this._emitReady();
1327
+ return res;
1328
+ })).then((results) => {
1329
+ if (this.closed)
1330
+ return;
1331
+ results.forEach((item) => {
1332
+ if (item)
1333
+ this.add(sysPath2.dirname(item), sysPath2.basename(_origAdd || item));
1334
+ });
1335
+ });
1336
+ return this;
1337
+ }
1338
+ /**
1339
+ * Close watchers or start ignoring events from specified paths.
1340
+ */
1341
+ unwatch(paths_) {
1342
+ if (this.closed)
1343
+ return this;
1344
+ const paths = unifyPaths(paths_);
1345
+ const { cwd } = this.options;
1346
+ paths.forEach((path3) => {
1347
+ if (!sysPath2.isAbsolute(path3) && !this._closers.has(path3)) {
1348
+ if (cwd)
1349
+ path3 = sysPath2.join(cwd, path3);
1350
+ path3 = sysPath2.resolve(path3);
1351
+ }
1352
+ this._closePath(path3);
1353
+ this._addIgnoredPath(path3);
1354
+ if (this._watched.has(path3)) {
1355
+ this._addIgnoredPath({
1356
+ path: path3,
1357
+ recursive: true
1358
+ });
1359
+ }
1360
+ this._userIgnored = void 0;
1361
+ });
1362
+ return this;
1363
+ }
1364
+ /**
1365
+ * Close watchers and remove all listeners from watched paths.
1366
+ */
1367
+ close() {
1368
+ if (this._closePromise) {
1369
+ return this._closePromise;
1370
+ }
1371
+ this.closed = true;
1372
+ this.removeAllListeners();
1373
+ const closers = [];
1374
+ this._closers.forEach((closerList) => closerList.forEach((closer) => {
1375
+ const promise = closer();
1376
+ if (promise instanceof Promise)
1377
+ closers.push(promise);
1378
+ }));
1379
+ this._streams.forEach((stream) => stream.destroy());
1380
+ this._userIgnored = void 0;
1381
+ this._readyCount = 0;
1382
+ this._readyEmitted = false;
1383
+ this._watched.forEach((dirent) => dirent.dispose());
1384
+ this._closers.clear();
1385
+ this._watched.clear();
1386
+ this._streams.clear();
1387
+ this._symlinkPaths.clear();
1388
+ this._throttled.clear();
1389
+ this._closePromise = closers.length ? Promise.all(closers).then(() => void 0) : Promise.resolve();
1390
+ return this._closePromise;
1391
+ }
1392
+ /**
1393
+ * Expose list of watched paths
1394
+ * @returns for chaining
1395
+ */
1396
+ getWatched() {
1397
+ const watchList = {};
1398
+ this._watched.forEach((entry, dir) => {
1399
+ const key = this.options.cwd ? sysPath2.relative(this.options.cwd, dir) : dir;
1400
+ const index = key || ONE_DOT;
1401
+ watchList[index] = entry.getChildren().sort();
1402
+ });
1403
+ return watchList;
1404
+ }
1405
+ emitWithAll(event, args) {
1406
+ this.emit(event, ...args);
1407
+ if (event !== EVENTS.ERROR)
1408
+ this.emit(EVENTS.ALL, event, ...args);
1409
+ }
1410
+ // Common helpers
1411
+ // --------------
1412
+ /**
1413
+ * Normalize and emit events.
1414
+ * Calling _emit DOES NOT MEAN emit() would be called!
1415
+ * @param event Type of event
1416
+ * @param path File or directory path
1417
+ * @param stats arguments to be passed with event
1418
+ * @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
1419
+ */
1420
+ async _emit(event, path3, stats) {
1421
+ if (this.closed)
1422
+ return;
1423
+ const opts = this.options;
1424
+ if (isWindows)
1425
+ path3 = sysPath2.normalize(path3);
1426
+ if (opts.cwd)
1427
+ path3 = sysPath2.relative(opts.cwd, path3);
1428
+ const args = [path3];
1429
+ if (stats != null)
1430
+ args.push(stats);
1431
+ const awf = opts.awaitWriteFinish;
1432
+ let pw;
1433
+ if (awf && (pw = this._pendingWrites.get(path3))) {
1434
+ pw.lastChange = /* @__PURE__ */ new Date();
1435
+ return this;
1436
+ }
1437
+ if (opts.atomic) {
1438
+ if (event === EVENTS.UNLINK) {
1439
+ this._pendingUnlinks.set(path3, [event, ...args]);
1440
+ setTimeout(() => {
1441
+ this._pendingUnlinks.forEach((entry, path4) => {
1442
+ this.emit(...entry);
1443
+ this.emit(EVENTS.ALL, ...entry);
1444
+ this._pendingUnlinks.delete(path4);
1445
+ });
1446
+ }, typeof opts.atomic === "number" ? opts.atomic : 100);
1447
+ return this;
1448
+ }
1449
+ if (event === EVENTS.ADD && this._pendingUnlinks.has(path3)) {
1450
+ event = EVENTS.CHANGE;
1451
+ this._pendingUnlinks.delete(path3);
1452
+ }
1453
+ }
1454
+ if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
1455
+ const awfEmit = (err, stats2) => {
1456
+ if (err) {
1457
+ event = EVENTS.ERROR;
1458
+ args[0] = err;
1459
+ this.emitWithAll(event, args);
1460
+ } else if (stats2) {
1461
+ if (args.length > 1) {
1462
+ args[1] = stats2;
1463
+ } else {
1464
+ args.push(stats2);
1465
+ }
1466
+ this.emitWithAll(event, args);
1467
+ }
1468
+ };
1469
+ this._awaitWriteFinish(path3, awf.stabilityThreshold, event, awfEmit);
1470
+ return this;
1471
+ }
1472
+ if (event === EVENTS.CHANGE) {
1473
+ const isThrottled = !this._throttle(EVENTS.CHANGE, path3, 50);
1474
+ if (isThrottled)
1475
+ return this;
1476
+ }
1477
+ if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
1478
+ const fullPath = opts.cwd ? sysPath2.join(opts.cwd, path3) : path3;
1479
+ let stats2;
1480
+ try {
1481
+ stats2 = await (0, import_promises3.stat)(fullPath);
1482
+ } catch (err) {
1483
+ }
1484
+ if (!stats2 || this.closed)
1485
+ return;
1486
+ args.push(stats2);
1487
+ }
1488
+ this.emitWithAll(event, args);
1489
+ return this;
1490
+ }
1491
+ /**
1492
+ * Common handler for errors
1493
+ * @returns The error if defined, otherwise the value of the FSWatcher instance's `closed` flag
1494
+ */
1495
+ _handleError(error) {
1496
+ const code = error && error.code;
1497
+ if (error && code !== "ENOENT" && code !== "ENOTDIR" && (!this.options.ignorePermissionErrors || code !== "EPERM" && code !== "EACCES")) {
1498
+ this.emit(EVENTS.ERROR, error);
1499
+ }
1500
+ return error || this.closed;
1501
+ }
1502
+ /**
1503
+ * Helper utility for throttling
1504
+ * @param actionType type being throttled
1505
+ * @param path being acted upon
1506
+ * @param timeout duration of time to suppress duplicate actions
1507
+ * @returns tracking object or false if action should be suppressed
1508
+ */
1509
+ _throttle(actionType, path3, timeout) {
1510
+ if (!this._throttled.has(actionType)) {
1511
+ this._throttled.set(actionType, /* @__PURE__ */ new Map());
1512
+ }
1513
+ const action = this._throttled.get(actionType);
1514
+ if (!action)
1515
+ throw new Error("invalid throttle");
1516
+ const actionPath = action.get(path3);
1517
+ if (actionPath) {
1518
+ actionPath.count++;
1519
+ return false;
1520
+ }
1521
+ let timeoutObject;
1522
+ const clear = () => {
1523
+ const item = action.get(path3);
1524
+ const count = item ? item.count : 0;
1525
+ action.delete(path3);
1526
+ clearTimeout(timeoutObject);
1527
+ if (item)
1528
+ clearTimeout(item.timeoutObject);
1529
+ return count;
1530
+ };
1531
+ timeoutObject = setTimeout(clear, timeout);
1532
+ const thr = { timeoutObject, clear, count: 0 };
1533
+ action.set(path3, thr);
1534
+ return thr;
1535
+ }
1536
+ _incrReadyCount() {
1537
+ return this._readyCount++;
1538
+ }
1539
+ /**
1540
+ * Awaits write operation to finish.
1541
+ * Polls a newly created file for size variations. When files size does not change for 'threshold' milliseconds calls callback.
1542
+ * @param path being acted upon
1543
+ * @param threshold Time in milliseconds a file size must be fixed before acknowledging write OP is finished
1544
+ * @param event
1545
+ * @param awfEmit Callback to be called when ready for event to be emitted.
1546
+ */
1547
+ _awaitWriteFinish(path3, threshold, event, awfEmit) {
1548
+ const awf = this.options.awaitWriteFinish;
1549
+ if (typeof awf !== "object")
1550
+ return;
1551
+ const pollInterval = awf.pollInterval;
1552
+ let timeoutHandler;
1553
+ let fullPath = path3;
1554
+ if (this.options.cwd && !sysPath2.isAbsolute(path3)) {
1555
+ fullPath = sysPath2.join(this.options.cwd, path3);
1556
+ }
1557
+ const now = /* @__PURE__ */ new Date();
1558
+ const writes = this._pendingWrites;
1559
+ function awaitWriteFinishFn(prevStat) {
1560
+ (0, import_fs2.stat)(fullPath, (err, curStat) => {
1561
+ if (err || !writes.has(path3)) {
1562
+ if (err && err.code !== "ENOENT")
1563
+ awfEmit(err);
1564
+ return;
1565
+ }
1566
+ const now2 = Number(/* @__PURE__ */ new Date());
1567
+ if (prevStat && curStat.size !== prevStat.size) {
1568
+ writes.get(path3).lastChange = now2;
1569
+ }
1570
+ const pw = writes.get(path3);
1571
+ const df = now2 - pw.lastChange;
1572
+ if (df >= threshold) {
1573
+ writes.delete(path3);
1574
+ awfEmit(void 0, curStat);
1575
+ } else {
1576
+ timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
1577
+ }
1578
+ });
1579
+ }
1580
+ if (!writes.has(path3)) {
1581
+ writes.set(path3, {
1582
+ lastChange: now,
1583
+ cancelWait: () => {
1584
+ writes.delete(path3);
1585
+ clearTimeout(timeoutHandler);
1586
+ return event;
1587
+ }
1588
+ });
1589
+ timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval);
1590
+ }
1591
+ }
1592
+ /**
1593
+ * Determines whether user has asked to ignore this path.
1594
+ */
1595
+ _isIgnored(path3, stats) {
1596
+ if (this.options.atomic && DOT_RE.test(path3))
1597
+ return true;
1598
+ if (!this._userIgnored) {
1599
+ const { cwd } = this.options;
1600
+ const ign = this.options.ignored;
1601
+ const ignored = (ign || []).map(normalizeIgnored(cwd));
1602
+ const ignoredPaths = [...this._ignoredPaths];
1603
+ const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
1604
+ this._userIgnored = anymatch(list, void 0);
1605
+ }
1606
+ return this._userIgnored(path3, stats);
1607
+ }
1608
+ _isntIgnored(path3, stat4) {
1609
+ return !this._isIgnored(path3, stat4);
1610
+ }
1611
+ /**
1612
+ * Provides a set of common helpers and properties relating to symlink handling.
1613
+ * @param path file or directory pattern being watched
1614
+ */
1615
+ _getWatchHelpers(path3) {
1616
+ return new WatchHelper(path3, this.options.followSymlinks, this);
1617
+ }
1618
+ // Directory helpers
1619
+ // -----------------
1620
+ /**
1621
+ * Provides directory tracking objects
1622
+ * @param directory path of the directory
1623
+ */
1624
+ _getWatchedDir(directory) {
1625
+ const dir = sysPath2.resolve(directory);
1626
+ if (!this._watched.has(dir))
1627
+ this._watched.set(dir, new DirEntry(dir, this._boundRemove));
1628
+ return this._watched.get(dir);
1629
+ }
1630
+ // File helpers
1631
+ // ------------
1632
+ /**
1633
+ * Check for read permissions: https://stackoverflow.com/a/11781404/1358405
1634
+ */
1635
+ _hasReadPermissions(stats) {
1636
+ if (this.options.ignorePermissionErrors)
1637
+ return true;
1638
+ return Boolean(Number(stats.mode) & 256);
1639
+ }
1640
+ /**
1641
+ * Handles emitting unlink events for
1642
+ * files and directories, and via recursion, for
1643
+ * files and directories within directories that are unlinked
1644
+ * @param directory within which the following item is located
1645
+ * @param item base path of item/directory
1646
+ */
1647
+ _remove(directory, item, isDirectory) {
1648
+ const path3 = sysPath2.join(directory, item);
1649
+ const fullPath = sysPath2.resolve(path3);
1650
+ isDirectory = isDirectory != null ? isDirectory : this._watched.has(path3) || this._watched.has(fullPath);
1651
+ if (!this._throttle("remove", path3, 100))
1652
+ return;
1653
+ if (!isDirectory && this._watched.size === 1) {
1654
+ this.add(directory, item, true);
1655
+ }
1656
+ const wp = this._getWatchedDir(path3);
1657
+ const nestedDirectoryChildren = wp.getChildren();
1658
+ nestedDirectoryChildren.forEach((nested) => this._remove(path3, nested));
1659
+ const parent = this._getWatchedDir(directory);
1660
+ const wasTracked = parent.has(item);
1661
+ parent.remove(item);
1662
+ if (this._symlinkPaths.has(fullPath)) {
1663
+ this._symlinkPaths.delete(fullPath);
1664
+ }
1665
+ let relPath = path3;
1666
+ if (this.options.cwd)
1667
+ relPath = sysPath2.relative(this.options.cwd, path3);
1668
+ if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
1669
+ const event = this._pendingWrites.get(relPath).cancelWait();
1670
+ if (event === EVENTS.ADD)
1671
+ return;
1672
+ }
1673
+ this._watched.delete(path3);
1674
+ this._watched.delete(fullPath);
1675
+ const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
1676
+ if (wasTracked && !this._isIgnored(path3))
1677
+ this._emit(eventName, path3);
1678
+ this._closePath(path3);
1679
+ }
1680
+ /**
1681
+ * Closes all watchers for a path
1682
+ */
1683
+ _closePath(path3) {
1684
+ this._closeFile(path3);
1685
+ const dir = sysPath2.dirname(path3);
1686
+ this._getWatchedDir(dir).remove(sysPath2.basename(path3));
1687
+ }
1688
+ /**
1689
+ * Closes only file-specific watchers
1690
+ */
1691
+ _closeFile(path3) {
1692
+ const closers = this._closers.get(path3);
1693
+ if (!closers)
1694
+ return;
1695
+ closers.forEach((closer) => closer());
1696
+ this._closers.delete(path3);
1697
+ }
1698
+ _addPathCloser(path3, closer) {
1699
+ if (!closer)
1700
+ return;
1701
+ let list = this._closers.get(path3);
1702
+ if (!list) {
1703
+ list = [];
1704
+ this._closers.set(path3, list);
1705
+ }
1706
+ list.push(closer);
1707
+ }
1708
+ _readdirp(root, opts) {
1709
+ if (this.closed)
1710
+ return;
1711
+ const options = { type: EVENTS.ALL, alwaysStat: true, lstat: true, ...opts, depth: 0 };
1712
+ let stream = readdirp(root, options);
1713
+ this._streams.add(stream);
1714
+ stream.once(STR_CLOSE, () => {
1715
+ stream = void 0;
1716
+ });
1717
+ stream.once(STR_END, () => {
1718
+ if (stream) {
1719
+ this._streams.delete(stream);
1720
+ stream = void 0;
1721
+ }
1722
+ });
1723
+ return stream;
1724
+ }
1725
+ };
1726
+ function watch(paths, options = {}) {
1727
+ const watcher = new FSWatcher(options);
1728
+ watcher.add(paths);
1729
+ return watcher;
1730
+ }
1731
+ var esm_default = { watch, FSWatcher };
1732
+
1733
+ // packages/playwright-core/src/package.ts
1734
+ var import_path = __toESM(require("path"));
1735
+ var packageRoot = import_path.default.join(__dirname, "..");
1736
+ var packageJSON = require(import_path.default.join(packageRoot, "package.json"));
1737
+ var binPath = import_path.default.join(packageRoot, "bin");
1738
+
1739
+ // packages/playwright-core/src/serverRegistry.ts
1740
+ var packageVersion = packageJSON.version;
1741
+ var ServerRegistry = class extends import_events2.EventEmitter {
1742
+ constructor() {
1743
+ super(...arguments);
1744
+ this._descriptors = /* @__PURE__ */ new Map();
1745
+ this._watcherRefs = 0;
1746
+ }
1747
+ on(event, listener) {
1748
+ return super.on(event, listener);
1749
+ }
1750
+ off(event, listener) {
1751
+ return super.off(event, listener);
1752
+ }
1753
+ watch() {
1754
+ this._watcherRefs++;
1755
+ if (!this._watcher)
1756
+ this._startWatcher();
1757
+ let disposed = false;
1758
+ return () => {
1759
+ if (disposed)
1760
+ return;
1761
+ disposed = true;
1762
+ this._watcherRefs--;
1763
+ if (this._watcherRefs === 0)
1764
+ this._stopWatcher();
1765
+ };
1766
+ }
1767
+ ready() {
1768
+ return this._ready ?? Promise.resolve();
1769
+ }
1770
+ async list() {
1771
+ const ownWatcher = !this._watcher;
1772
+ let dispose;
1773
+ if (ownWatcher)
1774
+ dispose = this.watch();
1775
+ try {
1776
+ await this._ready;
1777
+ const statuses = await Promise.all(
1778
+ [...this._descriptors.values()].map(async (descriptor) => {
1779
+ const canConnect = await canConnectTo(descriptor);
1780
+ return { descriptor, canConnect };
1781
+ })
1782
+ );
1783
+ const result = /* @__PURE__ */ new Map();
1784
+ for (const { descriptor, canConnect } of statuses) {
1785
+ if (!canConnect) {
1786
+ await import_fs3.default.promises.unlink(import_path2.default.join(this._browsersDir(), descriptor.browser.guid)).catch(() => {
1787
+ });
1788
+ continue;
1789
+ }
1790
+ const key = descriptor.workspaceDir ?? "";
1791
+ let list = result.get(key);
1792
+ if (!list) {
1793
+ list = [];
1794
+ result.set(key, list);
1795
+ }
1796
+ list.push(descriptor);
1797
+ }
1798
+ return result;
1799
+ } finally {
1800
+ dispose?.();
1801
+ }
1802
+ }
1803
+ async create(browser, endpoint) {
1804
+ const file = import_path2.default.join(this._browsersDir(), browser.guid);
1805
+ await import_fs3.default.promises.mkdir(this._browsersDir(), { recursive: true });
1806
+ const descriptor = {
1807
+ playwrightVersion: packageVersion,
1808
+ playwrightLib: packageRoot,
1809
+ title: endpoint.title,
1810
+ browser,
1811
+ endpoint: endpoint.endpoint,
1812
+ workspaceDir: endpoint.workspaceDir
1813
+ };
1814
+ await import_fs3.default.promises.writeFile(file, JSON.stringify(descriptor, null, 2), "utf-8");
1815
+ }
1816
+ async delete(guid) {
1817
+ const file = import_path2.default.join(this._browsersDir(), guid);
1818
+ await import_fs3.default.promises.unlink(file).catch(() => {
1819
+ });
1820
+ }
1821
+ async deleteUserData(guid) {
1822
+ const filePath = import_path2.default.join(this._browsersDir(), guid);
1823
+ const content = await import_fs3.default.promises.readFile(filePath, "utf-8");
1824
+ const descriptor = JSON.parse(content);
1825
+ if (descriptor.browser.userDataDir)
1826
+ await import_fs3.default.promises.rm(descriptor.browser.userDataDir, { recursive: true, force: true });
1827
+ await import_fs3.default.promises.unlink(filePath);
1828
+ }
1829
+ readDescriptor(guid) {
1830
+ const cached = this._descriptors.get(guid);
1831
+ if (cached)
1832
+ return cached;
1833
+ const filePath = import_path2.default.join(this._browsersDir(), guid);
1834
+ const content = import_fs3.default.readFileSync(filePath, "utf-8");
1835
+ return JSON.parse(content);
1836
+ }
1837
+ async find(name) {
1838
+ const entries = await this.list();
1839
+ for (const [, browsers] of entries) {
1840
+ for (const browser of browsers) {
1841
+ if (browser.title === name)
1842
+ return browser;
1843
+ }
1844
+ }
1845
+ return null;
1846
+ }
1847
+ _browsersDir() {
1848
+ return process.env.PWTEST_SERVER_REGISTRY || registryDirectory();
1849
+ }
1850
+ _startWatcher() {
1851
+ const dir = this._browsersDir();
1852
+ try {
1853
+ import_fs3.default.mkdirSync(dir, { recursive: true });
1854
+ } catch {
1855
+ }
1856
+ const watcher = esm_default.watch(dir, {
1857
+ ignoreInitial: false,
1858
+ depth: 0,
1859
+ awaitWriteFinish: { stabilityThreshold: 50, pollInterval: 20 }
1860
+ });
1861
+ this._watcher = watcher;
1862
+ this._ready = new Promise((resolve3, reject) => {
1863
+ watcher.once("ready", () => resolve3());
1864
+ watcher.once("error", reject);
1865
+ });
1866
+ watcher.on("add", (file) => this._onAddOrChange(file, "added"));
1867
+ watcher.on("change", (file) => this._onAddOrChange(file, "changed"));
1868
+ watcher.on("unlink", (file) => {
1869
+ const guid = import_path2.default.basename(file);
1870
+ if (this._descriptors.delete(guid))
1871
+ this.emit("removed", guid);
1872
+ });
1873
+ }
1874
+ _onAddOrChange(file, event) {
1875
+ const guid = import_path2.default.basename(file);
1876
+ let descriptor;
1877
+ try {
1878
+ descriptor = JSON.parse(import_fs3.default.readFileSync(file, "utf-8"));
1879
+ } catch {
1880
+ return;
1881
+ }
1882
+ this._descriptors.set(guid, descriptor);
1883
+ this.emit(event, descriptor);
1884
+ }
1885
+ _stopWatcher() {
1886
+ const watcher = this._watcher;
1887
+ this._watcher = void 0;
1888
+ this._ready = void 0;
1889
+ this._descriptors.clear();
1890
+ void watcher?.close();
1891
+ }
1892
+ };
1893
+ async function canConnectTo(descriptor) {
1894
+ if (!descriptor.endpoint)
1895
+ return false;
1896
+ if (descriptor.endpoint.startsWith("ws://") || descriptor.endpoint.startsWith("wss://")) {
1897
+ return await new Promise((resolve3) => {
1898
+ const url = new URL(descriptor.endpoint);
1899
+ const socket = import_net.default.createConnection(Number(url.port), url.hostname, () => {
1900
+ socket.destroy();
1901
+ resolve3(true);
1902
+ });
1903
+ socket.on("error", () => resolve3(false));
1904
+ });
1905
+ }
1906
+ return await new Promise((resolve3) => {
1907
+ const socket = import_net.default.createConnection(descriptor.endpoint ?? descriptor.pipeName, () => {
1908
+ socket.destroy();
1909
+ resolve3(true);
1910
+ });
1911
+ socket.on("error", () => resolve3(false));
1912
+ });
1913
+ }
1914
+ function computeDefaultCacheDirectory() {
1915
+ if (process.platform === "linux")
1916
+ return process.env.XDG_CACHE_HOME || import_path2.default.join(import_os2.default.homedir(), ".cache");
1917
+ if (process.platform === "darwin")
1918
+ return import_path2.default.join(import_os2.default.homedir(), "Library", "Caches");
1919
+ if (process.platform === "win32")
1920
+ return process.env.LOCALAPPDATA || import_path2.default.join(import_os2.default.homedir(), "AppData", "Local");
1921
+ throw new Error("Unsupported platform: " + process.platform);
1922
+ }
1923
+ var _defaultCacheDirectory;
1924
+ function defaultCacheDirectory() {
1925
+ return _defaultCacheDirectory ??= computeDefaultCacheDirectory();
1926
+ }
1927
+ function registryDirectory() {
1928
+ return import_path2.default.join(defaultCacheDirectory(), "ms-playwright", "b");
1929
+ }
1930
+ var serverRegistry = new ServerRegistry();
1931
+ // Annotate the CommonJS export names for ESM import in node:
1932
+ 0 && (module.exports = {
1933
+ serverRegistry
1934
+ });
1935
+ /*! Bundled license information:
1936
+
1937
+ chokidar/esm/index.js:
1938
+ (*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) *)
1939
+ */