{"version":3,"names":["processColorsInProps","_updatePropsJS","isFabric","isJest","shouldBeUseWeb","runOnUIImmediately","updateProps","_","updates","maybeViewRef","isAnimatedProps","items","forEach","item","_index","viewDescriptors","global","UpdatePropsManager","update","updatePropsJestWrapper","animatedStyle","adapters","adapter","current","value","createUpdatePropsManager","operations","viewDescriptor","push","shadowNodeWrapper","length","queueMicrotask","flush","_updatePropsFabric","tag","name","_updatePropsPaper","maybeThrowError","Error","Proxy","get","set"],"sources":["UpdateProps.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-redundant-type-constituents */\n'use strict';\nimport type { MutableRefObject } from 'react';\nimport { processColorsInProps } from './Colors';\nimport type { ShadowNodeWrapper, SharedValue, StyleProps } from './commonTypes';\nimport type { AnimatedStyle } from './helperTypes';\nimport type { Descriptor } from './hook/commonTypes';\nimport { _updatePropsJS } from './js-reanimated';\nimport { isFabric, isJest, shouldBeUseWeb } from './PlatformChecker';\nimport type { ViewRefSet } from './ViewDescriptorsSet';\nimport { runOnUIImmediately } from './threads';\n\nlet updateProps: (\n viewDescriptor: SharedValue,\n updates: StyleProps | AnimatedStyle,\n maybeViewRef: ViewRefSet | undefined,\n isAnimatedProps?: boolean\n) => void;\n\nif (shouldBeUseWeb()) {\n updateProps = (_, updates, maybeViewRef, isAnimatedProps) => {\n 'worklet';\n if (maybeViewRef) {\n maybeViewRef.items.forEach((item, _index) => {\n _updatePropsJS(updates, item, isAnimatedProps);\n });\n }\n };\n} else {\n updateProps = (viewDescriptors, updates) => {\n 'worklet';\n processColorsInProps(updates);\n global.UpdatePropsManager.update(viewDescriptors, updates);\n };\n}\n\nexport const updatePropsJestWrapper = (\n viewDescriptors: SharedValue,\n updates: AnimatedStyle,\n maybeViewRef: ViewRefSet | undefined,\n animatedStyle: MutableRefObject>,\n adapters: ((updates: AnimatedStyle) => void)[]\n): void => {\n adapters.forEach((adapter) => {\n adapter(updates);\n });\n animatedStyle.current.value = {\n ...animatedStyle.current.value,\n ...updates,\n };\n\n updateProps(viewDescriptors, updates, maybeViewRef);\n};\n\nexport default updateProps;\n\nconst createUpdatePropsManager = isFabric()\n ? () => {\n 'worklet';\n // Fabric\n const operations: {\n shadowNodeWrapper: ShadowNodeWrapper;\n updates: StyleProps | AnimatedStyle;\n }[] = [];\n return {\n update(\n viewDescriptors: SharedValue,\n updates: StyleProps | AnimatedStyle\n ) {\n viewDescriptors.value.forEach((viewDescriptor) => {\n operations.push({\n shadowNodeWrapper: viewDescriptor.shadowNodeWrapper,\n updates,\n });\n if (operations.length === 1) {\n queueMicrotask(this.flush);\n }\n });\n },\n flush(this: void) {\n _updatePropsFabric!(operations);\n operations.length = 0;\n },\n };\n }\n : () => {\n 'worklet';\n // Paper\n const operations: {\n tag: number;\n name: string;\n updates: StyleProps | AnimatedStyle;\n }[] = [];\n return {\n update(\n viewDescriptors: SharedValue,\n updates: StyleProps | AnimatedStyle\n ) {\n viewDescriptors.value.forEach((viewDescriptor) => {\n operations.push({\n tag: viewDescriptor.tag,\n name: viewDescriptor.name || 'RCTView',\n updates,\n });\n if (operations.length === 1) {\n queueMicrotask(this.flush);\n }\n });\n },\n flush(this: void) {\n _updatePropsPaper!(operations);\n operations.length = 0;\n },\n };\n };\n\nif (shouldBeUseWeb()) {\n const maybeThrowError = () => {\n // Jest attempts to access a property of this object to check if it is a Jest mock\n // so we can't throw an error in the getter.\n if (!isJest()) {\n throw new Error(\n '[Reanimated] `UpdatePropsManager` is not available on non-native platform.'\n );\n }\n };\n global.UpdatePropsManager = new Proxy({} as UpdatePropsManager, {\n get: maybeThrowError,\n set: () => {\n maybeThrowError();\n return false;\n },\n });\n} else {\n runOnUIImmediately(() => {\n 'worklet';\n global.UpdatePropsManager = createUpdatePropsManager();\n })();\n}\n\nexport interface UpdatePropsManager {\n update(\n viewDescriptors: SharedValue,\n updates: StyleProps | AnimatedStyle\n ): void;\n flush(): void;\n}\n"],"mappings":"AAAA;AACA,YAAY;;AAEZ,SAASA,oBAAoB,QAAQ,UAAU;AAI/C,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