File tree Expand file tree Collapse file tree 4 files changed +10
-13
lines changed
protocols/workers/internal Expand file tree Collapse file tree 4 files changed +10
-13
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " tgrid" ,
3- "version" : " 0.10.0 " ,
3+ "version" : " 0.10.1 " ,
44 "main" : " lib/index.js" ,
55 "typings" : " lib/index.d.ts" ,
66 "exports" : {
Original file line number Diff line number Diff line change @@ -5,20 +5,20 @@ import { NodeModule } from "../../../../utils/internal/NodeModule";
55 */
66export class ProcessChannel {
77 public static postMessage ( message : any ) : void {
8- NodeModule . process ( ) . send ! ( message ) ;
8+ NodeModule . process . get ( ) . send ! ( message ) ;
99 }
1010
1111 public static close ( ) : void {
12- NodeModule . process ( ) . exit ( ) ;
12+ NodeModule . process . get ( ) . exit ( ) ;
1313 }
1414
1515 public static set onmessage ( listener : ( event : MessageEvent ) => void ) {
16- NodeModule . process ( ) . on ( "message" , ( msg ) => {
16+ NodeModule . process . get ( ) . on ( "message" , ( msg ) => {
1717 listener ( { data : msg } as MessageEvent ) ;
1818 } ) ;
1919 }
2020
2121 public static is_worker_server ( ) : boolean {
22- return ! ! NodeModule . process ( ) . send ;
22+ return ! ! NodeModule . process . get ( ) . send ;
2323 }
2424}
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ export async function ThreadPort() {
1212 const { parentPort } = await NodeModule . thread . get ( ) ;
1313 if ( ! parentPort ) throw new Error ( "This is not a worker thread." ) ;
1414
15- const process = NodeModule . process ( ) ;
15+ const process = NodeModule . process . get ( ) ;
1616 class ThreadPort {
1717 public static postMessage ( message : any ) : void {
1818 parentPort ! . postMessage ( message ) ;
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import type * as __https from "https";
55import import2 from "import2" ;
66import type * as __os from "os" ;
77import type * as __process from "process" ;
8- import { Singleton } from "tstl" ;
8+ import { Singleton , is_node } from "tstl" ;
99import type * as __thread from "worker_threads" ;
1010import type * as __ws from "ws" ;
1111
@@ -31,10 +31,7 @@ export namespace NodeModule {
3131 export const ws : Singleton < Promise < typeof __ws > > = new Singleton (
3232 ( ) => import ( "ws" ) ,
3333 ) ;
34- export const process = ( ) => __global . process ;
34+ export const process : Singleton < typeof __process > = new Singleton ( ( ) =>
35+ is_node ( ) ? global . process : undefined ! ,
36+ ) ;
3537}
36-
37- /**
38- * @internal
39- */
40- const __global = global ;
You can’t perform that action at this time.
0 commit comments