@module-federation/bridge-vue3 0.6.5 → 0.6.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/CHANGELOG.md +6 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +2 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/dist/index.cjs.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("vue"),p=require("vue-router");function b(t){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const n=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(o,e,n.get?n:{enumerable:!0,get:()=>t[e]})}}return o.default=t,Object.freeze(o)}const h=b(s),d=b(p);var y=Object.defineProperty,v=(t,o,e)=>o in t?y(t,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[o]=e,i=(t,o,e)=>(v(t,typeof o!="symbol"?o+"":o,e),e);class f{constructor(o){i(this,"name"),i(this,"isDebugEnabled"),i(this,"color"),this.name=o,this.isDebugEnabled=!1,this.color=this.stringToColor(o),typeof window<"u"&&typeof localStorage<"u"&&(this.isDebugEnabled=localStorage.getItem("debug")==="true"),typeof process<"u"&&process.env&&(this.isDebugEnabled=process.env.DEBUG==="true")}log(...o){var e,n;if(this.isDebugEnabled){const r=`color: ${this.color}; font-weight: bold`,a=`%c[${this.name}]`,u=((n=(e=new Error().stack)==null?void 0:e.split(`
|
|
2
2
|
`)[2])==null?void 0:n.trim())||"Stack information not available";typeof console<"u"&&console.debug&&console.debug(a,r,...o,`
|
|
3
|
-
(${u})`)}}stringToColor(o){let e=0;for(let r=0;r<o.length;r++)e=o.charCodeAt(r)+((e<<5)-e);let n="#";for(let r=0;r<3;r++){const a=e>>r*8&255;n+=("00"+a.toString(16)).substr(-2)}return n}}function R(){const t=new PopStateEvent("popstate",{state:window.history.state});window.dispatchEvent(t)}const c=new f("vue3-bridge");function C(t){const o=new Map;return()=>({__APP_VERSION__:"0.6.
|
|
3
|
+
(${u})`)}}stringToColor(o){let e=0;for(let r=0;r<o.length;r++)e=o.charCodeAt(r)+((e<<5)-e);let n="#";for(let r=0;r<3;r++){const a=e>>r*8&255;n+=("00"+a.toString(16)).substr(-2)}return n}}function R(){const t=new PopStateEvent("popstate",{state:window.history.state});window.dispatchEvent(t)}const c=new f("vue3-bridge");function C(t){const o=new Map;return()=>({__APP_VERSION__:"0.6.6",render(e){c.log("createBridgeComponent render Info",e);const n=h.createApp(t.rootComponent);o.set(e.dom,n);const r=t.appOptions({basename:e.basename,memoryRoute:e.memoryRoute}),a=e.memoryRoute?d.createMemoryHistory(e.basename):d.createWebHistory(e.basename),u=d.createRouter({...r.router.options,history:a,routes:r.router.getRoutes()});c.log("createBridgeComponent render router info>>>",{name:e.moduleName,router:u}),e.memoryRoute?u.push(e.memoryRoute.entryPath).then(()=>{n.use(u),n.mount(e.dom)}):(n.use(u),n.mount(e.dom))},destroy(e){c.log("createBridgeComponent destroy Info",e);const n=o.get(e==null?void 0:e.dom);n==null||n.unmount()}})}const _=s.defineComponent({name:"RemoteApp",props:{moduleName:String,basename:String,memoryRoute:Object,providerInfo:Function},setup(t){const o=s.ref(null),e=s.ref(null),n=s.ref(""),r=p.useRoute(),a=()=>{var g;const m=(g=t.providerInfo)==null?void 0:g.call(t);e.value=m;const l={name:t.moduleName,dom:o.value,basename:t.basename,memoryRoute:t.memoryRoute};c.log("createRemoteComponent LazyComponent render >>>",l),m.render(l)},u=s.watch(()=>r.path,m=>{m!==r.path&&a(),n.value!==""&&n.value!==m&&(c.log("createRemoteComponent dispatchPopstateEnv >>>",{...t,pathname:r.path}),R()),n.value=m});return s.onMounted(()=>{a()}),s.onBeforeUnmount(()=>{var m;c.log("createRemoteComponent LazyComponent destroy >>>",{...t}),u(),(m=e.value)==null||m.destroy({dom:o.value})}),()=>s.createVNode("div",{ref:o},null)}});function w(t){return s.defineAsyncComponent({__APP_VERSION__:"0.6.6",loader:async()=>{var l;const o=p.useRoute();let e="/";const n=(l=o.matched[0])==null?void 0:l.path;n&&(n.endsWith("/:pathMatch(.*)*")?e=n.replace("/:pathMatch(.*)*",""):e=o.matched[0].path);const r=(t==null?void 0:t.export)||"default";c.log("createRemoteComponent LazyComponent create >>>",{basename:e,info:t});const a=await t.loader(),u=a&&a[Symbol.for("mf_module_id")],m=a[r];if(c.log("createRemoteComponent LazyComponent loadRemote info >>>",{name:u,module:a,exportName:r,basename:e,route:o}),r in a&&typeof m=="function")return{render(){return s.h(_,{moduleName:u,...t,providerInfo:m,basename:e})}};throw new Error("module not found")},loadingComponent:{template:"<div>Loading...</div>"},errorComponent:{template:"<div>Error loading component</div>"},delay:200,timeout:3e3})}exports.createBridgeComponent=C;exports.createRemoteComponent=w;
|
package/dist/index.es.js
CHANGED
|
@@ -36,7 +36,7 @@ const u = new S("vue3-bridge");
|
|
|
36
36
|
function B(t) {
|
|
37
37
|
const o = /* @__PURE__ */ new Map();
|
|
38
38
|
return () => ({
|
|
39
|
-
__APP_VERSION__: "0.6.
|
|
39
|
+
__APP_VERSION__: "0.6.6",
|
|
40
40
|
render(e) {
|
|
41
41
|
u.log("createBridgeComponent render Info", e);
|
|
42
42
|
const n = h.createApp(t.rootComponent);
|
|
@@ -105,7 +105,7 @@ const N = /* @__PURE__ */ y({
|
|
|
105
105
|
});
|
|
106
106
|
function D(t) {
|
|
107
107
|
return C({
|
|
108
|
-
__APP_VERSION__: "0.6.
|
|
108
|
+
__APP_VERSION__: "0.6.6",
|
|
109
109
|
//@ts-ignore
|
|
110
110
|
loader: async () => {
|
|
111
111
|
var c;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/bridge-vue3",
|
|
3
3
|
"author": "zhouxiao <codingzx@gmail.com>",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.6",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"vue-router": "=3"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@module-federation/bridge-shared": "0.6.
|
|
29
|
+
"@module-federation/bridge-shared": "0.6.6"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@vitejs/plugin-vue": "^5.0.4",
|