Add types file in API
This commit is contained in:
parent
a195870cfb
commit
706f531ca2
3
front/dist/service-worker-prod.js
vendored
3
front/dist/service-worker-prod.js
vendored
@ -57,4 +57,5 @@ self.addEventListener('update', function(event) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
self.addEventListener('beforeinstallprompt', (e) => {
|
self.addEventListener('beforeinstallprompt', (e) => {
|
||||||
//TODO change prompt
|
//TODO change prompt
|
||||||
|
});
|
@ -7,7 +7,7 @@ import { Popup } from "./Ui/Popup";
|
|||||||
import { ActionMessage } from "./Ui/ActionMessage";
|
import { ActionMessage } from "./Ui/ActionMessage";
|
||||||
import { isMessageReferenceEvent } from "../Events/ui/TriggerActionMessageEvent";
|
import { isMessageReferenceEvent } from "../Events/ui/TriggerActionMessageEvent";
|
||||||
import { Menu } from "./Ui/Menu";
|
import { Menu } from "./Ui/Menu";
|
||||||
import type { RequireOnlyOne } from "../../types";
|
import type { RequireOnlyOne } from "../types";
|
||||||
|
|
||||||
let popupId = 0;
|
let popupId = 0;
|
||||||
const popups: Map<number, Popup> = new Map<number, Popup>();
|
const popups: Map<number, Popup> = new Map<number, Popup>();
|
||||||
@ -26,7 +26,7 @@ interface MenuDescriptor {
|
|||||||
allowApi?: boolean;
|
allowApi?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
type CallbackOrIframe = RequireOnlyOne<MenuDescriptor, "callback" | "iframe">;
|
export type MenuOptions = RequireOnlyOne<MenuDescriptor, "callback" | "iframe">;
|
||||||
|
|
||||||
interface ZonedPopupOptions {
|
interface ZonedPopupOptions {
|
||||||
zone: string;
|
zone: string;
|
||||||
@ -119,10 +119,7 @@ export class WorkAdventureUiCommands extends IframeApiContribution<WorkAdventure
|
|||||||
return popup;
|
return popup;
|
||||||
}
|
}
|
||||||
|
|
||||||
registerMenuCommand(
|
registerMenuCommand(commandDescriptor: string, options: MenuOptions | ((commandDescriptor: string) => void)): Menu {
|
||||||
commandDescriptor: string,
|
|
||||||
options: CallbackOrIframe | ((commandDescriptor: string) => void)
|
|
||||||
): Menu {
|
|
||||||
const menu = new Menu(commandDescriptor);
|
const menu = new Menu(commandDescriptor);
|
||||||
|
|
||||||
if (typeof options === "function") {
|
if (typeof options === "function") {
|
||||||
|
4
front/src/Api/types.ts
Normal file
4
front/src/Api/types.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
export type RequireOnlyOne<T, keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, keys>> &
|
||||||
|
{
|
||||||
|
[K in keys]-?: Required<Pick<T, K>> & Partial<Record<Exclude<keys, K>, undefined>>;
|
||||||
|
}[keys];
|
@ -9,7 +9,8 @@
|
|||||||
import CustomSubMenu from "./CustomSubMenu.svelte"
|
import CustomSubMenu from "./CustomSubMenu.svelte"
|
||||||
import {customMenuIframe, menuVisiblilityStore, SubMenusInterface, subMenusStore} from "../../Stores/MenuStore";
|
import {customMenuIframe, menuVisiblilityStore, SubMenusInterface, subMenusStore} from "../../Stores/MenuStore";
|
||||||
import {onDestroy, onMount} from "svelte";
|
import {onDestroy, onMount} from "svelte";
|
||||||
import {get, Unsubscriber} from "svelte/store";
|
import {get} from "svelte/store";
|
||||||
|
import type {Unsubscriber} from "svelte/store";
|
||||||
import {sendMenuClickedEvent} from "../../Api/iframe/Ui/MenuItem";
|
import {sendMenuClickedEvent} from "../../Api/iframe/Ui/MenuItem";
|
||||||
|
|
||||||
let activeSubMenu: string = SubMenusInterface.settings;
|
let activeSubMenu: string = SubMenusInterface.settings;
|
||||||
|
@ -21,8 +21,3 @@ export interface IVirtualJoystick extends Phaser.GameObjects.GameObject {
|
|||||||
visible: boolean;
|
visible: boolean;
|
||||||
createCursorKeys: () => CursorKeys;
|
createCursorKeys: () => CursorKeys;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type RequireOnlyOne<T, keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, keys>> &
|
|
||||||
{
|
|
||||||
[K in keys]-?: Required<Pick<T, K>> & Partial<Record<Exclude<keys, K>, undefined>>;
|
|
||||||
}[keys];
|
|
||||||
|
Loading…
Reference in New Issue
Block a user