|
1 | 1 | import { LogObject, LogObjectType, LogLevel } from './LogObject'; |
2 | 2 |
|
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 | | - |
18 | 3 | function initialize() { |
19 | 4 | "use strict"; |
20 | 5 |
|
21 | 6 | if (typeof window !== 'undefined' && !window['BlazorExtensions']) { |
22 | 7 | // When the library is loaded in a browser via a <script> element, make the |
23 | 8 | // following APIs available in global scope for invocation from JS |
24 | 9 | window['BlazorExtensions'] = { |
| 10 | + Logging: { |
| 11 | + BrowserConsoleLogger: { |
| 12 | + } |
| 13 | + } |
25 | 14 | }; |
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 | + } |
33 | 21 | } |
34 | 22 | }; |
35 | 23 | } |
36 | 24 |
|
37 | 25 | 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); |
41 | 26 |
|
42 | | - //if (!logObject) { |
43 | | - // console.error('Invalid logObject received: ', logObjectString ? logObjectString : '<null>'); |
44 | | - // return; |
45 | | - //} |
46 | 27 | const logObject = JSON.parse(logObjectValue); |
47 | 28 | var logMethod = console.log; |
48 | 29 |
|
|
0 commit comments