@ankhorage/zora-game 0.4.0 → 0.4.1
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 +7 -0
- package/README.md +1 -1
- package/dist/features/game-presentation/composition/createGameBindingContext.d.ts.map +1 -1
- package/dist/features/game-presentation/composition/createGameBindingContext.js +1 -0
- package/dist/features/game-presentation/composition/createGameBindingContext.js.map +1 -1
- package/package.json +1 -1
- package/src/features/game-presentation/composition/createGameBindingContext.test.ts +20 -1
- package/src/features/game-presentation/composition/createGameBindingContext.ts +1 -0
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
# @ankhorage/zora-game
|
|
5
5
|
|
|
6
|
-
         
|
|
7
7
|
|
|
8
8
|
Generic game presentation primitives for React Native and React Native Web apps built on ZORA.
|
|
9
9
|
|
|
@@ -1 +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,
|
|
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,CAOtF"}
|
|
@@ -1 +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"]}
|
|
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,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC;YACzC,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 entities: Object.values(session.entities),\n session,\n },\n };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ankhorage/zora-game",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Generic game presentation primitives for React Native and React Native Web apps built on ZORA.",
|
|
6
6
|
"homepage": "https://github.com/ankhorage/zora-game#readme",
|
|
@@ -15,6 +15,11 @@ const session: GameSession = {
|
|
|
15
15
|
templateId: 'actor',
|
|
16
16
|
state: { x: 42, y: 73, label: 'Player' },
|
|
17
17
|
},
|
|
18
|
+
shot: {
|
|
19
|
+
id: 'shot',
|
|
20
|
+
templateId: 'projectile',
|
|
21
|
+
state: { x: 50, y: 60, label: 'A' },
|
|
22
|
+
},
|
|
18
23
|
},
|
|
19
24
|
scheduled: [],
|
|
20
25
|
elapsedMs: 120,
|
|
@@ -39,9 +44,23 @@ describe('createGameBindingContext', () => {
|
|
|
39
44
|
).toBe(80);
|
|
40
45
|
});
|
|
41
46
|
|
|
47
|
+
test('exposes current entities as a repeatable array with stable ids', () => {
|
|
48
|
+
const context = createGameBindingContext(session);
|
|
49
|
+
const entities = resolveRuntimeBindingValueSync(
|
|
50
|
+
{ source: { kind: 'context', path: 'game.entities' } },
|
|
51
|
+
{ context },
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
expect(Array.isArray(entities)).toBe(true);
|
|
55
|
+
expect(entities).toEqual(Object.values(session.entities));
|
|
56
|
+
});
|
|
57
|
+
|
|
42
58
|
test('owns only the local game namespace', () => {
|
|
43
59
|
expect(createGameBindingContext(session)).toEqual({
|
|
44
|
-
game: {
|
|
60
|
+
game: {
|
|
61
|
+
entities: Object.values(session.entities),
|
|
62
|
+
session,
|
|
63
|
+
},
|
|
45
64
|
});
|
|
46
65
|
});
|
|
47
66
|
});
|