@flighthq/input 0.5.1-next.904.b545d9c → 0.5.1-next.905.5fbf787

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.
package/README.md CHANGED
@@ -13,5 +13,5 @@ Import the supported application-facing API from `@flighthq/input`. The `@flight
13
13
  This package is part of the locked-version Flight SDK graph. Applications may instead install and import `@flighthq/sdk` when package-level tree shaking is sufficient.
14
14
 
15
15
  - [Flight project](https://github.com/flighthq/flight)
16
- - [Source for @flighthq/input@0.5.1-next.904.b545d9c](https://github.com/flighthq/flight/tree/b545d9cfe622400923a81685c78547f2be54eff5/packages/input)
17
- - [License](https://github.com/flighthq/flight/blob/b545d9cfe622400923a81685c78547f2be54eff5/LICENSE.md)
16
+ - [Source for @flighthq/input@0.5.1-next.905.5fbf787](https://github.com/flighthq/flight/tree/5fbf7874064c384307542d68b4dcb6a895ff0dcf/packages/input)
17
+ - [License](https://github.com/flighthq/flight/blob/5fbf7874064c384307542d68b4dcb6a895ff0dcf/LICENSE.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flighthq/input",
3
- "version": "0.5.1-next.904.b545d9c",
3
+ "version": "0.5.1-next.905.5fbf787",
4
4
  "author": "Joshua Granick and other contributors",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -38,9 +38,9 @@
38
38
  "clean:dist": "tsx ../../scripts/clean-package-dist.ts"
39
39
  },
40
40
  "dependencies": {
41
- "@flighthq/entity": "0.5.1-next.904.b545d9c",
42
- "@flighthq/signals": "0.5.1-next.904.b545d9c",
43
- "@flighthq/types": "0.5.1-next.904.b545d9c"
41
+ "@flighthq/entity": "0.5.1-next.905.5fbf787",
42
+ "@flighthq/signals": "0.5.1-next.905.5fbf787",
43
+ "@flighthq/types": "0.5.1-next.905.5fbf787"
44
44
  },
45
45
  "devDependencies": {
46
46
  "typescript": "^5.3.0"
@@ -38,10 +38,15 @@ import {
38
38
  getKeyCodeFromDomKeyboardEvent,
39
39
  getKeyModifierFromDomKeyboardEvent,
40
40
  getMouseWheelModeFromDomWheelEvent,
41
+ initializeInputKeyRepeatTimer,
42
+ initializeInputManager,
43
+ initializeInputSignals,
44
+ initializeInputState,
45
+ initializeWebInputIngressBackend,
46
+ installInputIngressHostBackend,
41
47
  isInputGamepadButtonDown,
42
48
  isInputKeyDown,
43
49
  isInputPointerButtonDown,
44
- installInputIngressHostBackend,
45
50
  releaseInputPointerCapture,
46
51
  resetInputIngressBackendForTest,
47
52
  setInputIngressBackend,
@@ -1078,6 +1083,36 @@ describe('getMouseWheelModeFromDomWheelEvent', () => {
1078
1083
  });
1079
1084
  });
1080
1085
 
1086
+ describe('initializeInputKeyRepeatTimer', () => {
1087
+ it('is the construction initializer of createInputKeyRepeatTimer', () => {
1088
+ expect(typeof initializeInputKeyRepeatTimer).toBe('function');
1089
+ });
1090
+ });
1091
+
1092
+ describe('initializeInputManager', () => {
1093
+ it('is the construction initializer of createInputManager', () => {
1094
+ expect(typeof initializeInputManager).toBe('function');
1095
+ });
1096
+ });
1097
+
1098
+ describe('initializeInputSignals', () => {
1099
+ it('is the construction initializer of createInputSignals', () => {
1100
+ expect(typeof initializeInputSignals).toBe('function');
1101
+ });
1102
+ });
1103
+
1104
+ describe('initializeInputState', () => {
1105
+ it('is the construction initializer of createInputState', () => {
1106
+ expect(typeof initializeInputState).toBe('function');
1107
+ });
1108
+ });
1109
+
1110
+ describe('initializeWebInputIngressBackend', () => {
1111
+ it('is the construction initializer of createWebInputIngressBackend', () => {
1112
+ expect(typeof initializeWebInputIngressBackend).toBe('function');
1113
+ });
1114
+ });
1115
+
1081
1116
  describe('installInputIngressHostBackend', () => {
1082
1117
  it('preserves the first installed host identity', () => {
1083
1118
  const firstHost = createTestInputIngressBackend();
@@ -1241,6 +1276,112 @@ describe('setInputIngressBackend', () => {
1241
1276
  });
1242
1277
  });
1243
1278
 
1279
+ function createInputEvent(type: string, data: string): InputEvent {
1280
+ return new InputEvent(type, { bubbles: true, data });
1281
+ }
1282
+
1283
+ function createKeyboardEvent(type: string, options: KeyboardEventInit = {}): KeyboardEvent {
1284
+ return new KeyboardEvent(type, {
1285
+ bubbles: true,
1286
+ cancelable: true,
1287
+ ...options,
1288
+ });
1289
+ }
1290
+
1291
+ function createPointerEvent(
1292
+ type: string,
1293
+ options: Partial<PointerEvent> & { pressure?: number; tiltX?: number; tiltY?: number } = {},
1294
+ ): PointerEvent {
1295
+ const event = new Event(type, { bubbles: true, cancelable: true }) as PointerEvent;
1296
+ Object.defineProperties(event, {
1297
+ altKey: { value: options.altKey ?? false },
1298
+ button: { value: options.button ?? 0 },
1299
+ buttons: { value: options.buttons ?? 1 },
1300
+ clientX: { value: options.clientX ?? 0 },
1301
+ clientY: { value: options.clientY ?? 0 },
1302
+ ctrlKey: { value: options.ctrlKey ?? false },
1303
+ height: { value: 1 },
1304
+ isPrimary: { value: options.isPrimary ?? true },
1305
+ metaKey: { value: options.metaKey ?? false },
1306
+ pointerId: { value: options.pointerId ?? 0 },
1307
+ pointerType: { value: options.pointerType ?? 'mouse' },
1308
+ pressure: { value: options.pressure ?? 0 },
1309
+ shiftKey: { value: options.shiftKey ?? false },
1310
+ tiltX: { value: options.tiltX ?? 0 },
1311
+ tiltY: { value: options.tiltY ?? 0 },
1312
+ twist: { value: 0 },
1313
+ width: { value: 1 },
1314
+ });
1315
+ return event;
1316
+ }
1317
+
1318
+ function createWheelEvent(options: WheelEventInit = {}): WheelEvent {
1319
+ return new WheelEvent('wheel', {
1320
+ bubbles: true,
1321
+ cancelable: true,
1322
+ clientX: 0,
1323
+ clientY: 0,
1324
+ deltaX: 0,
1325
+ deltaY: 0,
1326
+ ...options,
1327
+ });
1328
+ }
1329
+
1330
+ function createGamepad(
1331
+ index: number,
1332
+ id: string,
1333
+ axes: readonly number[] = [],
1334
+ buttons: readonly GamepadButton[] = [],
1335
+ ): Gamepad {
1336
+ return {
1337
+ axes,
1338
+ buttons,
1339
+ connected: true,
1340
+ id,
1341
+ index,
1342
+ mapping: 'standard',
1343
+ timestamp: 0,
1344
+ } as unknown as Gamepad;
1345
+ }
1346
+
1347
+ function createGamepadEvent(type: string, gamepadOrIndex: Gamepad | number, id?: string): Event {
1348
+ const event = new Event(type, { bubbles: false }) as GamepadEvent;
1349
+ const gamepad = typeof gamepadOrIndex === 'number' ? createGamepad(gamepadOrIndex, id ?? '') : gamepadOrIndex;
1350
+ Object.defineProperty(event, 'gamepad', { value: gamepad });
1351
+ return event;
1352
+ }
1353
+
1354
+ function installManualAnimationFrames(): Readonly<{
1355
+ cancel: ReturnType<typeof vi.fn>;
1356
+ pending: Map<number, FrameRequestCallback>;
1357
+ request: ReturnType<typeof vi.fn>;
1358
+ runAllCurrent(): void;
1359
+ }> {
1360
+ let nextHandle = 1;
1361
+ const pending = new Map<number, FrameRequestCallback>();
1362
+ const request = vi.fn((callback: FrameRequestCallback): number => {
1363
+ const handle = nextHandle++;
1364
+ pending.set(handle, callback);
1365
+ return handle;
1366
+ });
1367
+ const cancel = vi.fn((handle: number): void => {
1368
+ pending.delete(handle);
1369
+ });
1370
+ vi.stubGlobal('requestAnimationFrame', request);
1371
+ vi.stubGlobal('cancelAnimationFrame', cancel);
1372
+ return {
1373
+ cancel,
1374
+ pending,
1375
+ request,
1376
+ runAllCurrent(): void {
1377
+ const current = [...pending.entries()];
1378
+ for (const [handle, callback] of current) {
1379
+ if (!pending.delete(handle)) continue;
1380
+ callback(performance.now());
1381
+ }
1382
+ },
1383
+ };
1384
+ }
1244
1385
  describe('setInputPointerCapture', () => {
1245
1386
  it('calls setPointerCapture on the element', () => {
1246
1387
  const element = document.createElement('div');
@@ -1455,110 +1596,3 @@ describe('wasInputKeyReleased', () => {
1455
1596
  expect(wasInputKeyReleased(state, KeyCode.A)).toBe(false);
1456
1597
  });
1457
1598
  });
1458
-
1459
- function createInputEvent(type: string, data: string): InputEvent {
1460
- return new InputEvent(type, { bubbles: true, data });
1461
- }
1462
-
1463
- function createKeyboardEvent(type: string, options: KeyboardEventInit = {}): KeyboardEvent {
1464
- return new KeyboardEvent(type, {
1465
- bubbles: true,
1466
- cancelable: true,
1467
- ...options,
1468
- });
1469
- }
1470
-
1471
- function createPointerEvent(
1472
- type: string,
1473
- options: Partial<PointerEvent> & { pressure?: number; tiltX?: number; tiltY?: number } = {},
1474
- ): PointerEvent {
1475
- const event = new Event(type, { bubbles: true, cancelable: true }) as PointerEvent;
1476
- Object.defineProperties(event, {
1477
- altKey: { value: options.altKey ?? false },
1478
- button: { value: options.button ?? 0 },
1479
- buttons: { value: options.buttons ?? 1 },
1480
- clientX: { value: options.clientX ?? 0 },
1481
- clientY: { value: options.clientY ?? 0 },
1482
- ctrlKey: { value: options.ctrlKey ?? false },
1483
- height: { value: 1 },
1484
- isPrimary: { value: options.isPrimary ?? true },
1485
- metaKey: { value: options.metaKey ?? false },
1486
- pointerId: { value: options.pointerId ?? 0 },
1487
- pointerType: { value: options.pointerType ?? 'mouse' },
1488
- pressure: { value: options.pressure ?? 0 },
1489
- shiftKey: { value: options.shiftKey ?? false },
1490
- tiltX: { value: options.tiltX ?? 0 },
1491
- tiltY: { value: options.tiltY ?? 0 },
1492
- twist: { value: 0 },
1493
- width: { value: 1 },
1494
- });
1495
- return event;
1496
- }
1497
-
1498
- function createWheelEvent(options: WheelEventInit = {}): WheelEvent {
1499
- return new WheelEvent('wheel', {
1500
- bubbles: true,
1501
- cancelable: true,
1502
- clientX: 0,
1503
- clientY: 0,
1504
- deltaX: 0,
1505
- deltaY: 0,
1506
- ...options,
1507
- });
1508
- }
1509
-
1510
- function createGamepad(
1511
- index: number,
1512
- id: string,
1513
- axes: readonly number[] = [],
1514
- buttons: readonly GamepadButton[] = [],
1515
- ): Gamepad {
1516
- return {
1517
- axes,
1518
- buttons,
1519
- connected: true,
1520
- id,
1521
- index,
1522
- mapping: 'standard',
1523
- timestamp: 0,
1524
- } as unknown as Gamepad;
1525
- }
1526
-
1527
- function createGamepadEvent(type: string, gamepadOrIndex: Gamepad | number, id?: string): Event {
1528
- const event = new Event(type, { bubbles: false }) as GamepadEvent;
1529
- const gamepad = typeof gamepadOrIndex === 'number' ? createGamepad(gamepadOrIndex, id ?? '') : gamepadOrIndex;
1530
- Object.defineProperty(event, 'gamepad', { value: gamepad });
1531
- return event;
1532
- }
1533
-
1534
- function installManualAnimationFrames(): Readonly<{
1535
- cancel: ReturnType<typeof vi.fn>;
1536
- pending: Map<number, FrameRequestCallback>;
1537
- request: ReturnType<typeof vi.fn>;
1538
- runAllCurrent(): void;
1539
- }> {
1540
- let nextHandle = 1;
1541
- const pending = new Map<number, FrameRequestCallback>();
1542
- const request = vi.fn((callback: FrameRequestCallback): number => {
1543
- const handle = nextHandle++;
1544
- pending.set(handle, callback);
1545
- return handle;
1546
- });
1547
- const cancel = vi.fn((handle: number): void => {
1548
- pending.delete(handle);
1549
- });
1550
- vi.stubGlobal('requestAnimationFrame', request);
1551
- vi.stubGlobal('cancelAnimationFrame', cancel);
1552
- return {
1553
- cancel,
1554
- pending,
1555
- request,
1556
- runAllCurrent(): void {
1557
- const current = [...pending.entries()];
1558
- for (const [handle, callback] of current) {
1559
- if (!pending.delete(handle)) continue;
1560
- callback(performance.now());
1561
- }
1562
- },
1563
- };
1564
- }