@yang__yj/pixelstreaming-core 1.0.0 → 1.0.2

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.
Files changed (243) hide show
  1. package/.cspell.json +48 -0
  2. package/.eslintignore +8 -0
  3. package/.eslintrc.js +8 -0
  4. package/.prettierignore +0 -0
  5. package/.prettierrc.json +6 -0
  6. package/coverage/clover.xml +3480 -0
  7. package/coverage/coverage-final.json +62 -0
  8. package/coverage/lcov-report/base.css +224 -0
  9. package/coverage/lcov-report/block-navigation.js +87 -0
  10. package/coverage/lcov-report/favicon.png +0 -0
  11. package/coverage/lcov-report/index.html +356 -0
  12. package/coverage/lcov-report/prettify.css +1 -0
  13. package/coverage/lcov-report/prettify.js +2 -0
  14. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  15. package/coverage/lcov-report/sorter.js +196 -0
  16. package/coverage/lcov-report/src/AFK/AFKController.ts.html +559 -0
  17. package/coverage/lcov-report/src/AFK/index.html +116 -0
  18. package/coverage/lcov-report/src/Config/Config.ts.html +2764 -0
  19. package/coverage/lcov-report/src/Config/SettingBase.ts.html +280 -0
  20. package/coverage/lcov-report/src/Config/SettingFlag.ts.html +382 -0
  21. package/coverage/lcov-report/src/Config/SettingNumber.ts.html +418 -0
  22. package/coverage/lcov-report/src/Config/SettingOption.ts.html +424 -0
  23. package/coverage/lcov-report/src/Config/SettingText.ts.html +331 -0
  24. package/coverage/lcov-report/src/Config/index.html +191 -0
  25. package/coverage/lcov-report/src/DataChannel/DataChannelController.ts.html +499 -0
  26. package/coverage/lcov-report/src/DataChannel/DataChannelSender.ts.html +262 -0
  27. package/coverage/lcov-report/src/DataChannel/InitialSettings.ts.html +268 -0
  28. package/coverage/lcov-report/src/DataChannel/LatencyTestResults.ts.html +313 -0
  29. package/coverage/lcov-report/src/DataChannel/index.html +161 -0
  30. package/coverage/lcov-report/src/FreezeFrame/FreezeFrame.ts.html +427 -0
  31. package/coverage/lcov-report/src/FreezeFrame/FreezeFrameController.ts.html +427 -0
  32. package/coverage/lcov-report/src/FreezeFrame/index.html +131 -0
  33. package/coverage/lcov-report/src/Inputs/FakeTouchController.ts.html +682 -0
  34. package/coverage/lcov-report/src/Inputs/GamepadController.ts.html +985 -0
  35. package/coverage/lcov-report/src/Inputs/HoveringMouseEvents.ts.html +688 -0
  36. package/coverage/lcov-report/src/Inputs/InputClassesFactory.ts.html +505 -0
  37. package/coverage/lcov-report/src/Inputs/KeyboardController.ts.html +1048 -0
  38. package/coverage/lcov-report/src/Inputs/LockedMouseEvents.ts.html +946 -0
  39. package/coverage/lcov-report/src/Inputs/MouseButtons.ts.html +160 -0
  40. package/coverage/lcov-report/src/Inputs/MouseController.ts.html +1171 -0
  41. package/coverage/lcov-report/src/Inputs/SpecialKeyCodes.ts.html +133 -0
  42. package/coverage/lcov-report/src/Inputs/TouchController.ts.html +712 -0
  43. package/coverage/lcov-report/src/Inputs/XRGamepadController.ts.html +463 -0
  44. package/coverage/lcov-report/src/Inputs/index.html +266 -0
  45. package/coverage/lcov-report/src/Logger/Logger.ts.html +325 -0
  46. package/coverage/lcov-report/src/Logger/index.html +116 -0
  47. package/coverage/lcov-report/src/PeerConnectionController/AggregatedStats.ts.html +1018 -0
  48. package/coverage/lcov-report/src/PeerConnectionController/CandidatePairStats.ts.html +136 -0
  49. package/coverage/lcov-report/src/PeerConnectionController/CandidateStat.ts.html +124 -0
  50. package/coverage/lcov-report/src/PeerConnectionController/DataChannelStats.ts.html +136 -0
  51. package/coverage/lcov-report/src/PeerConnectionController/InboundRTPStats.ts.html +547 -0
  52. package/coverage/lcov-report/src/PeerConnectionController/OutBoundRTPStats.ts.html +163 -0
  53. package/coverage/lcov-report/src/PeerConnectionController/PeerConnectionController.ts.html +1795 -0
  54. package/coverage/lcov-report/src/PeerConnectionController/SessionStats.ts.html +115 -0
  55. package/coverage/lcov-report/src/PeerConnectionController/StreamStats.ts.html +118 -0
  56. package/coverage/lcov-report/src/PeerConnectionController/index.html +236 -0
  57. package/coverage/lcov-report/src/PixelStreaming/PixelStreaming.ts.html +2269 -0
  58. package/coverage/lcov-report/src/PixelStreaming/index.html +116 -0
  59. package/coverage/lcov-report/src/UI/OnScreenKeyboard.ts.html +376 -0
  60. package/coverage/lcov-report/src/UI/index.html +116 -0
  61. package/coverage/lcov-report/src/UeInstanceMessage/ResponseController.ts.html +226 -0
  62. package/coverage/lcov-report/src/UeInstanceMessage/SendDescriptorController.ts.html +346 -0
  63. package/coverage/lcov-report/src/UeInstanceMessage/SendMessageController.ts.html +364 -0
  64. package/coverage/lcov-report/src/UeInstanceMessage/StreamMessageController.ts.html +862 -0
  65. package/coverage/lcov-report/src/UeInstanceMessage/ToStreamerMessagesController.ts.html +271 -0
  66. package/coverage/lcov-report/src/UeInstanceMessage/TwoWayMap.ts.html +241 -0
  67. package/coverage/lcov-report/src/UeInstanceMessage/index.html +191 -0
  68. package/coverage/lcov-report/src/Util/CoordinateConverter.ts.html +952 -0
  69. package/coverage/lcov-report/src/Util/EventEmitter.ts.html +1705 -0
  70. package/coverage/lcov-report/src/Util/EventListenerTracker.ts.html +172 -0
  71. package/coverage/lcov-report/src/Util/FileUtil.ts.html +505 -0
  72. package/coverage/lcov-report/src/Util/WebGLUtils.ts.html +232 -0
  73. package/coverage/lcov-report/src/Util/WebXRUtils.ts.html +160 -0
  74. package/coverage/lcov-report/src/Util/index.html +191 -0
  75. package/coverage/lcov-report/src/VideoPlayer/StreamController.ts.html +349 -0
  76. package/coverage/lcov-report/src/VideoPlayer/VideoPlayer.ts.html +799 -0
  77. package/coverage/lcov-report/src/VideoPlayer/index.html +131 -0
  78. package/coverage/lcov-report/src/WebRtcPlayer/WebRtcPlayerController.ts.html +6199 -0
  79. package/coverage/lcov-report/src/WebRtcPlayer/index.html +116 -0
  80. package/coverage/lcov-report/src/WebSockets/MessageReceive.ts.html +352 -0
  81. package/coverage/lcov-report/src/WebSockets/MessageSend.ts.html +604 -0
  82. package/coverage/lcov-report/src/WebSockets/SignallingProtocol.ts.html +622 -0
  83. package/coverage/lcov-report/src/WebSockets/WebSocketController.ts.html +844 -0
  84. package/coverage/lcov-report/src/WebSockets/index.html +161 -0
  85. package/coverage/lcov-report/src/WebXR/WebXRController.ts.html +1042 -0
  86. package/coverage/lcov-report/src/WebXR/index.html +116 -0
  87. package/coverage/lcov-report/src/__test__/index.html +161 -0
  88. package/coverage/lcov-report/src/__test__/mockMediaStream.ts.html +457 -0
  89. package/coverage/lcov-report/src/__test__/mockRTCPeerConnection.ts.html +1126 -0
  90. package/coverage/lcov-report/src/__test__/mockRTCRtpReceiver.ts.html +151 -0
  91. package/coverage/lcov-report/src/__test__/mockWebSocket.ts.html +475 -0
  92. package/coverage/lcov-report/src/index.html +116 -0
  93. package/coverage/lcov-report/src/pixelstreamingfrontend.ts.html +232 -0
  94. package/coverage/lcov.info +6458 -0
  95. package/dist/lib-pixelstreamingfrontend.esm.js +1 -0
  96. package/dist/lib-pixelstreamingfrontend.js +1 -0
  97. package/jest.config.js +18 -0
  98. package/package.json +47 -18
  99. package/readme.md +15 -0
  100. package/src/AFK/AFKController.test.ts +162 -0
  101. package/src/AFK/AFKController.ts +158 -0
  102. package/src/Config/Config.test.ts +222 -0
  103. package/src/Config/Config.ts +909 -0
  104. package/src/Config/SettingBase.ts +65 -0
  105. package/src/Config/SettingFlag.ts +99 -0
  106. package/src/Config/SettingNumber.ts +111 -0
  107. package/src/Config/SettingOption.ts +124 -0
  108. package/src/Config/SettingText.ts +82 -0
  109. package/src/DataChannel/DataChannelController.ts +138 -0
  110. package/src/DataChannel/DataChannelLatencyTestController.ts +129 -0
  111. package/src/DataChannel/DataChannelLatencyTestResults.ts +67 -0
  112. package/src/DataChannel/DataChannelSender.ts +59 -0
  113. package/src/DataChannel/InitialSettings.ts +61 -0
  114. package/src/DataChannel/LatencyTestResults.ts +76 -0
  115. package/src/FreezeFrame/FreezeFrame.ts +114 -0
  116. package/src/FreezeFrame/FreezeFrameController.ts +114 -0
  117. package/src/Inputs/FakeTouchController.ts +199 -0
  118. package/src/Inputs/GamepadController.ts +300 -0
  119. package/src/Inputs/GamepadTypes.ts +10 -0
  120. package/src/Inputs/HoveringMouseEvents.ts +192 -0
  121. package/src/Inputs/IMouseEvents.ts +64 -0
  122. package/src/Inputs/ITouchController.ts +29 -0
  123. package/src/Inputs/InputClassesFactory.ts +140 -0
  124. package/src/Inputs/KeyboardController.ts +318 -0
  125. package/src/Inputs/LockedMouseEvents.ts +287 -0
  126. package/src/Inputs/MouseButtons.ts +25 -0
  127. package/src/Inputs/MouseController.ts +362 -0
  128. package/src/Inputs/SpecialKeyCodes.ts +16 -0
  129. package/src/Inputs/TouchController.ts +253 -0
  130. package/src/Inputs/XRGamepadController.ts +126 -0
  131. package/src/Logger/Logger.ts +80 -0
  132. package/src/PeerConnectionController/AggregatedStats.ts +311 -0
  133. package/src/PeerConnectionController/CandidatePairStats.ts +17 -0
  134. package/src/PeerConnectionController/CandidateStat.ts +13 -0
  135. package/src/PeerConnectionController/CodecStats.ts +19 -0
  136. package/src/PeerConnectionController/DataChannelStats.ts +17 -0
  137. package/src/PeerConnectionController/InboundRTPStats.ts +154 -0
  138. package/src/PeerConnectionController/InboundTrackStats.ts +34 -0
  139. package/src/PeerConnectionController/OutBoundRTPStats.ts +26 -0
  140. package/src/PeerConnectionController/PeerConnectionController.ts +563 -0
  141. package/src/PeerConnectionController/SessionStats.ts +10 -0
  142. package/src/PeerConnectionController/StreamStats.ts +11 -0
  143. package/src/PixelStreaming/PixelStreaming.test.ts +624 -0
  144. package/src/PixelStreaming/PixelStreaming.ts +847 -0
  145. package/src/UI/OnScreenKeyboard.ts +97 -0
  146. package/src/UeInstanceMessage/ResponseController.ts +47 -0
  147. package/src/UeInstanceMessage/SendMessageController.ts +154 -0
  148. package/src/UeInstanceMessage/StreamMessageController.ts +233 -0
  149. package/src/UeInstanceMessage/ToStreamerMessagesController.ts +62 -0
  150. package/src/Util/CoordinateConverter.ts +289 -0
  151. package/src/Util/EventEmitter.ts +595 -0
  152. package/src/Util/EventListenerTracker.ts +29 -0
  153. package/src/Util/FileUtil.ts +140 -0
  154. package/src/Util/RTCUtils.ts +41 -0
  155. package/src/Util/WebGLUtils.ts +49 -0
  156. package/src/Util/WebXRUtils.ts +25 -0
  157. package/src/VideoPlayer/StreamController.ts +89 -0
  158. package/src/VideoPlayer/VideoPlayer.ts +246 -0
  159. package/src/WebRtcPlayer/WebRtcPlayerController.ts +2221 -0
  160. package/src/WebSockets/MessageReceive.ts +89 -0
  161. package/src/WebSockets/MessageSend.ts +185 -0
  162. package/src/WebSockets/SignallingProtocol.ts +180 -0
  163. package/src/WebSockets/WebSocketController.ts +267 -0
  164. package/src/WebXR/WebXRController.ts +319 -0
  165. package/src/__test__/mockMediaStream.ts +124 -0
  166. package/src/__test__/mockRTCPeerConnection.ts +347 -0
  167. package/src/__test__/mockRTCRtpReceiver.ts +22 -0
  168. package/src/__test__/mockWebSocket.ts +130 -0
  169. package/src/pixelstreamingfrontend.ts +50 -0
  170. package/tsconfig.jest.json +8 -0
  171. package/tsconfig.json +24 -0
  172. package/{library/types → types}/Config/Config.d.ts +5 -4
  173. package/types/DataChannel/DataChannelLatencyTestController.d.ts +26 -0
  174. package/types/DataChannel/DataChannelLatencyTestResults.d.ts +46 -0
  175. package/{library/types → types}/Inputs/HoveringMouseEvents.d.ts +1 -1
  176. package/{library/types → types}/PeerConnectionController/PeerConnectionController.d.ts +1 -1
  177. package/{library/types → types}/PixelStreaming/PixelStreaming.d.ts +31 -6
  178. package/{library/types → types}/UeInstanceMessage/SendMessageController.d.ts +1 -1
  179. package/{library/types → types}/UeInstanceMessage/StreamMessageController.d.ts +3 -5
  180. package/{library/types → types}/Util/EventEmitter.d.ts +40 -3
  181. package/types/Util/RTCUtils.d.ts +8 -0
  182. package/{library/types → types}/VideoPlayer/StreamController.d.ts +3 -3
  183. package/{library/types → types}/VideoPlayer/VideoPlayer.d.ts +2 -0
  184. package/{library/types → types}/WebRtcPlayer/WebRtcPlayerController.d.ts +30 -27
  185. package/{library/types → types}/WebSockets/MessageReceive.d.ts +9 -9
  186. package/{library/types → types}/WebSockets/MessageSend.d.ts +13 -9
  187. package/{library/types → types}/WebSockets/SignallingProtocol.d.ts +3 -3
  188. package/{library/types → types}/WebSockets/WebSocketController.d.ts +16 -12
  189. package/{library/types → types}/pixelstreamingfrontend.d.ts +2 -1
  190. package/webpack.common.js +35 -0
  191. package/webpack.dev.js +35 -0
  192. package/webpack.prod.js +36 -0
  193. package/yang__yj-pixelstreaming-core-1.0.1.tgz +0 -0
  194. package/yang__yj-pixelstreaming-core-1.0.2.tgz +0 -0
  195. package/library/dist/lib-pixelstreamingfrontend.esm.js +0 -1
  196. package/library/dist/lib-pixelstreamingfrontend.js +0 -1
  197. /package/{library/types → types}/AFK/AFKController.d.ts +0 -0
  198. /package/{library/types → types}/Config/SettingBase.d.ts +0 -0
  199. /package/{library/types → types}/Config/SettingFlag.d.ts +0 -0
  200. /package/{library/types → types}/Config/SettingNumber.d.ts +0 -0
  201. /package/{library/types → types}/Config/SettingOption.d.ts +0 -0
  202. /package/{library/types → types}/Config/SettingText.d.ts +0 -0
  203. /package/{library/types → types}/DataChannel/DataChannelController.d.ts +0 -0
  204. /package/{library/types → types}/DataChannel/DataChannelSender.d.ts +0 -0
  205. /package/{library/types → types}/DataChannel/InitialSettings.d.ts +0 -0
  206. /package/{library/types → types}/DataChannel/LatencyTestResults.d.ts +0 -0
  207. /package/{library/types → types}/FreezeFrame/FreezeFrame.d.ts +0 -0
  208. /package/{library/types → types}/FreezeFrame/FreezeFrameController.d.ts +0 -0
  209. /package/{library/types → types}/Inputs/FakeTouchController.d.ts +0 -0
  210. /package/{library/types → types}/Inputs/GamepadController.d.ts +0 -0
  211. /package/{library/types → types}/Inputs/GamepadTypes.d.ts +0 -0
  212. /package/{library/types → types}/Inputs/IMouseEvents.d.ts +0 -0
  213. /package/{library/types → types}/Inputs/ITouchController.d.ts +0 -0
  214. /package/{library/types → types}/Inputs/InputClassesFactory.d.ts +0 -0
  215. /package/{library/types → types}/Inputs/KeyboardController.d.ts +0 -0
  216. /package/{library/types → types}/Inputs/LockedMouseEvents.d.ts +0 -0
  217. /package/{library/types → types}/Inputs/MouseButtons.d.ts +0 -0
  218. /package/{library/types → types}/Inputs/MouseController.d.ts +0 -0
  219. /package/{library/types → types}/Inputs/SpecialKeyCodes.d.ts +0 -0
  220. /package/{library/types → types}/Inputs/TouchController.d.ts +0 -0
  221. /package/{library/types → types}/Inputs/XRGamepadController.d.ts +0 -0
  222. /package/{library/types → types}/Logger/Logger.d.ts +0 -0
  223. /package/{library/types → types}/PeerConnectionController/AggregatedStats.d.ts +0 -0
  224. /package/{library/types → types}/PeerConnectionController/CandidatePairStats.d.ts +0 -0
  225. /package/{library/types → types}/PeerConnectionController/CandidateStat.d.ts +0 -0
  226. /package/{library/types → types}/PeerConnectionController/CodecStats.d.ts +0 -0
  227. /package/{library/types → types}/PeerConnectionController/DataChannelStats.d.ts +0 -0
  228. /package/{library/types → types}/PeerConnectionController/InboundRTPStats.d.ts +0 -0
  229. /package/{library/types → types}/PeerConnectionController/InboundTrackStats.d.ts +0 -0
  230. /package/{library/types → types}/PeerConnectionController/OutBoundRTPStats.d.ts +0 -0
  231. /package/{library/types → types}/PeerConnectionController/SessionStats.d.ts +0 -0
  232. /package/{library/types → types}/PeerConnectionController/StreamStats.d.ts +0 -0
  233. /package/{library/types → types}/UI/OnScreenKeyboard.d.ts +0 -0
  234. /package/{library/types → types}/UeInstanceMessage/ResponseController.d.ts +0 -0
  235. /package/{library/types → types}/UeInstanceMessage/SendDescriptorController.d.ts +0 -0
  236. /package/{library/types → types}/UeInstanceMessage/ToStreamerMessagesController.d.ts +0 -0
  237. /package/{library/types → types}/UeInstanceMessage/TwoWayMap.d.ts +0 -0
  238. /package/{library/types → types}/Util/CoordinateConverter.d.ts +0 -0
  239. /package/{library/types → types}/Util/EventListenerTracker.d.ts +0 -0
  240. /package/{library/types → types}/Util/FileUtil.d.ts +0 -0
  241. /package/{library/types → types}/Util/WebGLUtils.d.ts +0 -0
  242. /package/{library/types → types}/Util/WebXRUtils.d.ts +0 -0
  243. /package/{library/types → types}/WebXR/WebXRController.d.ts +0 -0
@@ -0,0 +1,909 @@
1
+ // Copyright Epic Games, Inc. All Rights Reserved.
2
+
3
+ import { Logger } from '../Logger/Logger';
4
+ import { SettingFlag } from './SettingFlag';
5
+ import { SettingNumber } from './SettingNumber';
6
+ import { SettingText } from './SettingText';
7
+ import { SettingOption } from './SettingOption';
8
+ import { EventEmitter, SettingsChangedEvent } from '../Util/EventEmitter';
9
+ import { SettingBase } from './SettingBase';
10
+
11
+ /**
12
+ * A collection of flags that can be toggled and are core to all Pixel Streaming experiences.
13
+ * These are used in the `Config.Flags` map.
14
+ */
15
+ export class Flags {
16
+ static AutoConnect = 'AutoConnect' as const;
17
+ static AutoPlayVideo = 'AutoPlayVideo' as const;
18
+ static AFKDetection = 'TimeoutIfIdle' as const;
19
+ static BrowserSendOffer = 'OfferToReceive' as const;
20
+ static HoveringMouseMode = 'HoveringMouse' as const;
21
+ static ForceMonoAudio = 'ForceMonoAudio' as const;
22
+ static ForceTURN = 'ForceTURN' as const;
23
+ static FakeMouseWithTouches = 'FakeMouseWithTouches' as const;
24
+ static IsQualityController = 'ControlsQuality' as const;
25
+ static MatchViewportResolution = 'MatchViewportRes' as const;
26
+ static StartVideoMuted = 'StartVideoMuted' as const;
27
+ static SuppressBrowserKeys = 'SuppressBrowserKeys' as const;
28
+ static UseMic = 'UseMic' as const;
29
+ static KeyboardInput = 'KeyboardInput' as const;
30
+ static MouseInput = 'MouseInput' as const;
31
+ static TouchInput = 'TouchInput' as const;
32
+ static GamepadInput = 'GamepadInput' as const;
33
+ static XRControllerInput = 'XRControllerInput' as const;
34
+ static WaitForStreamer = "WaitForStreamer" as const;
35
+ }
36
+
37
+ export type FlagsKeys = Exclude<keyof typeof Flags, 'prototype'>;
38
+ export type FlagsIds = typeof Flags[FlagsKeys];
39
+
40
+ const isFlagId = (id: string): id is FlagsIds =>
41
+ Object.getOwnPropertyNames(Flags).some(
42
+ (name: FlagsKeys) => Flags[name] === id
43
+ );
44
+
45
+ /**
46
+ * A collection of numeric parameters that are core to all Pixel Streaming experiences.
47
+ *
48
+ */
49
+ export class NumericParameters {
50
+ static AFKTimeoutSecs = 'AFKTimeout' as const;
51
+ static MinQP = 'MinQP' as const;
52
+ static MaxQP = 'MaxQP' as const;
53
+ static WebRTCFPS = 'WebRTCFPS' as const;
54
+ static WebRTCMinBitrate = 'WebRTCMinBitrate' as const;
55
+ static WebRTCMaxBitrate = 'WebRTCMaxBitrate' as const;
56
+ static MaxReconnectAttempts = 'MaxReconnectAttempts' as const;
57
+ static StreamerAutoJoinInterval = 'StreamerAutoJoinInterval' as const;
58
+ }
59
+
60
+ export type NumericParametersKeys = Exclude<
61
+ keyof typeof NumericParameters,
62
+ 'prototype'
63
+ >;
64
+ export type NumericParametersIds =
65
+ typeof NumericParameters[NumericParametersKeys];
66
+
67
+ const isNumericId = (id: string): id is NumericParametersIds =>
68
+ Object.getOwnPropertyNames(NumericParameters).some(
69
+ (name: NumericParametersKeys) => NumericParameters[name] === id
70
+ );
71
+
72
+ /**
73
+ * A collection of textual parameters that are core to all Pixel Streaming experiences.
74
+ *
75
+ */
76
+ export class TextParameters {
77
+ static SignallingServerUrl = 'ss' as const;
78
+ }
79
+
80
+ export type TextParametersKeys = Exclude<
81
+ keyof typeof TextParameters,
82
+ 'prototype'
83
+ >;
84
+ export type TextParametersIds = typeof TextParameters[TextParametersKeys];
85
+
86
+ const isTextId = (id: string): id is TextParametersIds =>
87
+ Object.getOwnPropertyNames(TextParameters).some(
88
+ (name: TextParametersKeys) => TextParameters[name] === id
89
+ );
90
+
91
+ /**
92
+ * A collection of enum based parameters that are core to all Pixel Streaming experiences.
93
+ *
94
+ */
95
+ export class OptionParameters {
96
+ static PreferredCodec = 'PreferredCodec' as const;
97
+ static StreamerId = 'StreamerId' as const;
98
+ }
99
+
100
+ export type OptionParametersKeys = Exclude<
101
+ keyof typeof OptionParameters,
102
+ 'prototype'
103
+ >;
104
+ export type OptionParametersIds = typeof OptionParameters[OptionParametersKeys];
105
+
106
+ const isOptionId = (id: string): id is OptionParametersIds =>
107
+ Object.getOwnPropertyNames(OptionParameters).some(
108
+ (name: OptionParametersKeys) => OptionParameters[name] === id
109
+ );
110
+
111
+ /**
112
+ * Utility types for inferring data type based on setting ID
113
+ */
114
+ export type OptionIds =
115
+ | FlagsIds
116
+ | NumericParametersIds
117
+ | TextParametersIds
118
+ | OptionParametersIds;
119
+ export type OptionKeys<T> = T extends FlagsIds
120
+ ? boolean
121
+ : T extends NumericParametersIds
122
+ ? number
123
+ : T extends TextParametersIds
124
+ ? string
125
+ : T extends OptionParametersIds
126
+ ? string
127
+ : never;
128
+
129
+ export type AllSettings = {
130
+ [K in OptionIds]: OptionKeys<K>;
131
+ };
132
+
133
+ export interface ConfigParams {
134
+ /** Initial Pixel Streaming settings */
135
+ initialSettings?: Partial<AllSettings>;
136
+ /** If useUrlParams is set true, will read initial values from URL parameters and persist changed settings into URL */
137
+ useUrlParams?: boolean;
138
+ }
139
+ export class Config {
140
+ /* A map of flags that can be toggled - options that can be set in the application - e.g. Use Mic? */
141
+ private flags = new Map<FlagsIds, SettingFlag>();
142
+
143
+ /* A map of numerical settings - options that can be in the application - e.g. MinBitrate */
144
+ private numericParameters = new Map<NumericParametersIds, SettingNumber>();
145
+
146
+ /* A map of text settings - e.g. signalling server url */
147
+ private textParameters = new Map<TextParametersIds, SettingText>();
148
+
149
+ /* A map of enum based settings - e.g. preferred codec */
150
+ private optionParameters = new Map<OptionParametersIds, SettingOption>();
151
+
152
+ private _useUrlParams: boolean;
153
+
154
+ // ------------ Settings -----------------
155
+
156
+ constructor(config: ConfigParams = {}) {
157
+ const { initialSettings, useUrlParams } = config;
158
+ this._useUrlParams = !!useUrlParams;
159
+ this.populateDefaultSettings(this._useUrlParams);
160
+ if (initialSettings) {
161
+ this.setSettings(initialSettings);
162
+ }
163
+ }
164
+
165
+ /**
166
+ * True if reading configuration initial values from URL parameters, and
167
+ * persisting changes in URL when changed.
168
+ */
169
+ public get useUrlParams() {
170
+ return this._useUrlParams;
171
+ }
172
+
173
+ /**
174
+ * Populate the default settings for a Pixel Streaming application
175
+ */
176
+ private populateDefaultSettings(useUrlParams: boolean): void {
177
+ /**
178
+ * Text Parameters
179
+ */
180
+
181
+ this.textParameters.set(
182
+ TextParameters.SignallingServerUrl,
183
+ new SettingText(
184
+ TextParameters.SignallingServerUrl,
185
+ 'Signalling url',
186
+ 'Url of the signalling server',
187
+ (location.protocol === 'https:' ? 'wss://' : 'ws://') +
188
+ window.location.hostname +
189
+ // for readability, we omit the port if it's 80
190
+ (window.location.port === '80' ||
191
+ window.location.port === ''
192
+ ? ''
193
+ : `:${window.location.port}`),
194
+ useUrlParams
195
+ )
196
+ );
197
+
198
+ this.optionParameters.set(
199
+ OptionParameters.StreamerId,
200
+ new SettingOption(
201
+ OptionParameters.StreamerId,
202
+ 'Streamer ID',
203
+ 'The ID of the streamer to stream.',
204
+ '',
205
+ [],
206
+ useUrlParams
207
+ )
208
+ );
209
+
210
+ /**
211
+ * Enum Parameters
212
+ */
213
+ this.optionParameters.set(
214
+ OptionParameters.PreferredCodec,
215
+ new SettingOption(
216
+ OptionParameters.PreferredCodec,
217
+ 'Preferred Codec',
218
+ 'The preferred codec to be used during codec negotiation',
219
+ 'H264 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f',
220
+ (function (): Array<string> {
221
+ const browserSupportedCodecs: Array<string> = [];
222
+ // Try get the info needed from the RTCRtpReceiver. This is only available on chrome
223
+ if (!RTCRtpReceiver.getCapabilities) {
224
+ browserSupportedCodecs.push('Only available on Chrome');
225
+ return browserSupportedCodecs;
226
+ }
227
+
228
+ const matcher = /(VP\d|H26\d|AV1).*/;
229
+ const codecs =
230
+ RTCRtpReceiver.getCapabilities('video').codecs;
231
+ codecs.forEach((codec) => {
232
+ const str =
233
+ codec.mimeType.split('/')[1] +
234
+ ' ' +
235
+ (codec.sdpFmtpLine || '');
236
+ const match = matcher.exec(str);
237
+ if (match !== null) {
238
+ browserSupportedCodecs.push(str);
239
+ }
240
+ });
241
+ return browserSupportedCodecs;
242
+ })(),
243
+ useUrlParams
244
+ )
245
+ );
246
+
247
+ /**
248
+ * Boolean parameters
249
+ */
250
+
251
+ this.flags.set(
252
+ Flags.AutoConnect,
253
+ new SettingFlag(
254
+ Flags.AutoConnect,
255
+ 'Auto connect to stream',
256
+ 'Whether we should attempt to auto connect to the signalling server or show a click to start prompt.',
257
+ false,
258
+ useUrlParams
259
+ )
260
+ );
261
+
262
+ this.flags.set(
263
+ Flags.AutoPlayVideo,
264
+ new SettingFlag(
265
+ Flags.AutoPlayVideo,
266
+ 'Auto play video',
267
+ 'When video is ready automatically start playing it as opposed to showing a play button.',
268
+ true,
269
+ useUrlParams
270
+ )
271
+ );
272
+
273
+ this.flags.set(
274
+ Flags.BrowserSendOffer,
275
+ new SettingFlag(
276
+ Flags.BrowserSendOffer,
277
+ 'Browser send offer',
278
+ 'Browser will initiate the WebRTC handshake by sending the offer to the streamer',
279
+ false,
280
+ useUrlParams
281
+ )
282
+ );
283
+
284
+ this.flags.set(
285
+ Flags.UseMic,
286
+ new SettingFlag(
287
+ Flags.UseMic,
288
+ 'Use microphone',
289
+ 'Make browser request microphone access and open an input audio track.',
290
+ false,
291
+ useUrlParams
292
+ )
293
+ );
294
+
295
+ this.flags.set(
296
+ Flags.StartVideoMuted,
297
+ new SettingFlag(
298
+ Flags.StartVideoMuted,
299
+ 'Start video muted',
300
+ 'Video will start muted if true.',
301
+ false,
302
+ useUrlParams
303
+ )
304
+ );
305
+
306
+ this.flags.set(
307
+ Flags.SuppressBrowserKeys,
308
+ new SettingFlag(
309
+ Flags.SuppressBrowserKeys,
310
+ 'Suppress browser keys',
311
+ 'Suppress certain browser keys that we use in UE, for example F5 to show shader complexity instead of refresh the page.',
312
+ true,
313
+ useUrlParams
314
+ )
315
+ );
316
+
317
+ this.flags.set(
318
+ Flags.IsQualityController,
319
+ new SettingFlag(
320
+ Flags.IsQualityController,
321
+ 'Is quality controller?',
322
+ 'True if this peer controls stream quality',
323
+ true,
324
+ useUrlParams
325
+ )
326
+ );
327
+
328
+ this.flags.set(
329
+ Flags.ForceMonoAudio,
330
+ new SettingFlag(
331
+ Flags.ForceMonoAudio,
332
+ 'Force mono audio',
333
+ 'Force browser to request mono audio in the SDP',
334
+ false,
335
+ useUrlParams
336
+ )
337
+ );
338
+
339
+ this.flags.set(
340
+ Flags.ForceTURN,
341
+ new SettingFlag(
342
+ Flags.ForceTURN,
343
+ 'Force TURN',
344
+ 'Only generate TURN/Relayed ICE candidates.',
345
+ false,
346
+ useUrlParams
347
+ )
348
+ );
349
+
350
+ this.flags.set(
351
+ Flags.AFKDetection,
352
+ new SettingFlag(
353
+ Flags.AFKDetection,
354
+ 'AFK if idle',
355
+ 'Timeout the experience if user is AFK for a period.',
356
+ false,
357
+ useUrlParams
358
+ )
359
+ );
360
+
361
+ this.flags.set(
362
+ Flags.MatchViewportResolution,
363
+ new SettingFlag(
364
+ Flags.MatchViewportResolution,
365
+ 'Match viewport resolution',
366
+ 'Pixel Streaming will be instructed to dynamically resize the video stream to match the size of the video element.',
367
+ false,
368
+ useUrlParams
369
+ )
370
+ );
371
+
372
+ this.flags.set(
373
+ Flags.HoveringMouseMode,
374
+ new SettingFlag(
375
+ Flags.HoveringMouseMode,
376
+ 'Control Scheme: Locked Mouse',
377
+ 'Either locked mouse, where the pointer is consumed by the video and locked to it, or hovering mouse, where the mouse is not consumed.',
378
+ false,
379
+ useUrlParams,
380
+ (isHoveringMouse: boolean, setting: SettingBase) => {
381
+ setting.label = `Control Scheme: ${isHoveringMouse ? 'Hovering' : 'Locked'} Mouse`;
382
+ }
383
+ )
384
+ );
385
+
386
+ this.flags.set(
387
+ Flags.FakeMouseWithTouches,
388
+ new SettingFlag(
389
+ Flags.FakeMouseWithTouches,
390
+ 'Fake mouse with touches',
391
+ 'A single finger touch is converted into a mouse event. This allows a non-touch application to be controlled partially via a touch device.',
392
+ false,
393
+ useUrlParams
394
+ )
395
+ );
396
+
397
+ this.flags.set(
398
+ Flags.KeyboardInput,
399
+ new SettingFlag(
400
+ Flags.KeyboardInput,
401
+ 'Keyboard input',
402
+ 'If enabled, send keyboard events to streamer',
403
+ true,
404
+ useUrlParams
405
+ )
406
+ );
407
+
408
+ this.flags.set(
409
+ Flags.MouseInput,
410
+ new SettingFlag(
411
+ Flags.MouseInput,
412
+ 'Mouse input',
413
+ 'If enabled, send mouse events to streamer',
414
+ true,
415
+ useUrlParams
416
+ )
417
+ );
418
+
419
+ this.flags.set(
420
+ Flags.TouchInput,
421
+ new SettingFlag(
422
+ Flags.TouchInput,
423
+ 'Touch input',
424
+ 'If enabled, send touch events to streamer',
425
+ true,
426
+ useUrlParams
427
+ )
428
+ );
429
+
430
+ this.flags.set(
431
+ Flags.GamepadInput,
432
+ new SettingFlag(
433
+ Flags.GamepadInput,
434
+ 'Gamepad input',
435
+ 'If enabled, send gamepad events to streamer',
436
+ true,
437
+ useUrlParams
438
+ )
439
+ );
440
+
441
+ this.flags.set(
442
+ Flags.XRControllerInput,
443
+ new SettingFlag(
444
+ Flags.XRControllerInput,
445
+ 'XR controller input',
446
+ 'If enabled, send XR controller events to streamer',
447
+ true,
448
+ useUrlParams
449
+ )
450
+ );
451
+
452
+ this.flags.set(
453
+ Flags.WaitForStreamer,
454
+ new SettingFlag(
455
+ Flags.WaitForStreamer,
456
+ '等待拖缆',
457
+ '将继续尝试连接到第一个可用的流媒体.',
458
+ true,
459
+ useUrlParams
460
+ )
461
+ );
462
+
463
+ /**
464
+ * Numeric parameters
465
+ */
466
+
467
+ this.numericParameters.set(
468
+ NumericParameters.AFKTimeoutSecs,
469
+ new SettingNumber(
470
+ NumericParameters.AFKTimeoutSecs,
471
+ 'AFK timeout',
472
+ 'The time (in seconds) it takes for the application to time out if AFK timeout is enabled.',
473
+ 0 /*min*/,
474
+ 600 /*max*/,
475
+ 120 /*value*/,
476
+ useUrlParams
477
+ )
478
+ );
479
+
480
+ this.numericParameters.set(
481
+ NumericParameters.MaxReconnectAttempts,
482
+ new SettingNumber(
483
+ NumericParameters.MaxReconnectAttempts,
484
+ 'Max Reconnects',
485
+ 'Maximum number of reconnects the application will attempt when a streamer disconnects.',
486
+ 0 /*min*/,
487
+ 999 /*max*/,
488
+ 3 /*value*/,
489
+ useUrlParams
490
+ )
491
+ );
492
+
493
+ this.numericParameters.set(
494
+ NumericParameters.MinQP,
495
+ new SettingNumber(
496
+ NumericParameters.MinQP,
497
+ 'Min QP',
498
+ 'The lower bound for the quantization parameter (QP) of the encoder. 0 = Best quality, 51 = worst quality.',
499
+ 0 /*min*/,
500
+ 51 /*max*/,
501
+ 0 /*value*/,
502
+ useUrlParams
503
+ )
504
+ );
505
+
506
+ this.numericParameters.set(
507
+ NumericParameters.MaxQP,
508
+ new SettingNumber(
509
+ NumericParameters.MaxQP,
510
+ 'Max QP',
511
+ 'The upper bound for the quantization parameter (QP) of the encoder. 0 = Best quality, 51 = worst quality.',
512
+ 0 /*min*/,
513
+ 51 /*max*/,
514
+ 51 /*value*/,
515
+ useUrlParams
516
+ )
517
+ );
518
+
519
+ this.numericParameters.set(
520
+ NumericParameters.WebRTCFPS,
521
+ new SettingNumber(
522
+ NumericParameters.WebRTCFPS,
523
+ 'Max FPS',
524
+ 'The maximum FPS that WebRTC will try to transmit frames at.',
525
+ 1 /*min*/,
526
+ 999 /*max*/,
527
+ 60 /*value*/,
528
+ useUrlParams
529
+ )
530
+ );
531
+
532
+ this.numericParameters.set(
533
+ NumericParameters.WebRTCMinBitrate,
534
+ new SettingNumber(
535
+ NumericParameters.WebRTCMinBitrate,
536
+ 'Min Bitrate (kbps)',
537
+ 'The minimum bitrate that WebRTC should use.',
538
+ 0 /*min*/,
539
+ 500000 /*max*/,
540
+ 0 /*value*/,
541
+ useUrlParams
542
+ )
543
+ );
544
+
545
+ this.numericParameters.set(
546
+ NumericParameters.WebRTCMaxBitrate,
547
+ new SettingNumber(
548
+ NumericParameters.WebRTCMaxBitrate,
549
+ 'Max Bitrate (kbps)',
550
+ 'The maximum bitrate that WebRTC should use.',
551
+ 0 /*min*/,
552
+ 500000 /*max*/,
553
+ 0 /*value*/,
554
+ useUrlParams
555
+ )
556
+ );
557
+
558
+ this.numericParameters.set(
559
+ NumericParameters.StreamerAutoJoinInterval,
560
+ new SettingNumber(
561
+ NumericParameters.StreamerAutoJoinInterval,
562
+ 'Streamer Auto Join Interval (ms)',
563
+ 'Delay between retries when waiting for an available streamer.',
564
+ 500 /*min*/,
565
+ 900000 /*max*/,
566
+ 3000 /*value*/,
567
+ useUrlParams
568
+ )
569
+ );
570
+ }
571
+
572
+ /**
573
+ * Add a callback to fire when the numeric setting is toggled.
574
+ * @param id The id of the flag.
575
+ * @param onChangedListener The callback to fire when the numeric value changes.
576
+ */
577
+ _addOnNumericSettingChangedListener(
578
+ id: NumericParametersIds,
579
+ onChangedListener: (newValue: number) => void
580
+ ): void {
581
+ if (this.numericParameters.has(id)) {
582
+ this.numericParameters
583
+ .get(id)
584
+ .addOnChangedListener(onChangedListener);
585
+ }
586
+ }
587
+
588
+ _addOnOptionSettingChangedListener(
589
+ id: OptionParametersIds,
590
+ onChangedListener: (newValue: string) => void
591
+ ): void {
592
+ if (this.optionParameters.has(id)) {
593
+ this.optionParameters
594
+ .get(id)
595
+ .addOnChangedListener(onChangedListener);
596
+ }
597
+ }
598
+
599
+ /**
600
+ * @param id The id of the numeric setting we are interested in getting a value for.
601
+ * @returns The numeric value stored in the parameter with the passed id.
602
+ */
603
+ getNumericSettingValue(id: NumericParametersIds): number {
604
+ if (this.numericParameters.has(id)) {
605
+ return this.numericParameters.get(id).number;
606
+ } else {
607
+ throw new Error(`There is no numeric setting with the id of ${id}`);
608
+ }
609
+ }
610
+
611
+ /**
612
+ * @param id The id of the text setting we are interested in getting a value for.
613
+ * @returns The text value stored in the parameter with the passed id.
614
+ */
615
+ getTextSettingValue(id: TextParametersIds): string {
616
+ if (this.textParameters.has(id)) {
617
+ return this.textParameters.get(id).value as string;
618
+ } else {
619
+ throw new Error(`There is no numeric setting with the id of ${id}`);
620
+ }
621
+ }
622
+
623
+ /**
624
+ * Set number in the setting.
625
+ * @param id The id of the numeric setting we are interested in.
626
+ * @param value The numeric value to set.
627
+ */
628
+ setNumericSetting(id: NumericParametersIds, value: number): void {
629
+ if (this.numericParameters.has(id)) {
630
+ this.numericParameters.get(id).number = value;
631
+ } else {
632
+ throw new Error(`There is no numeric setting with the id of ${id}`);
633
+ }
634
+ }
635
+
636
+ /**
637
+ * Add a callback to fire when the flag is toggled.
638
+ * @param id The id of the flag.
639
+ * @param onChangeListener The callback to fire when the value changes.
640
+ */
641
+ _addOnSettingChangedListener(
642
+ id: FlagsIds,
643
+ onChangeListener: (newFlagValue: boolean) => void
644
+ ): void {
645
+ if (this.flags.has(id)) {
646
+ this.flags.get(id).onChange = onChangeListener;
647
+ }
648
+ }
649
+
650
+ /**
651
+ * Add a callback to fire when the text is changed.
652
+ * @param id The id of the flag.
653
+ * @param onChangeListener The callback to fire when the value changes.
654
+ */
655
+ _addOnTextSettingChangedListener(
656
+ id: TextParametersIds,
657
+ onChangeListener: (newTextValue: string) => void
658
+ ): void {
659
+ if (this.textParameters.has(id)) {
660
+ this.textParameters.get(id).onChange = onChangeListener;
661
+ }
662
+ }
663
+
664
+ /**
665
+ * Get the option which has the given id.
666
+ * @param id The id of the option.
667
+ * @returns The SettingOption object matching id
668
+ */
669
+ getSettingOption(id: OptionParametersIds): SettingOption {
670
+ return this.optionParameters.get(id);
671
+ }
672
+
673
+ /**
674
+ * 获取具有给定id的配置标志的值。
675
+ * @param id标志的唯一id。
676
+ *如果启用了该标志,@返回True。
677
+ */
678
+ isFlagEnabled(id: FlagsIds): boolean {
679
+ return this.flags.get(id).flag as boolean;
680
+ }
681
+
682
+ /**
683
+ * Set flag to be enabled/disabled.
684
+ * @param id The id of the flag to toggle.
685
+ * @param flagEnabled True if the flag should be enabled.
686
+ */
687
+ setFlagEnabled(id: FlagsIds, flagEnabled: boolean) {
688
+ if (!this.flags.has(id)) {
689
+ Logger.Warning(
690
+ Logger.GetStackTrace(),
691
+ `Cannot toggle flag called ${id} - it does not exist in the Config.flags map.`
692
+ );
693
+ } else {
694
+ this.flags.get(id).flag = flagEnabled;
695
+ }
696
+ }
697
+
698
+ /**
699
+ * Set the text setting.
700
+ * @param id The id of the setting
701
+ * @param settingValue The value to set in the setting.
702
+ */
703
+ setTextSetting(id: TextParametersIds, settingValue: string) {
704
+ if (!this.textParameters.has(id)) {
705
+ Logger.Warning(
706
+ Logger.GetStackTrace(),
707
+ `Cannot set text setting called ${id} - it does not exist in the Config.textParameters map.`
708
+ );
709
+ } else {
710
+ this.textParameters.get(id).text = settingValue;
711
+ }
712
+ }
713
+
714
+ /**
715
+ * Set the option setting list of options.
716
+ * @param id The id of the setting
717
+ * @param settingOptions The values the setting could take
718
+ */
719
+ setOptionSettingOptions(
720
+ id: OptionParametersIds,
721
+ settingOptions: Array<string>
722
+ ) {
723
+ if (!this.optionParameters.has(id)) {
724
+ Logger.Warning(
725
+ Logger.GetStackTrace(),
726
+ `Cannot set text setting called ${id} - it does not exist in the Config.optionParameters map.`
727
+ );
728
+ } else {
729
+ console.log(settingOptions);
730
+
731
+ this.optionParameters.get(id).options = settingOptions;
732
+ }
733
+ }
734
+
735
+ /**
736
+ * Set option enum settings selected option.
737
+ * @param id The id of the setting
738
+ * @param settingOptions The value to select out of all the options
739
+ */
740
+ setOptionSettingValue(id: OptionParametersIds, settingValue: string) {
741
+ if (!this.optionParameters.has(id)) {
742
+ Logger.Warning(
743
+ Logger.GetStackTrace(),
744
+ `Cannot set text setting called ${id} - it does not exist in the Config.enumParameters map.`
745
+ );
746
+ } else {
747
+ this.optionParameters.get(id).selected = settingValue;
748
+ }
749
+ }
750
+
751
+ /**
752
+ * Set the label for the flag.
753
+ * @param id The id of the flag.
754
+ * @param label The new label to use for the flag.
755
+ */
756
+ setFlagLabel(id: FlagsIds, label: string) {
757
+ if (!this.flags.has(id)) {
758
+ Logger.Warning(
759
+ Logger.GetStackTrace(),
760
+ `Cannot set label for flag called ${id} - it does not exist in the Config.flags map.`
761
+ );
762
+ } else {
763
+ this.flags.get(id).label = label;
764
+ }
765
+ }
766
+
767
+ /**
768
+ * Set a subset of all settings in one function call.
769
+ *
770
+ * @param settings A (partial) list of settings to set
771
+ */
772
+ setSettings(settings: Partial<AllSettings>) {
773
+ for (const key of Object.keys(settings)) {
774
+ if (isFlagId(key)) {
775
+ this.setFlagEnabled(key, settings[key]);
776
+ } else if (isNumericId(key)) {
777
+ this.setNumericSetting(key, settings[key]);
778
+ } else if (isTextId(key)) {
779
+ this.setTextSetting(key, settings[key]);
780
+ } else if (isOptionId(key)) {
781
+ this.setOptionSettingValue(key, settings[key]);
782
+ }
783
+ }
784
+ }
785
+
786
+ /**
787
+ * Get all settings
788
+ * @returns All setting values as an object with setting ids as keys
789
+ */
790
+ getSettings(): Partial<AllSettings> {
791
+ const settings: Partial<AllSettings> = {};
792
+ for (const [key, value] of this.flags.entries()) {
793
+ settings[key] = value.flag;
794
+ }
795
+ for (const [key, value] of this.numericParameters.entries()) {
796
+ settings[key] = value.number;
797
+ }
798
+ for (const [key, value] of this.textParameters.entries()) {
799
+ settings[key] = value.text;
800
+ }
801
+ for (const [key, value] of this.optionParameters.entries()) {
802
+ settings[key] = value.selected;
803
+ }
804
+ return settings;
805
+ }
806
+
807
+ /**
808
+ * Get all Flag settings as an array.
809
+ * @returns All SettingFlag objects
810
+ */
811
+ getFlags(): Array<SettingFlag> {
812
+ return Array.from(this.flags.values());
813
+ }
814
+
815
+ /**
816
+ * Get all Text settings as an array.
817
+ * @returns All SettingText objects
818
+ */
819
+ getTextSettings(): Array<SettingText> {
820
+ return Array.from(this.textParameters.values());
821
+ }
822
+
823
+ /**
824
+ * Get all Number settings as an array.
825
+ * @returns All SettingNumber objects
826
+ */
827
+ getNumericSettings(): Array<SettingNumber> {
828
+ return Array.from(this.numericParameters.values());
829
+ }
830
+
831
+ /**
832
+ * Get all Option settings as an array.
833
+ * @returns All SettingOption objects
834
+ */
835
+ getOptionSettings(): Array<SettingOption> {
836
+ return Array.from(this.optionParameters.values());
837
+ }
838
+
839
+ /**
840
+ * Emit events when settings change.
841
+ * @param eventEmitter
842
+ */
843
+ _registerOnChangeEvents(eventEmitter: EventEmitter) {
844
+ for (const key of this.flags.keys()) {
845
+ const flag = this.flags.get(key);
846
+ if (flag) {
847
+ flag.onChangeEmit = (newValue: boolean) =>
848
+ eventEmitter.dispatchEvent(
849
+ new SettingsChangedEvent({
850
+ id: flag.id,
851
+ type: 'flag',
852
+ value: newValue,
853
+ target: flag
854
+ })
855
+ );
856
+ }
857
+ }
858
+ for (const key of this.numericParameters.keys()) {
859
+ const number = this.numericParameters.get(key);
860
+ if (number) {
861
+ number.onChangeEmit = (newValue: number) =>
862
+ eventEmitter.dispatchEvent(
863
+ new SettingsChangedEvent({
864
+ id: number.id,
865
+ type: 'number',
866
+ value: newValue,
867
+ target: number
868
+ })
869
+ );
870
+ }
871
+ }
872
+ for (const key of this.textParameters.keys()) {
873
+ const text = this.textParameters.get(key);
874
+ if (text) {
875
+ text.onChangeEmit = (newValue: string) =>
876
+ eventEmitter.dispatchEvent(
877
+ new SettingsChangedEvent({
878
+ id: text.id,
879
+ type: 'text',
880
+ value: newValue,
881
+ target: text
882
+ })
883
+ );
884
+ }
885
+ }
886
+ for (const key of this.optionParameters.keys()) {
887
+ const option = this.optionParameters.get(key);
888
+ if (option) {
889
+ option.onChangeEmit = (newValue: string) =>
890
+ eventEmitter.dispatchEvent(
891
+ new SettingsChangedEvent({
892
+ id: option.id,
893
+ type: 'option',
894
+ value: newValue,
895
+ target: option
896
+ })
897
+ );
898
+ }
899
+ }
900
+ }
901
+ }
902
+
903
+ /**
904
+ * The enum associated with the mouse being locked or hovering
905
+ */
906
+ export enum ControlSchemeType {
907
+ LockedMouse = 0,
908
+ HoveringMouse = 1
909
+ }