[WIP] fixed cherry pick conflicts

This commit is contained in:
jonny 2021-05-28 00:34:40 +02:00
parent 2de2d114a1
commit cbe93d7164
5 changed files with 6762 additions and 58 deletions

6742
front/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
import { ChatEvent } from '../Events/ChatEvent' import type { ChatEvent } from '../Events/ChatEvent'
import { isUserInputChatEvent, UserInputChatEvent } from '../Events/UserInputChatEvent' import { isUserInputChatEvent, UserInputChatEvent } from '../Events/UserInputChatEvent'
import { } from "./iframe-registration" import { } from "./iframe-registration"
import { apiCallback, IframeApiContribution, sendToWorkadventure } from './IframeApiContribution' import { apiCallback, IframeApiContribution, sendToWorkadventure } from './IframeApiContribution'

View File

@ -1,5 +1,5 @@
import { IframeEvent, IframeEventMap, IframeResponseEventMap } from '../Events/IframeEvent'; import { registeredCallbacks } from "../../iframe_api";
import { registeredCallbacks, WorkAdventureApi } from "../../iframe_api" import type { IframeResponseEventMap } from '../Events/IframeEvent';
/*export function registerWorkadventureCommand<T>(commnds: T): T { /*export function registerWorkadventureCommand<T>(commnds: T): T {
const commandPrototype = Object.getPrototypeOf(commnds); const commandPrototype = Object.getPrototypeOf(commnds);
const commandClassPropertyNames = Object.getOwnPropertyNames(commandPrototype).filter(name => name !== "constructor"); const commandClassPropertyNames = Object.getOwnPropertyNames(commandPrototype).filter(name => name !== "constructor");

View File

@ -1,7 +1,7 @@
import { isButtonClickedEvent } from '../Events/ButtonClickedEvent'; import { isButtonClickedEvent } from '../Events/ButtonClickedEvent';
import { ClosePopupEvent } from '../Events/ClosePopupEvent'; import type { ClosePopupEvent } from '../Events/ClosePopupEvent';
import { apiCallback, IframeApiContribution, IframeCallbackContribution, sendToWorkadventure } from './IframeApiContribution'; import { apiCallback, IframeApiContribution, sendToWorkadventure } from './IframeApiContribution';
import zoneCommands from "./zone-events" import zoneCommands from "./zone-events";
class Popup { class Popup {
constructor(private id: number) { constructor(private id: number) {
} }

View File

@ -1,24 +1,14 @@
import type { ChatEvent } from "./Api/Events/ChatEvent";
import { IframeEvent, IframeEventMap, IframeResponseEventMap, isIframeResponseEventWrapper } from "./Api/Events/IframeEvent";
import { isUserInputChatEvent, UserInputChatEvent } from "./Api/Events/UserInputChatEvent";
import { Subject } from "rxjs"; import { Subject } from "rxjs";
import { EnterLeaveEvent, isEnterLeaveEvent } from "./Api/Events/EnterLeaveEvent";
import type { OpenPopupEvent } from "./Api/Events/OpenPopupEvent";
import { isButtonClickedEvent } from "./Api/Events/ButtonClickedEvent";
import type { ClosePopupEvent } from "./Api/Events/ClosePopupEvent";
import type { OpenTabEvent } from "./Api/Events/OpenTabEvent";
import type { GoToPageEvent } from "./Api/Events/GoToPageEvent"; import type { GoToPageEvent } from "./Api/Events/GoToPageEvent";
import { IframeResponseEventMap, isIframeResponseEventWrapper } from "./Api/Events/IframeEvent";
import type { OpenCoWebSiteEvent } from "./Api/Events/OpenCoWebSiteEvent"; import type { OpenCoWebSiteEvent } from "./Api/Events/OpenCoWebSiteEvent";
import { OpenTabEvent } from "./Api/Events/OpenTabEvent"; import type { OpenTabEvent } from "./Api/Events/OpenTabEvent";
import { GoToPageEvent } from "./Api/Events/GoToPageEvent"; import { isUserInputChatEvent, UserInputChatEvent } from "./Api/Events/UserInputChatEvent";
import { OpenCoWebSiteEvent, OpenCoWebSiteOptionsEvent } from "./Api/Events/OpenCoWebSiteEvent";
import { LoadPageEvent } from './Api/Events/LoadPageEvent'; export const registeredCallbacks: { [K in keyof IframeResponseEventMap]?: {
import { isMenuItemClickedEvent } from './Api/Events/MenuItemClickedEvent'; typeChecker: Function
import { MenuItemRegisterEvent } from './Api/Events/MenuItemRegisterEvent'; callback: Function
import { GameStateEvent, isGameStateEvent } from './Api/Events/ApiGameStateEvent'; } } = {}
import { updateTile, UpdateTileEvent } from './Api/Events/ApiUpdateTileEvent';
import { isMessageReferenceEvent, removeTriggerMessage, triggerMessage, TriggerMessageCallback, TriggerMessageEvent } from './Api/Events/TriggerMessageEvent';
import { HasMovedEvent, HasMovedEventCallback, isHasMovedEvent } from './Api/Events/HasMovedEvent';
const importType = Promise.all([ const importType = Promise.all([
import("./Api/iframe/popup"), import("./Api/iframe/popup"),
@ -85,19 +75,6 @@ const userInputChatStream: Subject<UserInputChatEvent> = new Subject();
window.WA = { window.WA = {
/**
* Send a message in the chat.
* Only the local user will receive this message.
*/
sendChatMessage(message: string, author: string) {
window.parent.postMessage({
'type': 'chat',
'data': {
'message': message,
'author': author
} as ChatEvent
}, '*');
},
disablePlayerControls(): void { disablePlayerControls(): void {
window.parent.postMessage({ 'type': 'disablePlayerControls' }, '*'); window.parent.postMessage({ 'type': 'disablePlayerControls' }, '*');
}, },
@ -146,16 +123,6 @@ window.WA = {
"type": 'closeCoWebSite' "type": 'closeCoWebSite'
}, '*'); }, '*');
}, },
registerMenuCommand(commandDescriptor: string, callback: (commandDescriptor: string) => void) {
menuCallbacks.set(commandDescriptor, callback);
window.parent.postMessage({
'type': 'registerMenuCommand',
'data': {
menutItem: commandDescriptor
} as MenuItemRegisterEvent
}, '*');
},
...({} as WorkAdventureApiFiles), ...({} as WorkAdventureApiFiles),
} }
@ -171,11 +138,6 @@ window.addEventListener('message', message => {
if (isIframeResponseEventWrapper(payload)) { if (isIframeResponseEventWrapper(payload)) {
const payloadData = payload.data; const payloadData = payload.data;
if (registeredCallbacks[payload.type] && registeredCallbacks[payload.type]?.typeChecker(payloadData)) {
registeredCallbacks[payload.type]?.callback(payloadData)
return
}
if (payload.type === 'userInputChat' && isUserInputChatEvent(payloadData)) { if (payload.type === 'userInputChat' && isUserInputChatEvent(payloadData)) {
userInputChatStream.next(payloadData); userInputChatStream.next(payloadData);
} }