@device-management-toolkit/ui-toolkit-angular 11.1.8 → 12.0.0

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.
@@ -1,372 +1,587 @@
1
- import * as i0 from '@angular/core';
2
- import { inject, Renderer2, DestroyRef, viewChild, signal, input, output, effect, Component } from '@angular/core';
3
- import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
4
- import { Protocol, AMTKvmDataRedirector, AMTDesktop, DataProcessor, MouseHelper, KeyBoardHelper } from '@device-management-toolkit/ui-toolkit/core';
5
- import { fromEvent, timer } from 'rxjs';
6
- import { throttleTime } from 'rxjs/operators';
7
-
8
- /*********************************************************************
9
- * Copyright (c) Intel Corporation 2023
10
- * SPDX-License-Identifier: Apache-2.0
11
- **********************************************************************/
12
- class KVMComponent {
13
- constructor() {
14
- this.renderer = inject(Renderer2);
15
- this.destroyRef = inject(DestroyRef);
16
- this.KEY_SEQUENCE_DELAY_MS = 10;
17
- this.canvas = viewChild('canvas', ...(ngDevMode ? [{ debugName: "canvas" }] : /* istanbul ignore next */ []));
18
- this.device = viewChild.required('device');
19
- // Canvas properties
20
- this.context = null;
21
- this.width = signal(400, ...(ngDevMode ? [{ debugName: "width" }] : /* istanbul ignore next */ []));
22
- this.height = signal(400, ...(ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []));
23
- // Input properties
24
- this.isFullscreen = input(false, ...(ngDevMode ? [{ debugName: "isFullscreen" }] : /* istanbul ignore next */ []));
25
- this.mpsServer = input('', ...(ngDevMode ? [{ debugName: "mpsServer" }] : /* istanbul ignore next */ []));
26
- this.authToken = input('', ...(ngDevMode ? [{ debugName: "authToken" }] : /* istanbul ignore next */ []));
27
- this.deviceId = input('', ...(ngDevMode ? [{ debugName: "deviceId" }] : /* istanbul ignore next */ []));
28
- // Input/Output properties
29
- this.deviceStatus = output();
30
- this.deviceConnection = input(false, ...(ngDevMode ? [{ debugName: "deviceConnection" }] : /* istanbul ignore next */ []));
31
- this.selectedEncoding = input(1, ...(ngDevMode ? [{ debugName: "selectedEncoding" }] : /* istanbul ignore next */ []));
32
- this.selectedHotkey = input('', ...(ngDevMode ? [{ debugName: "selectedHotkey" }] : /* istanbul ignore next */ []));
33
- // Component state
34
- this.module = null;
35
- this.redirector = null;
36
- this.dataProcessor = null;
37
- this.mouseHelper = null;
38
- this.keyboardHelper = null;
39
- this.selected = signal(1, ...(ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []));
40
- this.isEncodingChange = false;
41
- this.encodings = [
42
- { value: 1, viewValue: 'RLE 8' },
43
- { value: 2, viewValue: 'RLE 16' }
44
- ];
45
- this.onConnectionStateChange = (redirector, state) => {
46
- this.deviceStatus.emit(state);
47
- };
48
- effect(() => {
49
- this.toggleFullscreen();
50
- });
51
- // React to deviceConnection changes
52
- effect(() => {
53
- const connected = this.deviceConnection();
54
- if (connected && this.redirector == null && !this.isEncodingChange) {
55
- console.log('KVMComponent: Device connected, initializing KVM...');
56
- this.init();
57
- }
58
- else if (!connected && this.redirector != null) {
59
- console.log('KVMComponent: Device disconnected, stopping KVM...');
60
- this.stopKvm();
61
- }
62
- });
63
- // React to selectedEncoding changes
64
- effect(() => {
65
- if (this.selectedEncoding() === this.selected() || !this.deviceConnection())
66
- return;
67
- console.log('KVMComponent: Encoding changed to', this.selectedEncoding());
68
- const encoding = this.selectedEncoding();
69
- this.selected.set(encoding);
70
- // Set flag to prevent connection effect interference
71
- if (this.redirector != null) {
72
- this.isEncodingChange = true;
73
- this.onEncodingChange();
74
- }
75
- });
76
- // React to selectedHotkey changes
77
- effect(() => {
78
- const hotkey = this.selectedHotkey();
79
- if (hotkey && this.deviceConnection() && this.keyboardHelper) {
80
- console.log('KVMComponent: Hotkey triggered:', hotkey);
81
- this.sendHotkey(hotkey);
82
- }
83
- });
84
- }
85
- toggleFullscreen() {
86
- const canvasElement = this.canvas()?.nativeElement;
87
- if (!canvasElement)
88
- return;
89
- if (this.isFullscreen()) {
90
- if (canvasElement.requestFullscreen) {
91
- canvasElement.requestFullscreen();
92
- }
93
- this.renderer.addClass(canvasElement, 'fullscreen');
94
- }
95
- else {
96
- if (document.exitFullscreen && document.fullscreenElement != null) {
97
- document.exitFullscreen();
98
- }
99
- this.renderer.removeClass(canvasElement, 'fullscreen');
100
- }
101
- this.mouseHelper?.resetOffsets();
102
- }
103
- instantiate() {
104
- const canvas = this.canvas();
105
- this.context = canvas?.nativeElement.getContext('2d') || null;
106
- const config = {
107
- mode: 'kvm',
108
- protocol: Protocol.KVM,
109
- fr: new FileReader(),
110
- host: this.deviceId(),
111
- port: 16994,
112
- user: '',
113
- pass: '',
114
- tls: 0,
115
- tls1only: 0,
116
- authToken: this.authToken(),
117
- server: this.mpsServer()
118
- };
119
- this.redirector = new AMTKvmDataRedirector(config);
120
- this.module = new AMTDesktop(this.context);
121
- this.dataProcessor = new DataProcessor(this.redirector, this.module);
122
- this.mouseHelper = new MouseHelper(this.module, this.redirector, 200);
123
- this.keyboardHelper = new KeyBoardHelper(this.module, this.redirector);
124
- this.redirector.onProcessData = this.module.processData.bind(this.module);
125
- this.redirector.onStart = this.module.start.bind(this.module);
126
- this.redirector.onNewState = this.module.onStateChange.bind(this.module);
127
- this.redirector.onSendKvmData = this.module.onSendKvmData.bind(this.module);
128
- this.redirector.onStateChanged = this.onConnectionStateChange.bind(this);
129
- this.redirector.onError = this.onRedirectorError.bind(this);
130
- this.module.onSend = this.redirector.send.bind(this.redirector);
131
- this.module.onProcessData = this.dataProcessor.processData.bind(this.dataProcessor);
132
- this.module.bpp = this.selected();
133
- this.mouseMove$ = fromEvent(canvas?.nativeElement, 'mousemove')
134
- .pipe(throttleTime(200), takeUntilDestroyed(this.destroyRef))
135
- .subscribe((event) => {
136
- this.mouseHelper?.mousemove(event);
137
- });
138
- }
139
- onRedirectorError() {
140
- this.reset();
141
- }
142
- init() {
143
- this.instantiate();
144
- setTimeout(() => {
145
- this.autoConnect();
146
- }, 4000);
147
- }
148
- autoConnect() {
149
- if (this.redirector) {
150
- this.redirector.start(WebSocket);
151
- this.keyboardHelper?.GrabKeyInput();
152
- }
153
- }
154
- onEncodingChange() {
155
- this.stopKvm();
156
- timer(1000).subscribe(() => {
157
- // Need to reinitialize since stopKvm() reset the redirector to null
158
- this.init();
159
- // Note: Parent component handles clearing isEncodingChange flag after full process
160
- });
161
- }
162
- reset() {
163
- this.redirector = null;
164
- this.module = null;
165
- this.dataProcessor = null;
166
- this.height.set(400);
167
- this.width.set(400);
168
- }
169
- stopKvm() {
170
- this.redirector?.stop();
171
- this.keyboardHelper?.UnGrabKeyInput();
172
- this.reset();
173
- }
174
- onMouseup(event) {
175
- this.mouseHelper?.mouseup(event);
176
- }
177
- onMousedown(event) {
178
- this.mouseHelper?.mousedown(event);
179
- }
180
- onMousemove(event) {
181
- this.mouseHelper?.mousemove(event);
182
- }
183
- sendHotkey(hotKeyType) {
184
- if (!this.keyboardHelper) {
185
- console.warn('KVMComponent: Cannot send hotkey - keyboard helper not available');
186
- return;
187
- }
188
- const keySequence = this.getKeySequence(hotKeyType);
189
- if (keySequence?.keys) {
190
- console.log('KVMComponent: Sending hotkey sequence for', hotKeyType);
191
- // Send each key in the sequence with a small delay
192
- keySequence.keys.forEach((key, index) => {
193
- setTimeout(() => {
194
- // Use the KeyboardHelper's existing handleKeyEvent method
195
- // 0 = Up, 1 = Down (from the UpDown enum)
196
- const upDown = key.down ? 1 : 0;
197
- // Create a mock keyboard event with the key code
198
- const mockEvent = {
199
- keyCode: key.code,
200
- preventDefault: () => { },
201
- stopPropagation: () => { }
202
- };
203
- // Use the existing handleKeyEvent method
204
- this.keyboardHelper.handleKeyEvent(upDown, mockEvent);
205
- }, index * this.KEY_SEQUENCE_DELAY_MS); // delay between keys
206
- });
207
- }
208
- }
209
- getKeySequence(hotKeyType) {
210
- // Check for function key patterns (alt-f1 to alt-f12, ctrl-alt-f1 to ctrl-alt-f12)
211
- const altFnMatch = hotKeyType.match(/^alt-f(\d+)$/);
212
- const ctrlAltFnMatch = hotKeyType.match(/^ctrl-alt-f(\d+)$/);
213
- if (altFnMatch) {
214
- const fnNum = parseInt(altFnMatch[1], 10);
215
- return this.buildFunctionKeySequence(fnNum, false);
216
- }
217
- if (ctrlAltFnMatch) {
218
- const fnNum = parseInt(ctrlAltFnMatch[1], 10);
219
- return this.buildFunctionKeySequence(fnNum, true);
220
- }
221
- // Handle other hotkey combinations
222
- switch (hotKeyType) {
223
- case 'ctrl-alt-del':
224
- return {
225
- keys: [
226
- { code: 17, down: true }, // Ctrl down (JS keyCode)
227
- { code: 18, down: true }, // Alt down (JS keyCode)
228
- { code: 46, down: true }, // Delete down (JS keyCode)
229
- { code: 46, down: false }, // Delete up (JS keyCode)
230
- { code: 18, down: false }, // Alt up (JS keyCode)
231
- { code: 17, down: false } // Ctrl up (JS keyCode)
232
- ]
233
- };
234
- case 'alt-tab':
235
- return {
236
- keys: [
237
- { code: 18, down: true }, // Alt down (JS keyCode)
238
- { code: 9, down: true }, // Tab down (JS keyCode)
239
- { code: 9, down: false }, // Tab up (JS keyCode)
240
- { code: 18, down: false } // Alt up (JS keyCode)
241
- ]
242
- };
243
- case 'alt-release':
244
- return {
245
- keys: [
246
- { code: 18, down: false } // Alt up (JS keyCode)
247
- ]
248
- };
249
- case 'windows':
250
- return {
251
- keys: [
252
- { code: 0xffe7, down: true }, // Windows key down
253
- { code: 0xffe7, down: false } // Windows key up
254
- ]
255
- };
256
- case 'windows-l':
257
- return {
258
- keys: [
259
- { code: 0xffe7, down: true }, // Windows down
260
- { code: 108, down: true }, // L down
261
- { code: 108, down: false }, // L up
262
- { code: 0xffe7, down: false } // Windows up
263
- ]
264
- };
265
- case 'windows-r':
266
- return {
267
- keys: [
268
- { code: 0xffe7, down: true }, // Windows down
269
- { code: 82, down: true }, // R down
270
- { code: 82, down: false }, // R up
271
- { code: 0xffe7, down: false } // Windows up
272
- ]
273
- };
274
- case 'windows-up':
275
- return {
276
- keys: [
277
- { code: 0xffe7, down: true }, // Windows down
278
- { code: 0xff52, down: true }, // Up arrow down
279
- { code: 0xff52, down: false }, // Up arrow up
280
- { code: 0xffe7, down: false } // Windows up
281
- ]
282
- };
283
- case 'windows-down':
284
- return {
285
- keys: [
286
- { code: 0xffe7, down: true }, // Windows down
287
- { code: 0xff54, down: true }, // Down arrow down
288
- { code: 0xff54, down: false }, // Down arrow up
289
- { code: 0xffe7, down: false } // Windows up
290
- ]
291
- };
292
- case 'windows-left':
293
- return {
294
- keys: [
295
- { code: 0xffe7, down: true }, // Windows down
296
- { code: 0xff51, down: true }, // Left arrow down
297
- { code: 0xff51, down: false }, // Left arrow up
298
- { code: 0xffe7, down: false } // Windows up
299
- ]
300
- };
301
- case 'windows-right':
302
- return {
303
- keys: [
304
- { code: 0xffe7, down: true }, // Windows down
305
- { code: 0xff53, down: true }, // Right arrow down
306
- { code: 0xff53, down: false }, // Right arrow up
307
- { code: 0xffe7, down: false } // Windows up
308
- ]
309
- };
310
- case 'ctrl-w':
311
- return {
312
- keys: [
313
- { code: 0xffe3, down: true }, // Ctrl down
314
- { code: 87, down: true }, // W down
315
- { code: 87, down: false }, // W up
316
- { code: 0xffe3, down: false } // Ctrl up
317
- ]
318
- };
319
- default:
320
- return null;
321
- }
322
- }
323
- buildFunctionKeySequence(fnNum, includeCtrl) {
324
- // Validate function key number (F1-F12)
325
- if (fnNum < 1 || fnNum > 12) {
326
- return null;
327
- }
328
- // Calculate function key code: F1 = 0xffbe, F2 = 0xffbf, ..., F12 = 0xffc9
329
- const fnKeyCode = 0xffbe + (fnNum - 1);
330
- const keys = [];
331
- // Add Ctrl if needed
332
- if (includeCtrl) {
333
- keys.push({ code: 0xffe3, down: true }); // Ctrl down
334
- }
335
- // Add Alt
336
- keys.push({ code: 0xffe9, down: true }); // Alt down
337
- // Add function key press
338
- keys.push({ code: fnKeyCode, down: true }); // Fn down
339
- keys.push({ code: fnKeyCode, down: false }); // Fn up
340
- // Release modifiers in reverse order
341
- keys.push({ code: 0xffe9, down: false }); // Alt up
342
- if (includeCtrl) {
343
- keys.push({ code: 0xffe3, down: false }); // Ctrl up
344
- }
345
- return { keys };
346
- }
347
- ngOnDestroy() {
348
- this.mouseMove$?.unsubscribe();
349
- this.stopKvm();
350
- }
351
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.21", ngImport: i0, type: KVMComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
352
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "21.2.21", type: KVMComponent, isStandalone: true, selector: "amt-kvm", inputs: { isFullscreen: { classPropertyName: "isFullscreen", publicName: "isFullscreen", isSignal: true, isRequired: false, transformFunction: null }, mpsServer: { classPropertyName: "mpsServer", publicName: "mpsServer", isSignal: true, isRequired: false, transformFunction: null }, authToken: { classPropertyName: "authToken", publicName: "authToken", isSignal: true, isRequired: false, transformFunction: null }, deviceId: { classPropertyName: "deviceId", publicName: "deviceId", isSignal: true, isRequired: false, transformFunction: null }, deviceConnection: { classPropertyName: "deviceConnection", publicName: "deviceConnection", isSignal: true, isRequired: false, transformFunction: null }, selectedEncoding: { classPropertyName: "selectedEncoding", publicName: "selectedEncoding", isSignal: true, isRequired: false, transformFunction: null }, selectedHotkey: { classPropertyName: "selectedHotkey", publicName: "selectedHotkey", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { deviceStatus: "deviceStatus" }, viewQueries: [{ propertyName: "canvas", first: true, predicate: ["canvas"], descendants: true, isSignal: true }, { propertyName: "device", first: true, predicate: ["device"], descendants: true, isSignal: true }], ngImport: i0, template: "<div>\n <canvas\n class=\"canvas\"\n #canvas\n [width]=\"width\"\n [height]=\"height\"\n oncontextmenu=\"return false\"\n (mouseup)=\"onMouseup($event)\"\n (mousedown)=\"onMousedown($event)\"\n (mousemove)=\"onMousemove($event)\"></canvas>\n</div>\n", styles: [".canvas{max-height:80%;max-width:100%}canvas.fullscreen{height:100vh!important}\n"] }); }
353
- }
354
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.21", ngImport: i0, type: KVMComponent, decorators: [{
355
- type: Component,
356
- args: [{ selector: 'amt-kvm', template: "<div>\n <canvas\n class=\"canvas\"\n #canvas\n [width]=\"width\"\n [height]=\"height\"\n oncontextmenu=\"return false\"\n (mouseup)=\"onMouseup($event)\"\n (mousedown)=\"onMousedown($event)\"\n (mousemove)=\"onMousemove($event)\"></canvas>\n</div>\n", styles: [".canvas{max-height:80%;max-width:100%}canvas.fullscreen{height:100vh!important}\n"] }]
357
- }], ctorParameters: () => [], propDecorators: { canvas: [{ type: i0.ViewChild, args: ['canvas', { isSignal: true }] }], device: [{ type: i0.ViewChild, args: ['device', { isSignal: true }] }], isFullscreen: [{ type: i0.Input, args: [{ isSignal: true, alias: "isFullscreen", required: false }] }], mpsServer: [{ type: i0.Input, args: [{ isSignal: true, alias: "mpsServer", required: false }] }], authToken: [{ type: i0.Input, args: [{ isSignal: true, alias: "authToken", required: false }] }], deviceId: [{ type: i0.Input, args: [{ isSignal: true, alias: "deviceId", required: false }] }], deviceStatus: [{ type: i0.Output, args: ["deviceStatus"] }], deviceConnection: [{ type: i0.Input, args: [{ isSignal: true, alias: "deviceConnection", required: false }] }], selectedEncoding: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedEncoding", required: false }] }], selectedHotkey: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedHotkey", required: false }] }] } });
358
-
359
- /*********************************************************************
360
- * Copyright (c) Intel Corporation 2023
361
- * SPDX-License-Identifier: Apache-2.0
362
- **********************************************************************/
363
- /*
364
- * Public API Surface of kvm
365
- */
366
-
367
- /**
368
- * Generated bundle index. Do not edit.
369
- */
370
-
1
+ import * as i0 from "@angular/core";
2
+ import { Component, DestroyRef, Renderer2, effect, inject, input, output, signal, viewChild } from "@angular/core";
3
+ import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
4
+ import { AMTDesktop, AMTKvmDataRedirector, DataProcessor, KeyBoardHelper, MouseHelper, Protocol } from "@device-management-toolkit/ui-toolkit/core";
5
+ import { fromEvent, timer } from "rxjs";
6
+ import { throttleTime } from "rxjs/operators";
7
+ var KVMComponent = class KVMComponent {
8
+ constructor() {
9
+ this.renderer = inject(Renderer2);
10
+ this.destroyRef = inject(DestroyRef);
11
+ this.KEY_SEQUENCE_DELAY_MS = 10;
12
+ this.canvas = viewChild("canvas", ...ngDevMode ? [{ debugName: "canvas" }] : /* istanbul ignore next */ []);
13
+ this.device = viewChild.required("device", ...ngDevMode ? [{ debugName: "device" }] : /* istanbul ignore next */ []);
14
+ this.context = null;
15
+ this.width = signal(400, ...ngDevMode ? [{ debugName: "width" }] : /* istanbul ignore next */ []);
16
+ this.height = signal(400, ...ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []);
17
+ this.isFullscreen = input(false, ...ngDevMode ? [{ debugName: "isFullscreen" }] : /* istanbul ignore next */ []);
18
+ this.mpsServer = input("", ...ngDevMode ? [{ debugName: "mpsServer" }] : /* istanbul ignore next */ []);
19
+ this.authToken = input("", ...ngDevMode ? [{ debugName: "authToken" }] : /* istanbul ignore next */ []);
20
+ this.deviceId = input("", ...ngDevMode ? [{ debugName: "deviceId" }] : /* istanbul ignore next */ []);
21
+ this.deviceStatus = output();
22
+ this.deviceConnection = input(false, ...ngDevMode ? [{ debugName: "deviceConnection" }] : /* istanbul ignore next */ []);
23
+ this.selectedEncoding = input(1, ...ngDevMode ? [{ debugName: "selectedEncoding" }] : /* istanbul ignore next */ []);
24
+ this.selectedHotkey = input("", ...ngDevMode ? [{ debugName: "selectedHotkey" }] : /* istanbul ignore next */ []);
25
+ this.module = null;
26
+ this.redirector = null;
27
+ this.dataProcessor = null;
28
+ this.mouseHelper = null;
29
+ this.keyboardHelper = null;
30
+ this.selected = signal(1, ...ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []);
31
+ this.isEncodingChange = false;
32
+ this.encodings = [{
33
+ value: 1,
34
+ viewValue: "RLE 8"
35
+ }, {
36
+ value: 2,
37
+ viewValue: "RLE 16"
38
+ }];
39
+ this.onConnectionStateChange = (redirector, state) => {
40
+ this.deviceStatus.emit(state);
41
+ };
42
+ effect(() => {
43
+ this.toggleFullscreen();
44
+ });
45
+ effect(() => {
46
+ const connected = this.deviceConnection();
47
+ if (connected && this.redirector == null && !this.isEncodingChange) {
48
+ console.log("KVMComponent: Device connected, initializing KVM...");
49
+ this.init();
50
+ } else if (!connected && this.redirector != null) {
51
+ console.log("KVMComponent: Device disconnected, stopping KVM...");
52
+ this.stopKvm();
53
+ }
54
+ });
55
+ effect(() => {
56
+ if (this.selectedEncoding() === this.selected() || !this.deviceConnection()) return;
57
+ console.log("KVMComponent: Encoding changed to", this.selectedEncoding());
58
+ const encoding = this.selectedEncoding();
59
+ this.selected.set(encoding);
60
+ if (this.redirector != null) {
61
+ this.isEncodingChange = true;
62
+ this.onEncodingChange();
63
+ }
64
+ });
65
+ effect(() => {
66
+ const hotkey = this.selectedHotkey();
67
+ if (hotkey && this.deviceConnection() && this.keyboardHelper) {
68
+ console.log("KVMComponent: Hotkey triggered:", hotkey);
69
+ this.sendHotkey(hotkey);
70
+ }
71
+ });
72
+ }
73
+ toggleFullscreen() {
74
+ const canvasElement = this.canvas()?.nativeElement;
75
+ if (!canvasElement) return;
76
+ if (this.isFullscreen()) {
77
+ if (canvasElement.requestFullscreen) canvasElement.requestFullscreen();
78
+ this.renderer.addClass(canvasElement, "fullscreen");
79
+ } else {
80
+ if (document.exitFullscreen && document.fullscreenElement != null) document.exitFullscreen();
81
+ this.renderer.removeClass(canvasElement, "fullscreen");
82
+ }
83
+ this.mouseHelper?.resetOffsets();
84
+ }
85
+ instantiate() {
86
+ const canvas = this.canvas();
87
+ this.context = canvas?.nativeElement.getContext("2d") || null;
88
+ const config = {
89
+ mode: "kvm",
90
+ protocol: Protocol.KVM,
91
+ fr: new FileReader(),
92
+ host: this.deviceId(),
93
+ port: 16994,
94
+ user: "",
95
+ pass: "",
96
+ tls: 0,
97
+ tls1only: 0,
98
+ authToken: this.authToken(),
99
+ server: this.mpsServer()
100
+ };
101
+ this.redirector = new AMTKvmDataRedirector(config);
102
+ this.module = new AMTDesktop(this.context);
103
+ this.dataProcessor = new DataProcessor(this.redirector, this.module);
104
+ this.mouseHelper = new MouseHelper(this.module, this.redirector, 200);
105
+ this.keyboardHelper = new KeyBoardHelper(this.module, this.redirector);
106
+ this.redirector.onProcessData = this.module.processData.bind(this.module);
107
+ this.redirector.onStart = this.module.start.bind(this.module);
108
+ this.redirector.onNewState = this.module.onStateChange.bind(this.module);
109
+ this.redirector.onSendKvmData = this.module.onSendKvmData.bind(this.module);
110
+ this.redirector.onStateChanged = this.onConnectionStateChange.bind(this);
111
+ this.redirector.onError = this.onRedirectorError.bind(this);
112
+ this.module.onSend = this.redirector.send.bind(this.redirector);
113
+ this.module.onProcessData = this.dataProcessor.processData.bind(this.dataProcessor);
114
+ this.module.bpp = this.selected();
115
+ this.mouseMove$ = fromEvent(canvas?.nativeElement, "mousemove").pipe(throttleTime(200), takeUntilDestroyed(this.destroyRef)).subscribe((event) => {
116
+ this.mouseHelper?.mousemove(event);
117
+ });
118
+ }
119
+ onRedirectorError() {
120
+ this.reset();
121
+ }
122
+ init() {
123
+ this.instantiate();
124
+ setTimeout(() => {
125
+ this.autoConnect();
126
+ }, 4e3);
127
+ }
128
+ autoConnect() {
129
+ if (this.redirector) {
130
+ this.redirector.start(WebSocket);
131
+ this.keyboardHelper?.GrabKeyInput();
132
+ }
133
+ }
134
+ onEncodingChange() {
135
+ this.stopKvm();
136
+ timer(1e3).subscribe(() => {
137
+ this.init();
138
+ });
139
+ }
140
+ reset() {
141
+ this.redirector = null;
142
+ this.module = null;
143
+ this.dataProcessor = null;
144
+ this.height.set(400);
145
+ this.width.set(400);
146
+ }
147
+ stopKvm() {
148
+ this.redirector?.stop();
149
+ this.keyboardHelper?.UnGrabKeyInput();
150
+ this.reset();
151
+ }
152
+ onMouseup(event) {
153
+ this.mouseHelper?.mouseup(event);
154
+ }
155
+ onMousedown(event) {
156
+ this.mouseHelper?.mousedown(event);
157
+ }
158
+ onMousemove(event) {
159
+ this.mouseHelper?.mousemove(event);
160
+ }
161
+ sendHotkey(hotKeyType) {
162
+ if (!this.keyboardHelper) {
163
+ console.warn("KVMComponent: Cannot send hotkey - keyboard helper not available");
164
+ return;
165
+ }
166
+ const keySequence = this.getKeySequence(hotKeyType);
167
+ if (keySequence?.keys) {
168
+ console.log("KVMComponent: Sending hotkey sequence for", hotKeyType);
169
+ keySequence.keys.forEach((key, index) => {
170
+ setTimeout(() => {
171
+ const upDown = key.down ? 1 : 0;
172
+ const mockEvent = {
173
+ keyCode: key.code,
174
+ preventDefault: () => {},
175
+ stopPropagation: () => {}
176
+ };
177
+ this.keyboardHelper.handleKeyEvent(upDown, mockEvent);
178
+ }, index * this.KEY_SEQUENCE_DELAY_MS);
179
+ });
180
+ }
181
+ }
182
+ getKeySequence(hotKeyType) {
183
+ const altFnMatch = hotKeyType.match(/^alt-f(\d+)$/);
184
+ const ctrlAltFnMatch = hotKeyType.match(/^ctrl-alt-f(\d+)$/);
185
+ if (altFnMatch) {
186
+ const fnNum = parseInt(altFnMatch[1], 10);
187
+ return this.buildFunctionKeySequence(fnNum, false);
188
+ }
189
+ if (ctrlAltFnMatch) {
190
+ const fnNum = parseInt(ctrlAltFnMatch[1], 10);
191
+ return this.buildFunctionKeySequence(fnNum, true);
192
+ }
193
+ switch (hotKeyType) {
194
+ case "ctrl-alt-del": return { keys: [
195
+ {
196
+ code: 17,
197
+ down: true
198
+ },
199
+ {
200
+ code: 18,
201
+ down: true
202
+ },
203
+ {
204
+ code: 46,
205
+ down: true
206
+ },
207
+ {
208
+ code: 46,
209
+ down: false
210
+ },
211
+ {
212
+ code: 18,
213
+ down: false
214
+ },
215
+ {
216
+ code: 17,
217
+ down: false
218
+ }
219
+ ] };
220
+ case "alt-tab": return { keys: [
221
+ {
222
+ code: 18,
223
+ down: true
224
+ },
225
+ {
226
+ code: 9,
227
+ down: true
228
+ },
229
+ {
230
+ code: 9,
231
+ down: false
232
+ },
233
+ {
234
+ code: 18,
235
+ down: false
236
+ }
237
+ ] };
238
+ case "alt-release": return { keys: [{
239
+ code: 18,
240
+ down: false
241
+ }] };
242
+ case "windows": return { keys: [{
243
+ code: 65511,
244
+ down: true
245
+ }, {
246
+ code: 65511,
247
+ down: false
248
+ }] };
249
+ case "windows-l": return { keys: [
250
+ {
251
+ code: 65511,
252
+ down: true
253
+ },
254
+ {
255
+ code: 108,
256
+ down: true
257
+ },
258
+ {
259
+ code: 108,
260
+ down: false
261
+ },
262
+ {
263
+ code: 65511,
264
+ down: false
265
+ }
266
+ ] };
267
+ case "windows-r": return { keys: [
268
+ {
269
+ code: 65511,
270
+ down: true
271
+ },
272
+ {
273
+ code: 82,
274
+ down: true
275
+ },
276
+ {
277
+ code: 82,
278
+ down: false
279
+ },
280
+ {
281
+ code: 65511,
282
+ down: false
283
+ }
284
+ ] };
285
+ case "windows-up": return { keys: [
286
+ {
287
+ code: 65511,
288
+ down: true
289
+ },
290
+ {
291
+ code: 65362,
292
+ down: true
293
+ },
294
+ {
295
+ code: 65362,
296
+ down: false
297
+ },
298
+ {
299
+ code: 65511,
300
+ down: false
301
+ }
302
+ ] };
303
+ case "windows-down": return { keys: [
304
+ {
305
+ code: 65511,
306
+ down: true
307
+ },
308
+ {
309
+ code: 65364,
310
+ down: true
311
+ },
312
+ {
313
+ code: 65364,
314
+ down: false
315
+ },
316
+ {
317
+ code: 65511,
318
+ down: false
319
+ }
320
+ ] };
321
+ case "windows-left": return { keys: [
322
+ {
323
+ code: 65511,
324
+ down: true
325
+ },
326
+ {
327
+ code: 65361,
328
+ down: true
329
+ },
330
+ {
331
+ code: 65361,
332
+ down: false
333
+ },
334
+ {
335
+ code: 65511,
336
+ down: false
337
+ }
338
+ ] };
339
+ case "windows-right": return { keys: [
340
+ {
341
+ code: 65511,
342
+ down: true
343
+ },
344
+ {
345
+ code: 65363,
346
+ down: true
347
+ },
348
+ {
349
+ code: 65363,
350
+ down: false
351
+ },
352
+ {
353
+ code: 65511,
354
+ down: false
355
+ }
356
+ ] };
357
+ case "ctrl-w": return { keys: [
358
+ {
359
+ code: 65507,
360
+ down: true
361
+ },
362
+ {
363
+ code: 87,
364
+ down: true
365
+ },
366
+ {
367
+ code: 87,
368
+ down: false
369
+ },
370
+ {
371
+ code: 65507,
372
+ down: false
373
+ }
374
+ ] };
375
+ default: return null;
376
+ }
377
+ }
378
+ buildFunctionKeySequence(fnNum, includeCtrl) {
379
+ if (fnNum < 1 || fnNum > 12) return null;
380
+ const fnKeyCode = 65470 + (fnNum - 1);
381
+ const keys = [];
382
+ if (includeCtrl) keys.push({
383
+ code: 65507,
384
+ down: true
385
+ });
386
+ keys.push({
387
+ code: 65513,
388
+ down: true
389
+ });
390
+ keys.push({
391
+ code: fnKeyCode,
392
+ down: true
393
+ });
394
+ keys.push({
395
+ code: fnKeyCode,
396
+ down: false
397
+ });
398
+ keys.push({
399
+ code: 65513,
400
+ down: false
401
+ });
402
+ if (includeCtrl) keys.push({
403
+ code: 65507,
404
+ down: false
405
+ });
406
+ return { keys };
407
+ }
408
+ ngOnDestroy() {
409
+ this.mouseMove$?.unsubscribe();
410
+ this.stopKvm();
411
+ }
412
+ static {
413
+ this.ɵfac = i0.ɵɵngDeclareFactory({
414
+ minVersion: "12.0.0",
415
+ version: "22.2.2",
416
+ ngImport: i0,
417
+ type: KVMComponent,
418
+ deps: [],
419
+ target: i0.ɵɵFactoryTarget.Component
420
+ });
421
+ }
422
+ static {
423
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
424
+ minVersion: "17.2.0",
425
+ version: "22.2.2",
426
+ type: KVMComponent,
427
+ isStandalone: true,
428
+ selector: "amt-kvm",
429
+ inputs: {
430
+ isFullscreen: {
431
+ classPropertyName: "isFullscreen",
432
+ publicName: "isFullscreen",
433
+ isSignal: true,
434
+ isRequired: false,
435
+ transformFunction: null
436
+ },
437
+ mpsServer: {
438
+ classPropertyName: "mpsServer",
439
+ publicName: "mpsServer",
440
+ isSignal: true,
441
+ isRequired: false,
442
+ transformFunction: null
443
+ },
444
+ authToken: {
445
+ classPropertyName: "authToken",
446
+ publicName: "authToken",
447
+ isSignal: true,
448
+ isRequired: false,
449
+ transformFunction: null
450
+ },
451
+ deviceId: {
452
+ classPropertyName: "deviceId",
453
+ publicName: "deviceId",
454
+ isSignal: true,
455
+ isRequired: false,
456
+ transformFunction: null
457
+ },
458
+ deviceConnection: {
459
+ classPropertyName: "deviceConnection",
460
+ publicName: "deviceConnection",
461
+ isSignal: true,
462
+ isRequired: false,
463
+ transformFunction: null
464
+ },
465
+ selectedEncoding: {
466
+ classPropertyName: "selectedEncoding",
467
+ publicName: "selectedEncoding",
468
+ isSignal: true,
469
+ isRequired: false,
470
+ transformFunction: null
471
+ },
472
+ selectedHotkey: {
473
+ classPropertyName: "selectedHotkey",
474
+ publicName: "selectedHotkey",
475
+ isSignal: true,
476
+ isRequired: false,
477
+ transformFunction: null
478
+ }
479
+ },
480
+ outputs: { deviceStatus: "deviceStatus" },
481
+ viewQueries: [{
482
+ propertyName: "canvas",
483
+ first: true,
484
+ predicate: ["canvas"],
485
+ descendants: true,
486
+ isSignal: true
487
+ }, {
488
+ propertyName: "device",
489
+ first: true,
490
+ predicate: ["device"],
491
+ descendants: true,
492
+ isSignal: true
493
+ }],
494
+ ngImport: i0,
495
+ template: "<div>\n <canvas\n class=\"canvas\"\n #canvas\n [width]=\"width()\"\n [height]=\"height()\"\n oncontextmenu=\"return false\"\n (mouseup)=\"onMouseup($event)\"\n (mousedown)=\"onMousedown($event)\"\n (mousemove)=\"onMousemove($event)\"></canvas>\n</div>\n",
496
+ styles: [".canvas{max-height:80%;max-width:100%}canvas.fullscreen{height:100vh!important}\n"]
497
+ });
498
+ }
499
+ };
500
+ i0.ɵɵngDeclareClassMetadata({
501
+ minVersion: "12.0.0",
502
+ version: "22.2.2",
503
+ ngImport: i0,
504
+ type: KVMComponent,
505
+ decorators: [{
506
+ type: Component,
507
+ args: [{
508
+ selector: "amt-kvm",
509
+ template: "<div>\n <canvas\n class=\"canvas\"\n #canvas\n [width]=\"width()\"\n [height]=\"height()\"\n oncontextmenu=\"return false\"\n (mouseup)=\"onMouseup($event)\"\n (mousedown)=\"onMousedown($event)\"\n (mousemove)=\"onMousemove($event)\"></canvas>\n</div>\n",
510
+ styles: [".canvas{max-height:80%;max-width:100%}canvas.fullscreen{height:100vh!important}\n"]
511
+ }]
512
+ }],
513
+ ctorParameters: () => [],
514
+ propDecorators: {
515
+ canvas: [{
516
+ type: i0.ViewChild,
517
+ args: ["canvas", { isSignal: true }]
518
+ }],
519
+ device: [{
520
+ type: i0.ViewChild,
521
+ args: ["device", { isSignal: true }]
522
+ }],
523
+ isFullscreen: [{
524
+ type: i0.Input,
525
+ args: [{
526
+ isSignal: true,
527
+ alias: "isFullscreen",
528
+ required: false
529
+ }]
530
+ }],
531
+ mpsServer: [{
532
+ type: i0.Input,
533
+ args: [{
534
+ isSignal: true,
535
+ alias: "mpsServer",
536
+ required: false
537
+ }]
538
+ }],
539
+ authToken: [{
540
+ type: i0.Input,
541
+ args: [{
542
+ isSignal: true,
543
+ alias: "authToken",
544
+ required: false
545
+ }]
546
+ }],
547
+ deviceId: [{
548
+ type: i0.Input,
549
+ args: [{
550
+ isSignal: true,
551
+ alias: "deviceId",
552
+ required: false
553
+ }]
554
+ }],
555
+ deviceStatus: [{
556
+ type: i0.Output,
557
+ args: ["deviceStatus"]
558
+ }],
559
+ deviceConnection: [{
560
+ type: i0.Input,
561
+ args: [{
562
+ isSignal: true,
563
+ alias: "deviceConnection",
564
+ required: false
565
+ }]
566
+ }],
567
+ selectedEncoding: [{
568
+ type: i0.Input,
569
+ args: [{
570
+ isSignal: true,
571
+ alias: "selectedEncoding",
572
+ required: false
573
+ }]
574
+ }],
575
+ selectedHotkey: [{
576
+ type: i0.Input,
577
+ args: [{
578
+ isSignal: true,
579
+ alias: "selectedHotkey",
580
+ required: false
581
+ }]
582
+ }]
583
+ }
584
+ });
371
585
  export { KVMComponent };
372
- //# sourceMappingURL=device-management-toolkit-ui-toolkit-angular-kvm.mjs.map
586
+
587
+ //# sourceMappingURL=device-management-toolkit-ui-toolkit-angular-kvm.mjs.map