web-extend-plugin-vue2 0.1.0 → 0.1.2

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 CHANGED
@@ -1,22 +1,52 @@
1
1
  # web-extend-plugin-vue2
2
2
 
3
- Vue 2.7 宿主侧 **Web 扩展插件**运行时:拉取清单、`hostApi`、菜单与 **`registerSlotComponents` 注册表**,以及 **`ExtensionPoint`**(同一组件覆盖内容区、工具栏等任意扩展点;插件在该点挂载 Vue 组件即可)。
3
+ 面向 **Vue 2.7** 宿主的 **Web 前端扩展插件**运行时(npm 包)。在浏览器中拉取插件清单、加载入口脚本、向插件注入 **`hostApi`**(路由 / 菜单 / 扩展点 / 受控请求桥等),并提供 **`ExtensionPoint`** 组件在布局中挂载插件视图。与后端清单服务、静态资源目录约定配套使用(如 `extend-plugin-framework` 中的 `web-extend-plugin-server`)。
4
4
 
5
- ## 依赖
5
+ ## 安装
6
6
 
7
- - `peerDependencies`: `vue@^2.7`, `vue-router@^3.6`
8
- - `dependencies`: `semver`
7
+ ```bash
8
+ npm add web-extend-plugin-vue2 vue@^2.7 vue-router@^3.6
9
+ ```
10
+
11
+ ## 最小接入
12
+
13
+ ```js
14
+ import Vue from 'vue'
15
+ import {
16
+ bootstrapPlugins,
17
+ createHostApi,
18
+ resolveRuntimeOptions,
19
+ ExtensionPoint
20
+ } from 'web-extend-plugin-vue2'
21
+
22
+ Vue.component('ExtensionPoint', ExtensionPoint) // 布局:<ExtensionPoint point-id="..." />
23
+
24
+ const runtime = resolveRuntimeOptions({
25
+ // 按需覆盖,见 defaultWebExtendPluginRuntime
26
+ })
27
+
28
+ bootstrapPlugins(router, (id, r, kit) => createHostApi(id, r, kit), runtime).catch(console.warn)
29
+ ```
30
+
31
+ 清单请求 URL 为 **`manifestBase` + `manifestListPath`**(默认 `/fp-api` + `/api/frontend-plugins`)。工厂请使用 **`(id, r, kit) => createHostApi(id, r, kit)`**,以便 bridge 白名单等配置生效;若仍写 `(id) => createHostApi(id, router)`,仅清单侧配置会随 `runtime` 变化,bridge 仍为内置默认。
32
+
33
+ ## 配置与默认值
34
+
35
+ - **优先级**:`bootstrapPlugins` 第三参 → `resolveRuntimeOptions({ ... })` 显式字段 → 环境变量 → 包内 **`defaultWebExtendPluginRuntime`**(可从本包导入)。
36
+ - **完整字段列表**:见仓库 **`src/default-runtime-config.js`** 与 **`src/PluginRuntime.js`** 中的 `resolveRuntimeOptions`。
37
+ - **环境变量**:支持 `VITE_*`;同等含义可用 **`PLUGIN_*`**(将 `VITE_` 换成 `PLUGIN_`)。Vite 使用 `PLUGIN_` 时需在 `vite.config` 设置 `envPrefix: ['VITE_', 'PLUGIN_']`;Webpack 用 `DefinePlugin` 注入 `process.env` 即可。
9
38
 
10
- ## 在 Vite 宿主中使用
39
+ ## 卸载
11
40
 
12
41
  ```js
13
- import { bootstrapPlugins, createHostApi, registries } from 'web-extend-plugin-vue2'
42
+ import { disposeWebPlugin } from 'web-extend-plugin-vue2'
14
43
 
15
- bootstrapPlugins(router, (pluginId) => createHostApi(pluginId, router)).catch(console.warn)
44
+ disposeWebPlugin('your.plugin.id')
16
45
  ```
17
46
 
18
- 开发环境下清单前缀、插件 Vite 联调等默认从 `import.meta.env`(`VITE_FRONTEND_PLUGIN_BASE`、`VITE_WEB_PLUGIN_DEV_*`)读取。非 Vite 或需覆盖时可传入第三参数,见源码 `resolveRuntimeOptions` / `WebExtendPluginRuntimeOptions`。
47
+ Vue Router 3 无公开 `removeRoute`,动态路由卸载后可能需整页刷新。
19
48
 
20
- ## 发布到 npm
49
+ ## 仓库与协议
21
50
 
22
- 在包目录执行 `npm publish`(需有权限)。本仓库可用 `file:../web-extend-plugin-vue2` 联调示例宿主。
51
+ - 源码:[extend-plugin-framework / web-extend-plugin-vue2](https://github.com/xtemplus/extend-plugin-framework/tree/master/web-extend-plugin-vue2)
52
+ - 许可证:Apache-2.0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-extend-plugin-vue2",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Vue 2.7 host runtime for web-extend-plugin: manifest bootstrap, hostApi, registries, ExtensionPoint",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",