web-extend-plugin-vue2 0.3.7 → 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 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.5
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.5`
18
+ - `web-extend-plugin-vue2@0.3.8`
19
19
 
20
20
  ## Public API
21
21
 
@@ -70,7 +70,7 @@ setWebExtendPluginEnv(import.meta.env)
70
70
 
71
71
  installWebExtendPluginVue2(Vue, router, {
72
72
  manifest: {
73
- baseUrl: '/fp-api'
73
+ baseUrl: '/api'
74
74
  }
75
75
  }).catch(console.warn)
76
76
  ```
@@ -80,8 +80,8 @@ Minimal host config usually starts with only:
80
80
  ```js
81
81
  installWebExtendPluginVue2(Vue, router, {
82
82
  manifest: {
83
- baseUrl: '/fp-api',
84
- listPath: '/api/frontend-plugins'
83
+ baseUrl: '/api',
84
+ listPath: '/frontend-plugins'
85
85
  },
86
86
  host: {
87
87
  bridge: {
@@ -109,6 +109,7 @@ installWebExtendPluginVue2(
109
109
  { request },
110
110
  {
111
111
  manifest: {
112
+ baseUrl: '/api',
112
113
  listPath: '/frontend-plugins'
113
114
  },
114
115
  host: {
@@ -203,8 +204,8 @@ Prefer the host bridge model instead:
203
204
 
204
205
  Core options most hosts need:
205
206
 
206
- - `manifest.baseUrl`: API prefix, default `/fp-api`
207
- - `manifest.listPath`: manifest path segment, default `/api/frontend-plugins`
207
+ - `manifest.baseUrl`: manifest request base URL, default `/dev-api`
208
+ - `manifest.listPath`: manifest path segment, default `/web-plugin`
208
209
  - `manifest.source`: `api` or `static`
209
210
  - `manifest.staticUrl`: required when `manifest.source` is `static`
210
211
  - `host.scriptHosts`: allowed remote script hosts
@@ -231,8 +232,8 @@ Development-only options:
231
232
  - `dev.pingPath`: dev server health-check path
232
233
  - `dev.reloadSsePath`: SSE path for dev reload notifications
233
234
  - `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`
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
236
237
  - `dev.bootstrapSummary`: whether to print bootstrap summary logs
237
238
 
238
239
  Advanced hooks:
@@ -251,4 +252,5 @@ Advanced hooks:
251
252
  - `host.route.parentName` has no implicit default. Pass it explicitly when you want child routes mounted under a named parent route.
252
253
  - `installWebExtendPluginVue2` no longer accepts install-only wrapper options. Runtime environment injection should use `setWebExtendPluginEnv(...)`.
253
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.
254
256
  - If you are unsure where to start, configure only the core options first. Most projects do not need the advanced hooks.
package/dist/index.cjs CHANGED
@@ -45,8 +45,8 @@ const defaultManifestFetchCache = {
45
45
  };
46
46
  const routeSynthNamePrefix = '__wep_';
47
47
  const defaultWebExtendPluginRuntime = {
48
- manifestBase: '/fp-api',
49
- manifestListPath: '/api/frontend-plugins',
48
+ manifestBase: '/dev-api',
49
+ manifestListPath: '/web-plugin',
50
50
  manifestFetchCredentials: 'include',
51
51
  devPingPath: '/__web_plugin_dev_ping',
52
52
  devReloadSsePath: '/__web_plugin_reload_stream',
@@ -56,7 +56,7 @@ const defaultWebExtendPluginRuntime = {
56
56
  allowedScriptHosts: ['localhost', '127.0.0.1', '::1'],
57
57
  bridgeAllowedPathPrefixes: ['/api/'],
58
58
  pluginMountPath: '/plugin',
59
- devFallbackStaticManifestUrl: '/web-plugins/plugins.manifest.json'
59
+ devFallbackStaticManifestUrl: ''
60
60
  };
61
61
 
62
62
  /**
@@ -336,7 +336,7 @@ function resolveDevManifestFallback(dev, manifestMode, isDev) {
336
336
  if (envFlag === '1' || envFlag === 'true') {
337
337
  return true;
338
338
  }
339
- return isDev;
339
+ return false;
340
340
  }
341
341
  function resolveRuntimeOptions$1(user = {}) {
342
342
  const manifest = resolveManifestInput(user);
@@ -398,7 +398,7 @@ function resolveRuntimeOptions$1(user = {}) {
398
398
  manifestListPath,
399
399
  manifestMode,
400
400
  staticManifestUrl,
401
- devManifestFallback: resolveDevManifestFallback(dev, manifestMode, isDev),
401
+ devManifestFallback: resolveDevManifestFallback(dev, manifestMode),
402
402
  devFallbackStaticManifestUrl,
403
403
  manifestFetchCredentials: resolveManifestCredentials(manifest.credentials, EK.manifestCredentials, DEF.manifestFetchCredentials),
404
404
  isDev,
@@ -4162,6 +4162,14 @@ function resolveManifestRequest(opts) {
4162
4162
  manifestUrl: `${base}${opts.manifestListPath}`
4163
4163
  };
4164
4164
  }
4165
+ function isResolvedRuntimeOptions(input) {
4166
+ return !!(input &&
4167
+ typeof input === 'object' &&
4168
+ !Array.isArray(input) &&
4169
+ ('manifestBase' in input ||
4170
+ 'manifestListPath' in input ||
4171
+ 'fetchManifest' in input));
4172
+ }
4165
4173
  async function bootstrapPlugins$1(
4166
4174
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
4167
4175
  router,
@@ -4173,7 +4181,7 @@ createHostApiFactory, runtimeOptions) {
4173
4181
  }
4174
4182
  printRuntimeBannerOnce();
4175
4183
  clearActivatedPluginIds();
4176
- const opts = resolveRuntimeOptions$1(runtimeOptions);
4184
+ const opts = isResolvedRuntimeOptions(runtimeOptions) ? runtimeOptions : resolveRuntimeOptions$1(runtimeOptions);
4177
4185
  const showBootstrapSummary = shouldShowBootstrapSummary(opts);
4178
4186
  setPluginBootstrapRouter(router);
4179
4187
  ensurePluginHostRoute$1(router, opts);
@@ -5005,22 +5013,6 @@ function installWebExtendPluginVue2(Vue, router, options) {
5005
5013
  return bootstrapPlugins$1(router, createHostApi, runtime);
5006
5014
  }
5007
5015
 
5008
- function resolveManifestPathUnderApiBase(manifestUrl, apiBase) {
5009
- const base = String(apiBase !== undefined
5010
- ? apiBase
5011
- : typeof process !== 'undefined' && process.env && process.env.VUE_APP_BASE_API
5012
- ? String(process.env.VUE_APP_BASE_API)
5013
- : '').replace(/\/$/, '');
5014
- if (typeof window === 'undefined') {
5015
- return '/api/frontend-plugins';
5016
- }
5017
- const url = new URL(manifestUrl, window.location.origin);
5018
- let path = url.pathname + url.search;
5019
- if (base && path.startsWith(base)) {
5020
- path = path.slice(base.length) || '/';
5021
- }
5022
- return path;
5023
- }
5024
5016
  function bridgePrefixesFromVueCliEnv() {
5025
5017
  const base = (typeof process !== 'undefined' && process.env && process.env.VUE_APP_BASE_API
5026
5018
  ? String(process.env.VUE_APP_BASE_API)
@@ -5039,17 +5031,13 @@ function createVueCliAxiosInstallOptions(deps, extra = {}) {
5039
5031
  const manifest = asRecord(extra.manifest) || {};
5040
5032
  const host = asRecord(extra.host) || {};
5041
5033
  const mergedHost = { ...host };
5042
- const envBase = (typeof process !== 'undefined' && process.env && process.env.VUE_APP_BASE_API
5043
- ? String(process.env.VUE_APP_BASE_API)
5044
- : '').replace(/\/$/, '');
5045
- const userBase = manifest.baseUrl !== undefined && String(manifest.baseUrl).trim() !== ''
5046
- ? String(manifest.baseUrl).replace(/\/$/, '')
5047
- : '';
5048
- const stripBase = userBase || envBase;
5049
5034
  const fetchManifestApi = async (ctx) => {
5050
5035
  try {
5036
+ const manifestRequestUrl = typeof window !== 'undefined'
5037
+ ? new URL(String(ctx.manifestUrl), window.location.origin).toString()
5038
+ : String(ctx.manifestUrl);
5051
5039
  const body = await request({
5052
- url: resolveManifestPathUnderApiBase(ctx.manifestUrl, stripBase),
5040
+ url: manifestRequestUrl,
5053
5041
  method: 'get'
5054
5042
  });
5055
5043
  const data = unwrapNestedManifestBody(body);
@@ -5081,7 +5069,9 @@ function createVueCliAxiosInstallOptions(deps, extra = {}) {
5081
5069
  ...extra,
5082
5070
  manifest: {
5083
5071
  ...manifest,
5084
- baseUrl: stripBase || undefined,
5072
+ baseUrl: manifest.baseUrl !== undefined && String(manifest.baseUrl).trim() !== ''
5073
+ ? String(manifest.baseUrl).replace(/\/$/, '')
5074
+ : undefined,
5085
5075
  listPath: manifest.listPath !== undefined ? manifest.listPath : listPath,
5086
5076
  source: manifestSource,
5087
5077
  staticUrl,