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.cjs +38 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +38 -1
- package/dist/index.mjs.map +1 -1
- package/index.d.ts +10 -0
- package/package.json +13 -13
package/dist/index.cjs
CHANGED
|
@@ -4901,6 +4901,43 @@ function installWebExtendPluginVue2(Vue, router, options) {
|
|
|
4901
4901
|
return bootstrapPlugins$1(router, (id, r, kit) => createHostApi(id, r, kit || {}), runtime);
|
|
4902
4902
|
}
|
|
4903
4903
|
|
|
4904
|
+
function isRecord(input) {
|
|
4905
|
+
return !!input && typeof input === 'object' && !Array.isArray(input);
|
|
4906
|
+
}
|
|
4907
|
+
function normalizeComponent(entry) {
|
|
4908
|
+
if (isRecord(entry) && 'component' in entry) {
|
|
4909
|
+
return entry.component;
|
|
4910
|
+
}
|
|
4911
|
+
return entry;
|
|
4912
|
+
}
|
|
4913
|
+
function toComponentAlias(name) {
|
|
4914
|
+
return name
|
|
4915
|
+
.trim()
|
|
4916
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1-$2')
|
|
4917
|
+
.replace(/[^a-zA-Z0-9]+/g, '-')
|
|
4918
|
+
.replace(/^-+|-+$/g, '')
|
|
4919
|
+
.toLowerCase();
|
|
4920
|
+
}
|
|
4921
|
+
function installHostBridge(
|
|
4922
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4923
|
+
VueRuntime, options = {}) {
|
|
4924
|
+
if (!VueRuntime || typeof VueRuntime.component !== 'function' || !VueRuntime.prototype) {
|
|
4925
|
+
throw new Error('[wep] installHostBridge requires a Vue 2 runtime constructor');
|
|
4926
|
+
}
|
|
4927
|
+
const modules = options.modules && isRecord(options.modules) ? Object.freeze({ ...options.modules }) : Object.freeze({});
|
|
4928
|
+
VueRuntime.prototype.$host = modules;
|
|
4929
|
+
const componentEntries = options.components && isRecord(options.components) ? Object.entries(options.components) : [];
|
|
4930
|
+
for (const [rawName, rawEntry] of componentEntries) {
|
|
4931
|
+
const alias = toComponentAlias(String(rawName));
|
|
4932
|
+
const component = normalizeComponent(rawEntry);
|
|
4933
|
+
if (!alias || component == null) {
|
|
4934
|
+
continue;
|
|
4935
|
+
}
|
|
4936
|
+
VueRuntime.component(alias, component);
|
|
4937
|
+
}
|
|
4938
|
+
return modules;
|
|
4939
|
+
}
|
|
4940
|
+
|
|
4904
4941
|
function resolveManifestPathUnderApiBase(manifestUrl, apiBase) {
|
|
4905
4942
|
const base = String(apiBase !== undefined
|
|
4906
4943
|
? apiBase
|
|
@@ -5007,6 +5044,7 @@ exports.getHostComponentMeta = getHostComponentMeta;
|
|
|
5007
5044
|
exports.getHostModule = getHostModule;
|
|
5008
5045
|
exports.getHostModuleMeta = getHostModuleMeta;
|
|
5009
5046
|
exports.getRegisteredTopRouteNamesForPlugin = getRegisteredTopRouteNamesForPlugin;
|
|
5047
|
+
exports.installHostBridge = installHostBridge;
|
|
5010
5048
|
exports.installWebExtendPluginVue2 = installWebExtendPluginVue2;
|
|
5011
5049
|
exports.manifestFetchCacheMiddleware = manifestFetchCacheMiddleware;
|
|
5012
5050
|
exports.peerMinimumVersions = peerMinimumVersions;
|