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/index.d.ts CHANGED
@@ -87,6 +87,14 @@ export type HostContext = Readonly<
87
87
  }
88
88
  >
89
89
 
90
+ /** Host bridge config exposed to plugins. */
91
+ export type HostBridgeOptions = {
92
+ /** Host modules exposed on `this.$host`. */
93
+ modules?: Record<string, unknown>
94
+ /** Host components auto-registered as global aliases. */
95
+ components?: Record<string, unknown | { component: unknown }>
96
+ }
97
+
90
98
  export type OnBeforePluginActivateFn = (ctx: {
91
99
  pluginId: string
92
100
  router: unknown
@@ -114,13 +122,21 @@ export type OnPluginRoutesContributedFn = (ctx: {
114
122
  contributedRoutes: ReadonlyArray<PluginRouteSnapshot>
115
123
  }) => void | Promise<void>
116
124
 
125
+ /** Host-side injections consumed by `createHostApi()`. */
117
126
  export type HostKitOptions = {
127
+ /** Backend path prefixes allowed by the request bridge. */
118
128
  bridgeAllowedPathPrefixes?: string[]
129
+ /** Parent route name used when mounting plugin child routes. */
119
130
  pluginRoutesParentName?: string
131
+ /** Route transform hook before registration. */
120
132
  transformRoutes?: TransformRoutesFn
133
+ /** Intercepts the default route registration flow. */
121
134
  interceptRegisterRoutes?: InterceptRegisterRoutesFn
135
+ /** Converts declaration-style routes into Vue Router configs. */
122
136
  adaptRouteDeclarations?: AdaptRouteDeclarationsFn
137
+ /** Called after plugin routes are contributed. */
123
138
  onPluginRoutesContributed?: OnPluginRoutesContributedFn
139
+ /** Readonly host context passed to plugins. */
124
140
  hostContext?: HostContext
125
141
  }
126
142
 
@@ -142,37 +158,129 @@ export type WebExtendPluginManifestRecord = Readonly<
142
158
  }
143
159
  >
144
160
 
145
- export type WebExtendPluginRuntimeOptions = HostKitOptions &
146
- Record<string, unknown> & {
147
- manifestBase?: string
148
- manifestListPath?: string
149
- manifestMode?: 'api' | 'static'
150
- staticManifestUrl?: string
151
- devManifestFallback?: boolean
152
- devFallbackStaticManifestUrl?: string
153
- manifestFetchCredentials?: RequestCredentials
154
- hostLayoutComponent?: unknown
155
- pluginMountPath?: string
156
- pluginHostRouteMeta?: Record<string, unknown>
157
- ensurePluginHostRoute?: boolean
158
- isDev?: boolean
159
- webPluginDevOrigin?: string
160
- webPluginDevIds?: string
161
- webPluginDevMapJson?: string
162
- webPluginDevEntryPath?: string
163
- devPingPath?: string
164
- devReloadSsePath?: string
165
- devPingTimeoutMs?: number
166
- defaultImplicitDevPluginIds?: string[]
167
- allowedScriptHosts?: string[]
168
- bootstrapSummary?: boolean
169
- fetchManifest?: ManifestFetchFn
170
- hostContext?: Record<string, unknown>
171
- hostCapabilities?: HostCapabilities
172
- onBeforePluginActivate?: OnBeforePluginActivateFn
173
- onAfterPluginActivate?: OnAfterPluginActivateFn
174
- onPluginActivateError?: OnPluginActivateErrorFn
175
- }
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
+ }
176
284
 
177
285
  export interface HostApi {
178
286
  readonly hostPluginApiVersion: string
@@ -207,13 +315,21 @@ export type ManifestFetchResult = {
207
315
 
208
316
  export type ManifestFetchFn = (ctx: ManifestFetchContext) => Promise<ManifestFetchResult>
209
317
 
318
+ /** Manifest fetch cache options. */
210
319
  export type ManifestFetchCacheOptions = {
320
+ /** Cache lifetime in milliseconds. */
211
321
  ttlMs?: number
322
+ /** Cache storage backend. */
212
323
  storage?: 'memory' | 'session' | 'local'
324
+ /** Key prefix when using Web Storage. */
213
325
  storageKeyPrefix?: string
326
+ /** Custom cache key builder. */
214
327
  cacheKey?: (ctx: ManifestFetchContext) => string
328
+ /** Controls which results may be cached. */
215
329
  shouldCache?: (result: ManifestFetchResult) => boolean
330
+ /** Max number of in-memory cache entries. */
216
331
  maxEntries?: number
332
+ /** Custom clock, usually for tests. */
217
333
  now?: () => number
218
334
  }
219
335
 
@@ -233,7 +349,7 @@ export function bootstrapPlugins(
233
349
  runtimeOptions?: WebExtendPluginRuntimeOptions
234
350
  ): Promise<void>
235
351
 
236
- export function resolveRuntimeOptions(user?: WebExtendPluginRuntimeOptions): WebExtendPluginRuntimeOptions
352
+ export function resolveRuntimeOptions(user?: WebExtendPluginRuntimeOptions): ResolvedWebExtendPluginRuntimeOptions
237
353
 
238
354
  export function ensurePluginHostRoute(router: unknown, opts: WebExtendPluginRuntimeOptions): void
239
355
  export function getActivatedPluginIds(): string[]
@@ -274,12 +390,17 @@ export function installWebExtendPluginVue2(
274
390
  options?: WebExtendPluginRuntimeOptions
275
391
  ): Promise<void>
276
392
 
393
+ export function installHostBridge(
394
+ Vue: unknown,
395
+ options?: HostBridgeOptions
396
+ ): Readonly<Record<string, unknown>>
397
+
277
398
  export const ExtensionPoint: unknown
278
399
 
279
400
  export function createVueCliAxiosInstallOptions(
280
401
  deps: { request: (config: Record<string, unknown>) => Promise<unknown> },
281
- extra?: Record<string, unknown>
282
- ): Record<string, unknown>
402
+ extra?: WebExtendPluginRuntimeOptions
403
+ ): WebExtendPluginRuntimeOptions
283
404
 
284
405
  export function composeManifestFetch(
285
406
  inner: ManifestFetchFn,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-extend-plugin-vue2",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -43,18 +43,18 @@
43
43
  "prepublishOnly": "npm run build"
44
44
  },
45
45
  "license": "Apache-2.0",
46
- "repository": {
47
- "type": "git",
48
- "url": "https://github.com/xtemplus/extend-plugin-framework.git",
49
- "directory": "web-extend-plugin-vue2"
50
- },
51
- "bugs": {
52
- "url": "https://github.com/xtemplus/extend-plugin-framework/issues"
53
- },
54
- "homepage": "https://github.com/xtemplus/extend-plugin-framework/tree/master/web-extend-plugin-vue2#readme",
55
- "keywords": [
56
- "vue2",
57
- "plugin",
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "https://github.com/xtemplus/extend-plugin-framework.git",
49
+ "directory": "web-extend-plugin-vue2"
50
+ },
51
+ "bugs": {
52
+ "url": "https://github.com/xtemplus/extend-plugin-framework/issues"
53
+ },
54
+ "homepage": "https://github.com/xtemplus/extend-plugin-framework/tree/master/web-extend-plugin-vue2#readme",
55
+ "keywords": [
56
+ "vue2",
57
+ "plugin",
58
58
  "extension"
59
59
  ]
60
60
  }