161847f8eSopenharmony_ci/* 261847f8eSopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd. 361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 461847f8eSopenharmony_ci * you may not use this file except in compliance with the License. 561847f8eSopenharmony_ci * You may obtain a copy of the License at 661847f8eSopenharmony_ci * 761847f8eSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 861847f8eSopenharmony_ci * 961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and 1361847f8eSopenharmony_ci * limitations under the License. 1461847f8eSopenharmony_ci */ 1561847f8eSopenharmony_ci 1661847f8eSopenharmony_ci/** 1761847f8eSopenharmony_ci * @file 1861847f8eSopenharmony_ci * @kit ArkTS 1961847f8eSopenharmony_ci */ 2061847f8eSopenharmony_ci 2161847f8eSopenharmony_ci/** 2261847f8eSopenharmony_ci * @typedef WorkerOptions 2361847f8eSopenharmony_ci * Provides options that can be set for the worker to create. 2461847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 2561847f8eSopenharmony_ci * @since 7 2661847f8eSopenharmony_ci */ 2761847f8eSopenharmony_ci/** 2861847f8eSopenharmony_ci * @typedef WorkerOptions 2961847f8eSopenharmony_ci * Provides options that can be set for the worker to create. 3061847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 3161847f8eSopenharmony_ci * @crossplatform 3261847f8eSopenharmony_ci * @since 10 3361847f8eSopenharmony_ci */ 3461847f8eSopenharmony_ci/** 3561847f8eSopenharmony_ci * @typedef WorkerOptions 3661847f8eSopenharmony_ci * Provides options that can be set for the worker to create. 3761847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 3861847f8eSopenharmony_ci * @crossplatform 3961847f8eSopenharmony_ci * @atomicservice 4061847f8eSopenharmony_ci * @since 11 4161847f8eSopenharmony_ci */ 4261847f8eSopenharmony_ciexport interface WorkerOptions { 4361847f8eSopenharmony_ci /** 4461847f8eSopenharmony_ci * Mode in which the worker executes the script. 4561847f8eSopenharmony_ci * 4661847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 4761847f8eSopenharmony_ci * @since 7 4861847f8eSopenharmony_ci */ 4961847f8eSopenharmony_ci /** 5061847f8eSopenharmony_ci * Mode in which the worker executes the script. 5161847f8eSopenharmony_ci * 5261847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 5361847f8eSopenharmony_ci * @crossplatform 5461847f8eSopenharmony_ci * @since 10 5561847f8eSopenharmony_ci */ 5661847f8eSopenharmony_ci /** 5761847f8eSopenharmony_ci * Mode in which the worker executes the script. 5861847f8eSopenharmony_ci * 5961847f8eSopenharmony_ci * @type { ?('classic' | 'module') } 6061847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 6161847f8eSopenharmony_ci * @crossplatform 6261847f8eSopenharmony_ci * @atomicservice 6361847f8eSopenharmony_ci * @since 11 6461847f8eSopenharmony_ci */ 6561847f8eSopenharmony_ci type?: 'classic' | 'module'; 6661847f8eSopenharmony_ci 6761847f8eSopenharmony_ci /** 6861847f8eSopenharmony_ci * Name of the worker. 6961847f8eSopenharmony_ci * 7061847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 7161847f8eSopenharmony_ci * @since 7 7261847f8eSopenharmony_ci */ 7361847f8eSopenharmony_ci /** 7461847f8eSopenharmony_ci * Name of the worker. 7561847f8eSopenharmony_ci * 7661847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 7761847f8eSopenharmony_ci * @crossplatform 7861847f8eSopenharmony_ci * @since 10 7961847f8eSopenharmony_ci */ 8061847f8eSopenharmony_ci /** 8161847f8eSopenharmony_ci * Name of the worker. 8261847f8eSopenharmony_ci * 8361847f8eSopenharmony_ci * @type { ?string } 8461847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 8561847f8eSopenharmony_ci * @crossplatform 8661847f8eSopenharmony_ci * @atomicservice 8761847f8eSopenharmony_ci * @since 11 8861847f8eSopenharmony_ci */ 8961847f8eSopenharmony_ci name?: string; 9061847f8eSopenharmony_ci 9161847f8eSopenharmony_ci /** 9261847f8eSopenharmony_ci * Whether the worker is shared. 9361847f8eSopenharmony_ci * 9461847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 9561847f8eSopenharmony_ci * @since 7 9661847f8eSopenharmony_ci */ 9761847f8eSopenharmony_ci /** 9861847f8eSopenharmony_ci * Whether the worker is shared. 9961847f8eSopenharmony_ci * 10061847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 10161847f8eSopenharmony_ci * @crossplatform 10261847f8eSopenharmony_ci * @since 10 10361847f8eSopenharmony_ci */ 10461847f8eSopenharmony_ci /** 10561847f8eSopenharmony_ci * Whether the worker is shared. 10661847f8eSopenharmony_ci * 10761847f8eSopenharmony_ci * @type { ?boolean } 10861847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 10961847f8eSopenharmony_ci * @crossplatform 11061847f8eSopenharmony_ci * @atomicservice 11161847f8eSopenharmony_ci * @since 12 11261847f8eSopenharmony_ci */ 11361847f8eSopenharmony_ci shared?: boolean; 11461847f8eSopenharmony_ci} 11561847f8eSopenharmony_ci 11661847f8eSopenharmony_ci/** 11761847f8eSopenharmony_ci * @typedef Event 11861847f8eSopenharmony_ci * Defines the event. 11961847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 12061847f8eSopenharmony_ci * @since 7 12161847f8eSopenharmony_ci */ 12261847f8eSopenharmony_ci/** 12361847f8eSopenharmony_ci * @typedef Event 12461847f8eSopenharmony_ci * Defines the event. 12561847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 12661847f8eSopenharmony_ci * @crossplatform 12761847f8eSopenharmony_ci * @since 10 12861847f8eSopenharmony_ci */ 12961847f8eSopenharmony_ci/** 13061847f8eSopenharmony_ci * @typedef Event 13161847f8eSopenharmony_ci * Defines the event. 13261847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 13361847f8eSopenharmony_ci * @crossplatform 13461847f8eSopenharmony_ci * @atomicservice 13561847f8eSopenharmony_ci * @since 11 13661847f8eSopenharmony_ci */ 13761847f8eSopenharmony_ciexport interface Event { 13861847f8eSopenharmony_ci /** 13961847f8eSopenharmony_ci * Type of the Event. 14061847f8eSopenharmony_ci * 14161847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 14261847f8eSopenharmony_ci * @since 7 14361847f8eSopenharmony_ci */ 14461847f8eSopenharmony_ci /** 14561847f8eSopenharmony_ci * Type of the Event. 14661847f8eSopenharmony_ci * 14761847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 14861847f8eSopenharmony_ci * @crossplatform 14961847f8eSopenharmony_ci * @since 10 15061847f8eSopenharmony_ci */ 15161847f8eSopenharmony_ci /** 15261847f8eSopenharmony_ci * Type of the Event. 15361847f8eSopenharmony_ci * 15461847f8eSopenharmony_ci * @type { string } 15561847f8eSopenharmony_ci * @readonly 15661847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 15761847f8eSopenharmony_ci * @crossplatform 15861847f8eSopenharmony_ci * @atomicservice 15961847f8eSopenharmony_ci * @since 12 16061847f8eSopenharmony_ci */ 16161847f8eSopenharmony_ci readonly type: string; 16261847f8eSopenharmony_ci 16361847f8eSopenharmony_ci /** 16461847f8eSopenharmony_ci * Timestamp(accurate to millisecond) when the event is created. 16561847f8eSopenharmony_ci * 16661847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 16761847f8eSopenharmony_ci * @since 7 16861847f8eSopenharmony_ci */ 16961847f8eSopenharmony_ci /** 17061847f8eSopenharmony_ci * Timestamp(accurate to millisecond) when the event is created. 17161847f8eSopenharmony_ci * 17261847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 17361847f8eSopenharmony_ci * @crossplatform 17461847f8eSopenharmony_ci * @since 10 17561847f8eSopenharmony_ci */ 17661847f8eSopenharmony_ci /** 17761847f8eSopenharmony_ci * Timestamp(accurate to millisecond) when the event is created. 17861847f8eSopenharmony_ci * 17961847f8eSopenharmony_ci * @type { number } 18061847f8eSopenharmony_ci * @readonly 18161847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 18261847f8eSopenharmony_ci * @crossplatform 18361847f8eSopenharmony_ci * @atomicservice 18461847f8eSopenharmony_ci * @since 12 18561847f8eSopenharmony_ci */ 18661847f8eSopenharmony_ci readonly timeStamp: number; 18761847f8eSopenharmony_ci} 18861847f8eSopenharmony_ci 18961847f8eSopenharmony_ci/** 19061847f8eSopenharmony_ci * Provides detailed information about the exception occurred during worker execution. 19161847f8eSopenharmony_ci * @typedef ErrorEvent 19261847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 19361847f8eSopenharmony_ci * @since 7 19461847f8eSopenharmony_ci */ 19561847f8eSopenharmony_ci/** 19661847f8eSopenharmony_ci * Provides detailed information about the exception occurred during worker execution. 19761847f8eSopenharmony_ci * @typedef ErrorEvent 19861847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 19961847f8eSopenharmony_ci * @crossplatform 20061847f8eSopenharmony_ci * @since 10 20161847f8eSopenharmony_ci */ 20261847f8eSopenharmony_ci/** 20361847f8eSopenharmony_ci * Provides detailed information about the exception occurred during worker execution. 20461847f8eSopenharmony_ci * @typedef ErrorEvent 20561847f8eSopenharmony_ci * @extends Event 20661847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 20761847f8eSopenharmony_ci * @crossplatform 20861847f8eSopenharmony_ci * @atomicservice 20961847f8eSopenharmony_ci * @since 11 21061847f8eSopenharmony_ci */ 21161847f8eSopenharmony_ciexport interface ErrorEvent extends Event { 21261847f8eSopenharmony_ci /** 21361847f8eSopenharmony_ci * Information about the exception. 21461847f8eSopenharmony_ci * 21561847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 21661847f8eSopenharmony_ci * @since 7 21761847f8eSopenharmony_ci */ 21861847f8eSopenharmony_ci /** 21961847f8eSopenharmony_ci * Information about the exception. 22061847f8eSopenharmony_ci * 22161847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 22261847f8eSopenharmony_ci * @crossplatform 22361847f8eSopenharmony_ci * @since 10 22461847f8eSopenharmony_ci */ 22561847f8eSopenharmony_ci /** 22661847f8eSopenharmony_ci * Information about the exception. 22761847f8eSopenharmony_ci * 22861847f8eSopenharmony_ci * @type { string } 22961847f8eSopenharmony_ci * @readonly 23061847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 23161847f8eSopenharmony_ci * @crossplatform 23261847f8eSopenharmony_ci * @atomicservice 23361847f8eSopenharmony_ci * @since 11 23461847f8eSopenharmony_ci */ 23561847f8eSopenharmony_ci readonly message: string; 23661847f8eSopenharmony_ci 23761847f8eSopenharmony_ci /** 23861847f8eSopenharmony_ci * File where the exception is located. 23961847f8eSopenharmony_ci * 24061847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 24161847f8eSopenharmony_ci * @since 7 24261847f8eSopenharmony_ci */ 24361847f8eSopenharmony_ci /** 24461847f8eSopenharmony_ci * File where the exception is located. 24561847f8eSopenharmony_ci * 24661847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 24761847f8eSopenharmony_ci * @crossplatform 24861847f8eSopenharmony_ci * @since 10 24961847f8eSopenharmony_ci */ 25061847f8eSopenharmony_ci /** 25161847f8eSopenharmony_ci * File where the exception is located. 25261847f8eSopenharmony_ci * 25361847f8eSopenharmony_ci * @type { string } 25461847f8eSopenharmony_ci * @readonly 25561847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 25661847f8eSopenharmony_ci * @crossplatform 25761847f8eSopenharmony_ci * @atomicservice 25861847f8eSopenharmony_ci * @since 11 25961847f8eSopenharmony_ci */ 26061847f8eSopenharmony_ci readonly filename: string; 26161847f8eSopenharmony_ci 26261847f8eSopenharmony_ci /** 26361847f8eSopenharmony_ci * Number of the line where the exception is located. 26461847f8eSopenharmony_ci * 26561847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 26661847f8eSopenharmony_ci * @since 7 26761847f8eSopenharmony_ci */ 26861847f8eSopenharmony_ci /** 26961847f8eSopenharmony_ci * Number of the line where the exception is located. 27061847f8eSopenharmony_ci * 27161847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 27261847f8eSopenharmony_ci * @crossplatform 27361847f8eSopenharmony_ci * @since 10 27461847f8eSopenharmony_ci */ 27561847f8eSopenharmony_ci /** 27661847f8eSopenharmony_ci * Number of the line where the exception is located. 27761847f8eSopenharmony_ci * 27861847f8eSopenharmony_ci * @type { number } 27961847f8eSopenharmony_ci * @readonly 28061847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 28161847f8eSopenharmony_ci * @crossplatform 28261847f8eSopenharmony_ci * @atomicservice 28361847f8eSopenharmony_ci * @since 11 28461847f8eSopenharmony_ci */ 28561847f8eSopenharmony_ci readonly lineno: number; 28661847f8eSopenharmony_ci 28761847f8eSopenharmony_ci /** 28861847f8eSopenharmony_ci * Number of the column where the exception is located. 28961847f8eSopenharmony_ci * 29061847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 29161847f8eSopenharmony_ci * @since 7 29261847f8eSopenharmony_ci */ 29361847f8eSopenharmony_ci /** 29461847f8eSopenharmony_ci * Number of the column where the exception is located. 29561847f8eSopenharmony_ci * 29661847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 29761847f8eSopenharmony_ci * @crossplatform 29861847f8eSopenharmony_ci * @since 10 29961847f8eSopenharmony_ci */ 30061847f8eSopenharmony_ci /** 30161847f8eSopenharmony_ci * Number of the column where the exception is located. 30261847f8eSopenharmony_ci * 30361847f8eSopenharmony_ci * @type { number } 30461847f8eSopenharmony_ci * @readonly 30561847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 30661847f8eSopenharmony_ci * @crossplatform 30761847f8eSopenharmony_ci * @atomicservice 30861847f8eSopenharmony_ci * @since 11 30961847f8eSopenharmony_ci */ 31061847f8eSopenharmony_ci readonly colno: number; 31161847f8eSopenharmony_ci 31261847f8eSopenharmony_ci /** 31361847f8eSopenharmony_ci * Type of the exception. 31461847f8eSopenharmony_ci * 31561847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 31661847f8eSopenharmony_ci * @since 7 31761847f8eSopenharmony_ci */ 31861847f8eSopenharmony_ci /** 31961847f8eSopenharmony_ci * Type of the exception. 32061847f8eSopenharmony_ci * 32161847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 32261847f8eSopenharmony_ci * @crossplatform 32361847f8eSopenharmony_ci * @since 10 32461847f8eSopenharmony_ci */ 32561847f8eSopenharmony_ci /** 32661847f8eSopenharmony_ci * Type of the exception. 32761847f8eSopenharmony_ci * 32861847f8eSopenharmony_ci * @type { Object } 32961847f8eSopenharmony_ci * @readonly 33061847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 33161847f8eSopenharmony_ci * @crossplatform 33261847f8eSopenharmony_ci * @atomicservice 33361847f8eSopenharmony_ci * @since 11 33461847f8eSopenharmony_ci */ 33561847f8eSopenharmony_ci readonly error: Object; 33661847f8eSopenharmony_ci} 33761847f8eSopenharmony_ci 33861847f8eSopenharmony_ci/** 33961847f8eSopenharmony_ci * Holds the data transferred between worker threads. 34061847f8eSopenharmony_ci * @typedef MessageEvent<T> 34161847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 34261847f8eSopenharmony_ci * @since 7 34361847f8eSopenharmony_ci */ 34461847f8eSopenharmony_ci/** 34561847f8eSopenharmony_ci * Holds the data transferred between worker threads. 34661847f8eSopenharmony_ci * @typedef MessageEvent<T> 34761847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 34861847f8eSopenharmony_ci * @crossplatform 34961847f8eSopenharmony_ci * @since 10 35061847f8eSopenharmony_ci */ 35161847f8eSopenharmony_ci/** 35261847f8eSopenharmony_ci * Holds the data transferred between worker threads. 35361847f8eSopenharmony_ci * @typedef MessageEvent<T> 35461847f8eSopenharmony_ci * @extends Event 35561847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 35661847f8eSopenharmony_ci * @crossplatform 35761847f8eSopenharmony_ci * @atomicservice 35861847f8eSopenharmony_ci * @since 12 35961847f8eSopenharmony_ci */ 36061847f8eSopenharmony_ciexport interface MessageEvent<T> extends Event { 36161847f8eSopenharmony_ci /** 36261847f8eSopenharmony_ci * Data transferred when an exception occurs. 36361847f8eSopenharmony_ci * 36461847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 36561847f8eSopenharmony_ci * @since 7 36661847f8eSopenharmony_ci */ 36761847f8eSopenharmony_ci /** 36861847f8eSopenharmony_ci * Data transferred when an exception occurs. 36961847f8eSopenharmony_ci * 37061847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 37161847f8eSopenharmony_ci * @crossplatform 37261847f8eSopenharmony_ci * @since 10 37361847f8eSopenharmony_ci */ 37461847f8eSopenharmony_ci /** 37561847f8eSopenharmony_ci * Data transferred when an exception occurs. 37661847f8eSopenharmony_ci * 37761847f8eSopenharmony_ci * @type { T } 37861847f8eSopenharmony_ci * @readonly 37961847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 38061847f8eSopenharmony_ci * @crossplatform 38161847f8eSopenharmony_ci * @atomicservice 38261847f8eSopenharmony_ci * @since 12 38361847f8eSopenharmony_ci */ 38461847f8eSopenharmony_ci readonly data: T; 38561847f8eSopenharmony_ci} 38661847f8eSopenharmony_ci 38761847f8eSopenharmony_ci/** 38861847f8eSopenharmony_ci * Saves the data transferred between worker thread and host thread. 38961847f8eSopenharmony_ci * @typedef MessageEvents 39061847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 39161847f8eSopenharmony_ci * @since 9 39261847f8eSopenharmony_ci */ 39361847f8eSopenharmony_ci/** 39461847f8eSopenharmony_ci * Saves the data transferred between worker thread and host thread. 39561847f8eSopenharmony_ci * @typedef MessageEvents 39661847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 39761847f8eSopenharmony_ci * @crossplatform 39861847f8eSopenharmony_ci * @since 10 39961847f8eSopenharmony_ci */ 40061847f8eSopenharmony_ci/** 40161847f8eSopenharmony_ci * Saves the data transferred between worker thread and host thread. 40261847f8eSopenharmony_ci * @typedef MessageEvents 40361847f8eSopenharmony_ci * @extends Event 40461847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 40561847f8eSopenharmony_ci * @crossplatform 40661847f8eSopenharmony_ci * @atomicservice 40761847f8eSopenharmony_ci * @since 11 40861847f8eSopenharmony_ci */ 40961847f8eSopenharmony_ciexport interface MessageEvents extends Event { 41061847f8eSopenharmony_ci /** 41161847f8eSopenharmony_ci * Data transferred when an exception occurs. 41261847f8eSopenharmony_ci * 41361847f8eSopenharmony_ci * @type { any } 41461847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 41561847f8eSopenharmony_ci * @since 9 41661847f8eSopenharmony_ci */ 41761847f8eSopenharmony_ci /** 41861847f8eSopenharmony_ci * Data transferred when an exception occurs. 41961847f8eSopenharmony_ci * 42061847f8eSopenharmony_ci * @type { any } 42161847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 42261847f8eSopenharmony_ci * @crossplatform 42361847f8eSopenharmony_ci * @since 10 42461847f8eSopenharmony_ci */ 42561847f8eSopenharmony_ci /** 42661847f8eSopenharmony_ci * Data transferred when an exception occurs. 42761847f8eSopenharmony_ci * 42861847f8eSopenharmony_ci * @type { any } 42961847f8eSopenharmony_ci * @readonly 43061847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 43161847f8eSopenharmony_ci * @crossplatform 43261847f8eSopenharmony_ci * @atomicservice 43361847f8eSopenharmony_ci * @since 11 43461847f8eSopenharmony_ci */ 43561847f8eSopenharmony_ci readonly data: any; 43661847f8eSopenharmony_ci} 43761847f8eSopenharmony_ci 43861847f8eSopenharmony_ci/** 43961847f8eSopenharmony_ci * @typedef PostMessageOptions 44061847f8eSopenharmony_ci * Specifies the object whose ownership need to be transferred during data transfer. 44161847f8eSopenharmony_ci * The object must be ArrayBuffer. 44261847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 44361847f8eSopenharmony_ci * @since 7 44461847f8eSopenharmony_ci */ 44561847f8eSopenharmony_ci/** 44661847f8eSopenharmony_ci * @typedef PostMessageOptions 44761847f8eSopenharmony_ci * Specifies the object whose ownership need to be transferred during data transfer. 44861847f8eSopenharmony_ci * The object must be ArrayBuffer. 44961847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 45061847f8eSopenharmony_ci * @crossplatform 45161847f8eSopenharmony_ci * @since 10 45261847f8eSopenharmony_ci */ 45361847f8eSopenharmony_ci/** 45461847f8eSopenharmony_ci * @typedef PostMessageOptions 45561847f8eSopenharmony_ci * Specifies the object whose ownership need to be transferred during data transfer. 45661847f8eSopenharmony_ci * The object must be ArrayBuffer. 45761847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 45861847f8eSopenharmony_ci * @crossplatform 45961847f8eSopenharmony_ci * @atomicservice 46061847f8eSopenharmony_ci * @since 11 46161847f8eSopenharmony_ci */ 46261847f8eSopenharmony_ciexport interface PostMessageOptions { 46361847f8eSopenharmony_ci /** 46461847f8eSopenharmony_ci * ArrayBuffer array used to transfer the ownership. 46561847f8eSopenharmony_ci * 46661847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 46761847f8eSopenharmony_ci * @since 7 46861847f8eSopenharmony_ci */ 46961847f8eSopenharmony_ci /** 47061847f8eSopenharmony_ci * ArrayBuffer array used to transfer the ownership. 47161847f8eSopenharmony_ci * 47261847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 47361847f8eSopenharmony_ci * @crossplatform 47461847f8eSopenharmony_ci * @since 10 47561847f8eSopenharmony_ci */ 47661847f8eSopenharmony_ci /** 47761847f8eSopenharmony_ci * ArrayBuffer array used to transfer the ownership. 47861847f8eSopenharmony_ci * 47961847f8eSopenharmony_ci * @type { ?Object[] } 48061847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 48161847f8eSopenharmony_ci * @crossplatform 48261847f8eSopenharmony_ci * @atomicservice 48361847f8eSopenharmony_ci * @since 11 48461847f8eSopenharmony_ci */ 48561847f8eSopenharmony_ci transfer?: Object[]; 48661847f8eSopenharmony_ci} 48761847f8eSopenharmony_ci 48861847f8eSopenharmony_ci/** 48961847f8eSopenharmony_ci * @typedef EventListener 49061847f8eSopenharmony_ci * Implements event listening. 49161847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 49261847f8eSopenharmony_ci * @since 7 49361847f8eSopenharmony_ci * @deprecated since 9 49461847f8eSopenharmony_ci * @useinstead ohos.worker.WorkerEventListener 49561847f8eSopenharmony_ci */ 49661847f8eSopenharmony_ciexport interface EventListener { 49761847f8eSopenharmony_ci /** 49861847f8eSopenharmony_ci * Specifies the callback to invoke. 49961847f8eSopenharmony_ci * 50061847f8eSopenharmony_ci * @param { Event } evt - evt evt Event class for the callback to invoke. 50161847f8eSopenharmony_ci * @returns { void | Promise<void> } 50261847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 50361847f8eSopenharmony_ci * @since 7 50461847f8eSopenharmony_ci * @deprecated since 9 50561847f8eSopenharmony_ci * @useinstead ohos.worker.WorkerEventListener.(event: Event) 50661847f8eSopenharmony_ci */ 50761847f8eSopenharmony_ci (evt: Event): void | Promise<void>; 50861847f8eSopenharmony_ci} 50961847f8eSopenharmony_ci 51061847f8eSopenharmony_ci/** 51161847f8eSopenharmony_ci * @typedef WorkerEventListener 51261847f8eSopenharmony_ci * Implements event listening. 51361847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 51461847f8eSopenharmony_ci * @since 9 51561847f8eSopenharmony_ci */ 51661847f8eSopenharmony_ci/** 51761847f8eSopenharmony_ci * @typedef WorkerEventListener 51861847f8eSopenharmony_ci * Implements event listening. 51961847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 52061847f8eSopenharmony_ci * @crossplatform 52161847f8eSopenharmony_ci * @since 10 52261847f8eSopenharmony_ci */ 52361847f8eSopenharmony_ci/** 52461847f8eSopenharmony_ci * @typedef WorkerEventListener 52561847f8eSopenharmony_ci * Implements event listening. 52661847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 52761847f8eSopenharmony_ci * @crossplatform 52861847f8eSopenharmony_ci * @atomicservice 52961847f8eSopenharmony_ci * @since 12 53061847f8eSopenharmony_ci */ 53161847f8eSopenharmony_ciexport interface WorkerEventListener { 53261847f8eSopenharmony_ci /** 53361847f8eSopenharmony_ci * Specifies the callback function to be invoked. 53461847f8eSopenharmony_ci * 53561847f8eSopenharmony_ci * @param { Event } event - event Event class for the callback to invoke. 53661847f8eSopenharmony_ci * @returns { void | Promise<void> } 53761847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 53861847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 53961847f8eSopenharmony_ci * 2.Incorrect parameter types; 54061847f8eSopenharmony_ci * 3.Parameter verification failed. 54161847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 54261847f8eSopenharmony_ci * @throws { BusinessError } 10200005 - The called API is not supported in the worker thread. 54361847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 54461847f8eSopenharmony_ci * @since 9 54561847f8eSopenharmony_ci */ 54661847f8eSopenharmony_ci /** 54761847f8eSopenharmony_ci * Specifies the callback function to be invoked. 54861847f8eSopenharmony_ci * 54961847f8eSopenharmony_ci * @param { Event } event - event Event class for the callback to invoke. 55061847f8eSopenharmony_ci * @returns { void | Promise<void> } 55161847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 55261847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 55361847f8eSopenharmony_ci * 2.Incorrect parameter types; 55461847f8eSopenharmony_ci * 3.Parameter verification failed. 55561847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 55661847f8eSopenharmony_ci * @throws { BusinessError } 10200005 - The called API is not supported in the worker thread. 55761847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 55861847f8eSopenharmony_ci * @crossplatform 55961847f8eSopenharmony_ci * @since 10 56061847f8eSopenharmony_ci */ 56161847f8eSopenharmony_ci /** 56261847f8eSopenharmony_ci * Specifies the callback function to be invoked. 56361847f8eSopenharmony_ci * 56461847f8eSopenharmony_ci * @param { Event } event - event Event class for the callback to invoke. 56561847f8eSopenharmony_ci * @returns { void | Promise<void> } 56661847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 56761847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 56861847f8eSopenharmony_ci * 2.Incorrect parameter types; 56961847f8eSopenharmony_ci * 3.Parameter verification failed. 57061847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - Worker instance is not running. 57161847f8eSopenharmony_ci * @throws { BusinessError } 10200005 - The invoked API is not supported in workers. 57261847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 57361847f8eSopenharmony_ci * @crossplatform 57461847f8eSopenharmony_ci * @atomicservice 57561847f8eSopenharmony_ci * @since 12 57661847f8eSopenharmony_ci */ 57761847f8eSopenharmony_ci (event: Event): void | Promise<void>; 57861847f8eSopenharmony_ci} 57961847f8eSopenharmony_ci 58061847f8eSopenharmony_ci/** 58161847f8eSopenharmony_ci * Type of message, only "message" and "messageerror". 58261847f8eSopenharmony_ci * 58361847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 58461847f8eSopenharmony_ci * @since 7 58561847f8eSopenharmony_ci */ 58661847f8eSopenharmony_ci/** 58761847f8eSopenharmony_ci * Type of message, only "message" and "messageerror". 58861847f8eSopenharmony_ci * 58961847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 59061847f8eSopenharmony_ci * @crossplatform 59161847f8eSopenharmony_ci * @since 10 59261847f8eSopenharmony_ci */ 59361847f8eSopenharmony_ci/** 59461847f8eSopenharmony_ci * Type of message, only "message" and "messageerror". 59561847f8eSopenharmony_ci * 59661847f8eSopenharmony_ci * @typedef { 'message' | 'messageerror' } 59761847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 59861847f8eSopenharmony_ci * @crossplatform 59961847f8eSopenharmony_ci * @atomicservice 60061847f8eSopenharmony_ci * @since 12 60161847f8eSopenharmony_ci */ 60261847f8eSopenharmony_citype MessageType = 'message' | 'messageerror'; 60361847f8eSopenharmony_ci 60461847f8eSopenharmony_ci/** 60561847f8eSopenharmony_ci * @typedef EventTarget 60661847f8eSopenharmony_ci * Specific event features. 60761847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 60861847f8eSopenharmony_ci * @since 7 60961847f8eSopenharmony_ci * @deprecated since 9 61061847f8eSopenharmony_ci * @useinstead ohos.worker.WorkerEventTarget 61161847f8eSopenharmony_ci */ 61261847f8eSopenharmony_ciexport interface EventTarget { 61361847f8eSopenharmony_ci /** 61461847f8eSopenharmony_ci * Adds an event listener to the worker. 61561847f8eSopenharmony_ci * 61661847f8eSopenharmony_ci * @param { string } type - type Type of the event to listen for. 61761847f8eSopenharmony_ci * @param { EventListener } listener - listener Callback to invoke when an event of the specified type occurs. 61861847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 61961847f8eSopenharmony_ci * @since 7 62061847f8eSopenharmony_ci * @deprecated since 9 62161847f8eSopenharmony_ci * @useinstead ohos.worker.WorkerEventTarget.addEventListener 62261847f8eSopenharmony_ci */ 62361847f8eSopenharmony_ci addEventListener(type: string, listener: EventListener): void; 62461847f8eSopenharmony_ci 62561847f8eSopenharmony_ci /** 62661847f8eSopenharmony_ci * Dispatches the event defined for the worker. 62761847f8eSopenharmony_ci * 62861847f8eSopenharmony_ci * @param { Event } event - event Event to dispatch. 62961847f8eSopenharmony_ci * @returns { boolean } 63061847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 63161847f8eSopenharmony_ci * @since 7 63261847f8eSopenharmony_ci * @deprecated since 9 63361847f8eSopenharmony_ci * @useinstead ohos.worker.WorkerEventTarget.dispatchEvent 63461847f8eSopenharmony_ci */ 63561847f8eSopenharmony_ci dispatchEvent(event: Event): boolean; 63661847f8eSopenharmony_ci 63761847f8eSopenharmony_ci /** 63861847f8eSopenharmony_ci * Removes an event defined for the worker. 63961847f8eSopenharmony_ci * 64061847f8eSopenharmony_ci * @param { string } type - type Type of the event for which the event listener is removed. 64161847f8eSopenharmony_ci * @param { EventListener } callback - callback Callback of the event listener to remove. 64261847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 64361847f8eSopenharmony_ci * @since 7 64461847f8eSopenharmony_ci * @deprecated since 9 64561847f8eSopenharmony_ci * @useinstead ohos.worker.WorkerEventTarget.removeEventListener 64661847f8eSopenharmony_ci */ 64761847f8eSopenharmony_ci removeEventListener(type: string, callback?: EventListener): void; 64861847f8eSopenharmony_ci 64961847f8eSopenharmony_ci /** 65061847f8eSopenharmony_ci * Removes all event listeners for the worker. 65161847f8eSopenharmony_ci * 65261847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 65361847f8eSopenharmony_ci * @since 7 65461847f8eSopenharmony_ci * @deprecated since 9 65561847f8eSopenharmony_ci * @useinstead ohos.worker.WorkerEventTarget.removeAllListener 65661847f8eSopenharmony_ci */ 65761847f8eSopenharmony_ci removeAllListener(): void; 65861847f8eSopenharmony_ci} 65961847f8eSopenharmony_ci 66061847f8eSopenharmony_ci/** 66161847f8eSopenharmony_ci * @typedef WorkerEventTarget 66261847f8eSopenharmony_ci * Specific worker event features. 66361847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 66461847f8eSopenharmony_ci * @since 9 66561847f8eSopenharmony_ci */ 66661847f8eSopenharmony_ci/** 66761847f8eSopenharmony_ci * @typedef WorkerEventTarget 66861847f8eSopenharmony_ci * Specific worker event features. 66961847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 67061847f8eSopenharmony_ci * @crossplatform 67161847f8eSopenharmony_ci * @since 10 67261847f8eSopenharmony_ci */ 67361847f8eSopenharmony_ci/** 67461847f8eSopenharmony_ci * @typedef WorkerEventTarget 67561847f8eSopenharmony_ci * Specific worker event features. 67661847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 67761847f8eSopenharmony_ci * @crossplatform 67861847f8eSopenharmony_ci * @atomicservice 67961847f8eSopenharmony_ci * @since 11 68061847f8eSopenharmony_ci */ 68161847f8eSopenharmony_ciexport interface WorkerEventTarget { 68261847f8eSopenharmony_ci /** 68361847f8eSopenharmony_ci * Adds an event listener to the worker. 68461847f8eSopenharmony_ci * 68561847f8eSopenharmony_ci * @param { string } type - type Type of the event to listen for. 68661847f8eSopenharmony_ci * @param { WorkerEventListener } listener - listener Callback to invoke when an event of the specified type occurs. 68761847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 68861847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 68961847f8eSopenharmony_ci * 2.Incorrect parameter types; 69061847f8eSopenharmony_ci * 3.Parameter verification failed. 69161847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 69261847f8eSopenharmony_ci * @throws { BusinessError } 10200005 - The called API is not supported in the worker thread. 69361847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 69461847f8eSopenharmony_ci * @since 9 69561847f8eSopenharmony_ci */ 69661847f8eSopenharmony_ci /** 69761847f8eSopenharmony_ci * Adds an event listener to the worker. 69861847f8eSopenharmony_ci * 69961847f8eSopenharmony_ci * @param { string } type - type Type of the event to listen for. 70061847f8eSopenharmony_ci * @param { WorkerEventListener } listener - listener Callback to invoke when an event of the specified type occurs. 70161847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 70261847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 70361847f8eSopenharmony_ci * 2.Incorrect parameter types; 70461847f8eSopenharmony_ci * 3.Parameter verification failed. 70561847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 70661847f8eSopenharmony_ci * @throws { BusinessError } 10200005 - The called API is not supported in the worker thread. 70761847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 70861847f8eSopenharmony_ci * @since 10 70961847f8eSopenharmony_ci */ 71061847f8eSopenharmony_ci /** 71161847f8eSopenharmony_ci * Adds an event listener to the worker. 71261847f8eSopenharmony_ci * 71361847f8eSopenharmony_ci * @param { string } type - type Type of the event to listen for. 71461847f8eSopenharmony_ci * @param { WorkerEventListener } listener - listener Callback to invoke when an event of the specified type occurs. 71561847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 71661847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 71761847f8eSopenharmony_ci * 2.Incorrect parameter types; 71861847f8eSopenharmony_ci * 3.Parameter verification failed. 71961847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 72061847f8eSopenharmony_ci * @throws { BusinessError } 10200005 - The called API is not supported in the worker thread. 72161847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 72261847f8eSopenharmony_ci * @crossplatform 72361847f8eSopenharmony_ci * @since 11 72461847f8eSopenharmony_ci */ 72561847f8eSopenharmony_ci /** 72661847f8eSopenharmony_ci * Adds an event listener to the worker. 72761847f8eSopenharmony_ci * 72861847f8eSopenharmony_ci * @param { string } type - type Type of the event to listen for. 72961847f8eSopenharmony_ci * @param { WorkerEventListener } listener - listener Callback to invoke when an event of the specified type occurs. 73061847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 73161847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 73261847f8eSopenharmony_ci * 2.Incorrect parameter types; 73361847f8eSopenharmony_ci * 3.Parameter verification failed. 73461847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 73561847f8eSopenharmony_ci * @throws { BusinessError } 10200005 - The called API is not supported in the worker thread. 73661847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 73761847f8eSopenharmony_ci * @crossplatform 73861847f8eSopenharmony_ci * @atomicservice 73961847f8eSopenharmony_ci * @since 12 74061847f8eSopenharmony_ci */ 74161847f8eSopenharmony_ci addEventListener(type: string, listener: WorkerEventListener): void; 74261847f8eSopenharmony_ci /** 74361847f8eSopenharmony_ci * Handle the event defined for the worker. 74461847f8eSopenharmony_ci * 74561847f8eSopenharmony_ci * @param { Event } event - event Event to dispatch. 74661847f8eSopenharmony_ci * @returns { boolean } 74761847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 74861847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 74961847f8eSopenharmony_ci * 2.Incorrect parameter types; 75061847f8eSopenharmony_ci * 3.Parameter verification failed. 75161847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 75261847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 75361847f8eSopenharmony_ci * @since 9 75461847f8eSopenharmony_ci */ 75561847f8eSopenharmony_ci /** 75661847f8eSopenharmony_ci * Handle the event defined for the worker. 75761847f8eSopenharmony_ci * 75861847f8eSopenharmony_ci * @param { Event } event - event Event to dispatch. 75961847f8eSopenharmony_ci * @returns { boolean } 76061847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 76161847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 76261847f8eSopenharmony_ci * 2.Incorrect parameter types; 76361847f8eSopenharmony_ci * 3.Parameter verification failed. 76461847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 76561847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 76661847f8eSopenharmony_ci * @crossplatform 76761847f8eSopenharmony_ci * @since 10 76861847f8eSopenharmony_ci */ 76961847f8eSopenharmony_ci /** 77061847f8eSopenharmony_ci * Handle the event defined for the worker. 77161847f8eSopenharmony_ci * 77261847f8eSopenharmony_ci * @param { Event } event - event Event to dispatch. 77361847f8eSopenharmony_ci * @returns { boolean } 77461847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 77561847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 77661847f8eSopenharmony_ci * 2.Incorrect parameter types; 77761847f8eSopenharmony_ci * 3.Parameter verification failed. 77861847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 77961847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 78061847f8eSopenharmony_ci * @crossplatform 78161847f8eSopenharmony_ci * @atomicservice 78261847f8eSopenharmony_ci * @since 12 78361847f8eSopenharmony_ci */ 78461847f8eSopenharmony_ci dispatchEvent(event: Event): boolean; 78561847f8eSopenharmony_ci /** 78661847f8eSopenharmony_ci * Remove an event defined for the worker. 78761847f8eSopenharmony_ci * 78861847f8eSopenharmony_ci * @param { string } type - type Type of the event for which the event listener is cancelled. 78961847f8eSopenharmony_ci * @param { WorkerEventListener } [callback] - callback Callback of the event listener to remove. 79061847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 79161847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 79261847f8eSopenharmony_ci * 2.Incorrect parameter types; 79361847f8eSopenharmony_ci * 3.Parameter verification failed. 79461847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 79561847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 79661847f8eSopenharmony_ci * @since 9 79761847f8eSopenharmony_ci */ 79861847f8eSopenharmony_ci /** 79961847f8eSopenharmony_ci * Remove an event defined for the worker. 80061847f8eSopenharmony_ci * 80161847f8eSopenharmony_ci * @param { string } type - type Type of the event for which the event listener is cancelled. 80261847f8eSopenharmony_ci * @param { WorkerEventListener } [callback] - callback Callback of the event listener to remove. 80361847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 80461847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 80561847f8eSopenharmony_ci * 2.Incorrect parameter types; 80661847f8eSopenharmony_ci * 3.Parameter verification failed. 80761847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 80861847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 80961847f8eSopenharmony_ci * @crossplatform 81061847f8eSopenharmony_ci * @since 10 81161847f8eSopenharmony_ci */ 81261847f8eSopenharmony_ci /** 81361847f8eSopenharmony_ci * Remove an event defined for the worker. 81461847f8eSopenharmony_ci * 81561847f8eSopenharmony_ci * @param { string } type - type Type of the event for which the event listener is cancelled. 81661847f8eSopenharmony_ci * @param { WorkerEventListener } [callback] - callback Callback of the event listener to remove. 81761847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 81861847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 81961847f8eSopenharmony_ci * 2.Incorrect parameter types; 82061847f8eSopenharmony_ci * 3.Parameter verification failed. 82161847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 82261847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 82361847f8eSopenharmony_ci * @crossplatform 82461847f8eSopenharmony_ci * @atomicservice 82561847f8eSopenharmony_ci * @since 12 82661847f8eSopenharmony_ci */ 82761847f8eSopenharmony_ci removeEventListener(type: string, callback?: WorkerEventListener): void; 82861847f8eSopenharmony_ci /** 82961847f8eSopenharmony_ci * Remove all event listeners for the worker. 83061847f8eSopenharmony_ci * 83161847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 83261847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 83361847f8eSopenharmony_ci * @since 9 83461847f8eSopenharmony_ci */ 83561847f8eSopenharmony_ci /** 83661847f8eSopenharmony_ci * Remove all event listeners for the worker. 83761847f8eSopenharmony_ci * 83861847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 83961847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 84061847f8eSopenharmony_ci * @crossplatform 84161847f8eSopenharmony_ci * @since 10 84261847f8eSopenharmony_ci */ 84361847f8eSopenharmony_ci /** 84461847f8eSopenharmony_ci * Remove all event listeners for the worker. 84561847f8eSopenharmony_ci * 84661847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 84761847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 84861847f8eSopenharmony_ci * @crossplatform 84961847f8eSopenharmony_ci * @atomicservice 85061847f8eSopenharmony_ci * @since 12 85161847f8eSopenharmony_ci */ 85261847f8eSopenharmony_ci removeAllListener(): void; 85361847f8eSopenharmony_ci} 85461847f8eSopenharmony_ci 85561847f8eSopenharmony_ci/** 85661847f8eSopenharmony_ci * @typedef WorkerGlobalScope 85761847f8eSopenharmony_ci * Specifies the worker thread running environment, which is isolated from the host thread environment. 85861847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 85961847f8eSopenharmony_ci * @since 7 86061847f8eSopenharmony_ci * @deprecated since 9 86161847f8eSopenharmony_ci * @useinstead ohos.worker.GlobalScope 86261847f8eSopenharmony_ci */ 86361847f8eSopenharmony_cideclare interface WorkerGlobalScope extends EventTarget { 86461847f8eSopenharmony_ci /** 86561847f8eSopenharmony_ci * Worker name specified when there is a new worker. 86661847f8eSopenharmony_ci * 86761847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 86861847f8eSopenharmony_ci * @since 7 86961847f8eSopenharmony_ci * @deprecated since 9 87061847f8eSopenharmony_ci * @useinstead ohos.worker.GlobalScope.name 87161847f8eSopenharmony_ci */ 87261847f8eSopenharmony_ci readonly name: string; 87361847f8eSopenharmony_ci 87461847f8eSopenharmony_ci /** 87561847f8eSopenharmony_ci * The onerror attribute of parentPort specifies 87661847f8eSopenharmony_ci * the event handler to be called when an exception occurs during worker execution. 87761847f8eSopenharmony_ci * The event handler is executed in the worker thread. 87861847f8eSopenharmony_ci * 87961847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 88061847f8eSopenharmony_ci * @since 7 88161847f8eSopenharmony_ci * @deprecated since 9 88261847f8eSopenharmony_ci * @useinstead ohos.worker.GlobalScope.onerror 88361847f8eSopenharmony_ci */ 88461847f8eSopenharmony_ci onerror?: (ev: ErrorEvent) => void; 88561847f8eSopenharmony_ci 88661847f8eSopenharmony_ci /** 88761847f8eSopenharmony_ci * Specify the type attribute for self. 88861847f8eSopenharmony_ci * 88961847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 89061847f8eSopenharmony_ci * @since 7 89161847f8eSopenharmony_ci * @deprecated since 9 89261847f8eSopenharmony_ci * @useinstead ohos.worker.GlobalScope.self 89361847f8eSopenharmony_ci */ 89461847f8eSopenharmony_ci readonly self: WorkerGlobalScope & typeof globalThis; 89561847f8eSopenharmony_ci} 89661847f8eSopenharmony_ci 89761847f8eSopenharmony_ci/** 89861847f8eSopenharmony_ci * The environment Specified in which worker threads run, which is isolated from the host thread environment. 89961847f8eSopenharmony_ci * @typedef GlobalScope 90061847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 90161847f8eSopenharmony_ci * @since 9 90261847f8eSopenharmony_ci */ 90361847f8eSopenharmony_ci/** 90461847f8eSopenharmony_ci * The environment Specified in which worker threads run, which is isolated from the host thread environment. 90561847f8eSopenharmony_ci * @typedef GlobalScope 90661847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 90761847f8eSopenharmony_ci * @crossplatform 90861847f8eSopenharmony_ci * @since 10 90961847f8eSopenharmony_ci */ 91061847f8eSopenharmony_ci/** 91161847f8eSopenharmony_ci * The environment Specified in which worker threads run, which is isolated from the host thread environment. 91261847f8eSopenharmony_ci * @typedef GlobalScope 91361847f8eSopenharmony_ci * @extends WorkerEventTarget 91461847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 91561847f8eSopenharmony_ci * @crossplatform 91661847f8eSopenharmony_ci * @atomicservice 91761847f8eSopenharmony_ci * @since 11 91861847f8eSopenharmony_ci */ 91961847f8eSopenharmony_cideclare interface GlobalScope extends WorkerEventTarget { 92061847f8eSopenharmony_ci /** 92161847f8eSopenharmony_ci * Name of Worker specified when there is a new worker. 92261847f8eSopenharmony_ci * 92361847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 92461847f8eSopenharmony_ci * @since 9 92561847f8eSopenharmony_ci */ 92661847f8eSopenharmony_ci /** 92761847f8eSopenharmony_ci * Name of Worker specified when there is a new worker. 92861847f8eSopenharmony_ci * 92961847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 93061847f8eSopenharmony_ci * @crossplatform 93161847f8eSopenharmony_ci * @since 10 93261847f8eSopenharmony_ci */ 93361847f8eSopenharmony_ci /** 93461847f8eSopenharmony_ci * Name of Worker specified when there is a new worker. 93561847f8eSopenharmony_ci * 93661847f8eSopenharmony_ci * @type { string } 93761847f8eSopenharmony_ci * @readonly 93861847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 93961847f8eSopenharmony_ci * @crossplatform 94061847f8eSopenharmony_ci * @atomicservice 94161847f8eSopenharmony_ci * @since 11 94261847f8eSopenharmony_ci */ 94361847f8eSopenharmony_ci readonly name: string; 94461847f8eSopenharmony_ci 94561847f8eSopenharmony_ci /** 94661847f8eSopenharmony_ci * The onerror attribute of parentPort specified. 94761847f8eSopenharmony_ci * the event handler to be called when an exception occurs during worker execution. 94861847f8eSopenharmony_ci * The event handler is executed in the worker thread. 94961847f8eSopenharmony_ci * 95061847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 95161847f8eSopenharmony_ci * @since 9 95261847f8eSopenharmony_ci */ 95361847f8eSopenharmony_ci /** 95461847f8eSopenharmony_ci * The onerror attribute of parentPort specified. 95561847f8eSopenharmony_ci * the event handler to be called when an exception occurs during worker execution. 95661847f8eSopenharmony_ci * The event handler is executed in the worker thread. 95761847f8eSopenharmony_ci * 95861847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 95961847f8eSopenharmony_ci * @crossplatform 96061847f8eSopenharmony_ci * @since 10 96161847f8eSopenharmony_ci */ 96261847f8eSopenharmony_ci /** 96361847f8eSopenharmony_ci * The onerror attribute of parentPort specified. 96461847f8eSopenharmony_ci * the event handler to be called when an exception occurs during worker execution. 96561847f8eSopenharmony_ci * The event handler is executed in the worker thread. 96661847f8eSopenharmony_ci * 96761847f8eSopenharmony_ci * @type { ?function } 96861847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 96961847f8eSopenharmony_ci * @crossplatform 97061847f8eSopenharmony_ci * @atomicservice 97161847f8eSopenharmony_ci * @since 11 97261847f8eSopenharmony_ci */ 97361847f8eSopenharmony_ci onerror?: (ev: ErrorEvent) => void; 97461847f8eSopenharmony_ci /** 97561847f8eSopenharmony_ci * Specify the type attribute for self. 97661847f8eSopenharmony_ci * 97761847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 97861847f8eSopenharmony_ci * @since 9 97961847f8eSopenharmony_ci */ 98061847f8eSopenharmony_ci /** 98161847f8eSopenharmony_ci * Specify the type attribute for self. 98261847f8eSopenharmony_ci * 98361847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 98461847f8eSopenharmony_ci * @crossplatform 98561847f8eSopenharmony_ci * @since 10 98661847f8eSopenharmony_ci */ 98761847f8eSopenharmony_ci /** 98861847f8eSopenharmony_ci * Specify the type attribute for self. 98961847f8eSopenharmony_ci * 99061847f8eSopenharmony_ci * @type { GlobalScope & typeof globalThis } 99161847f8eSopenharmony_ci * @readonly 99261847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 99361847f8eSopenharmony_ci * @crossplatform 99461847f8eSopenharmony_ci * @atomicservice 99561847f8eSopenharmony_ci * @since 11 99661847f8eSopenharmony_ci */ 99761847f8eSopenharmony_ci readonly self: GlobalScope & typeof globalThis; 99861847f8eSopenharmony_ci} 99961847f8eSopenharmony_ci 100061847f8eSopenharmony_ci/** 100161847f8eSopenharmony_ci * @typedef DedicatedWorkerGlobalScope 100261847f8eSopenharmony_ci * Specifies the worker thread running environment, which is isolated from the host thread environment 100361847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 100461847f8eSopenharmony_ci * @since 7 100561847f8eSopenharmony_ci * @deprecated since 9 100661847f8eSopenharmony_ci * @useinstead ohos.worker.ThreadWorkerGlobalScope 100761847f8eSopenharmony_ci */ 100861847f8eSopenharmony_ciexport interface DedicatedWorkerGlobalScope extends WorkerGlobalScope { 100961847f8eSopenharmony_ci /** 101061847f8eSopenharmony_ci * The onmessage attribute of parentPort specifies the event handler 101161847f8eSopenharmony_ci * to be called then the worker thread receives a message sent by 101261847f8eSopenharmony_ci * the host thread through worker postMessage. 101361847f8eSopenharmony_ci * The event handler is executed in the worker thread. 101461847f8eSopenharmony_ci * 101561847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 101661847f8eSopenharmony_ci * @since 7 101761847f8eSopenharmony_ci * @deprecated since 9 101861847f8eSopenharmony_ci * @useinstead ohos.worker.ThreadWorkerGlobalScope.onmessage 101961847f8eSopenharmony_ci */ 102061847f8eSopenharmony_ci onmessage?: (this: DedicatedWorkerGlobalScope, ev: MessageEvent) => void; 102161847f8eSopenharmony_ci 102261847f8eSopenharmony_ci /** 102361847f8eSopenharmony_ci * The onmessage attribute of parentPort specifies the event handler 102461847f8eSopenharmony_ci * to be called then the worker receives a message that cannot be deserialized. 102561847f8eSopenharmony_ci * The event handler is executed in the worker thread. 102661847f8eSopenharmony_ci * 102761847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 102861847f8eSopenharmony_ci * @since 7 102961847f8eSopenharmony_ci * @deprecated since 9 103061847f8eSopenharmony_ci * @useinstead ohos.worker.ThreadWorkerGlobalScope.onmessageerror 103161847f8eSopenharmony_ci */ 103261847f8eSopenharmony_ci onmessageerror?: (this: DedicatedWorkerGlobalScope, ev: MessageEvent) => void; 103361847f8eSopenharmony_ci 103461847f8eSopenharmony_ci /** 103561847f8eSopenharmony_ci * Close the worker thread to stop the worker from receiving messages 103661847f8eSopenharmony_ci * 103761847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 103861847f8eSopenharmony_ci * @since 7 103961847f8eSopenharmony_ci * @deprecated since 9 104061847f8eSopenharmony_ci * @useinstead ohos.worker.ThreadWorkerGlobalScope.close 104161847f8eSopenharmony_ci */ 104261847f8eSopenharmony_ci close(): void; 104361847f8eSopenharmony_ci 104461847f8eSopenharmony_ci /** 104561847f8eSopenharmony_ci * Send a message to be host thread from the worker 104661847f8eSopenharmony_ci * 104761847f8eSopenharmony_ci * @param { Object } messageObject - messageObject Data to be sent to the worker 104861847f8eSopenharmony_ci * @param { Transferable[] } transfer - transfer array cannot contain null. 104961847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 105061847f8eSopenharmony_ci * @since 7 105161847f8eSopenharmony_ci * @deprecated since 9 105261847f8eSopenharmony_ci * @useinstead ohos.worker.ThreadWorkerGlobalScope.postMessage 105361847f8eSopenharmony_ci */ 105461847f8eSopenharmony_ci postMessage(messageObject: Object, transfer: Transferable[]): void; 105561847f8eSopenharmony_ci 105661847f8eSopenharmony_ci /** 105761847f8eSopenharmony_ci * Send a message to be host thread from the worker 105861847f8eSopenharmony_ci * 105961847f8eSopenharmony_ci * @param { Object } messageObject - messageObject Data to be sent to the worker 106061847f8eSopenharmony_ci * @param { PostMessageOptions } [options] - options Option can be set for postmessage. 106161847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 106261847f8eSopenharmony_ci * @since 7 106361847f8eSopenharmony_ci * @deprecated since 9 106461847f8eSopenharmony_ci * @useinstead ohos.worker.ThreadWorkerGlobalScope.postMessage 106561847f8eSopenharmony_ci */ 106661847f8eSopenharmony_ci postMessage(messageObject: Object, options?: PostMessageOptions): void; 106761847f8eSopenharmony_ci 106861847f8eSopenharmony_ci /** 106961847f8eSopenharmony_ci * Send a message to host thread from the worker 107061847f8eSopenharmony_ci * 107161847f8eSopenharmony_ci * @param { Object } messageObject - messageObject Data to be sent to the worker 107261847f8eSopenharmony_ci * @param { ArrayBuffer[] } transfer - transfer array cannot contain null. 107361847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 107461847f8eSopenharmony_ci * @since 9 107561847f8eSopenharmony_ci * @deprecated since 9 107661847f8eSopenharmony_ci */ 107761847f8eSopenharmony_ci postMessage(messageObject: Object, transfer: ArrayBuffer[]): void; 107861847f8eSopenharmony_ci} 107961847f8eSopenharmony_ci 108061847f8eSopenharmony_ci/** 108161847f8eSopenharmony_ci * Specifies the thread-worker running environment, which is isolated from the host-thread environment 108261847f8eSopenharmony_ci * @typedef ThreadWorkerGlobalScope 108361847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 108461847f8eSopenharmony_ci * @since 9 108561847f8eSopenharmony_ci */ 108661847f8eSopenharmony_ci/** 108761847f8eSopenharmony_ci * Specifies the thread-worker running environment, which is isolated from the host-thread environment 108861847f8eSopenharmony_ci * @typedef ThreadWorkerGlobalScope 108961847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 109061847f8eSopenharmony_ci * @crossplatform 109161847f8eSopenharmony_ci * @since 10 109261847f8eSopenharmony_ci */ 109361847f8eSopenharmony_ci/** 109461847f8eSopenharmony_ci * Specifies the thread-worker running environment, which is isolated from the host-thread environment 109561847f8eSopenharmony_ci * @typedef ThreadWorkerGlobalScope 109661847f8eSopenharmony_ci * @extends GlobalScope 109761847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 109861847f8eSopenharmony_ci * @crossplatform 109961847f8eSopenharmony_ci * @atomicservice 110061847f8eSopenharmony_ci * @since 11 110161847f8eSopenharmony_ci */ 110261847f8eSopenharmony_ciexport interface ThreadWorkerGlobalScope extends GlobalScope { 110361847f8eSopenharmony_ci /** 110461847f8eSopenharmony_ci * The onmessage attribute of parentPort specifies the event handler 110561847f8eSopenharmony_ci * to be called then the worker thread receives a message sent by 110661847f8eSopenharmony_ci * the host thread through worker postMessage. 110761847f8eSopenharmony_ci * The event handler is executed in the worker thread. 110861847f8eSopenharmony_ci * 110961847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types. 111061847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 111161847f8eSopenharmony_ci * @throws { BusinessError } 10200005 - The called API is not supported in the worker thread. 111261847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 111361847f8eSopenharmony_ci * @since 9 111461847f8eSopenharmony_ci */ 111561847f8eSopenharmony_ci /** 111661847f8eSopenharmony_ci * The onmessage attribute of parentPort specifies the event handler 111761847f8eSopenharmony_ci * to be called then the worker thread receives a message sent by 111861847f8eSopenharmony_ci * the host thread through worker postMessage. 111961847f8eSopenharmony_ci * The event handler is executed in the worker thread. 112061847f8eSopenharmony_ci * 112161847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types. 112261847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 112361847f8eSopenharmony_ci * @throws { BusinessError } 10200005 - The called API is not supported in the worker thread. 112461847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 112561847f8eSopenharmony_ci * @crossplatform 112661847f8eSopenharmony_ci * @since 10 112761847f8eSopenharmony_ci */ 112861847f8eSopenharmony_ci /** 112961847f8eSopenharmony_ci * The onmessage attribute of parentPort specifies the event handler 113061847f8eSopenharmony_ci * to be called then the worker thread receives a message sent by 113161847f8eSopenharmony_ci * the host thread through worker postMessage. 113261847f8eSopenharmony_ci * The event handler is executed in the worker thread. 113361847f8eSopenharmony_ci * 113461847f8eSopenharmony_ci * @type { ?function } 113561847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types. 113661847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 113761847f8eSopenharmony_ci * @throws { BusinessError } 10200005 - The called API is not supported in the worker thread. 113861847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 113961847f8eSopenharmony_ci * @crossplatform 114061847f8eSopenharmony_ci * @atomicservice 114161847f8eSopenharmony_ci * @since 11 114261847f8eSopenharmony_ci */ 114361847f8eSopenharmony_ci onmessage?: (this: ThreadWorkerGlobalScope, ev: MessageEvents) => void; 114461847f8eSopenharmony_ci 114561847f8eSopenharmony_ci /** 114661847f8eSopenharmony_ci * The onmessage attribute of parentPort specifies the event handler 114761847f8eSopenharmony_ci * to be called then the worker receives a message that cannot be deserialized. 114861847f8eSopenharmony_ci * The event handler is executed in the worker thread. 114961847f8eSopenharmony_ci * 115061847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types. 115161847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 115261847f8eSopenharmony_ci * @throws { BusinessError } 10200005 - The called API is not supported in the worker thread. 115361847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 115461847f8eSopenharmony_ci * @since 9 115561847f8eSopenharmony_ci */ 115661847f8eSopenharmony_ci /** 115761847f8eSopenharmony_ci * The onmessage attribute of parentPort specifies the event handler 115861847f8eSopenharmony_ci * to be called then the worker receives a message that cannot be deserialized. 115961847f8eSopenharmony_ci * The event handler is executed in the worker thread. 116061847f8eSopenharmony_ci * 116161847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types. 116261847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 116361847f8eSopenharmony_ci * @throws { BusinessError } 10200005 - The called API is not supported in the worker thread. 116461847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 116561847f8eSopenharmony_ci * @crossplatform 116661847f8eSopenharmony_ci * @since 10 116761847f8eSopenharmony_ci */ 116861847f8eSopenharmony_ci /** 116961847f8eSopenharmony_ci * The onmessage attribute of parentPort specifies the event handler 117061847f8eSopenharmony_ci * to be called then the worker receives a message that cannot be deserialized. 117161847f8eSopenharmony_ci * The event handler is executed in the worker thread. 117261847f8eSopenharmony_ci * 117361847f8eSopenharmony_ci * @type { ?function } 117461847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types. 117561847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 117661847f8eSopenharmony_ci * @throws { BusinessError } 10200005 - The called API is not supported in the worker thread. 117761847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 117861847f8eSopenharmony_ci * @crossplatform 117961847f8eSopenharmony_ci * @atomicservice 118061847f8eSopenharmony_ci * @since 11 118161847f8eSopenharmony_ci */ 118261847f8eSopenharmony_ci onmessageerror?: (this: ThreadWorkerGlobalScope, ev: MessageEvents) => void; 118361847f8eSopenharmony_ci 118461847f8eSopenharmony_ci /** 118561847f8eSopenharmony_ci * Close the worker thread to stop the worker from receiving messages 118661847f8eSopenharmony_ci * 118761847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 118861847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 118961847f8eSopenharmony_ci * @since 9 119061847f8eSopenharmony_ci */ 119161847f8eSopenharmony_ci /** 119261847f8eSopenharmony_ci * Close the worker thread to stop the worker from receiving messages 119361847f8eSopenharmony_ci * 119461847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 119561847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 119661847f8eSopenharmony_ci * @crossplatform 119761847f8eSopenharmony_ci * @since 10 119861847f8eSopenharmony_ci */ 119961847f8eSopenharmony_ci /** 120061847f8eSopenharmony_ci * Close the worker thread to stop the worker from receiving messages 120161847f8eSopenharmony_ci * 120261847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 120361847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 120461847f8eSopenharmony_ci * @crossplatform 120561847f8eSopenharmony_ci * @atomicservice 120661847f8eSopenharmony_ci * @since 11 120761847f8eSopenharmony_ci */ 120861847f8eSopenharmony_ci close(): void; 120961847f8eSopenharmony_ci 121061847f8eSopenharmony_ci /** 121161847f8eSopenharmony_ci * Send a message to host thread from the worker 121261847f8eSopenharmony_ci * 121361847f8eSopenharmony_ci * @param { Object } messageObject - messageObject Data to be sent to the worker 121461847f8eSopenharmony_ci * @param { ArrayBuffer[] } transfer - transfer array cannot contain null. 121561847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 121661847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 121761847f8eSopenharmony_ci * 2.Incorrect parameter types; 121861847f8eSopenharmony_ci * 3.Parameter verification failed. 121961847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 122061847f8eSopenharmony_ci * @throws { BusinessError } 10200006 - An exception occurred during serialization. 122161847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 122261847f8eSopenharmony_ci * @since 9 122361847f8eSopenharmony_ci */ 122461847f8eSopenharmony_ci /** 122561847f8eSopenharmony_ci * Send a message to host thread from the worker 122661847f8eSopenharmony_ci * 122761847f8eSopenharmony_ci * @param { Object } messageObject - messageObject Data to be sent to the worker 122861847f8eSopenharmony_ci * @param { ArrayBuffer[] } transfer - transfer array cannot contain null. 122961847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 123061847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 123161847f8eSopenharmony_ci * 2.Incorrect parameter types; 123261847f8eSopenharmony_ci * 3.Parameter verification failed. 123361847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 123461847f8eSopenharmony_ci * @throws { BusinessError } 10200006 - An exception occurred during serialization. 123561847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 123661847f8eSopenharmony_ci * @crossplatform 123761847f8eSopenharmony_ci * @since 10 123861847f8eSopenharmony_ci */ 123961847f8eSopenharmony_ci /** 124061847f8eSopenharmony_ci * Send a message to host thread from the worker 124161847f8eSopenharmony_ci * 124261847f8eSopenharmony_ci * @param { Object } messageObject - messageObject Data to be sent to the worker 124361847f8eSopenharmony_ci * @param { ArrayBuffer[] } transfer - transfer array cannot contain null. 124461847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 124561847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 124661847f8eSopenharmony_ci * 2.Incorrect parameter types; 124761847f8eSopenharmony_ci * 3.Parameter verification failed. 124861847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 124961847f8eSopenharmony_ci * @throws { BusinessError } 10200006 - An exception occurred during serialization. 125061847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 125161847f8eSopenharmony_ci * @crossplatform 125261847f8eSopenharmony_ci * @atomicservice 125361847f8eSopenharmony_ci * @since 11 125461847f8eSopenharmony_ci */ 125561847f8eSopenharmony_ci postMessage(messageObject: Object, transfer: ArrayBuffer[]): void; 125661847f8eSopenharmony_ci 125761847f8eSopenharmony_ci /** 125861847f8eSopenharmony_ci * Send a message to be host thread from the worker 125961847f8eSopenharmony_ci * 126061847f8eSopenharmony_ci * @param { Object } messageObject - messageObject Data to be sent to the worker 126161847f8eSopenharmony_ci * @param { PostMessageOptions } [options] - options Option can be set for postmessage. 126261847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 126361847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 126461847f8eSopenharmony_ci * 2.Incorrect parameter types; 126561847f8eSopenharmony_ci * 3.Parameter verification failed. 126661847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 126761847f8eSopenharmony_ci * @throws { BusinessError } 10200006 - An exception occurred during serialization. 126861847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 126961847f8eSopenharmony_ci * @since 9 127061847f8eSopenharmony_ci */ 127161847f8eSopenharmony_ci /** 127261847f8eSopenharmony_ci * Send a message to be host thread from the worker 127361847f8eSopenharmony_ci * 127461847f8eSopenharmony_ci * @param { Object } messageObject - messageObject Data to be sent to the worker 127561847f8eSopenharmony_ci * @param { PostMessageOptions } [options] - options Option can be set for postmessage. 127661847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 127761847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 127861847f8eSopenharmony_ci * 2.Incorrect parameter types; 127961847f8eSopenharmony_ci * 3.Parameter verification failed. 128061847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 128161847f8eSopenharmony_ci * @throws { BusinessError } 10200006 - An exception occurred during serialization. 128261847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 128361847f8eSopenharmony_ci * @crossplatform 128461847f8eSopenharmony_ci * @since 10 128561847f8eSopenharmony_ci */ 128661847f8eSopenharmony_ci /** 128761847f8eSopenharmony_ci * Send a message to be host thread from the worker 128861847f8eSopenharmony_ci * 128961847f8eSopenharmony_ci * @param { Object } messageObject - messageObject Data to be sent to the worker 129061847f8eSopenharmony_ci * @param { PostMessageOptions } [options] - options Option can be set for postmessage. 129161847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 129261847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 129361847f8eSopenharmony_ci * 2.Incorrect parameter types; 129461847f8eSopenharmony_ci * 3.Parameter verification failed. 129561847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 129661847f8eSopenharmony_ci * @throws { BusinessError } 10200006 - An exception occurred during serialization. 129761847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 129861847f8eSopenharmony_ci * @crossplatform 129961847f8eSopenharmony_ci * @atomicservice 130061847f8eSopenharmony_ci * @since 11 130161847f8eSopenharmony_ci */ 130261847f8eSopenharmony_ci postMessage(messageObject: Object, options?: PostMessageOptions): void; 130361847f8eSopenharmony_ci 130461847f8eSopenharmony_ci /** 130561847f8eSopenharmony_ci * Send a message to the host thread from the worker thread. 130661847f8eSopenharmony_ci * If there're sendable objects included in the message, they will be passed through references. 130761847f8eSopenharmony_ci * Non-sendable objects are passed through serialization. 130861847f8eSopenharmony_ci * 130961847f8eSopenharmony_ci * @param { Object } message - Data to be sent to the worker thread. 131061847f8eSopenharmony_ci * @param { ArrayBuffer[] } [transfer] - ArrayBuffer instance that can be transferred. 131161847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 131261847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 131361847f8eSopenharmony_ci * 2.Incorrect parameter types; 131461847f8eSopenharmony_ci * 3.Parameter verification failed. 131561847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 131661847f8eSopenharmony_ci * @throws { BusinessError } 10200006 - An exception occurred during serialization. 131761847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 131861847f8eSopenharmony_ci * @crossplatform 131961847f8eSopenharmony_ci * @atomicservice 132061847f8eSopenharmony_ci * @since 12 132161847f8eSopenharmony_ci */ 132261847f8eSopenharmony_ci postMessageWithSharedSendable(message: Object, transfer?: ArrayBuffer[]): void; 132361847f8eSopenharmony_ci 132461847f8eSopenharmony_ci /** 132561847f8eSopenharmony_ci * Send a global call on registered globalCallObject on host side and return the result synchronously 132661847f8eSopenharmony_ci * 132761847f8eSopenharmony_ci * @param { string } instanceName - the exact key used in registration 132861847f8eSopenharmony_ci * @param { string } methodName - a string which is same to the method called on globalCallObject. 132961847f8eSopenharmony_ci * @param { number } timeout - the specific milliseconds that will wait for result to return, between 0 and 5000. 133061847f8eSopenharmony_ci * @param { Object[] } args - the method argument called on registered globalCallObject. 133161847f8eSopenharmony_ci * @returns { Object } Return the result of method if it has a return value, otherwise return void. 133261847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 133361847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 133461847f8eSopenharmony_ci * 2.Incorrect parameter types; 133561847f8eSopenharmony_ci * 3.Parameter verification failed. 133661847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 133761847f8eSopenharmony_ci * @throws { BusinessError } 10200006 - An exception occurred during serialization. 133861847f8eSopenharmony_ci * @throws { BusinessError } 10200019 - The globalCallObject is not registered. 133961847f8eSopenharmony_ci * @throws { BusinessError } 10200020 - The method to be called is not callable or is an async method or a generator. 134061847f8eSopenharmony_ci * @throws { BusinessError } 10200021 - Waiting for a global call timed out. 134161847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 134261847f8eSopenharmony_ci * @crossplatform 134361847f8eSopenharmony_ci * @since 11 134461847f8eSopenharmony_ci */ 134561847f8eSopenharmony_ci /** 134661847f8eSopenharmony_ci * Send a global call on registered globalCallObject on host side and return the result synchronously 134761847f8eSopenharmony_ci * 134861847f8eSopenharmony_ci * @param { string } instanceName - the exact key used in registration 134961847f8eSopenharmony_ci * @param { string } methodName - a string which is same to the method called on globalCallObject. 135061847f8eSopenharmony_ci * @param { number } timeout - the specific milliseconds that will wait for result to return, between 0 and 5000. 135161847f8eSopenharmony_ci * @param { Object[] } args - the method argument called on registered globalCallObject. 135261847f8eSopenharmony_ci * @returns { Object } Return the result of method if it has a return value, otherwise return void. 135361847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 135461847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 135561847f8eSopenharmony_ci * 2.Incorrect parameter types; 135661847f8eSopenharmony_ci * 3.Parameter verification failed. 135761847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - Worker instance is not running. 135861847f8eSopenharmony_ci * @throws { BusinessError } 10200006 - An exception occurred during serialization. 135961847f8eSopenharmony_ci * @throws { BusinessError } 10200019 - The globalCallObject is not registered. 136061847f8eSopenharmony_ci * @throws { BusinessError } 10200020 - The method to be called is not callable or is an async method or a generator. 136161847f8eSopenharmony_ci * @throws { BusinessError } 10200021 - The global call exceeds the timeout. 136261847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 136361847f8eSopenharmony_ci * @crossplatform 136461847f8eSopenharmony_ci * @atomicservice 136561847f8eSopenharmony_ci * @since 12 136661847f8eSopenharmony_ci */ 136761847f8eSopenharmony_ci callGlobalCallObjectMethod(instanceName: string, methodName: string, timeout: number, ...args: Object[]): Object; 136861847f8eSopenharmony_ci} 136961847f8eSopenharmony_ci 137061847f8eSopenharmony_ci/** 137161847f8eSopenharmony_ci * JS cross-thread communication tool 137261847f8eSopenharmony_ci * 137361847f8eSopenharmony_ci * @namespace worker 137461847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 137561847f8eSopenharmony_ci * @since 7 137661847f8eSopenharmony_ci */ 137761847f8eSopenharmony_ci/** 137861847f8eSopenharmony_ci * JS cross-thread communication tool 137961847f8eSopenharmony_ci * 138061847f8eSopenharmony_ci * @namespace worker 138161847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 138261847f8eSopenharmony_ci * @crossplatform 138361847f8eSopenharmony_ci * @since 10 138461847f8eSopenharmony_ci */ 138561847f8eSopenharmony_ci/** 138661847f8eSopenharmony_ci * JS cross-thread communication tool 138761847f8eSopenharmony_ci * 138861847f8eSopenharmony_ci * @namespace worker 138961847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 139061847f8eSopenharmony_ci * @crossplatform 139161847f8eSopenharmony_ci * @atomicservice 139261847f8eSopenharmony_ci * @since 11 139361847f8eSopenharmony_ci */ 139461847f8eSopenharmony_cideclare namespace worker { 139561847f8eSopenharmony_ci /** 139661847f8eSopenharmony_ci * The ThreadWorker class contains all Worker functions. 139761847f8eSopenharmony_ci * 139861847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 139961847f8eSopenharmony_ci * @since 9 140061847f8eSopenharmony_ci */ 140161847f8eSopenharmony_ci /** 140261847f8eSopenharmony_ci * The ThreadWorker class contains all Worker functions. 140361847f8eSopenharmony_ci * 140461847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 140561847f8eSopenharmony_ci * @crossplatform 140661847f8eSopenharmony_ci * @since 10 140761847f8eSopenharmony_ci */ 140861847f8eSopenharmony_ci /** 140961847f8eSopenharmony_ci * The ThreadWorker class contains all Worker functions. 141061847f8eSopenharmony_ci * 141161847f8eSopenharmony_ci * @implements WorkerEventTarget 141261847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 141361847f8eSopenharmony_ci * @crossplatform 141461847f8eSopenharmony_ci * @atomicservice 141561847f8eSopenharmony_ci * @since 11 141661847f8eSopenharmony_ci */ 141761847f8eSopenharmony_ci class ThreadWorker implements WorkerEventTarget { 141861847f8eSopenharmony_ci /** 141961847f8eSopenharmony_ci * Creates a worker instance 142061847f8eSopenharmony_ci * 142161847f8eSopenharmony_ci * @param { string } scriptURL - scriptURL URL of the script to be executed by the worker 142261847f8eSopenharmony_ci * @param { WorkerOptions } [options] - options Options that can be set for the worker 142361847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 142461847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 142561847f8eSopenharmony_ci * 2.Incorrect parameter types; 142661847f8eSopenharmony_ci * 3.Parameter verification failed. 142761847f8eSopenharmony_ci * @throws { BusinessError } 10200003 - Worker initialization failed. 142861847f8eSopenharmony_ci * @throws { BusinessError } 10200007 - The worker file path is invalid. 142961847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 143061847f8eSopenharmony_ci * @since 9 143161847f8eSopenharmony_ci */ 143261847f8eSopenharmony_ci /** 143361847f8eSopenharmony_ci * Creates a worker instance 143461847f8eSopenharmony_ci * 143561847f8eSopenharmony_ci * @param { string } scriptURL - scriptURL URL of the script to be executed by the worker 143661847f8eSopenharmony_ci * @param { WorkerOptions } [options] - options Options that can be set for the worker 143761847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 143861847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 143961847f8eSopenharmony_ci * 2.Incorrect parameter types; 144061847f8eSopenharmony_ci * 3.Parameter verification failed. 144161847f8eSopenharmony_ci * @throws { BusinessError } 10200003 - Worker initialization failed. 144261847f8eSopenharmony_ci * @throws { BusinessError } 10200007 - The worker file path is invalid. 144361847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 144461847f8eSopenharmony_ci * @crossplatform 144561847f8eSopenharmony_ci * @since 10 144661847f8eSopenharmony_ci */ 144761847f8eSopenharmony_ci /** 144861847f8eSopenharmony_ci * Creates a worker instance 144961847f8eSopenharmony_ci * 145061847f8eSopenharmony_ci * @param { string } scriptURL - scriptURL URL of the script to be executed by the worker 145161847f8eSopenharmony_ci * @param { WorkerOptions } [options] - options Options that can be set for the worker 145261847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 145361847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 145461847f8eSopenharmony_ci * 2.Incorrect parameter types; 145561847f8eSopenharmony_ci * 3.Parameter verification failed. 145661847f8eSopenharmony_ci * @throws { BusinessError } 10200003 - Worker initialization failed. 145761847f8eSopenharmony_ci * @throws { BusinessError } 10200007 - The worker file path is invalid. 145861847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 145961847f8eSopenharmony_ci * @crossplatform 146061847f8eSopenharmony_ci * @atomicservice 146161847f8eSopenharmony_ci * @since 11 146261847f8eSopenharmony_ci */ 146361847f8eSopenharmony_ci constructor(scriptURL: string, options?: WorkerOptions); 146461847f8eSopenharmony_ci /** 146561847f8eSopenharmony_ci * The onexit attribute of the worker specifies the event handler to be called 146661847f8eSopenharmony_ci * when the worker exits. The handler is executed in the host thread. 146761847f8eSopenharmony_ci * 146861847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types. 146961847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 147061847f8eSopenharmony_ci * @throws { BusinessError } 10200005 - The called API is not supported in the worker thread. 147161847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 147261847f8eSopenharmony_ci * @since 9 147361847f8eSopenharmony_ci */ 147461847f8eSopenharmony_ci /** 147561847f8eSopenharmony_ci * The onexit attribute of the worker specifies the event handler to be called 147661847f8eSopenharmony_ci * when the worker exits. The handler is executed in the host thread. 147761847f8eSopenharmony_ci * 147861847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types. 147961847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 148061847f8eSopenharmony_ci * @throws { BusinessError } 10200005 - The called API is not supported in the worker thread. 148161847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 148261847f8eSopenharmony_ci * @crossplatform 148361847f8eSopenharmony_ci * @since 10 148461847f8eSopenharmony_ci */ 148561847f8eSopenharmony_ci /** 148661847f8eSopenharmony_ci * The onexit attribute of the worker specifies the event handler to be called 148761847f8eSopenharmony_ci * when the worker exits. The handler is executed in the host thread. 148861847f8eSopenharmony_ci * 148961847f8eSopenharmony_ci * @type { ?function } 149061847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types. 149161847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 149261847f8eSopenharmony_ci * @throws { BusinessError } 10200005 - The called API is not supported in the worker thread. 149361847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 149461847f8eSopenharmony_ci * @crossplatform 149561847f8eSopenharmony_ci * @atomicservice 149661847f8eSopenharmony_ci * @since 11 149761847f8eSopenharmony_ci */ 149861847f8eSopenharmony_ci onexit?: (code: number) => void; 149961847f8eSopenharmony_ci /** 150061847f8eSopenharmony_ci * The onerror attribute of the worker specifies the event handler to be called 150161847f8eSopenharmony_ci * when an exception occurs during worker execution. 150261847f8eSopenharmony_ci * The event handler is executed in the host thread. 150361847f8eSopenharmony_ci * 150461847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types. 150561847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 150661847f8eSopenharmony_ci * @throws { BusinessError } 10200005 - The called API is not supported in the worker thread. 150761847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 150861847f8eSopenharmony_ci * @since 9 150961847f8eSopenharmony_ci */ 151061847f8eSopenharmony_ci /** 151161847f8eSopenharmony_ci * The onerror attribute of the worker specifies the event handler to be called 151261847f8eSopenharmony_ci * when an exception occurs during worker execution. 151361847f8eSopenharmony_ci * The event handler is executed in the host thread. 151461847f8eSopenharmony_ci * 151561847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types. 151661847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 151761847f8eSopenharmony_ci * @throws { BusinessError } 10200005 - The called API is not supported in the worker thread. 151861847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 151961847f8eSopenharmony_ci * @crossplatform 152061847f8eSopenharmony_ci * @since 10 152161847f8eSopenharmony_ci */ 152261847f8eSopenharmony_ci /** 152361847f8eSopenharmony_ci * The onerror attribute of the worker specifies the event handler to be called 152461847f8eSopenharmony_ci * when an exception occurs during worker execution. 152561847f8eSopenharmony_ci * The event handler is executed in the host thread. 152661847f8eSopenharmony_ci * 152761847f8eSopenharmony_ci * @type { ?function } 152861847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types. 152961847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 153061847f8eSopenharmony_ci * @throws { BusinessError } 10200005 - The called API is not supported in the worker thread. 153161847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 153261847f8eSopenharmony_ci * @crossplatform 153361847f8eSopenharmony_ci * @atomicservice 153461847f8eSopenharmony_ci * @since 11 153561847f8eSopenharmony_ci */ 153661847f8eSopenharmony_ci onerror?: (err: ErrorEvent) => void; 153761847f8eSopenharmony_ci /** 153861847f8eSopenharmony_ci * The onmessage attribute of the worker specifies the event handler 153961847f8eSopenharmony_ci * to be called then the host thread receives a message created by itself 154061847f8eSopenharmony_ci * and sent by the worker through the parentPort.postMessage. 154161847f8eSopenharmony_ci * The event handler is executed in the host thread. 154261847f8eSopenharmony_ci * 154361847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types. 154461847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 154561847f8eSopenharmony_ci * @throws { BusinessError } 10200005 - The called API is not supported in the worker thread. 154661847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 154761847f8eSopenharmony_ci * @since 9 154861847f8eSopenharmony_ci */ 154961847f8eSopenharmony_ci /** 155061847f8eSopenharmony_ci * The onmessage attribute of the worker specifies the event handler 155161847f8eSopenharmony_ci * to be called then the host thread receives a message created by itself 155261847f8eSopenharmony_ci * and sent by the worker through the parentPort.postMessage. 155361847f8eSopenharmony_ci * The event handler is executed in the host thread. 155461847f8eSopenharmony_ci * 155561847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types. 155661847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 155761847f8eSopenharmony_ci * @throws { BusinessError } 10200005 - The called API is not supported in the worker thread. 155861847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 155961847f8eSopenharmony_ci * @crossplatform 156061847f8eSopenharmony_ci * @since 10 156161847f8eSopenharmony_ci */ 156261847f8eSopenharmony_ci /** 156361847f8eSopenharmony_ci * The onmessage attribute of the worker specifies the event handler 156461847f8eSopenharmony_ci * to be called then the host thread receives a message created by itself 156561847f8eSopenharmony_ci * and sent by the worker through the parentPort.postMessage. 156661847f8eSopenharmony_ci * The event handler is executed in the host thread. 156761847f8eSopenharmony_ci * 156861847f8eSopenharmony_ci * @type { ?function } 156961847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types. 157061847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 157161847f8eSopenharmony_ci * @throws { BusinessError } 10200005 - The called API is not supported in the worker thread. 157261847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 157361847f8eSopenharmony_ci * @crossplatform 157461847f8eSopenharmony_ci * @atomicservice 157561847f8eSopenharmony_ci * @since 11 157661847f8eSopenharmony_ci */ 157761847f8eSopenharmony_ci onmessage?: (event: MessageEvents) => void; 157861847f8eSopenharmony_ci /** 157961847f8eSopenharmony_ci * The onmessage attribute of the worker specifies the event handler 158061847f8eSopenharmony_ci * when the worker receives a message that cannot be serialized. 158161847f8eSopenharmony_ci * The event handler is executed in the host thread. 158261847f8eSopenharmony_ci * 158361847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types. 158461847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 158561847f8eSopenharmony_ci * @throws { BusinessError } 10200005 - The called API is not supported in the worker thread. 158661847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 158761847f8eSopenharmony_ci * @since 9 158861847f8eSopenharmony_ci */ 158961847f8eSopenharmony_ci /** 159061847f8eSopenharmony_ci * The onmessage attribute of the worker specifies the event handler 159161847f8eSopenharmony_ci * when the worker receives a message that cannot be serialized. 159261847f8eSopenharmony_ci * The event handler is executed in the host thread. 159361847f8eSopenharmony_ci * 159461847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types. 159561847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 159661847f8eSopenharmony_ci * @throws { BusinessError } 10200005 - The called API is not supported in the worker thread. 159761847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 159861847f8eSopenharmony_ci * @crossplatform 159961847f8eSopenharmony_ci * @since 10 160061847f8eSopenharmony_ci */ 160161847f8eSopenharmony_ci /** 160261847f8eSopenharmony_ci * The onmessage attribute of the worker specifies the event handler 160361847f8eSopenharmony_ci * when the worker receives a message that cannot be serialized. 160461847f8eSopenharmony_ci * The event handler is executed in the host thread. 160561847f8eSopenharmony_ci * 160661847f8eSopenharmony_ci * @type { ?function } 160761847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types. 160861847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 160961847f8eSopenharmony_ci * @throws { BusinessError } 10200005 - The called API is not supported in the worker thread. 161061847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 161161847f8eSopenharmony_ci * @crossplatform 161261847f8eSopenharmony_ci * @atomicservice 161361847f8eSopenharmony_ci * @since 11 161461847f8eSopenharmony_ci */ 161561847f8eSopenharmony_ci onmessageerror?: (event: MessageEvents) => void; 161661847f8eSopenharmony_ci /** 161761847f8eSopenharmony_ci * Sends a message to the worker thread. 161861847f8eSopenharmony_ci * The data is transferred using the structured clone algorithm. 161961847f8eSopenharmony_ci * 162061847f8eSopenharmony_ci * @param { Object } message - message Data to be sent to the worker 162161847f8eSopenharmony_ci * @param { ArrayBuffer[] } transfer - transfer ArrayBuffer instance that can be transferred. 162261847f8eSopenharmony_ci * The transferList array cannot contain null. 162361847f8eSopenharmony_ci * @throws { BusinessError } 401 - if the input parameters are invalid. 162461847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 162561847f8eSopenharmony_ci * @throws { BusinessError } 10200006 - An exception occurred during serialization. 162661847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 162761847f8eSopenharmony_ci * @since 9 162861847f8eSopenharmony_ci */ 162961847f8eSopenharmony_ci /** 163061847f8eSopenharmony_ci * Sends a message to the worker thread. 163161847f8eSopenharmony_ci * The data is transferred using the structured clone algorithm. 163261847f8eSopenharmony_ci * 163361847f8eSopenharmony_ci * @param { Object } message - message Data to be sent to the worker 163461847f8eSopenharmony_ci * @param { ArrayBuffer[] } transfer - transfer ArrayBuffer instance that can be transferred. 163561847f8eSopenharmony_ci * The transferList array cannot contain null. 163661847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 163761847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 163861847f8eSopenharmony_ci * 2.Incorrect parameter types; 163961847f8eSopenharmony_ci * 3.Parameter verification failed. 164061847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 164161847f8eSopenharmony_ci * @throws { BusinessError } 10200006 - An exception occurred during serialization. 164261847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 164361847f8eSopenharmony_ci * @crossplatform 164461847f8eSopenharmony_ci * @since 10 164561847f8eSopenharmony_ci */ 164661847f8eSopenharmony_ci /** 164761847f8eSopenharmony_ci * Sends a message to the worker thread. 164861847f8eSopenharmony_ci * The data is transferred using the structured clone algorithm. 164961847f8eSopenharmony_ci * 165061847f8eSopenharmony_ci * @param { Object } message - message Data to be sent to the worker 165161847f8eSopenharmony_ci * @param { ArrayBuffer[] } transfer - transfer ArrayBuffer instance that can be transferred. 165261847f8eSopenharmony_ci * The transferList array cannot contain null. 165361847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 165461847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 165561847f8eSopenharmony_ci * 2.Incorrect parameter types; 165661847f8eSopenharmony_ci * 3.Parameter verification failed. 165761847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 165861847f8eSopenharmony_ci * @throws { BusinessError } 10200006 - An exception occurred during serialization. 165961847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 166061847f8eSopenharmony_ci * @crossplatform 166161847f8eSopenharmony_ci * @atomicservice 166261847f8eSopenharmony_ci * @since 11 166361847f8eSopenharmony_ci */ 166461847f8eSopenharmony_ci postMessage(message: Object, transfer: ArrayBuffer[]): void; 166561847f8eSopenharmony_ci /** 166661847f8eSopenharmony_ci * Sends a message to the worker thread. 166761847f8eSopenharmony_ci * The data is transferred using the structured clone algorithm. 166861847f8eSopenharmony_ci * 166961847f8eSopenharmony_ci * @param { Object } message - message Data to be sent to the worker 167061847f8eSopenharmony_ci * @param { PostMessageOptions } [options] - options 167161847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 167261847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 167361847f8eSopenharmony_ci * 2.Incorrect parameter types; 167461847f8eSopenharmony_ci * 3.Parameter verification failed. 167561847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 167661847f8eSopenharmony_ci * @throws { BusinessError } 10200006 - An exception occurred during serialization. 167761847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 167861847f8eSopenharmony_ci * @since 9 167961847f8eSopenharmony_ci */ 168061847f8eSopenharmony_ci /** 168161847f8eSopenharmony_ci * Sends a message to the worker thread. 168261847f8eSopenharmony_ci * The data is transferred using the structured clone algorithm. 168361847f8eSopenharmony_ci * 168461847f8eSopenharmony_ci * @param { Object } message - message Data to be sent to the worker 168561847f8eSopenharmony_ci * @param { PostMessageOptions } [options] - options 168661847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 168761847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 168861847f8eSopenharmony_ci * 2.Incorrect parameter types; 168961847f8eSopenharmony_ci * 3.Parameter verification failed. 169061847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 169161847f8eSopenharmony_ci * @throws { BusinessError } 10200006 - An exception occurred during serialization. 169261847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 169361847f8eSopenharmony_ci * @crossplatform 169461847f8eSopenharmony_ci * @since 10 169561847f8eSopenharmony_ci */ 169661847f8eSopenharmony_ci /** 169761847f8eSopenharmony_ci * Sends a message to the worker thread. 169861847f8eSopenharmony_ci * The data is transferred using the structured clone algorithm. 169961847f8eSopenharmony_ci * 170061847f8eSopenharmony_ci * @param { Object } message - message Data to be sent to the worker 170161847f8eSopenharmony_ci * @param { PostMessageOptions } [options] - options 170261847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 170361847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 170461847f8eSopenharmony_ci * 2.Incorrect parameter types; 170561847f8eSopenharmony_ci * 3.Parameter verification failed. 170661847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 170761847f8eSopenharmony_ci * @throws { BusinessError } 10200006 - An exception occurred during serialization. 170861847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 170961847f8eSopenharmony_ci * @crossplatform 171061847f8eSopenharmony_ci * @atomicservice 171161847f8eSopenharmony_ci * @since 11 171261847f8eSopenharmony_ci */ 171361847f8eSopenharmony_ci postMessage(message: Object, options?: PostMessageOptions): void; 171461847f8eSopenharmony_ci 171561847f8eSopenharmony_ci /** 171661847f8eSopenharmony_ci * Sends a message to the worker thread from the host thread. 171761847f8eSopenharmony_ci * If there're sendable objects included in the message, they will be passed through references. 171861847f8eSopenharmony_ci * Non-sendable objects are passed through serialization. 171961847f8eSopenharmony_ci * 172061847f8eSopenharmony_ci * @param { Object } message - Data to be sent to the worker thread. 172161847f8eSopenharmony_ci * @param { ArrayBuffer[] } [transfer] - ArrayBuffer instance that can be transferred. 172261847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 172361847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 172461847f8eSopenharmony_ci * 2.Incorrect parameter types; 172561847f8eSopenharmony_ci * 3.Parameter verification failed. 172661847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 172761847f8eSopenharmony_ci * @throws { BusinessError } 10200006 - An exception occurred during serialization. 172861847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 172961847f8eSopenharmony_ci * @crossplatform 173061847f8eSopenharmony_ci * @atomicservice 173161847f8eSopenharmony_ci * @since 12 173261847f8eSopenharmony_ci */ 173361847f8eSopenharmony_ci postMessageWithSharedSendable(message: Object, transfer?: ArrayBuffer[]): void; 173461847f8eSopenharmony_ci 173561847f8eSopenharmony_ci /** 173661847f8eSopenharmony_ci * Adds an event listener to the worker. 173761847f8eSopenharmony_ci * 173861847f8eSopenharmony_ci * @param { string } type - type Adds an event listener to the worker. 173961847f8eSopenharmony_ci * @param { WorkerEventListener } listener - listener Callback to invoke when an event of the specified type occurs. 174061847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 174161847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 174261847f8eSopenharmony_ci * 2.Incorrect parameter types; 174361847f8eSopenharmony_ci * 3.Parameter verification failed. 174461847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 174561847f8eSopenharmony_ci * @throws { BusinessError } 10200005 - The called API is not supported in the worker thread. 174661847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 174761847f8eSopenharmony_ci * @since 9 174861847f8eSopenharmony_ci */ 174961847f8eSopenharmony_ci /** 175061847f8eSopenharmony_ci * Adds an event listener to the worker. 175161847f8eSopenharmony_ci * 175261847f8eSopenharmony_ci * @param { string } type - type Adds an event listener to the worker. 175361847f8eSopenharmony_ci * @param { WorkerEventListener } listener - listener Callback to invoke when an event of the specified type occurs. 175461847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 175561847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 175661847f8eSopenharmony_ci * 2.Incorrect parameter types; 175761847f8eSopenharmony_ci * 3.Parameter verification failed. 175861847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 175961847f8eSopenharmony_ci * @throws { BusinessError } 10200005 - The called API is not supported in the worker thread. 176061847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 176161847f8eSopenharmony_ci * @crossplatform 176261847f8eSopenharmony_ci * @since 10 176361847f8eSopenharmony_ci */ 176461847f8eSopenharmony_ci /** 176561847f8eSopenharmony_ci * Adds an event listener to the worker. 176661847f8eSopenharmony_ci * 176761847f8eSopenharmony_ci * @param { string } type - type Adds an event listener to the worker. 176861847f8eSopenharmony_ci * @param { WorkerEventListener } listener - listener Callback to invoke when an event of the specified type occurs. 176961847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 177061847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 177161847f8eSopenharmony_ci * 2.Incorrect parameter types; 177261847f8eSopenharmony_ci * 3.Parameter verification failed. 177361847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - Worker instance is not running. 177461847f8eSopenharmony_ci * @throws { BusinessError } 10200005 - The invoked API is not supported in workers. 177561847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 177661847f8eSopenharmony_ci * @crossplatform 177761847f8eSopenharmony_ci * @atomicservice 177861847f8eSopenharmony_ci * @since 12 177961847f8eSopenharmony_ci */ 178061847f8eSopenharmony_ci on(type: string, listener: WorkerEventListener): void; 178161847f8eSopenharmony_ci /** 178261847f8eSopenharmony_ci * Adds an event listener to the worker 178361847f8eSopenharmony_ci * and removes the event listener automatically after it is invoked once. 178461847f8eSopenharmony_ci * 178561847f8eSopenharmony_ci * @param { string } type - type Type of the event to listen for 178661847f8eSopenharmony_ci * @param { WorkerEventListener } listener - listener Callback to invoke when an event of the specified type occurs 178761847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 178861847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 178961847f8eSopenharmony_ci * 2.Incorrect parameter types; 179061847f8eSopenharmony_ci * 3.Parameter verification failed. 179161847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 179261847f8eSopenharmony_ci * @throws { BusinessError } 10200005 - The called API is not supported in the worker thread. 179361847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 179461847f8eSopenharmony_ci * @since 9 179561847f8eSopenharmony_ci */ 179661847f8eSopenharmony_ci /** 179761847f8eSopenharmony_ci * Adds an event listener to the worker 179861847f8eSopenharmony_ci * and removes the event listener automatically after it is invoked once. 179961847f8eSopenharmony_ci * 180061847f8eSopenharmony_ci * @param { string } type - type Type of the event to listen for 180161847f8eSopenharmony_ci * @param { WorkerEventListener } listener - listener Callback to invoke when an event of the specified type occurs 180261847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 180361847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 180461847f8eSopenharmony_ci * 2.Incorrect parameter types; 180561847f8eSopenharmony_ci * 3.Parameter verification failed. 180661847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 180761847f8eSopenharmony_ci * @throws { BusinessError } 10200005 - The called API is not supported in the worker thread. 180861847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 180961847f8eSopenharmony_ci * @crossplatform 181061847f8eSopenharmony_ci * @since 10 181161847f8eSopenharmony_ci */ 181261847f8eSopenharmony_ci /** 181361847f8eSopenharmony_ci * Adds an event listener to the worker 181461847f8eSopenharmony_ci * and removes the event listener automatically after it is invoked once. 181561847f8eSopenharmony_ci * 181661847f8eSopenharmony_ci * @param { string } type - type Type of the event to listen for 181761847f8eSopenharmony_ci * @param { WorkerEventListener } listener - listener Callback to invoke when an event of the specified type occurs 181861847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 181961847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 182061847f8eSopenharmony_ci * 2.Incorrect parameter types; 182161847f8eSopenharmony_ci * 3.Parameter verification failed. 182261847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - Worker instance is not running. 182361847f8eSopenharmony_ci * @throws { BusinessError } 10200005 - The invoked API is not supported in workers. 182461847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 182561847f8eSopenharmony_ci * @crossplatform 182661847f8eSopenharmony_ci * @atomicservice 182761847f8eSopenharmony_ci * @since 12 182861847f8eSopenharmony_ci */ 182961847f8eSopenharmony_ci once(type: string, listener: WorkerEventListener): void; 183061847f8eSopenharmony_ci /** 183161847f8eSopenharmony_ci * Removes an event listener to the worker. 183261847f8eSopenharmony_ci * 183361847f8eSopenharmony_ci * @param { string } type - type Type of the event for which the event listener is removed. 183461847f8eSopenharmony_ci * @param { WorkerEventListener } [listener] - listener Callback of the event listener to remove. 183561847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 183661847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 183761847f8eSopenharmony_ci * 2.Incorrect parameter types; 183861847f8eSopenharmony_ci * 3.Parameter verification failed. 183961847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 184061847f8eSopenharmony_ci * @throws { BusinessError } 10200005 - The called API is not supported in the worker thread. 184161847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 184261847f8eSopenharmony_ci * @since 9 184361847f8eSopenharmony_ci */ 184461847f8eSopenharmony_ci /** 184561847f8eSopenharmony_ci * Removes an event listener to the worker. 184661847f8eSopenharmony_ci * 184761847f8eSopenharmony_ci * @param { string } type - type Type of the event for which the event listener is removed. 184861847f8eSopenharmony_ci * @param { WorkerEventListener } [listener] - listener Callback of the event listener to remove. 184961847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 185061847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 185161847f8eSopenharmony_ci * 2.Incorrect parameter types; 185261847f8eSopenharmony_ci * 3.Parameter verification failed. 185361847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 185461847f8eSopenharmony_ci * @throws { BusinessError } 10200005 - The called API is not supported in the worker thread. 185561847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 185661847f8eSopenharmony_ci * @crossplatform 185761847f8eSopenharmony_ci * @since 10 185861847f8eSopenharmony_ci */ 185961847f8eSopenharmony_ci /** 186061847f8eSopenharmony_ci * Removes an event listener to the worker. 186161847f8eSopenharmony_ci * 186261847f8eSopenharmony_ci * @param { string } type - type Type of the event for which the event listener is removed. 186361847f8eSopenharmony_ci * @param { WorkerEventListener } [listener] - listener Callback of the event listener to remove. 186461847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 186561847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 186661847f8eSopenharmony_ci * 2.Incorrect parameter types; 186761847f8eSopenharmony_ci * 3.Parameter verification failed. 186861847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - Worker instance is not running. 186961847f8eSopenharmony_ci * @throws { BusinessError } 10200005 - The invoked API is not supported in workers. 187061847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 187161847f8eSopenharmony_ci * @crossplatform 187261847f8eSopenharmony_ci * @atomicservice 187361847f8eSopenharmony_ci * @since 12 187461847f8eSopenharmony_ci */ 187561847f8eSopenharmony_ci off(type: string, listener?: WorkerEventListener): void; 187661847f8eSopenharmony_ci /** 187761847f8eSopenharmony_ci * Terminates the worker thread to stop the worker from receiving messages 187861847f8eSopenharmony_ci * 187961847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 188061847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 188161847f8eSopenharmony_ci * @since 9 188261847f8eSopenharmony_ci */ 188361847f8eSopenharmony_ci /** 188461847f8eSopenharmony_ci * Terminates the worker thread to stop the worker from receiving messages 188561847f8eSopenharmony_ci * 188661847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 188761847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 188861847f8eSopenharmony_ci * @crossplatform 188961847f8eSopenharmony_ci * @since 10 189061847f8eSopenharmony_ci */ 189161847f8eSopenharmony_ci /** 189261847f8eSopenharmony_ci * Terminates the worker thread to stop the worker from receiving messages 189361847f8eSopenharmony_ci * 189461847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 189561847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 189661847f8eSopenharmony_ci * @crossplatform 189761847f8eSopenharmony_ci * @atomicservice 189861847f8eSopenharmony_ci * @since 11 189961847f8eSopenharmony_ci */ 190061847f8eSopenharmony_ci terminate(): void; 190161847f8eSopenharmony_ci /** 190261847f8eSopenharmony_ci * Adds an event listener to the worker. 190361847f8eSopenharmony_ci * 190461847f8eSopenharmony_ci * @param { string } type - type Type of the event to listen for. 190561847f8eSopenharmony_ci * @param { WorkerEventListener } listener Callback to invoke when an event of the specified type occurs. 190661847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 190761847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 190861847f8eSopenharmony_ci * 2.Incorrect parameter types; 190961847f8eSopenharmony_ci * 3.Parameter verification failed. 191061847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 191161847f8eSopenharmony_ci * @throws { BusinessError } 10200005 - The called API is not supported in the worker thread. 191261847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 191361847f8eSopenharmony_ci * @since 9 191461847f8eSopenharmony_ci */ 191561847f8eSopenharmony_ci /** 191661847f8eSopenharmony_ci * Adds an event listener to the worker. 191761847f8eSopenharmony_ci * 191861847f8eSopenharmony_ci * @param { string } type - type Type of the event to listen for. 191961847f8eSopenharmony_ci * @param { WorkerEventListener } listener Callback to invoke when an event of the specified type occurs. 192061847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 192161847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 192261847f8eSopenharmony_ci * 2.Incorrect parameter types; 192361847f8eSopenharmony_ci * 3.Parameter verification failed. 192461847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 192561847f8eSopenharmony_ci * @throws { BusinessError } 10200005 - The called API is not supported in the worker thread. 192661847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 192761847f8eSopenharmony_ci * @crossplatform 192861847f8eSopenharmony_ci * @since 10 192961847f8eSopenharmony_ci */ 193061847f8eSopenharmony_ci /** 193161847f8eSopenharmony_ci * Adds an event listener to the worker. 193261847f8eSopenharmony_ci * 193361847f8eSopenharmony_ci * @param { string } type - type Type of the event to listen for. 193461847f8eSopenharmony_ci * @param { WorkerEventListener } listener Callback to invoke when an event of the specified type occurs. 193561847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 193661847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 193761847f8eSopenharmony_ci * 2.Incorrect parameter types; 193861847f8eSopenharmony_ci * 3.Parameter verification failed. 193961847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - Worker instance is not running. 194061847f8eSopenharmony_ci * @throws { BusinessError } 10200005 - The invoked API is not supported in workers. 194161847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 194261847f8eSopenharmony_ci * @crossplatform 194361847f8eSopenharmony_ci * @atomicservice 194461847f8eSopenharmony_ci * @since 12 194561847f8eSopenharmony_ci */ 194661847f8eSopenharmony_ci addEventListener(type: string, listener: WorkerEventListener): void; 194761847f8eSopenharmony_ci /** 194861847f8eSopenharmony_ci * Handle the event defined for the worker. 194961847f8eSopenharmony_ci * 195061847f8eSopenharmony_ci * @param { Event } event - event Event to dispatch. 195161847f8eSopenharmony_ci * @returns { boolean } 195261847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 195361847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 195461847f8eSopenharmony_ci * 2.Incorrect parameter types; 195561847f8eSopenharmony_ci * 3.Parameter verification failed. 195661847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 195761847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 195861847f8eSopenharmony_ci * @since 9 195961847f8eSopenharmony_ci */ 196061847f8eSopenharmony_ci /** 196161847f8eSopenharmony_ci * Handle the event defined for the worker. 196261847f8eSopenharmony_ci * 196361847f8eSopenharmony_ci * @param { Event } event - event Event to dispatch. 196461847f8eSopenharmony_ci * @returns { boolean } 196561847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 196661847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 196761847f8eSopenharmony_ci * 2.Incorrect parameter types; 196861847f8eSopenharmony_ci * 3.Parameter verification failed. 196961847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 197061847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 197161847f8eSopenharmony_ci * @crossplatform 197261847f8eSopenharmony_ci * @since 10 197361847f8eSopenharmony_ci */ 197461847f8eSopenharmony_ci /** 197561847f8eSopenharmony_ci * Handle the event defined for the worker. 197661847f8eSopenharmony_ci * 197761847f8eSopenharmony_ci * @param { Event } event - event Event to dispatch. 197861847f8eSopenharmony_ci * @returns { boolean } 197961847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 198061847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 198161847f8eSopenharmony_ci * 2.Incorrect parameter types; 198261847f8eSopenharmony_ci * 3.Parameter verification failed. 198361847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - Worker instance is not running. 198461847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 198561847f8eSopenharmony_ci * @crossplatform 198661847f8eSopenharmony_ci * @atomicservice 198761847f8eSopenharmony_ci * @since 12 198861847f8eSopenharmony_ci */ 198961847f8eSopenharmony_ci dispatchEvent(event: Event): boolean; 199061847f8eSopenharmony_ci /** 199161847f8eSopenharmony_ci * Remove an event defined for the worker. 199261847f8eSopenharmony_ci * 199361847f8eSopenharmony_ci * @param { string } type - type Type of the event for which the event listener is cancelled. 199461847f8eSopenharmony_ci * @param { WorkerEventListener } [callback] - callback Callback of the event listener to remove. 199561847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 199661847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 199761847f8eSopenharmony_ci * 2.Incorrect parameter types; 199861847f8eSopenharmony_ci * 3.Parameter verification failed. 199961847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 200061847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 200161847f8eSopenharmony_ci * @since 9 200261847f8eSopenharmony_ci */ 200361847f8eSopenharmony_ci /** 200461847f8eSopenharmony_ci * Remove an event defined for the worker. 200561847f8eSopenharmony_ci * 200661847f8eSopenharmony_ci * @param { string } type - type Type of the event for which the event listener is cancelled. 200761847f8eSopenharmony_ci * @param { WorkerEventListener } [callback] - callback Callback of the event listener to remove. 200861847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 200961847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 201061847f8eSopenharmony_ci * 2.Incorrect parameter types; 201161847f8eSopenharmony_ci * 3.Parameter verification failed. 201261847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 201361847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 201461847f8eSopenharmony_ci * @crossplatform 201561847f8eSopenharmony_ci * @since 10 201661847f8eSopenharmony_ci */ 201761847f8eSopenharmony_ci /** 201861847f8eSopenharmony_ci * Remove an event defined for the worker. 201961847f8eSopenharmony_ci * 202061847f8eSopenharmony_ci * @param { string } type - type Type of the event for which the event listener is cancelled. 202161847f8eSopenharmony_ci * @param { WorkerEventListener } [callback] - callback Callback of the event listener to remove. 202261847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 202361847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 202461847f8eSopenharmony_ci * 2.Incorrect parameter types; 202561847f8eSopenharmony_ci * 3.Parameter verification failed. 202661847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - Worker instance is not running. 202761847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 202861847f8eSopenharmony_ci * @crossplatform 202961847f8eSopenharmony_ci * @atomicservice 203061847f8eSopenharmony_ci * @since 12 203161847f8eSopenharmony_ci */ 203261847f8eSopenharmony_ci removeEventListener(type: string, callback?: WorkerEventListener): void; 203361847f8eSopenharmony_ci /** 203461847f8eSopenharmony_ci * Remove all event listeners for the worker. 203561847f8eSopenharmony_ci * 203661847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 203761847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 203861847f8eSopenharmony_ci * @since 9 203961847f8eSopenharmony_ci */ 204061847f8eSopenharmony_ci /** 204161847f8eSopenharmony_ci * Remove all event listeners for the worker. 204261847f8eSopenharmony_ci * 204361847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 204461847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 204561847f8eSopenharmony_ci * @crossplatform 204661847f8eSopenharmony_ci * @since 10 204761847f8eSopenharmony_ci */ 204861847f8eSopenharmony_ci /** 204961847f8eSopenharmony_ci * Remove all event listeners for the worker. 205061847f8eSopenharmony_ci * 205161847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - Worker instance is not running. 205261847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 205361847f8eSopenharmony_ci * @crossplatform 205461847f8eSopenharmony_ci * @atomicservice 205561847f8eSopenharmony_ci * @since 12 205661847f8eSopenharmony_ci */ 205761847f8eSopenharmony_ci removeAllListener(): void; 205861847f8eSopenharmony_ci 205961847f8eSopenharmony_ci /** 206061847f8eSopenharmony_ci * Register globalCallObject for global call. 206161847f8eSopenharmony_ci * @param { string } instanceName - The key to register globalCallObject. 206261847f8eSopenharmony_ci * @param { Object } globalCallObject - The globalCallObject that will be registered. 206361847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 206461847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 206561847f8eSopenharmony_ci * 2.Incorrect parameter types; 206661847f8eSopenharmony_ci * 3.Parameter verification failed. 206761847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 206861847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 206961847f8eSopenharmony_ci * @crossplatform 207061847f8eSopenharmony_ci * @since 11 207161847f8eSopenharmony_ci */ 207261847f8eSopenharmony_ci /** 207361847f8eSopenharmony_ci * Register globalCallObject for global call. 207461847f8eSopenharmony_ci * @param { string } instanceName - The key to register globalCallObject. 207561847f8eSopenharmony_ci * @param { Object } globalCallObject - The globalCallObject that will be registered. 207661847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 207761847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 207861847f8eSopenharmony_ci * 2.Incorrect parameter types; 207961847f8eSopenharmony_ci * 3.Parameter verification failed. 208061847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - Worker instance is not running. 208161847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 208261847f8eSopenharmony_ci * @crossplatform 208361847f8eSopenharmony_ci * @atomicservice 208461847f8eSopenharmony_ci * @since 12 208561847f8eSopenharmony_ci */ 208661847f8eSopenharmony_ci registerGlobalCallObject(instanceName: string, globalCallObject: Object): void; 208761847f8eSopenharmony_ci 208861847f8eSopenharmony_ci /** 208961847f8eSopenharmony_ci * Remove registered globalCallObject and release strong reference to registered object. 209061847f8eSopenharmony_ci * @param { string } [instanceName] - The exact key that used in registration. 209161847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 209261847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 209361847f8eSopenharmony_ci * 2.Incorrect parameter types; 209461847f8eSopenharmony_ci * 3.Parameter verification failed. 209561847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - The Worker instance is not running. 209661847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 209761847f8eSopenharmony_ci * @crossplatform 209861847f8eSopenharmony_ci * @since 11 209961847f8eSopenharmony_ci */ 210061847f8eSopenharmony_ci /** 210161847f8eSopenharmony_ci * Remove registered globalCallObject and release strong reference to registered object. 210261847f8eSopenharmony_ci * @param { string } [instanceName] - The exact key that used in registration. 210361847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 210461847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 210561847f8eSopenharmony_ci * 2.Incorrect parameter types; 210661847f8eSopenharmony_ci * 3.Parameter verification failed. 210761847f8eSopenharmony_ci * @throws { BusinessError } 10200004 - Worker instance is not running. 210861847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 210961847f8eSopenharmony_ci * @crossplatform 211061847f8eSopenharmony_ci * @atomicservice 211161847f8eSopenharmony_ci * @since 12 211261847f8eSopenharmony_ci */ 211361847f8eSopenharmony_ci unregisterGlobalCallObject(instanceName?: string): void; 211461847f8eSopenharmony_ci } 211561847f8eSopenharmony_ci 211661847f8eSopenharmony_ci /** 211761847f8eSopenharmony_ci * The RestrictedWorker class contains all Worker functions. 211861847f8eSopenharmony_ci * 211961847f8eSopenharmony_ci * @extends ThreadWorker 212061847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 212161847f8eSopenharmony_ci * @since 11 212261847f8eSopenharmony_ci */ 212361847f8eSopenharmony_ci /** 212461847f8eSopenharmony_ci * The RestrictedWorker class contains all Worker functions. 212561847f8eSopenharmony_ci * 212661847f8eSopenharmony_ci * @extends ThreadWorker 212761847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 212861847f8eSopenharmony_ci * @systemapi 212961847f8eSopenharmony_ci * @since 12 213061847f8eSopenharmony_ci */ 213161847f8eSopenharmony_ci class RestrictedWorker extends ThreadWorker { 213261847f8eSopenharmony_ci /** 213361847f8eSopenharmony_ci * Creates a worker instance 213461847f8eSopenharmony_ci * 213561847f8eSopenharmony_ci * @param { string } scriptURL - scriptURL URL of the script to be executed by the worker 213661847f8eSopenharmony_ci * @param { WorkerOptions } [options] - options Options that can be set for the worker 213761847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 213861847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 213961847f8eSopenharmony_ci * 2.Incorrect parameter types; 214061847f8eSopenharmony_ci * 3.Parameter verification failed. 214161847f8eSopenharmony_ci * @throws { BusinessError } 10200003 - Worker initialization failed. 214261847f8eSopenharmony_ci * @throws { BusinessError } 10200007 - The worker file path is invalid. 214361847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 214461847f8eSopenharmony_ci * @since 11 214561847f8eSopenharmony_ci */ 214661847f8eSopenharmony_ci /** 214761847f8eSopenharmony_ci * Creates a worker instance 214861847f8eSopenharmony_ci * 214961847f8eSopenharmony_ci * @param { string } scriptURL - scriptURL URL of the script to be executed by the worker 215061847f8eSopenharmony_ci * @param { WorkerOptions } [options] - options Options that can be set for the worker 215161847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 215261847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 215361847f8eSopenharmony_ci * 2.Incorrect parameter types; 215461847f8eSopenharmony_ci * 3.Parameter verification failed. 215561847f8eSopenharmony_ci * @throws { BusinessError } 10200003 - Worker initialization failure. 215661847f8eSopenharmony_ci * @throws { BusinessError } 10200007 - The worker file patch is invalid path. 215761847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 215861847f8eSopenharmony_ci * @systemapi 215961847f8eSopenharmony_ci * @since 12 216061847f8eSopenharmony_ci */ 216161847f8eSopenharmony_ci constructor(scriptURL: string, options?: WorkerOptions); 216261847f8eSopenharmony_ci } 216361847f8eSopenharmony_ci 216461847f8eSopenharmony_ci /** 216561847f8eSopenharmony_ci * The Worker class contains all Worker functions. 216661847f8eSopenharmony_ci * 216761847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 216861847f8eSopenharmony_ci * @since 7 216961847f8eSopenharmony_ci * @deprecated since 9 217061847f8eSopenharmony_ci * @useinstead ohos.worker.ThreadWorker 217161847f8eSopenharmony_ci */ 217261847f8eSopenharmony_ci class Worker implements EventTarget { 217361847f8eSopenharmony_ci /** 217461847f8eSopenharmony_ci * Creates a worker instance 217561847f8eSopenharmony_ci * 217661847f8eSopenharmony_ci * @param { string } scriptURL - scriptURL URL of the script to be executed by the worker 217761847f8eSopenharmony_ci * @param { WorkerOptions } options - options Options that can be set for the worker 217861847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 217961847f8eSopenharmony_ci * @since 7 218061847f8eSopenharmony_ci * @deprecated since 9 218161847f8eSopenharmony_ci * @useinstead ohos.worker.ThreadWorker.constructor 218261847f8eSopenharmony_ci */ 218361847f8eSopenharmony_ci constructor(scriptURL: string, options?: WorkerOptions); 218461847f8eSopenharmony_ci 218561847f8eSopenharmony_ci /** 218661847f8eSopenharmony_ci * The onexit attribute of the worker specifies the event handler to be called 218761847f8eSopenharmony_ci * when the worker exits. The handler is executed in the host thread. 218861847f8eSopenharmony_ci * 218961847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 219061847f8eSopenharmony_ci * @since 7 219161847f8eSopenharmony_ci * @deprecated since 9 219261847f8eSopenharmony_ci * @useinstead ohos.worker.ThreadWorker.onexit 219361847f8eSopenharmony_ci */ 219461847f8eSopenharmony_ci onexit?: (code: number) => void; 219561847f8eSopenharmony_ci 219661847f8eSopenharmony_ci /** 219761847f8eSopenharmony_ci * The onerror attribute of the worker specifies the event handler to be called 219861847f8eSopenharmony_ci * when an exception occurs during worker execution. 219961847f8eSopenharmony_ci * The event handler is executed in the host thread. 220061847f8eSopenharmony_ci * 220161847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 220261847f8eSopenharmony_ci * @since 7 220361847f8eSopenharmony_ci * @deprecated since 9 220461847f8eSopenharmony_ci * @useinstead ohos.worker.ThreadWorker.onerror 220561847f8eSopenharmony_ci */ 220661847f8eSopenharmony_ci onerror?: (err: ErrorEvent) => void; 220761847f8eSopenharmony_ci 220861847f8eSopenharmony_ci /** 220961847f8eSopenharmony_ci * The onmessage attribute of the worker specifies the event handler 221061847f8eSopenharmony_ci * to be called then the host thread receives a message created by itself 221161847f8eSopenharmony_ci * and sent by the worker through the parentPort.postMessage. 221261847f8eSopenharmony_ci * The event handler is executed in the host thread. 221361847f8eSopenharmony_ci * 221461847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 221561847f8eSopenharmony_ci * @since 7 221661847f8eSopenharmony_ci * @deprecated since 9 221761847f8eSopenharmony_ci * @useinstead ohos.worker.ThreadWorker.onmessage 221861847f8eSopenharmony_ci */ 221961847f8eSopenharmony_ci onmessage?: (event: MessageEvent) => void; 222061847f8eSopenharmony_ci 222161847f8eSopenharmony_ci /** 222261847f8eSopenharmony_ci * The onmessage attribute of the worker specifies the event handler 222361847f8eSopenharmony_ci * when the worker receives a message that cannot be serialized. 222461847f8eSopenharmony_ci * The event handler is executed in the host thread. 222561847f8eSopenharmony_ci * 222661847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 222761847f8eSopenharmony_ci * @since 7 222861847f8eSopenharmony_ci * @deprecated since 9 222961847f8eSopenharmony_ci * @useinstead ohos.worker.ThreadWorker.onmessageerror 223061847f8eSopenharmony_ci */ 223161847f8eSopenharmony_ci onmessageerror?: (event: MessageEvent) => void; 223261847f8eSopenharmony_ci 223361847f8eSopenharmony_ci /** 223461847f8eSopenharmony_ci * Sends a message to the worker thread. 223561847f8eSopenharmony_ci * The data is transferred using the structured clone algorithm. 223661847f8eSopenharmony_ci * 223761847f8eSopenharmony_ci * @param { Object } message - message - message Data to be sent to the worker 223861847f8eSopenharmony_ci * @param { ArrayBuffer[] } transfer - transfer ArrayBuffer instance that can be transferred. 223961847f8eSopenharmony_ci * The transferList array cannot contain null. 224061847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 224161847f8eSopenharmony_ci * @since 7 224261847f8eSopenharmony_ci * @deprecated since 9 224361847f8eSopenharmony_ci * @useinstead ohos.worker.ThreadWorker.postMessage 224461847f8eSopenharmony_ci */ 224561847f8eSopenharmony_ci postMessage(message: Object, transfer: ArrayBuffer[]): void; 224661847f8eSopenharmony_ci 224761847f8eSopenharmony_ci /** 224861847f8eSopenharmony_ci * Sends a message to the worker thread. 224961847f8eSopenharmony_ci * The data is transferred using the structured clone algorithm. 225061847f8eSopenharmony_ci * 225161847f8eSopenharmony_ci * @param { Object } message - message - message Data to be sent to the worker 225261847f8eSopenharmony_ci * @param { PostMessageOptions } [options] - options Option can be set for postmessage. 225361847f8eSopenharmony_ci * The transferList array cannot contain null. 225461847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 225561847f8eSopenharmony_ci * @since 7 225661847f8eSopenharmony_ci * @deprecated since 9 225761847f8eSopenharmony_ci * @useinstead ohos.worker.ThreadWorker.postMessage 225861847f8eSopenharmony_ci */ 225961847f8eSopenharmony_ci postMessage(message: Object, options?: PostMessageOptions): void; 226061847f8eSopenharmony_ci 226161847f8eSopenharmony_ci /** 226261847f8eSopenharmony_ci * Adds an event listener to the worker. 226361847f8eSopenharmony_ci * 226461847f8eSopenharmony_ci * @param { string } type - type Adds an event listener to the worker. 226561847f8eSopenharmony_ci * @param { EventListener } listener - listener Callback to invoke when an event of the specified type occurs. 226661847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 226761847f8eSopenharmony_ci * @since 7 226861847f8eSopenharmony_ci * @deprecated since 9 226961847f8eSopenharmony_ci * @useinstead ohos.worker.ThreadWorker.on 227061847f8eSopenharmony_ci */ 227161847f8eSopenharmony_ci on(type: string, listener: EventListener): void; 227261847f8eSopenharmony_ci 227361847f8eSopenharmony_ci /** 227461847f8eSopenharmony_ci * Adds an event listener to the worker 227561847f8eSopenharmony_ci * and removes the event listener automatically after it is invoked once. 227661847f8eSopenharmony_ci * 227761847f8eSopenharmony_ci * @param { string } type - type Type of the event to listen for 227861847f8eSopenharmony_ci * @param { EventListener } listener - listener Callback to invoke when an event of the specified type occurs 227961847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 228061847f8eSopenharmony_ci * @since 7 228161847f8eSopenharmony_ci * @deprecated since 9 228261847f8eSopenharmony_ci * @useinstead ohos.worker.ThreadWorker.once 228361847f8eSopenharmony_ci */ 228461847f8eSopenharmony_ci once(type: string, listener: EventListener): void; 228561847f8eSopenharmony_ci 228661847f8eSopenharmony_ci /** 228761847f8eSopenharmony_ci * Removes an event listener to the worker. 228861847f8eSopenharmony_ci * 228961847f8eSopenharmony_ci * @param { string } type - type Type of the event for which the event listener is removed. 229061847f8eSopenharmony_ci * @param { EventListener } listener - listener Callback of the event listener to remove. 229161847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 229261847f8eSopenharmony_ci * @since 7 229361847f8eSopenharmony_ci * @deprecated since 9 229461847f8eSopenharmony_ci * @useinstead ohos.worker.ThreadWorker.off 229561847f8eSopenharmony_ci */ 229661847f8eSopenharmony_ci off(type: string, listener?: EventListener): void; 229761847f8eSopenharmony_ci 229861847f8eSopenharmony_ci /** 229961847f8eSopenharmony_ci * Terminates the worker thread to stop the worker from receiving messages 230061847f8eSopenharmony_ci * 230161847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 230261847f8eSopenharmony_ci * @since 7 230361847f8eSopenharmony_ci * @deprecated since 9 230461847f8eSopenharmony_ci * @useinstead ohos.worker.ThreadWorker.terminate 230561847f8eSopenharmony_ci */ 230661847f8eSopenharmony_ci terminate(): void; 230761847f8eSopenharmony_ci } 230861847f8eSopenharmony_ci 230961847f8eSopenharmony_ci /** 231061847f8eSopenharmony_ci * The object used by the worker thread to communicate with the host thread. 231161847f8eSopenharmony_ci * 231261847f8eSopenharmony_ci * @constant 231361847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 231461847f8eSopenharmony_ci * @since 7 231561847f8eSopenharmony_ci * @deprecated since 9 231661847f8eSopenharmony_ci * @useinstead ohos.worker.workerPort 231761847f8eSopenharmony_ci */ 231861847f8eSopenharmony_ci const parentPort: DedicatedWorkerGlobalScope; 231961847f8eSopenharmony_ci 232061847f8eSopenharmony_ci /** 232161847f8eSopenharmony_ci * The object used by the worker thread to communicate with the host thread. 232261847f8eSopenharmony_ci * 232361847f8eSopenharmony_ci * @constant 232461847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 232561847f8eSopenharmony_ci * @since 9 232661847f8eSopenharmony_ci */ 232761847f8eSopenharmony_ci /** 232861847f8eSopenharmony_ci * The object used by the worker thread to communicate with the host thread. 232961847f8eSopenharmony_ci * 233061847f8eSopenharmony_ci * @constant 233161847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 233261847f8eSopenharmony_ci * @crossplatform 233361847f8eSopenharmony_ci * @since 10 233461847f8eSopenharmony_ci */ 233561847f8eSopenharmony_ci /** 233661847f8eSopenharmony_ci * The object used by the worker thread to communicate with the host thread. 233761847f8eSopenharmony_ci * 233861847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 233961847f8eSopenharmony_ci * @crossplatform 234061847f8eSopenharmony_ci * @atomicservice 234161847f8eSopenharmony_ci * @since 11 234261847f8eSopenharmony_ci */ 234361847f8eSopenharmony_ci const workerPort: ThreadWorkerGlobalScope; 234461847f8eSopenharmony_ci} 234561847f8eSopenharmony_ciexport default worker; 2346