@ankhorage/zora-game 0.4.1 → 0.6.0
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/CHANGELOG.md +14 -0
- package/README.md +1 -1
- package/dist/ZORA_GAME_COMPONENT_META.d.ts +177 -2
- package/dist/ZORA_GAME_COMPONENT_META.d.ts.map +1 -1
- package/dist/ZORA_GAME_COMPONENT_META.js +2 -0
- package/dist/ZORA_GAME_COMPONENT_META.js.map +1 -1
- package/dist/ZORA_GAME_PLUGIN.d.ts +182 -2
- package/dist/ZORA_GAME_PLUGIN.d.ts.map +1 -1
- package/dist/ZORA_GAME_PLUGIN.js +2 -0
- package/dist/ZORA_GAME_PLUGIN.js.map +1 -1
- package/dist/ZORA_PLUGIN_METADATA.d.ts +180 -2
- package/dist/ZORA_PLUGIN_METADATA.d.ts.map +1 -1
- package/dist/ZORA_PLUGIN_METADATA.js +4 -0
- package/dist/ZORA_PLUGIN_METADATA.js.map +1 -1
- package/dist/features/game-presentation/adapters/inbound/Game.d.ts.map +1 -1
- package/dist/features/game-presentation/adapters/inbound/Game.js +4 -1
- package/dist/features/game-presentation/adapters/inbound/Game.js.map +1 -1
- package/dist/features/game-presentation/adapters/inbound/GameEntity.d.ts +2 -1
- package/dist/features/game-presentation/adapters/inbound/GameEntity.d.ts.map +1 -1
- package/dist/features/game-presentation/adapters/inbound/GameEntity.js +14 -4
- package/dist/features/game-presentation/adapters/inbound/GameEntity.js.map +1 -1
- package/dist/features/game-presentation/adapters/inbound/GameInputZone.d.ts +2 -2
- package/dist/features/game-presentation/adapters/inbound/GameInputZone.d.ts.map +1 -1
- package/dist/features/game-presentation/adapters/inbound/GameInputZone.js +19 -5
- package/dist/features/game-presentation/adapters/inbound/GameInputZone.js.map +1 -1
- package/dist/features/game-presentation/adapters/inbound/GameMeasurementProbe.d.ts +4 -0
- package/dist/features/game-presentation/adapters/inbound/GameMeasurementProbe.d.ts.map +1 -0
- package/dist/features/game-presentation/adapters/inbound/GameMeasurementProbe.js +52 -0
- package/dist/features/game-presentation/adapters/inbound/GameMeasurementProbe.js.map +1 -0
- package/dist/features/game-presentation/adapters/inbound/createGameKeyboardEvent.d.ts +16 -0
- package/dist/features/game-presentation/adapters/inbound/createGameKeyboardEvent.d.ts.map +1 -0
- package/dist/features/game-presentation/adapters/inbound/createGameKeyboardEvent.js +16 -0
- package/dist/features/game-presentation/adapters/inbound/createGameKeyboardEvent.js.map +1 -0
- package/dist/features/game-presentation/adapters/inbound/createGameMeasurementEvent.d.ts +14 -0
- package/dist/features/game-presentation/adapters/inbound/createGameMeasurementEvent.d.ts.map +1 -0
- package/dist/features/game-presentation/adapters/inbound/createGameMeasurementEvent.js +25 -0
- package/dist/features/game-presentation/adapters/inbound/createGameMeasurementEvent.js.map +1 -0
- package/dist/features/game-presentation/adapters/inbound/measureGameEntity.d.ts +5 -0
- package/dist/features/game-presentation/adapters/inbound/measureGameEntity.d.ts.map +1 -0
- package/dist/features/game-presentation/adapters/inbound/measureGameEntity.js +22 -0
- package/dist/features/game-presentation/adapters/inbound/measureGameEntity.js.map +1 -0
- package/dist/features/game-presentation/adapters/inbound/useGameInputZoneResponder.d.ts +6 -0
- package/dist/features/game-presentation/adapters/inbound/useGameInputZoneResponder.d.ts.map +1 -1
- package/dist/features/game-presentation/adapters/inbound/useGameInputZoneResponder.js +15 -0
- package/dist/features/game-presentation/adapters/inbound/useGameInputZoneResponder.js.map +1 -1
- package/dist/features/game-presentation/composition/createGameMeasurementRegistry.d.ts +4 -0
- package/dist/features/game-presentation/composition/createGameMeasurementRegistry.d.ts.map +1 -0
- package/dist/features/game-presentation/composition/createGameMeasurementRegistry.js +15 -0
- package/dist/features/game-presentation/composition/createGameMeasurementRegistry.js.map +1 -0
- package/dist/features/game-presentation/composition/useGameRuntime.d.ts +2 -2
- package/dist/features/game-presentation/composition/useGameRuntime.d.ts.map +1 -1
- package/dist/features/game-presentation/composition/useGameRuntime.js.map +1 -1
- package/dist/features/game-presentation/meta/gameEntityMeta.d.ts +14 -0
- package/dist/features/game-presentation/meta/gameEntityMeta.d.ts.map +1 -1
- package/dist/features/game-presentation/meta/gameEntityMeta.js +7 -0
- package/dist/features/game-presentation/meta/gameEntityMeta.js.map +1 -1
- package/dist/features/game-presentation/meta/gameInputZoneMeta.d.ts +52 -1
- package/dist/features/game-presentation/meta/gameInputZoneMeta.d.ts.map +1 -1
- package/dist/features/game-presentation/meta/gameInputZoneMeta.js +47 -1
- package/dist/features/game-presentation/meta/gameInputZoneMeta.js.map +1 -1
- package/dist/features/game-presentation/meta/gameMeasurementProbeMeta.d.ts +112 -0
- package/dist/features/game-presentation/meta/gameMeasurementProbeMeta.d.ts.map +1 -0
- package/dist/features/game-presentation/meta/gameMeasurementProbeMeta.js +70 -0
- package/dist/features/game-presentation/meta/gameMeasurementProbeMeta.js.map +1 -0
- package/dist/features/game-presentation/meta/gameMeta.d.ts +1 -1
- package/dist/features/game-presentation/meta/gameMeta.d.ts.map +1 -1
- package/dist/features/game-presentation/meta/gameMeta.js +9 -1
- package/dist/features/game-presentation/meta/gameMeta.js.map +1 -1
- package/dist/features/game-presentation/public.d.ts +2 -1
- package/dist/features/game-presentation/public.d.ts.map +1 -1
- package/dist/features/game-presentation/public.js +1 -0
- package/dist/features/game-presentation/public.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types/gamePresentation.d.ts +16 -0
- package/dist/types/gamePresentation.d.ts.map +1 -1
- package/dist/types/gamePresentation.js.map +1 -1
- package/dist/types/gameRuntime.d.ts +16 -1
- package/dist/types/gameRuntime.d.ts.map +1 -1
- package/dist/types/gameRuntime.js.map +1 -1
- package/package.json +1 -1
- package/src/ZORA_GAME_COMPONENT_META.ts +2 -0
- package/src/ZORA_GAME_PLUGIN.ts +2 -0
- package/src/ZORA_PLUGIN_METADATA.test.ts +37 -10
- package/src/ZORA_PLUGIN_METADATA.ts +4 -0
- package/src/features/game-presentation/adapters/inbound/Game.tsx +7 -1
- package/src/features/game-presentation/adapters/inbound/GameEntity.tsx +15 -2
- package/src/features/game-presentation/adapters/inbound/GameInputZone.tsx +36 -9
- package/src/features/game-presentation/adapters/inbound/GameMeasurementProbe.tsx +79 -0
- package/src/features/game-presentation/adapters/inbound/createGameKeyboardEvent.test.ts +51 -0
- package/src/features/game-presentation/adapters/inbound/createGameKeyboardEvent.ts +33 -0
- package/src/features/game-presentation/adapters/inbound/createGameMeasurementEvent.test.ts +56 -0
- package/src/features/game-presentation/adapters/inbound/createGameMeasurementEvent.ts +38 -0
- package/src/features/game-presentation/adapters/inbound/measureGameEntity.ts +28 -0
- package/src/features/game-presentation/adapters/inbound/useGameInputZoneResponder.ts +22 -0
- package/src/features/game-presentation/composition/createGameMeasurementRegistry.test.ts +35 -0
- package/src/features/game-presentation/composition/createGameMeasurementRegistry.ts +16 -0
- package/src/features/game-presentation/composition/useGameRuntime.ts +3 -3
- package/src/features/game-presentation/meta/gameEntityMeta.ts +7 -0
- package/src/features/game-presentation/meta/gameInputZoneMeta.ts +47 -1
- package/src/features/game-presentation/meta/gameMeasurementProbeMeta.ts +72 -0
- package/src/features/game-presentation/meta/gameMeta.ts +9 -1
- package/src/features/game-presentation/public.ts +3 -0
- package/src/index.ts +3 -0
- package/src/types/gamePresentation.ts +18 -0
- package/src/types/gameRuntime.ts +19 -1
|
@@ -8,7 +8,7 @@ export declare const ZORA_PLUGIN_METADATA: {
|
|
|
8
8
|
readonly category: "pattern";
|
|
9
9
|
readonly description: "Embeds one config-driven game session inside ordinary ZORA layout and emits domain-neutral game outputs.";
|
|
10
10
|
readonly directManifestNode: true;
|
|
11
|
-
readonly allowedChildren: readonly ["GameEntity", "GameInputZone", "GameOverlay", "Gradient", "Image", "View"];
|
|
11
|
+
readonly allowedChildren: readonly ["GameEntity", "GameInputZone", "GameMeasurementProbe", "GameOverlay", "Gradient", "Image", "View"];
|
|
12
12
|
readonly blueprint: {
|
|
13
13
|
readonly label: "Game";
|
|
14
14
|
readonly defaultProps: {
|
|
@@ -194,6 +194,12 @@ export declare const ZORA_PLUGIN_METADATA: {
|
|
|
194
194
|
};
|
|
195
195
|
readonly acceptsFallback: true;
|
|
196
196
|
};
|
|
197
|
+
readonly measurementId: {
|
|
198
|
+
readonly value: {
|
|
199
|
+
readonly type: "string";
|
|
200
|
+
};
|
|
201
|
+
readonly acceptsFallback: true;
|
|
202
|
+
};
|
|
197
203
|
};
|
|
198
204
|
};
|
|
199
205
|
readonly props: {
|
|
@@ -286,6 +292,14 @@ export declare const ZORA_PLUGIN_METADATA: {
|
|
|
286
292
|
readonly authority: "instance";
|
|
287
293
|
};
|
|
288
294
|
};
|
|
295
|
+
readonly measurementId: {
|
|
296
|
+
readonly type: "string";
|
|
297
|
+
readonly category: "Measurement";
|
|
298
|
+
readonly label: "Measurement id";
|
|
299
|
+
readonly authoring: {
|
|
300
|
+
readonly authority: "instance";
|
|
301
|
+
};
|
|
302
|
+
};
|
|
289
303
|
readonly accessibilityLabel: {
|
|
290
304
|
readonly type: "string";
|
|
291
305
|
readonly category: "Accessibility";
|
|
@@ -349,7 +363,7 @@ export declare const ZORA_PLUGIN_METADATA: {
|
|
|
349
363
|
readonly GameInputZone: {
|
|
350
364
|
readonly name: "GameInputZone";
|
|
351
365
|
readonly category: "component";
|
|
352
|
-
readonly description: "Normalizes pointer
|
|
366
|
+
readonly description: "Normalizes pointer/touch positions and optional keyboard bindings into generic game events.";
|
|
353
367
|
readonly directManifestNode: true;
|
|
354
368
|
readonly allowedChildren: readonly [];
|
|
355
369
|
readonly blueprint: {
|
|
@@ -446,6 +460,57 @@ export declare const ZORA_PLUGIN_METADATA: {
|
|
|
446
460
|
readonly authority: "instance";
|
|
447
461
|
};
|
|
448
462
|
};
|
|
463
|
+
readonly keyboardBindings: {
|
|
464
|
+
readonly type: "array";
|
|
465
|
+
readonly category: "Input";
|
|
466
|
+
readonly label: "Keyboard bindings";
|
|
467
|
+
readonly default: readonly [];
|
|
468
|
+
readonly itemSchema: readonly [{
|
|
469
|
+
readonly key: "key";
|
|
470
|
+
readonly schema: {
|
|
471
|
+
readonly type: "string";
|
|
472
|
+
readonly category: "Input";
|
|
473
|
+
readonly label: "Key";
|
|
474
|
+
readonly authoring: {
|
|
475
|
+
readonly authority: "instance";
|
|
476
|
+
};
|
|
477
|
+
};
|
|
478
|
+
}, {
|
|
479
|
+
readonly key: "eventType";
|
|
480
|
+
readonly schema: {
|
|
481
|
+
readonly type: "string";
|
|
482
|
+
readonly category: "Input";
|
|
483
|
+
readonly label: "Event type";
|
|
484
|
+
readonly authoring: {
|
|
485
|
+
readonly authority: "instance";
|
|
486
|
+
};
|
|
487
|
+
};
|
|
488
|
+
}, {
|
|
489
|
+
readonly key: "entityId";
|
|
490
|
+
readonly schema: {
|
|
491
|
+
readonly type: "string";
|
|
492
|
+
readonly category: "Input";
|
|
493
|
+
readonly label: "Entity id";
|
|
494
|
+
readonly authoring: {
|
|
495
|
+
readonly authority: "instance";
|
|
496
|
+
};
|
|
497
|
+
};
|
|
498
|
+
}, {
|
|
499
|
+
readonly key: "preventDefault";
|
|
500
|
+
readonly schema: {
|
|
501
|
+
readonly type: "boolean";
|
|
502
|
+
readonly category: "Input";
|
|
503
|
+
readonly label: "Prevent browser default";
|
|
504
|
+
readonly default: false;
|
|
505
|
+
readonly authoring: {
|
|
506
|
+
readonly authority: "instance";
|
|
507
|
+
};
|
|
508
|
+
};
|
|
509
|
+
}];
|
|
510
|
+
readonly authoring: {
|
|
511
|
+
readonly authority: "instance";
|
|
512
|
+
};
|
|
513
|
+
};
|
|
449
514
|
readonly accessibilityLabel: {
|
|
450
515
|
readonly type: "string";
|
|
451
516
|
readonly category: "Accessibility";
|
|
@@ -456,6 +521,116 @@ export declare const ZORA_PLUGIN_METADATA: {
|
|
|
456
521
|
};
|
|
457
522
|
};
|
|
458
523
|
};
|
|
524
|
+
readonly GameMeasurementProbe: {
|
|
525
|
+
readonly name: "GameMeasurementProbe";
|
|
526
|
+
readonly category: "component";
|
|
527
|
+
readonly description: "Measures two registered game entities and reports their raw rendered bounds through a generic Game event.";
|
|
528
|
+
readonly directManifestNode: true;
|
|
529
|
+
readonly allowedChildren: readonly [];
|
|
530
|
+
readonly blueprint: {
|
|
531
|
+
readonly label: "Game measurement probe";
|
|
532
|
+
readonly defaultProps: {
|
|
533
|
+
readonly sourceId: "source";
|
|
534
|
+
readonly targetId: "target";
|
|
535
|
+
readonly eventType: "game.measurement";
|
|
536
|
+
readonly delayMs: 0;
|
|
537
|
+
readonly enabled: true;
|
|
538
|
+
};
|
|
539
|
+
};
|
|
540
|
+
readonly bindings: {
|
|
541
|
+
readonly props: {
|
|
542
|
+
readonly sourceId: {
|
|
543
|
+
readonly value: {
|
|
544
|
+
readonly type: "string";
|
|
545
|
+
};
|
|
546
|
+
readonly acceptsFallback: true;
|
|
547
|
+
};
|
|
548
|
+
readonly targetId: {
|
|
549
|
+
readonly value: {
|
|
550
|
+
readonly type: "string";
|
|
551
|
+
};
|
|
552
|
+
readonly acceptsFallback: true;
|
|
553
|
+
};
|
|
554
|
+
readonly eventType: {
|
|
555
|
+
readonly value: {
|
|
556
|
+
readonly type: "string";
|
|
557
|
+
};
|
|
558
|
+
readonly acceptsFallback: true;
|
|
559
|
+
};
|
|
560
|
+
readonly entityId: {
|
|
561
|
+
readonly value: {
|
|
562
|
+
readonly type: "string";
|
|
563
|
+
};
|
|
564
|
+
readonly acceptsFallback: true;
|
|
565
|
+
};
|
|
566
|
+
readonly delayMs: {
|
|
567
|
+
readonly value: {
|
|
568
|
+
readonly type: "number";
|
|
569
|
+
};
|
|
570
|
+
readonly acceptsFallback: true;
|
|
571
|
+
};
|
|
572
|
+
readonly enabled: {
|
|
573
|
+
readonly value: {
|
|
574
|
+
readonly type: "boolean";
|
|
575
|
+
};
|
|
576
|
+
readonly acceptsFallback: true;
|
|
577
|
+
};
|
|
578
|
+
};
|
|
579
|
+
};
|
|
580
|
+
readonly props: {
|
|
581
|
+
readonly sourceId: {
|
|
582
|
+
readonly type: "string";
|
|
583
|
+
readonly category: "Measurement";
|
|
584
|
+
readonly label: "Source id";
|
|
585
|
+
readonly authoring: {
|
|
586
|
+
readonly authority: "instance";
|
|
587
|
+
};
|
|
588
|
+
};
|
|
589
|
+
readonly targetId: {
|
|
590
|
+
readonly type: "string";
|
|
591
|
+
readonly category: "Measurement";
|
|
592
|
+
readonly label: "Target id";
|
|
593
|
+
readonly authoring: {
|
|
594
|
+
readonly authority: "instance";
|
|
595
|
+
};
|
|
596
|
+
};
|
|
597
|
+
readonly eventType: {
|
|
598
|
+
readonly type: "string";
|
|
599
|
+
readonly category: "Measurement";
|
|
600
|
+
readonly label: "Event type";
|
|
601
|
+
readonly default: "game.measurement";
|
|
602
|
+
readonly authoring: {
|
|
603
|
+
readonly authority: "instance";
|
|
604
|
+
};
|
|
605
|
+
};
|
|
606
|
+
readonly entityId: {
|
|
607
|
+
readonly type: "string";
|
|
608
|
+
readonly category: "Measurement";
|
|
609
|
+
readonly label: "Game entity id";
|
|
610
|
+
readonly authoring: {
|
|
611
|
+
readonly authority: "instance";
|
|
612
|
+
};
|
|
613
|
+
};
|
|
614
|
+
readonly delayMs: {
|
|
615
|
+
readonly type: "number";
|
|
616
|
+
readonly category: "Measurement";
|
|
617
|
+
readonly label: "Delay (ms)";
|
|
618
|
+
readonly default: 0;
|
|
619
|
+
readonly authoring: {
|
|
620
|
+
readonly authority: "instance";
|
|
621
|
+
};
|
|
622
|
+
};
|
|
623
|
+
readonly enabled: {
|
|
624
|
+
readonly type: "boolean";
|
|
625
|
+
readonly category: "State";
|
|
626
|
+
readonly label: "Enabled";
|
|
627
|
+
readonly default: true;
|
|
628
|
+
readonly authoring: {
|
|
629
|
+
readonly authority: "instance";
|
|
630
|
+
};
|
|
631
|
+
};
|
|
632
|
+
};
|
|
633
|
+
};
|
|
459
634
|
readonly GameOverlay: {
|
|
460
635
|
readonly name: "GameOverlay";
|
|
461
636
|
readonly category: "layout";
|
|
@@ -523,6 +698,9 @@ export declare const ZORA_PLUGIN_METADATA: {
|
|
|
523
698
|
}, {
|
|
524
699
|
readonly child: "GameInputZone";
|
|
525
700
|
readonly parents: readonly ["Game"];
|
|
701
|
+
}, {
|
|
702
|
+
readonly child: "GameMeasurementProbe";
|
|
703
|
+
readonly parents: readonly ["Game"];
|
|
526
704
|
}, {
|
|
527
705
|
readonly child: "GameOverlay";
|
|
528
706
|
readonly parents: readonly ["Game", "GameField"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ZORA_PLUGIN_METADATA.d.ts","sourceRoot":"","sources":["../src/ZORA_PLUGIN_METADATA.ts"],"names":[],"mappings":"AAIA,sFAAsF;AACtF,eAAO,MAAM,oBAAoB
|
|
1
|
+
{"version":3,"file":"ZORA_PLUGIN_METADATA.d.ts","sourceRoot":"","sources":["../src/ZORA_PLUGIN_METADATA.ts"],"names":[],"mappings":"AAIA,sFAAsF;AACtF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ZORA_PLUGIN_METADATA.js","sourceRoot":"","sources":["../src/ZORA_PLUGIN_METADATA.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAEtE,sFAAsF;AACtF,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,WAAW,EAAE,sBAAsB;IACnC,WAAW,EAAE,WAAW;IACxB,aAAa,EAAE,wBAAwB;IACvC,cAAc,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,CAAC;IACnF,UAAU,EAAE;QACV;YACE,KAAK,EAAE,MAAM;YACb,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,CAAC;SAC7D;QACD;YACE,KAAK,EAAE,WAAW;YAClB,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,CAAC;SAC7D;QACD;YACE,KAAK,EAAE,YAAY;YACnB,OAAO,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,aAAa,CAAC;SAC9C;QACD;YACE,KAAK,EAAE,eAAe;YACtB,OAAO,EAAE,CAAC,MAAM,CAAC;SAClB;QACD;YACE,KAAK,EAAE,aAAa;YACpB,OAAO,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC;SAC/B;KACF;CACoC,CAAC","sourcesContent":["import type { ZoraPluginMetadata } from '@ankhorage/zora/metadata';\n\nimport { ZORA_GAME_COMPONENT_META } from './ZORA_GAME_COMPONENT_META';\n\n/*** Describe generic game presentation nodes and their valid ZORA extension hosts. */\nexport const ZORA_PLUGIN_METADATA = {\n packageName: '@ankhorage/zora-game',\n displayName: 'ZORA Game',\n componentMeta: ZORA_GAME_COMPONENT_META,\n extensionHosts: ['Game', 'GameEntity', 'GameField', 'GameInputZone', 'GameOverlay'],\n placements: [\n {\n child: 'Game',\n parents: ['Card', 'Grid', 'Screen', 'ScreenSection', 'View'],\n },\n {\n child: 'GameField',\n parents: ['Card', 'Grid', 'Screen', 'ScreenSection', 'View'],\n },\n {\n child: 'GameEntity',\n parents: ['Game', 'GameField', 'GameOverlay'],\n },\n {\n child: 'GameInputZone',\n parents: ['Game'],\n },\n {\n child: 'GameOverlay',\n parents: ['Game', 'GameField'],\n },\n ],\n} as const satisfies ZoraPluginMetadata;\n"]}
|
|
1
|
+
{"version":3,"file":"ZORA_PLUGIN_METADATA.js","sourceRoot":"","sources":["../src/ZORA_PLUGIN_METADATA.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAEtE,sFAAsF;AACtF,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,WAAW,EAAE,sBAAsB;IACnC,WAAW,EAAE,WAAW;IACxB,aAAa,EAAE,wBAAwB;IACvC,cAAc,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,CAAC;IACnF,UAAU,EAAE;QACV;YACE,KAAK,EAAE,MAAM;YACb,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,CAAC;SAC7D;QACD;YACE,KAAK,EAAE,WAAW;YAClB,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,CAAC;SAC7D;QACD;YACE,KAAK,EAAE,YAAY;YACnB,OAAO,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,aAAa,CAAC;SAC9C;QACD;YACE,KAAK,EAAE,eAAe;YACtB,OAAO,EAAE,CAAC,MAAM,CAAC;SAClB;QACD;YACE,KAAK,EAAE,sBAAsB;YAC7B,OAAO,EAAE,CAAC,MAAM,CAAC;SAClB;QACD;YACE,KAAK,EAAE,aAAa;YACpB,OAAO,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC;SAC/B;KACF;CACoC,CAAC","sourcesContent":["import type { ZoraPluginMetadata } from '@ankhorage/zora/metadata';\n\nimport { ZORA_GAME_COMPONENT_META } from './ZORA_GAME_COMPONENT_META';\n\n/*** Describe generic game presentation nodes and their valid ZORA extension hosts. */\nexport const ZORA_PLUGIN_METADATA = {\n packageName: '@ankhorage/zora-game',\n displayName: 'ZORA Game',\n componentMeta: ZORA_GAME_COMPONENT_META,\n extensionHosts: ['Game', 'GameEntity', 'GameField', 'GameInputZone', 'GameOverlay'],\n placements: [\n {\n child: 'Game',\n parents: ['Card', 'Grid', 'Screen', 'ScreenSection', 'View'],\n },\n {\n child: 'GameField',\n parents: ['Card', 'Grid', 'Screen', 'ScreenSection', 'View'],\n },\n {\n child: 'GameEntity',\n parents: ['Game', 'GameField', 'GameOverlay'],\n },\n {\n child: 'GameInputZone',\n parents: ['Game'],\n },\n {\n child: 'GameMeasurementProbe',\n parents: ['Game'],\n },\n {\n child: 'GameOverlay',\n parents: ['Game', 'GameField'],\n },\n ],\n} as const satisfies ZoraPluginMetadata;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Game.d.ts","sourceRoot":"","sources":["../../../../../src/features/game-presentation/adapters/inbound/Game.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"Game.d.ts","sourceRoot":"","sources":["../../../../../src/features/game-presentation/adapters/inbound/Game.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAOpE,kGAAkG;AAClG,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,qBA6BpC"}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { RuntimeRendererConfigProvider } from '@ankhorage/runtime';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { createGameBindingContext } from '../../composition/createGameBindingContext';
|
|
4
|
+
import { createGameMeasurementRegistry } from '../../composition/createGameMeasurementRegistry';
|
|
4
5
|
import { GameRuntimeContext } from '../../composition/GameRuntimeContext';
|
|
5
6
|
import { useGameRuntime } from '../../composition/useGameRuntime';
|
|
6
7
|
import { GameField } from './GameField';
|
|
7
8
|
/*** Bind one serializable game definition to a local transient session and presentation field. */
|
|
8
9
|
export function Game(props) {
|
|
9
10
|
const runtime = useGameRuntime(props);
|
|
11
|
+
const [measurementRegistry] = React.useState(createGameMeasurementRegistry);
|
|
12
|
+
const runtimeContext = React.useMemo(() => ({ ...runtime, ...measurementRegistry }), [measurementRegistry, runtime]);
|
|
10
13
|
const runtimeBindingConfig = React.useMemo(() => ({ bindingContext: createGameBindingContext(runtime.session) }), [runtime.session]);
|
|
11
|
-
return (<GameRuntimeContext.Provider value={
|
|
14
|
+
return (<GameRuntimeContext.Provider value={runtimeContext}>
|
|
12
15
|
<RuntimeRendererConfigProvider value={runtimeBindingConfig}>
|
|
13
16
|
<GameField {...(props.aspectRatio === undefined ? {} : { aspectRatio: props.aspectRatio })} {...(props.minHeight === undefined ? {} : { minHeight: props.minHeight })} {...(props.clip === undefined ? {} : { clip: props.clip })} {...(props.accessibilityLabel === undefined
|
|
14
17
|
? {}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Game.js","sourceRoot":"","sources":["../../../../../src/features/game-presentation/adapters/inbound/Game.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,oBA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AAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAEjE;UAAA,CAAC,KAAK,CAAC,QAAQ,CACjB;QAAA,EAAE,SAAS,CACb;MAAA,EAAE,6BAA6B,CACjC;IAAA,EAAE,kBAAkB,CAAC,QAAQ,CAAC,CAC/B,CAAC;AACJ,CAAC","sourcesContent":["import { RuntimeRendererConfigProvider } from '@ankhorage/runtime';\nimport React from 'react';\n\nimport type { GameProps } from '../../../../types/gamePresentation';\nimport { createGameBindingContext } from '../../composition/createGameBindingContext';\nimport { createGameMeasurementRegistry } from '../../composition/createGameMeasurementRegistry';\nimport { GameRuntimeContext } from '../../composition/GameRuntimeContext';\nimport { useGameRuntime } from '../../composition/useGameRuntime';\nimport { GameField } from './GameField';\n\n/*** Bind one serializable game definition to a local transient session and presentation field. */\nexport function Game(props: GameProps) {\n const runtime = useGameRuntime(props);\n const [measurementRegistry] = React.useState(createGameMeasurementRegistry);\n const runtimeContext = React.useMemo(\n () => ({ ...runtime, ...measurementRegistry }),\n [measurementRegistry, runtime],\n );\n const runtimeBindingConfig = React.useMemo(\n () => ({ bindingContext: createGameBindingContext(runtime.session) }),\n [runtime.session],\n );\n\n return (\n <GameRuntimeContext.Provider value={runtimeContext}>\n <RuntimeRendererConfigProvider value={runtimeBindingConfig}>\n <GameField\n {...(props.aspectRatio === undefined ? {} : { aspectRatio: props.aspectRatio })}\n {...(props.minHeight === undefined ? {} : { minHeight: props.minHeight })}\n {...(props.clip === undefined ? {} : { clip: props.clip })}\n {...(props.accessibilityLabel === undefined\n ? {}\n : { accessibilityLabel: props.accessibilityLabel })}\n {...(props.testID === undefined ? {} : { testID: props.testID })}\n >\n {props.children}\n </GameField>\n </RuntimeRendererConfigProvider>\n </GameRuntimeContext.Provider>\n );\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import type { GameEntityProps } from '../../../../types/gamePresentation';
|
|
2
3
|
/*** Render one generic positioned game entity without owning gameplay semantics. */
|
|
3
|
-
export declare function GameEntity({ children, x, y, width, height, opacity, scale, rotation, zIndex, hidden, pointerEvents, accessibilityLabel, testID, }: GameEntityProps):
|
|
4
|
+
export declare function GameEntity({ children, x, y, width, height, opacity, scale, rotation, zIndex, hidden, pointerEvents, measurementId, accessibilityLabel, testID, }: GameEntityProps): React.JSX.Element;
|
|
4
5
|
//# sourceMappingURL=GameEntity.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GameEntity.d.ts","sourceRoot":"","sources":["../../../../../src/features/game-presentation/adapters/inbound/GameEntity.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GameEntity.d.ts","sourceRoot":"","sources":["../../../../../src/features/game-presentation/adapters/inbound/GameEntity.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAK1E,oFAAoF;AACpF,wBAAgB,UAAU,CAAC,EACzB,QAAQ,EACR,CAAK,EACL,CAAK,EACL,KAAK,EACL,MAAM,EACN,OAAW,EACX,KAAS,EACT,QAAY,EACZ,MAAU,EACV,MAAc,EACd,aAAsB,EACtB,aAAa,EACb,kBAAkB,EAClB,MAAM,GACP,EAAE,eAAe,qBAwBjB"}
|
|
@@ -1,9 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { StyleSheet } from 'react-native';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleSheet, View } from 'react-native';
|
|
3
|
+
import { GameRuntimeContext } from '../../composition/GameRuntimeContext';
|
|
3
4
|
import { toGamePercentage } from '../../utils/toGamePercentage';
|
|
5
|
+
import { measureGameEntity } from './measureGameEntity';
|
|
4
6
|
/*** Render one generic positioned game entity without owning gameplay semantics. */
|
|
5
|
-
export function GameEntity({ children, x = 0, y = 0, width, height, opacity = 1, scale = 1, rotation = 0, zIndex = 0, hidden = false, pointerEvents = 'auto', accessibilityLabel, testID, }) {
|
|
6
|
-
|
|
7
|
+
export function GameEntity({ children, x = 0, y = 0, width, height, opacity = 1, scale = 1, rotation = 0, zIndex = 0, hidden = false, pointerEvents = 'auto', measurementId, accessibilityLabel, testID, }) {
|
|
8
|
+
const elementRef = React.useRef(null);
|
|
9
|
+
const runtime = React.useContext(GameRuntimeContext);
|
|
10
|
+
const registerMeasurement = runtime?.registerMeasurement;
|
|
11
|
+
React.useEffect(() => {
|
|
12
|
+
if (measurementId === undefined || registerMeasurement === undefined)
|
|
13
|
+
return undefined;
|
|
14
|
+
return registerMeasurement(measurementId, () => measureGameEntity(elementRef.current));
|
|
15
|
+
}, [measurementId, registerMeasurement]);
|
|
16
|
+
return (<View ref={elementRef} {...(accessibilityLabel === undefined ? {} : { accessibilityLabel })} {...(testID === undefined ? {} : { testID })} pointerEvents={pointerEvents} style={[
|
|
7
17
|
styles.root,
|
|
8
18
|
createEntityStyle({ x, y, width, height, opacity, scale, rotation, zIndex, hidden }),
|
|
9
19
|
]}>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GameEntity.js","sourceRoot":"","sources":["../../../../../src/features/game-presentation/adapters/inbound/GameEntity.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"GameEntity.js","sourceRoot":"","sources":["../../../../../src/features/game-presentation/adapters/inbound/GameEntity.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,IAAI,EAAkB,MAAM,cAAc,CAAC;AAGhE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,oFAAoF;AACpF,MAAM,UAAU,UAAU,CAAC,EACzB,QAAQ,EACR,CAAC,GAAG,CAAC,E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AEF;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC;AAcD,sFAAsF;AACtF,SAAS,iBAAiB,CAAC,EACzB,CAAC,EACD,CAAC,EACD,KAAK,EACL,MAAM,EACN,OAAO,EACP,KAAK,EACL,QAAQ,EACR,MAAM,EACN,MAAM,GACe;IACrB,OAAO;QACL,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;QACjC,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC;QACzB,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;QAC1C,QAAQ,EAAE,UAAU;QACpB,GAAG,EAAE,gBAAgB,CAAC,CAAC,CAAC;QACxB,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,QAAQ,KAAK,EAAE,CAAC;QACpD,MAAM;QACN,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC;QAC3C,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;KAC1C,CAAC;AACJ,CAAC;AAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,IAAI,EAAE;QACJ,QAAQ,EAAE,UAAU;KACrB;CACF,CAAC,CAAC","sourcesContent":["import React from 'react';\nimport { StyleSheet, View, type ViewStyle } from 'react-native';\n\nimport type { GameEntityProps } from '../../../../types/gamePresentation';\nimport { GameRuntimeContext } from '../../composition/GameRuntimeContext';\nimport { toGamePercentage } from '../../utils/toGamePercentage';\nimport { measureGameEntity } from './measureGameEntity';\n\n/*** Render one generic positioned game entity without owning gameplay semantics. */\nexport function GameEntity({\n children,\n x = 0,\n y = 0,\n width,\n height,\n opacity = 1,\n scale = 1,\n rotation = 0,\n zIndex = 0,\n hidden = false,\n pointerEvents = 'auto',\n measurementId,\n accessibilityLabel,\n testID,\n}: GameEntityProps) {\n const elementRef = React.useRef<View | null>(null);\n const runtime = React.useContext(GameRuntimeContext);\n const registerMeasurement = runtime?.registerMeasurement;\n\n React.useEffect(() => {\n if (measurementId === undefined || registerMeasurement === undefined) return undefined;\n return registerMeasurement(measurementId, () => measureGameEntity(elementRef.current));\n }, [measurementId, registerMeasurement]);\n\n return (\n <View\n ref={elementRef}\n {...(accessibilityLabel === undefined ? {} : { accessibilityLabel })}\n {...(testID === undefined ? {} : { testID })}\n pointerEvents={pointerEvents}\n style={[\n styles.root,\n createEntityStyle({ x, y, width, height, opacity, scale, rotation, zIndex, hidden }),\n ]}\n >\n {children}\n </View>\n );\n}\n\ninterface GameEntityStyleInput {\n readonly x: number;\n readonly y: number;\n readonly width: number | undefined;\n readonly height: number | undefined;\n readonly opacity: number;\n readonly scale: number;\n readonly rotation: number;\n readonly zIndex: number;\n readonly hidden: boolean;\n}\n\n/*** Convert serializable entity presentation props into a React Native view style. */\nfunction createEntityStyle({\n x,\n y,\n width,\n height,\n opacity,\n scale,\n rotation,\n zIndex,\n hidden,\n}: GameEntityStyleInput): ViewStyle {\n return {\n display: hidden ? 'none' : 'flex',\n left: toGamePercentage(x),\n opacity: Math.min(1, Math.max(0, opacity)),\n position: 'absolute',\n top: toGamePercentage(y),\n transform: [{ scale }, { rotate: `${rotation}deg` }],\n zIndex,\n ...(height === undefined ? {} : { height }),\n ...(width === undefined ? {} : { width }),\n };\n}\n\nconst styles = StyleSheet.create({\n root: {\n position: 'absolute',\n },\n});\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { GameInputZoneProps } from '../../../../types/gamePresentation';
|
|
2
|
-
/*** Capture pointer/touch geometry and
|
|
3
|
-
export declare function GameInputZone({ x, y, width, height, zIndex, enabled, continuous, accessibilityLabel, testID, ...inputProps }: GameInputZoneProps): import("react").JSX.Element;
|
|
2
|
+
/*** Capture pointer/touch geometry and optional keyboard input as normalized generic Game events. */
|
|
3
|
+
export declare function GameInputZone({ x, y, width, height, zIndex, enabled, continuous, keyboardBindings, accessibilityLabel, testID, ...inputProps }: GameInputZoneProps): import("react").JSX.Element;
|
|
4
4
|
//# sourceMappingURL=GameInputZone.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GameInputZone.d.ts","sourceRoot":"","sources":["../../../../../src/features/game-presentation/adapters/inbound/GameInputZone.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAI7E,
|
|
1
|
+
{"version":3,"file":"GameInputZone.d.ts","sourceRoot":"","sources":["../../../../../src/features/game-presentation/adapters/inbound/GameInputZone.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAI7E,qGAAqG;AACrG,wBAAgB,aAAa,CAAC,EAC5B,CAAK,EACL,CAAK,EACL,KAAW,EACX,MAAY,EACZ,MAAU,EACV,OAAc,EACd,UAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,MAAM,EACN,GAAG,UAAU,EACd,EAAE,kBAAkB,+BAiCpB"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { StyleSheet, View } from 'react-native';
|
|
1
|
+
import { Platform, StyleSheet, View } from 'react-native';
|
|
2
2
|
import { toGamePercentage } from '../../utils/toGamePercentage';
|
|
3
3
|
import { useGameInputZoneResponder } from './useGameInputZoneResponder';
|
|
4
|
-
/*** Capture pointer/touch geometry and
|
|
5
|
-
export function GameInputZone({ x = 0, y = 0, width = 100, height = 100, zIndex = 0, enabled = true, continuous = true, accessibilityLabel, testID, ...inputProps }) {
|
|
6
|
-
const { dispatchPointer, handleLayout, shouldSetResponder } = useGameInputZoneResponder({
|
|
4
|
+
/*** Capture pointer/touch geometry and optional keyboard input as normalized generic Game events. */
|
|
5
|
+
export function GameInputZone({ x = 0, y = 0, width = 100, height = 100, zIndex = 0, enabled = true, continuous = true, keyboardBindings, accessibilityLabel, testID, ...inputProps }) {
|
|
6
|
+
const { dispatchKeyboard, dispatchPointer, handleLayout, shouldSetResponder } = useGameInputZoneResponder({
|
|
7
7
|
...inputProps,
|
|
8
8
|
x,
|
|
9
9
|
y,
|
|
@@ -11,11 +11,25 @@ export function GameInputZone({ x = 0, y = 0, width = 100, height = 100, zIndex
|
|
|
11
11
|
height,
|
|
12
12
|
enabled,
|
|
13
13
|
continuous,
|
|
14
|
+
...(keyboardBindings === undefined ? {} : { keyboardBindings }),
|
|
14
15
|
});
|
|
15
|
-
|
|
16
|
+
const keyboardProps = createGameInputZoneKeyboardProps({
|
|
17
|
+
dispatchKeyboard,
|
|
18
|
+
enabled,
|
|
19
|
+
keyboardBindings,
|
|
20
|
+
});
|
|
21
|
+
return (<View {...keyboardProps} {...(accessibilityLabel === undefined ? {} : { accessibilityLabel })} {...(testID === undefined ? {} : { testID })} {...(continuous
|
|
16
22
|
? { onResponderGrant: dispatchPointer, onResponderMove: dispatchPointer }
|
|
17
23
|
: { onResponderRelease: dispatchPointer })} collapsable={false} onLayout={handleLayout} onStartShouldSetResponder={shouldSetResponder} pointerEvents={enabled ? 'auto' : 'none'} style={createInputZoneStyle({ x, y, width, height, zIndex })}/>);
|
|
18
24
|
}
|
|
25
|
+
/*** Add a focusable web keyboard target only when the input zone owns key bindings. */
|
|
26
|
+
function createGameInputZoneKeyboardProps({ dispatchKeyboard, enabled, keyboardBindings, }) {
|
|
27
|
+
if (Platform.OS !== 'web' || !enabled || keyboardBindings === undefined)
|
|
28
|
+
return {};
|
|
29
|
+
if (keyboardBindings.length === 0)
|
|
30
|
+
return {};
|
|
31
|
+
return { onKeyDown: dispatchKeyboard, tabIndex: 0 };
|
|
32
|
+
}
|
|
19
33
|
/*** Convert field-relative input-zone props into one absolute React Native style. */
|
|
20
34
|
function createInputZoneStyle({ x, y, width, height, zIndex }) {
|
|
21
35
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GameInputZone.js","sourceRoot":"","sources":["../../../../../src/features/game-presentation/adapters/inbound/GameInputZone.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAkB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"GameInputZone.js","sourceRoot":"","sources":["../../../../../src/features/game-presentation/adapters/inbound/GameInputZone.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAkB,MAAM,cAAc,CAAC;AAG1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAExE,qGAAqG;AACrG,MAAM,UAAU,aAAa,CAAC,EAC5B,CAAC,GAAG,CAAC,EACL,CAAC,GAAG,CAAC,EACL,KAAK,GAAG,GAAG,EACX,MAAM,GAAG,GAAG,EACZ,MAAM,GAAG,CAAC,EACV,OAAO,GAAG,IAAI,EACd,UAAU,GAAG,IAAI,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,MAAM,EACN,GAAG,UAAU,EACM;IACnB,MAAM,EAAE,gBAAgB,EAAE,eAAe,EAAE,YAAY,EAAE,kBAAkB,EAAE,GAC3E,yBAAyB,CAAC;QACxB,GAAG,UAAU;QACb,CAAC;QACD,CAAC;QACD,KAAK;QACL,MAAM;QACN,OAAO;QACP,UAAU;QACV,GAAG,CAAC,gBAAgB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,CAAC;KAChE,CAAC,CAAC;IACL,MAAM,aAAa,GAAG,gCAAgC,CAAC;QACrD,gBAAgB;QAChB,OAAO;QACP,gBAAgB;KACjB,CAAC,CAAC;IAEH,OAAO,CACL,CAAC,IAAI,CACH,IAA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,EAAE,gBAAgB,CAAC,CAAC,CAAC;QACzB,GAAG,EAAE,gBAAgB,CAAC,CAAC,CAAC;QACxB,KAAK,EAAE,gBAAgB,CAAC,KAAK,CAAC;QAC9B,MAAM,EAAE,gBAAgB,CAAC,MAAM,CAAC;QAChC,MAAM;QACN,GAAG,MAAM,CAAC,IAAI;KACf,CAAC;AACJ,CAAC;AAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,IAAI,EAAE;QACJ,QAAQ,EAAE,UAAU;KACrB;CACF,CAAC,CAAC","sourcesContent":["import { Platform, StyleSheet, View, type ViewStyle } from 'react-native';\n\nimport type { GameInputZoneProps } from '../../../../types/gamePresentation';\nimport { toGamePercentage } from '../../utils/toGamePercentage';\nimport { useGameInputZoneResponder } from './useGameInputZoneResponder';\n\n/*** Capture pointer/touch geometry and optional keyboard input as normalized generic Game events. */\nexport function GameInputZone({\n x = 0,\n y = 0,\n width = 100,\n height = 100,\n zIndex = 0,\n enabled = true,\n continuous = true,\n keyboardBindings,\n accessibilityLabel,\n testID,\n ...inputProps\n}: GameInputZoneProps) {\n const { dispatchKeyboard, dispatchPointer, handleLayout, shouldSetResponder } =\n useGameInputZoneResponder({\n ...inputProps,\n x,\n y,\n width,\n height,\n enabled,\n continuous,\n ...(keyboardBindings === undefined ? {} : { keyboardBindings }),\n });\n const keyboardProps = createGameInputZoneKeyboardProps({\n dispatchKeyboard,\n enabled,\n keyboardBindings,\n });\n\n return (\n <View\n {...keyboardProps}\n {...(accessibilityLabel === undefined ? {} : { accessibilityLabel })}\n {...(testID === undefined ? {} : { testID })}\n {...(continuous\n ? { onResponderGrant: dispatchPointer, onResponderMove: dispatchPointer }\n : { onResponderRelease: dispatchPointer })}\n collapsable={false}\n onLayout={handleLayout}\n onStartShouldSetResponder={shouldSetResponder}\n pointerEvents={enabled ? 'auto' : 'none'}\n style={createInputZoneStyle({ x, y, width, height, zIndex })}\n />\n );\n}\n\ninterface GameInputZoneKeyboardPropsInput {\n readonly dispatchKeyboard: (event: { readonly key: string; preventDefault(): void }) => void;\n readonly enabled: boolean;\n readonly keyboardBindings: GameInputZoneProps['keyboardBindings'];\n}\n\n/*** Add a focusable web keyboard target only when the input zone owns key bindings. */\nfunction createGameInputZoneKeyboardProps({\n dispatchKeyboard,\n enabled,\n keyboardBindings,\n}: GameInputZoneKeyboardPropsInput) {\n if (Platform.OS !== 'web' || !enabled || keyboardBindings === undefined) return {};\n if (keyboardBindings.length === 0) return {};\n\n return { onKeyDown: dispatchKeyboard, tabIndex: 0 as const };\n}\n\ninterface InputZoneStyleInput {\n readonly x: number;\n readonly y: number;\n readonly width: number;\n readonly height: number;\n readonly zIndex: number;\n}\n\n/*** Convert field-relative input-zone props into one absolute React Native style. */\nfunction createInputZoneStyle({ x, y, width, height, zIndex }: InputZoneStyleInput): ViewStyle {\n return {\n left: toGamePercentage(x),\n top: toGamePercentage(y),\n width: toGamePercentage(width),\n height: toGamePercentage(height),\n zIndex,\n ...styles.root,\n };\n}\n\nconst styles = StyleSheet.create({\n root: {\n position: 'absolute',\n },\n});\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { GameMeasurementProbeProps } from '../../../../types/gamePresentation';
|
|
2
|
+
/*** Measure two registered game entities and dispatch only their raw rendered geometry. */
|
|
3
|
+
export declare function GameMeasurementProbe({ sourceId, targetId, eventType, entityId, delayMs, enabled, }: GameMeasurementProbeProps): null;
|
|
4
|
+
//# sourceMappingURL=GameMeasurementProbe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GameMeasurementProbe.d.ts","sourceRoot":"","sources":["../../../../../src/features/game-presentation/adapters/inbound/GameMeasurementProbe.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAKpF,2FAA2F;AAC3F,wBAAgB,oBAAoB,CAAC,EACnC,QAAQ,EACR,QAAQ,EACR,SAA8B,EAC9B,QAAQ,EACR,OAAW,EACX,OAAc,GACf,EAAE,yBAAyB,QAkC3B"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { GameRuntimeContext } from '../../composition/GameRuntimeContext';
|
|
3
|
+
import { createGameMeasurementEvent } from './createGameMeasurementEvent';
|
|
4
|
+
/*** Measure two registered game entities and dispatch only their raw rendered geometry. */
|
|
5
|
+
export function GameMeasurementProbe({ sourceId, targetId, eventType = 'game.measurement', entityId, delayMs = 0, enabled = true, }) {
|
|
6
|
+
const runtime = React.useContext(GameRuntimeContext);
|
|
7
|
+
if (runtime === null)
|
|
8
|
+
throw new Error('GameMeasurementProbe must be rendered inside Game.');
|
|
9
|
+
React.useEffect(() => {
|
|
10
|
+
if (!enabled)
|
|
11
|
+
return undefined;
|
|
12
|
+
const timer = setTimeout(() => {
|
|
13
|
+
void dispatchGameMeasurement({
|
|
14
|
+
dispatch: runtime.dispatch,
|
|
15
|
+
measure: runtime.measure,
|
|
16
|
+
sourceId,
|
|
17
|
+
targetId,
|
|
18
|
+
eventType,
|
|
19
|
+
...(entityId === undefined ? {} : { entityId }),
|
|
20
|
+
});
|
|
21
|
+
}, Math.max(0, delayMs));
|
|
22
|
+
return () => clearTimeout(timer);
|
|
23
|
+
}, [
|
|
24
|
+
delayMs,
|
|
25
|
+
enabled,
|
|
26
|
+
entityId,
|
|
27
|
+
eventType,
|
|
28
|
+
runtime.dispatch,
|
|
29
|
+
runtime.measure,
|
|
30
|
+
sourceId,
|
|
31
|
+
targetId,
|
|
32
|
+
]);
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
/*** Resolve both registered entity measurements before dispatching one Game event. */
|
|
36
|
+
async function dispatchGameMeasurement(input) {
|
|
37
|
+
const [source, target] = await Promise.all([
|
|
38
|
+
input.measure(input.sourceId),
|
|
39
|
+
input.measure(input.targetId),
|
|
40
|
+
]);
|
|
41
|
+
if (source === undefined || target === undefined)
|
|
42
|
+
return;
|
|
43
|
+
input.dispatch(createGameMeasurementEvent({
|
|
44
|
+
eventType: input.eventType,
|
|
45
|
+
...(input.entityId === undefined ? {} : { entityId: input.entityId }),
|
|
46
|
+
sourceId: input.sourceId,
|
|
47
|
+
targetId: input.targetId,
|
|
48
|
+
source,
|
|
49
|
+
target,
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=GameMeasurementProbe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GameMeasurementProbe.js","sourceRoot":"","sources":["../../../../../src/features/game-presentation/adapters/inbound/GameMeasurementProbe.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAE1E,2FAA2F;AAC3F,MAAM,UAAU,oBAAoB,CAAC,EACnC,QAAQ,EACR,QAAQ,EACR,SAAS,GAAG,kBAAkB,EAC9B,QAAQ,EACR,OAAO,GAAG,CAAC,EACX,OAAO,GAAG,IAAI,GACY;IAC1B,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC;IACrD,IAAI,OAAO,KAAK,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;IAE5F,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,CAAC,OAAO;YAAE,OAAO,SAAS,CAAC;QAE/B,MAAM,KAAK,GAAG,UAAU,CACtB,GAAG,EAAE;YACH,KAAK,uBAAuB,CAAC;gBAC3B,QAAQ,EAAE,OAAO,CAAC,QAAQ;gBAC1B,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,QAAQ;gBACR,QAAQ;gBACR,SAAS;gBACT,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC;aAChD,CAAC,CAAC;QACL,CAAC,EACD,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CACrB,CAAC;QAEF,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC,EAAE;QACD,OAAO;QACP,OAAO;QACP,QAAQ;QACR,SAAS;QACT,OAAO,CAAC,QAAQ;QAChB,OAAO,CAAC,OAAO;QACf,QAAQ;QACR,QAAQ;KACT,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC;AAWD,sFAAsF;AACtF,KAAK,UAAU,uBAAuB,CAAC,KAAmC;IACxE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACzC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC;QAC7B,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC;KAC9B,CAAC,CAAC;IACH,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO;IAEzD,KAAK,CAAC,QAAQ,CACZ,0BAA0B,CAAC;QACzB,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,GAAG,CAAC,KAAK,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC;QACrE,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,MAAM;QACN,MAAM;KACP,CAAC,CACH,CAAC;AACJ,CAAC","sourcesContent":["import React from 'react';\n\nimport type { GameMeasurementProbeProps } from '../../../../types/gamePresentation';\nimport type { GameRuntimeContextValue } from '../../../../types/gameRuntime';\nimport { GameRuntimeContext } from '../../composition/GameRuntimeContext';\nimport { createGameMeasurementEvent } from './createGameMeasurementEvent';\n\n/*** Measure two registered game entities and dispatch only their raw rendered geometry. */\nexport function GameMeasurementProbe({\n sourceId,\n targetId,\n eventType = 'game.measurement',\n entityId,\n delayMs = 0,\n enabled = true,\n}: GameMeasurementProbeProps) {\n const runtime = React.useContext(GameRuntimeContext);\n if (runtime === null) throw new Error('GameMeasurementProbe must be rendered inside Game.');\n\n React.useEffect(() => {\n if (!enabled) return undefined;\n\n const timer = setTimeout(\n () => {\n void dispatchGameMeasurement({\n dispatch: runtime.dispatch,\n measure: runtime.measure,\n sourceId,\n targetId,\n eventType,\n ...(entityId === undefined ? {} : { entityId }),\n });\n },\n Math.max(0, delayMs),\n );\n\n return () => clearTimeout(timer);\n }, [\n delayMs,\n enabled,\n entityId,\n eventType,\n runtime.dispatch,\n runtime.measure,\n sourceId,\n targetId,\n ]);\n\n return null;\n}\n\ninterface DispatchGameMeasurementInput {\n readonly dispatch: GameRuntimeContextValue['dispatch'];\n readonly measure: GameRuntimeContextValue['measure'];\n readonly sourceId: string;\n readonly targetId: string;\n readonly eventType: string;\n readonly entityId?: string;\n}\n\n/*** Resolve both registered entity measurements before dispatching one Game event. */\nasync function dispatchGameMeasurement(input: DispatchGameMeasurementInput): Promise<void> {\n const [source, target] = await Promise.all([\n input.measure(input.sourceId),\n input.measure(input.targetId),\n ]);\n if (source === undefined || target === undefined) return;\n\n input.dispatch(\n createGameMeasurementEvent({\n eventType: input.eventType,\n ...(input.entityId === undefined ? {} : { entityId: input.entityId }),\n sourceId: input.sourceId,\n targetId: input.targetId,\n source,\n target,\n }),\n );\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { GameEvent } from '@ankhorage/game';
|
|
2
|
+
import type { GameKeyboardBinding } from '../../../../types/gamePresentation';
|
|
3
|
+
interface CreateGameKeyboardEventInput {
|
|
4
|
+
readonly bindings: readonly GameKeyboardBinding[];
|
|
5
|
+
readonly fallbackEventType: string;
|
|
6
|
+
readonly fallbackEntityId?: string;
|
|
7
|
+
readonly key: string;
|
|
8
|
+
}
|
|
9
|
+
interface GameKeyboardEventResult {
|
|
10
|
+
readonly event: GameEvent;
|
|
11
|
+
readonly preventDefault: boolean;
|
|
12
|
+
}
|
|
13
|
+
/*** Map one configured keyboard key into a generic Game event. */
|
|
14
|
+
export declare function createGameKeyboardEvent(input: CreateGameKeyboardEventInput): GameKeyboardEventResult | undefined;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=createGameKeyboardEvent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createGameKeyboardEvent.d.ts","sourceRoot":"","sources":["../../../../../src/features/game-presentation/adapters/inbound/createGameKeyboardEvent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAE9E,UAAU,4BAA4B;IACpC,QAAQ,CAAC,QAAQ,EAAE,SAAS,mBAAmB,EAAE,CAAC;IAClD,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,UAAU,uBAAuB;IAC/B,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;CAClC;AAED,kEAAkE;AAClE,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,4BAA4B,GAClC,uBAAuB,GAAG,SAAS,CAarC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*** Map one configured keyboard key into a generic Game event. */
|
|
2
|
+
export function createGameKeyboardEvent(input) {
|
|
3
|
+
const binding = input.bindings.find((candidate) => candidate.key === input.key);
|
|
4
|
+
if (binding === undefined)
|
|
5
|
+
return undefined;
|
|
6
|
+
const entityId = binding.entityId ?? input.fallbackEntityId;
|
|
7
|
+
return {
|
|
8
|
+
event: {
|
|
9
|
+
type: binding.eventType ?? input.fallbackEventType,
|
|
10
|
+
...(entityId === undefined ? {} : { entityId }),
|
|
11
|
+
payload: { key: input.key },
|
|
12
|
+
},
|
|
13
|
+
preventDefault: binding.preventDefault ?? false,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=createGameKeyboardEvent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createGameKeyboardEvent.js","sourceRoot":"","sources":["../../../../../src/features/game-presentation/adapters/inbound/createGameKeyboardEvent.ts"],"names":[],"mappings":"AAgBA,kEAAkE;AAClE,MAAM,UAAU,uBAAuB,CACrC,KAAmC;IAEnC,MAAM,OAAO,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,KAAK,KAAK,CAAC,GAAG,CAAC,CAAC;IAChF,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAE5C,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,KAAK,CAAC,gBAAgB,CAAC;IAC5D,OAAO;QACL,KAAK,EAAE;YACL,IAAI,EAAE,OAAO,CAAC,SAAS,IAAI,KAAK,CAAC,iBAAiB;YAClD,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC;YAC/C,OAAO,EAAE,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE;SAC5B;QACD,cAAc,EAAE,OAAO,CAAC,cAAc,IAAI,KAAK;KAChD,CAAC;AACJ,CAAC","sourcesContent":["import type { GameEvent } from '@ankhorage/game';\n\nimport type { GameKeyboardBinding } from '../../../../types/gamePresentation';\n\ninterface CreateGameKeyboardEventInput {\n readonly bindings: readonly GameKeyboardBinding[];\n readonly fallbackEventType: string;\n readonly fallbackEntityId?: string;\n readonly key: string;\n}\n\ninterface GameKeyboardEventResult {\n readonly event: GameEvent;\n readonly preventDefault: boolean;\n}\n\n/*** Map one configured keyboard key into a generic Game event. */\nexport function createGameKeyboardEvent(\n input: CreateGameKeyboardEventInput,\n): GameKeyboardEventResult | undefined {\n const binding = input.bindings.find((candidate) => candidate.key === input.key);\n if (binding === undefined) return undefined;\n\n const entityId = binding.entityId ?? input.fallbackEntityId;\n return {\n event: {\n type: binding.eventType ?? input.fallbackEventType,\n ...(entityId === undefined ? {} : { entityId }),\n payload: { key: input.key },\n },\n preventDefault: binding.preventDefault ?? false,\n };\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { GameEvent } from '@ankhorage/game';
|
|
2
|
+
import type { GameMeasurementBounds } from '../../../../types/gameRuntime';
|
|
3
|
+
/*** Create one raw geometry event without deciding collision semantics. */
|
|
4
|
+
export declare function createGameMeasurementEvent(input: CreateGameMeasurementEventInput): GameEvent;
|
|
5
|
+
interface CreateGameMeasurementEventInput {
|
|
6
|
+
readonly eventType: string;
|
|
7
|
+
readonly entityId?: string;
|
|
8
|
+
readonly sourceId: string;
|
|
9
|
+
readonly targetId: string;
|
|
10
|
+
readonly source: GameMeasurementBounds;
|
|
11
|
+
readonly target: GameMeasurementBounds;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=createGameMeasurementEvent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createGameMeasurementEvent.d.ts","sourceRoot":"","sources":["../../../../../src/features/game-presentation/adapters/inbound/createGameMeasurementEvent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAc,MAAM,iBAAiB,CAAC;AAE7D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAE3E,2EAA2E;AAC3E,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,+BAA+B,GAAG,SAAS,CAW5F;AAED,UAAU,+BAA+B;IACvC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC;IACvC,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC;CACxC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*** Create one raw geometry event without deciding collision semantics. */
|
|
2
|
+
export function createGameMeasurementEvent(input) {
|
|
3
|
+
return {
|
|
4
|
+
type: input.eventType,
|
|
5
|
+
entityId: input.entityId ?? input.sourceId,
|
|
6
|
+
payload: {
|
|
7
|
+
sourceId: input.sourceId,
|
|
8
|
+
targetId: input.targetId,
|
|
9
|
+
source: toGameMeasurementRecord(input.source),
|
|
10
|
+
target: toGameMeasurementRecord(input.target),
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/*** Convert measured geometry into a serializable Game record. */
|
|
15
|
+
function toGameMeasurementRecord(bounds) {
|
|
16
|
+
return {
|
|
17
|
+
left: bounds.left,
|
|
18
|
+
right: bounds.right,
|
|
19
|
+
top: bounds.top,
|
|
20
|
+
bottom: bounds.bottom,
|
|
21
|
+
width: bounds.width,
|
|
22
|
+
height: bounds.height,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=createGameMeasurementEvent.js.map
|