bfg-common 1.5.483 → 1.5.484
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
CHANGED
@@ -1,187 +1,210 @@
|
|
1
|
-
const getURLParameter = (parameter) => {
|
2
|
-
const regex = new RegExp(`${parameter}=([^&]+)`)
|
3
|
-
const match = regex.exec(window.location.pathname)
|
4
|
-
return match && match[1]
|
5
|
-
}
|
6
|
-
|
7
|
-
let vmHost = window.location.hostname
|
8
|
-
if (vmHost === 'localhost') {
|
9
|
-
vmHost = '10.10.101.107' // Для разработки
|
10
|
-
}
|
11
|
-
const vmId = getURLParameter('id')
|
12
|
-
const vmPort = window.config.public.PORT
|
13
|
-
|
14
|
-
window.app = new Application({
|
15
|
-
supportHighDPI: false,
|
16
|
-
})
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
}
|
110
|
-
} else if (action === '
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
}
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
1
|
+
const getURLParameter = (parameter) => {
|
2
|
+
const regex = new RegExp(`${parameter}=([^&]+)`)
|
3
|
+
const match = regex.exec(window.location.pathname)
|
4
|
+
return match && match[1]
|
5
|
+
}
|
6
|
+
|
7
|
+
let vmHost = window.location.hostname
|
8
|
+
if (vmHost === 'localhost') {
|
9
|
+
vmHost = '10.10.101.107' // Для разработки
|
10
|
+
}
|
11
|
+
const vmId = getURLParameter('id')
|
12
|
+
const vmPort = window.config.public.PORT
|
13
|
+
|
14
|
+
window.app = new Application({
|
15
|
+
supportHighDPI: false,
|
16
|
+
})
|
17
|
+
|
18
|
+
// Custom code
|
19
|
+
let vmWidth = -1
|
20
|
+
let vmHeight = -1
|
21
|
+
window.addEventListener('resize', () => {
|
22
|
+
if (vmWidth !== -1 && vmHeight !== -1) setVmPosition(vmWidth, vmHeight)
|
23
|
+
})
|
24
|
+
const setVmPosition = (width, height) => {
|
25
|
+
// Делаем выравнивание по центру
|
26
|
+
vmWidth = width
|
27
|
+
vmHeight = height
|
28
|
+
const left = Math.max((window.innerWidth - width) / 2, 0)
|
29
|
+
const top = Math.max((window.innerHeight - height) / 2, 0)
|
30
|
+
document.getElementById('canvas_0').style.left = left + 'px'
|
31
|
+
document.getElementById('eventLayer').style.left = left + 'px'
|
32
|
+
document.getElementById('canvas_0').style.top = top + 'px'
|
33
|
+
document.getElementById('eventLayer').style.top = top + 'px'
|
34
|
+
}
|
35
|
+
// Custom code end
|
36
|
+
|
37
|
+
function start() {
|
38
|
+
wdi.graphicDebug = new wdi.GraphicDebug({ debugMode: false })
|
39
|
+
let cancelReconnection = false
|
40
|
+
let cancelFreezeTimer, cancelReconnectionTimer
|
41
|
+
|
42
|
+
const handleWindowAction = function (action, params) {
|
43
|
+
if (action === 'windowClosed') {
|
44
|
+
$(params.canvas).remove()
|
45
|
+
$(params.eventLayer).remove()
|
46
|
+
} else if (action === 'windowMoved') {
|
47
|
+
$(params.canvas).css({
|
48
|
+
top: params.info.top + 'px',
|
49
|
+
left: params.info.left + 'px',
|
50
|
+
})
|
51
|
+
$(params.eventLayer).css({
|
52
|
+
top: params.info.top + 'px',
|
53
|
+
left: params.info.left + 'px',
|
54
|
+
})
|
55
|
+
} else if (action === 'init' || action === 'windowCreated') {
|
56
|
+
let item = null
|
57
|
+
let canvas = null
|
58
|
+
let eventlayer = null
|
59
|
+
const body = $('body')
|
60
|
+
|
61
|
+
for (let i in params) {
|
62
|
+
item = params[i]
|
63
|
+
const position = item.position * 2
|
64
|
+
canvas = $(item.canvas).css({
|
65
|
+
zIndex: 10000 - position - 1,
|
66
|
+
position: 'absolute',
|
67
|
+
top: item.info.top + 'px',
|
68
|
+
left: item.info.left + 'px',
|
69
|
+
})
|
70
|
+
eventlayer = $(item.eventLayer).css({
|
71
|
+
top: item.info.top + 'px',
|
72
|
+
left: item.info.left + 'px',
|
73
|
+
zIndex: 10000 - position,
|
74
|
+
})
|
75
|
+
body.append(canvas)
|
76
|
+
body.append(eventlayer)
|
77
|
+
}
|
78
|
+
} else if (action === 'ready') {
|
79
|
+
app.setReconnecting(false)
|
80
|
+
if (cancelReconnectionTimer?.clearTimeout) {
|
81
|
+
cancelReconnectionTimer()
|
82
|
+
cancelReconnectionTimer = false
|
83
|
+
}
|
84
|
+
const width = $(window).width()
|
85
|
+
const height = $(window).height()
|
86
|
+
|
87
|
+
app.sendCommand(
|
88
|
+
'setResolution',
|
89
|
+
app.toSpiceResolution({
|
90
|
+
width: width,
|
91
|
+
height: height,
|
92
|
+
})
|
93
|
+
)
|
94
|
+
if (wdi.IntegrationBenchmarkEnabled) {
|
95
|
+
$('#integrationBenchmark').css({ display: 'inline' })
|
96
|
+
$('#launchWordButton').prop('disabled', false)
|
97
|
+
}
|
98
|
+
} else if (action === 'resolution') {
|
99
|
+
// Делаем выравнивание по центру
|
100
|
+
const { 0: width, 1: height } = params
|
101
|
+
setVmPosition(width, height)
|
102
|
+
} else if (action === 'windowResized') {
|
103
|
+
// Делаем выравнивание по центру
|
104
|
+
const { 0: width } = params
|
105
|
+
const left = (window.innerWidth - width) / 2
|
106
|
+
if (left >= 0) {
|
107
|
+
document.getElementById('canvas_0').style.left = left + 'px'
|
108
|
+
document.getElementById('eventLayer').style.left = left + 'px'
|
109
|
+
}
|
110
|
+
} else if (action === 'windowMinimized') {
|
111
|
+
$(params.canvas).css({ display: 'none' })
|
112
|
+
$(params.eventLayer).css({ display: 'none' })
|
113
|
+
} else if (action === 'windowMaximized') {
|
114
|
+
$(params.canvas).css({
|
115
|
+
top: params.info.top + 'px',
|
116
|
+
left: params.info.left + 'px',
|
117
|
+
})
|
118
|
+
$(params.eventLayer).css({
|
119
|
+
top: params.info.top + 'px',
|
120
|
+
left: params.info.left + 'px',
|
121
|
+
})
|
122
|
+
} else if (action === 'windowRestored') {
|
123
|
+
$(params.canvas).css({ display: 'block' })
|
124
|
+
$(params.eventLayer).css({ display: 'block' })
|
125
|
+
$(params.canvas).css({
|
126
|
+
top: params.info.top + 'px',
|
127
|
+
left: params.info.left + 'px',
|
128
|
+
})
|
129
|
+
$(params.eventLayer).css({
|
130
|
+
top: params.info.top + 'px',
|
131
|
+
left: params.info.left + 'px',
|
132
|
+
})
|
133
|
+
} else if (action === 'windowFocused') {
|
134
|
+
//debugger; //eyeos should move the window to front!
|
135
|
+
} else if (action === 'timeLapseDetected') {
|
136
|
+
wdi.Debug.log('Detected time lapse of ', params, 'seconds')
|
137
|
+
} else if (action === 'error') {
|
138
|
+
if (!app.getReconnecting()) {
|
139
|
+
if (!cancelFreezeTimer) {
|
140
|
+
cancelFreezeTimer = setTimeout(function () {
|
141
|
+
console.log('cancelFreeze')
|
142
|
+
app.cancelFreeze()
|
143
|
+
}, 10000)
|
144
|
+
}
|
145
|
+
if (!cancelReconnectionTimer) {
|
146
|
+
cancelReconnectionTimer = setTimeout(function () {
|
147
|
+
console.log('cancel reconnection')
|
148
|
+
cancelReconnection = true
|
149
|
+
}, 60000)
|
150
|
+
}
|
151
|
+
}
|
152
|
+
|
153
|
+
setTimeout(function () {
|
154
|
+
if (!cancelReconnection) {
|
155
|
+
console.log('Trying reconnect ', Date.now())
|
156
|
+
app.reconnect({
|
157
|
+
freeze: true,
|
158
|
+
})
|
159
|
+
}
|
160
|
+
}, 1000)
|
161
|
+
}
|
162
|
+
}
|
163
|
+
|
164
|
+
$(window)['resize'](function () {
|
165
|
+
app.sendCommand(
|
166
|
+
'setResolution',
|
167
|
+
app.toSpiceResolution({
|
168
|
+
width: $(window).width(),
|
169
|
+
height: $(window).height(),
|
170
|
+
})
|
171
|
+
)
|
172
|
+
})
|
173
|
+
|
174
|
+
const runParams = {
|
175
|
+
callback: handleWindowAction,
|
176
|
+
context: this,
|
177
|
+
host: vmHost,
|
178
|
+
port: vmPort,
|
179
|
+
protocol: 'wss',
|
180
|
+
// 'vmToken': getURLParameter('vmtoken') || '',
|
181
|
+
token: 'password',
|
182
|
+
vmHost: vmHost,
|
183
|
+
vmPort: vmPort,
|
184
|
+
vmid: vmId,
|
185
|
+
useBus: false,
|
186
|
+
busHost: 'localhost',
|
187
|
+
busPort: 61613,
|
188
|
+
busSubscriptions: ['/topic/00000000-0000-0000-0000-000000000000'],
|
189
|
+
busUser: '00000000-0000-0000-0000-000000000000',
|
190
|
+
busPass: 'potato',
|
191
|
+
layout: 'es',
|
192
|
+
useWorkers: true,
|
193
|
+
seamlessDesktopIntegration: false,
|
194
|
+
connectionControl: false,
|
195
|
+
heartbeatToken: 'heartbeat',
|
196
|
+
heartbeatTimeout: 4000, //miliseconds
|
197
|
+
externalClipboardHandling: false,
|
198
|
+
disableClipboard: false,
|
199
|
+
layer: document.getElementById('vmw'),
|
200
|
+
// vmInfoToken: getURLParameter('vmInfoToken'),
|
201
|
+
disableMessageBuffering: true,
|
202
|
+
clientOffset: {
|
203
|
+
x: 0,
|
204
|
+
y: 0,
|
205
|
+
},
|
206
|
+
}
|
207
|
+
app.run(runParams)
|
208
|
+
}
|
209
|
+
|
210
|
+
$(document).ready(start)
|