Skip to content

Commit

Permalink
chore: Fix lint & type
Browse files Browse the repository at this point in the history
  • Loading branch information
ci010 committed Jun 16, 2024
1 parent 92d171c commit 0419a35
Show file tree
Hide file tree
Showing 15 changed files with 6 additions and 20 deletions.
1 change: 0 additions & 1 deletion xmcl-electron-app/main/ElectronLauncherApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { LauncherApp, Shell } from '@xmcl/runtime/app'
import { LAUNCHER_NAME } from '@xmcl/runtime/constant'
import { Menu, app, shell } from 'electron'
import { join } from 'path'
import { URL } from 'url'
import { ElectronController } from './ElectronController'
import { ElectronSecretStorage } from './ElectronSecretStorage'
import defaultApp from './defaultApp'
Expand Down
1 change: 0 additions & 1 deletion xmcl-electron-app/main/utils/updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { platform } from 'os'
import { basename, dirname, join } from 'path'
import { SemVer } from 'semver'
import { request } from 'undici'
import { URL } from 'url'
import { promisify } from 'util'
import ElectronLauncherApp from '../ElectronLauncherApp'
import { DownloadAppInstallerTask } from './appinstaller'
Expand Down
1 change: 0 additions & 1 deletion xmcl-runtime/app/LauncherApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { join } from 'path'
import { Readable } from 'stream'
import { pipeline } from 'stream/promises'
import { setTimeout } from 'timers/promises'
import { URL } from 'url'
import { Logger } from '~/logger'
import { IS_DEV, LAUNCHER_NAME } from '../constant'
import { isSystemError } from '../util/error'
Expand Down
1 change: 0 additions & 1 deletion xmcl-runtime/app/LauncherAppManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import filenamifyCombined from 'filenamify'
import { ensureDir, readFile, readdir, rm, stat, writeFile } from 'fs-extra'
import { join } from 'path'
import { request } from 'undici'
import { URL } from 'url'
import { Logger } from '~/logger'
import { LauncherApp } from '../app/LauncherApp'
import { isSystemError } from '../util/error'
Expand Down
2 changes: 1 addition & 1 deletion xmcl-runtime/authlibInjector/AuthlibInjectorService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class AuthlibInjectorService extends AbstractService implements IAuthlibI
super(app)

networkInterface.registerOptionsInterceptor((options) => {
const origin = options.origin instanceof URL ? options.origin : new URL(options.origin!)
const origin = options.origin instanceof URL ? options.origin : new URL(options.origin! as any)
if (origin.hostname === 'authlib-injector.yushi.moe') {
if (shouldOverrideApiSet(settings, gfw.inside)) {
const api = settings.apiSets.find(a => a.name === settings.apiSetsPreference) || settings.apiSets[0]
Expand Down
1 change: 0 additions & 1 deletion xmcl-runtime/import/ImportService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { createHash } from 'crypto'
import { ensureFile, unlink } from 'fs-extra'
import { basename } from 'path'
import { request } from 'undici'
import { URL } from 'url'
import { Inject, LauncherAppKey, kTempDataPath } from '~/app'
import { kDownloadOptions } from '~/network'
import { ResourceService } from '~/resource'
Expand Down
2 changes: 0 additions & 2 deletions xmcl-runtime/import/sourceControlUrlParser.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { URL } from 'url'

export function parseSourceControlUrl(url: string) {
if (url.startsWith('https://github.com')) {
const resolvedUrl = new URL(url)
Expand Down
1 change: 0 additions & 1 deletion xmcl-runtime/install/InstallService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { AbortableTask, CancelledError, task } from '@xmcl/task'
import { existsSync } from 'fs'
import { ensureFile, readFile, unlink, writeFile } from 'fs-extra'
import { errors, request } from 'undici'
import { URL } from 'url'
import { Inject, LauncherApp, LauncherAppKey, PathResolver, kGameDataPath } from '~/app'
import { GFW } from '~/gfw'
import { JavaService } from '~/java'
Expand Down
1 change: 0 additions & 1 deletion xmcl-runtime/java/JavaService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { fetchJavaRuntimeManifest, installJavaRuntimeTask, parseJavaVersion, res
import { JavaService as IJavaService, Java, JavaRecord, JavaSchema, JavaServiceKey, JavaState, MutableState, Settings } from '@xmcl/runtime-api'
import { chmod, ensureFile, readFile } from 'fs-extra'
import { dirname, join } from 'path'
import { URL } from 'url'
import { Inject, LauncherAppKey, PathResolver, kGameDataPath } from '~/app'
import { GFW } from '~/gfw'
import { JavaValidation, validateJavaPath } from '~/java'
Expand Down
1 change: 0 additions & 1 deletion xmcl-runtime/network/dispatchers/NetworkAgent.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Socket } from 'net'
import { Agent, Client, Dispatcher, RetryHandler, buildConnector, errors, util } from 'undici'
import { URL } from 'url'

type DispatchHandlers = Dispatcher.DispatchHandlers
const { InvalidArgumentError, RequestAbortedError } = errors
Expand Down
7 changes: 3 additions & 4 deletions xmcl-runtime/network/pluginNetworkInterface.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { DefaultRangePolicy, createRedirectInterceptor, getDefaultAgentOptions } from '@xmcl/file-transfer'
import { DefaultRangePolicy } from '@xmcl/file-transfer'
import { PoolStats } from '@xmcl/runtime-api'
import { setTimeout as timeout } from 'timers/promises'
import { Agent, Dispatcher, Pool, RetryAgent, buildConnector, setGlobalDispatcher } from 'undici'
import { Agent, Dispatcher, Pool, buildConnector, setGlobalDispatcher } from 'undici'
import { kClients, kRunning } from 'undici/lib/core/symbols'
import { LauncherAppPlugin } from '~/app'
import { IS_DEV } from '~/constant'
import { kSettings } from '~/settings'
import { NetworkAgent, ProxySettingController } from './dispatchers/NetworkAgent'
import { createInterceptOptionsInterceptor } from './dispatchers/dispatcher'
import { kDownloadOptions, kNetworkInterface } from './networkInterface'
import { kUserAgent } from './userAgent'

Expand Down Expand Up @@ -76,7 +75,7 @@ export const pluginNetworkInterface: LauncherAppPlugin = (app) => {
connect,
factory(origin, opts: Agent.Options) {
let dispatcher: Dispatcher | undefined
for (const factory of apiClientFactories) { dispatcher = factory(typeof origin === 'string' ? new URL(origin) : origin, opts) }
for (const factory of apiClientFactories) { dispatcher = factory(typeof origin === 'string' ? new URL(origin) : origin as any, opts) }
if (!dispatcher) { dispatcher = new Pool(origin, opts) }
return patchIfPool(dispatcher)
},
Expand Down
2 changes: 1 addition & 1 deletion xmcl-runtime/settings/pluginSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const pluginSettings: LauncherAppPlugin = async (app) => {

settingFile.read().then(async () => {
const data = await settingFile.read()
data.locale = data.locale || app.getPreferredLocale() || app.host.getLocale()
data.locale = data.locale || app.host.getLocale()
state.config(data)
}).finally(() => {
app.registry.register(kSettings, state)
Expand Down
1 change: 0 additions & 1 deletion xmcl-runtime/user/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { AuthlibInjectorApiProfile, GameProfileAndTexture, YggdrasilApi } from '
import { GameProfile } from '@xmcl/user'
import { readFile } from 'fs-extra'
import { request } from 'undici'
import { URL } from 'url'

export interface OAuthTokenResponse {
token_type: string
Expand Down
2 changes: 1 addition & 1 deletion xmcl-runtime/util/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export async function serializeError(e: unknown): Promise<any> {
type: 'httpException',
code: e.code,
method: options?.method || '',
url: (e as any).url ?? (options ? new URL(options?.path, options.origin).toString() : ''),
url: (e as any).url ?? (options ? new URL(options?.path, options.origin as any).toString() : ''),
statusCode: e instanceof errors.ResponseStatusCodeError ? e.statusCode : 0,
body,
})
Expand Down
2 changes: 0 additions & 2 deletions xmcl-runtime/util/url.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { URL } from 'url'

export const isValidUrl = (url: string) => {
try {
// eslint-disable-next-line no-new
Expand Down

0 comments on commit 0419a35

Please sign in to comment.