@module-federation/bridge-vue3 0.6.12 → 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 CHANGED
@@ -1,5 +1,20 @@
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
+
12
+ ## 0.6.13
13
+
14
+ ### Patch Changes
15
+
16
+ - @module-federation/bridge-shared@0.6.13
17
+
3
18
  ## 0.6.12
4
19
 
5
20
  ### Patch Changes
package/dist/index.cjs.js CHANGED
@@ -1,3 +1,6 @@
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])==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.12",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.12",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;
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 h from "vue";
2
- import { defineComponent as y, ref as l, watch as b, onMounted as v, onBeforeUnmount as R, createVNode as f, defineAsyncComponent as C, h as w } from "vue";
3
- import * as d from "vue-router";
4
- import { useRoute as g } from "vue-router";
5
- var E = Object.defineProperty, _ = (t, o, e) => o in t ? E(t, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[o] = e, p = (t, o, e) => (_(t, typeof o != "symbol" ? o + "" : o, e), e);
6
- class S {
7
- constructor(o) {
8
- p(this, "name"), p(this, "isDebugEnabled"), p(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");
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
- log(...o) {
11
- var e, n;
12
- if (this.isDebugEnabled) {
13
- const r = `color: ${this.color}; font-weight: bold`, a = `%c[${this.name}]`, s = ((n = (e = new Error().stack) == null ? void 0 : e.split(`
14
- `)[2]) == null ? void 0 : n.trim()) || "Stack information not available";
15
- typeof console < "u" && console.debug && console.debug(a, r, ...o, `
16
- (${s})`);
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
- stringToColor(o) {
20
- let e = 0;
21
- for (let r = 0; r < o.length; r++)
22
- e = o.charCodeAt(r) + ((e << 5) - e);
23
- let n = "#";
24
- for (let r = 0; r < 3; r++) {
25
- const a = e >> r * 8 & 255;
26
- n += ("00" + a.toString(16)).substr(-2);
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
- return n;
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 I() {
32
- const t = new PopStateEvent("popstate", { state: window.history.state });
33
- window.dispatchEvent(t);
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
- const u = new S("vue3-bridge");
36
- function B(t) {
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.12",
40
- render(e) {
41
- u.log("createBridgeComponent render Info", e);
42
- const n = h.createApp(t.rootComponent);
43
- o.set(e.dom, n);
44
- const r = t.appOptions({
45
- basename: e.basename,
46
- memoryRoute: e.memoryRoute
47
- }), a = e.memoryRoute ? d.createMemoryHistory(e.basename) : d.createWebHistory(e.basename), s = d.createRouter({
48
- ...r.router.options,
49
- history: a,
50
- routes: r.router.getRoutes()
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
- u.log("createBridgeComponent render router info>>>", {
53
- name: e.moduleName,
54
- router: s
55
- }), e.memoryRoute ? s.push(e.memoryRoute.entryPath).then(() => {
56
- n.use(s), n.mount(e.dom);
57
- }) : (n.use(s), n.mount(e.dom));
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(e) {
60
- u.log("createBridgeComponent destroy Info", e);
61
- const n = o.get(e == null ? void 0 : e.dom);
62
- n == null || n.unmount();
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
- const N = /* @__PURE__ */ y({
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(t) {
75
- const o = l(null), e = l(null), n = l(""), r = g(), a = () => {
76
- var i;
77
- const m = (i = t.providerInfo) == null ? void 0 : i.call(t);
78
- e.value = m;
79
- const c = {
80
- name: t.moduleName,
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: t.basename,
83
- memoryRoute: t.memoryRoute
264
+ basename: e.basename,
265
+ memoryRoute: e.memoryRoute
84
266
  };
85
- u.log("createRemoteComponent LazyComponent render >>>", c), m.render(c);
86
- }, s = b(() => r.path, (m) => {
87
- m !== r.path && a(), n.value !== "" && n.value !== m && (u.log("createRemoteComponent dispatchPopstateEnv >>>", {
88
- ...t,
89
- pathname: r.path
90
- }), I()), n.value = m;
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 v(() => {
93
- a();
94
- }), R(() => {
95
- var m;
96
- u.log("createRemoteComponent LazyComponent destroy >>>", {
97
- ...t
98
- }), s(), (m = e.value) == null || m.destroy({
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
- }), () => f("div", {
283
+ }), () => k("div", {
102
284
  ref: o
103
285
  }, null);
104
286
  }
105
287
  });
106
- function D(t) {
107
- return C({
108
- __APP_VERSION__: "0.6.12",
288
+ function we(e) {
289
+ return z({
290
+ __APP_VERSION__: "0.6.14",
109
291
  //@ts-ignore
110
292
  loader: async () => {
111
- var c;
112
- const o = g();
113
- let e = "/";
114
- const n = (c = o.matched[0]) == null ? void 0 : c.path;
115
- n && (n.endsWith("/:pathMatch(.*)*") ? e = n.replace("/:pathMatch(.*)*", "") : e = o.matched[0].path);
116
- const r = (t == null ? void 0 : t.export) || "default";
117
- u.log("createRemoteComponent LazyComponent create >>>", {
118
- basename: e,
119
- info: t
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 a = await t.loader(), s = a && a[Symbol.for("mf_module_id")], m = a[r];
122
- if (u.log(
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: s, module: a, exportName: r, basename: e, route: o }
125
- ), r in a && typeof m == "function")
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 w(N, {
129
- moduleName: s,
130
- ...t,
131
- providerInfo: m,
132
- basename: e
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
- B as createBridgeComponent,
150
- D as createRemoteComponent
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.12",
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.12"
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 { Logger } from '@module-federation/bridge-shared';
1
+ import { createLogger } from '@module-federation/sdk';
2
2
 
3
- export const LoggerInstance = new Logger('vue3-bridge');
3
+ export const LoggerInstance = createLogger('[ Module Federation Bridge Vue3 ]');