From 7c48f51525507135f6610ef0a3c1d0614830a19a Mon Sep 17 00:00:00 2001 From: Andrew Ferreira Date: Thu, 11 May 2023 17:50:04 -0300 Subject: [PATCH 1/3] build: atualiza regra do eslint --- .eslintrc.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.eslintrc.json b/.eslintrc.json index 5bc85a89..10a4f32d 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -228,7 +228,10 @@ "@typescript-eslint/consistent-generic-constructors": ["error", "constructor"], "@typescript-eslint/consistent-type-assertions": ["error", { "assertionStyle": "as" }], "@typescript-eslint/consistent-type-exports": "error", - "@typescript-eslint/consistent-type-imports": ["error", { "prefer": "type-imports" }], + "@typescript-eslint/consistent-type-imports": ["error", { + "prefer": "type-imports", + "disallowTypeAnnotations": false + }], "@typescript-eslint/no-confusing-non-null-assertion": "error", "@typescript-eslint/no-confusing-void-expression": ["error", { "ignoreArrowShorthand": true }], "@typescript-eslint/no-duplicate-enum-values": "error", From 2893d1eb850355598b79727fd3da65b091a69b34 Mon Sep 17 00:00:00 2001 From: Andrew Ferreira Date: Thu, 11 May 2023 17:51:14 -0300 Subject: [PATCH 2/3] chore: converte para `d.ts` --- types/{ares.ts => ares.d.ts} | 6 +- types/{config.ts => config.d.ts} | 19 ++- types/{deimos.ts => deimos.d.ts} | 24 ++-- types/electron.d.ts | 8 ++ types/electron.ts | 7 -- types/{error.ts => error.d.ts} | 13 +- types/{game.ts => game.d.ts} | 48 ++++---- types/modules.d.ts | 34 ++++++ types/modules.ts | 37 ------ types/{phobos.ts => phobos.d.ts} | 14 +-- types/plunder/{config.ts => config.d.ts} | 14 +-- types/plunder/{group.ts => group.d.ts} | 4 +- types/plunder/{history.ts => history.d.ts} | 6 +- types/plunder/{index.ts => index.d.ts} | 20 +-- types/plunder/{info.ts => info.d.ts} | 2 +- types/plunder/{page.ts => page.d.ts} | 4 +- types/{stores.ts => stores.d.ts} | 136 ++++++++++----------- types/{utils.ts => utils.d.ts} | 12 +- types/{view.ts => view.d.ts} | 0 types/world/{config.ts => config.d.ts} | 2 +- types/world/index.d.ts | 10 ++ types/world/index.ts | 17 --- types/world/{units.ts => units.d.ts} | 6 +- types/world/{villages.ts => villages.d.ts} | 6 +- 24 files changed, 203 insertions(+), 246 deletions(-) rename types/{ares.ts => ares.d.ts} (80%) rename types/{config.ts => config.d.ts} (66%) rename types/{deimos.ts => deimos.d.ts} (88%) create mode 100644 types/electron.d.ts delete mode 100644 types/electron.ts rename types/{error.ts => error.d.ts} (53%) rename types/{game.ts => game.d.ts} (75%) create mode 100644 types/modules.d.ts delete mode 100644 types/modules.ts rename types/{phobos.ts => phobos.d.ts} (56%) rename types/plunder/{config.ts => config.d.ts} (90%) rename types/plunder/{group.ts => group.d.ts} (84%) rename types/plunder/{history.ts => history.d.ts} (64%) rename types/plunder/{index.ts => index.d.ts} (69%) rename types/plunder/{info.ts => info.d.ts} (93%) rename types/plunder/{page.ts => page.d.ts} (82%) rename types/{stores.ts => stores.d.ts} (52%) rename types/{utils.ts => utils.d.ts} (58%) rename types/{view.ts => view.d.ts} (100%) rename types/world/{config.ts => config.d.ts} (94%) create mode 100644 types/world/index.d.ts delete mode 100644 types/world/index.ts rename types/world/{units.ts => units.d.ts} (74%) rename types/world/{villages.ts => villages.d.ts} (53%) diff --git a/types/ares.ts b/types/ares.d.ts similarity index 80% rename from types/ares.ts rename to types/ares.d.ts index 6e2f2f0f..8d79e8ed 100644 --- a/types/ares.ts +++ b/types/ares.d.ts @@ -1,4 +1,4 @@ -export type EnvironmentInfo = { +type EnvironmentInfo = { readonly time: number; readonly ares: string; readonly electron: string; @@ -7,7 +7,7 @@ export type EnvironmentInfo = { readonly locale: string | null; }; -export type LatestVersion = { +type LatestVersion = { readonly version: string; readonly notes: string; readonly download: string; @@ -16,7 +16,7 @@ export type LatestVersion = { readonly date: number; }; -export type DownloadProgressType = { +type DownloadProgressType = { readonly receivedBytes: number; readonly totalBytes: number; }; \ No newline at end of file diff --git a/types/config.ts b/types/config.d.ts similarity index 66% rename from types/config.ts rename to types/config.d.ts index 7fa6a212..505b9888 100644 --- a/types/config.ts +++ b/types/config.d.ts @@ -1,35 +1,32 @@ -import type { Rectangle } from 'electron'; -import type { GameRegion } from '$types/game'; - -export type AppConfigName = +type AppConfigName = 'app_state' | 'app_update' | 'config_general' | 'config_notifications' | 'panel_bounds'; -export type AppConfigJSON = +type AppConfigJSON = AppStateType | GeneralConfigType | NotificationsConfigType | PanelBoundsConfigType | UpdateConfigType; -export type AppConfigByName = +type AppConfigByName = T extends 'config_general' ? GeneralConfigType : T extends 'config_notifications' ? NotificationsConfigType : never; -export type AppStateType = { +type AppStateType = { /** Última região acessada pelo usuário. */ lastRegion?: GameRegion; }; -export type UpdateConfigType = { +type UpdateConfigType = { /** O Ares alertará o usuário apenas quando houver uma versão mais recente que a ignorada. */ versionToIgnore: string; }; -export type GeneralConfigType = { +type GeneralConfigType = { /** Indica se a view deve ser atualizada após remoção de captchas. */ reloadAfterCaptcha: boolean; }; -export type NotificationsConfigType = { +type NotificationsConfigType = { /** Indica se o usuário deve ser notificado quando ocorrer um erro. */ notifyOnError: boolean; }; -export type PanelBoundsConfigType = Rectangle; \ No newline at end of file +type PanelBoundsConfigType = import('electron').Rectangle; \ No newline at end of file diff --git a/types/deimos.ts b/types/deimos.d.ts similarity index 88% rename from types/deimos.ts rename to types/deimos.d.ts index 6dc05577..39422fac 100644 --- a/types/deimos.ts +++ b/types/deimos.d.ts @@ -1,20 +1,18 @@ -import type { Resources, ResourcesPTBR, UnitsAmountAsStrings } from '$types/game'; +type UIMessageType = 'show-ui-error-message' | 'show-ui-info-message' | 'show-ui-success-message'; -export type UIMessageType = 'show-ui-error-message' | 'show-ui-info-message' | 'show-ui-success-message'; - -export type ActivePossible = { +type ActivePossible = { readonly active: boolean; readonly possible: boolean; }; -export type Features = { +type Features = { // Aqui é AccountManager, mas a variável global é Accountmanager. readonly AccountManager: ActivePossible; readonly FarmAssistent: ActivePossible; readonly Premium: ActivePossible; }; -export type Player = { +type Player = { ally: string; ally_level: string; ally_member_count: string; @@ -52,7 +50,7 @@ export type Player = { villages: string; }; -export type Village = { +type Village = { buildings: Buildings; coord: string; display_name: string; @@ -80,7 +78,7 @@ export type Village = { y: number; }; -export type Buildings = { +type Buildings = { barracks: string; farm: string; garage: string; @@ -100,7 +98,7 @@ export type Buildings = { wood: string; }; -export interface RawTribalWarsGameData { +interface RawTribalWarsGameData { // TribalWars.getGameData() readonly device: string; readonly features: Readonly; @@ -121,7 +119,7 @@ export interface RawTribalWarsGameData { readonly world: string; }; -export interface RawPlunderInfo { +interface RawPlunderInfo { // Accountmanager.farm readonly current_units: Readonly; readonly extended: boolean; @@ -137,20 +135,20 @@ export interface RawPlunderInfo { setPageSize(size: number): boolean; }; -export type MarketDataTrader = { +type MarketDataTrader = { readonly amount: number; readonly carry: number; readonly total: number; }; -export type PremiumExchangeGraphResourceData = { +type PremiumExchangeGraphResourceData = { readonly color: string; readonly data: ReadonlyArray<[number, string]>; readonly details: ReadonlyArray<{ res_type: Resources }>; readonly label: ResourcesPTBR; }; -export interface RawTiming { +interface RawTiming { readonly added_server_time: number; readonly initial_server_time: number; readonly is_ready: boolean; diff --git a/types/electron.d.ts b/types/electron.d.ts new file mode 100644 index 00000000..567a4b48 --- /dev/null +++ b/types/electron.d.ts @@ -0,0 +1,8 @@ +type BrowserViewConstructorOptions = import('electron').BrowserWindowConstructorOptions; +type WebContents = import('electron').WebContents; + +type WindowOpenHandler = ReturnType[0]>; + +type ElectronMessageBoxOptions = Pick; \ No newline at end of file diff --git a/types/electron.ts b/types/electron.ts deleted file mode 100644 index 88223950..00000000 --- a/types/electron.ts +++ /dev/null @@ -1,7 +0,0 @@ -import type { MessageBoxOptions, WebContents } from 'electron'; - -export type WindowOpenHandler = ReturnType[0]>; - -export type ElectronMessageBoxOptions = Pick; \ No newline at end of file diff --git a/types/error.ts b/types/error.d.ts similarity index 53% rename from types/error.ts rename to types/error.d.ts index 3ba71b23..7a20d1a2 100644 --- a/types/error.ts +++ b/types/error.d.ts @@ -1,7 +1,4 @@ -import type { EnvironmentInfo } from '$types/ares'; -import type { World } from '$types/game'; - -export type ErrorLogBase = { +type ErrorLogBase = { readonly id: number; readonly pending: boolean; readonly name: string; @@ -9,14 +6,14 @@ export type ErrorLogBase = { readonly stack: string | null; }; -export interface ErrorLogType extends EnvironmentInfo, ErrorLogBase { +interface ErrorLogType extends EnvironmentInfo, ErrorLogBase { readonly world: World | null; readonly url: string; }; -export type ElectronErrorLogType = EnvironmentInfo & ErrorLogBase; +type ElectronErrorLogType = EnvironmentInfo & ErrorLogBase; -export type OmitOptionalErrorLogProps = Omit; -export type AllErrorLogTypes = +type OmitOptionalErrorLogProps = Omit; +type AllErrorLogTypes = | OmitOptionalErrorLogProps & Partial> | OmitOptionalErrorLogProps & Partial>; \ No newline at end of file diff --git a/types/game.ts b/types/game.d.ts similarity index 75% rename from types/game.ts rename to types/game.d.ts index e4c91f95..e2a0dd4b 100644 --- a/types/game.ts +++ b/types/game.d.ts @@ -1,66 +1,64 @@ -import type { IntRange, IntRangeToStrings } from '$types/utils'; - -export type UserAlias = `${World}__USERID__${string}`; -export type GameRegion = 'br' | 'en' | 'nl' | 'pt' | 'uk' | 'us'; -export type World = +type UserAlias = `${World}__USERID__${string}`; +type GameRegion = 'br' | 'en' | 'nl' | 'pt' | 'uk' | 'us'; +type World = // eslint-disable-next-line @typescript-eslint/sort-type-constituents | `${GameRegion}${string}` // Mundo padrão. | `${GameRegion}s${string}` // Rodada speed. | `${GameRegion}p${string}`; // Mundo casual. // RECURSOS -export type Resources = 'iron' | 'stone' | 'wood'; -export type ResourcesPTBR = 'Argila' | 'Ferro' | 'Madeira'; -export type ResourceAmount = { [key in Resources]: number }; +type Resources = 'iron' | 'stone' | 'wood'; +type ResourcesPTBR = 'Argila' | 'Ferro' | 'Madeira'; +type ResourceAmount = { [key in Resources]: number }; // UNIDADES /** Unidades que podem ser usadas no assistente de saque. */ -export type FarmUnits = +type FarmUnits = 'archer' | 'axe' | 'heavy' | 'knight' | 'light' | 'marcher' | 'spear' | 'spy' | 'sword'; /** Unidades que não podem saquear. */ -export type OtherUnits = +type OtherUnits = 'catapult' | 'militia' | 'ram' | 'snob'; /** Todas as unidades do jogo. */ -export type AllUnits = +type AllUnits = | FarmUnits | OtherUnits; -export type FarmUnitsAmount = { [key in FarmUnits]: number }; -export type UnitAmount = { [key in AllUnits]: number }; -export type UnitsAmountAsStrings = { [key in AllUnits]: string }; -export type PlaceUnitsAmount = Partial>; +type FarmUnitsAmount = { [key in FarmUnits]: number }; +type UnitAmount = { [key in AllUnits]: number }; +type UnitsAmountAsStrings = { [key in AllUnits]: string }; +type PlaceUnitsAmount = Partial>; // CONSTRUÇÕES -export type WallLevel = IntRange<0, 21>; -export type StringWallLevel = IntRangeToStrings<0, 21>; +type WallLevel = IntRange<0, 21>; +type StringWallLevel = IntRangeToStrings<0, 21>; // OUTROS -export type DemolitionTroops = Omit; -export type UnitsToDestroyWall = Record; +type DemolitionTroops = Omit; +type UnitsToDestroyWall = Record; -export type GameScreen = +type GameScreen = 'am_farm' | 'info_player' | 'market' | 'overview_villages' | 'overview' | 'place' | 'report'; -export type Coords = { +type Coords = { x: number; y: number; }; -export type VillageGroup = { +type VillageGroup = { readonly id: number; /** Nome do grupo após codificado pela função `encodeURIComponent`. */ readonly name: string; readonly type: 'dynamic' | 'static'; }; -export type VillageGroupsType = { +type VillageGroupsType = { /** Todos os grupos de aldeias referentes a um determinado alias. */ readonly allGroups: VillageGroup[]; }; -export interface TribalWarsGameDataType { +interface TribalWarsGameDataType { readonly ares: { /** Local. */ readonly locale: string | null; @@ -128,7 +126,7 @@ export interface TribalWarsGameDataType { }; }; -export interface TribalWarsTimingType { +interface TribalWarsTimingType { readonly addedServerTime: number; readonly initialServerTime: number; readonly isReady: boolean; diff --git a/types/modules.d.ts b/types/modules.d.ts new file mode 100644 index 00000000..c51682ae --- /dev/null +++ b/types/modules.d.ts @@ -0,0 +1,34 @@ +type ModuleConstructorOptions = Pick; + +interface ModuleRouteToPush { + name: ModuleRoutes; +} + +interface ModuleRouteRecordRaw extends ModuleRouteToPush { + path: string; + component: import('vue-router').RouteComponent; + children?: ModuleRouteRecordRaw[]; +}; + +type ModuleRouteRecordRawStrict = Omit & { + name: T; + children?: ModuleRouteRecordRawStrict[]; +}; + +type SingleModules = + 'app-update' | 'default' | 'demolition' | 'plunder-history' | 'plunder-template'; + +type NestedModules = 'app-config' | 'error-log'; +type ModuleNames = NestedModules | SingleModules; + +type ErrorModuleRoutes = 'error-electron' | 'error-general'; + +type ConfigModuleRoutes = + 'config-advanced' | 'config-general' | 'config-notifications' | 'config-plunder'; + +type ModuleRoutes = ConfigModuleRoutes | ErrorModuleRoutes | ModuleNames; + +// WEBSITE +type WebsiteModuleNames = 'any-allowed' | 'ares' | 'issues' | 'repo'; \ No newline at end of file diff --git a/types/modules.ts b/types/modules.ts deleted file mode 100644 index 650878d7..00000000 --- a/types/modules.ts +++ /dev/null @@ -1,37 +0,0 @@ -import type { RouteComponent } from 'vue-router'; -import type { BrowserWindowConstructorOptions } from 'electron'; - -export type ModuleConstructorOptions = Pick; - -export interface ModuleRouteToPush { - name: ModuleRoutes; -} - -export interface ModuleRouteRecordRaw extends ModuleRouteToPush { - path: string; - component: RouteComponent; - children?: ModuleRouteRecordRaw[]; -}; - -export type ModuleRouteRecordRawStrict = Omit & { - name: T; - children?: ModuleRouteRecordRawStrict[]; -}; - -export type SingleModules = - 'app-update' | 'default' | 'demolition' | 'plunder-history' | 'plunder-template'; - -export type NestedModules = 'app-config' | 'error-log'; -export type ModuleNames = NestedModules | SingleModules; - -export type ErrorModuleRoutes = 'error-electron' | 'error-general'; - -export type ConfigModuleRoutes = - 'config-advanced' | 'config-general' | 'config-notifications' | 'config-plunder'; - -export type ModuleRoutes = ConfigModuleRoutes | ErrorModuleRoutes | ModuleNames; - -// WEBSITE -export type WebsiteModuleNames = 'any-allowed' | 'ares' | 'issues' | 'repo'; \ No newline at end of file diff --git a/types/phobos.ts b/types/phobos.d.ts similarity index 56% rename from types/phobos.ts rename to types/phobos.d.ts index 3623057b..c64b8349 100644 --- a/types/phobos.ts +++ b/types/phobos.d.ts @@ -1,8 +1,6 @@ -import type { AutoResizeOptions, Rectangle, BrowserViewConstructorOptions } from 'electron'; - -export interface PhobosOptions extends BrowserViewConstructorOptions { - autoResize?: AutoResizeOptions; - bounds?: Rectangle; +interface PhobosOptions extends BrowserViewConstructorOptions { + autoResize?: import('electron').AutoResizeOptions; + bounds?: import('electron').Rectangle; /** Define se um Phobos já ativo será destruido ao se tentar criar um novo com o mesmo nome. */ override?: boolean; @@ -13,13 +11,13 @@ export interface PhobosOptions extends BrowserViewConstructorOptions { overrideUrl?: boolean; }; -export type PhobosNames = +type PhobosNames = | 'fetch-world-config' | 'fetch-world-unit' | 'get-village-groups'; -export type PhobosChannel = PhobosNames; +type PhobosChannel = PhobosNames; -export interface PhobosPortMessage extends Record { +interface PhobosPortMessage extends Record { channel: PhobosChannel; }; \ No newline at end of file diff --git a/types/plunder/config.ts b/types/plunder/config.d.ts similarity index 90% rename from types/plunder/config.ts rename to types/plunder/config.d.ts index 4a96f98b..ba93ab68 100644 --- a/types/plunder/config.ts +++ b/types/plunder/config.d.ts @@ -1,5 +1,3 @@ -import type { WallLevel } from '$types/game'; - /** * Padrão de ataque quando o Plunder não tem informações dos exploradores. * @@ -7,7 +5,7 @@ import type { WallLevel } from '$types/game'; * * `smaller`: Ataca com a menor capacidade de carga possível. */ -export type BlindAttackPattern = 'bigger' | 'smaller'; +type BlindAttackPattern = 'bigger' | 'smaller'; /** * Padrão de ataque quando o Plunder está usando o modelo C. @@ -19,9 +17,9 @@ export type BlindAttackPattern = 'bigger' | 'smaller'; * * `only`: Utiliza apenas o modelo C. */ -export type UseCPattern = 'excess' | 'normal' | 'only'; +type UseCPattern = 'excess' | 'normal' | 'only'; -export type PlunderConfigType = { +type PlunderConfigType = { // Painel /** Indica se o Plunder está ativado. */ active: boolean; @@ -91,9 +89,9 @@ export type PlunderConfigType = { pageDelay: number; }; -export type PlunderPanelConfig = Pick; -export type PlunderPanelConfigKeys = keyof PlunderPanelConfig; -export type PlunderPanelConfigValues = PlunderPanelConfig[PlunderPanelConfigKeys]; \ No newline at end of file +type PlunderPanelConfigKeys = keyof PlunderPanelConfig; +type PlunderPanelConfigValues = PlunderPanelConfig[PlunderPanelConfigKeys]; \ No newline at end of file diff --git a/types/plunder/group.ts b/types/plunder/group.d.ts similarity index 84% rename from types/plunder/group.ts rename to types/plunder/group.d.ts index 1513dfac..fbd3e751 100644 --- a/types/plunder/group.ts +++ b/types/plunder/group.d.ts @@ -1,11 +1,11 @@ -export type PlunderGroupVillageType = { +type PlunderGroupVillageType = { /** Distância coberta pela última onda de ataques. */ waveMaxDistance: number; /** Indica se o Plunder já enviou todos os ataques possíveis a partir dessa aldeia. */ done: boolean; }; -export type PlunderGroupType = { +type PlunderGroupType = { /** ID do grupo. */ readonly id: number; /** Mapa contento as aldeias do grupo. As chaves são os IDs das aldeias. */ diff --git a/types/plunder/history.ts b/types/plunder/history.d.ts similarity index 64% rename from types/plunder/history.ts rename to types/plunder/history.d.ts index 9b56d0a1..fedfc775 100644 --- a/types/plunder/history.ts +++ b/types/plunder/history.d.ts @@ -1,4 +1,4 @@ -export type PlunderAttackLog = { +type PlunderAttackLog = { wood: number; stone: number; iron: number; @@ -6,11 +6,11 @@ export type PlunderAttackLog = { destroyedWalls: number; }; -export interface PlunderHistoryVillageType extends PlunderAttackLog { +interface PlunderHistoryVillageType extends PlunderAttackLog { readonly addedAt: number; }; -export interface PlunderHistoryType extends PlunderAttackLog { +interface PlunderHistoryType extends PlunderAttackLog { /** Histórico individual de cada aldeia nos últimos 30 dias. */ readonly villages: { [id: string]: PlunderHistoryVillageType[]; diff --git a/types/plunder/index.ts b/types/plunder/index.d.ts similarity index 69% rename from types/plunder/index.ts rename to types/plunder/index.d.ts index eb60593a..f32e35ae 100644 --- a/types/plunder/index.ts +++ b/types/plunder/index.d.ts @@ -1,14 +1,4 @@ -import type { FarmUnitsAmount, UserAlias, UnitsToDestroyWall } from '$types/game'; -import type { PlunderGroupType } from '$types/plunder/group'; -import type { PlunderPageListType } from '$types/plunder/page'; - -export type * from '$types/plunder/config'; -export type * from '$types/plunder/group'; -export type * from '$types/plunder/history'; -export type * from '$types/plunder/info'; -export type * from '$types/plunder/page'; - -export type PlunderCacheType = { +type PlunderCacheType = { /** Páginas do assistente de saque referentes à aldeia atual. */ readonly pages: PlunderPageListType | null; /** Informações sobre o grupo de saque. */ @@ -17,7 +7,7 @@ export type PlunderCacheType = { readonly demolitionTroops: DemolitionTemplateType | null; }; -export type PlunderTableButtons = { +type PlunderTableButtons = { /** Botão A do assistente de saque. */ a: HTMLAnchorElement | null; /** Botão B do assistente de saque. */ @@ -28,7 +18,7 @@ export type PlunderTableButtons = { place: HTMLAnchorElement | null; }; -export type PlunderTableResources = { +type PlunderTableResources = { /** Estimativa da quantidade de madeira disponível na aldeia. */ wood: number; /** Estimativa da quantidade de argila disponível na aldeia. */ @@ -39,7 +29,7 @@ export type PlunderTableResources = { total: number; }; -export type CustomPlunderTemplateType = { +type CustomPlunderTemplateType = { /** Alias do usuário. */ alias: UserAlias; /** Nome do modelo. */ @@ -50,7 +40,7 @@ export type CustomPlunderTemplateType = { readonly units: Omit; }; -export type DemolitionTemplateType = { +type DemolitionTemplateType = { /** Alias do usuário. */ alias: UserAlias; /** Modelos. */ diff --git a/types/plunder/info.ts b/types/plunder/info.d.ts similarity index 93% rename from types/plunder/info.ts rename to types/plunder/info.d.ts index 0aed589c..ce7d420b 100644 --- a/types/plunder/info.ts +++ b/types/plunder/info.d.ts @@ -1,4 +1,4 @@ -export type PlunderInfoType = { +type PlunderInfoType = { /** Indica se as aldeias sob ataque estão ocultas. */ readonly hideAttacked: boolean; /** Página atual. */ diff --git a/types/plunder/page.ts b/types/plunder/page.d.ts similarity index 82% rename from types/plunder/page.ts rename to types/plunder/page.d.ts index 123435ba..228978a1 100644 --- a/types/plunder/page.ts +++ b/types/plunder/page.d.ts @@ -1,11 +1,11 @@ -export type PlunderPageType = { +type PlunderPageType = { /** Índice da página (inicia em zero). */ readonly index: number; /** Indica se o Plunder já enviou ataques a partir dessa página. */ done: boolean; } -export type PlunderPageListType = { +type PlunderPageListType = { /** ID da aldeia a qual as páginas pertencem. */ readonly id: number; /** Lista de páginas. */ diff --git a/types/stores.ts b/types/stores.d.ts similarity index 52% rename from types/stores.ts rename to types/stores.d.ts index 6ba9c11d..1cd73d59 100644 --- a/types/stores.ts +++ b/types/stores.d.ts @@ -1,74 +1,68 @@ -import type { ComputedRef, Ref } from 'vue'; -import type { WebContents } from 'electron'; -import type { MechanusComputedRef, MechanusRef, MechanusStore } from 'mechanus'; -import type { RemoveMethods } from '$types/utils'; -import type { WorldConfigType } from '$types/world'; -import type { UnitDetails } from '$types/world'; -import type { GeneralConfigType, NotificationsConfigType } from '$types/config'; -import type { PlunderInfoType, PlunderConfigType, PlunderHistoryType, PlunderCacheType } from '$types/plunder'; -import type { AllUnits, GameRegion, TribalWarsGameDataType, UnitAmount, UserAlias, VillageGroup, World } from '$types/game'; +type MechanusRef = import('mechanus').MechanusRef; +type MechanusComputedRef = import('mechanus').MechanusComputedRef; +type MechanusStore = import('mechanus').MechanusStore; // APP GENERAL CONFIG -export type AppGeneralConfigStore = GeneralConfigType; -export type MechanusAppGeneralConfigStoreType = { +type AppGeneralConfigStore = GeneralConfigType; +type MechanusAppGeneralConfigStoreType = { [K in keyof AppGeneralConfigStore]: MechanusRef; }; // APP NOTIFICATIONS CONFIG -export type AppNotificationsConfigStore = NotificationsConfigType; -export type MechanusAppNotificationsConfigStoreType = { +type AppNotificationsConfigStore = NotificationsConfigType; +type MechanusAppNotificationsConfigStoreType = { [K in keyof AppNotificationsConfigStore]: MechanusRef; }; // ARES type AresType = TribalWarsGameDataType['ares']; -export interface AresStore extends AresType { +interface AresStore extends AresType { /** Indica se há um captcha ativo. */ readonly captcha: boolean; /** Tempo de resposta do servidor do jogo. */ readonly responseTime: number | null; }; -export type PiniaAresStoreType = { - [K in keyof AresStore]: Ref; +type PiniaAresStoreType = { + [K in keyof AresStore]: import('vue').Ref; }; -export type MechanusAresStoreType = { +type MechanusAresStoreType = { [K in keyof AresStore]: MechanusRef; }; // PLAYER -export type PlayerStore = TribalWarsGameDataType['player']; -export type PiniaPlayerStoreType = { - [K in keyof PlayerStore]: Ref; +type PlayerStore = TribalWarsGameDataType['player']; +type PiniaPlayerStoreType = { + [K in keyof PlayerStore]: import('vue').Ref; }; -export type MechanusPlayerStoreType = { +type MechanusPlayerStoreType = { [K in keyof PlayerStore]: MechanusRef; }; // FEATURES -export type FeaturesStore = TribalWarsGameDataType['features']; -export type PiniaFeaturesStoreType = { - [K in keyof FeaturesStore]: Ref; +type FeaturesStore = TribalWarsGameDataType['features']; +type PiniaFeaturesStoreType = { + [K in keyof FeaturesStore]: import('vue').Ref; }; -export type MechanusFeaturesStoreType = { +type MechanusFeaturesStoreType = { [K in keyof FeaturesStore]: MechanusRef; }; // GROUPS type GameDataGroups = TribalWarsGameDataType['groups']; -export interface GroupsStore extends GameDataGroups { +interface GroupsStore extends GameDataGroups { /** Todos os grupos de aldeias referentes ao alias atual. */ readonly all: Set; }; -export type PiniaGroupsStoreType = { - [K in keyof GroupsStore]: Ref; +type PiniaGroupsStoreType = { + [K in keyof GroupsStore]: import('vue').Ref; }; -export type MechanusGroupsStoreType = { +type MechanusGroupsStoreType = { [K in keyof GroupsStore]: MechanusRef; }; // CURRENT VILLAGE type CurrentVillageType = TribalWarsGameDataType['currentVillage']; -export interface CurrentVillageStore extends CurrentVillageType { +interface CurrentVillageStore extends CurrentVillageType { readonly coords: [CurrentVillageType['x'], CurrentVillageType['y']]; readonly totalResources: number | null; @@ -79,17 +73,17 @@ export interface CurrentVillageStore extends CurrentVillageType { getId(): number; }; -export type PiniaCurrentVillageStoreActions = CurrentVillageStore['getId']; -export type PiniaCurrentVillageStoreType = { +type PiniaCurrentVillageStoreActions = CurrentVillageStore['getId']; +type PiniaCurrentVillageStoreType = { [K in keyof CurrentVillageStore]: CurrentVillageStore[K] extends PiniaCurrentVillageStoreActions ? CurrentVillageStore[K] : K extends keyof Omit ? - ComputedRef : - Ref; + import('vue').ComputedRef : + import('vue').Ref; }; -export type MechanusCurrentVillageStoreType = { +type MechanusCurrentVillageStoreType = { [K in keyof RemoveMethods]: K extends keyof Omit ? MechanusComputedRef : @@ -97,90 +91,90 @@ export type MechanusCurrentVillageStoreType = { }; // PLUNDER INFO -export type PlunderStore = PlunderInfoType; -export type PiniaPlunderStoreType = { - [K in keyof PlunderStore]: Ref; +type PlunderStore = PlunderInfoType; +type PiniaPlunderStoreType = { + [K in keyof PlunderStore]: import('vue').Ref; }; -export type MechanusPlunderStoreType = { +type MechanusPlunderStoreType = { [K in keyof PlunderStore]: MechanusRef; }; // PLUNDER CONFIG -export interface PlunderConfigStore extends PlunderConfigType { +interface PlunderConfigStore extends PlunderConfigType { raw(): PlunderConfigType; }; -export type PiniaPlunderConfigStoreActions = PlunderConfigStore['raw']; +type PiniaPlunderConfigStoreActions = PlunderConfigStore['raw']; -export type PiniaPlunderConfigStoreType = { +type PiniaPlunderConfigStoreType = { [K in keyof PlunderConfigStore]: PlunderConfigStore[K] extends PiniaPlunderConfigStoreActions ? PlunderConfigStore[K] : - Ref; + import('vue').Ref; }; -export type MechanusPlunderConfigStoreType = { +type MechanusPlunderConfigStoreType = { [K in keyof RemoveMethods]: MechanusRef[K]>; }; // PLUNDER HISTORY -export interface PlunderHistoryStore extends PlunderHistoryType { - useTotal(): ComputedRef; +interface PlunderHistoryStore extends PlunderHistoryType { + useTotal(): import('vue').ComputedRef; }; -export type PiniaPlunderHistoryStoreActions = PlunderHistoryStore['useTotal']; +type PiniaPlunderHistoryStoreActions = PlunderHistoryStore['useTotal']; -export type PiniaPlunderHistoryStoreType = { +type PiniaPlunderHistoryStoreType = { [K in Exclude]: PlunderHistoryStore[K] extends PiniaPlunderHistoryStoreActions ? PlunderHistoryStore[K] : - Ref; + import('vue').Ref; }; -export type MechanusPlunderHistoryStoreType = { +type MechanusPlunderHistoryStoreType = { [K in keyof RemoveMethods]: MechanusRef[K]>; }; // PLUNDER CACHE -export type PlunderCacheStore = PlunderCacheType; -export type MechanusPlunderCacheStoreType = { +type PlunderCacheStore = PlunderCacheType; +type MechanusPlunderCacheStoreType = { [K in keyof PlunderCacheStore]: MechanusRef; }; // UNITS -export interface UnitsStore extends UnitAmount { +interface UnitsStore extends UnitAmount { raw(): UnitAmount; }; -export type PiniaUnitsStoreActions = UnitsStore['raw']; -export type PiniaUnitsStoreType = { +type PiniaUnitsStoreActions = UnitsStore['raw']; +type PiniaUnitsStoreType = { [K in keyof UnitsStore]: UnitsStore[K] extends PiniaUnitsStoreActions ? UnitsStore[K] : - Ref; + import('vue').Ref; }; -export type MechanusUnitsStoreType = { +type MechanusUnitsStoreType = { [K in keyof RemoveMethods]: MechanusRef[K]>; }; // WORLD CONFIG -export type WorldConfigStore = WorldConfigType; -export type MechanusWorldConfigStoreType = { +type WorldConfigStore = WorldConfigType; +type MechanusWorldConfigStoreType = { [K in keyof WorldConfigStore]: MechanusRef; }; // WORLD UNIT -export type WorldUnitStoresMap = ReadonlyMap MechanusStore>; -export type MechanusWorldUnitStoreType = { +type WorldUnitStoresMap = ReadonlyMap MechanusStore>; +type MechanusWorldUnitStoreType = { [K in keyof UnitDetails]: MechanusRef; }; // CACHE -export interface CacheStore { +interface CacheStore { readonly region: GameRegion; readonly world: World | null; readonly player: string | null; readonly userAlias: UserAlias | null; }; -export type MechanusCacheStoreType = { +type MechanusCacheStoreType = { [K in keyof CacheStore]: K extends 'userAlias' ? MechanusComputedRef : @@ -188,7 +182,7 @@ export type MechanusCacheStoreType = { }; // BROWSER VIEW -export interface BrowserViewStore { +interface BrowserViewStore { /** Todos os WebContents de BrowserViews associados à janela principal. */ readonly allWebContents: Set; /** Todos os WebContents de BrowserViews com eventos já registrados. */ @@ -199,26 +193,26 @@ export interface BrowserViewStore { readonly currentAutoResize: (() => void) | null; }; -export type MechanusBrowserViewStoreType = { +type MechanusBrowserViewStoreType = { [K in keyof BrowserViewStore]: MechanusRef; }; // BROWSER -export interface BrowserStore { +interface BrowserStore { /** Indica se o Deimos está pronto para receber comandos. */ readonly isDeimosReady: boolean; }; -export type PiniaBrowserStoreType = { - [K in keyof BrowserStore]: Ref; +type PiniaBrowserStoreType = { + [K in keyof BrowserStore]: import('vue').Ref; }; // PAINEL -export interface PanelStore { +interface PanelStore { /** Indica se o painel está visível. */ readonly isVisible: boolean; }; -export type PiniaPanelStoreType = { - [K in keyof PanelStore]: Ref; +type PiniaPanelStoreType = { + [K in keyof PanelStore]: import('vue').Ref; }; \ No newline at end of file diff --git a/types/utils.ts b/types/utils.d.ts similarity index 58% rename from types/utils.ts rename to types/utils.d.ts index e39fd0bc..c677b160 100644 --- a/types/utils.ts +++ b/types/utils.d.ts @@ -1,12 +1,12 @@ // Remove os métodos de um objeto. -export type NonFunctionKeyNames = Exclude<{ +type NonFunctionKeyNames = Exclude<{ [key in keyof T]: T[key] extends Function ? never : key; }[keyof T], undefined>; -export type RemoveMethods = Pick>; +type RemoveMethods = Pick>; // Número para string. -export type NumberToString = `${N}`; +type NumberToString = `${N}`; // Range de números inteiros. type Enumerate = Acc['length'] extends N @@ -14,12 +14,12 @@ type Enumerate = Acc['length'] exte : Enumerate /** Range de números inteiros. `F` é inclusivo e `T` é exclusivo. */ -export type IntRange = Exclude, Enumerate>; +type IntRange = Exclude, Enumerate>; /** Range de números inteiros convertidos para strings. `F` é inclusivo e `T` é exclusivo. */ -export type IntRangeToStrings = NumberToString>; +type IntRangeToStrings = NumberToString>; /** Opções do componente `NSelect` do Naive UI. */ -export type NSelectPatternOption = ReadonlyArray<{ +type NSelectPatternOption = ReadonlyArray<{ label: string; value: T; }>; \ No newline at end of file diff --git a/types/view.ts b/types/view.d.ts similarity index 100% rename from types/view.ts rename to types/view.d.ts diff --git a/types/world/config.ts b/types/world/config.d.ts similarity index 94% rename from types/world/config.ts rename to types/world/config.d.ts index 7959ae53..5fb4f6fb 100644 --- a/types/world/config.ts +++ b/types/world/config.d.ts @@ -1,4 +1,4 @@ -export type WorldConfigType = { +type WorldConfigType = { /** Velocidade do mundo (FLOAT). */ speed: number; /** Velocidade das unidades (FLOAT). */ diff --git a/types/world/index.d.ts b/types/world/index.d.ts new file mode 100644 index 00000000..f079a872 --- /dev/null +++ b/types/world/index.d.ts @@ -0,0 +1,10 @@ +type WorldDataType = { + villages: WorldVillagesType[]; +}; + +type WorldDataFetchHistoryType = { + readonly world: World; + readonly village: number | null; + readonly player: number | null; + readonly ally: number | null; +}; \ No newline at end of file diff --git a/types/world/index.ts b/types/world/index.ts deleted file mode 100644 index cbce85e9..00000000 --- a/types/world/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -import type { World } from '$types/game'; -import type { WorldVillagesType } from '$types/world/villages'; - -export * from '$types/world/config'; -export * from '$types/world/units'; -export * from '$types/world/villages'; - -export type WorldDataType = { - villages: WorldVillagesType[]; -}; - -export type WorldDataFetchHistoryType = { - readonly world: World; - readonly village: number | null; - readonly player: number | null; - readonly ally: number | null; -}; \ No newline at end of file diff --git a/types/world/units.ts b/types/world/units.d.ts similarity index 74% rename from types/world/units.ts rename to types/world/units.d.ts index 197bdb5b..4b785024 100644 --- a/types/world/units.ts +++ b/types/world/units.d.ts @@ -1,6 +1,4 @@ -import type { AllUnits } from '$types/game'; - -export type UnitDetails = { +type UnitDetails = { buildTime: number; pop: number; /** Velocidade da unidade (FLOAT). */ @@ -12,6 +10,6 @@ export type UnitDetails = { carry: number; }; -export type WorldUnitsType = { +type WorldUnitsType = { [key in AllUnits]: key extends 'archer' | 'marcher' ? UnitDetails | null : UnitDetails }; \ No newline at end of file diff --git a/types/world/villages.ts b/types/world/villages.d.ts similarity index 53% rename from types/world/villages.ts rename to types/world/villages.d.ts index 67a4163a..6814a775 100644 --- a/types/world/villages.ts +++ b/types/world/villages.d.ts @@ -1,6 +1,4 @@ -import type { Model } from 'sequelize'; - -export interface WorldVillagesModel extends Model { +interface WorldVillagesModel extends import('sequelize').Model { readonly id: number; readonly name: string; readonly x: number; @@ -10,4 +8,4 @@ export interface WorldVillagesModel extends Model { readonly type: number; }; -export type WorldVillagesType = Omit; \ No newline at end of file +type WorldVillagesType = Omit; \ No newline at end of file From baa6979c15315f035cfffe7bc2ce94cf1a367dc6 Mon Sep 17 00:00:00 2001 From: Andrew Ferreira Date: Thu, 11 May 2023 19:19:45 -0300 Subject: [PATCH 3/3] refactor: converte tipos para `d.ts` --- browser.config.ts | 1 - browser/components/PlunderReloadMessage.vue | 2 +- browser/components/TheCaptchaObserver.vue | 2 +- browser/lib/plunder/attack.ts | 1 - browser/lib/plunder/data.ts | 2 +- browser/lib/plunder/group.ts | 4 +- browser/lib/plunder/next.ts | 1 - browser/lib/plunder/targets.ts | 2 - browser/lib/plunder/templates.ts | 2 - browser/lib/plunder/units.ts | 1 - browser/lib/plunder/village.ts | 1 - browser/lib/plunder/wall.ts | 1 - browser/stores/browser.ts | 3 +- browser/views/PlunderView.vue | 1 - deimos/deimos.d.ts | 12 +- deimos/interface/ipc.ts | 1 - deimos/models/data.ts | 2 - deimos/models/plunder.ts | 2 - deimos/models/timing.ts | 2 - deimos/models/units.ts | 1 - deimos/tsconfig.json | 5 +- electron/app/modules/standard.ts | 5 +- electron/app/modules/website.ts | 1 - electron/app/phobos.ts | 4 +- electron/child-process/error.ts | 3 +- electron/child-process/world-data.ts | 2 - electron/database/config/config.ts | 1 - electron/database/config/index.ts | 1 - electron/database/config/panel.ts | 5 +- electron/database/config/state.ts | 2 - electron/database/error.ts | 2 - electron/database/groups.ts | 1 - electron/database/plunder/config.ts | 2 - electron/database/plunder/demolition.ts | 2 - electron/database/plunder/history.ts | 2 - electron/database/plunder/template.ts | 2 - electron/database/world/config.ts | 2 - electron/database/world/history.ts | 2 - electron/database/world/units.ts | 2 - electron/database/world/villages.ts | 2 - electron/error.ts | 1 - electron/events/config.ts | 2 - electron/events/deimos.ts | 12 +- electron/events/dev.ts | 3 +- electron/events/error.ts | 1 - electron/events/index.ts | 2 - electron/events/modules/update.ts | 1 - electron/events/plunder/config.ts | 3 +- electron/events/plunder/demolition.ts | 2 - electron/events/plunder/group.ts | 1 - electron/events/plunder/history.ts | 1 - electron/events/plunder/index.ts | 2 - electron/events/plunder/page.ts | 1 - electron/events/plunder/templates.ts | 2 - electron/events/ui/download.ts | 6 +- electron/events/ui/menu.ts | 9 +- electron/events/view.ts | 36 +++--- electron/events/world-data.ts | 1 - electron/interface/alias.ts | 2 - electron/interface/error.ts | 1 - electron/interface/world/config.ts | 3 - electron/interface/world/data.ts | 2 - electron/interface/world/index.ts | 1 - electron/interface/world/units.ts | 3 - electron/menu/dev.ts | 13 +- electron/menu/menu.ts | 5 +- electron/stores/ares.ts | 4 +- electron/stores/cache.ts | 4 +- electron/stores/config.ts | 3 +- electron/stores/features.ts | 3 +- electron/stores/groups.ts | 4 +- electron/stores/player.ts | 3 +- electron/stores/plunder/config.ts | 5 - electron/stores/plunder/history.ts | 3 - electron/stores/plunder/index.ts | 3 - electron/stores/units.ts | 3 +- electron/stores/view.ts | 10 +- electron/stores/village.ts | 2 - electron/stores/world.ts | 4 - electron/tsconfig.json | 5 +- electron/utils/groups.ts | 9 +- electron/utils/helpers.ts | 10 +- electron/utils/mechanus.ts | 4 +- electron/utils/view.ts | 31 ++--- global/error.ts | 2 - global/guards/ares.ts | 1 - global/guards/game.ts | 1 - global/helpers.ts | 1 - global/objects/plunder.ts | 2 - modules.config.ts | 1 - modules/components/ConfigGeneral.vue | 2 +- modules/components/ConfigNotifications.vue | 2 +- modules/components/ConfigPlunder.vue | 1 - .../components/ConfigPlunderGridAttack.vue | 2 - .../components/ConfigPlunderGridGroups.vue | 1 - .../components/ConfigPlunderGridOthers.vue | 1 - .../components/ConfigPlunderGridTemplateC.vue | 2 - modules/components/ConfigPlunderGridWall.vue | 2 - modules/components/ErrorLogElectron.vue | 1 - modules/components/ErrorLogGeneral.vue | 1 - .../components/PlunderHistoryDataTable.vue | 5 +- modules/components/PlunderHistoryHeader.vue | 1 - modules/components/PlunderTemplateCard.vue | 3 +- modules/components/PlunderTemplateModal.vue | 2 - modules/events.ts | 1 - modules/router/config.ts | 1 - modules/router/error.ts | 1 - modules/router/index.ts | 1 - modules/views/AppUpdateView.vue | 1 - modules/views/ConfigView.vue | 1 - modules/views/DemolitionView.vue | 1 - modules/views/ErrorLogView.vue | 1 - modules/views/PlunderHistoryView.vue | 4 +- modules/views/PlunderTemplateView.vue | 1 - panel.config.ts | 1 - panel/events/index.ts | 1 - panel/events/plunder.ts | 1 - panel/router/index.ts | 4 +- panel/stores/panel.ts | 1 - panel/views/CaptchaView.vue | 2 +- panel/views/PlunderView.vue | 2 +- phobos/events.ts | 1 - phobos/groups/groups.ts | 1 - phobos/tsconfig.json | 5 +- phobos/world/config.ts | 1 - phobos/world/unit.ts | 1 - renderer/components/ButtonGroupsUpdate.vue | 1 - renderer/components/InputNumber.vue | 2 +- renderer/components/InputWall.vue | 2 +- renderer/components/SwitchPopover.vue | 2 +- renderer/ipc.ts | 16 --- renderer/stores/ares.ts | 2 - renderer/stores/features.ts | 1 - renderer/stores/groups.ts | 2 - renderer/stores/player.ts | 1 - renderer/stores/plunder/config.ts | 3 - renderer/stores/plunder/index.ts | 1 - renderer/stores/units.ts | 2 - renderer/stores/village.ts | 1 - renderer/views/DefaultView.vue | 2 +- tsconfig.json | 3 +- types/electron.d.ts | 8 -- types/plunder/group.d.ts | 13 -- types/plunder/history.d.ts | 18 --- types/plunder/index.d.ts | 48 -------- types/plunder/info.d.ts | 14 --- types/plunder/page.d.ts | 13 -- types/world/config.d.ts | 18 --- types/world/index.d.ts | 10 -- types/world/units.d.ts | 15 --- types/world/villages.d.ts | 11 -- {types => typings}/config.d.ts | 2 +- {types => typings}/deimos.d.ts | 0 {types => typings}/error.d.ts | 0 {types => typings}/game.d.ts | 0 types/ares.d.ts => typings/index.d.ts | 7 ++ {types => typings}/modules.d.ts | 2 +- {types => typings}/phobos.d.ts | 6 +- .../config.d.ts => typings/plunder.d.ts | 113 +++++++++++++++++- {types => typings}/stores.d.ts | 10 +- {types => typings}/utils.d.ts | 0 {types => typings}/view.d.ts | 2 +- typings/world.d.ts | 57 +++++++++ ui.config.ts | 1 - ui/App.vue | 1 - ui/components/TheLoadingBar.vue | 5 +- ui/components/TheUpdateNotification.vue | 1 - ui/components/WindowMenu.vue | 1 - ui/components/WindowTabs.vue | 7 +- 169 files changed, 299 insertions(+), 511 deletions(-) delete mode 100644 types/electron.d.ts delete mode 100644 types/plunder/group.d.ts delete mode 100644 types/plunder/history.d.ts delete mode 100644 types/plunder/index.d.ts delete mode 100644 types/plunder/info.d.ts delete mode 100644 types/plunder/page.d.ts delete mode 100644 types/world/config.d.ts delete mode 100644 types/world/index.d.ts delete mode 100644 types/world/units.d.ts delete mode 100644 types/world/villages.d.ts rename {types => typings}/config.d.ts (94%) rename {types => typings}/deimos.d.ts (100%) rename {types => typings}/error.d.ts (100%) rename {types => typings}/game.d.ts (100%) rename types/ares.d.ts => typings/index.d.ts (61%) rename {types => typings}/modules.d.ts (92%) rename {types => typings}/phobos.d.ts (78%) rename types/plunder/config.d.ts => typings/plunder.d.ts (53%) rename {types => typings}/stores.d.ts (94%) rename {types => typings}/utils.d.ts (100%) rename {types => typings}/view.d.ts (60%) create mode 100644 typings/world.d.ts diff --git a/browser.config.ts b/browser.config.ts index 99e4c39f..ebaa5e4b 100644 --- a/browser.config.ts +++ b/browser.config.ts @@ -16,7 +16,6 @@ export default defineConfig({ '$modules': fileURLToPath(new URL('./modules', import.meta.url)), '$panel': fileURLToPath(new URL('./panel', import.meta.url)), '$renderer': fileURLToPath(new URL('./renderer', import.meta.url)), - '$types': fileURLToPath(new URL('./types', import.meta.url)), '$ui': fileURLToPath(new URL('./ui', import.meta.url)) } }, diff --git a/browser/components/PlunderReloadMessage.vue b/browser/components/PlunderReloadMessage.vue index 6816bea1..a8726944 100644 --- a/browser/components/PlunderReloadMessage.vue +++ b/browser/components/PlunderReloadMessage.vue @@ -33,7 +33,7 @@ const autoReloadMessage = computed(() => { - \ No newline at end of file diff --git a/browser/lib/plunder/attack.ts b/browser/lib/plunder/attack.ts index 480c1a7b..79349676 100644 --- a/browser/lib/plunder/attack.ts +++ b/browser/lib/plunder/attack.ts @@ -8,7 +8,6 @@ import { unitsRegex } from '$global/regex'; import { ipcSend, ipcInvoke } from '$renderer/ipc'; import { PlunderError } from '$browser/error'; import type { PlunderAttack } from '$global/objects/plunder'; -import type { PlaceUnitsAmount } from '$types/game'; export const eventTarget = new EventTarget(); diff --git a/browser/lib/plunder/data.ts b/browser/lib/plunder/data.ts index e95dfd70..46eda3a4 100644 --- a/browser/lib/plunder/data.ts +++ b/browser/lib/plunder/data.ts @@ -1,7 +1,7 @@ import { Deimos } from '$deimos/interface/ipc'; import { PlunderError } from '$browser/error'; -import { usePlunderStore, usePlunderConfigStore } from '$renderer/stores/plunder'; import { ipcInvoke } from '$renderer/ipc'; +import { usePlunderStore, usePlunderConfigStore } from '$renderer/stores/plunder'; export async function getPlunderInfo() { try { diff --git a/browser/lib/plunder/group.ts b/browser/lib/plunder/group.ts index 4f865043..d14a7bc0 100644 --- a/browser/lib/plunder/group.ts +++ b/browser/lib/plunder/group.ts @@ -1,12 +1,10 @@ -import { ref } from 'vue'; +import { ref, type Ref } from 'vue'; import { until, useStyleTag, useMutationObserver } from '@vueuse/core'; import { isInstanceOf, isInteger } from '$global/guards'; import { ipcInvoke, ipcSend } from '$renderer/ipc'; import { useFeaturesStore } from '$renderer/stores/features'; import { usePlunderConfigStore } from '$renderer/stores/plunder'; import { PlunderError } from '$browser/error'; -import type { Ref } from 'vue'; -import type { PlunderGroupType, PlunderGroupVillageType } from '$types/plunder'; class PlunderGroup implements PlunderGroupType { readonly id: number; diff --git a/browser/lib/plunder/next.ts b/browser/lib/plunder/next.ts index 029d23b2..ad9277a9 100644 --- a/browser/lib/plunder/next.ts +++ b/browser/lib/plunder/next.ts @@ -6,7 +6,6 @@ import { getPlunderTargets } from '$lib/plunder/targets'; import { PlunderError } from '$browser/error'; import { usePlunderConfigStore } from '$renderer/stores/plunder'; import { useCurrentVillageStore } from '$renderer/stores/village'; -import type { PlunderGroupType, PlunderGroupVillageType } from '$types/plunder'; import type { PlunderTargetInfo } from '$lib/plunder/targets'; export async function handleLackOfTargets(groupInfo: PlunderGroupType | null) { diff --git a/browser/lib/plunder/targets.ts b/browser/lib/plunder/targets.ts index 146dcb6a..cae31da1 100644 --- a/browser/lib/plunder/targets.ts +++ b/browser/lib/plunder/targets.ts @@ -7,8 +7,6 @@ import { PlunderError } from '$browser/error'; import { Kronos, resources as resourceList } from '$global/constants'; import { useCurrentVillageStore } from '$renderer/stores/village'; import { assertWallLevel } from '$global/guards'; -import type { Coords, WallLevel } from '$types/game'; -import type { PlunderTableButtons, PlunderTableResources } from '$types/plunder'; /** Informações sobre a aldeia-alvo. */ export class PlunderTargetInfo { diff --git a/browser/lib/plunder/templates.ts b/browser/lib/plunder/templates.ts index 27976f2b..e2121bb0 100644 --- a/browser/lib/plunder/templates.ts +++ b/browser/lib/plunder/templates.ts @@ -7,9 +7,7 @@ import { Kronos } from '$global/constants'; import { PlunderError } from '$browser/error'; import { ipcInvoke } from '$renderer/ipc'; import type { usePlunderConfigStore } from '$renderer/stores/plunder'; -import type { FarmUnits, FarmUnitsAmount, UserAlias } from '$types/game'; import type { PlunderTargetInfo } from '$browser/lib/plunder/targets'; -import type { CustomPlunderTemplateType } from '$types/plunder'; class TemplateUnits implements FarmUnitsAmount { spear = 0; diff --git a/browser/lib/plunder/units.ts b/browser/lib/plunder/units.ts index f7100603..757c684b 100644 --- a/browser/lib/plunder/units.ts +++ b/browser/lib/plunder/units.ts @@ -4,7 +4,6 @@ import { useUnitsStore } from '$renderer/stores/units'; import { assertUnit } from '$global/guards'; import { ipcInvoke } from '$renderer/ipc'; import { PlunderError } from '$browser/error'; -import type { AllUnits } from '$types/game'; /** Atualiza a quantidade de unidades disponíveis no assistente de saque. */ export async function queryAvailableUnits() { diff --git a/browser/lib/plunder/village.ts b/browser/lib/plunder/village.ts index 91bd500b..f17026e3 100644 --- a/browser/lib/plunder/village.ts +++ b/browser/lib/plunder/village.ts @@ -1,7 +1,6 @@ import { useCurrentVillageStore } from '$renderer/stores/village'; import { usePlunderStore } from '$renderer/stores/plunder'; import { ipcSend } from '$renderer/ipc'; -import type { PlunderPageListType, PlunderPageType } from '$types/plunder'; class PlunderPageList implements PlunderPageListType { readonly id: number; diff --git a/browser/lib/plunder/wall.ts b/browser/lib/plunder/wall.ts index a68869b0..2ae695f7 100644 --- a/browser/lib/plunder/wall.ts +++ b/browser/lib/plunder/wall.ts @@ -7,7 +7,6 @@ import { sendAttackFromPlace } from '$lib/plunder/attack'; import { PlunderError } from '$browser/error'; import { PlunderAttackWithLoot } from '$lib/plunder/resources'; import { queryAvailableUnits } from '$lib/plunder/units'; -import type { DemolitionTroops, StringWallLevel } from '$types/game'; import type { PlunderTargetInfo } from '$browser/lib/plunder/targets'; export async function destroyWall(info: PlunderTargetInfo): Promise { diff --git a/browser/stores/browser.ts b/browser/stores/browser.ts index 1827e7ac..6328fa19 100644 --- a/browser/stores/browser.ts +++ b/browser/stores/browser.ts @@ -1,6 +1,5 @@ -import { defineStore } from 'pinia'; import { ref } from 'vue'; -import type { PiniaBrowserStoreType } from '$types/stores'; +import { defineStore } from 'pinia'; export const useBrowserStore = defineStore('browser', () => { const isDeimosReady = ref(false); diff --git a/browser/views/PlunderView.vue b/browser/views/PlunderView.vue index 65b4010c..bd02dfb5 100644 --- a/browser/views/PlunderView.vue +++ b/browser/views/PlunderView.vue @@ -18,7 +18,6 @@ import { PlunderError } from '$browser/error'; import { ipcSend } from '$renderer/ipc'; import { Kronos } from '$global/constants'; import PlunderReload from '$browser/components/PlunderReload.vue'; -import type { PlunderGroupType } from '$types/plunder'; const ares = useAresStore(); const config = usePlunderConfigStore(); diff --git a/deimos/deimos.d.ts b/deimos/deimos.d.ts index 60866699..8a715076 100644 --- a/deimos/deimos.d.ts +++ b/deimos/deimos.d.ts @@ -1,11 +1,3 @@ -import type { ResourceAmount } from '$types/game'; -import type { - RawTribalWarsGameData, - RawPlunderInfo, - MarketDataTrader, - PremiumExchangeGraphResourceData -} from '$types/deimos'; - declare global { const Accountmanager: { readonly farm: RawPlunderInfo @@ -91,4 +83,6 @@ declare global { InfoMessage(message: string): void; SuccessMessage(message: string): void; }; -} \ No newline at end of file +} + +export {}; \ No newline at end of file diff --git a/deimos/interface/ipc.ts b/deimos/interface/ipc.ts index 9d15dfa1..55c951d1 100644 --- a/deimos/interface/ipc.ts +++ b/deimos/interface/ipc.ts @@ -4,7 +4,6 @@ import type { TribalWarsGameData } from '$deimos/models/data'; import type { PlunderInfo } from '$deimos/models/plunder'; import type { Units } from '$deimos/models/units'; import type { TribalWarsTiming } from '$deimos/models/timing'; -import type { UIMessageType } from '$types/deimos'; // Arquivos no diretório "interface" não podem importar de outras partes do Deimos. // Isso é para evitar que a importações dos protótipos feitas no index vazem para o resto do código. diff --git a/deimos/models/data.ts b/deimos/models/data.ts index 488effee..2ff01995 100644 --- a/deimos/models/data.ts +++ b/deimos/models/data.ts @@ -1,7 +1,5 @@ import { isString, isInteger } from '$global/guards'; import { isWorld } from '$global/guards'; -import type { RawTribalWarsGameData } from '$types/deimos'; -import type { TribalWarsGameDataType } from '$types/game'; /** `null` indica que o usuário se encontra numa página a partir da qual não é possível obter essas informações. */ export class TribalWarsGameData implements TribalWarsGameDataType { diff --git a/deimos/models/plunder.ts b/deimos/models/plunder.ts index ebd32071..8991403d 100644 --- a/deimos/models/plunder.ts +++ b/deimos/models/plunder.ts @@ -1,7 +1,5 @@ import { assertInteger, isInteger } from '$global/guards'; import { DeimosModelError } from '$deimos/interface/error'; -import type { RawPlunderInfo } from '$types/deimos'; -import type { PlunderInfoType } from '$types/plunder'; export class PlunderInfo implements PlunderInfoType { public readonly hideAttacked: boolean; diff --git a/deimos/models/timing.ts b/deimos/models/timing.ts index 9c152ab9..bcaf9c83 100644 --- a/deimos/models/timing.ts +++ b/deimos/models/timing.ts @@ -1,6 +1,4 @@ import { assertInteger } from '$global/guards'; -import type { TribalWarsTimingType } from '$types/game'; -import type { RawTiming } from '$types/deimos'; import { DeimosModelError } from '$deimos/interface/error'; export class TribalWarsTiming implements TribalWarsTimingType { diff --git a/deimos/models/units.ts b/deimos/models/units.ts index c7f27e27..798405be 100644 --- a/deimos/models/units.ts +++ b/deimos/models/units.ts @@ -1,5 +1,4 @@ import { assertString, isString } from '$global/guards'; -import type { UnitAmount, UnitsAmountAsStrings } from '$types/game'; interface MaybeNotArcherWorld extends Omit { archer?: string; diff --git a/deimos/tsconfig.json b/deimos/tsconfig.json index 97e29b57..c60c6bc7 100644 --- a/deimos/tsconfig.json +++ b/deimos/tsconfig.json @@ -3,7 +3,7 @@ "./**/*", "../global/**/*", "../renderer/**/*", - "../types/**/*" + "../typings/**/*" ], "compilerOptions": { @@ -17,8 +17,7 @@ "$modules/*": ["../modules/*"], "$panel/*": ["../panel/*"], "$phobos/*": ["../phobos/*"], - "$renderer/*": ["../renderer/*"], - "$types/*": ["../types/*"] + "$renderer/*": ["../renderer/*"] }, "alwaysStrict": true, diff --git a/electron/app/modules/standard.ts b/electron/app/modules/standard.ts index bb47a360..3798e093 100644 --- a/electron/app/modules/standard.ts +++ b/electron/app/modules/standard.ts @@ -1,10 +1,9 @@ -import { BrowserWindow, type BrowserWindowConstructorOptions } from 'electron'; +import { BrowserWindow } from 'electron'; import { isInstanceOf } from '$global/guards'; import { appIcon, moduleHtml } from '$electron/utils/files'; import { getMainWindow } from '$electron/utils/helpers'; import { ModuleCreationError } from '$electron/error'; import { setModuleDevMenu } from '$electron/menu/dev'; -import type { ModuleNames, ModuleRoutes, ModuleConstructorOptions } from '$types/modules'; const activeModules = new Map(); export const getActiveModule = (name: ModuleNames) => activeModules.get(name) ?? null; @@ -33,7 +32,7 @@ export function createModule( return; }; - const windowOptions: BrowserWindowConstructorOptions = { + const windowOptions: Electron.BrowserWindowConstructorOptions = { parent: mainWindow, width: 500, height: 600, diff --git a/electron/app/modules/website.ts b/electron/app/modules/website.ts index d8865c4b..0acb3230 100644 --- a/electron/app/modules/website.ts +++ b/electron/app/modules/website.ts @@ -5,7 +5,6 @@ import { getMainWindow } from '$electron/utils/helpers'; import { isAllowedOrigin } from '$global/guards'; import { ModuleCreationError } from '$electron/error'; import { setModuleDevMenu } from '$electron/menu/dev'; -import type { WebsiteModuleNames } from '$types/modules'; const activeWebsiteModules = new Map(); export const getActiveWebsiteModule = (name: WebsiteModuleNames) => activeWebsiteModules.get(name) ?? null; diff --git a/electron/app/phobos.ts b/electron/app/phobos.ts index dc1bdc38..5f196376 100644 --- a/electron/app/phobos.ts +++ b/electron/app/phobos.ts @@ -3,8 +3,6 @@ import { BrowserView } from 'electron'; import { assertString, assertInstanceOf, isInstanceOf } from '$global/guards'; import { getMainWindow } from '$electron/utils/helpers'; import { phobosJs } from '$electron/utils/files'; -import type { WebPreferences } from 'electron'; -import type { PhobosNames, PhobosOptions } from '$types/phobos'; const activePhobos = new Map(); @@ -39,7 +37,7 @@ export async function createPhobos(name: PhobosNames, url: URL, options?: Phobos }; }; - const webPreferences: WebPreferences = options?.webPreferences ?? {}; + const webPreferences: Electron.WebPreferences = options?.webPreferences ?? {}; webPreferences.preload = phobosJs; webPreferences.devTools = process.env.ARES_MODE === 'dev'; diff --git a/electron/child-process/error.ts b/electron/child-process/error.ts index 50216609..1869bcf9 100644 --- a/electron/child-process/error.ts +++ b/electron/child-process/error.ts @@ -3,7 +3,6 @@ import * as fs from 'node:fs/promises'; import { AresError } from '$global/error'; import { isString } from '$global/guards'; import { ErrorLogFile } from '$global/constants'; -import type { ElectronErrorLogType, OmitOptionalErrorLogProps } from '$types/error'; export class ChildProcessError extends AresError { constructor(message: string) { @@ -11,7 +10,7 @@ export class ChildProcessError extends AresError { this.name = 'ChildProcessError'; }; - public static override async catch(err: unknown) { + public static override async catch(err: unknown): Promise { if (!process.env.USER_DATA_PATH) return; if (err instanceof Error) { diff --git a/electron/child-process/world-data.ts b/electron/child-process/world-data.ts index d838a046..0f4faa44 100644 --- a/electron/child-process/world-data.ts +++ b/electron/child-process/world-data.ts @@ -6,8 +6,6 @@ import { Readable } from 'node:stream'; import { assertWorld } from '$global/guards'; import { getRegionFromWorld, getVillagesDataUrl } from '$global/helpers'; import { ChildProcessError } from '$electron/child-process/error'; -import type { World, GameRegion } from '$types/game'; -import type { WorldDataType, WorldVillagesType } from '$types/world'; const gunzip = promisify(zlib.gunzip); diff --git a/electron/database/config/config.ts b/electron/database/config/config.ts index 27febe0b..813265b9 100644 --- a/electron/database/config/config.ts +++ b/electron/database/config/config.ts @@ -1,7 +1,6 @@ import { sequelize } from '$electron/database'; import { DatabaseError } from '$electron/error'; import type { AppConfig as AppConfigTable } from '$database/config'; -import type { AppConfigName, AppConfigByName } from '$types/config'; import type { useAppGeneralConfigStore, useAppNotificationsStore } from '$electron/interface'; type OnlyConfig = Extract; diff --git a/electron/database/config/index.ts b/electron/database/config/index.ts index 0d8130e3..4bd5ce08 100644 --- a/electron/database/config/index.ts +++ b/electron/database/config/index.ts @@ -4,7 +4,6 @@ import { saveConfig, setConfig } from '$database/config/config'; import { savePanelBounds, setPanelBounds } from '$database/config/panel'; import { getLastRegionGameUrl, setGameRegion, saveGameRegion } from '$database/config/state'; import type { InferAttributes, InferCreationAttributes } from 'sequelize'; -import type { AppConfigName, AppConfigJSON } from '$types/config'; /** Diz respeito a configurações que abrangem toda a aplicação, independentemente do usuário. */ export class AppConfig extends Model, InferCreationAttributes> { diff --git a/electron/database/config/panel.ts b/electron/database/config/panel.ts index 621d8330..1aa2107e 100644 --- a/electron/database/config/panel.ts +++ b/electron/database/config/panel.ts @@ -1,7 +1,6 @@ import { sequelize } from '$electron/database'; import { DatabaseError } from '$electron/error'; import { getPanelWindow } from '$electron/utils/helpers'; -import type { Rectangle } from 'electron'; import type { AppConfig as AppConfigTable } from '$database/config'; export function setPanelBounds(AppConfig: typeof AppConfigTable) { @@ -10,7 +9,7 @@ export function setPanelBounds(AppConfig: typeof AppConfigTable) { const panelWindow = getPanelWindow(); const bounds = (await AppConfig.findByPk('panel_bounds'))?.toJSON(); if (!bounds?.json) return; - panelWindow.setBounds(bounds.json as Rectangle); + panelWindow.setBounds(bounds.json as Electron.Rectangle); } catch (err) { DatabaseError.catch(err); @@ -19,7 +18,7 @@ export function setPanelBounds(AppConfig: typeof AppConfigTable) { }; export function savePanelBounds(AppConfig: typeof AppConfigTable) { - return async function(rectangle: Rectangle) { + return async function(rectangle: Electron.Rectangle) { try { await sequelize.transaction(async (transaction) => { await AppConfig.upsert({ name: 'panel_bounds', json: rectangle }, { transaction }); diff --git a/electron/database/config/state.ts b/electron/database/config/state.ts index 669538c3..311e7445 100644 --- a/electron/database/config/state.ts +++ b/electron/database/config/state.ts @@ -5,8 +5,6 @@ import { getGameRegionUrl } from '$global/helpers'; import { isGameRegion } from '$global/guards'; import type { AppConfig as AppConfigTable } from '$database/config'; import type { useCacheStore } from '$electron/interface'; -import type { AppStateType } from '$types/config'; -import type { GameRegion } from '$types/game'; export function getLastRegionGameUrl(AppConfig: typeof AppConfigTable) { return async function() { diff --git a/electron/database/error.ts b/electron/database/error.ts index a57c18df..6d1fe7d6 100644 --- a/electron/database/error.ts +++ b/electron/database/error.ts @@ -1,8 +1,6 @@ import { DataTypes, Model } from 'sequelize'; import { sequelize } from '$electron/database'; import type { InferAttributes, InferCreationAttributes, CreationOptional } from 'sequelize'; -import type { ErrorLogType, ElectronErrorLogType } from '$types/error'; -import type { World } from '$types/game'; export class ErrorLog extends Model, InferCreationAttributes> implements ErrorLogType { declare readonly id: CreationOptional; diff --git a/electron/database/groups.ts b/electron/database/groups.ts index cc6a7715..0e3ade47 100644 --- a/electron/database/groups.ts +++ b/electron/database/groups.ts @@ -2,7 +2,6 @@ import { DataTypes, Model } from 'sequelize'; import { sequelize } from '$electron/database'; import { assertUserAlias } from '$global/guards'; import { DatabaseError } from '$electron/error'; -import type { UserAlias, VillageGroup, VillageGroupsType } from '$types/game'; import type { InferAttributes, InferCreationAttributes } from 'sequelize'; export class VillageGroups extends Model, InferCreationAttributes> implements VillageGroupsType { diff --git a/electron/database/plunder/config.ts b/electron/database/plunder/config.ts index 2b92e401..5e66a1aa 100644 --- a/electron/database/plunder/config.ts +++ b/electron/database/plunder/config.ts @@ -3,8 +3,6 @@ import { sequelize } from '$electron/database'; import { assertUserAlias, assertWallLevel } from '$global/guards'; import { DatabaseError } from '$electron/error'; import type { InferAttributes, InferCreationAttributes } from 'sequelize'; -import type { UserAlias, WallLevel } from '$types/game'; -import type { PlunderConfigType, BlindAttackPattern, UseCPattern } from '$types/plunder'; export class PlunderConfig extends Model, InferCreationAttributes> implements PlunderConfigType { declare readonly id: UserAlias; diff --git a/electron/database/plunder/demolition.ts b/electron/database/plunder/demolition.ts index 6468dde8..b6555866 100644 --- a/electron/database/plunder/demolition.ts +++ b/electron/database/plunder/demolition.ts @@ -4,8 +4,6 @@ import { assertUserAlias } from '$global/guards'; import { DatabaseError } from '$electron/error'; import { unitsToDestroyWall } from '$global/constants'; import type { InferAttributes, InferCreationAttributes, CreationOptional } from 'sequelize'; -import type { UnitsToDestroyWall, UserAlias } from '$types/game'; -import type { DemolitionTemplateType } from '$types/plunder'; export class DemolitionTemplate extends Model< InferAttributes, diff --git a/electron/database/plunder/history.ts b/electron/database/plunder/history.ts index c9f50f52..9f6ac971 100644 --- a/electron/database/plunder/history.ts +++ b/electron/database/plunder/history.ts @@ -3,8 +3,6 @@ import { sequelize } from '$electron/database'; import { assertUserAlias } from '$global/guards'; import { DatabaseError } from '$electron/error'; import type { CreationOptional, InferAttributes, InferCreationAttributes } from 'sequelize'; -import type { UserAlias } from '$types/game'; -import type { PlunderHistoryType } from '$types/plunder'; import type { usePlunderHistoryStore } from '$electron/interface'; export class PlunderHistory extends Model, InferCreationAttributes> implements PlunderHistoryType { diff --git a/electron/database/plunder/template.ts b/electron/database/plunder/template.ts index 59b22e81..9cd1ad2e 100644 --- a/electron/database/plunder/template.ts +++ b/electron/database/plunder/template.ts @@ -4,8 +4,6 @@ import { sequelize } from '$electron/database'; import { assertUserAlias } from '$global/guards'; import { DatabaseError } from '$electron/error'; import type { InferAttributes, InferCreationAttributes, CreationOptional } from 'sequelize'; -import type { UserAlias } from '$types/game'; -import type { CustomPlunderTemplateType } from '$types/plunder'; export class CustomPlunderTemplate extends Model< InferAttributes, diff --git a/electron/database/world/config.ts b/electron/database/world/config.ts index df423621..f53d91c9 100644 --- a/electron/database/world/config.ts +++ b/electron/database/world/config.ts @@ -1,8 +1,6 @@ import { DataTypes, Model } from 'sequelize'; import { sequelize } from '$electron/database'; import type { InferAttributes, InferCreationAttributes } from 'sequelize'; -import type { WorldConfigType } from '$types/world'; -import type { World } from '$types/game'; export class WorldConfig extends Model, InferCreationAttributes> implements WorldConfigType { declare readonly id: World; diff --git a/electron/database/world/history.ts b/electron/database/world/history.ts index f2ae6cc0..de9c7aa7 100644 --- a/electron/database/world/history.ts +++ b/electron/database/world/history.ts @@ -3,8 +3,6 @@ import { sequelize } from '$electron/database'; import { DatabaseError } from '$electron/error'; import { assertWorld } from '$global/guards'; import type { InferAttributes, InferCreationAttributes } from 'sequelize'; -import type { World } from '$types/game'; -import type { WorldDataFetchHistoryType } from '$types/world'; export class WorldDataFetchHistory extends Model< InferAttributes, diff --git a/electron/database/world/units.ts b/electron/database/world/units.ts index 13b617d5..d2c832dc 100644 --- a/electron/database/world/units.ts +++ b/electron/database/world/units.ts @@ -1,8 +1,6 @@ import { DataTypes, Model } from 'sequelize'; import { sequelize } from '$electron/database'; import type { InferAttributes, InferCreationAttributes } from 'sequelize'; -import type { WorldUnitsType, UnitDetails } from '$types/world'; -import type { World } from '$types/game'; export class WorldUnits extends Model, InferCreationAttributes> implements WorldUnitsType { declare readonly id: World; diff --git a/electron/database/world/villages.ts b/electron/database/world/villages.ts index cf694204..e40f4c88 100644 --- a/electron/database/world/villages.ts +++ b/electron/database/world/villages.ts @@ -1,8 +1,6 @@ import { DataTypes, Model } from 'sequelize'; import { sequelize } from '$electron/database'; import type { InferAttributes, InferCreationAttributes } from 'sequelize'; -import type { World } from '$types/game'; -import type { WorldVillagesModel } from '$types/world'; const worldVillagesTableMap = new Map>(); diff --git a/electron/error.ts b/electron/error.ts index 601b0c76..7f63c55f 100644 --- a/electron/error.ts +++ b/electron/error.ts @@ -4,7 +4,6 @@ import { app } from 'electron'; import { AresError } from '$global/error'; import { isString } from '$global/guards'; import { ErrorLogFile } from '$global/constants'; -import type { ElectronErrorLogType, OmitOptionalErrorLogProps } from '$types/error'; export class MainProcessError extends AresError { constructor(message: string) { diff --git a/electron/events/config.ts b/electron/events/config.ts index 1138acfd..26520384 100644 --- a/electron/events/config.ts +++ b/electron/events/config.ts @@ -6,8 +6,6 @@ import { AppConfig, useAppGeneralConfigStore, useAppNotificationsStore } from '$ import { MainProcessEventError } from '$electron/error'; import { database } from '$electron/utils/files'; import { restartAres } from '$electron/utils/helpers'; -import type { ConfigModuleRoutes } from '$types/modules'; -import type { GeneralConfigType, NotificationsConfigType } from '$types/config'; export function setConfigEvents() { const appGeneralConfigStore = useAppGeneralConfigStore(); diff --git a/electron/events/deimos.ts b/electron/events/deimos.ts index 2a9a3943..7c3940c2 100644 --- a/electron/events/deimos.ts +++ b/electron/events/deimos.ts @@ -2,10 +2,6 @@ import { ipcMain } from 'electron'; import { readDeimosFile } from '$electron/app/deimos'; import { getPanelWindow } from '$electron/utils/helpers'; import { MainProcessEventError } from '$electron/error'; -import type { IpcMainEvent } from 'electron'; -import type { MechanusStore } from 'mechanus'; -import type { PlunderInfoType } from '$types/plunder'; -import type { UnitAmount, TribalWarsGameDataType, World } from '$types/game'; import { useAresStore, @@ -42,7 +38,9 @@ export function setDeimosEvents() { }); // Recebe os dados do jogo, salva-os localmente e então envia-os ao painel. - ipcMain.on('deimos:update-game-data', (_e: IpcMainEvent, gameData: TribalWarsGameDataType) => { + ipcMain.on('deimos:update-game-data', ( + _e: Electron.IpcMainEvent, gameData: TribalWarsGameDataType + ) => { try { for (const key of Object.keys(gameData) as T[]) { switch (key) { @@ -76,7 +74,7 @@ export function setDeimosEvents() { // Recebe as informações referentes ao assistente de saque, salva-as localmente e então envia-as ao painel. ipcMain.handle('deimos:update-plunder-info', ( - _e: IpcMainEvent, plunderInfo: PlunderInfoType + _e: Electron.IpcMainEvent, plunderInfo: PlunderInfoType ) => { try { for (const [key, value] of Object.entries(plunderInfo) as [T, typeof plunderStore[T]][]) { @@ -95,7 +93,7 @@ export function setDeimosEvents() { // Recebe as informações referentes às unidades da aldeia atual, salva-as localmente e então envia-as ao painel. ipcMain.handle('deimos:update-current-village-units', ( - _e: IpcMainEvent, units: UnitAmount + _e: Electron.IpcMainEvent, units: UnitAmount ) => { try { for (const [key, value] of Object.entries(units) as [T, typeof unitsStore[T]][]) { diff --git a/electron/events/dev.ts b/electron/events/dev.ts index 0e2467d1..193bf9d2 100644 --- a/electron/events/dev.ts +++ b/electron/events/dev.ts @@ -3,7 +3,6 @@ import { computed, storeToRefs } from 'mechanus'; import { getMainWindow, getPanelWindow } from '$electron/utils/helpers'; import { getMainViewWebContents } from '$electron/utils/view'; import { useBrowserViewStore } from '$electron/interface'; -import type { WebContents } from 'electron'; export function setDevEvents() { if (process.env.ARES_MODE !== 'dev') return; @@ -13,7 +12,7 @@ export function setDevEvents() { const { webContents: panelContents } = getPanelWindow(); const { currentWebContents: currentWebContentsMaybeNull } = storeToRefs(browserViewStore); - const contents = computed([currentWebContentsMaybeNull], () => { + const contents = computed([currentWebContentsMaybeNull], () => { return currentWebContentsMaybeNull.value ?? getMainViewWebContents(); }); diff --git a/electron/events/error.ts b/electron/events/error.ts index c77813f2..63bf4493 100644 --- a/electron/events/error.ts +++ b/electron/events/error.ts @@ -9,7 +9,6 @@ import { getActiveModule } from '$electron/app/modules'; import { ErrorLog, ElectronErrorLog, useAresStore } from '$electron/interface'; import { getMainWindow } from '$electron/utils/helpers'; import { ErrorLogFile } from '$global/constants'; -import type { AllErrorLogTypes, ErrorLogBase, ErrorLogType, OmitOptionalErrorLogProps } from '$types/error'; export function setErrorEvents() { const mainWindow = getMainWindow(); diff --git a/electron/events/index.ts b/electron/events/index.ts index 45b97e8f..1132a761 100644 --- a/electron/events/index.ts +++ b/electron/events/index.ts @@ -16,8 +16,6 @@ import { openAnyAllowedWebsite, openAresWebsite, openIssuesWebsite, openRepoWebs import { useCacheStore, useWorldConfigStore, worldUnitsMap } from '$electron/interface'; import { getPlayerNameFromAlias, extractWorldUnitsFromMap, getMainWindow } from '$electron/utils/helpers'; import { MainProcessEventError } from '$electron/error'; -import type { UserAlias } from '$types/game'; -import type { ElectronMessageBoxOptions } from '$types/electron'; export function setEvents() { const mainWindow = getMainWindow(); diff --git a/electron/events/modules/update.ts b/electron/events/modules/update.ts index 079cd7c5..14936d37 100644 --- a/electron/events/modules/update.ts +++ b/electron/events/modules/update.ts @@ -4,7 +4,6 @@ import semverValid from 'semver/functions/valid'; import { MainProcessEventError } from '$electron/error'; import { AppConfig } from '$electron/interface'; import { showAppUpdate } from '$electron/app/modules'; -import type { UpdateConfigType } from '$types/config'; export function setAppUpdateModuleEvents() { ipcMain.on('open-app-update-window', () => showAppUpdate()); diff --git a/electron/events/plunder/config.ts b/electron/events/plunder/config.ts index 47adbd48..2037a627 100644 --- a/electron/events/plunder/config.ts +++ b/electron/events/plunder/config.ts @@ -3,7 +3,6 @@ import { sequelize } from '$electron/database'; import { MainProcessEventError } from '$electron/error'; import { useCacheStore, usePlunderConfigStore, PlunderConfig } from '$electron/interface'; import { isUserAlias, assertUserAlias } from '$global/guards'; -import type { IpcMainEvent } from 'electron'; export function setPlunderConfigEvents() { const cacheStore = useCacheStore(); @@ -21,7 +20,7 @@ export function setPlunderConfigEvents() { // Recebe as configurações do Plunder do painel ou do módulo de configuração e as salva no banco de dados. ipcMain.on('plunder:update-config', async ( - e: IpcMainEvent, key: T, value: typeof plunderConfigStore[T] + e: Electron.IpcMainEvent, key: T, value: typeof plunderConfigStore[T] ) => { try { if (!(key in plunderConfigStore)) return; diff --git a/electron/events/plunder/demolition.ts b/electron/events/plunder/demolition.ts index e73c4421..ae6485d2 100644 --- a/electron/events/plunder/demolition.ts +++ b/electron/events/plunder/demolition.ts @@ -3,8 +3,6 @@ import { storeToRefs } from 'mechanus'; import { showDemolitionConfig } from '$electron/app/modules'; import { isUserAlias } from '$global/guards'; import { useCacheStore, usePlunderCacheStore, DemolitionTemplate } from '$electron/interface'; -import type { UserAlias } from '$types/game'; -import type { DemolitionTemplateType } from '$types/plunder'; export function setPlunderDemolitionEvents() { const cacheStore = useCacheStore(); diff --git a/electron/events/plunder/group.ts b/electron/events/plunder/group.ts index 6104d8f8..dadbe18e 100644 --- a/electron/events/plunder/group.ts +++ b/electron/events/plunder/group.ts @@ -5,7 +5,6 @@ import { MainProcessEventError } from '$electron/error'; import { GameSearchParams } from '$global/constants'; import { generateRandomDelay } from '$global/helpers'; import { usePlunderConfigStore, usePlunderCacheStore } from '$electron/interface'; -import type { PlunderGroupType, PlunderGroupVillageType } from '$types/plunder'; export function setPlunderGroupEvents() { const plunderCacheStore = usePlunderCacheStore(); diff --git a/electron/events/plunder/history.ts b/electron/events/plunder/history.ts index e5582df8..14019edd 100644 --- a/electron/events/plunder/history.ts +++ b/electron/events/plunder/history.ts @@ -6,7 +6,6 @@ import { getPanelWindow } from '$electron/utils/helpers'; import { showPlunderHistory, getActiveModuleWebContents } from '$electron/app/modules'; import { usePlunderHistoryStore, PlunderHistory, useCacheStore } from '$electron/interface'; import { PlunderHistoryVillage } from '$global/objects/plunder'; -import type { PlunderAttackLog, PlunderHistoryType } from '$types/plunder'; export function setPlunderHistoryEvents() { const panelWindow = getPanelWindow(); diff --git a/electron/events/plunder/index.ts b/electron/events/plunder/index.ts index 8a0e9ee4..195af340 100644 --- a/electron/events/plunder/index.ts +++ b/electron/events/plunder/index.ts @@ -10,8 +10,6 @@ import { setPlunderConfigEvents } from '$electron/events/plunder/config'; import { setPlunderHistoryEvents } from '$electron/events/plunder/history'; import { setPlunderDemolitionEvents } from '$electron/events/plunder/demolition'; import { setPlunderTemplatesEvents } from '$electron/events/plunder/templates'; -import type { UnitAmount, World } from '$types/game'; -import type { WorldUnitsType } from '$types/world'; export function setPlunderEvents() { const cacheStore = useCacheStore(); diff --git a/electron/events/plunder/page.ts b/electron/events/plunder/page.ts index 803b9c1a..1db040e5 100644 --- a/electron/events/plunder/page.ts +++ b/electron/events/plunder/page.ts @@ -4,7 +4,6 @@ import { MainProcessEventError } from '$electron/error'; import { usePlunderStore, usePlunderConfigStore, usePlunderCacheStore } from '$electron/interface'; import { GameSearchParams } from '$global/constants'; import { generateRandomDelay } from '$global/helpers'; -import type { PlunderPageListType } from '$types/plunder'; export function setPlunderPageEvents() { const plunderStore = usePlunderStore(); diff --git a/electron/events/plunder/templates.ts b/electron/events/plunder/templates.ts index 30039440..fd7e87d9 100644 --- a/electron/events/plunder/templates.ts +++ b/electron/events/plunder/templates.ts @@ -3,8 +3,6 @@ import { storeToRefs } from 'mechanus'; import { showCustomPlunderTemplate } from '$electron/app/modules'; import { isUserAlias } from '$global/guards'; import { useCacheStore, useBrowserViewStore, CustomPlunderTemplate } from '$electron/interface'; -import type { UserAlias } from '$types/game'; -import type { CustomPlunderTemplateType } from '$types/plunder'; export function setPlunderTemplatesEvents() { const cacheStore = useCacheStore(); diff --git a/electron/events/ui/download.ts b/electron/events/ui/download.ts index 63b6b1e1..4760dfa9 100644 --- a/electron/events/ui/download.ts +++ b/electron/events/ui/download.ts @@ -4,14 +4,12 @@ import { isString } from '$global/guards'; import { getMainWindow } from '$electron/utils/helpers'; import { getActiveModuleWebContents } from '$electron/app/modules'; import { DownloadError } from '$electron/error'; -import type { DownloadItem } from 'electron'; -import type { DownloadProgressType } from '$types/ares'; class DownloadProgress implements DownloadProgressType { readonly receivedBytes: number; readonly totalBytes: number; - constructor(item: DownloadItem) { + constructor(item: Electron.DownloadItem) { this.receivedBytes = item.getReceivedBytes(); this.totalBytes = item.getTotalBytes(); }; @@ -29,7 +27,7 @@ export function setMainWindowDownloadEvents() { }); }; -function handleUpdateDownload(item: DownloadItem) { +function handleUpdateDownload(item: Electron.DownloadItem) { const updateContents = getActiveModuleWebContents('app-update'); if (updateContents) { updateContents.send('will-download-update', new DownloadProgress(item)); diff --git a/electron/events/ui/menu.ts b/electron/events/ui/menu.ts index c6059ea5..ba3359e1 100644 --- a/electron/events/ui/menu.ts +++ b/electron/events/ui/menu.ts @@ -6,9 +6,6 @@ import { showErrorLog, openIssuesWebsite } from '$electron/app/modules'; import { AppConfig, useCacheStore } from '$electron/interface'; import { MainProcessError } from '$electron/error'; import { getGameRegionUrl } from '$global/helpers'; -import type { MenuItemConstructorOptions } from 'electron'; -import type { MechanusRef } from 'mechanus'; -import type { GameRegion } from '$types/game'; export function setMenuEvents() { const mainWindow = getMainWindow(); @@ -19,7 +16,7 @@ export function setMenuEvents() { AppConfig.setGameRegion(cacheStore).catch(MainProcessError.catch); ipcMain.on('open-region-select-menu', () => { - const template: MenuItemConstructorOptions[] = [ + const template: Electron.MenuItemConstructorOptions[] = [ { label: 'tribalwars.com.br', type: 'radio', click: () => void setGameRegion('br', region) } ]; @@ -39,7 +36,7 @@ export function setMenuEvents() { }); ipcMain.on('open-bug-report-menu', () => { - const template: MenuItemConstructorOptions[] = [ + const template: Electron.MenuItemConstructorOptions[] = [ { label: 'Registro de erros', click: () => showErrorLog() }, { label: 'Problemas conhecidos', click: () => openIssuesWebsite() } ]; @@ -49,7 +46,7 @@ export function setMenuEvents() { }); }; -function setCheckedGameRegion(template: MenuItemConstructorOptions[], region: GameRegion) { +function setCheckedGameRegion(template: Electron.MenuItemConstructorOptions[], region: GameRegion) { template.forEach((item) => { if (item.label?.endsWith(region) || (region === 'en' && item.label?.endsWith('net'))) { item.checked = true; diff --git a/electron/events/view.ts b/electron/events/view.ts index 4fcf27dd..f52470a2 100644 --- a/electron/events/view.ts +++ b/electron/events/view.ts @@ -5,8 +5,6 @@ import { useBrowserViewStore, useCacheStore } from '$electron/interface'; import { isAllowedOrigin } from '$global/guards'; import { getMainWindow } from '$electron/utils/helpers'; import { BrowserViewError } from '$electron/error'; -import type { WebContents, BrowserWindow } from 'electron'; -import type { MechanusRef } from 'mechanus'; import { insertViewCSS, @@ -101,8 +99,8 @@ export function setBrowserViewEvents() { * Esses eventos devem ser removidos quando a BrowserView for destruída. */ function setViewSharedEvents( - mainWindow: BrowserWindow = getMainWindow(), - mainViewWebContents: WebContents = getMainViewWebContents() + mainWindow: Electron.BrowserWindow = getMainWindow(), + mainViewWebContents: Electron.WebContents = getMainViewWebContents() ) { const browserViewStore = useBrowserViewStore(); const { allWebContents, registeredWebContents } = storeToRefs(browserViewStore); @@ -134,7 +132,7 @@ function setViewSharedEvents( * Se um novo evento for adicionado, é preciso adicionar a remoção dele na função `removePreviousViewEvents`. * @param view WebContents da BrowserView atual. */ -function setCurrentViewEvents(view: WebContents, mainWindow: BrowserWindow = getMainWindow()) { +function setCurrentViewEvents(view: Electron.WebContents, mainWindow: Electron.BrowserWindow = getMainWindow()) { view.on('did-start-loading', () => { mainWindow.webContents.send('current-view-did-start-loading'); }); @@ -168,7 +166,7 @@ function setCurrentViewEvents(view: WebContents, mainWindow: BrowserWindow = get * Esses eventos são definidos na função `setCurrentViewEvents`. * @param view WebContents da BrowserView atual. */ -function removePreviousViewEvents(view: WebContents) { +function removePreviousViewEvents(view: Electron.WebContents) { view.removeAllListeners('did-start-loading'); view.removeAllListeners('did-stop-loading'); view.removeAllListeners('did-navigate'); @@ -183,7 +181,7 @@ function removePreviousViewEvents(view: WebContents) { * @param rawUrl URL da nova BrowserView. * @returns BrowserView criada ou `null` se algo impedir a criação. */ -async function createBrowserView(rawUrl: string, mainWindow: BrowserWindow = getMainWindow()) { +async function createBrowserView(rawUrl: string, mainWindow: Electron.BrowserWindow = getMainWindow()) { try { mainWindow.webContents.send('browser-view-will-be-created'); const browserView = new BrowserView({ @@ -225,8 +223,8 @@ async function createBrowserView(rawUrl: string, mainWindow: BrowserWindow = get function destroyBrowserView( view: BrowserView, - mainWindow: BrowserWindow = getMainWindow(), - mainViewWebContents: WebContents = getMainViewWebContents() + mainWindow: Electron.BrowserWindow = getMainWindow(), + mainViewWebContents: Electron.WebContents = getMainViewWebContents() ) { try { const browserViewStore = useBrowserViewStore(); @@ -260,7 +258,7 @@ function destroyBrowserView( * @param view WebContents da BrowserView atual. * @param mainWindow Janela principal. */ -function updateCurrentViewBackForwardStatus(view: WebContents, mainWindow: BrowserWindow = getMainWindow()) { +function updateCurrentViewBackForwardStatus(view: Electron.WebContents, mainWindow: Electron.BrowserWindow = getMainWindow()) { const backForwardStatus = getBackForwardStatus(view); mainWindow.webContents.send('current-view-back-forward-status', backForwardStatus); }; @@ -271,14 +269,16 @@ function updateCurrentViewBackForwardStatus(view: WebContents, mainWindow: Brows * Uma nova BrowserView será criada se a URL for permitida. * @param contents WebContents da BrowserView. */ -function setWindowOpenHandler(contents: WebContents) { +function setWindowOpenHandler(contents: Electron.WebContents) { contents.setWindowOpenHandler(({ url }) => { queueMicrotask(() => createBrowserView(url)); return { action: 'deny' }; }); }; -function findBrowserViewByWebContentsId(webContentsId: number, mainWindow: BrowserWindow = getMainWindow()) { +function findBrowserViewByWebContentsId( + webContentsId: number, mainWindow: Electron.BrowserWindow = getMainWindow() +): Electron.BrowserView { const browserViews = mainWindow.getBrowserViews(); const browserView = browserViews.find((view) => view.webContents.id === webContentsId); if (browserView) return browserView; @@ -292,10 +292,10 @@ function findBrowserViewByWebContentsId(webContentsId: number, mainWindow: Brows * @param mainWindow Janela principal. */ function setViewAsTopBrowserView( - view: BrowserView, + view: Electron.BrowserView, currentAutoResize: MechanusRef<(() => void) | null>, - mainWindow: BrowserWindow = getMainWindow() -) { + mainWindow: Electron.BrowserWindow = getMainWindow() +): void { mainWindow.webContents.send('browser-view-will-be-set-as-top', view.webContents.id); mainWindow.setTopBrowserView(view); setBrowserViewBounds(view); @@ -310,10 +310,10 @@ function setViewAsTopBrowserView( * @param mainWindow Janela principal. */ function hideBrowserView( - view: BrowserView, + view: Electron.BrowserView, currentAutoResize: MechanusRef<(() => void) | null>, - mainWindow: BrowserWindow = getMainWindow() -) { + mainWindow: Electron.BrowserWindow = getMainWindow() +): void { mainWindow.webContents.send('browser-view-will-be-hidden', view.webContents.id); view.setBounds({ x: 0, y: 0, width: 0, height: 0 }); if (typeof currentAutoResize.value === 'function') { diff --git a/electron/events/world-data.ts b/electron/events/world-data.ts index 2a1438bd..fa5928e3 100644 --- a/electron/events/world-data.ts +++ b/electron/events/world-data.ts @@ -2,7 +2,6 @@ import { Op } from 'sequelize'; import { ipcMain } from 'electron'; import { getWorldVillagesTable, useCacheStore } from '$electron/interface'; import { isWorld } from '$global/guards'; -import type { World } from '$types/game'; export function setWorldDataEvents() { const cacheStore = useCacheStore(); diff --git a/electron/interface/alias.ts b/electron/interface/alias.ts index f700c788..d7414422 100644 --- a/electron/interface/alias.ts +++ b/electron/interface/alias.ts @@ -5,8 +5,6 @@ import { Kronos } from '$global/constants'; import { fetchVillageGroups, patchVillageGroups } from '$electron/utils/groups'; import { AliasInterfaceError } from '$electron/error'; import { sequelize } from '$electron/database'; -import type { UserAlias } from '$types/game'; -import type { PlunderConfigType, PlunderHistoryType, PlunderHistoryVillageType } from '$types/plunder'; import type { PlunderConfig as PlunderConfigTable, PlunderHistory as PlunderHistoryTable } from '$database/plunder'; import type { VillageGroups as VillageGroupsTable } from '$database/groups'; diff --git a/electron/interface/error.ts b/electron/interface/error.ts index bf89eada..1ef596cc 100644 --- a/electron/interface/error.ts +++ b/electron/interface/error.ts @@ -5,7 +5,6 @@ import { sequelize } from '$electron/database'; import { getActiveModule } from '$electron/app/modules'; import { getMainWindow } from '$electron/utils/helpers'; import { MainProcessError } from '$electron/error'; -import type { ElectronErrorLogType, OmitOptionalErrorLogProps } from '$types/error'; import type { useAppNotificationsStore } from '$electron/interface'; import type { ElectronErrorLog as ElectronErrorLogTable } from '$electron/interface'; diff --git a/electron/interface/world/config.ts b/electron/interface/world/config.ts index 06862647..4b52ddb7 100644 --- a/electron/interface/world/config.ts +++ b/electron/interface/world/config.ts @@ -3,9 +3,6 @@ import { WorldInterfaceError } from '$electron/error'; import { createPhobos, destroyPhobos } from '$electron/app/phobos'; import { getWorldConfigUrl } from '$global/helpers'; import { sequelize } from '$electron/database'; -import type { WorldConfigType } from '$types/world'; -import type { PhobosPortMessage } from '$types/phobos'; -import type { World } from '$types/game'; import type { WorldConfig as WorldConfigTable, useCacheStore as useCacheStoreType, diff --git a/electron/interface/world/data.ts b/electron/interface/world/data.ts index df27ae44..d163578f 100644 --- a/electron/interface/world/data.ts +++ b/electron/interface/world/data.ts @@ -3,8 +3,6 @@ import { sequelize } from '$electron/database'; import { Kronos } from '$global/constants'; import { childProcess } from '$electron/utils/files'; import { WorldInterfaceError } from '$electron/error'; -import type { World } from '$types/game'; -import type { WorldDataType } from '$types/world'; import type { WorldDataFetchHistory as WorldDataFetchHistoryTable, getWorldVillagesTable as getWorldVillagesTableType diff --git a/electron/interface/world/index.ts b/electron/interface/world/index.ts index 8d2eb13d..8b7d9d9b 100644 --- a/electron/interface/world/index.ts +++ b/electron/interface/world/index.ts @@ -3,7 +3,6 @@ import { WorldInterfaceError } from '$electron/error'; import { fetchWorldData } from '$interface/world/data'; import { patchWorldConfigStoreState } from '$interface/world/config'; import { patchWorldUnitsStoresState } from '$interface/world/units'; -import type { World } from '$types/game'; import type { defineWorldConfigStore, createWorldUnitStoresMap } from '$stores/world'; import type { defineCacheStore } from '$stores/cache'; diff --git a/electron/interface/world/units.ts b/electron/interface/world/units.ts index 61d5bcff..4434caf1 100644 --- a/electron/interface/world/units.ts +++ b/electron/interface/world/units.ts @@ -3,9 +3,6 @@ import { WorldInterfaceError } from '$electron/error'; import { createPhobos, destroyPhobos } from '$electron/app/phobos'; import { getWorldUnitInfoUrl } from '$global/helpers'; import { sequelize } from '$electron/database'; -import type { WorldUnitsType, UnitDetails } from '$types/world'; -import type { PhobosPortMessage } from '$types/phobos'; -import type { World } from '$types/game'; import type { WorldUnits as WorldUnitsTable } from '$electron/database/world'; import type { createWorldUnitStoresMap } from '$stores/world'; import type { defineCacheStore } from '$stores/cache'; diff --git a/electron/menu/dev.ts b/electron/menu/dev.ts index 24d9a254..80531bfa 100644 --- a/electron/menu/dev.ts +++ b/electron/menu/dev.ts @@ -3,18 +3,17 @@ import { computed, storeToRefs } from 'mechanus'; import { getMainWindow, getPanelWindow } from '$electron/utils/helpers'; import { getMainViewWebContents } from '$electron/utils/view'; import type { useBrowserViewStore } from '$electron/interface'; -import type { BrowserWindow, MenuItemConstructorOptions, WebContents } from 'electron'; -function getDevOptions(browserViewStore: ReturnType): MenuItemConstructorOptions[] { +function getDevOptions(browserViewStore: ReturnType): Electron.MenuItemConstructorOptions[] { const { webContents: mainContents } = getMainWindow(); const { webContents: panelContents } = getPanelWindow(); const { currentWebContents: currentWebContentsMaybeNull } = storeToRefs(browserViewStore); - const contents = computed([currentWebContentsMaybeNull], () => { + const contents = computed([currentWebContentsMaybeNull], () => { return currentWebContentsMaybeNull.value ?? getMainViewWebContents(); }); - const options: MenuItemConstructorOptions[] = [ + const options: Electron.MenuItemConstructorOptions[] = [ { label: 'Forçar atualização', accelerator: 'CmdOrCtrl+F5', click: () => contents.value.reloadIgnoringCache() }, { label: 'Conjurar magia', accelerator: 'F9', click: () => castDevMagic() }, { label: 'Inspecionar', accelerator: 'F10', click: () => contents.value.openDevTools({ mode: 'detach' }) }, @@ -30,7 +29,7 @@ function getDevOptions(browserViewStore: ReturnType) }; /** Adiciona o menu de desenvolvedor à janela. */ -export function setDevMenu(browserViewStore: ReturnType, ...args: BrowserWindow[]) { +export function setDevMenu(browserViewStore: ReturnType, ...args: Electron.BrowserWindow[]) { const options = getDevOptions(browserViewStore); for (const browserWindow of args) { if (process.env.ARES_MODE !== 'dev') { @@ -54,14 +53,14 @@ export function appendDevMenu(browserViewStore: ReturnType contents.reloadIgnoringCache() }, { label: 'Conjurar magia', accelerator: 'F9', click: () => castDevMagic() }, { label: 'Inspecionar', accelerator: 'CmdOrCtrl+F12', click: () => contents.openDevTools({ mode: 'detach' }) } diff --git a/electron/menu/menu.ts b/electron/menu/menu.ts index 7154d761..77a85958 100644 --- a/electron/menu/menu.ts +++ b/electron/menu/menu.ts @@ -4,7 +4,6 @@ import { showAppSettings } from '$electron/app/modules'; import { togglePanelWindow, getMainWindow, getPanelWindow } from '$electron/utils/helpers'; import { appendDevMenu } from '$electron/menu/dev'; import { getMainViewWebContents, contentsGoBack, contentsGoForward, contentsGoHome } from '$electron/utils/view'; -import type { MenuItemConstructorOptions, WebContents } from 'electron'; import type { useBrowserViewStore, useCacheStore } from '$electron/interface'; export function setAppMenu( @@ -15,11 +14,11 @@ export function setAppMenu( const panelWindow = getPanelWindow(); const { currentWebContents: currentWebContentsMaybeNull } = storeToRefs(browserViewStore); - const currentWebContents = computed([currentWebContentsMaybeNull], () => { + const currentWebContents = computed([currentWebContentsMaybeNull], () => { return currentWebContentsMaybeNull.value ?? getMainViewWebContents(); }); - const sharedOptions: MenuItemConstructorOptions[] = [ + const sharedOptions: Electron.MenuItemConstructorOptions[] = [ { label: 'Início', accelerator: 'CmdOrCtrl+Home', click: () => contentsGoHome(currentWebContents.value, cacheStore.region) }, { label: 'Atualizar', accelerator: 'F5', click: () => currentWebContents.value.reload() }, { label: 'Voltar', accelerator: 'CmdOrCtrl+Left', click: () => contentsGoBack(currentWebContents.value) }, diff --git a/electron/stores/ares.ts b/electron/stores/ares.ts index e5d27f1f..d5fecab1 100644 --- a/electron/stores/ares.ts +++ b/electron/stores/ares.ts @@ -1,6 +1,4 @@ -import { ref, type Mechanus } from 'mechanus'; -import type { World } from '$types/game'; -import type { MechanusAresStoreType } from '$types/stores'; +import { ref } from 'mechanus'; import { stringOrNullRef, diff --git a/electron/stores/cache.ts b/electron/stores/cache.ts index eaf1ed7b..1813e431 100644 --- a/electron/stores/cache.ts +++ b/electron/stores/cache.ts @@ -1,9 +1,7 @@ -import { computed, ref, type Mechanus } from 'mechanus'; +import { computed, ref } from 'mechanus'; import { isString } from '$global/guards'; import { generateUserAlias } from '$electron/utils/helpers'; import { gameRegionRef, worldRef, stringRef } from '$electron/utils/mechanus'; -import type { MechanusCacheStoreType } from '$types/stores'; -import type { GameRegion, UserAlias, World } from '$types/game'; export function defineCacheStore(mechanus: Mechanus) { const region = ref('br', gameRegionRef); diff --git a/electron/stores/config.ts b/electron/stores/config.ts index b8f2fd94..91035e01 100644 --- a/electron/stores/config.ts +++ b/electron/stores/config.ts @@ -1,7 +1,6 @@ import { app } from 'electron'; -import { ref, type Mechanus } from 'mechanus'; +import { ref } from 'mechanus'; import { booleanRef } from '$electron/utils/mechanus'; -import type { MechanusAppGeneralConfigStoreType, MechanusAppNotificationsConfigStoreType } from '$types/stores'; export function defineAppGeneralConfigStore(mechanus: Mechanus) { return mechanus.define('appGeneralConfig', { diff --git a/electron/stores/features.ts b/electron/stores/features.ts index 85e42524..1776d6e4 100644 --- a/electron/stores/features.ts +++ b/electron/stores/features.ts @@ -1,6 +1,5 @@ -import { ref, type Mechanus } from 'mechanus'; +import { ref } from 'mechanus'; import { booleanOrNullRef } from '$electron/utils/mechanus'; -import type { MechanusFeaturesStoreType } from '$types/stores'; export function defineFeaturesStore(mechanus: Mechanus) { return mechanus.define('features', { diff --git a/electron/stores/groups.ts b/electron/stores/groups.ts index 7086ce74..ffa958d1 100644 --- a/electron/stores/groups.ts +++ b/electron/stores/groups.ts @@ -1,7 +1,5 @@ -import { ref, type Mechanus } from 'mechanus'; +import { ref } from 'mechanus'; import { integerOrNullRef } from '$electron/utils/mechanus'; -import type { MechanusGroupsStoreType } from '$types/stores'; -import type { VillageGroup } from '$types/game'; export function defineGroupsStore(mechanus: Mechanus) { return mechanus.define('groups', { diff --git a/electron/stores/player.ts b/electron/stores/player.ts index d0745a62..042e1847 100644 --- a/electron/stores/player.ts +++ b/electron/stores/player.ts @@ -1,6 +1,5 @@ -import { ref, type Mechanus } from 'mechanus'; +import { ref } from 'mechanus'; import { integerOrNullRef, stringOrNullRef } from '$electron/utils/mechanus'; -import type { MechanusPlayerStoreType } from '$types/stores'; export function definePlayerStore(mechanus: Mechanus) { return mechanus.define('player', { diff --git a/electron/stores/plunder/config.ts b/electron/stores/plunder/config.ts index 780cc26d..dd208ecf 100644 --- a/electron/stores/plunder/config.ts +++ b/electron/stores/plunder/config.ts @@ -1,8 +1,6 @@ import { ref } from 'mechanus'; import { Kronos } from '$global/constants'; import { isInteger, isFiniteNumber } from '$global/guards'; -import type { WallLevel } from '$types/game'; -import type { Mechanus, MechanusRefOptions } from 'mechanus'; import { booleanRef, @@ -13,9 +11,6 @@ import { positiveIntegerOrNullRef } from '$electron/utils/mechanus'; -import type { BlindAttackPattern, UseCPattern } from '$types/plunder'; -import type { MechanusPlunderConfigStoreType } from '$types/stores'; - // Patterns. const blindAttackPatterns: BlindAttackPattern[] = ['smaller', 'bigger']; const useCPatterns: UseCPattern[] = ['excess', 'normal', 'only']; diff --git a/electron/stores/plunder/history.ts b/electron/stores/plunder/history.ts index 422a5f4e..87d95585 100644 --- a/electron/stores/plunder/history.ts +++ b/electron/stores/plunder/history.ts @@ -1,9 +1,6 @@ import { ref } from 'mechanus'; import { positiveIntegerRef } from '$electron/utils/mechanus'; import { PlunderHistoryVillage } from '$global/objects/plunder'; -import type { Mechanus } from 'mechanus'; -import type { MechanusPlunderHistoryStoreType } from '$types/stores'; -import type { PlunderHistoryType, PlunderHistoryVillageType } from '$types/plunder'; const villages = new Proxy({} as PlunderHistoryType['villages'], { get(target, villageId): PlunderHistoryVillageType[] { diff --git a/electron/stores/plunder/index.ts b/electron/stores/plunder/index.ts index 42868ece..b6e7c343 100644 --- a/electron/stores/plunder/index.ts +++ b/electron/stores/plunder/index.ts @@ -1,8 +1,5 @@ import { ref } from 'mechanus'; import { integerRef, booleanRef, integerOrNullRef } from '$electron/utils/mechanus'; -import type { Mechanus } from 'mechanus'; -import type { PlunderPageListType, DemolitionTemplateType, PlunderGroupType } from '$types/plunder'; -import type { MechanusPlunderStoreType, MechanusPlunderCacheStoreType } from '$types/stores'; export * from '$stores/plunder/config'; export * from '$stores/plunder/history'; diff --git a/electron/stores/units.ts b/electron/stores/units.ts index 66c38903..45cce7e1 100644 --- a/electron/stores/units.ts +++ b/electron/stores/units.ts @@ -1,6 +1,5 @@ -import { ref, type Mechanus } from 'mechanus'; +import { ref } from 'mechanus'; import { integerRef } from '$electron/utils/mechanus'; -import type { MechanusUnitsStoreType } from '$types/stores'; export function defineUnitsStore(mechanus: Mechanus) { return mechanus.define('units', { diff --git a/electron/stores/view.ts b/electron/stores/view.ts index 15f7cdf4..5f8ee47d 100644 --- a/electron/stores/view.ts +++ b/electron/stores/view.ts @@ -1,12 +1,10 @@ -import { ref, type Mechanus } from 'mechanus'; -import type { WebContents } from 'electron'; -import type { MechanusBrowserViewStoreType } from '$types/stores'; +import { ref } from 'mechanus'; export function defineBrowserViewStore(mechanus: Mechanus) { return mechanus.define('browser-view', { - allWebContents: ref>(new Set()), - registeredWebContents: ref>(new WeakSet()), - currentWebContents: ref(null), + allWebContents: ref>(new Set()), + registeredWebContents: ref>(new WeakSet()), + currentWebContents: ref(null), currentAutoResize: ref<(() => void) | null>(null) } satisfies MechanusBrowserViewStoreType); }; \ No newline at end of file diff --git a/electron/stores/village.ts b/electron/stores/village.ts index 19697061..0b8dc733 100644 --- a/electron/stores/village.ts +++ b/electron/stores/village.ts @@ -1,7 +1,5 @@ import { computed, ref } from 'mechanus'; import { integerOrNullRef, stringOrNullRef } from '$electron/utils/mechanus'; -import type { Mechanus, MechanusComputedRef } from 'mechanus'; -import type { MechanusCurrentVillageStoreType } from '$types/stores'; export function defineCurrentVillageStore(mechanus: Mechanus) { const x = ref(null, integerOrNullRef); diff --git a/electron/stores/world.ts b/electron/stores/world.ts index 8a6f8076..0487d4c0 100644 --- a/electron/stores/world.ts +++ b/electron/stores/world.ts @@ -1,10 +1,6 @@ import { ref } from 'mechanus'; import { finiteNumberRef, integerRef, booleanRef } from '$electron/utils/mechanus'; import { allUnits } from '$global/constants'; -import type { AllUnits } from '$types/game'; -import type { UnitDetails } from '$types/world'; -import type { Mechanus, MechanusStore } from 'mechanus'; -import type { MechanusWorldConfigStoreType, MechanusWorldUnitStoreType, WorldUnitStoresMap } from '$types/stores'; export function defineWorldConfigStore(mechanus: Mechanus) { return mechanus.define('worldConfig', { diff --git a/electron/tsconfig.json b/electron/tsconfig.json index 77e56cd8..25eda76b 100644 --- a/electron/tsconfig.json +++ b/electron/tsconfig.json @@ -1,7 +1,7 @@ { "include": [ "./**/*", - "../types/**/*" + "../typings/**/*" ], "compilerOptions": { @@ -13,8 +13,7 @@ "$global/*": ["../global/*"], "$interface/*": ["./interface/*"], "$renderer/*": ["../renderer/*"], - "$stores/*": ["./stores/*"], - "$types/*": ["../types/*"] + "$stores/*": ["./stores/*"] }, "alwaysStrict": true, diff --git a/electron/utils/groups.ts b/electron/utils/groups.ts index 578abe2e..3d2d488b 100644 --- a/electron/utils/groups.ts +++ b/electron/utils/groups.ts @@ -4,12 +4,9 @@ import { assertInstanceOf } from '$global/guards'; import { createPhobos, destroyPhobos } from '$electron/app/phobos'; import { getMainViewWebContents } from '$electron/utils/view'; import { getPanelWindow } from '$electron/utils/helpers'; -import type { MechanusRef } from 'mechanus'; -import type { VillageGroup } from '$types/game'; -import type { PhobosPortMessage } from '$types/phobos'; -export function fetchVillageGroups() { - return new Promise>(async (resolve, reject) => { +export function fetchVillageGroups(): Promise> { + return new Promise(async (resolve, reject) => { // Cria o Phobos na tela de grupos manuais. // Lá é possível obter tanto os grupos manuais quanto os dinâmicos. const mainViewWebContents = getMainViewWebContents(); @@ -37,7 +34,7 @@ export function fetchVillageGroups() { }); }; -export function patchVillageGroups(groups: Set, all: MechanusRef>) { +export function patchVillageGroups(groups: Set, all: MechanusRef>): void { all.value.clear(); groups.forEach((group) => { all.value.add(group); diff --git a/electron/utils/helpers.ts b/electron/utils/helpers.ts index e08c4f83..64cbf6f4 100644 --- a/electron/utils/helpers.ts +++ b/electron/utils/helpers.ts @@ -2,8 +2,6 @@ import { app, BrowserWindow } from 'electron'; import { assertInstanceOf } from '$global/guards'; import { assertWorld } from '$global/guards'; import { MainProcessError } from '$electron/error'; -import type { UserAlias, World } from '$types/game'; -import type { WorldUnitsType } from '$types/world'; import type { createWorldUnitStoresMap } from '$stores/world'; export function restartAres() { @@ -11,14 +9,14 @@ export function restartAres() { app.quit(); }; -export const getMainWindow = () => { +export function getMainWindow(): BrowserWindow { const id = Number.parseIntStrict(process.env.MAIN_WINDOW_ID ?? ''); const mainWindow = BrowserWindow.fromId(id); assertInstanceOf(mainWindow, BrowserWindow, 'Could not get main window.'); return mainWindow; }; -export const getPanelWindow = () => { +export function getPanelWindow(): BrowserWindow { const id = Number.parseIntStrict(process.env.PANEL_WINDOW_ID ?? ''); const panelWindow = BrowserWindow.fromId(id); assertInstanceOf(panelWindow, BrowserWindow, 'Could not get panel window.'); @@ -26,7 +24,7 @@ export const getPanelWindow = () => { }; /** Exibe ou oculta a janela do painel. */ -export function togglePanelWindow() { +export function togglePanelWindow(): void { const mainWindow = getMainWindow(); const panelWindow = getPanelWindow(); @@ -49,7 +47,7 @@ export function togglePanelWindow() { * @param window Janela a ser maximizada ou restaurada. * @returns Booleano indicando se a janela está maximizada. */ -export function maximizeOrRestoreWindow(window: BrowserWindow) { +export function maximizeOrRestoreWindow(window: BrowserWindow): boolean { if (window.isMaximized()) { window.restore(); } else { diff --git a/electron/utils/mechanus.ts b/electron/utils/mechanus.ts index 97f796dc..7cbd37e9 100644 --- a/electron/utils/mechanus.ts +++ b/electron/utils/mechanus.ts @@ -1,7 +1,5 @@ -import { isFiniteNumber, isInteger, isString, isGameRegion, isWorld, isWallLevel } from '$global/guards'; import { MechanusStoreError } from '$electron/error'; -import type { MechanusRefOptions } from 'mechanus'; -import type { GameRegion, World, WallLevel } from '$types/game'; +import { isFiniteNumber, isInteger, isString, isGameRegion, isWorld, isWallLevel } from '$global/guards'; export const arrayIncludesRef = (array: T[]): MechanusRefOptions => ({ validator: (value: unknown): value is T => array.includes(value as T), diff --git a/electron/utils/view.ts b/electron/utils/view.ts index 22d68318..c0a2321b 100644 --- a/electron/utils/view.ts +++ b/electron/utils/view.ts @@ -1,21 +1,20 @@ -import { readFile } from 'node:fs/promises'; +import * as fs from 'node:fs/promises'; import { webContents } from 'electron'; import { browserCss } from '$electron/utils/files'; import { getMainWindow } from '$electron/utils/helpers'; import { Dimensions, GameUrl } from '$global/constants'; import { BrowserViewError } from '$electron/error'; -import type { WebContents, BrowserView, BrowserWindow, IpcMainEvent } from 'electron'; -import type { BackForwardStatus } from '$types/view'; -import type { GameRegion } from '$types/game'; -export const getMainViewWebContents = () => { +export function getMainViewWebContents(): Electron.WebContents { const id = Number.parseIntStrict(process.env.MAIN_VIEW_WEB_CONTENTS_ID ?? ''); const mainViewWebContents = webContents.fromId(id); if (!mainViewWebContents) throw new BrowserViewError('Could not get main view web contents.'); return mainViewWebContents; }; -export function setBrowserViewBounds(view: BrowserView, mainWindow: BrowserWindow = getMainWindow()) { +export function setBrowserViewBounds( + view: Electron.BrowserView, mainWindow: Electron.BrowserWindow = getMainWindow() +): void { const { width, height } = mainWindow.getContentBounds(); view.setBounds({ x: 0, y: Dimensions.TopContainerHeight, width, height: height - Dimensions.TopContainerHeight }); }; @@ -25,9 +24,11 @@ export function setBrowserViewBounds(view: BrowserView, mainWindow: BrowserWindo * @param view BrowserView a ser redimensionado. * @returns Função para remover o evento de redimensionamento. */ -export function setBrowserViewAutoResize(view: BrowserView, mainWindow: BrowserWindow = getMainWindow()): () => void { - let timeout: ReturnType | null = null; - function resize(e: IpcMainEvent) { +export function setBrowserViewAutoResize( + view: Electron.BrowserView, mainWindow: Electron.BrowserWindow = getMainWindow() +): () => void { + let timeout: NodeJS.Immediate | null = null; + function resize(e: Electron.IpcMainEvent) { e.preventDefault(); timeout = setImmediate(() => { if (timeout) clearImmediate(timeout); @@ -44,22 +45,22 @@ export function setBrowserViewAutoResize(view: BrowserView, mainWindow: BrowserW * Retorna um objeto com informações sobre a capacidade de navegação do WebContents. * @param contents WebContents da janela ou do BrowserView. */ -export function getBackForwardStatus(contents: WebContents): BackForwardStatus { +export function getBackForwardStatus(contents: Electron.WebContents): BackForwardStatus { return { canGoBack: contents.canGoBack(), canGoForward: contents.canGoForward() }; }; -export function contentsGoBack(contents: WebContents) { +export function contentsGoBack(contents: Electron.WebContents): void { if (contents.canGoBack()) contents.goBack(); }; -export function contentsGoForward(contents: WebContents) { +export function contentsGoForward(contents: Electron.WebContents): void { if (contents.canGoForward()) contents.goForward(); }; -export function contentsGoHome(contents: WebContents, region: GameRegion) { +export function contentsGoHome(contents: Electron.WebContents, region: GameRegion): void { let homeUrl: GameUrl; switch (region) { case 'br': @@ -92,10 +93,10 @@ export function contentsGoHome(contents: WebContents, region: GameRegion) { * @param contents WebContents da BrowserView. * @param css CSS a ser inserido. Se omitido, será usado o CSS padrão do browser. */ -export async function insertViewCSS(contents?: WebContents, css?: string) { +export async function insertViewCSS(contents?: Electron.WebContents, css?: string): Promise { try { contents ??= getMainViewWebContents(); - css ??= await readFile(browserCss, { encoding: 'utf8' }); + css ??= await fs.readFile(browserCss, { encoding: 'utf8' }); await contents.insertCSS(css); } catch (err) { BrowserViewError.catch(err); diff --git a/global/error.ts b/global/error.ts index 187a6efc..b6af62cb 100644 --- a/global/error.ts +++ b/global/error.ts @@ -1,5 +1,3 @@ -import type { AllErrorLogTypes } from '$types/error'; - export class AresError extends Error { declare public static catch: (err: unknown) => Promise; diff --git a/global/guards/ares.ts b/global/guards/ares.ts index e7908cad..51c460f6 100644 --- a/global/guards/ares.ts +++ b/global/guards/ares.ts @@ -1,7 +1,6 @@ import { isString } from '$global/guards/base'; import { aliasRegex, allowedOriginRegexList } from '$global/regex'; import type { AresError } from '$global/error'; -import type { UserAlias } from '$types/game'; export const isUserAlias = (alias: unknown): alias is UserAlias => (isString(alias) && aliasRegex.test(alias)); export function assertUserAlias(alias: unknown, SomeError: T, message?: string): asserts alias is UserAlias { diff --git a/global/guards/game.ts b/global/guards/game.ts index 87a400e5..88193d72 100644 --- a/global/guards/game.ts +++ b/global/guards/game.ts @@ -2,7 +2,6 @@ import { isFiniteNumber, isInteger, isString } from '$global/guards/base'; import { farmUnits, allUnits } from '$global/constants'; import { regionRegex, worldRegex } from '$global/regex'; import type { AresError } from '$global/error'; -import type { FarmUnits, GameRegion, World, WallLevel, AllUnits } from '$types/game'; /** Verifica se o valor passado é um nome válido de unidade. */ export const isUnit = (unit: unknown): unit is AllUnits => allUnits.includes(unit as AllUnits); diff --git a/global/helpers.ts b/global/helpers.ts index 10104054..e0ba196b 100644 --- a/global/helpers.ts +++ b/global/helpers.ts @@ -1,6 +1,5 @@ import { isInteger, assertGameRegion } from '$global/guards'; import { GameUrl, GameEndpoints } from '$global/constants'; -import type { GameRegion, UserAlias, World } from '$types/game'; import type { AresError } from '$global/error'; /** diff --git a/global/objects/plunder.ts b/global/objects/plunder.ts index 2092c88d..23e6162a 100644 --- a/global/objects/plunder.ts +++ b/global/objects/plunder.ts @@ -1,5 +1,3 @@ -import type { PlunderAttackLog, PlunderHistoryVillageType } from '$types/plunder'; - export abstract class PlunderAttack implements PlunderAttackLog { // Já incluso o ataque enviado. readonly attackAmount: number = 1; diff --git a/modules.config.ts b/modules.config.ts index 5b165969..8ada132d 100644 --- a/modules.config.ts +++ b/modules.config.ts @@ -15,7 +15,6 @@ export default defineConfig({ '$modules': fileURLToPath(new URL('./modules', import.meta.url)), '$panel': fileURLToPath(new URL('./panel', import.meta.url)), '$renderer': fileURLToPath(new URL('./renderer', import.meta.url)), - '$types': fileURLToPath(new URL('./types', import.meta.url)), '$ui': fileURLToPath(new URL('./ui', import.meta.url)) } }, diff --git a/modules/components/ConfigGeneral.vue b/modules/components/ConfigGeneral.vue index 7d27fcc9..4cbf50e0 100644 --- a/modules/components/ConfigGeneral.vue +++ b/modules/components/ConfigGeneral.vue @@ -27,7 +27,7 @@ watch(config, () => ipcSend('update-app-general-config', toRaw(config))); - \ No newline at end of file + \ No newline at end of file diff --git a/ui/components/TheUpdateNotification.vue b/ui/components/TheUpdateNotification.vue index 5939c81a..990c2cbe 100644 --- a/ui/components/TheUpdateNotification.vue +++ b/ui/components/TheUpdateNotification.vue @@ -5,7 +5,6 @@ import { useFetch } from '@vueuse/core'; import { NTag } from 'naive-ui'; import { ipcInvoke, ipcSend } from '$renderer/ipc'; import { AresAPI } from '$global/constants'; -import type { LatestVersion } from '$types/ares'; const appVersion = await ipcInvoke('app-version'); const { data } = useFetch(AresAPI.Latest).json(); diff --git a/ui/components/WindowMenu.vue b/ui/components/WindowMenu.vue index 5dd86fb1..8b2fd94e 100644 --- a/ui/components/WindowMenu.vue +++ b/ui/components/WindowMenu.vue @@ -9,7 +9,6 @@ import { ipcSend, ipcInvoke } from '$renderer/ipc'; import { WebsiteUrl } from '$global/constants'; import TheResponseTime from '$ui/components/TheResponseTime.vue'; import TheUpdateNotification from '$ui/components/TheUpdateNotification.vue'; -import type { BackForwardStatus } from '$types/view'; import { ArrowBackSharp, diff --git a/ui/components/WindowTabs.vue b/ui/components/WindowTabs.vue index 923fafe5..e3dfac2c 100644 --- a/ui/components/WindowTabs.vue +++ b/ui/components/WindowTabs.vue @@ -7,15 +7,14 @@ import { assertInteger } from '$global/guards'; import { ipcInvoke, ipcSend } from '$renderer/ipc'; import WindowTabsButtons from '$ui/components/WindowTabsButtons.vue'; import LightIcon from '$icons/units/LightIcon.vue'; -import type { WebContents } from 'electron'; const tabsContainer = ref(null); const { width } = useElementSize(tabsContainer); const tabsWidth = computed(() => `${width.value - 150}px`); -const allTabs = reactive>(new Map()); +const allTabs = reactive>(new Map()); const mainViewWebContentsId = await ipcInvoke('main-view-web-contents-id'); -const activeView = ref(mainViewWebContentsId); +const activeView = ref(mainViewWebContentsId); watch(activeView, (webContentsId) => ipcSend('update-current-view', webContentsId)); useIpcRendererOn('focus-main-view', () => (activeView.value = mainViewWebContentsId)); @@ -38,7 +37,7 @@ useIpcRendererOn('browser-view-title-updated', (_e, webContentsId: number, viewT allTabs.set(webContentsId, viewTitle); }); -function destroyBrowserView(webContentsId: WebContents['id']) { +function destroyBrowserView(webContentsId: Electron.WebContents['id']) { assertInteger(webContentsId, `Invalid webContentsId: ${webContentsId}`); ipcSend('destroy-browser-view', webContentsId); };