unprint 0.18.18 → 0.18.21
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/package.json +1 -1
- package/src/app.js +31 -2
package/package.json
CHANGED
package/src/app.js
CHANGED
|
@@ -369,6 +369,15 @@ function prefixUrl(urlPath, originUrl, customOptions) {
|
|
|
369
369
|
return null;
|
|
370
370
|
}
|
|
371
371
|
|
|
372
|
+
if (/^http/.test(urlPath)) {
|
|
373
|
+
// this is already a complete URL
|
|
374
|
+
return urlPath;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
if (!originUrl) {
|
|
378
|
+
return null;
|
|
379
|
+
}
|
|
380
|
+
|
|
372
381
|
const options = {
|
|
373
382
|
protocol: 'https',
|
|
374
383
|
...customOptions,
|
|
@@ -378,7 +387,7 @@ function prefixUrl(urlPath, originUrl, customOptions) {
|
|
|
378
387
|
|
|
379
388
|
try {
|
|
380
389
|
return new URL(urlPath, origin).href;
|
|
381
|
-
} catch {
|
|
390
|
+
} catch (_error) {
|
|
382
391
|
return null;
|
|
383
392
|
}
|
|
384
393
|
}
|
|
@@ -1230,7 +1239,15 @@ async function getBrowserInstance(scope, options, useProxy = false) {
|
|
|
1230
1239
|
}
|
|
1231
1240
|
|
|
1232
1241
|
async function closeAllBrowsers() {
|
|
1233
|
-
|
|
1242
|
+
const closingClients = Array.from(clients.values);
|
|
1243
|
+
|
|
1244
|
+
await Promise.all(closingClients.map(async (client) => client.browser.close()));
|
|
1245
|
+
|
|
1246
|
+
events.emit('browser', {
|
|
1247
|
+
action: 'close',
|
|
1248
|
+
keys: closingClients.map((client) => client.key),
|
|
1249
|
+
active: closingClients.reduce((acc, client) => acc + (client.active || 0), 0),
|
|
1250
|
+
});
|
|
1234
1251
|
}
|
|
1235
1252
|
|
|
1236
1253
|
async function closeBrowser(client, options) {
|
|
@@ -1238,6 +1255,12 @@ async function closeBrowser(client, options) {
|
|
|
1238
1255
|
|| (client.retired && client.active === 0)) { // this browser is retired to minimize garbage build-up
|
|
1239
1256
|
// this browser won't be reused
|
|
1240
1257
|
await client.browser.close();
|
|
1258
|
+
|
|
1259
|
+
events.emit('browser', {
|
|
1260
|
+
action: 'close',
|
|
1261
|
+
keys: [client.key],
|
|
1262
|
+
active: client.active,
|
|
1263
|
+
});
|
|
1241
1264
|
}
|
|
1242
1265
|
}
|
|
1243
1266
|
|
|
@@ -1301,6 +1324,12 @@ async function browserRequest(url, customOptions = {}) {
|
|
|
1301
1324
|
return limiter.schedule(async () => {
|
|
1302
1325
|
const client = await getBrowserInstance(options.client, options, agent instanceof undici.ProxyAgent);
|
|
1303
1326
|
|
|
1327
|
+
events.emit('browser', {
|
|
1328
|
+
action: 'open',
|
|
1329
|
+
keys: [client.key],
|
|
1330
|
+
active: client.active,
|
|
1331
|
+
});
|
|
1332
|
+
|
|
1304
1333
|
client.active += 1;
|
|
1305
1334
|
|
|
1306
1335
|
const page = await client.context.newPage();
|