Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Merge pull request #217 from ferreira-tb/194-arquivos-contendo-apenas…
Browse files Browse the repository at this point in the history
…-tipos-devem-ser-convertidos-em-arquivos-de-declaração
  • Loading branch information
ferreira-tb committed May 11, 2023
2 parents b0b74be + baa6979 commit 38005bb
Show file tree
Hide file tree
Showing 172 changed files with 552 additions and 804 deletions.
5 changes: 4 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion browser.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
},
Expand Down
2 changes: 1 addition & 1 deletion browser/components/PlunderReloadMessage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const autoReloadMessage = computed(() => {
</span>
</template>

<style scoped>
<style scoped lang="scss">
.auto-reload-message {
font-style: normal;
position: absolute;
Expand Down
2 changes: 1 addition & 1 deletion browser/components/TheCaptchaObserver.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ async function reloadMainView() {
<div></div>
</template>

<style scoped>
<style scoped lang="scss">
</style>
1 change: 0 additions & 1 deletion browser/lib/plunder/attack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion browser/lib/plunder/data.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
4 changes: 1 addition & 3 deletions browser/lib/plunder/group.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
1 change: 0 additions & 1 deletion browser/lib/plunder/next.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 0 additions & 2 deletions browser/lib/plunder/targets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 0 additions & 2 deletions browser/lib/plunder/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion browser/lib/plunder/units.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
1 change: 0 additions & 1 deletion browser/lib/plunder/village.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
1 change: 0 additions & 1 deletion browser/lib/plunder/wall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean> {
Expand Down
3 changes: 1 addition & 2 deletions browser/stores/browser.ts
Original file line number Diff line number Diff line change
@@ -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<boolean>(false);
Expand Down
1 change: 0 additions & 1 deletion browser/views/PlunderView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
12 changes: 3 additions & 9 deletions deimos/deimos.d.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -91,4 +83,6 @@ declare global {
InfoMessage(message: string): void;
SuccessMessage(message: string): void;
};
}
}

export {};
1 change: 0 additions & 1 deletion deimos/interface/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 0 additions & 2 deletions deimos/models/data.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 0 additions & 2 deletions deimos/models/plunder.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 0 additions & 2 deletions deimos/models/timing.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
1 change: 0 additions & 1 deletion deimos/models/units.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { assertString, isString } from '$global/guards';
import type { UnitAmount, UnitsAmountAsStrings } from '$types/game';

interface MaybeNotArcherWorld extends Omit<UnitsAmountAsStrings, 'archer' | 'marcher'> {
archer?: string;
Expand Down
5 changes: 2 additions & 3 deletions deimos/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"./**/*",
"../global/**/*",
"../renderer/**/*",
"../types/**/*"
"../typings/**/*"
],

"compilerOptions": {
Expand All @@ -17,8 +17,7 @@
"$modules/*": ["../modules/*"],
"$panel/*": ["../panel/*"],
"$phobos/*": ["../phobos/*"],
"$renderer/*": ["../renderer/*"],
"$types/*": ["../types/*"]
"$renderer/*": ["../renderer/*"]
},

"alwaysStrict": true,
Expand Down
5 changes: 2 additions & 3 deletions electron/app/modules/standard.ts
Original file line number Diff line number Diff line change
@@ -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<ModuleNames, BrowserWindow>();
export const getActiveModule = (name: ModuleNames) => activeModules.get(name) ?? null;
Expand Down Expand Up @@ -33,7 +32,7 @@ export function createModule<T extends keyof ModuleConstructorOptions>(
return;
};

const windowOptions: BrowserWindowConstructorOptions = {
const windowOptions: Electron.BrowserWindowConstructorOptions = {
parent: mainWindow,
width: 500,
height: 600,
Expand Down
1 change: 0 additions & 1 deletion electron/app/modules/website.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<WebsiteModuleNames, BrowserWindow>();
export const getActiveWebsiteModule = (name: WebsiteModuleNames) => activeWebsiteModules.get(name) ?? null;
Expand Down
4 changes: 1 addition & 3 deletions electron/app/phobos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<PhobosNames, BrowserView>();

Expand Down Expand Up @@ -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';

Expand Down
3 changes: 1 addition & 2 deletions electron/child-process/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ 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) {
super(message);
this.name = 'ChildProcessError';
};

public static override async catch(err: unknown) {
public static override async catch(err: unknown): Promise<void> {
if (!process.env.USER_DATA_PATH) return;

if (err instanceof Error) {
Expand Down
2 changes: 0 additions & 2 deletions electron/child-process/world-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
1 change: 0 additions & 1 deletion electron/database/config/config.ts
Original file line number Diff line number Diff line change
@@ -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<AppConfigName, `config_${string}`>;
Expand Down
1 change: 0 additions & 1 deletion electron/database/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<InferAttributes<AppConfig>, InferCreationAttributes<AppConfig>> {
Expand Down
5 changes: 2 additions & 3 deletions electron/database/config/panel.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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);
Expand All @@ -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 });
Expand Down
2 changes: 0 additions & 2 deletions electron/database/config/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 0 additions & 2 deletions electron/database/error.ts
Original file line number Diff line number Diff line change
@@ -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<InferAttributes<ErrorLog>, InferCreationAttributes<ErrorLog>> implements ErrorLogType {
declare readonly id: CreationOptional<number>;
Expand Down
1 change: 0 additions & 1 deletion electron/database/groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<InferAttributes<VillageGroups>, InferCreationAttributes<VillageGroups>> implements VillageGroupsType {
Expand Down
2 changes: 0 additions & 2 deletions electron/database/plunder/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<InferAttributes<PlunderConfig>, InferCreationAttributes<PlunderConfig>> implements PlunderConfigType {
declare readonly id: UserAlias;
Expand Down
2 changes: 0 additions & 2 deletions electron/database/plunder/demolition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<DemolitionTemplate>,
Expand Down
2 changes: 0 additions & 2 deletions electron/database/plunder/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<InferAttributes<PlunderHistory>, InferCreationAttributes<PlunderHistory>> implements PlunderHistoryType {
Expand Down
2 changes: 0 additions & 2 deletions electron/database/plunder/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<CustomPlunderTemplate>,
Expand Down
2 changes: 0 additions & 2 deletions electron/database/world/config.ts
Original file line number Diff line number Diff line change
@@ -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<InferAttributes<WorldConfig>, InferCreationAttributes<WorldConfig>> implements WorldConfigType {
declare readonly id: World;
Expand Down
Loading

0 comments on commit 38005bb

Please sign in to comment.