From f7466994c571e721578787d71a7dfc243af6838d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 15 Jul 2020 23:44:01 +0200 Subject: [PATCH 001/122] Playing with pipeline to display outline --- front/src/Phaser/Items/ActionableItem.ts | 0 front/src/Phaser/Items/ActionableSprite.ts | 0 front/src/Phaser/Player/Player.ts | 5 ++ front/src/Phaser/Shaders/OutlinePipeline.ts | 61 ++++++++++++++++++++ front/src/index.ts | 9 +++ maps/objects/computer.ts | 0 maps/package.json | 63 +++++++++++++++++++++ maps/tsconfig.json | 24 ++++++++ 8 files changed, 162 insertions(+) create mode 100644 front/src/Phaser/Items/ActionableItem.ts create mode 100644 front/src/Phaser/Items/ActionableSprite.ts create mode 100644 front/src/Phaser/Shaders/OutlinePipeline.ts create mode 100644 maps/objects/computer.ts create mode 100644 maps/package.json create mode 100644 maps/tsconfig.json diff --git a/front/src/Phaser/Items/ActionableItem.ts b/front/src/Phaser/Items/ActionableItem.ts new file mode 100644 index 00000000..e69de29b diff --git a/front/src/Phaser/Items/ActionableSprite.ts b/front/src/Phaser/Items/ActionableSprite.ts new file mode 100644 index 00000000..e69de29b diff --git a/front/src/Phaser/Player/Player.ts b/front/src/Phaser/Player/Player.ts index f912d110..1a3a3a03 100644 --- a/front/src/Phaser/Player/Player.ts +++ b/front/src/Phaser/Player/Player.ts @@ -3,6 +3,7 @@ import {GameScene, Textures} from "../Game/GameScene"; import {MessageUserPositionInterface, PointInterface} from "../../Connection"; import {ActiveEventList, UserInputEvent, UserInputManager} from "../UserInput/UserInputManager"; import {Character} from "../Entity/Character"; +import {OutlinePipeline} from "../Shaders/OutlinePipeline"; export const hasMovedEventName = "hasMoved"; @@ -32,6 +33,10 @@ export class Player extends Character implements CurrentGamerInterface { //the current player model should be push away by other players to prevent conflict this.setImmovable(false); + + this.setPipeline(OutlinePipeline.KEY); + this.pipeline.setFloat2('uTextureSize', + this.texture.getSourceImage().width, this.texture.getSourceImage().height); } moveUser(delta: number): void { diff --git a/front/src/Phaser/Shaders/OutlinePipeline.ts b/front/src/Phaser/Shaders/OutlinePipeline.ts new file mode 100644 index 00000000..f65a66d2 --- /dev/null +++ b/front/src/Phaser/Shaders/OutlinePipeline.ts @@ -0,0 +1,61 @@ +export class OutlinePipeline extends Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline +{ + + // the unique id of this pipeline + public static readonly KEY = 'Outline'; + + /** + * @param {Phaser.Game} game - the controller of the game instance + */ + constructor(game: Phaser.Game) + { + super({ + game: game, + renderer: game.renderer, + fragShader: ` + precision mediump float; + + uniform sampler2D uMainSampler; + uniform vec2 uTextureSize; + + varying vec2 outTexCoord; + varying float outTintEffect; + varying vec4 outTint; + + void main(void) + { + vec4 texture = texture2D(uMainSampler, outTexCoord); + vec4 texel = vec4(outTint.rgb * outTint.a, outTint.a); + vec4 color = texture; + + if (outTintEffect == 0.0) + { + color = texture * texel; + } + else if (outTintEffect == 1.0) + { + color.rgb = mix(texture.rgb, outTint.rgb * outTint.a, texture.a); + color.a = texture.a * texel.a; + } + else if (outTintEffect == 2.0) + { + color = texel; + } + + vec2 onePixel = vec2(1.0, 1.0) / uTextureSize; + float upAlpha = texture2D(uMainSampler, outTexCoord + vec2(0.0, onePixel.y)).a; + float leftAlpha = texture2D(uMainSampler, outTexCoord + vec2(-onePixel.x, 0.0)).a; + float downAlpha = texture2D(uMainSampler, outTexCoord + vec2(0.0, -onePixel.y)).a; + float rightAlpha = texture2D(uMainSampler, outTexCoord + vec2(onePixel.x, 0.0)).a; + + if (texture.a == 0.0 && max(max(upAlpha, downAlpha), max(leftAlpha, rightAlpha)) == 1.0) + { + color = vec4(1.0, 1.0, 1.0, 1.0); + } + + gl_FragColor = color; + } + ` + }); + } +} diff --git a/front/src/index.ts b/front/src/index.ts index eb63b6d0..b847fa74 100644 --- a/front/src/index.ts +++ b/front/src/index.ts @@ -8,6 +8,8 @@ import {gameManager} from "./Phaser/Game/GameManager"; import {SelectCharacterScene} from "./Phaser/Login/SelectCharacterScene"; import {EnableCameraScene} from "./Phaser/Login/EnableCameraScene"; import {FourOFourScene} from "./Phaser/Reconnecting/FourOFourScene"; +import WebGLRenderer = Phaser.Renderer.WebGL.WebGLRenderer; +import {OutlinePipeline} from "./Phaser/Shaders/OutlinePipeline"; const config: GameConfig = { title: "Office game", @@ -21,6 +23,13 @@ const config: GameConfig = { arcade: { debug: DEBUG_MODE } + }, + callbacks: { + postBoot: game => { + // FIXME: we should fore WebGL in the config. + let renderer = game.renderer as WebGLRenderer; + renderer.addPipeline(OutlinePipeline.KEY, new OutlinePipeline(game)); + } } }; diff --git a/maps/objects/computer.ts b/maps/objects/computer.ts new file mode 100644 index 00000000..e69de29b diff --git a/maps/package.json b/maps/package.json new file mode 100644 index 00000000..a20c876f --- /dev/null +++ b/maps/package.json @@ -0,0 +1,63 @@ +{ + "name": "workadventureback", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "tsc": "tsc", + "dev": "ts-node-dev --respawn --transpileOnly ./server.ts", + "prod": "tsc && node ./dist/server.js", + "profile": "tsc && node --prof ./dist/server.js", + "test": "ts-node node_modules/jasmine/bin/jasmine --config=jasmine.json", + "lint": "node_modules/.bin/eslint src/ . --ext .ts", + "fix": "node_modules/.bin/eslint --fix src/ . --ext .ts" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/thecodingmachine/workadventure.git" + }, + "contributors": [ + { + "name": "Grégoire Parant", + "email": "g.parant@thecodingmachine.com" + }, + { + "name": "David Négrier", + "email": "d.negrier@thecodingmachine.com" + }, + { + "name": "Arthmaël Poly", + "email": "a.poly@thecodingmachine.com" + } + ], + "license": "SEE LICENSE IN LICENSE.txt", + "bugs": { + "url": "https://github.com/thecodingmachine/workadventure/issues" + }, + "homepage": "https://github.com/thecodingmachine/workadventure#readme", + "dependencies": { + "@types/express": "^4.17.4", + "@types/http-status-codes": "^1.2.0", + "@types/jsonwebtoken": "^8.3.8", + "@types/socket.io": "^2.1.4", + "@types/uuidv4": "^5.0.0", + "body-parser": "^1.19.0", + "express": "^4.17.1", + "generic-type-guard": "^3.2.0", + "http-status-codes": "^1.4.0", + "jsonwebtoken": "^8.5.1", + "prom-client": "^12.0.0", + "socket.io": "^2.3.0", + "systeminformation": "^4.26.5", + "ts-node-dev": "^1.0.0-pre.44", + "typescript": "^3.8.3", + "uuidv4": "^6.0.7" + }, + "devDependencies": { + "@types/jasmine": "^3.5.10", + "@typescript-eslint/eslint-plugin": "^2.26.0", + "@typescript-eslint/parser": "^2.26.0", + "eslint": "^6.8.0", + "jasmine": "^3.5.0" + } +} diff --git a/maps/tsconfig.json b/maps/tsconfig.json new file mode 100644 index 00000000..9a140744 --- /dev/null +++ b/maps/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "outDir": "./dist/", + "sourceMap": true, + "moduleResolution": "node", + "module": "ESNext", + "target": "ES2015", + "downlevelIteration": true, + "jsx": "react", + "allowJs": true, + + "strict": false, /* Enable all strict type-checking options. */ + "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ + "strictNullChecks": true, /* Enable strict null checks. */ + "strictFunctionTypes": true, /* Enable strict checking of function types. */ + "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ + "strictPropertyInitialization": false, /* Enable strict checking of property initialization in classes. */ + "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + + "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + "noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */ + } +} From ed146226cffba914fb0418676b7ef8c95d2ac871 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 23 Jul 2020 18:09:24 +0200 Subject: [PATCH 002/122] Adding Outline capabilities and a ActionableItem notion. --- back/src/Assets/Maps/Floor0/floor0.json | 16 +- docker-compose.yaml | 22 +++ front/package.json | 3 +- front/src/Phaser/Game/GameScene.ts | 141 +++++++++++++++++- front/src/Phaser/Items/ActionableItem.ts | 60 ++++++++ front/src/Phaser/Items/ActionableSprite.ts | 0 front/src/Phaser/Items/Computer/computer.ts | 24 +++ .../src/Phaser/Items/ItemFactoryInterface.ts | 10 ++ front/src/Phaser/Player/Player.ts | 4 - front/src/Phaser/Shaders/OutlinePipeline.ts | 2 +- .../src/Phaser/UserInput/UserInputManager.ts | 1 + front/tsconfig.json | 5 +- front/webpack.config.js | 3 + front/yarn.lock | 29 +++- maps/.gitignore | 1 + maps/dist/.htaccess | 1 + maps/objects/computer.ts | 56 +++++++ maps/package.json | 24 +-- 18 files changed, 369 insertions(+), 33 deletions(-) delete mode 100644 front/src/Phaser/Items/ActionableSprite.ts create mode 100644 front/src/Phaser/Items/Computer/computer.ts create mode 100644 front/src/Phaser/Items/ItemFactoryInterface.ts create mode 100644 maps/.gitignore create mode 100644 maps/dist/.htaccess diff --git a/back/src/Assets/Maps/Floor0/floor0.json b/back/src/Assets/Maps/Floor0/floor0.json index 987004e6..94a215b3 100644 --- a/back/src/Assets/Maps/Floor0/floor0.json +++ b/back/src/Assets/Maps/Floor0/floor0.json @@ -199,7 +199,19 @@ "draworder":"topdown", "id":3, "name":"floorLayer", - "objects":[], + "objects":[ + { + "height":0, + "id":1, + "name":"computer", + "point":true, + "rotation":0, + "type":"computer", + "visible":true, + "width":0, + "x":431, + "y":142 + }], "opacity":1, "type":"objectgroup", "visible":true, @@ -225,7 +237,7 @@ "y":0 }], "nextlayerid":18, - "nextobjectid":1, + "nextobjectid":2, "orientation":"orthogonal", "renderorder":"right-down", "tiledversion":"1.3.3", diff --git a/docker-compose.yaml b/docker-compose.yaml index 74bbafbf..53208c76 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -38,6 +38,28 @@ services: - "traefik.http.routers.front-ssl.tls=true" - "traefik.http.routers.front-ssl.service=front" + maps: + image: thecodingmachine/nodejs:12-apache + environment: + DEBUG_MODE: "$DEBUG_MODE" + HOST: "0.0.0.0" + NODE_ENV: development + APACHE_DOCUMENT_ROOT: dist/ + #APACHE_EXTENSIONS: headers + #APACHE_EXTENSION_HEADERS: 1 + STARTUP_COMMAND_0: sudo a2enmod headers + STARTUP_COMMAND_1: yarn install + STARTUP_COMMAND_2: yarn run dev & + volumes: + - ./maps:/var/www/html + labels: + - "traefik.http.routers.maps.rule=Host(`maps.workadventure.localhost`)" + - "traefik.http.routers.maps.entryPoints=web,traefik" + - "traefik.http.services.maps.loadbalancer.server.port=80" + - "traefik.http.routers.maps-ssl.rule=Host(`maps.workadventure.localhost`)" + - "traefik.http.routers.maps-ssl.entryPoints=websecure" + - "traefik.http.routers.maps-ssl.tls=true" + - "traefik.http.routers.maps-ssl.service=maps" back: image: thecodingmachine/nodejs:12 diff --git a/front/package.json b/front/package.json index b0c5502b..e5ea5b66 100644 --- a/front/package.json +++ b/front/package.json @@ -25,7 +25,8 @@ "phaser": "^3.22.0", "queue-typescript": "^1.0.1", "simple-peer": "^9.6.2", - "socket.io-client": "^2.3.0" + "socket.io-client": "^2.3.0", + "webpack-require-http": "^0.4.3" }, "scripts": { "start": "webpack-dev-server --open", diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index a46672ee..6d311e33 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -10,7 +10,7 @@ import { DEBUG_MODE, ZOOM_LEVEL, POSITION_DELAY } from "../../Enum/EnvironmentVa import { ITiledMap, ITiledMapLayer, - ITiledMapLayerProperty, + ITiledMapLayerProperty, ITiledMapObject, ITiledTileSet } from "../Map/ITiledMap"; import {PLAYER_RESOURCES, PlayerResourceDescriptionInterface} from "../Entity/Character"; @@ -28,6 +28,8 @@ import {SimplePeer} from "../../WebRtc/SimplePeer"; import {ReconnectingSceneName} from "../Reconnecting/ReconnectingScene"; import FILE_LOAD_ERROR = Phaser.Loader.Events.FILE_LOAD_ERROR; import {FourOFourSceneName} from "../Reconnecting/FourOFourScene"; +import {ItemFactoryInterface} from "../Items/ItemFactoryInterface"; +import {ActionableItem} from "../Items/ActionableItem"; export enum Textures { @@ -89,6 +91,9 @@ export class GameScene extends Phaser.Scene { private connection: Connection; private simplePeer : SimplePeer; private connectionPromise: Promise + // A promise that will resolve when the "create" method is called (signaling loading is ended) + private createPromise: Promise; + private createPromiseResolve: (value?: void | PromiseLike) => void; MapKey: string; MapUrlFile: string; @@ -106,6 +111,9 @@ export class GameScene extends Phaser.Scene { private PositionNextScene: Array> = new Array>(); private startLayerName: string|undefined; + private actionableItems: Array = new Array(); + // The item that can be selected by pressing the space key. + private outlinedItem: ActionableItem|null = null; static createFromUrl(mapUrlFile: string, instance: string, key: string|null = null): GameScene { const mapKey = GameScene.getMapKeyByUrl(mapUrlFile); @@ -128,6 +136,10 @@ export class GameScene extends Phaser.Scene { this.MapKey = MapKey; this.MapUrlFile = MapUrlFile; this.RoomId = this.instance + '__' + MapKey; + + this.createPromise = new Promise((resolve, reject): void => { + this.createPromiseResolve = resolve; + }) } //hook preload scene @@ -225,7 +237,7 @@ export class GameScene extends Phaser.Scene { // FIXME: we need to put a "unknown" instead of a "any" and validate the structure of the JSON we are receiving. // eslint-disable-next-line @typescript-eslint/no-explicit-any - private onMapLoad(data: any): void { + private async onMapLoad(data: any): Promise { // Triggered when the map is loaded // Load tiles attached to the map recursively this.mapFile = data.data; @@ -238,6 +250,85 @@ export class GameScene extends Phaser.Scene { //TODO strategy to add access token this.load.image(`${url}/${tileset.image}`, `${url}/${tileset.image}`); }) + + // Scan the object layers for objects to load and load them. + let objects = new Map(); + + for (let layer of this.mapFile.layers) { + if (layer.type === 'objectgroup') { + for (let object of layer.objects) { + let objectsOfType: ITiledMapObject[]|undefined; + if (!objects.has(object.type)) { + objectsOfType = new Array(); + } else { + objectsOfType = objects.get(object.type); + if (objectsOfType === undefined) { + throw new Error('Unexpected object type not found'); + } + } + objectsOfType.push(object); + objects.set(object.type, objectsOfType); + } + } + } + + for (let [itemType, objectsOfType] of objects) { + // FIXME: we would ideally need for the loader to WAIT for the import to be performed, which means writing our own loader plugin. + + let itemFactory: ItemFactoryInterface; + + switch (itemType) { + case 'computer': + let module = await import('../Items/Computer/computer'); + itemFactory = module.default as ItemFactoryInterface; + break; + default: + throw new Error('Unsupported object type: "'+ itemType +'"'); + } + + itemFactory.preload(this.load); + this.load.start(); // Let's manually start the loader because the import might be over AFTER the loading ends. + + this.load.on('complete', () => { + // FIXME: the factory might fail because the resources might not be loaded yet... + // We would need to add a loader ended event in addition to the createPromise + this.createPromise.then(() => { + itemFactory.create(this); + + for (let object of objectsOfType) { + // TODO: we should pass here a factory to create sprites (maybe?) + let actionableItem = itemFactory.factory(this, object); + this.actionableItems.push(actionableItem); + } + }); + }); + + // import(/* webpackIgnore: true */ scriptUrl).then(result => { + // + // result.default.preload(this.load); + // + // this.load.start(); // Let's manually start the loader because the import might be over AFTER the loading ends. + // this.load.on('complete', () => { + // // FIXME: the factory might fail because the resources might not be loaded yet... + // // We would need to add a loader ended event in addition to the createPromise + // this.createPromise.then(() => { + // result.default.create(this); + // + // for (let object of objectsOfType) { + // // TODO: we should pass here a factory to create sprites (maybe?) + // let objectSprite = result.default.factory(this, object); + // } + // }); + // }); + // }); + } + + // TEST: let's load a module dynamically! + /*let foo = "http://maps.workadventure.localhost/computer.js"; + import(/* webpackIgnore: true * / foo).then(result => { + console.log(result); + + });*/ } //hook initialisation @@ -361,6 +452,8 @@ export class GameScene extends Phaser.Scene { } }, 500); } + + this.createPromiseResolve(); } private getExitSceneUrl(layer: ITiledMapLayer): string|undefined { @@ -526,6 +619,7 @@ export class GameScene extends Phaser.Scene { //listen event to share position of user this.CurrentPlayer.on(hasMovedEventName, this.pushPlayerPosition.bind(this)) + this.CurrentPlayer.on(hasMovedEventName, this.outlineItem.bind(this)) }); } @@ -555,6 +649,49 @@ export class GameScene extends Phaser.Scene { // Otherwise, do nothing. } + /** + * Finds the correct item to outline and outline it (if there is an item to be outlined) + * @param event + */ + private outlineItem(event: HasMovedEvent): void { + let x = event.x; + let y = event.y; + switch (event.direction) { + case PlayerAnimationNames.WalkUp: + y -= 32; + break; + case PlayerAnimationNames.WalkDown: + y += 32; + break; + case PlayerAnimationNames.WalkLeft: + x -= 32; + break; + case PlayerAnimationNames.WalkRight: + x += 32; + break; + default: + throw new Error('Unexpected direction "' + event.direction + '"'); + } + + let shortestDistance: number = Infinity; + let selectedItem: ActionableItem|null = null; + for (let item of this.actionableItems) { + let distance = item.actionableDistance(x, y); + if (distance !== null && distance < shortestDistance) { + shortestDistance = distance; + selectedItem = item; + } + } + + if (this.outlinedItem === selectedItem) { + return; + } + + this.outlinedItem?.notSelectable(); + this.outlinedItem = selectedItem; + this.outlinedItem?.selectable(); + } + private doPushPlayerPosition(event: HasMovedEvent): void { this.lastMoveEventSent = event; this.lastSentTick = this.currentTick; diff --git a/front/src/Phaser/Items/ActionableItem.ts b/front/src/Phaser/Items/ActionableItem.ts index e69de29b..229b0888 100644 --- a/front/src/Phaser/Items/ActionableItem.ts +++ b/front/src/Phaser/Items/ActionableItem.ts @@ -0,0 +1,60 @@ +/** + * An actionable item represents an in-game object that can be activated using the space-bar. + * It has coordinates and an "activation radius" + */ +import Sprite = Phaser.GameObjects.Sprite; +import {OutlinePipeline} from "../Shaders/OutlinePipeline"; + +export class ActionableItem { + private readonly activationRadiusSquared : number; + private isSelectable: boolean = false; + + public constructor(private sprite: Sprite, private activationRadius: number) { + this.activationRadiusSquared = activationRadius * activationRadius; + } + + /** + * Returns the square of the distance to the object center IF we are in item action range + * OR null if we are out of range. + */ + public actionableDistance(x: number, y: number): number|null { + let distanceSquared = (x - this.sprite.x)*(x - this.sprite.x) + (y - this.sprite.y)*(y - this.sprite.y); + if (distanceSquared < this.activationRadiusSquared) { + return distanceSquared; + } else { + return null; + } + } + + /** + * Show the outline of the sprite. + */ + public selectable(): void { + if (this.isSelectable) { + return; + } + this.isSelectable = true; + this.sprite.setPipeline(OutlinePipeline.KEY); + this.sprite.pipeline.setFloat2('uTextureSize', + this.sprite.texture.getSourceImage().width, this.sprite.texture.getSourceImage().height); + } + + /** + * Hide the outline of the sprite + */ + public notSelectable(): void { + if (!this.isSelectable) { + return; + } + this.isSelectable = false; + this.sprite.resetPipeline(); + } + + /** + * Triggered when the "space" key is pressed and the object is in range of being activated. + */ + public activate(): void { + + } +} + diff --git a/front/src/Phaser/Items/ActionableSprite.ts b/front/src/Phaser/Items/ActionableSprite.ts deleted file mode 100644 index e69de29b..00000000 diff --git a/front/src/Phaser/Items/Computer/computer.ts b/front/src/Phaser/Items/Computer/computer.ts new file mode 100644 index 00000000..99eddbb7 --- /dev/null +++ b/front/src/Phaser/Items/Computer/computer.ts @@ -0,0 +1,24 @@ +import * as Phaser from 'phaser'; +import {Scene} from "phaser"; +import Sprite = Phaser.GameObjects.Sprite; +import {ITiledMapObject} from "../../Map/ITiledMap"; +import {ItemFactoryInterface} from "../ItemFactoryInterface"; +import {GameScene} from "../../Game/GameScene"; +import {ActionableItem} from "../ActionableItem"; + +export default { + preload: (loader: Phaser.Loader.LoaderPlugin): void => { + loader.atlas('computer', 'http://maps.workadventure.localhost/computer/computer.png', 'http://maps.workadventure.localhost/computer/computer_atlas.json'); + }, + create: (scene: GameScene): void => { + + }, + factory: (scene: GameScene, object: ITiledMapObject): ActionableItem => { + // Idée: ESSAYER WebPack? https://paultavares.wordpress.com/2018/07/02/webpack-how-to-generate-an-es-module-bundle/ + let foo = new Sprite(scene, object.x, object.y, 'computer'); + scene.add.existing(foo); + + return new ActionableItem(foo, 32); + //scene.add.sprite(object.x, object.y, 'computer'); + } +} as ItemFactoryInterface; diff --git a/front/src/Phaser/Items/ItemFactoryInterface.ts b/front/src/Phaser/Items/ItemFactoryInterface.ts new file mode 100644 index 00000000..0f88f76b --- /dev/null +++ b/front/src/Phaser/Items/ItemFactoryInterface.ts @@ -0,0 +1,10 @@ +import LoaderPlugin = Phaser.Loader.LoaderPlugin; +import {GameScene} from "../Game/GameScene"; +import {ITiledMapObject} from "../Map/ITiledMap"; +import {ActionableItem} from "./ActionableItem"; + +export interface ItemFactoryInterface { + preload: (loader: LoaderPlugin) => void; + create: (scene: GameScene) => void; + factory: (scene: GameScene, object: ITiledMapObject) => ActionableItem; +} diff --git a/front/src/Phaser/Player/Player.ts b/front/src/Phaser/Player/Player.ts index 1a3a3a03..64adc246 100644 --- a/front/src/Phaser/Player/Player.ts +++ b/front/src/Phaser/Player/Player.ts @@ -33,10 +33,6 @@ export class Player extends Character implements CurrentGamerInterface { //the current player model should be push away by other players to prevent conflict this.setImmovable(false); - - this.setPipeline(OutlinePipeline.KEY); - this.pipeline.setFloat2('uTextureSize', - this.texture.getSourceImage().width, this.texture.getSourceImage().height); } moveUser(delta: number): void { diff --git a/front/src/Phaser/Shaders/OutlinePipeline.ts b/front/src/Phaser/Shaders/OutlinePipeline.ts index f65a66d2..6b416b8a 100644 --- a/front/src/Phaser/Shaders/OutlinePipeline.ts +++ b/front/src/Phaser/Shaders/OutlinePipeline.ts @@ -50,7 +50,7 @@ export class OutlinePipeline extends Phaser.Renderer.WebGL.Pipelines.TextureTint if (texture.a == 0.0 && max(max(upAlpha, downAlpha), max(leftAlpha, rightAlpha)) == 1.0) { - color = vec4(1.0, 1.0, 1.0, 1.0); + color = vec4(1.0, 1.0, 0.0, 1.0); } gl_FragColor = color; diff --git a/front/src/Phaser/UserInput/UserInputManager.ts b/front/src/Phaser/UserInput/UserInputManager.ts index eddbbf74..d40d149e 100644 --- a/front/src/Phaser/UserInput/UserInputManager.ts +++ b/front/src/Phaser/UserInput/UserInputManager.ts @@ -47,6 +47,7 @@ export class UserInputManager { {event: UserInputEvent.SpeedUp, keyInstance: Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SHIFT) }, {event: UserInputEvent.Interact, keyInstance: Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.E) }, + {event: UserInputEvent.Interact, keyInstance: Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE) }, {event: UserInputEvent.Shout, keyInstance: Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.F) }, ]; } diff --git a/front/tsconfig.json b/front/tsconfig.json index 1661efa2..9a140744 100644 --- a/front/tsconfig.json +++ b/front/tsconfig.json @@ -3,9 +3,8 @@ "outDir": "./dist/", "sourceMap": true, "moduleResolution": "node", - "noImplicitAny": true, - "module": "CommonJS", - "target": "es5", + "module": "ESNext", + "target": "ES2015", "downlevelIteration": true, "jsx": "react", "allowJs": true, diff --git a/front/webpack.config.js b/front/webpack.config.js index e162b4f8..68b1bc7e 100644 --- a/front/webpack.config.js +++ b/front/webpack.config.js @@ -33,6 +33,9 @@ module.exports = { path: path.resolve(__dirname, 'dist'), publicPath: '/' }, + externals:[ + require('webpack-require-http') + ], plugins: [ new HtmlWebpackPlugin( { diff --git a/front/yarn.lock b/front/yarn.lock index 05e9b368..b943ebf0 100644 --- a/front/yarn.lock +++ b/front/yarn.lock @@ -801,6 +801,11 @@ chardet@^0.7.0: resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e" integrity sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA== +charenc@~0.0.1: + version "0.0.2" + resolved "https://registry.yarnpkg.com/charenc/-/charenc-0.0.2.tgz#c0a1d2f3a7092e03774bfa83f14c0fc5790a8667" + integrity sha1-wKHS86cJLgN3S/qD8UwPxXkKhmc= + chokidar@^2.1.8: version "2.1.8" resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-2.1.8.tgz#804b3a7b6a99358c3c5c61e71d8728f041cff917" @@ -1063,6 +1068,11 @@ cross-spawn@6.0.5, cross-spawn@^6.0.0, cross-spawn@^6.0.5: shebang-command "^1.2.0" which "^1.2.9" +crypt@~0.0.1: + version "0.0.2" + resolved "https://registry.yarnpkg.com/crypt/-/crypt-0.0.2.tgz#88d7ff7ec0dfb86f713dc87bbb42d044d3e6c41b" + integrity sha1-iNf/fsDfuG9xPch7u0LQRNPmxBs= + crypto-browserify@^3.11.0: version "3.12.0" resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.12.0.tgz#396cf9f3137f03e4b8e532c58f698254e00f80ec" @@ -2350,7 +2360,7 @@ is-binary-path@^1.0.0: dependencies: binary-extensions "^1.0.0" -is-buffer@^1.1.5: +is-buffer@^1.1.5, is-buffer@~1.1.1: version "1.1.6" resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" @@ -2691,6 +2701,15 @@ md5.js@^1.3.4: inherits "^2.0.1" safe-buffer "^5.1.2" +md5@^2.0.0: + version "2.2.1" + resolved "https://registry.yarnpkg.com/md5/-/md5-2.2.1.tgz#53ab38d5fe3c8891ba465329ea23fac0540126f9" + integrity sha1-U6s41f48iJG6RlMp6iP6wFQBJvk= + dependencies: + charenc "~0.0.1" + crypt "~0.0.1" + is-buffer "~1.1.1" + media-typer@0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" @@ -4501,6 +4520,14 @@ webpack-merge@^4.2.2: dependencies: lodash "^4.17.15" +webpack-require-http@^0.4.3: + version "0.4.3" + resolved "https://registry.yarnpkg.com/webpack-require-http/-/webpack-require-http-0.4.3.tgz#5690d8cc57246a53a81f1ccffd20d0394d70261c" + integrity sha1-VpDYzFckalOoHxzP/SDQOU1wJhw= + dependencies: + md5 "^2.0.0" + url "^0.11.0" + webpack-sources@^1.4.0, webpack-sources@^1.4.1: version "1.4.3" resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.4.3.tgz#eedd8ec0b928fbf1cbfe994e22d2d890f330a933" diff --git a/maps/.gitignore b/maps/.gitignore new file mode 100644 index 00000000..2ccbe465 --- /dev/null +++ b/maps/.gitignore @@ -0,0 +1 @@ +/node_modules/ diff --git a/maps/dist/.htaccess b/maps/dist/.htaccess new file mode 100644 index 00000000..f2895509 --- /dev/null +++ b/maps/dist/.htaccess @@ -0,0 +1 @@ +Header set Access-Control-Allow-Origin "*" diff --git a/maps/objects/computer.ts b/maps/objects/computer.ts index e69de29b..145d19df 100644 --- a/maps/objects/computer.ts +++ b/maps/objects/computer.ts @@ -0,0 +1,56 @@ +import * as Phaser from 'phaser'; +import {Scene} from "phaser"; +import Sprite = Phaser.GameObjects.Sprite; + +interface ITiledMapObject { + id: number; + + /** + * Tile object id + */ + gid: number; + height: number; + name: string; + properties: {[key: string]: string}; + rotation: number; + type: string; + visible: boolean; + width: number; + x: number; + y: number; + + /** + * Whether or not object is an ellipse + */ + ellipse: boolean; + + /** + * Polygon points + */ + polygon: {x: number, y: number}[]; + + /** + * Polyline points + */ + polyline: {x: number, y: number}[]; +} + +class MySprite extends Sprite { + +} + + +export default { + preload: (loader: Phaser.Loader.LoaderPlugin) => { + loader.atlas('computer', 'http://maps.workadventure.localhost/computer/computer.png', 'http://maps.workadventure.localhost/computer/computer_atlas.json'); + }, + create: (scene: Scene) => { + + }, + factory: (scene: Scene, object: ITiledMapObject) => { + // Idée: ESSAYER WebPack? https://paultavares.wordpress.com/2018/07/02/webpack-how-to-generate-an-es-module-bundle/ + let foo = new MySprite(scene, object.x, object.y, 'computer'); + scene.add.existing(foo); + //scene.add.sprite(object.x, object.y, 'computer'); + } +}; diff --git a/maps/package.json b/maps/package.json index a20c876f..3623c205 100644 --- a/maps/package.json +++ b/maps/package.json @@ -1,13 +1,12 @@ { - "name": "workadventureback", + "name": "workadventuremaps", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "tsc": "tsc", - "dev": "ts-node-dev --respawn --transpileOnly ./server.ts", - "prod": "tsc && node ./dist/server.js", - "profile": "tsc && node --prof ./dist/server.js", + "dev": "tsc -w", + "prod": "tsc", "test": "ts-node node_modules/jasmine/bin/jasmine --config=jasmine.json", "lint": "node_modules/.bin/eslint src/ . --ext .ts", "fix": "node_modules/.bin/eslint --fix src/ . --ext .ts" @@ -36,22 +35,9 @@ }, "homepage": "https://github.com/thecodingmachine/workadventure#readme", "dependencies": { - "@types/express": "^4.17.4", - "@types/http-status-codes": "^1.2.0", - "@types/jsonwebtoken": "^8.3.8", - "@types/socket.io": "^2.1.4", - "@types/uuidv4": "^5.0.0", - "body-parser": "^1.19.0", - "express": "^4.17.1", - "generic-type-guard": "^3.2.0", - "http-status-codes": "^1.4.0", - "jsonwebtoken": "^8.5.1", - "prom-client": "^12.0.0", - "socket.io": "^2.3.0", - "systeminformation": "^4.26.5", + "phaser": "^3.24.1", "ts-node-dev": "^1.0.0-pre.44", - "typescript": "^3.8.3", - "uuidv4": "^6.0.7" + "typescript": "^3.8.3" }, "devDependencies": { "@types/jasmine": "^3.5.10", From 2484e4f1df75876cf01875f00e9fcd472c9360c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 23 Jul 2020 18:43:51 +0200 Subject: [PATCH 003/122] Moving maps to their own container --- .github/workflows/build-and-deploy.yml | 24 +++++++++ back/src/Controller/MapController.ts | 3 +- deeployer.libsonnet | 8 +++ docker-compose.yaml | 2 +- .../resources/items/computer/computer.png | Bin 0 -> 577 bytes .../items/computer/computer_atlas.json | 47 ++++++++++++++++++ .../items/computer/original/computer.png | Bin 0 -> 577 bytes .../computer/original/computer_atlas.json | 47 ++++++++++++++++++ .../items/computer/unpack/computer_off.png | Bin 0 -> 379 bytes .../items/computer/unpack/computer_on1.png | Bin 0 -> 492 bytes .../items/computer/unpack/computer_on2.png | Bin 0 -> 452 bytes front/src/Phaser/Items/Computer/computer.ts | 2 +- maps/{dist => }/.htaccess | 0 maps/Dockerfile | 9 ++++ .../Assets/Maps => maps}/Floor0/floor0.json | 0 .../Maps => maps}/Floor0/floortileset.png | Bin .../Floor0/tilesets_deviant_milkian_1.png | Bin .../Maps => maps}/Floor1/FloorTile_S.jpg | Bin .../Assets/Maps => maps}/Floor1/floor1.json | 0 .../Maps => maps}/Floor1/floortileset.png | Bin .../Floor1/tilesets_deviant_milkian_1.png | Bin .../Maps => maps}/Lyon/floortileset.png | Bin {back/src/Assets/Maps => maps}/Lyon/lyon.json | 0 .../Lyon/tilesets_deviant_milkian_1.png | Bin maps/objects/computer.ts | 2 +- 25 files changed, 140 insertions(+), 4 deletions(-) create mode 100644 front/dist/resources/items/computer/computer.png create mode 100644 front/dist/resources/items/computer/computer_atlas.json create mode 100644 front/dist/resources/items/computer/original/computer.png create mode 100644 front/dist/resources/items/computer/original/computer_atlas.json create mode 100644 front/dist/resources/items/computer/unpack/computer_off.png create mode 100644 front/dist/resources/items/computer/unpack/computer_on1.png create mode 100644 front/dist/resources/items/computer/unpack/computer_on2.png rename maps/{dist => }/.htaccess (100%) create mode 100644 maps/Dockerfile rename {back/src/Assets/Maps => maps}/Floor0/floor0.json (100%) rename {back/src/Assets/Maps => maps}/Floor0/floortileset.png (100%) rename {back/src/Assets/Maps => maps}/Floor0/tilesets_deviant_milkian_1.png (100%) rename {back/src/Assets/Maps => maps}/Floor1/FloorTile_S.jpg (100%) rename {back/src/Assets/Maps => maps}/Floor1/floor1.json (100%) rename {back/src/Assets/Maps => maps}/Floor1/floortileset.png (100%) rename {back/src/Assets/Maps => maps}/Floor1/tilesets_deviant_milkian_1.png (100%) rename {back/src/Assets/Maps => maps}/Lyon/floortileset.png (100%) rename {back/src/Assets/Maps => maps}/Lyon/lyon.json (100%) rename {back/src/Assets/Maps => maps}/Lyon/tilesets_deviant_milkian_1.png (100%) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index e79fe2a9..edd7b553 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -79,6 +79,30 @@ jobs: tags: ${{ env.GITHUB_REF_SLUG }} add_git_labels: true + build-maps: + + runs-on: ubuntu-latest + + steps: + + - name: Checkout + uses: actions/checkout@v2 + + + # Create a slugified value of the branch + - uses: rlespinasse/github-slug-action@master + + - name: "Build and push front image" + uses: docker/build-push-action@v1 + with: + dockerfile: maps/Dockerfile + path: maps/ + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + repository: thecodingmachine/workadventure-maps + tags: ${{ env.GITHUB_REF_SLUG }} + add_git_labels: true + deeploy: needs: - build-front diff --git a/back/src/Controller/MapController.ts b/back/src/Controller/MapController.ts index e3730898..af2ba848 100644 --- a/back/src/Controller/MapController.ts +++ b/back/src/Controller/MapController.ts @@ -19,8 +19,9 @@ export class MapController { // Returns a map mapping map name to file name of the map getStartMap() { this.App.get("/start-map", (req: Request, res: Response) => { + let url = req.headers.host?.replace('api.', 'maps.') + URL_ROOM_STARTED; res.status(OK).send({ - mapUrlStart: req.headers.host + "/map/files" + URL_ROOM_STARTED, + mapUrlStart: url, startInstance: "global" }); }); diff --git a/deeployer.libsonnet b/deeployer.libsonnet index 09074148..bb0ce34d 100644 --- a/deeployer.libsonnet +++ b/deeployer.libsonnet @@ -28,6 +28,14 @@ "API_URL": "api."+url } }, + "maps": { + "image": "thecodingmachine/workadventure-maps:"+tag, + "host": { + "url": "maps."+url, + "https": "enable" + }, + "ports": [80] + }, "website": { "image": "thecodingmachine/workadventure-website:"+tag, "host": { diff --git a/docker-compose.yaml b/docker-compose.yaml index 53208c76..6d9380b8 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -44,7 +44,7 @@ services: DEBUG_MODE: "$DEBUG_MODE" HOST: "0.0.0.0" NODE_ENV: development - APACHE_DOCUMENT_ROOT: dist/ + #APACHE_DOCUMENT_ROOT: dist/ #APACHE_EXTENSIONS: headers #APACHE_EXTENSION_HEADERS: 1 STARTUP_COMMAND_0: sudo a2enmod headers diff --git a/front/dist/resources/items/computer/computer.png b/front/dist/resources/items/computer/computer.png new file mode 100644 index 0000000000000000000000000000000000000000..cd3a261991801be8a1a79cd6a4ecb1656fec500e GIT binary patch literal 577 zcmV-H0>1r;P) z_y>hR@q`gY@w|$(;XC*1>V@psjnth@yDHtP+YRj3|nyiLH*mTJE@Z(AGU+ zL{U7=-8ZuI#1uvGB&2afM2rD?Tm=ONRmQ)NTEn0W`ZK|WwEFcd3Jj`Da3L?BMTbEd zbeL4o_b<7b*!kG&hx1Gh=NW@CXeL~FWf)YMu|eJH`YW7T>C{^XgEHtaQ?I-q&_BdHs4_4=wMKzKm4SI&1qB9GhAXcOgDL~_xC#mks?5K+;VuP(l4kh^iEayrv_vb( P00000NkvXXu0mjfFhUGc literal 0 HcmV?d00001 diff --git a/front/dist/resources/items/computer/computer_atlas.json b/front/dist/resources/items/computer/computer_atlas.json new file mode 100644 index 00000000..881f1189 --- /dev/null +++ b/front/dist/resources/items/computer/computer_atlas.json @@ -0,0 +1,47 @@ +{ + "frames": [ + { + "filename": "computer_off", + "frame": { + "w": 42, + "h": 40, + "x": 0, + "y": 0 + }, + "anchor": { + "x": 0.5, + "y": 0.5 + } + }, + { + "filename": "computer_on1", + "frame": { + "w": 42, + "h": 40, + "x": 0, + "y": 40 + }, + "anchor": { + "x": 0.5, + "y": 0.5 + } + }, + { + "filename": "computer_on2", + "frame": { + "w": 42, + "h": 40, + "x": 42, + "y": 0 + }, + "anchor": { + "x": 0.5, + "y": 0.5 + } + } + ], + "meta": { + "description": "Atlas generado con Atlas Packer Gamma V2", + "web": "https://gammafp.github.io/atlas-packer-phaser/" + } +} \ No newline at end of file diff --git a/front/dist/resources/items/computer/original/computer.png b/front/dist/resources/items/computer/original/computer.png new file mode 100644 index 0000000000000000000000000000000000000000..cd3a261991801be8a1a79cd6a4ecb1656fec500e GIT binary patch literal 577 zcmV-H0>1r;P) z_y>hR@q`gY@w|$(;XC*1>V@psjnth@yDHtP+YRj3|nyiLH*mTJE@Z(AGU+ zL{U7=-8ZuI#1uvGB&2afM2rD?Tm=ONRmQ)NTEn0W`ZK|WwEFcd3Jj`Da3L?BMTbEd zbeL4o_b<7b*!kG&hx1Gh=NW@CXeL~FWf)YMu|eJH`YW7T>C{^XgEHtaQ?I-q&_BdHs4_4=wMKzKm4SI&1qB9GhAXcOgDL~_xC#mks?5K+;VuP(l4kh^iEayrv_vb( P00000NkvXXu0mjfFhUGc literal 0 HcmV?d00001 diff --git a/front/dist/resources/items/computer/original/computer_atlas.json b/front/dist/resources/items/computer/original/computer_atlas.json new file mode 100644 index 00000000..881f1189 --- /dev/null +++ b/front/dist/resources/items/computer/original/computer_atlas.json @@ -0,0 +1,47 @@ +{ + "frames": [ + { + "filename": "computer_off", + "frame": { + "w": 42, + "h": 40, + "x": 0, + "y": 0 + }, + "anchor": { + "x": 0.5, + "y": 0.5 + } + }, + { + "filename": "computer_on1", + "frame": { + "w": 42, + "h": 40, + "x": 0, + "y": 40 + }, + "anchor": { + "x": 0.5, + "y": 0.5 + } + }, + { + "filename": "computer_on2", + "frame": { + "w": 42, + "h": 40, + "x": 42, + "y": 0 + }, + "anchor": { + "x": 0.5, + "y": 0.5 + } + } + ], + "meta": { + "description": "Atlas generado con Atlas Packer Gamma V2", + "web": "https://gammafp.github.io/atlas-packer-phaser/" + } +} \ No newline at end of file diff --git a/front/dist/resources/items/computer/unpack/computer_off.png b/front/dist/resources/items/computer/unpack/computer_off.png new file mode 100644 index 0000000000000000000000000000000000000000..544838fe0b24506c5934cf8fbc7574a7bd98d2fe GIT binary patch literal 379 zcmeAS@N?(olHy`uVBq!ia0vp^T0pG9!3HEdxHAHP6lZ})WHAE+-w_aIoT|+y&A`B@ z>*?Yc64Cm0#(uv;0V3`DrQ}-G1ER?a)SK<0SnWFt~zv#r*TkhPxT!AHf_lMg0rQR$DKHD(FTxU%% zkYU^~!+))CZdi5Eu2_pc=A3&j;#W_-J!d?#vn}$Bw`V0ozy|e+dmnpD@v&0uHFck` zLNK%!1NpxBp7H;mwkAIV+u;}UX1Fj{*B;c%y8C+ZgzeYmf3+X6+aHoG+&sfYw;^o% zUZxjUaTa&)uc$SKhFz@-4inQxn`HrY$F+K@OXTR(7OlImCbL-b`(^*|p9D$+9 N;OXk;vd$@?2>_4Go6P_K literal 0 HcmV?d00001 diff --git a/front/dist/resources/items/computer/unpack/computer_on1.png b/front/dist/resources/items/computer/unpack/computer_on1.png new file mode 100644 index 0000000000000000000000000000000000000000..e2492441e294b71049346902c083c246cc1d5eaa GIT binary patch literal 492 zcmV?00009a7bBm000ie z000ie0hKEb8vp*MgxL5L7NRJEA|#-MK)^;MZAAP7wKE{W zMyxE;hy;{W3TiB@B^E&tL_`dT4`9Tnut>8OW{kUW*3BwA%;4$ny@cExK4vouh9CeO z$8m%ZqS7MS?gqFgQm?O&pch56ZzUQELt zp@{np>u)Pj?Eyfd_eeRj!zd$z5v|eUMLn{_sE2AX<*H}4ZoloT=2w?J0PNjdcef?B z8kL5E_B-d@o0QmTR8mN1T(!)c?EjQORo4Bm+o;M|P?KJRvcHp4f7TeIp%$$cQ?8s9 z(wUCj`t`$LjL}dT^=2$+W>rrz*-!XOOSKZiycNw6OU2t0YJru|D&#Jaw0jY z^#o1z>b)9Dq_b|1ro7xoZuWY4qgy5NKy|<6{5Y`o5LXC^6HhH?00009a7bBm000ie z000ie0hKEb8vp^8j!h2Y^=l5rD4yYE5OfRYIl*i)OP4{60xm?CoxcdNPd$>AD+f?Eyfc_!2qG zhf$UnQd&cid!qsDdPS={=eI-qQFF_k0pR)RGTD~o)u=M`-+p+W+@vC(Mir%UO{-Pr zRNo|nf01vaQO3q$QX$5u(V}*}qMe)q5M$H=IJ&6z0nYYM0JwU%A+Fxp zvH^Ji{LnH!PQ)11&e4NI|BGm4a}9uoUG)d$MZL}dnMUvL{I4RF$zR%hpo-b|BoR5IVW@ocS^muqVP0000 { - loader.atlas('computer', 'http://maps.workadventure.localhost/computer/computer.png', 'http://maps.workadventure.localhost/computer/computer_atlas.json'); + loader.atlas('computer', '/resources/items/computer/computer.png', '/resources/items/computer/computer_atlas.json'); }, create: (scene: GameScene): void => { diff --git a/maps/dist/.htaccess b/maps/.htaccess similarity index 100% rename from maps/dist/.htaccess rename to maps/.htaccess diff --git a/maps/Dockerfile b/maps/Dockerfile new file mode 100644 index 00000000..550d87f1 --- /dev/null +++ b/maps/Dockerfile @@ -0,0 +1,9 @@ +# we are rebuilding on each deploy to cope with the API_URL environment URL +FROM thecodingmachine/nodejs:12-apache + +COPY --chown=docker:docker . . +#RUN yarn install + +#ENV NODE_ENV=production +#ENV STARTUP_COMMAND_1="yarn run build" +#ENV APACHE_DOCUMENT_ROOT=dist/ diff --git a/back/src/Assets/Maps/Floor0/floor0.json b/maps/Floor0/floor0.json similarity index 100% rename from back/src/Assets/Maps/Floor0/floor0.json rename to maps/Floor0/floor0.json diff --git a/back/src/Assets/Maps/Floor0/floortileset.png b/maps/Floor0/floortileset.png similarity index 100% rename from back/src/Assets/Maps/Floor0/floortileset.png rename to maps/Floor0/floortileset.png diff --git a/back/src/Assets/Maps/Floor0/tilesets_deviant_milkian_1.png b/maps/Floor0/tilesets_deviant_milkian_1.png similarity index 100% rename from back/src/Assets/Maps/Floor0/tilesets_deviant_milkian_1.png rename to maps/Floor0/tilesets_deviant_milkian_1.png diff --git a/back/src/Assets/Maps/Floor1/FloorTile_S.jpg b/maps/Floor1/FloorTile_S.jpg similarity index 100% rename from back/src/Assets/Maps/Floor1/FloorTile_S.jpg rename to maps/Floor1/FloorTile_S.jpg diff --git a/back/src/Assets/Maps/Floor1/floor1.json b/maps/Floor1/floor1.json similarity index 100% rename from back/src/Assets/Maps/Floor1/floor1.json rename to maps/Floor1/floor1.json diff --git a/back/src/Assets/Maps/Floor1/floortileset.png b/maps/Floor1/floortileset.png similarity index 100% rename from back/src/Assets/Maps/Floor1/floortileset.png rename to maps/Floor1/floortileset.png diff --git a/back/src/Assets/Maps/Floor1/tilesets_deviant_milkian_1.png b/maps/Floor1/tilesets_deviant_milkian_1.png similarity index 100% rename from back/src/Assets/Maps/Floor1/tilesets_deviant_milkian_1.png rename to maps/Floor1/tilesets_deviant_milkian_1.png diff --git a/back/src/Assets/Maps/Lyon/floortileset.png b/maps/Lyon/floortileset.png similarity index 100% rename from back/src/Assets/Maps/Lyon/floortileset.png rename to maps/Lyon/floortileset.png diff --git a/back/src/Assets/Maps/Lyon/lyon.json b/maps/Lyon/lyon.json similarity index 100% rename from back/src/Assets/Maps/Lyon/lyon.json rename to maps/Lyon/lyon.json diff --git a/back/src/Assets/Maps/Lyon/tilesets_deviant_milkian_1.png b/maps/Lyon/tilesets_deviant_milkian_1.png similarity index 100% rename from back/src/Assets/Maps/Lyon/tilesets_deviant_milkian_1.png rename to maps/Lyon/tilesets_deviant_milkian_1.png diff --git a/maps/objects/computer.ts b/maps/objects/computer.ts index 145d19df..3c48f91a 100644 --- a/maps/objects/computer.ts +++ b/maps/objects/computer.ts @@ -42,7 +42,7 @@ class MySprite extends Sprite { export default { preload: (loader: Phaser.Loader.LoaderPlugin) => { - loader.atlas('computer', 'http://maps.workadventure.localhost/computer/computer.png', 'http://maps.workadventure.localhost/computer/computer_atlas.json'); + loader.atlas('computer', '/resources/items/computer/computer.png', '/resources/items/computer/computer_atlas.json'); }, create: (scene: Scene) => { From d48d5b0285ef0729c2c86f4920cc0ac6a8adf562 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 23 Jul 2020 18:47:28 +0200 Subject: [PATCH 004/122] Fix CS --- back/src/Controller/MapController.ts | 2 +- front/src/Phaser/Game/GameScene.ts | 23 +++++++++++---------- front/src/Phaser/Items/ActionableItem.ts | 2 +- front/src/Phaser/Items/Computer/computer.ts | 2 +- front/src/index.ts | 2 +- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/back/src/Controller/MapController.ts b/back/src/Controller/MapController.ts index af2ba848..58ce40a9 100644 --- a/back/src/Controller/MapController.ts +++ b/back/src/Controller/MapController.ts @@ -19,7 +19,7 @@ export class MapController { // Returns a map mapping map name to file name of the map getStartMap() { this.App.get("/start-map", (req: Request, res: Response) => { - let url = req.headers.host?.replace('api.', 'maps.') + URL_ROOM_STARTED; + const url = req.headers.host?.replace('api.', 'maps.') + URL_ROOM_STARTED; res.status(OK).send({ mapUrlStart: url, startInstance: "global" diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 6d311e33..9ee54058 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -252,11 +252,11 @@ export class GameScene extends Phaser.Scene { }) // Scan the object layers for objects to load and load them. - let objects = new Map(); + const objects = new Map(); - for (let layer of this.mapFile.layers) { + for (const layer of this.mapFile.layers) { if (layer.type === 'objectgroup') { - for (let object of layer.objects) { + for (const object of layer.objects) { let objectsOfType: ITiledMapObject[]|undefined; if (!objects.has(object.type)) { objectsOfType = new Array(); @@ -272,16 +272,17 @@ export class GameScene extends Phaser.Scene { } } - for (let [itemType, objectsOfType] of objects) { + for (const [itemType, objectsOfType] of objects) { // FIXME: we would ideally need for the loader to WAIT for the import to be performed, which means writing our own loader plugin. let itemFactory: ItemFactoryInterface; switch (itemType) { - case 'computer': - let module = await import('../Items/Computer/computer'); - itemFactory = module.default as ItemFactoryInterface; + case 'computer': { + const module = await import('../Items/Computer/computer'); + itemFactory = module.default; break; + } default: throw new Error('Unsupported object type: "'+ itemType +'"'); } @@ -295,9 +296,9 @@ export class GameScene extends Phaser.Scene { this.createPromise.then(() => { itemFactory.create(this); - for (let object of objectsOfType) { + for (const object of objectsOfType) { // TODO: we should pass here a factory to create sprites (maybe?) - let actionableItem = itemFactory.factory(this, object); + const actionableItem = itemFactory.factory(this, object); this.actionableItems.push(actionableItem); } }); @@ -675,8 +676,8 @@ export class GameScene extends Phaser.Scene { let shortestDistance: number = Infinity; let selectedItem: ActionableItem|null = null; - for (let item of this.actionableItems) { - let distance = item.actionableDistance(x, y); + for (const item of this.actionableItems) { + const distance = item.actionableDistance(x, y); if (distance !== null && distance < shortestDistance) { shortestDistance = distance; selectedItem = item; diff --git a/front/src/Phaser/Items/ActionableItem.ts b/front/src/Phaser/Items/ActionableItem.ts index 229b0888..01e85c64 100644 --- a/front/src/Phaser/Items/ActionableItem.ts +++ b/front/src/Phaser/Items/ActionableItem.ts @@ -18,7 +18,7 @@ export class ActionableItem { * OR null if we are out of range. */ public actionableDistance(x: number, y: number): number|null { - let distanceSquared = (x - this.sprite.x)*(x - this.sprite.x) + (y - this.sprite.y)*(y - this.sprite.y); + const distanceSquared = (x - this.sprite.x)*(x - this.sprite.x) + (y - this.sprite.y)*(y - this.sprite.y); if (distanceSquared < this.activationRadiusSquared) { return distanceSquared; } else { diff --git a/front/src/Phaser/Items/Computer/computer.ts b/front/src/Phaser/Items/Computer/computer.ts index 7ea7b318..b979ebf6 100644 --- a/front/src/Phaser/Items/Computer/computer.ts +++ b/front/src/Phaser/Items/Computer/computer.ts @@ -15,7 +15,7 @@ export default { }, factory: (scene: GameScene, object: ITiledMapObject): ActionableItem => { // Idée: ESSAYER WebPack? https://paultavares.wordpress.com/2018/07/02/webpack-how-to-generate-an-es-module-bundle/ - let foo = new Sprite(scene, object.x, object.y, 'computer'); + const foo = new Sprite(scene, object.x, object.y, 'computer'); scene.add.existing(foo); return new ActionableItem(foo, 32); diff --git a/front/src/index.ts b/front/src/index.ts index b847fa74..bf744a36 100644 --- a/front/src/index.ts +++ b/front/src/index.ts @@ -27,7 +27,7 @@ const config: GameConfig = { callbacks: { postBoot: game => { // FIXME: we should fore WebGL in the config. - let renderer = game.renderer as WebGLRenderer; + const renderer = game.renderer as WebGLRenderer; renderer.addPipeline(OutlinePipeline.KEY, new OutlinePipeline(game)); } } From 513244ae1f55df558ee4de17a54e6f2a3e55ca17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 23 Jul 2020 19:04:33 +0200 Subject: [PATCH 005/122] Enabling header module on Apache maps container --- maps/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/maps/Dockerfile b/maps/Dockerfile index 550d87f1..33ca48b5 100644 --- a/maps/Dockerfile +++ b/maps/Dockerfile @@ -7,3 +7,4 @@ COPY --chown=docker:docker . . #ENV NODE_ENV=production #ENV STARTUP_COMMAND_1="yarn run build" #ENV APACHE_DOCUMENT_ROOT=dist/ +RUN sudo a2enmod headers From ee612f65859b5629c8db945ad25c4eb647c38e4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Mon, 27 Jul 2020 22:36:07 +0200 Subject: [PATCH 006/122] Adding event support to items --- back/src/Controller/IoSocketController.ts | 38 +++++++++- back/src/Model/Websocket/ItemEventMessage.ts | 10 +++ back/src/Model/World.ts | 10 +++ front/package.json | 1 + front/src/Connection.ts | 34 ++++++++- front/src/Phaser/Game/GameScene.ts | 68 +++++++++++++---- front/src/Phaser/Items/ActionableItem.ts | 36 ++++++++- front/src/Phaser/Items/Computer/computer.ts | 74 +++++++++++++++++-- .../src/Phaser/Items/ItemFactoryInterface.ts | 2 +- front/src/Phaser/Player/Player.ts | 11 +-- front/yarn.lock | 5 ++ 11 files changed, 253 insertions(+), 36 deletions(-) create mode 100644 back/src/Model/Websocket/ItemEventMessage.ts diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index edd29e7b..f0ac0337 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -19,6 +19,7 @@ import {isJoinRoomMessageInterface} from "../Model/Websocket/JoinRoomMessage"; import {isPointInterface, PointInterface} from "../Model/Websocket/PointInterface"; import {isWebRtcSignalMessageInterface} from "../Model/Websocket/WebRtcSignalMessage"; import {UserInGroupInterface} from "../Model/Websocket/UserInGroupInterface"; +import {isItemEventMessageInterface} from "../Model/Websocket/ItemEventMessage"; enum SockerIoEvent { CONNECTION = "connection", @@ -33,7 +34,8 @@ enum SockerIoEvent { MESSAGE_ERROR = "message-error", GROUP_CREATE_UPDATE = "group-create-update", GROUP_DELETE = "group-delete", - SET_PLAYER_DETAILS = "set-player-details" + SET_PLAYER_DETAILS = "set-player-details", + ITEM_EVENT = 'item-event', } export class IoSocketController { @@ -190,7 +192,16 @@ export class IoSocketController { } return new MessageUserPosition(user.id, player.name, player.character, player.position); }).filter((item: MessageUserPosition|null) => item !== null); - answerFn(listOfUsers); + + const listOfItems: {[itemId: string]: unknown} = {}; + for (const [itemId, item] of world.getItemsState().entries()) { + listOfItems[itemId] = item; + } + + answerFn({ + users: listOfUsers, + items: listOfItems + }); } catch (e) { console.error('An error occurred on "join_room" event'); console.error(e); @@ -281,6 +292,29 @@ export class IoSocketController { Client.character = playerDetails.character; answerFn(Client.userId); }); + + socket.on(SockerIoEvent.ITEM_EVENT, (itemEvent: unknown) => { + if (!isItemEventMessageInterface(itemEvent)) { + socket.emit(SockerIoEvent.MESSAGE_ERROR, {message: 'Invalid ITEM_EVENT message.'}); + console.warn('Invalid ITEM_EVENT message received: ', itemEvent); + return; + } + try { + const Client = (socket as ExSocketInterface); + + socket.to(Client.roomId).emit(SockerIoEvent.ITEM_EVENT, itemEvent); + + const world = this.Worlds.get(Client.roomId); + if (!world) { + console.error("Could not find world with id '", Client.roomId, "'"); + return; + } + world.setItemState(itemEvent.itemId, itemEvent.state); + } catch (e) { + console.error('An error occurred on "item_event"'); + console.error(e); + } + }); }); } diff --git a/back/src/Model/Websocket/ItemEventMessage.ts b/back/src/Model/Websocket/ItemEventMessage.ts new file mode 100644 index 00000000..b1f9203e --- /dev/null +++ b/back/src/Model/Websocket/ItemEventMessage.ts @@ -0,0 +1,10 @@ +import * as tg from "generic-type-guard"; + +export const isItemEventMessageInterface = + new tg.IsInterface().withProperties({ + itemId: tg.isNumber, + event: tg.isString, + state: tg.isUnknown, + parameters: tg.isUnknown, + }).get(); +export type ItemEventMessageInterface = tg.GuardedType; diff --git a/back/src/Model/World.ts b/back/src/Model/World.ts index 6d4fc205..5d26f817 100644 --- a/back/src/Model/World.ts +++ b/back/src/Model/World.ts @@ -27,6 +27,8 @@ export class World { private readonly groupUpdatedCallback: GroupUpdatedCallback; private readonly groupDeletedCallback: GroupDeletedCallback; + private itemsState: Map = new Map(); + constructor(connectCallback: ConnectCallback, disconnectCallback: DisconnectCallback, minDistance: number, @@ -227,6 +229,14 @@ export class World { return Math.sqrt(Math.pow(position2.x - position1.x, 2) + Math.pow(position2.y - position1.y, 2)); } + public setItemState(itemId: number, state: unknown) { + this.itemsState.set(itemId, state); + } + + public getItemsState(): Map { + return this.itemsState; + } + /*getDistancesBetweenGroupUsers(group: Group): Distance[] { let i = 0; diff --git a/front/package.json b/front/package.json index e5ea5b66..a9c7b3f8 100644 --- a/front/package.json +++ b/front/package.json @@ -22,6 +22,7 @@ "@types/axios": "^0.14.0", "@types/simple-peer": "^9.6.0", "@types/socket.io-client": "^1.4.32", + "generic-type-guard": "^3.2.0", "phaser": "^3.22.0", "queue-typescript": "^1.0.1", "simple-peer": "^9.6.2", diff --git a/front/src/Connection.ts b/front/src/Connection.ts index c4ac92c6..5e51974f 100644 --- a/front/src/Connection.ts +++ b/front/src/Connection.ts @@ -22,6 +22,7 @@ enum EventMessage{ GROUP_CREATE_UPDATE = "group-create-update", GROUP_DELETE = "group-delete", SET_PLAYER_DETAILS = "set-player-details", // Send the name and character to the server (on connect), receive back the id. + ITEM_EVENT = 'item-event', CONNECT_ERROR = "connect_error", } @@ -91,6 +92,18 @@ export interface StartMapInterface { startInstance: string } +export interface ItemEventMessageInterface { + itemId: number, + event: string, + state: unknown, + parameters: unknown +} + +export interface RoomJoinedMessageInterface { + users: MessageUserPositionInterface[] + items: { [itemId: number] : unknown } +} + export class Connection implements Connection { private readonly socket: Socket; private userId: string|null = null; @@ -147,10 +160,10 @@ export class Connection implements Connection { } - public joinARoom(roomId: string, startX: number, startY: number, direction: string, moving: boolean): Promise { - const promise = new Promise((resolve, reject) => { - this.socket.emit(EventMessage.JOIN_ROOM, { roomId, position: {x: startX, y: startY, direction, moving }}, (userPositions: MessageUserPositionInterface[]) => { - resolve(userPositions); + public joinARoom(roomId: string, startX: number, startY: number, direction: string, moving: boolean): Promise { + const promise = new Promise((resolve, reject) => { + this.socket.emit(EventMessage.JOIN_ROOM, { roomId, position: {x: startX, y: startY, direction, moving }}, (roomJoinedMessage: RoomJoinedMessageInterface) => { + resolve(roomJoinedMessage); }); }) return promise; @@ -223,4 +236,17 @@ export class Connection implements Connection { disconnectMessage(callback: (message: WebRtcDisconnectMessageInterface) => void): void { this.socket.on(EventMessage.WEBRTC_DISCONNECT, callback); } + + emitActionableEvent(itemId: number, event: string, state: unknown, parameters: unknown) { + return this.socket.emit(EventMessage.ITEM_EVENT, { + itemId, + event, + state, + parameters + }); + } + + onActionableEvent(callback: (message: ItemEventMessageInterface) => void): void { + this.socket.on(EventMessage.ITEM_EVENT, callback); + } } diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 9ee54058..c7c9e626 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -3,7 +3,7 @@ import { Connection, GroupCreatedUpdatedMessageInterface, MessageUserJoined, MessageUserMovedInterface, - MessageUserPositionInterface, PointInterface, PositionInterface + MessageUserPositionInterface, PointInterface, PositionInterface, RoomJoinedMessageInterface } from "../../Connection"; import {CurrentGamerInterface, hasMovedEventName, Player} from "../Player/Player"; import { DEBUG_MODE, ZOOM_LEVEL, POSITION_DELAY } from "../../Enum/EnvironmentVariable"; @@ -30,6 +30,7 @@ import FILE_LOAD_ERROR = Phaser.Loader.Events.FILE_LOAD_ERROR; import {FourOFourSceneName} from "../Reconnecting/FourOFourScene"; import {ItemFactoryInterface} from "../Items/ItemFactoryInterface"; import {ActionableItem} from "../Items/ActionableItem"; +import {UserInputManager} from "../UserInput/UserInputManager"; export enum Textures { @@ -91,6 +92,8 @@ export class GameScene extends Phaser.Scene { private connection: Connection; private simplePeer : SimplePeer; private connectionPromise: Promise + private connectionAnswerPromise: Promise; + private connectionAnswerPromiseResolve: (value?: RoomJoinedMessageInterface | PromiseLike) => void; // A promise that will resolve when the "create" method is called (signaling loading is ended) private createPromise: Promise; private createPromiseResolve: (value?: void | PromiseLike) => void; @@ -111,9 +114,10 @@ export class GameScene extends Phaser.Scene { private PositionNextScene: Array> = new Array>(); private startLayerName: string|undefined; - private actionableItems: Array = new Array(); + private actionableItems: Map = new Map(); // The item that can be selected by pressing the space key. private outlinedItem: ActionableItem|null = null; + private userInputManager: UserInputManager; static createFromUrl(mapUrlFile: string, instance: string, key: string|null = null): GameScene { const mapKey = GameScene.getMapKeyByUrl(mapUrlFile); @@ -140,6 +144,9 @@ export class GameScene extends Phaser.Scene { this.createPromise = new Promise((resolve, reject): void => { this.createPromiseResolve = resolve; }) + this.connectionAnswerPromise = new Promise((resolve, reject): void => { + this.connectionAnswerPromiseResolve = resolve; + }) } //hook preload scene @@ -225,6 +232,15 @@ export class GameScene extends Phaser.Scene { this.scene.remove(this.scene.key); }) + connection.onActionableEvent((message => { + const item = this.actionableItems.get(message.itemId); + if (item === undefined) { + console.warn('Received an event about object "'+message.itemId+'" but cannot find this item on the map.'); + return; + } + item.fire(message.event, message.state, message.parameters); + })); + // When connection is performed, let's connect SimplePeer this.simplePeer = new SimplePeer(this.connection); @@ -293,13 +309,19 @@ export class GameScene extends Phaser.Scene { this.load.on('complete', () => { // FIXME: the factory might fail because the resources might not be loaded yet... // We would need to add a loader ended event in addition to the createPromise - this.createPromise.then(() => { + this.createPromise.then(async () => { itemFactory.create(this); + const roomJoinedAnswer = await this.connectionAnswerPromise; + for (const object of objectsOfType) { // TODO: we should pass here a factory to create sprites (maybe?) - const actionableItem = itemFactory.factory(this, object); - this.actionableItems.push(actionableItem); + + // Do we have a state for this object? + const state = roomJoinedAnswer.items[object.id]; + + const actionableItem = itemFactory.factory(this, object, state); + this.actionableItems.set(actionableItem.getId(), actionableItem); } }); }); @@ -414,13 +436,15 @@ export class GameScene extends Phaser.Scene { //initialise list of other player this.MapPlayers = this.physics.add.group({ immovable: true }); + //create input to move + this.userInputManager = new UserInputManager(this); + //notify game manager can to create currentUser in map this.createCurrentPlayer(); //initialise camera this.initCamera(); - // Let's generate the circle for the group delimiter const circleElement = Object.values(this.textures.list).find((object: Texture) => object.key === 'circleSprite'); if(circleElement) { @@ -455,6 +479,11 @@ export class GameScene extends Phaser.Scene { } this.createPromiseResolve(); + + // TODO: use inputmanager instead + this.input.keyboard.on('keyup-SPACE', () => { + this.outlinedItem?.activate(); + }); } private getExitSceneUrl(layer: ITiledMapLayer): string|undefined { @@ -605,7 +634,8 @@ export class GameScene extends Phaser.Scene { this.GameManager.getPlayerName(), this.GameManager.getCharacterSelected(), PlayerAnimationNames.WalkDown, - false + false, + this.userInputManager ); //create collision @@ -614,8 +644,9 @@ export class GameScene extends Phaser.Scene { //join room this.connectionPromise.then((connection: Connection) => { - connection.joinARoom(this.RoomId, this.startX, this.startY, PlayerAnimationNames.WalkDown, false).then((userPositions: MessageUserPositionInterface[]) => { - this.initUsersPosition(userPositions); + connection.joinARoom(this.RoomId, this.startX, this.startY, PlayerAnimationNames.WalkDown, false).then((roomJoinedMessage: RoomJoinedMessageInterface) => { + this.initUsersPosition(roomJoinedMessage.users); + this.connectionAnswerPromiseResolve(roomJoinedMessage); }); //listen event to share position of user @@ -676,7 +707,7 @@ export class GameScene extends Phaser.Scene { let shortestDistance: number = Infinity; let selectedItem: ActionableItem|null = null; - for (const item of this.actionableItems) { + for (const item of this.actionableItems.values()) { const distance = item.actionableDistance(x, y); if (distance !== null && distance < shortestDistance) { shortestDistance = distance; @@ -766,10 +797,7 @@ export class GameScene extends Phaser.Scene { } } - /** - * - */ - checkToExit(): {key: string, hash: string} | null { + private checkToExit(): {key: string, hash: string} | null { const x = Math.floor(this.CurrentPlayer.x / 32); const y = Math.floor(this.CurrentPlayer.y / 32); @@ -947,4 +975,16 @@ export class GameScene extends Phaser.Scene { const endPos = mapUrlStart.indexOf(".json"); return mapUrlStart.substring(startPos, endPos); } + + /** + * Sends to the server an event emitted by one of the ActionableItems. + * + * @param itemId + * @param eventName + * @param state + * @param parameters + */ + emitActionableEvent(itemId: number, eventName: string, state: unknown, parameters: unknown) { + this.connection.emitActionableEvent(itemId, eventName, state, parameters); + } } diff --git a/front/src/Phaser/Items/ActionableItem.ts b/front/src/Phaser/Items/ActionableItem.ts index 01e85c64..36b14921 100644 --- a/front/src/Phaser/Items/ActionableItem.ts +++ b/front/src/Phaser/Items/ActionableItem.ts @@ -4,15 +4,23 @@ */ import Sprite = Phaser.GameObjects.Sprite; import {OutlinePipeline} from "../Shaders/OutlinePipeline"; +import {GameScene} from "../Game/GameScene"; + +type EventCallback = (state: unknown, parameters: unknown) => void; export class ActionableItem { private readonly activationRadiusSquared : number; private isSelectable: boolean = false; + private callbacks: Map> = new Map>(); - public constructor(private sprite: Sprite, private activationRadius: number) { + public constructor(private id: number, private sprite: Sprite, private eventHandler: GameScene, private activationRadius: number, private onActivateCallback: (item: ActionableItem) => void) { this.activationRadiusSquared = activationRadius * activationRadius; } + public getId(): number { + return this.id; + } + /** * Returns the square of the distance to the object center IF we are in item action range * OR null if we are out of range. @@ -54,7 +62,31 @@ export class ActionableItem { * Triggered when the "space" key is pressed and the object is in range of being activated. */ public activate(): void { + this.onActivateCallback(this); + } + public emit(eventName: string, state: unknown, parameters: unknown = null): void { + this.eventHandler.emitActionableEvent(this.id, eventName, state, parameters); + // Also, execute the action locally. + this.fire(eventName, state, parameters); + } + + public on(eventName: string, callback: EventCallback): void { + let callbacksArray: Array|undefined = this.callbacks.get(eventName); + if (callbacksArray === undefined) { + callbacksArray = new Array(); + this.callbacks.set(eventName, callbacksArray); + } + callbacksArray.push(callback); + } + + public fire(eventName: string, state: unknown, parameters: unknown): void { + const callbacksArray = this.callbacks.get(eventName); + if (callbacksArray === undefined) { + return; + } + for (const callback of callbacksArray) { + callback(state, parameters); + } } } - diff --git a/front/src/Phaser/Items/Computer/computer.ts b/front/src/Phaser/Items/Computer/computer.ts index b979ebf6..fdc7a358 100644 --- a/front/src/Phaser/Items/Computer/computer.ts +++ b/front/src/Phaser/Items/Computer/computer.ts @@ -5,20 +5,82 @@ import {ITiledMapObject} from "../../Map/ITiledMap"; import {ItemFactoryInterface} from "../ItemFactoryInterface"; import {GameScene} from "../../Game/GameScene"; import {ActionableItem} from "../ActionableItem"; +import * as tg from "generic-type-guard"; + +const isComputerState = + new tg.IsInterface().withProperties({ + status: tg.isString, + }).get(); +type ComputerState = tg.GuardedType; + +let state: ComputerState = { + 'status': 'off' +}; export default { preload: (loader: Phaser.Loader.LoaderPlugin): void => { loader.atlas('computer', '/resources/items/computer/computer.png', '/resources/items/computer/computer_atlas.json'); }, create: (scene: GameScene): void => { - + scene.anims.create({ + key: 'computer_off', + frames: [ + { + key: 'computer', + frame: 'computer_off' + } + ], + frameRate: 10, + repeat: -1 + }); + scene.anims.create({ + key: 'computer_run', + frames: [ + { + key: 'computer', + frame: 'computer_on1' + }, + { + key: 'computer', + frame: 'computer_on2' + } + ], + frameRate: 5, + repeat: -1 + }); }, - factory: (scene: GameScene, object: ITiledMapObject): ActionableItem => { - // Idée: ESSAYER WebPack? https://paultavares.wordpress.com/2018/07/02/webpack-how-to-generate-an-es-module-bundle/ - const foo = new Sprite(scene, object.x, object.y, 'computer'); - scene.add.existing(foo); + factory: (scene: GameScene, object: ITiledMapObject, initState: unknown): ActionableItem => { + if (initState !== undefined) { + if (!isComputerState(initState)) { + throw new Error('Invalid state received for computer object'); + } + state = initState; + } - return new ActionableItem(foo, 32); + // Idée: ESSAYER WebPack? https://paultavares.wordpress.com/2018/07/02/webpack-how-to-generate-an-es-module-bundle/ + const computer = new Sprite(scene, object.x, object.y, 'computer'); + scene.add.existing(computer); + if (state.status === 'on') { + computer.anims.play('computer_run'); + } + + const item = new ActionableItem(object.id, computer, scene, 32, (item: ActionableItem) => { + if (state.status === 'off') { + state.status = 'on'; + item.emit('TURN_ON', state); + } else { + state.status = 'off'; + item.emit('TURN_OFF', state); + } + }); + item.on('TURN_ON', () => { + computer.anims.play('computer_run'); + }); + item.on('TURN_OFF', () => { + computer.anims.play('computer_off'); + }); + + return item; //scene.add.sprite(object.x, object.y, 'computer'); } } as ItemFactoryInterface; diff --git a/front/src/Phaser/Items/ItemFactoryInterface.ts b/front/src/Phaser/Items/ItemFactoryInterface.ts index 0f88f76b..e3e52517 100644 --- a/front/src/Phaser/Items/ItemFactoryInterface.ts +++ b/front/src/Phaser/Items/ItemFactoryInterface.ts @@ -6,5 +6,5 @@ import {ActionableItem} from "./ActionableItem"; export interface ItemFactoryInterface { preload: (loader: LoaderPlugin) => void; create: (scene: GameScene) => void; - factory: (scene: GameScene, object: ITiledMapObject) => ActionableItem; + factory: (scene: GameScene, object: ITiledMapObject, state: unknown) => ActionableItem; } diff --git a/front/src/Phaser/Player/Player.ts b/front/src/Phaser/Player/Player.ts index 64adc246..1ddd8b87 100644 --- a/front/src/Phaser/Player/Player.ts +++ b/front/src/Phaser/Player/Player.ts @@ -13,9 +13,8 @@ export interface CurrentGamerInterface extends Character{ } export class Player extends Character implements CurrentGamerInterface { - userInputManager: UserInputManager; - previousDirection: string; - wasMoving: boolean; + private previousDirection: string; + private wasMoving: boolean; constructor( Scene: GameScene, @@ -24,13 +23,11 @@ export class Player extends Character implements CurrentGamerInterface { name: string, PlayerTexture: string, direction: string, - moving: boolean + moving: boolean, + private userInputManager: UserInputManager ) { super(Scene, x, y, PlayerTexture, name, direction, moving, 1); - //create input to move - this.userInputManager = new UserInputManager(Scene); - //the current player model should be push away by other players to prevent conflict this.setImmovable(false); } diff --git a/front/yarn.lock b/front/yarn.lock index b943ebf0..ae7b5558 100644 --- a/front/yarn.lock +++ b/front/yarn.lock @@ -1904,6 +1904,11 @@ functional-red-black-tree@^1.0.1: resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327" integrity sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc= +generic-type-guard@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/generic-type-guard/-/generic-type-guard-3.2.0.tgz#1fb136f934730c776486526b8a21fe96b067e691" + integrity sha512-EkkrXYbOtJ3VPB+SOrU7EhwY65rZErItGtBg5wAqywaj07BOubwOZqMYaxOWekJ9akioGqXIsw1fYk3wwbWsDQ== + get-browser-rtc@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/get-browser-rtc/-/get-browser-rtc-1.0.2.tgz#bbcd40c8451a7ed4ef5c373b8169a409dd1d11d9" From 2d818ec79d4c5d2e4cb07029a1853d7be8743523 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Mon, 27 Jul 2020 22:48:04 +0200 Subject: [PATCH 007/122] Fixing broken Jasmine test due to module config --- docker-compose.yaml | 2 +- front/Dockerfile | 2 +- front/tsconfig.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 6d9380b8..d691f204 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -19,7 +19,7 @@ services: - /var/run/docker.sock:/var/run/docker.sock front: - image: thecodingmachine/nodejs:12 + image: thecodingmachine/nodejs:14 environment: DEBUG_MODE: "$DEBUG_MODE" HOST: "0.0.0.0" diff --git a/front/Dockerfile b/front/Dockerfile index ee15270e..c5c605a8 100644 --- a/front/Dockerfile +++ b/front/Dockerfile @@ -1,5 +1,5 @@ # we are rebuilding on each deploy to cope with the API_URL environment URL -FROM thecodingmachine/nodejs:12-apache +FROM thecodingmachine/nodejs:14-apache COPY --chown=docker:docker . . RUN yarn install diff --git a/front/tsconfig.json b/front/tsconfig.json index 9a140744..b0eac1c0 100644 --- a/front/tsconfig.json +++ b/front/tsconfig.json @@ -3,7 +3,7 @@ "outDir": "./dist/", "sourceMap": true, "moduleResolution": "node", - "module": "ESNext", + "module": "CommonJS", "target": "ES2015", "downlevelIteration": true, "jsx": "react", From e418e8fd091d6701e234873f70e2cbcbcf1ab0db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 10 Sep 2020 09:31:53 +0200 Subject: [PATCH 008/122] Setting the depth of the chat mode / presentation mode to 99999 to avoid melting buttons with map. --- front/src/Phaser/Game/GameScene.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 5ea28b99..8a5630dc 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -397,12 +397,14 @@ export class GameScene extends Phaser.Scene implements CenterListener { this.presentationModeSprite.setOrigin(0, 1); this.presentationModeSprite.setInteractive(); this.presentationModeSprite.setVisible(false); + this.presentationModeSprite.setDepth(99999); this.presentationModeSprite.on('pointerup', this.switchLayoutMode.bind(this)); this.chatModeSprite = this.add.sprite(36, this.game.renderer.height - 2, 'layout_modes', 3); this.chatModeSprite.setScrollFactor(0, 0); this.chatModeSprite.setOrigin(0, 1); this.chatModeSprite.setInteractive(); this.chatModeSprite.setVisible(false); + this.chatModeSprite.setDepth(99999); this.chatModeSprite.on('pointerup', this.switchLayoutMode.bind(this)); // FIXME: change this to use the UserInputManager class for input From 9b702c75e3f17b7a4f200eecc173150b7501cbed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Tue, 15 Sep 2020 10:06:11 +0200 Subject: [PATCH 009/122] Adding batched messages + the notion of notifier / zones (not plugged in the system yet) --- back/src/Controller/IoSocketController.ts | 52 ++++- back/src/Model/PositionNotifier.ts | 106 ++++++++++ back/src/Model/UserInterface.ts | 4 +- back/src/Model/Websocket/ExSocketInterface.ts | 8 + back/src/Model/Websocket/UserMovesMessage.ts | 11 + back/src/Model/Websocket/ViewportMessage.ts | 10 + back/src/Model/World.ts | 4 +- back/src/Model/Zone.ts | 85 ++++++++ back/tests/PositionNotifierTest.ts | 193 ++++++++++++++++++ benchmark/socketio-load-test.yaml | 14 +- benchmark/socketioLoadTest.js | 8 +- front/src/Connection.ts | 37 +++- front/src/Phaser/Game/GameScene.ts | 8 +- 13 files changed, 518 insertions(+), 22 deletions(-) create mode 100644 back/src/Model/PositionNotifier.ts create mode 100644 back/src/Model/Websocket/UserMovesMessage.ts create mode 100644 back/src/Model/Websocket/ViewportMessage.ts create mode 100644 back/src/Model/Zone.ts create mode 100644 back/tests/PositionNotifierTest.ts diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index 34e0dbc8..228a0da8 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -6,8 +6,8 @@ import {ExSocketInterface} from "../Model/Websocket/ExSocketInterface"; //TODO f import Jwt, {JsonWebTokenError} from "jsonwebtoken"; import {SECRET_KEY, MINIMUM_DISTANCE, GROUP_RADIUS, ALLOW_ARTILLERY} from "../Enum/EnvironmentVariable"; //TODO fix import by "_Enum/..." import {World} from "../Model/World"; -import {Group} from "_Model/Group"; -import {UserInterface} from "_Model/UserInterface"; +import {Group} from "../Model/Group"; +import {UserInterface} from "../Model/UserInterface"; import {isSetPlayerDetailsMessage,} from "../Model/Websocket/SetPlayerDetailsMessage"; import {MessageUserJoined} from "../Model/Websocket/MessageUserJoined"; import {MessageUserMoved} from "../Model/Websocket/MessageUserMoved"; @@ -19,12 +19,13 @@ import {isPointInterface, PointInterface} from "../Model/Websocket/PointInterfac import {isWebRtcSignalMessageInterface} from "../Model/Websocket/WebRtcSignalMessage"; import {UserInGroupInterface} from "../Model/Websocket/UserInGroupInterface"; import {uuid} from 'uuidv4'; +import {isUserMovesInterface} from "../Model/Websocket/UserMovesMessage"; enum SockerIoEvent { CONNECTION = "connection", DISCONNECT = "disconnect", JOIN_ROOM = "join-room", // bi-directional - USER_POSITION = "user-position", // bi-directional + USER_POSITION = "user-position", // From client to server USER_MOVED = "user-moved", // From server to client USER_LEFT = "user-left", // From server to client WEBRTC_SIGNAL = "webrtc-signal", @@ -36,6 +37,20 @@ enum SockerIoEvent { GROUP_DELETE = "group-delete", SET_PLAYER_DETAILS = "set-player-details", SET_SILENT = "set_silent", // Set or unset the silent mode for this user. + SET_VIEWPORT = "set-viewport", + BATCH = "batch", +} + +function emitInBatch(socket: ExSocketInterface, event: string | symbol, payload: any): void { + socket.batchedMessages.push({ event, payload}); + + if (socket.batchTimeout === null) { + socket.batchTimeout = setTimeout(() => { + socket.emit(SockerIoEvent.BATCH, socket.batchedMessages); + socket.batchedMessages = []; + socket.batchTimeout = null; + }, 100); + } } export class IoSocketController { @@ -152,6 +167,11 @@ export class IoSocketController { ioConnection() { this.Io.on(SockerIoEvent.CONNECTION, (socket: Socket) => { const client : ExSocketInterface = socket as ExSocketInterface; + client.batchedMessages = []; + client.batchTimeout = null; + client.emitInBatch = (event: string | symbol, payload: any): void => { + emitInBatch(client, event, payload); + } this.sockets.set(client.userId, client); // Let's log server load when a user joins @@ -215,19 +235,20 @@ export class IoSocketController { } }); - socket.on(SockerIoEvent.USER_POSITION, (position: unknown): void => { - console.log(SockerIoEvent.USER_POSITION, position); + socket.on(SockerIoEvent.USER_POSITION, (userMovesMessage: unknown): void => { + console.log(SockerIoEvent.USER_POSITION, userMovesMessage); try { - if (!isPointInterface(position)) { + if (!isUserMovesInterface(userMovesMessage)) { socket.emit(SockerIoEvent.MESSAGE_ERROR, {message: 'Invalid USER_POSITION message.'}); - console.warn('Invalid USER_POSITION message received: ', position); + console.warn('Invalid USER_POSITION message received: ', userMovesMessage); return; } const Client = (socket as ExSocketInterface); // sending to all clients in room except sender - Client.position = position; + Client.position = userMovesMessage.position; + Client.viewport = userMovesMessage.viewport; // update position in the world const world = this.Worlds.get(Client.roomId); @@ -235,9 +256,20 @@ export class IoSocketController { console.error("Could not find world with id '", Client.roomId, "'"); return; } - world.updatePosition(Client, position); + world.updatePosition(Client, Client.position); - socket.to(Client.roomId).emit(SockerIoEvent.USER_MOVED, new MessageUserMoved(Client.userId, Client.position)); + const clientsInRoom = this.Io.sockets.adapter.rooms[Client.roomId]; + console.log('clientsInRoom', clientsInRoom); + for (const clientId in clientsInRoom.sockets) { + console.log('client: %s', clientId); + const targetSocket = this.Io.sockets.connected[clientId] as ExSocketInterface; + if (socket === targetSocket) { + continue; + } + //targetSocket.emit(SockerIoEvent.USER_MOVED, new MessageUserMoved(Client.userId, Client.position)); + targetSocket.emitInBatch(SockerIoEvent.USER_MOVED, new MessageUserMoved(Client.userId, Client.position)); + } + //socket.to(Client.roomId).emit(SockerIoEvent.USER_MOVED, new MessageUserMoved(Client.userId, Client.position)); } catch (e) { console.error('An error occurred on "user_position" event'); console.error(e); diff --git a/back/src/Model/PositionNotifier.ts b/back/src/Model/PositionNotifier.ts new file mode 100644 index 00000000..f5edf8d3 --- /dev/null +++ b/back/src/Model/PositionNotifier.ts @@ -0,0 +1,106 @@ +/** + * Tracks the position of every player on the map, and sends notifications to the players interested in knowing about the move + * (i.e. players that are looking at the zone the player is currently in) + * + * Internally, the PositionNotifier works with Zones. A zone is a square area of a map. + * Each player is in a given zone, and each player tracks one or many zones (depending on the player viewport) + * + * The PositionNotifier is important for performance. It allows us to send the position of players only to a restricted + * number of players around the current player. + */ +import {UserEntersCallback, UserLeavesCallback, UserMovesCallback, Zone} from "./Zone"; +import {PointInterface} from "_Model/Websocket/PointInterface"; +import {UserInterface} from "_Model/UserInterface"; +import {ViewportInterface} from "_Model/Websocket/ViewportMessage"; + +interface ZoneDescriptor { + i: number; + j: number; +} + +export class PositionNotifier { + + // TODO: we need a way to clean the zones if noone is in the zone and noone listening (to free memory!) + + private zones: Zone[][] = []; + + constructor(private zoneWidth: number, private zoneHeight: number, private onUserEnters: UserEntersCallback, private onUserMoves: UserMovesCallback, private onUserLeaves: UserLeavesCallback) { + } + + private getZoneDescriptorFromCoordinates(x: number, y: number): ZoneDescriptor { + return { + i: Math.floor(x / this.zoneWidth), + j: Math.floor(y / this.zoneHeight), + } + } + + public setViewport(user: UserInterface, viewport: ViewportInterface): void { + if (viewport.left > viewport.right || viewport.top > viewport.bottom) { + console.warn('Invalid viewport received: ', viewport); + return; + } + + const oldZones = user.listenedZones; + const newZones = new Set(); + + const topLeftDesc = this.getZoneDescriptorFromCoordinates(viewport.left, viewport.top); + const bottomRightDesc = this.getZoneDescriptorFromCoordinates(viewport.right, viewport.bottom); + + for (let j = topLeftDesc.j; j <= bottomRightDesc.j; j++) { + for (let i = topLeftDesc.i; i <= bottomRightDesc.i; i++) { + newZones.add(this.getZone(i, j)); + } + } + + const addedZones = [...newZones].filter(x => !oldZones.has(x)); + const removedZones = [...oldZones].filter(x => !newZones.has(x)); + + for (const zone of addedZones) { + zone.startListening(user); + } + for (const zone of removedZones) { + zone.stopListening(user); + } + } + + public updatePosition(user: UserInterface, userPosition: PointInterface): void { + // Did we change zone? + const oldZoneDesc = this.getZoneDescriptorFromCoordinates(user.position.x, user.position.y); + const newZoneDesc = this.getZoneDescriptorFromCoordinates(userPosition.x, userPosition.y); + + if (oldZoneDesc.i != newZoneDesc.i || oldZoneDesc.j != newZoneDesc.j) { + const oldZone = this.getZone(oldZoneDesc.i, oldZoneDesc.j); + const newZone = this.getZone(newZoneDesc.i, newZoneDesc.j); + + // Leave old zone + oldZone.leave(user, newZone); + + // Enter new zone + newZone.enter(user, oldZone, userPosition); + } else { + const zone = this.getZone(oldZoneDesc.i, oldZoneDesc.j); + zone.move(user, userPosition); + } + } + + public leave(user: UserInterface): void { + const oldZoneDesc = this.getZoneDescriptorFromCoordinates(user.position.x, user.position.y); + const oldZone = this.getZone(oldZoneDesc.i, oldZoneDesc.j); + oldZone.leave(user, null); + } + + private getZone(i: number, j: number): Zone { + let zoneRow = this.zones[j]; + if (zoneRow === undefined) { + zoneRow = new Array(); + this.zones[j] = zoneRow; + } + + let zone = this.zones[j][i]; + if (zone === undefined) { + zone = new Zone(this.onUserEnters, this.onUserMoves, this.onUserLeaves); + this.zones[j][i] = zone; + } + return zone; + } +} diff --git a/back/src/Model/UserInterface.ts b/back/src/Model/UserInterface.ts index 89994a31..d19ecd6f 100644 --- a/back/src/Model/UserInterface.ts +++ b/back/src/Model/UserInterface.ts @@ -1,9 +1,11 @@ import { Group } from "./Group"; import { PointInterface } from "./Websocket/PointInterface"; +import {Zone} from "_Model/Zone"; export interface UserInterface { id: string, group?: Group, position: PointInterface, - silent: boolean + silent: boolean, + listenedZones: Set } diff --git a/back/src/Model/Websocket/ExSocketInterface.ts b/back/src/Model/Websocket/ExSocketInterface.ts index 974fe63d..c5132eb7 100644 --- a/back/src/Model/Websocket/ExSocketInterface.ts +++ b/back/src/Model/Websocket/ExSocketInterface.ts @@ -2,6 +2,7 @@ import {Socket} from "socket.io"; import {PointInterface} from "./PointInterface"; import {Identificable} from "./Identificable"; import {TokenInterface} from "../../Controller/AuthenticateController"; +import {ViewportInterface} from "_Model/Websocket/ViewportMessage"; export interface ExSocketInterface extends Socket, Identificable { token: string; @@ -11,5 +12,12 @@ export interface ExSocketInterface extends Socket, Identificable { name: string; characterLayers: string[]; position: PointInterface; + viewport: ViewportInterface; isArtillery: boolean; // Whether this socket is opened by Artillery for load testing (hack) + /** + * Pushes an event that will be sent in the next batch of events + */ + emitInBatch: (event: string | symbol, payload: any) => void; + batchedMessages: Array<{ event: string | symbol, payload: any }>; + batchTimeout: NodeJS.Timeout|null; } diff --git a/back/src/Model/Websocket/UserMovesMessage.ts b/back/src/Model/Websocket/UserMovesMessage.ts new file mode 100644 index 00000000..2277d4c4 --- /dev/null +++ b/back/src/Model/Websocket/UserMovesMessage.ts @@ -0,0 +1,11 @@ +import * as tg from "generic-type-guard"; +import {isPointInterface} from "./PointInterface"; +import {isViewport} from "./ViewportMessage"; + + +export const isUserMovesInterface = + new tg.IsInterface().withProperties({ + position: isPointInterface, + viewport: isViewport, + }).get(); +export type UserMovesInterface = tg.GuardedType; diff --git a/back/src/Model/Websocket/ViewportMessage.ts b/back/src/Model/Websocket/ViewportMessage.ts new file mode 100644 index 00000000..62e2fc81 --- /dev/null +++ b/back/src/Model/Websocket/ViewportMessage.ts @@ -0,0 +1,10 @@ +import * as tg from "generic-type-guard"; + +export const isViewport = + new tg.IsInterface().withProperties({ + left: tg.isNumber, + top: tg.isNumber, + right: tg.isNumber, + bottom: tg.isNumber, + }).get(); +export type ViewportInterface = tg.GuardedType; diff --git a/back/src/Model/World.ts b/back/src/Model/World.ts index 8855702e..0f2cb050 100644 --- a/back/src/Model/World.ts +++ b/back/src/Model/World.ts @@ -6,6 +6,7 @@ import {UserInterface} from "./UserInterface"; import {ExSocketInterface} from "_Model/Websocket/ExSocketInterface"; import {PositionInterface} from "_Model/PositionInterface"; import {Identificable} from "_Model/Websocket/Identificable"; +import {Zone} from "_Model/Zone"; export type ConnectCallback = (user: string, group: Group) => void; export type DisconnectCallback = (user: string, group: Group) => void; @@ -56,7 +57,8 @@ export class World { this.users.set(socket.userId, { id: socket.userId, position: userPosition, - silent: false // FIXME: silent should be set at the correct value when joining a room. + silent: false, // FIXME: silent should be set at the correct value when joining a room. + listenedZones: new Set() }); // Let's call update position to trigger the join / leave room this.updatePosition(socket, userPosition); diff --git a/back/src/Model/Zone.ts b/back/src/Model/Zone.ts new file mode 100644 index 00000000..45d6cdd2 --- /dev/null +++ b/back/src/Model/Zone.ts @@ -0,0 +1,85 @@ +import {UserInterface} from "./UserInterface"; +import {PointInterface} from "_Model/Websocket/PointInterface"; +import {PositionInterface} from "_Model/PositionInterface"; + +export type UserEntersCallback = (user: UserInterface) => void; +export type UserMovesCallback = (user: UserInterface, position: PointInterface) => void; +export type UserLeavesCallback = (user: UserInterface) => void; + +export class Zone { + private players: Set = new Set(); + private listeners: Set = new Set(); + + constructor(private onUserEnters: UserEntersCallback, private onUserMoves: UserMovesCallback, private onUserLeaves: UserLeavesCallback) { + } + + /** + * A user leaves the zone + */ + public leave(user: UserInterface, newZone: Zone|null) { + this.players.delete(user); + this.notifyUserLeft(user, newZone); + } + + /** + * Notify listeners of this zone that this user left + */ + private notifyUserLeft(user: UserInterface, newZone: Zone|null) { + for (const listener of this.listeners) { + if (listener !== user && (newZone === null || !listener.listenedZones.has(newZone))) { + this.onUserLeaves(user); + } + } + } + + public enter(user: UserInterface, oldZone: Zone|null, position: PointInterface) { + this.players.add(user); + this.notifyUserEnter(user, oldZone, position); + } + + /** + * Notify listeners of this zone that this user entered + */ + private notifyUserEnter(user: UserInterface, oldZone: Zone|null, position: PointInterface) { + for (const listener of this.listeners) { + if (listener === user) { + continue; + } + if (oldZone === null || !listener.listenedZones.has(oldZone)) { + this.onUserEnters(user); + } else { + this.onUserMoves(user, position); + } + } + } + + public move(user: UserInterface, position: PointInterface) { + for (const listener of this.listeners) { + if (listener !== user) { + this.onUserMoves(user,position); + } + } + } + + public startListening(user: UserInterface): void { + for (const player of this.players) { + if (player !== user) { + this.onUserEnters(user); + } + } + + this.listeners.add(user); + user.listenedZones.add(this); + } + + public stopListening(user: UserInterface): void { + for (const player of this.players) { + if (player !== user) { + this.onUserLeaves(user); + } + } + + this.listeners.delete(user); + user.listenedZones.delete(this); + } +} diff --git a/back/tests/PositionNotifierTest.ts b/back/tests/PositionNotifierTest.ts new file mode 100644 index 00000000..833852b0 --- /dev/null +++ b/back/tests/PositionNotifierTest.ts @@ -0,0 +1,193 @@ +import "jasmine"; +import {World, ConnectCallback, DisconnectCallback } from "../src/Model/World"; +import {Point} from "../src/Model/Websocket/MessageUserPosition"; +import { Group } from "../src/Model/Group"; +import {PositionNotifier} from "../src/Model/PositionNotifier"; +import {UserInterface} from "../src/Model/UserInterface"; +import {PointInterface} from "../src/Model/Websocket/PointInterface"; +import {Zone} from "_Model/Zone"; + +function move(user: UserInterface, x: number, y: number, positionNotifier: PositionNotifier): void { + positionNotifier.updatePosition(user, { + x, + y, + moving: false, + direction: 'down' + }); + user.position.x = x; + user.position.y = y; +} + +describe("PositionNotifier", () => { + it("should receive notifications when player moves", () => { + let enterTriggered = false; + let moveTriggered = false; + let leaveTriggered = false; + + const positionNotifier = new PositionNotifier(300, 300, (user: UserInterface) => { + enterTriggered = true; + }, (user: UserInterface, position: PointInterface) => { + moveTriggered = true; + }, (user: UserInterface) => { + leaveTriggered = true; + }); + + let user1 = { + id: "1", + position: { + x: 500, + y: 500, + moving: false, + direction: 'down' + }, + listenedZones: new Set(), + } as UserInterface; + + let user2 = { + id: "2", + position: { + x: -9999, + y: -9999, + moving: false, + direction: 'down' + }, + listenedZones: new Set(), + } as UserInterface; + + positionNotifier.setViewport(user1, { + left: 200, + right: 600, + top: 100, + bottom: 500 + }); + + move(user2, 500, 500, positionNotifier); + + expect(enterTriggered).toBe(true); + expect(moveTriggered).toBe(false); + enterTriggered = false; + + // Move inside the zone + move(user2, 501, 500, positionNotifier); + + expect(enterTriggered).toBe(false); + expect(moveTriggered).toBe(true); + moveTriggered = false; + + // Move out of the zone in a zone that we don't track + move(user2, 901, 500, positionNotifier); + + expect(enterTriggered).toBe(false); + expect(moveTriggered).toBe(false); + expect(leaveTriggered).toBe(true); + leaveTriggered = false; + + // Move back in + move(user2, 500, 500, positionNotifier); + expect(enterTriggered).toBe(true); + expect(moveTriggered).toBe(false); + expect(leaveTriggered).toBe(false); + enterTriggered = false; + + // Move out of the zone in a zone that we do track + move(user2, 200, 500, positionNotifier); + expect(enterTriggered).toBe(false); + expect(moveTriggered).toBe(true); + expect(leaveTriggered).toBe(false); + moveTriggered = false; + + // Leave the room + positionNotifier.leave(user2); + expect(enterTriggered).toBe(false); + expect(moveTriggered).toBe(false); + expect(leaveTriggered).toBe(true); + leaveTriggered = false; + }); + + it("should receive notifications when camera moves", () => { + let enterTriggered = false; + let moveTriggered = false; + let leaveTriggered = false; + + const positionNotifier = new PositionNotifier(300, 300, (user: UserInterface) => { + enterTriggered = true; + }, (user: UserInterface, position: PointInterface) => { + moveTriggered = true; + }, (user: UserInterface) => { + leaveTriggered = true; + }); + + let user1 = { + id: "1", + position: { + x: 500, + y: 500, + moving: false, + direction: 'down' + }, + listenedZones: new Set(), + } as UserInterface; + + let user2 = { + id: "2", + position: { + x: -9999, + y: -9999, + moving: false, + direction: 'down' + }, + listenedZones: new Set(), + } as UserInterface; + + positionNotifier.setViewport(user1, { + left: 200, + right: 600, + top: 100, + bottom: 500 + }); + + move(user2, 500, 500, positionNotifier); + + expect(enterTriggered).toBe(true); + expect(moveTriggered).toBe(false); + enterTriggered = false; + + // Move the viewport but the user stays inside. + positionNotifier.setViewport(user1, { + left: 201, + right: 601, + top: 100, + bottom: 500 + }); + + expect(enterTriggered).toBe(false); + expect(moveTriggered).toBe(false); + expect(leaveTriggered).toBe(false); + + // Move the viewport out of the user. + positionNotifier.setViewport(user1, { + left: 901, + right: 1001, + top: 100, + bottom: 500 + }); + + expect(enterTriggered).toBe(false); + expect(moveTriggered).toBe(false); + expect(leaveTriggered).toBe(true); + leaveTriggered = false; + + // Move the viewport back on the user. + positionNotifier.setViewport(user1, { + left: 200, + right: 600, + top: 100, + bottom: 500 + }); + + expect(enterTriggered).toBe(true); + expect(moveTriggered).toBe(false); + expect(leaveTriggered).toBe(false); + enterTriggered = false; + }); +}) diff --git a/benchmark/socketio-load-test.yaml b/benchmark/socketio-load-test.yaml index 2f9f689d..e84b0402 100644 --- a/benchmark/socketio-load-test.yaml +++ b/benchmark/socketio-load-test.yaml @@ -34,10 +34,16 @@ scenarios: - emit: channel: "user-position" data: - x: "{{ x }}" - y: "{{ y }}" - direction: 'down' - moving: false + position: + x: "{{ x }}" + y: "{{ y }}" + direction: 'down' + moving: false + viewport: + left: "{{ left }}" + top: "{{ top }}" + right: "{{ right }}" + bottom: "{{ bottom }}" - think: 0.2 count: 100 - think: 10 diff --git a/benchmark/socketioLoadTest.js b/benchmark/socketioLoadTest.js index 907982b2..540cd8bd 100644 --- a/benchmark/socketioLoadTest.js +++ b/benchmark/socketioLoadTest.js @@ -5,7 +5,11 @@ module.exports = { }; function setYRandom(context, events, done) { - context.vars.x = (883 + Math.round(Math.random() * 300)); - context.vars.y = (270 + Math.round(Math.random() * 300)); + context.vars.x = (0 + Math.round(Math.random() * 1472)); + context.vars.y = (0 + Math.round(Math.random() * 1090)); + context.vars.left = context.vars.x - 320; + context.vars.top = context.vars.y - 200; + context.vars.right = context.vars.x + 320; + context.vars.bottom = context.vars.y + 200; return done(); } diff --git a/front/src/Connection.ts b/front/src/Connection.ts index 4a184c52..fd06329d 100644 --- a/front/src/Connection.ts +++ b/front/src/Connection.ts @@ -14,7 +14,7 @@ enum EventMessage{ WEBRTC_SCREEN_SHARING_SIGNAL = "webrtc-screen-sharing-signal", WEBRTC_START = "webrtc-start", JOIN_ROOM = "join-room", // bi-directional - USER_POSITION = "user-position", // bi-directional + USER_POSITION = "user-position", // From client to server USER_MOVED = "user-moved", // From server to client USER_LEFT = "user-left", // From server to client MESSAGE_ERROR = "message-error", @@ -25,6 +25,8 @@ enum EventMessage{ CONNECT_ERROR = "connect_error", SET_SILENT = "set_silent", // Set or unset the silent mode for this user. + SET_VIEWPORT = "set-viewport", + BATCH = "batch", } export interface PointInterface { @@ -95,6 +97,23 @@ export interface StartMapInterface { startInstance: string } +export interface ViewportInterface { + left: number, + top: number, + right: number, + bottom: number, +} + +export interface UserMovesInterface { + position: PositionInterface, + viewport: ViewportInterface, +} + +export interface BatchedMessageInterface { + event: string, + payload: any +} + export class Connection implements Connection { private readonly socket: Socket; private userId: string|null = null; @@ -111,6 +130,18 @@ export class Connection implements Connection { this.socket.on(EventMessage.MESSAGE_ERROR, (message: string) => { console.error(EventMessage.MESSAGE_ERROR, message); }) + + /** + * Messages inside batched messages are extracted and sent to listeners directly. + */ + this.socket.on(EventMessage.BATCH, (batchedMessages: BatchedMessageInterface[]) => { + for (const message of batchedMessages) { + const listeners = this.socket.listeners(message.event); + for (const listener of listeners) { + listener(message.payload); + } + } + }) } public static createConnection(name: string, characterLayersSelected: string[]): Promise { @@ -160,12 +191,12 @@ export class Connection implements Connection { return promise; } - public sharePosition(x : number, y : number, direction : string, moving: boolean) : void{ + public sharePosition(x : number, y : number, direction : string, moving: boolean, viewport: ViewportInterface) : void{ if(!this.socket){ return; } const point = new Point(x, y, direction, moving); - this.socket.emit(EventMessage.USER_POSITION, point); + this.socket.emit(EventMessage.USER_POSITION, { position: point, viewport } as UserMovesInterface); } public setSilent(silent: boolean): void { diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 8a5630dc..595fc9d3 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -677,7 +677,13 @@ export class GameScene extends Phaser.Scene implements CenterListener { private doPushPlayerPosition(event: HasMovedEvent): void { this.lastMoveEventSent = event; this.lastSentTick = this.currentTick; - this.connection.sharePosition(event.x, event.y, event.direction, event.moving); + const camera = this.cameras.main; + this.connection.sharePosition(event.x, event.y, event.direction, event.moving, { + left: camera.scrollX, + top: camera.scrollY, + right: camera.scrollX + camera.width, + bottom: camera.scrollY + camera.height, + }); } EventToClickOnTile(){ From f8d462b0d7231bc244b95b87983103e9d512b31d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Tue, 15 Sep 2020 10:10:35 +0200 Subject: [PATCH 010/122] Fixing "any" type --- back/src/Controller/IoSocketController.ts | 4 ++-- back/src/Model/Websocket/ExSocketInterface.ts | 4 ++-- back/tests/PositionNotifierTest.ts | 8 ++++---- front/src/Connection.ts | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index 228a0da8..e18a5beb 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -41,7 +41,7 @@ enum SockerIoEvent { BATCH = "batch", } -function emitInBatch(socket: ExSocketInterface, event: string | symbol, payload: any): void { +function emitInBatch(socket: ExSocketInterface, event: string | symbol, payload: unknown): void { socket.batchedMessages.push({ event, payload}); if (socket.batchTimeout === null) { @@ -169,7 +169,7 @@ export class IoSocketController { const client : ExSocketInterface = socket as ExSocketInterface; client.batchedMessages = []; client.batchTimeout = null; - client.emitInBatch = (event: string | symbol, payload: any): void => { + client.emitInBatch = (event: string | symbol, payload: unknown): void => { emitInBatch(client, event, payload); } this.sockets.set(client.userId, client); diff --git a/back/src/Model/Websocket/ExSocketInterface.ts b/back/src/Model/Websocket/ExSocketInterface.ts index c5132eb7..bbe18cbb 100644 --- a/back/src/Model/Websocket/ExSocketInterface.ts +++ b/back/src/Model/Websocket/ExSocketInterface.ts @@ -17,7 +17,7 @@ export interface ExSocketInterface extends Socket, Identificable { /** * Pushes an event that will be sent in the next batch of events */ - emitInBatch: (event: string | symbol, payload: any) => void; - batchedMessages: Array<{ event: string | symbol, payload: any }>; + emitInBatch: (event: string | symbol, payload: unknown) => void; + batchedMessages: Array<{ event: string | symbol, payload: unknown }>; batchTimeout: NodeJS.Timeout|null; } diff --git a/back/tests/PositionNotifierTest.ts b/back/tests/PositionNotifierTest.ts index 833852b0..ac82878b 100644 --- a/back/tests/PositionNotifierTest.ts +++ b/back/tests/PositionNotifierTest.ts @@ -32,7 +32,7 @@ describe("PositionNotifier", () => { leaveTriggered = true; }); - let user1 = { + const user1 = { id: "1", position: { x: 500, @@ -43,7 +43,7 @@ describe("PositionNotifier", () => { listenedZones: new Set(), } as UserInterface; - let user2 = { + const user2 = { id: "2", position: { x: -9999, @@ -117,7 +117,7 @@ describe("PositionNotifier", () => { leaveTriggered = true; }); - let user1 = { + const user1 = { id: "1", position: { x: 500, @@ -128,7 +128,7 @@ describe("PositionNotifier", () => { listenedZones: new Set(), } as UserInterface; - let user2 = { + const user2 = { id: "2", position: { x: -9999, diff --git a/front/src/Connection.ts b/front/src/Connection.ts index fd06329d..c04e5b4f 100644 --- a/front/src/Connection.ts +++ b/front/src/Connection.ts @@ -111,7 +111,7 @@ export interface UserMovesInterface { export interface BatchedMessageInterface { event: string, - payload: any + payload: unknown } export class Connection implements Connection { From d24ec0bd75d7930ed698137391357a94d49b3d55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Tue, 15 Sep 2020 16:21:41 +0200 Subject: [PATCH 011/122] Plugin PositionNotifier into the main application. --- back/src/Controller/IoSocketController.ts | 74 ++++++++++++++------- back/src/Model/PositionNotifier.ts | 18 ++++- back/src/Model/Websocket/JoinRoomMessage.ts | 2 + back/src/Model/World.ts | 27 +++++++- back/src/Model/Zone.ts | 45 ++++++++----- back/tests/PositionNotifierTest.ts | 7 +- back/tests/WorldTest.ts | 6 +- back/tsconfig.json | 2 +- front/src/Connection.ts | 16 +++-- front/src/Phaser/Game/GameScene.ts | 35 ++++++++-- 10 files changed, 170 insertions(+), 62 deletions(-) diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index e18a5beb..878c6c75 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -20,6 +20,7 @@ import {isWebRtcSignalMessageInterface} from "../Model/Websocket/WebRtcSignalMes import {UserInGroupInterface} from "../Model/Websocket/UserInGroupInterface"; import {uuid} from 'uuidv4'; import {isUserMovesInterface} from "../Model/Websocket/UserMovesMessage"; +import {isViewport} from "../Model/Websocket/ViewportMessage"; enum SockerIoEvent { CONNECTION = "connection", @@ -212,22 +213,16 @@ export class IoSocketController { //join new previous room const world = this.joinRoom(Client, roomId, message.position); - //add function to refresh position user in real time. - //this.refreshUserPosition(Client); - - const messageUserJoined = new MessageUserJoined(Client.userId, Client.name, Client.characterLayers, Client.position); - - socket.to(roomId).emit(SockerIoEvent.JOIN_ROOM, messageUserJoined); - - // The answer shall contain the list of all users of the room with their positions: - const listOfUsers = Array.from(world.getUsers(), ([key, user]) => { + const users = world.setViewport(Client, message.viewport); + const listOfUsers = users.map((user: UserInterface) => { const player: ExSocketInterface|undefined = this.sockets.get(user.id); if (player === undefined) { console.warn('Something went wrong. The World contains a user "'+user.id+"' but this user does not exist in the sockets list!"); return null; } return new MessageUserPosition(user.id, player.name, player.characterLayers, player.position); - }).filter((item: MessageUserPosition|null) => item !== null); + }, users); + answerFn(listOfUsers); } catch (e) { console.error('An error occurred on "join_room" event'); @@ -235,6 +230,30 @@ export class IoSocketController { } }); + socket.on(SockerIoEvent.SET_VIEWPORT, (message: unknown): void => { + try { + //console.log('SET_VIEWPORT') + if (!isViewport(message)) { + socket.emit(SockerIoEvent.MESSAGE_ERROR, {message: 'Invalid SET_VIEWPORT message.'}); + console.warn('Invalid SET_VIEWPORT message received: ', message); + return; + } + + const Client = (socket as ExSocketInterface); + Client.viewport = message; + + const world = this.Worlds.get(Client.roomId); + if (!world) { + console.error("Could not find world with id '", Client.roomId, "'"); + return; + } + world.setViewport(Client, Client.viewport); + } catch (e) { + console.error('An error occurred on "SET_VIEWPORT" event'); + console.error(e); + } + }); + socket.on(SockerIoEvent.USER_POSITION, (userMovesMessage: unknown): void => { console.log(SockerIoEvent.USER_POSITION, userMovesMessage); try { @@ -257,19 +276,7 @@ export class IoSocketController { return; } world.updatePosition(Client, Client.position); - - const clientsInRoom = this.Io.sockets.adapter.rooms[Client.roomId]; - console.log('clientsInRoom', clientsInRoom); - for (const clientId in clientsInRoom.sockets) { - console.log('client: %s', clientId); - const targetSocket = this.Io.sockets.connected[clientId] as ExSocketInterface; - if (socket === targetSocket) { - continue; - } - //targetSocket.emit(SockerIoEvent.USER_MOVED, new MessageUserMoved(Client.userId, Client.position)); - targetSocket.emitInBatch(SockerIoEvent.USER_MOVED, new MessageUserMoved(Client.userId, Client.position)); - } - //socket.to(Client.roomId).emit(SockerIoEvent.USER_MOVED, new MessageUserMoved(Client.userId, Client.position)); + world.setViewport(Client, Client.viewport); } catch (e) { console.error('An error occurred on "user_position" event'); console.error(e); @@ -404,8 +411,6 @@ export class IoSocketController { // leave previous room and world if(Client.roomId){ try { - Client.to(Client.roomId).emit(SockerIoEvent.USER_LEFT, Client.userId); - //user leave previous world const world: World | undefined = this.Worlds.get(Client.roomId); if (world) { @@ -441,6 +446,25 @@ export class IoSocketController { this.sendUpdateGroupEvent(group); }, (groupUuid: string, lastUser: UserInterface) => { this.sendDeleteGroupEvent(groupUuid, lastUser); + }, (user, listener) => { + const clientUser = this.searchClientByIdOrFail(user.id); + const clientListener = this.searchClientByIdOrFail(listener.id); + const messageUserJoined = new MessageUserJoined(clientUser.userId, clientUser.name, clientUser.characterLayers, clientUser.position); + + clientListener.emit(SockerIoEvent.JOIN_ROOM, messageUserJoined); + //console.log("Sending JOIN_ROOM event"); + }, (user, position, listener) => { + const clientUser = this.searchClientByIdOrFail(user.id); + const clientListener = this.searchClientByIdOrFail(listener.id); + + clientListener.emitInBatch(SockerIoEvent.USER_MOVED, new MessageUserMoved(clientUser.userId, clientUser.position)); + //console.log("Sending USER_MOVED event"); + }, (user, listener) => { + const clientUser = this.searchClientByIdOrFail(user.id); + const clientListener = this.searchClientByIdOrFail(listener.id); + + clientListener.emit(SockerIoEvent.USER_LEFT, clientUser.userId); + //console.log("Sending USER_LEFT event"); }); this.Worlds.set(roomId, world); } diff --git a/back/src/Model/PositionNotifier.ts b/back/src/Model/PositionNotifier.ts index f5edf8d3..9d6975e3 100644 --- a/back/src/Model/PositionNotifier.ts +++ b/back/src/Model/PositionNotifier.ts @@ -34,10 +34,14 @@ export class PositionNotifier { } } - public setViewport(user: UserInterface, viewport: ViewportInterface): void { + /** + * Sets the viewport coordinates. + * Returns the list of new users to add + */ + public setViewport(user: UserInterface, viewport: ViewportInterface): UserInterface[] { if (viewport.left > viewport.right || viewport.top > viewport.bottom) { console.warn('Invalid viewport received: ', viewport); - return; + return []; } const oldZones = user.listenedZones; @@ -55,12 +59,17 @@ export class PositionNotifier { const addedZones = [...newZones].filter(x => !oldZones.has(x)); const removedZones = [...oldZones].filter(x => !newZones.has(x)); + + let users: UserInterface[] = []; for (const zone of addedZones) { zone.startListening(user); + users = users.concat(Array.from(zone.getPlayers())) } for (const zone of removedZones) { zone.stopListening(user); } + + return users; } public updatePosition(user: UserInterface, userPosition: PointInterface): void { @@ -87,6 +96,11 @@ export class PositionNotifier { const oldZoneDesc = this.getZoneDescriptorFromCoordinates(user.position.x, user.position.y); const oldZone = this.getZone(oldZoneDesc.i, oldZoneDesc.j); oldZone.leave(user, null); + + // Also, let's stop listening on viewports + for (const zone of user.listenedZones) { + zone.stopListening(user); + } } private getZone(i: number, j: number): Zone { diff --git a/back/src/Model/Websocket/JoinRoomMessage.ts b/back/src/Model/Websocket/JoinRoomMessage.ts index 16613488..2036a441 100644 --- a/back/src/Model/Websocket/JoinRoomMessage.ts +++ b/back/src/Model/Websocket/JoinRoomMessage.ts @@ -1,9 +1,11 @@ import * as tg from "generic-type-guard"; import {isPointInterface} from "./PointInterface"; +import {isViewport} from "./ViewportMessage"; export const isJoinRoomMessageInterface = new tg.IsInterface().withProperties({ roomId: tg.isString, position: isPointInterface, + viewport: isViewport }).get(); export type JoinRoomMessageInterface = tg.GuardedType; diff --git a/back/src/Model/World.ts b/back/src/Model/World.ts index 0f2cb050..4422e95f 100644 --- a/back/src/Model/World.ts +++ b/back/src/Model/World.ts @@ -6,7 +6,9 @@ import {UserInterface} from "./UserInterface"; import {ExSocketInterface} from "_Model/Websocket/ExSocketInterface"; import {PositionInterface} from "_Model/PositionInterface"; import {Identificable} from "_Model/Websocket/Identificable"; -import {Zone} from "_Model/Zone"; +import {UserEntersCallback, UserLeavesCallback, UserMovesCallback, Zone} from "_Model/Zone"; +import {PositionNotifier} from "./PositionNotifier"; +import {ViewportInterface} from "_Model/Websocket/ViewportMessage"; export type ConnectCallback = (user: string, group: Group) => void; export type DisconnectCallback = (user: string, group: Group) => void; @@ -28,12 +30,17 @@ export class World { private readonly groupUpdatedCallback: GroupUpdatedCallback; private readonly groupDeletedCallback: GroupDeletedCallback; + private readonly positionNotifier: PositionNotifier; + constructor(connectCallback: ConnectCallback, disconnectCallback: DisconnectCallback, minDistance: number, groupRadius: number, groupUpdatedCallback: GroupUpdatedCallback, - groupDeletedCallback: GroupDeletedCallback) + groupDeletedCallback: GroupDeletedCallback, + onUserEnters: UserEntersCallback, + onUserMoves: UserMovesCallback, + onUserLeaves: UserLeavesCallback) { this.users = new Map(); this.groups = new Set(); @@ -43,6 +50,8 @@ export class World { this.groupRadius = groupRadius; this.groupUpdatedCallback = groupUpdatedCallback; this.groupDeletedCallback = groupDeletedCallback; + // A zone is 10 sprites wide. + this.positionNotifier = new PositionNotifier(320, 320, onUserEnters, onUserMoves, onUserLeaves); } public getGroups(): Group[] { @@ -73,6 +82,10 @@ export class World { this.leaveGroup(userObj); } this.users.delete(user.userId); + + if (userObj !== undefined) { + this.positionNotifier.leave(userObj); + } } public isEmpty(): boolean { @@ -85,6 +98,8 @@ export class World { return; } + this.positionNotifier.updatePosition(user, userPosition); + user.position = userPosition; if (user.silent) { @@ -318,4 +333,12 @@ export class World { } return 0; }*/ + setViewport(socket : Identificable, viewport: ViewportInterface): UserInterface[] { + const user = this.users.get(socket.userId); + if(typeof user === 'undefined') { + console.warn('In setViewport, could not find user with ID "'+socket.userId+'" in world.'); + return []; + } + return this.positionNotifier.setViewport(user, viewport); + } } diff --git a/back/src/Model/Zone.ts b/back/src/Model/Zone.ts index 45d6cdd2..bd748b0f 100644 --- a/back/src/Model/Zone.ts +++ b/back/src/Model/Zone.ts @@ -2,9 +2,9 @@ import {UserInterface} from "./UserInterface"; import {PointInterface} from "_Model/Websocket/PointInterface"; import {PositionInterface} from "_Model/PositionInterface"; -export type UserEntersCallback = (user: UserInterface) => void; -export type UserMovesCallback = (user: UserInterface, position: PointInterface) => void; -export type UserLeavesCallback = (user: UserInterface) => void; +export type UserEntersCallback = (user: UserInterface, listener: UserInterface) => void; +export type UserMovesCallback = (user: UserInterface, position: PointInterface, listener: UserInterface) => void; +export type UserLeavesCallback = (user: UserInterface, listener: UserInterface) => void; export class Zone { private players: Set = new Set(); @@ -27,7 +27,7 @@ export class Zone { private notifyUserLeft(user: UserInterface, newZone: Zone|null) { for (const listener of this.listeners) { if (listener !== user && (newZone === null || !listener.listenedZones.has(newZone))) { - this.onUserLeaves(user); + this.onUserLeaves(user, listener); } } } @@ -46,40 +46,51 @@ export class Zone { continue; } if (oldZone === null || !listener.listenedZones.has(oldZone)) { - this.onUserEnters(user); + this.onUserEnters(user, listener); } else { - this.onUserMoves(user, position); + this.onUserMoves(user, position, listener); } } } public move(user: UserInterface, position: PointInterface) { + if (!this.players.has(user)) { + this.players.add(user); + const foo = this.players; + this.notifyUserEnter(user, null, position); + return; + } + for (const listener of this.listeners) { if (listener !== user) { - this.onUserMoves(user,position); + this.onUserMoves(user,position, listener); } } } - public startListening(user: UserInterface): void { + public startListening(listener: UserInterface): void { for (const player of this.players) { - if (player !== user) { - this.onUserEnters(user); + if (player !== listener) { + this.onUserEnters(player, listener); } } - this.listeners.add(user); - user.listenedZones.add(this); + this.listeners.add(listener); + listener.listenedZones.add(this); } - public stopListening(user: UserInterface): void { + public stopListening(listener: UserInterface): void { for (const player of this.players) { - if (player !== user) { - this.onUserLeaves(user); + if (player !== listener) { + this.onUserLeaves(player, listener); } } - this.listeners.delete(user); - user.listenedZones.delete(this); + this.listeners.delete(listener); + listener.listenedZones.delete(this); + } + + public getPlayers(): Set { + return this.players; } } diff --git a/back/tests/PositionNotifierTest.ts b/back/tests/PositionNotifierTest.ts index ac82878b..0b8b466f 100644 --- a/back/tests/PositionNotifierTest.ts +++ b/back/tests/PositionNotifierTest.ts @@ -139,13 +139,15 @@ describe("PositionNotifier", () => { listenedZones: new Set(), } as UserInterface; - positionNotifier.setViewport(user1, { + let newUsers = positionNotifier.setViewport(user1, { left: 200, right: 600, top: 100, bottom: 500 }); + expect(newUsers.length).toBe(0); + move(user2, 500, 500, positionNotifier); expect(enterTriggered).toBe(true); @@ -178,7 +180,7 @@ describe("PositionNotifier", () => { leaveTriggered = false; // Move the viewport back on the user. - positionNotifier.setViewport(user1, { + newUsers = positionNotifier.setViewport(user1, { left: 200, right: 600, top: 100, @@ -189,5 +191,6 @@ describe("PositionNotifier", () => { expect(moveTriggered).toBe(false); expect(leaveTriggered).toBe(false); enterTriggered = false; + expect(newUsers.length).toBe(1); }); }) diff --git a/back/tests/WorldTest.ts b/back/tests/WorldTest.ts index c436eed7..580677c7 100644 --- a/back/tests/WorldTest.ts +++ b/back/tests/WorldTest.ts @@ -13,7 +13,7 @@ describe("World", () => { } - const world = new World(connect, disconnect, 160, 160, () => {}, () => {}); + const world = new World(connect, disconnect, 160, 160, () => {}, () => {}, () => {}, () => {}, () => {}); world.join({ userId: "foo" }, new Point(100, 100)); @@ -40,7 +40,7 @@ describe("World", () => { } - const world = new World(connect, disconnect, 160, 160, () => {}, () => {}); + const world = new World(connect, disconnect, 160, 160, () => {}, () => {}, () => {}, () => {}, () => {}); world.join({ userId: "foo" }, new Point(100, 100)); @@ -69,7 +69,7 @@ describe("World", () => { disconnectCallNumber++; } - const world = new World(connect, disconnect, 160, 160, () => {}, () => {}); + const world = new World(connect, disconnect, 160, 160, () => {}, () => {}, () => {}, () => {}, () => {}); world.join({ userId: "foo" }, new Point(100, 100)); diff --git a/back/tsconfig.json b/back/tsconfig.json index 397bb8a2..de6314a3 100644 --- a/back/tsconfig.json +++ b/back/tsconfig.json @@ -12,7 +12,7 @@ // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ // "declaration": true, /* Generates corresponding '.d.ts' file. */ // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ - // "sourceMap": true, /* Generates corresponding '.map' file. */ + "sourceMap": true, /* Generates corresponding '.map' file. */ // "outFile": "./", /* Concatenate and emit output to single file. */ "outDir": "./dist", /* Redirect output structure to the directory. */ // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ diff --git a/front/src/Connection.ts b/front/src/Connection.ts index c04e5b4f..dee27ae5 100644 --- a/front/src/Connection.ts +++ b/front/src/Connection.ts @@ -182,11 +182,15 @@ export class Connection implements Connection { } - public joinARoom(roomId: string, startX: number, startY: number, direction: string, moving: boolean): Promise { + public joinARoom(roomId: string, startX: number, startY: number, direction: string, moving: boolean, viewport: ViewportInterface): Promise { const promise = new Promise((resolve, reject) => { - this.socket.emit(EventMessage.JOIN_ROOM, { roomId, position: {x: startX, y: startY, direction, moving }}, (userPositions: MessageUserPositionInterface[]) => { - resolve(userPositions); - }); + this.socket.emit(EventMessage.JOIN_ROOM, { + roomId, + position: {x: startX, y: startY, direction, moving }, + viewport, + }, (userPositions: MessageUserPositionInterface[]) => { + resolve(userPositions); + }); }) return promise; } @@ -203,6 +207,10 @@ export class Connection implements Connection { this.socket.emit(EventMessage.SET_SILENT, silent); } + public setViewport(viewport: ViewportInterface): void { + this.socket.emit(EventMessage.SET_VIEWPORT, viewport); + } + public onUserJoins(callback: (message: MessageUserJoined) => void): void { this.socket.on(EventMessage.JOIN_ROOM, callback); } diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 595fc9d3..6a6656c2 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -111,7 +111,7 @@ export class GameScene extends Phaser.Scene implements CenterListener { private startLayerName: string|undefined; private presentationModeSprite!: Sprite; private chatModeSprite!: Sprite; - private repositionCallback!: (this: Window, ev: UIEvent) => void; + private onResizeCallback!: (this: Window, ev: UIEvent) => void; private gameMap!: GameMap; static createFromUrl(mapUrlFile: string, instance: string, key: string|null = null): GameScene { @@ -226,7 +226,7 @@ export class GameScene extends Phaser.Scene implements CenterListener { this.scene.stop(this.scene.key); this.scene.remove(this.scene.key); - window.removeEventListener('resize', this.repositionCallback); + window.removeEventListener('resize', this.onResizeCallback); }) // When connection is performed, let's connect SimplePeer @@ -412,8 +412,8 @@ export class GameScene extends Phaser.Scene implements CenterListener { this.switchLayoutMode(); }); - this.repositionCallback = this.reposition.bind(this); - window.addEventListener('resize', this.repositionCallback); + this.onResizeCallback = this.onResize.bind(this); + window.addEventListener('resize', this.onResizeCallback); this.reposition(); // From now, this game scene will be notified of reposition events @@ -636,7 +636,17 @@ export class GameScene extends Phaser.Scene implements CenterListener { //join room this.connectionPromise.then((connection: Connection) => { - connection.joinARoom(this.RoomId, this.startX, this.startY, PlayerAnimationNames.WalkDown, false).then((userPositions: MessageUserPositionInterface[]) => { + const camera = this.cameras.main; + connection.joinARoom(this.RoomId, + this.startX, + this.startY, + PlayerAnimationNames.WalkDown, + false, { + left: camera.scrollX, + top: camera.scrollY, + right: camera.scrollX + camera.width, + bottom: camera.scrollY + camera.height, + }).then((userPositions: MessageUserPositionInterface[]) => { this.initUsersPosition(userPositions); }); @@ -747,7 +757,7 @@ export class GameScene extends Phaser.Scene implements CenterListener { this.simplePeer.unregister(); this.scene.stop(); this.scene.remove(this.scene.key); - window.removeEventListener('resize', this.repositionCallback); + window.removeEventListener('resize', this.onResizeCallback); this.scene.start(nextSceneKey.key, { startLayerName: nextSceneKey.hash }); @@ -936,6 +946,19 @@ export class GameScene extends Phaser.Scene implements CenterListener { return mapUrlStart.substring(startPos, endPos); } + private onResize(): void { + this.reposition(); + + // Send new viewport to server + const camera = this.cameras.main; + this.connection.setViewport({ + left: camera.scrollX, + top: camera.scrollY, + right: camera.scrollX + camera.width, + bottom: camera.scrollY + camera.height, + }); + } + private reposition(): void { this.presentationModeSprite.setY(this.game.renderer.height - 2); this.chatModeSprite.setY(this.game.renderer.height - 2); From 7e7b42ce19eb64502b1af2a1c9443bef000b0016 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 16 Sep 2020 09:31:44 +0200 Subject: [PATCH 012/122] Changing load test to run in circles --- back/src/Controller/IoSocketController.ts | 16 ++++++++++++---- benchmark/socketio-load-test.yaml | 5 +++++ benchmark/socketioLoadTest.js | 9 +++++++-- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index 878c6c75..c1c00761 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -223,6 +223,14 @@ export class IoSocketController { return new MessageUserPosition(user.id, player.name, player.characterLayers, player.position); }, users); + //console.warn('ANSWER PLAYER POSITIONS', listOfUsers); + if (answerFn === undefined && ALLOW_ARTILLERY === true) { + /*console.error("TYPEOF answerFn", typeof(answerFn)); + console.error("answerFn", answerFn); + process.exit(1)*/ + // For some reason, answerFn can be undefined if we use Artillery (?) + return; + } answerFn(listOfUsers); } catch (e) { console.error('An error occurred on "join_room" event'); @@ -244,7 +252,7 @@ export class IoSocketController { const world = this.Worlds.get(Client.roomId); if (!world) { - console.error("Could not find world with id '", Client.roomId, "'"); + console.error("In SET_VIEWPORT, could not find world with id '", Client.roomId, "'"); return; } world.setViewport(Client, Client.viewport); @@ -255,7 +263,7 @@ export class IoSocketController { }); socket.on(SockerIoEvent.USER_POSITION, (userMovesMessage: unknown): void => { - console.log(SockerIoEvent.USER_POSITION, userMovesMessage); + //console.log(SockerIoEvent.USER_POSITION, userMovesMessage); try { if (!isUserMovesInterface(userMovesMessage)) { socket.emit(SockerIoEvent.MESSAGE_ERROR, {message: 'Invalid USER_POSITION message.'}); @@ -272,7 +280,7 @@ export class IoSocketController { // update position in the world const world = this.Worlds.get(Client.roomId); if (!world) { - console.error("Could not find world with id '", Client.roomId, "'"); + console.error("In USER_POSITION, could not find world with id '", Client.roomId, "'"); return; } world.updatePosition(Client, Client.position); @@ -351,7 +359,7 @@ export class IoSocketController { // update position in the world const world = this.Worlds.get(Client.roomId); if (!world) { - console.error("Could not find world with id '", Client.roomId, "'"); + console.error("In SET_SILENT, could not find world with id '", Client.roomId, "'"); return; } world.setSilent(Client, silent); diff --git a/benchmark/socketio-load-test.yaml b/benchmark/socketio-load-test.yaml index e84b0402..df2f580b 100644 --- a/benchmark/socketio-load-test.yaml +++ b/benchmark/socketio-load-test.yaml @@ -28,6 +28,11 @@ scenarios: y: 170 direction: 'down' moving: false + viewport: + left: 500 + top: 0 + right: 800 + bottom: 200 - think: 1 - loop: - function: "setYRandom" diff --git a/benchmark/socketioLoadTest.js b/benchmark/socketioLoadTest.js index 540cd8bd..f898d7b9 100644 --- a/benchmark/socketioLoadTest.js +++ b/benchmark/socketioLoadTest.js @@ -5,8 +5,13 @@ module.exports = { }; function setYRandom(context, events, done) { - context.vars.x = (0 + Math.round(Math.random() * 1472)); - context.vars.y = (0 + Math.round(Math.random() * 1090)); + if (context.angle === undefined) { + context.angle = Math.random() * Math.PI * 2; + } + context.angle += 0.05; + + context.vars.x = 320 + 1472/2 * (1 + Math.sin(context.angle)); + context.vars.y = 200 + 1090/2 * (1 + Math.cos(context.angle)); context.vars.left = context.vars.x - 320; context.vars.top = context.vars.y - 200; context.vars.right = context.vars.x + 320; From f5f9dcac04dcc13c66aa2e0dab550d5357dcf96c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 16 Sep 2020 16:06:43 +0200 Subject: [PATCH 013/122] Making groups part of zones --- back/src/Controller/IoSocketController.ts | 97 +++++++++++++------ back/src/Model/Group.ts | 21 ++-- back/src/Model/Movable.ts | 8 ++ back/src/Model/PositionNotifier.ts | 37 ++++--- back/src/Model/User.ts | 23 +++++ back/src/Model/UserInterface.ts | 11 --- .../Model/Websocket/GroupUpdateInterface.ts | 6 ++ back/src/Model/World.ts | 58 +++++------ back/src/Model/Zone.ts | 80 +++++++-------- back/tests/PositionNotifierTest.ts | 88 +++++++---------- front/src/Connection.ts | 3 +- front/src/Phaser/Game/GameScene.ts | 1 + 12 files changed, 245 insertions(+), 188 deletions(-) create mode 100644 back/src/Model/Movable.ts create mode 100644 back/src/Model/User.ts delete mode 100644 back/src/Model/UserInterface.ts create mode 100644 back/src/Model/Websocket/GroupUpdateInterface.ts diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index 1ce0c2db..f220aedb 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -7,7 +7,7 @@ import Jwt, {JsonWebTokenError} from "jsonwebtoken"; import {SECRET_KEY, MINIMUM_DISTANCE, GROUP_RADIUS, ALLOW_ARTILLERY} from "../Enum/EnvironmentVariable"; //TODO fix import by "_Enum/..." import {World} from "../Model/World"; import {Group} from "../Model/Group"; -import {UserInterface} from "../Model/UserInterface"; +import {User} from "../Model/User"; import {isSetPlayerDetailsMessage,} from "../Model/Websocket/SetPlayerDetailsMessage"; import {MessageUserJoined} from "../Model/Websocket/MessageUserJoined"; import {MessageUserMoved} from "../Model/Websocket/MessageUserMoved"; @@ -22,6 +22,8 @@ import {isItemEventMessageInterface} from "../Model/Websocket/ItemEventMessage"; import {uuid} from 'uuidv4'; import {isUserMovesInterface} from "../Model/Websocket/UserMovesMessage"; import {isViewport} from "../Model/Websocket/ViewportMessage"; +import {GroupUpdateInterface} from "_Model/Websocket/GroupUpdateInterface"; +import {Movable} from "../Model/Movable"; enum SockerIoEvent { CONNECTION = "connection", @@ -159,7 +161,7 @@ export class IoSocketController { }); } - private sendDeleteGroupEvent(uuid: string, lastUser: UserInterface): void { + private sendDeleteGroupEvent(uuid: string, lastUser: User): void { // Let's get the room of the group. To do this, let's get anyone in the group and find its room. const userId = lastUser.id; const client: ExSocketInterface = this.searchClientByIdOrFail(userId); @@ -215,15 +217,29 @@ export class IoSocketController { //join new previous room const world = this.joinRoom(Client, roomId, message.position); - const users = world.setViewport(Client, message.viewport); - const listOfUsers = users.map((user: UserInterface) => { - const player: ExSocketInterface|undefined = this.sockets.get(user.id); - if (player === undefined) { - console.warn('Something went wrong. The World contains a user "'+user.id+"' but this user does not exist in the sockets list!"); - return null; + const things = world.setViewport(Client, message.viewport); + + const listOfUsers: Array = []; + const listOfGroups: Array = []; + + for (const thing of things) { + if (thing instanceof User) { + const player: ExSocketInterface|undefined = this.sockets.get(thing.id); + if (player === undefined) { + console.warn('Something went wrong. The World contains a user "'+thing.id+"' but this user does not exist in the sockets list!"); + continue; + } + + listOfUsers.push(new MessageUserPosition(thing.id, player.name, player.characterLayers, player.position)); + } else if (thing instanceof Group) { + listOfGroups.push({ + groupId: thing.getId(), + position: thing.getPosition(), + }); + } else { + console.error("Unexpected type for Movable returned by setViewport"); } - return new MessageUserPosition(user.id, player.name, player.characterLayers, player.position); - }, users); + } const listOfItems: {[itemId: string]: unknown} = {}; for (const [itemId, item] of world.getItemsState().entries()) { @@ -232,15 +248,13 @@ export class IoSocketController { //console.warn('ANSWER PLAYER POSITIONS', listOfUsers); if (answerFn === undefined && ALLOW_ARTILLERY === true) { - /*console.error("TYPEOF answerFn", typeof(answerFn)); - console.error("answerFn", answerFn); - process.exit(1)*/ // For some reason, answerFn can be undefined if we use Artillery (?) return; } answerFn({ users: listOfUsers, + groups: listOfGroups, items: listOfItems }); } catch (e) { @@ -485,28 +499,51 @@ export class IoSocketController { }, (user1: string, group: Group) => { this.disConnectedUser(user1, group); }, MINIMUM_DISTANCE, GROUP_RADIUS, (group: Group) => { - this.sendUpdateGroupEvent(group); - }, (groupUuid: string, lastUser: UserInterface) => { - this.sendDeleteGroupEvent(groupUuid, lastUser); - }, (user, listener) => { - const clientUser = this.searchClientByIdOrFail(user.id); + //this.sendUpdateGroupEvent(group); + }, (groupUuid: string, lastUser: User) => { + //this.sendDeleteGroupEvent(groupUuid, lastUser); + }, (thing: Movable, listener: User) => { const clientListener = this.searchClientByIdOrFail(listener.id); - const messageUserJoined = new MessageUserJoined(clientUser.userId, clientUser.name, clientUser.characterLayers, clientUser.position); + if (thing instanceof User) { + const clientUser = this.searchClientByIdOrFail(thing.id); + const messageUserJoined = new MessageUserJoined(clientUser.userId, clientUser.name, clientUser.characterLayers, clientUser.position); - clientListener.emit(SockerIoEvent.JOIN_ROOM, messageUserJoined); - //console.log("Sending JOIN_ROOM event"); - }, (user, position, listener) => { - const clientUser = this.searchClientByIdOrFail(user.id); + clientListener.emit(SockerIoEvent.JOIN_ROOM, messageUserJoined); + } else if (thing instanceof Group) { + clientListener.emit(SockerIoEvent.GROUP_CREATE_UPDATE, { + position: thing.getPosition(), + groupId: thing.getId() + } as GroupUpdateInterface); + } else { + console.error('Unexpected type for Movable.'); + } + }, (thing: Movable, position, listener) => { const clientListener = this.searchClientByIdOrFail(listener.id); + if (thing instanceof User) { + const clientUser = this.searchClientByIdOrFail(thing.id); - clientListener.emitInBatch(SockerIoEvent.USER_MOVED, new MessageUserMoved(clientUser.userId, clientUser.position)); - //console.log("Sending USER_MOVED event"); - }, (user, listener) => { - const clientUser = this.searchClientByIdOrFail(user.id); + clientListener.emitInBatch(SockerIoEvent.USER_MOVED, new MessageUserMoved(clientUser.userId, clientUser.position)); + //console.log("Sending USER_MOVED event"); + } else if (thing instanceof Group) { + clientListener.emit(SockerIoEvent.GROUP_CREATE_UPDATE, { + position: thing.getPosition(), + groupId: thing.getId() + } as GroupUpdateInterface); + } else { + console.error('Unexpected type for Movable.'); + } + }, (thing: Movable, listener) => { const clientListener = this.searchClientByIdOrFail(listener.id); + if (thing instanceof User) { + const clientUser = this.searchClientByIdOrFail(thing.id); + clientListener.emit(SockerIoEvent.USER_LEFT, clientUser.userId); + //console.log("Sending USER_LEFT event"); + } else if (thing instanceof Group) { + clientListener.emit(SockerIoEvent.GROUP_DELETE, thing.getId()); + } else { + console.error('Unexpected type for Movable.'); + } - clientListener.emit(SockerIoEvent.USER_LEFT, clientUser.userId); - //console.log("Sending USER_LEFT event"); }); this.Worlds.set(roomId, world); } @@ -516,7 +553,7 @@ export class IoSocketController { Client.emit(SockerIoEvent.GROUP_CREATE_UPDATE, { position: group.getPosition(), groupId: group.getId() - }); + } as GroupUpdateInterface); }); //join world world.join(Client, Client.position); diff --git a/back/src/Model/Group.ts b/back/src/Model/Group.ts index 4c597557..4909b660 100644 --- a/back/src/Model/Group.ts +++ b/back/src/Model/Group.ts @@ -1,29 +1,30 @@ import { World, ConnectCallback, DisconnectCallback } from "./World"; -import { UserInterface } from "./UserInterface"; +import { User } from "./User"; import {PositionInterface} from "_Model/PositionInterface"; import {uuid} from "uuidv4"; +import {Movable} from "_Model/Movable"; -export class Group { +export class Group implements Movable { static readonly MAX_PER_GROUP = 4; private id: string; - private users: Set; + private users: Set; private connectCallback: ConnectCallback; private disconnectCallback: DisconnectCallback; - constructor(users: UserInterface[], connectCallback: ConnectCallback, disconnectCallback: DisconnectCallback) { - this.users = new Set(); + constructor(users: User[], connectCallback: ConnectCallback, disconnectCallback: DisconnectCallback) { + this.users = new Set(); this.connectCallback = connectCallback; this.disconnectCallback = disconnectCallback; this.id = uuid(); - users.forEach((user: UserInterface) => { + users.forEach((user: User) => { this.join(user); }); } - getUsers(): UserInterface[] { + getUsers(): User[] { return Array.from(this.users.values()); } @@ -38,7 +39,7 @@ export class Group { let x = 0; let y = 0; // Let's compute the barycenter of all users. - this.users.forEach((user: UserInterface) => { + this.users.forEach((user: User) => { x += user.position.x; y += user.position.y; }); @@ -58,7 +59,7 @@ export class Group { return this.users.size <= 1; } - join(user: UserInterface): void + join(user: User): void { // Broadcast on the right event this.connectCallback(user.id, this); @@ -66,7 +67,7 @@ export class Group { user.group = this; } - leave(user: UserInterface): void + leave(user: User): void { const success = this.users.delete(user); if (success === false) { diff --git a/back/src/Model/Movable.ts b/back/src/Model/Movable.ts new file mode 100644 index 00000000..173db0ae --- /dev/null +++ b/back/src/Model/Movable.ts @@ -0,0 +1,8 @@ +import {PositionInterface} from "_Model/PositionInterface"; + +/** + * A physical object that can be placed into a Zone + */ +export interface Movable { + getPosition(): PositionInterface +} diff --git a/back/src/Model/PositionNotifier.ts b/back/src/Model/PositionNotifier.ts index 9d6975e3..0e5b4b2f 100644 --- a/back/src/Model/PositionNotifier.ts +++ b/back/src/Model/PositionNotifier.ts @@ -8,10 +8,12 @@ * The PositionNotifier is important for performance. It allows us to send the position of players only to a restricted * number of players around the current player. */ -import {UserEntersCallback, UserLeavesCallback, UserMovesCallback, Zone} from "./Zone"; +import {EntersCallback, LeavesCallback, MovesCallback, Zone} from "./Zone"; import {PointInterface} from "_Model/Websocket/PointInterface"; -import {UserInterface} from "_Model/UserInterface"; +import {User} from "_Model/User"; import {ViewportInterface} from "_Model/Websocket/ViewportMessage"; +import {Movable} from "_Model/Movable"; +import {PositionInterface} from "_Model/PositionInterface"; interface ZoneDescriptor { i: number; @@ -24,7 +26,7 @@ export class PositionNotifier { private zones: Zone[][] = []; - constructor(private zoneWidth: number, private zoneHeight: number, private onUserEnters: UserEntersCallback, private onUserMoves: UserMovesCallback, private onUserLeaves: UserLeavesCallback) { + constructor(private zoneWidth: number, private zoneHeight: number, private onUserEnters: EntersCallback, private onUserMoves: MovesCallback, private onUserLeaves: LeavesCallback) { } private getZoneDescriptorFromCoordinates(x: number, y: number): ZoneDescriptor { @@ -38,7 +40,7 @@ export class PositionNotifier { * Sets the viewport coordinates. * Returns the list of new users to add */ - public setViewport(user: UserInterface, viewport: ViewportInterface): UserInterface[] { + public setViewport(user: User, viewport: ViewportInterface): Movable[] { if (viewport.left > viewport.right || viewport.top > viewport.bottom) { console.warn('Invalid viewport received: ', viewport); return []; @@ -60,43 +62,46 @@ export class PositionNotifier { const removedZones = [...oldZones].filter(x => !newZones.has(x)); - let users: UserInterface[] = []; + let things: Movable[] = []; for (const zone of addedZones) { zone.startListening(user); - users = users.concat(Array.from(zone.getPlayers())) + things = things.concat(Array.from(zone.getThings())) } for (const zone of removedZones) { zone.stopListening(user); } - return users; + return things; } - public updatePosition(user: UserInterface, userPosition: PointInterface): void { + public updatePosition(thing: Movable, newPosition: PositionInterface, oldPosition: PositionInterface): void { // Did we change zone? - const oldZoneDesc = this.getZoneDescriptorFromCoordinates(user.position.x, user.position.y); - const newZoneDesc = this.getZoneDescriptorFromCoordinates(userPosition.x, userPosition.y); + const oldZoneDesc = this.getZoneDescriptorFromCoordinates(oldPosition.x, oldPosition.y); + const newZoneDesc = this.getZoneDescriptorFromCoordinates(newPosition.x, newPosition.y); if (oldZoneDesc.i != newZoneDesc.i || oldZoneDesc.j != newZoneDesc.j) { const oldZone = this.getZone(oldZoneDesc.i, oldZoneDesc.j); const newZone = this.getZone(newZoneDesc.i, newZoneDesc.j); // Leave old zone - oldZone.leave(user, newZone); + oldZone.leave(thing, newZone); // Enter new zone - newZone.enter(user, oldZone, userPosition); + newZone.enter(thing, oldZone, newPosition); } else { const zone = this.getZone(oldZoneDesc.i, oldZoneDesc.j); - zone.move(user, userPosition); + zone.move(thing, newPosition); } } - public leave(user: UserInterface): void { - const oldZoneDesc = this.getZoneDescriptorFromCoordinates(user.position.x, user.position.y); + public leave(thing: Movable): void { + const oldPosition = thing.getPosition(); + const oldZoneDesc = this.getZoneDescriptorFromCoordinates(oldPosition.x, oldPosition.y); const oldZone = this.getZone(oldZoneDesc.i, oldZoneDesc.j); - oldZone.leave(user, null); + oldZone.leave(thing, null); + } + public removeViewport(user: User): void { // Also, let's stop listening on viewports for (const zone of user.listenedZones) { zone.stopListening(user); diff --git a/back/src/Model/User.ts b/back/src/Model/User.ts new file mode 100644 index 00000000..160a101c --- /dev/null +++ b/back/src/Model/User.ts @@ -0,0 +1,23 @@ +import { Group } from "./Group"; +import { PointInterface } from "./Websocket/PointInterface"; +import {Zone} from "_Model/Zone"; +import {Movable} from "_Model/Movable"; +import {PositionInterface} from "_Model/PositionInterface"; + +export class User implements Movable { + public listenedZones: Set; + public group?: Group; + + public constructor( + public id: string, + public position: PointInterface, + public silent: boolean, + + ) { + this.listenedZones = new Set(); + } + + public getPosition(): PositionInterface { + return this.position; + } +} diff --git a/back/src/Model/UserInterface.ts b/back/src/Model/UserInterface.ts deleted file mode 100644 index d19ecd6f..00000000 --- a/back/src/Model/UserInterface.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Group } from "./Group"; -import { PointInterface } from "./Websocket/PointInterface"; -import {Zone} from "_Model/Zone"; - -export interface UserInterface { - id: string, - group?: Group, - position: PointInterface, - silent: boolean, - listenedZones: Set -} diff --git a/back/src/Model/Websocket/GroupUpdateInterface.ts b/back/src/Model/Websocket/GroupUpdateInterface.ts new file mode 100644 index 00000000..45e64ea4 --- /dev/null +++ b/back/src/Model/Websocket/GroupUpdateInterface.ts @@ -0,0 +1,6 @@ +import {PositionInterface} from "_Model/PositionInterface"; + +export interface GroupUpdateInterface { + position: PositionInterface, + groupId: string, +} diff --git a/back/src/Model/World.ts b/back/src/Model/World.ts index 05651ad4..9a5e35ff 100644 --- a/back/src/Model/World.ts +++ b/back/src/Model/World.ts @@ -2,27 +2,28 @@ import {MessageUserPosition, Point} from "./Websocket/MessageUserPosition"; import {PointInterface} from "./Websocket/PointInterface"; import {Group} from "./Group"; import {Distance} from "./Distance"; -import {UserInterface} from "./UserInterface"; +import {User} from "./User"; import {ExSocketInterface} from "_Model/Websocket/ExSocketInterface"; import {PositionInterface} from "_Model/PositionInterface"; import {Identificable} from "_Model/Websocket/Identificable"; -import {UserEntersCallback, UserLeavesCallback, UserMovesCallback, Zone} from "_Model/Zone"; +import {EntersCallback, LeavesCallback, MovesCallback, Zone} from "_Model/Zone"; import {PositionNotifier} from "./PositionNotifier"; import {ViewportInterface} from "_Model/Websocket/ViewportMessage"; +import {Movable} from "_Model/Movable"; export type ConnectCallback = (user: string, group: Group) => void; export type DisconnectCallback = (user: string, group: Group) => void; // callback called when a group is created or moved or changes users export type GroupUpdatedCallback = (group: Group) => void; -export type GroupDeletedCallback = (uuid: string, lastUser: UserInterface) => void; +export type GroupDeletedCallback = (uuid: string, lastUser: User) => void; export class World { private readonly minDistance: number; private readonly groupRadius: number; // Users, sorted by ID - private readonly users: Map; + private readonly users: Map; private readonly groups: Set; private readonly connectCallback: ConnectCallback; @@ -40,11 +41,11 @@ export class World { groupRadius: number, groupUpdatedCallback: GroupUpdatedCallback, groupDeletedCallback: GroupDeletedCallback, - onUserEnters: UserEntersCallback, - onUserMoves: UserMovesCallback, - onUserLeaves: UserLeavesCallback) + onEnters: EntersCallback, + onMoves: MovesCallback, + onLeaves: LeavesCallback) { - this.users = new Map(); + this.users = new Map(); this.groups = new Set(); this.connectCallback = connectCallback; this.disconnectCallback = disconnectCallback; @@ -53,24 +54,19 @@ export class World { this.groupUpdatedCallback = groupUpdatedCallback; this.groupDeletedCallback = groupDeletedCallback; // A zone is 10 sprites wide. - this.positionNotifier = new PositionNotifier(320, 320, onUserEnters, onUserMoves, onUserLeaves); + this.positionNotifier = new PositionNotifier(320, 320, onEnters, onMoves, onLeaves); } public getGroups(): Group[] { return Array.from(this.groups.values()); } - public getUsers(): Map { + public getUsers(): Map { return this.users; } public join(socket : Identificable, userPosition: PointInterface): void { - this.users.set(socket.userId, { - id: socket.userId, - position: userPosition, - silent: false, // FIXME: silent should be set at the correct value when joining a room. - listenedZones: new Set() - }); + this.users.set(socket.userId, new User(socket.userId, userPosition, false)); // Let's call update position to trigger the join / leave room this.updatePosition(socket, userPosition); } @@ -87,6 +83,7 @@ export class World { if (userObj !== undefined) { this.positionNotifier.leave(userObj); + this.positionNotifier.removeViewport(userObj); } } @@ -100,7 +97,9 @@ export class World { return; } - this.positionNotifier.updatePosition(user, userPosition); + this.positionNotifier.updatePosition(user, userPosition, user.position); + + const oldGroupPosition = user.group?.getPosition(); user.position = userPosition; @@ -108,17 +107,17 @@ export class World { return; } - if (typeof user.group === 'undefined') { + if (user.group === undefined) { // If the user is not part of a group: // should he join a group? - const closestItem: UserInterface|Group|null = this.searchClosestAvailableUserOrGroup(user); + const closestItem: User|Group|null = this.searchClosestAvailableUserOrGroup(user); if (closestItem !== null) { if (closestItem instanceof Group) { // Let's join the group! closestItem.join(user); } else { - const closestUser : UserInterface = closestItem; + const closestUser : User = closestItem; const group: Group = new Group([ user, closestUser @@ -138,7 +137,8 @@ export class World { // At the very end, if the user is part of a group, let's call the callback to update group position if (typeof user.group !== 'undefined') { - this.groupUpdatedCallback(user.group); + this.positionNotifier.updatePosition(user.group, user.group.getPosition(), oldGroupPosition ? oldGroupPosition : user.group.getPosition()); + //this.groupUpdatedCallback(user.group); } } @@ -167,21 +167,23 @@ export class World { * * @param user */ - private leaveGroup(user: UserInterface): void { + private leaveGroup(user: User): void { const group = user.group; if (typeof group === 'undefined') { throw new Error("The user is part of no group"); } group.leave(user); if (group.isEmpty()) { - this.groupDeletedCallback(group.getId(), user); + //this.groupDeletedCallback(group.getId(), user); + this.positionNotifier.leave(group); group.destroy(); if (!this.groups.has(group)) { throw new Error("Could not find group "+group.getId()+" referenced by user "+user.id+" in World."); } this.groups.delete(group); } else { - this.groupUpdatedCallback(group); + this.positionNotifier.updatePosition(group, group.getPosition(), group.getPosition()); + //this.groupUpdatedCallback(group); } } @@ -193,10 +195,10 @@ export class World { * OR * - close enough to a group (distance <= groupRadius) */ - private searchClosestAvailableUserOrGroup(user: UserInterface): UserInterface|Group|null + private searchClosestAvailableUserOrGroup(user: User): User|Group|null { let minimumDistanceFound: number = Math.max(this.minDistance, this.groupRadius); - let matchingItem: UserInterface | Group | null = null; + let matchingItem: User | Group | null = null; this.users.forEach((currentUser, userId) => { // Let's only check users that are not part of a group if (typeof currentUser.group !== 'undefined') { @@ -265,7 +267,7 @@ export class World { return matchingItem; } - public static computeDistance(user1: UserInterface, user2: UserInterface): number + public static computeDistance(user1: User, user2: User): number { return Math.sqrt(Math.pow(user2.position.x - user1.position.x, 2) + Math.pow(user2.position.y - user1.position.y, 2)); } @@ -343,7 +345,7 @@ export class World { } return 0; }*/ - setViewport(socket : Identificable, viewport: ViewportInterface): UserInterface[] { + setViewport(socket : Identificable, viewport: ViewportInterface): Movable[] { const user = this.users.get(socket.userId); if(typeof user === 'undefined') { console.warn('In setViewport, could not find user with ID "'+socket.userId+'" in world.'); diff --git a/back/src/Model/Zone.ts b/back/src/Model/Zone.ts index bd748b0f..9933637c 100644 --- a/back/src/Model/Zone.ts +++ b/back/src/Model/Zone.ts @@ -1,77 +1,77 @@ -import {UserInterface} from "./UserInterface"; -import {PointInterface} from "_Model/Websocket/PointInterface"; +import {User} from "./User"; import {PositionInterface} from "_Model/PositionInterface"; +import {Movable} from "_Model/Movable"; -export type UserEntersCallback = (user: UserInterface, listener: UserInterface) => void; -export type UserMovesCallback = (user: UserInterface, position: PointInterface, listener: UserInterface) => void; -export type UserLeavesCallback = (user: UserInterface, listener: UserInterface) => void; +export type EntersCallback = (thing: Movable, listener: User) => void; +export type MovesCallback = (thing: Movable, position: PositionInterface, listener: User) => void; +export type LeavesCallback = (thing: Movable, listener: User) => void; export class Zone { - private players: Set = new Set(); - private listeners: Set = new Set(); + private things: Set = new Set(); + private listeners: Set = new Set(); - constructor(private onUserEnters: UserEntersCallback, private onUserMoves: UserMovesCallback, private onUserLeaves: UserLeavesCallback) { + constructor(private onEnters: EntersCallback, private onMoves: MovesCallback, private onLeaves: LeavesCallback) { } /** - * A user leaves the zone + * A user/thing leaves the zone */ - public leave(user: UserInterface, newZone: Zone|null) { - this.players.delete(user); - this.notifyUserLeft(user, newZone); + public leave(thing: Movable, newZone: Zone|null) { + this.things.delete(thing); + this.notifyLeft(thing, newZone); } /** - * Notify listeners of this zone that this user left + * Notify listeners of this zone that this user/thing left */ - private notifyUserLeft(user: UserInterface, newZone: Zone|null) { + private notifyLeft(thing: Movable, newZone: Zone|null) { for (const listener of this.listeners) { - if (listener !== user && (newZone === null || !listener.listenedZones.has(newZone))) { - this.onUserLeaves(user, listener); + if (listener !== thing && (newZone === null || !listener.listenedZones.has(newZone))) { + this.onLeaves(thing, listener); } } } - public enter(user: UserInterface, oldZone: Zone|null, position: PointInterface) { - this.players.add(user); - this.notifyUserEnter(user, oldZone, position); + public enter(thing: Movable, oldZone: Zone|null, position: PositionInterface) { + this.things.add(thing); + this.notifyUserEnter(thing, oldZone, position); } /** * Notify listeners of this zone that this user entered */ - private notifyUserEnter(user: UserInterface, oldZone: Zone|null, position: PointInterface) { + private notifyUserEnter(thing: Movable, oldZone: Zone|null, position: PositionInterface) { for (const listener of this.listeners) { - if (listener === user) { + if (listener === thing) { continue; } if (oldZone === null || !listener.listenedZones.has(oldZone)) { - this.onUserEnters(user, listener); + this.onEnters(thing, listener); } else { - this.onUserMoves(user, position, listener); + this.onMoves(thing, position, listener); } } } - public move(user: UserInterface, position: PointInterface) { - if (!this.players.has(user)) { - this.players.add(user); - const foo = this.players; - this.notifyUserEnter(user, null, position); + public move(thing: Movable, position: PositionInterface) { + if (!this.things.has(thing)) { + this.things.add(thing); + const foo = this.things; + this.notifyUserEnter(thing, null, position); return; } for (const listener of this.listeners) { - if (listener !== user) { - this.onUserMoves(user,position, listener); + if (listener !== thing) { + this.onMoves(thing,position, listener); } } } - public startListening(listener: UserInterface): void { - for (const player of this.players) { - if (player !== listener) { - this.onUserEnters(player, listener); + public startListening(listener: User): void { + for (const thing of this.things) { + if (thing !== listener) { + this.onEnters(thing, listener); } } @@ -79,10 +79,10 @@ export class Zone { listener.listenedZones.add(this); } - public stopListening(listener: UserInterface): void { - for (const player of this.players) { - if (player !== listener) { - this.onUserLeaves(player, listener); + public stopListening(listener: User): void { + for (const thing of this.things) { + if (thing !== listener) { + this.onLeaves(thing, listener); } } @@ -90,7 +90,7 @@ export class Zone { listener.listenedZones.delete(this); } - public getPlayers(): Set { - return this.players; + public getThings(): Set { + return this.things; } } diff --git a/back/tests/PositionNotifierTest.ts b/back/tests/PositionNotifierTest.ts index 0b8b466f..936efb08 100644 --- a/back/tests/PositionNotifierTest.ts +++ b/back/tests/PositionNotifierTest.ts @@ -3,17 +3,16 @@ import {World, ConnectCallback, DisconnectCallback } from "../src/Model/World"; import {Point} from "../src/Model/Websocket/MessageUserPosition"; import { Group } from "../src/Model/Group"; import {PositionNotifier} from "../src/Model/PositionNotifier"; -import {UserInterface} from "../src/Model/UserInterface"; +import {User} from "../src/Model/User"; import {PointInterface} from "../src/Model/Websocket/PointInterface"; import {Zone} from "_Model/Zone"; +import {Movable} from "_Model/Movable"; -function move(user: UserInterface, x: number, y: number, positionNotifier: PositionNotifier): void { +function move(user: User, x: number, y: number, positionNotifier: PositionNotifier): void { positionNotifier.updatePosition(user, { x, - y, - moving: false, - direction: 'down' - }); + y + }, user.position); user.position.x = x; user.position.y = y; } @@ -24,35 +23,27 @@ describe("PositionNotifier", () => { let moveTriggered = false; let leaveTriggered = false; - const positionNotifier = new PositionNotifier(300, 300, (user: UserInterface) => { + const positionNotifier = new PositionNotifier(300, 300, (thing: Movable) => { enterTriggered = true; - }, (user: UserInterface, position: PointInterface) => { + }, (thing: Movable, position: PointInterface) => { moveTriggered = true; - }, (user: UserInterface) => { + }, (thing: Movable) => { leaveTriggered = true; }); - const user1 = { - id: "1", - position: { - x: 500, - y: 500, - moving: false, - direction: 'down' - }, - listenedZones: new Set(), - } as UserInterface; + const user1 = new User("1", { + x: 500, + y: 500, + moving: false, + direction: 'down' + }, false); - const user2 = { - id: "2", - position: { - x: -9999, - y: -9999, - moving: false, - direction: 'down' - }, - listenedZones: new Set(), - } as UserInterface; + const user2 = new User("2", { + x: -9999, + y: -9999, + moving: false, + direction: 'down' + }, false); positionNotifier.setViewport(user1, { left: 200, @@ -98,6 +89,7 @@ describe("PositionNotifier", () => { // Leave the room positionNotifier.leave(user2); + positionNotifier.removeViewport(user2); expect(enterTriggered).toBe(false); expect(moveTriggered).toBe(false); expect(leaveTriggered).toBe(true); @@ -109,35 +101,27 @@ describe("PositionNotifier", () => { let moveTriggered = false; let leaveTriggered = false; - const positionNotifier = new PositionNotifier(300, 300, (user: UserInterface) => { + const positionNotifier = new PositionNotifier(300, 300, (thing: Movable) => { enterTriggered = true; - }, (user: UserInterface, position: PointInterface) => { + }, (thing: Movable, position: PointInterface) => { moveTriggered = true; - }, (user: UserInterface) => { + }, (thing: Movable) => { leaveTriggered = true; }); - const user1 = { - id: "1", - position: { - x: 500, - y: 500, - moving: false, - direction: 'down' - }, - listenedZones: new Set(), - } as UserInterface; + const user1 = new User("1", { + x: 500, + y: 500, + moving: false, + direction: 'down' + }, false); - const user2 = { - id: "2", - position: { - x: -9999, - y: -9999, - moving: false, - direction: 'down' - }, - listenedZones: new Set(), - } as UserInterface; + const user2 = new User("2", { + x: -9999, + y: -9999, + moving: false, + direction: 'down' + }, false); let newUsers = positionNotifier.setViewport(user1, { left: 200, diff --git a/front/src/Connection.ts b/front/src/Connection.ts index 68fcc206..5062ca7f 100644 --- a/front/src/Connection.ts +++ b/front/src/Connection.ts @@ -123,7 +123,8 @@ export interface ItemEventMessageInterface { } export interface RoomJoinedMessageInterface { - users: MessageUserPositionInterface[] + users: MessageUserPositionInterface[], + groups: GroupCreatedUpdatedMessageInterface[], items: { [itemId: number] : unknown } } diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 62c7c97a..ad378bc3 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -780,6 +780,7 @@ export class GameScene extends Phaser.Scene implements CenterListener { this.initUsersPosition(roomJoinedMessage.users); this.connectionAnswerPromiseResolve(roomJoinedMessage); }); + // FIXME: weirdly enough we don't use the result of joinARoom !!!!!! //listen event to share position of user this.CurrentPlayer.on(hasMovedEventName, this.pushPlayerPosition.bind(this)) From 7410cc8a4bfd98327e4b523978023ad1d444bd89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 16 Sep 2020 16:10:20 +0200 Subject: [PATCH 014/122] Fixing tests --- back/tests/PositionNotifierTest.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/back/tests/PositionNotifierTest.ts b/back/tests/PositionNotifierTest.ts index 936efb08..dd1e3b4b 100644 --- a/back/tests/PositionNotifierTest.ts +++ b/back/tests/PositionNotifierTest.ts @@ -7,6 +7,7 @@ import {User} from "../src/Model/User"; import {PointInterface} from "../src/Model/Websocket/PointInterface"; import {Zone} from "_Model/Zone"; import {Movable} from "_Model/Movable"; +import {PositionInterface} from "_Model/PositionInterface"; function move(user: User, x: number, y: number, positionNotifier: PositionNotifier): void { positionNotifier.updatePosition(user, { @@ -25,7 +26,7 @@ describe("PositionNotifier", () => { const positionNotifier = new PositionNotifier(300, 300, (thing: Movable) => { enterTriggered = true; - }, (thing: Movable, position: PointInterface) => { + }, (thing: Movable, position: PositionInterface) => { moveTriggered = true; }, (thing: Movable) => { leaveTriggered = true; @@ -103,7 +104,7 @@ describe("PositionNotifier", () => { const positionNotifier = new PositionNotifier(300, 300, (thing: Movable) => { enterTriggered = true; - }, (thing: Movable, position: PointInterface) => { + }, (thing: Movable, position: PositionInterface) => { moveTriggered = true; }, (thing: Movable) => { leaveTriggered = true; From f6458a833509054418de164b4ef61d2d147ab9de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 16 Sep 2020 16:13:47 +0200 Subject: [PATCH 015/122] Removing useless group callbacks at the World level --- back/src/Controller/IoSocketController.ts | 26 +---------------------- back/src/Model/World.ts | 13 ------------ back/tests/WorldTest.ts | 6 +++--- 3 files changed, 4 insertions(+), 41 deletions(-) diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index f220aedb..56168804 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -149,26 +149,6 @@ export class IoSocketController { return null; } - private sendUpdateGroupEvent(group: Group): void { - // Let's get the room of the group. To do this, let's get anyone in the group and find its room. - // Note: this is suboptimal - const userId = group.getUsers()[0].id; - const client: ExSocketInterface = this.searchClientByIdOrFail(userId); - const roomId = client.roomId; - this.Io.in(roomId).emit(SockerIoEvent.GROUP_CREATE_UPDATE, { - position: group.getPosition(), - groupId: group.getId() - }); - } - - private sendDeleteGroupEvent(uuid: string, lastUser: User): void { - // Let's get the room of the group. To do this, let's get anyone in the group and find its room. - const userId = lastUser.id; - const client: ExSocketInterface = this.searchClientByIdOrFail(userId); - const roomId = client.roomId; - this.Io.in(roomId).emit(SockerIoEvent.GROUP_DELETE, uuid); - } - ioConnection() { this.Io.on(SockerIoEvent.CONNECTION, (socket: Socket) => { const client : ExSocketInterface = socket as ExSocketInterface; @@ -498,11 +478,7 @@ export class IoSocketController { this.connectedUser(user1, group); }, (user1: string, group: Group) => { this.disConnectedUser(user1, group); - }, MINIMUM_DISTANCE, GROUP_RADIUS, (group: Group) => { - //this.sendUpdateGroupEvent(group); - }, (groupUuid: string, lastUser: User) => { - //this.sendDeleteGroupEvent(groupUuid, lastUser); - }, (thing: Movable, listener: User) => { + }, MINIMUM_DISTANCE, GROUP_RADIUS, (thing: Movable, listener: User) => { const clientListener = this.searchClientByIdOrFail(listener.id); if (thing instanceof User) { const clientUser = this.searchClientByIdOrFail(thing.id); diff --git a/back/src/Model/World.ts b/back/src/Model/World.ts index 9a5e35ff..6e739c02 100644 --- a/back/src/Model/World.ts +++ b/back/src/Model/World.ts @@ -14,10 +14,6 @@ import {Movable} from "_Model/Movable"; export type ConnectCallback = (user: string, group: Group) => void; export type DisconnectCallback = (user: string, group: Group) => void; -// callback called when a group is created or moved or changes users -export type GroupUpdatedCallback = (group: Group) => void; -export type GroupDeletedCallback = (uuid: string, lastUser: User) => void; - export class World { private readonly minDistance: number; private readonly groupRadius: number; @@ -28,8 +24,6 @@ export class World { private readonly connectCallback: ConnectCallback; private readonly disconnectCallback: DisconnectCallback; - private readonly groupUpdatedCallback: GroupUpdatedCallback; - private readonly groupDeletedCallback: GroupDeletedCallback; private itemsState: Map = new Map(); @@ -39,8 +33,6 @@ export class World { disconnectCallback: DisconnectCallback, minDistance: number, groupRadius: number, - groupUpdatedCallback: GroupUpdatedCallback, - groupDeletedCallback: GroupDeletedCallback, onEnters: EntersCallback, onMoves: MovesCallback, onLeaves: LeavesCallback) @@ -51,8 +43,6 @@ export class World { this.disconnectCallback = disconnectCallback; this.minDistance = minDistance; this.groupRadius = groupRadius; - this.groupUpdatedCallback = groupUpdatedCallback; - this.groupDeletedCallback = groupDeletedCallback; // A zone is 10 sprites wide. this.positionNotifier = new PositionNotifier(320, 320, onEnters, onMoves, onLeaves); } @@ -138,7 +128,6 @@ export class World { // At the very end, if the user is part of a group, let's call the callback to update group position if (typeof user.group !== 'undefined') { this.positionNotifier.updatePosition(user.group, user.group.getPosition(), oldGroupPosition ? oldGroupPosition : user.group.getPosition()); - //this.groupUpdatedCallback(user.group); } } @@ -174,7 +163,6 @@ export class World { } group.leave(user); if (group.isEmpty()) { - //this.groupDeletedCallback(group.getId(), user); this.positionNotifier.leave(group); group.destroy(); if (!this.groups.has(group)) { @@ -183,7 +171,6 @@ export class World { this.groups.delete(group); } else { this.positionNotifier.updatePosition(group, group.getPosition(), group.getPosition()); - //this.groupUpdatedCallback(group); } } diff --git a/back/tests/WorldTest.ts b/back/tests/WorldTest.ts index 580677c7..63e46928 100644 --- a/back/tests/WorldTest.ts +++ b/back/tests/WorldTest.ts @@ -13,7 +13,7 @@ describe("World", () => { } - const world = new World(connect, disconnect, 160, 160, () => {}, () => {}, () => {}, () => {}, () => {}); + const world = new World(connect, disconnect, 160, 160, () => {}, () => {}, () => {}); world.join({ userId: "foo" }, new Point(100, 100)); @@ -40,7 +40,7 @@ describe("World", () => { } - const world = new World(connect, disconnect, 160, 160, () => {}, () => {}, () => {}, () => {}, () => {}); + const world = new World(connect, disconnect, 160, 160, () => {}, () => {}, () => {}); world.join({ userId: "foo" }, new Point(100, 100)); @@ -69,7 +69,7 @@ describe("World", () => { disconnectCallNumber++; } - const world = new World(connect, disconnect, 160, 160, () => {}, () => {}, () => {}, () => {}, () => {}); + const world = new World(connect, disconnect, 160, 160, () => {}, () => {}, () => {}); world.join({ userId: "foo" }, new Point(100, 100)); From 2e8fa8d676c413a09d32117ce278269f9107e5f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 16 Sep 2020 18:34:24 +0200 Subject: [PATCH 016/122] Adding protocol buffers to the project with Typescript support --- back/package.json | 7 +++++-- back/src/proto/generated/.gitkeep | 0 back/src/proto/messages.proto | 6 ++++++ back/yarn.lock | 12 ++++++++++++ docker-compose.yaml | 2 +- 5 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 back/src/proto/generated/.gitkeep create mode 100644 back/src/proto/messages.proto diff --git a/back/package.json b/back/package.json index a20c876f..fc7ad60e 100644 --- a/back/package.json +++ b/back/package.json @@ -10,7 +10,8 @@ "profile": "tsc && node --prof ./dist/server.js", "test": "ts-node node_modules/jasmine/bin/jasmine --config=jasmine.json", "lint": "node_modules/.bin/eslint src/ . --ext .ts", - "fix": "node_modules/.bin/eslint --fix src/ . --ext .ts" + "fix": "node_modules/.bin/eslint --fix src/ . --ext .ts", + "proto": "protoc --plugin=\"protoc-gen-ts=./node_modules/.bin/protoc-gen-ts\" --js_out=\"import_style=commonjs,binary:src/proto/generated\" --ts_out=\"src/proto/generated\" src/proto/messages.proto" }, "repository": { "type": "git", @@ -44,6 +45,7 @@ "body-parser": "^1.19.0", "express": "^4.17.1", "generic-type-guard": "^3.2.0", + "google-protobuf": "^3.13.0", "http-status-codes": "^1.4.0", "jsonwebtoken": "^8.5.1", "prom-client": "^12.0.0", @@ -58,6 +60,7 @@ "@typescript-eslint/eslint-plugin": "^2.26.0", "@typescript-eslint/parser": "^2.26.0", "eslint": "^6.8.0", - "jasmine": "^3.5.0" + "jasmine": "^3.5.0", + "ts-protoc-gen": "^0.13.0" } } diff --git a/back/src/proto/generated/.gitkeep b/back/src/proto/generated/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/back/src/proto/messages.proto b/back/src/proto/messages.proto new file mode 100644 index 00000000..ea9fafe2 --- /dev/null +++ b/back/src/proto/messages.proto @@ -0,0 +1,6 @@ +syntax = "proto3"; + +message SetPlayerDetailsMessage { + string name = 1; + repeated string characterLayers = 2; +} diff --git a/back/yarn.lock b/back/yarn.lock index f660a5c8..fe5c26e1 100644 --- a/back/yarn.lock +++ b/back/yarn.lock @@ -822,6 +822,11 @@ globals@^12.1.0: dependencies: type-fest "^0.8.1" +google-protobuf@^3.13.0, google-protobuf@^3.6.1: + version "3.13.0" + resolved "https://registry.yarnpkg.com/google-protobuf/-/google-protobuf-3.13.0.tgz#909c5983d75dd6101ed57c79e0528d000cdc3251" + integrity sha512-ZIf3qfLFayVrPvAjeKKxO5FRF1/NwRxt6Dko+fWEMuHwHbZx8/fcaAao9b0wCM6kr8qeg2te8XTpyuvKuD9aKw== + graceful-fs@^4.1.2: version "4.2.3" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.3.tgz#4a12ff1b60376ef09862c2093edd908328be8423" @@ -1764,6 +1769,13 @@ ts-node@*: source-map-support "^0.5.6" yn "3.1.1" +ts-protoc-gen@^0.13.0: + version "0.13.0" + resolved "https://registry.yarnpkg.com/ts-protoc-gen/-/ts-protoc-gen-0.13.0.tgz#2763ae4e4a1a7d7001d53d2f3043357c691701ea" + integrity sha512-j18X4rkDBbG/ZHUJy88WFeZP6mStGow5uREaohowlHXTu3/N7WcpyPhb7Vh6wN38ERmc/AkT9gqT98+vtlRhJA== + dependencies: + google-protobuf "^3.6.1" + tsconfig@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/tsconfig/-/tsconfig-7.0.0.tgz#84538875a4dc216e5c4a5432b3a4dec3d54e91b7" diff --git a/docker-compose.yaml b/docker-compose.yaml index 6f859759..beddf025 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -66,7 +66,7 @@ services: - "traefik.http.routers.maps-ssl.service=maps" back: - image: thecodingmachine/nodejs:12 + image: thecodingmachine/workadventure-back-base:latest command: yarn dev #command: yarn run profile environment: From 509196785b49fa5be2d11400c2b49b9788eb661e Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Wed, 16 Sep 2020 18:38:50 +0200 Subject: [PATCH 017/122] Initialise global message - Create new class to manager global message. My idea is that this class permit to manage audio or text message. - Update html to have main content id and inject html in this. - Create front event to receive startMessage and stopMessage. - Delete impoted variable not used. --- front/.gitignore | 1 + front/dist/index.html | 2 +- front/dist/resources/style/style.css | 11 ++++++ front/src/Connection.ts | 18 ++++++++- front/src/Phaser/Game/GameScene.ts | 4 ++ front/src/Phaser/Login/EnableCameraScene.ts | 5 +-- front/src/WebRtc/GlobalMessageManager.ts | 43 +++++++++++++++++++++ front/src/WebRtc/HtmlUtils.ts | 10 +++++ front/src/WebRtc/SimplePeer.ts | 2 - 9 files changed, 88 insertions(+), 8 deletions(-) create mode 100644 front/src/WebRtc/GlobalMessageManager.ts diff --git a/front/.gitignore b/front/.gitignore index a74d68d5..e207e30a 100644 --- a/front/.gitignore +++ b/front/.gitignore @@ -4,3 +4,4 @@ /dist/webpack.config.js /dist/webpack.config.js.map /dist/src +*.sh \ No newline at end of file diff --git a/front/dist/index.html b/front/dist/index.html index 5de00b3b..4fd514a8 100644 --- a/front/dist/index.html +++ b/front/dist/index.html @@ -39,7 +39,7 @@ WorkAdventure -
+
diff --git a/front/dist/resources/style/style.css b/front/dist/resources/style/style.css index 807544ad..bf495f90 100644 --- a/front/dist/resources/style/style.css +++ b/front/dist/resources/style/style.css @@ -403,3 +403,14 @@ body { .chat-mode > div:last-child { flex-grow: 5; } + +.message-container{ + top: 0; + left: 20%; + position: absolute; + width: 60%; + height: auto; + z-index: 200; + background-color: #00000096; + border-radius: 0 0 10px 10px; +} diff --git a/front/src/Connection.ts b/front/src/Connection.ts index 5062ca7f..b930f198 100644 --- a/front/src/Connection.ts +++ b/front/src/Connection.ts @@ -1,6 +1,5 @@ import Axios from "axios"; import {API_URL} from "./Enum/EnvironmentVariable"; -import {MessageUI} from "./Logger/MessageUI"; import {SetPlayerDetailsMessage} from "./Messages/SetPlayerDetailsMessage"; const SocketIo = require('socket.io-client'); @@ -28,6 +27,9 @@ enum EventMessage{ SET_SILENT = "set_silent", // Set or unset the silent mode for this user. SET_VIEWPORT = "set-viewport", BATCH = "batch", + + PLAY_GLOBAL_MESSAGE = "play-global-message", + STOP_GLOBAL_MESSAGE = "stop-global-message", } export interface PointInterface { @@ -128,6 +130,12 @@ export interface RoomJoinedMessageInterface { items: { [itemId: number] : unknown } } +export interface GlobalMessageInterface { + id: number + type: string + message: string +} + export class Connection implements Connection { private readonly socket: Socket; private userId: string|null = null; @@ -275,6 +283,14 @@ export class Connection implements Connection { return this.socket.on(EventMessage.WEBRTC_SCREEN_SHARING_SIGNAL, callback); } + public receivePlayGlobalMessage(callback: (message: GlobalMessageInterface) => void) { + return this.socket.on(EventMessage.PLAY_GLOBAL_MESSAGE, callback); + } + + public receiveStopGlobalMessage(callback: (message: GlobalMessageInterface) => void) { + return this.socket.on(EventMessage.STOP_GLOBAL_MESSAGE, callback); + } + public onServerDisconnected(callback: (reason: string) => void): void { this.socket.on('disconnect', (reason: string) => { if (reason === 'io client disconnect') { diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index ad378bc3..37e7c2ef 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -40,6 +40,7 @@ import {FourOFourSceneName} from "../Reconnecting/FourOFourScene"; import {ItemFactoryInterface} from "../Items/ItemFactoryInterface"; import {ActionableItem} from "../Items/ActionableItem"; import {UserInputManager} from "../UserInput/UserInputManager"; +import {GlobalMessageManager} from "../../WebRtc/GlobalMessageManager"; export enum Textures { @@ -100,6 +101,7 @@ export class GameScene extends Phaser.Scene implements CenterListener { private playersPositionInterpolator = new PlayersPositionInterpolator(); private connection!: Connection; private simplePeer!: SimplePeer; + private GlobalMessageManager!: GlobalMessageManager; private connectionPromise!: Promise private connectionAnswerPromise: Promise; private connectionAnswerPromiseResolve!: (value?: RoomJoinedMessageInterface | PromiseLike) => void; @@ -265,6 +267,8 @@ export class GameScene extends Phaser.Scene implements CenterListener { // When connection is performed, let's connect SimplePeer this.simplePeer = new SimplePeer(this.connection); + this.GlobalMessageManager = new GlobalMessageManager(this.connection); + const self = this; this.simplePeer.registerPeerConnectionListener({ onConnect(user: UserSimplePeerInterface) { diff --git a/front/src/Phaser/Login/EnableCameraScene.ts b/front/src/Phaser/Login/EnableCameraScene.ts index 6fc1cd54..b280dd1c 100644 --- a/front/src/Phaser/Login/EnableCameraScene.ts +++ b/front/src/Phaser/Login/EnableCameraScene.ts @@ -1,12 +1,9 @@ import {gameManager} from "../Game/GameManager"; import {TextField} from "../Components/TextField"; -import {ClickButton} from "../Components/ClickButton"; import Image = Phaser.GameObjects.Image; -import Rectangle = Phaser.GameObjects.Rectangle; -import {PLAYER_RESOURCES, PlayerResourceDescriptionInterface} from "../Entity/Character"; import {GameSceneInitInterface} from "../Game/GameScene"; import {StartMapInterface} from "../../Connection"; -import {mediaManager, MediaManager} from "../../WebRtc/MediaManager"; +import {mediaManager} from "../../WebRtc/MediaManager"; import {RESOLUTION} from "../../Enum/EnvironmentVariable"; import {SoundMeter} from "../Components/SoundMeter"; import {SoundMeterSprite} from "../Components/SoundMeterSprite"; diff --git a/front/src/WebRtc/GlobalMessageManager.ts b/front/src/WebRtc/GlobalMessageManager.ts new file mode 100644 index 00000000..91dc64c3 --- /dev/null +++ b/front/src/WebRtc/GlobalMessageManager.ts @@ -0,0 +1,43 @@ +import {HtmlUtils} from "./HtmlUtils"; +import {Connection, GlobalMessageInterface} from "../Connection"; + +export class GlobalMessageManager { + + private Connection: Connection; + + constructor(Connection: Connection) { + this.Connection = Connection; + this.initialise(); + } + + initialise(){ + //receive signal to show message + this.Connection.receivePlayGlobalMessage((message: GlobalMessageInterface) => { + this.playMessage(message.id, message.message); + }); + + //receive signal to close message + this.Connection.receiveStopGlobalMessage((message: GlobalMessageInterface) => { + this.stopMessage(message.id); + }); + } + + playMessage(messageId : number, htmlMessage: string){ + const div = document.createElement('div'); + div.innerHTML = htmlMessage; + div.id = this.getHtmlMessageId(messageId); + div.className = "message-container"; + + const mainSectionDiv = HtmlUtils.getElementByIdOrFail('main-container'); + mainSectionDiv.appendChild(div); + } + + stopMessage(messageId: number){ + HtmlUtils.removeElementByIdOrFail(this.getHtmlMessageId(messageId)); + } + + private getHtmlMessageId(messageId: number){ + return `message-${messageId}`; + } + +} diff --git a/front/src/WebRtc/HtmlUtils.ts b/front/src/WebRtc/HtmlUtils.ts index c2e6ff6d..b7cb2124 100644 --- a/front/src/WebRtc/HtmlUtils.ts +++ b/front/src/WebRtc/HtmlUtils.ts @@ -7,4 +7,14 @@ export class HtmlUtils { // FIXME: does not check the type of the returned type return elem as T; } + + public static removeElementByIdOrFail(id: string): T { + const elem = document.getElementById(id); + if (elem === null) { + throw new Error("Cannot find HTML element with id '"+id+"'"); + } + // FIXME: does not check the type of the returned type + elem.remove(); + return elem as T; + } } diff --git a/front/src/WebRtc/SimplePeer.ts b/front/src/WebRtc/SimplePeer.ts index f388b2ec..f78e83e4 100644 --- a/front/src/WebRtc/SimplePeer.ts +++ b/front/src/WebRtc/SimplePeer.ts @@ -10,10 +10,8 @@ import { StopScreenSharingCallback, UpdatedLocalStreamCallback } from "./MediaManager"; -import * as SimplePeerNamespace from "simple-peer"; import {ScreenSharingPeer} from "./ScreenSharingPeer"; import {VideoPeer} from "./VideoPeer"; -const Peer: SimplePeerNamespace.SimplePeer = require('simple-peer'); export interface UserSimplePeerInterface{ userId: string; From e59cbcfaa7cb3890a3d7ea03fb40262e2e769ccb Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Wed, 16 Sep 2020 21:50:04 +0200 Subject: [PATCH 018/122] Create console global message - Add style - Create zone and button to show the admin console --- front/dist/resources/style/style.css | 37 ++++++++++++++ front/src/Connection.ts | 20 +++++--- front/src/Phaser/Game/GameScene.ts | 4 ++ .../src/WebRtc/ConsoleGlobalMessageManager.ts | 51 +++++++++++++++++++ front/src/WebRtc/GlobalMessageManager.ts | 6 +-- 5 files changed, 107 insertions(+), 11 deletions(-) create mode 100644 front/src/WebRtc/ConsoleGlobalMessageManager.ts diff --git a/front/dist/resources/style/style.css b/front/dist/resources/style/style.css index bf495f90..39a7af02 100644 --- a/front/dist/resources/style/style.css +++ b/front/dist/resources/style/style.css @@ -414,3 +414,40 @@ body { background-color: #00000096; border-radius: 0 0 10px 10px; } + +.main-console{ + position: absolute; + width: 80%; + top: 0; + left: 10%; + background: #000000a6; + z-index: 200; + height: auto; + transition: all 0.1s ease-out; +} +.main-console div{ + position: absolute; + background: none repeat scroll 0% 0% #ccc0; + border-color: #000000 #ffffff00 #ffffff00 #ffffff00; + border-style: solid; + border-width: 20px 7px; + height: auto; + width: 10%; + color: white; + z-index: 200; + left: 45%; + transition: all 0.1s ease-out; + display: none; +} +.main-console div.active{ + display: block; +} +.main-console div span{ + position: absolute; + top: -20px; + left: 30%; +} +.main-console div:hover{ + cursor: pointer; + transform: scale(1.2) translateY(3px); +} \ No newline at end of file diff --git a/front/src/Connection.ts b/front/src/Connection.ts index b930f198..1341347b 100644 --- a/front/src/Connection.ts +++ b/front/src/Connection.ts @@ -283,14 +283,6 @@ export class Connection implements Connection { return this.socket.on(EventMessage.WEBRTC_SCREEN_SHARING_SIGNAL, callback); } - public receivePlayGlobalMessage(callback: (message: GlobalMessageInterface) => void) { - return this.socket.on(EventMessage.PLAY_GLOBAL_MESSAGE, callback); - } - - public receiveStopGlobalMessage(callback: (message: GlobalMessageInterface) => void) { - return this.socket.on(EventMessage.STOP_GLOBAL_MESSAGE, callback); - } - public onServerDisconnected(callback: (reason: string) => void): void { this.socket.on('disconnect', (reason: string) => { if (reason === 'io client disconnect') { @@ -322,4 +314,16 @@ export class Connection implements Connection { onActionableEvent(callback: (message: ItemEventMessageInterface) => void): void { this.socket.on(EventMessage.ITEM_EVENT, callback); } + + public receivePlayGlobalMessage(callback: (message: GlobalMessageInterface) => void) { + return this.socket.on(EventMessage.PLAY_GLOBAL_MESSAGE, callback); + } + + public receiveStopGlobalMessage(callback: (message: GlobalMessageInterface) => void) { + return this.socket.on(EventMessage.STOP_GLOBAL_MESSAGE, callback); + } + + public emitGlobalMessage(message: GlobalMessageInterface){ + return this.socket.emit(EventMessage.PLAY_GLOBAL_MESSAGE, message); + } } diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 37e7c2ef..332c3bcd 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -41,6 +41,7 @@ import {ItemFactoryInterface} from "../Items/ItemFactoryInterface"; import {ActionableItem} from "../Items/ActionableItem"; import {UserInputManager} from "../UserInput/UserInputManager"; import {GlobalMessageManager} from "../../WebRtc/GlobalMessageManager"; +import {ConsoleGlobalMessageManager} from "../../WebRtc/ConsoleGlobalMessageManager"; export enum Textures { @@ -102,6 +103,7 @@ export class GameScene extends Phaser.Scene implements CenterListener { private connection!: Connection; private simplePeer!: SimplePeer; private GlobalMessageManager!: GlobalMessageManager; + private ConsoleGlobalMessageManager!: ConsoleGlobalMessageManager; private connectionPromise!: Promise private connectionAnswerPromise: Promise; private connectionAnswerPromiseResolve!: (value?: RoomJoinedMessageInterface | PromiseLike) => void; @@ -268,6 +270,8 @@ export class GameScene extends Phaser.Scene implements CenterListener { // When connection is performed, let's connect SimplePeer this.simplePeer = new SimplePeer(this.connection); this.GlobalMessageManager = new GlobalMessageManager(this.connection); + //TODO check right of user + this.ConsoleGlobalMessageManager = new ConsoleGlobalMessageManager(this.connection); const self = this; this.simplePeer.registerPeerConnectionListener({ diff --git a/front/src/WebRtc/ConsoleGlobalMessageManager.ts b/front/src/WebRtc/ConsoleGlobalMessageManager.ts new file mode 100644 index 00000000..fe7fa216 --- /dev/null +++ b/front/src/WebRtc/ConsoleGlobalMessageManager.ts @@ -0,0 +1,51 @@ +import {HtmlUtils} from "./HtmlUtils"; +import {Connection, GlobalMessageInterface} from "../Connection"; + +export const CLASS_CONSOLE_MESSAGE = 'main-console'; +export const INPUT_CONSOLE_MESSAGE = 'input-send-text'; +export const UPLOAD_CONSOLE_MESSAGE = 'input-upload-music'; +export const BUTTON_CONSOLE_SEND = 'button-send'; +export const INPUT_TYPE_CONSOLE = 'input-type'; + +export const AUDIO_TYPE = 'audio'; +export const MESSAGE_TYPE = 'message'; + +export class ConsoleGlobalMessageManager { + + private Connection: Connection; + + constructor(Connection: Connection) { + this.Connection = Connection; + this.initialise(); + } + + initialise(){ + const buttonText = document.createElement('span'); + buttonText.innerText = 'Console'; + + const buttonMainConsole = document.createElement('div'); + buttonMainConsole.classList.add('active'); + buttonMainConsole.appendChild(buttonText) + + const divMainConsole = document.createElement('div'); + divMainConsole.className = CLASS_CONSOLE_MESSAGE; + divMainConsole.appendChild(buttonMainConsole) + + const mainSectionDiv = HtmlUtils.getElementByIdOrFail('main-container'); + mainSectionDiv.appendChild(divMainConsole); + } + + sendMessage(html: string){ + const inputText = HtmlUtils.getElementByIdOrFail(INPUT_CONSOLE_MESSAGE); + const inputType = HtmlUtils.getElementByIdOrFail(INPUT_TYPE_CONSOLE); + if(AUDIO_TYPE !== inputType.innerText && MESSAGE_TYPE !== inputType.innerText){ + throw "Error event type"; + } + let GlobalMessage : GlobalMessageInterface = { + id: 1, + message: inputText.innerText, + type: inputType.innerText + }; + this.Connection.emitGlobalMessage(GlobalMessage); + } +} \ No newline at end of file diff --git a/front/src/WebRtc/GlobalMessageManager.ts b/front/src/WebRtc/GlobalMessageManager.ts index 91dc64c3..29868957 100644 --- a/front/src/WebRtc/GlobalMessageManager.ts +++ b/front/src/WebRtc/GlobalMessageManager.ts @@ -22,7 +22,7 @@ export class GlobalMessageManager { }); } - playMessage(messageId : number, htmlMessage: string){ + private playMessage(messageId : number, htmlMessage: string){ const div = document.createElement('div'); div.innerHTML = htmlMessage; div.id = this.getHtmlMessageId(messageId); @@ -32,11 +32,11 @@ export class GlobalMessageManager { mainSectionDiv.appendChild(div); } - stopMessage(messageId: number){ + private stopMessage(messageId: number){ HtmlUtils.removeElementByIdOrFail(this.getHtmlMessageId(messageId)); } - private getHtmlMessageId(messageId: number){ + private getHtmlMessageId(messageId: number) : string{ return `message-${messageId}`; } From 9dd3d4bac803a2d74e2387a8564679cb853c4fef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 16 Sep 2020 22:27:37 +0200 Subject: [PATCH 019/122] Watching protoc in dev mode --- back/package.json | 6 +- back/yarn.lock | 194 ++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 192 insertions(+), 8 deletions(-) diff --git a/back/package.json b/back/package.json index fc7ad60e..411beb94 100644 --- a/back/package.json +++ b/back/package.json @@ -5,13 +5,14 @@ "main": "index.js", "scripts": { "tsc": "tsc", - "dev": "ts-node-dev --respawn --transpileOnly ./server.ts", + "dev": "concurrently \"yarn run proto:watch\" \"ts-node-dev --respawn --transpileOnly ./server.ts\"", "prod": "tsc && node ./dist/server.js", "profile": "tsc && node --prof ./dist/server.js", "test": "ts-node node_modules/jasmine/bin/jasmine --config=jasmine.json", "lint": "node_modules/.bin/eslint src/ . --ext .ts", "fix": "node_modules/.bin/eslint --fix src/ . --ext .ts", - "proto": "protoc --plugin=\"protoc-gen-ts=./node_modules/.bin/protoc-gen-ts\" --js_out=\"import_style=commonjs,binary:src/proto/generated\" --ts_out=\"src/proto/generated\" src/proto/messages.proto" + "proto": "protoc --plugin=\"protoc-gen-ts=./node_modules/.bin/protoc-gen-ts\" --js_out=\"import_style=commonjs,binary:src/proto/generated\" --ts_out=\"src/proto/generated\" src/proto/messages.proto", + "proto:watch": "inotifywait -q -m -e close_write src/proto/messages.proto | while read -r filename event; do yarn run proto; done" }, "repository": { "type": "git", @@ -59,6 +60,7 @@ "@types/jasmine": "^3.5.10", "@typescript-eslint/eslint-plugin": "^2.26.0", "@typescript-eslint/parser": "^2.26.0", + "concurrently": "^5.3.0", "eslint": "^6.8.0", "jasmine": "^3.5.0", "ts-protoc-gen": "^0.13.0" diff --git a/back/yarn.lock b/back/yarn.lock index fe5c26e1..5384de4c 100644 --- a/back/yarn.lock +++ b/back/yarn.lock @@ -328,7 +328,12 @@ camelcase@^2.0.0: version "2.1.1" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-2.1.1.tgz#7c1d16d679a1bbe59ca02cacecfb011e201f5a1f" -chalk@^2.0.0, chalk@^2.1.0: +camelcase@^5.0.0: + version "5.3.1" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" + integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== + +chalk@^2.0.0, chalk@^2.1.0, chalk@^2.4.2: version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" dependencies: @@ -357,6 +362,15 @@ cli-width@^2.0.0: version "2.2.0" resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639" +cliui@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-5.0.0.tgz#deefcfdb2e800784aa34f46fa08e06851c7bbbc5" + integrity sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA== + dependencies: + string-width "^3.1.0" + strip-ansi "^5.2.0" + wrap-ansi "^5.1.0" + color-convert@^1.9.0: version "1.9.3" resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" @@ -393,6 +407,21 @@ concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" +concurrently@^5.3.0: + version "5.3.0" + resolved "https://registry.yarnpkg.com/concurrently/-/concurrently-5.3.0.tgz#7500de6410d043c912b2da27de3202cb489b1e7b" + integrity sha512-8MhqOB6PWlBfA2vJ8a0bSFKATOdWlHiQlk11IfmQBPaHVP8oP2gsh2MObE6UR3hqDHqvaIvLTyceNW6obVuFHQ== + dependencies: + chalk "^2.4.2" + date-fns "^2.0.1" + lodash "^4.17.15" + read-pkg "^4.0.1" + rxjs "^6.5.2" + spawn-command "^0.0.2-1" + supports-color "^6.1.0" + tree-kill "^1.2.2" + yargs "^13.3.0" + content-disposition@0.5.3: version "0.5.3" resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.3.tgz#e130caf7e7279087c5616c2007d0485698984fbd" @@ -431,6 +460,11 @@ currently-unhandled@^0.4.1: dependencies: array-find-index "^1.0.1" +date-fns@^2.0.1: + version "2.16.1" + resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.16.1.tgz#05775792c3f3331da812af253e1a935851d3834b" + integrity sha512-sAJVKx/FqrLYHAQeN7VpJrPhagZc9R4ImZIWYRFZaaohR3KzmuK88touwsSwSVT8Qcbd4zoDsnGfX4GFB4imyQ== + dateformat@~1.0.4-1.2.3: version "1.0.12" resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-1.0.12.tgz#9f124b67594c937ff706932e4a642cca8dbbfee9" @@ -460,7 +494,7 @@ debug@~3.1.0: dependencies: ms "2.0.0" -decamelize@^1.1.2: +decamelize@^1.1.2, decamelize@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" @@ -551,7 +585,7 @@ engine.io@~3.4.0: engine.io-parser "~2.2.0" ws "^7.1.2" -error-ex@^1.2.0: +error-ex@^1.2.0, error-ex@^1.3.1: version "1.3.2" resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" dependencies: @@ -762,6 +796,13 @@ find-up@^1.0.0: path-exists "^2.0.0" pinkie-promise "^2.0.0" +find-up@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-3.0.0.tgz#49169f1d7993430646da61ecc5ae355c21c97b73" + integrity sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg== + dependencies: + locate-path "^3.0.0" + flat-cache@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-2.0.1.tgz#5d296d6f04bda44a4630a301413bdbc2ec085ec0" @@ -795,6 +836,11 @@ generic-type-guard@^3.2.0: resolved "https://registry.yarnpkg.com/generic-type-guard/-/generic-type-guard-3.2.0.tgz#1fb136f934730c776486526b8a21fe96b067e691" integrity sha512-EkkrXYbOtJ3VPB+SOrU7EhwY65rZErItGtBg5wAqywaj07BOubwOZqMYaxOWekJ9akioGqXIsw1fYk3wwbWsDQ== +get-caller-file@^2.0.1: + version "2.0.5" + resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" + integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== + get-stdin@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe" @@ -1017,6 +1063,11 @@ js-yaml@^3.13.1: argparse "^1.0.7" esprima "^4.0.0" +json-parse-better-errors@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9" + integrity sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw== + json-schema-traverse@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" @@ -1072,6 +1123,14 @@ load-json-file@^1.0.0: pinkie-promise "^2.0.0" strip-bom "^2.0.0" +locate-path@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e" + integrity sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A== + dependencies: + p-locate "^3.0.0" + path-exists "^3.0.0" + lodash.includes@^4.3.0: version "4.3.0" resolved "https://registry.yarnpkg.com/lodash.includes/-/lodash.includes-4.3.0.tgz#60bb98a87cb923c68ca1e51325483314849f553f" @@ -1268,6 +1327,25 @@ os-tmpdir@~1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" +p-limit@^2.0.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1" + integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w== + dependencies: + p-try "^2.0.0" + +p-locate@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-3.0.0.tgz#322d69a05c0264b25997d9f40cd8a891ab0064a4" + integrity sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ== + dependencies: + p-limit "^2.0.0" + +p-try@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" + integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== + parent-module@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2" @@ -1280,6 +1358,14 @@ parse-json@^2.2.0: dependencies: error-ex "^1.2.0" +parse-json@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-4.0.0.tgz#be35f5425be1f7f6c747184f98a788cb99477ee0" + integrity sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA= + dependencies: + error-ex "^1.3.1" + json-parse-better-errors "^1.0.1" + parseqs@0.0.5: version "0.0.5" resolved "https://registry.yarnpkg.com/parseqs/-/parseqs-0.0.5.tgz#d5208a3738e46766e291ba2ea173684921a8b89d" @@ -1302,6 +1388,11 @@ path-exists@^2.0.0: dependencies: pinkie-promise "^2.0.0" +path-exists@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515" + integrity sha1-zg6+ql94yxiSXqfYENe1mwEP1RU= + path-is-absolute@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" @@ -1330,6 +1421,11 @@ pify@^2.0.0: version "2.3.0" resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" +pify@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176" + integrity sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY= + pinkie-promise@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa" @@ -1398,6 +1494,15 @@ read-pkg@^1.0.0: normalize-package-data "^2.3.2" path-type "^1.0.0" +read-pkg@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-4.0.1.tgz#963625378f3e1c4d48c85872b5a6ec7d5d093237" + integrity sha1-ljYlN48+HE1IyFhytabsfV0JMjc= + dependencies: + normalize-package-data "^2.3.2" + parse-json "^4.0.0" + pify "^3.0.0" + redent@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/redent/-/redent-1.0.0.tgz#cf916ab1fd5f1f16dfb20822dd6ec7f730c2afde" @@ -1419,6 +1524,16 @@ repeating@^2.0.0: dependencies: is-finite "^1.0.0" +require-directory@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" + integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I= + +require-main-filename@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b" + integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg== + resolve-from@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" @@ -1454,6 +1569,13 @@ run-async@^2.4.0: dependencies: is-promise "^2.1.0" +rxjs@^6.5.2: + version "6.6.3" + resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.6.3.tgz#8ca84635c4daa900c0d3967a6ee7ac60271ee552" + integrity sha512-trsQc+xYYXZ3urjOiJOuCOa5N3jAZ3eiSpQB5hIT8zGlL2QfnHLJ2r7GMkBGuIausdJN1OneaI6gQlsqNHHmZQ== + dependencies: + tslib "^1.9.0" + rxjs@^6.5.3: version "6.5.5" resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.5.5.tgz#c5c884e3094c8cfee31bf27eb87e54ccfc87f9ec" @@ -1507,6 +1629,11 @@ serve-static@1.14.1: parseurl "~1.3.3" send "0.17.1" +set-blocking@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" + integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc= + setprototypeof@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.1.1.tgz#7e95acb24aa92f5885e0abef5ba131330d4ae683" @@ -1598,6 +1725,11 @@ source-map@^0.6.0: version "0.6.1" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" +spawn-command@^0.0.2-1: + version "0.0.2-1" + resolved "https://registry.yarnpkg.com/spawn-command/-/spawn-command-0.0.2-1.tgz#62f5e9466981c1b796dc5929937e11c9c6921bd0" + integrity sha1-YvXpRmmBwbeW3Fkpk34RycaSG9A= + spdx-correct@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.1.0.tgz#fb83e504445268f154b074e218c87c003cd31df4" @@ -1628,7 +1760,7 @@ sprintf-js@~1.0.2: version "1.5.0" resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" -string-width@^3.0.0: +string-width@^3.0.0, string-width@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/string-width/-/string-width-3.1.0.tgz#22767be21b62af1081574306f69ac51b62203961" dependencies: @@ -1644,7 +1776,7 @@ string-width@^4.1.0: is-fullwidth-code-point "^3.0.0" strip-ansi "^6.0.0" -strip-ansi@^5.1.0, strip-ansi@^5.2.0: +strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-5.2.0.tgz#8c9a536feb6afc962bdfa5b104a5091c1ad9c0ae" dependencies: @@ -1686,6 +1818,13 @@ supports-color@^5.3.0: dependencies: has-flag "^3.0.0" +supports-color@^6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-6.1.0.tgz#0764abc69c63d5ac842dd4867e8d025e880df8f3" + integrity sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ== + dependencies: + has-flag "^3.0.0" + supports-color@^7.1.0: version "7.1.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.1.0.tgz#68e32591df73e25ad1c4b49108a2ec507962bfd1" @@ -1734,7 +1873,7 @@ toidentifier@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.0.tgz#7e1be3470f1e77948bc43d94a3c8f4d7752ba553" -tree-kill@^1.2.1: +tree-kill@^1.2.1, tree-kill@^1.2.2: version "1.2.2" resolved "https://registry.yarnpkg.com/tree-kill/-/tree-kill-1.2.2.tgz#4ca09a9092c88b73a7cdc5e8a01b507b0790a0cc" @@ -1859,6 +1998,11 @@ vary@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" +which-module@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" + integrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho= + which@^1.2.9, which@^1.3.0: version "1.3.1" resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" @@ -1869,6 +2013,15 @@ word-wrap@~1.2.3: version "1.2.3" resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c" +wrap-ansi@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-5.1.0.tgz#1fd1f67235d5b6d0fee781056001bfb694c03b09" + integrity sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q== + dependencies: + ansi-styles "^3.2.0" + string-width "^3.0.0" + strip-ansi "^5.0.0" + wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" @@ -1897,6 +2050,35 @@ xtend@^4.0.0: version "4.0.2" resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54" +y18n@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b" + integrity sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w== + +yargs-parser@^13.1.2: + version "13.1.2" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-13.1.2.tgz#130f09702ebaeef2650d54ce6e3e5706f7a4fb38" + integrity sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg== + dependencies: + camelcase "^5.0.0" + decamelize "^1.2.0" + +yargs@^13.3.0: + version "13.3.2" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-13.3.2.tgz#ad7ffefec1aa59565ac915f82dccb38a9c31a2dd" + integrity sha512-AX3Zw5iPruN5ie6xGRIDgqkT+ZhnRlZMLMHAs8tg7nRruy2Nb+i5o9bwghAogtM08q1dpr2LVoS8KSTMYpWXUw== + dependencies: + cliui "^5.0.0" + find-up "^3.0.0" + get-caller-file "^2.0.1" + require-directory "^2.1.1" + require-main-filename "^2.0.0" + set-blocking "^2.0.0" + string-width "^3.0.0" + which-module "^2.0.0" + y18n "^4.0.0" + yargs-parser "^13.1.2" + yeast@0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/yeast/-/yeast-0.1.2.tgz#008e06d8094320c372dbc2f8ed76a0ca6c8ac419" From 4b55b54a07d1c7eff8636e55a35914b67c394cbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 17 Sep 2020 17:14:47 +0200 Subject: [PATCH 020/122] Adding first protobuf message exchange --- back/package.json | 6 +- back/src/Controller/IoSocketController.ts | 9 +- back/src/proto/generated/.gitkeep | 0 back/yarn.lock | 7 +- benchmark/.gitignore | 3 + benchmark/package-lock.json | 1970 +++++++++++++++++ docker-compose.yaml | 2 + front/src/Connection.ts | 10 +- front/src/Messages/SetPlayerDetailsMessage.ts | 4 - messages/.gitignore | 1 + messages/generated/.gitignore | 1 + messages/generated/src/proto/messages_pb.d.ts | 31 + messages/generated/src/proto/messages_pb.js | 223 ++ {back/src/proto => messages}/messages.proto | 0 messages/package.json | 43 + messages/yarn.lock | 889 ++++++++ 16 files changed, 3185 insertions(+), 14 deletions(-) delete mode 100644 back/src/proto/generated/.gitkeep create mode 100644 benchmark/.gitignore create mode 100644 benchmark/package-lock.json delete mode 100644 front/src/Messages/SetPlayerDetailsMessage.ts create mode 100644 messages/.gitignore create mode 100644 messages/generated/.gitignore create mode 100644 messages/generated/src/proto/messages_pb.d.ts create mode 100644 messages/generated/src/proto/messages_pb.js rename {back/src/proto => messages}/messages.proto (100%) create mode 100644 messages/package.json create mode 100644 messages/yarn.lock diff --git a/back/package.json b/back/package.json index 411beb94..e9a4d4fc 100644 --- a/back/package.json +++ b/back/package.json @@ -11,8 +11,8 @@ "test": "ts-node node_modules/jasmine/bin/jasmine --config=jasmine.json", "lint": "node_modules/.bin/eslint src/ . --ext .ts", "fix": "node_modules/.bin/eslint --fix src/ . --ext .ts", - "proto": "protoc --plugin=\"protoc-gen-ts=./node_modules/.bin/protoc-gen-ts\" --js_out=\"import_style=commonjs,binary:src/proto/generated\" --ts_out=\"src/proto/generated\" src/proto/messages.proto", - "proto:watch": "inotifywait -q -m -e close_write src/proto/messages.proto | while read -r filename event; do yarn run proto; done" + "proto": "protoc --plugin=\"protoc-gen-ts=./node_modules/.bin/protoc-gen-ts\" --js_out=\"import_style=commonjs,binary:src/messages/generated\" --ts_out=\"src/messages/generated\" src/messages/messages.proto", + "proto:watch": "inotifywait -q -m -e close_write src/messages/messages.proto | while read -r filename event; do yarn run proto; done" }, "repository": { "type": "git", @@ -46,7 +46,6 @@ "body-parser": "^1.19.0", "express": "^4.17.1", "generic-type-guard": "^3.2.0", - "google-protobuf": "^3.13.0", "http-status-codes": "^1.4.0", "jsonwebtoken": "^8.5.1", "prom-client": "^12.0.0", @@ -57,6 +56,7 @@ "uuidv4": "^6.0.7" }, "devDependencies": { + "@types/google-protobuf": "^3.7.3", "@types/jasmine": "^3.5.10", "@typescript-eslint/eslint-plugin": "^2.26.0", "@typescript-eslint/parser": "^2.26.0", diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index 56168804..38950e35 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -24,6 +24,7 @@ import {isUserMovesInterface} from "../Model/Websocket/UserMovesMessage"; import {isViewport} from "../Model/Websocket/ViewportMessage"; import {GroupUpdateInterface} from "_Model/Websocket/GroupUpdateInterface"; import {Movable} from "../Model/Movable"; +import {SetPlayerDetailsMessage} from "../../../messages/generated/src/proto/messages_pb"; enum SockerIoEvent { CONNECTION = "connection", @@ -334,7 +335,13 @@ export class IoSocketController { }); // Let's send the user id to the user - socket.on(SockerIoEvent.SET_PLAYER_DETAILS, (playerDetails: unknown, answerFn) => { + socket.on(SockerIoEvent.SET_PLAYER_DETAILS, (message: any, answerFn) => { + console.log(SockerIoEvent.SET_PLAYER_DETAILS, message); + const playerDetailsMessage = SetPlayerDetailsMessage.deserializeBinary(new Uint8Array(message)); + const playerDetails = { + name: playerDetailsMessage.getName(), + characterLayers: playerDetailsMessage.getCharacterlayersList() + }; console.log(SockerIoEvent.SET_PLAYER_DETAILS, playerDetails); if (!isSetPlayerDetailsMessage(playerDetails)) { socket.emit(SockerIoEvent.MESSAGE_ERROR, {message: 'Invalid SET_PLAYER_DETAILS message.'}); diff --git a/back/src/proto/generated/.gitkeep b/back/src/proto/generated/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/back/yarn.lock b/back/yarn.lock index 5384de4c..a3269cb5 100644 --- a/back/yarn.lock +++ b/back/yarn.lock @@ -57,6 +57,11 @@ "@types/qs" "*" "@types/serve-static" "*" +"@types/google-protobuf@^3.7.3": + version "3.7.3" + resolved "https://registry.yarnpkg.com/@types/google-protobuf/-/google-protobuf-3.7.3.tgz#429512e541bbd777f2c867692e6335ee08d1f6d4" + integrity sha512-FRwj40euE2bYkG+0X5w2nEA8yAzgJRcEa7RBd0Gsdkb9/tPM2pctVVAvnOUTbcXo2VmIHPo0Ae94Gl9vRHfKzg== + "@types/http-status-codes@^1.2.0": version "1.2.0" resolved "https://registry.yarnpkg.com/@types/http-status-codes/-/http-status-codes-1.2.0.tgz#6e5244835aaf7164dd306f1d4d2dfdbb2159d909" @@ -868,7 +873,7 @@ globals@^12.1.0: dependencies: type-fest "^0.8.1" -google-protobuf@^3.13.0, google-protobuf@^3.6.1: +google-protobuf@^3.6.1: version "3.13.0" resolved "https://registry.yarnpkg.com/google-protobuf/-/google-protobuf-3.13.0.tgz#909c5983d75dd6101ed57c79e0528d000cdc3251" integrity sha512-ZIf3qfLFayVrPvAjeKKxO5FRF1/NwRxt6Dko+fWEMuHwHbZx8/fcaAao9b0wCM6kr8qeg2te8XTpyuvKuD9aKw== diff --git a/benchmark/.gitignore b/benchmark/.gitignore new file mode 100644 index 00000000..cbff8d41 --- /dev/null +++ b/benchmark/.gitignore @@ -0,0 +1,3 @@ +/node_modules/ +/artillery_output.html +/artillery_output.json diff --git a/benchmark/package-lock.json b/benchmark/package-lock.json new file mode 100644 index 00000000..4d8a4edf --- /dev/null +++ b/benchmark/package-lock.json @@ -0,0 +1,1970 @@ +{ + "name": "workadventure-artillery", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@types/node": { + "version": "14.6.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.6.4.tgz", + "integrity": "sha512-Wk7nG1JSaMfMpoMJDKUsWYugliB2Vy55pdjLpmLixeyMi7HizW2I/9QoxsPCkXl3dO+ZOVqPumKaDUv5zJu2uQ==" + }, + "after": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/after/-/after-0.8.2.tgz", + "integrity": "sha1-/ts5T58OAqqXaOcCvaI7UF+ufh8=" + }, + "ajv": { + "version": "6.12.4", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.4.tgz", + "integrity": "sha512-eienB2c9qVQs2KWexhkrdMLVDoIQCz5KSeLxwg9Lzk4DOfBtIK9PQwwufcsn1jjGuf9WZmqPMbGxOzfcuphJCQ==", + "requires": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "ansi-align": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ansi-align/-/ansi-align-2.0.0.tgz", + "integrity": "sha1-w2rsy6VjuJzrVW82kPCx2eNUf38=", + "requires": { + "string-width": "^2.0.0" + } + }, + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=" + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "arraybuffer.slice": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.7.tgz", + "integrity": "sha512-wGUIVQXuehL5TCqQun8OW81jGzAWycqzFF8lFp+GOM5BXLYj3bKNsYC4daB7n6XjCqxQA/qgTJ+8ANR3acjrog==" + }, + "arrivals": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/arrivals/-/arrivals-2.1.2.tgz", + "integrity": "sha512-g3+rxhxUen2H4+PPBOz6U6pkQ4esBuQPna1rPskgK1jamBdDZeoppyB2vPUM/l0ccunwRrq4r2rKgCvc2FnrFA==", + "requires": { + "debug": "^4.0.1", + "nanotimer": "0.3.14" + }, + "dependencies": { + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "requires": { + "ms": "^2.1.1" + } + }, + "nanotimer": { + "version": "0.3.14", + "resolved": "https://registry.npmjs.org/nanotimer/-/nanotimer-0.3.14.tgz", + "integrity": "sha1-ENgR+NBkeIGACWzh+WxwhG/Voro=" + } + } + }, + "artillery": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/artillery/-/artillery-1.6.1.tgz", + "integrity": "sha512-yRUqYziBsnAuzBM4G3d1uJ0YvbyxLF3e7BsjMxguzOaNxxdAFAady2CBJWe1BrPM4yLnW6lH/O6AcSG/CPzjfw==", + "requires": { + "arrivals": "^2.1.2", + "artillery-plugin-statsd": "^2.2.1", + "async": "^1.5.2", + "chalk": "1.1.3", + "cheerio": "^1.0.0-rc.2", + "commander": "2.9.0", + "csv-parse": "^4.4.6", + "debug": "^2.2.0", + "deep-equal": "^1.0.1", + "deep-for-each": "^3.0.0", + "driftless": "^2.0.3", + "esprima": "^4.0.0", + "filtrex": "^0.5.4", + "js-yaml": "^3.13.1", + "jsck": "^0.3.2", + "jsonpath": "^1.0.2", + "lodash": "^4.17.13", + "moment": "^2.22.1", + "nanotimer": "^0.3.15", + "opn": "^5.3.0", + "ora": "^1.3.0", + "pidusage": "^1.1.6", + "rc": "^1.1.6", + "request": "^2.88.0", + "socket.io-client": "^2.1.0", + "socketio-wildcard": "^2.0.0", + "stats-lite": "^2.1.0", + "tmp": "0.0.28", + "tough-cookie": "^2.3.4", + "try-require": "^1.2.1", + "update-notifier": "^2.1.0", + "uuid": "^2.0.3", + "ws": "^5.1.1" + } + }, + "artillery-plugin-statsd": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/artillery-plugin-statsd/-/artillery-plugin-statsd-2.2.1.tgz", + "integrity": "sha512-Zn6hxi11p1Rpazopm8bZkIqhIA5laTE3/amEhLsE933o8bgvrAJBblpsZ45vhmURztsglqC9yxSCQyW27yUZmQ==", + "requires": { + "debug": "^3.1.0", + "lodash": "^4.17.11", + "lynx": "^0.2.0" + }, + "dependencies": { + "debug": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "requires": { + "ms": "^2.1.1" + } + } + } + }, + "asn1": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", + "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", + "requires": { + "safer-buffer": "~2.1.0" + } + }, + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" + }, + "async": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", + "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=" + }, + "async-limiter": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz", + "integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==" + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + }, + "aws-sign2": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", + "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=" + }, + "aws4": { + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.10.1.tgz", + "integrity": "sha512-zg7Hz2k5lI8kb7U32998pRRFin7zJlkfezGJjUc2heaD4Pw2wObakCDVzkKztTm/Ln7eiVvYsjqak0Ed4LkMDA==" + }, + "backo2": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz", + "integrity": "sha1-MasayLEpNjRj41s+u2n038+6eUc=" + }, + "base64-arraybuffer": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz", + "integrity": "sha1-c5JncZI7Whl0etZmqlzUv5xunOg=" + }, + "bcrypt-pbkdf": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", + "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", + "requires": { + "tweetnacl": "^0.14.3" + } + }, + "better-assert": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/better-assert/-/better-assert-1.0.2.tgz", + "integrity": "sha1-QIZrnhueC1W0gYlDEeaPr/rrxSI=", + "requires": { + "callsite": "1.0.0" + } + }, + "blob": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/blob/-/blob-0.0.5.tgz", + "integrity": "sha512-gaqbzQPqOoamawKg0LGVd7SzLgXS+JH61oWprSLH+P+abTczqJbhTR8CmJ2u9/bUYNmHTGJx/UEmn6doAvvuig==" + }, + "boolbase": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", + "integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24=" + }, + "boxen": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/boxen/-/boxen-1.3.0.tgz", + "integrity": "sha512-TNPjfTr432qx7yOjQyaXm3dSR0MH9vXp7eT1BFSl/C51g+EFnOR9hTg1IreahGBmDNCehscshe45f+C1TBZbLw==", + "requires": { + "ansi-align": "^2.0.0", + "camelcase": "^4.0.0", + "chalk": "^2.0.1", + "cli-boxes": "^1.0.0", + "string-width": "^2.0.0", + "term-size": "^1.2.0", + "widest-line": "^2.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "requires": { + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "callsite": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/callsite/-/callsite-1.0.0.tgz", + "integrity": "sha1-KAOY5dZkvXQDi28JBRU+borxvCA=" + }, + "camelcase": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz", + "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=" + }, + "capture-stack-trace": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/capture-stack-trace/-/capture-stack-trace-1.0.1.tgz", + "integrity": "sha512-mYQLZnx5Qt1JgB1WEiMCf2647plpGeQ2NMR/5L0HNZzGQo4fuSPnK+wjfPnKZV0aiJDgzmWqqkV/g7JD+DW0qw==" + }, + "caseless": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "requires": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + } + }, + "cheerio": { + "version": "1.0.0-rc.3", + "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.3.tgz", + "integrity": "sha512-0td5ijfUPuubwLUu0OBoe98gZj8C/AA+RW3v67GPlGOrvxWjZmBXiBCRU+I8VEiNyJzjth40POfHiz2RB3gImA==", + "requires": { + "css-select": "~1.2.0", + "dom-serializer": "~0.1.1", + "entities": "~1.1.1", + "htmlparser2": "^3.9.1", + "lodash": "^4.15.0", + "parse5": "^3.0.1" + } + }, + "ci-info": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-1.6.0.tgz", + "integrity": "sha512-vsGdkwSCDpWmP80ncATX7iea5DWQemg1UgCW5J8tqjU3lYw4FBYuj89J0CTVomA7BEfvSZd84GmHko+MxFQU2A==" + }, + "cli-boxes": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/cli-boxes/-/cli-boxes-1.0.0.tgz", + "integrity": "sha1-T6kXw+WclKAEzWH47lCdplFocUM=" + }, + "cli-cursor": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", + "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", + "requires": { + "restore-cursor": "^2.0.0" + } + }, + "cli-spinners": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-1.3.1.tgz", + "integrity": "sha512-1QL4544moEsDVH9T/l6Cemov/37iv1RtoKf7NJ04A60+4MREXNfx/QvavbH6QoGdsD4N4Mwy49cmaINR/o2mdg==" + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, + "combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "commander": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz", + "integrity": "sha1-nJkJQXbhIkDLItbFFGCYQA/g99Q=", + "requires": { + "graceful-readlink": ">= 1.0.0" + } + }, + "component-bind": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/component-bind/-/component-bind-1.0.0.tgz", + "integrity": "sha1-AMYIq33Nk4l8AAllGx06jh5zu9E=" + }, + "component-emitter": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", + "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=" + }, + "component-inherit": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/component-inherit/-/component-inherit-0.0.3.tgz", + "integrity": "sha1-ZF/ErfWLcrZJ1crmUTVhnbJv8UM=" + }, + "configstore": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/configstore/-/configstore-3.1.5.tgz", + "integrity": "sha512-nlOhI4+fdzoK5xmJ+NY+1gZK56bwEaWZr8fYuXohZ9Vkc1o3a4T/R3M+yE/w7x/ZVJ1zF8c+oaOvF0dztdUgmA==", + "requires": { + "dot-prop": "^4.2.1", + "graceful-fs": "^4.1.2", + "make-dir": "^1.0.0", + "unique-string": "^1.0.0", + "write-file-atomic": "^2.0.0", + "xdg-basedir": "^3.0.0" + } + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" + }, + "create-error-class": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/create-error-class/-/create-error-class-3.0.2.tgz", + "integrity": "sha1-Br56vvlHo/FKMP1hBnHUAbyot7Y=", + "requires": { + "capture-stack-trace": "^1.0.0" + } + }, + "cross-spawn": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", + "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", + "requires": { + "lru-cache": "^4.0.1", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + } + }, + "crypto-random-string": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-1.0.0.tgz", + "integrity": "sha1-ojD2T1aDEOFJgAmUB5DsmVRbyn4=" + }, + "css-select": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/css-select/-/css-select-1.2.0.tgz", + "integrity": "sha1-KzoRBTnFNV8c2NMUYj6HCxIeyFg=", + "requires": { + "boolbase": "~1.0.0", + "css-what": "2.1", + "domutils": "1.5.1", + "nth-check": "~1.0.1" + } + }, + "css-what": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/css-what/-/css-what-2.1.3.tgz", + "integrity": "sha512-a+EPoD+uZiNfh+5fxw2nO9QwFa6nJe2Or35fGY6Ipw1R3R4AGz1d1TEZrCegvw2YTmZ0jXirGYlzxxpYSHwpEg==" + }, + "csv-parse": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/csv-parse/-/csv-parse-4.12.0.tgz", + "integrity": "sha512-wPQl3H79vWLPI8cgKFcQXl0NBgYYEqVnT1i6/So7OjMpsI540oD7p93r3w6fDSyPvwkTepG05F69/7AViX2lXg==" + }, + "dashdash": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", + "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", + "requires": { + "assert-plus": "^1.0.0" + } + }, + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + }, + "dependencies": { + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + } + } + }, + "deep-equal": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.1.1.tgz", + "integrity": "sha512-yd9c5AdiqVcR+JjcwUQb9DkhJc8ngNr0MahEBGvDiJw8puWab2yZlh+nkasOnZP+EGTAP6rRp2JzJhJZzvNF8g==", + "requires": { + "is-arguments": "^1.0.4", + "is-date-object": "^1.0.1", + "is-regex": "^1.0.4", + "object-is": "^1.0.1", + "object-keys": "^1.1.1", + "regexp.prototype.flags": "^1.2.0" + } + }, + "deep-extend": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", + "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==" + }, + "deep-for-each": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/deep-for-each/-/deep-for-each-3.0.0.tgz", + "integrity": "sha512-pPN+0f8jlnNP+z90qqOdxGghJU5XM6oBDhvAR+qdQzjCg5pk/7VPPvKK1GqoXEFkHza6ZS+Otzzvmr0g3VUaKw==", + "requires": { + "lodash.isplainobject": "^4.0.6" + } + }, + "deep-is": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", + "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=" + }, + "define-properties": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", + "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", + "requires": { + "object-keys": "^1.0.12" + } + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + }, + "dom-serializer": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.1.tgz", + "integrity": "sha512-l0IU0pPzLWSHBcieZbpOKgkIn3ts3vAh7ZuFyXNwJxJXk/c4Gwj9xaTJwIDVQCXawWD0qb3IzMGH5rglQaO0XA==", + "requires": { + "domelementtype": "^1.3.0", + "entities": "^1.1.1" + } + }, + "domelementtype": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.1.tgz", + "integrity": "sha512-BSKB+TSpMpFI/HOxCNr1O8aMOTZ8hT3pM3GQ0w/mWRmkhEDSFJkkyzz4XQsBV44BChwGkrDfMyjVD0eA2aFV3w==" + }, + "domhandler": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.4.2.tgz", + "integrity": "sha512-JiK04h0Ht5u/80fdLMCEmV4zkNh2BcoMFBmZ/91WtYZ8qVXSKjiw7fXMgFPnHcSZgOo3XdinHvmnDUeMf5R4wA==", + "requires": { + "domelementtype": "1" + } + }, + "domutils": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz", + "integrity": "sha1-3NhIiib1Y9YQeeSMn3t+Mjc2gs8=", + "requires": { + "dom-serializer": "0", + "domelementtype": "1" + } + }, + "dot-prop": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-4.2.1.tgz", + "integrity": "sha512-l0p4+mIuJIua0mhxGoh4a+iNL9bmeK5DvnSVQa6T0OhrVmaEa1XScX5Etc673FePCJOArq/4Pa2cLGODUWTPOQ==", + "requires": { + "is-obj": "^1.0.0" + } + }, + "driftless": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/driftless/-/driftless-2.0.3.tgz", + "integrity": "sha512-hSDKsQphnL4O0XLAiyWQ8EiM9suXH0Qd4gMtwF86b5wygGV8r95w0JcA38FOmx9N3LjFCIHLG2winLPNken4Tg==", + "requires": { + "present": "^0.0.3" + } + }, + "duplexer3": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.4.tgz", + "integrity": "sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=" + }, + "ecc-jsbn": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", + "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", + "requires": { + "jsbn": "~0.1.0", + "safer-buffer": "^2.1.0" + } + }, + "engine.io-client": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-3.4.3.tgz", + "integrity": "sha512-0NGY+9hioejTEJCaSJZfWZLk4FPI9dN+1H1C4+wj2iuFba47UgZbJzfWs4aNFajnX/qAaYKbe2lLTfEEWzCmcw==", + "requires": { + "component-emitter": "~1.3.0", + "component-inherit": "0.0.3", + "debug": "~4.1.0", + "engine.io-parser": "~2.2.0", + "has-cors": "1.1.0", + "indexof": "0.0.1", + "parseqs": "0.0.5", + "parseuri": "0.0.5", + "ws": "~6.1.0", + "xmlhttprequest-ssl": "~1.5.4", + "yeast": "0.1.2" + }, + "dependencies": { + "component-emitter": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", + "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==" + }, + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "requires": { + "ms": "^2.1.1" + } + }, + "ws": { + "version": "6.1.4", + "resolved": "https://registry.npmjs.org/ws/-/ws-6.1.4.tgz", + "integrity": "sha512-eqZfL+NE/YQc1/ZynhojeV8q+H050oR8AZ2uIev7RU10svA9ZnJUddHcOUZTJLinZ9yEfdA2kSATS2qZK5fhJA==", + "requires": { + "async-limiter": "~1.0.0" + } + } + } + }, + "engine.io-parser": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-2.2.0.tgz", + "integrity": "sha512-6I3qD9iUxotsC5HEMuuGsKA0cXerGz+4uGcXQEkfBidgKf0amsjrrtwcbwK/nzpZBxclXlV7gGl9dgWvu4LF6w==", + "requires": { + "after": "0.8.2", + "arraybuffer.slice": "~0.0.7", + "base64-arraybuffer": "0.1.5", + "blob": "0.0.5", + "has-binary2": "~1.0.2" + } + }, + "entities": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz", + "integrity": "sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==" + }, + "es-abstract": { + "version": "1.17.6", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.6.tgz", + "integrity": "sha512-Fr89bON3WFyUi5EvAeI48QTWX0AyekGgLA8H+c+7fbfCkJwRWRMLd8CQedNEyJuoYYhmtEqY92pgte1FAhBlhw==", + "requires": { + "es-to-primitive": "^1.2.1", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1", + "is-callable": "^1.2.0", + "is-regex": "^1.1.0", + "object-inspect": "^1.7.0", + "object-keys": "^1.1.1", + "object.assign": "^4.1.0", + "string.prototype.trimend": "^1.0.1", + "string.prototype.trimstart": "^1.0.1" + } + }, + "es-to-primitive": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", + "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", + "requires": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + } + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, + "escodegen": { + "version": "1.14.3", + "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.14.3.tgz", + "integrity": "sha512-qFcX0XJkdg+PB3xjZZG/wKSuT1PnQWx57+TVSjIMmILd2yC/6ByYElPwJnslDsuWuSAp4AwJGumarAAmJch5Kw==", + "requires": { + "esprima": "^4.0.1", + "estraverse": "^4.2.0", + "esutils": "^2.0.2", + "optionator": "^0.8.1", + "source-map": "~0.6.1" + } + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" + }, + "estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==" + }, + "esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==" + }, + "execa": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-0.7.0.tgz", + "integrity": "sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c=", + "requires": { + "cross-spawn": "^5.0.1", + "get-stream": "^3.0.0", + "is-stream": "^1.1.0", + "npm-run-path": "^2.0.0", + "p-finally": "^1.0.0", + "signal-exit": "^3.0.0", + "strip-eof": "^1.0.0" + } + }, + "extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" + }, + "extsprintf": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", + "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" + }, + "fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" + }, + "fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==" + }, + "fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=" + }, + "filtrex": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/filtrex/-/filtrex-0.5.4.tgz", + "integrity": "sha1-mAddUY8GjE9Yt7WJoifZi9n2OV0=" + }, + "forever-agent": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=" + }, + "form-data": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", + "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" + } + }, + "function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" + }, + "get-stream": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" + }, + "getpass": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", + "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", + "requires": { + "assert-plus": "^1.0.0" + } + }, + "global-dirs": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/global-dirs/-/global-dirs-0.1.1.tgz", + "integrity": "sha1-sxnA3UYH81PzvpzKTHL8FIxJ9EU=", + "requires": { + "ini": "^1.3.4" + } + }, + "got": { + "version": "6.7.1", + "resolved": "https://registry.npmjs.org/got/-/got-6.7.1.tgz", + "integrity": "sha1-JAzQV4WpoY5WHcG0S0HHY+8ejbA=", + "requires": { + "create-error-class": "^3.0.0", + "duplexer3": "^0.1.4", + "get-stream": "^3.0.0", + "is-redirect": "^1.0.0", + "is-retry-allowed": "^1.0.0", + "is-stream": "^1.0.0", + "lowercase-keys": "^1.0.0", + "safe-buffer": "^5.0.1", + "timed-out": "^4.0.0", + "unzip-response": "^2.0.1", + "url-parse-lax": "^1.0.0" + } + }, + "graceful-fs": { + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz", + "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==" + }, + "graceful-readlink": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz", + "integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=" + }, + "har-schema": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", + "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=" + }, + "har-validator": { + "version": "5.1.5", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.5.tgz", + "integrity": "sha512-nmT2T0lljbxdQZfspsno9hgrG3Uir6Ks5afism62poxqBM6sDnMEuPmzTq8XN0OEwqKLLdh1jQI3qyE66Nzb3w==", + "requires": { + "ajv": "^6.12.3", + "har-schema": "^2.0.0" + } + }, + "has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "requires": { + "function-bind": "^1.1.1" + } + }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "has-binary2": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-binary2/-/has-binary2-1.0.3.tgz", + "integrity": "sha512-G1LWKhDSvhGeAQ8mPVQlqNcOB2sJdwATtZKl2pDKKHfpf/rYj24lkinxf69blJbnsvtqqNU+L3SL50vzZhXOnw==", + "requires": { + "isarray": "2.0.1" + } + }, + "has-cors": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-cors/-/has-cors-1.1.0.tgz", + "integrity": "sha1-XkdHk/fqmEPRu5nCPu9J/xJv/zk=" + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" + }, + "has-symbols": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", + "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==" + }, + "htmlparser2": { + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.10.1.tgz", + "integrity": "sha512-IgieNijUMbkDovyoKObU1DUhm1iwNYE/fuifEoEHfd1oZKZDaONBSkal7Y01shxsM49R4XaMdGez3WnF9UfiCQ==", + "requires": { + "domelementtype": "^1.3.1", + "domhandler": "^2.3.0", + "domutils": "^1.5.1", + "entities": "^1.1.1", + "inherits": "^2.0.1", + "readable-stream": "^3.1.1" + } + }, + "http-signature": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", + "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", + "requires": { + "assert-plus": "^1.0.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" + } + }, + "import-lazy": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/import-lazy/-/import-lazy-2.1.0.tgz", + "integrity": "sha1-BWmOPUXIjo1+nZLLBYTnfwlvPkM=" + }, + "imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=" + }, + "indexof": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz", + "integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=" + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "ini": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==" + }, + "is-arguments": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.0.4.tgz", + "integrity": "sha512-xPh0Rmt8NE65sNzvyUmWgI1tz3mKq74lGA0mL8LYZcoIzKOzDh6HmrYm3d18k60nHerC8A9Km8kYu87zfSFnLA==" + }, + "is-callable": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.1.tgz", + "integrity": "sha512-wliAfSzx6V+6WfMOmus1xy0XvSgf/dlStkvTfq7F0g4bOIW0PSUbnyse3NhDwdyYS1ozfUtAAySqTws3z9Eqgg==" + }, + "is-ci": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-ci/-/is-ci-1.2.1.tgz", + "integrity": "sha512-s6tfsaQaQi3JNciBH6shVqEDvhGut0SUXr31ag8Pd8BBbVVlcGfWhpPmEOoM6RJ5TFhbypvf5yyRw/VXW1IiWg==", + "requires": { + "ci-info": "^1.5.0" + } + }, + "is-date-object": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.2.tgz", + "integrity": "sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g==" + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=" + }, + "is-installed-globally": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-installed-globally/-/is-installed-globally-0.1.0.tgz", + "integrity": "sha1-Df2Y9akRFxbdU13aZJL2e/PSWoA=", + "requires": { + "global-dirs": "^0.1.0", + "is-path-inside": "^1.0.0" + } + }, + "is-npm": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-npm/-/is-npm-1.0.0.tgz", + "integrity": "sha1-8vtjpl5JBbQGyGBydloaTceTufQ=" + }, + "is-obj": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", + "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=" + }, + "is-path-inside": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.1.tgz", + "integrity": "sha1-jvW33lBDej/cprToZe96pVy0gDY=", + "requires": { + "path-is-inside": "^1.0.1" + } + }, + "is-redirect": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-redirect/-/is-redirect-1.0.0.tgz", + "integrity": "sha1-HQPd7VO9jbDzDCbk+V02/HyH3CQ=" + }, + "is-regex": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.1.tgz", + "integrity": "sha512-1+QkEcxiLlB7VEyFtyBg94e08OAsvq7FUBgApTq/w2ymCLyKJgDPsybBENVtA7XCQEgEXxKPonG+mvYRxh/LIg==", + "requires": { + "has-symbols": "^1.0.1" + } + }, + "is-retry-allowed": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/is-retry-allowed/-/is-retry-allowed-1.2.0.tgz", + "integrity": "sha512-RUbUeKwvm3XG2VYamhJL1xFktgjvPzL0Hq8C+6yrWIswDy3BIXGqCxhxkc30N9jqK311gVU137K8Ei55/zVJRg==" + }, + "is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" + }, + "is-symbol": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz", + "integrity": "sha512-OwijhaRSgqvhm/0ZdAcXNZt9lYdKFpcRDT5ULUuYXPoT794UNOdU+gpT6Rzo7b4V2HUl/op6GqY894AZwv9faQ==", + "requires": { + "has-symbols": "^1.0.1" + } + }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" + }, + "is-wsl": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-1.1.0.tgz", + "integrity": "sha1-HxbkqiKwTRM2tmGIpmrzxgDDpm0=" + }, + "isarray": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.1.tgz", + "integrity": "sha1-o32U7ZzaLVmGXJ92/llu4fM4dB4=" + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" + }, + "isnumber": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isnumber/-/isnumber-1.0.0.tgz", + "integrity": "sha1-Dj+XWbWB2Z3YUIbw7Cp0kJz63QE=" + }, + "isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" + }, + "js-yaml": { + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.0.tgz", + "integrity": "sha512-/4IbIeHcD9VMHFqDR/gQ7EdZdLimOvW2DdcxFjdyyZ9NsbS+ccrXqVWDtab/lRl5AlUqmpBx8EhPaWR+OtY17A==", + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=" + }, + "jsck": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/jsck/-/jsck-0.3.2.tgz", + "integrity": "sha1-jgazG7V7AJDlA91O5q0PJp3/GlU=" + }, + "json-schema": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", + "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" + }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" + }, + "json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" + }, + "jsonpath": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/jsonpath/-/jsonpath-1.0.2.tgz", + "integrity": "sha512-rmzlgFZiQPc6q4HDyK8s9Qb4oxBnI5sF61y/Co5PV0lc3q2bIuRsNdueVbhoSHdKM4fxeimphOAtfz47yjCfeA==", + "requires": { + "esprima": "1.2.2", + "static-eval": "2.0.2", + "underscore": "1.7.0" + }, + "dependencies": { + "esprima": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-1.2.2.tgz", + "integrity": "sha1-dqD9Zvz+FU/SkmZ9wmQBl1CxZXs=" + } + } + }, + "jsprim": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", + "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.3.0", + "json-schema": "0.2.3", + "verror": "1.10.0" + } + }, + "latest-version": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/latest-version/-/latest-version-3.1.0.tgz", + "integrity": "sha1-ogU4P+oyKzO1rjsYq+4NwvNW7hU=", + "requires": { + "package-json": "^4.0.0" + } + }, + "levn": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "requires": { + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2" + } + }, + "lodash": { + "version": "4.17.20", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", + "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==" + }, + "lodash.isplainobject": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", + "integrity": "sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs=" + }, + "log-symbols": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz", + "integrity": "sha512-VeIAFslyIerEJLXHziedo2basKbMKtTw3vfn5IzG0XTjhAVEJyNHnL2p7vc+wBDSdQuUpNw3M2u6xb9QsAY5Eg==", + "requires": { + "chalk": "^2.0.1" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "requires": { + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "lowercase-keys": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.1.tgz", + "integrity": "sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA==" + }, + "lru-cache": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", + "integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==", + "requires": { + "pseudomap": "^1.0.2", + "yallist": "^2.1.2" + } + }, + "lynx": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/lynx/-/lynx-0.2.0.tgz", + "integrity": "sha1-eeZnRTDaQYPoeVO9aGFx4HDaULk=", + "requires": { + "mersenne": "~0.0.3", + "statsd-parser": "~0.0.4" + } + }, + "make-dir": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.3.0.tgz", + "integrity": "sha512-2w31R7SJtieJJnQtGc7RVL2StM2vGYVfqUOvUDxH6bC6aJTxPxTF0GnIgCyu7tjockiUWAYQRbxa7vKn34s5sQ==", + "requires": { + "pify": "^3.0.0" + } + }, + "mersenne": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/mersenne/-/mersenne-0.0.4.tgz", + "integrity": "sha1-QB/ex+whzbngPNPTAhOY2iGycIU=" + }, + "mime-db": { + "version": "1.44.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz", + "integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg==" + }, + "mime-types": { + "version": "2.1.27", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz", + "integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==", + "requires": { + "mime-db": "1.44.0" + } + }, + "mimic-fn": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", + "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==" + }, + "minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" + }, + "moment": { + "version": "2.27.0", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.27.0.tgz", + "integrity": "sha512-al0MUK7cpIcglMv3YF13qSgdAIqxHTO7brRtaz3DlSULbqfazqkc5kEjNrLDOM7fsjshoFIihnU8snrP7zUvhQ==" + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "nanotimer": { + "version": "0.3.15", + "resolved": "https://registry.npmjs.org/nanotimer/-/nanotimer-0.3.15.tgz", + "integrity": "sha1-KA0nfbkUbspvilcLVyq68qmsx1Q=" + }, + "npm-run-path": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", + "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", + "requires": { + "path-key": "^2.0.0" + } + }, + "nth-check": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-1.0.2.tgz", + "integrity": "sha512-WeBOdju8SnzPN5vTUJYxYUxLeXpCaVP5i5e0LF8fg7WORF2Wd7wFX/pk0tYZk7s8T+J7VLy0Da6J1+wCT0AtHg==", + "requires": { + "boolbase": "~1.0.0" + } + }, + "oauth-sign": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", + "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" + }, + "object-component": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/object-component/-/object-component-0.0.3.tgz", + "integrity": "sha1-8MaapQ78lbhmwYb0AKM3acsvEpE=" + }, + "object-inspect": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.8.0.tgz", + "integrity": "sha512-jLdtEOB112fORuypAyl/50VRVIBIdVQOSUUGQHzJ4xBSbit81zRarz7GThkEFZy1RceYrWYcPcBFPQwHyAc1gA==" + }, + "object-is": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.2.tgz", + "integrity": "sha512-5lHCz+0uufF6wZ7CRFWJN3hp8Jqblpgve06U5CMQ3f//6iDjPr2PEo9MWCjEssDsa+UZEL4PkFpr+BMop6aKzQ==", + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.5" + } + }, + "object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==" + }, + "object.assign": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", + "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==", + "requires": { + "define-properties": "^1.1.2", + "function-bind": "^1.1.1", + "has-symbols": "^1.0.0", + "object-keys": "^1.0.11" + } + }, + "onetime": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", + "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", + "requires": { + "mimic-fn": "^1.0.0" + } + }, + "opn": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/opn/-/opn-5.5.0.tgz", + "integrity": "sha512-PqHpggC9bLV0VeWcdKhkpxY+3JTzetLSqTCWL/z/tFIbI6G8JCjondXklT1JinczLz2Xib62sSp0T/gKT4KksA==", + "requires": { + "is-wsl": "^1.1.0" + } + }, + "optionator": { + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", + "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", + "requires": { + "deep-is": "~0.1.3", + "fast-levenshtein": "~2.0.6", + "levn": "~0.3.0", + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2", + "word-wrap": "~1.2.3" + } + }, + "ora": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/ora/-/ora-1.4.0.tgz", + "integrity": "sha512-iMK1DOQxzzh2MBlVsU42G80mnrvUhqsMh74phHtDlrcTZPK0pH6o7l7DRshK+0YsxDyEuaOkziVdvM3T0QTzpw==", + "requires": { + "chalk": "^2.1.0", + "cli-cursor": "^2.1.0", + "cli-spinners": "^1.0.1", + "log-symbols": "^2.1.0" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "requires": { + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "os-tmpdir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=" + }, + "p-finally": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", + "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=" + }, + "package-json": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/package-json/-/package-json-4.0.1.tgz", + "integrity": "sha1-iGmgQBJTZhxMTKPabCEh7VVfXu0=", + "requires": { + "got": "^6.7.1", + "registry-auth-token": "^3.0.1", + "registry-url": "^3.0.3", + "semver": "^5.1.0" + } + }, + "parse5": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-3.0.3.tgz", + "integrity": "sha512-rgO9Zg5LLLkfJF9E6CCmXlSE4UVceloys8JrFqCcHloC3usd/kJCyPDwH2SOlzix2j3xaP9sUX3e8+kvkuleAA==", + "requires": { + "@types/node": "*" + } + }, + "parseqs": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.5.tgz", + "integrity": "sha1-1SCKNzjkZ2bikbouoXNoSSGouJ0=", + "requires": { + "better-assert": "~1.0.0" + } + }, + "parseuri": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/parseuri/-/parseuri-0.0.5.tgz", + "integrity": "sha1-gCBKUNTbt3m/3G6+J3jZDkvOMgo=", + "requires": { + "better-assert": "~1.0.0" + } + }, + "path-is-inside": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", + "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=" + }, + "path-key": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", + "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=" + }, + "performance-now": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", + "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" + }, + "pidusage": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/pidusage/-/pidusage-1.2.0.tgz", + "integrity": "sha512-OGo+iSOk44HRJ8q15AyG570UYxcm5u+R99DI8Khu8P3tKGkVu5EZX4ywHglWSTMNNXQ274oeGpYrvFEhDIFGPg==" + }, + "pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=" + }, + "prelude-ls": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=" + }, + "prepend-http": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-1.0.4.tgz", + "integrity": "sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw=" + }, + "present": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/present/-/present-0.0.3.tgz", + "integrity": "sha1-Wu+4pd32s0xldDvxzeU1I6rBwFo=" + }, + "pseudomap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", + "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=" + }, + "psl": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz", + "integrity": "sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ==" + }, + "punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" + }, + "qs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" + }, + "rc": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", + "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", + "requires": { + "deep-extend": "^0.6.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" + } + }, + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + }, + "regexp.prototype.flags": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.3.0.tgz", + "integrity": "sha512-2+Q0C5g951OlYlJz6yu5/M33IcsESLlLfsyIaLJaG4FA2r4yP8MvVMJUUP/fVBkSpbbbZlS5gynbEWLipiiXiQ==", + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.0-next.1" + } + }, + "registry-auth-token": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-3.4.0.tgz", + "integrity": "sha512-4LM6Fw8eBQdwMYcES4yTnn2TqIasbXuwDx3um+QRs7S55aMKCBKBxvPXl2RiUjHwuJLTyYfxSpmfSAjQpcuP+A==", + "requires": { + "rc": "^1.1.6", + "safe-buffer": "^5.0.1" + } + }, + "registry-url": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/registry-url/-/registry-url-3.1.0.tgz", + "integrity": "sha1-PU74cPc93h138M+aOBQyRE4XSUI=", + "requires": { + "rc": "^1.0.1" + } + }, + "request": { + "version": "2.88.2", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", + "integrity": "sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==", + "requires": { + "aws-sign2": "~0.7.0", + "aws4": "^1.8.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.6", + "extend": "~3.0.2", + "forever-agent": "~0.6.1", + "form-data": "~2.3.2", + "har-validator": "~5.1.3", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.19", + "oauth-sign": "~0.9.0", + "performance-now": "^2.1.0", + "qs": "~6.5.2", + "safe-buffer": "^5.1.2", + "tough-cookie": "~2.5.0", + "tunnel-agent": "^0.6.0", + "uuid": "^3.3.2" + }, + "dependencies": { + "uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==" + } + } + }, + "restore-cursor": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", + "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", + "requires": { + "onetime": "^2.0.0", + "signal-exit": "^3.0.2" + } + }, + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" + }, + "semver-diff": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/semver-diff/-/semver-diff-2.1.0.tgz", + "integrity": "sha1-S7uEN8jTfksM8aaP1ybsbWRdbTY=", + "requires": { + "semver": "^5.0.3" + } + }, + "shebang-command": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "requires": { + "shebang-regex": "^1.0.0" + } + }, + "shebang-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=" + }, + "signal-exit": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz", + "integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==" + }, + "socket.io-client": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-2.3.0.tgz", + "integrity": "sha512-cEQQf24gET3rfhxZ2jJ5xzAOo/xhZwK+mOqtGRg5IowZsMgwvHwnf/mCRapAAkadhM26y+iydgwsXGObBB5ZdA==", + "requires": { + "backo2": "1.0.2", + "base64-arraybuffer": "0.1.5", + "component-bind": "1.0.0", + "component-emitter": "1.2.1", + "debug": "~4.1.0", + "engine.io-client": "~3.4.0", + "has-binary2": "~1.0.2", + "has-cors": "1.1.0", + "indexof": "0.0.1", + "object-component": "0.0.3", + "parseqs": "0.0.5", + "parseuri": "0.0.5", + "socket.io-parser": "~3.3.0", + "to-array": "0.1.4" + }, + "dependencies": { + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "requires": { + "ms": "^2.1.1" + } + } + } + }, + "socket.io-parser": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-3.3.0.tgz", + "integrity": "sha512-hczmV6bDgdaEbVqhAeVMM/jfUfzuEZHsQg6eOmLgJht6G3mPKMxYm75w2+qhAQZ+4X+1+ATZ+QFKeOZD5riHng==", + "requires": { + "component-emitter": "1.2.1", + "debug": "~3.1.0", + "isarray": "2.0.1" + }, + "dependencies": { + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + } + } + }, + "socketio-wildcard": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/socketio-wildcard/-/socketio-wildcard-2.0.0.tgz", + "integrity": "sha1-JGboMidrGRY1Y77ncjiHR/kSR1s=" + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "optional": true + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" + }, + "sshpk": { + "version": "1.16.1", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", + "integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==", + "requires": { + "asn1": "~0.2.3", + "assert-plus": "^1.0.0", + "bcrypt-pbkdf": "^1.0.0", + "dashdash": "^1.12.0", + "ecc-jsbn": "~0.1.1", + "getpass": "^0.1.1", + "jsbn": "~0.1.0", + "safer-buffer": "^2.0.2", + "tweetnacl": "~0.14.0" + } + }, + "static-eval": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/static-eval/-/static-eval-2.0.2.tgz", + "integrity": "sha512-N/D219Hcr2bPjLxPiV+TQE++Tsmrady7TqAJugLy7Xk1EumfDWS/f5dtBbkRCGE7wKKXuYockQoj8Rm2/pVKyg==", + "requires": { + "escodegen": "^1.8.1" + } + }, + "stats-lite": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/stats-lite/-/stats-lite-2.2.0.tgz", + "integrity": "sha512-/Kz55rgUIv2KP2MKphwYT/NCuSfAlbbMRv2ZWw7wyXayu230zdtzhxxuXXcvsc6EmmhS8bSJl3uS1wmMHFumbA==", + "requires": { + "isnumber": "~1.0.0" + } + }, + "statsd-parser": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/statsd-parser/-/statsd-parser-0.0.4.tgz", + "integrity": "sha1-y9JDlTzELv/VSLXSI4jtaJ7GOb0=" + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=" + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "requires": { + "ansi-regex": "^3.0.0" + } + } + } + }, + "string.prototype.trimend": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.1.tgz", + "integrity": "sha512-LRPxFUaTtpqYsTeNKaFOw3R4bxIzWOnbQ837QfBylo8jIxtcbK/A/sMV7Q+OAV/vWo+7s25pOE10KYSjaSO06g==", + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.5" + } + }, + "string.prototype.trimstart": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.1.tgz", + "integrity": "sha512-XxZn+QpvrBI1FOcg6dIpxUPgWCPuNXvMD72aaRaUQv1eD4e/Qy8i/hFTe0BUmD60p/QA6bh1avmuPTfNjqVWRw==", + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.5" + } + }, + "string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "requires": { + "safe-buffer": "~5.2.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "strip-eof": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", + "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=" + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=" + }, + "term-size": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/term-size/-/term-size-1.2.0.tgz", + "integrity": "sha1-RYuDiH8oj8Vtb/+/rSYuJmOO+mk=", + "requires": { + "execa": "^0.7.0" + } + }, + "timed-out": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/timed-out/-/timed-out-4.0.1.tgz", + "integrity": "sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8=" + }, + "tmp": { + "version": "0.0.28", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.28.tgz", + "integrity": "sha1-Fyc1t/YU6nrzlmT6hM8N5OUV0SA=", + "requires": { + "os-tmpdir": "~1.0.1" + } + }, + "to-array": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/to-array/-/to-array-0.1.4.tgz", + "integrity": "sha1-F+bBH3PdTz10zaek/zI46a2b+JA=" + }, + "tough-cookie": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", + "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", + "requires": { + "psl": "^1.1.28", + "punycode": "^2.1.1" + } + }, + "try-require": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/try-require/-/try-require-1.2.1.tgz", + "integrity": "sha1-NEiaLKwMCcHMEO2RugEVlNQzO+I=" + }, + "tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "requires": { + "safe-buffer": "^5.0.1" + } + }, + "tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=" + }, + "type-check": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "requires": { + "prelude-ls": "~1.1.2" + } + }, + "underscore": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.7.0.tgz", + "integrity": "sha1-a7rwh3UA02vjTsqlhODbn+8DUgk=" + }, + "unique-string": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unique-string/-/unique-string-1.0.0.tgz", + "integrity": "sha1-nhBXzKhRq7kzmPizOuGHuZyuwRo=", + "requires": { + "crypto-random-string": "^1.0.0" + } + }, + "unzip-response": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/unzip-response/-/unzip-response-2.0.1.tgz", + "integrity": "sha1-0vD3N9FrBhXnKmk17QQhRXLVb5c=" + }, + "update-notifier": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/update-notifier/-/update-notifier-2.5.0.tgz", + "integrity": "sha512-gwMdhgJHGuj/+wHJJs9e6PcCszpxR1b236igrOkUofGhqJuG+amlIKwApH1IW1WWl7ovZxsX49lMBWLxSdm5Dw==", + "requires": { + "boxen": "^1.2.1", + "chalk": "^2.0.1", + "configstore": "^3.0.0", + "import-lazy": "^2.1.0", + "is-ci": "^1.0.10", + "is-installed-globally": "^0.1.0", + "is-npm": "^1.0.0", + "latest-version": "^3.0.0", + "semver-diff": "^2.0.0", + "xdg-basedir": "^3.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "requires": { + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "uri-js": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.0.tgz", + "integrity": "sha512-B0yRTzYdUCCn9n+F4+Gh4yIDtMQcaJsmYBDsTSG8g/OejKBodLQ2IHfN3bM7jUsRXndopT7OIXWdYqc1fjmV6g==", + "requires": { + "punycode": "^2.1.0" + } + }, + "url-parse-lax": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-1.0.0.tgz", + "integrity": "sha1-evjzA2Rem9eaJy56FKxovAYJ2nM=", + "requires": { + "prepend-http": "^1.0.1" + } + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + }, + "uuid": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.3.tgz", + "integrity": "sha1-Z+LoY3lyFVMN/zGOW/nc6/1Hsho=" + }, + "verror": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", + "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", + "requires": { + "assert-plus": "^1.0.0", + "core-util-is": "1.0.2", + "extsprintf": "^1.2.0" + } + }, + "which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "requires": { + "isexe": "^2.0.0" + } + }, + "widest-line": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/widest-line/-/widest-line-2.0.1.tgz", + "integrity": "sha512-Ba5m9/Fa4Xt9eb2ELXt77JxVDV8w7qQrH0zS/TWSJdLyAwQjWoOzpzj5lwVftDz6n/EOu3tNACS84v509qwnJA==", + "requires": { + "string-width": "^2.1.1" + } + }, + "word-wrap": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", + "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==" + }, + "write-file-atomic": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-2.4.3.tgz", + "integrity": "sha512-GaETH5wwsX+GcnzhPgKcKjJ6M2Cq3/iZp1WyY/X1CSqrW+jVNM9Y7D8EC2sM4ZG/V8wZlSniJnCKWPmBYAucRQ==", + "requires": { + "graceful-fs": "^4.1.11", + "imurmurhash": "^0.1.4", + "signal-exit": "^3.0.2" + } + }, + "ws": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/ws/-/ws-5.2.2.tgz", + "integrity": "sha512-jaHFD6PFv6UgoIVda6qZllptQsMlDEJkTQcybzzXDYM1XO9Y8em691FGMPmM46WGyLU4z9KMgQN+qrux/nhlHA==", + "requires": { + "async-limiter": "~1.0.0" + } + }, + "xdg-basedir": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-3.0.0.tgz", + "integrity": "sha1-SWsswQnsqNus/i3HK2A8F8WHCtQ=" + }, + "xmlhttprequest-ssl": { + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.5.tgz", + "integrity": "sha1-wodrBhaKrcQOV9l+gRkayPQ5iz4=" + }, + "yallist": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", + "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=" + }, + "yeast": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/yeast/-/yeast-0.1.2.tgz", + "integrity": "sha1-AI4G2AlDIMNy28L47XagymyKxBk=" + } + } +} diff --git a/docker-compose.yaml b/docker-compose.yaml index beddf025..ce16a31b 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -33,6 +33,7 @@ services: command: yarn run start volumes: - ./front:/usr/src/app + - ./messages:/usr/src/messages/ labels: - "traefik.http.routers.front.rule=Host(`play.workadventure.localhost`)" - "traefik.http.routers.front.entryPoints=web,traefik" @@ -75,6 +76,7 @@ services: ALLOW_ARTILLERY: "true" volumes: - ./back:/usr/src/app + - ./messages:/usr/src/messages/ labels: - "traefik.http.routers.back.rule=Host(`api.workadventure.localhost`)" - "traefik.http.routers.back.entryPoints=web" diff --git a/front/src/Connection.ts b/front/src/Connection.ts index 5062ca7f..7a60cfba 100644 --- a/front/src/Connection.ts +++ b/front/src/Connection.ts @@ -1,7 +1,7 @@ import Axios from "axios"; import {API_URL} from "./Enum/EnvironmentVariable"; import {MessageUI} from "./Logger/MessageUI"; -import {SetPlayerDetailsMessage} from "./Messages/SetPlayerDetailsMessage"; +import {SetPlayerDetailsMessage} from "../../messages/generated/src/proto/messages_pb" const SocketIo = require('socket.io-client'); import Socket = SocketIOClient.Socket; @@ -170,10 +170,10 @@ export class Connection implements Connection { reject(error); }); - connection.socket.emit(EventMessage.SET_PLAYER_DETAILS, { - name: name, - characterLayers: characterLayersSelected - } as SetPlayerDetailsMessage, (id: string) => { + const message = new SetPlayerDetailsMessage(); + message.setName(name); + message.setCharacterlayersList(characterLayersSelected); + connection.socket.emit(EventMessage.SET_PLAYER_DETAILS, message.serializeBinary().buffer, (id: string) => { connection.userId = id; }); diff --git a/front/src/Messages/SetPlayerDetailsMessage.ts b/front/src/Messages/SetPlayerDetailsMessage.ts deleted file mode 100644 index 789833ff..00000000 --- a/front/src/Messages/SetPlayerDetailsMessage.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface SetPlayerDetailsMessage { - name: string, - characterLayers: string[] -} diff --git a/messages/.gitignore b/messages/.gitignore new file mode 100644 index 00000000..2ccbe465 --- /dev/null +++ b/messages/.gitignore @@ -0,0 +1 @@ +/node_modules/ diff --git a/messages/generated/.gitignore b/messages/generated/.gitignore new file mode 100644 index 00000000..8eba6c8d --- /dev/null +++ b/messages/generated/.gitignore @@ -0,0 +1 @@ +src/ diff --git a/messages/generated/src/proto/messages_pb.d.ts b/messages/generated/src/proto/messages_pb.d.ts new file mode 100644 index 00000000..4c700d90 --- /dev/null +++ b/messages/generated/src/proto/messages_pb.d.ts @@ -0,0 +1,31 @@ +// package: +// file: src/proto/messages.proto + +import * as jspb from "google-protobuf"; + +export class SetPlayerDetailsMessage extends jspb.Message { + getName(): string; + setName(value: string): void; + + clearCharacterlayersList(): void; + getCharacterlayersList(): Array; + setCharacterlayersList(value: Array): void; + addCharacterlayers(value: string, index?: number): string; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): SetPlayerDetailsMessage.AsObject; + static toObject(includeInstance: boolean, msg: SetPlayerDetailsMessage): SetPlayerDetailsMessage.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: SetPlayerDetailsMessage, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): SetPlayerDetailsMessage; + static deserializeBinaryFromReader(message: SetPlayerDetailsMessage, reader: jspb.BinaryReader): SetPlayerDetailsMessage; +} + +export namespace SetPlayerDetailsMessage { + export type AsObject = { + name: string, + characterlayersList: Array, + } +} + diff --git a/messages/generated/src/proto/messages_pb.js b/messages/generated/src/proto/messages_pb.js new file mode 100644 index 00000000..27ffc622 --- /dev/null +++ b/messages/generated/src/proto/messages_pb.js @@ -0,0 +1,223 @@ +// source: src/proto/messages.proto +/** + * @fileoverview + * @enhanceable + * @suppress {messageConventions} JS Compiler reports an error if a variable or + * field starts with 'MSG_' and isn't a translatable message. + * @public + */ +// GENERATED CODE -- DO NOT EDIT! + +var jspb = require('google-protobuf'); +var goog = jspb; +var global = Function('return this')(); + +goog.exportSymbol('proto.SetPlayerDetailsMessage', null, global); +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.SetPlayerDetailsMessage = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.SetPlayerDetailsMessage.repeatedFields_, null); +}; +goog.inherits(proto.SetPlayerDetailsMessage, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.SetPlayerDetailsMessage.displayName = 'proto.SetPlayerDetailsMessage'; +} + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.SetPlayerDetailsMessage.repeatedFields_ = [2]; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.SetPlayerDetailsMessage.prototype.toObject = function(opt_includeInstance) { + return proto.SetPlayerDetailsMessage.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.SetPlayerDetailsMessage} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.SetPlayerDetailsMessage.toObject = function(includeInstance, msg) { + var f, obj = { + name: jspb.Message.getFieldWithDefault(msg, 1, ""), + characterlayersList: (f = jspb.Message.getRepeatedField(msg, 2)) == null ? undefined : f + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.SetPlayerDetailsMessage} + */ +proto.SetPlayerDetailsMessage.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.SetPlayerDetailsMessage; + return proto.SetPlayerDetailsMessage.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.SetPlayerDetailsMessage} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.SetPlayerDetailsMessage} + */ +proto.SetPlayerDetailsMessage.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setName(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.addCharacterlayers(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.SetPlayerDetailsMessage.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.SetPlayerDetailsMessage.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.SetPlayerDetailsMessage} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.SetPlayerDetailsMessage.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getName(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getCharacterlayersList(); + if (f.length > 0) { + writer.writeRepeatedString( + 2, + f + ); + } +}; + + +/** + * optional string name = 1; + * @return {string} + */ +proto.SetPlayerDetailsMessage.prototype.getName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.SetPlayerDetailsMessage} returns this + */ +proto.SetPlayerDetailsMessage.prototype.setName = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * repeated string characterLayers = 2; + * @return {!Array} + */ +proto.SetPlayerDetailsMessage.prototype.getCharacterlayersList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 2)); +}; + + +/** + * @param {!Array} value + * @return {!proto.SetPlayerDetailsMessage} returns this + */ +proto.SetPlayerDetailsMessage.prototype.setCharacterlayersList = function(value) { + return jspb.Message.setField(this, 2, value || []); +}; + + +/** + * @param {string} value + * @param {number=} opt_index + * @return {!proto.SetPlayerDetailsMessage} returns this + */ +proto.SetPlayerDetailsMessage.prototype.addCharacterlayers = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 2, value, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.SetPlayerDetailsMessage} returns this + */ +proto.SetPlayerDetailsMessage.prototype.clearCharacterlayersList = function() { + return this.setCharacterlayersList([]); +}; + + +goog.object.extend(exports, proto); diff --git a/back/src/proto/messages.proto b/messages/messages.proto similarity index 100% rename from back/src/proto/messages.proto rename to messages/messages.proto diff --git a/messages/package.json b/messages/package.json new file mode 100644 index 00000000..e2548499 --- /dev/null +++ b/messages/package.json @@ -0,0 +1,43 @@ +{ + "name": "workadventure-messages", + "version": "1.0.0", + "description": "", + "main": "generated/src/proto/messages_pb.js", + "scripts": { + "proto": "protoc --plugin=\"protoc-gen-ts=./node_modules/.bin/protoc-gen-ts\" --js_out=\"import_style=commonjs,binary:src/messages/generated\" --ts_out=\"src/messages/generated\" src/messages/messages.proto", + "proto:watch": "inotifywait -q -m -e close_write src/messages/messages.proto | while read -r filename event; do yarn run proto; done" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/thecodingmachine/workadventure.git" + }, + "contributors": [ + { + "name": "Grégoire Parant", + "email": "g.parant@thecodingmachine.com" + }, + { + "name": "David Négrier", + "email": "d.negrier@thecodingmachine.com" + }, + { + "name": "Arthmaël Poly", + "email": "a.poly@thecodingmachine.com" + } + ], + "license": "SEE LICENSE IN LICENSE.txt", + "bugs": { + "url": "https://github.com/thecodingmachine/workadventure/issues" + }, + "homepage": "https://github.com/thecodingmachine/workadventure#readme", + "dependencies": { + "google-protobuf": "^3.13.0", + "typescript": "^3.8.3" + }, + "devDependencies": { + "ts-node-dev": "^1.0.0-pre.44", + "@types/google-protobuf": "^3.7.3", + "concurrently": "^5.3.0", + "ts-protoc-gen": "^0.13.0" + } +} diff --git a/messages/yarn.lock b/messages/yarn.lock new file mode 100644 index 00000000..9e883f1d --- /dev/null +++ b/messages/yarn.lock @@ -0,0 +1,889 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@types/google-protobuf@^3.7.3": + version "3.7.3" + resolved "https://registry.yarnpkg.com/@types/google-protobuf/-/google-protobuf-3.7.3.tgz#429512e541bbd777f2c867692e6335ee08d1f6d4" + integrity sha512-FRwj40euE2bYkG+0X5w2nEA8yAzgJRcEa7RBd0Gsdkb9/tPM2pctVVAvnOUTbcXo2VmIHPo0Ae94Gl9vRHfKzg== + +"@types/strip-bom@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@types/strip-bom/-/strip-bom-3.0.0.tgz#14a8ec3956c2e81edb7520790aecf21c290aebd2" + integrity sha1-FKjsOVbC6B7bdSB5CuzyHCkK69I= + +"@types/strip-json-comments@0.0.30": + version "0.0.30" + resolved "https://registry.yarnpkg.com/@types/strip-json-comments/-/strip-json-comments-0.0.30.tgz#9aa30c04db212a9a0649d6ae6fd50accc40748a1" + integrity sha512-7NQmHra/JILCd1QqpSzl8+mJRc8ZHz3uDm8YV1Ks9IhK0epEiTw8aIErbvH9PI+6XbqhyIQy3462nEsn7UVzjQ== + +ansi-regex@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.0.tgz#8b9f8f08cf1acb843756a839ca8c7e3168c51997" + integrity sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg== + +ansi-styles@^3.2.0, ansi-styles@^3.2.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" + integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== + dependencies: + color-convert "^1.9.0" + +anymatch@~3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.1.tgz#c55ecf02185e2469259399310c173ce31233b142" + integrity sha512-mM8522psRCqzV+6LhomX5wgp25YVibjh8Wj23I5RPkPppSVSjyKD2A2mBJmWGa+KN7f2D6LNh9jkBCeyLktzjg== + dependencies: + normalize-path "^3.0.0" + picomatch "^2.0.4" + +arg@^4.1.0: + version "4.1.3" + resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" + integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA== + +array-find-index@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/array-find-index/-/array-find-index-1.0.2.tgz#df010aa1287e164bbda6f9723b0a96a1ec4187a1" + integrity sha1-3wEKoSh+Fku9pvlyOwqWoexBh6E= + +balanced-match@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" + integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c= + +binary-extensions@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.1.0.tgz#30fa40c9e7fe07dbc895678cd287024dea241dd9" + integrity sha512-1Yj8h9Q+QDF5FzhMs/c9+6UntbD5MkRfRwac8DoEm9ZfUBZ7tZ55YcGVAzEe4bXsdQHEk+s9S5wsOKVdZrw0tQ== + +brace-expansion@^1.1.7: + version "1.1.11" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" + integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== + dependencies: + balanced-match "^1.0.0" + concat-map "0.0.1" + +braces@~3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" + integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== + dependencies: + fill-range "^7.0.1" + +buffer-from@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" + integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A== + +camelcase-keys@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-2.1.0.tgz#308beeaffdf28119051efa1d932213c91b8f92e7" + integrity sha1-MIvur/3ygRkFHvodkyITyRuPkuc= + dependencies: + camelcase "^2.0.0" + map-obj "^1.0.0" + +camelcase@^2.0.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-2.1.1.tgz#7c1d16d679a1bbe59ca02cacecfb011e201f5a1f" + integrity sha1-fB0W1nmhu+WcoCys7PsBHiAfWh8= + +camelcase@^5.0.0: + version "5.3.1" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" + integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== + +chalk@^2.4.2: + version "2.4.2" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" + integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== + dependencies: + ansi-styles "^3.2.1" + escape-string-regexp "^1.0.5" + supports-color "^5.3.0" + +chokidar@^3.4.0: + version "3.4.2" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.4.2.tgz#38dc8e658dec3809741eb3ef7bb0a47fe424232d" + integrity sha512-IZHaDeBeI+sZJRX7lGcXsdzgvZqKv6sECqsbErJA4mHWfpRrD8B97kSFN4cQz6nGBGiuFia1MKR4d6c1o8Cv7A== + dependencies: + anymatch "~3.1.1" + braces "~3.0.2" + glob-parent "~5.1.0" + is-binary-path "~2.1.0" + is-glob "~4.0.1" + normalize-path "~3.0.0" + readdirp "~3.4.0" + optionalDependencies: + fsevents "~2.1.2" + +cliui@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-5.0.0.tgz#deefcfdb2e800784aa34f46fa08e06851c7bbbc5" + integrity sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA== + dependencies: + string-width "^3.1.0" + strip-ansi "^5.2.0" + wrap-ansi "^5.1.0" + +color-convert@^1.9.0: + version "1.9.3" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" + integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== + dependencies: + color-name "1.1.3" + +color-name@1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" + integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= + +concat-map@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= + +concurrently@^5.3.0: + version "5.3.0" + resolved "https://registry.yarnpkg.com/concurrently/-/concurrently-5.3.0.tgz#7500de6410d043c912b2da27de3202cb489b1e7b" + integrity sha512-8MhqOB6PWlBfA2vJ8a0bSFKATOdWlHiQlk11IfmQBPaHVP8oP2gsh2MObE6UR3hqDHqvaIvLTyceNW6obVuFHQ== + dependencies: + chalk "^2.4.2" + date-fns "^2.0.1" + lodash "^4.17.15" + read-pkg "^4.0.1" + rxjs "^6.5.2" + spawn-command "^0.0.2-1" + supports-color "^6.1.0" + tree-kill "^1.2.2" + yargs "^13.3.0" + +currently-unhandled@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/currently-unhandled/-/currently-unhandled-0.4.1.tgz#988df33feab191ef799a61369dd76c17adf957ea" + integrity sha1-mI3zP+qxke95mmE2nddsF635V+o= + dependencies: + array-find-index "^1.0.1" + +date-fns@^2.0.1: + version "2.16.1" + resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.16.1.tgz#05775792c3f3331da812af253e1a935851d3834b" + integrity sha512-sAJVKx/FqrLYHAQeN7VpJrPhagZc9R4ImZIWYRFZaaohR3KzmuK88touwsSwSVT8Qcbd4zoDsnGfX4GFB4imyQ== + +dateformat@~1.0.4-1.2.3: + version "1.0.12" + resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-1.0.12.tgz#9f124b67594c937ff706932e4a642cca8dbbfee9" + integrity sha1-nxJLZ1lMk3/3BpMuSmQsyo27/uk= + dependencies: + get-stdin "^4.0.1" + meow "^3.3.0" + +decamelize@^1.1.2, decamelize@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" + integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA= + +diff@^4.0.1: + version "4.0.2" + resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" + integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== + +dynamic-dedupe@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/dynamic-dedupe/-/dynamic-dedupe-0.3.0.tgz#06e44c223f5e4e94d78ef9db23a6515ce2f962a1" + integrity sha1-BuRMIj9eTpTXjvnbI6ZRXOL5YqE= + dependencies: + xtend "^4.0.0" + +emoji-regex@^7.0.1: + version "7.0.3" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-7.0.3.tgz#933a04052860c85e83c122479c4748a8e4c72156" + integrity sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA== + +error-ex@^1.2.0, error-ex@^1.3.1: + version "1.3.2" + resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" + integrity sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g== + dependencies: + is-arrayish "^0.2.1" + +escape-string-regexp@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" + integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= + +fill-range@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" + integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== + dependencies: + to-regex-range "^5.0.1" + +find-up@^1.0.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-1.1.2.tgz#6b2e9822b1a2ce0a60ab64d610eccad53cb24d0f" + integrity sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8= + dependencies: + path-exists "^2.0.0" + pinkie-promise "^2.0.0" + +find-up@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-3.0.0.tgz#49169f1d7993430646da61ecc5ae355c21c97b73" + integrity sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg== + dependencies: + locate-path "^3.0.0" + +fs.realpath@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" + integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= + +fsevents@~2.1.2: + version "2.1.3" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.1.3.tgz#fb738703ae8d2f9fe900c33836ddebee8b97f23e" + integrity sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ== + +get-caller-file@^2.0.1: + version "2.0.5" + resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" + integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== + +get-stdin@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe" + integrity sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4= + +glob-parent@~5.1.0: + version "5.1.1" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.1.tgz#b6c1ef417c4e5663ea498f1c45afac6916bbc229" + integrity sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ== + dependencies: + is-glob "^4.0.1" + +glob@^7.1.3: + version "7.1.6" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6" + integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.4" + once "^1.3.0" + path-is-absolute "^1.0.0" + +google-protobuf@^3.13.0, google-protobuf@^3.6.1: + version "3.13.0" + resolved "https://registry.yarnpkg.com/google-protobuf/-/google-protobuf-3.13.0.tgz#909c5983d75dd6101ed57c79e0528d000cdc3251" + integrity sha512-ZIf3qfLFayVrPvAjeKKxO5FRF1/NwRxt6Dko+fWEMuHwHbZx8/fcaAao9b0wCM6kr8qeg2te8XTpyuvKuD9aKw== + +graceful-fs@^4.1.2: + version "4.2.4" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.4.tgz#2256bde14d3632958c465ebc96dc467ca07a29fb" + integrity sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw== + +has-flag@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" + integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= + +hosted-git-info@^2.1.4: + version "2.8.8" + resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.8.tgz#7539bd4bc1e0e0a895815a2e0262420b12858488" + integrity sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg== + +indent-string@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-2.1.0.tgz#8e2d48348742121b4a8218b7a137e9a52049dc80" + integrity sha1-ji1INIdCEhtKghi3oTfppSBJ3IA= + dependencies: + repeating "^2.0.0" + +inflight@^1.0.4: + version "1.0.6" + resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= + dependencies: + once "^1.3.0" + wrappy "1" + +inherits@2: + version "2.0.4" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" + integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== + +is-arrayish@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" + integrity sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0= + +is-binary-path@~2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" + integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== + dependencies: + binary-extensions "^2.0.0" + +is-extglob@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" + integrity sha1-qIwCU1eR8C7TfHahueqXc8gz+MI= + +is-finite@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-finite/-/is-finite-1.1.0.tgz#904135c77fb42c0641d6aa1bcdbc4daa8da082f3" + integrity sha512-cdyMtqX/BOqqNBBiKlIVkytNHm49MtMlYyn1zxzvJKWmFMlGzm+ry5BBfYyeY9YmNKbRSo/o7OX9w9ale0wg3w== + +is-fullwidth-code-point@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" + integrity sha1-o7MKXE8ZkYMWeqq5O+764937ZU8= + +is-glob@^4.0.1, is-glob@~4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.1.tgz#7567dbe9f2f5e2467bc77ab83c4a29482407a5dc" + integrity sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg== + dependencies: + is-extglob "^2.1.1" + +is-number@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" + integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== + +is-utf8@^0.2.0: + version "0.2.1" + resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" + integrity sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI= + +json-parse-better-errors@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9" + integrity sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw== + +load-json-file@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-1.1.0.tgz#956905708d58b4bab4c2261b04f59f31c99374c0" + integrity sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA= + dependencies: + graceful-fs "^4.1.2" + parse-json "^2.2.0" + pify "^2.0.0" + pinkie-promise "^2.0.0" + strip-bom "^2.0.0" + +locate-path@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e" + integrity sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A== + dependencies: + p-locate "^3.0.0" + path-exists "^3.0.0" + +lodash@^4.17.15: + version "4.17.20" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52" + integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA== + +loud-rejection@^1.0.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/loud-rejection/-/loud-rejection-1.6.0.tgz#5b46f80147edee578870f086d04821cf998e551f" + integrity sha1-W0b4AUft7leIcPCG0Eghz5mOVR8= + dependencies: + currently-unhandled "^0.4.1" + signal-exit "^3.0.0" + +make-error@^1.1.1: + version "1.3.6" + resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" + integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== + +map-obj@^1.0.0, map-obj@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-1.0.1.tgz#d933ceb9205d82bdcf4886f6742bdc2b4dea146d" + integrity sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0= + +meow@^3.3.0: + version "3.7.0" + resolved "https://registry.yarnpkg.com/meow/-/meow-3.7.0.tgz#72cb668b425228290abbfa856892587308a801fb" + integrity sha1-cstmi0JSKCkKu/qFaJJYcwioAfs= + dependencies: + camelcase-keys "^2.0.0" + decamelize "^1.1.2" + loud-rejection "^1.0.0" + map-obj "^1.0.1" + minimist "^1.1.3" + normalize-package-data "^2.3.4" + object-assign "^4.0.1" + read-pkg-up "^1.0.1" + redent "^1.0.0" + trim-newlines "^1.0.0" + +minimatch@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" + integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA== + dependencies: + brace-expansion "^1.1.7" + +minimist@^1.1.3, minimist@^1.2.5: + version "1.2.5" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" + integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== + +mkdirp@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" + integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== + +normalize-package-data@^2.3.2, normalize-package-data@^2.3.4: + version "2.5.0" + resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.5.0.tgz#e66db1838b200c1dfc233225d12cb36520e234a8" + integrity sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA== + dependencies: + hosted-git-info "^2.1.4" + resolve "^1.10.0" + semver "2 || 3 || 4 || 5" + validate-npm-package-license "^3.0.1" + +normalize-path@^3.0.0, normalize-path@~3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" + integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== + +object-assign@^4.0.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" + integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM= + +once@^1.3.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= + dependencies: + wrappy "1" + +p-limit@^2.0.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1" + integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w== + dependencies: + p-try "^2.0.0" + +p-locate@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-3.0.0.tgz#322d69a05c0264b25997d9f40cd8a891ab0064a4" + integrity sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ== + dependencies: + p-limit "^2.0.0" + +p-try@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" + integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== + +parse-json@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-2.2.0.tgz#f480f40434ef80741f8469099f8dea18f55a4dc9" + integrity sha1-9ID0BDTvgHQfhGkJn43qGPVaTck= + dependencies: + error-ex "^1.2.0" + +parse-json@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-4.0.0.tgz#be35f5425be1f7f6c747184f98a788cb99477ee0" + integrity sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA= + dependencies: + error-ex "^1.3.1" + json-parse-better-errors "^1.0.1" + +path-exists@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-2.1.0.tgz#0feb6c64f0fc518d9a754dd5efb62c7022761f4b" + integrity sha1-D+tsZPD8UY2adU3V77YscCJ2H0s= + dependencies: + pinkie-promise "^2.0.0" + +path-exists@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515" + integrity sha1-zg6+ql94yxiSXqfYENe1mwEP1RU= + +path-is-absolute@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= + +path-parse@^1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" + integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw== + +path-type@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/path-type/-/path-type-1.1.0.tgz#59c44f7ee491da704da415da5a4070ba4f8fe441" + integrity sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE= + dependencies: + graceful-fs "^4.1.2" + pify "^2.0.0" + pinkie-promise "^2.0.0" + +picomatch@^2.0.4, picomatch@^2.2.1: + version "2.2.2" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad" + integrity sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg== + +pify@^2.0.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" + integrity sha1-7RQaasBDqEnqWISY59yosVMw6Qw= + +pify@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176" + integrity sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY= + +pinkie-promise@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa" + integrity sha1-ITXW36ejWMBprJsXh3YogihFD/o= + dependencies: + pinkie "^2.0.0" + +pinkie@^2.0.0: + version "2.0.4" + resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870" + integrity sha1-clVrgM+g1IqXToDnckjoDtT3+HA= + +read-pkg-up@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-1.0.1.tgz#9d63c13276c065918d57f002a57f40a1b643fb02" + integrity sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI= + dependencies: + find-up "^1.0.0" + read-pkg "^1.0.0" + +read-pkg@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-1.1.0.tgz#f5ffaa5ecd29cb31c0474bca7d756b6bb29e3f28" + integrity sha1-9f+qXs0pyzHAR0vKfXVra7KePyg= + dependencies: + load-json-file "^1.0.0" + normalize-package-data "^2.3.2" + path-type "^1.0.0" + +read-pkg@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-4.0.1.tgz#963625378f3e1c4d48c85872b5a6ec7d5d093237" + integrity sha1-ljYlN48+HE1IyFhytabsfV0JMjc= + dependencies: + normalize-package-data "^2.3.2" + parse-json "^4.0.0" + pify "^3.0.0" + +readdirp@~3.4.0: + version "3.4.0" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.4.0.tgz#9fdccdf9e9155805449221ac645e8303ab5b9ada" + integrity sha512-0xe001vZBnJEK+uKcj8qOhyAKPzIT+gStxWr3LCB0DwcXR5NZJ3IaC+yGnHCYzB/S7ov3m3EEbZI2zeNvX+hGQ== + dependencies: + picomatch "^2.2.1" + +redent@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/redent/-/redent-1.0.0.tgz#cf916ab1fd5f1f16dfb20822dd6ec7f730c2afde" + integrity sha1-z5Fqsf1fHxbfsggi3W7H9zDCr94= + dependencies: + indent-string "^2.1.0" + strip-indent "^1.0.1" + +repeating@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/repeating/-/repeating-2.0.1.tgz#5214c53a926d3552707527fbab415dbc08d06dda" + integrity sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo= + dependencies: + is-finite "^1.0.0" + +require-directory@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" + integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I= + +require-main-filename@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b" + integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg== + +resolve@^1.0.0, resolve@^1.10.0: + version "1.17.0" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.17.0.tgz#b25941b54968231cc2d1bb76a79cb7f2c0bf8444" + integrity sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w== + dependencies: + path-parse "^1.0.6" + +rimraf@^2.6.1: + version "2.7.1" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec" + integrity sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w== + dependencies: + glob "^7.1.3" + +rxjs@^6.5.2: + version "6.6.3" + resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.6.3.tgz#8ca84635c4daa900c0d3967a6ee7ac60271ee552" + integrity sha512-trsQc+xYYXZ3urjOiJOuCOa5N3jAZ3eiSpQB5hIT8zGlL2QfnHLJ2r7GMkBGuIausdJN1OneaI6gQlsqNHHmZQ== + dependencies: + tslib "^1.9.0" + +"semver@2 || 3 || 4 || 5": + version "5.7.1" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" + integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== + +set-blocking@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" + integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc= + +signal-exit@^3.0.0: + version "3.0.3" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c" + integrity sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA== + +source-map-support@^0.5.12, source-map-support@^0.5.17: + version "0.5.19" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61" + integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw== + dependencies: + buffer-from "^1.0.0" + source-map "^0.6.0" + +source-map@^0.6.0: + version "0.6.1" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" + integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== + +spawn-command@^0.0.2-1: + version "0.0.2-1" + resolved "https://registry.yarnpkg.com/spawn-command/-/spawn-command-0.0.2-1.tgz#62f5e9466981c1b796dc5929937e11c9c6921bd0" + integrity sha1-YvXpRmmBwbeW3Fkpk34RycaSG9A= + +spdx-correct@^3.0.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.1.1.tgz#dece81ac9c1e6713e5f7d1b6f17d468fa53d89a9" + integrity sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w== + dependencies: + spdx-expression-parse "^3.0.0" + spdx-license-ids "^3.0.0" + +spdx-exceptions@^2.1.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz#3f28ce1a77a00372683eade4a433183527a2163d" + integrity sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A== + +spdx-expression-parse@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz#cf70f50482eefdc98e3ce0a6833e4a53ceeba679" + integrity sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q== + dependencies: + spdx-exceptions "^2.1.0" + spdx-license-ids "^3.0.0" + +spdx-license-ids@^3.0.0: + version "3.0.6" + resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.6.tgz#c80757383c28abf7296744998cbc106ae8b854ce" + integrity sha512-+orQK83kyMva3WyPf59k1+Y525csj5JejicWut55zeTWANuN17qSiSLUXWtzHeNWORSvT7GLDJ/E/XiIWoXBTw== + +string-width@^3.0.0, string-width@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-3.1.0.tgz#22767be21b62af1081574306f69ac51b62203961" + integrity sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w== + dependencies: + emoji-regex "^7.0.1" + is-fullwidth-code-point "^2.0.0" + strip-ansi "^5.1.0" + +strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-5.2.0.tgz#8c9a536feb6afc962bdfa5b104a5091c1ad9c0ae" + integrity sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA== + dependencies: + ansi-regex "^4.1.0" + +strip-bom@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-2.0.0.tgz#6219a85616520491f35788bdbf1447a99c7e6b0e" + integrity sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4= + dependencies: + is-utf8 "^0.2.0" + +strip-bom@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" + integrity sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM= + +strip-indent@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-1.0.1.tgz#0c7962a6adefa7bbd4ac366460a638552ae1a0a2" + integrity sha1-DHlipq3vp7vUrDZkYKY4VSrhoKI= + dependencies: + get-stdin "^4.0.1" + +strip-json-comments@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" + integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo= + +supports-color@^5.3.0: + version "5.5.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" + integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== + dependencies: + has-flag "^3.0.0" + +supports-color@^6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-6.1.0.tgz#0764abc69c63d5ac842dd4867e8d025e880df8f3" + integrity sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ== + dependencies: + has-flag "^3.0.0" + +to-regex-range@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" + integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== + dependencies: + is-number "^7.0.0" + +tree-kill@^1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/tree-kill/-/tree-kill-1.2.2.tgz#4ca09a9092c88b73a7cdc5e8a01b507b0790a0cc" + integrity sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A== + +trim-newlines@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613" + integrity sha1-WIeWa7WCpFA6QetST301ARgVphM= + +ts-node-dev@^1.0.0-pre.44: + version "1.0.0-pre.62" + resolved "https://registry.yarnpkg.com/ts-node-dev/-/ts-node-dev-1.0.0-pre.62.tgz#835644c43669b659a880379b9d06df86cef665ad" + integrity sha512-hfsEuCqUZOVnZ86l7A3icxD1nFt1HEmLVbx4YOHCkrbSHPBNWcw+IczAPZo3zz7YiOm9vs0xG6OENNrkgm89tQ== + dependencies: + chokidar "^3.4.0" + dateformat "~1.0.4-1.2.3" + dynamic-dedupe "^0.3.0" + minimist "^1.2.5" + mkdirp "^1.0.4" + resolve "^1.0.0" + rimraf "^2.6.1" + source-map-support "^0.5.12" + tree-kill "^1.2.2" + ts-node "^8.10.2" + tsconfig "^7.0.0" + +ts-node@^8.10.2: + version "8.10.2" + resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-8.10.2.tgz#eee03764633b1234ddd37f8db9ec10b75ec7fb8d" + integrity sha512-ISJJGgkIpDdBhWVu3jufsWpK3Rzo7bdiIXJjQc0ynKxVOVcg2oIrf2H2cejminGrptVc6q6/uynAHNCuWGbpVA== + dependencies: + arg "^4.1.0" + diff "^4.0.1" + make-error "^1.1.1" + source-map-support "^0.5.17" + yn "3.1.1" + +ts-protoc-gen@^0.13.0: + version "0.13.0" + resolved "https://registry.yarnpkg.com/ts-protoc-gen/-/ts-protoc-gen-0.13.0.tgz#2763ae4e4a1a7d7001d53d2f3043357c691701ea" + integrity sha512-j18X4rkDBbG/ZHUJy88WFeZP6mStGow5uREaohowlHXTu3/N7WcpyPhb7Vh6wN38ERmc/AkT9gqT98+vtlRhJA== + dependencies: + google-protobuf "^3.6.1" + +tsconfig@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/tsconfig/-/tsconfig-7.0.0.tgz#84538875a4dc216e5c4a5432b3a4dec3d54e91b7" + integrity sha512-vZXmzPrL+EmC4T/4rVlT2jNVMWCi/O4DIiSj3UHg1OE5kCKbk4mfrXc6dZksLgRM/TZlKnousKH9bbTazUWRRw== + dependencies: + "@types/strip-bom" "^3.0.0" + "@types/strip-json-comments" "0.0.30" + strip-bom "^3.0.0" + strip-json-comments "^2.0.0" + +tslib@^1.9.0: + version "1.13.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.13.0.tgz#c881e13cc7015894ed914862d276436fa9a47043" + integrity sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q== + +typescript@^3.8.3: + version "3.9.7" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.7.tgz#98d600a5ebdc38f40cb277522f12dc800e9e25fa" + integrity sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw== + +validate-npm-package-license@^3.0.1: + version "3.0.4" + resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz#fc91f6b9c7ba15c857f4cb2c5defeec39d4f410a" + integrity sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew== + dependencies: + spdx-correct "^3.0.0" + spdx-expression-parse "^3.0.0" + +which-module@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" + integrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho= + +wrap-ansi@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-5.1.0.tgz#1fd1f67235d5b6d0fee781056001bfb694c03b09" + integrity sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q== + dependencies: + ansi-styles "^3.2.0" + string-width "^3.0.0" + strip-ansi "^5.0.0" + +wrappy@1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= + +xtend@^4.0.0: + version "4.0.2" + resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54" + integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ== + +y18n@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b" + integrity sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w== + +yargs-parser@^13.1.2: + version "13.1.2" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-13.1.2.tgz#130f09702ebaeef2650d54ce6e3e5706f7a4fb38" + integrity sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg== + dependencies: + camelcase "^5.0.0" + decamelize "^1.2.0" + +yargs@^13.3.0: + version "13.3.2" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-13.3.2.tgz#ad7ffefec1aa59565ac915f82dccb38a9c31a2dd" + integrity sha512-AX3Zw5iPruN5ie6xGRIDgqkT+ZhnRlZMLMHAs8tg7nRruy2Nb+i5o9bwghAogtM08q1dpr2LVoS8KSTMYpWXUw== + dependencies: + cliui "^5.0.0" + find-up "^3.0.0" + get-caller-file "^2.0.1" + require-directory "^2.1.1" + require-main-filename "^2.0.0" + set-blocking "^2.0.0" + string-width "^3.0.0" + which-module "^2.0.0" + y18n "^4.0.0" + yargs-parser "^13.1.2" + +yn@3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" + integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q== From ed9552b62b531166332b09182481a13ac3bdca00 Mon Sep 17 00:00:00 2001 From: arp Date: Thu, 17 Sep 2020 18:08:20 +0200 Subject: [PATCH 021/122] added a register route via token --- back/package.json | 1 + back/src/App.ts | 3 ++ back/src/Controller/AdminController.ts | 40 ++++++++++++++++++++++++++ back/src/Enum/EnvironmentVariable.ts | 8 ++++-- back/yarn.lock | 12 ++++++++ front/src/index.ts | 3 +- front/src/register.ts | 12 ++++++++ 7 files changed, 76 insertions(+), 3 deletions(-) create mode 100644 back/src/Controller/AdminController.ts create mode 100644 front/src/register.ts diff --git a/back/package.json b/back/package.json index a20c876f..396991f2 100644 --- a/back/package.json +++ b/back/package.json @@ -41,6 +41,7 @@ "@types/jsonwebtoken": "^8.3.8", "@types/socket.io": "^2.1.4", "@types/uuidv4": "^5.0.0", + "axios": "^0.20.0", "body-parser": "^1.19.0", "express": "^4.17.1", "generic-type-guard": "^3.2.0", diff --git a/back/src/App.ts b/back/src/App.ts index e12afdb4..d1f7392f 100644 --- a/back/src/App.ts +++ b/back/src/App.ts @@ -7,6 +7,7 @@ import bodyParser = require('body-parser'); import * as http from "http"; import {MapController} from "./Controller/MapController"; import {PrometheusController} from "./Controller/PrometheusController"; +import {AdminController} from "./Controller/AdminController"; class App { public app: Application; @@ -15,6 +16,7 @@ class App { public authenticateController: AuthenticateController; public mapController: MapController; public prometheusController: PrometheusController; + private adminController: AdminController; constructor() { this.app = express(); @@ -32,6 +34,7 @@ class App { this.authenticateController = new AuthenticateController(this.app); this.mapController = new MapController(this.app); this.prometheusController = new PrometheusController(this.app, this.ioSocketController); + this.adminController = new AdminController(this.app); } // TODO add session user diff --git a/back/src/Controller/AdminController.ts b/back/src/Controller/AdminController.ts new file mode 100644 index 00000000..d6f1d23d --- /dev/null +++ b/back/src/Controller/AdminController.ts @@ -0,0 +1,40 @@ +import {Application, Request, Response} from "express"; +import {OK} from "http-status-codes"; +import {ADMIN_API_URL} from "../Enum/EnvironmentVariable"; +import Axios, {AxiosError} from "axios"; + +export class AdminController { + App : Application; + + constructor(App : Application) { + this.App = App; + this.getLoginUrlByToken(); + } + + + getLoginUrlByToken(){ + this.App.get("/register/:token", async (req: Request, res: Response) => { + if (!ADMIN_API_URL) { + return res.status(500).send('No admin backoffice set!'); + } + const token:string = req.params.token; + + //todo add ADMIN_API_TOKEN authorization + let response = null + try { + console.log(ADMIN_API_URL+'/api/login-url/'+token); + response = await Axios.get(ADMIN_API_URL+'/api/login-url/'+token) + } catch (e) { + console.log(e.message) + return res.status(500).send('An error happened'); + } + + const teamSlug = response.data.teamSlug; + const worldSlug = response.data.worldSlug; + const roomSlug = response.data.roomSlug; + return res.status(OK).send({ + loginUrl: '/@/'+teamSlug+'/'+worldSlug+'/'+roomSlug, + }); + }); + } +} diff --git a/back/src/Enum/EnvironmentVariable.ts b/back/src/Enum/EnvironmentVariable.ts index d8baaf89..c910bb66 100644 --- a/back/src/Enum/EnvironmentVariable.ts +++ b/back/src/Enum/EnvironmentVariable.ts @@ -3,11 +3,15 @@ const URL_ROOM_STARTED = "/Floor0/floor0.json"; const MINIMUM_DISTANCE = process.env.MINIMUM_DISTANCE ? Number(process.env.MINIMUM_DISTANCE) : 64; const GROUP_RADIUS = process.env.GROUP_RADIUS ? Number(process.env.GROUP_RADIUS) : 48; const ALLOW_ARTILLERY = process.env.ALLOW_ARTILLERY ? process.env.ALLOW_ARTILLERY == 'true' : false; +const ADMIN_API_URL = process.env.ADMIN_API_URL || null; +const ADMIN_API_TOKEN = process.env.ADMIN_API_TOKEN || null; export { SECRET_KEY, URL_ROOM_STARTED, MINIMUM_DISTANCE, + ADMIN_API_URL, + ADMIN_API_TOKEN, GROUP_RADIUS, - ALLOW_ARTILLERY -} + ALLOW_ARTILLERY, +} \ No newline at end of file diff --git a/back/yarn.lock b/back/yarn.lock index f660a5c8..c498ff43 100644 --- a/back/yarn.lock +++ b/back/yarn.lock @@ -244,6 +244,13 @@ async-limiter@~1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.1.tgz#dd379e94f0db8310b08291f9d64c3209766617fd" +axios@^0.20.0: + version "0.20.0" + resolved "https://registry.yarnpkg.com/axios/-/axios-0.20.0.tgz#057ba30f04884694993a8cd07fa394cff11c50bd" + integrity sha512-ANA4rr2BDcmmAQLOKft2fufrtuvlqR+cXNNinUmvfeSNCOF98PZL+7M/v1zIdGo7OLjEA9J2gXJL+j4zGsl0bA== + dependencies: + follow-redirects "^1.10.0" + backo2@1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/backo2/-/backo2-1.0.2.tgz#31ab1ac8b129363463e35b3ebb69f4dfcfba7947" @@ -774,6 +781,11 @@ flatted@^2.0.0: version "2.0.2" resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138" +follow-redirects@^1.10.0: + version "1.13.0" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.13.0.tgz#b42e8d93a2a7eea5ed88633676d6597bc8e384db" + integrity sha512-aq6gF1BEKje4a9i9+5jimNFIpq4Q1WiwBToeRK5NvZBd/TRsmW8BsJfOEGkr76TbOyPVD3OVDN910EcUNtRYEA== + forwarded@~0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.1.2.tgz#98c23dab1175657b8c0573e8ceccd91b0ff18c84" diff --git a/front/src/index.ts b/front/src/index.ts index 2356bd0a..8be675fb 100644 --- a/front/src/index.ts +++ b/front/src/index.ts @@ -10,10 +10,11 @@ import {FourOFourScene} from "./Phaser/Reconnecting/FourOFourScene"; import WebGLRenderer = Phaser.Renderer.WebGL.WebGLRenderer; import {OutlinePipeline} from "./Phaser/Shaders/OutlinePipeline"; import {CustomizeScene} from "./Phaser/Login/CustomizeScene"; -import {HtmlUtils} from "./WebRtc/HtmlUtils"; import {CoWebsiteManager} from "./WebRtc/CoWebsiteManager"; +import {redirectIfToken} from "./register"; //CoWebsiteManager.loadCoWebsite('https://thecodingmachine.com'); +redirectIfToken(); // Load Jitsi if the environment variable is set. if (JITSI_URL) { diff --git a/front/src/register.ts b/front/src/register.ts new file mode 100644 index 00000000..0cc9dd13 --- /dev/null +++ b/front/src/register.ts @@ -0,0 +1,12 @@ +import Axios from "axios"; +import {API_URL} from "./Enum/EnvironmentVariable"; +declare let window:Window; + +export function redirectIfToken() { + const match = window.location.toString().match(/\/register\/(.+)/); + if (match) { + Axios.get(`${API_URL}/register/`+match[1]).then((res) => { + window.location = res.data.loginUrl; + }); + } +} \ No newline at end of file From e9ca8721a664f41c8023daf4032ea3eefa2d3fe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Fri, 18 Sep 2020 13:57:38 +0200 Subject: [PATCH 022/122] Migrating userId to "int32" to save some space and adding userMoves message in protobuf --- back/src/Controller/AuthenticateController.ts | 8 +- back/src/Controller/IoSocketController.ts | 141 ++++++----- back/src/Model/Group.ts | 9 +- back/src/Model/User.ts | 2 +- back/src/Model/Websocket/ExSocketInterface.ts | 3 +- .../Model/Websocket/GroupUpdateInterface.ts | 2 +- back/src/Model/Websocket/Identificable.ts | 2 +- back/src/Model/Websocket/MessageUserJoined.ts | 2 +- back/src/Model/Websocket/MessageUserMoved.ts | 2 +- .../Model/Websocket/MessageUserPosition.ts | 2 +- .../Model/Websocket/UserInGroupInterface.ts | 2 +- back/src/Model/Websocket/UserMovesMessage.ts | 11 - .../Model/Websocket/WebRtcSignalMessage.ts | 4 +- back/src/Model/World.ts | 10 +- back/tests/PositionNotifierTest.ts | 8 +- back/tests/WorldTest.ts | 38 +-- docker-compose.yaml | 10 +- front/src/Connection.ts | 72 ++++-- front/src/Phaser/Entity/RemotePlayer.ts | 4 +- front/src/Phaser/Game/AddPlayerInterface.ts | 2 +- front/src/Phaser/Game/GameScene.ts | 16 +- .../Game/PlayersPositionInterpolator.ts | 12 +- front/src/WebRtc/MediaManager.ts | 30 +-- front/src/WebRtc/ScreenSharingPeer.ts | 12 +- front/src/WebRtc/SimplePeer.ts | 30 +-- front/src/WebRtc/VideoPeer.ts | 10 +- messages/generated/.gitignore | 3 +- messages/generated/src/proto/messages_pb.d.ts | 31 --- messages/generated/src/proto/messages_pb.js | 223 ------------------ messages/messages.proto | 35 +++ messages/package.json | 4 +- 31 files changed, 295 insertions(+), 445 deletions(-) delete mode 100644 back/src/Model/Websocket/UserMovesMessage.ts delete mode 100644 messages/generated/src/proto/messages_pb.d.ts delete mode 100644 messages/generated/src/proto/messages_pb.js diff --git a/back/src/Controller/AuthenticateController.ts b/back/src/Controller/AuthenticateController.ts index 71e538a4..83880f45 100644 --- a/back/src/Controller/AuthenticateController.ts +++ b/back/src/Controller/AuthenticateController.ts @@ -6,7 +6,7 @@ import { uuid } from 'uuidv4'; export interface TokenInterface { name: string, - userId: string + userUuid: string } export class AuthenticateController { @@ -28,12 +28,12 @@ export class AuthenticateController { }); }*/ //TODO check user email for The Coding Machine game - const userId = uuid(); - const token = Jwt.sign({name: param.name, userId: userId} as TokenInterface, SECRET_KEY, {expiresIn: '24h'}); + const userUuid = uuid(); + const token = Jwt.sign({name: param.name, userUuid: userUuid} as TokenInterface, SECRET_KEY, {expiresIn: '24h'}); return res.status(OK).send({ token: token, mapUrlStart: URL_ROOM_STARTED, - userId: userId, + userId: userUuid, }); }); } diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index 38950e35..a2732fb8 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -20,13 +20,14 @@ import {isWebRtcSignalMessageInterface} from "../Model/Websocket/WebRtcSignalMes import {UserInGroupInterface} from "../Model/Websocket/UserInGroupInterface"; import {isItemEventMessageInterface} from "../Model/Websocket/ItemEventMessage"; import {uuid} from 'uuidv4'; -import {isUserMovesInterface} from "../Model/Websocket/UserMovesMessage"; import {isViewport} from "../Model/Websocket/ViewportMessage"; import {GroupUpdateInterface} from "_Model/Websocket/GroupUpdateInterface"; import {Movable} from "../Model/Movable"; -import {SetPlayerDetailsMessage} from "../../../messages/generated/src/proto/messages_pb"; +import {PositionMessage, SetPlayerDetailsMessage} from "../../../messages/generated/messages_pb"; +import {UserMovesMessage} from "../../../messages/generated/messages_pb"; +import Direction = PositionMessage.Direction; -enum SockerIoEvent { +enum SocketIoEvent { CONNECTION = "connection", DISCONNECT = "disconnect", JOIN_ROOM = "join-room", // bi-directional @@ -52,7 +53,7 @@ function emitInBatch(socket: ExSocketInterface, event: string | symbol, payload: if (socket.batchTimeout === null) { socket.batchTimeout = setTimeout(() => { - socket.emit(SockerIoEvent.BATCH, socket.batchedMessages); + socket.emit(SocketIoEvent.BATCH, socket.batchedMessages); socket.batchedMessages = []; socket.batchTimeout = null; }, 100); @@ -62,9 +63,10 @@ function emitInBatch(socket: ExSocketInterface, event: string | symbol, payload: export class IoSocketController { public readonly Io: socketIO.Server; private Worlds: Map = new Map(); - private sockets: Map = new Map(); + private sockets: Map = new Map(); private nbClientsGauge: Gauge; private nbClientsPerRoomGauge: Gauge; + private nextUserId: number = 1; constructor(server: http.Server) { this.Io = socketIO(server); @@ -90,7 +92,9 @@ export class IoSocketController { if(socket.handshake.query.token === 'test'){ if (ALLOW_ARTILLERY) { (socket as ExSocketInterface).token = socket.handshake.query.token; - (socket as ExSocketInterface).userId = uuid(); + (socket as ExSocketInterface).userId = this.nextUserId; + (socket as ExSocketInterface).userUuid = uuid(); + this.nextUserId++; (socket as ExSocketInterface).isArtillery = true; console.log((socket as ExSocketInterface).userId); next(); @@ -116,7 +120,9 @@ export class IoSocketController { } (socket as ExSocketInterface).token = socket.handshake.query.token; - (socket as ExSocketInterface).userId = tokenDecoded.userId; + (socket as ExSocketInterface).userId = this.nextUserId; + (socket as ExSocketInterface).userUuid = tokenDecoded.userUuid; + this.nextUserId++; next(); }); }); @@ -125,7 +131,7 @@ export class IoSocketController { } private isValidToken(token: object): token is TokenInterface { - if (typeof((token as TokenInterface).userId) !== 'string') { + if (typeof((token as TokenInterface).userUuid) !== 'string') { return false; } if (typeof((token as TokenInterface).name) !== 'string') { @@ -151,7 +157,7 @@ export class IoSocketController { } ioConnection() { - this.Io.on(SockerIoEvent.CONNECTION, (socket: Socket) => { + this.Io.on(SocketIoEvent.CONNECTION, (socket: Socket) => { const client : ExSocketInterface = socket as ExSocketInterface; client.batchedMessages = []; client.batchTimeout = null; @@ -176,11 +182,11 @@ export class IoSocketController { x: user x position on map y: user y position on map */ - socket.on(SockerIoEvent.JOIN_ROOM, (message: unknown, answerFn): void => { - console.log(SockerIoEvent.JOIN_ROOM, message); + socket.on(SocketIoEvent.JOIN_ROOM, (message: unknown, answerFn): void => { + console.log(SocketIoEvent.JOIN_ROOM, message); try { if (!isJoinRoomMessageInterface(message)) { - socket.emit(SockerIoEvent.MESSAGE_ERROR, {message: 'Invalid JOIN_ROOM message.'}); + socket.emit(SocketIoEvent.MESSAGE_ERROR, {message: 'Invalid JOIN_ROOM message.'}); console.warn('Invalid JOIN_ROOM message received: ', message); return; } @@ -244,11 +250,11 @@ export class IoSocketController { } }); - socket.on(SockerIoEvent.SET_VIEWPORT, (message: unknown): void => { + socket.on(SocketIoEvent.SET_VIEWPORT, (message: unknown): void => { try { //console.log('SET_VIEWPORT') if (!isViewport(message)) { - socket.emit(SockerIoEvent.MESSAGE_ERROR, {message: 'Invalid SET_VIEWPORT message.'}); + socket.emit(SocketIoEvent.MESSAGE_ERROR, {message: 'Invalid SET_VIEWPORT message.'}); console.warn('Invalid SET_VIEWPORT message received: ', message); return; } @@ -268,20 +274,47 @@ export class IoSocketController { } }); - socket.on(SockerIoEvent.USER_POSITION, (userMovesMessage: unknown): void => { + socket.on(SocketIoEvent.USER_POSITION, (message: unknown): void => { //console.log(SockerIoEvent.USER_POSITION, userMovesMessage); try { - if (!isUserMovesInterface(userMovesMessage)) { - socket.emit(SockerIoEvent.MESSAGE_ERROR, {message: 'Invalid USER_POSITION message.'}); - console.warn('Invalid USER_POSITION message received: ', userMovesMessage); - return; + const userMovesMessage = UserMovesMessage.deserializeBinary(new Uint8Array(message as ArrayBuffer)); + const userMoves = userMovesMessage.toObject(); + + const position = userMoves.position; + if (position === undefined) { + throw new Error('Position not found in message'); + } + const viewport = userMoves.viewport; + if (viewport === undefined) { + throw new Error('Viewport not found in message'); + } + + let direction: string; + switch (position.direction) { + case Direction.UP: + direction = 'up'; + break; + case Direction.DOWN: + direction = 'down'; + break; + case Direction.LEFT: + direction = 'left'; + break; + case Direction.RIGHT: + direction = 'right'; + break; } const Client = (socket as ExSocketInterface); // sending to all clients in room except sender - Client.position = userMovesMessage.position; - Client.viewport = userMovesMessage.viewport; + Client.position = { + x: position.x, + y: position.y, + direction, + moving: position.moving, + }; + Client.viewport = viewport; // update position in the world const world = this.Worlds.get(Client.roomId); @@ -297,15 +330,15 @@ export class IoSocketController { } }); - socket.on(SockerIoEvent.WEBRTC_SIGNAL, (data: unknown) => { + socket.on(SocketIoEvent.WEBRTC_SIGNAL, (data: unknown) => { this.emitVideo((socket as ExSocketInterface), data); }); - socket.on(SockerIoEvent.WEBRTC_SCREEN_SHARING_SIGNAL, (data: unknown) => { + socket.on(SocketIoEvent.WEBRTC_SCREEN_SHARING_SIGNAL, (data: unknown) => { this.emitScreenSharing((socket as ExSocketInterface), data); }); - socket.on(SockerIoEvent.DISCONNECT, () => { + socket.on(SocketIoEvent.DISCONNECT, () => { const Client = (socket as ExSocketInterface); try { //leave room @@ -335,16 +368,16 @@ export class IoSocketController { }); // Let's send the user id to the user - socket.on(SockerIoEvent.SET_PLAYER_DETAILS, (message: any, answerFn) => { - console.log(SockerIoEvent.SET_PLAYER_DETAILS, message); + socket.on(SocketIoEvent.SET_PLAYER_DETAILS, (message: any, answerFn) => { + console.log(SocketIoEvent.SET_PLAYER_DETAILS, message); const playerDetailsMessage = SetPlayerDetailsMessage.deserializeBinary(new Uint8Array(message)); const playerDetails = { name: playerDetailsMessage.getName(), characterLayers: playerDetailsMessage.getCharacterlayersList() }; - console.log(SockerIoEvent.SET_PLAYER_DETAILS, playerDetails); + console.log(SocketIoEvent.SET_PLAYER_DETAILS, playerDetails); if (!isSetPlayerDetailsMessage(playerDetails)) { - socket.emit(SockerIoEvent.MESSAGE_ERROR, {message: 'Invalid SET_PLAYER_DETAILS message.'}); + socket.emit(SocketIoEvent.MESSAGE_ERROR, {message: 'Invalid SET_PLAYER_DETAILS message.'}); console.warn('Invalid SET_PLAYER_DETAILS message received: ', playerDetails); return; } @@ -357,10 +390,10 @@ export class IoSocketController { } }); - socket.on(SockerIoEvent.SET_SILENT, (silent: unknown) => { - console.log(SockerIoEvent.SET_SILENT, silent); + socket.on(SocketIoEvent.SET_SILENT, (silent: unknown) => { + console.log(SocketIoEvent.SET_SILENT, silent); if (typeof silent !== "boolean") { - socket.emit(SockerIoEvent.MESSAGE_ERROR, {message: 'Invalid SET_SILENT message.'}); + socket.emit(SocketIoEvent.MESSAGE_ERROR, {message: 'Invalid SET_SILENT message.'}); console.warn('Invalid SET_SILENT message received: ', silent); return; } @@ -381,16 +414,16 @@ export class IoSocketController { } }); - socket.on(SockerIoEvent.ITEM_EVENT, (itemEvent: unknown) => { + socket.on(SocketIoEvent.ITEM_EVENT, (itemEvent: unknown) => { if (!isItemEventMessageInterface(itemEvent)) { - socket.emit(SockerIoEvent.MESSAGE_ERROR, {message: 'Invalid ITEM_EVENT message.'}); + socket.emit(SocketIoEvent.MESSAGE_ERROR, {message: 'Invalid ITEM_EVENT message.'}); console.warn('Invalid ITEM_EVENT message received: ', itemEvent); return; } try { const Client = (socket as ExSocketInterface); - socket.to(Client.roomId).emit(SockerIoEvent.ITEM_EVENT, itemEvent); + socket.to(Client.roomId).emit(SocketIoEvent.ITEM_EVENT, itemEvent); const world = this.Worlds.get(Client.roomId); if (!world) { @@ -408,7 +441,7 @@ export class IoSocketController { emitVideo(socket: ExSocketInterface, data: unknown){ if (!isWebRtcSignalMessageInterface(data)) { - socket.emit(SockerIoEvent.MESSAGE_ERROR, {message: 'Invalid WEBRTC_SIGNAL message.'}); + socket.emit(SocketIoEvent.MESSAGE_ERROR, {message: 'Invalid WEBRTC_SIGNAL message.'}); console.warn('Invalid WEBRTC_SIGNAL message received: ', data); return; } @@ -418,7 +451,7 @@ export class IoSocketController { console.warn("While exchanging a WebRTC signal: client with id ", data.receiverId, " does not exist. This might be a race condition."); return; } - return client.emit(SockerIoEvent.WEBRTC_SIGNAL, { + return client.emit(SocketIoEvent.WEBRTC_SIGNAL, { userId: socket.userId, signal: data.signal }); @@ -426,7 +459,7 @@ export class IoSocketController { emitScreenSharing(socket: ExSocketInterface, data: unknown){ if (!isWebRtcSignalMessageInterface(data)) { - socket.emit(SockerIoEvent.MESSAGE_ERROR, {message: 'Invalid WEBRTC_SCREEN_SHARING message.'}); + socket.emit(SocketIoEvent.MESSAGE_ERROR, {message: 'Invalid WEBRTC_SCREEN_SHARING message.'}); console.warn('Invalid WEBRTC_SCREEN_SHARING message received: ', data); return; } @@ -436,13 +469,13 @@ export class IoSocketController { console.warn("While exchanging a WEBRTC_SCREEN_SHARING signal: client with id ", data.receiverId, " does not exist. This might be a race condition."); return; } - return client.emit(SockerIoEvent.WEBRTC_SCREEN_SHARING_SIGNAL, { + return client.emit(SocketIoEvent.WEBRTC_SCREEN_SHARING_SIGNAL, { userId: socket.userId, signal: data.signal }); } - searchClientByIdOrFail(userId: string): ExSocketInterface { + searchClientByIdOrFail(userId: number): ExSocketInterface { const client: ExSocketInterface|undefined = this.sockets.get(userId); if (client === undefined) { throw new Error("Could not find user with id " + userId); @@ -481,9 +514,9 @@ export class IoSocketController { //check and create new world for a room let world = this.Worlds.get(roomId) if(world === undefined){ - world = new World((user1: string, group: Group) => { + world = new World((user1: number, group: Group) => { this.connectedUser(user1, group); - }, (user1: string, group: Group) => { + }, (user1: number, group: Group) => { this.disConnectedUser(user1, group); }, MINIMUM_DISTANCE, GROUP_RADIUS, (thing: Movable, listener: User) => { const clientListener = this.searchClientByIdOrFail(listener.id); @@ -491,9 +524,9 @@ export class IoSocketController { const clientUser = this.searchClientByIdOrFail(thing.id); const messageUserJoined = new MessageUserJoined(clientUser.userId, clientUser.name, clientUser.characterLayers, clientUser.position); - clientListener.emit(SockerIoEvent.JOIN_ROOM, messageUserJoined); + clientListener.emit(SocketIoEvent.JOIN_ROOM, messageUserJoined); } else if (thing instanceof Group) { - clientListener.emit(SockerIoEvent.GROUP_CREATE_UPDATE, { + clientListener.emit(SocketIoEvent.GROUP_CREATE_UPDATE, { position: thing.getPosition(), groupId: thing.getId() } as GroupUpdateInterface); @@ -505,10 +538,10 @@ export class IoSocketController { if (thing instanceof User) { const clientUser = this.searchClientByIdOrFail(thing.id); - clientListener.emitInBatch(SockerIoEvent.USER_MOVED, new MessageUserMoved(clientUser.userId, clientUser.position)); + clientListener.emitInBatch(SocketIoEvent.USER_MOVED, new MessageUserMoved(clientUser.userId, clientUser.position)); //console.log("Sending USER_MOVED event"); } else if (thing instanceof Group) { - clientListener.emit(SockerIoEvent.GROUP_CREATE_UPDATE, { + clientListener.emit(SocketIoEvent.GROUP_CREATE_UPDATE, { position: thing.getPosition(), groupId: thing.getId() } as GroupUpdateInterface); @@ -519,10 +552,10 @@ export class IoSocketController { const clientListener = this.searchClientByIdOrFail(listener.id); if (thing instanceof User) { const clientUser = this.searchClientByIdOrFail(thing.id); - clientListener.emit(SockerIoEvent.USER_LEFT, clientUser.userId); + clientListener.emit(SocketIoEvent.USER_LEFT, clientUser.userId); //console.log("Sending USER_LEFT event"); } else if (thing instanceof Group) { - clientListener.emit(SockerIoEvent.GROUP_DELETE, thing.getId()); + clientListener.emit(SocketIoEvent.GROUP_DELETE, thing.getId()); } else { console.error('Unexpected type for Movable.'); } @@ -533,7 +566,7 @@ export class IoSocketController { // Dispatch groups position to newly connected user world.getGroups().forEach((group: Group) => { - Client.emit(SockerIoEvent.GROUP_CREATE_UPDATE, { + Client.emit(SocketIoEvent.GROUP_CREATE_UPDATE, { position: group.getPosition(), groupId: group.getId() } as GroupUpdateInterface); @@ -578,7 +611,7 @@ export class IoSocketController { return tabs; }, []); - client.emit(SockerIoEvent.WEBRTC_START, {clients: peerClients, roomId: roomId}); + client.emit(SocketIoEvent.WEBRTC_START, {clients: peerClients, roomId: roomId}); }); } @@ -600,19 +633,19 @@ export class IoSocketController { **/ //connected user - connectedUser(userId: string, group: Group) { + connectedUser(userId: number, group: Group) { /*let Client = this.sockets.get(userId); if (Client === undefined) { return; }*/ const Client = this.searchClientByIdOrFail(userId); - this.joinWebRtcRoom(Client, group.getId()); + this.joinWebRtcRoom(Client, "webrtcroom"+group.getId()); } //disconnect user - disConnectedUser(userId: string, group: Group) { + disConnectedUser(userId: number, group: Group) { const Client = this.searchClientByIdOrFail(userId); - Client.to(group.getId()).emit(SockerIoEvent.WEBRTC_DISCONNECT, { + Client.to("webrtcroom"+group.getId()).emit(SocketIoEvent.WEBRTC_DISCONNECT, { userId: userId }); @@ -622,7 +655,7 @@ export class IoSocketController { // the other player will try connecting until a timeout happens (during this time, the connection icon will be displayed for nothing). // So we also send the disconnect event to the other player. for (const user of group.getUsers()) { - Client.emit(SockerIoEvent.WEBRTC_DISCONNECT, { + Client.emit(SocketIoEvent.WEBRTC_DISCONNECT, { userId: user.id }); } diff --git a/back/src/Model/Group.ts b/back/src/Model/Group.ts index 4909b660..43990ef4 100644 --- a/back/src/Model/Group.ts +++ b/back/src/Model/Group.ts @@ -7,7 +7,9 @@ import {Movable} from "_Model/Movable"; export class Group implements Movable { static readonly MAX_PER_GROUP = 4; - private id: string; + private static nextId: number = 1; + + private id: number; private users: Set; private connectCallback: ConnectCallback; private disconnectCallback: DisconnectCallback; @@ -17,7 +19,8 @@ export class Group implements Movable { this.users = new Set(); this.connectCallback = connectCallback; this.disconnectCallback = disconnectCallback; - this.id = uuid(); + this.id = Group.nextId; + Group.nextId++; users.forEach((user: User) => { this.join(user); @@ -28,7 +31,7 @@ export class Group implements Movable { return Array.from(this.users.values()); } - getId() : string{ + getId() : number { return this.id; } diff --git a/back/src/Model/User.ts b/back/src/Model/User.ts index 160a101c..b147e4be 100644 --- a/back/src/Model/User.ts +++ b/back/src/Model/User.ts @@ -9,7 +9,7 @@ export class User implements Movable { public group?: Group; public constructor( - public id: string, + public id: number, public position: PointInterface, public silent: boolean, diff --git a/back/src/Model/Websocket/ExSocketInterface.ts b/back/src/Model/Websocket/ExSocketInterface.ts index bbe18cbb..648bbe21 100644 --- a/back/src/Model/Websocket/ExSocketInterface.ts +++ b/back/src/Model/Websocket/ExSocketInterface.ts @@ -8,7 +8,8 @@ export interface ExSocketInterface extends Socket, Identificable { token: string; roomId: string; webRtcRoomId: string; - userId: string; + userId: number; // A temporary (autoincremented) identifier for this user + userUuid: string; // A unique identifier for this user name: string; characterLayers: string[]; position: PointInterface; diff --git a/back/src/Model/Websocket/GroupUpdateInterface.ts b/back/src/Model/Websocket/GroupUpdateInterface.ts index 45e64ea4..34a6d8b1 100644 --- a/back/src/Model/Websocket/GroupUpdateInterface.ts +++ b/back/src/Model/Websocket/GroupUpdateInterface.ts @@ -2,5 +2,5 @@ import {PositionInterface} from "_Model/PositionInterface"; export interface GroupUpdateInterface { position: PositionInterface, - groupId: string, + groupId: number, } diff --git a/back/src/Model/Websocket/Identificable.ts b/back/src/Model/Websocket/Identificable.ts index 4e3228ae..424d3a76 100644 --- a/back/src/Model/Websocket/Identificable.ts +++ b/back/src/Model/Websocket/Identificable.ts @@ -1,3 +1,3 @@ export interface Identificable { - userId: string; + userId: number; } diff --git a/back/src/Model/Websocket/MessageUserJoined.ts b/back/src/Model/Websocket/MessageUserJoined.ts index 9e993dd3..9ae7ab2c 100644 --- a/back/src/Model/Websocket/MessageUserJoined.ts +++ b/back/src/Model/Websocket/MessageUserJoined.ts @@ -1,6 +1,6 @@ import {PointInterface} from "_Model/Websocket/PointInterface"; export class MessageUserJoined { - constructor(public userId: string, public name: string, public characterLayers: string[], public position: PointInterface) { + constructor(public userId: number, public name: string, public characterLayers: string[], public position: PointInterface) { } } diff --git a/back/src/Model/Websocket/MessageUserMoved.ts b/back/src/Model/Websocket/MessageUserMoved.ts index 283c011d..e08be81b 100644 --- a/back/src/Model/Websocket/MessageUserMoved.ts +++ b/back/src/Model/Websocket/MessageUserMoved.ts @@ -1,6 +1,6 @@ import {PointInterface} from "./PointInterface"; export class MessageUserMoved { - constructor(public userId: string, public position: PointInterface) { + constructor(public userId: number, public position: PointInterface) { } } diff --git a/back/src/Model/Websocket/MessageUserPosition.ts b/back/src/Model/Websocket/MessageUserPosition.ts index 03fc6f09..08035997 100644 --- a/back/src/Model/Websocket/MessageUserPosition.ts +++ b/back/src/Model/Websocket/MessageUserPosition.ts @@ -6,6 +6,6 @@ export class Point implements PointInterface{ } export class MessageUserPosition { - constructor(public userId: string, public name: string, public characterLayers: string[], public position: PointInterface) { + constructor(public userId: number, public name: string, public characterLayers: string[], public position: PointInterface) { } } diff --git a/back/src/Model/Websocket/UserInGroupInterface.ts b/back/src/Model/Websocket/UserInGroupInterface.ts index 26cc5fd4..087f519e 100644 --- a/back/src/Model/Websocket/UserInGroupInterface.ts +++ b/back/src/Model/Websocket/UserInGroupInterface.ts @@ -1,5 +1,5 @@ export interface UserInGroupInterface { - userId: string, + userId: number, name: string, initiator: boolean } diff --git a/back/src/Model/Websocket/UserMovesMessage.ts b/back/src/Model/Websocket/UserMovesMessage.ts deleted file mode 100644 index 2277d4c4..00000000 --- a/back/src/Model/Websocket/UserMovesMessage.ts +++ /dev/null @@ -1,11 +0,0 @@ -import * as tg from "generic-type-guard"; -import {isPointInterface} from "./PointInterface"; -import {isViewport} from "./ViewportMessage"; - - -export const isUserMovesInterface = - new tg.IsInterface().withProperties({ - position: isPointInterface, - viewport: isViewport, - }).get(); -export type UserMovesInterface = tg.GuardedType; diff --git a/back/src/Model/Websocket/WebRtcSignalMessage.ts b/back/src/Model/Websocket/WebRtcSignalMessage.ts index 5a0dd1af..c0f5f8ab 100644 --- a/back/src/Model/Websocket/WebRtcSignalMessage.ts +++ b/back/src/Model/Websocket/WebRtcSignalMessage.ts @@ -7,12 +7,12 @@ export const isSignalData = export const isWebRtcSignalMessageInterface = new tg.IsInterface().withProperties({ - receiverId: tg.isString, + receiverId: tg.isNumber, signal: isSignalData }).get(); export const isWebRtcScreenSharingStartMessageInterface = new tg.IsInterface().withProperties({ - userId: tg.isString, + userId: tg.isNumber, roomId: tg.isString }).get(); export type WebRtcSignalMessageInterface = tg.GuardedType; diff --git a/back/src/Model/World.ts b/back/src/Model/World.ts index 6e739c02..dc3dcd07 100644 --- a/back/src/Model/World.ts +++ b/back/src/Model/World.ts @@ -11,15 +11,15 @@ import {PositionNotifier} from "./PositionNotifier"; import {ViewportInterface} from "_Model/Websocket/ViewportMessage"; import {Movable} from "_Model/Movable"; -export type ConnectCallback = (user: string, group: Group) => void; -export type DisconnectCallback = (user: string, group: Group) => void; +export type ConnectCallback = (user: number, group: Group) => void; +export type DisconnectCallback = (user: number, group: Group) => void; export class World { private readonly minDistance: number; private readonly groupRadius: number; // Users, sorted by ID - private readonly users: Map; + private readonly users: Map; private readonly groups: Set; private readonly connectCallback: ConnectCallback; @@ -37,7 +37,7 @@ export class World { onMoves: MovesCallback, onLeaves: LeavesCallback) { - this.users = new Map(); + this.users = new Map(); this.groups = new Set(); this.connectCallback = connectCallback; this.disconnectCallback = disconnectCallback; @@ -51,7 +51,7 @@ export class World { return Array.from(this.groups.values()); } - public getUsers(): Map { + public getUsers(): Map { return this.users; } diff --git a/back/tests/PositionNotifierTest.ts b/back/tests/PositionNotifierTest.ts index dd1e3b4b..643dd938 100644 --- a/back/tests/PositionNotifierTest.ts +++ b/back/tests/PositionNotifierTest.ts @@ -32,14 +32,14 @@ describe("PositionNotifier", () => { leaveTriggered = true; }); - const user1 = new User("1", { + const user1 = new User(1, { x: 500, y: 500, moving: false, direction: 'down' }, false); - const user2 = new User("2", { + const user2 = new User(2, { x: -9999, y: -9999, moving: false, @@ -110,14 +110,14 @@ describe("PositionNotifier", () => { leaveTriggered = true; }); - const user1 = new User("1", { + const user1 = new User(1, { x: 500, y: 500, moving: false, direction: 'down' }, false); - const user2 = new User("2", { + const user2 = new User(2, { x: -9999, y: -9999, moving: false, diff --git a/back/tests/WorldTest.ts b/back/tests/WorldTest.ts index 63e46928..9afef228 100644 --- a/back/tests/WorldTest.ts +++ b/back/tests/WorldTest.ts @@ -6,55 +6,55 @@ import { Group } from "../src/Model/Group"; describe("World", () => { it("should connect user1 and user2", () => { let connectCalledNumber: number = 0; - const connect: ConnectCallback = (user: string, group: Group): void => { + const connect: ConnectCallback = (user: number, group: Group): void => { connectCalledNumber++; } - const disconnect: DisconnectCallback = (user: string, group: Group): void => { + const disconnect: DisconnectCallback = (user: number, group: Group): void => { } const world = new World(connect, disconnect, 160, 160, () => {}, () => {}, () => {}); - world.join({ userId: "foo" }, new Point(100, 100)); + world.join({ userId: 1 }, new Point(100, 100)); - world.join({ userId: "bar" }, new Point(500, 100)); + world.join({ userId: 2 }, new Point(500, 100)); - world.updatePosition({ userId: "bar" }, new Point(261, 100)); + world.updatePosition({ userId: 2 }, new Point(261, 100)); expect(connectCalledNumber).toBe(0); - world.updatePosition({ userId: "bar" }, new Point(101, 100)); + world.updatePosition({ userId: 2 }, new Point(101, 100)); expect(connectCalledNumber).toBe(2); - world.updatePosition({ userId: "bar" }, new Point(102, 100)); + world.updatePosition({ userId: 2 }, new Point(102, 100)); expect(connectCalledNumber).toBe(2); }); it("should connect 3 users", () => { let connectCalled: boolean = false; - const connect: ConnectCallback = (user: string, group: Group): void => { + const connect: ConnectCallback = (user: number, group: Group): void => { connectCalled = true; } - const disconnect: DisconnectCallback = (user: string, group: Group): void => { + const disconnect: DisconnectCallback = (user: number, group: Group): void => { } const world = new World(connect, disconnect, 160, 160, () => {}, () => {}, () => {}); - world.join({ userId: "foo" }, new Point(100, 100)); + world.join({ userId: 1 }, new Point(100, 100)); - world.join({ userId: "bar" }, new Point(200, 100)); + world.join({ userId: 2 }, new Point(200, 100)); expect(connectCalled).toBe(true); connectCalled = false; // baz joins at the outer limit of the group - world.join({ userId: "baz" }, new Point(311, 100)); + world.join({ userId: 3 }, new Point(311, 100)); expect(connectCalled).toBe(false); - world.updatePosition({ userId: "baz" }, new Point(309, 100)); + world.updatePosition({ userId: 3 }, new Point(309, 100)); expect(connectCalled).toBe(true); }); @@ -62,27 +62,27 @@ describe("World", () => { it("should disconnect user1 and user2", () => { let connectCalled: boolean = false; let disconnectCallNumber: number = 0; - const connect: ConnectCallback = (user: string, group: Group): void => { + const connect: ConnectCallback = (user: number, group: Group): void => { connectCalled = true; } - const disconnect: DisconnectCallback = (user: string, group: Group): void => { + const disconnect: DisconnectCallback = (user: number, group: Group): void => { disconnectCallNumber++; } const world = new World(connect, disconnect, 160, 160, () => {}, () => {}, () => {}); - world.join({ userId: "foo" }, new Point(100, 100)); + world.join({ userId: 1 }, new Point(100, 100)); - world.join({ userId: "bar" }, new Point(259, 100)); + world.join({ userId: 2 }, new Point(259, 100)); expect(connectCalled).toBe(true); expect(disconnectCallNumber).toBe(0); - world.updatePosition({ userId: "bar" }, new Point(100+160+160+1, 100)); + world.updatePosition({ userId: 2 }, new Point(100+160+160+1, 100)); expect(disconnectCallNumber).toBe(2); - world.updatePosition({ userId: "bar" }, new Point(262, 100)); + world.updatePosition({ userId: 2 }, new Point(262, 100)); expect(disconnectCallNumber).toBe(2); }); diff --git a/docker-compose.yaml b/docker-compose.yaml index ce16a31b..fce76204 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -67,7 +67,7 @@ services: - "traefik.http.routers.maps-ssl.service=maps" back: - image: thecodingmachine/workadventure-back-base:latest + image: thecodingmachine/nodejs:12 command: yarn dev #command: yarn run profile environment: @@ -103,3 +103,11 @@ services: - "traefik.http.routers.website-ssl.entryPoints=websecure" - "traefik.http.routers.website-ssl.tls=true" - "traefik.http.routers.website-ssl.service=website" + + messages: + image: thecodingmachine/workadventure-back-base:latest + environment: + STARTUP_COMMAND_1: yarn install + STARTUP_COMMAND_2: yarn run proto:watch + volumes: + - ./messages:/usr/src/app diff --git a/front/src/Connection.ts b/front/src/Connection.ts index 7a60cfba..b6d4c6ee 100644 --- a/front/src/Connection.ts +++ b/front/src/Connection.ts @@ -1,13 +1,19 @@ import Axios from "axios"; import {API_URL} from "./Enum/EnvironmentVariable"; import {MessageUI} from "./Logger/MessageUI"; -import {SetPlayerDetailsMessage} from "../../messages/generated/src/proto/messages_pb" +import { + PositionMessage, + SetPlayerDetailsMessage, + UserMovesMessage, + ViewportMessage +} from "../../messages/generated/messages_pb" const SocketIo = require('socket.io-client'); import Socket = SocketIOClient.Socket; import {PlayerAnimationNames} from "./Phaser/Player/Animation"; import {UserSimplePeerInterface} from "./WebRtc/SimplePeer"; import {SignalData} from "simple-peer"; +import Direction = PositionMessage.Direction; enum EventMessage{ WEBRTC_SIGNAL = "webrtc-signal", @@ -46,19 +52,19 @@ export class Point implements PointInterface{ } export interface MessageUserPositionInterface { - userId: string; + userId: number; name: string; characterLayers: string[]; position: PointInterface; } export interface MessageUserMovedInterface { - userId: string; + userId: number; position: PointInterface; } export interface MessageUserJoined { - userId: string; + userId: number; name: string; characterLayers: string[]; position: PointInterface @@ -80,16 +86,16 @@ export interface WebRtcStartMessageInterface { } export interface WebRtcDisconnectMessageInterface { - userId: string + userId: number } export interface WebRtcSignalSentMessageInterface { - receiverId: string, + receiverId: number, signal: SignalData } export interface WebRtcSignalReceivedMessageInterface { - userId: string, + userId: number, signal: SignalData } @@ -105,11 +111,6 @@ export interface ViewportInterface { bottom: number, } -export interface UserMovesInterface { - position: PositionInterface, - viewport: ViewportInterface, -} - export interface BatchedMessageInterface { event: string, payload: unknown @@ -130,7 +131,7 @@ export interface RoomJoinedMessageInterface { export class Connection implements Connection { private readonly socket: Socket; - private userId: string|null = null; + private userId: number|null = null; private constructor(token: string) { @@ -173,7 +174,7 @@ export class Connection implements Connection { const message = new SetPlayerDetailsMessage(); message.setName(name); message.setCharacterlayersList(characterLayersSelected); - connection.socket.emit(EventMessage.SET_PLAYER_DETAILS, message.serializeBinary().buffer, (id: string) => { + connection.socket.emit(EventMessage.SET_PLAYER_DETAILS, message.serializeBinary().buffer, (id: number) => { connection.userId = id; }); @@ -214,7 +215,40 @@ export class Connection implements Connection { return; } const point = new Point(x, y, direction, moving); - this.socket.emit(EventMessage.USER_POSITION, { position: point, viewport } as UserMovesInterface); + const positionMessage = new PositionMessage(); + positionMessage.setX(Math.floor(x)); + positionMessage.setY(Math.floor(y)); + let directionEnum: PositionMessage.DirectionMap[keyof PositionMessage.DirectionMap]; + switch (direction) { + case 'up': + directionEnum = Direction.UP; + break; + case 'down': + directionEnum = Direction.DOWN; + break; + case 'left': + directionEnum = Direction.LEFT; + break; + case 'right': + directionEnum = Direction.RIGHT; + break; + default: + throw new Error("Unexpected direction"); + } + positionMessage.setDirection(directionEnum); + positionMessage.setMoving(moving); + + const viewportMessage = new ViewportMessage(); + viewportMessage.setLeft(Math.floor(viewport.left)); + viewportMessage.setRight(Math.floor(viewport.right)); + viewportMessage.setTop(Math.floor(viewport.top)); + viewportMessage.setBottom(Math.floor(viewport.bottom)); + + const userMovesMessage = new UserMovesMessage(); + userMovesMessage.setPosition(positionMessage); + userMovesMessage.setViewport(viewportMessage); + + this.socket.emit(EventMessage.USER_POSITION, userMovesMessage.serializeBinary().buffer); } public setSilent(silent: boolean): void { @@ -233,7 +267,7 @@ export class Connection implements Connection { this.socket.on(EventMessage.USER_MOVED, callback); } - public onUserLeft(callback: (userId: string) => void): void { + public onUserLeft(callback: (userId: number) => void): void { this.socket.on(EventMessage.USER_LEFT, callback); } @@ -249,14 +283,14 @@ export class Connection implements Connection { this.socket.on(EventMessage.CONNECT_ERROR, callback) } - public sendWebrtcSignal(signal: unknown, receiverId : string) { + public sendWebrtcSignal(signal: unknown, receiverId: number) { return this.socket.emit(EventMessage.WEBRTC_SIGNAL, { receiverId: receiverId, signal: signal } as WebRtcSignalSentMessageInterface); } - public sendWebrtcScreenSharingSignal(signal: unknown, receiverId : string) { + public sendWebrtcScreenSharingSignal(signal: unknown, receiverId: number) { return this.socket.emit(EventMessage.WEBRTC_SCREEN_SHARING_SIGNAL, { receiverId: receiverId, signal: signal @@ -286,7 +320,7 @@ export class Connection implements Connection { } - public getUserId(): string|null { + public getUserId(): number|null { return this.userId; } diff --git a/front/src/Phaser/Entity/RemotePlayer.ts b/front/src/Phaser/Entity/RemotePlayer.ts index 6764ff59..00a3e4c4 100644 --- a/front/src/Phaser/Entity/RemotePlayer.ts +++ b/front/src/Phaser/Entity/RemotePlayer.ts @@ -6,10 +6,10 @@ import {Character} from "../Entity/Character"; * Class representing the sprite of a remote player (a player that plays on another computer) */ export class RemotePlayer extends Character { - userId: string; + userId: number; constructor( - userId: string, + userId: number, Scene: GameScene, x: number, y: number, diff --git a/front/src/Phaser/Game/AddPlayerInterface.ts b/front/src/Phaser/Game/AddPlayerInterface.ts index a3f50de3..d0ed2dad 100644 --- a/front/src/Phaser/Game/AddPlayerInterface.ts +++ b/front/src/Phaser/Game/AddPlayerInterface.ts @@ -1,7 +1,7 @@ import {PointInterface} from "../../Connection"; export interface AddPlayerInterface { - userId: string; + userId: number; name: string; characterLayers: string[]; position: PointInterface; diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index ad378bc3..7695294e 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -63,7 +63,7 @@ interface AddPlayerEventInterface { interface RemovePlayerEventInterface { type: 'RemovePlayerEvent' - userId: string + userId: number } interface UserMovedEventInterface { @@ -86,7 +86,7 @@ export class GameScene extends Phaser.Scene implements CenterListener { Terrains : Array; CurrentPlayer!: CurrentGamerInterface; MapPlayers!: Phaser.Physics.Arcade.Group; - MapPlayersByKey : Map = new Map(); + MapPlayersByKey : Map = new Map(); Map!: Phaser.Tilemaps.Tilemap; Layers!: Array; Objects!: Array; @@ -217,7 +217,7 @@ export class GameScene extends Phaser.Scene implements CenterListener { this.updatePlayerPosition(message); }); - connection.onUserLeft((userId: string) => { + connection.onUserLeft((userId: number) => { this.removePlayer(userId); }); @@ -271,7 +271,7 @@ export class GameScene extends Phaser.Scene implements CenterListener { self.presentationModeSprite.setVisible(true); self.chatModeSprite.setVisible(true); }, - onDisconnect(userId: string) { + onDisconnect(userId: number) { if (self.simplePeer.getNbConnections() === 0) { self.presentationModeSprite.setVisible(false); self.chatModeSprite.setVisible(false); @@ -918,7 +918,7 @@ export class GameScene extends Phaser.Scene implements CenterListener { // Let's move all users const updatedPlayersPositions = this.playersPositionInterpolator.getUpdatedPositions(time); - updatedPlayersPositions.forEach((moveEvent: HasMovedEvent, userId: string) => { + updatedPlayersPositions.forEach((moveEvent: HasMovedEvent, userId: number) => { const player : RemotePlayer | undefined = this.MapPlayersByKey.get(userId); if (player === undefined) { throw new Error('Cannot find player with ID "' + userId +'"'); @@ -973,7 +973,7 @@ export class GameScene extends Phaser.Scene implements CenterListener { player.destroy(); this.MapPlayers.remove(player); }); - this.MapPlayersByKey = new Map(); + this.MapPlayersByKey = new Map(); // load map usersPosition.forEach((userPosition : MessageUserPositionInterface) => { @@ -1030,14 +1030,14 @@ export class GameScene extends Phaser.Scene implements CenterListener { /** * Called by the connexion when a player is removed from the map */ - public removePlayer(userId: string) { + public removePlayer(userId: number) { this.pendingEvents.enqueue({ type: "RemovePlayerEvent", userId }); } - private doRemovePlayer(userId: string) { + private doRemovePlayer(userId: number) { const player = this.MapPlayersByKey.get(userId); if (player === undefined) { console.error('Cannot find user with id ', userId); diff --git a/front/src/Phaser/Game/PlayersPositionInterpolator.ts b/front/src/Phaser/Game/PlayersPositionInterpolator.ts index 080c8a17..3ac87397 100644 --- a/front/src/Phaser/Game/PlayersPositionInterpolator.ts +++ b/front/src/Phaser/Game/PlayersPositionInterpolator.ts @@ -6,19 +6,19 @@ import {PlayerMovement} from "./PlayerMovement"; import {HasMovedEvent} from "./GameManager"; export class PlayersPositionInterpolator { - playerMovements: Map = new Map(); + playerMovements: Map = new Map(); - updatePlayerPosition(userId: string, playerMovement: PlayerMovement) : void { + updatePlayerPosition(userId: number, playerMovement: PlayerMovement) : void { this.playerMovements.set(userId, playerMovement); } - removePlayer(userId: string): void { + removePlayer(userId: number): void { this.playerMovements.delete(userId); } - getUpdatedPositions(tick: number) : Map { - const positions = new Map(); - this.playerMovements.forEach((playerMovement: PlayerMovement, userId: string) => { + getUpdatedPositions(tick: number) : Map { + const positions = new Map(); + this.playerMovements.forEach((playerMovement: PlayerMovement, userId: number) => { if (playerMovement.isOutdated(tick)) { //console.log("outdated") this.playerMovements.delete(userId); diff --git a/front/src/WebRtc/MediaManager.ts b/front/src/WebRtc/MediaManager.ts index 153d660b..6d8e5c3d 100644 --- a/front/src/WebRtc/MediaManager.ts +++ b/front/src/WebRtc/MediaManager.ts @@ -343,7 +343,7 @@ export class MediaManager { * * @param userId */ - addActiveVideo(userId : string, userName: string = ""){ + addActiveVideo(userId: string, userName: string = ""){ this.webrtcInAudio.play(); userName = userName.toUpperCase(); @@ -368,7 +368,7 @@ export class MediaManager { * * @param userId */ - addScreenSharingActiveVideo(userId : string, divImportance: DivImportance = DivImportance.Important){ + addScreenSharingActiveVideo(userId: string, divImportance: DivImportance = DivImportance.Important){ //this.webrtcInAudio.play(); userId = `screen-sharing-${userId}`; @@ -387,7 +387,7 @@ export class MediaManager { * * @param userId */ - disabledMicrophoneByUserId(userId: string){ + disabledMicrophoneByUserId(userId: number){ const element = document.getElementById(`microphone-${userId}`); if(!element){ return; @@ -399,7 +399,7 @@ export class MediaManager { * * @param userId */ - enabledMicrophoneByUserId(userId: string){ + enabledMicrophoneByUserId(userId: number){ const element = document.getElementById(`microphone-${userId}`); if(!element){ return; @@ -411,7 +411,7 @@ export class MediaManager { * * @param userId */ - disabledVideoByUserId(userId: string) { + disabledVideoByUserId(userId: number) { let element = document.getElementById(`${userId}`); if (element) { element.style.opacity = "0"; @@ -426,7 +426,7 @@ export class MediaManager { * * @param userId */ - enabledVideoByUserId(userId: string){ + enabledVideoByUserId(userId: number){ let element = document.getElementById(`${userId}`); if(element){ element.style.opacity = "1"; @@ -442,7 +442,7 @@ export class MediaManager { * @param userId * @param stream */ - addStreamRemoteVideo(userId : string, stream : MediaStream){ + addStreamRemoteVideo(userId: string, stream : MediaStream){ const remoteVideo = this.remoteVideo.get(userId); if (remoteVideo === undefined) { console.error('Unable to find video for ', userId); @@ -450,7 +450,7 @@ export class MediaManager { } remoteVideo.srcObject = stream; } - addStreamRemoteScreenSharing(userId : string, stream : MediaStream){ + addStreamRemoteScreenSharing(userId: string, stream : MediaStream){ // In the case of screen sharing (going both ways), we may need to create the HTML element if it does not exist yet const remoteVideo = this.remoteVideo.get(`screen-sharing-${userId}`); if (remoteVideo === undefined) { @@ -464,15 +464,15 @@ export class MediaManager { * * @param userId */ - removeActiveVideo(userId : string){ + removeActiveVideo(userId: string){ layoutManager.remove(userId); this.remoteVideo.delete(userId); } - removeActiveScreenSharingVideo(userId : string) { + removeActiveScreenSharingVideo(userId: string) { this.removeActiveVideo(`screen-sharing-${userId}`) } - isConnecting(userId : string): void { + isConnecting(userId: string): void { const connectingSpinnerDiv = this.getSpinner(userId); if (connectingSpinnerDiv === null) { return; @@ -480,7 +480,7 @@ export class MediaManager { connectingSpinnerDiv.style.display = 'block'; } - isConnected(userId : string): void { + isConnected(userId: string): void { const connectingSpinnerDiv = this.getSpinner(userId); if (connectingSpinnerDiv === null) { return; @@ -488,7 +488,7 @@ export class MediaManager { connectingSpinnerDiv.style.display = 'none'; } - isError(userId : string): void { + isError(userId: string): void { console.log("isError", `div-${userId}`); const element = document.getElementById(`div-${userId}`); if(!element){ @@ -500,12 +500,12 @@ export class MediaManager { } errorDiv.style.display = 'block'; } - isErrorScreenSharing(userId : string): void { + isErrorScreenSharing(userId: string): void { this.isError(`screen-sharing-${userId}`); } - private getSpinner(userId : string): HTMLDivElement|null { + private getSpinner(userId: string): HTMLDivElement|null { const element = document.getElementById(`div-${userId}`); if(!element){ return null; diff --git a/front/src/WebRtc/ScreenSharingPeer.ts b/front/src/WebRtc/ScreenSharingPeer.ts index 8857274e..9c2022a6 100644 --- a/front/src/WebRtc/ScreenSharingPeer.ts +++ b/front/src/WebRtc/ScreenSharingPeer.ts @@ -14,7 +14,7 @@ export class ScreenSharingPeer extends Peer { */ private isReceivingStream:boolean = false; - constructor(private userId: string, initiator: boolean, private connection: Connection) { + constructor(private userId: number, initiator: boolean, private connection: Connection) { super({ initiator: initiator ? initiator : false, reconnectTimer: 10000, @@ -52,7 +52,7 @@ export class ScreenSharingPeer extends Peer { if (message.streamEnded !== true) { console.error('Unexpected message on screen sharing peer connection'); } - mediaManager.removeActiveScreenSharingVideo(this.userId); + mediaManager.removeActiveScreenSharingVideo("" + this.userId); }); // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -63,7 +63,7 @@ export class ScreenSharingPeer extends Peer { this.on('connect', () => { // FIXME: we need to put the loader on the screen sharing connection - mediaManager.isConnected(this.userId); + mediaManager.isConnected("" + this.userId); console.info(`connect => ${this.userId}`); }); @@ -86,10 +86,10 @@ export class ScreenSharingPeer extends Peer { //console.log(`ScreenSharingPeer::stream => ${this.userId}`, stream); //console.log(`stream => ${this.userId} => `, stream); if(!stream){ - mediaManager.removeActiveScreenSharingVideo(this.userId); + mediaManager.removeActiveScreenSharingVideo("" + this.userId); this.isReceivingStream = false; } else { - mediaManager.addStreamRemoteScreenSharing(this.userId, stream); + mediaManager.addStreamRemoteScreenSharing("" + this.userId, stream); this.isReceivingStream = true; } } @@ -100,7 +100,7 @@ export class ScreenSharingPeer extends Peer { public destroy(error?: Error): void { try { - mediaManager.removeActiveScreenSharingVideo(this.userId); + mediaManager.removeActiveScreenSharingVideo("" + this.userId); // FIXME: I don't understand why "Closing connection with" message is displayed TWICE before "Nb users in peerConnectionArray" // I do understand the method closeConnection is called twice, but I don't understand how they manage to run in parallel. //console.log('Closing connection with '+userId); diff --git a/front/src/WebRtc/SimplePeer.ts b/front/src/WebRtc/SimplePeer.ts index f388b2ec..ac603756 100644 --- a/front/src/WebRtc/SimplePeer.ts +++ b/front/src/WebRtc/SimplePeer.ts @@ -16,7 +16,7 @@ import {VideoPeer} from "./VideoPeer"; const Peer: SimplePeerNamespace.SimplePeer = require('simple-peer'); export interface UserSimplePeerInterface{ - userId: string; + userId: number; name?: string; initiator?: boolean; } @@ -24,7 +24,7 @@ export interface UserSimplePeerInterface{ export interface PeerConnectionListener { onConnect(user: UserSimplePeerInterface): void; - onDisconnect(userId: string): void; + onDisconnect(userId: number): void; } /** @@ -35,8 +35,8 @@ export class SimplePeer { private WebRtcRoomId: string; private Users: Array = new Array(); - private PeerScreenSharingConnectionArray: Map = new Map(); - private PeerConnectionArray: Map = new Map(); + private PeerScreenSharingConnectionArray: Map = new Map(); + private PeerConnectionArray: Map = new Map(); private readonly sendLocalVideoStreamCallback: UpdatedLocalStreamCallback; private readonly sendLocalScreenSharingStreamCallback: StartScreenSharingCallback; private readonly stopLocalScreenSharingStreamCallback: StopScreenSharingCallback; @@ -140,8 +140,8 @@ export class SimplePeer { } } - mediaManager.removeActiveVideo(user.userId); - mediaManager.addActiveVideo(user.userId, name); + mediaManager.removeActiveVideo("" + user.userId); + mediaManager.addActiveVideo("" + user.userId, name); const peer = new VideoPeer(user.userId, user.initiator ? user.initiator : false, this.Connection); // When a connection is established to a video stream, and if a screen sharing is taking place, @@ -171,8 +171,8 @@ export class SimplePeer { // We should display the screen sharing ONLY if we are not initiator if (!user.initiator) { - mediaManager.removeActiveScreenSharingVideo(user.userId); - mediaManager.addScreenSharingActiveVideo(user.userId); + mediaManager.removeActiveScreenSharingVideo("" + user.userId); + mediaManager.addScreenSharingActiveVideo("" + user.userId); } const peer = new ScreenSharingPeer(user.userId, user.initiator ? user.initiator : false, this.Connection); @@ -189,7 +189,7 @@ export class SimplePeer { * * @param userId */ - private closeConnection(userId : string) { + private closeConnection(userId : number) { try { //mediaManager.removeActiveVideo(userId); const peer = this.PeerConnectionArray.get(userId); @@ -217,9 +217,9 @@ export class SimplePeer { * * @param userId */ - private closeScreenSharingConnection(userId : string) { + private closeScreenSharingConnection(userId : number) { try { - mediaManager.removeActiveScreenSharingVideo(userId); + mediaManager.removeActiveScreenSharingVideo("" + userId); const peer = this.PeerScreenSharingConnectionArray.get(userId); if (peer === undefined) { console.warn("Tried to close connection for user "+userId+" but could not find user") @@ -293,7 +293,7 @@ export class SimplePeer { * * @param userId */ - private pushVideoToRemoteUser(userId : string) { + private pushVideoToRemoteUser(userId : number) { try { const PeerConnection = this.PeerConnectionArray.get(userId); if (!PeerConnection) { @@ -314,7 +314,7 @@ export class SimplePeer { } } - private pushScreenSharingToRemoteUser(userId : string) { + private pushScreenSharingToRemoteUser(userId : number) { const PeerConnection = this.PeerScreenSharingConnectionArray.get(userId); if (!PeerConnection) { throw new Error('While pushing screen sharing, cannot find user with ID ' + userId); @@ -359,7 +359,7 @@ export class SimplePeer { } } - private sendLocalScreenSharingStreamToUser(userId: string): void { + private sendLocalScreenSharingStreamToUser(userId: number): void { // If a connection already exists with user (because it is already sharing a screen with us... let's use this connection) if (this.PeerScreenSharingConnectionArray.has(userId)) { this.pushScreenSharingToRemoteUser(userId); @@ -376,7 +376,7 @@ export class SimplePeer { } } - private stopLocalScreenSharingStreamToUser(userId: string, stream: MediaStream): void { + private stopLocalScreenSharingStreamToUser(userId: number, stream: MediaStream): void { const PeerConnectionScreenSharing = this.PeerScreenSharingConnectionArray.get(userId); if (!PeerConnectionScreenSharing) { throw new Error('Weird, screen sharing connection to user ' + userId + 'not found') diff --git a/front/src/WebRtc/VideoPeer.ts b/front/src/WebRtc/VideoPeer.ts index 33422433..e046ffe2 100644 --- a/front/src/WebRtc/VideoPeer.ts +++ b/front/src/WebRtc/VideoPeer.ts @@ -9,7 +9,7 @@ const Peer: SimplePeerNamespace.SimplePeer = require('simple-peer'); * A peer connection used to transmit video / audio signals between 2 peers. */ export class VideoPeer extends Peer { - constructor(private userId: string, initiator: boolean, private connection: Connection) { + constructor(private userId: number, initiator: boolean, private connection: Connection) { super({ initiator: initiator ? initiator : false, reconnectTimer: 10000, @@ -63,11 +63,11 @@ export class VideoPeer extends Peer { // eslint-disable-next-line @typescript-eslint/no-explicit-any this.on('error', (err: any) => { console.error(`error => ${this.userId} => ${err.code}`, err); - mediaManager.isError(userId); + mediaManager.isError("" + userId); }); this.on('connect', () => { - mediaManager.isConnected(this.userId); + mediaManager.isConnected("" + this.userId); console.info(`connect => ${this.userId}`); }); @@ -108,7 +108,7 @@ export class VideoPeer extends Peer { mediaManager.disabledVideoByUserId(this.userId); mediaManager.disabledMicrophoneByUserId(this.userId); } else { - mediaManager.addStreamRemoteVideo(this.userId, stream); + mediaManager.addStreamRemoteVideo("" + this.userId, stream); } } @@ -117,7 +117,7 @@ export class VideoPeer extends Peer { */ public destroy(error?: Error): void { try { - mediaManager.removeActiveVideo(this.userId); + mediaManager.removeActiveVideo("" + this.userId); // FIXME: I don't understand why "Closing connection with" message is displayed TWICE before "Nb users in peerConnectionArray" // I do understand the method closeConnection is called twice, but I don't understand how they manage to run in parallel. //console.log('Closing connection with '+userId); diff --git a/messages/generated/.gitignore b/messages/generated/.gitignore index 8eba6c8d..d6b7ef32 100644 --- a/messages/generated/.gitignore +++ b/messages/generated/.gitignore @@ -1 +1,2 @@ -src/ +* +!.gitignore diff --git a/messages/generated/src/proto/messages_pb.d.ts b/messages/generated/src/proto/messages_pb.d.ts deleted file mode 100644 index 4c700d90..00000000 --- a/messages/generated/src/proto/messages_pb.d.ts +++ /dev/null @@ -1,31 +0,0 @@ -// package: -// file: src/proto/messages.proto - -import * as jspb from "google-protobuf"; - -export class SetPlayerDetailsMessage extends jspb.Message { - getName(): string; - setName(value: string): void; - - clearCharacterlayersList(): void; - getCharacterlayersList(): Array; - setCharacterlayersList(value: Array): void; - addCharacterlayers(value: string, index?: number): string; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): SetPlayerDetailsMessage.AsObject; - static toObject(includeInstance: boolean, msg: SetPlayerDetailsMessage): SetPlayerDetailsMessage.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: SetPlayerDetailsMessage, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): SetPlayerDetailsMessage; - static deserializeBinaryFromReader(message: SetPlayerDetailsMessage, reader: jspb.BinaryReader): SetPlayerDetailsMessage; -} - -export namespace SetPlayerDetailsMessage { - export type AsObject = { - name: string, - characterlayersList: Array, - } -} - diff --git a/messages/generated/src/proto/messages_pb.js b/messages/generated/src/proto/messages_pb.js deleted file mode 100644 index 27ffc622..00000000 --- a/messages/generated/src/proto/messages_pb.js +++ /dev/null @@ -1,223 +0,0 @@ -// source: src/proto/messages.proto -/** - * @fileoverview - * @enhanceable - * @suppress {messageConventions} JS Compiler reports an error if a variable or - * field starts with 'MSG_' and isn't a translatable message. - * @public - */ -// GENERATED CODE -- DO NOT EDIT! - -var jspb = require('google-protobuf'); -var goog = jspb; -var global = Function('return this')(); - -goog.exportSymbol('proto.SetPlayerDetailsMessage', null, global); -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.SetPlayerDetailsMessage = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, proto.SetPlayerDetailsMessage.repeatedFields_, null); -}; -goog.inherits(proto.SetPlayerDetailsMessage, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.SetPlayerDetailsMessage.displayName = 'proto.SetPlayerDetailsMessage'; -} - -/** - * List of repeated fields within this message type. - * @private {!Array} - * @const - */ -proto.SetPlayerDetailsMessage.repeatedFields_ = [2]; - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.SetPlayerDetailsMessage.prototype.toObject = function(opt_includeInstance) { - return proto.SetPlayerDetailsMessage.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.SetPlayerDetailsMessage} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.SetPlayerDetailsMessage.toObject = function(includeInstance, msg) { - var f, obj = { - name: jspb.Message.getFieldWithDefault(msg, 1, ""), - characterlayersList: (f = jspb.Message.getRepeatedField(msg, 2)) == null ? undefined : f - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.SetPlayerDetailsMessage} - */ -proto.SetPlayerDetailsMessage.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.SetPlayerDetailsMessage; - return proto.SetPlayerDetailsMessage.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.SetPlayerDetailsMessage} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.SetPlayerDetailsMessage} - */ -proto.SetPlayerDetailsMessage.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {string} */ (reader.readString()); - msg.setName(value); - break; - case 2: - var value = /** @type {string} */ (reader.readString()); - msg.addCharacterlayers(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.SetPlayerDetailsMessage.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.SetPlayerDetailsMessage.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.SetPlayerDetailsMessage} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.SetPlayerDetailsMessage.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getName(); - if (f.length > 0) { - writer.writeString( - 1, - f - ); - } - f = message.getCharacterlayersList(); - if (f.length > 0) { - writer.writeRepeatedString( - 2, - f - ); - } -}; - - -/** - * optional string name = 1; - * @return {string} - */ -proto.SetPlayerDetailsMessage.prototype.getName = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * @param {string} value - * @return {!proto.SetPlayerDetailsMessage} returns this - */ -proto.SetPlayerDetailsMessage.prototype.setName = function(value) { - return jspb.Message.setProto3StringField(this, 1, value); -}; - - -/** - * repeated string characterLayers = 2; - * @return {!Array} - */ -proto.SetPlayerDetailsMessage.prototype.getCharacterlayersList = function() { - return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 2)); -}; - - -/** - * @param {!Array} value - * @return {!proto.SetPlayerDetailsMessage} returns this - */ -proto.SetPlayerDetailsMessage.prototype.setCharacterlayersList = function(value) { - return jspb.Message.setField(this, 2, value || []); -}; - - -/** - * @param {string} value - * @param {number=} opt_index - * @return {!proto.SetPlayerDetailsMessage} returns this - */ -proto.SetPlayerDetailsMessage.prototype.addCharacterlayers = function(value, opt_index) { - return jspb.Message.addToRepeatedField(this, 2, value, opt_index); -}; - - -/** - * Clears the list making it empty but non-null. - * @return {!proto.SetPlayerDetailsMessage} returns this - */ -proto.SetPlayerDetailsMessage.prototype.clearCharacterlayersList = function() { - return this.setCharacterlayersList([]); -}; - - -goog.object.extend(exports, proto); diff --git a/messages/messages.proto b/messages/messages.proto index ea9fafe2..cc0449e9 100644 --- a/messages/messages.proto +++ b/messages/messages.proto @@ -1,6 +1,41 @@ syntax = "proto3"; +/*********** CLIENT TO SERVER MESSAGES *************/ + message SetPlayerDetailsMessage { string name = 1; repeated string characterLayers = 2; } + +message PositionMessage { + int32 x = 1; + int32 y = 2; + enum Direction { + UP = 0; + RIGHT = 1; + DOWN = 2; + LEFT = 3; + } + Direction direction = 3; + bool moving = 4; +} + +message ViewportMessage { + int32 left = 1; + int32 top = 2; + int32 right = 3; + int32 bottom = 4; +} + +message UserMovesMessage { + PositionMessage position = 1; + ViewportMessage viewport = 2; +} + + +/*********** SERVER TO CLIENT MESSAGES *************/ + +message UserMovedMessage { + int32 userId = 1; + PositionMessage position = 2; +} diff --git a/messages/package.json b/messages/package.json index e2548499..b70d4900 100644 --- a/messages/package.json +++ b/messages/package.json @@ -4,8 +4,8 @@ "description": "", "main": "generated/src/proto/messages_pb.js", "scripts": { - "proto": "protoc --plugin=\"protoc-gen-ts=./node_modules/.bin/protoc-gen-ts\" --js_out=\"import_style=commonjs,binary:src/messages/generated\" --ts_out=\"src/messages/generated\" src/messages/messages.proto", - "proto:watch": "inotifywait -q -m -e close_write src/messages/messages.proto | while read -r filename event; do yarn run proto; done" + "proto": "protoc --plugin=\"protoc-gen-ts=./node_modules/.bin/protoc-gen-ts\" --js_out=\"import_style=commonjs,binary:generated\" --ts_out=\"generated\" messages.proto", + "proto:watch": "inotifywait -q -m -e close_write messages.proto | while read -r filename event; do yarn run proto; done" }, "repository": { "type": "git", From 3a17795ad33bdbcc95d1b420ff179a560f60c2f5 Mon Sep 17 00:00:00 2001 From: arp Date: Fri, 18 Sep 2020 15:48:30 +0200 Subject: [PATCH 023/122] added basic token auth --- back/src/Controller/AdminController.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/back/src/Controller/AdminController.ts b/back/src/Controller/AdminController.ts index d6f1d23d..7c20498f 100644 --- a/back/src/Controller/AdminController.ts +++ b/back/src/Controller/AdminController.ts @@ -1,6 +1,6 @@ import {Application, Request, Response} from "express"; import {OK} from "http-status-codes"; -import {ADMIN_API_URL} from "../Enum/EnvironmentVariable"; +import {ADMIN_API_TOKEN, ADMIN_API_URL} from "../Enum/EnvironmentVariable"; import Axios, {AxiosError} from "axios"; export class AdminController { @@ -19,14 +19,12 @@ export class AdminController { } const token:string = req.params.token; - //todo add ADMIN_API_TOKEN authorization let response = null try { - console.log(ADMIN_API_URL+'/api/login-url/'+token); - response = await Axios.get(ADMIN_API_URL+'/api/login-url/'+token) + response = await Axios.get(ADMIN_API_URL+'/api/login-url/'+token, { headers: {"Authorization" : `${ADMIN_API_TOKEN}`} }) } catch (e) { console.log(e.message) - return res.status(500).send('An error happened'); + return res.status(e.status || 500).send('An error happened'); } const teamSlug = response.data.teamSlug; From df0636c51369b1f005d8f0c2acc74f85ba7c9256 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Fri, 18 Sep 2020 15:51:15 +0200 Subject: [PATCH 024/122] Migrating user position messages to protobuf --- back/src/Controller/IoSocketController.ts | 32 ++++++++++---- back/src/Model/Websocket/ExSocketInterface.ts | 5 ++- back/src/Model/Websocket/MessageUserMoved.ts | 6 --- back/src/Model/Websocket/ProtobufUtils.ts | 35 +++++++++++++++ benchmark/socketio-load-test.yaml | 18 ++------ benchmark/socketioLoadTest.js | 33 ++++++++++++++ front/src/Connection.ts | 43 ++++++++++++++++--- front/src/Network/ProtobufClientUtils.ts | 34 +++++++++++++++ front/src/Phaser/Game/GameScene.ts | 17 +++++++- messages/messages.proto | 25 ++++++++--- 10 files changed, 202 insertions(+), 46 deletions(-) delete mode 100644 back/src/Model/Websocket/MessageUserMoved.ts create mode 100644 back/src/Model/Websocket/ProtobufUtils.ts create mode 100644 front/src/Network/ProtobufClientUtils.ts diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index a2732fb8..f3eab483 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -10,7 +10,6 @@ import {Group} from "../Model/Group"; import {User} from "../Model/User"; import {isSetPlayerDetailsMessage,} from "../Model/Websocket/SetPlayerDetailsMessage"; import {MessageUserJoined} from "../Model/Websocket/MessageUserJoined"; -import {MessageUserMoved} from "../Model/Websocket/MessageUserMoved"; import si from "systeminformation"; import {Gauge} from "prom-client"; import {TokenInterface} from "../Controller/AuthenticateController"; @@ -23,9 +22,17 @@ import {uuid} from 'uuidv4'; import {isViewport} from "../Model/Websocket/ViewportMessage"; import {GroupUpdateInterface} from "_Model/Websocket/GroupUpdateInterface"; import {Movable} from "../Model/Movable"; -import {PositionMessage, SetPlayerDetailsMessage} from "../../../messages/generated/messages_pb"; +import { + PositionMessage, + SetPlayerDetailsMessage, + SubMessage, + UserMovedMessage, + BatchMessage +} from "../../../messages/generated/messages_pb"; import {UserMovesMessage} from "../../../messages/generated/messages_pb"; import Direction = PositionMessage.Direction; +import {ProtobufUtils} from "../Model/Websocket/ProtobufUtils"; +import toPositionMessage = ProtobufUtils.toPositionMessage; enum SocketIoEvent { CONNECTION = "connection", @@ -48,13 +55,13 @@ enum SocketIoEvent { BATCH = "batch", } -function emitInBatch(socket: ExSocketInterface, event: string | symbol, payload: unknown): void { - socket.batchedMessages.push({ event, payload}); +function emitInBatch(socket: ExSocketInterface, event: string, payload: SubMessage): void { + socket.batchedMessages.addPayload(payload); if (socket.batchTimeout === null) { socket.batchTimeout = setTimeout(() => { - socket.emit(SocketIoEvent.BATCH, socket.batchedMessages); - socket.batchedMessages = []; + socket.binary(true).emit(SocketIoEvent.BATCH, socket.batchedMessages.serializeBinary().buffer); + socket.batchedMessages = new BatchMessage(); socket.batchTimeout = null; }, 100); } @@ -159,9 +166,9 @@ export class IoSocketController { ioConnection() { this.Io.on(SocketIoEvent.CONNECTION, (socket: Socket) => { const client : ExSocketInterface = socket as ExSocketInterface; - client.batchedMessages = []; + client.batchedMessages = new BatchMessage(); client.batchTimeout = null; - client.emitInBatch = (event: string | symbol, payload: unknown): void => { + client.emitInBatch = (event: string, payload: SubMessage): void => { emitInBatch(client, event, payload); } this.sockets.set(client.userId, client); @@ -538,7 +545,14 @@ export class IoSocketController { if (thing instanceof User) { const clientUser = this.searchClientByIdOrFail(thing.id); - clientListener.emitInBatch(SocketIoEvent.USER_MOVED, new MessageUserMoved(clientUser.userId, clientUser.position)); + const userMovedMessage = new UserMovedMessage(); + userMovedMessage.setUserid(clientUser.userId); + userMovedMessage.setPosition(toPositionMessage(clientUser.position)); + + const subMessage = new SubMessage(); + subMessage.setUsermovedmessage(userMovedMessage); + + clientListener.emitInBatch(SocketIoEvent.USER_MOVED, subMessage); //console.log("Sending USER_MOVED event"); } else if (thing instanceof Group) { clientListener.emit(SocketIoEvent.GROUP_CREATE_UPDATE, { diff --git a/back/src/Model/Websocket/ExSocketInterface.ts b/back/src/Model/Websocket/ExSocketInterface.ts index 648bbe21..d7edf554 100644 --- a/back/src/Model/Websocket/ExSocketInterface.ts +++ b/back/src/Model/Websocket/ExSocketInterface.ts @@ -3,6 +3,7 @@ import {PointInterface} from "./PointInterface"; import {Identificable} from "./Identificable"; import {TokenInterface} from "../../Controller/AuthenticateController"; import {ViewportInterface} from "_Model/Websocket/ViewportMessage"; +import {BatchMessage, SubMessage} from "../../../../messages/generated/messages_pb"; export interface ExSocketInterface extends Socket, Identificable { token: string; @@ -18,7 +19,7 @@ export interface ExSocketInterface extends Socket, Identificable { /** * Pushes an event that will be sent in the next batch of events */ - emitInBatch: (event: string | symbol, payload: unknown) => void; - batchedMessages: Array<{ event: string | symbol, payload: unknown }>; + emitInBatch: (event: string, payload: SubMessage) => void; + batchedMessages: BatchMessage; batchTimeout: NodeJS.Timeout|null; } diff --git a/back/src/Model/Websocket/MessageUserMoved.ts b/back/src/Model/Websocket/MessageUserMoved.ts deleted file mode 100644 index e08be81b..00000000 --- a/back/src/Model/Websocket/MessageUserMoved.ts +++ /dev/null @@ -1,6 +0,0 @@ -import {PointInterface} from "./PointInterface"; - -export class MessageUserMoved { - constructor(public userId: number, public position: PointInterface) { - } -} diff --git a/back/src/Model/Websocket/ProtobufUtils.ts b/back/src/Model/Websocket/ProtobufUtils.ts new file mode 100644 index 00000000..ff73b7c0 --- /dev/null +++ b/back/src/Model/Websocket/ProtobufUtils.ts @@ -0,0 +1,35 @@ +import {PointInterface} from "./PointInterface"; +import {PositionMessage} from "../../../../messages/generated/messages_pb"; +import {ExSocketInterface} from "_Model/Websocket/ExSocketInterface"; + +export namespace ProtobufUtils { + import Direction = PositionMessage.Direction; + + export function toPositionMessage(point: PointInterface): PositionMessage { + let direction: PositionMessage.DirectionMap[keyof PositionMessage.DirectionMap]; + switch (point.direction) { + case 'up': + direction = Direction.UP; + break; + case 'down': + direction = Direction.DOWN; + break; + case 'left': + direction = Direction.LEFT; + break; + case 'right': + direction = Direction.RIGHT; + break; + default: + throw new Error('unexpected direction'); + } + + const position = new PositionMessage(); + position.setX(point.x); + position.setY(point.y); + position.setMoving(point.moving); + position.setDirection(direction); + + return position; + } +} diff --git a/benchmark/socketio-load-test.yaml b/benchmark/socketio-load-test.yaml index df2f580b..81c7e55e 100644 --- a/benchmark/socketio-load-test.yaml +++ b/benchmark/socketio-load-test.yaml @@ -6,7 +6,7 @@ config: token: "test" phases: - duration: 20 - arrivalRate: 2 + arrivalRate: 3 processor: "./socketioLoadTest.js" scenarios: - name: "Connects and moves player for 20 seconds" @@ -22,7 +22,7 @@ scenarios: - emit: channel: "join-room" data: - roomId: 'global__api.workadventure.localhost/map/files/Floor0/floor0' + roomId: 'global__maps.workadventure.localhost/Floor0/floor0' position: x: 783 y: 170 @@ -35,20 +35,10 @@ scenarios: bottom: 200 - think: 1 - loop: - - function: "setYRandom" + - function: "setUserMovesMessage" - emit: channel: "user-position" - data: - position: - x: "{{ x }}" - y: "{{ y }}" - direction: 'down' - moving: false - viewport: - left: "{{ left }}" - top: "{{ top }}" - right: "{{ right }}" - bottom: "{{ bottom }}" + data: "{{ message }}" - think: 0.2 count: 100 - think: 10 diff --git a/benchmark/socketioLoadTest.js b/benchmark/socketioLoadTest.js index f898d7b9..3f01bab6 100644 --- a/benchmark/socketioLoadTest.js +++ b/benchmark/socketioLoadTest.js @@ -1,5 +1,8 @@ 'use strict'; +require("../messages/generated/messages_pb"); +//import {PositionMessage, UserMovesMessage, ViewportMessage} from "../messages/generated/messages_pb"; + module.exports = { setYRandom }; @@ -18,3 +21,33 @@ function setYRandom(context, events, done) { context.vars.bottom = context.vars.y + 200; return done(); } + +function setUserMovesMessage(context, events, done) { + if (context.angle === undefined) { + context.angle = Math.random() * Math.PI * 2; + } + context.angle += 0.05; + + const x = Math.floor(320 + 1472/2 * (1 + Math.sin(context.angle))); + const y = Math.floor(200 + 1090/2 * (1 + Math.cos(context.angle))); + + const positionMessage = new PositionMessage(); + positionMessage.setX(x); + positionMessage.setY(y); + positionMessage.setDirection(PositionMessage.Direction.UP); + positionMessage.setMoving(false); + + const viewportMessage = new ViewportMessage(); + viewportMessage.setTop(y - 200); + viewportMessage.setBottom(y + 200); + viewportMessage.setLeft(x - 320); + viewportMessage.setRight(x + 320); + + const userMovesMessage = new UserMovesMessage(); + userMovesMessage.setPosition(positionMessage); + userMovesMessage.setViewport(viewportMessage); + + context.vars.message = userMovesMessage.serializeBinary().buffer; + console.log(context.vars.message); + return done(); +} diff --git a/front/src/Connection.ts b/front/src/Connection.ts index b6d4c6ee..78f107fe 100644 --- a/front/src/Connection.ts +++ b/front/src/Connection.ts @@ -2,8 +2,9 @@ import Axios from "axios"; import {API_URL} from "./Enum/EnvironmentVariable"; import {MessageUI} from "./Logger/MessageUI"; import { + BatchMessage, PositionMessage, - SetPlayerDetailsMessage, + SetPlayerDetailsMessage, UserMovedMessage, UserMovesMessage, ViewportMessage } from "../../messages/generated/messages_pb" @@ -132,6 +133,7 @@ export interface RoomJoinedMessageInterface { export class Connection implements Connection { private readonly socket: Socket; private userId: number|null = null; + private batchCallbacks: Map = new Map(); private constructor(token: string) { @@ -149,11 +151,25 @@ export class Connection implements Connection { /** * Messages inside batched messages are extracted and sent to listeners directly. */ - this.socket.on(EventMessage.BATCH, (batchedMessages: BatchedMessageInterface[]) => { - for (const message of batchedMessages) { - const listeners = this.socket.listeners(message.event); + this.socket.on(EventMessage.BATCH, (batchedMessagesBinary: ArrayBuffer) => { + const batchMessage = BatchMessage.deserializeBinary(new Uint8Array(batchedMessagesBinary as ArrayBuffer)); + + for (const message of batchMessage.getPayloadList()) { + let event: string; + let payload; + if (message.hasUsermovedmessage()) { + event = EventMessage.USER_MOVED; + payload = message.getUsermovedmessage(); + } else { + throw new Error('Unexpected batch message type'); + } + + const listeners = this.batchCallbacks.get(event); + if (listeners === undefined) { + continue; + } for (const listener of listeners) { - listener(message.payload); + listener(payload); } } }) @@ -263,8 +279,21 @@ export class Connection implements Connection { this.socket.on(EventMessage.JOIN_ROOM, callback); } - public onUserMoved(callback: (message: MessageUserMovedInterface) => void): void { - this.socket.on(EventMessage.USER_MOVED, callback); + public onUserMoved(callback: (message: UserMovedMessage) => void): void { + this.onBatchMessage(EventMessage.USER_MOVED, callback); + //this.socket.on(EventMessage.USER_MOVED, callback); + } + + /** + * Registers a listener on a message that is part of a batch + */ + private onBatchMessage(eventName: string, callback: Function): void { + let callbacks = this.batchCallbacks.get(eventName); + if (callbacks === undefined) { + callbacks = new Array(); + this.batchCallbacks.set(eventName, callbacks); + } + callbacks.push(callback); } public onUserLeft(callback: (userId: number) => void): void { diff --git a/front/src/Network/ProtobufClientUtils.ts b/front/src/Network/ProtobufClientUtils.ts new file mode 100644 index 00000000..311ba80d --- /dev/null +++ b/front/src/Network/ProtobufClientUtils.ts @@ -0,0 +1,34 @@ +import {PositionMessage} from "../../../messages/generated/messages_pb"; +import {PointInterface} from "../Connection"; + +export namespace ProtobufClientUtils { + import Direction = PositionMessage.Direction; + + export function toPointInterface(position: PositionMessage): PointInterface { + let direction: string; + switch (position.getDirection()) { + case Direction.UP: + direction = 'up'; + break; + case Direction.DOWN: + direction = 'down'; + break; + case Direction.LEFT: + direction = 'left'; + break; + case Direction.RIGHT: + direction = 'right'; + break; + default: + throw new Error("Unexpected direction"); + } + + // sending to all clients in room except sender + return { + x: position.getX(), + y: position.getY(), + direction, + moving: position.getMoving(), + }; + } +} diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 7695294e..bf73b31d 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -40,6 +40,9 @@ import {FourOFourSceneName} from "../Reconnecting/FourOFourScene"; import {ItemFactoryInterface} from "../Items/ItemFactoryInterface"; import {ActionableItem} from "../Items/ActionableItem"; import {UserInputManager} from "../UserInput/UserInputManager"; +import {UserMovedMessage} from "../../../../messages/generated/messages_pb"; +import {ProtobufClientUtils} from "../../Network/ProtobufClientUtils"; +import toPointInterface = ProtobufClientUtils.toPointInterface; export enum Textures { @@ -213,8 +216,18 @@ export class GameScene extends Phaser.Scene implements CenterListener { this.addPlayer(userMessage); }); - connection.onUserMoved((message: MessageUserMovedInterface) => { - this.updatePlayerPosition(message); + connection.onUserMoved((message: UserMovedMessage) => { + const position = message.getPosition(); + if (position === undefined) { + throw new Error('Position missing from UserMovedMessage'); + } + + const messageUserMoved: MessageUserMovedInterface = { + userId: message.getUserid(), + position: toPointInterface(position) + } + + this.updatePlayerPosition(messageUserMoved); }); connection.onUserLeft((userId: number) => { diff --git a/messages/messages.proto b/messages/messages.proto index cc0449e9..7d8cb0a8 100644 --- a/messages/messages.proto +++ b/messages/messages.proto @@ -1,11 +1,6 @@ syntax = "proto3"; -/*********** CLIENT TO SERVER MESSAGES *************/ - -message SetPlayerDetailsMessage { - string name = 1; - repeated string characterLayers = 2; -} +/*********** PARTIAL MESSAGES **************/ message PositionMessage { int32 x = 1; @@ -27,6 +22,13 @@ message ViewportMessage { int32 bottom = 4; } +/*********** CLIENT TO SERVER MESSAGES *************/ + +message SetPlayerDetailsMessage { + string name = 1; + repeated string characterLayers = 2; +} + message UserMovesMessage { PositionMessage position = 1; ViewportMessage viewport = 2; @@ -39,3 +41,14 @@ message UserMovedMessage { int32 userId = 1; PositionMessage position = 2; } + +message SubMessage { + oneof message { + UserMovedMessage userMovedMessage = 1; + } +} + +message BatchMessage { + string event = 1; + repeated SubMessage payload = 2; +} From 28dc3a2c8407266e7d41721cfff88a4a13fe4420 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Fri, 18 Sep 2020 16:05:52 +0200 Subject: [PATCH 025/122] Removing protobuf packages from back --- back/package.json | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/back/package.json b/back/package.json index e9a4d4fc..9bec3c03 100644 --- a/back/package.json +++ b/back/package.json @@ -5,14 +5,12 @@ "main": "index.js", "scripts": { "tsc": "tsc", - "dev": "concurrently \"yarn run proto:watch\" \"ts-node-dev --respawn --transpileOnly ./server.ts\"", + "dev": "ts-node-dev --respawn --transpileOnly ./server.ts", "prod": "tsc && node ./dist/server.js", "profile": "tsc && node --prof ./dist/server.js", "test": "ts-node node_modules/jasmine/bin/jasmine --config=jasmine.json", "lint": "node_modules/.bin/eslint src/ . --ext .ts", "fix": "node_modules/.bin/eslint --fix src/ . --ext .ts", - "proto": "protoc --plugin=\"protoc-gen-ts=./node_modules/.bin/protoc-gen-ts\" --js_out=\"import_style=commonjs,binary:src/messages/generated\" --ts_out=\"src/messages/generated\" src/messages/messages.proto", - "proto:watch": "inotifywait -q -m -e close_write src/messages/messages.proto | while read -r filename event; do yarn run proto; done" }, "repository": { "type": "git", @@ -38,11 +36,6 @@ }, "homepage": "https://github.com/thecodingmachine/workadventure#readme", "dependencies": { - "@types/express": "^4.17.4", - "@types/http-status-codes": "^1.2.0", - "@types/jsonwebtoken": "^8.3.8", - "@types/socket.io": "^2.1.4", - "@types/uuidv4": "^5.0.0", "body-parser": "^1.19.0", "express": "^4.17.1", "generic-type-guard": "^3.2.0", @@ -56,13 +49,15 @@ "uuidv4": "^6.0.7" }, "devDependencies": { - "@types/google-protobuf": "^3.7.3", + "@types/express": "^4.17.4", + "@types/http-status-codes": "^1.2.0", "@types/jasmine": "^3.5.10", + "@types/jsonwebtoken": "^8.3.8", + "@types/socket.io": "^2.1.4", + "@types/uuidv4": "^5.0.0", "@typescript-eslint/eslint-plugin": "^2.26.0", "@typescript-eslint/parser": "^2.26.0", - "concurrently": "^5.3.0", "eslint": "^6.8.0", "jasmine": "^3.5.0", - "ts-protoc-gen": "^0.13.0" } } From 32f92d5c455228fd1efc13ad741686d2f34d73fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Fri, 18 Sep 2020 17:01:45 +0200 Subject: [PATCH 026/122] Switching test loading from Artillery to home-grown test --- back/package.json | 4 +- back/yarn.lock | 211 +-------- benchmark/artillery_multi_core.sh | 17 - benchmark/benchmark_multi_core.sh | 15 + benchmark/index.ts | 48 +++ benchmark/package.json | 10 +- benchmark/yarn.lock | 693 ++++++++++++++++++++++++++++++ 7 files changed, 771 insertions(+), 227 deletions(-) delete mode 100755 benchmark/artillery_multi_core.sh create mode 100755 benchmark/benchmark_multi_core.sh create mode 100644 benchmark/index.ts create mode 100644 benchmark/yarn.lock diff --git a/back/package.json b/back/package.json index 9bec3c03..3306578a 100644 --- a/back/package.json +++ b/back/package.json @@ -10,7 +10,7 @@ "profile": "tsc && node --prof ./dist/server.js", "test": "ts-node node_modules/jasmine/bin/jasmine --config=jasmine.json", "lint": "node_modules/.bin/eslint src/ . --ext .ts", - "fix": "node_modules/.bin/eslint --fix src/ . --ext .ts", + "fix": "node_modules/.bin/eslint --fix src/ . --ext .ts" }, "repository": { "type": "git", @@ -58,6 +58,6 @@ "@typescript-eslint/eslint-plugin": "^2.26.0", "@typescript-eslint/parser": "^2.26.0", "eslint": "^6.8.0", - "jasmine": "^3.5.0", + "jasmine": "^3.5.0" } } diff --git a/back/yarn.lock b/back/yarn.lock index a3269cb5..f660a5c8 100644 --- a/back/yarn.lock +++ b/back/yarn.lock @@ -57,11 +57,6 @@ "@types/qs" "*" "@types/serve-static" "*" -"@types/google-protobuf@^3.7.3": - version "3.7.3" - resolved "https://registry.yarnpkg.com/@types/google-protobuf/-/google-protobuf-3.7.3.tgz#429512e541bbd777f2c867692e6335ee08d1f6d4" - integrity sha512-FRwj40euE2bYkG+0X5w2nEA8yAzgJRcEa7RBd0Gsdkb9/tPM2pctVVAvnOUTbcXo2VmIHPo0Ae94Gl9vRHfKzg== - "@types/http-status-codes@^1.2.0": version "1.2.0" resolved "https://registry.yarnpkg.com/@types/http-status-codes/-/http-status-codes-1.2.0.tgz#6e5244835aaf7164dd306f1d4d2dfdbb2159d909" @@ -333,12 +328,7 @@ camelcase@^2.0.0: version "2.1.1" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-2.1.1.tgz#7c1d16d679a1bbe59ca02cacecfb011e201f5a1f" -camelcase@^5.0.0: - version "5.3.1" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" - integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== - -chalk@^2.0.0, chalk@^2.1.0, chalk@^2.4.2: +chalk@^2.0.0, chalk@^2.1.0: version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" dependencies: @@ -367,15 +357,6 @@ cli-width@^2.0.0: version "2.2.0" resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639" -cliui@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-5.0.0.tgz#deefcfdb2e800784aa34f46fa08e06851c7bbbc5" - integrity sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA== - dependencies: - string-width "^3.1.0" - strip-ansi "^5.2.0" - wrap-ansi "^5.1.0" - color-convert@^1.9.0: version "1.9.3" resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" @@ -412,21 +393,6 @@ concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" -concurrently@^5.3.0: - version "5.3.0" - resolved "https://registry.yarnpkg.com/concurrently/-/concurrently-5.3.0.tgz#7500de6410d043c912b2da27de3202cb489b1e7b" - integrity sha512-8MhqOB6PWlBfA2vJ8a0bSFKATOdWlHiQlk11IfmQBPaHVP8oP2gsh2MObE6UR3hqDHqvaIvLTyceNW6obVuFHQ== - dependencies: - chalk "^2.4.2" - date-fns "^2.0.1" - lodash "^4.17.15" - read-pkg "^4.0.1" - rxjs "^6.5.2" - spawn-command "^0.0.2-1" - supports-color "^6.1.0" - tree-kill "^1.2.2" - yargs "^13.3.0" - content-disposition@0.5.3: version "0.5.3" resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.3.tgz#e130caf7e7279087c5616c2007d0485698984fbd" @@ -465,11 +431,6 @@ currently-unhandled@^0.4.1: dependencies: array-find-index "^1.0.1" -date-fns@^2.0.1: - version "2.16.1" - resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.16.1.tgz#05775792c3f3331da812af253e1a935851d3834b" - integrity sha512-sAJVKx/FqrLYHAQeN7VpJrPhagZc9R4ImZIWYRFZaaohR3KzmuK88touwsSwSVT8Qcbd4zoDsnGfX4GFB4imyQ== - dateformat@~1.0.4-1.2.3: version "1.0.12" resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-1.0.12.tgz#9f124b67594c937ff706932e4a642cca8dbbfee9" @@ -499,7 +460,7 @@ debug@~3.1.0: dependencies: ms "2.0.0" -decamelize@^1.1.2, decamelize@^1.2.0: +decamelize@^1.1.2: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" @@ -590,7 +551,7 @@ engine.io@~3.4.0: engine.io-parser "~2.2.0" ws "^7.1.2" -error-ex@^1.2.0, error-ex@^1.3.1: +error-ex@^1.2.0: version "1.3.2" resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" dependencies: @@ -801,13 +762,6 @@ find-up@^1.0.0: path-exists "^2.0.0" pinkie-promise "^2.0.0" -find-up@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/find-up/-/find-up-3.0.0.tgz#49169f1d7993430646da61ecc5ae355c21c97b73" - integrity sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg== - dependencies: - locate-path "^3.0.0" - flat-cache@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-2.0.1.tgz#5d296d6f04bda44a4630a301413bdbc2ec085ec0" @@ -841,11 +795,6 @@ generic-type-guard@^3.2.0: resolved "https://registry.yarnpkg.com/generic-type-guard/-/generic-type-guard-3.2.0.tgz#1fb136f934730c776486526b8a21fe96b067e691" integrity sha512-EkkrXYbOtJ3VPB+SOrU7EhwY65rZErItGtBg5wAqywaj07BOubwOZqMYaxOWekJ9akioGqXIsw1fYk3wwbWsDQ== -get-caller-file@^2.0.1: - version "2.0.5" - resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" - integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== - get-stdin@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe" @@ -873,11 +822,6 @@ globals@^12.1.0: dependencies: type-fest "^0.8.1" -google-protobuf@^3.6.1: - version "3.13.0" - resolved "https://registry.yarnpkg.com/google-protobuf/-/google-protobuf-3.13.0.tgz#909c5983d75dd6101ed57c79e0528d000cdc3251" - integrity sha512-ZIf3qfLFayVrPvAjeKKxO5FRF1/NwRxt6Dko+fWEMuHwHbZx8/fcaAao9b0wCM6kr8qeg2te8XTpyuvKuD9aKw== - graceful-fs@^4.1.2: version "4.2.3" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.3.tgz#4a12ff1b60376ef09862c2093edd908328be8423" @@ -1068,11 +1012,6 @@ js-yaml@^3.13.1: argparse "^1.0.7" esprima "^4.0.0" -json-parse-better-errors@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9" - integrity sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw== - json-schema-traverse@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" @@ -1128,14 +1067,6 @@ load-json-file@^1.0.0: pinkie-promise "^2.0.0" strip-bom "^2.0.0" -locate-path@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e" - integrity sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A== - dependencies: - p-locate "^3.0.0" - path-exists "^3.0.0" - lodash.includes@^4.3.0: version "4.3.0" resolved "https://registry.yarnpkg.com/lodash.includes/-/lodash.includes-4.3.0.tgz#60bb98a87cb923c68ca1e51325483314849f553f" @@ -1332,25 +1263,6 @@ os-tmpdir@~1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" -p-limit@^2.0.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1" - integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w== - dependencies: - p-try "^2.0.0" - -p-locate@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-3.0.0.tgz#322d69a05c0264b25997d9f40cd8a891ab0064a4" - integrity sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ== - dependencies: - p-limit "^2.0.0" - -p-try@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" - integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== - parent-module@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2" @@ -1363,14 +1275,6 @@ parse-json@^2.2.0: dependencies: error-ex "^1.2.0" -parse-json@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-4.0.0.tgz#be35f5425be1f7f6c747184f98a788cb99477ee0" - integrity sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA= - dependencies: - error-ex "^1.3.1" - json-parse-better-errors "^1.0.1" - parseqs@0.0.5: version "0.0.5" resolved "https://registry.yarnpkg.com/parseqs/-/parseqs-0.0.5.tgz#d5208a3738e46766e291ba2ea173684921a8b89d" @@ -1393,11 +1297,6 @@ path-exists@^2.0.0: dependencies: pinkie-promise "^2.0.0" -path-exists@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515" - integrity sha1-zg6+ql94yxiSXqfYENe1mwEP1RU= - path-is-absolute@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" @@ -1426,11 +1325,6 @@ pify@^2.0.0: version "2.3.0" resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" -pify@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176" - integrity sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY= - pinkie-promise@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa" @@ -1499,15 +1393,6 @@ read-pkg@^1.0.0: normalize-package-data "^2.3.2" path-type "^1.0.0" -read-pkg@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-4.0.1.tgz#963625378f3e1c4d48c85872b5a6ec7d5d093237" - integrity sha1-ljYlN48+HE1IyFhytabsfV0JMjc= - dependencies: - normalize-package-data "^2.3.2" - parse-json "^4.0.0" - pify "^3.0.0" - redent@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/redent/-/redent-1.0.0.tgz#cf916ab1fd5f1f16dfb20822dd6ec7f730c2afde" @@ -1529,16 +1414,6 @@ repeating@^2.0.0: dependencies: is-finite "^1.0.0" -require-directory@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" - integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I= - -require-main-filename@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b" - integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg== - resolve-from@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" @@ -1574,13 +1449,6 @@ run-async@^2.4.0: dependencies: is-promise "^2.1.0" -rxjs@^6.5.2: - version "6.6.3" - resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.6.3.tgz#8ca84635c4daa900c0d3967a6ee7ac60271ee552" - integrity sha512-trsQc+xYYXZ3urjOiJOuCOa5N3jAZ3eiSpQB5hIT8zGlL2QfnHLJ2r7GMkBGuIausdJN1OneaI6gQlsqNHHmZQ== - dependencies: - tslib "^1.9.0" - rxjs@^6.5.3: version "6.5.5" resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.5.5.tgz#c5c884e3094c8cfee31bf27eb87e54ccfc87f9ec" @@ -1634,11 +1502,6 @@ serve-static@1.14.1: parseurl "~1.3.3" send "0.17.1" -set-blocking@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" - integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc= - setprototypeof@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.1.1.tgz#7e95acb24aa92f5885e0abef5ba131330d4ae683" @@ -1730,11 +1593,6 @@ source-map@^0.6.0: version "0.6.1" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" -spawn-command@^0.0.2-1: - version "0.0.2-1" - resolved "https://registry.yarnpkg.com/spawn-command/-/spawn-command-0.0.2-1.tgz#62f5e9466981c1b796dc5929937e11c9c6921bd0" - integrity sha1-YvXpRmmBwbeW3Fkpk34RycaSG9A= - spdx-correct@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.1.0.tgz#fb83e504445268f154b074e218c87c003cd31df4" @@ -1765,7 +1623,7 @@ sprintf-js@~1.0.2: version "1.5.0" resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" -string-width@^3.0.0, string-width@^3.1.0: +string-width@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/string-width/-/string-width-3.1.0.tgz#22767be21b62af1081574306f69ac51b62203961" dependencies: @@ -1781,7 +1639,7 @@ string-width@^4.1.0: is-fullwidth-code-point "^3.0.0" strip-ansi "^6.0.0" -strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0: +strip-ansi@^5.1.0, strip-ansi@^5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-5.2.0.tgz#8c9a536feb6afc962bdfa5b104a5091c1ad9c0ae" dependencies: @@ -1823,13 +1681,6 @@ supports-color@^5.3.0: dependencies: has-flag "^3.0.0" -supports-color@^6.1.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-6.1.0.tgz#0764abc69c63d5ac842dd4867e8d025e880df8f3" - integrity sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ== - dependencies: - has-flag "^3.0.0" - supports-color@^7.1.0: version "7.1.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.1.0.tgz#68e32591df73e25ad1c4b49108a2ec507962bfd1" @@ -1878,7 +1729,7 @@ toidentifier@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.0.tgz#7e1be3470f1e77948bc43d94a3c8f4d7752ba553" -tree-kill@^1.2.1, tree-kill@^1.2.2: +tree-kill@^1.2.1: version "1.2.2" resolved "https://registry.yarnpkg.com/tree-kill/-/tree-kill-1.2.2.tgz#4ca09a9092c88b73a7cdc5e8a01b507b0790a0cc" @@ -1913,13 +1764,6 @@ ts-node@*: source-map-support "^0.5.6" yn "3.1.1" -ts-protoc-gen@^0.13.0: - version "0.13.0" - resolved "https://registry.yarnpkg.com/ts-protoc-gen/-/ts-protoc-gen-0.13.0.tgz#2763ae4e4a1a7d7001d53d2f3043357c691701ea" - integrity sha512-j18X4rkDBbG/ZHUJy88WFeZP6mStGow5uREaohowlHXTu3/N7WcpyPhb7Vh6wN38ERmc/AkT9gqT98+vtlRhJA== - dependencies: - google-protobuf "^3.6.1" - tsconfig@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/tsconfig/-/tsconfig-7.0.0.tgz#84538875a4dc216e5c4a5432b3a4dec3d54e91b7" @@ -2003,11 +1847,6 @@ vary@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" -which-module@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" - integrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho= - which@^1.2.9, which@^1.3.0: version "1.3.1" resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" @@ -2018,15 +1857,6 @@ word-wrap@~1.2.3: version "1.2.3" resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c" -wrap-ansi@^5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-5.1.0.tgz#1fd1f67235d5b6d0fee781056001bfb694c03b09" - integrity sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q== - dependencies: - ansi-styles "^3.2.0" - string-width "^3.0.0" - strip-ansi "^5.0.0" - wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" @@ -2055,35 +1885,6 @@ xtend@^4.0.0: version "4.0.2" resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54" -y18n@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b" - integrity sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w== - -yargs-parser@^13.1.2: - version "13.1.2" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-13.1.2.tgz#130f09702ebaeef2650d54ce6e3e5706f7a4fb38" - integrity sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg== - dependencies: - camelcase "^5.0.0" - decamelize "^1.2.0" - -yargs@^13.3.0: - version "13.3.2" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-13.3.2.tgz#ad7ffefec1aa59565ac915f82dccb38a9c31a2dd" - integrity sha512-AX3Zw5iPruN5ie6xGRIDgqkT+ZhnRlZMLMHAs8tg7nRruy2Nb+i5o9bwghAogtM08q1dpr2LVoS8KSTMYpWXUw== - dependencies: - cliui "^5.0.0" - find-up "^3.0.0" - get-caller-file "^2.0.1" - require-directory "^2.1.1" - require-main-filename "^2.0.0" - set-blocking "^2.0.0" - string-width "^3.0.0" - which-module "^2.0.0" - y18n "^4.0.0" - yargs-parser "^13.1.2" - yeast@0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/yeast/-/yeast-0.1.2.tgz#008e06d8094320c372dbc2f8ed76a0ca6c8ac419" diff --git a/benchmark/artillery_multi_core.sh b/benchmark/artillery_multi_core.sh deleted file mode 100755 index 5eeb4d60..00000000 --- a/benchmark/artillery_multi_core.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -npm run start & -pid1=$! -npm run start:nooutput & -pid2=$! -npm run start:nooutput & -pid3=$! -npm run start:nooutput & -pid4=$! - -wait $pid1 -wait $pid2 -wait $pid3 -wait $pid4 - - diff --git a/benchmark/benchmark_multi_core.sh b/benchmark/benchmark_multi_core.sh new file mode 100755 index 00000000..ef2f2096 --- /dev/null +++ b/benchmark/benchmark_multi_core.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +yarn run start & +pid1=$! +yarn run start & +pid2=$! +yarn run start & +pid3=$! +yarn run start & +pid4=$! + +wait $pid1 +wait $pid2 +wait $pid3 +wait $pid4 diff --git a/benchmark/index.ts b/benchmark/index.ts new file mode 100644 index 00000000..057d5d2f --- /dev/null +++ b/benchmark/index.ts @@ -0,0 +1,48 @@ +import {Connection} from "../front/src/Connection"; + +function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); +} + +async function startOneUser(): Promise { + const connection = await Connection.createConnection('foo', ['male3']); + + await connection.joinARoom('global__maps.workadventure.localhost/Floor0/floor0', 783, 170, 'down', false, { + top: 0, + bottom: 200, + left: 500, + right: 800 + }); + console.log(connection.getUserId()); + + let angle = Math.random() * Math.PI * 2; + + for (let i = 0; i < 100; i++) { + const x = Math.floor(320 + 1472/2 * (1 + Math.sin(angle))); + const y = Math.floor(200 + 1090/2 * (1 + Math.cos(angle))); + + connection.sharePosition(x, y, 'down', true, { + top: y - 200, + bottom: y + 200, + left: x - 320, + right: x + 320 + }) + + angle += 0.05; + + await sleep(200); + } + + await sleep(10000); + connection.closeConnection(); +} + +(async () => { + let promises: Promise[] = new Array>(); + + for (let userNo = 0; userNo < 40; userNo++) { + promises.push(startOneUser()); + // Wait 0.5s between adding users + await sleep(500); + } +})(); diff --git a/benchmark/package.json b/benchmark/package.json index 59b182bc..2c874a7e 100644 --- a/benchmark/package.json +++ b/benchmark/package.json @@ -3,8 +3,7 @@ "version": "1.0.0", "description": "Load testing for WorkAdventure", "scripts": { - "start": "artillery run socketio-load-test.yaml -o artillery_output.json && artillery report --output artillery_output.html artillery_output.json", - "start:nooutput": "artillery run socketio-load-test.yaml" + "start": "ts-node ./index.ts" }, "contributors": [ { @@ -22,6 +21,11 @@ ], "license": "SEE LICENSE IN LICENSE.txt", "dependencies": { - "artillery": "^1.6.1" + "socket.io-client": "^2.3.0", + "ts-node-dev": "^1.0.0-pre.62", + "typescript": "^4.0.2" + }, + "devDependencies": { + "@types/socket.io-client": "^1.4.33" } } diff --git a/benchmark/yarn.lock b/benchmark/yarn.lock new file mode 100644 index 00000000..4c73bc38 --- /dev/null +++ b/benchmark/yarn.lock @@ -0,0 +1,693 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@types/socket.io-client@^1.4.33": + version "1.4.33" + resolved "https://registry.yarnpkg.com/@types/socket.io-client/-/socket.io-client-1.4.33.tgz#8e705b9b3f7fba6cb329d27cd2eda222812adbf1" + +"@types/strip-bom@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@types/strip-bom/-/strip-bom-3.0.0.tgz#14a8ec3956c2e81edb7520790aecf21c290aebd2" + +"@types/strip-json-comments@0.0.30": + version "0.0.30" + resolved "https://registry.yarnpkg.com/@types/strip-json-comments/-/strip-json-comments-0.0.30.tgz#9aa30c04db212a9a0649d6ae6fd50accc40748a1" + +after@0.8.2: + version "0.8.2" + resolved "https://registry.yarnpkg.com/after/-/after-0.8.2.tgz#fedb394f9f0e02aa9768e702bda23b505fae7e1f" + +anymatch@~3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.1.tgz#c55ecf02185e2469259399310c173ce31233b142" + dependencies: + normalize-path "^3.0.0" + picomatch "^2.0.4" + +arg@^4.1.0: + version "4.1.3" + resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" + +array-find-index@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/array-find-index/-/array-find-index-1.0.2.tgz#df010aa1287e164bbda6f9723b0a96a1ec4187a1" + +arraybuffer.slice@~0.0.7: + version "0.0.7" + resolved "https://registry.yarnpkg.com/arraybuffer.slice/-/arraybuffer.slice-0.0.7.tgz#3bbc4275dd584cc1b10809b89d4e8b63a69e7675" + +async-limiter@~1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.1.tgz#dd379e94f0db8310b08291f9d64c3209766617fd" + +backo2@1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/backo2/-/backo2-1.0.2.tgz#31ab1ac8b129363463e35b3ebb69f4dfcfba7947" + +balanced-match@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" + +base64-arraybuffer@0.1.5: + version "0.1.5" + resolved "https://registry.yarnpkg.com/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz#73926771923b5a19747ad666aa5cd4bf9c6e9ce8" + +better-assert@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/better-assert/-/better-assert-1.0.2.tgz#40866b9e1b9e0b55b481894311e68faffaebc522" + dependencies: + callsite "1.0.0" + +binary-extensions@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.1.0.tgz#30fa40c9e7fe07dbc895678cd287024dea241dd9" + +blob@0.0.5: + version "0.0.5" + resolved "https://registry.yarnpkg.com/blob/-/blob-0.0.5.tgz#d680eeef25f8cd91ad533f5b01eed48e64caf683" + +brace-expansion@^1.1.7: + version "1.1.11" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" + dependencies: + balanced-match "^1.0.0" + concat-map "0.0.1" + +braces@~3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" + dependencies: + fill-range "^7.0.1" + +buffer-from@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" + +callsite@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/callsite/-/callsite-1.0.0.tgz#280398e5d664bd74038b6f0905153e6e8af1bc20" + +camelcase-keys@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-2.1.0.tgz#308beeaffdf28119051efa1d932213c91b8f92e7" + dependencies: + camelcase "^2.0.0" + map-obj "^1.0.0" + +camelcase@^2.0.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-2.1.1.tgz#7c1d16d679a1bbe59ca02cacecfb011e201f5a1f" + +chokidar@^3.4.0: + version "3.4.2" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.4.2.tgz#38dc8e658dec3809741eb3ef7bb0a47fe424232d" + dependencies: + anymatch "~3.1.1" + braces "~3.0.2" + glob-parent "~5.1.0" + is-binary-path "~2.1.0" + is-glob "~4.0.1" + normalize-path "~3.0.0" + readdirp "~3.4.0" + optionalDependencies: + fsevents "~2.1.2" + +component-bind@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/component-bind/-/component-bind-1.0.0.tgz#00c608ab7dcd93897c0009651b1d3a8e1e73bbd1" + +component-emitter@1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.2.1.tgz#137918d6d78283f7df7a6b7c5a63e140e69425e6" + +component-emitter@~1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.3.0.tgz#16e4070fba8ae29b679f2215853ee181ab2eabc0" + +component-inherit@0.0.3: + version "0.0.3" + resolved "https://registry.yarnpkg.com/component-inherit/-/component-inherit-0.0.3.tgz#645fc4adf58b72b649d5cae65135619db26ff143" + +concat-map@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + +currently-unhandled@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/currently-unhandled/-/currently-unhandled-0.4.1.tgz#988df33feab191ef799a61369dd76c17adf957ea" + dependencies: + array-find-index "^1.0.1" + +dateformat@~1.0.4-1.2.3: + version "1.0.12" + resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-1.0.12.tgz#9f124b67594c937ff706932e4a642cca8dbbfee9" + dependencies: + get-stdin "^4.0.1" + meow "^3.3.0" + +debug@~3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" + dependencies: + ms "2.0.0" + +debug@~4.1.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791" + dependencies: + ms "^2.1.1" + +decamelize@^1.1.2: + version "1.2.0" + resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" + +diff@^4.0.1: + version "4.0.2" + resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" + +dynamic-dedupe@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/dynamic-dedupe/-/dynamic-dedupe-0.3.0.tgz#06e44c223f5e4e94d78ef9db23a6515ce2f962a1" + dependencies: + xtend "^4.0.0" + +engine.io-client@~3.4.0: + version "3.4.3" + resolved "https://registry.yarnpkg.com/engine.io-client/-/engine.io-client-3.4.3.tgz#192d09865403e3097e3575ebfeb3861c4d01a66c" + dependencies: + component-emitter "~1.3.0" + component-inherit "0.0.3" + debug "~4.1.0" + engine.io-parser "~2.2.0" + has-cors "1.1.0" + indexof "0.0.1" + parseqs "0.0.5" + parseuri "0.0.5" + ws "~6.1.0" + xmlhttprequest-ssl "~1.5.4" + yeast "0.1.2" + +engine.io-parser@~2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/engine.io-parser/-/engine.io-parser-2.2.0.tgz#312c4894f57d52a02b420868da7b5c1c84af80ed" + dependencies: + after "0.8.2" + arraybuffer.slice "~0.0.7" + base64-arraybuffer "0.1.5" + blob "0.0.5" + has-binary2 "~1.0.2" + +error-ex@^1.2.0: + version "1.3.2" + resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" + dependencies: + is-arrayish "^0.2.1" + +fill-range@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" + dependencies: + to-regex-range "^5.0.1" + +find-up@^1.0.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-1.1.2.tgz#6b2e9822b1a2ce0a60ab64d610eccad53cb24d0f" + dependencies: + path-exists "^2.0.0" + pinkie-promise "^2.0.0" + +fs.realpath@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" + +fsevents@~2.1.2: + version "2.1.3" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.1.3.tgz#fb738703ae8d2f9fe900c33836ddebee8b97f23e" + +get-stdin@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe" + +glob-parent@~5.1.0: + version "5.1.1" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.1.tgz#b6c1ef417c4e5663ea498f1c45afac6916bbc229" + dependencies: + is-glob "^4.0.1" + +glob@^7.1.3: + version "7.1.6" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6" + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.4" + once "^1.3.0" + path-is-absolute "^1.0.0" + +graceful-fs@^4.1.2: + version "4.2.4" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.4.tgz#2256bde14d3632958c465ebc96dc467ca07a29fb" + +has-binary2@~1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/has-binary2/-/has-binary2-1.0.3.tgz#7776ac627f3ea77250cfc332dab7ddf5e4f5d11d" + dependencies: + isarray "2.0.1" + +has-cors@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/has-cors/-/has-cors-1.1.0.tgz#5e474793f7ea9843d1bb99c23eef49ff126fff39" + +hosted-git-info@^2.1.4: + version "2.8.8" + resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.8.tgz#7539bd4bc1e0e0a895815a2e0262420b12858488" + +indent-string@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-2.1.0.tgz#8e2d48348742121b4a8218b7a137e9a52049dc80" + dependencies: + repeating "^2.0.0" + +indexof@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/indexof/-/indexof-0.0.1.tgz#82dc336d232b9062179d05ab3293a66059fd435d" + +inflight@^1.0.4: + version "1.0.6" + resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + dependencies: + once "^1.3.0" + wrappy "1" + +inherits@2: + version "2.0.4" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" + +is-arrayish@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" + +is-binary-path@~2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" + dependencies: + binary-extensions "^2.0.0" + +is-extglob@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" + +is-finite@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-finite/-/is-finite-1.1.0.tgz#904135c77fb42c0641d6aa1bcdbc4daa8da082f3" + +is-glob@^4.0.1, is-glob@~4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.1.tgz#7567dbe9f2f5e2467bc77ab83c4a29482407a5dc" + dependencies: + is-extglob "^2.1.1" + +is-number@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" + +is-utf8@^0.2.0: + version "0.2.1" + resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" + +isarray@2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-2.0.1.tgz#a37d94ed9cda2d59865c9f76fe596ee1f338741e" + +load-json-file@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-1.1.0.tgz#956905708d58b4bab4c2261b04f59f31c99374c0" + dependencies: + graceful-fs "^4.1.2" + parse-json "^2.2.0" + pify "^2.0.0" + pinkie-promise "^2.0.0" + strip-bom "^2.0.0" + +loud-rejection@^1.0.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/loud-rejection/-/loud-rejection-1.6.0.tgz#5b46f80147edee578870f086d04821cf998e551f" + dependencies: + currently-unhandled "^0.4.1" + signal-exit "^3.0.0" + +make-error@^1.1.1: + version "1.3.6" + resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" + +map-obj@^1.0.0, map-obj@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-1.0.1.tgz#d933ceb9205d82bdcf4886f6742bdc2b4dea146d" + +meow@^3.3.0: + version "3.7.0" + resolved "https://registry.yarnpkg.com/meow/-/meow-3.7.0.tgz#72cb668b425228290abbfa856892587308a801fb" + dependencies: + camelcase-keys "^2.0.0" + decamelize "^1.1.2" + loud-rejection "^1.0.0" + map-obj "^1.0.1" + minimist "^1.1.3" + normalize-package-data "^2.3.4" + object-assign "^4.0.1" + read-pkg-up "^1.0.1" + redent "^1.0.0" + trim-newlines "^1.0.0" + +minimatch@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" + dependencies: + brace-expansion "^1.1.7" + +minimist@^1.1.3, minimist@^1.2.5: + version "1.2.5" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" + +mkdirp@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" + +ms@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" + +ms@^2.1.1: + version "2.1.2" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" + +normalize-package-data@^2.3.2, normalize-package-data@^2.3.4: + version "2.5.0" + resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.5.0.tgz#e66db1838b200c1dfc233225d12cb36520e234a8" + dependencies: + hosted-git-info "^2.1.4" + resolve "^1.10.0" + semver "2 || 3 || 4 || 5" + validate-npm-package-license "^3.0.1" + +normalize-path@^3.0.0, normalize-path@~3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" + +object-assign@^4.0.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" + +object-component@0.0.3: + version "0.0.3" + resolved "https://registry.yarnpkg.com/object-component/-/object-component-0.0.3.tgz#f0c69aa50efc95b866c186f400a33769cb2f1291" + +once@^1.3.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + dependencies: + wrappy "1" + +parse-json@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-2.2.0.tgz#f480f40434ef80741f8469099f8dea18f55a4dc9" + dependencies: + error-ex "^1.2.0" + +parseqs@0.0.5: + version "0.0.5" + resolved "https://registry.yarnpkg.com/parseqs/-/parseqs-0.0.5.tgz#d5208a3738e46766e291ba2ea173684921a8b89d" + dependencies: + better-assert "~1.0.0" + +parseuri@0.0.5: + version "0.0.5" + resolved "https://registry.yarnpkg.com/parseuri/-/parseuri-0.0.5.tgz#80204a50d4dbb779bfdc6ebe2778d90e4bce320a" + dependencies: + better-assert "~1.0.0" + +path-exists@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-2.1.0.tgz#0feb6c64f0fc518d9a754dd5efb62c7022761f4b" + dependencies: + pinkie-promise "^2.0.0" + +path-is-absolute@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + +path-parse@^1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" + +path-type@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/path-type/-/path-type-1.1.0.tgz#59c44f7ee491da704da415da5a4070ba4f8fe441" + dependencies: + graceful-fs "^4.1.2" + pify "^2.0.0" + pinkie-promise "^2.0.0" + +picomatch@^2.0.4, picomatch@^2.2.1: + version "2.2.2" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad" + +pify@^2.0.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" + +pinkie-promise@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa" + dependencies: + pinkie "^2.0.0" + +pinkie@^2.0.0: + version "2.0.4" + resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870" + +read-pkg-up@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-1.0.1.tgz#9d63c13276c065918d57f002a57f40a1b643fb02" + dependencies: + find-up "^1.0.0" + read-pkg "^1.0.0" + +read-pkg@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-1.1.0.tgz#f5ffaa5ecd29cb31c0474bca7d756b6bb29e3f28" + dependencies: + load-json-file "^1.0.0" + normalize-package-data "^2.3.2" + path-type "^1.0.0" + +readdirp@~3.4.0: + version "3.4.0" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.4.0.tgz#9fdccdf9e9155805449221ac645e8303ab5b9ada" + dependencies: + picomatch "^2.2.1" + +redent@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/redent/-/redent-1.0.0.tgz#cf916ab1fd5f1f16dfb20822dd6ec7f730c2afde" + dependencies: + indent-string "^2.1.0" + strip-indent "^1.0.1" + +repeating@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/repeating/-/repeating-2.0.1.tgz#5214c53a926d3552707527fbab415dbc08d06dda" + dependencies: + is-finite "^1.0.0" + +resolve@^1.0.0, resolve@^1.10.0: + version "1.17.0" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.17.0.tgz#b25941b54968231cc2d1bb76a79cb7f2c0bf8444" + dependencies: + path-parse "^1.0.6" + +rimraf@^2.6.1: + version "2.7.1" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec" + dependencies: + glob "^7.1.3" + +"semver@2 || 3 || 4 || 5": + version "5.7.1" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" + +signal-exit@^3.0.0: + version "3.0.3" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c" + +socket.io-client@^2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/socket.io-client/-/socket.io-client-2.3.0.tgz#14d5ba2e00b9bcd145ae443ab96b3f86cbcc1bb4" + dependencies: + backo2 "1.0.2" + base64-arraybuffer "0.1.5" + component-bind "1.0.0" + component-emitter "1.2.1" + debug "~4.1.0" + engine.io-client "~3.4.0" + has-binary2 "~1.0.2" + has-cors "1.1.0" + indexof "0.0.1" + object-component "0.0.3" + parseqs "0.0.5" + parseuri "0.0.5" + socket.io-parser "~3.3.0" + to-array "0.1.4" + +socket.io-parser@~3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-3.3.0.tgz#2b52a96a509fdf31440ba40fed6094c7d4f1262f" + dependencies: + component-emitter "1.2.1" + debug "~3.1.0" + isarray "2.0.1" + +source-map-support@^0.5.12, source-map-support@^0.5.17: + version "0.5.19" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61" + dependencies: + buffer-from "^1.0.0" + source-map "^0.6.0" + +source-map@^0.6.0: + version "0.6.1" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" + +spdx-correct@^3.0.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.1.1.tgz#dece81ac9c1e6713e5f7d1b6f17d468fa53d89a9" + dependencies: + spdx-expression-parse "^3.0.0" + spdx-license-ids "^3.0.0" + +spdx-exceptions@^2.1.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz#3f28ce1a77a00372683eade4a433183527a2163d" + +spdx-expression-parse@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz#cf70f50482eefdc98e3ce0a6833e4a53ceeba679" + dependencies: + spdx-exceptions "^2.1.0" + spdx-license-ids "^3.0.0" + +spdx-license-ids@^3.0.0: + version "3.0.6" + resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.6.tgz#c80757383c28abf7296744998cbc106ae8b854ce" + +strip-bom@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-2.0.0.tgz#6219a85616520491f35788bdbf1447a99c7e6b0e" + dependencies: + is-utf8 "^0.2.0" + +strip-bom@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" + +strip-indent@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-1.0.1.tgz#0c7962a6adefa7bbd4ac366460a638552ae1a0a2" + dependencies: + get-stdin "^4.0.1" + +strip-json-comments@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" + +to-array@0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/to-array/-/to-array-0.1.4.tgz#17e6c11f73dd4f3d74cda7a4ff3238e9ad9bf890" + +to-regex-range@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" + dependencies: + is-number "^7.0.0" + +tree-kill@^1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/tree-kill/-/tree-kill-1.2.2.tgz#4ca09a9092c88b73a7cdc5e8a01b507b0790a0cc" + +trim-newlines@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613" + +ts-node-dev@^1.0.0-pre.62: + version "1.0.0-pre.62" + resolved "https://registry.yarnpkg.com/ts-node-dev/-/ts-node-dev-1.0.0-pre.62.tgz#835644c43669b659a880379b9d06df86cef665ad" + dependencies: + chokidar "^3.4.0" + dateformat "~1.0.4-1.2.3" + dynamic-dedupe "^0.3.0" + minimist "^1.2.5" + mkdirp "^1.0.4" + resolve "^1.0.0" + rimraf "^2.6.1" + source-map-support "^0.5.12" + tree-kill "^1.2.2" + ts-node "^8.10.2" + tsconfig "^7.0.0" + +ts-node@^8.10.2: + version "8.10.2" + resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-8.10.2.tgz#eee03764633b1234ddd37f8db9ec10b75ec7fb8d" + dependencies: + arg "^4.1.0" + diff "^4.0.1" + make-error "^1.1.1" + source-map-support "^0.5.17" + yn "3.1.1" + +tsconfig@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/tsconfig/-/tsconfig-7.0.0.tgz#84538875a4dc216e5c4a5432b3a4dec3d54e91b7" + dependencies: + "@types/strip-bom" "^3.0.0" + "@types/strip-json-comments" "0.0.30" + strip-bom "^3.0.0" + strip-json-comments "^2.0.0" + +typescript@^4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.2.tgz#7ea7c88777c723c681e33bf7988be5d008d05ac2" + +validate-npm-package-license@^3.0.1: + version "3.0.4" + resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz#fc91f6b9c7ba15c857f4cb2c5defeec39d4f410a" + dependencies: + spdx-correct "^3.0.0" + spdx-expression-parse "^3.0.0" + +wrappy@1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + +ws@~6.1.0: + version "6.1.4" + resolved "https://registry.yarnpkg.com/ws/-/ws-6.1.4.tgz#5b5c8800afab925e94ccb29d153c8d02c1776ef9" + dependencies: + async-limiter "~1.0.0" + +xmlhttprequest-ssl@~1.5.4: + version "1.5.5" + resolved "https://registry.yarnpkg.com/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.5.tgz#c2876b06168aadc40e57d97e81191ac8f4398b3e" + +xtend@^4.0.0: + version "4.0.2" + resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54" + +yeast@0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/yeast/-/yeast-0.1.2.tgz#008e06d8094320c372dbc2f8ed76a0ca6c8ac419" + +yn@3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" From 7826b2ea8dab81ce44353b2e7c625b6eaccd3762 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Fri, 18 Sep 2020 17:18:50 +0200 Subject: [PATCH 027/122] Fixing Docker build images to add new messages directory --- .github/workflows/build-and-deploy.yml | 4 ++-- back/Dockerfile | 4 +++- back/src/Model/Websocket/ExSocketInterface.ts | 2 +- front/Dockerfile | 4 +++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index edd7b553..7e7c9014 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -26,7 +26,7 @@ jobs: uses: docker/build-push-action@v1 with: dockerfile: front/Dockerfile - path: front/ + path: ./ username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} repository: thecodingmachine/workadventure-front @@ -49,7 +49,7 @@ jobs: uses: docker/build-push-action@v1 with: dockerfile: back/Dockerfile - path: back/ + path: ./ username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} repository: thecodingmachine/workadventure-back diff --git a/back/Dockerfile b/back/Dockerfile index 8b1b8f61..ca98a648 100644 --- a/back/Dockerfile +++ b/back/Dockerfile @@ -1,7 +1,9 @@ FROM thecodingmachine/nodejs:12 -COPY --chown=docker:docker . . +COPY --chown=docker:docker back . +COPY --chown=docker:docker messages ../messages RUN yarn install +RUN cd /usr/src/messages && yarn install ENV NODE_ENV=production diff --git a/back/src/Model/Websocket/ExSocketInterface.ts b/back/src/Model/Websocket/ExSocketInterface.ts index d7edf554..cd1f73ed 100644 --- a/back/src/Model/Websocket/ExSocketInterface.ts +++ b/back/src/Model/Websocket/ExSocketInterface.ts @@ -8,7 +8,7 @@ import {BatchMessage, SubMessage} from "../../../../messages/generated/messages_ export interface ExSocketInterface extends Socket, Identificable { token: string; roomId: string; - webRtcRoomId: string; + webRtcRoomId: string|undefined; userId: number; // A temporary (autoincremented) identifier for this user userUuid: string; // A unique identifier for this user name: string; diff --git a/front/Dockerfile b/front/Dockerfile index c5c605a8..ba2c422b 100644 --- a/front/Dockerfile +++ b/front/Dockerfile @@ -1,8 +1,10 @@ # we are rebuilding on each deploy to cope with the API_URL environment URL FROM thecodingmachine/nodejs:14-apache -COPY --chown=docker:docker . . +COPY --chown=docker:docker front . +COPY --chown=docker:docker messages /var/www/messages RUN yarn install +RUN cd /usr/src/messages && yarn install ENV NODE_ENV=production ENV STARTUP_COMMAND_1="yarn run build" From 30d2a25501a35f93df153aeadadbe89dc89760a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Fri, 18 Sep 2020 17:36:33 +0200 Subject: [PATCH 028/122] Artillery cleanup --- benchmark/index.ts | 4 +-- benchmark/socketio-load-test.yaml | 44 ------------------------- benchmark/socketioLoadTest.js | 53 ------------------------------- 3 files changed, 1 insertion(+), 100 deletions(-) delete mode 100644 benchmark/socketio-load-test.yaml delete mode 100644 benchmark/socketioLoadTest.js diff --git a/benchmark/index.ts b/benchmark/index.ts index 057d5d2f..736a7bdc 100644 --- a/benchmark/index.ts +++ b/benchmark/index.ts @@ -38,10 +38,8 @@ async function startOneUser(): Promise { } (async () => { - let promises: Promise[] = new Array>(); - for (let userNo = 0; userNo < 40; userNo++) { - promises.push(startOneUser()); + startOneUser(); // Wait 0.5s between adding users await sleep(500); } diff --git a/benchmark/socketio-load-test.yaml b/benchmark/socketio-load-test.yaml deleted file mode 100644 index 81c7e55e..00000000 --- a/benchmark/socketio-load-test.yaml +++ /dev/null @@ -1,44 +0,0 @@ -config: - target: "http://api.workadventure.localhost/" - socketio: - transports: ["websocket"] - query: - token: "test" - phases: - - duration: 20 - arrivalRate: 3 - processor: "./socketioLoadTest.js" -scenarios: - - name: "Connects and moves player for 20 seconds" - weight: 90 - engine: "socketio" - flow: - - emit: - channel: "set-player-details" - data: - name: 'TEST' - characterLayers: ['male3'] - - think: 1 - - emit: - channel: "join-room" - data: - roomId: 'global__maps.workadventure.localhost/Floor0/floor0' - position: - x: 783 - y: 170 - direction: 'down' - moving: false - viewport: - left: 500 - top: 0 - right: 800 - bottom: 200 - - think: 1 - - loop: - - function: "setUserMovesMessage" - - emit: - channel: "user-position" - data: "{{ message }}" - - think: 0.2 - count: 100 - - think: 10 diff --git a/benchmark/socketioLoadTest.js b/benchmark/socketioLoadTest.js deleted file mode 100644 index 3f01bab6..00000000 --- a/benchmark/socketioLoadTest.js +++ /dev/null @@ -1,53 +0,0 @@ -'use strict'; - -require("../messages/generated/messages_pb"); -//import {PositionMessage, UserMovesMessage, ViewportMessage} from "../messages/generated/messages_pb"; - -module.exports = { - setYRandom -}; - -function setYRandom(context, events, done) { - if (context.angle === undefined) { - context.angle = Math.random() * Math.PI * 2; - } - context.angle += 0.05; - - context.vars.x = 320 + 1472/2 * (1 + Math.sin(context.angle)); - context.vars.y = 200 + 1090/2 * (1 + Math.cos(context.angle)); - context.vars.left = context.vars.x - 320; - context.vars.top = context.vars.y - 200; - context.vars.right = context.vars.x + 320; - context.vars.bottom = context.vars.y + 200; - return done(); -} - -function setUserMovesMessage(context, events, done) { - if (context.angle === undefined) { - context.angle = Math.random() * Math.PI * 2; - } - context.angle += 0.05; - - const x = Math.floor(320 + 1472/2 * (1 + Math.sin(context.angle))); - const y = Math.floor(200 + 1090/2 * (1 + Math.cos(context.angle))); - - const positionMessage = new PositionMessage(); - positionMessage.setX(x); - positionMessage.setY(y); - positionMessage.setDirection(PositionMessage.Direction.UP); - positionMessage.setMoving(false); - - const viewportMessage = new ViewportMessage(); - viewportMessage.setTop(y - 200); - viewportMessage.setBottom(y + 200); - viewportMessage.setLeft(x - 320); - viewportMessage.setRight(x + 320); - - const userMovesMessage = new UserMovesMessage(); - userMovesMessage.setPosition(positionMessage); - userMovesMessage.setViewport(viewportMessage); - - context.vars.message = userMovesMessage.serializeBinary().buffer; - console.log(context.vars.message); - return done(); -} From 5c0a4e7c5a11706e8fd8b149a5f88faf2e19b61d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Fri, 18 Sep 2020 17:39:59 +0200 Subject: [PATCH 029/122] Fixing front Dockerfile --- front/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/Dockerfile b/front/Dockerfile index ba2c422b..a2bc518f 100644 --- a/front/Dockerfile +++ b/front/Dockerfile @@ -4,7 +4,7 @@ FROM thecodingmachine/nodejs:14-apache COPY --chown=docker:docker front . COPY --chown=docker:docker messages /var/www/messages RUN yarn install -RUN cd /usr/src/messages && yarn install +RUN cd /var/www/messages && yarn install ENV NODE_ENV=production ENV STARTUP_COMMAND_1="yarn run build" From 398ca1760b48b9a8b26037f499f532086148ff38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Fri, 18 Sep 2020 17:47:18 +0200 Subject: [PATCH 030/122] Fixing CI builds --- .github/workflows/continuous_integration.yml | 8 ++++++++ messages/messages.proto | 14 ++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index 7c74fb66..4ca1ebe5 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -26,6 +26,10 @@ jobs: run: yarn install working-directory: "front" + - name: "Install messages dependencies" + run: yarn install + working-directory: "messages" + - name: "Build" run: yarn run build env: @@ -58,6 +62,10 @@ jobs: run: yarn install working-directory: "back" + - name: "Install messages dependencies" + run: yarn install + working-directory: "messages" + - name: "Build" run: yarn run tsc working-directory: "back" diff --git a/messages/messages.proto b/messages/messages.proto index 7d8cb0a8..9cf6de8a 100644 --- a/messages/messages.proto +++ b/messages/messages.proto @@ -15,6 +15,11 @@ message PositionMessage { bool moving = 4; } +message PointMessage { + int32 x = 1; + int32 y = 2; +} + message ViewportMessage { int32 left = 1; int32 top = 2; @@ -52,3 +57,12 @@ message BatchMessage { string event = 1; repeated SubMessage payload = 2; } + +message GroupUpdateMessage { + int32 groupId = 1; + PointMessage position = 2; +} + +message GroupDeleteMessage { + int32 groupId = 1; +} From d3116c740076059d8312eb542983eb03eaeb3717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Fri, 18 Sep 2020 17:51:12 +0200 Subject: [PATCH 031/122] Building proto messages in CI --- .github/workflows/continuous_integration.yml | 8 ++++++++ back/Dockerfile | 2 +- front/Dockerfile | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index 4ca1ebe5..8545fe58 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -30,6 +30,10 @@ jobs: run: yarn install working-directory: "messages" + - name: "Build proto messages" + run: yarn run proto + working-directory: "messages" + - name: "Build" run: yarn run build env: @@ -66,6 +70,10 @@ jobs: run: yarn install working-directory: "messages" + - name: "Build proto messages" + run: yarn run proto + working-directory: "messages" + - name: "Build" run: yarn run tsc working-directory: "back" diff --git a/back/Dockerfile b/back/Dockerfile index ca98a648..80c02529 100644 --- a/back/Dockerfile +++ b/back/Dockerfile @@ -3,7 +3,7 @@ FROM thecodingmachine/nodejs:12 COPY --chown=docker:docker back . COPY --chown=docker:docker messages ../messages RUN yarn install -RUN cd /usr/src/messages && yarn install +RUN cd /usr/src/messages && yarn install && yarn proto ENV NODE_ENV=production diff --git a/front/Dockerfile b/front/Dockerfile index a2bc518f..4a6a2e6a 100644 --- a/front/Dockerfile +++ b/front/Dockerfile @@ -4,7 +4,7 @@ FROM thecodingmachine/nodejs:14-apache COPY --chown=docker:docker front . COPY --chown=docker:docker messages /var/www/messages RUN yarn install -RUN cd /var/www/messages && yarn install +RUN cd /var/www/messages && yarn install && yarn proto ENV NODE_ENV=production ENV STARTUP_COMMAND_1="yarn run build" From d2a5060ad2227ffdef9a9e844b7337e6bf3f3a77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Fri, 18 Sep 2020 18:00:03 +0200 Subject: [PATCH 032/122] Using multistage builds with protocol buffers --- back/Dockerfile | 8 ++++++-- front/Dockerfile | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/back/Dockerfile b/back/Dockerfile index 80c02529..f0c565f9 100644 --- a/back/Dockerfile +++ b/back/Dockerfile @@ -1,9 +1,13 @@ +FROM thecodingmachine/workadventure-back-base:latest as builder +WORKDIR /var/www/messages +COPY --chown=docker:docker messages . +RUN yarn install && yarn proto + FROM thecodingmachine/nodejs:12 COPY --chown=docker:docker back . -COPY --chown=docker:docker messages ../messages +COPY --from=builder --chown=docker:docker /var/www/messages /var/www/messages RUN yarn install -RUN cd /usr/src/messages && yarn install && yarn proto ENV NODE_ENV=production diff --git a/front/Dockerfile b/front/Dockerfile index 4a6a2e6a..98e29a52 100644 --- a/front/Dockerfile +++ b/front/Dockerfile @@ -1,10 +1,14 @@ +FROM thecodingmachine/workadventure-back-base:latest as builder +WORKDIR /var/www/messages +COPY --chown=docker:docker messages . +RUN yarn install && yarn proto + # we are rebuilding on each deploy to cope with the API_URL environment URL FROM thecodingmachine/nodejs:14-apache COPY --chown=docker:docker front . -COPY --chown=docker:docker messages /var/www/messages +COPY --from=builder --chown=docker:docker /var/www/messages /var/www/messages RUN yarn install -RUN cd /var/www/messages && yarn install && yarn proto ENV NODE_ENV=production ENV STARTUP_COMMAND_1="yarn run build" From 5c63573ef1f3e27ed54d76b5abe420f8abdc4866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Fri, 18 Sep 2020 18:01:36 +0200 Subject: [PATCH 033/122] Adding protoc to CI --- .github/workflows/continuous_integration.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index 8545fe58..95aed5a2 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -20,7 +20,12 @@ jobs: - name: "Setup NodeJS" uses: actions/setup-node@v1 with: - node-version: '12.x' + node-version: '14.x' + + - name: Install Protoc + uses: arduino/setup-protoc@v1 + with: + version: '3.x' - name: "Install dependencies" run: yarn install @@ -62,6 +67,11 @@ jobs: with: node-version: '12.x' + - name: Install Protoc + uses: arduino/setup-protoc@v1 + with: + version: '3.x' + - name: "Install dependencies" run: yarn install working-directory: "back" From b148ca3708b07abfedb19ec6c948c08f4e6dc1b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Fri, 18 Sep 2020 18:16:26 +0200 Subject: [PATCH 034/122] Linting --- back/src/Controller/IoSocketController.ts | 20 +++++++++++++++----- back/src/Model/Websocket/ProtobufUtils.ts | 6 +++--- front/src/Connection.ts | 2 +- front/src/Network/ProtobufClientUtils.ts | 6 +++--- front/src/Phaser/Game/GameScene.ts | 3 +-- 5 files changed, 23 insertions(+), 14 deletions(-) diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index f3eab483..985e6da2 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -32,7 +32,6 @@ import { import {UserMovesMessage} from "../../../messages/generated/messages_pb"; import Direction = PositionMessage.Direction; import {ProtobufUtils} from "../Model/Websocket/ProtobufUtils"; -import toPositionMessage = ProtobufUtils.toPositionMessage; enum SocketIoEvent { CONNECTION = "connection", @@ -284,6 +283,12 @@ export class IoSocketController { socket.on(SocketIoEvent.USER_POSITION, (message: unknown): void => { //console.log(SockerIoEvent.USER_POSITION, userMovesMessage); try { + if (!(message instanceof Buffer)) { + socket.emit(SocketIoEvent.MESSAGE_ERROR, {message: 'Invalid USER_POSITION message. Expecting binary buffer.'}); + console.warn('Invalid USER_POSITION message received (expecting binary buffer): ', message); + return; + } + const userMovesMessage = UserMovesMessage.deserializeBinary(new Uint8Array(message as ArrayBuffer)); const userMoves = userMovesMessage.toObject(); @@ -375,14 +380,19 @@ export class IoSocketController { }); // Let's send the user id to the user - socket.on(SocketIoEvent.SET_PLAYER_DETAILS, (message: any, answerFn) => { - console.log(SocketIoEvent.SET_PLAYER_DETAILS, message); + socket.on(SocketIoEvent.SET_PLAYER_DETAILS, (message: unknown, answerFn) => { + //console.log(SocketIoEvent.SET_PLAYER_DETAILS, message); + if (!(message instanceof Buffer)) { + socket.emit(SocketIoEvent.MESSAGE_ERROR, {message: 'Invalid SET_PLAYER_DETAILS message. Expecting binary buffer.'}); + console.warn('Invalid SET_PLAYER_DETAILS message received (expecting binary buffer): ', message); + return; + } const playerDetailsMessage = SetPlayerDetailsMessage.deserializeBinary(new Uint8Array(message)); const playerDetails = { name: playerDetailsMessage.getName(), characterLayers: playerDetailsMessage.getCharacterlayersList() }; - console.log(SocketIoEvent.SET_PLAYER_DETAILS, playerDetails); + //console.log(SocketIoEvent.SET_PLAYER_DETAILS, playerDetails); if (!isSetPlayerDetailsMessage(playerDetails)) { socket.emit(SocketIoEvent.MESSAGE_ERROR, {message: 'Invalid SET_PLAYER_DETAILS message.'}); console.warn('Invalid SET_PLAYER_DETAILS message received: ', playerDetails); @@ -547,7 +557,7 @@ export class IoSocketController { const userMovedMessage = new UserMovedMessage(); userMovedMessage.setUserid(clientUser.userId); - userMovedMessage.setPosition(toPositionMessage(clientUser.position)); + userMovedMessage.setPosition(ProtobufUtils.toPositionMessage(clientUser.position)); const subMessage = new SubMessage(); subMessage.setUsermovedmessage(userMovedMessage); diff --git a/back/src/Model/Websocket/ProtobufUtils.ts b/back/src/Model/Websocket/ProtobufUtils.ts index ff73b7c0..516a744e 100644 --- a/back/src/Model/Websocket/ProtobufUtils.ts +++ b/back/src/Model/Websocket/ProtobufUtils.ts @@ -1,11 +1,11 @@ import {PointInterface} from "./PointInterface"; import {PositionMessage} from "../../../../messages/generated/messages_pb"; import {ExSocketInterface} from "_Model/Websocket/ExSocketInterface"; +import Direction = PositionMessage.Direction; -export namespace ProtobufUtils { - import Direction = PositionMessage.Direction; +export class ProtobufUtils { - export function toPositionMessage(point: PointInterface): PositionMessage { + public static toPositionMessage(point: PointInterface): PositionMessage { let direction: PositionMessage.DirectionMap[keyof PositionMessage.DirectionMap]; switch (point.direction) { case 'up': diff --git a/front/src/Connection.ts b/front/src/Connection.ts index 78f107fe..fa04feb8 100644 --- a/front/src/Connection.ts +++ b/front/src/Connection.ts @@ -152,7 +152,7 @@ export class Connection implements Connection { * Messages inside batched messages are extracted and sent to listeners directly. */ this.socket.on(EventMessage.BATCH, (batchedMessagesBinary: ArrayBuffer) => { - const batchMessage = BatchMessage.deserializeBinary(new Uint8Array(batchedMessagesBinary as ArrayBuffer)); + const batchMessage = BatchMessage.deserializeBinary(new Uint8Array(batchedMessagesBinary)); for (const message of batchMessage.getPayloadList()) { let event: string; diff --git a/front/src/Network/ProtobufClientUtils.ts b/front/src/Network/ProtobufClientUtils.ts index 311ba80d..6755025c 100644 --- a/front/src/Network/ProtobufClientUtils.ts +++ b/front/src/Network/ProtobufClientUtils.ts @@ -1,10 +1,10 @@ import {PositionMessage} from "../../../messages/generated/messages_pb"; import {PointInterface} from "../Connection"; +import Direction = PositionMessage.Direction; -export namespace ProtobufClientUtils { - import Direction = PositionMessage.Direction; +export class ProtobufClientUtils { - export function toPointInterface(position: PositionMessage): PointInterface { + public static toPointInterface(position: PositionMessage): PointInterface { let direction: string; switch (position.getDirection()) { case Direction.UP: diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index bf73b31d..c7a7fd3e 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -42,7 +42,6 @@ import {ActionableItem} from "../Items/ActionableItem"; import {UserInputManager} from "../UserInput/UserInputManager"; import {UserMovedMessage} from "../../../../messages/generated/messages_pb"; import {ProtobufClientUtils} from "../../Network/ProtobufClientUtils"; -import toPointInterface = ProtobufClientUtils.toPointInterface; export enum Textures { @@ -224,7 +223,7 @@ export class GameScene extends Phaser.Scene implements CenterListener { const messageUserMoved: MessageUserMovedInterface = { userId: message.getUserid(), - position: toPointInterface(position) + position: ProtobufClientUtils.toPointInterface(position) } this.updatePlayerPosition(messageUserMoved); From 57545a96a595b0a4ded896f544e35eb1f178f202 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Fri, 18 Sep 2020 18:18:39 +0200 Subject: [PATCH 035/122] Removing binary call because missing typescript def --- back/src/Controller/IoSocketController.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index 985e6da2..2334111e 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -59,7 +59,7 @@ function emitInBatch(socket: ExSocketInterface, event: string, payload: SubMessa if (socket.batchTimeout === null) { socket.batchTimeout = setTimeout(() => { - socket.binary(true).emit(SocketIoEvent.BATCH, socket.batchedMessages.serializeBinary().buffer); + socket./*binary(true).*/emit(SocketIoEvent.BATCH, socket.batchedMessages.serializeBinary().buffer); socket.batchedMessages = new BatchMessage(); socket.batchTimeout = null; }, 100); From 4c7e458e52de83434883cdfe8babc0fedb8e8ccd Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Sat, 19 Sep 2020 01:08:56 +0200 Subject: [PATCH 036/122] create event and brodcast event in backend --- back/src/Controller/IoSocketController.ts | 8 +++ front/dist/resources/style/style.css | 37 +++++----- .../src/WebRtc/ConsoleGlobalMessageManager.ts | 70 +++++++++++++++---- front/src/WebRtc/GlobalMessageManager.ts | 32 +++++++-- 4 files changed, 110 insertions(+), 37 deletions(-) diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index 56168804..8033044f 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -24,6 +24,7 @@ import {isUserMovesInterface} from "../Model/Websocket/UserMovesMessage"; import {isViewport} from "../Model/Websocket/ViewportMessage"; import {GroupUpdateInterface} from "_Model/Websocket/GroupUpdateInterface"; import {Movable} from "../Model/Movable"; +import {isUnknown} from "generic-type-guard"; enum SockerIoEvent { CONNECTION = "connection", @@ -44,6 +45,9 @@ enum SockerIoEvent { SET_SILENT = "set_silent", // Set or unset the silent mode for this user. SET_VIEWPORT = "set-viewport", BATCH = "batch", + + PLAY_GLOBAL_MESSAGE = "play-global-message", + STOP_GLOBAL_MESSAGE = "stop-global-message", } function emitInBatch(socket: ExSocketInterface, event: string | symbol, payload: unknown): void { @@ -396,6 +400,10 @@ export class IoSocketController { console.error(e); } }); + + socket.on(SockerIoEvent.PLAY_GLOBAL_MESSAGE, (itemEvent: unknown) => { + socket.broadcast.emit(SockerIoEvent.PLAY_GLOBAL_MESSAGE, itemEvent); + }); }); } diff --git a/front/dist/resources/style/style.css b/front/dist/resources/style/style.css index 39a7af02..90ca3826 100644 --- a/front/dist/resources/style/style.css +++ b/front/dist/resources/style/style.css @@ -404,31 +404,31 @@ body { flex-grow: 5; } -.message-container{ - top: 0; - left: 20%; - position: absolute; - width: 60%; - height: auto; - z-index: 200; - background-color: #00000096; - border-radius: 0 0 10px 10px; -} - +.message-container, .main-console{ position: absolute; width: 80%; - top: 0; + height: 80%; + top: -80%; left: 10%; background: #000000a6; z-index: 200; - height: auto; transition: all 0.1s ease-out; } + +.message-container{ + height: auto; + border-radius: 0 0 10px 10px; + color: white; + padding: 10px; + top: 0; +} + +.message-container div, .main-console div{ position: absolute; background: none repeat scroll 0% 0% #ccc0; - border-color: #000000 #ffffff00 #ffffff00 #ffffff00; + border-color: #000000cf #ffffff00 #ffffff00 #ffffff00; border-style: solid; border-width: 20px 7px; height: auto; @@ -437,16 +437,17 @@ body { z-index: 200; left: 45%; transition: all 0.1s ease-out; - display: none; -} -.main-console div.active{ - display: block; + top: 100%; } + +.message-container div span, .main-console div span{ position: absolute; top: -20px; left: 30%; } + +.message-container div:hover, .main-console div:hover{ cursor: pointer; transform: scale(1.2) translateY(3px); diff --git a/front/src/WebRtc/ConsoleGlobalMessageManager.ts b/front/src/WebRtc/ConsoleGlobalMessageManager.ts index fe7fa216..40f0587e 100644 --- a/front/src/WebRtc/ConsoleGlobalMessageManager.ts +++ b/front/src/WebRtc/ConsoleGlobalMessageManager.ts @@ -13,39 +13,81 @@ export const MESSAGE_TYPE = 'message'; export class ConsoleGlobalMessageManager { private Connection: Connection; + private divMainConsole: HTMLDivElement; + private buttonMainConsole: HTMLDivElement; + private activeConsole: boolean = false; constructor(Connection: Connection) { this.Connection = Connection; + this.buttonMainConsole = document.createElement('div'); + this.divMainConsole = document.createElement('div'); this.initialise(); } - initialise(){ + initialise() { const buttonText = document.createElement('span'); buttonText.innerText = 'Console'; - const buttonMainConsole = document.createElement('div'); - buttonMainConsole.classList.add('active'); - buttonMainConsole.appendChild(buttonText) + this.buttonMainConsole.appendChild(buttonText); + this.buttonMainConsole.addEventListener('click', () => { + if(this.activeConsole){ + this.disabled(); + }else{ + this.active(); + } + }); - const divMainConsole = document.createElement('div'); - divMainConsole.className = CLASS_CONSOLE_MESSAGE; - divMainConsole.appendChild(buttonMainConsole) + this.divMainConsole.className = CLASS_CONSOLE_MESSAGE; + this.divMainConsole.appendChild(this.buttonMainConsole); + + this.createTextMessagePart(); const mainSectionDiv = HtmlUtils.getElementByIdOrFail('main-container'); - mainSectionDiv.appendChild(divMainConsole); + mainSectionDiv.appendChild(this.divMainConsole); } - sendMessage(html: string){ - const inputText = HtmlUtils.getElementByIdOrFail(INPUT_CONSOLE_MESSAGE); - const inputType = HtmlUtils.getElementByIdOrFail(INPUT_TYPE_CONSOLE); - if(AUDIO_TYPE !== inputType.innerText && MESSAGE_TYPE !== inputType.innerText){ + createTextMessagePart(){ + const input = document.createElement('textarea'); + this.divMainConsole.appendChild(input); + input.id = INPUT_CONSOLE_MESSAGE; + const buttonSend = document.createElement('button'); + + buttonSend.innerText = 'Envoyer'; + buttonSend.addEventListener('click', (event: MouseEvent) => { + this.sendMessage(); + this.disabled(); + }); + this.divMainConsole.appendChild(buttonSend); + + const typeConsole = document.createElement('input'); + typeConsole.id = INPUT_TYPE_CONSOLE; + typeConsole.value = MESSAGE_TYPE; + typeConsole.type = 'hidden'; + this.divMainConsole.appendChild(typeConsole); + } + + sendMessage(){ + const inputText = HtmlUtils.getElementByIdOrFail(INPUT_CONSOLE_MESSAGE); + const inputType = HtmlUtils.getElementByIdOrFail(INPUT_TYPE_CONSOLE); + if(AUDIO_TYPE !== inputType.value && MESSAGE_TYPE !== inputType.value){ throw "Error event type"; } let GlobalMessage : GlobalMessageInterface = { id: 1, - message: inputText.innerText, - type: inputType.innerText + message: inputText.value, + type: inputType.value }; + inputText.value = ''; this.Connection.emitGlobalMessage(GlobalMessage); } + + active(){ + this.activeConsole = true; + this.divMainConsole.style.top = '0'; + } + + disabled(){ + this.activeConsole = false; + this.divMainConsole.style.top = '-80%'; + } } \ No newline at end of file diff --git a/front/src/WebRtc/GlobalMessageManager.ts b/front/src/WebRtc/GlobalMessageManager.ts index 29868957..6a0ef7e4 100644 --- a/front/src/WebRtc/GlobalMessageManager.ts +++ b/front/src/WebRtc/GlobalMessageManager.ts @@ -23,13 +23,35 @@ export class GlobalMessageManager { } private playMessage(messageId : number, htmlMessage: string){ - const div = document.createElement('div'); - div.innerHTML = htmlMessage; - div.id = this.getHtmlMessageId(messageId); - div.className = "message-container"; + let previousMessage = document.getElementById(this.getHtmlMessageId(messageId)); + if(previousMessage){ + previousMessage.remove(); + } + + //add button to clear message + const buttonText = document.createElement('span'); + buttonText.id = 'button-clear-message' + buttonText.innerText = 'Clear'; + + const buttonMainConsole = document.createElement('div'); + buttonMainConsole.appendChild(buttonText); + buttonMainConsole.addEventListener('click', () => { + messageContainer.style.top = '-80%'; + setTimeout(() => { + messageContainer.remove(); + buttonMainConsole.remove(); + }); + }); + + //add message container + const messageContainer = document.createElement('div'); + messageContainer.innerHTML = htmlMessage; + messageContainer.id = this.getHtmlMessageId(messageId); + messageContainer.className = "message-container"; + messageContainer.appendChild(buttonMainConsole); const mainSectionDiv = HtmlUtils.getElementByIdOrFail('main-container'); - mainSectionDiv.appendChild(div); + mainSectionDiv.appendChild(messageContainer); } private stopMessage(messageId: number){ From 45ad4bbb36c6852ef2ca6c9e0b711d5c95d6d64c Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Sun, 20 Sep 2020 17:12:27 +0200 Subject: [PATCH 037/122] Send and play audio message --- back/src/Controller/FileController.ts | 40 +++++++++++++++++++ front/dist/resources/style/style.css | 21 +++++----- .../ConsoleGlobalMessageManager.ts | 29 ++++++++++++-- .../GlobalMessageManager.ts | 37 ++++++++++++++--- front/src/Connection.ts | 9 +++++ front/src/Phaser/Game/GameScene.ts | 4 +- front/src/index.ts | 1 - 7 files changed, 117 insertions(+), 24 deletions(-) create mode 100644 back/src/Controller/FileController.ts rename front/src/{WebRtc => Administration}/ConsoleGlobalMessageManager.ts (79%) rename front/src/{WebRtc => Administration}/GlobalMessageManager.ts (61%) diff --git a/back/src/Controller/FileController.ts b/back/src/Controller/FileController.ts new file mode 100644 index 00000000..162429dc --- /dev/null +++ b/back/src/Controller/FileController.ts @@ -0,0 +1,40 @@ +import {Application, Request, Response} from "express"; +import {OK} from "http-status-codes"; +import {URL_ROOM_STARTED} from "_Enum/EnvironmentVariable"; +import {uuid} from "uuidv4"; + +export class FileController { + App : Application; + + constructor(App : Application) { + this.App = App; + this.uploadAudioMessage(); + this.downloadAudioMessage(); + } + + uploadAudioMessage(){ + this.App.post("/upload-audio-message", (req: Request, res: Response) => { + //TODO check user connected and admin role + //TODO upload audio message + const audioMessageId = uuid(); + return res.status(OK).send({ + id: audioMessageId, + audioMessageUrl: `/audi-message/${audioMessageId}`, + }); + }); + } + + downloadAudioMessage(){ + this.App.post("/download-audio-message/:id", (req: Request, res: Response) => { + //TODO check user connected and admin role + //TODO upload audio message + let audiMessageId = req.params.id; + + let fs = require('fs'); + let path = `/dist/files/${audiMessageId}`; + let file = fs.createReadStream(path); + res.writeHead(200); + file.pipe(res); + }); + } +} \ No newline at end of file diff --git a/front/dist/resources/style/style.css b/front/dist/resources/style/style.css index 90ca3826..bf66bf3d 100644 --- a/front/dist/resources/style/style.css +++ b/front/dist/resources/style/style.css @@ -427,24 +427,21 @@ body { .message-container div, .main-console div{ position: absolute; - background: none repeat scroll 0% 0% #ccc0; - border-color: #000000cf #ffffff00 #ffffff00 #ffffff00; - border-style: solid; - border-width: 20px 7px; - height: auto; - width: 10%; color: white; z-index: 200; - left: 45%; transition: all 0.1s ease-out; top: 100%; + width: 100px; + height: 40px; + background-color: black; + left: calc(50% - 50px); + border-radius: 0 0 10px 10px; + text-align: center; } -.message-container div span, -.main-console div span{ - position: absolute; - top: -20px; - left: 30%; +.message-container div p, +.main-console div p{ + margin-top: 6px; } .message-container div:hover, diff --git a/front/src/WebRtc/ConsoleGlobalMessageManager.ts b/front/src/Administration/ConsoleGlobalMessageManager.ts similarity index 79% rename from front/src/WebRtc/ConsoleGlobalMessageManager.ts rename to front/src/Administration/ConsoleGlobalMessageManager.ts index 40f0587e..61bdc744 100644 --- a/front/src/WebRtc/ConsoleGlobalMessageManager.ts +++ b/front/src/Administration/ConsoleGlobalMessageManager.ts @@ -1,4 +1,4 @@ -import {HtmlUtils} from "./HtmlUtils"; +import {HtmlUtils} from "../WebRtc/HtmlUtils"; import {Connection, GlobalMessageInterface} from "../Connection"; export const CLASS_CONSOLE_MESSAGE = 'main-console'; @@ -25,7 +25,7 @@ export class ConsoleGlobalMessageManager { } initialise() { - const buttonText = document.createElement('span'); + const buttonText = document.createElement('p'); buttonText.innerText = 'Console'; this.buttonMainConsole.appendChild(buttonText); @@ -67,20 +67,41 @@ export class ConsoleGlobalMessageManager { } sendMessage(){ - const inputText = HtmlUtils.getElementByIdOrFail(INPUT_CONSOLE_MESSAGE); const inputType = HtmlUtils.getElementByIdOrFail(INPUT_TYPE_CONSOLE); if(AUDIO_TYPE !== inputType.value && MESSAGE_TYPE !== inputType.value){ throw "Error event type"; } + if(AUDIO_TYPE !== inputType.value){ + return this.sendAudioMessage(); + } + return this.sendTextMessage(); + } + + private sendTextMessage(){ + const inputText = HtmlUtils.getElementByIdOrFail(INPUT_CONSOLE_MESSAGE); let GlobalMessage : GlobalMessageInterface = { id: 1, message: inputText.value, - type: inputType.value + type: MESSAGE_TYPE }; inputText.value = ''; this.Connection.emitGlobalMessage(GlobalMessage); } + private async sendAudioMessage(){ + const inputAudio = HtmlUtils.getElementByIdOrFail(UPLOAD_CONSOLE_MESSAGE); + let res = await this.Connection.uploadAudio(inputAudio.value); + + let GlobalMessage : GlobalMessageInterface = { + id: res.id, + message: res.audioMessageUrl, + type: MESSAGE_TYPE + }; + inputAudio.value = ''; + this.Connection.emitGlobalMessage(GlobalMessage); + } + + active(){ this.activeConsole = true; this.divMainConsole.style.top = '0'; diff --git a/front/src/WebRtc/GlobalMessageManager.ts b/front/src/Administration/GlobalMessageManager.ts similarity index 61% rename from front/src/WebRtc/GlobalMessageManager.ts rename to front/src/Administration/GlobalMessageManager.ts index 6a0ef7e4..ec1693f8 100644 --- a/front/src/WebRtc/GlobalMessageManager.ts +++ b/front/src/Administration/GlobalMessageManager.ts @@ -1,5 +1,6 @@ -import {HtmlUtils} from "./HtmlUtils"; +import {HtmlUtils} from "./../WebRtc/HtmlUtils"; import {Connection, GlobalMessageInterface} from "../Connection"; +import {AUDIO_TYPE, MESSAGE_TYPE} from "./ConsoleGlobalMessageManager"; export class GlobalMessageManager { @@ -13,7 +14,7 @@ export class GlobalMessageManager { initialise(){ //receive signal to show message this.Connection.receivePlayGlobalMessage((message: GlobalMessageInterface) => { - this.playMessage(message.id, message.message); + this.playMessage(message); }); //receive signal to close message @@ -22,14 +23,40 @@ export class GlobalMessageManager { }); } - private playMessage(messageId : number, htmlMessage: string){ - let previousMessage = document.getElementById(this.getHtmlMessageId(messageId)); + private playMessage(message : GlobalMessageInterface){ + let previousMessage = document.getElementById(this.getHtmlMessageId(message.id)); if(previousMessage){ previousMessage.remove(); } + if(AUDIO_TYPE === message.type){ + this.playAudioMessage(message.id, message.message); + } + + if(MESSAGE_TYPE === message.type){ + this.playTextMessage(message.id, message.message); + } + } + + private playAudioMessage(messageId : number, urlMessage: string){ + const messageVideo : HTMLAudioElement = document.createElement('audio'); + messageVideo.id = this.getHtmlMessageId(messageId); + messageVideo.src = urlMessage; + messageVideo.onended = () => { + messageVideo.remove(); + } + messageVideo.onloadeddata = () => { + messageVideo.play(); + }; + const mainSectionDiv = HtmlUtils.getElementByIdOrFail('main-container'); + mainSectionDiv.appendChild(messageVideo); + + //TODO add element when audio message is played + } + + private playTextMessage(messageId : number, htmlMessage: string){ //add button to clear message - const buttonText = document.createElement('span'); + const buttonText = document.createElement('p'); buttonText.id = 'button-clear-message' buttonText.innerText = 'Clear'; diff --git a/front/src/Connection.ts b/front/src/Connection.ts index 1341347b..f8aeb9bc 100644 --- a/front/src/Connection.ts +++ b/front/src/Connection.ts @@ -199,6 +199,15 @@ export class Connection implements Connection { }); } + public uploadAudio(file : any){ + return Axios.post(`${API_URL}/upload-audio-message`, {file}).then((res: any) => { + return res.data; + }).catch((err) => { + console.error(err); + throw err; + }); + } + public closeConnection(): void { this.socket?.close(); } diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 332c3bcd..15b269ae 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -40,8 +40,8 @@ import {FourOFourSceneName} from "../Reconnecting/FourOFourScene"; import {ItemFactoryInterface} from "../Items/ItemFactoryInterface"; import {ActionableItem} from "../Items/ActionableItem"; import {UserInputManager} from "../UserInput/UserInputManager"; -import {GlobalMessageManager} from "../../WebRtc/GlobalMessageManager"; -import {ConsoleGlobalMessageManager} from "../../WebRtc/ConsoleGlobalMessageManager"; +import {GlobalMessageManager} from "../../Administration/GlobalMessageManager"; +import {ConsoleGlobalMessageManager} from "../../Administration/ConsoleGlobalMessageManager"; export enum Textures { diff --git a/front/src/index.ts b/front/src/index.ts index 2356bd0a..8009843e 100644 --- a/front/src/index.ts +++ b/front/src/index.ts @@ -10,7 +10,6 @@ import {FourOFourScene} from "./Phaser/Reconnecting/FourOFourScene"; import WebGLRenderer = Phaser.Renderer.WebGL.WebGLRenderer; import {OutlinePipeline} from "./Phaser/Shaders/OutlinePipeline"; import {CustomizeScene} from "./Phaser/Login/CustomizeScene"; -import {HtmlUtils} from "./WebRtc/HtmlUtils"; import {CoWebsiteManager} from "./WebRtc/CoWebsiteManager"; //CoWebsiteManager.loadCoWebsite('https://thecodingmachine.com'); From 844bffa98813e7098f366386f60344b4b24df67e Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Sun, 20 Sep 2020 19:01:21 +0200 Subject: [PATCH 038/122] Create file controller to upload audio document --- back/package.json | 2 + back/src/App.ts | 3 + back/src/Controller/FileController.ts | 24 ++- back/yarn.lock | 142 +++++++++++++++++- .../ConsoleGlobalMessageManager.ts | 15 +- front/src/Connection.ts | 4 +- 6 files changed, 171 insertions(+), 19 deletions(-) diff --git a/back/package.json b/back/package.json index a20c876f..b061e5a5 100644 --- a/back/package.json +++ b/back/package.json @@ -39,6 +39,7 @@ "@types/express": "^4.17.4", "@types/http-status-codes": "^1.2.0", "@types/jsonwebtoken": "^8.3.8", + "@types/multer": "^1.4.4", "@types/socket.io": "^2.1.4", "@types/uuidv4": "^5.0.0", "body-parser": "^1.19.0", @@ -46,6 +47,7 @@ "generic-type-guard": "^3.2.0", "http-status-codes": "^1.4.0", "jsonwebtoken": "^8.5.1", + "multer": "^1.4.2", "prom-client": "^12.0.0", "socket.io": "^2.3.0", "systeminformation": "^4.26.5", diff --git a/back/src/App.ts b/back/src/App.ts index e12afdb4..401f93fc 100644 --- a/back/src/App.ts +++ b/back/src/App.ts @@ -7,12 +7,14 @@ import bodyParser = require('body-parser'); import * as http from "http"; import {MapController} from "./Controller/MapController"; import {PrometheusController} from "./Controller/PrometheusController"; +import {FileController} from "./Controller/FileController"; class App { public app: Application; public server: http.Server; public ioSocketController: IoSocketController; public authenticateController: AuthenticateController; + public fileController: FileController; public mapController: MapController; public prometheusController: PrometheusController; @@ -30,6 +32,7 @@ class App { //create socket controllers this.ioSocketController = new IoSocketController(this.server); this.authenticateController = new AuthenticateController(this.app); + this.fileController = new FileController(this.app); this.mapController = new MapController(this.app); this.prometheusController = new PrometheusController(this.app, this.ioSocketController); } diff --git a/back/src/Controller/FileController.ts b/back/src/Controller/FileController.ts index 162429dc..a337537f 100644 --- a/back/src/Controller/FileController.ts +++ b/back/src/Controller/FileController.ts @@ -1,7 +1,11 @@ -import {Application, Request, Response} from "express"; +import {Application, Request, RequestHandler, Response} from "express"; import {OK} from "http-status-codes"; import {URL_ROOM_STARTED} from "_Enum/EnvironmentVariable"; import {uuid} from "uuidv4"; +import multer from 'multer'; +import fs from "fs"; + +const upload = multer({ dest: 'dist/files/' }); export class FileController { App : Application; @@ -13,26 +17,30 @@ export class FileController { } uploadAudioMessage(){ - this.App.post("/upload-audio-message", (req: Request, res: Response) => { + this.App.post("/upload-audio-message", (upload.single('file') as RequestHandler), (req: Request, res: Response) => { //TODO check user connected and admin role //TODO upload audio message const audioMessageId = uuid(); + + fs.copyFileSync(req.file.path, `dist/files/${audioMessageId}`); + fs.unlinkSync(req.file.path); + return res.status(OK).send({ id: audioMessageId, - audioMessageUrl: `/audi-message/${audioMessageId}`, + path: `/download-audio-message/${audioMessageId}` }); }); } downloadAudioMessage(){ - this.App.post("/download-audio-message/:id", (req: Request, res: Response) => { + this.App.get("/download-audio-message/:id", (req: Request, res: Response) => { //TODO check user connected and admin role //TODO upload audio message - let audiMessageId = req.params.id; + const audiMessageId = req.params.id; - let fs = require('fs'); - let path = `/dist/files/${audiMessageId}`; - let file = fs.createReadStream(path); + const fs = require('fs'); + const path = `dist/files/${audiMessageId}`; + const file = fs.createReadStream(path); res.writeHead(200); file.pipe(res); }); diff --git a/back/yarn.lock b/back/yarn.lock index f660a5c8..83ab3c54 100644 --- a/back/yarn.lock +++ b/back/yarn.lock @@ -48,6 +48,16 @@ "@types/node" "*" "@types/range-parser" "*" +"@types/express@*": + version "4.17.8" + resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.8.tgz#3df4293293317e61c60137d273a2e96cd8d5f27a" + integrity sha512-wLhcKh3PMlyA2cNAB9sjM1BntnhPMiM0JOBwPBqttjHev2428MLEB4AYVN+d8s2iyCVZac+o41Pflm/ZH5vLXQ== + dependencies: + "@types/body-parser" "*" + "@types/express-serve-static-core" "*" + "@types/qs" "*" + "@types/serve-static" "*" + "@types/express@^4.17.4": version "4.17.4" resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.4.tgz#e78bf09f3f530889575f4da8a94cd45384520aac" @@ -81,6 +91,13 @@ version "2.0.1" resolved "https://registry.yarnpkg.com/@types/mime/-/mime-2.0.1.tgz#dc488842312a7f075149312905b5e3c0b054c79d" +"@types/multer@^1.4.4": + version "1.4.4" + resolved "https://registry.yarnpkg.com/@types/multer/-/multer-1.4.4.tgz#bb5d9abc410da82726ceca74008bb81813349a88" + integrity sha512-wdfkiKBBEMTODNbuF3J+qDDSqJxt50yB9pgDiTcFew7f97Gcc7/sM4HR66ofGgpJPOALWOqKAch4gPyqEXSkeQ== + dependencies: + "@types/express" "*" + "@types/node@*": version "13.11.0" resolved "https://registry.yarnpkg.com/@types/node/-/node-13.11.0.tgz#390ea202539c61c8fa6ba4428b57e05bc36dc47b" @@ -214,6 +231,11 @@ ansi-styles@^4.1.0: "@types/color-name" "^1.1.1" color-convert "^2.0.1" +append-field@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/append-field/-/append-field-1.0.0.tgz#1e3440e915f0b1203d23748e78edd7b9b5b43e56" + integrity sha1-HjRA6RXwsSA9I3SOeO3XubW0PlY= + arg@^4.1.0: version "4.1.3" resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" @@ -305,6 +327,14 @@ buffer-from@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" +busboy@^0.2.11: + version "0.2.14" + resolved "https://registry.yarnpkg.com/busboy/-/busboy-0.2.14.tgz#6c2a622efcf47c57bbbe1e2a9c37ad36c7925453" + integrity sha1-bCpiLvz0fFe7vh4qnDetNseSVFM= + dependencies: + dicer "0.2.5" + readable-stream "1.1.x" + bytes@3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.0.tgz#f6cf7933a360e0588fa9fde85651cdc7f805d1f6" @@ -393,6 +423,16 @@ concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" +concat-stream@^1.5.2: + version "1.6.2" + resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.2.tgz#904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34" + integrity sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw== + dependencies: + buffer-from "^1.0.0" + inherits "^2.0.3" + readable-stream "^2.2.2" + typedarray "^0.0.6" + content-disposition@0.5.3: version "0.5.3" resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.3.tgz#e130caf7e7279087c5616c2007d0485698984fbd" @@ -415,6 +455,11 @@ cookie@0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.0.tgz#beb437e7022b3b6d49019d088665303ebe9c14ba" +core-util-is@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" + integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= + cross-spawn@^6.0.5: version "6.0.5" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" @@ -476,6 +521,14 @@ destroy@~1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.0.4.tgz#978857442c44749e4206613e37946205826abd80" +dicer@0.2.5: + version "0.2.5" + resolved "https://registry.yarnpkg.com/dicer/-/dicer-0.2.5.tgz#5996c086bb33218c812c090bddc09cd12facb70f" + integrity sha1-WZbAhrszIYyBLAkL3cCc0S+stw8= + dependencies: + readable-stream "1.1.x" + streamsearch "0.1.2" + diff@^4.0.1: version "4.0.2" resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" @@ -914,7 +967,7 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherits@2, inherits@2.0.4: +inherits@2, inherits@2.0.4, inherits@^2.0.3, inherits@~2.0.1, inherits@~2.0.3: version "2.0.4" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" @@ -982,10 +1035,20 @@ is-wsl@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-1.1.0.tgz#1f16e4aa22b04d1336b66188a66af3c600c3a66d" +isarray@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" + integrity sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8= + isarray@2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/isarray/-/isarray-2.0.1.tgz#a37d94ed9cda2d59865c9f76fe596ee1f338741e" +isarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" + integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE= + isexe@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" @@ -1187,6 +1250,20 @@ ms@^2.1.1: version "2.1.2" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" +multer@^1.4.2: + version "1.4.2" + resolved "https://registry.yarnpkg.com/multer/-/multer-1.4.2.tgz#2f1f4d12dbaeeba74cb37e623f234bf4d3d2057a" + integrity sha512-xY8pX7V+ybyUpbYMxtjM9KAiD9ixtg5/JkeKUTD6xilfDv0vzzOFcCp4Ljb1UU3tSOM3VTZtKo63OmzOrGi3Cg== + dependencies: + append-field "^1.0.0" + busboy "^0.2.11" + concat-stream "^1.5.2" + mkdirp "^0.5.1" + object-assign "^4.1.1" + on-finished "^2.3.0" + type-is "^1.6.4" + xtend "^4.0.0" + mute-stream@0.0.8: version "0.0.8" resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d" @@ -1222,7 +1299,7 @@ normalize-package-data@^2.3.2, normalize-package-data@^2.3.4: semver "2 || 3 || 4 || 5" validate-npm-package-license "^3.0.1" -object-assign@^4.0.1: +object-assign@^4.0.1, object-assign@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" @@ -1230,7 +1307,7 @@ object-component@0.0.3: version "0.0.3" resolved "https://registry.yarnpkg.com/object-component/-/object-component-0.0.3.tgz#f0c69aa50efc95b866c186f400a33769cb2f1291" -on-finished@~2.3.0: +on-finished@^2.3.0, on-finished@~2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947" dependencies: @@ -1339,6 +1416,11 @@ prelude-ls@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" +process-nextick-args@~2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" + integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag== + progress@^2.0.0: version "2.0.3" resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8" @@ -1393,6 +1475,29 @@ read-pkg@^1.0.0: normalize-package-data "^2.3.2" path-type "^1.0.0" +readable-stream@1.1.x: + version "1.1.14" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.1.14.tgz#7cf4c54ef648e3813084c636dd2079e166c081d9" + integrity sha1-fPTFTvZI44EwhMY23SB54WbAgdk= + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "0.0.1" + string_decoder "~0.10.x" + +readable-stream@^2.2.2: + version "2.3.7" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57" + integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw== + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.3" + isarray "~1.0.0" + process-nextick-args "~2.0.0" + safe-buffer "~5.1.1" + string_decoder "~1.1.1" + util-deprecate "~1.0.1" + redent@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/redent/-/redent-1.0.0.tgz#cf916ab1fd5f1f16dfb20822dd6ec7f730c2afde" @@ -1455,7 +1560,7 @@ rxjs@^6.5.3: dependencies: tslib "^1.9.0" -safe-buffer@5.1.2: +safe-buffer@5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1: version "5.1.2" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" @@ -1623,6 +1728,11 @@ sprintf-js@~1.0.2: version "1.5.0" resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" +streamsearch@0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/streamsearch/-/streamsearch-0.1.2.tgz#808b9d0e56fc273d809ba57338e929919a1a9f1a" + integrity sha1-gIudDlb8Jz2Am6VzOOkpkZoanxo= + string-width@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/string-width/-/string-width-3.1.0.tgz#22767be21b62af1081574306f69ac51b62203961" @@ -1639,6 +1749,18 @@ string-width@^4.1.0: is-fullwidth-code-point "^3.0.0" strip-ansi "^6.0.0" +string_decoder@~0.10.x: + version "0.10.31" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" + integrity sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ= + +string_decoder@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" + integrity sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg== + dependencies: + safe-buffer "~5.1.0" + strip-ansi@^5.1.0, strip-ansi@^5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-5.2.0.tgz#8c9a536feb6afc962bdfa5b104a5091c1ad9c0ae" @@ -1797,13 +1919,18 @@ type-fest@^0.8.1: version "0.8.1" resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.8.1.tgz#09e249ebde851d3b1e48d27c105444667f17b83d" -type-is@~1.6.17, type-is@~1.6.18: +type-is@^1.6.4, type-is@~1.6.17, type-is@~1.6.18: version "1.6.18" resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.18.tgz#4e552cd05df09467dcbc4ef739de89f2cf37c131" dependencies: media-typer "0.3.0" mime-types "~2.1.24" +typedarray@^0.0.6: + version "0.0.6" + resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" + integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= + typescript@^3.8.3: version "3.8.3" resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.8.3.tgz#409eb8544ea0335711205869ec458ab109ee1061" @@ -1818,6 +1945,11 @@ uri-js@^4.2.2: dependencies: punycode "^2.1.0" +util-deprecate@~1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" + integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= + utils-merge@1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" diff --git a/front/src/Administration/ConsoleGlobalMessageManager.ts b/front/src/Administration/ConsoleGlobalMessageManager.ts index 61bdc744..4a76a0d2 100644 --- a/front/src/Administration/ConsoleGlobalMessageManager.ts +++ b/front/src/Administration/ConsoleGlobalMessageManager.ts @@ -71,7 +71,7 @@ export class ConsoleGlobalMessageManager { if(AUDIO_TYPE !== inputType.value && MESSAGE_TYPE !== inputType.value){ throw "Error event type"; } - if(AUDIO_TYPE !== inputType.value){ + if(AUDIO_TYPE === inputType.value){ return this.sendAudioMessage(); } return this.sendTextMessage(); @@ -89,12 +89,19 @@ export class ConsoleGlobalMessageManager { } private async sendAudioMessage(){ - const inputAudio = HtmlUtils.getElementByIdOrFail(UPLOAD_CONSOLE_MESSAGE); - let res = await this.Connection.uploadAudio(inputAudio.value); + const inputAudio = HtmlUtils.getElementByIdOrFail(UPLOAD_CONSOLE_MESSAGE); + const selectedFile = inputAudio.files ? inputAudio.files[0] : null; + if(!selectedFile){ + throw 'no file selected'; + } + + const fd = new FormData(); + fd.append('file', selectedFile); + let res = await this.Connection.uploadAudio(fd); let GlobalMessage : GlobalMessageInterface = { id: res.id, - message: res.audioMessageUrl, + message: res.path, type: MESSAGE_TYPE }; inputAudio.value = ''; diff --git a/front/src/Connection.ts b/front/src/Connection.ts index f8aeb9bc..66a133f3 100644 --- a/front/src/Connection.ts +++ b/front/src/Connection.ts @@ -199,8 +199,8 @@ export class Connection implements Connection { }); } - public uploadAudio(file : any){ - return Axios.post(`${API_URL}/upload-audio-message`, {file}).then((res: any) => { + public uploadAudio(file : FormData){ + return Axios.post(`${API_URL}/upload-audio-message`, file).then((res: any) => { return res.data; }).catch((err) => { console.error(err); From 9b955ebd20fe819ab64c4158cbc65490e5bb2f1d Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Sun, 20 Sep 2020 19:31:24 +0200 Subject: [PATCH 039/122] fix style quill box --- front/dist/index.html | 9 ++++ front/dist/resources/style/style.css | 26 +++++++--- .../ConsoleGlobalMessageManager.ts | 51 ++++++++++++++++--- 3 files changed, 74 insertions(+), 12 deletions(-) diff --git a/front/dist/index.html b/front/dist/index.html index 4fd514a8..f885079a 100644 --- a/front/dist/index.html +++ b/front/dist/index.html @@ -6,6 +6,12 @@ content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> + + + + + + + @@ -40,6 +47,7 @@
+
@@ -120,5 +128,6 @@ + diff --git a/front/dist/resources/style/style.css b/front/dist/resources/style/style.css index bf66bf3d..6ad80d88 100644 --- a/front/dist/resources/style/style.css +++ b/front/dist/resources/style/style.css @@ -409,6 +409,7 @@ body { position: absolute; width: 80%; height: 80%; + min-height: 200px; top: -80%; left: 10%; background: #000000a6; @@ -424,8 +425,8 @@ body { top: 0; } -.message-container div, -.main-console div{ +.main-console div.console, +.message-container div { position: absolute; color: white; z-index: 200; @@ -439,13 +440,26 @@ body { text-align: center; } -.message-container div p, -.main-console div p{ +.main-console div.console p, +.message-container div p{ margin-top: 6px; } -.message-container div:hover, -.main-console div:hover{ +.main-console div.console:hover, +.message-container div:hover { cursor: pointer; transform: scale(1.2) translateY(3px); +} + +.main-console #input-send-text{ + min-height: 200px; +} + +.main-console #input-send-text .ql-editor{ + color: white; + min-height: 200px; +} + +.main-console .ql-toolbar{ + background: white; } \ No newline at end of file diff --git a/front/src/Administration/ConsoleGlobalMessageManager.ts b/front/src/Administration/ConsoleGlobalMessageManager.ts index 4a76a0d2..7be459d4 100644 --- a/front/src/Administration/ConsoleGlobalMessageManager.ts +++ b/front/src/Administration/ConsoleGlobalMessageManager.ts @@ -1,3 +1,5 @@ +const Quill = require("quill"); + import {HtmlUtils} from "../WebRtc/HtmlUtils"; import {Connection, GlobalMessageInterface} from "../Connection"; @@ -20,6 +22,7 @@ export class ConsoleGlobalMessageManager { constructor(Connection: Connection) { this.Connection = Connection; this.buttonMainConsole = document.createElement('div'); + this.buttonMainConsole.classList.add('console'); this.divMainConsole = document.createElement('div'); this.initialise(); } @@ -47,23 +50,59 @@ export class ConsoleGlobalMessageManager { } createTextMessagePart(){ - const input = document.createElement('textarea'); - this.divMainConsole.appendChild(input); - input.id = INPUT_CONSOLE_MESSAGE; - const buttonSend = document.createElement('button'); + const div = document.createElement('div'); + div.id = INPUT_CONSOLE_MESSAGE; + const buttonSend = document.createElement('button'); buttonSend.innerText = 'Envoyer'; buttonSend.addEventListener('click', (event: MouseEvent) => { this.sendMessage(); this.disabled(); }); - this.divMainConsole.appendChild(buttonSend); const typeConsole = document.createElement('input'); typeConsole.id = INPUT_TYPE_CONSOLE; typeConsole.value = MESSAGE_TYPE; typeConsole.type = 'hidden'; - this.divMainConsole.appendChild(typeConsole); + + const section = document.createElement('section'); + section.appendChild(buttonSend); + section.appendChild(typeConsole); + section.appendChild(div); + this.divMainConsole.appendChild(section); + + //TODO refactor + setTimeout(() => { + const toolbarOptions = [ + ['bold', 'italic', 'underline', 'strike'], // toggled buttons + ['blockquote', 'code-block'], + + [{ 'header': 1 }, { 'header': 2 }], // custom button values + [{ 'list': 'ordered'}, { 'list': 'bullet' }], + [{ 'script': 'sub'}, { 'script': 'super' }], // superscript/subscript + [{ 'indent': '-1'}, { 'indent': '+1' }], // outdent/indent + [{ 'direction': 'rtl' }], // text direction + + [{ 'size': ['small', false, 'large', 'huge'] }], // custom dropdown + [{ 'header': [1, 2, 3, 4, 5, 6, false] }], + + [{ 'color': [] }, { 'background': [] }], // dropdown with defaults from theme + [{ 'font': [] }], + [{ 'align': [] }], + + ['clean'], + + ['link', 'image', 'video'] + // remove formatting button + ]; + + let quill = new Quill(`#${INPUT_CONSOLE_MESSAGE}`, { + theme: 'snow', + modules: { + toolbar: toolbarOptions + }, + }); + }, 1000); } sendMessage(){ From e0ae79eaf17e91bf237f2f70b96846535f9035e9 Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Mon, 21 Sep 2020 00:34:25 +0200 Subject: [PATCH 040/122] Fini quill box --- front/dist/resources/style/style.css | 21 +++++++++++ .../ConsoleGlobalMessageManager.ts | 18 ++++++++-- front/src/Phaser/Game/GameScene.ts | 5 +-- .../src/Phaser/UserInput/UserInputManager.ts | 35 ++++++++++++------- 4 files changed, 61 insertions(+), 18 deletions(-) diff --git a/front/dist/resources/style/style.css b/front/dist/resources/style/style.css index 6ad80d88..31fb8b51 100644 --- a/front/dist/resources/style/style.css +++ b/front/dist/resources/style/style.css @@ -462,4 +462,25 @@ body { .main-console .ql-toolbar{ background: white; +} + +.main-console .btn-action{ + margin: 10px; + text-align: center; +} + +.main-console .btn-action .btn{ + border: 1px solid black; + background-color: #00000000; + color: #ffda01; + border-radius: 10px; + padding: 10px 30px; + transition: all .2s ease; +} +.main-console .btn-action .btn:hover{ + cursor: pointer; + background-color: #ffda01; + color: black; + border: 1px solid black; + transform: scale(1.1); } \ No newline at end of file diff --git a/front/src/Administration/ConsoleGlobalMessageManager.ts b/front/src/Administration/ConsoleGlobalMessageManager.ts index 7be459d4..2c576cba 100644 --- a/front/src/Administration/ConsoleGlobalMessageManager.ts +++ b/front/src/Administration/ConsoleGlobalMessageManager.ts @@ -1,7 +1,10 @@ +import {GameScene} from "../Phaser/Game/GameScene"; + const Quill = require("quill"); import {HtmlUtils} from "../WebRtc/HtmlUtils"; import {Connection, GlobalMessageInterface} from "../Connection"; +import {UserInputManager} from "../Phaser/UserInput/UserInputManager"; export const CLASS_CONSOLE_MESSAGE = 'main-console'; export const INPUT_CONSOLE_MESSAGE = 'input-send-text'; @@ -18,12 +21,14 @@ export class ConsoleGlobalMessageManager { private divMainConsole: HTMLDivElement; private buttonMainConsole: HTMLDivElement; private activeConsole: boolean = false; + private userInputManager!: UserInputManager; - constructor(Connection: Connection) { + constructor(Connection: Connection, userInputManager : UserInputManager) { this.Connection = Connection; this.buttonMainConsole = document.createElement('div'); this.buttonMainConsole.classList.add('console'); this.divMainConsole = document.createElement('div'); + this.userInputManager = userInputManager; this.initialise(); } @@ -55,10 +60,14 @@ export class ConsoleGlobalMessageManager { const buttonSend = document.createElement('button'); buttonSend.innerText = 'Envoyer'; + buttonSend.classList.add('btn'); buttonSend.addEventListener('click', (event: MouseEvent) => { this.sendMessage(); this.disabled(); }); + const buttonDiv = document.createElement('div'); + buttonDiv.classList.add('btn-action'); + buttonDiv.appendChild(buttonSend) const typeConsole = document.createElement('input'); typeConsole.id = INPUT_TYPE_CONSOLE; @@ -66,9 +75,9 @@ export class ConsoleGlobalMessageManager { typeConsole.type = 'hidden'; const section = document.createElement('section'); - section.appendChild(buttonSend); - section.appendChild(typeConsole); section.appendChild(div); + section.appendChild(buttonDiv); + section.appendChild(typeConsole); this.divMainConsole.appendChild(section); //TODO refactor @@ -102,6 +111,7 @@ export class ConsoleGlobalMessageManager { toolbar: toolbarOptions }, }); + }, 1000); } @@ -149,11 +159,13 @@ export class ConsoleGlobalMessageManager { active(){ + this.userInputManager.clearAllInputKeyboard(); this.activeConsole = true; this.divMainConsole.style.top = '0'; } disabled(){ + this.userInputManager.initKeyBoardEvent(); this.activeConsole = false; this.divMainConsole.style.top = '-80%'; } diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 15b269ae..654b9d75 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -270,8 +270,6 @@ export class GameScene extends Phaser.Scene implements CenterListener { // When connection is performed, let's connect SimplePeer this.simplePeer = new SimplePeer(this.connection); this.GlobalMessageManager = new GlobalMessageManager(this.connection); - //TODO check right of user - this.ConsoleGlobalMessageManager = new ConsoleGlobalMessageManager(this.connection); const self = this; this.simplePeer.registerPeerConnectionListener({ @@ -483,6 +481,9 @@ export class GameScene extends Phaser.Scene implements CenterListener { //create input to move this.userInputManager = new UserInputManager(this); + //TODO check right of user + this.ConsoleGlobalMessageManager = new ConsoleGlobalMessageManager(this.connection, this.userInputManager); + //notify game manager can to create currentUser in map this.createCurrentPlayer(); diff --git a/front/src/Phaser/UserInput/UserInputManager.ts b/front/src/Phaser/UserInput/UserInputManager.ts index d40d149e..a7be41cf 100644 --- a/front/src/Phaser/UserInput/UserInputManager.ts +++ b/front/src/Phaser/UserInput/UserInputManager.ts @@ -29,29 +29,38 @@ export class ActiveEventList { //this class is responsible for catching user inputs and listing all active user actions at every game tick events. export class UserInputManager { - private KeysCode: UserInputManagerDatum[]; + private KeysCode!: UserInputManagerDatum[]; + private Scene: GameScene; constructor(Scene : GameScene) { + this.Scene = Scene; + this.initKeyBoardEvent(); + } + initKeyBoardEvent(){ this.KeysCode = [ - {event: UserInputEvent.MoveUp, keyInstance: Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.Z) }, - {event: UserInputEvent.MoveLeft, keyInstance: Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.Q) }, - {event: UserInputEvent.MoveDown, keyInstance: Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.S) }, - {event: UserInputEvent.MoveRight, keyInstance: Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.D) }, + {event: UserInputEvent.MoveUp, keyInstance: this.Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.Z) }, + {event: UserInputEvent.MoveLeft, keyInstance: this.Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.Q) }, + {event: UserInputEvent.MoveDown, keyInstance: this.Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.S) }, + {event: UserInputEvent.MoveRight, keyInstance: this.Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.D) }, - {event: UserInputEvent.MoveUp, keyInstance: Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.UP) }, - {event: UserInputEvent.MoveLeft, keyInstance: Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.LEFT) }, - {event: UserInputEvent.MoveDown, keyInstance: Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.DOWN) }, - {event: UserInputEvent.MoveRight, keyInstance: Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.RIGHT) }, + {event: UserInputEvent.MoveUp, keyInstance: this.Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.UP) }, + {event: UserInputEvent.MoveLeft, keyInstance: this.Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.LEFT) }, + {event: UserInputEvent.MoveDown, keyInstance: this.Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.DOWN) }, + {event: UserInputEvent.MoveRight, keyInstance: this.Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.RIGHT) }, - {event: UserInputEvent.SpeedUp, keyInstance: Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SHIFT) }, + {event: UserInputEvent.SpeedUp, keyInstance: this.Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SHIFT) }, - {event: UserInputEvent.Interact, keyInstance: Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.E) }, - {event: UserInputEvent.Interact, keyInstance: Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE) }, - {event: UserInputEvent.Shout, keyInstance: Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.F) }, + {event: UserInputEvent.Interact, keyInstance: this.Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.E) }, + {event: UserInputEvent.Interact, keyInstance: this.Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE) }, + {event: UserInputEvent.Shout, keyInstance: this.Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.F) }, ]; } + clearAllInputKeyboard(){ + this.Scene.input.keyboard.removeAllKeys(); + } + getEventListForGameTick(): ActiveEventList { const eventsMap = new ActiveEventList(); this.KeysCode.forEach(d => { From 1829912c91ff02bbc4af086056085cf6c32f534c Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Mon, 21 Sep 2020 00:42:39 +0200 Subject: [PATCH 041/122] Fix remove last childnode --- front/src/Administration/ConsoleGlobalMessageManager.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/front/src/Administration/ConsoleGlobalMessageManager.ts b/front/src/Administration/ConsoleGlobalMessageManager.ts index 2c576cba..21bd4514 100644 --- a/front/src/Administration/ConsoleGlobalMessageManager.ts +++ b/front/src/Administration/ConsoleGlobalMessageManager.ts @@ -33,6 +33,11 @@ export class ConsoleGlobalMessageManager { } initialise() { + const mainSectionDiv = HtmlUtils.getElementByIdOrFail('main-container'); + mainSectionDiv.childNodes.forEach((c : ChildNode) => { + c.remove(); + }); + const buttonText = document.createElement('p'); buttonText.innerText = 'Console'; @@ -50,7 +55,6 @@ export class ConsoleGlobalMessageManager { this.createTextMessagePart(); - const mainSectionDiv = HtmlUtils.getElementByIdOrFail('main-container'); mainSectionDiv.appendChild(this.divMainConsole); } From 16b3e487116b68c9d21e76e248e6d88ad22ce73c Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Mon, 21 Sep 2020 01:16:10 +0200 Subject: [PATCH 042/122] Add menu to switch --- front/dist/resources/style/style.css | 16 +++++++++++ .../ConsoleGlobalMessageManager.ts | 27 ++++++++++++++++--- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/front/dist/resources/style/style.css b/front/dist/resources/style/style.css index 31fb8b51..3fc554ec 100644 --- a/front/dist/resources/style/style.css +++ b/front/dist/resources/style/style.css @@ -483,4 +483,20 @@ body { color: black; border: 1px solid black; transform: scale(1.1); +} + +.main-console .menu { + padding: 20px; + color: #ffffffa6; + text-align: center; +} + +.main-console .menu span { + margin: 20px; + cursor: pointer; +} + +.main-console .menu span.active { + color: white; + border-bottom: solid 1px white; } \ No newline at end of file diff --git a/front/src/Administration/ConsoleGlobalMessageManager.ts b/front/src/Administration/ConsoleGlobalMessageManager.ts index 21bd4514..efabd25a 100644 --- a/front/src/Administration/ConsoleGlobalMessageManager.ts +++ b/front/src/Administration/ConsoleGlobalMessageManager.ts @@ -33,10 +33,30 @@ export class ConsoleGlobalMessageManager { } initialise() { - const mainSectionDiv = HtmlUtils.getElementByIdOrFail('main-container'); - mainSectionDiv.childNodes.forEach((c : ChildNode) => { - c.remove(); + try { + let mainConsole = HtmlUtils.getElementByIdOrFail(CLASS_CONSOLE_MESSAGE); + mainConsole.remove(); + }catch (err){} + + const menu = document.createElement('div'); + menu.classList.add('menu') + const textMessage = document.createElement('span'); + textMessage.innerText = "Message"; + textMessage.classList.add('active'); + textMessage.addEventListener('click', () => { + textMessage.classList.add('active'); + textAudio.classList.remove('active'); }); + menu.appendChild(textMessage); + const textAudio = document.createElement('span'); + textAudio.innerText = "Audio"; + textAudio.addEventListener('click', () => { + textAudio.classList.add('active'); + textMessage.classList.remove('active'); + }); + menu.appendChild(textMessage); + menu.appendChild(textAudio); + this.divMainConsole.appendChild(menu); const buttonText = document.createElement('p'); buttonText.innerText = 'Console'; @@ -55,6 +75,7 @@ export class ConsoleGlobalMessageManager { this.createTextMessagePart(); + const mainSectionDiv = HtmlUtils.getElementByIdOrFail('main-container'); mainSectionDiv.appendChild(this.divMainConsole); } From a19f09bef2fdaa43041e3c604f70b1ed04906b2e Mon Sep 17 00:00:00 2001 From: arp Date: Fri, 18 Sep 2020 16:29:53 +0200 Subject: [PATCH 043/122] improve the register workflow --- back/src/Controller/AdminController.ts | 8 +++---- front/src/index.ts | 3 ++- front/src/register.ts | 31 ++++++++++++++++++++------ 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/back/src/Controller/AdminController.ts b/back/src/Controller/AdminController.ts index 7c20498f..c4905a8a 100644 --- a/back/src/Controller/AdminController.ts +++ b/back/src/Controller/AdminController.ts @@ -1,7 +1,7 @@ import {Application, Request, Response} from "express"; import {OK} from "http-status-codes"; import {ADMIN_API_TOKEN, ADMIN_API_URL} from "../Enum/EnvironmentVariable"; -import Axios, {AxiosError} from "axios"; +import Axios from "axios"; export class AdminController { App : Application; @@ -27,12 +27,10 @@ export class AdminController { return res.status(e.status || 500).send('An error happened'); } - const teamSlug = response.data.teamSlug; + const organizationSlug = response.data.organizationSlug; const worldSlug = response.data.worldSlug; const roomSlug = response.data.roomSlug; - return res.status(OK).send({ - loginUrl: '/@/'+teamSlug+'/'+worldSlug+'/'+roomSlug, - }); + return res.status(OK).send({organizationSlug, worldSlug, roomSlug}); }); } } diff --git a/front/src/index.ts b/front/src/index.ts index 8be675fb..1f6b1d4a 100644 --- a/front/src/index.ts +++ b/front/src/index.ts @@ -14,7 +14,8 @@ import {CoWebsiteManager} from "./WebRtc/CoWebsiteManager"; import {redirectIfToken} from "./register"; //CoWebsiteManager.loadCoWebsite('https://thecodingmachine.com'); -redirectIfToken(); +let connectionData //todo: do something with this data +redirectIfToken().then(res => connectionData = res); // Load Jitsi if the environment variable is set. if (JITSI_URL) { diff --git a/front/src/register.ts b/front/src/register.ts index 0cc9dd13..98fe0d1e 100644 --- a/front/src/register.ts +++ b/front/src/register.ts @@ -1,12 +1,29 @@ import Axios from "axios"; import {API_URL} from "./Enum/EnvironmentVariable"; -declare let window:Window; +declare let history:History; -export function redirectIfToken() { - const match = window.location.toString().match(/\/register\/(.+)/); - if (match) { - Axios.get(`${API_URL}/register/`+match[1]).then((res) => { - window.location = res.data.loginUrl; - }); +//todo: better naming +export interface ConnexionData { + organizationSlug: string, + worldSlug: string, + roomSlug: string, +} + +export async function redirectIfToken(): Promise { + const match = /\/register\/(.+)/.exec(window.location.toString()); + if (!match) { + return null } + let res = null; + try { + res = await Axios.get(`${API_URL}/register/`+match[1]) + } catch (e) { + return null; + } + const organizationSlug = res.data.organizationSlug; + const worldSlug = res.data.worldSlug; + const roomSlug = res.data.roomSlug; + const connexionUrl = '/@/'+organizationSlug+'/'+worldSlug+'/'+roomSlug; + history.pushState({}, '', connexionUrl); + return {organizationSlug, worldSlug, roomSlug}; } \ No newline at end of file From 76d37794382f52410a5d2d25ec91e7ccbc54058e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Mon, 21 Sep 2020 11:24:03 +0200 Subject: [PATCH 044/122] Moved GroupUpdateMessage to protobuf --- back/src/Controller/IoSocketController.ts | 40 +++++++++++++---------- back/src/Model/Group.ts | 23 ++++++++++--- back/src/Model/World.ts | 5 +-- front/src/Connection.ts | 29 +++++++++++++--- front/src/Phaser/Game/GameScene.ts | 12 +++---- 5 files changed, 76 insertions(+), 33 deletions(-) diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index 2334111e..4a1c9240 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -14,7 +14,7 @@ import si from "systeminformation"; import {Gauge} from "prom-client"; import {TokenInterface} from "../Controller/AuthenticateController"; import {isJoinRoomMessageInterface} from "../Model/Websocket/JoinRoomMessage"; -import {isPointInterface, PointInterface} from "../Model/Websocket/PointInterface"; +import {PointInterface} from "../Model/Websocket/PointInterface"; import {isWebRtcSignalMessageInterface} from "../Model/Websocket/WebRtcSignalMessage"; import {UserInGroupInterface} from "../Model/Websocket/UserInGroupInterface"; import {isItemEventMessageInterface} from "../Model/Websocket/ItemEventMessage"; @@ -27,7 +27,7 @@ import { SetPlayerDetailsMessage, SubMessage, UserMovedMessage, - BatchMessage + BatchMessage, GroupUpdateMessage, PointMessage } from "../../../messages/generated/messages_pb"; import {UserMovesMessage} from "../../../messages/generated/messages_pb"; import Direction = PositionMessage.Direction; @@ -90,7 +90,7 @@ export class IoSocketController { // Authentication with token. it will be decoded and stored in the socket. // Completely commented for now, as we do not use the "/login" route at all. this.Io.use((socket: Socket, next) => { - console.log(socket.handshake.query.token); + //console.log(socket.handshake.query.token); if (!socket.handshake.query || !socket.handshake.query.token) { console.error('An authentication error happened, a user tried to connect without a token.'); return next(new Error('Authentication error')); @@ -176,8 +176,8 @@ export class IoSocketController { const srvSockets = this.Io.sockets.sockets; this.nbClientsGauge.inc(); console.log(new Date().toISOString() + ' A user joined (', Object.keys(srvSockets).length, ' connected users)'); - si.currentLoad().then(data => console.log(' Current load: ', data.avgload)); - si.currentLoad().then(data => console.log(' CPU: ', data.currentload, '%')); + //si.currentLoad().then(data => console.log(' Current load: ', data.avgload)); + //si.currentLoad().then(data => console.log(' CPU: ', data.currentload, '%')); // End log server load /*join-rom event permit to join one room. @@ -189,7 +189,7 @@ export class IoSocketController { y: user y position on map */ socket.on(SocketIoEvent.JOIN_ROOM, (message: unknown, answerFn): void => { - console.log(SocketIoEvent.JOIN_ROOM, message); + //console.log(SocketIoEvent.JOIN_ROOM, message); try { if (!isJoinRoomMessageInterface(message)) { socket.emit(SocketIoEvent.MESSAGE_ERROR, {message: 'Invalid JOIN_ROOM message.'}); @@ -374,8 +374,8 @@ export class IoSocketController { const srvSockets = this.Io.sockets.sockets; this.nbClientsGauge.dec(); console.log('A user left (', Object.keys(srvSockets).length, ' connected users)'); - si.currentLoad().then(data => console.log('Current load: ', data.avgload)); - si.currentLoad().then(data => console.log('CPU: ', data.currentload, '%')); + //si.currentLoad().then(data => console.log('Current load: ', data.avgload)); + //si.currentLoad().then(data => console.log('CPU: ', data.currentload, '%')); // End log server load }); @@ -408,7 +408,7 @@ export class IoSocketController { }); socket.on(SocketIoEvent.SET_SILENT, (silent: unknown) => { - console.log(SocketIoEvent.SET_SILENT, silent); + //console.log(SocketIoEvent.SET_SILENT, silent); if (typeof silent !== "boolean") { socket.emit(SocketIoEvent.MESSAGE_ERROR, {message: 'Invalid SET_SILENT message.'}); console.warn('Invalid SET_SILENT message received: ', silent); @@ -543,10 +543,7 @@ export class IoSocketController { clientListener.emit(SocketIoEvent.JOIN_ROOM, messageUserJoined); } else if (thing instanceof Group) { - clientListener.emit(SocketIoEvent.GROUP_CREATE_UPDATE, { - position: thing.getPosition(), - groupId: thing.getId() - } as GroupUpdateInterface); + this.emitCreateUpdateGroupEvent(clientListener, thing); } else { console.error('Unexpected type for Movable.'); } @@ -565,10 +562,7 @@ export class IoSocketController { clientListener.emitInBatch(SocketIoEvent.USER_MOVED, subMessage); //console.log("Sending USER_MOVED event"); } else if (thing instanceof Group) { - clientListener.emit(SocketIoEvent.GROUP_CREATE_UPDATE, { - position: thing.getPosition(), - groupId: thing.getId() - } as GroupUpdateInterface); + this.emitCreateUpdateGroupEvent(clientListener, thing); } else { console.error('Unexpected type for Movable.'); } @@ -600,6 +594,18 @@ export class IoSocketController { return world; } + private emitCreateUpdateGroupEvent(socket: Socket, group: Group): void { + const position = group.getPosition(); + const pointMessage = new PointMessage(); + pointMessage.setX(Math.floor(position.x)); + pointMessage.setY(Math.floor(position.y)); + const groupUpdateMessage = new GroupUpdateMessage(); + groupUpdateMessage.setGroupid(group.getId()); + groupUpdateMessage.setPosition(pointMessage); + + socket.emit(SocketIoEvent.GROUP_CREATE_UPDATE, groupUpdateMessage.serializeBinary().buffer); + } + /** * * @param socket diff --git a/back/src/Model/Group.ts b/back/src/Model/Group.ts index 43990ef4..4364455d 100644 --- a/back/src/Model/Group.ts +++ b/back/src/Model/Group.ts @@ -13,6 +13,8 @@ export class Group implements Movable { private users: Set; private connectCallback: ConnectCallback; private disconnectCallback: DisconnectCallback; + private x!: number; + private y!: number; constructor(users: User[], connectCallback: ConnectCallback, disconnectCallback: DisconnectCallback) { @@ -25,6 +27,8 @@ export class Group implements Movable { users.forEach((user: User) => { this.join(user); }); + + this.updatePosition(); } getUsers(): User[] { @@ -39,6 +43,16 @@ export class Group implements Movable { * Returns the barycenter of all users (i.e. the center of the group) */ getPosition(): PositionInterface { + return { + x: this.x, + y: this.y + }; + } + + /** + * Computes the barycenter of all users (i.e. the center of the group) + */ + updatePosition(): void { let x = 0; let y = 0; // Let's compute the barycenter of all users. @@ -48,10 +62,11 @@ export class Group implements Movable { }); x /= this.users.size; y /= this.users.size; - return { - x, - y - }; + if (this.users.size === 0) { + throw new Error("EMPTY GROUP FOUND!!!"); + } + this.x = x; + this.y = y; } isFull(): boolean { diff --git a/back/src/Model/World.ts b/back/src/Model/World.ts index dc3dcd07..452c6c17 100644 --- a/back/src/Model/World.ts +++ b/back/src/Model/World.ts @@ -90,6 +90,7 @@ export class World { this.positionNotifier.updatePosition(user, userPosition, user.position); const oldGroupPosition = user.group?.getPosition(); + user.group?.updatePosition(); user.position = userPosition; @@ -126,7 +127,7 @@ export class World { } // At the very end, if the user is part of a group, let's call the callback to update group position - if (typeof user.group !== 'undefined') { + if (user.group !== undefined) { this.positionNotifier.updatePosition(user.group, user.group.getPosition(), oldGroupPosition ? oldGroupPosition : user.group.getPosition()); } } @@ -158,7 +159,7 @@ export class World { */ private leaveGroup(user: User): void { const group = user.group; - if (typeof group === 'undefined') { + if (group === undefined) { throw new Error("The user is part of no group"); } group.leave(user); diff --git a/front/src/Connection.ts b/front/src/Connection.ts index fa04feb8..02752c10 100644 --- a/front/src/Connection.ts +++ b/front/src/Connection.ts @@ -2,7 +2,7 @@ import Axios from "axios"; import {API_URL} from "./Enum/EnvironmentVariable"; import {MessageUI} from "./Logger/MessageUI"; import { - BatchMessage, + BatchMessage, GroupUpdateMessage, PositionMessage, SetPlayerDetailsMessage, UserMovedMessage, UserMovesMessage, @@ -78,7 +78,7 @@ export interface PositionInterface { export interface GroupCreatedUpdatedMessageInterface { position: PositionInterface, - groupId: string + groupId: number } export interface WebRtcStartMessageInterface { @@ -301,10 +301,31 @@ export class Connection implements Connection { } public onGroupUpdatedOrCreated(callback: (groupCreateUpdateMessage: GroupCreatedUpdatedMessageInterface) => void): void { - this.socket.on(EventMessage.GROUP_CREATE_UPDATE, callback); + // TODO: READ THIS FROM BINARY FORMAT + // TODO: READ THIS FROM BINARY FORMAT + // TODO: READ THIS FROM BINARY FORMAT + // TODO: CHANGE THIS EVENT TO BE PART OF THE BATCHES + // TODO: CHANGE THIS EVENT TO BE PART OF THE BATCHES + // TODO: CHANGE THIS EVENT TO BE PART OF THE BATCHES + // TODO: CHANGE THIS EVENT TO BE PART OF THE BATCHES + // TODO: CHANGE THIS EVENT TO BE PART OF THE BATCHES + this.socket.on(EventMessage.GROUP_CREATE_UPDATE, (buffer: ArrayBuffer) => { + const message = GroupUpdateMessage.deserializeBinary(new Uint8Array(buffer)); + const position = message.getPosition(); + if (position === undefined) { + throw new Error('Missing position in GROUP_CREATE_UPDATE'); + } + + const groupCreateUpdateMessage: GroupCreatedUpdatedMessageInterface = { + groupId: message.getGroupid(), + position: position.toObject() + } + + callback(groupCreateUpdateMessage); + }); } - public onGroupDeleted(callback: (groupId: string) => void): void { + public onGroupDeleted(callback: (groupId: number) => void): void { this.socket.on(EventMessage.GROUP_DELETE, callback) } diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index c7a7fd3e..8abddfd3 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -80,7 +80,7 @@ interface GroupCreatedUpdatedEventInterface { interface DeleteGroupEventInterface { type: 'DeleteGroupEvent' - groupId: string + groupId: number } export class GameScene extends Phaser.Scene implements CenterListener { @@ -93,7 +93,7 @@ export class GameScene extends Phaser.Scene implements CenterListener { Layers!: Array; Objects!: Array; mapFile!: ITiledMap; - groups: Map; + groups: Map; startX!: number; startY!: number; circleTexture!: CanvasTexture; @@ -149,7 +149,7 @@ export class GameScene extends Phaser.Scene implements CenterListener { this.GameManager = gameManager; this.Terrains = []; - this.groups = new Map(); + this.groups = new Map(); this.instance = instance; this.MapKey = MapKey; @@ -237,7 +237,7 @@ export class GameScene extends Phaser.Scene implements CenterListener { this.shareGroupPosition(groupPositionMessage); }) - connection.onGroupDeleted((groupId: string) => { + connection.onGroupDeleted((groupId: number) => { try { this.deleteGroup(groupId); } catch (e) { @@ -1108,14 +1108,14 @@ export class GameScene extends Phaser.Scene implements CenterListener { } } - deleteGroup(groupId: string): void { + deleteGroup(groupId: number): void { this.pendingEvents.enqueue({ type: "DeleteGroupEvent", groupId }); } - doDeleteGroup(groupId: string): void { + doDeleteGroup(groupId: number): void { const group = this.groups.get(groupId); if(!group){ return; From 8c43c6774173ae3483101747477d6b9ee0c2b17c Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Mon, 21 Sep 2020 15:00:39 +0200 Subject: [PATCH 045/122] Create feature to send and read audio message --- front/dist/index.html | 3 + front/dist/resources/logos/megaphone.svg | 18 +++ front/dist/resources/logos/music-file.svg | 27 +++++ .../dist/resources/logos/music-file.svg.back | 1 + front/dist/resources/style/style.css | 59 +++++++++ .../ConsoleGlobalMessageManager.ts | 112 ++++++++++++++++-- .../Administration/GlobalMessageManager.ts | 49 ++++++-- 7 files changed, 247 insertions(+), 22 deletions(-) create mode 100644 front/dist/resources/logos/megaphone.svg create mode 100644 front/dist/resources/logos/music-file.svg create mode 100644 front/dist/resources/logos/music-file.svg.back diff --git a/front/dist/index.html b/front/dist/index.html index f885079a..9d883ffe 100644 --- a/front/dist/index.html +++ b/front/dist/index.html @@ -95,6 +95,9 @@
+
+ +
+ + + + + + + + + diff --git a/front/dist/resources/logos/music-file.svg b/front/dist/resources/logos/music-file.svg new file mode 100644 index 00000000..a97656ba --- /dev/null +++ b/front/dist/resources/logos/music-file.svg @@ -0,0 +1,27 @@ + + + + + + + + + + + diff --git a/front/dist/resources/logos/music-file.svg.back b/front/dist/resources/logos/music-file.svg.back new file mode 100644 index 00000000..185bff28 --- /dev/null +++ b/front/dist/resources/logos/music-file.svg.back @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/front/dist/resources/style/style.css b/front/dist/resources/style/style.css index 3fc554ec..4b292df4 100644 --- a/front/dist/resources/style/style.css +++ b/front/dist/resources/style/style.css @@ -499,4 +499,63 @@ body { .main-console .menu span.active { color: white; border-bottom: solid 1px white; +} + +.main-console section{ + text-align: center; + display: none; +} + +.main-console section.active{ + display: block; +} + +.main-console section div.upload{ + text-align: center; + border: solid 1px #ffda01; + height: 150px; + margin: 10px 200px; + padding: 20px; + min-height: 200px; +} + +.main-console section div.upload label{ + color: #ffda01; +} +.main-console section div.upload input{ + display: none; +} +.main-console section div.upload label img{ + height: 150px; + cursor: pointer; +} +.main-console section div.upload label img{ + cursor: pointer; +} + +/*audio html when audio message playing*/ +.main-container .audio-playing { + position: absolute; + width: 200px; + height: 54px; + right: -210px; + top: 40px; + transition: all 0.1s ease-out; + background-color: black; + border-radius: 30px 0 0 30px; + display: inline-flex; +} + +.main-container .audio-playing.active{ + right: 0; +} +.main-container .audio-playing img{ + width: 30px; + border-radius: 50%; + background-color: #ffda01; + padding: 10px; +} +.main-container .audio-playing p{ + color: white; + margin-left: 10px; } \ No newline at end of file diff --git a/front/src/Administration/ConsoleGlobalMessageManager.ts b/front/src/Administration/ConsoleGlobalMessageManager.ts index efabd25a..37ba6dbb 100644 --- a/front/src/Administration/ConsoleGlobalMessageManager.ts +++ b/front/src/Administration/ConsoleGlobalMessageManager.ts @@ -34,10 +34,14 @@ export class ConsoleGlobalMessageManager { initialise() { try { - let mainConsole = HtmlUtils.getElementByIdOrFail(CLASS_CONSOLE_MESSAGE); - mainConsole.remove(); + HtmlUtils.removeElementByIdOrFail(CLASS_CONSOLE_MESSAGE); }catch (err){} + const typeConsole = document.createElement('input'); + typeConsole.id = INPUT_TYPE_CONSOLE; + typeConsole.value = MESSAGE_TYPE; + typeConsole.type = 'hidden'; + const menu = document.createElement('div'); menu.classList.add('menu') const textMessage = document.createElement('span'); @@ -45,14 +49,28 @@ export class ConsoleGlobalMessageManager { textMessage.classList.add('active'); textMessage.addEventListener('click', () => { textMessage.classList.add('active'); + const messageSection = HtmlUtils.getElementByIdOrFail(this.getSectionId(INPUT_CONSOLE_MESSAGE)); + messageSection.classList.add('active'); + textAudio.classList.remove('active'); + const audioSection = HtmlUtils.getElementByIdOrFail(this.getSectionId(UPLOAD_CONSOLE_MESSAGE)); + audioSection.classList.remove('active'); + + typeConsole.value = MESSAGE_TYPE; }); menu.appendChild(textMessage); const textAudio = document.createElement('span'); textAudio.innerText = "Audio"; textAudio.addEventListener('click', () => { textAudio.classList.add('active'); + const audioSection = HtmlUtils.getElementByIdOrFail(this.getSectionId(UPLOAD_CONSOLE_MESSAGE)); + audioSection.classList.add('active'); + textMessage.classList.remove('active'); + const messageSection = HtmlUtils.getElementByIdOrFail(this.getSectionId(INPUT_CONSOLE_MESSAGE)); + messageSection.classList.remove('active'); + + typeConsole.value = AUDIO_TYPE; }); menu.appendChild(textMessage); menu.appendChild(textAudio); @@ -72,8 +90,10 @@ export class ConsoleGlobalMessageManager { this.divMainConsole.className = CLASS_CONSOLE_MESSAGE; this.divMainConsole.appendChild(this.buttonMainConsole); + this.divMainConsole.appendChild(typeConsole); this.createTextMessagePart(); + this.createUploadAudioPart(); const mainSectionDiv = HtmlUtils.getElementByIdOrFail('main-container'); mainSectionDiv.appendChild(this.divMainConsole); @@ -81,8 +101,7 @@ export class ConsoleGlobalMessageManager { createTextMessagePart(){ const div = document.createElement('div'); - div.id = INPUT_CONSOLE_MESSAGE; - + div.id = INPUT_CONSOLE_MESSAGE const buttonSend = document.createElement('button'); buttonSend.innerText = 'Envoyer'; buttonSend.classList.add('btn'); @@ -94,15 +113,11 @@ export class ConsoleGlobalMessageManager { buttonDiv.classList.add('btn-action'); buttonDiv.appendChild(buttonSend) - const typeConsole = document.createElement('input'); - typeConsole.id = INPUT_TYPE_CONSOLE; - typeConsole.value = MESSAGE_TYPE; - typeConsole.type = 'hidden'; - const section = document.createElement('section'); + section.id = this.getSectionId(INPUT_CONSOLE_MESSAGE); + section.classList.add('active'); section.appendChild(div); section.appendChild(buttonDiv); - section.appendChild(typeConsole); this.divMainConsole.appendChild(section); //TODO refactor @@ -140,6 +155,62 @@ export class ConsoleGlobalMessageManager { }, 1000); } + createUploadAudioPart(){ + const div = document.createElement('div'); + div.classList.add('upload'); + + const label = document.createElement('label'); + label.setAttribute('for', UPLOAD_CONSOLE_MESSAGE); + + const img = document.createElement('img'); + img.setAttribute('for', UPLOAD_CONSOLE_MESSAGE); + img.src = 'resources/logos/music-file.svg'; + + const input = document.createElement('input'); + input.type = 'file'; + input.id = UPLOAD_CONSOLE_MESSAGE + input.addEventListener('input', (e: any) => { + if(!e.target || !e.target.files || e.target.files.length === 0){ + return; + } + let file : File = e.target.files[0]; + + if(!file){ + return; + } + + try { + HtmlUtils.removeElementByIdOrFail('audi-message-filename'); + }catch (e) {} + + const p = document.createElement('p'); + p.id = 'audi-message-filename'; + p.innerText = `${file.name} : ${this.getFileSize(file.size)}`; + label.appendChild(p); + }); + + label.appendChild(img); + div.appendChild(label); + div.appendChild(input); + + const buttonSend = document.createElement('button'); + buttonSend.innerText = 'Envoyer'; + buttonSend.classList.add('btn'); + buttonSend.addEventListener('click', (event: MouseEvent) => { + this.sendMessage(); + this.disabled(); + }); + const buttonDiv = document.createElement('div'); + buttonDiv.classList.add('btn-action'); + buttonDiv.appendChild(buttonSend) + + const section = document.createElement('section'); + section.id = this.getSectionId(UPLOAD_CONSOLE_MESSAGE); + section.appendChild(div); + section.appendChild(buttonDiv); + this.divMainConsole.appendChild(section); + } + sendMessage(){ const inputType = HtmlUtils.getElementByIdOrFail(INPUT_TYPE_CONSOLE); if(AUDIO_TYPE !== inputType.value && MESSAGE_TYPE !== inputType.value){ @@ -176,9 +247,12 @@ export class ConsoleGlobalMessageManager { let GlobalMessage : GlobalMessageInterface = { id: res.id, message: res.path, - type: MESSAGE_TYPE + type: AUDIO_TYPE }; inputAudio.value = ''; + try { + HtmlUtils.removeElementByIdOrFail('audi-message-filename'); + }catch (e) {} this.Connection.emitGlobalMessage(GlobalMessage); } @@ -194,4 +268,20 @@ export class ConsoleGlobalMessageManager { this.activeConsole = false; this.divMainConsole.style.top = '-80%'; } + + private getSectionId(id: string) : string { + return `section-${id}`; + } + + private getFileSize(number: number) :string { + if (number < 1024) { + return number + 'bytes'; + } else if (number >= 1024 && number < 1048576) { + return (number / 1024).toFixed(1) + 'KB'; + } else if (number >= 1048576) { + return (number / 1048576).toFixed(1) + 'MB'; + }else{ + return ''; + } + } } \ No newline at end of file diff --git a/front/src/Administration/GlobalMessageManager.ts b/front/src/Administration/GlobalMessageManager.ts index ec1693f8..ec700e2a 100644 --- a/front/src/Administration/GlobalMessageManager.ts +++ b/front/src/Administration/GlobalMessageManager.ts @@ -1,6 +1,7 @@ import {HtmlUtils} from "./../WebRtc/HtmlUtils"; import {Connection, GlobalMessageInterface} from "../Connection"; import {AUDIO_TYPE, MESSAGE_TYPE} from "./ConsoleGlobalMessageManager"; +import {API_URL} from "../Enum/EnvironmentVariable"; export class GlobalMessageManager { @@ -39,19 +40,45 @@ export class GlobalMessageManager { } private playAudioMessage(messageId : number, urlMessage: string){ - const messageVideo : HTMLAudioElement = document.createElement('audio'); - messageVideo.id = this.getHtmlMessageId(messageId); - messageVideo.src = urlMessage; - messageVideo.onended = () => { - messageVideo.remove(); + //delete previous elements + const previousDivAudio = document.getElementsByClassName('audio-playing'); + for(let i = 0; i < previousDivAudio.length; i++){ + previousDivAudio[i].remove(); } - messageVideo.onloadeddata = () => { - messageVideo.play(); - }; - const mainSectionDiv = HtmlUtils.getElementByIdOrFail('main-container'); - mainSectionDiv.appendChild(messageVideo); - //TODO add element when audio message is played + //create new element + const divAudio : HTMLDivElement = document.createElement('div'); + divAudio.id = `audio-playing-${messageId}`; + divAudio.classList.add('audio-playing'); + const imgAudio : HTMLImageElement = document.createElement('img'); + imgAudio.src = '/resources/logos/megaphone.svg'; + const pAudio : HTMLParagraphElement = document.createElement('p'); + pAudio.textContent = 'Message audio' + divAudio.appendChild(imgAudio); + divAudio.appendChild(pAudio); + + const mainSectionDiv = HtmlUtils.getElementByIdOrFail('main-container'); + mainSectionDiv.appendChild(divAudio); + + const messageAudio : HTMLAudioElement = document.createElement('audio'); + messageAudio.id = this.getHtmlMessageId(messageId); + messageAudio.autoplay = true; + messageAudio.style.display = 'none'; + messageAudio.onended = () => { + divAudio.classList.remove('active'); + messageAudio.remove(); + setTimeout(() => { + divAudio.remove(); + }, 1000); + } + messageAudio.onplay = () => { + console.log('play'); + divAudio.classList.add('active'); + } + const messageAudioSource : HTMLSourceElement = document.createElement('source'); + messageAudioSource.src = `${API_URL}${urlMessage}`; + messageAudio.appendChild(messageAudioSource); + mainSectionDiv.appendChild(messageAudio); } private playTextMessage(messageId : number, htmlMessage: string){ From 0d2893ec75fcf3ee751e713d8b4dff5a352fb797 Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Mon, 21 Sep 2020 15:11:46 +0200 Subject: [PATCH 046/122] Send at every player connected --- back/src/Controller/IoSocketController.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index 8033044f..dc64513c 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -402,7 +402,8 @@ export class IoSocketController { }); socket.on(SockerIoEvent.PLAY_GLOBAL_MESSAGE, (itemEvent: unknown) => { - socket.broadcast.emit(SockerIoEvent.PLAY_GLOBAL_MESSAGE, itemEvent); + //permit to send message at every member connected + this.Io.emit(SockerIoEvent.PLAY_GLOBAL_MESSAGE, itemEvent); }); }); } From 942d2cbcef442e2c5a3a4681b5a47cd7e004c5a9 Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Wed, 23 Sep 2020 17:22:00 +0200 Subject: [PATCH 047/122] Refactor and remove prevent default keyboard --- front/src/Phaser/Components/TextInput.ts | 2 -- front/src/Phaser/Game/GameScene.ts | 3 +- .../src/Phaser/UserInput/UserInputManager.ts | 31 ++++++++++++------- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/front/src/Phaser/Components/TextInput.ts b/front/src/Phaser/Components/TextInput.ts index 3a20eadf..7a549d1f 100644 --- a/front/src/Phaser/Components/TextInput.ts +++ b/front/src/Phaser/Components/TextInput.ts @@ -10,8 +10,6 @@ export class TextInput extends Phaser.GameObjects.BitmapText { this.underLine = this.scene.add.text(x, y+1, '_______', { fontFamily: 'Arial', fontSize: "32px", color: '#ffffff'}) - const keySpace = this.scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE); - const keyBackspace = this.scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.BACKSPACE); this.scene.input.keyboard.on('keydown', (event: KeyboardEvent) => { if (event.keyCode === 8 && this.text.length > 0) { this.deleteLetter(); diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 654b9d75..a88cca71 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -525,8 +525,7 @@ export class GameScene extends Phaser.Scene implements CenterListener { this.createPromiseResolve(); - // TODO: use inputmanager instead - this.input.keyboard.on('keyup-SPACE', () => { + this.userInputManager.spaceEvent( () => { this.outlinedItem?.activate(); }); diff --git a/front/src/Phaser/UserInput/UserInputManager.ts b/front/src/Phaser/UserInput/UserInputManager.ts index a7be41cf..fa7080b5 100644 --- a/front/src/Phaser/UserInput/UserInputManager.ts +++ b/front/src/Phaser/UserInput/UserInputManager.ts @@ -39,21 +39,21 @@ export class UserInputManager { initKeyBoardEvent(){ this.KeysCode = [ - {event: UserInputEvent.MoveUp, keyInstance: this.Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.Z) }, - {event: UserInputEvent.MoveLeft, keyInstance: this.Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.Q) }, - {event: UserInputEvent.MoveDown, keyInstance: this.Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.S) }, - {event: UserInputEvent.MoveRight, keyInstance: this.Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.D) }, + {event: UserInputEvent.MoveUp, keyInstance: this.Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.Z, false) }, + {event: UserInputEvent.MoveLeft, keyInstance: this.Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.Q, false) }, + {event: UserInputEvent.MoveDown, keyInstance: this.Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.S, false) }, + {event: UserInputEvent.MoveRight, keyInstance: this.Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.D, false) }, - {event: UserInputEvent.MoveUp, keyInstance: this.Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.UP) }, - {event: UserInputEvent.MoveLeft, keyInstance: this.Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.LEFT) }, - {event: UserInputEvent.MoveDown, keyInstance: this.Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.DOWN) }, - {event: UserInputEvent.MoveRight, keyInstance: this.Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.RIGHT) }, + {event: UserInputEvent.MoveUp, keyInstance: this.Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.UP, false) }, + {event: UserInputEvent.MoveLeft, keyInstance: this.Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.LEFT, false) }, + {event: UserInputEvent.MoveDown, keyInstance: this.Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.DOWN, false) }, + {event: UserInputEvent.MoveRight, keyInstance: this.Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.RIGHT, false) }, - {event: UserInputEvent.SpeedUp, keyInstance: this.Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SHIFT) }, + {event: UserInputEvent.SpeedUp, keyInstance: this.Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SHIFT, false) }, - {event: UserInputEvent.Interact, keyInstance: this.Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.E) }, - {event: UserInputEvent.Interact, keyInstance: this.Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE) }, - {event: UserInputEvent.Shout, keyInstance: this.Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.F) }, + {event: UserInputEvent.Interact, keyInstance: this.Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.E, false) }, + {event: UserInputEvent.Interact, keyInstance: this.Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE, false) }, + {event: UserInputEvent.Shout, keyInstance: this.Scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.F, false) }, ]; } @@ -70,4 +70,11 @@ export class UserInputManager { }); return eventsMap; } + + spaceEvent(callback : Function){ + this.Scene.input.keyboard.on('keyup-SPACE', (event: Event) => { + callback(); + return event; + }); + } } From d5fdb9d8577a02f1e9cb6f3612236352f0673035 Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Wed, 23 Sep 2020 18:07:31 +0200 Subject: [PATCH 048/122] Fix style --- front/dist/resources/style/style.css | 17 +++++++++++++---- .../ConsoleGlobalMessageManager.ts | 10 +++++++--- .../src/Administration/GlobalMessageManager.ts | 11 ++++++++--- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/front/dist/resources/style/style.css b/front/dist/resources/style/style.css index 4b292df4..e22795a9 100644 --- a/front/dist/resources/style/style.css +++ b/front/dist/resources/style/style.css @@ -410,6 +410,7 @@ body { width: 80%; height: 80%; min-height: 200px; + max-height: 80%; top: -80%; left: 10%; background: #000000a6; @@ -421,12 +422,19 @@ body { height: auto; border-radius: 0 0 10px 10px; color: white; - padding: 10px; top: 0; } +.message-container .content-message{ + position: relative; + padding: 20px; + margin: 20px; + overflow: scroll; + max-height: 400px; +} + .main-console div.console, -.message-container div { +.message-container div.clear { position: absolute; color: white; z-index: 200; @@ -441,12 +449,12 @@ body { } .main-console div.console p, -.message-container div p{ +.message-container div.clear p{ margin-top: 6px; } .main-console div.console:hover, -.message-container div:hover { +.message-container div.clear:hover { cursor: pointer; transform: scale(1.2) translateY(3px); } @@ -458,6 +466,7 @@ body { .main-console #input-send-text .ql-editor{ color: white; min-height: 200px; + max-height: 300px; } .main-console .ql-toolbar{ diff --git a/front/src/Administration/ConsoleGlobalMessageManager.ts b/front/src/Administration/ConsoleGlobalMessageManager.ts index 37ba6dbb..582427af 100644 --- a/front/src/Administration/ConsoleGlobalMessageManager.ts +++ b/front/src/Administration/ConsoleGlobalMessageManager.ts @@ -223,13 +223,17 @@ export class ConsoleGlobalMessageManager { } private sendTextMessage(){ - const inputText = HtmlUtils.getElementByIdOrFail(INPUT_CONSOLE_MESSAGE); + let elements = document.getElementsByClassName('ql-editor'); + let quillEditor = elements.item(0); + if(!quillEditor){ + throw "Error get quill node"; + } let GlobalMessage : GlobalMessageInterface = { id: 1, - message: inputText.value, + message: quillEditor.innerHTML, type: MESSAGE_TYPE }; - inputText.value = ''; + quillEditor.innerHTML = ''; this.Connection.emitGlobalMessage(GlobalMessage); } diff --git a/front/src/Administration/GlobalMessageManager.ts b/front/src/Administration/GlobalMessageManager.ts index ec700e2a..e2850bff 100644 --- a/front/src/Administration/GlobalMessageManager.ts +++ b/front/src/Administration/GlobalMessageManager.ts @@ -72,7 +72,6 @@ export class GlobalMessageManager { }, 1000); } messageAudio.onplay = () => { - console.log('play'); divAudio.classList.add('active'); } const messageAudioSource : HTMLSourceElement = document.createElement('source'); @@ -84,10 +83,11 @@ export class GlobalMessageManager { private playTextMessage(messageId : number, htmlMessage: string){ //add button to clear message const buttonText = document.createElement('p'); - buttonText.id = 'button-clear-message' + buttonText.id = 'button-clear-message'; buttonText.innerText = 'Clear'; const buttonMainConsole = document.createElement('div'); + buttonMainConsole.classList.add('clear'); buttonMainConsole.appendChild(buttonText); buttonMainConsole.addEventListener('click', () => { messageContainer.style.top = '-80%'; @@ -97,11 +97,16 @@ export class GlobalMessageManager { }); }); + //create content message + const messageCotent = document.createElement('div'); + messageCotent.innerHTML = htmlMessage; + messageCotent.className = "content-message"; + //add message container const messageContainer = document.createElement('div'); - messageContainer.innerHTML = htmlMessage; messageContainer.id = this.getHtmlMessageId(messageId); messageContainer.className = "message-container"; + messageContainer.appendChild(messageCotent); messageContainer.appendChild(buttonMainConsole); const mainSectionDiv = HtmlUtils.getElementByIdOrFail('main-container'); From 4beeb62c6f616f5104305f01239c954e777a8c2e Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Wed, 23 Sep 2020 18:28:12 +0200 Subject: [PATCH 049/122] Fix CI --- back/package.json | 1 - back/src/Controller/FileController.ts | 17 +- back/yarn.lock | 17 - maps/yarn.lock | 2240 +++++++++++++++++++++++++ 4 files changed, 2254 insertions(+), 21 deletions(-) create mode 100644 maps/yarn.lock diff --git a/back/package.json b/back/package.json index b6888fbb..b69093aa 100644 --- a/back/package.json +++ b/back/package.json @@ -39,7 +39,6 @@ "@types/express": "^4.17.4", "@types/http-status-codes": "^1.2.0", "@types/jsonwebtoken": "^8.3.8", - "@types/multer": "^1.4.4", "@types/socket.io": "^2.1.4", "@types/uuidv4": "^5.0.0", "axios": "^0.20.0", diff --git a/back/src/Controller/FileController.ts b/back/src/Controller/FileController.ts index a337537f..c98b97ae 100644 --- a/back/src/Controller/FileController.ts +++ b/back/src/Controller/FileController.ts @@ -1,12 +1,23 @@ +const multer = require('multer'); import {Application, Request, RequestHandler, Response} from "express"; import {OK} from "http-status-codes"; import {URL_ROOM_STARTED} from "_Enum/EnvironmentVariable"; import {uuid} from "uuidv4"; -import multer from 'multer'; import fs from "fs"; const upload = multer({ dest: 'dist/files/' }); +class FileUpload{ + path: string + constructor(path : string) { + this.path = path; + } +} + +interface RequestFileHandlerInterface extends Request{ + file: FileUpload +} + export class FileController { App : Application; @@ -22,8 +33,8 @@ export class FileController { //TODO upload audio message const audioMessageId = uuid(); - fs.copyFileSync(req.file.path, `dist/files/${audioMessageId}`); - fs.unlinkSync(req.file.path); + fs.copyFileSync((req as RequestFileHandlerInterface).file.path, `dist/files/${audioMessageId}`); + fs.unlinkSync((req as RequestFileHandlerInterface).file.path); return res.status(OK).send({ id: audioMessageId, diff --git a/back/yarn.lock b/back/yarn.lock index f7ec048b..7fd73c0d 100644 --- a/back/yarn.lock +++ b/back/yarn.lock @@ -48,16 +48,6 @@ "@types/node" "*" "@types/range-parser" "*" -"@types/express@*": - version "4.17.8" - resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.8.tgz#3df4293293317e61c60137d273a2e96cd8d5f27a" - integrity sha512-wLhcKh3PMlyA2cNAB9sjM1BntnhPMiM0JOBwPBqttjHev2428MLEB4AYVN+d8s2iyCVZac+o41Pflm/ZH5vLXQ== - dependencies: - "@types/body-parser" "*" - "@types/express-serve-static-core" "*" - "@types/qs" "*" - "@types/serve-static" "*" - "@types/express@^4.17.4": version "4.17.4" resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.4.tgz#e78bf09f3f530889575f4da8a94cd45384520aac" @@ -91,13 +81,6 @@ version "2.0.1" resolved "https://registry.yarnpkg.com/@types/mime/-/mime-2.0.1.tgz#dc488842312a7f075149312905b5e3c0b054c79d" -"@types/multer@^1.4.4": - version "1.4.4" - resolved "https://registry.yarnpkg.com/@types/multer/-/multer-1.4.4.tgz#bb5d9abc410da82726ceca74008bb81813349a88" - integrity sha512-wdfkiKBBEMTODNbuF3J+qDDSqJxt50yB9pgDiTcFew7f97Gcc7/sM4HR66ofGgpJPOALWOqKAch4gPyqEXSkeQ== - dependencies: - "@types/express" "*" - "@types/node@*": version "13.11.0" resolved "https://registry.yarnpkg.com/@types/node/-/node-13.11.0.tgz#390ea202539c61c8fa6ba4428b57e05bc36dc47b" diff --git a/maps/yarn.lock b/maps/yarn.lock new file mode 100644 index 00000000..04c9d5ff --- /dev/null +++ b/maps/yarn.lock @@ -0,0 +1,2240 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@babel/code-frame@^7.0.0": + version "7.10.4" + resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.10.4.tgz#168da1a36e90da68ae8d49c0f1b48c7c6249213a" + integrity sha512-vG6SvB6oYEhvgisZNFRmRCUkLz11c7rp+tbNTynGqc6mS1d5ATd/sGyV6W0KZZnXRKMTzZDRgQT3Ou9jhpAfUg== + dependencies: + "@babel/highlight" "^7.10.4" + +"@babel/helper-validator-identifier@^7.10.4": + version "7.10.4" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.4.tgz#a78c7a7251e01f616512d31b10adcf52ada5e0d2" + integrity sha512-3U9y+43hz7ZM+rzG24Qe2mufW5KhvFg/NhnNph+i9mgCtdTCtMJuI1TMkrIUiK7Ix4PYlRF9I5dhqaLYA/ADXw== + +"@babel/highlight@^7.10.4": + version "7.10.4" + resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.10.4.tgz#7d1bdfd65753538fabe6c38596cdb76d9ac60143" + integrity sha512-i6rgnR/YgPEQzZZnbTHHuZdlE8qyoBNalD6F+q4vAFlcMEcqmkoG+mPqJYJCo63qPf74+Y1UZsl3l6f7/RIkmA== + dependencies: + "@babel/helper-validator-identifier" "^7.10.4" + chalk "^2.0.0" + js-tokens "^4.0.0" + +"@mrmlnc/readdir-enhanced@^2.2.1": + version "2.2.1" + resolved "https://registry.yarnpkg.com/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz#524af240d1a360527b730475ecfa1344aa540dde" + integrity sha512-bPHp6Ji8b41szTOcaP63VlnbbO5Ny6dwAATtY6JTjh5N2OLrb5Qk/Th5cRkRQhkWCt+EJsYrNB0MiL+Gpn6e3g== + dependencies: + call-me-maybe "^1.0.1" + glob-to-regexp "^0.3.0" + +"@nodelib/fs.stat@^1.1.2": + version "1.1.3" + resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-1.1.3.tgz#2b5a3ab3f918cca48a8c754c08168e3f03eba61b" + integrity sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw== + +"@types/color-name@^1.1.1": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0" + integrity sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ== + +"@types/eslint-visitor-keys@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d" + integrity sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag== + +"@types/jasmine@^3.5.10": + version "3.5.14" + resolved "https://registry.yarnpkg.com/@types/jasmine/-/jasmine-3.5.14.tgz#f41a14e8ffa939062a71cf9722e5ee7d4e1f94af" + integrity sha512-Fkgk536sHPqcOtd+Ow+WiUNuk0TSo/BntKkF8wSvcd6M2FvPjeXcUE6Oz/bwDZiUZEaXLslAgw00Q94Pnx6T4w== + +"@types/json-schema@^7.0.3", "@types/json-schema@^7.0.5": + version "7.0.6" + resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.6.tgz#f4c7ec43e81b319a9815115031709f26987891f0" + integrity sha512-3c+yGKvVP5Y9TYBEibGNR+kLtijnj7mYrXRg+WpFb2X9xm04g/DXYkfg4hmzJQosc9snFNUPkbYIhu+KAm6jJw== + +"@types/strip-bom@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@types/strip-bom/-/strip-bom-3.0.0.tgz#14a8ec3956c2e81edb7520790aecf21c290aebd2" + integrity sha1-FKjsOVbC6B7bdSB5CuzyHCkK69I= + +"@types/strip-json-comments@0.0.30": + version "0.0.30" + resolved "https://registry.yarnpkg.com/@types/strip-json-comments/-/strip-json-comments-0.0.30.tgz#9aa30c04db212a9a0649d6ae6fd50accc40748a1" + integrity sha512-7NQmHra/JILCd1QqpSzl8+mJRc8ZHz3uDm8YV1Ks9IhK0epEiTw8aIErbvH9PI+6XbqhyIQy3462nEsn7UVzjQ== + +"@typescript-eslint/eslint-plugin@^2.26.0": + version "2.34.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.34.0.tgz#6f8ce8a46c7dea4a6f1d171d2bb8fbae6dac2be9" + integrity sha512-4zY3Z88rEE99+CNvTbXSyovv2z9PNOVffTWD2W8QF5s2prBQtwN2zadqERcrHpcR7O/+KMI3fcTAmUUhK/iQcQ== + dependencies: + "@typescript-eslint/experimental-utils" "2.34.0" + functional-red-black-tree "^1.0.1" + regexpp "^3.0.0" + tsutils "^3.17.1" + +"@typescript-eslint/experimental-utils@2.34.0": + version "2.34.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-2.34.0.tgz#d3524b644cdb40eebceca67f8cf3e4cc9c8f980f" + integrity sha512-eS6FTkq+wuMJ+sgtuNTtcqavWXqsflWcfBnlYhg/nS4aZ1leewkXGbvBhaapn1q6qf4M71bsR1tez5JTRMuqwA== + dependencies: + "@types/json-schema" "^7.0.3" + "@typescript-eslint/typescript-estree" "2.34.0" + eslint-scope "^5.0.0" + eslint-utils "^2.0.0" + +"@typescript-eslint/parser@^2.26.0": + version "2.34.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-2.34.0.tgz#50252630ca319685420e9a39ca05fe185a256bc8" + integrity sha512-03ilO0ucSD0EPTw2X4PntSIRFtDPWjrVq7C3/Z3VQHRC7+13YB55rcJI3Jt+YgeHbjUdJPcPa7b23rXCBokuyA== + dependencies: + "@types/eslint-visitor-keys" "^1.0.0" + "@typescript-eslint/experimental-utils" "2.34.0" + "@typescript-eslint/typescript-estree" "2.34.0" + eslint-visitor-keys "^1.1.0" + +"@typescript-eslint/typescript-estree@2.34.0": + version "2.34.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-2.34.0.tgz#14aeb6353b39ef0732cc7f1b8285294937cf37d5" + integrity sha512-OMAr+nJWKdlVM9LOqCqh3pQQPwxHAN7Du8DR6dmwCrAmxtiXQnhHJ6tBNtf+cggqfo51SG/FCwnKhXCIM7hnVg== + dependencies: + debug "^4.1.1" + eslint-visitor-keys "^1.1.0" + glob "^7.1.6" + is-glob "^4.0.1" + lodash "^4.17.15" + semver "^7.3.2" + tsutils "^3.17.1" + +acorn-jsx@^5.2.0: + version "5.3.1" + resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.1.tgz#fc8661e11b7ac1539c47dbfea2e72b3af34d267b" + integrity sha512-K0Ptm/47OKfQRpNQ2J/oIN/3QYiK6FwW+eJbILhsdxh2WTLdl+30o8aGdTbm5JbffpFFAg/g+zi1E+jvJha5ng== + +acorn@^7.1.1: + version "7.4.0" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.0.tgz#e1ad486e6c54501634c6c397c5c121daa383607c" + integrity sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w== + +ajv-keywords@^3.5.2: + version "3.5.2" + resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.5.2.tgz#31f29da5ab6e00d1c2d329acf7b5929614d5014d" + integrity sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ== + +ajv@^6.10.0, ajv@^6.10.2, ajv@^6.12.4: + version "6.12.5" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.5.tgz#19b0e8bae8f476e5ba666300387775fb1a00a4da" + integrity sha512-lRF8RORchjpKG50/WFf8xmg7sgCLFiYNNnqdKflk63whMQcWR5ngGjiSXkL9bjxy6B2npOK2HSMN49jEBMSkag== + dependencies: + fast-deep-equal "^3.1.1" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.4.1" + uri-js "^4.2.2" + +ansi-escapes@^4.2.1: + version "4.3.1" + resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-4.3.1.tgz#a5c47cc43181f1f38ffd7076837700d395522a61" + integrity sha512-JWF7ocqNrp8u9oqpgV+wH5ftbt+cfvv+PTjOvKLT3AdYly/LmORARfEVT1iyjwN+4MqE5UmVKoAdIBqeoCHgLA== + dependencies: + type-fest "^0.11.0" + +ansi-regex@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.0.tgz#8b9f8f08cf1acb843756a839ca8c7e3168c51997" + integrity sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg== + +ansi-regex@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.0.tgz#388539f55179bf39339c81af30a654d69f87cb75" + integrity sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg== + +ansi-styles@^3.2.0, ansi-styles@^3.2.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" + integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== + dependencies: + color-convert "^1.9.0" + +ansi-styles@^4.1.0: + version "4.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.2.1.tgz#90ae75c424d008d2624c5bf29ead3177ebfcf359" + integrity sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA== + dependencies: + "@types/color-name" "^1.1.1" + color-convert "^2.0.1" + +anymatch@~3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.1.tgz#c55ecf02185e2469259399310c173ce31233b142" + integrity sha512-mM8522psRCqzV+6LhomX5wgp25YVibjh8Wj23I5RPkPppSVSjyKD2A2mBJmWGa+KN7f2D6LNh9jkBCeyLktzjg== + dependencies: + normalize-path "^3.0.0" + picomatch "^2.0.4" + +arg@^4.1.0: + version "4.1.3" + resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" + integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA== + +argparse@^1.0.7: + version "1.0.10" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" + integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== + dependencies: + sprintf-js "~1.0.2" + +arr-diff@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-4.0.0.tgz#d6461074febfec71e7e15235761a329a5dc7c520" + integrity sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA= + +arr-flatten@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.1.0.tgz#36048bbff4e7b47e136644316c99669ea5ae91f1" + integrity sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg== + +arr-union@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/arr-union/-/arr-union-3.1.0.tgz#e39b09aea9def866a8f206e288af63919bae39c4" + integrity sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ= + +array-find-index@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/array-find-index/-/array-find-index-1.0.2.tgz#df010aa1287e164bbda6f9723b0a96a1ec4187a1" + integrity sha1-3wEKoSh+Fku9pvlyOwqWoexBh6E= + +array-unique@^0.3.2: + version "0.3.2" + resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428" + integrity sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg= + +assign-symbols@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/assign-symbols/-/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367" + integrity sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c= + +astral-regex@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-1.0.0.tgz#6c8c3fb827dd43ee3918f27b82782ab7658a6fd9" + integrity sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg== + +atob@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9" + integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg== + +balanced-match@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" + integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c= + +base@^0.11.1: + version "0.11.2" + resolved "https://registry.yarnpkg.com/base/-/base-0.11.2.tgz#7bde5ced145b6d551a90db87f83c558b4eb48a8f" + integrity sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg== + dependencies: + cache-base "^1.0.1" + class-utils "^0.3.5" + component-emitter "^1.2.1" + define-property "^1.0.0" + isobject "^3.0.1" + mixin-deep "^1.2.0" + pascalcase "^0.1.1" + +big.js@^5.2.2: + version "5.2.2" + resolved "https://registry.yarnpkg.com/big.js/-/big.js-5.2.2.tgz#65f0af382f578bcdc742bd9c281e9cb2d7768328" + integrity sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ== + +binary-extensions@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.1.0.tgz#30fa40c9e7fe07dbc895678cd287024dea241dd9" + integrity sha512-1Yj8h9Q+QDF5FzhMs/c9+6UntbD5MkRfRwac8DoEm9ZfUBZ7tZ55YcGVAzEe4bXsdQHEk+s9S5wsOKVdZrw0tQ== + +brace-expansion@^1.1.7: + version "1.1.11" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" + integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== + dependencies: + balanced-match "^1.0.0" + concat-map "0.0.1" + +braces@^2.3.1: + version "2.3.2" + resolved "https://registry.yarnpkg.com/braces/-/braces-2.3.2.tgz#5979fd3f14cd531565e5fa2df1abfff1dfaee729" + integrity sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w== + dependencies: + arr-flatten "^1.1.0" + array-unique "^0.3.2" + extend-shallow "^2.0.1" + fill-range "^4.0.0" + isobject "^3.0.1" + repeat-element "^1.1.2" + snapdragon "^0.8.1" + snapdragon-node "^2.0.1" + split-string "^3.0.2" + to-regex "^3.0.1" + +braces@~3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" + integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== + dependencies: + fill-range "^7.0.1" + +buffer-from@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" + integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A== + +cache-base@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/cache-base/-/cache-base-1.0.1.tgz#0a7f46416831c8b662ee36fe4e7c59d76f666ab2" + integrity sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ== + dependencies: + collection-visit "^1.0.0" + component-emitter "^1.2.1" + get-value "^2.0.6" + has-value "^1.0.0" + isobject "^3.0.1" + set-value "^2.0.0" + to-object-path "^0.3.0" + union-value "^1.0.0" + unset-value "^1.0.0" + +call-me-maybe@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/call-me-maybe/-/call-me-maybe-1.0.1.tgz#26d208ea89e37b5cbde60250a15f031c16a4d66b" + integrity sha1-JtII6onje1y95gJQoV8DHBak1ms= + +callsites@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" + integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ== + +camelcase-keys@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-2.1.0.tgz#308beeaffdf28119051efa1d932213c91b8f92e7" + integrity sha1-MIvur/3ygRkFHvodkyITyRuPkuc= + dependencies: + camelcase "^2.0.0" + map-obj "^1.0.0" + +camelcase@^2.0.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-2.1.1.tgz#7c1d16d679a1bbe59ca02cacecfb011e201f5a1f" + integrity sha1-fB0W1nmhu+WcoCys7PsBHiAfWh8= + +chalk@^2.0.0, chalk@^2.1.0: + version "2.4.2" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" + integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== + dependencies: + ansi-styles "^3.2.1" + escape-string-regexp "^1.0.5" + supports-color "^5.3.0" + +chalk@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.0.tgz#4e14870a618d9e2edd97dd8345fd9d9dc315646a" + integrity sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A== + dependencies: + ansi-styles "^4.1.0" + supports-color "^7.1.0" + +chardet@^0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e" + integrity sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA== + +chokidar@^3.4.0: + version "3.4.2" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.4.2.tgz#38dc8e658dec3809741eb3ef7bb0a47fe424232d" + integrity sha512-IZHaDeBeI+sZJRX7lGcXsdzgvZqKv6sECqsbErJA4mHWfpRrD8B97kSFN4cQz6nGBGiuFia1MKR4d6c1o8Cv7A== + dependencies: + anymatch "~3.1.1" + braces "~3.0.2" + glob-parent "~5.1.0" + is-binary-path "~2.1.0" + is-glob "~4.0.1" + normalize-path "~3.0.0" + readdirp "~3.4.0" + optionalDependencies: + fsevents "~2.1.2" + +class-utils@^0.3.5: + version "0.3.6" + resolved "https://registry.yarnpkg.com/class-utils/-/class-utils-0.3.6.tgz#f93369ae8b9a7ce02fd41faad0ca83033190c463" + integrity sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg== + dependencies: + arr-union "^3.1.0" + define-property "^0.2.5" + isobject "^3.0.0" + static-extend "^0.1.1" + +cli-cursor@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-3.1.0.tgz#264305a7ae490d1d03bf0c9ba7c925d1753af307" + integrity sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw== + dependencies: + restore-cursor "^3.1.0" + +cli-width@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-3.0.0.tgz#a2f48437a2caa9a22436e794bf071ec9e61cedf6" + integrity sha512-FxqpkPPwu1HjuN93Omfm4h8uIanXofW0RxVEW3k5RKx+mJJYSthzNhp32Kzxxy3YAEZ/Dc/EWN1vZRY0+kOhbw== + +collection-visit@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/collection-visit/-/collection-visit-1.0.0.tgz#4bc0373c164bc3291b4d368c829cf1a80a59dca0" + integrity sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA= + dependencies: + map-visit "^1.0.0" + object-visit "^1.0.0" + +color-convert@^1.9.0: + version "1.9.3" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" + integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== + dependencies: + color-name "1.1.3" + +color-convert@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" + integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== + dependencies: + color-name "~1.1.4" + +color-name@1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" + integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= + +color-name@~1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" + integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== + +component-emitter@^1.2.1: + version "1.3.0" + resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.3.0.tgz#16e4070fba8ae29b679f2215853ee181ab2eabc0" + integrity sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg== + +concat-map@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= + +copy-descriptor@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d" + integrity sha1-Z29us8OZl8LuGsOpJP1hJHSPV40= + +cross-spawn@^6.0.5: + version "6.0.5" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" + integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ== + dependencies: + nice-try "^1.0.4" + path-key "^2.0.1" + semver "^5.5.0" + shebang-command "^1.2.0" + which "^1.2.9" + +currently-unhandled@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/currently-unhandled/-/currently-unhandled-0.4.1.tgz#988df33feab191ef799a61369dd76c17adf957ea" + integrity sha1-mI3zP+qxke95mmE2nddsF635V+o= + dependencies: + array-find-index "^1.0.1" + +dateformat@~1.0.4-1.2.3: + version "1.0.12" + resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-1.0.12.tgz#9f124b67594c937ff706932e4a642cca8dbbfee9" + integrity sha1-nxJLZ1lMk3/3BpMuSmQsyo27/uk= + dependencies: + get-stdin "^4.0.1" + meow "^3.3.0" + +debug@^2.2.0, debug@^2.3.3: + version "2.6.9" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" + integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== + dependencies: + ms "2.0.0" + +debug@^4.0.1, debug@^4.1.1: + version "4.2.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.2.0.tgz#7f150f93920e94c58f5574c2fd01a3110effe7f1" + integrity sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg== + dependencies: + ms "2.1.2" + +decamelize@^1.1.2: + version "1.2.0" + resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" + integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA= + +decode-uri-component@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" + integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU= + +deep-is@~0.1.3: + version "0.1.3" + resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" + integrity sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ= + +define-property@^0.2.5: + version "0.2.5" + resolved "https://registry.yarnpkg.com/define-property/-/define-property-0.2.5.tgz#c35b1ef918ec3c990f9a5bc57be04aacec5c8116" + integrity sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY= + dependencies: + is-descriptor "^0.1.0" + +define-property@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/define-property/-/define-property-1.0.0.tgz#769ebaaf3f4a63aad3af9e8d304c9bbe79bfb0e6" + integrity sha1-dp66rz9KY6rTr56NMEybvnm/sOY= + dependencies: + is-descriptor "^1.0.0" + +define-property@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/define-property/-/define-property-2.0.2.tgz#d459689e8d654ba77e02a817f8710d702cb16e9d" + integrity sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ== + dependencies: + is-descriptor "^1.0.2" + isobject "^3.0.1" + +diff@^4.0.1: + version "4.0.2" + resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" + integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== + +doctrine@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-3.0.0.tgz#addebead72a6574db783639dc87a121773973961" + integrity sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w== + dependencies: + esutils "^2.0.2" + +dynamic-dedupe@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/dynamic-dedupe/-/dynamic-dedupe-0.3.0.tgz#06e44c223f5e4e94d78ef9db23a6515ce2f962a1" + integrity sha1-BuRMIj9eTpTXjvnbI6ZRXOL5YqE= + dependencies: + xtend "^4.0.0" + +emoji-regex@^7.0.1: + version "7.0.3" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-7.0.3.tgz#933a04052860c85e83c122479c4748a8e4c72156" + integrity sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA== + +emoji-regex@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" + integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== + +emojis-list@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-3.0.0.tgz#5570662046ad29e2e916e71aae260abdff4f6a78" + integrity sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q== + +error-ex@^1.2.0: + version "1.3.2" + resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" + integrity sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g== + dependencies: + is-arrayish "^0.2.1" + +escape-string-regexp@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" + integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= + +eslint-scope@^5.0.0: + version "5.1.1" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" + integrity sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw== + dependencies: + esrecurse "^4.3.0" + estraverse "^4.1.1" + +eslint-utils@^1.4.3: + version "1.4.3" + resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-1.4.3.tgz#74fec7c54d0776b6f67e0251040b5806564e981f" + integrity sha512-fbBN5W2xdY45KulGXmLHZ3c3FHfVYmKg0IrAKGOkT/464PQsx2UeIzfz1RmEci+KLm1bBaAzZAh8+/E+XAeZ8Q== + dependencies: + eslint-visitor-keys "^1.1.0" + +eslint-utils@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-2.1.0.tgz#d2de5e03424e707dc10c74068ddedae708741b27" + integrity sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg== + dependencies: + eslint-visitor-keys "^1.1.0" + +eslint-visitor-keys@^1.1.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz#30ebd1ef7c2fdff01c3a4f151044af25fab0523e" + integrity sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ== + +eslint@^6.8.0: + version "6.8.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-6.8.0.tgz#62262d6729739f9275723824302fb227c8c93ffb" + integrity sha512-K+Iayyo2LtyYhDSYwz5D5QdWw0hCacNzyq1Y821Xna2xSJj7cijoLLYmLxTQgcgZ9mC61nryMy9S7GRbYpI5Ig== + dependencies: + "@babel/code-frame" "^7.0.0" + ajv "^6.10.0" + chalk "^2.1.0" + cross-spawn "^6.0.5" + debug "^4.0.1" + doctrine "^3.0.0" + eslint-scope "^5.0.0" + eslint-utils "^1.4.3" + eslint-visitor-keys "^1.1.0" + espree "^6.1.2" + esquery "^1.0.1" + esutils "^2.0.2" + file-entry-cache "^5.0.1" + functional-red-black-tree "^1.0.1" + glob-parent "^5.0.0" + globals "^12.1.0" + ignore "^4.0.6" + import-fresh "^3.0.0" + imurmurhash "^0.1.4" + inquirer "^7.0.0" + is-glob "^4.0.0" + js-yaml "^3.13.1" + json-stable-stringify-without-jsonify "^1.0.1" + levn "^0.3.0" + lodash "^4.17.14" + minimatch "^3.0.4" + mkdirp "^0.5.1" + natural-compare "^1.4.0" + optionator "^0.8.3" + progress "^2.0.0" + regexpp "^2.0.1" + semver "^6.1.2" + strip-ansi "^5.2.0" + strip-json-comments "^3.0.1" + table "^5.2.3" + text-table "^0.2.0" + v8-compile-cache "^2.0.3" + +espree@^6.1.2: + version "6.2.1" + resolved "https://registry.yarnpkg.com/espree/-/espree-6.2.1.tgz#77fc72e1fd744a2052c20f38a5b575832e82734a" + integrity sha512-ysCxRQY3WaXJz9tdbWOwuWr5Y/XrPTGX9Kiz3yoUXwW0VZ4w30HTkQLaGx/+ttFjF8i+ACbArnB4ce68a9m5hw== + dependencies: + acorn "^7.1.1" + acorn-jsx "^5.2.0" + eslint-visitor-keys "^1.1.0" + +esprima@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" + integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== + +esquery@^1.0.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.3.1.tgz#b78b5828aa8e214e29fb74c4d5b752e1c033da57" + integrity sha512-olpvt9QG0vniUBZspVRN6lwB7hOZoTRtT+jzR+tS4ffYx2mzbw+z0XCOk44aaLYKApNX5nMm+E+P6o25ip/DHQ== + dependencies: + estraverse "^5.1.0" + +esrecurse@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.3.0.tgz#7ad7964d679abb28bee72cec63758b1c5d2c9921" + integrity sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag== + dependencies: + estraverse "^5.2.0" + +estraverse@^4.1.1: + version "4.3.0" + resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.3.0.tgz#398ad3f3c5a24948be7725e83d11a7de28cdbd1d" + integrity sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw== + +estraverse@^5.1.0, estraverse@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.2.0.tgz#307df42547e6cc7324d3cf03c155d5cdb8c53880" + integrity sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ== + +esutils@^2.0.2: + version "2.0.3" + resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" + integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== + +eventemitter3@^4.0.4: + version "4.0.7" + resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.7.tgz#2de9b68f6528d5644ef5c59526a1b4a07306169f" + integrity sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw== + +expand-brackets@^2.1.4: + version "2.1.4" + resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-2.1.4.tgz#b77735e315ce30f6b6eff0f83b04151a22449622" + integrity sha1-t3c14xXOMPa27/D4OwQVGiJEliI= + dependencies: + debug "^2.3.3" + define-property "^0.2.5" + extend-shallow "^2.0.1" + posix-character-classes "^0.1.0" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.1" + +exports-loader@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/exports-loader/-/exports-loader-1.1.0.tgz#26a16706e4cf533145de24c1419baf33b624fb5c" + integrity sha512-zGB2SujiAyO0Rwn4GQ17/HlT8cwmT8abcBeZpr2R3sItJ5sI5Y9BzNzus3H9tH1iWLAoJLi9N3TP54D2+j859Q== + dependencies: + loader-utils "^2.0.0" + schema-utils "^2.7.0" + source-map "^0.6.1" + +extend-shallow@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-2.0.1.tgz#51af7d614ad9a9f610ea1bafbb989d6b1c56890f" + integrity sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8= + dependencies: + is-extendable "^0.1.0" + +extend-shallow@^3.0.0, extend-shallow@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-3.0.2.tgz#26a71aaf073b39fb2127172746131c2704028db8" + integrity sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg= + dependencies: + assign-symbols "^1.0.0" + is-extendable "^1.0.1" + +external-editor@^3.0.3: + version "3.1.0" + resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-3.1.0.tgz#cb03f740befae03ea4d283caed2741a83f335495" + integrity sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew== + dependencies: + chardet "^0.7.0" + iconv-lite "^0.4.24" + tmp "^0.0.33" + +extglob@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/extglob/-/extglob-2.0.4.tgz#ad00fe4dc612a9232e8718711dc5cb5ab0285543" + integrity sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw== + dependencies: + array-unique "^0.3.2" + define-property "^1.0.0" + expand-brackets "^2.1.4" + extend-shallow "^2.0.1" + fragment-cache "^0.2.1" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.1" + +fast-deep-equal@^3.1.1: + version "3.1.3" + resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" + integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== + +fast-glob@^2.2.6: + version "2.2.7" + resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-2.2.7.tgz#6953857c3afa475fff92ee6015d52da70a4cd39d" + integrity sha512-g1KuQwHOZAmOZMuBtHdxDtju+T2RT8jgCC9aANsbpdiDDTSnjgfuVsIBNKbUeJI3oKMRExcfNDtJl4OhbffMsw== + dependencies: + "@mrmlnc/readdir-enhanced" "^2.2.1" + "@nodelib/fs.stat" "^1.1.2" + glob-parent "^3.1.0" + is-glob "^4.0.0" + merge2 "^1.2.3" + micromatch "^3.1.10" + +fast-json-stable-stringify@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" + integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== + +fast-levenshtein@~2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" + integrity sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc= + +figures@^3.0.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/figures/-/figures-3.2.0.tgz#625c18bd293c604dc4a8ddb2febf0c88341746af" + integrity sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg== + dependencies: + escape-string-regexp "^1.0.5" + +file-entry-cache@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-5.0.1.tgz#ca0f6efa6dd3d561333fb14515065c2fafdf439c" + integrity sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g== + dependencies: + flat-cache "^2.0.1" + +fill-range@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-4.0.0.tgz#d544811d428f98eb06a63dc402d2403c328c38f7" + integrity sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc= + dependencies: + extend-shallow "^2.0.1" + is-number "^3.0.0" + repeat-string "^1.6.1" + to-regex-range "^2.1.0" + +fill-range@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" + integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== + dependencies: + to-regex-range "^5.0.1" + +find-up@^1.0.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-1.1.2.tgz#6b2e9822b1a2ce0a60ab64d610eccad53cb24d0f" + integrity sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8= + dependencies: + path-exists "^2.0.0" + pinkie-promise "^2.0.0" + +flat-cache@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-2.0.1.tgz#5d296d6f04bda44a4630a301413bdbc2ec085ec0" + integrity sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA== + dependencies: + flatted "^2.0.0" + rimraf "2.6.3" + write "1.0.3" + +flatted@^2.0.0: + version "2.0.2" + resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138" + integrity sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA== + +for-in@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" + integrity sha1-gQaNKVqBQuwKxybG4iAMMPttXoA= + +fragment-cache@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/fragment-cache/-/fragment-cache-0.2.1.tgz#4290fad27f13e89be7f33799c6bc5a0abfff0d19" + integrity sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk= + dependencies: + map-cache "^0.2.2" + +fs.realpath@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" + integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= + +fsevents@~2.1.2: + version "2.1.3" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.1.3.tgz#fb738703ae8d2f9fe900c33836ddebee8b97f23e" + integrity sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ== + +functional-red-black-tree@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327" + integrity sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc= + +get-stdin@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe" + integrity sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4= + +get-value@^2.0.3, get-value@^2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/get-value/-/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28" + integrity sha1-3BXKHGcjh8p2vTesCjlbogQqLCg= + +glob-parent@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-3.1.0.tgz#9e6af6299d8d3bd2bd40430832bd113df906c5ae" + integrity sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4= + dependencies: + is-glob "^3.1.0" + path-dirname "^1.0.0" + +glob-parent@^5.0.0, glob-parent@~5.1.0: + version "5.1.1" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.1.tgz#b6c1ef417c4e5663ea498f1c45afac6916bbc229" + integrity sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ== + dependencies: + is-glob "^4.0.1" + +glob-to-regexp@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.3.0.tgz#8c5a1494d2066c570cc3bfe4496175acc4d502ab" + integrity sha1-jFoUlNIGbFcMw7/kSWF1rMTVAqs= + +glob@^7.1.3, glob@^7.1.6: + version "7.1.6" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6" + integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.4" + once "^1.3.0" + path-is-absolute "^1.0.0" + +globals@^12.1.0: + version "12.4.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-12.4.0.tgz#a18813576a41b00a24a97e7f815918c2e19925f8" + integrity sha512-BWICuzzDvDoH54NHKCseDanAhE3CeDorgDL5MT6LMXXj2WCnd9UC2szdk4AWLfjdgNBCXLUanXYcpBBKOSWGwg== + dependencies: + type-fest "^0.8.1" + +graceful-fs@^4.1.2: + version "4.2.4" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.4.tgz#2256bde14d3632958c465ebc96dc467ca07a29fb" + integrity sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw== + +has-flag@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" + integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= + +has-flag@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" + integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== + +has-value@^0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/has-value/-/has-value-0.3.1.tgz#7b1f58bada62ca827ec0a2078025654845995e1f" + integrity sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8= + dependencies: + get-value "^2.0.3" + has-values "^0.1.4" + isobject "^2.0.0" + +has-value@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-value/-/has-value-1.0.0.tgz#18b281da585b1c5c51def24c930ed29a0be6b177" + integrity sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc= + dependencies: + get-value "^2.0.6" + has-values "^1.0.0" + isobject "^3.0.0" + +has-values@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/has-values/-/has-values-0.1.4.tgz#6d61de95d91dfca9b9a02089ad384bff8f62b771" + integrity sha1-bWHeldkd/Km5oCCJrThL/49it3E= + +has-values@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-values/-/has-values-1.0.0.tgz#95b0b63fec2146619a6fe57fe75628d5a39efe4f" + integrity sha1-lbC2P+whRmGab+V/51Yo1aOe/k8= + dependencies: + is-number "^3.0.0" + kind-of "^4.0.0" + +hosted-git-info@^2.1.4: + version "2.8.8" + resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.8.tgz#7539bd4bc1e0e0a895815a2e0262420b12858488" + integrity sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg== + +iconv-lite@^0.4.24: + version "0.4.24" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" + integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== + dependencies: + safer-buffer ">= 2.1.2 < 3" + +ignore@^4.0.6: + version "4.0.6" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" + integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg== + +import-fresh@^3.0.0: + version "3.2.1" + resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.2.1.tgz#633ff618506e793af5ac91bf48b72677e15cbe66" + integrity sha512-6e1q1cnWP2RXD9/keSkxHScg508CdXqXWgWBaETNhyuBFz+kUZlKboh+ISK+bU++DmbHimVBrOz/zzPe0sZ3sQ== + dependencies: + parent-module "^1.0.0" + resolve-from "^4.0.0" + +imports-loader@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/imports-loader/-/imports-loader-1.1.0.tgz#1c3a388d0c5cd7f9eb08f3646d4aae3b70e57933" + integrity sha512-HcPM6rULdQ6EBLVq+5O+CF9xb7qiUjsRm6V28bTG/c3IU5sQkVZzUDwYY0r4jHvSAmVFdO9WA/vLAURR5WQSeQ== + dependencies: + loader-utils "^2.0.0" + schema-utils "^2.7.0" + source-map "^0.6.1" + strip-comments "^2.0.1" + +imurmurhash@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" + integrity sha1-khi5srkoojixPcT7a21XbyMUU+o= + +indent-string@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-2.1.0.tgz#8e2d48348742121b4a8218b7a137e9a52049dc80" + integrity sha1-ji1INIdCEhtKghi3oTfppSBJ3IA= + dependencies: + repeating "^2.0.0" + +inflight@^1.0.4: + version "1.0.6" + resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= + dependencies: + once "^1.3.0" + wrappy "1" + +inherits@2: + version "2.0.4" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" + integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== + +inherits@2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" + integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4= + +inquirer@^7.0.0: + version "7.3.3" + resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-7.3.3.tgz#04d176b2af04afc157a83fd7c100e98ee0aad003" + integrity sha512-JG3eIAj5V9CwcGvuOmoo6LB9kbAYT8HXffUl6memuszlwDC/qvFAJw49XJ5NROSFNPxp3iQg1GqkFhaY/CR0IA== + dependencies: + ansi-escapes "^4.2.1" + chalk "^4.1.0" + cli-cursor "^3.1.0" + cli-width "^3.0.0" + external-editor "^3.0.3" + figures "^3.0.0" + lodash "^4.17.19" + mute-stream "0.0.8" + run-async "^2.4.0" + rxjs "^6.6.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + through "^2.3.6" + +is-accessor-descriptor@^0.1.6: + version "0.1.6" + resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz#a9e12cb3ae8d876727eeef3843f8a0897b5c98d6" + integrity sha1-qeEss66Nh2cn7u84Q/igiXtcmNY= + dependencies: + kind-of "^3.0.2" + +is-accessor-descriptor@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz#169c2f6d3df1f992618072365c9b0ea1f6878656" + integrity sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ== + dependencies: + kind-of "^6.0.0" + +is-arrayish@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" + integrity sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0= + +is-binary-path@~2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" + integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== + dependencies: + binary-extensions "^2.0.0" + +is-buffer@^1.1.5: + version "1.1.6" + resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" + integrity sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w== + +is-data-descriptor@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz#0b5ee648388e2c860282e793f1856fec3f301b56" + integrity sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y= + dependencies: + kind-of "^3.0.2" + +is-data-descriptor@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz#d84876321d0e7add03990406abbbbd36ba9268c7" + integrity sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ== + dependencies: + kind-of "^6.0.0" + +is-descriptor@^0.1.0: + version "0.1.6" + resolved "https://registry.yarnpkg.com/is-descriptor/-/is-descriptor-0.1.6.tgz#366d8240dde487ca51823b1ab9f07a10a78251ca" + integrity sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg== + dependencies: + is-accessor-descriptor "^0.1.6" + is-data-descriptor "^0.1.4" + kind-of "^5.0.0" + +is-descriptor@^1.0.0, is-descriptor@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-descriptor/-/is-descriptor-1.0.2.tgz#3b159746a66604b04f8c81524ba365c5f14d86ec" + integrity sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg== + dependencies: + is-accessor-descriptor "^1.0.0" + is-data-descriptor "^1.0.0" + kind-of "^6.0.2" + +is-extendable@^0.1.0, is-extendable@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" + integrity sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik= + +is-extendable@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-1.0.1.tgz#a7470f9e426733d81bd81e1155264e3a3507cab4" + integrity sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA== + dependencies: + is-plain-object "^2.0.4" + +is-extglob@^2.1.0, is-extglob@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" + integrity sha1-qIwCU1eR8C7TfHahueqXc8gz+MI= + +is-finite@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-finite/-/is-finite-1.1.0.tgz#904135c77fb42c0641d6aa1bcdbc4daa8da082f3" + integrity sha512-cdyMtqX/BOqqNBBiKlIVkytNHm49MtMlYyn1zxzvJKWmFMlGzm+ry5BBfYyeY9YmNKbRSo/o7OX9w9ale0wg3w== + +is-fullwidth-code-point@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" + integrity sha1-o7MKXE8ZkYMWeqq5O+764937ZU8= + +is-fullwidth-code-point@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" + integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== + +is-glob@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-3.1.0.tgz#7ba5ae24217804ac70707b96922567486cc3e84a" + integrity sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo= + dependencies: + is-extglob "^2.1.0" + +is-glob@^4.0.0, is-glob@^4.0.1, is-glob@~4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.1.tgz#7567dbe9f2f5e2467bc77ab83c4a29482407a5dc" + integrity sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg== + dependencies: + is-extglob "^2.1.1" + +is-number@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195" + integrity sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU= + dependencies: + kind-of "^3.0.2" + +is-number@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" + integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== + +is-plain-object@^2.0.3, is-plain-object@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677" + integrity sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og== + dependencies: + isobject "^3.0.1" + +is-utf8@^0.2.0: + version "0.2.1" + resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" + integrity sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI= + +is-windows@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d" + integrity sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA== + +isarray@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" + integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE= + +isexe@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" + integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= + +isobject@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/isobject/-/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89" + integrity sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk= + dependencies: + isarray "1.0.0" + +isobject@^3.0.0, isobject@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" + integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8= + +jasmine-core@~3.6.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-3.6.0.tgz#491f3bb23941799c353ceb7a45b38a950ebc5a20" + integrity sha512-8uQYa7zJN8hq9z+g8z1bqCfdC8eoDAeVnM5sfqs7KHv9/ifoJ500m018fpFc7RDaO6SWCLCXwo/wPSNcdYTgcw== + +jasmine@^3.5.0: + version "3.6.1" + resolved "https://registry.yarnpkg.com/jasmine/-/jasmine-3.6.1.tgz#a20456b309a669b547a3c24bb2120f16f70cfc65" + integrity sha512-Jqp8P6ZWkTVFGmJwBK46p+kJNrZCdqkQ4GL+PGuBXZwK1fM4ST9BizkYgIwCFqYYqnTizAy6+XG2Ej5dFrej9Q== + dependencies: + fast-glob "^2.2.6" + jasmine-core "~3.6.0" + +js-tokens@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" + integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== + +js-yaml@^3.13.1: + version "3.14.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.0.tgz#a7a34170f26a21bb162424d8adacb4113a69e482" + integrity sha512-/4IbIeHcD9VMHFqDR/gQ7EdZdLimOvW2DdcxFjdyyZ9NsbS+ccrXqVWDtab/lRl5AlUqmpBx8EhPaWR+OtY17A== + dependencies: + argparse "^1.0.7" + esprima "^4.0.0" + +json-schema-traverse@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" + integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== + +json-stable-stringify-without-jsonify@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" + integrity sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE= + +json5@^2.1.2: + version "2.1.3" + resolved "https://registry.yarnpkg.com/json5/-/json5-2.1.3.tgz#c9b0f7fa9233bfe5807fe66fcf3a5617ed597d43" + integrity sha512-KXPvOm8K9IJKFM0bmdn8QXh7udDh1g/giieX0NLCaMnb4hEiVFqnop2ImTXCc5e0/oHz3LTqmHGtExn5hfMkOA== + dependencies: + minimist "^1.2.5" + +kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.2.0: + version "3.2.2" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" + integrity sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ= + dependencies: + is-buffer "^1.1.5" + +kind-of@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-4.0.0.tgz#20813df3d712928b207378691a45066fae72dd57" + integrity sha1-IIE989cSkosgc3hpGkUGb65y3Vc= + dependencies: + is-buffer "^1.1.5" + +kind-of@^5.0.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-5.1.0.tgz#729c91e2d857b7a419a1f9aa65685c4c33f5845d" + integrity sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw== + +kind-of@^6.0.0, kind-of@^6.0.2: + version "6.0.3" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" + integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== + +levn@^0.3.0, levn@~0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee" + integrity sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4= + dependencies: + prelude-ls "~1.1.2" + type-check "~0.3.2" + +load-json-file@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-1.1.0.tgz#956905708d58b4bab4c2261b04f59f31c99374c0" + integrity sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA= + dependencies: + graceful-fs "^4.1.2" + parse-json "^2.2.0" + pify "^2.0.0" + pinkie-promise "^2.0.0" + strip-bom "^2.0.0" + +loader-utils@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-2.0.0.tgz#e4cace5b816d425a166b5f097e10cd12b36064b0" + integrity sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ== + dependencies: + big.js "^5.2.2" + emojis-list "^3.0.0" + json5 "^2.1.2" + +lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19: + version "4.17.20" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52" + integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA== + +loud-rejection@^1.0.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/loud-rejection/-/loud-rejection-1.6.0.tgz#5b46f80147edee578870f086d04821cf998e551f" + integrity sha1-W0b4AUft7leIcPCG0Eghz5mOVR8= + dependencies: + currently-unhandled "^0.4.1" + signal-exit "^3.0.0" + +make-error@^1.1.1: + version "1.3.6" + resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" + integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== + +map-cache@^0.2.2: + version "0.2.2" + resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf" + integrity sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8= + +map-obj@^1.0.0, map-obj@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-1.0.1.tgz#d933ceb9205d82bdcf4886f6742bdc2b4dea146d" + integrity sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0= + +map-visit@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/map-visit/-/map-visit-1.0.0.tgz#ecdca8f13144e660f1b5bd41f12f3479d98dfb8f" + integrity sha1-7Nyo8TFE5mDxtb1B8S80edmN+48= + dependencies: + object-visit "^1.0.0" + +meow@^3.3.0: + version "3.7.0" + resolved "https://registry.yarnpkg.com/meow/-/meow-3.7.0.tgz#72cb668b425228290abbfa856892587308a801fb" + integrity sha1-cstmi0JSKCkKu/qFaJJYcwioAfs= + dependencies: + camelcase-keys "^2.0.0" + decamelize "^1.1.2" + loud-rejection "^1.0.0" + map-obj "^1.0.1" + minimist "^1.1.3" + normalize-package-data "^2.3.4" + object-assign "^4.0.1" + read-pkg-up "^1.0.1" + redent "^1.0.0" + trim-newlines "^1.0.0" + +merge2@^1.2.3: + version "1.4.1" + resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae" + integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== + +micromatch@^3.1.10: + version "3.1.10" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23" + integrity sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg== + dependencies: + arr-diff "^4.0.0" + array-unique "^0.3.2" + braces "^2.3.1" + define-property "^2.0.2" + extend-shallow "^3.0.2" + extglob "^2.0.4" + fragment-cache "^0.2.1" + kind-of "^6.0.2" + nanomatch "^1.2.9" + object.pick "^1.3.0" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.2" + +mimic-fn@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" + integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== + +minimatch@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" + integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA== + dependencies: + brace-expansion "^1.1.7" + +minimist@^1.1.3, minimist@^1.2.5: + version "1.2.5" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" + integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== + +mixin-deep@^1.2.0: + version "1.3.2" + resolved "https://registry.yarnpkg.com/mixin-deep/-/mixin-deep-1.3.2.tgz#1120b43dc359a785dce65b55b82e257ccf479566" + integrity sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA== + dependencies: + for-in "^1.0.2" + is-extendable "^1.0.1" + +mkdirp@^0.5.1: + version "0.5.5" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def" + integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ== + dependencies: + minimist "^1.2.5" + +mkdirp@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" + integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== + +ms@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" + integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g= + +ms@2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" + integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== + +mute-stream@0.0.8: + version "0.0.8" + resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d" + integrity sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA== + +nanomatch@^1.2.9: + version "1.2.13" + resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119" + integrity sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA== + dependencies: + arr-diff "^4.0.0" + array-unique "^0.3.2" + define-property "^2.0.2" + extend-shallow "^3.0.2" + fragment-cache "^0.2.1" + is-windows "^1.0.2" + kind-of "^6.0.2" + object.pick "^1.3.0" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.1" + +natural-compare@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" + integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc= + +nice-try@^1.0.4: + version "1.0.5" + resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" + integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ== + +normalize-package-data@^2.3.2, normalize-package-data@^2.3.4: + version "2.5.0" + resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.5.0.tgz#e66db1838b200c1dfc233225d12cb36520e234a8" + integrity sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA== + dependencies: + hosted-git-info "^2.1.4" + resolve "^1.10.0" + semver "2 || 3 || 4 || 5" + validate-npm-package-license "^3.0.1" + +normalize-path@^3.0.0, normalize-path@~3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" + integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== + +object-assign@^4.0.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" + integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM= + +object-copy@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/object-copy/-/object-copy-0.1.0.tgz#7e7d858b781bd7c991a41ba975ed3812754e998c" + integrity sha1-fn2Fi3gb18mRpBupde04EnVOmYw= + dependencies: + copy-descriptor "^0.1.0" + define-property "^0.2.5" + kind-of "^3.0.3" + +object-visit@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/object-visit/-/object-visit-1.0.1.tgz#f79c4493af0c5377b59fe39d395e41042dd045bb" + integrity sha1-95xEk68MU3e1n+OdOV5BBC3QRbs= + dependencies: + isobject "^3.0.0" + +object.pick@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/object.pick/-/object.pick-1.3.0.tgz#87a10ac4c1694bd2e1cbf53591a66141fb5dd747" + integrity sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c= + dependencies: + isobject "^3.0.1" + +once@^1.3.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= + dependencies: + wrappy "1" + +onetime@^5.1.0: + version "5.1.2" + resolved "https://registry.yarnpkg.com/onetime/-/onetime-5.1.2.tgz#d0e96ebb56b07476df1dd9c4806e5237985ca45e" + integrity sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg== + dependencies: + mimic-fn "^2.1.0" + +optionator@^0.8.3: + version "0.8.3" + resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.3.tgz#84fa1d036fe9d3c7e21d99884b601167ec8fb495" + integrity sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA== + dependencies: + deep-is "~0.1.3" + fast-levenshtein "~2.0.6" + levn "~0.3.0" + prelude-ls "~1.1.2" + type-check "~0.3.2" + word-wrap "~1.2.3" + +os-tmpdir@~1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" + integrity sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ= + +parent-module@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2" + integrity sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g== + dependencies: + callsites "^3.0.0" + +parse-json@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-2.2.0.tgz#f480f40434ef80741f8469099f8dea18f55a4dc9" + integrity sha1-9ID0BDTvgHQfhGkJn43qGPVaTck= + dependencies: + error-ex "^1.2.0" + +pascalcase@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14" + integrity sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ= + +path-dirname@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/path-dirname/-/path-dirname-1.0.2.tgz#cc33d24d525e099a5388c0336c6e32b9160609e0" + integrity sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA= + +path-exists@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-2.1.0.tgz#0feb6c64f0fc518d9a754dd5efb62c7022761f4b" + integrity sha1-D+tsZPD8UY2adU3V77YscCJ2H0s= + dependencies: + pinkie-promise "^2.0.0" + +path-is-absolute@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= + +path-key@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" + integrity sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A= + +path-parse@^1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" + integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw== + +path-type@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/path-type/-/path-type-1.1.0.tgz#59c44f7ee491da704da415da5a4070ba4f8fe441" + integrity sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE= + dependencies: + graceful-fs "^4.1.2" + pify "^2.0.0" + pinkie-promise "^2.0.0" + +path@^0.12.7: + version "0.12.7" + resolved "https://registry.yarnpkg.com/path/-/path-0.12.7.tgz#d4dc2a506c4ce2197eb481ebfcd5b36c0140b10f" + integrity sha1-1NwqUGxM4hl+tIHr/NWzbAFAsQ8= + dependencies: + process "^0.11.1" + util "^0.10.3" + +phaser@^3.24.1: + version "3.24.1" + resolved "https://registry.yarnpkg.com/phaser/-/phaser-3.24.1.tgz#376e0c965d2a35af37c06ee78627dafbde5be017" + integrity sha512-WbrRMkbpEzarkfrq83akeauc6b8xNxsOTpDygyW7wrU2G2ne6kOYu3hji4UAaGnZaOLrVuj8ycYPjX9P1LxcDw== + dependencies: + eventemitter3 "^4.0.4" + exports-loader "^1.1.0" + imports-loader "^1.1.0" + path "^0.12.7" + +picomatch@^2.0.4, picomatch@^2.2.1: + version "2.2.2" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad" + integrity sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg== + +pify@^2.0.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" + integrity sha1-7RQaasBDqEnqWISY59yosVMw6Qw= + +pinkie-promise@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa" + integrity sha1-ITXW36ejWMBprJsXh3YogihFD/o= + dependencies: + pinkie "^2.0.0" + +pinkie@^2.0.0: + version "2.0.4" + resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870" + integrity sha1-clVrgM+g1IqXToDnckjoDtT3+HA= + +posix-character-classes@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab" + integrity sha1-AerA/jta9xoqbAL+q7jB/vfgDqs= + +prelude-ls@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" + integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ= + +process@^0.11.1: + version "0.11.10" + resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" + integrity sha1-czIwDoQBYb2j5podHZGn1LwW8YI= + +progress@^2.0.0: + version "2.0.3" + resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8" + integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA== + +punycode@^2.1.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" + integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== + +read-pkg-up@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-1.0.1.tgz#9d63c13276c065918d57f002a57f40a1b643fb02" + integrity sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI= + dependencies: + find-up "^1.0.0" + read-pkg "^1.0.0" + +read-pkg@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-1.1.0.tgz#f5ffaa5ecd29cb31c0474bca7d756b6bb29e3f28" + integrity sha1-9f+qXs0pyzHAR0vKfXVra7KePyg= + dependencies: + load-json-file "^1.0.0" + normalize-package-data "^2.3.2" + path-type "^1.0.0" + +readdirp@~3.4.0: + version "3.4.0" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.4.0.tgz#9fdccdf9e9155805449221ac645e8303ab5b9ada" + integrity sha512-0xe001vZBnJEK+uKcj8qOhyAKPzIT+gStxWr3LCB0DwcXR5NZJ3IaC+yGnHCYzB/S7ov3m3EEbZI2zeNvX+hGQ== + dependencies: + picomatch "^2.2.1" + +redent@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/redent/-/redent-1.0.0.tgz#cf916ab1fd5f1f16dfb20822dd6ec7f730c2afde" + integrity sha1-z5Fqsf1fHxbfsggi3W7H9zDCr94= + dependencies: + indent-string "^2.1.0" + strip-indent "^1.0.1" + +regex-not@^1.0.0, regex-not@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/regex-not/-/regex-not-1.0.2.tgz#1f4ece27e00b0b65e0247a6810e6a85d83a5752c" + integrity sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A== + dependencies: + extend-shallow "^3.0.2" + safe-regex "^1.1.0" + +regexpp@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f" + integrity sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw== + +regexpp@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.1.0.tgz#206d0ad0a5648cffbdb8ae46438f3dc51c9f78e2" + integrity sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q== + +repeat-element@^1.1.2: + version "1.1.3" + resolved "https://registry.yarnpkg.com/repeat-element/-/repeat-element-1.1.3.tgz#782e0d825c0c5a3bb39731f84efee6b742e6b1ce" + integrity sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g== + +repeat-string@^1.6.1: + version "1.6.1" + resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" + integrity sha1-jcrkcOHIirwtYA//Sndihtp15jc= + +repeating@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/repeating/-/repeating-2.0.1.tgz#5214c53a926d3552707527fbab415dbc08d06dda" + integrity sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo= + dependencies: + is-finite "^1.0.0" + +resolve-from@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" + integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g== + +resolve-url@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" + integrity sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo= + +resolve@^1.0.0, resolve@^1.10.0: + version "1.17.0" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.17.0.tgz#b25941b54968231cc2d1bb76a79cb7f2c0bf8444" + integrity sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w== + dependencies: + path-parse "^1.0.6" + +restore-cursor@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-3.1.0.tgz#39f67c54b3a7a58cea5236d95cf0034239631f7e" + integrity sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA== + dependencies: + onetime "^5.1.0" + signal-exit "^3.0.2" + +ret@~0.1.10: + version "0.1.15" + resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc" + integrity sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg== + +rimraf@2.6.3: + version "2.6.3" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.3.tgz#b2d104fe0d8fb27cf9e0a1cda8262dd3833c6cab" + integrity sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA== + dependencies: + glob "^7.1.3" + +rimraf@^2.6.1: + version "2.7.1" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec" + integrity sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w== + dependencies: + glob "^7.1.3" + +run-async@^2.4.0: + version "2.4.1" + resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.4.1.tgz#8440eccf99ea3e70bd409d49aab88e10c189a455" + integrity sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ== + +rxjs@^6.6.0: + version "6.6.3" + resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.6.3.tgz#8ca84635c4daa900c0d3967a6ee7ac60271ee552" + integrity sha512-trsQc+xYYXZ3urjOiJOuCOa5N3jAZ3eiSpQB5hIT8zGlL2QfnHLJ2r7GMkBGuIausdJN1OneaI6gQlsqNHHmZQ== + dependencies: + tslib "^1.9.0" + +safe-regex@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/safe-regex/-/safe-regex-1.1.0.tgz#40a3669f3b077d1e943d44629e157dd48023bf2e" + integrity sha1-QKNmnzsHfR6UPURinhV91IAjvy4= + dependencies: + ret "~0.1.10" + +"safer-buffer@>= 2.1.2 < 3": + version "2.1.2" + resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" + integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== + +schema-utils@^2.7.0: + version "2.7.1" + resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-2.7.1.tgz#1ca4f32d1b24c590c203b8e7a50bf0ea4cd394d7" + integrity sha512-SHiNtMOUGWBQJwzISiVYKu82GiV4QYGePp3odlY1tuKO7gPtphAT5R/py0fA6xtbgLL/RvtJZnU9b8s0F1q0Xg== + dependencies: + "@types/json-schema" "^7.0.5" + ajv "^6.12.4" + ajv-keywords "^3.5.2" + +"semver@2 || 3 || 4 || 5", semver@^5.5.0: + version "5.7.1" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" + integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== + +semver@^6.1.2: + version "6.3.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" + integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== + +semver@^7.3.2: + version "7.3.2" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.2.tgz#604962b052b81ed0786aae84389ffba70ffd3938" + integrity sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ== + +set-value@^2.0.0, set-value@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/set-value/-/set-value-2.0.1.tgz#a18d40530e6f07de4228c7defe4227af8cad005b" + integrity sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw== + dependencies: + extend-shallow "^2.0.1" + is-extendable "^0.1.1" + is-plain-object "^2.0.3" + split-string "^3.0.1" + +shebang-command@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" + integrity sha1-RKrGW2lbAzmJaMOfNj/uXer98eo= + dependencies: + shebang-regex "^1.0.0" + +shebang-regex@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" + integrity sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM= + +signal-exit@^3.0.0, signal-exit@^3.0.2: + version "3.0.3" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c" + integrity sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA== + +slice-ansi@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-2.1.0.tgz#cacd7693461a637a5788d92a7dd4fba068e81636" + integrity sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ== + dependencies: + ansi-styles "^3.2.0" + astral-regex "^1.0.0" + is-fullwidth-code-point "^2.0.0" + +snapdragon-node@^2.0.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b" + integrity sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw== + dependencies: + define-property "^1.0.0" + isobject "^3.0.0" + snapdragon-util "^3.0.1" + +snapdragon-util@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/snapdragon-util/-/snapdragon-util-3.0.1.tgz#f956479486f2acd79700693f6f7b805e45ab56e2" + integrity sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ== + dependencies: + kind-of "^3.2.0" + +snapdragon@^0.8.1: + version "0.8.2" + resolved "https://registry.yarnpkg.com/snapdragon/-/snapdragon-0.8.2.tgz#64922e7c565b0e14204ba1aa7d6964278d25182d" + integrity sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg== + dependencies: + base "^0.11.1" + debug "^2.2.0" + define-property "^0.2.5" + extend-shallow "^2.0.1" + map-cache "^0.2.2" + source-map "^0.5.6" + source-map-resolve "^0.5.0" + use "^3.1.0" + +source-map-resolve@^0.5.0: + version "0.5.3" + resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.5.3.tgz#190866bece7553e1f8f267a2ee82c606b5509a1a" + integrity sha512-Htz+RnsXWk5+P2slx5Jh3Q66vhQj1Cllm0zvnaY98+NFx+Dv2CF/f5O/t8x+KaNdrdIAsruNzoh/KpialbqAnw== + dependencies: + atob "^2.1.2" + decode-uri-component "^0.2.0" + resolve-url "^0.2.1" + source-map-url "^0.4.0" + urix "^0.1.0" + +source-map-support@^0.5.12, source-map-support@^0.5.17: + version "0.5.19" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61" + integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw== + dependencies: + buffer-from "^1.0.0" + source-map "^0.6.0" + +source-map-url@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.0.tgz#3e935d7ddd73631b97659956d55128e87b5084a3" + integrity sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM= + +source-map@^0.5.6: + version "0.5.7" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" + integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= + +source-map@^0.6.0, source-map@^0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" + integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== + +spdx-correct@^3.0.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.1.1.tgz#dece81ac9c1e6713e5f7d1b6f17d468fa53d89a9" + integrity sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w== + dependencies: + spdx-expression-parse "^3.0.0" + spdx-license-ids "^3.0.0" + +spdx-exceptions@^2.1.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz#3f28ce1a77a00372683eade4a433183527a2163d" + integrity sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A== + +spdx-expression-parse@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz#cf70f50482eefdc98e3ce0a6833e4a53ceeba679" + integrity sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q== + dependencies: + spdx-exceptions "^2.1.0" + spdx-license-ids "^3.0.0" + +spdx-license-ids@^3.0.0: + version "3.0.6" + resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.6.tgz#c80757383c28abf7296744998cbc106ae8b854ce" + integrity sha512-+orQK83kyMva3WyPf59k1+Y525csj5JejicWut55zeTWANuN17qSiSLUXWtzHeNWORSvT7GLDJ/E/XiIWoXBTw== + +split-string@^3.0.1, split-string@^3.0.2: + version "3.1.0" + resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2" + integrity sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw== + dependencies: + extend-shallow "^3.0.0" + +sprintf-js@~1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" + integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= + +static-extend@^0.1.1: + version "0.1.2" + resolved "https://registry.yarnpkg.com/static-extend/-/static-extend-0.1.2.tgz#60809c39cbff55337226fd5e0b520f341f1fb5c6" + integrity sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY= + dependencies: + define-property "^0.2.5" + object-copy "^0.1.0" + +string-width@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-3.1.0.tgz#22767be21b62af1081574306f69ac51b62203961" + integrity sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w== + dependencies: + emoji-regex "^7.0.1" + is-fullwidth-code-point "^2.0.0" + strip-ansi "^5.1.0" + +string-width@^4.1.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.0.tgz#952182c46cc7b2c313d1596e623992bd163b72b5" + integrity sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.0" + +strip-ansi@^5.1.0, strip-ansi@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-5.2.0.tgz#8c9a536feb6afc962bdfa5b104a5091c1ad9c0ae" + integrity sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA== + dependencies: + ansi-regex "^4.1.0" + +strip-ansi@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.0.tgz#0b1571dd7669ccd4f3e06e14ef1eed26225ae532" + integrity sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w== + dependencies: + ansi-regex "^5.0.0" + +strip-bom@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-2.0.0.tgz#6219a85616520491f35788bdbf1447a99c7e6b0e" + integrity sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4= + dependencies: + is-utf8 "^0.2.0" + +strip-bom@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" + integrity sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM= + +strip-comments@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/strip-comments/-/strip-comments-2.0.1.tgz#4ad11c3fbcac177a67a40ac224ca339ca1c1ba9b" + integrity sha512-ZprKx+bBLXv067WTCALv8SSz5l2+XhpYCsVtSqlMnkAXMWDq+/ekVbl1ghqP9rUHTzv6sm/DwCOiYutU/yp1fw== + +strip-indent@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-1.0.1.tgz#0c7962a6adefa7bbd4ac366460a638552ae1a0a2" + integrity sha1-DHlipq3vp7vUrDZkYKY4VSrhoKI= + dependencies: + get-stdin "^4.0.1" + +strip-json-comments@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" + integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo= + +strip-json-comments@^3.0.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" + integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== + +supports-color@^5.3.0: + version "5.5.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" + integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== + dependencies: + has-flag "^3.0.0" + +supports-color@^7.1.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" + integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== + dependencies: + has-flag "^4.0.0" + +table@^5.2.3: + version "5.4.6" + resolved "https://registry.yarnpkg.com/table/-/table-5.4.6.tgz#1292d19500ce3f86053b05f0e8e7e4a3bb21079e" + integrity sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug== + dependencies: + ajv "^6.10.2" + lodash "^4.17.14" + slice-ansi "^2.1.0" + string-width "^3.0.0" + +text-table@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" + integrity sha1-f17oI66AUgfACvLfSoTsP8+lcLQ= + +through@^2.3.6: + version "2.3.8" + resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" + integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU= + +tmp@^0.0.33: + version "0.0.33" + resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" + integrity sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw== + dependencies: + os-tmpdir "~1.0.2" + +to-object-path@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/to-object-path/-/to-object-path-0.3.0.tgz#297588b7b0e7e0ac08e04e672f85c1f4999e17af" + integrity sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68= + dependencies: + kind-of "^3.0.2" + +to-regex-range@^2.1.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-2.1.1.tgz#7c80c17b9dfebe599e27367e0d4dd5590141db38" + integrity sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg= + dependencies: + is-number "^3.0.0" + repeat-string "^1.6.1" + +to-regex-range@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" + integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== + dependencies: + is-number "^7.0.0" + +to-regex@^3.0.1, to-regex@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/to-regex/-/to-regex-3.0.2.tgz#13cfdd9b336552f30b51f33a8ae1b42a7a7599ce" + integrity sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw== + dependencies: + define-property "^2.0.2" + extend-shallow "^3.0.2" + regex-not "^1.0.2" + safe-regex "^1.1.0" + +tree-kill@^1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/tree-kill/-/tree-kill-1.2.2.tgz#4ca09a9092c88b73a7cdc5e8a01b507b0790a0cc" + integrity sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A== + +trim-newlines@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613" + integrity sha1-WIeWa7WCpFA6QetST301ARgVphM= + +ts-node-dev@^1.0.0-pre.44: + version "1.0.0-pre.62" + resolved "https://registry.yarnpkg.com/ts-node-dev/-/ts-node-dev-1.0.0-pre.62.tgz#835644c43669b659a880379b9d06df86cef665ad" + integrity sha512-hfsEuCqUZOVnZ86l7A3icxD1nFt1HEmLVbx4YOHCkrbSHPBNWcw+IczAPZo3zz7YiOm9vs0xG6OENNrkgm89tQ== + dependencies: + chokidar "^3.4.0" + dateformat "~1.0.4-1.2.3" + dynamic-dedupe "^0.3.0" + minimist "^1.2.5" + mkdirp "^1.0.4" + resolve "^1.0.0" + rimraf "^2.6.1" + source-map-support "^0.5.12" + tree-kill "^1.2.2" + ts-node "^8.10.2" + tsconfig "^7.0.0" + +ts-node@^8.10.2: + version "8.10.2" + resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-8.10.2.tgz#eee03764633b1234ddd37f8db9ec10b75ec7fb8d" + integrity sha512-ISJJGgkIpDdBhWVu3jufsWpK3Rzo7bdiIXJjQc0ynKxVOVcg2oIrf2H2cejminGrptVc6q6/uynAHNCuWGbpVA== + dependencies: + arg "^4.1.0" + diff "^4.0.1" + make-error "^1.1.1" + source-map-support "^0.5.17" + yn "3.1.1" + +tsconfig@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/tsconfig/-/tsconfig-7.0.0.tgz#84538875a4dc216e5c4a5432b3a4dec3d54e91b7" + integrity sha512-vZXmzPrL+EmC4T/4rVlT2jNVMWCi/O4DIiSj3UHg1OE5kCKbk4mfrXc6dZksLgRM/TZlKnousKH9bbTazUWRRw== + dependencies: + "@types/strip-bom" "^3.0.0" + "@types/strip-json-comments" "0.0.30" + strip-bom "^3.0.0" + strip-json-comments "^2.0.0" + +tslib@^1.8.1, tslib@^1.9.0: + version "1.13.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.13.0.tgz#c881e13cc7015894ed914862d276436fa9a47043" + integrity sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q== + +tsutils@^3.17.1: + version "3.17.1" + resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.17.1.tgz#ed719917f11ca0dee586272b2ac49e015a2dd759" + integrity sha512-kzeQ5B8H3w60nFY2g8cJIuH7JDpsALXySGtwGJ0p2LSjLgay3NdIpqq5SoOBe46bKDW2iq25irHCr8wjomUS2g== + dependencies: + tslib "^1.8.1" + +type-check@~0.3.2: + version "0.3.2" + resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" + integrity sha1-WITKtRLPHTVeP7eE8wgEsrUg23I= + dependencies: + prelude-ls "~1.1.2" + +type-fest@^0.11.0: + version "0.11.0" + resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.11.0.tgz#97abf0872310fed88a5c466b25681576145e33f1" + integrity sha512-OdjXJxnCN1AvyLSzeKIgXTXxV+99ZuXl3Hpo9XpJAv9MBcHrrJOQ5kV7ypXOuQie+AmWG25hLbiKdwYTifzcfQ== + +type-fest@^0.8.1: + version "0.8.1" + resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.8.1.tgz#09e249ebde851d3b1e48d27c105444667f17b83d" + integrity sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA== + +typescript@^3.8.3: + version "3.9.7" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.7.tgz#98d600a5ebdc38f40cb277522f12dc800e9e25fa" + integrity sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw== + +union-value@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/union-value/-/union-value-1.0.1.tgz#0b6fe7b835aecda61c6ea4d4f02c14221e109847" + integrity sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg== + dependencies: + arr-union "^3.1.0" + get-value "^2.0.6" + is-extendable "^0.1.1" + set-value "^2.0.1" + +unset-value@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/unset-value/-/unset-value-1.0.0.tgz#8376873f7d2335179ffb1e6fc3a8ed0dfc8ab559" + integrity sha1-g3aHP30jNRef+x5vw6jtDfyKtVk= + dependencies: + has-value "^0.3.1" + isobject "^3.0.0" + +uri-js@^4.2.2: + version "4.4.0" + resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.0.tgz#aa714261de793e8a82347a7bcc9ce74e86f28602" + integrity sha512-B0yRTzYdUCCn9n+F4+Gh4yIDtMQcaJsmYBDsTSG8g/OejKBodLQ2IHfN3bM7jUsRXndopT7OIXWdYqc1fjmV6g== + dependencies: + punycode "^2.1.0" + +urix@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/urix/-/urix-0.1.0.tgz#da937f7a62e21fec1fd18d49b35c2935067a6c72" + integrity sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI= + +use@^3.1.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/use/-/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f" + integrity sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ== + +util@^0.10.3: + version "0.10.4" + resolved "https://registry.yarnpkg.com/util/-/util-0.10.4.tgz#3aa0125bfe668a4672de58857d3ace27ecb76901" + integrity sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A== + dependencies: + inherits "2.0.3" + +v8-compile-cache@^2.0.3: + version "2.1.1" + resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.1.1.tgz#54bc3cdd43317bca91e35dcaf305b1a7237de745" + integrity sha512-8OQ9CL+VWyt3JStj7HX7/ciTL2V3Rl1Wf5OL+SNTm0yK1KvtReVulksyeRnCANHHuUxHlQig+JJDlUhBt1NQDQ== + +validate-npm-package-license@^3.0.1: + version "3.0.4" + resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz#fc91f6b9c7ba15c857f4cb2c5defeec39d4f410a" + integrity sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew== + dependencies: + spdx-correct "^3.0.0" + spdx-expression-parse "^3.0.0" + +which@^1.2.9: + version "1.3.1" + resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" + integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== + dependencies: + isexe "^2.0.0" + +word-wrap@~1.2.3: + version "1.2.3" + resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c" + integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ== + +wrappy@1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= + +write@1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/write/-/write-1.0.3.tgz#0800e14523b923a387e415123c865616aae0f5c3" + integrity sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig== + dependencies: + mkdirp "^0.5.1" + +xtend@^4.0.0: + version "4.0.2" + resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54" + integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ== + +yn@3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" + integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q== From 4ea15e1d04eeea6c46851c19adf6b48d1d263e39 Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Wed, 23 Sep 2020 18:29:18 +0200 Subject: [PATCH 050/122] Fix CI --- maps/yarn.lock | 2240 ------------------------------------------------ 1 file changed, 2240 deletions(-) delete mode 100644 maps/yarn.lock diff --git a/maps/yarn.lock b/maps/yarn.lock deleted file mode 100644 index 04c9d5ff..00000000 --- a/maps/yarn.lock +++ /dev/null @@ -1,2240 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@babel/code-frame@^7.0.0": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.10.4.tgz#168da1a36e90da68ae8d49c0f1b48c7c6249213a" - integrity sha512-vG6SvB6oYEhvgisZNFRmRCUkLz11c7rp+tbNTynGqc6mS1d5ATd/sGyV6W0KZZnXRKMTzZDRgQT3Ou9jhpAfUg== - dependencies: - "@babel/highlight" "^7.10.4" - -"@babel/helper-validator-identifier@^7.10.4": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.4.tgz#a78c7a7251e01f616512d31b10adcf52ada5e0d2" - integrity sha512-3U9y+43hz7ZM+rzG24Qe2mufW5KhvFg/NhnNph+i9mgCtdTCtMJuI1TMkrIUiK7Ix4PYlRF9I5dhqaLYA/ADXw== - -"@babel/highlight@^7.10.4": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.10.4.tgz#7d1bdfd65753538fabe6c38596cdb76d9ac60143" - integrity sha512-i6rgnR/YgPEQzZZnbTHHuZdlE8qyoBNalD6F+q4vAFlcMEcqmkoG+mPqJYJCo63qPf74+Y1UZsl3l6f7/RIkmA== - dependencies: - "@babel/helper-validator-identifier" "^7.10.4" - chalk "^2.0.0" - js-tokens "^4.0.0" - -"@mrmlnc/readdir-enhanced@^2.2.1": - version "2.2.1" - resolved "https://registry.yarnpkg.com/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz#524af240d1a360527b730475ecfa1344aa540dde" - integrity sha512-bPHp6Ji8b41szTOcaP63VlnbbO5Ny6dwAATtY6JTjh5N2OLrb5Qk/Th5cRkRQhkWCt+EJsYrNB0MiL+Gpn6e3g== - dependencies: - call-me-maybe "^1.0.1" - glob-to-regexp "^0.3.0" - -"@nodelib/fs.stat@^1.1.2": - version "1.1.3" - resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-1.1.3.tgz#2b5a3ab3f918cca48a8c754c08168e3f03eba61b" - integrity sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw== - -"@types/color-name@^1.1.1": - version "1.1.1" - resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0" - integrity sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ== - -"@types/eslint-visitor-keys@^1.0.0": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d" - integrity sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag== - -"@types/jasmine@^3.5.10": - version "3.5.14" - resolved "https://registry.yarnpkg.com/@types/jasmine/-/jasmine-3.5.14.tgz#f41a14e8ffa939062a71cf9722e5ee7d4e1f94af" - integrity sha512-Fkgk536sHPqcOtd+Ow+WiUNuk0TSo/BntKkF8wSvcd6M2FvPjeXcUE6Oz/bwDZiUZEaXLslAgw00Q94Pnx6T4w== - -"@types/json-schema@^7.0.3", "@types/json-schema@^7.0.5": - version "7.0.6" - resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.6.tgz#f4c7ec43e81b319a9815115031709f26987891f0" - integrity sha512-3c+yGKvVP5Y9TYBEibGNR+kLtijnj7mYrXRg+WpFb2X9xm04g/DXYkfg4hmzJQosc9snFNUPkbYIhu+KAm6jJw== - -"@types/strip-bom@^3.0.0": - version "3.0.0" - resolved "https://registry.yarnpkg.com/@types/strip-bom/-/strip-bom-3.0.0.tgz#14a8ec3956c2e81edb7520790aecf21c290aebd2" - integrity sha1-FKjsOVbC6B7bdSB5CuzyHCkK69I= - -"@types/strip-json-comments@0.0.30": - version "0.0.30" - resolved "https://registry.yarnpkg.com/@types/strip-json-comments/-/strip-json-comments-0.0.30.tgz#9aa30c04db212a9a0649d6ae6fd50accc40748a1" - integrity sha512-7NQmHra/JILCd1QqpSzl8+mJRc8ZHz3uDm8YV1Ks9IhK0epEiTw8aIErbvH9PI+6XbqhyIQy3462nEsn7UVzjQ== - -"@typescript-eslint/eslint-plugin@^2.26.0": - version "2.34.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.34.0.tgz#6f8ce8a46c7dea4a6f1d171d2bb8fbae6dac2be9" - integrity sha512-4zY3Z88rEE99+CNvTbXSyovv2z9PNOVffTWD2W8QF5s2prBQtwN2zadqERcrHpcR7O/+KMI3fcTAmUUhK/iQcQ== - dependencies: - "@typescript-eslint/experimental-utils" "2.34.0" - functional-red-black-tree "^1.0.1" - regexpp "^3.0.0" - tsutils "^3.17.1" - -"@typescript-eslint/experimental-utils@2.34.0": - version "2.34.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-2.34.0.tgz#d3524b644cdb40eebceca67f8cf3e4cc9c8f980f" - integrity sha512-eS6FTkq+wuMJ+sgtuNTtcqavWXqsflWcfBnlYhg/nS4aZ1leewkXGbvBhaapn1q6qf4M71bsR1tez5JTRMuqwA== - dependencies: - "@types/json-schema" "^7.0.3" - "@typescript-eslint/typescript-estree" "2.34.0" - eslint-scope "^5.0.0" - eslint-utils "^2.0.0" - -"@typescript-eslint/parser@^2.26.0": - version "2.34.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-2.34.0.tgz#50252630ca319685420e9a39ca05fe185a256bc8" - integrity sha512-03ilO0ucSD0EPTw2X4PntSIRFtDPWjrVq7C3/Z3VQHRC7+13YB55rcJI3Jt+YgeHbjUdJPcPa7b23rXCBokuyA== - dependencies: - "@types/eslint-visitor-keys" "^1.0.0" - "@typescript-eslint/experimental-utils" "2.34.0" - "@typescript-eslint/typescript-estree" "2.34.0" - eslint-visitor-keys "^1.1.0" - -"@typescript-eslint/typescript-estree@2.34.0": - version "2.34.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-2.34.0.tgz#14aeb6353b39ef0732cc7f1b8285294937cf37d5" - integrity sha512-OMAr+nJWKdlVM9LOqCqh3pQQPwxHAN7Du8DR6dmwCrAmxtiXQnhHJ6tBNtf+cggqfo51SG/FCwnKhXCIM7hnVg== - dependencies: - debug "^4.1.1" - eslint-visitor-keys "^1.1.0" - glob "^7.1.6" - is-glob "^4.0.1" - lodash "^4.17.15" - semver "^7.3.2" - tsutils "^3.17.1" - -acorn-jsx@^5.2.0: - version "5.3.1" - resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.1.tgz#fc8661e11b7ac1539c47dbfea2e72b3af34d267b" - integrity sha512-K0Ptm/47OKfQRpNQ2J/oIN/3QYiK6FwW+eJbILhsdxh2WTLdl+30o8aGdTbm5JbffpFFAg/g+zi1E+jvJha5ng== - -acorn@^7.1.1: - version "7.4.0" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.0.tgz#e1ad486e6c54501634c6c397c5c121daa383607c" - integrity sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w== - -ajv-keywords@^3.5.2: - version "3.5.2" - resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.5.2.tgz#31f29da5ab6e00d1c2d329acf7b5929614d5014d" - integrity sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ== - -ajv@^6.10.0, ajv@^6.10.2, ajv@^6.12.4: - version "6.12.5" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.5.tgz#19b0e8bae8f476e5ba666300387775fb1a00a4da" - integrity sha512-lRF8RORchjpKG50/WFf8xmg7sgCLFiYNNnqdKflk63whMQcWR5ngGjiSXkL9bjxy6B2npOK2HSMN49jEBMSkag== - dependencies: - fast-deep-equal "^3.1.1" - fast-json-stable-stringify "^2.0.0" - json-schema-traverse "^0.4.1" - uri-js "^4.2.2" - -ansi-escapes@^4.2.1: - version "4.3.1" - resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-4.3.1.tgz#a5c47cc43181f1f38ffd7076837700d395522a61" - integrity sha512-JWF7ocqNrp8u9oqpgV+wH5ftbt+cfvv+PTjOvKLT3AdYly/LmORARfEVT1iyjwN+4MqE5UmVKoAdIBqeoCHgLA== - dependencies: - type-fest "^0.11.0" - -ansi-regex@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.0.tgz#8b9f8f08cf1acb843756a839ca8c7e3168c51997" - integrity sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg== - -ansi-regex@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.0.tgz#388539f55179bf39339c81af30a654d69f87cb75" - integrity sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg== - -ansi-styles@^3.2.0, ansi-styles@^3.2.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" - integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== - dependencies: - color-convert "^1.9.0" - -ansi-styles@^4.1.0: - version "4.2.1" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.2.1.tgz#90ae75c424d008d2624c5bf29ead3177ebfcf359" - integrity sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA== - dependencies: - "@types/color-name" "^1.1.1" - color-convert "^2.0.1" - -anymatch@~3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.1.tgz#c55ecf02185e2469259399310c173ce31233b142" - integrity sha512-mM8522psRCqzV+6LhomX5wgp25YVibjh8Wj23I5RPkPppSVSjyKD2A2mBJmWGa+KN7f2D6LNh9jkBCeyLktzjg== - dependencies: - normalize-path "^3.0.0" - picomatch "^2.0.4" - -arg@^4.1.0: - version "4.1.3" - resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" - integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA== - -argparse@^1.0.7: - version "1.0.10" - resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" - integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== - dependencies: - sprintf-js "~1.0.2" - -arr-diff@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-4.0.0.tgz#d6461074febfec71e7e15235761a329a5dc7c520" - integrity sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA= - -arr-flatten@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.1.0.tgz#36048bbff4e7b47e136644316c99669ea5ae91f1" - integrity sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg== - -arr-union@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/arr-union/-/arr-union-3.1.0.tgz#e39b09aea9def866a8f206e288af63919bae39c4" - integrity sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ= - -array-find-index@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/array-find-index/-/array-find-index-1.0.2.tgz#df010aa1287e164bbda6f9723b0a96a1ec4187a1" - integrity sha1-3wEKoSh+Fku9pvlyOwqWoexBh6E= - -array-unique@^0.3.2: - version "0.3.2" - resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428" - integrity sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg= - -assign-symbols@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/assign-symbols/-/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367" - integrity sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c= - -astral-regex@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-1.0.0.tgz#6c8c3fb827dd43ee3918f27b82782ab7658a6fd9" - integrity sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg== - -atob@^2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9" - integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg== - -balanced-match@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" - integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c= - -base@^0.11.1: - version "0.11.2" - resolved "https://registry.yarnpkg.com/base/-/base-0.11.2.tgz#7bde5ced145b6d551a90db87f83c558b4eb48a8f" - integrity sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg== - dependencies: - cache-base "^1.0.1" - class-utils "^0.3.5" - component-emitter "^1.2.1" - define-property "^1.0.0" - isobject "^3.0.1" - mixin-deep "^1.2.0" - pascalcase "^0.1.1" - -big.js@^5.2.2: - version "5.2.2" - resolved "https://registry.yarnpkg.com/big.js/-/big.js-5.2.2.tgz#65f0af382f578bcdc742bd9c281e9cb2d7768328" - integrity sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ== - -binary-extensions@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.1.0.tgz#30fa40c9e7fe07dbc895678cd287024dea241dd9" - integrity sha512-1Yj8h9Q+QDF5FzhMs/c9+6UntbD5MkRfRwac8DoEm9ZfUBZ7tZ55YcGVAzEe4bXsdQHEk+s9S5wsOKVdZrw0tQ== - -brace-expansion@^1.1.7: - version "1.1.11" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" - integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== - dependencies: - balanced-match "^1.0.0" - concat-map "0.0.1" - -braces@^2.3.1: - version "2.3.2" - resolved "https://registry.yarnpkg.com/braces/-/braces-2.3.2.tgz#5979fd3f14cd531565e5fa2df1abfff1dfaee729" - integrity sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w== - dependencies: - arr-flatten "^1.1.0" - array-unique "^0.3.2" - extend-shallow "^2.0.1" - fill-range "^4.0.0" - isobject "^3.0.1" - repeat-element "^1.1.2" - snapdragon "^0.8.1" - snapdragon-node "^2.0.1" - split-string "^3.0.2" - to-regex "^3.0.1" - -braces@~3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" - integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== - dependencies: - fill-range "^7.0.1" - -buffer-from@^1.0.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" - integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A== - -cache-base@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/cache-base/-/cache-base-1.0.1.tgz#0a7f46416831c8b662ee36fe4e7c59d76f666ab2" - integrity sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ== - dependencies: - collection-visit "^1.0.0" - component-emitter "^1.2.1" - get-value "^2.0.6" - has-value "^1.0.0" - isobject "^3.0.1" - set-value "^2.0.0" - to-object-path "^0.3.0" - union-value "^1.0.0" - unset-value "^1.0.0" - -call-me-maybe@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/call-me-maybe/-/call-me-maybe-1.0.1.tgz#26d208ea89e37b5cbde60250a15f031c16a4d66b" - integrity sha1-JtII6onje1y95gJQoV8DHBak1ms= - -callsites@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" - integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ== - -camelcase-keys@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-2.1.0.tgz#308beeaffdf28119051efa1d932213c91b8f92e7" - integrity sha1-MIvur/3ygRkFHvodkyITyRuPkuc= - dependencies: - camelcase "^2.0.0" - map-obj "^1.0.0" - -camelcase@^2.0.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-2.1.1.tgz#7c1d16d679a1bbe59ca02cacecfb011e201f5a1f" - integrity sha1-fB0W1nmhu+WcoCys7PsBHiAfWh8= - -chalk@^2.0.0, chalk@^2.1.0: - version "2.4.2" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" - integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== - dependencies: - ansi-styles "^3.2.1" - escape-string-regexp "^1.0.5" - supports-color "^5.3.0" - -chalk@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.0.tgz#4e14870a618d9e2edd97dd8345fd9d9dc315646a" - integrity sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A== - dependencies: - ansi-styles "^4.1.0" - supports-color "^7.1.0" - -chardet@^0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e" - integrity sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA== - -chokidar@^3.4.0: - version "3.4.2" - resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.4.2.tgz#38dc8e658dec3809741eb3ef7bb0a47fe424232d" - integrity sha512-IZHaDeBeI+sZJRX7lGcXsdzgvZqKv6sECqsbErJA4mHWfpRrD8B97kSFN4cQz6nGBGiuFia1MKR4d6c1o8Cv7A== - dependencies: - anymatch "~3.1.1" - braces "~3.0.2" - glob-parent "~5.1.0" - is-binary-path "~2.1.0" - is-glob "~4.0.1" - normalize-path "~3.0.0" - readdirp "~3.4.0" - optionalDependencies: - fsevents "~2.1.2" - -class-utils@^0.3.5: - version "0.3.6" - resolved "https://registry.yarnpkg.com/class-utils/-/class-utils-0.3.6.tgz#f93369ae8b9a7ce02fd41faad0ca83033190c463" - integrity sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg== - dependencies: - arr-union "^3.1.0" - define-property "^0.2.5" - isobject "^3.0.0" - static-extend "^0.1.1" - -cli-cursor@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-3.1.0.tgz#264305a7ae490d1d03bf0c9ba7c925d1753af307" - integrity sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw== - dependencies: - restore-cursor "^3.1.0" - -cli-width@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-3.0.0.tgz#a2f48437a2caa9a22436e794bf071ec9e61cedf6" - integrity sha512-FxqpkPPwu1HjuN93Omfm4h8uIanXofW0RxVEW3k5RKx+mJJYSthzNhp32Kzxxy3YAEZ/Dc/EWN1vZRY0+kOhbw== - -collection-visit@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/collection-visit/-/collection-visit-1.0.0.tgz#4bc0373c164bc3291b4d368c829cf1a80a59dca0" - integrity sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA= - dependencies: - map-visit "^1.0.0" - object-visit "^1.0.0" - -color-convert@^1.9.0: - version "1.9.3" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" - integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== - dependencies: - color-name "1.1.3" - -color-convert@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" - integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== - dependencies: - color-name "~1.1.4" - -color-name@1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" - integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= - -color-name@~1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" - integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== - -component-emitter@^1.2.1: - version "1.3.0" - resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.3.0.tgz#16e4070fba8ae29b679f2215853ee181ab2eabc0" - integrity sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg== - -concat-map@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= - -copy-descriptor@^0.1.0: - version "0.1.1" - resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d" - integrity sha1-Z29us8OZl8LuGsOpJP1hJHSPV40= - -cross-spawn@^6.0.5: - version "6.0.5" - resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" - integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ== - dependencies: - nice-try "^1.0.4" - path-key "^2.0.1" - semver "^5.5.0" - shebang-command "^1.2.0" - which "^1.2.9" - -currently-unhandled@^0.4.1: - version "0.4.1" - resolved "https://registry.yarnpkg.com/currently-unhandled/-/currently-unhandled-0.4.1.tgz#988df33feab191ef799a61369dd76c17adf957ea" - integrity sha1-mI3zP+qxke95mmE2nddsF635V+o= - dependencies: - array-find-index "^1.0.1" - -dateformat@~1.0.4-1.2.3: - version "1.0.12" - resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-1.0.12.tgz#9f124b67594c937ff706932e4a642cca8dbbfee9" - integrity sha1-nxJLZ1lMk3/3BpMuSmQsyo27/uk= - dependencies: - get-stdin "^4.0.1" - meow "^3.3.0" - -debug@^2.2.0, debug@^2.3.3: - version "2.6.9" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" - integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== - dependencies: - ms "2.0.0" - -debug@^4.0.1, debug@^4.1.1: - version "4.2.0" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.2.0.tgz#7f150f93920e94c58f5574c2fd01a3110effe7f1" - integrity sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg== - dependencies: - ms "2.1.2" - -decamelize@^1.1.2: - version "1.2.0" - resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" - integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA= - -decode-uri-component@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" - integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU= - -deep-is@~0.1.3: - version "0.1.3" - resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" - integrity sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ= - -define-property@^0.2.5: - version "0.2.5" - resolved "https://registry.yarnpkg.com/define-property/-/define-property-0.2.5.tgz#c35b1ef918ec3c990f9a5bc57be04aacec5c8116" - integrity sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY= - dependencies: - is-descriptor "^0.1.0" - -define-property@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/define-property/-/define-property-1.0.0.tgz#769ebaaf3f4a63aad3af9e8d304c9bbe79bfb0e6" - integrity sha1-dp66rz9KY6rTr56NMEybvnm/sOY= - dependencies: - is-descriptor "^1.0.0" - -define-property@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/define-property/-/define-property-2.0.2.tgz#d459689e8d654ba77e02a817f8710d702cb16e9d" - integrity sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ== - dependencies: - is-descriptor "^1.0.2" - isobject "^3.0.1" - -diff@^4.0.1: - version "4.0.2" - resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" - integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== - -doctrine@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-3.0.0.tgz#addebead72a6574db783639dc87a121773973961" - integrity sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w== - dependencies: - esutils "^2.0.2" - -dynamic-dedupe@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/dynamic-dedupe/-/dynamic-dedupe-0.3.0.tgz#06e44c223f5e4e94d78ef9db23a6515ce2f962a1" - integrity sha1-BuRMIj9eTpTXjvnbI6ZRXOL5YqE= - dependencies: - xtend "^4.0.0" - -emoji-regex@^7.0.1: - version "7.0.3" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-7.0.3.tgz#933a04052860c85e83c122479c4748a8e4c72156" - integrity sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA== - -emoji-regex@^8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" - integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== - -emojis-list@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-3.0.0.tgz#5570662046ad29e2e916e71aae260abdff4f6a78" - integrity sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q== - -error-ex@^1.2.0: - version "1.3.2" - resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" - integrity sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g== - dependencies: - is-arrayish "^0.2.1" - -escape-string-regexp@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" - integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= - -eslint-scope@^5.0.0: - version "5.1.1" - resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" - integrity sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw== - dependencies: - esrecurse "^4.3.0" - estraverse "^4.1.1" - -eslint-utils@^1.4.3: - version "1.4.3" - resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-1.4.3.tgz#74fec7c54d0776b6f67e0251040b5806564e981f" - integrity sha512-fbBN5W2xdY45KulGXmLHZ3c3FHfVYmKg0IrAKGOkT/464PQsx2UeIzfz1RmEci+KLm1bBaAzZAh8+/E+XAeZ8Q== - dependencies: - eslint-visitor-keys "^1.1.0" - -eslint-utils@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-2.1.0.tgz#d2de5e03424e707dc10c74068ddedae708741b27" - integrity sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg== - dependencies: - eslint-visitor-keys "^1.1.0" - -eslint-visitor-keys@^1.1.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz#30ebd1ef7c2fdff01c3a4f151044af25fab0523e" - integrity sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ== - -eslint@^6.8.0: - version "6.8.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-6.8.0.tgz#62262d6729739f9275723824302fb227c8c93ffb" - integrity sha512-K+Iayyo2LtyYhDSYwz5D5QdWw0hCacNzyq1Y821Xna2xSJj7cijoLLYmLxTQgcgZ9mC61nryMy9S7GRbYpI5Ig== - dependencies: - "@babel/code-frame" "^7.0.0" - ajv "^6.10.0" - chalk "^2.1.0" - cross-spawn "^6.0.5" - debug "^4.0.1" - doctrine "^3.0.0" - eslint-scope "^5.0.0" - eslint-utils "^1.4.3" - eslint-visitor-keys "^1.1.0" - espree "^6.1.2" - esquery "^1.0.1" - esutils "^2.0.2" - file-entry-cache "^5.0.1" - functional-red-black-tree "^1.0.1" - glob-parent "^5.0.0" - globals "^12.1.0" - ignore "^4.0.6" - import-fresh "^3.0.0" - imurmurhash "^0.1.4" - inquirer "^7.0.0" - is-glob "^4.0.0" - js-yaml "^3.13.1" - json-stable-stringify-without-jsonify "^1.0.1" - levn "^0.3.0" - lodash "^4.17.14" - minimatch "^3.0.4" - mkdirp "^0.5.1" - natural-compare "^1.4.0" - optionator "^0.8.3" - progress "^2.0.0" - regexpp "^2.0.1" - semver "^6.1.2" - strip-ansi "^5.2.0" - strip-json-comments "^3.0.1" - table "^5.2.3" - text-table "^0.2.0" - v8-compile-cache "^2.0.3" - -espree@^6.1.2: - version "6.2.1" - resolved "https://registry.yarnpkg.com/espree/-/espree-6.2.1.tgz#77fc72e1fd744a2052c20f38a5b575832e82734a" - integrity sha512-ysCxRQY3WaXJz9tdbWOwuWr5Y/XrPTGX9Kiz3yoUXwW0VZ4w30HTkQLaGx/+ttFjF8i+ACbArnB4ce68a9m5hw== - dependencies: - acorn "^7.1.1" - acorn-jsx "^5.2.0" - eslint-visitor-keys "^1.1.0" - -esprima@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" - integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== - -esquery@^1.0.1: - version "1.3.1" - resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.3.1.tgz#b78b5828aa8e214e29fb74c4d5b752e1c033da57" - integrity sha512-olpvt9QG0vniUBZspVRN6lwB7hOZoTRtT+jzR+tS4ffYx2mzbw+z0XCOk44aaLYKApNX5nMm+E+P6o25ip/DHQ== - dependencies: - estraverse "^5.1.0" - -esrecurse@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.3.0.tgz#7ad7964d679abb28bee72cec63758b1c5d2c9921" - integrity sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag== - dependencies: - estraverse "^5.2.0" - -estraverse@^4.1.1: - version "4.3.0" - resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.3.0.tgz#398ad3f3c5a24948be7725e83d11a7de28cdbd1d" - integrity sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw== - -estraverse@^5.1.0, estraverse@^5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.2.0.tgz#307df42547e6cc7324d3cf03c155d5cdb8c53880" - integrity sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ== - -esutils@^2.0.2: - version "2.0.3" - resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" - integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== - -eventemitter3@^4.0.4: - version "4.0.7" - resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.7.tgz#2de9b68f6528d5644ef5c59526a1b4a07306169f" - integrity sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw== - -expand-brackets@^2.1.4: - version "2.1.4" - resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-2.1.4.tgz#b77735e315ce30f6b6eff0f83b04151a22449622" - integrity sha1-t3c14xXOMPa27/D4OwQVGiJEliI= - dependencies: - debug "^2.3.3" - define-property "^0.2.5" - extend-shallow "^2.0.1" - posix-character-classes "^0.1.0" - regex-not "^1.0.0" - snapdragon "^0.8.1" - to-regex "^3.0.1" - -exports-loader@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/exports-loader/-/exports-loader-1.1.0.tgz#26a16706e4cf533145de24c1419baf33b624fb5c" - integrity sha512-zGB2SujiAyO0Rwn4GQ17/HlT8cwmT8abcBeZpr2R3sItJ5sI5Y9BzNzus3H9tH1iWLAoJLi9N3TP54D2+j859Q== - dependencies: - loader-utils "^2.0.0" - schema-utils "^2.7.0" - source-map "^0.6.1" - -extend-shallow@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-2.0.1.tgz#51af7d614ad9a9f610ea1bafbb989d6b1c56890f" - integrity sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8= - dependencies: - is-extendable "^0.1.0" - -extend-shallow@^3.0.0, extend-shallow@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-3.0.2.tgz#26a71aaf073b39fb2127172746131c2704028db8" - integrity sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg= - dependencies: - assign-symbols "^1.0.0" - is-extendable "^1.0.1" - -external-editor@^3.0.3: - version "3.1.0" - resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-3.1.0.tgz#cb03f740befae03ea4d283caed2741a83f335495" - integrity sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew== - dependencies: - chardet "^0.7.0" - iconv-lite "^0.4.24" - tmp "^0.0.33" - -extglob@^2.0.4: - version "2.0.4" - resolved "https://registry.yarnpkg.com/extglob/-/extglob-2.0.4.tgz#ad00fe4dc612a9232e8718711dc5cb5ab0285543" - integrity sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw== - dependencies: - array-unique "^0.3.2" - define-property "^1.0.0" - expand-brackets "^2.1.4" - extend-shallow "^2.0.1" - fragment-cache "^0.2.1" - regex-not "^1.0.0" - snapdragon "^0.8.1" - to-regex "^3.0.1" - -fast-deep-equal@^3.1.1: - version "3.1.3" - resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" - integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== - -fast-glob@^2.2.6: - version "2.2.7" - resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-2.2.7.tgz#6953857c3afa475fff92ee6015d52da70a4cd39d" - integrity sha512-g1KuQwHOZAmOZMuBtHdxDtju+T2RT8jgCC9aANsbpdiDDTSnjgfuVsIBNKbUeJI3oKMRExcfNDtJl4OhbffMsw== - dependencies: - "@mrmlnc/readdir-enhanced" "^2.2.1" - "@nodelib/fs.stat" "^1.1.2" - glob-parent "^3.1.0" - is-glob "^4.0.0" - merge2 "^1.2.3" - micromatch "^3.1.10" - -fast-json-stable-stringify@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" - integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== - -fast-levenshtein@~2.0.6: - version "2.0.6" - resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" - integrity sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc= - -figures@^3.0.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/figures/-/figures-3.2.0.tgz#625c18bd293c604dc4a8ddb2febf0c88341746af" - integrity sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg== - dependencies: - escape-string-regexp "^1.0.5" - -file-entry-cache@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-5.0.1.tgz#ca0f6efa6dd3d561333fb14515065c2fafdf439c" - integrity sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g== - dependencies: - flat-cache "^2.0.1" - -fill-range@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-4.0.0.tgz#d544811d428f98eb06a63dc402d2403c328c38f7" - integrity sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc= - dependencies: - extend-shallow "^2.0.1" - is-number "^3.0.0" - repeat-string "^1.6.1" - to-regex-range "^2.1.0" - -fill-range@^7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" - integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== - dependencies: - to-regex-range "^5.0.1" - -find-up@^1.0.0: - version "1.1.2" - resolved "https://registry.yarnpkg.com/find-up/-/find-up-1.1.2.tgz#6b2e9822b1a2ce0a60ab64d610eccad53cb24d0f" - integrity sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8= - dependencies: - path-exists "^2.0.0" - pinkie-promise "^2.0.0" - -flat-cache@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-2.0.1.tgz#5d296d6f04bda44a4630a301413bdbc2ec085ec0" - integrity sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA== - dependencies: - flatted "^2.0.0" - rimraf "2.6.3" - write "1.0.3" - -flatted@^2.0.0: - version "2.0.2" - resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138" - integrity sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA== - -for-in@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" - integrity sha1-gQaNKVqBQuwKxybG4iAMMPttXoA= - -fragment-cache@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/fragment-cache/-/fragment-cache-0.2.1.tgz#4290fad27f13e89be7f33799c6bc5a0abfff0d19" - integrity sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk= - dependencies: - map-cache "^0.2.2" - -fs.realpath@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" - integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= - -fsevents@~2.1.2: - version "2.1.3" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.1.3.tgz#fb738703ae8d2f9fe900c33836ddebee8b97f23e" - integrity sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ== - -functional-red-black-tree@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327" - integrity sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc= - -get-stdin@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe" - integrity sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4= - -get-value@^2.0.3, get-value@^2.0.6: - version "2.0.6" - resolved "https://registry.yarnpkg.com/get-value/-/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28" - integrity sha1-3BXKHGcjh8p2vTesCjlbogQqLCg= - -glob-parent@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-3.1.0.tgz#9e6af6299d8d3bd2bd40430832bd113df906c5ae" - integrity sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4= - dependencies: - is-glob "^3.1.0" - path-dirname "^1.0.0" - -glob-parent@^5.0.0, glob-parent@~5.1.0: - version "5.1.1" - resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.1.tgz#b6c1ef417c4e5663ea498f1c45afac6916bbc229" - integrity sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ== - dependencies: - is-glob "^4.0.1" - -glob-to-regexp@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.3.0.tgz#8c5a1494d2066c570cc3bfe4496175acc4d502ab" - integrity sha1-jFoUlNIGbFcMw7/kSWF1rMTVAqs= - -glob@^7.1.3, glob@^7.1.6: - version "7.1.6" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6" - integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA== - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.0.4" - once "^1.3.0" - path-is-absolute "^1.0.0" - -globals@^12.1.0: - version "12.4.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-12.4.0.tgz#a18813576a41b00a24a97e7f815918c2e19925f8" - integrity sha512-BWICuzzDvDoH54NHKCseDanAhE3CeDorgDL5MT6LMXXj2WCnd9UC2szdk4AWLfjdgNBCXLUanXYcpBBKOSWGwg== - dependencies: - type-fest "^0.8.1" - -graceful-fs@^4.1.2: - version "4.2.4" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.4.tgz#2256bde14d3632958c465ebc96dc467ca07a29fb" - integrity sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw== - -has-flag@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" - integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= - -has-flag@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" - integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== - -has-value@^0.3.1: - version "0.3.1" - resolved "https://registry.yarnpkg.com/has-value/-/has-value-0.3.1.tgz#7b1f58bada62ca827ec0a2078025654845995e1f" - integrity sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8= - dependencies: - get-value "^2.0.3" - has-values "^0.1.4" - isobject "^2.0.0" - -has-value@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/has-value/-/has-value-1.0.0.tgz#18b281da585b1c5c51def24c930ed29a0be6b177" - integrity sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc= - dependencies: - get-value "^2.0.6" - has-values "^1.0.0" - isobject "^3.0.0" - -has-values@^0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/has-values/-/has-values-0.1.4.tgz#6d61de95d91dfca9b9a02089ad384bff8f62b771" - integrity sha1-bWHeldkd/Km5oCCJrThL/49it3E= - -has-values@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/has-values/-/has-values-1.0.0.tgz#95b0b63fec2146619a6fe57fe75628d5a39efe4f" - integrity sha1-lbC2P+whRmGab+V/51Yo1aOe/k8= - dependencies: - is-number "^3.0.0" - kind-of "^4.0.0" - -hosted-git-info@^2.1.4: - version "2.8.8" - resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.8.tgz#7539bd4bc1e0e0a895815a2e0262420b12858488" - integrity sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg== - -iconv-lite@^0.4.24: - version "0.4.24" - resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" - integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== - dependencies: - safer-buffer ">= 2.1.2 < 3" - -ignore@^4.0.6: - version "4.0.6" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" - integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg== - -import-fresh@^3.0.0: - version "3.2.1" - resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.2.1.tgz#633ff618506e793af5ac91bf48b72677e15cbe66" - integrity sha512-6e1q1cnWP2RXD9/keSkxHScg508CdXqXWgWBaETNhyuBFz+kUZlKboh+ISK+bU++DmbHimVBrOz/zzPe0sZ3sQ== - dependencies: - parent-module "^1.0.0" - resolve-from "^4.0.0" - -imports-loader@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/imports-loader/-/imports-loader-1.1.0.tgz#1c3a388d0c5cd7f9eb08f3646d4aae3b70e57933" - integrity sha512-HcPM6rULdQ6EBLVq+5O+CF9xb7qiUjsRm6V28bTG/c3IU5sQkVZzUDwYY0r4jHvSAmVFdO9WA/vLAURR5WQSeQ== - dependencies: - loader-utils "^2.0.0" - schema-utils "^2.7.0" - source-map "^0.6.1" - strip-comments "^2.0.1" - -imurmurhash@^0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" - integrity sha1-khi5srkoojixPcT7a21XbyMUU+o= - -indent-string@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-2.1.0.tgz#8e2d48348742121b4a8218b7a137e9a52049dc80" - integrity sha1-ji1INIdCEhtKghi3oTfppSBJ3IA= - dependencies: - repeating "^2.0.0" - -inflight@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" - integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= - dependencies: - once "^1.3.0" - wrappy "1" - -inherits@2: - version "2.0.4" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" - integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== - -inherits@2.0.3: - version "2.0.3" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" - integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4= - -inquirer@^7.0.0: - version "7.3.3" - resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-7.3.3.tgz#04d176b2af04afc157a83fd7c100e98ee0aad003" - integrity sha512-JG3eIAj5V9CwcGvuOmoo6LB9kbAYT8HXffUl6memuszlwDC/qvFAJw49XJ5NROSFNPxp3iQg1GqkFhaY/CR0IA== - dependencies: - ansi-escapes "^4.2.1" - chalk "^4.1.0" - cli-cursor "^3.1.0" - cli-width "^3.0.0" - external-editor "^3.0.3" - figures "^3.0.0" - lodash "^4.17.19" - mute-stream "0.0.8" - run-async "^2.4.0" - rxjs "^6.6.0" - string-width "^4.1.0" - strip-ansi "^6.0.0" - through "^2.3.6" - -is-accessor-descriptor@^0.1.6: - version "0.1.6" - resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz#a9e12cb3ae8d876727eeef3843f8a0897b5c98d6" - integrity sha1-qeEss66Nh2cn7u84Q/igiXtcmNY= - dependencies: - kind-of "^3.0.2" - -is-accessor-descriptor@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz#169c2f6d3df1f992618072365c9b0ea1f6878656" - integrity sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ== - dependencies: - kind-of "^6.0.0" - -is-arrayish@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" - integrity sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0= - -is-binary-path@~2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" - integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== - dependencies: - binary-extensions "^2.0.0" - -is-buffer@^1.1.5: - version "1.1.6" - resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" - integrity sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w== - -is-data-descriptor@^0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz#0b5ee648388e2c860282e793f1856fec3f301b56" - integrity sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y= - dependencies: - kind-of "^3.0.2" - -is-data-descriptor@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz#d84876321d0e7add03990406abbbbd36ba9268c7" - integrity sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ== - dependencies: - kind-of "^6.0.0" - -is-descriptor@^0.1.0: - version "0.1.6" - resolved "https://registry.yarnpkg.com/is-descriptor/-/is-descriptor-0.1.6.tgz#366d8240dde487ca51823b1ab9f07a10a78251ca" - integrity sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg== - dependencies: - is-accessor-descriptor "^0.1.6" - is-data-descriptor "^0.1.4" - kind-of "^5.0.0" - -is-descriptor@^1.0.0, is-descriptor@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/is-descriptor/-/is-descriptor-1.0.2.tgz#3b159746a66604b04f8c81524ba365c5f14d86ec" - integrity sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg== - dependencies: - is-accessor-descriptor "^1.0.0" - is-data-descriptor "^1.0.0" - kind-of "^6.0.2" - -is-extendable@^0.1.0, is-extendable@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" - integrity sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik= - -is-extendable@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-1.0.1.tgz#a7470f9e426733d81bd81e1155264e3a3507cab4" - integrity sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA== - dependencies: - is-plain-object "^2.0.4" - -is-extglob@^2.1.0, is-extglob@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" - integrity sha1-qIwCU1eR8C7TfHahueqXc8gz+MI= - -is-finite@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-finite/-/is-finite-1.1.0.tgz#904135c77fb42c0641d6aa1bcdbc4daa8da082f3" - integrity sha512-cdyMtqX/BOqqNBBiKlIVkytNHm49MtMlYyn1zxzvJKWmFMlGzm+ry5BBfYyeY9YmNKbRSo/o7OX9w9ale0wg3w== - -is-fullwidth-code-point@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" - integrity sha1-o7MKXE8ZkYMWeqq5O+764937ZU8= - -is-fullwidth-code-point@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" - integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== - -is-glob@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-3.1.0.tgz#7ba5ae24217804ac70707b96922567486cc3e84a" - integrity sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo= - dependencies: - is-extglob "^2.1.0" - -is-glob@^4.0.0, is-glob@^4.0.1, is-glob@~4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.1.tgz#7567dbe9f2f5e2467bc77ab83c4a29482407a5dc" - integrity sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg== - dependencies: - is-extglob "^2.1.1" - -is-number@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195" - integrity sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU= - dependencies: - kind-of "^3.0.2" - -is-number@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" - integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== - -is-plain-object@^2.0.3, is-plain-object@^2.0.4: - version "2.0.4" - resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677" - integrity sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og== - dependencies: - isobject "^3.0.1" - -is-utf8@^0.2.0: - version "0.2.1" - resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" - integrity sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI= - -is-windows@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d" - integrity sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA== - -isarray@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" - integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE= - -isexe@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" - integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= - -isobject@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/isobject/-/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89" - integrity sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk= - dependencies: - isarray "1.0.0" - -isobject@^3.0.0, isobject@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" - integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8= - -jasmine-core@~3.6.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-3.6.0.tgz#491f3bb23941799c353ceb7a45b38a950ebc5a20" - integrity sha512-8uQYa7zJN8hq9z+g8z1bqCfdC8eoDAeVnM5sfqs7KHv9/ifoJ500m018fpFc7RDaO6SWCLCXwo/wPSNcdYTgcw== - -jasmine@^3.5.0: - version "3.6.1" - resolved "https://registry.yarnpkg.com/jasmine/-/jasmine-3.6.1.tgz#a20456b309a669b547a3c24bb2120f16f70cfc65" - integrity sha512-Jqp8P6ZWkTVFGmJwBK46p+kJNrZCdqkQ4GL+PGuBXZwK1fM4ST9BizkYgIwCFqYYqnTizAy6+XG2Ej5dFrej9Q== - dependencies: - fast-glob "^2.2.6" - jasmine-core "~3.6.0" - -js-tokens@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" - integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== - -js-yaml@^3.13.1: - version "3.14.0" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.0.tgz#a7a34170f26a21bb162424d8adacb4113a69e482" - integrity sha512-/4IbIeHcD9VMHFqDR/gQ7EdZdLimOvW2DdcxFjdyyZ9NsbS+ccrXqVWDtab/lRl5AlUqmpBx8EhPaWR+OtY17A== - dependencies: - argparse "^1.0.7" - esprima "^4.0.0" - -json-schema-traverse@^0.4.1: - version "0.4.1" - resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" - integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== - -json-stable-stringify-without-jsonify@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" - integrity sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE= - -json5@^2.1.2: - version "2.1.3" - resolved "https://registry.yarnpkg.com/json5/-/json5-2.1.3.tgz#c9b0f7fa9233bfe5807fe66fcf3a5617ed597d43" - integrity sha512-KXPvOm8K9IJKFM0bmdn8QXh7udDh1g/giieX0NLCaMnb4hEiVFqnop2ImTXCc5e0/oHz3LTqmHGtExn5hfMkOA== - dependencies: - minimist "^1.2.5" - -kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.2.0: - version "3.2.2" - resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" - integrity sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ= - dependencies: - is-buffer "^1.1.5" - -kind-of@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-4.0.0.tgz#20813df3d712928b207378691a45066fae72dd57" - integrity sha1-IIE989cSkosgc3hpGkUGb65y3Vc= - dependencies: - is-buffer "^1.1.5" - -kind-of@^5.0.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-5.1.0.tgz#729c91e2d857b7a419a1f9aa65685c4c33f5845d" - integrity sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw== - -kind-of@^6.0.0, kind-of@^6.0.2: - version "6.0.3" - resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" - integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== - -levn@^0.3.0, levn@~0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee" - integrity sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4= - dependencies: - prelude-ls "~1.1.2" - type-check "~0.3.2" - -load-json-file@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-1.1.0.tgz#956905708d58b4bab4c2261b04f59f31c99374c0" - integrity sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA= - dependencies: - graceful-fs "^4.1.2" - parse-json "^2.2.0" - pify "^2.0.0" - pinkie-promise "^2.0.0" - strip-bom "^2.0.0" - -loader-utils@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-2.0.0.tgz#e4cace5b816d425a166b5f097e10cd12b36064b0" - integrity sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ== - dependencies: - big.js "^5.2.2" - emojis-list "^3.0.0" - json5 "^2.1.2" - -lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19: - version "4.17.20" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52" - integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA== - -loud-rejection@^1.0.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/loud-rejection/-/loud-rejection-1.6.0.tgz#5b46f80147edee578870f086d04821cf998e551f" - integrity sha1-W0b4AUft7leIcPCG0Eghz5mOVR8= - dependencies: - currently-unhandled "^0.4.1" - signal-exit "^3.0.0" - -make-error@^1.1.1: - version "1.3.6" - resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" - integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== - -map-cache@^0.2.2: - version "0.2.2" - resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf" - integrity sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8= - -map-obj@^1.0.0, map-obj@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-1.0.1.tgz#d933ceb9205d82bdcf4886f6742bdc2b4dea146d" - integrity sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0= - -map-visit@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/map-visit/-/map-visit-1.0.0.tgz#ecdca8f13144e660f1b5bd41f12f3479d98dfb8f" - integrity sha1-7Nyo8TFE5mDxtb1B8S80edmN+48= - dependencies: - object-visit "^1.0.0" - -meow@^3.3.0: - version "3.7.0" - resolved "https://registry.yarnpkg.com/meow/-/meow-3.7.0.tgz#72cb668b425228290abbfa856892587308a801fb" - integrity sha1-cstmi0JSKCkKu/qFaJJYcwioAfs= - dependencies: - camelcase-keys "^2.0.0" - decamelize "^1.1.2" - loud-rejection "^1.0.0" - map-obj "^1.0.1" - minimist "^1.1.3" - normalize-package-data "^2.3.4" - object-assign "^4.0.1" - read-pkg-up "^1.0.1" - redent "^1.0.0" - trim-newlines "^1.0.0" - -merge2@^1.2.3: - version "1.4.1" - resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae" - integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== - -micromatch@^3.1.10: - version "3.1.10" - resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23" - integrity sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg== - dependencies: - arr-diff "^4.0.0" - array-unique "^0.3.2" - braces "^2.3.1" - define-property "^2.0.2" - extend-shallow "^3.0.2" - extglob "^2.0.4" - fragment-cache "^0.2.1" - kind-of "^6.0.2" - nanomatch "^1.2.9" - object.pick "^1.3.0" - regex-not "^1.0.0" - snapdragon "^0.8.1" - to-regex "^3.0.2" - -mimic-fn@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" - integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== - -minimatch@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" - integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA== - dependencies: - brace-expansion "^1.1.7" - -minimist@^1.1.3, minimist@^1.2.5: - version "1.2.5" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" - integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== - -mixin-deep@^1.2.0: - version "1.3.2" - resolved "https://registry.yarnpkg.com/mixin-deep/-/mixin-deep-1.3.2.tgz#1120b43dc359a785dce65b55b82e257ccf479566" - integrity sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA== - dependencies: - for-in "^1.0.2" - is-extendable "^1.0.1" - -mkdirp@^0.5.1: - version "0.5.5" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def" - integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ== - dependencies: - minimist "^1.2.5" - -mkdirp@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" - integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== - -ms@2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" - integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g= - -ms@2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" - integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== - -mute-stream@0.0.8: - version "0.0.8" - resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d" - integrity sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA== - -nanomatch@^1.2.9: - version "1.2.13" - resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119" - integrity sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA== - dependencies: - arr-diff "^4.0.0" - array-unique "^0.3.2" - define-property "^2.0.2" - extend-shallow "^3.0.2" - fragment-cache "^0.2.1" - is-windows "^1.0.2" - kind-of "^6.0.2" - object.pick "^1.3.0" - regex-not "^1.0.0" - snapdragon "^0.8.1" - to-regex "^3.0.1" - -natural-compare@^1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" - integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc= - -nice-try@^1.0.4: - version "1.0.5" - resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" - integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ== - -normalize-package-data@^2.3.2, normalize-package-data@^2.3.4: - version "2.5.0" - resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.5.0.tgz#e66db1838b200c1dfc233225d12cb36520e234a8" - integrity sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA== - dependencies: - hosted-git-info "^2.1.4" - resolve "^1.10.0" - semver "2 || 3 || 4 || 5" - validate-npm-package-license "^3.0.1" - -normalize-path@^3.0.0, normalize-path@~3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" - integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== - -object-assign@^4.0.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" - integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM= - -object-copy@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/object-copy/-/object-copy-0.1.0.tgz#7e7d858b781bd7c991a41ba975ed3812754e998c" - integrity sha1-fn2Fi3gb18mRpBupde04EnVOmYw= - dependencies: - copy-descriptor "^0.1.0" - define-property "^0.2.5" - kind-of "^3.0.3" - -object-visit@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/object-visit/-/object-visit-1.0.1.tgz#f79c4493af0c5377b59fe39d395e41042dd045bb" - integrity sha1-95xEk68MU3e1n+OdOV5BBC3QRbs= - dependencies: - isobject "^3.0.0" - -object.pick@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/object.pick/-/object.pick-1.3.0.tgz#87a10ac4c1694bd2e1cbf53591a66141fb5dd747" - integrity sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c= - dependencies: - isobject "^3.0.1" - -once@^1.3.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" - integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= - dependencies: - wrappy "1" - -onetime@^5.1.0: - version "5.1.2" - resolved "https://registry.yarnpkg.com/onetime/-/onetime-5.1.2.tgz#d0e96ebb56b07476df1dd9c4806e5237985ca45e" - integrity sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg== - dependencies: - mimic-fn "^2.1.0" - -optionator@^0.8.3: - version "0.8.3" - resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.3.tgz#84fa1d036fe9d3c7e21d99884b601167ec8fb495" - integrity sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA== - dependencies: - deep-is "~0.1.3" - fast-levenshtein "~2.0.6" - levn "~0.3.0" - prelude-ls "~1.1.2" - type-check "~0.3.2" - word-wrap "~1.2.3" - -os-tmpdir@~1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" - integrity sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ= - -parent-module@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2" - integrity sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g== - dependencies: - callsites "^3.0.0" - -parse-json@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-2.2.0.tgz#f480f40434ef80741f8469099f8dea18f55a4dc9" - integrity sha1-9ID0BDTvgHQfhGkJn43qGPVaTck= - dependencies: - error-ex "^1.2.0" - -pascalcase@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14" - integrity sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ= - -path-dirname@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/path-dirname/-/path-dirname-1.0.2.tgz#cc33d24d525e099a5388c0336c6e32b9160609e0" - integrity sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA= - -path-exists@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-2.1.0.tgz#0feb6c64f0fc518d9a754dd5efb62c7022761f4b" - integrity sha1-D+tsZPD8UY2adU3V77YscCJ2H0s= - dependencies: - pinkie-promise "^2.0.0" - -path-is-absolute@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" - integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= - -path-key@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" - integrity sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A= - -path-parse@^1.0.6: - version "1.0.6" - resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" - integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw== - -path-type@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/path-type/-/path-type-1.1.0.tgz#59c44f7ee491da704da415da5a4070ba4f8fe441" - integrity sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE= - dependencies: - graceful-fs "^4.1.2" - pify "^2.0.0" - pinkie-promise "^2.0.0" - -path@^0.12.7: - version "0.12.7" - resolved "https://registry.yarnpkg.com/path/-/path-0.12.7.tgz#d4dc2a506c4ce2197eb481ebfcd5b36c0140b10f" - integrity sha1-1NwqUGxM4hl+tIHr/NWzbAFAsQ8= - dependencies: - process "^0.11.1" - util "^0.10.3" - -phaser@^3.24.1: - version "3.24.1" - resolved "https://registry.yarnpkg.com/phaser/-/phaser-3.24.1.tgz#376e0c965d2a35af37c06ee78627dafbde5be017" - integrity sha512-WbrRMkbpEzarkfrq83akeauc6b8xNxsOTpDygyW7wrU2G2ne6kOYu3hji4UAaGnZaOLrVuj8ycYPjX9P1LxcDw== - dependencies: - eventemitter3 "^4.0.4" - exports-loader "^1.1.0" - imports-loader "^1.1.0" - path "^0.12.7" - -picomatch@^2.0.4, picomatch@^2.2.1: - version "2.2.2" - resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad" - integrity sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg== - -pify@^2.0.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" - integrity sha1-7RQaasBDqEnqWISY59yosVMw6Qw= - -pinkie-promise@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa" - integrity sha1-ITXW36ejWMBprJsXh3YogihFD/o= - dependencies: - pinkie "^2.0.0" - -pinkie@^2.0.0: - version "2.0.4" - resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870" - integrity sha1-clVrgM+g1IqXToDnckjoDtT3+HA= - -posix-character-classes@^0.1.0: - version "0.1.1" - resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab" - integrity sha1-AerA/jta9xoqbAL+q7jB/vfgDqs= - -prelude-ls@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" - integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ= - -process@^0.11.1: - version "0.11.10" - resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" - integrity sha1-czIwDoQBYb2j5podHZGn1LwW8YI= - -progress@^2.0.0: - version "2.0.3" - resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8" - integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA== - -punycode@^2.1.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" - integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== - -read-pkg-up@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-1.0.1.tgz#9d63c13276c065918d57f002a57f40a1b643fb02" - integrity sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI= - dependencies: - find-up "^1.0.0" - read-pkg "^1.0.0" - -read-pkg@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-1.1.0.tgz#f5ffaa5ecd29cb31c0474bca7d756b6bb29e3f28" - integrity sha1-9f+qXs0pyzHAR0vKfXVra7KePyg= - dependencies: - load-json-file "^1.0.0" - normalize-package-data "^2.3.2" - path-type "^1.0.0" - -readdirp@~3.4.0: - version "3.4.0" - resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.4.0.tgz#9fdccdf9e9155805449221ac645e8303ab5b9ada" - integrity sha512-0xe001vZBnJEK+uKcj8qOhyAKPzIT+gStxWr3LCB0DwcXR5NZJ3IaC+yGnHCYzB/S7ov3m3EEbZI2zeNvX+hGQ== - dependencies: - picomatch "^2.2.1" - -redent@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/redent/-/redent-1.0.0.tgz#cf916ab1fd5f1f16dfb20822dd6ec7f730c2afde" - integrity sha1-z5Fqsf1fHxbfsggi3W7H9zDCr94= - dependencies: - indent-string "^2.1.0" - strip-indent "^1.0.1" - -regex-not@^1.0.0, regex-not@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/regex-not/-/regex-not-1.0.2.tgz#1f4ece27e00b0b65e0247a6810e6a85d83a5752c" - integrity sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A== - dependencies: - extend-shallow "^3.0.2" - safe-regex "^1.1.0" - -regexpp@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f" - integrity sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw== - -regexpp@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.1.0.tgz#206d0ad0a5648cffbdb8ae46438f3dc51c9f78e2" - integrity sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q== - -repeat-element@^1.1.2: - version "1.1.3" - resolved "https://registry.yarnpkg.com/repeat-element/-/repeat-element-1.1.3.tgz#782e0d825c0c5a3bb39731f84efee6b742e6b1ce" - integrity sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g== - -repeat-string@^1.6.1: - version "1.6.1" - resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" - integrity sha1-jcrkcOHIirwtYA//Sndihtp15jc= - -repeating@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/repeating/-/repeating-2.0.1.tgz#5214c53a926d3552707527fbab415dbc08d06dda" - integrity sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo= - dependencies: - is-finite "^1.0.0" - -resolve-from@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" - integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g== - -resolve-url@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" - integrity sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo= - -resolve@^1.0.0, resolve@^1.10.0: - version "1.17.0" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.17.0.tgz#b25941b54968231cc2d1bb76a79cb7f2c0bf8444" - integrity sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w== - dependencies: - path-parse "^1.0.6" - -restore-cursor@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-3.1.0.tgz#39f67c54b3a7a58cea5236d95cf0034239631f7e" - integrity sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA== - dependencies: - onetime "^5.1.0" - signal-exit "^3.0.2" - -ret@~0.1.10: - version "0.1.15" - resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc" - integrity sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg== - -rimraf@2.6.3: - version "2.6.3" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.3.tgz#b2d104fe0d8fb27cf9e0a1cda8262dd3833c6cab" - integrity sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA== - dependencies: - glob "^7.1.3" - -rimraf@^2.6.1: - version "2.7.1" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec" - integrity sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w== - dependencies: - glob "^7.1.3" - -run-async@^2.4.0: - version "2.4.1" - resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.4.1.tgz#8440eccf99ea3e70bd409d49aab88e10c189a455" - integrity sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ== - -rxjs@^6.6.0: - version "6.6.3" - resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.6.3.tgz#8ca84635c4daa900c0d3967a6ee7ac60271ee552" - integrity sha512-trsQc+xYYXZ3urjOiJOuCOa5N3jAZ3eiSpQB5hIT8zGlL2QfnHLJ2r7GMkBGuIausdJN1OneaI6gQlsqNHHmZQ== - dependencies: - tslib "^1.9.0" - -safe-regex@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/safe-regex/-/safe-regex-1.1.0.tgz#40a3669f3b077d1e943d44629e157dd48023bf2e" - integrity sha1-QKNmnzsHfR6UPURinhV91IAjvy4= - dependencies: - ret "~0.1.10" - -"safer-buffer@>= 2.1.2 < 3": - version "2.1.2" - resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" - integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== - -schema-utils@^2.7.0: - version "2.7.1" - resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-2.7.1.tgz#1ca4f32d1b24c590c203b8e7a50bf0ea4cd394d7" - integrity sha512-SHiNtMOUGWBQJwzISiVYKu82GiV4QYGePp3odlY1tuKO7gPtphAT5R/py0fA6xtbgLL/RvtJZnU9b8s0F1q0Xg== - dependencies: - "@types/json-schema" "^7.0.5" - ajv "^6.12.4" - ajv-keywords "^3.5.2" - -"semver@2 || 3 || 4 || 5", semver@^5.5.0: - version "5.7.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" - integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== - -semver@^6.1.2: - version "6.3.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" - integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== - -semver@^7.3.2: - version "7.3.2" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.2.tgz#604962b052b81ed0786aae84389ffba70ffd3938" - integrity sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ== - -set-value@^2.0.0, set-value@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/set-value/-/set-value-2.0.1.tgz#a18d40530e6f07de4228c7defe4227af8cad005b" - integrity sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw== - dependencies: - extend-shallow "^2.0.1" - is-extendable "^0.1.1" - is-plain-object "^2.0.3" - split-string "^3.0.1" - -shebang-command@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" - integrity sha1-RKrGW2lbAzmJaMOfNj/uXer98eo= - dependencies: - shebang-regex "^1.0.0" - -shebang-regex@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" - integrity sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM= - -signal-exit@^3.0.0, signal-exit@^3.0.2: - version "3.0.3" - resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c" - integrity sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA== - -slice-ansi@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-2.1.0.tgz#cacd7693461a637a5788d92a7dd4fba068e81636" - integrity sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ== - dependencies: - ansi-styles "^3.2.0" - astral-regex "^1.0.0" - is-fullwidth-code-point "^2.0.0" - -snapdragon-node@^2.0.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b" - integrity sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw== - dependencies: - define-property "^1.0.0" - isobject "^3.0.0" - snapdragon-util "^3.0.1" - -snapdragon-util@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/snapdragon-util/-/snapdragon-util-3.0.1.tgz#f956479486f2acd79700693f6f7b805e45ab56e2" - integrity sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ== - dependencies: - kind-of "^3.2.0" - -snapdragon@^0.8.1: - version "0.8.2" - resolved "https://registry.yarnpkg.com/snapdragon/-/snapdragon-0.8.2.tgz#64922e7c565b0e14204ba1aa7d6964278d25182d" - integrity sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg== - dependencies: - base "^0.11.1" - debug "^2.2.0" - define-property "^0.2.5" - extend-shallow "^2.0.1" - map-cache "^0.2.2" - source-map "^0.5.6" - source-map-resolve "^0.5.0" - use "^3.1.0" - -source-map-resolve@^0.5.0: - version "0.5.3" - resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.5.3.tgz#190866bece7553e1f8f267a2ee82c606b5509a1a" - integrity sha512-Htz+RnsXWk5+P2slx5Jh3Q66vhQj1Cllm0zvnaY98+NFx+Dv2CF/f5O/t8x+KaNdrdIAsruNzoh/KpialbqAnw== - dependencies: - atob "^2.1.2" - decode-uri-component "^0.2.0" - resolve-url "^0.2.1" - source-map-url "^0.4.0" - urix "^0.1.0" - -source-map-support@^0.5.12, source-map-support@^0.5.17: - version "0.5.19" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61" - integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw== - dependencies: - buffer-from "^1.0.0" - source-map "^0.6.0" - -source-map-url@^0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.0.tgz#3e935d7ddd73631b97659956d55128e87b5084a3" - integrity sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM= - -source-map@^0.5.6: - version "0.5.7" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" - integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= - -source-map@^0.6.0, source-map@^0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" - integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== - -spdx-correct@^3.0.0: - version "3.1.1" - resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.1.1.tgz#dece81ac9c1e6713e5f7d1b6f17d468fa53d89a9" - integrity sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w== - dependencies: - spdx-expression-parse "^3.0.0" - spdx-license-ids "^3.0.0" - -spdx-exceptions@^2.1.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz#3f28ce1a77a00372683eade4a433183527a2163d" - integrity sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A== - -spdx-expression-parse@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz#cf70f50482eefdc98e3ce0a6833e4a53ceeba679" - integrity sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q== - dependencies: - spdx-exceptions "^2.1.0" - spdx-license-ids "^3.0.0" - -spdx-license-ids@^3.0.0: - version "3.0.6" - resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.6.tgz#c80757383c28abf7296744998cbc106ae8b854ce" - integrity sha512-+orQK83kyMva3WyPf59k1+Y525csj5JejicWut55zeTWANuN17qSiSLUXWtzHeNWORSvT7GLDJ/E/XiIWoXBTw== - -split-string@^3.0.1, split-string@^3.0.2: - version "3.1.0" - resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2" - integrity sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw== - dependencies: - extend-shallow "^3.0.0" - -sprintf-js@~1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" - integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= - -static-extend@^0.1.1: - version "0.1.2" - resolved "https://registry.yarnpkg.com/static-extend/-/static-extend-0.1.2.tgz#60809c39cbff55337226fd5e0b520f341f1fb5c6" - integrity sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY= - dependencies: - define-property "^0.2.5" - object-copy "^0.1.0" - -string-width@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-3.1.0.tgz#22767be21b62af1081574306f69ac51b62203961" - integrity sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w== - dependencies: - emoji-regex "^7.0.1" - is-fullwidth-code-point "^2.0.0" - strip-ansi "^5.1.0" - -string-width@^4.1.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.0.tgz#952182c46cc7b2c313d1596e623992bd163b72b5" - integrity sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.0" - -strip-ansi@^5.1.0, strip-ansi@^5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-5.2.0.tgz#8c9a536feb6afc962bdfa5b104a5091c1ad9c0ae" - integrity sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA== - dependencies: - ansi-regex "^4.1.0" - -strip-ansi@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.0.tgz#0b1571dd7669ccd4f3e06e14ef1eed26225ae532" - integrity sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w== - dependencies: - ansi-regex "^5.0.0" - -strip-bom@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-2.0.0.tgz#6219a85616520491f35788bdbf1447a99c7e6b0e" - integrity sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4= - dependencies: - is-utf8 "^0.2.0" - -strip-bom@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" - integrity sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM= - -strip-comments@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/strip-comments/-/strip-comments-2.0.1.tgz#4ad11c3fbcac177a67a40ac224ca339ca1c1ba9b" - integrity sha512-ZprKx+bBLXv067WTCALv8SSz5l2+XhpYCsVtSqlMnkAXMWDq+/ekVbl1ghqP9rUHTzv6sm/DwCOiYutU/yp1fw== - -strip-indent@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-1.0.1.tgz#0c7962a6adefa7bbd4ac366460a638552ae1a0a2" - integrity sha1-DHlipq3vp7vUrDZkYKY4VSrhoKI= - dependencies: - get-stdin "^4.0.1" - -strip-json-comments@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" - integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo= - -strip-json-comments@^3.0.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" - integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== - -supports-color@^5.3.0: - version "5.5.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" - integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== - dependencies: - has-flag "^3.0.0" - -supports-color@^7.1.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" - integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== - dependencies: - has-flag "^4.0.0" - -table@^5.2.3: - version "5.4.6" - resolved "https://registry.yarnpkg.com/table/-/table-5.4.6.tgz#1292d19500ce3f86053b05f0e8e7e4a3bb21079e" - integrity sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug== - dependencies: - ajv "^6.10.2" - lodash "^4.17.14" - slice-ansi "^2.1.0" - string-width "^3.0.0" - -text-table@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" - integrity sha1-f17oI66AUgfACvLfSoTsP8+lcLQ= - -through@^2.3.6: - version "2.3.8" - resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" - integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU= - -tmp@^0.0.33: - version "0.0.33" - resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" - integrity sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw== - dependencies: - os-tmpdir "~1.0.2" - -to-object-path@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/to-object-path/-/to-object-path-0.3.0.tgz#297588b7b0e7e0ac08e04e672f85c1f4999e17af" - integrity sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68= - dependencies: - kind-of "^3.0.2" - -to-regex-range@^2.1.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-2.1.1.tgz#7c80c17b9dfebe599e27367e0d4dd5590141db38" - integrity sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg= - dependencies: - is-number "^3.0.0" - repeat-string "^1.6.1" - -to-regex-range@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" - integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== - dependencies: - is-number "^7.0.0" - -to-regex@^3.0.1, to-regex@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/to-regex/-/to-regex-3.0.2.tgz#13cfdd9b336552f30b51f33a8ae1b42a7a7599ce" - integrity sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw== - dependencies: - define-property "^2.0.2" - extend-shallow "^3.0.2" - regex-not "^1.0.2" - safe-regex "^1.1.0" - -tree-kill@^1.2.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/tree-kill/-/tree-kill-1.2.2.tgz#4ca09a9092c88b73a7cdc5e8a01b507b0790a0cc" - integrity sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A== - -trim-newlines@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613" - integrity sha1-WIeWa7WCpFA6QetST301ARgVphM= - -ts-node-dev@^1.0.0-pre.44: - version "1.0.0-pre.62" - resolved "https://registry.yarnpkg.com/ts-node-dev/-/ts-node-dev-1.0.0-pre.62.tgz#835644c43669b659a880379b9d06df86cef665ad" - integrity sha512-hfsEuCqUZOVnZ86l7A3icxD1nFt1HEmLVbx4YOHCkrbSHPBNWcw+IczAPZo3zz7YiOm9vs0xG6OENNrkgm89tQ== - dependencies: - chokidar "^3.4.0" - dateformat "~1.0.4-1.2.3" - dynamic-dedupe "^0.3.0" - minimist "^1.2.5" - mkdirp "^1.0.4" - resolve "^1.0.0" - rimraf "^2.6.1" - source-map-support "^0.5.12" - tree-kill "^1.2.2" - ts-node "^8.10.2" - tsconfig "^7.0.0" - -ts-node@^8.10.2: - version "8.10.2" - resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-8.10.2.tgz#eee03764633b1234ddd37f8db9ec10b75ec7fb8d" - integrity sha512-ISJJGgkIpDdBhWVu3jufsWpK3Rzo7bdiIXJjQc0ynKxVOVcg2oIrf2H2cejminGrptVc6q6/uynAHNCuWGbpVA== - dependencies: - arg "^4.1.0" - diff "^4.0.1" - make-error "^1.1.1" - source-map-support "^0.5.17" - yn "3.1.1" - -tsconfig@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/tsconfig/-/tsconfig-7.0.0.tgz#84538875a4dc216e5c4a5432b3a4dec3d54e91b7" - integrity sha512-vZXmzPrL+EmC4T/4rVlT2jNVMWCi/O4DIiSj3UHg1OE5kCKbk4mfrXc6dZksLgRM/TZlKnousKH9bbTazUWRRw== - dependencies: - "@types/strip-bom" "^3.0.0" - "@types/strip-json-comments" "0.0.30" - strip-bom "^3.0.0" - strip-json-comments "^2.0.0" - -tslib@^1.8.1, tslib@^1.9.0: - version "1.13.0" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.13.0.tgz#c881e13cc7015894ed914862d276436fa9a47043" - integrity sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q== - -tsutils@^3.17.1: - version "3.17.1" - resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.17.1.tgz#ed719917f11ca0dee586272b2ac49e015a2dd759" - integrity sha512-kzeQ5B8H3w60nFY2g8cJIuH7JDpsALXySGtwGJ0p2LSjLgay3NdIpqq5SoOBe46bKDW2iq25irHCr8wjomUS2g== - dependencies: - tslib "^1.8.1" - -type-check@~0.3.2: - version "0.3.2" - resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" - integrity sha1-WITKtRLPHTVeP7eE8wgEsrUg23I= - dependencies: - prelude-ls "~1.1.2" - -type-fest@^0.11.0: - version "0.11.0" - resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.11.0.tgz#97abf0872310fed88a5c466b25681576145e33f1" - integrity sha512-OdjXJxnCN1AvyLSzeKIgXTXxV+99ZuXl3Hpo9XpJAv9MBcHrrJOQ5kV7ypXOuQie+AmWG25hLbiKdwYTifzcfQ== - -type-fest@^0.8.1: - version "0.8.1" - resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.8.1.tgz#09e249ebde851d3b1e48d27c105444667f17b83d" - integrity sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA== - -typescript@^3.8.3: - version "3.9.7" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.7.tgz#98d600a5ebdc38f40cb277522f12dc800e9e25fa" - integrity sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw== - -union-value@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/union-value/-/union-value-1.0.1.tgz#0b6fe7b835aecda61c6ea4d4f02c14221e109847" - integrity sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg== - dependencies: - arr-union "^3.1.0" - get-value "^2.0.6" - is-extendable "^0.1.1" - set-value "^2.0.1" - -unset-value@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/unset-value/-/unset-value-1.0.0.tgz#8376873f7d2335179ffb1e6fc3a8ed0dfc8ab559" - integrity sha1-g3aHP30jNRef+x5vw6jtDfyKtVk= - dependencies: - has-value "^0.3.1" - isobject "^3.0.0" - -uri-js@^4.2.2: - version "4.4.0" - resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.0.tgz#aa714261de793e8a82347a7bcc9ce74e86f28602" - integrity sha512-B0yRTzYdUCCn9n+F4+Gh4yIDtMQcaJsmYBDsTSG8g/OejKBodLQ2IHfN3bM7jUsRXndopT7OIXWdYqc1fjmV6g== - dependencies: - punycode "^2.1.0" - -urix@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/urix/-/urix-0.1.0.tgz#da937f7a62e21fec1fd18d49b35c2935067a6c72" - integrity sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI= - -use@^3.1.0: - version "3.1.1" - resolved "https://registry.yarnpkg.com/use/-/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f" - integrity sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ== - -util@^0.10.3: - version "0.10.4" - resolved "https://registry.yarnpkg.com/util/-/util-0.10.4.tgz#3aa0125bfe668a4672de58857d3ace27ecb76901" - integrity sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A== - dependencies: - inherits "2.0.3" - -v8-compile-cache@^2.0.3: - version "2.1.1" - resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.1.1.tgz#54bc3cdd43317bca91e35dcaf305b1a7237de745" - integrity sha512-8OQ9CL+VWyt3JStj7HX7/ciTL2V3Rl1Wf5OL+SNTm0yK1KvtReVulksyeRnCANHHuUxHlQig+JJDlUhBt1NQDQ== - -validate-npm-package-license@^3.0.1: - version "3.0.4" - resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz#fc91f6b9c7ba15c857f4cb2c5defeec39d4f410a" - integrity sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew== - dependencies: - spdx-correct "^3.0.0" - spdx-expression-parse "^3.0.0" - -which@^1.2.9: - version "1.3.1" - resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" - integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== - dependencies: - isexe "^2.0.0" - -word-wrap@~1.2.3: - version "1.2.3" - resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c" - integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ== - -wrappy@1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" - integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= - -write@1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/write/-/write-1.0.3.tgz#0800e14523b923a387e415123c865616aae0f5c3" - integrity sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig== - dependencies: - mkdirp "^0.5.1" - -xtend@^4.0.0: - version "4.0.2" - resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54" - integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ== - -yn@3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" - integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q== From 3cb079c80c3f88bf0c503a5b2e41779698930235 Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Wed, 23 Sep 2020 18:37:54 +0200 Subject: [PATCH 051/122] Fix CI --- front/package.json | 1 + .../ConsoleGlobalMessageManager.ts | 2 +- front/yarn.lock | 46 +++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/front/package.json b/front/package.json index a9c7b3f8..dd620e40 100644 --- a/front/package.json +++ b/front/package.json @@ -25,6 +25,7 @@ "generic-type-guard": "^3.2.0", "phaser": "^3.22.0", "queue-typescript": "^1.0.1", + "quill": "1.3.6", "simple-peer": "^9.6.2", "socket.io-client": "^2.3.0", "webpack-require-http": "^0.4.3" diff --git a/front/src/Administration/ConsoleGlobalMessageManager.ts b/front/src/Administration/ConsoleGlobalMessageManager.ts index 582427af..69f4a3ad 100644 --- a/front/src/Administration/ConsoleGlobalMessageManager.ts +++ b/front/src/Administration/ConsoleGlobalMessageManager.ts @@ -145,7 +145,7 @@ export class ConsoleGlobalMessageManager { // remove formatting button ]; - let quill = new Quill(`#${INPUT_CONSOLE_MESSAGE}`, { + new Quill(`#${INPUT_CONSOLE_MESSAGE}`, { theme: 'snow', modules: { toolbar: toolbarOptions diff --git a/front/yarn.lock b/front/yarn.lock index 2e7007e1..8b5510c5 100644 --- a/front/yarn.lock +++ b/front/yarn.lock @@ -1009,6 +1009,11 @@ cliui@^5.0.0: strip-ansi "^5.2.0" wrap-ansi "^5.1.0" +clone@^2.1.1: + version "2.1.2" + resolved "https://registry.yarnpkg.com/clone/-/clone-2.1.2.tgz#1b7f4b9f591f1e8f83670401600345a02887435f" + integrity sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18= + collection-visit@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/collection-visit/-/collection-visit-1.0.0.tgz#4bc0373c164bc3291b4d368c829cf1a80a59dca0" @@ -1760,6 +1765,11 @@ etag@~1.8.1: resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887" integrity sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc= +eventemitter3@^2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-2.0.3.tgz#b5e1079b59fb5e1ba2771c0a993be060a58c99ba" + integrity sha1-teEHm1n7XhuidxwKmTvgYKWMmbo= + eventemitter3@^4.0.0, eventemitter3@^4.0.4: version "4.0.4" resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.4.tgz#b5463ace635a083d018bdc7c917b4c5f10a85384" @@ -1878,6 +1888,11 @@ extend-shallow@^3.0.0, extend-shallow@^3.0.2: assign-symbols "^1.0.0" is-extendable "^1.0.1" +extend@^3.0.1, extend@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" + integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g== + external-editor@^3.0.3: version "3.1.0" resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-3.1.0.tgz#cb03f740befae03ea4d283caed2741a83f335495" @@ -1906,6 +1921,11 @@ fast-deep-equal@^3.1.1: resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== +fast-diff@1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.1.2.tgz#4b62c42b8e03de3f848460b639079920695d0154" + integrity sha512-KaJUt+M9t1qaIteSvjc6P3RbMdXsNhK61GRftR6SNxqmhthcd9MGIi4T+o0jD8LUSpSnSKXE20nLtJ3fOHxQig== + fast-glob@^2.2.6: version "2.2.7" resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-2.2.7.tgz#6953857c3afa475fff92ee6015d52da70a4cd39d" @@ -3529,6 +3549,11 @@ param-case@^3.0.3: dot-case "^3.0.3" tslib "^1.10.0" +parchment@^1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/parchment/-/parchment-1.1.4.tgz#aeded7ab938fe921d4c34bc339ce1168bc2ffde5" + integrity sha512-J5FBQt/pM2inLzg4hEWmzQx/8h8D0CiDxaG3vyp9rKrQRSDgBlhjdP5jQGgosEajXPSQouXGHOmVdgo7QmJuOg== + parent-module@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2" @@ -3827,6 +3852,27 @@ queue-typescript@^1.0.1: dependencies: linked-list-typescript "^1.0.11" +quill-delta@^3.6.2: + version "3.6.3" + resolved "https://registry.yarnpkg.com/quill-delta/-/quill-delta-3.6.3.tgz#b19fd2b89412301c60e1ff213d8d860eac0f1032" + integrity sha512-wdIGBlcX13tCHOXGMVnnTVFtGRLoP0imqxM696fIPwIf5ODIYUHIvHbZcyvGlZFiFhK5XzDC2lpjbxRhnM05Tg== + dependencies: + deep-equal "^1.0.1" + extend "^3.0.2" + fast-diff "1.1.2" + +quill@1.3.6: + version "1.3.6" + resolved "https://registry.yarnpkg.com/quill/-/quill-1.3.6.tgz#99f4de1fee85925a0d7d4163b6d8328f23317a4d" + integrity sha512-K0mvhimWZN6s+9OQ249CH2IEPZ9JmkFuCQeHAOQax3EZ2nDJ3wfGh59mnlQaZV2i7u8eFarx6wAtvQKgShojug== + dependencies: + clone "^2.1.1" + deep-equal "^1.0.1" + eventemitter3 "^2.0.3" + extend "^3.0.1" + parchment "^1.1.4" + quill-delta "^3.6.2" + randombytes@^2.0.0, randombytes@^2.0.1, randombytes@^2.0.3, randombytes@^2.0.5, randombytes@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" From 7584c3a04df4a828360b9545e3133307f3484e84 Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Wed, 23 Sep 2020 18:44:24 +0200 Subject: [PATCH 052/122] Fix CI --- .../ConsoleGlobalMessageManager.ts | 26 ++++++++++++------- .../Administration/GlobalMessageManager.ts | 2 +- front/src/Connection.ts | 2 +- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/front/src/Administration/ConsoleGlobalMessageManager.ts b/front/src/Administration/ConsoleGlobalMessageManager.ts index 69f4a3ad..7de1af40 100644 --- a/front/src/Administration/ConsoleGlobalMessageManager.ts +++ b/front/src/Administration/ConsoleGlobalMessageManager.ts @@ -35,7 +35,9 @@ export class ConsoleGlobalMessageManager { initialise() { try { HtmlUtils.removeElementByIdOrFail(CLASS_CONSOLE_MESSAGE); - }catch (err){} + }catch (err){ + console.error(err); + } const typeConsole = document.createElement('input'); typeConsole.id = INPUT_TYPE_CONSOLE; @@ -169,11 +171,11 @@ export class ConsoleGlobalMessageManager { const input = document.createElement('input'); input.type = 'file'; input.id = UPLOAD_CONSOLE_MESSAGE - input.addEventListener('input', (e: any) => { + input.addEventListener('input', (e: Event) => { if(!e.target || !e.target.files || e.target.files.length === 0){ return; } - let file : File = e.target.files[0]; + const file : File = e.target.files[0]; if(!file){ return; @@ -181,7 +183,9 @@ export class ConsoleGlobalMessageManager { try { HtmlUtils.removeElementByIdOrFail('audi-message-filename'); - }catch (e) {} + }catch (err) { + console.error(err) + } const p = document.createElement('p'); p.id = 'audi-message-filename'; @@ -223,12 +227,12 @@ export class ConsoleGlobalMessageManager { } private sendTextMessage(){ - let elements = document.getElementsByClassName('ql-editor'); - let quillEditor = elements.item(0); + const elements = document.getElementsByClassName('ql-editor'); + const quillEditor = elements.item(0); if(!quillEditor){ throw "Error get quill node"; } - let GlobalMessage : GlobalMessageInterface = { + const GlobalMessage : GlobalMessageInterface = { id: 1, message: quillEditor.innerHTML, type: MESSAGE_TYPE @@ -246,9 +250,9 @@ export class ConsoleGlobalMessageManager { const fd = new FormData(); fd.append('file', selectedFile); - let res = await this.Connection.uploadAudio(fd); + const res = await this.Connection.uploadAudio(fd); - let GlobalMessage : GlobalMessageInterface = { + const GlobalMessage : GlobalMessageInterface = { id: res.id, message: res.path, type: AUDIO_TYPE @@ -256,7 +260,9 @@ export class ConsoleGlobalMessageManager { inputAudio.value = ''; try { HtmlUtils.removeElementByIdOrFail('audi-message-filename'); - }catch (e) {} + }catch (err) { + console.error(err); + } this.Connection.emitGlobalMessage(GlobalMessage); } diff --git a/front/src/Administration/GlobalMessageManager.ts b/front/src/Administration/GlobalMessageManager.ts index e2850bff..0b75d4be 100644 --- a/front/src/Administration/GlobalMessageManager.ts +++ b/front/src/Administration/GlobalMessageManager.ts @@ -25,7 +25,7 @@ export class GlobalMessageManager { } private playMessage(message : GlobalMessageInterface){ - let previousMessage = document.getElementById(this.getHtmlMessageId(message.id)); + const previousMessage = document.getElementById(this.getHtmlMessageId(message.id)); if(previousMessage){ previousMessage.remove(); } diff --git a/front/src/Connection.ts b/front/src/Connection.ts index 66a133f3..dd8540bf 100644 --- a/front/src/Connection.ts +++ b/front/src/Connection.ts @@ -200,7 +200,7 @@ export class Connection implements Connection { } public uploadAudio(file : FormData){ - return Axios.post(`${API_URL}/upload-audio-message`, file).then((res: any) => { + return Axios.post(`${API_URL}/upload-audio-message`, file).then((res: {data:{}}) => { return res.data; }).catch((err) => { console.error(err); From 7f4014cccfb99603612eaa4a967d5558436226e3 Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Wed, 23 Sep 2020 19:07:45 +0200 Subject: [PATCH 053/122] Fix CI --- .../ConsoleGlobalMessageManager.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/front/src/Administration/ConsoleGlobalMessageManager.ts b/front/src/Administration/ConsoleGlobalMessageManager.ts index 7de1af40..84a73a71 100644 --- a/front/src/Administration/ConsoleGlobalMessageManager.ts +++ b/front/src/Administration/ConsoleGlobalMessageManager.ts @@ -15,6 +15,10 @@ export const INPUT_TYPE_CONSOLE = 'input-type'; export const AUDIO_TYPE = 'audio'; export const MESSAGE_TYPE = 'message'; +interface EventTargetFiles extends EventTarget { + files: Array; +} + export class ConsoleGlobalMessageManager { private Connection: Connection; @@ -172,10 +176,14 @@ export class ConsoleGlobalMessageManager { input.type = 'file'; input.id = UPLOAD_CONSOLE_MESSAGE input.addEventListener('input', (e: Event) => { - if(!e.target || !e.target.files || e.target.files.length === 0){ + if(!e.target){ return; } - const file : File = e.target.files[0]; + const eventTarget : EventTargetFiles = (e.target as EventTargetFiles); + if(!eventTarget || !eventTarget.files || eventTarget.files.length === 0){ + return; + } + const file : File = eventTarget.files[0]; if(!file){ return; @@ -253,8 +261,8 @@ export class ConsoleGlobalMessageManager { const res = await this.Connection.uploadAudio(fd); const GlobalMessage : GlobalMessageInterface = { - id: res.id, - message: res.path, + id: (res as {id: number}).id, + message: (res as {path: string}).path, type: AUDIO_TYPE }; inputAudio.value = ''; From b4f971c50115c180edbecf86742b73ab5e9be0bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 24 Sep 2020 10:05:16 +0200 Subject: [PATCH 054/122] Switched group position to protobuf --- back/src/Controller/IoSocketController.ts | 27 +++++++++++++++++------ back/src/Model/World.ts | 2 +- front/src/Connection.ts | 27 ++++++++++++----------- messages/messages.proto | 2 ++ messages/package.json | 2 +- 5 files changed, 38 insertions(+), 22 deletions(-) diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index 4a1c9240..bf1452ac 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -27,7 +27,7 @@ import { SetPlayerDetailsMessage, SubMessage, UserMovedMessage, - BatchMessage, GroupUpdateMessage, PointMessage + BatchMessage, GroupUpdateMessage, PointMessage, GroupDeleteMessage } from "../../../messages/generated/messages_pb"; import {UserMovesMessage} from "../../../messages/generated/messages_pb"; import Direction = PositionMessage.Direction; @@ -573,7 +573,7 @@ export class IoSocketController { clientListener.emit(SocketIoEvent.USER_LEFT, clientUser.userId); //console.log("Sending USER_LEFT event"); } else if (thing instanceof Group) { - clientListener.emit(SocketIoEvent.GROUP_DELETE, thing.getId()); + this.emitDeleteGroupEvent(clientListener, thing.getId()); } else { console.error('Unexpected type for Movable.'); } @@ -584,10 +584,7 @@ export class IoSocketController { // Dispatch groups position to newly connected user world.getGroups().forEach((group: Group) => { - Client.emit(SocketIoEvent.GROUP_CREATE_UPDATE, { - position: group.getPosition(), - groupId: group.getId() - } as GroupUpdateInterface); + this.emitCreateUpdateGroupEvent(Client, group); }); //join world world.join(Client, Client.position); @@ -603,7 +600,23 @@ export class IoSocketController { groupUpdateMessage.setGroupid(group.getId()); groupUpdateMessage.setPosition(pointMessage); - socket.emit(SocketIoEvent.GROUP_CREATE_UPDATE, groupUpdateMessage.serializeBinary().buffer); + const subMessage = new SubMessage(); + subMessage.setGroupupdatemessage(groupUpdateMessage); + + const client : ExSocketInterface = socket as ExSocketInterface; + emitInBatch(client, SocketIoEvent.GROUP_CREATE_UPDATE, subMessage); + //socket.emit(SocketIoEvent.GROUP_CREATE_UPDATE, groupUpdateMessage.serializeBinary().buffer); + } + + private emitDeleteGroupEvent(socket: Socket, groupId: number): void { + const groupDeleteMessage = new GroupDeleteMessage(); + groupDeleteMessage.setGroupid(groupId); + + const subMessage = new SubMessage(); + subMessage.setGroupdeletemessage(groupDeleteMessage); + + const client : ExSocketInterface = socket as ExSocketInterface; + emitInBatch(client, SocketIoEvent.GROUP_DELETE, subMessage); } /** diff --git a/back/src/Model/World.ts b/back/src/Model/World.ts index 452c6c17..321b3e1b 100644 --- a/back/src/Model/World.ts +++ b/back/src/Model/World.ts @@ -90,9 +90,9 @@ export class World { this.positionNotifier.updatePosition(user, userPosition, user.position); const oldGroupPosition = user.group?.getPosition(); - user.group?.updatePosition(); user.position = userPosition; + user.group?.updatePosition(); if (user.silent) { return; diff --git a/front/src/Connection.ts b/front/src/Connection.ts index 02752c10..459e58c1 100644 --- a/front/src/Connection.ts +++ b/front/src/Connection.ts @@ -2,7 +2,7 @@ import Axios from "axios"; import {API_URL} from "./Enum/EnvironmentVariable"; import {MessageUI} from "./Logger/MessageUI"; import { - BatchMessage, GroupUpdateMessage, + BatchMessage, GroupDeleteMessage, GroupUpdateMessage, PositionMessage, SetPlayerDetailsMessage, UserMovedMessage, UserMovesMessage, @@ -160,6 +160,12 @@ export class Connection implements Connection { if (message.hasUsermovedmessage()) { event = EventMessage.USER_MOVED; payload = message.getUsermovedmessage(); + } else if (message.hasGroupupdatemessage()) { + event = EventMessage.GROUP_CREATE_UPDATE; + payload = message.getGroupupdatemessage(); + } else if (message.hasGroupdeletemessage()) { + event = EventMessage.GROUP_DELETE; + payload = message.getGroupdeletemessage(); } else { throw new Error('Unexpected batch message type'); } @@ -230,7 +236,6 @@ export class Connection implements Connection { if(!this.socket){ return; } - const point = new Point(x, y, direction, moving); const positionMessage = new PositionMessage(); positionMessage.setX(Math.floor(x)); positionMessage.setY(Math.floor(y)); @@ -264,6 +269,8 @@ export class Connection implements Connection { userMovesMessage.setPosition(positionMessage); userMovesMessage.setViewport(viewportMessage); + //console.log('Sending position ', positionMessage.getX(), positionMessage.getY()); + this.socket.emit(EventMessage.USER_POSITION, userMovesMessage.serializeBinary().buffer); } @@ -301,16 +308,7 @@ export class Connection implements Connection { } public onGroupUpdatedOrCreated(callback: (groupCreateUpdateMessage: GroupCreatedUpdatedMessageInterface) => void): void { - // TODO: READ THIS FROM BINARY FORMAT - // TODO: READ THIS FROM BINARY FORMAT - // TODO: READ THIS FROM BINARY FORMAT - // TODO: CHANGE THIS EVENT TO BE PART OF THE BATCHES - // TODO: CHANGE THIS EVENT TO BE PART OF THE BATCHES - // TODO: CHANGE THIS EVENT TO BE PART OF THE BATCHES - // TODO: CHANGE THIS EVENT TO BE PART OF THE BATCHES - // TODO: CHANGE THIS EVENT TO BE PART OF THE BATCHES - this.socket.on(EventMessage.GROUP_CREATE_UPDATE, (buffer: ArrayBuffer) => { - const message = GroupUpdateMessage.deserializeBinary(new Uint8Array(buffer)); + this.onBatchMessage(EventMessage.GROUP_CREATE_UPDATE, (message: GroupUpdateMessage) => { const position = message.getPosition(); if (position === undefined) { throw new Error('Missing position in GROUP_CREATE_UPDATE'); @@ -321,12 +319,15 @@ export class Connection implements Connection { position: position.toObject() } + //console.log('Group position: ', position.toObject()); callback(groupCreateUpdateMessage); }); } public onGroupDeleted(callback: (groupId: number) => void): void { - this.socket.on(EventMessage.GROUP_DELETE, callback) + this.onBatchMessage(EventMessage.GROUP_DELETE, (message: GroupDeleteMessage) => { + callback(message.getGroupid()); + }); } public onConnectError(callback: (error: object) => void): void { diff --git a/messages/messages.proto b/messages/messages.proto index 9cf6de8a..8b081fe6 100644 --- a/messages/messages.proto +++ b/messages/messages.proto @@ -50,6 +50,8 @@ message UserMovedMessage { message SubMessage { oneof message { UserMovedMessage userMovedMessage = 1; + GroupUpdateMessage groupUpdateMessage = 2; + GroupDeleteMessage groupDeleteMessage = 3; } } diff --git a/messages/package.json b/messages/package.json index b70d4900..6f2bc3f1 100644 --- a/messages/package.json +++ b/messages/package.json @@ -5,7 +5,7 @@ "main": "generated/src/proto/messages_pb.js", "scripts": { "proto": "protoc --plugin=\"protoc-gen-ts=./node_modules/.bin/protoc-gen-ts\" --js_out=\"import_style=commonjs,binary:generated\" --ts_out=\"generated\" messages.proto", - "proto:watch": "inotifywait -q -m -e close_write messages.proto | while read -r filename event; do yarn run proto; done" + "proto:watch": "yarn run proto || inotifywait -q -m -e close_write messages.proto | while read -r filename event; do yarn run proto; done" }, "repository": { "type": "git", From d7209d886430c1794d95c7126a7a8c949c6ed972 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 24 Sep 2020 11:16:08 +0200 Subject: [PATCH 055/122] Migrating messages locally into back and front --- back/Dockerfile | 2 +- back/package.json | 2 ++ back/src/Controller/IoSocketController.ts | 4 ++-- back/src/Messages/.gitignore | 1 + back/src/Model/Websocket/ExSocketInterface.ts | 2 +- back/src/Model/Websocket/ProtobufUtils.ts | 2 +- back/tsconfig.json | 2 +- back/yarn.lock | 10 ++++++++++ docker-compose.yaml | 4 ++-- front/Dockerfile | 2 +- front/package.json | 2 ++ front/src/Connection.ts | 2 +- front/src/Messages/.gitignore | 1 + front/src/Network/ProtobufClientUtils.ts | 2 +- front/src/Phaser/Game/GameScene.ts | 4 +++- front/src/Phaser/Game/PlayerMovement.ts | 3 ++- front/yarn.lock | 10 ++++++++++ messages/package.json | 5 ++++- 18 files changed, 46 insertions(+), 14 deletions(-) create mode 100644 back/src/Messages/.gitignore create mode 100644 front/src/Messages/.gitignore diff --git a/back/Dockerfile b/back/Dockerfile index f0c565f9..bd98d66a 100644 --- a/back/Dockerfile +++ b/back/Dockerfile @@ -6,7 +6,7 @@ RUN yarn install && yarn proto FROM thecodingmachine/nodejs:12 COPY --chown=docker:docker back . -COPY --from=builder --chown=docker:docker /var/www/messages /var/www/messages +COPY --from=builder --chown=docker:docker /var/www/messages/generated /var/www/html/src/Messages/generated RUN yarn install ENV NODE_ENV=production diff --git a/back/package.json b/back/package.json index 3306578a..17763861 100644 --- a/back/package.json +++ b/back/package.json @@ -39,6 +39,7 @@ "body-parser": "^1.19.0", "express": "^4.17.1", "generic-type-guard": "^3.2.0", + "google-protobuf": "^3.13.0", "http-status-codes": "^1.4.0", "jsonwebtoken": "^8.5.1", "prom-client": "^12.0.0", @@ -50,6 +51,7 @@ }, "devDependencies": { "@types/express": "^4.17.4", + "@types/google-protobuf": "^3.7.3", "@types/http-status-codes": "^1.2.0", "@types/jasmine": "^3.5.10", "@types/jsonwebtoken": "^8.3.8", diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index bf1452ac..7e13b9d0 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -28,8 +28,8 @@ import { SubMessage, UserMovedMessage, BatchMessage, GroupUpdateMessage, PointMessage, GroupDeleteMessage -} from "../../../messages/generated/messages_pb"; -import {UserMovesMessage} from "../../../messages/generated/messages_pb"; +} from "../Messages/generated/messages_pb"; +import {UserMovesMessage} from "../Messages/generated/messages_pb"; import Direction = PositionMessage.Direction; import {ProtobufUtils} from "../Model/Websocket/ProtobufUtils"; diff --git a/back/src/Messages/.gitignore b/back/src/Messages/.gitignore new file mode 100644 index 00000000..9e0adcc1 --- /dev/null +++ b/back/src/Messages/.gitignore @@ -0,0 +1 @@ +/generated/ diff --git a/back/src/Model/Websocket/ExSocketInterface.ts b/back/src/Model/Websocket/ExSocketInterface.ts index cd1f73ed..ace374f4 100644 --- a/back/src/Model/Websocket/ExSocketInterface.ts +++ b/back/src/Model/Websocket/ExSocketInterface.ts @@ -3,7 +3,7 @@ import {PointInterface} from "./PointInterface"; import {Identificable} from "./Identificable"; import {TokenInterface} from "../../Controller/AuthenticateController"; import {ViewportInterface} from "_Model/Websocket/ViewportMessage"; -import {BatchMessage, SubMessage} from "../../../../messages/generated/messages_pb"; +import {BatchMessage, SubMessage} from "../../Messages/generated/messages_pb"; export interface ExSocketInterface extends Socket, Identificable { token: string; diff --git a/back/src/Model/Websocket/ProtobufUtils.ts b/back/src/Model/Websocket/ProtobufUtils.ts index 516a744e..4e5aec02 100644 --- a/back/src/Model/Websocket/ProtobufUtils.ts +++ b/back/src/Model/Websocket/ProtobufUtils.ts @@ -1,5 +1,5 @@ import {PointInterface} from "./PointInterface"; -import {PositionMessage} from "../../../../messages/generated/messages_pb"; +import {PositionMessage} from "../../Messages/generated/messages_pb"; import {ExSocketInterface} from "_Model/Websocket/ExSocketInterface"; import Direction = PositionMessage.Direction; diff --git a/back/tsconfig.json b/back/tsconfig.json index de6314a3..34ad9a5a 100644 --- a/back/tsconfig.json +++ b/back/tsconfig.json @@ -7,7 +7,7 @@ "downlevelIteration": true, "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ // "lib": [], /* Specify library files to be included in the compilation. */ - // "allowJs": true, /* Allow javascript files to be compiled. */ + "allowJs": true, /* Allow javascript files to be compiled. */ // "checkJs": true, /* Report errors in .js files. */ // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ // "declaration": true, /* Generates corresponding '.d.ts' file. */ diff --git a/back/yarn.lock b/back/yarn.lock index f660a5c8..feef36ea 100644 --- a/back/yarn.lock +++ b/back/yarn.lock @@ -57,6 +57,11 @@ "@types/qs" "*" "@types/serve-static" "*" +"@types/google-protobuf@^3.7.3": + version "3.7.3" + resolved "https://registry.yarnpkg.com/@types/google-protobuf/-/google-protobuf-3.7.3.tgz#429512e541bbd777f2c867692e6335ee08d1f6d4" + integrity sha512-FRwj40euE2bYkG+0X5w2nEA8yAzgJRcEa7RBd0Gsdkb9/tPM2pctVVAvnOUTbcXo2VmIHPo0Ae94Gl9vRHfKzg== + "@types/http-status-codes@^1.2.0": version "1.2.0" resolved "https://registry.yarnpkg.com/@types/http-status-codes/-/http-status-codes-1.2.0.tgz#6e5244835aaf7164dd306f1d4d2dfdbb2159d909" @@ -822,6 +827,11 @@ globals@^12.1.0: dependencies: type-fest "^0.8.1" +google-protobuf@^3.13.0: + version "3.13.0" + resolved "https://registry.yarnpkg.com/google-protobuf/-/google-protobuf-3.13.0.tgz#909c5983d75dd6101ed57c79e0528d000cdc3251" + integrity sha512-ZIf3qfLFayVrPvAjeKKxO5FRF1/NwRxt6Dko+fWEMuHwHbZx8/fcaAao9b0wCM6kr8qeg2te8XTpyuvKuD9aKw== + graceful-fs@^4.1.2: version "4.2.3" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.3.tgz#4a12ff1b60376ef09862c2093edd908328be8423" diff --git a/docker-compose.yaml b/docker-compose.yaml index fce76204..a37fe28f 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -33,7 +33,6 @@ services: command: yarn run start volumes: - ./front:/usr/src/app - - ./messages:/usr/src/messages/ labels: - "traefik.http.routers.front.rule=Host(`play.workadventure.localhost`)" - "traefik.http.routers.front.entryPoints=web,traefik" @@ -76,7 +75,6 @@ services: ALLOW_ARTILLERY: "true" volumes: - ./back:/usr/src/app - - ./messages:/usr/src/messages/ labels: - "traefik.http.routers.back.rule=Host(`api.workadventure.localhost`)" - "traefik.http.routers.back.entryPoints=web" @@ -111,3 +109,5 @@ services: STARTUP_COMMAND_2: yarn run proto:watch volumes: - ./messages:/usr/src/app + - ./back:/usr/src/back + - ./front:/usr/src/front diff --git a/front/Dockerfile b/front/Dockerfile index 98e29a52..6c79ad6e 100644 --- a/front/Dockerfile +++ b/front/Dockerfile @@ -7,7 +7,7 @@ RUN yarn install && yarn proto FROM thecodingmachine/nodejs:14-apache COPY --chown=docker:docker front . -COPY --from=builder --chown=docker:docker /var/www/messages /var/www/messages +COPY --from=builder --chown=docker:docker /var/www/messages/generated /var/www/html/src/Messages/generated RUN yarn install ENV NODE_ENV=production diff --git a/front/package.json b/front/package.json index a9c7b3f8..048c7099 100644 --- a/front/package.json +++ b/front/package.json @@ -4,6 +4,7 @@ "main": "index.js", "license": "SEE LICENSE IN LICENSE.txt", "devDependencies": { + "@types/google-protobuf": "^3.7.3", "@types/jasmine": "^3.5.10", "@typescript-eslint/eslint-plugin": "^2.26.0", "@typescript-eslint/parser": "^2.26.0", @@ -23,6 +24,7 @@ "@types/simple-peer": "^9.6.0", "@types/socket.io-client": "^1.4.32", "generic-type-guard": "^3.2.0", + "google-protobuf": "^3.13.0", "phaser": "^3.22.0", "queue-typescript": "^1.0.1", "simple-peer": "^9.6.2", diff --git a/front/src/Connection.ts b/front/src/Connection.ts index 459e58c1..0a05673a 100644 --- a/front/src/Connection.ts +++ b/front/src/Connection.ts @@ -7,7 +7,7 @@ import { SetPlayerDetailsMessage, UserMovedMessage, UserMovesMessage, ViewportMessage -} from "../../messages/generated/messages_pb" +} from "./Messages/generated/messages_pb" const SocketIo = require('socket.io-client'); import Socket = SocketIOClient.Socket; diff --git a/front/src/Messages/.gitignore b/front/src/Messages/.gitignore new file mode 100644 index 00000000..9e0adcc1 --- /dev/null +++ b/front/src/Messages/.gitignore @@ -0,0 +1 @@ +/generated/ diff --git a/front/src/Network/ProtobufClientUtils.ts b/front/src/Network/ProtobufClientUtils.ts index 6755025c..1eb5b923 100644 --- a/front/src/Network/ProtobufClientUtils.ts +++ b/front/src/Network/ProtobufClientUtils.ts @@ -1,4 +1,4 @@ -import {PositionMessage} from "../../../messages/generated/messages_pb"; +import {PositionMessage} from "../Messages/generated/messages_pb"; import {PointInterface} from "../Connection"; import Direction = PositionMessage.Direction; diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 8abddfd3..f971a1e3 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -40,7 +40,7 @@ import {FourOFourSceneName} from "../Reconnecting/FourOFourScene"; import {ItemFactoryInterface} from "../Items/ItemFactoryInterface"; import {ActionableItem} from "../Items/ActionableItem"; import {UserInputManager} from "../UserInput/UserInputManager"; -import {UserMovedMessage} from "../../../../messages/generated/messages_pb"; +import {UserMovedMessage} from "../../Messages/generated/messages_pb"; import {ProtobufClientUtils} from "../../Network/ProtobufClientUtils"; @@ -220,6 +220,7 @@ export class GameScene extends Phaser.Scene implements CenterListener { if (position === undefined) { throw new Error('Position missing from UserMovedMessage'); } + //console.log('Received position ', position.getX(), position.getY(), "from user", message.getUserid()); const messageUserMoved: MessageUserMovedInterface = { userId: message.getUserid(), @@ -1079,6 +1080,7 @@ export class GameScene extends Phaser.Scene implements CenterListener { // We do not update the player position directly (because it is sent only every 200ms). // Instead we use the PlayersPositionInterpolator that will do a smooth animation over the next 200ms. const playerMovement = new PlayerMovement({ x: player.x, y: player.y }, this.currentTick, message.position, this.currentTick + POSITION_DELAY); + //console.log('Target position: ', player.x, player.y); this.playersPositionInterpolator.updatePlayerPosition(player.userId, playerMovement); } diff --git a/front/src/Phaser/Game/PlayerMovement.ts b/front/src/Phaser/Game/PlayerMovement.ts index 1458335d..56c4f113 100644 --- a/front/src/Phaser/Game/PlayerMovement.ts +++ b/front/src/Phaser/Game/PlayerMovement.ts @@ -20,12 +20,13 @@ export class PlayerMovement { public getPosition(tick: number): HasMovedEvent { // Special case: end position reached and end position is not moving if (tick >= this.endTick && this.endPosition.moving === false) { + //console.log('Movement finished ', this.endPosition) return this.endPosition; } const x = (this.endPosition.x - this.startPosition.x) * ((tick - this.startTick) / (this.endTick - this.startTick)) + this.startPosition.x; const y = (this.endPosition.y - this.startPosition.y) * ((tick - this.startTick) / (this.endTick - this.startTick)) + this.startPosition.y; - + //console.log('Computed position ', x, y) return { x, y, diff --git a/front/yarn.lock b/front/yarn.lock index 2e7007e1..2da1afa2 100644 --- a/front/yarn.lock +++ b/front/yarn.lock @@ -66,6 +66,11 @@ "@types/minimatch" "*" "@types/node" "*" +"@types/google-protobuf@^3.7.3": + version "3.7.3" + resolved "https://registry.yarnpkg.com/@types/google-protobuf/-/google-protobuf-3.7.3.tgz#429512e541bbd777f2c867692e6335ee08d1f6d4" + integrity sha512-FRwj40euE2bYkG+0X5w2nEA8yAzgJRcEa7RBd0Gsdkb9/tPM2pctVVAvnOUTbcXo2VmIHPo0Ae94Gl9vRHfKzg== + "@types/html-minifier-terser@^5.0.0": version "5.1.0" resolved "https://registry.yarnpkg.com/@types/html-minifier-terser/-/html-minifier-terser-5.1.0.tgz#551a4589b6ee2cc9c1dff08056128aec29b94880" @@ -2237,6 +2242,11 @@ globby@^6.1.0: pify "^2.0.0" pinkie-promise "^2.0.0" +google-protobuf@^3.13.0: + version "3.13.0" + resolved "https://registry.yarnpkg.com/google-protobuf/-/google-protobuf-3.13.0.tgz#909c5983d75dd6101ed57c79e0528d000cdc3251" + integrity sha512-ZIf3qfLFayVrPvAjeKKxO5FRF1/NwRxt6Dko+fWEMuHwHbZx8/fcaAao9b0wCM6kr8qeg2te8XTpyuvKuD9aKw== + graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2: version "4.2.4" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.4.tgz#2256bde14d3632958c465ebc96dc467ca07a29fb" diff --git a/messages/package.json b/messages/package.json index 6f2bc3f1..f7c73863 100644 --- a/messages/package.json +++ b/messages/package.json @@ -5,7 +5,10 @@ "main": "generated/src/proto/messages_pb.js", "scripts": { "proto": "protoc --plugin=\"protoc-gen-ts=./node_modules/.bin/protoc-gen-ts\" --js_out=\"import_style=commonjs,binary:generated\" --ts_out=\"generated\" messages.proto", - "proto:watch": "yarn run proto || inotifywait -q -m -e close_write messages.proto | while read -r filename event; do yarn run proto; done" + "copy-to-back": "rm -rf ../back/src/Messages/generated && cp -rf generated/ ../back/src/Messages/generated", + "copy-to-front": "rm -rf ../front/src/Messages/generated && cp -rf generated/ ../front/src/Messages/generated", + "proto-all": "yarn run proto && yarn run copy-to-back && yarn run copy-to-front", + "proto:watch": "yarn run proto-all; inotifywait -q -m -e close_write messages.proto | while read -r filename event; do yarn run proto-all; done" }, "repository": { "type": "git", From 64803296d660893c6e896211f114acd2cfbc7fb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 24 Sep 2020 11:20:10 +0200 Subject: [PATCH 056/122] Fixing CI --- .github/workflows/continuous_integration.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index 95aed5a2..47b28d72 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -36,7 +36,7 @@ jobs: working-directory: "messages" - name: "Build proto messages" - run: yarn run proto + run: yarn run proto && yarn run copy-to-front working-directory: "messages" - name: "Build" @@ -81,7 +81,7 @@ jobs: working-directory: "messages" - name: "Build proto messages" - run: yarn run proto + run: yarn run proto && yarn run copy-to-back working-directory: "messages" - name: "Build" From 72806b3ca09c6d9885de9ef9949309fcea0da287 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 24 Sep 2020 11:54:00 +0200 Subject: [PATCH 057/122] Fixing messages copy --- back/Dockerfile | 2 +- back/src/Controller/IoSocketController.ts | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/back/Dockerfile b/back/Dockerfile index bd98d66a..02369b9f 100644 --- a/back/Dockerfile +++ b/back/Dockerfile @@ -6,7 +6,7 @@ RUN yarn install && yarn proto FROM thecodingmachine/nodejs:12 COPY --chown=docker:docker back . -COPY --from=builder --chown=docker:docker /var/www/messages/generated /var/www/html/src/Messages/generated +COPY --from=builder --chown=docker:docker /var/www/messages/generated /usr/src/app/src/Messages/generated RUN yarn install ENV NODE_ENV=production diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index 7e13b9d0..4e165446 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -315,6 +315,8 @@ export class IoSocketController { case Direction.RIGHT: direction = 'right'; break; + default: + throw new Error("Unexpected direction"); } const Client = (socket as ExSocketInterface); From 2dad601311a77b42ced2eb4655e5585dec773c99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 24 Sep 2020 14:50:28 +0200 Subject: [PATCH 058/122] Adding JOIN_ROOM message in protobuf --- back/src/Controller/IoSocketController.ts | 14 +++++++++++--- front/src/Connection.ts | 20 ++++++++++++++++++-- messages/messages.proto | 8 ++++++++ 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index 4e165446..3e0eeb2e 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -27,7 +27,7 @@ import { SetPlayerDetailsMessage, SubMessage, UserMovedMessage, - BatchMessage, GroupUpdateMessage, PointMessage, GroupDeleteMessage + BatchMessage, GroupUpdateMessage, PointMessage, GroupDeleteMessage, UserJoinedMessage } from "../Messages/generated/messages_pb"; import {UserMovesMessage} from "../Messages/generated/messages_pb"; import Direction = PositionMessage.Direction; @@ -541,9 +541,17 @@ export class IoSocketController { const clientListener = this.searchClientByIdOrFail(listener.id); if (thing instanceof User) { const clientUser = this.searchClientByIdOrFail(thing.id); - const messageUserJoined = new MessageUserJoined(clientUser.userId, clientUser.name, clientUser.characterLayers, clientUser.position); - clientListener.emit(SocketIoEvent.JOIN_ROOM, messageUserJoined); + const userJoinedMessage = new UserJoinedMessage(); + userJoinedMessage.setUserid(clientUser.userId); + userJoinedMessage.setName(clientUser.name); + userJoinedMessage.setCharacterlayersList(clientUser.characterLayers); + userJoinedMessage.setPosition(ProtobufUtils.toPositionMessage(clientUser.position)); + + const subMessage = new SubMessage(); + subMessage.setUserjoinedmessage(userJoinedMessage); + + emitInBatch(clientListener, SocketIoEvent.JOIN_ROOM, subMessage); } else if (thing instanceof Group) { this.emitCreateUpdateGroupEvent(clientListener, thing); } else { diff --git a/front/src/Connection.ts b/front/src/Connection.ts index 0a05673a..d64f4643 100644 --- a/front/src/Connection.ts +++ b/front/src/Connection.ts @@ -4,7 +4,7 @@ import {MessageUI} from "./Logger/MessageUI"; import { BatchMessage, GroupDeleteMessage, GroupUpdateMessage, PositionMessage, - SetPlayerDetailsMessage, UserMovedMessage, + SetPlayerDetailsMessage, UserJoinedMessage, UserMovedMessage, UserMovesMessage, ViewportMessage } from "./Messages/generated/messages_pb" @@ -15,6 +15,7 @@ import {PlayerAnimationNames} from "./Phaser/Player/Animation"; import {UserSimplePeerInterface} from "./WebRtc/SimplePeer"; import {SignalData} from "simple-peer"; import Direction = PositionMessage.Direction; +import {ProtobufClientUtils} from "./Network/ProtobufClientUtils"; enum EventMessage{ WEBRTC_SIGNAL = "webrtc-signal", @@ -166,6 +167,9 @@ export class Connection implements Connection { } else if (message.hasGroupdeletemessage()) { event = EventMessage.GROUP_DELETE; payload = message.getGroupdeletemessage(); + } else if (message.hasUserjoinedmessage()) { + event = EventMessage.JOIN_ROOM; + payload = message.getUserjoinedmessage(); } else { throw new Error('Unexpected batch message type'); } @@ -283,7 +287,19 @@ export class Connection implements Connection { } public onUserJoins(callback: (message: MessageUserJoined) => void): void { - this.socket.on(EventMessage.JOIN_ROOM, callback); + this.onBatchMessage(EventMessage.JOIN_ROOM, (message: UserJoinedMessage) => { + const position = message.getPosition(); + if (position === undefined) { + throw new Error('Invalid JOIN_ROOM message'); + } + const messageUserJoined: MessageUserJoined = { + userId: message.getUserid(), + name: message.getName(), + characterLayers: message.getCharacterlayersList(), + position: ProtobufClientUtils.toPointInterface(position) + } + callback(messageUserJoined); + }); } public onUserMoved(callback: (message: UserMovedMessage) => void): void { diff --git a/messages/messages.proto b/messages/messages.proto index 8b081fe6..50a0aa5d 100644 --- a/messages/messages.proto +++ b/messages/messages.proto @@ -52,6 +52,7 @@ message SubMessage { UserMovedMessage userMovedMessage = 1; GroupUpdateMessage groupUpdateMessage = 2; GroupDeleteMessage groupDeleteMessage = 3; + UserJoinedMessage userJoinedMessage = 4; } } @@ -68,3 +69,10 @@ message GroupUpdateMessage { message GroupDeleteMessage { int32 groupId = 1; } + +message UserJoinedMessage { + int32 userId = 1; + string name = 2; + repeated string characterLayers = 3; + PositionMessage position = 4; +} From 0c4c43f88c55e4bbd22fdbc96bc5ef73d5d0ffa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 24 Sep 2020 16:11:47 +0200 Subject: [PATCH 059/122] Adding USER_LEFT message to protobuf --- back/src/Controller/IoSocketController.ts | 16 +++++++++++++--- front/src/Connection.ts | 9 +++++++-- messages/messages.proto | 5 +++++ 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index 3e0eeb2e..9110702e 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -27,7 +27,7 @@ import { SetPlayerDetailsMessage, SubMessage, UserMovedMessage, - BatchMessage, GroupUpdateMessage, PointMessage, GroupDeleteMessage, UserJoinedMessage + BatchMessage, GroupUpdateMessage, PointMessage, GroupDeleteMessage, UserJoinedMessage, UserLeftMessage } from "../Messages/generated/messages_pb"; import {UserMovesMessage} from "../Messages/generated/messages_pb"; import Direction = PositionMessage.Direction; @@ -580,8 +580,7 @@ export class IoSocketController { const clientListener = this.searchClientByIdOrFail(listener.id); if (thing instanceof User) { const clientUser = this.searchClientByIdOrFail(thing.id); - clientListener.emit(SocketIoEvent.USER_LEFT, clientUser.userId); - //console.log("Sending USER_LEFT event"); + this.emitUserLeftEvent(clientListener, clientUser.userId); } else if (thing instanceof Group) { this.emitDeleteGroupEvent(clientListener, thing.getId()); } else { @@ -629,6 +628,17 @@ export class IoSocketController { emitInBatch(client, SocketIoEvent.GROUP_DELETE, subMessage); } + private emitUserLeftEvent(socket: Socket, userId: number): void { + const userLeftMessage = new UserLeftMessage(); + userLeftMessage.setUserid(userId); + + const subMessage = new SubMessage(); + subMessage.setUserleftmessage(userLeftMessage); + + const client : ExSocketInterface = socket as ExSocketInterface; + emitInBatch(client, SocketIoEvent.USER_LEFT, subMessage); + } + /** * * @param socket diff --git a/front/src/Connection.ts b/front/src/Connection.ts index d64f4643..faf080f0 100644 --- a/front/src/Connection.ts +++ b/front/src/Connection.ts @@ -4,7 +4,7 @@ import {MessageUI} from "./Logger/MessageUI"; import { BatchMessage, GroupDeleteMessage, GroupUpdateMessage, PositionMessage, - SetPlayerDetailsMessage, UserJoinedMessage, UserMovedMessage, + SetPlayerDetailsMessage, UserJoinedMessage, UserLeftMessage, UserMovedMessage, UserMovesMessage, ViewportMessage } from "./Messages/generated/messages_pb" @@ -170,6 +170,9 @@ export class Connection implements Connection { } else if (message.hasUserjoinedmessage()) { event = EventMessage.JOIN_ROOM; payload = message.getUserjoinedmessage(); + } else if (message.hasUserleftmessage()) { + event = EventMessage.USER_LEFT; + payload = message.getUserleftmessage(); } else { throw new Error('Unexpected batch message type'); } @@ -320,7 +323,9 @@ export class Connection implements Connection { } public onUserLeft(callback: (userId: number) => void): void { - this.socket.on(EventMessage.USER_LEFT, callback); + this.onBatchMessage(EventMessage.USER_LEFT, (message: UserLeftMessage) => { + callback(message.getUserid()); + }); } public onGroupUpdatedOrCreated(callback: (groupCreateUpdateMessage: GroupCreatedUpdatedMessageInterface) => void): void { diff --git a/messages/messages.proto b/messages/messages.proto index 50a0aa5d..01782e57 100644 --- a/messages/messages.proto +++ b/messages/messages.proto @@ -53,6 +53,7 @@ message SubMessage { GroupUpdateMessage groupUpdateMessage = 2; GroupDeleteMessage groupDeleteMessage = 3; UserJoinedMessage userJoinedMessage = 4; + UserLeftMessage userLeftMessage = 5; } } @@ -76,3 +77,7 @@ message UserJoinedMessage { repeated string characterLayers = 3; PositionMessage position = 4; } + +message UserLeftMessage { + int32 userId = 1; +} From 24a6cd7f8e86b0dbee33b97adf74213f739a3130 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 24 Sep 2020 17:24:37 +0200 Subject: [PATCH 060/122] Switched ITEM_EVENT to protobuf --- back/src/Controller/IoSocketController.ts | 36 +++++++++++++++++++---- back/src/Model/Websocket/ProtobufUtils.ts | 22 +++++++++++++- front/src/Connection.ts | 29 ++++++++++++------ messages/messages.proto | 9 ++++++ 4 files changed, 81 insertions(+), 15 deletions(-) diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index 9110702e..57e204f4 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -27,7 +27,13 @@ import { SetPlayerDetailsMessage, SubMessage, UserMovedMessage, - BatchMessage, GroupUpdateMessage, PointMessage, GroupDeleteMessage, UserJoinedMessage, UserLeftMessage + BatchMessage, + GroupUpdateMessage, + PointMessage, + GroupDeleteMessage, + UserJoinedMessage, + UserLeftMessage, + ItemEventMessage } from "../Messages/generated/messages_pb"; import {UserMovesMessage} from "../Messages/generated/messages_pb"; import Direction = PositionMessage.Direction; @@ -433,22 +439,42 @@ export class IoSocketController { } }); - socket.on(SocketIoEvent.ITEM_EVENT, (itemEvent: unknown) => { - if (!isItemEventMessageInterface(itemEvent)) { + socket.on(SocketIoEvent.ITEM_EVENT, (message: unknown) => { + if (!(message instanceof Buffer)) { + socket.emit(SocketIoEvent.MESSAGE_ERROR, {message: 'Invalid ITEM_EVENT message. Expecting binary buffer.'}); + console.warn('Invalid ITEM_EVENT message received (expecting binary buffer): ', message); + return; + } + const itemEventMessage = ItemEventMessage.deserializeBinary(new Uint8Array(message)); + + const itemEvent = ProtobufUtils.toItemEvent(itemEventMessage); + + /*if (!isItemEventMessageInterface(itemEvent)) { socket.emit(SocketIoEvent.MESSAGE_ERROR, {message: 'Invalid ITEM_EVENT message.'}); console.warn('Invalid ITEM_EVENT message received: ', itemEvent); return; - } + }*/ try { const Client = (socket as ExSocketInterface); - socket.to(Client.roomId).emit(SocketIoEvent.ITEM_EVENT, itemEvent); + //socket.to(Client.roomId).emit(SocketIoEvent.ITEM_EVENT, itemEvent); const world = this.Worlds.get(Client.roomId); if (!world) { console.error("Could not find world with id '", Client.roomId, "'"); return; } + + const subMessage = new SubMessage(); + subMessage.setItemeventmessage(itemEventMessage); + + // Let's send the event without using the SocketIO room. + for (let user of world.getUsers().values()) { + const client = this.searchClientByIdOrFail(user.id); + //client.emit(SocketIoEvent.ITEM_EVENT, itemEvent); + emitInBatch(client, SocketIoEvent.ITEM_EVENT, subMessage); + } + world.setItemState(itemEvent.itemId, itemEvent.state); } catch (e) { console.error('An error occurred on "item_event"'); diff --git a/back/src/Model/Websocket/ProtobufUtils.ts b/back/src/Model/Websocket/ProtobufUtils.ts index 4e5aec02..aa6810a4 100644 --- a/back/src/Model/Websocket/ProtobufUtils.ts +++ b/back/src/Model/Websocket/ProtobufUtils.ts @@ -1,7 +1,8 @@ import {PointInterface} from "./PointInterface"; -import {PositionMessage} from "../../Messages/generated/messages_pb"; +import {ItemEventMessage, PositionMessage} from "../../Messages/generated/messages_pb"; import {ExSocketInterface} from "_Model/Websocket/ExSocketInterface"; import Direction = PositionMessage.Direction; +import {ItemEventMessageInterface} from "_Model/Websocket/ItemEventMessage"; export class ProtobufUtils { @@ -32,4 +33,23 @@ export class ProtobufUtils { return position; } + + public static toItemEvent(itemEventMessage: ItemEventMessage): ItemEventMessageInterface { + return { + itemId: itemEventMessage.getItemid(), + event: itemEventMessage.getEvent(), + parameters: JSON.parse(itemEventMessage.getParametersjson()), + state: JSON.parse(itemEventMessage.getStatejson()), + } + } + + public static toItemEventProtobuf(itemEvent: ItemEventMessageInterface): ItemEventMessage { + const itemEventMessage = new ItemEventMessage(); + itemEventMessage.setItemid(itemEvent.itemId); + itemEventMessage.setEvent(itemEvent.event); + itemEventMessage.setParametersjson(JSON.stringify(itemEvent.parameters)); + itemEventMessage.setStatejson(JSON.stringify(itemEvent.state)); + + return itemEventMessage; + } } diff --git a/front/src/Connection.ts b/front/src/Connection.ts index faf080f0..8201b5af 100644 --- a/front/src/Connection.ts +++ b/front/src/Connection.ts @@ -2,7 +2,7 @@ import Axios from "axios"; import {API_URL} from "./Enum/EnvironmentVariable"; import {MessageUI} from "./Logger/MessageUI"; import { - BatchMessage, GroupDeleteMessage, GroupUpdateMessage, + BatchMessage, GroupDeleteMessage, GroupUpdateMessage, ItemEventMessage, PositionMessage, SetPlayerDetailsMessage, UserJoinedMessage, UserLeftMessage, UserMovedMessage, UserMovesMessage, @@ -173,6 +173,9 @@ export class Connection implements Connection { } else if (message.hasUserleftmessage()) { event = EventMessage.USER_LEFT; payload = message.getUserleftmessage(); + } else if (message.hasItemeventmessage()) { + event = EventMessage.ITEM_EVENT; + payload = message.getItemeventmessage(); } else { throw new Error('Unexpected batch message type'); } @@ -400,16 +403,24 @@ export class Connection implements Connection { this.socket.on(EventMessage.WEBRTC_DISCONNECT, callback); } - emitActionableEvent(itemId: number, event: string, state: unknown, parameters: unknown) { - return this.socket.emit(EventMessage.ITEM_EVENT, { - itemId, - event, - state, - parameters - }); + emitActionableEvent(itemId: number, event: string, state: unknown, parameters: unknown): void { + const itemEventMessage = new ItemEventMessage(); + itemEventMessage.setItemid(itemId); + itemEventMessage.setEvent(event); + itemEventMessage.setStatejson(JSON.stringify(state)); + itemEventMessage.setParametersjson(JSON.stringify(parameters)); + + this.socket.emit(EventMessage.ITEM_EVENT, itemEventMessage.serializeBinary().buffer); } onActionableEvent(callback: (message: ItemEventMessageInterface) => void): void { - this.socket.on(EventMessage.ITEM_EVENT, callback); + this.onBatchMessage(EventMessage.ITEM_EVENT, (message: ItemEventMessage) => { + callback({ + itemId: message.getItemid(), + event: message.getEvent(), + parameters: JSON.parse(message.getParametersjson()), + state: JSON.parse(message.getStatejson()) + }); + }); } } diff --git a/messages/messages.proto b/messages/messages.proto index 01782e57..57b1f2ea 100644 --- a/messages/messages.proto +++ b/messages/messages.proto @@ -39,6 +39,14 @@ message UserMovesMessage { ViewportMessage viewport = 2; } +/************ BI-DIRECTIONAL MESSAGES **************/ + +message ItemEventMessage { + int32 itemId = 1; + string event = 2; + string stateJson = 3; + string parametersJson = 4; +} /*********** SERVER TO CLIENT MESSAGES *************/ @@ -54,6 +62,7 @@ message SubMessage { GroupDeleteMessage groupDeleteMessage = 3; UserJoinedMessage userJoinedMessage = 4; UserLeftMessage userLeftMessage = 5; + ItemEventMessage itemEventMessage = 6; } } From ac80850335be06bd3fa0b391320a410fb46740db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 24 Sep 2020 17:36:10 +0200 Subject: [PATCH 061/122] Switching SetViewport to protobuf --- back/src/Controller/IoSocketController.ts | 15 ++++++++------- front/src/Connection.ts | 8 +++++++- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index 57e204f4..e7305d15 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -19,7 +19,6 @@ import {isWebRtcSignalMessageInterface} from "../Model/Websocket/WebRtcSignalMes import {UserInGroupInterface} from "../Model/Websocket/UserInGroupInterface"; import {isItemEventMessageInterface} from "../Model/Websocket/ItemEventMessage"; import {uuid} from 'uuidv4'; -import {isViewport} from "../Model/Websocket/ViewportMessage"; import {GroupUpdateInterface} from "_Model/Websocket/GroupUpdateInterface"; import {Movable} from "../Model/Movable"; import { @@ -33,7 +32,7 @@ import { GroupDeleteMessage, UserJoinedMessage, UserLeftMessage, - ItemEventMessage + ItemEventMessage, ViewportMessage } from "../Messages/generated/messages_pb"; import {UserMovesMessage} from "../Messages/generated/messages_pb"; import Direction = PositionMessage.Direction; @@ -264,15 +263,17 @@ export class IoSocketController { socket.on(SocketIoEvent.SET_VIEWPORT, (message: unknown): void => { try { - //console.log('SET_VIEWPORT') - if (!isViewport(message)) { - socket.emit(SocketIoEvent.MESSAGE_ERROR, {message: 'Invalid SET_VIEWPORT message.'}); - console.warn('Invalid SET_VIEWPORT message received: ', message); + if (!(message instanceof Buffer)) { + socket.emit(SocketIoEvent.MESSAGE_ERROR, {message: 'Invalid SET_VIEWPORT message. Expecting binary buffer.'}); + console.warn('Invalid SET_VIEWPORT message received (expecting binary buffer): ', message); return; } + const viewportMessage = ViewportMessage.deserializeBinary(new Uint8Array(message as ArrayBuffer)); + const viewport = viewportMessage.toObject(); + const Client = (socket as ExSocketInterface); - Client.viewport = message; + Client.viewport = viewport; const world = this.Worlds.get(Client.roomId); if (!world) { diff --git a/front/src/Connection.ts b/front/src/Connection.ts index 8201b5af..61b0c4e7 100644 --- a/front/src/Connection.ts +++ b/front/src/Connection.ts @@ -289,7 +289,13 @@ export class Connection implements Connection { } public setViewport(viewport: ViewportInterface): void { - this.socket.emit(EventMessage.SET_VIEWPORT, viewport); + const viewportMessage = new ViewportMessage(); + viewportMessage.setTop(Math.round(viewport.top)); + viewportMessage.setBottom(Math.round(viewport.bottom)); + viewportMessage.setLeft(Math.round(viewport.left)); + viewportMessage.setRight(Math.round(viewport.right)); + + this.socket.emit(EventMessage.SET_VIEWPORT, viewportMessage.serializeBinary().buffer); } public onUserJoins(callback: (message: MessageUserJoined) => void): void { From 953912b8924769abb8b06a8e1b7c9e40cc378569 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 24 Sep 2020 17:52:12 +0200 Subject: [PATCH 062/122] Fix style --- back/src/Controller/IoSocketController.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index e7305d15..ca83a79e 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -470,7 +470,7 @@ export class IoSocketController { subMessage.setItemeventmessage(itemEventMessage); // Let's send the event without using the SocketIO room. - for (let user of world.getUsers().values()) { + for (const user of world.getUsers().values()) { const client = this.searchClientByIdOrFail(user.id); //client.emit(SocketIoEvent.ITEM_EVENT, itemEvent); emitInBatch(client, SocketIoEvent.ITEM_EVENT, subMessage); From 892d1555b8c191cf8c064a255bf1e08e3e8db9d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Fri, 25 Sep 2020 13:48:02 +0200 Subject: [PATCH 063/122] Adding "dump" controller and fixing issue with groups in PositionNotifier by delegating the PositionNotifier.updatePosition call to groups themselves --- .env.template | 4 +- back/package.json | 2 + back/src/App.ts | 2 + back/src/Controller/DebugController.ts | 58 +++++++++++++++++++++++ back/src/Controller/IoSocketController.ts | 4 ++ back/src/Model/Group.ts | 21 ++++++-- back/src/Model/PositionNotifier.ts | 2 +- back/src/Model/World.ts | 14 ++++-- back/src/Model/Zone.ts | 27 ++++++++--- back/yarn.lock | 10 ++++ docker-compose.yaml | 1 + 11 files changed, 127 insertions(+), 18 deletions(-) create mode 100644 back/src/Controller/DebugController.ts diff --git a/.env.template b/.env.template index 81044e99..d355ab67 100644 --- a/.env.template +++ b/.env.template @@ -1 +1,3 @@ -DEBUG_MODE=false \ No newline at end of file +DEBUG_MODE=false +JITSI_URL=meet.jit.si +ADMIN_API_TOKEN=123 diff --git a/back/package.json b/back/package.json index 6ad2842f..b1159144 100644 --- a/back/package.json +++ b/back/package.json @@ -38,6 +38,7 @@ "dependencies": { "axios": "^0.20.0", "body-parser": "^1.19.0", + "circular-json": "^0.5.9", "express": "^4.17.1", "generic-type-guard": "^3.2.0", "google-protobuf": "^3.13.0", @@ -51,6 +52,7 @@ "uuidv4": "^6.0.7" }, "devDependencies": { + "@types/circular-json": "^0.4.0", "@types/express": "^4.17.4", "@types/google-protobuf": "^3.7.3", "@types/http-status-codes": "^1.2.0", diff --git a/back/src/App.ts b/back/src/App.ts index d1f7392f..ac681ba3 100644 --- a/back/src/App.ts +++ b/back/src/App.ts @@ -8,6 +8,7 @@ import * as http from "http"; import {MapController} from "./Controller/MapController"; import {PrometheusController} from "./Controller/PrometheusController"; import {AdminController} from "./Controller/AdminController"; +import {DebugController} from "./Controller/DebugController"; class App { public app: Application; @@ -35,6 +36,7 @@ class App { this.mapController = new MapController(this.app); this.prometheusController = new PrometheusController(this.app, this.ioSocketController); this.adminController = new AdminController(this.app); + this.debugController = new DebugController(this.app, this.ioSocketController); } // TODO add session user diff --git a/back/src/Controller/DebugController.ts b/back/src/Controller/DebugController.ts new file mode 100644 index 00000000..ebc4894b --- /dev/null +++ b/back/src/Controller/DebugController.ts @@ -0,0 +1,58 @@ +import {Application, Request, Response} from "express"; +import {OK} from "http-status-codes"; +import {ADMIN_API_TOKEN, ADMIN_API_URL} from "../Enum/EnvironmentVariable"; +import Axios from "axios"; +import {DEBUG_MODE} from "../../../front/src/Enum/EnvironmentVariable"; +import {IoSocketController} from "_Controller/IoSocketController"; +import Flatted from "flatted"; +import {stringify} from "circular-json"; + +export class DebugController { + constructor(private App : Application, private ioSocketController: IoSocketController) { + this.getDump(); + } + + + getDump(){ + this.App.get("/dump", async (req: Request, res: Response) => { + if (req.query.token !== ADMIN_API_TOKEN) { + return res.status(401).send('Invalid token sent!'); + } + +/* const obj: any = {}; + + for (const [worldName, world] of this.ioSocketController.getWorlds().entries()) { + let users = new Array(); + for (const [worldName, world] of this.ioSocketController.getWorlds().entries()) { + + } + + + obj[worldName] = { + users: world.getUsers() + }; + }*/ + + return res.status(OK).contentType('application/json').send(stringify( + this.ioSocketController.getWorlds(), + (key: any, value: any) => { + if(value instanceof Map) { + const obj: any = {}; + for (const [mapKey, mapValue] of value.entries()) { + obj[mapKey] = mapValue; + } + return obj; + } else if(value instanceof Set) { + const obj: Array = []; + for (const [setKey, setValue] of value.entries()) { + obj.push(setValue); + } + return obj; + } else { + return value; + } + } + )); + }); + } +} diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index ca83a79e..7111e7d2 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -757,4 +757,8 @@ export class IoSocketController { Client.leave(Client.webRtcRoomId); delete Client.webRtcRoomId; } + + public getWorlds(): Map { + return this.Worlds; + } } diff --git a/back/src/Model/Group.ts b/back/src/Model/Group.ts index 4364455d..d08e6d90 100644 --- a/back/src/Model/Group.ts +++ b/back/src/Model/Group.ts @@ -3,6 +3,7 @@ import { User } from "./User"; import {PositionInterface} from "_Model/PositionInterface"; import {uuid} from "uuidv4"; import {Movable} from "_Model/Movable"; +import {PositionNotifier} from "_Model/PositionNotifier"; export class Group implements Movable { static readonly MAX_PER_GROUP = 4; @@ -11,16 +12,12 @@ export class Group implements Movable { private id: number; private users: Set; - private connectCallback: ConnectCallback; - private disconnectCallback: DisconnectCallback; private x!: number; private y!: number; - constructor(users: User[], connectCallback: ConnectCallback, disconnectCallback: DisconnectCallback) { + constructor(users: User[], private connectCallback: ConnectCallback, private disconnectCallback: DisconnectCallback, private positionNotifier: PositionNotifier) { this.users = new Set(); - this.connectCallback = connectCallback; - this.disconnectCallback = disconnectCallback; this.id = Group.nextId; Group.nextId++; @@ -53,6 +50,9 @@ export class Group implements Movable { * Computes the barycenter of all users (i.e. the center of the group) */ updatePosition(): void { + const oldX = this.x; + const oldY = this.y; + let x = 0; let y = 0; // Let's compute the barycenter of all users. @@ -67,6 +67,13 @@ export class Group implements Movable { } this.x = x; this.y = y; + + if (oldX === undefined) { + // TODO: do we need a "create" + this.positionNotifier.updatePosition(this, {x, y}, {x, y}); + } else { + this.positionNotifier.updatePosition(this, {x, y}, {x: oldX, y: oldY}); + } } isFull(): boolean { @@ -93,6 +100,10 @@ export class Group implements Movable { } user.group = undefined; + if (this.users.size !== 0) { + this.updatePosition(); + } + // Broadcast on the right event this.disconnectCallback(user.id, this); } diff --git a/back/src/Model/PositionNotifier.ts b/back/src/Model/PositionNotifier.ts index 0e5b4b2f..0c30fe30 100644 --- a/back/src/Model/PositionNotifier.ts +++ b/back/src/Model/PositionNotifier.ts @@ -117,7 +117,7 @@ export class PositionNotifier { let zone = this.zones[j][i]; if (zone === undefined) { - zone = new Zone(this.onUserEnters, this.onUserMoves, this.onUserLeaves); + zone = new Zone(this.onUserEnters, this.onUserMoves, this.onUserLeaves, i, j); this.zones[j][i] = zone; } return zone; diff --git a/back/src/Model/World.ts b/back/src/Model/World.ts index 321b3e1b..bbc472a0 100644 --- a/back/src/Model/World.ts +++ b/back/src/Model/World.ts @@ -93,6 +93,10 @@ export class World { user.position = userPosition; user.group?.updatePosition(); + /*if (user.group !== undefined) { + // TODO: positionNotifier should be notified by the group itself when it moves!!! + this.positionNotifier.updatePosition(user.group, user.group.getPosition(), oldGroupPosition ? oldGroupPosition : user.group.getPosition()); + }*/ if (user.silent) { return; @@ -112,7 +116,7 @@ export class World { const group: Group = new Group([ user, closestUser - ], this.connectCallback, this.disconnectCallback); + ], this.connectCallback, this.disconnectCallback, this.positionNotifier); this.groups.add(group); } } @@ -127,9 +131,9 @@ export class World { } // At the very end, if the user is part of a group, let's call the callback to update group position - if (user.group !== undefined) { + /*if (user.group !== undefined) { this.positionNotifier.updatePosition(user.group, user.group.getPosition(), oldGroupPosition ? oldGroupPosition : user.group.getPosition()); - } + }*/ } setSilent(socket: Identificable, silent: boolean) { @@ -162,6 +166,7 @@ export class World { if (group === undefined) { throw new Error("The user is part of no group"); } + const oldPosition = group.getPosition(); group.leave(user); if (group.isEmpty()) { this.positionNotifier.leave(group); @@ -171,7 +176,8 @@ export class World { } this.groups.delete(group); } else { - this.positionNotifier.updatePosition(group, group.getPosition(), group.getPosition()); + group.updatePosition(); + //this.positionNotifier.updatePosition(group, group.getPosition(), oldPosition); } } diff --git a/back/src/Model/Zone.ts b/back/src/Model/Zone.ts index 9933637c..36551b39 100644 --- a/back/src/Model/Zone.ts +++ b/back/src/Model/Zone.ts @@ -1,6 +1,7 @@ import {User} from "./User"; import {PositionInterface} from "_Model/PositionInterface"; -import {Movable} from "_Model/Movable"; +import {Movable} from "./Movable"; +import {Group} from "./Group"; export type EntersCallback = (thing: Movable, listener: User) => void; export type MovesCallback = (thing: Movable, position: PositionInterface, listener: User) => void; @@ -10,14 +11,27 @@ export class Zone { private things: Set = new Set(); private listeners: Set = new Set(); - constructor(private onEnters: EntersCallback, private onMoves: MovesCallback, private onLeaves: LeavesCallback) { + /** + * @param x For debugging purpose only + * @param y For debugging purpose only + */ + constructor(private onEnters: EntersCallback, private onMoves: MovesCallback, private onLeaves: LeavesCallback, private x: number, private y: number) { } /** * A user/thing leaves the zone */ public leave(thing: Movable, newZone: Zone|null) { - this.things.delete(thing); + const result = this.things.delete(thing); + if (!result) { + if (thing instanceof User) { + console.error('Could not find user in zone '+thing.id); + } + if (thing instanceof Group) { + console.error('Could not find group '+thing.getId()+' in zone ('+this.x+','+this.y+'). Position of group: ('+thing.getPosition().x+','+thing.getPosition().y+')'); + } + + } this.notifyLeft(thing, newZone); } @@ -34,13 +48,13 @@ export class Zone { public enter(thing: Movable, oldZone: Zone|null, position: PositionInterface) { this.things.add(thing); - this.notifyUserEnter(thing, oldZone, position); + this.notifyEnter(thing, oldZone, position); } /** * Notify listeners of this zone that this user entered */ - private notifyUserEnter(thing: Movable, oldZone: Zone|null, position: PositionInterface) { + private notifyEnter(thing: Movable, oldZone: Zone|null, position: PositionInterface) { for (const listener of this.listeners) { if (listener === thing) { continue; @@ -56,8 +70,7 @@ export class Zone { public move(thing: Movable, position: PositionInterface) { if (!this.things.has(thing)) { this.things.add(thing); - const foo = this.things; - this.notifyUserEnter(thing, null, position); + this.notifyEnter(thing, null, position); return; } diff --git a/back/yarn.lock b/back/yarn.lock index cb25dc86..3731547d 100644 --- a/back/yarn.lock +++ b/back/yarn.lock @@ -27,6 +27,11 @@ "@types/connect" "*" "@types/node" "*" +"@types/circular-json@^0.4.0": + version "0.4.0" + resolved "https://registry.yarnpkg.com/@types/circular-json/-/circular-json-0.4.0.tgz#7401f7e218cfe87ad4c43690da5658b9acaf51be" + integrity sha512-7+kYB7x5a7nFWW1YPBh3KxhwKfiaI4PbZ1RvzBU91LZy7lWJO822CI+pqzSre/DZ7KsCuMKdHnLHHFu8AyXbQg== + "@types/color-name@^1.1.1": version "1.1.1" resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0" @@ -359,6 +364,11 @@ chardet@^0.7.0: version "0.7.0" resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e" +circular-json@^0.5.9: + version "0.5.9" + resolved "https://registry.yarnpkg.com/circular-json/-/circular-json-0.5.9.tgz#932763ae88f4f7dead7a0d09c8a51a4743a53b1d" + integrity sha512-4ivwqHpIFJZBuhN3g/pEcdbnGUywkBblloGbkglyloVjjR3uT6tieI89MVOfbP2tHX5sgb01FuLgAOzebNlJNQ== + cli-cursor@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-3.1.0.tgz#264305a7ae490d1d03bf0c9ba7c925d1753af307" diff --git a/docker-compose.yaml b/docker-compose.yaml index a37fe28f..ffc846e4 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -73,6 +73,7 @@ services: STARTUP_COMMAND_1: yarn install SECRET_KEY: yourSecretKey ALLOW_ARTILLERY: "true" + ADMIN_API_TOKEN: "$ADMIN_API_TOKEN" volumes: - ./back:/usr/src/app labels: From 23cea1c8357aaef5b1222dd637db92727b70a00e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Fri, 25 Sep 2020 15:25:06 +0200 Subject: [PATCH 064/122] Migrating position notification into the User class --- back/src/App.ts | 1 + back/src/Model/Group.ts | 8 +++--- back/src/Model/PositionNotifier.ts | 7 +++++ back/src/Model/User.ts | 15 ++++++++-- back/src/Model/World.ts | 32 ++++++++++------------ back/src/Model/Zone.ts | 4 +-- back/tests/PositionNotifierTest.ts | 44 +++++++++++++----------------- 7 files changed, 59 insertions(+), 52 deletions(-) diff --git a/back/src/App.ts b/back/src/App.ts index ac681ba3..a2aa91a5 100644 --- a/back/src/App.ts +++ b/back/src/App.ts @@ -18,6 +18,7 @@ class App { public mapController: MapController; public prometheusController: PrometheusController; private adminController: AdminController; + private debugController: DebugController; constructor() { this.app = express(); diff --git a/back/src/Model/Group.ts b/back/src/Model/Group.ts index d08e6d90..f2e5feb1 100644 --- a/back/src/Model/Group.ts +++ b/back/src/Model/Group.ts @@ -57,8 +57,9 @@ export class Group implements Movable { let y = 0; // Let's compute the barycenter of all users. this.users.forEach((user: User) => { - x += user.position.x; - y += user.position.y; + const position = user.getPosition(); + x += position.x; + y += position.y; }); x /= this.users.size; y /= this.users.size; @@ -69,8 +70,7 @@ export class Group implements Movable { this.y = y; if (oldX === undefined) { - // TODO: do we need a "create" - this.positionNotifier.updatePosition(this, {x, y}, {x, y}); + this.positionNotifier.enter(this); } else { this.positionNotifier.updatePosition(this, {x, y}, {x: oldX, y: oldY}); } diff --git a/back/src/Model/PositionNotifier.ts b/back/src/Model/PositionNotifier.ts index 0c30fe30..215d6ee6 100644 --- a/back/src/Model/PositionNotifier.ts +++ b/back/src/Model/PositionNotifier.ts @@ -74,6 +74,13 @@ export class PositionNotifier { return things; } + public enter(thing: Movable): void { + const position = thing.getPosition(); + const zoneDesc = this.getZoneDescriptorFromCoordinates(position.x, position.y); + const zone = this.getZone(zoneDesc.i, zoneDesc.j); + zone.enter(thing, null, position); + } + public updatePosition(thing: Movable, newPosition: PositionInterface, oldPosition: PositionInterface): void { // Did we change zone? const oldZoneDesc = this.getZoneDescriptorFromCoordinates(oldPosition.x, oldPosition.y); diff --git a/back/src/Model/User.ts b/back/src/Model/User.ts index b147e4be..2396c4d8 100644 --- a/back/src/Model/User.ts +++ b/back/src/Model/User.ts @@ -3,6 +3,7 @@ import { PointInterface } from "./Websocket/PointInterface"; import {Zone} from "_Model/Zone"; import {Movable} from "_Model/Movable"; import {PositionInterface} from "_Model/PositionInterface"; +import {PositionNotifier} from "_Model/PositionNotifier"; export class User implements Movable { public listenedZones: Set; @@ -10,14 +11,22 @@ export class User implements Movable { public constructor( public id: number, - public position: PointInterface, + private position: PointInterface, public silent: boolean, - + private positionNotifier: PositionNotifier ) { this.listenedZones = new Set(); + + this.positionNotifier.enter(this); } - public getPosition(): PositionInterface { + public getPosition(): PointInterface { return this.position; } + + public setPosition(position: PointInterface): void { + const oldPosition = this.position; + this.position = position; + this.positionNotifier.updatePosition(this, position, oldPosition); + } } diff --git a/back/src/Model/World.ts b/back/src/Model/World.ts index bbc472a0..75ac1bdc 100644 --- a/back/src/Model/World.ts +++ b/back/src/Model/World.ts @@ -56,9 +56,11 @@ export class World { } public join(socket : Identificable, userPosition: PointInterface): void { - this.users.set(socket.userId, new User(socket.userId, userPosition, false)); + const user = new User(socket.userId, userPosition, false, this.positionNotifier); + this.users.set(socket.userId, user); // Let's call update position to trigger the join / leave room - this.updatePosition(socket, userPosition); + //this.updatePosition(socket, userPosition); + this.updateUserGroup(user); } public leave(user : Identificable){ @@ -87,16 +89,13 @@ export class World { return; } - this.positionNotifier.updatePosition(user, userPosition, user.position); + user.setPosition(userPosition); - const oldGroupPosition = user.group?.getPosition(); + this.updateUserGroup(user); + } - user.position = userPosition; + private updateUserGroup(user: User): void { user.group?.updatePosition(); - /*if (user.group !== undefined) { - // TODO: positionNotifier should be notified by the group itself when it moves!!! - this.positionNotifier.updatePosition(user.group, user.group.getPosition(), oldGroupPosition ? oldGroupPosition : user.group.getPosition()); - }*/ if (user.silent) { return; @@ -124,16 +123,11 @@ export class World { } else { // If the user is part of a group: // should he leave the group? - const distance = World.computeDistanceBetweenPositions(user.position, user.group.getPosition()); + const distance = World.computeDistanceBetweenPositions(user.getPosition(), user.group.getPosition()); if (distance > this.groupRadius) { this.leaveGroup(user); } } - - // At the very end, if the user is part of a group, let's call the callback to update group position - /*if (user.group !== undefined) { - this.positionNotifier.updatePosition(user.group, user.group.getPosition(), oldGroupPosition ? oldGroupPosition : user.group.getPosition()); - }*/ } setSilent(socket: Identificable, silent: boolean) { @@ -152,7 +146,7 @@ export class World { } if (!silent) { // If we are back to life, let's trigger a position update to see if we can join some group. - this.updatePosition(socket, user.position); + this.updatePosition(socket, user.getPosition()); } } @@ -251,7 +245,7 @@ export class World { if (group.isFull()) { return; } - const distance = World.computeDistanceBetweenPositions(user.position, group.getPosition()); + const distance = World.computeDistanceBetweenPositions(user.getPosition(), group.getPosition()); if(distance <= minimumDistanceFound && distance <= this.groupRadius) { minimumDistanceFound = distance; matchingItem = group; @@ -263,7 +257,9 @@ export class World { public static computeDistance(user1: User, user2: User): number { - return Math.sqrt(Math.pow(user2.position.x - user1.position.x, 2) + Math.pow(user2.position.y - user1.position.y, 2)); + const user1Position = user1.getPosition(); + const user2Position = user2.getPosition(); + return Math.sqrt(Math.pow(user2Position.x - user1Position.x, 2) + Math.pow(user2Position.y - user1Position.y, 2)); } public static computeDistanceBetweenPositions(position1: PositionInterface, position2: PositionInterface): number diff --git a/back/src/Model/Zone.ts b/back/src/Model/Zone.ts index 36551b39..4266c892 100644 --- a/back/src/Model/Zone.ts +++ b/back/src/Model/Zone.ts @@ -25,10 +25,10 @@ export class Zone { const result = this.things.delete(thing); if (!result) { if (thing instanceof User) { - console.error('Could not find user in zone '+thing.id); + throw new Error('Could not find user in zone '+thing.id); } if (thing instanceof Group) { - console.error('Could not find group '+thing.getId()+' in zone ('+this.x+','+this.y+'). Position of group: ('+thing.getPosition().x+','+thing.getPosition().y+')'); + throw new Error('Could not find group '+thing.getId()+' in zone ('+this.x+','+this.y+'). Position of group: ('+thing.getPosition().x+','+thing.getPosition().y+')'); } } diff --git a/back/tests/PositionNotifierTest.ts b/back/tests/PositionNotifierTest.ts index 643dd938..e65d025d 100644 --- a/back/tests/PositionNotifierTest.ts +++ b/back/tests/PositionNotifierTest.ts @@ -9,14 +9,6 @@ import {Zone} from "_Model/Zone"; import {Movable} from "_Model/Movable"; import {PositionInterface} from "_Model/PositionInterface"; -function move(user: User, x: number, y: number, positionNotifier: PositionNotifier): void { - positionNotifier.updatePosition(user, { - x, - y - }, user.position); - user.position.x = x; - user.position.y = y; -} describe("PositionNotifier", () => { it("should receive notifications when player moves", () => { @@ -37,14 +29,14 @@ describe("PositionNotifier", () => { y: 500, moving: false, direction: 'down' - }, false); + }, false, positionNotifier); const user2 = new User(2, { x: -9999, y: -9999, moving: false, direction: 'down' - }, false); + }, false, positionNotifier); positionNotifier.setViewport(user1, { left: 200, @@ -53,21 +45,21 @@ describe("PositionNotifier", () => { bottom: 500 }); - move(user2, 500, 500, positionNotifier); + user2.setPosition({x: 500, y: 500, direction: 'down', moving: false}); expect(enterTriggered).toBe(true); expect(moveTriggered).toBe(false); enterTriggered = false; // Move inside the zone - move(user2, 501, 500, positionNotifier); + user2.setPosition({x:501, y:500, direction: 'down', moving: false}); expect(enterTriggered).toBe(false); expect(moveTriggered).toBe(true); moveTriggered = false; // Move out of the zone in a zone that we don't track - move(user2, 901, 500, positionNotifier); + user2.setPosition({x: 901, y: 500, direction: 'down', moving: false}); expect(enterTriggered).toBe(false); expect(moveTriggered).toBe(false); @@ -75,14 +67,14 @@ describe("PositionNotifier", () => { leaveTriggered = false; // Move back in - move(user2, 500, 500, positionNotifier); + user2.setPosition({x: 500, y: 500, direction: 'down', moving: false}); expect(enterTriggered).toBe(true); expect(moveTriggered).toBe(false); expect(leaveTriggered).toBe(false); enterTriggered = false; // Move out of the zone in a zone that we do track - move(user2, 200, 500, positionNotifier); + user2.setPosition({x: 200, y: 500, direction: 'down', moving: false}); expect(enterTriggered).toBe(false); expect(moveTriggered).toBe(true); expect(leaveTriggered).toBe(false); @@ -115,14 +107,14 @@ describe("PositionNotifier", () => { y: 500, moving: false, direction: 'down' - }, false); + }, false, positionNotifier); const user2 = new User(2, { - x: -9999, - y: -9999, + x: 0, + y: 0, moving: false, direction: 'down' - }, false); + }, false, positionNotifier); let newUsers = positionNotifier.setViewport(user1, { left: 200, @@ -131,14 +123,16 @@ describe("PositionNotifier", () => { bottom: 500 }); - expect(newUsers.length).toBe(0); - - move(user2, 500, 500, positionNotifier); - + expect(newUsers.length).toBe(2); expect(enterTriggered).toBe(true); - expect(moveTriggered).toBe(false); enterTriggered = false; + user2.setPosition({x: 500, y: 500, direction: 'down', moving: false}); + + expect(enterTriggered).toBe(false); + expect(moveTriggered).toBe(true); + moveTriggered = false; + // Move the viewport but the user stays inside. positionNotifier.setViewport(user1, { left: 201, @@ -176,6 +170,6 @@ describe("PositionNotifier", () => { expect(moveTriggered).toBe(false); expect(leaveTriggered).toBe(false); enterTriggered = false; - expect(newUsers.length).toBe(1); + expect(newUsers.length).toBe(2); }); }) From 48469e3de3102e6bbbda421061a66e3ab050e7e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Fri, 25 Sep 2020 15:42:05 +0200 Subject: [PATCH 065/122] Fixing linting --- back/src/Controller/DebugController.ts | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/back/src/Controller/DebugController.ts b/back/src/Controller/DebugController.ts index ebc4894b..1ef3e9c8 100644 --- a/back/src/Controller/DebugController.ts +++ b/back/src/Controller/DebugController.ts @@ -14,36 +14,22 @@ export class DebugController { getDump(){ - this.App.get("/dump", async (req: Request, res: Response) => { + this.App.get("/dump", (req: Request, res: Response) => { if (req.query.token !== ADMIN_API_TOKEN) { return res.status(401).send('Invalid token sent!'); } -/* const obj: any = {}; - - for (const [worldName, world] of this.ioSocketController.getWorlds().entries()) { - let users = new Array(); - for (const [worldName, world] of this.ioSocketController.getWorlds().entries()) { - - } - - - obj[worldName] = { - users: world.getUsers() - }; - }*/ - return res.status(OK).contentType('application/json').send(stringify( this.ioSocketController.getWorlds(), - (key: any, value: any) => { + (key: unknown, value: unknown) => { if(value instanceof Map) { - const obj: any = {}; + const obj: any = {}; // eslint-disable-line @typescript-eslint/no-explicit-any for (const [mapKey, mapValue] of value.entries()) { obj[mapKey] = mapValue; } return obj; } else if(value instanceof Set) { - const obj: Array = []; + const obj: Array = []; for (const [setKey, setValue] of value.entries()) { obj.push(setValue); } From dd4d5db54fb2506c286d82e2a648e08b8978967c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Fri, 25 Sep 2020 15:42:55 +0200 Subject: [PATCH 066/122] Fixing build --- back/src/Controller/DebugController.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/back/src/Controller/DebugController.ts b/back/src/Controller/DebugController.ts index 1ef3e9c8..54544f6c 100644 --- a/back/src/Controller/DebugController.ts +++ b/back/src/Controller/DebugController.ts @@ -1,10 +1,7 @@ import {Application, Request, Response} from "express"; import {OK} from "http-status-codes"; -import {ADMIN_API_TOKEN, ADMIN_API_URL} from "../Enum/EnvironmentVariable"; -import Axios from "axios"; -import {DEBUG_MODE} from "../../../front/src/Enum/EnvironmentVariable"; +import {ADMIN_API_TOKEN} from "../Enum/EnvironmentVariable"; import {IoSocketController} from "_Controller/IoSocketController"; -import Flatted from "flatted"; import {stringify} from "circular-json"; export class DebugController { From af4611ed292093e01e9a118226eefd175ff36c78 Mon Sep 17 00:00:00 2001 From: arp Date: Fri, 25 Sep 2020 18:29:22 +0200 Subject: [PATCH 067/122] rewrote the login workflow --- back/src/Controller/AdminController.ts | 36 ---- back/src/Controller/AuthenticateController.ts | 65 +++++-- benchmark/index.ts | 4 +- front/src/Connexion/ConnectionManager.ts | 53 ++++++ front/src/Connexion/ConnexionModels.ts | 117 ++++++++++++ .../RoomConnection.ts} | 178 +++--------------- front/src/Network/ProtobufClientUtils.ts | 2 +- front/src/Phaser/Entity/RemotePlayer.ts | 2 +- front/src/Phaser/Game/AddPlayerInterface.ts | 2 +- front/src/Phaser/Game/GameManager.ts | 27 ++- front/src/Phaser/Game/GameScene.ts | 15 +- front/src/Phaser/Game/PlayerMovement.ts | 2 +- front/src/Phaser/Login/EnableCameraScene.ts | 7 +- .../src/Phaser/Login/SelectCharacterScene.ts | 2 - front/src/Phaser/Player/Player.ts | 6 +- front/src/WebRtc/ScreenSharingPeer.ts | 4 +- front/src/WebRtc/SimplePeer.ts | 8 +- front/src/WebRtc/VideoPeer.ts | 4 +- front/src/index.ts | 5 +- front/src/register.ts | 29 --- 20 files changed, 290 insertions(+), 278 deletions(-) delete mode 100644 back/src/Controller/AdminController.ts create mode 100644 front/src/Connexion/ConnectionManager.ts create mode 100644 front/src/Connexion/ConnexionModels.ts rename front/src/{Connection.ts => Connexion/RoomConnection.ts} (69%) delete mode 100644 front/src/register.ts diff --git a/back/src/Controller/AdminController.ts b/back/src/Controller/AdminController.ts deleted file mode 100644 index c4905a8a..00000000 --- a/back/src/Controller/AdminController.ts +++ /dev/null @@ -1,36 +0,0 @@ -import {Application, Request, Response} from "express"; -import {OK} from "http-status-codes"; -import {ADMIN_API_TOKEN, ADMIN_API_URL} from "../Enum/EnvironmentVariable"; -import Axios from "axios"; - -export class AdminController { - App : Application; - - constructor(App : Application) { - this.App = App; - this.getLoginUrlByToken(); - } - - - getLoginUrlByToken(){ - this.App.get("/register/:token", async (req: Request, res: Response) => { - if (!ADMIN_API_URL) { - return res.status(500).send('No admin backoffice set!'); - } - const token:string = req.params.token; - - let response = null - try { - response = await Axios.get(ADMIN_API_URL+'/api/login-url/'+token, { headers: {"Authorization" : `${ADMIN_API_TOKEN}`} }) - } catch (e) { - console.log(e.message) - return res.status(e.status || 500).send('An error happened'); - } - - const organizationSlug = response.data.organizationSlug; - const worldSlug = response.data.worldSlug; - const roomSlug = response.data.roomSlug; - return res.status(OK).send({organizationSlug, worldSlug, roomSlug}); - }); - } -} diff --git a/back/src/Controller/AuthenticateController.ts b/back/src/Controller/AuthenticateController.ts index 83880f45..26cc6ae5 100644 --- a/back/src/Controller/AuthenticateController.ts +++ b/back/src/Controller/AuthenticateController.ts @@ -1,8 +1,9 @@ import {Application, Request, Response} from "express"; import Jwt from "jsonwebtoken"; -import {BAD_REQUEST, OK} from "http-status-codes"; -import {SECRET_KEY, URL_ROOM_STARTED} from "../Enum/EnvironmentVariable"; //TODO fix import by "_Enum/..." +import {OK} from "http-status-codes"; +import {ADMIN_API_TOKEN, ADMIN_API_URL, SECRET_KEY, URL_ROOM_STARTED} from "../Enum/EnvironmentVariable"; //TODO fix import by "_Enum/..." import { uuid } from 'uuidv4'; +import Axios from "axios"; export interface TokenInterface { name: string, @@ -20,21 +21,53 @@ export class AuthenticateController { //permit to login on application. Return token to connect on Websocket IO. login(){ // For now, let's completely forget the /login route. - this.App.post("/login", (req: Request, res: Response) => { - const param = req.body; - /*if(!param.name){ - return res.status(BAD_REQUEST).send({ - message: "email parameter is empty" + this.App.post("/login", async (req: Request, res: Response) => { + //todo: what to do if the organizationMemberToken is already used? + const organizationMemberToken:string|null = req.body.organizationMemberToken; + + try { + let userUuid; + let mapUrlStart; + let newUrl = null; + + if (organizationMemberToken) { + if (!ADMIN_API_URL) { + return res.status(401).send('No admin backoffice set!'); + } + //todo: this call can fail if the corresponding world is not activated or if the token is invalid. Handle that case. + const response = await Axios.get(ADMIN_API_URL+'/api/login-url/'+organizationMemberToken, + { headers: {"Authorization" : `${ADMIN_API_TOKEN}`} } + ); + + userUuid = response.data.userUuid; + mapUrlStart = response.data.mapUrlStart; + newUrl = this.getNewUrlOnAdminAuth(response.data) + } else { + userUuid = uuid(); + mapUrlStart= URL_ROOM_STARTED; + newUrl = null; + } + + const authToken = Jwt.sign({userUuid: userUuid} as TokenInterface, SECRET_KEY, {expiresIn: '24h'}); + return res.status(OK).send({ + authToken, + userUuid, + mapUrlStart, + newUrl, }); - }*/ - //TODO check user email for The Coding Machine game - const userUuid = uuid(); - const token = Jwt.sign({name: param.name, userUuid: userUuid} as TokenInterface, SECRET_KEY, {expiresIn: '24h'}); - return res.status(OK).send({ - token: token, - mapUrlStart: URL_ROOM_STARTED, - userId: userUuid, - }); + + } catch (e) { + console.log(e.message) + return res.status(e.status || 500).send('An error happened'); + } + }); } + + getNewUrlOnAdminAuth(data:any): string { + const organizationSlug = data.organizationSlug; + const worldSlug = data.worldSlug; + const roomSlug = data.roomSlug; + return '/@/'+organizationSlug+'/'+worldSlug+'/'+roomSlug; + } } diff --git a/benchmark/index.ts b/benchmark/index.ts index 736a7bdc..921f4cbb 100644 --- a/benchmark/index.ts +++ b/benchmark/index.ts @@ -1,11 +1,11 @@ -import {Connection} from "../front/src/Connection"; +import {RoomConnection} from "../front/src/Connexion/Connection"; function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } async function startOneUser(): Promise { - const connection = await Connection.createConnection('foo', ['male3']); + const connection = await RoomConnection.createConnection('foo', ['male3']); await connection.joinARoom('global__maps.workadventure.localhost/Floor0/floor0', 783, 170, 'down', false, { top: 0, diff --git a/front/src/Connexion/ConnectionManager.ts b/front/src/Connexion/ConnectionManager.ts new file mode 100644 index 00000000..cb70eef3 --- /dev/null +++ b/front/src/Connexion/ConnectionManager.ts @@ -0,0 +1,53 @@ +import Axios from "axios"; +import {API_URL} from "../Enum/EnvironmentVariable"; +import {RoomConnection} from "./RoomConnection"; + +class ConnectionManager { + private mapUrlStart: string|null = null; + + private authToken:string|null = null; + private userUuid: string|null = null; + private userName:string|null = null; + + public async init(): Promise { + const match = /\/register\/(.+)/.exec(window.location.toString()); + const organizationMemberToken = match ? match[1] : null; + const res = await Axios.post(`${API_URL}/login`, {organizationMemberToken}); + this.authToken = res.data.authToken; + this.userUuid = res.data.userUuid; + this.mapUrlStart = res.data.mapUrlStart; + const newUrl = res.data.newUrl; + + if (newUrl) { + history.pushState({}, '', newUrl); + } + } + + public async setUserName(name:string): Promise { + //todo + } + + public connectToRoomSocket(): Promise { + return Axios.post(`${API_URL}/connectToSocket`, {authToken: this.authToken}).then((res) => { + return new Promise((resolve, reject) => { + const connection = new RoomConnection(res.data.roomToken); + connection.onConnectError((error: object) => { + console.log('An error occurred while connecting to socket server. Retrying'); + reject(error); + }); + resolve(connection); + }); + }) + .catch((err) => { + // Let's retry in 4-6 seconds + return new Promise((resolve, reject) => { + setTimeout(() => { + //todo: allow a way to break recurrsion? + this.connectToRoomSocket().then((connection) => resolve(connection)); + }, 4000 + Math.floor(Math.random() * 2000) ); + }); + }); + } +} + +export const connectionManager = new ConnectionManager(); \ No newline at end of file diff --git a/front/src/Connexion/ConnexionModels.ts b/front/src/Connexion/ConnexionModels.ts new file mode 100644 index 00000000..794b9169 --- /dev/null +++ b/front/src/Connexion/ConnexionModels.ts @@ -0,0 +1,117 @@ +import {PlayerAnimationNames} from "../Phaser/Player/Animation"; +import {UserSimplePeerInterface} from "../WebRtc/SimplePeer"; +import {SignalData} from "simple-peer"; + +export enum EventMessage{ + WEBRTC_SIGNAL = "webrtc-signal", + WEBRTC_SCREEN_SHARING_SIGNAL = "webrtc-screen-sharing-signal", + WEBRTC_START = "webrtc-start", + JOIN_ROOM = "join-room", // bi-directional + USER_POSITION = "user-position", // From client to server + USER_MOVED = "user-moved", // From server to client + USER_LEFT = "user-left", // From server to client + MESSAGE_ERROR = "message-error", + WEBRTC_DISCONNECT = "webrtc-disconect", + GROUP_CREATE_UPDATE = "group-create-update", + GROUP_DELETE = "group-delete", + SET_PLAYER_DETAILS = "set-player-details", // Send the name and character to the server (on connect), receive back the id. + ITEM_EVENT = 'item-event', + + CONNECT_ERROR = "connect_error", + SET_SILENT = "set_silent", // Set or unset the silent mode for this user. + SET_VIEWPORT = "set-viewport", + BATCH = "batch", +} + +export interface PointInterface { + x: number; + y: number; + direction : string; + moving: boolean; +} + +export class Point implements PointInterface{ + constructor(public x : number, public y : number, public direction : string = PlayerAnimationNames.WalkDown, public moving : boolean = false) { + if(x === null || y === null){ + throw Error("position x and y cannot be null"); + } + } +} + +export interface MessageUserPositionInterface { + userId: number; + name: string; + characterLayers: string[]; + position: PointInterface; +} + +export interface MessageUserMovedInterface { + userId: number; + position: PointInterface; +} + +export interface MessageUserJoined { + userId: number; + name: string; + characterLayers: string[]; + position: PointInterface +} + +export interface PositionInterface { + x: number, + y: number +} + +export interface GroupCreatedUpdatedMessageInterface { + position: PositionInterface, + groupId: number +} + +export interface WebRtcStartMessageInterface { + roomId: string, + clients: UserSimplePeerInterface[] +} + +export interface WebRtcDisconnectMessageInterface { + userId: number +} + +export interface WebRtcSignalSentMessageInterface { + receiverId: number, + signal: SignalData +} + +export interface WebRtcSignalReceivedMessageInterface { + userId: number, + signal: SignalData +} + +export interface StartMapInterface { + mapUrlStart: string, + startInstance: string +} + +export interface ViewportInterface { + left: number, + top: number, + right: number, + bottom: number, +} + +export interface BatchedMessageInterface { + event: string, + payload: unknown +} + +export interface ItemEventMessageInterface { + itemId: number, + event: string, + state: unknown, + parameters: unknown +} + +export interface RoomJoinedMessageInterface { + users: MessageUserPositionInterface[], + groups: GroupCreatedUpdatedMessageInterface[], + items: { [itemId: number] : unknown } +} \ No newline at end of file diff --git a/front/src/Connection.ts b/front/src/Connexion/RoomConnection.ts similarity index 69% rename from front/src/Connection.ts rename to front/src/Connexion/RoomConnection.ts index 61b0c4e7..99ef7b4e 100644 --- a/front/src/Connection.ts +++ b/front/src/Connexion/RoomConnection.ts @@ -1,142 +1,34 @@ -import Axios from "axios"; -import {API_URL} from "./Enum/EnvironmentVariable"; -import {MessageUI} from "./Logger/MessageUI"; +import {API_URL} from "../Enum/EnvironmentVariable"; import { BatchMessage, GroupDeleteMessage, GroupUpdateMessage, ItemEventMessage, PositionMessage, SetPlayerDetailsMessage, UserJoinedMessage, UserLeftMessage, UserMovedMessage, UserMovesMessage, ViewportMessage -} from "./Messages/generated/messages_pb" +} from "../Messages/generated/messages_pb" const SocketIo = require('socket.io-client'); import Socket = SocketIOClient.Socket; -import {PlayerAnimationNames} from "./Phaser/Player/Animation"; -import {UserSimplePeerInterface} from "./WebRtc/SimplePeer"; -import {SignalData} from "simple-peer"; import Direction = PositionMessage.Direction; -import {ProtobufClientUtils} from "./Network/ProtobufClientUtils"; +import {ProtobufClientUtils} from "../Network/ProtobufClientUtils"; +import { + EventMessage, + GroupCreatedUpdatedMessageInterface, ItemEventMessageInterface, + MessageUserJoined, + RoomJoinedMessageInterface, + ViewportInterface, WebRtcDisconnectMessageInterface, + WebRtcSignalReceivedMessageInterface, + WebRtcSignalSentMessageInterface, + WebRtcStartMessageInterface +} from "./ConnexionModels"; -enum EventMessage{ - WEBRTC_SIGNAL = "webrtc-signal", - WEBRTC_SCREEN_SHARING_SIGNAL = "webrtc-screen-sharing-signal", - WEBRTC_START = "webrtc-start", - JOIN_ROOM = "join-room", // bi-directional - USER_POSITION = "user-position", // From client to server - USER_MOVED = "user-moved", // From server to client - USER_LEFT = "user-left", // From server to client - MESSAGE_ERROR = "message-error", - WEBRTC_DISCONNECT = "webrtc-disconect", - GROUP_CREATE_UPDATE = "group-create-update", - GROUP_DELETE = "group-delete", - SET_PLAYER_DETAILS = "set-player-details", // Send the name and character to the server (on connect), receive back the id. - ITEM_EVENT = 'item-event', - CONNECT_ERROR = "connect_error", - SET_SILENT = "set_silent", // Set or unset the silent mode for this user. - SET_VIEWPORT = "set-viewport", - BATCH = "batch", -} - -export interface PointInterface { - x: number; - y: number; - direction : string; - moving: boolean; -} - -export class Point implements PointInterface{ - constructor(public x : number, public y : number, public direction : string = PlayerAnimationNames.WalkDown, public moving : boolean = false) { - if(x === null || y === null){ - throw Error("position x and y cannot be null"); - } - } -} - -export interface MessageUserPositionInterface { - userId: number; - name: string; - characterLayers: string[]; - position: PointInterface; -} - -export interface MessageUserMovedInterface { - userId: number; - position: PointInterface; -} - -export interface MessageUserJoined { - userId: number; - name: string; - characterLayers: string[]; - position: PointInterface -} - -export interface PositionInterface { - x: number, - y: number -} - -export interface GroupCreatedUpdatedMessageInterface { - position: PositionInterface, - groupId: number -} - -export interface WebRtcStartMessageInterface { - roomId: string, - clients: UserSimplePeerInterface[] -} - -export interface WebRtcDisconnectMessageInterface { - userId: number -} - -export interface WebRtcSignalSentMessageInterface { - receiverId: number, - signal: SignalData -} - -export interface WebRtcSignalReceivedMessageInterface { - userId: number, - signal: SignalData -} - -export interface StartMapInterface { - mapUrlStart: string, - startInstance: string -} - -export interface ViewportInterface { - left: number, - top: number, - right: number, - bottom: number, -} - -export interface BatchedMessageInterface { - event: string, - payload: unknown -} - -export interface ItemEventMessageInterface { - itemId: number, - event: string, - state: unknown, - parameters: unknown -} - -export interface RoomJoinedMessageInterface { - users: MessageUserPositionInterface[], - groups: GroupCreatedUpdatedMessageInterface[], - items: { [itemId: number] : unknown } -} - -export class Connection implements Connection { +export class RoomConnection implements RoomConnection { private readonly socket: Socket; private userId: number|null = null; private batchCallbacks: Map = new Map(); - private constructor(token: string) { + public constructor(token: string) { this.socket = SocketIo(`${API_URL}`, { query: { @@ -190,38 +82,14 @@ export class Connection implements Connection { } }) } - - public static createConnection(name: string, characterLayersSelected: string[]): Promise { - return Axios.post(`${API_URL}/login`, {name: name}) - .then((res) => { - - return new Promise((resolve, reject) => { - const connection = new Connection(res.data.token); - - connection.onConnectError((error: object) => { - console.log('An error occurred while connecting to socket server. Retrying'); - reject(error); - }); - - const message = new SetPlayerDetailsMessage(); - message.setName(name); - message.setCharacterlayersList(characterLayersSelected); - connection.socket.emit(EventMessage.SET_PLAYER_DETAILS, message.serializeBinary().buffer, (id: number) => { - connection.userId = id; - }); - - resolve(connection); - }); - }) - .catch((err) => { - // Let's retry in 4-6 seconds - return new Promise((resolve, reject) => { - setTimeout(() => { - Connection.createConnection(name, characterLayersSelected).then((connection) => resolve(connection)) - .catch((error) => reject(error)); - }, 4000 + Math.floor(Math.random() * 2000) ); - }); - }); + + public emitPlayerDetailsMessage(characterLayersSelected: string[]) { + const message = new SetPlayerDetailsMessage(); + message.setName(name); + message.setCharacterlayersList(characterLayersSelected); + this.socket.emit(EventMessage.SET_PLAYER_DETAILS, message.serializeBinary().buffer, (id: number) => { + this.userId = id; + }); } public closeConnection(): void { diff --git a/front/src/Network/ProtobufClientUtils.ts b/front/src/Network/ProtobufClientUtils.ts index 1eb5b923..6a402e97 100644 --- a/front/src/Network/ProtobufClientUtils.ts +++ b/front/src/Network/ProtobufClientUtils.ts @@ -1,6 +1,6 @@ import {PositionMessage} from "../Messages/generated/messages_pb"; -import {PointInterface} from "../Connection"; import Direction = PositionMessage.Direction; +import {PointInterface} from "../Connexion/ConnexionModels"; export class ProtobufClientUtils { diff --git a/front/src/Phaser/Entity/RemotePlayer.ts b/front/src/Phaser/Entity/RemotePlayer.ts index 00a3e4c4..ba0a74d2 100644 --- a/front/src/Phaser/Entity/RemotePlayer.ts +++ b/front/src/Phaser/Entity/RemotePlayer.ts @@ -1,5 +1,5 @@ import {GameScene} from "../Game/GameScene"; -import {PointInterface} from "../../Connection"; +import {PointInterface} from "../../Connexion/ConnexionModels"; import {Character} from "../Entity/Character"; /** diff --git a/front/src/Phaser/Game/AddPlayerInterface.ts b/front/src/Phaser/Game/AddPlayerInterface.ts index d0ed2dad..519116ac 100644 --- a/front/src/Phaser/Game/AddPlayerInterface.ts +++ b/front/src/Phaser/Game/AddPlayerInterface.ts @@ -1,4 +1,4 @@ -import {PointInterface} from "../../Connection"; +import {PointInterface} from "../../Connexion/Connection"; export interface AddPlayerInterface { userId: number; diff --git a/front/src/Phaser/Game/GameManager.ts b/front/src/Phaser/Game/GameManager.ts index db119a13..34a0bdf6 100644 --- a/front/src/Phaser/Game/GameManager.ts +++ b/front/src/Phaser/Game/GameManager.ts @@ -1,9 +1,10 @@ import {GameScene} from "./GameScene"; import { StartMapInterface -} from "../../Connection"; +} from "../../Connexion/ConnexionModels"; import Axios from "axios"; import {API_URL} from "../../Enum/EnvironmentVariable"; +import {adminDataFetchPromise} from "../../register"; export interface HasMovedEvent { direction: string; @@ -29,13 +30,23 @@ export class GameManager { } loadStartMap() : Promise { - return Axios.get(`${API_URL}/start-map`) - .then((res) => { - return res.data; - }).catch((err) => { - console.error(err); - throw err; - }); + if (adminDataFetchPromise) { + return adminDataFetchPromise.then(data => { + return { + mapUrlStart: data.mapUrlStart, + startInstance: data.startInstance, + } + }) + } else { + //todo: remove this call, merge with the admin workflow? + return Axios.get(`${API_URL}/start-map`) + .then((res) => { + return res.data; + }).catch((err) => { + console.error(err); + throw err; + }); + } } getPlayerName(): string { diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index f971a1e3..163eb3dc 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -1,6 +1,5 @@ import {GameManager, gameManager, HasMovedEvent} from "./GameManager"; import { - Connection, GroupCreatedUpdatedMessageInterface, MessageUserJoined, MessageUserMovedInterface, @@ -8,7 +7,7 @@ import { PointInterface, PositionInterface, RoomJoinedMessageInterface -} from "../../Connection"; +} from "../../Connexion/ConnexionModels"; import {CurrentGamerInterface, hasMovedEventName, Player} from "../Player/Player"; import {DEBUG_MODE, JITSI_URL, POSITION_DELAY, RESOLUTION, ZOOM_LEVEL} from "../../Enum/EnvironmentVariable"; import { @@ -42,6 +41,8 @@ import {ActionableItem} from "../Items/ActionableItem"; import {UserInputManager} from "../UserInput/UserInputManager"; import {UserMovedMessage} from "../../Messages/generated/messages_pb"; import {ProtobufClientUtils} from "../../Network/ProtobufClientUtils"; +import {connectionManager} from "../../Connexion/ConnectionManager"; +import {RoomConnection} from "../../Connexion/RoomConnection"; export enum Textures { @@ -100,9 +101,9 @@ export class GameScene extends Phaser.Scene implements CenterListener { pendingEvents: Queue = new Queue(); private initPosition: PositionInterface|null = null; private playersPositionInterpolator = new PlayersPositionInterpolator(); - private connection!: Connection; + private connection!: RoomConnection; private simplePeer!: SimplePeer; - private connectionPromise!: Promise + private connectionPromise!: Promise private connectionAnswerPromise: Promise; private connectionAnswerPromiseResolve!: (value?: RoomJoinedMessageInterface | PromiseLike) => void; // A promise that will resolve when the "create" method is called (signaling loading is ended) @@ -202,8 +203,10 @@ export class GameScene extends Phaser.Scene implements CenterListener { this.load.bitmapFont('main_font', 'resources/fonts/arcade.png', 'resources/fonts/arcade.xml'); - this.connectionPromise = Connection.createConnection(gameManager.getPlayerName(), gameManager.getCharacterSelected()).then((connection : Connection) => { + this.connectionPromise = connectionManager.connectToRoomSocket().then((connection : RoomConnection) => { this.connection = connection; + + this.connection.emitPlayerDetailsMessage(gameManager.getCharacterSelected()) connection.onUserJoins((message: MessageUserJoined) => { const userMessage: AddPlayerInterface = { @@ -778,7 +781,7 @@ export class GameScene extends Phaser.Scene implements CenterListener { this.createCollisionObject(); //join room - this.connectionPromise.then((connection: Connection) => { + this.connectionPromise.then((connection: RoomConnection) => { const camera = this.cameras.main; connection.joinARoom(this.RoomId, this.startX, diff --git a/front/src/Phaser/Game/PlayerMovement.ts b/front/src/Phaser/Game/PlayerMovement.ts index 56c4f113..eb1a5d1b 100644 --- a/front/src/Phaser/Game/PlayerMovement.ts +++ b/front/src/Phaser/Game/PlayerMovement.ts @@ -1,6 +1,6 @@ import {HasMovedEvent} from "./GameManager"; import {MAX_EXTRAPOLATION_TIME} from "../../Enum/EnvironmentVariable"; -import {PositionInterface} from "../../Connection"; +import {PositionInterface} from "../../Connexion/ConnexionModels"; export class PlayerMovement { public constructor(private startPosition: PositionInterface, private startTick: number, private endPosition: HasMovedEvent, private endTick: number) { diff --git a/front/src/Phaser/Login/EnableCameraScene.ts b/front/src/Phaser/Login/EnableCameraScene.ts index 6fc1cd54..6ac1ad47 100644 --- a/front/src/Phaser/Login/EnableCameraScene.ts +++ b/front/src/Phaser/Login/EnableCameraScene.ts @@ -1,12 +1,9 @@ import {gameManager} from "../Game/GameManager"; import {TextField} from "../Components/TextField"; -import {ClickButton} from "../Components/ClickButton"; import Image = Phaser.GameObjects.Image; -import Rectangle = Phaser.GameObjects.Rectangle; -import {PLAYER_RESOURCES, PlayerResourceDescriptionInterface} from "../Entity/Character"; import {GameSceneInitInterface} from "../Game/GameScene"; -import {StartMapInterface} from "../../Connection"; -import {mediaManager, MediaManager} from "../../WebRtc/MediaManager"; +import {StartMapInterface} from "../../Connexion/ConnexionModels"; +import {mediaManager} from "../../WebRtc/MediaManager"; import {RESOLUTION} from "../../Enum/EnvironmentVariable"; import {SoundMeter} from "../Components/SoundMeter"; import {SoundMeterSprite} from "../Components/SoundMeterSprite"; diff --git a/front/src/Phaser/Login/SelectCharacterScene.ts b/front/src/Phaser/Login/SelectCharacterScene.ts index 64285766..8d3c7ab1 100644 --- a/front/src/Phaser/Login/SelectCharacterScene.ts +++ b/front/src/Phaser/Login/SelectCharacterScene.ts @@ -3,8 +3,6 @@ import {TextField} from "../Components/TextField"; import Image = Phaser.GameObjects.Image; import Rectangle = Phaser.GameObjects.Rectangle; import {PLAYER_RESOURCES, PlayerResourceDescriptionInterface} from "../Entity/Character"; -import {GameSceneInitInterface} from "../Game/GameScene"; -import {StartMapInterface} from "../../Connection"; import {EnableCameraSceneName} from "./EnableCameraScene"; import {CustomizeSceneName} from "./CustomizeScene"; diff --git a/front/src/Phaser/Player/Player.ts b/front/src/Phaser/Player/Player.ts index 0fde84ae..b9c1c91a 100644 --- a/front/src/Phaser/Player/Player.ts +++ b/front/src/Phaser/Player/Player.ts @@ -1,9 +1,7 @@ import {PlayerAnimationNames} from "./Animation"; -import {GameScene, Textures} from "../Game/GameScene"; -import {MessageUserPositionInterface, PointInterface} from "../../Connection"; -import {ActiveEventList, UserInputEvent, UserInputManager} from "../UserInput/UserInputManager"; +import {GameScene} from "../Game/GameScene"; +import {UserInputEvent, UserInputManager} from "../UserInput/UserInputManager"; import {Character} from "../Entity/Character"; -import {OutlinePipeline} from "../Shaders/OutlinePipeline"; export const hasMovedEventName = "hasMoved"; diff --git a/front/src/WebRtc/ScreenSharingPeer.ts b/front/src/WebRtc/ScreenSharingPeer.ts index 9c2022a6..3cbc4154 100644 --- a/front/src/WebRtc/ScreenSharingPeer.ts +++ b/front/src/WebRtc/ScreenSharingPeer.ts @@ -1,7 +1,7 @@ import * as SimplePeerNamespace from "simple-peer"; import {mediaManager} from "./MediaManager"; -import {Connection} from "../Connection"; import {TURN_SERVER, TURN_USER, TURN_PASSWORD} from "../Enum/EnvironmentVariable"; +import {RoomConnection} from "../Connexion/RoomConnection"; const Peer: SimplePeerNamespace.SimplePeer = require('simple-peer'); @@ -14,7 +14,7 @@ export class ScreenSharingPeer extends Peer { */ private isReceivingStream:boolean = false; - constructor(private userId: number, initiator: boolean, private connection: Connection) { + constructor(private userId: number, initiator: boolean, private connection: RoomConnection) { super({ initiator: initiator ? initiator : false, reconnectTimer: 10000, diff --git a/front/src/WebRtc/SimplePeer.ts b/front/src/WebRtc/SimplePeer.ts index ac603756..bafbc02f 100644 --- a/front/src/WebRtc/SimplePeer.ts +++ b/front/src/WebRtc/SimplePeer.ts @@ -1,9 +1,8 @@ import { - Connection, WebRtcDisconnectMessageInterface, WebRtcSignalReceivedMessageInterface, WebRtcStartMessageInterface -} from "../Connection"; +} from "../Connexion/ConnexionModels"; import { mediaManager, StartScreenSharingCallback, @@ -13,6 +12,7 @@ import { import * as SimplePeerNamespace from "simple-peer"; import {ScreenSharingPeer} from "./ScreenSharingPeer"; import {VideoPeer} from "./VideoPeer"; +import {RoomConnection} from "../Connexion/RoomConnection"; const Peer: SimplePeerNamespace.SimplePeer = require('simple-peer'); export interface UserSimplePeerInterface{ @@ -31,7 +31,7 @@ export interface PeerConnectionListener { * This class manages connections to all the peers in the same group as me. */ export class SimplePeer { - private Connection: Connection; + private Connection: RoomConnection; private WebRtcRoomId: string; private Users: Array = new Array(); @@ -42,7 +42,7 @@ export class SimplePeer { private readonly stopLocalScreenSharingStreamCallback: StopScreenSharingCallback; private readonly peerConnectionListeners: Array = new Array(); - constructor(Connection: Connection, WebRtcRoomId: string = "test-webrtc") { + constructor(Connection: RoomConnection, WebRtcRoomId: string = "test-webrtc") { this.Connection = Connection; this.WebRtcRoomId = WebRtcRoomId; // We need to go through this weird bound function pointer in order to be able to "free" this reference later. diff --git a/front/src/WebRtc/VideoPeer.ts b/front/src/WebRtc/VideoPeer.ts index e046ffe2..9331bea7 100644 --- a/front/src/WebRtc/VideoPeer.ts +++ b/front/src/WebRtc/VideoPeer.ts @@ -1,7 +1,7 @@ import * as SimplePeerNamespace from "simple-peer"; import {mediaManager} from "./MediaManager"; -import {Connection} from "../Connection"; import {TURN_PASSWORD, TURN_SERVER, TURN_USER} from "../Enum/EnvironmentVariable"; +import {RoomConnection} from "../Connexion/RoomConnection"; const Peer: SimplePeerNamespace.SimplePeer = require('simple-peer'); @@ -9,7 +9,7 @@ const Peer: SimplePeerNamespace.SimplePeer = require('simple-peer'); * A peer connection used to transmit video / audio signals between 2 peers. */ export class VideoPeer extends Peer { - constructor(private userId: number, initiator: boolean, private connection: Connection) { + constructor(private userId: number, initiator: boolean, private connection: RoomConnection) { super({ initiator: initiator ? initiator : false, reconnectTimer: 10000, diff --git a/front/src/index.ts b/front/src/index.ts index 1f6b1d4a..8e235c7a 100644 --- a/front/src/index.ts +++ b/front/src/index.ts @@ -11,11 +11,10 @@ import WebGLRenderer = Phaser.Renderer.WebGL.WebGLRenderer; import {OutlinePipeline} from "./Phaser/Shaders/OutlinePipeline"; import {CustomizeScene} from "./Phaser/Login/CustomizeScene"; import {CoWebsiteManager} from "./WebRtc/CoWebsiteManager"; -import {redirectIfToken} from "./register"; +import {connectionManager} from "./Connexion/ConnectionManager"; //CoWebsiteManager.loadCoWebsite('https://thecodingmachine.com'); -let connectionData //todo: do something with this data -redirectIfToken().then(res => connectionData = res); +connectionManager.init(); // Load Jitsi if the environment variable is set. if (JITSI_URL) { diff --git a/front/src/register.ts b/front/src/register.ts deleted file mode 100644 index 98fe0d1e..00000000 --- a/front/src/register.ts +++ /dev/null @@ -1,29 +0,0 @@ -import Axios from "axios"; -import {API_URL} from "./Enum/EnvironmentVariable"; -declare let history:History; - -//todo: better naming -export interface ConnexionData { - organizationSlug: string, - worldSlug: string, - roomSlug: string, -} - -export async function redirectIfToken(): Promise { - const match = /\/register\/(.+)/.exec(window.location.toString()); - if (!match) { - return null - } - let res = null; - try { - res = await Axios.get(`${API_URL}/register/`+match[1]) - } catch (e) { - return null; - } - const organizationSlug = res.data.organizationSlug; - const worldSlug = res.data.worldSlug; - const roomSlug = res.data.roomSlug; - const connexionUrl = '/@/'+organizationSlug+'/'+worldSlug+'/'+roomSlug; - history.pushState({}, '', connexionUrl); - return {organizationSlug, worldSlug, roomSlug}; -} \ No newline at end of file From 3f9659ef3c75c643c356ef38e039b0a37bc53f8b Mon Sep 17 00:00:00 2001 From: arp Date: Mon, 28 Sep 2020 15:02:37 +0200 Subject: [PATCH 068/122] improvments --- back/src/App.ts | 3 - back/src/Controller/AuthenticateController.ts | 25 ++++--- back/src/Controller/IoSocketController.ts | 12 ++-- back/src/Controller/MapController.ts | 1 + back/src/Model/Websocket/ExSocketInterface.ts | 1 - front/src/Connexion/ConnectionManager.ts | 66 +++++++++++-------- front/src/Connexion/RoomConnection.ts | 4 +- front/src/Phaser/Game/AddPlayerInterface.ts | 2 +- front/src/Phaser/Game/GameManager.ts | 25 ++----- front/src/Phaser/Game/GameScene.ts | 4 +- 10 files changed, 72 insertions(+), 71 deletions(-) diff --git a/back/src/App.ts b/back/src/App.ts index a2aa91a5..545bdd91 100644 --- a/back/src/App.ts +++ b/back/src/App.ts @@ -7,7 +7,6 @@ import bodyParser = require('body-parser'); import * as http from "http"; import {MapController} from "./Controller/MapController"; import {PrometheusController} from "./Controller/PrometheusController"; -import {AdminController} from "./Controller/AdminController"; import {DebugController} from "./Controller/DebugController"; class App { @@ -17,7 +16,6 @@ class App { public authenticateController: AuthenticateController; public mapController: MapController; public prometheusController: PrometheusController; - private adminController: AdminController; private debugController: DebugController; constructor() { @@ -36,7 +34,6 @@ class App { this.authenticateController = new AuthenticateController(this.app); this.mapController = new MapController(this.app); this.prometheusController = new PrometheusController(this.app, this.ioSocketController); - this.adminController = new AdminController(this.app); this.debugController = new DebugController(this.app, this.ioSocketController); } diff --git a/back/src/Controller/AuthenticateController.ts b/back/src/Controller/AuthenticateController.ts index 26cc6ae5..d6ebe124 100644 --- a/back/src/Controller/AuthenticateController.ts +++ b/back/src/Controller/AuthenticateController.ts @@ -6,7 +6,14 @@ import { uuid } from 'uuidv4'; import Axios from "axios"; export interface TokenInterface { - name: string, + userUuid: string +} + +interface AdminApiData { + organizationSlug: string + worldSlug: string + roomSlug: string + mapUrlStart: string userUuid: string } @@ -35,20 +42,20 @@ export class AuthenticateController { return res.status(401).send('No admin backoffice set!'); } //todo: this call can fail if the corresponding world is not activated or if the token is invalid. Handle that case. - const response = await Axios.get(ADMIN_API_URL+'/api/login-url/'+organizationMemberToken, + const data = await Axios.get(ADMIN_API_URL+'/api/login-url/'+organizationMemberToken, { headers: {"Authorization" : `${ADMIN_API_TOKEN}`} } - ); + ).then((res): AdminApiData => res.data); - userUuid = response.data.userUuid; - mapUrlStart = response.data.mapUrlStart; - newUrl = this.getNewUrlOnAdminAuth(response.data) + userUuid = data.userUuid; + mapUrlStart = data.mapUrlStart; + newUrl = this.getNewUrlOnAdminAuth(data) } else { userUuid = uuid(); - mapUrlStart= URL_ROOM_STARTED; + mapUrlStart = req.headers.host?.replace('api.', 'maps.') + URL_ROOM_STARTED; newUrl = null; } - const authToken = Jwt.sign({userUuid: userUuid} as TokenInterface, SECRET_KEY, {expiresIn: '24h'}); + const authToken = Jwt.sign({userUuid: userUuid}, SECRET_KEY, {expiresIn: '24h'}); return res.status(OK).send({ authToken, userUuid, @@ -64,7 +71,7 @@ export class AuthenticateController { }); } - getNewUrlOnAdminAuth(data:any): string { + private getNewUrlOnAdminAuth(data:AdminApiData): string { const organizationSlug = data.organizationSlug; const worldSlug = data.worldSlug; const roomSlug = data.roomSlug; diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index 7111e7d2..3e18149f 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -121,18 +121,19 @@ export class IoSocketController { return next(new Error('Authentication error')); } Jwt.verify(socket.handshake.query.token, SECRET_KEY, (err: JsonWebTokenError, tokenDecoded: object) => { + const tokenInterface = tokenDecoded as TokenInterface; if (err) { console.error('An authentication error happened, invalid JsonWebToken.', err); return next(new Error('Authentication error')); } - if (!this.isValidToken(tokenDecoded)) { + if (!this.isValidToken(tokenInterface)) { return next(new Error('Authentication error, invalid token structure')); } (socket as ExSocketInterface).token = socket.handshake.query.token; (socket as ExSocketInterface).userId = this.nextUserId; - (socket as ExSocketInterface).userUuid = tokenDecoded.userUuid; + (socket as ExSocketInterface).userUuid = tokenInterface.userUuid; this.nextUserId++; next(); }); @@ -141,11 +142,8 @@ export class IoSocketController { this.ioConnection(); } - private isValidToken(token: object): token is TokenInterface { - if (typeof((token as TokenInterface).userUuid) !== 'string') { - return false; - } - if (typeof((token as TokenInterface).name) !== 'string') { + private isValidToken(token: TokenInterface): boolean { + if (typeof(token.userUuid) !== 'string') { return false; } return true; diff --git a/back/src/Controller/MapController.ts b/back/src/Controller/MapController.ts index 58ce40a9..539eb9d7 100644 --- a/back/src/Controller/MapController.ts +++ b/back/src/Controller/MapController.ts @@ -3,6 +3,7 @@ import {Application, Request, Response} from "express"; import {OK} from "http-status-codes"; import {URL_ROOM_STARTED} from "../Enum/EnvironmentVariable"; +//todo: delete this export class MapController { App: Application; diff --git a/back/src/Model/Websocket/ExSocketInterface.ts b/back/src/Model/Websocket/ExSocketInterface.ts index ace374f4..3cacd7f5 100644 --- a/back/src/Model/Websocket/ExSocketInterface.ts +++ b/back/src/Model/Websocket/ExSocketInterface.ts @@ -1,7 +1,6 @@ import {Socket} from "socket.io"; import {PointInterface} from "./PointInterface"; import {Identificable} from "./Identificable"; -import {TokenInterface} from "../../Controller/AuthenticateController"; import {ViewportInterface} from "_Model/Websocket/ViewportMessage"; import {BatchMessage, SubMessage} from "../../Messages/generated/messages_pb"; diff --git a/front/src/Connexion/ConnectionManager.ts b/front/src/Connexion/ConnectionManager.ts index cb70eef3..6f8e67a5 100644 --- a/front/src/Connexion/ConnectionManager.ts +++ b/front/src/Connexion/ConnectionManager.ts @@ -2,51 +2,61 @@ import Axios from "axios"; import {API_URL} from "../Enum/EnvironmentVariable"; import {RoomConnection} from "./RoomConnection"; +interface LoginApiData { + authToken: string + userUuid: string + mapUrlStart: string + newUrl: string +} + class ConnectionManager { + private initPromise: Promise = Promise.reject(); private mapUrlStart: string|null = null; private authToken:string|null = null; private userUuid: string|null = null; - private userName:string|null = null; public async init(): Promise { const match = /\/register\/(.+)/.exec(window.location.toString()); const organizationMemberToken = match ? match[1] : null; - const res = await Axios.post(`${API_URL}/login`, {organizationMemberToken}); - this.authToken = res.data.authToken; - this.userUuid = res.data.userUuid; - this.mapUrlStart = res.data.mapUrlStart; - const newUrl = res.data.newUrl; + this.initPromise = Axios.post(`${API_URL}/login`, {organizationMemberToken}).then(res => res.data); + const data = await this.initPromise + this.authToken = data.authToken; + this.userUuid = data.userUuid; + this.mapUrlStart = data.mapUrlStart; + const newUrl = data.newUrl; if (newUrl) { history.pushState({}, '', newUrl); } } - public async setUserName(name:string): Promise { - //todo + public connectToRoomSocket(): Promise { + return new Promise((resolve, reject) => { + const connection = new RoomConnection(this.authToken as string); + connection.onConnectError((error: object) => { + console.log('An error occurred while connecting to socket server. Retrying'); + reject(error); + }); + resolve(connection); + }).catch((err) => { + // Let's retry in 4-6 seconds + return new Promise((resolve, reject) => { + setTimeout(() => { + //todo: allow a way to break recurrsion? + this.connectToRoomSocket().then((connection) => resolve(connection)); + }, 4000 + Math.floor(Math.random() * 2000) ); + }); + }); } - public connectToRoomSocket(): Promise { - return Axios.post(`${API_URL}/connectToSocket`, {authToken: this.authToken}).then((res) => { - return new Promise((resolve, reject) => { - const connection = new RoomConnection(res.data.roomToken); - connection.onConnectError((error: object) => { - console.log('An error occurred while connecting to socket server. Retrying'); - reject(error); - }); - resolve(connection); - }); - }) - .catch((err) => { - // Let's retry in 4-6 seconds - return new Promise((resolve, reject) => { - setTimeout(() => { - //todo: allow a way to break recurrsion? - this.connectToRoomSocket().then((connection) => resolve(connection)); - }, 4000 + Math.floor(Math.random() * 2000) ); - }); - }); + public getMapUrlStart(): Promise { + return this.initPromise.then(() => { + if (!this.mapUrlStart) { + throw new Error('No map url set!'); + } + return this.mapUrlStart; + }) } } diff --git a/front/src/Connexion/RoomConnection.ts b/front/src/Connexion/RoomConnection.ts index 99ef7b4e..54519f60 100644 --- a/front/src/Connexion/RoomConnection.ts +++ b/front/src/Connexion/RoomConnection.ts @@ -83,9 +83,9 @@ export class RoomConnection implements RoomConnection { }) } - public emitPlayerDetailsMessage(characterLayersSelected: string[]) { + public emitPlayerDetailsMessage(userName: string, characterLayersSelected: string[]) { const message = new SetPlayerDetailsMessage(); - message.setName(name); + message.setName(userName); message.setCharacterlayersList(characterLayersSelected); this.socket.emit(EventMessage.SET_PLAYER_DETAILS, message.serializeBinary().buffer, (id: number) => { this.userId = id; diff --git a/front/src/Phaser/Game/AddPlayerInterface.ts b/front/src/Phaser/Game/AddPlayerInterface.ts index 519116ac..91563dd0 100644 --- a/front/src/Phaser/Game/AddPlayerInterface.ts +++ b/front/src/Phaser/Game/AddPlayerInterface.ts @@ -1,4 +1,4 @@ -import {PointInterface} from "../../Connexion/Connection"; +import {PointInterface} from "../../Connexion/ConnexionModels"; export interface AddPlayerInterface { userId: number; diff --git a/front/src/Phaser/Game/GameManager.ts b/front/src/Phaser/Game/GameManager.ts index 34a0bdf6..960ce7e2 100644 --- a/front/src/Phaser/Game/GameManager.ts +++ b/front/src/Phaser/Game/GameManager.ts @@ -4,7 +4,7 @@ import { } from "../../Connexion/ConnexionModels"; import Axios from "axios"; import {API_URL} from "../../Enum/EnvironmentVariable"; -import {adminDataFetchPromise} from "../../register"; +import {connectionManager} from "../../Connexion/ConnectionManager"; export interface HasMovedEvent { direction: string; @@ -30,23 +30,12 @@ export class GameManager { } loadStartMap() : Promise { - if (adminDataFetchPromise) { - return adminDataFetchPromise.then(data => { - return { - mapUrlStart: data.mapUrlStart, - startInstance: data.startInstance, - } - }) - } else { - //todo: remove this call, merge with the admin workflow? - return Axios.get(`${API_URL}/start-map`) - .then((res) => { - return res.data; - }).catch((err) => { - console.error(err); - throw err; - }); - } + return connectionManager.getMapUrlStart().then(mapUrlStart => { + return { + mapUrlStart: mapUrlStart, + startInstance: "global", //todo: is this property still usefull? + } + }); } getPlayerName(): string { diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 163eb3dc..425aaf36 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -205,8 +205,8 @@ export class GameScene extends Phaser.Scene implements CenterListener { this.connectionPromise = connectionManager.connectToRoomSocket().then((connection : RoomConnection) => { this.connection = connection; - - this.connection.emitPlayerDetailsMessage(gameManager.getCharacterSelected()) + + this.connection.emitPlayerDetailsMessage(gameManager.getPlayerName(), gameManager.getCharacterSelected()) connection.onUserJoins((message: MessageUserJoined) => { const userMessage: AddPlayerInterface = { From 6a4c0c86782c2624f39e336bf37ff06b02158f14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Mon, 28 Sep 2020 18:52:54 +0200 Subject: [PATCH 069/122] Migrating to uWS --- back/package.json | 8 +- back/server.ts | 2 +- back/src/App.ts | 31 +- back/src/Controller/AuthenticateController.ts | 50 +- back/src/Controller/BaseController.ts | 10 + back/src/Controller/IoSocketController.ts | 684 +++++++++--------- back/src/Controller/MapController.ts | 30 +- back/src/Model/Websocket/ExSocketInterface.ts | 7 +- back/src/Model/Websocket/ProtobufUtils.ts | 39 +- back/src/Model/World.ts | 2 +- back/src/Server/server/app.ts | 13 + back/src/Server/server/baseapp.ts | 220 ++++++ back/src/Server/server/cluster.ts | 48 ++ back/src/Server/server/formdata.ts | 99 +++ back/src/Server/server/graphiql.html | 133 ++++ back/src/Server/server/graphql.ts | 138 ++++ back/src/Server/server/livereload.ts | 35 + back/src/Server/server/livereloadjs.js | 47 ++ back/src/Server/server/loadroutes.ts | 42 ++ back/src/Server/server/mime.ts | 176 +++++ back/src/Server/server/sendfile.ts | 172 +++++ back/src/Server/server/sslapp.ts | 13 + back/src/Server/server/types.ts | 26 + back/src/Server/server/utils.ts | 52 ++ back/src/Server/sifrr.server.ts | 30 + back/yarn.lock | 505 ++----------- benchmark/index.ts | 5 + benchmark/package.json | 9 +- benchmark/yarn.lock | 187 +---- front/src/Connection.ts | 303 +++++--- messages/messages.proto | 63 ++ 31 files changed, 2056 insertions(+), 1123 deletions(-) create mode 100644 back/src/Controller/BaseController.ts create mode 100644 back/src/Server/server/app.ts create mode 100644 back/src/Server/server/baseapp.ts create mode 100644 back/src/Server/server/cluster.ts create mode 100644 back/src/Server/server/formdata.ts create mode 100644 back/src/Server/server/graphiql.html create mode 100644 back/src/Server/server/graphql.ts create mode 100644 back/src/Server/server/livereload.ts create mode 100644 back/src/Server/server/livereloadjs.js create mode 100644 back/src/Server/server/loadroutes.ts create mode 100644 back/src/Server/server/mime.ts create mode 100644 back/src/Server/server/sendfile.ts create mode 100644 back/src/Server/server/sslapp.ts create mode 100644 back/src/Server/server/types.ts create mode 100644 back/src/Server/server/utils.ts create mode 100644 back/src/Server/sifrr.server.ts diff --git a/back/package.json b/back/package.json index b1159144..50d4fe18 100644 --- a/back/package.json +++ b/back/package.json @@ -38,27 +38,27 @@ "dependencies": { "axios": "^0.20.0", "body-parser": "^1.19.0", + "busboy": "^0.3.1", "circular-json": "^0.5.9", - "express": "^4.17.1", "generic-type-guard": "^3.2.0", "google-protobuf": "^3.13.0", "http-status-codes": "^1.4.0", + "iterall": "^1.3.0", "jsonwebtoken": "^8.5.1", "prom-client": "^12.0.0", - "socket.io": "^2.3.0", + "query-string": "^6.13.3", "systeminformation": "^4.26.5", "ts-node-dev": "^1.0.0-pre.44", "typescript": "^3.8.3", + "uWebSockets.js": "uNetworking/uWebSockets.js#v18.5.0", "uuidv4": "^6.0.7" }, "devDependencies": { "@types/circular-json": "^0.4.0", - "@types/express": "^4.17.4", "@types/google-protobuf": "^3.7.3", "@types/http-status-codes": "^1.2.0", "@types/jasmine": "^3.5.10", "@types/jsonwebtoken": "^8.3.8", - "@types/socket.io": "^2.1.4", "@types/uuidv4": "^5.0.0", "@typescript-eslint/eslint-plugin": "^2.26.0", "@typescript-eslint/parser": "^2.26.0", diff --git a/back/server.ts b/back/server.ts index f98c9df2..cb4a7604 100644 --- a/back/server.ts +++ b/back/server.ts @@ -1,3 +1,3 @@ // lib/server.ts import App from "./src/App"; -App.listen(8080, () => console.log(`Example app listening on port 8080!`)) \ No newline at end of file +App.listen(8080, () => console.log(`WorkAdventure starting on port 8080!`)) diff --git a/back/src/App.ts b/back/src/App.ts index a2aa91a5..c13b6fdc 100644 --- a/back/src/App.ts +++ b/back/src/App.ts @@ -9,10 +9,10 @@ import {MapController} from "./Controller/MapController"; import {PrometheusController} from "./Controller/PrometheusController"; import {AdminController} from "./Controller/AdminController"; import {DebugController} from "./Controller/DebugController"; +import {App as uwsApp} from "./Server/sifrr.server"; class App { - public app: Application; - public server: http.Server; + public app: uwsApp; public ioSocketController: IoSocketController; public authenticateController: AuthenticateController; public mapController: MapController; @@ -21,18 +21,25 @@ class App { private debugController: DebugController; constructor() { - this.app = express(); - - //config server http - this.server = http.createServer(this.app); + this.app = new uwsApp(); this.config(); this.crossOrigin(); //TODO add middleware with access token to secure api + // STUPID CORS IMPLEMENTATION. + // TODO: SECURE THIS + this.app.any('/*', (res, req) => { + res.writeHeader('access-control-allow-headers', 'Origin, X-Requested-With, Content-Type, Accept'); + res.writeHeader('access-control-allow-methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE'); + res.writeHeader('access-control-allow-origin', '*'); + + req.setYield(true); + }); + //create socket controllers - this.ioSocketController = new IoSocketController(this.server); + this.ioSocketController = new IoSocketController(this.app); this.authenticateController = new AuthenticateController(this.app); this.mapController = new MapController(this.app); this.prometheusController = new PrometheusController(this.app, this.ioSocketController); @@ -42,20 +49,20 @@ class App { // TODO add session user private config(): void { - this.app.use(bodyParser.json()); - this.app.use(bodyParser.urlencoded({extended: false})); + /*this.app.use(bodyParser.json()); + this.app.use(bodyParser.urlencoded({extended: false}));*/ } private crossOrigin(){ - this.app.use((req: Request, res: Response, next) => { + /*this.app.use((req: Request, res: Response, next) => { res.setHeader("Access-Control-Allow-Origin", "*"); // update to match the domain you will make the request from // Request methods you wish to allow res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE'); // Request headers you wish to allow res.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); next(); - }); + });*/ } } -export default new App().server; +export default new App().app; diff --git a/back/src/Controller/AuthenticateController.ts b/back/src/Controller/AuthenticateController.ts index 83880f45..a65255a2 100644 --- a/back/src/Controller/AuthenticateController.ts +++ b/back/src/Controller/AuthenticateController.ts @@ -3,38 +3,58 @@ import Jwt from "jsonwebtoken"; import {BAD_REQUEST, OK} from "http-status-codes"; import {SECRET_KEY, URL_ROOM_STARTED} from "../Enum/EnvironmentVariable"; //TODO fix import by "_Enum/..." import { uuid } from 'uuidv4'; +import {HttpRequest, HttpResponse, TemplatedApp} from "uWebSockets.js"; +import {BaseController} from "./BaseController"; export interface TokenInterface { name: string, userUuid: string } -export class AuthenticateController { - App : Application; +export class AuthenticateController extends BaseController { - constructor(App : Application) { - this.App = App; + constructor(private App : TemplatedApp) { + super(); this.login(); } + onAbortedOrFinishedResponse(res: HttpResponse/*, readStream: any*/) { + + console.log("ERROR! onAbortedOrFinishedResponse called!"); + /*if (res.id == -1) { + console.log("ERROR! onAbortedOrFinishedResponse called twice for the same res!"); + } else { + console.log('Stream was closed, openStreams: ' + --openStreams); + console.timeEnd(res.id); + readStream.destroy(); + }*/ + + /* Mark this response already accounted for */ + //res.id = -1; + } + //permit to login on application. Return token to connect on Websocket IO. login(){ - // For now, let's completely forget the /login route. - this.App.post("/login", (req: Request, res: Response) => { - const param = req.body; - /*if(!param.name){ - return res.status(BAD_REQUEST).send({ - message: "email parameter is empty" - }); - }*/ - //TODO check user email for The Coding Machine game + this.App.options("/login", (res: HttpResponse, req: HttpRequest) => { + this.addCorsHeaders(res); + + res.end(); + }); + + this.App.post("/login", async (res: HttpResponse, req: HttpRequest) => { + this.addCorsHeaders(res); + + res.onAborted(() => { + console.warn('Login request was aborted'); + }) + const param = await res.json(); const userUuid = uuid(); const token = Jwt.sign({name: param.name, userUuid: userUuid} as TokenInterface, SECRET_KEY, {expiresIn: '24h'}); - return res.status(OK).send({ + res.writeStatus("200 OK").end(JSON.stringify({ token: token, mapUrlStart: URL_ROOM_STARTED, userId: userUuid, - }); + })); }); } } diff --git a/back/src/Controller/BaseController.ts b/back/src/Controller/BaseController.ts new file mode 100644 index 00000000..93c17ab4 --- /dev/null +++ b/back/src/Controller/BaseController.ts @@ -0,0 +1,10 @@ +import {HttpResponse} from "uWebSockets.js"; + + +export class BaseController { + protected addCorsHeaders(res: HttpResponse): void { + res.writeHeader('access-control-allow-headers', 'Origin, X-Requested-With, Content-Type, Accept'); + res.writeHeader('access-control-allow-methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE'); + res.writeHeader('access-control-allow-origin', '*'); + } +} diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index 7111e7d2..1928679d 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -1,5 +1,3 @@ -import socketIO = require('socket.io'); -import {Socket} from "socket.io"; import * as http from "http"; import {MessageUserPosition, Point} from "../Model/Websocket/MessageUserPosition"; //TODO fix import by "_Model/.." import {ExSocketInterface} from "../Model/Websocket/ExSocketInterface"; //TODO fix import by "_Model/.." @@ -32,11 +30,19 @@ import { GroupDeleteMessage, UserJoinedMessage, UserLeftMessage, - ItemEventMessage, ViewportMessage + ItemEventMessage, + ViewportMessage, + ClientToServerMessage, + JoinRoomMessage, + ErrorMessage, + RoomJoinedMessage, + ItemStateMessage, + ServerToClientMessage, SetUserIdMessage, SilentMessage } from "../Messages/generated/messages_pb"; import {UserMovesMessage} from "../Messages/generated/messages_pb"; import Direction = PositionMessage.Direction; import {ProtobufUtils} from "../Model/Websocket/ProtobufUtils"; +import {App, TemplatedApp, WebSocket} from "uWebSockets.js" enum SocketIoEvent { CONNECTION = "connection", @@ -59,12 +65,18 @@ enum SocketIoEvent { BATCH = "batch", } -function emitInBatch(socket: ExSocketInterface, event: string, payload: SubMessage): void { +function emitInBatch(socket: ExSocketInterface, payload: SubMessage): void { + if (socket.disconnecting) { + return; + } socket.batchedMessages.addPayload(payload); if (socket.batchTimeout === null) { socket.batchTimeout = setTimeout(() => { - socket./*binary(true).*/emit(SocketIoEvent.BATCH, socket.batchedMessages.serializeBinary().buffer); + const serverToClientMessage = new ServerToClientMessage(); + serverToClientMessage.setBatchmessage(socket.batchedMessages); + + socket.send(serverToClientMessage.serializeBinary().buffer, true); socket.batchedMessages = new BatchMessage(); socket.batchTimeout = null; }, 100); @@ -72,15 +84,14 @@ function emitInBatch(socket: ExSocketInterface, event: string, payload: SubMessa } export class IoSocketController { - public readonly Io: socketIO.Server; private Worlds: Map = new Map(); private sockets: Map = new Map(); private nbClientsGauge: Gauge; private nbClientsPerRoomGauge: Gauge; private nextUserId: number = 1; - constructor(server: http.Server) { - this.Io = socketIO(server); + constructor(private readonly app: TemplatedApp) { + this.nbClientsGauge = new Gauge({ name: 'workadventure_nb_sockets', help: 'Number of connected sockets', @@ -92,52 +103,6 @@ export class IoSocketController { labelNames: [ 'room' ] }); - // Authentication with token. it will be decoded and stored in the socket. - // Completely commented for now, as we do not use the "/login" route at all. - this.Io.use((socket: Socket, next) => { - //console.log(socket.handshake.query.token); - if (!socket.handshake.query || !socket.handshake.query.token) { - console.error('An authentication error happened, a user tried to connect without a token.'); - return next(new Error('Authentication error')); - } - if(socket.handshake.query.token === 'test'){ - if (ALLOW_ARTILLERY) { - (socket as ExSocketInterface).token = socket.handshake.query.token; - (socket as ExSocketInterface).userId = this.nextUserId; - (socket as ExSocketInterface).userUuid = uuid(); - this.nextUserId++; - (socket as ExSocketInterface).isArtillery = true; - console.log((socket as ExSocketInterface).userId); - next(); - return; - } else { - console.warn("In order to perform a load-testing test on this environment, you must set the ALLOW_ARTILLERY environment variable to 'true'"); - next(); - } - } - (socket as ExSocketInterface).isArtillery = false; - if(this.searchClientByToken(socket.handshake.query.token)){ - console.error('An authentication error happened, a user tried to connect while its token is already connected.'); - return next(new Error('Authentication error')); - } - Jwt.verify(socket.handshake.query.token, SECRET_KEY, (err: JsonWebTokenError, tokenDecoded: object) => { - if (err) { - console.error('An authentication error happened, invalid JsonWebToken.', err); - return next(new Error('Authentication error')); - } - - if (!this.isValidToken(tokenDecoded)) { - return next(new Error('Authentication error, invalid token structure')); - } - - (socket as ExSocketInterface).token = socket.handshake.query.token; - (socket as ExSocketInterface).userId = this.nextUserId; - (socket as ExSocketInterface).userUuid = tokenDecoded.userUuid; - this.nextUserId++; - next(); - }); - }); - this.ioConnection(); } @@ -167,201 +132,107 @@ export class IoSocketController { return null; } - ioConnection() { - this.Io.on(SocketIoEvent.CONNECTION, (socket: Socket) => { - const client : ExSocketInterface = socket as ExSocketInterface; - client.batchedMessages = new BatchMessage(); - client.batchTimeout = null; - client.emitInBatch = (event: string, payload: SubMessage): void => { - emitInBatch(client, event, payload); + private authenticate(ws: WebSocket) { + //console.log(socket.handshake.query.token); + + /*if (!socket.handshake.query || !socket.handshake.query.token) { + console.error('An authentication error happened, a user tried to connect without a token.'); + return next(new Error('Authentication error')); + } + if(socket.handshake.query.token === 'test'){ + if (ALLOW_ARTILLERY) { + (socket as ExSocketInterface).token = socket.handshake.query.token; + (socket as ExSocketInterface).userId = this.nextUserId; + (socket as ExSocketInterface).userUuid = uuid(); + this.nextUserId++; + (socket as ExSocketInterface).isArtillery = true; + console.log((socket as ExSocketInterface).userId); + next(); + return; + } else { + console.warn("In order to perform a load-testing test on this environment, you must set the ALLOW_ARTILLERY environment variable to 'true'"); + next(); + } + } + (socket as ExSocketInterface).isArtillery = false; + if(this.searchClientByToken(socket.handshake.query.token)){ + console.error('An authentication error happened, a user tried to connect while its token is already connected.'); + return next(new Error('Authentication error')); + } + Jwt.verify(socket.handshake.query.token, SECRET_KEY, (err: JsonWebTokenError, tokenDecoded: object) => { + if (err) { + console.error('An authentication error happened, invalid JsonWebToken.', err); + return next(new Error('Authentication error')); } - this.sockets.set(client.userId, client); - // Let's log server load when a user joins - const srvSockets = this.Io.sockets.sockets; - this.nbClientsGauge.inc(); - console.log(new Date().toISOString() + ' A user joined (', Object.keys(srvSockets).length, ' connected users)'); - //si.currentLoad().then(data => console.log(' Current load: ', data.avgload)); - //si.currentLoad().then(data => console.log(' CPU: ', data.currentload, '%')); - // End log server load + if (!this.isValidToken(tokenDecoded)) { + return next(new Error('Authentication error, invalid token structure')); + } - /*join-rom event permit to join one room. - message : - userId : user identification - roomId: room identification - position: position of user in map - x: user x position on map - y: user y position on map - */ - socket.on(SocketIoEvent.JOIN_ROOM, (message: unknown, answerFn): void => { - //console.log(SocketIoEvent.JOIN_ROOM, message); - try { - if (!isJoinRoomMessageInterface(message)) { - socket.emit(SocketIoEvent.MESSAGE_ERROR, {message: 'Invalid JOIN_ROOM message.'}); - console.warn('Invalid JOIN_ROOM message received: ', message); - return; - } - const roomId = message.roomId; + (socket as ExSocketInterface).token = socket.handshake.query.token; + (socket as ExSocketInterface).userId = this.nextUserId; + (socket as ExSocketInterface).userUuid = tokenDecoded.userUuid; + this.nextUserId++; + next(); + });*/ + const socket = ws as ExSocketInterface; + socket.userId = this.nextUserId; + this.nextUserId++; + } - const Client = (socket as ExSocketInterface); + ioConnection() { + this.app.ws('/*', { + /* Options */ + //compression: uWS.SHARED_COMPRESSOR, + maxPayloadLength: 16 * 1024 * 1024, + idleTimeout: 10, + /* Handlers */ + open: (ws) => { + this.authenticate(ws); + // TODO: close if authenticate is ko - if (Client.roomId === roomId) { - return; - } - - //leave previous room - this.leaveRoom(Client); - - //join new previous room - const world = this.joinRoom(Client, roomId, message.position); - - const things = world.setViewport(Client, message.viewport); - - const listOfUsers: Array = []; - const listOfGroups: Array = []; - - for (const thing of things) { - if (thing instanceof User) { - const player: ExSocketInterface|undefined = this.sockets.get(thing.id); - if (player === undefined) { - console.warn('Something went wrong. The World contains a user "'+thing.id+"' but this user does not exist in the sockets list!"); - continue; - } - - listOfUsers.push(new MessageUserPosition(thing.id, player.name, player.characterLayers, player.position)); - } else if (thing instanceof Group) { - listOfGroups.push({ - groupId: thing.getId(), - position: thing.getPosition(), - }); - } else { - console.error("Unexpected type for Movable returned by setViewport"); - } - } - - const listOfItems: {[itemId: string]: unknown} = {}; - for (const [itemId, item] of world.getItemsState().entries()) { - listOfItems[itemId] = item; - } - - //console.warn('ANSWER PLAYER POSITIONS', listOfUsers); - if (answerFn === undefined && ALLOW_ARTILLERY === true) { - // For some reason, answerFn can be undefined if we use Artillery (?) - return; - } - - answerFn({ - users: listOfUsers, - groups: listOfGroups, - items: listOfItems - }); - } catch (e) { - console.error('An error occurred on "join_room" event'); - console.error(e); + const client : ExSocketInterface = ws as ExSocketInterface; + client.batchedMessages = new BatchMessage(); + client.batchTimeout = null; + client.emitInBatch = (payload: SubMessage): void => { + emitInBatch(client, payload); } - }); + client.disconnecting = false; + this.sockets.set(client.userId, client); - socket.on(SocketIoEvent.SET_VIEWPORT, (message: unknown): void => { - try { - if (!(message instanceof Buffer)) { - socket.emit(SocketIoEvent.MESSAGE_ERROR, {message: 'Invalid SET_VIEWPORT message. Expecting binary buffer.'}); - console.warn('Invalid SET_VIEWPORT message received (expecting binary buffer): ', message); - return; - } + // Let's log server load when a user joins + this.nbClientsGauge.inc(); + console.log(new Date().toISOString() + ' A user joined (', this.sockets.size, ' connected users)'); - const viewportMessage = ViewportMessage.deserializeBinary(new Uint8Array(message as ArrayBuffer)); - const viewport = viewportMessage.toObject(); + }, + message: (ws, arrayBuffer, isBinary) => { + const client = ws as ExSocketInterface; + const message = ClientToServerMessage.deserializeBinary(new Uint8Array(arrayBuffer)); - const Client = (socket as ExSocketInterface); - Client.viewport = viewport; - - const world = this.Worlds.get(Client.roomId); - if (!world) { - console.error("In SET_VIEWPORT, could not find world with id '", Client.roomId, "'"); - return; - } - world.setViewport(Client, Client.viewport); - } catch (e) { - console.error('An error occurred on "SET_VIEWPORT" event'); - console.error(e); + if (message.hasJoinroommessage()) { + this.handleJoinRoom(client, message.getJoinroommessage() as JoinRoomMessage); + } else if (message.hasViewportmessage()) { + this.handleViewport(client, message.getViewportmessage() as ViewportMessage); + } else if (message.hasUsermovesmessage()) { + this.handleUserMovesMessage(client, message.getUsermovesmessage() as UserMovesMessage); + } else if (message.hasSetplayerdetailsmessage()) { + this.handleSetPlayerDetails(client, message.getSetplayerdetailsmessage() as SetPlayerDetailsMessage); + } else if (message.hasSilentmessage()) { + this.handleSilentMessage(client, message.getSilentmessage() as SilentMessage); + } else if (message.hasItemeventmessage()) { + this.handleItemEvent(client, message.getItemeventmessage() as ItemEventMessage); } - }); - socket.on(SocketIoEvent.USER_POSITION, (message: unknown): void => { - //console.log(SockerIoEvent.USER_POSITION, userMovesMessage); - try { - if (!(message instanceof Buffer)) { - socket.emit(SocketIoEvent.MESSAGE_ERROR, {message: 'Invalid USER_POSITION message. Expecting binary buffer.'}); - console.warn('Invalid USER_POSITION message received (expecting binary buffer): ', message); - return; - } - - const userMovesMessage = UserMovesMessage.deserializeBinary(new Uint8Array(message as ArrayBuffer)); - const userMoves = userMovesMessage.toObject(); - - const position = userMoves.position; - if (position === undefined) { - throw new Error('Position not found in message'); - } - const viewport = userMoves.viewport; - if (viewport === undefined) { - throw new Error('Viewport not found in message'); - } - - let direction: string; - switch (position.direction) { - case Direction.UP: - direction = 'up'; - break; - case Direction.DOWN: - direction = 'down'; - break; - case Direction.LEFT: - direction = 'left'; - break; - case Direction.RIGHT: - direction = 'right'; - break; - default: - throw new Error("Unexpected direction"); - } - - const Client = (socket as ExSocketInterface); - - // sending to all clients in room except sender - Client.position = { - x: position.x, - y: position.y, - direction, - moving: position.moving, - }; - Client.viewport = viewport; - - // update position in the world - const world = this.Worlds.get(Client.roomId); - if (!world) { - console.error("In USER_POSITION, could not find world with id '", Client.roomId, "'"); - return; - } - world.updatePosition(Client, Client.position); - world.setViewport(Client, Client.viewport); - } catch (e) { - console.error('An error occurred on "user_position" event'); - console.error(e); - } - }); - - socket.on(SocketIoEvent.WEBRTC_SIGNAL, (data: unknown) => { - this.emitVideo((socket as ExSocketInterface), data); - }); - - socket.on(SocketIoEvent.WEBRTC_SCREEN_SHARING_SIGNAL, (data: unknown) => { - this.emitScreenSharing((socket as ExSocketInterface), data); - }); - - socket.on(SocketIoEvent.DISCONNECT, () => { - const Client = (socket as ExSocketInterface); + /* Ok is false if backpressure was built up, wait for drain */ + //let ok = ws.send(message, isBinary); + }, + drain: (ws) => { + console.log('WebSocket backpressure: ' + ws.getBufferedAmount()); + }, + close: (ws, code, message) => { + const Client = (ws as ExSocketInterface); try { + Client.disconnecting = true; //leave room this.leaveRoom(Client); @@ -377,112 +248,251 @@ export class IoSocketController { console.error('An error occurred on "disconnect"'); console.error(e); } + this.sockets.delete(Client.userId); // Let's log server load when a user leaves - const srvSockets = this.Io.sockets.sockets; this.nbClientsGauge.dec(); - console.log('A user left (', Object.keys(srvSockets).length, ' connected users)'); - //si.currentLoad().then(data => console.log('Current load: ', data.avgload)); - //si.currentLoad().then(data => console.log('CPU: ', data.currentload, '%')); - // End log server load + console.log('A user left (', this.sockets.size, ' connected users)'); + } + }) + + // TODO: finish this! + /*this.Io.on(SocketIoEvent.CONNECTION, (socket: Socket) => { + + + + socket.on(SocketIoEvent.WEBRTC_SIGNAL, (data: unknown) => { + this.emitVideo((socket as ExSocketInterface), data); }); - // Let's send the user id to the user - socket.on(SocketIoEvent.SET_PLAYER_DETAILS, (message: unknown, answerFn) => { - //console.log(SocketIoEvent.SET_PLAYER_DETAILS, message); - if (!(message instanceof Buffer)) { - socket.emit(SocketIoEvent.MESSAGE_ERROR, {message: 'Invalid SET_PLAYER_DETAILS message. Expecting binary buffer.'}); - console.warn('Invalid SET_PLAYER_DETAILS message received (expecting binary buffer): ', message); - return; - } - const playerDetailsMessage = SetPlayerDetailsMessage.deserializeBinary(new Uint8Array(message)); - const playerDetails = { - name: playerDetailsMessage.getName(), - characterLayers: playerDetailsMessage.getCharacterlayersList() - }; - //console.log(SocketIoEvent.SET_PLAYER_DETAILS, playerDetails); - if (!isSetPlayerDetailsMessage(playerDetails)) { - socket.emit(SocketIoEvent.MESSAGE_ERROR, {message: 'Invalid SET_PLAYER_DETAILS message.'}); - console.warn('Invalid SET_PLAYER_DETAILS message received: ', playerDetails); - return; - } - const Client = (socket as ExSocketInterface); - Client.name = playerDetails.name; - Client.characterLayers = playerDetails.characterLayers; - // Artillery fails when receiving an acknowledgement that is not a JSON object - if (!Client.isArtillery) { - answerFn(Client.userId); - } + socket.on(SocketIoEvent.WEBRTC_SCREEN_SHARING_SIGNAL, (data: unknown) => { + this.emitScreenSharing((socket as ExSocketInterface), data); }); - socket.on(SocketIoEvent.SET_SILENT, (silent: unknown) => { - //console.log(SocketIoEvent.SET_SILENT, silent); - if (typeof silent !== "boolean") { - socket.emit(SocketIoEvent.MESSAGE_ERROR, {message: 'Invalid SET_SILENT message.'}); - console.warn('Invalid SET_SILENT message received: ', silent); - return; - } + });*/ + } - try { - const Client = (socket as ExSocketInterface); + private emitError(Client: ExSocketInterface, message: string): void { + const errorMessage = new ErrorMessage(); + errorMessage.setMessage(message); - // update position in the world - const world = this.Worlds.get(Client.roomId); - if (!world) { - console.error("In SET_SILENT, could not find world with id '", Client.roomId, "'"); - return; - } - world.setSilent(Client, silent); - } catch (e) { - console.error('An error occurred on "SET_SILENT"'); - console.error(e); - } - }); + const serverToClientMessage = new ServerToClientMessage(); + serverToClientMessage.setErrormessage(errorMessage); - socket.on(SocketIoEvent.ITEM_EVENT, (message: unknown) => { - if (!(message instanceof Buffer)) { - socket.emit(SocketIoEvent.MESSAGE_ERROR, {message: 'Invalid ITEM_EVENT message. Expecting binary buffer.'}); - console.warn('Invalid ITEM_EVENT message received (expecting binary buffer): ', message); - return; - } - const itemEventMessage = ItemEventMessage.deserializeBinary(new Uint8Array(message)); + if (!Client.disconnecting) { + Client.send(serverToClientMessage.serializeBinary().buffer); + } + console.warn(message); + } - const itemEvent = ProtobufUtils.toItemEvent(itemEventMessage); + private handleJoinRoom(Client: ExSocketInterface, message: JoinRoomMessage): void { + try { + /*if (!isJoinRoomMessageInterface(message.toObject())) { + console.log(message.toObject()) + this.emitError(Client, 'Invalid JOIN_ROOM message received: ' + message.toObject().toString()); + return; + }*/ + const roomId = message.getRoomid(); - /*if (!isItemEventMessageInterface(itemEvent)) { - socket.emit(SocketIoEvent.MESSAGE_ERROR, {message: 'Invalid ITEM_EVENT message.'}); - console.warn('Invalid ITEM_EVENT message received: ', itemEvent); - return; - }*/ - try { - const Client = (socket as ExSocketInterface); + if (Client.roomId === roomId) { + return; + } - //socket.to(Client.roomId).emit(SocketIoEvent.ITEM_EVENT, itemEvent); + //leave previous room + this.leaveRoom(Client); - const world = this.Worlds.get(Client.roomId); - if (!world) { - console.error("Could not find world with id '", Client.roomId, "'"); - return; + //join new previous room + const world = this.joinRoom(Client, roomId, ProtobufUtils.toPointInterface(message.getPosition() as PositionMessage)); + + const things = world.setViewport(Client, (message.getViewport() as ViewportMessage).toObject()); + + const roomJoinedMessage = new RoomJoinedMessage(); + + for (const thing of things) { + if (thing instanceof User) { + const player: ExSocketInterface|undefined = this.sockets.get(thing.id); + if (player === undefined) { + console.warn('Something went wrong. The World contains a user "'+thing.id+"' but this user does not exist in the sockets list!"); + continue; } - const subMessage = new SubMessage(); - subMessage.setItemeventmessage(itemEventMessage); + const userJoinedMessage = new UserJoinedMessage(); + userJoinedMessage.setUserid(thing.id); + userJoinedMessage.setName(player.name); + userJoinedMessage.setCharacterlayersList(player.characterLayers); + userJoinedMessage.setPosition(ProtobufUtils.toPositionMessage(player.position)); - // Let's send the event without using the SocketIO room. - for (const user of world.getUsers().values()) { - const client = this.searchClientByIdOrFail(user.id); - //client.emit(SocketIoEvent.ITEM_EVENT, itemEvent); - emitInBatch(client, SocketIoEvent.ITEM_EVENT, subMessage); - } + roomJoinedMessage.addUser(userJoinedMessage); + } else if (thing instanceof Group) { + const groupUpdateMessage = new GroupUpdateMessage(); + groupUpdateMessage.setGroupid(thing.getId()); + groupUpdateMessage.setPosition(ProtobufUtils.toPointMessage(thing.getPosition())); - world.setItemState(itemEvent.itemId, itemEvent.state); - } catch (e) { - console.error('An error occurred on "item_event"'); - console.error(e); + roomJoinedMessage.addGroup(groupUpdateMessage); + } else { + console.error("Unexpected type for Movable returned by setViewport"); } - }); - }); + } + + for (const [itemId, item] of world.getItemsState().entries()) { + const itemStateMessage = new ItemStateMessage(); + itemStateMessage.setItemid(itemId); + itemStateMessage.setStatejson(JSON.stringify(item)); + + roomJoinedMessage.addItem(itemStateMessage); + } + + const serverToClientMessage = new ServerToClientMessage(); + serverToClientMessage.setRoomjoinedmessage(roomJoinedMessage); + + if (!Client.disconnecting) { + Client.send(serverToClientMessage.serializeBinary().buffer, true); + } + } catch (e) { + console.error('An error occurred on "join_room" event'); + console.error(e); + } + } + + private handleViewport(client: ExSocketInterface, viewportMessage: ViewportMessage) { + try { + const viewport = viewportMessage.toObject(); + + client.viewport = viewport; + + const world = this.Worlds.get(client.roomId); + if (!world) { + console.error("In SET_VIEWPORT, could not find world with id '", client.roomId, "'"); + return; + } + world.setViewport(client, client.viewport); + } catch (e) { + console.error('An error occurred on "SET_VIEWPORT" event'); + console.error(e); + } + } + + private handleUserMovesMessage(client: ExSocketInterface, userMovesMessage: UserMovesMessage) { + //console.log(SockerIoEvent.USER_POSITION, userMovesMessage); + try { + const userMoves = userMovesMessage.toObject(); + + const position = userMoves.position; + if (position === undefined) { + throw new Error('Position not found in message'); + } + const viewport = userMoves.viewport; + if (viewport === undefined) { + throw new Error('Viewport not found in message'); + } + + let direction: string; + switch (position.direction) { + case Direction.UP: + direction = 'up'; + break; + case Direction.DOWN: + direction = 'down'; + break; + case Direction.LEFT: + direction = 'left'; + break; + case Direction.RIGHT: + direction = 'right'; + break; + default: + throw new Error("Unexpected direction"); + } + + // sending to all clients in room except sender + client.position = { + x: position.x, + y: position.y, + direction, + moving: position.moving, + }; + client.viewport = viewport; + + // update position in the world + const world = this.Worlds.get(client.roomId); + if (!world) { + console.error("In USER_POSITION, could not find world with id '", client.roomId, "'"); + return; + } + world.updatePosition(client, client.position); + world.setViewport(client, client.viewport); + } catch (e) { + console.error('An error occurred on "user_position" event'); + console.error(e); + } + } + + private handleSetPlayerDetails(client: ExSocketInterface, playerDetailsMessage: SetPlayerDetailsMessage) { + const playerDetails = { + name: playerDetailsMessage.getName(), + characterLayers: playerDetailsMessage.getCharacterlayersList() + }; + //console.log(SocketIoEvent.SET_PLAYER_DETAILS, playerDetails); + if (!isSetPlayerDetailsMessage(playerDetails)) { + this.emitError(client, 'Invalid SET_PLAYER_DETAILS message received: '); + return; + } + client.name = playerDetails.name; + client.characterLayers = playerDetails.characterLayers; + + + const setUserIdMessage = new SetUserIdMessage(); + setUserIdMessage.setUserid(client.userId); + + const serverToClientMessage = new ServerToClientMessage(); + serverToClientMessage.setSetuseridmessage(setUserIdMessage); + + if (!client.disconnecting) { + client.send(serverToClientMessage.serializeBinary().buffer, true); + } + } + + private handleSilentMessage(client: ExSocketInterface, silentMessage: SilentMessage) { + try { + // update position in the world + const world = this.Worlds.get(client.roomId); + if (!world) { + console.error("In handleSilentMessage, could not find world with id '", client.roomId, "'"); + return; + } + world.setSilent(client, silentMessage.getSilent()); + } catch (e) { + console.error('An error occurred on "handleSilentMessage"'); + console.error(e); + } + } + + private handleItemEvent(ws: ExSocketInterface, itemEventMessage: ItemEventMessage) { + const itemEvent = ProtobufUtils.toItemEvent(itemEventMessage); + + try { + const world = this.Worlds.get(ws.roomId); + if (!world) { + console.error("Could not find world with id '", ws.roomId, "'"); + return; + } + + const subMessage = new SubMessage(); + subMessage.setItemeventmessage(itemEventMessage); + + // Let's send the event without using the SocketIO room. + for (const user of world.getUsers().values()) { + const client = this.searchClientByIdOrFail(user.id); + //client.emit(SocketIoEvent.ITEM_EVENT, itemEvent); + emitInBatch(client, subMessage); + } + + world.setItemState(itemEvent.itemId, itemEvent.state); + } catch (e) { + console.error('An error occurred on "item_event"'); + console.error(e); + } } emitVideo(socket: ExSocketInterface, data: unknown){ @@ -542,7 +552,7 @@ export class IoSocketController { } } //user leave previous room - Client.leave(Client.roomId); + //Client.leave(Client.roomId); } finally { this.nbClientsPerRoomGauge.dec({ room: Client.roomId }); delete Client.roomId; @@ -552,7 +562,7 @@ export class IoSocketController { private joinRoom(Client : ExSocketInterface, roomId: string, position: PointInterface): World { //join user in room - Client.join(roomId); + //Client.join(roomId); this.nbClientsPerRoomGauge.inc({ room: roomId }); Client.roomId = roomId; Client.position = position; @@ -570,6 +580,9 @@ export class IoSocketController { const clientUser = this.searchClientByIdOrFail(thing.id); const userJoinedMessage = new UserJoinedMessage(); + if (!Number.isInteger(clientUser.userId)) { + throw new Error('clientUser.userId is not an integer '+clientUser.userId); + } userJoinedMessage.setUserid(clientUser.userId); userJoinedMessage.setName(clientUser.name); userJoinedMessage.setCharacterlayersList(clientUser.characterLayers); @@ -578,7 +591,7 @@ export class IoSocketController { const subMessage = new SubMessage(); subMessage.setUserjoinedmessage(userJoinedMessage); - emitInBatch(clientListener, SocketIoEvent.JOIN_ROOM, subMessage); + emitInBatch(clientListener, subMessage); } else if (thing instanceof Group) { this.emitCreateUpdateGroupEvent(clientListener, thing); } else { @@ -596,7 +609,7 @@ export class IoSocketController { const subMessage = new SubMessage(); subMessage.setUsermovedmessage(userMovedMessage); - clientListener.emitInBatch(SocketIoEvent.USER_MOVED, subMessage); + clientListener.emitInBatch(subMessage); //console.log("Sending USER_MOVED event"); } else if (thing instanceof Group) { this.emitCreateUpdateGroupEvent(clientListener, thing); @@ -627,7 +640,7 @@ export class IoSocketController { return world; } - private emitCreateUpdateGroupEvent(socket: Socket, group: Group): void { + private emitCreateUpdateGroupEvent(client: ExSocketInterface, group: Group): void { const position = group.getPosition(); const pointMessage = new PointMessage(); pointMessage.setX(Math.floor(position.x)); @@ -639,8 +652,7 @@ export class IoSocketController { const subMessage = new SubMessage(); subMessage.setGroupupdatemessage(groupUpdateMessage); - const client : ExSocketInterface = socket as ExSocketInterface; - emitInBatch(client, SocketIoEvent.GROUP_CREATE_UPDATE, subMessage); + emitInBatch(client, subMessage); //socket.emit(SocketIoEvent.GROUP_CREATE_UPDATE, groupUpdateMessage.serializeBinary().buffer); } @@ -652,7 +664,7 @@ export class IoSocketController { subMessage.setGroupdeletemessage(groupDeleteMessage); const client : ExSocketInterface = socket as ExSocketInterface; - emitInBatch(client, SocketIoEvent.GROUP_DELETE, subMessage); + emitInBatch(client, subMessage); } private emitUserLeftEvent(socket: Socket, userId: number): void { @@ -663,7 +675,7 @@ export class IoSocketController { subMessage.setUserleftmessage(userLeftMessage); const client : ExSocketInterface = socket as ExSocketInterface; - emitInBatch(client, SocketIoEvent.USER_LEFT, subMessage); + emitInBatch(client, subMessage); } /** @@ -672,6 +684,10 @@ export class IoSocketController { * @param roomId */ joinWebRtcRoom(socket: ExSocketInterface, roomId: string) { + + // TODO: REBUILD THIS + return; + if (socket.webRtcRoomId === roomId) { return; } @@ -734,6 +750,9 @@ export class IoSocketController { //disconnect user disConnectedUser(userId: number, group: Group) { + // TODO: rebuild this + return; + const Client = this.searchClientByIdOrFail(userId); Client.to("webrtcroom"+group.getId()).emit(SocketIoEvent.WEBRTC_DISCONNECT, { userId: userId @@ -761,4 +780,5 @@ export class IoSocketController { public getWorlds(): Map { return this.Worlds; } + } diff --git a/back/src/Controller/MapController.ts b/back/src/Controller/MapController.ts index 58ce40a9..ad6f5548 100644 --- a/back/src/Controller/MapController.ts +++ b/back/src/Controller/MapController.ts @@ -1,29 +1,33 @@ -import express from "express"; -import {Application, Request, Response} from "express"; import {OK} from "http-status-codes"; import {URL_ROOM_STARTED} from "../Enum/EnvironmentVariable"; +import {HttpRequest, HttpResponse, TemplatedApp} from "uWebSockets.js"; +import {BaseController} from "./BaseController"; -export class MapController { - App: Application; +export class MapController extends BaseController{ - constructor(App: Application) { + constructor(private App : TemplatedApp) { + super(); this.App = App; this.getStartMap(); - this.assetMaps(); } - assetMaps() { - this.App.use('/map/files', express.static('src/Assets/Maps')); - } // Returns a map mapping map name to file name of the map getStartMap() { - this.App.get("/start-map", (req: Request, res: Response) => { - const url = req.headers.host?.replace('api.', 'maps.') + URL_ROOM_STARTED; - res.status(OK).send({ + this.App.options("/start-map", (res: HttpResponse, req: HttpRequest) => { + this.addCorsHeaders(res); + + res.end(); + }); + + this.App.get("/start-map", (res: HttpResponse, req: HttpRequest) => { + this.addCorsHeaders(res); + + const url = req.getHeader('host').replace('api.', 'maps.') + URL_ROOM_STARTED; + res.writeStatus("200 OK").end(JSON.stringify({ mapUrlStart: url, startInstance: "global" - }); + })); }); } } diff --git a/back/src/Model/Websocket/ExSocketInterface.ts b/back/src/Model/Websocket/ExSocketInterface.ts index ace374f4..36265143 100644 --- a/back/src/Model/Websocket/ExSocketInterface.ts +++ b/back/src/Model/Websocket/ExSocketInterface.ts @@ -1,11 +1,11 @@ -import {Socket} from "socket.io"; import {PointInterface} from "./PointInterface"; import {Identificable} from "./Identificable"; import {TokenInterface} from "../../Controller/AuthenticateController"; import {ViewportInterface} from "_Model/Websocket/ViewportMessage"; import {BatchMessage, SubMessage} from "../../Messages/generated/messages_pb"; +import {WebSocket} from "uWebSockets.js" -export interface ExSocketInterface extends Socket, Identificable { +export interface ExSocketInterface extends WebSocket, Identificable { token: string; roomId: string; webRtcRoomId: string|undefined; @@ -19,7 +19,8 @@ export interface ExSocketInterface extends Socket, Identificable { /** * Pushes an event that will be sent in the next batch of events */ - emitInBatch: (event: string, payload: SubMessage) => void; + emitInBatch: (payload: SubMessage) => void; batchedMessages: BatchMessage; batchTimeout: NodeJS.Timeout|null; + disconnecting: boolean } diff --git a/back/src/Model/Websocket/ProtobufUtils.ts b/back/src/Model/Websocket/ProtobufUtils.ts index aa6810a4..42adbd4c 100644 --- a/back/src/Model/Websocket/ProtobufUtils.ts +++ b/back/src/Model/Websocket/ProtobufUtils.ts @@ -1,8 +1,9 @@ import {PointInterface} from "./PointInterface"; -import {ItemEventMessage, PositionMessage} from "../../Messages/generated/messages_pb"; +import {ItemEventMessage, PointMessage, PositionMessage} from "../../Messages/generated/messages_pb"; import {ExSocketInterface} from "_Model/Websocket/ExSocketInterface"; import Direction = PositionMessage.Direction; import {ItemEventMessageInterface} from "_Model/Websocket/ItemEventMessage"; +import {PositionInterface} from "_Model/PositionInterface"; export class ProtobufUtils { @@ -34,6 +35,42 @@ export class ProtobufUtils { return position; } + public static toPointInterface(position: PositionMessage): PointInterface { + let direction: string; + switch (position.getDirection()) { + case Direction.UP: + direction = 'up'; + break; + case Direction.DOWN: + direction = 'down'; + break; + case Direction.LEFT: + direction = 'left'; + break; + case Direction.RIGHT: + direction = 'right'; + break; + default: + throw new Error("Unexpected direction"); + } + + // sending to all clients in room except sender + return { + x: position.getX(), + y: position.getY(), + direction, + moving: position.getMoving(), + }; + } + + public static toPointMessage(point: PositionInterface): PointMessage { + const position = new PointMessage(); + position.setX(Math.floor(point.x)); + position.setY(Math.floor(point.y)); + + return position; + } + public static toItemEvent(itemEventMessage: ItemEventMessage): ItemEventMessageInterface { return { itemId: itemEventMessage.getItemid(), diff --git a/back/src/Model/World.ts b/back/src/Model/World.ts index 75ac1bdc..8e645c74 100644 --- a/back/src/Model/World.ts +++ b/back/src/Model/World.ts @@ -74,8 +74,8 @@ export class World { this.users.delete(user.userId); if (userObj !== undefined) { - this.positionNotifier.leave(userObj); this.positionNotifier.removeViewport(userObj); + this.positionNotifier.leave(userObj); } } diff --git a/back/src/Server/server/app.ts b/back/src/Server/server/app.ts new file mode 100644 index 00000000..800353c2 --- /dev/null +++ b/back/src/Server/server/app.ts @@ -0,0 +1,13 @@ +import { App as _App, AppOptions } from 'uWebSockets.js'; +import BaseApp from './baseapp'; +import { extend } from './utils'; +import { UwsApp } from './types'; + +class App extends (_App) { + constructor(options: AppOptions = {}) { + super(options); + extend(this, new BaseApp()); + } +} + +export default App; diff --git a/back/src/Server/server/baseapp.ts b/back/src/Server/server/baseapp.ts new file mode 100644 index 00000000..dbac5929 --- /dev/null +++ b/back/src/Server/server/baseapp.ts @@ -0,0 +1,220 @@ +import { readdirSync, statSync } from 'fs'; +import { join, relative } from 'path'; +import { Readable } from 'stream'; +import { us_listen_socket_close, TemplatedApp, HttpResponse, HttpRequest } from 'uWebSockets.js'; +//import { watch } from 'chokidar'; + +import { wsConfig } from './livereload'; +import sendFile from './sendfile'; +import formData from './formdata'; +import loadroutes from './loadroutes'; +import { graphqlPost, graphqlWs } from './graphql'; +import { stob } from './utils'; +import { SendFileOptions, Handler } from './types'; + +const contTypes = ['application/x-www-form-urlencoded', 'multipart/form-data']; +const noOp = () => true; + +const handleBody = (res: HttpResponse, req: HttpRequest) => { + const contType = req.getHeader('content-type'); + + res.bodyStream = function() { + const stream = new Readable(); + stream._read = noOp; + + this.onData((ab, isLast) => { + // uint and then slicing is bit faster than slice and then uint + stream.push(new Uint8Array(ab.slice(ab.byteOffset, ab.byteLength))); + if (isLast) { + stream.push(null); + } + }); + + return stream; + }; + + res.body = () => stob(res.bodyStream()); + + if (contType.indexOf('application/json') > -1) + res.json = async () => JSON.parse(await res.body()); + if (contTypes.map(t => contType.indexOf(t) > -1).indexOf(true) > -1) + res.formData = formData.bind(res, contType); +}; + +class BaseApp { + _staticPaths = new Map(); + //_watched = new Map(); + _sockets = new Map(); + __livereloadenabled = false; + ws!: TemplatedApp['ws']; + get!: TemplatedApp['get']; + _post!: TemplatedApp['post']; + _put!: TemplatedApp['put']; + _patch!: TemplatedApp['patch']; + _listen!: TemplatedApp['listen']; + + file(pattern: string, filePath: string, options: SendFileOptions = {}) { + pattern=pattern.replace(/\\/g,'/'); + if (this._staticPaths.has(pattern)) { + if (options.failOnDuplicateRoute) + throw Error( + `Error serving '${filePath}' for '${pattern}', already serving '${ + this._staticPaths.get(pattern)[0] + }' file for this pattern.` + ); + else if (!options.overwriteRoute) return this; + } + + if (options.livereload && !this.__livereloadenabled) { + this.ws('/__sifrrLiveReload', wsConfig); + this.file('/livereload.js', join(__dirname, './livereloadjs.js')); + this.__livereloadenabled = true; + } + + this._staticPaths.set(pattern, [filePath, options]); + this.get(pattern, this._serveStatic); + return this; + } + + folder(prefix: string, folder: string, options: SendFileOptions, base: string = folder) { + // not a folder + if (!statSync(folder).isDirectory()) { + throw Error('Given path is not a directory: ' + folder); + } + + // ensure slash in beginning and no trailing slash for prefix + if (prefix[0] !== '/') prefix = '/' + prefix; + if (prefix[prefix.length - 1] === '/') prefix = prefix.slice(0, -1); + + // serve folder + const filter = options ? options.filter || noOp : noOp; + readdirSync(folder).forEach(file => { + // Absolute path + const filePath = join(folder, file); + // Return if filtered + if (!filter(filePath)) return; + + if (statSync(filePath).isDirectory()) { + // Recursive if directory + this.folder(prefix, filePath, options, base); + } else { + this.file(prefix + '/' + relative(base, filePath), filePath, options); + } + }); + + /*if (options && options.watch) { + if (!this._watched.has(folder)) { + const w = watch(folder); + + w.on('unlink', filePath => { + const url = '/' + relative(base, filePath); + this._staticPaths.delete(prefix + url); + }); + + w.on('add', filePath => { + const url = '/' + relative(base, filePath); + this.file(prefix + url, filePath, options); + }); + + this._watched.set(folder, w); + } + }*/ + return this; + } + + _serveStatic(res: HttpResponse, req: HttpRequest) { + res.onAborted(noOp); + const options = this._staticPaths.get(req.getUrl()); + if (typeof options === 'undefined') { + res.writeStatus('404 Not Found'); + res.end(); + } else sendFile(res, req, options[0], options[1]); + } + + post(pattern: string, handler: Handler) { + if (typeof handler !== 'function') + throw Error(`handler should be a function, given ${typeof handler}.`); + this._post(pattern, (res, req) => { + handleBody(res, req); + handler(res, req); + }); + return this; + } + + put(pattern: string, handler: Handler) { + if (typeof handler !== 'function') + throw Error(`handler should be a function, given ${typeof handler}.`); + this._put(pattern, (res, req) => { + handleBody(res, req); + + handler(res, req); + }); + return this; + } + + patch(pattern: string, handler: Handler) { + if (typeof handler !== 'function') + throw Error(`handler should be a function, given ${typeof handler}.`); + this._patch(pattern, (res, req) => { + handleBody(res, req); + + handler(res, req); + }); + return this; + } + + graphql(route: string, schema, graphqlOptions: any = {}, uwsOptions = {}, graphql) { + const handler = graphqlPost(schema, graphqlOptions, graphql); + this.post(route, handler); + this.ws(route, graphqlWs(schema, graphqlOptions, uwsOptions, graphql)); + // this.get(route, handler); + if (graphqlOptions && graphqlOptions.graphiqlPath) + this.file(graphqlOptions.graphiqlPath, join(__dirname, './graphiql.html')); + return this; + } + + load(dir: string, options) { + loadroutes.call(this, dir, options); + return this; + } + + listen(h: string | number, p: Function | number = noOp, cb?: Function) { + if (typeof p === 'number' && typeof h === 'string') { + this._listen(h, p, socket => { + this._sockets.set(p, socket); + if (cb === undefined) { + throw new Error('cb undefined'); + } + cb(socket); + }); + } else if (typeof h === 'number' && typeof p === 'function') { + this._listen(h, socket => { + this._sockets.set(h, socket); + p(socket); + }); + } else { + throw Error( + 'Argument types: (host: string, port: number, cb?: Function) | (port: number, cb?: Function)' + ); + } + + return this; + } + + close(port: null | number = null) { + //this._watched.forEach(v => v.close()); + //this._watched.clear(); + if (port) { + this._sockets.has(port) && us_listen_socket_close(this._sockets.get(port)); + this._sockets.delete(port); + } else { + this._sockets.forEach(app => { + us_listen_socket_close(app); + }); + this._sockets.clear(); + } + return this; + } +} + +export default BaseApp; diff --git a/back/src/Server/server/cluster.ts b/back/src/Server/server/cluster.ts new file mode 100644 index 00000000..5b875327 --- /dev/null +++ b/back/src/Server/server/cluster.ts @@ -0,0 +1,48 @@ +const noop = (a, b) => {}; + +export default class Cluster { + apps: any[]; + listens = {}; + // apps = [ { app: SifrrServerApp, port/ports: int } ] + constructor(apps) { + if (!Array.isArray(apps)) apps = [apps]; + this.apps = apps; + } + + listen(onListen = noop) { + for (let i = 0; i < this.apps.length; i++) { + const config = this.apps[i]; + let { app, port, ports } = config; + if (!Array.isArray(ports) || ports.length === 0) { + ports = [port]; + } + ports.forEach(p => { + if (typeof p !== 'number') throw Error(`Port should be a number, given ${p}`); + if (this.listens[p]) return; + + app.listen(p, socket => { + onListen.call(app, socket, p); + }); + this.listens[p] = app; + }); + } + return this; + } + + closeAll() { + Object.keys(this.listens).forEach(port => { + this.close(port); + }); + return this; + } + + close(port = null) { + if (port) { + this.listens[port] && this.listens[port].close(port); + delete this.listens[port]; + } else { + this.closeAll(); + } + return this; + } +} diff --git a/back/src/Server/server/formdata.ts b/back/src/Server/server/formdata.ts new file mode 100644 index 00000000..419e6c6b --- /dev/null +++ b/back/src/Server/server/formdata.ts @@ -0,0 +1,99 @@ +import { createWriteStream } from 'fs'; +import { join, dirname } from 'path'; +import Busboy from 'busboy'; +import mkdirp from 'mkdirp'; + +function formData( + contType: string, + options: busboy.BusboyConfig & { + abortOnLimit?: boolean; + tmpDir?: string; + onFile?: ( + fieldname: string, + file: NodeJS.ReadableStream, + filename: string, + encoding: string, + mimetype: string + ) => string; + onField?: (fieldname: string, value: any) => void; + filename?: (oldName: string) => string; + } = {} +) { + options.headers = { + 'content-type': contType + }; + + return new Promise((resolve, reject) => { + const busb = new Busboy(options); + const ret = {}; + + this.bodyStream().pipe(busb); + + busb.on('limit', () => { + if (options.abortOnLimit) { + reject(Error('limit')); + } + }); + + busb.on('file', function(fieldname, file, filename, encoding, mimetype) { + const value = { + filename, + encoding, + mimetype, + filePath: undefined + }; + + if (typeof options.tmpDir === 'string') { + if (typeof options.filename === 'function') filename = options.filename(filename); + const fileToSave = join(options.tmpDir, filename); + mkdirp(dirname(fileToSave)); + + file.pipe(createWriteStream(fileToSave)); + value.filePath = fileToSave; + } + if (typeof options.onFile === 'function') { + value.filePath = + options.onFile(fieldname, file, filename, encoding, mimetype) || value.filePath; + } + + setRetValue(ret, fieldname, value); + }); + + busb.on('field', function(fieldname, value) { + if (typeof options.onField === 'function') options.onField(fieldname, value); + + setRetValue(ret, fieldname, value); + }); + + busb.on('finish', function() { + resolve(ret); + }); + + busb.on('error', reject); + }); +} + +function setRetValue( + ret: { [x: string]: any }, + fieldname: string, + value: { filename: string; encoding: string; mimetype: string; filePath?: string } | any +) { + if (fieldname.slice(-2) === '[]') { + fieldname = fieldname.slice(0, fieldname.length - 2); + if (Array.isArray(ret[fieldname])) { + ret[fieldname].push(value); + } else { + ret[fieldname] = [value]; + } + } else { + if (Array.isArray(ret[fieldname])) { + ret[fieldname].push(value); + } else if (ret[fieldname]) { + ret[fieldname] = [ret[fieldname], value]; + } else { + ret[fieldname] = value; + } + } +} + +export default formData; diff --git a/back/src/Server/server/graphiql.html b/back/src/Server/server/graphiql.html new file mode 100644 index 00000000..7ce03921 --- /dev/null +++ b/back/src/Server/server/graphiql.html @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + +
Loading...
+ + + diff --git a/back/src/Server/server/graphql.ts b/back/src/Server/server/graphql.ts new file mode 100644 index 00000000..63a2bdaa --- /dev/null +++ b/back/src/Server/server/graphql.ts @@ -0,0 +1,138 @@ +import { parse } from 'query-string'; +import { createAsyncIterator, forAwaitEach, isAsyncIterable } from 'iterall'; +import { HttpResponse, HttpRequest } from 'uWebSockets.js'; +// client -> server +const GQL_START = 'start'; +const GQL_STOP = 'stop'; +// server -> client +const GQL_DATA = 'data'; +const GQL_QUERY = 'query'; + +async function getGraphqlParams(res: HttpResponse, req: HttpRequest) { + // query and variables + const queryParams = parse(req.getQuery()); + let { query, variables, operationName } = queryParams; + if (typeof variables === 'string') variables = JSON.parse(variables); + + // body + if (res && typeof res.json === 'function') { + const data = await res.json(); + query = data.query || query; + variables = data.variables || variables; + operationName = data.operationName || operationName; + } + return { + source: query, + variableValues: variables, + operationName + }; +} + +function graphqlPost(schema, graphqlOptions: any = {}, graphql: any = {}) { + const execute = graphql.graphql || require('graphql').graphql; + + return async (res: HttpResponse, req: HttpRequest) => { + res.onAborted(console.error); + + res.writeHeader('content-type', 'application/json'); + res.end( + JSON.stringify( + await execute({ + schema, + ...(await getGraphqlParams(res, req)), + ...graphqlOptions, + contextValue: { + res, + req, + ...(graphqlOptions && + (graphqlOptions.contextValue || + (graphqlOptions.contextFxn && (await graphqlOptions.contextFxn(res, req))))) + } + }) + ) + ); + }; +} + +function stopGqsSubscription(operations, reqOpId) { + if (!reqOpId) return; + operations[reqOpId] && operations[reqOpId].return && operations[reqOpId].return(); + delete operations[reqOpId]; +} + +function graphqlWs(schema, graphqlOptions: any = {}, uwsOptions: any = {}, graphql: any = {}) { + const subscribe = graphql.subscribe || require('graphql').subscribe; + const execute = graphql.graphql || require('graphql').graphql; + + return { + open: (ws, req) => { + ws.req = req; + ws.operations = {}; + ws.opId = 1; + }, + message: async (ws, message) => { + const { type, payload = {}, id: reqOpId } = JSON.parse(Buffer.from(message).toString('utf8')); + let opId; + if (reqOpId) { + opId = reqOpId; + } else { + opId = ws.opId++; + } + + const params = { + schema, + source: payload.query, + variableValues: payload.variables, + operationName: payload.operationName, + contextValue: { + ws, + ...(graphqlOptions && + (graphqlOptions.contextValue || + (graphqlOptions.contextFxn && (await graphqlOptions.contextFxn(ws))))) + }, + ...graphqlOptions + }; + + switch (type) { + case GQL_START: + stopGqsSubscription(ws.operations, opId); + + // eslint-disable-next-line no-case-declarations + let asyncIterable = await subscribe( + params.schema, + graphql.parse(params.source), + params.rootValue, + params.contextValue, + params.variableValues, + params.operationName + ); + asyncIterable = isAsyncIterable(asyncIterable) + ? asyncIterable + : createAsyncIterator([asyncIterable]); + + forAwaitEach(asyncIterable, result => + ws.send( + JSON.stringify({ + id: opId, + type: GQL_DATA, + payload: result + }) + ) + ); + break; + + case GQL_STOP: + stopGqsSubscription(ws.operations, reqOpId); + break; + + default: + ws.send(JSON.stringify({ payload: await execute(params), type: GQL_QUERY, id: opId })); + break; + } + }, + idleTimeout: 24 * 60 * 60, + ...uwsOptions + }; +} + +export { graphqlPost, graphqlWs }; diff --git a/back/src/Server/server/livereload.ts b/back/src/Server/server/livereload.ts new file mode 100644 index 00000000..787c871b --- /dev/null +++ b/back/src/Server/server/livereload.ts @@ -0,0 +1,35 @@ +import { WebSocketBehavior, WebSocket } from 'uWebSockets.js'; + +const websockets = {}; +let id = 0; + +const wsConfig: WebSocketBehavior = { + open: (ws: WebSocket & { id: number }, req) => { + websockets[id] = { + dirty: false + }; + ws.id = id; + console.log('websocket connected: ', id); + id++; + }, + message: ws => { + ws.send(JSON.stringify(websockets[ws.id].dirty)); + websockets[ws.id].dirty = false; + }, + close: (ws, code, message) => { + delete websockets[ws.id]; + console.log( + `websocket disconnected with code ${code} and message ${message}:`, + ws.id, + websockets + ); + } +}; + +const sendSignal = (type: string, path: string) => { + console.log(type, 'signal for file: ', path); + for (let i in websockets) websockets[i].dirty = true; +}; + +export default { websockets, wsConfig, sendSignal }; +export { websockets, wsConfig, sendSignal }; diff --git a/back/src/Server/server/livereloadjs.js b/back/src/Server/server/livereloadjs.js new file mode 100644 index 00000000..04839578 --- /dev/null +++ b/back/src/Server/server/livereloadjs.js @@ -0,0 +1,47 @@ +const loc = window.location; +let path; +if (loc.protocol === 'https:') { + path = 'wss:'; +} else { + path = 'ws:'; +} +path += '//' + loc.host + '/__sifrrLiveReload'; + +let ws, + ttr = 500, + timeout; + +function newWsConnection() { + ws = new WebSocket(path); + ws.onopen = function() { + ttr = 500; + checkMessage(); + console.log('watching for file changes through sifrr-server livereload mode.'); + }; + ws.onmessage = function(event) { + if (JSON.parse(event.data)) { + console.log('Files changed, refreshing page.'); + location.reload(); + } + }; + ws.onerror = e => { + console.error('Webosocket error: ', e); + console.log('Retrying after ', ttr / 4, 'ms'); + ttr *= 4; + }; + ws.onclose = e => { + console.error(`Webosocket closed with code \${e.code} error \${e.message}`); + }; +} + +function checkMessage() { + if (!ws) return; + if (ws.readyState === WebSocket.OPEN) ws.send(''); + else if (ws.readyState === WebSocket.CLOSED) newWsConnection(); + + if (timeout) clearTimeout(timeout); + timeout = setTimeout(checkMessage, ttr); +} + +newWsConnection(); +setTimeout(checkMessage, ttr); diff --git a/back/src/Server/server/loadroutes.ts b/back/src/Server/server/loadroutes.ts new file mode 100644 index 00000000..3761d762 --- /dev/null +++ b/back/src/Server/server/loadroutes.ts @@ -0,0 +1,42 @@ +import { statSync, readdirSync } from 'fs'; +import { join, extname } from 'path'; + +function loadRoutes(dir, { filter = () => true, basePath = '' } = {}) { + let files; + const paths = []; + + if (statSync(dir).isDirectory()) { + files = readdirSync(dir) + .filter(filter) + .map(file => join(dir, file)); + } else { + files = [dir]; + } + + files.forEach(file => { + if (statSync(file).isDirectory()) { + // Recursive if directory + paths.push(...loadRoutes.call(this, file, { filter, basePath })); + } else if (extname(file) === '.js') { + const routes = require(file); + let basePaths = routes.basePath || ['']; + delete routes.basePath; + if (typeof basePaths === 'string') basePaths = [basePaths]; + + basePaths.forEach(basep => { + for (const method in routes) { + const methodRoutes = routes[method]; + for (let r in methodRoutes) { + if (!Array.isArray(methodRoutes[r])) methodRoutes[r] = [methodRoutes[r]]; + this[method](basePath + basep + r, ...methodRoutes[r]); + paths.push(basePath + basep + r); + } + } + }); + } + }); + + return paths; +} + +export default loadRoutes; diff --git a/back/src/Server/server/mime.ts b/back/src/Server/server/mime.ts new file mode 100644 index 00000000..396073cc --- /dev/null +++ b/back/src/Server/server/mime.ts @@ -0,0 +1,176 @@ +const mimes = { + '3gp': 'video/3gpp', + a: 'application/octet-stream', + ai: 'application/postscript', + aif: 'audio/x-aiff', + aiff: 'audio/x-aiff', + asc: 'application/pgp-signature', + asf: 'video/x-ms-asf', + asm: 'text/x-asm', + asx: 'video/x-ms-asf', + atom: 'application/atom+xml', + au: 'audio/basic', + avi: 'video/x-msvideo', + bat: 'application/x-msdownload', + bin: 'application/octet-stream', + bmp: 'image/bmp', + bz2: 'application/x-bzip2', + c: 'text/x-c', + cab: 'application/vnd.ms-cab-compressed', + cc: 'text/x-c', + chm: 'application/vnd.ms-htmlhelp', + class: 'application/octet-stream', + com: 'application/x-msdownload', + conf: 'text/plain', + cpp: 'text/x-c', + crt: 'application/x-x509-ca-cert', + css: 'text/css', + csv: 'text/csv', + cxx: 'text/x-c', + deb: 'application/x-debian-package', + der: 'application/x-x509-ca-cert', + diff: 'text/x-diff', + djv: 'image/vnd.djvu', + djvu: 'image/vnd.djvu', + dll: 'application/x-msdownload', + dmg: 'application/octet-stream', + doc: 'application/msword', + dot: 'application/msword', + dtd: 'application/xml-dtd', + dvi: 'application/x-dvi', + ear: 'application/java-archive', + eml: 'message/rfc822', + eps: 'application/postscript', + exe: 'application/x-msdownload', + f: 'text/x-fortran', + f77: 'text/x-fortran', + f90: 'text/x-fortran', + flv: 'video/x-flv', + for: 'text/x-fortran', + gem: 'application/octet-stream', + gemspec: 'text/x-script.ruby', + gif: 'image/gif', + gz: 'application/x-gzip', + h: 'text/x-c', + hh: 'text/x-c', + htm: 'text/html', + html: 'text/html', + ico: 'image/vnd.microsoft.icon', + ics: 'text/calendar', + ifb: 'text/calendar', + iso: 'application/octet-stream', + jar: 'application/java-archive', + java: 'text/x-java-source', + jnlp: 'application/x-java-jnlp-file', + jpeg: 'image/jpeg', + jpg: 'image/jpeg', + js: 'application/javascript', + json: 'application/json', + log: 'text/plain', + m3u: 'audio/x-mpegurl', + m4v: 'video/mp4', + man: 'text/troff', + mathml: 'application/mathml+xml', + mbox: 'application/mbox', + mdoc: 'text/troff', + me: 'text/troff', + mid: 'audio/midi', + midi: 'audio/midi', + mime: 'message/rfc822', + mjs: 'application/javascript', + mml: 'application/mathml+xml', + mng: 'video/x-mng', + mov: 'video/quicktime', + mp3: 'audio/mpeg', + mp4: 'video/mp4', + mp4v: 'video/mp4', + mpeg: 'video/mpeg', + mpg: 'video/mpeg', + ms: 'text/troff', + msi: 'application/x-msdownload', + odp: 'application/vnd.oasis.opendocument.presentation', + ods: 'application/vnd.oasis.opendocument.spreadsheet', + odt: 'application/vnd.oasis.opendocument.text', + ogg: 'application/ogg', + p: 'text/x-pascal', + pas: 'text/x-pascal', + pbm: 'image/x-portable-bitmap', + pdf: 'application/pdf', + pem: 'application/x-x509-ca-cert', + pgm: 'image/x-portable-graymap', + pgp: 'application/pgp-encrypted', + pkg: 'application/octet-stream', + pl: 'text/x-script.perl', + pm: 'text/x-script.perl-module', + png: 'image/png', + pnm: 'image/x-portable-anymap', + ppm: 'image/x-portable-pixmap', + pps: 'application/vnd.ms-powerpoint', + ppt: 'application/vnd.ms-powerpoint', + ps: 'application/postscript', + psd: 'image/vnd.adobe.photoshop', + py: 'text/x-script.python', + qt: 'video/quicktime', + ra: 'audio/x-pn-realaudio', + rake: 'text/x-script.ruby', + ram: 'audio/x-pn-realaudio', + rar: 'application/x-rar-compressed', + rb: 'text/x-script.ruby', + rdf: 'application/rdf+xml', + roff: 'text/troff', + rpm: 'application/x-redhat-package-manager', + rss: 'application/rss+xml', + rtf: 'application/rtf', + ru: 'text/x-script.ruby', + s: 'text/x-asm', + sgm: 'text/sgml', + sgml: 'text/sgml', + sh: 'application/x-sh', + sig: 'application/pgp-signature', + snd: 'audio/basic', + so: 'application/octet-stream', + svg: 'image/svg+xml', + svgz: 'image/svg+xml', + swf: 'application/x-shockwave-flash', + t: 'text/troff', + tar: 'application/x-tar', + tbz: 'application/x-bzip-compressed-tar', + tcl: 'application/x-tcl', + tex: 'application/x-tex', + texi: 'application/x-texinfo', + texinfo: 'application/x-texinfo', + text: 'text/plain', + tif: 'image/tiff', + tiff: 'image/tiff', + torrent: 'application/x-bittorrent', + tr: 'text/troff', + txt: 'text/plain', + vcf: 'text/x-vcard', + vcs: 'text/x-vcalendar', + vrml: 'model/vrml', + war: 'application/java-archive', + wav: 'audio/x-wav', + wma: 'audio/x-ms-wma', + wmv: 'video/x-ms-wmv', + wmx: 'video/x-ms-wmx', + wrl: 'model/vrml', + wsdl: 'application/wsdl+xml', + xbm: 'image/x-xbitmap', + xhtml: 'application/xhtml+xml', + xls: 'application/vnd.ms-excel', + xml: 'application/xml', + xpm: 'image/x-xpixmap', + xsl: 'application/xml', + xslt: 'application/xslt+xml', + yaml: 'text/yaml', + yml: 'text/yaml', + zip: 'application/zip', + default: 'text/html' +}; + +const getMime = (path: string): string => { + const i = path.lastIndexOf('.'); + return mimes[path.substr(i + 1).toLowerCase()] || mimes['default']; +}; + +export { getMime, mimes }; diff --git a/back/src/Server/server/sendfile.ts b/back/src/Server/server/sendfile.ts new file mode 100644 index 00000000..8310c4a7 --- /dev/null +++ b/back/src/Server/server/sendfile.ts @@ -0,0 +1,172 @@ +import { watch, statSync, createReadStream } from 'fs'; +import { createBrotliCompress, createGzip, createDeflate } from 'zlib'; +const watchedPaths = new Set(); + +const compressions = { + br: createBrotliCompress, + gzip: createGzip, + deflate: createDeflate +}; +import { writeHeaders } from './utils'; +import { getMime } from './mime'; +const bytes = 'bytes='; +import { stob } from './utils'; +import { sendSignal } from './livereload'; +import { SendFileOptions } from './types'; +import { HttpResponse, HttpRequest } from 'uWebSockets.js'; + +function sendFile(res: HttpResponse, req: HttpRequest, path: string, options: SendFileOptions) { + if (options && options.livereload && !watchedPaths.has(path)) { + watchedPaths.add(path); + watch(path, sendSignal); + } + + sendFileToRes( + res, + { + 'if-modified-since': req.getHeader('if-modified-since'), + range: req.getHeader('range'), + 'accept-encoding': req.getHeader('accept-encoding') + }, + path, + options + ); +} + +function sendFileToRes( + res: HttpResponse, + reqHeaders: { [name: string]: string }, + path: string, + { + lastModified = true, + headers = {}, + compress = false, + compressionOptions = { + priority: ['gzip', 'br', 'deflate'] + }, + cache = false + }: { cache: any } & any = {} +) { + let { mtime, size } = statSync(path); + mtime.setMilliseconds(0); + const mtimeutc = mtime.toUTCString(); + + headers = Object.assign({}, headers); + // handling last modified + if (lastModified) { + // Return 304 if last-modified + if (reqHeaders['if-modified-since']) { + if (new Date(reqHeaders['if-modified-since']) >= mtime) { + res.writeStatus('304 Not Modified'); + return res.end(); + } + } + headers['last-modified'] = mtimeutc; + } + headers['content-type'] = getMime(path); + + // write data + let start = 0, + end = size - 1; + + if (reqHeaders.range) { + compress = false; + const parts = reqHeaders.range.replace(bytes, '').split('-'); + start = parseInt(parts[0], 10); + end = parts[1] ? parseInt(parts[1], 10) : end; + headers['accept-ranges'] = 'bytes'; + headers['content-range'] = `bytes ${start}-${end}/${size}`; + size = end - start + 1; + res.writeStatus('206 Partial Content'); + } + + // for size = 0 + if (end < 0) end = 0; + + let readStream = createReadStream(path, { start, end }); + // Compression; + let compressed: boolean | string = false; + if (compress) { + const l = compressionOptions.priority.length; + for (let i = 0; i < l; i++) { + const type = compressionOptions.priority[i]; + if (reqHeaders['accept-encoding'].indexOf(type) > -1) { + compressed = type; + const compressor = compressions[type](compressionOptions); + readStream.pipe(compressor); + readStream = compressor; + headers['content-encoding'] = compressionOptions.priority[i]; + break; + } + } + } + + res.onAborted(() => readStream.destroy()); + writeHeaders(res, headers); + // check cache + if (cache) { + return cache.wrap( + `${path}_${mtimeutc}_${start}_${end}_${compressed}`, + cb => { + stob(readStream) + .then(b => cb(null, b)) + .catch(cb); + }, + { ttl: 0 }, + (err, buffer) => { + if (err) { + res.writeStatus('500 Internal server error'); + res.end(); + throw err; + } + res.end(buffer); + } + ); + } else if (compressed) { + readStream.on('data', buffer => { + res.write(buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength)); + }); + } else { + readStream.on('data', buffer => { + const chunk = buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength), + lastOffset = res.getWriteOffset(); + + // First try + const [ok, done] = res.tryEnd(chunk, size); + + if (done) { + readStream.destroy(); + } else if (!ok) { + // pause because backpressure + readStream.pause(); + + // Save unsent chunk for later + res.ab = chunk; + res.abOffset = lastOffset; + + // Register async handlers for drainage + res.onWritable(offset => { + const [ok, done] = res.tryEnd(res.ab.slice(offset - res.abOffset), size); + if (done) { + readStream.destroy(); + } else if (ok) { + readStream.resume(); + } + return ok; + }); + } + }); + } + readStream + .on('error', e => { + res.writeStatus('500 Internal server error'); + res.end(); + readStream.destroy(); + throw e; + }) + .on('end', () => { + res.end(); + }); +} + +export default sendFile; diff --git a/back/src/Server/server/sslapp.ts b/back/src/Server/server/sslapp.ts new file mode 100644 index 00000000..60b17aa4 --- /dev/null +++ b/back/src/Server/server/sslapp.ts @@ -0,0 +1,13 @@ +import { SSLApp as _SSLApp, AppOptions } from 'uWebSockets.js'; +import BaseApp from './baseapp'; +import { extend } from './utils'; +import { UwsApp } from './types'; + +class SSLApp extends (_SSLApp) { + constructor(options: AppOptions) { + super(options); + extend(this, new BaseApp()); + } +} + +export default SSLApp; diff --git a/back/src/Server/server/types.ts b/back/src/Server/server/types.ts new file mode 100644 index 00000000..09916b5f --- /dev/null +++ b/back/src/Server/server/types.ts @@ -0,0 +1,26 @@ +import { AppOptions, TemplatedApp, HttpResponse, HttpRequest } from 'uWebSockets.js'; + +export type UwsApp = { + (options: AppOptions): TemplatedApp; + new (options: AppOptions): TemplatedApp; + prototype: TemplatedApp; +}; + +export type SendFileOptions = { + failOnDuplicateRoute?: boolean; + overwriteRoute?: boolean; + watch?: boolean; + filter?: (path: string) => boolean; + livereload?: boolean; + lastModified?: boolean; + headers?: { [name: string]: string }; + compress?: boolean; + compressionOptions?: { + priority?: 'gzip' | 'br' | 'deflate'; + }; + cache?: boolean; +}; + +export type Handler = (res: HttpResponse, req: HttpRequest) => void; + +export {}; diff --git a/back/src/Server/server/utils.ts b/back/src/Server/server/utils.ts new file mode 100644 index 00000000..8f6db886 --- /dev/null +++ b/back/src/Server/server/utils.ts @@ -0,0 +1,52 @@ +import { HttpResponse } from 'uWebSockets.js'; +import { ReadStream } from 'fs'; + +function writeHeaders( + res: HttpResponse, + headers: { [name: string]: string } | string, + other?: string +) { + if (typeof headers === 'string') { + res.writeHeader(headers, other.toString()); + } else { + for (const n in headers) { + res.writeHeader(n, headers[n].toString()); + } + } +} + +function extend(who: object, from: object, overwrite = true) { + const ownProps = Object.getOwnPropertyNames(Object.getPrototypeOf(from)).concat( + Object.keys(from) + ); + ownProps.forEach(prop => { + if (prop === 'constructor' || from[prop] === undefined) return; + if (who[prop] && overwrite) { + who[`_${prop}`] = who[prop]; + } + if (typeof from[prop] === 'function') who[prop] = from[prop].bind(who); + else who[prop] = from[prop]; + }); +} + +function stob(stream: ReadStream): Promise { + return new Promise(resolve => { + const buffers = []; + stream.on('data', buffers.push.bind(buffers)); + + stream.on('end', () => { + switch (buffers.length) { + case 0: + resolve(Buffer.allocUnsafe(0)); + break; + case 1: + resolve(buffers[0]); + break; + default: + resolve(Buffer.concat(buffers)); + } + }); + }); +} + +export { writeHeaders, extend, stob }; diff --git a/back/src/Server/sifrr.server.ts b/back/src/Server/sifrr.server.ts new file mode 100644 index 00000000..9a274378 --- /dev/null +++ b/back/src/Server/sifrr.server.ts @@ -0,0 +1,30 @@ +import { parse } from 'query-string'; +import { HttpRequest } from 'uWebSockets.js'; +import App from './server/app'; +import SSLApp from './server/sslapp'; +import { mimes, getMime } from './server/mime'; +import { writeHeaders } from './server/utils'; +import sendFile from './server/sendfile'; +import Cluster from './server/cluster'; +import livereload from './server/livereload'; +import * as types from './server/types'; + +const getQuery = (req: HttpRequest) => { + return parse(req.getQuery()); +}; + +export { App, SSLApp, mimes, getMime, writeHeaders, sendFile, Cluster, livereload, getQuery }; +export * from './server/types'; + +export default { + App, + SSLApp, + mimes, + getMime, + writeHeaders, + sendFile, + Cluster, + livereload, + getQuery, + ...types +}; diff --git a/back/yarn.lock b/back/yarn.lock index 3731547d..5531f281 100644 --- a/back/yarn.lock +++ b/back/yarn.lock @@ -20,13 +20,6 @@ chalk "^2.0.0" js-tokens "^4.0.0" -"@types/body-parser@*": - version "1.19.0" - resolved "https://registry.yarnpkg.com/@types/body-parser/-/body-parser-1.19.0.tgz#0685b3c47eb3006ffed117cdd55164b61f80538f" - dependencies: - "@types/connect" "*" - "@types/node" "*" - "@types/circular-json@^0.4.0": version "0.4.0" resolved "https://registry.yarnpkg.com/@types/circular-json/-/circular-json-0.4.0.tgz#7401f7e218cfe87ad4c43690da5658b9acaf51be" @@ -36,32 +29,10 @@ version "1.1.1" resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0" -"@types/connect@*": - version "3.4.33" - resolved "https://registry.yarnpkg.com/@types/connect/-/connect-3.4.33.tgz#31610c901eca573b8713c3330abc6e6b9f588546" - dependencies: - "@types/node" "*" - "@types/eslint-visitor-keys@^1.0.0": version "1.0.0" resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d" -"@types/express-serve-static-core@*": - version "4.17.3" - resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.17.3.tgz#dc8068ee3e354d7fba69feb86b3dfeee49b10f09" - dependencies: - "@types/node" "*" - "@types/range-parser" "*" - -"@types/express@^4.17.4": - version "4.17.4" - resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.4.tgz#e78bf09f3f530889575f4da8a94cd45384520aac" - dependencies: - "@types/body-parser" "*" - "@types/express-serve-static-core" "*" - "@types/qs" "*" - "@types/serve-static" "*" - "@types/google-protobuf@^3.7.3": version "3.7.3" resolved "https://registry.yarnpkg.com/@types/google-protobuf/-/google-protobuf-3.7.3.tgz#429512e541bbd777f2c867692e6335ee08d1f6d4" @@ -87,35 +58,10 @@ dependencies: "@types/node" "*" -"@types/mime@*": - version "2.0.1" - resolved "https://registry.yarnpkg.com/@types/mime/-/mime-2.0.1.tgz#dc488842312a7f075149312905b5e3c0b054c79d" - "@types/node@*": version "13.11.0" resolved "https://registry.yarnpkg.com/@types/node/-/node-13.11.0.tgz#390ea202539c61c8fa6ba4428b57e05bc36dc47b" -"@types/qs@*": - version "6.9.1" - resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.1.tgz#937fab3194766256ee09fcd40b781740758617e7" - -"@types/range-parser@*": - version "1.2.3" - resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.3.tgz#7ee330ba7caafb98090bece86a5ee44115904c2c" - -"@types/serve-static@*": - version "1.13.3" - resolved "https://registry.yarnpkg.com/@types/serve-static/-/serve-static-1.13.3.tgz#eb7e1c41c4468272557e897e9171ded5e2ded9d1" - dependencies: - "@types/express-serve-static-core" "*" - "@types/mime" "*" - -"@types/socket.io@^2.1.4": - version "2.1.4" - resolved "https://registry.yarnpkg.com/@types/socket.io/-/socket.io-2.1.4.tgz#674e7bc193c5ccdadd4433f79f3660d31759e9ac" - dependencies: - "@types/node" "*" - "@types/strip-bom@^3.0.0": version "3.0.0" resolved "https://registry.yarnpkg.com/@types/strip-bom/-/strip-bom-3.0.0.tgz#14a8ec3956c2e81edb7520790aecf21c290aebd2" @@ -169,13 +115,6 @@ semver "^6.3.0" tsutils "^3.17.1" -accepts@~1.3.4, accepts@~1.3.7: - version "1.3.7" - resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.7.tgz#531bc726517a3b2b41f850021c6cc15eaab507cd" - dependencies: - mime-types "~2.1.24" - negotiator "0.6.2" - acorn-jsx@^5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.2.0.tgz#4c66069173d6fdd68ed85239fc256226182b2ebe" @@ -184,10 +123,6 @@ acorn@^7.1.1: version "7.1.1" resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.1.1.tgz#e35668de0b402f359de515c5482a1ab9f89a69bf" -after@0.8.2: - version "0.8.2" - resolved "https://registry.yarnpkg.com/after/-/after-0.8.2.tgz#fedb394f9f0e02aa9768e702bda23b505fae7e1f" - ajv@^6.10.0, ajv@^6.10.2: version "6.12.0" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.0.tgz#06d60b96d87b8454a5adaba86e7854da629db4b7" @@ -238,22 +173,10 @@ array-find-index@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/array-find-index/-/array-find-index-1.0.2.tgz#df010aa1287e164bbda6f9723b0a96a1ec4187a1" -array-flatten@1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2" - -arraybuffer.slice@~0.0.7: - version "0.0.7" - resolved "https://registry.yarnpkg.com/arraybuffer.slice/-/arraybuffer.slice-0.0.7.tgz#3bbc4275dd584cc1b10809b89d4e8b63a69e7675" - astral-regex@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-1.0.0.tgz#6c8c3fb827dd43ee3918f27b82782ab7658a6fd9" -async-limiter@~1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.1.tgz#dd379e94f0db8310b08291f9d64c3209766617fd" - axios@^0.20.0: version "0.20.0" resolved "https://registry.yarnpkg.com/axios/-/axios-0.20.0.tgz#057ba30f04884694993a8cd07fa394cff11c50bd" @@ -261,38 +184,16 @@ axios@^0.20.0: dependencies: follow-redirects "^1.10.0" -backo2@1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/backo2/-/backo2-1.0.2.tgz#31ab1ac8b129363463e35b3ebb69f4dfcfba7947" - balanced-match@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" -base64-arraybuffer@0.1.5: - version "0.1.5" - resolved "https://registry.yarnpkg.com/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz#73926771923b5a19747ad666aa5cd4bf9c6e9ce8" - -base64id@2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/base64id/-/base64id-2.0.0.tgz#2770ac6bc47d312af97a8bf9a634342e0cd25cb6" - -better-assert@~1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/better-assert/-/better-assert-1.0.2.tgz#40866b9e1b9e0b55b481894311e68faffaebc522" - dependencies: - callsite "1.0.0" - bintrees@1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/bintrees/-/bintrees-1.0.1.tgz#0e655c9b9c2435eaab68bf4027226d2b55a34524" integrity sha1-DmVcm5wkNeqraL9AJyJtK1WjRSQ= -blob@0.0.5: - version "0.0.5" - resolved "https://registry.yarnpkg.com/blob/-/blob-0.0.5.tgz#d680eeef25f8cd91ad533f5b01eed48e64caf683" - -body-parser@1.19.0, body-parser@^1.19.0: +body-parser@^1.19.0: version "1.19.0" resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.19.0.tgz#96b2709e57c9c4e09a6fd66a8fd979844f69f08a" dependencies: @@ -322,14 +223,17 @@ buffer-from@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" +busboy@^0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/busboy/-/busboy-0.3.1.tgz#170899274c5bf38aae27d5c62b71268cd585fd1b" + integrity sha512-y7tTxhGKXcyBxRKAni+awqx8uqaJKrSFSNFSeRG5CsWNdmy2BIK+6VGWEW7TZnIO/533mtMEA4rOevQV815YJw== + dependencies: + dicer "0.3.0" + bytes@3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.0.tgz#f6cf7933a360e0588fa9fde85651cdc7f805d1f6" -callsite@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/callsite/-/callsite-1.0.0.tgz#280398e5d664bd74038b6f0905153e6e8af1bc20" - callsites@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" @@ -399,44 +303,14 @@ color-name@~1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" -component-bind@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/component-bind/-/component-bind-1.0.0.tgz#00c608ab7dcd93897c0009651b1d3a8e1e73bbd1" - -component-emitter@1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.2.1.tgz#137918d6d78283f7df7a6b7c5a63e140e69425e6" - -component-inherit@0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/component-inherit/-/component-inherit-0.0.3.tgz#645fc4adf58b72b649d5cae65135619db26ff143" - concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" -content-disposition@0.5.3: - version "0.5.3" - resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.3.tgz#e130caf7e7279087c5616c2007d0485698984fbd" - dependencies: - safe-buffer "5.1.2" - content-type@~1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.4.tgz#e138cc75e040c727b1966fe5e5f8c9aee256fe3b" -cookie-signature@1.0.6: - version "1.0.6" - resolved "https://registry.yarnpkg.com/cookie-signature/-/cookie-signature-1.0.6.tgz#e303a882b342cc3ee8ca513a79999734dab3ae2c" - -cookie@0.3.1: - version "0.3.1" - resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb" - -cookie@0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.0.tgz#beb437e7022b3b6d49019d088665303ebe9c14ba" - cross-spawn@^6.0.5: version "6.0.5" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" @@ -470,22 +344,21 @@ debug@2.6.9: dependencies: ms "2.0.0" -debug@^4.0.1, debug@^4.1.1, debug@~4.1.0: +debug@^4.0.1, debug@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791" dependencies: ms "^2.1.1" -debug@~3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" - dependencies: - ms "2.0.0" - decamelize@^1.1.2: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" +decode-uri-component@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" + integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU= + deep-is@~0.1.3: version "0.1.3" resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" @@ -494,9 +367,12 @@ depd@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" -destroy@~1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.0.4.tgz#978857442c44749e4206613e37946205826abd80" +dicer@0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/dicer/-/dicer-0.3.0.tgz#eacd98b3bfbf92e8ab5c2fdb71aaac44bb06b872" + integrity sha512-MdceRRWqltEG2dZqO769g27N/3PXfcKl04VhYnBlo2YhH7zPi88VebsjTKclaOyiuMaGU72hTfw3VkUitGcVCA== + dependencies: + streamsearch "0.1.2" diff@^4.0.1: version "4.0.2" @@ -532,57 +408,12 @@ emoji-regex@^8.0.0: version "8.0.0" resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" -encodeurl@~1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59" - -engine.io-client@~3.4.0: - version "3.4.0" - resolved "https://registry.yarnpkg.com/engine.io-client/-/engine.io-client-3.4.0.tgz#82a642b42862a9b3f7a188f41776b2deab643700" - dependencies: - component-emitter "1.2.1" - component-inherit "0.0.3" - debug "~4.1.0" - engine.io-parser "~2.2.0" - has-cors "1.1.0" - indexof "0.0.1" - parseqs "0.0.5" - parseuri "0.0.5" - ws "~6.1.0" - xmlhttprequest-ssl "~1.5.4" - yeast "0.1.2" - -engine.io-parser@~2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/engine.io-parser/-/engine.io-parser-2.2.0.tgz#312c4894f57d52a02b420868da7b5c1c84af80ed" - dependencies: - after "0.8.2" - arraybuffer.slice "~0.0.7" - base64-arraybuffer "0.1.5" - blob "0.0.5" - has-binary2 "~1.0.2" - -engine.io@~3.4.0: - version "3.4.0" - resolved "https://registry.yarnpkg.com/engine.io/-/engine.io-3.4.0.tgz#3a962cc4535928c252759a00f98519cb46c53ff3" - dependencies: - accepts "~1.3.4" - base64id "2.0.0" - cookie "0.3.1" - debug "~4.1.0" - engine.io-parser "~2.2.0" - ws "^7.1.2" - error-ex@^1.2.0: version "1.3.2" resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" dependencies: is-arrayish "^0.2.1" -escape-html@~1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" - escape-string-regexp@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" @@ -688,45 +519,6 @@ esutils@^2.0.2: version "2.0.3" resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" -etag@~1.8.1: - version "1.8.1" - resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887" - -express@^4.17.1: - version "4.17.1" - resolved "https://registry.yarnpkg.com/express/-/express-4.17.1.tgz#4491fc38605cf51f8629d39c2b5d026f98a4c134" - dependencies: - accepts "~1.3.7" - array-flatten "1.1.1" - body-parser "1.19.0" - content-disposition "0.5.3" - content-type "~1.0.4" - cookie "0.4.0" - cookie-signature "1.0.6" - debug "2.6.9" - depd "~1.1.2" - encodeurl "~1.0.2" - escape-html "~1.0.3" - etag "~1.8.1" - finalhandler "~1.1.2" - fresh "0.5.2" - merge-descriptors "1.0.1" - methods "~1.1.2" - on-finished "~2.3.0" - parseurl "~1.3.3" - path-to-regexp "0.1.7" - proxy-addr "~2.0.5" - qs "6.7.0" - range-parser "~1.2.1" - safe-buffer "5.1.2" - send "0.17.1" - serve-static "1.14.1" - setprototypeof "1.1.1" - statuses "~1.5.0" - type-is "~1.6.18" - utils-merge "1.0.1" - vary "~1.1.2" - external-editor@^3.0.3: version "3.1.0" resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-3.1.0.tgz#cb03f740befae03ea4d283caed2741a83f335495" @@ -765,18 +557,6 @@ filewatcher@~3.0.0: dependencies: debounce "^1.0.0" -finalhandler@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.1.2.tgz#b7e7d000ffd11938d0fdb053506f6ebabe9f587d" - dependencies: - debug "2.6.9" - encodeurl "~1.0.2" - escape-html "~1.0.3" - on-finished "~2.3.0" - parseurl "~1.3.3" - statuses "~1.5.0" - unpipe "~1.0.0" - find-up@^1.0.0: version "1.1.2" resolved "https://registry.yarnpkg.com/find-up/-/find-up-1.1.2.tgz#6b2e9822b1a2ce0a60ab64d610eccad53cb24d0f" @@ -801,14 +581,6 @@ follow-redirects@^1.10.0: resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.13.0.tgz#b42e8d93a2a7eea5ed88633676d6597bc8e384db" integrity sha512-aq6gF1BEKje4a9i9+5jimNFIpq4Q1WiwBToeRK5NvZBd/TRsmW8BsJfOEGkr76TbOyPVD3OVDN910EcUNtRYEA== -forwarded@~0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.1.2.tgz#98c23dab1175657b8c0573e8ceccd91b0ff18c84" - -fresh@0.5.2: - version "0.5.2" - resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7" - fs.realpath@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" @@ -862,16 +634,6 @@ growly@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081" -has-binary2@~1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/has-binary2/-/has-binary2-1.0.3.tgz#7776ac627f3ea77250cfc332dab7ddf5e4f5d11d" - dependencies: - isarray "2.0.1" - -has-cors@1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/has-cors/-/has-cors-1.1.0.tgz#5e474793f7ea9843d1bb99c23eef49ff126fff39" - has-flag@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" @@ -894,16 +656,6 @@ http-errors@1.7.2: statuses ">= 1.5.0 < 2" toidentifier "1.0.0" -http-errors@~1.7.2: - version "1.7.3" - resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.7.3.tgz#6c619e4f9c60308c38519498c14fbb10aacebb06" - dependencies: - depd "~1.1.2" - inherits "2.0.4" - setprototypeof "1.1.1" - statuses ">= 1.5.0 < 2" - toidentifier "1.0.0" - http-status-codes@*, http-status-codes@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/http-status-codes/-/http-status-codes-1.4.0.tgz#6e4c15d16ff3a9e2df03b89f3a55e1aae05fb477" @@ -935,10 +687,6 @@ indent-string@^2.1.0: dependencies: repeating "^2.0.0" -indexof@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/indexof/-/indexof-0.0.1.tgz#82dc336d232b9062179d05ab3293a66059fd435d" - inflight@^1.0.4: version "1.0.6" resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" @@ -946,7 +694,7 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherits@2, inherits@2.0.4: +inherits@2: version "2.0.4" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" @@ -972,10 +720,6 @@ inquirer@^7.0.0: strip-ansi "^6.0.0" through "^2.3.6" -ipaddr.js@1.9.1: - version "1.9.1" - resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.9.1.tgz#bff38543eeb8984825079ff3a2a8e6cbd46781b3" - is-arrayish@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" @@ -1014,14 +758,15 @@ is-wsl@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-1.1.0.tgz#1f16e4aa22b04d1336b66188a66af3c600c3a66d" -isarray@2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/isarray/-/isarray-2.0.1.tgz#a37d94ed9cda2d59865c9f76fe596ee1f338741e" - isexe@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" +iterall@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/iterall/-/iterall-1.3.0.tgz#afcb08492e2915cbd8a0884eb93a8c94d0d72fea" + integrity sha512-QZ9qOMdF+QLHxy1QIpUHUU1D5pS2CG2P69LF6L6CPjPYA/XMOmKV3PZpawHoAjHNyB0swdVTRxdYT4tbBbxqwg== + jasmine-core@~3.5.0: version "3.5.0" resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-3.5.0.tgz#132c23e645af96d85c8bca13c8758b18429fc1e4" @@ -1165,14 +910,6 @@ meow@^3.3.0: redent "^1.0.0" trim-newlines "^1.0.0" -merge-descriptors@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61" - -methods@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee" - mime-db@1.43.0: version "1.43.0" resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.43.0.tgz#0a12e0502650e473d735535050e7c8f4eb4fae58" @@ -1183,10 +920,6 @@ mime-types@~2.1.24: dependencies: mime-db "1.43.0" -mime@1.6.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" - mimic-fn@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" @@ -1211,10 +944,6 @@ ms@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" -ms@2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" - ms@^2.1.1: version "2.1.2" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" @@ -1227,10 +956,6 @@ natural-compare@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" -negotiator@0.6.2: - version "0.6.2" - resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.2.tgz#feacf7ccf525a77ae9634436a64883ffeca346fb" - nice-try@^1.0.4: version "1.0.5" resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" @@ -1258,10 +983,6 @@ object-assign@^4.0.1: version "4.1.1" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" -object-component@0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/object-component/-/object-component-0.0.3.tgz#f0c69aa50efc95b866c186f400a33769cb2f1291" - on-finished@~2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947" @@ -1307,22 +1028,6 @@ parse-json@^2.2.0: dependencies: error-ex "^1.2.0" -parseqs@0.0.5: - version "0.0.5" - resolved "https://registry.yarnpkg.com/parseqs/-/parseqs-0.0.5.tgz#d5208a3738e46766e291ba2ea173684921a8b89d" - dependencies: - better-assert "~1.0.0" - -parseuri@0.0.5: - version "0.0.5" - resolved "https://registry.yarnpkg.com/parseuri/-/parseuri-0.0.5.tgz#80204a50d4dbb779bfdc6ebe2778d90e4bce320a" - dependencies: - better-assert "~1.0.0" - -parseurl@~1.3.3: - version "1.3.3" - resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.3.tgz#9da19e7bee8d12dff0513ed5b76957793bc2e8d4" - path-exists@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-2.1.0.tgz#0feb6c64f0fc518d9a754dd5efb62c7022761f4b" @@ -1341,10 +1046,6 @@ path-parse@^1.0.6: version "1.0.6" resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" -path-to-regexp@0.1.7: - version "0.1.7" - resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c" - path-type@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/path-type/-/path-type-1.1.0.tgz#59c44f7ee491da704da415da5a4070ba4f8fe441" @@ -1382,13 +1083,6 @@ prom-client@^12.0.0: dependencies: tdigest "^0.1.1" -proxy-addr@~2.0.5: - version "2.0.6" - resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.6.tgz#fdc2336505447d3f2f2c638ed272caf614bbb2bf" - dependencies: - forwarded "~0.1.2" - ipaddr.js "1.9.1" - punycode@^2.1.0: version "2.1.1" resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" @@ -1397,9 +1091,14 @@ qs@6.7.0: version "6.7.0" resolved "https://registry.yarnpkg.com/qs/-/qs-6.7.0.tgz#41dc1a015e3d581f1621776be31afb2876a9b1bc" -range-parser@~1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.1.tgz#3cf37023d199e1c24d1a55b84800c2f3e6468031" +query-string@^6.13.3: + version "6.13.3" + resolved "https://registry.yarnpkg.com/query-string/-/query-string-6.13.3.tgz#57d1c20e828b0e562d66b7f71a4998bd57f84112" + integrity sha512-dldo2oHe3sg03iPshlHw/64nkaRUJKdS0FW85kmWQkmCkqUbNdNdgkgtAufJcEpjzrx6Q9EW9Y3xqx/rM9pGhw== + dependencies: + decode-uri-component "^0.2.0" + split-on-first "^1.0.0" + strict-uri-encode "^2.0.0" raw-body@2.4.0: version "2.4.0" @@ -1487,10 +1186,6 @@ rxjs@^6.5.3: dependencies: tslib "^1.9.0" -safe-buffer@5.1.2: - version "5.1.2" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" - safe-buffer@^5.0.1: version "5.2.0" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.0.tgz#b74daec49b1148f88c64b68d49b1e815c1f2f519" @@ -1507,33 +1202,6 @@ semver@^6.1.2, semver@^6.3.0: version "6.3.0" resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" -send@0.17.1: - version "0.17.1" - resolved "https://registry.yarnpkg.com/send/-/send-0.17.1.tgz#c1d8b059f7900f7466dd4938bdc44e11ddb376c8" - dependencies: - debug "2.6.9" - depd "~1.1.2" - destroy "~1.0.4" - encodeurl "~1.0.2" - escape-html "~1.0.3" - etag "~1.8.1" - fresh "0.5.2" - http-errors "~1.7.2" - mime "1.6.0" - ms "2.1.1" - on-finished "~2.3.0" - range-parser "~1.2.1" - statuses "~1.5.0" - -serve-static@1.14.1: - version "1.14.1" - resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.14.1.tgz#666e636dc4f010f7ef29970a88a674320898b2f9" - dependencies: - encodeurl "~1.0.2" - escape-html "~1.0.3" - parseurl "~1.3.3" - send "0.17.1" - setprototypeof@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.1.1.tgz#7e95acb24aa92f5885e0abef5ba131330d4ae683" @@ -1564,56 +1232,6 @@ slice-ansi@^2.1.0: astral-regex "^1.0.0" is-fullwidth-code-point "^2.0.0" -socket.io-adapter@~1.1.0: - version "1.1.2" - resolved "https://registry.yarnpkg.com/socket.io-adapter/-/socket.io-adapter-1.1.2.tgz#ab3f0d6f66b8fc7fca3959ab5991f82221789be9" - -socket.io-client@2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/socket.io-client/-/socket.io-client-2.3.0.tgz#14d5ba2e00b9bcd145ae443ab96b3f86cbcc1bb4" - dependencies: - backo2 "1.0.2" - base64-arraybuffer "0.1.5" - component-bind "1.0.0" - component-emitter "1.2.1" - debug "~4.1.0" - engine.io-client "~3.4.0" - has-binary2 "~1.0.2" - has-cors "1.1.0" - indexof "0.0.1" - object-component "0.0.3" - parseqs "0.0.5" - parseuri "0.0.5" - socket.io-parser "~3.3.0" - to-array "0.1.4" - -socket.io-parser@~3.3.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-3.3.0.tgz#2b52a96a509fdf31440ba40fed6094c7d4f1262f" - dependencies: - component-emitter "1.2.1" - debug "~3.1.0" - isarray "2.0.1" - -socket.io-parser@~3.4.0: - version "3.4.0" - resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-3.4.0.tgz#370bb4a151df2f77ce3345ff55a7072cc6e9565a" - dependencies: - component-emitter "1.2.1" - debug "~4.1.0" - isarray "2.0.1" - -socket.io@^2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/socket.io/-/socket.io-2.3.0.tgz#cd762ed6a4faeca59bc1f3e243c0969311eb73fb" - dependencies: - debug "~4.1.0" - engine.io "~3.4.0" - has-binary2 "~1.0.2" - socket.io-adapter "~1.1.0" - socket.io-client "2.3.0" - socket.io-parser "~3.4.0" - source-map-support@^0.5.12, source-map-support@^0.5.6: version "0.5.16" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.16.tgz#0ae069e7fe3ba7538c64c98515e35339eac5a042" @@ -1647,14 +1265,29 @@ spdx-license-ids@^3.0.0: version "3.0.5" resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.5.tgz#3694b5804567a458d3c8045842a6358632f62654" +split-on-first@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/split-on-first/-/split-on-first-1.1.0.tgz#f610afeee3b12bce1d0c30425e76398b78249a5f" + integrity sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw== + sprintf-js@~1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" -"statuses@>= 1.5.0 < 2", statuses@~1.5.0: +"statuses@>= 1.5.0 < 2": version "1.5.0" resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" +streamsearch@0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/streamsearch/-/streamsearch-0.1.2.tgz#808b9d0e56fc273d809ba57338e929919a1a9f1a" + integrity sha1-gIudDlb8Jz2Am6VzOOkpkZoanxo= + +strict-uri-encode@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz#b9c7330c7042862f6b142dc274bbcc5866ce3546" + integrity sha1-ucczDHBChi9rFC3CdLvMWGbONUY= + string-width@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/string-width/-/string-width-3.1.0.tgz#22767be21b62af1081574306f69ac51b62203961" @@ -1753,10 +1386,6 @@ tmp@^0.0.33: dependencies: os-tmpdir "~1.0.2" -to-array@0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/to-array/-/to-array-0.1.4.tgz#17e6c11f73dd4f3d74cda7a4ff3238e9ad9bf890" - toidentifier@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.0.tgz#7e1be3470f1e77948bc43d94a3c8f4d7752ba553" @@ -1829,7 +1458,7 @@ type-fest@^0.8.1: version "0.8.1" resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.8.1.tgz#09e249ebde851d3b1e48d27c105444667f17b83d" -type-is@~1.6.17, type-is@~1.6.18: +type-is@~1.6.17: version "1.6.18" resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.18.tgz#4e552cd05df09467dcbc4ef739de89f2cf37c131" dependencies: @@ -1840,7 +1469,11 @@ typescript@^3.8.3: version "3.8.3" resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.8.3.tgz#409eb8544ea0335711205869ec458ab109ee1061" -unpipe@1.0.0, unpipe@~1.0.0: +uWebSockets.js@uNetworking/uWebSockets.js#v18.5.0: + version "18.5.0" + resolved "https://codeload.github.com/uNetworking/uWebSockets.js/tar.gz/9b1605d2db82981cafe69dbe356e10ce412f5805" + +unpipe@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" @@ -1850,10 +1483,6 @@ uri-js@^4.2.2: dependencies: punycode "^2.1.0" -utils-merge@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" - uuid@7.0.3: version "7.0.3" resolved "https://registry.yarnpkg.com/uuid/-/uuid-7.0.3.tgz#c5c9f2c8cf25dc0a372c4df1441c41f5bd0c680b" @@ -1875,10 +1504,6 @@ validate-npm-package-license@^3.0.1: spdx-correct "^3.0.0" spdx-expression-parse "^3.0.0" -vary@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" - which@^1.2.9, which@^1.3.0: version "1.3.1" resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" @@ -1899,28 +1524,10 @@ write@1.0.3: dependencies: mkdirp "^0.5.1" -ws@^7.1.2: - version "7.2.3" - resolved "https://registry.yarnpkg.com/ws/-/ws-7.2.3.tgz#a5411e1fb04d5ed0efee76d26d5c46d830c39b46" - -ws@~6.1.0: - version "6.1.4" - resolved "https://registry.yarnpkg.com/ws/-/ws-6.1.4.tgz#5b5c8800afab925e94ccb29d153c8d02c1776ef9" - dependencies: - async-limiter "~1.0.0" - -xmlhttprequest-ssl@~1.5.4: - version "1.5.5" - resolved "https://registry.yarnpkg.com/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.5.tgz#c2876b06168aadc40e57d97e81191ac8f4398b3e" - xtend@^4.0.0: version "4.0.2" resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54" -yeast@0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/yeast/-/yeast-0.1.2.tgz#008e06d8094320c372dbc2f8ed76a0ca6c8ac419" - yn@3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" diff --git a/benchmark/index.ts b/benchmark/index.ts index 736a7bdc..50cd9e17 100644 --- a/benchmark/index.ts +++ b/benchmark/index.ts @@ -1,9 +1,14 @@ import {Connection} from "../front/src/Connection"; +import * as WebSocket from "ws" function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } +Connection.setWebsocketFactory((url: string) => { + return new WebSocket(url); +}); + async function startOneUser(): Promise { const connection = await Connection.createConnection('foo', ['male3']); diff --git a/benchmark/package.json b/benchmark/package.json index 2c874a7e..b0cd6a23 100644 --- a/benchmark/package.json +++ b/benchmark/package.json @@ -21,11 +21,10 @@ ], "license": "SEE LICENSE IN LICENSE.txt", "dependencies": { - "socket.io-client": "^2.3.0", + "@types/ws": "^7.2.6", "ts-node-dev": "^1.0.0-pre.62", - "typescript": "^4.0.2" + "typescript": "^4.0.2", + "ws": "^7.3.1" }, - "devDependencies": { - "@types/socket.io-client": "^1.4.33" - } + "devDependencies": {} } diff --git a/benchmark/yarn.lock b/benchmark/yarn.lock index 4c73bc38..d93e3667 100644 --- a/benchmark/yarn.lock +++ b/benchmark/yarn.lock @@ -2,9 +2,9 @@ # yarn lockfile v1 -"@types/socket.io-client@^1.4.33": - version "1.4.33" - resolved "https://registry.yarnpkg.com/@types/socket.io-client/-/socket.io-client-1.4.33.tgz#8e705b9b3f7fba6cb329d27cd2eda222812adbf1" +"@types/node@*": + version "14.11.2" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.11.2.tgz#2de1ed6670439387da1c9f549a2ade2b0a799256" "@types/strip-bom@^3.0.0": version "3.0.0" @@ -14,9 +14,11 @@ version "0.0.30" resolved "https://registry.yarnpkg.com/@types/strip-json-comments/-/strip-json-comments-0.0.30.tgz#9aa30c04db212a9a0649d6ae6fd50accc40748a1" -after@0.8.2: - version "0.8.2" - resolved "https://registry.yarnpkg.com/after/-/after-0.8.2.tgz#fedb394f9f0e02aa9768e702bda23b505fae7e1f" +"@types/ws@^7.2.6": + version "7.2.6" + resolved "https://registry.yarnpkg.com/@types/ws/-/ws-7.2.6.tgz#516cbfb818310f87b43940460e065eb912a4178d" + dependencies: + "@types/node" "*" anymatch@~3.1.1: version "3.1.1" @@ -33,40 +35,14 @@ array-find-index@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/array-find-index/-/array-find-index-1.0.2.tgz#df010aa1287e164bbda6f9723b0a96a1ec4187a1" -arraybuffer.slice@~0.0.7: - version "0.0.7" - resolved "https://registry.yarnpkg.com/arraybuffer.slice/-/arraybuffer.slice-0.0.7.tgz#3bbc4275dd584cc1b10809b89d4e8b63a69e7675" - -async-limiter@~1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.1.tgz#dd379e94f0db8310b08291f9d64c3209766617fd" - -backo2@1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/backo2/-/backo2-1.0.2.tgz#31ab1ac8b129363463e35b3ebb69f4dfcfba7947" - balanced-match@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" -base64-arraybuffer@0.1.5: - version "0.1.5" - resolved "https://registry.yarnpkg.com/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz#73926771923b5a19747ad666aa5cd4bf9c6e9ce8" - -better-assert@~1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/better-assert/-/better-assert-1.0.2.tgz#40866b9e1b9e0b55b481894311e68faffaebc522" - dependencies: - callsite "1.0.0" - binary-extensions@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.1.0.tgz#30fa40c9e7fe07dbc895678cd287024dea241dd9" -blob@0.0.5: - version "0.0.5" - resolved "https://registry.yarnpkg.com/blob/-/blob-0.0.5.tgz#d680eeef25f8cd91ad533f5b01eed48e64caf683" - brace-expansion@^1.1.7: version "1.1.11" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" @@ -84,10 +60,6 @@ buffer-from@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" -callsite@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/callsite/-/callsite-1.0.0.tgz#280398e5d664bd74038b6f0905153e6e8af1bc20" - camelcase-keys@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-2.1.0.tgz#308beeaffdf28119051efa1d932213c91b8f92e7" @@ -113,22 +85,6 @@ chokidar@^3.4.0: optionalDependencies: fsevents "~2.1.2" -component-bind@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/component-bind/-/component-bind-1.0.0.tgz#00c608ab7dcd93897c0009651b1d3a8e1e73bbd1" - -component-emitter@1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.2.1.tgz#137918d6d78283f7df7a6b7c5a63e140e69425e6" - -component-emitter@~1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.3.0.tgz#16e4070fba8ae29b679f2215853ee181ab2eabc0" - -component-inherit@0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/component-inherit/-/component-inherit-0.0.3.tgz#645fc4adf58b72b649d5cae65135619db26ff143" - concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" @@ -146,18 +102,6 @@ dateformat@~1.0.4-1.2.3: get-stdin "^4.0.1" meow "^3.3.0" -debug@~3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" - dependencies: - ms "2.0.0" - -debug@~4.1.0: - version "4.1.1" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791" - dependencies: - ms "^2.1.1" - decamelize@^1.1.2: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" @@ -172,32 +116,6 @@ dynamic-dedupe@^0.3.0: dependencies: xtend "^4.0.0" -engine.io-client@~3.4.0: - version "3.4.3" - resolved "https://registry.yarnpkg.com/engine.io-client/-/engine.io-client-3.4.3.tgz#192d09865403e3097e3575ebfeb3861c4d01a66c" - dependencies: - component-emitter "~1.3.0" - component-inherit "0.0.3" - debug "~4.1.0" - engine.io-parser "~2.2.0" - has-cors "1.1.0" - indexof "0.0.1" - parseqs "0.0.5" - parseuri "0.0.5" - ws "~6.1.0" - xmlhttprequest-ssl "~1.5.4" - yeast "0.1.2" - -engine.io-parser@~2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/engine.io-parser/-/engine.io-parser-2.2.0.tgz#312c4894f57d52a02b420868da7b5c1c84af80ed" - dependencies: - after "0.8.2" - arraybuffer.slice "~0.0.7" - base64-arraybuffer "0.1.5" - blob "0.0.5" - has-binary2 "~1.0.2" - error-ex@^1.2.0: version "1.3.2" resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" @@ -250,16 +168,6 @@ graceful-fs@^4.1.2: version "4.2.4" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.4.tgz#2256bde14d3632958c465ebc96dc467ca07a29fb" -has-binary2@~1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/has-binary2/-/has-binary2-1.0.3.tgz#7776ac627f3ea77250cfc332dab7ddf5e4f5d11d" - dependencies: - isarray "2.0.1" - -has-cors@1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/has-cors/-/has-cors-1.1.0.tgz#5e474793f7ea9843d1bb99c23eef49ff126fff39" - hosted-git-info@^2.1.4: version "2.8.8" resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.8.tgz#7539bd4bc1e0e0a895815a2e0262420b12858488" @@ -270,10 +178,6 @@ indent-string@^2.1.0: dependencies: repeating "^2.0.0" -indexof@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/indexof/-/indexof-0.0.1.tgz#82dc336d232b9062179d05ab3293a66059fd435d" - inflight@^1.0.4: version "1.0.6" resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" @@ -317,10 +221,6 @@ is-utf8@^0.2.0: version "0.2.1" resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" -isarray@2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/isarray/-/isarray-2.0.1.tgz#a37d94ed9cda2d59865c9f76fe596ee1f338741e" - load-json-file@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-1.1.0.tgz#956905708d58b4bab4c2261b04f59f31c99374c0" @@ -375,14 +275,6 @@ mkdirp@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" -ms@2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" - -ms@^2.1.1: - version "2.1.2" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" - normalize-package-data@^2.3.2, normalize-package-data@^2.3.4: version "2.5.0" resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.5.0.tgz#e66db1838b200c1dfc233225d12cb36520e234a8" @@ -400,10 +292,6 @@ object-assign@^4.0.1: version "4.1.1" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" -object-component@0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/object-component/-/object-component-0.0.3.tgz#f0c69aa50efc95b866c186f400a33769cb2f1291" - once@^1.3.0: version "1.4.0" resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" @@ -416,18 +304,6 @@ parse-json@^2.2.0: dependencies: error-ex "^1.2.0" -parseqs@0.0.5: - version "0.0.5" - resolved "https://registry.yarnpkg.com/parseqs/-/parseqs-0.0.5.tgz#d5208a3738e46766e291ba2ea173684921a8b89d" - dependencies: - better-assert "~1.0.0" - -parseuri@0.0.5: - version "0.0.5" - resolved "https://registry.yarnpkg.com/parseuri/-/parseuri-0.0.5.tgz#80204a50d4dbb779bfdc6ebe2778d90e4bce320a" - dependencies: - better-assert "~1.0.0" - path-exists@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-2.1.0.tgz#0feb6c64f0fc518d9a754dd5efb62c7022761f4b" @@ -522,33 +398,6 @@ signal-exit@^3.0.0: version "3.0.3" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c" -socket.io-client@^2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/socket.io-client/-/socket.io-client-2.3.0.tgz#14d5ba2e00b9bcd145ae443ab96b3f86cbcc1bb4" - dependencies: - backo2 "1.0.2" - base64-arraybuffer "0.1.5" - component-bind "1.0.0" - component-emitter "1.2.1" - debug "~4.1.0" - engine.io-client "~3.4.0" - has-binary2 "~1.0.2" - has-cors "1.1.0" - indexof "0.0.1" - object-component "0.0.3" - parseqs "0.0.5" - parseuri "0.0.5" - socket.io-parser "~3.3.0" - to-array "0.1.4" - -socket.io-parser@~3.3.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-3.3.0.tgz#2b52a96a509fdf31440ba40fed6094c7d4f1262f" - dependencies: - component-emitter "1.2.1" - debug "~3.1.0" - isarray "2.0.1" - source-map-support@^0.5.12, source-map-support@^0.5.17: version "0.5.19" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61" @@ -602,10 +451,6 @@ strip-json-comments@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" -to-array@0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/to-array/-/to-array-0.1.4.tgz#17e6c11f73dd4f3d74cda7a4ff3238e9ad9bf890" - to-regex-range@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" @@ -670,24 +515,14 @@ wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" -ws@~6.1.0: - version "6.1.4" - resolved "https://registry.yarnpkg.com/ws/-/ws-6.1.4.tgz#5b5c8800afab925e94ccb29d153c8d02c1776ef9" - dependencies: - async-limiter "~1.0.0" - -xmlhttprequest-ssl@~1.5.4: - version "1.5.5" - resolved "https://registry.yarnpkg.com/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.5.tgz#c2876b06168aadc40e57d97e81191ac8f4398b3e" +ws@^7.3.1: + version "7.3.1" + resolved "https://registry.yarnpkg.com/ws/-/ws-7.3.1.tgz#d0547bf67f7ce4f12a72dfe31262c68d7dc551c8" xtend@^4.0.0: version "4.0.2" resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54" -yeast@0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/yeast/-/yeast-0.1.2.tgz#008e06d8094320c372dbc2f8ed76a0ca6c8ac419" - yn@3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" diff --git a/front/src/Connection.ts b/front/src/Connection.ts index 61b0c4e7..d7036ba8 100644 --- a/front/src/Connection.ts +++ b/front/src/Connection.ts @@ -2,15 +2,13 @@ import Axios from "axios"; import {API_URL} from "./Enum/EnvironmentVariable"; import {MessageUI} from "./Logger/MessageUI"; import { - BatchMessage, GroupDeleteMessage, GroupUpdateMessage, ItemEventMessage, - PositionMessage, - SetPlayerDetailsMessage, UserJoinedMessage, UserLeftMessage, UserMovedMessage, + BatchMessage, ClientToServerMessage, GroupDeleteMessage, GroupUpdateMessage, ItemEventMessage, JoinRoomMessage, + PositionMessage, RoomJoinedMessage, ServerToClientMessage, + SetPlayerDetailsMessage, SetUserIdMessage, SilentMessage, UserJoinedMessage, UserLeftMessage, UserMovedMessage, UserMovesMessage, ViewportMessage } from "./Messages/generated/messages_pb" -const SocketIo = require('socket.io-client'); -import Socket = SocketIOClient.Socket; import {PlayerAnimationNames} from "./Phaser/Player/Animation"; import {UserSimplePeerInterface} from "./WebRtc/SimplePeer"; import {SignalData} from "simple-peer"; @@ -132,63 +130,91 @@ export interface RoomJoinedMessageInterface { } export class Connection implements Connection { - private readonly socket: Socket; + private readonly socket: WebSocket; private userId: number|null = null; private batchCallbacks: Map = new Map(); + private static websocketFactory: null|((url: string)=>any) = null; + + public static setWebsocketFactory(websocketFactory: (url: string)=>any): void { + Connection.websocketFactory = websocketFactory; + } private constructor(token: string) { + let url = API_URL.replace('http://', 'ws://').replace('https://', 'wss://'); + url += '?token='+token; - this.socket = SocketIo(`${API_URL}`, { - query: { - token: token - }, - reconnection: false // Reconnection is handled by the application itself - }); + if (Connection.websocketFactory) { + this.socket = Connection.websocketFactory(url); + } else { + this.socket = new WebSocket(url); + } - this.socket.on(EventMessage.MESSAGE_ERROR, (message: string) => { - console.error(EventMessage.MESSAGE_ERROR, message); - }) + this.socket.binaryType = 'arraybuffer'; - /** - * Messages inside batched messages are extracted and sent to listeners directly. - */ - this.socket.on(EventMessage.BATCH, (batchedMessagesBinary: ArrayBuffer) => { - const batchMessage = BatchMessage.deserializeBinary(new Uint8Array(batchedMessagesBinary)); + this.socket.onopen = (ev) => { + console.log('WS connected'); + }; - for (const message of batchMessage.getPayloadList()) { - let event: string; - let payload; - if (message.hasUsermovedmessage()) { - event = EventMessage.USER_MOVED; - payload = message.getUsermovedmessage(); - } else if (message.hasGroupupdatemessage()) { - event = EventMessage.GROUP_CREATE_UPDATE; - payload = message.getGroupupdatemessage(); - } else if (message.hasGroupdeletemessage()) { - event = EventMessage.GROUP_DELETE; - payload = message.getGroupdeletemessage(); - } else if (message.hasUserjoinedmessage()) { - event = EventMessage.JOIN_ROOM; - payload = message.getUserjoinedmessage(); - } else if (message.hasUserleftmessage()) { - event = EventMessage.USER_LEFT; - payload = message.getUserleftmessage(); - } else if (message.hasItemeventmessage()) { - event = EventMessage.ITEM_EVENT; - payload = message.getItemeventmessage(); - } else { - throw new Error('Unexpected batch message type'); + this.socket.onmessage = (messageEvent) => { + const arrayBuffer: ArrayBuffer = messageEvent.data; + const message = ServerToClientMessage.deserializeBinary(new Uint8Array(arrayBuffer)); + + if (message.hasBatchmessage()) { + for (const subMessage of (message.getBatchmessage() as BatchMessage).getPayloadList()) { + let event: string; + let payload; + if (subMessage.hasUsermovedmessage()) { + event = EventMessage.USER_MOVED; + payload = subMessage.getUsermovedmessage(); + } else if (subMessage.hasGroupupdatemessage()) { + event = EventMessage.GROUP_CREATE_UPDATE; + payload = subMessage.getGroupupdatemessage(); + } else if (subMessage.hasGroupdeletemessage()) { + event = EventMessage.GROUP_DELETE; + payload = subMessage.getGroupdeletemessage(); + } else if (subMessage.hasUserjoinedmessage()) { + event = EventMessage.JOIN_ROOM; + payload = subMessage.getUserjoinedmessage(); + } else if (subMessage.hasUserleftmessage()) { + event = EventMessage.USER_LEFT; + payload = subMessage.getUserleftmessage(); + } else if (subMessage.hasItemeventmessage()) { + event = EventMessage.ITEM_EVENT; + payload = subMessage.getItemeventmessage(); + } else { + throw new Error('Unexpected batch message type'); + } + + const listeners = this.batchCallbacks.get(event); + if (listeners === undefined) { + continue; + } + for (const listener of listeners) { + listener(payload); + } + } + } else if (message.hasRoomjoinedmessage()) { + const roomJoinedMessage = message.getRoomjoinedmessage() as RoomJoinedMessage; + + const users: Array = roomJoinedMessage.getUserList().map(this.toMessageUserJoined); + const groups: Array = roomJoinedMessage.getGroupList().map(this.toGroupCreatedUpdatedMessage); + let items: { [itemId: number] : unknown } = {}; + for (const item of roomJoinedMessage.getItemList()) { + items[item.getItemid()] = JSON.parse(item.getStatejson()); } - const listeners = this.batchCallbacks.get(event); - if (listeners === undefined) { - continue; - } - for (const listener of listeners) { - listener(payload); - } + this.resolveJoinRoom({ + users, + groups, + items + }) + } else if (message.hasSetuseridmessage()) { + this.userId = (message.getSetuseridmessage() as SetUserIdMessage).getUserid(); + } else if (message.hasErrormessage()) { + console.error(EventMessage.MESSAGE_ERROR, message.getErrormessage()?.getMessage); } - }) + + } } public static createConnection(name: string, characterLayersSelected: string[]): Promise { @@ -203,18 +229,23 @@ export class Connection implements Connection { reject(error); }); - const message = new SetPlayerDetailsMessage(); - message.setName(name); - message.setCharacterlayersList(characterLayersSelected); - connection.socket.emit(EventMessage.SET_PLAYER_DETAILS, message.serializeBinary().buffer, (id: number) => { - connection.userId = id; - }); + connection.onConnect(() => { + const message = new SetPlayerDetailsMessage(); + message.setName(name); + message.setCharacterlayersList(characterLayersSelected); - resolve(connection); + const clientToServerMessage = new ClientToServerMessage(); + clientToServerMessage.setSetplayerdetailsmessage(message); + + connection.socket.send(clientToServerMessage.serializeBinary().buffer); + + resolve(connection); + }); }); }) .catch((err) => { // Let's retry in 4-6 seconds + console.error('Connection failed. Retrying', err); return new Promise((resolve, reject) => { setTimeout(() => { Connection.createConnection(name, characterLayersSelected).then((connection) => resolve(connection)) @@ -228,24 +259,30 @@ export class Connection implements Connection { this.socket?.close(); } + private resolveJoinRoom!: (value?: (RoomJoinedMessageInterface | PromiseLike | undefined)) => void; public joinARoom(roomId: string, startX: number, startY: number, direction: string, moving: boolean, viewport: ViewportInterface): Promise { const promise = new Promise((resolve, reject) => { - this.socket.emit(EventMessage.JOIN_ROOM, { - roomId, - position: {x: startX, y: startY, direction, moving }, - viewport, - }, (roomJoinedMessage: RoomJoinedMessageInterface) => { - resolve(roomJoinedMessage); - }); + this.resolveJoinRoom = resolve; + + const positionMessage = this.toPositionMessage(startX, startY, direction, moving); + const viewportMessage = this.toViewportMessage(viewport); + + const joinRoomMessage = new JoinRoomMessage(); + joinRoomMessage.setRoomid(roomId); + joinRoomMessage.setPosition(positionMessage); + joinRoomMessage.setViewport(viewportMessage); + + //console.log('Sending position ', positionMessage.getX(), positionMessage.getY()); + const clientToServerMessage = new ClientToServerMessage(); + clientToServerMessage.setJoinroommessage(joinRoomMessage); + + this.socket.send(clientToServerMessage.serializeBinary().buffer); }) return promise; } - public sharePosition(x : number, y : number, direction : string, moving: boolean, viewport: ViewportInterface) : void{ - if(!this.socket){ - return; - } + private toPositionMessage(x : number, y : number, direction : string, moving: boolean): PositionMessage { const positionMessage = new PositionMessage(); positionMessage.setX(Math.floor(x)); positionMessage.setY(Math.floor(y)); @@ -269,23 +306,47 @@ export class Connection implements Connection { positionMessage.setDirection(directionEnum); positionMessage.setMoving(moving); + return positionMessage; + } + + private toViewportMessage(viewport: ViewportInterface): ViewportMessage { const viewportMessage = new ViewportMessage(); viewportMessage.setLeft(Math.floor(viewport.left)); viewportMessage.setRight(Math.floor(viewport.right)); viewportMessage.setTop(Math.floor(viewport.top)); viewportMessage.setBottom(Math.floor(viewport.bottom)); + return viewportMessage; + } + + public sharePosition(x : number, y : number, direction : string, moving: boolean, viewport: ViewportInterface) : void{ + if(!this.socket){ + return; + } + + const positionMessage = this.toPositionMessage(x, y, direction, moving); + + const viewportMessage = this.toViewportMessage(viewport); + const userMovesMessage = new UserMovesMessage(); userMovesMessage.setPosition(positionMessage); userMovesMessage.setViewport(viewportMessage); //console.log('Sending position ', positionMessage.getX(), positionMessage.getY()); + const clientToServerMessage = new ClientToServerMessage(); + clientToServerMessage.setUsermovesmessage(userMovesMessage); - this.socket.emit(EventMessage.USER_POSITION, userMovesMessage.serializeBinary().buffer); + this.socket.send(clientToServerMessage.serializeBinary().buffer); } public setSilent(silent: boolean): void { - this.socket.emit(EventMessage.SET_SILENT, silent); + const silentMessage = new SilentMessage(); + silentMessage.setSilent(silent); + + const clientToServerMessage = new ClientToServerMessage(); + clientToServerMessage.setSilentmessage(silentMessage); + + this.socket.send(clientToServerMessage.serializeBinary().buffer); } public setViewport(viewport: ViewportInterface): void { @@ -295,25 +356,32 @@ export class Connection implements Connection { viewportMessage.setLeft(Math.round(viewport.left)); viewportMessage.setRight(Math.round(viewport.right)); - this.socket.emit(EventMessage.SET_VIEWPORT, viewportMessage.serializeBinary().buffer); + const clientToServerMessage = new ClientToServerMessage(); + clientToServerMessage.setViewportmessage(viewportMessage); + + this.socket.send(clientToServerMessage.serializeBinary().buffer); } public onUserJoins(callback: (message: MessageUserJoined) => void): void { this.onBatchMessage(EventMessage.JOIN_ROOM, (message: UserJoinedMessage) => { - const position = message.getPosition(); - if (position === undefined) { - throw new Error('Invalid JOIN_ROOM message'); - } - const messageUserJoined: MessageUserJoined = { - userId: message.getUserid(), - name: message.getName(), - characterLayers: message.getCharacterlayersList(), - position: ProtobufClientUtils.toPointInterface(position) - } - callback(messageUserJoined); + callback(this.toMessageUserJoined(message)); }); } + // TODO: move this to protobuf utils + private toMessageUserJoined(message: UserJoinedMessage): MessageUserJoined { + const position = message.getPosition(); + if (position === undefined) { + throw new Error('Invalid JOIN_ROOM message'); + } + return { + userId: message.getUserid(), + name: message.getName(), + characterLayers: message.getCharacterlayersList(), + position: ProtobufClientUtils.toPointInterface(position) + } + } + public onUserMoved(callback: (message: UserMovedMessage) => void): void { this.onBatchMessage(EventMessage.USER_MOVED, callback); //this.socket.on(EventMessage.USER_MOVED, callback); @@ -339,64 +407,73 @@ export class Connection implements Connection { public onGroupUpdatedOrCreated(callback: (groupCreateUpdateMessage: GroupCreatedUpdatedMessageInterface) => void): void { this.onBatchMessage(EventMessage.GROUP_CREATE_UPDATE, (message: GroupUpdateMessage) => { - const position = message.getPosition(); - if (position === undefined) { - throw new Error('Missing position in GROUP_CREATE_UPDATE'); - } - - const groupCreateUpdateMessage: GroupCreatedUpdatedMessageInterface = { - groupId: message.getGroupid(), - position: position.toObject() - } - - //console.log('Group position: ', position.toObject()); - callback(groupCreateUpdateMessage); + callback(this.toGroupCreatedUpdatedMessage(message)); }); } + private toGroupCreatedUpdatedMessage(message: GroupUpdateMessage): GroupCreatedUpdatedMessageInterface { + const position = message.getPosition(); + if (position === undefined) { + throw new Error('Missing position in GROUP_CREATE_UPDATE'); + } + + return { + groupId: message.getGroupid(), + position: position.toObject() + } + } + public onGroupDeleted(callback: (groupId: number) => void): void { this.onBatchMessage(EventMessage.GROUP_DELETE, (message: GroupDeleteMessage) => { callback(message.getGroupid()); }); } - public onConnectError(callback: (error: object) => void): void { - this.socket.on(EventMessage.CONNECT_ERROR, callback) + public onConnectError(callback: (error: Event) => void): void { + this.socket.addEventListener('error', callback) + } + + public onConnect(callback: (event: Event) => void): void { + this.socket.addEventListener('open', callback) } public sendWebrtcSignal(signal: unknown, receiverId: number) { - return this.socket.emit(EventMessage.WEBRTC_SIGNAL, { +/* return this.socket.emit(EventMessage.WEBRTC_SIGNAL, { receiverId: receiverId, signal: signal - } as WebRtcSignalSentMessageInterface); + } as WebRtcSignalSentMessageInterface);*/ } public sendWebrtcScreenSharingSignal(signal: unknown, receiverId: number) { - return this.socket.emit(EventMessage.WEBRTC_SCREEN_SHARING_SIGNAL, { +/* return this.socket.emit(EventMessage.WEBRTC_SCREEN_SHARING_SIGNAL, { receiverId: receiverId, signal: signal - } as WebRtcSignalSentMessageInterface); + } as WebRtcSignalSentMessageInterface);*/ } public receiveWebrtcStart(callback: (message: WebRtcStartMessageInterface) => void) { - this.socket.on(EventMessage.WEBRTC_START, callback); +// TODO + // this.socket.on(EventMessage.WEBRTC_START, callback); } public receiveWebrtcSignal(callback: (message: WebRtcSignalReceivedMessageInterface) => void) { - return this.socket.on(EventMessage.WEBRTC_SIGNAL, callback); +// TODO + // return this.socket.on(EventMessage.WEBRTC_SIGNAL, callback); } public receiveWebrtcScreenSharingSignal(callback: (message: WebRtcSignalReceivedMessageInterface) => void) { - return this.socket.on(EventMessage.WEBRTC_SCREEN_SHARING_SIGNAL, callback); +// TODO + // return this.socket.on(EventMessage.WEBRTC_SCREEN_SHARING_SIGNAL, callback); } - public onServerDisconnected(callback: (reason: string) => void): void { - this.socket.on('disconnect', (reason: string) => { - if (reason === 'io client disconnect') { - // The client asks for disconnect, let's not trigger any event. + public onServerDisconnected(callback: (event: CloseEvent) => void): void { + this.socket.addEventListener('close', (event) => { + + if (event.code === 1000) { + // Normal closure case return; } - callback(reason); + callback(event); }); } @@ -406,7 +483,8 @@ export class Connection implements Connection { } disconnectMessage(callback: (message: WebRtcDisconnectMessageInterface) => void): void { - this.socket.on(EventMessage.WEBRTC_DISCONNECT, callback); +// TODO + // this.socket.on(EventMessage.WEBRTC_DISCONNECT, callback); } emitActionableEvent(itemId: number, event: string, state: unknown, parameters: unknown): void { @@ -416,7 +494,10 @@ export class Connection implements Connection { itemEventMessage.setStatejson(JSON.stringify(state)); itemEventMessage.setParametersjson(JSON.stringify(parameters)); - this.socket.emit(EventMessage.ITEM_EVENT, itemEventMessage.serializeBinary().buffer); + const clientToServerMessage = new ClientToServerMessage(); + clientToServerMessage.setItemeventmessage(itemEventMessage); + + this.socket.send(clientToServerMessage.serializeBinary().buffer); } onActionableEvent(callback: (message: ItemEventMessageInterface) => void): void { diff --git a/messages/messages.proto b/messages/messages.proto index 57b1f2ea..6dd936fc 100644 --- a/messages/messages.proto +++ b/messages/messages.proto @@ -27,6 +27,10 @@ message ViewportMessage { int32 bottom = 4; } +message SilentMessage { + bool silent = 1; +} + /*********** CLIENT TO SERVER MESSAGES *************/ message SetPlayerDetailsMessage { @@ -34,11 +38,29 @@ message SetPlayerDetailsMessage { repeated string characterLayers = 2; } +message JoinRoomMessage { + string roomId = 1; + PositionMessage position = 2; + ViewportMessage viewport = 3; +} + message UserMovesMessage { PositionMessage position = 1; ViewportMessage viewport = 2; } +message ClientToServerMessage { + oneof message { + JoinRoomMessage joinRoomMessage = 1; + UserMovesMessage userMovesMessage = 2; + SilentMessage silentMessage = 3; + ViewportMessage viewportMessage = 4; + ItemEventMessage itemEventMessage = 5; + SetPlayerDetailsMessage setPlayerDetailsMessage = 6; + } +} + + /************ BI-DIRECTIONAL MESSAGES **************/ message ItemEventMessage { @@ -90,3 +112,44 @@ message UserJoinedMessage { message UserLeftMessage { int32 userId = 1; } + +message ErrorMessage { + string message = 1; +} + +message SetUserIdMessage { + int32 userId = 1; +} + +message ItemStateMessage { + int32 itemId = 1; + string stateJson = 2; +} + +message RoomJoinedMessage { + repeated UserJoinedMessage user = 1; + repeated GroupUpdateMessage group = 2; + repeated ItemStateMessage item = 3; +} + + +/*message WebRtcStartMessage { + int32 itemId = 1; + string event = 2; + string stateJson = 3; + string parametersJson = 4; +}*/ + + +message ServerToClientMessage { + oneof message { + BatchMessage batchMessage = 1; + ErrorMessage errorMessage = 2; + RoomJoinedMessage roomJoinedMessage = 3; + SetUserIdMessage setUserIdMessage = 4; // TODO: merge this with RoomJoinedMessage ? +// WebRtcStartMessage webRtcStartMessage = 3; +// WebRtcSignalMessage webRtcSignalMessage = 4; +// WebRtcScreenSharingSignalMessage webRtcScreenSharingSignalMessage = 5; +// WebRtcDisconnectMessage webRtcDisconnectMessage = 6; + } +} From 2cea0e490bc6cfaafe45062cb955f49145b158c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Tue, 29 Sep 2020 09:45:47 +0200 Subject: [PATCH 070/122] Fixing disconnect call --- back/src/Controller/IoSocketController.ts | 13 +++++++------ back/src/Controller/PrometheusController.ts | 9 +++++---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index 1928679d..d9bdc950 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -66,13 +66,14 @@ enum SocketIoEvent { } function emitInBatch(socket: ExSocketInterface, payload: SubMessage): void { - if (socket.disconnecting) { - return; - } socket.batchedMessages.addPayload(payload); if (socket.batchTimeout === null) { socket.batchTimeout = setTimeout(() => { + if (socket.disconnecting) { + return; + } + const serverToClientMessage = new ServerToClientMessage(); serverToClientMessage.setBatchmessage(socket.batchedMessages); @@ -688,13 +689,13 @@ export class IoSocketController { // TODO: REBUILD THIS return; - if (socket.webRtcRoomId === roomId) { +/* if (socket.webRtcRoomId === roomId) { return; } socket.join(roomId); socket.webRtcRoomId = roomId; //if two persons in room share - if (this.Io.sockets.adapter.rooms[roomId].length < 2 /*|| this.Io.sockets.adapter.rooms[roomId].length >= 4*/) { + if (this.Io.sockets.adapter.rooms[roomId].length < 2) { return; } @@ -718,7 +719,7 @@ export class IoSocketController { }, []); client.emit(SocketIoEvent.WEBRTC_START, {clients: peerClients, roomId: roomId}); - }); + });*/ } /** permit to share user position diff --git a/back/src/Controller/PrometheusController.ts b/back/src/Controller/PrometheusController.ts index 0a0db2bb..95254af8 100644 --- a/back/src/Controller/PrometheusController.ts +++ b/back/src/Controller/PrometheusController.ts @@ -1,10 +1,11 @@ -import {Application, Request, Response} from "express"; +import {App} from "../Server/sifrr.server"; import {IoSocketController} from "_Controller/IoSocketController"; +import {HttpRequest, HttpResponse} from "uWebSockets.js"; const register = require('prom-client').register; const collectDefaultMetrics = require('prom-client').collectDefaultMetrics; export class PrometheusController { - constructor(private App: Application, private ioSocketController: IoSocketController) { + constructor(private App: App, private ioSocketController: IoSocketController) { collectDefaultMetrics({ timeout: 10000, gcDurationBuckets: [0.001, 0.01, 0.1, 1, 2, 5], // These are the default buckets. @@ -13,8 +14,8 @@ export class PrometheusController { this.App.get("/metrics", this.metrics.bind(this)); } - private metrics(req: Request, res: Response): void { - res.set('Content-Type', register.contentType); + private metrics(res: HttpResponse, req: HttpRequest): void { + res.writeHeader('Content-Type', register.contentType); res.end(register.metrics()); } } From a9b1313d39c9e6ff5acbcc2f5031847187c8ecf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Tue, 29 Sep 2020 10:57:14 +0200 Subject: [PATCH 071/122] Cleanup --- back/src/App.ts | 4 - back/src/Controller/AdminController.ts | 24 +-- back/src/Controller/AuthenticateController.ts | 2 - back/src/Controller/DebugController.ts | 15 +- back/src/Controller/IoSocketController.ts | 10 +- back/src/Server/server/baseapp.ts | 113 +---------- back/src/Server/server/cluster.ts | 48 ----- back/src/Server/server/formdata.ts | 99 ---------- back/src/Server/server/graphiql.html | 133 ------------- back/src/Server/server/graphql.ts | 138 -------------- back/src/Server/server/livereload.ts | 35 ---- back/src/Server/server/livereloadjs.js | 47 ----- back/src/Server/server/loadroutes.ts | 42 ----- back/src/Server/server/mime.ts | 176 ------------------ back/src/Server/server/sendfile.ts | 172 ----------------- back/src/Server/server/types.ts | 15 -- back/src/Server/server/utils.ts | 21 +-- back/src/Server/sifrr.server.ts | 13 +- 18 files changed, 32 insertions(+), 1075 deletions(-) delete mode 100644 back/src/Server/server/cluster.ts delete mode 100644 back/src/Server/server/formdata.ts delete mode 100644 back/src/Server/server/graphiql.html delete mode 100644 back/src/Server/server/graphql.ts delete mode 100644 back/src/Server/server/livereload.ts delete mode 100644 back/src/Server/server/livereloadjs.js delete mode 100644 back/src/Server/server/loadroutes.ts delete mode 100644 back/src/Server/server/mime.ts delete mode 100644 back/src/Server/server/sendfile.ts diff --git a/back/src/App.ts b/back/src/App.ts index c13b6fdc..5853f4d6 100644 --- a/back/src/App.ts +++ b/back/src/App.ts @@ -1,10 +1,6 @@ // lib/app.ts import {IoSocketController} from "./Controller/IoSocketController"; //TODO fix import by "_Controller/..." import {AuthenticateController} from "./Controller/AuthenticateController"; //TODO fix import by "_Controller/..." -import express from "express"; -import {Application, Request, Response} from 'express'; -import bodyParser = require('body-parser'); -import * as http from "http"; import {MapController} from "./Controller/MapController"; import {PrometheusController} from "./Controller/PrometheusController"; import {AdminController} from "./Controller/AdminController"; diff --git a/back/src/Controller/AdminController.ts b/back/src/Controller/AdminController.ts index c4905a8a..78280523 100644 --- a/back/src/Controller/AdminController.ts +++ b/back/src/Controller/AdminController.ts @@ -1,24 +1,26 @@ -import {Application, Request, Response} from "express"; import {OK} from "http-status-codes"; import {ADMIN_API_TOKEN, ADMIN_API_URL} from "../Enum/EnvironmentVariable"; import Axios from "axios"; +import {HttpRequest, HttpResponse} from "uWebSockets.js"; +import {parse} from "query-string"; +import {App} from "../Server/sifrr.server"; export class AdminController { - App : Application; - - constructor(App : Application) { - this.App = App; + constructor(private App : App) { this.getLoginUrlByToken(); } - + getLoginUrlByToken(){ - this.App.get("/register/:token", async (req: Request, res: Response) => { + this.App.get("/register/:token", async (res: HttpResponse, req: HttpRequest) => { if (!ADMIN_API_URL) { - return res.status(500).send('No admin backoffice set!'); + return res.writeStatus("500 Internal Server Error").end('No admin backoffice set!'); } - const token:string = req.params.token; - + + const query = parse(req.getQuery()); + + const token:string = query.token as string; + let response = null try { response = await Axios.get(ADMIN_API_URL+'/api/login-url/'+token, { headers: {"Authorization" : `${ADMIN_API_TOKEN}`} }) @@ -30,7 +32,7 @@ export class AdminController { const organizationSlug = response.data.organizationSlug; const worldSlug = response.data.worldSlug; const roomSlug = response.data.roomSlug; - return res.status(OK).send({organizationSlug, worldSlug, roomSlug}); + return res.writeStatus("200 OK").end(JSON.stringify({organizationSlug, worldSlug, roomSlug})); }); } } diff --git a/back/src/Controller/AuthenticateController.ts b/back/src/Controller/AuthenticateController.ts index a65255a2..b7fd093c 100644 --- a/back/src/Controller/AuthenticateController.ts +++ b/back/src/Controller/AuthenticateController.ts @@ -1,6 +1,4 @@ -import {Application, Request, Response} from "express"; import Jwt from "jsonwebtoken"; -import {BAD_REQUEST, OK} from "http-status-codes"; import {SECRET_KEY, URL_ROOM_STARTED} from "../Enum/EnvironmentVariable"; //TODO fix import by "_Enum/..." import { uuid } from 'uuidv4'; import {HttpRequest, HttpResponse, TemplatedApp} from "uWebSockets.js"; diff --git a/back/src/Controller/DebugController.ts b/back/src/Controller/DebugController.ts index 54544f6c..e77b28f3 100644 --- a/back/src/Controller/DebugController.ts +++ b/back/src/Controller/DebugController.ts @@ -1,22 +1,25 @@ -import {Application, Request, Response} from "express"; -import {OK} from "http-status-codes"; import {ADMIN_API_TOKEN} from "../Enum/EnvironmentVariable"; import {IoSocketController} from "_Controller/IoSocketController"; import {stringify} from "circular-json"; +import {HttpRequest, HttpResponse} from "uWebSockets.js"; +import { parse } from 'query-string'; +import {App} from "../Server/sifrr.server"; export class DebugController { - constructor(private App : Application, private ioSocketController: IoSocketController) { + constructor(private App : App, private ioSocketController: IoSocketController) { this.getDump(); } getDump(){ - this.App.get("/dump", (req: Request, res: Response) => { - if (req.query.token !== ADMIN_API_TOKEN) { + this.App.get("/dump", (res: HttpResponse, req: HttpRequest) => { + const query = parse(req.getQuery()); + + if (query.token !== ADMIN_API_TOKEN) { return res.status(401).send('Invalid token sent!'); } - return res.status(OK).contentType('application/json').send(stringify( + return res.writeStatus('200 OK').writeHeader('Content-Type', 'application/json').end(stringify( this.ioSocketController.getWorlds(), (key: unknown, value: unknown) => { if(value instanceof Map) { diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index d9bdc950..cd3d5e52 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -121,7 +121,7 @@ export class IoSocketController { * * @param token */ - searchClientByToken(token: string): ExSocketInterface | null { +/* searchClientByToken(token: string): ExSocketInterface | null { const clients: ExSocketInterface[] = Object.values(this.Io.sockets.sockets) as ExSocketInterface[]; for (let i = 0; i < clients.length; i++) { const client = clients[i]; @@ -131,7 +131,7 @@ export class IoSocketController { return client; } return null; - } + }*/ private authenticate(ws: WebSocket) { //console.log(socket.handshake.query.token); @@ -657,25 +657,23 @@ export class IoSocketController { //socket.emit(SocketIoEvent.GROUP_CREATE_UPDATE, groupUpdateMessage.serializeBinary().buffer); } - private emitDeleteGroupEvent(socket: Socket, groupId: number): void { + private emitDeleteGroupEvent(client: ExSocketInterface, groupId: number): void { const groupDeleteMessage = new GroupDeleteMessage(); groupDeleteMessage.setGroupid(groupId); const subMessage = new SubMessage(); subMessage.setGroupdeletemessage(groupDeleteMessage); - const client : ExSocketInterface = socket as ExSocketInterface; emitInBatch(client, subMessage); } - private emitUserLeftEvent(socket: Socket, userId: number): void { + private emitUserLeftEvent(client: ExSocketInterface, userId: number): void { const userLeftMessage = new UserLeftMessage(); userLeftMessage.setUserid(userId); const subMessage = new SubMessage(); subMessage.setUserleftmessage(userLeftMessage); - const client : ExSocketInterface = socket as ExSocketInterface; emitInBatch(client, subMessage); } diff --git a/back/src/Server/server/baseapp.ts b/back/src/Server/server/baseapp.ts index dbac5929..d723c33d 100644 --- a/back/src/Server/server/baseapp.ts +++ b/back/src/Server/server/baseapp.ts @@ -1,18 +1,9 @@ -import { readdirSync, statSync } from 'fs'; -import { join, relative } from 'path'; import { Readable } from 'stream'; import { us_listen_socket_close, TemplatedApp, HttpResponse, HttpRequest } from 'uWebSockets.js'; -//import { watch } from 'chokidar'; -import { wsConfig } from './livereload'; -import sendFile from './sendfile'; -import formData from './formdata'; -import loadroutes from './loadroutes'; -import { graphqlPost, graphqlWs } from './graphql'; import { stob } from './utils'; -import { SendFileOptions, Handler } from './types'; +import { Handler } from './types'; -const contTypes = ['application/x-www-form-urlencoded', 'multipart/form-data']; const noOp = () => true; const handleBody = (res: HttpResponse, req: HttpRequest) => { @@ -24,7 +15,7 @@ const handleBody = (res: HttpResponse, req: HttpRequest) => { this.onData((ab, isLast) => { // uint and then slicing is bit faster than slice and then uint - stream.push(new Uint8Array(ab.slice(ab.byteOffset, ab.byteLength))); + stream.push(new Uint8Array(ab.slice((ab as any).byteOffset, ab.byteLength))); if (isLast) { stream.push(null); } @@ -37,15 +28,10 @@ const handleBody = (res: HttpResponse, req: HttpRequest) => { if (contType.indexOf('application/json') > -1) res.json = async () => JSON.parse(await res.body()); - if (contTypes.map(t => contType.indexOf(t) > -1).indexOf(true) > -1) - res.formData = formData.bind(res, contType); }; class BaseApp { - _staticPaths = new Map(); - //_watched = new Map(); _sockets = new Map(); - __livereloadenabled = false; ws!: TemplatedApp['ws']; get!: TemplatedApp['get']; _post!: TemplatedApp['post']; @@ -53,84 +39,6 @@ class BaseApp { _patch!: TemplatedApp['patch']; _listen!: TemplatedApp['listen']; - file(pattern: string, filePath: string, options: SendFileOptions = {}) { - pattern=pattern.replace(/\\/g,'/'); - if (this._staticPaths.has(pattern)) { - if (options.failOnDuplicateRoute) - throw Error( - `Error serving '${filePath}' for '${pattern}', already serving '${ - this._staticPaths.get(pattern)[0] - }' file for this pattern.` - ); - else if (!options.overwriteRoute) return this; - } - - if (options.livereload && !this.__livereloadenabled) { - this.ws('/__sifrrLiveReload', wsConfig); - this.file('/livereload.js', join(__dirname, './livereloadjs.js')); - this.__livereloadenabled = true; - } - - this._staticPaths.set(pattern, [filePath, options]); - this.get(pattern, this._serveStatic); - return this; - } - - folder(prefix: string, folder: string, options: SendFileOptions, base: string = folder) { - // not a folder - if (!statSync(folder).isDirectory()) { - throw Error('Given path is not a directory: ' + folder); - } - - // ensure slash in beginning and no trailing slash for prefix - if (prefix[0] !== '/') prefix = '/' + prefix; - if (prefix[prefix.length - 1] === '/') prefix = prefix.slice(0, -1); - - // serve folder - const filter = options ? options.filter || noOp : noOp; - readdirSync(folder).forEach(file => { - // Absolute path - const filePath = join(folder, file); - // Return if filtered - if (!filter(filePath)) return; - - if (statSync(filePath).isDirectory()) { - // Recursive if directory - this.folder(prefix, filePath, options, base); - } else { - this.file(prefix + '/' + relative(base, filePath), filePath, options); - } - }); - - /*if (options && options.watch) { - if (!this._watched.has(folder)) { - const w = watch(folder); - - w.on('unlink', filePath => { - const url = '/' + relative(base, filePath); - this._staticPaths.delete(prefix + url); - }); - - w.on('add', filePath => { - const url = '/' + relative(base, filePath); - this.file(prefix + url, filePath, options); - }); - - this._watched.set(folder, w); - } - }*/ - return this; - } - - _serveStatic(res: HttpResponse, req: HttpRequest) { - res.onAborted(noOp); - const options = this._staticPaths.get(req.getUrl()); - if (typeof options === 'undefined') { - res.writeStatus('404 Not Found'); - res.end(); - } else sendFile(res, req, options[0], options[1]); - } - post(pattern: string, handler: Handler) { if (typeof handler !== 'function') throw Error(`handler should be a function, given ${typeof handler}.`); @@ -163,21 +71,6 @@ class BaseApp { return this; } - graphql(route: string, schema, graphqlOptions: any = {}, uwsOptions = {}, graphql) { - const handler = graphqlPost(schema, graphqlOptions, graphql); - this.post(route, handler); - this.ws(route, graphqlWs(schema, graphqlOptions, uwsOptions, graphql)); - // this.get(route, handler); - if (graphqlOptions && graphqlOptions.graphiqlPath) - this.file(graphqlOptions.graphiqlPath, join(__dirname, './graphiql.html')); - return this; - } - - load(dir: string, options) { - loadroutes.call(this, dir, options); - return this; - } - listen(h: string | number, p: Function | number = noOp, cb?: Function) { if (typeof p === 'number' && typeof h === 'string') { this._listen(h, p, socket => { @@ -202,8 +95,6 @@ class BaseApp { } close(port: null | number = null) { - //this._watched.forEach(v => v.close()); - //this._watched.clear(); if (port) { this._sockets.has(port) && us_listen_socket_close(this._sockets.get(port)); this._sockets.delete(port); diff --git a/back/src/Server/server/cluster.ts b/back/src/Server/server/cluster.ts deleted file mode 100644 index 5b875327..00000000 --- a/back/src/Server/server/cluster.ts +++ /dev/null @@ -1,48 +0,0 @@ -const noop = (a, b) => {}; - -export default class Cluster { - apps: any[]; - listens = {}; - // apps = [ { app: SifrrServerApp, port/ports: int } ] - constructor(apps) { - if (!Array.isArray(apps)) apps = [apps]; - this.apps = apps; - } - - listen(onListen = noop) { - for (let i = 0; i < this.apps.length; i++) { - const config = this.apps[i]; - let { app, port, ports } = config; - if (!Array.isArray(ports) || ports.length === 0) { - ports = [port]; - } - ports.forEach(p => { - if (typeof p !== 'number') throw Error(`Port should be a number, given ${p}`); - if (this.listens[p]) return; - - app.listen(p, socket => { - onListen.call(app, socket, p); - }); - this.listens[p] = app; - }); - } - return this; - } - - closeAll() { - Object.keys(this.listens).forEach(port => { - this.close(port); - }); - return this; - } - - close(port = null) { - if (port) { - this.listens[port] && this.listens[port].close(port); - delete this.listens[port]; - } else { - this.closeAll(); - } - return this; - } -} diff --git a/back/src/Server/server/formdata.ts b/back/src/Server/server/formdata.ts deleted file mode 100644 index 419e6c6b..00000000 --- a/back/src/Server/server/formdata.ts +++ /dev/null @@ -1,99 +0,0 @@ -import { createWriteStream } from 'fs'; -import { join, dirname } from 'path'; -import Busboy from 'busboy'; -import mkdirp from 'mkdirp'; - -function formData( - contType: string, - options: busboy.BusboyConfig & { - abortOnLimit?: boolean; - tmpDir?: string; - onFile?: ( - fieldname: string, - file: NodeJS.ReadableStream, - filename: string, - encoding: string, - mimetype: string - ) => string; - onField?: (fieldname: string, value: any) => void; - filename?: (oldName: string) => string; - } = {} -) { - options.headers = { - 'content-type': contType - }; - - return new Promise((resolve, reject) => { - const busb = new Busboy(options); - const ret = {}; - - this.bodyStream().pipe(busb); - - busb.on('limit', () => { - if (options.abortOnLimit) { - reject(Error('limit')); - } - }); - - busb.on('file', function(fieldname, file, filename, encoding, mimetype) { - const value = { - filename, - encoding, - mimetype, - filePath: undefined - }; - - if (typeof options.tmpDir === 'string') { - if (typeof options.filename === 'function') filename = options.filename(filename); - const fileToSave = join(options.tmpDir, filename); - mkdirp(dirname(fileToSave)); - - file.pipe(createWriteStream(fileToSave)); - value.filePath = fileToSave; - } - if (typeof options.onFile === 'function') { - value.filePath = - options.onFile(fieldname, file, filename, encoding, mimetype) || value.filePath; - } - - setRetValue(ret, fieldname, value); - }); - - busb.on('field', function(fieldname, value) { - if (typeof options.onField === 'function') options.onField(fieldname, value); - - setRetValue(ret, fieldname, value); - }); - - busb.on('finish', function() { - resolve(ret); - }); - - busb.on('error', reject); - }); -} - -function setRetValue( - ret: { [x: string]: any }, - fieldname: string, - value: { filename: string; encoding: string; mimetype: string; filePath?: string } | any -) { - if (fieldname.slice(-2) === '[]') { - fieldname = fieldname.slice(0, fieldname.length - 2); - if (Array.isArray(ret[fieldname])) { - ret[fieldname].push(value); - } else { - ret[fieldname] = [value]; - } - } else { - if (Array.isArray(ret[fieldname])) { - ret[fieldname].push(value); - } else if (ret[fieldname]) { - ret[fieldname] = [ret[fieldname], value]; - } else { - ret[fieldname] = value; - } - } -} - -export default formData; diff --git a/back/src/Server/server/graphiql.html b/back/src/Server/server/graphiql.html deleted file mode 100644 index 7ce03921..00000000 --- a/back/src/Server/server/graphiql.html +++ /dev/null @@ -1,133 +0,0 @@ - - - - - - - - - - - - - - - - -
Loading...
- - - diff --git a/back/src/Server/server/graphql.ts b/back/src/Server/server/graphql.ts deleted file mode 100644 index 63a2bdaa..00000000 --- a/back/src/Server/server/graphql.ts +++ /dev/null @@ -1,138 +0,0 @@ -import { parse } from 'query-string'; -import { createAsyncIterator, forAwaitEach, isAsyncIterable } from 'iterall'; -import { HttpResponse, HttpRequest } from 'uWebSockets.js'; -// client -> server -const GQL_START = 'start'; -const GQL_STOP = 'stop'; -// server -> client -const GQL_DATA = 'data'; -const GQL_QUERY = 'query'; - -async function getGraphqlParams(res: HttpResponse, req: HttpRequest) { - // query and variables - const queryParams = parse(req.getQuery()); - let { query, variables, operationName } = queryParams; - if (typeof variables === 'string') variables = JSON.parse(variables); - - // body - if (res && typeof res.json === 'function') { - const data = await res.json(); - query = data.query || query; - variables = data.variables || variables; - operationName = data.operationName || operationName; - } - return { - source: query, - variableValues: variables, - operationName - }; -} - -function graphqlPost(schema, graphqlOptions: any = {}, graphql: any = {}) { - const execute = graphql.graphql || require('graphql').graphql; - - return async (res: HttpResponse, req: HttpRequest) => { - res.onAborted(console.error); - - res.writeHeader('content-type', 'application/json'); - res.end( - JSON.stringify( - await execute({ - schema, - ...(await getGraphqlParams(res, req)), - ...graphqlOptions, - contextValue: { - res, - req, - ...(graphqlOptions && - (graphqlOptions.contextValue || - (graphqlOptions.contextFxn && (await graphqlOptions.contextFxn(res, req))))) - } - }) - ) - ); - }; -} - -function stopGqsSubscription(operations, reqOpId) { - if (!reqOpId) return; - operations[reqOpId] && operations[reqOpId].return && operations[reqOpId].return(); - delete operations[reqOpId]; -} - -function graphqlWs(schema, graphqlOptions: any = {}, uwsOptions: any = {}, graphql: any = {}) { - const subscribe = graphql.subscribe || require('graphql').subscribe; - const execute = graphql.graphql || require('graphql').graphql; - - return { - open: (ws, req) => { - ws.req = req; - ws.operations = {}; - ws.opId = 1; - }, - message: async (ws, message) => { - const { type, payload = {}, id: reqOpId } = JSON.parse(Buffer.from(message).toString('utf8')); - let opId; - if (reqOpId) { - opId = reqOpId; - } else { - opId = ws.opId++; - } - - const params = { - schema, - source: payload.query, - variableValues: payload.variables, - operationName: payload.operationName, - contextValue: { - ws, - ...(graphqlOptions && - (graphqlOptions.contextValue || - (graphqlOptions.contextFxn && (await graphqlOptions.contextFxn(ws))))) - }, - ...graphqlOptions - }; - - switch (type) { - case GQL_START: - stopGqsSubscription(ws.operations, opId); - - // eslint-disable-next-line no-case-declarations - let asyncIterable = await subscribe( - params.schema, - graphql.parse(params.source), - params.rootValue, - params.contextValue, - params.variableValues, - params.operationName - ); - asyncIterable = isAsyncIterable(asyncIterable) - ? asyncIterable - : createAsyncIterator([asyncIterable]); - - forAwaitEach(asyncIterable, result => - ws.send( - JSON.stringify({ - id: opId, - type: GQL_DATA, - payload: result - }) - ) - ); - break; - - case GQL_STOP: - stopGqsSubscription(ws.operations, reqOpId); - break; - - default: - ws.send(JSON.stringify({ payload: await execute(params), type: GQL_QUERY, id: opId })); - break; - } - }, - idleTimeout: 24 * 60 * 60, - ...uwsOptions - }; -} - -export { graphqlPost, graphqlWs }; diff --git a/back/src/Server/server/livereload.ts b/back/src/Server/server/livereload.ts deleted file mode 100644 index 787c871b..00000000 --- a/back/src/Server/server/livereload.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { WebSocketBehavior, WebSocket } from 'uWebSockets.js'; - -const websockets = {}; -let id = 0; - -const wsConfig: WebSocketBehavior = { - open: (ws: WebSocket & { id: number }, req) => { - websockets[id] = { - dirty: false - }; - ws.id = id; - console.log('websocket connected: ', id); - id++; - }, - message: ws => { - ws.send(JSON.stringify(websockets[ws.id].dirty)); - websockets[ws.id].dirty = false; - }, - close: (ws, code, message) => { - delete websockets[ws.id]; - console.log( - `websocket disconnected with code ${code} and message ${message}:`, - ws.id, - websockets - ); - } -}; - -const sendSignal = (type: string, path: string) => { - console.log(type, 'signal for file: ', path); - for (let i in websockets) websockets[i].dirty = true; -}; - -export default { websockets, wsConfig, sendSignal }; -export { websockets, wsConfig, sendSignal }; diff --git a/back/src/Server/server/livereloadjs.js b/back/src/Server/server/livereloadjs.js deleted file mode 100644 index 04839578..00000000 --- a/back/src/Server/server/livereloadjs.js +++ /dev/null @@ -1,47 +0,0 @@ -const loc = window.location; -let path; -if (loc.protocol === 'https:') { - path = 'wss:'; -} else { - path = 'ws:'; -} -path += '//' + loc.host + '/__sifrrLiveReload'; - -let ws, - ttr = 500, - timeout; - -function newWsConnection() { - ws = new WebSocket(path); - ws.onopen = function() { - ttr = 500; - checkMessage(); - console.log('watching for file changes through sifrr-server livereload mode.'); - }; - ws.onmessage = function(event) { - if (JSON.parse(event.data)) { - console.log('Files changed, refreshing page.'); - location.reload(); - } - }; - ws.onerror = e => { - console.error('Webosocket error: ', e); - console.log('Retrying after ', ttr / 4, 'ms'); - ttr *= 4; - }; - ws.onclose = e => { - console.error(`Webosocket closed with code \${e.code} error \${e.message}`); - }; -} - -function checkMessage() { - if (!ws) return; - if (ws.readyState === WebSocket.OPEN) ws.send(''); - else if (ws.readyState === WebSocket.CLOSED) newWsConnection(); - - if (timeout) clearTimeout(timeout); - timeout = setTimeout(checkMessage, ttr); -} - -newWsConnection(); -setTimeout(checkMessage, ttr); diff --git a/back/src/Server/server/loadroutes.ts b/back/src/Server/server/loadroutes.ts deleted file mode 100644 index 3761d762..00000000 --- a/back/src/Server/server/loadroutes.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { statSync, readdirSync } from 'fs'; -import { join, extname } from 'path'; - -function loadRoutes(dir, { filter = () => true, basePath = '' } = {}) { - let files; - const paths = []; - - if (statSync(dir).isDirectory()) { - files = readdirSync(dir) - .filter(filter) - .map(file => join(dir, file)); - } else { - files = [dir]; - } - - files.forEach(file => { - if (statSync(file).isDirectory()) { - // Recursive if directory - paths.push(...loadRoutes.call(this, file, { filter, basePath })); - } else if (extname(file) === '.js') { - const routes = require(file); - let basePaths = routes.basePath || ['']; - delete routes.basePath; - if (typeof basePaths === 'string') basePaths = [basePaths]; - - basePaths.forEach(basep => { - for (const method in routes) { - const methodRoutes = routes[method]; - for (let r in methodRoutes) { - if (!Array.isArray(methodRoutes[r])) methodRoutes[r] = [methodRoutes[r]]; - this[method](basePath + basep + r, ...methodRoutes[r]); - paths.push(basePath + basep + r); - } - } - }); - } - }); - - return paths; -} - -export default loadRoutes; diff --git a/back/src/Server/server/mime.ts b/back/src/Server/server/mime.ts deleted file mode 100644 index 396073cc..00000000 --- a/back/src/Server/server/mime.ts +++ /dev/null @@ -1,176 +0,0 @@ -const mimes = { - '3gp': 'video/3gpp', - a: 'application/octet-stream', - ai: 'application/postscript', - aif: 'audio/x-aiff', - aiff: 'audio/x-aiff', - asc: 'application/pgp-signature', - asf: 'video/x-ms-asf', - asm: 'text/x-asm', - asx: 'video/x-ms-asf', - atom: 'application/atom+xml', - au: 'audio/basic', - avi: 'video/x-msvideo', - bat: 'application/x-msdownload', - bin: 'application/octet-stream', - bmp: 'image/bmp', - bz2: 'application/x-bzip2', - c: 'text/x-c', - cab: 'application/vnd.ms-cab-compressed', - cc: 'text/x-c', - chm: 'application/vnd.ms-htmlhelp', - class: 'application/octet-stream', - com: 'application/x-msdownload', - conf: 'text/plain', - cpp: 'text/x-c', - crt: 'application/x-x509-ca-cert', - css: 'text/css', - csv: 'text/csv', - cxx: 'text/x-c', - deb: 'application/x-debian-package', - der: 'application/x-x509-ca-cert', - diff: 'text/x-diff', - djv: 'image/vnd.djvu', - djvu: 'image/vnd.djvu', - dll: 'application/x-msdownload', - dmg: 'application/octet-stream', - doc: 'application/msword', - dot: 'application/msword', - dtd: 'application/xml-dtd', - dvi: 'application/x-dvi', - ear: 'application/java-archive', - eml: 'message/rfc822', - eps: 'application/postscript', - exe: 'application/x-msdownload', - f: 'text/x-fortran', - f77: 'text/x-fortran', - f90: 'text/x-fortran', - flv: 'video/x-flv', - for: 'text/x-fortran', - gem: 'application/octet-stream', - gemspec: 'text/x-script.ruby', - gif: 'image/gif', - gz: 'application/x-gzip', - h: 'text/x-c', - hh: 'text/x-c', - htm: 'text/html', - html: 'text/html', - ico: 'image/vnd.microsoft.icon', - ics: 'text/calendar', - ifb: 'text/calendar', - iso: 'application/octet-stream', - jar: 'application/java-archive', - java: 'text/x-java-source', - jnlp: 'application/x-java-jnlp-file', - jpeg: 'image/jpeg', - jpg: 'image/jpeg', - js: 'application/javascript', - json: 'application/json', - log: 'text/plain', - m3u: 'audio/x-mpegurl', - m4v: 'video/mp4', - man: 'text/troff', - mathml: 'application/mathml+xml', - mbox: 'application/mbox', - mdoc: 'text/troff', - me: 'text/troff', - mid: 'audio/midi', - midi: 'audio/midi', - mime: 'message/rfc822', - mjs: 'application/javascript', - mml: 'application/mathml+xml', - mng: 'video/x-mng', - mov: 'video/quicktime', - mp3: 'audio/mpeg', - mp4: 'video/mp4', - mp4v: 'video/mp4', - mpeg: 'video/mpeg', - mpg: 'video/mpeg', - ms: 'text/troff', - msi: 'application/x-msdownload', - odp: 'application/vnd.oasis.opendocument.presentation', - ods: 'application/vnd.oasis.opendocument.spreadsheet', - odt: 'application/vnd.oasis.opendocument.text', - ogg: 'application/ogg', - p: 'text/x-pascal', - pas: 'text/x-pascal', - pbm: 'image/x-portable-bitmap', - pdf: 'application/pdf', - pem: 'application/x-x509-ca-cert', - pgm: 'image/x-portable-graymap', - pgp: 'application/pgp-encrypted', - pkg: 'application/octet-stream', - pl: 'text/x-script.perl', - pm: 'text/x-script.perl-module', - png: 'image/png', - pnm: 'image/x-portable-anymap', - ppm: 'image/x-portable-pixmap', - pps: 'application/vnd.ms-powerpoint', - ppt: 'application/vnd.ms-powerpoint', - ps: 'application/postscript', - psd: 'image/vnd.adobe.photoshop', - py: 'text/x-script.python', - qt: 'video/quicktime', - ra: 'audio/x-pn-realaudio', - rake: 'text/x-script.ruby', - ram: 'audio/x-pn-realaudio', - rar: 'application/x-rar-compressed', - rb: 'text/x-script.ruby', - rdf: 'application/rdf+xml', - roff: 'text/troff', - rpm: 'application/x-redhat-package-manager', - rss: 'application/rss+xml', - rtf: 'application/rtf', - ru: 'text/x-script.ruby', - s: 'text/x-asm', - sgm: 'text/sgml', - sgml: 'text/sgml', - sh: 'application/x-sh', - sig: 'application/pgp-signature', - snd: 'audio/basic', - so: 'application/octet-stream', - svg: 'image/svg+xml', - svgz: 'image/svg+xml', - swf: 'application/x-shockwave-flash', - t: 'text/troff', - tar: 'application/x-tar', - tbz: 'application/x-bzip-compressed-tar', - tcl: 'application/x-tcl', - tex: 'application/x-tex', - texi: 'application/x-texinfo', - texinfo: 'application/x-texinfo', - text: 'text/plain', - tif: 'image/tiff', - tiff: 'image/tiff', - torrent: 'application/x-bittorrent', - tr: 'text/troff', - txt: 'text/plain', - vcf: 'text/x-vcard', - vcs: 'text/x-vcalendar', - vrml: 'model/vrml', - war: 'application/java-archive', - wav: 'audio/x-wav', - wma: 'audio/x-ms-wma', - wmv: 'video/x-ms-wmv', - wmx: 'video/x-ms-wmx', - wrl: 'model/vrml', - wsdl: 'application/wsdl+xml', - xbm: 'image/x-xbitmap', - xhtml: 'application/xhtml+xml', - xls: 'application/vnd.ms-excel', - xml: 'application/xml', - xpm: 'image/x-xpixmap', - xsl: 'application/xml', - xslt: 'application/xslt+xml', - yaml: 'text/yaml', - yml: 'text/yaml', - zip: 'application/zip', - default: 'text/html' -}; - -const getMime = (path: string): string => { - const i = path.lastIndexOf('.'); - return mimes[path.substr(i + 1).toLowerCase()] || mimes['default']; -}; - -export { getMime, mimes }; diff --git a/back/src/Server/server/sendfile.ts b/back/src/Server/server/sendfile.ts deleted file mode 100644 index 8310c4a7..00000000 --- a/back/src/Server/server/sendfile.ts +++ /dev/null @@ -1,172 +0,0 @@ -import { watch, statSync, createReadStream } from 'fs'; -import { createBrotliCompress, createGzip, createDeflate } from 'zlib'; -const watchedPaths = new Set(); - -const compressions = { - br: createBrotliCompress, - gzip: createGzip, - deflate: createDeflate -}; -import { writeHeaders } from './utils'; -import { getMime } from './mime'; -const bytes = 'bytes='; -import { stob } from './utils'; -import { sendSignal } from './livereload'; -import { SendFileOptions } from './types'; -import { HttpResponse, HttpRequest } from 'uWebSockets.js'; - -function sendFile(res: HttpResponse, req: HttpRequest, path: string, options: SendFileOptions) { - if (options && options.livereload && !watchedPaths.has(path)) { - watchedPaths.add(path); - watch(path, sendSignal); - } - - sendFileToRes( - res, - { - 'if-modified-since': req.getHeader('if-modified-since'), - range: req.getHeader('range'), - 'accept-encoding': req.getHeader('accept-encoding') - }, - path, - options - ); -} - -function sendFileToRes( - res: HttpResponse, - reqHeaders: { [name: string]: string }, - path: string, - { - lastModified = true, - headers = {}, - compress = false, - compressionOptions = { - priority: ['gzip', 'br', 'deflate'] - }, - cache = false - }: { cache: any } & any = {} -) { - let { mtime, size } = statSync(path); - mtime.setMilliseconds(0); - const mtimeutc = mtime.toUTCString(); - - headers = Object.assign({}, headers); - // handling last modified - if (lastModified) { - // Return 304 if last-modified - if (reqHeaders['if-modified-since']) { - if (new Date(reqHeaders['if-modified-since']) >= mtime) { - res.writeStatus('304 Not Modified'); - return res.end(); - } - } - headers['last-modified'] = mtimeutc; - } - headers['content-type'] = getMime(path); - - // write data - let start = 0, - end = size - 1; - - if (reqHeaders.range) { - compress = false; - const parts = reqHeaders.range.replace(bytes, '').split('-'); - start = parseInt(parts[0], 10); - end = parts[1] ? parseInt(parts[1], 10) : end; - headers['accept-ranges'] = 'bytes'; - headers['content-range'] = `bytes ${start}-${end}/${size}`; - size = end - start + 1; - res.writeStatus('206 Partial Content'); - } - - // for size = 0 - if (end < 0) end = 0; - - let readStream = createReadStream(path, { start, end }); - // Compression; - let compressed: boolean | string = false; - if (compress) { - const l = compressionOptions.priority.length; - for (let i = 0; i < l; i++) { - const type = compressionOptions.priority[i]; - if (reqHeaders['accept-encoding'].indexOf(type) > -1) { - compressed = type; - const compressor = compressions[type](compressionOptions); - readStream.pipe(compressor); - readStream = compressor; - headers['content-encoding'] = compressionOptions.priority[i]; - break; - } - } - } - - res.onAborted(() => readStream.destroy()); - writeHeaders(res, headers); - // check cache - if (cache) { - return cache.wrap( - `${path}_${mtimeutc}_${start}_${end}_${compressed}`, - cb => { - stob(readStream) - .then(b => cb(null, b)) - .catch(cb); - }, - { ttl: 0 }, - (err, buffer) => { - if (err) { - res.writeStatus('500 Internal server error'); - res.end(); - throw err; - } - res.end(buffer); - } - ); - } else if (compressed) { - readStream.on('data', buffer => { - res.write(buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength)); - }); - } else { - readStream.on('data', buffer => { - const chunk = buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength), - lastOffset = res.getWriteOffset(); - - // First try - const [ok, done] = res.tryEnd(chunk, size); - - if (done) { - readStream.destroy(); - } else if (!ok) { - // pause because backpressure - readStream.pause(); - - // Save unsent chunk for later - res.ab = chunk; - res.abOffset = lastOffset; - - // Register async handlers for drainage - res.onWritable(offset => { - const [ok, done] = res.tryEnd(res.ab.slice(offset - res.abOffset), size); - if (done) { - readStream.destroy(); - } else if (ok) { - readStream.resume(); - } - return ok; - }); - } - }); - } - readStream - .on('error', e => { - res.writeStatus('500 Internal server error'); - res.end(); - readStream.destroy(); - throw e; - }) - .on('end', () => { - res.end(); - }); -} - -export default sendFile; diff --git a/back/src/Server/server/types.ts b/back/src/Server/server/types.ts index 09916b5f..3d0f48c7 100644 --- a/back/src/Server/server/types.ts +++ b/back/src/Server/server/types.ts @@ -6,21 +6,6 @@ export type UwsApp = { prototype: TemplatedApp; }; -export type SendFileOptions = { - failOnDuplicateRoute?: boolean; - overwriteRoute?: boolean; - watch?: boolean; - filter?: (path: string) => boolean; - livereload?: boolean; - lastModified?: boolean; - headers?: { [name: string]: string }; - compress?: boolean; - compressionOptions?: { - priority?: 'gzip' | 'br' | 'deflate'; - }; - cache?: boolean; -}; - export type Handler = (res: HttpResponse, req: HttpRequest) => void; export {}; diff --git a/back/src/Server/server/utils.ts b/back/src/Server/server/utils.ts index 8f6db886..f7f3e4b5 100644 --- a/back/src/Server/server/utils.ts +++ b/back/src/Server/server/utils.ts @@ -1,21 +1,6 @@ -import { HttpResponse } from 'uWebSockets.js'; import { ReadStream } from 'fs'; -function writeHeaders( - res: HttpResponse, - headers: { [name: string]: string } | string, - other?: string -) { - if (typeof headers === 'string') { - res.writeHeader(headers, other.toString()); - } else { - for (const n in headers) { - res.writeHeader(n, headers[n].toString()); - } - } -} - -function extend(who: object, from: object, overwrite = true) { +function extend(who: any, from: any, overwrite = true) { const ownProps = Object.getOwnPropertyNames(Object.getPrototypeOf(from)).concat( Object.keys(from) ); @@ -31,7 +16,7 @@ function extend(who: object, from: object, overwrite = true) { function stob(stream: ReadStream): Promise { return new Promise(resolve => { - const buffers = []; + const buffers: Buffer[] = []; stream.on('data', buffers.push.bind(buffers)); stream.on('end', () => { @@ -49,4 +34,4 @@ function stob(stream: ReadStream): Promise { }); } -export { writeHeaders, extend, stob }; +export { extend, stob }; diff --git a/back/src/Server/sifrr.server.ts b/back/src/Server/sifrr.server.ts index 9a274378..47fba02c 100644 --- a/back/src/Server/sifrr.server.ts +++ b/back/src/Server/sifrr.server.ts @@ -2,29 +2,18 @@ import { parse } from 'query-string'; import { HttpRequest } from 'uWebSockets.js'; import App from './server/app'; import SSLApp from './server/sslapp'; -import { mimes, getMime } from './server/mime'; -import { writeHeaders } from './server/utils'; -import sendFile from './server/sendfile'; -import Cluster from './server/cluster'; -import livereload from './server/livereload'; import * as types from './server/types'; const getQuery = (req: HttpRequest) => { return parse(req.getQuery()); }; -export { App, SSLApp, mimes, getMime, writeHeaders, sendFile, Cluster, livereload, getQuery }; +export { App, SSLApp, getQuery }; export * from './server/types'; export default { App, SSLApp, - mimes, - getMime, - writeHeaders, - sendFile, - Cluster, - livereload, getQuery, ...types }; From b485c9bf4642bc1d6472425406fcf78ec7a2401f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Tue, 29 Sep 2020 16:01:22 +0200 Subject: [PATCH 072/122] Switching WebRTC to protobuf + uws --- back/src/Controller/IoSocketController.ts | 182 ++++++++++++++-------- back/src/Model/Group.ts | 4 +- back/src/Model/User.ts | 4 +- back/src/Model/World.ts | 8 +- front/src/Connection.ts | 133 +++++++++++----- front/src/WebRtc/SimplePeer.ts | 18 ++- messages/messages.proto | 33 ++-- 7 files changed, 253 insertions(+), 129 deletions(-) diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index cd3d5e52..fb1f0680 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -37,7 +37,12 @@ import { ErrorMessage, RoomJoinedMessage, ItemStateMessage, - ServerToClientMessage, SetUserIdMessage, SilentMessage + ServerToClientMessage, + SetUserIdMessage, + SilentMessage, + WebRtcSignalToClientMessage, + WebRtcSignalToServerMessage, + WebRtcStartMessage, WebRtcDisconnectMessage } from "../Messages/generated/messages_pb"; import {UserMovesMessage} from "../Messages/generated/messages_pb"; import Direction = PositionMessage.Direction; @@ -186,7 +191,7 @@ export class IoSocketController { /* Options */ //compression: uWS.SHARED_COMPRESSOR, maxPayloadLength: 16 * 1024 * 1024, - idleTimeout: 10, + //idleTimeout: 10, /* Handlers */ open: (ws) => { this.authenticate(ws); @@ -222,6 +227,10 @@ export class IoSocketController { this.handleSilentMessage(client, message.getSilentmessage() as SilentMessage); } else if (message.hasItemeventmessage()) { this.handleItemEvent(client, message.getItemeventmessage() as ItemEventMessage); + } else if (message.hasWebrtcsignaltoservermessage()) { + this.emitVideo(client, message.getWebrtcsignaltoservermessage() as WebRtcSignalToServerMessage) + } else if (message.hasWebrtcscreensharingsignaltoservermessage()) { + this.emitScreenSharing(client, message.getWebrtcscreensharingsignaltoservermessage() as WebRtcSignalToServerMessage) } /* Ok is false if backpressure was built up, wait for drain */ @@ -282,7 +291,7 @@ export class IoSocketController { serverToClientMessage.setErrormessage(errorMessage); if (!Client.disconnecting) { - Client.send(serverToClientMessage.serializeBinary().buffer); + Client.send(serverToClientMessage.serializeBinary().buffer, true); } console.warn(message); } @@ -496,40 +505,44 @@ export class IoSocketController { } } - emitVideo(socket: ExSocketInterface, data: unknown){ - if (!isWebRtcSignalMessageInterface(data)) { - socket.emit(SocketIoEvent.MESSAGE_ERROR, {message: 'Invalid WEBRTC_SIGNAL message.'}); - console.warn('Invalid WEBRTC_SIGNAL message received: ', data); - return; - } + emitVideo(socket: ExSocketInterface, data: WebRtcSignalToServerMessage): void { //send only at user - const client = this.sockets.get(data.receiverId); + const client = this.sockets.get(data.getReceiverid()); if (client === undefined) { - console.warn("While exchanging a WebRTC signal: client with id ", data.receiverId, " does not exist. This might be a race condition."); + console.warn("While exchanging a WebRTC signal: client with id ", data.getReceiverid(), " does not exist. This might be a race condition."); return; } - return client.emit(SocketIoEvent.WEBRTC_SIGNAL, { - userId: socket.userId, - signal: data.signal - }); + + const webrtcSignalToClient = new WebRtcSignalToClientMessage(); + webrtcSignalToClient.setUserid(socket.userId); + webrtcSignalToClient.setSignal(data.getSignal()); + + const serverToClientMessage = new ServerToClientMessage(); + serverToClientMessage.setWebrtcsignaltoclientmessage(webrtcSignalToClient); + + if (!client.disconnecting) { + client.send(serverToClientMessage.serializeBinary().buffer, true); + } } - emitScreenSharing(socket: ExSocketInterface, data: unknown){ - if (!isWebRtcSignalMessageInterface(data)) { - socket.emit(SocketIoEvent.MESSAGE_ERROR, {message: 'Invalid WEBRTC_SCREEN_SHARING message.'}); - console.warn('Invalid WEBRTC_SCREEN_SHARING message received: ', data); - return; - } + emitScreenSharing(socket: ExSocketInterface, data: WebRtcSignalToServerMessage): void { //send only at user - const client = this.sockets.get(data.receiverId); + const client = this.sockets.get(data.getReceiverid()); if (client === undefined) { - console.warn("While exchanging a WEBRTC_SCREEN_SHARING signal: client with id ", data.receiverId, " does not exist. This might be a race condition."); + console.warn("While exchanging a WEBRTC_SCREEN_SHARING signal: client with id ", data.getReceiverid(), " does not exist. This might be a race condition."); return; } - return client.emit(SocketIoEvent.WEBRTC_SCREEN_SHARING_SIGNAL, { - userId: socket.userId, - signal: data.signal - }); + + const webrtcSignalToClient = new WebRtcSignalToClientMessage(); + webrtcSignalToClient.setUserid(socket.userId); + webrtcSignalToClient.setSignal(data.getSignal()); + + const serverToClientMessage = new ServerToClientMessage(); + serverToClientMessage.setWebrtcscreensharingsignaltoclientmessage(webrtcSignalToClient); + + if (!client.disconnecting) { + client.send(serverToClientMessage.serializeBinary().buffer, true); + } } searchClientByIdOrFail(userId: number): ExSocketInterface { @@ -571,9 +584,9 @@ export class IoSocketController { //check and create new world for a room let world = this.Worlds.get(roomId) if(world === undefined){ - world = new World((user1: number, group: Group) => { - this.connectedUser(user1, group); - }, (user1: number, group: Group) => { + world = new World((user1: User, group: Group) => { + this.joinWebRtcRoom(user1, group); + }, (user1: User, group: Group) => { this.disConnectedUser(user1, group); }, MINIMUM_DISTANCE, GROUP_RADIUS, (thing: Movable, listener: User) => { const clientListener = this.searchClientByIdOrFail(listener.id); @@ -677,20 +690,49 @@ export class IoSocketController { emitInBatch(client, subMessage); } - /** - * - * @param socket - * @param roomId - */ - joinWebRtcRoom(socket: ExSocketInterface, roomId: string) { - - // TODO: REBUILD THIS - return; - -/* if (socket.webRtcRoomId === roomId) { + joinWebRtcRoom(user: User, group: Group) { + /*const roomId: string = "webrtcroom"+group.getId(); + if (user.socket.webRtcRoomId === roomId) { return; + }*/ + + // TODO: joinWebRtcRoom will be trigerred twice when joining the first time! Maybe we should fix the GROUP constructor to trigger only one event +console.log('joinWebRtcRoom FOR '+user.socket.name+" "+user.socket.userId); + for (const otherUser of group.getUsers()) { + if (user === otherUser) { + continue; + } + + // Let's send 2 messages: one to the user joining the group and one to the other user + const webrtcStartMessage1 = new WebRtcStartMessage(); + webrtcStartMessage1.setUserid(otherUser.id); + webrtcStartMessage1.setName(otherUser.socket.name); + webrtcStartMessage1.setInitiator(true); + + const serverToClientMessage1 = new ServerToClientMessage(); + serverToClientMessage1.setWebrtcstartmessage(webrtcStartMessage1); + + if (!user.socket.disconnecting) { + user.socket.send(serverToClientMessage1.serializeBinary().buffer, true); + console.log('Sending webrtcstart initiator to '+user.socket.userId) + } + + const webrtcStartMessage2 = new WebRtcStartMessage(); + webrtcStartMessage2.setUserid(user.id); + webrtcStartMessage2.setName(user.socket.name); + webrtcStartMessage2.setInitiator(false); + + const serverToClientMessage2 = new ServerToClientMessage(); + serverToClientMessage2.setWebrtcstartmessage(webrtcStartMessage2); + + if (!otherUser.socket.disconnecting) { + otherUser.socket.send(serverToClientMessage2.serializeBinary().buffer, true); + console.log('Sending webrtcstart to '+otherUser.socket.userId) + } + } - socket.join(roomId); + +/* socket.join(roomId); socket.webRtcRoomId = roomId; //if two persons in room share if (this.Io.sockets.adapter.rooms[roomId].length < 2) { @@ -737,43 +779,49 @@ export class IoSocketController { ] **/ - //connected user - connectedUser(userId: number, group: Group) { - /*let Client = this.sockets.get(userId); - if (Client === undefined) { - return; - }*/ - const Client = this.searchClientByIdOrFail(userId); - this.joinWebRtcRoom(Client, "webrtcroom"+group.getId()); - } - //disconnect user - disConnectedUser(userId: number, group: Group) { - // TODO: rebuild this - return; + disConnectedUser(user: User, group: Group) { - const Client = this.searchClientByIdOrFail(userId); - Client.to("webrtcroom"+group.getId()).emit(SocketIoEvent.WEBRTC_DISCONNECT, { - userId: userId - }); + const Client = user.socket; // Most of the time, sending a disconnect event to one of the players is enough (the player will close the connection // which will be shut for the other player). // However! In the rare case where the WebRTC connection is not yet established, if we close the connection on one of the player, // the other player will try connecting until a timeout happens (during this time, the connection icon will be displayed for nothing). // So we also send the disconnect event to the other player. - for (const user of group.getUsers()) { - Client.emit(SocketIoEvent.WEBRTC_DISCONNECT, { - userId: user.id - }); + for (const otherUser of group.getUsers()) { + if (user === otherUser) { + continue; + } + + const webrtcDisconnectMessage1 = new WebRtcDisconnectMessage(); + webrtcDisconnectMessage1.setUserid(user.id); + + const serverToClientMessage1 = new ServerToClientMessage(); + serverToClientMessage1.setWebrtcdisconnectmessage(webrtcDisconnectMessage1); + + if (!otherUser.socket.disconnecting) { + otherUser.socket.send(serverToClientMessage1.serializeBinary().buffer, true); + } + + + const webrtcDisconnectMessage2 = new WebRtcDisconnectMessage(); + webrtcDisconnectMessage2.setUserid(otherUser.id); + + const serverToClientMessage2 = new ServerToClientMessage(); + serverToClientMessage2.setWebrtcdisconnectmessage(webrtcDisconnectMessage2); + + if (!user.socket.disconnecting) { + user.socket.send(serverToClientMessage2.serializeBinary().buffer, true); + } } //disconnect webrtc room - if(!Client.webRtcRoomId){ + /*if(!Client.webRtcRoomId){ return; - } - Client.leave(Client.webRtcRoomId); - delete Client.webRtcRoomId; + }*/ + //Client.leave(Client.webRtcRoomId); + //delete Client.webRtcRoomId; } public getWorlds(): Map { diff --git a/back/src/Model/Group.ts b/back/src/Model/Group.ts index f2e5feb1..16dd6cd5 100644 --- a/back/src/Model/Group.ts +++ b/back/src/Model/Group.ts @@ -87,7 +87,7 @@ export class Group implements Movable { join(user: User): void { // Broadcast on the right event - this.connectCallback(user.id, this); + this.connectCallback(user, this); this.users.add(user); user.group = this; } @@ -105,7 +105,7 @@ export class Group implements Movable { } // Broadcast on the right event - this.disconnectCallback(user.id, this); + this.disconnectCallback(user, this); } /** diff --git a/back/src/Model/User.ts b/back/src/Model/User.ts index 2396c4d8..34377dc4 100644 --- a/back/src/Model/User.ts +++ b/back/src/Model/User.ts @@ -4,6 +4,7 @@ import {Zone} from "_Model/Zone"; import {Movable} from "_Model/Movable"; import {PositionInterface} from "_Model/PositionInterface"; import {PositionNotifier} from "_Model/PositionNotifier"; +import {ExSocketInterface} from "_Model/Websocket/ExSocketInterface"; export class User implements Movable { public listenedZones: Set; @@ -13,7 +14,8 @@ export class User implements Movable { public id: number, private position: PointInterface, public silent: boolean, - private positionNotifier: PositionNotifier + private positionNotifier: PositionNotifier, + public readonly socket: ExSocketInterface ) { this.listenedZones = new Set(); diff --git a/back/src/Model/World.ts b/back/src/Model/World.ts index 8e645c74..c276d04e 100644 --- a/back/src/Model/World.ts +++ b/back/src/Model/World.ts @@ -11,8 +11,8 @@ import {PositionNotifier} from "./PositionNotifier"; import {ViewportInterface} from "_Model/Websocket/ViewportMessage"; import {Movable} from "_Model/Movable"; -export type ConnectCallback = (user: number, group: Group) => void; -export type DisconnectCallback = (user: number, group: Group) => void; +export type ConnectCallback = (user: User, group: Group) => void; +export type DisconnectCallback = (user: User, group: Group) => void; export class World { private readonly minDistance: number; @@ -55,8 +55,8 @@ export class World { return this.users; } - public join(socket : Identificable, userPosition: PointInterface): void { - const user = new User(socket.userId, userPosition, false, this.positionNotifier); + public join(socket : ExSocketInterface, userPosition: PointInterface): void { + const user = new User(socket.userId, userPosition, false, this.positionNotifier, socket); this.users.set(socket.userId, user); // Let's call update position to trigger the join / leave room //this.updatePosition(socket, userPosition); diff --git a/front/src/Connection.ts b/front/src/Connection.ts index d7036ba8..6da46c2d 100644 --- a/front/src/Connection.ts +++ b/front/src/Connection.ts @@ -2,11 +2,27 @@ import Axios from "axios"; import {API_URL} from "./Enum/EnvironmentVariable"; import {MessageUI} from "./Logger/MessageUI"; import { - BatchMessage, ClientToServerMessage, GroupDeleteMessage, GroupUpdateMessage, ItemEventMessage, JoinRoomMessage, - PositionMessage, RoomJoinedMessage, ServerToClientMessage, - SetPlayerDetailsMessage, SetUserIdMessage, SilentMessage, UserJoinedMessage, UserLeftMessage, UserMovedMessage, + BatchMessage, + ClientToServerMessage, + GroupDeleteMessage, + GroupUpdateMessage, + ItemEventMessage, + JoinRoomMessage, + PositionMessage, + RoomJoinedMessage, + ServerToClientMessage, + SetPlayerDetailsMessage, + SetUserIdMessage, + SilentMessage, + UserJoinedMessage, + UserLeftMessage, + UserMovedMessage, UserMovesMessage, - ViewportMessage + ViewportMessage, + WebRtcDisconnectMessage, + WebRtcSignalToClientMessage, + WebRtcSignalToServerMessage, + WebRtcStartMessage } from "./Messages/generated/messages_pb" import {PlayerAnimationNames} from "./Phaser/Player/Animation"; @@ -132,7 +148,7 @@ export interface RoomJoinedMessageInterface { export class Connection implements Connection { private readonly socket: WebSocket; private userId: number|null = null; - private batchCallbacks: Map = new Map(); + private listeners: Map = new Map(); private static websocketFactory: null|((url: string)=>any) = null; public static setWebsocketFactory(websocketFactory: (url: string)=>any): void { @@ -185,13 +201,7 @@ export class Connection implements Connection { throw new Error('Unexpected batch message type'); } - const listeners = this.batchCallbacks.get(event); - if (listeners === undefined) { - continue; - } - for (const listener of listeners) { - listener(payload); - } + this.dispatch(event, payload); } } else if (message.hasRoomjoinedmessage()) { const roomJoinedMessage = message.getRoomjoinedmessage() as RoomJoinedMessage; @@ -212,11 +222,32 @@ export class Connection implements Connection { this.userId = (message.getSetuseridmessage() as SetUserIdMessage).getUserid(); } else if (message.hasErrormessage()) { console.error(EventMessage.MESSAGE_ERROR, message.getErrormessage()?.getMessage); + } else if (message.hasWebrtcsignaltoclientmessage()) { + this.dispatch(EventMessage.WEBRTC_SIGNAL, message.getWebrtcsignaltoclientmessage()); + } else if (message.hasWebrtcscreensharingsignaltoclientmessage()) { + this.dispatch(EventMessage.WEBRTC_SCREEN_SHARING_SIGNAL, message.getWebrtcscreensharingsignaltoclientmessage()); + } else if (message.hasWebrtcstartmessage()) { + console.log('Received WebRtcStartMessage'); + this.dispatch(EventMessage.WEBRTC_START, message.getWebrtcstartmessage()); + } else if (message.hasWebrtcdisconnectmessage()) { + this.dispatch(EventMessage.WEBRTC_DISCONNECT, message.getWebrtcdisconnectmessage()); + } else { + throw new Error('Unknown message received'); } } } + private dispatch(event: string, payload: unknown): void { + const listeners = this.listeners.get(event); + if (listeners === undefined) { + return; + } + for (const listener of listeners) { + listener(payload); + } + } + public static createConnection(name: string, characterLayersSelected: string[]): Promise { return Axios.post(`${API_URL}/login`, {name: name}) .then((res) => { @@ -363,7 +394,7 @@ export class Connection implements Connection { } public onUserJoins(callback: (message: MessageUserJoined) => void): void { - this.onBatchMessage(EventMessage.JOIN_ROOM, (message: UserJoinedMessage) => { + this.onMessage(EventMessage.JOIN_ROOM, (message: UserJoinedMessage) => { callback(this.toMessageUserJoined(message)); }); } @@ -383,30 +414,30 @@ export class Connection implements Connection { } public onUserMoved(callback: (message: UserMovedMessage) => void): void { - this.onBatchMessage(EventMessage.USER_MOVED, callback); + this.onMessage(EventMessage.USER_MOVED, callback); //this.socket.on(EventMessage.USER_MOVED, callback); } /** * Registers a listener on a message that is part of a batch */ - private onBatchMessage(eventName: string, callback: Function): void { - let callbacks = this.batchCallbacks.get(eventName); + private onMessage(eventName: string, callback: Function): void { + let callbacks = this.listeners.get(eventName); if (callbacks === undefined) { callbacks = new Array(); - this.batchCallbacks.set(eventName, callbacks); + this.listeners.set(eventName, callbacks); } callbacks.push(callback); } public onUserLeft(callback: (userId: number) => void): void { - this.onBatchMessage(EventMessage.USER_LEFT, (message: UserLeftMessage) => { + this.onMessage(EventMessage.USER_LEFT, (message: UserLeftMessage) => { callback(message.getUserid()); }); } public onGroupUpdatedOrCreated(callback: (groupCreateUpdateMessage: GroupCreatedUpdatedMessageInterface) => void): void { - this.onBatchMessage(EventMessage.GROUP_CREATE_UPDATE, (message: GroupUpdateMessage) => { + this.onMessage(EventMessage.GROUP_CREATE_UPDATE, (message: GroupUpdateMessage) => { callback(this.toGroupCreatedUpdatedMessage(message)); }); } @@ -424,7 +455,7 @@ export class Connection implements Connection { } public onGroupDeleted(callback: (groupId: number) => void): void { - this.onBatchMessage(EventMessage.GROUP_DELETE, (message: GroupDeleteMessage) => { + this.onMessage(EventMessage.GROUP_DELETE, (message: GroupDeleteMessage) => { callback(message.getGroupid()); }); } @@ -438,37 +469,58 @@ export class Connection implements Connection { } public sendWebrtcSignal(signal: unknown, receiverId: number) { -/* return this.socket.emit(EventMessage.WEBRTC_SIGNAL, { - receiverId: receiverId, - signal: signal - } as WebRtcSignalSentMessageInterface);*/ + const webRtcSignal = new WebRtcSignalToServerMessage(); + webRtcSignal.setReceiverid(receiverId); + webRtcSignal.setSignal(JSON.stringify(signal)); + + const clientToServerMessage = new ClientToServerMessage(); + clientToServerMessage.setWebrtcsignaltoservermessage(webRtcSignal); + + this.socket.send(clientToServerMessage.serializeBinary().buffer); } public sendWebrtcScreenSharingSignal(signal: unknown, receiverId: number) { -/* return this.socket.emit(EventMessage.WEBRTC_SCREEN_SHARING_SIGNAL, { - receiverId: receiverId, - signal: signal - } as WebRtcSignalSentMessageInterface);*/ + const webRtcSignal = new WebRtcSignalToServerMessage(); + webRtcSignal.setReceiverid(receiverId); + webRtcSignal.setSignal(JSON.stringify(signal)); + + const clientToServerMessage = new ClientToServerMessage(); + clientToServerMessage.setWebrtcscreensharingsignaltoservermessage(webRtcSignal); + + this.socket.send(clientToServerMessage.serializeBinary().buffer); } - public receiveWebrtcStart(callback: (message: WebRtcStartMessageInterface) => void) { -// TODO - // this.socket.on(EventMessage.WEBRTC_START, callback); + public receiveWebrtcStart(callback: (message: UserSimplePeerInterface) => void) { + this.onMessage(EventMessage.WEBRTC_START, (message: WebRtcStartMessage) => { + callback({ + userId: message.getUserid(), + name: message.getName(), + initiator: message.getInitiator() + }); + }); } public receiveWebrtcSignal(callback: (message: WebRtcSignalReceivedMessageInterface) => void) { -// TODO - // return this.socket.on(EventMessage.WEBRTC_SIGNAL, callback); + this.onMessage(EventMessage.WEBRTC_SIGNAL, (message: WebRtcSignalToClientMessage) => { + callback({ + userId: message.getUserid(), + signal: JSON.parse(message.getSignal()) + }); + }); } public receiveWebrtcScreenSharingSignal(callback: (message: WebRtcSignalReceivedMessageInterface) => void) { -// TODO - // return this.socket.on(EventMessage.WEBRTC_SCREEN_SHARING_SIGNAL, callback); + this.onMessage(EventMessage.WEBRTC_SCREEN_SHARING_SIGNAL, (message: WebRtcSignalToClientMessage) => { + callback({ + userId: message.getUserid(), + signal: JSON.parse(message.getSignal()) + }); + }); } public onServerDisconnected(callback: (event: CloseEvent) => void): void { this.socket.addEventListener('close', (event) => { - + console.log('Socket closed with code '+event.code+". Reason: "+event.reason); if (event.code === 1000) { // Normal closure case return; @@ -483,8 +535,11 @@ export class Connection implements Connection { } disconnectMessage(callback: (message: WebRtcDisconnectMessageInterface) => void): void { -// TODO - // this.socket.on(EventMessage.WEBRTC_DISCONNECT, callback); + this.onMessage(EventMessage.WEBRTC_DISCONNECT, (message: WebRtcDisconnectMessage) => { + callback({ + userId: message.getUserid() + }); + }); } emitActionableEvent(itemId: number, event: string, state: unknown, parameters: unknown): void { @@ -501,7 +556,7 @@ export class Connection implements Connection { } onActionableEvent(callback: (message: ItemEventMessageInterface) => void): void { - this.onBatchMessage(EventMessage.ITEM_EVENT, (message: ItemEventMessage) => { + this.onMessage(EventMessage.ITEM_EVENT, (message: ItemEventMessage) => { callback({ itemId: message.getItemid(), event: message.getEvent(), diff --git a/front/src/WebRtc/SimplePeer.ts b/front/src/WebRtc/SimplePeer.ts index ac603756..c32e4305 100644 --- a/front/src/WebRtc/SimplePeer.ts +++ b/front/src/WebRtc/SimplePeer.ts @@ -82,7 +82,7 @@ export class SimplePeer { mediaManager.getCamera().then(() => { //receive message start - this.Connection.receiveWebrtcStart((message: WebRtcStartMessageInterface) => { + this.Connection.receiveWebrtcStart((message: UserSimplePeerInterface) => { this.receiveWebrtcStart(message); }); @@ -95,17 +95,22 @@ export class SimplePeer { }); } - private receiveWebrtcStart(data: WebRtcStartMessageInterface) { - this.WebRtcRoomId = data.roomId; - this.Users = data.clients; + private receiveWebrtcStart(user: UserSimplePeerInterface) { + //this.WebRtcRoomId = data.roomId; + this.Users.push(user); // Note: the clients array contain the list of all clients (even the ones we are already connected to in case a user joints a group) // So we can receive a request we already had before. (which will abort at the first line of createPeerConnection) - // TODO: refactor this to only send a message to connect to one user (rather than several users). + // TODO: refactor this to only send a message to connect to one user (rather than several users). => DONE // This would be symmetrical to the way we handle disconnection. //console.log('Start message', data); //start connection - this.startWebRtc(); + //this.startWebRtc(); + console.log('receiveWebrtcStart. Initiator: ', user.initiator) + if(!user.initiator){ + return; + } + this.createPeerConnection(user); } /** @@ -129,6 +134,7 @@ export class SimplePeer { if( this.PeerConnectionArray.has(user.userId) ){ + console.log('Peer connection already exists to user '+user.userId) return null; } diff --git a/messages/messages.proto b/messages/messages.proto index 6dd936fc..1cbaae40 100644 --- a/messages/messages.proto +++ b/messages/messages.proto @@ -49,6 +49,11 @@ message UserMovesMessage { ViewportMessage viewport = 2; } +message WebRtcSignalToServerMessage { + int32 receiverId = 1; + string signal = 2; +} + message ClientToServerMessage { oneof message { JoinRoomMessage joinRoomMessage = 1; @@ -57,6 +62,8 @@ message ClientToServerMessage { ViewportMessage viewportMessage = 4; ItemEventMessage itemEventMessage = 5; SetPlayerDetailsMessage setPlayerDetailsMessage = 6; + WebRtcSignalToServerMessage webRtcSignalToServerMessage = 7; + WebRtcSignalToServerMessage webRtcScreenSharingSignalToServerMessage = 8; } } @@ -132,14 +139,20 @@ message RoomJoinedMessage { repeated ItemStateMessage item = 3; } +message WebRtcStartMessage { + int32 userId = 1; + string name = 2; + bool initiator = 3; +} -/*message WebRtcStartMessage { - int32 itemId = 1; - string event = 2; - string stateJson = 3; - string parametersJson = 4; -}*/ +message WebRtcDisconnectMessage { + int32 userId = 1; +} +message WebRtcSignalToClientMessage { + int32 userId = 1; + string signal = 2; +} message ServerToClientMessage { oneof message { @@ -147,9 +160,9 @@ message ServerToClientMessage { ErrorMessage errorMessage = 2; RoomJoinedMessage roomJoinedMessage = 3; SetUserIdMessage setUserIdMessage = 4; // TODO: merge this with RoomJoinedMessage ? -// WebRtcStartMessage webRtcStartMessage = 3; -// WebRtcSignalMessage webRtcSignalMessage = 4; -// WebRtcScreenSharingSignalMessage webRtcScreenSharingSignalMessage = 5; -// WebRtcDisconnectMessage webRtcDisconnectMessage = 6; + WebRtcStartMessage webRtcStartMessage = 5; + WebRtcSignalToClientMessage webRtcSignalToClientMessage = 6; + WebRtcSignalToClientMessage webRtcScreenSharingSignalToClientMessage = 7; + WebRtcDisconnectMessage webRtcDisconnectMessage = 8; } } From 432b4a0e85f41c587c6c00d69849ce8e87c17949 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Tue, 29 Sep 2020 16:12:17 +0200 Subject: [PATCH 073/122] Linting app --- back/src/Controller/AdminController.ts | 36 ++++++++++--------- back/src/Controller/AuthenticateController.ts | 28 ++++++++------- back/src/Server/server/app.ts | 2 +- back/src/Server/server/baseapp.ts | 6 ++-- back/src/Server/server/sslapp.ts | 2 +- back/src/Server/server/utils.ts | 2 +- front/src/Connection.ts | 12 +++---- 7 files changed, 46 insertions(+), 42 deletions(-) diff --git a/back/src/Controller/AdminController.ts b/back/src/Controller/AdminController.ts index 78280523..7bb536ca 100644 --- a/back/src/Controller/AdminController.ts +++ b/back/src/Controller/AdminController.ts @@ -12,27 +12,29 @@ export class AdminController { getLoginUrlByToken(){ - this.App.get("/register/:token", async (res: HttpResponse, req: HttpRequest) => { - if (!ADMIN_API_URL) { - return res.writeStatus("500 Internal Server Error").end('No admin backoffice set!'); - } + this.App.get("/register/:token", (res: HttpResponse, req: HttpRequest) => { + (async () => { + if (!ADMIN_API_URL) { + return res.writeStatus("500 Internal Server Error").end('No admin backoffice set!'); + } - const query = parse(req.getQuery()); + const query = parse(req.getQuery()); - const token:string = query.token as string; + const token:string = query.token as string; - let response = null - try { - response = await Axios.get(ADMIN_API_URL+'/api/login-url/'+token, { headers: {"Authorization" : `${ADMIN_API_TOKEN}`} }) - } catch (e) { - console.log(e.message) - return res.status(e.status || 500).send('An error happened'); - } + let response = null + try { + response = await Axios.get(ADMIN_API_URL+'/api/login-url/'+token, { headers: {"Authorization" : `${ADMIN_API_TOKEN}`} }) + } catch (e) { + console.log(e.message) + return res.status(e.status || 500).send('An error happened'); + } - const organizationSlug = response.data.organizationSlug; - const worldSlug = response.data.worldSlug; - const roomSlug = response.data.roomSlug; - return res.writeStatus("200 OK").end(JSON.stringify({organizationSlug, worldSlug, roomSlug})); + const organizationSlug = response.data.organizationSlug; + const worldSlug = response.data.worldSlug; + const roomSlug = response.data.roomSlug; + res.writeStatus("200 OK").end(JSON.stringify({organizationSlug, worldSlug, roomSlug})); + })(); }); } } diff --git a/back/src/Controller/AuthenticateController.ts b/back/src/Controller/AuthenticateController.ts index b7fd093c..6585054d 100644 --- a/back/src/Controller/AuthenticateController.ts +++ b/back/src/Controller/AuthenticateController.ts @@ -39,20 +39,22 @@ export class AuthenticateController extends BaseController { res.end(); }); - this.App.post("/login", async (res: HttpResponse, req: HttpRequest) => { - this.addCorsHeaders(res); + this.App.post("/login", (res: HttpResponse, req: HttpRequest) => { + (async () => { + this.addCorsHeaders(res); - res.onAborted(() => { - console.warn('Login request was aborted'); - }) - const param = await res.json(); - const userUuid = uuid(); - const token = Jwt.sign({name: param.name, userUuid: userUuid} as TokenInterface, SECRET_KEY, {expiresIn: '24h'}); - res.writeStatus("200 OK").end(JSON.stringify({ - token: token, - mapUrlStart: URL_ROOM_STARTED, - userId: userUuid, - })); + res.onAborted(() => { + console.warn('Login request was aborted'); + }) + const param = await res.json(); + const userUuid = uuid(); + const token = Jwt.sign({name: param.name, userUuid: userUuid} as TokenInterface, SECRET_KEY, {expiresIn: '24h'}); + res.writeStatus("200 OK").end(JSON.stringify({ + token: token, + mapUrlStart: URL_ROOM_STARTED, + userId: userUuid, + })); + })(); }); } } diff --git a/back/src/Server/server/app.ts b/back/src/Server/server/app.ts index 800353c2..3b98a9b3 100644 --- a/back/src/Server/server/app.ts +++ b/back/src/Server/server/app.ts @@ -5,7 +5,7 @@ import { UwsApp } from './types'; class App extends (_App) { constructor(options: AppOptions = {}) { - super(options); + super(options); // eslint-disable-line constructor-super extend(this, new BaseApp()); } } diff --git a/back/src/Server/server/baseapp.ts b/back/src/Server/server/baseapp.ts index d723c33d..0c07c17e 100644 --- a/back/src/Server/server/baseapp.ts +++ b/back/src/Server/server/baseapp.ts @@ -11,11 +11,11 @@ const handleBody = (res: HttpResponse, req: HttpRequest) => { res.bodyStream = function() { const stream = new Readable(); - stream._read = noOp; + stream._read = noOp; // eslint-disable-line @typescript-eslint/unbound-method this.onData((ab, isLast) => { // uint and then slicing is bit faster than slice and then uint - stream.push(new Uint8Array(ab.slice((ab as any).byteOffset, ab.byteLength))); + stream.push(new Uint8Array(ab.slice((ab as any).byteOffset, ab.byteLength))); // eslint-disable-line @typescript-eslint/no-explicit-any if (isLast) { stream.push(null); } @@ -26,7 +26,7 @@ const handleBody = (res: HttpResponse, req: HttpRequest) => { res.body = () => stob(res.bodyStream()); - if (contType.indexOf('application/json') > -1) + if (contType.includes('application/json')) res.json = async () => JSON.parse(await res.body()); }; diff --git a/back/src/Server/server/sslapp.ts b/back/src/Server/server/sslapp.ts index 60b17aa4..46ae89a5 100644 --- a/back/src/Server/server/sslapp.ts +++ b/back/src/Server/server/sslapp.ts @@ -5,7 +5,7 @@ import { UwsApp } from './types'; class SSLApp extends (_SSLApp) { constructor(options: AppOptions) { - super(options); + super(options); // eslint-disable-line constructor-super extend(this, new BaseApp()); } } diff --git a/back/src/Server/server/utils.ts b/back/src/Server/server/utils.ts index f7f3e4b5..80ea3938 100644 --- a/back/src/Server/server/utils.ts +++ b/back/src/Server/server/utils.ts @@ -1,6 +1,6 @@ import { ReadStream } from 'fs'; -function extend(who: any, from: any, overwrite = true) { +function extend(who: any, from: any, overwrite = true) { // eslint-disable-line @typescript-eslint/no-explicit-any const ownProps = Object.getOwnPropertyNames(Object.getPrototypeOf(from)).concat( Object.keys(from) ); diff --git a/front/src/Connection.ts b/front/src/Connection.ts index 6da46c2d..e0c3121d 100644 --- a/front/src/Connection.ts +++ b/front/src/Connection.ts @@ -149,9 +149,9 @@ export class Connection implements Connection { private readonly socket: WebSocket; private userId: number|null = null; private listeners: Map = new Map(); - private static websocketFactory: null|((url: string)=>any) = null; + private static websocketFactory: null|((url: string)=>any) = null; // eslint-disable-line @typescript-eslint/no-explicit-any - public static setWebsocketFactory(websocketFactory: (url: string)=>any): void { + public static setWebsocketFactory(websocketFactory: (url: string)=>any): void { // eslint-disable-line @typescript-eslint/no-explicit-any Connection.websocketFactory = websocketFactory; } @@ -206,9 +206,9 @@ export class Connection implements Connection { } else if (message.hasRoomjoinedmessage()) { const roomJoinedMessage = message.getRoomjoinedmessage() as RoomJoinedMessage; - const users: Array = roomJoinedMessage.getUserList().map(this.toMessageUserJoined); - const groups: Array = roomJoinedMessage.getGroupList().map(this.toGroupCreatedUpdatedMessage); - let items: { [itemId: number] : unknown } = {}; + const users: Array = roomJoinedMessage.getUserList().map(this.toMessageUserJoined.bind(this)); + const groups: Array = roomJoinedMessage.getGroupList().map(this.toGroupCreatedUpdatedMessage.bind(this)); + const items: { [itemId: number] : unknown } = {}; for (const item of roomJoinedMessage.getItemList()) { items[item.getItemid()] = JSON.parse(item.getStatejson()); } @@ -221,7 +221,7 @@ export class Connection implements Connection { } else if (message.hasSetuseridmessage()) { this.userId = (message.getSetuseridmessage() as SetUserIdMessage).getUserid(); } else if (message.hasErrormessage()) { - console.error(EventMessage.MESSAGE_ERROR, message.getErrormessage()?.getMessage); + console.error(EventMessage.MESSAGE_ERROR, message.getErrormessage()?.getMessage()); } else if (message.hasWebrtcsignaltoclientmessage()) { this.dispatch(EventMessage.WEBRTC_SIGNAL, message.getWebrtcsignaltoclientmessage()); } else if (message.hasWebrtcscreensharingsignaltoclientmessage()) { From a37557dd4b0864f0f82fd21c97cccb7d856d8028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Tue, 29 Sep 2020 16:27:41 +0200 Subject: [PATCH 074/122] Fixing tests --- back/tests/PositionNotifierTest.ts | 9 ++++---- back/tests/WorldTest.ts | 34 ++++++++++++++++++------------ 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/back/tests/PositionNotifierTest.ts b/back/tests/PositionNotifierTest.ts index e65d025d..253283af 100644 --- a/back/tests/PositionNotifierTest.ts +++ b/back/tests/PositionNotifierTest.ts @@ -8,6 +8,7 @@ import {PointInterface} from "../src/Model/Websocket/PointInterface"; import {Zone} from "_Model/Zone"; import {Movable} from "_Model/Movable"; import {PositionInterface} from "_Model/PositionInterface"; +import {ExSocketInterface} from "_Model/Websocket/ExSocketInterface"; describe("PositionNotifier", () => { @@ -29,14 +30,14 @@ describe("PositionNotifier", () => { y: 500, moving: false, direction: 'down' - }, false, positionNotifier); + }, false, positionNotifier, {} as ExSocketInterface); const user2 = new User(2, { x: -9999, y: -9999, moving: false, direction: 'down' - }, false, positionNotifier); + }, false, positionNotifier, {} as ExSocketInterface); positionNotifier.setViewport(user1, { left: 200, @@ -107,14 +108,14 @@ describe("PositionNotifier", () => { y: 500, moving: false, direction: 'down' - }, false, positionNotifier); + }, false, positionNotifier, {} as ExSocketInterface); const user2 = new User(2, { x: 0, y: 0, moving: false, direction: 'down' - }, false, positionNotifier); + }, false, positionNotifier, {} as ExSocketInterface); let newUsers = positionNotifier.setViewport(user1, { left: 200, diff --git a/back/tests/WorldTest.ts b/back/tests/WorldTest.ts index 9afef228..8d3b1a2d 100644 --- a/back/tests/WorldTest.ts +++ b/back/tests/WorldTest.ts @@ -2,22 +2,30 @@ import "jasmine"; import {World, ConnectCallback, DisconnectCallback } from "../src/Model/World"; import {Point} from "../src/Model/Websocket/MessageUserPosition"; import { Group } from "../src/Model/Group"; +import {ExSocketInterface} from "_Model/Websocket/ExSocketInterface"; +import {User} from "_Model/User"; + +function createMockUser(userId: number): ExSocketInterface { + return { + userId + } as ExSocketInterface; +} describe("World", () => { it("should connect user1 and user2", () => { let connectCalledNumber: number = 0; - const connect: ConnectCallback = (user: number, group: Group): void => { + const connect: ConnectCallback = (user: User, group: Group): void => { connectCalledNumber++; } - const disconnect: DisconnectCallback = (user: number, group: Group): void => { + const disconnect: DisconnectCallback = (user: User, group: Group): void => { } const world = new World(connect, disconnect, 160, 160, () => {}, () => {}, () => {}); - world.join({ userId: 1 }, new Point(100, 100)); + world.join(createMockUser(1), new Point(100, 100)); - world.join({ userId: 2 }, new Point(500, 100)); + world.join(createMockUser(2), new Point(500, 100)); world.updatePosition({ userId: 2 }, new Point(261, 100)); @@ -33,24 +41,24 @@ describe("World", () => { it("should connect 3 users", () => { let connectCalled: boolean = false; - const connect: ConnectCallback = (user: number, group: Group): void => { + const connect: ConnectCallback = (user: User, group: Group): void => { connectCalled = true; } - const disconnect: DisconnectCallback = (user: number, group: Group): void => { + const disconnect: DisconnectCallback = (user: User, group: Group): void => { } const world = new World(connect, disconnect, 160, 160, () => {}, () => {}, () => {}); - world.join({ userId: 1 }, new Point(100, 100)); + world.join(createMockUser(1), new Point(100, 100)); - world.join({ userId: 2 }, new Point(200, 100)); + world.join(createMockUser(2), new Point(200, 100)); expect(connectCalled).toBe(true); connectCalled = false; // baz joins at the outer limit of the group - world.join({ userId: 3 }, new Point(311, 100)); + world.join(createMockUser(3), new Point(311, 100)); expect(connectCalled).toBe(false); @@ -62,18 +70,18 @@ describe("World", () => { it("should disconnect user1 and user2", () => { let connectCalled: boolean = false; let disconnectCallNumber: number = 0; - const connect: ConnectCallback = (user: number, group: Group): void => { + const connect: ConnectCallback = (user: User, group: Group): void => { connectCalled = true; } - const disconnect: DisconnectCallback = (user: number, group: Group): void => { + const disconnect: DisconnectCallback = (user: User, group: Group): void => { disconnectCallNumber++; } const world = new World(connect, disconnect, 160, 160, () => {}, () => {}, () => {}); - world.join({ userId: 1 }, new Point(100, 100)); + world.join(createMockUser(1), new Point(100, 100)); - world.join({ userId: 2 }, new Point(259, 100)); + world.join(createMockUser(2), new Point(259, 100)); expect(connectCalled).toBe(true); expect(disconnectCallNumber).toBe(0); From 53c6c2bc30d7c896a64553ce2c807e95cbe93804 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Tue, 29 Sep 2020 17:24:16 +0200 Subject: [PATCH 075/122] Fixing benchmark --- back/src/Controller/IoSocketController.ts | 18 ++++++------------ back/src/Model/Websocket/ExSocketInterface.ts | 1 - benchmark/index.ts | 9 +++++++-- front/src/Connexion/RoomConnection.ts | 4 ++-- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index dc116616..c8753371 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -244,14 +244,10 @@ export class IoSocketController { //leave room this.leaveRoom(Client); - //leave webrtc room - //socket.leave(Client.webRtcRoomId); - //delete all socket information - delete Client.webRtcRoomId; - delete Client.roomId; + /*delete Client.roomId; delete Client.token; - delete Client.position; + delete Client.position;*/ } catch (e) { console.error('An error occurred on "disconnect"'); console.error(e); @@ -308,7 +304,7 @@ export class IoSocketController { } //leave previous room - this.leaveRoom(Client); + //this.leaveRoom(Client); // Useless now, there is only one room per connection //join new previous room const world = this.joinRoom(Client, roomId, ProtobufUtils.toPointInterface(message.getPosition() as PositionMessage)); @@ -567,7 +563,7 @@ export class IoSocketController { //Client.leave(Client.roomId); } finally { this.nbClientsPerRoomGauge.dec({ room: Client.roomId }); - delete Client.roomId; + //delete Client.roomId; } } } @@ -694,8 +690,6 @@ export class IoSocketController { return; }*/ - // TODO: joinWebRtcRoom will be trigerred twice when joining the first time! Maybe we should fix the GROUP constructor to trigger only one event -console.log('joinWebRtcRoom FOR '+user.socket.name+" "+user.socket.userId); for (const otherUser of group.getUsers()) { if (user === otherUser) { continue; @@ -712,7 +706,7 @@ console.log('joinWebRtcRoom FOR '+user.socket.name+" "+user.socket.userId); if (!user.socket.disconnecting) { user.socket.send(serverToClientMessage1.serializeBinary().buffer, true); - console.log('Sending webrtcstart initiator to '+user.socket.userId) + //console.log('Sending webrtcstart initiator to '+user.socket.userId) } const webrtcStartMessage2 = new WebRtcStartMessage(); @@ -725,7 +719,7 @@ console.log('joinWebRtcRoom FOR '+user.socket.name+" "+user.socket.userId); if (!otherUser.socket.disconnecting) { otherUser.socket.send(serverToClientMessage2.serializeBinary().buffer, true); - console.log('Sending webrtcstart to '+otherUser.socket.userId) + //console.log('Sending webrtcstart to '+otherUser.socket.userId) } } diff --git a/back/src/Model/Websocket/ExSocketInterface.ts b/back/src/Model/Websocket/ExSocketInterface.ts index 46c4b787..00aeadb7 100644 --- a/back/src/Model/Websocket/ExSocketInterface.ts +++ b/back/src/Model/Websocket/ExSocketInterface.ts @@ -7,7 +7,6 @@ import {WebSocket} from "uWebSockets.js" export interface ExSocketInterface extends WebSocket, Identificable { token: string; roomId: string; - webRtcRoomId: string|undefined; userId: number; // A temporary (autoincremented) identifier for this user userUuid: string; // A unique identifier for this user name: string; diff --git a/benchmark/index.ts b/benchmark/index.ts index ebf58c6a..af209581 100644 --- a/benchmark/index.ts +++ b/benchmark/index.ts @@ -1,4 +1,5 @@ -import {RoomConnection} from "../front/src/Connexion/Connection"; +import {RoomConnection} from "../front/src/Connexion/RoomConnection"; +import {connectionManager} from "../front/src/Connexion/ConnectionManager"; import * as WebSocket from "ws" function sleep(ms) { @@ -10,7 +11,8 @@ RoomConnection.setWebsocketFactory((url: string) => { }); async function startOneUser(): Promise { - const connection = await RoomConnection.createConnection('foo', ['male3']); + const connection = await connectionManager.connectToRoomSocket(); + connection.emitPlayerDetailsMessage('foo', ['male3']); await connection.joinARoom('global__maps.workadventure.localhost/Floor0/floor0', 783, 170, 'down', false, { top: 0, @@ -43,6 +45,9 @@ async function startOneUser(): Promise { } (async () => { + + //await connectionManager.init(); + for (let userNo = 0; userNo < 40; userNo++) { startOneUser(); // Wait 0.5s between adding users diff --git a/front/src/Connexion/RoomConnection.ts b/front/src/Connexion/RoomConnection.ts index e64164b8..526ce54c 100644 --- a/front/src/Connexion/RoomConnection.ts +++ b/front/src/Connexion/RoomConnection.ts @@ -61,7 +61,7 @@ export class RoomConnection implements RoomConnection { this.socket.binaryType = 'arraybuffer'; this.socket.onopen = (ev) => { - console.log('WS connected'); + //console.log('WS connected'); }; this.socket.onmessage = (messageEvent) => { @@ -143,7 +143,7 @@ export class RoomConnection implements RoomConnection { public emitPlayerDetailsMessage(userName: string, characterLayersSelected: string[]) { const message = new SetPlayerDetailsMessage(); - message.setName(name); + message.setName(userName); message.setCharacterlayersList(characterLayersSelected); const clientToServerMessage = new ClientToServerMessage(); From e9b538e43c14d1ee7bf84afc9d55340e8fe88c58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Tue, 29 Sep 2020 17:30:38 +0200 Subject: [PATCH 076/122] Fixing import --- back/src/Controller/AuthenticateController.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/back/src/Controller/AuthenticateController.ts b/back/src/Controller/AuthenticateController.ts index b6381eea..d8d92cc1 100644 --- a/back/src/Controller/AuthenticateController.ts +++ b/back/src/Controller/AuthenticateController.ts @@ -1,6 +1,4 @@ import Jwt from "jsonwebtoken"; -import {SECRET_KEY, URL_ROOM_STARTED} from "../Enum/EnvironmentVariable"; //TODO fix import by "_Enum/..." -import {OK} from "http-status-codes"; import {ADMIN_API_TOKEN, ADMIN_API_URL, SECRET_KEY, URL_ROOM_STARTED} from "../Enum/EnvironmentVariable"; //TODO fix import by "_Enum/..." import { uuid } from 'uuidv4'; import {HttpRequest, HttpResponse, TemplatedApp} from "uWebSockets.js"; From 5de2f6123179739b637efa2ecfd6d37eac95e26c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 30 Sep 2020 10:12:40 +0200 Subject: [PATCH 077/122] Adding back authentication to uws websocket --- back/src/Controller/AdminController.ts | 0 back/src/Controller/AuthenticateController.ts | 5 +- back/src/Controller/IoSocketController.ts | 134 +++++++++++++----- back/src/Model/Websocket/ExSocketInterface.ts | 1 - 4 files changed, 98 insertions(+), 42 deletions(-) delete mode 100644 back/src/Controller/AdminController.ts diff --git a/back/src/Controller/AdminController.ts b/back/src/Controller/AdminController.ts deleted file mode 100644 index e69de29b..00000000 diff --git a/back/src/Controller/AuthenticateController.ts b/back/src/Controller/AuthenticateController.ts index d8d92cc1..ce97eb0e 100644 --- a/back/src/Controller/AuthenticateController.ts +++ b/back/src/Controller/AuthenticateController.ts @@ -39,6 +39,7 @@ export class AuthenticateController extends BaseController { res.onAborted(() => { console.warn('Login request was aborted'); }) + const host = req.getHeader('host'); const param = await res.json(); //todo: what to do if the organizationMemberToken is already used? @@ -63,7 +64,7 @@ export class AuthenticateController extends BaseController { newUrl = this.getNewUrlOnAdminAuth(data) } else { userUuid = uuid(); - mapUrlStart = req.getHeader('host').replace('api.', 'maps.') + URL_ROOM_STARTED; + mapUrlStart = host.replace('api.', 'maps.') + URL_ROOM_STARTED; newUrl = null; } @@ -76,7 +77,7 @@ export class AuthenticateController extends BaseController { })); } catch (e) { - console.log(e.message) + console.log("An error happened", e) res.writeStatus(e.status || "500 Internal Server Error").end('An error happened'); } diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index c8753371..49ff7f49 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -47,7 +47,8 @@ import { import {UserMovesMessage} from "../Messages/generated/messages_pb"; import Direction = PositionMessage.Direction; import {ProtobufUtils} from "../Model/Websocket/ProtobufUtils"; -import {App, TemplatedApp, WebSocket} from "uWebSockets.js" +import {App, HttpRequest, TemplatedApp, WebSocket} from "uWebSockets.js" +import {parse} from "query-string"; enum SocketIoEvent { CONNECTION = "connection", @@ -135,67 +136,122 @@ export class IoSocketController { return null; }*/ - private authenticate(ws: WebSocket) { + private async authenticate(req: HttpRequest): Promise<{ token: string, userUuid: string }> { //console.log(socket.handshake.query.token); - /*if (!socket.handshake.query || !socket.handshake.query.token) { - console.error('An authentication error happened, a user tried to connect without a token.'); - return next(new Error('Authentication error')); - } - if(socket.handshake.query.token === 'test'){ - if (ALLOW_ARTILLERY) { - (socket as ExSocketInterface).token = socket.handshake.query.token; - (socket as ExSocketInterface).userId = this.nextUserId; - (socket as ExSocketInterface).userUuid = uuid(); - this.nextUserId++; - (socket as ExSocketInterface).isArtillery = true; - console.log((socket as ExSocketInterface).userId); - next(); - return; - } else { - console.warn("In order to perform a load-testing test on this environment, you must set the ALLOW_ARTILLERY environment variable to 'true'"); - next(); + const query = parse(req.getQuery()); + + if (!query.token) { + console.error('An authentication error happened, a user tried to connect without a token.'); + throw new Error('An authentication error happened, a user tried to connect without a token.'); + } + + const token = query.token; + if (typeof(token) !== "string") { + throw new Error('Token is expected to be a string'); + } + + + if(token === 'test'){ + if (ALLOW_ARTILLERY) { + return { + token, + userUuid: uuid() } + } else { + throw new Error("In order to perform a load-testing test on this environment, you must set the ALLOW_ARTILLERY environment variable to 'true'"); } - (socket as ExSocketInterface).isArtillery = false; - if(this.searchClientByToken(socket.handshake.query.token)){ - console.error('An authentication error happened, a user tried to connect while its token is already connected.'); - return next(new Error('Authentication error')); - } - Jwt.verify(socket.handshake.query.token, SECRET_KEY, (err: JsonWebTokenError, tokenDecoded: object) => { + } + + /*if(this.searchClientByToken(socket.handshake.query.token)){ + console.error('An authentication error happened, a user tried to connect while its token is already connected.'); + return next(new Error('Authentication error')); + }*/ + + const promise = new Promise<{ token: string, userUuid: string }>((resolve, reject) => { + Jwt.verify(token, SECRET_KEY, (err: JsonWebTokenError, tokenDecoded: object) => { const tokenInterface = tokenDecoded as TokenInterface; if (err) { console.error('An authentication error happened, invalid JsonWebToken.', err); - return next(new Error('Authentication error')); + reject(new Error('An authentication error happened, invalid JsonWebToken. '+err.message)); + return; } if (!this.isValidToken(tokenInterface)) { - return next(new Error('Authentication error, invalid token structure')); + reject(new Error('Authentication error, invalid token structure.')); + return; } - (socket as ExSocketInterface).token = socket.handshake.query.token; - (socket as ExSocketInterface).userId = this.nextUserId; - (socket as ExSocketInterface).userUuid = tokenInterface.userUuid; - this.nextUserId++; - next(); - });*/ - const socket = ws as ExSocketInterface; - socket.userId = this.nextUserId; - this.nextUserId++; + resolve({ + token, + userUuid: tokenInterface.userUuid + }); + }); + }); + + return promise; } ioConnection() { this.app.ws('/*', { + /* Options */ //compression: uWS.SHARED_COMPRESSOR, maxPayloadLength: 16 * 1024 * 1024, //idleTimeout: 10, + upgrade: (res, req, context) => { + console.log('An Http connection wants to become WebSocket, URL: ' + req.getUrl() + '!'); + (async () => { + + /* Keep track of abortions */ + const upgradeAborted = {aborted: false}; + + res.onAborted(() => { + /* We can simply signal that we were aborted */ + upgradeAborted.aborted = true; + }); + + try { + const result = await this.authenticate(req); + + if (upgradeAborted.aborted) { + console.log("Ouch! Client disconnected before we could upgrade it!"); + /* You must not upgrade now */ + return; + } + + /* This immediately calls open handler, you must not use res after this call */ + res.upgrade({ + // Data passed here is accessible on the "websocket" socket object. + url: req.getUrl(), + token: result.token, + userUuid: result.userUuid + }, + /* Spell these correctly */ + req.getHeader('sec-websocket-key'), + req.getHeader('sec-websocket-protocol'), + req.getHeader('sec-websocket-extensions'), + context); + + } catch (e: unknown) { + if (e instanceof Error) { + console.warn(e.message); + res.writeStatus("401 Unauthorized").end(e.message); + } else { + console.warn(e); + res.writeStatus("500 Internal Server Error").end('An error occurred'); + } + return; + } + })(); + }, /* Handlers */ open: (ws) => { - this.authenticate(ws); - // TODO: close if authenticate is ko - const client : ExSocketInterface = ws as ExSocketInterface; + client.userId = this.nextUserId; + this.nextUserId++; + client.userUuid = ws.userUuid; + client.token = ws.token; client.batchedMessages = new BatchMessage(); client.batchTimeout = null; client.emitInBatch = (payload: SubMessage): void => { diff --git a/back/src/Model/Websocket/ExSocketInterface.ts b/back/src/Model/Websocket/ExSocketInterface.ts index 00aeadb7..d70205ef 100644 --- a/back/src/Model/Websocket/ExSocketInterface.ts +++ b/back/src/Model/Websocket/ExSocketInterface.ts @@ -13,7 +13,6 @@ export interface ExSocketInterface extends WebSocket, Identificable { characterLayers: string[]; position: PointInterface; viewport: ViewportInterface; - isArtillery: boolean; // Whether this socket is opened by Artillery for load testing (hack) /** * Pushes an event that will be sent in the next batch of events */ From c7f5770968313df41a2ec0c3478300aa407360f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 30 Sep 2020 10:17:01 +0200 Subject: [PATCH 078/122] Fix CI --- back/src/Controller/IoSocketController.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index 49ff7f49..6248372c 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -233,7 +233,7 @@ export class IoSocketController { req.getHeader('sec-websocket-extensions'), context); - } catch (e: unknown) { + } catch (e) { if (e instanceof Error) { console.warn(e.message); res.writeStatus("401 Unauthorized").end(e.message); From 074398c4e09b46f978337e9f6515556fdb85a7e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 30 Sep 2020 12:12:24 +0200 Subject: [PATCH 079/122] Fixing benchmark initialization --- benchmark/index.ts | 2 +- front/src/Connexion/ConnectionManager.ts | 4 ++++ front/src/Connexion/RoomConnection.ts | 1 - 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/benchmark/index.ts b/benchmark/index.ts index af209581..df1a69dd 100644 --- a/benchmark/index.ts +++ b/benchmark/index.ts @@ -45,8 +45,8 @@ async function startOneUser(): Promise { } (async () => { + connectionManager.initBenchmark(); - //await connectionManager.init(); for (let userNo = 0; userNo < 40; userNo++) { startOneUser(); diff --git a/front/src/Connexion/ConnectionManager.ts b/front/src/Connexion/ConnectionManager.ts index 311f0351..4df45099 100644 --- a/front/src/Connexion/ConnectionManager.ts +++ b/front/src/Connexion/ConnectionManager.ts @@ -31,6 +31,10 @@ class ConnectionManager { } } + public initBenchmark(): void { + this.authToken = 'test'; + } + public connectToRoomSocket(): Promise { return new Promise((resolve, reject) => { const connection = new RoomConnection(this.authToken as string); diff --git a/front/src/Connexion/RoomConnection.ts b/front/src/Connexion/RoomConnection.ts index 526ce54c..f96d2eed 100644 --- a/front/src/Connexion/RoomConnection.ts +++ b/front/src/Connexion/RoomConnection.ts @@ -120,7 +120,6 @@ export class RoomConnection implements RoomConnection { } else if (message.hasWebrtcscreensharingsignaltoclientmessage()) { this.dispatch(EventMessage.WEBRTC_SCREEN_SHARING_SIGNAL, message.getWebrtcscreensharingsignaltoclientmessage()); } else if (message.hasWebrtcstartmessage()) { - console.log('Received WebRtcStartMessage'); this.dispatch(EventMessage.WEBRTC_START, message.getWebrtcstartmessage()); } else if (message.hasWebrtcdisconnectmessage()) { this.dispatch(EventMessage.WEBRTC_DISCONNECT, message.getWebrtcdisconnectmessage()); From d9c910cfca2cf1c236fbac2b6c86939d568dae0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 30 Sep 2020 12:16:39 +0200 Subject: [PATCH 080/122] Removing useless code --- back/src/App.ts | 12 ----- back/src/Controller/IoSocketController.ts | 62 ++++++++++++++--------- 2 files changed, 38 insertions(+), 36 deletions(-) diff --git a/back/src/App.ts b/back/src/App.ts index b251290c..155ed450 100644 --- a/back/src/App.ts +++ b/back/src/App.ts @@ -20,18 +20,6 @@ class App { this.config(); this.crossOrigin(); - //TODO add middleware with access token to secure api - - // STUPID CORS IMPLEMENTATION. - // TODO: SECURE THIS - this.app.any('/*', (res, req) => { - res.writeHeader('access-control-allow-headers', 'Origin, X-Requested-With, Content-Type, Accept'); - res.writeHeader('access-control-allow-methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE'); - res.writeHeader('access-control-allow-origin', '*'); - - req.setYield(true); - }); - //create socket controllers this.ioSocketController = new IoSocketController(this.app); this.authenticateController = new AuthenticateController(this.app); diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index 6248372c..511a171e 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -50,27 +50,6 @@ import {ProtobufUtils} from "../Model/Websocket/ProtobufUtils"; import {App, HttpRequest, TemplatedApp, WebSocket} from "uWebSockets.js" import {parse} from "query-string"; -enum SocketIoEvent { - CONNECTION = "connection", - DISCONNECT = "disconnect", - JOIN_ROOM = "join-room", // bi-directional - USER_POSITION = "user-position", // From client to server - USER_MOVED = "user-moved", // From server to client - USER_LEFT = "user-left", // From server to client - WEBRTC_SIGNAL = "webrtc-signal", - WEBRTC_SCREEN_SHARING_SIGNAL = "webrtc-screen-sharing-signal", - WEBRTC_START = "webrtc-start", - WEBRTC_DISCONNECT = "webrtc-disconect", - MESSAGE_ERROR = "message-error", - GROUP_CREATE_UPDATE = "group-create-update", - GROUP_DELETE = "group-delete", - SET_PLAYER_DETAILS = "set-player-details", - ITEM_EVENT = 'item-event', - SET_SILENT = "set_silent", // Set or unset the silent mode for this user. - SET_VIEWPORT = "set-viewport", - BATCH = "batch", -} - function emitInBatch(socket: ExSocketInterface, payload: SubMessage): void { socket.batchedMessages.addPayload(payload); @@ -111,6 +90,41 @@ export class IoSocketController { }); this.ioConnection(); + + + + + let time = process.hrtime.bigint() + let usage = process.cpuUsage() + + + function secNSec2ms(secNSec) { + if (Array.isArray(secNSec)) { + return secNSec[0] * 1000 + secNSec[1] / 1000000; + } + return secNSec / 1000; + } + + let oldCpuUsage = process.cpuUsage(); + setInterval(() => { + let elapTime = process.hrtime.bigint(); + let elapUsage = process.cpuUsage(usage) + usage = process.cpuUsage() + + let elapTimeMS = elapTime - time; + let elapUserMS = secNSec2ms(elapUsage.user) + let elapSystMS = secNSec2ms(elapUsage.system) + let cpuPercent = Math.round(100 * (elapUserMS + elapSystMS) / Number(elapTimeMS) * 1000000) + + time = elapTime; + //usage = elapUsage; + console.log('elapsed time ms: ', elapTimeMS) + console.log('elapsed user ms: ', elapUserMS) + console.log('elapsed system ms:', elapSystMS) + console.log('cpu percent: ', cpuPercent) + + + }, 500); } private isValidToken(token: object): token is TokenInterface { @@ -142,7 +156,6 @@ export class IoSocketController { const query = parse(req.getQuery()); if (!query.token) { - console.error('An authentication error happened, a user tried to connect without a token.'); throw new Error('An authentication error happened, a user tried to connect without a token.'); } @@ -152,7 +165,7 @@ export class IoSocketController { } - if(token === 'test'){ + if(token === 'test') { if (ALLOW_ARTILLERY) { return { token, @@ -198,9 +211,10 @@ export class IoSocketController { /* Options */ //compression: uWS.SHARED_COMPRESSOR, maxPayloadLength: 16 * 1024 * 1024, + maxBackpressure: 65536, // Maximum 64kB of data in the buffer. //idleTimeout: 10, upgrade: (res, req, context) => { - console.log('An Http connection wants to become WebSocket, URL: ' + req.getUrl() + '!'); + //console.log('An Http connection wants to become WebSocket, URL: ' + req.getUrl() + '!'); (async () => { /* Keep track of abortions */ From 27871641aa2e7d708542040dbb777f9a0a790522 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 30 Sep 2020 12:17:27 +0200 Subject: [PATCH 081/122] Removing dead code --- back/src/App.ts | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/back/src/App.ts b/back/src/App.ts index 155ed450..c575279c 100644 --- a/back/src/App.ts +++ b/back/src/App.ts @@ -17,9 +17,6 @@ class App { constructor() { this.app = new uwsApp(); - this.config(); - this.crossOrigin(); - //create socket controllers this.ioSocketController = new IoSocketController(this.app); this.authenticateController = new AuthenticateController(this.app); @@ -27,23 +24,6 @@ class App { this.prometheusController = new PrometheusController(this.app, this.ioSocketController); this.debugController = new DebugController(this.app, this.ioSocketController); } - - // TODO add session user - private config(): void { - /*this.app.use(bodyParser.json()); - this.app.use(bodyParser.urlencoded({extended: false}));*/ - } - - private crossOrigin(){ - /*this.app.use((req: Request, res: Response, next) => { - res.setHeader("Access-Control-Allow-Origin", "*"); // update to match the domain you will make the request from - // Request methods you wish to allow - res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE'); - // Request headers you wish to allow - res.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); - next(); - });*/ - } } export default new App().app; From a87cdc543bf5cbfa78c51c0c0642425441f1179e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 30 Sep 2020 12:50:34 +0200 Subject: [PATCH 082/122] Adding CPU tracking: if CPU > 80%, ignore position of moving players --- back/src/Controller/IoSocketController.ts | 41 ++++------------------- back/src/Services/CpuTracker.ts | 40 ++++++++++++++++++++++ benchmark/index.ts | 2 +- 3 files changed, 47 insertions(+), 36 deletions(-) create mode 100644 back/src/Services/CpuTracker.ts diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index 511a171e..87a8c5e2 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -49,6 +49,7 @@ import Direction = PositionMessage.Direction; import {ProtobufUtils} from "../Model/Websocket/ProtobufUtils"; import {App, HttpRequest, TemplatedApp, WebSocket} from "uWebSockets.js" import {parse} from "query-string"; +import {cpuTracker} from "../Services/CpuTracker"; function emitInBatch(socket: ExSocketInterface, payload: SubMessage): void { socket.batchedMessages.addPayload(payload); @@ -90,41 +91,6 @@ export class IoSocketController { }); this.ioConnection(); - - - - - let time = process.hrtime.bigint() - let usage = process.cpuUsage() - - - function secNSec2ms(secNSec) { - if (Array.isArray(secNSec)) { - return secNSec[0] * 1000 + secNSec[1] / 1000000; - } - return secNSec / 1000; - } - - let oldCpuUsage = process.cpuUsage(); - setInterval(() => { - let elapTime = process.hrtime.bigint(); - let elapUsage = process.cpuUsage(usage) - usage = process.cpuUsage() - - let elapTimeMS = elapTime - time; - let elapUserMS = secNSec2ms(elapUsage.user) - let elapSystMS = secNSec2ms(elapUsage.system) - let cpuPercent = Math.round(100 * (elapUserMS + elapSystMS) / Number(elapTimeMS) * 1000000) - - time = elapTime; - //usage = elapUsage; - console.log('elapsed time ms: ', elapTimeMS) - console.log('elapsed user ms: ', elapUserMS) - console.log('elapsed system ms:', elapSystMS) - console.log('cpu percent: ', cpuPercent) - - - }, 500); } private isValidToken(token: object): token is TokenInterface { @@ -452,6 +418,11 @@ export class IoSocketController { try { const userMoves = userMovesMessage.toObject(); + // If CPU is high, let's drop messages of users moving (we will only dispatch the final position) + if (cpuTracker.getCpuPercent() > 80 && userMoves.position?.moving === true) { + return; + } + const position = userMoves.position; if (position === undefined) { throw new Error('Position not found in message'); diff --git a/back/src/Services/CpuTracker.ts b/back/src/Services/CpuTracker.ts new file mode 100644 index 00000000..69eac8b9 --- /dev/null +++ b/back/src/Services/CpuTracker.ts @@ -0,0 +1,40 @@ + +function secNSec2ms(secNSec: Array|number) { + if (Array.isArray(secNSec)) { + return secNSec[0] * 1000 + secNSec[1] / 1000000; + } + return secNSec / 1000; +} + +class CpuTracker { + private cpuPercent: number = 0; + + constructor() { + let time = process.hrtime.bigint() + let usage = process.cpuUsage() + setInterval(() => { + let elapTime = process.hrtime.bigint(); + let elapUsage = process.cpuUsage(usage) + usage = process.cpuUsage() + + let elapTimeMS = elapTime - time; + let elapUserMS = secNSec2ms(elapUsage.user) + let elapSystMS = secNSec2ms(elapUsage.system) + this.cpuPercent = Math.round(100 * (elapUserMS + elapSystMS) / Number(elapTimeMS) * 1000000) + + time = elapTime; + /*console.log('elapsed time ms: ', elapTimeMS) + console.log('elapsed user ms: ', elapUserMS) + console.log('elapsed system ms:', elapSystMS) + console.log('cpu percent: ', this.cpuPercent)*/ + }, 500); + } + + public getCpuPercent(): number { + return this.cpuPercent; + } +} + +const cpuTracker = new CpuTracker(); + +export { cpuTracker }; diff --git a/benchmark/index.ts b/benchmark/index.ts index df1a69dd..420223cc 100644 --- a/benchmark/index.ts +++ b/benchmark/index.ts @@ -14,7 +14,7 @@ async function startOneUser(): Promise { const connection = await connectionManager.connectToRoomSocket(); connection.emitPlayerDetailsMessage('foo', ['male3']); - await connection.joinARoom('global__maps.workadventure.localhost/Floor0/floor0', 783, 170, 'down', false, { + await connection.joinARoom('global__maps.workadventure.localhost/Floor0/floor0', 783, 170, 'down', true, { top: 0, bottom: 200, left: 500, From 57262de1bf1aa8adeac98000bb1246a43f9d43b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 30 Sep 2020 13:49:23 +0200 Subject: [PATCH 083/122] Fixing CI + lowering extrapolation time --- back/src/Services/CpuTracker.ts | 12 ++++++------ front/src/Enum/EnvironmentVariable.ts | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/back/src/Services/CpuTracker.ts b/back/src/Services/CpuTracker.ts index 69eac8b9..abc0a17b 100644 --- a/back/src/Services/CpuTracker.ts +++ b/back/src/Services/CpuTracker.ts @@ -13,13 +13,13 @@ class CpuTracker { let time = process.hrtime.bigint() let usage = process.cpuUsage() setInterval(() => { - let elapTime = process.hrtime.bigint(); - let elapUsage = process.cpuUsage(usage) + const elapTime = process.hrtime.bigint(); + const elapUsage = process.cpuUsage(usage) usage = process.cpuUsage() - let elapTimeMS = elapTime - time; - let elapUserMS = secNSec2ms(elapUsage.user) - let elapSystMS = secNSec2ms(elapUsage.system) + const elapTimeMS = elapTime - time; + const elapUserMS = secNSec2ms(elapUsage.user) + const elapSystMS = secNSec2ms(elapUsage.system) this.cpuPercent = Math.round(100 * (elapUserMS + elapSystMS) / Number(elapTimeMS) * 1000000) time = elapTime; @@ -27,7 +27,7 @@ class CpuTracker { console.log('elapsed user ms: ', elapUserMS) console.log('elapsed system ms:', elapSystMS) console.log('cpu percent: ', this.cpuPercent)*/ - }, 500); + }, 100); } public getCpuPercent(): number { diff --git a/front/src/Enum/EnvironmentVariable.ts b/front/src/Enum/EnvironmentVariable.ts index 59c8b50f..0479d252 100644 --- a/front/src/Enum/EnvironmentVariable.ts +++ b/front/src/Enum/EnvironmentVariable.ts @@ -7,7 +7,7 @@ const JITSI_URL : string|undefined = (process.env.JITSI_URL === '') ? undefined const RESOLUTION = 3; const ZOOM_LEVEL = 1/*3/4*/; const POSITION_DELAY = 200; // Wait 200ms between sending position events -const MAX_EXTRAPOLATION_TIME = 250; // Extrapolate a maximum of 250ms if no new movement is sent by the player +const MAX_EXTRAPOLATION_TIME = 100; // Extrapolate a maximum of 250ms if no new movement is sent by the player export { DEBUG_MODE, From a8bbe04caef82df44b6e2dfa4ad92b9966c42113 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 30 Sep 2020 14:42:35 +0200 Subject: [PATCH 084/122] Adding logs to track overheating --- back/src/Controller/IoSocketController.ts | 2 +- back/src/Enum/EnvironmentVariable.ts | 4 +++- back/src/Services/CpuTracker.ts | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index 87a8c5e2..42be1e1d 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -419,7 +419,7 @@ export class IoSocketController { const userMoves = userMovesMessage.toObject(); // If CPU is high, let's drop messages of users moving (we will only dispatch the final position) - if (cpuTracker.getCpuPercent() > 80 && userMoves.position?.moving === true) { + if (cpuTracker.isOverHeating() && userMoves.position?.moving === true) { return; } diff --git a/back/src/Enum/EnvironmentVariable.ts b/back/src/Enum/EnvironmentVariable.ts index c910bb66..b69ba00c 100644 --- a/back/src/Enum/EnvironmentVariable.ts +++ b/back/src/Enum/EnvironmentVariable.ts @@ -5,6 +5,7 @@ const GROUP_RADIUS = process.env.GROUP_RADIUS ? Number(process.env.GROUP_RADIUS) const ALLOW_ARTILLERY = process.env.ALLOW_ARTILLERY ? process.env.ALLOW_ARTILLERY == 'true' : false; const ADMIN_API_URL = process.env.ADMIN_API_URL || null; const ADMIN_API_TOKEN = process.env.ADMIN_API_TOKEN || null; +const CPU_OVERHEAT_THRESHOLD = Number(process.env.CPU_OVERHEAT_THRESHOLD) || 80; export { SECRET_KEY, @@ -14,4 +15,5 @@ export { ADMIN_API_TOKEN, GROUP_RADIUS, ALLOW_ARTILLERY, -} \ No newline at end of file + CPU_OVERHEAT_THRESHOLD, +} diff --git a/back/src/Services/CpuTracker.ts b/back/src/Services/CpuTracker.ts index abc0a17b..c7d57f3d 100644 --- a/back/src/Services/CpuTracker.ts +++ b/back/src/Services/CpuTracker.ts @@ -1,3 +1,4 @@ +import {CPU_OVERHEAT_THRESHOLD} from "../Enum/EnvironmentVariable"; function secNSec2ms(secNSec: Array|number) { if (Array.isArray(secNSec)) { @@ -8,6 +9,7 @@ function secNSec2ms(secNSec: Array|number) { class CpuTracker { private cpuPercent: number = 0; + private overHeating: boolean = false; constructor() { let time = process.hrtime.bigint() @@ -23,6 +25,15 @@ class CpuTracker { this.cpuPercent = Math.round(100 * (elapUserMS + elapSystMS) / Number(elapTimeMS) * 1000000) time = elapTime; + + if (!this.overHeating && this.cpuPercent > CPU_OVERHEAT_THRESHOLD) { + this.overHeating = true; + console.warn('CPU high threshold alert. Going in "overheat" mode'); + } else if (this.overHeating && this.cpuPercent <= CPU_OVERHEAT_THRESHOLD) { + this.overHeating = false; + console.log('CPU is back to normal. Canceling "overheat" mode'); + } + /*console.log('elapsed time ms: ', elapTimeMS) console.log('elapsed user ms: ', elapUserMS) console.log('elapsed system ms:', elapSystMS) @@ -33,6 +44,10 @@ class CpuTracker { public getCpuPercent(): number { return this.cpuPercent; } + + public isOverHeating(): boolean { + return this.overHeating; + } } const cpuTracker = new CpuTracker(); From e4872c6f9d29df5294b3ee1d1cbdec4e73c216ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 1 Oct 2020 15:55:23 +0200 Subject: [PATCH 085/122] Fix CI --- back/src/Controller/FileController.ts | 101 +++++++++++++------------- back/src/Server/server/baseapp.ts | 2 +- back/src/Server/server/formdata.ts | 8 +- benchmark/index.ts | 4 +- 4 files changed, 56 insertions(+), 59 deletions(-) diff --git a/back/src/Controller/FileController.ts b/back/src/Controller/FileController.ts index fa0c5f24..889cfa61 100644 --- a/back/src/Controller/FileController.ts +++ b/back/src/Controller/FileController.ts @@ -63,7 +63,7 @@ export class FileController extends BaseController { console.log('READING FILE', fieldname) const chunks: Buffer[] = [] - for await (let chunk of file) { + for await (const chunk of file) { if (!(chunk instanceof Buffer)) { throw new Error('Unexpected chunk'); } @@ -101,61 +101,58 @@ export class FileController extends BaseController { }); this.App.get("/download-audio-message/:id", (res: HttpResponse, req: HttpRequest) => { - (async () => { - this.addCorsHeaders(res); + this.addCorsHeaders(res); - res.onAborted(() => { - console.warn('upload-audio-message request was aborted'); - }) + res.onAborted(() => { + console.warn('upload-audio-message request was aborted'); + }) - const id = req.getParameter(0); + const id = req.getParameter(0); - const file = this.uploadedFileBuffers.get(id); - if (file === undefined) { - res.writeStatus("404 Not found").end("Cannot find file"); - return; + const file = this.uploadedFileBuffers.get(id); + if (file === undefined) { + res.writeStatus("404 Not found").end("Cannot find file"); + return; + } + + const readable = new Readable() + readable._read = () => {} // _read is required but you can noop it + readable.push(file.buffer); + readable.push(null); + + const size = file.buffer.byteLength; + + res.writeStatus("200 OK"); + + readable.on('data', buffer => { + const chunk = buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength), + lastOffset = res.getWriteOffset(); + + // First try + const [ok, done] = res.tryEnd(chunk, size); + + if (done) { + readable.destroy(); + } else if (!ok) { + // pause because backpressure + readable.pause(); + + // Save unsent chunk for later + res.ab = chunk; + res.abOffset = lastOffset; + + // Register async handlers for drainage + res.onWritable(offset => { + const [ok, done] = res.tryEnd(res.ab.slice(offset - res.abOffset), size); + if (done) { + readable.destroy(); + } else if (ok) { + readable.resume(); + } + return ok; + }); } - - const readable = new Readable() - readable._read = () => {} // _read is required but you can noop it - readable.push(file.buffer); - readable.push(null); - - const size = file.buffer.byteLength; - - res.writeStatus("200 OK"); - - readable.on('data', buffer => { - const chunk = buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength), - lastOffset = res.getWriteOffset(); - - // First try - const [ok, done] = res.tryEnd(chunk, size); - - if (done) { - readable.destroy(); - } else if (!ok) { - // pause because backpressure - readable.pause(); - - // Save unsent chunk for later - res.ab = chunk; - res.abOffset = lastOffset; - - // Register async handlers for drainage - res.onWritable(offset => { - const [ok, done] = res.tryEnd(res.ab.slice(offset - res.abOffset), size); - if (done) { - readable.destroy(); - } else if (ok) { - readable.resume(); - } - return ok; - }); - } - }); - - })(); + }); }); } } diff --git a/back/src/Server/server/baseapp.ts b/back/src/Server/server/baseapp.ts index 9831c860..accd8a99 100644 --- a/back/src/Server/server/baseapp.ts +++ b/back/src/Server/server/baseapp.ts @@ -31,7 +31,7 @@ const handleBody = (res: HttpResponse, req: HttpRequest) => { if (contType.includes('application/json')) res.json = async () => JSON.parse(await res.body()); - if (contTypes.map(t => contType.indexOf(t) > -1).indexOf(true) > -1) + if (contTypes.map(t => contType.includes(t)).includes(true)) res.formData = formData.bind(res, contType); }; diff --git a/back/src/Server/server/formdata.ts b/back/src/Server/server/formdata.ts index 7af70dda..9dd08440 100644 --- a/back/src/Server/server/formdata.ts +++ b/back/src/Server/server/formdata.ts @@ -15,7 +15,7 @@ function formData( encoding: string, mimetype: string ) => string; - onField?: (fieldname: string, value: any) => void; + onField?: (fieldname: string, value: any) => void; // eslint-disable-line @typescript-eslint/no-explicit-any filename?: (oldName: string) => string; } = {} ) { @@ -75,11 +75,11 @@ function formData( } function setRetValue( - ret: { [x: string]: any }, + ret: { [x: string]: any }, // eslint-disable-line @typescript-eslint/no-explicit-any fieldname: string, - value: { filename: string; encoding: string; mimetype: string; filePath?: string } | any + value: { filename: string; encoding: string; mimetype: string; filePath?: string } | any // eslint-disable-line @typescript-eslint/no-explicit-any ) { - if (fieldname.slice(-2) === '[]') { + if (fieldname.endsWith('[]')) { fieldname = fieldname.slice(0, fieldname.length - 2); if (Array.isArray(ret[fieldname])) { ret[fieldname].push(value); diff --git a/benchmark/index.ts b/benchmark/index.ts index 420223cc..c4bda8fc 100644 --- a/benchmark/index.ts +++ b/benchmark/index.ts @@ -48,9 +48,9 @@ async function startOneUser(): Promise { connectionManager.initBenchmark(); - for (let userNo = 0; userNo < 40; userNo++) { + for (let userNo = 0; userNo < 160; userNo++) { startOneUser(); // Wait 0.5s between adding users - await sleep(500); + await sleep(125); } })(); From 9563013f480cf63baae697cccf076afbdabd899f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 1 Oct 2020 16:02:45 +0200 Subject: [PATCH 086/122] Removing useless file --- front/dist/resources/logos/music-file.svg.back | 1 - 1 file changed, 1 deletion(-) delete mode 100644 front/dist/resources/logos/music-file.svg.back diff --git a/front/dist/resources/logos/music-file.svg.back b/front/dist/resources/logos/music-file.svg.back deleted file mode 100644 index 185bff28..00000000 --- a/front/dist/resources/logos/music-file.svg.back +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file From f06abfae4c8edafee31304d3d9ef37823481cc60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 1 Oct 2020 16:51:51 +0200 Subject: [PATCH 087/122] Migrating to uuid v4 --- back/src/Controller/AuthenticateController.ts | 4 ++-- back/src/Controller/FileController.ts | 4 ++-- back/src/Controller/IoSocketController.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/back/src/Controller/AuthenticateController.ts b/back/src/Controller/AuthenticateController.ts index aa27a468..84cfd97f 100644 --- a/back/src/Controller/AuthenticateController.ts +++ b/back/src/Controller/AuthenticateController.ts @@ -1,6 +1,6 @@ import Jwt from "jsonwebtoken"; import {ADMIN_API_TOKEN, ADMIN_API_URL, SECRET_KEY, URL_ROOM_STARTED} from "../Enum/EnvironmentVariable"; //TODO fix import by "_Enum/..." -import { uuid } from 'uuidv4'; +import { v4 } from 'uuid'; import {HttpRequest, HttpResponse, TemplatedApp} from "uWebSockets.js"; import {BaseController} from "./BaseController"; import Axios from "axios"; @@ -63,7 +63,7 @@ export class AuthenticateController extends BaseController { mapUrlStart = data.mapUrlStart; newUrl = this.getNewUrlOnAdminAuth(data) } else { - userUuid = uuid(); + userUuid = v4(); mapUrlStart = host.replace('api.', 'maps.') + URL_ROOM_STARTED; newUrl = null; } diff --git a/back/src/Controller/FileController.ts b/back/src/Controller/FileController.ts index 889cfa61..87b72b80 100644 --- a/back/src/Controller/FileController.ts +++ b/back/src/Controller/FileController.ts @@ -1,6 +1,6 @@ import {App} from "../Server/sifrr.server"; -import {uuid} from "uuidv4"; +import {v4} from "uuid"; import {HttpRequest, HttpResponse} from "uWebSockets.js"; import {BaseController} from "./BaseController"; import { Readable } from 'stream' @@ -51,7 +51,7 @@ export class FileController extends BaseController { }) try { - const audioMessageId = uuid(); + const audioMessageId = v4(); const params = await res.formData({ onFile: (fieldname: string, diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index 9696748a..e9f97ea6 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -16,7 +16,7 @@ import {PointInterface} from "../Model/Websocket/PointInterface"; import {isWebRtcSignalMessageInterface} from "../Model/Websocket/WebRtcSignalMessage"; import {UserInGroupInterface} from "../Model/Websocket/UserInGroupInterface"; import {isItemEventMessageInterface} from "../Model/Websocket/ItemEventMessage"; -import {uuid} from 'uuidv4'; +import { v4 as uuidv4 } from 'uuid'; import {GroupUpdateInterface} from "_Model/Websocket/GroupUpdateInterface"; import {Movable} from "../Model/Movable"; import { @@ -135,7 +135,7 @@ export class IoSocketController { if (ALLOW_ARTILLERY) { return { token, - userUuid: uuid() + userUuid: uuidv4() } } else { throw new Error("In order to perform a load-testing test on this environment, you must set the ALLOW_ARTILLERY environment variable to 'true'"); From 8bc5832eac2651f2ca2a27c2393971edcb802296 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 1 Oct 2020 17:15:33 +0200 Subject: [PATCH 088/122] Removing warning on startup --- front/src/Connexion/ConnectionManager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/src/Connexion/ConnectionManager.ts b/front/src/Connexion/ConnectionManager.ts index 4df45099..59a54510 100644 --- a/front/src/Connexion/ConnectionManager.ts +++ b/front/src/Connexion/ConnectionManager.ts @@ -10,7 +10,7 @@ interface LoginApiData { } class ConnectionManager { - private initPromise: Promise = Promise.reject(); + private initPromise!: Promise; private mapUrlStart: string|null = null; private authToken:string|null = null; From e1193ad95aa3c072ac4f45fa39f02d3d1cd637f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 1 Oct 2020 17:16:36 +0200 Subject: [PATCH 089/122] Fixing console removal --- back/src/Model/Group.ts | 3 +-- front/src/Administration/ConsoleGlobalMessageManager.ts | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/back/src/Model/Group.ts b/back/src/Model/Group.ts index 16dd6cd5..a67383f0 100644 --- a/back/src/Model/Group.ts +++ b/back/src/Model/Group.ts @@ -1,7 +1,6 @@ -import { World, ConnectCallback, DisconnectCallback } from "./World"; +import { ConnectCallback, DisconnectCallback } from "./World"; import { User } from "./User"; import {PositionInterface} from "_Model/PositionInterface"; -import {uuid} from "uuidv4"; import {Movable} from "_Model/Movable"; import {PositionNotifier} from "_Model/PositionNotifier"; diff --git a/front/src/Administration/ConsoleGlobalMessageManager.ts b/front/src/Administration/ConsoleGlobalMessageManager.ts index e60b8a3d..135f1799 100644 --- a/front/src/Administration/ConsoleGlobalMessageManager.ts +++ b/front/src/Administration/ConsoleGlobalMessageManager.ts @@ -36,10 +36,8 @@ export class ConsoleGlobalMessageManager { } initialise() { - try { - HtmlUtils.removeElementByIdOrFail(CLASS_CONSOLE_MESSAGE); - }catch (err){ - console.error(err); + for (const elem of document.getElementsByClassName(CLASS_CONSOLE_MESSAGE)) { + elem.remove(); } const typeConsole = document.createElement('input'); From 1061c80f1ff66e9a3b68d61b45e76d9f7e8ded6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 1 Oct 2020 17:16:49 +0200 Subject: [PATCH 090/122] Fixing connection closing --- front/src/Connexion/RoomConnection.ts | 5 +++++ front/src/Phaser/Game/GameScene.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/front/src/Connexion/RoomConnection.ts b/front/src/Connexion/RoomConnection.ts index 3492f0f9..a27bd323 100644 --- a/front/src/Connexion/RoomConnection.ts +++ b/front/src/Connexion/RoomConnection.ts @@ -43,6 +43,7 @@ export class RoomConnection implements RoomConnection { private userId: number|null = null; private listeners: Map = new Map(); private static websocketFactory: null|((url: string)=>any) = null; // eslint-disable-line @typescript-eslint/no-explicit-any + private closed: boolean = false; public static setWebsocketFactory(websocketFactory: (url: string)=>any): void { // eslint-disable-line @typescript-eslint/no-explicit-any RoomConnection.websocketFactory = websocketFactory; @@ -157,6 +158,7 @@ export class RoomConnection implements RoomConnection { public closeConnection(): void { this.socket?.close(); + this.closed = true; } private resolveJoinRoom!: (value?: (RoomJoinedMessageInterface | PromiseLike | undefined)) => void; @@ -389,6 +391,9 @@ export class RoomConnection implements RoomConnection { public onServerDisconnected(callback: (event: CloseEvent) => void): void { this.socket.addEventListener('close', (event) => { + if (this.closed === true) { + return; + } console.log('Socket closed with code '+event.code+". Reason: "+event.reason); if (event.code === 1000) { // Normal closure case diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index bdaf3ac6..608d920b 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -951,7 +951,7 @@ export class GameScene extends Phaser.Scene implements CenterListener { }); const nextSceneKey = this.checkToExit(); - if(nextSceneKey){ + if (nextSceneKey) { // We are completely destroying the current scene to avoid using a half-backed instance when coming back to the same map. this.connection.closeConnection(); this.simplePeer.unregister(); From 0b78eb62772129ab9df8f9e8ff97aeaa015af1be Mon Sep 17 00:00:00 2001 From: arp Date: Tue, 6 Oct 2020 15:37:00 +0200 Subject: [PATCH 091/122] temp --- back/src/Controller/AuthenticateController.ts | 18 +-- back/src/Controller/IoSocketController.ts | 136 +++++++----------- back/src/Model/{World.ts => GameRoom.ts} | 107 +------------- back/src/Model/Group.ts | 3 +- back/src/Services/AdminApi.ts | 36 +++++ back/tests/PositionNotifierTest.ts | 2 +- back/tests/WorldTest.ts | 8 +- 7 files changed, 102 insertions(+), 208 deletions(-) rename back/src/Model/{World.ts => GameRoom.ts} (68%) create mode 100644 back/src/Services/AdminApi.ts diff --git a/back/src/Controller/AuthenticateController.ts b/back/src/Controller/AuthenticateController.ts index aa27a468..7a8a95dd 100644 --- a/back/src/Controller/AuthenticateController.ts +++ b/back/src/Controller/AuthenticateController.ts @@ -3,20 +3,12 @@ import {ADMIN_API_TOKEN, ADMIN_API_URL, SECRET_KEY, URL_ROOM_STARTED} from "../E import { uuid } from 'uuidv4'; import {HttpRequest, HttpResponse, TemplatedApp} from "uWebSockets.js"; import {BaseController} from "./BaseController"; -import Axios from "axios"; +import {adminApi, AdminApiData} from "../Services/AdminApi"; export interface TokenInterface { userUuid: string } -interface AdminApiData { - organizationSlug: string - worldSlug: string - roomSlug: string - mapUrlStart: string - userUuid: string -} - export class AuthenticateController extends BaseController { constructor(private App : TemplatedApp) { @@ -51,13 +43,7 @@ export class AuthenticateController extends BaseController { let newUrl: string|null = null; if (organizationMemberToken) { - if (!ADMIN_API_URL) { - return res.status(401).send('No admin backoffice set!'); - } - //todo: this call can fail if the corresponding world is not activated or if the token is invalid. Handle that case. - const data = await Axios.get(ADMIN_API_URL+'/api/login-url/'+organizationMemberToken, - { headers: {"Authorization" : `${ADMIN_API_TOKEN}`} } - ).then((res): AdminApiData => res.data); + const data = await adminApi.fetchMemberDataByToken(organizationMemberToken); userUuid = data.userUuid; mapUrlStart = data.mapUrlStart; diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index 9696748a..1591a5f1 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -1,23 +1,14 @@ -import * as http from "http"; -import {MessageUserPosition, Point} from "../Model/Websocket/MessageUserPosition"; //TODO fix import by "_Model/.." import {ExSocketInterface} from "../Model/Websocket/ExSocketInterface"; //TODO fix import by "_Model/.." -import Jwt, {JsonWebTokenError} from "jsonwebtoken"; +import Jwt from "jsonwebtoken"; import {SECRET_KEY, MINIMUM_DISTANCE, GROUP_RADIUS, ALLOW_ARTILLERY} from "../Enum/EnvironmentVariable"; //TODO fix import by "_Enum/..." -import {World} from "../Model/World"; +import {GameRoom} from "../Model/GameRoom"; import {Group} from "../Model/Group"; import {User} from "../Model/User"; import {isSetPlayerDetailsMessage,} from "../Model/Websocket/SetPlayerDetailsMessage"; -import {MessageUserJoined} from "../Model/Websocket/MessageUserJoined"; -import si from "systeminformation"; import {Gauge} from "prom-client"; import {TokenInterface} from "../Controller/AuthenticateController"; -import {isJoinRoomMessageInterface} from "../Model/Websocket/JoinRoomMessage"; import {PointInterface} from "../Model/Websocket/PointInterface"; -import {isWebRtcSignalMessageInterface} from "../Model/Websocket/WebRtcSignalMessage"; -import {UserInGroupInterface} from "../Model/Websocket/UserInGroupInterface"; -import {isItemEventMessageInterface} from "../Model/Websocket/ItemEventMessage"; import {uuid} from 'uuidv4'; -import {GroupUpdateInterface} from "_Model/Websocket/GroupUpdateInterface"; import {Movable} from "../Model/Movable"; import { PositionMessage, @@ -42,14 +33,17 @@ import { SilentMessage, WebRtcSignalToClientMessage, WebRtcSignalToServerMessage, - WebRtcStartMessage, WebRtcDisconnectMessage, PlayGlobalMessage + WebRtcStartMessage, + WebRtcDisconnectMessage, + PlayGlobalMessage, } from "../Messages/generated/messages_pb"; import {UserMovesMessage} from "../Messages/generated/messages_pb"; import Direction = PositionMessage.Direction; import {ProtobufUtils} from "../Model/Websocket/ProtobufUtils"; -import {App, HttpRequest, TemplatedApp, WebSocket} from "uWebSockets.js" +import {HttpRequest, TemplatedApp} from "uWebSockets.js" import {parse} from "query-string"; import {cpuTracker} from "../Services/CpuTracker"; +import {adminApi} from "../Services/AdminApi"; function emitInBatch(socket: ExSocketInterface, payload: SubMessage): void { socket.batchedMessages.addPayload(payload); @@ -71,7 +65,7 @@ function emitInBatch(socket: ExSocketInterface, payload: SubMessage): void { } export class IoSocketController { - private Worlds: Map = new Map(); + private Worlds: Map = new Map(); private sockets: Map = new Map(); private nbClientsGauge: Gauge; private nbClientsPerRoomGauge: Gauge; @@ -100,32 +94,11 @@ export class IoSocketController { return true; } - /** - * - * @param token - */ -/* searchClientByToken(token: string): ExSocketInterface | null { - const clients: ExSocketInterface[] = Object.values(this.Io.sockets.sockets) as ExSocketInterface[]; - for (let i = 0; i < clients.length; i++) { - const client = clients[i]; - if (client.token !== token) { - continue - } - return client; - } - return null; - }*/ - - private async authenticate(req: HttpRequest): Promise<{ token: string, userUuid: string }> { - //console.log(socket.handshake.query.token); - - const query = parse(req.getQuery()); - - if (!query.token) { + private async getUserUuidFromToken(token: unknown): Promise { + + if (!token) { throw new Error('An authentication error happened, a user tried to connect without a token.'); } - - const token = query.token; if (typeof(token) !== "string") { throw new Error('Token is expected to be a string'); } @@ -133,22 +106,15 @@ export class IoSocketController { if(token === 'test') { if (ALLOW_ARTILLERY) { - return { - token, - userUuid: uuid() - } + return uuid(); } else { throw new Error("In order to perform a load-testing test on this environment, you must set the ALLOW_ARTILLERY environment variable to 'true'"); } } - /*if(this.searchClientByToken(socket.handshake.query.token)){ - console.error('An authentication error happened, a user tried to connect while its token is already connected.'); - return next(new Error('Authentication error')); - }*/ - - const promise = new Promise<{ token: string, userUuid: string }>((resolve, reject) => { + return new Promise((resolve, reject) => { Jwt.verify(token, SECRET_KEY, {},(err, tokenDecoded) => { + const tokenInterface = tokenDecoded as TokenInterface; if (err) { console.error('An authentication error happened, invalid JsonWebToken.', err); reject(new Error('An authentication error happened, invalid JsonWebToken. '+err.message)); @@ -159,25 +125,19 @@ export class IoSocketController { reject(new Error('Empty token found.')); return; } - const tokenInterface = tokenDecoded as TokenInterface; if (!this.isValidToken(tokenInterface)) { reject(new Error('Authentication error, invalid token structure.')); return; } - resolve({ - token, - userUuid: tokenInterface.userUuid - }); + resolve(tokenInterface.userUuid); }); }); - - return promise; } ioConnection() { - this.app.ws('/*', { + this.app.ws('/room', { /* Options */ //compression: uWS.SHARED_COMPRESSOR, @@ -197,7 +157,21 @@ export class IoSocketController { }); try { - const result = await this.authenticate(req); + const query = parse(req.getQuery()); + + const moderated = query.moderated || false; + const roomId = query.roomId || null; + const token = query.token; + + + const userUuid = await this.getUserUuidFromToken(token); + + this.handleJoinRoom(client, message.getJoinroommessage() as JoinRoomMessage); + + const isGranted = await adminApi.memberIsGrantedAccessToRoom(client.userUuid, roomId); + if (!isGranted) { + throw Error('Client cannot acces this ressource.'); + } if (upgradeAborted.aborted) { console.log("Ouch! Client disconnected before we could upgrade it!"); @@ -209,8 +183,8 @@ export class IoSocketController { res.upgrade({ // Data passed here is accessible on the "websocket" socket object. url: req.getUrl(), - token: result.token, - userUuid: result.userUuid + token, + userUuid }, /* Spell these correctly */ req.getHeader('sec-websocket-key'), @@ -250,13 +224,11 @@ export class IoSocketController { console.log(new Date().toISOString() + ' A user joined (', this.sockets.size, ' connected users)'); }, - message: (ws, arrayBuffer, isBinary) => { + message: (ws, arrayBuffer, isBinary): void => { const client = ws as ExSocketInterface; const message = ClientToServerMessage.deserializeBinary(new Uint8Array(arrayBuffer)); - if (message.hasJoinroommessage()) { - this.handleJoinRoom(client, message.getJoinroommessage() as JoinRoomMessage); - } else if (message.hasViewportmessage()) { + if (message.hasViewportmessage()) { this.handleViewport(client, message.getViewportmessage() as ViewportMessage); } else if (message.hasUsermovesmessage()) { this.handleUserMovesMessage(client, message.getUsermovesmessage() as UserMovesMessage); @@ -333,26 +305,22 @@ export class IoSocketController { console.warn(message); } - private handleJoinRoom(Client: ExSocketInterface, message: JoinRoomMessage): void { + private async handleJoinRoom(client: ExSocketInterface, message: JoinRoomMessage): Promise { try { - /*if (!isJoinRoomMessageInterface(message.toObject())) { - console.log(message.toObject()) - this.emitError(Client, 'Invalid JOIN_ROOM message received: ' + message.toObject().toString()); - return; - }*/ const roomId = message.getRoomid(); - if (Client.roomId === roomId) { + if (client.roomId === roomId) { return; } + //leave previous room //this.leaveRoom(Client); // Useless now, there is only one room per connection //join new previous room - const world = this.joinRoom(Client, roomId, ProtobufUtils.toPointInterface(message.getPosition() as PositionMessage)); + const gameRoom = await this.joinRoom(client, roomId, ProtobufUtils.toPointInterface(message.getPosition() as PositionMessage)); - const things = world.setViewport(Client, (message.getViewport() as ViewportMessage).toObject()); + const things = gameRoom.setViewport(client, (message.getViewport() as ViewportMessage).toObject()); const roomJoinedMessage = new RoomJoinedMessage(); @@ -382,7 +350,7 @@ export class IoSocketController { } } - for (const [itemId, item] of world.getItemsState().entries()) { + for (const [itemId, item] of gameRoom.getItemsState().entries()) { const itemStateMessage = new ItemStateMessage(); itemStateMessage.setItemid(itemId); itemStateMessage.setStatejson(JSON.stringify(item)); @@ -393,8 +361,8 @@ export class IoSocketController { const serverToClientMessage = new ServerToClientMessage(); serverToClientMessage.setRoomjoinedmessage(roomJoinedMessage); - if (!Client.disconnecting) { - Client.send(serverToClientMessage.serializeBinary().buffer, true); + if (!client.disconnecting) { + client.send(serverToClientMessage.serializeBinary().buffer, true); } } catch (e) { console.error('An error occurred on "join_room" event'); @@ -600,7 +568,7 @@ export class IoSocketController { if(Client.roomId){ try { //user leave previous world - const world: World | undefined = this.Worlds.get(Client.roomId); + const world: GameRoom | undefined = this.Worlds.get(Client.roomId); if (world) { world.leave(Client); if (world.isEmpty()) { @@ -616,17 +584,17 @@ export class IoSocketController { } } - private joinRoom(Client : ExSocketInterface, roomId: string, position: PointInterface): World { + private joinRoom(client : ExSocketInterface, roomId: string, position: PointInterface): GameRoom { + //join user in room - //Client.join(roomId); this.nbClientsPerRoomGauge.inc({ room: roomId }); - Client.roomId = roomId; - Client.position = position; + client.roomId = roomId; + client.position = position; //check and create new world for a room let world = this.Worlds.get(roomId) if(world === undefined){ - world = new World((user1: User, group: Group) => { + world = new GameRoom((user1: User, group: Group) => { this.joinWebRtcRoom(user1, group); }, (user1: User, group: Group) => { this.disConnectedUser(user1, group); @@ -689,10 +657,10 @@ export class IoSocketController { // Dispatch groups position to newly connected user world.getGroups().forEach((group: Group) => { - this.emitCreateUpdateGroupEvent(Client, group); + this.emitCreateUpdateGroupEvent(client, group); }); //join world - world.join(Client, Client.position); + world.join(client, client.position); return world; } @@ -882,7 +850,7 @@ export class IoSocketController { } - public getWorlds(): Map { + public getWorlds(): Map { return this.Worlds; } } diff --git a/back/src/Model/World.ts b/back/src/Model/GameRoom.ts similarity index 68% rename from back/src/Model/World.ts rename to back/src/Model/GameRoom.ts index c276d04e..1f438e61 100644 --- a/back/src/Model/World.ts +++ b/back/src/Model/GameRoom.ts @@ -1,12 +1,10 @@ -import {MessageUserPosition, Point} from "./Websocket/MessageUserPosition"; import {PointInterface} from "./Websocket/PointInterface"; import {Group} from "./Group"; -import {Distance} from "./Distance"; import {User} from "./User"; import {ExSocketInterface} from "_Model/Websocket/ExSocketInterface"; import {PositionInterface} from "_Model/PositionInterface"; import {Identificable} from "_Model/Websocket/Identificable"; -import {EntersCallback, LeavesCallback, MovesCallback, Zone} from "_Model/Zone"; +import {EntersCallback, LeavesCallback, MovesCallback} from "_Model/Zone"; import {PositionNotifier} from "./PositionNotifier"; import {ViewportInterface} from "_Model/Websocket/ViewportMessage"; import {Movable} from "_Model/Movable"; @@ -14,7 +12,7 @@ import {Movable} from "_Model/Movable"; export type ConnectCallback = (user: User, group: Group) => void; export type DisconnectCallback = (user: User, group: Group) => void; -export class World { +export class GameRoom { private readonly minDistance: number; private readonly groupRadius: number; @@ -123,7 +121,7 @@ export class World { } else { // If the user is part of a group: // should he leave the group? - const distance = World.computeDistanceBetweenPositions(user.getPosition(), user.group.getPosition()); + const distance = GameRoom.computeDistanceBetweenPositions(user.getPosition(), user.group.getPosition()); if (distance > this.groupRadius) { this.leaveGroup(user); } @@ -199,53 +197,19 @@ export class World { return; } - const distance = World.computeDistance(user, currentUser); // compute distance between peers. + const distance = GameRoom.computeDistance(user, currentUser); // compute distance between peers. if(distance <= minimumDistanceFound && distance <= this.minDistance) { minimumDistanceFound = distance; matchingItem = currentUser; } - /*if (typeof currentUser.group === 'undefined' || !currentUser.group.isFull()) { - // We found a user we can bind to. - return; - }*/ - /* - if(context.groups.length > 0) { - - context.groups.forEach(group => { - if(group.isPartOfGroup(userPosition)) { // Is the user in a group ? - if(group.isStillIn(userPosition)) { // Is the user leaving the group ? (is the user at more than max distance of each player) - - // Should we split the group? (is each player reachable from the current player?) - // This is needed if - // A <==> B <==> C <===> D - // becomes A <==> B <=====> C <> D - // If C moves right, the distance between B and C is too great and we must form 2 groups - - } - } else { - // If the user is in no group - // Is there someone in a group close enough and with room in the group ? - } - }); - - } else { - // Aucun groupe n'existe donc je stock les users assez proches de moi - let dist: Distance = { - distance: distance, - first: userPosition, - second: user // TODO: convertir en messageUserPosition - } - usersToBeGroupedWith.push(dist); - } - */ }); this.groups.forEach((group: Group) => { if (group.isFull()) { return; } - const distance = World.computeDistanceBetweenPositions(user.getPosition(), group.getPosition()); + const distance = GameRoom.computeDistanceBetweenPositions(user.getPosition(), group.getPosition()); if(distance <= minimumDistanceFound && distance <= this.groupRadius) { minimumDistanceFound = distance; matchingItem = group; @@ -275,66 +239,7 @@ export class World { return this.itemsState; } - /*getDistancesBetweenGroupUsers(group: Group): Distance[] - { - let i = 0; - let users = group.getUsers(); - let distances: Distance[] = []; - users.forEach(function(user1, key1) { - users.forEach(function(user2, key2) { - if(key1 < key2) { - distances[i] = { - distance: World.computeDistance(user1, user2), - first: user1, - second: user2 - }; - i++; - } - }); - }); - - distances.sort(World.compareDistances); - - return distances; - } - - filterGroup(distances: Distance[], group: Group): void - { - let users = group.getUsers(); - let usersToRemove = false; - let groupTmp: MessageUserPosition[] = []; - distances.forEach(dist => { - if(dist.distance <= World.MIN_DISTANCE) { - let users = [dist.first]; - let usersbis = [dist.second] - groupTmp.push(dist.first); - groupTmp.push(dist.second); - } else { - usersToRemove = true; - } - }); - - if(usersToRemove) { - // Detecte le ou les users qui se sont fait sortir du groupe - let difference = users.filter(x => !groupTmp.includes(x)); - - // TODO : Notify users un difference that they have left the group - } - - let newgroup = new Group(groupTmp); - this.groups.push(newgroup); - } - - private static compareDistances(distA: Distance, distB: Distance): number - { - if (distA.distance < distB.distance) { - return -1; - } - if (distA.distance > distB.distance) { - return 1; - } - return 0; - }*/ + setViewport(socket : Identificable, viewport: ViewportInterface): Movable[] { const user = this.users.get(socket.userId); if(typeof user === 'undefined') { diff --git a/back/src/Model/Group.ts b/back/src/Model/Group.ts index 16dd6cd5..9afa9764 100644 --- a/back/src/Model/Group.ts +++ b/back/src/Model/Group.ts @@ -1,7 +1,6 @@ -import { World, ConnectCallback, DisconnectCallback } from "./World"; +import { ConnectCallback, DisconnectCallback } from "./GameRoom"; import { User } from "./User"; import {PositionInterface} from "_Model/PositionInterface"; -import {uuid} from "uuidv4"; import {Movable} from "_Model/Movable"; import {PositionNotifier} from "_Model/PositionNotifier"; diff --git a/back/src/Services/AdminApi.ts b/back/src/Services/AdminApi.ts new file mode 100644 index 00000000..de28e4ef --- /dev/null +++ b/back/src/Services/AdminApi.ts @@ -0,0 +1,36 @@ +import {ADMIN_API_TOKEN, ADMIN_API_URL} from "../Enum/EnvironmentVariable"; +import Axios from "axios"; + +export interface AdminApiData { + organizationSlug: string + worldSlug: string + roomSlug: string + mapUrlStart: string + userUuid: string +} + +class AdminApi { + + async fetchMemberDataByToken(organizationMemberToken: string): Promise { + if (!ADMIN_API_URL) { + return Promise.reject('No admin backoffice set!'); + } + //todo: this call can fail if the corresponding world is not activated or if the token is invalid. Handle that case. + const res = await Axios.get(ADMIN_API_URL+'/api/login-url/'+organizationMemberToken, + { headers: {"Authorization" : `${ADMIN_API_TOKEN}`} } + ) + return res.data; + } + + async memberIsGrantedAccessToRoom(memberId: string, roomId: string): Promise { + if (!ADMIN_API_URL) { + return Promise.reject('No admin backoffice set!'); + } + const res = await Axios.get(ADMIN_API_URL+'/api/member/'+memberId+'/is-granted-access/'+roomId, + { headers: {"Authorization" : `${ADMIN_API_TOKEN}`} } + ) + return res.data === true; + } +} + +export const adminApi = new AdminApi(); \ No newline at end of file diff --git a/back/tests/PositionNotifierTest.ts b/back/tests/PositionNotifierTest.ts index 253283af..0f556866 100644 --- a/back/tests/PositionNotifierTest.ts +++ b/back/tests/PositionNotifierTest.ts @@ -1,5 +1,5 @@ import "jasmine"; -import {World, ConnectCallback, DisconnectCallback } from "../src/Model/World"; +import {GameRoom, ConnectCallback, DisconnectCallback } from "_Model/GameRoom"; import {Point} from "../src/Model/Websocket/MessageUserPosition"; import { Group } from "../src/Model/Group"; import {PositionNotifier} from "../src/Model/PositionNotifier"; diff --git a/back/tests/WorldTest.ts b/back/tests/WorldTest.ts index 8d3b1a2d..5ab421bb 100644 --- a/back/tests/WorldTest.ts +++ b/back/tests/WorldTest.ts @@ -1,5 +1,5 @@ import "jasmine"; -import {World, ConnectCallback, DisconnectCallback } from "../src/Model/World"; +import {GameRoom, ConnectCallback, DisconnectCallback } from "_Model/GameRoom"; import {Point} from "../src/Model/Websocket/MessageUserPosition"; import { Group } from "../src/Model/Group"; import {ExSocketInterface} from "_Model/Websocket/ExSocketInterface"; @@ -21,7 +21,7 @@ describe("World", () => { } - const world = new World(connect, disconnect, 160, 160, () => {}, () => {}, () => {}); + const world = new GameRoom(connect, disconnect, 160, 160, () => {}, () => {}, () => {}); world.join(createMockUser(1), new Point(100, 100)); @@ -48,7 +48,7 @@ describe("World", () => { } - const world = new World(connect, disconnect, 160, 160, () => {}, () => {}, () => {}); + const world = new GameRoom(connect, disconnect, 160, 160, () => {}, () => {}, () => {}); world.join(createMockUser(1), new Point(100, 100)); @@ -77,7 +77,7 @@ describe("World", () => { disconnectCallNumber++; } - const world = new World(connect, disconnect, 160, 160, () => {}, () => {}, () => {}); + const world = new GameRoom(connect, disconnect, 160, 160, () => {}, () => {}, () => {}); world.join(createMockUser(1), new Point(100, 100)); From f542b117a8686254a43841ffd7b33de6623a6f2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Tue, 6 Oct 2020 18:09:23 +0200 Subject: [PATCH 092/122] Refactoring connection to pass room info on connect --- back/src/Controller/IoSocketController.ts | 114 ++++++---- front/package.json | 2 +- front/src/Connexion/ConnectionManager.ts | 7 +- front/src/Connexion/ConnexionModels.ts | 1 + front/src/Connexion/RoomConnection.ts | 58 ++--- front/src/Phaser/Game/GameScene.ts | 255 +++++++++++----------- front/yarn.lock | 12 +- messages/messages.proto | 7 - 8 files changed, 239 insertions(+), 217 deletions(-) diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index 1591a5f1..943f949c 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -24,7 +24,6 @@ import { ItemEventMessage, ViewportMessage, ClientToServerMessage, - JoinRoomMessage, ErrorMessage, RoomJoinedMessage, ItemStateMessage, @@ -33,17 +32,17 @@ import { SilentMessage, WebRtcSignalToClientMessage, WebRtcSignalToServerMessage, - WebRtcStartMessage, - WebRtcDisconnectMessage, + WebRtcStartMessage, + WebRtcDisconnectMessage, PlayGlobalMessage, } from "../Messages/generated/messages_pb"; import {UserMovesMessage} from "../Messages/generated/messages_pb"; import Direction = PositionMessage.Direction; import {ProtobufUtils} from "../Model/Websocket/ProtobufUtils"; -import {HttpRequest, TemplatedApp} from "uWebSockets.js" +import {TemplatedApp} from "uWebSockets.js" import {parse} from "query-string"; import {cpuTracker} from "../Services/CpuTracker"; -import {adminApi} from "../Services/AdminApi"; +import {ViewportInterface} from "../Model/Websocket/ViewportMessage"; function emitInBatch(socket: ExSocketInterface, payload: SubMessage): void { socket.batchedMessages.addPayload(payload); @@ -95,7 +94,7 @@ export class IoSocketController { } private async getUserUuidFromToken(token: unknown): Promise { - + if (!token) { throw new Error('An authentication error happened, a user tried to connect without a token.'); } @@ -137,8 +136,7 @@ export class IoSocketController { } ioConnection() { - this.app.ws('/room', { - + this.app.ws('/room/*', { /* Options */ //compression: uWS.SHARED_COMPRESSOR, maxPayloadLength: 16 * 1024 * 1024, @@ -147,7 +145,6 @@ export class IoSocketController { upgrade: (res, req, context) => { //console.log('An Http connection wants to become WebSocket, URL: ' + req.getUrl() + '!'); (async () => { - /* Keep track of abortions */ const upgradeAborted = {aborted: false}; @@ -159,19 +156,32 @@ export class IoSocketController { try { const query = parse(req.getQuery()); - const moderated = query.moderated || false; - const roomId = query.roomId || null; + const roomId = req.getUrl().substr(6); + const token = query.token; + const x = Number(query.x); + const y = Number(query.y); + const top = Number(query.top); + const bottom = Number(query.bottom); + const left = Number(query.left); + const right = Number(query.right); + const name = query.name; + if (typeof name !== 'string') { + throw new Error('Expecting name'); + } + if (name === '') { + throw new Error('No empty name'); + } + let characterLayers = query.characterLayers; + if (characterLayers === null) { + throw new Error('Expecting skin'); + } + if (typeof characterLayers === 'string') { + characterLayers = [ characterLayers ]; + } const userUuid = await this.getUserUuidFromToken(token); - - this.handleJoinRoom(client, message.getJoinroommessage() as JoinRoomMessage); - - const isGranted = await adminApi.memberIsGrantedAccessToRoom(client.userUuid, roomId); - if (!isGranted) { - throw Error('Client cannot acces this ressource.'); - } if (upgradeAborted.aborted) { console.log("Ouch! Client disconnected before we could upgrade it!"); @@ -184,7 +194,22 @@ export class IoSocketController { // Data passed here is accessible on the "websocket" socket object. url: req.getUrl(), token, - userUuid + userUuid, + roomId, + name, + characterLayers, + position: { + x: x, + y: y, + direction: 'down', + moving: false + } as PointInterface, + viewport: { + top, + right, + bottom, + left + } }, /* Spell these correctly */ req.getHeader('sec-websocket-key'), @@ -217,12 +242,34 @@ export class IoSocketController { emitInBatch(client, payload); } client.disconnecting = false; + + client.name = ws.name; + client.characterLayers = ws.characterLayers; + client.roomId = ws.roomId; + this.sockets.set(client.userId, client); // Let's log server load when a user joins this.nbClientsGauge.inc(); console.log(new Date().toISOString() + ' A user joined (', this.sockets.size, ' connected users)'); + // Let's join the room + this.handleJoinRoom(client, client.roomId, client.position, client.viewport, client.name, client.characterLayers); + + /*const isGranted = await adminApi.memberIsGrantedAccessToRoom(client.userUuid, roomId); + if (!isGranted) { + throw Error('Client cannot acces this ressource.'); + }*/ + + const setUserIdMessage = new SetUserIdMessage(); + setUserIdMessage.setUserid(client.userId); + + const serverToClientMessage = new ServerToClientMessage(); + serverToClientMessage.setSetuseridmessage(setUserIdMessage); + + if (!client.disconnecting) { + client.send(serverToClientMessage.serializeBinary().buffer, true); + } }, message: (ws, arrayBuffer, isBinary): void => { const client = ws as ExSocketInterface; @@ -305,22 +352,12 @@ export class IoSocketController { console.warn(message); } - private async handleJoinRoom(client: ExSocketInterface, message: JoinRoomMessage): Promise { + private async handleJoinRoom(client: ExSocketInterface, roomId: string, position: PointInterface, viewport: ViewportInterface, name: string, characterLayers: string[]): Promise { try { - const roomId = message.getRoomid(); - - if (client.roomId === roomId) { - return; - } - - - //leave previous room - //this.leaveRoom(Client); // Useless now, there is only one room per connection - //join new previous room - const gameRoom = await this.joinRoom(client, roomId, ProtobufUtils.toPointInterface(message.getPosition() as PositionMessage)); + const gameRoom = await this.joinRoom(client, roomId, position); - const things = gameRoom.setViewport(client, (message.getViewport() as ViewportMessage).toObject()); + const things = gameRoom.setViewport(client, viewport); const roomJoinedMessage = new RoomJoinedMessage(); @@ -448,6 +485,7 @@ export class IoSocketController { } } + // Useless now, will be useful again if we allow editing details in game private handleSetPlayerDetails(client: ExSocketInterface, playerDetailsMessage: SetPlayerDetailsMessage) { const playerDetails = { name: playerDetailsMessage.getName(), @@ -461,16 +499,6 @@ export class IoSocketController { client.name = playerDetails.name; client.characterLayers = playerDetails.characterLayers; - - const setUserIdMessage = new SetUserIdMessage(); - setUserIdMessage.setUserid(client.userId); - - const serverToClientMessage = new ServerToClientMessage(); - serverToClientMessage.setSetuseridmessage(setUserIdMessage); - - if (!client.disconnecting) { - client.send(serverToClientMessage.serializeBinary().buffer, true); - } } private handleSilentMessage(client: ExSocketInterface, silentMessage: SilentMessage) { @@ -585,7 +613,7 @@ export class IoSocketController { } private joinRoom(client : ExSocketInterface, roomId: string, position: PointInterface): GameRoom { - + //join user in room this.nbClientsPerRoomGauge.inc({ room: roomId }); client.roomId = roomId; diff --git a/front/package.json b/front/package.json index c3b9f880..76e71f35 100644 --- a/front/package.json +++ b/front/package.json @@ -27,7 +27,7 @@ "google-protobuf": "^3.13.0", "phaser": "^3.22.0", "queue-typescript": "^1.0.1", - "quill": "1.3.6", + "quill": "^1.3.7", "simple-peer": "^9.6.2", "socket.io-client": "^2.3.0", "webpack-require-http": "^0.4.3" diff --git a/front/src/Connexion/ConnectionManager.ts b/front/src/Connexion/ConnectionManager.ts index 4df45099..217f9e8d 100644 --- a/front/src/Connexion/ConnectionManager.ts +++ b/front/src/Connexion/ConnectionManager.ts @@ -1,6 +1,7 @@ import Axios from "axios"; import {API_URL} from "../Enum/EnvironmentVariable"; import {RoomConnection} from "./RoomConnection"; +import {PositionInterface, ViewportInterface} from "./ConnexionModels"; interface LoginApiData { authToken: string @@ -35,9 +36,9 @@ class ConnectionManager { this.authToken = 'test'; } - public connectToRoomSocket(): Promise { + public connectToRoomSocket(roomId: string, name: string, characterLayers: string[], position: PositionInterface, viewport: ViewportInterface): Promise { return new Promise((resolve, reject) => { - const connection = new RoomConnection(this.authToken as string); + const connection = new RoomConnection(this.authToken as string, roomId, name, characterLayers, position, viewport); connection.onConnectError((error: object) => { console.log('An error occurred while connecting to socket server. Retrying'); reject(error); @@ -50,7 +51,7 @@ class ConnectionManager { return new Promise((resolve, reject) => { setTimeout(() => { //todo: allow a way to break recurrsion? - this.connectToRoomSocket().then((connection) => resolve(connection)); + this.connectToRoomSocket(roomId, name, characterLayers, position, viewport).then((connection) => resolve(connection)); }, 4000 + Math.floor(Math.random() * 2000) ); }); }); diff --git a/front/src/Connexion/ConnexionModels.ts b/front/src/Connexion/ConnexionModels.ts index 4ec76198..3df32331 100644 --- a/front/src/Connexion/ConnexionModels.ts +++ b/front/src/Connexion/ConnexionModels.ts @@ -6,6 +6,7 @@ export enum EventMessage{ WEBRTC_SIGNAL = "webrtc-signal", WEBRTC_SCREEN_SHARING_SIGNAL = "webrtc-screen-sharing-signal", WEBRTC_START = "webrtc-start", + START_ROOM = "start-room", // From server to client: list of all room users/groups/items JOIN_ROOM = "join-room", // bi-directional USER_POSITION = "user-position", // From client to server USER_MOVED = "user-moved", // From server to client diff --git a/front/src/Connexion/RoomConnection.ts b/front/src/Connexion/RoomConnection.ts index 3492f0f9..8799f977 100644 --- a/front/src/Connexion/RoomConnection.ts +++ b/front/src/Connexion/RoomConnection.ts @@ -6,7 +6,7 @@ import { GroupDeleteMessage, GroupUpdateMessage, ItemEventMessage, - JoinRoomMessage, PlayGlobalMessage, + PlayGlobalMessage, PositionMessage, RoomJoinedMessage, ServerToClientMessage, @@ -30,7 +30,7 @@ import {ProtobufClientUtils} from "../Network/ProtobufClientUtils"; import { EventMessage, GroupCreatedUpdatedMessageInterface, ItemEventMessageInterface, - MessageUserJoined, PlayGlobalMessageInterface, + MessageUserJoined, PlayGlobalMessageInterface, PositionInterface, RoomJoinedMessageInterface, ViewportInterface, WebRtcDisconnectMessageInterface, WebRtcSignalReceivedMessageInterface, @@ -48,9 +48,25 @@ export class RoomConnection implements RoomConnection { RoomConnection.websocketFactory = websocketFactory; } - public constructor(token: string) { + /** + * + * @param token A JWT token containing the UUID of the user + * @param roomId The ID of the room in the form "_/[instance]/[map_url]" or "@/[org]/[event]/[map]" + */ + public constructor(token: string, roomId: string, name: string, characterLayers: string[], position: PositionInterface, viewport: ViewportInterface) { let url = API_URL.replace('http://', 'ws://').replace('https://', 'wss://'); - url += '?token='+token; + url += '/room/'+roomId + url += '?token='+encodeURIComponent(token); + url += '&name='+encodeURIComponent(name); + for (let layer of characterLayers) { + url += '&characterLayers='+encodeURIComponent(layer); + } + url += '&x='+Math.floor(position.x); + url += '&y='+Math.floor(position.y); + url += '&top='+Math.floor(viewport.top); + url += '&bottom='+Math.floor(viewport.bottom); + url += '&left='+Math.floor(viewport.left); + url += '&right='+Math.floor(viewport.right); if (RoomConnection.websocketFactory) { this.socket = RoomConnection.websocketFactory(url); @@ -106,11 +122,11 @@ export class RoomConnection implements RoomConnection { items[item.getItemid()] = JSON.parse(item.getStatejson()); } - this.resolveJoinRoom({ + this.dispatch(EventMessage.START_ROOM, { users, groups, items - }) + }); } else if (message.hasSetuseridmessage()) { this.userId = (message.getSetuseridmessage() as SetUserIdMessage).getUserid(); } else if (message.hasErrormessage()) { @@ -159,29 +175,6 @@ export class RoomConnection implements RoomConnection { this.socket?.close(); } - private resolveJoinRoom!: (value?: (RoomJoinedMessageInterface | PromiseLike | undefined)) => void; - - public joinARoom(roomId: string, startX: number, startY: number, direction: string, moving: boolean, viewport: ViewportInterface): Promise { - const promise = new Promise((resolve, reject) => { - this.resolveJoinRoom = resolve; - - const positionMessage = this.toPositionMessage(startX, startY, direction, moving); - const viewportMessage = this.toViewportMessage(viewport); - - const joinRoomMessage = new JoinRoomMessage(); - joinRoomMessage.setRoomid(roomId); - joinRoomMessage.setPosition(positionMessage); - joinRoomMessage.setViewport(viewportMessage); - - //console.log('Sending position ', positionMessage.getX(), positionMessage.getY()); - const clientToServerMessage = new ClientToServerMessage(); - clientToServerMessage.setJoinroommessage(joinRoomMessage); - - this.socket.send(clientToServerMessage.serializeBinary().buffer); - }) - return promise; - } - private toPositionMessage(x : number, y : number, direction : string, moving: boolean): PositionMessage { const positionMessage = new PositionMessage(); positionMessage.setX(Math.floor(x)); @@ -337,6 +330,13 @@ export class RoomConnection implements RoomConnection { this.socket.addEventListener('open', callback) } + /** + * Triggered when we receive all the details of a room (users, groups, ...) + */ + public onStartRoom(callback: (event: RoomJoinedMessageInterface) => void): void { + this.onMessage(EventMessage.START_ROOM, callback); + } + public sendWebrtcSignal(signal: unknown, receiverId: number) { const webRtcSignal = new WebRtcSignalToServerMessage(); webRtcSignal.setReceiverid(receiverId); diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index bdaf3ac6..b3a5f104 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -107,7 +107,6 @@ export class GameScene extends Phaser.Scene implements CenterListener { private simplePeer!: SimplePeer; private GlobalMessageManager!: GlobalMessageManager; private ConsoleGlobalMessageManager!: ConsoleGlobalMessageManager; - private connectionPromise!: Promise private connectionAnswerPromise: Promise; private connectionAnswerPromiseResolve!: (value?: RoomJoinedMessageInterface | PromiseLike) => void; // A promise that will resolve when the "create" method is called (signaling loading is ended) @@ -206,106 +205,6 @@ export class GameScene extends Phaser.Scene implements CenterListener { loadAllLayers(this.load); this.load.bitmapFont('main_font', 'resources/fonts/arcade.png', 'resources/fonts/arcade.xml'); - - this.connectionPromise = connectionManager.connectToRoomSocket().then((connection : RoomConnection) => { - this.connection = connection; - - this.connection.emitPlayerDetailsMessage(gameManager.getPlayerName(), gameManager.getCharacterSelected()) - - connection.onUserJoins((message: MessageUserJoined) => { - const userMessage: AddPlayerInterface = { - userId: message.userId, - characterLayers: message.characterLayers, - name: message.name, - position: message.position - } - this.addPlayer(userMessage); - }); - - connection.onUserMoved((message: UserMovedMessage) => { - const position = message.getPosition(); - if (position === undefined) { - throw new Error('Position missing from UserMovedMessage'); - } - //console.log('Received position ', position.getX(), position.getY(), "from user", message.getUserid()); - - const messageUserMoved: MessageUserMovedInterface = { - userId: message.getUserid(), - position: ProtobufClientUtils.toPointInterface(position) - } - - this.updatePlayerPosition(messageUserMoved); - }); - - connection.onUserLeft((userId: number) => { - this.removePlayer(userId); - }); - - connection.onGroupUpdatedOrCreated((groupPositionMessage: GroupCreatedUpdatedMessageInterface) => { - this.shareGroupPosition(groupPositionMessage); - }) - - connection.onGroupDeleted((groupId: number) => { - try { - this.deleteGroup(groupId); - } catch (e) { - console.error(e); - } - }) - - connection.onServerDisconnected(() => { - console.log('Player disconnected from server. Reloading scene.'); - - this.simplePeer.closeAllConnections(); - this.simplePeer.unregister(); - - const key = 'somekey'+Math.round(Math.random()*10000); - const game : Phaser.Scene = GameScene.createFromUrl(this.MapUrlFile, this.instance, key); - this.scene.add(key, game, true, - { - initPosition: { - x: this.CurrentPlayer.x, - y: this.CurrentPlayer.y - } - }); - - this.scene.stop(this.scene.key); - this.scene.remove(this.scene.key); - window.removeEventListener('resize', this.onResizeCallback); - }) - - connection.onActionableEvent((message => { - const item = this.actionableItems.get(message.itemId); - if (item === undefined) { - console.warn('Received an event about object "'+message.itemId+'" but cannot find this item on the map.'); - return; - } - item.fire(message.event, message.state, message.parameters); - })); - - // When connection is performed, let's connect SimplePeer - this.simplePeer = new SimplePeer(this.connection); - this.GlobalMessageManager = new GlobalMessageManager(this.connection); - - const self = this; - this.simplePeer.registerPeerConnectionListener({ - onConnect(user: UserSimplePeerInterface) { - self.presentationModeSprite.setVisible(true); - self.chatModeSprite.setVisible(true); - }, - onDisconnect(userId: number) { - if (self.simplePeer.getNbConnections() === 0) { - self.presentationModeSprite.setVisible(false); - self.chatModeSprite.setVisible(false); - } - } - }) - - this.scene.wake(); - this.scene.sleep(ReconnectingSceneName); - - return connection; - }); } // FIXME: we need to put a "unknown" instead of a "any" and validate the structure of the JSON we are receiving. @@ -617,6 +516,133 @@ export class GameScene extends Phaser.Scene implements CenterListener { this.connection.setSilent(true); } }); + + const camera = this.cameras.main; + + connectionManager.connectToRoomSocket( + this.RoomId, + gameManager.getPlayerName(), + gameManager.getCharacterSelected(), + { + x: this.startX, + y: this.startY + }, + { + left: camera.scrollX, + top: camera.scrollY, + right: camera.scrollX + camera.width, + bottom: camera.scrollY + camera.height, + }).then((connection : RoomConnection) => { + this.connection = connection; + + //this.connection.emitPlayerDetailsMessage(gameManager.getPlayerName(), gameManager.getCharacterSelected()) + connection.onStartRoom((roomJoinedMessage: RoomJoinedMessageInterface) => { + this.initUsersPosition(roomJoinedMessage.users); + this.connectionAnswerPromiseResolve(roomJoinedMessage); + }); + + connection.onUserJoins((message: MessageUserJoined) => { + const userMessage: AddPlayerInterface = { + userId: message.userId, + characterLayers: message.characterLayers, + name: message.name, + position: message.position + } + this.addPlayer(userMessage); + }); + + connection.onUserMoved((message: UserMovedMessage) => { + const position = message.getPosition(); + if (position === undefined) { + throw new Error('Position missing from UserMovedMessage'); + } + //console.log('Received position ', position.getX(), position.getY(), "from user", message.getUserid()); + + const messageUserMoved: MessageUserMovedInterface = { + userId: message.getUserid(), + position: ProtobufClientUtils.toPointInterface(position) + } + + this.updatePlayerPosition(messageUserMoved); + }); + + connection.onUserLeft((userId: number) => { + this.removePlayer(userId); + }); + + connection.onGroupUpdatedOrCreated((groupPositionMessage: GroupCreatedUpdatedMessageInterface) => { + this.shareGroupPosition(groupPositionMessage); + }) + + connection.onGroupDeleted((groupId: number) => { + try { + this.deleteGroup(groupId); + } catch (e) { + console.error(e); + } + }) + + connection.onServerDisconnected(() => { + console.log('Player disconnected from server. Reloading scene.'); + + this.simplePeer.closeAllConnections(); + this.simplePeer.unregister(); + + const key = 'somekey'+Math.round(Math.random()*10000); + const game : Phaser.Scene = GameScene.createFromUrl(this.MapUrlFile, this.instance, key); + this.scene.add(key, game, true, + { + initPosition: { + x: this.CurrentPlayer.x, + y: this.CurrentPlayer.y + } + }); + + this.scene.stop(this.scene.key); + this.scene.remove(this.scene.key); + window.removeEventListener('resize', this.onResizeCallback); + }) + + connection.onActionableEvent((message => { + const item = this.actionableItems.get(message.itemId); + if (item === undefined) { + console.warn('Received an event about object "'+message.itemId+'" but cannot find this item on the map.'); + return; + } + item.fire(message.event, message.state, message.parameters); + })); + + // When connection is performed, let's connect SimplePeer + this.simplePeer = new SimplePeer(this.connection); + this.GlobalMessageManager = new GlobalMessageManager(this.connection); + + const self = this; + this.simplePeer.registerPeerConnectionListener({ + onConnect(user: UserSimplePeerInterface) { + self.presentationModeSprite.setVisible(true); + self.chatModeSprite.setVisible(true); + }, + onDisconnect(userId: number) { + if (self.simplePeer.getNbConnections() === 0) { + self.presentationModeSprite.setVisible(false); + self.chatModeSprite.setVisible(false); + } + } + }) + + //listen event to share position of user + this.CurrentPlayer.on(hasMovedEventName, this.pushPlayerPosition.bind(this)) + this.CurrentPlayer.on(hasMovedEventName, this.outlineItem.bind(this)) + this.CurrentPlayer.on(hasMovedEventName, (event: HasMovedEvent) => { + this.gameMap.setPosition(event.x, event.y); + }) + + + this.scene.wake(); + this.scene.sleep(ReconnectingSceneName); + + return connection; + }); } private switchLayoutMode(): void { @@ -787,32 +813,6 @@ export class GameScene extends Phaser.Scene implements CenterListener { //create collision this.createCollisionWithPlayer(); this.createCollisionObject(); - - //join room - this.connectionPromise.then((connection: RoomConnection) => { - const camera = this.cameras.main; - connection.joinARoom(this.RoomId, - this.startX, - this.startY, - PlayerAnimationNames.WalkDown, - false, { - left: camera.scrollX, - top: camera.scrollY, - right: camera.scrollX + camera.width, - bottom: camera.scrollY + camera.height, - }).then((roomJoinedMessage: RoomJoinedMessageInterface) => { - this.initUsersPosition(roomJoinedMessage.users); - this.connectionAnswerPromiseResolve(roomJoinedMessage); - }); - // FIXME: weirdly enough we don't use the result of joinARoom !!!!!! - - //listen event to share position of user - this.CurrentPlayer.on(hasMovedEventName, this.pushPlayerPosition.bind(this)) - this.CurrentPlayer.on(hasMovedEventName, this.outlineItem.bind(this)) - this.CurrentPlayer.on(hasMovedEventName, (event: HasMovedEvent) => { - this.gameMap.setPosition(event.x, event.y); - }) - }); } pushPlayerPosition(event: HasMovedEvent) { @@ -983,7 +983,6 @@ export class GameScene extends Phaser.Scene implements CenterListener { type: "InitUserPositionEvent", event: usersPosition }); - } /** diff --git a/front/yarn.lock b/front/yarn.lock index c014d18d..5d235a82 100644 --- a/front/yarn.lock +++ b/front/yarn.lock @@ -1893,7 +1893,7 @@ extend-shallow@^3.0.0, extend-shallow@^3.0.2: assign-symbols "^1.0.0" is-extendable "^1.0.1" -extend@^3.0.1, extend@^3.0.2: +extend@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g== @@ -3871,15 +3871,15 @@ quill-delta@^3.6.2: extend "^3.0.2" fast-diff "1.1.2" -quill@1.3.6: - version "1.3.6" - resolved "https://registry.yarnpkg.com/quill/-/quill-1.3.6.tgz#99f4de1fee85925a0d7d4163b6d8328f23317a4d" - integrity sha512-K0mvhimWZN6s+9OQ249CH2IEPZ9JmkFuCQeHAOQax3EZ2nDJ3wfGh59mnlQaZV2i7u8eFarx6wAtvQKgShojug== +quill@^1.3.7: + version "1.3.7" + resolved "https://registry.yarnpkg.com/quill/-/quill-1.3.7.tgz#da5b2f3a2c470e932340cdbf3668c9f21f9286e8" + integrity sha512-hG/DVzh/TiknWtE6QmWAF/pxoZKYxfe3J/d/+ShUWkDvvkZQVTPeVmUJVu1uE6DDooC4fWTiCLh84ul89oNz5g== dependencies: clone "^2.1.1" deep-equal "^1.0.1" eventemitter3 "^2.0.3" - extend "^3.0.1" + extend "^3.0.2" parchment "^1.1.4" quill-delta "^3.6.2" diff --git a/messages/messages.proto b/messages/messages.proto index 87cf2231..63c3ddaf 100644 --- a/messages/messages.proto +++ b/messages/messages.proto @@ -38,12 +38,6 @@ message SetPlayerDetailsMessage { repeated string characterLayers = 2; } -message JoinRoomMessage { - string roomId = 1; - PositionMessage position = 2; - ViewportMessage viewport = 3; -} - message UserMovesMessage { PositionMessage position = 1; ViewportMessage viewport = 2; @@ -56,7 +50,6 @@ message WebRtcSignalToServerMessage { message ClientToServerMessage { oneof message { - JoinRoomMessage joinRoomMessage = 1; UserMovesMessage userMovesMessage = 2; SilentMessage silentMessage = 3; ViewportMessage viewportMessage = 4; From 79b5c5de93cd5e9e3d47da2403dd29638514b5ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 7 Oct 2020 18:03:34 +0200 Subject: [PATCH 093/122] Making login scene responsive --- front/src/Phaser/Components/TextInput.ts | 12 ++++++++++++ front/src/Phaser/Login/LoginScene.ts | 23 +++++++++++++++++------ front/src/Phaser/Login/ResizableScene.ts | 5 +++++ front/src/index.ts | 8 ++++++++ 4 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 front/src/Phaser/Login/ResizableScene.ts diff --git a/front/src/Phaser/Components/TextInput.ts b/front/src/Phaser/Components/TextInput.ts index 7a549d1f..47f713e0 100644 --- a/front/src/Phaser/Components/TextInput.ts +++ b/front/src/Phaser/Components/TextInput.ts @@ -38,4 +38,16 @@ export class TextInput extends Phaser.GameObjects.BitmapText { getText(): string { return this.text; } + + setX(x: number): this { + super.setX(x); + this.underLine.x = x; + return this; + } + + setY(y: number): this { + super.setY(y); + this.underLine.y = y+1; + return this; + } } diff --git a/front/src/Phaser/Login/LoginScene.ts b/front/src/Phaser/Login/LoginScene.ts index 308ba3ae..6e6bf291 100644 --- a/front/src/Phaser/Login/LoginScene.ts +++ b/front/src/Phaser/Login/LoginScene.ts @@ -7,6 +7,7 @@ import Rectangle = Phaser.GameObjects.Rectangle; import {PLAYER_RESOURCES, PlayerResourceDescriptionInterface} from "../Entity/Character"; import {cypressAsserter} from "../../Cypress/CypressAsserter"; import {SelectCharacterSceneName} from "./SelectCharacterScene"; +import {ResizableScene} from "./ResizableScene"; //todo: put this constants in a dedicated file export const LoginSceneName = "LoginScene"; @@ -15,12 +16,12 @@ enum LoginTextures { mainFont = "main_font" } -export class LoginScene extends Phaser.Scene { - private nameInput: TextInput|null = null; - private textField: TextField|null = null; - private infoTextField: TextField|null = null; - private pressReturnField: TextField|null = null; - private logo: Image|null = null; +export class LoginScene extends ResizableScene { + private nameInput!: TextInput; + private textField!: TextField; + private infoTextField!: TextField; + private pressReturnField!: TextField; + private logo!: Image; private name: string = ''; constructor() { @@ -93,4 +94,14 @@ export class LoginScene extends Phaser.Scene { this.scene.start(SelectCharacterSceneName); } + + public onResize(ev: UIEvent): void { + this.textField.x = this.game.renderer.width / 2; + this.nameInput.setX(this.game.renderer.width / 2 - 64); + this.pressReturnField.x = this.game.renderer.width / 2; + this.logo.x = this.game.renderer.width - 30; + this.logo.y = this.game.renderer.height - 20; + this.infoTextField.y = this.game.renderer.height - 35; + } + } diff --git a/front/src/Phaser/Login/ResizableScene.ts b/front/src/Phaser/Login/ResizableScene.ts new file mode 100644 index 00000000..82123e2b --- /dev/null +++ b/front/src/Phaser/Login/ResizableScene.ts @@ -0,0 +1,5 @@ +import {Scene} from "phaser"; + +export abstract class ResizableScene extends Scene { + public abstract onResize(ev: UIEvent): void; +} diff --git a/front/src/index.ts b/front/src/index.ts index 8e235c7a..177c56c0 100644 --- a/front/src/index.ts +++ b/front/src/index.ts @@ -12,6 +12,7 @@ import {OutlinePipeline} from "./Phaser/Shaders/OutlinePipeline"; import {CustomizeScene} from "./Phaser/Login/CustomizeScene"; import {CoWebsiteManager} from "./WebRtc/CoWebsiteManager"; import {connectionManager} from "./Connexion/ConnectionManager"; +import {ResizableScene} from "./Phaser/Login/ResizableScene"; //CoWebsiteManager.loadCoWebsite('https://thecodingmachine.com'); connectionManager.init(); @@ -55,6 +56,13 @@ window.addEventListener('resize', function (event) { const {width, height} = CoWebsiteManager.getGameSize(); game.scale.resize(width / RESOLUTION, height / RESOLUTION); + + // Let's trigger the onResize method of any active scene that is a ResizableScene + for (const scene of game.scene.getScenes(true)) { + if (scene instanceof ResizableScene) { + scene.onResize(event); + } + } }); CoWebsiteManager.onStateChange(() => { const {width, height} = CoWebsiteManager.getGameSize(); From 5ac208399507c63499f1fdfde101c6e3f9831872 Mon Sep 17 00:00:00 2001 From: arp Date: Thu, 8 Oct 2020 11:48:49 +0200 Subject: [PATCH 094/122] updated quill in front to 1.3.7 --- front/package.json | 2 +- front/yarn.lock | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/front/package.json b/front/package.json index c3b9f880..4892eba1 100644 --- a/front/package.json +++ b/front/package.json @@ -27,7 +27,7 @@ "google-protobuf": "^3.13.0", "phaser": "^3.22.0", "queue-typescript": "^1.0.1", - "quill": "1.3.6", + "quill": "1.3.7", "simple-peer": "^9.6.2", "socket.io-client": "^2.3.0", "webpack-require-http": "^0.4.3" diff --git a/front/yarn.lock b/front/yarn.lock index c014d18d..933a02b4 100644 --- a/front/yarn.lock +++ b/front/yarn.lock @@ -1893,7 +1893,7 @@ extend-shallow@^3.0.0, extend-shallow@^3.0.2: assign-symbols "^1.0.0" is-extendable "^1.0.1" -extend@^3.0.1, extend@^3.0.2: +extend@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g== @@ -3871,15 +3871,15 @@ quill-delta@^3.6.2: extend "^3.0.2" fast-diff "1.1.2" -quill@1.3.6: - version "1.3.6" - resolved "https://registry.yarnpkg.com/quill/-/quill-1.3.6.tgz#99f4de1fee85925a0d7d4163b6d8328f23317a4d" - integrity sha512-K0mvhimWZN6s+9OQ249CH2IEPZ9JmkFuCQeHAOQax3EZ2nDJ3wfGh59mnlQaZV2i7u8eFarx6wAtvQKgShojug== +quill@1.3.7: + version "1.3.7" + resolved "https://registry.yarnpkg.com/quill/-/quill-1.3.7.tgz#da5b2f3a2c470e932340cdbf3668c9f21f9286e8" + integrity sha512-hG/DVzh/TiknWtE6QmWAF/pxoZKYxfe3J/d/+ShUWkDvvkZQVTPeVmUJVu1uE6DDooC4fWTiCLh84ul89oNz5g== dependencies: clone "^2.1.1" deep-equal "^1.0.1" eventemitter3 "^2.0.3" - extend "^3.0.1" + extend "^3.0.2" parchment "^1.1.4" quill-delta "^3.6.2" From 78e7f481d559207046b7aa07ec0984557cb4c45c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 8 Oct 2020 10:04:29 +0000 Subject: [PATCH 095/122] Bump elliptic from 6.4.1 to 6.5.3 in /website Bumps [elliptic](https://github.com/indutny/elliptic) from 6.4.1 to 6.5.3. - [Release notes](https://github.com/indutny/elliptic/releases) - [Commits](https://github.com/indutny/elliptic/compare/v6.4.1...v6.5.3) Signed-off-by: dependabot[bot] --- website/package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/website/package-lock.json b/website/package-lock.json index 96ba750a..aec58f00 100644 --- a/website/package-lock.json +++ b/website/package-lock.json @@ -2287,9 +2287,9 @@ "dev": true }, "elliptic": { - "version": "6.4.1", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.1.tgz", - "integrity": "sha512-BsXLz5sqX8OHcsh7CqBMztyXARmGQ3LWPtGjJi6DiJHq5C/qvi9P3OqgswKSDftbu8+IoI/QDTAm2fFnQ9SZSQ==", + "version": "6.5.3", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.3.tgz", + "integrity": "sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw==", "dev": true, "requires": { "bn.js": "^4.4.0", From 607b495644d054460efe592a8918fb0a7cfaf94c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 8 Oct 2020 10:04:31 +0000 Subject: [PATCH 096/122] Bump lodash from 4.17.15 to 4.17.20 in /website Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.20. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.20) Signed-off-by: dependabot[bot] --- website/package-lock.json | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/website/package-lock.json b/website/package-lock.json index 96ba750a..5d2a4c71 100644 --- a/website/package-lock.json +++ b/website/package-lock.json @@ -3487,13 +3487,6 @@ "glob": "~7.1.1", "lodash": "~4.17.12", "minimatch": "~3.0.2" - }, - "dependencies": { - "lodash": { - "version": "4.17.15", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" - } } }, "graceful-fs": { @@ -4234,9 +4227,9 @@ } }, "lodash": { - "version": "4.17.15", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" + "version": "4.17.20", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", + "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==" }, "lodash.get": { "version": "4.4.2", @@ -4721,11 +4714,6 @@ "which": "^1.2.9" } }, - "lodash": { - "version": "4.17.15", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" - }, "lru-cache": { "version": "4.1.5", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", From 66f33458617a99a51848731f4cd7695beb535a9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 8 Oct 2020 15:10:46 +0200 Subject: [PATCH 097/122] Adding responsive to SelectCharacterScene --- .../src/Phaser/Login/SelectCharacterScene.ts | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/front/src/Phaser/Login/SelectCharacterScene.ts b/front/src/Phaser/Login/SelectCharacterScene.ts index 8d3c7ab1..71b433b3 100644 --- a/front/src/Phaser/Login/SelectCharacterScene.ts +++ b/front/src/Phaser/Login/SelectCharacterScene.ts @@ -5,6 +5,7 @@ import Rectangle = Phaser.GameObjects.Rectangle; import {PLAYER_RESOURCES, PlayerResourceDescriptionInterface} from "../Entity/Character"; import {EnableCameraSceneName} from "./EnableCameraScene"; import {CustomizeSceneName} from "./CustomizeScene"; +import {ResizableScene} from "./ResizableScene"; //todo: put this constants in a dedicated file @@ -17,7 +18,7 @@ enum LoginTextures { customizeButtonSelected = "customize_button_selected" } -export class SelectCharacterScene extends Phaser.Scene { +export class SelectCharacterScene extends ResizableScene { private readonly nbCharactersPerRow = 4; private textField!: TextField; private pressReturnField!: TextField; @@ -242,4 +243,25 @@ export class SelectCharacterScene extends Phaser.Scene { window.localStorage.setItem('selectedPlayer', String(playerNumber)); } } + + public onResize(ev: UIEvent): void { + this.textField.x = this.game.renderer.width / 2; + this.pressReturnField.x = this.game.renderer.width / 2; + this.logo.x = this.game.renderer.width - 30; + this.logo.y = this.game.renderer.height - 20; + this.customizeButton.x = this.game.renderer.width / 2; + + for (let i = 0; i Date: Thu, 8 Oct 2020 16:00:29 +0200 Subject: [PATCH 098/122] Switching customizeScene and gameScene to new ResizableScene --- front/src/Phaser/Game/GameScene.ts | 10 +++------- front/src/Phaser/Login/CustomizeScene.ts | 11 +++-------- front/src/Phaser/Login/SelectCharacterScene.ts | 1 + 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 608d920b..f3381d5f 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -45,6 +45,7 @@ import {connectionManager} from "../../Connexion/ConnectionManager"; import {RoomConnection} from "../../Connexion/RoomConnection"; import {GlobalMessageManager} from "../../Administration/GlobalMessageManager"; import {ConsoleGlobalMessageManager} from "../../Administration/ConsoleGlobalMessageManager"; +import {ResizableScene} from "../Login/ResizableScene"; export enum Textures { @@ -86,7 +87,7 @@ interface DeleteGroupEventInterface { groupId: number } -export class GameScene extends Phaser.Scene implements CenterListener { +export class GameScene extends ResizableScene implements CenterListener { GameManager : GameManager; Terrains : Array; CurrentPlayer!: CurrentGamerInterface; @@ -132,7 +133,6 @@ export class GameScene extends Phaser.Scene implements CenterListener { private startLayerName: string|undefined; private presentationModeSprite!: Sprite; private chatModeSprite!: Sprite; - private onResizeCallback!: (this: Window, ev: UIEvent) => void; private gameMap!: GameMap; private actionableItems: Map = new Map(); // The item that can be selected by pressing the space key. @@ -271,7 +271,6 @@ export class GameScene extends Phaser.Scene implements CenterListener { this.scene.stop(this.scene.key); this.scene.remove(this.scene.key); - window.removeEventListener('resize', this.onResizeCallback); }) connection.onActionableEvent((message => { @@ -565,8 +564,6 @@ export class GameScene extends Phaser.Scene implements CenterListener { this.switchLayoutMode(); }); - this.onResizeCallback = this.onResize.bind(this); - window.addEventListener('resize', this.onResizeCallback); this.reposition(); // From now, this game scene will be notified of reposition events @@ -957,7 +954,6 @@ export class GameScene extends Phaser.Scene implements CenterListener { this.simplePeer.unregister(); this.scene.stop(); this.scene.remove(this.scene.key); - window.removeEventListener('resize', this.onResizeCallback); this.scene.start(nextSceneKey.key, { startLayerName: nextSceneKey.hash }); @@ -1156,7 +1152,7 @@ export class GameScene extends Phaser.Scene implements CenterListener { this.connection.emitActionableEvent(itemId, eventName, state, parameters); } - private onResize(): void { + public onResize(): void { this.reposition(); // Send new viewport to server diff --git a/front/src/Phaser/Login/CustomizeScene.ts b/front/src/Phaser/Login/CustomizeScene.ts index 50834bd1..4ada5026 100644 --- a/front/src/Phaser/Login/CustomizeScene.ts +++ b/front/src/Phaser/Login/CustomizeScene.ts @@ -6,6 +6,7 @@ import {LAYERS, loadAllLayers} from "../Entity/body_character"; import Sprite = Phaser.GameObjects.Sprite; import Container = Phaser.GameObjects.Container; import {gameManager} from "../Game/GameManager"; +import {ResizableScene} from "./ResizableScene"; export const CustomizeSceneName = "CustomizeScene"; @@ -16,7 +17,7 @@ enum CustomizeTextures{ arrowUp = "arrow_up", } -export class CustomizeScene extends Phaser.Scene { +export class CustomizeScene extends ResizableScene { private textField!: TextField; private enterField!: TextField; @@ -35,8 +36,6 @@ export class CustomizeScene extends Phaser.Scene { private containersRow: Array> = new Array>(); private activeRow = 0; - private repositionCallback!: (this: Window, ev: UIEvent) => void; - constructor() { super({ key: CustomizeSceneName @@ -144,10 +143,6 @@ export class CustomizeScene extends Phaser.Scene { this.moveLayers(); } }); - - this.repositionCallback = this.reposition.bind(this); - window.addEventListener('resize', this.repositionCallback); - } update(time: number, delta: number): void { super.update(time, delta); @@ -249,7 +244,7 @@ export class CustomizeScene extends Phaser.Scene { } } - private reposition() { + public onResize(): void { this.moveLayers(); this.Rectangle.x = this.cameras.main.worldView.x + this.cameras.main.width / 2; diff --git a/front/src/Phaser/Login/SelectCharacterScene.ts b/front/src/Phaser/Login/SelectCharacterScene.ts index 71b433b3..e5df0a0d 100644 --- a/front/src/Phaser/Login/SelectCharacterScene.ts +++ b/front/src/Phaser/Login/SelectCharacterScene.ts @@ -250,6 +250,7 @@ export class SelectCharacterScene extends ResizableScene { this.logo.x = this.game.renderer.width - 30; this.logo.y = this.game.renderer.height - 20; this.customizeButton.x = this.game.renderer.width / 2; + this.customizeButtonSelected.x = this.game.renderer.width / 2; for (let i = 0; i Date: Thu, 8 Oct 2020 18:51:24 +0200 Subject: [PATCH 099/122] simplified mapUrl parsing --- back/src/Controller/AuthenticateController.ts | 7 +- front/src/Connexion/ConnectionManager.ts | 14 +++- .../src/Phaser/Entity/GameSceneDescriptor.ts | 6 ++ front/src/Phaser/Game/GameManager.ts | 66 +++++++++++++++---- front/src/Phaser/Game/GameScene.ts | 27 ++++---- front/src/Phaser/Login/EnableCameraScene.ts | 46 ++----------- 6 files changed, 93 insertions(+), 73 deletions(-) create mode 100644 front/src/Phaser/Entity/GameSceneDescriptor.ts diff --git a/back/src/Controller/AuthenticateController.ts b/back/src/Controller/AuthenticateController.ts index 7a8a95dd..a178b530 100644 --- a/back/src/Controller/AuthenticateController.ts +++ b/back/src/Controller/AuthenticateController.ts @@ -36,6 +36,7 @@ export class AuthenticateController extends BaseController { //todo: what to do if the organizationMemberToken is already used? const organizationMemberToken:string|null = param.organizationMemberToken; + const mapSlug:string|null = param.mapSlug; try { let userUuid; @@ -48,10 +49,14 @@ export class AuthenticateController extends BaseController { userUuid = data.userUuid; mapUrlStart = data.mapUrlStart; newUrl = this.getNewUrlOnAdminAuth(data) + } else if (mapSlug !== null) { + userUuid = uuid(); + mapUrlStart = mapSlug; + newUrl = null; } else { userUuid = uuid(); mapUrlStart = host.replace('api.', 'maps.') + URL_ROOM_STARTED; - newUrl = null; + newUrl = '_/global/'+mapUrlStart; } const authToken = Jwt.sign({userUuid: userUuid}, SECRET_KEY, {expiresIn: '24h'}); diff --git a/front/src/Connexion/ConnectionManager.ts b/front/src/Connexion/ConnectionManager.ts index 217f9e8d..a9d15dd9 100644 --- a/front/src/Connexion/ConnectionManager.ts +++ b/front/src/Connexion/ConnectionManager.ts @@ -17,10 +17,20 @@ class ConnectionManager { private authToken:string|null = null; private userUuid: string|null = null; + //todo: get map infos from url in anonym case public async init(): Promise { + let organizationMemberToken = null; + let teamSlug = null; + let mapSlug = null; const match = /\/register\/(.+)/.exec(window.location.toString()); - const organizationMemberToken = match ? match[1] : null; - this.initPromise = Axios.post(`${API_URL}/login`, {organizationMemberToken}).then(res => res.data); + if (match) { + organizationMemberToken = match[1]; + } else { + const match = /\/_\/(.+)\/(.+)/.exec(window.location.toString()); + teamSlug = match ? match[1] : null; + mapSlug = match ? match[2] : null; + } + this.initPromise = Axios.post(`${API_URL}/login`, {organizationMemberToken, teamSlug, mapSlug}).then(res => res.data); const data = await this.initPromise this.authToken = data.authToken; this.userUuid = data.userUuid; diff --git a/front/src/Phaser/Entity/GameSceneDescriptor.ts b/front/src/Phaser/Entity/GameSceneDescriptor.ts new file mode 100644 index 00000000..df114c28 --- /dev/null +++ b/front/src/Phaser/Entity/GameSceneDescriptor.ts @@ -0,0 +1,6 @@ +export class GameSceneDescriptor { + + constructor(MapKey : string, MapUrlFile: string, instance: string, key: string) { + this.roomId = '';// + } +} \ No newline at end of file diff --git a/front/src/Phaser/Game/GameManager.ts b/front/src/Phaser/Game/GameManager.ts index 960ce7e2..5188d2fe 100644 --- a/front/src/Phaser/Game/GameManager.ts +++ b/front/src/Phaser/Game/GameManager.ts @@ -1,4 +1,4 @@ -import {GameScene} from "./GameScene"; +import {GameScene, GameSceneInitInterface} from "./GameScene"; import { StartMapInterface } from "../../Connexion/ConnexionModels"; @@ -13,6 +13,11 @@ export interface HasMovedEvent { y: number; } +export interface loadMapResponseInterface { + key: string, + startLayerName: string; +} + export class GameManager { private playerName!: string; private characterLayers!: string[]; @@ -29,15 +34,6 @@ export class GameManager { this.characterLayers = layers; } - loadStartMap() : Promise { - return connectionManager.getMapUrlStart().then(mapUrlStart => { - return { - mapUrlStart: mapUrlStart, - startInstance: "global", //todo: is this property still usefull? - } - }); - } - getPlayerName(): string { return this.playerName; } @@ -46,8 +42,47 @@ export class GameManager { return this.characterLayers; } - loadMap(mapUrl: string, scene: Phaser.Scenes.ScenePlugin, instance: string): string { - const sceneKey = GameScene.getMapKeyByUrl(mapUrl); + /** + * Returns the map URL and the instance from the current URL + */ + private findMapUrl(): [string, string]|null { + const path = window.location.pathname; + if (!path.startsWith('/_/')) { + return null; + } + const instanceAndMap = path.substr(3); + const firstSlash = instanceAndMap.indexOf('/'); + if (firstSlash === -1) { + return null; + } + const instance = instanceAndMap.substr(0, firstSlash); + return [window.location.protocol+'//'+instanceAndMap.substr(firstSlash+1), instance]; + } + + public loadStartingMap(scene: Phaser.Scenes.ScenePlugin): Promise { + // Do we have a start URL in the address bar? If so, let's redirect to this address + const instanceAndMapUrl = this.findMapUrl(); + if (instanceAndMapUrl !== null) { + const [mapUrl, instance] = instanceAndMapUrl; + const key = gameManager.loadMap(mapUrl, scene, instance); + const startLayerName = window.location.hash ? window.location.hash.substr(1) : ''; + return Promise.resolve({key, startLayerName}); + + } else { + // If we do not have a map address in the URL, let's ask the server for a start map. + return connectionManager.getMapUrlStart().then((mapUrlStart: string) => { + const key = gameManager.loadMap(window.location.protocol + "//" + mapUrlStart, scene, 'global'); + return {key, startLayerName: ''} + }).catch((err) => { + console.error(err); + throw err; + }); + } + + } + + public loadMap(mapUrl: string, scene: Phaser.Scenes.ScenePlugin, instance: string): string { + const sceneKey = this.getMapKeyByUrl(mapUrl); const gameIndex = scene.getIndex(sceneKey); if(gameIndex === -1){ @@ -56,6 +91,13 @@ export class GameManager { } return sceneKey; } + + public getMapKeyByUrl(mapUrlStart: string) : string { + // FIXME: the key should be computed from the full URL of the map. + const startPos = mapUrlStart.indexOf('://')+3; + const endPos = mapUrlStart.indexOf(".json"); + return mapUrlStart.substring(startPos, endPos); + } } export const gameManager = new GameManager(); diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index b3a5f104..a9591f21 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -138,17 +138,17 @@ export class GameScene extends Phaser.Scene implements CenterListener { private outlinedItem: ActionableItem|null = null; private userInputManager!: UserInputManager; - static createFromUrl(mapUrlFile: string, instance: string, key: string|null = null): GameScene { - const mapKey = GameScene.getMapKeyByUrl(mapUrlFile); - if (key === null) { - key = mapKey; + static createFromUrl(mapUrlFile: string, instance: string, gameSceneKey: string|null = null): GameScene { + const mapKey = gameManager.getMapKeyByUrl(mapUrlFile); + if (gameSceneKey === null) { + gameSceneKey = mapKey; } - return new GameScene(mapKey, mapUrlFile, instance, key); + return new GameScene(mapKey, mapUrlFile, instance, gameSceneKey); } - constructor(MapKey : string, MapUrlFile: string, instance: string, key: string) { + constructor(MapKey : string, MapUrlFile: string, instance: string, gameSceneKey: string) { super({ - key: key + key: gameSceneKey }); this.GameManager = gameManager; @@ -588,9 +588,9 @@ export class GameScene extends Phaser.Scene implements CenterListener { this.simplePeer.closeAllConnections(); this.simplePeer.unregister(); - const key = 'somekey'+Math.round(Math.random()*10000); - const game : Phaser.Scene = GameScene.createFromUrl(this.MapUrlFile, this.instance, key); - this.scene.add(key, game, true, + const gameSceneKey = 'somekey'+Math.round(Math.random()*10000); + const game : Phaser.Scene = GameScene.createFromUrl(this.MapUrlFile, this.instance, gameSceneKey); + this.scene.add(gameSceneKey, game, true, { initPosition: { x: this.CurrentPlayer.x, @@ -1136,12 +1136,7 @@ export class GameScene extends Phaser.Scene implements CenterListener { this.groups.delete(groupId); } - public static getMapKeyByUrl(mapUrlStart: string) : string { - // FIXME: the key should be computed from the full URL of the map. - const startPos = mapUrlStart.indexOf('://')+3; - const endPos = mapUrlStart.indexOf(".json"); - return mapUrlStart.substring(startPos, endPos); - } + /** * Sends to the server an event emitted by one of the ActionableItems. diff --git a/front/src/Phaser/Login/EnableCameraScene.ts b/front/src/Phaser/Login/EnableCameraScene.ts index 6ac1ad47..672facbb 100644 --- a/front/src/Phaser/Login/EnableCameraScene.ts +++ b/front/src/Phaser/Login/EnableCameraScene.ts @@ -94,7 +94,7 @@ export class EnableCameraScene extends Phaser.Scene { this.add.existing(this.logo); this.input.keyboard.on('keyup-ENTER', () => { - return this.login(); + this.login(); }); this.getElementByIdOrFail('webRtcSetup').classList.add('active'); @@ -258,7 +258,7 @@ export class EnableCameraScene extends Phaser.Scene { this.soundMeterSprite.setVolume(this.soundMeter.getVolume()); } - private async login(): Promise { + private async login(): Promise { this.getElementByIdOrFail('webRtcSetup').style.display = 'none'; this.soundMeter.stop(); window.removeEventListener('resize', this.repositionCallback); @@ -266,46 +266,8 @@ export class EnableCameraScene extends Phaser.Scene { mediaManager.stopCamera(); mediaManager.stopMicrophone(); - // Do we have a start URL in the address bar? If so, let's redirect to this address - const instanceAndMapUrl = this.findMapUrl(); - if (instanceAndMapUrl !== null) { - const [mapUrl, instance] = instanceAndMapUrl; - const key = gameManager.loadMap(mapUrl, this.scene, instance); - this.scene.start(key, { - startLayerName: window.location.hash ? window.location.hash.substr(1) : undefined - } as GameSceneInitInterface); - return { - mapUrlStart: mapUrl, - startInstance: instance - }; - } else { - // If we do not have a map address in the URL, let's ask the server for a start map. - return gameManager.loadStartMap().then((startMap: StartMapInterface) => { - const key = gameManager.loadMap(window.location.protocol + "//" + startMap.mapUrlStart, this.scene, startMap.startInstance); - this.scene.start(key); - return startMap; - }).catch((err) => { - console.error(err); - throw err; - }); - } - } - - /** - * Returns the map URL and the instance from the current URL - */ - private findMapUrl(): [string, string]|null { - const path = window.location.pathname; - if (!path.startsWith('/_/')) { - return null; - } - const instanceAndMap = path.substr(3); - const firstSlash = instanceAndMap.indexOf('/'); - if (firstSlash === -1) { - return null; - } - const instance = instanceAndMap.substr(0, firstSlash); - return [window.location.protocol+'//'+instanceAndMap.substr(firstSlash+1), instance]; + let {key, startLayerName} = await gameManager.loadStartingMap(this.scene); + this.scene.start(key, {startLayerName}); } private async getDevices() { From 5e54fc2c26901810572842fbeea66bb10e983e18 Mon Sep 17 00:00:00 2001 From: arp Date: Fri, 9 Oct 2020 14:53:18 +0200 Subject: [PATCH 100/122] some fixes --- back/src/Controller/AuthenticateController.ts | 6 +- back/src/Controller/IoSocketController.ts | 68 +++---------------- back/src/Services/JWTTokenManager.ts | 60 ++++++++++++++++ front/src/Connexion/ConnectionManager.ts | 2 +- front/src/Connexion/RoomConnection.ts | 4 +- .../src/Phaser/Entity/GameSceneDescriptor.ts | 6 -- 6 files changed, 76 insertions(+), 70 deletions(-) create mode 100644 back/src/Services/JWTTokenManager.ts delete mode 100644 front/src/Phaser/Entity/GameSceneDescriptor.ts diff --git a/back/src/Controller/AuthenticateController.ts b/back/src/Controller/AuthenticateController.ts index a178b530..d84ccb56 100644 --- a/back/src/Controller/AuthenticateController.ts +++ b/back/src/Controller/AuthenticateController.ts @@ -1,9 +1,9 @@ -import Jwt from "jsonwebtoken"; -import {ADMIN_API_TOKEN, ADMIN_API_URL, SECRET_KEY, URL_ROOM_STARTED} from "../Enum/EnvironmentVariable"; //TODO fix import by "_Enum/..." +import {URL_ROOM_STARTED} from "../Enum/EnvironmentVariable"; //TODO fix import by "_Enum/..." import { uuid } from 'uuidv4'; import {HttpRequest, HttpResponse, TemplatedApp} from "uWebSockets.js"; import {BaseController} from "./BaseController"; import {adminApi, AdminApiData} from "../Services/AdminApi"; +import {jwtTokenManager} from "../Services/JWTTokenManager"; export interface TokenInterface { userUuid: string @@ -59,7 +59,7 @@ export class AuthenticateController extends BaseController { newUrl = '_/global/'+mapUrlStart; } - const authToken = Jwt.sign({userUuid: userUuid}, SECRET_KEY, {expiresIn: '24h'}); + const authToken = jwtTokenManager.createJWTToken(userUuid); res.writeStatus("200 OK").end(JSON.stringify({ authToken, userUuid, diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index 943f949c..30f14134 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -1,14 +1,11 @@ import {ExSocketInterface} from "../Model/Websocket/ExSocketInterface"; //TODO fix import by "_Model/.." -import Jwt from "jsonwebtoken"; -import {SECRET_KEY, MINIMUM_DISTANCE, GROUP_RADIUS, ALLOW_ARTILLERY} from "../Enum/EnvironmentVariable"; //TODO fix import by "_Enum/..." +import {MINIMUM_DISTANCE, GROUP_RADIUS} from "../Enum/EnvironmentVariable"; //TODO fix import by "_Enum/..." import {GameRoom} from "../Model/GameRoom"; import {Group} from "../Model/Group"; import {User} from "../Model/User"; import {isSetPlayerDetailsMessage,} from "../Model/Websocket/SetPlayerDetailsMessage"; import {Gauge} from "prom-client"; -import {TokenInterface} from "../Controller/AuthenticateController"; import {PointInterface} from "../Model/Websocket/PointInterface"; -import {uuid} from 'uuidv4'; import {Movable} from "../Model/Movable"; import { PositionMessage, @@ -43,6 +40,8 @@ import {TemplatedApp} from "uWebSockets.js" import {parse} from "query-string"; import {cpuTracker} from "../Services/CpuTracker"; import {ViewportInterface} from "../Model/Websocket/ViewportMessage"; +import {jwtTokenManager} from "../Services/JWTTokenManager"; +import {adminApi} from "../Services/AdminApi"; function emitInBatch(socket: ExSocketInterface, payload: SubMessage): void { socket.batchedMessages.addPayload(payload); @@ -86,54 +85,7 @@ export class IoSocketController { this.ioConnection(); } - private isValidToken(token: object): token is TokenInterface { - if (typeof((token as TokenInterface).userUuid) !== 'string') { - return false; - } - return true; - } - - private async getUserUuidFromToken(token: unknown): Promise { - - if (!token) { - throw new Error('An authentication error happened, a user tried to connect without a token.'); - } - if (typeof(token) !== "string") { - throw new Error('Token is expected to be a string'); - } - - - if(token === 'test') { - if (ALLOW_ARTILLERY) { - return uuid(); - } else { - throw new Error("In order to perform a load-testing test on this environment, you must set the ALLOW_ARTILLERY environment variable to 'true'"); - } - } - - return new Promise((resolve, reject) => { - Jwt.verify(token, SECRET_KEY, {},(err, tokenDecoded) => { - const tokenInterface = tokenDecoded as TokenInterface; - if (err) { - console.error('An authentication error happened, invalid JsonWebToken.', err); - reject(new Error('An authentication error happened, invalid JsonWebToken. '+err.message)); - return; - } - if (tokenDecoded === undefined) { - console.error('Empty token found.'); - reject(new Error('Empty token found.')); - return; - } - - if (!this.isValidToken(tokenInterface)) { - reject(new Error('Authentication error, invalid token structure.')); - return; - } - - resolve(tokenInterface.userUuid); - }); - }); - } + ioConnection() { this.app.ws('/room/*', { @@ -181,7 +133,12 @@ export class IoSocketController { } - const userUuid = await this.getUserUuidFromToken(token); + const userUuid = await jwtTokenManager.getUserUuidFromToken(token); + + const isGranted = await adminApi.memberIsGrantedAccessToRoom(userUuid, roomId); + if (!isGranted) { + throw Error('Client cannot acces this ressource.'); + } if (upgradeAborted.aborted) { console.log("Ouch! Client disconnected before we could upgrade it!"); @@ -256,11 +213,6 @@ export class IoSocketController { // Let's join the room this.handleJoinRoom(client, client.roomId, client.position, client.viewport, client.name, client.characterLayers); - /*const isGranted = await adminApi.memberIsGrantedAccessToRoom(client.userUuid, roomId); - if (!isGranted) { - throw Error('Client cannot acces this ressource.'); - }*/ - const setUserIdMessage = new SetUserIdMessage(); setUserIdMessage.setUserid(client.userId); diff --git a/back/src/Services/JWTTokenManager.ts b/back/src/Services/JWTTokenManager.ts new file mode 100644 index 00000000..905e0ac6 --- /dev/null +++ b/back/src/Services/JWTTokenManager.ts @@ -0,0 +1,60 @@ +import {ALLOW_ARTILLERY, SECRET_KEY} from "../Enum/EnvironmentVariable"; +import {uuid} from "uuidv4"; +import Jwt from "jsonwebtoken"; +import {TokenInterface} from "../Controller/AuthenticateController"; + +class JWTTokenManager { + + public createJWTToken(userUuid: string) { + return Jwt.sign({userUuid: userUuid}, SECRET_KEY, {expiresIn: '24h'}); + } + + public async getUserUuidFromToken(token: unknown): Promise { + + if (!token) { + throw new Error('An authentication error happened, a user tried to connect without a token.'); + } + if (typeof(token) !== "string") { + throw new Error('Token is expected to be a string'); + } + + + if(token === 'test') { + if (ALLOW_ARTILLERY) { + return uuid(); + } else { + throw new Error("In order to perform a load-testing test on this environment, you must set the ALLOW_ARTILLERY environment variable to 'true'"); + } + } + + return new Promise((resolve, reject) => { + Jwt.verify(token, SECRET_KEY, {},(err, tokenDecoded) => { + const tokenInterface = tokenDecoded as TokenInterface; + if (err) { + console.error('An authentication error happened, invalid JsonWebToken.', err); + reject(new Error('An authentication error happened, invalid JsonWebToken. '+err.message)); + return; + } + if (tokenDecoded === undefined) { + console.error('Empty token found.'); + reject(new Error('Empty token found.')); + return; + } + + if (!this.isValidToken(tokenInterface)) { + reject(new Error('Authentication error, invalid token structure.')); + return; + } + + resolve(tokenInterface.userUuid); + }); + }); + } + + private isValidToken(token: object): token is TokenInterface { + return !(typeof((token as TokenInterface).userUuid) !== 'string'); + } + +} + +export const jwtTokenManager = new JWTTokenManager(); \ No newline at end of file diff --git a/front/src/Connexion/ConnectionManager.ts b/front/src/Connexion/ConnectionManager.ts index a9d15dd9..06f8fe03 100644 --- a/front/src/Connexion/ConnectionManager.ts +++ b/front/src/Connexion/ConnectionManager.ts @@ -48,7 +48,7 @@ class ConnectionManager { public connectToRoomSocket(roomId: string, name: string, characterLayers: string[], position: PositionInterface, viewport: ViewportInterface): Promise { return new Promise((resolve, reject) => { - const connection = new RoomConnection(this.authToken as string, roomId, name, characterLayers, position, viewport); + const connection = new RoomConnection(this.authToken, roomId, name, characterLayers, position, viewport); connection.onConnectError((error: object) => { console.log('An error occurred while connecting to socket server. Retrying'); reject(error); diff --git a/front/src/Connexion/RoomConnection.ts b/front/src/Connexion/RoomConnection.ts index 8799f977..f34197d3 100644 --- a/front/src/Connexion/RoomConnection.ts +++ b/front/src/Connexion/RoomConnection.ts @@ -53,10 +53,10 @@ export class RoomConnection implements RoomConnection { * @param token A JWT token containing the UUID of the user * @param roomId The ID of the room in the form "_/[instance]/[map_url]" or "@/[org]/[event]/[map]" */ - public constructor(token: string, roomId: string, name: string, characterLayers: string[], position: PositionInterface, viewport: ViewportInterface) { + public constructor(token: string|null, roomId: string, name: string, characterLayers: string[], position: PositionInterface, viewport: ViewportInterface) { let url = API_URL.replace('http://', 'ws://').replace('https://', 'wss://'); url += '/room/'+roomId - url += '?token='+encodeURIComponent(token); + url += '?token='+(token ?encodeURIComponent(token):''); url += '&name='+encodeURIComponent(name); for (let layer of characterLayers) { url += '&characterLayers='+encodeURIComponent(layer); diff --git a/front/src/Phaser/Entity/GameSceneDescriptor.ts b/front/src/Phaser/Entity/GameSceneDescriptor.ts deleted file mode 100644 index df114c28..00000000 --- a/front/src/Phaser/Entity/GameSceneDescriptor.ts +++ /dev/null @@ -1,6 +0,0 @@ -export class GameSceneDescriptor { - - constructor(MapKey : string, MapUrlFile: string, instance: string, key: string) { - this.roomId = '';// - } -} \ No newline at end of file From c5f8b43fec79ac7f480b72acfdd8cd89530c103a Mon Sep 17 00:00:00 2001 From: arp Date: Fri, 9 Oct 2020 16:18:25 +0200 Subject: [PATCH 101/122] more fixes --- back/src/Controller/IoSocketController.ts | 22 +++++++++++++++------- back/src/Services/AdminApi.ts | 15 ++++++++++----- front/src/Connexion/ConnectionManager.ts | 1 + 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index 30f14134..36a52e46 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -106,7 +106,11 @@ export class IoSocketController { }); try { + const url = req.getUrl(); const query = parse(req.getQuery()); + const websocketKey = req.getHeader('sec-websocket-key'); + const websocketProtocol = req.getHeader('sec-websocket-protocol'); + const websocketExtensions = req.getHeader('sec-websocket-extensions'); const roomId = req.getUrl().substr(6); @@ -134,10 +138,14 @@ export class IoSocketController { const userUuid = await jwtTokenManager.getUserUuidFromToken(token); + console.log('uuid', userUuid); const isGranted = await adminApi.memberIsGrantedAccessToRoom(userUuid, roomId); if (!isGranted) { - throw Error('Client cannot acces this ressource.'); + console.log('access not granted for user '+userUuid+' and room '+roomId); + throw new Error('Client cannot acces this ressource.') + } else { + console.log('access granted for user '+userUuid+' and room '+roomId); } if (upgradeAborted.aborted) { @@ -149,7 +157,7 @@ export class IoSocketController { /* This immediately calls open handler, you must not use res after this call */ res.upgrade({ // Data passed here is accessible on the "websocket" socket object. - url: req.getUrl(), + url, token, userUuid, roomId, @@ -169,17 +177,17 @@ export class IoSocketController { } }, /* Spell these correctly */ - req.getHeader('sec-websocket-key'), - req.getHeader('sec-websocket-protocol'), - req.getHeader('sec-websocket-extensions'), + websocketKey, + websocketProtocol, + websocketExtensions, context); } catch (e) { if (e instanceof Error) { - console.warn(e.message); + console.log(e.message); res.writeStatus("401 Unauthorized").end(e.message); } else { - console.warn(e); + console.log(e); res.writeStatus("500 Internal Server Error").end('An error occurred'); } return; diff --git a/back/src/Services/AdminApi.ts b/back/src/Services/AdminApi.ts index de28e4ef..79a68810 100644 --- a/back/src/Services/AdminApi.ts +++ b/back/src/Services/AdminApi.ts @@ -1,5 +1,5 @@ import {ADMIN_API_TOKEN, ADMIN_API_URL} from "../Enum/EnvironmentVariable"; -import Axios from "axios"; +import Axios, {AxiosError} from "axios"; export interface AdminApiData { organizationSlug: string @@ -26,10 +26,15 @@ class AdminApi { if (!ADMIN_API_URL) { return Promise.reject('No admin backoffice set!'); } - const res = await Axios.get(ADMIN_API_URL+'/api/member/'+memberId+'/is-granted-access/'+roomId, - { headers: {"Authorization" : `${ADMIN_API_TOKEN}`} } - ) - return res.data === true; + try { + const res = await Axios.get(ADMIN_API_URL+'/api/member/is-granted-access', + { headers: {"Authorization" : `${ADMIN_API_TOKEN}`}, params: {memberId, roomIdentifier: roomId} } + ) + return !!res.data; + } catch (e) { + console.log(e.message) + return false; + } } } diff --git a/front/src/Connexion/ConnectionManager.ts b/front/src/Connexion/ConnectionManager.ts index 06f8fe03..7863df2f 100644 --- a/front/src/Connexion/ConnectionManager.ts +++ b/front/src/Connexion/ConnectionManager.ts @@ -36,6 +36,7 @@ class ConnectionManager { this.userUuid = data.userUuid; this.mapUrlStart = data.mapUrlStart; const newUrl = data.newUrl; + console.log('u', this.userUuid) if (newUrl) { history.pushState({}, '', newUrl); From 032facb75fe5b1d10186b26f585534a1efbd5220 Mon Sep 17 00:00:00 2001 From: arp Date: Fri, 9 Oct 2020 17:14:03 +0200 Subject: [PATCH 102/122] lint fixes --- back/src/Controller/IoSocketController.ts | 4 ++-- back/tests/WorldTest.ts | 2 +- front/src/Connexion/RoomConnection.ts | 2 +- front/src/Phaser/Game/GameScene.ts | 1 - front/src/Phaser/Login/EnableCameraScene.ts | 2 +- front/yarn.lock | 2 +- 6 files changed, 6 insertions(+), 7 deletions(-) diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index 36a52e46..7ef0d811 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -312,10 +312,10 @@ export class IoSocketController { console.warn(message); } - private async handleJoinRoom(client: ExSocketInterface, roomId: string, position: PointInterface, viewport: ViewportInterface, name: string, characterLayers: string[]): Promise { + private handleJoinRoom(client: ExSocketInterface, roomId: string, position: PointInterface, viewport: ViewportInterface, name: string, characterLayers: string[]): void { try { //join new previous room - const gameRoom = await this.joinRoom(client, roomId, position); + const gameRoom = this.joinRoom(client, roomId, position); const things = gameRoom.setViewport(client, viewport); diff --git a/back/tests/WorldTest.ts b/back/tests/WorldTest.ts index 5ab421bb..5e06414c 100644 --- a/back/tests/WorldTest.ts +++ b/back/tests/WorldTest.ts @@ -1,5 +1,5 @@ import "jasmine"; -import {GameRoom, ConnectCallback, DisconnectCallback } from "_Model/GameRoom"; +import {GameRoom, ConnectCallback, DisconnectCallback } from "../src/Model/GameRoom"; import {Point} from "../src/Model/Websocket/MessageUserPosition"; import { Group } from "../src/Model/Group"; import {ExSocketInterface} from "_Model/Websocket/ExSocketInterface"; diff --git a/front/src/Connexion/RoomConnection.ts b/front/src/Connexion/RoomConnection.ts index f4290689..ed669fed 100644 --- a/front/src/Connexion/RoomConnection.ts +++ b/front/src/Connexion/RoomConnection.ts @@ -59,7 +59,7 @@ export class RoomConnection implements RoomConnection { url += '/room/'+roomId url += '?token='+(token ?encodeURIComponent(token):''); url += '&name='+encodeURIComponent(name); - for (let layer of characterLayers) { + for (const layer of characterLayers) { url += '&characterLayers='+encodeURIComponent(layer); } url += '&x='+Math.floor(position.x); diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 9f041eab..ba1d75fa 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -598,7 +598,6 @@ export class GameScene extends ResizableScene implements CenterListener { this.scene.stop(this.scene.key); this.scene.remove(this.scene.key); - window.removeEventListener('resize', this.onResizeCallback); }) connection.onActionableEvent((message => { diff --git a/front/src/Phaser/Login/EnableCameraScene.ts b/front/src/Phaser/Login/EnableCameraScene.ts index 672facbb..5d5339d9 100644 --- a/front/src/Phaser/Login/EnableCameraScene.ts +++ b/front/src/Phaser/Login/EnableCameraScene.ts @@ -266,7 +266,7 @@ export class EnableCameraScene extends Phaser.Scene { mediaManager.stopCamera(); mediaManager.stopMicrophone(); - let {key, startLayerName} = await gameManager.loadStartingMap(this.scene); + const {key, startLayerName} = await gameManager.loadStartingMap(this.scene); this.scene.start(key, {startLayerName}); } diff --git a/front/yarn.lock b/front/yarn.lock index 933a02b4..5d235a82 100644 --- a/front/yarn.lock +++ b/front/yarn.lock @@ -3871,7 +3871,7 @@ quill-delta@^3.6.2: extend "^3.0.2" fast-diff "1.1.2" -quill@1.3.7: +quill@^1.3.7: version "1.3.7" resolved "https://registry.yarnpkg.com/quill/-/quill-1.3.7.tgz#da5b2f3a2c470e932340cdbf3668c9f21f9286e8" integrity sha512-hG/DVzh/TiknWtE6QmWAF/pxoZKYxfe3J/d/+ShUWkDvvkZQVTPeVmUJVu1uE6DDooC4fWTiCLh84ul89oNz5g== From 02c193a262422d2ac90442f00f390d13be5b4788 Mon Sep 17 00:00:00 2001 From: arp Date: Mon, 12 Oct 2020 16:23:07 +0200 Subject: [PATCH 103/122] rewrote the authorisation flow: give more responsability to gameManager and less to gameScene --- back/src/Controller/AuthenticateController.ts | 76 ++++++++------- back/src/Controller/IoSocketController.ts | 24 +++-- back/src/Model/RoomIdentifier.ts | 14 +++ back/src/Services/AdminApi.ts | 8 +- front/src/Connexion/ConnectionManager.ts | 94 ++++++++++--------- front/src/Connexion/LocalUser.ts | 9 ++ front/src/Connexion/LocalUserStore.ts | 16 ++++ front/src/Connexion/Room.ts | 10 ++ front/src/Connexion/RoomConnection.ts | 3 +- front/src/Phaser/Game/GameManager.ts | 77 ++++----------- front/src/Phaser/Game/GameScene.ts | 23 +---- front/src/Phaser/Login/EnableCameraScene.ts | 3 +- front/src/Url/UrlManager.ts | 52 ++++++++++ front/src/index.ts | 5 +- 14 files changed, 244 insertions(+), 170 deletions(-) create mode 100644 back/src/Model/RoomIdentifier.ts create mode 100644 front/src/Connexion/LocalUser.ts create mode 100644 front/src/Connexion/LocalUserStore.ts create mode 100644 front/src/Connexion/Room.ts create mode 100644 front/src/Url/UrlManager.ts diff --git a/back/src/Controller/AuthenticateController.ts b/back/src/Controller/AuthenticateController.ts index 984d7445..55036a0e 100644 --- a/back/src/Controller/AuthenticateController.ts +++ b/back/src/Controller/AuthenticateController.ts @@ -1,8 +1,7 @@ -import {URL_ROOM_STARTED} from "../Enum/EnvironmentVariable"; //TODO fix import by "_Enum/..." import { v4 } from 'uuid'; import {HttpRequest, HttpResponse, TemplatedApp} from "uWebSockets.js"; import {BaseController} from "./BaseController"; -import {adminApi, AdminApiData} from "../Services/AdminApi"; +import {adminApi} from "../Services/AdminApi"; import {jwtTokenManager} from "../Services/JWTTokenManager"; export interface TokenInterface { @@ -13,18 +12,19 @@ export class AuthenticateController extends BaseController { constructor(private App : TemplatedApp) { super(); - this.login(); + this.register(); + this.anonymLogin(); } - //permit to login on application. Return token to connect on Websocket IO. - login(){ - this.App.options("/login", (res: HttpResponse, req: HttpRequest) => { + //Try to login with an admin token + register(){ + this.App.options("/register", (res: HttpResponse, req: HttpRequest) => { this.addCorsHeaders(res); res.end(); }); - this.App.post("/login", (res: HttpResponse, req: HttpRequest) => { + this.App.post("/register", (res: HttpResponse, req: HttpRequest) => { (async () => { this.addCorsHeaders(res); @@ -36,35 +36,25 @@ export class AuthenticateController extends BaseController { //todo: what to do if the organizationMemberToken is already used? const organizationMemberToken:string|null = param.organizationMemberToken; - const mapSlug:string|null = param.mapSlug; - + try { - let userUuid; - let mapUrlStart; - let newUrl: string|null = null; + if (typeof organizationMemberToken != 'string') throw new Error('No organization token'); + const data = await adminApi.fetchMemberDataByToken(organizationMemberToken); - if (organizationMemberToken) { - const data = await adminApi.fetchMemberDataByToken(organizationMemberToken); - - userUuid = data.userUuid; - mapUrlStart = data.mapUrlStart; - newUrl = this.getNewUrlOnAdminAuth(data) - } else if (mapSlug !== null) { - userUuid = v4(); - mapUrlStart = mapSlug; - newUrl = null; - } else { - userUuid = v4(); - mapUrlStart = host.replace('api.', 'maps.') + URL_ROOM_STARTED; - newUrl = '_/global/'+mapUrlStart; - } + const userUuid = data.userUuid; + const organizationSlug = data.organizationSlug; + const worldSlug = data.worldSlug; + const roomSlug = data.roomSlug; + const mapUrlStart = data.mapUrlStart; const authToken = jwtTokenManager.createJWTToken(userUuid); res.writeStatus("200 OK").end(JSON.stringify({ authToken, userUuid, + organizationSlug, + worldSlug, + roomSlug, mapUrlStart, - newUrl, })); } catch (e) { @@ -75,12 +65,32 @@ export class AuthenticateController extends BaseController { })(); }); + } - private getNewUrlOnAdminAuth(data:AdminApiData): string { - const organizationSlug = data.organizationSlug; - const worldSlug = data.worldSlug; - const roomSlug = data.roomSlug; - return '/@/'+organizationSlug+'/'+worldSlug+'/'+roomSlug; + //permit to login on application. Return token to connect on Websocket IO. + anonymLogin(){ + this.App.options("/anonymLogin", (res: HttpResponse, req: HttpRequest) => { + this.addCorsHeaders(res); + + res.end(); + }); + + this.App.post("/anonymLogin", (res: HttpResponse, req: HttpRequest) => { + (async () => { + this.addCorsHeaders(res); + + res.onAborted(() => { + console.warn('Login request was aborted'); + }) + + const userUuid = v4(); + const authToken = jwtTokenManager.createJWTToken(userUuid); + res.writeStatus("200 OK").end(JSON.stringify({ + authToken, + userUuid, + })); + })(); + }); } } diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index 7ef0d811..306b874e 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -42,6 +42,7 @@ import {cpuTracker} from "../Services/CpuTracker"; import {ViewportInterface} from "../Model/Websocket/ViewportMessage"; import {jwtTokenManager} from "../Services/JWTTokenManager"; import {adminApi} from "../Services/AdminApi"; +import {RoomIdentifier} from "../Model/RoomIdentifier"; function emitInBatch(socket: ExSocketInterface, payload: SubMessage): void { socket.batchedMessages.addPayload(payload); @@ -88,7 +89,7 @@ export class IoSocketController { ioConnection() { - this.app.ws('/room/*', { + this.app.ws('/room', { /* Options */ //compression: uWS.SHARED_COMPRESSOR, maxPayloadLength: 16 * 1024 * 1024, @@ -112,7 +113,12 @@ export class IoSocketController { const websocketProtocol = req.getHeader('sec-websocket-protocol'); const websocketExtensions = req.getHeader('sec-websocket-extensions'); - const roomId = req.getUrl().substr(6); + const roomId = query.roomId; + //todo: better validation: /\/_\/.*\/.*/ or /\/@\/.*\/.*\/.*/ + if (typeof roomId !== 'string') { + throw new Error('Undefined room ID: '); + } + const roomIdentifier = new RoomIdentifier(roomId); const token = query.token; const x = Number(query.x); @@ -140,12 +146,14 @@ export class IoSocketController { const userUuid = await jwtTokenManager.getUserUuidFromToken(token); console.log('uuid', userUuid); - const isGranted = await adminApi.memberIsGrantedAccessToRoom(userUuid, roomId); - if (!isGranted) { - console.log('access not granted for user '+userUuid+' and room '+roomId); - throw new Error('Client cannot acces this ressource.') - } else { - console.log('access granted for user '+userUuid+' and room '+roomId); + if (roomIdentifier.anonymous === false) { + const isGranted = await adminApi.memberIsGrantedAccessToRoom(userUuid, roomIdentifier); + if (!isGranted) { + console.log('access not granted for user '+userUuid+' and room '+roomId); + throw new Error('Client cannot acces this ressource.') + } else { + console.log('access granted for user '+userUuid+' and room '+roomId); + } } if (upgradeAborted.aborted) { diff --git a/back/src/Model/RoomIdentifier.ts b/back/src/Model/RoomIdentifier.ts new file mode 100644 index 00000000..9bb58bb9 --- /dev/null +++ b/back/src/Model/RoomIdentifier.ts @@ -0,0 +1,14 @@ +export class RoomIdentifier { + public anonymous: boolean; + public id:string + constructor(roomID: string) { + if (roomID.indexOf('_/') === 0) { + this.anonymous = true; + } else if(roomID.indexOf('@/') === 0) { + this.anonymous = false; + } else { + throw new Error('Incorrect room ID: '+roomID); + } + this.id = roomID; //todo: extract more data from the id (like room slug, organization name, etc); + } +} \ No newline at end of file diff --git a/back/src/Services/AdminApi.ts b/back/src/Services/AdminApi.ts index 79a68810..2d03ee9d 100644 --- a/back/src/Services/AdminApi.ts +++ b/back/src/Services/AdminApi.ts @@ -1,5 +1,6 @@ import {ADMIN_API_TOKEN, ADMIN_API_URL} from "../Enum/EnvironmentVariable"; -import Axios, {AxiosError} from "axios"; +import Axios from "axios"; +import {RoomIdentifier} from "../Model/RoomIdentifier"; export interface AdminApiData { organizationSlug: string @@ -22,13 +23,14 @@ class AdminApi { return res.data; } - async memberIsGrantedAccessToRoom(memberId: string, roomId: string): Promise { + async memberIsGrantedAccessToRoom(memberId: string, roomIdentifier: RoomIdentifier): Promise { if (!ADMIN_API_URL) { return Promise.reject('No admin backoffice set!'); } try { + //todo: send more specialized data instead of the whole id const res = await Axios.get(ADMIN_API_URL+'/api/member/is-granted-access', - { headers: {"Authorization" : `${ADMIN_API_TOKEN}`}, params: {memberId, roomIdentifier: roomId} } + { headers: {"Authorization" : `${ADMIN_API_TOKEN}`}, params: {memberId, roomIdentifier: roomIdentifier.id} } ) return !!res.data; } catch (e) { diff --git a/front/src/Connexion/ConnectionManager.ts b/front/src/Connexion/ConnectionManager.ts index 91a42882..0fea50b5 100644 --- a/front/src/Connexion/ConnectionManager.ts +++ b/front/src/Connexion/ConnectionManager.ts @@ -2,54 +2,67 @@ import Axios from "axios"; import {API_URL} from "../Enum/EnvironmentVariable"; import {RoomConnection} from "./RoomConnection"; import {PositionInterface, ViewportInterface} from "./ConnexionModels"; - -interface LoginApiData { - authToken: string - userUuid: string - mapUrlStart: string - newUrl: string -} +import {GameConnexionTypes, urlManager} from "../Url/UrlManager"; +import {localUserStore} from "./LocalUserStore"; +import {LocalUser} from "./LocalUser"; +import {Room} from "./Room"; class ConnectionManager { - private initPromise!: Promise; - private mapUrlStart: string|null = null; + private localUser!:LocalUser; - private authToken:string|null = null; - private userUuid: string|null = null; + /** + * Tries to login to the node server and return the starting map url to be loaded + */ + public async initGameConnexion(): Promise { - //todo: get map infos from url in anonym case - public async init(): Promise { - let organizationMemberToken = null; - let teamSlug = null; - let mapSlug = null; - const match = /\/register\/(.+)/.exec(window.location.toString()); - if (match) { - organizationMemberToken = match[1]; - } else { - const match = /\/_\/(.+)\/(.+)/.exec(window.location.toString()); - teamSlug = match ? match[1] : null; - mapSlug = match ? match[2] : null; - } - this.initPromise = Axios.post(`${API_URL}/login`, {organizationMemberToken, teamSlug, mapSlug}).then(res => res.data); - const data = await this.initPromise - this.authToken = data.authToken; - this.userUuid = data.userUuid; - this.mapUrlStart = data.mapUrlStart; - const newUrl = data.newUrl; - console.log('u', this.userUuid) - - if (newUrl) { - history.pushState({}, '', newUrl); + const connexionType = urlManager.getGameConnexionType(); + if(connexionType === GameConnexionTypes.register) { + const organizationMemberToken = urlManager.getOrganizationToken(); + const data:any = await Axios.post(`${API_URL}/register`, {organizationMemberToken}).then(res => res.data); + this.localUser = new LocalUser(data.userUuid, data.authToken); + localUserStore.saveUser(this.localUser); + + const organizationSlug = data.organizationSlug; + const worldSlug = data.worldSlug; + const roomSlug = data.roomSlug; + urlManager.editUrlForRoom(roomSlug, organizationSlug, worldSlug); + + const room = new Room(window.location.pathname, data.mapUrlStart) + return Promise.resolve(room); + } else if (connexionType === GameConnexionTypes.anonymous) { + const localUser = localUserStore.getLocalUser(); + + if (localUser) { + this.localUser = localUser + } else { + const data:any = await Axios.post(`${API_URL}/anonymLogin`).then(res => res.data); + this.localUser = new LocalUser(data.userUuid, data.authToken); + localUserStore.saveUser(this.localUser); + } + const room = new Room(window.location.pathname, urlManager.getAnonymousMapUrlStart()) + return Promise.resolve(room); + } else if (connexionType == GameConnexionTypes.organization) { + const localUser = localUserStore.getLocalUser(); + + if (localUser) { + this.localUser = localUser + //todo: ask the node api for the correct starting map Url from its slug + return Promise.reject('Case not handled: need to get the map\'s url from its slug'); + } else { + //todo: find some kind of fallback? + return Promise.reject('Could not find a user in localstorage'); + } } + return Promise.reject('ConnexionManager initialization failed'); } public initBenchmark(): void { - this.authToken = 'test'; + this.localUser = new LocalUser('', 'test'); } public connectToRoomSocket(roomId: string, name: string, characterLayers: string[], position: PositionInterface, viewport: ViewportInterface): Promise { return new Promise((resolve, reject) => { - const connection = new RoomConnection(this.authToken, roomId, name, characterLayers, position, viewport); + const connection = new RoomConnection(this.localUser.jwtToken, roomId, name, characterLayers, position, viewport); connection.onConnectError((error: object) => { console.log('An error occurred while connecting to socket server. Retrying'); reject(error); @@ -67,15 +80,6 @@ class ConnectionManager { }); }); } - - public getMapUrlStart(): Promise { - return this.initPromise.then(() => { - if (!this.mapUrlStart) { - throw new Error('No map url set!'); - } - return this.mapUrlStart; - }) - } } export const connectionManager = new ConnectionManager(); diff --git a/front/src/Connexion/LocalUser.ts b/front/src/Connexion/LocalUser.ts new file mode 100644 index 00000000..1411f66c --- /dev/null +++ b/front/src/Connexion/LocalUser.ts @@ -0,0 +1,9 @@ +export class LocalUser { + public uuid: string; + public jwtToken: string; + + constructor(uuid:string, jwtToken: string) { + this.uuid = uuid; + this.jwtToken = jwtToken; + } +} \ No newline at end of file diff --git a/front/src/Connexion/LocalUserStore.ts b/front/src/Connexion/LocalUserStore.ts new file mode 100644 index 00000000..0976b5c9 --- /dev/null +++ b/front/src/Connexion/LocalUserStore.ts @@ -0,0 +1,16 @@ +import {LocalUser} from "./LocalUser"; + +class LocalUserStore { + + saveUser(localUser: LocalUser) { + localStorage.setItem('localUser', JSON.stringify(localUser)); + } + + getLocalUser(): LocalUser|null { + const data = localStorage.getItem('localUser'); + return data ? JSON.parse(data) : null; + } + +} + +export const localUserStore = new LocalUserStore(); \ No newline at end of file diff --git a/front/src/Connexion/Room.ts b/front/src/Connexion/Room.ts new file mode 100644 index 00000000..36a8072b --- /dev/null +++ b/front/src/Connexion/Room.ts @@ -0,0 +1,10 @@ +export class Room { + public ID: string; + public url: string + + constructor(ID: string, url: string) { + this.ID = ID; + this.url = url; + } + +} \ No newline at end of file diff --git a/front/src/Connexion/RoomConnection.ts b/front/src/Connexion/RoomConnection.ts index ed669fed..fd9410c4 100644 --- a/front/src/Connexion/RoomConnection.ts +++ b/front/src/Connexion/RoomConnection.ts @@ -56,7 +56,8 @@ export class RoomConnection implements RoomConnection { */ public constructor(token: string|null, roomId: string, name: string, characterLayers: string[], position: PositionInterface, viewport: ViewportInterface) { let url = API_URL.replace('http://', 'ws://').replace('https://', 'wss://'); - url += '/room/'+roomId + url += '/room'; + url += '?roomId='+(roomId ?encodeURIComponent(roomId):''); url += '?token='+(token ?encodeURIComponent(token):''); url += '&name='+encodeURIComponent(name); for (const layer of characterLayers) { diff --git a/front/src/Phaser/Game/GameManager.ts b/front/src/Phaser/Game/GameManager.ts index 5188d2fe..10277e20 100644 --- a/front/src/Phaser/Game/GameManager.ts +++ b/front/src/Phaser/Game/GameManager.ts @@ -1,10 +1,6 @@ -import {GameScene, GameSceneInitInterface} from "./GameScene"; -import { - StartMapInterface -} from "../../Connexion/ConnexionModels"; -import Axios from "axios"; -import {API_URL} from "../../Enum/EnvironmentVariable"; +import {GameScene} from "./GameScene"; import {connectionManager} from "../../Connexion/ConnectionManager"; +import {Room} from "../../Connexion/Room"; export interface HasMovedEvent { direction: string; @@ -13,14 +9,17 @@ export interface HasMovedEvent { y: number; } -export interface loadMapResponseInterface { - key: string, - startLayerName: string; -} - export class GameManager { private playerName!: string; private characterLayers!: string[]; + private startRoom!:Room; + private sceneManager!: Phaser.Scenes.SceneManager; + + public async init(sceneManager: Phaser.Scenes.SceneManager) { + this.sceneManager = sceneManager; + this.startRoom = await connectionManager.initGameConnexion(); + this.loadMap(this.startRoom.url, this.startRoom.ID); + } public setPlayerName(name: string): void { this.playerName = name; @@ -41,55 +40,15 @@ export class GameManager { getCharacterSelected(): string[] { return this.characterLayers; } - - /** - * Returns the map URL and the instance from the current URL - */ - private findMapUrl(): [string, string]|null { - const path = window.location.pathname; - if (!path.startsWith('/_/')) { - return null; - } - const instanceAndMap = path.substr(3); - const firstSlash = instanceAndMap.indexOf('/'); - if (firstSlash === -1) { - return null; - } - const instance = instanceAndMap.substr(0, firstSlash); - return [window.location.protocol+'//'+instanceAndMap.substr(firstSlash+1), instance]; - } - public loadStartingMap(scene: Phaser.Scenes.ScenePlugin): Promise { - // Do we have a start URL in the address bar? If so, let's redirect to this address - const instanceAndMapUrl = this.findMapUrl(); - if (instanceAndMapUrl !== null) { - const [mapUrl, instance] = instanceAndMapUrl; - const key = gameManager.loadMap(mapUrl, scene, instance); - const startLayerName = window.location.hash ? window.location.hash.substr(1) : ''; - return Promise.resolve({key, startLayerName}); - - } else { - // If we do not have a map address in the URL, let's ask the server for a start map. - return connectionManager.getMapUrlStart().then((mapUrlStart: string) => { - const key = gameManager.loadMap(window.location.protocol + "//" + mapUrlStart, scene, 'global'); - return {key, startLayerName: ''} - }).catch((err) => { - console.error(err); - throw err; - }); - } - - } - - public loadMap(mapUrl: string, scene: Phaser.Scenes.ScenePlugin, instance: string): string { - const sceneKey = this.getMapKeyByUrl(mapUrl); - - const gameIndex = scene.getIndex(sceneKey); + + public loadMap(mapUrl: string, roomID: string): void { + console.log('Loading map '+roomID+' at url '+mapUrl); + const gameIndex = this.sceneManager.getIndex(roomID); if(gameIndex === -1){ - const game : Phaser.Scene = GameScene.createFromUrl(mapUrl, instance); - scene.add(sceneKey, game, false); + const game : Phaser.Scene = GameScene.createFromUrl(mapUrl, roomID); + this.sceneManager.add(roomID, game, false); } - return sceneKey; } public getMapKeyByUrl(mapUrlStart: string) : string { @@ -98,6 +57,10 @@ export class GameManager { const endPos = mapUrlStart.indexOf(".json"); return mapUrlStart.substring(startPos, endPos); } + + public async goToStartingMap() { + this.sceneManager.start(this.startRoom.ID, {startLayerName: 'global'}); + } } export const gameManager = new GameManager(); diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index ba1d75fa..602f697e 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -418,15 +418,7 @@ export class GameScene extends ResizableScene implements CenterListener { context.strokeStyle = '#ffffff'; context.stroke(); this.circleTexture.refresh(); - - // Let's alter browser history - const url = new URL(this.MapUrlFile); - let path = '/_/'+this.instance+'/'+url.host+url.pathname; - if (this.startLayerName) { - path += '#'+this.startLayerName; - } - window.history.pushState({}, 'WorkAdventure', path); - + // Let's pause the scene if the connection is not established yet if (this.connection === undefined) { // Let's wait 0.5 seconds before printing the "connecting" screen to avoid blinking @@ -686,6 +678,7 @@ export class GameScene extends ResizableScene implements CenterListener { * @param tileWidth * @param tileHeight */ + //todo: push that into the gameManager private loadNextGame(layer: ITiledMapLayer, mapWidth: number, tileWidth: number, tileHeight: number){ const exitSceneUrl = this.getExitSceneUrl(layer); if (exitSceneUrl === undefined) { @@ -698,7 +691,8 @@ export class GameScene extends ResizableScene implements CenterListener { // TODO: eventually compute a relative URL const absoluteExitSceneUrl = new URL(exitSceneUrl, this.MapUrlFile).href; - const exitSceneKey = gameManager.loadMap(absoluteExitSceneUrl, this.scene, instance); + gameManager.loadMap(absoluteExitSceneUrl, instance); + const exitSceneKey = instance; const tiles : number[] = layer.data as number[]; for (let key=0; key < tiles.length; key++) { @@ -785,14 +779,6 @@ export class GameScene extends ResizableScene implements CenterListener { }); } - createCollisionObject(){ - /*this.Objects.forEach((Object : Phaser.Physics.Arcade.Sprite) => { - this.physics.add.collider(this.CurrentPlayer, Object, (object1, object2) => { - this.CurrentPlayer.say("Collision with object : " + (object2 as Phaser.Physics.Arcade.Sprite).texture.key) - }); - })*/ - } - createCurrentPlayer(){ //initialise player //TODO create animation moving between exit and start @@ -809,7 +795,6 @@ export class GameScene extends ResizableScene implements CenterListener { //create collision this.createCollisionWithPlayer(); - this.createCollisionObject(); } pushPlayerPosition(event: HasMovedEvent) { diff --git a/front/src/Phaser/Login/EnableCameraScene.ts b/front/src/Phaser/Login/EnableCameraScene.ts index 5d5339d9..8695464b 100644 --- a/front/src/Phaser/Login/EnableCameraScene.ts +++ b/front/src/Phaser/Login/EnableCameraScene.ts @@ -266,8 +266,7 @@ export class EnableCameraScene extends Phaser.Scene { mediaManager.stopCamera(); mediaManager.stopMicrophone(); - const {key, startLayerName} = await gameManager.loadStartingMap(this.scene); - this.scene.start(key, {startLayerName}); + gameManager.goToStartingMap(); } private async getDevices() { diff --git a/front/src/Url/UrlManager.ts b/front/src/Url/UrlManager.ts new file mode 100644 index 00000000..39f5667d --- /dev/null +++ b/front/src/Url/UrlManager.ts @@ -0,0 +1,52 @@ + +export enum GameConnexionTypes { + anonymous=1, + organization, + register, + unknown, +} + +//this class is responsible with analysing and editing the game's url +class UrlManager { + + //todo: use that to detect if we can find a token in localstorage + public getGameConnexionType(): GameConnexionTypes { + const url = window.location.pathname.toString(); + if (url.indexOf('_/') > -1) { + return GameConnexionTypes.anonymous; + } else if (url.indexOf('@/') > -1) { + return GameConnexionTypes.organization; + } else if(url.indexOf('register/')) { + return GameConnexionTypes.register + } else { + return GameConnexionTypes.unknown + } + } + + public getAnonymousMapUrlStart():string { + const match = /\/_\/global\/(.+)/.exec(window.location.pathname.toString()) + if (!match) throw new Error('Could not extract startmap url from'+window.location.pathname); + return match[1]; + + } + + public getOrganizationToken(): string|null { + const match = /\/register\/(.+)/.exec(window.location.pathname.toString()); + return match ? match [1] : null; + } + + + public editUrlForRoom(roomSlug: string, organizationSlug: string|null, worldSlug: string |null): string { + let newUrl:string; + if (organizationSlug) { + newUrl = '/@/'+organizationSlug+'/'+worldSlug+'/'+roomSlug; + } else { + newUrl = '/_/global/'+roomSlug; + } + history.pushState({}, 'WorkAdventure', newUrl); + return newUrl; + } + +} + +export const urlManager = new UrlManager(); \ No newline at end of file diff --git a/front/src/index.ts b/front/src/index.ts index 177c56c0..f57474d7 100644 --- a/front/src/index.ts +++ b/front/src/index.ts @@ -11,11 +11,10 @@ import WebGLRenderer = Phaser.Renderer.WebGL.WebGLRenderer; import {OutlinePipeline} from "./Phaser/Shaders/OutlinePipeline"; import {CustomizeScene} from "./Phaser/Login/CustomizeScene"; import {CoWebsiteManager} from "./WebRtc/CoWebsiteManager"; -import {connectionManager} from "./Connexion/ConnectionManager"; +import {gameManager} from "./Phaser/Game/GameManager"; import {ResizableScene} from "./Phaser/Login/ResizableScene"; //CoWebsiteManager.loadCoWebsite('https://thecodingmachine.com'); -connectionManager.init(); // Load Jitsi if the environment variable is set. if (JITSI_URL) { @@ -52,6 +51,8 @@ cypressAsserter.gameStarted(); const game = new Phaser.Game(config); +gameManager.init(game.scene); + window.addEventListener('resize', function (event) { const {width, height} = CoWebsiteManager.getGameSize(); From 2852f204f506caa38b438caeac7c92338c584840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Mon, 12 Oct 2020 17:42:37 +0200 Subject: [PATCH 104/122] Improving error handling upon unknown URL --- front/src/Connexion/ConnectionManager.ts | 2 +- front/src/Phaser/Game/GameManager.ts | 17 ++++++++++---- .../src/Phaser/Reconnecting/FourOFourScene.ts | 23 +++++++++++++++---- front/src/Url/UrlManager.ts | 2 +- 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/front/src/Connexion/ConnectionManager.ts b/front/src/Connexion/ConnectionManager.ts index 0fea50b5..615f75b9 100644 --- a/front/src/Connexion/ConnectionManager.ts +++ b/front/src/Connexion/ConnectionManager.ts @@ -53,7 +53,7 @@ class ConnectionManager { return Promise.reject('Could not find a user in localstorage'); } } - return Promise.reject('ConnexionManager initialization failed'); + return Promise.reject('ConnexionManager initialization failed: invalid URL'); } public initBenchmark(): void { diff --git a/front/src/Phaser/Game/GameManager.ts b/front/src/Phaser/Game/GameManager.ts index 10277e20..bed098ae 100644 --- a/front/src/Phaser/Game/GameManager.ts +++ b/front/src/Phaser/Game/GameManager.ts @@ -1,6 +1,7 @@ import {GameScene} from "./GameScene"; import {connectionManager} from "../../Connexion/ConnectionManager"; import {Room} from "../../Connexion/Room"; +import {FourOFourSceneName} from "../Reconnecting/FourOFourScene"; export interface HasMovedEvent { direction: string; @@ -14,10 +15,16 @@ export class GameManager { private characterLayers!: string[]; private startRoom!:Room; private sceneManager!: Phaser.Scenes.SceneManager; - + public async init(sceneManager: Phaser.Scenes.SceneManager) { this.sceneManager = sceneManager; - this.startRoom = await connectionManager.initGameConnexion(); + try { + this.startRoom = await connectionManager.initGameConnexion(); + } catch (e) { + this.sceneManager.start(FourOFourSceneName, { + url: window.location.pathname.toString() + }); + } this.loadMap(this.startRoom.url, this.startRoom.ID); } @@ -40,8 +47,8 @@ export class GameManager { getCharacterSelected(): string[] { return this.characterLayers; } - - + + public loadMap(mapUrl: string, roomID: string): void { console.log('Loading map '+roomID+' at url '+mapUrl); const gameIndex = this.sceneManager.getIndex(roomID); @@ -57,7 +64,7 @@ export class GameManager { const endPos = mapUrlStart.indexOf(".json"); return mapUrlStart.substring(startPos, endPos); } - + public async goToStartingMap() { this.sceneManager.start(this.startRoom.ID, {startLayerName: 'global'}); } diff --git a/front/src/Phaser/Reconnecting/FourOFourScene.ts b/front/src/Phaser/Reconnecting/FourOFourScene.ts index 0c91a5bc..3e84b7e9 100644 --- a/front/src/Phaser/Reconnecting/FourOFourScene.ts +++ b/front/src/Phaser/Reconnecting/FourOFourScene.ts @@ -15,7 +15,8 @@ export class FourOFourScene extends Phaser.Scene { private fileNameField!: Text; private logo!: Image; private cat!: Sprite; - private file!: string; + private file: string|undefined; + private url: string|undefined; constructor() { super({ @@ -23,8 +24,9 @@ export class FourOFourScene extends Phaser.Scene { }); } - init({ file }: { file: string }) { + init({ file, url }: { file?: string, url?: string }) { this.file = file; + this.url = url; } preload() { @@ -45,11 +47,22 @@ export class FourOFourScene extends Phaser.Scene { this.mapNotFoundField = new TextField(this, this.game.renderer.width / 2, this.game.renderer.height / 2, "404 - File not found"); this.mapNotFoundField.setOrigin(0.5, 0.5).setCenterAlign(); - this.couldNotFindField = new TextField(this, this.game.renderer.width / 2, this.game.renderer.height / 2 + 24, "Could not load file"); + let text: string = ''; + if (this.file !== undefined) { + text = "Could not load map" + } + if (this.url !== undefined) { + text = "Invalid URL" + } + + this.couldNotFindField = new TextField(this, this.game.renderer.width / 2, this.game.renderer.height / 2 + 24, text); this.couldNotFindField.setOrigin(0.5, 0.5).setCenterAlign(); - this.fileNameField = this.add.text(this.game.renderer.width / 2, this.game.renderer.height / 2 + 38, this.file, { fontFamily: 'Georgia, "Goudy Bookletter 1911", Times, serif', fontSize: '10px' }); - this.fileNameField.setOrigin(0.5, 0.5); + const url = this.file ? this.file : this.url; + if (url !== undefined) { + this.fileNameField = this.add.text(this.game.renderer.width / 2, this.game.renderer.height / 2 + 38, url, { fontFamily: 'Georgia, "Goudy Bookletter 1911", Times, serif', fontSize: '10px' }); + this.fileNameField.setOrigin(0.5, 0.5); + } this.cat = this.physics.add.sprite(this.game.renderer.width / 2, this.game.renderer.height / 2 - 32, 'cat', 6); this.cat.flipY=true; diff --git a/front/src/Url/UrlManager.ts b/front/src/Url/UrlManager.ts index 39f5667d..876e258e 100644 --- a/front/src/Url/UrlManager.ts +++ b/front/src/Url/UrlManager.ts @@ -16,7 +16,7 @@ class UrlManager { return GameConnexionTypes.anonymous; } else if (url.indexOf('@/') > -1) { return GameConnexionTypes.organization; - } else if(url.indexOf('register/')) { + } else if(url.indexOf('register/') > -1) { return GameConnexionTypes.register } else { return GameConnexionTypes.unknown From 0731bd39e500b181f527cceaae2f6ddaf0a295a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Mon, 12 Oct 2020 18:59:49 +0200 Subject: [PATCH 105/122] Moving back to using ScenePlugin and adding EntryScene --- front/src/Phaser/Game/GameManager.ts | 26 ++++++-------- front/src/Phaser/Game/GameScene.ts | 10 +++--- front/src/Phaser/Login/EnableCameraScene.ts | 2 +- front/src/Phaser/Login/EntryScene.ts | 40 +++++++++++++++++++++ front/src/Url/UrlManager.ts | 14 ++++---- front/src/index.ts | 5 ++- 6 files changed, 65 insertions(+), 32 deletions(-) create mode 100644 front/src/Phaser/Login/EntryScene.ts diff --git a/front/src/Phaser/Game/GameManager.ts b/front/src/Phaser/Game/GameManager.ts index bed098ae..22123d1c 100644 --- a/front/src/Phaser/Game/GameManager.ts +++ b/front/src/Phaser/Game/GameManager.ts @@ -14,18 +14,10 @@ export class GameManager { private playerName!: string; private characterLayers!: string[]; private startRoom!:Room; - private sceneManager!: Phaser.Scenes.SceneManager; - public async init(sceneManager: Phaser.Scenes.SceneManager) { - this.sceneManager = sceneManager; - try { - this.startRoom = await connectionManager.initGameConnexion(); - } catch (e) { - this.sceneManager.start(FourOFourSceneName, { - url: window.location.pathname.toString() - }); - } - this.loadMap(this.startRoom.url, this.startRoom.ID); + public async init(scenePlugin: Phaser.Scenes.ScenePlugin) { + this.startRoom = await connectionManager.initGameConnexion(); + this.loadMap(this.startRoom.url, this.startRoom.ID, scenePlugin); } public setPlayerName(name: string): void { @@ -49,12 +41,13 @@ export class GameManager { } - public loadMap(mapUrl: string, roomID: string): void { + public loadMap(mapUrl: string, roomID: string, scenePlugin: Phaser.Scenes.ScenePlugin): void { console.log('Loading map '+roomID+' at url '+mapUrl); - const gameIndex = this.sceneManager.getIndex(roomID); + const gameIndex = scenePlugin.getIndex(mapUrl); if(gameIndex === -1){ const game : Phaser.Scene = GameScene.createFromUrl(mapUrl, roomID); - this.sceneManager.add(roomID, game, false); + console.log('Adding scene '+mapUrl); + scenePlugin.add(mapUrl, game, false); } } @@ -65,8 +58,9 @@ export class GameManager { return mapUrlStart.substring(startPos, endPos); } - public async goToStartingMap() { - this.sceneManager.start(this.startRoom.ID, {startLayerName: 'global'}); + public async goToStartingMap(scenePlugin: Phaser.Scenes.ScenePlugin) { + console.log('Starting scene '+this.startRoom.url); + scenePlugin.start(this.startRoom.url, {startLayerName: 'global'}); } } diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 602f697e..a22d973a 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -139,11 +139,11 @@ export class GameScene extends ResizableScene implements CenterListener { private userInputManager!: UserInputManager; static createFromUrl(mapUrlFile: string, instance: string, gameSceneKey: string|null = null): GameScene { - const mapKey = gameManager.getMapKeyByUrl(mapUrlFile); + // We use the map URL as a key if (gameSceneKey === null) { - gameSceneKey = mapKey; + gameSceneKey = mapUrlFile; } - return new GameScene(mapKey, mapUrlFile, instance, gameSceneKey); + return new GameScene(mapUrlFile, mapUrlFile, instance, gameSceneKey); } constructor(MapKey : string, MapUrlFile: string, instance: string, gameSceneKey: string) { @@ -418,7 +418,7 @@ export class GameScene extends ResizableScene implements CenterListener { context.strokeStyle = '#ffffff'; context.stroke(); this.circleTexture.refresh(); - + // Let's pause the scene if the connection is not established yet if (this.connection === undefined) { // Let's wait 0.5 seconds before printing the "connecting" screen to avoid blinking @@ -691,7 +691,7 @@ export class GameScene extends ResizableScene implements CenterListener { // TODO: eventually compute a relative URL const absoluteExitSceneUrl = new URL(exitSceneUrl, this.MapUrlFile).href; - gameManager.loadMap(absoluteExitSceneUrl, instance); + gameManager.loadMap(absoluteExitSceneUrl, instance, this.scene); const exitSceneKey = instance; const tiles : number[] = layer.data as number[]; diff --git a/front/src/Phaser/Login/EnableCameraScene.ts b/front/src/Phaser/Login/EnableCameraScene.ts index 8695464b..3916587a 100644 --- a/front/src/Phaser/Login/EnableCameraScene.ts +++ b/front/src/Phaser/Login/EnableCameraScene.ts @@ -266,7 +266,7 @@ export class EnableCameraScene extends Phaser.Scene { mediaManager.stopCamera(); mediaManager.stopMicrophone(); - gameManager.goToStartingMap(); + gameManager.goToStartingMap(this.scene); } private async getDevices() { diff --git a/front/src/Phaser/Login/EntryScene.ts b/front/src/Phaser/Login/EntryScene.ts new file mode 100644 index 00000000..fec4e880 --- /dev/null +++ b/front/src/Phaser/Login/EntryScene.ts @@ -0,0 +1,40 @@ +import {gameManager} from "../Game/GameManager"; +import {TextField} from "../Components/TextField"; +import {TextInput} from "../Components/TextInput"; +import {ClickButton} from "../Components/ClickButton"; +import Image = Phaser.GameObjects.Image; +import Rectangle = Phaser.GameObjects.Rectangle; +import {PLAYER_RESOURCES, PlayerResourceDescriptionInterface} from "../Entity/Character"; +import {cypressAsserter} from "../../Cypress/CypressAsserter"; +import {SelectCharacterSceneName} from "./SelectCharacterScene"; +import {ResizableScene} from "./ResizableScene"; +import {Scene} from "phaser"; +import {LoginSceneName} from "./LoginScene"; +import {FourOFourSceneName} from "../Reconnecting/FourOFourScene"; + +export const EntrySceneName = "EntryScene"; + +/** + * The EntryScene is not a real scene. It is the first scene loaded and is only used to initialize the gameManager + * and to route to the next correct scene. + */ +export class EntryScene extends Scene { + constructor() { + super({ + key: EntrySceneName + }); + } + + preload() { + } + + create() { + gameManager.init(this.scene).then(() => { + this.scene.start(LoginSceneName); + }).catch(() => { + this.scene.start(FourOFourSceneName, { + url: window.location.pathname.toString() + }); + }); + } +} diff --git a/front/src/Url/UrlManager.ts b/front/src/Url/UrlManager.ts index 876e258e..ae8725bc 100644 --- a/front/src/Url/UrlManager.ts +++ b/front/src/Url/UrlManager.ts @@ -8,7 +8,7 @@ export enum GameConnexionTypes { //this class is responsible with analysing and editing the game's url class UrlManager { - + //todo: use that to detect if we can find a token in localstorage public getGameConnexionType(): GameConnexionTypes { const url = window.location.pathname.toString(); @@ -22,14 +22,14 @@ class UrlManager { return GameConnexionTypes.unknown } } - + public getAnonymousMapUrlStart():string { const match = /\/_\/global\/(.+)/.exec(window.location.pathname.toString()) if (!match) throw new Error('Could not extract startmap url from'+window.location.pathname); - return match[1]; - + return window.location.protocol+'//'+match[1]; + } - + public getOrganizationToken(): string|null { const match = /\/register\/(.+)/.exec(window.location.pathname.toString()); return match ? match [1] : null; @@ -46,7 +46,7 @@ class UrlManager { history.pushState({}, 'WorkAdventure', newUrl); return newUrl; } - + } -export const urlManager = new UrlManager(); \ No newline at end of file +export const urlManager = new UrlManager(); diff --git a/front/src/index.ts b/front/src/index.ts index f57474d7..e12d8707 100644 --- a/front/src/index.ts +++ b/front/src/index.ts @@ -13,6 +13,7 @@ import {CustomizeScene} from "./Phaser/Login/CustomizeScene"; import {CoWebsiteManager} from "./WebRtc/CoWebsiteManager"; import {gameManager} from "./Phaser/Game/GameManager"; import {ResizableScene} from "./Phaser/Login/ResizableScene"; +import {EntryScene} from "./Phaser/Login/EntryScene"; //CoWebsiteManager.loadCoWebsite('https://thecodingmachine.com'); @@ -30,7 +31,7 @@ const config: GameConfig = { width: width / RESOLUTION, height: height / RESOLUTION, parent: "game", - scene: [LoginScene, SelectCharacterScene, EnableCameraScene, ReconnectingScene, FourOFourScene, CustomizeScene], + scene: [EntryScene, LoginScene, SelectCharacterScene, EnableCameraScene, ReconnectingScene, FourOFourScene, CustomizeScene], zoom: RESOLUTION, physics: { default: "arcade", @@ -51,8 +52,6 @@ cypressAsserter.gameStarted(); const game = new Phaser.Game(config); -gameManager.init(game.scene); - window.addEventListener('resize', function (event) { const {width, height} = CoWebsiteManager.getGameSize(); From 9a04836215ad27239c73ccf3166844cb6c7b6c91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Tue, 13 Oct 2020 10:26:27 +0200 Subject: [PATCH 106/122] Dynamically import Quill We load Quill only if it is needed (after all, only admins need Quill) --- front/dist/index.html | 6 - front/package.json | 3 +- .../ConsoleGlobalMessageManager.ts | 57 +- front/yarn.lock | 578 +++++++++--------- 4 files changed, 324 insertions(+), 320 deletions(-) diff --git a/front/dist/index.html b/front/dist/index.html index 9d883ffe..5984af7b 100644 --- a/front/dist/index.html +++ b/front/dist/index.html @@ -6,12 +6,6 @@ content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> - - - - - -