Skip to content

Commit 595784c

Browse files
committed
Fix object collision
1 parent a379f25 commit 595784c

File tree

1 file changed

+10
-29
lines changed

1 file changed

+10
-29
lines changed

src/Blazor.Extensions.Logging.JS/src/Initialize.ts

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,29 @@
11
import { LogObject, LogObjectType, LogLevel } from './LogObject';
22

3-
// Declare types here until we've Blazor.d.ts
4-
export interface System_Object { System_Object__DO_NOT_IMPLEMENT: any };
5-
export interface System_String extends System_Object { System_String__DO_NOT_IMPLEMENT: any }
6-
7-
interface Platform {
8-
toJavaScriptString(dotNetString: System_String): string;
9-
}
10-
11-
type BlazorType = {
12-
registerFunction(identifier: string, implementation: Function),
13-
platform: Platform
14-
};
15-
16-
const Blazor: BlazorType = window["Blazor"];
17-
183
function initialize() {
194
"use strict";
205

216
if (typeof window !== 'undefined' && !window['BlazorExtensions']) {
227
// When the library is loaded in a browser via a <script> element, make the
238
// following APIs available in global scope for invocation from JS
249
window['BlazorExtensions'] = {
10+
Logging: {
11+
BrowserConsoleLogger: {
12+
}
13+
}
2514
};
26-
}
27-
28-
if (typeof window['BlazorExtensions']['Logging'] === 'undefined') {
29-
// When the library is loaded in a browser via a <script> element, make the
30-
// following APIs available in global scope for invocation from JS
31-
window['BlazorExtensions']['Logging'] = {
32-
BrowserConsoleLogger: {
15+
} else {
16+
window['BlazorExtensions'] = {
17+
...window['BlazorExtensions'],
18+
Logging: {
19+
BrowserConsoleLogger: {
20+
}
3321
}
3422
};
3523
}
3624

3725
window['BlazorExtensions']['Logging']['BrowserConsoleLogger']['Log'] = function (logObjectValue) {
38-
//console.log(logObjectValue);
39-
//const logObjectString = Blazor.platform.toJavaScriptString(logObjectValue);
40-
//const logObject: LogObject = JSON.parse(logObjectString);
4126

42-
//if (!logObject) {
43-
// console.error('Invalid logObject received: ', logObjectString ? logObjectString : '<null>');
44-
// return;
45-
//}
4627
const logObject = JSON.parse(logObjectValue);
4728
var logMethod = console.log;
4829

0 commit comments

Comments
 (0)