comparison Platforms/Wasm/wasm-application-runner.ts @ 603:70992b38aa8a

new routable logging system in STDIO mode + flag support (with no value) in StartupParametersBuilder + 80 col indent
author Benjamin Golinvaux <bgo@osimis.io>
date Mon, 29 Apr 2019 15:09:48 +0200
parents e1ba16436d59
children 28b9e3a54200
comparison
equal deleted inserted replaced
602:03c4b998fcd0 603:70992b38aa8a
25 function DoAnimationThread() { 25 function DoAnimationThread() {
26 if (WasmDoAnimation != null) { 26 if (WasmDoAnimation != null) {
27 WasmDoAnimation(); 27 WasmDoAnimation();
28 } 28 }
29 29
30 setTimeout(DoAnimationThread, 100); // Update the viewport content every 100ms if need be 30 // Update the viewport content every 100ms if need be
31 setTimeout(DoAnimationThread, 100);
31 } 32 }
32 33
33 function GetUriParameters(): Map<string, string> { 34 function GetUriParameters(): Map<string, string> {
34 var parameters = window.location.search.substr(1); 35 var parameters = window.location.search.substr(1);
35 36
40 41
41 for (var i = 0; i < tokens.length; i++) { 42 for (var i = 0; i < tokens.length; i++) {
42 var tmp = tokens[i].split('='); 43 var tmp = tokens[i].split('=');
43 if (tmp.length == 2) { 44 if (tmp.length == 2) {
44 result[tmp[0]] = decodeURIComponent(tmp[1]); 45 result[tmp[0]] = decodeURIComponent(tmp[1]);
46 } else if(tmp.length == 1) {
47 // if there is no '=', we treat ot afterwards as a flag-style param
48 result[tmp[0]] = "";
45 } 49 }
46 } 50 }
47 51 return result;
48 return result;
49 } 52 }
50 else { 53 else {
51 return new Map<string, string>(); 54 return new Map<string, string>();
52 } 55 }
53 } 56 }
63 // parse uri and transmit the parameters to the app before initializing it 66 // parse uri and transmit the parameters to the app before initializing it
64 let parameters = GetUriParameters(); 67 let parameters = GetUriParameters();
65 68
66 for (let key in parameters) { 69 for (let key in parameters) {
67 if (parameters.hasOwnProperty(key)) { 70 if (parameters.hasOwnProperty(key)) {
71 Logger.defaultLogger.debug(
72 `About to call SetStartupParameter("${key}","${parameters[key]}")`);
68 SetStartupParameter(key, parameters[key]); 73 SetStartupParameter(key, parameters[key]);
69 } 74 }
70 } 75 }
71 76
72 StartWasmApplication(orthancBaseUrl); 77 StartWasmApplication(orthancBaseUrl);
90 SetStartupParameter = (<any> window).StoneFrameworkModule.cwrap('SetStartupParameter', null, ['string', 'string']); 95 SetStartupParameter = (<any> window).StoneFrameworkModule.cwrap('SetStartupParameter', null, ['string', 'string']);
91 CreateWasmApplication = (<any> window).StoneFrameworkModule.cwrap('CreateWasmApplication', null, ['number']); 96 CreateWasmApplication = (<any> window).StoneFrameworkModule.cwrap('CreateWasmApplication', null, ['number']);
92 CreateCppViewport = (<any> window).StoneFrameworkModule.cwrap('CreateCppViewport', 'number', []); 97 CreateCppViewport = (<any> window).StoneFrameworkModule.cwrap('CreateCppViewport', 'number', []);
93 ReleaseCppViewport = (<any> window).StoneFrameworkModule.cwrap('ReleaseCppViewport', null, ['number']); 98 ReleaseCppViewport = (<any> window).StoneFrameworkModule.cwrap('ReleaseCppViewport', null, ['number']);
94 StartWasmApplication = (<any> window).StoneFrameworkModule.cwrap('StartWasmApplication', null, ['string']); 99 StartWasmApplication = (<any> window).StoneFrameworkModule.cwrap('StartWasmApplication', null, ['string']);
100 (<any> window).IsTraceLevelEnabled = (<any> window).StoneFrameworkModule.cwrap('WasmIsTraceLevelEnabled', 'boolean', null);
101 (<any> window).IsInfoLevelEnabled = (<any> window).StoneFrameworkModule.cwrap('WasmIsInfoLevelEnabled', 'boolean', null);
95 102
96 (<any> window).WasmWebService_NotifyCachedSuccess = (<any> window).StoneFrameworkModule.cwrap('WasmWebService_NotifyCachedSuccess', null, ['number']); 103 (<any> window).WasmWebService_NotifyCachedSuccess = (<any> window).StoneFrameworkModule.cwrap('WasmWebService_NotifyCachedSuccess', null, ['number']);
97 (<any> window).WasmWebService_NotifySuccess = (<any> window).StoneFrameworkModule.cwrap('WasmWebService_NotifySuccess', null, ['number', 'string', 'array', 'number', 'number']); 104 (<any> window).WasmWebService_NotifySuccess = (<any> window).StoneFrameworkModule.cwrap('WasmWebService_NotifySuccess', null, ['number', 'string', 'array', 'number', 'number']);
98 (<any> window).WasmWebService_NotifyError = (<any> window).StoneFrameworkModule.cwrap('WasmWebService_NotifyError', null, ['number', 'string', 'number']); 105 (<any> window).WasmWebService_NotifyError = (<any> window).StoneFrameworkModule.cwrap('WasmWebService_NotifyError', null, ['number', 'string', 'number']);
99 (<any> window).WasmDelayedCallExecutor_ExecuteCallback = (<any> window).StoneFrameworkModule.cwrap('WasmDelayedCallExecutor_ExecuteCallback', null, ['number']); 106 (<any> window).WasmDelayedCallExecutor_ExecuteCallback = (<any> window).StoneFrameworkModule.cwrap('WasmDelayedCallExecutor_ExecuteCallback', null, ['number']);