Creates player state and uses it to get and set values from local storage
This commit is contained in:
@@ -9,6 +9,7 @@ export const isGameStateEvent = new tg.IsInterface()
|
||||
startLayerName: tg.isUnion(tg.isString, tg.isNull),
|
||||
tags: tg.isArray(tg.isString),
|
||||
variables: tg.isObject,
|
||||
playerVariables: tg.isObject,
|
||||
})
|
||||
.get();
|
||||
/**
|
||||
|
||||
@@ -150,14 +150,6 @@ export const iframeQueryMapTypeGuards = {
|
||||
query: isCreateEmbeddedWebsiteEvent,
|
||||
answer: tg.isUndefined,
|
||||
},
|
||||
getPlayerProperty: {
|
||||
query: tg.isString,
|
||||
answer: isPlayerPropertyEvent,
|
||||
},
|
||||
setPlayerProperty: {
|
||||
query: isPlayerPropertyEvent,
|
||||
answer: tg.isUndefined,
|
||||
},
|
||||
};
|
||||
|
||||
type GuardedType<T> = T extends (x: unknown) => x is infer T ? T : never;
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
import * as tg from "generic-type-guard";
|
||||
|
||||
export const isPlayerPropertyEvent = new tg.IsInterface()
|
||||
.withProperties({
|
||||
propertyName: tg.isString,
|
||||
propertyValue: tg.isUnknown,
|
||||
})
|
||||
.get();
|
||||
|
||||
/**
|
||||
* A message sent from the iFrame to set player-related properties.
|
||||
*/
|
||||
export type PlayerPropertyEvent = tg.GuardedType<typeof isPlayerPropertyEvent>;
|
||||
@@ -4,6 +4,7 @@ export const isSetVariableEvent = new tg.IsInterface()
|
||||
.withProperties({
|
||||
key: tg.isString,
|
||||
value: tg.isUnknown,
|
||||
target: tg.isSingletonStringUnion("global", "player"),
|
||||
})
|
||||
.get();
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user