From bf1953fe22a70dc73ec963731f1808e5aedf95da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?gr=C3=A9goire=20parant?= Date: Sun, 5 Sep 2021 19:51:33 +0200 Subject: [PATCH] Release v1.4.15 (#1411) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * audio player volume improvements * Add workaround for #932 * Bump striptags from 3.1.1 to 3.2.0 in /messages Bumps [striptags](https://github.com/ericnorris/striptags) from 3.1.1 to 3.2.0. - [Release notes](https://github.com/ericnorris/striptags/releases) - [Commits](https://github.com/ericnorris/striptags/compare/v3.1.1...v3.2.0) --- updated-dependencies: - dependency-name: striptags dependency-type: indirect ... Signed-off-by: dependabot[bot] * Add anthoer note for https://github.com/thecodingmachine/workadventure/issues/932#issuecomment-867562208 * WIP: svelte menu * temp * temp * Bump tar from 4.4.13 to 4.4.15 in /back Bumps [tar](https://github.com/npm/node-tar) from 4.4.13 to 4.4.15. - [Release notes](https://github.com/npm/node-tar/releases) - [Changelog](https://github.com/npm/node-tar/blob/main/CHANGELOG.md) - [Commits](https://github.com/npm/node-tar/compare/v4.4.13...v4.4.15) --- updated-dependencies: - dependency-name: tar dependency-type: indirect ... Signed-off-by: dependabot[bot] * New menu svelte * Migration of report menu in svelte * Migration of registerCustomMenu for Menu in Svelte Refactor subMenuStore Suppression of old MenuScene and ReportMenu * Suppression of HTML files that aren't use anymore * New version of cache management (#1365) Signed-off-by: Gregoire Parant * migrate to svelte * remove redundancy * initial localUserStore volume * Exit scene acess denied detected (#1369) * Add auth token user to get right in admin and check if user have right Signed-off-by: Gregoire Parant * Update error show Signed-off-by: Gregoire Parant * Update token generation (#1372) - Permit only decode token to get map details, - If user have token expired, set the token to null and reload the page. This feature will be updated when authentication stategy will be finished. Signed-off-by: Gregoire Parant * GameManager has an attribute scenePlugin * GameManager has an attribute scenePlugin * Suppression of gameManager in IframeListener * fix deeployer * fix deeployer * Fixing enter/leave event not properly sent on adjacent zones On adjacent zones, the zone leave event was not properly triggered when leaving a zone for the zone next to it. Closes #1366 * First pass on css * First pass on css * Second pass on css and reportMenu * Second pass on css and reportMenu * Second pass on css and reportMenu * Improving popup If a popup message is empty, only the buttons will be displayed (not the container) Unrelated: the Sound.play method in the API now accepts 0 arguments. * Third pass on css and reportMenu * Correction following test * Player return a the same position when after editing his profile * Player return a the same position when after editing his profile (same as reconnection) * Contact page only if environment variable exist * Execute scripts of the map after creating gameScene * Rollback on createPromise switched to public * Bump tar from 6.1.0 to 6.1.10 in /pusher Bumps [tar](https://github.com/npm/node-tar) from 6.1.0 to 6.1.10. - [Release notes](https://github.com/npm/node-tar/releases) - [Changelog](https://github.com/npm/node-tar/blob/main/CHANGELOG.md) - [Commits](https://github.com/npm/node-tar/compare/v6.1.0...v6.1.10) --- updated-dependencies: - dependency-name: tar dependency-type: indirect ... Signed-off-by: dependabot[bot] * Add iframe submenu by scripting API Delete menu by scripting API * Removing ts-ignore * REVIEW : Migration Menu and Report Menu in Svelte (#1363) * WIP: svelte menu * temp * temp * New menu svelte * Migration of report menu in svelte * Migration of registerCustomMenu for Menu in Svelte Refactor subMenuStore Suppression of old MenuScene and ReportMenu * Suppression of HTML files that aren't use anymore * fix deeployer * First pass on css * First pass on css * Second pass on css and reportMenu * Second pass on css and reportMenu * Second pass on css and reportMenu * Third pass on css and reportMenu * Correction following test * Contact page only if environment variable exist * Update service worker Signed-off-by: Gregoire Parant * Change requested * Change requested Co-authored-by: kharhamel Co-authored-by: Gregoire Parant * Refactor to only have one function registerMenuCommand When selected custom menu is removed, go to settings menu Allow iframe in custom menu to use Scripting API Return menu object when it is registered, can call remove function on it * Correct bad change * Add types file in API * Add types file in API * Fixing "has/in" on variables proxy object When using WA.state, using `"myVariable" in WA.state` would always return false. This is now fixed by adding a "has" method on the Proxy class. Also, added a `WA.state.hasVariable` method. * Add documentation delete unused test map * Properties changed via the Iframe API now trigger changes directly Changes performed in WA.room.setPropertyLayer now have a real-time impact. If the property is changed on a layer the current player is on, the changes will be triggered. * documentation and CHANGELOG * add possibility to set size of coWebsite and Jitsis via map property * Update GameScene.ts typo fixed * Update CoWebsiteManager.ts typos and style * Update CoWebsiteManager.ts yet another typo * FIX: media tracks were not readded to a 3rd person in some situations * fix ReportMenu (#1397) * remove the package systeminformation from back * Bump url-parse from 1.5.1 to 1.5.3 in /front Bumps [url-parse](https://github.com/unshiftio/url-parse) from 1.5.1 to 1.5.3. - [Release notes](https://github.com/unshiftio/url-parse/releases) - [Commits](https://github.com/unshiftio/url-parse/compare/1.5.1...1.5.3) --- updated-dependencies: - dependency-name: url-parse dependency-type: indirect ... Signed-off-by: dependabot[bot] * Bump tar from 4.4.15 to 4.4.19 in /back Bumps [tar](https://github.com/npm/node-tar) from 4.4.15 to 4.4.19. - [Release notes](https://github.com/npm/node-tar/releases) - [Changelog](https://github.com/npm/node-tar/blob/main/CHANGELOG.md) - [Commits](https://github.com/npm/node-tar/compare/v4.4.15...v4.4.19) --- updated-dependencies: - dependency-name: tar dependency-type: indirect ... Signed-off-by: dependabot[bot] * Bump path-parse from 1.0.6 to 1.0.7 in /messages Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7. - [Release notes](https://github.com/jbgutierrez/path-parse/releases) - [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7) --- updated-dependencies: - dependency-name: path-parse dependency-type: indirect ... Signed-off-by: dependabot[bot] * openTabPropertyKey (create new props in own file) * Bump path-parse from 1.0.6 to 1.0.7 in /uploader Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7. - [Release notes](https://github.com/jbgutierrez/path-parse/releases) - [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7) --- updated-dependencies: - dependency-name: path-parse dependency-type: indirect ... Signed-off-by: dependabot[bot] * Bump path-parse from 1.0.6 to 1.0.7 in /front Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7. - [Release notes](https://github.com/jbgutierrez/path-parse/releases) - [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7) --- updated-dependencies: - dependency-name: path-parse dependency-type: indirect ... Signed-off-by: dependabot[bot] * Bump path-parse from 1.0.6 to 1.0.7 in /back Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7. - [Release notes](https://github.com/jbgutierrez/path-parse/releases) - [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7) --- updated-dependencies: - dependency-name: path-parse dependency-type: indirect ... Signed-off-by: dependabot[bot] * Bump path-parse from 1.0.6 to 1.0.7 in /maps Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7. - [Release notes](https://github.com/jbgutierrez/path-parse/releases) - [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7) --- updated-dependencies: - dependency-name: path-parse dependency-type: indirect ... Signed-off-by: dependabot[bot] * FEATURE: improved the mediaStore code to disable tracks instead of deleting them * Bump path-parse from 1.0.6 to 1.0.7 in /benchmark Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7. - [Release notes](https://github.com/jbgutierrez/path-parse/releases) - [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7) --- updated-dependencies: - dependency-name: path-parse dependency-type: indirect ... Signed-off-by: dependabot[bot] * added jitsiTypes * renamed * Allowing variables nested in group layers Up until this commit, variables nested in object layers inside group layers where not found by the front nor the back. This PR changes analysis so that variables can be detected. * FIX: fixed a circular dependancy in stores by rewriting createPeerStore() and createScreenSharingPeerStore() * WIP: Bypass camera scene (#1337) * Set new local camera setup variable * Finish by pass video settings - TODO add button to update camera settings Signed-off-by: Gregoire Parant * Merge branch 'develop' into jumpVideoCamera Signed-off-by: Gregoire Parant # Conflicts: # front/src/Connexion/LocalUserStore.ts # front/src/Phaser/Components/Loader.ts # front/src/Phaser/Game/GameManager.ts # front/src/Phaser/Login/EnableCameraScene.ts * Add menu to open enable camera scene Signed-off-by: Gregoire Parant * Finish jump camera setup Signed-off-by: Gregoire Parant * Active authentication Oauth (#1377) * Active authentication Oauth - Google authentication - GitHub authentication - Linkedin authentication Signed-off-by: Gregoire Parant * Finish connexion et get user info connexion Signed-off-by: Gregoire Parant * Fix lint error Signed-off-by: Gregoire Parant * Change the expires token for 30 days Signed-off-by: Gregoire Parant * Update connexion stratgey - Set last room when it will be created and not when connexion is openned - Add '/login' end point permit to logout and open iframe to log user - Add logout feature permit to logout in front Signed-off-by: Gregoire Parant * Implement logout and revoke token with hydra Signed-off-by: Gregoire Parant * Fix pull develop conflict Signed-off-by: Gregoire Parant * Profile url (#1399) * Create function that permit to get profile URL Signed-off-by: Gregoire Parant * Continue profil user Signed-off-by: Gregoire Parant * Add menu and logout button Signed-off-by: Gregoire Parant * Update last room use Signed-off-by: Gregoire Parant * Profile callback permit to get url profile setting from admin Signed-off-by: Gregoire Parant * Finish profile show Signed-off-by: Gregoire Parant * Delete profileUrl will be not use today Signed-off-by: Gregoire Parant * Correct lint Signed-off-by: Gregoire Parant * Update size of iframe Signed-off-by: Gregoire Parant * Delete console log Signed-off-by: Gregoire Parant * Update feedback ARP Signed-off-by: Gregoire Parant * Emote silent zone (#1342) * Add an emote when the user is in silent zone * Update silent icon strategy * Update strategy for silent zone - Add svelte store - Show silent zone indication and replace camera This update permit to hide silent zone when user is in Jitsi discussion * Fix css silent zone Signed-off-by: Gregoire Parant * Hotfix media constraint error - Create error to manage displayed warning when we try to access on media with no constraint video and audio - Fix disabled microphone if we try to active and we don't have right or there is an error. Signed-off-by: Gregoire Parant Co-authored-by: Lurkars Co-authored-by: Guy Sheffer Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: kharhamel Co-authored-by: GRL Co-authored-by: David Négrier Co-authored-by: GRL78 <80678534+GRL78@users.noreply.github.com> Co-authored-by: ¯\_(ツ)_/¯ Co-authored-by: Kharhamel Co-authored-by: jonny --- CHANGELOG.md | 6 + README.md | 3 + back/package.json | 3 +- back/src/Services/VariablesManager.ts | 45 +- back/yarn.lock | 53 +-- benchmark/package-lock.json | 6 +- benchmark/yarn.lock | 4 +- deeployer.libsonnet | 1 + docs/maps/api-deprecated.md | 1 + docs/maps/api-state.md | 1 + docs/maps/api-ui.md | 50 +- docs/maps/images/custom-menu-iframe.png | Bin 0 -> 14317 bytes docs/maps/images/custom-menu-navbar.png | Bin 0 -> 3302 bytes front/dist/index.tmpl.html | 26 -- front/dist/resources/html/gameMenu.html | 78 ---- front/dist/resources/html/gameMenuIcon.html | 28 -- .../dist/resources/html/gameQualityMenu.html | 81 ---- front/dist/resources/html/gameReport.html | 115 ----- front/dist/resources/html/gameShare.html | 96 ---- front/dist/resources/logos/tcm_full.png | Bin 0 -> 300 bytes front/dist/resources/logos/tcm_short.png | Bin 0 -> 216 bytes .../logos => static/images}/logo-WA-min.png | Bin front/src/Api/Events/IframeEvent.ts | 5 +- front/src/Api/Events/SetVariableEvent.ts | 1 - .../Api/Events/ui/MenuItemRegisterEvent.ts | 26 -- front/src/Api/Events/ui/MenuRegisterEvent.ts | 31 ++ front/src/Api/IframeListener.ts | 125 ++--- front/src/Api/iframe/Sound/Sound.ts | 33 +- front/src/Api/iframe/Ui/Menu.ts | 17 + front/src/Api/iframe/state.ts | 10 + front/src/Api/iframe/ui.ts | 70 ++- front/src/Api/types.ts | 4 + front/src/Components/App.svelte | 27 +- .../AudioManager/AudioManager.svelte | 131 ++++-- front/src/Components/CameraControls.svelte | 21 +- .../ConsoleGlobalMessageManager.svelte | 152 ------- .../Components/Menu/AboutRoomSubMenu.svelte | 147 ++++++ .../AudioGlobalMessage.svelte} | 24 +- .../src/Components/Menu/ContactSubMenu.svelte | 15 + .../Components/Menu/CreateMapSubMenu.svelte | 51 +++ .../src/Components/Menu/CustomSubMenu.svelte | 33 ++ .../Menu/GlobalMessagesSubMenu.svelte | 118 +++++ front/src/Components/Menu/Menu.svelte | 154 +++++++ front/src/Components/Menu/MenuIcon.svelte | 51 ++- .../src/Components/Menu/ProfileSubMenu.svelte | 116 +++++ .../Components/Menu/SettingsSubMenu.svelte | 140 ++++++ .../TextGlobalMessage.svelte} | 36 +- front/src/Components/MyCamera.svelte | 39 +- .../Components/ReportMenu/BlockSubMenu.svelte | 44 ++ .../Components/ReportMenu/ReportMenu.svelte | 141 ++++++ .../ReportMenu/ReportSubMenu.svelte | 55 +++ .../Video/PresentationLayout.svelte | 4 +- front/src/Components/images/logo-WA-min.png | Bin 0 -> 2136 bytes front/src/Connexion/ConnectionManager.ts | 123 +++-- front/src/Connexion/LocalUserStore.ts | 39 +- front/src/Connexion/Room.ts | 12 + front/src/Connexion/RoomConnection.ts | 7 +- front/src/Enum/EnvironmentVariable.ts | 2 + front/src/Phaser/Components/Loader.ts | 58 ++- front/src/Phaser/Entity/Character.ts | 254 ++++++----- front/src/Phaser/Entity/RemotePlayer.ts | 43 +- front/src/Phaser/Game/EmoteManager.ts | 51 ++- front/src/Phaser/Game/GameManager.ts | 69 ++- front/src/Phaser/Game/GameMap.ts | 35 +- .../Phaser/Game/GameMapPropertiesListener.ts | 55 +++ front/src/Phaser/Game/GameScene.ts | 174 +++---- .../src/Phaser/Game/SharedVariablesManager.ts | 42 +- front/src/Phaser/Login/CustomizeScene.ts | 2 +- front/src/Phaser/Login/EnableCameraScene.ts | 35 +- front/src/Phaser/Login/LoginScene.ts | 40 +- .../src/Phaser/Login/SelectCharacterScene.ts | 2 +- .../src/Phaser/Login/SelectCompanionScene.ts | 87 ++-- front/src/Phaser/Menu/MenuScene.ts | 430 ------------------ front/src/Phaser/Menu/ReportMenu.ts | 120 ----- front/src/Phaser/Player/Player.ts | 41 +- front/src/Stores/AudioManagerStore.ts | 5 + .../Errors/MediaStreamConstraintsError.ts | 10 + front/src/Stores/LoginSceneStore.ts | 1 + front/src/Stores/MediaStore.ts | 184 ++++---- front/src/Stores/MenuStore.ts | 97 +++- front/src/Stores/PeerStore.ts | 75 ++- front/src/Stores/PlayersStore.ts | 1 + front/src/Stores/ScreenSharingStore.ts | 13 +- front/src/Stores/ShowReportScreenStore.ts | 7 +- front/src/Stores/UserInputStore.ts | 9 +- front/src/Stores/VideoFocusStore.ts | 34 +- front/src/Url/UrlManager.ts | 8 +- front/src/WebRtc/CoWebsiteManager.ts | 20 +- front/src/WebRtc/JitsiFactory.ts | 165 ++++--- front/src/WebRtc/MediaManager.ts | 29 +- front/src/WebRtc/SimplePeer.ts | 124 +---- front/src/WebRtc/VideoPeer.ts | 74 ++- front/src/index.ts | 2 - front/src/types.ts | 7 +- ...css => TextGlobalMessageSvelte-Style.scss} | 18 +- front/style/index.scss | 2 +- front/style/style.scss | 73 +-- front/webpack.config.ts | 3 + front/yarn.lock | 12 +- maps/tests/Metadata/customIframeMenu.html | 9 + maps/tests/Metadata/customIframeMenuApi.html | 20 + maps/tests/Metadata/customMenu.html | 32 +- maps/tests/Metadata/customMenu.js | 15 + maps/tests/Metadata/customMenu.json | 361 ++++----------- maps/yarn.lock | 6 +- messages/yarn.lock | 12 +- .../src/Controller/AuthenticateController.ts | 83 +++- pusher/src/Enum/EnvironmentVariable.ts | 2 + pusher/src/Services/AdminApi.ts | 11 +- pusher/src/Services/JWTTokenManager.ts | 6 +- pusher/src/Services/OpenIDClient.ts | 25 +- pusher/yarn.lock | 6 +- uploader/yarn.lock | 6 +- 113 files changed, 3017 insertions(+), 2689 deletions(-) create mode 100644 docs/maps/images/custom-menu-iframe.png create mode 100644 docs/maps/images/custom-menu-navbar.png delete mode 100644 front/dist/resources/html/gameMenuIcon.html delete mode 100644 front/dist/resources/html/gameQualityMenu.html delete mode 100644 front/dist/resources/html/gameReport.html delete mode 100644 front/dist/resources/html/gameShare.html create mode 100644 front/dist/resources/logos/tcm_full.png create mode 100644 front/dist/resources/logos/tcm_short.png rename front/dist/{resources/logos => static/images}/logo-WA-min.png (100%) delete mode 100644 front/src/Api/Events/ui/MenuItemRegisterEvent.ts create mode 100644 front/src/Api/Events/ui/MenuRegisterEvent.ts create mode 100644 front/src/Api/iframe/Ui/Menu.ts create mode 100644 front/src/Api/types.ts delete mode 100644 front/src/Components/ConsoleGlobalMessageManager/ConsoleGlobalMessageManager.svelte create mode 100644 front/src/Components/Menu/AboutRoomSubMenu.svelte rename front/src/Components/{ConsoleGlobalMessageManager/UploadAudioGlobalMessage.svelte => Menu/AudioGlobalMessage.svelte} (81%) create mode 100644 front/src/Components/Menu/ContactSubMenu.svelte create mode 100644 front/src/Components/Menu/CreateMapSubMenu.svelte create mode 100644 front/src/Components/Menu/CustomSubMenu.svelte create mode 100644 front/src/Components/Menu/GlobalMessagesSubMenu.svelte create mode 100644 front/src/Components/Menu/Menu.svelte create mode 100644 front/src/Components/Menu/ProfileSubMenu.svelte create mode 100644 front/src/Components/Menu/SettingsSubMenu.svelte rename front/src/Components/{ConsoleGlobalMessageManager/InputTextGlobalMessage.svelte => Menu/TextGlobalMessage.svelte} (69%) create mode 100644 front/src/Components/ReportMenu/BlockSubMenu.svelte create mode 100644 front/src/Components/ReportMenu/ReportMenu.svelte create mode 100644 front/src/Components/ReportMenu/ReportSubMenu.svelte create mode 100644 front/src/Components/images/logo-WA-min.png create mode 100644 front/src/Phaser/Game/GameMapPropertiesListener.ts delete mode 100644 front/src/Phaser/Menu/MenuScene.ts delete mode 100644 front/src/Phaser/Menu/ReportMenu.ts create mode 100644 front/src/Stores/Errors/MediaStreamConstraintsError.ts rename front/style/{inputTextGlobalMessageSvelte-Style.scss => TextGlobalMessageSvelte-Style.scss} (56%) create mode 100644 maps/tests/Metadata/customIframeMenu.html create mode 100644 maps/tests/Metadata/customIframeMenuApi.html create mode 100644 maps/tests/Metadata/customMenu.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d23f4b9..710b85fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ ## Version develop +### Updates +- New scripting API features : + - Use `WA.ui.registerMenuCommand(commandDescriptor: string, options: MenuOptions): Menu` to add a custom menu or an iframe to the menu. + +## Version 1.4.14 + ### Updates - New scripting API features : - Use `WA.room.loadTileset(url: string) : Promise` to load a tileset from a JSON file. diff --git a/README.md b/README.md index 322f06ba..ba9e70ce 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,9 @@ Note: on some OSes, you will need to add this line to your `/etc/hosts` file: 127.0.0.1 workadventure.localhost ``` +Note: If on the first run you get a page with "network error". Try to ``docker-compose stop`` , then ``docker-compose start``. +Note 2: If you are still getting "network error". Make sure you are authorizing the self-signed certificate by entering https://pusher.workadventure.testing and accepting them. + ### MacOS developers, your environment with Vagrant If you are using MacOS, you can increase Docker performance using Vagrant. If you want more explanations, you can read [this medium article](https://medium.com/better-programming/vagrant-to-increase-docker-performance-with-macos-25b354b0c65c). diff --git a/back/package.json b/back/package.json index 8a1e445e..bb54d624 100644 --- a/back/package.json +++ b/back/package.json @@ -40,7 +40,7 @@ }, "homepage": "https://github.com/thecodingmachine/workadventure#readme", "dependencies": { - "@workadventure/tiled-map-type-guard": "^1.0.0", + "@workadventure/tiled-map-type-guard": "^1.0.2", "axios": "^0.21.1", "busboy": "^0.3.1", "circular-json": "^0.5.9", @@ -54,7 +54,6 @@ "prom-client": "^12.0.0", "query-string": "^6.13.3", "redis": "^3.1.2", - "systeminformation": "^4.31.1", "uWebSockets.js": "uNetworking/uWebSockets.js#v18.5.0", "uuidv4": "^6.0.7" }, diff --git a/back/src/Services/VariablesManager.ts b/back/src/Services/VariablesManager.ts index e8aaef25..915c6c05 100644 --- a/back/src/Services/VariablesManager.ts +++ b/back/src/Services/VariablesManager.ts @@ -1,7 +1,12 @@ /** * Handles variables shared between the scripting API and the server. */ -import { ITiledMap, ITiledMapObject, ITiledMapObjectLayer } from "@workadventure/tiled-map-type-guard/dist"; +import { + ITiledMap, + ITiledMapLayer, + ITiledMapObject, + ITiledMapObjectLayer, +} from "@workadventure/tiled-map-type-guard/dist"; import { User } from "_Model/User"; import { variablesRepository } from "./Repository/VariablesRepository"; import { redisClient } from "./RedisClient"; @@ -83,25 +88,33 @@ export class VariablesManager { private static findVariablesInMap(map: ITiledMap): Map { const objects = new Map(); for (const layer of map.layers) { - if (layer.type === "objectgroup") { - for (const object of (layer as ITiledMapObjectLayer).objects) { - if (object.type === "variable") { - if (object.template) { - console.warn( - 'Warning, a variable object is using a Tiled "template". WorkAdventure does not support objects generated from Tiled templates.' - ); - continue; - } - - // We store a copy of the object (to make it immutable) - objects.set(object.name, this.iTiledObjectToVariable(object)); - } - } - } + this.recursiveFindVariablesInLayer(layer, objects); } return objects; } + private static recursiveFindVariablesInLayer(layer: ITiledMapLayer, objects: Map): void { + if (layer.type === "objectgroup") { + for (const object of layer.objects) { + if (object.type === "variable") { + if (object.template) { + console.warn( + 'Warning, a variable object is using a Tiled "template". WorkAdventure does not support objects generated from Tiled templates.' + ); + continue; + } + + // We store a copy of the object (to make it immutable) + objects.set(object.name, this.iTiledObjectToVariable(object)); + } + } + } else if (layer.type === "group") { + for (const innerLayer of layer.layers) { + this.recursiveFindVariablesInLayer(innerLayer, objects); + } + } + } + private static iTiledObjectToVariable(object: ITiledMapObject): Variable { const variable: Variable = {}; diff --git a/back/yarn.lock b/back/yarn.lock index 98d675ee..64dcb9ce 100644 --- a/back/yarn.lock +++ b/back/yarn.lock @@ -194,10 +194,10 @@ semver "^7.3.2" tsutils "^3.17.1" -"@workadventure/tiled-map-type-guard@^1.0.0": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@workadventure/tiled-map-type-guard/-/tiled-map-type-guard-1.0.0.tgz#02524602ee8b2688429a1f56df1d04da3fc171ba" - integrity sha512-Mc0SE128otQnYlScQWVaQVyu1+CkailU/FTBh09UTrVnBAhyMO+jIn9vT9+Dv244xq+uzgQDpXmiVdjgrYFQ+A== +"@workadventure/tiled-map-type-guard@^1.0.2": + version "1.0.2" + resolved "https://registry.yarnpkg.com/@workadventure/tiled-map-type-guard/-/tiled-map-type-guard-1.0.2.tgz#4171550f6cd71be19791faef48360d65d698bcb0" + integrity sha512-RCtygGV5y9cb7QoyGMINBE9arM5pyXjkxvXgA5uXEv4GDbXKorhFim/rHgwbVR+eFnVF3rDgWbRnk3DIaHt+lQ== dependencies: generic-type-guard "^3.4.1" @@ -554,7 +554,7 @@ chokidar@^3.4.0: optionalDependencies: fsevents "~2.1.2" -chownr@^1.1.1: +chownr@^1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.4.tgz#6fc9d7b42d32a583596337666e7d08084da2cc6b" integrity sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg== @@ -1159,7 +1159,7 @@ fragment-cache@^0.2.1: dependencies: map-cache "^0.2.2" -fs-minipass@^1.2.5: +fs-minipass@^1.2.7: version "1.2.7" resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.7.tgz#ccff8570841e7fe4265693da88936c55aed7f7c7" integrity sha512-GWSSJGFy4e9GUeCcbIkED+bgAoFyj7XF1mV8rma3QW4NIqX9Kyx79N/PF61H5udOV3aY1IaMLs6pGbH71nlCTA== @@ -1969,7 +1969,7 @@ minimist@^1.1.3, minimist@^1.2.0, minimist@^1.2.5: resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== -minipass@^2.6.0, minipass@^2.8.6, minipass@^2.9.0: +minipass@^2.6.0, minipass@^2.9.0: version "2.9.0" resolved "https://registry.yarnpkg.com/minipass/-/minipass-2.9.0.tgz#e713762e7d3e32fed803115cf93e04bca9fcc9a6" integrity sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg== @@ -1977,7 +1977,7 @@ minipass@^2.6.0, minipass@^2.8.6, minipass@^2.9.0: safe-buffer "^5.1.2" yallist "^3.0.0" -minizlib@^1.2.1: +minizlib@^1.3.3: version "1.3.3" resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-1.3.3.tgz#2290de96818a34c29551c8a8d301216bd65a861d" integrity sha512-6ZYMOEnmVsdCeTJVE0W9ZD+pVnE8h9Hma/iOwwRDsdQoePpoX56/8B6z3P9VNwppJuBKNRuFDRNRqRWexT9G9Q== @@ -1992,7 +1992,7 @@ mixin-deep@^1.2.0: for-in "^1.0.2" is-extendable "^1.0.1" -mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@^0.5.3: +mkdirp@^0.5.1, mkdirp@^0.5.3, mkdirp@^0.5.5: version "0.5.5" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def" integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ== @@ -2290,9 +2290,9 @@ path-key@^3.0.0, path-key@^3.1.0: integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== 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== + version "1.0.7" + resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" + integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== path-type@^1.0.0: version "1.1.0" @@ -2578,7 +2578,7 @@ rxjs@^6.6.7: dependencies: tslib "^1.9.0" -safe-buffer@^5.0.1, safe-buffer@^5.1.2: +safe-buffer@^5.0.1, safe-buffer@^5.1.2, safe-buffer@^5.2.1: version "5.2.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== @@ -2962,11 +2962,6 @@ supports-color@^7.1.0: dependencies: has-flag "^4.0.0" -systeminformation@^4.31.1: - version "4.31.1" - resolved "https://registry.yarnpkg.com/systeminformation/-/systeminformation-4.31.1.tgz#2e02c26987494d4b6a4d2d83138724593bc98d50" - integrity sha512-dVCDWNMN8ncMZo5vbMCA5dpAdMgzafK2ucuJy5LFmGtp1cG6farnPg8QNvoOSky9SkFoEX1Aw0XhcOFV6TnLYA== - table@^5.2.3: version "5.4.6" resolved "https://registry.yarnpkg.com/table/-/table-5.4.6.tgz#1292d19500ce3f86053b05f0e8e7e4a3bb21079e" @@ -2978,17 +2973,17 @@ table@^5.2.3: string-width "^3.0.0" tar@^4.4.2: - version "4.4.13" - resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.13.tgz#43b364bc52888d555298637b10d60790254ab525" - integrity sha512-w2VwSrBoHa5BsSyH+KxEqeQBAllHhccyMFVHtGtdMpF4W7IRWfZjFiQceJPChOeTsSDVUpER2T8FA93pr0L+QA== + version "4.4.19" + resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.19.tgz#2e4d7263df26f2b914dee10c825ab132123742f3" + integrity sha512-a20gEsvHnWe0ygBY8JbxoM4w3SJdhc7ZAuxkLqh+nvNQN2IOt0B5lLgM490X5Hl8FF0dl0tOf2ewFYAlIFgzVA== dependencies: - chownr "^1.1.1" - fs-minipass "^1.2.5" - minipass "^2.8.6" - minizlib "^1.2.1" - mkdirp "^0.5.0" - safe-buffer "^5.1.2" - yallist "^3.0.3" + chownr "^1.1.4" + fs-minipass "^1.2.7" + minipass "^2.9.0" + minizlib "^1.3.3" + mkdirp "^0.5.5" + safe-buffer "^5.2.1" + yallist "^3.1.1" tdigest@^0.1.1: version "0.1.1" @@ -3282,7 +3277,7 @@ y18n@^3.2.0: resolved "https://registry.yarnpkg.com/y18n/-/y18n-3.2.2.tgz#85c901bd6470ce71fc4bb723ad209b70f7f28696" integrity sha512-uGZHXkHnhF0XeeAPgnKfPv1bgKAYyVvmNL1xlKsPYZPaIHxGti2hHqvOCQv71XMsLxu1QjergkqogUnms5D3YQ== -yallist@^3.0.0, yallist@^3.0.3: +yallist@^3.0.0, yallist@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd" integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g== diff --git a/benchmark/package-lock.json b/benchmark/package-lock.json index 2d25c58a..5d9ef0c6 100644 --- a/benchmark/package-lock.json +++ b/benchmark/package-lock.json @@ -429,9 +429,9 @@ "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" }, "path-parse": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", - "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==" + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==" }, "path-type": { "version": "1.1.0", diff --git a/benchmark/yarn.lock b/benchmark/yarn.lock index 8dcffe52..92541451 100644 --- a/benchmark/yarn.lock +++ b/benchmark/yarn.lock @@ -315,8 +315,8 @@ path-is-absolute@^1.0.0: 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" + version "1.0.7" + resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" path-type@^1.0.0: version "1.1.0" diff --git a/deeployer.libsonnet b/deeployer.libsonnet index 494c72b8..a2e8970a 100644 --- a/deeployer.libsonnet +++ b/deeployer.libsonnet @@ -101,6 +101,7 @@ }, "redis": { "image": "redis:6", + "ports": [6379] } }, "config": { diff --git a/docs/maps/api-deprecated.md b/docs/maps/api-deprecated.md index 930caebe..f2b582a5 100644 --- a/docs/maps/api-deprecated.md +++ b/docs/maps/api-deprecated.md @@ -18,3 +18,4 @@ The list of functions below is **deprecated**. You should not use those but. use - Method `WA.onChatMessage` is deprecated. It has been renamed to `WA.chat.onChatMessage`. - Method `WA.onEnterZone` is deprecated. It has been renamed to `WA.room.onEnterZone`. - Method `WA.onLeaveZone` is deprecated. It has been renamed to `WA.room.onLeaveZone`. +- Method `WA.ui.registerMenuCommand` parameter `callback` is deprecated. Use `WA.ui.registerMenuCommand(commandDescriptor: string, options: MenuOptions)`. \ No newline at end of file diff --git a/docs/maps/api-state.md b/docs/maps/api-state.md index 634b47e1..1cc4f7fb 100644 --- a/docs/maps/api-state.md +++ b/docs/maps/api-state.md @@ -9,6 +9,7 @@ Moreover, `WA.state` functions can be used to persist this state across reloads. ``` WA.state.saveVariable(key : string, data : unknown): void WA.state.loadVariable(key : string) : unknown +WA.state.hasVariable(key : string) : boolean WA.state.onVariableChange(key : string).subscribe((data: unknown) => {}) : Subscription WA.state.[any property]: unknown ``` diff --git a/docs/maps/api-ui.md b/docs/maps/api-ui.md index e4b9425d..dc701500 100644 --- a/docs/maps/api-ui.md +++ b/docs/maps/api-ui.md @@ -68,25 +68,53 @@ WA.room.onLeaveZone('myZone', () => { ### Add custom menu -```typescript -WA.ui.registerMenuCommand(menuCommand: string, callback: (menuCommand: string) => void): void ``` -Add a custom menu item containing the text `commandDescriptor` in the main menu. A click on the menu will trigger the `callback`. +WA.ui.registerMenuCommand(commandDescriptor: string, options: MenuOptions): Menu +``` +Add a custom menu item containing the text `commandDescriptor` in the navbar of the menu. +`options` attribute accepts an object with three properties : +- `callback : (commandDescriptor: string) => void` : A click on the custom menu will trigger the `callback`. +- `iframe: string` : A click on the custom menu will open the `iframe` inside the menu. +- `allowApi?: boolean` : Allow the iframe of the custom menu to use the Scripting API. + +Important : `options` accepts only `callback` or `iframe` not both. + Custom menu exist only until the map is unloaded, or you leave the iframe zone of the script. -Example: +
+
+ +
+
+ +
+
+Example: ```javascript +const menu = WA.ui.registerMenuCommand('menu test', + { + callback: () => { + WA.chat.sendChatMessage('test'); + } + }) -WA.ui.registerMenuCommand("test", () => { - WA.chat.sendChatMessage("test clicked", "menu cmd") -}) - +// Some time later, if you want to remove the menu: +menu.remove(); ``` -
- -
+Please note that `registerMenuCommand` returns an object of the `Menu` class. + +The `Menu` class contains a single method: `remove(): void`. This will obviously remove the menu when called. + +```javascript +class Menu { + /** + * Remove the menu + */ + remove() {}; +} +``` diff --git a/docs/maps/images/custom-menu-iframe.png b/docs/maps/images/custom-menu-iframe.png new file mode 100644 index 0000000000000000000000000000000000000000..9df2aa5fdd63353319ed2e2898111a9ec2f1604a GIT binary patch literal 14317 zcmeHtd0bQ1)^@D5ts_ON2#6>ar~@D%^APF)RY6o#WUe5@0)h}`NJ48>5Cjzk8A7Ni z$QS_`!W5Mu$dG`{W0c4kAV3HKLXvNvK-AY>Z+q|izTfZtsf1` z(32;O)~}IR1B1cVAN}d@X&7u(JPfvS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jiU-dIPXtE!=MrcoT7?niV9h?3}pau3_y&f^=sKRf+3G&Vq7;8{&99XwQ}ohTY9b}iHj=!wCQ zc0C75+!Z}{Ed?$M;4}=i1shT0IEWU9tEwbGpE@n$LjZK>I4F4F9wUhO$s-IjJpp}R zs;x$Mxae2zQWtOIvkExIwT1L0xzLeDb&tI+Pq4tmkaPB!oPBn$%BzA)tG5icF(JbG z179)aZVJXNH0QRS)kGgu=|$se->;yix)?V0S~tSGq(JyeQ(t5t#a!-Qxv>)?To@S& zOM(K_p#TC~?wR7MY*#!P5WFfM3q(z0RfGwZ1lVIpbZb)7Z?R*Gvr+S6B95^ljM}lL zM^vGvJk}|`pTA3pXbpzOxS7~>RLME>LvA;J=Q&RYRkeJlI}aXgHnRN_N&8#c6h?%D zTi=>X-TY22L&W#UlpSe!I&kiNC4ZkzR$TU&$(k!J$T!2}Xb)mu|d2RjVx*`)$ZiYxOLf} zK3)N@AtS{Fs)igb>12rMm>=z~kPQgE07<~6(iIl%&_#rh!W0 zQ!}5o8oqYo#VHOnozMTW%}nNz5_(|mWorkAdventure -
@@ -62,31 +61,6 @@
- -
diff --git a/front/dist/resources/html/gameMenu.html b/front/dist/resources/html/gameMenu.html index 73c62918..e69de29b 100644 --- a/front/dist/resources/html/gameMenu.html +++ b/front/dist/resources/html/gameMenu.html @@ -1,78 +0,0 @@ - - - diff --git a/front/dist/resources/html/gameMenuIcon.html b/front/dist/resources/html/gameMenuIcon.html deleted file mode 100644 index 22fe9867..00000000 --- a/front/dist/resources/html/gameMenuIcon.html +++ /dev/null @@ -1,28 +0,0 @@ - -
-
- -
-
\ No newline at end of file diff --git a/front/dist/resources/html/gameQualityMenu.html b/front/dist/resources/html/gameQualityMenu.html deleted file mode 100644 index babb3f0e..00000000 --- a/front/dist/resources/html/gameQualityMenu.html +++ /dev/null @@ -1,81 +0,0 @@ - - - diff --git a/front/dist/resources/html/gameReport.html b/front/dist/resources/html/gameReport.html deleted file mode 100644 index d35ae556..00000000 --- a/front/dist/resources/html/gameReport.html +++ /dev/null @@ -1,115 +0,0 @@ - - -
-
- -

Moderate

-

What action do you want to take?

-
-
-

Block:

-

Block any communication from and to this user. This can be reverted.

-
- -
-
-
-

Report:

-

Send a report message to the administrators of this room. They may later ban this user.

-
-
-
Your message:
- -

-
-
- -
-
-
-
- diff --git a/front/dist/resources/html/gameShare.html b/front/dist/resources/html/gameShare.html deleted file mode 100644 index 404c8680..00000000 --- a/front/dist/resources/html/gameShare.html +++ /dev/null @@ -1,96 +0,0 @@ - - - diff --git a/front/dist/resources/logos/tcm_full.png b/front/dist/resources/logos/tcm_full.png new file mode 100644 index 0000000000000000000000000000000000000000..3ea27990a3ca3cfd62f1866b766d92d407709a46 GIT binary patch literal 300 zcmV+{0n`48P)sgDDXIM|1Dp| zmbyeoV8V);i2YXtGwvUAa6OXpc(I5BlZpe=e#L|`)0nGQe!HC7{xdq`c;SNf%l|DR zO%vl3%D$^I>gH-3kbP*;zq@gog-GzZChK)p7q}jY{C8p4l`AQ+)1LE}UWDR>;!c)b zJI`-5Qf1)ITE-zS+`tiDcJM^))FyL1*W0XTW;~kO!{X5ZLVQKHxBlLdx_JxGp$wj` MelF{r5}Fto0L7nB_y7O^ literal 0 HcmV?d00001 diff --git a/front/dist/resources/logos/logo-WA-min.png b/front/dist/static/images/logo-WA-min.png similarity index 100% rename from front/dist/resources/logos/logo-WA-min.png rename to front/dist/static/images/logo-WA-min.png diff --git a/front/src/Api/Events/IframeEvent.ts b/front/src/Api/Events/IframeEvent.ts index ed723241..861acc22 100644 --- a/front/src/Api/Events/IframeEvent.ts +++ b/front/src/Api/Events/IframeEvent.ts @@ -15,7 +15,6 @@ import type { SetPropertyEvent } from "./setPropertyEvent"; import type { LoadSoundEvent } from "./LoadSoundEvent"; import type { PlaySoundEvent } from "./PlaySoundEvent"; import type { MenuItemClickedEvent } from "./ui/MenuItemClickedEvent"; -import type { MenuItemRegisterEvent } from "./ui/MenuItemRegisterEvent"; import type { HasPlayerMovedEvent } from "./HasPlayerMovedEvent"; import type { SetTilesEvent } from "./SetTilesEvent"; import type { SetVariableEvent } from "./SetVariableEvent"; @@ -33,6 +32,7 @@ import type { TriggerActionMessageEvent, } from "./ui/TriggerActionMessageEvent"; import { isMessageReferenceEvent, isTriggerActionMessageEvent } from "./ui/TriggerActionMessageEvent"; +import type { MenuRegisterEvent, UnregisterMenuEvent } from "./ui/MenuRegisterEvent"; export interface TypedMessageEvent extends MessageEvent { data: T; @@ -63,7 +63,8 @@ export type IframeEventMap = { stopSound: null; getState: undefined; loadTileset: LoadTilesetEvent; - registerMenuCommand: MenuItemRegisterEvent; + registerMenu: MenuRegisterEvent; + unregisterMenu: UnregisterMenuEvent; setTiles: SetTilesEvent; modifyEmbeddedWebsite: Partial; // Note: name should be compulsory in fact }; diff --git a/front/src/Api/Events/SetVariableEvent.ts b/front/src/Api/Events/SetVariableEvent.ts index 3b4e9c85..3e2303b3 100644 --- a/front/src/Api/Events/SetVariableEvent.ts +++ b/front/src/Api/Events/SetVariableEvent.ts @@ -1,5 +1,4 @@ import * as tg from "generic-type-guard"; -import { isMenuItemRegisterEvent } from "./ui/MenuItemRegisterEvent"; export const isSetVariableEvent = new tg.IsInterface() .withProperties({ diff --git a/front/src/Api/Events/ui/MenuItemRegisterEvent.ts b/front/src/Api/Events/ui/MenuItemRegisterEvent.ts deleted file mode 100644 index 404bdb13..00000000 --- a/front/src/Api/Events/ui/MenuItemRegisterEvent.ts +++ /dev/null @@ -1,26 +0,0 @@ -import * as tg from "generic-type-guard"; -import { Subject } from "rxjs"; - -export const isMenuItemRegisterEvent = new tg.IsInterface() - .withProperties({ - menutItem: tg.isString, - }) - .get(); -/** - * A message sent from the iFrame to the game to add a new menu item. - */ -export type MenuItemRegisterEvent = tg.GuardedType; - -export const isMenuItemRegisterIframeEvent = new tg.IsInterface() - .withProperties({ - type: tg.isSingletonString("registerMenuCommand"), - data: isMenuItemRegisterEvent, - }) - .get(); - -const _registerMenuCommandStream: Subject = new Subject(); -export const registerMenuCommandStream = _registerMenuCommandStream.asObservable(); - -export function handleMenuItemRegistrationEvent(event: MenuItemRegisterEvent) { - _registerMenuCommandStream.next(event.menutItem); -} diff --git a/front/src/Api/Events/ui/MenuRegisterEvent.ts b/front/src/Api/Events/ui/MenuRegisterEvent.ts new file mode 100644 index 00000000..f620745f --- /dev/null +++ b/front/src/Api/Events/ui/MenuRegisterEvent.ts @@ -0,0 +1,31 @@ +import * as tg from "generic-type-guard"; + +/** + * A message sent from a script to the game to remove a custom menu from the menu + */ +export const isUnregisterMenuEvent = new tg.IsInterface() + .withProperties({ + name: tg.isString, + }) + .get(); + +export type UnregisterMenuEvent = tg.GuardedType; + +export const isMenuRegisterOptions = new tg.IsInterface() + .withProperties({ + allowApi: tg.isBoolean, + }) + .get(); + +/** + * A message sent from a script to the game to add a custom menu from the menu + */ +export const isMenuRegisterEvent = new tg.IsInterface() + .withProperties({ + name: tg.isString, + iframe: tg.isUnion(tg.isString, tg.isUndefined), + options: isMenuRegisterOptions, + }) + .get(); + +export type MenuRegisterEvent = tg.GuardedType; diff --git a/front/src/Api/IframeListener.ts b/front/src/Api/IframeListener.ts index 4dde1b7d..140d2f34 100644 --- a/front/src/Api/IframeListener.ts +++ b/front/src/Api/IframeListener.ts @@ -29,11 +29,12 @@ import { isSetPropertyEvent, SetPropertyEvent } from "./Events/setPropertyEvent" import { isLayerEvent, LayerEvent } from "./Events/LayerEvent"; import type { HasPlayerMovedEvent } from "./Events/HasPlayerMovedEvent"; import { isLoadPageEvent } from "./Events/LoadPageEvent"; -import { handleMenuItemRegistrationEvent, isMenuItemRegisterIframeEvent } from "./Events/ui/MenuItemRegisterEvent"; +import { isMenuRegisterEvent, isUnregisterMenuEvent } from "./Events/ui/MenuRegisterEvent"; import { SetTilesEvent, isSetTilesEvent } from "./Events/SetTilesEvent"; import type { SetVariableEvent } from "./Events/SetVariableEvent"; import { ModifyEmbeddedWebsiteEvent, isEmbeddedWebsiteEvent } from "./Events/EmbeddedWebsiteEvent"; import { EmbeddedWebsite } from "./iframe/Room/EmbeddedWebsite"; +import { handleMenuRegistrationEvent, handleMenuUnregisterEvent } from "../Stores/MenuStore"; type AnswererCallback = ( query: IframeQueryMap[T]["query"], @@ -93,12 +94,6 @@ class IframeListener { private readonly _setPropertyStream: Subject = new Subject(); public readonly setPropertyStream = this._setPropertyStream.asObservable(); - private readonly _registerMenuCommandStream: Subject = new Subject(); - public readonly registerMenuCommandStream = this._registerMenuCommandStream.asObservable(); - - private readonly _unregisterMenuCommandStream: Subject = new Subject(); - public readonly unregisterMenuCommandStream = this._unregisterMenuCommandStream.asObservable(); - private readonly _playSoundStream: Subject = new Subject(); public readonly playSoundStream = this._playSoundStream.asObservable(); @@ -260,17 +255,23 @@ class IframeListener { this._removeBubbleStream.next(); } else if (payload.type == "onPlayerMove") { this.sendPlayerMove = true; - } else if (isMenuItemRegisterIframeEvent(payload)) { - const data = payload.data.menutItem; - // @ts-ignore - this.iframeCloseCallbacks.get(iframe).push(() => { - this._unregisterMenuCommandStream.next(data); - }); - handleMenuItemRegistrationEvent(payload.data); } else if (payload.type == "setTiles" && isSetTilesEvent(payload.data)) { this._setTilesStream.next(payload.data); } else if (payload.type == "modifyEmbeddedWebsite" && isEmbeddedWebsiteEvent(payload.data)) { this._modifyEmbeddedWebsiteStream.next(payload.data); + } else if (payload.type == "registerMenu" && isMenuRegisterEvent(payload.data)) { + const dataName = payload.data.name; + this.iframeCloseCallbacks.get(iframe)?.push(() => { + handleMenuUnregisterEvent(dataName); + }); + handleMenuRegistrationEvent( + payload.data.name, + payload.data.iframe, + foundSrc, + payload.data.options + ); + } else if (payload.type == "unregisterMenu" && isUnregisterMenuEvent(payload.data)) { + handleMenuUnregisterEvent(payload.data.name); } } }, @@ -293,57 +294,67 @@ class IframeListener { this.iframes.delete(iframe); } - registerScript(scriptUrl: string): void { - console.log("Loading map related script at ", scriptUrl); + registerScript(scriptUrl: string): Promise { + return new Promise((resolve, reject) => { + console.log("Loading map related script at ", scriptUrl); - if (!process.env.NODE_ENV || process.env.NODE_ENV === "development") { - // Using external iframe mode ( - const iframe = document.createElement("iframe"); - iframe.id = IframeListener.getIFrameId(scriptUrl); - iframe.style.display = "none"; - iframe.src = "/iframe.html?script=" + encodeURIComponent(scriptUrl); + if (!process.env.NODE_ENV || process.env.NODE_ENV === "development") { + // Using external iframe mode ( + const iframe = document.createElement("iframe"); + iframe.id = IframeListener.getIFrameId(scriptUrl); + iframe.style.display = "none"; + iframe.src = "/iframe.html?script=" + encodeURIComponent(scriptUrl); - // We are putting a sandbox on this script because it will run in the same domain as the main website. - iframe.sandbox.add("allow-scripts"); - iframe.sandbox.add("allow-top-navigation-by-user-activation"); + // We are putting a sandbox on this script because it will run in the same domain as the main website. + iframe.sandbox.add("allow-scripts"); + iframe.sandbox.add("allow-top-navigation-by-user-activation"); - document.body.prepend(iframe); + iframe.addEventListener("load", () => { + resolve(); + }); - this.scripts.set(scriptUrl, iframe); - this.registerIframe(iframe); - } else { - // production code - const iframe = document.createElement("iframe"); - iframe.id = IframeListener.getIFrameId(scriptUrl); - iframe.style.display = "none"; + document.body.prepend(iframe); - // We are putting a sandbox on this script because it will run in the same domain as the main website. - iframe.sandbox.add("allow-scripts"); - iframe.sandbox.add("allow-top-navigation-by-user-activation"); + this.scripts.set(scriptUrl, iframe); + this.registerIframe(iframe); + } else { + // production code + const iframe = document.createElement("iframe"); + iframe.id = IframeListener.getIFrameId(scriptUrl); + iframe.style.display = "none"; - //iframe.src = "data:text/html;charset=utf-8," + escape(html); - iframe.srcdoc = - "\n" + - "\n" + - '\n' + - "\n" + - '\n' + - '\n' + - "\n" + - "\n" + - "\n"; + // We are putting a sandbox on this script because it will run in the same domain as the main website. + iframe.sandbox.add("allow-scripts"); + iframe.sandbox.add("allow-top-navigation-by-user-activation"); - document.body.prepend(iframe); + //iframe.src = "data:text/html;charset=utf-8," + escape(html); + iframe.srcdoc = + "\n" + + "\n" + + '\n' + + "\n" + + '\n' + + '\n' + + "\n" + + "\n" + + "\n"; - this.scripts.set(scriptUrl, iframe); - this.registerIframe(iframe); - } + iframe.addEventListener("load", () => { + resolve(); + }); + + document.body.prepend(iframe); + + this.scripts.set(scriptUrl, iframe); + this.registerIframe(iframe); + } + }); } private getBaseUrl(src: string, source: MessageEventSource | null): string { diff --git a/front/src/Api/iframe/Sound/Sound.ts b/front/src/Api/iframe/Sound/Sound.ts index 3bb3251a..132176c2 100644 --- a/front/src/Api/iframe/Sound/Sound.ts +++ b/front/src/Api/iframe/Sound/Sound.ts @@ -1,38 +1,35 @@ -import {sendToWorkadventure} from "../IframeApiContribution"; -import type {LoadSoundEvent} from "../../Events/LoadSoundEvent"; -import type {PlaySoundEvent} from "../../Events/PlaySoundEvent"; -import type {StopSoundEvent} from "../../Events/StopSoundEvent"; +import { sendToWorkadventure } from "../IframeApiContribution"; +import type { LoadSoundEvent } from "../../Events/LoadSoundEvent"; +import type { PlaySoundEvent } from "../../Events/PlaySoundEvent"; +import type { StopSoundEvent } from "../../Events/StopSoundEvent"; import SoundConfig = Phaser.Types.Sound.SoundConfig; export class Sound { constructor(private url: string) { sendToWorkadventure({ - "type": 'loadSound', - "data": { + type: "loadSound", + data: { url: this.url, - } as LoadSoundEvent - + } as LoadSoundEvent, }); } - public play(config: SoundConfig) { + public play(config: SoundConfig | undefined) { sendToWorkadventure({ - "type": 'playSound', - "data": { + type: "playSound", + data: { url: this.url, - config - } as PlaySoundEvent - + config, + } as PlaySoundEvent, }); return this.url; } public stop() { sendToWorkadventure({ - "type": 'stopSound', - "data": { + type: "stopSound", + data: { url: this.url, - } as StopSoundEvent - + } as StopSoundEvent, }); return this.url; } diff --git a/front/src/Api/iframe/Ui/Menu.ts b/front/src/Api/iframe/Ui/Menu.ts new file mode 100644 index 00000000..c0fe772e --- /dev/null +++ b/front/src/Api/iframe/Ui/Menu.ts @@ -0,0 +1,17 @@ +import { sendToWorkadventure } from "../IframeApiContribution"; + +export class Menu { + constructor(private menuName: string) {} + + /** + * remove the menu + */ + public remove() { + sendToWorkadventure({ + type: "unregisterMenu", + data: { + name: this.menuName, + }, + }); + } +} diff --git a/front/src/Api/iframe/state.ts b/front/src/Api/iframe/state.ts index 3b551864..a875f3e0 100644 --- a/front/src/Api/iframe/state.ts +++ b/front/src/Api/iframe/state.ts @@ -62,6 +62,10 @@ export class WorkadventureStateCommands extends IframeApiContribution { let subject = variableSubscribers.get(key); if (subject === undefined) { @@ -85,6 +89,12 @@ const proxyCommand = new Proxy(new WorkadventureStateCommands(), { target.saveVariable(p.toString(), value); return true; }, + has(target: WorkadventureStateCommands, p: PropertyKey): boolean { + if (p in target) { + return true; + } + return target.hasVariable(p.toString()); + }, }) as WorkadventureStateCommands & { [key: string]: unknown }; export default proxyCommand; diff --git a/front/src/Api/iframe/ui.ts b/front/src/Api/iframe/ui.ts index ab5b2007..c4d40d16 100644 --- a/front/src/Api/iframe/ui.ts +++ b/front/src/Api/iframe/ui.ts @@ -6,6 +6,8 @@ import type { ButtonClickedCallback, ButtonDescriptor } from "./Ui/ButtonDescrip import { Popup } from "./Ui/Popup"; import { ActionMessage } from "./Ui/ActionMessage"; import { isMessageReferenceEvent } from "../Events/ui/TriggerActionMessageEvent"; +import { Menu } from "./Ui/Menu"; +import type { RequireOnlyOne } from "../types"; let popupId = 0; const popups: Map = new Map(); @@ -14,9 +16,18 @@ const popupCallbacks: Map> = new Map< Map >(); +const menus: Map = new Map(); const menuCallbacks: Map void> = new Map(); const actionMessages = new Map(); +interface MenuDescriptor { + callback?: (commandDescriptor: string) => void; + iframe?: string; + allowApi?: boolean; +} + +export type MenuOptions = RequireOnlyOne; + interface ZonedPopupOptions { zone: string; objectLayerName?: string; @@ -52,6 +63,10 @@ export class WorkAdventureUiCommands extends IframeApiContribution { const callback = menuCallbacks.get(event.menuItem); + const menu = menus.get(event.menuItem); + if (menu === undefined) { + throw new Error('Could not find menu named "' + event.menuItem + '"'); + } if (callback) { callback(event.menuItem); } @@ -104,14 +119,53 @@ export class WorkAdventureUiCommands extends IframeApiContribution void) { - menuCallbacks.set(commandDescriptor, callback); - sendToWorkadventure({ - type: "registerMenuCommand", - data: { - menutItem: commandDescriptor, - }, - }); + registerMenuCommand(commandDescriptor: string, options: MenuOptions | ((commandDescriptor: string) => void)): Menu { + const menu = new Menu(commandDescriptor); + + if (typeof options === "function") { + menuCallbacks.set(commandDescriptor, options); + sendToWorkadventure({ + type: "registerMenu", + data: { + name: commandDescriptor, + options: { + allowApi: false, + }, + }, + }); + } else { + options.allowApi = options.allowApi === undefined ? options.iframe !== undefined : options.allowApi; + + if (options.iframe !== undefined) { + sendToWorkadventure({ + type: "registerMenu", + data: { + name: commandDescriptor, + iframe: options.iframe, + options: { + allowApi: options.allowApi, + }, + }, + }); + } else if (options.callback !== undefined) { + menuCallbacks.set(commandDescriptor, options.callback); + sendToWorkadventure({ + type: "registerMenu", + data: { + name: commandDescriptor, + options: { + allowApi: options.allowApi, + }, + }, + }); + } else { + throw new Error( + "When adding a menu with WA.ui.registerMenuCommand, you must pass either an iframe or a callback" + ); + } + } + menus.set(commandDescriptor, menu); + return menu; } displayBubble(): void { diff --git a/front/src/Api/types.ts b/front/src/Api/types.ts new file mode 100644 index 00000000..7d1a2107 --- /dev/null +++ b/front/src/Api/types.ts @@ -0,0 +1,4 @@ +export type RequireOnlyOne = Pick> & + { + [K in keys]-?: Required> & Partial, undefined>>; + }[keys]; diff --git a/front/src/Components/App.svelte b/front/src/Components/App.svelte index d65f699e..8b033e5f 100644 --- a/front/src/Components/App.svelte +++ b/front/src/Components/App.svelte @@ -1,4 +1,6 @@
@@ -55,22 +62,22 @@ Switch to presentation mode {/if}
-
- {#if $requestedScreenSharingState} +
+ {#if $requestedScreenSharingState && !isSilent} Start screen sharing {:else} Stop screen sharing {/if}
-
- {#if $requestedCameraState} +
+ {#if $requestedCameraState && !isSilent} Turn on webcam {:else} Turn off webcam {/if}
-
- {#if $requestedMicrophoneState} +
+ {#if $requestedMicrophoneState && !isSilent} Turn on microphone {:else} Turn off microphone diff --git a/front/src/Components/ConsoleGlobalMessageManager/ConsoleGlobalMessageManager.svelte b/front/src/Components/ConsoleGlobalMessageManager/ConsoleGlobalMessageManager.svelte deleted file mode 100644 index c1811650..00000000 --- a/front/src/Components/ConsoleGlobalMessageManager/ConsoleGlobalMessageManager.svelte +++ /dev/null @@ -1,152 +0,0 @@ - - - - -
- -
-
-

Global Message

- -
-
- {#if inputSendTextActive} - - {/if} - {#if uploadMusicActive} - - {/if} -
- -
-
- - - - diff --git a/front/src/Components/Menu/AboutRoomSubMenu.svelte b/front/src/Components/Menu/AboutRoomSubMenu.svelte new file mode 100644 index 00000000..3ccc9669 --- /dev/null +++ b/front/src/Components/Menu/AboutRoomSubMenu.svelte @@ -0,0 +1,147 @@ + + +
+ +
+

Share the link of the room !

+ +
+

Information on the map

+
+

{mapName}

+

{mapDescription}

+

expandedMapCopyright = !expandedMapCopyright}>Copyrights of the map

+ +

expandedTilesetCopyright = !expandedTilesetCopyright}>Copyrights of the tilesets

+ +
+
+ + + \ No newline at end of file diff --git a/front/src/Components/ConsoleGlobalMessageManager/UploadAudioGlobalMessage.svelte b/front/src/Components/Menu/AudioGlobalMessage.svelte similarity index 81% rename from front/src/Components/ConsoleGlobalMessageManager/UploadAudioGlobalMessage.svelte rename to front/src/Components/Menu/AudioGlobalMessage.svelte index 91f462c8..1704e732 100644 --- a/front/src/Components/ConsoleGlobalMessageManager/UploadAudioGlobalMessage.svelte +++ b/front/src/Components/Menu/AudioGlobalMessage.svelte @@ -1,20 +1,15 @@ @@ -105,24 +94,17 @@ img { flex: 1 1 auto; - max-height: 80%; margin-bottom: 20px; } - p { - flex: 1 1 auto; - margin-bottom: 5px; - color: whitesmoke; font-size: 1rem; - &.err { color: #ce372b; } } - input { display: none; } diff --git a/front/src/Components/Menu/ContactSubMenu.svelte b/front/src/Components/Menu/ContactSubMenu.svelte new file mode 100644 index 00000000..6cca0609 --- /dev/null +++ b/front/src/Components/Menu/ContactSubMenu.svelte @@ -0,0 +1,15 @@ + + + + + \ No newline at end of file diff --git a/front/src/Components/Menu/CreateMapSubMenu.svelte b/front/src/Components/Menu/CreateMapSubMenu.svelte new file mode 100644 index 00000000..6cce71ac --- /dev/null +++ b/front/src/Components/Menu/CreateMapSubMenu.svelte @@ -0,0 +1,51 @@ + + +
+
+
+

Getting started

+

+ WorkAdventure allows you to create an online space to communicate spontaneously with others. + And it all starts with creating your own space. Choose from a large selection of prefabricated maps by our team. +

+ +
+
+

Create your map

+

You can also create your own custom map by following the step of the documentation.

+ +
+
+
+ + \ No newline at end of file diff --git a/front/src/Components/Menu/CustomSubMenu.svelte b/front/src/Components/Menu/CustomSubMenu.svelte new file mode 100644 index 00000000..f85499c3 --- /dev/null +++ b/front/src/Components/Menu/CustomSubMenu.svelte @@ -0,0 +1,33 @@ + + + + + + \ No newline at end of file diff --git a/front/src/Components/Menu/GlobalMessagesSubMenu.svelte b/front/src/Components/Menu/GlobalMessagesSubMenu.svelte new file mode 100644 index 00000000..8ec66de9 --- /dev/null +++ b/front/src/Components/Menu/GlobalMessagesSubMenu.svelte @@ -0,0 +1,118 @@ + + +
+
+
+ +
+
+ +
+
+
+ {#if inputSendTextActive} + + {/if} + {#if uploadAudioActive} + + {/if} +
+ +
+ + + + + \ No newline at end of file diff --git a/front/src/Components/Menu/Menu.svelte b/front/src/Components/Menu/Menu.svelte new file mode 100644 index 00000000..4086a9ae --- /dev/null +++ b/front/src/Components/Menu/Menu.svelte @@ -0,0 +1,154 @@ + + + + + + + + \ No newline at end of file diff --git a/front/src/Components/Menu/MenuIcon.svelte b/front/src/Components/Menu/MenuIcon.svelte index 241bf45f..2da9e870 100644 --- a/front/src/Components/Menu/MenuIcon.svelte +++ b/front/src/Components/Menu/MenuIcon.svelte @@ -1,33 +1,40 @@ + +
-
- -
+ open menu
diff --git a/front/src/Components/Menu/ProfileSubMenu.svelte b/front/src/Components/Menu/ProfileSubMenu.svelte new file mode 100644 index 00000000..39214b4f --- /dev/null +++ b/front/src/Components/Menu/ProfileSubMenu.svelte @@ -0,0 +1,116 @@ + + +
+ {#if $userIsConnected} +
+ {#if PROFILE_URL != undefined} + + {/if} +
+
+ +
+ {:else} +
+ Sing in +
+ {/if} +
+ + + +
+
+ +
+ +
+ + \ No newline at end of file diff --git a/front/src/Components/Menu/SettingsSubMenu.svelte b/front/src/Components/Menu/SettingsSubMenu.svelte new file mode 100644 index 00000000..4c0c62dd --- /dev/null +++ b/front/src/Components/Menu/SettingsSubMenu.svelte @@ -0,0 +1,140 @@ + + +
+
+

Game quality

+
+ +
+
+
+

Video quality

+
+ +
+
+
+

(Saving these settings will restart the game)

+ +
+
+ + +
+
+ + \ No newline at end of file diff --git a/front/src/Components/ConsoleGlobalMessageManager/InputTextGlobalMessage.svelte b/front/src/Components/Menu/TextGlobalMessage.svelte similarity index 69% rename from front/src/Components/ConsoleGlobalMessageManager/InputTextGlobalMessage.svelte rename to front/src/Components/Menu/TextGlobalMessage.svelte index 7baa8226..1749ba7d 100644 --- a/front/src/Components/ConsoleGlobalMessageManager/InputTextGlobalMessage.svelte +++ b/front/src/Components/Menu/TextGlobalMessage.svelte @@ -1,8 +1,7 @@
-
+
diff --git a/front/src/Components/MyCamera.svelte b/front/src/Components/MyCamera.svelte index ed4154a9..67826859 100644 --- a/front/src/Components/MyCamera.svelte +++ b/front/src/Components/MyCamera.svelte @@ -1,27 +1,11 @@
-
- {#if $localStreamStore.type === "success" && $localStreamStore.stream } - +
+ {#if $localStreamStore.type === "success" && $localStreamStore.stream} + {/if}
+
+ Silent zone +
diff --git a/front/src/Components/ReportMenu/BlockSubMenu.svelte b/front/src/Components/ReportMenu/BlockSubMenu.svelte new file mode 100644 index 00000000..0ec04abc --- /dev/null +++ b/front/src/Components/ReportMenu/BlockSubMenu.svelte @@ -0,0 +1,44 @@ + + +
+

Block

+

Block any communication from and to {userName}. This can be reverted.

+ +
+ + + \ No newline at end of file diff --git a/front/src/Components/ReportMenu/ReportMenu.svelte b/front/src/Components/ReportMenu/ReportMenu.svelte new file mode 100644 index 00000000..7594b1c9 --- /dev/null +++ b/front/src/Components/ReportMenu/ReportMenu.svelte @@ -0,0 +1,141 @@ + + + + +
+
+

Moderate {userName}

+
+ +
+
+
+
+ +
+
+ +
+
+
+ {#if blockActive} + + {:else if reportActive} + + {:else } +

ERROR : There is no action selected.

+ {/if} +
+
+ + \ No newline at end of file diff --git a/front/src/Components/ReportMenu/ReportSubMenu.svelte b/front/src/Components/ReportMenu/ReportSubMenu.svelte new file mode 100644 index 00000000..45167cc0 --- /dev/null +++ b/front/src/Components/ReportMenu/ReportSubMenu.svelte @@ -0,0 +1,55 @@ + + +
+

Report

+

Send a report message to the administrators of this room. They may later ban this user.

+
+
+ + +
+
+ +
+
+
+ + \ No newline at end of file diff --git a/front/src/Components/Video/PresentationLayout.svelte b/front/src/Components/Video/PresentationLayout.svelte index f68dd2f1..65a229f4 100644 --- a/front/src/Components/Video/PresentationLayout.svelte +++ b/front/src/Components/Video/PresentationLayout.svelte @@ -12,7 +12,9 @@
{#if $videoFocusStore } - + {#key $videoFocusStore.uniqueId} + + {/key} {/if}