1- import { ApplyPath , CallType , InterfaceType , NodeName , PlatformInstanceId } from './types' ;
1+ import {
2+ ApplyPath ,
3+ CallType ,
4+ InstanceId ,
5+ InterfaceType ,
6+ NodeName ,
7+ PlatformInstanceId ,
8+ WinId ,
9+ } from './types' ;
210import {
311 ApplyPathKey ,
412 InstanceDataKey ,
@@ -18,7 +26,7 @@ export const logMain = (msg: string) => {
1826 }
1927} ;
2028
21- export const logWorker = ( msg : string , winId = - 1 ) => {
29+ export const logWorker = ( msg : string , winId ?: WinId ) => {
2230 if ( debug ) {
2331 try {
2432 const config = webWorkerCtx . $config$ ;
@@ -31,7 +39,7 @@ export const logWorker = (msg: string, winId = -1) => {
3139
3240 let prefix : string ;
3341 let color : string ;
34- if ( winId > - 1 ) {
42+ if ( winId ) {
3543 prefix = `Worker (${ normalizedWinId ( winId ) } ) 🎉` ;
3644 color = winColor ( winId ) ;
3745 } else {
@@ -51,15 +59,15 @@ export const logWorker = (msg: string, winId = -1) => {
5159 }
5260} ;
5361
54- const winIds : number [ ] = [ ] ;
55- export const normalizedWinId = ( winId : number ) => {
62+ const winIds : WinId [ ] = [ ] ;
63+ export const normalizedWinId = ( winId : WinId ) => {
5664 if ( ! winIds . includes ( winId ) ) {
5765 winIds . push ( winId ) ;
5866 }
5967 return winIds . indexOf ( winId ) + 1 ;
6068} ;
6169
62- const winColor = ( winId : number ) => {
70+ const winColor = ( winId : WinId ) => {
6371 const colors = [ '#00309e' , '#ea3655' , '#eea727' ] ;
6472 const index = normalizedWinId ( winId ) - 1 ;
6573 return colors [ index ] || colors [ colors . length - 1 ] ;
@@ -212,8 +220,8 @@ const getLogValue = (applyPath: ApplyPath, v: any): string => {
212220 return `[${ v . map ( getLogValue ) . join ( ', ' ) } ]` ;
213221 }
214222 if ( type === 'object' ) {
215- const instanceId : number = v [ InstanceIdKey ] ;
216- if ( typeof instanceId === 'number ' ) {
223+ const instanceId : InstanceId = v [ InstanceIdKey ] ;
224+ if ( typeof instanceId === 'string ' ) {
217225 if ( instanceId === PlatformInstanceId . body ) {
218226 return `<body>` ;
219227 }
0 commit comments