@module-federation/bridge-react 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 +15 -0
- package/dist/context-9t7opEwi.js +329 -0
- package/dist/context-BVnJi3LE.cjs +328 -0
- package/dist/index.cjs.js +13 -9
- package/dist/index.es.js +7 -3
- package/dist/router-v5.cjs.js +1 -1
- package/dist/router-v5.es.js +1 -1
- package/dist/router-v6.cjs.js +1 -1
- package/dist/router-v6.es.js +1 -1
- package/dist/router.cjs.js +1 -1
- package/dist/router.es.js +1 -1
- package/package.json +3 -2
- package/src/utils.ts +4 -2
- package/dist/context--mtFt3tp.cjs +0 -73
- package/dist/context-Bw2PEwa6.js +0 -74
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @module-federation/bridge-react
|
|
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
|
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import React__default from "react";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var browser_exports = {};
|
|
20
|
+
__export(browser_exports, {
|
|
21
|
+
createLogger: () => createLogger2,
|
|
22
|
+
logger: () => logger
|
|
23
|
+
});
|
|
24
|
+
var browser = __toCommonJS(browser_exports);
|
|
25
|
+
var supportsSubstitutions = void 0;
|
|
26
|
+
var supportColor = () => {
|
|
27
|
+
if (typeof supportsSubstitutions !== "undefined") {
|
|
28
|
+
return supportsSubstitutions;
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
console.log("%c", "color:");
|
|
32
|
+
supportsSubstitutions = true;
|
|
33
|
+
} catch (e) {
|
|
34
|
+
supportsSubstitutions = false;
|
|
35
|
+
}
|
|
36
|
+
return supportsSubstitutions;
|
|
37
|
+
};
|
|
38
|
+
var ansiToCss = {
|
|
39
|
+
"bold": "font-weight: bold;",
|
|
40
|
+
"red": "color: red;",
|
|
41
|
+
"green": "color: green;",
|
|
42
|
+
"yellow": "color: yellow;",
|
|
43
|
+
"magenta": "color: magenta;",
|
|
44
|
+
"cyan": "color: cyan;",
|
|
45
|
+
"gray": "color: gray;"
|
|
46
|
+
};
|
|
47
|
+
var formatter = (key) => supportColor() ? (input) => {
|
|
48
|
+
if (Array.isArray(input)) {
|
|
49
|
+
const [label, style] = input;
|
|
50
|
+
return [`%c${label.replace("%c", "")}`, style ? `${ansiToCss[key]}${style}` : `${ansiToCss[key] || ""}`];
|
|
51
|
+
}
|
|
52
|
+
return [`%c${String(input).replace("%c", "")}`, ansiToCss[key] || ""];
|
|
53
|
+
} : (input) => [String(input)];
|
|
54
|
+
var bold = formatter("bold");
|
|
55
|
+
var red = formatter("red");
|
|
56
|
+
var green = formatter("green");
|
|
57
|
+
var yellow = formatter("yellow");
|
|
58
|
+
var magenta = formatter("magenta");
|
|
59
|
+
var cyan = formatter("cyan");
|
|
60
|
+
formatter("gray");
|
|
61
|
+
function getLabel(type, logType, labels) {
|
|
62
|
+
let label = [""];
|
|
63
|
+
if ("label" in logType) {
|
|
64
|
+
label = [labels[type] || logType.label || ""];
|
|
65
|
+
label = bold(logType.color ? logType.color(label) : label[0]);
|
|
66
|
+
}
|
|
67
|
+
label = label.filter(Boolean);
|
|
68
|
+
return label;
|
|
69
|
+
}
|
|
70
|
+
function finalLog(label, text, args, message) {
|
|
71
|
+
if (label.length) {
|
|
72
|
+
if (Array.isArray(message)) {
|
|
73
|
+
console.log(...label, ...message);
|
|
74
|
+
} else {
|
|
75
|
+
console.log(...label, text);
|
|
76
|
+
}
|
|
77
|
+
} else {
|
|
78
|
+
Array.isArray(message) ? console.log(...message) : console.log(text, ...args);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
var LOG_LEVEL = {
|
|
82
|
+
error: 0,
|
|
83
|
+
warn: 1,
|
|
84
|
+
info: 2,
|
|
85
|
+
log: 3,
|
|
86
|
+
verbose: 4
|
|
87
|
+
};
|
|
88
|
+
var errorStackRegExp = /at\s.*:\d+:\d+[\s\)]*$/;
|
|
89
|
+
var anonymousErrorStackRegExp = /at\s.*\(<anonymous>\)$/;
|
|
90
|
+
var isErrorStackMessage = (message) => errorStackRegExp.test(message) || anonymousErrorStackRegExp.test(message);
|
|
91
|
+
var createLogger$1 = (options = {}, { getLabel: getLabel2, handleError, finalLog: finalLog2, greet, LOG_TYPES: LOG_TYPES2 }) => {
|
|
92
|
+
let maxLevel = options.level || "log";
|
|
93
|
+
let customLabels = options.labels || {};
|
|
94
|
+
let log = (type, message, ...args) => {
|
|
95
|
+
if (LOG_LEVEL[LOG_TYPES2[type].level] > LOG_LEVEL[maxLevel]) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (message === void 0 || message === null) {
|
|
99
|
+
return console.log();
|
|
100
|
+
}
|
|
101
|
+
let logType = LOG_TYPES2[type];
|
|
102
|
+
let text = "";
|
|
103
|
+
const label = getLabel2(type, logType, customLabels);
|
|
104
|
+
if (message instanceof Error) {
|
|
105
|
+
if (message.stack) {
|
|
106
|
+
let [name, ...rest] = message.stack.split("\n");
|
|
107
|
+
if (name.startsWith("Error: ")) {
|
|
108
|
+
name = name.slice(7);
|
|
109
|
+
}
|
|
110
|
+
text = `${name}
|
|
111
|
+
${handleError(rest.join("\n"))}`;
|
|
112
|
+
} else {
|
|
113
|
+
text = message.message;
|
|
114
|
+
}
|
|
115
|
+
} else if (logType.level === "error" && typeof message === "string") {
|
|
116
|
+
let lines = message.split("\n");
|
|
117
|
+
text = lines.map((line) => isErrorStackMessage(line) ? handleError(line) : line).join("\n");
|
|
118
|
+
} else {
|
|
119
|
+
text = `${message}`;
|
|
120
|
+
}
|
|
121
|
+
finalLog2(label, text, args, message);
|
|
122
|
+
};
|
|
123
|
+
let logger2 = {
|
|
124
|
+
// greet
|
|
125
|
+
greet: (message) => log("log", greet(message))
|
|
126
|
+
};
|
|
127
|
+
Object.keys(LOG_TYPES2).forEach((key) => {
|
|
128
|
+
logger2[key] = (...args) => log(key, ...args);
|
|
129
|
+
});
|
|
130
|
+
Object.defineProperty(logger2, "level", {
|
|
131
|
+
get: () => maxLevel,
|
|
132
|
+
set(val) {
|
|
133
|
+
maxLevel = val;
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
Object.defineProperty(logger2, "labels", {
|
|
137
|
+
get: () => customLabels,
|
|
138
|
+
set(val) {
|
|
139
|
+
customLabels = val;
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
logger2.override = (customLogger) => {
|
|
143
|
+
Object.assign(logger2, customLogger);
|
|
144
|
+
};
|
|
145
|
+
return logger2;
|
|
146
|
+
};
|
|
147
|
+
var startColor = [189, 255, 243];
|
|
148
|
+
var endColor = [74, 194, 154];
|
|
149
|
+
var isWord = (char) => !/[\s\n]/.test(char);
|
|
150
|
+
function gradient(message) {
|
|
151
|
+
if (!supportColor()) {
|
|
152
|
+
return [message];
|
|
153
|
+
}
|
|
154
|
+
const chars = [...message];
|
|
155
|
+
const words = chars.filter(isWord);
|
|
156
|
+
const steps = words.length - 1;
|
|
157
|
+
if (steps === 0) {
|
|
158
|
+
console.log(`%c${message}`, `color: rgb(${startColor.join(",")}); font-weight: bold;`);
|
|
159
|
+
return [message];
|
|
160
|
+
}
|
|
161
|
+
let output = "";
|
|
162
|
+
let styles = [];
|
|
163
|
+
chars.forEach((char) => {
|
|
164
|
+
if (isWord(char)) {
|
|
165
|
+
const progress = words.indexOf(char) / steps;
|
|
166
|
+
const r = Math.round(startColor[0] + (endColor[0] - startColor[0]) * progress);
|
|
167
|
+
const g = Math.round(startColor[1] + (endColor[1] - startColor[1]) * progress);
|
|
168
|
+
const b = Math.round(startColor[2] + (endColor[2] - startColor[2]) * progress);
|
|
169
|
+
output += `%c${char}`;
|
|
170
|
+
styles.push(`color: rgb(${r},${g},${b}); font-weight: bold;`);
|
|
171
|
+
} else {
|
|
172
|
+
output += char;
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
return [output, ...styles];
|
|
176
|
+
}
|
|
177
|
+
var LOG_TYPES = {
|
|
178
|
+
// Level error
|
|
179
|
+
error: {
|
|
180
|
+
label: "error",
|
|
181
|
+
level: "error",
|
|
182
|
+
color: red
|
|
183
|
+
},
|
|
184
|
+
// Level warn
|
|
185
|
+
warn: {
|
|
186
|
+
label: "warn",
|
|
187
|
+
level: "warn",
|
|
188
|
+
color: yellow
|
|
189
|
+
},
|
|
190
|
+
// Level info
|
|
191
|
+
info: {
|
|
192
|
+
label: "info",
|
|
193
|
+
level: "info",
|
|
194
|
+
color: cyan
|
|
195
|
+
},
|
|
196
|
+
start: {
|
|
197
|
+
label: "start",
|
|
198
|
+
level: "info",
|
|
199
|
+
color: cyan
|
|
200
|
+
},
|
|
201
|
+
ready: {
|
|
202
|
+
label: "ready",
|
|
203
|
+
level: "info",
|
|
204
|
+
color: green
|
|
205
|
+
},
|
|
206
|
+
success: {
|
|
207
|
+
label: "success",
|
|
208
|
+
level: "info",
|
|
209
|
+
color: green
|
|
210
|
+
},
|
|
211
|
+
// Level log
|
|
212
|
+
log: {
|
|
213
|
+
level: "log"
|
|
214
|
+
},
|
|
215
|
+
// Level debug
|
|
216
|
+
debug: {
|
|
217
|
+
label: "debug",
|
|
218
|
+
level: "verbose",
|
|
219
|
+
color: magenta
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
function createLogger2(options = {}) {
|
|
223
|
+
return createLogger$1(options, {
|
|
224
|
+
handleError: (msg) => msg,
|
|
225
|
+
getLabel,
|
|
226
|
+
gradient,
|
|
227
|
+
finalLog,
|
|
228
|
+
LOG_TYPES,
|
|
229
|
+
greet: (msg) => {
|
|
230
|
+
return gradient(msg);
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
var logger = createLogger2();
|
|
235
|
+
const BROWSER_LOG_KEY = "FEDERATION_DEBUG";
|
|
236
|
+
const BROWSER_LOG_VALUE = "1";
|
|
237
|
+
function isBrowserEnv() {
|
|
238
|
+
return typeof window !== "undefined";
|
|
239
|
+
}
|
|
240
|
+
function isBrowserDebug() {
|
|
241
|
+
try {
|
|
242
|
+
if (isBrowserEnv() && window.localStorage) {
|
|
243
|
+
return localStorage.getItem(BROWSER_LOG_KEY) === BROWSER_LOG_VALUE;
|
|
244
|
+
}
|
|
245
|
+
} catch (error) {
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
return false;
|
|
249
|
+
}
|
|
250
|
+
function isDebugMode() {
|
|
251
|
+
if (typeof process !== "undefined" && process.env && process.env["FEDERATION_DEBUG"]) {
|
|
252
|
+
return Boolean(process.env["FEDERATION_DEBUG"]);
|
|
253
|
+
}
|
|
254
|
+
if (typeof FEDERATION_DEBUG !== "undefined" && Boolean(FEDERATION_DEBUG)) {
|
|
255
|
+
return true;
|
|
256
|
+
}
|
|
257
|
+
return isBrowserDebug();
|
|
258
|
+
}
|
|
259
|
+
const PREFIX = "[ Module Federation ]";
|
|
260
|
+
function setDebug(loggerInstance) {
|
|
261
|
+
if (isDebugMode()) {
|
|
262
|
+
loggerInstance.level = "verbose";
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
function setPrefix(loggerInstance, prefix) {
|
|
266
|
+
loggerInstance.labels = {
|
|
267
|
+
warn: `${prefix} Warn`,
|
|
268
|
+
error: `${prefix} Error`,
|
|
269
|
+
success: `${prefix} Success`,
|
|
270
|
+
info: `${prefix} Info`,
|
|
271
|
+
ready: `${prefix} Ready`,
|
|
272
|
+
debug: `${prefix} Debug`
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
function createLogger(prefix) {
|
|
276
|
+
const loggerInstance = browser.createLogger({
|
|
277
|
+
labels: {
|
|
278
|
+
warn: `${PREFIX} Warn`,
|
|
279
|
+
error: `${PREFIX} Error`,
|
|
280
|
+
success: `${PREFIX} Success`,
|
|
281
|
+
info: `${PREFIX} Info`,
|
|
282
|
+
ready: `${PREFIX} Ready`,
|
|
283
|
+
debug: `${PREFIX} Debug`
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
setDebug(loggerInstance);
|
|
287
|
+
setPrefix(loggerInstance, prefix);
|
|
288
|
+
return loggerInstance;
|
|
289
|
+
}
|
|
290
|
+
createLogger(PREFIX);
|
|
291
|
+
const LoggerInstance = createLogger(
|
|
292
|
+
"[ Module Federation Bridge React ]"
|
|
293
|
+
);
|
|
294
|
+
function atLeastReact18(React2) {
|
|
295
|
+
if (React2 && typeof React2.version === "string" && React2.version.indexOf(".") >= 0) {
|
|
296
|
+
const majorVersionString = React2.version.split(".")[0];
|
|
297
|
+
try {
|
|
298
|
+
return Number(majorVersionString) >= 18;
|
|
299
|
+
} catch (err) {
|
|
300
|
+
return false;
|
|
301
|
+
}
|
|
302
|
+
} else {
|
|
303
|
+
return false;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
function pathJoin(...args) {
|
|
307
|
+
const res = args.reduce((res2, path) => {
|
|
308
|
+
let nPath = path;
|
|
309
|
+
if (!nPath || typeof nPath !== "string") {
|
|
310
|
+
return res2;
|
|
311
|
+
}
|
|
312
|
+
if (nPath[0] !== "/") {
|
|
313
|
+
nPath = `/${nPath}`;
|
|
314
|
+
}
|
|
315
|
+
const lastIndex = nPath.length - 1;
|
|
316
|
+
if (nPath[lastIndex] === "/") {
|
|
317
|
+
nPath = nPath.substring(0, lastIndex);
|
|
318
|
+
}
|
|
319
|
+
return res2 + nPath;
|
|
320
|
+
}, "");
|
|
321
|
+
return res || "/";
|
|
322
|
+
}
|
|
323
|
+
const RouterContext = React__default.createContext(null);
|
|
324
|
+
export {
|
|
325
|
+
LoggerInstance as L,
|
|
326
|
+
RouterContext as R,
|
|
327
|
+
atLeastReact18 as a,
|
|
328
|
+
pathJoin as p
|
|
329
|
+
};
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const React = require("react");
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var browser_exports = {};
|
|
21
|
+
__export(browser_exports, {
|
|
22
|
+
createLogger: () => createLogger2,
|
|
23
|
+
logger: () => logger
|
|
24
|
+
});
|
|
25
|
+
var browser = __toCommonJS(browser_exports);
|
|
26
|
+
var supportsSubstitutions = void 0;
|
|
27
|
+
var supportColor = () => {
|
|
28
|
+
if (typeof supportsSubstitutions !== "undefined") {
|
|
29
|
+
return supportsSubstitutions;
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
console.log("%c", "color:");
|
|
33
|
+
supportsSubstitutions = true;
|
|
34
|
+
} catch (e) {
|
|
35
|
+
supportsSubstitutions = false;
|
|
36
|
+
}
|
|
37
|
+
return supportsSubstitutions;
|
|
38
|
+
};
|
|
39
|
+
var ansiToCss = {
|
|
40
|
+
"bold": "font-weight: bold;",
|
|
41
|
+
"red": "color: red;",
|
|
42
|
+
"green": "color: green;",
|
|
43
|
+
"yellow": "color: yellow;",
|
|
44
|
+
"magenta": "color: magenta;",
|
|
45
|
+
"cyan": "color: cyan;",
|
|
46
|
+
"gray": "color: gray;"
|
|
47
|
+
};
|
|
48
|
+
var formatter = (key) => supportColor() ? (input) => {
|
|
49
|
+
if (Array.isArray(input)) {
|
|
50
|
+
const [label, style] = input;
|
|
51
|
+
return [`%c${label.replace("%c", "")}`, style ? `${ansiToCss[key]}${style}` : `${ansiToCss[key] || ""}`];
|
|
52
|
+
}
|
|
53
|
+
return [`%c${String(input).replace("%c", "")}`, ansiToCss[key] || ""];
|
|
54
|
+
} : (input) => [String(input)];
|
|
55
|
+
var bold = formatter("bold");
|
|
56
|
+
var red = formatter("red");
|
|
57
|
+
var green = formatter("green");
|
|
58
|
+
var yellow = formatter("yellow");
|
|
59
|
+
var magenta = formatter("magenta");
|
|
60
|
+
var cyan = formatter("cyan");
|
|
61
|
+
formatter("gray");
|
|
62
|
+
function getLabel(type, logType, labels) {
|
|
63
|
+
let label = [""];
|
|
64
|
+
if ("label" in logType) {
|
|
65
|
+
label = [labels[type] || logType.label || ""];
|
|
66
|
+
label = bold(logType.color ? logType.color(label) : label[0]);
|
|
67
|
+
}
|
|
68
|
+
label = label.filter(Boolean);
|
|
69
|
+
return label;
|
|
70
|
+
}
|
|
71
|
+
function finalLog(label, text, args, message) {
|
|
72
|
+
if (label.length) {
|
|
73
|
+
if (Array.isArray(message)) {
|
|
74
|
+
console.log(...label, ...message);
|
|
75
|
+
} else {
|
|
76
|
+
console.log(...label, text);
|
|
77
|
+
}
|
|
78
|
+
} else {
|
|
79
|
+
Array.isArray(message) ? console.log(...message) : console.log(text, ...args);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
var LOG_LEVEL = {
|
|
83
|
+
error: 0,
|
|
84
|
+
warn: 1,
|
|
85
|
+
info: 2,
|
|
86
|
+
log: 3,
|
|
87
|
+
verbose: 4
|
|
88
|
+
};
|
|
89
|
+
var errorStackRegExp = /at\s.*:\d+:\d+[\s\)]*$/;
|
|
90
|
+
var anonymousErrorStackRegExp = /at\s.*\(<anonymous>\)$/;
|
|
91
|
+
var isErrorStackMessage = (message) => errorStackRegExp.test(message) || anonymousErrorStackRegExp.test(message);
|
|
92
|
+
var createLogger$1 = (options = {}, { getLabel: getLabel2, handleError, finalLog: finalLog2, greet, LOG_TYPES: LOG_TYPES2 }) => {
|
|
93
|
+
let maxLevel = options.level || "log";
|
|
94
|
+
let customLabels = options.labels || {};
|
|
95
|
+
let log = (type, message, ...args) => {
|
|
96
|
+
if (LOG_LEVEL[LOG_TYPES2[type].level] > LOG_LEVEL[maxLevel]) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (message === void 0 || message === null) {
|
|
100
|
+
return console.log();
|
|
101
|
+
}
|
|
102
|
+
let logType = LOG_TYPES2[type];
|
|
103
|
+
let text = "";
|
|
104
|
+
const label = getLabel2(type, logType, customLabels);
|
|
105
|
+
if (message instanceof Error) {
|
|
106
|
+
if (message.stack) {
|
|
107
|
+
let [name, ...rest] = message.stack.split("\n");
|
|
108
|
+
if (name.startsWith("Error: ")) {
|
|
109
|
+
name = name.slice(7);
|
|
110
|
+
}
|
|
111
|
+
text = `${name}
|
|
112
|
+
${handleError(rest.join("\n"))}`;
|
|
113
|
+
} else {
|
|
114
|
+
text = message.message;
|
|
115
|
+
}
|
|
116
|
+
} else if (logType.level === "error" && typeof message === "string") {
|
|
117
|
+
let lines = message.split("\n");
|
|
118
|
+
text = lines.map((line) => isErrorStackMessage(line) ? handleError(line) : line).join("\n");
|
|
119
|
+
} else {
|
|
120
|
+
text = `${message}`;
|
|
121
|
+
}
|
|
122
|
+
finalLog2(label, text, args, message);
|
|
123
|
+
};
|
|
124
|
+
let logger2 = {
|
|
125
|
+
// greet
|
|
126
|
+
greet: (message) => log("log", greet(message))
|
|
127
|
+
};
|
|
128
|
+
Object.keys(LOG_TYPES2).forEach((key) => {
|
|
129
|
+
logger2[key] = (...args) => log(key, ...args);
|
|
130
|
+
});
|
|
131
|
+
Object.defineProperty(logger2, "level", {
|
|
132
|
+
get: () => maxLevel,
|
|
133
|
+
set(val) {
|
|
134
|
+
maxLevel = val;
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
Object.defineProperty(logger2, "labels", {
|
|
138
|
+
get: () => customLabels,
|
|
139
|
+
set(val) {
|
|
140
|
+
customLabels = val;
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
logger2.override = (customLogger) => {
|
|
144
|
+
Object.assign(logger2, customLogger);
|
|
145
|
+
};
|
|
146
|
+
return logger2;
|
|
147
|
+
};
|
|
148
|
+
var startColor = [189, 255, 243];
|
|
149
|
+
var endColor = [74, 194, 154];
|
|
150
|
+
var isWord = (char) => !/[\s\n]/.test(char);
|
|
151
|
+
function gradient(message) {
|
|
152
|
+
if (!supportColor()) {
|
|
153
|
+
return [message];
|
|
154
|
+
}
|
|
155
|
+
const chars = [...message];
|
|
156
|
+
const words = chars.filter(isWord);
|
|
157
|
+
const steps = words.length - 1;
|
|
158
|
+
if (steps === 0) {
|
|
159
|
+
console.log(`%c${message}`, `color: rgb(${startColor.join(",")}); font-weight: bold;`);
|
|
160
|
+
return [message];
|
|
161
|
+
}
|
|
162
|
+
let output = "";
|
|
163
|
+
let styles = [];
|
|
164
|
+
chars.forEach((char) => {
|
|
165
|
+
if (isWord(char)) {
|
|
166
|
+
const progress = words.indexOf(char) / steps;
|
|
167
|
+
const r = Math.round(startColor[0] + (endColor[0] - startColor[0]) * progress);
|
|
168
|
+
const g = Math.round(startColor[1] + (endColor[1] - startColor[1]) * progress);
|
|
169
|
+
const b = Math.round(startColor[2] + (endColor[2] - startColor[2]) * progress);
|
|
170
|
+
output += `%c${char}`;
|
|
171
|
+
styles.push(`color: rgb(${r},${g},${b}); font-weight: bold;`);
|
|
172
|
+
} else {
|
|
173
|
+
output += char;
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
return [output, ...styles];
|
|
177
|
+
}
|
|
178
|
+
var LOG_TYPES = {
|
|
179
|
+
// Level error
|
|
180
|
+
error: {
|
|
181
|
+
label: "error",
|
|
182
|
+
level: "error",
|
|
183
|
+
color: red
|
|
184
|
+
},
|
|
185
|
+
// Level warn
|
|
186
|
+
warn: {
|
|
187
|
+
label: "warn",
|
|
188
|
+
level: "warn",
|
|
189
|
+
color: yellow
|
|
190
|
+
},
|
|
191
|
+
// Level info
|
|
192
|
+
info: {
|
|
193
|
+
label: "info",
|
|
194
|
+
level: "info",
|
|
195
|
+
color: cyan
|
|
196
|
+
},
|
|
197
|
+
start: {
|
|
198
|
+
label: "start",
|
|
199
|
+
level: "info",
|
|
200
|
+
color: cyan
|
|
201
|
+
},
|
|
202
|
+
ready: {
|
|
203
|
+
label: "ready",
|
|
204
|
+
level: "info",
|
|
205
|
+
color: green
|
|
206
|
+
},
|
|
207
|
+
success: {
|
|
208
|
+
label: "success",
|
|
209
|
+
level: "info",
|
|
210
|
+
color: green
|
|
211
|
+
},
|
|
212
|
+
// Level log
|
|
213
|
+
log: {
|
|
214
|
+
level: "log"
|
|
215
|
+
},
|
|
216
|
+
// Level debug
|
|
217
|
+
debug: {
|
|
218
|
+
label: "debug",
|
|
219
|
+
level: "verbose",
|
|
220
|
+
color: magenta
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
function createLogger2(options = {}) {
|
|
224
|
+
return createLogger$1(options, {
|
|
225
|
+
handleError: (msg) => msg,
|
|
226
|
+
getLabel,
|
|
227
|
+
gradient,
|
|
228
|
+
finalLog,
|
|
229
|
+
LOG_TYPES,
|
|
230
|
+
greet: (msg) => {
|
|
231
|
+
return gradient(msg);
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
var logger = createLogger2();
|
|
236
|
+
const BROWSER_LOG_KEY = "FEDERATION_DEBUG";
|
|
237
|
+
const BROWSER_LOG_VALUE = "1";
|
|
238
|
+
function isBrowserEnv() {
|
|
239
|
+
return typeof window !== "undefined";
|
|
240
|
+
}
|
|
241
|
+
function isBrowserDebug() {
|
|
242
|
+
try {
|
|
243
|
+
if (isBrowserEnv() && window.localStorage) {
|
|
244
|
+
return localStorage.getItem(BROWSER_LOG_KEY) === BROWSER_LOG_VALUE;
|
|
245
|
+
}
|
|
246
|
+
} catch (error) {
|
|
247
|
+
return false;
|
|
248
|
+
}
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
function isDebugMode() {
|
|
252
|
+
if (typeof process !== "undefined" && process.env && process.env["FEDERATION_DEBUG"]) {
|
|
253
|
+
return Boolean(process.env["FEDERATION_DEBUG"]);
|
|
254
|
+
}
|
|
255
|
+
if (typeof FEDERATION_DEBUG !== "undefined" && Boolean(FEDERATION_DEBUG)) {
|
|
256
|
+
return true;
|
|
257
|
+
}
|
|
258
|
+
return isBrowserDebug();
|
|
259
|
+
}
|
|
260
|
+
const PREFIX = "[ Module Federation ]";
|
|
261
|
+
function setDebug(loggerInstance) {
|
|
262
|
+
if (isDebugMode()) {
|
|
263
|
+
loggerInstance.level = "verbose";
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
function setPrefix(loggerInstance, prefix) {
|
|
267
|
+
loggerInstance.labels = {
|
|
268
|
+
warn: `${prefix} Warn`,
|
|
269
|
+
error: `${prefix} Error`,
|
|
270
|
+
success: `${prefix} Success`,
|
|
271
|
+
info: `${prefix} Info`,
|
|
272
|
+
ready: `${prefix} Ready`,
|
|
273
|
+
debug: `${prefix} Debug`
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
function createLogger(prefix) {
|
|
277
|
+
const loggerInstance = browser.createLogger({
|
|
278
|
+
labels: {
|
|
279
|
+
warn: `${PREFIX} Warn`,
|
|
280
|
+
error: `${PREFIX} Error`,
|
|
281
|
+
success: `${PREFIX} Success`,
|
|
282
|
+
info: `${PREFIX} Info`,
|
|
283
|
+
ready: `${PREFIX} Ready`,
|
|
284
|
+
debug: `${PREFIX} Debug`
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
setDebug(loggerInstance);
|
|
288
|
+
setPrefix(loggerInstance, prefix);
|
|
289
|
+
return loggerInstance;
|
|
290
|
+
}
|
|
291
|
+
createLogger(PREFIX);
|
|
292
|
+
const LoggerInstance = createLogger(
|
|
293
|
+
"[ Module Federation Bridge React ]"
|
|
294
|
+
);
|
|
295
|
+
function atLeastReact18(React2) {
|
|
296
|
+
if (React2 && typeof React2.version === "string" && React2.version.indexOf(".") >= 0) {
|
|
297
|
+
const majorVersionString = React2.version.split(".")[0];
|
|
298
|
+
try {
|
|
299
|
+
return Number(majorVersionString) >= 18;
|
|
300
|
+
} catch (err) {
|
|
301
|
+
return false;
|
|
302
|
+
}
|
|
303
|
+
} else {
|
|
304
|
+
return false;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
function pathJoin(...args) {
|
|
308
|
+
const res = args.reduce((res2, path) => {
|
|
309
|
+
let nPath = path;
|
|
310
|
+
if (!nPath || typeof nPath !== "string") {
|
|
311
|
+
return res2;
|
|
312
|
+
}
|
|
313
|
+
if (nPath[0] !== "/") {
|
|
314
|
+
nPath = `/${nPath}`;
|
|
315
|
+
}
|
|
316
|
+
const lastIndex = nPath.length - 1;
|
|
317
|
+
if (nPath[lastIndex] === "/") {
|
|
318
|
+
nPath = nPath.substring(0, lastIndex);
|
|
319
|
+
}
|
|
320
|
+
return res2 + nPath;
|
|
321
|
+
}, "");
|
|
322
|
+
return res || "/";
|
|
323
|
+
}
|
|
324
|
+
const RouterContext = React.createContext(null);
|
|
325
|
+
exports.LoggerInstance = LoggerInstance;
|
|
326
|
+
exports.RouterContext = RouterContext;
|
|
327
|
+
exports.atLeastReact18 = atLeastReact18;
|
|
328
|
+
exports.pathJoin = pathJoin;
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const React = require("react");
|
|
4
|
-
const context = require("./context
|
|
4
|
+
const context = require("./context-BVnJi3LE.cjs");
|
|
5
5
|
const ReactRouterDOM = require("react-router-dom");
|
|
6
6
|
const ReactDOM = require("react-dom");
|
|
7
|
-
function _interopNamespaceDefault(
|
|
7
|
+
function _interopNamespaceDefault(e2) {
|
|
8
8
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
9
|
-
if (
|
|
10
|
-
for (const k in
|
|
9
|
+
if (e2) {
|
|
10
|
+
for (const k in e2) {
|
|
11
11
|
if (k !== "default") {
|
|
12
|
-
const d = Object.getOwnPropertyDescriptor(
|
|
12
|
+
const d = Object.getOwnPropertyDescriptor(e2, k);
|
|
13
13
|
Object.defineProperty(n, k, d.get ? d : {
|
|
14
14
|
enumerable: true,
|
|
15
|
-
get: () =>
|
|
15
|
+
get: () => e2[k]
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
n.default =
|
|
20
|
+
n.default = e2;
|
|
21
21
|
return Object.freeze(n);
|
|
22
22
|
}
|
|
23
23
|
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
@@ -117,6 +117,10 @@ function hasArrayChanged() {
|
|
|
117
117
|
let b = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
|
|
118
118
|
return a.length !== b.length || a.some((item, index) => !Object.is(item, b[index]));
|
|
119
119
|
}
|
|
120
|
+
function e() {
|
|
121
|
+
const t = new PopStateEvent("popstate", { state: window.history.state });
|
|
122
|
+
window.dispatchEvent(t);
|
|
123
|
+
}
|
|
120
124
|
const RemoteAppWrapper = React.forwardRef(function(props, ref) {
|
|
121
125
|
const RemoteApp2 = () => {
|
|
122
126
|
context.LoggerInstance.log(`RemoteAppWrapper RemoteApp props >>>`, { props });
|
|
@@ -177,7 +181,7 @@ const RemoteAppWrapper = React.forwardRef(function(props, ref) {
|
|
|
177
181
|
}
|
|
178
182
|
);
|
|
179
183
|
};
|
|
180
|
-
RemoteApp2["__APP_VERSION__"] = "0.6.
|
|
184
|
+
RemoteApp2["__APP_VERSION__"] = "0.6.14";
|
|
181
185
|
return /* @__PURE__ */ React.createElement(RemoteApp2, null);
|
|
182
186
|
});
|
|
183
187
|
function withRouterData(WrappedComponent) {
|
|
@@ -234,7 +238,7 @@ function withRouterData(WrappedComponent) {
|
|
|
234
238
|
name: props.name,
|
|
235
239
|
pathname: location.pathname
|
|
236
240
|
});
|
|
237
|
-
|
|
241
|
+
e();
|
|
238
242
|
}
|
|
239
243
|
setPathname(location.pathname);
|
|
240
244
|
}, [location]);
|
package/dist/index.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import React__default, { createContext, Component, createElement, isValidElement, forwardRef, useRef, useEffect, useContext, useState } from "react";
|
|
3
|
-
import { L as LoggerInstance, p as pathJoin,
|
|
3
|
+
import { L as LoggerInstance, p as pathJoin, a as atLeastReact18, R as RouterContext } from "./context-9t7opEwi.js";
|
|
4
4
|
import * as ReactRouterDOM from "react-router-dom";
|
|
5
5
|
import ReactDOM from "react-dom";
|
|
6
6
|
const ErrorBoundaryContext = createContext(null);
|
|
@@ -98,6 +98,10 @@ function hasArrayChanged() {
|
|
|
98
98
|
let b = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
|
|
99
99
|
return a.length !== b.length || a.some((item, index) => !Object.is(item, b[index]));
|
|
100
100
|
}
|
|
101
|
+
function e() {
|
|
102
|
+
const t = new PopStateEvent("popstate", { state: window.history.state });
|
|
103
|
+
window.dispatchEvent(t);
|
|
104
|
+
}
|
|
101
105
|
const RemoteAppWrapper = forwardRef(function(props, ref) {
|
|
102
106
|
const RemoteApp2 = () => {
|
|
103
107
|
LoggerInstance.log(`RemoteAppWrapper RemoteApp props >>>`, { props });
|
|
@@ -158,7 +162,7 @@ const RemoteAppWrapper = forwardRef(function(props, ref) {
|
|
|
158
162
|
}
|
|
159
163
|
);
|
|
160
164
|
};
|
|
161
|
-
RemoteApp2["__APP_VERSION__"] = "0.6.
|
|
165
|
+
RemoteApp2["__APP_VERSION__"] = "0.6.14";
|
|
162
166
|
return /* @__PURE__ */ React__default.createElement(RemoteApp2, null);
|
|
163
167
|
});
|
|
164
168
|
function withRouterData(WrappedComponent) {
|
|
@@ -215,7 +219,7 @@ function withRouterData(WrappedComponent) {
|
|
|
215
219
|
name: props.name,
|
|
216
220
|
pathname: location.pathname
|
|
217
221
|
});
|
|
218
|
-
|
|
222
|
+
e();
|
|
219
223
|
}
|
|
220
224
|
setPathname(location.pathname);
|
|
221
225
|
}, [location]);
|
package/dist/router-v5.cjs.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const React = require("react");
|
|
4
4
|
const ReactRouterDom$1 = require("react-router-dom/index.js");
|
|
5
|
-
const context = require("./context
|
|
5
|
+
const context = require("./context-BVnJi3LE.cjs");
|
|
6
6
|
const ReactRouterDom = require("react-router-dom/index.js");
|
|
7
7
|
function _interopNamespaceDefault(e) {
|
|
8
8
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
package/dist/router-v5.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React__default, { useContext } from "react";
|
|
2
2
|
import * as ReactRouterDom$1 from "react-router-dom/index.js";
|
|
3
|
-
import { R as RouterContext, L as LoggerInstance } from "./context-
|
|
3
|
+
import { R as RouterContext, L as LoggerInstance } from "./context-9t7opEwi.js";
|
|
4
4
|
export * from "react-router-dom/index.js";
|
|
5
5
|
function WraperRouter(props) {
|
|
6
6
|
const { basename, ...propsRes } = props;
|
package/dist/router-v6.cjs.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const React = require("react");
|
|
4
4
|
const ReactRouterDom = require("react-router-dom/dist/index.js");
|
|
5
|
-
const context = require("./context
|
|
5
|
+
const context = require("./context-BVnJi3LE.cjs");
|
|
6
6
|
function _interopNamespaceDefault(e) {
|
|
7
7
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
8
8
|
if (e) {
|
package/dist/router-v6.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React__default, { useContext } from "react";
|
|
2
2
|
import * as ReactRouterDom from "react-router-dom/dist/index.js";
|
|
3
3
|
export * from "react-router-dom/dist/index.js";
|
|
4
|
-
import { R as RouterContext, L as LoggerInstance } from "./context-
|
|
4
|
+
import { R as RouterContext, L as LoggerInstance } from "./context-9t7opEwi.js";
|
|
5
5
|
function WraperRouter(props) {
|
|
6
6
|
const { basename, ...propsRes } = props;
|
|
7
7
|
const routerContextProps = useContext(RouterContext) || {};
|
package/dist/router.cjs.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const React = require("react");
|
|
4
4
|
const ReactRouterDom = require("react-router-dom/");
|
|
5
|
-
const context = require("./context
|
|
5
|
+
const context = require("./context-BVnJi3LE.cjs");
|
|
6
6
|
function _interopNamespaceDefault(e) {
|
|
7
7
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
8
8
|
if (e) {
|
package/dist/router.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React__default, { useContext } from "react";
|
|
2
2
|
import * as ReactRouterDom from "react-router-dom/";
|
|
3
3
|
export * from "react-router-dom/";
|
|
4
|
-
import { R as RouterContext, L as LoggerInstance } from "./context-
|
|
4
|
+
import { R as RouterContext, L as LoggerInstance } from "./context-9t7opEwi.js";
|
|
5
5
|
function WrapperRouter(props) {
|
|
6
6
|
const { basename, ...propsRes } = props;
|
|
7
7
|
const routerContextProps = useContext(RouterContext) || {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/bridge-react",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.14",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -35,7 +35,8 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@loadable/component": "^5.16.4",
|
|
37
37
|
"react-error-boundary": "^4.0.13",
|
|
38
|
-
"@module-federation/bridge-shared": "0.6.
|
|
38
|
+
"@module-federation/bridge-shared": "0.6.14",
|
|
39
|
+
"@module-federation/sdk": "0.6.14"
|
|
39
40
|
},
|
|
40
41
|
"peerDependencies": {
|
|
41
42
|
"react": ">=16.9.0",
|
package/src/utils.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { createLogger } from '@module-federation/sdk';
|
|
3
3
|
|
|
4
|
-
export const LoggerInstance =
|
|
4
|
+
export const LoggerInstance = createLogger(
|
|
5
|
+
'[ Module Federation Bridge React ]',
|
|
6
|
+
);
|
|
5
7
|
|
|
6
8
|
type typeReact = typeof React;
|
|
7
9
|
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const React = require("react");
|
|
3
|
-
var a = Object.defineProperty;
|
|
4
|
-
var c = (s, e, t) => e in s ? a(s, e, { enumerable: true, configurable: true, writable: true, value: t }) : s[e] = t;
|
|
5
|
-
var i = (s, e, t) => (c(s, typeof e != "symbol" ? e + "" : e, t), t);
|
|
6
|
-
class g {
|
|
7
|
-
constructor(e) {
|
|
8
|
-
i(this, "name");
|
|
9
|
-
i(this, "isDebugEnabled");
|
|
10
|
-
i(this, "color");
|
|
11
|
-
this.name = e, this.isDebugEnabled = false, 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");
|
|
12
|
-
}
|
|
13
|
-
log(...e) {
|
|
14
|
-
var t, n;
|
|
15
|
-
if (this.isDebugEnabled) {
|
|
16
|
-
const o = `color: ${this.color}; font-weight: bold`, l = `%c[${this.name}]`, r = ((n = (t = new Error().stack) == null ? void 0 : t.split(`
|
|
17
|
-
`)[2]) == null ? void 0 : n.trim()) || "Stack information not available";
|
|
18
|
-
typeof console < "u" && console.debug && console.debug(l, o, ...e, `
|
|
19
|
-
(${r})`);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
stringToColor(e) {
|
|
23
|
-
let t = 0;
|
|
24
|
-
for (let o = 0; o < e.length; o++)
|
|
25
|
-
t = e.charCodeAt(o) + ((t << 5) - t);
|
|
26
|
-
let n = "#";
|
|
27
|
-
for (let o = 0; o < 3; o++) {
|
|
28
|
-
const l = t >> o * 8 & 255;
|
|
29
|
-
n += ("00" + l.toString(16)).substr(-2);
|
|
30
|
-
}
|
|
31
|
-
return n;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
function f() {
|
|
35
|
-
const s = new PopStateEvent("popstate", { state: window.history.state });
|
|
36
|
-
window.dispatchEvent(s);
|
|
37
|
-
}
|
|
38
|
-
const LoggerInstance = new g("bridge-react");
|
|
39
|
-
function atLeastReact18(React2) {
|
|
40
|
-
if (React2 && typeof React2.version === "string" && React2.version.indexOf(".") >= 0) {
|
|
41
|
-
const majorVersionString = React2.version.split(".")[0];
|
|
42
|
-
try {
|
|
43
|
-
return Number(majorVersionString) >= 18;
|
|
44
|
-
} catch (err) {
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
} else {
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
function pathJoin(...args) {
|
|
52
|
-
const res = args.reduce((res2, path) => {
|
|
53
|
-
let nPath = path;
|
|
54
|
-
if (!nPath || typeof nPath !== "string") {
|
|
55
|
-
return res2;
|
|
56
|
-
}
|
|
57
|
-
if (nPath[0] !== "/") {
|
|
58
|
-
nPath = `/${nPath}`;
|
|
59
|
-
}
|
|
60
|
-
const lastIndex = nPath.length - 1;
|
|
61
|
-
if (nPath[lastIndex] === "/") {
|
|
62
|
-
nPath = nPath.substring(0, lastIndex);
|
|
63
|
-
}
|
|
64
|
-
return res2 + nPath;
|
|
65
|
-
}, "");
|
|
66
|
-
return res || "/";
|
|
67
|
-
}
|
|
68
|
-
const RouterContext = React.createContext(null);
|
|
69
|
-
exports.LoggerInstance = LoggerInstance;
|
|
70
|
-
exports.RouterContext = RouterContext;
|
|
71
|
-
exports.atLeastReact18 = atLeastReact18;
|
|
72
|
-
exports.f = f;
|
|
73
|
-
exports.pathJoin = pathJoin;
|
package/dist/context-Bw2PEwa6.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import React__default from "react";
|
|
2
|
-
var a = Object.defineProperty;
|
|
3
|
-
var c = (s, e, t) => e in s ? a(s, e, { enumerable: true, configurable: true, writable: true, value: t }) : s[e] = t;
|
|
4
|
-
var i = (s, e, t) => (c(s, typeof e != "symbol" ? e + "" : e, t), t);
|
|
5
|
-
class g {
|
|
6
|
-
constructor(e) {
|
|
7
|
-
i(this, "name");
|
|
8
|
-
i(this, "isDebugEnabled");
|
|
9
|
-
i(this, "color");
|
|
10
|
-
this.name = e, this.isDebugEnabled = false, 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");
|
|
11
|
-
}
|
|
12
|
-
log(...e) {
|
|
13
|
-
var t, n;
|
|
14
|
-
if (this.isDebugEnabled) {
|
|
15
|
-
const o = `color: ${this.color}; font-weight: bold`, l = `%c[${this.name}]`, r = ((n = (t = new Error().stack) == null ? void 0 : t.split(`
|
|
16
|
-
`)[2]) == null ? void 0 : n.trim()) || "Stack information not available";
|
|
17
|
-
typeof console < "u" && console.debug && console.debug(l, o, ...e, `
|
|
18
|
-
(${r})`);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
stringToColor(e) {
|
|
22
|
-
let t = 0;
|
|
23
|
-
for (let o = 0; o < e.length; o++)
|
|
24
|
-
t = e.charCodeAt(o) + ((t << 5) - t);
|
|
25
|
-
let n = "#";
|
|
26
|
-
for (let o = 0; o < 3; o++) {
|
|
27
|
-
const l = t >> o * 8 & 255;
|
|
28
|
-
n += ("00" + l.toString(16)).substr(-2);
|
|
29
|
-
}
|
|
30
|
-
return n;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
function f() {
|
|
34
|
-
const s = new PopStateEvent("popstate", { state: window.history.state });
|
|
35
|
-
window.dispatchEvent(s);
|
|
36
|
-
}
|
|
37
|
-
const LoggerInstance = new g("bridge-react");
|
|
38
|
-
function atLeastReact18(React2) {
|
|
39
|
-
if (React2 && typeof React2.version === "string" && React2.version.indexOf(".") >= 0) {
|
|
40
|
-
const majorVersionString = React2.version.split(".")[0];
|
|
41
|
-
try {
|
|
42
|
-
return Number(majorVersionString) >= 18;
|
|
43
|
-
} catch (err) {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
} else {
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
function pathJoin(...args) {
|
|
51
|
-
const res = args.reduce((res2, path) => {
|
|
52
|
-
let nPath = path;
|
|
53
|
-
if (!nPath || typeof nPath !== "string") {
|
|
54
|
-
return res2;
|
|
55
|
-
}
|
|
56
|
-
if (nPath[0] !== "/") {
|
|
57
|
-
nPath = `/${nPath}`;
|
|
58
|
-
}
|
|
59
|
-
const lastIndex = nPath.length - 1;
|
|
60
|
-
if (nPath[lastIndex] === "/") {
|
|
61
|
-
nPath = nPath.substring(0, lastIndex);
|
|
62
|
-
}
|
|
63
|
-
return res2 + nPath;
|
|
64
|
-
}, "");
|
|
65
|
-
return res || "/";
|
|
66
|
-
}
|
|
67
|
-
const RouterContext = React__default.createContext(null);
|
|
68
|
-
export {
|
|
69
|
-
LoggerInstance as L,
|
|
70
|
-
RouterContext as R,
|
|
71
|
-
atLeastReact18 as a,
|
|
72
|
-
f,
|
|
73
|
-
pathJoin as p
|
|
74
|
-
};
|