Commit 33427980 authored by nanahira's avatar nanahira

adapt Koishi 4.8.2

parent f1683fa1
......@@ -2,15 +2,13 @@ import { App } from 'koishi';
import TargetPlugin from '../src';
import ConsolePlugin from '@koishijs/plugin-console';
import SandboxPlugin from '@koishijs/plugin-sandbox';
import * as DatabasePlugin from '@koishijs/plugin-database-memory';
import CachePlugin from '@koishijs/plugin-cache-lru';
import DatabasePlugin from '@koishijs/plugin-database-memory';
import ExtrasInDev from './extras';
const app = new App({
port: 14514,
host: 'localhost',
prefix: '.',
locale: 'en',
});
// Console and sandbox
......@@ -19,8 +17,7 @@ app.plugin(ConsolePlugin, {
open: false,
});
// Some services
app.plugin(CachePlugin);
// Database
app.plugin(DatabasePlugin);
// Some extras
......
This source diff could not be displayed because it is too large. You can view the blob instead.
// import 'source-map-support/register';
import { SchemaProperty, RegisterSchema, SchemaClass } from 'koishi-thirdeye';
import { Quester } from 'koishi';
import { Quester, Schema } from 'koishi';
import { PicMiddleware, PicMiddlewareInfo, PicSourceInfo } from './def';
@RegisterSchema()
......@@ -18,7 +18,7 @@ export class PicsPluginConfig {
@SchemaProperty({ description: '使用 Base64 发送图片结果。', default: false })
useBase64: boolean;
@SchemaProperty({ type: Quester.createSchema(), default: {} })
@SchemaProperty({ type: Schema.object({}), default: {} })
httpConfig: Quester.Config;
@SchemaProperty({
......
......@@ -4,7 +4,7 @@ import { PicsPluginConfig } from './config';
import _ from 'lodash';
import { segment, Quester } from 'koishi';
import {
BasePlugin,
StarterPlugin,
Caller,
CommandExample,
CommandLocale,
......@@ -31,18 +31,15 @@ export * from './picsource';
export * from './def';
declare module 'koishi' {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace Context {
interface Services {
pics: PicsContainer;
}
interface Context {
pics: PicsContainer;
}
}
@Provide('pics', { immediate: true })
@DefinePlugin({ name: 'pics', schema: PicsPluginConfig })
@DefinePlugin({ name: 'pics' })
export default class PicsContainer
extends BasePlugin<PicsPluginConfig>
extends StarterPlugin(PicsPluginConfig)
implements LifecycleEvents
{
private sources = new Map<PicSource, () => boolean>();
......
import { Awaitable, Context, Logger, Schema } from 'koishi';
import { PicMiddlewareConfig } from './config';
import {
BasePlugin,
CreatePluginFactory,
Inject,
InjectLogger,
......@@ -9,13 +8,14 @@ import {
PartialDeep,
Reusable,
schemaFromClass,
StarterPlugin,
} from 'koishi-thirdeye';
import PicsContainer, { PicMiddlewareInfo } from './index';
import { PicMiddleware, PicNext } from './def';
@Reusable()
export class BasePicMiddlewarePlugin
extends BasePlugin<PicMiddlewareConfig>
extends StarterPlugin(PicMiddlewareConfig)
implements PicMiddleware, LifecycleEvents
{
@Inject(true)
......@@ -42,7 +42,7 @@ export const PicMiddlewarePlugin = CreatePluginFactory(
export function PlainPicMiddlewarePlugin<C>(dict: {
[K in keyof C]: Schema<C[K]>;
}) {
const Config = schemaFromClass(PicMiddlewareConfig) as Schema<
const Config = schemaFromClass(PicMiddlewareConfig) as unknown as Schema<
PartialDeep<PicMiddlewareConfig & C>,
PicMiddlewareConfig & C
>;
......
......@@ -82,7 +82,7 @@ export const PicSourcePlugin = CreatePluginFactory(
export function PlainPicSourcePlugin<C>(dict: {
[K in keyof C]: Schema<C[K]>;
}) {
const Config = schemaFromClass(PicSourceConfig) as Schema<
const Config = schemaFromClass(PicSourceConfig) as unknown as Schema<
PartialDeep<PicSourceConfig & C>,
PicSourceConfig & C
>;
......
const path = require('path');
const packgeInfo = require('./package.json');
const { ESBuildMinifyPlugin } = require('esbuild-loader');
function externalsFromDep() {
return Object.fromEntries(
......@@ -43,4 +44,11 @@ module.exports = {
koishi: 'koishi',
...(packAll ? {} : externalsFromDep()),
},
optimization: {
minimizer: [
new ESBuildMinifyPlugin({
keepNames: true,
}),
],
},
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment