patchright-core 1.56.1 → 1.57.0

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 (100) hide show
  1. package/ThirdPartyNotices.txt +40 -381
  2. package/bin/install_webkit_wsl.ps1 +1 -3
  3. package/browsers.json +13 -13
  4. package/lib/cli/program.js +14 -57
  5. package/lib/client/api.js +0 -3
  6. package/lib/client/browserContext.js +22 -4
  7. package/lib/client/consoleMessage.js +5 -1
  8. package/lib/client/electron.js +1 -1
  9. package/lib/client/events.js +2 -1
  10. package/lib/client/locator.js +4 -1
  11. package/lib/client/page.js +2 -5
  12. package/lib/client/playwright.js +1 -5
  13. package/lib/client/tracing.js +6 -4
  14. package/lib/client/worker.js +22 -0
  15. package/lib/generated/clockSource.js +1 -1
  16. package/lib/generated/injectedScriptSource.js +1 -1
  17. package/lib/generated/pollingRecorderSource.js +1 -1
  18. package/lib/inProcessFactory.js +0 -2
  19. package/lib/protocol/validator.js +24 -46
  20. package/lib/server/android/android.js +1 -1
  21. package/lib/server/bidi/bidiBrowser.js +26 -11
  22. package/lib/server/bidi/bidiChromium.js +1 -1
  23. package/lib/server/bidi/bidiFirefox.js +1 -1
  24. package/lib/server/bidi/bidiPage.js +25 -5
  25. package/lib/server/browserContext.js +9 -10
  26. package/lib/server/chromium/chromium.js +12 -1
  27. package/lib/server/chromium/chromiumSwitches.js +10 -1
  28. package/lib/server/chromium/crBrowser.js +8 -0
  29. package/lib/server/chromium/crNetworkManager.js +15 -6
  30. package/lib/server/chromium/crPage.js +7 -9
  31. package/lib/server/chromium/crServiceWorker.js +14 -1
  32. package/lib/server/chromium/videoRecorder.js +14 -12
  33. package/lib/server/console.js +5 -1
  34. package/lib/server/deviceDescriptorsSource.json +56 -56
  35. package/lib/server/dispatchers/browserContextDispatcher.js +23 -6
  36. package/lib/server/dispatchers/pageDispatcher.js +10 -22
  37. package/lib/server/dispatchers/playwrightDispatcher.js +0 -4
  38. package/lib/server/electron/electron.js +1 -1
  39. package/lib/server/firefox/ffPage.js +3 -6
  40. package/lib/server/firefox/firefox.js +12 -1
  41. package/lib/server/frameSelectors.js +2 -4
  42. package/lib/server/frames.js +6 -1
  43. package/lib/server/input.js +7 -3
  44. package/lib/server/localUtils.js +4 -8
  45. package/lib/server/page.js +54 -38
  46. package/lib/server/playwright.js +2 -4
  47. package/lib/server/recorder/recorderApp.js +1 -1
  48. package/lib/server/recorder.js +3 -2
  49. package/lib/server/registry/index.js +114 -48
  50. package/lib/server/registry/oopDownloadBrowserMain.js +6 -2
  51. package/lib/server/socksClientCertificatesInterceptor.js +1 -1
  52. package/lib/server/trace/recorder/tracing.js +2 -0
  53. package/lib/server/trace/viewer/traceViewer.js +37 -36
  54. package/lib/server/utils/comparators.js +3 -25
  55. package/lib/server/utils/hostPlatform.js +15 -3
  56. package/lib/server/utils/imageUtils.js +141 -0
  57. package/lib/server/utils/network.js +22 -16
  58. package/lib/server/webkit/webkit.js +1 -10
  59. package/lib/server/webkit/wkPage.js +1 -5
  60. package/lib/server/webkit/wkWorkers.js +2 -1
  61. package/lib/utils/isomorphic/ariaSnapshot.js +5 -0
  62. package/lib/utils/isomorphic/locatorGenerators.js +24 -8
  63. package/lib/utils/isomorphic/mimeType.js +1 -1
  64. package/lib/utils/isomorphic/protocolFormatter.js +3 -0
  65. package/lib/utils/isomorphic/protocolMetainfo.js +2 -1
  66. package/lib/utils/isomorphic/urlMatch.js +19 -5
  67. package/lib/utils.js +2 -0
  68. package/lib/utilsBundle.js +6 -3
  69. package/lib/utilsBundleImpl/index.js +171 -171
  70. package/lib/vite/htmlReport/index.html +18 -18
  71. package/lib/vite/recorder/assets/codeMirrorModule-CBbSe-ZI.js +25 -0
  72. package/lib/vite/recorder/assets/{index-Y-X2TGJv.js → index-CpZVd2nA.js} +32 -32
  73. package/lib/vite/recorder/index.html +1 -1
  74. package/lib/vite/traceViewer/assets/codeMirrorModule-DHz0wP2C.js +25 -0
  75. package/lib/vite/traceViewer/assets/defaultSettingsView-WsZP88O6.js +266 -0
  76. package/lib/vite/traceViewer/defaultSettingsView.ConWv5KN.css +1 -0
  77. package/lib/vite/traceViewer/index.C4Y3Aw8n.css +1 -0
  78. package/lib/vite/traceViewer/index.C8xAeo93.js +2 -0
  79. package/lib/vite/traceViewer/index.html +6 -6
  80. package/lib/vite/traceViewer/manifest.webmanifest +16 -0
  81. package/lib/vite/traceViewer/snapshot.html +3 -3
  82. package/lib/vite/traceViewer/sw.bundle.js +3 -3
  83. package/lib/vite/traceViewer/{uiMode.B_CpmIpF.js → uiMode.BltraIJB.js} +3 -3
  84. package/lib/vite/traceViewer/uiMode.html +3 -3
  85. package/package.json +1 -1
  86. package/types/protocol.d.ts +213 -98
  87. package/types/types.d.ts +120 -117
  88. package/lib/client/accessibility.js +0 -49
  89. package/lib/server/accessibility.js +0 -69
  90. package/lib/server/chromium/crAccessibility.js +0 -263
  91. package/lib/server/firefox/ffAccessibility.js +0 -238
  92. package/lib/server/webkit/wkAccessibility.js +0 -237
  93. package/lib/server/webkit/wsl/webkit-wsl-transport-client.js +0 -74
  94. package/lib/server/webkit/wsl/webkit-wsl-transport-server.js +0 -113
  95. package/lib/vite/recorder/assets/codeMirrorModule-RJCXzfmE.js +0 -24
  96. package/lib/vite/traceViewer/assets/codeMirrorModule-rbQPefq7.js +0 -24
  97. package/lib/vite/traceViewer/assets/defaultSettingsView-CLbol9XR.js +0 -265
  98. package/lib/vite/traceViewer/defaultSettingsView.TQ8_7ybu.css +0 -1
  99. package/lib/vite/traceViewer/index.I8N9v4jT.css +0 -1
  100. package/lib/vite/traceViewer/index.zIVi6mN9.js +0 -2
package/types/types.d.ts CHANGED
@@ -2496,6 +2496,12 @@ export interface Page {
2496
2496
  y: number;
2497
2497
  };
2498
2498
 
2499
+ /**
2500
+ * Defaults to 1. Sends `n` interpolated `mousemove` events to represent travel between the `mousedown` and `mouseup`
2501
+ * of the drag. When set to 1, emits a single `mousemove` event at the destination location.
2502
+ */
2503
+ steps?: number;
2504
+
2499
2505
  /**
2500
2506
  * When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
2501
2507
  * element, the call throws an exception.
@@ -5167,13 +5173,6 @@ export interface Page {
5167
5173
  */
5168
5174
  workers(): Array<Worker>;
5169
5175
 
5170
- /**
5171
- * @deprecated This property is discouraged. Please use other libraries such as [Axe](https://www.deque.com/axe/) if you need to
5172
- * test page accessibility. See our Node.js [guide](https://playwright.dev/docs/accessibility-testing) for integration
5173
- * with Axe.
5174
- */
5175
- accessibility: Accessibility;
5176
-
5177
5176
  /**
5178
5177
  * Playwright has ability to mock clock and passage of time.
5179
5178
  */
@@ -6407,6 +6406,12 @@ export interface Frame {
6407
6406
  y: number;
6408
6407
  };
6409
6408
 
6409
+ /**
6410
+ * Defaults to 1. Sends `n` interpolated `mousemove` events to represent travel between the `mousedown` and `mouseup`
6411
+ * of the drag. When set to 1, emits a single `mousemove` event at the destination location.
6412
+ */
6413
+ steps?: number;
6414
+
6410
6415
  /**
6411
6416
  * When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
6412
6417
  * element, the call throws an exception.
@@ -8802,18 +8807,18 @@ export interface BrowserContext {
8802
8807
  value: string;
8803
8808
 
8804
8809
  /**
8805
- * Either url or domain / path are required. Optional.
8810
+ * Either `url` or both `domain` and `path` are required. Optional.
8806
8811
  */
8807
8812
  url?: string;
8808
8813
 
8809
8814
  /**
8810
- * For the cookie to apply to all subdomains as well, prefix domain with a dot, like this: ".example.com". Either url
8811
- * or domain / path are required. Optional.
8815
+ * For the cookie to apply to all subdomains as well, prefix domain with a dot, like this: ".example.com". Either
8816
+ * `url` or both `domain` and `path` are required. Optional.
8812
8817
  */
8813
8818
  domain?: string;
8814
8819
 
8815
8820
  /**
8816
- * Either url or domain / path are required Optional.
8821
+ * Either `url` or both `domain` and `path` are required. Optional.
8817
8822
  */
8818
8823
  path?: string;
8819
8824
 
@@ -10325,34 +10330,76 @@ export interface Worker {
10325
10330
  */
10326
10331
  on(event: 'close', listener: (worker: Worker) => any): this;
10327
10332
 
10333
+ /**
10334
+ * Emitted when JavaScript within the worker calls one of console API methods, e.g. `console.log` or `console.dir`.
10335
+ */
10336
+ on(event: 'console', listener: (consoleMessage: ConsoleMessage) => any): this;
10337
+
10328
10338
  /**
10329
10339
  * Adds an event listener that will be automatically removed after it is triggered once. See `addListener` for more information about this event.
10330
10340
  */
10331
10341
  once(event: 'close', listener: (worker: Worker) => any): this;
10332
10342
 
10343
+ /**
10344
+ * Adds an event listener that will be automatically removed after it is triggered once. See `addListener` for more information about this event.
10345
+ */
10346
+ once(event: 'console', listener: (consoleMessage: ConsoleMessage) => any): this;
10347
+
10333
10348
  /**
10334
10349
  * Emitted when this dedicated [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) is
10335
10350
  * terminated.
10336
10351
  */
10337
10352
  addListener(event: 'close', listener: (worker: Worker) => any): this;
10338
10353
 
10354
+ /**
10355
+ * Emitted when JavaScript within the worker calls one of console API methods, e.g. `console.log` or `console.dir`.
10356
+ */
10357
+ addListener(event: 'console', listener: (consoleMessage: ConsoleMessage) => any): this;
10358
+
10339
10359
  /**
10340
10360
  * Removes an event listener added by `on` or `addListener`.
10341
10361
  */
10342
10362
  removeListener(event: 'close', listener: (worker: Worker) => any): this;
10343
10363
 
10364
+ /**
10365
+ * Removes an event listener added by `on` or `addListener`.
10366
+ */
10367
+ removeListener(event: 'console', listener: (consoleMessage: ConsoleMessage) => any): this;
10368
+
10344
10369
  /**
10345
10370
  * Removes an event listener added by `on` or `addListener`.
10346
10371
  */
10347
10372
  off(event: 'close', listener: (worker: Worker) => any): this;
10348
10373
 
10374
+ /**
10375
+ * Removes an event listener added by `on` or `addListener`.
10376
+ */
10377
+ off(event: 'console', listener: (consoleMessage: ConsoleMessage) => any): this;
10378
+
10349
10379
  /**
10350
10380
  * Emitted when this dedicated [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) is
10351
10381
  * terminated.
10352
10382
  */
10353
10383
  prependListener(event: 'close', listener: (worker: Worker) => any): this;
10354
10384
 
10385
+ /**
10386
+ * Emitted when JavaScript within the worker calls one of console API methods, e.g. `console.log` or `console.dir`.
10387
+ */
10388
+ prependListener(event: 'console', listener: (consoleMessage: ConsoleMessage) => any): this;
10389
+
10355
10390
  url(): string;
10391
+
10392
+ /**
10393
+ * Emitted when this dedicated [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) is
10394
+ * terminated.
10395
+ */
10396
+ waitForEvent(event: 'close', optionsOrPredicate?: { predicate?: (worker: Worker) => boolean | Promise<boolean>, timeout?: number } | ((worker: Worker) => boolean | Promise<boolean>)): Promise<Worker>;
10397
+
10398
+ /**
10399
+ * Emitted when JavaScript within the worker calls one of console API methods, e.g. `console.log` or `console.dir`.
10400
+ */
10401
+ waitForEvent(event: 'console', optionsOrPredicate?: { predicate?: (consoleMessage: ConsoleMessage) => boolean | Promise<boolean>, timeout?: number } | ((consoleMessage: ConsoleMessage) => boolean | Promise<boolean>)): Promise<ConsoleMessage>;
10402
+
10356
10403
  }
10357
10404
 
10358
10405
  /**
@@ -11211,6 +11258,12 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
11211
11258
  y: number;
11212
11259
  };
11213
11260
 
11261
+ /**
11262
+ * Defaults to 1. Sends `n` interpolated `mousemove` events to represent travel between Playwright's current cursor
11263
+ * position and the provided destination. When set to 1, emits a single `mousemove` event at the destination location.
11264
+ */
11265
+ steps?: number;
11266
+
11214
11267
  /**
11215
11268
  * Maximum time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout`
11216
11269
  * option in the config, or by using the
@@ -11294,6 +11347,12 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
11294
11347
  y: number;
11295
11348
  };
11296
11349
 
11350
+ /**
11351
+ * Defaults to 1. Sends `n` interpolated `mousemove` events to represent travel between Playwright's current cursor
11352
+ * position and the provided destination. When set to 1, emits a single `mousemove` event at the destination location.
11353
+ */
11354
+ steps?: number;
11355
+
11297
11356
  /**
11298
11357
  * Maximum time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout`
11299
11358
  * option in the config, or by using the
@@ -12788,6 +12847,12 @@ export interface Locator {
12788
12847
  y: number;
12789
12848
  };
12790
12849
 
12850
+ /**
12851
+ * Defaults to 1. Sends `n` interpolated `mousemove` events to represent travel between Playwright's current cursor
12852
+ * position and the provided destination. When set to 1, emits a single `mousemove` event at the destination location.
12853
+ */
12854
+ steps?: number;
12855
+
12791
12856
  /**
12792
12857
  * Maximum time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout`
12793
12858
  * option in the config, or by using the
@@ -12905,6 +12970,12 @@ export interface Locator {
12905
12970
  y: number;
12906
12971
  };
12907
12972
 
12973
+ /**
12974
+ * Defaults to 1. Sends `n` interpolated `mousemove` events to represent travel between Playwright's current cursor
12975
+ * position and the provided destination. When set to 1, emits a single `mousemove` event at the destination location.
12976
+ */
12977
+ steps?: number;
12978
+
12908
12979
  /**
12909
12980
  * Maximum time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout`
12910
12981
  * option in the config, or by using the
@@ -12937,6 +13008,25 @@ export interface Locator {
12937
13008
  */
12938
13009
  describe(description: string): Locator;
12939
13010
 
13011
+ /**
13012
+ * Returns locator description previously set with
13013
+ * [locator.describe(description)](https://playwright.dev/docs/api/class-locator#locator-describe). Returns `null` if
13014
+ * no custom description has been set. Prefer `Locator.toString()` for a human-readable representation, as it uses the
13015
+ * description when available.
13016
+ *
13017
+ * **Usage**
13018
+ *
13019
+ * ```js
13020
+ * const button = page.getByRole('button').describe('Subscribe button');
13021
+ * console.log(button.description()); // "Subscribe button"
13022
+ *
13023
+ * const input = page.getByRole('textbox');
13024
+ * console.log(input.description()); // null
13025
+ * ```
13026
+ *
13027
+ */
13028
+ description(): null|string;
13029
+
12940
13030
  /**
12941
13031
  * Programmatically dispatch an event on the matching element.
12942
13032
  *
@@ -13039,6 +13129,12 @@ export interface Locator {
13039
13129
  y: number;
13040
13130
  };
13041
13131
 
13132
+ /**
13133
+ * Defaults to 1. Sends `n` interpolated `mousemove` events to represent travel between the `mousedown` and `mouseup`
13134
+ * of the drag. When set to 1, emits a single `mousemove` event at the destination location.
13135
+ */
13136
+ steps?: number;
13137
+
13042
13138
  /**
13043
13139
  * Drops on the target element at this point relative to the top-left corner of the element's padding box. If not
13044
13140
  * specified, some visible point of the element is used.
@@ -15731,97 +15827,6 @@ class TimeoutError extends Error {
15731
15827
 
15732
15828
  }
15733
15829
 
15734
- /**
15735
- * The Accessibility class provides methods for inspecting Chromium's accessibility tree. The accessibility tree is
15736
- * used by assistive technology such as [screen readers](https://en.wikipedia.org/wiki/Screen_reader) or
15737
- * [switches](https://en.wikipedia.org/wiki/Switch_access).
15738
- *
15739
- * Accessibility is a very platform-specific thing. On different platforms, there are different screen readers that
15740
- * might have wildly different output.
15741
- *
15742
- * Rendering engines of Chromium, Firefox and WebKit have a concept of "accessibility tree", which is then translated
15743
- * into different platform-specific APIs. Accessibility namespace gives access to this Accessibility Tree.
15744
- *
15745
- * Most of the accessibility tree gets filtered out when converting from internal browser AX Tree to Platform-specific
15746
- * AX-Tree or by assistive technologies themselves. By default, Playwright tries to approximate this filtering,
15747
- * exposing only the "interesting" nodes of the tree.
15748
- */
15749
- export interface Accessibility {
15750
- /**
15751
- * Captures the current state of the accessibility tree. The returned object represents the root accessible node of
15752
- * the page.
15753
- *
15754
- * **NOTE** The Chromium accessibility tree contains nodes that go unused on most platforms and by most screen
15755
- * readers. Playwright will discard them as well for an easier to process tree, unless
15756
- * [`interestingOnly`](https://playwright.dev/docs/api/class-accessibility#accessibility-snapshot-option-interesting-only)
15757
- * is set to `false`.
15758
- *
15759
- * **Usage**
15760
- *
15761
- * An example of dumping the entire accessibility tree:
15762
- *
15763
- * ```js
15764
- * const snapshot = await page.accessibility.snapshot();
15765
- * console.log(snapshot);
15766
- * ```
15767
- *
15768
- * An example of logging the focused node's name:
15769
- *
15770
- * ```js
15771
- * const snapshot = await page.accessibility.snapshot();
15772
- * const node = findFocusedNode(snapshot);
15773
- * console.log(node && node.name);
15774
- *
15775
- * function findFocusedNode(node) {
15776
- * if (node.focused)
15777
- * return node;
15778
- * for (const child of node.children || []) {
15779
- * const foundNode = findFocusedNode(child);
15780
- * if (foundNode)
15781
- * return foundNode;
15782
- * }
15783
- * return null;
15784
- * }
15785
- * ```
15786
- *
15787
- * @deprecated This method is deprecated. Please use other libraries such as [Axe](https://www.deque.com/axe/) if you need to test
15788
- * page accessibility. See our Node.js [guide](https://playwright.dev/docs/accessibility-testing) for integration with
15789
- * Axe.
15790
- * @param options
15791
- */
15792
- snapshot(options?: AccessibilitySnapshotOptions): Promise<null|AccessibilityNode>;
15793
-
15794
- }
15795
-
15796
- type AccessibilityNode = {
15797
- role: string;
15798
- name: string;
15799
- value?: string|number;
15800
- description?: string;
15801
- keyshortcuts?: string;
15802
- roledescription?: string;
15803
- valuetext?: string;
15804
- disabled?: boolean;
15805
- expanded?: boolean;
15806
- focused?: boolean;
15807
- modal?: boolean;
15808
- multiline?: boolean;
15809
- multiselectable?: boolean;
15810
- readonly?: boolean;
15811
- required?: boolean;
15812
- selected?: boolean;
15813
- checked?: boolean|"mixed";
15814
- pressed?: boolean|"mixed";
15815
- level?: number;
15816
- valuemin?: number;
15817
- valuemax?: number;
15818
- autocomplete?: string;
15819
- haspopup?: string;
15820
- invalid?: string;
15821
- orientation?: string;
15822
- children?: AccessibilityNode[];
15823
- }
15824
-
15825
15830
  export const devices: Devices;
15826
15831
 
15827
15832
  //@ts-ignore this will be any if electron is not installed
@@ -16291,8 +16296,6 @@ export type AndroidKey =
16291
16296
 
16292
16297
  export const _electron: Electron;
16293
16298
  export const _android: Android;
16294
- export const _bidiChromium: BrowserType;
16295
- export const _bidiFirefox: BrowserType;
16296
16299
 
16297
16300
  // This is required to not export everything by default. See https://github.com/Microsoft/TypeScript/issues/19545#issuecomment-340490459
16298
16301
  export {};
@@ -18879,6 +18882,13 @@ export interface ConsoleMessage {
18879
18882
  text(): string;
18880
18883
 
18881
18884
  type(): "log"|"debug"|"info"|"error"|"warning"|"dir"|"dirxml"|"table"|"trace"|"clear"|"startGroup"|"startGroupCollapsed"|"endGroup"|"assert"|"profile"|"profileEnd"|"count"|"timeEnd";
18885
+
18886
+ /**
18887
+ * The web worker or service worker that produced this console message, if any. Note that console messages from web
18888
+ * workers also have non-null
18889
+ * [consoleMessage.page()](https://playwright.dev/docs/api/class-consolemessage#console-message-page).
18890
+ */
18891
+ worker(): null|Worker;
18882
18892
  }
18883
18893
 
18884
18894
  /**
@@ -19109,6 +19119,10 @@ export interface Download {
19109
19119
 
19110
19120
  /**
19111
19121
  * Returns a readable stream for a successful download, or throws for a failed/canceled download.
19122
+ *
19123
+ * **NOTE** If you don't need a readable stream, it's usually simpler to read the file from disk after the download
19124
+ * completed. See [download.path()](https://playwright.dev/docs/api/class-download#download-path).
19125
+ *
19112
19126
  */
19113
19127
  createReadStream(): Promise<Readable>;
19114
19128
 
@@ -20274,7 +20288,8 @@ export interface Mouse {
20274
20288
  */
20275
20289
  move(x: number, y: number, options?: {
20276
20290
  /**
20277
- * Defaults to 1. Sends intermediate `mousemove` events.
20291
+ * Defaults to 1. Sends `n` interpolated `mousemove` events to represent travel between Playwright's current cursor
20292
+ * position and the provided destination. When set to 1, emits a single `mousemove` event at the destination location.
20278
20293
  */
20279
20294
  steps?: number;
20280
20295
  }): Promise<void>;
@@ -21724,18 +21739,6 @@ export interface WebSocket {
21724
21739
 
21725
21740
  }
21726
21741
 
21727
- interface AccessibilitySnapshotOptions {
21728
- /**
21729
- * Prune uninteresting nodes from the tree. Defaults to `true`.
21730
- */
21731
- interestingOnly?: boolean;
21732
-
21733
- /**
21734
- * The root DOM element for the snapshot. Defaults to the whole page.
21735
- */
21736
- root?: ElementHandle;
21737
- }
21738
-
21739
21742
  export interface LaunchOptions {
21740
21743
  /**
21741
21744
  * **NOTE** Use custom browser args at your own risk, as some of them may break Playwright functionality.
@@ -1,49 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var accessibility_exports = {};
20
- __export(accessibility_exports, {
21
- Accessibility: () => Accessibility
22
- });
23
- module.exports = __toCommonJS(accessibility_exports);
24
- function axNodeFromProtocol(axNode) {
25
- const result = {
26
- ...axNode,
27
- value: axNode.valueNumber !== void 0 ? axNode.valueNumber : axNode.valueString,
28
- checked: axNode.checked === "checked" ? true : axNode.checked === "unchecked" ? false : axNode.checked,
29
- pressed: axNode.pressed === "pressed" ? true : axNode.pressed === "released" ? false : axNode.pressed,
30
- children: axNode.children ? axNode.children.map(axNodeFromProtocol) : void 0
31
- };
32
- delete result.valueNumber;
33
- delete result.valueString;
34
- return result;
35
- }
36
- class Accessibility {
37
- constructor(channel) {
38
- this._channel = channel;
39
- }
40
- async snapshot(options = {}) {
41
- const root = options.root ? options.root._elementChannel : void 0;
42
- const result = await this._channel.accessibilitySnapshot({ interestingOnly: options.interestingOnly, root });
43
- return result.rootAXNode ? axNodeFromProtocol(result.rootAXNode) : null;
44
- }
45
- }
46
- // Annotate the CommonJS export names for ESM import in node:
47
- 0 && (module.exports = {
48
- Accessibility
49
- });
@@ -1,69 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var accessibility_exports = {};
20
- __export(accessibility_exports, {
21
- Accessibility: () => Accessibility
22
- });
23
- module.exports = __toCommonJS(accessibility_exports);
24
- class Accessibility {
25
- constructor(getAXTree) {
26
- this._getAXTree = getAXTree;
27
- }
28
- async snapshot(options = {}) {
29
- const {
30
- interestingOnly = true,
31
- root = null
32
- } = options;
33
- const { tree, needle } = await this._getAXTree(root || void 0);
34
- if (!interestingOnly) {
35
- if (root)
36
- return needle && serializeTree(needle)[0];
37
- return serializeTree(tree)[0];
38
- }
39
- const interestingNodes = /* @__PURE__ */ new Set();
40
- collectInterestingNodes(interestingNodes, tree, false);
41
- if (root && (!needle || !interestingNodes.has(needle)))
42
- return null;
43
- return serializeTree(needle || tree, interestingNodes)[0];
44
- }
45
- }
46
- function collectInterestingNodes(collection, node, insideControl) {
47
- if (node.isInteresting(insideControl))
48
- collection.add(node);
49
- if (node.isLeafNode())
50
- return;
51
- insideControl = insideControl || node.isControl();
52
- for (const child of node.children())
53
- collectInterestingNodes(collection, child, insideControl);
54
- }
55
- function serializeTree(node, whitelistedNodes) {
56
- const children = [];
57
- for (const child of node.children())
58
- children.push(...serializeTree(child, whitelistedNodes));
59
- if (whitelistedNodes && !whitelistedNodes.has(node))
60
- return children;
61
- const serializedNode = node.serialize();
62
- if (children.length)
63
- serializedNode.children = children;
64
- return [serializedNode];
65
- }
66
- // Annotate the CommonJS export names for ESM import in node:
67
- 0 && (module.exports = {
68
- Accessibility
69
- });