vite-plugin-aipanel 1.3.4 → 1.3.6
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/es/core/framework.d.ts +19 -3
- package/es/core/framework.mjs +15 -1
- package/es/inspectors/vue.d.ts +3 -0
- package/es/inspectors/vue.mjs +9 -5
- package/lib/core/framework.cjs +17 -2
- package/lib/core/framework.d.ts +19 -3
- package/lib/inspectors/vue.cjs +9 -5
- package/lib/inspectors/vue.d.ts +3 -0
- package/package.json +5 -5
package/es/core/framework.d.ts
CHANGED
|
@@ -1,14 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 构建期框架检测:从 Vite 插件列表推断项目框架。
|
|
3
3
|
* 依据官方插件命名约定(@vitejs/plugin-vue → "vite:vue*",plugin-react / plugin-react-swc →
|
|
4
4
|
* "vite:react*"),用于门控 Vue DevTools 桥注入与各框架 inspector 集成;
|
|
5
5
|
* 标识复用 INSPECTOR_ADAPTER_IDS,与运行时适配器注册表对齐。
|
|
6
6
|
*/
|
|
7
|
-
import type {
|
|
7
|
+
import type { Plugin } from "vite";
|
|
8
8
|
import { INSPECTOR_ADAPTER_IDS } from "@aipanel/core";
|
|
9
9
|
export type ViteFramework = (typeof INSPECTOR_ADAPTER_IDS)[keyof typeof INSPECTOR_ADAPTER_IDS];
|
|
10
|
+
/**
|
|
11
|
+
* 框架判定所需的配置形态:configResolved 拿到的是已解析配置(ResolvedConfig),
|
|
12
|
+
* apply 阶段(Vite 解析插件列表时)拿到的是用户原始配置(UserConfig),两者都满足。
|
|
13
|
+
*/
|
|
14
|
+
export interface FrameworkDetectionConfig {
|
|
15
|
+
readonly plugins?: readonly unknown[];
|
|
16
|
+
}
|
|
10
17
|
/**
|
|
11
18
|
* 检测项目框架:vue / react 同时存在时以 vue 优先(与运行时适配器解析顺序一致);
|
|
12
19
|
* 无法识别(solid、svelte、纯原生等)返回 null,调用方按保守策略处理。
|
|
13
20
|
*/
|
|
14
|
-
export declare function detectViteFramework(config:
|
|
21
|
+
export declare function detectViteFramework(config: FrameworkDetectionConfig): ViteFramework | null;
|
|
22
|
+
/**
|
|
23
|
+
* 把构建期插件收窄到框架判定通过的项目,并保留插件原有的 apply 条件(如仅 dev server)。
|
|
24
|
+
*
|
|
25
|
+
* 只能在这一步拦截:Vite 解析插件列表时即调用 apply,此时拿到的是用户原始配置;
|
|
26
|
+
* 一旦插件被注册,第三方注入插件(unplugin-vue-inspector 会在 index.html 注入依赖 vue
|
|
27
|
+
* 的运行时)在 configResolved 阶段已撤销不了,React 等未安装 vue 的项目会直接报
|
|
28
|
+
* `Failed to resolve import "vue"`。框架判定与 configResolved 侧共用 detectViteFramework。
|
|
29
|
+
*/
|
|
30
|
+
export declare function restrictPluginsToFramework(plugins: Plugin[], accepts: (framework: ViteFramework | null) => boolean): Plugin[];
|
package/es/core/framework.mjs
CHANGED
|
@@ -22,6 +22,20 @@ function detectViteFramework(config) {
|
|
|
22
22
|
}
|
|
23
23
|
return null;
|
|
24
24
|
}
|
|
25
|
+
function restrictPluginsToFramework(plugins, accepts) {
|
|
26
|
+
return plugins.map((plugin) => {
|
|
27
|
+
const inner = plugin.apply;
|
|
28
|
+
return {
|
|
29
|
+
...plugin,
|
|
30
|
+
apply: (config, env) => {
|
|
31
|
+
if (!accepts(detectViteFramework(config))) return false;
|
|
32
|
+
if (!inner) return true;
|
|
33
|
+
return typeof inner === "function" ? inner(config, env) : inner === env.command;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
}
|
|
25
38
|
export {
|
|
26
|
-
detectViteFramework
|
|
39
|
+
detectViteFramework,
|
|
40
|
+
restrictPluginsToFramework
|
|
27
41
|
};
|
package/es/inspectors/vue.d.ts
CHANGED
|
@@ -3,5 +3,8 @@ import type { InspectorIntegration } from "./types";
|
|
|
3
3
|
* Vue 集成:注入 unplugin-vue-inspector 运行时。
|
|
4
4
|
* 常驻但默认不启用(enabled: false),由挂件进入选择模式时开启;
|
|
5
5
|
* 同时隐藏其自带的切换按钮与快捷键,避免与挂件交互冲突。
|
|
6
|
+
*
|
|
7
|
+
* 只对 Vue 项目注册:该插件会向 index.html 注入依赖 vue 的运行时,注册到未安装 vue 的
|
|
8
|
+
* 项目(React 等)会让浏览器直接报 Failed to resolve import "vue"。
|
|
6
9
|
*/
|
|
7
10
|
export declare const vueInspectorIntegration: InspectorIntegration;
|
package/es/inspectors/vue.mjs
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import Inspector from "unplugin-vue-inspector/vite";
|
|
2
2
|
import { INSPECTOR_ADAPTER_IDS } from "@aipanel/core";
|
|
3
|
+
import { restrictPluginsToFramework } from "../core/framework.mjs";
|
|
3
4
|
const vueInspectorIntegration = {
|
|
4
5
|
id: INSPECTOR_ADAPTER_IDS.vue,
|
|
5
|
-
plugins: () =>
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
plugins: () => restrictPluginsToFramework(
|
|
7
|
+
Inspector({
|
|
8
|
+
enabled: false,
|
|
9
|
+
toggleButtonVisibility: "never",
|
|
10
|
+
toggleComboKey: false
|
|
11
|
+
}),
|
|
12
|
+
(framework) => framework === INSPECTOR_ADAPTER_IDS.vue
|
|
13
|
+
)
|
|
10
14
|
};
|
|
11
15
|
export {
|
|
12
16
|
vueInspectorIntegration
|
package/lib/core/framework.cjs
CHANGED
|
@@ -17,7 +17,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
var framework_exports = {};
|
|
19
19
|
__export(framework_exports, {
|
|
20
|
-
detectViteFramework: () => detectViteFramework
|
|
20
|
+
detectViteFramework: () => detectViteFramework,
|
|
21
|
+
restrictPluginsToFramework: () => restrictPluginsToFramework
|
|
21
22
|
});
|
|
22
23
|
module.exports = __toCommonJS(framework_exports);
|
|
23
24
|
var import_core = require("@aipanel/core");
|
|
@@ -44,7 +45,21 @@ function detectViteFramework(config) {
|
|
|
44
45
|
}
|
|
45
46
|
return null;
|
|
46
47
|
}
|
|
48
|
+
function restrictPluginsToFramework(plugins, accepts) {
|
|
49
|
+
return plugins.map((plugin) => {
|
|
50
|
+
const inner = plugin.apply;
|
|
51
|
+
return {
|
|
52
|
+
...plugin,
|
|
53
|
+
apply: (config, env) => {
|
|
54
|
+
if (!accepts(detectViteFramework(config))) return false;
|
|
55
|
+
if (!inner) return true;
|
|
56
|
+
return typeof inner === "function" ? inner(config, env) : inner === env.command;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
}
|
|
47
61
|
// Annotate the CommonJS export names for ESM import in node:
|
|
48
62
|
0 && (module.exports = {
|
|
49
|
-
detectViteFramework
|
|
63
|
+
detectViteFramework,
|
|
64
|
+
restrictPluginsToFramework
|
|
50
65
|
});
|
package/lib/core/framework.d.ts
CHANGED
|
@@ -1,14 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 构建期框架检测:从 Vite 插件列表推断项目框架。
|
|
3
3
|
* 依据官方插件命名约定(@vitejs/plugin-vue → "vite:vue*",plugin-react / plugin-react-swc →
|
|
4
4
|
* "vite:react*"),用于门控 Vue DevTools 桥注入与各框架 inspector 集成;
|
|
5
5
|
* 标识复用 INSPECTOR_ADAPTER_IDS,与运行时适配器注册表对齐。
|
|
6
6
|
*/
|
|
7
|
-
import type {
|
|
7
|
+
import type { Plugin } from "vite";
|
|
8
8
|
import { INSPECTOR_ADAPTER_IDS } from "@aipanel/core";
|
|
9
9
|
export type ViteFramework = (typeof INSPECTOR_ADAPTER_IDS)[keyof typeof INSPECTOR_ADAPTER_IDS];
|
|
10
|
+
/**
|
|
11
|
+
* 框架判定所需的配置形态:configResolved 拿到的是已解析配置(ResolvedConfig),
|
|
12
|
+
* apply 阶段(Vite 解析插件列表时)拿到的是用户原始配置(UserConfig),两者都满足。
|
|
13
|
+
*/
|
|
14
|
+
export interface FrameworkDetectionConfig {
|
|
15
|
+
readonly plugins?: readonly unknown[];
|
|
16
|
+
}
|
|
10
17
|
/**
|
|
11
18
|
* 检测项目框架:vue / react 同时存在时以 vue 优先(与运行时适配器解析顺序一致);
|
|
12
19
|
* 无法识别(solid、svelte、纯原生等)返回 null,调用方按保守策略处理。
|
|
13
20
|
*/
|
|
14
|
-
export declare function detectViteFramework(config:
|
|
21
|
+
export declare function detectViteFramework(config: FrameworkDetectionConfig): ViteFramework | null;
|
|
22
|
+
/**
|
|
23
|
+
* 把构建期插件收窄到框架判定通过的项目,并保留插件原有的 apply 条件(如仅 dev server)。
|
|
24
|
+
*
|
|
25
|
+
* 只能在这一步拦截:Vite 解析插件列表时即调用 apply,此时拿到的是用户原始配置;
|
|
26
|
+
* 一旦插件被注册,第三方注入插件(unplugin-vue-inspector 会在 index.html 注入依赖 vue
|
|
27
|
+
* 的运行时)在 configResolved 阶段已撤销不了,React 等未安装 vue 的项目会直接报
|
|
28
|
+
* `Failed to resolve import "vue"`。框架判定与 configResolved 侧共用 detectViteFramework。
|
|
29
|
+
*/
|
|
30
|
+
export declare function restrictPluginsToFramework(plugins: Plugin[], accepts: (framework: ViteFramework | null) => boolean): Plugin[];
|
package/lib/inspectors/vue.cjs
CHANGED
|
@@ -32,13 +32,17 @@ __export(vue_exports, {
|
|
|
32
32
|
module.exports = __toCommonJS(vue_exports);
|
|
33
33
|
var import_vite = __toESM(require("unplugin-vue-inspector/vite"));
|
|
34
34
|
var import_core = require("@aipanel/core");
|
|
35
|
+
var import_framework = require("../core/framework.cjs");
|
|
35
36
|
const vueInspectorIntegration = {
|
|
36
37
|
id: import_core.INSPECTOR_ADAPTER_IDS.vue,
|
|
37
|
-
plugins: () => (0,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
plugins: () => (0, import_framework.restrictPluginsToFramework)(
|
|
39
|
+
(0, import_vite.default)({
|
|
40
|
+
enabled: false,
|
|
41
|
+
toggleButtonVisibility: "never",
|
|
42
|
+
toggleComboKey: false
|
|
43
|
+
}),
|
|
44
|
+
(framework) => framework === import_core.INSPECTOR_ADAPTER_IDS.vue
|
|
45
|
+
)
|
|
42
46
|
};
|
|
43
47
|
// Annotate the CommonJS export names for ESM import in node:
|
|
44
48
|
0 && (module.exports = {
|
package/lib/inspectors/vue.d.ts
CHANGED
|
@@ -3,5 +3,8 @@ import type { InspectorIntegration } from "./types";
|
|
|
3
3
|
* Vue 集成:注入 unplugin-vue-inspector 运行时。
|
|
4
4
|
* 常驻但默认不启用(enabled: false),由挂件进入选择模式时开启;
|
|
5
5
|
* 同时隐藏其自带的切换按钮与快捷键,避免与挂件交互冲突。
|
|
6
|
+
*
|
|
7
|
+
* 只对 Vue 项目注册:该插件会向 index.html 注入依赖 vue 的运行时,注册到未安装 vue 的
|
|
8
|
+
* 项目(React 等)会让浏览器直接报 Failed to resolve import "vue"。
|
|
6
9
|
*/
|
|
7
10
|
export declare const vueInspectorIntegration: InspectorIntegration;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-aipanel",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.6",
|
|
4
4
|
"description": "Embed OpenCode Web UI in your Vite dev server for real-time code modification and preview",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.cjs",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"author": "",
|
|
36
36
|
"license": "MIT",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@aipanel/core": "1.3.
|
|
39
|
-
"@aipanel/provider-opencode": "1.3.
|
|
38
|
+
"@aipanel/core": "1.3.6",
|
|
39
|
+
"@aipanel/provider-opencode": "1.3.6",
|
|
40
40
|
"@code-inspector/core": "^2.0.9",
|
|
41
41
|
"@vue/devtools-kit": "^8.0.0",
|
|
42
42
|
"@vue/language-server": "^3.3.7",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"unplugin-vue-inspector": "^3.0.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@aipanel/provider-deepseek": "1.3.
|
|
50
|
+
"@aipanel/provider-deepseek": "1.3.6",
|
|
51
51
|
"vite": ">=5.0.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependenciesMeta": {
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
}
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@aipanel/client": "1.3.
|
|
59
|
+
"@aipanel/client": "1.3.6",
|
|
60
60
|
"@types/picomatch": "^4.0.0",
|
|
61
61
|
"sharp": "^0.34.5"
|
|
62
62
|
},
|