'use strict'; import type { RemoteFunction, SerializableRef, SynchronizableRef, } from '../memory/types'; import type { WorkletRuntime } from '../types'; /** Type of `__workletsModuleProxy` injected with JSI. */ export interface WorkletsModuleProxy { loadUnpackersWithCode( valueUnpackerCode: string, valueUnpackerLocation: string, valueUnpackerSourceMap: string, synchronizableUnpackerCode: string, synchronizableUnpackerLocation: string, synchronizableUnpackerSourceMap: string, customSerializableUnpackerCode: string, customSerializableUnpackerLocation: string, customSerializableUnpackerSourceMap: string, shareableHostUnpackerCode: string, shareableHostUnpackerLocation: string, shareableHostUnpackerSourceMap: string, shareableGuestUnpackerCode: string, shareableGuestUnpackerLocation: string, shareableGuestUnpackerSourceMap: string, remoteFunctionUnpackerCode: string, remoteFunctionUnpackerLocation: string, remoteFunctionUnpackerSourceMap: string ): void; loadUnpackersWithBytecode( valueUnpackerBytecode: ArrayBuffer, synchronizableUnpackerBytecode: ArrayBuffer, customSerializableUnpackerBytecode: ArrayBuffer, shareableHostUnpackerBytecode: ArrayBuffer, shareableGuestUnpackerBytecode: ArrayBuffer, remoteFunctionUnpackerBytecode: ArrayBuffer ): void; createSerializableImport( source: string, imported: string ): SerializableRef; createSerializableString(str: string): SerializableRef; createSerializableNumber(num: number): SerializableRef; createSerializableBoolean(bool: boolean): SerializableRef; createSerializableBigInt(bigInt: bigint): SerializableRef; createSerializableUndefined(): SerializableRef; createSerializableNull(): SerializableRef; createSerializableTurboModuleLike< TProps extends object, TProto extends object, >( props: TProps, proto: TProto ): SerializableRef; createSerializableObject( obj: T, shouldRetainRemote: boolean, nativeStateSource?: object ): SerializableRef; createSerializableHostObject(obj: T): SerializableRef; createSerializableArray( array: unknown[], shouldRetainRemote?: boolean ): SerializableRef; createSerializableArrayBuffer( arrayBuffer: ArrayBuffer ): SerializableRef; createSerializableMap( keys: TKey[], values: TValue[] ): SerializableRef>; createSerializableSet( values: TValues[] ): SerializableRef>; createSerializableError( name: string, message: string, stack: string | undefined ): SerializableRef; createSerializableRegExp( pattern: string, flags: string ): SerializableRef; createSerializableArrayBufferView( typeName: string, buffer: ArrayBuffer, byteOffset: number, length: number ): SerializableRef; createSerializableNonWorkletFunction( fun: (...args: TArgs) => TReturn, functionName: string | undefined ): SerializableRef<(...args: TArgs) => TReturn>; createSerializableWorklet( worklet: object, shouldPersistRemote: boolean ): SerializableRef; createCustomSerializable( data: SerializableRef, typeId: number ): SerializableRef; registerCustomSerializable( determine: SerializableRef, pack: SerializableRef, unpack: SerializableRef, typeId: number ): void; createShareable( hostRuntimeId: number, initial: SerializableRef, initSynchronously: boolean, decorateHost: SerializableRef, decorateGuest: SerializableRef ): SerializableRef; scheduleOnRN( fun: RemoteFunction | ((...args: TArgs) => unknown), args: SerializableRef | undefined ): void; scheduleOnUI( serializableArrayOfWorklets: SerializableRef, serializableArrayOfArguments: SerializableRef, scheduleStacks: string[] | undefined ): void; runOnUISync( serializable: SerializableRef, scheduleStack: string | undefined ): TReturn; createWorkletRuntime( name: string, initializer: SerializableRef<() => void>, useDefaultQueue: boolean, customQueue: object | undefined, enableEventLoop: boolean, enableLocking: boolean, enableNetworking: boolean ): WorkletRuntime; scheduleOnRuntime( workletRuntime: WorkletRuntime, worklet: SerializableRef, scheduleStack?: string ): void; scheduleOnRuntimeWithId( runtimeId: number, worklet: SerializableRef, scheduleStack?: string ): void; runOnRuntimeSync( workletRuntime: WorkletRuntime, worklet: SerializableRef, scheduleStack?: string ): TReturn; runOnRuntimeSyncWithId( runtimeId: number, worklet: SerializableRef, scheduleStack?: string ): TReturn; handlePromise( resolveOrReject: | ((value: TValue | PromiseLike) => void) | RemoteFunction, valueOrError: SerializableRef ): void; reportFatalErrorOnJS(message: string, stack: string, name: string): void; createSynchronizable( value: SerializableRef | TValue, isFixed: boolean ): SynchronizableRef; synchronizableGetDirty( synchronizableRef: SynchronizableRef ): TValue; synchronizableGetBlocking( synchronizableRef: SynchronizableRef ): TValue; synchronizableSetBlocking( synchronizableRef: SynchronizableRef, value: SerializableRef | TValue ): void; synchronizableSetDirty( synchronizableRef: SynchronizableRef, value: TValue ): void; synchronizableLock( synchronizableRef: SynchronizableRef ): void; synchronizableUnlock( synchronizableRef: SynchronizableRef ): void; getStaticFeatureFlag(name: string): boolean; setDynamicFeatureFlag(name: string, value: boolean): void; getCurrentThreadId(): string; getUIRuntimeHolder(): object; getUISchedulerHolder(): object; /** @deprecated Don't use unless you have to. */ createSerializableLEGACY( value: TValue, nativeStateSource: object | undefined ): SerializableRef; } type InternalMethods = | 'loadUnpackersWithCode' | 'loadUnpackersWithBytecode' | 'createSerializableLEGACY'; type TurboModulePublic = { toggleSlowAnimationsOnUIRuntime(): boolean; }; export type IWorkletsModule = Omit & TurboModulePublic;