web-extend-plugin-vue2 0.3.6 → 0.3.8
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 +154 -50
- package/dist/index.cjs +504 -441
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +504 -441
- package/dist/index.mjs.map +1 -1
- package/index.d.ts +145 -34
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ Vue 2 host runtime for web plugin bootstrap, route registration, host API inject
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm i web-extend-plugin-vue2@0.3.
|
|
8
|
+
npm i web-extend-plugin-vue2@0.3.8
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
Peer dependencies:
|
|
@@ -15,7 +15,7 @@ Peer dependencies:
|
|
|
15
15
|
|
|
16
16
|
Published package:
|
|
17
17
|
|
|
18
|
-
- `web-extend-plugin-vue2@0.3.
|
|
18
|
+
- `web-extend-plugin-vue2@0.3.8`
|
|
19
19
|
|
|
20
20
|
## Public API
|
|
21
21
|
|
|
@@ -37,9 +37,10 @@ Utilities:
|
|
|
37
37
|
|
|
38
38
|
- `createRequestBridge`
|
|
39
39
|
- `createVueCliAxiosInstallOptions`
|
|
40
|
-
- `
|
|
41
|
-
- `
|
|
42
|
-
- `
|
|
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
|
-
|
|
72
|
+
manifest: {
|
|
73
|
+
baseUrl: '/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: '/api',
|
|
84
|
+
listPath: '/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,149 @@ installWebExtendPluginVue2(
|
|
|
86
108
|
createVueCliAxiosInstallOptions(
|
|
87
109
|
{ request },
|
|
88
110
|
{
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
111
|
+
manifest: {
|
|
112
|
+
baseUrl: '/api',
|
|
113
|
+
listPath: '/frontend-plugins'
|
|
114
|
+
},
|
|
115
|
+
host: {
|
|
116
|
+
context: { router, store },
|
|
117
|
+
bridge: {
|
|
118
|
+
modules: {
|
|
119
|
+
request,
|
|
120
|
+
router,
|
|
121
|
+
store
|
|
122
|
+
},
|
|
123
|
+
components: {
|
|
124
|
+
'app.pagination': Pagination
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
route: {
|
|
128
|
+
enabled: true,
|
|
129
|
+
layout: Layout,
|
|
130
|
+
parentName: 'pluginHost'
|
|
131
|
+
}
|
|
132
|
+
}
|
|
95
133
|
}
|
|
96
134
|
)
|
|
97
135
|
).catch(console.warn)
|
|
98
136
|
```
|
|
99
137
|
|
|
100
|
-
##
|
|
138
|
+
## Recommended host bridge
|
|
139
|
+
|
|
140
|
+
Preferred integration is:
|
|
101
141
|
|
|
102
|
-
|
|
142
|
+
- host native Vue globals stay native in plugins, for example `this.$router`, `this.$route`, `this.$store`
|
|
143
|
+
- host UI globals stay native in plugins, for example `this.$message`
|
|
144
|
+
- extra host business capabilities are exposed through `this.$host`
|
|
145
|
+
- extra host components can be registered as direct aliases such as `<app-pagination />`
|
|
103
146
|
|
|
104
147
|
```js
|
|
105
148
|
import {
|
|
106
149
|
installWebExtendPluginVue2,
|
|
107
|
-
createVueCliAxiosInstallOptions
|
|
108
|
-
registerHostComponents,
|
|
109
|
-
registerVueGlobalComponents,
|
|
110
|
-
registerHostModules
|
|
150
|
+
createVueCliAxiosInstallOptions
|
|
111
151
|
} from 'web-extend-plugin-vue2'
|
|
112
152
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
153
|
+
installWebExtendPluginVue2(
|
|
154
|
+
Vue,
|
|
155
|
+
router,
|
|
156
|
+
createVueCliAxiosInstallOptions(
|
|
157
|
+
{ request },
|
|
158
|
+
{
|
|
159
|
+
host: {
|
|
160
|
+
bridge: {
|
|
161
|
+
modules: {
|
|
162
|
+
request,
|
|
163
|
+
download,
|
|
164
|
+
bus: Vue.prototype.$bus
|
|
165
|
+
},
|
|
166
|
+
components: {
|
|
167
|
+
'app.pagination': Pagination,
|
|
168
|
+
'app.dict-tag': DictTag
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
)
|
|
174
|
+
)
|
|
175
|
+
```
|
|
117
176
|
|
|
118
|
-
|
|
119
|
-
'app.pagination': Pagination,
|
|
120
|
-
'app.dict-tag': DictTag
|
|
121
|
-
})
|
|
177
|
+
Then plugin pages can use:
|
|
122
178
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
179
|
+
- `this.$message(...)`
|
|
180
|
+
- `this.$router.push(...)`
|
|
181
|
+
- `this.$host.request(...)`
|
|
182
|
+
- `<el-button />`
|
|
183
|
+
- `<app-pagination />`
|
|
184
|
+
|
|
185
|
+
## Legacy registry APIs
|
|
186
|
+
|
|
187
|
+
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.
|
|
188
|
+
|
|
189
|
+
Avoid building new plugin pages around:
|
|
190
|
+
|
|
191
|
+
- `registerHostComponents(...)`
|
|
192
|
+
- `registerHostModules(...)`
|
|
193
|
+
- `registerVueGlobalComponents(...)`
|
|
194
|
+
- `hostApi.getHostComponent(...)`
|
|
195
|
+
- `hostApi.getHostModule(...)`
|
|
196
|
+
|
|
197
|
+
Prefer the host bridge model instead:
|
|
198
|
+
|
|
199
|
+
- native host globals stay native
|
|
200
|
+
- extra business capabilities go through `this.$host`
|
|
201
|
+
- extra components are registered as direct aliases
|
|
202
|
+
|
|
203
|
+
## Runtime options
|
|
204
|
+
|
|
205
|
+
Core options most hosts need:
|
|
206
|
+
|
|
207
|
+
- `manifest.baseUrl`: manifest request base URL, default `/dev-api`
|
|
208
|
+
- `manifest.listPath`: manifest path segment, default `/web-plugin`
|
|
209
|
+
- `manifest.source`: `api` or `static`
|
|
210
|
+
- `manifest.staticUrl`: required when `manifest.source` is `static`
|
|
211
|
+
- `host.scriptHosts`: allowed remote script hosts
|
|
212
|
+
- `host.requestPathPrefixes`: allowed bridge request path prefixes
|
|
213
|
+
- `host.bridge`: preferred way to expose host modules and host components
|
|
214
|
+
- `host.context`: readonly host dependencies injected into `hostApi.hostContext`
|
|
215
|
+
- `host.capabilities`: optional metadata; prefer `host.bridge` for real capability exposure
|
|
216
|
+
|
|
217
|
+
Host route integration options:
|
|
218
|
+
|
|
219
|
+
- `host.route.layout`: layout component for plugin shell route
|
|
220
|
+
- `host.route.mountPath`: shell mount path, default `/plugin`
|
|
221
|
+
- `host.route.parentName`: explicit parent route name for child plugin routes
|
|
222
|
+
- `host.route.enabled`: when `true`, auto-registers the shell route
|
|
223
|
+
- `host.route.meta`: meta assigned to the auto-created shell route
|
|
224
|
+
|
|
225
|
+
Development-only options:
|
|
226
|
+
|
|
227
|
+
- `dev.enabled`: explicit dev mode override
|
|
228
|
+
- `dev.origin`: local plugin dev server origin
|
|
229
|
+
- `dev.pluginIds`: plugin ids using the local dev entry
|
|
230
|
+
- `dev.pluginMap`: explicit plugin id to dev entry map
|
|
231
|
+
- `dev.entryPath`: implicit dev entry path
|
|
232
|
+
- `dev.pingPath`: dev server health-check path
|
|
233
|
+
- `dev.reloadSsePath`: SSE path for dev reload notifications
|
|
234
|
+
- `dev.pingTimeoutMs`: dev server ping timeout
|
|
235
|
+
- `dev.manifestFallback.enabled`: whether dev mode falls back to a static manifest, default `false`
|
|
236
|
+
- `dev.manifestFallback.staticUrl`: no default; must be provided explicitly when fallback is enabled
|
|
237
|
+
- `dev.bootstrapSummary`: whether to print bootstrap summary logs
|
|
238
|
+
|
|
239
|
+
Advanced hooks:
|
|
128
240
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
- `
|
|
134
|
-
- `
|
|
135
|
-
- `
|
|
136
|
-
- `
|
|
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`
|
|
241
|
+
- `manifest.fetch`: override manifest loading
|
|
242
|
+
- `hooks.transformRoutes`: mutate routes before registration
|
|
243
|
+
- `hooks.interceptRegisterRoutes`: take over the default route registration flow
|
|
244
|
+
- `hooks.adaptRouteDeclarations`: convert declaration-style routes into Vue Router configs
|
|
245
|
+
- `hooks.onRoutesContributed`: observe contributed routes after registration
|
|
246
|
+
- `hooks.beforeActivate`: hook before activation
|
|
247
|
+
- `hooks.afterActivate`: hook after activation
|
|
248
|
+
- `hooks.onActivateError`: hook on activation failure
|
|
147
249
|
|
|
148
250
|
## Notes
|
|
149
251
|
|
|
150
|
-
- `
|
|
252
|
+
- `host.route.parentName` has no implicit default. Pass it explicitly when you want child routes mounted under a named parent route.
|
|
151
253
|
- `installWebExtendPluginVue2` no longer accepts install-only wrapper options. Runtime environment injection should use `setWebExtendPluginEnv(...)`.
|
|
152
254
|
- Vue CLI preset helpers were reduced to a single builder: `createVueCliAxiosInstallOptions`.
|
|
255
|
+
- `createVueCliAxiosInstallOptions` no longer rewrites `manifest.baseUrl + manifest.listPath`; the configured manifest URL is requested as-is.
|
|
256
|
+
- If you are unsure where to start, configure only the core options first. Most projects do not need the advanced hooks.
|