bfg-common 1.4.534 → 1.4.536

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.
@@ -40,27 +40,25 @@
40
40
  >
41
41
  {{ localization.common.sendAltCommand }}
42
42
  </button>
43
- <label
44
- for="upload-folder"
45
- class="vmw-drawer-body__btn animation toggle-fullscreen"
46
- >
43
+ <label class="vmw-drawer-body__btn animation relative">
47
44
  {{ localization.remoteConsole.uploadFolder }}
45
+ <input type="file" webkitdirectory directory multiple />
48
46
  </label>
49
- <input
50
- id="upload-folder"
51
- type="file"
52
- webkitdirectory
53
- directory
54
- multiple
55
- />
56
-
57
- <label
58
- for="upload-files"
59
- class="vmw-drawer-body__btn animation toggle-fullscreen"
60
- >
47
+ <label class="vmw-drawer-body__btn animation relative">
61
48
  {{ localization.remoteConsole.uploadFiles }}
49
+ <input type="file" multiple />
62
50
  </label>
63
- <input id="upload-files" type="file" multiple />
51
+
52
+ <select v-model="usbDevice" @change="onChangeUsbDevice">
53
+ <option
54
+ v-for="item in usbDevices"
55
+ :key="item.value"
56
+ :value="item.value"
57
+ :disabled="item.disabled"
58
+ >
59
+ {{ item.label }}
60
+ </option>
61
+ </select>
64
62
 
65
63
  <select
66
64
  v-model="codec"
@@ -98,8 +96,13 @@
98
96
  </template>
99
97
  <script setup lang="ts">
100
98
  import { useDraggable } from '@vueuse/core'
99
+ import type { UI_I_DeviceOption } from '~/components/common/spiceConsole/lib/models/interfaces'
101
100
  import type { UI_I_Localization } from '~/lib/models/interfaces'
102
101
  import type { UI_T_CODEC } from '~/components/common/spiceConsole/lib/models/types'
102
+ import {
103
+ getUSBDeviceType,
104
+ identifyHIDDevice,
105
+ } from '~/components/common/spiceConsole/lib/utils/getDeviceType'
103
106
 
104
107
  const emits = defineEmits<{
105
108
  (event: 'toggle-fullscreen'): void
@@ -112,7 +115,7 @@ const onChangeCodec = (): void => {
112
115
  if (!window.app) return
113
116
  // @ts-ignore
114
117
  const channels = window.app.spiceConnection.channels
115
- for (let i in channels) {
118
+ for (const i in channels) {
116
119
  const channel = channels[i]
117
120
  if (channel.channel === wdi.SpiceVars.SPICE_CHANNEL_DISPLAY) {
118
121
  channel.changeCodec(codec.value)
@@ -145,7 +148,7 @@ watch(y, () => {
145
148
  })
146
149
 
147
150
  let isDrag = false
148
- const toggleDrawer = () => {
151
+ const toggleDrawer = (): void => {
149
152
  if (isDrag) {
150
153
  isDrag = false
151
154
  return
@@ -171,6 +174,63 @@ const displaySizeInfo = (): void => {
171
174
  requestAnimationFrame(displaySizeInfo)
172
175
  }
173
176
  displaySizeInfo()
177
+
178
+ const usbDevice = ref<number | string>(-1)
179
+ const usbDevices = ref<UI_I_DeviceOption[]>([
180
+ { label: 'USB Device', value: -1, disabled: true },
181
+ { label: 'Add USB device', value: -2 },
182
+ ])
183
+ const onChangeUsbDevice = (data: any): void => {
184
+ if (data.target.value === '-2') {
185
+ getUSBDeviceInformation()
186
+ }
187
+ }
188
+
189
+ const getUSBDeviceInformation = async (): Promise<void> => {
190
+ try {
191
+ // Запросить устройство
192
+ const device = await navigator.usb.requestDevice({ filters: [] })
193
+ usbDevice.value = setDevice(device)
194
+ } catch (error) {
195
+ console.error('Error:', error)
196
+ }
197
+ }
198
+
199
+ const setDevice = (device: any): string => {
200
+ const interfaces = device.configuration.interfaces
201
+
202
+ const types: any = new Set()
203
+ interfaces.forEach((item: any) => {
204
+ const classCode = item.alternate.interfaceClass
205
+ const subclassCode = item.alternate.interfaceSubclass
206
+ const protocolCode = item.alternate.interfaceProtocol
207
+
208
+ if (classCode === 0x03) {
209
+ // HID класс
210
+ types.add(identifyHIDDevice(subclassCode, protocolCode))
211
+ } else {
212
+ types.add(getUSBDeviceType(classCode))
213
+ }
214
+ })
215
+
216
+ const value = `${device.productId}_${device.vendorId}`
217
+ if (usbDevices.value.every((device) => device.value !== value)) {
218
+ usbDevices.value.push({
219
+ value,
220
+ label: Array.from(types).join(' / '),
221
+ })
222
+ }
223
+
224
+ return value
225
+ }
226
+
227
+ const setDefaultDevices = async (): Promise<void> => {
228
+ const devices = await navigator.usb.getDevices()
229
+ devices.forEach((device: any) => {
230
+ setDevice(device)
231
+ })
232
+ }
233
+ setDefaultDevices()
174
234
  </script>
175
235
  <style lang="scss" scoped>
176
236
  .vmw-drawer {
@@ -181,6 +241,7 @@ displaySizeInfo()
181
241
  width: 300px;
182
242
  height: 100vh;
183
243
  padding: 20px;
244
+ z-index: 9999;
184
245
 
185
246
  &.show {
186
247
  right: 0;
@@ -275,7 +336,12 @@ displaySizeInfo()
275
336
  }
276
337
 
277
338
  input[type='file'] {
278
- display: none;
339
+ position: absolute;
340
+ top: 0;
341
+ left: 0;
342
+ right: 0;
343
+ bottom: 0;
344
+ opacity: 0;
279
345
  }
280
346
  }
281
347
 
@@ -0,0 +1,5 @@
1
+ export interface UI_I_DeviceOption {
2
+ label: string
3
+ value: any
4
+ disabled?: boolean
5
+ }
@@ -0,0 +1,36 @@
1
+ export const getUSBDeviceType = (classCode: any): string => {
2
+ const deviceClasses = {
3
+ 0x00: 'Undefined',
4
+ 0x01: 'Audio',
5
+ 0x02: 'Communications and CDC Control',
6
+ 0x03: 'HID (Human Interface Device)',
7
+ 0x05: 'Physical Interface Device',
8
+ 0x06: 'Image (Scanner/Camera)',
9
+ 0x07: 'Printer',
10
+ 0x08: 'Mass Storage (e.g., Flash Drive)',
11
+ 0x09: 'Hub',
12
+ 0x0a: 'CDC-Data',
13
+ 0x0b: 'Smart Card',
14
+ 0x0d: 'Content Security',
15
+ 0x0e: 'Video',
16
+ 0x0f: 'Personal Healthcare',
17
+ 0x10: 'Audio/Video Devices',
18
+ 0x11: 'Billboard Device',
19
+ 0x12: 'USB Type-C Bridge',
20
+ 0xdc: 'Diagnostic Device',
21
+ 0xe0: 'Wireless Controller',
22
+ 0xef: 'Miscellaneous',
23
+ 0xfe: 'Application-Specific',
24
+ 0xff: 'Vendor-Specific',
25
+ }
26
+ return deviceClasses[classCode] || 'Unknown'
27
+ }
28
+
29
+ // Функция для определения типа HID-устройства
30
+ export const identifyHIDDevice = (subclass: any, protocol: any): string => {
31
+ if (subclass === 0x01) {
32
+ if (protocol === 0x01) return 'Keyboard'
33
+ if (protocol === 0x02) return 'Mouse'
34
+ }
35
+ return 'Generic HID Device'
36
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bfg-common",
3
3
  "private": false,
4
- "version": "1.4.534",
4
+ "version": "1.4.536",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",