web-extend-plugin-vue2 0.3.5 → 0.3.6

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
@@ -4895,6 +4895,43 @@ function installWebExtendPluginVue2(Vue, router, options) {
4895
4895
  return bootstrapPlugins$1(router, (id, r, kit) => createHostApi(id, r, kit || {}), runtime);
4896
4896
  }
4897
4897
 
4898
+ function isRecord(input) {
4899
+ return !!input && typeof input === 'object' && !Array.isArray(input);
4900
+ }
4901
+ function normalizeComponent(entry) {
4902
+ if (isRecord(entry) && 'component' in entry) {
4903
+ return entry.component;
4904
+ }
4905
+ return entry;
4906
+ }
4907
+ function toComponentAlias(name) {
4908
+ return name
4909
+ .trim()
4910
+ .replace(/([a-z0-9])([A-Z])/g, '$1-$2')
4911
+ .replace(/[^a-zA-Z0-9]+/g, '-')
4912
+ .replace(/^-+|-+$/g, '')
4913
+ .toLowerCase();
4914
+ }
4915
+ function installHostBridge(
4916
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4917
+ VueRuntime, options = {}) {
4918
+ if (!VueRuntime || typeof VueRuntime.component !== 'function' || !VueRuntime.prototype) {
4919
+ throw new Error('[wep] installHostBridge requires a Vue 2 runtime constructor');
4920
+ }
4921
+ const modules = options.modules && isRecord(options.modules) ? Object.freeze({ ...options.modules }) : Object.freeze({});
4922
+ VueRuntime.prototype.$host = modules;
4923
+ const componentEntries = options.components && isRecord(options.components) ? Object.entries(options.components) : [];
4924
+ for (const [rawName, rawEntry] of componentEntries) {
4925
+ const alias = toComponentAlias(String(rawName));
4926
+ const component = normalizeComponent(rawEntry);
4927
+ if (!alias || component == null) {
4928
+ continue;
4929
+ }
4930
+ VueRuntime.component(alias, component);
4931
+ }
4932
+ return modules;
4933
+ }
4934
+
4898
4935
  function resolveManifestPathUnderApiBase(manifestUrl, apiBase) {
4899
4936
  const base = String(apiBase !== undefined
4900
4937
  ? apiBase
@@ -4978,5 +5015,5 @@ function createVueCliAxiosInstallOptions(deps, extra = {}) {
4978
5015
  const { bootstrapPlugins, defaultFetchWebPluginManifest, resolveRuntimeOptions, ensurePluginHostRoute, getActivatedPluginIds } = pluginRuntime;
4979
5016
  const { composeManifestFetch, manifestFetchCacheMiddleware, wrapManifestFetchWithCache } = manifestComposer;
4980
5017
 
4981
- export { ExtensionPoint, HOST_PLUGIN_API_VERSION, RUNTIME_CONSOLE_LABEL, bootstrapPlugins, composeManifestFetch, createHostApi, createRequestBridge, createVueCliAxiosInstallOptions, defaultFetchWebPluginManifest, defaultManifestFetchCache, defaultManifestMode, defaultWebExtendPluginRuntime, disposeWebPlugin, ensurePluginHostRoute, getActivatedPluginIds, getAllHostComponentMeta, getAllHostModuleMeta, getContributedRoutesForPlugin, getHostComponent, getHostComponentMeta, getHostModule, getHostModuleMeta, getRegisteredTopRouteNamesForPlugin, installWebExtendPluginVue2, manifestFetchCacheMiddleware, peerMinimumVersions, registerHostComponents, registerHostModules, registerVueGlobalComponents, registries, resolveRuntimeOptions, routeSynthNamePrefix, setWebExtendPluginEnv, webExtendPluginEnvKeys, wrapManifestFetchWithCache };
5018
+ export { ExtensionPoint, HOST_PLUGIN_API_VERSION, RUNTIME_CONSOLE_LABEL, bootstrapPlugins, composeManifestFetch, createHostApi, createRequestBridge, createVueCliAxiosInstallOptions, defaultFetchWebPluginManifest, defaultManifestFetchCache, defaultManifestMode, defaultWebExtendPluginRuntime, disposeWebPlugin, ensurePluginHostRoute, getActivatedPluginIds, getAllHostComponentMeta, getAllHostModuleMeta, getContributedRoutesForPlugin, getHostComponent, getHostComponentMeta, getHostModule, getHostModuleMeta, getRegisteredTopRouteNamesForPlugin, installHostBridge, installWebExtendPluginVue2, manifestFetchCacheMiddleware, peerMinimumVersions, registerHostComponents, registerHostModules, registerVueGlobalComponents, registries, resolveRuntimeOptions, routeSynthNamePrefix, setWebExtendPluginEnv, webExtendPluginEnvKeys, wrapManifestFetchWithCache };
4982
5019
  //# sourceMappingURL=index.mjs.map