diff --git a/.gitignore b/.gitignore index dab2e6e..df9a223 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,6 @@ node_modules .env -pnpm-lock.yaml \ No newline at end of file +pnpm-lock.yaml + +dist \ No newline at end of file diff --git a/bun.config.ts b/bun.config.ts new file mode 100644 index 0000000..0ebeef5 --- /dev/null +++ b/bun.config.ts @@ -0,0 +1,22 @@ +import { resolvePath } from '@kevisual/use-config'; +import { execSync } from 'node:child_process'; + +const entry = 'src/index.ts'; +const naming = 'app'; +const external: string[] = []; +/** + * @type {import('bun').BuildConfig} + */ +await Bun.build({ + target: 'browser', + format: 'esm', + entrypoints: [resolvePath(entry, { meta: import.meta })], + outdir: resolvePath('./dist', { meta: import.meta }), + naming: { + entry: `${naming}.js`, + }, + external, +}); + +const dts = 'dts -i src/index.ts -o app.d.ts'; +execSync(dts); \ No newline at end of file diff --git a/package.json b/package.json index a783067..a5a5db2 100644 --- a/package.json +++ b/package.json @@ -2,13 +2,14 @@ "name": "@kevisual/app", "version": "0.0.2", "description": "", - "main": "index.js", "scripts": { - "dev": "bun" + "dev": "bun", + "build": "bun bun.config.ts" }, "files": [ "src", - "mod.ts" + "mod.ts", + "dist" ], "publishConfig": { "access": "public" @@ -16,14 +17,23 @@ "keywords": [], "author": "abearxiong (https://www.xiongxiao.me)", "license": "MIT", - "packageManager": "pnpm@10.14.0", + "packageManager": "pnpm@10.26.0", "type": "module", "dependencies": { "@kevisual/ai": "^0.0.19", "@kevisual/context": "^0.0.4", - "@kevisual/query": "^0.0.31", - "@kevisual/router": "^0.0.36", + "@kevisual/query": "^0.0.32", + "@kevisual/router": "^0.0.39", "@kevisual/use-config": "^1.0.21", - "mitt": "^3.0.1" + "mitt": "^3.0.1", + "nanoid": "^5.1.6" + }, + "devDependencies": { + "@types/bun": "^1.3.4", + "@types/node": "^25.0.3" + }, + "exports": { + ".": "./dist/app.js", + "./mod.ts": "./mod.ts" } } \ No newline at end of file diff --git a/src/app.ts b/src/app.ts index 600859f..59419bb 100644 --- a/src/app.ts +++ b/src/app.ts @@ -1,4 +1,4 @@ -import { QueryRouterServer } from '@kevisual/router' +import { QueryRouterServer } from '@kevisual/router/src/route.ts' import { use } from '@kevisual/context' import { Query } from '@kevisual/query' import { Kevisual, ChatProviderMap } from '@kevisual/ai' @@ -119,8 +119,8 @@ export class App { } return config; } - async chat(message: string) { - const routes = this.router.getList(); + async chat(message: string, options?: { filter?: (data?: any) => boolean }) { + const routes = this.router.getList(options?.filter); let v = ''; if (routes.length > 0) { diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..349bda6 --- /dev/null +++ b/src/index.ts @@ -0,0 +1 @@ +export * from './app.ts' \ No newline at end of file