Skip to content

Commit

Permalink
Merge pull request #203 from MaaAssistantArknights/format
Browse files Browse the repository at this point in the history
format
  • Loading branch information
ChingCdesu authored Sep 22, 2023
2 parents 436285a + 280f3ba commit df33e94
Show file tree
Hide file tree
Showing 147 changed files with 896 additions and 675 deletions.
4 changes: 2 additions & 2 deletions packages/main/componentManager/components/adb.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'fs'

import AdbInstaller from '@main/componentManager/installers/adb'
import type { Component } from '@type/componentManager'
import fs from 'fs'

import { infoPathOf } from '../utils/update'

export const getComponentAdb = async (): Promise<Component> => {
Expand Down
8 changes: 4 additions & 4 deletions packages/main/componentManager/components/core.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import fs from 'fs'

import CoreLoader from '@main/coreLoader'
import CoreInstaller from '@main/componentManager/installers/core'
import path from 'path'
import CoreLoader from '@main/coreLoader'
import type { Component } from '@type/componentManager'
import fs from 'fs'
import path from 'path'

import { infoPathOf } from '../utils/update'
import { getComponentBaseDir } from '../utils/path'

Expand Down
7 changes: 4 additions & 3 deletions packages/main/componentManager/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Singleton } from '@common/function/singletonDecorator'
import { getComponentAdb } from './components/adb'
import { getComponentCore } from './components/core'
import CoreLoader from '@main/coreLoader'
import type { Module } from '@type/misc'
import type { Component, ComponentType } from '@type/componentManager'
import type { Module } from '@type/misc'

import { getComponentAdb } from './components/adb'
import { getComponentCore } from './components/core'

@Singleton
class ComponentManager implements Module {
Expand Down
12 changes: 6 additions & 6 deletions packages/main/componentManager/installer.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import path from 'path'

import DownloadManager from '@main/downloadManager'
import type { Installer, Notifier, SourceMirror, UpdateStatus } from './types'
import type { ComponentType } from '@type/componentManager'
import { extractFile } from '@main/utils/extract'
import logger from '@main/utils/logger'
import { getAppBaseDir } from '@main/utils/path'
import { createNotifier } from './utils/notifier'
import type { ComponentType } from '@type/componentManager'
import type { InstallerStatus } from '@type/misc'
import { extractFile } from '@main/utils/extract'
import path from 'path'

import type { Installer, Notifier, SourceMirror, UpdateStatus } from './types'
import { createNotifier } from './utils/notifier'

export default abstract class InstallerBase implements Installer {
public readonly componentType: ComponentType
Expand Down
9 changes: 5 additions & 4 deletions packages/main/componentManager/installers/adb.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import type { SourceMirror, UpdateStatus } from '../types'
import { Singleton } from '@common/function/singletonDecorator'
import { createFixedGetRelease } from '../utils/release'
import Storage from '@main/storageManager'
import { getPlatform } from '@main/utils/os'
import { createCheckUpdate } from '../utils/update'

import InstallerBase from '../installer'
import Storage from '@main/storageManager'
import type { SourceMirror, UpdateStatus } from '../types'
import { createFixedGetRelease } from '../utils/release'
import { createCheckUpdate } from '../utils/update'

@Singleton
export default class AdbInstaller extends InstallerBase {
Expand Down
11 changes: 6 additions & 5 deletions packages/main/componentManager/installers/core.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { SourceMirror, UpdateStatus } from '../types'
import { Singleton } from '@common/function/singletonDecorator'
import { createGetRelease } from '../utils/release'
import { getDownloadUrlExtension, getDownloadUrlSuffix } from '@main/utils/os'
import { createCheckUpdate } from '../utils/update'
import CoreLoader from '@main/coreLoader'
import InstallerBase from '../installer'
import Storage from '@main/storageManager'
import { getDownloadUrlExtension, getDownloadUrlSuffix } from '@main/utils/os'

import InstallerBase from '../installer'
import type { SourceMirror, UpdateStatus } from '../types'
import { createGetRelease } from '../utils/release'
import { createCheckUpdate } from '../utils/update'

@Singleton
export default class CoreInstaller extends InstallerBase {
Expand Down
1 change: 1 addition & 0 deletions packages/main/componentManager/utils/notifier.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { ComponentType } from '@type/componentManager'
import type { InstallerStatus } from '@type/misc'

import type { Notifier } from '../types'

export function createNotifier(
Expand Down
7 changes: 3 additions & 4 deletions packages/main/componentManager/utils/release.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import axios from 'axios'

import { getProxy } from './proxy'
import logger from '@main/utils/logger'

import type { ComponentType } from '@type/componentManager'
import axios from 'axios'

import type { ReleaseObject } from '../types'
import { getProxy } from './proxy'

const MaxRetryTimes = 3

Expand Down
6 changes: 3 additions & 3 deletions packages/main/componentManager/utils/update.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import logger from '@main/utils/logger'
import { getAppBaseDir } from '@main/utils/path'
import type { ComponentType } from '@type/componentManager'
import fs from 'fs'
import path from 'path'

import logger from '@main/utils/logger'
import type { ReleaseObject, SourceMirror, UpdateStatus } from '../types'
import type { ComponentType } from '@type/componentManager'
import { getComponentBaseDir } from './path'

export function infoPathOf(componentDir: string) {
Expand Down
2 changes: 1 addition & 1 deletion packages/main/coreLoader/callback.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logger from '@main/utils/logger'
import ffi from '@tigerconnect/ffi-napi'
import ref from '@tigerconnect/ref-napi'
import logger from '@main/utils/logger'
import type { AsstMsg } from '@type/task/callback'

const callbackHandle = ffi.Callback(
Expand Down
16 changes: 10 additions & 6 deletions packages/main/coreLoader/index.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import { Singleton } from '@common/function/singletonDecorator'
import Storage from '@main/storageManager'
import path from 'path'
import _ from 'lodash'
import { extractFile } from '@main/utils/extract'
import logger from '@main/utils/logger'
import { existsSync, mkdirSync, readFileSync, rmdirSync, unlinkSync, writeFileSync } from 'fs'
import { getAppBaseDir } from '@main/utils/path'
import ffi, { DynamicLibrary } from '@tigerconnect/ffi-napi'
import ref from '@tigerconnect/ref-napi'
import callbackHandle from './callback'
import { getAppBaseDir } from '@main/utils/path'
import type { ResourceType } from '@type/game'
import type { TouchMode } from '@type/misc'
import { InstanceOptionKey } from '@type/misc'
import { extractFile } from '@main/utils/extract'
import { existsSync, mkdirSync, readFileSync, rmdirSync, unlinkSync, writeFileSync } from 'fs'
import _ from 'lodash'
import path from 'path'

import callbackHandle from './callback'

import type { ResourceType } from '@type/game'
import { getComponentBaseDir } from '@main/componentManager/utils/path'


const storage = new Storage()

/** Some types for core */
Expand Down
2 changes: 1 addition & 1 deletion packages/main/deviceDetector/adapters/linuxAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import psList from 'ps-list'
import { Singleton } from '@common/function/singletonDecorator'
import type { Device, Emulator, EmulatorAdapter } from '@type/device'
import psList from 'ps-list'

@Singleton
class LinuxEmulator implements EmulatorAdapter {
Expand Down
4 changes: 2 additions & 2 deletions packages/main/deviceDetector/adapters/macAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import psList from 'ps-list'
import { Singleton } from '@common/function/singletonDecorator'
import type { EmulatorAdapter, Device, Emulator } from '@type/device'
import type { Device, Emulator, EmulatorAdapter } from '@type/device'
import psList from 'ps-list'

@Singleton
class MacEmulator implements EmulatorAdapter {
Expand Down
12 changes: 6 additions & 6 deletions packages/main/deviceDetector/adapters/winAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/* eslint-disable vue/max-len */
import { Singleton } from '@common/function/singletonDecorator'
import path from 'path'
import { readFileSync, existsSync } from 'fs'
import { defaultAdbPath, getDeviceUuid } from '@main/deviceDetector/utils'
import logger from '@main/utils/logger'
import { $ } from '@main/utils/shell'
import type { Device, Emulator, EmulatorAdapter } from '@type/device'
import { assert } from 'console'
import { existsSync, readFileSync } from 'fs'
import _ from 'lodash'
import { $ } from '@main/utils/shell'
import logger from '@main/utils/logger'
import { defaultAdbPath, getDeviceUuid } from '@main/deviceDetector/utils'
import type { EmulatorAdapter, Emulator, Device } from '@type/device'
import path from 'path'

const inUsePorts: string[] = [] // 本次识别已被使用的端口,将会在此暂存。

Expand Down
5 changes: 3 additions & 2 deletions packages/main/deviceDetector/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { defaultAdbPath, getDeviceUuid, isDefaultAdbExists } from './utils'
import { $$, $ } from '@main/utils/shell'
import { parseArguments } from '@main/utils/arguments'
import { $, $$ } from '@main/utils/shell'
import type { EmulatorAdapter } from '@type/device'

import { defaultAdbPath, getDeviceUuid, isDefaultAdbExists } from './utils'

export function useEmulatorHooks(adapter: Promise<EmulatorAdapter>): void {
globalThis.main.DeviceDetector = {
async getEmulators() {
Expand Down
7 changes: 4 additions & 3 deletions packages/main/deviceDetector/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Singleton } from '@common/function/singletonDecorator'
import { useEmulatorHooks } from './hooks'
import adapters from './adapters'
import type { EmulatorAdapter, Emulator, Device } from '@type/device'
import type { Device, Emulator, EmulatorAdapter } from '@type/device'
import type { Module } from '@type/misc'

import adapters from './adapters'
import { useEmulatorHooks } from './hooks'

@Singleton
class DeviceDetector implements Module {
private readonly adapter: Promise<EmulatorAdapter>
Expand Down
9 changes: 6 additions & 3 deletions packages/main/deviceDetector/utils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import _ from 'lodash'
import { app } from 'electron'
import path from 'path'
import logger from '@main/utils/logger'
import { getPlatform } from '@main/utils/os'
import { $, $$ } from '@main/utils/shell'
import { app } from 'electron'
import fs from 'fs'

import _ from 'lodash'
import path from 'path'

import logger from '@main/utils/logger'
import { getComponentBaseDir } from '@main/componentManager/utils/path'

Expand Down
11 changes: 5 additions & 6 deletions packages/main/downloadManager/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import fs from 'fs'
import path from 'path'
import type { BrowserWindow } from 'electron'

import { Singleton } from '@main/../common/function/singletonDecorator'
import logger from '@main/utils/logger'
import { getAppBaseDir } from '@main/utils/path'
import WindowManager from '@main/windowManager'
import type { DownloadHandle, DownloadTask } from '@type/downloadManager'
import type { Module } from '@type/misc'
import { getAppBaseDir } from '@main/utils/path'
import logger from '@main/utils/logger'
import type { BrowserWindow } from 'electron'
import fs from 'fs'
import path from 'path'

@Singleton
export default class DownloadManager implements Module {
Expand Down
2 changes: 1 addition & 1 deletion packages/main/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { IpcRendererOnEventProxy, IpcMainHandleEventCalleeProxy } from '@type/ipc'
import type { IpcMainHandleEventCalleeProxy, IpcRendererOnEventProxy } from '@type/ipc'

export {}

Expand Down
4 changes: 2 additions & 2 deletions packages/main/hooks/asst.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import path from 'path'
import fs from 'fs'
import CoreLoader from '@main/coreLoader'
import logger from '@main/utils/logger'
import type { IpcMainHandleEventCalleeProxy } from '@type/ipc'
import fs from 'fs'
import path from 'path'

const core = new CoreLoader()

Expand Down
8 changes: 5 additions & 3 deletions packages/main/hooks/clear.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import fs from 'fs'
import path from 'path'
import { app } from 'electron'
import { manager } from '@main/utils/logger'
import { getAppBaseDir } from '@main/utils/path'

import { app } from 'electron'
import fs from 'fs'
import path from 'path'

import type { ComponentType } from '@type/componentManager'
import { getComponentBaseDir } from '@main/componentManager/utils/path'
import { getComponentAdb } from '@main/componentManager/components/adb'
Expand Down
8 changes: 4 additions & 4 deletions packages/main/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import useVersionHooks from './version'
import useAsstHooks from './asst'
import useStorageHooks from './storage'
import useClearHooks from './clear'
import useOsHooks from './os'
import usePathHooks from './path'
import useShutdownHooks from './shutdown'
import useClearHooks from './clear'
import useStorageHooks from './storage'
import useTaskHooks from './task'
import usePathHooks from './path'
import useVersionHooks from './version'

export default function useHooks(): void {
useVersionHooks()
Expand Down
4 changes: 2 additions & 2 deletions packages/main/hooks/os.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {
generateIdempotentKey,
getArch,
getPlatform,
getSystemInformation,
reload,
generateIdempotentKey,
isInDev,
reload,
} from '@main/utils/os'

export default function useOsHooks(): void {
Expand Down
1 change: 1 addition & 0 deletions packages/main/hooks/path.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { openFolder, openExternal, saveTempJson } from '@main/utils/path'
import { moveComponentBaseDir } from '@main/componentManager/utils/path'


export default function usePathHooks(): void {
globalThis.main.Util = {
openFolder,
Expand Down
4 changes: 2 additions & 2 deletions packages/main/hooks/shutdown.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { $ } from '@main/utils/shell'
import logger from '@main/utils/logger'
import { getPlatform } from '@main/utils/os'
import { $ } from '@main/utils/shell'
import WindowManager from '@main/windowManager'
import logger from '@main/utils/logger'

async function shutdownEmulator(pid: string): Promise<void> {
logger.silly('Shutdown Emulator')
Expand Down
2 changes: 1 addition & 1 deletion packages/main/hooks/task.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from 'fs'
import logger from '@main/utils/logger'
import fs from 'fs'

export default function useTaskHooks(): void {
globalThis.main.Task.readInfrastConfig = ({ filepath }) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/main/hooks/version.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { app } from 'electron'
import CoreLoader from '@main/coreLoader'
import { app } from 'electron'

export default function useVersionHooks(): void {
globalThis.main.Util.getUiVersion = () => app.getVersion()
Expand Down
23 changes: 11 additions & 12 deletions packages/main/index.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import { app, BrowserWindow, shell } from 'electron'
import { release } from 'os'
import { join } from 'path'
import fs from 'fs'

import ComponentManager from '@main/componentManager'
import CoreLoader from '@main/coreLoader'
import DeviceDetector from '@main/deviceDetector'
import useHooks from '@main/hooks'
import StorageManager from '@main/storageManager'
import useDebug from '@main/utils/debug'
import logger from '@main/utils/logger'
import useHooks from '@main/hooks'
import { getPlatform, isInDev } from '@main/utils/os'

// modules
import WindowManager from '@main/windowManager'
import StorageManager from '@main/storageManager'
import ComponentManager from '@main/componentManager'
import CoreLoader from '@main/coreLoader'
import DeviceDetector from '@main/deviceDetector'
import { BrowserWindow, app, shell } from 'electron'
import fs from 'fs'
import { release } from 'os'
import { join } from 'path'

import DownloadManager from './downloadManager'
import { getAppBaseDir } from './utils/path'
import { setupHookProxy } from './utils/ipc-main'
import { getAppBaseDir } from './utils/path'

require('source-map-support').install()

Expand Down
Loading

0 comments on commit df33e94

Please sign in to comment.