@koishi-ce/client 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -0
- package/app/home/home.vue +4 -0
- package/app/home/index.ts +4 -0
- package/app/home/welcome.en-US.yml +4 -0
- package/app/home/welcome.vue +16 -6
- package/app/home/welcome.zh-CN.yml +4 -0
- package/app/index.scss +4 -0
- package/app/index.ts +12 -2
- package/app/layout/header.vue +16 -4
- package/app/layout/index.ts +4 -0
- package/app/layout/layout.vue +8 -1
- package/app/layout/menu-item.vue +7 -1
- package/app/settings/index.ts +4 -0
- package/app/settings/settings.vue +10 -4
- package/app/settings/theme.vue +8 -1
- package/app/shims.d.ts +3 -0
- package/app/status/index.ts +4 -0
- package/app/status/loading.vue +8 -1
- package/app/status/status.vue +4 -0
- package/app/styles/element.scss +4 -0
- package/app/styles/hc.scss +4 -0
- package/app/styles/index.scss +4 -0
- package/app/styles/index.ts +4 -0
- package/app/styles/layout.scss +4 -0
- package/app/theme/activity/button.vue +8 -1
- package/app/theme/activity/index.vue +16 -4
- package/app/theme/activity/item.vue +22 -4
- package/app/theme/activity/separator.vue +48 -12
- package/app/theme/activity/utils.ts +4 -0
- package/app/theme/blank.vue +4 -0
- package/app/theme/index.ts +9 -1
- package/app/theme/index.vue +7 -1
- package/app/theme/menu/index.vue +4 -0
- package/app/theme/menu/menu-item.vue +14 -4
- package/app/theme/menu/menu.vue +13 -4
- package/app/theme/status.vue +4 -0
- package/client/components/chat/image.vue +4 -0
- package/client/components/chat/overlay.vue +34 -8
- package/client/components/chat/utils.ts +4 -0
- package/client/components/common/index.ts +4 -0
- package/client/components/common/k-button.vue +4 -0
- package/client/components/common/k-hint.vue +7 -1
- package/client/components/common/k-tab.vue +4 -0
- package/client/components/dynamic.vue +6 -1
- package/client/components/icons/activity/default.vue +4 -0
- package/client/components/icons/activity/ellipsis.vue +4 -0
- package/client/components/icons/activity/home.vue +4 -0
- package/client/components/icons/activity/moon.vue +4 -0
- package/client/components/icons/activity/settings.vue +4 -0
- package/client/components/icons/activity/sun.vue +4 -0
- package/client/components/icons/index.ts +11 -2
- package/client/components/icons/style.scss +4 -0
- package/client/components/icons/svg/arrow-left.vue +4 -0
- package/client/components/icons/svg/arrow-right.vue +4 -0
- package/client/components/icons/svg/box-open.vue +4 -0
- package/client/components/icons/svg/check-full.vue +4 -0
- package/client/components/icons/svg/chevron-down.vue +4 -0
- package/client/components/icons/svg/chevron-left.vue +4 -0
- package/client/components/icons/svg/chevron-right.vue +4 -0
- package/client/components/icons/svg/chevron-up.vue +4 -0
- package/client/components/icons/svg/clipboard-list.vue +4 -0
- package/client/components/icons/svg/edit.vue +4 -0
- package/client/components/icons/svg/exclamation-full.vue +4 -0
- package/client/components/icons/svg/expand.vue +4 -0
- package/client/components/icons/svg/file-archive.vue +4 -0
- package/client/components/icons/svg/filter.vue +4 -0
- package/client/components/icons/svg/github.vue +4 -0
- package/client/components/icons/svg/gitlab.vue +4 -0
- package/client/components/icons/svg/info-full.vue +4 -0
- package/client/components/icons/svg/koishi.vue +4 -0
- package/client/components/icons/svg/link.vue +4 -0
- package/client/components/icons/svg/paper-plane.vue +4 -0
- package/client/components/icons/svg/question-empty.vue +4 -0
- package/client/components/icons/svg/redo.vue +4 -0
- package/client/components/icons/svg/search-minus.vue +4 -0
- package/client/components/icons/svg/search-plus.vue +4 -0
- package/client/components/icons/svg/search.vue +4 -0
- package/client/components/icons/svg/star-empty.vue +4 -0
- package/client/components/icons/svg/star-full.vue +4 -0
- package/client/components/icons/svg/start.vue +4 -0
- package/client/components/icons/svg/tag.vue +4 -0
- package/client/components/icons/svg/times-full.vue +4 -0
- package/client/components/icons/svg/tools.vue +4 -0
- package/client/components/icons/svg/undo.vue +4 -0
- package/client/components/icons/svg/user.vue +4 -0
- package/client/components/index.ts +12 -2
- package/client/components/layout/card.vue +4 -0
- package/client/components/layout/content.vue +4 -0
- package/client/components/layout/empty.vue +4 -0
- package/client/components/layout/index.ts +4 -0
- package/client/components/layout/tab-group.vue +4 -0
- package/client/components/layout/tab-item.vue +4 -0
- package/client/components/link.ts +9 -2
- package/client/components/perms.vue +26 -5
- package/client/components/slot.ts +23 -4
- package/client/context.ts +16 -4
- package/client/data.ts +61 -26
- package/client/index.ts +6 -1
- package/client/plugins/action.ts +50 -13
- package/client/plugins/i18n.ts +4 -0
- package/client/plugins/loader.ts +71 -45
- package/client/plugins/router.ts +38 -11
- package/client/plugins/setting.ts +49 -12
- package/client/plugins/theme.ts +25 -6
- package/client/shims.d.ts +3 -0
- package/client/utils.ts +11 -2
- package/global.d.ts +4 -0
- package/lib/bin.mjs +7 -3
- package/lib/{client-CaTn_gVG.mjs → client-C97iYPCr.mjs} +1 -1
- package/lib/index.mjs +1 -1
- package/lib/{src-lTfcJ1xA.mjs → src-BOakssV3.mjs} +8 -2
- package/package.json +6 -2
- package/src/bin.ts +13 -3
- package/src/index.ts +72 -14
- package/src/yaml.ts +3 -0
package/src/index.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
2
|
+
// Copyright (c) 2019-present Shigma and Koishijs contributors.
|
|
3
|
+
// Copyright (c) 2026-present Koishi-CE contributors.
|
|
4
|
+
|
|
1
5
|
/**
|
|
2
6
|
* @koishi-ce/client 构建入口。
|
|
3
7
|
*
|
|
@@ -10,6 +14,7 @@
|
|
|
10
14
|
import { existsSync } from "node:fs";
|
|
11
15
|
import { mkdir, rm } from "node:fs/promises";
|
|
12
16
|
import { resolve } from "node:path";
|
|
17
|
+
import { pathToFileURL } from "node:url";
|
|
13
18
|
import vue from "@vitejs/plugin-vue";
|
|
14
19
|
import * as vite from "vite";
|
|
15
20
|
import { yaml } from "./yaml.ts";
|
|
@@ -28,21 +33,32 @@ interface BuildResult {
|
|
|
28
33
|
// 将全部工作区包名映射到其源码目录,行为对齐根 tsconfig 的 paths 别名。
|
|
29
34
|
// 没有被任何工作区包依赖的插件(如 plugin-logger)不会出现在 node_modules
|
|
30
35
|
// 的链接里,bundler 无法按包名解析,必须显式提供这层映射。
|
|
31
|
-
async function collectWorkspaceAliases(): Promise<
|
|
36
|
+
async function collectWorkspaceAliases(): Promise<
|
|
37
|
+
Record<string, string>
|
|
38
|
+
> {
|
|
32
39
|
// 源码形态(src/)与产物形态(lib/)都在包根下一级,上跳四级到仓库根一致
|
|
33
|
-
const repoRoot = resolve(
|
|
34
|
-
|
|
40
|
+
const repoRoot = resolve(
|
|
41
|
+
import.meta.dir,
|
|
42
|
+
"../../../..",
|
|
43
|
+
).replace(/\\/g, "/");
|
|
44
|
+
const manifest = await Bun.file(
|
|
45
|
+
`${repoRoot}/package.json`,
|
|
46
|
+
).json();
|
|
35
47
|
const aliases: Record<string, string> = {};
|
|
36
48
|
for (const pattern of manifest.workspaces ?? []) {
|
|
37
49
|
// scanSync 产出的相对路径在 Windows 上是反斜杠,统一归一化为正斜杠
|
|
38
|
-
const files = new Bun.Glob(
|
|
50
|
+
const files = new Bun.Glob(
|
|
51
|
+
`${pattern}/package.json`,
|
|
52
|
+
).scanSync({
|
|
39
53
|
cwd: repoRoot,
|
|
40
54
|
});
|
|
41
55
|
for (const file of files) {
|
|
42
56
|
const rel = file.replaceAll("\\", "/");
|
|
43
57
|
const dir = `${repoRoot}/${rel.slice(0, -"/package.json".length)}`;
|
|
44
58
|
try {
|
|
45
|
-
const { name } = await Bun.file(
|
|
59
|
+
const { name } = await Bun.file(
|
|
60
|
+
`${dir}/package.json`,
|
|
61
|
+
).json();
|
|
46
62
|
if (!name) continue;
|
|
47
63
|
// 控制台前端语境下,裸包名对到浏览器端入口(替代上游 lib 的 browser
|
|
48
64
|
// 导出条件);`<name>/src` 子路径对到源码目录,供共享代码引用;
|
|
@@ -51,9 +67,13 @@ async function collectWorkspaceAliases(): Promise<Record<string, string>> {
|
|
|
51
67
|
// 上游与 npm 产物的 exports 均未声明它,同样靠仓库内别名解析)。
|
|
52
68
|
// 子路径键必须先插入——别名解析按插入序取首个命中项
|
|
53
69
|
const clientEntry = `${dir}/client/index.ts`;
|
|
54
|
-
if (existsSync(`${dir}/src`))
|
|
55
|
-
|
|
56
|
-
|
|
70
|
+
if (existsSync(`${dir}/src`))
|
|
71
|
+
aliases[`${name}/src`] = `${dir}/src`;
|
|
72
|
+
if (existsSync(clientEntry))
|
|
73
|
+
aliases[`${name}/client`] = clientEntry;
|
|
74
|
+
aliases[name] = existsSync(clientEntry)
|
|
75
|
+
? clientEntry
|
|
76
|
+
: `${dir}/src`;
|
|
57
77
|
} catch {}
|
|
58
78
|
}
|
|
59
79
|
}
|
|
@@ -67,7 +87,10 @@ const workspaceAliases = await collectWorkspaceAliases();
|
|
|
67
87
|
// 类型面由根 tsconfig.client.json 的 paths 解析到 schemastery-vue-client.ts
|
|
68
88
|
const runtimeShimPath = (
|
|
69
89
|
workspaceAliases["@koishi-ce/components"] ?? ""
|
|
70
|
-
).replace(
|
|
90
|
+
).replace(
|
|
91
|
+
/client\/index\.ts$/,
|
|
92
|
+
"client/schemastery-vue-runtime.ts",
|
|
93
|
+
);
|
|
71
94
|
|
|
72
95
|
/**
|
|
73
96
|
* 构建单个 webui 插件的前端产物。
|
|
@@ -75,9 +98,23 @@ const runtimeShimPath = (
|
|
|
75
98
|
* @param root 插件目录(无 `client/` 子目录时视为该插件没有前端,直接跳过)
|
|
76
99
|
* @param config 额外的 vite 配置,逐层合并覆盖下方默认值
|
|
77
100
|
*/
|
|
78
|
-
export async function build(
|
|
101
|
+
export async function build(
|
|
102
|
+
root: string,
|
|
103
|
+
config: vite.UserConfig = {},
|
|
104
|
+
) {
|
|
79
105
|
if (!existsSync(`${root}/client`)) return;
|
|
80
106
|
|
|
107
|
+
// 插件可自带 `build/client.ts` 导出额外的 vite 配置覆盖下方默认值
|
|
108
|
+
// (vite 只自动发现 vite.config.*,不会加载该路径,须在此显式接线),
|
|
109
|
+
// 如 analytics 的 fuck-echarts 符号遮蔽修补
|
|
110
|
+
const overridePath = `${root}/build/client.ts`;
|
|
111
|
+
if (existsSync(overridePath)) {
|
|
112
|
+
const mod = await import(
|
|
113
|
+
pathToFileURL(overridePath).href
|
|
114
|
+
);
|
|
115
|
+
config = vite.mergeConfig(config, mod.default ?? mod);
|
|
116
|
+
}
|
|
117
|
+
|
|
81
118
|
// 产物约定:固定写入插件目录下的 dist/,清空后重建
|
|
82
119
|
const outDir = `${root}/dist`;
|
|
83
120
|
if (existsSync(outDir)) {
|
|
@@ -110,7 +147,9 @@ export async function build(root: string, config: vite.UserConfig = {}) {
|
|
|
110
147
|
// 仓库侧无法根治,直接静默
|
|
111
148
|
onwarn(warning, warn) {
|
|
112
149
|
if (
|
|
113
|
-
warning.message.includes(
|
|
150
|
+
warning.message.includes(
|
|
151
|
+
"is being imported multiple times",
|
|
152
|
+
)
|
|
114
153
|
) {
|
|
115
154
|
return;
|
|
116
155
|
}
|
|
@@ -130,7 +169,16 @@ export async function build(root: string, config: vite.UserConfig = {}) {
|
|
|
130
169
|
},
|
|
131
170
|
},
|
|
132
171
|
plugins: [
|
|
133
|
-
|
|
172
|
+
// 钉死剥离模板注释:注释写在 template 根元素之前时,SFC 会被
|
|
173
|
+
// 编译成多根 fragment,Vue 随之禁用 attribute 透传(外部传入的
|
|
174
|
+
// class 落不到 svg 上,侧栏图标因此丢掉尺寸类);生产语义本就
|
|
175
|
+
// 应剥注释,这里显式钉死,避免随 NODE_ENV 漂移。dev server
|
|
176
|
+
// 同步钉死,保证开发态与产物行为一致
|
|
177
|
+
vue({
|
|
178
|
+
template: {
|
|
179
|
+
compilerOptions: { comments: false },
|
|
180
|
+
},
|
|
181
|
+
}),
|
|
134
182
|
yaml(),
|
|
135
183
|
(
|
|
136
184
|
await import("unocss/vite")
|
|
@@ -157,7 +205,8 @@ export async function build(root: string, config: vite.UserConfig = {}) {
|
|
|
157
205
|
// 源码发布的组件库),其内部以 npm 名引用组件库;重定向到
|
|
158
206
|
// 本仓库同版本(1.5.22)components 源码,避免 npm 版整套
|
|
159
207
|
// 组件库被打进插件产物
|
|
160
|
-
"@koishijs/components":
|
|
208
|
+
"@koishijs/components":
|
|
209
|
+
workspaceAliases["@koishi-ce/components"],
|
|
161
210
|
// 虚拟子路径的运行时载体(补齐真实包缺失的 SchemaBase
|
|
162
211
|
// 具名导出);类型面由 tsconfig.client.json 的 paths
|
|
163
212
|
// 解析到 schemastery-vue-client.ts
|
|
@@ -228,7 +277,16 @@ export async function createServer(
|
|
|
228
277
|
},
|
|
229
278
|
},
|
|
230
279
|
plugins: [
|
|
231
|
-
|
|
280
|
+
// 钉死剥离模板注释:注释写在 template 根元素之前时,SFC 会被
|
|
281
|
+
// 编译成多根 fragment,Vue 随之禁用 attribute 透传(外部传入的
|
|
282
|
+
// class 落不到 svg 上,侧栏图标因此丢掉尺寸类);生产语义本就
|
|
283
|
+
// 应剥注释,这里显式钉死,避免随 NODE_ENV 漂移。dev server
|
|
284
|
+
// 同步钉死,保证开发态与产物行为一致
|
|
285
|
+
vue({
|
|
286
|
+
template: {
|
|
287
|
+
compilerOptions: { comments: false },
|
|
288
|
+
},
|
|
289
|
+
}),
|
|
232
290
|
yaml(),
|
|
233
291
|
(await import("unocss/vite")).default({
|
|
234
292
|
presets: [
|