@epicgames-ps/lib-pixelstreamingfrontend-ue5.5 1.0.1 → 1.0.3

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.
@@ -19,7 +19,7 @@ export class KeyboardController implements IInputController {
19
19
  onKeyDownListener: (event: KeyboardEvent) => void;
20
20
  onKeyUpListener: (event: KeyboardEvent) => void;
21
21
  onKeyPressListener: (event: KeyboardEvent) => void;
22
- onCompositionEndListener: (event: KeyboardEvent) => void;
22
+ onCompositionEndListener: (event: CompositionEvent) => void;
23
23
 
24
24
  constructor(streamMessageController: StreamMessageController, config: Config, activeKeys: ActiveKeys) {
25
25
  this.streamMessageController = streamMessageController;
@@ -54,15 +54,19 @@ export class KeyboardController implements IInputController {
54
54
  }
55
55
 
56
56
  const toStreamerHandlers = this.streamMessageController.toStreamerHandlers;
57
- toStreamerHandlers.get('KeyDown')([this.getKeycode(keyboardEvent), keyboardEvent.repeat ? 1 : 0]);
57
+ toStreamerHandlers.get('KeyDown')?.([this.getKeycode(keyboardEvent)!, keyboardEvent.repeat ? 1 : 0]);
58
58
  const activeKeys = this.activeKeys.getActiveKeys();
59
59
  activeKeys.push(keyCode);
60
+
60
61
  // Backspace is not considered a keypress in JavaScript but we need it
61
62
  // to be so characters may be deleted in a UE text entry field.
63
+ // since keypress is deprecated we really should be sending all keys to keypress
64
+ // or we change everything to handle the deprecation of these parts
62
65
  if (keyCode === SpecialKeyCodes.backSpace) {
63
- document.dispatchEvent(
66
+ this.handleOnKeyPress(
64
67
  new KeyboardEvent('keypress', {
65
- charCode: SpecialKeyCodes.backSpace
68
+ charCode: SpecialKeyCodes.backSpace,
69
+ keyCode: SpecialKeyCodes.backSpace
66
70
  })
67
71
  );
68
72
  }
@@ -79,7 +83,7 @@ export class KeyboardController implements IInputController {
79
83
  }
80
84
 
81
85
  const toStreamerHandlers = this.streamMessageController.toStreamerHandlers;
82
- toStreamerHandlers.get('KeyUp')([keyCode]);
86
+ toStreamerHandlers.get('KeyUp')?.([keyCode]);
83
87
 
84
88
  if (this.config.isFlagEnabled(Flags.SuppressBrowserKeys) && this.isKeyCodeBrowserKey(keyCode)) {
85
89
  keyboardEvent.preventDefault();
@@ -93,7 +97,7 @@ export class KeyboardController implements IInputController {
93
97
  }
94
98
 
95
99
  const toStreamerHandlers = this.streamMessageController.toStreamerHandlers;
96
- toStreamerHandlers.get('KeyPress')([keyCode]);
100
+ toStreamerHandlers.get('KeyPress')?.([keyCode]);
97
101
  }
98
102
 
99
103
  private handleOnCompositionEnd(compositionEvent: CompositionEvent) {
@@ -132,8 +136,10 @@ export class KeyboardController implements IInputController {
132
136
  // If we don't have keyCode property because browser API is deprecated then use KeyboardEvent.code instead.
133
137
  // See: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode#constants_for_keycode_value
134
138
  if (!('keyCode' in keyboardEvent)) {
135
- // Convert KeyboardEvent.code string into integer-based key code for backwards compatibility reasons.
139
+ // this type assertion here is required because if 'keyCode' doesnt exist in keyboardEvent then
140
+ // it cannot be a KeyboardEvent and so it gets narrowed to 'never'
136
141
  const event = keyboardEvent as KeyboardEvent;
142
+ // Convert KeyboardEvent.code string into integer-based key code for backwards compatibility reasons.
137
143
  if (event.code in CodeToKeyCode) {
138
144
  return CodeToKeyCode[event.code];
139
145
  } else {
@@ -81,9 +81,13 @@ export class OnScreenKeyboard {
81
81
  * @param command the command received via the data channel containing keyboard positions
82
82
  */
83
83
  showOnScreenKeyboard(command: any) {
84
+ if (!this.editTextButton) {
85
+ return;
86
+ }
87
+
84
88
  if (command.showOnScreenKeyboard) {
85
89
  // Show the 'edit text' button.
86
- this.editTextButton.style.display = 'default';
90
+ this.editTextButton.style.display = 'block';
87
91
  // Place the 'edit text' button near the UE input widget.
88
92
  const pos = this.unquantizeAndDenormalizeUnsigned(command.x, command.y);
89
93
  this.editTextButton.style.top = pos.y.toString() + 'px';
@@ -169,7 +169,7 @@ export class WebRtcPlayerController {
169
169
  this.streamMessageController = new StreamMessageController();
170
170
 
171
171
  // set up websocket methods
172
- this.transport = new WebSocketTransport();
172
+ this.transport = new WebSocketTransport(config.webSocketProtocols);
173
173
  this.protocol = new SignallingProtocol(this.transport);
174
174
  this.protocol.addListener(Messages.config.typeName, (msg: BaseMessage) =>
175
175
  this.handleOnConfigMessage(msg as Messages.config)