testcafe 1.20.2-alpha.1 → 2.0.0-rc.3

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 (231) hide show
  1. package/lib/api/request-hooks/assert-type.js +2 -2
  2. package/lib/api/request-hooks/hook.js +2 -2
  3. package/lib/api/request-hooks/request-logger.js +2 -2
  4. package/lib/api/skip-js-errors/index.js +62 -0
  5. package/lib/api/structure/base-unit.js +2 -2
  6. package/lib/api/structure/fixture.js +13 -13
  7. package/lib/api/structure/test.js +18 -17
  8. package/lib/api/structure/testing-unit.js +26 -16
  9. package/lib/api/test-controller/assertion.js +5 -5
  10. package/lib/api/test-controller/execution-context.js +2 -2
  11. package/lib/api/test-controller/index.js +33 -30
  12. package/lib/api/test-controller/proxy.js +2 -2
  13. package/lib/api/test-page-url.js +4 -4
  14. package/lib/api/test-run-tracker.js +2 -2
  15. package/lib/api/wrap-test-function.js +3 -3
  16. package/lib/assertions/executor.js +4 -4
  17. package/lib/assertions/get-fn.js +3 -3
  18. package/lib/browser/connection/gateway.js +18 -18
  19. package/lib/browser/connection/get-hints.js +8 -8
  20. package/lib/browser/connection/index.js +11 -11
  21. package/lib/browser/connection/remotes-queue.js +4 -4
  22. package/lib/browser/provider/built-in/dedicated/base.js +6 -6
  23. package/lib/browser/provider/built-in/dedicated/chrome/cdp-client/index.js +10 -10
  24. package/lib/browser/provider/built-in/dedicated/chrome/config.js +17 -17
  25. package/lib/browser/provider/built-in/dedicated/chrome/create-temp-profile.js +4 -4
  26. package/lib/browser/provider/built-in/dedicated/chrome/index.js +6 -6
  27. package/lib/browser/provider/built-in/dedicated/chrome/local-chrome.js +6 -6
  28. package/lib/browser/provider/built-in/dedicated/chrome/runtime-info.js +4 -4
  29. package/lib/browser/provider/built-in/dedicated/edge/runtime-info.js +2 -2
  30. package/lib/browser/provider/built-in/dedicated/firefox/config.js +8 -8
  31. package/lib/browser/provider/built-in/dedicated/firefox/create-temp-profile.js +3 -3
  32. package/lib/browser/provider/built-in/dedicated/firefox/index.js +5 -5
  33. package/lib/browser/provider/built-in/dedicated/firefox/local-firefox.js +2 -2
  34. package/lib/browser/provider/built-in/dedicated/firefox/marionette-client/index.js +7 -7
  35. package/lib/browser/provider/built-in/dedicated/firefox/runtime-info.js +3 -3
  36. package/lib/browser/provider/built-in/path.js +2 -2
  37. package/lib/browser/provider/built-in/remote.js +3 -3
  38. package/lib/browser/provider/index.js +5 -5
  39. package/lib/browser/provider/plugin-host.js +5 -6
  40. package/lib/browser/provider/pool.js +4 -4
  41. package/lib/browser/provider/utils/argument-parsing.js +3 -3
  42. package/lib/browser/provider/utils/browser-starter.js +2 -2
  43. package/lib/cli/argument-parser/index.js +52 -41
  44. package/lib/cli/argument-parser/parse-utils.js +2 -2
  45. package/lib/cli/authentication-helper.js +3 -3
  46. package/lib/cli/cli.js +8 -8
  47. package/lib/cli/correct-browsers-and-sources.js +2 -2
  48. package/lib/cli/index.js +2 -2
  49. package/lib/cli/log.js +3 -3
  50. package/lib/cli/remotes-wizard.js +3 -3
  51. package/lib/client/automation/index.js +120 -34
  52. package/lib/client/automation/index.min.js +1 -1
  53. package/lib/client/browser/idle-page/index.js +321 -317
  54. package/lib/client/browser/service-worker.js +244 -290
  55. package/lib/client/core/deps/hammerhead.js +12 -4
  56. package/lib/client/core/index.js +145 -55
  57. package/lib/client/core/index.min.js +1 -1
  58. package/lib/client/core/utils/dom.js +33 -28
  59. package/lib/client/core/utils/position.js +18 -14
  60. package/lib/client/core/utils/style.js +8 -4
  61. package/lib/client/driver/command-executors/client-functions/selector-executor/filter.js +5 -5
  62. package/lib/client/driver/command-executors/client-functions/selector-executor/utils.js +3 -3
  63. package/lib/client/driver/deps/hammerhead.js +12 -4
  64. package/lib/client/driver/deps/testcafe-core.js +12 -4
  65. package/lib/client/driver/deps/testcafe-ui.js +12 -4
  66. package/lib/client/driver/index.js +654 -630
  67. package/lib/client/driver/index.min.js +1 -1
  68. package/lib/client/driver/status.js +2 -2
  69. package/lib/client/ui/index.js +10 -8
  70. package/lib/client/ui/index.min.js +1 -1
  71. package/lib/client-functions/builder-symbol.js +1 -2
  72. package/lib/client-functions/client-function-builder.js +12 -12
  73. package/lib/client-functions/replicator.js +2 -2
  74. package/lib/client-functions/selector-api-execution-mode.js +2 -2
  75. package/lib/client-functions/selectors/add-api.js +48 -48
  76. package/lib/client-functions/selectors/selector-builder.js +17 -17
  77. package/lib/compiler/compile-client-function.js +6 -6
  78. package/lib/compiler/index.js +9 -9
  79. package/lib/compiler/test-file/api-based.js +8 -8
  80. package/lib/compiler/test-file/base.js +6 -6
  81. package/lib/compiler/test-file/exportble-lib-path.js +2 -2
  82. package/lib/compiler/test-file/formats/coffeescript/compiler.js +2 -2
  83. package/lib/compiler/test-file/formats/coffeescript/get-test-list.js +2 -2
  84. package/lib/compiler/test-file/formats/es-next/compiler.js +4 -4
  85. package/lib/compiler/test-file/formats/es-next/get-test-list.js +4 -4
  86. package/lib/compiler/test-file/formats/raw.js +2 -2
  87. package/lib/compiler/test-file/formats/typescript/compiler.js +11 -11
  88. package/lib/compiler/test-file/formats/typescript/get-test-list.js +3 -3
  89. package/lib/compiler/test-file/test-file-parser-base.js +3 -3
  90. package/lib/configuration/configuration-base.js +15 -15
  91. package/lib/configuration/interfaces.js +1 -1
  92. package/lib/configuration/skip-js-errors-option-names.js +11 -0
  93. package/lib/configuration/testcafe-configuration.js +21 -16
  94. package/lib/configuration/types.js +1 -1
  95. package/lib/configuration/typescript-configuration.js +4 -4
  96. package/lib/custom-client-scripts/assert-type.js +2 -2
  97. package/lib/custom-client-scripts/client-script.js +6 -6
  98. package/lib/custom-client-scripts/get-code.js +2 -2
  99. package/lib/custom-client-scripts/routing.js +3 -3
  100. package/lib/custom-client-scripts/utils.js +3 -3
  101. package/lib/dashboard/connector.js +4 -4
  102. package/lib/dashboard/get-default-project-link.js +2 -2
  103. package/lib/dashboard/index.js +26 -26
  104. package/lib/errors/create-stack-filter.js +2 -2
  105. package/lib/errors/error-list.js +2 -2
  106. package/lib/errors/get-callsite.js +2 -2
  107. package/lib/errors/is-internal-stack-frame.js +5 -5
  108. package/lib/errors/process-test-fn-error.js +2 -2
  109. package/lib/errors/runtime/index.js +10 -10
  110. package/lib/errors/runtime/templates.js +5 -2
  111. package/lib/errors/runtime/type-assertions.js +6 -6
  112. package/lib/errors/stack-cleaning-hook.js +2 -2
  113. package/lib/errors/test-run/formattable-adapter.js +7 -7
  114. package/lib/errors/test-run/index.js +25 -5
  115. package/lib/errors/test-run/render-error-template/index.js +6 -6
  116. package/lib/errors/test-run/render-error-template/utils.js +2 -2
  117. package/lib/errors/test-run/templates.js +40 -31
  118. package/lib/errors/test-run/utils.js +7 -7
  119. package/lib/errors/types.js +5 -1
  120. package/lib/index.js +1 -1
  121. package/lib/live/file-watcher/index.js +2 -2
  122. package/lib/live/keyboard-observer.js +3 -3
  123. package/lib/live/test-run-controller.js +3 -3
  124. package/lib/live/test-run.js +3 -2
  125. package/lib/live/test-runner.js +2 -2
  126. package/lib/load-assets.js +2 -2
  127. package/lib/notifications/add-rendered-warning.js +4 -4
  128. package/lib/notifications/debug-logger.js +6 -6
  129. package/lib/notifications/deprecated.js +2 -2
  130. package/lib/notifications/information-message.js +4 -3
  131. package/lib/proxyless/resource-injector.js +4 -4
  132. package/lib/reporter/command/command-formatter.js +4 -4
  133. package/lib/reporter/index.js +10 -10
  134. package/lib/reporter/plugin-host.js +7 -7
  135. package/lib/role/index.js +8 -8
  136. package/lib/role/role.js +2 -2
  137. package/lib/runner/bootstrapper.js +20 -20
  138. package/lib/runner/browser-job.js +3 -3
  139. package/lib/runner/browser-set.js +12 -12
  140. package/lib/runner/fixture-hook-controller.js +5 -5
  141. package/lib/runner/index.js +43 -33
  142. package/lib/runner/task/index.js +10 -6
  143. package/lib/runner/test-run-hook-controller.js +5 -5
  144. package/lib/runner/tested-app.js +7 -7
  145. package/lib/screenshots/capturer.js +17 -17
  146. package/lib/screenshots/crop.js +8 -8
  147. package/lib/screenshots/index.js +6 -10
  148. package/lib/screenshots/utils.js +4 -4
  149. package/lib/services/compiler/host.js +8 -8
  150. package/lib/services/compiler/service.js +13 -13
  151. package/lib/services/compiler/test-run-proxy.js +8 -8
  152. package/lib/services/serialization/replicator/transforms/callsite-record-transform.js +2 -2
  153. package/lib/services/serialization/replicator/transforms/command-base-trasform/command-constructors.js +2 -1
  154. package/lib/services/serialization/replicator/transforms/command-base-trasform/index.js +3 -3
  155. package/lib/services/serialization/replicator/transforms/raw-command-callsite-record-transform.js +2 -2
  156. package/lib/services/serialization/test-structure.js +4 -4
  157. package/lib/services/utils/ipc/interfaces.js +1 -3
  158. package/lib/services/utils/ipc/io.js +3 -3
  159. package/lib/services/utils/ipc/message.js +2 -2
  160. package/lib/services/utils/ipc/proxy.js +4 -4
  161. package/lib/services/utils/ipc/transport.js +2 -2
  162. package/lib/shared/errors/index.js +9 -2
  163. package/lib/shared/errors/selector-error-ctor-callback.js +7 -3
  164. package/lib/test-run/bookmark.js +1 -1
  165. package/lib/test-run/browser-manipulation-queue.js +3 -3
  166. package/lib/test-run/commands/actions.js +66 -46
  167. package/lib/test-run/commands/assertion.js +3 -3
  168. package/lib/test-run/commands/base.js +2 -2
  169. package/lib/test-run/commands/browser-manipulation.js +8 -8
  170. package/lib/test-run/commands/observation.js +4 -4
  171. package/lib/test-run/commands/options.js +27 -12
  172. package/lib/test-run/commands/type.js +2 -1
  173. package/lib/test-run/commands/utils.js +3 -2
  174. package/lib/test-run/commands/validations/argument.js +19 -10
  175. package/lib/test-run/commands/validations/factories.js +10 -2
  176. package/lib/test-run/commands/validations/initializers.js +4 -4
  177. package/lib/test-run/debug-log.js +4 -4
  178. package/lib/test-run/execute-js-expression/index.js +4 -4
  179. package/lib/test-run/index.js +48 -41
  180. package/lib/test-run/request/create-request-options.js +9 -9
  181. package/lib/test-run/request/process-response-data.js +2 -2
  182. package/lib/test-run/request/send.js +5 -5
  183. package/lib/testcafe.js +8 -4
  184. package/lib/utils/check-file-path.js +2 -2
  185. package/lib/utils/check-url.js +2 -2
  186. package/lib/utils/correct-file-path.js +4 -4
  187. package/lib/utils/delegated-api.js +1 -1
  188. package/lib/utils/detect-ffmpeg.js +3 -3
  189. package/lib/utils/diff/colors.js +2 -2
  190. package/lib/utils/diff/index.js +11 -7
  191. package/lib/utils/diff/util.js +5 -5
  192. package/lib/utils/diff.js +4 -4
  193. package/lib/utils/escape-user-agent.js +2 -2
  194. package/lib/utils/execute-fn-with-timeout.js +2 -2
  195. package/lib/utils/get-browser.js +2 -2
  196. package/lib/utils/get-filter-fn.js +4 -4
  197. package/lib/utils/get-options/base.js +2 -2
  198. package/lib/utils/get-options/compiler.js +2 -2
  199. package/lib/utils/get-options/dashboard.js +2 -2
  200. package/lib/utils/get-options/get-assertion-timeout.js +1 -1
  201. package/lib/utils/get-options/index.js +4 -2
  202. package/lib/utils/get-options/meta.js +2 -2
  203. package/lib/utils/get-options/quarantine.js +8 -6
  204. package/lib/utils/get-options/screenshot.js +2 -2
  205. package/lib/utils/get-options/skip-js-errors.js +35 -0
  206. package/lib/utils/get-options/ssl.js +6 -6
  207. package/lib/utils/get-options/video.js +2 -2
  208. package/lib/utils/is-password-input.js +1 -1
  209. package/lib/utils/log-entry.js +2 -2
  210. package/lib/utils/make-reg-exp.js +19 -6
  211. package/lib/utils/moment-loader.js +2 -2
  212. package/lib/utils/parse-file-list.js +7 -7
  213. package/lib/utils/path-pattern.js +4 -4
  214. package/lib/utils/prepare-reporters.js +2 -2
  215. package/lib/utils/prerender-callsite.js +6 -6
  216. package/lib/utils/process.js +7 -7
  217. package/lib/utils/promisified-functions.js +14 -14
  218. package/lib/utils/raw-command-callsite-record.js +2 -2
  219. package/lib/utils/resolve-path-relatively-cwd.js +2 -2
  220. package/lib/utils/string.js +3 -3
  221. package/lib/utils/temp-directory/cleanup-process/index.js +6 -6
  222. package/lib/utils/temp-directory/cleanup-process/worker.js +4 -4
  223. package/lib/utils/temp-directory/index.js +6 -6
  224. package/lib/utils/temp-directory/lockfile.js +2 -2
  225. package/lib/video-recorder/process.js +6 -6
  226. package/lib/video-recorder/recorder.js +9 -9
  227. package/lib/video-recorder/test-run-video-recorder.js +2 -2
  228. package/package.json +8 -7
  229. package/ts-defs/index.d.ts +46 -7
  230. package/ts-defs/selectors.d.ts +39 -0
  231. package/ts-defs/testcafe-scripts.d.ts +39 -0
@@ -1,301 +1,255 @@
1
1
  (function () {
2
2
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
3
3
 
4
- var PENDING = 'pending';
5
- var SETTLED = 'settled';
6
- var FULFILLED = 'fulfilled';
7
- var REJECTED = 'rejected';
8
- var NOOP = function () {};
9
- var isNode = typeof commonjsGlobal !== 'undefined' && typeof commonjsGlobal.process !== 'undefined' && typeof commonjsGlobal.process.emit === 'function';
10
-
11
- var asyncSetTimer = typeof setImmediate === 'undefined' ? setTimeout : setImmediate;
12
- var asyncQueue = [];
13
- var asyncTimer;
14
-
15
- function asyncFlush() {
16
- // run promise callbacks
17
- for (var i = 0; i < asyncQueue.length; i++) {
18
- asyncQueue[i][0](asyncQueue[i][1]);
19
- }
20
-
21
- // reset async asyncQueue
22
- asyncQueue = [];
23
- asyncTimer = false;
24
- }
25
-
26
- function asyncCall(callback, arg) {
27
- asyncQueue.push([callback, arg]);
28
-
29
- if (!asyncTimer) {
30
- asyncTimer = true;
31
- asyncSetTimer(asyncFlush, 0);
32
- }
33
- }
34
-
35
- function invokeResolver(resolver, promise) {
36
- function resolvePromise(value) {
37
- resolve(promise, value);
38
- }
39
-
40
- function rejectPromise(reason) {
41
- reject(promise, reason);
42
- }
43
-
44
- try {
45
- resolver(resolvePromise, rejectPromise);
46
- } catch (e) {
47
- rejectPromise(e);
48
- }
49
- }
50
-
51
- function invokeCallback(subscriber) {
52
- var owner = subscriber.owner;
53
- var settled = owner._state;
54
- var value = owner._data;
55
- var callback = subscriber[settled];
56
- var promise = subscriber.then;
57
-
58
- if (typeof callback === 'function') {
59
- settled = FULFILLED;
60
- try {
61
- value = callback(value);
62
- } catch (e) {
63
- reject(promise, e);
64
- }
65
- }
66
-
67
- if (!handleThenable(promise, value)) {
68
- if (settled === FULFILLED) {
69
- resolve(promise, value);
70
- }
71
-
72
- if (settled === REJECTED) {
73
- reject(promise, value);
74
- }
75
- }
76
- }
77
-
78
- function handleThenable(promise, value) {
79
- var resolved;
80
-
81
- try {
82
- if (promise === value) {
83
- throw new TypeError('A promises callback cannot return that same promise.');
84
- }
85
-
86
- if (value && (typeof value === 'function' || typeof value === 'object')) {
87
- // then should be retrieved only once
88
- var then = value.then;
89
-
90
- if (typeof then === 'function') {
91
- then.call(value, function (val) {
92
- if (!resolved) {
93
- resolved = true;
94
-
95
- if (value === val) {
96
- fulfill(promise, val);
97
- } else {
98
- resolve(promise, val);
99
- }
100
- }
101
- }, function (reason) {
102
- if (!resolved) {
103
- resolved = true;
104
-
105
- reject(promise, reason);
106
- }
107
- });
108
-
109
- return true;
110
- }
111
- }
112
- } catch (e) {
113
- if (!resolved) {
114
- reject(promise, e);
115
- }
116
-
117
- return true;
118
- }
119
-
120
- return false;
121
- }
122
-
123
- function resolve(promise, value) {
124
- if (promise === value || !handleThenable(promise, value)) {
125
- fulfill(promise, value);
126
- }
127
- }
128
-
129
- function fulfill(promise, value) {
130
- if (promise._state === PENDING) {
131
- promise._state = SETTLED;
132
- promise._data = value;
133
-
134
- asyncCall(publishFulfillment, promise);
135
- }
136
- }
137
-
138
- function reject(promise, reason) {
139
- if (promise._state === PENDING) {
140
- promise._state = SETTLED;
141
- promise._data = reason;
142
-
143
- asyncCall(publishRejection, promise);
144
- }
145
- }
146
-
147
- function publish(promise) {
148
- promise._then = promise._then.forEach(invokeCallback);
149
- }
150
-
151
- function publishFulfillment(promise) {
152
- promise._state = FULFILLED;
153
- publish(promise);
154
- }
155
-
156
- function publishRejection(promise) {
157
- promise._state = REJECTED;
158
- publish(promise);
159
- if (!promise._handled && isNode) {
160
- commonjsGlobal.process.emit('unhandledRejection', promise._data, promise);
161
- }
162
- }
163
-
164
- function notifyRejectionHandled(promise) {
165
- commonjsGlobal.process.emit('rejectionHandled', promise);
166
- }
167
-
168
- /**
169
- * @class
170
- */
171
- function Promise(resolver) {
172
- if (typeof resolver !== 'function') {
173
- throw new TypeError('Promise resolver ' + resolver + ' is not a function');
174
- }
175
-
176
- if (this instanceof Promise === false) {
177
- throw new TypeError('Failed to construct \'Promise\': Please use the \'new\' operator, this object constructor cannot be called as a function.');
178
- }
179
-
180
- this._then = [];
181
-
182
- invokeResolver(resolver, this);
183
- }
184
-
185
- Promise.prototype = {
186
- constructor: Promise,
187
-
188
- _state: PENDING,
189
- _then: null,
190
- _data: undefined,
191
- _handled: false,
192
-
193
- then: function (onFulfillment, onRejection) {
194
- var subscriber = {
195
- owner: this,
196
- then: new this.constructor(NOOP),
197
- fulfilled: onFulfillment,
198
- rejected: onRejection
199
- };
200
-
201
- if ((onRejection || onFulfillment) && !this._handled) {
202
- this._handled = true;
203
- if (this._state === REJECTED && isNode) {
204
- asyncCall(notifyRejectionHandled, this);
205
- }
206
- }
207
-
208
- if (this._state === FULFILLED || this._state === REJECTED) {
209
- // already resolved, call callback async
210
- asyncCall(invokeCallback, subscriber);
211
- } else {
212
- // subscribe
213
- this._then.push(subscriber);
214
- }
215
-
216
- return subscriber.then;
217
- },
218
-
219
- catch: function (onRejection) {
220
- return this.then(null, onRejection);
221
- }
222
- };
223
-
224
- Promise.all = function (promises) {
225
- if (!Array.isArray(promises)) {
226
- throw new TypeError('You must pass an array to Promise.all().');
227
- }
228
-
229
- return new Promise(function (resolve, reject) {
230
- var results = [];
231
- var remaining = 0;
232
-
233
- function resolver(index) {
234
- remaining++;
235
- return function (value) {
236
- results[index] = value;
237
- if (!--remaining) {
238
- resolve(results);
239
- }
240
- };
241
- }
242
-
243
- for (var i = 0, promise; i < promises.length; i++) {
244
- promise = promises[i];
245
-
246
- if (promise && typeof promise.then === 'function') {
247
- promise.then(resolver(i), reject);
248
- } else {
249
- results[i] = promise;
250
- }
251
- }
252
-
253
- if (!remaining) {
254
- resolve(results);
255
- }
256
- });
257
- };
258
-
259
- Promise.race = function (promises) {
260
- if (!Array.isArray(promises)) {
261
- throw new TypeError('You must pass an array to Promise.race().');
262
- }
263
-
264
- return new Promise(function (resolve, reject) {
265
- for (var i = 0, promise; i < promises.length; i++) {
266
- promise = promises[i];
267
-
268
- if (promise && typeof promise.then === 'function') {
269
- promise.then(resolve, reject);
270
- } else {
271
- resolve(promise);
272
- }
273
- }
274
- });
275
- };
276
-
277
- Promise.resolve = function (value) {
278
- if (value && typeof value === 'object' && value.constructor === Promise) {
279
- return value;
280
- }
281
-
282
- return new Promise(function (resolve) {
283
- resolve(value);
284
- });
285
- };
286
-
287
- Promise.reject = function (reason) {
288
- return new Promise(function (resolve, reject) {
289
- reject(reason);
290
- });
291
- };
292
-
4
+ var PENDING = 'pending';
5
+ var SETTLED = 'settled';
6
+ var FULFILLED = 'fulfilled';
7
+ var REJECTED = 'rejected';
8
+ var NOOP = function () { };
9
+ var isNode = typeof commonjsGlobal !== 'undefined' && typeof commonjsGlobal.process !== 'undefined' && typeof commonjsGlobal.process.emit === 'function';
10
+ var asyncSetTimer = typeof setImmediate === 'undefined' ? setTimeout : setImmediate;
11
+ var asyncQueue = [];
12
+ var asyncTimer;
13
+ function asyncFlush() {
14
+ // run promise callbacks
15
+ for (var i = 0; i < asyncQueue.length; i++) {
16
+ asyncQueue[i][0](asyncQueue[i][1]);
17
+ }
18
+ // reset async asyncQueue
19
+ asyncQueue = [];
20
+ asyncTimer = false;
21
+ }
22
+ function asyncCall(callback, arg) {
23
+ asyncQueue.push([callback, arg]);
24
+ if (!asyncTimer) {
25
+ asyncTimer = true;
26
+ asyncSetTimer(asyncFlush, 0);
27
+ }
28
+ }
29
+ function invokeResolver(resolver, promise) {
30
+ function resolvePromise(value) {
31
+ resolve(promise, value);
32
+ }
33
+ function rejectPromise(reason) {
34
+ reject(promise, reason);
35
+ }
36
+ try {
37
+ resolver(resolvePromise, rejectPromise);
38
+ }
39
+ catch (e) {
40
+ rejectPromise(e);
41
+ }
42
+ }
43
+ function invokeCallback(subscriber) {
44
+ var owner = subscriber.owner;
45
+ var settled = owner._state;
46
+ var value = owner._data;
47
+ var callback = subscriber[settled];
48
+ var promise = subscriber.then;
49
+ if (typeof callback === 'function') {
50
+ settled = FULFILLED;
51
+ try {
52
+ value = callback(value);
53
+ }
54
+ catch (e) {
55
+ reject(promise, e);
56
+ }
57
+ }
58
+ if (!handleThenable(promise, value)) {
59
+ if (settled === FULFILLED) {
60
+ resolve(promise, value);
61
+ }
62
+ if (settled === REJECTED) {
63
+ reject(promise, value);
64
+ }
65
+ }
66
+ }
67
+ function handleThenable(promise, value) {
68
+ var resolved;
69
+ try {
70
+ if (promise === value) {
71
+ throw new TypeError('A promises callback cannot return that same promise.');
72
+ }
73
+ if (value && (typeof value === 'function' || typeof value === 'object')) {
74
+ // then should be retrieved only once
75
+ var then = value.then;
76
+ if (typeof then === 'function') {
77
+ then.call(value, function (val) {
78
+ if (!resolved) {
79
+ resolved = true;
80
+ if (value === val) {
81
+ fulfill(promise, val);
82
+ }
83
+ else {
84
+ resolve(promise, val);
85
+ }
86
+ }
87
+ }, function (reason) {
88
+ if (!resolved) {
89
+ resolved = true;
90
+ reject(promise, reason);
91
+ }
92
+ });
93
+ return true;
94
+ }
95
+ }
96
+ }
97
+ catch (e) {
98
+ if (!resolved) {
99
+ reject(promise, e);
100
+ }
101
+ return true;
102
+ }
103
+ return false;
104
+ }
105
+ function resolve(promise, value) {
106
+ if (promise === value || !handleThenable(promise, value)) {
107
+ fulfill(promise, value);
108
+ }
109
+ }
110
+ function fulfill(promise, value) {
111
+ if (promise._state === PENDING) {
112
+ promise._state = SETTLED;
113
+ promise._data = value;
114
+ asyncCall(publishFulfillment, promise);
115
+ }
116
+ }
117
+ function reject(promise, reason) {
118
+ if (promise._state === PENDING) {
119
+ promise._state = SETTLED;
120
+ promise._data = reason;
121
+ asyncCall(publishRejection, promise);
122
+ }
123
+ }
124
+ function publish(promise) {
125
+ promise._then = promise._then.forEach(invokeCallback);
126
+ }
127
+ function publishFulfillment(promise) {
128
+ promise._state = FULFILLED;
129
+ publish(promise);
130
+ }
131
+ function publishRejection(promise) {
132
+ promise._state = REJECTED;
133
+ publish(promise);
134
+ if (!promise._handled && isNode) {
135
+ commonjsGlobal.process.emit('unhandledRejection', promise._data, promise);
136
+ }
137
+ }
138
+ function notifyRejectionHandled(promise) {
139
+ commonjsGlobal.process.emit('rejectionHandled', promise);
140
+ }
141
+ /**
142
+ * @class
143
+ */
144
+ function Promise(resolver) {
145
+ if (typeof resolver !== 'function') {
146
+ throw new TypeError('Promise resolver ' + resolver + ' is not a function');
147
+ }
148
+ if (this instanceof Promise === false) {
149
+ throw new TypeError('Failed to construct \'Promise\': Please use the \'new\' operator, this object constructor cannot be called as a function.');
150
+ }
151
+ this._then = [];
152
+ invokeResolver(resolver, this);
153
+ }
154
+ Promise.prototype = {
155
+ constructor: Promise,
156
+ _state: PENDING,
157
+ _then: null,
158
+ _data: undefined,
159
+ _handled: false,
160
+ then: function (onFulfillment, onRejection) {
161
+ var subscriber = {
162
+ owner: this,
163
+ then: new this.constructor(NOOP),
164
+ fulfilled: onFulfillment,
165
+ rejected: onRejection
166
+ };
167
+ if ((onRejection || onFulfillment) && !this._handled) {
168
+ this._handled = true;
169
+ if (this._state === REJECTED && isNode) {
170
+ asyncCall(notifyRejectionHandled, this);
171
+ }
172
+ }
173
+ if (this._state === FULFILLED || this._state === REJECTED) {
174
+ // already resolved, call callback async
175
+ asyncCall(invokeCallback, subscriber);
176
+ }
177
+ else {
178
+ // subscribe
179
+ this._then.push(subscriber);
180
+ }
181
+ return subscriber.then;
182
+ },
183
+ catch: function (onRejection) {
184
+ return this.then(null, onRejection);
185
+ }
186
+ };
187
+ Promise.all = function (promises) {
188
+ if (!Array.isArray(promises)) {
189
+ throw new TypeError('You must pass an array to Promise.all().');
190
+ }
191
+ return new Promise(function (resolve, reject) {
192
+ var results = [];
193
+ var remaining = 0;
194
+ function resolver(index) {
195
+ remaining++;
196
+ return function (value) {
197
+ results[index] = value;
198
+ if (!--remaining) {
199
+ resolve(results);
200
+ }
201
+ };
202
+ }
203
+ for (var i = 0, promise; i < promises.length; i++) {
204
+ promise = promises[i];
205
+ if (promise && typeof promise.then === 'function') {
206
+ promise.then(resolver(i), reject);
207
+ }
208
+ else {
209
+ results[i] = promise;
210
+ }
211
+ }
212
+ if (!remaining) {
213
+ resolve(results);
214
+ }
215
+ });
216
+ };
217
+ Promise.race = function (promises) {
218
+ if (!Array.isArray(promises)) {
219
+ throw new TypeError('You must pass an array to Promise.race().');
220
+ }
221
+ return new Promise(function (resolve, reject) {
222
+ for (var i = 0, promise; i < promises.length; i++) {
223
+ promise = promises[i];
224
+ if (promise && typeof promise.then === 'function') {
225
+ promise.then(resolve, reject);
226
+ }
227
+ else {
228
+ resolve(promise);
229
+ }
230
+ }
231
+ });
232
+ };
233
+ Promise.resolve = function (value) {
234
+ if (value && typeof value === 'object' && value.constructor === Promise) {
235
+ return value;
236
+ }
237
+ return new Promise(function (resolve) {
238
+ resolve(value);
239
+ });
240
+ };
241
+ Promise.reject = function (reason) {
242
+ return new Promise(function (resolve, reject) {
243
+ reject(reason);
244
+ });
245
+ };
293
246
  var pinkie = Promise;
294
247
 
295
248
  function __rest(s, e) {
296
249
  var t = {};
297
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
298
- t[p] = s[p];
250
+ for (var p in s)
251
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
252
+ t[p] = s[p];
299
253
  if (s != null && typeof Object.getOwnPropertySymbols === "function")
300
254
  for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
301
255
  if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
@@ -303,42 +257,92 @@
303
257
  }
304
258
  return t;
305
259
  }
306
-
307
260
  function __awaiter(thisArg, _arguments, P, generator) {
308
261
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
309
262
  return new (P || (P = pinkie))(function (resolve, reject) {
310
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
311
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
263
+ function fulfilled(value) { try {
264
+ step(generator.next(value));
265
+ }
266
+ catch (e) {
267
+ reject(e);
268
+ } }
269
+ function rejected(value) { try {
270
+ step(generator["throw"](value));
271
+ }
272
+ catch (e) {
273
+ reject(e);
274
+ } }
312
275
  function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
313
276
  step((generator = generator.apply(thisArg, _arguments || [])).next());
314
277
  });
315
278
  }
316
-
317
279
  function __generator(thisArg, body) {
318
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
319
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
280
+ var _ = { label: 0, sent: function () { if (t[0] & 1)
281
+ throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
282
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
320
283
  function verb(n) { return function (v) { return step([n, v]); }; }
321
284
  function step(op) {
322
- if (f) throw new TypeError("Generator is already executing.");
323
- while (_) try {
324
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
325
- if (y = 0, t) op = [op[0] & 2, t.value];
326
- switch (op[0]) {
327
- case 0: case 1: t = op; break;
328
- case 4: _.label++; return { value: op[1], done: false };
329
- case 5: _.label++; y = op[1]; op = [0]; continue;
330
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
331
- default:
332
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
333
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
334
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
335
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
336
- if (t[2]) _.ops.pop();
337
- _.trys.pop(); continue;
285
+ if (f)
286
+ throw new TypeError("Generator is already executing.");
287
+ while (_)
288
+ try {
289
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
290
+ return t;
291
+ if (y = 0, t)
292
+ op = [op[0] & 2, t.value];
293
+ switch (op[0]) {
294
+ case 0:
295
+ case 1:
296
+ t = op;
297
+ break;
298
+ case 4:
299
+ _.label++;
300
+ return { value: op[1], done: false };
301
+ case 5:
302
+ _.label++;
303
+ y = op[1];
304
+ op = [0];
305
+ continue;
306
+ case 7:
307
+ op = _.ops.pop();
308
+ _.trys.pop();
309
+ continue;
310
+ default:
311
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
312
+ _ = 0;
313
+ continue;
314
+ }
315
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
316
+ _.label = op[1];
317
+ break;
318
+ }
319
+ if (op[0] === 6 && _.label < t[1]) {
320
+ _.label = t[1];
321
+ t = op;
322
+ break;
323
+ }
324
+ if (t && _.label < t[2]) {
325
+ _.label = t[2];
326
+ _.ops.push(op);
327
+ break;
328
+ }
329
+ if (t[2])
330
+ _.ops.pop();
331
+ _.trys.pop();
332
+ continue;
333
+ }
334
+ op = body.call(thisArg, _);
335
+ }
336
+ catch (e) {
337
+ op = [6, e];
338
+ y = 0;
339
+ }
340
+ finally {
341
+ f = t = 0;
338
342
  }
339
- op = body.call(thisArg, _);
340
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
341
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
343
+ if (op[0] & 5)
344
+ throw op[1];
345
+ return { value: op[0] ? op[1] : void 0, done: true };
342
346
  }
343
347
  }
344
348
 
@@ -524,7 +528,7 @@
524
528
  if (!(i < MAX_STATUS_RETRY)) return [3 /*break*/, 5];
525
529
  return [4 /*yield*/, tryGetStatus.apply(void 0, args)];
526
530
  case 2:
527
- (_a = _b.sent(), (error = _a.error, _a), result = __rest(_a, ["error"]));
531
+ (_a = _b.sent(), error = _a.error, result = __rest(_a, ["error"]));
528
532
  if (!error)
529
533
  return [2 /*return*/, result];
530
534
  return [4 /*yield*/, delay(STATUS_RETRY_DELAY)];