Skip to content

Commit

Permalink
chore: run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
lidongjies committed Aug 9, 2021
1 parent 8453d42 commit 5263dc0
Show file tree
Hide file tree
Showing 176 changed files with 23,908 additions and 22,990 deletions.
3 changes: 1 addition & 2 deletions packages/eva.js/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

# @eva/eva.js

More Introduction

- [EN](https://eva.js.org)
- [中文](https://eva-engine.gitee.io)

8 changes: 2 additions & 6 deletions packages/eva.js/__tests__/__mocks__/requestAnimationFrame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,5 @@ class RequestAnimationFrameMockSession {

export const requestAnimationFrameMock = new RequestAnimationFrameMockSession();

window.requestAnimationFrame = requestAnimationFrameMock.requestAnimationFrame.bind(
requestAnimationFrameMock,
);
window.cancelAnimationFrame = requestAnimationFrameMock.cancelAnimationFrame.bind(
requestAnimationFrameMock,
);
window.requestAnimationFrame = requestAnimationFrameMock.requestAnimationFrame.bind(requestAnimationFrameMock);
window.cancelAnimationFrame = requestAnimationFrameMock.cancelAnimationFrame.bind(requestAnimationFrameMock);
2 changes: 1 addition & 1 deletion packages/eva.js/__tests__/__mocks__/resource-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,4 @@ export class XhrLoadStrategy {
}
}

export class VideoLoadStrategy {}
export class VideoLoadStrategy {}
8 changes: 4 additions & 4 deletions packages/eva.js/__tests__/decorators.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {decorators, System} from '../lib';
import { decorators, System } from '../lib';

const {IDEProp, componentObserver} = decorators;
const { IDEProp, componentObserver } = decorators;

describe('decorators', () => {
it('ide decorator should collect props', () => {
Expand All @@ -19,8 +19,8 @@ describe('decorators', () => {
Transform: [
'size',
['style', 'color'],
{prop: 'position', deep: false},
{prop: ['transform', 'translate'], deep: true},
{ prop: 'position', deep: false },
{ prop: ['transform', 'translate'], deep: true },
],
})
class Test extends System {}
Expand Down
19 changes: 9 additions & 10 deletions packages/eva.js/__tests__/game.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {mocked} from 'ts-jest/utils';
import {Game, Scene, GameObject, System} from '../lib';
import { mocked } from 'ts-jest/utils';
import { Game, Scene, GameObject, System } from '../lib';
import Ticker from '../lib/game/Ticker';
import {TestSystem, Test2System, TestComponent} from '@eva/plugin-renderer-test';
import { TestSystem, Test2System, TestComponent } from '@eva/plugin-renderer-test';

const MockTicker = mocked(Ticker, true);
const mockTickerAdd = jest.fn();
Expand Down Expand Up @@ -75,7 +75,6 @@ describe('Game', () => {
expect(game.systems.length).toBe(2);
expect(game.systems[0]).toBeInstanceOf(TestSystem);
expect(game.systems[1]).toBeInstanceOf(Test2System);

});

it('add system twice', () => {
Expand Down Expand Up @@ -126,7 +125,7 @@ describe('Game', () => {
game.addSystem(testSys);
expect(game.systems.length).toBe(1);
game.removeSystem(testSys);
expect(game.systems.length).toBe(0);
expect(game.systems.length).toBe(0);
});

it('when throug in anything else', () => {
Expand Down Expand Up @@ -162,14 +161,14 @@ describe('Game', () => {
});

it('pause when pausing', () => {
const game = new Game({autoStart: false});
const game = new Game({ autoStart: false });
game.pause();
expect(mockTickerPause).not.toBeCalled();
expect(game.playing).toBeFalsy();
});

it('start', () => {
const game = new Game({autoStart: false});
const game = new Game({ autoStart: false });
game.addSystem(TestSystem);
game.addSystem(Test2System);
game.start();
Expand All @@ -185,7 +184,7 @@ describe('Game', () => {
});

it('resume', () => {
const game = new Game({autoStart: false});
const game = new Game({ autoStart: false });
game.addSystem(TestSystem);
game.addSystem(Test2System);
game.resume();
Expand Down Expand Up @@ -232,7 +231,7 @@ describe('Game', () => {
});

it('trigger pause without scene', () => {
const game = new Game({needScene: false, systems: [new TestSystem(), new Test2System()]});
const game = new Game({ needScene: false, systems: [new TestSystem(), new Test2System()] });
game.triggerPause();
});

Expand All @@ -255,7 +254,7 @@ describe('Game', () => {
});

it('init ticker without scene', () => {
new Game({needScene: false});
new Game({ needScene: false });
const fn = mockTickerAdd.mock.calls[0][0];
fn();
expect(mockTickerAdd).toBeCalled();
Expand Down
12 changes: 5 additions & 7 deletions packages/eva.js/__tests__/gameObject.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describe('GameObject', () => {
expect(child.scene).toBeUndefined();
});

it('do nothing if child\'s parent not this', () => {
it("do nothing if child's parent not this", () => {
const parent = new GameObject('parent');
const parent2 = new GameObject('parent2');
const child = new GameObject('child');
Expand Down Expand Up @@ -203,9 +203,7 @@ describe('GameObject', () => {

it('do nothing when Component.componentName not on gameObject', () => {
const gameObj = new GameObject('gameObj');
expect(
gameObj.removeComponent(TestComponent.componentName),
).toBeUndefined();
expect(gameObj.removeComponent(TestComponent.componentName)).toBeUndefined();
expect(gameObj.components.length).toBe(1);
});

Expand All @@ -226,15 +224,15 @@ describe('GameObject', () => {
const gameObj = new GameObject('gameObj');
expect(() => {
gameObj.removeComponent('Transform');
}).toThrow('Transform can\'t be removed');
}).toThrow("Transform can't be removed");

expect(() => {
gameObj.removeComponent(Transform.componentName);
}).toThrow('Transform can\'t be removed');
}).toThrow("Transform can't be removed");

expect(() => {
gameObj.removeComponent(gameObj.transform.name);
}).toThrow('Transform can\'t be removed');
}).toThrow("Transform can't be removed");
});

it('getComponent by componentName', () => {
Expand Down
31 changes: 12 additions & 19 deletions packages/eva.js/__tests__/observer.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {TestSystem, TestComponent} from '@eva/plugin-renderer-test';
import {GameObject, Transform} from '../lib';
import { TestSystem, TestComponent } from '@eva/plugin-renderer-test';
import { GameObject, Transform } from '../lib';
import {
initObserver,
setSystemObserver,
Expand Down Expand Up @@ -30,14 +30,9 @@ describe('observer', () => {
it('initObserver successfully', () => {
initObserver([TestSystem]);

const {
componentProps,
systemInstance,
observerInfos,
} = testUtils.getLocal();
const { componentProps, systemInstance, observerInfos } = testUtils.getLocal();

const observerKeyCount = Object.keys(TestSystem.observerInfo['Test'])
.length;
const observerKeyCount = Object.keys(TestSystem.observerInfo['Test']).length;
expect(componentProps['Test'].length).toBe(observerKeyCount);
expect(systemInstance['Test']).toStrictEqual(system);
expect(observerInfos['Test']).toStrictEqual(TestSystem.observerInfo);
Expand All @@ -52,7 +47,7 @@ describe('observer', () => {
observer(testComp, testComp.name);

expect(testComp['_size']).toEqual([10, 10]);
expect(testComp['_style']).toMatchObject({color: 'rgba(255, 255, 255)'});
expect(testComp['_style']).toMatchObject({ color: 'rgba(255, 255, 255)' });
expect(system.componentObserver.add).toHaveBeenCalledTimes(1);

const size = [20, 20];
Expand All @@ -77,11 +72,11 @@ describe('observer', () => {
const gameObj = new GameObject('gameObj');
gameObj.addComponent(testComp);

TestSystem.observerInfo['Test'].push({prop: ['transform'], deep: false});
TestSystem.observerInfo['Test'].push({ prop: ['transform'], deep: false });
initObserver(TestSystem);
observer(testComp, testComp.name);

const {componentProps} = testUtils.getLocal();
const { componentProps } = testUtils.getLocal();
expect(componentProps['Test']).toContainEqual({
prop: ['transform'],
deep: false,
Expand All @@ -103,7 +98,7 @@ describe('observer', () => {
});

it('should throw error when component not instanceof Component', () => {
const comp: any = {name: 'Test', size: [15, 15]};
const comp: any = { name: 'Test', size: [15, 15] };
expect(() => {
observer(comp);
}).toThrow('component param must be an instance of Component');
Expand Down Expand Up @@ -174,12 +169,10 @@ describe('observer', () => {
const testComp = new TestComponent();
gameObj.addComponent(testComp);

const {objectCache} = testUtils.getLocal();
const { objectCache } = testUtils.getLocal();
expect(objectCache[gameObj.id]).toHaveProperty('Test_size');
expect(objectCache[gameObj.id]).toHaveProperty('Test_style');
expect(objectCache[gameObj.id]).toHaveProperty(
'Test_geomerty,data,vertex',
);
expect(objectCache[gameObj.id]).toHaveProperty('Test_geomerty,data,vertex');

observerRemoved(testComp);
expect(objectCache[gameObj.id]).toBeUndefined();
Expand All @@ -194,13 +187,13 @@ describe('observer', () => {
it('observer add component is null', () => {
expect(() => {
observerRemoved(null, TestComponent.componentName);
}).toThrow('Cannot read property \'gameObject\' of null');
}).toThrow("Cannot read property 'gameObject' of null");
});

it('component is undefined', () => {
expect(() => {
observerRemoved(undefined, TestComponent.componentName);
}).toThrow('Cannot read property \'gameObject\' of undefined');
}).toThrow("Cannot read property 'gameObject' of undefined");
});

it('componentName is empty', () => {
Expand Down
21 changes: 9 additions & 12 deletions packages/eva.js/__tests__/resource.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe('resource management', () => {
res.on(LOAD_EVENT.COMPLETE, () => {
expect(checkResourceSpy).toHaveBeenCalledTimes(1);
done();
})
});
res.loadConfig([imageRes]);
});

Expand All @@ -79,24 +79,24 @@ describe('resource management', () => {
});

it('preload without resource', done => {
res.on(LOAD_EVENT.COMPLETE, (loader) => {
res.on(LOAD_EVENT.COMPLETE, loader => {
expect(loader.resourceTotal).toBe(0);
done()
})
done();
});
res.preload();
});

it('preload with resources', done => {
const progressSpy = jest.fn();
res.on(LOAD_EVENT.PROGRESS, progressSpy);
res.on(LOAD_EVENT.COMPLETE, (loader) => {
res.on(LOAD_EVENT.COMPLETE, loader => {
expect(progressSpy).toBeCalledTimes(2);
expect(loader.resourceTotal).toBe(2);
done();
})
});
res.addResource([imageRes, imageRes2]);
res.preload();
})
});

/**
* 连续触发两次 preload,会导致 resourceManager 的 progress 属性被覆盖
Expand All @@ -105,10 +105,7 @@ describe('resource management', () => {
res.loadConfig([imageRes]);
res.loadConfig([imageRes2]);

const [image, dragonBone] = await Promise.all([
res.getResource(imageRes.name),
res.getResource(imageRes2.name),
]);
const [image, dragonBone] = await Promise.all([res.getResource(imageRes.name), res.getResource(imageRes2.name)]);

expect(image).toMatchObject({});
expect(dragonBone).toMatchObject({});
Expand Down Expand Up @@ -171,7 +168,7 @@ describe('resource management', () => {
res.on(LOAD_EVENT.COMPLETE, () => {
expect(imageInstanceCallback).toHaveBeenCalled();
done();
})
});
res.loadConfig([imageRes]);
});

Expand Down
2 changes: 1 addition & 1 deletion packages/eva.js/__tests__/scene.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Scene, Transform, GameObject} from '../lib';
import { Scene, Transform, GameObject } from '../lib';

describe('Scene', () => {
it('create scene', () => {
Expand Down
12 changes: 6 additions & 6 deletions packages/eva.js/__tests__/utils/resources.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {RESOURCE_TYPE} from '../../lib';
import { RESOURCE_TYPE } from '../../lib';

export interface EVAResourceParams {
name: string;
Expand All @@ -16,7 +16,7 @@ type EVAResourceObject = Record<string, any>;

export class EVADataRes {
static from(options: Partial<EVAResourceParams>): EVAResourceObject {
const {name, data} = options;
const { name, data } = options;
return {
name,
type: 'data',
Expand All @@ -32,7 +32,7 @@ export class EVADataRes {

export class EVADragonBone {
static from(options: Partial<EVAResourceParams>): EVAResourceObject {
const {name, preload, image, imageType = 'png', ske, tex} = options;
const { name, preload, image, imageType = 'png', ske, tex } = options;
return {
name,
type: RESOURCE_TYPE.DRAGONBONE,
Expand All @@ -57,7 +57,7 @@ export class EVADragonBone {

export class EVAImage {
static from(options: Partial<EVAResourceParams>): EVAResourceObject {
const {name, image, preload, imageType = 'png'} = options;
const { name, image, preload, imageType = 'png' } = options;
return {
name,
preload,
Expand All @@ -74,7 +74,7 @@ export class EVAImage {

export class EVASprite {
static from(options: Partial<EVAResourceParams>): EVAResourceObject {
const {name, image, json, preload, imageType = 'png'} = options;
const { name, image, json, preload, imageType = 'png' } = options;
return {
name,
preload,
Expand All @@ -95,7 +95,7 @@ export class EVASprite {

export class EVASpriteAnimation {
static from(options: Partial<EVAResourceParams>): EVAResourceObject {
const {name, image, json, preload, imageType = 'png'} = options;
const { name, image, json, preload, imageType = 'png' } = options;
return {
name,
preload,
Expand Down
2 changes: 1 addition & 1 deletion packages/eva.js/api-extractor.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"dtsRollup": {
"publicTrimmedFilePath": "./dist/eva.js.d.ts"
}
}
}
6 changes: 3 additions & 3 deletions packages/eva.js/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'
'use strict';

if (process.env.NODE_ENV === 'production') {
module.exports = require('./dist/eva.js.cjs.prod.js')
module.exports = require('./dist/eva.js.cjs.prod.js');
} else {
module.exports = require('./dist/eva.js.cjs.js')
module.exports = require('./dist/eva.js.cjs.js');
}
Loading

0 comments on commit 5263dc0

Please sign in to comment.