apify 2.3.1-beta.4 → 3.0.0-alpha.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.
- package/README.md +6 -5
- package/package.json +69 -128
- package/build/actor.d.ts +0 -113
- package/build/actor.d.ts.map +0 -1
- package/build/actor.js +0 -582
- package/build/actor.js.map +0 -1
- package/build/apify.d.ts +0 -752
- package/build/apify.d.ts.map +0 -1
- package/build/apify.js +0 -877
- package/build/apify.js.map +0 -1
- package/build/autoscaling/autoscaled_pool.d.ts +0 -384
- package/build/autoscaling/autoscaled_pool.d.ts.map +0 -1
- package/build/autoscaling/autoscaled_pool.js +0 -557
- package/build/autoscaling/autoscaled_pool.js.map +0 -1
- package/build/autoscaling/snapshotter.d.ts +0 -278
- package/build/autoscaling/snapshotter.d.ts.map +0 -1
- package/build/autoscaling/snapshotter.js +0 -447
- package/build/autoscaling/snapshotter.js.map +0 -1
- package/build/autoscaling/system_status.d.ts +0 -224
- package/build/autoscaling/system_status.d.ts.map +0 -1
- package/build/autoscaling/system_status.js +0 -228
- package/build/autoscaling/system_status.js.map +0 -1
- package/build/browser_launchers/browser_launcher.d.ts +0 -154
- package/build/browser_launchers/browser_launcher.d.ts.map +0 -1
- package/build/browser_launchers/browser_launcher.js +0 -160
- package/build/browser_launchers/browser_launcher.js.map +0 -1
- package/build/browser_launchers/browser_plugin.d.ts +0 -23
- package/build/browser_launchers/browser_plugin.d.ts.map +0 -1
- package/build/browser_launchers/browser_plugin.js +0 -25
- package/build/browser_launchers/browser_plugin.js.map +0 -1
- package/build/browser_launchers/playwright_launcher.d.ts +0 -131
- package/build/browser_launchers/playwright_launcher.d.ts.map +0 -1
- package/build/browser_launchers/playwright_launcher.js +0 -150
- package/build/browser_launchers/playwright_launcher.js.map +0 -1
- package/build/browser_launchers/puppeteer_launcher.d.ts +0 -153
- package/build/browser_launchers/puppeteer_launcher.d.ts.map +0 -1
- package/build/browser_launchers/puppeteer_launcher.js +0 -197
- package/build/browser_launchers/puppeteer_launcher.js.map +0 -1
- package/build/cache_container.d.ts +0 -31
- package/build/cache_container.d.ts.map +0 -1
- package/build/cache_container.js +0 -48
- package/build/cache_container.js.map +0 -1
- package/build/configuration.d.ts +0 -226
- package/build/configuration.d.ts.map +0 -1
- package/build/configuration.js +0 -325
- package/build/configuration.js.map +0 -1
- package/build/constants.d.ts +0 -37
- package/build/constants.d.ts.map +0 -1
- package/build/constants.js +0 -41
- package/build/constants.js.map +0 -1
- package/build/crawlers/basic_crawler.d.ts +0 -443
- package/build/crawlers/basic_crawler.d.ts.map +0 -1
- package/build/crawlers/basic_crawler.js +0 -664
- package/build/crawlers/basic_crawler.js.map +0 -1
- package/build/crawlers/browser_crawler.d.ts +0 -512
- package/build/crawlers/browser_crawler.d.ts.map +0 -1
- package/build/crawlers/browser_crawler.js +0 -540
- package/build/crawlers/browser_crawler.js.map +0 -1
- package/build/crawlers/cheerio_crawler.d.ts +0 -931
- package/build/crawlers/cheerio_crawler.d.ts.map +0 -1
- package/build/crawlers/cheerio_crawler.js +0 -913
- package/build/crawlers/cheerio_crawler.js.map +0 -1
- package/build/crawlers/crawler_extension.d.ts +0 -10
- package/build/crawlers/crawler_extension.d.ts.map +0 -1
- package/build/crawlers/crawler_extension.js +0 -19
- package/build/crawlers/crawler_extension.js.map +0 -1
- package/build/crawlers/crawler_utils.d.ts +0 -34
- package/build/crawlers/crawler_utils.d.ts.map +0 -1
- package/build/crawlers/crawler_utils.js +0 -87
- package/build/crawlers/crawler_utils.js.map +0 -1
- package/build/crawlers/playwright_crawler.d.ts +0 -448
- package/build/crawlers/playwright_crawler.d.ts.map +0 -1
- package/build/crawlers/playwright_crawler.js +0 -299
- package/build/crawlers/playwright_crawler.js.map +0 -1
- package/build/crawlers/puppeteer_crawler.d.ts +0 -425
- package/build/crawlers/puppeteer_crawler.d.ts.map +0 -1
- package/build/crawlers/puppeteer_crawler.js +0 -299
- package/build/crawlers/puppeteer_crawler.js.map +0 -1
- package/build/crawlers/statistics.d.ts +0 -185
- package/build/crawlers/statistics.d.ts.map +0 -1
- package/build/crawlers/statistics.js +0 -331
- package/build/crawlers/statistics.js.map +0 -1
- package/build/enqueue_links/click_elements.d.ts +0 -179
- package/build/enqueue_links/click_elements.d.ts.map +0 -1
- package/build/enqueue_links/click_elements.js +0 -434
- package/build/enqueue_links/click_elements.js.map +0 -1
- package/build/enqueue_links/enqueue_links.d.ts +0 -117
- package/build/enqueue_links/enqueue_links.d.ts.map +0 -1
- package/build/enqueue_links/enqueue_links.js +0 -163
- package/build/enqueue_links/enqueue_links.js.map +0 -1
- package/build/enqueue_links/shared.d.ts +0 -42
- package/build/enqueue_links/shared.d.ts.map +0 -1
- package/build/enqueue_links/shared.js +0 -121
- package/build/enqueue_links/shared.js.map +0 -1
- package/build/errors.d.ts +0 -29
- package/build/errors.d.ts.map +0 -1
- package/build/errors.js +0 -38
- package/build/errors.js.map +0 -1
- package/build/events.d.ts +0 -11
- package/build/events.d.ts.map +0 -1
- package/build/events.js +0 -147
- package/build/events.js.map +0 -1
- package/build/index.d.ts +0 -4
- package/build/index.d.ts.map +0 -1
- package/build/index.js +0 -7
- package/build/index.js.map +0 -1
- package/build/main.d.ts +0 -179
- package/build/main.d.ts.map +0 -1
- package/build/main.js +0 -81
- package/build/main.js.map +0 -1
- package/build/playwright_utils.d.ts +0 -9
- package/build/playwright_utils.d.ts.map +0 -1
- package/build/playwright_utils.js +0 -90
- package/build/playwright_utils.js.map +0 -1
- package/build/proxy_configuration.d.ts +0 -411
- package/build/proxy_configuration.d.ts.map +0 -1
- package/build/proxy_configuration.js +0 -517
- package/build/proxy_configuration.js.map +0 -1
- package/build/pseudo_url.d.ts +0 -86
- package/build/pseudo_url.d.ts.map +0 -1
- package/build/pseudo_url.js +0 -153
- package/build/pseudo_url.js.map +0 -1
- package/build/puppeteer_request_interception.d.ts +0 -8
- package/build/puppeteer_request_interception.d.ts.map +0 -1
- package/build/puppeteer_request_interception.js +0 -235
- package/build/puppeteer_request_interception.js.map +0 -1
- package/build/puppeteer_utils.d.ts +0 -250
- package/build/puppeteer_utils.d.ts.map +0 -1
- package/build/puppeteer_utils.js +0 -551
- package/build/puppeteer_utils.js.map +0 -1
- package/build/request.d.ts +0 -180
- package/build/request.d.ts.map +0 -1
- package/build/request.js +0 -261
- package/build/request.js.map +0 -1
- package/build/request_list.d.ts +0 -581
- package/build/request_list.d.ts.map +0 -1
- package/build/request_list.js +0 -826
- package/build/request_list.js.map +0 -1
- package/build/serialization.d.ts +0 -5
- package/build/serialization.d.ts.map +0 -1
- package/build/serialization.js +0 -139
- package/build/serialization.js.map +0 -1
- package/build/session_pool/errors.d.ts +0 -11
- package/build/session_pool/errors.d.ts.map +0 -1
- package/build/session_pool/errors.js +0 -18
- package/build/session_pool/errors.js.map +0 -1
- package/build/session_pool/events.d.ts +0 -5
- package/build/session_pool/events.d.ts.map +0 -1
- package/build/session_pool/events.js +0 -6
- package/build/session_pool/events.js.map +0 -1
- package/build/session_pool/session.d.ts +0 -286
- package/build/session_pool/session.d.ts.map +0 -1
- package/build/session_pool/session.js +0 -355
- package/build/session_pool/session.js.map +0 -1
- package/build/session_pool/session_pool.d.ts +0 -280
- package/build/session_pool/session_pool.d.ts.map +0 -1
- package/build/session_pool/session_pool.js +0 -393
- package/build/session_pool/session_pool.js.map +0 -1
- package/build/session_pool/session_utils.d.ts +0 -4
- package/build/session_pool/session_utils.d.ts.map +0 -1
- package/build/session_pool/session_utils.js +0 -24
- package/build/session_pool/session_utils.js.map +0 -1
- package/build/stealth/hiding_tricks.d.ts +0 -22
- package/build/stealth/hiding_tricks.d.ts.map +0 -1
- package/build/stealth/hiding_tricks.js +0 -308
- package/build/stealth/hiding_tricks.js.map +0 -1
- package/build/stealth/stealth.d.ts +0 -56
- package/build/stealth/stealth.d.ts.map +0 -1
- package/build/stealth/stealth.js +0 -125
- package/build/stealth/stealth.js.map +0 -1
- package/build/storages/dataset.d.ts +0 -288
- package/build/storages/dataset.d.ts.map +0 -1
- package/build/storages/dataset.js +0 -480
- package/build/storages/dataset.js.map +0 -1
- package/build/storages/key_value_store.d.ts +0 -243
- package/build/storages/key_value_store.d.ts.map +0 -1
- package/build/storages/key_value_store.js +0 -462
- package/build/storages/key_value_store.js.map +0 -1
- package/build/storages/request_queue.d.ts +0 -318
- package/build/storages/request_queue.d.ts.map +0 -1
- package/build/storages/request_queue.js +0 -636
- package/build/storages/request_queue.js.map +0 -1
- package/build/storages/storage_manager.d.ts +0 -87
- package/build/storages/storage_manager.d.ts.map +0 -1
- package/build/storages/storage_manager.js +0 -150
- package/build/storages/storage_manager.js.map +0 -1
- package/build/tsconfig.tsbuildinfo +0 -1
- package/build/typedefs.d.ts +0 -146
- package/build/typedefs.d.ts.map +0 -1
- package/build/typedefs.js +0 -88
- package/build/typedefs.js.map +0 -1
- package/build/utils.d.ts +0 -175
- package/build/utils.d.ts.map +0 -1
- package/build/utils.js +0 -731
- package/build/utils.js.map +0 -1
- package/build/utils_log.d.ts +0 -41
- package/build/utils_log.d.ts.map +0 -1
- package/build/utils_log.js +0 -192
- package/build/utils_log.js.map +0 -1
- package/build/utils_request.d.ts +0 -77
- package/build/utils_request.d.ts.map +0 -1
- package/build/utils_request.js +0 -385
- package/build/utils_request.js.map +0 -1
- package/build/utils_social.d.ts +0 -210
- package/build/utils_social.d.ts.map +0 -1
- package/build/utils_social.js +0 -787
- package/build/utils_social.js.map +0 -1
- package/build/validators.d.ts +0 -23
- package/build/validators.d.ts.map +0 -1
- package/build/validators.js +0 -29
- package/build/validators.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"system_status.d.ts","sourceRoot":"","sources":["../../src/autoscaling/system_status.js"],"names":[],"mappings":";;;;;;;;kBASc,OAAO;;;;;YAEA,MAAM;;;YAEN,MAAM;;;YACN,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAT3B;;;;;;;;;;GAUG;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH;IACI;;OAEG;IACH,uDAyBC;IANG,2BAAmD;IACnD,iCAAwD;IACxD,oCAA8D;IAC9D,8BAAkD;IAClD,iCAAwD;IACxD,yBAAmD;IAGvD;;;;;;;;;;;;;;;;OAgBG;IACH,oBAFY,UAAU,CAIrB;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,uBAFY,UAAU,CAIrB;IAED;;;;;;;;OAQG;IACH,oEALY,UAAU,CAiBrB;IAED;;;;;;;;;OASG;IACH,oDANW,MAAM,GACL,MAAM,CAQjB;IAED;;;;;;;;;OASG;IACH,uDANW,MAAM,GACL,MAAM,CAQjB;IAED;;;;;;;;;OASG;IACH,iDANW,MAAM,GACL,MAAM,CAQjB;IAED;;;;;;;;OAQG;IACH,oDANW,MAAM,GACL;QAAC,YAAY,EAAE,OAAO,CAAC;QAAC,kBAAkB,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAC,CAQnF;IAED;;;;;;;;;;OAUG;IACH,sCAPW,UAAQ,SACR,MAAM,GACL,MAAM,CAqBjB;CACJ"}
|
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const ow_1 = (0, tslib_1.__importDefault)(require("ow"));
|
|
5
|
-
const snapshotter_1 = (0, tslib_1.__importDefault)(require("./snapshotter")); // eslint-disable-line import/no-duplicates
|
|
6
|
-
const utils_1 = require("../utils");
|
|
7
|
-
// TODO yin: Add `@property clientInfo` as in `SystemStatus._isSystemIdle()`
|
|
8
|
-
/**
|
|
9
|
-
* Represents the current status of the system.
|
|
10
|
-
*
|
|
11
|
-
* @typedef SystemInfo
|
|
12
|
-
* @property {boolean} isSystemIdle
|
|
13
|
-
* If true, system is being overloaded.
|
|
14
|
-
* @property {Object<string, *>} memInfo
|
|
15
|
-
* Memory
|
|
16
|
-
* @property {Object<string, *>} eventLoopInfo
|
|
17
|
-
* @property {Object<string, *>} cpuInfo
|
|
18
|
-
*/
|
|
19
|
-
/**
|
|
20
|
-
* @typedef SystemStatusOptions
|
|
21
|
-
* @property {number} [currentHistorySecs=5]
|
|
22
|
-
* Defines max age of snapshots used in the
|
|
23
|
-
* {@link SystemStatus#getCurrentStatus} measurement.
|
|
24
|
-
* @property {number} [maxMemoryOverloadedRatio=0.2]
|
|
25
|
-
* Sets the maximum ratio of overloaded snapshots in a memory sample.
|
|
26
|
-
* If the sample exceeds this ratio, the system will be overloaded.
|
|
27
|
-
* @property {number} [maxEventLoopOverloadedRatio=0.6]
|
|
28
|
-
* Sets the maximum ratio of overloaded snapshots in an event loop sample.
|
|
29
|
-
* If the sample exceeds this ratio, the system will be overloaded.
|
|
30
|
-
* @property {number} [maxCpuOverloadedRatio=0.4]
|
|
31
|
-
* Sets the maximum ratio of overloaded snapshots in a CPU sample.
|
|
32
|
-
* If the sample exceeds this ratio, the system will be overloaded.
|
|
33
|
-
* @property {number} [maxClientOverloadedRatio=0.3]
|
|
34
|
-
* Sets the maximum ratio of overloaded snapshots in a Client sample.
|
|
35
|
-
* If the sample exceeds this ratio, the system will be overloaded.
|
|
36
|
-
* @property {Snapshotter} [snapshotter]
|
|
37
|
-
* The `Snapshotter` instance to be queried for `SystemStatus`.
|
|
38
|
-
*/
|
|
39
|
-
/**
|
|
40
|
-
* Provides a simple interface to reading system status from a {@link Snapshotter} instance.
|
|
41
|
-
* It only exposes two functions {@link SystemStatus#getCurrentStatus}
|
|
42
|
-
* and {@link SystemStatus#getHistoricalStatus}.
|
|
43
|
-
* The system status is calculated using a weighted average of overloaded
|
|
44
|
-
* messages in the snapshots, with the weights being the time intervals
|
|
45
|
-
* between the snapshots. Each resource is calculated separately
|
|
46
|
-
* and the system is overloaded whenever at least one resource is overloaded.
|
|
47
|
-
* The class is used by the {@link AutoscaledPool} class.
|
|
48
|
-
*
|
|
49
|
-
* {@link SystemStatus#getCurrentStatus}
|
|
50
|
-
* returns a boolean that represents the current status of the system.
|
|
51
|
-
* The length of the current timeframe in seconds is configurable
|
|
52
|
-
* by the `currentHistorySecs` option and represents the max age
|
|
53
|
-
* of snapshots to be considered for the calculation.
|
|
54
|
-
*
|
|
55
|
-
* {@link SystemStatus#getHistoricalStatus}
|
|
56
|
-
* returns a boolean that represents the long-term status
|
|
57
|
-
* of the system. It considers the full snapshot history available
|
|
58
|
-
* in the {@link Snapshotter} instance.
|
|
59
|
-
*/
|
|
60
|
-
class SystemStatus {
|
|
61
|
-
/**
|
|
62
|
-
* @param {SystemStatusOptions} [options] All `SystemStatus` configuration options.
|
|
63
|
-
*/
|
|
64
|
-
constructor(options = {}) {
|
|
65
|
-
(0, ow_1.default)(options, ow_1.default.object.exactShape({
|
|
66
|
-
currentHistorySecs: ow_1.default.optional.number,
|
|
67
|
-
maxMemoryOverloadedRatio: ow_1.default.optional.number,
|
|
68
|
-
maxEventLoopOverloadedRatio: ow_1.default.optional.number,
|
|
69
|
-
maxCpuOverloadedRatio: ow_1.default.optional.number,
|
|
70
|
-
maxClientOverloadedRatio: ow_1.default.optional.number,
|
|
71
|
-
snapshotter: ow_1.default.optional.object,
|
|
72
|
-
}));
|
|
73
|
-
const { currentHistorySecs = 5, maxMemoryOverloadedRatio = 0.2, maxEventLoopOverloadedRatio = 0.6, maxCpuOverloadedRatio = 0.4, maxClientOverloadedRatio = 0.3, snapshotter, } = options;
|
|
74
|
-
this.currentHistorySecs = currentHistorySecs * 1000;
|
|
75
|
-
this.maxMemoryOverloadedRatio = maxMemoryOverloadedRatio;
|
|
76
|
-
this.maxEventLoopOverloadedRatio = maxEventLoopOverloadedRatio;
|
|
77
|
-
this.maxCpuOverloadedRatio = maxCpuOverloadedRatio;
|
|
78
|
-
this.maxClientOverloadedRatio = maxClientOverloadedRatio;
|
|
79
|
-
this.snapshotter = snapshotter || new snapshotter_1.default();
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Returns an {@link SystemInfo} object with the following structure:
|
|
83
|
-
*
|
|
84
|
-
* ```javascript
|
|
85
|
-
* {
|
|
86
|
-
* isSystemIdle: Boolean,
|
|
87
|
-
* memInfo: Object,
|
|
88
|
-
* eventLoopInfo: Object,
|
|
89
|
-
* cpuInfo: Object
|
|
90
|
-
* }
|
|
91
|
-
* ```
|
|
92
|
-
*
|
|
93
|
-
* Where the `isSystemIdle` property is set to `false` if the system
|
|
94
|
-
* has been overloaded in the last `options.currentHistorySecs` seconds,
|
|
95
|
-
* and `true` otherwise.
|
|
96
|
-
* @return {SystemInfo}
|
|
97
|
-
*/
|
|
98
|
-
getCurrentStatus() {
|
|
99
|
-
return this._isSystemIdle(this.currentHistorySecs);
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Returns an {@link SystemInfo} object with the following structure:
|
|
103
|
-
*
|
|
104
|
-
* ```javascript
|
|
105
|
-
* {
|
|
106
|
-
* isSystemIdle: Boolean,
|
|
107
|
-
* memInfo: Object,
|
|
108
|
-
* eventLoopInfo: Object,
|
|
109
|
-
* cpuInfo: Object
|
|
110
|
-
* }
|
|
111
|
-
* ```
|
|
112
|
-
*
|
|
113
|
-
* Where the `isSystemIdle` property is set to `false` if the system
|
|
114
|
-
* has been overloaded in the full history of the {@link Snapshotter}
|
|
115
|
-
* (which is configurable in the {@link Snapshotter}) and `true` otherwise.
|
|
116
|
-
* @return {SystemInfo}
|
|
117
|
-
*/
|
|
118
|
-
getHistoricalStatus() {
|
|
119
|
-
return this._isSystemIdle();
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Returns a system status object.
|
|
123
|
-
*
|
|
124
|
-
* @param {number} [sampleDurationMillis]
|
|
125
|
-
* @return {SystemInfo}
|
|
126
|
-
* @ignore
|
|
127
|
-
* @protected
|
|
128
|
-
* @internal
|
|
129
|
-
*/
|
|
130
|
-
_isSystemIdle(sampleDurationMillis) {
|
|
131
|
-
const memInfo = this._isMemoryOverloaded(sampleDurationMillis);
|
|
132
|
-
const eventLoopInfo = this._isEventLoopOverloaded(sampleDurationMillis);
|
|
133
|
-
const cpuInfo = this._isCpuOverloaded(sampleDurationMillis);
|
|
134
|
-
const clientInfo = this._isClientOverloaded(sampleDurationMillis);
|
|
135
|
-
return {
|
|
136
|
-
isSystemIdle: !memInfo.isOverloaded && !eventLoopInfo.isOverloaded && !cpuInfo.isOverloaded && !clientInfo.isOverloaded,
|
|
137
|
-
memInfo,
|
|
138
|
-
eventLoopInfo,
|
|
139
|
-
cpuInfo,
|
|
140
|
-
clientInfo,
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Returns an object with an isOverloaded property set to true
|
|
145
|
-
* if the memory has been overloaded in the last sampleDurationMillis.
|
|
146
|
-
*
|
|
147
|
-
* @param {number} sampleDurationMillis
|
|
148
|
-
* @return {object}
|
|
149
|
-
* @ignore
|
|
150
|
-
* @protected
|
|
151
|
-
* @internal
|
|
152
|
-
*/
|
|
153
|
-
_isMemoryOverloaded(sampleDurationMillis) {
|
|
154
|
-
const sample = this.snapshotter.getMemorySample(sampleDurationMillis);
|
|
155
|
-
return this._isSampleOverloaded(sample, this.maxMemoryOverloadedRatio);
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Returns an object with an isOverloaded property set to true
|
|
159
|
-
* if the event loop has been overloaded in the last sampleDurationMillis.
|
|
160
|
-
*
|
|
161
|
-
* @param {number} sampleDurationMillis
|
|
162
|
-
* @return {object}
|
|
163
|
-
* @ignore
|
|
164
|
-
* @protected
|
|
165
|
-
* @internal
|
|
166
|
-
*/
|
|
167
|
-
_isEventLoopOverloaded(sampleDurationMillis) {
|
|
168
|
-
const sample = this.snapshotter.getEventLoopSample(sampleDurationMillis);
|
|
169
|
-
return this._isSampleOverloaded(sample, this.maxEventLoopOverloadedRatio);
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Returns an object with an isOverloaded property set to true
|
|
173
|
-
* if the CPU has been overloaded in the last sampleDurationMillis.
|
|
174
|
-
*
|
|
175
|
-
* @param {number} sampleDurationMillis
|
|
176
|
-
* @return {object}
|
|
177
|
-
* @ignore
|
|
178
|
-
* @protected
|
|
179
|
-
* @internal
|
|
180
|
-
*/
|
|
181
|
-
_isCpuOverloaded(sampleDurationMillis) {
|
|
182
|
-
const sample = this.snapshotter.getCpuSample(sampleDurationMillis);
|
|
183
|
-
return this._isSampleOverloaded(sample, this.maxCpuOverloadedRatio);
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* Returns an object with an isOverloaded property set to true
|
|
187
|
-
* if the client has been overloaded in the last sampleDurationMillis.
|
|
188
|
-
* @param {number} sampleDurationMillis
|
|
189
|
-
* @return {{isOverloaded: boolean, maxOverloadedRatio: number, actualRatio: number}}
|
|
190
|
-
* @ignore
|
|
191
|
-
* @protected
|
|
192
|
-
* @internal
|
|
193
|
-
*/
|
|
194
|
-
_isClientOverloaded(sampleDurationMillis) {
|
|
195
|
-
const sample = this.snapshotter.getClientSample(sampleDurationMillis);
|
|
196
|
-
return this._isSampleOverloaded(sample, this.maxClientOverloadedRatio);
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Returns an object with sample information and an isOverloaded property
|
|
200
|
-
* set to true if at least the ratio of snapshots in the sample are overloaded.
|
|
201
|
-
*
|
|
202
|
-
* @param {Array<*>} sample
|
|
203
|
-
* @param {number} ratio
|
|
204
|
-
* @return {object}
|
|
205
|
-
* @ignore
|
|
206
|
-
* @protected
|
|
207
|
-
* @internal
|
|
208
|
-
*/
|
|
209
|
-
_isSampleOverloaded(sample, ratio) {
|
|
210
|
-
const weights = [];
|
|
211
|
-
const values = [];
|
|
212
|
-
for (let i = 1; i < sample.length; i++) {
|
|
213
|
-
const previous = sample[i - 1];
|
|
214
|
-
const current = sample[i];
|
|
215
|
-
const weight = current.createdAt - previous.createdAt;
|
|
216
|
-
weights.push(weight || 1); // Prevent errors from 0ms long intervals (sync) between snapshots.
|
|
217
|
-
values.push(Number(current.isOverloaded));
|
|
218
|
-
}
|
|
219
|
-
const wAvg = (0, utils_1.weightedAvg)(values, weights);
|
|
220
|
-
return {
|
|
221
|
-
isOverloaded: wAvg > ratio,
|
|
222
|
-
limitRatio: ratio,
|
|
223
|
-
actualRatio: Math.round(wAvg * 1000) / 1000,
|
|
224
|
-
};
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
exports.default = SystemStatus;
|
|
228
|
-
//# sourceMappingURL=system_status.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"system_status.js","sourceRoot":"","sources":["../../src/autoscaling/system_status.js"],"names":[],"mappings":";;;AAAA,yDAAoB;AACpB,6EAAwC,CAAC,2CAA2C;AACpF,oCAAuC;AAEvC,4EAA4E;AAC5E;;;;;;;;;;GAUG;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,YAAY;IACd;;OAEG;IACH,YAAY,OAAO,GAAG,EAAE;QACpB,IAAA,YAAE,EAAC,OAAO,EAAE,YAAE,CAAC,MAAM,CAAC,UAAU,CAAC;YAC7B,kBAAkB,EAAE,YAAE,CAAC,QAAQ,CAAC,MAAM;YACtC,wBAAwB,EAAE,YAAE,CAAC,QAAQ,CAAC,MAAM;YAC5C,2BAA2B,EAAE,YAAE,CAAC,QAAQ,CAAC,MAAM;YAC/C,qBAAqB,EAAE,YAAE,CAAC,QAAQ,CAAC,MAAM;YACzC,wBAAwB,EAAE,YAAE,CAAC,QAAQ,CAAC,MAAM;YAC5C,WAAW,EAAE,YAAE,CAAC,QAAQ,CAAC,MAAM;SAClC,CAAC,CAAC,CAAC;QAEJ,MAAM,EACF,kBAAkB,GAAG,CAAC,EACtB,wBAAwB,GAAG,GAAG,EAC9B,2BAA2B,GAAG,GAAG,EACjC,qBAAqB,GAAG,GAAG,EAC3B,wBAAwB,GAAG,GAAG,EAC9B,WAAW,GACd,GAAG,OAAO,CAAC;QAEZ,IAAI,CAAC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AmE;YAC9F,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC;SAC7C;QACD,MAAM,IAAI,GAAG,IAAA,mBAAW,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC1C,OAAO;YACH,YAAY,EAAE,IAAI,GAAG,KAAK;YAC1B,UAAU,EAAE,KAAK;YACjB,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,IAAI;SAC9C,CAAC;IACN,CAAC;CACJ;AAED,kBAAe,YAAY,CAAC"}
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef BrowserLaunchContext
|
|
3
|
-
* @property {Object<string, *>} [launchOptions]
|
|
4
|
-
* `Options passed to the browser launcher function. Options are based on underlying library.
|
|
5
|
-
* @property {string} [proxyUrl]
|
|
6
|
-
* URL to a HTTP proxy server. It must define the port number,
|
|
7
|
-
* and it may also contain proxy username and password.
|
|
8
|
-
*
|
|
9
|
-
* Example: `http://bob:pass123@proxy.example.com:1234`.
|
|
10
|
-
* @property {boolean} [useChrome=false]
|
|
11
|
-
* If `true` and `executablePath` is not set,
|
|
12
|
-
* Playwright will launch full Google Chrome browser available on the machine
|
|
13
|
-
* rather than the bundled Chromium. The path to Chrome executable
|
|
14
|
-
* is taken from the `APIFY_CHROME_EXECUTABLE_PATH` environment variable if provided,
|
|
15
|
-
* or defaults to the typical Google Chrome executable location specific for the operating system.
|
|
16
|
-
* By default, this option is `false`.
|
|
17
|
-
* @property {boolean} [useIncognitoPages=false]
|
|
18
|
-
* With this option selected, all pages will be opened in a new incognito browser context.
|
|
19
|
-
* This means they will not share cookies nor cache and their resources will not be throttled by one another.
|
|
20
|
-
* @property {string} [userDataDir]
|
|
21
|
-
* Sets the [User Data Directory](https://chromium.googlesource.com/chromium/src/+/master/docs/user_data_dir.md) path.
|
|
22
|
-
* The user data directory contains profile data such as history, bookmarks, and cookies, as well as other per-installation local state.
|
|
23
|
-
* If not specified, a temporary directory is used instead.
|
|
24
|
-
* @property {*} [launcher]
|
|
25
|
-
// @ts-ignore optional peer dependency
|
|
26
|
-
* By default this function uses require("playwright").chromium`.
|
|
27
|
-
// @ts-ignore optional peer dependency
|
|
28
|
-
* If you want to use a different browser you can pass it by this property as `require("playwright").firefox
|
|
29
|
-
*/
|
|
30
|
-
/**
|
|
31
|
-
* Abstract class for creating browser launchers, such as `PlaywrightLauncher` and `PuppeteerLauncher`.
|
|
32
|
-
* @ignore
|
|
33
|
-
*/
|
|
34
|
-
export default class BrowserLauncher {
|
|
35
|
-
static optionsShape: {
|
|
36
|
-
proxyUrl: import("ow").StringPredicate & import("ow").BasePredicate<string | undefined>;
|
|
37
|
-
useChrome: import("ow").BooleanPredicate & import("ow").BasePredicate<boolean | undefined>;
|
|
38
|
-
useIncognitoPages: import("ow").BooleanPredicate & import("ow").BasePredicate<boolean | undefined>;
|
|
39
|
-
userDataDir: import("ow").StringPredicate & import("ow").BasePredicate<string | undefined>;
|
|
40
|
-
launchOptions: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
*
|
|
44
|
-
* @param {string} launcher
|
|
45
|
-
* @param {string} apifyImageName
|
|
46
|
-
* @returns {*}
|
|
47
|
-
*
|
|
48
|
-
*/
|
|
49
|
-
static requireLauncherOrThrow(launcher: string, apifyImageName: string): any;
|
|
50
|
-
/**
|
|
51
|
-
* @param {BrowserLaunchContext} launchContext
|
|
52
|
-
* All `BrowserLauncher` parameters are passed via an launchContext object.
|
|
53
|
-
*/
|
|
54
|
-
constructor(launchContext: BrowserLaunchContext);
|
|
55
|
-
/** @type {*} */
|
|
56
|
-
launcher: any;
|
|
57
|
-
proxyUrl: string | undefined;
|
|
58
|
-
useChrome: boolean | undefined;
|
|
59
|
-
/** @type {Object<string, *>} */
|
|
60
|
-
launchOptions: {
|
|
61
|
-
[x: string]: any;
|
|
62
|
-
};
|
|
63
|
-
otherLaunchContextProps: {
|
|
64
|
-
/**
|
|
65
|
-
* With this option selected, all pages will be opened in a new incognito browser context.
|
|
66
|
-
* This means they will not share cookies nor cache and their resources will not be throttled by one another.
|
|
67
|
-
*/
|
|
68
|
-
useIncognitoPages?: boolean | undefined;
|
|
69
|
-
/**
|
|
70
|
-
* Sets the [User Data Directory](https://chromium.googlesource.com/chromium/src/+/master/docs/user_data_dir.md) path.
|
|
71
|
-
* The user data directory contains profile data such as history, bookmarks, and cookies, as well as other per-installation local state.
|
|
72
|
-
* If not specified, a temporary directory is used instead.
|
|
73
|
-
*/
|
|
74
|
-
userDataDir?: string | undefined;
|
|
75
|
-
};
|
|
76
|
-
/** @type {BrowserPlugin} */
|
|
77
|
-
Plugin: BrowserPlugin;
|
|
78
|
-
/**
|
|
79
|
-
* @returns {BrowserPlugin}
|
|
80
|
-
* @ignore
|
|
81
|
-
*/
|
|
82
|
-
createBrowserPlugin(): BrowserPlugin;
|
|
83
|
-
/**
|
|
84
|
-
* Launches a browser instance based on the plugin.
|
|
85
|
-
* @returns {Promise<*>} Browser instance.
|
|
86
|
-
*/
|
|
87
|
-
launch(): Promise<any>;
|
|
88
|
-
/**
|
|
89
|
-
* @returns {Object<string, *>}
|
|
90
|
-
*/
|
|
91
|
-
createLaunchOptions(): {
|
|
92
|
-
[x: string]: any;
|
|
93
|
-
};
|
|
94
|
-
/**
|
|
95
|
-
* @returns {boolean}
|
|
96
|
-
* @private
|
|
97
|
-
*/
|
|
98
|
-
private _getDefaultHeadlessOption;
|
|
99
|
-
/**
|
|
100
|
-
* @returns {string}
|
|
101
|
-
* @private
|
|
102
|
-
*/
|
|
103
|
-
private _getChromeExecutablePath;
|
|
104
|
-
/**
|
|
105
|
-
*
|
|
106
|
-
* @param {string} proxyUrl
|
|
107
|
-
* @private
|
|
108
|
-
*/
|
|
109
|
-
private _validateProxyUrlProtocol;
|
|
110
|
-
}
|
|
111
|
-
export type BrowserLaunchContext = {
|
|
112
|
-
/**
|
|
113
|
-
* `Options passed to the browser launcher function. Options are based on underlying library.
|
|
114
|
-
*/
|
|
115
|
-
launchOptions?: {
|
|
116
|
-
[x: string]: any;
|
|
117
|
-
} | undefined;
|
|
118
|
-
/**
|
|
119
|
-
* URL to a HTTP proxy server. It must define the port number,
|
|
120
|
-
* and it may also contain proxy username and password.
|
|
121
|
-
*
|
|
122
|
-
* Example: `http://bob:pass123@proxy.example.com:1234`.
|
|
123
|
-
*/
|
|
124
|
-
proxyUrl?: string | undefined;
|
|
125
|
-
/**
|
|
126
|
-
* If `true` and `executablePath` is not set,
|
|
127
|
-
* Playwright will launch full Google Chrome browser available on the machine
|
|
128
|
-
* rather than the bundled Chromium. The path to Chrome executable
|
|
129
|
-
* is taken from the `APIFY_CHROME_EXECUTABLE_PATH` environment variable if provided,
|
|
130
|
-
* or defaults to the typical Google Chrome executable location specific for the operating system.
|
|
131
|
-
* By default, this option is `false`.
|
|
132
|
-
*/
|
|
133
|
-
useChrome?: boolean | undefined;
|
|
134
|
-
/**
|
|
135
|
-
* With this option selected, all pages will be opened in a new incognito browser context.
|
|
136
|
-
* This means they will not share cookies nor cache and their resources will not be throttled by one another.
|
|
137
|
-
*/
|
|
138
|
-
useIncognitoPages?: boolean | undefined;
|
|
139
|
-
/**
|
|
140
|
-
* Sets the [User Data Directory](https://chromium.googlesource.com/chromium/src/+/master/docs/user_data_dir.md) path.
|
|
141
|
-
* The user data directory contains profile data such as history, bookmarks, and cookies, as well as other per-installation local state.
|
|
142
|
-
* If not specified, a temporary directory is used instead.
|
|
143
|
-
*/
|
|
144
|
-
userDataDir?: string | undefined;
|
|
145
|
-
/**
|
|
146
|
-
// @ts-ignore optional peer dependency
|
|
147
|
-
* By default this function uses require("playwright").chromium`.
|
|
148
|
-
// @ts-ignore optional peer dependency
|
|
149
|
-
* If you want to use a different browser you can pass it by this property as `require("playwright").firefox
|
|
150
|
-
*/
|
|
151
|
-
launcher?: any;
|
|
152
|
-
};
|
|
153
|
-
import { BrowserPlugin } from "./browser_plugin";
|
|
154
|
-
//# sourceMappingURL=browser_launcher.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"browser_launcher.d.ts","sourceRoot":"","sources":["../../src/browser_launchers/browser_launcher.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;;;GAGG;AACH;IACI;;;;;;MAME;IAEF;;;;;;OAMG;IACH,wCALW,MAAM,kBACN,MAAM,OAkBhB;IAED;;;MAGE;IACF,2BAHU,oBAAoB,EAyB7B;IAVG,gBAAgB;IAChB,cAAwB;IACxB,6BAAwB;IACxB,+BAA0B;IAC1B,gCAAgC;IAChC;YADkB,MAAM;MACU;IAClC;;;;;;;;;;;;MAAsD;IAEtD,4BAA4B;IAC5B,QADW,aAAa,CACN;IAGtB;;;OAGG;IACH,uBAHa,aAAa,CAYzB;IAED;;;OAGG;IACH,UAFa,YAAU,CAMtB;IAED;;OAEG;IACH;YAFoB,MAAM;MAgBzB;IAED;;;OAGG;IACH,kCAEC;IAED;;;MAGE;IACF,iCAEC;IAED;;;;OAIG;IACH,kCAcC;CACJ"}
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const ow_1 = (0, tslib_1.__importDefault)(require("ow"));
|
|
5
|
-
const consts_1 = require("@apify/consts");
|
|
6
|
-
const utils_1 = require("../utils");
|
|
7
|
-
/**
|
|
8
|
-
* @typedef BrowserLaunchContext
|
|
9
|
-
* @property {Object<string, *>} [launchOptions]
|
|
10
|
-
* `Options passed to the browser launcher function. Options are based on underlying library.
|
|
11
|
-
* @property {string} [proxyUrl]
|
|
12
|
-
* URL to a HTTP proxy server. It must define the port number,
|
|
13
|
-
* and it may also contain proxy username and password.
|
|
14
|
-
*
|
|
15
|
-
* Example: `http://bob:pass123@proxy.example.com:1234`.
|
|
16
|
-
* @property {boolean} [useChrome=false]
|
|
17
|
-
* If `true` and `executablePath` is not set,
|
|
18
|
-
* Playwright will launch full Google Chrome browser available on the machine
|
|
19
|
-
* rather than the bundled Chromium. The path to Chrome executable
|
|
20
|
-
* is taken from the `APIFY_CHROME_EXECUTABLE_PATH` environment variable if provided,
|
|
21
|
-
* or defaults to the typical Google Chrome executable location specific for the operating system.
|
|
22
|
-
* By default, this option is `false`.
|
|
23
|
-
* @property {boolean} [useIncognitoPages=false]
|
|
24
|
-
* With this option selected, all pages will be opened in a new incognito browser context.
|
|
25
|
-
* This means they will not share cookies nor cache and their resources will not be throttled by one another.
|
|
26
|
-
* @property {string} [userDataDir]
|
|
27
|
-
* Sets the [User Data Directory](https://chromium.googlesource.com/chromium/src/+/master/docs/user_data_dir.md) path.
|
|
28
|
-
* The user data directory contains profile data such as history, bookmarks, and cookies, as well as other per-installation local state.
|
|
29
|
-
* If not specified, a temporary directory is used instead.
|
|
30
|
-
* @property {*} [launcher]
|
|
31
|
-
* By default this function uses require("playwright").chromium`.
|
|
32
|
-
* If you want to use a different browser you can pass it by this property as `require("playwright").firefox
|
|
33
|
-
*/
|
|
34
|
-
/**
|
|
35
|
-
* Abstract class for creating browser launchers, such as `PlaywrightLauncher` and `PuppeteerLauncher`.
|
|
36
|
-
* @ignore
|
|
37
|
-
*/
|
|
38
|
-
class BrowserLauncher {
|
|
39
|
-
/**
|
|
40
|
-
* @param {BrowserLaunchContext} launchContext
|
|
41
|
-
* All `BrowserLauncher` parameters are passed via an launchContext object.
|
|
42
|
-
*/
|
|
43
|
-
constructor(launchContext) {
|
|
44
|
-
const { launcher, proxyUrl, useChrome, launchOptions = {}, ...otherLaunchContextProps } = launchContext;
|
|
45
|
-
this._validateProxyUrlProtocol(proxyUrl);
|
|
46
|
-
// those need to be reassigned otherwise they are {} in types
|
|
47
|
-
/** @type {*} */
|
|
48
|
-
this.launcher = launcher;
|
|
49
|
-
this.proxyUrl = proxyUrl;
|
|
50
|
-
this.useChrome = useChrome;
|
|
51
|
-
/** @type {Object<string, *>} */
|
|
52
|
-
this.launchOptions = launchOptions;
|
|
53
|
-
this.otherLaunchContextProps = otherLaunchContextProps;
|
|
54
|
-
/** @type {BrowserPlugin} */
|
|
55
|
-
this.Plugin = null; // to be provided by child classes;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
*
|
|
59
|
-
* @param {string} launcher
|
|
60
|
-
* @param {string} apifyImageName
|
|
61
|
-
* @returns {*}
|
|
62
|
-
*
|
|
63
|
-
*/
|
|
64
|
-
static requireLauncherOrThrow(launcher, apifyImageName) {
|
|
65
|
-
try {
|
|
66
|
-
return require(launcher); // eslint-disable-line
|
|
67
|
-
}
|
|
68
|
-
catch (err) {
|
|
69
|
-
if (err.code === 'MODULE_NOT_FOUND') {
|
|
70
|
-
const msg = `Cannot find module '${launcher}'. Did you you install the '${launcher}' package?\n`
|
|
71
|
-
+ `Make sure you have '${launcher}' in your package.json dependencies and in your package-lock.json, if you use it.`;
|
|
72
|
-
err.message = (0, utils_1.isAtHome)()
|
|
73
|
-
? `${msg}\nOn the Apify platform, '${launcher}' can only be used with the ${apifyImageName} Docker image.`
|
|
74
|
-
: msg;
|
|
75
|
-
}
|
|
76
|
-
throw err;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* @returns {BrowserPlugin}
|
|
81
|
-
* @ignore
|
|
82
|
-
*/
|
|
83
|
-
createBrowserPlugin() {
|
|
84
|
-
return new this.Plugin(this.launcher, {
|
|
85
|
-
proxyUrl: this.proxyUrl,
|
|
86
|
-
launchOptions: this.createLaunchOptions(),
|
|
87
|
-
...this.otherLaunchContextProps,
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Launches a browser instance based on the plugin.
|
|
92
|
-
* @returns {Promise<*>} Browser instance.
|
|
93
|
-
*/
|
|
94
|
-
async launch() {
|
|
95
|
-
const plugin = this.createBrowserPlugin();
|
|
96
|
-
const context = await plugin.createLaunchContext();
|
|
97
|
-
return plugin.launch(context);
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* @returns {Object<string, *>}
|
|
101
|
-
*/
|
|
102
|
-
createLaunchOptions() {
|
|
103
|
-
const launchOptions = {
|
|
104
|
-
...this.launchOptions,
|
|
105
|
-
};
|
|
106
|
-
if (launchOptions.headless == null) {
|
|
107
|
-
launchOptions.headless = this._getDefaultHeadlessOption();
|
|
108
|
-
}
|
|
109
|
-
if (this.useChrome && !launchOptions.executablePath) {
|
|
110
|
-
launchOptions.executablePath = this._getChromeExecutablePath();
|
|
111
|
-
}
|
|
112
|
-
return launchOptions;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* @returns {boolean}
|
|
116
|
-
* @private
|
|
117
|
-
*/
|
|
118
|
-
_getDefaultHeadlessOption() {
|
|
119
|
-
return process.env[consts_1.ENV_VARS.HEADLESS] === '1' && process.env[consts_1.ENV_VARS.XVFB] !== '1';
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* @returns {string}
|
|
123
|
-
* @private
|
|
124
|
-
*/
|
|
125
|
-
_getChromeExecutablePath() {
|
|
126
|
-
return process.env[consts_1.ENV_VARS.CHROME_EXECUTABLE_PATH] || (0, utils_1.getTypicalChromeExecutablePath)();
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
*
|
|
130
|
-
* @param {string} proxyUrl
|
|
131
|
-
* @private
|
|
132
|
-
*/
|
|
133
|
-
_validateProxyUrlProtocol(proxyUrl) {
|
|
134
|
-
if (!proxyUrl)
|
|
135
|
-
return;
|
|
136
|
-
if (!/^(http|https|socks4|socks5)/i.test(proxyUrl)) {
|
|
137
|
-
throw new Error(`Invalid "proxyUrl". Unsupported protocol: ${proxyUrl}.`);
|
|
138
|
-
}
|
|
139
|
-
const url = new URL(proxyUrl);
|
|
140
|
-
if (url.username || url.password) {
|
|
141
|
-
if (url.protocol !== 'http:' && url.protocol !== 'https:') {
|
|
142
|
-
throw new Error('Invalid "proxyUrl" option: authentication is only supported for HTTP proxy type.');
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
exports.default = BrowserLauncher;
|
|
148
|
-
Object.defineProperty(BrowserLauncher, "optionsShape", {
|
|
149
|
-
enumerable: true,
|
|
150
|
-
configurable: true,
|
|
151
|
-
writable: true,
|
|
152
|
-
value: {
|
|
153
|
-
proxyUrl: ow_1.default.optional.string.url,
|
|
154
|
-
useChrome: ow_1.default.optional.boolean,
|
|
155
|
-
useIncognitoPages: ow_1.default.optional.boolean,
|
|
156
|
-
userDataDir: ow_1.default.optional.string,
|
|
157
|
-
launchOptions: ow_1.default.optional.object,
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
//# sourceMappingURL=browser_launcher.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"browser_launcher.js","sourceRoot":"","sources":["../../src/browser_launchers/browser_launcher.js"],"names":[],"mappings":";;;AAAA,yDAAoB;AACpB,0CAAyC;AACzC,oCAAoE;AAGpE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;;;GAGG;AACH,MAAqB,eAAe;IAgChC;;;MAGE;IACF,YAAY,aAAa;QACrB,MAAM,EACF,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,aAAa,GAAG,EAAE,EAClB,GAAG,uBAAuB,EAC7B,GAAG,aAAa,CAAC;QAElB,IAAI,CAAC,yBAAyB,CAAC,QAAQ,CAAC,CAAC;QAEzC,6DAA6D;QAC7D,gBAAgB;QAChB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,gCAAgC;QAChC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,uBAAuB,GAAG,uBAAuB,CAAC;QA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;QACtC,WAAW,EAAE,YAAE,CAAC,QAAQ,CAAC,MAAM;QAC/B,aAAa,EAAE,YAAE,CAAC,QAAQ,CAAC,MAAM;KACpC;GAAC"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export class BrowserPlugin {
|
|
2
|
-
/**
|
|
3
|
-
* @param {*} launcher
|
|
4
|
-
* @param {Object<string, *>} context
|
|
5
|
-
*/
|
|
6
|
-
constructor(launcher: any, context: {
|
|
7
|
-
[x: string]: any;
|
|
8
|
-
});
|
|
9
|
-
launcher: any;
|
|
10
|
-
context: {
|
|
11
|
-
[x: string]: any;
|
|
12
|
-
};
|
|
13
|
-
/** @return {Promise<*>} */
|
|
14
|
-
createLaunchContext(): Promise<any>;
|
|
15
|
-
/**
|
|
16
|
-
* @param {Object<string, *>} context
|
|
17
|
-
* @return {Promise<*>}
|
|
18
|
-
*/
|
|
19
|
-
launch(context: {
|
|
20
|
-
[x: string]: any;
|
|
21
|
-
}): Promise<any>;
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=browser_plugin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"browser_plugin.d.ts","sourceRoot":"","sources":["../../src/browser_launchers/browser_plugin.js"],"names":[],"mappings":"AACA;IACI;;;OAGG;IACH;YAFkB,MAAM;OAKvB;IAFG,cAAwB;IACxB;;MAAsB;IAG1B,2BAA2B;IAE3B,uBAFa,YAAU,CAEQ;IAE/B;;;OAGG;IAEH;YAJkB,MAAM;QACZ,YAAU,CAGG;CAC5B"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BrowserPlugin = void 0;
|
|
4
|
-
// empty class to be properly typed
|
|
5
|
-
class BrowserPlugin {
|
|
6
|
-
/**
|
|
7
|
-
* @param {*} launcher
|
|
8
|
-
* @param {Object<string, *>} context
|
|
9
|
-
*/
|
|
10
|
-
constructor(launcher, context) {
|
|
11
|
-
this.launcher = launcher;
|
|
12
|
-
this.context = context;
|
|
13
|
-
}
|
|
14
|
-
/** @return {Promise<*>} */
|
|
15
|
-
// eslint-disable-next-line no-empty-function
|
|
16
|
-
async createLaunchContext() { }
|
|
17
|
-
/**
|
|
18
|
-
* @param {Object<string, *>} context
|
|
19
|
-
* @return {Promise<*>}
|
|
20
|
-
*/
|
|
21
|
-
// eslint-disable-next-line no-empty-function,no-unused-vars
|
|
22
|
-
async launch(context) { }
|
|
23
|
-
}
|
|
24
|
-
exports.BrowserPlugin = BrowserPlugin;
|
|
25
|
-
//# sourceMappingURL=browser_plugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"browser_plugin.js","sourceRoot":"","sources":["../../src/browser_launchers/browser_plugin.js"],"names":[],"mappings":";;;AAAA,mCAAmC;AACnC,MAAa,aAAa;IACtB;;;OAGG;IACH,YAAY,QAAQ,EAAE,OAAO;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IAED,2BAA2B;IAC3B,6CAA6C;IAC7C,KAAK,CAAC,mBAAmB,KAAK,CAAC;IAE/B;;;OAGG;IACH,4DAA4D;IAC5D,KAAK,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC;CAC5B;AApBD,sCAoBC"}
|