patchright-core 1.48.2 → 1.49.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 (110) hide show
  1. package/README.md +2 -2
  2. package/ThirdPartyNotices.txt +70 -384
  3. package/bin/reinstall_chrome_beta_linux.sh +10 -8
  4. package/bin/reinstall_chrome_stable_linux.sh +10 -8
  5. package/bin/reinstall_msedge_beta_linux.sh +11 -9
  6. package/bin/reinstall_msedge_dev_linux.sh +11 -9
  7. package/bin/reinstall_msedge_stable_linux.sh +11 -9
  8. package/browsers.json +19 -11
  9. package/lib/cli/program.js +23 -5
  10. package/lib/client/channelOwner.js +2 -2
  11. package/lib/client/locator.js +7 -0
  12. package/lib/client/network.js +5 -0
  13. package/lib/client/page.js +4 -2
  14. package/lib/client/tracing.js +13 -0
  15. package/lib/client/waiter.js +15 -11
  16. package/lib/generated/consoleApiSource.js +1 -1
  17. package/lib/generated/injectedScriptSource.js +1 -1
  18. package/lib/generated/pollingRecorderSource.js +1 -1
  19. package/lib/generated/webSocketMockSource.js +1 -1
  20. package/lib/protocol/validator.js +23 -3
  21. package/lib/server/ariaSnapshot.js +33 -0
  22. package/lib/server/bidi/bidiChromium.js +1 -1
  23. package/lib/server/bidi/bidiConnection.js +0 -2
  24. package/lib/server/bidi/bidiExecutionContext.js +0 -3
  25. package/lib/server/browserType.js +4 -1
  26. package/lib/server/chromium/chromium.js +6 -2
  27. package/lib/server/chromium/crExecutionContext.js +0 -13
  28. package/lib/server/chromium/crNetworkManager.js +1 -1
  29. package/lib/server/chromium/crPage.js +4 -5
  30. package/lib/server/codegen/csharp.js +11 -16
  31. package/lib/server/codegen/java.js +4 -7
  32. package/lib/server/codegen/javascript.js +28 -6
  33. package/lib/server/codegen/python.js +12 -16
  34. package/lib/server/debugController.js +8 -5
  35. package/lib/server/deviceDescriptorsSource.json +127 -127
  36. package/lib/server/dispatchers/androidDispatcher.js +13 -2
  37. package/lib/server/dispatchers/debugControllerDispatcher.js +1 -1
  38. package/lib/server/dispatchers/dispatcher.js +1 -1
  39. package/lib/server/dispatchers/frameDispatcher.js +8 -1
  40. package/lib/server/dispatchers/tracingDispatcher.js +10 -0
  41. package/lib/server/dom.js +79 -36
  42. package/lib/server/fetch.js +30 -17
  43. package/lib/server/firefox/ffExecutionContext.js +0 -12
  44. package/lib/server/firefox/ffNetworkManager.js +1 -1
  45. package/lib/server/frames.js +55 -62
  46. package/lib/server/index.js +0 -6
  47. package/lib/server/javascript.js +0 -6
  48. package/lib/server/page.js +32 -5
  49. package/lib/server/progress.js +0 -3
  50. package/lib/server/recorder/recorderApp.js +6 -15
  51. package/lib/server/recorder/recorderInTraceViewer.js +3 -3
  52. package/lib/server/recorder/recorderUtils.js +2 -1
  53. package/lib/server/recorder.js +66 -31
  54. package/lib/server/registry/index.js +70 -23
  55. package/lib/server/registry/nativeDeps.js +6 -3
  56. package/lib/server/socksClientCertificatesInterceptor.js +1 -1
  57. package/lib/server/trace/recorder/snapshotter.js +1 -12
  58. package/lib/server/trace/recorder/snapshotterInjected.js +19 -1
  59. package/lib/server/trace/recorder/tracing.js +69 -15
  60. package/lib/server/trace/test/inMemorySnapshotter.js +3 -3
  61. package/lib/server/trace/viewer/traceViewer.js +2 -1
  62. package/lib/server/webkit/wkBrowser.js +2 -2
  63. package/lib/server/webkit/wkExecutionContext.js +0 -13
  64. package/lib/server/webkit/wkPage.js +4 -0
  65. package/lib/utils/comparators.js +12 -30
  66. package/lib/utils/crypto.js +1 -4
  67. package/lib/utils/hostPlatform.js +6 -0
  68. package/lib/utils/isomorphic/ariaSnapshot.js +267 -0
  69. package/lib/utils/isomorphic/locatorGenerators.js +23 -5
  70. package/lib/utils/isomorphic/recorderUtils.js +36 -4
  71. package/lib/utils/isomorphic/stringUtils.js +30 -0
  72. package/lib/utils/isomorphic/urlMatch.js +5 -1
  73. package/lib/utils/network.js +1 -1
  74. package/lib/utils/sequence.js +64 -0
  75. package/lib/utils/stackTrace.js +16 -3
  76. package/lib/utils/zones.js +32 -23
  77. package/lib/utilsBundle.js +4 -5
  78. package/lib/utilsBundleImpl/index.js +190 -33
  79. package/lib/vite/htmlReport/index.html +19 -16
  80. package/lib/vite/recorder/assets/codeMirrorModule-AFvV6hAs.js +24 -0
  81. package/lib/vite/recorder/assets/index-_cTWgVuJ.js +184 -0
  82. package/lib/vite/recorder/assets/{index-BW-aOBcL.css → index-iA1aAGZg.css} +1 -1
  83. package/lib/vite/recorder/index.html +2 -2
  84. package/lib/vite/traceViewer/assets/codeMirrorModule-BWCrdKft.js +24 -0
  85. package/lib/vite/traceViewer/assets/inspectorTab-C_9qyxv5.js +68 -0
  86. package/lib/vite/traceViewer/assets/workbench-DsQEOQud.js +9 -0
  87. package/lib/vite/traceViewer/{embedded.BlHoW5LY.js → embedded.D4x_-tXl.js} +1 -1
  88. package/lib/vite/traceViewer/embedded.html +5 -5
  89. package/lib/vite/traceViewer/{index.DaWVfou1.js → index.BskMikzx.js} +1 -1
  90. package/lib/vite/traceViewer/index.html +24 -7
  91. package/lib/vite/traceViewer/{inspectorTab.DLjBDrQR.css → inspectorTab.DEOUW62d.css} +1 -1
  92. package/lib/vite/traceViewer/recorder.Dsk1wX5k.js +2 -0
  93. package/lib/vite/traceViewer/recorder.html +3 -3
  94. package/lib/vite/traceViewer/sw.bundle.js +3 -3
  95. package/lib/vite/traceViewer/uiMode.CzKr-TMc.js +5 -0
  96. package/lib/vite/traceViewer/uiMode.html +6 -6
  97. package/lib/vite/traceViewer/{uiMode.CAYqod-m.css → uiMode.voC1ZiOQ.css} +1 -1
  98. package/lib/vite/traceViewer/workbench.C-zR9ysA.css +1 -0
  99. package/package.json +1 -1
  100. package/types/protocol.d.ts +58 -10
  101. package/types/types.d.ts +116 -20
  102. package/lib/third_party/diff_match_patch.js +0 -2222
  103. package/lib/vite/recorder/assets/codeMirrorModule-baozm8ur.js +0 -24
  104. package/lib/vite/recorder/assets/index-2ElAIWFB.js +0 -42
  105. package/lib/vite/traceViewer/assets/codeMirrorModule-Bh1rfd2w.js +0 -24
  106. package/lib/vite/traceViewer/assets/inspectorTab-7GHnKvSD.js +0 -64
  107. package/lib/vite/traceViewer/assets/workbench-DPQnTHYP.js +0 -9
  108. package/lib/vite/traceViewer/recorder.C4zxcvd2.js +0 -2
  109. package/lib/vite/traceViewer/uiMode.mTXWniJb.js +0 -5
  110. package/lib/vite/traceViewer/workbench.D3JVcA9K.css +0 -1
@@ -175,17 +175,27 @@ function innerAsLocators(factory, parsed, isFrameLocator = false, maxOutputSize
175
175
  }
176
176
  }
177
177
  if (part.name === 'internal:control' && part.body === 'enter-frame') {
178
- tokens.push([factory.generateLocator(base, 'frame', '')]);
178
+ // transform last tokens from `${selector}` into `${selector}.contentFrame()` and `frameLocator(${selector})`
179
+ const lastTokens = tokens[tokens.length - 1];
180
+ const lastPart = parts[index - 1];
181
+ const transformed = lastTokens.map(token => factory.chainLocators([token, factory.generateLocator(base, 'frame', '')]));
182
+ if (['xpath', 'css'].includes(lastPart.name)) {
183
+ transformed.push(factory.generateLocator(base, 'frame-locator', (0, _selectorParser.stringifySelector)({
184
+ parts: [lastPart]
185
+ })), factory.generateLocator(base, 'frame-locator', (0, _selectorParser.stringifySelector)({
186
+ parts: [lastPart]
187
+ }, true)));
188
+ }
189
+ lastTokens.splice(0, lastTokens.length, ...transformed);
179
190
  nextBase = 'frame-locator';
180
191
  continue;
181
192
  }
182
- let locatorType = 'default';
183
193
  const nextPart = parts[index + 1];
184
194
  const selectorPart = (0, _selectorParser.stringifySelector)({
185
195
  parts: [part]
186
196
  });
187
- const locatorPart = factory.generateLocator(base, locatorType, selectorPart);
188
- if (locatorType === 'default' && nextPart && ['internal:has-text', 'internal:has-not-text'].includes(nextPart.name)) {
197
+ const locatorPart = factory.generateLocator(base, 'default', selectorPart);
198
+ if (nextPart && ['internal:has-text', 'internal:has-not-text'].includes(nextPart.name)) {
189
199
  const {
190
200
  exact,
191
201
  text
@@ -213,7 +223,7 @@ function innerAsLocators(factory, parsed, isFrameLocator = false, maxOutputSize
213
223
  const selectorPart = (0, _selectorParser.stringifySelector)({
214
224
  parts: [part]
215
225
  }, /* forceEngineName */true);
216
- locatorPartWithEngine = factory.generateLocator(base, locatorType, selectorPart);
226
+ locatorPartWithEngine = factory.generateLocator(base, 'default', selectorPart);
217
227
  }
218
228
  tokens.push([locatorPart, locatorPartWithEngine].filter(Boolean));
219
229
  }
@@ -267,6 +277,8 @@ class JavaScriptLocatorFactory {
267
277
  if (options.hasText !== undefined) return `locator(${this.quote(body)}, { hasText: ${this.toHasText(options.hasText)} })`;
268
278
  if (options.hasNotText !== undefined) return `locator(${this.quote(body)}, { hasNotText: ${this.toHasText(options.hasNotText)} })`;
269
279
  return `locator(${this.quote(body)})`;
280
+ case 'frame-locator':
281
+ return `frameLocator(${this.quote(body)})`;
270
282
  case 'frame':
271
283
  return `contentFrame()`;
272
284
  case 'nth':
@@ -350,6 +362,8 @@ class PythonLocatorFactory {
350
362
  if (options.hasText !== undefined) return `locator(${this.quote(body)}, has_text=${this.toHasText(options.hasText)})`;
351
363
  if (options.hasNotText !== undefined) return `locator(${this.quote(body)}, has_not_text=${this.toHasText(options.hasNotText)})`;
352
364
  return `locator(${this.quote(body)})`;
365
+ case 'frame-locator':
366
+ return `frame_locator(${this.quote(body)})`;
353
367
  case 'frame':
354
368
  return `content_frame`;
355
369
  case 'nth':
@@ -450,6 +464,8 @@ class JavaLocatorFactory {
450
464
  if (options.hasText !== undefined) return `locator(${this.quote(body)}, new ${clazz}.LocatorOptions().setHasText(${this.toHasText(options.hasText)}))`;
451
465
  if (options.hasNotText !== undefined) return `locator(${this.quote(body)}, new ${clazz}.LocatorOptions().setHasNotText(${this.toHasText(options.hasNotText)}))`;
452
466
  return `locator(${this.quote(body)})`;
467
+ case 'frame-locator':
468
+ return `frameLocator(${this.quote(body)})`;
453
469
  case 'frame':
454
470
  return `contentFrame()`;
455
471
  case 'nth':
@@ -534,6 +550,8 @@ class CSharpLocatorFactory {
534
550
  if (options.hasText !== undefined) return `Locator(${this.quote(body)}, new() { ${this.toHasText(options.hasText)} })`;
535
551
  if (options.hasNotText !== undefined) return `Locator(${this.quote(body)}, new() { ${this.toHasNotText(options.hasNotText)} })`;
536
552
  return `Locator(${this.quote(body)})`;
553
+ case 'frame-locator':
554
+ return `FrameLocator(${this.quote(body)})`;
537
555
  case 'frame':
538
556
  return `ContentFrame`;
539
557
  case 'nth':
@@ -25,6 +25,7 @@ exports.traceParamsForAction = traceParamsForAction;
25
25
  function buildFullSelector(framePath, selector) {
26
26
  return [...framePath, selector].join(' >> internal:control=enter-frame >> ');
27
27
  }
28
+ const kDefaultTimeout = 5_000;
28
29
  function traceParamsForAction(actionInContext) {
29
30
  const {
30
31
  action
@@ -37,6 +38,7 @@ function traceParamsForAction(actionInContext) {
37
38
  };
38
39
  return {
39
40
  method: 'goto',
41
+ apiName: 'page.goto',
40
42
  params
41
43
  };
42
44
  }
@@ -58,6 +60,7 @@ function traceParamsForAction(actionInContext) {
58
60
  };
59
61
  return {
60
62
  method: 'click',
63
+ apiName: 'locator.click',
61
64
  params
62
65
  };
63
66
  }
@@ -70,6 +73,7 @@ function traceParamsForAction(actionInContext) {
70
73
  };
71
74
  return {
72
75
  method: 'press',
76
+ apiName: 'locator.press',
73
77
  params
74
78
  };
75
79
  }
@@ -82,6 +86,7 @@ function traceParamsForAction(actionInContext) {
82
86
  };
83
87
  return {
84
88
  method: 'fill',
89
+ apiName: 'locator.fill',
85
90
  params
86
91
  };
87
92
  }
@@ -94,6 +99,7 @@ function traceParamsForAction(actionInContext) {
94
99
  };
95
100
  return {
96
101
  method: 'setInputFiles',
102
+ apiName: 'locator.setInputFiles',
97
103
  params
98
104
  };
99
105
  }
@@ -105,6 +111,7 @@ function traceParamsForAction(actionInContext) {
105
111
  };
106
112
  return {
107
113
  method: 'check',
114
+ apiName: 'locator.check',
108
115
  params
109
116
  };
110
117
  }
@@ -116,6 +123,7 @@ function traceParamsForAction(actionInContext) {
116
123
  };
117
124
  return {
118
125
  method: 'uncheck',
126
+ apiName: 'locator.uncheck',
119
127
  params
120
128
  };
121
129
  }
@@ -130,6 +138,7 @@ function traceParamsForAction(actionInContext) {
130
138
  };
131
139
  return {
132
140
  method: 'selectOption',
141
+ apiName: 'locator.selectOption',
133
142
  params
134
143
  };
135
144
  }
@@ -138,10 +147,12 @@ function traceParamsForAction(actionInContext) {
138
147
  const params = {
139
148
  selector: action.selector,
140
149
  expression: 'to.be.checked',
141
- isNot: !action.checked
150
+ isNot: !action.checked,
151
+ timeout: kDefaultTimeout
142
152
  };
143
153
  return {
144
154
  method: 'expect',
155
+ apiName: 'expect.toBeChecked',
145
156
  params
146
157
  };
147
158
  }
@@ -151,10 +162,12 @@ function traceParamsForAction(actionInContext) {
151
162
  selector,
152
163
  expression: 'to.have.text',
153
164
  expectedText: [],
154
- isNot: false
165
+ isNot: false,
166
+ timeout: kDefaultTimeout
155
167
  };
156
168
  return {
157
169
  method: 'expect',
170
+ apiName: 'expect.toContainText',
158
171
  params
159
172
  };
160
173
  }
@@ -164,10 +177,12 @@ function traceParamsForAction(actionInContext) {
164
177
  selector,
165
178
  expression: 'to.have.value',
166
179
  expectedValue: undefined,
167
- isNot: false
180
+ isNot: false,
181
+ timeout: kDefaultTimeout
168
182
  };
169
183
  return {
170
184
  method: 'expect',
185
+ apiName: 'expect.toHaveValue',
171
186
  params
172
187
  };
173
188
  }
@@ -176,10 +191,27 @@ function traceParamsForAction(actionInContext) {
176
191
  const params = {
177
192
  selector,
178
193
  expression: 'to.be.visible',
179
- isNot: false
194
+ isNot: false,
195
+ timeout: kDefaultTimeout
180
196
  };
181
197
  return {
182
198
  method: 'expect',
199
+ apiName: 'expect.toBeVisible',
200
+ params
201
+ };
202
+ }
203
+ case 'assertSnapshot':
204
+ {
205
+ const params = {
206
+ selector,
207
+ expression: 'to.match.snapshot',
208
+ expectedText: [],
209
+ isNot: false,
210
+ timeout: kDefaultTimeout
211
+ };
212
+ return {
213
+ method: 'expect',
214
+ apiName: 'expect.toMatchAriaSnapshot',
183
215
  params
184
216
  };
185
217
  }
@@ -10,8 +10,10 @@ exports.escapeForTextSelector = escapeForTextSelector;
10
10
  exports.escapeHTML = escapeHTML;
11
11
  exports.escapeHTMLAttribute = escapeHTMLAttribute;
12
12
  exports.escapeRegExp = escapeRegExp;
13
+ exports.escapeTemplateString = escapeTemplateString;
13
14
  exports.escapeWithQuotes = escapeWithQuotes;
14
15
  exports.isString = isString;
16
+ exports.longestCommonSubstring = longestCommonSubstring;
15
17
  exports.normalizeEscapedRegexQuotes = normalizeEscapedRegexQuotes;
16
18
  exports.normalizeWhiteSpace = normalizeWhiteSpace;
17
19
  exports.quoteCSSAttributeValue = quoteCSSAttributeValue;
@@ -44,6 +46,9 @@ function escapeWithQuotes(text, char = '\'') {
44
46
  if (char === '`') return char + escapedText.replace(/[`]/g, '`') + char;
45
47
  throw new Error('Invalid escape char');
46
48
  }
49
+ function escapeTemplateString(text) {
50
+ return text.replace(/\\/g, '\\\\').replace(/`/g, '\\`').replace(/\$\{/g, '\\${');
51
+ }
47
52
  function isString(obj) {
48
53
  return typeof obj === 'string' || obj instanceof String;
49
54
  }
@@ -136,4 +141,29 @@ function escapeHTMLAttribute(s) {
136
141
  }
137
142
  function escapeHTML(s) {
138
143
  return s.replace(/[&<]/ug, char => escaped[char]);
144
+ }
145
+ function longestCommonSubstring(s1, s2) {
146
+ const n = s1.length;
147
+ const m = s2.length;
148
+ let maxLen = 0;
149
+ let endingIndex = 0;
150
+
151
+ // Initialize a 2D array with zeros
152
+ const dp = Array(n + 1).fill(null).map(() => Array(m + 1).fill(0));
153
+
154
+ // Build the dp table
155
+ for (let i = 1; i <= n; i++) {
156
+ for (let j = 1; j <= m; j++) {
157
+ if (s1[i - 1] === s2[j - 1]) {
158
+ dp[i][j] = dp[i - 1][j - 1] + 1;
159
+ if (dp[i][j] > maxLen) {
160
+ maxLen = dp[i][j];
161
+ endingIndex = i;
162
+ }
163
+ }
164
+ }
165
+ }
166
+
167
+ // Extract the longest common substring
168
+ return s1.slice(endingIndex - maxLen, endingIndex);
139
169
  }
@@ -94,7 +94,11 @@ function urlMatchesEqual(match1, match2) {
94
94
  }
95
95
  function urlMatches(baseURL, urlString, match) {
96
96
  if (match === undefined || match === '') return true;
97
- if ((0, _stringUtils.isString)(match) && !match.startsWith('*')) match = constructURLBasedOnBaseURL(baseURL, match);
97
+ if ((0, _stringUtils.isString)(match) && !match.startsWith('*')) {
98
+ // Allow http(s) baseURL to match ws(s) urls.
99
+ if (baseURL && /^https?:\/\//.test(baseURL) && /^wss?:\/\//.test(urlString)) baseURL = baseURL.replace(/^http/, 'ws');
100
+ match = constructURLBasedOnBaseURL(baseURL, match);
101
+ }
98
102
  if ((0, _stringUtils.isString)(match)) match = globToRegex(match);
99
103
  if (isRegExp(match)) return match.test(urlString);
100
104
  if (typeof match === 'string' && match === urlString) return true;
@@ -47,7 +47,7 @@ function httpRequest(params, onResponse, onError) {
47
47
  const timeout = (_params$timeout = params.timeout) !== null && _params$timeout !== void 0 ? _params$timeout : NET_DEFAULT_TIMEOUT;
48
48
  const proxyURL = (0, _utilsBundle.getProxyForUrl)(params.url);
49
49
  if (proxyURL) {
50
- const parsedProxyURL = _url.default.parse(proxyURL);
50
+ const parsedProxyURL = new URL(proxyURL);
51
51
  if (params.url.startsWith('http:')) {
52
52
  options = {
53
53
  path: parsedUrl.href,
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.findRepeatedSubsequences = findRepeatedSubsequences;
7
+ /**
8
+ * Copyright (c) Microsoft Corporation.
9
+ *
10
+ * Licensed under the Apache License, Version 2.0 (the "License");
11
+ * you may not use this file except in compliance with the License.
12
+ * You may obtain a copy of the License at
13
+ *
14
+ * http://www.apache.org/licenses/LICENSE-2.0
15
+ *
16
+ * Unless required by applicable law or agreed to in writing, software
17
+ * distributed under the License is distributed on an "AS IS" BASIS,
18
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ * See the License for the specific language governing permissions and
20
+ * limitations under the License.
21
+ */
22
+
23
+ function findRepeatedSubsequences(s) {
24
+ const n = s.length;
25
+ const result = [];
26
+ let i = 0;
27
+ const arraysEqual = (a1, a2) => {
28
+ if (a1.length !== a2.length) return false;
29
+ for (let j = 0; j < a1.length; j++) {
30
+ if (a1[j] !== a2[j]) return false;
31
+ }
32
+ return true;
33
+ };
34
+ while (i < n) {
35
+ let maxRepeatCount = 1;
36
+ let maxRepeatSubstr = [s[i]]; // Initialize with the element at index i
37
+ let maxRepeatLength = 1;
38
+
39
+ // Try substrings of length from 1 to the remaining length of the array
40
+ for (let p = 1; p <= n - i; p++) {
41
+ const substr = s.slice(i, i + p); // Extract substring as array
42
+ let k = 1;
43
+
44
+ // Count how many times the substring repeats consecutively
45
+ while (i + p * k <= n && arraysEqual(s.slice(i + p * (k - 1), i + p * k), substr)) k += 1;
46
+ k -= 1; // Adjust k since it increments one extra time in the loop
47
+
48
+ // Update the maximal repeating substring if necessary
49
+ if (k > 1 && k * p > maxRepeatCount * maxRepeatLength) {
50
+ maxRepeatCount = k;
51
+ maxRepeatSubstr = substr;
52
+ maxRepeatLength = p;
53
+ }
54
+ }
55
+
56
+ // Record the substring and its count
57
+ result.push({
58
+ sequence: maxRepeatSubstr,
59
+ count: maxRepeatCount
60
+ });
61
+ i += maxRepeatLength * maxRepeatCount; // Move index forward
62
+ }
63
+ return result;
64
+ }
@@ -7,13 +7,14 @@ exports.addInternalStackPrefix = void 0;
7
7
  exports.captureLibraryStackText = captureLibraryStackText;
8
8
  exports.captureLibraryStackTrace = captureLibraryStackTrace;
9
9
  exports.captureRawStack = captureRawStack;
10
+ exports.compressCallLog = compressCallLog;
10
11
  exports.formatCallLog = formatCallLog;
11
12
  exports.rewriteErrorMessage = rewriteErrorMessage;
12
13
  exports.splitErrorMessage = splitErrorMessage;
13
14
  exports.stringifyStackFrames = stringifyStackFrames;
14
15
  var _path = _interopRequireDefault(require("path"));
15
16
  var _utilsBundle = require("../utilsBundle");
16
- var _ = require("./");
17
+ var _sequence = require("./sequence");
17
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
19
  /**
19
20
  * Copyright (c) Microsoft Corporation.
@@ -53,7 +54,6 @@ function captureRawStack() {
53
54
  }
54
55
  function captureLibraryStackTrace() {
55
56
  const stack = captureRawStack();
56
- const isTesting = (0, _.isUnderTest)();
57
57
  let parsedFrames = stack.map(line => {
58
58
  const frame = (0, _utilsBundle.parseStackTraceLine)(line);
59
59
  if (!frame || !frame.file) return null;
@@ -116,6 +116,19 @@ function formatCallLog(log) {
116
116
  if (!log || !log.some(l => !!l)) return '';
117
117
  return `
118
118
  Call log:
119
- ${_utilsBundle.colors.dim('- ' + (log || []).join('\n - '))}
119
+ ${_utilsBundle.colors.dim(log.join('\n'))}
120
120
  `;
121
+ }
122
+ function compressCallLog(log) {
123
+ const lines = [];
124
+ for (const block of (0, _sequence.findRepeatedSubsequences)(log)) {
125
+ for (let i = 0; i < block.sequence.length; i++) {
126
+ const line = block.sequence[i];
127
+ const leadingWhitespace = line.match(/^\s*/);
128
+ const whitespacePrefix = ' ' + (leadingWhitespace === null || leadingWhitespace === void 0 ? void 0 : leadingWhitespace[0]) || '';
129
+ const countPrefix = `${block.count} × `;
130
+ if (block.count > 1 && i === 0) lines.push(whitespacePrefix + countPrefix + line.trim());else if (block.count > 1) lines.push(whitespacePrefix + ' '.repeat(countPrefix.length - 2) + '- ' + line.trim());else lines.push(whitespacePrefix + '- ' + line.trim());
131
+ }
132
+ }
133
+ return lines;
121
134
  }
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.zones = void 0;
6
+ exports.zones = exports.Zone = void 0;
7
7
  var _async_hooks = require("async_hooks");
8
8
  /**
9
9
  * Copyright (c) Microsoft Corporation.
@@ -26,37 +26,46 @@ class ZoneManager {
26
26
  this._asyncLocalStorage = new _async_hooks.AsyncLocalStorage();
27
27
  }
28
28
  run(type, data, func) {
29
- const previous = this._asyncLocalStorage.getStore();
30
- const zone = new Zone(previous, type, data);
29
+ const zone = Zone._createWithData(this._asyncLocalStorage, type, data);
31
30
  return this._asyncLocalStorage.run(zone, func);
32
31
  }
33
32
  zoneData(type) {
34
- for (let zone = this._asyncLocalStorage.getStore(); zone; zone = zone.previous) {
35
- if (zone.type === type) return zone.data;
36
- }
37
- return undefined;
33
+ const zone = this._asyncLocalStorage.getStore();
34
+ return zone === null || zone === void 0 ? void 0 : zone.get(type);
35
+ }
36
+ currentZone() {
37
+ var _this$_asyncLocalStor;
38
+ return (_this$_asyncLocalStor = this._asyncLocalStorage.getStore()) !== null && _this$_asyncLocalStor !== void 0 ? _this$_asyncLocalStor : Zone._createEmpty(this._asyncLocalStorage);
38
39
  }
39
40
  exitZones(func) {
40
41
  return this._asyncLocalStorage.run(undefined, func);
41
42
  }
42
- printZones() {
43
- const zones = [];
44
- for (let zone = this._asyncLocalStorage.getStore(); zone; zone = zone.previous) {
45
- let str = zone.type;
46
- if (zone.type === 'apiZone') str += `(${zone.data.apiName})`;
47
- zones.push(str);
48
- }
49
- console.log('zones: ', zones.join(' -> '));
50
- }
51
43
  }
52
44
  class Zone {
53
- constructor(previous, type, data) {
54
- this.type = void 0;
55
- this.data = void 0;
56
- this.previous = void 0;
57
- this.type = type;
58
- this.data = data;
59
- this.previous = previous;
45
+ static _createWithData(asyncLocalStorage, type, data) {
46
+ var _asyncLocalStorage$ge;
47
+ const store = new Map((_asyncLocalStorage$ge = asyncLocalStorage.getStore()) === null || _asyncLocalStorage$ge === void 0 ? void 0 : _asyncLocalStorage$ge._data);
48
+ store.set(type, data);
49
+ return new Zone(asyncLocalStorage, store);
50
+ }
51
+ static _createEmpty(asyncLocalStorage) {
52
+ return new Zone(asyncLocalStorage, new Map());
53
+ }
54
+ constructor(asyncLocalStorage, store) {
55
+ this._asyncLocalStorage = void 0;
56
+ this._data = void 0;
57
+ this._asyncLocalStorage = asyncLocalStorage;
58
+ this._data = store;
59
+ }
60
+ run(func) {
61
+ // Reset apiZone and expectZone, but restore stepZone.
62
+ const entries = [...this._data.entries()].filter(([type]) => type !== 'apiZone' && type !== 'expectZone');
63
+ const resetZone = new Zone(this._asyncLocalStorage, new Map(entries));
64
+ return this._asyncLocalStorage.run(resetZone, func);
65
+ }
66
+ get(type) {
67
+ return this._data.get(type);
60
68
  }
61
69
  }
70
+ exports.Zone = Zone;
62
71
  const zones = exports.zones = new ZoneManager();
@@ -3,11 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.minimatch = exports.mime = exports.lockfile = exports.jpegjs = exports.getProxyForUrl = exports.dotenv = exports.debug = exports.colors = exports.SocksProxyAgent = exports.PNG = exports.HttpsProxyAgent = void 0;
6
+ exports.minimatch = exports.mime = exports.lockfile = exports.jpegjs = exports.getProxyForUrl = exports.dotenv = exports.diff = exports.debug = exports.colors = exports.SocksProxyAgent = exports.PNG = exports.HttpsProxyAgent = void 0;
7
7
  exports.ms = ms;
8
8
  exports.open = void 0;
9
9
  exports.parseStackTraceLine = parseStackTraceLine;
10
- exports.wsServer = exports.wsSender = exports.wsReceiver = exports.ws = exports.progress = exports.program = void 0;
10
+ exports.yaml = exports.wsServer = exports.wsSender = exports.wsReceiver = exports.ws = exports.progress = exports.program = void 0;
11
11
  var _url = _interopRequireDefault(require("url"));
12
12
  var _path = _interopRequireDefault(require("path"));
13
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -29,6 +29,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
29
29
 
30
30
  const colors = exports.colors = require('./utilsBundleImpl').colors;
31
31
  const debug = exports.debug = require('./utilsBundleImpl').debug;
32
+ const diff = exports.diff = require('./utilsBundleImpl').diff;
32
33
  const dotenv = exports.dotenv = require('./utilsBundleImpl').dotenv;
33
34
  const getProxyForUrl = exports.getProxyForUrl = require('./utilsBundleImpl').getProxyForUrl;
34
35
  const HttpsProxyAgent = exports.HttpsProxyAgent = require('./utilsBundleImpl').HttpsProxyAgent;
@@ -41,6 +42,7 @@ const PNG = exports.PNG = require('./utilsBundleImpl').PNG;
41
42
  const program = exports.program = require('./utilsBundleImpl').program;
42
43
  const progress = exports.progress = require('./utilsBundleImpl').progress;
43
44
  const SocksProxyAgent = exports.SocksProxyAgent = require('./utilsBundleImpl').SocksProxyAgent;
45
+ const yaml = exports.yaml = require('./utilsBundleImpl').yaml;
44
46
  const ws = exports.ws = require('./utilsBundleImpl').ws;
45
47
  const wsServer = exports.wsServer = require('./utilsBundleImpl').wsServer;
46
48
  const wsReceiver = exports.wsReceiver = require('./utilsBundleImpl').wsReceiver;
@@ -49,11 +51,8 @@ const StackUtils = require('./utilsBundleImpl').StackUtils;
49
51
  const stackUtils = new StackUtils({
50
52
  internals: StackUtils.nodeInternals()
51
53
  });
52
- const nodeInternals = StackUtils.nodeInternals();
53
- const nodeMajorVersion = +process.versions.node.split('.')[0];
54
54
  function parseStackTraceLine(line) {
55
55
  var _frame$file, _frame$file2;
56
- if (!process.env.PWDEBUGIMPL && nodeMajorVersion < 16 && nodeInternals.some(internal => internal.test(line))) return null;
57
56
  const frame = stackUtils.parseLine(line);
58
57
  if (!frame) return null;
59
58
  if (!process.env.PWDEBUGIMPL && ((_frame$file = frame.file) !== null && _frame$file !== void 0 && _frame$file.startsWith('internal') || (_frame$file2 = frame.file) !== null && _frame$file2 !== void 0 && _frame$file2.startsWith('node:'))) return null;