Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: fix several type error and config, avoid build failed #234

Merged
merged 2 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@
}
},
"peerDependencies": {
"@koishijs/plugin-proxy-agent": "^0.1.4 || ^0.2.0",
"@cordisjs/plugin-proxy-agent": ">=0.3.0",
"koishi": "^4.17.0"
},
"devDependencies": {
"@cordisjs/plugin-proxy-agent": ">=0.3.3",
"@koishijs/assets": "^1.0.2",
"@koishijs/plugin-proxy-agent": "^0.2.0",
"koishi": "^4.17.0"
},
"dependencies": {
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class ImageService extends Service {

async imgUrlToBase64(url: string): Promise<string> {
return this.ctx
.http(url, { method: 'GET', responseType: 'arraybuffer' })
.http(url, { method: 'GET', responseType: 'arraybuffer', proxyAgent: '' })
.then((resp) => {
return `data:${resp.headers['content-type']};base64,${Buffer.from(resp.data).toString('base64')}`
})
Expand Down Expand Up @@ -214,7 +214,9 @@ export const Config = Schema.intersect([
])

export function apply(ctx: Context, config: Config) {
// @ts-expect-error inject structure not compatiable
ctx.plugin(ImageService, config)
// @ts-expect-error inject structure not compatiable
ctx.plugin(Command, config)

// eslint-disable-next-line @typescript-eslint/no-var-requires
Expand Down
5 changes: 2 additions & 3 deletions packages/core/src/source.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { Context, Element, Quester, Schema } from 'koishi'

import type {} from '@koishijs/plugin-proxy-agent'
import type { Inject } from 'cordis'
import type {} from '@cordisjs/plugin-proxy-agent'

export abstract class ImageSource<Config extends ImageSource.Config = ImageSource.Config> {
static inject: string[] | Partial<Inject> = ['booru']
static inject: string[] | Partial<Record<'required' | 'optional', string[]>> = ['booru']

languages: string[] = []
source: string
Expand Down
3 changes: 1 addition & 2 deletions packages/e621/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { Context, Quester, Schema, trimSlash } from 'koishi'
import { Context, Schema, trimSlash } from 'koishi'
import { ImageSource } from 'koishi-plugin-booru'

import { e621 } from './types'

class e621ImageSource extends ImageSource<e621ImageSource.Config> {
languages = ['en']
source = 'e621'
http: Quester

constructor(ctx: Context, config: e621ImageSource.Config) {
super(ctx, config)
Expand Down
6 changes: 3 additions & 3 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"compilerOptions": {
"target": "es2019",
"module": "commonjs",
"target": "esnext",
"module": "esnext",
"declaration": true,
"composite": true,
"incremental": true,
"skipLibCheck": true,
"esModuleInterop": true,
"moduleResolution": "node",
"moduleResolution": "bundler",
"strictBindCallApply": true,
"jsx": "react-jsx",
"jsxImportSource": "@satorijs/element",
Expand Down