Skip to content

Commit

Permalink
refa: refactor to monorepo
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Jul 1, 2024
1 parent 253bd3f commit e116080
Show file tree
Hide file tree
Showing 11 changed files with 175 additions and 55 deletions.
58 changes: 22 additions & 36 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,51 +1,37 @@
{
"name": "koishi-plugin-im",
"version": "0.0.0",
"description": "IM for Koishi",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"files": [
"lib"
],
"contributors": [
"Shigma <[email protected]>"
"name": "@root/satori-im",
"private": true,
"type": "module",
"version": "1.0.0",
"workspaces": [
"packages/*"
],
"license": "MIT",
"homepage": "https://github.com/koishijs/koishi-plugin-im",
"repository": {
"type": "git",
"url": "https://github.com/koishijs/koishi-plugin-im.git"
},
"bugs": {
"url": "https://github.com/koishijs/koishi-plugin-im/issues"
},
"keywords": [
"bot",
"chatbot",
"koishi",
"plugin",
"im",
"chat",
"messenger",
"platform"
],
"scripts": {
"build": "atsc -b",
"lint": "eslint --ext=ts --cache"
"build": "yakumo build",
"lint": "eslint --cache",
"test": "yakumo mocha -r esbuild-register -t 10000",
"test:text": "shx rm -rf coverage && c8 -r text yarn test",
"test:json": "shx rm -rf coverage && c8 -r json yarn test",
"test:html": "shx rm -rf coverage && c8 -r html yarn test"
},
"devDependencies": {
"@cordisjs/eslint-config": "^1.1.1",
"@koishijs/plugin-server": "^3.2.1",
"@types/chai": "^4.3.14",
"@types/mocha": "^9.1.1",
"@types/node": "^20.11.30",
"atsc": "^2.0.1",
"c8": "^7.14.0",
"chai": "^4.4.1",
"esbuild": "^0.18.20",
"esbuild-register": "^3.5.0",
"eslint": "^8.57.0",
"koishi": "^4.17.5",
"mocha": "^9.2.2",
"shx": "^0.3.4",
"typescript": "^5.4.3",
"yakumo": "^1.0.0-beta.16",
"yakumo-esbuild": "^1.0.0-beta.6",
"yakumo-mocha": "^1.0.0-beta.2",
"yakumo-tsc": "^1.0.0-beta.4",
"yml-register": "^1.2.5"
},
"peerDependencies": {
"koishi": "^4.17.5"
}
}
5 changes: 5 additions & 0 deletions packages/im/client/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Context } from '@cordisjs/client'
import {} from '../src'

export default (ctx: Context) => {
}
11 changes: 11 additions & 0 deletions packages/im/client/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../../../tsconfig.client",
"include": [
".",
],
"references": [
{
"path": "../tsconfig.json",
},
],
}
48 changes: 48 additions & 0 deletions packages/im/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"name": "@satorijs/plugin-im",
"description": "IM for Satori",
"version": "0.0.0",
"type": "module",
"main": "lib/index.js",
"files": [
"lib",
"dist"
],
"author": "Shigma <[email protected]>",
"license": "MIT",
"scripts": {
"lint": "eslint src --ext .ts"
},
"repository": {
"type": "git",
"url": "git+https://github.com/koishijs/koishi-plugin-im.git",
"directory": "packages/im"
},
"bugs": {
"url": "https://github.com/koishijs/koishi-plugin-im/issues"
},
"keywords": [
"satori",
"plugin",
"webui",
"chat",
"im"
],
"cordis": {
"service": {
"required": [
"webui"
]
}
},
"peerDependencies": {
"@cordisjs/plugin-webui": "^0.1.7",
"@satorijs/core": "^4.1.1"
},
"devDependencies": {
"@cordisjs/client": "^0.1.7"
},
"dependencies": {
"cosmokit": "^1.6.2"
}
}
23 changes: 23 additions & 0 deletions packages/im/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Context, Schema } from '@satorijs/core'
import {} from '@cordisjs/plugin-webui'

export const name = 'im'

export const inject = {
required: ['webui'],
}

export interface Config {}

export const Config: Schema<Config> = Schema.object({})

export function apply(ctx: Context) {
ctx.webui.addEntry({
base: import.meta.url,
dev: '../client/index.ts',
prod: [
'../dist/index.js',
'../dist/style.css',
],
})
}
10 changes: 10 additions & 0 deletions packages/im/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../tsconfig.base",
"compilerOptions": {
"rootDir": "src",
"outDir": "lib",
},
"include": [
"src",
],
}
8 changes: 8 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
# koishi-plugin-im

[OSPP 2024 项目](https://summer-ospp.ac.cn/org/prodetail/2490f0533)

Koishi 作为聊天机器人底层基于名为 Satori 的协议开发,官方提供了超过 15 个聊天平台的适配。得益于 Satori 协议的通用性设计,开发者得以以更低的成本开发出跨平台、可扩展、高性能的聊天应用,并将机器人运行在世界上几乎所有聊天平台上。

然而,仅仅实现已有的聊天平台并不能完全发挥 Satori 协议的表达能力。因此,本项目希望设计一个运行在 Satori / Koishi 架构上的独立聊天平台。任何 Koishi 机器人的用户可以直接在网页或 App 中访问聊天界面,并与其他用户聊天。诚然,完成独立聊天平台是一个很大的工程,但基础设施的设计和代码将会由 Satori / Koishi 架构直接提供,本项目的参与者只需完成其中的上层部分。

本项目的呈现形式为名为 IM(Instant Message,即时通信)的 Koishi 插件。在任意 Koishi 应用安装此查看即可在 Koishi WebUI 中扩展出上述聊天平台。
Empty file removed src/index.ts
Empty file.
19 changes: 19 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"target": "es2022",
"module": "esnext",
"declaration": true,
"emitDeclarationOnly": true,
"composite": true,
"incremental": true,
"skipLibCheck": true,
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"strict": true,
"noImplicitAny": false,
"types": [
"node",
"yml-register/types",
],
},
}
19 changes: 19 additions & 0 deletions tsconfig.client.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"target": "es2022",
"module": "esnext",
"declaration": true,
"jsx": "preserve",
"noEmit": true,
"composite": true,
"incremental": true,
"skipLibCheck": true,
"esModuleInterop": true,
"moduleResolution": "bundler",
"strict": true,
"noImplicitAny": false,
"types": [
"@cordisjs/client/global",
],
},
}
29 changes: 10 additions & 19 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
{
"extends": "./tsconfig.base",
"compilerOptions": {
"baseUrl": ".",
"outDir": "lib",
"rootDir": "src",
"target": "es2022",
"module": "commonjs",
"declaration": true,
"composite": true,
"incremental": true,
"skipLibCheck": true,
"esModuleInterop": true,
"moduleResolution": "node",
"strictBindCallApply": true,
"jsx": "react-jsx",
"jsxImportSource": "@satorijs/element",
"types": [
"yml-register/types",
],
"paths": {
"@satorijs/plugin-*": [
"packages/*/src",
],
"*": [
"packages/*/src",
],
},
},
"include": [
"src",
],
"files": [],
}

0 comments on commit e116080

Please sign in to comment.