openvibers/openvibe.games Commits
Fix content pack typings and the digest-less hello test assertion
Changes
@@@ -56,7 +56,7 @@ export interface ContentProp {export interface ContentPack {/** Definitions, deep-validated by `mergePackDefs`; the schema only bounds them. */defs?: NonNullable<ContentPackV2['defs']>-- map?: ContentPackV2['map']++ map?: NonNullable<ContentPackV2['map']>announcements?: ContentAnnouncement[]props?: ContentProp[]}@@@ -22,7 +22,7 @@ export * from './defs/skills.js'export * from './defs/resources.js'export * from './packs/scraplandia.js'--import { ContentRegistry } from './registry.js'++import { ContentRegistry, type ContentDefs } from './registry.js'import { mergePackDefs, type ContentPackV2 } from './pack.js'import { SCRAPLANDIA_PACK } from './packs/scraplandia.js'import { CROPS } from './defs/crops.js'@@@ -42,7 +42,7 @@ import { SKILLS } from './defs/skills.js'* immutable: packs take effect when it is built, i.e. at the next start.*/export function createContent(packs: ContentPackV2[] = []): ContentRegistry {-- const { defs, errors } = mergePackDefs(++ const { defs, errors } = mergePackDefs<ContentDefs>({items: ITEMS,recipes: RECIPES,@@@ -48,7 +48,8 @@ describe('protocol codec', () => {t: 'hello', v: PROTOCOL_VERSION - 1, slot: 0, name: 'Old',appearance: defaultAppearance(),}))-- expect(old).toMatchObject({ t: 'hello', contentDigest: undefined })++ expect(old).toMatchObject({ t: 'hello' })++ expect(old).not.toHaveProperty('contentDigest')expect(decodeClientMessage(JSON.stringify({t: 'hello', v: PROTOCOL_VERSION, contentDigest: 'garbage',slot: 0, name: 'Bad', appearance: defaultAppearance(),
@@ -56,7 +56,7 @@ export interface ContentProp {
@@ -56,7 +56,7 @@ export interface ContentProp {
export interface ContentPack {
export interface ContentPack {
/** Definitions, deep-validated by `mergePackDefs`; the schema only bounds them. */
/** Definitions, deep-validated by `mergePackDefs`; the schema only bounds them. */
defs?: NonNullable<ContentPackV2['defs']>
defs?: NonNullable<ContentPackV2['defs']>
- map?: ContentPackV2['map']
+ map?: NonNullable<ContentPackV2['map']>
announcements?: ContentAnnouncement[]
announcements?: ContentAnnouncement[]
props?: ContentProp[]
props?: ContentProp[]
}
}
@@ -22,7 +22,7 @@ export * from './defs/skills.js'
@@ -22,7 +22,7 @@ export * from './defs/skills.js'
export * from './defs/resources.js'
export * from './defs/resources.js'
export * from './packs/scraplandia.js'
export * from './packs/scraplandia.js'
-import { ContentRegistry } from './registry.js'
+import { ContentRegistry, type ContentDefs } from './registry.js'
import { mergePackDefs, type ContentPackV2 } from './pack.js'
import { mergePackDefs, type ContentPackV2 } from './pack.js'
import { SCRAPLANDIA_PACK } from './packs/scraplandia.js'
import { SCRAPLANDIA_PACK } from './packs/scraplandia.js'
import { CROPS } from './defs/crops.js'
import { CROPS } from './defs/crops.js'
@@ -42,7 +42,7 @@ import { SKILLS } from './defs/skills.js'
@@ -42,7 +42,7 @@ import { SKILLS } from './defs/skills.js'
* immutable: packs take effect when it is built, i.e. at the next start.
* immutable: packs take effect when it is built, i.e. at the next start.
*/
*/
export function createContent(packs: ContentPackV2[] = []): ContentRegistry {
export function createContent(packs: ContentPackV2[] = []): ContentRegistry {
- const { defs, errors } = mergePackDefs(
+ const { defs, errors } = mergePackDefs<ContentDefs>(
{
{
items: ITEMS,
items: ITEMS,
recipes: RECIPES,
recipes: RECIPES,
@@ -48,7 +48,8 @@ describe('protocol codec', () => {
@@ -48,7 +48,8 @@ describe('protocol codec', () => {
t: 'hello', v: PROTOCOL_VERSION - 1, slot: 0, name: 'Old',
t: 'hello', v: PROTOCOL_VERSION - 1, slot: 0, name: 'Old',
appearance: defaultAppearance(),
appearance: defaultAppearance(),
}))
}))
- expect(old).toMatchObject({ t: 'hello', contentDigest: undefined })
+ expect(old).toMatchObject({ t: 'hello' })
+ expect(old).not.toHaveProperty('contentDigest')
expect(decodeClientMessage(JSON.stringify({
expect(decodeClientMessage(JSON.stringify({
t: 'hello', v: PROTOCOL_VERSION, contentDigest: 'garbage',
t: 'hello', v: PROTOCOL_VERSION, contentDigest: 'garbage',
slot: 0, name: 'Bad', appearance: defaultAppearance(),
slot: 0, name: 'Bad', appearance: defaultAppearance(),