@ankhorage/zora-game 0.2.0 → 0.4.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.
Files changed (87) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +2 -1
  3. package/dist/ZORA_GAME_COMPONENT_META.d.ts +169 -1
  4. package/dist/ZORA_GAME_COMPONENT_META.d.ts.map +1 -1
  5. package/dist/ZORA_GAME_COMPONENT_META.js +2 -0
  6. package/dist/ZORA_GAME_COMPONENT_META.js.map +1 -1
  7. package/dist/ZORA_GAME_PLUGIN.d.ts +175 -2
  8. package/dist/ZORA_GAME_PLUGIN.d.ts.map +1 -1
  9. package/dist/ZORA_GAME_PLUGIN.js +2 -0
  10. package/dist/ZORA_GAME_PLUGIN.js.map +1 -1
  11. package/dist/ZORA_PLUGIN_METADATA.d.ts +173 -2
  12. package/dist/ZORA_PLUGIN_METADATA.d.ts.map +1 -1
  13. package/dist/ZORA_PLUGIN_METADATA.js +5 -1
  14. package/dist/ZORA_PLUGIN_METADATA.js.map +1 -1
  15. package/dist/features/game-presentation/adapters/inbound/Game.d.ts.map +1 -1
  16. package/dist/features/game-presentation/adapters/inbound/Game.js +8 -3
  17. package/dist/features/game-presentation/adapters/inbound/Game.js.map +1 -1
  18. package/dist/features/game-presentation/adapters/inbound/GameEntity.d.ts.map +1 -1
  19. package/dist/features/game-presentation/adapters/inbound/GameEntity.js +4 -11
  20. package/dist/features/game-presentation/adapters/inbound/GameEntity.js.map +1 -1
  21. package/dist/features/game-presentation/adapters/inbound/GameInputZone.d.ts +4 -0
  22. package/dist/features/game-presentation/adapters/inbound/GameInputZone.d.ts.map +1 -0
  23. package/dist/features/game-presentation/adapters/inbound/GameInputZone.js +35 -0
  24. package/dist/features/game-presentation/adapters/inbound/GameInputZone.js.map +1 -0
  25. package/dist/features/game-presentation/adapters/inbound/createGamePointerEvent.d.ts +17 -0
  26. package/dist/features/game-presentation/adapters/inbound/createGamePointerEvent.d.ts.map +1 -0
  27. package/dist/features/game-presentation/adapters/inbound/createGamePointerEvent.js +20 -0
  28. package/dist/features/game-presentation/adapters/inbound/createGamePointerEvent.js.map +1 -0
  29. package/dist/features/game-presentation/adapters/inbound/useGameInputZoneResponder.d.ts +9 -0
  30. package/dist/features/game-presentation/adapters/inbound/useGameInputZoneResponder.d.ts.map +1 -0
  31. package/dist/features/game-presentation/adapters/inbound/useGameInputZoneResponder.js +37 -0
  32. package/dist/features/game-presentation/adapters/inbound/useGameInputZoneResponder.js.map +1 -0
  33. package/dist/features/game-presentation/composition/createGameBindingContext.d.ts +4 -0
  34. package/dist/features/game-presentation/composition/createGameBindingContext.d.ts.map +1 -0
  35. package/dist/features/game-presentation/composition/createGameBindingContext.js +9 -0
  36. package/dist/features/game-presentation/composition/createGameBindingContext.js.map +1 -0
  37. package/dist/features/game-presentation/meta/gameEntityMeta.d.ts +58 -0
  38. package/dist/features/game-presentation/meta/gameEntityMeta.d.ts.map +1 -1
  39. package/dist/features/game-presentation/meta/gameEntityMeta.js +13 -0
  40. package/dist/features/game-presentation/meta/gameEntityMeta.js.map +1 -1
  41. package/dist/features/game-presentation/meta/gameInputZoneMeta.d.ts +112 -0
  42. package/dist/features/game-presentation/meta/gameInputZoneMeta.d.ts.map +1 -0
  43. package/dist/features/game-presentation/meta/gameInputZoneMeta.js +92 -0
  44. package/dist/features/game-presentation/meta/gameInputZoneMeta.js.map +1 -0
  45. package/dist/features/game-presentation/meta/gameMeta.d.ts +1 -1
  46. package/dist/features/game-presentation/meta/gameMeta.js +1 -1
  47. package/dist/features/game-presentation/meta/gameMeta.js.map +1 -1
  48. package/dist/features/game-presentation/public.d.ts +2 -1
  49. package/dist/features/game-presentation/public.d.ts.map +1 -1
  50. package/dist/features/game-presentation/public.js +1 -0
  51. package/dist/features/game-presentation/public.js.map +1 -1
  52. package/dist/features/game-presentation/utils/clampGamePercentage.d.ts +3 -0
  53. package/dist/features/game-presentation/utils/clampGamePercentage.d.ts.map +1 -0
  54. package/dist/features/game-presentation/utils/clampGamePercentage.js +5 -0
  55. package/dist/features/game-presentation/utils/clampGamePercentage.js.map +1 -0
  56. package/dist/features/game-presentation/utils/toGamePercentage.d.ts +3 -0
  57. package/dist/features/game-presentation/utils/toGamePercentage.d.ts.map +1 -0
  58. package/dist/features/game-presentation/utils/toGamePercentage.js +6 -0
  59. package/dist/features/game-presentation/utils/toGamePercentage.js.map +1 -0
  60. package/dist/index.d.ts +2 -2
  61. package/dist/index.d.ts.map +1 -1
  62. package/dist/index.js +1 -1
  63. package/dist/index.js.map +1 -1
  64. package/dist/types/gamePresentation.d.ts +13 -0
  65. package/dist/types/gamePresentation.d.ts.map +1 -1
  66. package/dist/types/gamePresentation.js.map +1 -1
  67. package/package.json +3 -2
  68. package/src/ZORA_GAME_COMPONENT_META.ts +2 -0
  69. package/src/ZORA_GAME_PLUGIN.ts +2 -0
  70. package/src/ZORA_PLUGIN_METADATA.test.ts +20 -0
  71. package/src/ZORA_PLUGIN_METADATA.ts +5 -1
  72. package/src/features/game-presentation/adapters/inbound/Game.tsx +19 -11
  73. package/src/features/game-presentation/adapters/inbound/GameEntity.tsx +4 -13
  74. package/src/features/game-presentation/adapters/inbound/GameInputZone.tsx +70 -0
  75. package/src/features/game-presentation/adapters/inbound/createGamePointerEvent.test.ts +56 -0
  76. package/src/features/game-presentation/adapters/inbound/createGamePointerEvent.ts +39 -0
  77. package/src/features/game-presentation/adapters/inbound/useGameInputZoneResponder.ts +49 -0
  78. package/src/features/game-presentation/composition/createGameBindingContext.test.ts +47 -0
  79. package/src/features/game-presentation/composition/createGameBindingContext.ts +10 -0
  80. package/src/features/game-presentation/meta/gameEntityMeta.ts +13 -0
  81. package/src/features/game-presentation/meta/gameInputZoneMeta.ts +94 -0
  82. package/src/features/game-presentation/meta/gameMeta.ts +1 -1
  83. package/src/features/game-presentation/public.ts +2 -0
  84. package/src/features/game-presentation/utils/clampGamePercentage.ts +4 -0
  85. package/src/features/game-presentation/utils/toGamePercentage.ts +6 -0
  86. package/src/index.ts +8 -1
  87. package/src/types/gamePresentation.ts +14 -0
@@ -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", "GameOverlay", "Gradient", "Image", "View"];
11
+ readonly allowedChildren: readonly ["GameEntity", "GameInputZone", "GameOverlay", "Gradient", "Image", "View"];
12
12
  readonly blueprint: {
13
13
  readonly label: "Game";
14
14
  readonly defaultProps: {
@@ -138,6 +138,64 @@ export declare const ZORA_PLUGIN_METADATA: {
138
138
  readonly zIndex: 0;
139
139
  };
140
140
  };
141
+ readonly bindings: {
142
+ readonly props: {
143
+ readonly x: {
144
+ readonly value: {
145
+ readonly type: "number";
146
+ };
147
+ readonly acceptsFallback: true;
148
+ };
149
+ readonly y: {
150
+ readonly value: {
151
+ readonly type: "number";
152
+ };
153
+ readonly acceptsFallback: true;
154
+ };
155
+ readonly width: {
156
+ readonly value: {
157
+ readonly type: "number";
158
+ };
159
+ readonly acceptsFallback: true;
160
+ };
161
+ readonly height: {
162
+ readonly value: {
163
+ readonly type: "number";
164
+ };
165
+ readonly acceptsFallback: true;
166
+ };
167
+ readonly opacity: {
168
+ readonly value: {
169
+ readonly type: "number";
170
+ };
171
+ readonly acceptsFallback: true;
172
+ };
173
+ readonly scale: {
174
+ readonly value: {
175
+ readonly type: "number";
176
+ };
177
+ readonly acceptsFallback: true;
178
+ };
179
+ readonly rotation: {
180
+ readonly value: {
181
+ readonly type: "number";
182
+ };
183
+ readonly acceptsFallback: true;
184
+ };
185
+ readonly zIndex: {
186
+ readonly value: {
187
+ readonly type: "number";
188
+ };
189
+ readonly acceptsFallback: true;
190
+ };
191
+ readonly hidden: {
192
+ readonly value: {
193
+ readonly type: "boolean";
194
+ };
195
+ readonly acceptsFallback: true;
196
+ };
197
+ };
198
+ };
141
199
  readonly props: {
142
200
  readonly x: {
143
201
  readonly type: "number";
@@ -288,6 +346,116 @@ export declare const ZORA_PLUGIN_METADATA: {
288
346
  };
289
347
  };
290
348
  };
349
+ readonly GameInputZone: {
350
+ readonly name: "GameInputZone";
351
+ readonly category: "component";
352
+ readonly description: "Normalizes pointer and touch positions into field-relative percentages and dispatches a generic game event.";
353
+ readonly directManifestNode: true;
354
+ readonly allowedChildren: readonly [];
355
+ readonly blueprint: {
356
+ readonly label: "Game input zone";
357
+ readonly defaultProps: {
358
+ readonly eventType: "game.pointer";
359
+ readonly x: 0;
360
+ readonly y: 0;
361
+ readonly width: 100;
362
+ readonly height: 100;
363
+ readonly zIndex: 1;
364
+ readonly enabled: true;
365
+ readonly continuous: true;
366
+ };
367
+ };
368
+ readonly props: {
369
+ readonly eventType: {
370
+ readonly type: "string";
371
+ readonly category: "Input";
372
+ readonly label: "Game event type";
373
+ readonly default: "game.pointer";
374
+ readonly authoring: {
375
+ readonly authority: "instance";
376
+ };
377
+ };
378
+ readonly entityId: {
379
+ readonly type: "string";
380
+ readonly category: "Input";
381
+ readonly label: "Entity id";
382
+ readonly authoring: {
383
+ readonly authority: "instance";
384
+ };
385
+ };
386
+ readonly x: {
387
+ readonly type: "number";
388
+ readonly category: "Position";
389
+ readonly label: "X (%)";
390
+ readonly default: 0;
391
+ readonly authoring: {
392
+ readonly authority: "instance";
393
+ };
394
+ };
395
+ readonly y: {
396
+ readonly type: "number";
397
+ readonly category: "Position";
398
+ readonly label: "Y (%)";
399
+ readonly default: 0;
400
+ readonly authoring: {
401
+ readonly authority: "instance";
402
+ };
403
+ };
404
+ readonly width: {
405
+ readonly type: "number";
406
+ readonly category: "Size";
407
+ readonly label: "Width (%)";
408
+ readonly default: 100;
409
+ readonly authoring: {
410
+ readonly authority: "instance";
411
+ };
412
+ };
413
+ readonly height: {
414
+ readonly type: "number";
415
+ readonly category: "Size";
416
+ readonly label: "Height (%)";
417
+ readonly default: 100;
418
+ readonly authoring: {
419
+ readonly authority: "instance";
420
+ };
421
+ };
422
+ readonly zIndex: {
423
+ readonly type: "number";
424
+ readonly category: "Position";
425
+ readonly label: "Z index";
426
+ readonly default: 1;
427
+ readonly authoring: {
428
+ readonly authority: "instance";
429
+ };
430
+ };
431
+ readonly enabled: {
432
+ readonly type: "boolean";
433
+ readonly category: "State";
434
+ readonly label: "Enabled";
435
+ readonly default: true;
436
+ readonly authoring: {
437
+ readonly authority: "instance";
438
+ };
439
+ };
440
+ readonly continuous: {
441
+ readonly type: "boolean";
442
+ readonly category: "Input";
443
+ readonly label: "Dispatch while moving";
444
+ readonly default: true;
445
+ readonly authoring: {
446
+ readonly authority: "instance";
447
+ };
448
+ };
449
+ readonly accessibilityLabel: {
450
+ readonly type: "string";
451
+ readonly category: "Accessibility";
452
+ readonly label: "Accessibility label";
453
+ readonly authoring: {
454
+ readonly authority: "instance";
455
+ };
456
+ };
457
+ };
458
+ };
291
459
  readonly GameOverlay: {
292
460
  readonly name: "GameOverlay";
293
461
  readonly category: "layout";
@@ -342,7 +510,7 @@ export declare const ZORA_PLUGIN_METADATA: {
342
510
  };
343
511
  };
344
512
  };
345
- readonly extensionHosts: readonly ["Game", "GameField", "GameEntity", "GameOverlay"];
513
+ readonly extensionHosts: readonly ["Game", "GameEntity", "GameField", "GameInputZone", "GameOverlay"];
346
514
  readonly placements: readonly [{
347
515
  readonly child: "Game";
348
516
  readonly parents: readonly ["Card", "Grid", "Screen", "ScreenSection", "View"];
@@ -352,6 +520,9 @@ export declare const ZORA_PLUGIN_METADATA: {
352
520
  }, {
353
521
  readonly child: "GameEntity";
354
522
  readonly parents: readonly ["Game", "GameField", "GameOverlay"];
523
+ }, {
524
+ readonly child: "GameInputZone";
525
+ readonly parents: readonly ["Game"];
355
526
  }, {
356
527
  readonly child: "GameOverlay";
357
528
  readonly parents: readonly ["Game", "GameField"];
@@ -1 +1 @@
1
- {"version":3,"file":"ZORA_PLUGIN_METADATA.d.ts","sourceRoot":"","sources":["../src/ZORA_PLU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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BM,CAAC"}
@@ -4,7 +4,7 @@ export const ZORA_PLUGIN_METADATA = {
4
4
  packageName: '@ankhorage/zora-game',
5
5
  displayName: 'ZORA Game',
6
6
  componentMeta: ZORA_GAME_COMPONENT_META,
7
- extensionHosts: ['Game', 'GameField', 'GameEntity', 'GameOverlay'],
7
+ extensionHosts: ['Game', 'GameEntity', 'GameField', 'GameInputZone', 'GameOverlay'],
8
8
  placements: [
9
9
  {
10
10
  child: 'Game',
@@ -18,6 +18,10 @@ export const ZORA_PLUGIN_METADATA = {
18
18
  child: 'GameEntity',
19
19
  parents: ['Game', 'GameField', 'GameOverlay'],
20
20
  },
21
+ {
22
+ child: 'GameInputZone',
23
+ parents: ['Game'],
24
+ },
21
25
  {
22
26
  child: 'GameOverlay',
23
27
  parents: ['Game', 'GameField'],
@@ -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,WAAW,EAAE,YAAY,EAAE,aAAa,CAAC;IAClE,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,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', 'GameField', 'GameEntity', '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: '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,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 +1 @@
1
- {"version":3,"file":"Game.d.ts","sourceRoot":"","sources":["../../../../../src/features/game-presentation/adapters/inbound/Game.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAKpE,kGAAkG;AAClG,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,qBAkBpC"}
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;AAMpE,kGAAkG;AAClG,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,qBAwBpC"}
@@ -1,16 +1,21 @@
1
+ import { RuntimeRendererConfigProvider } from '@ankhorage/runtime';
1
2
  import React from 'react';
3
+ import { createGameBindingContext } from '../../composition/createGameBindingContext';
2
4
  import { GameRuntimeContext } from '../../composition/GameRuntimeContext';
3
5
  import { useGameRuntime } from '../../composition/useGameRuntime';
4
6
  import { GameField } from './GameField';
5
7
  /*** Bind one serializable game definition to a local transient session and presentation field. */
6
8
  export function Game(props) {
7
9
  const runtime = useGameRuntime(props);
10
+ const runtimeBindingConfig = React.useMemo(() => ({ bindingContext: createGameBindingContext(runtime.session) }), [runtime.session]);
8
11
  return (<GameRuntimeContext.Provider value={runtime}>
9
- <GameField {...(props.aspectRatio === undefined ? {} : { aspectRatio: props.aspectRatio })} {...(props.minHeight === undefined ? {} : { minHeight: props.minHeight })} {...(props.clip === undefined ? {} : { clip: props.clip })} {...(props.accessibilityLabel === undefined
12
+ <RuntimeRendererConfigProvider value={runtimeBindingConfig}>
13
+ <GameField {...(props.aspectRatio === undefined ? {} : { aspectRatio: props.aspectRatio })} {...(props.minHeight === undefined ? {} : { minHeight: props.minHeight })} {...(props.clip === undefined ? {} : { clip: props.clip })} {...(props.accessibilityLabel === undefined
10
14
  ? {}
11
15
  : { accessibilityLabel: props.accessibilityLabel })} {...(props.testID === undefined ? {} : { testID: props.testID })}>
12
- {props.children}
13
- </GameField>
16
+ {props.children}
17
+ </GameField>
18
+ </RuntimeRendererConfigProvider>
14
19
  </GameRuntimeContext.Provider>);
15
20
  }
16
21
  //# sourceMappingURL=Game.js.map
@@ -1 +1 @@
1
- {"version":3,"file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,CAAC,QAAQ,CACjB;MAAA,EAAE,SAAS,CACb;IAAA,EAAE,kBAAkB,CAAC,QAAQ,CAAC,CAC/B,CAAC;AACJ,CAAC","sourcesContent":["import React from 'react';\n\nimport type { GameProps } from '../../../../types/gamePresentation';\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\n return (\n <GameRuntimeContext.Provider value={runtime}>\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 </GameRuntimeContext.Provider>\n );\n}\n"]}
1
+ {"version":3,"file":"Game.js","sourceRoot":"","sources":["../../../../../src/features/game-presentation/adapters/inbound/Game.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,wBAAwB,EAAE,MAAM,4CAA4C,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,kGAAkG;AAClG,MAAM,UAAU,IAAI,CAAC,KAAgB;IACnC,MAAM,OAAO,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;IACtC,MAAM,oBAAoB,GAAG,KAAK,CAAC,OAAO,CACxC,GAAG,EAAE,CAAC,CAAC,EAAE,cAAc,EAAE,wBAAwB,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,EACrE,CAAC,OAAO,CAAC,OAAO,CAAC,CAClB,CAAC;IAEF,OAAO,CACL,CAAC,kBAAkB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAC1C;MAAA,CAAC,6BAA6B,CAAC,KAAK,CAAC,CAAC,oBAAoB,CAAC,CACzD;QAAA,CAAC,SAAS,CACR,IAAI,CAAC,KAAK,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAChF,IAAI,CAAC,KAAK,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAC1E,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAC3D,IAAI,CAAC,KAAK,CAAC,kBAAkB,KAAK,SAAS;QACzC,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,EAAE,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,EAAE,CAAC,CAAC,CACtD,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,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 { 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 runtimeBindingConfig = React.useMemo(\n () => ({ bindingContext: createGameBindingContext(runtime.session) }),\n [runtime.session],\n );\n\n return (\n <GameRuntimeContext.Provider value={runtime}>\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 +1 @@
1
- {"version":3,"file":"GameEntity.d.ts","sourceRoot":"","sources":["../../../../../src/features/game-presentation/adapters/inbound/GameEntity.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAE1E,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,kBAAkB,EAClB,MAAM,GACP,EAAE,eAAe,+BAcjB"}
1
+ {"version":3,"file":"GameEntity.d.ts","sourceRoot":"","sources":["../../../../../src/features/game-presentation/adapters/inbound/GameEntity.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAG1E,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,kBAAkB,EAClB,MAAM,GACP,EAAE,eAAe,+BAcjB"}
@@ -1,5 +1,6 @@
1
1
  import { View } from '@ankhorage/zora';
2
2
  import { StyleSheet } from 'react-native';
3
+ import { toGamePercentage } from '../../utils/toGamePercentage';
3
4
  /*** Render one generic positioned game entity without owning gameplay semantics. */
4
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, }) {
5
6
  return (<View {...(accessibilityLabel === undefined ? {} : { accessibilityLabel })} {...(testID === undefined ? {} : { testID })} pointerEvents={pointerEvents} style={[
@@ -13,24 +14,16 @@ export function GameEntity({ children, x = 0, y = 0, width, height, opacity = 1,
13
14
  function createEntityStyle({ x, y, width, height, opacity, scale, rotation, zIndex, hidden, }) {
14
15
  return {
15
16
  display: hidden ? 'none' : 'flex',
16
- left: toPercent(x),
17
- opacity: clamp(opacity, 0, 1),
17
+ left: toGamePercentage(x),
18
+ opacity: Math.min(1, Math.max(0, opacity)),
18
19
  position: 'absolute',
19
- top: toPercent(y),
20
+ top: toGamePercentage(y),
20
21
  transform: [{ scale }, { rotate: `${rotation}deg` }],
21
22
  zIndex,
22
23
  ...(height === undefined ? {} : { height }),
23
24
  ...(width === undefined ? {} : { width }),
24
25
  };
25
26
  }
26
- /*** Convert a bounded percentage number to React Native percentage syntax. */
27
- function toPercent(value) {
28
- return `${clamp(value, 0, 100)}%`;
29
- }
30
- /*** Clamp one numeric presentation value to an inclusive range. */
31
- function clamp(value, minimum, maximum) {
32
- return Math.min(maximum, Math.max(minimum, value));
33
- }
34
27
  const styles = StyleSheet.create({
35
28
  root: {
36
29
  position: 'absolute',
@@ -1 +1 @@
1
- {"version":3,"file":"GameEntity.js","sourceRoot":"","sources":["../../../../../src/features/game-presentation/adapters/inbound/GameEntity.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,UAAU,EAAkB,MAAM,cAAc,CAAC;AAI1D,oFAAoF;AACpF,MAAM,UAAU,UAAU,CAAC,EACzB,QAAQ,EACR,CAAC,GAAG,CAAC,EACL,CAAC,GAAG,CAAC,EACL,KAAK,EACL,MAAM,EACN,OAAO,GAAG,CAAC,EACX,KAAK,GAAG,CAAC,EACT,QAAQ,GAAG,CAAC,EACZ,MAAM,GAAG,CAAC,EACV,MAAM,GAAG,KAAK,EACd,aAAa,GAAG,MAAM,EACtB,kBAAkB,EAClB,MAAM,GACU;IAChB,OAAO,CACL,CAAC,IAAI,CACH,IAAI,CAAC,kBAAkB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,kBAAkB,EAAE,CAAC,CAAC,CACrE,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAC7C,aAAa,CAAC,CAAC,aAAa,CAAC,CAC7B,KAAK,CAAC,CAAC;YACL,MAAM,CAAC,IAAI;YACX,iBAAiB,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;SACrF,CAAC,CAEF;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,SAAS,CAAC,CAAC,CAAC;QAClB,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;QAC7B,QAAQ,EAAE,UAAU;QACpB,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC;QACjB,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,8EAA8E;AAC9E,SAAS,SAAS,CAAC,KAAa;IAC9B,OAAO,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC;AACpC,CAAC;AAED,mEAAmE;AACnE,SAAS,KAAK,CAAC,KAAa,EAAE,OAAe,EAAE,OAAe;IAC5D,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;AACrD,CAAC;AAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,IAAI,EAAE;QACJ,QAAQ,EAAE,UAAU;KACrB;CACF,CAAC,CAAC","sourcesContent":["import { View } from '@ankhorage/zora';\nimport { StyleSheet, type ViewStyle } from 'react-native';\n\nimport type { GameEntityProps } from '../../../../types/gamePresentation';\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 accessibilityLabel,\n testID,\n}: GameEntityProps) {\n return (\n <View\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: toPercent(x),\n opacity: clamp(opacity, 0, 1),\n position: 'absolute',\n top: toPercent(y),\n transform: [{ scale }, { rotate: `${rotation}deg` }],\n zIndex,\n ...(height === undefined ? {} : { height }),\n ...(width === undefined ? {} : { width }),\n };\n}\n\n/*** Convert a bounded percentage number to React Native percentage syntax. */\nfunction toPercent(value: number): `${number}%` {\n return `${clamp(value, 0, 100)}%`;\n}\n\n/*** Clamp one numeric presentation value to an inclusive range. */\nfunction clamp(value: number, minimum: number, maximum: number): number {\n return Math.min(maximum, Math.max(minimum, value));\n}\n\nconst styles = StyleSheet.create({\n root: {\n position: 'absolute',\n },\n});\n"]}
1
+ {"version":3,"file":"GameEntity.js","sourceRoot":"","sources":["../../../../../src/features/game-presentation/adapters/inbound/GameEntity.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,UAAU,EAAkB,MAAM,cAAc,CAAC;AAG1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE,oFAAoF;AACpF,MAAM,UAAU,UAAU,CAAC,EAC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,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 { View } from '@ankhorage/zora';\nimport { StyleSheet, type ViewStyle } from 'react-native';\n\nimport type { GameEntityProps } from '../../../../types/gamePresentation';\nimport { toGamePercentage } from '../../utils/toGamePercentage';\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 accessibilityLabel,\n testID,\n}: GameEntityProps) {\n return (\n <View\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"]}
@@ -0,0 +1,4 @@
1
+ import type { GameInputZoneProps } from '../../../../types/gamePresentation';
2
+ /*** Capture pointer/touch geometry and dispatch only normalized generic Game events. */
3
+ export declare function GameInputZone({ x, y, width, height, zIndex, enabled, continuous, accessibilityLabel, testID, ...inputProps }: GameInputZoneProps): import("react").JSX.Element;
4
+ //# sourceMappingURL=GameInputZone.d.ts.map
@@ -0,0 +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,wFAAwF;AACxF,wBAAgB,aAAa,CAAC,EAC5B,CAAK,EACL,CAAK,EACL,KAAW,EACX,MAAY,EACZ,MAAU,EACV,OAAc,EACd,UAAiB,EACjB,kBAAkB,EAClB,MAAM,EACN,GAAG,UAAU,EACd,EAAE,kBAAkB,+BAyBpB"}
@@ -0,0 +1,35 @@
1
+ import { StyleSheet, View } from 'react-native';
2
+ import { toGamePercentage } from '../../utils/toGamePercentage';
3
+ import { useGameInputZoneResponder } from './useGameInputZoneResponder';
4
+ /*** Capture pointer/touch geometry and dispatch only normalized generic Game events. */
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({
7
+ ...inputProps,
8
+ x,
9
+ y,
10
+ width,
11
+ height,
12
+ enabled,
13
+ continuous,
14
+ });
15
+ return (<View {...(accessibilityLabel === undefined ? {} : { accessibilityLabel })} {...(testID === undefined ? {} : { testID })} {...(continuous
16
+ ? { onResponderGrant: dispatchPointer, onResponderMove: dispatchPointer }
17
+ : { onResponderRelease: dispatchPointer })} collapsable={false} onLayout={handleLayout} onStartShouldSetResponder={shouldSetResponder} pointerEvents={enabled ? 'auto' : 'none'} style={createInputZoneStyle({ x, y, width, height, zIndex })}/>);
18
+ }
19
+ /*** Convert field-relative input-zone props into one absolute React Native style. */
20
+ function createInputZoneStyle({ x, y, width, height, zIndex }) {
21
+ return {
22
+ left: toGamePercentage(x),
23
+ top: toGamePercentage(y),
24
+ width: toGamePercentage(width),
25
+ height: toGamePercentage(height),
26
+ zIndex,
27
+ ...styles.root,
28
+ };
29
+ }
30
+ const styles = StyleSheet.create({
31
+ root: {
32
+ position: 'absolute',
33
+ },
34
+ });
35
+ //# sourceMappingURL=GameInputZone.js.map
@@ -0,0 +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;AAGhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAExE,wFAAwF;AACxF,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,kBAAkB,EAClB,MAAM,EACN,GAAG,UAAU,EACM;IACnB,MAAM,EAAE,eAAe,EAAE,YAAY,EAAE,kBAAkB,EAAE,GAAG,yBAAyB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MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,IAAI,EAAE;QACJ,QAAQ,EAAE,UAAU;KACrB;CACF,CAAC,CAAC","sourcesContent":["import { 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 dispatch only 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 accessibilityLabel,\n testID,\n ...inputProps\n}: GameInputZoneProps) {\n const { dispatchPointer, handleLayout, shouldSetResponder } = useGameInputZoneResponder({\n ...inputProps,\n x,\n y,\n width,\n height,\n enabled,\n continuous,\n });\n\n return (\n <View\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 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,17 @@
1
+ import type { GameEvent } from '@ankhorage/game';
2
+ interface GamePointerEventInput {
3
+ readonly eventType: string;
4
+ readonly entityId?: string;
5
+ readonly localX: number;
6
+ readonly localY: number;
7
+ readonly measuredWidth: number;
8
+ readonly measuredHeight: number;
9
+ readonly zoneX: number;
10
+ readonly zoneY: number;
11
+ readonly zoneWidth: number;
12
+ readonly zoneHeight: number;
13
+ }
14
+ /*** Normalize one measured pointer/touch position into a field-relative generic Game event. */
15
+ export declare function createGamePointerEvent(input: GamePointerEventInput): GameEvent | undefined;
16
+ export {};
17
+ //# sourceMappingURL=createGamePointerEvent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createGamePointerEvent.d.ts","sourceRoot":"","sources":["../../../../../src/features/game-presentation/adapters/inbound/createGamePointerEvent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAIjD,UAAU,qBAAqB;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,+FAA+F;AAC/F,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,qBAAqB,GAAG,SAAS,GAAG,SAAS,CAoB1F"}
@@ -0,0 +1,20 @@
1
+ import { clampGamePercentage } from '../../utils/clampGamePercentage';
2
+ /*** Normalize one measured pointer/touch position into a field-relative generic Game event. */
3
+ export function createGamePointerEvent(input) {
4
+ if (!Number.isFinite(input.measuredWidth) ||
5
+ !Number.isFinite(input.measuredHeight) ||
6
+ input.measuredWidth <= 0 ||
7
+ input.measuredHeight <= 0) {
8
+ return undefined;
9
+ }
10
+ const localX = clampGamePercentage((input.localX / input.measuredWidth) * 100);
11
+ const localY = clampGamePercentage((input.localY / input.measuredHeight) * 100);
12
+ const x = clampGamePercentage(input.zoneX + (localX * input.zoneWidth) / 100);
13
+ const y = clampGamePercentage(input.zoneY + (localY * input.zoneHeight) / 100);
14
+ return {
15
+ type: input.eventType,
16
+ ...(input.entityId === undefined ? {} : { entityId: input.entityId }),
17
+ payload: { x, y },
18
+ };
19
+ }
20
+ //# sourceMappingURL=createGamePointerEvent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createGamePointerEvent.js","sourceRoot":"","sources":["../../../../../src/features/game-presentation/adapters/inbound/createGamePointerEvent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAetE,+FAA+F;AAC/F,MAAM,UAAU,sBAAsB,CAAC,KAA4B;IACjE,IACE,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC;QACrC,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC;QACtC,KAAK,CAAC,aAAa,IAAI,CAAC;QACxB,KAAK,CAAC,cAAc,IAAI,CAAC,EACzB,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,MAAM,GAAG,mBAAmB,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,aAAa,CAAC,GAAG,GAAG,CAAC,CAAC;IAC/E,MAAM,MAAM,GAAG,mBAAmB,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,cAAc,CAAC,GAAG,GAAG,CAAC,CAAC;IAChF,MAAM,CAAC,GAAG,mBAAmB,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG,GAAG,CAAC,CAAC;IAC9E,MAAM,CAAC,GAAG,mBAAmB,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,MAAM,GAAG,KAAK,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,CAAC;IAE/E,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,SAAS;QACrB,GAAG,CAAC,KAAK,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC;QACrE,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE;KAClB,CAAC;AACJ,CAAC","sourcesContent":["import type { GameEvent } from '@ankhorage/game';\n\nimport { clampGamePercentage } from '../../utils/clampGamePercentage';\n\ninterface GamePointerEventInput {\n readonly eventType: string;\n readonly entityId?: string;\n readonly localX: number;\n readonly localY: number;\n readonly measuredWidth: number;\n readonly measuredHeight: number;\n readonly zoneX: number;\n readonly zoneY: number;\n readonly zoneWidth: number;\n readonly zoneHeight: number;\n}\n\n/*** Normalize one measured pointer/touch position into a field-relative generic Game event. */\nexport function createGamePointerEvent(input: GamePointerEventInput): GameEvent | undefined {\n if (\n !Number.isFinite(input.measuredWidth) ||\n !Number.isFinite(input.measuredHeight) ||\n input.measuredWidth <= 0 ||\n input.measuredHeight <= 0\n ) {\n return undefined;\n }\n\n const localX = clampGamePercentage((input.localX / input.measuredWidth) * 100);\n const localY = clampGamePercentage((input.localY / input.measuredHeight) * 100);\n const x = clampGamePercentage(input.zoneX + (localX * input.zoneWidth) / 100);\n const y = clampGamePercentage(input.zoneY + (localY * input.zoneHeight) / 100);\n\n return {\n type: input.eventType,\n ...(input.entityId === undefined ? {} : { entityId: input.entityId }),\n payload: { x, y },\n };\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import type { GestureResponderEvent, LayoutChangeEvent } from 'react-native';
2
+ import type { GameInputZoneProps } from '../../../../types/gamePresentation';
3
+ /*** Own React Native responder measurement and event dispatch for one Game input zone. */
4
+ export declare function useGameInputZoneResponder(props: GameInputZoneProps): {
5
+ dispatchPointer: (event: GestureResponderEvent) => void;
6
+ handleLayout: (event: LayoutChangeEvent) => void;
7
+ shouldSetResponder: () => boolean;
8
+ };
9
+ //# sourceMappingURL=useGameInputZoneResponder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useGameInputZoneResponder.d.ts","sourceRoot":"","sources":["../../../../../src/features/game-presentation/adapters/inbound/useGameInputZoneResponder.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAE7E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAS7E,0FAA0F;AAC1F,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,kBAAkB;6BAWvD,qBAAqB;0BANgB,iBAAiB;;EA8BjE"}
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ import { GameRuntimeContext } from '../../composition/GameRuntimeContext';
3
+ import { createGamePointerEvent } from './createGamePointerEvent';
4
+ /*** Own React Native responder measurement and event dispatch for one Game input zone. */
5
+ export function useGameInputZoneResponder(props) {
6
+ const runtime = React.useContext(GameRuntimeContext);
7
+ if (runtime === null)
8
+ throw new Error('GameInputZone must be rendered inside Game.');
9
+ const measuredSizeRef = React.useRef({ width: 0, height: 0 });
10
+ const handleLayout = React.useCallback((event) => {
11
+ const { width, height } = event.nativeEvent.layout;
12
+ measuredSizeRef.current = { width, height };
13
+ }, []);
14
+ const dispatchPointer = React.useCallback((event) => {
15
+ const measured = measuredSizeRef.current;
16
+ const gameEvent = createGamePointerEvent({
17
+ eventType: props.eventType,
18
+ ...(props.entityId === undefined ? {} : { entityId: props.entityId }),
19
+ localX: event.nativeEvent.locationX,
20
+ localY: event.nativeEvent.locationY,
21
+ measuredWidth: measured.width,
22
+ measuredHeight: measured.height,
23
+ zoneX: props.x ?? 0,
24
+ zoneY: props.y ?? 0,
25
+ zoneWidth: props.width ?? 100,
26
+ zoneHeight: props.height ?? 100,
27
+ });
28
+ if (gameEvent !== undefined)
29
+ runtime.dispatch(gameEvent);
30
+ }, [props.entityId, props.eventType, props.height, props.width, props.x, props.y, runtime]);
31
+ return {
32
+ dispatchPointer,
33
+ handleLayout,
34
+ shouldSetResponder: () => props.enabled ?? true,
35
+ };
36
+ }
37
+ //# sourceMappingURL=useGameInputZoneResponder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useGameInputZoneResponder.js","sourceRoot":"","sources":["../../../../../src/features/game-presentation/adapters/inbound/useGameInputZoneResponder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAOlE,0FAA0F;AAC1F,MAAM,UAAU,yBAAyB,CAAC,KAAyB;IACjE,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC;IACrD,IAAI,OAAO,KAAK,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IAErF,MAAM,eAAe,GAAG,KAAK,CAAC,MAAM,CAAe,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;IAC5E,MAAM,YAAY,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,KAAwB,EAAE,EAAE;QAClE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC;QACnD,eAAe,CAAC,OAAO,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAC9C,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,eAAe,GAAG,KAAK,CAAC,WAAW,CACvC,CAAC,KAA4B,EAAE,EAAE;QAC/B,MAAM,QAAQ,GAAG,eAAe,CAAC,OAAO,CAAC;QACzC,MAAM,SAAS,GAAG,sBAAsB,CAAC;YACvC,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,GAAG,CAAC,KAAK,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC;YACrE,MAAM,EAAE,KAAK,CAAC,WAAW,CAAC,SAAS;YACnC,MAAM,EAAE,KAAK,CAAC,WAAW,CAAC,SAAS;YACnC,aAAa,EAAE,QAAQ,CAAC,KAAK;YAC7B,cAAc,EAAE,QAAQ,CAAC,MAAM;YAC/B,KAAK,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC;YACnB,KAAK,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC;YACnB,SAAS,EAAE,KAAK,CAAC,KAAK,IAAI,GAAG;YAC7B,UAAU,EAAE,KAAK,CAAC,MAAM,IAAI,GAAG;SAChC,CAAC,CAAC;QACH,IAAI,SAAS,KAAK,SAAS;YAAE,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IAC3D,CAAC,EACD,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,CACxF,CAAC;IAEF,OAAO;QACL,eAAe;QACf,YAAY;QACZ,kBAAkB,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,IAAI,IAAI;KAChD,CAAC;AACJ,CAAC","sourcesContent":["import React from 'react';\nimport type { GestureResponderEvent, LayoutChangeEvent } from 'react-native';\n\nimport type { GameInputZoneProps } from '../../../../types/gamePresentation';\nimport { GameRuntimeContext } from '../../composition/GameRuntimeContext';\nimport { createGamePointerEvent } from './createGamePointerEvent';\n\ninterface MeasuredSize {\n readonly width: number;\n readonly height: number;\n}\n\n/*** Own React Native responder measurement and event dispatch for one Game input zone. */\nexport function useGameInputZoneResponder(props: GameInputZoneProps) {\n const runtime = React.useContext(GameRuntimeContext);\n if (runtime === null) throw new Error('GameInputZone must be rendered inside Game.');\n\n const measuredSizeRef = React.useRef<MeasuredSize>({ width: 0, height: 0 });\n const handleLayout = React.useCallback((event: LayoutChangeEvent) => {\n const { width, height } = event.nativeEvent.layout;\n measuredSizeRef.current = { width, height };\n }, []);\n\n const dispatchPointer = React.useCallback(\n (event: GestureResponderEvent) => {\n const measured = measuredSizeRef.current;\n const gameEvent = createGamePointerEvent({\n eventType: props.eventType,\n ...(props.entityId === undefined ? {} : { entityId: props.entityId }),\n localX: event.nativeEvent.locationX,\n localY: event.nativeEvent.locationY,\n measuredWidth: measured.width,\n measuredHeight: measured.height,\n zoneX: props.x ?? 0,\n zoneY: props.y ?? 0,\n zoneWidth: props.width ?? 100,\n zoneHeight: props.height ?? 100,\n });\n if (gameEvent !== undefined) runtime.dispatch(gameEvent);\n },\n [props.entityId, props.eventType, props.height, props.width, props.x, props.y, runtime],\n );\n\n return {\n dispatchPointer,\n handleLayout,\n shouldSetResponder: () => props.enabled ?? true,\n };\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type { GameSession } from '@ankhorage/game';
2
+ /*** Create the canonical Runtime context namespace for one local game session. */
3
+ export declare function createGameBindingContext(session: GameSession): Record<string, unknown>;
4
+ //# sourceMappingURL=createGameBindingContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createGameBindingContext.d.ts","sourceRoot":"","sources":["../../../../src/features/game-presentation/composition/createGameBindingContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,kFAAkF;AAClF,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAMtF"}
@@ -0,0 +1,9 @@
1
+ /*** Create the canonical Runtime context namespace for one local game session. */
2
+ export function createGameBindingContext(session) {
3
+ return {
4
+ game: {
5
+ session,
6
+ },
7
+ };
8
+ }
9
+ //# sourceMappingURL=createGameBindingContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createGameBindingContext.js","sourceRoot":"","sources":["../../../../src/features/game-presentation/composition/createGameBindingContext.ts"],"names":[],"mappings":"AAEA,kFAAkF;AAClF,MAAM,UAAU,wBAAwB,CAAC,OAAoB;IAC3D,OAAO;QACL,IAAI,EAAE;YACJ,OAAO;SACR;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { GameSession } from '@ankhorage/game';\n\n/*** Create the canonical Runtime context namespace for one local game session. */\nexport function createGameBindingContext(session: GameSession): Record<string, unknown> {\n return {\n game: {\n session,\n },\n };\n}\n"]}
@@ -16,6 +16,64 @@ export declare const gameEntityMeta: {
16
16
  readonly zIndex: 0;
17
17
  };
18
18
  };
19
+ readonly bindings: {
20
+ readonly props: {
21
+ readonly x: {
22
+ readonly value: {
23
+ readonly type: "number";
24
+ };
25
+ readonly acceptsFallback: true;
26
+ };
27
+ readonly y: {
28
+ readonly value: {
29
+ readonly type: "number";
30
+ };
31
+ readonly acceptsFallback: true;
32
+ };
33
+ readonly width: {
34
+ readonly value: {
35
+ readonly type: "number";
36
+ };
37
+ readonly acceptsFallback: true;
38
+ };
39
+ readonly height: {
40
+ readonly value: {
41
+ readonly type: "number";
42
+ };
43
+ readonly acceptsFallback: true;
44
+ };
45
+ readonly opacity: {
46
+ readonly value: {
47
+ readonly type: "number";
48
+ };
49
+ readonly acceptsFallback: true;
50
+ };
51
+ readonly scale: {
52
+ readonly value: {
53
+ readonly type: "number";
54
+ };
55
+ readonly acceptsFallback: true;
56
+ };
57
+ readonly rotation: {
58
+ readonly value: {
59
+ readonly type: "number";
60
+ };
61
+ readonly acceptsFallback: true;
62
+ };
63
+ readonly zIndex: {
64
+ readonly value: {
65
+ readonly type: "number";
66
+ };
67
+ readonly acceptsFallback: true;
68
+ };
69
+ readonly hidden: {
70
+ readonly value: {
71
+ readonly type: "boolean";
72
+ };
73
+ readonly acceptsFallback: true;
74
+ };
75
+ };
76
+ };
19
77
  readonly props: {
20
78
  readonly x: {
21
79
  readonly type: "number";
@@ -1 +1 @@
1
- {"version":3,"file":"gameEntityMeta.d.ts","sourceRoot":"","sources":["../../../../src/features/game-presentation/meta/gameEntityMeta.ts"],"names":[],"mappings":"AAEA,6EAA6E;AAC7E,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuFW,CAAC"}
1
+ {"version":3,"file":"gameEntityMeta.d.ts","sourceRoot":"","sources":["../../../../src/features/game-presentation/meta/gameEntityMeta.ts"],"names":[],"mappings":"AAEA,6EAA6E;AAC7E,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoGW,CAAC"}