@koishi-ce/plugin-config 1.0.4 → 1.0.5

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/lib/index.mjs CHANGED
@@ -1,12 +1,8 @@
1
- import { createRequire } from "node:module";
2
1
  import { resolve } from "node:path";
3
2
  import { Context, Logger, Schema, remove } from "@koishi-ce/koishi";
4
3
  import { DataService } from "@koishi-ce/console";
5
- import { LocalScanner, getPluginShortname } from "@koishi-ce/registry";
4
+ import { LocalScanner, getPluginShortname, isResidentInCache } from "@koishi-ce/registry";
6
5
  import { Loader } from "@koishi-ce/loader";
7
- //#region \0rolldown/runtime.js
8
- var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
9
- //#endregion
10
6
  //#region src/shared/packages.ts
11
7
  /**
12
8
  * 插件包元数据提供器(服务端共享实现)。
@@ -486,8 +482,7 @@ var PackageScanner = class extends LocalScanner {
486
482
  async parsePackage(name) {
487
483
  const result = await super.parsePackage(name);
488
484
  try {
489
- const entry = __require.resolve(name);
490
- if (__require.cache[entry]) {
485
+ if (isResidentInCache(name)) {
491
486
  const shortname = getPluginShortname(name);
492
487
  this.service.cache[shortname] = await this.service.parseExports(shortname);
493
488
  }
package/package.json CHANGED
@@ -1,78 +1,78 @@
1
1
  {
2
- "name": "@koishi-ce/plugin-config",
3
- "description": "Manage your bots and plugins with console",
4
- "version": "1.0.4",
5
- "type": "module",
6
- "main": "lib/index.mjs",
7
- "types": "lib/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "source": "./src/index.ts",
11
- "types": "./lib/index.d.ts",
12
- "import": "./lib/index.mjs",
13
- "default": "./lib/index.mjs"
14
- },
15
- "./shared": {
16
- "import": "./lib/shared/index.mjs",
17
- "default": "./lib/shared/index.mjs"
18
- },
19
- "./src/*": "./src/*",
20
- "./package.json": "./package.json"
21
- },
22
- "files": [
23
- "lib",
24
- "dist",
25
- "src"
26
- ],
27
- "contributors": [
28
- "Shigma <shigma10826@gmail.com>",
29
- "Oppenheymu <oppenheymu@gmail.com>"
30
- ],
31
- "license": "AGPL-3.0",
32
- "repository": {
33
- "type": "git",
34
- "url": "git+https://github.com/Koishi-CE/koishi.git",
35
- "directory": "plugins/webui/config"
36
- },
37
- "bugs": {
38
- "url": "https://github.com/Koishi-CE/koishi/issues"
39
- },
40
- "homepage": "https://koishi.chat/plugins/console/config.html",
41
- "keywords": [
42
- "bot",
43
- "chatbot",
44
- "koishi",
45
- "plugin",
46
- "config",
47
- "manager",
48
- "server"
49
- ],
50
- "koishi": {
51
- "public": [
52
- "dist"
53
- ],
54
- "description": {
55
- "en": "Configure your plugins with console",
56
- "zh": "使用控制台查看、配置你的插件"
57
- },
58
- "service": {
59
- "required": [
60
- "console"
61
- ]
62
- }
63
- },
64
- "peerDependencies": {
65
- "@koishijs/loader": "^4.6.11",
66
- "@koishijs/plugin-console": "^5.30.11",
67
- "koishi": "^4.18.11"
68
- },
69
- "devDependencies": {
70
- "@koishi-ce/client": "^1.0.1",
71
- "@koishi-ce/plugin-hmr": "^1.0.2"
72
- },
73
- "dependencies": {
74
- "@koishi-ce/console": "^1.0.0",
75
- "@koishi-ce/loader": "^1.0.2",
76
- "@koishi-ce/registry": "^1.0.3"
77
- }
2
+ "name": "@koishi-ce/plugin-config",
3
+ "description": "Manage your bots and plugins with console",
4
+ "version": "1.0.5",
5
+ "type": "module",
6
+ "main": "lib/index.mjs",
7
+ "types": "lib/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "source": "./src/index.ts",
11
+ "types": "./lib/index.d.ts",
12
+ "import": "./lib/index.mjs",
13
+ "default": "./lib/index.mjs"
14
+ },
15
+ "./shared": {
16
+ "import": "./lib/shared/index.mjs",
17
+ "default": "./lib/shared/index.mjs"
18
+ },
19
+ "./src/*": "./src/*",
20
+ "./package.json": "./package.json"
21
+ },
22
+ "files": [
23
+ "lib",
24
+ "dist",
25
+ "src"
26
+ ],
27
+ "contributors": [
28
+ "Shigma <shigma10826@gmail.com>",
29
+ "Oppenheymu <oppenheymu@gmail.com>"
30
+ ],
31
+ "license": "AGPL-3.0",
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "git+https://github.com/Koishi-CE/koishi.git",
35
+ "directory": "plugins/webui/config"
36
+ },
37
+ "bugs": {
38
+ "url": "https://github.com/Koishi-CE/koishi/issues"
39
+ },
40
+ "homepage": "https://koishi.chat/plugins/console/config.html",
41
+ "keywords": [
42
+ "bot",
43
+ "chatbot",
44
+ "koishi",
45
+ "plugin",
46
+ "config",
47
+ "manager",
48
+ "server"
49
+ ],
50
+ "koishi": {
51
+ "public": [
52
+ "dist"
53
+ ],
54
+ "description": {
55
+ "en": "Configure your plugins with console",
56
+ "zh": "使用控制台查看、配置你的插件"
57
+ },
58
+ "service": {
59
+ "required": [
60
+ "console"
61
+ ]
62
+ }
63
+ },
64
+ "peerDependencies": {
65
+ "@koishijs/loader": "^4.6.11",
66
+ "@koishijs/plugin-console": "^5.30.11",
67
+ "koishi": "^4.18.11"
68
+ },
69
+ "devDependencies": {
70
+ "@koishi-ce/client": "workspace:*",
71
+ "@koishi-ce/plugin-hmr": "workspace:*"
72
+ },
73
+ "dependencies": {
74
+ "@koishi-ce/console": "workspace:*",
75
+ "@koishi-ce/loader": "workspace:*",
76
+ "@koishi-ce/registry": "workspace:*"
77
+ }
78
78
  }
@@ -10,7 +10,11 @@
10
10
  */
11
11
  import { resolve } from "node:path";
12
12
  import { Logger } from "@koishi-ce/koishi";
13
- import { getPluginShortname, LocalScanner } from "@koishi-ce/registry";
13
+ import {
14
+ getPluginShortname,
15
+ isResidentInCache,
16
+ LocalScanner,
17
+ } from "@koishi-ce/registry";
14
18
  import * as shared from "../shared/index.ts";
15
19
 
16
20
  const logger = new Logger("config");
@@ -40,10 +44,13 @@ class PackageScanner extends LocalScanner {
40
44
  override async parsePackage(name: string) {
41
45
  const result = await super.parsePackage(name);
42
46
  try {
43
- // require.resolve(name) 的结果可能与 require.resolve(path) 不同,
44
- // 因为 tsconfig-paths 可能以不同方式解析路径
45
- const entry = require.resolve(name);
46
- if (require.cache[entry]) {
47
+ // 驻留判断不能用 require.resolve(name):裸名形态可能已被市场
48
+ // 安装前的探测写入 Bun 的父目录快照缓存(装完插件后同进程内
49
+ // 必然失败,生产上报 "failed to resolve" 假警的根因)。改用
50
+ // isResidentInCache:纯 fs 取包目录 + require.cache 前缀扫描,
51
+ // 全程不触碰解析 API(比「入口模块驻留」稍宽:包目录下任何
52
+ // 模块驻留即视为可预热,多一次 parseExports 无副作用)。
53
+ if (isResidentInCache(name)) {
47
54
  const shortname = getPluginShortname(name);
48
55
  this.service.cache[shortname] =
49
56
  await this.service.parseExports(shortname);