'use strict'; import type { LazyBundleRegistrar } from './bundleMode/lazyBundles'; // This file works by accident - currently Builder Bob doesn't move `.d.ts` files to output types. // If it ever breaks, we should address it so we'd not pollute the user's global namespace. import type { reportFatalRemoteError } from './debug/errors'; import type { CustomSerializableUnpacker } from './memory/customSerializableUnpacker'; import type { RemoteFunctionUnpacker } from './memory/remoteFunctionUnpacker'; import type { makeShareableCloneOnUIRecursive } from './memory/serializable'; import type { ShareableGuestUnpacker } from './memory/shareableGuestUnpacker'; import type { ShareableHostUnpacker } from './memory/shareableHostUnpacker'; import type { SynchronizableUnpacker } from './memory/synchronizableUnpacker'; import type { CustomSerializationRegistry } from './memory/types'; import type { Queue } from './runLoop/workletRuntime/taskQueue'; import type { ValueUnpacker } from './types'; import type { WorkletsModuleProxy } from './WorkletsModule/workletsModuleProxy'; declare global { /** The only runtime-available require method is `__r` defined by Metro. */ var __r: ((moduleId: number) => Record) & Record; /** * The name of the current runtime, used in debugging. * * - "RN" for the RN Runtime. * - "UI" for the UI Runtime. * - A custom name for Worker Runtimes. */ var __RUNTIME_NAME: string; var _toString: (value: unknown) => string; var __workletsModuleProxy: WorkletsModuleProxy; var _WORKLETS_BUNDLE_MODE_ENABLED: boolean | undefined; /** The URL of the bundle. Only in Bundle Mode on Worklet Runtimes. */ var _WORKLETS_SOURCE_URL: string | undefined; /** Prefix of the Metro runtime globals, defined by the Metro prelude. */ var __METRO_GLOBAL_PREFIX__: string | undefined; /** Only in Debug builds on Worklet Runtimes. */ var evalWithSourceUrl: | ((code: string, sourceUrl: string) => unknown) | undefined; /** Only in dev builds in Bundle Mode on Worklet Runtimes. */ var __workletsLazyBundleRegistrar: LazyBundleRegistrar | undefined; var _WORKLETS_VERSION_CPP: string | undefined; var _WORKLETS_VERSION_JS: string | undefined; var _createSerializableString: (value: string) => FlatSerializableRef; var _createSerializableNumber: (value: number) => FlatSerializableRef; var _createSerializableBoolean: ( value: boolean ) => FlatSerializableRef; var _createSerializableBigInt: (value: bigint) => FlatSerializableRef; var _createSerializableUndefined: () => FlatSerializableRef; var _createSerializableNull: () => FlatSerializableRef; var _createSerializableObject: ( value: T, shouldRetainRemote: boolean, nativeStateSource?: object ) => FlatSerializableRef; var _createSerializableHostObject: ( value: T ) => FlatSerializableRef; var _createSerializableWorklet: ( value: object, shouldPersistRemote: boolean ) => FlatSerializableRef; var _createSerializableArray: ( value: unknown[] ) => FlatSerializableRef; var _createSerializableSynchronizable: ( value: object ) => FlatShareableRef; var __serializer: typeof makeShareableCloneOnUIRecursive; /** Available on runtimes with the Hermes microtask queue enabled. */ var __drainMicrotasks: () => void; /** * Returns the number of outermost native calls into this runtime that have * started. Available on Worklet Runtimes only with the `RUNTIME_TEST_FLAG` * static feature flag. */ var __getRootTaskId: (() => number) | undefined; /** Available only on the UI Runtime */ var __nativeRequestAnimationFrame: ( callback: (timestamp: number) => void ) => void; /** Available only on RN Runtime */ var __reportFatalRemoteError: typeof reportFatalRemoteError | undefined; var __valueUnpacker: ValueUnpacker; var __synchronizableUnpacker: SynchronizableUnpacker; var __customSerializationRegistry: CustomSerializationRegistry; var __customSerializableUnpacker: CustomSerializableUnpacker; var __remoteFunctionUnpacker: RemoteFunctionUnpacker; var __frameTimestamp: number | undefined; var _log: (value: unknown) => void; var _startProfiling: (meanHzFreq?: number) => void; var _stopProfiling: () => string; var _beginSection: (name: string) => void; var _endSection: () => void; var _getAnimationTimestamp: () => number; var _getTimerTimestamp: () => number; var _scheduleOnRuntime: ( runtime: WorkletRuntime, worklet: SerializableRef<() => void> ) => void; var _scheduleTimeoutCallback: (delay: number, handlerId: number) => void; var __runTimeoutCallback: (handlerId: number) => void; var _taskQueue: Queue; /** Only in Debug builds. */ var __hasNativeState: (value: object) => boolean; /** Only in Debug builds. */ var __isHostObject: (value: object) => boolean; var __shareableHostUnpacker: ShareableHostUnpacker; var __shareableGuestUnpacker: ShareableGuestUnpacker< unknown, unknown, unknown >; /** * Native logging hook installed by React Native on the RN Runtime and * propagated to Worklet Runtimes in Bundle Mode. Level values match RN's * `LOG_LEVELS`: 0 = trace, 1 = info, 2 = warn, 3 = error. */ var nativeLoggingHook: ((message: string, level: number) => void) | undefined; /** Only in Bundle Mode on Worklet Runtimes. */ var __workletsNetworking: | { sendRequest( config: { method: string; url: string; headers: Array<[string, string]>; body?: string | ArrayBuffer; timeoutMs: number; withCredentials: boolean; }, onEvent: (type: string, payload: unknown) => void ): number; abortRequest(requestId: number): void; decodeText(buffer: ArrayBuffer, encoding?: string): string; connectWebSocket( config: { url: string; protocols: string[]; headers: Array<[string, string]>; }, onEvent: (type: string, payload: unknown) => void ): number; sendWebSocketMessage( socketId: number, message: string | ArrayBuffer ): void; closeWebSocket(socketId: number, code: number, reason: string): void; } | undefined; interface NodeRequire { resolveWeak(id: string): number; getModules(): Map; } }