@oidoid/void 0.1.7 → 0.1.8

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 (168) hide show
  1. package/dist/public/index.js +1 -1
  2. package/dist/public/index.js.map +1 -1
  3. package/dist/public/{void-v0.1.7+20260106.c6b562a.html → void-v0.1.8+20260106.f2ce523.html} +2 -2
  4. package/dist/src/demo/ents/clock.test.d.ts +2 -0
  5. package/dist/src/demo/ents/clock.test.d.ts.map +1 -0
  6. package/dist/src/demo/ents/clock.test.js +24 -0
  7. package/dist/src/demo/ents/clock.test.js.map +1 -0
  8. package/dist/src/demo/tsconfig.json +3 -3
  9. package/dist/src/ents/cursor.test.d.ts +2 -0
  10. package/dist/src/ents/cursor.test.d.ts.map +1 -0
  11. package/dist/src/ents/cursor.test.js +92 -0
  12. package/dist/src/ents/cursor.test.js.map +1 -0
  13. package/dist/src/ents/ent-query.test.d.ts +11 -0
  14. package/dist/src/ents/ent-query.test.d.ts.map +1 -0
  15. package/dist/src/ents/ent-query.test.js +63 -0
  16. package/dist/src/ents/ent-query.test.js.map +1 -0
  17. package/dist/src/graphics/atlas-parser.test.d.ts +2 -0
  18. package/dist/src/graphics/atlas-parser.test.d.ts.map +1 -0
  19. package/dist/src/graphics/atlas-parser.test.js +100 -0
  20. package/dist/src/graphics/atlas-parser.test.js.map +1 -0
  21. package/dist/src/graphics/cam.test.d.ts +2 -0
  22. package/dist/src/graphics/cam.test.d.ts.map +1 -0
  23. package/dist/src/graphics/cam.test.js +456 -0
  24. package/dist/src/graphics/cam.test.js.map +1 -0
  25. package/dist/src/graphics/layer.test.d.ts +2 -0
  26. package/dist/src/graphics/layer.test.d.ts.map +1 -0
  27. package/dist/src/graphics/layer.test.js +23 -0
  28. package/dist/src/graphics/layer.test.js.map +1 -0
  29. package/dist/src/graphics/renderer.test.d.ts +2 -0
  30. package/dist/src/graphics/renderer.test.d.ts.map +1 -0
  31. package/dist/src/graphics/renderer.test.js +92 -0
  32. package/dist/src/graphics/renderer.test.js.map +1 -0
  33. package/dist/src/graphics/sprite.test.d.ts +2 -0
  34. package/dist/src/graphics/sprite.test.d.ts.map +1 -0
  35. package/dist/src/graphics/sprite.test.js +582 -0
  36. package/dist/src/graphics/sprite.test.js.map +1 -0
  37. package/dist/src/index.d.ts.map +1 -1
  38. package/dist/src/index.js +0 -1
  39. package/dist/src/index.js.map +1 -1
  40. package/dist/src/input/context-menu.test.d.ts +2 -0
  41. package/dist/src/input/context-menu.test.d.ts.map +1 -0
  42. package/dist/src/input/context-menu.test.js +111 -0
  43. package/dist/src/input/context-menu.test.js.map +1 -0
  44. package/dist/src/input/gamepad.test.d.ts +2 -0
  45. package/dist/src/input/gamepad.test.d.ts.map +1 -0
  46. package/dist/src/input/gamepad.test.js +172 -0
  47. package/dist/src/input/gamepad.test.js.map +1 -0
  48. package/dist/src/input/input.test.d.ts +2 -0
  49. package/dist/src/input/input.test.d.ts.map +1 -0
  50. package/dist/src/input/input.test.js +1146 -0
  51. package/dist/src/input/input.test.js.map +1 -0
  52. package/dist/src/input/keyboard.test.d.ts +2 -0
  53. package/dist/src/input/keyboard.test.d.ts.map +1 -0
  54. package/dist/src/input/keyboard.test.js +159 -0
  55. package/dist/src/input/keyboard.test.js.map +1 -0
  56. package/dist/src/input/pointer.test.d.ts +2 -0
  57. package/dist/src/input/pointer.test.d.ts.map +1 -0
  58. package/dist/src/input/pointer.test.js +339 -0
  59. package/dist/src/input/pointer.test.js.map +1 -0
  60. package/dist/src/input/wheel.test.d.ts +2 -0
  61. package/dist/src/input/wheel.test.d.ts.map +1 -0
  62. package/dist/src/input/wheel.test.js +92 -0
  63. package/dist/src/input/wheel.test.js.map +1 -0
  64. package/dist/src/level/level-parser.test.d.ts +20 -0
  65. package/dist/src/level/level-parser.test.d.ts.map +1 -0
  66. package/dist/src/level/level-parser.test.js +340 -0
  67. package/dist/src/level/level-parser.test.js.map +1 -0
  68. package/dist/src/looper.test.d.ts +2 -0
  69. package/dist/src/looper.test.d.ts.map +1 -0
  70. package/dist/src/looper.test.js +128 -0
  71. package/dist/src/looper.test.js.map +1 -0
  72. package/dist/src/mem/pool.test.d.ts +2 -0
  73. package/dist/src/mem/pool.test.d.ts.map +1 -0
  74. package/dist/src/mem/pool.test.js +120 -0
  75. package/dist/src/mem/pool.test.js.map +1 -0
  76. package/dist/src/random/random.test.d.ts +2 -0
  77. package/dist/src/random/random.test.d.ts.map +1 -0
  78. package/dist/src/random/random.test.js +36 -0
  79. package/dist/src/random/random.test.js.map +1 -0
  80. package/dist/src/storage/local-storage.test.d.ts +2 -0
  81. package/dist/src/storage/local-storage.test.d.ts.map +1 -0
  82. package/dist/src/storage/local-storage.test.js +105 -0
  83. package/dist/src/storage/local-storage.test.js.map +1 -0
  84. package/dist/src/test/assert.d.ts +5 -0
  85. package/dist/src/test/assert.d.ts.map +1 -0
  86. package/dist/src/test/assert.js +6 -0
  87. package/dist/src/test/assert.js.map +1 -0
  88. package/dist/src/test/device-pixel-ratio-mock.d.ts +6 -0
  89. package/dist/src/test/device-pixel-ratio-mock.d.ts.map +1 -0
  90. package/dist/src/test/device-pixel-ratio-mock.js +10 -0
  91. package/dist/src/test/device-pixel-ratio-mock.js.map +1 -0
  92. package/dist/src/test/index.d.ts +5 -0
  93. package/dist/src/test/index.d.ts.map +1 -0
  94. package/dist/src/test/index.js +5 -0
  95. package/dist/src/test/index.js.map +1 -0
  96. package/dist/src/test/navigator-gamepads-mock.d.ts +7 -0
  97. package/dist/src/test/navigator-gamepads-mock.d.ts.map +1 -0
  98. package/dist/src/test/navigator-gamepads-mock.js +14 -0
  99. package/dist/src/test/navigator-gamepads-mock.js.map +1 -0
  100. package/dist/src/test/secure-context-mock.d.ts +6 -0
  101. package/dist/src/test/secure-context-mock.d.ts.map +1 -0
  102. package/dist/src/test/secure-context-mock.js +10 -0
  103. package/dist/src/test/secure-context-mock.js.map +1 -0
  104. package/dist/src/test/test-element.d.ts +2 -0
  105. package/dist/src/test/test-element.d.ts.map +1 -0
  106. package/dist/src/test/test-element.js +8 -0
  107. package/dist/src/test/test-element.js.map +1 -0
  108. package/dist/src/test/test-event.d.ts +17 -0
  109. package/dist/src/test/test-event.d.ts.map +1 -0
  110. package/dist/src/test/test-event.js +26 -0
  111. package/dist/src/test/test-event.js.map +1 -0
  112. package/dist/src/test/tsconfig.json +30 -0
  113. package/dist/src/text/text-layout.test.d.ts +2 -0
  114. package/dist/src/text/text-layout.test.d.ts.map +1 -0
  115. package/dist/src/text/text-layout.test.js +717 -0
  116. package/dist/src/text/text-layout.test.js.map +1 -0
  117. package/dist/src/tsconfig.json +3 -3
  118. package/dist/src/types/geo.test.d.ts +2 -0
  119. package/dist/src/types/geo.test.d.ts.map +1 -0
  120. package/dist/src/types/geo.test.js +657 -0
  121. package/dist/src/types/geo.test.js.map +1 -0
  122. package/dist/src/types/time.test.d.ts +2 -0
  123. package/dist/src/types/time.test.d.ts.map +1 -0
  124. package/dist/src/types/time.test.js +27 -0
  125. package/dist/src/types/time.test.js.map +1 -0
  126. package/dist/src/utils/async-util.test.d.ts +2 -0
  127. package/dist/src/utils/async-util.test.d.ts.map +1 -0
  128. package/dist/src/utils/async-util.test.js +55 -0
  129. package/dist/src/utils/async-util.test.js.map +1 -0
  130. package/dist/src/utils/color-util.test.d.ts +2 -0
  131. package/dist/src/utils/color-util.test.d.ts.map +1 -0
  132. package/dist/src/utils/color-util.test.js +20 -0
  133. package/dist/src/utils/color-util.test.js.map +1 -0
  134. package/dist/src/utils/debug.test.d.ts +2 -0
  135. package/dist/src/utils/debug.test.d.ts.map +1 -0
  136. package/dist/src/utils/debug.test.js +61 -0
  137. package/dist/src/utils/debug.test.js.map +1 -0
  138. package/dist/src/utils/delay-interval.test.d.ts +2 -0
  139. package/dist/src/utils/delay-interval.test.d.ts.map +1 -0
  140. package/dist/src/utils/delay-interval.test.js +91 -0
  141. package/dist/src/utils/delay-interval.test.js.map +1 -0
  142. package/dist/src/utils/math.test.d.ts +2 -0
  143. package/dist/src/utils/math.test.d.ts.map +1 -0
  144. package/dist/src/utils/math.test.js +10 -0
  145. package/dist/src/utils/math.test.js.map +1 -0
  146. package/dist/src/utils/str-util.test.d.ts +2 -0
  147. package/dist/src/utils/str-util.test.d.ts.map +1 -0
  148. package/dist/src/utils/str-util.test.js +13 -0
  149. package/dist/src/utils/str-util.test.js.map +1 -0
  150. package/dist/tools/atlas-pack/atlas-json-parser.test.d.ts +2 -0
  151. package/dist/tools/atlas-pack/atlas-json-parser.test.d.ts.map +1 -0
  152. package/dist/tools/atlas-pack/atlas-json-parser.test.js +2109 -0
  153. package/dist/tools/atlas-pack/atlas-json-parser.test.js.map +1 -0
  154. package/dist/tools/atlas-pack/atlas.test.aseprite.json +4499 -0
  155. package/dist/tools/bundle/bundle.js +1 -1
  156. package/dist/tools/types/config-file.test.d.ts +2 -0
  157. package/dist/tools/types/config-file.test.d.ts.map +1 -0
  158. package/dist/tools/types/config-file.test.js +68 -0
  159. package/dist/tools/types/config-file.test.js.map +1 -0
  160. package/dist/tools/types/config.test.d.ts +2 -0
  161. package/dist/tools/types/config.test.d.ts.map +1 -0
  162. package/dist/tools/types/config.test.js +125 -0
  163. package/dist/tools/types/config.test.js.map +1 -0
  164. package/dist/tools/utils/argv.test.d.ts +9 -0
  165. package/dist/tools/utils/argv.test.d.ts.map +1 -0
  166. package/dist/tools/utils/argv.test.js +42 -0
  167. package/dist/tools/utils/argv.test.js.map +1 -0
  168. package/package.json +7 -3
@@ -0,0 +1,1146 @@
1
+ var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
2
+ if (value !== null && value !== void 0) {
3
+ if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
4
+ var dispose, inner;
5
+ if (async) {
6
+ if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
7
+ dispose = value[Symbol.asyncDispose];
8
+ }
9
+ if (dispose === void 0) {
10
+ if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
11
+ dispose = value[Symbol.dispose];
12
+ if (async) inner = dispose;
13
+ }
14
+ if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
15
+ if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
16
+ env.stack.push({ value: value, dispose: dispose, async: async });
17
+ }
18
+ else if (async) {
19
+ env.stack.push({ async: true });
20
+ }
21
+ return value;
22
+ };
23
+ var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
24
+ return function (env) {
25
+ function fail(e) {
26
+ env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
27
+ env.hasError = true;
28
+ }
29
+ var r, s = 0;
30
+ function next() {
31
+ while (r = env.stack.pop()) {
32
+ try {
33
+ if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
34
+ if (r.dispose) {
35
+ var result = r.dispose.call(r.value);
36
+ if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
37
+ }
38
+ else s |= 1;
39
+ }
40
+ catch (e) {
41
+ fail(e);
42
+ }
43
+ }
44
+ if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
45
+ if (env.hasError) throw env.error;
46
+ }
47
+ return next();
48
+ };
49
+ })(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
50
+ var e = new Error(message);
51
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
52
+ });
53
+ import { afterEach, beforeEach, test } from 'node:test';
54
+ import { Cam } from "../graphics/cam.js";
55
+ import { assert } from "../test/assert.js";
56
+ import { DevicePixelRatioMock } from "../test/device-pixel-ratio-mock.js";
57
+ import { SecureContextMock } from "../test/secure-context-mock.js";
58
+ import { TestElement } from "../test/test-element.js";
59
+ import { KeyTestEvent, PointerTestEvent, WheelTestEvent } from "../test/test-event.js";
60
+ import { Input } from "./input.js";
61
+ beforeEach(() => {
62
+ globalThis.addEventListener = () => { };
63
+ globalThis.removeEventListener = () => { };
64
+ });
65
+ afterEach(() => {
66
+ delete globalThis.addEventListener;
67
+ delete globalThis.removeEventListener;
68
+ });
69
+ test('init', async (ctx) => {
70
+ const env_1 = { stack: [], error: void 0, hasError: false };
71
+ try {
72
+ const secureContext = __addDisposableResource(env_1, new SecureContextMock(), false);
73
+ secureContext.secure = false;
74
+ const dpr = __addDisposableResource(env_1, new DevicePixelRatioMock(), false);
75
+ dpr.ratio = 1;
76
+ const target = TestElement();
77
+ const input = __addDisposableResource(env_1, DefaultInput(DefaultCam(), target).register('add'), false);
78
+ await ctx.test('no update', () => {
79
+ assert(input.on, []);
80
+ assert(input.handled, false);
81
+ assert(input.invalid, false);
82
+ assert(input.gestured, false);
83
+ assert(input.held, false);
84
+ assert(input.started, false);
85
+ assertButton(input, 'U', 'Off');
86
+ assertCombo(input, [['U']], 'Unequal');
87
+ assert(input.point, undefined);
88
+ assert(input.wheel, undefined);
89
+ });
90
+ await ctx.test('no change after update', () => {
91
+ input.update(16);
92
+ assert(input.on, []);
93
+ assert(input.handled, false);
94
+ assert(input.invalid, false);
95
+ assert(input.gestured, false);
96
+ assert(input.held, false);
97
+ assert(input.started, false);
98
+ assertButton(input, 'U', 'Off');
99
+ assertCombo(input, [['U']], 'Unequal');
100
+ assert(input.point, undefined);
101
+ assert(input.wheel, undefined);
102
+ });
103
+ }
104
+ catch (e_1) {
105
+ env_1.error = e_1;
106
+ env_1.hasError = true;
107
+ }
108
+ finally {
109
+ __disposeResources(env_1);
110
+ }
111
+ });
112
+ test('held off', () => {
113
+ const env_2 = { stack: [], error: void 0, hasError: false };
114
+ try {
115
+ const secureContext = __addDisposableResource(env_2, new SecureContextMock(), false);
116
+ secureContext.secure = false;
117
+ const dpr = __addDisposableResource(env_2, new DevicePixelRatioMock(), false);
118
+ dpr.ratio = 1;
119
+ const target = TestElement();
120
+ const input = __addDisposableResource(env_2, DefaultInput(DefaultCam(), target).register('add'), false);
121
+ input.update((input.comboMaxIntervalMillis + 1));
122
+ assert(input.on, []);
123
+ assert(input.invalid, false);
124
+ assert(input.gestured, false);
125
+ assert(input.held, true);
126
+ assert(input.started, false);
127
+ assertButton(input, 'U', 'Off');
128
+ assertCombo(input, [['U']], 'Unequal');
129
+ }
130
+ catch (e_2) {
131
+ env_2.error = e_2;
132
+ env_2.hasError = true;
133
+ }
134
+ finally {
135
+ __disposeResources(env_2);
136
+ }
137
+ });
138
+ test('pressed buttons', async (ctx) => {
139
+ const env_3 = { stack: [], error: void 0, hasError: false };
140
+ try {
141
+ const secureContext = __addDisposableResource(env_3, new SecureContextMock(), false);
142
+ secureContext.secure = false;
143
+ const dpr = __addDisposableResource(env_3, new DevicePixelRatioMock(), false);
144
+ dpr.ratio = 1;
145
+ const target = TestElement();
146
+ const input = __addDisposableResource(env_3, DefaultInput(DefaultCam(), target).register('add'), false);
147
+ await ctx.test('pressed are active and triggered', () => {
148
+ target.dispatchEvent(KeyTestEvent('keydown', { code: 'ArrowUp' }));
149
+ input.update(16);
150
+ assert(input.on, ['U']);
151
+ assert(input.invalid, true);
152
+ assert(input.gestured, true);
153
+ assert(input.held, false);
154
+ assert(input.started, true);
155
+ assertButton(input, 'U', 'On', 'Start');
156
+ assertCombo(input, [['U']], 'Equal', 'Start');
157
+ assert(input.combo, [['U']]);
158
+ });
159
+ await ctx.test('unpressed are inactive and not triggered', () => {
160
+ assertButton(input, 'D', 'Off');
161
+ assertCombo(input, [['D']], 'Unequal');
162
+ assertCombo(input, [['D', 'U']], 'Unequal');
163
+ assertCombo(input, [['D'], ['U']], 'Unequal');
164
+ });
165
+ await ctx.test('pressed are triggered for one frame only', () => {
166
+ input.update(16);
167
+ assert(input.on, ['U']);
168
+ assert(input.invalid, false);
169
+ assert(input.gestured, true);
170
+ assert(input.held, false);
171
+ assert(input.started, false);
172
+ assertButton(input, 'U', 'On');
173
+ assertCombo(input, [['U']], 'Equal');
174
+ assert(input.combo, [['U']]);
175
+ });
176
+ await ctx.test('released are off and triggered', () => {
177
+ target.dispatchEvent(KeyTestEvent('keyup', { code: 'ArrowUp' }));
178
+ input.update(16);
179
+ assert(input.on, []);
180
+ assert(input.invalid, true);
181
+ assert(input.gestured, true);
182
+ assert(input.held, false);
183
+ assert(input.started, true);
184
+ assertButton(input, 'U', 'Off', 'Start');
185
+ assertCombo(input, [['U']], 'Equal');
186
+ assert(input.combo, [['U']]);
187
+ });
188
+ await ctx.test('pressed are held on', () => {
189
+ target.dispatchEvent(KeyTestEvent('keydown', { code: 'ArrowUp' }));
190
+ input.update(input.minHeldMillis);
191
+ assert(input.on, ['U']);
192
+ assert(input.invalid, true);
193
+ assert(input.gestured, true);
194
+ assert(input.held, true);
195
+ assert(input.started, true);
196
+ assertButton(input, 'U', 'On', 'Start');
197
+ assertCombo(input, [['U']], 'EndsWith', 'Start');
198
+ assertCombo(input, [['U'], ['U']], 'Equal', 'Start');
199
+ assert(input.combo, [['U'], ['U']]);
200
+ });
201
+ await ctx.test('expired allow current combo to stay on but discontinue next', () => {
202
+ input.update((input.comboMaxIntervalMillis + 1));
203
+ assert(input.on, ['U']);
204
+ assert(input.invalid, false);
205
+ assert(input.gestured, true);
206
+ assert(input.held, true);
207
+ assert(input.started, false);
208
+ assertButton(input, 'U', 'On');
209
+ assertCombo(input, [['U']], 'EndsWith');
210
+ assertCombo(input, [['U'], ['U']], 'Equal');
211
+ assert(input.combo, [['U'], ['U']]);
212
+ });
213
+ await ctx.test('expired start new combo', () => {
214
+ target.dispatchEvent(KeyTestEvent('keyup', { code: 'ArrowUp' }));
215
+ input.update(16);
216
+ target.dispatchEvent(KeyTestEvent('keydown', { code: 'ArrowUp' }));
217
+ input.update(16);
218
+ assert(input.on, ['U']);
219
+ assert(input.invalid, true);
220
+ assert(input.gestured, true);
221
+ assert(input.held, false);
222
+ assert(input.started, true);
223
+ assertButton(input, 'U', 'On', 'Start');
224
+ assertCombo(input, [['U']], 'Equal', 'Start');
225
+ assertCombo(input, [['U'], ['U']], 'Unequal');
226
+ assert(input.combo, [['U']]);
227
+ });
228
+ }
229
+ catch (e_3) {
230
+ env_3.error = e_3;
231
+ env_3.hasError = true;
232
+ }
233
+ finally {
234
+ __disposeResources(env_3);
235
+ }
236
+ });
237
+ test('combos require gaps between presses', async (ctx) => {
238
+ const env_4 = { stack: [], error: void 0, hasError: false };
239
+ try {
240
+ const secureContext = __addDisposableResource(env_4, new SecureContextMock(), false);
241
+ secureContext.secure = false;
242
+ const dpr = __addDisposableResource(env_4, new DevicePixelRatioMock(), false);
243
+ dpr.ratio = 1;
244
+ const target = TestElement();
245
+ const input = __addDisposableResource(env_4, DefaultInput(DefaultCam(), target).register('add'), false);
246
+ await ctx.test('Up', () => {
247
+ target.dispatchEvent(KeyTestEvent('keydown', { code: 'ArrowUp' }));
248
+ input.update(16);
249
+ assert(input.on, ['U']);
250
+ assert(input.invalid, true);
251
+ assert(input.gestured, true);
252
+ assert(input.held, false);
253
+ assert(input.started, true);
254
+ assertButton(input, 'U', 'On', 'Start');
255
+ assertButton(input, 'D', 'Off');
256
+ assertCombo(input, [['U']], 'Equal', 'Start');
257
+ assertCombo(input, [['U'], ['D']], 'Unequal');
258
+ assertCombo(input, [['U'], ['D'], ['U']], 'Unequal');
259
+ });
260
+ await ctx.test('Up, Down', () => {
261
+ target.dispatchEvent(KeyTestEvent('keyup', { code: 'ArrowUp' }));
262
+ input.update(16);
263
+ target.dispatchEvent(KeyTestEvent('keydown', { code: 'ArrowDown' }));
264
+ input.update(16);
265
+ assert(input.on, ['D']);
266
+ assert(input.invalid, true);
267
+ assert(input.gestured, true);
268
+ assert(input.held, false);
269
+ assert(input.started, true);
270
+ assertButton(input, 'U', 'Off');
271
+ assertButton(input, 'D', 'On', 'Start');
272
+ assertCombo(input, [['U']], 'Unequal');
273
+ assertCombo(input, [['U'], ['D']], 'Equal', 'Start');
274
+ assertCombo(input, [['U'], ['D'], ['U']], 'Unequal');
275
+ });
276
+ await ctx.test('Up, Down, Up', () => {
277
+ target.dispatchEvent(KeyTestEvent('keyup', { code: 'ArrowDown' }));
278
+ target.dispatchEvent(KeyTestEvent('keydown', { code: 'ArrowUp' }));
279
+ input.update(16);
280
+ assert(input.on, ['U']);
281
+ assert(input.invalid, true);
282
+ assert(input.gestured, true);
283
+ assert(input.held, false);
284
+ assert(input.started, true);
285
+ assertButton(input, 'U', 'On', 'Start');
286
+ assertButton(input, 'D', 'Off', 'Start');
287
+ assertCombo(input, [['U']], 'Equal', 'Start');
288
+ assertCombo(input, [['U'], ['D']], 'Unequal');
289
+ assertCombo(input, [['U'], ['D'], ['U']], 'Unequal');
290
+ });
291
+ }
292
+ catch (e_4) {
293
+ env_4.error = e_4;
294
+ env_4.hasError = true;
295
+ }
296
+ finally {
297
+ __disposeResources(env_4);
298
+ }
299
+ });
300
+ test('around-the-world combo', () => {
301
+ const env_5 = { stack: [], error: void 0, hasError: false };
302
+ try {
303
+ const secureContext = __addDisposableResource(env_5, new SecureContextMock(), false);
304
+ secureContext.secure = false;
305
+ const dpr = __addDisposableResource(env_5, new DevicePixelRatioMock(), false);
306
+ dpr.ratio = 1;
307
+ const target = TestElement();
308
+ const input = __addDisposableResource(env_5, DefaultInput(DefaultCam(), target).register('add'), false);
309
+ const sets = [
310
+ ['ArrowUp'],
311
+ ['ArrowUp', 'ArrowRight'],
312
+ ['ArrowRight'],
313
+ ['ArrowRight', 'ArrowDown'],
314
+ ['ArrowDown'],
315
+ ['ArrowDown', 'ArrowLeft'],
316
+ ['ArrowLeft'],
317
+ ['ArrowUp', 'ArrowLeft']
318
+ ];
319
+ for (const set of sets) {
320
+ input.update(16);
321
+ for (const code of set)
322
+ target.dispatchEvent(KeyTestEvent('keydown', { code }));
323
+ input.update(16);
324
+ for (const code of set)
325
+ target.dispatchEvent(KeyTestEvent('keyup', { code }));
326
+ }
327
+ assertCombo(input, [
328
+ ['U'],
329
+ ['U', 'R'],
330
+ ['R'],
331
+ ['D', 'R'],
332
+ ['D'],
333
+ ['D', 'L'],
334
+ ['L'],
335
+ ['U', 'L']
336
+ ], 'Equal', 'Start');
337
+ }
338
+ catch (e_5) {
339
+ env_5.error = e_5;
340
+ env_5.hasError = true;
341
+ }
342
+ finally {
343
+ __disposeResources(env_5);
344
+ }
345
+ });
346
+ test('Up, Up, Down, Down, Left', async (ctx) => {
347
+ const env_6 = { stack: [], error: void 0, hasError: false };
348
+ try {
349
+ const secureContext = __addDisposableResource(env_6, new SecureContextMock(), false);
350
+ secureContext.secure = false;
351
+ const dpr = __addDisposableResource(env_6, new DevicePixelRatioMock(), false);
352
+ dpr.ratio = 1;
353
+ const target = TestElement();
354
+ const input = __addDisposableResource(env_6, DefaultInput(DefaultCam(), target).register('add'), false);
355
+ await ctx.test('Up', () => {
356
+ target.dispatchEvent(KeyTestEvent('keydown', { code: 'ArrowUp' }));
357
+ input.update(16);
358
+ assert(input.on, ['U']);
359
+ assert(input.invalid, true);
360
+ assert(input.gestured, true);
361
+ assert(input.held, false);
362
+ assert(input.started, true);
363
+ assertButton(input, 'U', 'On', 'Start');
364
+ assertButton(input, 'D', 'Off');
365
+ assertButton(input, 'L', 'Off');
366
+ assertCombo(input, [['U']], 'Equal', 'Start');
367
+ assertCombo(input, [['U'], ['U']], 'Unequal');
368
+ assertCombo(input, [['U'], ['U'], ['D']], 'Unequal');
369
+ assertCombo(input, [['U'], ['U'], ['D'], ['D']], 'Unequal');
370
+ assertCombo(input, [['U'], ['U'], ['D'], ['D'], ['L']], 'Unequal');
371
+ });
372
+ await ctx.test('Up, Up', () => {
373
+ target.dispatchEvent(KeyTestEvent('keyup', { code: 'ArrowUp' }));
374
+ input.update(16);
375
+ target.dispatchEvent(KeyTestEvent('keydown', { code: 'ArrowUp' }));
376
+ input.update(16);
377
+ assert(input.on, ['U']);
378
+ assert(input.invalid, true);
379
+ assert(input.gestured, true);
380
+ assert(input.held, false);
381
+ assert(input.started, true);
382
+ assertButton(input, 'U', 'On', 'Start');
383
+ assertButton(input, 'D', 'Off');
384
+ assertButton(input, 'L', 'Off');
385
+ assertCombo(input, [['U']], 'EndsWith', 'Start');
386
+ assertCombo(input, [['U'], ['U']], 'Equal', 'Start');
387
+ assertCombo(input, [['U'], ['U'], ['D']], 'Unequal');
388
+ assertCombo(input, [['U'], ['U'], ['D'], ['D']], 'Unequal');
389
+ assertCombo(input, [['U'], ['U'], ['D'], ['D'], ['L']], 'Unequal');
390
+ });
391
+ await ctx.test('Up, Up, Down', () => {
392
+ target.dispatchEvent(KeyTestEvent('keyup', { code: 'ArrowUp' }));
393
+ input.update(16);
394
+ target.dispatchEvent(KeyTestEvent('keydown', { code: 'ArrowDown' }));
395
+ input.update(16);
396
+ assert(input.on, ['D']);
397
+ assert(input.invalid, true);
398
+ assert(input.gestured, true);
399
+ assert(input.held, false);
400
+ assert(input.started, true);
401
+ assertButton(input, 'U', 'Off');
402
+ assertButton(input, 'D', 'On', 'Start');
403
+ assertButton(input, 'L', 'Off');
404
+ assertCombo(input, [['U']], 'Unequal');
405
+ assertCombo(input, [['U'], ['U']], 'Unequal');
406
+ assertCombo(input, [['U'], ['U'], ['D']], 'Equal', 'Start');
407
+ assertCombo(input, [['U'], ['U'], ['D'], ['D']], 'Unequal');
408
+ assertCombo(input, [['U'], ['U'], ['D'], ['D'], ['L']], 'Unequal');
409
+ });
410
+ await ctx.test('Up, Up, Down, Down', () => {
411
+ target.dispatchEvent(KeyTestEvent('keyup', { code: 'ArrowDown' }));
412
+ input.update(16);
413
+ target.dispatchEvent(KeyTestEvent('keydown', { code: 'ArrowDown' }));
414
+ input.update(16);
415
+ assert(input.on, ['D']);
416
+ assert(input.invalid, true);
417
+ assert(input.gestured, true);
418
+ assert(input.held, false);
419
+ assert(input.started, true);
420
+ assertButton(input, 'U', 'Off');
421
+ assertButton(input, 'D', 'On', 'Start');
422
+ assertButton(input, 'L', 'Off');
423
+ assertCombo(input, [['U']], 'Unequal');
424
+ assertCombo(input, [['U'], ['U']], 'Unequal');
425
+ assertCombo(input, [['U'], ['U'], ['D']], 'Unequal');
426
+ assertCombo(input, [['U'], ['U'], ['D'], ['D']], 'Equal', 'Start');
427
+ assertCombo(input, [['U'], ['U'], ['D'], ['D'], ['L']], 'Unequal');
428
+ });
429
+ await ctx.test('Up, Up, Down, Down, Left', () => {
430
+ target.dispatchEvent(KeyTestEvent('keyup', { code: 'ArrowDown' }));
431
+ input.update(16);
432
+ target.dispatchEvent(KeyTestEvent('keydown', { code: 'ArrowLeft' }));
433
+ input.update(16);
434
+ assert(input.on, ['L']);
435
+ assert(input.invalid, true);
436
+ assert(input.gestured, true);
437
+ assert(input.held, false);
438
+ assert(input.started, true);
439
+ assertButton(input, 'U', 'Off');
440
+ assertButton(input, 'D', 'Off');
441
+ assertButton(input, 'L', 'On', 'Start');
442
+ assertCombo(input, [['U']], 'Unequal');
443
+ assertCombo(input, [['U'], ['U']], 'Unequal');
444
+ assertCombo(input, [['U'], ['U'], ['D']], 'Unequal');
445
+ assertCombo(input, [['U'], ['U'], ['D'], ['D']], 'Unequal');
446
+ assertCombo(input, [['U'], ['U'], ['D'], ['D'], ['L']], 'Equal', 'Start');
447
+ });
448
+ }
449
+ catch (e_6) {
450
+ env_6.error = e_6;
451
+ env_6.hasError = true;
452
+ }
453
+ finally {
454
+ __disposeResources(env_6);
455
+ }
456
+ });
457
+ test('held combos stay active past expiry', async (ctx) => {
458
+ const env_7 = { stack: [], error: void 0, hasError: false };
459
+ try {
460
+ const secureContext = __addDisposableResource(env_7, new SecureContextMock(), false);
461
+ secureContext.secure = false;
462
+ const dpr = __addDisposableResource(env_7, new DevicePixelRatioMock(), false);
463
+ dpr.ratio = 1;
464
+ const target = TestElement();
465
+ const input = __addDisposableResource(env_7, DefaultInput(DefaultCam(), target).register('add'), false);
466
+ await ctx.test('Up, Up', () => {
467
+ target.dispatchEvent(KeyTestEvent('keydown', { code: 'ArrowUp' }));
468
+ input.update(16);
469
+ target.dispatchEvent(KeyTestEvent('keyup', { code: 'ArrowUp' }));
470
+ input.update(16);
471
+ target.dispatchEvent(KeyTestEvent('keydown', { code: 'ArrowUp' }));
472
+ input.update(16);
473
+ assert(input.on, ['U']);
474
+ assert(input.invalid, true);
475
+ assert(input.gestured, true);
476
+ assert(input.held, false);
477
+ assert(input.started, true);
478
+ assertButton(input, 'U', 'On', 'Start');
479
+ assertCombo(input, [['U']], 'EndsWith', 'Start');
480
+ assertCombo(input, [['U'], ['U']], 'Equal', 'Start');
481
+ });
482
+ await ctx.test('held', () => {
483
+ input.update((input.comboMaxIntervalMillis + 1));
484
+ assert(input.on, ['U']);
485
+ assert(input.invalid, false);
486
+ assert(input.gestured, true);
487
+ assert(input.held, true);
488
+ assert(input.started, false);
489
+ assertButton(input, 'U', 'On');
490
+ assertCombo(input, [['U']], 'EndsWith');
491
+ assertCombo(input, [['U'], ['U']], 'Equal');
492
+ });
493
+ }
494
+ catch (e_7) {
495
+ env_7.error = e_7;
496
+ env_7.hasError = true;
497
+ }
498
+ finally {
499
+ __disposeResources(env_7);
500
+ }
501
+ });
502
+ test('combo sequences can have multiple buttons', async (ctx) => {
503
+ const env_8 = { stack: [], error: void 0, hasError: false };
504
+ try {
505
+ const secureContext = __addDisposableResource(env_8, new SecureContextMock(), false);
506
+ secureContext.secure = false;
507
+ const dpr = __addDisposableResource(env_8, new DevicePixelRatioMock(), false);
508
+ dpr.ratio = 1;
509
+ const target = TestElement();
510
+ const input = __addDisposableResource(env_8, DefaultInput(DefaultCam(), target).register('add'), false);
511
+ await ctx.test('Up Left', () => {
512
+ target.dispatchEvent(KeyTestEvent('keydown', { code: 'ArrowUp' }));
513
+ target.dispatchEvent(KeyTestEvent('keydown', { code: 'ArrowLeft' }));
514
+ input.update(16);
515
+ assert(input.on, ['L', 'U']);
516
+ assert(input.invalid, true);
517
+ assert(input.gestured, true);
518
+ assert(input.held, false);
519
+ assert(input.started, true);
520
+ assertButton(input, 'U', 'On', 'Start');
521
+ assertButton(input, 'D', 'Off');
522
+ assertButton(input, 'L', 'On', 'Start');
523
+ assertButton(input, 'R', 'Off');
524
+ assertCombo(input, [['U']], 'Unequal');
525
+ assertCombo(input, [['D']], 'Unequal');
526
+ assertCombo(input, [['L']], 'Unequal');
527
+ assertCombo(input, [['R']], 'Unequal');
528
+ assertCombo(input, [['U', 'L']], 'Equal', 'Start');
529
+ assertCombo(input, [['D', 'R']], 'Unequal');
530
+ assertCombo(input, [['U', 'L'], ['D', 'R']], // biome-ignore format:;
531
+ 'Unequal');
532
+ });
533
+ await ctx.test('Up Left, Down Right', () => {
534
+ target.dispatchEvent(KeyTestEvent('keyup', { code: 'ArrowUp' }));
535
+ target.dispatchEvent(KeyTestEvent('keyup', { code: 'ArrowLeft' }));
536
+ input.update(16);
537
+ target.dispatchEvent(KeyTestEvent('keydown', { code: 'ArrowDown' }));
538
+ target.dispatchEvent(KeyTestEvent('keydown', { code: 'ArrowRight' }));
539
+ input.update(16);
540
+ assert(input.on, ['D', 'R']);
541
+ assert(input.invalid, true);
542
+ assert(input.gestured, true);
543
+ assert(input.held, false);
544
+ assert(input.started, true);
545
+ assertButton(input, 'U', 'Off');
546
+ assertButton(input, 'D', 'On', 'Start');
547
+ assertButton(input, 'L', 'Off');
548
+ assertButton(input, 'R', 'On', 'Start');
549
+ assertCombo(input, [['U']], 'Unequal');
550
+ assertCombo(input, [['D']], 'Unequal');
551
+ assertCombo(input, [['L']], 'Unequal');
552
+ assertCombo(input, [['R']], 'Unequal');
553
+ assertCombo(input, [['U', 'L']], 'Unequal');
554
+ assertCombo(input, [['D', 'R']], 'EndsWith', 'Start');
555
+ assertCombo(input, [['U', 'L'], ['D', 'R']], // biome-ignore format:;
556
+ 'Equal', 'Start');
557
+ });
558
+ }
559
+ catch (e_8) {
560
+ env_8.error = e_8;
561
+ env_8.hasError = true;
562
+ }
563
+ finally {
564
+ __disposeResources(env_8);
565
+ }
566
+ });
567
+ test('handled', () => {
568
+ const env_9 = { stack: [], error: void 0, hasError: false };
569
+ try {
570
+ const secureContext = __addDisposableResource(env_9, new SecureContextMock(), false);
571
+ secureContext.secure = false;
572
+ const dpr = __addDisposableResource(env_9, new DevicePixelRatioMock(), false);
573
+ dpr.ratio = 1;
574
+ const target = TestElement();
575
+ const input = __addDisposableResource(env_9, DefaultInput(DefaultCam(), target).register('add'), false);
576
+ assert(input.invalid, false);
577
+ assert(input.gestured, false);
578
+ assert(input.held, false);
579
+ assert(input.started, false);
580
+ assertButton(input, 'U', 'Off');
581
+ assertCombo(input, [['U']], 'Unequal');
582
+ input.handled = true;
583
+ assert(input.on, []);
584
+ assert(input.invalid, false);
585
+ assert(input.gestured, false);
586
+ assert(input.held, false);
587
+ assert(input.started, false);
588
+ assert(input.isAnyOn('U'), false);
589
+ assert(input.isAnyOnStart('U'), false);
590
+ assert(input.isOn('U'), false);
591
+ assert(input.isOnStart('U'), false);
592
+ assert(input.isOff('U'), false);
593
+ assert(input.isOffStart('U'), false);
594
+ assert(input.isComboEndsWith(['U']), false);
595
+ assert(input.isComboEndsWithStart(['U']), false);
596
+ assert(input.isCombo(['U']), false);
597
+ assert(input.isComboStart(['U']), false);
598
+ target.dispatchEvent(KeyTestEvent('keydown', { code: 'ArrowUp' }));
599
+ input.update(input.minHeldMillis);
600
+ assert(input.on, ['U']);
601
+ assert(input.invalid, true);
602
+ assert(input.gestured, true);
603
+ assert(input.held, true);
604
+ assert(input.started, true);
605
+ assertButton(input, 'U', 'On', 'Start');
606
+ assertCombo(input, [['U']], 'Equal', 'Start');
607
+ input.handled = true;
608
+ assert(input.invalid, true);
609
+ assert(input.gestured, true);
610
+ assert(input.held, false);
611
+ assert(input.started, false);
612
+ assert(input.isAnyOn('U'), false);
613
+ assert(input.isAnyOnStart('U'), false);
614
+ assert(input.isOn('U'), false);
615
+ assert(input.isOnStart('U'), false);
616
+ assert(input.isOff('U'), false);
617
+ assert(input.isOffStart('U'), false);
618
+ assert(input.isComboEndsWith(['U']), false);
619
+ assert(input.isComboEndsWithStart(['U']), false);
620
+ assert(input.isCombo(['U']), false);
621
+ assert(input.isComboStart(['U']), false);
622
+ }
623
+ catch (e_9) {
624
+ env_9.error = e_9;
625
+ env_9.hasError = true;
626
+ }
627
+ finally {
628
+ __disposeResources(env_9);
629
+ }
630
+ });
631
+ test('isAnyOn() / isAnyOnStart()', () => {
632
+ const env_10 = { stack: [], error: void 0, hasError: false };
633
+ try {
634
+ const secureContext = __addDisposableResource(env_10, new SecureContextMock(), false);
635
+ secureContext.secure = false;
636
+ const dpr = __addDisposableResource(env_10, new DevicePixelRatioMock(), false);
637
+ dpr.ratio = 1;
638
+ const target = TestElement();
639
+ const input = __addDisposableResource(env_10, DefaultInput(DefaultCam(), target).register('add'), false);
640
+ target.dispatchEvent(KeyTestEvent('keydown', { code: 'ArrowUp' }));
641
+ input.update(16);
642
+ assert(input.started, true);
643
+ assert(input.isAnyOn('U'), true);
644
+ assert(input.isAnyOnStart('U'), true);
645
+ assert(input.isAnyOn('U', 'D'), true);
646
+ assert(input.isAnyOnStart('U', 'D'), true);
647
+ assert(input.isAnyOn('D'), false);
648
+ assert(input.isAnyOnStart('D'), false);
649
+ assert(input.isAnyOn('D', 'R'), false);
650
+ assert(input.isAnyOnStart('D', 'R'), false);
651
+ }
652
+ catch (e_10) {
653
+ env_10.error = e_10;
654
+ env_10.hasError = true;
655
+ }
656
+ finally {
657
+ __disposeResources(env_10);
658
+ }
659
+ });
660
+ test('started', () => {
661
+ const env_11 = { stack: [], error: void 0, hasError: false };
662
+ try {
663
+ const secureContext = __addDisposableResource(env_11, new SecureContextMock(), false);
664
+ secureContext.secure = false;
665
+ const dpr = __addDisposableResource(env_11, new DevicePixelRatioMock(), false);
666
+ dpr.ratio = 1;
667
+ const target = TestElement();
668
+ const input = __addDisposableResource(env_11, DefaultInput(DefaultCam(), target).register('add'), false);
669
+ assert(input.started, false);
670
+ target.dispatchEvent(KeyTestEvent('keydown', { code: 'ArrowUp' }));
671
+ input.update(16);
672
+ assert(input.started, true);
673
+ input.update(16);
674
+ assert(input.started, false);
675
+ target.dispatchEvent(KeyTestEvent('keyup', { code: 'ArrowUp' }));
676
+ input.update(16);
677
+ assert(input.started, true);
678
+ input.update(16);
679
+ assert(input.started, false);
680
+ }
681
+ catch (e_11) {
682
+ env_11.error = e_11;
683
+ env_11.hasError = true;
684
+ }
685
+ finally {
686
+ __disposeResources(env_11);
687
+ }
688
+ });
689
+ test('isOnStart() requires the tested button to change state', () => {
690
+ const env_12 = { stack: [], error: void 0, hasError: false };
691
+ try {
692
+ const secureContext = __addDisposableResource(env_12, new SecureContextMock(), false);
693
+ secureContext.secure = false;
694
+ const dpr = __addDisposableResource(env_12, new DevicePixelRatioMock(), false);
695
+ dpr.ratio = 1;
696
+ const target = TestElement();
697
+ const input = __addDisposableResource(env_12, DefaultInput(DefaultCam(), target).register('add'), false);
698
+ target.dispatchEvent(KeyTestEvent('keydown', { code: 'ArrowUp' }));
699
+ input.update(16);
700
+ assert(input.isOnStart('U'), true);
701
+ target.dispatchEvent(KeyTestEvent('keydown', { code: 'ArrowRight' }));
702
+ input.update(16);
703
+ assert(input.isOnStart('U'), false);
704
+ target.dispatchEvent(KeyTestEvent('keyup', { code: 'ArrowRight' }));
705
+ input.update(16);
706
+ assert(input.isOnStart('U'), false);
707
+ target.dispatchEvent(KeyTestEvent('keyup', { code: 'ArrowUp' }));
708
+ input.update(16);
709
+ assert(input.isOnStart('U'), false);
710
+ target.dispatchEvent(KeyTestEvent('keydown', { code: 'ArrowUp' }));
711
+ input.update(16);
712
+ assert(input.isOnStart('U'), true);
713
+ }
714
+ catch (e_12) {
715
+ env_12.error = e_12;
716
+ env_12.hasError = true;
717
+ }
718
+ finally {
719
+ __disposeResources(env_12);
720
+ }
721
+ });
722
+ test('pointer movements update position', async (ctx) => {
723
+ const env_13 = { stack: [], error: void 0, hasError: false };
724
+ try {
725
+ const secureContext = __addDisposableResource(env_13, new SecureContextMock(), false);
726
+ secureContext.secure = false;
727
+ const dpr = __addDisposableResource(env_13, new DevicePixelRatioMock(), false);
728
+ dpr.ratio = 1;
729
+ const target = TestElement();
730
+ const input = __addDisposableResource(env_13, DefaultInput(DefaultCam(), target).register('add'), false);
731
+ await ctx.test('move', () => {
732
+ target.dispatchEvent(PointerTestEvent('pointermove', {
733
+ offsetX: 1,
734
+ offsetY: 2
735
+ }));
736
+ input.update(16);
737
+ assert(input.point?.client, { x: 1, y: 2 });
738
+ assert(input.point?.type, 'Mouse');
739
+ assert(input.point?.invalid, true);
740
+ });
741
+ await ctx.test('and position is not lost on update', () => {
742
+ input.update(16);
743
+ assert(input.point?.client, { x: 1, y: 2 });
744
+ assert(input.point?.type, 'Mouse');
745
+ assert(input.point?.invalid, false);
746
+ });
747
+ }
748
+ catch (e_13) {
749
+ env_13.error = e_13;
750
+ env_13.hasError = true;
751
+ }
752
+ finally {
753
+ __disposeResources(env_13);
754
+ }
755
+ });
756
+ test('pointer clicks are buttons', () => {
757
+ const env_14 = { stack: [], error: void 0, hasError: false };
758
+ try {
759
+ const secureContext = __addDisposableResource(env_14, new SecureContextMock(), false);
760
+ secureContext.secure = false;
761
+ const dpr = __addDisposableResource(env_14, new DevicePixelRatioMock(), false);
762
+ dpr.ratio = 1;
763
+ const target = TestElement();
764
+ const input = __addDisposableResource(env_14, DefaultInput(DefaultCam(), target).register('add'), false);
765
+ target.dispatchEvent(PointerTestEvent('pointerdown', { buttons: 1, offsetX: 1, offsetY: 2 }));
766
+ input.update(16);
767
+ assertButton(input, 'A', 'On', 'Start');
768
+ assertCombo(input, [['A']], 'Equal', 'Start');
769
+ assert(input.point?.invalid, true);
770
+ }
771
+ catch (e_14) {
772
+ env_14.error = e_14;
773
+ env_14.hasError = true;
774
+ }
775
+ finally {
776
+ __disposeResources(env_14);
777
+ }
778
+ });
779
+ test('pointer secondary clicks are buttons', () => {
780
+ const env_15 = { stack: [], error: void 0, hasError: false };
781
+ try {
782
+ const secureContext = __addDisposableResource(env_15, new SecureContextMock(), false);
783
+ secureContext.secure = false;
784
+ const dpr = __addDisposableResource(env_15, new DevicePixelRatioMock(), false);
785
+ dpr.ratio = 1;
786
+ const target = TestElement();
787
+ const input = __addDisposableResource(env_15, DefaultInput(DefaultCam(), target).register('add'), false);
788
+ target.dispatchEvent(PointerTestEvent('pointerdown', { buttons: 2, offsetX: 1, offsetY: 2 }));
789
+ input.update(16);
790
+ assertButton(input, 'B', 'On', 'Start');
791
+ assertCombo(input, [['B']], 'Equal', 'Start');
792
+ assert(input.point?.invalid, true);
793
+ }
794
+ catch (e_15) {
795
+ env_15.error = e_15;
796
+ env_15.hasError = true;
797
+ }
798
+ finally {
799
+ __disposeResources(env_15);
800
+ }
801
+ });
802
+ test('a pointer click can become a drag', async (ctx) => {
803
+ const env_16 = { stack: [], error: void 0, hasError: false };
804
+ try {
805
+ const secureContext = __addDisposableResource(env_16, new SecureContextMock(), false);
806
+ secureContext.secure = false;
807
+ const dpr = __addDisposableResource(env_16, new DevicePixelRatioMock(), false);
808
+ dpr.ratio = 1;
809
+ const target = TestElement();
810
+ const input = __addDisposableResource(env_16, DefaultInput(DefaultCam(), target).register('add'), false);
811
+ await ctx.test('init', () => {
812
+ assert(input.point?.drag.on, undefined);
813
+ assert(input.point?.drag.start, undefined);
814
+ assert(input.point?.drag.end, undefined);
815
+ assert(input.point?.click, undefined);
816
+ assert(input.point?.invalid, undefined);
817
+ });
818
+ await ctx.test('click', () => {
819
+ target.dispatchEvent(PointerTestEvent('pointerdown', { buttons: 1, offsetX: 1, offsetY: 2 }));
820
+ input.update(16);
821
+ assertButton(input, 'A', 'On', 'Start');
822
+ assertCombo(input, [['A']], 'Equal', 'Start');
823
+ assert(input.point?.drag.on, false);
824
+ assert(input.point?.drag.start, false);
825
+ assert(input.point?.drag.end, false);
826
+ assert.partialDeepStrictEqual(input.point?.click, { x: 1, y: 2 });
827
+ assert(input.point?.invalid, true);
828
+ });
829
+ await ctx.test('drag', () => {
830
+ target.dispatchEvent(PointerTestEvent('pointermove', { buttons: 1, offsetX: 6, offsetY: 2 }));
831
+ input.update(16);
832
+ assertButton(input, 'A', 'On');
833
+ assertCombo(input, [['A']], 'Equal');
834
+ assert(input.point?.drag.on, true);
835
+ assert(input.point?.drag.start, true);
836
+ assert(input.point?.drag.end, false);
837
+ assert.partialDeepStrictEqual(input.point?.click, { x: 1, y: 2 });
838
+ assert(input.point?.invalid, true);
839
+ });
840
+ await ctx.test('pause', () => {
841
+ input.update(16);
842
+ assertButton(input, 'A', 'On');
843
+ assertCombo(input, [['A']], 'Equal');
844
+ assert(input.point?.drag.on, true);
845
+ assert(input.point?.drag.start, false);
846
+ assert(input.point?.drag.end, false);
847
+ assert.partialDeepStrictEqual(input.point?.click, { x: 1, y: 2 });
848
+ assert(input.point?.invalid, false);
849
+ });
850
+ await ctx.test('move', () => {
851
+ target.dispatchEvent(PointerTestEvent('pointermove', { buttons: 1, offsetX: 16, offsetY: 12 }));
852
+ input.update(16);
853
+ assertButton(input, 'A', 'On');
854
+ assertCombo(input, [['A']], 'Equal');
855
+ assert(input.point?.drag.on, true);
856
+ assert(input.point?.drag.start, false);
857
+ assert(input.point?.drag.end, false);
858
+ assert.partialDeepStrictEqual(input.point?.click, { x: 1, y: 2 });
859
+ assert(input.point?.invalid, true);
860
+ });
861
+ await ctx.test('release', () => {
862
+ target.dispatchEvent(PointerTestEvent('pointerup', {}));
863
+ input.update(16);
864
+ assertButton(input, 'A', 'Off', 'Start');
865
+ assertCombo(input, [['A']], 'Equal');
866
+ assert(input.point?.drag.on, false);
867
+ assert(input.point?.drag.start, false);
868
+ assert(input.point?.drag.end, true);
869
+ assert.partialDeepStrictEqual(input.point?.click, undefined);
870
+ assert(input.point?.invalid, true);
871
+ });
872
+ await ctx.test('pause again', () => {
873
+ input.update(16);
874
+ assertButton(input, 'A', 'Off');
875
+ assertCombo(input, [['A']], 'Equal');
876
+ assert(input.point?.drag.on, false);
877
+ assert(input.point?.drag.start, false);
878
+ assert(input.point?.drag.end, false);
879
+ assert.partialDeepStrictEqual(input.point?.click, undefined);
880
+ assert(input.point?.invalid, false);
881
+ });
882
+ }
883
+ catch (e_16) {
884
+ env_16.error = e_16;
885
+ env_16.hasError = true;
886
+ }
887
+ finally {
888
+ __disposeResources(env_16);
889
+ }
890
+ });
891
+ test('a pointer click can become a drag or a pinch', async (ctx) => {
892
+ const env_17 = { stack: [], error: void 0, hasError: false };
893
+ try {
894
+ const secureContext = __addDisposableResource(env_17, new SecureContextMock(), false);
895
+ secureContext.secure = false;
896
+ const dpr = __addDisposableResource(env_17, new DevicePixelRatioMock(), false);
897
+ dpr.ratio = 1;
898
+ const target = TestElement();
899
+ const input = __addDisposableResource(env_17, DefaultInput(DefaultCam(), target).register('add'), false);
900
+ await ctx.test('init', () => {
901
+ assert(input.point?.drag.on, undefined);
902
+ assert(input.point?.drag.start, undefined);
903
+ assert(input.point?.drag.end, undefined);
904
+ assert.partialDeepStrictEqual(input.point?.click, undefined);
905
+ assert(input.point?.pinch?.xy, undefined);
906
+ assert(input.point?.center, undefined);
907
+ assert(input.point?.invalid, undefined);
908
+ });
909
+ await ctx.test('click', () => {
910
+ target.dispatchEvent(PointerTestEvent('pointerdown', { buttons: 1, offsetX: 1, offsetY: 2 }));
911
+ input.update(16);
912
+ assertButton(input, 'A', 'On', 'Start');
913
+ assertCombo(input, [['A']], 'Equal', 'Start');
914
+ assert(input.point?.drag.on, false);
915
+ assert(input.point?.drag.start, false);
916
+ assert(input.point?.drag.end, false);
917
+ assert.partialDeepStrictEqual(input.point?.click, { x: 1, y: 2 });
918
+ assert(input.point?.pinch?.xy, undefined);
919
+ assert.partialDeepStrictEqual(input.point?.center, { x: 1, y: 2 });
920
+ assert(input.point?.invalid, true);
921
+ });
922
+ await ctx.test('drag', () => {
923
+ target.dispatchEvent(PointerTestEvent('pointermove', { buttons: 1, offsetX: 6, offsetY: 2 }));
924
+ input.update(16);
925
+ assertButton(input, 'A', 'On');
926
+ assertCombo(input, [['A']], 'Equal');
927
+ assert(input.point?.drag.on, true);
928
+ assert(input.point?.drag.start, true);
929
+ assert(input.point?.drag.end, false);
930
+ assert.partialDeepStrictEqual(input.point?.click, { x: 1, y: 2 });
931
+ assert(input.point?.pinch?.xy, undefined);
932
+ assert.partialDeepStrictEqual(input.point?.center, { x: 6, y: 2 });
933
+ assert(input.point?.invalid, true);
934
+ });
935
+ await ctx.test('pinch', () => {
936
+ target.dispatchEvent(PointerTestEvent('pointerdown', {
937
+ buttons: 1,
938
+ offsetX: 10,
939
+ offsetY: 10,
940
+ pointerId: 2
941
+ }));
942
+ input.update(16);
943
+ assertButton(input, 'A', 'On');
944
+ assertCombo(input, [['A']], 'Equal');
945
+ assert(input.point?.drag.on, false);
946
+ assert(input.point?.drag.start, false);
947
+ assert(input.point?.drag.end, true);
948
+ assert.partialDeepStrictEqual(input.point?.click, { x: 1, y: 2 });
949
+ assert(input.point?.pinch?.xy, { x: 0, y: 0 });
950
+ assert.partialDeepStrictEqual(input.point?.center, { x: 8, y: 6 });
951
+ assert(input.point?.invalid, true);
952
+ });
953
+ await ctx.test('expand', () => {
954
+ target.dispatchEvent(PointerTestEvent('pointermove', {
955
+ buttons: 1,
956
+ offsetX: 20,
957
+ offsetY: 20,
958
+ pointerId: 2
959
+ }));
960
+ input.update(16);
961
+ assertButton(input, 'A', 'On');
962
+ assertCombo(input, [['A']], 'Equal');
963
+ assert(input.point?.drag.on, false);
964
+ assert(input.point?.drag.start, false);
965
+ assert(input.point?.drag.end, false);
966
+ assert.partialDeepStrictEqual(input.point?.click, { x: 1, y: 2 });
967
+ assert(input.point?.pinch?.xy, { x: 10, y: 10 });
968
+ assert.partialDeepStrictEqual(input.point?.center, { x: 13, y: 11 });
969
+ assert(input.point?.invalid, true);
970
+ });
971
+ }
972
+ catch (e_17) {
973
+ env_17.error = e_17;
974
+ env_17.hasError = true;
975
+ }
976
+ finally {
977
+ __disposeResources(env_17);
978
+ }
979
+ });
980
+ test('center', async (ctx) => {
981
+ const env_18 = { stack: [], error: void 0, hasError: false };
982
+ try {
983
+ const secureContext = __addDisposableResource(env_18, new SecureContextMock(), false);
984
+ secureContext.secure = false;
985
+ const dpr = __addDisposableResource(env_18, new DevicePixelRatioMock(), false);
986
+ dpr.ratio = 1;
987
+ const target = TestElement();
988
+ const input = __addDisposableResource(env_18, DefaultInput(DefaultCam(), target).register('add'), false);
989
+ await ctx.test('init', () => assert.partialDeepStrictEqual(input.point?.center, undefined));
990
+ await ctx.test('click', () => {
991
+ target.dispatchEvent(PointerTestEvent('pointerdown', { buttons: 1, offsetX: 1, offsetY: 2 }));
992
+ input.update(16);
993
+ assert.partialDeepStrictEqual(input.point?.center, { x: 1, y: 2 });
994
+ assert(input.point?.invalid, true);
995
+ });
996
+ await ctx.test('drag', () => {
997
+ target.dispatchEvent(PointerTestEvent('pointermove', { buttons: 1, offsetX: 10, offsetY: 10 }));
998
+ input.update(16);
999
+ assert.partialDeepStrictEqual(input.point?.center, { x: 10, y: 10 });
1000
+ assert(input.point?.invalid, true);
1001
+ });
1002
+ await ctx.test('secondary click', () => {
1003
+ target.dispatchEvent(PointerTestEvent('pointerdown', {
1004
+ buttons: 1,
1005
+ offsetX: 20,
1006
+ offsetY: 20,
1007
+ pointerId: 2
1008
+ }));
1009
+ input.update(16);
1010
+ assert.partialDeepStrictEqual(input.point?.center, { x: 15, y: 15 });
1011
+ assert(input.point?.invalid, true);
1012
+ });
1013
+ await ctx.test('primary unclick', () => {
1014
+ target.dispatchEvent(PointerTestEvent('pointerup', { offsetX: 30, offsetY: 30 }));
1015
+ input.update(16);
1016
+ assert.partialDeepStrictEqual(input.point?.center, { x: 20, y: 20 });
1017
+ assert(input.point?.invalid, true);
1018
+ });
1019
+ }
1020
+ catch (e_18) {
1021
+ env_18.error = e_18;
1022
+ env_18.hasError = true;
1023
+ }
1024
+ finally {
1025
+ __disposeResources(env_18);
1026
+ }
1027
+ });
1028
+ test('pinch', async (ctx) => {
1029
+ const env_19 = { stack: [], error: void 0, hasError: false };
1030
+ try {
1031
+ const secureContext = __addDisposableResource(env_19, new SecureContextMock(), false);
1032
+ secureContext.secure = false;
1033
+ const dpr = __addDisposableResource(env_19, new DevicePixelRatioMock(), false);
1034
+ dpr.ratio = 1;
1035
+ const target = TestElement();
1036
+ const input = __addDisposableResource(env_19, DefaultInput(DefaultCam(), target).register('add'), false);
1037
+ await ctx.test('init', () => {
1038
+ assert.partialDeepStrictEqual(input.point?.center, undefined);
1039
+ assert(input.point?.pinch, undefined);
1040
+ assert(input.point?.invalid, undefined);
1041
+ });
1042
+ await ctx.test('click', () => {
1043
+ target.dispatchEvent(PointerTestEvent('pointerdown', { buttons: 1, offsetX: 10, offsetY: 10 }));
1044
+ input.update(16);
1045
+ assert.partialDeepStrictEqual(input.point?.center, { x: 10, y: 10 });
1046
+ assert(input.point?.pinch?.xy, undefined);
1047
+ assert(input.point?.invalid, true);
1048
+ });
1049
+ await ctx.test('secondary click', () => {
1050
+ target.dispatchEvent(PointerTestEvent('pointerdown', {
1051
+ buttons: 1,
1052
+ offsetX: 20,
1053
+ offsetY: 20,
1054
+ pointerId: 2
1055
+ }));
1056
+ input.update(16);
1057
+ assert.partialDeepStrictEqual(input.point?.center, { x: 15, y: 15 });
1058
+ assert(input.point?.pinch?.xy, { x: 0, y: 0 });
1059
+ assert(input.point?.invalid, true);
1060
+ });
1061
+ await ctx.test('expand', () => {
1062
+ target.dispatchEvent(PointerTestEvent('pointermove', {
1063
+ buttons: 1,
1064
+ offsetX: 30,
1065
+ offsetY: 30,
1066
+ pointerId: 2
1067
+ }));
1068
+ input.update(16);
1069
+ assert.partialDeepStrictEqual(input.point?.center, { x: 20, y: 20 });
1070
+ assert(input.point?.pinch?.xy, { x: 10, y: 10 });
1071
+ assert(input.point?.invalid, true);
1072
+ });
1073
+ await ctx.test('release', () => {
1074
+ target.dispatchEvent(PointerTestEvent('pointerup', { pointerId: 2 }));
1075
+ input.update(16);
1076
+ assert.partialDeepStrictEqual(input.point?.center, { x: 10, y: 10 });
1077
+ assert(input.point?.pinch?.xy, undefined);
1078
+ assert(input.point?.invalid, true);
1079
+ });
1080
+ }
1081
+ catch (e_19) {
1082
+ env_19.error = e_19;
1083
+ env_19.hasError = true;
1084
+ }
1085
+ finally {
1086
+ __disposeResources(env_19);
1087
+ }
1088
+ });
1089
+ test('wheel', () => {
1090
+ const env_20 = { stack: [], error: void 0, hasError: false };
1091
+ try {
1092
+ const secureContext = __addDisposableResource(env_20, new SecureContextMock(), false);
1093
+ secureContext.secure = false;
1094
+ const dpr = __addDisposableResource(env_20, new DevicePixelRatioMock(), false);
1095
+ dpr.ratio = 1;
1096
+ const target = TestElement();
1097
+ const input = __addDisposableResource(env_20, DefaultInput(DefaultCam(), target).register('add'), false);
1098
+ target.dispatchEvent(WheelTestEvent({ deltaX: 1, deltaY: 2, deltaZ: 3 }));
1099
+ input.update(16);
1100
+ assert(input.wheel?.delta.client, { x: 1, y: 2, z: 3 });
1101
+ assert(input.wheel?.delta.xy, { x: 1, y: 2 });
1102
+ }
1103
+ catch (e_20) {
1104
+ env_20.error = e_20;
1105
+ env_20.hasError = true;
1106
+ }
1107
+ finally {
1108
+ __disposeResources(env_20);
1109
+ }
1110
+ });
1111
+ function assertButton(input, btn, state, edge) {
1112
+ assert(input.isAnyOn(btn), state === 'On');
1113
+ assert(input.isAnyOnStart(btn), state === 'On' && edge === 'Start');
1114
+ assert(input.isOn(btn), state === 'On');
1115
+ assert(input.isOnStart(btn), state === 'On' && edge === 'Start');
1116
+ assert(input.isOff(btn), state === 'Off');
1117
+ assert(input.isOffStart(btn), state === 'Off' && edge === 'Start');
1118
+ }
1119
+ function assertCombo(input, combo, state, edge) {
1120
+ assert(input.isComboEndsWith(...combo), state !== 'Unequal');
1121
+ assert(input.isComboEndsWithStart(...combo), state !== 'Unequal' && edge === 'Start');
1122
+ assert(input.isCombo(...combo), state === 'Equal');
1123
+ assert(input.isComboStart(...combo), state === 'Equal' && edge === 'Start');
1124
+ const abcCombo = combo.map(set => set.sort());
1125
+ if (state === 'Equal')
1126
+ assert(input.combo, abcCombo);
1127
+ else
1128
+ assert.notDeepEqual(input.combo, abcCombo);
1129
+ }
1130
+ function DefaultCam() {
1131
+ const cam = new Cam();
1132
+ // assume a fixed cam for all tests.
1133
+ cam.update({
1134
+ width: 0,
1135
+ height: 0,
1136
+ parentElement: { clientHeight: 1000, clientWidth: 1000 },
1137
+ style: { width: '', height: '' }
1138
+ });
1139
+ return cam;
1140
+ }
1141
+ function DefaultInput(cam, target) {
1142
+ const input = new Input(cam, target);
1143
+ input.mapDefault();
1144
+ return input;
1145
+ }
1146
+ //# sourceMappingURL=input.test.js.map