web-extend-plugin-vue2 0.3.5 → 0.3.7

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
@@ -37,9 +37,10 @@ Utilities:
37
37
 
38
38
  - `createRequestBridge`
39
39
  - `createVueCliAxiosInstallOptions`
40
- - `registerHostComponents`
41
- - `registerVueGlobalComponents`
42
- - `registerHostModules`
40
+ - `installHostBridge`
41
+ - `registerHostComponents` (legacy)
42
+ - `registerVueGlobalComponents` (legacy)
43
+ - `registerHostModules` (legacy)
43
44
  - `composeManifestFetch`
44
45
  - `manifestFetchCacheMiddleware`
45
46
  - `wrapManifestFetchWithCache`
@@ -68,10 +69,30 @@ import { installWebExtendPluginVue2, setWebExtendPluginEnv } from 'web-extend-pl
68
69
  setWebExtendPluginEnv(import.meta.env)
69
70
 
70
71
  installWebExtendPluginVue2(Vue, router, {
71
- manifestBase: '/fp-api'
72
+ manifest: {
73
+ baseUrl: '/fp-api'
74
+ }
72
75
  }).catch(console.warn)
73
76
  ```
74
77
 
78
+ Minimal host config usually starts with only:
79
+
80
+ ```js
81
+ installWebExtendPluginVue2(Vue, router, {
82
+ manifest: {
83
+ baseUrl: '/fp-api',
84
+ listPath: '/api/frontend-plugins'
85
+ },
86
+ host: {
87
+ bridge: {
88
+ modules: { request }
89
+ }
90
+ }
91
+ })
92
+ ```
93
+
94
+ Add development options or advanced hooks only when the default flow is not enough.
95
+
75
96
  ## Vue CLI + axios
76
97
 
77
98
  ```js
@@ -79,6 +100,7 @@ import { installWebExtendPluginVue2, createVueCliAxiosInstallOptions } from 'web
79
100
  import request from '@/utils/request'
80
101
  import Layout from '@/layout'
81
102
  import store from '@/store'
103
+ import Pagination from '@/components/Pagination'
82
104
 
83
105
  installWebExtendPluginVue2(
84
106
  Vue,
@@ -86,67 +108,147 @@ installWebExtendPluginVue2(
86
108
  createVueCliAxiosInstallOptions(
87
109
  { request },
88
110
  {
89
- manifestBase: process.env.VUE_APP_BASE_API,
90
- manifestListPath: '/frontend-plugins',
91
- hostLayoutComponent: Layout,
92
- hostContext: { router, store },
93
- ensurePluginHostRoute: true,
94
- pluginRoutesParentName: 'pluginHost'
111
+ manifest: {
112
+ listPath: '/frontend-plugins'
113
+ },
114
+ host: {
115
+ context: { router, store },
116
+ bridge: {
117
+ modules: {
118
+ request,
119
+ router,
120
+ store
121
+ },
122
+ components: {
123
+ 'app.pagination': Pagination
124
+ }
125
+ },
126
+ route: {
127
+ enabled: true,
128
+ layout: Layout,
129
+ parentName: 'pluginHost'
130
+ }
131
+ }
95
132
  }
96
133
  )
97
134
  ).catch(console.warn)
98
135
  ```
99
136
 
100
- ## Host exposes
137
+ ## Recommended host bridge
138
+
139
+ Preferred integration is:
101
140
 
102
- Preferred host integration uses concrete component/module exposes instead of relying on `hostCapabilities`.
141
+ - host native Vue globals stay native in plugins, for example `this.$router`, `this.$route`, `this.$store`
142
+ - host UI globals stay native in plugins, for example `this.$message`
143
+ - extra host business capabilities are exposed through `this.$host`
144
+ - extra host components can be registered as direct aliases such as `<app-pagination />`
103
145
 
104
146
  ```js
105
147
  import {
106
148
  installWebExtendPluginVue2,
107
- createVueCliAxiosInstallOptions,
108
- registerHostComponents,
109
- registerVueGlobalComponents,
110
- registerHostModules
149
+ createVueCliAxiosInstallOptions
111
150
  } from 'web-extend-plugin-vue2'
112
151
 
113
- registerVueGlobalComponents(Vue, {
114
- include: (name) => /^El[A-Z]/.test(name),
115
- mapName: (name) => name.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase()
116
- })
152
+ installWebExtendPluginVue2(
153
+ Vue,
154
+ router,
155
+ createVueCliAxiosInstallOptions(
156
+ { request },
157
+ {
158
+ host: {
159
+ bridge: {
160
+ modules: {
161
+ request,
162
+ download,
163
+ bus: Vue.prototype.$bus
164
+ },
165
+ components: {
166
+ 'app.pagination': Pagination,
167
+ 'app.dict-tag': DictTag
168
+ }
169
+ },
170
+ }
171
+ }
172
+ )
173
+ )
174
+ ```
117
175
 
118
- registerHostComponents({
119
- 'app.pagination': Pagination,
120
- 'app.dict-tag': DictTag
121
- })
176
+ Then plugin pages can use:
122
177
 
123
- registerHostModules({
124
- request,
125
- download
126
- })
127
- ```
178
+ - `this.$message(...)`
179
+ - `this.$router.push(...)`
180
+ - `this.$host.request(...)`
181
+ - `<el-button />`
182
+ - `<app-pagination />`
183
+
184
+ ## Legacy registry APIs
185
+
186
+ The registry-style APIs remain exported for compatibility inside the framework package, but they are no longer the recommended model for plugin development in this project.
187
+
188
+ Avoid building new plugin pages around:
189
+
190
+ - `registerHostComponents(...)`
191
+ - `registerHostModules(...)`
192
+ - `registerVueGlobalComponents(...)`
193
+ - `hostApi.getHostComponent(...)`
194
+ - `hostApi.getHostModule(...)`
195
+
196
+ Prefer the host bridge model instead:
197
+
198
+ - native host globals stay native
199
+ - extra business capabilities go through `this.$host`
200
+ - extra components are registered as direct aliases
201
+
202
+ ## Runtime options
203
+
204
+ Core options most hosts need:
205
+
206
+ - `manifest.baseUrl`: API prefix, default `/fp-api`
207
+ - `manifest.listPath`: manifest path segment, default `/api/frontend-plugins`
208
+ - `manifest.source`: `api` or `static`
209
+ - `manifest.staticUrl`: required when `manifest.source` is `static`
210
+ - `host.scriptHosts`: allowed remote script hosts
211
+ - `host.requestPathPrefixes`: allowed bridge request path prefixes
212
+ - `host.bridge`: preferred way to expose host modules and host components
213
+ - `host.context`: readonly host dependencies injected into `hostApi.hostContext`
214
+ - `host.capabilities`: optional metadata; prefer `host.bridge` for real capability exposure
215
+
216
+ Host route integration options:
217
+
218
+ - `host.route.layout`: layout component for plugin shell route
219
+ - `host.route.mountPath`: shell mount path, default `/plugin`
220
+ - `host.route.parentName`: explicit parent route name for child plugin routes
221
+ - `host.route.enabled`: when `true`, auto-registers the shell route
222
+ - `host.route.meta`: meta assigned to the auto-created shell route
223
+
224
+ Development-only options:
225
+
226
+ - `dev.enabled`: explicit dev mode override
227
+ - `dev.origin`: local plugin dev server origin
228
+ - `dev.pluginIds`: plugin ids using the local dev entry
229
+ - `dev.pluginMap`: explicit plugin id to dev entry map
230
+ - `dev.entryPath`: implicit dev entry path
231
+ - `dev.pingPath`: dev server health-check path
232
+ - `dev.reloadSsePath`: SSE path for dev reload notifications
233
+ - `dev.pingTimeoutMs`: dev server ping timeout
234
+ - `dev.manifestFallback.enabled`: whether dev mode falls back to a static manifest
235
+ - `dev.manifestFallback.staticUrl`: default `/web-plugins/plugins.manifest.json`
236
+ - `dev.bootstrapSummary`: whether to print bootstrap summary logs
237
+
238
+ Advanced hooks:
128
239
 
129
- Plugins should depend on stable expose names such as `el-button`, `app.pagination`, or `request`.
130
-
131
- ## Important runtime options
132
-
133
- - `manifestBase`: API prefix, default `/fp-api`
134
- - `manifestListPath`: manifest path segment, default `/api/frontend-plugins`
135
- - `manifestMode`: `api` or `static`
136
- - `staticManifestUrl`: required when `manifestMode` is `static`
137
- - `devManifestFallback`: whether dev mode falls back to a static manifest
138
- - `devFallbackStaticManifestUrl`: default `/web-plugins/plugins.manifest.json`
139
- - `allowedScriptHosts`: allowed remote script hosts
140
- - `bridgeAllowedPathPrefixes`: allowed bridge request path prefixes
141
- - `hostLayoutComponent`: layout component for plugin shell route
142
- - `pluginMountPath`: shell mount path, default `/plugin`
143
- - `pluginRoutesParentName`: explicit parent route name for child plugin routes
144
- - `ensurePluginHostRoute`: when `true`, auto-registers the shell route
145
- - `hostContext`: readonly host dependencies injected into `hostApi.hostContext`
146
- - `hostCapabilities`: optional legacy metadata; prefer `registerHostComponents` and `registerHostModules`
240
+ - `manifest.fetch`: override manifest loading
241
+ - `hooks.transformRoutes`: mutate routes before registration
242
+ - `hooks.interceptRegisterRoutes`: take over the default route registration flow
243
+ - `hooks.adaptRouteDeclarations`: convert declaration-style routes into Vue Router configs
244
+ - `hooks.onRoutesContributed`: observe contributed routes after registration
245
+ - `hooks.beforeActivate`: hook before activation
246
+ - `hooks.afterActivate`: hook after activation
247
+ - `hooks.onActivateError`: hook on activation failure
147
248
 
148
249
  ## Notes
149
250
 
150
- - `pluginRoutesParentName` has no implicit default. Pass it explicitly when you want child routes mounted under a named parent route.
251
+ - `host.route.parentName` has no implicit default. Pass it explicitly when you want child routes mounted under a named parent route.
151
252
  - `installWebExtendPluginVue2` no longer accepts install-only wrapper options. Runtime environment injection should use `setWebExtendPluginEnv(...)`.
152
253
  - Vue CLI preset helpers were reduced to a single builder: `createVueCliAxiosInstallOptions`.
254
+ - If you are unsure where to start, configure only the core options first. Most projects do not need the advanced hooks.