@module-federation/bridge-shared 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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @module-federation/bridge-shared
2
2
 
3
+ ## 0.6.14
4
+
5
+ ### Patch Changes
6
+
7
+ - ad605d2: chore: unified logger
8
+
3
9
  ## 0.6.13
4
10
 
5
11
  ## 0.6.12
package/dist/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  export type { RenderFnParams, ProviderParams } from './type';
2
- export { Logger } from './logger';
3
2
  export { dispatchPopstateEnv } from './env';
package/dist/index.es.js CHANGED
@@ -1,39 +1,7 @@
1
- var a = Object.defineProperty;
2
- var c = (s, e, t) => e in s ? a(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
- var i = (s, e, t) => (c(s, typeof e != "symbol" ? e + "" : e, t), t);
4
- class g {
5
- constructor(e) {
6
- i(this, "name");
7
- i(this, "isDebugEnabled");
8
- i(this, "color");
9
- this.name = e, this.isDebugEnabled = !1, this.color = this.stringToColor(e), typeof window < "u" && typeof localStorage < "u" && (this.isDebugEnabled = localStorage.getItem("debug") === "true"), typeof process < "u" && process.env && (this.isDebugEnabled = process.env.DEBUG === "true");
10
- }
11
- log(...e) {
12
- var t, n;
13
- if (this.isDebugEnabled) {
14
- const o = `color: ${this.color}; font-weight: bold`, l = `%c[${this.name}]`, r = ((n = (t = new Error().stack) == null ? void 0 : t.split(`
15
- `)[2]) == null ? void 0 : n.trim()) || "Stack information not available";
16
- typeof console < "u" && console.debug && console.debug(l, o, ...e, `
17
- (${r})`);
18
- }
19
- }
20
- stringToColor(e) {
21
- let t = 0;
22
- for (let o = 0; o < e.length; o++)
23
- t = e.charCodeAt(o) + ((t << 5) - t);
24
- let n = "#";
25
- for (let o = 0; o < 3; o++) {
26
- const l = t >> o * 8 & 255;
27
- n += ("00" + l.toString(16)).substr(-2);
28
- }
29
- return n;
30
- }
31
- }
32
- function f() {
33
- const s = new PopStateEvent("popstate", { state: window.history.state });
34
- window.dispatchEvent(s);
1
+ function e() {
2
+ const t = new PopStateEvent("popstate", { state: window.history.state });
3
+ window.dispatchEvent(t);
35
4
  }
36
5
  export {
37
- g as Logger,
38
- f as dispatchPopstateEnv
6
+ e as dispatchPopstateEnv
39
7
  };
package/dist/index.umd.js CHANGED
@@ -1,3 +1 @@
1
- (function(e,t){typeof exports=="object"&&typeof module<"u"?t(exports):typeof define=="function"&&define.amd?define(["exports"],t):(e=typeof globalThis<"u"?globalThis:e||self,t(e["bridge-shared"]={}))})(this,function(e){"use strict";var f=Object.defineProperty;var u=(e,t,n)=>t in e?f(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var d=(e,t,n)=>(u(e,typeof t!="symbol"?t+"":t,n),n);class t{constructor(s){d(this,"name");d(this,"isDebugEnabled");d(this,"color");this.name=s,this.isDebugEnabled=!1,this.color=this.stringToColor(s),typeof window<"u"&&typeof localStorage<"u"&&(this.isDebugEnabled=localStorage.getItem("debug")==="true"),typeof process<"u"&&process.env&&(this.isDebugEnabled=process.env.DEBUG==="true")}log(...s){var i,l;if(this.isDebugEnabled){const o=`color: ${this.color}; font-weight: bold`,r=`%c[${this.name}]`,c=((l=(i=new Error().stack)==null?void 0:i.split(`
2
- `)[2])==null?void 0:l.trim())||"Stack information not available";typeof console<"u"&&console.debug&&console.debug(r,o,...s,`
3
- (${c})`)}}stringToColor(s){let i=0;for(let o=0;o<s.length;o++)i=s.charCodeAt(o)+((i<<5)-i);let l="#";for(let o=0;o<3;o++){const r=i>>o*8&255;l+=("00"+r.toString(16)).substr(-2)}return l}}function n(){const a=new PopStateEvent("popstate",{state:window.history.state});window.dispatchEvent(a)}e.Logger=t,e.dispatchPopstateEnv=n,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
1
+ (function(e,t){typeof exports=="object"&&typeof module<"u"?t(exports):typeof define=="function"&&define.amd?define(["exports"],t):(e=typeof globalThis<"u"?globalThis:e||self,t(e["bridge-shared"]={}))})(this,function(e){"use strict";function t(){const n=new PopStateEvent("popstate",{state:window.history.state});window.dispatchEvent(n)}e.dispatchPopstateEnv=t,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/bridge-shared",
3
- "version": "0.6.13",
3
+ "version": "0.6.14",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/index.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  export type { RenderFnParams, ProviderParams } from './type';
2
- export { Logger } from './logger';
3
2
  export { dispatchPopstateEnv } from './env';
package/dist/logger.d.ts DELETED
@@ -1,8 +0,0 @@
1
- export declare class Logger {
2
- private name;
3
- private isDebugEnabled;
4
- private color;
5
- constructor(name: string);
6
- log(...messages: any[]): void;
7
- private stringToColor;
8
- }
package/src/logger.ts DELETED
@@ -1,52 +0,0 @@
1
- export class Logger {
2
- private name: string;
3
- private isDebugEnabled: boolean;
4
- private color: string;
5
-
6
- constructor(name: string) {
7
- this.name = name;
8
- this.isDebugEnabled = false;
9
- this.color = this.stringToColor(name);
10
-
11
- // Check if debug is enabled in the browser environment
12
- if (typeof window !== 'undefined' && typeof localStorage !== 'undefined') {
13
- this.isDebugEnabled = localStorage.getItem('debug') === 'true';
14
- }
15
-
16
- // Check if debug is enabled in the Node.js environment
17
- if (typeof process !== 'undefined' && process.env) {
18
- this.isDebugEnabled = process.env.DEBUG === 'true';
19
- }
20
- }
21
-
22
- public log(...messages: any[]): void {
23
- if (this.isDebugEnabled) {
24
- const infoStyle = `color: ${this.color}; font-weight: bold`;
25
- const logMessage = `%c[${this.name}]`;
26
- const stack =
27
- new Error().stack?.split('\n')[2]?.trim() ||
28
- 'Stack information not available';
29
-
30
- if (typeof console !== 'undefined' && console.debug) {
31
- console.debug(logMessage, infoStyle, ...messages, `\n (${stack})`);
32
-
33
- // if (this.isDebugEnabledStack) {
34
- // console.log(`%c${stack}`, 'color: grey; font-style: italic;');
35
- // }
36
- }
37
- }
38
- }
39
-
40
- private stringToColor(str: string): string {
41
- let hash = 0;
42
- for (let i = 0; i < str.length; i++) {
43
- hash = str.charCodeAt(i) + ((hash << 5) - hash);
44
- }
45
- let color = '#';
46
- for (let i = 0; i < 3; i++) {
47
- const value = (hash >> (i * 8)) & 0xff;
48
- color += ('00' + value.toString(16)).substr(-2);
49
- }
50
- return color;
51
- }
52
- }