@shopify/react-native-skia 0.1.215 → 0.1.216

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,6 @@
1
1
  import type { Container } from "../../renderer/Container";
2
2
  import type { AnimatedProps } from "../../renderer/processors";
3
3
  import type { Node } from "../../dom/types";
4
+ export declare const unbindReanimatedNode: (node: Node<unknown>) => void;
4
5
  export declare function extractReanimatedProps(props: AnimatedProps<any>): AnimatedProps<any, never>[];
5
6
  export declare function bindReanimatedProps(container: Container, node: Node<any>, reanimatedProps: AnimatedProps<any>): void;
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.bindReanimatedProps = bindReanimatedProps;
7
7
  exports.extractReanimatedProps = extractReanimatedProps;
8
+ exports.unbindReanimatedNode = void 0;
8
9
 
9
10
  var _moduleWrapper = require("./moduleWrapper");
10
11
 
@@ -13,6 +14,16 @@ var _moduleWrapper = require("./moduleWrapper");
13
14
  /* eslint-disable reanimated/js-function-in-worklet */
14
15
  const _bindings = new WeakMap();
15
16
 
17
+ const unbindReanimatedNode = node => {
18
+ const previousMapperId = _bindings.get(node);
19
+
20
+ if (previousMapperId !== undefined) {
21
+ (0, _moduleWrapper.stopMapper)(previousMapperId);
22
+ }
23
+ };
24
+
25
+ exports.unbindReanimatedNode = unbindReanimatedNode;
26
+
16
27
  function extractReanimatedProps(props) {
17
28
  if (!_moduleWrapper.HAS_REANIMATED3 && !_moduleWrapper.HAS_REANIMATED2) {
18
29
  return [props, {}];
@@ -81,7 +92,7 @@ function bindReanimatedProps2(container, node, reanimatedProps) {
81
92
  }
82
93
 
83
94
  function bindReanimatedProps(container, node, reanimatedProps) {
84
- if (_moduleWrapper.HAS_REANIMATED2) {
95
+ if (_moduleWrapper.HAS_REANIMATED2 && !_moduleWrapper.HAS_REANIMATED3) {
85
96
  return bindReanimatedProps2(container, node, reanimatedProps);
86
97
  }
87
98
 
@@ -105,8 +116,10 @@ function bindReanimatedProps(container, node, reanimatedProps) {
105
116
  const mapperId = (0, _moduleWrapper.startMapper)(() => {
106
117
  "worklet";
107
118
 
108
- for (const propName in reanimatedProps) {
109
- node && node.setProp(propName, reanimatedProps[propName].value);
119
+ if (node) {
120
+ for (const propName in reanimatedProps) {
121
+ node.setProp(propName, reanimatedProps[propName].value);
122
+ }
110
123
  } // On React Native we use the SkiaViewApi to redraw because it can
111
124
  // run on the worklet thread (container.redraw can't)
112
125
  // if SkiaViewApi is undefined, we are on web and container.redraw()
@@ -1 +1 @@
1
- {"version":3,"names":["_bindings","WeakMap","extractReanimatedProps","props","HAS_REANIMATED3","HAS_REANIMATED2","reanimatedProps","otherProps","propName","propValue","isSharedValue","value","bindReanimatedProps2","container","node","sharedValues","Object","values","previousMapperId","get","undefined","stopMapper","length","viewId","getNativeId","SkiaViewApi","global","updateProps","setProp","requestRedraw","redraw","mapperId","startMapper","runOnJS","set","bindReanimatedProps"],"sources":["renderHelpers.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable reanimated/js-function-in-worklet */\nimport type { Container } from \"../../renderer/Container\";\nimport type { AnimatedProps } from \"../../renderer/processors\";\nimport type { Node } from \"../../dom/types\";\n\nimport {\n startMapper,\n stopMapper,\n isSharedValue,\n HAS_REANIMATED3,\n HAS_REANIMATED2,\n runOnJS,\n} from \"./moduleWrapper\";\n\nconst _bindings = new WeakMap<Node<unknown>, unknown>();\n\nexport function extractReanimatedProps(props: AnimatedProps<any>) {\n if (!HAS_REANIMATED3 && !HAS_REANIMATED2) {\n return [props, {}];\n }\n const reanimatedProps = {} as AnimatedProps<any>;\n const otherProps = {} as AnimatedProps<any>;\n for (const propName in props) {\n if (propName === \"children\") {\n continue;\n }\n const propValue = props[propName];\n if (isSharedValue(propValue)) {\n reanimatedProps[propName] = propValue;\n otherProps[propName] = propValue.value;\n } else {\n otherProps[propName] = propValue;\n }\n }\n return [otherProps, reanimatedProps];\n}\n\nfunction bindReanimatedProps2(\n container: Container,\n node: Node<any>,\n reanimatedProps: AnimatedProps<any>\n) {\n const sharedValues = Object.values(reanimatedProps);\n const previousMapperId = _bindings.get(node);\n if (previousMapperId !== undefined) {\n stopMapper(previousMapperId as number);\n }\n if (sharedValues.length > 0) {\n const viewId = container.getNativeId();\n const { SkiaViewApi } = global;\n const updateProps = () => {\n for (const propName in reanimatedProps) {\n node && node.setProp(propName, reanimatedProps[propName].value);\n }\n // On React Native we use the SkiaViewApi to redraw because it can\n // run on the worklet thread (container.redraw can't)\n // if SkiaViewApi is undefined, we are on web and container.redraw()\n // can safely be invoked\n if (SkiaViewApi) {\n SkiaViewApi.requestRedraw(viewId);\n } else {\n container.redraw();\n }\n };\n const mapperId = startMapper(() => {\n \"worklet\";\n runOnJS(updateProps)();\n }, sharedValues);\n _bindings.set(node, mapperId);\n }\n}\n\nexport function bindReanimatedProps(\n container: Container,\n node: Node<any>,\n reanimatedProps: AnimatedProps<any>\n) {\n if (HAS_REANIMATED2) {\n return bindReanimatedProps2(container, node, reanimatedProps);\n }\n if (!HAS_REANIMATED3) {\n return;\n }\n const sharedValues = Object.values(reanimatedProps);\n const previousMapperId = _bindings.get(node);\n if (previousMapperId !== undefined) {\n stopMapper(previousMapperId as number);\n }\n if (sharedValues.length > 0) {\n const viewId = container.getNativeId();\n const { SkiaViewApi } = global;\n const mapperId = startMapper(() => {\n \"worklet\";\n for (const propName in reanimatedProps) {\n node && node.setProp(propName, reanimatedProps[propName].value);\n }\n // On React Native we use the SkiaViewApi to redraw because it can\n // run on the worklet thread (container.redraw can't)\n // if SkiaViewApi is undefined, we are on web and container.redraw()\n // can safely be invoked\n if (SkiaViewApi) {\n SkiaViewApi.requestRedraw(viewId);\n } else {\n container.redraw();\n }\n }, sharedValues);\n _bindings.set(node, mapperId);\n }\n}\n"],"mappings":";;;;;;;;AAMA;;AANA;;AACA;AAcA,MAAMA,SAAS,GAAG,IAAIC,OAAJ,EAAlB;;AAEO,SAASC,sBAAT,CAAgCC,KAAhC,EAA2D;EAChE,IAAI,CAACC,8BAAD,IAAoB,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D;IACF,CAdgB,EAcdf,YAdc,CAAjB;;IAeAf,SAAS,CAACkC,GAAV,CAAcpB,IAAd,EAAoBiB,QAApB;EACD;AACF"}
1
+ {"version":3,"names":["_bindings","WeakMap","unbindReanimatedNode","node","previousMapperId","get","undefined","stopMapper","extractReanimatedProps","props","HAS_REANIMATED3","HAS_REANIMATED2","reanimatedProps","otherProps","propName","propValue","isSharedValue","value","bindReanimatedProps2","container","sharedValues","Object","values","length","viewId","getNativeId","SkiaViewApi","global","updateProps","setProp","requestRedraw","redraw","mapperId","startMapper","runOnJS","set","bindReanimatedProps"],"sources":["renderHelpers.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable reanimated/js-function-in-worklet */\nimport type { Container } from \"../../renderer/Container\";\nimport type { AnimatedProps } from \"../../renderer/processors\";\nimport type { Node } from \"../../dom/types\";\n\nimport {\n startMapper,\n stopMapper,\n isSharedValue,\n HAS_REANIMATED3,\n HAS_REANIMATED2,\n runOnJS,\n} from \"./moduleWrapper\";\n\nconst _bindings = new WeakMap<Node<unknown>, unknown>();\n\nexport const unbindReanimatedNode = (node: Node<unknown>) => {\n const previousMapperId = _bindings.get(node);\n if (previousMapperId !== undefined) {\n stopMapper(previousMapperId as number);\n }\n};\n\nexport function extractReanimatedProps(props: AnimatedProps<any>) {\n if (!HAS_REANIMATED3 && !HAS_REANIMATED2) {\n return [props, {}];\n }\n const reanimatedProps = {} as AnimatedProps<any>;\n const otherProps = {} as AnimatedProps<any>;\n for (const propName in props) {\n if (propName === \"children\") {\n continue;\n }\n const propValue = props[propName];\n if (isSharedValue(propValue)) {\n reanimatedProps[propName] = propValue;\n otherProps[propName] = propValue.value;\n } else {\n otherProps[propName] = propValue;\n }\n }\n return [otherProps, reanimatedProps];\n}\n\nfunction bindReanimatedProps2(\n container: Container,\n node: Node<any>,\n reanimatedProps: AnimatedProps<any>\n) {\n const sharedValues = Object.values(reanimatedProps);\n const previousMapperId = _bindings.get(node);\n if (previousMapperId !== undefined) {\n stopMapper(previousMapperId as number);\n }\n if (sharedValues.length > 0) {\n const viewId = container.getNativeId();\n const { SkiaViewApi } = global;\n const updateProps = () => {\n for (const propName in reanimatedProps) {\n node && node.setProp(propName, reanimatedProps[propName].value);\n }\n // On React Native we use the SkiaViewApi to redraw because it can\n // run on the worklet thread (container.redraw can't)\n // if SkiaViewApi is undefined, we are on web and container.redraw()\n // can safely be invoked\n if (SkiaViewApi) {\n SkiaViewApi.requestRedraw(viewId);\n } else {\n container.redraw();\n }\n };\n const mapperId = startMapper(() => {\n \"worklet\";\n runOnJS(updateProps)();\n }, sharedValues);\n _bindings.set(node, mapperId);\n }\n}\n\nexport function bindReanimatedProps(\n container: Container,\n node: Node<any>,\n reanimatedProps: AnimatedProps<any>\n) {\n if (HAS_REANIMATED2 && !HAS_REANIMATED3) {\n return bindReanimatedProps2(container, node, reanimatedProps);\n }\n if (!HAS_REANIMATED3) {\n return;\n }\n const sharedValues = Object.values(reanimatedProps);\n const previousMapperId = _bindings.get(node);\n if (previousMapperId !== undefined) {\n stopMapper(previousMapperId as number);\n }\n if (sharedValues.length > 0) {\n const viewId = container.getNativeId();\n const { SkiaViewApi } = global;\n const mapperId = startMapper(() => {\n \"worklet\";\n if (node) {\n for (const propName in reanimatedProps) {\n node.setProp(propName, reanimatedProps[propName].value);\n }\n }\n // On React Native we use the SkiaViewApi to redraw because it can\n // run on the worklet thread (container.redraw can't)\n // if SkiaViewApi is undefined, we are on web and container.redraw()\n // can safely be invoked\n if (SkiaViewApi) {\n SkiaViewApi.requestRedraw(viewId);\n } else {\n container.redraw();\n }\n }, sharedValues);\n _bindings.set(node, mapperId);\n }\n}\n"],"mappings":";;;;;;;;;AAMA;;AANA;;AACA;AAcA,MAAMA,SAAS,GAAG,IAAIC,OAAJ,EAAlB;;AAEO,MAAMC,oBAAoB,GAAIC,IAAD,IAAyB;EAC3D,MAAMC,gBAAgB,GAAGJ,SAAS,CAACK,GAAV,CAAcF,IAAd,CAAzB;;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QAAb,EAAuBF,eAAe,CAACE,QAAD,CAAf,CAA0BG,KAAjD;QACD;MACF,CANgC,CAOjC;MACA;MACA;MACA;;;MACA,IAAIS,WAAJ,EAAiB;QACfA,WAAW,CAACI,aAAZ,CAA0BN,MAA1B;MACD,CAFD,MAEO;QACLL,SAAS,CAACY,MAAV;MACD;IACF,CAhBgB,EAgBdX,YAhBc,CAAjB;;IAiBApB,SAAS,CAACmC,GAAV,CAAchC,IAAd,EAAoB6B,QAApB;EACD;AACF"}
@@ -31,6 +31,7 @@ const appendNode = (parent, child) => {
31
31
  };
32
32
 
33
33
  const removeNode = (parent, child) => {
34
+ (0, _renderHelpers.unbindReanimatedNode)(child);
34
35
  return parent.removeChild(child);
35
36
  };
36
37
 
@@ -1 +1 @@
1
- {"version":3,"names":["DEBUG","debug","console","log","appendNode","parent","child","addChild","removeNode","removeChild","insertBefore","before","insertChildBefore","skHostConfig","now","Date","supportsMutation","isPrimaryRenderer","supportsPersistence","supportsHydration","scheduleTimeout","setTimeout","cancelTimeout","clearTimeout","noTimeout","appendChildToContainer","container","root","appendChild","getRootHostContext","_rootContainerInstance","getChildHostContext","_parentHostContext","_type","shouldSetTextContent","_props","createTextInstance","_text","_hostContext","_internalInstanceHandle","Error","createInstance","type","pristineProps","props","reanimatedProps","extractReanimatedProps","node","createNode","materialize","bindReanimatedProps","depMgr","subscribeNode","appendInitialChild","parentInstance","finalizeInitialChildren","commitMount","prepareForCommit","_containerInfo","resetAfterCommit","update","redraw","getPublicInstance","prepareUpdate","_instance","oldProps","newProps","rootContainerInstance","propsAreEqual","shallowEq","commitUpdate","instance","updatePayload","prevProps","nextProps","_internalHandle","unsubscribeNode","setProps","commitTextUpdate","_textInstance","_oldText","_newText","clearContainer","children","forEach","preparePortalMount","removeChildFromContainer","insertInContainerBefore","getCurrentEventPriority","DefaultEventPriority","beforeActiveInstanceBlur","afterActiveInstanceBlur","detachDeletedInstance","result","mapKeys","key","prop","isValue","current","isSelector","selector","value"],"sources":["HostConfig.ts"],"sourcesContent":["/*global NodeJS*/\nimport type { HostConfig } from \"react-reconciler\";\nimport { DefaultEventPriority } from \"react-reconciler/constants\";\n\nimport type { NodeType, Node } from \"../dom/types\";\nimport type { SkiaValue } from \"../values\";\nimport {\n bindReanimatedProps,\n extractReanimatedProps,\n} from \"../external/reanimated/renderHelpers\";\n\nimport type { Container } from \"./Container\";\nimport { createNode } from \"./HostComponents\";\nimport type { AnimatedProps } from \"./processors\";\nimport { isSelector, isValue } from \"./processors\";\nimport { mapKeys, shallowEq } from \"./typeddash\";\n\nconst DEBUG = false;\nexport const debug = (...args: Parameters<typeof console.log>) => {\n if (DEBUG) {\n console.log(...args);\n }\n};\n\ntype Instance = Node<unknown>;\n\ntype Props = object;\ntype TextInstance = Node<unknown>;\ntype SuspenseInstance = Instance;\ntype HydratableInstance = Instance;\ntype PublicInstance = Instance;\ntype HostContext = null;\ntype UpdatePayload = Container;\ntype ChildSet = unknown;\ntype TimeoutHandle = NodeJS.Timeout;\ntype NoTimeout = -1;\n\ntype SkiaHostConfig = HostConfig<\n NodeType,\n Props,\n Container,\n Instance,\n TextInstance,\n SuspenseInstance,\n HydratableInstance,\n PublicInstance,\n HostContext,\n UpdatePayload,\n ChildSet,\n TimeoutHandle,\n NoTimeout\n>;\n\nconst appendNode = (parent: Node<unknown>, child: Node<unknown>) => {\n parent.addChild(child);\n};\n\nconst removeNode = (parent: Node<unknown>, child: Node<unknown>) => {\n return parent.removeChild(child);\n};\n\nconst insertBefore = (\n parent: Node<unknown>,\n child: Node<unknown>,\n before: Node<unknown>\n) => {\n parent.insertChildBefore(child, before);\n};\n\nexport const skHostConfig: SkiaHostConfig = {\n /**\n * This function is used by the reconciler in order to calculate current time for prioritising work.\n */\n now: Date.now,\n supportsMutation: true,\n isPrimaryRenderer: false,\n supportsPersistence: false,\n supportsHydration: false,\n //supportsMicrotask: true,\n\n scheduleTimeout: setTimeout,\n cancelTimeout: clearTimeout,\n noTimeout: -1,\n\n appendChildToContainer(container, child) {\n debug(\"appendChildToContainer\", container, child);\n appendNode(container.root, child);\n },\n\n appendChild(parent, child) {\n debug(\"appendChild\", parent, child);\n appendNode(parent, child);\n },\n\n getRootHostContext: (_rootContainerInstance: Container) => {\n debug(\"getRootHostContext\");\n return null;\n },\n\n getChildHostContext(_parentHostContext, _type, _rootContainerInstance) {\n debug(\"getChildHostContext\");\n return null;\n },\n\n shouldSetTextContent(_type, _props) {\n return false;\n },\n\n createTextInstance(\n _text,\n _rootContainerInstance,\n _hostContext,\n _internalInstanceHandle\n ) {\n debug(\"createTextInstance\");\n // return SpanNode({}, text) as SkNode;\n throw new Error(\"Text nodes are not supported yet\");\n },\n\n createInstance(\n type,\n pristineProps,\n container,\n _hostContext,\n _internalInstanceHandle\n ) {\n debug(\"createInstance\", type);\n const [props, reanimatedProps] = extractReanimatedProps(pristineProps);\n const node = createNode(container, type, materialize(props));\n bindReanimatedProps(container, node, reanimatedProps);\n container.depMgr.subscribeNode(node, props);\n return node;\n },\n\n appendInitialChild(parentInstance, child) {\n debug(\"appendInitialChild\");\n appendNode(parentInstance, child);\n },\n\n finalizeInitialChildren(\n parentInstance,\n _type,\n _props,\n _rootContainerInstance,\n _hostContext\n ) {\n debug(\"finalizeInitialChildren\", parentInstance);\n return false;\n },\n\n commitMount() {\n // if finalizeInitialChildren = true\n debug(\"commitMount\");\n },\n\n prepareForCommit(_containerInfo) {\n debug(\"prepareForCommit\");\n return null;\n },\n\n resetAfterCommit(container) {\n debug(\"resetAfterCommit\");\n container.depMgr.update();\n container.redraw();\n },\n\n getPublicInstance(node: Instance) {\n debug(\"getPublicInstance\");\n return node;\n },\n\n prepareUpdate: (\n _instance,\n type,\n oldProps,\n newProps,\n rootContainerInstance,\n _hostContext\n ) => {\n debug(\"prepareUpdate\");\n const propsAreEqual = shallowEq(oldProps, newProps);\n if (propsAreEqual) {\n return null;\n }\n debug(\"update \", type);\n return rootContainerInstance;\n },\n\n commitUpdate(\n instance,\n updatePayload,\n type,\n prevProps,\n nextProps,\n _internalHandle\n ) {\n debug(\"commitUpdate: \", type);\n if (shallowEq(prevProps, nextProps)) {\n return;\n }\n const [props, reanimatedProps] = extractReanimatedProps(nextProps);\n updatePayload.depMgr.unsubscribeNode(instance);\n instance.setProps(materialize(props));\n bindReanimatedProps(updatePayload, instance, reanimatedProps);\n updatePayload.depMgr.subscribeNode(instance, props);\n },\n\n commitTextUpdate: (\n _textInstance: TextInstance,\n _oldText: string,\n _newText: string\n ) => {\n // textInstance.instance = newText;\n },\n\n clearContainer: (container) => {\n debug(\"clearContainer\");\n container.root.children().forEach((child) => {\n container.root.removeChild(child);\n });\n },\n\n preparePortalMount: () => {\n debug(\"preparePortalMount\");\n },\n\n removeChild: (parent, child) => {\n removeNode(parent, child);\n },\n\n removeChildFromContainer: (container, child) => {\n removeNode(container.root, child);\n },\n\n insertInContainerBefore: (container, child, before) => {\n insertBefore(container.root, child, before);\n },\n\n insertBefore: (parent, child, before) => {\n insertBefore(parent, child, before);\n },\n // see https://github.com/pmndrs/react-three-fiber/pull/2360#discussion_r916356874\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n getCurrentEventPriority: () => DefaultEventPriority,\n beforeActiveInstanceBlur: () => {},\n afterActiveInstanceBlur: () => {},\n detachDeletedInstance: () => {},\n};\n\nconst materialize = <P>(props: AnimatedProps<P>) => {\n const result = { ...props } as P;\n mapKeys(props).forEach((key) => {\n const prop = props[key];\n if (isValue(prop)) {\n result[key] = (prop as SkiaValue<P[typeof key]>).current;\n } else if (isSelector(prop)) {\n result[key] = prop.selector(prop.value.current) as P[typeof key];\n }\n });\n\n return result;\n};\n"],"mappings":";;;;;;;AAEA;;AAIA;;AAMA;;AAEA;;AACA;;AAfA;AAiBA,MAAMA,KAAK,GAAG,KAAd;;AACO,MAAMC,KAAK,GAAG,YAA6C;EAChE,IAAID,KAAJ,EAAW;IACTE,OAAO,CAACC,GAAR,CAAY,YAAZ;EACD;AACF,CAJM;;;;AAmCP,MAAMC,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KAAJ,IAAgC;EAClD,MAAMiD,MAAM,GAAG,EAAE,GAAGjD;EAAL,CAAf;EACA,IAAAkD,kBAAA,EAAQlD,KAAR,EAAewC,OAAf,CAAwBW,GAAD,IAAS;IAC9B,MAAMC,IAAI,GAAGpD,KAAK,CAACmD,GAAD,CAAlB;;IACA,IAAI,IAAAE,mBAAA,EAAQD,IAAR,CAAJ,EAAmB;MACjBH,MAAM,CAACE,GAAD,CAAN,GAAeC,IAAD,CAAmCE,OAAjD;IACD,CAFD,MAEO,IAAI,IAAAC,sBAAA,EAAWH,IAAX,CAAJ,EAAsB;MAC3BH,MAAM,CAACE,GAAD,CAAN,GAAcC,IAAI,CAACI,QAAL,CAAcJ,IAAI,CAACK,KAAL,CAAWH,OAAzB,CAAd;IACD;EACF,CAPD;EASA,OAAOL,MAAP;AACD,CAZD"}
1
+ {"version":3,"names":["DEBUG","debug","console","log","appendNode","parent","child","addChild","removeNode","unbindReanimatedNode","removeChild","insertBefore","before","insertChildBefore","skHostConfig","now","Date","supportsMutation","isPrimaryRenderer","supportsPersistence","supportsHydration","scheduleTimeout","setTimeout","cancelTimeout","clearTimeout","noTimeout","appendChildToContainer","container","root","appendChild","getRootHostContext","_rootContainerInstance","getChildHostContext","_parentHostContext","_type","shouldSetTextContent","_props","createTextInstance","_text","_hostContext","_internalInstanceHandle","Error","createInstance","type","pristineProps","props","reanimatedProps","extractReanimatedProps","node","createNode","materialize","bindReanimatedProps","depMgr","subscribeNode","appendInitialChild","parentInstance","finalizeInitialChildren","commitMount","prepareForCommit","_containerInfo","resetAfterCommit","update","redraw","getPublicInstance","prepareUpdate","_instance","oldProps","newProps","rootContainerInstance","propsAreEqual","shallowEq","commitUpdate","instance","updatePayload","prevProps","nextProps","_internalHandle","unsubscribeNode","setProps","commitTextUpdate","_textInstance","_oldText","_newText","clearContainer","children","forEach","preparePortalMount","removeChildFromContainer","insertInContainerBefore","getCurrentEventPriority","DefaultEventPriority","beforeActiveInstanceBlur","afterActiveInstanceBlur","detachDeletedInstance","result","mapKeys","key","prop","isValue","current","isSelector","selector","value"],"sources":["HostConfig.ts"],"sourcesContent":["/*global NodeJS*/\nimport type { HostConfig } from \"react-reconciler\";\nimport { DefaultEventPriority } from \"react-reconciler/constants\";\n\nimport type { NodeType, Node } from \"../dom/types\";\nimport type { SkiaValue } from \"../values\";\nimport {\n bindReanimatedProps,\n extractReanimatedProps,\n unbindReanimatedNode,\n} from \"../external/reanimated/renderHelpers\";\n\nimport type { Container } from \"./Container\";\nimport { createNode } from \"./HostComponents\";\nimport type { AnimatedProps } from \"./processors\";\nimport { isSelector, isValue } from \"./processors\";\nimport { mapKeys, shallowEq } from \"./typeddash\";\n\nconst DEBUG = false;\nexport const debug = (...args: Parameters<typeof console.log>) => {\n if (DEBUG) {\n console.log(...args);\n }\n};\n\ntype Instance = Node<unknown>;\n\ntype Props = object;\ntype TextInstance = Node<unknown>;\ntype SuspenseInstance = Instance;\ntype HydratableInstance = Instance;\ntype PublicInstance = Instance;\ntype HostContext = null;\ntype UpdatePayload = Container;\ntype ChildSet = unknown;\ntype TimeoutHandle = NodeJS.Timeout;\ntype NoTimeout = -1;\n\ntype SkiaHostConfig = HostConfig<\n NodeType,\n Props,\n Container,\n Instance,\n TextInstance,\n SuspenseInstance,\n HydratableInstance,\n PublicInstance,\n HostContext,\n UpdatePayload,\n ChildSet,\n TimeoutHandle,\n NoTimeout\n>;\n\nconst appendNode = (parent: Node<unknown>, child: Node<unknown>) => {\n parent.addChild(child);\n};\n\nconst removeNode = (parent: Node<unknown>, child: Node<unknown>) => {\n unbindReanimatedNode(child);\n return parent.removeChild(child);\n};\n\nconst insertBefore = (\n parent: Node<unknown>,\n child: Node<unknown>,\n before: Node<unknown>\n) => {\n parent.insertChildBefore(child, before);\n};\n\nexport const skHostConfig: SkiaHostConfig = {\n /**\n * This function is used by the reconciler in order to calculate current time for prioritising work.\n */\n now: Date.now,\n supportsMutation: true,\n isPrimaryRenderer: false,\n supportsPersistence: false,\n supportsHydration: false,\n //supportsMicrotask: true,\n\n scheduleTimeout: setTimeout,\n cancelTimeout: clearTimeout,\n noTimeout: -1,\n\n appendChildToContainer(container, child) {\n debug(\"appendChildToContainer\", container, child);\n appendNode(container.root, child);\n },\n\n appendChild(parent, child) {\n debug(\"appendChild\", parent, child);\n appendNode(parent, child);\n },\n\n getRootHostContext: (_rootContainerInstance: Container) => {\n debug(\"getRootHostContext\");\n return null;\n },\n\n getChildHostContext(_parentHostContext, _type, _rootContainerInstance) {\n debug(\"getChildHostContext\");\n return null;\n },\n\n shouldSetTextContent(_type, _props) {\n return false;\n },\n\n createTextInstance(\n _text,\n _rootContainerInstance,\n _hostContext,\n _internalInstanceHandle\n ) {\n debug(\"createTextInstance\");\n // return SpanNode({}, text) as SkNode;\n throw new Error(\"Text nodes are not supported yet\");\n },\n\n createInstance(\n type,\n pristineProps,\n container,\n _hostContext,\n _internalInstanceHandle\n ) {\n debug(\"createInstance\", type);\n const [props, reanimatedProps] = extractReanimatedProps(pristineProps);\n const node = createNode(container, type, materialize(props));\n bindReanimatedProps(container, node, reanimatedProps);\n container.depMgr.subscribeNode(node, props);\n return node;\n },\n\n appendInitialChild(parentInstance, child) {\n debug(\"appendInitialChild\");\n appendNode(parentInstance, child);\n },\n\n finalizeInitialChildren(\n parentInstance,\n _type,\n _props,\n _rootContainerInstance,\n _hostContext\n ) {\n debug(\"finalizeInitialChildren\", parentInstance);\n return false;\n },\n\n commitMount() {\n // if finalizeInitialChildren = true\n debug(\"commitMount\");\n },\n\n prepareForCommit(_containerInfo) {\n debug(\"prepareForCommit\");\n return null;\n },\n\n resetAfterCommit(container) {\n debug(\"resetAfterCommit\");\n container.depMgr.update();\n container.redraw();\n },\n\n getPublicInstance(node: Instance) {\n debug(\"getPublicInstance\");\n return node;\n },\n\n prepareUpdate: (\n _instance,\n type,\n oldProps,\n newProps,\n rootContainerInstance,\n _hostContext\n ) => {\n debug(\"prepareUpdate\");\n const propsAreEqual = shallowEq(oldProps, newProps);\n if (propsAreEqual) {\n return null;\n }\n debug(\"update \", type);\n return rootContainerInstance;\n },\n\n commitUpdate(\n instance,\n updatePayload,\n type,\n prevProps,\n nextProps,\n _internalHandle\n ) {\n debug(\"commitUpdate: \", type);\n if (shallowEq(prevProps, nextProps)) {\n return;\n }\n const [props, reanimatedProps] = extractReanimatedProps(nextProps);\n updatePayload.depMgr.unsubscribeNode(instance);\n instance.setProps(materialize(props));\n bindReanimatedProps(updatePayload, instance, reanimatedProps);\n updatePayload.depMgr.subscribeNode(instance, props);\n },\n\n commitTextUpdate: (\n _textInstance: TextInstance,\n _oldText: string,\n _newText: string\n ) => {\n // textInstance.instance = newText;\n },\n\n clearContainer: (container) => {\n debug(\"clearContainer\");\n container.root.children().forEach((child) => {\n container.root.removeChild(child);\n });\n },\n\n preparePortalMount: () => {\n debug(\"preparePortalMount\");\n },\n\n removeChild: (parent, child) => {\n removeNode(parent, child);\n },\n\n removeChildFromContainer: (container, child) => {\n removeNode(container.root, child);\n },\n\n insertInContainerBefore: (container, child, before) => {\n insertBefore(container.root, child, before);\n },\n\n insertBefore: (parent, child, before) => {\n insertBefore(parent, child, before);\n },\n // see https://github.com/pmndrs/react-three-fiber/pull/2360#discussion_r916356874\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n getCurrentEventPriority: () => DefaultEventPriority,\n beforeActiveInstanceBlur: () => {},\n afterActiveInstanceBlur: () => {},\n detachDeletedInstance: () => {},\n};\n\nconst materialize = <P>(props: AnimatedProps<P>) => {\n const result = { ...props } as P;\n mapKeys(props).forEach((key) => {\n const prop = props[key];\n if (isValue(prop)) {\n result[key] = (prop as SkiaValue<P[typeof key]>).current;\n } else if (isSelector(prop)) {\n result[key] = prop.selector(prop.value.current) as P[typeof key];\n }\n });\n\n return result;\n};\n"],"mappings":";;;;;;;AAEA;;AAIA;;AAOA;;AAEA;;AACA;;AAhBA;AAkBA,MAAMA,KAAK,GAAG,KAAd;;AACO,MAAMC,KAAK,GAAG,YAA6C;E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,CAhLQ;EAiL1CC,uBAAuB,EAAE,MAAM,CAAE,CAjLS;EAkL1CC,qBAAqB,EAAE,MAAM,CAAE;AAlLW,CAArC;;;AAqLP,MAAM3C,WAAW,GAAOL,KAAJ,IAAgC;EAClD,MAAMiD,MAAM,GAAG,EAAE,GAAGjD;EAAL,CAAf;EACA,IAAAkD,kBAAA,EAAQlD,KAAR,EAAewC,OAAf,CAAwBW,GAAD,IAAS;IAC9B,MAAMC,IAAI,GAAGpD,KAAK,CAACmD,GAAD,CAAlB;;IACA,IAAI,IAAAE,mBAAA,EAAQD,IAAR,CAAJ,EAAmB;MACjBH,MAAM,CAACE,GAAD,CAAN,GAAeC,IAAD,CAAmCE,OAAjD;IACD,CAFD,MAEO,IAAI,IAAAC,sBAAA,EAAWH,IAAX,CAAJ,EAAsB;MAC3BH,MAAM,CAACE,GAAD,CAAN,GAAcC,IAAI,CAACI,QAAL,CAAcJ,IAAI,CAACK,KAAL,CAAWH,OAAzB,CAAd;IACD;EACF,CAPD;EASA,OAAOL,MAAP;AACD,CAZD"}
@@ -1,5 +1,6 @@
1
1
  import type { Container } from "../../renderer/Container";
2
2
  import type { AnimatedProps } from "../../renderer/processors";
3
3
  import type { Node } from "../../dom/types";
4
+ export declare const unbindReanimatedNode: (node: Node<unknown>) => void;
4
5
  export declare function extractReanimatedProps(props: AnimatedProps<any>): AnimatedProps<any, never>[];
5
6
  export declare function bindReanimatedProps(container: Container, node: Node<any>, reanimatedProps: AnimatedProps<any>): void;
@@ -5,6 +5,13 @@ import { startMapper, stopMapper, isSharedValue, HAS_REANIMATED3, HAS_REANIMATED
5
5
 
6
6
  const _bindings = new WeakMap();
7
7
 
8
+ export const unbindReanimatedNode = node => {
9
+ const previousMapperId = _bindings.get(node);
10
+
11
+ if (previousMapperId !== undefined) {
12
+ stopMapper(previousMapperId);
13
+ }
14
+ };
8
15
  export function extractReanimatedProps(props) {
9
16
  if (!HAS_REANIMATED3 && !HAS_REANIMATED2) {
10
17
  return [props, {}];
@@ -73,7 +80,7 @@ function bindReanimatedProps2(container, node, reanimatedProps) {
73
80
  }
74
81
 
75
82
  export function bindReanimatedProps(container, node, reanimatedProps) {
76
- if (HAS_REANIMATED2) {
83
+ if (HAS_REANIMATED2 && !HAS_REANIMATED3) {
77
84
  return bindReanimatedProps2(container, node, reanimatedProps);
78
85
  }
79
86
 
@@ -97,8 +104,10 @@ export function bindReanimatedProps(container, node, reanimatedProps) {
97
104
  const mapperId = startMapper(() => {
98
105
  "worklet";
99
106
 
100
- for (const propName in reanimatedProps) {
101
- node && node.setProp(propName, reanimatedProps[propName].value);
107
+ if (node) {
108
+ for (const propName in reanimatedProps) {
109
+ node.setProp(propName, reanimatedProps[propName].value);
110
+ }
102
111
  } // On React Native we use the SkiaViewApi to redraw because it can
103
112
  // run on the worklet thread (container.redraw can't)
104
113
  // if SkiaViewApi is undefined, we are on web and container.redraw()
@@ -1 +1 @@
1
- {"version":3,"names":["startMapper","stopMapper","isSharedValue","HAS_REANIMATED3","HAS_REANIMATED2","runOnJS","_bindings","WeakMap","extractReanimatedProps","props","reanimatedProps","otherProps","propName","propValue","value","bindReanimatedProps2","container","node","sharedValues","Object","values","previousMapperId","get","undefined","length","viewId","getNativeId","SkiaViewApi","global","updateProps","setProp","requestRedraw","redraw","mapperId","set","bindReanimatedProps"],"sources":["renderHelpers.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable reanimated/js-function-in-worklet */\nimport type { Container } from \"../../renderer/Container\";\nimport type { AnimatedProps } from \"../../renderer/processors\";\nimport type { Node } from \"../../dom/types\";\n\nimport {\n startMapper,\n stopMapper,\n isSharedValue,\n HAS_REANIMATED3,\n HAS_REANIMATED2,\n runOnJS,\n} from \"./moduleWrapper\";\n\nconst _bindings = new WeakMap<Node<unknown>, unknown>();\n\nexport function extractReanimatedProps(props: AnimatedProps<any>) {\n if (!HAS_REANIMATED3 && !HAS_REANIMATED2) {\n return [props, {}];\n }\n const reanimatedProps = {} as AnimatedProps<any>;\n const otherProps = {} as AnimatedProps<any>;\n for (const propName in props) {\n if (propName === \"children\") {\n continue;\n }\n const propValue = props[propName];\n if (isSharedValue(propValue)) {\n reanimatedProps[propName] = propValue;\n otherProps[propName] = propValue.value;\n } else {\n otherProps[propName] = propValue;\n }\n }\n return [otherProps, reanimatedProps];\n}\n\nfunction bindReanimatedProps2(\n container: Container,\n node: Node<any>,\n reanimatedProps: AnimatedProps<any>\n) {\n const sharedValues = Object.values(reanimatedProps);\n const previousMapperId = _bindings.get(node);\n if (previousMapperId !== undefined) {\n stopMapper(previousMapperId as number);\n }\n if (sharedValues.length > 0) {\n const viewId = container.getNativeId();\n const { SkiaViewApi } = global;\n const updateProps = () => {\n for (const propName in reanimatedProps) {\n node && node.setProp(propName, reanimatedProps[propName].value);\n }\n // On React Native we use the SkiaViewApi to redraw because it can\n // run on the worklet thread (container.redraw can't)\n // if SkiaViewApi is undefined, we are on web and container.redraw()\n // can safely be invoked\n if (SkiaViewApi) {\n SkiaViewApi.requestRedraw(viewId);\n } else {\n container.redraw();\n }\n };\n const mapperId = startMapper(() => {\n \"worklet\";\n runOnJS(updateProps)();\n }, sharedValues);\n _bindings.set(node, mapperId);\n }\n}\n\nexport function bindReanimatedProps(\n container: Container,\n node: Node<any>,\n reanimatedProps: AnimatedProps<any>\n) {\n if (HAS_REANIMATED2) {\n return bindReanimatedProps2(container, node, reanimatedProps);\n }\n if (!HAS_REANIMATED3) {\n return;\n }\n const sharedValues = Object.values(reanimatedProps);\n const previousMapperId = _bindings.get(node);\n if (previousMapperId !== undefined) {\n stopMapper(previousMapperId as number);\n }\n if (sharedValues.length > 0) {\n const viewId = container.getNativeId();\n const { SkiaViewApi } = global;\n const mapperId = startMapper(() => {\n \"worklet\";\n for (const propName in reanimatedProps) {\n node && node.setProp(propName, reanimatedProps[propName].value);\n }\n // On React Native we use the SkiaViewApi to redraw because it can\n // run on the worklet thread (container.redraw can't)\n // if SkiaViewApi is undefined, we are on web and container.redraw()\n // can safely be invoked\n if (SkiaViewApi) {\n SkiaViewApi.requestRedraw(viewId);\n } else {\n container.redraw();\n }\n }, sharedValues);\n _bindings.set(node, mapperId);\n }\n}\n"],"mappings":"AAAA;;AACA;AAKA,SACEA,WADF,EAEEC,UAFF,EAGEC,aAHF,EAIEC,eAJF,EAKEC,eALF,EAMEC,OANF,QAOO,iBAPP;;AASA,MAAMC,SAAS,GAAG,IAAIC,OAAJ,EAAlB;;AAEA,OAAO,SAASC,sBAAT,CAAgCC,KAAhC,EAA2D;EAChE,IAAI,CAACN,eAAD,IAAoB,CAACC,eAAzB,EAA0C;IACxC,OAAO,CAACK,KAAD,EAAQ,EAAR,CAAP;EACD;;EACD,MAAMC,eAAe,GAAG,EAAxB;EACA,MAAMC,UAAU,GAAG,EAAnB;;EACA,KAAK,MAAMC,QAAX,IAAuBH,KAAvB,EAA8B;IAC5B,IAAIG,QAAQ,KAAK,UAAjB,EAA6B;MAC3B;IACD;;IACD,MAAMC,SAAS,GAAGJ,KAAK,CAACG,QAAD,CAAvB;;IACA,IAAIV,aAAa,CAACW,SAAD,CAAjB,EAA8B;MAC5BH,eAAe,CAACE,QAAD,CAAf,GAA4BC,SAA5B;MACAF,UAAU,CAACC,QAAD,CAAV,GAAuBC,SAAS,CAACC,KAAjC;IACD,CAHD,MAGO;MACLH,UAAU,CAACC,QAAD,CAAV,GAAuBC,SAAvB;IACD;EACF;;EACD,OAAO,CAACF,UAAD,EAAaD,eAAb,CAAP;AACD;;AAED,SAASK,oBAAT,CACEC,SADF,EAEEC,IAFF,EAGEP,eAHF,EAIE;EACA,MAAMQ,YAAY,GAAGC,MAAM,CAACC,MAAP,CAAcV,eAAd,CAArB;;EACA,MAAMW,gBAAgB,GAAGf,SAAS,CAACgB,GAAV,CAAcL,IAAd,CAAzB;;EACA,IAAII,gBAAgB,KAAKE,SAAzB,EAAoC;IAClCtB,UAAU,CAACoB,gBAAD,CAAV;EACD;;EACD,IAAIH,YAAY,CAACM,MAAb,GAAsB,C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,GAAGjC,WAAW,CAAC,MAAM;MACjC;;MACA,KAAK,MAAMY,QAAX,IAAuBF,eAAvB,EAAwC;QACtCO,IAAI,IAAIA,IAAI,CAACa,OAAL,CAAalB,QAAb,EAAuBF,eAAe,CAACE,QAAD,CAAf,CAA0BE,KAAjD,CAAR;MACD,CAJgC,CAKjC;MACA;MACA;MACA;;;MACA,IAAIa,WAAJ,EAAiB;QACfA,WAAW,CAACI,aAAZ,CAA0BN,MAA1B;MACD,CAFD,MAEO;QACLT,SAAS,CAACgB,MAAV;MACD;IACF,CAd2B,EAczBd,YAdyB,CAA5B;;IAeAZ,SAAS,CAAC4B,GAAV,CAAcjB,IAAd,EAAoBgB,QAApB;EACD;AACF"}
1
+ {"version":3,"names":["startMapper","stopMapper","isSharedValue","HAS_REANIMATED3","HAS_REANIMATED2","runOnJS","_bindings","WeakMap","unbindReanimatedNode","node","previousMapperId","get","undefined","extractReanimatedProps","props","reanimatedProps","otherProps","propName","propValue","value","bindReanimatedProps2","container","sharedValues","Object","values","length","viewId","getNativeId","SkiaViewApi","global","updateProps","setProp","requestRedraw","redraw","mapperId","set","bindReanimatedProps"],"sources":["renderHelpers.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable reanimated/js-function-in-worklet */\nimport type { Container } from \"../../renderer/Container\";\nimport type { AnimatedProps } from \"../../renderer/processors\";\nimport type { Node } from \"../../dom/types\";\n\nimport {\n startMapper,\n stopMapper,\n isSharedValue,\n HAS_REANIMATED3,\n HAS_REANIMATED2,\n runOnJS,\n} from \"./moduleWrapper\";\n\nconst _bindings = new WeakMap<Node<unknown>, unknown>();\n\nexport const unbindReanimatedNode = (node: Node<unknown>) => {\n const previousMapperId = _bindings.get(node);\n if (previousMapperId !== undefined) {\n stopMapper(previousMapperId as number);\n }\n};\n\nexport function extractReanimatedProps(props: AnimatedProps<any>) {\n if (!HAS_REANIMATED3 && !HAS_REANIMATED2) {\n return [props, {}];\n }\n const reanimatedProps = {} as AnimatedProps<any>;\n const otherProps = {} as AnimatedProps<any>;\n for (const propName in props) {\n if (propName === \"children\") {\n continue;\n }\n const propValue = props[propName];\n if (isSharedValue(propValue)) {\n reanimatedProps[propName] = propValue;\n otherProps[propName] = propValue.value;\n } else {\n otherProps[propName] = propValue;\n }\n }\n return [otherProps, reanimatedProps];\n}\n\nfunction bindReanimatedProps2(\n container: Container,\n node: Node<any>,\n reanimatedProps: AnimatedProps<any>\n) {\n const sharedValues = Object.values(reanimatedProps);\n const previousMapperId = _bindings.get(node);\n if (previousMapperId !== undefined) {\n stopMapper(previousMapperId as number);\n }\n if (sharedValues.length > 0) {\n const viewId = container.getNativeId();\n const { SkiaViewApi } = global;\n const updateProps = () => {\n for (const propName in reanimatedProps) {\n node && node.setProp(propName, reanimatedProps[propName].value);\n }\n // On React Native we use the SkiaViewApi to redraw because it can\n // run on the worklet thread (container.redraw can't)\n // if SkiaViewApi is undefined, we are on web and container.redraw()\n // can safely be invoked\n if (SkiaViewApi) {\n SkiaViewApi.requestRedraw(viewId);\n } else {\n container.redraw();\n }\n };\n const mapperId = startMapper(() => {\n \"worklet\";\n runOnJS(updateProps)();\n }, sharedValues);\n _bindings.set(node, mapperId);\n }\n}\n\nexport function bindReanimatedProps(\n container: Container,\n node: Node<any>,\n reanimatedProps: AnimatedProps<any>\n) {\n if (HAS_REANIMATED2 && !HAS_REANIMATED3) {\n return bindReanimatedProps2(container, node, reanimatedProps);\n }\n if (!HAS_REANIMATED3) {\n return;\n }\n const sharedValues = Object.values(reanimatedProps);\n const previousMapperId = _bindings.get(node);\n if (previousMapperId !== undefined) {\n stopMapper(previousMapperId as number);\n }\n if (sharedValues.length > 0) {\n const viewId = container.getNativeId();\n const { SkiaViewApi } = global;\n const mapperId = startMapper(() => {\n \"worklet\";\n if (node) {\n for (const propName in reanimatedProps) {\n node.setProp(propName, reanimatedProps[propName].value);\n }\n }\n // On React Native we use the SkiaViewApi to redraw because it can\n // run on the worklet thread (container.redraw can't)\n // if SkiaViewApi is undefined, we are on web and container.redraw()\n // can safely be invoked\n if (SkiaViewApi) {\n SkiaViewApi.requestRedraw(viewId);\n } else {\n container.redraw();\n }\n }, sharedValues);\n _bindings.set(node, mapperId);\n }\n}\n"],"mappings":"AAAA;;AACA;AAKA,SACEA,WADF,EAEEC,UAFF,EAGEC,aAHF,EAIEC,eAJF,EAKEC,eALF,EAMEC,OANF,QAOO,iBAPP;;AASA,MAAMC,SAAS,GAAG,IAAIC,OAAJ,EAAlB;;AAEA,OAAO,MAAMC,oBAAoB,GAAIC,IAAD,IAAyB;EAC3D,MAAMC,gBAAgB,GAAGJ,SAAS,CAACK,GAAV,CAAcF,IAAd,CAAzB;;EACA,IAAIC,gBAAgB,KAAKE,SAAzB,EAAoC;IAClCX,UAAU,CAACS,gBAAD,CAAV;EACD;AACF,CALM;AAOP,OAAO,SAASG,sBAAT,CAAgCC,KAAhC,EAA2D;EAChE,IAAI,CAACX,eAAD,IAAoB,CAACC,eAAzB,EAA0C;IACxC,OAAO,CAACU,KAAD,EAAQ,EAAR,CAAP;EACD;;EACD,MAAMC,eAAe,GAAG,EAAxB;EACA,MAAMC,UAAU,GAAG,EAAnB;;EACA,KAAK,MAAMC,QAAX,IAAuBH,KAAvB,EAA8B;IAC5B,IAAIG,QAAQ,KAAK,UAAjB,EAA6B;MAC3B;IACD;;IACD,MAAMC,SAAS,GAAGJ,KAAK,CAACG,QAAD,CAAvB;;IACA,IAAIf,aAAa,CAACgB,SAAD,CAAjB,EAA8B;MAC5BH,eAAe,CAACE,QAAD,CAAf,GAA4BC,SAA5B;MACAF,UAAU,CAACC,QAAD,CAAV,GAAuBC,SAAS,CAACC,KAAjC;IACD,CAHD,MAGO;MACLH,UAAU,CAACC,QAAD,CAAV,GAAuBC,SAAvB;IACD;EACF;;EACD,OAAO,CAACF,UAAD,EAAaD,eAAb,CAAP;AACD;;AAED,SAASK,oBAAT,CACEC,SADF,EAEEZ,IAFF,EAGEM,eAHF,EAIE;EACA,MAAMO,YA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Ad,CAAzB;;EACA,IAAIC,gBAAgB,KAAKE,SAAzB,EAAoC;IAClCX,UAAU,CAACS,gBAAD,CAAV;EACD;;EACD,IAAIY,YAAY,CAACG,MAAb,GAAsB,CAA1B,EAA6B;IAC3B,MAAMC,MAAM,GAAGL,SAAS,CAACM,WAAV,EAAf;IACA,MAAM;MAAEC;IAAF,IAAkBC,MAAxB;IACA,MAAMK,QAAQ,GAAGlC,WAAW,CAAC,MAAM;MACjC;;MACA,IAAIS,IAAJ,EAAU;QACR,KAAK,MAAMQ,QAAX,IAAuBF,eAAvB,EAAwC;UACtCN,IAAI,CAACsB,OAAL,CAAad,QAAb,EAAuBF,eAAe,CAACE,QAAD,CAAf,CAA0BE,KAAjD;QACD;MACF,CANgC,CAOjC;MACA;MACA;MACA;;;MACA,IAAIS,WAAJ,EAAiB;QACfA,WAAW,CAACI,aAAZ,CAA0BN,MAA1B;MACD,CAFD,MAEO;QACLL,SAAS,CAACY,MAAV;MACD;IACF,CAhB2B,EAgBzBX,YAhByB,CAA5B;;IAiBAhB,SAAS,CAAC6B,GAAV,CAAc1B,IAAd,EAAoByB,QAApB;EACD;AACF"}
@@ -1,6 +1,6 @@
1
1
  /*global NodeJS*/
2
2
  import { DefaultEventPriority } from "react-reconciler/constants";
3
- import { bindReanimatedProps, extractReanimatedProps } from "../external/reanimated/renderHelpers";
3
+ import { bindReanimatedProps, extractReanimatedProps, unbindReanimatedNode } from "../external/reanimated/renderHelpers";
4
4
  import { createNode } from "./HostComponents";
5
5
  import { isSelector, isValue } from "./processors";
6
6
  import { mapKeys, shallowEq } from "./typeddash";
@@ -16,6 +16,7 @@ const appendNode = (parent, child) => {
16
16
  };
17
17
 
18
18
  const removeNode = (parent, child) => {
19
+ unbindReanimatedNode(child);
19
20
  return parent.removeChild(child);
20
21
  };
21
22
 
@@ -1 +1 @@
1
- {"version":3,"names":["DefaultEventPriority","bindReanimatedProps","extractReanimatedProps","createNode","isSelector","isValue","mapKeys","shallowEq","DEBUG","debug","console","log","appendNode","parent","child","addChild","removeNode","removeChild","insertBefore","before","insertChildBefore","skHostConfig","now","Date","supportsMutation","isPrimaryRenderer","supportsPersistence","supportsHydration","scheduleTimeout","setTimeout","cancelTimeout","clearTimeout","noTimeout","appendChildToContainer","container","root","appendChild","getRootHostContext","_rootContainerInstance","getChildHostContext","_parentHostContext","_type","shouldSetTextContent","_props","createTextInstance","_text","_hostContext","_internalInstanceHandle","Error","createInstance","type","pristineProps","props","reanimatedProps","node","materialize","depMgr","subscribeNode","appendInitialChild","parentInstance","finalizeInitialChildren","commitMount","prepareForCommit","_containerInfo","resetAfterCommit","update","redraw","getPublicInstance","prepareUpdate","_instance","oldProps","newProps","rootContainerInstance","propsAreEqual","commitUpdate","instance","updatePayload","prevProps","nextProps","_internalHandle","unsubscribeNode","setProps","commitTextUpdate","_textInstance","_oldText","_newText","clearContainer","children","forEach","preparePortalMount","removeChildFromContainer","insertInContainerBefore","getCurrentEventPriority","beforeActiveInstanceBlur","afterActiveInstanceBlur","detachDeletedInstance","result","key","prop","current","selector","value"],"sources":["HostConfig.ts"],"sourcesContent":["/*global NodeJS*/\nimport type { HostConfig } from \"react-reconciler\";\nimport { DefaultEventPriority } from \"react-reconciler/constants\";\n\nimport type { NodeType, Node } from \"../dom/types\";\nimport type { SkiaValue } from \"../values\";\nimport {\n bindReanimatedProps,\n extractReanimatedProps,\n} from \"../external/reanimated/renderHelpers\";\n\nimport type { Container } from \"./Container\";\nimport { createNode } from \"./HostComponents\";\nimport type { AnimatedProps } from \"./processors\";\nimport { isSelector, isValue } from \"./processors\";\nimport { mapKeys, shallowEq } from \"./typeddash\";\n\nconst DEBUG = false;\nexport const debug = (...args: Parameters<typeof console.log>) => {\n if (DEBUG) {\n console.log(...args);\n }\n};\n\ntype Instance = Node<unknown>;\n\ntype Props = object;\ntype TextInstance = Node<unknown>;\ntype SuspenseInstance = Instance;\ntype HydratableInstance = Instance;\ntype PublicInstance = Instance;\ntype HostContext = null;\ntype UpdatePayload = Container;\ntype ChildSet = unknown;\ntype TimeoutHandle = NodeJS.Timeout;\ntype NoTimeout = -1;\n\ntype SkiaHostConfig = HostConfig<\n NodeType,\n Props,\n Container,\n Instance,\n TextInstance,\n SuspenseInstance,\n HydratableInstance,\n PublicInstance,\n HostContext,\n UpdatePayload,\n ChildSet,\n TimeoutHandle,\n NoTimeout\n>;\n\nconst appendNode = (parent: Node<unknown>, child: Node<unknown>) => {\n parent.addChild(child);\n};\n\nconst removeNode = (parent: Node<unknown>, child: Node<unknown>) => {\n return parent.removeChild(child);\n};\n\nconst insertBefore = (\n parent: Node<unknown>,\n child: Node<unknown>,\n before: Node<unknown>\n) => {\n parent.insertChildBefore(child, before);\n};\n\nexport const skHostConfig: SkiaHostConfig = {\n /**\n * This function is used by the reconciler in order to calculate current time for prioritising work.\n */\n now: Date.now,\n supportsMutation: true,\n isPrimaryRenderer: false,\n supportsPersistence: false,\n supportsHydration: false,\n //supportsMicrotask: true,\n\n scheduleTimeout: setTimeout,\n cancelTimeout: clearTimeout,\n noTimeout: -1,\n\n appendChildToContainer(container, child) {\n debug(\"appendChildToContainer\", container, child);\n appendNode(container.root, child);\n },\n\n appendChild(parent, child) {\n debug(\"appendChild\", parent, child);\n appendNode(parent, child);\n },\n\n getRootHostContext: (_rootContainerInstance: Container) => {\n debug(\"getRootHostContext\");\n return null;\n },\n\n getChildHostContext(_parentHostContext, _type, _rootContainerInstance) {\n debug(\"getChildHostContext\");\n return null;\n },\n\n shouldSetTextContent(_type, _props) {\n return false;\n },\n\n createTextInstance(\n _text,\n _rootContainerInstance,\n _hostContext,\n _internalInstanceHandle\n ) {\n debug(\"createTextInstance\");\n // return SpanNode({}, text) as SkNode;\n throw new Error(\"Text nodes are not supported yet\");\n },\n\n createInstance(\n type,\n pristineProps,\n container,\n _hostContext,\n _internalInstanceHandle\n ) {\n debug(\"createInstance\", type);\n const [props, reanimatedProps] = extractReanimatedProps(pristineProps);\n const node = createNode(container, type, materialize(props));\n bindReanimatedProps(container, node, reanimatedProps);\n container.depMgr.subscribeNode(node, props);\n return node;\n },\n\n appendInitialChild(parentInstance, child) {\n debug(\"appendInitialChild\");\n appendNode(parentInstance, child);\n },\n\n finalizeInitialChildren(\n parentInstance,\n _type,\n _props,\n _rootContainerInstance,\n _hostContext\n ) {\n debug(\"finalizeInitialChildren\", parentInstance);\n return false;\n },\n\n commitMount() {\n // if finalizeInitialChildren = true\n debug(\"commitMount\");\n },\n\n prepareForCommit(_containerInfo) {\n debug(\"prepareForCommit\");\n return null;\n },\n\n resetAfterCommit(container) {\n debug(\"resetAfterCommit\");\n container.depMgr.update();\n container.redraw();\n },\n\n getPublicInstance(node: Instance) {\n debug(\"getPublicInstance\");\n return node;\n },\n\n prepareUpdate: (\n _instance,\n type,\n oldProps,\n newProps,\n rootContainerInstance,\n _hostContext\n ) => {\n debug(\"prepareUpdate\");\n const propsAreEqual = shallowEq(oldProps, newProps);\n if (propsAreEqual) {\n return null;\n }\n debug(\"update \", type);\n return rootContainerInstance;\n },\n\n commitUpdate(\n instance,\n updatePayload,\n type,\n prevProps,\n nextProps,\n _internalHandle\n ) {\n debug(\"commitUpdate: \", type);\n if (shallowEq(prevProps, nextProps)) {\n return;\n }\n const [props, reanimatedProps] = extractReanimatedProps(nextProps);\n updatePayload.depMgr.unsubscribeNode(instance);\n instance.setProps(materialize(props));\n bindReanimatedProps(updatePayload, instance, reanimatedProps);\n updatePayload.depMgr.subscribeNode(instance, props);\n },\n\n commitTextUpdate: (\n _textInstance: TextInstance,\n _oldText: string,\n _newText: string\n ) => {\n // textInstance.instance = newText;\n },\n\n clearContainer: (container) => {\n debug(\"clearContainer\");\n container.root.children().forEach((child) => {\n container.root.removeChild(child);\n });\n },\n\n preparePortalMount: () => {\n debug(\"preparePortalMount\");\n },\n\n removeChild: (parent, child) => {\n removeNode(parent, child);\n },\n\n removeChildFromContainer: (container, child) => {\n removeNode(container.root, child);\n },\n\n insertInContainerBefore: (container, child, before) => {\n insertBefore(container.root, child, before);\n },\n\n insertBefore: (parent, child, before) => {\n insertBefore(parent, child, before);\n },\n // see https://github.com/pmndrs/react-three-fiber/pull/2360#discussion_r916356874\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n getCurrentEventPriority: () => DefaultEventPriority,\n beforeActiveInstanceBlur: () => {},\n afterActiveInstanceBlur: () => {},\n detachDeletedInstance: () => {},\n};\n\nconst materialize = <P>(props: AnimatedProps<P>) => {\n const result = { ...props } as P;\n mapKeys(props).forEach((key) => {\n const prop = props[key];\n if (isValue(prop)) {\n result[key] = (prop as SkiaValue<P[typeof key]>).current;\n } else if (isSelector(prop)) {\n result[key] = prop.selector(prop.value.current) as P[typeof key];\n }\n });\n\n return result;\n};\n"],"mappings":"AAAA;AAEA,SAASA,oBAAT,QAAqC,4BAArC;AAIA,SACEC,mBADF,EAEEC,sBAFF,QAGO,sCAHP;AAMA,SAASC,UAAT,QAA2B,kBAA3B;AAEA,SAASC,UAAT,EAAqBC,OAArB,QAAoC,cAApC;AACA,SAASC,OAAT,EAAkBC,SAAlB,QAAmC,aAAnC;AAEA,MAAMC,KAAK,GAAG,KAAd;AACA,OAAO,MAAMC,KAAK,GAAG,YAA6C;EAChE,IAAID,KAAJ,EAAW;IACTE,OAAO,CAACC,GAAR,CAAY,YAAZ;EACD;AACF,CAJM;;AAmCP,MAAMC,UAAU,GAAG,CAACC,MAAD,EAAwBC,KAAxB,KAAiD;EAClED,MAAM,CAACE,QAAP,CAAgBD,KAAhB;AACD,CAFD;;AAIA,MAAME,UAAU,GAAG,CAACH,MAAD,EAAwBC,KAAxB,KAAiD;EAClE,OAAOD,MAAM,CAACI,WAAP,CAAmBH,KAAnB,CAAP;AACD,CAFD;;AAIA,MAAMI,YAAY,GAAG,CACnBL,MADmB,EAEnBC,KAFmB,EAGnBK,MAHmB,KAIhB;EACHN,MAAM,CAACO,iBAAP,CAAyBN,KAAzB,EAAgCK,MAAhC;AACD,CAND;;AAQA,OAAO,MAAME,YAA4B,GAAG;EAC1C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AI,CAACG,KAAL,CAAWF,OAAzB,CAAd;IACD;EACF,CAPD;EASA,OAAOH,MAAP;AACD,CAZD"}
1
+ {"version":3,"names":["DefaultEventPriority","bindReanimatedProps","extractReanimatedProps","unbindReanimatedNode","createNode","isSelector","isValue","mapKeys","shallowEq","DEBUG","debug","console","log","appendNode","parent","child","addChild","removeNode","removeChild","insertBefore","before","insertChildBefore","skHostConfig","now","Date","supportsMutation","isPrimaryRenderer","supportsPersistence","supportsHydration","scheduleTimeout","setTimeout","cancelTimeout","clearTimeout","noTimeout","appendChildToContainer","container","root","appendChild","getRootHostContext","_rootContainerInstance","getChildHostContext","_parentHostContext","_type","shouldSetTextContent","_props","createTextInstance","_text","_hostContext","_internalInstanceHandle","Error","createInstance","type","pristineProps","props","reanimatedProps","node","materialize","depMgr","subscribeNode","appendInitialChild","parentInstance","finalizeInitialChildren","commitMount","prepareForCommit","_containerInfo","resetAfterCommit","update","redraw","getPublicInstance","prepareUpdate","_instance","oldProps","newProps","rootContainerInstance","propsAreEqual","commitUpdate","instance","updatePayload","prevProps","nextProps","_internalHandle","unsubscribeNode","setProps","commitTextUpdate","_textInstance","_oldText","_newText","clearContainer","children","forEach","preparePortalMount","removeChildFromContainer","insertInContainerBefore","getCurrentEventPriority","beforeActiveInstanceBlur","afterActiveInstanceBlur","detachDeletedInstance","result","key","prop","current","selector","value"],"sources":["HostConfig.ts"],"sourcesContent":["/*global NodeJS*/\nimport type { HostConfig } from \"react-reconciler\";\nimport { DefaultEventPriority } from \"react-reconciler/constants\";\n\nimport type { NodeType, Node } from \"../dom/types\";\nimport type { SkiaValue } from \"../values\";\nimport {\n bindReanimatedProps,\n extractReanimatedProps,\n unbindReanimatedNode,\n} from \"../external/reanimated/renderHelpers\";\n\nimport type { Container } from \"./Container\";\nimport { createNode } from \"./HostComponents\";\nimport type { AnimatedProps } from \"./processors\";\nimport { isSelector, isValue } from \"./processors\";\nimport { mapKeys, shallowEq } from \"./typeddash\";\n\nconst DEBUG = false;\nexport const debug = (...args: Parameters<typeof console.log>) => {\n if (DEBUG) {\n console.log(...args);\n }\n};\n\ntype Instance = Node<unknown>;\n\ntype Props = object;\ntype TextInstance = Node<unknown>;\ntype SuspenseInstance = Instance;\ntype HydratableInstance = Instance;\ntype PublicInstance = Instance;\ntype HostContext = null;\ntype UpdatePayload = Container;\ntype ChildSet = unknown;\ntype TimeoutHandle = NodeJS.Timeout;\ntype NoTimeout = -1;\n\ntype SkiaHostConfig = HostConfig<\n NodeType,\n Props,\n Container,\n Instance,\n TextInstance,\n SuspenseInstance,\n HydratableInstance,\n PublicInstance,\n HostContext,\n UpdatePayload,\n ChildSet,\n TimeoutHandle,\n NoTimeout\n>;\n\nconst appendNode = (parent: Node<unknown>, child: Node<unknown>) => {\n parent.addChild(child);\n};\n\nconst removeNode = (parent: Node<unknown>, child: Node<unknown>) => {\n unbindReanimatedNode(child);\n return parent.removeChild(child);\n};\n\nconst insertBefore = (\n parent: Node<unknown>,\n child: Node<unknown>,\n before: Node<unknown>\n) => {\n parent.insertChildBefore(child, before);\n};\n\nexport const skHostConfig: SkiaHostConfig = {\n /**\n * This function is used by the reconciler in order to calculate current time for prioritising work.\n */\n now: Date.now,\n supportsMutation: true,\n isPrimaryRenderer: false,\n supportsPersistence: false,\n supportsHydration: false,\n //supportsMicrotask: true,\n\n scheduleTimeout: setTimeout,\n cancelTimeout: clearTimeout,\n noTimeout: -1,\n\n appendChildToContainer(container, child) {\n debug(\"appendChildToContainer\", container, child);\n appendNode(container.root, child);\n },\n\n appendChild(parent, child) {\n debug(\"appendChild\", parent, child);\n appendNode(parent, child);\n },\n\n getRootHostContext: (_rootContainerInstance: Container) => {\n debug(\"getRootHostContext\");\n return null;\n },\n\n getChildHostContext(_parentHostContext, _type, _rootContainerInstance) {\n debug(\"getChildHostContext\");\n return null;\n },\n\n shouldSetTextContent(_type, _props) {\n return false;\n },\n\n createTextInstance(\n _text,\n _rootContainerInstance,\n _hostContext,\n _internalInstanceHandle\n ) {\n debug(\"createTextInstance\");\n // return SpanNode({}, text) as SkNode;\n throw new Error(\"Text nodes are not supported yet\");\n },\n\n createInstance(\n type,\n pristineProps,\n container,\n _hostContext,\n _internalInstanceHandle\n ) {\n debug(\"createInstance\", type);\n const [props, reanimatedProps] = extractReanimatedProps(pristineProps);\n const node = createNode(container, type, materialize(props));\n bindReanimatedProps(container, node, reanimatedProps);\n container.depMgr.subscribeNode(node, props);\n return node;\n },\n\n appendInitialChild(parentInstance, child) {\n debug(\"appendInitialChild\");\n appendNode(parentInstance, child);\n },\n\n finalizeInitialChildren(\n parentInstance,\n _type,\n _props,\n _rootContainerInstance,\n _hostContext\n ) {\n debug(\"finalizeInitialChildren\", parentInstance);\n return false;\n },\n\n commitMount() {\n // if finalizeInitialChildren = true\n debug(\"commitMount\");\n },\n\n prepareForCommit(_containerInfo) {\n debug(\"prepareForCommit\");\n return null;\n },\n\n resetAfterCommit(container) {\n debug(\"resetAfterCommit\");\n container.depMgr.update();\n container.redraw();\n },\n\n getPublicInstance(node: Instance) {\n debug(\"getPublicInstance\");\n return node;\n },\n\n prepareUpdate: (\n _instance,\n type,\n oldProps,\n newProps,\n rootContainerInstance,\n _hostContext\n ) => {\n debug(\"prepareUpdate\");\n const propsAreEqual = shallowEq(oldProps, newProps);\n if (propsAreEqual) {\n return null;\n }\n debug(\"update \", type);\n return rootContainerInstance;\n },\n\n commitUpdate(\n instance,\n updatePayload,\n type,\n prevProps,\n nextProps,\n _internalHandle\n ) {\n debug(\"commitUpdate: \", type);\n if (shallowEq(prevProps, nextProps)) {\n return;\n }\n const [props, reanimatedProps] = extractReanimatedProps(nextProps);\n updatePayload.depMgr.unsubscribeNode(instance);\n instance.setProps(materialize(props));\n bindReanimatedProps(updatePayload, instance, reanimatedProps);\n updatePayload.depMgr.subscribeNode(instance, props);\n },\n\n commitTextUpdate: (\n _textInstance: TextInstance,\n _oldText: string,\n _newText: string\n ) => {\n // textInstance.instance = newText;\n },\n\n clearContainer: (container) => {\n debug(\"clearContainer\");\n container.root.children().forEach((child) => {\n container.root.removeChild(child);\n });\n },\n\n preparePortalMount: () => {\n debug(\"preparePortalMount\");\n },\n\n removeChild: (parent, child) => {\n removeNode(parent, child);\n },\n\n removeChildFromContainer: (container, child) => {\n removeNode(container.root, child);\n },\n\n insertInContainerBefore: (container, child, before) => {\n insertBefore(container.root, child, before);\n },\n\n insertBefore: (parent, child, before) => {\n insertBefore(parent, child, before);\n },\n // see https://github.com/pmndrs/react-three-fiber/pull/2360#discussion_r916356874\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n getCurrentEventPriority: () => DefaultEventPriority,\n beforeActiveInstanceBlur: () => {},\n afterActiveInstanceBlur: () => {},\n detachDeletedInstance: () => {},\n};\n\nconst materialize = <P>(props: AnimatedProps<P>) => {\n const result = { ...props } as P;\n mapKeys(props).forEach((key) => {\n const prop = props[key];\n if (isValue(prop)) {\n result[key] = (prop as SkiaValue<P[typeof key]>).current;\n } else if (isSelector(prop)) {\n result[key] = prop.selector(prop.value.current) as P[typeof key];\n }\n });\n\n return result;\n};\n"],"mappings":"AAAA;AAEA,SAASA,oBAAT,QAAqC,4BAArC;AAIA,SACEC,mBADF,EAEEC,sBAFF,EAGEC,oBAHF,QAIO,sCAJP;AAOA,SAASC,UAAT,QAA2B,kBAA3B;AAEA,SAASC,UAAT,EAAqBC,OAArB,QAAoC,cAApC;AACA,SAASC,OAAT,EAAkBC,SAAlB,QAAmC,aAAnC;AAEA,MAAMC,KAAK,GAAG,KAAd;AACA,OAAO,MAAMC,KAAK,GAAG,YAA6C;EAChE,IAAID,KAAJ,EAAW;IACTE,OAAO,CAACC,GAAR,CAAY,YAAZ;EACD;AACF,CAJM;;AAmCP,MAAMC,UAAU,GAAG,CAACC,MAAD,EAAwBC,KAAxB,KAAiD;EAClED,MAAM,CAACE,QAAP,CAAgBD,KAAhB;AACD,CAFD;;AAIA,MAAME,UAAU,GAAG,CAACH,MAAD,EAAwBC,KAAxB,KAAiD;EAClEZ,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AAG9C,KAAK,CAAC6C,GAAD,CAAlB;;IACA,IAAI5F,OAAO,CAAC6F,IAAD,CAAX,EAAmB;MACjBF,MAAM,CAACC,GAAD,CAAN,GAAeC,IAAD,CAAmCC,OAAjD;IACD,CAFD,MAEO,IAAI/F,UAAU,CAAC8F,IAAD,CAAd,EAAsB;MAC3BF,MAAM,CAACC,GAAD,CAAN,GAAcC,IAAI,CAACE,QAAL,CAAcF,IAAI,CAACG,KAAL,CAAWF,OAAzB,CAAd;IACD;EACF,CAPD;EASA,OAAOH,MAAP;AACD,CAZD"}
@@ -1,5 +1,6 @@
1
1
  import type { Container } from "../../renderer/Container";
2
2
  import type { AnimatedProps } from "../../renderer/processors";
3
3
  import type { Node } from "../../dom/types";
4
+ export declare const unbindReanimatedNode: (node: Node<unknown>) => void;
4
5
  export declare function extractReanimatedProps(props: AnimatedProps<any>): AnimatedProps<any, never>[];
5
6
  export declare function bindReanimatedProps(container: Container, node: Node<any>, reanimatedProps: AnimatedProps<any>): void;
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "setup-skia-web": "./scripts/setup-canvaskit.js"
8
8
  },
9
9
  "title": "React Native Skia",
10
- "version": "0.1.215",
10
+ "version": "0.1.216",
11
11
  "description": "High-performance React Native Graphics using Skia",
12
12
  "main": "lib/module/index.js",
13
13
  "files": [
@@ -15,6 +15,13 @@ import {
15
15
 
16
16
  const _bindings = new WeakMap<Node<unknown>, unknown>();
17
17
 
18
+ export const unbindReanimatedNode = (node: Node<unknown>) => {
19
+ const previousMapperId = _bindings.get(node);
20
+ if (previousMapperId !== undefined) {
21
+ stopMapper(previousMapperId as number);
22
+ }
23
+ };
24
+
18
25
  export function extractReanimatedProps(props: AnimatedProps<any>) {
19
26
  if (!HAS_REANIMATED3 && !HAS_REANIMATED2) {
20
27
  return [props, {}];
@@ -76,7 +83,7 @@ export function bindReanimatedProps(
76
83
  node: Node<any>,
77
84
  reanimatedProps: AnimatedProps<any>
78
85
  ) {
79
- if (HAS_REANIMATED2) {
86
+ if (HAS_REANIMATED2 && !HAS_REANIMATED3) {
80
87
  return bindReanimatedProps2(container, node, reanimatedProps);
81
88
  }
82
89
  if (!HAS_REANIMATED3) {
@@ -92,8 +99,10 @@ export function bindReanimatedProps(
92
99
  const { SkiaViewApi } = global;
93
100
  const mapperId = startMapper(() => {
94
101
  "worklet";
95
- for (const propName in reanimatedProps) {
96
- node && node.setProp(propName, reanimatedProps[propName].value);
102
+ if (node) {
103
+ for (const propName in reanimatedProps) {
104
+ node.setProp(propName, reanimatedProps[propName].value);
105
+ }
97
106
  }
98
107
  // On React Native we use the SkiaViewApi to redraw because it can
99
108
  // run on the worklet thread (container.redraw can't)
@@ -7,6 +7,7 @@ import type { SkiaValue } from "../values";
7
7
  import {
8
8
  bindReanimatedProps,
9
9
  extractReanimatedProps,
10
+ unbindReanimatedNode,
10
11
  } from "../external/reanimated/renderHelpers";
11
12
 
12
13
  import type { Container } from "./Container";
@@ -56,6 +57,7 @@ const appendNode = (parent: Node<unknown>, child: Node<unknown>) => {
56
57
  };
57
58
 
58
59
  const removeNode = (parent: Node<unknown>, child: Node<unknown>) => {
60
+ unbindReanimatedNode(child);
59
61
  return parent.removeChild(child);
60
62
  };
61
63