-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export interface MiniProgramWorker { | ||
onMessage<T = Record<string, unknown>>(cb: (message: T) => void): void; | ||
postMessage<T = Record<string, unknown>>(message: T): void; | ||
/** | ||
* 用于模拟 iOS ExperimentalWorker 线程被系统回收事件,主线程中通过 Worker.onProcessKilled 监听, 以便于调试。 | ||
* 仅限 iOS 系统, 仅支持在 worker 线程内可用。 | ||
*/ | ||
testOnProcessKilled(): void; | ||
} | ||
|
||
declare var worker: MiniProgramWorker; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import type { MiniProgramWorker } from '../../packages/global/types/lib.worker'; | ||
import { expectAssignable } from 'tsd-lite'; | ||
|
||
declare const worker: MiniProgramWorker; | ||
|
||
expectAssignable<(cb: (evt: any) => any) => any>(worker.onMessage); | ||
expectAssignable<(message: any) => any>(worker.postMessage); | ||
expectAssignable<() => any>(worker.testOnProcessKilled); |