@epicgames-ps/lib-pixelstreamingfrontend-ue5.5 0.3.0 → 0.3.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 (172) hide show
  1. package/dist/commonjs/AFK/AFKController.js +109 -109
  2. package/dist/commonjs/Config/Config.js +559 -559
  3. package/dist/commonjs/Config/SettingBase.js +98 -98
  4. package/dist/commonjs/Config/SettingFlag.js +49 -49
  5. package/dist/commonjs/Config/SettingNumber.js +83 -83
  6. package/dist/commonjs/Config/SettingOption.js +84 -84
  7. package/dist/commonjs/Config/SettingText.js +42 -42
  8. package/dist/commonjs/DataChannel/DataChannelController.js +106 -106
  9. package/dist/commonjs/DataChannel/DataChannelLatencyTestController.js +94 -94
  10. package/dist/commonjs/DataChannel/DataChannelLatencyTestResults.js +18 -18
  11. package/dist/commonjs/DataChannel/DataChannelSender.js +43 -43
  12. package/dist/commonjs/DataChannel/InitialSettings.js +41 -41
  13. package/dist/commonjs/DataChannel/LatencyTestResults.js +60 -60
  14. package/dist/commonjs/FreezeFrame/FreezeFrame.js +93 -93
  15. package/dist/commonjs/FreezeFrame/FreezeFrameController.js +95 -95
  16. package/dist/commonjs/Inputs/GamepadController.js +188 -188
  17. package/dist/commonjs/Inputs/GamepadTypes.js +21 -21
  18. package/dist/commonjs/Inputs/IInputController.js +2 -2
  19. package/dist/commonjs/Inputs/InputClassesFactory.js +96 -96
  20. package/dist/commonjs/Inputs/KeyCodes.js +112 -112
  21. package/dist/commonjs/Inputs/KeyboardController.js +137 -137
  22. package/dist/commonjs/Inputs/MouseButtons.js +28 -28
  23. package/dist/commonjs/Inputs/MouseController.js +97 -97
  24. package/dist/commonjs/Inputs/MouseControllerHovering.js +93 -93
  25. package/dist/commonjs/Inputs/MouseControllerLocked.js +153 -153
  26. package/dist/commonjs/Inputs/SpecialKeyCodes.js +19 -19
  27. package/dist/commonjs/Inputs/TouchController.js +123 -123
  28. package/dist/commonjs/Inputs/TouchController.js.map +1 -1
  29. package/dist/commonjs/Inputs/TouchControllerFake.js +91 -91
  30. package/dist/commonjs/Inputs/XRGamepadController.js +124 -124
  31. package/dist/commonjs/PeerConnectionController/AggregatedStats.js +252 -252
  32. package/dist/commonjs/PeerConnectionController/CandidatePairStats.js +10 -10
  33. package/dist/commonjs/PeerConnectionController/CandidateStat.js +10 -10
  34. package/dist/commonjs/PeerConnectionController/CodecStats.js +10 -10
  35. package/dist/commonjs/PeerConnectionController/DataChannelStats.js +10 -10
  36. package/dist/commonjs/PeerConnectionController/InboundRTPStats.js +22 -22
  37. package/dist/commonjs/PeerConnectionController/InboundTrackStats.js +10 -10
  38. package/dist/commonjs/PeerConnectionController/OutBoundRTPStats.js +16 -16
  39. package/dist/commonjs/PeerConnectionController/PeerConnectionController.js +584 -584
  40. package/dist/commonjs/PeerConnectionController/SessionStats.js +10 -10
  41. package/dist/commonjs/PeerConnectionController/StreamStats.js +10 -10
  42. package/dist/commonjs/PixelStreaming/PixelStreaming.js +607 -607
  43. package/dist/commonjs/UI/OnScreenKeyboard.js +82 -82
  44. package/dist/commonjs/UeInstanceMessage/ResponseController.js +38 -38
  45. package/dist/commonjs/UeInstanceMessage/SendMessageController.js +120 -120
  46. package/dist/commonjs/UeInstanceMessage/StreamMessageController.js +210 -210
  47. package/dist/commonjs/UeInstanceMessage/ToStreamerMessagesController.js +49 -49
  48. package/dist/commonjs/Util/EventEmitter.js +386 -386
  49. package/dist/commonjs/Util/FileUtil.js +108 -108
  50. package/dist/commonjs/Util/IURLSearchParams.js +25 -25
  51. package/dist/commonjs/Util/InputCoordTranslator.js +49 -49
  52. package/dist/commonjs/Util/RTCUtils.js +40 -40
  53. package/dist/commonjs/VideoPlayer/StreamController.js +67 -67
  54. package/dist/commonjs/VideoPlayer/VideoPlayer.js +177 -177
  55. package/dist/commonjs/WebRtcPlayer/WebRtcPlayerController.js +1221 -1221
  56. package/dist/commonjs/WebXR/WebXRController.js +335 -335
  57. package/dist/commonjs/pixelstreamingfrontend.js +70 -70
  58. package/dist/esm/AFK/AFKController.js +105 -105
  59. package/dist/esm/Config/Config.js +551 -551
  60. package/dist/esm/Config/SettingBase.js +94 -94
  61. package/dist/esm/Config/SettingFlag.js +45 -45
  62. package/dist/esm/Config/SettingNumber.js +79 -79
  63. package/dist/esm/Config/SettingOption.js +80 -80
  64. package/dist/esm/Config/SettingText.js +38 -38
  65. package/dist/esm/DataChannel/DataChannelController.js +102 -102
  66. package/dist/esm/DataChannel/DataChannelLatencyTestController.js +90 -90
  67. package/dist/esm/DataChannel/DataChannelLatencyTestResults.js +14 -14
  68. package/dist/esm/DataChannel/DataChannelSender.js +39 -39
  69. package/dist/esm/DataChannel/InitialSettings.js +34 -34
  70. package/dist/esm/DataChannel/LatencyTestResults.js +56 -56
  71. package/dist/esm/FreezeFrame/FreezeFrame.js +89 -89
  72. package/dist/esm/FreezeFrame/FreezeFrameController.js +91 -91
  73. package/dist/esm/Inputs/GamepadController.js +184 -184
  74. package/dist/esm/Inputs/GamepadTypes.js +17 -17
  75. package/dist/esm/Inputs/IInputController.js +1 -1
  76. package/dist/esm/Inputs/InputClassesFactory.js +91 -91
  77. package/dist/esm/Inputs/KeyCodes.js +109 -109
  78. package/dist/esm/Inputs/KeyboardController.js +133 -133
  79. package/dist/esm/Inputs/MouseButtons.js +23 -23
  80. package/dist/esm/Inputs/MouseController.js +93 -93
  81. package/dist/esm/Inputs/MouseControllerHovering.js +89 -89
  82. package/dist/esm/Inputs/MouseControllerLocked.js +149 -149
  83. package/dist/esm/Inputs/SpecialKeyCodes.js +15 -15
  84. package/dist/esm/Inputs/TouchController.js +119 -119
  85. package/dist/esm/Inputs/TouchController.js.map +1 -1
  86. package/dist/esm/Inputs/TouchControllerFake.js +87 -87
  87. package/dist/esm/Inputs/XRGamepadController.js +120 -120
  88. package/dist/esm/PeerConnectionController/AggregatedStats.js +248 -248
  89. package/dist/esm/PeerConnectionController/CandidatePairStats.js +6 -6
  90. package/dist/esm/PeerConnectionController/CandidateStat.js +6 -6
  91. package/dist/esm/PeerConnectionController/CodecStats.js +6 -6
  92. package/dist/esm/PeerConnectionController/DataChannelStats.js +6 -6
  93. package/dist/esm/PeerConnectionController/InboundRTPStats.js +16 -16
  94. package/dist/esm/PeerConnectionController/InboundTrackStats.js +6 -6
  95. package/dist/esm/PeerConnectionController/OutBoundRTPStats.js +11 -11
  96. package/dist/esm/PeerConnectionController/PeerConnectionController.js +580 -580
  97. package/dist/esm/PeerConnectionController/SessionStats.js +6 -6
  98. package/dist/esm/PeerConnectionController/StreamStats.js +6 -6
  99. package/dist/esm/PixelStreaming/PixelStreaming.js +603 -603
  100. package/dist/esm/UI/OnScreenKeyboard.js +78 -78
  101. package/dist/esm/UeInstanceMessage/ResponseController.js +34 -34
  102. package/dist/esm/UeInstanceMessage/SendMessageController.js +116 -116
  103. package/dist/esm/UeInstanceMessage/StreamMessageController.js +205 -205
  104. package/dist/esm/UeInstanceMessage/ToStreamerMessagesController.js +45 -45
  105. package/dist/esm/Util/EventEmitter.js +345 -345
  106. package/dist/esm/Util/FileUtil.js +103 -103
  107. package/dist/esm/Util/IURLSearchParams.js +21 -21
  108. package/dist/esm/Util/InputCoordTranslator.js +45 -45
  109. package/dist/esm/Util/RTCUtils.js +36 -36
  110. package/dist/esm/VideoPlayer/StreamController.js +63 -63
  111. package/dist/esm/VideoPlayer/VideoPlayer.js +173 -173
  112. package/dist/esm/WebRtcPlayer/WebRtcPlayerController.js +1217 -1217
  113. package/dist/esm/WebXR/WebXRController.js +331 -331
  114. package/dist/esm/pixelstreamingfrontend.js +24 -24
  115. package/dist/types/AFK/AFKController.d.ts +38 -38
  116. package/dist/types/Config/Config.d.ts +220 -220
  117. package/dist/types/Config/SettingBase.d.ts +43 -43
  118. package/dist/types/Config/SettingFlag.d.ts +24 -24
  119. package/dist/types/Config/SettingNumber.d.ts +41 -41
  120. package/dist/types/Config/SettingOption.d.ts +41 -41
  121. package/dist/types/Config/SettingText.d.ts +21 -21
  122. package/dist/types/DataChannel/DataChannelController.d.ts +59 -59
  123. package/dist/types/DataChannel/DataChannelLatencyTestController.d.ts +25 -25
  124. package/dist/types/DataChannel/DataChannelLatencyTestResults.d.ts +46 -46
  125. package/dist/types/DataChannel/DataChannelSender.d.ts +21 -21
  126. package/dist/types/DataChannel/InitialSettings.d.ts +44 -44
  127. package/dist/types/DataChannel/LatencyTestResults.d.ts +31 -31
  128. package/dist/types/FreezeFrame/FreezeFrame.d.ts +36 -36
  129. package/dist/types/FreezeFrame/FreezeFrameController.d.ts +37 -37
  130. package/dist/types/Inputs/GamepadController.d.ts +61 -61
  131. package/dist/types/Inputs/GamepadTypes.d.ts +15 -15
  132. package/dist/types/Inputs/IInputController.d.ts +16 -16
  133. package/dist/types/Inputs/InputClassesFactory.d.ts +53 -53
  134. package/dist/types/Inputs/KeyCodes.d.ts +5 -5
  135. package/dist/types/Inputs/KeyboardController.d.ts +34 -34
  136. package/dist/types/Inputs/MouseButtons.d.ts +22 -22
  137. package/dist/types/Inputs/MouseController.d.ts +40 -40
  138. package/dist/types/Inputs/MouseControllerHovering.d.ts +26 -26
  139. package/dist/types/Inputs/MouseControllerLocked.d.ts +31 -31
  140. package/dist/types/Inputs/SpecialKeyCodes.d.ts +14 -14
  141. package/dist/types/Inputs/TouchController.d.ts +28 -28
  142. package/dist/types/Inputs/TouchControllerFake.d.ts +29 -29
  143. package/dist/types/Inputs/XRGamepadController.d.ts +15 -15
  144. package/dist/types/PeerConnectionController/AggregatedStats.d.ts +82 -82
  145. package/dist/types/PeerConnectionController/CandidatePairStats.d.ts +22 -22
  146. package/dist/types/PeerConnectionController/CandidateStat.d.ts +13 -13
  147. package/dist/types/PeerConnectionController/CodecStats.d.ts +14 -14
  148. package/dist/types/PeerConnectionController/DataChannelStats.d.ts +15 -15
  149. package/dist/types/PeerConnectionController/InboundRTPStats.d.ts +141 -141
  150. package/dist/types/PeerConnectionController/InboundTrackStats.d.ts +32 -32
  151. package/dist/types/PeerConnectionController/OutBoundRTPStats.d.ts +23 -23
  152. package/dist/types/PeerConnectionController/PeerConnectionController.d.ts +143 -143
  153. package/dist/types/PeerConnectionController/SessionStats.d.ts +8 -8
  154. package/dist/types/PeerConnectionController/StreamStats.d.ts +9 -9
  155. package/dist/types/PixelStreaming/PixelStreaming.d.ts +271 -271
  156. package/dist/types/UI/OnScreenKeyboard.d.ts +30 -30
  157. package/dist/types/UeInstanceMessage/ResponseController.d.ts +19 -19
  158. package/dist/types/UeInstanceMessage/SendMessageController.d.ts +18 -18
  159. package/dist/types/UeInstanceMessage/StreamMessageController.d.ts +29 -29
  160. package/dist/types/UeInstanceMessage/ToStreamerMessagesController.d.ts +32 -32
  161. package/dist/types/Util/EventEmitter.d.ts +429 -429
  162. package/dist/types/Util/FileUtil.d.ts +32 -32
  163. package/dist/types/Util/IURLSearchParams.d.ts +9 -9
  164. package/dist/types/Util/InputCoordTranslator.d.ts +29 -29
  165. package/dist/types/Util/RTCUtils.d.ts +8 -8
  166. package/dist/types/VideoPlayer/StreamController.d.ts +22 -22
  167. package/dist/types/VideoPlayer/VideoPlayer.d.ts +78 -78
  168. package/dist/types/WebRtcPlayer/WebRtcPlayerController.d.ts +379 -379
  169. package/dist/types/WebXR/WebXRController.d.ts +42 -42
  170. package/dist/types/pixelstreamingfrontend.d.ts +23 -23
  171. package/package.json +45 -45
  172. package/src/Inputs/TouchController.ts +3 -3
@@ -1,95 +1,95 @@
1
- // Copyright Epic Games, Inc. All Rights Reserved.
2
- /**
3
- * Base class for a setting that has a text label and an arbitrary setting value it stores.
4
- */
5
- export class SettingBase {
6
- constructor(id, label, description, defaultSettingValue,
7
- // eslint-disable-next-line @typescript-eslint/no-empty-function
8
- defaultOnChangeListener = () => {
9
- /* Do nothing, to be overridden. */
10
- }) {
11
- this.parseURLParams();
12
- this.onChange = defaultOnChangeListener;
13
- this.onChangeEmit = () => {
14
- /* Do nothing, to be overridden. */
15
- };
16
- this.id = id;
17
- this.description = description;
18
- this.label = label;
19
- this.value = defaultSettingValue;
20
- }
21
- /**
22
- * Set the label text for the setting.
23
- * @param label setting label.
24
- */
25
- set label(inLabel) {
26
- this._label = inLabel;
27
- this.onChangeEmit(this._value);
28
- }
29
- /**
30
- * @returns The label text for the setting.
31
- */
32
- get label() {
33
- return this._label;
34
- }
35
- /**
36
- * @return The setting's value.
37
- */
38
- get value() {
39
- return this._value;
40
- }
41
- /**
42
- * Update the setting's stored value.
43
- * @param inValue The new value for the setting.
44
- */
45
- set value(inValue) {
46
- this._value = inValue;
47
- this.onChange(this._value, this);
48
- this.onChangeEmit(this._value);
49
- }
50
- /**
51
- * Persist the setting value in URL.
52
- */
53
- updateURLParams() {
54
- if (this.useUrlParams) {
55
- // set url params
56
- const urlParams = new URLSearchParams(window.location.search);
57
- const valueString = this.getValueAsString();
58
- let set = false;
59
- for (const [name, _value] of urlParams) {
60
- if (name.toLowerCase() == this.id.toLowerCase()) {
61
- urlParams.set(name, valueString);
62
- set = true;
63
- break;
64
- }
65
- }
66
- if (!set) {
67
- urlParams.set(this.id, valueString);
68
- }
69
- window.history.replaceState({}, '', urlParams.toString() !== '' ? `${location.pathname}?${urlParams}` : `${location.pathname}`);
70
- }
71
- }
72
- /**
73
- * Allows sub types to provide their value for the url search params.
74
- */
75
- getValueAsString() {
76
- return '';
77
- }
78
- parseURLParams() {
79
- this._urlParams = {};
80
- const params = new URLSearchParams(window.location.search);
81
- for (const [name, value] of params) {
82
- this._urlParams[name.toLowerCase()] = value;
83
- }
84
- }
85
- hasURLParam(name) {
86
- return name.toLowerCase() in this._urlParams;
87
- }
88
- getURLParam(name) {
89
- if (this.hasURLParam(name)) {
90
- return this._urlParams[name.toLowerCase()];
91
- }
92
- return '';
93
- }
94
- }
1
+ // Copyright Epic Games, Inc. All Rights Reserved.
2
+ /**
3
+ * Base class for a setting that has a text label and an arbitrary setting value it stores.
4
+ */
5
+ export class SettingBase {
6
+ constructor(id, label, description, defaultSettingValue,
7
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
8
+ defaultOnChangeListener = () => {
9
+ /* Do nothing, to be overridden. */
10
+ }) {
11
+ this.parseURLParams();
12
+ this.onChange = defaultOnChangeListener;
13
+ this.onChangeEmit = () => {
14
+ /* Do nothing, to be overridden. */
15
+ };
16
+ this.id = id;
17
+ this.description = description;
18
+ this.label = label;
19
+ this.value = defaultSettingValue;
20
+ }
21
+ /**
22
+ * Set the label text for the setting.
23
+ * @param label setting label.
24
+ */
25
+ set label(inLabel) {
26
+ this._label = inLabel;
27
+ this.onChangeEmit(this._value);
28
+ }
29
+ /**
30
+ * @returns The label text for the setting.
31
+ */
32
+ get label() {
33
+ return this._label;
34
+ }
35
+ /**
36
+ * @return The setting's value.
37
+ */
38
+ get value() {
39
+ return this._value;
40
+ }
41
+ /**
42
+ * Update the setting's stored value.
43
+ * @param inValue The new value for the setting.
44
+ */
45
+ set value(inValue) {
46
+ this._value = inValue;
47
+ this.onChange(this._value, this);
48
+ this.onChangeEmit(this._value);
49
+ }
50
+ /**
51
+ * Persist the setting value in URL.
52
+ */
53
+ updateURLParams() {
54
+ if (this.useUrlParams) {
55
+ // set url params
56
+ const urlParams = new URLSearchParams(window.location.search);
57
+ const valueString = this.getValueAsString();
58
+ let set = false;
59
+ for (const [name, _value] of urlParams) {
60
+ if (name.toLowerCase() == this.id.toLowerCase()) {
61
+ urlParams.set(name, valueString);
62
+ set = true;
63
+ break;
64
+ }
65
+ }
66
+ if (!set) {
67
+ urlParams.set(this.id, valueString);
68
+ }
69
+ window.history.replaceState({}, '', urlParams.toString() !== '' ? `${location.pathname}?${urlParams}` : `${location.pathname}`);
70
+ }
71
+ }
72
+ /**
73
+ * Allows sub types to provide their value for the url search params.
74
+ */
75
+ getValueAsString() {
76
+ return '';
77
+ }
78
+ parseURLParams() {
79
+ this._urlParams = {};
80
+ const params = new URLSearchParams(window.location.search);
81
+ for (const [name, value] of params) {
82
+ this._urlParams[name.toLowerCase()] = value;
83
+ }
84
+ }
85
+ hasURLParam(name) {
86
+ return name.toLowerCase() in this._urlParams;
87
+ }
88
+ getURLParam(name) {
89
+ if (this.hasURLParam(name)) {
90
+ return this._urlParams[name.toLowerCase()];
91
+ }
92
+ return '';
93
+ }
94
+ }
95
95
  //# sourceMappingURL=SettingBase.js.map
@@ -1,46 +1,46 @@
1
- // Copyright Epic Games, Inc. All Rights Reserved.
2
- import { SettingBase } from './SettingBase';
3
- /**
4
- * A boolean flag setting object with a text label.
5
- */
6
- export class SettingFlag extends SettingBase {
7
- constructor(id, label, description, defaultFlagValue, useUrlParams,
8
- // eslint-disable-next-line @typescript-eslint/no-empty-function
9
- defaultOnChangeListener = () => {
10
- /* Do nothing, to be overridden. */
11
- }) {
12
- super(id, label, description, defaultFlagValue, defaultOnChangeListener);
13
- if (!useUrlParams || !this.hasURLParam(this.id)) {
14
- this.flag = defaultFlagValue;
15
- }
16
- else {
17
- // parse flag from url parameters
18
- const urlParamFlag = this.getURLParam(this.id);
19
- this.flag = urlParamFlag.toLowerCase() != 'false';
20
- }
21
- this.useUrlParams = useUrlParams;
22
- }
23
- getValueAsString() {
24
- return this.flag ? 'true' : 'false';
25
- }
26
- /**
27
- * Enables this flag.
28
- */
29
- enable() {
30
- this.flag = true;
31
- }
32
- /**
33
- * @return The setting's value.
34
- */
35
- get flag() {
36
- return !!this.value;
37
- }
38
- /**
39
- * Update the setting's stored value.
40
- * @param inValue The new value for the setting.
41
- */
42
- set flag(inValue) {
43
- this.value = inValue;
44
- }
45
- }
1
+ // Copyright Epic Games, Inc. All Rights Reserved.
2
+ import { SettingBase } from './SettingBase';
3
+ /**
4
+ * A boolean flag setting object with a text label.
5
+ */
6
+ export class SettingFlag extends SettingBase {
7
+ constructor(id, label, description, defaultFlagValue, useUrlParams,
8
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
9
+ defaultOnChangeListener = () => {
10
+ /* Do nothing, to be overridden. */
11
+ }) {
12
+ super(id, label, description, defaultFlagValue, defaultOnChangeListener);
13
+ if (!useUrlParams || !this.hasURLParam(this.id)) {
14
+ this.flag = defaultFlagValue;
15
+ }
16
+ else {
17
+ // parse flag from url parameters
18
+ const urlParamFlag = this.getURLParam(this.id);
19
+ this.flag = urlParamFlag.toLowerCase() != 'false';
20
+ }
21
+ this.useUrlParams = useUrlParams;
22
+ }
23
+ getValueAsString() {
24
+ return this.flag ? 'true' : 'false';
25
+ }
26
+ /**
27
+ * Enables this flag.
28
+ */
29
+ enable() {
30
+ this.flag = true;
31
+ }
32
+ /**
33
+ * @return The setting's value.
34
+ */
35
+ get flag() {
36
+ return !!this.value;
37
+ }
38
+ /**
39
+ * Update the setting's stored value.
40
+ * @param inValue The new value for the setting.
41
+ */
42
+ set flag(inValue) {
43
+ this.value = inValue;
44
+ }
45
+ }
46
46
  //# sourceMappingURL=SettingFlag.js.map
@@ -1,80 +1,80 @@
1
- // Copyright Epic Games, Inc. All Rights Reserved.
2
- import { SettingBase } from './SettingBase';
3
- /**
4
- * A number setting object with a text label. Min and max limit the range of allowed values.
5
- */
6
- export class SettingNumber extends SettingBase {
7
- constructor(id, label, description, min, max, defaultNumber, useUrlParams,
8
- // eslint-disable-next-line @typescript-eslint/no-empty-function
9
- defaultOnChangeListener = () => {
10
- /* Do nothing, to be overridden. */
11
- }) {
12
- super(id, label, description, defaultNumber, defaultOnChangeListener);
13
- this._min = min;
14
- this._max = max;
15
- // attempt to read the number from the url params
16
- if (!useUrlParams || !this.hasURLParam(this.id)) {
17
- this.number = defaultNumber;
18
- }
19
- else {
20
- const parsedValue = Number.parseFloat(this.getURLParam(this.id));
21
- this.number = Number.isNaN(parsedValue) ? defaultNumber : parsedValue;
22
- }
23
- this.useUrlParams = useUrlParams;
24
- }
25
- getValueAsString() {
26
- return this.number.toString();
27
- }
28
- /**
29
- * Set the number value (will be clamped within range).
30
- */
31
- set number(newNumber) {
32
- this.value = this.clamp(newNumber);
33
- }
34
- /**
35
- * @returns The number stored.
36
- */
37
- get number() {
38
- return this.value;
39
- }
40
- /**
41
- * Clamps a number between the min and max values (inclusive).
42
- * @param inNumber The number to clamp.
43
- * @returns The clamped number.
44
- */
45
- clamp(inNumber) {
46
- if (this._min == null && this._max == null) {
47
- return inNumber;
48
- }
49
- else if (this._min == null) {
50
- return Math.min(this._max, inNumber);
51
- }
52
- else if (this._max == null) {
53
- return Math.max(this._min, inNumber);
54
- }
55
- else {
56
- return Math.max(Math.min(this._max, inNumber), this._min);
57
- }
58
- }
59
- /**
60
- * Returns the minimum value
61
- * @returns The minimum value
62
- */
63
- get min() {
64
- return this._min;
65
- }
66
- /**
67
- * Returns the maximum value
68
- * @returns The maximum value
69
- */
70
- get max() {
71
- return this._max;
72
- }
73
- /**
74
- * Add a change listener to the number object.
75
- */
76
- addOnChangedListener(onChangedFunc) {
77
- this.onChange = onChangedFunc;
78
- }
79
- }
1
+ // Copyright Epic Games, Inc. All Rights Reserved.
2
+ import { SettingBase } from './SettingBase';
3
+ /**
4
+ * A number setting object with a text label. Min and max limit the range of allowed values.
5
+ */
6
+ export class SettingNumber extends SettingBase {
7
+ constructor(id, label, description, min, max, defaultNumber, useUrlParams,
8
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
9
+ defaultOnChangeListener = () => {
10
+ /* Do nothing, to be overridden. */
11
+ }) {
12
+ super(id, label, description, defaultNumber, defaultOnChangeListener);
13
+ this._min = min;
14
+ this._max = max;
15
+ // attempt to read the number from the url params
16
+ if (!useUrlParams || !this.hasURLParam(this.id)) {
17
+ this.number = defaultNumber;
18
+ }
19
+ else {
20
+ const parsedValue = Number.parseFloat(this.getURLParam(this.id));
21
+ this.number = Number.isNaN(parsedValue) ? defaultNumber : parsedValue;
22
+ }
23
+ this.useUrlParams = useUrlParams;
24
+ }
25
+ getValueAsString() {
26
+ return this.number.toString();
27
+ }
28
+ /**
29
+ * Set the number value (will be clamped within range).
30
+ */
31
+ set number(newNumber) {
32
+ this.value = this.clamp(newNumber);
33
+ }
34
+ /**
35
+ * @returns The number stored.
36
+ */
37
+ get number() {
38
+ return this.value;
39
+ }
40
+ /**
41
+ * Clamps a number between the min and max values (inclusive).
42
+ * @param inNumber The number to clamp.
43
+ * @returns The clamped number.
44
+ */
45
+ clamp(inNumber) {
46
+ if (this._min == null && this._max == null) {
47
+ return inNumber;
48
+ }
49
+ else if (this._min == null) {
50
+ return Math.min(this._max, inNumber);
51
+ }
52
+ else if (this._max == null) {
53
+ return Math.max(this._min, inNumber);
54
+ }
55
+ else {
56
+ return Math.max(Math.min(this._max, inNumber), this._min);
57
+ }
58
+ }
59
+ /**
60
+ * Returns the minimum value
61
+ * @returns The minimum value
62
+ */
63
+ get min() {
64
+ return this._min;
65
+ }
66
+ /**
67
+ * Returns the maximum value
68
+ * @returns The maximum value
69
+ */
70
+ get max() {
71
+ return this._max;
72
+ }
73
+ /**
74
+ * Add a change listener to the number object.
75
+ */
76
+ addOnChangedListener(onChangedFunc) {
77
+ this.onChange = onChangedFunc;
78
+ }
79
+ }
80
80
  //# sourceMappingURL=SettingNumber.js.map
@@ -1,81 +1,81 @@
1
- // Copyright Epic Games, Inc. All Rights Reserved.
2
- import { Logger } from '@epicgames-ps/lib-pixelstreamingcommon-ue5.5';
3
- import { SettingBase } from './SettingBase';
4
- /**
5
- * An Option setting object with a text label. Allows you to specify an array of options and select one of them.
6
- */
7
- export class SettingOption extends SettingBase {
8
- constructor(id, label, description, defaultTextValue, options, useUrlParams,
9
- // eslint-disable-next-line @typescript-eslint/no-empty-function
10
- defaultUrlParamResolver = function (value) {
11
- /* Return the string as-is by default */
12
- return value;
13
- },
14
- // eslint-disable-next-line @typescript-eslint/no-empty-function
15
- defaultOnChangeListener = () => {
16
- /* Do nothing, to be overridden. */
17
- }) {
18
- super(id, label, description, defaultTextValue, defaultOnChangeListener);
19
- this._urlParamResolver = defaultUrlParamResolver;
20
- const stringToMatch = this.hasURLParam(this.id)
21
- ? this._urlParamResolver(this.getURLParam(this.id))
22
- : defaultTextValue;
23
- this.options = options !== null && options !== void 0 ? options : [stringToMatch];
24
- this.selected = stringToMatch;
25
- this.useUrlParams = useUrlParams;
26
- }
27
- getValueAsString() {
28
- return this.selected;
29
- }
30
- /**
31
- * Add a change listener to the select element.
32
- */
33
- addOnChangedListener(onChangedFunc) {
34
- this.onChange = onChangedFunc;
35
- }
36
- /**
37
- * @returns All available options as an array
38
- */
39
- get options() {
40
- return this._options;
41
- }
42
- /**
43
- * Set options
44
- * @param values Array of options
45
- */
46
- set options(values) {
47
- this._options = values;
48
- this.onChangeEmit(this.selected);
49
- }
50
- /**
51
- * @returns Selected option as a string
52
- */
53
- get selected() {
54
- return this.value;
55
- }
56
- /**
57
- * Set selected option if it matches one of the available options
58
- * @param value Selected option
59
- */
60
- set selected(value) {
61
- if (value === undefined) {
62
- return;
63
- }
64
- // If options contains the value, then set that as selected
65
- if (this.options.includes(value)) {
66
- this.value = value;
67
- }
68
- else {
69
- Logger.Error(`Could not set "${value}" as the selected option for ${this.id} because it wasn't one of the options.`);
70
- }
71
- }
72
- /**
73
- * Set the url parameter resolver to do some transformation to the string value
74
- * that is extracted from the url parameters.
75
- * @param urlParam A function that transforms the extracted url parameter string for this setting to something else.
76
- */
77
- set urlParamResolver(value) {
78
- this._urlParamResolver = value;
79
- }
80
- }
1
+ // Copyright Epic Games, Inc. All Rights Reserved.
2
+ import { Logger } from '@epicgames-ps/lib-pixelstreamingcommon-ue5.5';
3
+ import { SettingBase } from './SettingBase';
4
+ /**
5
+ * An Option setting object with a text label. Allows you to specify an array of options and select one of them.
6
+ */
7
+ export class SettingOption extends SettingBase {
8
+ constructor(id, label, description, defaultTextValue, options, useUrlParams,
9
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
10
+ defaultUrlParamResolver = function (value) {
11
+ /* Return the string as-is by default */
12
+ return value;
13
+ },
14
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
15
+ defaultOnChangeListener = () => {
16
+ /* Do nothing, to be overridden. */
17
+ }) {
18
+ super(id, label, description, defaultTextValue, defaultOnChangeListener);
19
+ this._urlParamResolver = defaultUrlParamResolver;
20
+ const stringToMatch = this.hasURLParam(this.id)
21
+ ? this._urlParamResolver(this.getURLParam(this.id))
22
+ : defaultTextValue;
23
+ this.options = options !== null && options !== void 0 ? options : [stringToMatch];
24
+ this.selected = stringToMatch;
25
+ this.useUrlParams = useUrlParams;
26
+ }
27
+ getValueAsString() {
28
+ return this.selected;
29
+ }
30
+ /**
31
+ * Add a change listener to the select element.
32
+ */
33
+ addOnChangedListener(onChangedFunc) {
34
+ this.onChange = onChangedFunc;
35
+ }
36
+ /**
37
+ * @returns All available options as an array
38
+ */
39
+ get options() {
40
+ return this._options;
41
+ }
42
+ /**
43
+ * Set options
44
+ * @param values Array of options
45
+ */
46
+ set options(values) {
47
+ this._options = values;
48
+ this.onChangeEmit(this.selected);
49
+ }
50
+ /**
51
+ * @returns Selected option as a string
52
+ */
53
+ get selected() {
54
+ return this.value;
55
+ }
56
+ /**
57
+ * Set selected option if it matches one of the available options
58
+ * @param value Selected option
59
+ */
60
+ set selected(value) {
61
+ if (value === undefined) {
62
+ return;
63
+ }
64
+ // If options contains the value, then set that as selected
65
+ if (this.options.includes(value)) {
66
+ this.value = value;
67
+ }
68
+ else {
69
+ Logger.Error(`Could not set "${value}" as the selected option for ${this.id} because it wasn't one of the options.`);
70
+ }
71
+ }
72
+ /**
73
+ * Set the url parameter resolver to do some transformation to the string value
74
+ * that is extracted from the url parameters.
75
+ * @param urlParam A function that transforms the extracted url parameter string for this setting to something else.
76
+ */
77
+ set urlParamResolver(value) {
78
+ this._urlParamResolver = value;
79
+ }
80
+ }
81
81
  //# sourceMappingURL=SettingOption.js.map