web-ext 6.8.0 → 7.0.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 +17 -8
- package/bin/web-ext.js +13 -0
- package/index.js +12 -0
- package/lib/cmd/build.js +226 -0
- package/lib/cmd/build.js.map +1 -0
- package/lib/cmd/docs.js +16 -0
- package/lib/cmd/docs.js.map +1 -0
- package/lib/cmd/index.js +47 -0
- package/lib/cmd/index.js.map +1 -0
- package/lib/cmd/lint.js +50 -0
- package/lib/cmd/lint.js.map +1 -0
- package/lib/cmd/run.js +191 -0
- package/lib/cmd/run.js.map +1 -0
- package/lib/cmd/sign.js +140 -0
- package/lib/cmd/sign.js.map +1 -0
- package/lib/config.js +144 -0
- package/lib/config.js.map +1 -0
- package/{src → lib}/errors.js +26 -35
- package/lib/errors.js.map +1 -0
- package/lib/extension-runners/base.js +2 -0
- package/lib/extension-runners/base.js.map +1 -0
- package/{src → lib}/extension-runners/chromium.js +121 -178
- package/lib/extension-runners/chromium.js.map +1 -0
- package/{src → lib}/extension-runners/firefox-android.js +168 -326
- package/lib/extension-runners/firefox-android.js.map +1 -0
- package/{src → lib}/extension-runners/firefox-desktop.js +73 -114
- package/lib/extension-runners/firefox-desktop.js.map +1 -0
- package/lib/extension-runners/index.js +311 -0
- package/lib/extension-runners/index.js.map +1 -0
- package/lib/firefox/index.js +362 -0
- package/lib/firefox/index.js.map +1 -0
- package/lib/firefox/package-identifiers.js +5 -0
- package/lib/firefox/package-identifiers.js.map +1 -0
- package/{src → lib}/firefox/preferences.js +27 -70
- package/lib/firefox/preferences.js.map +1 -0
- package/{src → lib}/firefox/rdp-client.js +98 -105
- package/lib/firefox/rdp-client.js.map +1 -0
- package/{src → lib}/firefox/remote.js +55 -129
- package/lib/firefox/remote.js.map +1 -0
- package/lib/main.js +9 -0
- package/lib/main.js.map +1 -0
- package/lib/program.js +657 -0
- package/lib/program.js.map +1 -0
- package/lib/util/adb.js +322 -0
- package/lib/util/adb.js.map +1 -0
- package/lib/util/artifacts.js +52 -0
- package/lib/util/artifacts.js.map +1 -0
- package/lib/util/desktop-notifier.js +27 -0
- package/lib/util/desktop-notifier.js.map +1 -0
- package/{src → lib}/util/file-exists.js +7 -14
- package/lib/util/file-exists.js.map +1 -0
- package/{src → lib}/util/file-filter.js +31 -59
- package/lib/util/file-filter.js.map +1 -0
- package/lib/util/is-directory.js +20 -0
- package/lib/util/is-directory.js.map +1 -0
- package/lib/util/logger.js +79 -0
- package/lib/util/logger.js.map +1 -0
- package/{src → lib}/util/manifest.js +18 -50
- package/lib/util/manifest.js.map +1 -0
- package/{src → lib}/util/promisify.js +6 -9
- package/lib/util/promisify.js.map +1 -0
- package/{src → lib}/util/stdin.js +3 -7
- package/lib/util/stdin.js.map +1 -0
- package/{src → lib}/util/temp-dir.js +47 -52
- package/lib/util/temp-dir.js.map +1 -0
- package/lib/util/updates.js +16 -0
- package/lib/util/updates.js.map +1 -0
- package/lib/watcher.js +78 -0
- package/lib/watcher.js.map +1 -0
- package/package.json +50 -52
- package/CODE_OF_CONDUCT.md +0 -10
- package/bin/web-ext +0 -7
- package/dist/web-ext.js +0 -2
- package/index.mjs +0 -13
- package/src/cmd/build.js +0 -319
- package/src/cmd/docs.js +0 -33
- package/src/cmd/index.js +0 -57
- package/src/cmd/lint.js +0 -102
- package/src/cmd/run.js +0 -266
- package/src/cmd/sign.js +0 -198
- package/src/config.js +0 -187
- package/src/extension-runners/base.js +0 -40
- package/src/extension-runners/index.js +0 -381
- package/src/firefox/index.js +0 -541
- package/src/firefox/package-identifiers.js +0 -14
- package/src/main.js +0 -19
- package/src/program.js +0 -765
- package/src/util/adb.js +0 -433
- package/src/util/artifacts.js +0 -69
- package/src/util/desktop-notifier.js +0 -41
- package/src/util/is-directory.js +0 -23
- package/src/util/logger.js +0 -131
- package/src/util/updates.js +0 -21
- package/src/watcher.js +0 -115
|
@@ -1,75 +1,35 @@
|
|
|
1
|
-
/* @flow */
|
|
2
1
|
import net from 'net';
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import {createLogger} from '../util/logger';
|
|
8
|
-
import {
|
|
9
|
-
isErrorWithCode,
|
|
10
|
-
RemoteTempInstallNotSupported,
|
|
11
|
-
UsageError,
|
|
12
|
-
WebExtError,
|
|
13
|
-
} from '../errors';
|
|
14
|
-
|
|
15
|
-
const log = createLogger(__filename);
|
|
16
|
-
|
|
17
|
-
export type FirefoxConnectorFn =
|
|
18
|
-
(port: number) => Promise<FirefoxRDPClient>;
|
|
19
|
-
|
|
20
|
-
export type FirefoxRDPAddonActor = {|
|
|
21
|
-
id: string,
|
|
22
|
-
actor: string,
|
|
23
|
-
|};
|
|
24
|
-
|
|
25
|
-
export type FirefoxRDPResponseError = {|
|
|
26
|
-
error: string,
|
|
27
|
-
message: string,
|
|
28
|
-
|};
|
|
29
|
-
|
|
30
|
-
export type FirefoxRDPResponseAddon = {|
|
|
31
|
-
addon: FirefoxRDPAddonActor,
|
|
32
|
-
|};
|
|
33
|
-
|
|
34
|
-
export type FirefoxRDPResponseRequestTypes = {|
|
|
35
|
-
requestTypes: Array<string>,
|
|
36
|
-
|};
|
|
37
|
-
|
|
38
|
-
// NOTE: this type aliases Object to catch any other possible response.
|
|
39
|
-
export type FirefoxRDPResponseAny = Object;
|
|
40
|
-
|
|
41
|
-
export type FirefoxRDPResponseMaybe =
|
|
42
|
-
FirefoxRDPResponseRequestTypes | FirefoxRDPResponseAny;
|
|
2
|
+
import FirefoxRDPClient, { connectToFirefox as defaultFirefoxConnector } from './rdp-client.js';
|
|
3
|
+
import { createLogger } from '../util/logger.js';
|
|
4
|
+
import { isErrorWithCode, RemoteTempInstallNotSupported, UsageError, WebExtError } from '../errors.js';
|
|
5
|
+
const log = createLogger(import.meta.url);
|
|
43
6
|
|
|
44
7
|
// Convert a request rejection to a message string.
|
|
45
|
-
function requestErrorToMessage(err
|
|
8
|
+
function requestErrorToMessage(err) {
|
|
46
9
|
if (err instanceof Error) {
|
|
47
10
|
return String(err);
|
|
48
11
|
}
|
|
12
|
+
|
|
49
13
|
return `${err.error}: ${err.message}`;
|
|
50
14
|
}
|
|
51
15
|
|
|
52
16
|
export class RemoteFirefox {
|
|
53
|
-
client
|
|
54
|
-
checkedForAddonReloading: boolean;
|
|
55
|
-
|
|
56
|
-
constructor(client: FirefoxRDPClient) {
|
|
17
|
+
constructor(client) {
|
|
57
18
|
this.client = client;
|
|
58
19
|
this.checkedForAddonReloading = false;
|
|
59
|
-
|
|
60
20
|
client.on('disconnect', () => {
|
|
61
21
|
log.debug('Received "disconnect" from Firefox client');
|
|
62
22
|
});
|
|
63
23
|
client.on('end', () => {
|
|
64
24
|
log.debug('Received "end" from Firefox client');
|
|
65
25
|
});
|
|
66
|
-
client.on('unsolicited-event',
|
|
26
|
+
client.on('unsolicited-event', info => {
|
|
67
27
|
log.debug(`Received message from client: ${JSON.stringify(info)}`);
|
|
68
28
|
});
|
|
69
|
-
client.on('rdp-error',
|
|
29
|
+
client.on('rdp-error', rdpError => {
|
|
70
30
|
log.debug(`Received error from client: ${JSON.stringify(rdpError)}`);
|
|
71
31
|
});
|
|
72
|
-
client.on('error',
|
|
32
|
+
client.on('error', error => {
|
|
73
33
|
log.debug(`Received error from client: ${String(error)}`);
|
|
74
34
|
});
|
|
75
35
|
}
|
|
@@ -78,32 +38,29 @@ export class RemoteFirefox {
|
|
|
78
38
|
this.client.disconnect();
|
|
79
39
|
}
|
|
80
40
|
|
|
81
|
-
async addonRequest(
|
|
82
|
-
addon: FirefoxRDPAddonActor,
|
|
83
|
-
request: string
|
|
84
|
-
): Promise<FirefoxRDPResponseMaybe> {
|
|
41
|
+
async addonRequest(addon, request) {
|
|
85
42
|
try {
|
|
86
43
|
const response = await this.client.request({
|
|
87
|
-
to: addon.actor,
|
|
44
|
+
to: addon.actor,
|
|
45
|
+
type: request
|
|
88
46
|
});
|
|
89
47
|
return response;
|
|
90
48
|
} catch (err) {
|
|
91
|
-
log.debug(
|
|
92
|
-
`Client responded to '${request}' request with error:`, err);
|
|
49
|
+
log.debug(`Client responded to '${request}' request with error:`, err);
|
|
93
50
|
const message = requestErrorToMessage(err);
|
|
94
51
|
throw new WebExtError(`Remote Firefox: addonRequest() error: ${message}`);
|
|
95
52
|
}
|
|
96
53
|
}
|
|
97
54
|
|
|
98
|
-
async getAddonsActor()
|
|
55
|
+
async getAddonsActor() {
|
|
99
56
|
try {
|
|
100
57
|
// getRoot should work since Firefox 55 (bug 1352157).
|
|
101
58
|
const response = await this.client.request('getRoot');
|
|
59
|
+
|
|
102
60
|
if (response.addonsActor == null) {
|
|
103
|
-
return Promise.reject(new RemoteTempInstallNotSupported(
|
|
104
|
-
'This version of Firefox does not provide an add-ons actor for ' +
|
|
105
|
-
'remote installation.'));
|
|
61
|
+
return Promise.reject(new RemoteTempInstallNotSupported('This version of Firefox does not provide an add-ons actor for ' + 'remote installation.'));
|
|
106
62
|
}
|
|
63
|
+
|
|
107
64
|
return response.addonsActor;
|
|
108
65
|
} catch (err) {
|
|
109
66
|
// Fallback to listTabs otherwise, Firefox 49 - 77 (bug 1618691).
|
|
@@ -111,17 +68,13 @@ export class RemoteFirefox {
|
|
|
111
68
|
}
|
|
112
69
|
|
|
113
70
|
try {
|
|
114
|
-
const response = await this.client.request('listTabs');
|
|
115
|
-
|
|
71
|
+
const response = await this.client.request('listTabs'); // addonsActor was added to listTabs in Firefox 49 (bug 1273183).
|
|
72
|
+
|
|
116
73
|
if (response.addonsActor == null) {
|
|
117
|
-
log.debug(
|
|
118
|
-
|
|
119
|
-
`${JSON.stringify(response)}`);
|
|
120
|
-
return Promise.reject(new RemoteTempInstallNotSupported(
|
|
121
|
-
'This is an older version of Firefox that does not provide an ' +
|
|
122
|
-
'add-ons actor for remote installation. Try Firefox 49 or ' +
|
|
123
|
-
'higher.'));
|
|
74
|
+
log.debug('listTabs returned a falsey addonsActor: ' + `${JSON.stringify(response)}`);
|
|
75
|
+
return Promise.reject(new RemoteTempInstallNotSupported('This is an older version of Firefox that does not provide an ' + 'add-ons actor for remote installation. Try Firefox 49 or ' + 'higher.'));
|
|
124
76
|
}
|
|
77
|
+
|
|
125
78
|
return response.addonsActor;
|
|
126
79
|
} catch (err) {
|
|
127
80
|
log.debug('listTabs error', err);
|
|
@@ -130,16 +83,14 @@ export class RemoteFirefox {
|
|
|
130
83
|
}
|
|
131
84
|
}
|
|
132
85
|
|
|
133
|
-
async installTemporaryAddon(
|
|
134
|
-
addonPath: string
|
|
135
|
-
): Promise<FirefoxRDPResponseAddon> {
|
|
86
|
+
async installTemporaryAddon(addonPath) {
|
|
136
87
|
const addonsActor = await this.getAddonsActor();
|
|
137
88
|
|
|
138
89
|
try {
|
|
139
90
|
const response = await this.client.request({
|
|
140
91
|
to: addonsActor,
|
|
141
92
|
type: 'installTemporaryAddon',
|
|
142
|
-
addonPath
|
|
93
|
+
addonPath
|
|
143
94
|
});
|
|
144
95
|
log.debug(`installTemporaryAddon: ${JSON.stringify(response)}`);
|
|
145
96
|
log.info(`Installed ${addonPath} as a temporary add-on`);
|
|
@@ -150,27 +101,25 @@ export class RemoteFirefox {
|
|
|
150
101
|
}
|
|
151
102
|
}
|
|
152
103
|
|
|
153
|
-
async getInstalledAddon(addonId
|
|
104
|
+
async getInstalledAddon(addonId) {
|
|
154
105
|
try {
|
|
155
106
|
const response = await this.client.request('listAddons');
|
|
107
|
+
|
|
156
108
|
for (const addon of response.addons) {
|
|
157
109
|
if (addon.id === addonId) {
|
|
158
110
|
return addon;
|
|
159
111
|
}
|
|
160
112
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
return Promise.reject(new WebExtError(
|
|
164
|
-
'The remote Firefox does not have your extension installed'));
|
|
113
|
+
|
|
114
|
+
log.debug(`Remote Firefox has these addons: ${response.addons.map(a => a.id)}`);
|
|
115
|
+
return Promise.reject(new WebExtError('The remote Firefox does not have your extension installed'));
|
|
165
116
|
} catch (err) {
|
|
166
117
|
const message = requestErrorToMessage(err);
|
|
167
118
|
throw new WebExtError(`Remote Firefox: listAddons() error: ${message}`);
|
|
168
119
|
}
|
|
169
120
|
}
|
|
170
121
|
|
|
171
|
-
async checkForAddonReloading(
|
|
172
|
-
addon: FirefoxRDPAddonActor
|
|
173
|
-
): Promise<FirefoxRDPAddonActor> {
|
|
122
|
+
async checkForAddonReloading(addon) {
|
|
174
123
|
if (this.checkedForAddonReloading) {
|
|
175
124
|
// We only need to check once if reload() is supported.
|
|
176
125
|
return addon;
|
|
@@ -179,11 +128,8 @@ export class RemoteFirefox {
|
|
|
179
128
|
|
|
180
129
|
if (response.requestTypes.indexOf('reload') === -1) {
|
|
181
130
|
const supportedRequestTypes = JSON.stringify(response.requestTypes);
|
|
182
|
-
log.debug(
|
|
183
|
-
|
|
184
|
-
throw new UsageError(
|
|
185
|
-
'This Firefox version does not support add-on reloading. ' +
|
|
186
|
-
'Re-run with --no-reload');
|
|
131
|
+
log.debug(`Remote Firefox only supports: ${supportedRequestTypes}`);
|
|
132
|
+
throw new UsageError('This Firefox version does not support add-on reloading. ' + 'Re-run with --no-reload');
|
|
187
133
|
} else {
|
|
188
134
|
this.checkedForAddonReloading = true;
|
|
189
135
|
return addon;
|
|
@@ -191,51 +137,33 @@ export class RemoteFirefox {
|
|
|
191
137
|
}
|
|
192
138
|
}
|
|
193
139
|
|
|
194
|
-
async reloadAddon(addonId
|
|
140
|
+
async reloadAddon(addonId) {
|
|
195
141
|
const addon = await this.getInstalledAddon(addonId);
|
|
196
142
|
await this.checkForAddonReloading(addon);
|
|
197
143
|
await this.addonRequest(addon, 'reload');
|
|
198
|
-
process.stdout.write(
|
|
199
|
-
`\rLast extension reload: ${(new Date()).toTimeString()}`);
|
|
144
|
+
process.stdout.write(`\rLast extension reload: ${new Date().toTimeString()}`);
|
|
200
145
|
log.debug('\n');
|
|
201
146
|
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
// Connect types and implementation
|
|
206
147
|
|
|
207
|
-
|
|
208
|
-
connectToFirefox: FirefoxConnectorFn,
|
|
209
|
-
|};
|
|
148
|
+
} // Connect types and implementation
|
|
210
149
|
|
|
211
|
-
export async function connect(
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
): Promise<RemoteFirefox> {
|
|
150
|
+
export async function connect(port, {
|
|
151
|
+
connectToFirefox = defaultFirefoxConnector
|
|
152
|
+
} = {}) {
|
|
215
153
|
log.debug(`Connecting to Firefox on port ${port}`);
|
|
216
154
|
const client = await connectToFirefox(port);
|
|
217
155
|
log.debug(`Connected to the remote Firefox debugger on port ${port}`);
|
|
218
156
|
return new RemoteFirefox(client);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
export type ConnectWithMaxRetriesDeps = {|
|
|
231
|
-
connectToFirefox: typeof connect,
|
|
232
|
-
|};
|
|
233
|
-
|
|
234
|
-
export async function connectWithMaxRetries(
|
|
235
|
-
// A max of 250 will try connecting for 30 seconds.
|
|
236
|
-
{maxRetries = 250, retryInterval = 120, port}: ConnectWithMaxRetriesParams,
|
|
237
|
-
{connectToFirefox = connect}: ConnectWithMaxRetriesDeps = {}
|
|
238
|
-
): Promise<RemoteFirefox> {
|
|
157
|
+
} // ConnectWithMaxRetries types and implementation
|
|
158
|
+
|
|
159
|
+
export async function connectWithMaxRetries( // A max of 250 will try connecting for 30 seconds.
|
|
160
|
+
{
|
|
161
|
+
maxRetries = 250,
|
|
162
|
+
retryInterval = 120,
|
|
163
|
+
port
|
|
164
|
+
}, {
|
|
165
|
+
connectToFirefox = connect
|
|
166
|
+
} = {}) {
|
|
239
167
|
async function establishConnection() {
|
|
240
168
|
var lastError;
|
|
241
169
|
|
|
@@ -245,13 +173,11 @@ export async function connectWithMaxRetries(
|
|
|
245
173
|
} catch (error) {
|
|
246
174
|
if (isErrorWithCode('ECONNREFUSED', error)) {
|
|
247
175
|
// Wait for `retryInterval` ms.
|
|
248
|
-
await new Promise(
|
|
176
|
+
await new Promise(resolve => {
|
|
249
177
|
setTimeout(resolve, retryInterval);
|
|
250
178
|
});
|
|
251
|
-
|
|
252
179
|
lastError = error;
|
|
253
|
-
log.debug(
|
|
254
|
-
`Retrying Firefox (${retries}); connection error: ${error}`);
|
|
180
|
+
log.debug(`Retrying Firefox (${retries}); connection error: ${error}`);
|
|
255
181
|
} else {
|
|
256
182
|
log.error(error.stack);
|
|
257
183
|
throw error;
|
|
@@ -266,14 +192,14 @@ export async function connectWithMaxRetries(
|
|
|
266
192
|
log.debug('Connecting to the remote Firefox debugger');
|
|
267
193
|
return establishConnection();
|
|
268
194
|
}
|
|
195
|
+
export function findFreeTcpPort() {
|
|
196
|
+
return new Promise(resolve => {
|
|
197
|
+
const srv = net.createServer(); // $FlowFixMe: signature for listen() is missing - see https://github.com/facebook/flow/pull/8290
|
|
269
198
|
|
|
270
|
-
export function findFreeTcpPort(): Promise<number> {
|
|
271
|
-
return new Promise((resolve) => {
|
|
272
|
-
const srv = net.createServer();
|
|
273
|
-
// $FlowFixMe: signature for listen() is missing - see https://github.com/facebook/flow/pull/8290
|
|
274
199
|
srv.listen(0, '127.0.0.1', () => {
|
|
275
200
|
const freeTcpPort = srv.address().port;
|
|
276
201
|
srv.close(() => resolve(freeTcpPort));
|
|
277
202
|
});
|
|
278
203
|
});
|
|
279
204
|
}
|
|
205
|
+
//# sourceMappingURL=remote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote.js","names":["net","FirefoxRDPClient","connectToFirefox","defaultFirefoxConnector","createLogger","isErrorWithCode","RemoteTempInstallNotSupported","UsageError","WebExtError","log","import","meta","url","requestErrorToMessage","err","Error","String","error","message","RemoteFirefox","constructor","client","checkedForAddonReloading","on","debug","info","JSON","stringify","rdpError","disconnect","addonRequest","addon","request","response","to","actor","type","getAddonsActor","addonsActor","Promise","reject","installTemporaryAddon","addonPath","getInstalledAddon","addonId","addons","id","map","a","checkForAddonReloading","requestTypes","indexOf","supportedRequestTypes","reloadAddon","process","stdout","write","Date","toTimeString","connect","port","connectWithMaxRetries","maxRetries","retryInterval","establishConnection","lastError","retries","resolve","setTimeout","stack","findFreeTcpPort","srv","createServer","listen","freeTcpPort","address","close"],"sources":["../../src/firefox/remote.js"],"sourcesContent":["/* @flow */\nimport net from 'net';\n\nimport FirefoxRDPClient, {\n connectToFirefox as defaultFirefoxConnector,\n} from './rdp-client.js';\nimport {createLogger} from '../util/logger.js';\nimport {\n isErrorWithCode,\n RemoteTempInstallNotSupported,\n UsageError,\n WebExtError,\n} from '../errors.js';\n\nconst log = createLogger(import.meta.url);\n\nexport type FirefoxConnectorFn =\n (port: number) => Promise<FirefoxRDPClient>;\n\nexport type FirefoxRDPAddonActor = {|\n id: string,\n actor: string,\n|};\n\nexport type FirefoxRDPResponseError = {|\n error: string,\n message: string,\n|};\n\nexport type FirefoxRDPResponseAddon = {|\n addon: FirefoxRDPAddonActor,\n|};\n\nexport type FirefoxRDPResponseRequestTypes = {|\n requestTypes: Array<string>,\n|};\n\n// NOTE: this type aliases Object to catch any other possible response.\nexport type FirefoxRDPResponseAny = Object;\n\nexport type FirefoxRDPResponseMaybe =\n FirefoxRDPResponseRequestTypes | FirefoxRDPResponseAny;\n\n// Convert a request rejection to a message string.\nfunction requestErrorToMessage(err: Error | FirefoxRDPResponseError) {\n if (err instanceof Error) {\n return String(err);\n }\n return `${err.error}: ${err.message}`;\n}\n\nexport class RemoteFirefox {\n client: Object;\n checkedForAddonReloading: boolean;\n\n constructor(client: FirefoxRDPClient) {\n this.client = client;\n this.checkedForAddonReloading = false;\n\n client.on('disconnect', () => {\n log.debug('Received \"disconnect\" from Firefox client');\n });\n client.on('end', () => {\n log.debug('Received \"end\" from Firefox client');\n });\n client.on('unsolicited-event', (info) => {\n log.debug(`Received message from client: ${JSON.stringify(info)}`);\n });\n client.on('rdp-error', (rdpError) => {\n log.debug(`Received error from client: ${JSON.stringify(rdpError)}`);\n });\n client.on('error', (error) => {\n log.debug(`Received error from client: ${String(error)}`);\n });\n }\n\n disconnect() {\n this.client.disconnect();\n }\n\n async addonRequest(\n addon: FirefoxRDPAddonActor,\n request: string\n ): Promise<FirefoxRDPResponseMaybe> {\n try {\n const response = await this.client.request({\n to: addon.actor, type: request,\n });\n return response;\n } catch (err) {\n log.debug(\n `Client responded to '${request}' request with error:`, err);\n const message = requestErrorToMessage(err);\n throw new WebExtError(`Remote Firefox: addonRequest() error: ${message}`);\n }\n }\n\n async getAddonsActor(): Promise<string> {\n try {\n // getRoot should work since Firefox 55 (bug 1352157).\n const response = await this.client.request('getRoot');\n if (response.addonsActor == null) {\n return Promise.reject(new RemoteTempInstallNotSupported(\n 'This version of Firefox does not provide an add-ons actor for ' +\n 'remote installation.'));\n }\n return response.addonsActor;\n } catch (err) {\n // Fallback to listTabs otherwise, Firefox 49 - 77 (bug 1618691).\n log.debug('Falling back to listTabs because getRoot failed', err);\n }\n\n try {\n const response = await this.client.request('listTabs');\n // addonsActor was added to listTabs in Firefox 49 (bug 1273183).\n if (response.addonsActor == null) {\n log.debug(\n 'listTabs returned a falsey addonsActor: ' +\n `${JSON.stringify(response)}`);\n return Promise.reject(new RemoteTempInstallNotSupported(\n 'This is an older version of Firefox that does not provide an ' +\n 'add-ons actor for remote installation. Try Firefox 49 or ' +\n 'higher.'));\n }\n return response.addonsActor;\n } catch (err) {\n log.debug('listTabs error', err);\n const message = requestErrorToMessage(err);\n throw new WebExtError(`Remote Firefox: listTabs() error: ${message}`);\n }\n }\n\n async installTemporaryAddon(\n addonPath: string\n ): Promise<FirefoxRDPResponseAddon> {\n const addonsActor = await this.getAddonsActor();\n\n try {\n const response = await this.client.request({\n to: addonsActor,\n type: 'installTemporaryAddon',\n addonPath,\n });\n log.debug(`installTemporaryAddon: ${JSON.stringify(response)}`);\n log.info(`Installed ${addonPath} as a temporary add-on`);\n return response;\n } catch (err) {\n const message = requestErrorToMessage(err);\n throw new WebExtError(`installTemporaryAddon: Error: ${message}`);\n }\n }\n\n async getInstalledAddon(addonId: string): Promise<FirefoxRDPAddonActor> {\n try {\n const response = await this.client.request('listAddons');\n for (const addon of response.addons) {\n if (addon.id === addonId) {\n return addon;\n }\n }\n log.debug(\n `Remote Firefox has these addons: ${response.addons.map((a) => a.id)}`);\n return Promise.reject(new WebExtError(\n 'The remote Firefox does not have your extension installed'));\n } catch (err) {\n const message = requestErrorToMessage(err);\n throw new WebExtError(`Remote Firefox: listAddons() error: ${message}`);\n }\n }\n\n async checkForAddonReloading(\n addon: FirefoxRDPAddonActor\n ): Promise<FirefoxRDPAddonActor> {\n if (this.checkedForAddonReloading) {\n // We only need to check once if reload() is supported.\n return addon;\n } else {\n const response = await this.addonRequest(addon, 'requestTypes');\n\n if (response.requestTypes.indexOf('reload') === -1) {\n const supportedRequestTypes = JSON.stringify(response.requestTypes);\n log.debug(\n `Remote Firefox only supports: ${supportedRequestTypes}`);\n throw new UsageError(\n 'This Firefox version does not support add-on reloading. ' +\n 'Re-run with --no-reload');\n } else {\n this.checkedForAddonReloading = true;\n return addon;\n }\n }\n }\n\n async reloadAddon(addonId: string): Promise<void> {\n const addon = await this.getInstalledAddon(addonId);\n await this.checkForAddonReloading(addon);\n await this.addonRequest(addon, 'reload');\n process.stdout.write(\n `\\rLast extension reload: ${(new Date()).toTimeString()}`);\n log.debug('\\n');\n }\n}\n\n\n// Connect types and implementation\n\nexport type ConnectOptions = {\n connectToFirefox: FirefoxConnectorFn,\n};\n\nexport async function connect(\n port: number,\n {connectToFirefox = defaultFirefoxConnector}: ConnectOptions = {}\n): Promise<RemoteFirefox> {\n log.debug(`Connecting to Firefox on port ${port}`);\n const client = await connectToFirefox(port);\n log.debug(`Connected to the remote Firefox debugger on port ${port}`);\n return new RemoteFirefox(client);\n}\n\n\n// ConnectWithMaxRetries types and implementation\n\nexport type ConnectWithMaxRetriesParams = {|\n maxRetries?: number,\n retryInterval?: number,\n port: number,\n|};\n\nexport type ConnectWithMaxRetriesDeps = {\n connectToFirefox: typeof connect,\n};\n\nexport async function connectWithMaxRetries(\n // A max of 250 will try connecting for 30 seconds.\n {maxRetries = 250, retryInterval = 120, port}: ConnectWithMaxRetriesParams,\n {connectToFirefox = connect}: ConnectWithMaxRetriesDeps = {}\n): Promise<RemoteFirefox> {\n async function establishConnection() {\n var lastError;\n\n for (let retries = 0; retries <= maxRetries; retries++) {\n try {\n return await connectToFirefox(port);\n } catch (error) {\n if (isErrorWithCode('ECONNREFUSED', error)) {\n // Wait for `retryInterval` ms.\n await new Promise((resolve) => {\n setTimeout(resolve, retryInterval);\n });\n\n lastError = error;\n log.debug(\n `Retrying Firefox (${retries}); connection error: ${error}`);\n } else {\n log.error(error.stack);\n throw error;\n }\n }\n }\n\n log.debug('Connect to Firefox debugger: too many retries');\n throw lastError;\n }\n\n log.debug('Connecting to the remote Firefox debugger');\n return establishConnection();\n}\n\nexport function findFreeTcpPort(): Promise<number> {\n return new Promise((resolve) => {\n const srv = net.createServer();\n // $FlowFixMe: signature for listen() is missing - see https://github.com/facebook/flow/pull/8290\n srv.listen(0, '127.0.0.1', () => {\n const freeTcpPort = srv.address().port;\n srv.close(() => resolve(freeTcpPort));\n });\n });\n}\n"],"mappings":"AACA,OAAOA,GAAP,MAAgB,KAAhB;AAEA,OAAOC,gBAAP,IACEC,gBAAgB,IAAIC,uBADtB,QAEO,iBAFP;AAGA,SAAQC,YAAR,QAA2B,mBAA3B;AACA,SACEC,eADF,EAEEC,6BAFF,EAGEC,UAHF,EAIEC,WAJF,QAKO,cALP;AAOA,MAAMC,GAAG,GAAGL,YAAY,CAACM,MAAM,CAACC,IAAP,CAAYC,GAAb,CAAxB;;AA6BA;AACA,SAASC,qBAAT,CAA+BC,GAA/B,EAAqE;EACnE,IAAIA,GAAG,YAAYC,KAAnB,EAA0B;IACxB,OAAOC,MAAM,CAACF,GAAD,CAAb;EACD;;EACD,OAAQ,GAAEA,GAAG,CAACG,KAAM,KAAIH,GAAG,CAACI,OAAQ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IACD,CAHD;EAID,CAPM,CAAP;AAQD"}
|
package/lib/main.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { main } from './program.js';
|
|
2
|
+
import cmd from './cmd/index.js'; // This only exposes main and cmd, while util/logger and util/adb are defined as
|
|
3
|
+
// separate additional exports in the package.json.
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
main,
|
|
7
|
+
cmd
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=main.js.map
|
package/lib/main.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","names":["main","cmd"],"sources":["../src/main.js"],"sourcesContent":["/* @flow */\nimport {main} from './program.js';\nimport cmd from './cmd/index.js';\n\n// This only exposes main and cmd, while util/logger and util/adb are defined as\n// separate additional exports in the package.json.\nexport default {main, cmd};\n"],"mappings":"AACA,SAAQA,IAAR,QAAmB,cAAnB;AACA,OAAOC,GAAP,MAAgB,gBAAhB,C,CAEA;AACA;;AACA,eAAe;EAACD,IAAD;EAAOC;AAAP,CAAf"}
|