From 84a82a8b27822e1f504451695e3b3ab2cd03b6d3 Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Sat, 20 Mar 2021 16:18:05 +0100 Subject: [PATCH] Adjusted the client to the new webpack shared part --- imports/shared-app/Bookmarks.d.ts | 67 +++++++++ imports/shared-app/ConnectionHandler.d.ts | 2 +- imports/shared-app/PPTListener.d.ts | 44 ++++-- imports/shared-app/audio/Player.d.ts | 27 ++++ .../audio/{recorder.d.ts => Recorder.d.ts} | 11 +- .../shared-app/{sound => audio}/Sounds.d.ts | 5 + imports/shared-app/audio/player.d.ts | 5 - imports/shared-app/bookmarks.d.ts | 48 ------ imports/shared-app/connection/ErrorCode.d.ts | 2 + imports/shared-app/connectionlog/History.d.ts | 2 + imports/shared-app/devel_main.d.ts | 1 - imports/shared-app/dns.d.ts | 44 +++++- imports/shared-app/entry-points/MainApp.d.ts | 1 + .../shared-app/entry-points/ModalWindow.d.ts | 1 + imports/shared-app/file/Icons.d.ts | 1 + imports/shared-app/file/Utils.d.ts | 2 + imports/shared-app/i18n/localize.d.ts | 2 +- imports/shared-app/main.d.ts | 1 + imports/shared-app/proto.d.ts | 27 +++- imports/shared-app/settings.d.ts | 8 +- .../text/bbcode/YoutubeController.d.ts | 1 + .../{youtube.d.ts => YoutubeRenderer.d.ts} | 0 imports/shared-app/text/bbcode/renderer.d.ts | 2 +- imports/shared-app/tree/Channel.d.ts | 3 +- imports/shared-app/tree/Server.d.ts | 1 + imports/shared-app/ui/elements/Modal.d.ts | 1 + .../ui/frames/HostBannerRenderer.d.ts | 6 +- .../shared-app/ui/frames/ImagePreview.d.ts | 5 + .../ui/frames/control-bar/Controller.d.ts | 2 +- .../shared-app/ui/frames/image_preview.d.ts | 4 - .../ui/frames/video/Definitions.d.ts | 7 +- .../shared-app/ui/frames/video/Renderer.d.ts | 9 +- .../ui/frames/video/RendererSpotlight.d.ts | 9 ++ imports/shared-app/ui/htmltags.d.ts | 9 -- .../ui/modal/ModalChangeVolumeNew.d.ts | 4 +- imports/shared-app/ui/modal/ModalInvite.d.ts | 2 - imports/shared-app/ui/modal/ModalPoke.d.ts | 11 -- .../bookmarks-add-server/Controller.d.ts | 2 + .../bookmarks-add-server/Definitions.d.ts | 21 +++ .../modal/bookmarks-add-server/Renderer.d.ts | 13 ++ .../Controller.d.ts} | 0 .../ui/modal/bookmarks/Definitions.d.ts | 87 +++++++++++ .../ui/modal/bookmarks/Renderer.d.ts | 15 ++ .../shared-app/ui/modal/connect/Renderer.d.ts | 1 - .../permission/ModalPermissionEditor.d.ts | 38 ++--- .../shared-app/ui/modal/poke/Controller.d.ts | 6 + .../shared-app/ui/modal/poke/Definitions.d.ts | 17 +++ .../shared-app/ui/modal/poke/Renderer.d.ts | 15 ++ .../ui/modal/settings/Microphone.d.ts | 4 +- .../transfer/FileBrowserControllerRemote.d.ts | 2 +- .../transfer/FileTransferInfoController.d.ts | 2 +- .../ui/modal/video-source/Renderer.d.ts | 2 +- .../ui/modal/whats-new/Definitions.d.ts | 4 + .../shared-app/ui/react-elements/Button.d.ts | 5 +- .../ui/react-elements/CountryIcon.d.ts | 5 + .../ui/react-elements/ErrorBoundary.d.ts | 2 +- .../ui/react-elements/FontSize.d.ts | 4 + .../shared-app/ui/react-elements/Helper.d.ts | 2 +- .../ui/react-elements/InputField.d.ts | 1 + .../shared-app/ui/react-elements/Tooltip.d.ts | 2 + .../external-modal/Controller.d.ts | 26 ---- .../external-modal/IPCMessage.d.ts | 35 ----- .../external-modal/PopoutController.d.ts | 13 -- .../external-modal/PopoutEntrypoint.d.ts | 2 - .../external-modal/PopoutRendererClient.d.ts | 16 -- .../external-modal/PopoutRendererWeb.d.ts | 8 - .../react-elements/external-modal/index.d.ts | 7 - .../ui/react-elements/i18n/index.d.ts | 3 - .../internal-modal/Controller.d.ts | 23 --- .../internal-modal/Renderer.d.ts | 23 --- .../ui/react-elements/modal/Controller.d.ts | 22 +++ .../ui/react-elements/modal/Definitions.d.ts | 41 ++++-- .../ui/react-elements/modal/Registry.d.ts | 4 +- .../ui/react-elements/modal/Renderer.d.ts | 44 ++++++ .../modal/external/Controller.d.ts | 27 ++++ .../modal/external/Definitions.d.ts | 25 ++++ .../modal/external/renderer/Controller.d.ts | 21 +++ .../modal/external/renderer/EntryPoint.d.ts | 2 + .../external/renderer/ModalRenderer.d.ts | 12 ++ .../ui/react-elements/modal/index.d.ts | 16 +- .../react-elements/modal/internal/index.d.ts | 25 ++++ imports/shared-app/ui/tree/EntryTags.d.ts | 16 +- imports/shared-app/ui/utils/Variable.d.ts | 20 +-- .../shared-app/ui/windows/WindowManager.d.ts | 44 ++++++ imports/shared-app/voice/RecorderBase.d.ts | 4 +- imports/shared-app/voice/RecorderProfile.d.ts | 6 +- jenkins/create_build.sh | 2 +- modules/core/render-backend/ExternalModal.ts | 26 ++-- modules/core/render-backend/index.ts | 1 - .../renderer/{backend-impl => }/Backend.ts | 4 +- modules/renderer/ExternalModalHandler.ts | 71 --------- modules/renderer/KeyBoard.ts | 51 +++++++ modules/renderer/PushToTalkHandler.ts | 139 ------------------ modules/renderer/WindowManager.ts | 108 ++++++++++++++ modules/renderer/audio/AudioFilter.ts | 11 +- modules/renderer/audio/AudioPlayer.ts | 105 +++++++++++++ modules/renderer/audio/AudioRecorder.ts | 12 +- modules/renderer/audio/InputDeviceList.ts | 6 +- modules/renderer/audio/Sounds.ts | 27 ++++ modules/renderer/audio/sounds.ts | 24 --- modules/renderer/backend-impl/audio/player.ts | 15 -- modules/renderer/backend-impl/audio/sounds.ts | 3 - modules/renderer/backend-impl/dns.ts | 4 - modules/renderer/backend-impl/ppt.ts | 12 -- modules/renderer/dns/NativeDnsResolver.ts | 44 ++++++ modules/renderer/dns/dns_resolver.ts | 29 ---- modules/renderer/hooks/AudioBackend.ts | 9 ++ modules/renderer/hooks/AudioInput.ts | 4 +- modules/renderer/hooks/Backend.ts | 2 +- modules/renderer/hooks/ChangeLogClient.ts | 2 +- modules/renderer/hooks/Dns.ts | 9 ++ modules/renderer/hooks/ExternalModal.ts | 12 -- modules/renderer/hooks/KeyBoard.ts | 9 ++ modules/renderer/hooks/Sound.ts | 9 ++ modules/renderer/hooks/WindowManager.ts | 9 ++ modules/renderer/hooks/index.ts | 11 ++ modules/renderer/index.ts | 10 +- modules/shared/ipc/ExternalModal.ts | 12 -- modules/shared/ipc/IpcWindowInstance.ts | 12 ++ modules/shared/proxy/Definitions.ts | 29 +++- modules/shared/proxy/Server.ts | 4 +- modules/shared/proxy/Test.ts | 4 - .../src/audio/filter/FilterThreshold.cpp | 38 ++--- .../src/audio/filter/FilterThreshold.h | 56 ++++--- .../src/connection/ProtocolHandler.cpp | 2 +- .../src/connection/ProtocolHandlerPOW.cpp | 1 + native/serverconnection/test/js/flood.ts | 4 +- native/serverconnection/test/js/main.ts | 2 +- package.json | 2 +- 129 files changed, 1279 insertions(+), 779 deletions(-) create mode 100644 imports/shared-app/Bookmarks.d.ts create mode 100644 imports/shared-app/audio/Player.d.ts rename imports/shared-app/audio/{recorder.d.ts => Recorder.d.ts} (90%) rename imports/shared-app/{sound => audio}/Sounds.d.ts (94%) delete mode 100644 imports/shared-app/audio/player.d.ts delete mode 100644 imports/shared-app/bookmarks.d.ts delete mode 100644 imports/shared-app/devel_main.d.ts create mode 100644 imports/shared-app/entry-points/MainApp.d.ts create mode 100644 imports/shared-app/entry-points/ModalWindow.d.ts create mode 100644 imports/shared-app/file/Utils.d.ts create mode 100644 imports/shared-app/text/bbcode/YoutubeController.d.ts rename imports/shared-app/text/bbcode/{youtube.d.ts => YoutubeRenderer.d.ts} (100%) create mode 100644 imports/shared-app/ui/frames/ImagePreview.d.ts delete mode 100644 imports/shared-app/ui/frames/image_preview.d.ts create mode 100644 imports/shared-app/ui/frames/video/RendererSpotlight.d.ts delete mode 100644 imports/shared-app/ui/modal/ModalInvite.d.ts delete mode 100644 imports/shared-app/ui/modal/ModalPoke.d.ts create mode 100644 imports/shared-app/ui/modal/bookmarks-add-server/Controller.d.ts create mode 100644 imports/shared-app/ui/modal/bookmarks-add-server/Definitions.d.ts create mode 100644 imports/shared-app/ui/modal/bookmarks-add-server/Renderer.d.ts rename imports/shared-app/ui/modal/{ModalBookmarks.d.ts => bookmarks/Controller.d.ts} (100%) create mode 100644 imports/shared-app/ui/modal/bookmarks/Definitions.d.ts create mode 100644 imports/shared-app/ui/modal/bookmarks/Renderer.d.ts create mode 100644 imports/shared-app/ui/modal/poke/Controller.d.ts create mode 100644 imports/shared-app/ui/modal/poke/Definitions.d.ts create mode 100644 imports/shared-app/ui/modal/poke/Renderer.d.ts create mode 100644 imports/shared-app/ui/modal/whats-new/Definitions.d.ts create mode 100644 imports/shared-app/ui/react-elements/CountryIcon.d.ts create mode 100644 imports/shared-app/ui/react-elements/FontSize.d.ts delete mode 100644 imports/shared-app/ui/react-elements/external-modal/Controller.d.ts delete mode 100644 imports/shared-app/ui/react-elements/external-modal/IPCMessage.d.ts delete mode 100644 imports/shared-app/ui/react-elements/external-modal/PopoutController.d.ts delete mode 100644 imports/shared-app/ui/react-elements/external-modal/PopoutEntrypoint.d.ts delete mode 100644 imports/shared-app/ui/react-elements/external-modal/PopoutRendererClient.d.ts delete mode 100644 imports/shared-app/ui/react-elements/external-modal/PopoutRendererWeb.d.ts delete mode 100644 imports/shared-app/ui/react-elements/external-modal/index.d.ts delete mode 100644 imports/shared-app/ui/react-elements/internal-modal/Controller.d.ts delete mode 100644 imports/shared-app/ui/react-elements/internal-modal/Renderer.d.ts create mode 100644 imports/shared-app/ui/react-elements/modal/Controller.d.ts create mode 100644 imports/shared-app/ui/react-elements/modal/Renderer.d.ts create mode 100644 imports/shared-app/ui/react-elements/modal/external/Controller.d.ts create mode 100644 imports/shared-app/ui/react-elements/modal/external/Definitions.d.ts create mode 100644 imports/shared-app/ui/react-elements/modal/external/renderer/Controller.d.ts create mode 100644 imports/shared-app/ui/react-elements/modal/external/renderer/EntryPoint.d.ts create mode 100644 imports/shared-app/ui/react-elements/modal/external/renderer/ModalRenderer.d.ts create mode 100644 imports/shared-app/ui/react-elements/modal/internal/index.d.ts create mode 100644 imports/shared-app/ui/windows/WindowManager.d.ts rename modules/renderer/{backend-impl => }/Backend.ts (94%) delete mode 100644 modules/renderer/ExternalModalHandler.ts create mode 100644 modules/renderer/KeyBoard.ts delete mode 100644 modules/renderer/PushToTalkHandler.ts create mode 100644 modules/renderer/WindowManager.ts create mode 100644 modules/renderer/audio/Sounds.ts delete mode 100644 modules/renderer/audio/sounds.ts delete mode 100644 modules/renderer/backend-impl/audio/player.ts delete mode 100644 modules/renderer/backend-impl/audio/sounds.ts delete mode 100644 modules/renderer/backend-impl/dns.ts delete mode 100644 modules/renderer/backend-impl/ppt.ts create mode 100644 modules/renderer/dns/NativeDnsResolver.ts delete mode 100644 modules/renderer/dns/dns_resolver.ts create mode 100644 modules/renderer/hooks/AudioBackend.ts create mode 100644 modules/renderer/hooks/Dns.ts delete mode 100644 modules/renderer/hooks/ExternalModal.ts create mode 100644 modules/renderer/hooks/KeyBoard.ts create mode 100644 modules/renderer/hooks/Sound.ts create mode 100644 modules/renderer/hooks/WindowManager.ts create mode 100644 modules/renderer/hooks/index.ts delete mode 100644 modules/shared/ipc/ExternalModal.ts create mode 100644 modules/shared/ipc/IpcWindowInstance.ts diff --git a/imports/shared-app/Bookmarks.d.ts b/imports/shared-app/Bookmarks.d.ts new file mode 100644 index 0000000..f0c7648 --- /dev/null +++ b/imports/shared-app/Bookmarks.d.ts @@ -0,0 +1,67 @@ +import { WritableKeys } from "tc-shared/proto"; +import { Registry } from "tc-events"; +declare type BookmarkBase = { + readonly uniqueId: string; + displayName: string; + previousEntry: string | undefined; + parentEntry: string | undefined; +}; +export declare type BookmarkInfo = BookmarkBase & { + readonly type: "entry"; + connectOnStartup: boolean; + connectProfile: string; + serverAddress: string; + serverPasswordHash: string | undefined; + defaultChannel: string | undefined; + defaultChannelPasswordHash: string | undefined; +}; +export declare type BookmarkDirectory = BookmarkBase & { + readonly type: "directory"; +}; +export declare type BookmarkEntry = BookmarkInfo | BookmarkDirectory; +export interface BookmarkEvents { + notify_bookmark_created: { + bookmark: BookmarkEntry; + }; + notify_bookmark_edited: { + bookmark: BookmarkEntry; + keys: (keyof BookmarkInfo | keyof BookmarkDirectory)[]; + }; + notify_bookmark_deleted: { + bookmark: BookmarkEntry; + children: BookmarkEntry[]; + }; + notify_bookmarks_imported: { + bookmarks: BookmarkEntry[]; + }; +} +export declare type OrderedBookmarkEntry = { + entry: BookmarkEntry; + depth: number; + childCount: number; +}; +export declare class BookmarkManager { + readonly events: Registry; + private readonly registeredBookmarks; + private defaultBookmarkCreated; + constructor(); + private loadBookmarks; + private importOldBookmarks; + private saveBookmarks; + getRegisteredBookmarks(): BookmarkEntry[]; + getOrderedRegisteredBookmarks(): OrderedBookmarkEntry[]; + findBookmark(uniqueId: string): BookmarkEntry | undefined; + createBookmark(properties: Pick>): BookmarkInfo; + editBookmark(uniqueId: string, newValues: Partial>>): void; + createDirectory(properties: Pick>): BookmarkDirectory; + editDirectory(uniqueId: string, newValues: Partial>>): void; + deleteEntry(uniqueId: string): void; + executeConnect(uniqueId: string, newTab: boolean): void; + executeAutoConnect(): void; + exportBookmarks(): string; + importBookmarks(filePayload: string): number; + private doEditBookmark; + private validateHangInPoint; +} +export declare let bookmarks: BookmarkManager; +export {}; diff --git a/imports/shared-app/ConnectionHandler.d.ts b/imports/shared-app/ConnectionHandler.d.ts index d869b51..1132f6f 100644 --- a/imports/shared-app/ConnectionHandler.d.ts +++ b/imports/shared-app/ConnectionHandler.d.ts @@ -2,7 +2,7 @@ import { AbstractServerConnection } from "./connection/ConnectionBase"; import { PermissionManager } from "./permission/PermissionManager"; import { GroupManager } from "./permission/GroupManager"; import { ServerSettings } from "./settings"; -import { SoundManager } from "./sound/Sounds"; +import { SoundManager } from "./audio/Sounds"; import { ConnectionProfile } from "./profiles/ConnectionProfile"; import { RecorderProfile } from "./voice/RecorderProfile"; import { Registry } from "./events"; diff --git a/imports/shared-app/PPTListener.d.ts b/imports/shared-app/PPTListener.d.ts index 1bc9494..9b6dc82 100644 --- a/imports/shared-app/PPTListener.d.ts +++ b/imports/shared-app/PPTListener.d.ts @@ -129,19 +129,45 @@ export declare enum SpecialKey { ALT = 3 } export interface KeyDescriptor { - key_code: string; - key_ctrl: boolean; - key_windows: boolean; - key_shift: boolean; - key_alt: boolean; + keyCode: string; + keyCtrl: boolean; + keyWindows: boolean; + keyShift: boolean; + keyAlt: boolean; } export interface KeyEvent extends KeyDescriptor { readonly type: EventType; readonly key: string; } export interface KeyHook extends KeyDescriptor { - cancel: boolean; - callback_press: () => any; - callback_release: () => any; + callbackPress: () => any; + callbackRelease: () => any; } -export declare function key_description(key: KeyDescriptor): string; +export interface KeyBoardBackend { + registerListener(listener: (event: KeyEvent) => void): any; + unregisterListener(listener: (event: KeyEvent) => void): any; + registerHook(hook: KeyHook): any; + unregisterHook(hook: KeyHook): any; + isKeyPressed(key: string | SpecialKey): boolean; +} +export declare class AbstractKeyBoard implements KeyBoardBackend { + protected readonly registeredListener: ((event: KeyEvent) => void)[]; + protected readonly activeSpecialKeys: { + [key: number]: boolean; + }; + protected readonly activeKeys: any; + protected registeredKeyHooks: KeyHook[]; + protected activeKeyHooks: KeyHook[]; + constructor(); + protected destroy(): void; + isKeyPressed(key: string | SpecialKey): boolean; + registerHook(hook: KeyHook): void; + unregisterHook(hook: KeyHook): void; + registerListener(listener: (event: KeyEvent) => void): void; + unregisterListener(listener: (event: KeyEvent) => void): void; + protected fireKeyEvent(event: KeyEvent): void; + protected resetKeyboardState(): void; +} +export declare function getKeyBoard(): KeyBoardBackend; +export declare function setKeyBoardBackend(newBackend: KeyBoardBackend): void; +export declare function getKeyDescription(key: KeyDescriptor): string; diff --git a/imports/shared-app/audio/Player.d.ts b/imports/shared-app/audio/Player.d.ts new file mode 100644 index 0000000..42d9106 --- /dev/null +++ b/imports/shared-app/audio/Player.d.ts @@ -0,0 +1,27 @@ +export interface OutputDevice { + device_id: string; + driver: string; + name: string; +} +export interface AudioBackendEvents { + notify_initialized: {}; + notify_volume_changed: { + oldVolume: number; + newVolume: number; + }; +} +export interface AudioBackend { + isInitialized(): boolean; + getAudioContext(): AudioContext | undefined; + isDeviceRefreshAvailable(): boolean; + refreshDevices(): Promise; + getAvailableDevices(): Promise; + getDefaultDeviceId(): string; + getCurrentDevice(): OutputDevice; + setCurrentDevice(targetId: string | undefined): Promise; + getMasterVolume(): number; + setMasterVolume(volume: number): any; + executeWhenInitialized(callback: () => void): any; +} +export declare function getAudioBackend(): AudioBackend; +export declare function setAudioBackend(newBackend: AudioBackend): void; diff --git a/imports/shared-app/audio/recorder.d.ts b/imports/shared-app/audio/Recorder.d.ts similarity index 90% rename from imports/shared-app/audio/recorder.d.ts rename to imports/shared-app/audio/Recorder.d.ts index b300ba4..88cde76 100644 --- a/imports/shared-app/audio/recorder.d.ts +++ b/imports/shared-app/audio/Recorder.d.ts @@ -1,9 +1,8 @@ import { AbstractInput, LevelMeter } from "../voice/RecorderBase"; import { Registry } from "../events"; -export declare type DeviceQueryResult = {}; export interface AudioRecorderBacked { createInput(): AbstractInput; - createLevelMeter(device: IDevice): Promise; + createLevelMeter(device: InputDevice): Promise; getDeviceList(): DeviceList; isRnNoiseSupported(): boolean; toggleRnNoise(target: boolean): any; @@ -23,12 +22,12 @@ export interface DeviceListEvents { }; } export declare type DeviceListState = "healthy" | "uninitialized" | "no-permissions" | "error"; -export interface IDevice { +export interface InputDevice { deviceId: string; driver: string; name: string; } -export declare namespace IDevice { +export declare namespace InputDevice { const NoDeviceId = "none"; const DefaultDeviceId = "default"; } @@ -40,7 +39,7 @@ export interface DeviceList { requestPermissions(): Promise; getPermissionState(): PermissionState; getStatus(): DeviceListState; - getDevices(): IDevice[]; + getDevices(): InputDevice[]; getDefaultDeviceId(): string; awaitHealthy(): Promise; awaitInitialized(): Promise; @@ -57,7 +56,7 @@ export declare abstract class AbstractDeviceList implements DeviceList { awaitInitialized(): Promise; awaitHealthy(): Promise; abstract getDefaultDeviceId(): string; - abstract getDevices(): IDevice[]; + abstract getDevices(): InputDevice[]; abstract getEvents(): Registry; abstract isRefreshAvailable(): boolean; abstract refresh(): Promise; diff --git a/imports/shared-app/sound/Sounds.d.ts b/imports/shared-app/audio/Sounds.d.ts similarity index 94% rename from imports/shared-app/sound/Sounds.d.ts rename to imports/shared-app/audio/Sounds.d.ts index cd62056..2563dfb 100644 --- a/imports/shared-app/sound/Sounds.d.ts +++ b/imports/shared-app/audio/Sounds.d.ts @@ -80,3 +80,8 @@ export declare class SoundManager { constructor(handle: ConnectionHandler); play(_sound: Sound, options?: PlaybackOptions): void; } +export interface SoundBackend { + playSound(sound: SoundFile): Promise; +} +export declare function getSoundBackend(): SoundBackend; +export declare function setSoundBackend(newSoundBackend: SoundBackend): void; diff --git a/imports/shared-app/audio/player.d.ts b/imports/shared-app/audio/player.d.ts deleted file mode 100644 index d283622..0000000 --- a/imports/shared-app/audio/player.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -export interface Device { - device_id: string; - driver: string; - name: string; -} diff --git a/imports/shared-app/bookmarks.d.ts b/imports/shared-app/bookmarks.d.ts deleted file mode 100644 index a751894..0000000 --- a/imports/shared-app/bookmarks.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { ConnectionHandler } from "./ConnectionHandler"; -import { Registry } from "tc-shared/events"; -export interface BookmarkEvents { - notify_bookmarks_updated: {}; -} -export declare const bookmarkEvents: Registry; -export declare const boorkmak_connect: (mark: Bookmark, new_tab?: boolean) => void; -export interface ServerProperties { - server_address: string; - server_port: number; - server_password_hash?: string; - server_password?: string; -} -export declare enum BookmarkType { - ENTRY = 0, - DIRECTORY = 1 -} -export interface Bookmark { - type: BookmarkType.ENTRY; - parent: DirectoryBookmark; - server_properties: ServerProperties; - display_name: string; - unique_id: string; - nickname: string; - default_channel?: number | string; - default_channel_password_hash?: string; - default_channel_password?: string; - connect_profile: string; - last_icon_id?: number; - last_icon_server_id?: string; -} -export interface DirectoryBookmark { - type: BookmarkType.DIRECTORY; - parent: DirectoryBookmark; - readonly content: (Bookmark | DirectoryBookmark)[]; - unique_id: string; - display_name: string; -} -export declare function bookmarks(): DirectoryBookmark; -export declare function bookmarks_flat(): Bookmark[]; -export declare function find_bookmark(uuid: string): Bookmark | DirectoryBookmark | undefined; -export declare function parent_bookmark(bookmark: Bookmark): DirectoryBookmark; -export declare function create_bookmark(display_name: string, directory: DirectoryBookmark, server_properties: ServerProperties, nickname: string): Bookmark; -export declare function create_bookmark_directory(parent: DirectoryBookmark, name: string): DirectoryBookmark; -export declare function change_directory(parent: DirectoryBookmark, bookmark: Bookmark | DirectoryBookmark): void; -export declare function save_bookmark(bookmark?: Bookmark | DirectoryBookmark): void; -export declare function delete_bookmark(bookmark: Bookmark | DirectoryBookmark): void; -export declare function add_server_to_bookmarks(server: ConnectionHandler): void; diff --git a/imports/shared-app/connection/ErrorCode.d.ts b/imports/shared-app/connection/ErrorCode.d.ts index dcd5a79..faf21d5 100644 --- a/imports/shared-app/connection/ErrorCode.d.ts +++ b/imports/shared-app/connection/ErrorCode.d.ts @@ -129,6 +129,8 @@ export declare enum ErrorCode { SERVER_CONNECT_BANNED = 3329, BAN_FLOODING = 3331, TOKEN_INVALID_ID = 3840, + TOKEN_EXPIRED = 3856, + TOKEN_USE_LIMIT_EXCEEDED = 3857, WEB_HANDSHAKE_INVALID = 4096, WEB_HANDSHAKE_UNSUPPORTED = 4097, WEB_HANDSHAKE_IDENTITY_UNSUPPORTED = 4098, diff --git a/imports/shared-app/connectionlog/History.d.ts b/imports/shared-app/connectionlog/History.d.ts index c78d19f..7c454a8 100644 --- a/imports/shared-app/connectionlog/History.d.ts +++ b/imports/shared-app/connectionlog/History.d.ts @@ -19,6 +19,8 @@ export declare type ConnectionHistoryServerInfo = { country: string; clientsOnline: number | -1; clientsMax: number | -1; + hostBannerUrl: string | undefined; + hostBannerMode: number; passwordProtected: boolean; }; export declare class ConnectionHistory { diff --git a/imports/shared-app/devel_main.d.ts b/imports/shared-app/devel_main.d.ts deleted file mode 100644 index 9489fbc..0000000 --- a/imports/shared-app/devel_main.d.ts +++ /dev/null @@ -1 +0,0 @@ -import "./proto"; diff --git a/imports/shared-app/dns.d.ts b/imports/shared-app/dns.d.ts index 717c12d..92020c0 100644 --- a/imports/shared-app/dns.d.ts +++ b/imports/shared-app/dns.d.ts @@ -4,12 +4,42 @@ export interface AddressTarget { } export interface ResolveOptions { timeout?: number; - allow_cache?: boolean; - max_depth?: number; - allow_srv?: boolean; - allow_cname?: boolean; - allow_any?: boolean; - allow_a?: boolean; - allow_aaaa?: boolean; + allowCache?: boolean; + maxDepth?: number; + allowSrv?: boolean; + allowCName?: boolean; + allowAny?: boolean; + allowA?: boolean; + allowAAAA?: boolean; } export declare const default_options: ResolveOptions; +export interface DNSResolveOptions { + timeout?: number; + allowCache?: boolean; + maxDepth?: number; + allowSrv?: boolean; + allowCName?: boolean; + allowAny?: boolean; + allowA?: boolean; + allowAAAA?: boolean; +} +export interface DNSAddress { + hostname: string; + port: number; +} +export declare type DNSResolveResult = { + status: "success"; + originalAddress: DNSAddress; + resolvedAddress: DNSAddress; +} | { + status: "error"; + message: string; +} | { + status: "empty-result"; +}; +export interface DNSProvider { + resolveAddress(address: DNSAddress, options: DNSResolveOptions): Promise; + resolveAddressIPv4(address: DNSAddress, options: DNSResolveOptions): Promise; +} +export declare function getDNSProvider(): DNSProvider; +export declare function setDNSProvider(newProvider: DNSProvider): void; diff --git a/imports/shared-app/entry-points/MainApp.d.ts b/imports/shared-app/entry-points/MainApp.d.ts new file mode 100644 index 0000000..ead5cd4 --- /dev/null +++ b/imports/shared-app/entry-points/MainApp.d.ts @@ -0,0 +1 @@ +import "../main"; diff --git a/imports/shared-app/entry-points/ModalWindow.d.ts b/imports/shared-app/entry-points/ModalWindow.d.ts new file mode 100644 index 0000000..4a6cdc1 --- /dev/null +++ b/imports/shared-app/entry-points/ModalWindow.d.ts @@ -0,0 +1 @@ +import "../ui/react-elements/modal/external/renderer/EntryPoint"; diff --git a/imports/shared-app/file/Icons.d.ts b/imports/shared-app/file/Icons.d.ts index 74e8550..c46b54e 100644 --- a/imports/shared-app/file/Icons.d.ts +++ b/imports/shared-app/file/Icons.d.ts @@ -47,6 +47,7 @@ export declare abstract class RemoteIcon { } export declare abstract class AbstractIconManager { protected static iconUniqueKey(iconId: number, serverUniqueId: string): string; + resolveIconInfo(icon: RemoteIconInfo): RemoteIcon; /** * @param iconId The requested icon * @param serverUniqueId The server unique id for the icon diff --git a/imports/shared-app/file/Utils.d.ts b/imports/shared-app/file/Utils.d.ts new file mode 100644 index 0000000..f4249dd --- /dev/null +++ b/imports/shared-app/file/Utils.d.ts @@ -0,0 +1,2 @@ +export declare const downloadTextAsFile: (text: string, name: string) => void; +export declare const requestFileAsText: () => Promise; diff --git a/imports/shared-app/i18n/localize.d.ts b/imports/shared-app/i18n/localize.d.ts index f901cb1..2a9f13b 100644 --- a/imports/shared-app/i18n/localize.d.ts +++ b/imports/shared-app/i18n/localize.d.ts @@ -62,7 +62,7 @@ export declare function registered_repositories(): TranslationRepository[]; export declare function delete_repository(repository: TranslationRepository): void; export declare function iterate_repositories(callback_entry: (repository: TranslationRepository) => any): Promise; export declare function select_translation(repository: TranslationRepository, entry: RepositoryTranslation): void; -export declare function initialize(): Promise; +export declare function initializeI18N(): Promise; declare global { interface Window { tr(message: string): string; diff --git a/imports/shared-app/main.d.ts b/imports/shared-app/main.d.ts index f5826ae..1af742a 100644 --- a/imports/shared-app/main.d.ts +++ b/imports/shared-app/main.d.ts @@ -21,6 +21,7 @@ import "./ui/elements/ContextDivider"; import "./ui/elements/Tab"; import "./clientservice"; import "./text/bbcode/InviteController"; +import "./text/bbcode/YoutubeController"; export declare function handleNativeConnectRequest(url: URL): void; export declare function handleConnectRequest(serverAddress: string, serverUniqueId: string | undefined, parameters: UrlParameterParser): Promise; export declare function handle_connect_request(properties: ConnectRequestData, _connection: ConnectionHandler): void; diff --git a/imports/shared-app/proto.d.ts b/imports/shared-app/proto.d.ts index c42bcfd..22d192e 100644 --- a/imports/shared-app/proto.d.ts +++ b/imports/shared-app/proto.d.ts @@ -7,7 +7,17 @@ declare global { remove(elem?: T): boolean; last?(): T; pop_front(): T | undefined; + /** + * @param entry The entry to toggle + * @returns `true` if the entry has been inserted and false if the entry has been deleted + */ toggle(entry: T): boolean; + /** + * @param entry The entry to toggle + * @param insert Whatever the entry should be in the array or not + * @returns `true` if the array has been modified + */ + toggle(entry: T, insert: boolean): any; } interface JSON { map_to(object: T, json: any, variables?: string | string[], validator?: (map_field: string, map_value: string) => boolean, variable_direction?: number): number; @@ -47,5 +57,18 @@ declare global { isSimilar(a: any, b: any): boolean; } } -declare const _default: {}; -export = _default; +export declare type IfEquals = (() => T extends X ? 1 : 2) extends (() => T extends Y ? 1 : 2) ? A : B; +export declare type WritableKeys = { + [P in keyof T]-?: IfEquals<{ + [Q in P]: T[P]; + }, { + -readonly [Q in P]: T[P]; + }, P, never>; +}[keyof T]; +export declare type ReadonlyKeys = { + [P in keyof T]: IfEquals<{ + [Q in P]: T[P]; + }, { + -readonly [Q in P]: T[P]; + }, never, P>; +}[keyof T]; diff --git a/imports/shared-app/settings.d.ts b/imports/shared-app/settings.d.ts index 21c79d8..54694c1 100644 --- a/imports/shared-app/settings.d.ts +++ b/imports/shared-app/settings.d.ts @@ -50,8 +50,7 @@ export declare namespace AppParameters { const KEY_CONNECT_CHANNEL_PASSWORD: RegistryKey; const KEY_IPC_APP_ADDRESS: RegistryKey; const KEY_IPC_CORE_PEER_ADDRESS: RegistryKey; - const KEY_MODAL_IDENTITY_CODE: RegistryKey; - const KEY_MODAL_TARGET: RegistryKey; + const KEY_MODAL_IPC_CHANNEL: RegistryKey; const KEY_LOAD_DUMMY_ERROR: ValuedRegistryKey; } export declare class StaticSettings { @@ -139,8 +138,13 @@ export declare class Settings { static readonly KEY_VIDEO_DYNAMIC_QUALITY: ValuedRegistryKey; static readonly KEY_VIDEO_DYNAMIC_FRAME_RATE: ValuedRegistryKey; static readonly KEY_VIDEO_QUICK_SETUP: ValuedRegistryKey; + static readonly KEY_VIDEO_SPOTLIGHT_MODE: ValuedRegistryKey; static readonly KEY_INVITE_SHORT_URL: ValuedRegistryKey; static readonly KEY_INVITE_ADVANCED_ENABLED: ValuedRegistryKey; + static readonly KEY_MICROPHONE_LEVEL_INDICATOR: RegistryKey; + static readonly KEY_MICROPHONE_THRESHOLD_ATTACK_SMOOTH: ValuedRegistryKey; + static readonly KEY_MICROPHONE_THRESHOLD_RELEASE_SMOOTH: ValuedRegistryKey; + static readonly KEY_MICROPHONE_THRESHOLD_RELEASE_DELAY: ValuedRegistryKey; static readonly FN_LOG_ENABLED: (category: string) => RegistryKey; static readonly FN_SEPARATOR_STATE: (separator: string) => RegistryKey; static readonly FN_LOG_LEVEL_ENABLED: (category: string) => RegistryKey; diff --git a/imports/shared-app/text/bbcode/YoutubeController.d.ts b/imports/shared-app/text/bbcode/YoutubeController.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/imports/shared-app/text/bbcode/YoutubeController.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/imports/shared-app/text/bbcode/youtube.d.ts b/imports/shared-app/text/bbcode/YoutubeRenderer.d.ts similarity index 100% rename from imports/shared-app/text/bbcode/youtube.d.ts rename to imports/shared-app/text/bbcode/YoutubeRenderer.d.ts diff --git a/imports/shared-app/text/bbcode/renderer.d.ts b/imports/shared-app/text/bbcode/renderer.d.ts index 142cb12..bc5d8aa 100644 --- a/imports/shared-app/text/bbcode/renderer.d.ts +++ b/imports/shared-app/text/bbcode/renderer.d.ts @@ -4,7 +4,7 @@ import ReactRenderer from "vendor/xbbcode/renderer/react"; import HTMLRenderer from "vendor/xbbcode/renderer/html"; import "./emoji"; import "./highlight"; -import "./youtube"; +import "./YoutubeRenderer"; import "./url"; import "./image"; export declare let BBCodeHandlerContext: Context; diff --git a/imports/shared-app/tree/Channel.d.ts b/imports/shared-app/tree/Channel.d.ts index c5fefc4..7f21b08 100644 --- a/imports/shared-app/tree/Channel.d.ts +++ b/imports/shared-app/tree/Channel.d.ts @@ -127,8 +127,7 @@ export declare class ChannelEntry extends ChannelTreeEntry { key: string; value: string; }[]): void; - generate_bbcode(): string; - generate_tag(braces?: boolean): JQuery; + generateBBCode(): string; channelType(): ChannelType; joinChannel(ignorePasswordFlag?: boolean): Promise; requestChannelPassword(ignorePermission: PermissionType): Promise<{ diff --git a/imports/shared-app/tree/Server.d.ts b/imports/shared-app/tree/Server.d.ts index c885254..bfce3f3 100644 --- a/imports/shared-app/tree/Server.d.ts +++ b/imports/shared-app/tree/Server.d.ts @@ -84,6 +84,7 @@ export interface ServerAddress { port: number; } export declare function parseServerAddress(address: string): ServerAddress | undefined; +export declare function stringifyServerAddress(address: ServerAddress): string; export interface ServerEvents extends ChannelTreeEntryEvents { notify_properties_updated: { updated_properties: Partial; diff --git a/imports/shared-app/ui/elements/Modal.d.ts b/imports/shared-app/ui/elements/Modal.d.ts index 517c7d6..df4fe87 100644 --- a/imports/shared-app/ui/elements/Modal.d.ts +++ b/imports/shared-app/ui/elements/Modal.d.ts @@ -42,6 +42,7 @@ export declare class Modal { export declare function createModal(data: ModalProperties | any): Modal; export declare class InputModalProperties extends ModalProperties { maxLength?: number; + defaultValue?: string; field_title?: string; field_label?: string; field_placeholder?: string; diff --git a/imports/shared-app/ui/frames/HostBannerRenderer.d.ts b/imports/shared-app/ui/frames/HostBannerRenderer.d.ts index f4b0265..09c6e32 100644 --- a/imports/shared-app/ui/frames/HostBannerRenderer.d.ts +++ b/imports/shared-app/ui/frames/HostBannerRenderer.d.ts @@ -1,6 +1,10 @@ import { Registry } from "tc-shared/events"; -import { HostBannerUiEvents } from "tc-shared/ui/frames/HostBannerDefinitions"; +import { HostBannerInfoSet, HostBannerUiEvents } from "tc-shared/ui/frames/HostBannerDefinitions"; import * as React from "react"; +export declare const HostBannerRenderer: React.MemoExoticComponent<(props: { + banner: HostBannerInfoSet; + className?: string; +}) => JSX.Element>; export declare const HostBanner: React.MemoExoticComponent<(props: { events: Registry; }) => JSX.Element>; diff --git a/imports/shared-app/ui/frames/ImagePreview.d.ts b/imports/shared-app/ui/frames/ImagePreview.d.ts new file mode 100644 index 0000000..525c3e5 --- /dev/null +++ b/imports/shared-app/ui/frames/ImagePreview.d.ts @@ -0,0 +1,5 @@ +import React from "react"; +export declare const ImagePreviewHook: React.MemoExoticComponent<() => JSX.Element>; +export declare function showImagePreview(url: string, originalUrl: string): void; +export declare function isImagePreviewAvailable(): boolean; +export declare function closeImagePreview(): void; diff --git a/imports/shared-app/ui/frames/control-bar/Controller.d.ts b/imports/shared-app/ui/frames/control-bar/Controller.d.ts index 1a6bfa9..12b5fbf 100644 --- a/imports/shared-app/ui/frames/control-bar/Controller.d.ts +++ b/imports/shared-app/ui/frames/control-bar/Controller.d.ts @@ -23,7 +23,7 @@ declare class InfoController { private unregisterCurrentHandlerEvents; setConnectionHandler(handler: ConnectionHandler): void; sendConnectionState(): void; - sendBookmarks(): void; + sendBookmarks(): Promise; sendAwayState(): void; sendMicrophoneState(): void; sendMicrophoneList(): void; diff --git a/imports/shared-app/ui/frames/image_preview.d.ts b/imports/shared-app/ui/frames/image_preview.d.ts deleted file mode 100644 index 2f545ac..0000000 --- a/imports/shared-app/ui/frames/image_preview.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -export declare function preview_image(url: string, original_url: string): void; -export declare function preview_image_tag(tag: JQuery): void; -export declare function current_url(): string; -export declare function close_preview(): void; diff --git a/imports/shared-app/ui/frames/video/Definitions.d.ts b/imports/shared-app/ui/frames/video/Definitions.d.ts index 6169ab4..e9d4bb5 100644 --- a/imports/shared-app/ui/frames/video/Definitions.d.ts +++ b/imports/shared-app/ui/frames/video/Definitions.d.ts @@ -80,8 +80,9 @@ export interface ChannelVideoEvents { action_video_scroll: { direction: "left" | "right"; }; - action_set_spotlight: { - videoId: string | undefined; + action_toggle_spotlight: { + videoIds: string[]; + enabled: boolean; expend: boolean; }; action_focus_spotlight: {}; @@ -143,7 +144,7 @@ export interface ChannelVideoEvents { right: boolean; }; notify_spotlight: { - videoId: string | undefined; + videoId: string[]; }; notify_video_statistics: { videoId: string | undefined; diff --git a/imports/shared-app/ui/frames/video/Renderer.d.ts b/imports/shared-app/ui/frames/video/Renderer.d.ts index 1ca9341..d707372 100644 --- a/imports/shared-app/ui/frames/video/Renderer.d.ts +++ b/imports/shared-app/ui/frames/video/Renderer.d.ts @@ -1,6 +1,11 @@ -/// +import * as React from "react"; import { Registry } from "tc-shared/events"; -import { ChannelVideoEvents } from "tc-shared/ui/frames/video/Definitions"; +import { ChannelVideoEvents } from "./Definitions"; +export declare const RendererVideoEventContext: React.Context>; +export declare const VideoContainer: React.MemoExoticComponent<(props: { + videoId: string; + isSpotlight: boolean; +}) => JSX.Element>; export declare const ChannelVideoRenderer: (props: { handlerId: string; events: Registry; diff --git a/imports/shared-app/ui/frames/video/RendererSpotlight.d.ts b/imports/shared-app/ui/frames/video/RendererSpotlight.d.ts new file mode 100644 index 0000000..f4aa8f2 --- /dev/null +++ b/imports/shared-app/ui/frames/video/RendererSpotlight.d.ts @@ -0,0 +1,9 @@ +import * as React from "react"; +import "!style-loader!css-loader?url=false!sass-loader?sourceMap=true!react-resizable/css/styles.css"; +import "!style-loader!css-loader?url=false!sass-loader?sourceMap=true!react-grid-layout/css/styles.css"; +export declare type SpotlightDimensions = { + width: number; + height: number; +}; +export declare const SpotlightDimensionsContext: React.Context; +export declare const Spotlight: () => JSX.Element; diff --git a/imports/shared-app/ui/htmltags.d.ts b/imports/shared-app/ui/htmltags.d.ts index cbd36e7..19cef54 100644 --- a/imports/shared-app/ui/htmltags.d.ts +++ b/imports/shared-app/ui/htmltags.d.ts @@ -5,17 +5,8 @@ export interface ClientProperties { add_braces?: boolean; client_database_id?: number; } -export interface ChannelProperties { - channel_id: number; - channel_name: string; - channel_display_name?: string; - add_braces?: boolean; -} export declare function generate_client(properties: ClientProperties): string; export declare function generate_client_object(properties: ClientProperties): JQuery; -export declare function generate_channel(properties: ChannelProperties): string; -export declare function generate_channel_object(properties: ChannelProperties): JQuery; export declare namespace callbacks { function callback_context_client(element: JQuery): boolean; - function callback_context_channel(element: JQuery): boolean; } diff --git a/imports/shared-app/ui/modal/ModalChangeVolumeNew.d.ts b/imports/shared-app/ui/modal/ModalChangeVolumeNew.d.ts index 8d7ad58..56cdcf4 100644 --- a/imports/shared-app/ui/modal/ModalChangeVolumeNew.d.ts +++ b/imports/shared-app/ui/modal/ModalChangeVolumeNew.d.ts @@ -18,5 +18,5 @@ export interface VolumeChangeEvents { }; "close-modal": {}; } -export declare function spawnClientVolumeChange(client: ClientEntry): import("../react-elements/internal-modal/Controller").InternalModalController; -export declare function spawnMusicBotVolumeChange(client: MusicClientEntry, maxValue: number): import("../react-elements/internal-modal/Controller").InternalModalController; +export declare function spawnClientVolumeChange(client: ClientEntry): import("../react-elements/modal/Definitions").ModalController; +export declare function spawnMusicBotVolumeChange(client: MusicClientEntry, maxValue: number): import("../react-elements/modal/Definitions").ModalController; diff --git a/imports/shared-app/ui/modal/ModalInvite.d.ts b/imports/shared-app/ui/modal/ModalInvite.d.ts deleted file mode 100644 index 3dd6af8..0000000 --- a/imports/shared-app/ui/modal/ModalInvite.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import { ConnectionHandler } from "../../ConnectionHandler"; -export declare function spawnInviteEditor(connection: ConnectionHandler): void; diff --git a/imports/shared-app/ui/modal/ModalPoke.d.ts b/imports/shared-app/ui/modal/ModalPoke.d.ts deleted file mode 100644 index 1f54ac2..0000000 --- a/imports/shared-app/ui/modal/ModalPoke.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { ConnectionHandler } from "../../ConnectionHandler"; -export interface ServerEntry { - source: ConnectionHandler; - add_message(invoker: PokeInvoker, message: string): any; -} -export declare type PokeInvoker = { - name: string; - id: number; - unique_id: string; -}; -export declare function spawnPoke(source: ConnectionHandler, invoker: PokeInvoker, message: string): void; diff --git a/imports/shared-app/ui/modal/bookmarks-add-server/Controller.d.ts b/imports/shared-app/ui/modal/bookmarks-add-server/Controller.d.ts new file mode 100644 index 0000000..9bdf965 --- /dev/null +++ b/imports/shared-app/ui/modal/bookmarks-add-server/Controller.d.ts @@ -0,0 +1,2 @@ +import { ConnectionHandler } from "tc-shared/ConnectionHandler"; +export declare function spawnModalAddCurrentServerToBookmarks(handler: ConnectionHandler): void; diff --git a/imports/shared-app/ui/modal/bookmarks-add-server/Definitions.d.ts b/imports/shared-app/ui/modal/bookmarks-add-server/Definitions.d.ts new file mode 100644 index 0000000..574b5bc --- /dev/null +++ b/imports/shared-app/ui/modal/bookmarks-add-server/Definitions.d.ts @@ -0,0 +1,21 @@ +export declare type TargetBookmarkInfo = { + type: "success"; + handlerId: string; + serverName: string; + serverUniqueId: string; + currentChannelId: number; + currentChannelName: string; +} | { + type: "not-connected" | "loading"; +}; +export interface ModalBookmarksAddServerVariables { + readonly serverInfo: TargetBookmarkInfo; + bookmarkName: string; + bookmarkNameValid: boolean; + saveCurrentChannel: boolean; +} +export interface ModalBookmarksAddServerEvents { + action_add_bookmark: {}; + action_cancel: {}; + notify_bookmark_added: {}; +} diff --git a/imports/shared-app/ui/modal/bookmarks-add-server/Renderer.d.ts b/imports/shared-app/ui/modal/bookmarks-add-server/Renderer.d.ts new file mode 100644 index 0000000..f66e81b --- /dev/null +++ b/imports/shared-app/ui/modal/bookmarks-add-server/Renderer.d.ts @@ -0,0 +1,13 @@ +import { AbstractModal } from "tc-shared/ui/react-elements/modal/Definitions"; +import React from "react"; +import { IpcRegistryDescription } from "tc-events"; +import { ModalBookmarksAddServerEvents, ModalBookmarksAddServerVariables } from "tc-shared/ui/modal/bookmarks-add-server/Definitions"; +import { IpcVariableDescriptor } from "tc-shared/ui/utils/IpcVariable"; +declare class ModalBookmarksAddServer extends AbstractModal { + private readonly variables; + private readonly events; + constructor(events: IpcRegistryDescription, variables: IpcVariableDescriptor); + renderBody(): React.ReactElement; + renderTitle(): string | React.ReactElement; +} +export = ModalBookmarksAddServer; diff --git a/imports/shared-app/ui/modal/ModalBookmarks.d.ts b/imports/shared-app/ui/modal/bookmarks/Controller.d.ts similarity index 100% rename from imports/shared-app/ui/modal/ModalBookmarks.d.ts rename to imports/shared-app/ui/modal/bookmarks/Controller.d.ts diff --git a/imports/shared-app/ui/modal/bookmarks/Definitions.d.ts b/imports/shared-app/ui/modal/bookmarks/Definitions.d.ts new file mode 100644 index 0000000..bb922bd --- /dev/null +++ b/imports/shared-app/ui/modal/bookmarks/Definitions.d.ts @@ -0,0 +1,87 @@ +import { RemoteIconInfo } from "tc-shared/file/Icons"; +export declare type BookmarkListEntry = { + uniqueId: string; + type: "bookmark" | "directory"; + displayName: string; + icon: RemoteIconInfo | undefined; + depth: number; + childCount: number; +}; +export interface BookmarkConnectInfo { + serverName: string; + serverRegion: string; + clientsOnline: number; + clientsMax: number; + connectCountUniqueId: number; + connectCountAddress: number; + hostBannerUrl: string; + hostBannerMode: number; +} +export declare type CurrentClientChannel = { + name: string; + channelId: number; + path: string; + passwordHash: string; +}; +export interface ModalBookmarkVariables { + readonly bookmarks: BookmarkListEntry[]; + bookmarkSelected: { + type?: "empty" | "bookmark" | "directory"; + id: string | undefined; + }; + readonly connectProfiles: { + id: string; + name: string; + }[]; + readonly currentClientChannel: CurrentClientChannel | undefined; + bookmarkName: string; + bookmarkConnectProfile: string; + bookmarkConnectOnStartup: boolean; + bookmarkServerAddress: string; + bookmarkServerPassword: string | undefined; + bookmarkDefaultChannel: string | undefined; + bookmarkDefaultChannelPassword: string | undefined; + bookmarkInfo: BookmarkConnectInfo | undefined; +} +export interface ModalBookmarkEvents { + action_create_bookmark: { + entryType: "bookmark" | "directory"; + order: { + type: "previous"; + entry: string; + } | { + type: "parent"; + entry: string; + } | { + type: "selected"; + }; + displayName: string | undefined; + }; + action_duplicate_bookmark: { + uniqueId: string; + displayName: string | undefined; + originalName: string; + }; + action_delete_bookmark: { + uniqueId: string; + }; + action_connect: { + uniqueId: string; + newTab: boolean; + closeModal: boolean; + }; + action_export: {}; + action_import: { + payload: string | undefined; + }; + notify_export_data: { + payload: string; + }; + notify_import_result: { + status: "success"; + importedBookmarks: number; + } | { + status: "error"; + message: string; + }; +} diff --git a/imports/shared-app/ui/modal/bookmarks/Renderer.d.ts b/imports/shared-app/ui/modal/bookmarks/Renderer.d.ts new file mode 100644 index 0000000..0d422d0 --- /dev/null +++ b/imports/shared-app/ui/modal/bookmarks/Renderer.d.ts @@ -0,0 +1,15 @@ +import { AbstractModal } from "tc-shared/ui/react-elements/modal/Definitions"; +import { IpcVariableDescriptor } from "tc-shared/ui/utils/IpcVariable"; +import { ModalBookmarkEvents, ModalBookmarkVariables } from "tc-shared/ui/modal/bookmarks/Definitions"; +import { IpcRegistryDescription, Registry } from "tc-events"; +import { UiVariableConsumer } from "tc-shared/ui/utils/Variable"; +import * as React from "react"; +declare class ModalBookmarks extends AbstractModal { + readonly events: Registry; + readonly variables: UiVariableConsumer; + constructor(events: IpcRegistryDescription, variables: IpcVariableDescriptor); + protected onDestroy(): void; + renderBody(): React.ReactElement; + renderTitle(): string | React.ReactElement; +} +export = ModalBookmarks; diff --git a/imports/shared-app/ui/modal/connect/Renderer.d.ts b/imports/shared-app/ui/modal/connect/Renderer.d.ts index bbeb72f..39651a0 100644 --- a/imports/shared-app/ui/modal/connect/Renderer.d.ts +++ b/imports/shared-app/ui/modal/connect/Renderer.d.ts @@ -11,7 +11,6 @@ declare class ConnectModal extends AbstractModal { protected onDestroy(): void; renderBody(): React.ReactElement; renderTitle(): string | React.ReactElement; - color(): "none" | "blue"; verticalAlignment(): "top" | "center" | "bottom"; } export = ConnectModal; diff --git a/imports/shared-app/ui/modal/permission/ModalPermissionEditor.d.ts b/imports/shared-app/ui/modal/permission/ModalPermissionEditor.d.ts index ae5224b..e9d2925 100644 --- a/imports/shared-app/ui/modal/permission/ModalPermissionEditor.d.ts +++ b/imports/shared-app/ui/modal/permission/ModalPermissionEditor.d.ts @@ -50,7 +50,7 @@ export interface PermissionModalEvents { id: number | string | undefined; }; action_set_permission_editor_subject: { - mode: PermissionEditorSubject; + mode: PermissionEditorSubject | undefined; groupId?: number; channelId?: number; clientDatabaseId?: number; @@ -108,32 +108,18 @@ export interface PermissionModalEvents { query_groups: { target: "server" | "channel"; }; - query_groups_result: { - target: "server" | "channel"; - groups: GroupProperties[]; - }; query_group_clients: { id: number; }; - query_group_clients_result: { - id: number; - status: "success" | "error" | "no-permissions"; - error?: string; - clients?: { - name: string; - databaseId: number; - uniqueId: string; - }[]; - }; query_channels: {}; - query_channels_result: { - channels: ChannelInfo[]; - }; query_client_permissions: {}; query_client_info: { client: number | string; }; - query_client_info_result: { + notify_channels: { + channels: ChannelInfo[]; + }; + notify_client_info: { client: number | string; state: "success" | "error" | "no-such-client" | "no-permission"; error?: string; @@ -157,7 +143,21 @@ export interface PermissionModalEvents { target: "server" | "channel"; groups: number[]; }; + notify_group_clients: { + id: number; + status: "success" | "error" | "no-permissions"; + error?: string; + clients?: { + name: string; + databaseId: number; + uniqueId: string; + }[]; + }; notify_groups_reset: {}; + notify_groups: { + target: "server" | "channel"; + groups: GroupProperties[]; + }; notify_client_permissions: { permissionModifyPower: number; serverGroupCreate: boolean; diff --git a/imports/shared-app/ui/modal/poke/Controller.d.ts b/imports/shared-app/ui/modal/poke/Controller.d.ts new file mode 100644 index 0000000..0b4317b --- /dev/null +++ b/imports/shared-app/ui/modal/poke/Controller.d.ts @@ -0,0 +1,6 @@ +import { ConnectionHandler } from "tc-shared/ConnectionHandler"; +export declare function spawnPokeModal(handler: ConnectionHandler, client: { + clientName: string; + clientId: number; + clientUniqueId: string; +}, message: string): void; diff --git a/imports/shared-app/ui/modal/poke/Definitions.d.ts b/imports/shared-app/ui/modal/poke/Definitions.d.ts new file mode 100644 index 0000000..c21175a --- /dev/null +++ b/imports/shared-app/ui/modal/poke/Definitions.d.ts @@ -0,0 +1,17 @@ +export declare type PokeRecord = { + uniqueId: string; + timestamp: number; + handlerId: string; + serverName: string; + serverUniqueId: string; + clientId: number; + clientUniqueId: string; + clientName: string; + message: string; +}; +export interface ModalPokeVariables { + readonly pokeList: PokeRecord[]; +} +export interface ModalPokeEvents { + action_close: {}; +} diff --git a/imports/shared-app/ui/modal/poke/Renderer.d.ts b/imports/shared-app/ui/modal/poke/Renderer.d.ts new file mode 100644 index 0000000..23f8e23 --- /dev/null +++ b/imports/shared-app/ui/modal/poke/Renderer.d.ts @@ -0,0 +1,15 @@ +import { AbstractModal } from "tc-shared/ui/react-elements/modal/Definitions"; +import React from "react"; +import { UiVariableConsumer } from "tc-shared/ui/utils/Variable"; +import { ModalPokeEvents, ModalPokeVariables } from "tc-shared/ui/modal/poke/Definitions"; +import { IpcRegistryDescription, Registry } from "tc-events"; +import { IpcVariableDescriptor } from "tc-shared/ui/utils/IpcVariable"; +declare class PokeModal extends AbstractModal { + readonly variables: UiVariableConsumer; + readonly events: Registry; + constructor(events: IpcRegistryDescription, variables: IpcVariableDescriptor); + renderBody(): React.ReactElement; + renderTitle(): string | React.ReactElement; + verticalAlignment(): "top" | "center" | "bottom"; +} +export default PokeModal; diff --git a/imports/shared-app/ui/modal/settings/Microphone.d.ts b/imports/shared-app/ui/modal/settings/Microphone.d.ts index 6de8a45..77c2b80 100644 --- a/imports/shared-app/ui/modal/settings/Microphone.d.ts +++ b/imports/shared-app/ui/modal/settings/Microphone.d.ts @@ -1,5 +1,5 @@ import { Registry } from "tc-shared/events"; -import { DeviceListState } from "tc-shared/audio/recorder"; +import { DeviceListState } from "tc-shared/audio/Recorder"; export declare type MicrophoneSetting = "volume" | "vad-type" | "ppt-key" | "ppt-release-delay" | "ppt-release-delay-active" | "threshold-threshold" | "rnnoise"; export declare type MicrophoneDevice = { id: string; @@ -42,8 +42,6 @@ export interface MicrophoneSettingsEvents { target: SelectedMicrophone; }; "action_set_selected_device_result": { - status: "success"; - } | { status: "error"; reason: string; }; diff --git a/imports/shared-app/ui/modal/transfer/FileBrowserControllerRemote.d.ts b/imports/shared-app/ui/modal/transfer/FileBrowserControllerRemote.d.ts index 6ef9896..17c17db 100644 --- a/imports/shared-app/ui/modal/transfer/FileBrowserControllerRemote.d.ts +++ b/imports/shared-app/ui/modal/transfer/FileBrowserControllerRemote.d.ts @@ -1,4 +1,4 @@ import { ConnectionHandler } from "../../../ConnectionHandler"; -import { Registry } from "../../../events"; +import { Registry } from "tc-events"; import { FileBrowserEvents } from "tc-shared/ui/modal/transfer/FileDefinitions"; export declare function initializeRemoteFileBrowserController(connection: ConnectionHandler, events: Registry): void; diff --git a/imports/shared-app/ui/modal/transfer/FileTransferInfoController.d.ts b/imports/shared-app/ui/modal/transfer/FileTransferInfoController.d.ts index 5c0040e..eb9f702 100644 --- a/imports/shared-app/ui/modal/transfer/FileTransferInfoController.d.ts +++ b/imports/shared-app/ui/modal/transfer/FileTransferInfoController.d.ts @@ -1,4 +1,4 @@ import { ConnectionHandler } from "../../../ConnectionHandler"; -import { Registry } from "../../../events"; +import { Registry } from "tc-events"; import { TransferInfoEvents } from "tc-shared/ui/modal/transfer/FileTransferInfoDefinitions"; export declare const initializeTransferInfoController: (connection: ConnectionHandler, events: Registry) => void; diff --git a/imports/shared-app/ui/modal/video-source/Renderer.d.ts b/imports/shared-app/ui/modal/video-source/Renderer.d.ts index 0628a1e..7a5e79d 100644 --- a/imports/shared-app/ui/modal/video-source/Renderer.d.ts +++ b/imports/shared-app/ui/modal/video-source/Renderer.d.ts @@ -1,9 +1,9 @@ import { Registry } from "tc-shared/events"; import * as React from "react"; import { ModalVideoSourceEvents } from "tc-shared/ui/modal/video-source/Definitions"; -import { InternalModal } from "tc-shared/ui/react-elements/internal-modal/Controller"; import { Translatable } from "tc-shared/ui/react-elements/i18n"; import { VideoBroadcastType } from "tc-shared/connection/VideoConnection"; +import { InternalModal } from "tc-shared/ui/react-elements/modal/Definitions"; export declare class ModalVideoSource extends InternalModal { protected readonly events: Registry; private readonly sourceType; diff --git a/imports/shared-app/ui/modal/whats-new/Definitions.d.ts b/imports/shared-app/ui/modal/whats-new/Definitions.d.ts new file mode 100644 index 0000000..c96e8de --- /dev/null +++ b/imports/shared-app/ui/modal/whats-new/Definitions.d.ts @@ -0,0 +1,4 @@ +export interface ModalWhatsNewVariables { +} +export interface ModalWhatsNewEvents { +} diff --git a/imports/shared-app/ui/react-elements/Button.d.ts b/imports/shared-app/ui/react-elements/Button.d.ts index abb9573..9273f93 100644 --- a/imports/shared-app/ui/react-elements/Button.d.ts +++ b/imports/shared-app/ui/react-elements/Button.d.ts @@ -1,4 +1,3 @@ -import { ReactComponentBase } from "tc-shared/ui/react-elements/ReactComponentBase"; import * as React from "react"; export interface ButtonProperties { color?: "green" | "blue" | "red" | "purple" | "brown" | "yellow" | "default" | "none"; @@ -13,7 +12,7 @@ export interface ButtonProperties { export interface ButtonState { disabled?: boolean; } -export declare class Button extends ReactComponentBase { - protected defaultState(): ButtonState; +export declare class Button extends React.Component { + constructor(props: any); render(): JSX.Element; } diff --git a/imports/shared-app/ui/react-elements/CountryIcon.d.ts b/imports/shared-app/ui/react-elements/CountryIcon.d.ts new file mode 100644 index 0000000..1c57f67 --- /dev/null +++ b/imports/shared-app/ui/react-elements/CountryIcon.d.ts @@ -0,0 +1,5 @@ +/// +export declare const CountryIcon: (props: { + country: string; + className?: string; +}) => JSX.Element; diff --git a/imports/shared-app/ui/react-elements/ErrorBoundary.d.ts b/imports/shared-app/ui/react-elements/ErrorBoundary.d.ts index 16761fe..2559447 100644 --- a/imports/shared-app/ui/react-elements/ErrorBoundary.d.ts +++ b/imports/shared-app/ui/react-elements/ErrorBoundary.d.ts @@ -2,7 +2,7 @@ import * as React from "react"; interface ErrorBoundaryState { errorOccurred: boolean; } -export declare class ErrorBoundary extends React.Component<{}, ErrorBoundaryState> { +export declare class ErrorBoundary extends React.PureComponent<{}, ErrorBoundaryState> { constructor(props: any); render(): {}; componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void; diff --git a/imports/shared-app/ui/react-elements/FontSize.d.ts b/imports/shared-app/ui/react-elements/FontSize.d.ts new file mode 100644 index 0000000..81ac10b --- /dev/null +++ b/imports/shared-app/ui/react-elements/FontSize.d.ts @@ -0,0 +1,4 @@ +import * as React from "react"; +export declare const FontSizeObserver: React.MemoExoticComponent<(props: { + children: (fontSize: number) => string | number | boolean | {} | React.ReactElement React.ReactElement React.Component)>) | (new (props: any) => React.Component)> | React.ReactNodeArray | React.ReactPortal | React.ReactNode[]; +}) => JSX.Element>; diff --git a/imports/shared-app/ui/react-elements/Helper.d.ts b/imports/shared-app/ui/react-elements/Helper.d.ts index b8dfcf0..2589a49 100644 --- a/imports/shared-app/ui/react-elements/Helper.d.ts +++ b/imports/shared-app/ui/react-elements/Helper.d.ts @@ -3,5 +3,5 @@ import { RegistryKey, RegistryValueType, ValuedRegistryKey } from "tc-shared/set export declare function useDependentState(factory: (prevState?: S) => S, inputs: ReadonlyArray): [S, Dispatch>]; export declare function useTr(message: string): string; export declare function joinClassList(...classes: any[]): string; -export declare function useGlobalSetting(key: RegistryKey, defaultValue: DV): V | DV; export declare function useGlobalSetting(key: ValuedRegistryKey, defaultValue?: V): V; +export declare function useGlobalSetting(key: RegistryKey, defaultValue: DV): V | DV; diff --git a/imports/shared-app/ui/react-elements/InputField.d.ts b/imports/shared-app/ui/react-elements/InputField.d.ts index 31f4528..45011de 100644 --- a/imports/shared-app/ui/react-elements/InputField.d.ts +++ b/imports/shared-app/ui/react-elements/InputField.d.ts @@ -20,6 +20,7 @@ export declare const ControlledBoxedInputField: (props: { onFocus?: () => void; onBlur?: () => void; finishOnEnter?: boolean; + refInput?: React.RefObject; }) => JSX.Element; export interface BoxedInputFieldProperties { prefix?: string; diff --git a/imports/shared-app/ui/react-elements/Tooltip.d.ts b/imports/shared-app/ui/react-elements/Tooltip.d.ts index f664467..aecc918 100644 --- a/imports/shared-app/ui/react-elements/Tooltip.d.ts +++ b/imports/shared-app/ui/react-elements/Tooltip.d.ts @@ -8,6 +8,7 @@ export interface TooltipState { } export interface TooltipProperties { tooltip: () => ReactElement | ReactElement[] | string; + className?: string; } export declare class Tooltip extends React.Component { readonly tooltipId: string; @@ -23,4 +24,5 @@ export declare class Tooltip extends React.Component React.ReactElement React.Component)>) | (new (props: any) => React.Component)> | React.ReactElement React.ReactElement React.Component)>) | (new (props: any) => React.Component)>[]; className?: string; + outerClassName?: string; }) => JSX.Element; diff --git a/imports/shared-app/ui/react-elements/external-modal/Controller.d.ts b/imports/shared-app/ui/react-elements/external-modal/Controller.d.ts deleted file mode 100644 index 3f4fdc8..0000000 --- a/imports/shared-app/ui/react-elements/external-modal/Controller.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { ChannelMessage } from "../../../ipc/BrowserIPC"; -import { Registry } from "tc-events"; -import { EventControllerBase, Popout2ControllerMessages, PopoutIPCMessage } from "../../../ui/react-elements/external-modal/IPCMessage"; -import { ModalController, ModalEvents, ModalOptions, ModalState } from "../../../ui/react-elements/ModalDefinitions"; -export declare abstract class AbstractExternalModalController extends EventControllerBase<"controller"> implements ModalController { - readonly modalType: string; - readonly constructorArguments: any[]; - private readonly modalEvents; - private modalState; - private readonly documentUnloadListener; - private callbackWindowInitialized; - protected constructor(modalType: string, constructorArguments: any[]); - getOptions(): Readonly; - getEvents(): Registry; - getState(): ModalState; - protected abstract spawnWindow(): Promise; - protected abstract focusWindow(): void; - protected abstract destroyWindow(): void; - show(): Promise; - private doDestroyWindow; - hide(): Promise; - destroy(): void; - protected handleWindowClosed(): void; - protected handleIPCMessage(remoteId: string, broadcast: boolean, message: ChannelMessage): void; - protected handleTypedIPCMessage(remoteId: string, isBroadcast: boolean, type: T, payload: PopoutIPCMessage[T]): void; -} diff --git a/imports/shared-app/ui/react-elements/external-modal/IPCMessage.d.ts b/imports/shared-app/ui/react-elements/external-modal/IPCMessage.d.ts deleted file mode 100644 index 44ef4c1..0000000 --- a/imports/shared-app/ui/react-elements/external-modal/IPCMessage.d.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { IPCChannel } from "../../../ipc/BrowserIPC"; -export declare const kPopoutIPCChannelId = "popout-channel"; -export interface PopoutIPCMessage { - "hello-popout": { - version: string; - authenticationCode: string; - }; - "hello-controller": { - accepted: boolean; - message?: string; - constructorArguments?: any[]; - }; - "invoke-modal-action": { - action: "close" | "minimize"; - }; -} -export declare type Controller2PopoutMessages = "hello-controller"; -export declare type Popout2ControllerMessages = "hello-popout" | "invoke-modal-action"; -export interface SendIPCMessage { - "controller": Controller2PopoutMessages; - "popout": Popout2ControllerMessages; -} -export interface ReceivedIPCMessage { - "controller": Popout2ControllerMessages; - "popout": Controller2PopoutMessages; -} -export declare abstract class EventControllerBase { - protected readonly ipcAuthenticationCode: string; - protected ipcRemotePeerId: string; - protected ipcChannel: IPCChannel; - protected constructor(ipcAuthenticationCode: string); - protected sendIPCMessage(type: T, payload: PopoutIPCMessage[T]): void; - protected handleTypedIPCMessage(remoteId: string, isBroadcast: boolean, type: T, payload: PopoutIPCMessage[T]): void; - protected destroyIPC(): void; -} diff --git a/imports/shared-app/ui/react-elements/external-modal/PopoutController.d.ts b/imports/shared-app/ui/react-elements/external-modal/PopoutController.d.ts deleted file mode 100644 index 4f30f55..0000000 --- a/imports/shared-app/ui/react-elements/external-modal/PopoutController.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { Controller2PopoutMessages, EventControllerBase, PopoutIPCMessage } from "../../../ui/react-elements/external-modal/IPCMessage"; -export declare function getPopoutController(): PopoutController; -declare class PopoutController extends EventControllerBase<"popout"> { - private constructorArguments; - private callbackControllerHello; - constructor(); - getConstructorArguments(): any[]; - initialize(): Promise; - protected handleTypedIPCMessage(remoteId: string, isBroadcast: boolean, type: T, payload: PopoutIPCMessage[T]): void; - doClose(): void; - doMinimize(): void; -} -export {}; diff --git a/imports/shared-app/ui/react-elements/external-modal/PopoutEntrypoint.d.ts b/imports/shared-app/ui/react-elements/external-modal/PopoutEntrypoint.d.ts deleted file mode 100644 index e3274b3..0000000 --- a/imports/shared-app/ui/react-elements/external-modal/PopoutEntrypoint.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import "../../../file/RemoteAvatars"; -import "../../../file/RemoteIcons"; diff --git a/imports/shared-app/ui/react-elements/external-modal/PopoutRendererClient.d.ts b/imports/shared-app/ui/react-elements/external-modal/PopoutRendererClient.d.ts deleted file mode 100644 index 94a2947..0000000 --- a/imports/shared-app/ui/react-elements/external-modal/PopoutRendererClient.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { AbstractModal, ModalRenderer } from "tc-shared/ui/react-elements/ModalDefinitions"; -export interface ModalControlFunctions { - close(): any; - minimize(): any; -} -export declare class ClientModalRenderer implements ModalRenderer { - private readonly functionController; - private readonly titleElement; - private readonly container; - private readonly titleChangeObserver; - private titleContainer; - private currentModal; - constructor(functionController: ModalControlFunctions); - renderModal(modal: AbstractModal | undefined): void; - private updateTitle; -} diff --git a/imports/shared-app/ui/react-elements/external-modal/PopoutRendererWeb.d.ts b/imports/shared-app/ui/react-elements/external-modal/PopoutRendererWeb.d.ts deleted file mode 100644 index 4fbd805..0000000 --- a/imports/shared-app/ui/react-elements/external-modal/PopoutRendererWeb.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { AbstractModal, ModalRenderer } from "tc-shared/ui/react-elements/ModalDefinitions"; -export declare class WebModalRenderer implements ModalRenderer { - private readonly titleRenderer; - private readonly bodyRenderer; - private currentModal; - constructor(); - renderModal(modal: AbstractModal | undefined): void; -} diff --git a/imports/shared-app/ui/react-elements/external-modal/index.d.ts b/imports/shared-app/ui/react-elements/external-modal/index.d.ts deleted file mode 100644 index 72ddee3..0000000 --- a/imports/shared-app/ui/react-elements/external-modal/index.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import "./Controller"; -import { ModalController, ModalOptions } from "../ModalDefinitions"; -export declare type ControllerFactory = (modalType: string, constructorArguments?: any[], options?: ModalOptions) => ModalController; -export declare function setExternalModalControllerFactory(factory: ControllerFactory): void; -export declare function spawnExternalModal(modalType: string, constructorArguments?: any[], options?: ModalOptions): ModalController; diff --git a/imports/shared-app/ui/react-elements/i18n/index.d.ts b/imports/shared-app/ui/react-elements/i18n/index.d.ts index d3adc50..fcfa8f1 100644 --- a/imports/shared-app/ui/react-elements/i18n/index.d.ts +++ b/imports/shared-app/ui/react-elements/i18n/index.d.ts @@ -1,9 +1,7 @@ import * as React from "react"; export declare class Translatable extends React.Component<{ children: string | (string | React.ReactElement)[]; - __cacheKey?: string; trIgnore?: boolean; - enforceTextOnly?: boolean; }, { translated: string; }> { @@ -16,7 +14,6 @@ export declare class Translatable extends React.Component<{ export declare type VariadicTranslatableChild = React.ReactElement | string | number; export declare const VariadicTranslatable: (props: { text: string; - __cacheKey?: string; children?: string | number | React.ReactElement React.ReactElement React.Component)>) | (new (props: any) => React.Component)> | VariadicTranslatableChild[]; }) => JSX.Element; declare global { diff --git a/imports/shared-app/ui/react-elements/internal-modal/Controller.d.ts b/imports/shared-app/ui/react-elements/internal-modal/Controller.d.ts deleted file mode 100644 index 544dea8..0000000 --- a/imports/shared-app/ui/react-elements/internal-modal/Controller.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { Registry } from "../../../events"; -import { AbstractModal, ModalController, ModalEvents, ModalOptions, ModalState } from "../../../ui/react-elements/ModalDefinitions"; -import { RegisteredModal } from "tc-shared/ui/react-elements/modal/Registry"; -export declare class InternalModalController implements ModalController { - readonly events: Registry; - private readonly modalType; - private readonly constructorArguments; - private modalInstance; - private initializedPromise; - private domElement; - private refModal; - private modalState_; - constructor(modalType: RegisteredModal, constructorArguments: any[]); - getOptions(): Readonly; - getEvents(): Registry; - getState(): ModalState; - private initialize; - show(): Promise; - hide(): Promise; - destroy(): void; -} -export declare abstract class InternalModal extends AbstractModal { -} diff --git a/imports/shared-app/ui/react-elements/internal-modal/Renderer.d.ts b/imports/shared-app/ui/react-elements/internal-modal/Renderer.d.ts deleted file mode 100644 index 7ba4ad4..0000000 --- a/imports/shared-app/ui/react-elements/internal-modal/Renderer.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -import * as React from "react"; -import { AbstractModal } from "tc-shared/ui/react-elements/ModalDefinitions"; -export declare const InternalModalContentRenderer: React.MemoExoticComponent<(props: { - modal: AbstractModal; - onClose?: () => void; - onMinimize?: () => void; - containerClass?: string; - headerClass?: string; - headerTitleClass?: string; - bodyClass?: string; - refContent?: React.Ref; -}) => JSX.Element>; -export declare class InternalModalRenderer extends React.PureComponent<{ - modal: AbstractModal; - onClose: () => void; -}, { - show: boolean; -}> { - private readonly refModal; - constructor(props: any); - render(): JSX.Element; - private onBackdropClick; -} diff --git a/imports/shared-app/ui/react-elements/modal/Controller.d.ts b/imports/shared-app/ui/react-elements/modal/Controller.d.ts new file mode 100644 index 0000000..379f47b --- /dev/null +++ b/imports/shared-app/ui/react-elements/modal/Controller.d.ts @@ -0,0 +1,22 @@ +import { InternalModal, ModalConstructorArguments, ModalController, ModalEvents, ModalOptions, ModalState } from "tc-shared/ui/react-elements/modal/Definitions"; +import { Registry } from "tc-events"; +export declare class GenericModalController implements ModalController { + private readonly events; + private readonly modalType; + private readonly modalConstructorArguments; + private readonly modalOptions; + private modalKlass; + private instance; + private popedOut; + static fromInternalModal(klass: new (...args: any[]) => ModalClass, constructorArguments: any[]): GenericModalController<"__internal__modal__">; + constructor(modalType: T, constructorArguments: ModalConstructorArguments[T], options: ModalOptions); + private getModalClass; + private createModalInstance; + private destroyModalInstance; + destroy(): void; + getEvents(): Registry; + getOptions(): Readonly; + getState(): ModalState; + hide(): Promise; + show(): Promise; +} diff --git a/imports/shared-app/ui/react-elements/modal/Definitions.d.ts b/imports/shared-app/ui/react-elements/modal/Definitions.d.ts index bb394b4..73d1a23 100644 --- a/imports/shared-app/ui/react-elements/modal/Definitions.d.ts +++ b/imports/shared-app/ui/react-elements/modal/Definitions.d.ts @@ -4,9 +4,11 @@ import { ChannelEditEvents } from "tc-shared/ui/modal/channel-edit/Definitions"; import { EchoTestEvents } from "tc-shared/ui/modal/echo-test/Definitions"; import { ModalGlobalSettingsEditorEvents } from "tc-shared/ui/modal/global-settings-editor/Definitions"; import { InviteUiEvents, InviteUiVariables } from "tc-shared/ui/modal/invite/Definitions"; -import { ReactElement } from "react"; -import * as React from "react"; +import React, { ReactElement } from "react"; import { IpcVariableDescriptor } from "tc-shared/ui/utils/IpcVariable"; +import { ModalBookmarkEvents, ModalBookmarkVariables } from "tc-shared/ui/modal/bookmarks/Definitions"; +import { ModalBookmarksAddServerEvents, ModalBookmarksAddServerVariables } from "tc-shared/ui/modal/bookmarks-add-server/Definitions"; +import { ModalPokeEvents, ModalPokeVariables } from "tc-shared/ui/modal/poke/Definitions"; export declare type ModalType = "error" | "warning" | "info" | "none"; export declare type ModalRenderType = "page" | "dialog"; export interface ModalOptions { @@ -45,13 +47,6 @@ export interface ModalOptions { */ popedOut?: boolean; } -export interface ModalFunctionController { - minimize(): any; - supportMinimize(): boolean; - maximize(): any; - supportMaximize(): boolean; - close(): any; -} export interface ModalEvents { "open": {}; "close": {}; @@ -62,6 +57,22 @@ export declare enum ModalState { HIDDEN = 1, DESTROYED = 2 } +export interface ModalInstanceEvents { + action_close: {}; + action_minimize: {}; + action_popout: {}; + notify_open: {}; + notify_minimize: {}; + notify_close: {}; + notify_destroy: {}; +} +export interface ModalInstanceController { + getState(): ModalState; + getEvents(): Registry; + show(): Promise; + hide(): Promise; + destroy(): any; +} export interface ModalController { getOptions(): Readonly; getEvents(): Registry; @@ -70,7 +81,11 @@ export interface ModalController { hide(): Promise; destroy(): any; } +export interface ModalInstanceProperties { + windowed: boolean; +} export declare abstract class AbstractModal { + protected readonly properties: ModalInstanceProperties; protected constructor(); abstract renderBody(): ReactElement; abstract renderTitle(): string | React.ReactElement; @@ -82,10 +97,11 @@ export declare abstract class AbstractModal { protected onClose(): void; protected onOpen(): void; } -export interface ModalRenderer { - renderModal(modal: AbstractModal | undefined): any; +export declare abstract class InternalModal extends AbstractModal { } +export declare function constructAbstractModalClass(klass: new (...args: ModalConstructorArguments[T]) => AbstractModal, properties: ModalInstanceProperties, args: ModalConstructorArguments[T]): AbstractModal; export interface ModalConstructorArguments { + "__internal__modal__": any[]; "video-viewer": [IpcRegistryDescription, string]; "channel-edit": [IpcRegistryDescription, boolean]; "echo-test": [IpcRegistryDescription]; @@ -95,4 +111,7 @@ export interface ModalConstructorArguments { "channel-tree": any; "modal-connect": any; "modal-invite": [IpcRegistryDescription, IpcVariableDescriptor, string]; + "modal-bookmarks": [IpcRegistryDescription, IpcVariableDescriptor]; + "modal-bookmark-add-server": [IpcRegistryDescription, IpcVariableDescriptor]; + "modal-poked": [IpcRegistryDescription, IpcVariableDescriptor]; } diff --git a/imports/shared-app/ui/react-elements/modal/Registry.d.ts b/imports/shared-app/ui/react-elements/modal/Registry.d.ts index 70b25ca..0a05d89 100644 --- a/imports/shared-app/ui/react-elements/modal/Registry.d.ts +++ b/imports/shared-app/ui/react-elements/modal/Registry.d.ts @@ -2,7 +2,9 @@ import { AbstractModal } from "../../../ui/react-elements/ModalDefinitions"; import { ModalConstructorArguments } from "tc-shared/ui/react-elements/modal/Definitions"; export interface RegisteredModal { modalId: T; - classLoader: () => Promise AbstractModal>; + classLoader: () => Promise<{ + default: new (...args: ModalConstructorArguments[T]) => AbstractModal; + }>; popoutSupported: boolean; } export declare function findRegisteredModal(name: T): RegisteredModal | undefined; diff --git a/imports/shared-app/ui/react-elements/modal/Renderer.d.ts b/imports/shared-app/ui/react-elements/modal/Renderer.d.ts new file mode 100644 index 0000000..f9147e3 --- /dev/null +++ b/imports/shared-app/ui/react-elements/modal/Renderer.d.ts @@ -0,0 +1,44 @@ +import { AbstractModal } from "tc-shared/ui/react-elements/modal/Definitions"; +import React from "react"; +export declare class ModalFrameTopRenderer extends React.PureComponent<{ + modalInstance: AbstractModal; + className?: string; + onClose?: () => void; + onPopout?: () => void; + onMinimize?: () => void; + replacePageTitle: boolean; +}> { + private readonly refTitle; + private titleElement; + private observer; + componentDidMount(): void; + componentWillUnmount(): void; + render(): JSX.Element; + private updatePageTitle; +} +export declare class ModalBodyRenderer extends React.PureComponent<{ + modalInstance: AbstractModal; + className?: string; +}> { + constructor(props: any); + render(): JSX.Element; +} +export declare class ModalFrameRenderer extends React.PureComponent<{ + windowed: boolean; + children: [React.ReactElement, React.ReactElement]; +}> { + render(): JSX.Element; +} +export declare class PageModalRenderer extends React.PureComponent<{ + modalInstance: AbstractModal; + onBackdropClicked: () => void; + children: React.ReactElement; +}, { + shown: boolean; +}> { + constructor(props: any); + render(): JSX.Element; +} +export declare const WindowModalRenderer: (props: { + children: [React.ReactElement React.ReactElement React.Component)>) | (new (props: any) => React.Component)>, React.ReactElement React.ReactElement React.Component)>) | (new (props: any) => React.Component)>]; +}) => JSX.Element; diff --git a/imports/shared-app/ui/react-elements/modal/external/Controller.d.ts b/imports/shared-app/ui/react-elements/modal/external/Controller.d.ts new file mode 100644 index 0000000..7a65753 --- /dev/null +++ b/imports/shared-app/ui/react-elements/modal/external/Controller.d.ts @@ -0,0 +1,27 @@ +import { Registry } from "tc-events"; +import { ModalOptions } from "tc-shared/ui/react-elements/modal/Definitions"; +import { ModalInstanceController, ModalInstanceEvents, ModalState } from "tc-shared/ui/react-elements/modal/Definitions"; +export declare class ExternalModalController implements ModalInstanceController { + private readonly modalType; + private readonly modalOptions; + private readonly constructorArguments; + private readonly mainModalId; + private readonly ipcMessageHandler; + private ipcRemotePeerId; + private ipcChannel; + private readonly modalEvents; + private modalInitializeCallback; + private windowId; + private windowListener; + private windowMutatePromise; + constructor(modalType: string, constructorArguments: any[], modalOptions: ModalOptions); + destroy(): void; + getEvents(): Registry; + getState(): ModalState; + show(): Promise; + hide(): Promise; + private mutateWindow; + private handleWindowDestroyed; + private registerIpcMessageHandler; + private sendIpcMessage; +} diff --git a/imports/shared-app/ui/react-elements/modal/external/Definitions.d.ts b/imports/shared-app/ui/react-elements/modal/external/Definitions.d.ts new file mode 100644 index 0000000..2bd81aa --- /dev/null +++ b/imports/shared-app/ui/react-elements/modal/external/Definitions.d.ts @@ -0,0 +1,25 @@ +export interface ModalIPCMessages { + "hello-renderer": { + version: string; + }; + "hello-controller": { + accepted: true; + modalId: string; + modalType: string; + constructorArguments: any[]; + } | { + accepted: false; + message: string; + }; + "invoke-modal-action": { + modalId: string; + action: "close" | "minimize"; + }; + "invalidate-modal-instance": {}; +} +export declare type ModalIPCRenderer2ControllerMessages = Pick; +export declare type ModalIPCController2Renderer = Pick; +export declare type ModalIPCMessage = { + type: T; + payload: Messages[T]; +}; diff --git a/imports/shared-app/ui/react-elements/modal/external/renderer/Controller.d.ts b/imports/shared-app/ui/react-elements/modal/external/renderer/Controller.d.ts new file mode 100644 index 0000000..d3f49ea --- /dev/null +++ b/imports/shared-app/ui/react-elements/modal/external/renderer/Controller.d.ts @@ -0,0 +1,21 @@ +export declare type ModalInstanceInitializeResult = { + status: "success"; + modalId: string; + modalType: string; + constructorArguments: any[]; +} | { + status: "timeout"; +} | { + status: "rejected"; + message: string; +}; +export declare class ModalWindowControllerInstance { + private readonly ipcMessageHandler; + private ipcRemotePeerId; + private ipcChannel; + constructor(modalChannelId: string); + initialize(): Promise; + triggerModalAction(modalId: string, action: "minimize" | "close"): void; + private registerIpcMessageHandler; + private sendIpcMessage; +} diff --git a/imports/shared-app/ui/react-elements/modal/external/renderer/EntryPoint.d.ts b/imports/shared-app/ui/react-elements/modal/external/renderer/EntryPoint.d.ts new file mode 100644 index 0000000..6e39f8b --- /dev/null +++ b/imports/shared-app/ui/react-elements/modal/external/renderer/EntryPoint.d.ts @@ -0,0 +1,2 @@ +import "../../../../../file/RemoteAvatars"; +import "../../../../../file/RemoteIcons"; diff --git a/imports/shared-app/ui/react-elements/modal/external/renderer/ModalRenderer.d.ts b/imports/shared-app/ui/react-elements/modal/external/renderer/ModalRenderer.d.ts new file mode 100644 index 0000000..4fc11ef --- /dev/null +++ b/imports/shared-app/ui/react-elements/modal/external/renderer/ModalRenderer.d.ts @@ -0,0 +1,12 @@ +import { AbstractModal } from "tc-shared/ui/react-elements/ModalDefinitions"; +import "./ModalRenderer.scss"; +export interface ModalControlFunctions { + close(): any; + minimize(): any; +} +export declare class ModalRenderer { + private readonly functionController; + private readonly container; + constructor(functionController: ModalControlFunctions); + renderModal(modal: AbstractModal | undefined): void; +} diff --git a/imports/shared-app/ui/react-elements/modal/index.d.ts b/imports/shared-app/ui/react-elements/modal/index.d.ts index 6b26f0c..dbc00ff 100644 --- a/imports/shared-app/ui/react-elements/modal/index.d.ts +++ b/imports/shared-app/ui/react-elements/modal/index.d.ts @@ -1,11 +1,9 @@ -import { ModalConstructorArguments } from "tc-shared/ui/react-elements/modal/Definitions"; +import { InternalModal, ModalConstructorArguments } from "tc-shared/ui/react-elements/modal/Definitions"; import { ModalController, ModalOptions } from "tc-shared/ui/react-elements/ModalDefinitions"; -import { InternalModal, InternalModalController } from "tc-shared/ui/react-elements/internal-modal/Controller"; export declare function spawnModal(modal: T, constructorArguments: ModalConstructorArguments[T], options?: ModalOptions): ModalController; -export declare function spawnReactModal(modalClass: new () => ModalClass): InternalModalController; -export declare function spawnReactModal(modalClass: new (..._: [A1]) => ModalClass, arg1: A1): InternalModalController; -export declare function spawnReactModal(modalClass: new (..._: [A1, A2]) => ModalClass, arg1: A1, arg2: A2): InternalModalController; -export declare function spawnReactModal(modalClass: new (..._: [A1, A2, A3]) => ModalClass, arg1: A1, arg2: A2, arg3: A3): InternalModalController; -export declare function spawnReactModal(modalClass: new (..._: [A1, A2, A3, A4]) => ModalClass, arg1: A1, arg2: A2, arg3: A3, arg4: A4): InternalModalController; -export declare function spawnReactModal(modalClass: new (..._: [A1, A2, A3, A4]) => ModalClass, arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5): InternalModalController; -export declare function spawnInternalModal(modal: T, constructorArguments: ModalConstructorArguments[T], options?: ModalOptions): InternalModalController; +export declare function spawnReactModal(modalClass: new () => ModalClass): ModalController; +export declare function spawnReactModal(modalClass: new (..._: [A1]) => ModalClass, arg1: A1): ModalController; +export declare function spawnReactModal(modalClass: new (..._: [A1, A2]) => ModalClass, arg1: A1, arg2: A2): ModalController; +export declare function spawnReactModal(modalClass: new (..._: [A1, A2, A3]) => ModalClass, arg1: A1, arg2: A2, arg3: A3): ModalController; +export declare function spawnReactModal(modalClass: new (..._: [A1, A2, A3, A4]) => ModalClass, arg1: A1, arg2: A2, arg3: A3, arg4: A4): ModalController; +export declare function spawnReactModal(modalClass: new (..._: [A1, A2, A3, A4]) => ModalClass, arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5): ModalController; diff --git a/imports/shared-app/ui/react-elements/modal/internal/index.d.ts b/imports/shared-app/ui/react-elements/modal/internal/index.d.ts new file mode 100644 index 0000000..2238007 --- /dev/null +++ b/imports/shared-app/ui/react-elements/modal/internal/index.d.ts @@ -0,0 +1,25 @@ +import { ModalInstanceController, ModalInstanceEvents, ModalOptions, ModalState } from "tc-shared/ui/react-elements/modal/Definitions"; +import { RegisteredModal } from "tc-shared/ui/react-elements/modal/Registry"; +import { Registry } from "tc-events"; +export declare class InternalModalInstance implements ModalInstanceController { + readonly events: Registry; + private readonly modalKlass; + private readonly constructorArguments; + private readonly rendererInstance; + private readonly modalOptions; + private state; + private modalInstance; + private htmlContainer; + private modalInitializePromise; + constructor(modalType: RegisteredModal, constructorArguments: any[], modalOptions: ModalOptions); + private constructModal; + private destructModal; + getState(): ModalState; + getEvents(): Registry; + show(): Promise; + hide(): Promise; + destroy(): void; + private getCloseCallback; + private getPopoutCallback; + private getMinimizeCallback; +} diff --git a/imports/shared-app/ui/tree/EntryTags.d.ts b/imports/shared-app/ui/tree/EntryTags.d.ts index 1e51ae2..9d05817 100644 --- a/imports/shared-app/ui/tree/EntryTags.d.ts +++ b/imports/shared-app/ui/tree/EntryTags.d.ts @@ -1,15 +1,21 @@ -/// -export declare const ClientTag: (props: { +import * as React from "react"; +export declare const ServerTag: React.MemoExoticComponent<(props: { + serverName: string; + handlerId: string; + serverUniqueId?: string; + className?: string; +}) => JSX.Element>; +export declare const ClientTag: React.MemoExoticComponent<(props: { clientName: string; clientUniqueId: string; handlerId: string; clientId?: number; clientDatabaseId?: number; className?: string; -}) => JSX.Element; -export declare const ChannelTag: (props: { +}) => JSX.Element>; +export declare const ChannelTag: React.MemoExoticComponent<(props: { channelName: string; channelId: number; handlerId: string; className?: string; -}) => JSX.Element; +}) => JSX.Element>; diff --git a/imports/shared-app/ui/utils/Variable.d.ts b/imports/shared-app/ui/utils/Variable.d.ts index 9a73ca1..34b98e8 100644 --- a/imports/shared-app/ui/utils/Variable.d.ts +++ b/imports/shared-app/ui/utils/Variable.d.ts @@ -1,22 +1,8 @@ +import { ReadonlyKeys, WritableKeys } from "tc-shared/proto"; export declare type UiVariable = Transferable | undefined | null | number | string | object; export declare type UiVariableMap = { [key: string]: any; }; -declare type IfEquals = (() => T extends X ? 1 : 2) extends (() => T extends Y ? 1 : 2) ? A : B; -declare type WritableKeys = { - [P in keyof T]-?: IfEquals<{ - [Q in P]: T[P]; - }, { - -readonly [Q in P]: T[P]; - }, P, never>; -}[keyof T]; -declare type ReadonlyKeys = { - [P in keyof T]: IfEquals<{ - [Q in P]: T[P]; - }, { - -readonly [Q in P]: T[P]; - }, never, P>; -}[keyof T]; export declare type ReadonlyVariables = Pick>; export declare type WriteableVariables = Pick>; declare type UiVariableEditor = Variables[T] extends { @@ -28,8 +14,11 @@ declare type UiVariableEditorPromise { private variableProvider; private variableEditor; + private artificialDelay; protected constructor(); destroy(): void; + getArtificialDelay(): number; + setArtificialDelay(value: number): void; setVariableProvider(variable: T, provider: (customData: any) => Variables[T] | Promise): void; /** * @param variable @@ -70,6 +59,7 @@ export declare abstract class UiVariableConsumer>(variable: T, customData: any, newValue: Variables[T]): void; useVariable>(variable: T, customData?: any, defaultValue?: Variables[T]): UiVariableStatus; useReadOnly(variable: T, customData?: any, defaultValue?: never): UiReadOnlyVariableStatus; useReadOnly(variable: T, customData: any | undefined, defaultValue: Variables[T]): Variables[T]; diff --git a/imports/shared-app/ui/windows/WindowManager.d.ts b/imports/shared-app/ui/windows/WindowManager.d.ts new file mode 100644 index 0000000..60b36dc --- /dev/null +++ b/imports/shared-app/ui/windows/WindowManager.d.ts @@ -0,0 +1,44 @@ +import { Registry } from "tc-events"; +export declare type WindowCreateResult = { + status: "success"; + windowId: string; +} | { + status: "error-unknown"; + message: string; +} | { + status: "error-user-rejected"; +}; +export interface WindowManagerEvents { + notify_window_created: { + windowId: string; + }; + notify_window_focused: { + windowId: string; + }; + notify_window_destroyed: { + windowId: string; + }; +} +export declare type WindowAction = "focus" | "maximize" | "minimize"; +export interface WindowSpawnOptions { + uniqueId: string; + loaderTarget: string; + windowName?: string; + appParameters?: { + [key: string]: string; + }; + defaultSize?: { + width: number; + height: number; + }; +} +export interface WindowManager { + getEvents(): Registry; + createWindow(options: WindowSpawnOptions): Promise; + destroyWindow(windowId: string): any; + getActiveWindowId(): string | undefined; + isActionSupported(windowId: string, action: WindowAction): boolean; + executeAction(windowId: string, action: WindowAction): Promise; +} +export declare function getWindowManager(): WindowManager; +export declare function setWindowManager(newWindowManager: WindowManager): void; diff --git a/imports/shared-app/voice/RecorderBase.d.ts b/imports/shared-app/voice/RecorderBase.d.ts index 9c28ba9..12a3ca8 100644 --- a/imports/shared-app/voice/RecorderBase.d.ts +++ b/imports/shared-app/voice/RecorderBase.d.ts @@ -1,4 +1,4 @@ -import { IDevice } from "../audio/recorder"; +import { InputDevice } from "../audio/Recorder"; import { Registry } from "../events"; import { Filter, FilterType, FilterTypeClass } from "../voice/Filter"; export declare enum InputConsumerType { @@ -91,7 +91,7 @@ export interface AbstractInput { setVolume(volume: number): any; } export interface LevelMeter { - getDevice(): IDevice; + getDevice(): InputDevice; setObserver(callback: (value: number) => any): any; destroy(): any; } diff --git a/imports/shared-app/voice/RecorderProfile.d.ts b/imports/shared-app/voice/RecorderProfile.d.ts index 6877fa6..60b726f 100644 --- a/imports/shared-app/voice/RecorderProfile.d.ts +++ b/imports/shared-app/voice/RecorderProfile.d.ts @@ -1,7 +1,7 @@ import { AbstractInput } from "../voice/RecorderBase"; import { KeyDescriptor } from "../PPTListener"; import { ConnectionHandler } from "../ConnectionHandler"; -import { IDevice } from "../audio/recorder"; +import { InputDevice } from "../audio/Recorder"; import { Registry } from "tc-shared/events"; export declare type VadType = "threshold" | "push_to_talk" | "active"; export interface RecorderProfileConfig { @@ -61,8 +61,8 @@ export declare class RecorderProfile { setPushToTalkKey(key: KeyDescriptor): void; getPushToTalkDelay(): number; setPushToTalkDelay(value: number): void; - getDeviceId(): string | typeof IDevice.DefaultDeviceId | typeof IDevice.NoDeviceId; - setDevice(device: IDevice | typeof IDevice.DefaultDeviceId | typeof IDevice.NoDeviceId): Promise; + getDeviceId(): string | typeof InputDevice.DefaultDeviceId | typeof InputDevice.NoDeviceId; + setDevice(device: InputDevice | typeof InputDevice.DefaultDeviceId | typeof InputDevice.NoDeviceId): Promise; getVolume(): number; setVolume(volume: number): void; } diff --git a/jenkins/create_build.sh b/jenkins/create_build.sh index a052b98..8fd81cd 100755 --- a/jenkins/create_build.sh +++ b/jenkins/create_build.sh @@ -121,7 +121,7 @@ function deploy_client() { } #install_npm -compile_scripts +#compile_scripts #compile_native package_client deploy_client diff --git a/modules/core/render-backend/ExternalModal.ts b/modules/core/render-backend/ExternalModal.ts index 522c001..14c3004 100644 --- a/modules/core/render-backend/ExternalModal.ts +++ b/modules/core/render-backend/ExternalModal.ts @@ -1,5 +1,5 @@ import {ObjectProxyServer} from "../../shared/proxy/Server"; -import {ExternalModal, kIPCChannelExternalModal} from "../../shared/ipc/ExternalModal"; +import {IpcWindowInstance, kIPCChannelWindowManager} from "../../shared/ipc/IpcWindowInstance"; import {ProxiedClass} from "../../shared/proxy/Definitions"; import {BrowserWindow, dialog} from "electron"; import {loadWindowBounds, startTrackWindowBounds} from "../../shared/window"; @@ -7,24 +7,24 @@ import {Arguments, processArguments} from "../../shared/process-arguments"; import {openURLPreview} from "../url-preview"; import * as path from "path"; -class ProxyImplementation extends ProxiedClass implements ExternalModal { +class ProxyImplementation extends ProxiedClass implements IpcWindowInstance { private windowInstance: BrowserWindow; - public constructor(props) { - super(props); - } - - async focus(): Promise { + async focus(): Promise { this.windowInstance?.focusOnWebView(); } - async minimize(): Promise { + async minimize(): Promise { this.windowInstance?.minimize(); } - async spawnWindow(modalTarget: string, url: string): Promise { + async maximize(): Promise { + this.windowInstance?.maximize(); + } + + async initialize(loaderTarget: string, windowId: string, url: string): Promise { if(this.windowInstance) { - return; + return false; } this.windowInstance = new BrowserWindow({ @@ -45,8 +45,8 @@ class ProxyImplementation extends ProxiedClass implements Externa show: true }); - loadWindowBounds("modal-" + modalTarget, this.windowInstance).then(() => { - startTrackWindowBounds("modal-" + modalTarget, this.windowInstance); + loadWindowBounds("window-" + windowId, this.windowInstance).then(() => { + startTrackWindowBounds("window-" + windowId, this.windowInstance); }); this.windowInstance.webContents.on('new-window', (event, url_str, frameName, disposition, options, additionalFeatures) => { @@ -109,5 +109,5 @@ class ProxyImplementation extends ProxiedClass implements Externa } } -const server = new ObjectProxyServer(kIPCChannelExternalModal, ProxyImplementation); +const server = new ObjectProxyServer(kIPCChannelWindowManager, ProxyImplementation); server.initialize(); \ No newline at end of file diff --git a/modules/core/render-backend/index.ts b/modules/core/render-backend/index.ts index dff7895..8aab5c1 100644 --- a/modules/core/render-backend/index.ts +++ b/modules/core/render-backend/index.ts @@ -5,7 +5,6 @@ import ipcMain = electron.ipcMain; import BrowserWindow = electron.BrowserWindow; import {openChangeLog as open_changelog} from "../app-updater/changelog"; -import * as updater from "../app-updater"; import {execute_connect_urls} from "../MultiInstanceHandler"; import {processArguments} from "../../shared/process-arguments"; diff --git a/modules/renderer/backend-impl/Backend.ts b/modules/renderer/Backend.ts similarity index 94% rename from modules/renderer/backend-impl/Backend.ts rename to modules/renderer/Backend.ts index c86852c..38bf109 100644 --- a/modules/renderer/backend-impl/Backend.ts +++ b/modules/renderer/Backend.ts @@ -1,7 +1,7 @@ -import {NativeClientBackend, NativeClientVersionInfo} from "tc-shared/backend/NativeClient"; import {ipcRenderer, remote} from "electron"; -import {Arguments, processArguments} from "../../shared/process-arguments"; import * as os from "os"; +import {NativeClientBackend, NativeClientVersionInfo} from "tc-shared/backend/NativeClient"; +import {Arguments, processArguments} from "../shared/process-arguments"; const call_basic_action = (name: string, ...args: any[]) => ipcRenderer.send('basic-action', name, ...args); let versionInfo: NativeClientVersionInfo; diff --git a/modules/renderer/ExternalModalHandler.ts b/modules/renderer/ExternalModalHandler.ts deleted file mode 100644 index a6e79b5..0000000 --- a/modules/renderer/ExternalModalHandler.ts +++ /dev/null @@ -1,71 +0,0 @@ -import {AbstractExternalModalController} from "tc-shared/ui/react-elements/external-modal/Controller"; -import {Popout2ControllerMessages, PopoutIPCMessage} from "tc-shared/ui/react-elements/external-modal/IPCMessage"; -import {ExternalModal, kIPCChannelExternalModal} from "../shared/ipc/ExternalModal"; -import {ObjectProxyClient} from "../shared/proxy/Client"; -import {ProxiedClass} from "../shared/proxy/Definitions"; -import {getIpcInstance} from "tc-shared/ipc/BrowserIPC"; -import {ModalOptions} from "tc-shared/ui/react-elements/modal/Definitions"; - -const modalClient = new ObjectProxyClient(kIPCChannelExternalModal); -modalClient.initialize(); - -export class ExternalModalController extends AbstractExternalModalController { - private handle: ProxiedClass & ExternalModal; - - constructor(modalType: string, constructorArguments?: any[], options?: ModalOptions) { - super(modalType, constructorArguments); - } - - protected async spawnWindow(): Promise { - if(!this.handle) { - this.handle = await modalClient.createNewInstance(); - } - - const parameters = { - "loader-target": "manifest", - "chunk": "modal-external", - "modal-target": this.modalType, - "modal-identify": this.ipcAuthenticationCode, - "ipc-address": getIpcInstance().getApplicationChannelId(), - "ipc-core-peer": getIpcInstance().getLocalPeerId(), - "loader-abort": 0, - "animation-short": 1 - }; - - const baseUrl = location.origin + location.pathname + "?"; - const url = baseUrl + Object.keys(parameters).map(e => e + "=" + encodeURIComponent(parameters[e])).join("&"); - - return await this.handle.spawnWindow(this.modalType, url); - } - - protected destroyWindow(): void { - this.handle?.destroy(); - this.handle = undefined; - } - - protected focusWindow(): void { - this.handle?.focus().then(() => {}); - } - - protected handleTypedIPCMessage(remoteId: string, isBroadcast: boolean, type: T, payload: PopoutIPCMessage[T]): void { - super.handleTypedIPCMessage(remoteId, isBroadcast, type, payload); - - switch (type) { - case "invoke-modal-action": - const data = payload as PopoutIPCMessage["invoke-modal-action"]; - switch (data.action) { - case "close": - this.destroy(); - break; - - case "minimize": - this.handle?.minimize().then(() => {}); - break; - } - break; - - case "hello-popout": - break; - } - } -} \ No newline at end of file diff --git a/modules/renderer/KeyBoard.ts b/modules/renderer/KeyBoard.ts new file mode 100644 index 0000000..24e8511 --- /dev/null +++ b/modules/renderer/KeyBoard.ts @@ -0,0 +1,51 @@ +import {KeyEvent as NKeyEvent, RegisterCallback, UnregisterCallback} from "tc-native/ppt"; +import {AbstractKeyBoard, EventType, KeyEvent, KeyHook, SpecialKey} from "tc-shared/PPTListener"; +import {tr} from "tc-shared/i18n/localize"; +import {LogCategory, logTrace} from "tc-shared/log"; + +export class NativeKeyBoard extends AbstractKeyBoard { + private readonly listener; + + constructor() { + super(); + RegisterCallback(this.listener = event => this.handleNativeKeyEvent(event)); + } + + destroy() { + UnregisterCallback(this.listener); + } + + private handleNativeKeyEvent(nativeEvent: NKeyEvent) { + let type; + switch (nativeEvent.type) { + case 0: + type = EventType.KEY_PRESS; + break; + + case 1: + type = EventType.KEY_RELEASE; + break; + + case 2: + type = EventType.KEY_TYPED; + break; + + default: + return; + } + + const event: KeyEvent = { + type: type, + + key: nativeEvent.key_code, + keyCode: nativeEvent.key_code, + + keyCtrl: nativeEvent.key_ctrl, + keyShift: nativeEvent.key_shift, + keyAlt: nativeEvent.key_alt, + keyWindows: nativeEvent.key_windows, + }; + + this.fireKeyEvent(event); + } +} \ No newline at end of file diff --git a/modules/renderer/PushToTalkHandler.ts b/modules/renderer/PushToTalkHandler.ts deleted file mode 100644 index 2e54b4b..0000000 --- a/modules/renderer/PushToTalkHandler.ts +++ /dev/null @@ -1,139 +0,0 @@ -import {KeyEvent as NKeyEvent, RegisterCallback, UnregisterCallback} from "tc-native/ppt"; -import {EventType, KeyEvent, KeyHook, SpecialKey} from "tc-shared/PPTListener"; -import {tr} from "tc-shared/i18n/localize"; -import {LogCategory, logTrace} from "tc-shared/log"; -import * as log from "tc-shared/log"; - -let key_listener: ((_: KeyEvent) => any)[] = []; - -function listener_key(type: EventType, nevent: NKeyEvent) { - if(nevent.key_code === 'VoidSymbol' || nevent.key_code === 'error') - nevent.key_code = undefined; /* trigger event for state update */ - - let event: KeyEvent = { - type: type, - - key: nevent.key_code, - key_code: nevent.key_code, - - key_ctrl: nevent.key_ctrl, - key_shift: nevent.key_shift, - key_alt: nevent.key_alt, - key_windows: nevent.key_windows - } as any; - - for (const listener of key_listener) - listener && listener(event); -} - -function native_keyhook(event: NKeyEvent) { - //console.log("Native event!: %o", event); - - if(event.type == 0) - listener_key(EventType.KEY_PRESS, event); - else if(event.type == 1) - listener_key(EventType.KEY_RELEASE, event); - else if(event.type == 2) - listener_key(EventType.KEY_TYPED, event); - else - console.warn(tr("Received unknown native event: %o"), event); -} - -export async function initialize() : Promise { - register_key_listener(listener_hook); - RegisterCallback(native_keyhook); -} - -export function finalize() { - unregister_key_listener(listener_hook); - UnregisterCallback(native_keyhook); -} - -export function register_key_listener(listener: (_: KeyEvent) => any) { - key_listener.push(listener); -} - -export function unregister_key_listener(listener: (_: KeyEvent) => any) { - const index = key_listener.findIndex(e => e === listener); - if(index !== -1) key_listener.splice(index, 1); -} - -let key_hooks: KeyHook[] = []; - -interface CurrentState { - keys: {[code: string]:KeyEvent}; - special: { [key:number]:boolean }; -} -let current_state: CurrentState = { - special: [] -} as any; - -let key_hooks_active: KeyHook[] = []; - -function listener_hook(event: KeyEvent) { - if(event.type == EventType.KEY_TYPED) - return; - - let old_hooks = [...key_hooks_active]; - let new_hooks = []; - - current_state.special[SpecialKey.ALT] = event.key_alt; - current_state.special[SpecialKey.CTRL] = event.key_ctrl; - current_state.special[SpecialKey.SHIFT] = event.key_shift; - current_state.special[SpecialKey.WINDOWS] = event.key_windows; - - current_state[event.key_code] = undefined; - if(event.type == EventType.KEY_PRESS) { - current_state[event.key_code] = event; - - for(const hook of key_hooks) { - if(hook.key_code !== event.key_code) continue; - if(hook.key_alt != event.key_alt) continue; - if(hook.key_ctrl != event.key_ctrl) continue; - if(hook.key_shift != event.key_shift) continue; - if(hook.key_windows != event.key_windows) continue; - - new_hooks.push(hook); - const index = old_hooks.findIndex(e => e === hook); - if(index === -1 && hook.callback_press) { - hook.callback_press(); - logTrace(LogCategory.GENERAL, tr("Trigger key press for %o!"), hook); - } - } - } - - //We have a new situation - for(const hook of old_hooks) { - //Do not test for meta key states because they could differ in a key release event - if(hook.key_code === event.key_code) { - if(hook.callback_release) { - hook.callback_release(); - logTrace(LogCategory.GENERAL, tr("Trigger key release for %o!"), hook); - } - } else { - new_hooks.push(hook); - } - } - key_hooks_active = new_hooks; -} - - -export function register_key_hook(hook: KeyHook) { - key_hooks.push(hook); -} - -export function unregister_key_hook(hook: KeyHook) { - let index; - - index = key_hooks.findIndex(e => e === hook); - if(index !== -1) key_hooks.splice(index, 1); - - index = key_hooks_active.findIndex(e => e === hook); - if(index !== -1) key_hooks_active.splice(index, 1); -} - -export function key_pressed(code: string | SpecialKey) : boolean { - if(typeof(code) === 'string') - return typeof(current_state[code]) === "object"; - return current_state.special[code]; -} \ No newline at end of file diff --git a/modules/renderer/WindowManager.ts b/modules/renderer/WindowManager.ts new file mode 100644 index 0000000..e4609d4 --- /dev/null +++ b/modules/renderer/WindowManager.ts @@ -0,0 +1,108 @@ +import { + WindowAction, + WindowCreateResult, + WindowManager, + WindowManagerEvents, + WindowSpawnOptions +} from "tc-shared/ui/windows/WindowManager"; +import {Registry} from "tc-events"; +import {assertMainApplication} from "tc-shared/ui/utils"; +import {ObjectProxyClient} from "../shared/proxy/Client"; +import {IpcWindowInstance, kIPCChannelWindowManager} from "../shared/ipc/IpcWindowInstance"; +import {ProxiedClass} from "../shared/proxy/Definitions"; +import {guid} from "tc-shared/crypto/uid"; +import {getIpcInstance} from "tc-shared/ipc/BrowserIPC"; + +assertMainApplication(); + +const modalClient = new ObjectProxyClient(kIPCChannelWindowManager); +modalClient.initialize(); + +export class NativeWindowManager implements WindowManager { + private readonly events: Registry; + private readonly windowInstances: { [key: string]: ProxiedClass & IpcWindowInstance }; + + constructor() { + this.windowInstances = {}; + this.events = new Registry(); + } + + getEvents(): Registry { + return this.events; + } + + async createWindow(options: WindowSpawnOptions): Promise { + const windowHandle = await modalClient.createNewInstance(); + + const parameters = { + "loader-target": "manifest", + "loader-chunk": "modal-external", + "ipc-address": getIpcInstance().getApplicationChannelId(), + "ipc-core-peer": getIpcInstance().getLocalPeerId(), + "loader-abort": 0, + "animation-short": 1 + }; + Object.assign(parameters, options.appParameters); + + const baseUrl = location.origin + location.pathname + "?"; + const url = baseUrl + Object.keys(parameters).map(e => e + "=" + encodeURIComponent(parameters[e])).join("&"); + const result = await windowHandle.initialize("modal-external", options.uniqueId, url); + if(!result) { + windowHandle.destroy(); + return { status: "error-unknown", message: tr("failed to spawn window") }; + } + + const windowId = guid(); + windowHandle.events.onClose = () => this.destroyWindow(windowId); + this.windowInstances[windowId] = windowHandle; + return { status: "success", windowId: windowId }; + } + + destroyWindow(windowId: string): any { + if(!this.windowInstances[windowId]) { + return; + } + + this.windowInstances[windowId].destroy(); + delete this.windowInstances[windowId]; + this.events.fire("notify_window_destroyed", { windowId: windowId }); + } + + getActiveWindowId(): string | undefined { + /* TODO! */ + return undefined; + } + + async executeAction(windowId: string, action: WindowAction): Promise { + if(!this.windowInstances[windowId]) { + return; + } + + const window = this.windowInstances[windowId]; + switch (action) { + case "focus": + await window.focus(); + break; + + case "maximize": + await window.maximize(); + break; + + case "minimize": + await window.minimize(); + break; + } + } + + isActionSupported(windowId: string, action: WindowAction): boolean { + switch (action) { + case "minimize": + case "focus": + case "maximize": + return true; + + default: + return false; + } + } +} \ No newline at end of file diff --git a/modules/renderer/audio/AudioFilter.ts b/modules/renderer/audio/AudioFilter.ts index 33eebf8..91907a8 100644 --- a/modules/renderer/audio/AudioFilter.ts +++ b/modules/renderer/audio/AudioFilter.ts @@ -1,6 +1,6 @@ import {audio} from "tc-native/connection"; -import {FilterType, StateFilter, ThresholdFilter, VoiceLevelFilter} from "tc-shared/voice/Filter"; import {NativeInput} from "./AudioRecorder"; +import {FilterType, StateFilter, ThresholdFilter, VoiceLevelFilter} from "tc-shared/voice/Filter"; export abstract class NativeFilter { readonly priority: number; @@ -79,8 +79,9 @@ export class NThresholdFilter extends NativeFilter implements ThresholdFilter { setMarginFrames(value: number) { this.marginFrames = value; - if(this.filter) + if(this.filter) { this.filter.set_margin_time(value / 960 / 1000); + } } getAttackSmooth(): number { @@ -93,14 +94,16 @@ export class NThresholdFilter extends NativeFilter implements ThresholdFilter { setAttackSmooth(value: number) { this._attack_smooth = value; - if(this.filter) + if(this.filter) { this.filter.set_attack_smooth(value); + } } setReleaseSmooth(value: number) { this._release_smooth = value; - if(this.filter) + if(this.filter) { this.filter.set_release_smooth(value); + } } setThreshold(value: number): Promise { diff --git a/modules/renderer/audio/AudioPlayer.ts b/modules/renderer/audio/AudioPlayer.ts index 13023e2..3faed6f 100644 --- a/modules/renderer/audio/AudioPlayer.ts +++ b/modules/renderer/audio/AudioPlayer.ts @@ -1,4 +1,5 @@ import * as native from "tc-native/connection"; +import {AudioBackend, OutputDevice} from "tc-shared/audio/Player"; //FIXME: Native audio initialize handle! export interface Device { @@ -70,4 +71,108 @@ export function get_master_volume() : number { } export function set_master_volume(volume: number) { native.audio.playback.set_master_volume(volume); +} + +export class NativeAudioPlayer implements AudioBackend { + private readonly audioContext: AudioContext; + private initializedPromises: (() => void)[]; + + private currentDevice: native.audio.AudioDevice; + + constructor() { + this.audioContext = new AudioContext(); + this.initializedPromises = []; + + native.audio.initialize(() => { + const promises = this.initializedPromises; + this.initializedPromises = undefined; + + promises.forEach(callback => callback()); + }); + } + + executeWhenInitialized(callback: () => void): any { + if(this.initializedPromises) { + this.initializedPromises.push(callback); + } else { + callback(); + } + } + + getMasterVolume(): number { + return native.audio.playback.get_master_volume(); + } + + setMasterVolume(volume: number): any { + native.audio.playback.set_master_volume(volume); + } + + getAudioContext(): AudioContext | undefined { + return this.audioContext; + } + + async getAvailableDevices(): Promise { + return native.audio.available_devices().filter(e => e.output_supported || e.output_default).map(entry => ({ + device_id: entry.device_id, + driver: entry.driver, + name: entry.name + })); + } + + getCurrentDevice(): OutputDevice { + if(this.currentDevice) { + return this.currentDevice; + } + + const defaultDevice = native.audio.available_devices().find(entry => entry.output_default); + if(defaultDevice) { + return { + name: defaultDevice.name, + driver: defaultDevice.driver, + device_id: defaultDevice.device_id + }; + } + + return { + name: "Default device", + device_id: "default", + driver: "default driver" + }; + } + + async setCurrentDevice(targetId: string | undefined): Promise { + const device = native.audio.available_devices().find(e => e.device_id == targetId); + if(!device) { + console.warn("Missing audio device with is %s", targetId); + throw "invalid device id"; + } + + try { + native.audio.playback.set_device(device.device_id); + } catch(error) { + if(error instanceof Error) { + throw error.message; + } + + throw error; + } + + this.currentDevice = device; + } + + getDefaultDeviceId(): string { + return native.audio.available_devices().find(entry => entry.output_default).device_id; + } + + isDeviceRefreshAvailable(): boolean { + return false; + } + + isInitialized(): boolean { + return !this.initializedPromises; + } + + refreshDevices(): Promise { + return Promise.resolve(undefined); + } } \ No newline at end of file diff --git a/modules/renderer/audio/AudioRecorder.ts b/modules/renderer/audio/AudioRecorder.ts index ce486e7..dbe9be8 100644 --- a/modules/renderer/audio/AudioRecorder.ts +++ b/modules/renderer/audio/AudioRecorder.ts @@ -13,7 +13,7 @@ import {tr} from "tc-shared/i18n/localize"; import {Registry} from "tc-shared/events"; import {Filter, FilterType, FilterTypeClass} from "tc-shared/voice/Filter"; import {NativeFilter, NStateFilter, NThresholdFilter, NVoiceLevelFilter} from "./AudioFilter"; -import {getRecorderBackend, IDevice} from "tc-shared/audio/recorder"; +import {getRecorderBackend, InputDevice} from "tc-shared/audio/Recorder"; import {LogCategory, logError, logTrace, logWarn} from "tc-shared/log"; import {Settings, settings} from "tc-shared/settings"; import NativeFilterMode = audio.record.FilterMode; @@ -80,9 +80,9 @@ export class NativeInput implements AbstractInput { logTrace(LogCategory.AUDIO, tr("Starting input for device %o", this.deviceId)); try { let deviceId; - if(this.deviceId === IDevice.NoDeviceId) { + if(this.deviceId === InputDevice.NoDeviceId) { throw tr("no device selected"); - } else if(this.deviceId === IDevice.DefaultDeviceId) { + } else if(this.deviceId === InputDevice.DefaultDeviceId) { deviceId = getRecorderBackend().getDeviceList().getDefaultDeviceId(); } else { deviceId = this.deviceId; @@ -271,7 +271,7 @@ export class NativeInput implements AbstractInput { export class NativeLevelMeter implements LevelMeter { static readonly instances: NativeLevelMeter[] = []; - readonly targetDevice: IDevice; + readonly targetDevice: InputDevice; public nativeRecorder: audio.record.AudioRecorder; public nativeConsumer: audio.record.AudioConsumer; @@ -279,7 +279,7 @@ export class NativeLevelMeter implements LevelMeter { private callback: (num: number) => any; private nativeFilter: audio.record.ThresholdConsumeFilter; - constructor(device: IDevice) { + constructor(device: InputDevice) { this.targetDevice = device; this.callback = () => {}; } @@ -341,7 +341,7 @@ export class NativeLevelMeter implements LevelMeter { this.nativeFilter = undefined; } - getDevice(): IDevice { + getDevice(): InputDevice { return this.targetDevice; } diff --git a/modules/renderer/audio/InputDeviceList.ts b/modules/renderer/audio/InputDeviceList.ts index ea7bfc1..6935786 100644 --- a/modules/renderer/audio/InputDeviceList.ts +++ b/modules/renderer/audio/InputDeviceList.ts @@ -1,12 +1,12 @@ -import {AbstractDeviceList, DeviceListEvents, IDevice, PermissionState} from "tc-shared/audio/recorder"; -import {Registry} from "tc-shared/events"; +import {AbstractDeviceList, DeviceListEvents, InputDevice, PermissionState} from "tc-shared/audio/Recorder"; +import {Registry} from "tc-events"; import * as loader from "tc-loader"; import * as native from "tc-native/connection"; import {audio} from "tc-native/connection"; import {LogCategory, logTrace} from "tc-shared/log"; -interface NativeIDevice extends IDevice { +interface NativeIDevice extends InputDevice { isDefault: boolean } diff --git a/modules/renderer/audio/Sounds.ts b/modules/renderer/audio/Sounds.ts new file mode 100644 index 0000000..8079092 --- /dev/null +++ b/modules/renderer/audio/Sounds.ts @@ -0,0 +1,27 @@ +import {audio as naudio} from "tc-native/connection"; +import {SoundBackend, SoundFile} from "tc-shared/audio/Sounds"; +import * as paths from "path"; + +export class NativeSoundBackend implements SoundBackend { + playSound(sound: SoundFile): Promise { + return new Promise((resolve, reject) => { + let pathname = paths.dirname(decodeURIComponent(location.pathname)); + if(pathname[0] === '/' && pathname[2] === ':') //e.g.: /C:/test... + pathname = pathname.substr(1); + const path = paths.join(pathname, sound.path); + + console.log("replaying %s (volume: %f)", sound.path, sound.volume); + naudio.sounds.playback_sound({ + callback: (result, message) => { + if(result == naudio.sounds.PlaybackResult.SUCCEEDED) + resolve(); + else + reject(naudio.sounds.PlaybackResult[result].toLowerCase() + ": " + message); + }, + file: path, + volume: typeof sound.volume === "number" ? sound.volume : 1 + }); + }); + } + +} \ No newline at end of file diff --git a/modules/renderer/audio/sounds.ts b/modules/renderer/audio/sounds.ts deleted file mode 100644 index e188043..0000000 --- a/modules/renderer/audio/sounds.ts +++ /dev/null @@ -1,24 +0,0 @@ -import {audio as naudio} from "tc-native/connection"; -import * as paths from "path"; -import {SoundFile} from "tc-shared/sound/Sounds"; - -export async function play_sound(file: SoundFile) : Promise { - await new Promise((resolve, reject) => { - let pathname = paths.dirname(decodeURIComponent(location.pathname)); - if(pathname[0] === '/' && pathname[2] === ':') //e.g.: /C:/test... - pathname = pathname.substr(1); - const path = paths.join(pathname, file.path); - - console.log("replaying %s (volume: %f)", file.path, file.volume); - naudio.sounds.playback_sound({ - callback: (result, message) => { - if(result == naudio.sounds.PlaybackResult.SUCCEEDED) - resolve(); - else - reject(naudio.sounds.PlaybackResult[result].toLowerCase() + ": " + message); - }, - file: path, - volume: file.volume || 1 - }); - }); -} \ No newline at end of file diff --git a/modules/renderer/backend-impl/audio/player.ts b/modules/renderer/backend-impl/audio/player.ts deleted file mode 100644 index bda238e..0000000 --- a/modules/renderer/backend-impl/audio/player.ts +++ /dev/null @@ -1,15 +0,0 @@ -import * as handler from "../../audio/AudioPlayer"; - -export const initialize = handler.initialize; -export const initialized = handler.initialized; - -export const get_master_volume = handler.get_master_volume; -export const set_master_volume = handler.set_master_volume; - -export const on_ready = handler.on_ready; - -export const available_devices = handler.available_devices; -export const set_device = handler.set_device; -export const current_device = handler.current_device; - -export const initializeFromGesture = () => {}; \ No newline at end of file diff --git a/modules/renderer/backend-impl/audio/sounds.ts b/modules/renderer/backend-impl/audio/sounds.ts deleted file mode 100644 index 2d8fc0a..0000000 --- a/modules/renderer/backend-impl/audio/sounds.ts +++ /dev/null @@ -1,3 +0,0 @@ -import * as handler from "../../audio/sounds"; - -export const play_sound = handler.play_sound; \ No newline at end of file diff --git a/modules/renderer/backend-impl/dns.ts b/modules/renderer/backend-impl/dns.ts deleted file mode 100644 index 19cde92..0000000 --- a/modules/renderer/backend-impl/dns.ts +++ /dev/null @@ -1,4 +0,0 @@ -import * as handler from "../dns/dns_resolver"; - -export const supported = handler.supported; -export const resolve_address = handler.resolve_address; \ No newline at end of file diff --git a/modules/renderer/backend-impl/ppt.ts b/modules/renderer/backend-impl/ppt.ts deleted file mode 100644 index a6d1e0c..0000000 --- a/modules/renderer/backend-impl/ppt.ts +++ /dev/null @@ -1,12 +0,0 @@ -import * as handler from "../PushToTalkHandler"; - -export const initialize = handler.initialize; -export const finalize = handler.finalize; - -export const register_key_listener = handler.register_key_listener; -export const unregister_key_listener = handler.unregister_key_listener; - -export const register_key_hook = handler.register_key_hook; -export const unregister_key_hook = handler.unregister_key_hook; - -export const key_pressed = handler.key_pressed; \ No newline at end of file diff --git a/modules/renderer/dns/NativeDnsResolver.ts b/modules/renderer/dns/NativeDnsResolver.ts new file mode 100644 index 0000000..ef12205 --- /dev/null +++ b/modules/renderer/dns/NativeDnsResolver.ts @@ -0,0 +1,44 @@ +import * as loader from "tc-loader"; + +import { + DNSAddress, + DNSProvider, + DNSResolveOptions, + DNSResolveResult, +} from "tc-shared/dns"; +import * as dns_handler from "tc-native/dns"; + +export class NativeDnsResolver implements DNSProvider { + resolveAddress(address: DNSAddress, options: DNSResolveOptions): Promise { + return new Promise((resolve, reject) => { + dns_handler.resolve_cr(address.hostname, address.port, result => { + if(typeof result === "string") { + resolve({ status: "error", message: result }); + } else { + resolve({ + status: "success", + originalAddress: address, + resolvedAddress: { + port: address.port, + hostname: address.hostname + } + }); + } + }); + }) + } + + resolveAddressIPv4(address: DNSAddress, options: DNSResolveOptions): Promise { + /* Currently only used to test if con-gate works which should not be required within the native client */ + return Promise.resolve({ status: "error", message: "not implemented" }); + } + +} + +loader.register_task(loader.Stage.JAVASCRIPT_INITIALIZING, { + name: "Native DNS initialized", + function: async () => { + dns_handler.initialize(); + }, + priority: 100 +}); \ No newline at end of file diff --git a/modules/renderer/dns/dns_resolver.ts b/modules/renderer/dns/dns_resolver.ts deleted file mode 100644 index e94c80b..0000000 --- a/modules/renderer/dns/dns_resolver.ts +++ /dev/null @@ -1,29 +0,0 @@ -import * as loader from "tc-loader"; - -import {AddressTarget, ResolveOptions} from "tc-shared/dns"; -import * as dns_handler from "tc-native/dns"; -import {ServerAddress} from "tc-shared/tree/Server"; - -export function resolve_address(address: ServerAddress, _options?: ResolveOptions) : Promise { - return new Promise((resolve, reject) => { - dns_handler.resolve_cr(address.host, address.port, result => { - if(typeof(result) === "string") { - reject(result); - } else { - resolve({ - target_ip: result.host, - target_port: result.port - }); - } - }); - }) -} -export function supported() { return true; } - -loader.register_task(loader.Stage.JAVASCRIPT_INITIALIZING, { - name: "Native DNS initialized", - function: async () => { - dns_handler.initialize(); - }, - priority: 10 -}); \ No newline at end of file diff --git a/modules/renderer/hooks/AudioBackend.ts b/modules/renderer/hooks/AudioBackend.ts new file mode 100644 index 0000000..0cc70a8 --- /dev/null +++ b/modules/renderer/hooks/AudioBackend.ts @@ -0,0 +1,9 @@ +import * as loader from "tc-loader"; +import {setAudioBackend} from "tc-shared/audio/Player"; +import {NativeAudioPlayer} from "../audio/AudioPlayer"; + +loader.register_task(loader.Stage.JAVASCRIPT_INITIALIZING, { + name: "Native audi backend initialized", + function: async () => setAudioBackend(new NativeAudioPlayer()), + priority: 100 +}); \ No newline at end of file diff --git a/modules/renderer/hooks/AudioInput.ts b/modules/renderer/hooks/AudioInput.ts index e568fcd..1c515f5 100644 --- a/modules/renderer/hooks/AudioInput.ts +++ b/modules/renderer/hooks/AudioInput.ts @@ -1,4 +1,4 @@ -import {AudioRecorderBacked, DeviceList, IDevice, setRecorderBackend} from "tc-shared/audio/recorder"; +import {AudioRecorderBacked, DeviceList, InputDevice, setRecorderBackend} from "tc-shared/audio/Recorder"; import {AbstractInput, LevelMeter} from "tc-shared/voice/RecorderBase"; import {inputDeviceList} from "../audio/InputDeviceList"; import {NativeInput, NativeLevelMeter} from "../audio/AudioRecorder"; @@ -8,7 +8,7 @@ setRecorderBackend(new class implements AudioRecorderBacked { return new NativeInput(); } - async createLevelMeter(device: IDevice): Promise { + async createLevelMeter(device: InputDevice): Promise { const meter = new NativeLevelMeter(device); await meter.initialize(); return meter; diff --git a/modules/renderer/hooks/Backend.ts b/modules/renderer/hooks/Backend.ts index 6b3ce0e..04bb7ab 100644 --- a/modules/renderer/hooks/Backend.ts +++ b/modules/renderer/hooks/Backend.ts @@ -1,4 +1,4 @@ import {setBackend} from "tc-shared/backend"; -import {NativeClientBackendImpl} from "../backend-impl/Backend"; +import {NativeClientBackendImpl} from "../Backend"; setBackend(new NativeClientBackendImpl()); \ No newline at end of file diff --git a/modules/renderer/hooks/ChangeLogClient.ts b/modules/renderer/hooks/ChangeLogClient.ts index ee82944..f06aefb 100644 --- a/modules/renderer/hooks/ChangeLogClient.ts +++ b/modules/renderer/hooks/ChangeLogClient.ts @@ -1,7 +1,7 @@ import * as loader from "tc-loader"; import {Stage} from "tc-loader"; -import {setNativeUpdater} from "tc-shared/update"; import {ClientUpdater} from "../ClientUpdater"; +import {setNativeUpdater} from "tc-shared/update"; loader.register_task(Stage.JAVASCRIPT_INITIALIZING, { name: "web updater init", diff --git a/modules/renderer/hooks/Dns.ts b/modules/renderer/hooks/Dns.ts new file mode 100644 index 0000000..a899ab1 --- /dev/null +++ b/modules/renderer/hooks/Dns.ts @@ -0,0 +1,9 @@ +import * as loader from "tc-loader"; +import {setDNSProvider} from "tc-shared/dns"; +import {NativeDnsResolver} from "../dns/NativeDnsResolver"; + +loader.register_task(loader.Stage.JAVASCRIPT_INITIALIZING, { + name: "Native DNS initialized", + function: async () => setDNSProvider(new NativeDnsResolver()), + priority: 100 +}); \ No newline at end of file diff --git a/modules/renderer/hooks/ExternalModal.ts b/modules/renderer/hooks/ExternalModal.ts deleted file mode 100644 index ee0ab12..0000000 --- a/modules/renderer/hooks/ExternalModal.ts +++ /dev/null @@ -1,12 +0,0 @@ -import * as loader from "tc-loader"; -import {Stage} from "tc-loader"; -import {setExternalModalControllerFactory} from "tc-shared/ui/react-elements/external-modal"; -import {ExternalModalController} from "../ExternalModalHandler"; - -loader.register_task(Stage.JAVASCRIPT_INITIALIZING, { - priority: 50, - name: "external modal controller factory setup", - function: async () => { - setExternalModalControllerFactory((modal, events, userData) => new ExternalModalController(modal, events, userData)); - } -}); \ No newline at end of file diff --git a/modules/renderer/hooks/KeyBoard.ts b/modules/renderer/hooks/KeyBoard.ts new file mode 100644 index 0000000..7658a21 --- /dev/null +++ b/modules/renderer/hooks/KeyBoard.ts @@ -0,0 +1,9 @@ +import * as loader from "tc-loader"; +import {setKeyBoardBackend} from "tc-shared/PPTListener"; +import {NativeKeyBoard} from "../KeyBoard"; + +loader.register_task(loader.Stage.JAVASCRIPT_INITIALIZING, { + name: "Native keyboard initialized", + function: async () => setKeyBoardBackend(new NativeKeyBoard()), + priority: 100 +}); \ No newline at end of file diff --git a/modules/renderer/hooks/Sound.ts b/modules/renderer/hooks/Sound.ts new file mode 100644 index 0000000..3e47b8f --- /dev/null +++ b/modules/renderer/hooks/Sound.ts @@ -0,0 +1,9 @@ +import * as loader from "tc-loader"; +import {setSoundBackend} from "tc-shared/audio/Sounds"; +import {NativeSoundBackend} from "../audio/Sounds"; + +loader.register_task(loader.Stage.JAVASCRIPT_INITIALIZING, { + name: "Native sound initialized", + function: async () => setSoundBackend(new NativeSoundBackend()), + priority: 100 +}); \ No newline at end of file diff --git a/modules/renderer/hooks/WindowManager.ts b/modules/renderer/hooks/WindowManager.ts new file mode 100644 index 0000000..755cf20 --- /dev/null +++ b/modules/renderer/hooks/WindowManager.ts @@ -0,0 +1,9 @@ +import * as loader from "tc-loader"; +import {setWindowManager} from "tc-shared/ui/windows/WindowManager"; +import {NativeWindowManager} from "../WindowManager"; + +loader.register_task(loader.Stage.JAVASCRIPT_INITIALIZING, { + name: "window manager initialize", + function: async () => setWindowManager(new NativeWindowManager()), + priority: 100 +}); \ No newline at end of file diff --git a/modules/renderer/hooks/index.ts b/modules/renderer/hooks/index.ts new file mode 100644 index 0000000..90b5a37 --- /dev/null +++ b/modules/renderer/hooks/index.ts @@ -0,0 +1,11 @@ +import "./AudioInput"; +import "./AudioBackend"; +import "./Backend"; +import "./ChangeLogClient"; +import "./Dns"; +import "./MenuBar"; +import "./ServerConnection"; +import "./Video"; +import "./Sound"; +import "./KeyBoard"; +import "./WindowManager"; \ No newline at end of file diff --git a/modules/renderer/index.ts b/modules/renderer/index.ts index 900f942..f3200cd 100644 --- a/modules/renderer/index.ts +++ b/modules/renderer/index.ts @@ -22,7 +22,7 @@ if(!processArguments.has_flag(Arguments.NO_CRASH_RENDERER)) { crash_handler.initialize_handler("renderer", is_electron_run); } -RequireProxy.initialize(path.join(__dirname, "backend-impl"), "client-app"); +RequireProxy.initialize(path.join(__dirname, "backend-impl"), "main-app"); /* --------------- main initialize --------------- */ import * as loader from "tc-loader"; @@ -160,13 +160,7 @@ loader.register_task(loader.Stage.JAVASCRIPT_INITIALIZING, { await import("./IconHelper"); await import("./connection/FileTransfer"); - await import("./hooks/AudioInput"); - await import("./hooks/ExternalModal"); - await import("./hooks/ServerConnection"); - await import("./hooks/ChangeLogClient"); - await import("./hooks/Backend"); - await import("./hooks/MenuBar"); - await import("./hooks/Video"); + await import("./hooks"); await import("./UnloadHandler"); await import("./WindowsTrayHandler"); diff --git a/modules/shared/ipc/ExternalModal.ts b/modules/shared/ipc/ExternalModal.ts deleted file mode 100644 index 1d2a7c1..0000000 --- a/modules/shared/ipc/ExternalModal.ts +++ /dev/null @@ -1,12 +0,0 @@ -export const kIPCChannelExternalModal = "external-modal"; - -export interface ExternalModal { - readonly events: { - onClose: () => void - } - - spawnWindow(modalTarget: string, url: string) : Promise; - - minimize() : Promise; - focus() : Promise; -} \ No newline at end of file diff --git a/modules/shared/ipc/IpcWindowInstance.ts b/modules/shared/ipc/IpcWindowInstance.ts new file mode 100644 index 0000000..264a21f --- /dev/null +++ b/modules/shared/ipc/IpcWindowInstance.ts @@ -0,0 +1,12 @@ +export const kIPCChannelWindowManager = "window-manager"; + +export interface IpcWindowInstance { + readonly events: { + onClose: () => void + } + + initialize(loaderTarget: string, windowId: string, url: string) : Promise; + minimize() : Promise; + maximize() : Promise; + focus() : Promise; +} \ No newline at end of file diff --git a/modules/shared/proxy/Definitions.ts b/modules/shared/proxy/Definitions.ts index fbbd263..902762f 100644 --- a/modules/shared/proxy/Definitions.ts +++ b/modules/shared/proxy/Definitions.ts @@ -10,23 +10,42 @@ export type FunctionalInterface = { export type ProxiedClassProperties = { instanceId: string, ownerWindowId: number, events: any }; export type ProxyInterface = FunctionalInterface; -export type ProxyClass = { new(props: ProxiedClassProperties): ProxyInterface & ProxiedClass }; +export type ProxyClass = { new(): ProxyInterface & ProxiedClass }; +let constructorProperties: ProxiedClassProperties; export abstract class ProxiedClass }> { public readonly ownerWindowId: number; public readonly instanceId: string; public readonly events: ProxiedEvents; - protected constructor(props: ProxiedClassProperties) { - this.ownerWindowId = props.ownerWindowId; - this.instanceId = props.instanceId; - this.events = props.events; + public constructor() { + if(typeof constructorProperties === "undefined") { + throw "a ProxiedClass instance can only be allocated by createProxiedClassInstance"; + } + + this.ownerWindowId = constructorProperties.ownerWindowId; + this.instanceId = constructorProperties.instanceId; + this.events = constructorProperties.events; + constructorProperties = undefined; } public destroy() {} } +export function createProxiedClassInstance(klass: new (...args: any[]) => ProxiedClass & ProxyInterface, args: any[], props: ProxiedClassProperties) : ProxiedClass & ProxyInterface { + constructorProperties = props; + try { + const result = new klass(...args); + if(typeof constructorProperties !== "undefined") { + throw "tried to allocate an class which didn't called the ProxiedClass constructor"; + } + return result; + } finally { + constructorProperties = undefined; + } +} + export function generateUUID() { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); diff --git a/modules/shared/proxy/Server.ts b/modules/shared/proxy/Server.ts index c8a4f5f..7cc5bd2 100644 --- a/modules/shared/proxy/Server.ts +++ b/modules/shared/proxy/Server.ts @@ -1,5 +1,5 @@ import {BrowserWindow, ipcMain, IpcMainEvent} from "electron"; -import {generateUUID, ProxiedClass, ProxyClass, ProxyInterface} from "./Definitions"; +import {createProxiedClassInstance, generateUUID, ProxiedClass, ProxyClass, ProxyInterface} from "./Definitions"; export class ObjectProxyServer> { private readonly ipcChannel: string; @@ -30,7 +30,7 @@ export class ObjectProxyServer> { let instance: ProxiedClass & ProxyInterface; try { const instanceId = generateUUID(); - instance = new this.klass({ + instance = createProxiedClassInstance(this.klass, [], { ownerWindowId: event.sender.id, instanceId: instanceId, events: this.generateEventProxy(instanceId, event.sender.id) diff --git a/modules/shared/proxy/Test.ts b/modules/shared/proxy/Test.ts index d54b4d7..7d8a776 100644 --- a/modules/shared/proxy/Test.ts +++ b/modules/shared/proxy/Test.ts @@ -11,10 +11,6 @@ interface TextModal { } class TextModalImpl extends ProxiedClass implements TextModal { - constructor(props) { - super(props); - } - async sayHi(): Promise { this.events.onHide(); } diff --git a/native/serverconnection/src/audio/filter/FilterThreshold.cpp b/native/serverconnection/src/audio/filter/FilterThreshold.cpp index d2da025..4098812 100644 --- a/native/serverconnection/src/audio/filter/FilterThreshold.cpp +++ b/native/serverconnection/src/audio/filter/FilterThreshold.cpp @@ -9,7 +9,7 @@ using namespace tc::audio; using namespace tc::audio::filter; ThresholdFilter::ThresholdFilter(size_t a, size_t b, size_t c) : Filter(a, b, c) {} -ThresholdFilter::~ThresholdFilter() {} +ThresholdFilter::~ThresholdFilter() = default; bool ThresholdFilter::initialize(std::string &, float val, size_t margin) { this->_threshold = val; @@ -32,8 +32,9 @@ inline float merge_ab(float a, float b, float n) { auto half_n = n / 2; auto inv_half_n = 1 / half_n; - if(a < half_n && b < half_n) - return inv_half_n * a * b; + if(a < half_n && b < half_n) { + return inv_half_n * a * b; + } return 2 * (a + b) - inv_half_n * a * b - n; } @@ -45,24 +46,28 @@ bool ThresholdFilter::process(const void *_buffer) { for(size_t channel = 0; channel < this->_channels; channel++) { auto percentage = this->analyze(_buffer, channel); - if(channel == 0) - value = (float) percentage; - else - value = merge_ab(value, (float) percentage, 100); + if(channel == 0) { + value = (float) percentage; + } else { + value = merge_ab(value, (float) percentage, 100); + } } auto last_level = this->_current_level; float smooth; - if(this->_margin_processed_samples == 0) /* we're in release */ - smooth = this->_release_smooth; - else - smooth = this->_attack_smooth; + if(this->_margin_processed_samples == 0) { + /* we're in release */ + smooth = this->_release_smooth; + } else { + smooth = this->_attack_smooth; + } this->_current_level = last_level * smooth + value * (1 - smooth); //log_trace(category::audio, "Vad level: before: {}, edit: {}, now: {}, smooth: {}", last_level, value, this->_current_level, smooth); - if(analyze_callback) - analyze_callback(this->_current_level); + if(analyze_callback) { + analyze_callback(this->_current_level); + } if(this->_current_level >= this->_threshold) { this->_margin_processed_samples = 0; @@ -75,14 +80,14 @@ bool ThresholdFilter::process(const void *_buffer) { long double ThresholdFilter::analyze(const void *_buffer, size_t channel) { /* equation taken from the web client */ - auto buffer = (float*) _buffer; long double value = 0; auto sample = this->_frame_size; while(sample-- > 0) { - const auto num = floorl(*buffer * 127) / 127.f; /* to be like the web client */ + /* to be like the web client */ + const auto num = floorl(*buffer * 127) / 127.f; value += num * num; buffer += this->_channels; } @@ -91,7 +96,6 @@ long double ThresholdFilter::analyze(const void *_buffer, size_t channel) { auto db = (long double) 20 * (log(rms) / log(10)); db = max((long double) -192, min(db, (long double) 0)); - - float percentage = (float) (100 + (db * 1.92f)); + auto percentage = (float) (100 + (db * 1.92f)); return max(0.f, min(percentage, 100.f)); } \ No newline at end of file diff --git a/native/serverconnection/src/audio/filter/FilterThreshold.h b/native/serverconnection/src/audio/filter/FilterThreshold.h index 9b0bb29..4e47093 100644 --- a/native/serverconnection/src/audio/filter/FilterThreshold.h +++ b/native/serverconnection/src/audio/filter/FilterThreshold.h @@ -5,43 +5,39 @@ #include #include -namespace tc { - namespace audio { - namespace filter { - class ThresholdFilter : public Filter { - public: - ThresholdFilter(size_t /* channel count */, size_t /* sample rate */, size_t /* frame size */); - virtual ~ThresholdFilter(); +namespace tc::audio::filter { + class ThresholdFilter : public Filter { + public: + ThresholdFilter(size_t /* channel count */, size_t /* sample rate */, size_t /* frame size */); + virtual ~ThresholdFilter(); - bool initialize(std::string& /* error */, float /* threshold */, size_t /* margin frames */); - bool process(const void* /* buffer */) override; + bool initialize(std::string& /* error */, float /* threshold */, size_t /* margin frames */); + bool process(const void* /* buffer */) override; - long double analyze(const void* /* buffer */, size_t /* channel */); + long double analyze(const void* /* buffer */, size_t /* channel */); - inline float threshold() { return this->_threshold; } - inline void set_threshold(float value) { this->_threshold = value; } + inline void set_threshold(float value) { this->_threshold = value; } + [[nodiscard]] inline float threshold() const { return this->_threshold; } - /* in seconds */ - inline float margin_release_time() { return (float) this->_margin_samples / (float) this->_sample_rate; } - inline void set_margin_release_time(float value) { this->_margin_samples = (size_t) ceil((float) this->_sample_rate * value); } + /* in seconds */ + inline float margin_release_time() { return (float) this->_margin_samples / (float) this->_sample_rate; } + inline void set_margin_release_time(float value) { this->_margin_samples = (size_t) ceil((float) this->_sample_rate * value); } - inline void attack_smooth(float value) { this->_attack_smooth = value; } - inline float attack_smooth() { return this->_attack_smooth; } + inline void attack_smooth(float value) { this->_attack_smooth = value; } + [[nodiscard]] inline float attack_smooth() const { return this->_attack_smooth; } - inline void release_smooth(float value) { this->_release_smooth = value; } - inline float release_smooth() { return this->_release_smooth; } + inline void release_smooth(float value) { this->_release_smooth = value; } + [[nodiscard]] inline float release_smooth() const { return this->_release_smooth; } - std::function on_analyze; - private: - float _attack_smooth = 0; - float _release_smooth = 0; - float _current_level = 0; + std::function on_analyze; + private: + float _attack_smooth = 0; + float _release_smooth = 0; + float _current_level = 0; - float _threshold; + float _threshold{}; - size_t _margin_samples = 0; - size_t _margin_processed_samples = 0; - }; - } - } + size_t _margin_samples = 0; + size_t _margin_processed_samples = 0; + }; } \ No newline at end of file diff --git a/native/serverconnection/src/connection/ProtocolHandler.cpp b/native/serverconnection/src/connection/ProtocolHandler.cpp index cc4258b..f2a70ec 100644 --- a/native/serverconnection/src/connection/ProtocolHandler.cpp +++ b/native/serverconnection/src/connection/ProtocolHandler.cpp @@ -96,7 +96,7 @@ void ProtocolHandler::execute_tick() { } if(this->connection_state == connection_state::INIT_LOW || this->connection_state == connection_state::INIT_HIGH) { - if(this->connect_timestamp < now - seconds(15)) { + if(this->connect_timestamp < now - seconds(15) && false) { this->handle->call_connect_result.call(this->handle->errors.register_error("timeout (" + to_string(this->connection_state) + ")"), true); this->handle->close_connection(); return; diff --git a/native/serverconnection/src/connection/ProtocolHandlerPOW.cpp b/native/serverconnection/src/connection/ProtocolHandlerPOW.cpp index 5e596dd..fd80f51 100644 --- a/native/serverconnection/src/connection/ProtocolHandlerPOW.cpp +++ b/native/serverconnection/src/connection/ProtocolHandlerPOW.cpp @@ -50,6 +50,7 @@ void ProtocolHandler::handlePacketInit(const ts::protocol::PacketParser &packet) auto packet_state = static_cast(data[0]); if(packet_state == pow_state::COMMAND_RESET) { + return; log_trace(category::connection, tr("[POW] Received reset")); this->pow.retry_count++; if(this->pow.retry_count > 8) { diff --git a/native/serverconnection/test/js/flood.ts b/native/serverconnection/test/js/flood.ts index 4419d22..ca8883c 100644 --- a/native/serverconnection/test/js/flood.ts +++ b/native/serverconnection/test/js/flood.ts @@ -179,13 +179,13 @@ class Bot { const botList: Bot[] = []; async function connectBots() { - for(let index = 0; index < 20; index++) { + for(let index = 0; index < 200; index++) { console.error("CONNECT"); const bot = new Bot(); botList.push(bot); await new Promise(resolve => bot.connect(resolve)); - await new Promise(resolve => setTimeout(resolve, 250)); + //await new Promise(resolve => setTimeout(resolve, 250)); while(botList.length > 50) { const [ bot ] = botList.splice(0, 1); bot.reset(); diff --git a/native/serverconnection/test/js/main.ts b/native/serverconnection/test/js/main.ts index 8b7348b..7be8264 100644 --- a/native/serverconnection/test/js/main.ts +++ b/native/serverconnection/test/js/main.ts @@ -54,7 +54,7 @@ connection.callback_disconnect = reason => { const do_connect = (connection) => { connection.connect({ - timeout: 5000, + timeout: 500_000, remote_port: 9987, //remote_host: "188.40.240.20", /* twerion */ remote_host: "127.0.0.1", diff --git a/package.json b/package.json index 6570d64..ed4cede 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "start-nd": "electron . -t --gdb --disable-hardware-acceleration --no-single-instance -u=http://clientapi.teaspeak.dev/ -d --updater-ui-loader_type=0", "start-01": "electron . --updater-channel=test -u=http://dev.clientapi.teaspeak.de/ -d --updater-ui-loader_type=0 --updater-local-version=1.0.1", "start-devel-download": "electron . --disable-hardware-acceleration --gdb --debug --updater-ui-loader_type=2 --updater-ui-ignore-version -t -u http://localhost:8081/", - "start-s": "electron . --disable-hardware-acceleration --gdb --debug --updater-ui-loader_type=3 --updater-ui-ignore-version -t -u http://localhost:8081/", + "start-s": "electron . --disable-hardware-acceleration --gdb --debug --updater-ui-loader_type=3 --updater-ui-ignore-version -t -u http://localhost:8080/", "dtest": "electron . dtest", "sass": "sass", "compile-sass": "sass --update .:.",