@symbo.ls/socket 2.11.410 → 2.11.446
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/client.js +16 -5
- package/package.json +5 -5
package/client.js
CHANGED
|
@@ -6,7 +6,6 @@ import io from 'socket.io-client'
|
|
|
6
6
|
|
|
7
7
|
const { isFunction, isArray } = utils.default || utils
|
|
8
8
|
const { window } = globals.default || globals
|
|
9
|
-
|
|
10
9
|
const ENV = process.env.NODE_ENV
|
|
11
10
|
|
|
12
11
|
const defautlOpts = {}
|
|
@@ -14,11 +13,13 @@ const defautlOpts = {}
|
|
|
14
13
|
let CONNECT_ATTEPT = 0
|
|
15
14
|
const CONNECT_ATTEPT_MAX_ALLOWED = 1
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
const getIsDev = (options) => {
|
|
17
|
+
return options.development ||
|
|
19
18
|
(window && window.location && window.location.host.includes('local')) ||
|
|
20
19
|
(ENV === 'test' || ENV === 'development')
|
|
20
|
+
}
|
|
21
21
|
|
|
22
|
+
const getSocketUrl = (options, isDev) => {
|
|
22
23
|
const SOCKET_BACKEND_URL = isDev
|
|
23
24
|
? 'http://localhost:13336/'
|
|
24
25
|
: 'https://socket.symbols.app/'
|
|
@@ -30,14 +31,24 @@ export const connect = (key, options = {}) => {
|
|
|
30
31
|
const primaryUrl = socketUrls[0]
|
|
31
32
|
const secondaryUrl = socketUrls[1] || 'socket.symbols.app'
|
|
32
33
|
|
|
33
|
-
|
|
34
|
+
return {
|
|
35
|
+
primaryUrl: primaryUrl || SOCKET_BACKEND_URL,
|
|
36
|
+
secondaryUrl
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const connect = (key, options = {}) => {
|
|
41
|
+
const isDev = getIsDev(options)
|
|
42
|
+
|
|
43
|
+
const { primaryUrl, secondaryUrl } = getSocketUrl(options, isDev)
|
|
44
|
+
const socket = io(primaryUrl || secondaryUrl, {
|
|
34
45
|
// withCredentials: true
|
|
35
46
|
})
|
|
36
47
|
|
|
37
48
|
socket.on('connect', () => {
|
|
38
49
|
if (isDev) {
|
|
39
50
|
console.log(
|
|
40
|
-
`Connected to %c${primaryUrl
|
|
51
|
+
`Connected to %c${primaryUrl} %c${key} %c${socket.id}`,
|
|
41
52
|
'font-weight: bold; color: green;',
|
|
42
53
|
'font-weight: bold;',
|
|
43
54
|
''
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/socket",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.446",
|
|
4
4
|
"description": "Connect your app to Symbols editor",
|
|
5
5
|
"main": "server.js",
|
|
6
6
|
"author": "symbo.ls",
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
"start": "nodemon server.js"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@domql/globals": "
|
|
14
|
-
"@domql/utils": "
|
|
15
|
-
"@symbo.ls/init": "
|
|
13
|
+
"@domql/globals": "^2.5.0",
|
|
14
|
+
"@domql/utils": "^2.5.0",
|
|
15
|
+
"@symbo.ls/init": "^2.11.446",
|
|
16
16
|
"chalk": "^5.0.0",
|
|
17
17
|
"express": "^4.18.1",
|
|
18
18
|
"http": "^0.0.1-security",
|
|
@@ -20,5 +20,5 @@
|
|
|
20
20
|
"socket.io": "^4.5.2",
|
|
21
21
|
"socket.io-client": "^4.5.2"
|
|
22
22
|
},
|
|
23
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "d042e0c4fc9379b0ca7584f6405cfa2e7c1301d4"
|
|
24
24
|
}
|