@shopify/react-native-skia 0.1.175 → 0.1.178

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. package/android/CMakeLists.txt +2 -0
  2. package/android/build.gradle +2 -1
  3. package/cpp/jsi/JsiHostObject.cpp +13 -7
  4. package/cpp/jsi/JsiHostObject.h +3 -1
  5. package/cpp/jsi/RuntimeAwareCache.cpp +9 -0
  6. package/cpp/jsi/RuntimeAwareCache.h +101 -0
  7. package/cpp/jsi/RuntimeLifecycleMonitor.cpp +57 -0
  8. package/cpp/jsi/RuntimeLifecycleMonitor.h +32 -0
  9. package/cpp/rnskia/RNSkJsView.cpp +1 -1
  10. package/cpp/rnskia/RNSkManager.cpp +4 -0
  11. package/cpp/rnskia/dom/base/JsiDomNode.h +22 -2
  12. package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.mm +12 -8
  13. package/lib/commonjs/external/reanimated/index.d.ts +1 -0
  14. package/lib/commonjs/external/reanimated/index.js +13 -0
  15. package/lib/commonjs/external/reanimated/index.js.map +1 -1
  16. package/lib/commonjs/external/reanimated/moduleWrapper.d.ts +8 -0
  17. package/lib/commonjs/external/reanimated/moduleWrapper.js +72 -0
  18. package/lib/commonjs/external/reanimated/moduleWrapper.js.map +1 -0
  19. package/lib/commonjs/external/reanimated/renderHelpers.d.ts +5 -0
  20. package/lib/commonjs/external/reanimated/renderHelpers.js +85 -0
  21. package/lib/commonjs/external/reanimated/renderHelpers.js.map +1 -0
  22. package/lib/commonjs/external/reanimated/useSharedValueEffect.d.ts +2 -5
  23. package/lib/commonjs/external/reanimated/useSharedValueEffect.js +10 -25
  24. package/lib/commonjs/external/reanimated/useSharedValueEffect.js.map +1 -1
  25. package/lib/commonjs/headless/index.d.ts +3 -0
  26. package/lib/commonjs/headless/index.js +57 -0
  27. package/lib/commonjs/headless/index.js.map +1 -0
  28. package/lib/commonjs/mock/index.d.ts +1 -2
  29. package/lib/commonjs/mock/index.js +0 -4
  30. package/lib/commonjs/mock/index.js.map +1 -1
  31. package/lib/commonjs/renderer/Canvas.js +7 -1
  32. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  33. package/lib/commonjs/renderer/Container.d.ts +2 -1
  34. package/lib/commonjs/renderer/Container.js +2 -0
  35. package/lib/commonjs/renderer/Container.js.map +1 -1
  36. package/lib/commonjs/renderer/HostConfig.js +6 -4
  37. package/lib/commonjs/renderer/HostConfig.js.map +1 -1
  38. package/lib/commonjs/renderer/Reconciler.d.ts +1 -1
  39. package/lib/commonjs/renderer/Reconciler.js +2 -1
  40. package/lib/commonjs/renderer/Reconciler.js.map +1 -1
  41. package/lib/commonjs/renderer/processors/Animations/Animations.d.ts +4 -1
  42. package/lib/commonjs/renderer/processors/Animations/Animations.js.map +1 -1
  43. package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js +8 -1
  44. package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js.map +1 -1
  45. package/lib/module/external/reanimated/index.d.ts +1 -0
  46. package/lib/module/external/reanimated/index.js +1 -0
  47. package/lib/module/external/reanimated/index.js.map +1 -1
  48. package/lib/module/external/reanimated/moduleWrapper.d.ts +8 -0
  49. package/lib/module/external/reanimated/moduleWrapper.js +51 -0
  50. package/lib/module/external/reanimated/moduleWrapper.js.map +1 -0
  51. package/lib/module/external/reanimated/renderHelpers.d.ts +5 -0
  52. package/lib/module/external/reanimated/renderHelpers.js +76 -0
  53. package/lib/module/external/reanimated/renderHelpers.js.map +1 -0
  54. package/lib/module/external/reanimated/useSharedValueEffect.d.ts +2 -5
  55. package/lib/module/external/reanimated/useSharedValueEffect.js +7 -22
  56. package/lib/module/external/reanimated/useSharedValueEffect.js.map +1 -1
  57. package/lib/module/headless/index.d.ts +3 -0
  58. package/lib/module/headless/index.js +29 -0
  59. package/lib/module/headless/index.js.map +1 -0
  60. package/lib/module/mock/index.d.ts +1 -2
  61. package/lib/module/mock/index.js +0 -3
  62. package/lib/module/mock/index.js.map +1 -1
  63. package/lib/module/renderer/Canvas.js +7 -1
  64. package/lib/module/renderer/Canvas.js.map +1 -1
  65. package/lib/module/renderer/Container.d.ts +2 -1
  66. package/lib/module/renderer/Container.js +2 -0
  67. package/lib/module/renderer/Container.js.map +1 -1
  68. package/lib/module/renderer/HostConfig.js +5 -4
  69. package/lib/module/renderer/HostConfig.js.map +1 -1
  70. package/lib/module/renderer/Reconciler.d.ts +1 -1
  71. package/lib/module/renderer/Reconciler.js +2 -1
  72. package/lib/module/renderer/Reconciler.js.map +1 -1
  73. package/lib/module/renderer/processors/Animations/Animations.d.ts +4 -1
  74. package/lib/module/renderer/processors/Animations/Animations.js.map +1 -1
  75. package/lib/module/skia/web/JsiSkSurfaceFactory.js +8 -1
  76. package/lib/module/skia/web/JsiSkSurfaceFactory.js.map +1 -1
  77. package/lib/typescript/src/external/reanimated/index.d.ts +1 -0
  78. package/lib/typescript/src/external/reanimated/moduleWrapper.d.ts +8 -0
  79. package/lib/typescript/src/external/reanimated/renderHelpers.d.ts +5 -0
  80. package/lib/typescript/src/external/reanimated/useSharedValueEffect.d.ts +2 -5
  81. package/lib/typescript/src/headless/index.d.ts +3 -0
  82. package/lib/typescript/src/mock/index.d.ts +1 -2
  83. package/lib/typescript/src/renderer/Container.d.ts +2 -1
  84. package/lib/typescript/src/renderer/Reconciler.d.ts +1 -1
  85. package/lib/typescript/src/renderer/processors/Animations/Animations.d.ts +4 -1
  86. package/libs/ios/libskia.xcframework/Info.plist +5 -5
  87. package/libs/ios/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
  88. package/libs/ios/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  89. package/libs/ios/libskottie.xcframework/Info.plist +5 -5
  90. package/libs/ios/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
  91. package/libs/ios/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
  92. package/libs/ios/libsksg.xcframework/Info.plist +5 -5
  93. package/libs/ios/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
  94. package/libs/ios/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
  95. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
  96. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  97. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
  98. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  99. package/package.json +1 -1
  100. package/react-native-skia.podspec +7 -26
  101. package/src/external/reanimated/index.ts +1 -0
  102. package/src/external/reanimated/moduleWrapper.ts +62 -0
  103. package/src/external/reanimated/renderHelpers.ts +74 -0
  104. package/src/external/reanimated/useSharedValueEffect.ts +17 -23
  105. package/src/headless/index.ts +31 -0
  106. package/src/mock/index.ts +0 -5
  107. package/src/renderer/Canvas.tsx +6 -2
  108. package/src/renderer/Container.tsx +2 -1
  109. package/src/renderer/HostConfig.ts +8 -2
  110. package/src/renderer/Reconciler.tsx +3 -2
  111. package/src/renderer/processors/Animations/Animations.ts +9 -1
  112. package/src/skia/web/JsiSkSurfaceFactory.ts +6 -3
@@ -7,51 +7,36 @@ exports.useSharedValueEffect = void 0;
7
7
 
8
8
  var _react = require("react");
9
9
 
10
- var _Reanimated;
10
+ var _moduleWrapper = require("./moduleWrapper");
11
11
 
12
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
- let Reanimated;
14
-
15
- try {
16
- Reanimated = require("react-native-reanimated");
17
- } catch (e) {// Ignore
18
- }
19
-
20
- const useSharedValueWrapper = ((_Reanimated = Reanimated) === null || _Reanimated === void 0 ? void 0 : _Reanimated.useSharedValue) === undefined ? value => (0, _react.useMemo)(() => ({
21
- value
22
- }), [value]) : Reanimated.useSharedValue;
23
12
  /**
24
13
  * Connects a shared value from reanimated to a SkiaView or Canvas
25
14
  * so whenever the shared value changes the SkiaView will redraw.
26
15
  * @param cb Callback that will be called whenever the shared value changes.
27
16
  * @param values One or more shared values to listen for.
28
17
  */
29
-
30
18
  const useSharedValueEffect = function (cb, value) {
31
19
  for (var _len = arguments.length, values = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
32
20
  values[_key - 2] = arguments[_key];
33
21
  }
34
22
 
35
- const input = useSharedValueWrapper(0);
23
+ console.warn(`useSharedValueEffect() is now deprecated, you can use Reanimated values directly.
24
+ Learn more at https://shopify.github.io/react-native-skia/.`);
25
+ const input = (0, _moduleWrapper.useSharedValue)(0);
36
26
  (0, _react.useEffect)(() => {
37
- if (!Reanimated) {
27
+ if (!_moduleWrapper.HAS_REANIMATED) {
38
28
  console.warn("Reanimated was not found and the useSharedValueEffect hook will have no effect.");
39
29
  } else {
40
- const {
41
- runOnJS,
42
- startMapper,
43
- stopMapper
44
- } = Reanimated; // Start a mapper in Reanimated
45
-
46
- const mapperId = startMapper(() => {
30
+ // Start a mapper in Reanimated
31
+ const mapperId = (0, _moduleWrapper.startMapper)(() => {
47
32
  "worklet";
48
33
 
49
- runOnJS(cb)();
34
+ (0, _moduleWrapper.runOnJS)(cb)();
50
35
  }, [value, ...values], [input]); // Return unregistering the mapper
51
36
 
52
37
  return () => {
53
- if (stopMapper && mapperId !== undefined) {
54
- stopMapper(mapperId);
38
+ if (_moduleWrapper.stopMapper && mapperId !== undefined) {
39
+ (0, _moduleWrapper.stopMapper)(mapperId);
55
40
  }
56
41
  };
57
42
  }
@@ -1 +1 @@
1
- {"version":3,"names":["Reanimated","require","e","useSharedValueWrapper","useSharedValue","undefined","value","useMemo","useSharedValueEffect","cb","values","input","useEffect","console","warn","runOnJS","startMapper","stopMapper","mapperId"],"sources":["useSharedValueEffect.ts"],"sourcesContent":["import { useEffect, useMemo } from \"react\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nlet Reanimated: any;\n\ntry {\n Reanimated = require(\"react-native-reanimated\");\n} catch (e) {\n // Ignore\n}\n\ntype SharedValueTypeWrapper<T = number> = {\n value: T;\n};\n\nconst useSharedValueWrapper =\n Reanimated?.useSharedValue === undefined\n ? (value: number) => useMemo(() => ({ value }), [value])\n : Reanimated.useSharedValue;\n\n/**\n * Connects a shared value from reanimated to a SkiaView or Canvas\n * so whenever the shared value changes the SkiaView will redraw.\n * @param cb Callback that will be called whenever the shared value changes.\n * @param values One or more shared values to listen for.\n */\nexport const useSharedValueEffect = <T = number>(\n cb: () => void,\n value: SharedValueTypeWrapper<T>,\n ...values: SharedValueTypeWrapper<T>[]\n) => {\n const input = useSharedValueWrapper(0);\n\n useEffect(() => {\n if (!Reanimated) {\n console.warn(\n \"Reanimated was not found and the useSharedValueEffect hook will have no effect.\"\n );\n } else {\n const { runOnJS, startMapper, stopMapper } = Reanimated;\n\n // Start a mapper in Reanimated\n const mapperId = startMapper(\n () => {\n \"worklet\";\n runOnJS(cb)();\n },\n [value, ...values],\n [input]\n );\n // Return unregistering the mapper\n return () => {\n if (stopMapper && mapperId !== undefined) {\n stopMapper(mapperId);\n }\n };\n }\n return () => {};\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [input, value, ...values]);\n};\n"],"mappings":";;;;;;;AAAA;;;;AAEA;AACA,IAAIA,UAAJ;;AAEA,IAAI;EACFA,UAAU,GAAGC,OAAO,CAAC,yBAAD,CAApB;AACD,CAFD,CAEE,OAAOC,CAAP,EAAU,CACV;AACD;;AAMD,MAAMC,qBAAqB,GACzB,gBAAAH,UAAU,UAAV,kDAAYI,cAAZ,MAA+BC,SAA/B,GACKC,KAAD,IAAmB,IAAAC,cAAA,EAAQ,OAAO;EAAED;AAAF,CAAP,CAAR,EAA2B,CAACA,KAAD,CAA3B,CADvB,GAEIN,UAAU,CAACI,cAHjB;AAKA;AACA;AACA;AACA;AACA;AACA;;AACO,MAAMI,oBAAoB,GAAG,UAClCC,EADkC,EAElCH,KAFkC,EAI/B;EAAA,kCADAI,MACA;IADAA,MACA;EAAA;;EACH,MAAMC,KAAK,GAAGR,qBAAqB,CAAC,CAAD,CAAnC;EAEA,IAAAS,gBAAA,EAAU,MAAM;IACd,IAAI,CAACZ,UAAL,EAAiB;MACfa,OAAO,CAACC,IAAR,CACE,iFADF;IAGD,CAJD,MAIO;MACL,MAAM;QAAEC,OAAF;QAAWC,WAAX;QAAwBC;MAAxB,IAAuCjB,UAA7C,CADK,CAGL;;MACA,MAAMkB,QAAQ,GAAGF,WAAW,CAC1B,MAAM;QACJ;;QACAD,OAAO,CAACN,EAAD,CAAP;MACD,CAJyB,EAK1B,CAACH,KAAD,EAAQ,GAAGI,MAAX,CAL0B,EAM1B,CAACC,KAAD,CAN0B,CAA5B,CAJK,CAYL;;MACA,OAAO,MAAM;QACX,IAAIM,UAAU,IAAIC,QAAQ,KAAKb,SAA/B,EAA0C;UACxCY,UAAU,CAACC,QAAD,CAAV;QACD;MACF,CAJD;IAKD;;IACD,OAAO,MAAM,CAAE,CAAf,CAxBc,CAyBd;EACD,CA1BD,EA0BG,CAACP,KAAD,EAAQL,KAAR,EAAe,GAAGI,MAAlB,CA1BH;AA2BD,CAlCM"}
1
+ {"version":3,"names":["useSharedValueEffect","cb","value","values","console","warn","input","useSharedValue","useEffect","HAS_REANIMATED","mapperId","startMapper","runOnJS","stopMapper","undefined"],"sources":["useSharedValueEffect.ts"],"sourcesContent":["import { useEffect } from \"react\";\n\nimport type { SharedValueType } from \"../../renderer/processors/Animations\";\n\nimport {\n HAS_REANIMATED,\n useSharedValue,\n runOnJS,\n startMapper,\n stopMapper,\n} from \"./moduleWrapper\";\n\n/**\n * Connects a shared value from reanimated to a SkiaView or Canvas\n * so whenever the shared value changes the SkiaView will redraw.\n * @param cb Callback that will be called whenever the shared value changes.\n * @param values One or more shared values to listen for.\n */\nexport const useSharedValueEffect = <T = number>(\n cb: () => void,\n value: SharedValueType<T>,\n ...values: SharedValueType<T>[]\n) => {\n console.warn(\n `useSharedValueEffect() is now deprecated, you can use Reanimated values directly.\nLearn more at https://shopify.github.io/react-native-skia/.`\n );\n const input = useSharedValue(0);\n\n useEffect(() => {\n if (!HAS_REANIMATED) {\n console.warn(\n \"Reanimated was not found and the useSharedValueEffect hook will have no effect.\"\n );\n } else {\n // Start a mapper in Reanimated\n const mapperId = startMapper(\n () => {\n \"worklet\";\n runOnJS(cb)();\n },\n [value, ...values],\n [input]\n );\n // Return unregistering the mapper\n return () => {\n if (stopMapper && mapperId !== undefined) {\n stopMapper(mapperId);\n }\n };\n }\n return () => {};\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [input, value, ...values]);\n};\n"],"mappings":";;;;;;;AAAA;;AAIA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,oBAAoB,GAAG,UAClCC,EADkC,EAElCC,KAFkC,EAI/B;EAAA,kCADAC,MACA;IADAA,MACA;EAAA;;EACHC,OAAO,CAACC,IAAR,CACG;AACL,4DAFE;EAIA,MAAMC,KAAK,GAAG,IAAAC,6BAAA,EAAe,CAAf,CAAd;EAEA,IAAAC,gBAAA,EAAU,MAAM;IACd,IAAI,CAACC,6BAAL,EAAqB;MACnBL,OAAO,CAACC,IAAR,CACE,iFADF;IAGD,CAJD,MAIO;MACL;MACA,MAAMK,QAAQ,GAAG,IAAAC,0BAAA,EACf,MAAM;QACJ;;QACA,IAAAC,sBAAA,EAAQX,EAAR;MACD,CAJc,EAKf,CAACC,KAAD,EAAQ,GAAGC,MAAX,CALe,EAMf,CAACG,KAAD,CANe,CAAjB,CAFK,CAUL;;MACA,OAAO,MAAM;QACX,IAAIO,yBAAA,IAAcH,QAAQ,KAAKI,SAA/B,EAA0C;UACxC,IAAAD,yBAAA,EAAWH,QAAX;QACD;MACF,CAJD;IAKD;;IACD,OAAO,MAAM,CAAE,CAAf,CAtBc,CAuBd;EACD,CAxBD,EAwBG,CAACJ,KAAD,EAAQJ,KAAR,EAAe,GAAGC,MAAlB,CAxBH;AAyBD,CApCM"}
@@ -0,0 +1,3 @@
1
+ import type { ReactNode } from "react";
2
+ export * from "../renderer/components";
3
+ export declare const draw: (element: ReactNode, width: number, height: number) => any;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _exportNames = {
7
+ draw: true
8
+ };
9
+ exports.draw = void 0;
10
+
11
+ var _web = require("../skia/web");
12
+
13
+ var _Reconciler = require("../renderer/Reconciler");
14
+
15
+ var _types = require("../dom/types");
16
+
17
+ var _components = require("../renderer/components");
18
+
19
+ Object.keys(_components).forEach(function (key) {
20
+ if (key === "default" || key === "__esModule") return;
21
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
22
+ if (key in exports && exports[key] === _components[key]) return;
23
+ Object.defineProperty(exports, key, {
24
+ enumerable: true,
25
+ get: function () {
26
+ return _components[key];
27
+ }
28
+ });
29
+ });
30
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
31
+ // @ts-ignore
32
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
33
+ let Skia;
34
+
35
+ const draw = (element, width, height) => {
36
+ if (!Skia) {
37
+ Skia = (0, _web.JsiSkApi)(CanvasKit);
38
+ }
39
+
40
+ const surface = Skia.Surface.MakeOffscreen(width, height);
41
+
42
+ if (surface === null) {
43
+ throw new Error("Couldn't create surface!");
44
+ }
45
+
46
+ const root = new _Reconciler.SkiaRoot(Skia);
47
+ root.render(element);
48
+ const canvas = surface.getCanvas();
49
+ const ctx = new _types.JsiDrawingContext(Skia, canvas);
50
+ root.dom.render(ctx);
51
+ surface.flush();
52
+ const image = surface.makeImageSnapshot();
53
+ return image;
54
+ };
55
+
56
+ exports.draw = draw;
57
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Skia","draw","element","width","height","JsiSkApi","CanvasKit","surface","Surface","MakeOffscreen","Error","root","SkiaRoot","render","canvas","getCanvas","ctx","JsiDrawingContext","dom","flush","image","makeImageSnapshot"],"sources":["index.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport CanvasKitInit from \"canvaskit-wasm/bin/full/canvaskit\";\nimport type { ReactNode } from \"react\";\n\nimport { JsiSkApi } from \"../skia/web\";\nimport { SkiaRoot } from \"../renderer/Reconciler\";\nimport { JsiDrawingContext } from \"../dom/types\";\n\nexport * from \"../renderer/components\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nlet Skia: any;\n\nexport const draw = (element: ReactNode, width: number, height: number) => {\n if (!Skia) {\n Skia = JsiSkApi(CanvasKit);\n }\n const surface = Skia.Surface.MakeOffscreen(width, height);\n if (surface === null) {\n throw new Error(\"Couldn't create surface!\");\n }\n const root = new SkiaRoot(Skia);\n root.render(element);\n const canvas = surface.getCanvas();\n const ctx = new JsiDrawingContext(Skia, canvas);\n root.dom.render(ctx);\n surface.flush();\n const image = surface.makeImageSnapshot();\n return image;\n};\n"],"mappings":";;;;;;;;;;AAKA;;AACA;;AACA;;AAEA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AATA;AACA;AAUA;AACA,IAAIA,IAAJ;;AAEO,MAAMC,IAAI,GAAG,CAACC,OAAD,EAAqBC,KAArB,EAAoCC,MAApC,KAAuD;EACzE,IAAI,CAACJ,IAAL,EAAW;IACTA,IAAI,GAAG,IAAAK,aAAA,EAASC,SAAT,CAAP;EACD;;EACD,MAAMC,OAAO,GAAGP,IAAI,CAACQ,OAAL,CAAaC,aAAb,CAA2BN,KAA3B,EAAkCC,MAAlC,CAAhB;;EACA,IAAIG,OAAO,KAAK,IAAhB,EAAsB;IACpB,MAAM,IAAIG,KAAJ,CAAU,0BAAV,CAAN;EACD;;EACD,MAAMC,IAAI,GAAG,IAAIC,oBAAJ,CAAaZ,IAAb,CAAb;EACAW,IAAI,CAACE,MAAL,CAAYX,OAAZ;EACA,MAAMY,MAAM,GAAGP,OAAO,CAACQ,SAAR,EAAf;EACA,MAAMC,GAAG,GAAG,IAAIC,wBAAJ,CAAsBjB,IAAtB,EAA4Bc,MAA5B,CAAZ;EACAH,IAAI,CAACO,GAAL,CAASL,MAAT,CAAgBG,GAAhB;EACAT,OAAO,CAACY,KAAR;EACA,MAAMC,KAAK,GAAGb,OAAO,CAACc,iBAAR,EAAd;EACA,OAAOD,KAAP;AACD,CAhBM"}
@@ -1,6 +1,5 @@
1
1
  import type { Skia as SkiaApi } from "../skia/types";
2
2
  import type * as SkiaExports from "../skia";
3
- import type * as ExternalExports from "../external";
4
3
  import type * as ValueExports from "../values";
5
4
  import type * as AnimationExports from "../animation";
6
5
  import { ShaderLib } from "../renderer/components/shaders/ShaderLib";
@@ -9,7 +8,7 @@ export declare const vec: (x?: number, y?: number) => {
9
8
  x: number;
10
9
  y: number;
11
10
  };
12
- export declare const Mock: typeof SkiaExports & typeof ExternalExports & typeof ValueExports & typeof AnimationExports & {
11
+ export declare const Mock: typeof SkiaExports & typeof ValueExports & typeof AnimationExports & {
13
12
  createDrawing: () => any;
14
13
  createDeclaration: () => any;
15
14
  ShaderLib: typeof ShaderLib;
@@ -13,8 +13,6 @@ var _selector = require("../values/selector");
13
13
 
14
14
  var BaseSkia = _interopRequireWildcard(require("../skia/types"));
15
15
 
16
- var _useSharedValueEffect = require("../external/reanimated/useSharedValueEffect");
17
-
18
16
  var timingFunctions = _interopRequireWildcard(require("../animation/timing"));
19
17
 
20
18
  var springFunctions = _interopRequireWildcard(require("../animation/spring"));
@@ -105,8 +103,6 @@ const Mock = {
105
103
  bottomRight: Noop,
106
104
  center: Noop,
107
105
  processTransform2d: Noop,
108
- // ExternalExports
109
- useSharedValueEffect: _useSharedValueEffect.useSharedValueEffect,
110
106
  // ValueExports
111
107
  ...Values,
112
108
  ...ValuesHooks,
@@ -1 +1 @@
1
- {"version":3,"names":["Stub","constructor","Proxy","get","apply","set","Noop","Skia","vec","x","y","Mock","BaseSkia","useRawData","useData","useFont","useTypeface","useImage","useSVG","createPicture","rect","width","height","rrect","r","rx","ry","point","add","a","b","sub","neg","dist","Math","hypot","translate","translateX","translateY","bounds","topLeft","topRight","bottomLeft","bottomRight","center","processTransform2d","useSharedValueEffect","Values","ValuesHooks","Selector","timingFunctions","springFunctions","decayFunctions","interpolateFn","interpolatePathFn","interpolateVectorFn","interpolateColors","_value","_inputRange","_outputRange","Float32Array","of","mixColors","_v","_x","_y","ShaderLib","createDrawing","createDeclaration"],"sources":["index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type { Color, Skia as SkiaApi, SkRect, Vector } from \"../skia/types\";\nimport * as Values from \"../values/web\";\nimport * as ValuesHooks from \"../values/hooks\";\nimport { Selector } from \"../values/selector\";\nimport * as BaseSkia from \"../skia/types\";\nimport type * as SkiaExports from \"../skia\";\nimport type * as ExternalExports from \"../external\";\nimport type * as ValueExports from \"../values\";\nimport type * as AnimationExports from \"../animation\";\nimport { useSharedValueEffect } from \"../external/reanimated/useSharedValueEffect\";\nimport * as timingFunctions from \"../animation/timing\";\nimport * as springFunctions from \"../animation/spring\";\nimport * as decayFunctions from \"../animation/decay\";\nimport * as interpolateFn from \"../animation/functions/interpolate\";\nimport * as interpolatePathFn from \"../animation/functions/interpolatePaths\";\nimport * as interpolateVectorFn from \"../animation/functions/interpolateVector\";\nimport { ShaderLib } from \"../renderer/components/shaders/ShaderLib\";\n\nclass Stub {\n constructor() {\n return new Proxy(() => {}, {\n get: () => new Stub(),\n apply: () => new Stub(),\n set: () => true,\n });\n }\n}\n\nconst Noop: () => any = () => {};\n\nexport const Skia: SkiaApi = new Stub() as any;\n\nexport const vec = (x?: number, y?: number) => ({ x: x ?? 0, y: y ?? x ?? 0 });\n\nexport const Mock: typeof SkiaExports &\n typeof ExternalExports &\n typeof ValueExports &\n typeof AnimationExports & {\n createDrawing: () => any;\n createDeclaration: () => any;\n ShaderLib: typeof ShaderLib;\n } = {\n // SkiaExports\n // 1. Skia API. BaseSkia contains the enums, and functions like isPaint etc\n Skia,\n ...BaseSkia,\n // 2. Hooks\n useRawData: Noop,\n useData: Noop,\n useFont: Noop,\n useTypeface: Noop,\n useImage: Noop,\n useSVG: Noop,\n createPicture: Noop,\n // 3. Point/Rect/Transform utilities\n vec,\n rect: (x: number, y: number, width: number, height: number) => ({\n x,\n y,\n width,\n height,\n }),\n rrect: (r: SkRect, rx: number, ry: number) => ({\n rect: r,\n rx,\n ry,\n }),\n point: vec,\n add: (a: Vector, b: Vector) => vec(a.x + b.x, a.y + b.y),\n sub: (a: Vector, b: Vector) => vec(a.x - b.x, a.y - b.y),\n neg: (a: Vector) => vec(-a.x, -a.y),\n dist: (a: Vector, b: Vector) => Math.hypot(a.x - b.x, a.y - b.y),\n translate: ({ x, y }: Vector) =>\n [{ translateX: x }, { translateY: y }] as const,\n\n bounds: Noop,\n topLeft: Noop,\n topRight: Noop,\n bottomLeft: Noop,\n bottomRight: Noop,\n center: Noop,\n processTransform2d: Noop,\n // ExternalExports\n useSharedValueEffect,\n // ValueExports\n ...Values,\n ...ValuesHooks,\n Selector,\n // Animations\n ...timingFunctions,\n ...springFunctions,\n ...decayFunctions,\n ...interpolateFn,\n ...interpolatePathFn,\n ...interpolateVectorFn,\n interpolateColors: (\n _value: number,\n _inputRange: number[],\n _outputRange: Color[]\n ) => Float32Array.of(0, 0, 0, 0),\n mixColors: (_v: number, _x: Color, _y: Color) => Float32Array.of(0, 0, 0, 0),\n ShaderLib,\n createDrawing: Noop,\n createDeclaration: Noop,\n};\n"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAlBA;AAoBA,MAAMA,IAAN,CAAW;EACTC,WAAW,GAAG;IACZ,OAAO,IAAIC,KAAJ,CAAU,MAAM,CAAE,CAAlB,EAAoB;MACzBC,GAAG,EAAE,MAAM,IAAIH,IAAJ,EADc;MAEzBI,KAAK,EAAE,MAAM,IAAIJ,IAAJ,EAFY;MAGzBK,GAAG,EAAE,MAAM;IAHc,CAApB,CAAP;EAKD;;AAPQ;;AAUX,MAAMC,IAAe,GAAG,MAAM,CAAE,CA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yB,CAAzB,CA3D7C;EA4DJK,SAAS,EAATA,oBA5DI;EA6DJC,aAAa,EAAE7D,IA7DX;EA8DJ8D,iBAAiB,EAAE9D;AA9Df,CAPC"}
1
+ {"version":3,"names":["Stub","constructor","Proxy","get","apply","set","Noop","Skia","vec","x","y","Mock","BaseSkia","useRawData","useData","useFont","useTypeface","useImage","useSVG","createPicture","rect","width","height","rrect","r","rx","ry","point","add","a","b","sub","neg","dist","Math","hypot","translate","translateX","translateY","bounds","topLeft","topRight","bottomLeft","bottomRight","center","processTransform2d","Values","ValuesHooks","Selector","timingFunctions","springFunctions","decayFunctions","interpolateFn","interpolatePathFn","interpolateVectorFn","interpolateColors","_value","_inputRange","_outputRange","Float32Array","of","mixColors","_v","_x","_y","ShaderLib","createDrawing","createDeclaration"],"sources":["index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type { Color, Skia as SkiaApi, SkRect, Vector } from \"../skia/types\";\nimport * as Values from \"../values/web\";\nimport * as ValuesHooks from \"../values/hooks\";\nimport { Selector } from \"../values/selector\";\nimport * as BaseSkia from \"../skia/types\";\nimport type * as SkiaExports from \"../skia\";\nimport type * as ValueExports from \"../values\";\nimport type * as AnimationExports from \"../animation\";\nimport * as timingFunctions from \"../animation/timing\";\nimport * as springFunctions from \"../animation/spring\";\nimport * as decayFunctions from \"../animation/decay\";\nimport * as interpolateFn from \"../animation/functions/interpolate\";\nimport * as interpolatePathFn from \"../animation/functions/interpolatePaths\";\nimport * as interpolateVectorFn from \"../animation/functions/interpolateVector\";\nimport { ShaderLib } from \"../renderer/components/shaders/ShaderLib\";\n\nclass Stub {\n constructor() {\n return new Proxy(() => {}, {\n get: () => new Stub(),\n apply: () => new Stub(),\n set: () => true,\n });\n }\n}\n\nconst Noop: () => any = () => {};\n\nexport const Skia: SkiaApi = new Stub() as any;\n\nexport const vec = (x?: number, y?: number) => ({ x: x ?? 0, y: y ?? x ?? 0 });\n\nexport const Mock: typeof SkiaExports &\n typeof ValueExports &\n typeof AnimationExports & {\n createDrawing: () => any;\n createDeclaration: () => any;\n ShaderLib: typeof ShaderLib;\n } = {\n // SkiaExports\n // 1. Skia API. BaseSkia contains the enums, and functions like isPaint etc\n Skia,\n ...BaseSkia,\n // 2. Hooks\n useRawData: Noop,\n useData: Noop,\n useFont: Noop,\n useTypeface: Noop,\n useImage: Noop,\n useSVG: Noop,\n createPicture: Noop,\n // 3. Point/Rect/Transform utilities\n vec,\n rect: (x: number, y: number, width: number, height: number) => ({\n x,\n y,\n width,\n height,\n }),\n rrect: (r: SkRect, rx: number, ry: number) => ({\n rect: r,\n rx,\n ry,\n }),\n point: vec,\n add: (a: Vector, b: Vector) => vec(a.x + b.x, a.y + b.y),\n sub: (a: Vector, b: Vector) => vec(a.x - b.x, a.y - b.y),\n neg: (a: Vector) => vec(-a.x, -a.y),\n dist: (a: Vector, b: Vector) => Math.hypot(a.x - b.x, a.y - b.y),\n translate: ({ x, y }: Vector) =>\n [{ translateX: x }, { translateY: y }] as const,\n\n bounds: Noop,\n topLeft: Noop,\n topRight: Noop,\n bottomLeft: Noop,\n bottomRight: Noop,\n center: Noop,\n processTransform2d: Noop,\n // ValueExports\n ...Values,\n ...ValuesHooks,\n Selector,\n // Animations\n ...timingFunctions,\n ...springFunctions,\n ...decayFunctions,\n ...interpolateFn,\n ...interpolatePathFn,\n ...interpolateVectorFn,\n interpolateColors: (\n _value: number,\n _inputRange: number[],\n _outputRange: Color[]\n ) => Float32Array.of(0, 0, 0, 0),\n mixColors: (_v: number, _x: Color, _y: Color) => Float32Array.of(0, 0, 0, 0),\n ShaderLib,\n createDrawing: Noop,\n createDeclaration: Noop,\n};\n"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AAIA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAhBA;AAkBA,MAAMA,IAAN,CAAW;EACTC,WAAW,GAAG;IACZ,OAAO,IAAIC,KAAJ,CAAU,MAAM,CAAE,CAAlB,EAAoB;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EAAyB,CAAzB,CAxDD;EAyDJC,SAAS,EAAE,CAACC,EAAD,EAAaC,EAAb,EAAwBC,EAAxB,KAAsCL,YAAY,CAACC,EAAb,CAAgB,CAAhB,EAAmB,CAAnB,EAAsB,CAAtB,EAAyB,CAAzB,CAzD7C;EA0DJK,SAAS,EAATA,oBA1DI;EA2DJC,aAAa,EAAE5D,IA3DX;EA4DJ6D,iBAAiB,EAAE7D;AA5Df,CANC"}
@@ -39,6 +39,12 @@ const Canvas = /*#__PURE__*/(0, _react.forwardRef)((_ref, forwardedRef) => {
39
39
 
40
40
  (_innerRef$current = innerRef.current) === null || _innerRef$current === void 0 ? void 0 : _innerRef$current.redraw();
41
41
  }, [innerRef]);
42
+ const getNativeId = (0, _react.useCallback)(() => {
43
+ var _innerRef$current2;
44
+
45
+ const id = ((_innerRef$current2 = innerRef.current) === null || _innerRef$current2 === void 0 ? void 0 : _innerRef$current2.nativeId) ?? -1;
46
+ return id;
47
+ }, [innerRef]);
42
48
  const registerValues = (0, _react.useCallback)(values => {
43
49
  if (ref.current !== null) {
44
50
  return ref.current.registerValues(values);
@@ -46,7 +52,7 @@ const Canvas = /*#__PURE__*/(0, _react.forwardRef)((_ref, forwardedRef) => {
46
52
 
47
53
  return () => {};
48
54
  }, [ref]);
49
- const root = (0, _react.useMemo)(() => new _Reconciler.SkiaRoot(_Skia.Skia, registerValues, redraw), [redraw, registerValues]); // Render effect
55
+ const root = (0, _react.useMemo)(() => new _Reconciler.SkiaRoot(_Skia.Skia, registerValues, redraw, getNativeId), [redraw, registerValues, getNativeId]); // Render effect
50
56
 
51
57
  (0, _react.useEffect)(() => {
52
58
  root.render(children);
@@ -1 +1 @@
1
- {"version":3,"names":["useCanvasRef","useRef","Canvas","forwardRef","forwardedRef","children","style","debug","mode","onTouch","onSize","props","innerRef","ref","useCombinedRefs","redraw","useCallback","current","registerValues","values","root","useMemo","SkiaRoot","Skia","useEffect","render","unmount","dom","refs","targetRef","React","forEach"],"sources":["Canvas.tsx"],"sourcesContent":["import React, {\n useEffect,\n useCallback,\n useMemo,\n forwardRef,\n useRef,\n} from \"react\";\nimport type {\n RefObject,\n ReactNode,\n MutableRefObject,\n ForwardedRef,\n} from \"react\";\n\nimport { SkiaDomView } from \"../views\";\nimport { Skia } from \"../skia/Skia\";\nimport type { TouchHandler, SkiaBaseViewProps } from \"../views\";\nimport type { SkiaValue } from \"../values/types\";\n\nimport { SkiaRoot } from \"./Reconciler\";\n\nexport const useCanvasRef = () => useRef<SkiaDomView>(null);\n\nexport interface CanvasProps extends SkiaBaseViewProps {\n ref?: RefObject<SkiaDomView>;\n children: ReactNode;\n onTouch?: TouchHandler;\n}\n\nexport const Canvas = forwardRef<SkiaDomView, CanvasProps>(\n (\n { children, style, debug, mode, onTouch, onSize, ...props },\n forwardedRef\n ) => {\n const innerRef = useCanvasRef();\n const ref = useCombinedRefs(forwardedRef, innerRef);\n const redraw = useCallback(() => {\n innerRef.current?.redraw();\n }, [innerRef]);\n\n const registerValues = useCallback(\n (values: Array<SkiaValue<unknown>>) => {\n if (ref.current !== null) {\n return ref.current.registerValues(values);\n }\n return () => {};\n },\n [ref]\n );\n const root = useMemo(\n () => new SkiaRoot(Skia, registerValues, redraw),\n [redraw, registerValues]\n );\n\n // Render effect\n useEffect(() => {\n root.render(children);\n }, [children, root, redraw]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n\n return (\n <SkiaDomView\n ref={ref}\n style={style}\n root={root.dom}\n onTouch={onTouch}\n onSize={onSize}\n mode={mode}\n debug={debug}\n {...props}\n />\n );\n }\n) as React.FC<CanvasProps & React.RefAttributes<SkiaDomView>>;\n\n/**\n * Combines a list of refs into a single ref. This can be used to provide\n * both a forwarded ref and an internal ref keeping the same functionality\n * on both of the refs.\n * @param refs Array of refs to combine\n * @returns A single ref that can be used in a ref prop.\n */\nconst useCombinedRefs = <T,>(\n ...refs: Array<MutableRefObject<T> | ForwardedRef<T>>\n) => {\n const targetRef = React.useRef<T>(null);\n React.useEffect(() => {\n refs.forEach((ref) => {\n if (ref) {\n if (typeof ref === \"function\") {\n ref(targetRef.current);\n } else {\n ref.current = targetRef.current;\n }\n }\n });\n }, [refs]);\n return targetRef;\n};\n"],"mappings":";;;;;;;AAAA;;AAcA;;AACA;;AAIA;;;;;;;;AAEO,MAAMA,YAAY,GAAG,MAAM,IAAAC,aAAA,EAAoB,IAApB,CAA3B;;;AAQA,MAAMC,MAAM,gBAAG,IAAAC,iBAAA,EACpB,OAEEC,YAFF,KAGK;EAAA,IAFH;IAAEC,QAAF;IAAYC,KAAZ;IAAmBC,KAAnB;IAA0BC,IAA1B;IAAgCC,OAAhC;IAAyCC,MAAzC;IAAiD,GAAGC;EAApD,CAEG;EACH,MAAMC,QAAQ,GAAGZ,YAAY,EAA7B;EACA,MAAMa,GAAG,GAAGC,eAAe,CAACV,YAAD,EAAeQ,QAAf,CAA3B;EACA,MAAMG,MAAM,GAAG,IAAAC,kBAAA,EAAY,MAAM;IAAA;;IAC/B,qBAAAJ,QAAQ,CAACK,OAAT,wEAAkBF,MAAlB;EACD,CAFc,EAEZ,CAACH,QAAD,CAFY,CAAf;EAIA,MAAMM,cAAc,GAAG,IAAAF,kBAAA,EACpBG,MAAD,IAAuC;IACrC,IAAIN,GAAG,CAACI,OAAJ,KAAgB,IAApB,EAA0B;MACxB,OAAOJ,GAAG,CAACI,OAAJ,CAAYC,cAAZ,CAA2BC,MAA3B,CAAP;IACD;;IACD,OAAO,MAAM,CAAE,CAAf;EACD,CANoB,EAOrB,CAACN,GAAD,CAPqB,CAAvB;EASA,MAAMO,IAAI,GAAG,IAAAC,cAAA,EACX,MAAM,IAAIC,oBAAJ,CAAaC,UAAb,EAAmBL,cAAnB,EAAmCH,MAAnC,CADK,EAEX,CAACA,MAAD,EAASG,cAAT,CAFW,CAAb,CAhBG,CAqBH;;EACA,IAAAM,gBAAA,EAAU,MAAM;IACdJ,IAAI,CAACK,MAAL,CAAYpB,QAAZ;EACD,CAFD,EAEG,CAACA,QAAD,EAAWe,IAAX,EAAiBL,MAAjB,CAFH;EAIA,IAAAS,gBAAA,EAAU,MAAM;IACd,OAAO,MAAM;MACXJ,IAAI,CAACM,OAAL;IACD,CAFD;EAGD,CAJD,EAIG,CAACN,IAAD,CAJH;EAMA,oBACE,6BAAC,kBAAD;IACE,GAAG,EAAEP,GADP;IAEE,KAAK,EAAEP,KAFT;IAGE,IAAI,EAAEc,IAAI,CAACO,GAHb;IAIE,OAAO,EAAElB,OAJX;IAKE,MAAM,EAAEC,MALV;IAME,IAAI,EAAEF,IANR;IAOE,KAAK,EAAED;EAPT,GAQMI,KARN,EADF;AAYD,CAhDmB,CAAf;AAmDP;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACA,MAAMG,eAAe,GAAG,YAEnB;EAAA,kCADAc,IACA;IADAA,IACA;EAAA;;EACH,MAAMC,SAAS,GAAGC,cAAA,CAAM7B,MAAN,CAAgB,IAAhB,CAAlB;;EACA6B,cAAA,CAAMN,SAAN,CAAgB,MAAM;IACpBI,IAAI,CAACG,OAAL,CAAclB,GAAD,IAAS;MACpB,IAAIA,GAAJ,EAAS;QACP,IAAI,OAAOA,GAAP,KAAe,UAAnB,EAA+B;UAC7BA,GAAG,CAACgB,SAAS,CAACZ,OAAX,CAAH;QACD,CAFD,MAEO;UACLJ,GAAG,CAACI,OAAJ,GAAcY,SAAS,CAACZ,OAAxB;QACD;MACF;IACF,CARD;EASD,CAVD,EAUG,CAACW,IAAD,CAVH;;EAWA,OAAOC,SAAP;AACD,CAhBD"}
1
+ {"version":3,"names":["useCanvasRef","useRef","Canvas","forwardRef","forwardedRef","children","style","debug","mode","onTouch","onSize","props","innerRef","ref","useCombinedRefs","redraw","useCallback","current","getNativeId","id","nativeId","registerValues","values","root","useMemo","SkiaRoot","Skia","useEffect","render","unmount","dom","refs","targetRef","React","forEach"],"sources":["Canvas.tsx"],"sourcesContent":["import React, {\n useEffect,\n useCallback,\n useMemo,\n forwardRef,\n useRef,\n} from \"react\";\nimport type {\n RefObject,\n ReactNode,\n MutableRefObject,\n ForwardedRef,\n} from \"react\";\n\nimport { SkiaDomView } from \"../views\";\nimport { Skia } from \"../skia/Skia\";\nimport type { TouchHandler, SkiaBaseViewProps } from \"../views\";\nimport type { SkiaValue } from \"../values/types\";\n\nimport { SkiaRoot } from \"./Reconciler\";\n\nexport const useCanvasRef = () => useRef<SkiaDomView>(null);\n\nexport interface CanvasProps extends SkiaBaseViewProps {\n ref?: RefObject<SkiaDomView>;\n children: ReactNode;\n onTouch?: TouchHandler;\n}\n\nexport const Canvas = forwardRef<SkiaDomView, CanvasProps>(\n (\n { children, style, debug, mode, onTouch, onSize, ...props },\n forwardedRef\n ) => {\n const innerRef = useCanvasRef();\n const ref = useCombinedRefs(forwardedRef, innerRef);\n const redraw = useCallback(() => {\n innerRef.current?.redraw();\n }, [innerRef]);\n const getNativeId = useCallback(() => {\n const id = innerRef.current?.nativeId ?? -1;\n return id;\n }, [innerRef]);\n\n const registerValues = useCallback(\n (values: Array<SkiaValue<unknown>>) => {\n if (ref.current !== null) {\n return ref.current.registerValues(values);\n }\n return () => {};\n },\n [ref]\n );\n const root = useMemo(\n () => new SkiaRoot(Skia, registerValues, redraw, getNativeId),\n [redraw, registerValues, getNativeId]\n );\n\n // Render effect\n useEffect(() => {\n root.render(children);\n }, [children, root, redraw]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n\n return (\n <SkiaDomView\n ref={ref}\n style={style}\n root={root.dom}\n onTouch={onTouch}\n onSize={onSize}\n mode={mode}\n debug={debug}\n {...props}\n />\n );\n }\n) as React.FC<CanvasProps & React.RefAttributes<SkiaDomView>>;\n\n/**\n * Combines a list of refs into a single ref. This can be used to provide\n * both a forwarded ref and an internal ref keeping the same functionality\n * on both of the refs.\n * @param refs Array of refs to combine\n * @returns A single ref that can be used in a ref prop.\n */\nconst useCombinedRefs = <T,>(\n ...refs: Array<MutableRefObject<T> | ForwardedRef<T>>\n) => {\n const targetRef = React.useRef<T>(null);\n React.useEffect(() => {\n refs.forEach((ref) => {\n if (ref) {\n if (typeof ref === \"function\") {\n ref(targetRef.current);\n } else {\n ref.current = targetRef.current;\n }\n }\n });\n }, [refs]);\n return targetRef;\n};\n"],"mappings":";;;;;;;AAAA;;AAcA;;AACA;;AAIA;;;;;;;;AAEO,MAAMA,YAAY,GAAG,MAAM,IAAAC,aAAA,EAAoB,IAApB,CAA3B;;;AAQA,MAAMC,MAAM,gBAAG,IAAAC,iBAAA,EACpB,OAEEC,YAFF,KAGK;EAAA,IAFH;IAAEC,QAAF;IAAYC,KAAZ;IAAmBC,KAAnB;IAA0BC,IAA1B;IAAgCC,OAAhC;IAAyCC,MAAzC;IAAiD,GAAGC;EAApD,CAEG;EACH,MAAMC,QAAQ,GAAGZ,YAAY,EAA7B;EACA,MAAMa,GAAG,GAAGC,eAAe,CAACV,YAAD,EAAeQ,QAAf,CAA3B;EACA,MAAMG,MAAM,GAAG,IAAAC,kBAAA,EAAY,MAAM;IAAA;;IAC/B,qBAAAJ,QAAQ,CAACK,OAAT,wEAAkBF,MAAlB;EACD,CAFc,EAEZ,CAACH,QAAD,CAFY,CAAf;EAGA,MAAMM,WAAW,GAAG,IAAAF,kBAAA,EAAY,MAAM;IAAA;;IACpC,MAAMG,EAAE,GAAG,uBAAAP,QAAQ,CAACK,OAAT,0EAAkBG,QAAlB,KAA8B,CAAC,CAA1C;IACA,OAAOD,EAAP;EACD,CAHmB,EAGjB,CAACP,QAAD,CAHiB,CAApB;EAKA,MAAMS,cAAc,GAAG,IAAAL,kBAAA,EACpBM,MAAD,IAAuC;IACrC,IAAIT,GAAG,CAACI,OAAJ,KAAgB,IAApB,EAA0B;MACxB,OAAOJ,GAAG,CAACI,OAAJ,CAAYI,cAAZ,CAA2BC,MAA3B,CAAP;IACD;;IACD,OAAO,MAAM,CAAE,CAAf;EACD,CANoB,EAOrB,CAACT,GAAD,CAPqB,CAAvB;EASA,MAAMU,IAAI,GAAG,IAAAC,cAAA,EACX,MAAM,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yManager";
4
4
  export declare class Container {
5
5
  depMgr: DependencyManager;
6
6
  redraw: () => void;
7
+ getNativeId: () => number;
7
8
  private _root;
8
9
  Sk: SkDOM;
9
- constructor(Skia: Skia, depMgr: DependencyManager, redraw?: () => void);
10
+ constructor(Skia: Skia, depMgr: DependencyManager, redraw?: () => void, getNativeId?: () => number);
10
11
  draw(ctx: DrawingContext): void;
11
12
  get root(): RenderNode<GroupProps>;
12
13
  }
@@ -12,8 +12,10 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
12
12
  class Container {
13
13
  constructor(Skia, depMgr) {
14
14
  let redraw = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : () => {};
15
+ let getNativeId = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : () => 0;
15
16
  this.depMgr = depMgr;
16
17
  this.redraw = redraw;
18
+ this.getNativeId = getNativeId;
17
19
 
18
20
  _defineProperty(this, "_root", void 0);
19
21
 
@@ -1 +1 @@
1
- {"version":3,"names":["Container","constructor","Skia","depMgr","redraw","Sk","JsiSkDOM","_root","Group","draw","ctx","render","root"],"sources":["Container.tsx"],"sourcesContent":["import { JsiSkDOM } from \"../dom/nodes\";\nimport type {\n GroupProps,\n DrawingContext,\n RenderNode,\n SkDOM,\n} from \"../dom/types\";\nimport type { Skia } from \"../skia/types\";\n\nimport type { DependencyManager } from \"./DependencyManager\";\n\nexport class Container {\n private _root: RenderNode<GroupProps>;\n public Sk: SkDOM;\n constructor(\n Skia: Skia,\n public depMgr: DependencyManager,\n public redraw: () => void = () => {}\n ) {\n this.Sk = new JsiSkDOM({ Skia, depMgr });\n this._root = this.Sk.Group();\n }\n\n draw(ctx: DrawingContext) {\n this._root.render(ctx);\n }\n\n get root() {\n return this._root;\n }\n}\n"],"mappings":";;;;;;;AAAA;;;;AAWO,MAAMA,SAAN,CAAgB;EAGrBC,WAAW,CACTC,IADS,EAEFC,MAFE,EAIT;IAAA,IADOC,MACP,uEAD4B,MAAM,CAAE,CACpC;IAAA,KAFOD,MAEP,GAFOA,MAEP;IAAA,KADOC,MACP,GADOA,MACP;;IAAA;;IAAA;;IACA,KAAKC,EAAL,GAAU,IAAIC,eAAJ,CAAa;MAAEJ,IAAF;MAAQC;IAAR,CAAb,CAAV;IACA,KAAKI,KAAL,GAAa,KAAKF,EAAL,CAAQG,KAAR,EAAb;EACD;;EAEDC,IAAI,CAACC,GAAD,EAAsB;IACxB,KAAKH,KAAL,CAAWI,MAAX,CAAkBD,GAAlB;EACD;;EAEO,IAAJE,IAAI,GAAG;IACT,OAAO,KAAKL,KAAZ;EACD;;AAlBoB"}
1
+ {"version":3,"names":["Container","constructor","Skia","depMgr","redraw","getNativeId","Sk","JsiSkDOM","_root","Group","draw","ctx","render","root"],"sources":["Container.tsx"],"sourcesContent":["import { JsiSkDOM } from \"../dom/nodes\";\nimport type {\n GroupProps,\n DrawingContext,\n RenderNode,\n SkDOM,\n} from \"../dom/types\";\nimport type { Skia } from \"../skia/types\";\n\nimport type { DependencyManager } from \"./DependencyManager\";\n\nexport class Container {\n private _root: RenderNode<GroupProps>;\n public Sk: SkDOM;\n constructor(\n Skia: Skia,\n public depMgr: DependencyManager,\n public redraw: () => void = () => {},\n public getNativeId: () => number = () => 0\n ) {\n this.Sk = new JsiSkDOM({ Skia, depMgr });\n this._root = this.Sk.Group();\n }\n\n draw(ctx: DrawingContext) {\n this._root.render(ctx);\n }\n\n get root() {\n return this._root;\n }\n}\n"],"mappings":";;;;;;;AAAA;;;;AAWO,MAAMA,SAAN,CAAgB;EAGrBC,WAAW,CACTC,IADS,EAEFC,MAFE,EAKT;IAAA,IAFOC,MAEP,uEAF4B,MAAM,CAAE,CAEpC;IAAA,IADOC,WACP,uEADmC,MAAM,CACzC;IAAA,KAHOF,MAGP,GAHOA,MAGP;IAAA,KAFOC,MAEP,GAFOA,MAEP;IAAA,KADOC,WACP,GADOA,WACP;;IAAA;;IAAA;;IACA,KAAKC,EAAL,GAAU,IAAIC,eAAJ,CAAa;MAAEL,IAAF;MAAQC;IAAR,CAAb,CAAV;IACA,KAAKK,KAAL,GAAa,KAAKF,EAAL,CAAQG,KAAR,EAAb;EACD;;EAEDC,IAAI,CAACC,GAAD,EAAsB;IACxB,KAAKH,KAAL,CAAWI,MAAX,CAAkBD,GAAlB;EACD;;EAEO,IAAJE,IAAI,GAAG;IACT,OAAO,KAAKL,KAAZ;EACD;;AAnBoB"}
@@ -7,6 +7,8 @@ exports.skHostConfig = exports.debug = void 0;
7
7
 
8
8
  var _constants = require("react-reconciler/constants");
9
9
 
10
+ var _reanimated = require("../external/reanimated");
11
+
10
12
  var _HostComponents = require("./HostComponents");
11
13
 
12
14
  var _processors = require("./processors");
@@ -82,9 +84,9 @@ const skHostConfig = {
82
84
 
83
85
  createInstance(type, pristineProps, container, _hostContext, _internalInstanceHandle) {
84
86
  debug("createInstance", type);
85
- const props = { ...pristineProps
86
- };
87
+ const [props, reanimatedProps] = (0, _reanimated.extractReanimatedProps)(pristineProps);
87
88
  const node = (0, _HostComponents.createNode)(container, type, materialize(props));
89
+ (0, _reanimated.bindReanimatedProps)(container, node, reanimatedProps);
88
90
  container.depMgr.subscribeNode(node, props);
89
91
  return node;
90
92
  },
@@ -139,10 +141,10 @@ const skHostConfig = {
139
141
  return;
140
142
  }
141
143
 
142
- const props = { ...nextProps
143
- };
144
+ const [props, reanimatedProps] = (0, _reanimated.extractReanimatedProps)(nextProps);
144
145
  updatePayload.depMgr.unsubscribeNode(instance);
145
146
  instance.setProps(materialize(props));
147
+ (0, _reanimated.bindReanimatedProps)(updatePayload, instance, reanimatedProps);
146
148
  updatePayload.depMgr.subscribeNode(instance, props);
147
149
  },
148
150
 
@@ -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","node","createNode","materialize","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\";\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 = { ...pristineProps };\n const node = createNode(container, type, materialize(props));\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 = { ...nextProps };\n updatePayload.depMgr.unsubscribeNode(instance);\n instance.setProps(materialize(props));\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;;AAMA;;AAEA;;AACA;;AAXA;AAaA,MAAMA,KAAK,GAAG,KAAd;;AACO,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;;AAQO,MAAME,YAA4B,GAAG;EAC1C;AACF;AACA;EACEC,GAAG,EAAEC,IAAI,CAACD,GAJgC;EAK1CE,gBAAgB,EAAE,IALwB;EAM1CC,iBAAiB,EAAE,KANuB;EAO1CC,mBAAmB,EAAE,KAPqB;EAQ1CC,iBAAiB,EAAE,KARuB;EAS1C;EAEAC,eAAe,EAAEC,UAXyB;EAY1CC,aAAa,EAAEC,YAZ2B;EAa1CC,SAAS,EAAE,CAAC,CAb8B;;EAe1CC,sBAAsB,CAACC,SAAD,EAAYpB,KAAZ,EAAmB;IACvCL,KAAK,CAAC,wBAAD,EAA2ByB,SAA3B,EAAsCpB,KAAtC,CAAL;IACAF,UAAU,CAACsB,SAAS,CAACC,IAAX,EAAiBrB,KAAjB,CAAV;EACD,CAlByC;;EAoB1CsB,WAAW,CAACvB,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wB,EAAE,MAAM,CAAE,CA9KQ;EA+K1CC,uBAAuB,EAAE,MAAM,CAAE,CA/KS;EAgL1CC,qBAAqB,EAAE,MAAM,CAAE;AAhLW,CAArC;;;AAmLP,MAAM1C,WAAW,GAAOH,KAAJ,IAAgC;EAClD,MAAM8C,MAAM,GAAG,EAAE,GAAG9C;EAAL,CAAf;EACA,IAAA+C,kBAAA,EAAQ/C,KAAR,EAAeqC,OAAf,CAAwBW,GAAD,IAAS;IAC9B,MAAMC,IAAI,GAAGjD,KAAK,CAACgD,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","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\";\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;;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AuB,EAAE,MAAMC,+BA/KW;EAgL1CC,wBAAwB,EAAE,MAAM,CAAE,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"}
@@ -5,7 +5,7 @@ declare type RegisterValues = (values: Array<SkiaValue<unknown>>) => () => void;
5
5
  export declare class SkiaRoot {
6
6
  private root;
7
7
  private container;
8
- constructor(Skia: Skia, registerValues?: RegisterValues, redraw?: () => void);
8
+ constructor(Skia: Skia, registerValues?: RegisterValues, redraw?: () => void, getNativeId?: () => number);
9
9
  render(element: ReactNode): void;
10
10
  unmount(): void;
11
11
  get dom(): import("..").RenderNode<import("..").GroupProps>;
@@ -31,13 +31,14 @@ class SkiaRoot {
31
31
  constructor(Skia) {
32
32
  let registerValues = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : () => () => {};
33
33
  let redraw = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : () => {};
34
+ let getNativeId = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : () => 0;
34
35
 
35
36
  _defineProperty(this, "root", void 0);
36
37
 
37
38
  _defineProperty(this, "container", void 0);
38
39
 
39
40
  const depMgr = createDependencyManager(registerValues);
40
- this.container = new _Container.Container(Skia, depMgr, redraw);
41
+ this.container = new _Container.Container(Skia, depMgr, redraw, getNativeId);
41
42
  this.root = skiaReconciler.createContainer(this.container, 0, null, true, null, "", console.error, null);
42
43
  }
43
44
 
@@ -1 +1 @@
1
- {"version":3,"names":["skiaReconciler","ReactReconciler","skHostConfig","createDependencyManager","registerValues","global","SkiaDomApi","DependencyManager","injectIntoDevTools","bundleType","version","rendererPackageName","SkiaRoot","constructor","Skia","redraw","depMgr","container","Container","root","createContainer","console","error","render","element","updateContainer","hostDebug","unmount","remove","dom"],"sources":["Reconciler.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport type { OpaqueRoot } from \"react-reconciler\";\nimport ReactReconciler from \"react-reconciler\";\n\nimport type { Skia } from \"../skia/types\";\nimport type { SkiaValue } from \"../values/types\";\n\nimport { DependencyManager } from \"./DependencyManager\";\nimport { skHostConfig, debug as hostDebug } from \"./HostConfig\";\nimport { Container } from \"./Container\";\n\nconst skiaReconciler = ReactReconciler(skHostConfig);\n\ntype RegisterValues = (values: Array<SkiaValue<unknown>>) => () => void;\n\nconst createDependencyManager = (registerValues: RegisterValues) =>\n global.SkiaDomApi && global.SkiaDomApi.DependencyManager\n ? global.SkiaDomApi.DependencyManager(registerValues)\n : new DependencyManager(registerValues);\n\nskiaReconciler.injectIntoDevTools({\n bundleType: 1,\n version: \"0.0.1\",\n rendererPackageName: \"react-native-skia\",\n});\n\nexport class SkiaRoot {\n private root: OpaqueRoot;\n private container: Container;\n\n constructor(\n Skia: Skia,\n registerValues: RegisterValues = () => () => {},\n redraw: () => void = () => {}\n ) {\n const depMgr = createDependencyManager(registerValues);\n this.container = new Container(Skia, depMgr, redraw);\n this.root = skiaReconciler.createContainer(\n this.container,\n 0,\n null,\n true,\n null,\n \"\",\n console.error,\n null\n );\n }\n\n render(element: ReactNode) {\n skiaReconciler.updateContainer(element, this.root, null, () => {\n hostDebug(\"updateContainer\");\n });\n }\n\n unmount() {\n skiaReconciler.updateContainer(null, this.root, null, () => {\n this.container.depMgr.remove();\n });\n }\n\n get dom() {\n return this.container.root;\n }\n}\n"],"mappings":";;;;;;;AAEA;;AAKA;;AACA;;AACA;;;;;;AAEA,MAAMA,cAAc,GAAG,IAAAC,wBAAA,EAAgBC,wBAAhB,CAAvB;;AAIA,MAAMC,uBAAuB,GAAIC,cAAD,IAC9BC,MAAM,CAACC,UAAP,IAAqBD,MAAM,CAACC,UAAP,CAAkBC,iBAAvC,GACIF,MAAM,CAACC,UAAP,CAAkBC,iBAAlB,CAAoCH,cAApC,CADJ,GAEI,IAAIG,oCAAJ,CAAsBH,cAAtB,CAHN;;AAKAJ,cAAc,CAACQ,kBAAf,CAAkC;EAChCC,UAAU,EAAE,CADoB;EAEhCC,OAAO,EAAE,OAFuB;EAGhCC,mBAAmB,EAAE;AAHW,CAAlC;;AAMO,MAAMC,QAAN,CAAe;EAIpBC,WAAW,CACTC,IADS,EAIT;IAAA,IAFAV,cAEA,uEAFiC,MAAM,MAAM,CAAE,CAE/C;IAAA,IADAW,MACA,uEADqB,MAAM,CAAE,CAC7B;;IAAA;;IAAA;;IACA,MAAMC,MAAM,GAAGb,uBAAuB,CAACC,cAAD,CAAtC;IACA,KAAKa,SAAL,GAAiB,IAAIC,oBAAJ,CAAcJ,IAAd,EAAoBE,MAApB,EAA4BD,MAA5B,CAAjB;IACA,KAAKI,IAAL,GAAYnB,cAAc,CAACoB,eAAf,CACV,KAAKH,SADK,EAEV,CAFU,EAGV,IAHU,EAIV,IAJU,EAKV,IALU,EAMV,EANU,EAOVI,OAAO,CAACC,KAPE,EAQV,IARU,CAAZ;EAUD;;EAEDC,MAAM,CAACC,OAAD,EAAqB;IACzBxB,cAAc,CAACyB,eAAf,CAA+BD,OAA/B,EAAwC,KAAKL,IAA7C,EAAmD,IAAnD,EAAyD,MAAM;MAC7D,IAAAO,iBAAA,EAAU,iBAAV;IACD,CAFD;EAGD;;EAEDC,OAAO,GAAG;IACR3B,cAAc,CAACyB,eAAf,CAA+B,IAA/B,EAAqC,KAAKN,IAA1C,EAAgD,IAAhD,EAAsD,MAAM;MAC1D,KAAKF,SAAL,CAAeD,MAAf,CAAsBY,MAAtB;IACD,CAFD;EAGD;;EAEM,IAAHC,GAAG,GAAG;IACR,OAAO,KAAKZ,SAAL,CAAeE,IAAtB;EACD;;AArCmB"}
1
+ {"version":3,"names":["skiaReconciler","ReactReconciler","skHostConfig","createDependencyManager","registerValues","global","SkiaDomApi","DependencyManager","injectIntoDevTools","bundleType","version","rendererPackageName","SkiaRoot","constructor","Skia","redraw","getNativeId","depMgr","container","Container","root","createContainer","console","error","render","element","updateContainer","hostDebug","unmount","remove","dom"],"sources":["Reconciler.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport type { OpaqueRoot } from \"react-reconciler\";\nimport ReactReconciler from \"react-reconciler\";\n\nimport type { Skia } from \"../skia/types\";\nimport type { SkiaValue } from \"../values/types\";\n\nimport { DependencyManager } from \"./DependencyManager\";\nimport { skHostConfig, debug as hostDebug } from \"./HostConfig\";\nimport { Container } from \"./Container\";\n\nconst skiaReconciler = ReactReconciler(skHostConfig);\n\ntype RegisterValues = (values: Array<SkiaValue<unknown>>) => () => void;\n\nconst createDependencyManager = (registerValues: RegisterValues) =>\n global.SkiaDomApi && global.SkiaDomApi.DependencyManager\n ? global.SkiaDomApi.DependencyManager(registerValues)\n : new DependencyManager(registerValues);\n\nskiaReconciler.injectIntoDevTools({\n bundleType: 1,\n version: \"0.0.1\",\n rendererPackageName: \"react-native-skia\",\n});\n\nexport class SkiaRoot {\n private root: OpaqueRoot;\n private container: Container;\n\n constructor(\n Skia: Skia,\n registerValues: RegisterValues = () => () => {},\n redraw: () => void = () => {},\n getNativeId: () => number = () => 0\n ) {\n const depMgr = createDependencyManager(registerValues);\n this.container = new Container(Skia, depMgr, redraw, getNativeId);\n this.root = skiaReconciler.createContainer(\n this.container,\n 0,\n null,\n true,\n null,\n \"\",\n console.error,\n null\n );\n }\n\n render(element: ReactNode) {\n skiaReconciler.updateContainer(element, this.root, null, () => {\n hostDebug(\"updateContainer\");\n });\n }\n\n unmount() {\n skiaReconciler.updateContainer(null, this.root, null, () => {\n this.container.depMgr.remove();\n });\n }\n\n get dom() {\n return this.container.root;\n }\n}\n"],"mappings":";;;;;;;AAEA;;AAKA;;AACA;;AACA;;;;;;AAEA,MAAMA,cAAc,GAAG,IAAAC,wBAAA,EAAgBC,wBAAhB,CAAvB;;AAIA,MAAMC,uBAAuB,GAAIC,cAAD,IAC9BC,MAAM,CAACC,UAAP,IAAqBD,MAAM,CAACC,UAAP,CAAkBC,iBAAvC,GACIF,MAAM,CAACC,UAAP,CAAkBC,iBAAlB,CAAoCH,cAApC,CADJ,GAEI,IAAIG,oCAAJ,CAAsBH,cAAtB,CAHN;;AAKAJ,cAAc,CAACQ,kBAAf,CAAkC;EAChCC,UAAU,EAAE,CADoB;EAEhCC,OAAO,EAAE,OAFuB;EAGhCC,mBAAmB,EAAE;AAHW,CAAlC;;AAMO,MAAMC,QAAN,CAAe;EAIpBC,WAAW,CACTC,IADS,EAKT;IAAA,IAHAV,cAGA,uEAHiC,MAAM,MAAM,CAAE,CAG/C;IAAA,IAFAW,MAEA,uEAFqB,MAAM,CAAE,CAE7B;IAAA,IADAC,WACA,uEAD4B,MAAM,CAClC;;IAAA;;IAAA;;IACA,MAAMC,MAAM,GAAGd,uBAAuB,CAACC,cAAD,CAAtC;IACA,KAAKc,SAAL,GAAiB,IAAIC,oBAAJ,CAAcL,IAAd,EAAoBG,MAApB,EAA4BF,MAA5B,EAAoCC,WAApC,CAAjB;IACA,KAAKI,IAAL,GAAYpB,cAAc,CAACqB,eAAf,CACV,KAAKH,SADK,EAEV,CAFU,EAGV,IAHU,EAIV,IAJU,EAKV,IALU,EAMV,EANU,EAOVI,OAAO,CAACC,KAPE,EAQV,IARU,CAAZ;EAUD;;EAEDC,MAAM,CAACC,OAAD,EAAqB;IACzBzB,cAAc,CAAC0B,eAAf,CAA+BD,OAA/B,EAAwC,KAAKL,IAA7C,EAAmD,IAAnD,EAAyD,MAAM;MAC7D,IAAAO,iBAAA,EAAU,iBAAV;IACD,CAFD;EAGD;;EAEDC,OAAO,GAAG;IACR5B,cAAc,CAAC0B,eAAf,CAA+B,IAA/B,EAAqC,KAAKN,IAA1C,EAAgD,IAAhD,EAAsD,MAAM;MAC1D,KAAKF,SAAL,CAAeD,MAAf,CAAsBY,MAAtB;IACD,CAFD;EAGD;;EAEM,IAAHC,GAAG,GAAG;IACR,OAAO,KAAKZ,SAAL,CAAeE,IAAtB;EACD;;AAtCmB"}
@@ -1,11 +1,14 @@
1
1
  import type { SkiaSelector, SkiaValue } from "../../../values";
2
+ export declare type SharedValueType<T = number> = {
3
+ value: T;
4
+ };
2
5
  export declare const isValue: (value: unknown) => value is SkiaValue<unknown>;
3
6
  export declare const isSelector: <T, R>(value: unknown) => value is {
4
7
  selector: (v: T) => R;
5
8
  value: SkiaValue<T>;
6
9
  };
7
10
  export declare const isAnimated: <T>(props: AnimatedProps<T, never>) => boolean;
8
- export declare type AnimatedProp<T, P = any> = T | SkiaValue<T> | SkiaSelector<T, P>;
11
+ export declare type AnimatedProp<T, P = any> = T | SkiaValue<T> | SkiaSelector<T, P> | SharedValueType<T>;
9
12
  export declare type AnimatedProps<T, O extends keyof T | never = never> = {
10
13
  [K in keyof T]: K extends "children" ? T[K] : K extends O ? T[K] : AnimatedProp<T[K]>;
11
14
  };
@@ -1 +1 @@
1
- {"version":3,"names":["isValue","value","undefined","__typename__","isSelector","selector","isAnimated","props","Object","values"],"sources":["Animations.ts"],"sourcesContent":["import type { SkiaSelector, SkiaValue } from \"../../../values\";\n\nexport const isValue = (value: unknown): value is SkiaValue<unknown> => {\n if (value === undefined || value === null) {\n return false;\n }\n try {\n if (\n typeof value === \"object\" &&\n \"__typename__\" in value &&\n (value as unknown as SkiaValue<unknown>).__typename__ === \"RNSkValue\"\n ) {\n return true;\n }\n } catch {}\n return false;\n};\n\nexport const isSelector = <T, R>(\n value: unknown\n): value is {\n selector: (v: T) => R;\n value: SkiaValue<T>;\n} => {\n if (value) {\n return (\n typeof value === \"object\" &&\n \"selector\" in value &&\n \"value\" in value &&\n (value as Record<string, unknown>).selector !== undefined &&\n (value as Record<string, unknown>).value !== undefined\n );\n }\n return false;\n};\n\nexport const isAnimated = <T>(props: AnimatedProps<T>) => {\n for (const value of Object.values(props)) {\n if (isValue(value) || isSelector(value)) {\n return true;\n }\n }\n return false;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnimatedProp<T, P = any> = T | SkiaValue<T> | SkiaSelector<T, P>;\n\nexport type AnimatedProps<T, O extends keyof T | never = never> = {\n [K in keyof T]: K extends \"children\"\n ? T[K]\n : K extends O\n ? T[K]\n : AnimatedProp<T[K]>;\n};\n\nexport type SkiaProps<\n P = object,\n O extends keyof P | never = never\n> = AnimatedProps<P, O>;\n\ntype WithOptional<T extends object, N extends keyof T> = Omit<T, N> & {\n [K in N]?: T[K];\n};\n\nexport type SkiaDefaultProps<\n T extends object,\n N extends keyof T\n> = WithOptional<SkiaProps<T>, N>;\n"],"mappings":";;;;;;;AAEO,MAAMA,OAAO,GAAIC,KAAD,IAAiD;EACtE,IAAIA,KAAK,KAAKC,SAAV,IAAuBD,KAAK,KAAK,IAArC,EAA2C;IACzC,OAAO,KAAP;EACD;;EACD,IAAI;IACF,IACE,OAAOA,KAAP,KAAiB,QAAjB,IACA,kBAAkBA,KADlB,IAECA,KAAD,CAAyCE,YAAzC,KAA0D,WAH5D,EAIE;MACA,OAAO,IAAP;IACD;EACF,CARD,CAQE,MAAM,CAAE;;EACV,OAAO,KAAP;AACD,CAdM;;;;AAgBA,MAAMC,UAAU,GACrBH,KADwB,IAKrB;EACH,IAAIA,KAAJ,EAAW;IACT,OACE,OAAOA,KAAP,KAAiB,QAAjB,IACA,cAAcA,KADd,IAEA,WAAWA,KAFX,IAGCA,KAAD,CAAmCI,QAAnC,KAAgDH,SAHhD,IAICD,KAAD,CAAmCA,KAAnC,KAA6CC,SAL/C;EAOD;;EACD,OAAO,KAAP;AACD,CAhBM;;;;AAkBA,MAAMI,UAAU,GAAOC,KAAJ,IAAgC;EACxD,KAAK,MAAMN,KAAX,IAAoBO,MAAM,CAACC,MAAP,CAAcF,KAAd,CAApB,EAA0C;IACxC,IAAIP,OAAO,CAACC,KAAD,CAAP,IAAkBG,UAAU,CAACH,KAAD,CAAhC,EAAyC;MACvC,OAAO,IAAP;IACD;EACF;;EACD,OAAO,KAAP;AACD,CAPM,C,CASP"}
1
+ {"version":3,"names":["isValue","value","undefined","__typename__","isSelector","selector","isAnimated","props","Object","values"],"sources":["Animations.ts"],"sourcesContent":["import type { SkiaSelector, SkiaValue } from \"../../../values\";\n\nexport type SharedValueType<T = number> = {\n value: T;\n};\n\nexport const isValue = (value: unknown): value is SkiaValue<unknown> => {\n if (value === undefined || value === null) {\n return false;\n }\n try {\n if (\n typeof value === \"object\" &&\n \"__typename__\" in value &&\n (value as unknown as SkiaValue<unknown>).__typename__ === \"RNSkValue\"\n ) {\n return true;\n }\n } catch {}\n return false;\n};\n\nexport const isSelector = <T, R>(\n value: unknown\n): value is {\n selector: (v: T) => R;\n value: SkiaValue<T>;\n} => {\n if (value) {\n return (\n typeof value === \"object\" &&\n \"selector\" in value &&\n \"value\" in value &&\n (value as Record<string, unknown>).selector !== undefined &&\n (value as Record<string, unknown>).value !== undefined\n );\n }\n return false;\n};\n\nexport const isAnimated = <T>(props: AnimatedProps<T>) => {\n for (const value of Object.values(props)) {\n if (isValue(value) || isSelector(value)) {\n return true;\n }\n }\n return false;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnimatedProp<T, P = any> =\n | T\n | SkiaValue<T>\n | SkiaSelector<T, P>\n | SharedValueType<T>;\n\nexport type AnimatedProps<T, O extends keyof T | never = never> = {\n [K in keyof T]: K extends \"children\"\n ? T[K]\n : K extends O\n ? T[K]\n : AnimatedProp<T[K]>;\n};\n\nexport type SkiaProps<\n P = object,\n O extends keyof P | never = never\n> = AnimatedProps<P, O>;\n\ntype WithOptional<T extends object, N extends keyof T> = Omit<T, N> & {\n [K in N]?: T[K];\n};\n\nexport type SkiaDefaultProps<\n T extends object,\n N extends keyof T\n> = WithOptional<SkiaProps<T>, N>;\n"],"mappings":";;;;;;;AAMO,MAAMA,OAAO,GAAIC,KAAD,IAAiD;EACtE,IAAIA,KAAK,KAAKC,SAAV,IAAuBD,KAAK,KAAK,IAArC,EAA2C;IACzC,OAAO,KAAP;EACD;;EACD,IAAI;IACF,IACE,OAAOA,KAAP,KAAiB,QAAjB,IACA,kBAAkBA,KADlB,IAECA,KAAD,CAAyCE,YAAzC,KAA0D,WAH5D,EAIE;MACA,OAAO,IAAP;IACD;EACF,CARD,CAQE,MAAM,CAAE;;EACV,OAAO,KAAP;AACD,CAdM;;;;AAgBA,MAAMC,UAAU,GACrBH,KADwB,IAKrB;EACH,IAAIA,KAAJ,EAAW;IACT,OACE,OAAOA,KAAP,KAAiB,QAAjB,IACA,cAAcA,KADd,IAEA,WAAWA,KAFX,IAGCA,KAAD,CAAmCI,QAAnC,KAAgDH,SAHhD,IAICD,KAAD,CAAmCA,KAAnC,KAA6CC,SAL/C;EAOD;;EACD,OAAO,KAAP;AACD,CAhBM;;;;AAkBA,MAAMI,UAAU,GAAOC,KAAJ,IAAgC;EACxD,KAAK,MAAMN,KAAX,IAAoBO,MAAM,CAACC,MAAP,CAAcF,KAAd,CAApB,EAA0C;IACxC,IAAIP,OAAO,CAACC,KAAD,CAAP,IAAkBG,UAAU,CAACH,KAAD,CAAhC,EAAyC;MACvC,OAAO,IAAP;IACD;EACF;;EACD,OAAO,KAAP;AACD,CAPM,C,CASP"}
@@ -34,7 +34,14 @@ class JsiSkSurfaceFactory extends _Host.Host {
34
34
  surface = this.CanvasKit.MakeSurface(width, height);
35
35
  } else {
36
36
  const offscreen = new OC(width, height);
37
- surface = this.CanvasKit.MakeWebGLCanvasSurface(offscreen);
37
+ const webglContext = this.CanvasKit.GetWebGLContext(offscreen);
38
+ const grContext = this.CanvasKit.MakeWebGLContext(webglContext);
39
+
40
+ if (!grContext) {
41
+ throw new Error("Could not make a graphics context");
42
+ }
43
+
44
+ surface = this.CanvasKit.MakeRenderTarget(grContext, width, height);
38
45
  }
39
46
 
40
47
  if (!surface) {
@@ -1 +1 @@
1
- {"version":3,"names":["JsiSkSurfaceFactory","Host","constructor","CanvasKit","Make","width","height","surface","MakeSurface","JsiSkSurface","MakeOffscreen","OC","globalThis","OffscreenCanvas","undefined","offscreen","MakeWebGLCanvasSurface"],"sources":["JsiSkSurfaceFactory.ts"],"sourcesContent":["import type { CanvasKit, Surface } from \"canvaskit-wasm\";\n\nimport type { SurfaceFactory } from \"../types\";\n\nimport { Host } from \"./Host\";\nimport { JsiSkSurface } from \"./JsiSkSurface\";\n\nexport class JsiSkSurfaceFactory extends Host implements SurfaceFactory {\n constructor(CanvasKit: CanvasKit) {\n super(CanvasKit);\n }\n\n Make(width: number, height: number) {\n const surface = this.CanvasKit.MakeSurface(width, height);\n if (!surface) {\n return null;\n }\n return new JsiSkSurface(this.CanvasKit, surface);\n }\n\n MakeOffscreen(width: number, height: number) {\n // OffscreenCanvas may be unvailable in some environments.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const OC = (globalThis as any).OffscreenCanvas;\n let surface: Surface | null;\n if (OC === undefined) {\n surface = this.CanvasKit.MakeSurface(width, height);\n } else {\n const offscreen = new OC(width, height);\n surface = this.CanvasKit.MakeWebGLCanvasSurface(\n offscreen as unknown as HTMLCanvasElement\n );\n }\n if (!surface) {\n return null;\n }\n return new JsiSkSurface(this.CanvasKit, surface);\n }\n}\n"],"mappings":";;;;;;;AAIA;;AACA;;AAEO,MAAMA,mBAAN,SAAkCC,UAAlC,CAAiE;EACtEC,WAAW,CAACC,SAAD,EAAuB;IAChC,MAAMA,SAAN;EACD;;EAEDC,IAAI,CAACC,KAAD,EAAgBC,MAAhB,EAAgC;IAClC,MAAMC,OAAO,GAAG,KAAKJ,SAAL,CAAeK,WAAf,CAA2BH,KAA3B,EAAkCC,MAAlC,CAAhB;;IACA,IAAI,CAACC,OAAL,EAAc;MACZ,OAAO,IAAP;IACD;;IACD,OAAO,IAAIE,0BAAJ,CAAiB,KAAKN,SAAtB,EAAiCI,OAAjC,CAAP;EACD;;EAEDG,aAAa,CAACL,KAAD,EAAgBC,MAAhB,EAAgC;IAC3C;IACA;IACA,MAAMK,EAAE,GAAIC,UAAD,CAAoBC,eAA/B;IACA,IAAIN,OAAJ;;IACA,IAAII,EAAE,KAAKG,SAAX,EAAsB;MACpBP,OAAO,GAAG,KAAKJ,SAAL,CAAeK,WAAf,CAA2BH,KAA3B,EAAkCC,MAAlC,CAAV;IACD,CAFD,MAEO;MACL,MAAMS,SAAS,GAAG,IAAIJ,EAAJ,CAAON,KAAP,EAAcC,MAAd,CAAlB;MACAC,OAAO,GAAG,KAAKJ,SAAL,CAAea,sBAAf,CACRD,SADQ,CAAV;IAGD;;IACD,IAAI,CAACR,OAAL,EAAc;MACZ,OAAO,IAAP;IACD;;IACD,OAAO,IAAIE,0BAAJ,CAAiB,KAAKN,SAAtB,EAAiCI,OAAjC,CAAP;EACD;;AA9BqE"}
1
+ {"version":3,"names":["JsiSkSurfaceFactory","Host","constructor","CanvasKit","Make","width","height","surface","MakeSurface","JsiSkSurface","MakeOffscreen","OC","globalThis","OffscreenCanvas","undefined","offscreen","webglContext","GetWebGLContext","grContext","MakeWebGLContext","Error","MakeRenderTarget"],"sources":["JsiSkSurfaceFactory.ts"],"sourcesContent":["import type { CanvasKit, Surface } from \"canvaskit-wasm\";\n\nimport type { SurfaceFactory } from \"../types\";\n\nimport { Host } from \"./Host\";\nimport { JsiSkSurface } from \"./JsiSkSurface\";\n\nexport class JsiSkSurfaceFactory extends Host implements SurfaceFactory {\n constructor(CanvasKit: CanvasKit) {\n super(CanvasKit);\n }\n\n Make(width: number, height: number) {\n const surface = this.CanvasKit.MakeSurface(width, height);\n if (!surface) {\n return null;\n }\n return new JsiSkSurface(this.CanvasKit, surface);\n }\n\n MakeOffscreen(width: number, height: number) {\n // OffscreenCanvas may be unvailable in some environments.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const OC = (globalThis as any).OffscreenCanvas;\n let surface: Surface | null;\n if (OC === undefined) {\n surface = this.CanvasKit.MakeSurface(width, height);\n } else {\n const offscreen = new OC(width, height);\n const webglContext = this.CanvasKit.GetWebGLContext(offscreen);\n const grContext = this.CanvasKit.MakeWebGLContext(webglContext);\n if (!grContext) {\n throw new Error(\"Could not make a graphics context\");\n }\n surface = this.CanvasKit.MakeRenderTarget(grContext, width, height);\n }\n if (!surface) {\n return null;\n }\n return new JsiSkSurface(this.CanvasKit, surface);\n }\n}\n"],"mappings":";;;;;;;AAIA;;AACA;;AAEO,MAAMA,mBAAN,SAAkCC,UAAlC,CAAiE;EACtEC,WAAW,CAACC,SAAD,EAAuB;IAChC,MAAMA,SAAN;EACD;;EAEDC,IAAI,CAACC,KAAD,EAAgBC,MAAhB,EAAgC;IAClC,MAAMC,OAAO,GAAG,KAAKJ,SAAL,CAAeK,WAAf,CAA2BH,KAA3B,EAAkCC,MAAlC,CAAhB;;IACA,IAAI,CAACC,OAAL,EAAc;MACZ,OAAO,IAAP;IACD;;IACD,OAAO,IAAIE,0BAAJ,CAAiB,KAAKN,SAAtB,EAAiCI,OAAjC,CAAP;EACD;;EAEDG,aAAa,CAACL,KAAD,EAAgBC,MAAhB,EAAgC;IAC3C;IACA;IACA,MAAMK,EAAE,GAAIC,UAAD,CAAoBC,eAA/B;IACA,IAAIN,OAAJ;;IACA,IAAII,EAAE,KAAKG,SAAX,EAAsB;MACpBP,OAAO,GAAG,KAAKJ,SAAL,CAAeK,WAAf,CAA2BH,KAA3B,EAAkCC,MAAlC,CAAV;IACD,CAFD,MAEO;MACL,MAAMS,SAAS,GAAG,IAAIJ,EAAJ,CAAON,KAAP,EAAcC,MAAd,CAAlB;MACA,MAAMU,YAAY,GAAG,KAAKb,SAAL,CAAec,eAAf,CAA+BF,SAA/B,CAArB;MACA,MAAMG,SAAS,GAAG,KAAKf,SAAL,CAAegB,gBAAf,CAAgCH,YAAhC,CAAlB;;MACA,IAAI,CAACE,SAAL,EAAgB;QACd,MAAM,IAAIE,KAAJ,CAAU,mCAAV,CAAN;MACD;;MACDb,OAAO,GAAG,KAAKJ,SAAL,CAAekB,gBAAf,CAAgCH,SAAhC,EAA2Cb,KAA3C,EAAkDC,MAAlD,CAAV;IACD;;IACD,IAAI,CAACC,OAAL,EAAc;MACZ,OAAO,IAAP;IACD;;IACD,OAAO,IAAIE,0BAAJ,CAAiB,KAAKN,SAAtB,EAAiCI,OAAjC,CAAP;EACD;;AAjCqE"}
@@ -1 +1,2 @@
1
1
  export * from "./useSharedValueEffect";
2
+ export * from "./renderHelpers";
@@ -1,2 +1,3 @@
1
1
  export * from "./useSharedValueEffect";
2
+ export * from "./renderHelpers";
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./useSharedValueEffect\";\n"],"mappings":"AAAA,cAAc,wBAAd"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./useSharedValueEffect\";\nexport * from \"./renderHelpers\";\n"],"mappings":"AAAA,cAAc,wBAAd;AACA,cAAc,iBAAd"}
@@ -0,0 +1,8 @@
1
+ import type { SharedValueType } from "../../renderer/processors/Animations";
2
+ export declare const HAS_REANIMATED: boolean;
3
+ export declare function throwOnIncompatibleReanimatedVersion(): void;
4
+ export declare const useSharedValue: any;
5
+ export declare const startMapper: any;
6
+ export declare const stopMapper: any;
7
+ export declare const runOnJS: any;
8
+ export declare const isSharedValue: <T>(value: unknown) => value is SharedValueType<T>;
@@ -0,0 +1,51 @@
1
+ var _Reanimated, _Reanimated2, _Reanimated3, _Reanimated4;
2
+
3
+ import { useMemo } from "react";
4
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
+ let Reanimated;
6
+
7
+ try {
8
+ Reanimated = require("react-native-reanimated");
9
+ } catch (e) {// Ignore
10
+ }
11
+
12
+ export const HAS_REANIMATED = !!Reanimated;
13
+
14
+ function throwOnMissingReanimated() {
15
+ throw new Error("Reanimated was not found, make sure react-native-reanimated package is installed if you want to use \
16
+ react-naitve-skia's integration layer API.");
17
+ }
18
+
19
+ let ReanimatedVersionTested = false;
20
+ export function throwOnIncompatibleReanimatedVersion() {
21
+ if (ReanimatedVersionTested) {
22
+ // we avoid testing version more than once as it won't change and we throw
23
+ // an error when version is incompatible
24
+ return;
25
+ }
26
+
27
+ ReanimatedVersionTested = true;
28
+
29
+ const reanimatedVersion = // eslint-disable-next-line import/extensions
30
+ require("react-native-reanimated/package.json").version; // The first compatible version is 3.0.0 but we need to exclude 3.0.0 pre-releases
31
+ // as they have limited support for the used API.
32
+
33
+
34
+ if (!reanimatedVersion || reanimatedVersion < "3.0.0" || reanimatedVersion.includes("3.0.0-")) {
35
+ throw new Error(`Reanimated version ${reanimatedVersion} is not supported, please upgrade to 3.0.0 or newer.`);
36
+ }
37
+ }
38
+ export const useSharedValue = ((_Reanimated = Reanimated) === null || _Reanimated === void 0 ? void 0 : _Reanimated.useSharedValue) || (value => useMemo(() => ({
39
+ value
40
+ }), [value]));
41
+ export const startMapper = ((_Reanimated2 = Reanimated) === null || _Reanimated2 === void 0 ? void 0 : _Reanimated2.startMapper) || throwOnMissingReanimated;
42
+ export const stopMapper = ((_Reanimated3 = Reanimated) === null || _Reanimated3 === void 0 ? void 0 : _Reanimated3.stopMapper) || throwOnMissingReanimated;
43
+ export const runOnJS = ((_Reanimated4 = Reanimated) === null || _Reanimated4 === void 0 ? void 0 : _Reanimated4.runOnJS) || throwOnMissingReanimated;
44
+ export const isSharedValue = value => {
45
+ if (!Reanimated) {
46
+ throwOnMissingReanimated();
47
+ }
48
+
49
+ return !!value && Reanimated.isSharedValue(value);
50
+ };
51
+ //# sourceMappingURL=moduleWrapper.js.map