@cardsgame/types
Advanced tools
Comparing version 0.7.0 to 0.8.0
@@ -1,4 +0,2 @@ | ||
/** | ||
* Entity | ||
*/ | ||
// === Entity === | ||
@@ -13,3 +11,3 @@ type EntityID = number | ||
type: string | ||
data?: unknown // & PrivateAttributeChangeData | ||
data?: unknown | ||
@@ -23,14 +21,2 @@ /** | ||
// type PrivateAttributeChangeData = { | ||
// path: number[] | ||
// owner?: string | ||
// public: boolean | ||
// attribute: string | ||
// value: any | ||
// } | ||
/** | ||
* Event created by player on client | ||
* while interacting with game elements or UI | ||
*/ | ||
type ClientPlayerEvent = { | ||
@@ -42,3 +28,2 @@ /** | ||
command?: string | ||
/** | ||
@@ -48,21 +33,13 @@ * Interaction-related events ("click", "touchstart"...) | ||
event?: string | ||
/** | ||
* Path to target Entity. | ||
* As array of numbers: `[0, 2, 0]` | ||
* Ar a string: `"0,2,0"` (no spaces) | ||
* TODO: ^ Decide which one we're gonna keep... | ||
* Custom command's data. | ||
*/ | ||
entityPath?: number[] | string | ||
data?: any | ||
/** | ||
* Custom command's data. | ||
* Path to target Entity as an array: `[0,2,0]` | ||
*/ | ||
data?: any | ||
entityPath?: number[] | ||
} | ||
/** | ||
* Type of the element which player interacted with | ||
*/ | ||
// type PlayerEventTargetType = "Entity" | "UIElement" | ||
type PlayerInteractionEvent = { type: string; data?: any } | ||
@@ -80,14 +57,15 @@ /** | ||
// 1. Transform the type to flag all the undesired keys as 'never' | ||
type FlagExcludedType<Base, Type> = { | ||
[Key in keyof Base]: Base[Key] extends Type ? never : Key | ||
// === Utility types === | ||
interface AnyClass extends Function { | ||
new (...args: any[]): any | ||
} | ||
// 2. Get the keys that are not flagged as 'never' | ||
type AllowedNames<Base, Type> = FlagExcludedType<Base, Type>[keyof Base] | ||
type AllowArrays<T> = { [prop in keyof T]: T[prop] | Array<T[prop]> } | ||
// 3. Use this with a simple Pick to get the right interface, excluding the undesired type | ||
type OmitType<Base, Type> = Pick<Base, AllowedNames<Base, Type>> | ||
// 4. Exclude the Function type to only get properties | ||
type ConstructorType<T> = OmitType<T, Function> | ||
// Author: https://stackoverflow.com/a/55479659/1404284 | ||
type NonFunctionPropertyNames<T> = { | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
[K in keyof T]: T[K] extends Function ? never : K | ||
}[keyof T] | ||
type NonFunctionProperties<T> = Pick<T, NonFunctionPropertyNames<T>> |
{ | ||
"name": "@cardsgame/types", | ||
"version": "0.7.0", | ||
"version": "0.8.0", | ||
"description": "", | ||
"author": "Darek Greenly (https://darekgreenly.com)", | ||
"license": "ISC", | ||
"license": "MIT", | ||
"types": "index", | ||
"gitHead": "db08f5674a86f730a75faee37414299079fd8eaf" | ||
"gitHead": "a44fb0f1391342ef8d0ab9a8bac0648afa73ae2d" | ||
} |
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
0
2940
56