web-extend-plugin-vue2 0.3.6 → 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 +150 -48
- package/dist/index.cjs +491 -418
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +491 -418
- package/dist/index.mjs.map +1 -1
- package/index.d.ts +145 -34
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -87,8 +87,11 @@ export type HostContext = Readonly<
|
|
|
87
87
|
}
|
|
88
88
|
>
|
|
89
89
|
|
|
90
|
+
/** Host bridge config exposed to plugins. */
|
|
90
91
|
export type HostBridgeOptions = {
|
|
92
|
+
/** Host modules exposed on `this.$host`. */
|
|
91
93
|
modules?: Record<string, unknown>
|
|
94
|
+
/** Host components auto-registered as global aliases. */
|
|
92
95
|
components?: Record<string, unknown | { component: unknown }>
|
|
93
96
|
}
|
|
94
97
|
|
|
@@ -119,13 +122,21 @@ export type OnPluginRoutesContributedFn = (ctx: {
|
|
|
119
122
|
contributedRoutes: ReadonlyArray<PluginRouteSnapshot>
|
|
120
123
|
}) => void | Promise<void>
|
|
121
124
|
|
|
125
|
+
/** Host-side injections consumed by `createHostApi()`. */
|
|
122
126
|
export type HostKitOptions = {
|
|
127
|
+
/** Backend path prefixes allowed by the request bridge. */
|
|
123
128
|
bridgeAllowedPathPrefixes?: string[]
|
|
129
|
+
/** Parent route name used when mounting plugin child routes. */
|
|
124
130
|
pluginRoutesParentName?: string
|
|
131
|
+
/** Route transform hook before registration. */
|
|
125
132
|
transformRoutes?: TransformRoutesFn
|
|
133
|
+
/** Intercepts the default route registration flow. */
|
|
126
134
|
interceptRegisterRoutes?: InterceptRegisterRoutesFn
|
|
135
|
+
/** Converts declaration-style routes into Vue Router configs. */
|
|
127
136
|
adaptRouteDeclarations?: AdaptRouteDeclarationsFn
|
|
137
|
+
/** Called after plugin routes are contributed. */
|
|
128
138
|
onPluginRoutesContributed?: OnPluginRoutesContributedFn
|
|
139
|
+
/** Readonly host context passed to plugins. */
|
|
129
140
|
hostContext?: HostContext
|
|
130
141
|
}
|
|
131
142
|
|
|
@@ -147,37 +158,129 @@ export type WebExtendPluginManifestRecord = Readonly<
|
|
|
147
158
|
}
|
|
148
159
|
>
|
|
149
160
|
|
|
150
|
-
export type
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
161
|
+
export type RuntimeManifestOptions = {
|
|
162
|
+
/** Manifest source mode. */
|
|
163
|
+
source?: 'api' | 'static'
|
|
164
|
+
/** API-mode manifest service base path. */
|
|
165
|
+
baseUrl?: string
|
|
166
|
+
/** API-mode manifest path. */
|
|
167
|
+
listPath?: string
|
|
168
|
+
/** Manifest URL in static mode. */
|
|
169
|
+
staticUrl?: string
|
|
170
|
+
/** Fetch credentials used for manifest loading. */
|
|
171
|
+
credentials?: RequestCredentials
|
|
172
|
+
/** Optional manifest fetch override. */
|
|
173
|
+
fetch?: ManifestFetchFn
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export type RuntimeHostRouteOptions = {
|
|
177
|
+
/** Enables auto-registration of the plugin host route. */
|
|
178
|
+
enabled?: boolean
|
|
179
|
+
/** Host layout component used by the plugin shell route. */
|
|
180
|
+
layout?: unknown
|
|
181
|
+
/** Shared mount path for plugin pages. */
|
|
182
|
+
mountPath?: string
|
|
183
|
+
/** Parent route name used for plugin child routes. */
|
|
184
|
+
parentName?: string
|
|
185
|
+
/** Meta assigned to the auto-created plugin host route. */
|
|
186
|
+
meta?: Record<string, unknown>
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export type RuntimeHostOptions = HostKitOptions & {
|
|
190
|
+
/** Host modules/components auto-installed into the Vue runtime. */
|
|
191
|
+
bridge?: HostBridgeOptions
|
|
192
|
+
/** Host context passed to plugins. */
|
|
193
|
+
context?: Record<string, unknown>
|
|
194
|
+
/** Host capability metadata passed to plugins. */
|
|
195
|
+
capabilities?: HostCapabilities
|
|
196
|
+
/** Allowed hosts for remote plugin scripts. */
|
|
197
|
+
scriptHosts?: string[]
|
|
198
|
+
/** Allowed backend path prefixes for the request bridge. */
|
|
199
|
+
requestPathPrefixes?: string[]
|
|
200
|
+
/** Plugin host route configuration. */
|
|
201
|
+
route?: RuntimeHostRouteOptions
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export type RuntimeDevManifestFallbackOptions = {
|
|
205
|
+
/** Enables manifest fallback in development mode. */
|
|
206
|
+
enabled?: boolean
|
|
207
|
+
/** Static manifest URL used by the development fallback. */
|
|
208
|
+
staticUrl?: string
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export type RuntimeDevOptions = {
|
|
212
|
+
/** Explicitly marks runtime as development mode. */
|
|
213
|
+
enabled?: boolean
|
|
214
|
+
/** Local plugin dev server origin. */
|
|
215
|
+
origin?: string
|
|
216
|
+
/** Plugin ids using the local dev entry. */
|
|
217
|
+
pluginIds?: string[] | string
|
|
218
|
+
/** Explicit plugin id -> dev entry mapping. */
|
|
219
|
+
pluginMap?: Record<string, string> | string
|
|
220
|
+
/** Entry path used by implicit dev mode. */
|
|
221
|
+
entryPath?: string
|
|
222
|
+
/** Ping path used to detect the dev server. */
|
|
223
|
+
pingPath?: string
|
|
224
|
+
/** SSE path used for dev reload notifications. */
|
|
225
|
+
reloadSsePath?: string
|
|
226
|
+
/** Ping timeout in milliseconds. */
|
|
227
|
+
pingTimeoutMs?: number
|
|
228
|
+
/** Development manifest fallback config. */
|
|
229
|
+
manifestFallback?: RuntimeDevManifestFallbackOptions
|
|
230
|
+
/** Whether to print bootstrap summary logs. */
|
|
231
|
+
bootstrapSummary?: boolean
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export type RuntimeHooksOptions = {
|
|
235
|
+
/** Route transform hook before registration. */
|
|
236
|
+
transformRoutes?: TransformRoutesFn
|
|
237
|
+
/** Intercepts the default route registration flow. */
|
|
238
|
+
interceptRegisterRoutes?: InterceptRegisterRoutesFn
|
|
239
|
+
/** Converts declaration-style routes into Vue Router configs. */
|
|
240
|
+
adaptRouteDeclarations?: AdaptRouteDeclarationsFn
|
|
241
|
+
/** Called after plugin routes are contributed. */
|
|
242
|
+
onRoutesContributed?: OnPluginRoutesContributedFn
|
|
243
|
+
/** Hook called before plugin activation. */
|
|
244
|
+
beforeActivate?: OnBeforePluginActivateFn
|
|
245
|
+
/** Hook called after plugin activation. */
|
|
246
|
+
afterActivate?: OnAfterPluginActivateFn
|
|
247
|
+
/** Hook called when plugin activation fails. */
|
|
248
|
+
onActivateError?: OnPluginActivateErrorFn
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export type WebExtendPluginRuntimeOptions = {
|
|
252
|
+
manifest?: RuntimeManifestOptions
|
|
253
|
+
host?: RuntimeHostOptions
|
|
254
|
+
dev?: RuntimeDevOptions
|
|
255
|
+
hooks?: RuntimeHooksOptions
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export type ResolvedWebExtendPluginRuntimeOptions = Record<string, unknown> & {
|
|
259
|
+
manifestBase: string
|
|
260
|
+
manifestListPath: string
|
|
261
|
+
manifestMode: 'api' | 'static'
|
|
262
|
+
staticManifestUrl: string
|
|
263
|
+
devManifestFallback: boolean
|
|
264
|
+
devFallbackStaticManifestUrl: string
|
|
265
|
+
manifestFetchCredentials: RequestCredentials
|
|
266
|
+
isDev: boolean
|
|
267
|
+
webPluginDevOrigin: string
|
|
268
|
+
webPluginDevIds: string[]
|
|
269
|
+
webPluginDevMapJson: string
|
|
270
|
+
webPluginDevEntryPath: string
|
|
271
|
+
devPingPath: string
|
|
272
|
+
devReloadSsePath: string
|
|
273
|
+
devPingTimeoutMs: number
|
|
274
|
+
defaultImplicitDevPluginIds: string[]
|
|
275
|
+
allowedScriptHosts: string[]
|
|
276
|
+
bridgeAllowedPathPrefixes: string[]
|
|
277
|
+
bootstrapSummary?: boolean
|
|
278
|
+
hostLayoutComponent?: unknown
|
|
279
|
+
pluginMountPath: string
|
|
280
|
+
pluginHostRouteMeta?: Record<string, unknown>
|
|
281
|
+
ensurePluginHostRoute: boolean
|
|
282
|
+
pluginRoutesParentName: string
|
|
283
|
+
}
|
|
181
284
|
|
|
182
285
|
export interface HostApi {
|
|
183
286
|
readonly hostPluginApiVersion: string
|
|
@@ -212,13 +315,21 @@ export type ManifestFetchResult = {
|
|
|
212
315
|
|
|
213
316
|
export type ManifestFetchFn = (ctx: ManifestFetchContext) => Promise<ManifestFetchResult>
|
|
214
317
|
|
|
318
|
+
/** Manifest fetch cache options. */
|
|
215
319
|
export type ManifestFetchCacheOptions = {
|
|
320
|
+
/** Cache lifetime in milliseconds. */
|
|
216
321
|
ttlMs?: number
|
|
322
|
+
/** Cache storage backend. */
|
|
217
323
|
storage?: 'memory' | 'session' | 'local'
|
|
324
|
+
/** Key prefix when using Web Storage. */
|
|
218
325
|
storageKeyPrefix?: string
|
|
326
|
+
/** Custom cache key builder. */
|
|
219
327
|
cacheKey?: (ctx: ManifestFetchContext) => string
|
|
328
|
+
/** Controls which results may be cached. */
|
|
220
329
|
shouldCache?: (result: ManifestFetchResult) => boolean
|
|
330
|
+
/** Max number of in-memory cache entries. */
|
|
221
331
|
maxEntries?: number
|
|
332
|
+
/** Custom clock, usually for tests. */
|
|
222
333
|
now?: () => number
|
|
223
334
|
}
|
|
224
335
|
|
|
@@ -238,7 +349,7 @@ export function bootstrapPlugins(
|
|
|
238
349
|
runtimeOptions?: WebExtendPluginRuntimeOptions
|
|
239
350
|
): Promise<void>
|
|
240
351
|
|
|
241
|
-
export function resolveRuntimeOptions(user?: WebExtendPluginRuntimeOptions):
|
|
352
|
+
export function resolveRuntimeOptions(user?: WebExtendPluginRuntimeOptions): ResolvedWebExtendPluginRuntimeOptions
|
|
242
353
|
|
|
243
354
|
export function ensurePluginHostRoute(router: unknown, opts: WebExtendPluginRuntimeOptions): void
|
|
244
355
|
export function getActivatedPluginIds(): string[]
|
|
@@ -288,8 +399,8 @@ export const ExtensionPoint: unknown
|
|
|
288
399
|
|
|
289
400
|
export function createVueCliAxiosInstallOptions(
|
|
290
401
|
deps: { request: (config: Record<string, unknown>) => Promise<unknown> },
|
|
291
|
-
extra?:
|
|
292
|
-
):
|
|
402
|
+
extra?: WebExtendPluginRuntimeOptions
|
|
403
|
+
): WebExtendPluginRuntimeOptions
|
|
293
404
|
|
|
294
405
|
export function composeManifestFetch(
|
|
295
406
|
inner: ManifestFetchFn,
|