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