{"version":3,"names":["NativeReanimatedModule","shouldBeUseWeb","registerWorkletStackDetails","jsVersion","shareableMappingCache","shareableMappingFlag","SHOULD_BE_USE_WEB","MAGIC_KEY","isHostObject","value","isPlainJSObject","object","Object","getPrototypeOf","prototype","INACCESSIBLE_OBJECT","__init","Proxy","get","_","prop","Error","String","set","VALID_ARRAY_VIEWS_NAMES","DETECT_CYCLIC_OBJECT_DEPTH_THRESHOLD","processedObjectAtThresholdDepth","makeShareableCloneRecursive","shouldPersistRemote","arguments","length","undefined","depth","type","isTypeObject","isTypeFunction","cached","toAdapt","Array","isArray","map","element","__workletHash","__DEV__","babelVersion","__initData","version","getWorkletCode","__stackDetails","key","entries","RegExp","pattern","source","flags","handle","ArrayBuffer","isView","buffer","typeName","constructor","name","includes","global","inaccessibleObject","freeze","adopted","makeShareableClone","WORKLET_CODE_THRESHOLD","_value$__initData","code","substring","isRemoteFunction","__remoteFunction","makeShareableCloneOnUIRecursive","cloneRecursive","_makeShareableClone","makeShareableJS","makeShareableNative","makeShareable"],"sources":["shareables.ts"],"sourcesContent":["'use strict';\nimport NativeReanimatedModule from './NativeReanimated';\nimport type {\n ShareableRef,\n FlatShareableRef,\n __WorkletFunction,\n} from './commonTypes';\nimport { shouldBeUseWeb } from './PlatformChecker';\nimport { registerWorkletStackDetails } from './errors';\nimport { jsVersion } from './platform-specific/jsVersion';\nimport {\n shareableMappingCache,\n shareableMappingFlag,\n} from './shareableMappingCache';\n\n// for web/chrome debugger/jest environments this file provides a stub implementation\n// where no shareable references are used. Instead, the objects themselves are used\n// instead of shareable references, because of the fact that we don't have to deal with\n// runnning the code on separate VMs.\nconst SHOULD_BE_USE_WEB = shouldBeUseWeb();\n\nconst MAGIC_KEY = 'REANIMATED_MAGIC_KEY';\n\nfunction isHostObject(value: NonNullable) {\n 'worklet';\n // We could use JSI to determine whether an object is a host object, however\n // the below workaround works well and is way faster than an additional JSI call.\n // We use the fact that host objects have broken implementation of `hasOwnProperty`\n // and hence return true for all `in` checks regardless of the key we ask for.\n return MAGIC_KEY in value;\n}\n\nfunction isPlainJSObject(object: object): object is object {\n return Object.getPrototypeOf(object) === Object.prototype;\n}\n\n// The below object is used as a replacement for objects that cannot be transferred\n// as shareable values. In makeShareableCloneRecursive we detect if an object is of\n// a plain Object.prototype and only allow such objects to be transferred. This lets\n// us avoid all sorts of react internals from leaking into the UI runtime. To make it\n// possible to catch errors when someone actually tries to access such object on the UI\n// runtime, we use the below Proxy object which is instantiated on the UI runtime and\n// throws whenever someone tries to access its fields.\nconst INACCESSIBLE_OBJECT = {\n __init: () => {\n 'worklet';\n return new Proxy(\n {},\n {\n get: (_: unknown, prop: string | symbol) => {\n if (\n prop === '_isReanimatedSharedValue' ||\n prop === '__remoteFunction'\n ) {\n // not very happy about this check here, but we need to allow for\n // \"inaccessible\" objects to be tested with isSharedValue check\n // as it is being used in the mappers when extracting inputs recursively\n // as well as with isRemoteFunction when cloning objects recursively.\n // Apparently we can't check if a key exists there as HostObjects always\n // return true for such tests, so the only possibility for us is to\n // actually access that key and see if it is set to true. We therefore\n // need to allow for this key to be accessed here.\n return false;\n }\n throw new Error(\n `[Reanimated] Trying to access property \\`${String(\n prop\n )}\\` of an object which cannot be sent to the UI runtime.`\n );\n },\n set: () => {\n throw new Error(\n '[Reanimated] Trying to write to an object which cannot be sent to the UI runtime.'\n );\n },\n }\n );\n },\n};\n\nconst VALID_ARRAY_VIEWS_NAMES = [\n 'Int8Array',\n 'Uint8Array',\n 'Uint8ClampedArray',\n 'Int16Array',\n 'Uint16Array',\n 'Int32Array',\n 'Uint32Array',\n 'Float32Array',\n 'Float64Array',\n 'BigInt64Array',\n 'BigUint64Array',\n 'DataView',\n];\n\nconst DETECT_CYCLIC_OBJECT_DEPTH_THRESHOLD = 30;\n// Below variable stores object that we process in makeShareableCloneRecursive at the specified depth.\n// We use it to check if later on the function reenters with the same object\nlet processedObjectAtThresholdDepth: unknown;\n\nexport function makeShareableCloneRecursive(\n value: any,\n shouldPersistRemote = false,\n depth = 0\n): ShareableRef {\n if (SHOULD_BE_USE_WEB) {\n return value;\n }\n if (depth >= DETECT_CYCLIC_OBJECT_DEPTH_THRESHOLD) {\n // if we reach certain recursion depth we suspect that we are dealing with a cyclic object.\n // this type of objects are not supported and cannot be trasferred as shareable, so we\n // implement a simple detection mechanism that remembers the value at a given depth and\n // tests whether we try reenter this method later on with the same value. If that happens\n // we throw an appropriate error.\n if (depth === DETECT_CYCLIC_OBJECT_DEPTH_THRESHOLD) {\n processedObjectAtThresholdDepth = value;\n } else if (value === processedObjectAtThresholdDepth) {\n throw new Error(\n '[Reanimated] Trying to convert a cyclic object to a shareable. This is not supported.'\n );\n }\n } else {\n processedObjectAtThresholdDepth = undefined;\n }\n // This one actually may be worth to be moved to c++, we also need similar logic to run on the UI thread\n const type = typeof value;\n const isTypeObject = type === 'object';\n const isTypeFunction = type === 'function';\n if ((isTypeObject || isTypeFunction) && value !== null) {\n const cached = shareableMappingCache.get(value);\n if (cached === shareableMappingFlag) {\n return value;\n } else if (cached !== undefined) {\n return cached as ShareableRef;\n } else {\n let toAdapt: any;\n if (Array.isArray(value)) {\n toAdapt = value.map((element) =>\n makeShareableCloneRecursive(element, shouldPersistRemote, depth + 1)\n );\n } else if (isTypeFunction && value.__workletHash === undefined) {\n // this is a remote function\n toAdapt = value;\n } else if (isHostObject(value)) {\n // for host objects we pass the reference to the object as shareable and\n // then recreate new host object wrapping the same instance on the UI thread.\n // there is no point of iterating over keys as we do for regular objects.\n toAdapt = value;\n } else if (isPlainJSObject(value) || isTypeFunction) {\n toAdapt = {};\n if (value.__workletHash !== undefined) {\n // we are converting a worklet\n if (__DEV__) {\n const babelVersion = value.__initData.version;\n if (babelVersion !== undefined && babelVersion !== jsVersion) {\n throw new Error(`[Reanimated] Mismatch between JavaScript code version and Reanimated Babel plugin version (${jsVersion} vs. ${babelVersion}). \nSee \\`https://docs.swmansion.com/react-native-reanimated/docs/guides/troubleshooting#mismatch-between-javascript-code-version-and-reanimated-babel-plugin-version\\` for more details.\nOffending code was: \\`${getWorkletCode(value)}\\``);\n }\n registerWorkletStackDetails(\n value.__workletHash,\n value.__stackDetails\n );\n }\n if (value.__stackDetails) {\n // `Error` type of value cannot be copied to the UI thread, so we\n // remove it after we handled it in dev mode or delete it to ignore it in production mode.\n // Not removing this would cause an infinite loop in production mode and it just\n // seems more elegant to handle it this way.\n delete value.__stackDetails;\n }\n // to save on transferring static __initData field of worklet structure\n // we request shareable value to persist its UI counterpart. This means\n // that the __initData field that contains long strings represeting the\n // worklet code, source map, and location, will always be\n // serialized/deserialized once.\n toAdapt.__initData = makeShareableCloneRecursive(\n value.__initData,\n true,\n depth + 1\n );\n }\n\n for (const [key, element] of Object.entries(value)) {\n if (key === '__initData' && toAdapt.__initData !== undefined) {\n continue;\n }\n toAdapt[key] = makeShareableCloneRecursive(\n element,\n shouldPersistRemote,\n depth + 1\n );\n }\n } else if (value instanceof RegExp) {\n const pattern = value.source;\n const flags = value.flags;\n const handle = makeShareableCloneRecursive({\n __init: () => {\n 'worklet';\n return new RegExp(pattern, flags);\n },\n });\n shareableMappingCache.set(value, handle);\n return handle as ShareableRef;\n } else if (value instanceof ArrayBuffer) {\n toAdapt = value;\n } else if (ArrayBuffer.isView(value)) {\n // typed array (e.g. Int32Array, Uint8ClampedArray) or DataView\n const buffer = value.buffer;\n const typeName = value.constructor.name;\n const handle = makeShareableCloneRecursive({\n __init: () => {\n 'worklet';\n if (!VALID_ARRAY_VIEWS_NAMES.includes(typeName)) {\n throw new Error(\n `[Reanimated] Invalid array view name \\`${typeName}\\`.`\n );\n }\n const constructor = global[typeName as keyof typeof global];\n if (constructor === undefined) {\n throw new Error(\n `[Reanimated] Constructor for \\`${typeName}\\` not found.`\n );\n }\n return new constructor(buffer);\n },\n });\n shareableMappingCache.set(value, handle);\n return handle as ShareableRef;\n } else {\n // This is reached for object types that are not of plain Object.prototype.\n // We don't support such objects from being transferred as shareables to\n // the UI runtime and hence we replace them with \"inaccessible object\"\n // which is implemented as a Proxy object that throws on any attempt\n // of accessing its fields. We argue that such objects can sometimes leak\n // as attributes of objects being captured by worklets but should never\n // be used on the UI runtime regardless. If they are being accessed, the user\n // will get an appropriate error message.\n const inaccessibleObject =\n makeShareableCloneRecursive(INACCESSIBLE_OBJECT);\n shareableMappingCache.set(value, inaccessibleObject);\n return inaccessibleObject;\n }\n if (__DEV__) {\n // we freeze objects that are transformed to shareable. This should help\n // detect issues when someone modifies data after it's been converted to\n // shareable. Meaning that they may be doing a faulty assumption in their\n // code expecting that the updates are going to automatically populate to\n // the object sent to the UI thread. If the user really wants some objects\n // to be mutable they should use shared values instead.\n Object.freeze(value);\n }\n const adopted = NativeReanimatedModule.makeShareableClone(\n toAdapt,\n shouldPersistRemote\n );\n shareableMappingCache.set(value, adopted);\n shareableMappingCache.set(adopted);\n return adopted;\n }\n }\n return NativeReanimatedModule.makeShareableClone(value, shouldPersistRemote);\n}\n\nconst WORKLET_CODE_THRESHOLD = 255;\n\nfunction getWorkletCode(value: __WorkletFunction) {\n // @ts-ignore this is fine\n const code = value?.__initData?.code;\n if (!code) {\n return 'unknown';\n }\n if (code.length > WORKLET_CODE_THRESHOLD) {\n return `${code.substring(0, WORKLET_CODE_THRESHOLD)}...`;\n }\n return code;\n}\n\ntype RemoteFunction = {\n __remoteFunction: FlatShareableRef;\n};\n\nfunction isRemoteFunction(value: {\n __remoteFunction?: unknown;\n}): value is RemoteFunction {\n 'worklet';\n return !!value.__remoteFunction;\n}\n\nexport function makeShareableCloneOnUIRecursive(\n value: T\n): FlatShareableRef {\n 'worklet';\n if (SHOULD_BE_USE_WEB) {\n // @ts-ignore web is an interesting place where we don't run a secondary VM on the UI thread\n // see more details in the comment where USE_STUB_IMPLEMENTATION is defined.\n return value;\n }\n // eslint-disable-next-line @typescript-eslint/no-shadow\n function cloneRecursive(value: T): FlatShareableRef {\n if (\n (typeof value === 'object' && value !== null) ||\n typeof value === 'function'\n ) {\n if (isHostObject(value)) {\n // We call `_makeShareableClone` to wrap the provided HostObject\n // inside ShareableJSRef.\n return _makeShareableClone(value) as FlatShareableRef;\n }\n if (isRemoteFunction(value)) {\n // RemoteFunctions are created by us therefore they are\n // a Shareable out of the box and there is no need to\n // call `_makeShareableClone`.\n return value.__remoteFunction;\n }\n if (Array.isArray(value)) {\n return _makeShareableClone(\n value.map(cloneRecursive)\n ) as FlatShareableRef;\n }\n const toAdapt: Record> = {};\n for (const [key, element] of Object.entries(value)) {\n toAdapt[key] = cloneRecursive(element);\n }\n return _makeShareableClone(toAdapt) as FlatShareableRef;\n }\n return _makeShareableClone(value);\n }\n return cloneRecursive(value);\n}\n\nfunction makeShareableJS(value: T): T {\n return value;\n}\n\nfunction makeShareableNative(value: T): T {\n if (shareableMappingCache.get(value)) {\n return value;\n }\n const handle = makeShareableCloneRecursive({\n __init: () => {\n 'worklet';\n return value;\n },\n });\n shareableMappingCache.set(value, handle);\n return value;\n}\n\n/**\n * This function creates a value on UI with persistent state - changes to it on the UI\n * thread will be seen by all worklets. Use it when you want to create a value\n * that is read and written only on the UI thread.\n */\nexport const makeShareable = SHOULD_BE_USE_WEB\n ? makeShareableJS\n : makeShareableNative;\n"],"mappings":"AAAA,YAAY;;AACZ,OAAOA,sBAAsB,MAAM,oBAAoB;AAMvD,SAASC,cAAc,QAAQ,mBAAmB;AAClD,SAASC,2BAA2B,QAAQ,UAAU;AACtD,SAASC,SAAS,QAAQ,+BAA+B;AACzD,SACEC,qBAAqB,EACrBC,oBAAoB,QACf,yBAAyB;;AAEhC;AACA;AACA;AACA;AACA,MAAMC,iBAAiB,GAAGL,cAAc,EAAE;AAE1C,MAAMM,SAAS,GAAG,sBAAsB;AAExC,SAASC,YAAYA,CAACC,KAA0B,EAAE;EAChD,SAAS;;EACT;EACA;EACA;EACA;EACA,OAAOF,SAAS,IAAIE,KAAK;AAC3B;AAEA,SAASC,eAAeA,CAACC,MAAc,EAAoB;EACzD,OAAOC,MAAM,CAACC,cAAc,CAACF,MAAM,CAAC,KAAKC,MAAM,CAACE,SAAS;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