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/dist/index.mjs CHANGED
@@ -39,8 +39,8 @@ const defaultManifestFetchCache = {
39
39
  };
40
40
  const routeSynthNamePrefix = '__wep_';
41
41
  const defaultWebExtendPluginRuntime = {
42
- manifestBase: '/fp-api',
43
- manifestListPath: '/api/frontend-plugins',
42
+ manifestBase: '/dev-api',
43
+ manifestListPath: '/web-plugin',
44
44
  manifestFetchCredentials: 'include',
45
45
  devPingPath: '/__web_plugin_dev_ping',
46
46
  devReloadSsePath: '/__web_plugin_reload_stream',
@@ -50,7 +50,7 @@ const defaultWebExtendPluginRuntime = {
50
50
  allowedScriptHosts: ['localhost', '127.0.0.1', '::1'],
51
51
  bridgeAllowedPathPrefixes: ['/api/'],
52
52
  pluginMountPath: '/plugin',
53
- devFallbackStaticManifestUrl: '/web-plugins/plugins.manifest.json'
53
+ devFallbackStaticManifestUrl: ''
54
54
  };
55
55
 
56
56
  /**
@@ -330,7 +330,7 @@ function resolveDevManifestFallback(dev, manifestMode, isDev) {
330
330
  if (envFlag === '1' || envFlag === 'true') {
331
331
  return true;
332
332
  }
333
- return isDev;
333
+ return false;
334
334
  }
335
335
  function resolveRuntimeOptions$1(user = {}) {
336
336
  const manifest = resolveManifestInput(user);
@@ -392,7 +392,7 @@ function resolveRuntimeOptions$1(user = {}) {
392
392
  manifestListPath,
393
393
  manifestMode,
394
394
  staticManifestUrl,
395
- devManifestFallback: resolveDevManifestFallback(dev, manifestMode, isDev),
395
+ devManifestFallback: resolveDevManifestFallback(dev, manifestMode),
396
396
  devFallbackStaticManifestUrl,
397
397
  manifestFetchCredentials: resolveManifestCredentials(manifest.credentials, EK.manifestCredentials, DEF.manifestFetchCredentials),
398
398
  isDev,
@@ -4156,6 +4156,14 @@ function resolveManifestRequest(opts) {
4156
4156
  manifestUrl: `${base}${opts.manifestListPath}`
4157
4157
  };
4158
4158
  }
4159
+ function isResolvedRuntimeOptions(input) {
4160
+ return !!(input &&
4161
+ typeof input === 'object' &&
4162
+ !Array.isArray(input) &&
4163
+ ('manifestBase' in input ||
4164
+ 'manifestListPath' in input ||
4165
+ 'fetchManifest' in input));
4166
+ }
4159
4167
  async function bootstrapPlugins$1(
4160
4168
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
4161
4169
  router,
@@ -4167,7 +4175,7 @@ createHostApiFactory, runtimeOptions) {
4167
4175
  }
4168
4176
  printRuntimeBannerOnce();
4169
4177
  clearActivatedPluginIds();
4170
- const opts = resolveRuntimeOptions$1(runtimeOptions);
4178
+ const opts = isResolvedRuntimeOptions(runtimeOptions) ? runtimeOptions : resolveRuntimeOptions$1(runtimeOptions);
4171
4179
  const showBootstrapSummary = shouldShowBootstrapSummary(opts);
4172
4180
  setPluginBootstrapRouter(router);
4173
4181
  ensurePluginHostRoute$1(router, opts);
@@ -4999,22 +5007,6 @@ function installWebExtendPluginVue2(Vue, router, options) {
4999
5007
  return bootstrapPlugins$1(router, createHostApi, runtime);
5000
5008
  }
5001
5009
 
5002
- function resolveManifestPathUnderApiBase(manifestUrl, apiBase) {
5003
- const base = String(apiBase !== undefined
5004
- ? apiBase
5005
- : typeof process !== 'undefined' && process.env && process.env.VUE_APP_BASE_API
5006
- ? String(process.env.VUE_APP_BASE_API)
5007
- : '').replace(/\/$/, '');
5008
- if (typeof window === 'undefined') {
5009
- return '/api/frontend-plugins';
5010
- }
5011
- const url = new URL(manifestUrl, window.location.origin);
5012
- let path = url.pathname + url.search;
5013
- if (base && path.startsWith(base)) {
5014
- path = path.slice(base.length) || '/';
5015
- }
5016
- return path;
5017
- }
5018
5010
  function bridgePrefixesFromVueCliEnv() {
5019
5011
  const base = (typeof process !== 'undefined' && process.env && process.env.VUE_APP_BASE_API
5020
5012
  ? String(process.env.VUE_APP_BASE_API)
@@ -5033,17 +5025,13 @@ function createVueCliAxiosInstallOptions(deps, extra = {}) {
5033
5025
  const manifest = asRecord(extra.manifest) || {};
5034
5026
  const host = asRecord(extra.host) || {};
5035
5027
  const mergedHost = { ...host };
5036
- const envBase = (typeof process !== 'undefined' && process.env && process.env.VUE_APP_BASE_API
5037
- ? String(process.env.VUE_APP_BASE_API)
5038
- : '').replace(/\/$/, '');
5039
- const userBase = manifest.baseUrl !== undefined && String(manifest.baseUrl).trim() !== ''
5040
- ? String(manifest.baseUrl).replace(/\/$/, '')
5041
- : '';
5042
- const stripBase = userBase || envBase;
5043
5028
  const fetchManifestApi = async (ctx) => {
5044
5029
  try {
5030
+ const manifestRequestUrl = typeof window !== 'undefined'
5031
+ ? new URL(String(ctx.manifestUrl), window.location.origin).toString()
5032
+ : String(ctx.manifestUrl);
5045
5033
  const body = await request({
5046
- url: resolveManifestPathUnderApiBase(ctx.manifestUrl, stripBase),
5034
+ url: manifestRequestUrl,
5047
5035
  method: 'get'
5048
5036
  });
5049
5037
  const data = unwrapNestedManifestBody(body);
@@ -5075,7 +5063,9 @@ function createVueCliAxiosInstallOptions(deps, extra = {}) {
5075
5063
  ...extra,
5076
5064
  manifest: {
5077
5065
  ...manifest,
5078
- baseUrl: stripBase || undefined,
5066
+ baseUrl: manifest.baseUrl !== undefined && String(manifest.baseUrl).trim() !== ''
5067
+ ? String(manifest.baseUrl).replace(/\/$/, '')
5068
+ : undefined,
5079
5069
  listPath: manifest.listPath !== undefined ? manifest.listPath : listPath,
5080
5070
  source: manifestSource,
5081
5071
  staticUrl,