Fixing linting

This commit is contained in:
David Négrier 2021-11-24 15:29:12 +01:00
parent d3bd99b5ee
commit 2cbf5b56af
12 changed files with 164 additions and 175 deletions

View File

@ -18,72 +18,62 @@ class AnalyticsClient {
} }
identifyUser(uuid: string, email: string | null) { identifyUser(uuid: string, email: string | null) {
this.posthogPromise this.posthogPromise?.then((posthog) => {
?.then((posthog) => {
posthog.identify(uuid, { uuid, email, wa: true }); posthog.identify(uuid, { uuid, email, wa: true });
}); });
} }
loggedWithSso() { loggedWithSso() {
this.posthogPromise this.posthogPromise?.then((posthog) => {
?.then((posthog) => {
posthog.capture("wa-logged-sso"); posthog.capture("wa-logged-sso");
}); });
} }
loggedWithToken() { loggedWithToken() {
this.posthogPromise this.posthogPromise?.then((posthog) => {
?.then((posthog) => {
posthog.capture("wa-logged-token"); posthog.capture("wa-logged-token");
}); });
} }
enteredRoom(roomId: string, roomGroup: string | null) { enteredRoom(roomId: string, roomGroup: string | null) {
this.posthogPromise this.posthogPromise?.then((posthog) => {
?.then((posthog) => {
posthog.capture("$pageView", { roomId, roomGroup }); posthog.capture("$pageView", { roomId, roomGroup });
posthog.capture("enteredRoom"); posthog.capture("enteredRoom");
}); });
} }
openedMenu() { openedMenu() {
this.posthogPromise this.posthogPromise?.then((posthog) => {
?.then((posthog) => {
posthog.capture("wa-opened-menu"); posthog.capture("wa-opened-menu");
}); });
} }
launchEmote(emote: string) { launchEmote(emote: string) {
this.posthogPromise this.posthogPromise?.then((posthog) => {
?.then((posthog) => {
posthog.capture("wa-emote-launch", { emote }); posthog.capture("wa-emote-launch", { emote });
}); });
} }
enteredJitsi(roomName: string, roomId: string) { enteredJitsi(roomName: string, roomId: string) {
this.posthogPromise this.posthogPromise?.then((posthog) => {
?.then((posthog) => {
posthog.capture("wa-entered-jitsi", { roomName, roomId }); posthog.capture("wa-entered-jitsi", { roomName, roomId });
}); });
} }
validationName() { validationName() {
this.posthogPromise this.posthogPromise?.then((posthog) => {
?.then((posthog) => {
posthog.capture("wa-name-validation"); posthog.capture("wa-name-validation");
}); });
} }
validationWoka(scene: string) { validationWoka(scene: string) {
this.posthogPromise this.posthogPromise?.then((posthog) => {
?.then((posthog) => {
posthog.capture("wa-woka-validation", { scene }); posthog.capture("wa-woka-validation", { scene });
}); });
} }
validationVideo() { validationVideo() {
this.posthogPromise this.posthogPromise?.then((posthog) => {
?.then((posthog) => {
posthog.capture("wa-video-validation"); posthog.capture("wa-video-validation");
}); });
} }

View File

@ -2,7 +2,7 @@ import * as tg from "generic-type-guard";
export const isCloseCoWebsite = new tg.IsInterface() export const isCloseCoWebsite = new tg.IsInterface()
.withProperties({ .withProperties({
id: tg.isOptional(tg.isString) id: tg.isOptional(tg.isString),
}) })
.get(); .get();

View File

@ -24,9 +24,7 @@ import type { EmbeddedWebsite } from "../iframe/Room/EmbeddedWebsite";
import { isCreateEmbeddedWebsiteEvent } from "./EmbeddedWebsiteEvent"; import { isCreateEmbeddedWebsiteEvent } from "./EmbeddedWebsiteEvent";
import type { LoadTilesetEvent } from "./LoadTilesetEvent"; import type { LoadTilesetEvent } from "./LoadTilesetEvent";
import { isLoadTilesetEvent } from "./LoadTilesetEvent"; import { isLoadTilesetEvent } from "./LoadTilesetEvent";
import type { import type { MessageReferenceEvent } from "./ui/TriggerActionMessageEvent";
MessageReferenceEvent,
} from "./ui/TriggerActionMessageEvent";
import { isMessageReferenceEvent, isTriggerActionMessageEvent } from "./ui/TriggerActionMessageEvent"; import { isMessageReferenceEvent, isTriggerActionMessageEvent } from "./ui/TriggerActionMessageEvent";
import type { MenuRegisterEvent, UnregisterMenuEvent } from "./ui/MenuRegisterEvent"; import type { MenuRegisterEvent, UnregisterMenuEvent } from "./ui/MenuRegisterEvent";
import type { ChangeLayerEvent } from "./ChangeLayerEvent"; import type { ChangeLayerEvent } from "./ChangeLayerEvent";
@ -117,19 +115,19 @@ export const iframeQueryMapTypeGuards = {
}, },
openCoWebsite: { openCoWebsite: {
query: isOpenCoWebsiteEvent, query: isOpenCoWebsiteEvent,
answer: isCoWebsite answer: isCoWebsite,
}, },
getCoWebsites: { getCoWebsites: {
query: tg.isUndefined, query: tg.isUndefined,
answer: tg.isArray(isCoWebsite) answer: tg.isArray(isCoWebsite),
}, },
closeCoWebsite: { closeCoWebsite: {
query: tg.isString, query: tg.isString,
answer: tg.isUndefined answer: tg.isUndefined,
}, },
closeCoWebsites: { closeCoWebsites: {
query: tg.isUndefined, query: tg.isUndefined,
answer: tg.isUndefined answer: tg.isUndefined,
}, },
triggerActionMessage: { triggerActionMessage: {
query: isTriggerActionMessageEvent, query: isTriggerActionMessageEvent,

View File

@ -5,7 +5,7 @@ export const isOpenCoWebsiteEvent = new tg.IsInterface()
url: tg.isString, url: tg.isString,
allowApi: tg.isOptional(tg.isBoolean), allowApi: tg.isOptional(tg.isBoolean),
allowPolicy: tg.isOptional(tg.isString), allowPolicy: tg.isOptional(tg.isString),
position: tg.isOptional(tg.isNumber) position: tg.isOptional(tg.isNumber),
}) })
.get(); .get();

View File

@ -49,7 +49,7 @@ class IframeListener {
public readonly openTabStream = this._openTabStream.asObservable(); public readonly openTabStream = this._openTabStream.asObservable();
private readonly _loadPageStream: Subject<string> = new Subject(); private readonly _loadPageStream: Subject<string> = new Subject();
public readonly loadPageStream = this._loadPageStream.asObservable() public readonly loadPageStream = this._loadPageStream.asObservable();
private readonly _disablePlayerControlStream: Subject<void> = new Subject(); private readonly _disablePlayerControlStream: Subject<void> = new Subject();
public readonly disablePlayerControlStream = this._disablePlayerControlStream.asObservable(); public readonly disablePlayerControlStream = this._disablePlayerControlStream.asObservable();

View File

@ -57,7 +57,7 @@ export class WorkadventureNavigationCommands extends IframeApiContribution<Worka
async getCoWebSites(): Promise<CoWebsite[]> { async getCoWebSites(): Promise<CoWebsite[]> {
const result = await queryWorkadventure({ const result = await queryWorkadventure({
type: "getCoWebsites", type: "getCoWebsites",
data: undefined data: undefined,
}); });
return result.map((cowebsiteEvent) => new CoWebsite(cowebsiteEvent.id, cowebsiteEvent.position)); return result.map((cowebsiteEvent) => new CoWebsite(cowebsiteEvent.id, cowebsiteEvent.position));
} }

View File

@ -122,7 +122,7 @@ class LocalUserStore {
setLastRoomUrl(roomUrl: string): void { setLastRoomUrl(roomUrl: string): void {
localStorage.setItem(lastRoomUrl, roomUrl.toString()); localStorage.setItem(lastRoomUrl, roomUrl.toString());
if ('caches' in window) { if ("caches" in window) {
caches.open(cacheAPIIndex).then((cache) => { caches.open(cacheAPIIndex).then((cache) => {
const stringResponse = new Response(JSON.stringify({ roomUrl })); const stringResponse = new Response(JSON.stringify({ roomUrl }));
cache.put(`/${lastRoomUrl}`, stringResponse); cache.put(`/${lastRoomUrl}`, stringResponse);
@ -135,7 +135,7 @@ class LocalUserStore {
); );
} }
getLastRoomUrlCacheApi(): Promise<string | undefined> { getLastRoomUrlCacheApi(): Promise<string | undefined> {
if (!('caches' in window)) { if (!("caches" in window)) {
return Promise.resolve(undefined); return Promise.resolve(undefined);
} }
return caches.open(cacheAPIIndex).then((cache) => { return caches.open(cacheAPIIndex).then((cache) => {

View File

@ -12,8 +12,7 @@ export type PropertyChangeCallback = (
export type layerChangeCallback = ( export type layerChangeCallback = (
layersChangedByAction: Array<ITiledMapLayer>, layersChangedByAction: Array<ITiledMapLayer>,
allLayersOnNewPosition: Array<ITiledMapLayer>, allLayersOnNewPosition: Array<ITiledMapLayer>
) => void; ) => void;
/** /**
@ -81,7 +80,7 @@ export class GameMap {
} }
private getLayersByKey(key: number): Array<ITiledMapLayer> { private getLayersByKey(key: number): Array<ITiledMapLayer> {
return this.flatLayers.filter(flatLayer => flatLayer.type === 'tilelayer' && flatLayer.data[key] !== 0); return this.flatLayers.filter((flatLayer) => flatLayer.type === "tilelayer" && flatLayer.data[key] !== 0);
} }
/** /**
@ -134,14 +133,13 @@ export class GameMap {
const enterLayers = new Set(layersByNewKey); const enterLayers = new Set(layersByNewKey);
const leaveLayers = new Set(layersByOldKey); const leaveLayers = new Set(layersByOldKey);
enterLayers.forEach(layer => { enterLayers.forEach((layer) => {
if (leaveLayers.has(layer)) { if (leaveLayers.has(layer)) {
leaveLayers.delete(layer); leaveLayers.delete(layer);
enterLayers.delete(layer); enterLayers.delete(layer);
} }
}); });
if (enterLayers.size > 0) { if (enterLayers.size > 0) {
const layerArray = Array.from(enterLayers); const layerArray = Array.from(enterLayers);
for (const callback of this.enterLayerCallbacks) { for (const callback of this.enterLayerCallbacks) {

View File

@ -1,37 +1,37 @@
export enum GameMapProperties { export enum GameMapProperties {
ALLOW_API = 'allowApi', ALLOW_API = "allowApi",
AUDIO_LOOP = 'audioLoop', AUDIO_LOOP = "audioLoop",
AUDIO_VOLUME = 'audioVolume', AUDIO_VOLUME = "audioVolume",
COLLIDES = 'collides', COLLIDES = "collides",
DEFAULT = 'default', DEFAULT = "default",
EXIT_URL = 'exitUrl', EXIT_URL = "exitUrl",
EXIT_SCENE_URL = 'exitSceneUrl', EXIT_SCENE_URL = "exitSceneUrl",
FONT_FAMILY = 'font-family', FONT_FAMILY = "font-family",
JITSI_ADMIN_ROOM_TAG = 'jitsiRoomAdminTag', JITSI_ADMIN_ROOM_TAG = "jitsiRoomAdminTag",
JITSI_CONFIG = 'jitsiConfig', JITSI_CONFIG = "jitsiConfig",
JITSI_INTERFACE_CONFIG = 'jitsiInterfaceConfig', JITSI_INTERFACE_CONFIG = "jitsiInterfaceConfig",
JITSI_ROOM = 'jitsiRoom', JITSI_ROOM = "jitsiRoom",
JITSI_TRIGGER = 'jitsiTrigger', JITSI_TRIGGER = "jitsiTrigger",
JITSI_TRIGGER_MESSAGE = 'jitsiTriggerMessage', JITSI_TRIGGER_MESSAGE = "jitsiTriggerMessage",
JITSI_URL = 'jitsiUrl', JITSI_URL = "jitsiUrl",
JITSI_WIDTH = 'jitsiWidth', JITSI_WIDTH = "jitsiWidth",
NAME = 'name', NAME = "name",
OPEN_TAB = 'openTab', OPEN_TAB = "openTab",
OPEN_WEBSITE = 'openWebsite', OPEN_WEBSITE = "openWebsite",
OPEN_WEBSITE_ALLOW_API = 'openWebsiteAllowApi', OPEN_WEBSITE_ALLOW_API = "openWebsiteAllowApi",
OPEN_WEBSITE_POLICY = 'openWebsitePolicy', OPEN_WEBSITE_POLICY = "openWebsitePolicy",
OPEN_WEBSITE_WIDTH = 'openWebsiteWidth', OPEN_WEBSITE_WIDTH = "openWebsiteWidth",
OPEN_WEBSITE_POSITION = 'openWebsitePosition', OPEN_WEBSITE_POSITION = "openWebsitePosition",
OPEN_WEBSITE_TRIGGER = 'openWebsiteTrigger', OPEN_WEBSITE_TRIGGER = "openWebsiteTrigger",
OPEN_WEBSITE_TRIGGER_MESSAGE = 'openWebsiteTriggerMessage', OPEN_WEBSITE_TRIGGER_MESSAGE = "openWebsiteTriggerMessage",
PLAY_AUDIO = 'playAudio', PLAY_AUDIO = "playAudio",
PLAY_AUDIO_LOOP = 'playAudioLoop', PLAY_AUDIO_LOOP = "playAudioLoop",
READABLE_BY = 'readableBy', READABLE_BY = "readableBy",
SCRIPT = 'script', SCRIPT = "script",
SILENT = 'silent', SILENT = "silent",
START = 'start', START = "start",
START_LAYER = 'startLayer', START_LAYER = "startLayer",
URL = 'url', URL = "url",
WRITABLE_BY = 'writableBy', WRITABLE_BY = "writableBy",
ZONE = 'zone', ZONE = "zone",
} }

View File

@ -4,10 +4,8 @@ import { scriptUtils } from "../../Api/ScriptUtils";
import type { CoWebsite } from "../../WebRtc/CoWebsiteManager"; import type { CoWebsite } from "../../WebRtc/CoWebsiteManager";
import { coWebsiteManager } from "../../WebRtc/CoWebsiteManager"; import { coWebsiteManager } from "../../WebRtc/CoWebsiteManager";
import { layoutManagerActionStore } from "../../Stores/LayoutManagerStore"; import { layoutManagerActionStore } from "../../Stores/LayoutManagerStore";
import { get } from 'svelte/store'; import { get } from "svelte/store";
import { import { ON_ACTION_TRIGGER_BUTTON } from "../../WebRtc/LayoutManager";
ON_ACTION_TRIGGER_BUTTON,
} from "../../WebRtc/LayoutManager";
import type { ITiledMapLayer } from "../Map/ITiledMap"; import type { ITiledMapLayer } from "../Map/ITiledMap";
import { GameMapProperties } from "./GameMapProperties"; import { GameMapProperties } from "./GameMapProperties";
@ -18,8 +16,8 @@ enum OpenCoWebsiteState {
} }
interface OpenCoWebsite { interface OpenCoWebsite {
coWebsite: CoWebsite | undefined, coWebsite: CoWebsite | undefined;
state: OpenCoWebsiteState state: OpenCoWebsiteState;
} }
export class GameMapPropertiesListener { export class GameMapPropertiesListener {
@ -56,7 +54,7 @@ export class GameMapPropertiesListener {
// Open a new co-website by the property. // Open a new co-website by the property.
this.gameMap.onEnterLayer((newLayers) => { this.gameMap.onEnterLayer((newLayers) => {
const handler = () => { const handler = () => {
newLayers.forEach(layer => { newLayers.forEach((layer) => {
if (!layer.properties) { if (!layer.properties) {
return; return;
} }
@ -69,7 +67,7 @@ export class GameMapPropertiesListener {
let websiteTriggerProperty: string | undefined; let websiteTriggerProperty: string | undefined;
let websiteTriggerMessageProperty: string | undefined; let websiteTriggerMessageProperty: string | undefined;
layer.properties.forEach(property => { layer.properties.forEach((property) => {
switch (property.name) { switch (property.name) {
case GameMapProperties.OPEN_WEBSITE: case GameMapProperties.OPEN_WEBSITE:
openWebsiteProperty = property.value as string | undefined; openWebsiteProperty = property.value as string | undefined;
@ -111,14 +109,16 @@ export class GameMapPropertiesListener {
}); });
const openWebsiteFunction = () => { const openWebsiteFunction = () => {
coWebsiteManager.loadCoWebsite( coWebsiteManager
.loadCoWebsite(
openWebsiteProperty as string, openWebsiteProperty as string,
this.scene.MapUrlFile, this.scene.MapUrlFile,
allowApiProperty, allowApiProperty,
websitePolicyProperty, websitePolicyProperty,
websiteWidthProperty, websiteWidthProperty,
websitePositionProperty, websitePositionProperty
).then(coWebsite => { )
.then((coWebsite) => {
const coWebsiteOpen = this.coWebsitesOpenByLayer.get(layer); const coWebsiteOpen = this.coWebsitesOpenByLayer.get(layer);
if (coWebsiteOpen && coWebsiteOpen.state === OpenCoWebsiteState.MUST_BE_CLOSE) { if (coWebsiteOpen && coWebsiteOpen.state === OpenCoWebsiteState.MUST_BE_CLOSE) {
coWebsiteManager.closeCoWebsite(coWebsite); coWebsiteManager.closeCoWebsite(coWebsite);
@ -127,7 +127,7 @@ export class GameMapPropertiesListener {
} else { } else {
this.coWebsitesOpenByLayer.set(layer, { this.coWebsitesOpenByLayer.set(layer, {
coWebsite, coWebsite,
state: OpenCoWebsiteState.OPENED state: OpenCoWebsiteState.OPENED,
}); });
} }
}); });
@ -161,7 +161,7 @@ export class GameMapPropertiesListener {
// Close opened co-websites on leave the layer who contain the property. // Close opened co-websites on leave the layer who contain the property.
this.gameMap.onLeaveLayer((oldLayers) => { this.gameMap.onLeaveLayer((oldLayers) => {
const handler = () => { const handler = () => {
oldLayers.forEach(layer => { oldLayers.forEach((layer) => {
if (!layer.properties) { if (!layer.properties) {
return; return;
} }
@ -169,7 +169,7 @@ export class GameMapPropertiesListener {
let openWebsiteProperty: string | undefined; let openWebsiteProperty: string | undefined;
let websiteTriggerProperty: string | undefined; let websiteTriggerProperty: string | undefined;
layer.properties.forEach(property => { layer.properties.forEach((property) => {
switch (property.name) { switch (property.name) {
case GameMapProperties.OPEN_WEBSITE: case GameMapProperties.OPEN_WEBSITE:
openWebsiteProperty = property.value as string | undefined; openWebsiteProperty = property.value as string | undefined;
@ -216,9 +216,10 @@ export class GameMapPropertiesListener {
return; return;
} }
const action = actionStore && actionStore.length > 0 ? const action =
actionStore.find(action => action.uuid === actionTriggerUuid) : undefined; actionStore && actionStore.length > 0
? actionStore.find((action) => action.uuid === actionTriggerUuid)
: undefined;
if (action) { if (action) {
layoutManagerActionStore.removeAction(actionTriggerUuid); layoutManagerActionStore.removeAction(actionTriggerUuid);

View File

@ -9,9 +9,7 @@ export interface LayoutManagerAction {
userInputManager: UserInputManager | undefined; userInputManager: UserInputManager | undefined;
} }
function createLayoutManagerAction() { function createLayoutManagerAction() {
const { subscribe, set, update } = writable<LayoutManagerAction[]>([]); const { subscribe, set, update } = writable<LayoutManagerAction[]>([]);
return { return {

View File

@ -141,7 +141,8 @@ class JitsiFactory {
jitsiUrl?: string, jitsiUrl?: string,
jitsiWidth?: number jitsiWidth?: number
): void { ): void {
coWebsiteManager.addCoWebsite(async (cowebsiteDiv) => { coWebsiteManager.addCoWebsite(
async (cowebsiteDiv) => {
// Jitsi meet external API maintains some data in local storage // Jitsi meet external API maintains some data in local storage
// which is sent via the appData URL parameter when joining a // which is sent via the appData URL parameter when joining a
// conference. Problem is that this data grows indefinitely. Thus // conference. Problem is that this data grows indefinitely. Thus
@ -176,7 +177,7 @@ class JitsiFactory {
throw new Error("Could not find Jitsi Iframe"); throw new Error("Could not find Jitsi Iframe");
} }
resolve(iframe); resolve(iframe);
} };
options.onload = () => doResolve(); //we want for the iframe to be loaded before triggering animations. options.onload = () => doResolve(); //we want for the iframe to be loaded before triggering animations.
setTimeout(() => doResolve(), 2000); //failsafe in case the iframe is deleted before loading or too long to load setTimeout(() => doResolve(), 2000); //failsafe in case the iframe is deleted before loading or too long to load
this.jitsiApi = new window.JitsiMeetExternalAPI(domain, options); this.jitsiApi = new window.JitsiMeetExternalAPI(domain, options);
@ -185,7 +186,10 @@ class JitsiFactory {
this.jitsiApi.addListener("audioMuteStatusChanged", this.audioCallback); this.jitsiApi.addListener("audioMuteStatusChanged", this.audioCallback);
this.jitsiApi.addListener("videoMuteStatusChanged", this.videoCallback); this.jitsiApi.addListener("videoMuteStatusChanged", this.videoCallback);
}); });
}, jitsiWidth, 0); },
jitsiWidth,
0
);
} }
public stop() { public stop() {