[WIP] fixed cherry pick conflicts
This commit is contained in:
parent
2de2d114a1
commit
cbe93d7164
5 changed files with 6762 additions and 58 deletions
6742
front/package-lock.json
generated
Normal file
6742
front/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,4 +1,4 @@
|
|||
import { ChatEvent } from '../Events/ChatEvent'
|
||||
import type { ChatEvent } from '../Events/ChatEvent'
|
||||
import { isUserInputChatEvent, UserInputChatEvent } from '../Events/UserInputChatEvent'
|
||||
import { } from "./iframe-registration"
|
||||
import { apiCallback, IframeApiContribution, sendToWorkadventure } from './IframeApiContribution'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { IframeEvent, IframeEventMap, IframeResponseEventMap } from '../Events/IframeEvent';
|
||||
import { registeredCallbacks, WorkAdventureApi } from "../../iframe_api"
|
||||
import { registeredCallbacks } from "../../iframe_api";
|
||||
import type { IframeResponseEventMap } from '../Events/IframeEvent';
|
||||
/*export function registerWorkadventureCommand<T>(commnds: T): T {
|
||||
const commandPrototype = Object.getPrototypeOf(commnds);
|
||||
const commandClassPropertyNames = Object.getOwnPropertyNames(commandPrototype).filter(name => name !== "constructor");
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { isButtonClickedEvent } from '../Events/ButtonClickedEvent';
|
||||
import { ClosePopupEvent } from '../Events/ClosePopupEvent';
|
||||
import { apiCallback, IframeApiContribution, IframeCallbackContribution, sendToWorkadventure } from './IframeApiContribution';
|
||||
import zoneCommands from "./zone-events"
|
||||
import type { ClosePopupEvent } from '../Events/ClosePopupEvent';
|
||||
import { apiCallback, IframeApiContribution, sendToWorkadventure } from './IframeApiContribution';
|
||||
import zoneCommands from "./zone-events";
|
||||
class Popup {
|
||||
constructor(private id: number) {
|
||||
}
|
||||
|
|
|
@ -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 { 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 { IframeResponseEventMap, isIframeResponseEventWrapper } from "./Api/Events/IframeEvent";
|
||||
import type { OpenCoWebSiteEvent } from "./Api/Events/OpenCoWebSiteEvent";
|
||||
import { OpenTabEvent } from "./Api/Events/OpenTabEvent";
|
||||
import { GoToPageEvent } from "./Api/Events/GoToPageEvent";
|
||||
import { OpenCoWebSiteEvent, OpenCoWebSiteOptionsEvent } from "./Api/Events/OpenCoWebSiteEvent";
|
||||
import { LoadPageEvent } from './Api/Events/LoadPageEvent';
|
||||
import { isMenuItemClickedEvent } from './Api/Events/MenuItemClickedEvent';
|
||||
import { MenuItemRegisterEvent } from './Api/Events/MenuItemRegisterEvent';
|
||||
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';
|
||||
import type { OpenTabEvent } from "./Api/Events/OpenTabEvent";
|
||||
import { isUserInputChatEvent, UserInputChatEvent } from "./Api/Events/UserInputChatEvent";
|
||||
|
||||
export const registeredCallbacks: { [K in keyof IframeResponseEventMap]?: {
|
||||
typeChecker: Function
|
||||
callback: Function
|
||||
} } = {}
|
||||
|
||||
const importType = Promise.all([
|
||||
import("./Api/iframe/popup"),
|
||||
|
@ -57,9 +47,9 @@ type WorkAdventureApiFiles = {
|
|||
} & SubObjectTypes
|
||||
|
||||
export interface WorkAdventureApi extends WorkAdventureApiFiles {
|
||||
openTab(url : string): void;
|
||||
goToPage(url : string): void;
|
||||
openCoWebSite(url : string): void;
|
||||
openTab(url: string): void;
|
||||
goToPage(url: string): void;
|
||||
openCoWebSite(url: string): void;
|
||||
closeCoWebSite(): void;
|
||||
disablePlayerControls(): void;
|
||||
restorePlayerControls(): void;
|
||||
|
@ -85,19 +75,6 @@ const userInputChatStream: Subject<UserInputChatEvent> = new Subject();
|
|||
|
||||
|
||||
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 {
|
||||
window.parent.postMessage({ 'type': 'disablePlayerControls' }, '*');
|
||||
},
|
||||
|
@ -132,10 +109,10 @@ window.WA = {
|
|||
}, '*');
|
||||
},
|
||||
|
||||
openCoWebSite(url : string) : void{
|
||||
openCoWebSite(url: string): void {
|
||||
window.parent.postMessage({
|
||||
"type" : 'openCoWebSite',
|
||||
"data" : {
|
||||
"type": 'openCoWebSite',
|
||||
"data": {
|
||||
url
|
||||
} as OpenCoWebSiteEvent
|
||||
}, '*');
|
||||
|
@ -146,16 +123,6 @@ window.WA = {
|
|||
"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),
|
||||
}
|
||||
|
||||
|
@ -171,11 +138,6 @@ window.addEventListener('message', message => {
|
|||
if (isIframeResponseEventWrapper(payload)) {
|
||||
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)) {
|
||||
userInputChatStream.next(payloadData);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue