diff --git a/package-lock.json b/package-lock.json index add3b97e..400ce7be 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14720,9 +14720,9 @@ } }, "webpack-svg-sprite-generator": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/webpack-svg-sprite-generator/-/webpack-svg-sprite-generator-1.0.9.tgz", - "integrity": "sha512-i1jfHW998QHWd/CszJCvNt0/x9AKosjGBA1mBDCip9up0ck+vecXOMebaZMJM3u2s1ng20RopEU85bRYmUx/ZQ==", + "version": "1.0.13", + "resolved": "https://registry.npmjs.org/webpack-svg-sprite-generator/-/webpack-svg-sprite-generator-1.0.13.tgz", + "integrity": "sha512-1KZG+RpLeBZiFCUzKIVWfWUW24JccomaoYyNgKoYldCt4A4DgZPxsBi1QttfTtPzKJlGKXSlwps9RANGLEJY+Q==", "dev": true, "requires": { "fs-extra": "^9.0.1", diff --git a/package.json b/package.json index 732daf3f..e2004803 100644 --- a/package.json +++ b/package.json @@ -77,7 +77,7 @@ "webpack": "^4.42.1", "webpack-bundle-analyzer": "^3.6.1", "webpack-cli": "^3.3.11", - "webpack-svg-sprite-generator": "^1.0.9", + "webpack-svg-sprite-generator": "^1.0.13", "worker-plugin": "^4.0.2", "xml-parser": "^1.2.1" }, diff --git a/scripts/build_declarations.sh b/scripts/build_declarations.sh index 8d366527..6ae0202b 100644 --- a/scripts/build_declarations.sh +++ b/scripts/build_declarations.sh @@ -31,39 +31,4 @@ fi ./shared/generate_declarations.sh; _exit_code=$? [[ $_exit_code -ne 0 ]] && { echo "Failed to generate shared ($_exit_code)" -} - -exit 0 -#Easy going: Each "module" has it's exports and imports -#So lets first build the exports and ignore any errors -#Note: For the client we have to use the given file - -#Web -npm run dtsgen -- --config web/tsconfig/dtsconfig.json -v -replace_tribble web/declarations/exports.d.ts -echo "Generated web declarations" - -#Client -npm run dtsgen -- --config client/tsconfig/dtsconfig.json -v -replace_tribble client/declarations/exports.d.ts -echo "Generated client declarations" - -#replace_tribble shared/declarations/exports.d.ts -echo "Generated shared declarations" - -#Now build the merged declaration for the shared project -#Link the declaration files (All interface declarations should be equal!) -if [[ ! -d shared/declarations ]]; then - mkdir shared/declarations - if [[ $? -ne 0 ]]; then - echo "Failed to create directory shared/declarations" - exit 1 - fi -fi - -#Last but not least the client imports -generate_link shared/declarations/exports_app.d.ts web/declarations/imports_shared.d.ts -generate_link shared/declarations/exports_loader_app.d.ts web/declarations/imports_shared_loader.d.ts - -generate_link shared/declarations/exports_app.d.ts client/declarations/imports_shared.d.ts -generate_link shared/declarations/exports_loader_app.d.ts client/declarations/imports_shared_loader.d.ts \ No newline at end of file +} \ No newline at end of file diff --git a/shared/generate_declarations.sh b/shared/generate_declarations.sh index 9817ea95..e3c2e28c 100644 --- a/shared/generate_declarations.sh +++ b/shared/generate_declarations.sh @@ -25,4 +25,6 @@ function generate_declaration() { #Generate the loader definitions first app_declaration="../declarations/shared-app/" generate_declaration dtsconfig_app.json ${app_declaration} + +cp -r svg-sprites "../declarations/svg-sprites" exit 0 \ No newline at end of file diff --git a/shared/js/main.tsx b/shared/js/main.tsx index 74ea67e9..f36c7c2d 100644 --- a/shared/js/main.tsx +++ b/shared/js/main.tsx @@ -33,7 +33,7 @@ import {FileTransferState, TransferProvider,} from "tc-shared/file/Transfer"; import {MenuEntryType, spawn_context_menu} from "tc-shared/ui/elements/ContextMenu"; import {copy_to_clipboard} from "tc-shared/utils/helpers"; import ContextMenuEvent = JQuery.ContextMenuEvent; -import "svg-sprite/client-icons"; +import "svg-sprites/client-icons"; /* required import for init */ import "../css/load-css" diff --git a/shared/js/settings.ts b/shared/js/settings.ts index 64f01cd1..c82b726b 100644 --- a/shared/js/settings.ts +++ b/shared/js/settings.ts @@ -4,12 +4,17 @@ import * as loader from "tc-loader"; import {Stage} from "tc-loader"; import {Registry} from "tc-shared/events"; -type ConfigValueTypes = boolean | number | string; -type ConfigValueTypeNames = "boolean" | "number" | "string"; +type ConfigValueTypes = boolean | number | string | object; +type ConfigValueTypeNames = "boolean" | "number" | "string" | "object"; + +type ValueTypeMapping = T extends boolean ? "boolean" : + T extends number ? "number" : + T extends string ? "string" : + T extends object ? "object" : never; export interface SettingsKey { key: string; - valueType: ConfigValueTypeNames; + valueType: ValueTypeMapping; defaultValue?: ValueType; @@ -44,6 +49,13 @@ export class SettingsBase { case "number": return parseFloat(input) as any; + case "object": + try { + return JSON.parse(input); + } catch (error) { + return {} as any; + } + default: return defaultValue; } @@ -62,6 +74,9 @@ export class SettingsBase { case "number": return input.toString(); + case "object": + return JSON.stringify(input); + default: return undefined; } @@ -486,7 +501,7 @@ export class Settings extends StaticSettings { static readonly FN_LOG_LEVEL_ENABLED: (category: string) => SettingsKey = category => { return { key: "log.level." + category.toLowerCase() + ".enabled", - valueType: "boolean", + valueType: "boolean" } }; @@ -512,10 +527,10 @@ export class Settings extends StaticSettings { } }; - static readonly FN_PROFILE_RECORD: (name: string) => SettingsKey = name => { + static readonly FN_PROFILE_RECORD: (name: string) => SettingsKey = name => { return { key: 'profile_record' + name, - valueType: "string", + valueType: "object", } }; diff --git a/shared/js/ui/client.ts b/shared/js/ui/client.ts index c95eadcc..6026ed27 100644 --- a/shared/js/ui/client.ts +++ b/shared/js/ui/client.ts @@ -29,7 +29,7 @@ import {spawnPermissionEditorModal} from "tc-shared/ui/modal/permission/ModalPer import {EventClient, EventType} from "tc-shared/ui/frames/log/Definitions"; import {W2GPluginCmdHandler} from "tc-shared/video-viewer/W2GPlugin"; import {global_client_actions} from "tc-shared/events/GlobalEvents"; -import { ClientIcon } from "svg-sprite/client-icons"; +import { ClientIcon } from "svg-sprites/client-icons"; export enum ClientType { CLIENT_VOICE, diff --git a/shared/js/ui/modal/ModalSettings.tsx b/shared/js/ui/modal/ModalSettings.tsx index c37caf9d..48fec1bc 100644 --- a/shared/js/ui/modal/ModalSettings.tsx +++ b/shared/js/ui/modal/ModalSettings.tsx @@ -1719,6 +1719,7 @@ export namespace modal_settings { const update_level_meter = () => { destroy_meters(); + return; /* FIXME: Remove! */ for(const device of arecorder.devices()) { let promise = arecorder.create_levelmeter(device).then(meter => { meter.set_observer(level => { diff --git a/shared/js/voice/RecorderProfile.ts b/shared/js/voice/RecorderProfile.ts index 3913cbbb..4dfb1795 100644 --- a/shared/js/voice/RecorderProfile.ts +++ b/shared/js/voice/RecorderProfile.ts @@ -153,7 +153,7 @@ export class RecorderProfile { } private save(enforce?: boolean) { - if(enforce || !this.volatile) + if(!this.volatile) settings.changeGlobal(Settings.FN_PROFILE_RECORD(this.name), this.config); } diff --git a/shared/svg-sprites/client-icons.d.ts b/shared/svg-sprites/client-icons.d.ts index 682776a7..31075c9a 100644 --- a/shared/svg-sprites/client-icons.d.ts +++ b/shared/svg-sprites/client-icons.d.ts @@ -1,4 +1,12 @@ +/* + * DO NOT MODIFY THIS FILE! + * + * This file has been auto generated by the svg-sprite generator. + * Sprite source directory: D:\TeaSpeak\web\shared\img\client-icons + * Sprite count: 200 + */ export type ClientIconClass = "client-about" | "client-activate_microphone" | "client-add" | "client-add_foe" | "client-add_folder" | "client-add_friend" | "client-addon-collection" | "client-addon" | "client-apply" | "client-arrow_down" | "client-arrow_left" | "client-arrow_right" | "client-arrow_up" | "client-away" | "client-ban_client" | "client-ban_list" | "client-bookmark_add" | "client-bookmark_add_folder" | "client-bookmark_duplicate" | "client-bookmark_manager" | "client-bookmark_remove" | "client-broken_image" | "client-browse-addon-online" | "client-capture" | "client-change_nickname" | "client-changelog" | "client-channel_chat" | "client-channel_collapse_all" | "client-channel_commander" | "client-channel_create" | "client-channel_create_sub" | "client-channel_default" | "client-channel_delete" | "client-channel_edit" | "client-channel_expand_all" | "client-channel_green" | "client-channel_green_subscribed" | "client-channel_green_subscribed2" | "client-channel_private" | "client-channel_red" | "client-channel_red_subscribed" | "client-channel_switch" | "client-channel_unsubscribed" | "client-channel_yellow" | "client-channel_yellow_subscribed" | "client-check_update" | "client-client_hide" | "client-client_show" | "client-close_button" | "client-complaint_list" | "client-conflict-icon" | "client-connect" | "client-contact" | "client-copy" | "client-copy_url" | "client-d_sound" | "client-d_sound_me" | "client-d_sound_user" | "client-default" | "client-default_for_all_bookmarks" | "client-delete" | "client-delete_avatar" | "client-disconnect" | "client-down" | "client-download" | "client-edit" | "client-edit_friend_foe_status" | "client-emoticon" | "client-error" | "client-file_home" | "client-file_refresh" | "client-filetransfer" | "client-find" | "client-folder" | "client-folder_up" | "client-group_100" | "client-group_200" | "client-group_300" | "client-group_500" | "client-group_600" | "client-guisetup" | "client-hardware_input_muted" | "client-hardware_output_muted" | "client-home" | "client-hoster_button" | "client-hotkeys" | "client-icon-pack" | "client-iconsview" | "client-iconviewer" | "client-identity_default" | "client-identity_export" | "client-identity_import" | "client-identity_manager" | "client-info" | "client-input_muted" | "client-input_muted_local" | "client-invite_buddy" | "client-is_talker" | "client-kick_channel" | "client-kick_server" | "client-listview" | "client-loading_image" | "client-message_incoming" | "client-message_info" | "client-message_outgoing" | "client-messages" | "client-moderated" | "client-move_client_to_own_channel" | "client-music" | "client-new_chat" | "client-notifications" | "client-offline_messages" | "client-on_whisperlist" | "client-output_muted" | "client-permission_channel" | "client-permission_client" | "client-permission_overview" | "client-permission_server_groups" | "client-phoneticsnickname" | "client-ping_1" | "client-ping_2" | "client-ping_3" | "client-ping_4" | "client-ping_calculating" | "client-ping_disconnected" | "client-play" | "client-player_chat" | "client-player_commander_off" | "client-player_commander_on" | "client-player_off" | "client-player_on" | "client-player_whisper" | "client-plugins" | "client-poke" | "client-present" | "client-recording_start" | "client-recording_stop" | "client-refresh" | "client-register" | "client-reload" | "client-remove_foe" | "client-remove_friend" | "client-security" | "client-selectfolder" | "client-send_complaint" | "client-server_green" | "client-server_log" | "client-server_query" | "client-settings" | "client-sort_by_name" | "client-sound-pack" | "client-soundpack" | "client-stop" | "client-subscribe_mode" | "client-subscribe_to_all_channels" | "client-subscribe_to_channel" | "client-subscribe_to_channel_family" | "client-switch_advanced" | "client-switch_standard" | "client-sync-disable" | "client-sync-enable" | "client-sync-icon" | "client-tab_close_button" | "client-talk_power_grant" | "client-talk_power_grant_next" | "client-talk_power_request" | "client-talk_power_request_cancel" | "client-talk_power_revoke" | "client-talk_power_revoke_all_grant_next" | "client-temp_server_password" | "client-temp_server_password_add" | "client-textformat" | "client-textformat_bold" | "client-textformat_foreground" | "client-textformat_italic" | "client-textformat_underline" | "client-theme" | "client-toggle_server_query_clients" | "client-toggle_whisper" | "client-token" | "client-token_use" | "client-translation" | "client-unsubscribe_from_all_channels" | "client-unsubscribe_from_channel_family" | "client-unsubscribe_mode" | "client-up" | "client-upload" | "client-upload_avatar" | "client-urlcatcher" | "client-user-account" | "client-virtualserver_edit" | "client-volume" | "client-w2g" | "client-warning" | "client-warning_external_link" | "client-warning_info" | "client-warning_question" | "client-weblist" | "client-whisper" | "client-whisperlists"; + export enum ClientIcon { About = "client-about", ActivateMicrophone = "client-activate_microphone", @@ -201,5 +209,18 @@ export enum ClientIcon { Whisper = "client-whisper", Whisperlists = "client-whisperlists", } + +export const spriteEntries: { + id: string; + className: string; + width: number; + height: number; + xOffset: number; + yOffset: number; +}[]; + export const spriteUrl: string; -export const classList: string[]; \ No newline at end of file +export const classList: string[]; + +export const spriteWidth: number; +export const spriteHeight: number; \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 3c4b6d87..19cf5c05 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,7 +16,7 @@ "tc-backend/web/*": ["web/app/*"], /* specific web part */ "tc-backend/*": ["shared/backend.d/*"], "tc-loader": ["loader/exports/loader.d.ts"], - "svg-sprite/*": ["shared/svg-sprites/*"], + "svg-sprites/*": ["shared/svg-sprites/*"], "vendor/xbbcode/*": ["vendor/xbbcode/src/*"] } diff --git a/webpack/ManifestPlugin.ts b/webpack/ManifestPlugin.ts index 42d57b3e..89fe4803 100644 --- a/webpack/ManifestPlugin.ts +++ b/webpack/ManifestPlugin.ts @@ -18,13 +18,15 @@ class ManifestGenerator { apply(compiler: webpack.Compiler) { compiler.hooks.afterCompile.tap(this.constructor.name, compilation => { const chunks_data = {}; - for(const chunk_group of compilation.chunkGroups) { - const js_files = []; - const css_files = []; + for(const chunkGroup of compilation.chunkGroups) { + const fileJs = []; + const filesCss = []; const modules = []; - for(const chunk of chunk_group.chunks) { - if(!chunk.files.length) continue; + for(const chunk of chunkGroup.chunks) { + if(!chunk.files.length) + continue; + if(chunk.files.length !== 1) { console.error("Expected only one file per chunk but got " + chunk.files.length); chunk.files.forEach(e => console.log(" - %s", e)); @@ -33,25 +35,39 @@ class ManifestGenerator { for(const file of chunk.files) { const extension = path.extname(file); - if(extension === ".js") - js_files.push({ + if(extension === ".js") { + fileJs.push({ hash: chunk.hash, file: file }); - else if(extension === ".css") - css_files.push({ + } else if(extension === ".css") { + filesCss.push({ hash: chunk.hash, file: file }); - else + } else { throw "Unknown chunk file with extension " + extension; + } } - for(const module of chunk._modules) { + for(const module of chunk.getModules()) { if(!module.type.startsWith("javascript/")) continue; - if(!module.resource || !module.context) + if(!module.context) + continue; + + if(module.context.startsWith("svg-sprites/")) { + /* custom svg sprite handler */ + modules.push({ + id: module.id, + context: "svg-sprites", + resource: module.context.substring("svg-sprites/".length) + }); + continue; + } + + if(!module.resource) continue; if(module.context !== path.dirname(module.resource)) @@ -65,9 +81,9 @@ class ManifestGenerator { } } - chunks_data[chunk_group.options.name] = { - files: js_files, - css_files: css_files, + chunks_data[chunkGroup.options.name] = { + files: fileJs, + css_files: filesCss, modules: modules }; }