Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@eva/eva.js

Package Overview
Dependencies
Maintainers
2
Versions
168
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eva/eva.js - npm Package Compare versions

Comparing version 1.0.5-alpha.1 to 1.0.5-alpha.2

399

dist/eva.js.d.ts

@@ -5,69 +5,16 @@ import EE from 'eventemitter3';

/**
* Component contain raw data apply to gameObject and how it interacts with the world
* @public
*/
export declare class Component extends EventEmitter {
/** Name of this component */
static componentName: string;
/** Name of this component */
readonly name: string;
/**
* Represents the status of the component, If component has started, the value is true
* @defaultValue false
*/
started: boolean;
/**
* gameObject which this component had added on
* @remarks
* Component can only be added on one gameObject, otherwise an error will be thrown,
* see {@link https://eva.js.org/#/tutorials/gameObject} for more details
*/
gameObject: GameObject;
/** Default paramaters for this component */
__componentDefaultParams: string;
constructor(params?: any);
/**
* Called during component construction
* @param params - optional initial parameters
* @override
*/
init?(params?: any): void;
/**
* Called when component is added to a gameObject
* @override
*/
awake?(): void;
/**
* Called after all component's `awake` method has been called
* @override
*/
start?(): void;
/**
* Called in every tick, change self property or other component property
* @param frame - frame info about this tick
* @override
*/
update?(frame: UpdateParams): void;
/**
* Called after all gameObject's `update` method has been called
* @param frame - frame info about this tick
* @override
*/
lateUpdate?(frame: UpdateParams): void;
/**
* Called before game runing or every time game paused
* @virtual
* @override
*/
onResume?(): void;
/**
* Called while the game paused.
* @override
*/
onPause?(): void;
/**
* Called while component be destroyed.
* @override
*/
onDestroy?(): void;

@@ -83,45 +30,14 @@ }

/**
* Management observe events
* @remarks
* See {@link System} for more details
* @public
*/
declare class ComponentObserver {
/**
* Component property change events
* @defaultValue []
*/
private events;
/**
* Add event
* @remarks
* The same event will be placed last
* @param component - changed component
* @param prop - changed property on `component`
* @param type - change event type
* @param componentName - `component.name` this parameter will deprecated
*/
add({ component, prop, type, componentName }: ObserverEventParams): void;
/** Return change events */
getChanged(): ComponentChanged[];
/**
* Return change events
* @readonly
*/
get changed(): ComponentChanged[];
/** Clear events */
clear(): ComponentChanged[];
}
/**
* Normailize system observer info
* @param obj - system observer info
*/
export declare function componentObserver(observerInfo?: ObserverInfo): (constructor: any) => void;
/** type of Component is function */
declare type ComponentType = typeof Component;
/** Decorators util */
export declare const decorators: {

@@ -142,19 +58,8 @@ IDEProp: typeof IDEProp;

canvas: HTMLCanvasElement;
/**
* State of game
* @defaultValue false
*/
playing: boolean;
started: boolean;
multiScenes: Scene[];
/**
* Timeline for game
*/
ticker: Ticker;
/** Systems alled to this game */
systems: System[];
constructor({ autoStart, frameRate, systems, needScene, }?: GameParams);
/**
* Get scene on this game
*/
get scene(): Scene;

@@ -165,36 +70,11 @@ set scene(scene: Scene);

addSystem<T extends SystemType>(S: T, obj?: any): InstanceType<T>;
/**
* Remove system from this game
* @param system - one of system instance / system Class or system name
*/
removeSystem(system: System | SystemType | string): void;
/**
* Get system
* @param S - system class or system name
* @returns system instance
*/
getSystem(S: SystemType | string): System;
/** Pause game */
pause(): void;
/** Start game */
start(): void;
/** Resume game */
resume(): void;
/**
* add main render method to ticker
* @remarks
* the method added to ticker will called in each requestAnimationFrame,
* 1. call update method on all gameObject
* 2. call lastUpdate method on all gameObject
* 3. call update method on all system
* 4. call lastUpdate method on all system
*/
initTicker(): void;
/** Call onResume method on all gameObject's, and then call onResume method on all system */
triggerResume(): void;
/** Call onPause method on all gameObject */
triggerPause(): void;
/** remove all system on this game */
destroySystems(): void;
/** Destroy game instance */
destroy(): void;

@@ -204,72 +84,18 @@ loadScene({ scene, mode, params, }: LoadSceneParams): void;

/**
* GameObject is a general purpose object. It consists of a unique id and components.
* @public
*/
export declare class GameObject {
/** Name of this gameObject */
private _name;
/** Scene is an abstraction, represent a canvas layer */
private _scene;
/** A key-value map for components on this gameObject */
private _componentCache;
/** Identifier of this gameObject */
id: number;
/** Components apply to this gameObject */
components: Component[];
/**
* Consruct a new gameObject
* @param name - the name of this gameObject
* @param obj - optional transform parameters for default Transform component
*/
constructor(name: string, obj?: TransformParams);
/**
* Get default transform component
* @returns transform component on this gameObject
* @readonly
*/
get transform(): Transform;
/**
* Get parent gameObject
* @returns parent gameObject
* @readonly
*/
get parent(): GameObject;
/**
* Get the name of this gameObject
* @readonly
*/
get name(): string;
set scene(val: Scene);
/**
* Get the scene which this gameObject added on
* @returns scene
* @readonly
*/
get scene(): Scene;
/**
* Add child gameObject
* @param gameObject - child gameobject
*/
addChild(gameObject: GameObject): void;
/**
* Remove child gameObject
* @param gameObject - child gameobject
*/
removeChild(gameObject: GameObject): GameObject;
/**
* Add component to this gameObject
* @remarks
* If component has already been added on a gameObject, it will throw an error
* @param C - component instance or Component class
*/
addComponent<T extends Component>(C: T): T;
addComponent<T extends ComponentType>(C: T, obj?: any): InstanceType<T>;
/**
* Remove component on this gameObject
* @remarks
* default Transform component can not be removed, if the paramter represent a transform component, an error will be thrown.
* @param c - one of the compnoentName, component instance, component Class
* @returns
*/
removeComponent<T extends Component>(c: string): T;

@@ -279,16 +105,6 @@ removeComponent<T extends Component>(c: T): T;

private _removeComponent;
/**
* Get component on this gameObject
* @param c - one of the compnoentName, component instance, component Class
* @returns
*/
getComponent<T extends Component>(c: string): T;
getComponent<T extends Component>(c: T): T;
getComponent<T extends ComponentType>(c: T): InstanceType<T>;
/**
* Remove this gameObject on its parent
* @returns return this gameObject
*/
remove(): GameObject;
/** Destory this gameObject */
destroy(): void;

@@ -298,20 +114,10 @@ }

declare interface GameParams {
/** isn't game will auto start */
autoStart?: boolean;
/** fps for this game */
frameRate?: number;
/** systems in this game */
systems?: System[];
/** whether or not need to create scene */
needScene?: boolean;
}
/**
* Collect property which react in Editor, such as EVA Design
* @param target - component instance
* @param propertyKey - property name
*/
export declare function IDEProp(target: any, propertyKey: any): void;
/** Load event */
export declare enum LOAD_EVENT {

@@ -338,3 +144,2 @@ 'START' = "start",

/** Observer event type */
export declare enum OBSERVER_TYPE {

@@ -353,12 +158,2 @@ ADD = "ADD",

/**
* Normailized observer info
* @example
* ```typescript
* {
* Transform: [{ prop: ['size'], deep: false }],
* OtherComponent: [{ prop: ['style', 'transform'], deep: true }]
* }
* ```
*/
export declare type ObserverInfo = Record<ComponentName, ObserverValue[]>;

@@ -373,3 +168,2 @@

/** eva plugin struct */
export declare interface PluginStruct {

@@ -393,21 +187,4 @@ Components?: typeof Component[];

/**
* Observer Info
* @remarks
* The key of this map always be component's name, the value of this map is an array of `PureObserverProp`
*/
export declare type PureObserverInfo = Record<string, PureObserverProp[]>;
/**
* Observer property
* @remarks
* If `deep` is true then all descendants of `prop` will be observed
* @example
* ```typescript
* @observerComponent({
* Transform: [{ prop: 'size', deep: true }]
* })
* class TestSystem extends System {}
* ```
*/
declare interface PureObserverProp {

@@ -418,16 +195,7 @@ deep: boolean;

/**
* Resource manager
* @public
*/
declare class Resource extends EE {
/** load resource timeout */
timeout: number;
/** Resource cache */
private resourcesMap;
/** Collection of make resource instance function */
private makeInstanceFunctions;
/** Collection of destroy resource instance function */
private destroyInstanceFunctions;
/** Resource load promise */
private promiseMap;

@@ -439,20 +207,11 @@ private loaders;

});
/** Add resource configs and then preload */
loadConfig(resources: ResourceBase[]): void;
/** Add single resource config and then preload */
loadSingle(resource: ResourceBase): Promise<ResourceStruct>;
/** Add resource configs */
addResource(resources: ResourceBase[]): void;
/** Start preload */
preload(): void;
/** Get resource by name */
getResource(name: string): Promise<ResourceStruct>;
/** Make resource instance by resource type */
private instance;
/** destory this resource manager */
destroy(name: string): Promise<void>;
private _destroy;
/** Add resource instance function */
registerInstance(type: RESOURCE_TYPE | string, callback: ResourceProcessFn): void;
/** Add resource destroy function */
registerDestroy(type: RESOURCE_TYPE | string, callback: ResourceProcessFn): void;

@@ -467,6 +226,4 @@ private loadResource;

/** Resource manager single instance */
export declare const resource: Resource;
/** Resource type */
export declare enum RESOURCE_TYPE {

@@ -482,3 +239,2 @@ 'IMAGE' = "IMAGE",

/** Eva resource base */
declare interface ResourceBase {

@@ -502,3 +258,2 @@ name?: string;

/** Resource with entity */
declare interface ResourceStruct extends ResourceBase {

@@ -517,5 +272,2 @@ data?: {

/**
* Scene is a gameObject container
*/
export declare class Scene extends GameObject {

@@ -525,21 +277,7 @@ gameObjects: GameObject[];

constructor(name: any, obj?: TransformParams);
/**
* Add gameObject
* @param gameObject - game object
*/
addGameObject(gameObject: GameObject): void;
/**
* Remove gameObject
* @param gameObject - game object
*/
removeGameObject(gameObject: GameObject): void;
/**
* Destroy scene
*/
destroy(): void;
}
/**
* Two dimensional size
*/
declare interface Size2 {

@@ -550,3 +288,2 @@ width: number;

/** Resource item */
declare interface SrcBase {

@@ -558,89 +295,19 @@ type: string;

/**
* Each System runs continuously and performs global actions on every Entity that possesses a Component of the same aspect as that System.
* @public
*/
export declare class System {
/** System name */
static systemName: string;
name: string;
/**
* The collection of component properties observed by the System. System will respond to these changes
* @example
* ```typescript
* // TestSystem will respond to changes of `size` and `position` property of the Transform component
* class TestSystem extends System {
* static observerInfo = {
* Transform: [{ prop: 'size', deep: true }, { prop: 'position', deep: true }]
* }
* }
* ```
*/
static observerInfo: PureObserverInfo;
/** Component Observer */
componentObserver: ComponentObserver;
/** Game instance */
game: Game;
/** Represents the status of the component, if component has started, the value is true */
started: boolean;
/** Default paramaters for this system */
__systemDefaultParams: any;
constructor(params?: any);
/**
* Called when system is added to a gameObject
* @remarks
* The difference between init and awake is that `init` method recieves params.
* Both of those methods are called early than `start` method.
* Use this method to prepare data, ect.
* @param param - optional params
* @override
*/
init?(param?: any): void;
/**
* Calleen system installed
* @override
*/
awake?(): void;
/**
* Called after all system `awake` method has been called
* @override
*/
start?(): void;
/**
* Called in each tick
* @example
* ```typescript
* // run TWEEN `update` method in main requestAnimationFrame loop
* class TransitionSystem extends System {
* update() {
* TWEEN.update()
* }
* }
* ```
* @param e - info about this tick
* @override
*/
update?(e: UpdateParams): void;
/**
* Called after all system have called the `update` method
* @param e - info about this tick
* @override
*/
lateUpdate?(e: UpdateParams): void;
/**
* Called before game runing or every time game paused
* @override
*/
onResume?(): void;
/**
* Called while the game paused
* @override
*/
onPause?(): void;
/**
* Called while the system be destroyed.
* @override
*/
onDestroy?(): void;
/** Default destory method */
destroy(): void;

@@ -651,43 +318,20 @@ }

/**
* Timeline tool
*/
declare class Ticker {
/** Whether or not ticker should auto start */
autoStart: boolean;
/** FPS, The number of times that raf method is called per second */
frameRate: number;
/** Time between two frame */
private _frameDuration;
/** Ticker is a function will called in each raf */
private _tickers;
/** Block time */
private _blockTime;
/** raf handle id */
_requestId: number;
/** Last frame render time */
private _lastTime;
/** Frame count since from ticker beigning */
private _frameCount;
private _activeWithPause;
/** Main ticker method handle */
private _ticker;
/** Represents the status of the Ticker, If ticker has started, the value is true */
private _started;
/** Last stop time */
private _lastStopTime;
/**
* @param autoStart - auto start game
* @param frameRate - game frame rate
*/
constructor(options?: TickerOptions);
/** Main loop, all _tickers will called in this method */
update(): void;
/** Add ticker function */
add(fn: any): void;
/** Remove ticker function */
remove(fn: any): void;
/** Start main loop */
start(): void;
/** Pause main loop */
pause(): void;

@@ -704,21 +348,9 @@ active(): void;

/** Basic component for gameObject, See {@link TransformParams} */
export declare class Transform extends Component {
/**
* component's name
* @readonly
*/
static componentName: string;
readonly name: string;
private _parent;
/** Whether this transform in a scene object */
inScene: boolean;
/** World coordinate system transformation matrix */
worldTransform: TransformMatrix;
/** Child transform components */
children: Transform[];
/**
* Init component
* @param params - Transform init data
*/
init(params?: TransformParams): void;

@@ -733,28 +365,8 @@ position: Vector2;

set parent(val: Transform);
/**
* Get parent of this component
*/
get parent(): Transform;
/**
* Add Child Transform
* @remarks
* If `child` is already a child of this component, `child` will removed to the last of children list
* If `child` is already a child of other component, `child` will removed from its parent first
* @param child - child gameObject's transform component
*/
addChild(child: Transform): void;
/**
* Remove child transform
* @param child - child gameObject's transform component
*/
removeChild(child: Transform): void;
/** Clear all child transform */
clearChildren(): void;
}
/**
* Radiation transformation martix
*
* {@link https://developer.mozilla.org/zh-CN/docs/Web/CSS/transform-function/matrix() }
*/
declare interface TransformMatrix {

@@ -770,5 +382,2 @@ a: number;

/**
* Transform propterty
*/
export declare interface TransformParams {

@@ -783,17 +392,9 @@ position?: Vector2;

/** frame info pass to `Component.update` method */
export declare interface UpdateParams {
/** delta time from last frame */
deltaTime: number;
/** frame count since game begining */
frameCount: number;
/** current timestamp */
time: number;
/** fps at current frame */
fps: number;
}
/**
* Two dimensional vector
*/
declare interface Vector2 {

@@ -800,0 +401,0 @@ x: number;

2

package.json
{
"name": "@eva/eva.js",
"version": "1.0.5-alpha.1",
"version": "1.0.5-alpha.2",
"description": "@eva/eva.js",

@@ -5,0 +5,0 @@ "main": "index.js",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc