@browserless.io/browserless 2.4.0-beta-1 → 2.4.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.
Files changed (100) hide show
  1. package/CHANGELOG.md +14 -1
  2. package/bin/scaffold/README.md +2 -0
  3. package/build/browserless.d.ts +4 -2
  4. package/build/browserless.js +17 -4
  5. package/build/browsers/chromium.cdp.d.ts +1 -5
  6. package/build/browsers/chromium.cdp.js +5 -115
  7. package/build/browsers/chromium.playwright.d.ts +1 -3
  8. package/build/browsers/chromium.playwright.js +1 -6
  9. package/build/browsers/firefox.playwright.d.ts +1 -3
  10. package/build/browsers/firefox.playwright.js +1 -6
  11. package/build/browsers/index.d.ts +5 -1
  12. package/build/browsers/index.js +6 -5
  13. package/build/browsers/webkit.playwright.d.ts +1 -3
  14. package/build/browsers/webkit.playwright.js +1 -6
  15. package/build/config.d.ts +9 -0
  16. package/build/config.js +11 -0
  17. package/build/constants.d.ts +0 -1
  18. package/build/constants.js +0 -1
  19. package/build/file-system.d.ts +12 -1
  20. package/build/file-system.js +14 -1
  21. package/build/http.d.ts +0 -7
  22. package/build/limiter.d.ts +9 -0
  23. package/build/limiter.js +11 -0
  24. package/build/metrics.d.ts +12 -1
  25. package/build/metrics.js +13 -1
  26. package/build/monitoring.d.ts +12 -1
  27. package/build/monitoring.js +14 -1
  28. package/build/router.d.ts +12 -2
  29. package/build/router.js +16 -6
  30. package/build/routes/chrome/http/content.post.body.json +8 -8
  31. package/build/routes/chrome/http/content.post.query.json +0 -4
  32. package/build/routes/chrome/http/download.post.query.json +0 -4
  33. package/build/routes/chrome/http/function.post.query.json +0 -4
  34. package/build/routes/chrome/http/pdf.post.body.json +8 -11
  35. package/build/routes/chrome/http/pdf.post.query.json +0 -4
  36. package/build/routes/chrome/http/performance.post.query.json +0 -4
  37. package/build/routes/chrome/http/scrape.post.body.json +8 -8
  38. package/build/routes/chrome/http/scrape.post.query.json +0 -4
  39. package/build/routes/chrome/http/screenshot.post.body.json +8 -8
  40. package/build/routes/chrome/http/screenshot.post.query.json +0 -4
  41. package/build/routes/chrome/ws/browser.query.json +0 -4
  42. package/build/routes/chrome/ws/cdp.query.json +0 -4
  43. package/build/routes/chrome/ws/page.query.json +0 -4
  44. package/build/routes/chrome/ws/playwright.query.json +0 -4
  45. package/build/routes/chromium/http/content.post.body.json +8 -8
  46. package/build/routes/chromium/http/content.post.query.json +0 -4
  47. package/build/routes/chromium/http/download.post.query.json +0 -4
  48. package/build/routes/chromium/http/function.post.query.json +0 -4
  49. package/build/routes/chromium/http/pdf.post.body.json +8 -11
  50. package/build/routes/chromium/http/pdf.post.query.json +0 -4
  51. package/build/routes/chromium/http/performance.post.query.json +0 -4
  52. package/build/routes/chromium/http/scrape.post.body.json +8 -8
  53. package/build/routes/chromium/http/scrape.post.query.json +0 -4
  54. package/build/routes/chromium/http/screenshot.post.body.json +8 -8
  55. package/build/routes/chromium/http/screenshot.post.query.json +0 -4
  56. package/build/routes/chromium/ws/browser.query.json +0 -4
  57. package/build/routes/chromium/ws/cdp.query.json +0 -4
  58. package/build/routes/chromium/ws/page.query.json +0 -4
  59. package/build/routes/chromium/ws/playwright.query.json +0 -4
  60. package/build/routes/firefox/ws/playwright.query.json +0 -4
  61. package/build/routes/webkit/ws/playwright.query.json +0 -4
  62. package/build/server.d.ts +8 -3
  63. package/build/server.js +15 -13
  64. package/build/shared/content.http.js +1 -1
  65. package/build/shared/pdf.http.d.ts +0 -1
  66. package/build/shared/pdf.http.js +1 -1
  67. package/build/shared/screenshot.http.js +1 -1
  68. package/build/token.d.ts +12 -1
  69. package/build/token.js +14 -1
  70. package/build/types.d.ts +3 -14
  71. package/build/webhooks.d.ts +12 -1
  72. package/build/webhooks.js +14 -1
  73. package/extensions/.gitkeep +0 -0
  74. package/package.json +8 -8
  75. package/src/browserless.ts +17 -4
  76. package/src/browsers/chromium.cdp.ts +10 -157
  77. package/src/browsers/chromium.playwright.ts +0 -8
  78. package/src/browsers/firefox.playwright.ts +0 -8
  79. package/src/browsers/index.ts +7 -6
  80. package/src/browsers/webkit.playwright.ts +0 -8
  81. package/src/config.ts +13 -0
  82. package/src/constants.ts +0 -1
  83. package/src/file-system.ts +16 -1
  84. package/src/http.ts +0 -8
  85. package/src/limiter.ts +13 -0
  86. package/src/metrics.ts +16 -1
  87. package/src/monitoring.ts +18 -2
  88. package/src/router.ts +20 -9
  89. package/src/server.ts +18 -16
  90. package/src/shared/content.http.ts +5 -4
  91. package/src/shared/pdf.http.ts +4 -5
  92. package/src/shared/screenshot.http.ts +4 -4
  93. package/src/token.ts +18 -2
  94. package/src/types.ts +0 -13
  95. package/src/webhooks.ts +18 -2
  96. package/static/docs/swagger.json +10 -192
  97. package/static/docs/swagger.min.json +9 -191
  98. package/extensions/screencast/background.js +0 -143
  99. package/extensions/screencast/content_script.js +0 -18
  100. package/extensions/screencast/manifest.json +0 -19
@@ -225,14 +225,14 @@
225
225
  "length": {
226
226
  "type": "number"
227
227
  },
228
- "__@toStringTag@10910": {
228
+ "__@toStringTag@10915": {
229
229
  "type": "string",
230
230
  "const": "Uint8Array"
231
231
  }
232
232
  },
233
233
  "required": [
234
234
  "BYTES_PER_ELEMENT",
235
- "__@toStringTag@10910",
235
+ "__@toStringTag@10915",
236
236
  "buffer",
237
237
  "byteLength",
238
238
  "byteOffset",
@@ -267,13 +267,13 @@
267
267
  "byteLength": {
268
268
  "type": "number"
269
269
  },
270
- "__@toStringTag@10910": {
270
+ "__@toStringTag@10915": {
271
271
  "type": "string"
272
272
  }
273
273
  },
274
274
  "additionalProperties": false,
275
275
  "required": [
276
- "__@toStringTag@10910",
276
+ "__@toStringTag@10915",
277
277
  "byteLength"
278
278
  ]
279
279
  },
@@ -283,18 +283,18 @@
283
283
  "byteLength": {
284
284
  "type": "number"
285
285
  },
286
- "__@species@11011": {
286
+ "__@species@11016": {
287
287
  "$ref": "#/definitions/SharedArrayBuffer"
288
288
  },
289
- "__@toStringTag@10910": {
289
+ "__@toStringTag@10915": {
290
290
  "type": "string",
291
291
  "const": "SharedArrayBuffer"
292
292
  }
293
293
  },
294
294
  "additionalProperties": false,
295
295
  "required": [
296
- "__@species@11011",
297
- "__@toStringTag@10910",
296
+ "__@species@11016",
297
+ "__@toStringTag@10915",
298
298
  "byteLength"
299
299
  ]
300
300
  },
@@ -1098,7 +1098,7 @@
1098
1098
  },
1099
1099
  "info": {
1100
1100
  "title": "Browserless",
1101
- "version": "2.4.0-beta-1",
1101
+ "version": "2.4.0",
1102
1102
  "x-logo": {
1103
1103
  "altText": "browserless logo",
1104
1104
  "url": "./docs/browserless-logo-inline.svg"
@@ -1133,14 +1133,6 @@
1133
1133
  ]
1134
1134
  }
1135
1135
  },
1136
- {
1137
- "in": "query",
1138
- "name": "record",
1139
- "schema": {
1140
- "description": "Whether or nor to record the session. The browser will run\nin \"head-full\" mode, and recording is started and closed\nvia the embedded browserless API. Please refer to the \"Recording\"\nsection in the live documentation site for more details.",
1141
- "type": "boolean"
1142
- }
1143
- },
1144
1136
  {
1145
1137
  "in": "query",
1146
1138
  "name": "timeout",
@@ -1413,14 +1405,6 @@
1413
1405
  ]
1414
1406
  }
1415
1407
  },
1416
- {
1417
- "in": "query",
1418
- "name": "record",
1419
- "schema": {
1420
- "description": "Whether or nor to record the session. The browser will run\nin \"head-full\" mode, and recording is started and closed\nvia the embedded browserless API. Please refer to the \"Recording\"\nsection in the live documentation site for more details.",
1421
- "type": "boolean"
1422
- }
1423
- },
1424
1408
  {
1425
1409
  "in": "query",
1426
1410
  "name": "timeout",
@@ -1529,14 +1513,6 @@
1529
1513
  ]
1530
1514
  }
1531
1515
  },
1532
- {
1533
- "in": "query",
1534
- "name": "record",
1535
- "schema": {
1536
- "description": "Whether or nor to record the session. The browser will run\nin \"head-full\" mode, and recording is started and closed\nvia the embedded browserless API. Please refer to the \"Recording\"\nsection in the live documentation site for more details.",
1537
- "type": "boolean"
1538
- }
1539
- },
1540
1516
  {
1541
1517
  "in": "query",
1542
1518
  "name": "timeout",
@@ -1999,14 +1975,6 @@
1999
1975
  ]
2000
1976
  }
2001
1977
  },
2002
- {
2003
- "in": "query",
2004
- "name": "record",
2005
- "schema": {
2006
- "description": "Whether or nor to record the session. The browser will run\nin \"head-full\" mode, and recording is started and closed\nvia the embedded browserless API. Please refer to the \"Recording\"\nsection in the live documentation site for more details.",
2007
- "type": "boolean"
2008
- }
2009
- },
2010
1978
  {
2011
1979
  "in": "query",
2012
1980
  "name": "timeout",
@@ -2048,9 +2016,6 @@
2048
2016
  "description": "When bestAttempt is set to true, browserless attempt to proceed\nwhen \"awaited\" events fail or timeout. This includes things like\ngoto, waitForSelector, and more.",
2049
2017
  "type": "boolean"
2050
2018
  },
2051
- "blockModals": {
2052
- "type": "boolean"
2053
- },
2054
2019
  "cookies": {
2055
2020
  "type": "array",
2056
2021
  "items": {
@@ -2284,14 +2249,6 @@
2284
2249
  ]
2285
2250
  }
2286
2251
  },
2287
- {
2288
- "in": "query",
2289
- "name": "record",
2290
- "schema": {
2291
- "description": "Whether or nor to record the session. The browser will run\nin \"head-full\" mode, and recording is started and closed\nvia the embedded browserless API. Please refer to the \"Recording\"\nsection in the live documentation site for more details.",
2292
- "type": "boolean"
2293
- }
2294
- },
2295
2252
  {
2296
2253
  "in": "query",
2297
2254
  "name": "timeout",
@@ -2415,14 +2372,6 @@
2415
2372
  ]
2416
2373
  }
2417
2374
  },
2418
- {
2419
- "in": "query",
2420
- "name": "record",
2421
- "schema": {
2422
- "description": "Whether or nor to record the session. The browser will run\nin \"head-full\" mode, and recording is started and closed\nvia the embedded browserless API. Please refer to the \"Recording\"\nsection in the live documentation site for more details.",
2423
- "type": "boolean"
2424
- }
2425
- },
2426
2375
  {
2427
2376
  "in": "query",
2428
2377
  "name": "timeout",
@@ -3007,14 +2956,6 @@
3007
2956
  ]
3008
2957
  }
3009
2958
  },
3010
- {
3011
- "in": "query",
3012
- "name": "record",
3013
- "schema": {
3014
- "description": "Whether or nor to record the session. The browser will run\nin \"head-full\" mode, and recording is started and closed\nvia the embedded browserless API. Please refer to the \"Recording\"\nsection in the live documentation site for more details.",
3015
- "type": "boolean"
3016
- }
3017
- },
3018
2959
  {
3019
2960
  "in": "query",
3020
2961
  "name": "timeout",
@@ -3303,14 +3244,6 @@
3303
3244
  ]
3304
3245
  }
3305
3246
  },
3306
- {
3307
- "in": "query",
3308
- "name": "record",
3309
- "schema": {
3310
- "description": "Whether or nor to record the session. The browser will run\nin \"head-full\" mode, and recording is started and closed\nvia the embedded browserless API. Please refer to the \"Recording\"\nsection in the live documentation site for more details.",
3311
- "type": "boolean"
3312
- }
3313
- },
3314
3247
  {
3315
3248
  "in": "query",
3316
3249
  "name": "timeout",
@@ -3400,14 +3333,6 @@
3400
3333
  ]
3401
3334
  }
3402
3335
  },
3403
- {
3404
- "in": "query",
3405
- "name": "record",
3406
- "schema": {
3407
- "description": "Whether or nor to record the session. The browser will run\nin \"head-full\" mode, and recording is started and closed\nvia the embedded browserless API. Please refer to the \"Recording\"\nsection in the live documentation site for more details.",
3408
- "type": "boolean"
3409
- }
3410
- },
3411
3336
  {
3412
3337
  "in": "query",
3413
3338
  "name": "timeout",
@@ -3497,14 +3422,6 @@
3497
3422
  ]
3498
3423
  }
3499
3424
  },
3500
- {
3501
- "in": "query",
3502
- "name": "record",
3503
- "schema": {
3504
- "description": "Whether or nor to record the session. The browser will run\nin \"head-full\" mode, and recording is started and closed\nvia the embedded browserless API. Please refer to the \"Recording\"\nsection in the live documentation site for more details.",
3505
- "type": "boolean"
3506
- }
3507
- },
3508
3425
  {
3509
3426
  "in": "query",
3510
3427
  "name": "timeout",
@@ -3594,14 +3511,6 @@
3594
3511
  ]
3595
3512
  }
3596
3513
  },
3597
- {
3598
- "in": "query",
3599
- "name": "record",
3600
- "schema": {
3601
- "description": "Whether or nor to record the session. The browser will run\nin \"head-full\" mode, and recording is started and closed\nvia the embedded browserless API. Please refer to the \"Recording\"\nsection in the live documentation site for more details.",
3602
- "type": "boolean"
3603
- }
3604
- },
3605
3514
  {
3606
3515
  "in": "query",
3607
3516
  "name": "timeout",
@@ -3690,14 +3599,6 @@
3690
3599
  ]
3691
3600
  }
3692
3601
  },
3693
- {
3694
- "in": "query",
3695
- "name": "record",
3696
- "schema": {
3697
- "description": "Whether or nor to record the session. The browser will run\nin \"head-full\" mode, and recording is started and closed\nvia the embedded browserless API. Please refer to the \"Recording\"\nsection in the live documentation site for more details.",
3698
- "type": "boolean"
3699
- }
3700
- },
3701
3602
  {
3702
3603
  "in": "query",
3703
3604
  "name": "timeout",
@@ -3970,14 +3871,6 @@
3970
3871
  ]
3971
3872
  }
3972
3873
  },
3973
- {
3974
- "in": "query",
3975
- "name": "record",
3976
- "schema": {
3977
- "description": "Whether or nor to record the session. The browser will run\nin \"head-full\" mode, and recording is started and closed\nvia the embedded browserless API. Please refer to the \"Recording\"\nsection in the live documentation site for more details.",
3978
- "type": "boolean"
3979
- }
3980
- },
3981
3874
  {
3982
3875
  "in": "query",
3983
3876
  "name": "timeout",
@@ -4086,14 +3979,6 @@
4086
3979
  ]
4087
3980
  }
4088
3981
  },
4089
- {
4090
- "in": "query",
4091
- "name": "record",
4092
- "schema": {
4093
- "description": "Whether or nor to record the session. The browser will run\nin \"head-full\" mode, and recording is started and closed\nvia the embedded browserless API. Please refer to the \"Recording\"\nsection in the live documentation site for more details.",
4094
- "type": "boolean"
4095
- }
4096
- },
4097
3982
  {
4098
3983
  "in": "query",
4099
3984
  "name": "timeout",
@@ -4202,14 +4087,6 @@
4202
4087
  ]
4203
4088
  }
4204
4089
  },
4205
- {
4206
- "in": "query",
4207
- "name": "record",
4208
- "schema": {
4209
- "description": "Whether or nor to record the session. The browser will run\nin \"head-full\" mode, and recording is started and closed\nvia the embedded browserless API. Please refer to the \"Recording\"\nsection in the live documentation site for more details.",
4210
- "type": "boolean"
4211
- }
4212
- },
4213
4090
  {
4214
4091
  "in": "query",
4215
4092
  "name": "timeout",
@@ -4251,9 +4128,6 @@
4251
4128
  "description": "When bestAttempt is set to true, browserless attempt to proceed\nwhen \"awaited\" events fail or timeout. This includes things like\ngoto, waitForSelector, and more.",
4252
4129
  "type": "boolean"
4253
4130
  },
4254
- "blockModals": {
4255
- "type": "boolean"
4256
- },
4257
4131
  "cookies": {
4258
4132
  "type": "array",
4259
4133
  "items": {
@@ -4487,14 +4361,6 @@
4487
4361
  ]
4488
4362
  }
4489
4363
  },
4490
- {
4491
- "in": "query",
4492
- "name": "record",
4493
- "schema": {
4494
- "description": "Whether or nor to record the session. The browser will run\nin \"head-full\" mode, and recording is started and closed\nvia the embedded browserless API. Please refer to the \"Recording\"\nsection in the live documentation site for more details.",
4495
- "type": "boolean"
4496
- }
4497
- },
4498
4364
  {
4499
4365
  "in": "query",
4500
4366
  "name": "timeout",
@@ -4618,14 +4484,6 @@
4618
4484
  ]
4619
4485
  }
4620
4486
  },
4621
- {
4622
- "in": "query",
4623
- "name": "record",
4624
- "schema": {
4625
- "description": "Whether or nor to record the session. The browser will run\nin \"head-full\" mode, and recording is started and closed\nvia the embedded browserless API. Please refer to the \"Recording\"\nsection in the live documentation site for more details.",
4626
- "type": "boolean"
4627
- }
4628
- },
4629
4487
  {
4630
4488
  "in": "query",
4631
4489
  "name": "timeout",
@@ -5210,14 +5068,6 @@
5210
5068
  ]
5211
5069
  }
5212
5070
  },
5213
- {
5214
- "in": "query",
5215
- "name": "record",
5216
- "schema": {
5217
- "description": "Whether or nor to record the session. The browser will run\nin \"head-full\" mode, and recording is started and closed\nvia the embedded browserless API. Please refer to the \"Recording\"\nsection in the live documentation site for more details.",
5218
- "type": "boolean"
5219
- }
5220
- },
5221
5071
  {
5222
5072
  "in": "query",
5223
5073
  "name": "timeout",
@@ -5506,14 +5356,6 @@
5506
5356
  ]
5507
5357
  }
5508
5358
  },
5509
- {
5510
- "in": "query",
5511
- "name": "record",
5512
- "schema": {
5513
- "description": "Whether or nor to record the session. The browser will run\nin \"head-full\" mode, and recording is started and closed\nvia the embedded browserless API. Please refer to the \"Recording\"\nsection in the live documentation site for more details.",
5514
- "type": "boolean"
5515
- }
5516
- },
5517
5359
  {
5518
5360
  "in": "query",
5519
5361
  "name": "timeout",
@@ -5603,14 +5445,6 @@
5603
5445
  ]
5604
5446
  }
5605
5447
  },
5606
- {
5607
- "in": "query",
5608
- "name": "record",
5609
- "schema": {
5610
- "description": "Whether or nor to record the session. The browser will run\nin \"head-full\" mode, and recording is started and closed\nvia the embedded browserless API. Please refer to the \"Recording\"\nsection in the live documentation site for more details.",
5611
- "type": "boolean"
5612
- }
5613
- },
5614
5448
  {
5615
5449
  "in": "query",
5616
5450
  "name": "timeout",
@@ -5764,14 +5598,6 @@
5764
5598
  }
5765
5599
  }
5766
5600
  },
5767
- {
5768
- "in": "query",
5769
- "name": "record",
5770
- "schema": {
5771
- "description": "Whether or nor to record the session. The browser will run\nin \"head-full\" mode, and recording is started and closed\nvia the embedded browserless API. Please refer to the \"Recording\"\nsection in the live documentation site for more details.",
5772
- "type": "boolean"
5773
- }
5774
- },
5775
5601
  {
5776
5602
  "in": "query",
5777
5603
  "name": "timeout",
@@ -6623,14 +6449,6 @@
6623
6449
  ]
6624
6450
  }
6625
6451
  },
6626
- {
6627
- "in": "query",
6628
- "name": "record",
6629
- "schema": {
6630
- "description": "Whether or nor to record the session. The browser will run\nin \"head-full\" mode, and recording is started and closed\nvia the embedded browserless API. Please refer to the \"Recording\"\nsection in the live documentation site for more details.",
6631
- "type": "boolean"
6632
- }
6633
- },
6634
6452
  {
6635
6453
  "in": "query",
6636
6454
  "name": "timeout",
@@ -1,143 +0,0 @@
1
- /* eslint-disable no-undef */
2
-
3
- // All recordings are hoisted in this reference
4
- // so we can navigate pages and more.
5
- const recordings = new Map();
6
- class Recorder {
7
- #recorder = null;
8
- #chunks = [];
9
-
10
- async start(opts) {
11
- return new Promise((resolve, reject) => {
12
- if (this.#recorder) {
13
- return reject(new Error(`${id} has already started recording`));
14
- }
15
-
16
- chrome.desktopCapture.chooseDesktopMedia(
17
- ['audio', 'tab'],
18
- async (streamId) => {
19
- const userMediaPreferences = {
20
- audio: {
21
- mandatory: {
22
- chromeMediaSource: 'desktop',
23
- chromeMediaSourceId: streamId,
24
- echoCancellation: true,
25
- },
26
- },
27
- video: {
28
- mandatory: {
29
- chromeMediaSource: 'desktop',
30
- chromeMediaSourceId: streamId,
31
- maxFrameRate: opts.framerate || 60,
32
- minFrameRate: opts.framerate || 60,
33
- },
34
- },
35
- };
36
-
37
- const stream = await navigator.mediaDevices.getUserMedia(
38
- userMediaPreferences
39
- );
40
-
41
- if (opts.video === false) {
42
- const videoTracks = stream.getVideoTracks();
43
- videoTracks.forEach((track) => stream.removeTrack(track));
44
- }
45
-
46
- if (opts.audio === false) {
47
- const audioTracks = stream.getAudioTracks();
48
- audioTracks.forEach((track) => stream.removeTrack(track));
49
- }
50
-
51
- this.#recorder = new MediaRecorder(stream, {
52
- ignoreMutedMedia: true,
53
- mimeType: opts.video === false ? 'audio/webm' : 'video/webm',
54
- });
55
-
56
- this.#recorder.ondataavailable = (event) => {
57
- if (event.data.size > 0) {
58
- this.#chunks.push(event.data);
59
- }
60
- };
61
- resolve();
62
-
63
- // Wait 350ms for the invisible dialog to disappear
64
- setTimeout(() => this.#recorder.start(), 500);
65
- }
66
- );
67
- });
68
- }
69
-
70
- async stop() {
71
- return new Promise((resolve, reject) => {
72
- if (!this.#recorder) {
73
- return reject(
74
- new Error(`No recorder has started, did you forget to start?`)
75
- );
76
- }
77
-
78
- this.#recorder.onstop = () => {
79
- const blob = new Blob(this.#chunks, {
80
- type: 'video/webm',
81
- });
82
- const reader = new FileReader();
83
-
84
- reader.onload = () => {
85
- resolve(reader.result);
86
- };
87
-
88
- reader.onerror = (err) => {
89
- reject(err);
90
- };
91
-
92
- reader.readAsBinaryString(blob);
93
- };
94
-
95
- this.#recorder.stop();
96
- });
97
- }
98
- }
99
-
100
- chrome.runtime.onConnect.addListener((port) => {
101
- port.onMessage.addListener(async (msg) => {
102
- const { id, type } = msg;
103
- if (type === 'REC_START') {
104
- if (recordings.has(id)) {
105
- return;
106
- }
107
- const recorder = new Recorder();
108
- recordings.set(id, recorder);
109
- try {
110
- await recorder.start(msg);
111
- return port.postMessage({ id, message: 'REC_STARTED' });
112
- } catch (err) {
113
- return port.postMessage({
114
- error: err.message,
115
- id,
116
- message: 'REC_START_FAIL',
117
- });
118
- }
119
- }
120
-
121
- if (type === 'REC_STOP') {
122
- const recorder = recordings.get(id);
123
- if (!recorder) {
124
- return port.postMessage({
125
- id,
126
- message: 'REC_NOT_STARTED',
127
- });
128
- }
129
- try {
130
- const result = await recorder.stop();
131
- return port.postMessage({ file: result, id, message: 'REC_FILE' });
132
- } catch (err) {
133
- return port.postMessage({
134
- error: err.message,
135
- id,
136
- message: 'REC_STOP_FAIL',
137
- });
138
- } finally {
139
- recordings.delete(id);
140
- }
141
- }
142
- });
143
- });
@@ -1,18 +0,0 @@
1
- /* eslint-disable no-undef */
2
- /**
3
- * Simply forwarding messages here back and forth
4
- * between the background.js script and the page's
5
- * runtime JavaScript.
6
- */
7
- window.onload = () => {
8
- const port = chrome.runtime.connect(chrome.runtime.id);
9
- port.onMessage.addListener((msg) => {
10
- window.postMessage(msg, '*');
11
- });
12
- window.addEventListener('message', event => {
13
- if (event.source === window && event.data.type) {
14
- port.postMessage(event.data);
15
- }
16
- });
17
- document.title = 'browserless-screencast';
18
- };
@@ -1,19 +0,0 @@
1
- {
2
- "name": "browserless-vhs",
3
- "version": "1.0.0",
4
- "manifest_version": 2,
5
- "background": {
6
- "scripts": ["background.js"]
7
- },
8
- "content_scripts": [{
9
- "matches": ["<all_urls>"],
10
- "js": ["content_script.js"],
11
- "run_at": "document_start"
12
- }],
13
- "permissions": [
14
- "desktopCapture",
15
- "audio",
16
- "<all_urls>",
17
- "downloads"
18
- ]
19
- }