@live-change/print-service 0.9.7 → 0.9.9
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/browser.js +13 -0
- package/config.js +4 -0
- package/package.json +5 -5
package/browser.js
CHANGED
|
@@ -9,6 +9,8 @@ import { chromium } from 'playwright'
|
|
|
9
9
|
import PQueue from 'p-queue'
|
|
10
10
|
import got from "got"
|
|
11
11
|
|
|
12
|
+
import dns from "dns/promises"
|
|
13
|
+
|
|
12
14
|
const browserQueue = new PQueue({ concurrency: config.concurrency })
|
|
13
15
|
|
|
14
16
|
async function newBrowser() {
|
|
@@ -19,6 +21,17 @@ async function newBrowser() {
|
|
|
19
21
|
const browserInfo = await got.post(config.browserUrl + '/json/version').json()
|
|
20
22
|
const browser = await chromium.connect({ wsEndpoint: browserInfo.webSocketDebuggerUrl })
|
|
21
23
|
return browser
|
|
24
|
+
} if(config.browserHost) {
|
|
25
|
+
const ip = await dns.resolve4(config.browserHost)
|
|
26
|
+
const browserInfo = await got.post(`http://${ip}:${config.browserPort}/json/version`).json()
|
|
27
|
+
console.log("Browser info", browserInfo)
|
|
28
|
+
try {
|
|
29
|
+
const browser = await chromium.connectOverCDP(browserInfo.webSocketDebuggerUrl)
|
|
30
|
+
return browser
|
|
31
|
+
} catch (error) {
|
|
32
|
+
console.error("Failed to connect to browser", error)
|
|
33
|
+
throw error
|
|
34
|
+
}
|
|
22
35
|
} else {
|
|
23
36
|
const browser = await chromium.launch({
|
|
24
37
|
headless: true
|
package/config.js
CHANGED
|
@@ -4,6 +4,8 @@ import crypto from 'crypto'
|
|
|
4
4
|
const {
|
|
5
5
|
browserUrl,
|
|
6
6
|
browserWebSocketDebuggerUrl,
|
|
7
|
+
browserHost,
|
|
8
|
+
browserPort = 9222,
|
|
7
9
|
concurrency = 1,
|
|
8
10
|
printAuthenticationKey = crypto.randomBytes(24).toString('hex'),
|
|
9
11
|
ssrUrl = process.env.SSR_URL || 'http://localhost:8001'
|
|
@@ -16,6 +18,8 @@ definition.clientConfig = {
|
|
|
16
18
|
const config = {
|
|
17
19
|
browserUrl,
|
|
18
20
|
browserWebSocketDebuggerUrl,
|
|
21
|
+
browserHost,
|
|
22
|
+
browserPort,
|
|
19
23
|
concurrency,
|
|
20
24
|
printAuthenticationKey,
|
|
21
25
|
ssrUrl
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/print-service",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.9",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
"url": "https://www.viamage.com/"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@live-change/framework": "^0.9.
|
|
25
|
-
"@live-change/relations-plugin": "^0.9.
|
|
26
|
-
"@live-change/user-service": "^0.9.
|
|
24
|
+
"@live-change/framework": "^0.9.9",
|
|
25
|
+
"@live-change/relations-plugin": "^0.9.9",
|
|
26
|
+
"@live-change/user-service": "^0.9.9",
|
|
27
27
|
"got": "^11.8.6",
|
|
28
28
|
"p-queue": "^8.0.1",
|
|
29
29
|
"playwright": "1.48.1"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "150ef8008399a3b6a160985a4a8d4e91255c0e99",
|
|
32
32
|
"type": "module"
|
|
33
33
|
}
|