@module-federation/bridge-vue3 0.6.13 → 0.6.14
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 +9 -0
- package/dist/index.cjs.js +6 -3
- package/dist/index.es.js +281 -99
- package/package.json +3 -2
- package/src/utils.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @module-federation/bridge-vue3
|
|
2
2
|
|
|
3
|
+
## 0.6.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ad605d2: chore: unified logger
|
|
8
|
+
- Updated dependencies [ad605d2]
|
|
9
|
+
- @module-federation/bridge-shared@0.6.14
|
|
10
|
+
- @module-federation/sdk@0.6.14
|
|
11
|
+
|
|
3
12
|
## 0.6.13
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
`)
|
|
3
|
-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("vue"),O=require("vue-router");function j(e){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const t=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(o,r,t.get?t:{enumerable:!0,get:()=>e[r]})}}return o.default=e,Object.freeze(o)}const G=j(d),E=j(O);var $=Object.defineProperty,W=Object.getOwnPropertyDescriptor,U=Object.getOwnPropertyNames,T=Object.prototype.hasOwnProperty,k=(e,o)=>{for(var r in o)$(e,r,{get:o[r],enumerable:!0})},x=(e,o,r,t)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of U(o))!T.call(e,n)&&n!==r&&$(e,n,{get:()=>o[n],enumerable:!(t=W(o,n))||t.enumerable});return e},z=e=>x($({},"__esModule",{value:!0}),e),A={};k(A,{createLogger:()=>M,logger:()=>ne});var H=z(A),R=void 0,I=()=>{if(typeof R<"u")return R;try{console.log("%c","color:"),R=!0}catch{R=!1}return R},h={bold:"font-weight: bold;",red:"color: red;",green:"color: green;",yellow:"color: yellow;",magenta:"color: magenta;",cyan:"color: cyan;",gray:"color: gray;"},v=e=>I()?o=>{if(Array.isArray(o)){const[r,t]=o;return[`%c${r.replace("%c","")}`,t?`${h[e]}${t}`:`${h[e]||""}`]}return[`%c${String(o).replace("%c","")}`,h[e]||""]}:o=>[String(o)],q=v("bold"),J=v("red"),S=v("green"),K=v("yellow"),X=v("magenta"),L=v("cyan");v("gray");function Y(e,o,r){let t=[""];return"label"in o&&(t=[r[e]||o.label||""],t=q(o.color?o.color(t):t[0])),t=t.filter(Boolean),t}function Q(e,o,r,t){e.length?Array.isArray(t)?console.log(...e,...t):console.log(...e,o):Array.isArray(t)?console.log(...t):console.log(o,...r)}var P={error:0,warn:1,info:2,log:3,verbose:4},Z=/at\s.*:\d+:\d+[\s\)]*$/,ee=/at\s.*\(<anonymous>\)$/,oe=e=>Z.test(e)||ee.test(e),re=(e={},{getLabel:o,handleError:r,finalLog:t,greet:n,LOG_TYPES:c})=>{let l=e.level||"log",a=e.labels||{},m=(s,u,...F)=>{if(P[c[s].level]>P[l])return;if(u==null)return console.log();let C=c[s],b="";const V=o(s,C,a);if(u instanceof Error)if(u.stack){let[y,..._]=u.stack.split(`
|
|
2
|
+
`);y.startsWith("Error: ")&&(y=y.slice(7)),b=`${y}
|
|
3
|
+
${r(_.join(`
|
|
4
|
+
`))}`}else b=u.message;else C.level==="error"&&typeof u=="string"?b=u.split(`
|
|
5
|
+
`).map(_=>oe(_)?r(_):_).join(`
|
|
6
|
+
`):b=`${u}`;t(V,b,F,u)},i={greet:s=>m("log",n(s))};return Object.keys(c).forEach(s=>{i[s]=(...u)=>m(s,...u)}),Object.defineProperty(i,"level",{get:()=>l,set(s){l=s}}),Object.defineProperty(i,"labels",{get:()=>a,set(s){a=s}}),i.override=s=>{Object.assign(i,s)},i},p=[189,255,243],w=[74,194,154],B=e=>!/[\s\n]/.test(e);function D(e){if(!I())return[e];const o=[...e],r=o.filter(B),t=r.length-1;if(t===0)return console.log(`%c${e}`,`color: rgb(${p.join(",")}); font-weight: bold;`),[e];let n="",c=[];return o.forEach(l=>{if(B(l)){const a=r.indexOf(l)/t,m=Math.round(p[0]+(w[0]-p[0])*a),i=Math.round(p[1]+(w[1]-p[1])*a),s=Math.round(p[2]+(w[2]-p[2])*a);n+=`%c${l}`,c.push(`color: rgb(${m},${i},${s}); font-weight: bold;`)}else n+=l}),[n,...c]}var te={error:{label:"error",level:"error",color:J},warn:{label:"warn",level:"warn",color:K},info:{label:"info",level:"info",color:L},start:{label:"start",level:"info",color:L},ready:{label:"ready",level:"info",color:S},success:{label:"success",level:"info",color:S},log:{level:"log"},debug:{label:"debug",level:"verbose",color:X}};function M(e={}){return re(e,{handleError:o=>o,getLabel:Y,gradient:D,finalLog:Q,LOG_TYPES:te,greet:o=>D(o)})}var ne=M();const ae="FEDERATION_DEBUG",le="1";function ce(){return typeof window<"u"}function se(){try{if(ce()&&window.localStorage)return localStorage.getItem(ae)===le}catch{return!1}return!1}function ue(){return typeof process<"u"&&process.env&&process.env.FEDERATION_DEBUG?!!process.env.FEDERATION_DEBUG:typeof FEDERATION_DEBUG<"u"&&FEDERATION_DEBUG?!0:se()}const f="[ Module Federation ]";function ie(e){ue()&&(e.level="verbose")}function de(e,o){e.labels={warn:`${o} Warn`,error:`${o} Error`,success:`${o} Success`,info:`${o} Info`,ready:`${o} Ready`,debug:`${o} Debug`}}function N(e){const o=H.createLogger({labels:{warn:`${f} Warn`,error:`${f} Error`,success:`${f} Success`,info:`${f} Info`,ready:`${f} Ready`,debug:`${f} Debug`}});return ie(o),de(o,e),o}N(f);const g=N("[ Module Federation Bridge Vue3 ]");function me(e){const o=new Map;return()=>({__APP_VERSION__:"0.6.14",render(r){g.log("createBridgeComponent render Info",r);const t=G.createApp(e.rootComponent);o.set(r.dom,t);const n=e.appOptions({basename:r.basename,memoryRoute:r.memoryRoute}),c=r.memoryRoute?E.createMemoryHistory(r.basename):E.createWebHistory(r.basename),l=E.createRouter({...n.router.options,history:c,routes:n.router.getRoutes()});g.log("createBridgeComponent render router info>>>",{name:r.moduleName,router:l}),r.memoryRoute?l.push(r.memoryRoute.entryPath).then(()=>{t.use(l),t.mount(r.dom)}):(t.use(l),t.mount(r.dom))},destroy(r){g.log("createBridgeComponent destroy Info",r);const t=o.get(r==null?void 0:r.dom);t==null||t.unmount()}})}function ge(){const e=new PopStateEvent("popstate",{state:window.history.state});window.dispatchEvent(e)}const pe=d.defineComponent({name:"RemoteApp",props:{moduleName:String,basename:String,memoryRoute:Object,providerInfo:Function},setup(e){const o=d.ref(null),r=d.ref(null),t=d.ref(""),n=O.useRoute(),c=()=>{var i;const a=(i=e.providerInfo)==null?void 0:i.call(e);r.value=a;const m={name:e.moduleName,dom:o.value,basename:e.basename,memoryRoute:e.memoryRoute};g.log("createRemoteComponent LazyComponent render >>>",m),a.render(m)},l=d.watch(()=>n.path,a=>{a!==n.path&&c(),t.value!==""&&t.value!==a&&(g.log("createRemoteComponent dispatchPopstateEnv >>>",{...e,pathname:n.path}),ge()),t.value=a});return d.onMounted(()=>{c()}),d.onBeforeUnmount(()=>{var a;g.log("createRemoteComponent LazyComponent destroy >>>",{...e}),l(),(a=r.value)==null||a.destroy({dom:o.value})}),()=>d.createVNode("div",{ref:o},null)}});function fe(e){return d.defineAsyncComponent({__APP_VERSION__:"0.6.14",loader:async()=>{var m;const o=O.useRoute();let r="/";const t=(m=o.matched[0])==null?void 0:m.path;t&&(t.endsWith("/:pathMatch(.*)*")?r=t.replace("/:pathMatch(.*)*",""):r=o.matched[0].path);const n=(e==null?void 0:e.export)||"default";g.log("createRemoteComponent LazyComponent create >>>",{basename:r,info:e});const c=await e.loader(),l=c&&c[Symbol.for("mf_module_id")],a=c[n];if(g.log("createRemoteComponent LazyComponent loadRemote info >>>",{name:l,module:c,exportName:n,basename:r,route:o}),n in c&&typeof a=="function")return{render(){return d.h(pe,{moduleName:l,...e,providerInfo:a,basename:r})}};throw new Error("module not found")},loadingComponent:{template:"<div>Loading...</div>"},errorComponent:{template:"<div>Error loading component</div>"},delay:200,timeout:3e3})}exports.createBridgeComponent=me;exports.createRemoteComponent=fe;
|
package/dist/index.es.js
CHANGED
|
@@ -1,69 +1,251 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { defineComponent as
|
|
3
|
-
import * as
|
|
4
|
-
import { useRoute as
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import * as G from "vue";
|
|
2
|
+
import { defineComponent as V, ref as R, watch as W, onMounted as U, onBeforeUnmount as x, createVNode as k, defineAsyncComponent as z, h as T } from "vue";
|
|
3
|
+
import * as h from "vue-router";
|
|
4
|
+
import { useRoute as B } from "vue-router";
|
|
5
|
+
var O = Object.defineProperty, H = Object.getOwnPropertyDescriptor, J = Object.getOwnPropertyNames, K = Object.prototype.hasOwnProperty, X = (e, o) => {
|
|
6
|
+
for (var r in o)
|
|
7
|
+
O(e, r, { get: o[r], enumerable: !0 });
|
|
8
|
+
}, Y = (e, o, r, t) => {
|
|
9
|
+
if (o && typeof o == "object" || typeof o == "function")
|
|
10
|
+
for (let n of J(o))
|
|
11
|
+
!K.call(e, n) && n !== r && O(e, n, { get: () => o[n], enumerable: !(t = H(o, n)) || t.enumerable });
|
|
12
|
+
return e;
|
|
13
|
+
}, q = (e) => Y(O({}, "__esModule", { value: !0 }), e), I = {};
|
|
14
|
+
X(I, {
|
|
15
|
+
createLogger: () => N,
|
|
16
|
+
logger: () => de
|
|
17
|
+
});
|
|
18
|
+
var Q = q(I), E = void 0, D = () => {
|
|
19
|
+
if (typeof E < "u")
|
|
20
|
+
return E;
|
|
21
|
+
try {
|
|
22
|
+
console.log("%c", "color:"), E = !0;
|
|
23
|
+
} catch {
|
|
24
|
+
E = !1;
|
|
9
25
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
26
|
+
return E;
|
|
27
|
+
}, _ = {
|
|
28
|
+
bold: "font-weight: bold;",
|
|
29
|
+
red: "color: red;",
|
|
30
|
+
green: "color: green;",
|
|
31
|
+
yellow: "color: yellow;",
|
|
32
|
+
magenta: "color: magenta;",
|
|
33
|
+
cyan: "color: cyan;",
|
|
34
|
+
gray: "color: gray;"
|
|
35
|
+
}, f = (e) => D() ? (o) => {
|
|
36
|
+
if (Array.isArray(o)) {
|
|
37
|
+
const [r, t] = o;
|
|
38
|
+
return [`%c${r.replace("%c", "")}`, t ? `${_[e]}${t}` : `${_[e] || ""}`];
|
|
18
39
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
40
|
+
return [`%c${String(o).replace("%c", "")}`, _[e] || ""];
|
|
41
|
+
} : (o) => [String(o)], Z = f("bold"), ee = f("red"), C = f("green"), oe = f("yellow"), re = f("magenta"), L = f("cyan");
|
|
42
|
+
f("gray");
|
|
43
|
+
function te(e, o, r) {
|
|
44
|
+
let t = [""];
|
|
45
|
+
return "label" in o && (t = [r[e] || o.label || ""], t = Z(o.color ? o.color(t) : t[0])), t = t.filter(Boolean), t;
|
|
46
|
+
}
|
|
47
|
+
function ne(e, o, r, t) {
|
|
48
|
+
e.length ? Array.isArray(t) ? console.log(...e, ...t) : console.log(...e, o) : Array.isArray(t) ? console.log(...t) : console.log(o, ...r);
|
|
49
|
+
}
|
|
50
|
+
var P = {
|
|
51
|
+
error: 0,
|
|
52
|
+
warn: 1,
|
|
53
|
+
info: 2,
|
|
54
|
+
log: 3,
|
|
55
|
+
verbose: 4
|
|
56
|
+
}, ae = /at\s.*:\d+:\d+[\s\)]*$/, le = /at\s.*\(<anonymous>\)$/, ce = (e) => ae.test(e) || le.test(e), se = (e = {}, { getLabel: o, handleError: r, finalLog: t, greet: n, LOG_TYPES: c }) => {
|
|
57
|
+
let l = e.level || "log", a = e.labels || {}, i = (s, u, ...j) => {
|
|
58
|
+
if (P[c[s].level] > P[l])
|
|
59
|
+
return;
|
|
60
|
+
if (u == null)
|
|
61
|
+
return console.log();
|
|
62
|
+
let $ = c[s], v = "";
|
|
63
|
+
const F = o(s, $, a);
|
|
64
|
+
if (u instanceof Error)
|
|
65
|
+
if (u.stack) {
|
|
66
|
+
let [y, ...b] = u.stack.split(`
|
|
67
|
+
`);
|
|
68
|
+
y.startsWith("Error: ") && (y = y.slice(7)), v = `${y}
|
|
69
|
+
${r(b.join(`
|
|
70
|
+
`))}`;
|
|
71
|
+
} else
|
|
72
|
+
v = u.message;
|
|
73
|
+
else
|
|
74
|
+
$.level === "error" && typeof u == "string" ? v = u.split(`
|
|
75
|
+
`).map((b) => ce(b) ? r(b) : b).join(`
|
|
76
|
+
`) : v = `${u}`;
|
|
77
|
+
t(F, v, j, u);
|
|
78
|
+
}, d = {
|
|
79
|
+
// greet
|
|
80
|
+
greet: (s) => i("log", n(s))
|
|
81
|
+
};
|
|
82
|
+
return Object.keys(c).forEach((s) => {
|
|
83
|
+
d[s] = (...u) => i(s, ...u);
|
|
84
|
+
}), Object.defineProperty(d, "level", {
|
|
85
|
+
get: () => l,
|
|
86
|
+
set(s) {
|
|
87
|
+
l = s;
|
|
27
88
|
}
|
|
28
|
-
|
|
89
|
+
}), Object.defineProperty(d, "labels", {
|
|
90
|
+
get: () => a,
|
|
91
|
+
set(s) {
|
|
92
|
+
a = s;
|
|
93
|
+
}
|
|
94
|
+
}), d.override = (s) => {
|
|
95
|
+
Object.assign(d, s);
|
|
96
|
+
}, d;
|
|
97
|
+
}, g = [189, 255, 243], w = [74, 194, 154], S = (e) => !/[\s\n]/.test(e);
|
|
98
|
+
function A(e) {
|
|
99
|
+
if (!D())
|
|
100
|
+
return [e];
|
|
101
|
+
const o = [...e], r = o.filter(S), t = r.length - 1;
|
|
102
|
+
if (t === 0)
|
|
103
|
+
return console.log(`%c${e}`, `color: rgb(${g.join(",")}); font-weight: bold;`), [e];
|
|
104
|
+
let n = "", c = [];
|
|
105
|
+
return o.forEach((l) => {
|
|
106
|
+
if (S(l)) {
|
|
107
|
+
const a = r.indexOf(l) / t, i = Math.round(g[0] + (w[0] - g[0]) * a), d = Math.round(g[1] + (w[1] - g[1]) * a), s = Math.round(g[2] + (w[2] - g[2]) * a);
|
|
108
|
+
n += `%c${l}`, c.push(`color: rgb(${i},${d},${s}); font-weight: bold;`);
|
|
109
|
+
} else
|
|
110
|
+
n += l;
|
|
111
|
+
}), [n, ...c];
|
|
112
|
+
}
|
|
113
|
+
var ue = {
|
|
114
|
+
// Level error
|
|
115
|
+
error: {
|
|
116
|
+
label: "error",
|
|
117
|
+
level: "error",
|
|
118
|
+
color: ee
|
|
119
|
+
},
|
|
120
|
+
// Level warn
|
|
121
|
+
warn: {
|
|
122
|
+
label: "warn",
|
|
123
|
+
level: "warn",
|
|
124
|
+
color: oe
|
|
125
|
+
},
|
|
126
|
+
// Level info
|
|
127
|
+
info: {
|
|
128
|
+
label: "info",
|
|
129
|
+
level: "info",
|
|
130
|
+
color: L
|
|
131
|
+
},
|
|
132
|
+
start: {
|
|
133
|
+
label: "start",
|
|
134
|
+
level: "info",
|
|
135
|
+
color: L
|
|
136
|
+
},
|
|
137
|
+
ready: {
|
|
138
|
+
label: "ready",
|
|
139
|
+
level: "info",
|
|
140
|
+
color: C
|
|
141
|
+
},
|
|
142
|
+
success: {
|
|
143
|
+
label: "success",
|
|
144
|
+
level: "info",
|
|
145
|
+
color: C
|
|
146
|
+
},
|
|
147
|
+
// Level log
|
|
148
|
+
log: {
|
|
149
|
+
level: "log"
|
|
150
|
+
},
|
|
151
|
+
// Level debug
|
|
152
|
+
debug: {
|
|
153
|
+
label: "debug",
|
|
154
|
+
level: "verbose",
|
|
155
|
+
color: re
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
function N(e = {}) {
|
|
159
|
+
return se(e, {
|
|
160
|
+
handleError: (o) => o,
|
|
161
|
+
getLabel: te,
|
|
162
|
+
gradient: A,
|
|
163
|
+
finalLog: ne,
|
|
164
|
+
LOG_TYPES: ue,
|
|
165
|
+
greet: (o) => A(o)
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
var de = N();
|
|
169
|
+
const ie = "FEDERATION_DEBUG", me = "1";
|
|
170
|
+
function ge() {
|
|
171
|
+
return typeof window < "u";
|
|
172
|
+
}
|
|
173
|
+
function pe() {
|
|
174
|
+
try {
|
|
175
|
+
if (ge() && window.localStorage)
|
|
176
|
+
return localStorage.getItem(ie) === me;
|
|
177
|
+
} catch {
|
|
178
|
+
return !1;
|
|
29
179
|
}
|
|
180
|
+
return !1;
|
|
181
|
+
}
|
|
182
|
+
function fe() {
|
|
183
|
+
return typeof process < "u" && process.env && process.env.FEDERATION_DEBUG ? !!process.env.FEDERATION_DEBUG : typeof FEDERATION_DEBUG < "u" && FEDERATION_DEBUG ? !0 : pe();
|
|
184
|
+
}
|
|
185
|
+
const p = "[ Module Federation ]";
|
|
186
|
+
function ve(e) {
|
|
187
|
+
fe() && (e.level = "verbose");
|
|
30
188
|
}
|
|
31
|
-
function
|
|
32
|
-
|
|
33
|
-
|
|
189
|
+
function ye(e, o) {
|
|
190
|
+
e.labels = {
|
|
191
|
+
warn: `${o} Warn`,
|
|
192
|
+
error: `${o} Error`,
|
|
193
|
+
success: `${o} Success`,
|
|
194
|
+
info: `${o} Info`,
|
|
195
|
+
ready: `${o} Ready`,
|
|
196
|
+
debug: `${o} Debug`
|
|
197
|
+
};
|
|
34
198
|
}
|
|
35
|
-
|
|
36
|
-
|
|
199
|
+
function M(e) {
|
|
200
|
+
const o = Q.createLogger({
|
|
201
|
+
labels: {
|
|
202
|
+
warn: `${p} Warn`,
|
|
203
|
+
error: `${p} Error`,
|
|
204
|
+
success: `${p} Success`,
|
|
205
|
+
info: `${p} Info`,
|
|
206
|
+
ready: `${p} Ready`,
|
|
207
|
+
debug: `${p} Debug`
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
return ve(o), ye(o, e), o;
|
|
211
|
+
}
|
|
212
|
+
M(p);
|
|
213
|
+
const m = M("[ Module Federation Bridge Vue3 ]");
|
|
214
|
+
function _e(e) {
|
|
37
215
|
const o = /* @__PURE__ */ new Map();
|
|
38
216
|
return () => ({
|
|
39
|
-
__APP_VERSION__: "0.6.
|
|
40
|
-
render(
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
o.set(
|
|
44
|
-
const
|
|
45
|
-
basename:
|
|
46
|
-
memoryRoute:
|
|
47
|
-
}),
|
|
48
|
-
...
|
|
49
|
-
history:
|
|
50
|
-
routes:
|
|
217
|
+
__APP_VERSION__: "0.6.14",
|
|
218
|
+
render(r) {
|
|
219
|
+
m.log("createBridgeComponent render Info", r);
|
|
220
|
+
const t = G.createApp(e.rootComponent);
|
|
221
|
+
o.set(r.dom, t);
|
|
222
|
+
const n = e.appOptions({
|
|
223
|
+
basename: r.basename,
|
|
224
|
+
memoryRoute: r.memoryRoute
|
|
225
|
+
}), c = r.memoryRoute ? h.createMemoryHistory(r.basename) : h.createWebHistory(r.basename), l = h.createRouter({
|
|
226
|
+
...n.router.options,
|
|
227
|
+
history: c,
|
|
228
|
+
routes: n.router.getRoutes()
|
|
51
229
|
});
|
|
52
|
-
|
|
53
|
-
name:
|
|
54
|
-
router:
|
|
55
|
-
}),
|
|
56
|
-
|
|
57
|
-
}) : (
|
|
230
|
+
m.log("createBridgeComponent render router info>>>", {
|
|
231
|
+
name: r.moduleName,
|
|
232
|
+
router: l
|
|
233
|
+
}), r.memoryRoute ? l.push(r.memoryRoute.entryPath).then(() => {
|
|
234
|
+
t.use(l), t.mount(r.dom);
|
|
235
|
+
}) : (t.use(l), t.mount(r.dom));
|
|
58
236
|
},
|
|
59
|
-
destroy(
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
|
|
237
|
+
destroy(r) {
|
|
238
|
+
m.log("createBridgeComponent destroy Info", r);
|
|
239
|
+
const t = o.get(r == null ? void 0 : r.dom);
|
|
240
|
+
t == null || t.unmount();
|
|
63
241
|
}
|
|
64
242
|
});
|
|
65
243
|
}
|
|
66
|
-
|
|
244
|
+
function be() {
|
|
245
|
+
const e = new PopStateEvent("popstate", { state: window.history.state });
|
|
246
|
+
window.dispatchEvent(e);
|
|
247
|
+
}
|
|
248
|
+
const Ee = /* @__PURE__ */ V({
|
|
67
249
|
name: "RemoteApp",
|
|
68
250
|
props: {
|
|
69
251
|
moduleName: String,
|
|
@@ -71,65 +253,65 @@ const N = /* @__PURE__ */ y({
|
|
|
71
253
|
memoryRoute: Object,
|
|
72
254
|
providerInfo: Function
|
|
73
255
|
},
|
|
74
|
-
setup(
|
|
75
|
-
const o =
|
|
76
|
-
var
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
name:
|
|
256
|
+
setup(e) {
|
|
257
|
+
const o = R(null), r = R(null), t = R(""), n = B(), c = () => {
|
|
258
|
+
var d;
|
|
259
|
+
const a = (d = e.providerInfo) == null ? void 0 : d.call(e);
|
|
260
|
+
r.value = a;
|
|
261
|
+
const i = {
|
|
262
|
+
name: e.moduleName,
|
|
81
263
|
dom: o.value,
|
|
82
|
-
basename:
|
|
83
|
-
memoryRoute:
|
|
264
|
+
basename: e.basename,
|
|
265
|
+
memoryRoute: e.memoryRoute
|
|
84
266
|
};
|
|
85
|
-
|
|
86
|
-
},
|
|
87
|
-
|
|
88
|
-
...
|
|
89
|
-
pathname:
|
|
90
|
-
}),
|
|
267
|
+
m.log("createRemoteComponent LazyComponent render >>>", i), a.render(i);
|
|
268
|
+
}, l = W(() => n.path, (a) => {
|
|
269
|
+
a !== n.path && c(), t.value !== "" && t.value !== a && (m.log("createRemoteComponent dispatchPopstateEnv >>>", {
|
|
270
|
+
...e,
|
|
271
|
+
pathname: n.path
|
|
272
|
+
}), be()), t.value = a;
|
|
91
273
|
});
|
|
92
|
-
return
|
|
93
|
-
|
|
94
|
-
}),
|
|
95
|
-
var
|
|
96
|
-
|
|
97
|
-
...
|
|
98
|
-
}),
|
|
274
|
+
return U(() => {
|
|
275
|
+
c();
|
|
276
|
+
}), x(() => {
|
|
277
|
+
var a;
|
|
278
|
+
m.log("createRemoteComponent LazyComponent destroy >>>", {
|
|
279
|
+
...e
|
|
280
|
+
}), l(), (a = r.value) == null || a.destroy({
|
|
99
281
|
dom: o.value
|
|
100
282
|
});
|
|
101
|
-
}), () =>
|
|
283
|
+
}), () => k("div", {
|
|
102
284
|
ref: o
|
|
103
285
|
}, null);
|
|
104
286
|
}
|
|
105
287
|
});
|
|
106
|
-
function
|
|
107
|
-
return
|
|
108
|
-
__APP_VERSION__: "0.6.
|
|
288
|
+
function we(e) {
|
|
289
|
+
return z({
|
|
290
|
+
__APP_VERSION__: "0.6.14",
|
|
109
291
|
//@ts-ignore
|
|
110
292
|
loader: async () => {
|
|
111
|
-
var
|
|
112
|
-
const o =
|
|
113
|
-
let
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
basename:
|
|
119
|
-
info:
|
|
293
|
+
var i;
|
|
294
|
+
const o = B();
|
|
295
|
+
let r = "/";
|
|
296
|
+
const t = (i = o.matched[0]) == null ? void 0 : i.path;
|
|
297
|
+
t && (t.endsWith("/:pathMatch(.*)*") ? r = t.replace("/:pathMatch(.*)*", "") : r = o.matched[0].path);
|
|
298
|
+
const n = (e == null ? void 0 : e.export) || "default";
|
|
299
|
+
m.log("createRemoteComponent LazyComponent create >>>", {
|
|
300
|
+
basename: r,
|
|
301
|
+
info: e
|
|
120
302
|
});
|
|
121
|
-
const
|
|
122
|
-
if (
|
|
303
|
+
const c = await e.loader(), l = c && c[Symbol.for("mf_module_id")], a = c[n];
|
|
304
|
+
if (m.log(
|
|
123
305
|
"createRemoteComponent LazyComponent loadRemote info >>>",
|
|
124
|
-
{ name:
|
|
125
|
-
),
|
|
306
|
+
{ name: l, module: c, exportName: n, basename: r, route: o }
|
|
307
|
+
), n in c && typeof a == "function")
|
|
126
308
|
return {
|
|
127
309
|
render() {
|
|
128
|
-
return
|
|
129
|
-
moduleName:
|
|
130
|
-
...
|
|
131
|
-
providerInfo:
|
|
132
|
-
basename:
|
|
310
|
+
return T(Ee, {
|
|
311
|
+
moduleName: l,
|
|
312
|
+
...e,
|
|
313
|
+
providerInfo: a,
|
|
314
|
+
basename: r
|
|
133
315
|
});
|
|
134
316
|
}
|
|
135
317
|
};
|
|
@@ -146,6 +328,6 @@ function D(t) {
|
|
|
146
328
|
});
|
|
147
329
|
}
|
|
148
330
|
export {
|
|
149
|
-
|
|
150
|
-
|
|
331
|
+
_e as createBridgeComponent,
|
|
332
|
+
we as createRemoteComponent
|
|
151
333
|
};
|
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.14",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
"vue-router": "=3"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@module-federation/bridge-shared": "0.6.
|
|
29
|
+
"@module-federation/bridge-shared": "0.6.14",
|
|
30
|
+
"@module-federation/sdk": "0.6.14"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
33
|
"@vitejs/plugin-vue": "^5.0.4",
|
package/src/utils.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createLogger } from '@module-federation/sdk';
|
|
2
2
|
|
|
3
|
-
export const LoggerInstance =
|
|
3
|
+
export const LoggerInstance = createLogger('[ Module Federation Bridge Vue3 ]');
|