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.
- package/lib/api/request-hooks/assert-type.js +2 -2
- package/lib/api/request-hooks/hook.js +2 -2
- package/lib/api/request-hooks/request-logger.js +2 -2
- package/lib/api/skip-js-errors/index.js +62 -0
- package/lib/api/structure/base-unit.js +2 -2
- package/lib/api/structure/fixture.js +13 -13
- package/lib/api/structure/test.js +18 -17
- package/lib/api/structure/testing-unit.js +26 -16
- package/lib/api/test-controller/assertion.js +5 -5
- package/lib/api/test-controller/execution-context.js +2 -2
- package/lib/api/test-controller/index.js +33 -30
- package/lib/api/test-controller/proxy.js +2 -2
- package/lib/api/test-page-url.js +4 -4
- package/lib/api/test-run-tracker.js +2 -2
- package/lib/api/wrap-test-function.js +3 -3
- package/lib/assertions/executor.js +4 -4
- package/lib/assertions/get-fn.js +3 -3
- package/lib/browser/connection/gateway.js +18 -18
- package/lib/browser/connection/get-hints.js +8 -8
- package/lib/browser/connection/index.js +11 -11
- package/lib/browser/connection/remotes-queue.js +4 -4
- package/lib/browser/provider/built-in/dedicated/base.js +6 -6
- package/lib/browser/provider/built-in/dedicated/chrome/cdp-client/index.js +10 -10
- package/lib/browser/provider/built-in/dedicated/chrome/config.js +17 -17
- package/lib/browser/provider/built-in/dedicated/chrome/create-temp-profile.js +4 -4
- package/lib/browser/provider/built-in/dedicated/chrome/index.js +6 -6
- package/lib/browser/provider/built-in/dedicated/chrome/local-chrome.js +6 -6
- package/lib/browser/provider/built-in/dedicated/chrome/runtime-info.js +4 -4
- package/lib/browser/provider/built-in/dedicated/edge/runtime-info.js +2 -2
- package/lib/browser/provider/built-in/dedicated/firefox/config.js +8 -8
- package/lib/browser/provider/built-in/dedicated/firefox/create-temp-profile.js +3 -3
- package/lib/browser/provider/built-in/dedicated/firefox/index.js +5 -5
- package/lib/browser/provider/built-in/dedicated/firefox/local-firefox.js +2 -2
- package/lib/browser/provider/built-in/dedicated/firefox/marionette-client/index.js +7 -7
- package/lib/browser/provider/built-in/dedicated/firefox/runtime-info.js +3 -3
- package/lib/browser/provider/built-in/path.js +2 -2
- package/lib/browser/provider/built-in/remote.js +3 -3
- package/lib/browser/provider/index.js +5 -5
- package/lib/browser/provider/plugin-host.js +5 -6
- package/lib/browser/provider/pool.js +4 -4
- package/lib/browser/provider/utils/argument-parsing.js +3 -3
- package/lib/browser/provider/utils/browser-starter.js +2 -2
- package/lib/cli/argument-parser/index.js +52 -41
- package/lib/cli/argument-parser/parse-utils.js +2 -2
- package/lib/cli/authentication-helper.js +3 -3
- package/lib/cli/cli.js +8 -8
- package/lib/cli/correct-browsers-and-sources.js +2 -2
- package/lib/cli/index.js +2 -2
- package/lib/cli/log.js +3 -3
- package/lib/cli/remotes-wizard.js +3 -3
- package/lib/client/automation/index.js +120 -34
- package/lib/client/automation/index.min.js +1 -1
- package/lib/client/browser/idle-page/index.js +321 -317
- package/lib/client/browser/service-worker.js +244 -290
- package/lib/client/core/deps/hammerhead.js +12 -4
- package/lib/client/core/index.js +145 -55
- package/lib/client/core/index.min.js +1 -1
- package/lib/client/core/utils/dom.js +33 -28
- package/lib/client/core/utils/position.js +18 -14
- package/lib/client/core/utils/style.js +8 -4
- package/lib/client/driver/command-executors/client-functions/selector-executor/filter.js +5 -5
- package/lib/client/driver/command-executors/client-functions/selector-executor/utils.js +3 -3
- package/lib/client/driver/deps/hammerhead.js +12 -4
- package/lib/client/driver/deps/testcafe-core.js +12 -4
- package/lib/client/driver/deps/testcafe-ui.js +12 -4
- package/lib/client/driver/index.js +654 -630
- package/lib/client/driver/index.min.js +1 -1
- package/lib/client/driver/status.js +2 -2
- package/lib/client/ui/index.js +10 -8
- package/lib/client/ui/index.min.js +1 -1
- package/lib/client-functions/builder-symbol.js +1 -2
- package/lib/client-functions/client-function-builder.js +12 -12
- package/lib/client-functions/replicator.js +2 -2
- package/lib/client-functions/selector-api-execution-mode.js +2 -2
- package/lib/client-functions/selectors/add-api.js +48 -48
- package/lib/client-functions/selectors/selector-builder.js +17 -17
- package/lib/compiler/compile-client-function.js +6 -6
- package/lib/compiler/index.js +9 -9
- package/lib/compiler/test-file/api-based.js +8 -8
- package/lib/compiler/test-file/base.js +6 -6
- package/lib/compiler/test-file/exportble-lib-path.js +2 -2
- package/lib/compiler/test-file/formats/coffeescript/compiler.js +2 -2
- package/lib/compiler/test-file/formats/coffeescript/get-test-list.js +2 -2
- package/lib/compiler/test-file/formats/es-next/compiler.js +4 -4
- package/lib/compiler/test-file/formats/es-next/get-test-list.js +4 -4
- package/lib/compiler/test-file/formats/raw.js +2 -2
- package/lib/compiler/test-file/formats/typescript/compiler.js +11 -11
- package/lib/compiler/test-file/formats/typescript/get-test-list.js +3 -3
- package/lib/compiler/test-file/test-file-parser-base.js +3 -3
- package/lib/configuration/configuration-base.js +15 -15
- package/lib/configuration/interfaces.js +1 -1
- package/lib/configuration/skip-js-errors-option-names.js +11 -0
- package/lib/configuration/testcafe-configuration.js +21 -16
- package/lib/configuration/types.js +1 -1
- package/lib/configuration/typescript-configuration.js +4 -4
- package/lib/custom-client-scripts/assert-type.js +2 -2
- package/lib/custom-client-scripts/client-script.js +6 -6
- package/lib/custom-client-scripts/get-code.js +2 -2
- package/lib/custom-client-scripts/routing.js +3 -3
- package/lib/custom-client-scripts/utils.js +3 -3
- package/lib/dashboard/connector.js +4 -4
- package/lib/dashboard/get-default-project-link.js +2 -2
- package/lib/dashboard/index.js +26 -26
- package/lib/errors/create-stack-filter.js +2 -2
- package/lib/errors/error-list.js +2 -2
- package/lib/errors/get-callsite.js +2 -2
- package/lib/errors/is-internal-stack-frame.js +5 -5
- package/lib/errors/process-test-fn-error.js +2 -2
- package/lib/errors/runtime/index.js +10 -10
- package/lib/errors/runtime/templates.js +5 -2
- package/lib/errors/runtime/type-assertions.js +6 -6
- package/lib/errors/stack-cleaning-hook.js +2 -2
- package/lib/errors/test-run/formattable-adapter.js +7 -7
- package/lib/errors/test-run/index.js +25 -5
- package/lib/errors/test-run/render-error-template/index.js +6 -6
- package/lib/errors/test-run/render-error-template/utils.js +2 -2
- package/lib/errors/test-run/templates.js +40 -31
- package/lib/errors/test-run/utils.js +7 -7
- package/lib/errors/types.js +5 -1
- package/lib/index.js +1 -1
- package/lib/live/file-watcher/index.js +2 -2
- package/lib/live/keyboard-observer.js +3 -3
- package/lib/live/test-run-controller.js +3 -3
- package/lib/live/test-run.js +3 -2
- package/lib/live/test-runner.js +2 -2
- package/lib/load-assets.js +2 -2
- package/lib/notifications/add-rendered-warning.js +4 -4
- package/lib/notifications/debug-logger.js +6 -6
- package/lib/notifications/deprecated.js +2 -2
- package/lib/notifications/information-message.js +4 -3
- package/lib/proxyless/resource-injector.js +4 -4
- package/lib/reporter/command/command-formatter.js +4 -4
- package/lib/reporter/index.js +10 -10
- package/lib/reporter/plugin-host.js +7 -7
- package/lib/role/index.js +8 -8
- package/lib/role/role.js +2 -2
- package/lib/runner/bootstrapper.js +20 -20
- package/lib/runner/browser-job.js +3 -3
- package/lib/runner/browser-set.js +12 -12
- package/lib/runner/fixture-hook-controller.js +5 -5
- package/lib/runner/index.js +43 -33
- package/lib/runner/task/index.js +10 -6
- package/lib/runner/test-run-hook-controller.js +5 -5
- package/lib/runner/tested-app.js +7 -7
- package/lib/screenshots/capturer.js +17 -17
- package/lib/screenshots/crop.js +8 -8
- package/lib/screenshots/index.js +6 -10
- package/lib/screenshots/utils.js +4 -4
- package/lib/services/compiler/host.js +8 -8
- package/lib/services/compiler/service.js +13 -13
- package/lib/services/compiler/test-run-proxy.js +8 -8
- package/lib/services/serialization/replicator/transforms/callsite-record-transform.js +2 -2
- package/lib/services/serialization/replicator/transforms/command-base-trasform/command-constructors.js +2 -1
- package/lib/services/serialization/replicator/transforms/command-base-trasform/index.js +3 -3
- package/lib/services/serialization/replicator/transforms/raw-command-callsite-record-transform.js +2 -2
- package/lib/services/serialization/test-structure.js +4 -4
- package/lib/services/utils/ipc/interfaces.js +1 -3
- package/lib/services/utils/ipc/io.js +3 -3
- package/lib/services/utils/ipc/message.js +2 -2
- package/lib/services/utils/ipc/proxy.js +4 -4
- package/lib/services/utils/ipc/transport.js +2 -2
- package/lib/shared/errors/index.js +9 -2
- package/lib/shared/errors/selector-error-ctor-callback.js +7 -3
- package/lib/test-run/bookmark.js +1 -1
- package/lib/test-run/browser-manipulation-queue.js +3 -3
- package/lib/test-run/commands/actions.js +66 -46
- package/lib/test-run/commands/assertion.js +3 -3
- package/lib/test-run/commands/base.js +2 -2
- package/lib/test-run/commands/browser-manipulation.js +8 -8
- package/lib/test-run/commands/observation.js +4 -4
- package/lib/test-run/commands/options.js +27 -12
- package/lib/test-run/commands/type.js +2 -1
- package/lib/test-run/commands/utils.js +3 -2
- package/lib/test-run/commands/validations/argument.js +19 -10
- package/lib/test-run/commands/validations/factories.js +10 -2
- package/lib/test-run/commands/validations/initializers.js +4 -4
- package/lib/test-run/debug-log.js +4 -4
- package/lib/test-run/execute-js-expression/index.js +4 -4
- package/lib/test-run/index.js +48 -41
- package/lib/test-run/request/create-request-options.js +9 -9
- package/lib/test-run/request/process-response-data.js +2 -2
- package/lib/test-run/request/send.js +5 -5
- package/lib/testcafe.js +8 -4
- package/lib/utils/check-file-path.js +2 -2
- package/lib/utils/check-url.js +2 -2
- package/lib/utils/correct-file-path.js +4 -4
- package/lib/utils/delegated-api.js +1 -1
- package/lib/utils/detect-ffmpeg.js +3 -3
- package/lib/utils/diff/colors.js +2 -2
- package/lib/utils/diff/index.js +11 -7
- package/lib/utils/diff/util.js +5 -5
- package/lib/utils/diff.js +4 -4
- package/lib/utils/escape-user-agent.js +2 -2
- package/lib/utils/execute-fn-with-timeout.js +2 -2
- package/lib/utils/get-browser.js +2 -2
- package/lib/utils/get-filter-fn.js +4 -4
- package/lib/utils/get-options/base.js +2 -2
- package/lib/utils/get-options/compiler.js +2 -2
- package/lib/utils/get-options/dashboard.js +2 -2
- package/lib/utils/get-options/get-assertion-timeout.js +1 -1
- package/lib/utils/get-options/index.js +4 -2
- package/lib/utils/get-options/meta.js +2 -2
- package/lib/utils/get-options/quarantine.js +8 -6
- package/lib/utils/get-options/screenshot.js +2 -2
- package/lib/utils/get-options/skip-js-errors.js +35 -0
- package/lib/utils/get-options/ssl.js +6 -6
- package/lib/utils/get-options/video.js +2 -2
- package/lib/utils/is-password-input.js +1 -1
- package/lib/utils/log-entry.js +2 -2
- package/lib/utils/make-reg-exp.js +19 -6
- package/lib/utils/moment-loader.js +2 -2
- package/lib/utils/parse-file-list.js +7 -7
- package/lib/utils/path-pattern.js +4 -4
- package/lib/utils/prepare-reporters.js +2 -2
- package/lib/utils/prerender-callsite.js +6 -6
- package/lib/utils/process.js +7 -7
- package/lib/utils/promisified-functions.js +14 -14
- package/lib/utils/raw-command-callsite-record.js +2 -2
- package/lib/utils/resolve-path-relatively-cwd.js +2 -2
- package/lib/utils/string.js +3 -3
- package/lib/utils/temp-directory/cleanup-process/index.js +6 -6
- package/lib/utils/temp-directory/cleanup-process/worker.js +4 -4
- package/lib/utils/temp-directory/index.js +6 -6
- package/lib/utils/temp-directory/lockfile.js +2 -2
- package/lib/video-recorder/process.js +6 -6
- package/lib/video-recorder/recorder.js +9 -9
- package/lib/video-recorder/test-run-video-recorder.js +2 -2
- package/package.json +8 -7
- package/ts-defs/index.d.ts +46 -7
- package/ts-defs/selectors.d.ts +39 -0
- 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
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
function
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
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)
|
|
298
|
-
|
|
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 {
|
|
311
|
-
|
|
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)
|
|
319
|
-
|
|
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)
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
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
|
-
|
|
340
|
-
|
|
341
|
-
|
|
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(),
|
|
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)];
|