@shopify/react-native-skia 0.1.176 → 0.1.178

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. package/android/CMakeLists.txt +2 -0
  2. package/cpp/jsi/JsiHostObject.cpp +13 -7
  3. package/cpp/jsi/JsiHostObject.h +3 -1
  4. package/cpp/jsi/RuntimeAwareCache.cpp +9 -0
  5. package/cpp/jsi/RuntimeAwareCache.h +101 -0
  6. package/cpp/jsi/RuntimeLifecycleMonitor.cpp +57 -0
  7. package/cpp/jsi/RuntimeLifecycleMonitor.h +32 -0
  8. package/cpp/rnskia/RNSkManager.cpp +4 -0
  9. package/cpp/rnskia/dom/base/JsiDomNode.h +22 -2
  10. package/lib/commonjs/external/reanimated/index.d.ts +1 -0
  11. package/lib/commonjs/external/reanimated/index.js +13 -0
  12. package/lib/commonjs/external/reanimated/index.js.map +1 -1
  13. package/lib/commonjs/external/reanimated/moduleWrapper.d.ts +8 -0
  14. package/lib/commonjs/external/reanimated/moduleWrapper.js +72 -0
  15. package/lib/commonjs/external/reanimated/moduleWrapper.js.map +1 -0
  16. package/lib/commonjs/external/reanimated/renderHelpers.d.ts +5 -0
  17. package/lib/commonjs/external/reanimated/renderHelpers.js +85 -0
  18. package/lib/commonjs/external/reanimated/renderHelpers.js.map +1 -0
  19. package/lib/commonjs/external/reanimated/useSharedValueEffect.d.ts +2 -5
  20. package/lib/commonjs/external/reanimated/useSharedValueEffect.js +10 -25
  21. package/lib/commonjs/external/reanimated/useSharedValueEffect.js.map +1 -1
  22. package/lib/commonjs/headless/index.d.ts +3 -0
  23. package/lib/commonjs/headless/index.js +57 -0
  24. package/lib/commonjs/headless/index.js.map +1 -0
  25. package/lib/commonjs/mock/index.d.ts +1 -2
  26. package/lib/commonjs/mock/index.js +0 -4
  27. package/lib/commonjs/mock/index.js.map +1 -1
  28. package/lib/commonjs/renderer/Canvas.js +7 -1
  29. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  30. package/lib/commonjs/renderer/Container.d.ts +2 -1
  31. package/lib/commonjs/renderer/Container.js +2 -0
  32. package/lib/commonjs/renderer/Container.js.map +1 -1
  33. package/lib/commonjs/renderer/HostConfig.js +6 -4
  34. package/lib/commonjs/renderer/HostConfig.js.map +1 -1
  35. package/lib/commonjs/renderer/Reconciler.d.ts +1 -1
  36. package/lib/commonjs/renderer/Reconciler.js +2 -1
  37. package/lib/commonjs/renderer/Reconciler.js.map +1 -1
  38. package/lib/commonjs/renderer/processors/Animations/Animations.d.ts +4 -1
  39. package/lib/commonjs/renderer/processors/Animations/Animations.js.map +1 -1
  40. package/lib/module/external/reanimated/index.d.ts +1 -0
  41. package/lib/module/external/reanimated/index.js +1 -0
  42. package/lib/module/external/reanimated/index.js.map +1 -1
  43. package/lib/module/external/reanimated/moduleWrapper.d.ts +8 -0
  44. package/lib/module/external/reanimated/moduleWrapper.js +51 -0
  45. package/lib/module/external/reanimated/moduleWrapper.js.map +1 -0
  46. package/lib/module/external/reanimated/renderHelpers.d.ts +5 -0
  47. package/lib/module/external/reanimated/renderHelpers.js +76 -0
  48. package/lib/module/external/reanimated/renderHelpers.js.map +1 -0
  49. package/lib/module/external/reanimated/useSharedValueEffect.d.ts +2 -5
  50. package/lib/module/external/reanimated/useSharedValueEffect.js +7 -22
  51. package/lib/module/external/reanimated/useSharedValueEffect.js.map +1 -1
  52. package/lib/module/headless/index.d.ts +3 -0
  53. package/lib/module/headless/index.js +29 -0
  54. package/lib/module/headless/index.js.map +1 -0
  55. package/lib/module/mock/index.d.ts +1 -2
  56. package/lib/module/mock/index.js +0 -3
  57. package/lib/module/mock/index.js.map +1 -1
  58. package/lib/module/renderer/Canvas.js +7 -1
  59. package/lib/module/renderer/Canvas.js.map +1 -1
  60. package/lib/module/renderer/Container.d.ts +2 -1
  61. package/lib/module/renderer/Container.js +2 -0
  62. package/lib/module/renderer/Container.js.map +1 -1
  63. package/lib/module/renderer/HostConfig.js +5 -4
  64. package/lib/module/renderer/HostConfig.js.map +1 -1
  65. package/lib/module/renderer/Reconciler.d.ts +1 -1
  66. package/lib/module/renderer/Reconciler.js +2 -1
  67. package/lib/module/renderer/Reconciler.js.map +1 -1
  68. package/lib/module/renderer/processors/Animations/Animations.d.ts +4 -1
  69. package/lib/module/renderer/processors/Animations/Animations.js.map +1 -1
  70. package/lib/typescript/src/external/reanimated/index.d.ts +1 -0
  71. package/lib/typescript/src/external/reanimated/moduleWrapper.d.ts +8 -0
  72. package/lib/typescript/src/external/reanimated/renderHelpers.d.ts +5 -0
  73. package/lib/typescript/src/external/reanimated/useSharedValueEffect.d.ts +2 -5
  74. package/lib/typescript/src/headless/index.d.ts +3 -0
  75. package/lib/typescript/src/mock/index.d.ts +1 -2
  76. package/lib/typescript/src/renderer/Container.d.ts +2 -1
  77. package/lib/typescript/src/renderer/Reconciler.d.ts +1 -1
  78. package/lib/typescript/src/renderer/processors/Animations/Animations.d.ts +4 -1
  79. package/package.json +1 -1
  80. package/src/external/reanimated/index.ts +1 -0
  81. package/src/external/reanimated/moduleWrapper.ts +62 -0
  82. package/src/external/reanimated/renderHelpers.ts +74 -0
  83. package/src/external/reanimated/useSharedValueEffect.ts +17 -23
  84. package/src/headless/index.ts +31 -0
  85. package/src/mock/index.ts +0 -5
  86. package/src/renderer/Canvas.tsx +6 -2
  87. package/src/renderer/Container.tsx +2 -1
  88. package/src/renderer/HostConfig.ts +8 -2
  89. package/src/renderer/Reconciler.tsx +3 -2
  90. package/src/renderer/processors/Animations/Animations.ts +9 -1
@@ -1,17 +1,5 @@
1
- var _Reanimated;
2
-
3
- import { useEffect, useMemo } from "react"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
-
5
- let Reanimated;
6
-
7
- try {
8
- Reanimated = require("react-native-reanimated");
9
- } catch (e) {// Ignore
10
- }
11
-
12
- const useSharedValueWrapper = ((_Reanimated = Reanimated) === null || _Reanimated === void 0 ? void 0 : _Reanimated.useSharedValue) === undefined ? value => useMemo(() => ({
13
- value
14
- }), [value]) : Reanimated.useSharedValue;
1
+ import { useEffect } from "react";
2
+ import { HAS_REANIMATED, useSharedValue, runOnJS, startMapper, stopMapper } from "./moduleWrapper";
15
3
  /**
16
4
  * Connects a shared value from reanimated to a SkiaView or Canvas
17
5
  * so whenever the shared value changes the SkiaView will redraw.
@@ -24,17 +12,14 @@ export const useSharedValueEffect = function (cb, value) {
24
12
  values[_key - 2] = arguments[_key];
25
13
  }
26
14
 
27
- const input = useSharedValueWrapper(0);
15
+ console.warn(`useSharedValueEffect() is now deprecated, you can use Reanimated values directly.
16
+ Learn more at https://shopify.github.io/react-native-skia/.`);
17
+ const input = useSharedValue(0);
28
18
  useEffect(() => {
29
- if (!Reanimated) {
19
+ if (!HAS_REANIMATED) {
30
20
  console.warn("Reanimated was not found and the useSharedValueEffect hook will have no effect.");
31
21
  } else {
32
- const {
33
- runOnJS,
34
- startMapper,
35
- stopMapper
36
- } = Reanimated; // Start a mapper in Reanimated
37
-
22
+ // Start a mapper in Reanimated
38
23
  const mapperId = startMapper(() => {
39
24
  "worklet";
40
25
 
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","useMemo","Reanimated","require","e","useSharedValueWrapper","useSharedValue","undefined","value","useSharedValueEffect","cb","values","input","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,SAASA,SAAT,EAAoBC,OAApB,QAAmC,OAAnC,C,CAEA;;AACA,IAAIC,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,IAAmBP,OAAO,CAAC,OAAO;EAAEO;AAAF,CAAP,CAAD,EAAoB,CAACA,KAAD,CAApB,CAD9B,GAEIN,UAAU,CAACI,cAHjB;AAKA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMG,oBAAoB,GAAG,UAClCC,EADkC,EAElCF,KAFkC,EAI/B;EAAA,kCADAG,MACA;IADAA,MACA;EAAA;;EACH,MAAMC,KAAK,GAAGP,qBAAqB,CAAC,CAAD,CAAnC;EAEAL,SAAS,CAAC,MAAM;IACd,IAAI,CAACE,UAAL,EAAiB;MACfW,OAAO,CAACC,IAAR,CACE,iFADF;IAGD,CAJD,MAIO;MACL,MAAM;QAAEC,OAAF;QAAWC,WAAX;QAAwBC;MAAxB,IAAuCf,UAA7C,CADK,CAGL;;MACA,MAAMgB,QAAQ,GAAGF,WAAW,CAC1B,MAAM;QACJ;;QACAD,OAAO,CAACL,EAAD,CAAP;MACD,CAJyB,EAK1B,CAACF,KAAD,EAAQ,GAAGG,MAAX,CAL0B,EAM1B,CAACC,KAAD,CAN0B,CAA5B,CAJK,CAYL;;MACA,OAAO,MAAM;QACX,IAAIK,UAAU,IAAIC,QAAQ,KAAKX,SAA/B,EAA0C;UACxCU,UAAU,CAACC,QAAD,CAAV;QACD;MACF,CAJD;IAKD;;IACD,OAAO,MAAM,CAAE,CAAf,CAxBc,CAyBd;EACD,CA1BQ,EA0BN,CAACN,KAAD,EAAQJ,KAAR,EAAe,GAAGG,MAAlB,CA1BM,CAAT;AA2BD,CAlCM"}
1
+ {"version":3,"names":["useEffect","HAS_REANIMATED","useSharedValue","runOnJS","startMapper","stopMapper","useSharedValueEffect","cb","value","values","console","warn","input","mapperId","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,SAASA,SAAT,QAA0B,OAA1B;AAIA,SACEC,cADF,EAEEC,cAFF,EAGEC,OAHF,EAIEC,WAJF,EAKEC,UALF,QAMO,iBANP;AAQA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,oBAAoB,GAAG,UAClCC,EADkC,EAElCC,KAFkC,EAI/B;EAAA,kCADAC,MACA;IADAA,MACA;EAAA;;EACHC,OAAO,CAACC,IAAR,CACG;AACL,4DAFE;EAIA,MAAMC,KAAK,GAAGV,cAAc,CAAC,CAAD,CAA5B;EAEAF,SAAS,CAAC,MAAM;IACd,IAAI,CAACC,cAAL,EAAqB;MACnBS,OAAO,CAACC,IAAR,CACE,iFADF;IAGD,CAJD,MAIO;MACL;MACA,MAAME,QAAQ,GAAGT,WAAW,CAC1B,MAAM;QACJ;;QACAD,OAAO,CAACI,EAAD,CAAP;MACD,CAJyB,EAK1B,CAACC,KAAD,EAAQ,GAAGC,MAAX,CAL0B,EAM1B,CAACG,KAAD,CAN0B,CAA5B,CAFK,CAUL;;MACA,OAAO,MAAM;QACX,IAAIP,UAAU,IAAIQ,QAAQ,KAAKC,SAA/B,EAA0C;UACxCT,UAAU,CAACQ,QAAD,CAAV;QACD;MACF,CAJD;IAKD;;IACD,OAAO,MAAM,CAAE,CAAf,CAtBc,CAuBd;EACD,CAxBQ,EAwBN,CAACD,KAAD,EAAQJ,KAAR,EAAe,GAAGC,MAAlB,CAxBM,CAAT;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,29 @@
1
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
+ // @ts-ignore
3
+ import { JsiSkApi } from "../skia/web";
4
+ import { SkiaRoot } from "../renderer/Reconciler";
5
+ import { JsiDrawingContext } from "../dom/types";
6
+ export * from "../renderer/components"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
+
8
+ let Skia;
9
+ export const draw = (element, width, height) => {
10
+ if (!Skia) {
11
+ Skia = JsiSkApi(CanvasKit);
12
+ }
13
+
14
+ const surface = Skia.Surface.MakeOffscreen(width, height);
15
+
16
+ if (surface === null) {
17
+ throw new Error("Couldn't create surface!");
18
+ }
19
+
20
+ const root = new SkiaRoot(Skia);
21
+ root.render(element);
22
+ const canvas = surface.getCanvas();
23
+ const ctx = new JsiDrawingContext(Skia, canvas);
24
+ root.dom.render(ctx);
25
+ surface.flush();
26
+ const image = surface.makeImageSnapshot();
27
+ return image;
28
+ };
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["JsiSkApi","SkiaRoot","JsiDrawingContext","Skia","draw","element","width","height","CanvasKit","surface","Surface","MakeOffscreen","Error","root","render","canvas","getCanvas","ctx","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":"AAAA;AACA;AAIA,SAASA,QAAT,QAAyB,aAAzB;AACA,SAASC,QAAT,QAAyB,wBAAzB;AACA,SAASC,iBAAT,QAAkC,cAAlC;AAEA,cAAc,wBAAd,C,CAEA;;AACA,IAAIC,IAAJ;AAEA,OAAO,MAAMC,IAAI,GAAG,CAACC,OAAD,EAAqBC,KAArB,EAAoCC,MAApC,KAAuD;EACzE,IAAI,CAACJ,IAAL,EAAW;IACTA,IAAI,GAAGH,QAAQ,CAACQ,SAAD,CAAf;EACD;;EACD,MAAMC,OAAO,GAAGN,IAAI,CAACO,OAAL,CAAaC,aAAb,CAA2BL,KAA3B,EAAkCC,MAAlC,CAAhB;;EACA,IAAIE,OAAO,KAAK,IAAhB,EAAsB;IACpB,MAAM,IAAIG,KAAJ,CAAU,0BAAV,CAAN;EACD;;EACD,MAAMC,IAAI,GAAG,IAAIZ,QAAJ,CAAaE,IAAb,CAAb;EACAU,IAAI,CAACC,MAAL,CAAYT,OAAZ;EACA,MAAMU,MAAM,GAAGN,OAAO,CAACO,SAAR,EAAf;EACA,MAAMC,GAAG,GAAG,IAAIf,iBAAJ,CAAsBC,IAAtB,EAA4BY,MAA5B,CAAZ;EACAF,IAAI,CAACK,GAAL,CAASJ,MAAT,CAAgBG,GAAhB;EACAR,OAAO,CAACU,KAAR;EACA,MAAMC,KAAK,GAAGX,OAAO,CAACY,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;
@@ -3,7 +3,6 @@ import * as Values from "../values/web";
3
3
  import * as ValuesHooks from "../values/hooks";
4
4
  import { Selector } from "../values/selector";
5
5
  import * as BaseSkia from "../skia/types";
6
- import { useSharedValueEffect } from "../external/reanimated/useSharedValueEffect";
7
6
  import * as timingFunctions from "../animation/timing";
8
7
  import * as springFunctions from "../animation/spring";
9
8
  import * as decayFunctions from "../animation/decay";
@@ -83,8 +82,6 @@ export const Mock = {
83
82
  bottomRight: Noop,
84
83
  center: Noop,
85
84
  processTransform2d: Noop,
86
- // ExternalExports
87
- useSharedValueEffect,
88
85
  // ValueExports
89
86
  ...Values,
90
87
  ...ValuesHooks,
@@ -1 +1 @@
1
- {"version":3,"names":["Values","ValuesHooks","Selector","BaseSkia","useSharedValueEffect","timingFunctions","springFunctions","decayFunctions","interpolateFn","interpolatePathFn","interpolateVectorFn","ShaderLib","Stub","constructor","Proxy","get","apply","set","Noop","Skia","vec","x","y","Mock","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","interpolateColors","_value","_inputRange","_outputRange","Float32Array","of","mixColors","_v","_x","_y","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":"AAAA;AAGA,OAAO,KAAKA,MAAZ,MAAwB,eAAxB;AACA,OAAO,KAAKC,WAAZ,MAA6B,iBAA7B;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,OAAO,KAAKC,QAAZ,MAA0B,eAA1B;AAKA,SAASC,oBAAT,QAAqC,6CAArC;AACA,OAAO,KAAKC,eAAZ,MAAiC,qBAAjC;AACA,OAAO,KAAKC,eAAZ,MAAiC,qBAAjC;AACA,OAAO,KAAKC,cAAZ,MAAgC,oBAAhC;AACA,OAAO,KAAKC,aAAZ,MAA+B,oCAA/B;AACA,OAAO,KAAKC,iBAAZ,MAAmC,yCAAnC;AACA,OAAO,KAAKC,mBAAZ,MAAqC,0CAArC;AACA,SAASC,SAAT,QAA0B,0CAA1B;;AAEA,MAAMC,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,CAAhC;;AAEA,OAAO,MAAMC,IAAa,GAAG,IAAIP,IAAJ,EAAtB;AAEP,OAAO,MAAMQ,GAAG,GAAG,CAACC,CAAD,EAAaC,CAAb;EAAA;;EAAA,OAA6B;IAAED,CAAC,E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ElD;AA9Df,CAPC"}
1
+ {"version":3,"names":["Values","ValuesHooks","Selector","BaseSkia","timingFunctions","springFunctions","decayFunctions","interpolateFn","interpolatePathFn","interpolateVectorFn","ShaderLib","Stub","constructor","Proxy","get","apply","set","Noop","Skia","vec","x","y","Mock","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","interpolateColors","_value","_inputRange","_outputRange","Float32Array","of","mixColors","_v","_x","_y","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":"AAAA;AAGA,OAAO,KAAKA,MAAZ,MAAwB,eAAxB;AACA,OAAO,KAAKC,WAAZ,MAA6B,iBAA7B;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,OAAO,KAAKC,QAAZ,MAA0B,eAA1B;AAIA,OAAO,KAAKC,eAAZ,MAAiC,qBAAjC;AACA,OAAO,KAAKC,eAAZ,MAAiC,qBAAjC;AACA,OAAO,KAAKC,cAAZ,MAAgC,oBAAhC;AACA,OAAO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1CC;EA2CJ,GAAGC,WA3CC;EA4CJC,QA5CI;EA6CJ;EACA,GAAGE,eA9CC;EA+CJ,GAAGC,eA/CC;EAgDJ,GAAGC,cAhDC;EAiDJ,GAAGC,aAjDC;EAkDJ,GAAGC,iBAlDC;EAmDJ,GAAGC,mBAnDC;EAoDJ+C,iBAAiB,EAAE,CACjBC,MADiB,EAEjBC,WAFiB,EAGjBC,YAHiB,KAIdC,YAAY,CAACC,EAAb,CAAgB,CAAhB,EAAmB,CAAnB,EAAsB,CAAtB,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;EA0DJnD,SA1DI;EA2DJwD,aAAa,EAAEjD,IA3DX;EA4DJkD,iBAAiB,EAAElD;AA5Df,CANC"}
@@ -22,6 +22,12 @@ export const Canvas = /*#__PURE__*/forwardRef((_ref, forwardedRef) => {
22
22
 
23
23
  (_innerRef$current = innerRef.current) === null || _innerRef$current === void 0 ? void 0 : _innerRef$current.redraw();
24
24
  }, [innerRef]);
25
+ const getNativeId = useCallback(() => {
26
+ var _innerRef$current$nat, _innerRef$current2;
27
+
28
+ const id = (_innerRef$current$nat = (_innerRef$current2 = innerRef.current) === null || _innerRef$current2 === void 0 ? void 0 : _innerRef$current2.nativeId) !== null && _innerRef$current$nat !== void 0 ? _innerRef$current$nat : -1;
29
+ return id;
30
+ }, [innerRef]);
25
31
  const registerValues = useCallback(values => {
26
32
  if (ref.current !== null) {
27
33
  return ref.current.registerValues(values);
@@ -29,7 +35,7 @@ export const Canvas = /*#__PURE__*/forwardRef((_ref, forwardedRef) => {
29
35
 
30
36
  return () => {};
31
37
  }, [ref]);
32
- const root = useMemo(() => new SkiaRoot(Skia, registerValues, redraw), [redraw, registerValues]); // Render effect
38
+ const root = useMemo(() => new SkiaRoot(Skia, registerValues, redraw, getNativeId), [redraw, registerValues, getNativeId]); // Render effect
33
39
 
34
40
  useEffect(() => {
35
41
  root.render(children);
@@ -1 +1 @@
1
- {"version":3,"names":["React","useEffect","useCallback","useMemo","forwardRef","useRef","SkiaDomView","Skia","SkiaRoot","useCanvasRef","Canvas","forwardedRef","children","style","debug","mode","onTouch","onSize","props","innerRef","ref","useCombinedRefs","redraw","current","registerValues","values","root","render","unmount","dom","refs","targetRef","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,OAAOA,KAAP,IACEC,SADF,EAEEC,WAFF,EAGEC,OAHF,EAIEC,UAJF,EAKEC,MALF,QAMO,OANP;AAcA,SAASC,WAAT,QAA4B,UAA5B;AACA,SAASC,IAAT,QAAqB,cAArB;AAIA,SAASC,QAAT,QAAyB,cAAzB;AAEA,OAAO,MAAMC,YAAY,GAAG,MAAMJ,MAAM,CAAc,IAAd,CAAjC;AAQP,OAAO,MAAMK,MAAM,gBAAGN,UAAU,CAC9B,OAEEO,YAFF,KAGK;EAAA,IAFH;IAAEC,QAAF;IAAYC,KAAZ;IAAmBC,KAAnB;IAA0BC,IAA1B;IAAgCC,OAAhC;IAAyCC,MAAzC;IAAiD,GAAGC;EAApD,CAEG;EACH,MAAMC,QAAQ,GAAGV,YAAY,EAA7B;EACA,MAAMW,GAAG,GAAGC,eAAe,CAACV,YAAD,EAAeQ,QAAf,CAA3B;EACA,MAAMG,MAAM,GAAGpB,WAAW,CAAC,MAAM;IAAA;;IAC/B,qBAAAiB,QAAQ,CAACI,OAAT,wEAAkBD,MAAlB;EACD,CAFyB,EAEvB,CAACH,QAAD,CAFuB,CAA1B;EAIA,MAAMK,cAAc,GAAGtB,WAAW,CAC/BuB,MAAD,IAAuC;IACrC,IAAIL,GAAG,CAACG,OAAJ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ACLH,GAAG,CAACG,OAAJ,GAAcQ,SAAS,CAACR,OAAxB;QACD;MACF;IACF,CARD;EASD,CAVD,EAUG,CAACO,IAAD,CAVH;EAWA,OAAOC,SAAP;AACD,CAhBD"}
1
+ {"version":3,"names":["React","useEffect","useCallback","useMemo","forwardRef","useRef","SkiaDomView","Skia","SkiaRoot","useCanvasRef","Canvas","forwardedRef","children","style","debug","mode","onTouch","onSize","props","innerRef","ref","useCombinedRefs","redraw","current","getNativeId","id","nativeId","registerValues","values","root","render","unmount","dom","refs","targetRef","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,OAAOA,KAAP,IACEC,SADF,EAEEC,WAFF,EAGEC,OAHF,EAIEC,UAJF,EAKEC,MALF,QAMO,OANP;AAcA,SAASC,WAAT,QAA4B,UAA5B;AACA,SAASC,IAAT,QAAqB,cAArB;AAIA,SAASC,QAAT,QAAyB,cAAzB;AAEA,OAAO,MAAMC,YAAY,GAAG,MAAMJ,MAAM,CAAc,IAAd,CAAjC;AAQP,OAAO,MAAMK,MAAM,gBAAGN,UAAU,CAC9B,OAEEO,YAFF,KAGK;EAAA,IAFH;IAAEC,QAAF;IAAYC,KAAZ;IAAmBC,KAAnB;IAA0BC,IAA1B;IAAgCC,OAAhC;IAAyCC,MAAzC;IAAiD,GAAGC;EAApD,CAEG;EACH,MAAMC,QAAQ,GAAGV,YAAY,EAA7B;EACA,MAAMW,GAAG,GAAGC,eAAe,CAACV,YAAD,EAAeQ,QAAf,CAA3B;EACA,MAAMG,MAAM,GAAGpB,WAAW,CAAC,MAAM;IAAA;;IAC/B,qBAAAiB,QAAQ,CAACI,OAAT,wEAAkBD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DP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMG,eAAe,GAAG,YAEnB;EAAA,kCADAY,IACA;IADAA,IACA;EAAA;;EACH,MAAMC,SAAS,GAAGlC,KAAK,CAACK,MAAN,CAAgB,IAAhB,CAAlB;EACAL,KAAK,CAACC,SAAN,CAAgB,MAAM;IACpBgC,IAAI,CAACE,OAAL,CAAcf,GAAD,IAAS;MACpB,IAAIA,GAAJ,EAAS;QACP,IAAI,OAAOA,GAAP,KAAe,UAAnB,EAA+B;UAC7BA,GAAG,CAACc,SAAS,CAACX,OAAX,CAAH;QACD,CAFD,MAEO;UACLH,GAAG,CAACG,OAAJ,GAAcW,SAAS,CAACX,OAAxB;QACD;MACF;IACF,CARD;EASD,CAVD,EAUG,CAACU,IAAD,CAVH;EAWA,OAAOC,SAAP;AACD,CAhBD"}
@@ -4,9 +4,10 @@ import type { DependencyManager } from "./DependencyManager";
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
  }
@@ -4,8 +4,10 @@ import { JsiSkDOM } from "../dom/nodes";
4
4
  export class Container {
5
5
  constructor(Skia, depMgr) {
6
6
  let redraw = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : () => {};
7
+ let getNativeId = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : () => 0;
7
8
  this.depMgr = depMgr;
8
9
  this.redraw = redraw;
10
+ this.getNativeId = getNativeId;
9
11
 
10
12
  _defineProperty(this, "_root", void 0);
11
13
 
@@ -1 +1 @@
1
- {"version":3,"names":["JsiSkDOM","Container","constructor","Skia","depMgr","redraw","Sk","_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,SAASA,QAAT,QAAyB,cAAzB;AAWA,OAAO,MAAMC,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,IAAIN,QAAJ,CAAa;MAAEG,IAAF;MAAQC;IAAR,CAAb,CAAV;IACA,KAAKG,KAAL,GAAa,KAAKD,EAAL,CAAQE,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":["JsiSkDOM","Container","constructor","Skia","depMgr","redraw","getNativeId","Sk","_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,SAASA,QAAT,QAAyB,cAAzB;AAWA,OAAO,MAAMC,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,IAAIP,QAAJ,CAAa;MAAEG,IAAF;MAAQC;IAAR,CAAb,CAAV;IACA,KAAKI,KAAL,GAAa,KAAKD,EAAL,CAAQE,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"}
@@ -1,5 +1,6 @@
1
1
  /*global NodeJS*/
2
2
  import { DefaultEventPriority } from "react-reconciler/constants";
3
+ import { bindReanimatedProps, extractReanimatedProps } from "../external/reanimated";
3
4
  import { createNode } from "./HostComponents";
4
5
  import { isSelector, isValue } from "./processors";
5
6
  import { mapKeys, shallowEq } from "./typeddash";
@@ -68,9 +69,9 @@ export const skHostConfig = {
68
69
 
69
70
  createInstance(type, pristineProps, container, _hostContext, _internalInstanceHandle) {
70
71
  debug("createInstance", type);
71
- const props = { ...pristineProps
72
- };
72
+ const [props, reanimatedProps] = extractReanimatedProps(pristineProps);
73
73
  const node = createNode(container, type, materialize(props));
74
+ bindReanimatedProps(container, node, reanimatedProps);
74
75
  container.depMgr.subscribeNode(node, props);
75
76
  return node;
76
77
  },
@@ -125,10 +126,10 @@ export const skHostConfig = {
125
126
  return;
126
127
  }
127
128
 
128
- const props = { ...nextProps
129
- };
129
+ const [props, reanimatedProps] = extractReanimatedProps(nextProps);
130
130
  updatePayload.depMgr.unsubscribeNode(instance);
131
131
  instance.setProps(materialize(props));
132
+ bindReanimatedProps(updatePayload, instance, reanimatedProps);
132
133
  updatePayload.depMgr.subscribeNode(instance, props);
133
134
  },
134
135
 
@@ -1 +1 @@
1
- {"version":3,"names":["DefaultEventPriority","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","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\";\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":"AAAA;AAEA,SAASA,oBAAT,QAAqC,4BAArC;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,WA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IAAI,CAACE,QAAL,CAAcF,IAAI,CAACG,KAAL,CAAWF,OAAzB,CAAd;IACD;EACF,CAPD;EASA,OAAOH,MAAP;AACD,CAZD"}
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\";\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,wBAHP;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,CAA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X,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"}
@@ -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>;
@@ -17,13 +17,14 @@ export class SkiaRoot {
17
17
  constructor(Skia) {
18
18
  let registerValues = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : () => () => {};
19
19
  let redraw = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : () => {};
20
+ let getNativeId = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : () => 0;
20
21
 
21
22
  _defineProperty(this, "root", void 0);
22
23
 
23
24
  _defineProperty(this, "container", void 0);
24
25
 
25
26
  const depMgr = createDependencyManager(registerValues);
26
- this.container = new Container(Skia, depMgr, redraw);
27
+ this.container = new Container(Skia, depMgr, redraw, getNativeId);
27
28
  this.root = skiaReconciler.createContainer(this.container, 0, null, true, null, "", console.error, null);
28
29
  }
29
30
 
@@ -1 +1 @@
1
- {"version":3,"names":["ReactReconciler","DependencyManager","skHostConfig","debug","hostDebug","Container","skiaReconciler","createDependencyManager","registerValues","global","SkiaDomApi","injectIntoDevTools","bundleType","version","rendererPackageName","SkiaRoot","constructor","Skia","redraw","depMgr","container","root","createContainer","console","error","render","element","updateContainer","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,OAAOA,eAAP,MAA4B,kBAA5B;AAKA,SAASC,iBAAT,QAAkC,qBAAlC;AACA,SAASC,YAAT,EAAuBC,KAAK,IAAIC,SAAhC,QAAiD,cAAjD;AACA,SAASC,SAAT,QAA0B,aAA1B;AAEA,MAAMC,cAAc,GAAGN,eAAe,CAACE,YAAD,CAAtC;;AAIA,MAAMK,uBAAuB,GAAIC,cAAD,IAC9BC,MAAM,CA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","DependencyManager","skHostConfig","debug","hostDebug","Container","skiaReconciler","createDependencyManager","registerValues","global","SkiaDomApi","injectIntoDevTools","bundleType","version","rendererPackageName","SkiaRoot","constructor","Skia","redraw","getNativeId","depMgr","container","root","createContainer","console","error","render","element","updateContainer","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,OAAOA,eAAP,MAA4B,kBAA5B;AAKA,SAASC,iBAAT,QAAkC,qBA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B,cAAc,CAACsB,eAAf,CAA+B,IAA/B,EAAqC,KAAKN,IAA1C,EAAgD,IAAhD,EAAsD,MAAM;MAC1D,KAAKD,SAAL,CAAeD,MAAf,CAAsBU,MAAtB;IACD,CAFD;EAGD;;EAEM,IAAHC,GAAG,GAAG;IACR,OAAO,KAAKV,SAAL,CAAeC,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":"AAEA,OAAO,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;AAgBP,OAAO,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;AAkBP,OAAO,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":"AAMA,OAAO,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;AAgBP,OAAO,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;AAkBP,OAAO,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 +1,2 @@
1
1
  export * from "./useSharedValueEffect";
2
+ export * from "./renderHelpers";
@@ -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,5 @@
1
+ import type { Container } from "../../renderer/Container";
2
+ import type { AnimatedProps } from "../../renderer/processors";
3
+ import type { Node } from "../../dom/types";
4
+ export declare function extractReanimatedProps(props: AnimatedProps<any>): AnimatedProps<any, never>[];
5
+ export declare function bindReanimatedProps(container: Container, node: Node<any>, reanimatedProps: AnimatedProps<any>): void;
@@ -1,11 +1,8 @@
1
- declare type SharedValueTypeWrapper<T = number> = {
2
- value: T;
3
- };
1
+ import type { SharedValueType } from "../../renderer/processors/Animations";
4
2
  /**
5
3
  * Connects a shared value from reanimated to a SkiaView or Canvas
6
4
  * so whenever the shared value changes the SkiaView will redraw.
7
5
  * @param cb Callback that will be called whenever the shared value changes.
8
6
  * @param values One or more shared values to listen for.
9
7
  */
10
- export declare const useSharedValueEffect: <T = number>(cb: () => void, value: SharedValueTypeWrapper<T>, ...values: SharedValueTypeWrapper<T>[]) => void;
11
- export {};
8
+ export declare const useSharedValueEffect: <T = number>(cb: () => void, value: SharedValueType<T>, ...values: SharedValueType<T>[]) => void;
@@ -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;
@@ -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;
@@ -4,9 +4,10 @@ import type { DependencyManager } from "./DependencyManager";
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
  }
@@ -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>;
@@ -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
  };
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.176",
10
+ "version": "0.1.178",
11
11
  "description": "High-performance React Native Graphics using Skia",
12
12
  "main": "lib/module/index.js",
13
13
  "files": [
@@ -1 +1,2 @@
1
1
  export * from "./useSharedValueEffect";
2
+ export * from "./renderHelpers";