@shopify/react-native-skia 0.1.233 → 0.1.234

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. package/android/CMakeLists.txt +0 -1
  2. package/android/cpp/jni/JniSkiaManager.cpp +0 -1
  3. package/android/cpp/rnskia-android/RNSkAndroidView.h +0 -1
  4. package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp +1 -1
  5. package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.h +1 -2
  6. package/lib/commonjs/external/reanimated/interpolators.js +3 -1
  7. package/lib/commonjs/external/reanimated/interpolators.js.map +1 -1
  8. package/lib/commonjs/renderer/Canvas.js +5 -4
  9. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  10. package/lib/commonjs/skia/web/JsiSkPath.d.ts +2 -2
  11. package/lib/commonjs/skia/web/JsiSkPath.js +10 -2
  12. package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
  13. package/lib/commonjs/views/SkiaJSDomView.d.ts +31 -0
  14. package/lib/commonjs/views/SkiaJSDomView.js +161 -0
  15. package/lib/commonjs/views/SkiaJSDomView.js.map +1 -0
  16. package/lib/commonjs/views/SkiaJSDomView.web.d.ts +1 -0
  17. package/lib/commonjs/views/SkiaJSDomView.web.js +14 -0
  18. package/lib/commonjs/views/SkiaJSDomView.web.js.map +1 -0
  19. package/lib/module/external/reanimated/interpolators.js +2 -1
  20. package/lib/module/external/reanimated/interpolators.js.map +1 -1
  21. package/lib/module/renderer/Canvas.js +4 -3
  22. package/lib/module/renderer/Canvas.js.map +1 -1
  23. package/lib/module/skia/web/JsiSkPath.d.ts +2 -2
  24. package/lib/module/skia/web/JsiSkPath.js +10 -2
  25. package/lib/module/skia/web/JsiSkPath.js.map +1 -1
  26. package/lib/module/views/SkiaJSDomView.d.ts +31 -0
  27. package/lib/module/views/SkiaJSDomView.js +136 -0
  28. package/lib/module/views/SkiaJSDomView.js.map +1 -0
  29. package/lib/module/views/SkiaJSDomView.web.d.ts +1 -0
  30. package/lib/module/views/SkiaJSDomView.web.js +2 -0
  31. package/lib/module/views/SkiaJSDomView.web.js.map +1 -0
  32. package/lib/typescript/src/skia/web/JsiSkPath.d.ts +2 -2
  33. package/lib/typescript/src/views/SkiaJSDomView.d.ts +31 -0
  34. package/lib/typescript/src/views/SkiaJSDomView.web.d.ts +1 -0
  35. package/package.json +1 -1
  36. package/src/external/reanimated/interpolators.ts +2 -1
  37. package/src/renderer/Canvas.tsx +3 -2
  38. package/src/skia/web/JsiSkPath.ts +23 -3
  39. package/src/views/SkiaJSDomView.tsx +126 -0
  40. package/src/views/SkiaJSDomView.web.tsx +1 -0
  41. package/android/cpp/jni/include/JniSkiaDrawView.h +0 -90
  42. package/cpp/rnskia/RNSkJsView.cpp +0 -236
  43. package/cpp/rnskia/RNSkJsView.h +0 -121
@@ -54,7 +54,6 @@ add_library(
54
54
  "${PROJECT_SOURCE_DIR}/../cpp/jsi/JsiPromises.cpp"
55
55
 
56
56
  "${PROJECT_SOURCE_DIR}/../cpp/rnskia/RNSkManager.cpp"
57
- "${PROJECT_SOURCE_DIR}/../cpp/rnskia/RNSkJsView.cpp"
58
57
  "${PROJECT_SOURCE_DIR}/../cpp/rnskia/RNSkDomView.cpp"
59
58
  "${PROJECT_SOURCE_DIR}/../cpp/rnskia/RNSkDispatchQueue.cpp"
60
59
 
@@ -5,7 +5,6 @@
5
5
  #include <string>
6
6
  #include <utility>
7
7
 
8
- #include "JniSkiaDrawView.h"
9
8
  #include <RNSkManager.h>
10
9
 
11
10
  namespace RNSkia {
@@ -4,7 +4,6 @@
4
4
  #include <string>
5
5
  #include <vector>
6
6
 
7
- #include <RNSkJsView.h>
8
7
  #include <RNSkOpenGLCanvasProvider.h>
9
8
  #include <android/native_window.h>
10
9
 
@@ -1,4 +1,4 @@
1
- #include <RNSkOpenGLCanvasProvider.h>
1
+ #include "RNSkOpenGLCanvasProvider.h"
2
2
 
3
3
  #include <memory>
4
4
 
@@ -4,8 +4,7 @@
4
4
 
5
5
  #include <memory>
6
6
 
7
- #include <RNSkJsView.h>
8
-
7
+ #include "RNSkView.h"
9
8
  #include "SkiaOpenGLSurfaceFactory.h"
10
9
  #include <android/native_window.h>
11
10
 
@@ -11,12 +11,14 @@ var _animation = require("../../animation");
11
11
 
12
12
  var _skia = require("../../skia");
13
13
 
14
+ var _Platform = require("../../Platform");
15
+
14
16
  var _moduleWrapper = require("./moduleWrapper");
15
17
 
16
18
  const notifyChange = value => {
17
19
  "worklet";
18
20
 
19
- if (_WORKLET) {
21
+ if (_WORKLET || _Platform.Platform.OS === "web") {
20
22
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
23
  value._value = value.value;
22
24
  }
@@ -1 +1 @@
1
- {"version":3,"names":["notifyChange","value","_WORKLET","_value","usePathValue","cb","pathInit","useMemo","Skia","Path","Make","path","useSharedValue","useDerivedValue","reset","useClock","clock","callback","useCallback","info","timeSinceFirstFrame","useFrameCallback","useInterpolator","factory","interpolator","input","output","options","init","result","useAnimatedReaction","val","usePathInterpolation","outputRange","interpolatePaths","useVectorInterpolation","Point","interpolateVector"],"sources":["interpolators.ts"],"sourcesContent":["import type {\n ExtrapolationType,\n FrameInfo,\n SharedValue,\n} from \"react-native-reanimated\";\nimport { useCallback, useMemo } from \"react\";\n\nimport type { SkPath, SkPoint } from \"../../skia/types\";\nimport { interpolatePaths, interpolateVector } from \"../../animation\";\nimport { Skia } from \"../../skia\";\n\nimport {\n useAnimatedReaction,\n useFrameCallback,\n useSharedValue,\n useDerivedValue,\n} from \"./moduleWrapper\";\n\nexport const notifyChange = (value: SharedValue<unknown>) => {\n \"worklet\";\n if (_WORKLET) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (value as any)._value = value.value;\n }\n};\n\nexport const usePathValue = (cb: (path: SkPath) => void) => {\n const pathInit = useMemo(() => Skia.Path.Make(), []);\n const path = useSharedValue(pathInit);\n useDerivedValue(() => {\n path.value.reset();\n cb(path.value);\n notifyChange(path);\n });\n return path;\n};\n\nexport const useClock = () => {\n const clock = useSharedValue(0);\n const callback = useCallback(\n (info: FrameInfo) => {\n \"worklet\";\n clock.value = info.timeSinceFirstFrame;\n },\n [clock]\n );\n useFrameCallback(callback);\n return clock;\n};\n\n/**\n * @worklet\n */\ntype Interpolator<T> = (\n value: number,\n input: number[],\n output: T[],\n options: ExtrapolationType,\n result: T\n) => T;\n\nconst useInterpolator = <T>(\n factory: () => T,\n value: SharedValue<number>,\n interpolator: Interpolator<T>,\n input: number[],\n output: T[],\n options?: ExtrapolationType\n) => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const init = useMemo(() => factory(), []);\n const result = useSharedValue(init);\n useAnimatedReaction(\n () => value.value,\n (val) => {\n result.value = interpolator(val, input, output, options, result.value);\n notifyChange(result);\n },\n [input, output, options]\n );\n return result;\n};\n\nexport const usePathInterpolation = (\n value: SharedValue<number>,\n input: number[],\n outputRange: SkPath[],\n options?: ExtrapolationType\n) =>\n useInterpolator(\n () => Skia.Path.Make(),\n value,\n interpolatePaths,\n input,\n outputRange,\n options\n );\n\nexport const useVectorInterpolation = (\n value: SharedValue<number>,\n input: number[],\n outputRange: SkPoint[],\n options?: ExtrapolationType\n) =>\n useInterpolator(\n () => Skia.Point(0, 0),\n value,\n interpolateVector,\n input,\n outputRange,\n options\n );\n"],"mappings":";;;;;;;AAKA;;AAGA;;AACA;;AAEA;;AAOO,MAAMA,YAAY,GAAIC,KAAD,IAAiC;EAC3D;;EACA,IAAIC,QAAJ,EAAc;IACZ;IACCD,KAAD,CAAeE,MAAf,GAAwBF,KAAK,CAACA,KAA9B;EACD;AACF,CANM;;;;AAQA,MAAMG,YAAY,GAAIC,EAAD,IAAgC;EAC1D,MAAMC,QAAQ,GAAG,IAAAC,cAAA,EAAQ,MAAMC,UAAA,CAAKC,IAAL,CAAUC,IAAV,EAAd,EAAgC,EAAhC,CAAjB;EACA,MAAMC,IAAI,GAAG,IAAAC,6BAAA,EAAeN,QAAf,CAAb;EACA,IAAAO,8BAAA,EAAgB,MAAM;IACpBF,IAAI,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,EAEbT,KAFa,EAGbiC,2BAHa,EAIbT,KAJa,EAKbQ,WALa,EAMbN,OANa,CANV;;;;AAeA,MAAMQ,sBAAsB,GAAG,CACpClC,KADoC,EAEpCwB,KAFoC,EAGpCQ,WAHoC,EAIpCN,OAJoC,KAMpCL,eAAe,CACb,MAAMd,UAAA,CAAK4B,KAAL,CAAW,CAAX,EAAc,CAAd,CADO,EAEbnC,KAFa,EAGboC,4BAHa,EAIbZ,KAJa,EAKbQ,WALa,EAMbN,OANa,CANV"}
1
+ {"version":3,"names":["notifyChange","value","_WORKLET","Platform","OS","_value","usePathValue","cb","pathInit","useMemo","Skia","Path","Make","path","useSharedValue","useDerivedValue","reset","useClock","clock","callback","useCallback","info","timeSinceFirstFrame","useFrameCallback","useInterpolator","factory","interpolator","input","output","options","init","result","useAnimatedReaction","val","usePathInterpolation","outputRange","interpolatePaths","useVectorInterpolation","Point","interpolateVector"],"sources":["interpolators.ts"],"sourcesContent":["import type {\n ExtrapolationType,\n FrameInfo,\n SharedValue,\n} from \"react-native-reanimated\";\nimport { useCallback, useMemo } from \"react\";\n\nimport type { SkPath, SkPoint } from \"../../skia/types\";\nimport { interpolatePaths, interpolateVector } from \"../../animation\";\nimport { Skia } from \"../../skia\";\nimport { Platform } from \"../../Platform\";\n\nimport {\n useAnimatedReaction,\n useFrameCallback,\n useSharedValue,\n useDerivedValue,\n} from \"./moduleWrapper\";\n\nexport const notifyChange = (value: SharedValue<unknown>) => {\n \"worklet\";\n if (_WORKLET || Platform.OS === \"web\") {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (value as any)._value = value.value;\n }\n};\n\nexport const usePathValue = (cb: (path: SkPath) => void) => {\n const pathInit = useMemo(() => Skia.Path.Make(), []);\n const path = useSharedValue(pathInit);\n useDerivedValue(() => {\n path.value.reset();\n cb(path.value);\n notifyChange(path);\n });\n return path;\n};\n\nexport const useClock = () => {\n const clock = useSharedValue(0);\n const callback = useCallback(\n (info: FrameInfo) => {\n \"worklet\";\n clock.value = info.timeSinceFirstFrame;\n },\n [clock]\n );\n useFrameCallback(callback);\n return clock;\n};\n\n/**\n * @worklet\n */\ntype Interpolator<T> = (\n value: number,\n input: number[],\n output: T[],\n options: ExtrapolationType,\n result: T\n) => T;\n\nconst useInterpolator = <T>(\n factory: () => T,\n value: SharedValue<number>,\n interpolator: Interpolator<T>,\n input: number[],\n output: T[],\n options?: ExtrapolationType\n) => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const init = useMemo(() => factory(), []);\n const result = useSharedValue(init);\n useAnimatedReaction(\n () => value.value,\n (val) => {\n result.value = interpolator(val, input, output, options, result.value);\n notifyChange(result);\n },\n [input, output, options]\n );\n return result;\n};\n\nexport const usePathInterpolation = (\n value: SharedValue<number>,\n input: number[],\n outputRange: SkPath[],\n options?: ExtrapolationType\n) =>\n useInterpolator(\n () => Skia.Path.Make(),\n value,\n interpolatePaths,\n input,\n outputRange,\n options\n );\n\nexport const useVectorInterpolation = (\n value: SharedValue<number>,\n input: number[],\n outputRange: SkPoint[],\n options?: ExtrapolationType\n) =>\n useInterpolator(\n () => Skia.Point(0, 0),\n value,\n interpolateVector,\n input,\n outputRange,\n options\n );\n"],"mappings":";;;;;;;AAKA;;AAGA;;AACA;;AACA;;AAEA;;AAOO,MAAMA,YAAY,GAAIC,KAAD,IAAiC;EAC3D;;EACA,IAAIC,QAAQ,IAAIC,kBAAA,CAASC,EAAT,KAAgB,KAAhC,EAAuC;IACrC;IACCH,KAAD,CAAeI,MAAf,GAAwBJ,KAAK,CAACA,KAA9B;EACD;AACF,CANM;;;;AAQA,MAAMK,YAAY,GAAIC,EAAD,IAAgC;EAC1D,MAAMC,QAAQ,GAAG,IAAAC,cAAA,EAAQ,MAAMC,UAAA,CAAKC,IAAL,CAAUC,IAAV,EAAd,EAAgC,EAAhC,CAAjB;EACA,MAAMC,IAAI,GAAG,IAAAC,6BAAA,EAAeN,QAAf,CAAb;EACA,IAAAO,8BAAA,EAAgB,MAAM;IACpBF,IAAI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,EADO,EAEbX,KAFa,EAGbmC,2BAHa,EAIbT,KAJa,EAKbQ,WALa,EAMbN,OANa,CANV;;;;AAeA,MAAMQ,sBAAsB,GAAG,CACpCpC,KADoC,EAEpC0B,KAFoC,EAGpCQ,WAHoC,EAIpCN,OAJoC,KAMpCL,eAAe,CACb,MAAMd,UAAA,CAAK4B,KAAL,CAAW,CAAX,EAAc,CAAd,CADO,EAEbrC,KAFa,EAGbsC,4BAHa,EAIbZ,KAJa,EAKbQ,WALa,EAMbN,OANa,CANV"}
@@ -9,10 +9,10 @@ var _react = _interopRequireWildcard(require("react"));
9
9
 
10
10
  var _views = require("../views");
11
11
 
12
- var _SkiaDomView = require("../views/SkiaDomView.web");
13
-
14
12
  var _Skia = require("../skia/Skia");
15
13
 
14
+ var _SkiaJSDomView = require("../views/SkiaJSDomView");
15
+
16
16
  var _Reconciler = require("./Reconciler");
17
17
 
18
18
  var _HostComponents = require("./HostComponents");
@@ -94,8 +94,9 @@ const Canvas = /*#__PURE__*/(0, _react.forwardRef)((_ref, forwardedRef) => {
94
94
  debug: debug
95
95
  }, props));
96
96
  } else {
97
- return /*#__PURE__*/_react.default.createElement(_SkiaDomView.SkiaDomView // eslint-disable-next-line @typescript-eslint/no-explicit-any
98
- , _extends({
97
+ return /*#__PURE__*/_react.default.createElement(_SkiaJSDomView.SkiaJSDomView, _extends({
98
+ Skia: _Skia.Skia // eslint-disable-next-line @typescript-eslint/no-explicit-any
99
+ ,
99
100
  ref: ref,
100
101
  style: style,
101
102
  root: root.dom,
@@ -1 +1 @@
1
- {"version":3,"names":["useCanvasRef","useRef","useOnSizeEvent","resultValue","onLayout","useCallback","event","width","height","nativeEvent","layout","value","Canvas","forwardRef","forwardedRef","children","style","debug","mode","onTouch","onSize","_onSize","_onLayout","props","innerRef","ref","useCombinedRefs","redraw","current","getNativeId","id","nativeId","root","useMemo","SkiaRoot","Skia","useEffect","render","unmount","NATIVE_DOM","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 FunctionComponent,\n} from \"react\";\nimport type { LayoutChangeEvent } from \"react-native\";\n\nimport { SkiaDomView } from \"../views\";\nimport { SkiaDomView as SkiaDomViewWeb } from \"../views/SkiaDomView.web\";\nimport { Skia } from \"../skia/Skia\";\nimport type { TouchHandler, SkiaBaseViewProps } from \"../views\";\n\nimport { SkiaRoot } from \"./Reconciler\";\nimport { NATIVE_DOM } from \"./HostComponents\";\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\nconst useOnSizeEvent = (\n resultValue: SkiaBaseViewProps[\"onSize\"],\n onLayout?: (event: LayoutChangeEvent) => void\n) => {\n return useCallback(\n (event: LayoutChangeEvent) => {\n if (onLayout) {\n onLayout(event);\n }\n const { width, height } = event.nativeEvent.layout;\n\n if (resultValue) {\n resultValue.value = { width, height };\n }\n },\n [onLayout, resultValue]\n );\n};\n\nexport const Canvas = forwardRef<SkiaDomView, CanvasProps>(\n (\n {\n children,\n style,\n debug,\n mode,\n onTouch,\n onSize: _onSize,\n onLayout: _onLayout,\n ...props\n },\n forwardedRef\n ) => {\n const onLayout = useOnSizeEvent(_onSize, _onLayout);\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 root = useMemo(\n () => new SkiaRoot(Skia, redraw, getNativeId),\n [redraw, 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 if (NATIVE_DOM) {\n return (\n <SkiaDomView\n ref={ref}\n style={style}\n root={root.dom}\n onTouch={onTouch}\n onLayout={onLayout}\n mode={mode}\n debug={debug}\n {...props}\n />\n );\n } else {\n return (\n <SkiaDomViewWeb\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ref={ref as any}\n style={style}\n root={root.dom}\n onTouch={onTouch}\n onLayout={onLayout}\n mode={mode}\n debug={debug}\n {...props}\n />\n );\n }\n }\n) as FunctionComponent<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;;AAgBA;;AACA;;AACA;;AAGA;;AACA;;;;;;;;AAEO,MAAMA,YAAY,GAAG,MAAM,IAAAC,aAAA,EAAoB,IAApB,CAA3B;;;;AAQP,MAAMC,cAAc,GAAG,CACrBC,WADqB,EAErBC,QAFqB,KAGlB;EACH,OAAO,IAAAC,kBAAA,EACJC,KAAD,IAA8B;IAC5B,IAAIF,QAAJ,EAAc;MACZA,QAAQ,CAACE,KAAD,CAAR;IACD;;IACD,MAAM;MAAEC,KAAF;MAASC;IAAT,IAAoBF,KAAK,CAACG,WAAN,CAAkBC,MAA5C;;IAEA,IAAIP,WAAJ,EAAiB;MACfA,WAAW,CAACQ,KAAZ,GAAoB;QAAEJ,KAAF;QAASC;MAAT,CAApB;IACD;EACF,CAVI,EAWL,CAACJ,QAAD,EAAWD,WAAX,CAXK,CAAP;AAaD,CAj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d,oBACE,6BAAC,kBAAD;MACE,GAAG,EAAEd,GADP;MAEE,KAAK,EAAET,KAFT;MAGE,IAAI,EAAEgB,IAAI,CAACQ,GAHb;MAIE,OAAO,EAAErB,OAJX;MAKE,QAAQ,EAAEf,QALZ;MAME,IAAI,EAAEc,IANR;MAOE,KAAK,EAAED;IAPT,GAQMM,KARN,EADF;EAYD,CAbD,MAaO;IACL,oBACE,6BAAC,wBAAD,CACE;IADF;MAEE,GAAG,EAAEE,GAFP;MAGE,KAAK,EAAET,KAHT;MAIE,IAAI,EAAEgB,IAAI,CAACQ,GAJb;MAKE,OAAO,EAAErB,OALX;MAME,QAAQ,EAAEf,QANZ;MAOE,IAAI,EAAEc,IAPR;MAQE,KAAK,EAAED;IART,GASMM,KATN,EADF;EAaD;AACF,CArEmB,CAAf;AAwEP;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACA,MAAMG,eAAe,GAAG,YAEnB;EAAA,kCADAe,IACA;IADAA,IACA;EAAA;;EACH,MAAMC,SAAS,GAAGC,cAAA,CAAM1C,MAAN,CAAgB,IAAhB,CAAlB;;EACA0C,cAAA,CAAMP,SAAN,CAAgB,MAAM;IACpBK,IAAI,CAACG,OAAL,CAAcnB,GAAD,IAAS;MACpB,IAAIA,GAAJ,EAAS;QACP,IAAI,OAAOA,GAAP,KAAe,UAAnB,EAA+B;UAC7BA,GAAG,CAACiB,SAAS,CAACd,OAAX,CAAH;QACD,CAFD,MAEO;UACLH,GAAG,CAACG,OAAJ,GAAcc,SAAS,CAACd,OAAxB;QACD;MACF;IACF,CARD;EASD,CAVD,EAUG,CAACa,IAAD,CAVH;;EAWA,OAAOC,SAAP;AACD,CAhBD"}
1
+ {"version":3,"names":["useCanvasRef","useRef","useOnSizeEvent","resultValue","onLayout","useCallback","event","width","height","nativeEvent","layout","value","Canvas","forwardRef","forwardedRef","children","style","debug","mode","onTouch","onSize","_onSize","_onLayout","props","innerRef","ref","useCombinedRefs","redraw","current","getNativeId","id","nativeId","root","useMemo","SkiaRoot","Skia","useEffect","render","unmount","NATIVE_DOM","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 FunctionComponent,\n} from \"react\";\nimport type { LayoutChangeEvent } from \"react-native\";\n\nimport { SkiaDomView } from \"../views\";\nimport { Skia } from \"../skia/Skia\";\nimport type { TouchHandler, SkiaBaseViewProps } from \"../views\";\nimport { SkiaJSDomView } from \"../views/SkiaJSDomView\";\n\nimport { SkiaRoot } from \"./Reconciler\";\nimport { NATIVE_DOM } from \"./HostComponents\";\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\nconst useOnSizeEvent = (\n resultValue: SkiaBaseViewProps[\"onSize\"],\n onLayout?: (event: LayoutChangeEvent) => void\n) => {\n return useCallback(\n (event: LayoutChangeEvent) => {\n if (onLayout) {\n onLayout(event);\n }\n const { width, height } = event.nativeEvent.layout;\n\n if (resultValue) {\n resultValue.value = { width, height };\n }\n },\n [onLayout, resultValue]\n );\n};\n\nexport const Canvas = forwardRef<SkiaDomView, CanvasProps>(\n (\n {\n children,\n style,\n debug,\n mode,\n onTouch,\n onSize: _onSize,\n onLayout: _onLayout,\n ...props\n },\n forwardedRef\n ) => {\n const onLayout = useOnSizeEvent(_onSize, _onLayout);\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 root = useMemo(\n () => new SkiaRoot(Skia, redraw, getNativeId),\n [redraw, 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 if (NATIVE_DOM) {\n return (\n <SkiaDomView\n ref={ref}\n style={style}\n root={root.dom}\n onTouch={onTouch}\n onLayout={onLayout}\n mode={mode}\n debug={debug}\n {...props}\n />\n );\n } else {\n return (\n <SkiaJSDomView\n Skia={Skia}\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ref={ref as any}\n style={style}\n root={root.dom}\n onTouch={onTouch}\n onLayout={onLayout}\n mode={mode}\n debug={debug}\n {...props}\n />\n );\n }\n }\n) as FunctionComponent<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;;AAgBA;;AACA;;AAEA;;AAEA;;AACA;;;;;;;;AAEO,MAAMA,YAAY,GAAG,MAAM,IAAAC,aAAA,EAAoB,IAApB,CAA3B;;;;AAQP,MAAMC,cAAc,GAAG,CACrBC,WADqB,EAErBC,QAFqB,KAGlB;EACH,OAAO,IAAAC,kBAAA,EACJC,KAAD,IAA8B;IAC5B,IAAIF,QAAJ,EAAc;MACZA,QAAQ,CAACE,KAAD,CAAR;IACD;;IACD,MAAM;MAAEC,KAAF;MAASC;IAAT,IAAoBF,KAAK,CAACG,WAAN,CAAkBC,MAA5C;;IAEA,IAAIP,WAAJ,EAAiB;MACfA,WAAW,CAACQ,KAAZ,GAAoB;QAAEJ,KAAF;QAASC;MAA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ACD,CAFD;EAGD,CAJD,EAIG,CAACN,IAAD,CAJH;;EAMA,IAAIO,0BAAJ,EAAgB;IACd,oBACE,6BAAC,kBAAD;MACE,GAAG,EAAEd,GADP;MAEE,KAAK,EAAET,KAFT;MAGE,IAAI,EAAEgB,IAAI,CAACQ,GAHb;MAIE,OAAO,EAAErB,OAJX;MAKE,QAAQ,EAAEf,QALZ;MAME,IAAI,EAAEc,IANR;MAOE,KAAK,EAAED;IAPT,GAQMM,KARN,EADF;EAYD,CAbD,MAaO;IACL,oBACE,6BAAC,4BAAD;MACE,IAAI,EAAEY,UADR,CAEE;MAFF;MAGE,GAAG,EAAEV,GAHP;MAIE,KAAK,EAAET,KAJT;MAKE,IAAI,EAAEgB,IAAI,CAACQ,GALb;MAME,OAAO,EAAErB,OANX;MAOE,QAAQ,EAAEf,QAPZ;MAQE,IAAI,EAAEc,IARR;MASE,KAAK,EAAED;IATT,GAUMM,KAVN,EADF;EAcD;AACF,CAtEmB,CAAf;AAyEP;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACA,MAAMG,eAAe,GAAG,YAEnB;EAAA,kCADAe,IACA;IADAA,IACA;EAAA;;EACH,MAAMC,SAAS,GAAGC,cAAA,CAAM1C,MAAN,CAAgB,IAAhB,CAAlB;;EACA0C,cAAA,CAAMP,SAAN,CAAgB,MAAM;IACpBK,IAAI,CAACG,OAAL,CAAcnB,GAAD,IAAS;MACpB,IAAIA,GAAJ,EAAS;QACP,IAAI,OAAOA,GAAP,KAAe,UAAnB,EAA+B;UAC7BA,GAAG,CAACiB,SAAS,CAACd,OAAX,CAAH;QACD,CAFD,MAEO;UACLH,GAAG,CAACG,OAAJ,GAAcc,SAAS,CAACd,OAAxB;QACD;MACF;IACF,CARD;EASD,CAVD,EAUG,CAACa,IAAD,CAVH;;EAWA,OAAOC,SAAP;AACD,CAhBD"}
@@ -1,5 +1,5 @@
1
1
  import type { CanvasKit, Path } from "canvaskit-wasm";
2
- import type { FillType, PathCommand, PathOp, SkMatrix, SkPath, SkPoint, SkRect, InputRRect, StrokeOpts } from "../types";
2
+ import type { FillType, PathCommand, PathOp, SkMatrix, SkPath, SkPoint, SkRect, InputRRect, StrokeOpts, InputMatrix } from "../types";
3
3
  import { HostObject } from "./Host";
4
4
  import { JsiSkPoint } from "./JsiSkPoint";
5
5
  import { JsiSkRect } from "./JsiSkRect";
@@ -51,7 +51,7 @@ export declare class JsiSkPath extends HostObject<Path, "Path"> implements SkPat
51
51
  simplify(): boolean;
52
52
  toSVGString(): string;
53
53
  trim(start: number, stop: number, isComplement: boolean): this | null;
54
- transform(m3: SkMatrix): this;
54
+ transform(m: InputMatrix): this;
55
55
  interpolate(end: SkPath, t: number, output?: SkPath): SkPath | JsiSkPath | null;
56
56
  isInterpolatable(path2: SkPath): boolean;
57
57
  toCmds(): PathCommand[];
@@ -265,8 +265,16 @@ class JsiSkPath extends _Host.HostObject {
265
265
  return result === null ? result : this;
266
266
  }
267
267
 
268
- transform(m3) {
269
- this.ref.transform(Array.isArray(m3) ? m3 : _JsiSkMatrix.JsiSkMatrix.fromValue(m3));
268
+ transform(m) {
269
+ let matrix = m instanceof _JsiSkMatrix.JsiSkMatrix ? Array.from(_JsiSkMatrix.JsiSkMatrix.fromValue(m)) : m;
270
+
271
+ if (matrix.length === 16) {
272
+ matrix = [matrix[0], matrix[1], matrix[3], matrix[4], matrix[5], matrix[7], matrix[12], matrix[13], matrix[15]];
273
+ } else if (matrix.length !== 9) {
274
+ throw new Error(`Invalid matrix length: ${matrix.length}`);
275
+ }
276
+
277
+ this.ref.transform(matrix);
270
278
  return this;
271
279
  }
272
280
 
@@ -1 +1 @@
1
- {"version":3,"names":["CommandCount","PathVerb","Move","Line","Quad","Conic","Cubic","Close","pinT","t","Math","min","max","JsiSkPath","HostObject","constructor","CanvasKit","ref","delete","addPath","src","matrix","extend","args","fromValue","JsiSkMatrix","addArc","oval","startAngleInDegrees","sweepAngleInDegrees","JsiSkRect","addOval","isCCW","startIndex","countPoints","addPoly","points","close","map","p","Array","from","JsiSkPoint","flat","moveTo","x","y","lineTo","makeAsWinding","result","offset","dx","dy","rArcTo","rx","ry","xAxisRotateInDegrees","useSmallArc","rConicTo","dx1","dy1","dx2","dy2","w","rCubicTo","cpx1","cpy1","cpx2","cpy2","rMoveTo","rLineTo","rQuadTo","x1","y1","x2","y2","setFillType","fill","getEnum","FillType","setIsVolatile","volatile","stroke","opts","undefined","width","miter_limit","precision","join","optEnum","StrokeJoin","cap","StrokeCap","reset","rewind","computeTightBounds","arcToOval","forceMoveTo","arcToRotated","arcToTangent","radius","conicTo","contains","copy","cubicTo","dash","on","off","phase","equals","other","getBounds","getFillType","value","quadTo","addRect","rect","addRRect","rrect","JsiSkRRect","getPoint","index","isEmpty","isVolatile","addCircle","r","getLastPt","op","path","PathOp","simplify","toSVGString","trim","start","stop","isComplement","startT","stopT","transform","m3","isArray","interpolate","end","output","Path","MakeFromPathInterpolation","isInterpolatable","path2","CanInterpolate","toCmds","cmds","reduce","acc","cmd","i","push","current","length"],"sources":["JsiSkPath.ts"],"sourcesContent":["import type { CanvasKit, Path } from \"canvaskit-wasm\";\n\nimport { PathVerb } from \"../types\";\nimport type {\n FillType,\n PathCommand,\n PathOp,\n SkMatrix,\n SkPath,\n SkPoint,\n SkRect,\n InputRRect,\n StrokeOpts,\n} from \"../types\";\n\nimport { getEnum, HostObject, optEnum } from \"./Host\";\nimport { JsiSkPoint } from \"./JsiSkPoint\";\nimport { JsiSkRect } from \"./JsiSkRect\";\nimport { JsiSkRRect } from \"./JsiSkRRect\";\nimport { JsiSkMatrix } from \"./JsiSkMatrix\";\n\nconst CommandCount = {\n [PathVerb.Move]: 3,\n [PathVerb.Line]: 3,\n [PathVerb.Quad]: 5,\n [PathVerb.Conic]: 6,\n [PathVerb.Cubic]: 7,\n [PathVerb.Close]: 1,\n};\n\nconst pinT = (t: number) => Math.min(Math.max(t, 0), 1);\n\nexport class JsiSkPath extends HostObject<Path, \"Path\"> implements SkPath {\n constructor(CanvasKit: CanvasKit, ref: Path) {\n super(CanvasKit, ref, \"Path\");\n }\n\n dispose = () => {\n this.ref.delete();\n };\n\n addPath(src: SkPath, matrix?: SkMatrix, extend = false) {\n const args = [\n JsiSkPath.fromValue(src),\n ...(matrix ? JsiSkMatrix.fromValue<Float32Array>(matrix) : []),\n extend,\n ];\n this.ref.addPath(...args);\n return this;\n }\n\n addArc(\n oval: SkRect,\n startAngleInDegrees: number,\n sweepAngleInDegrees: number\n ) {\n this.ref.addArc(\n JsiSkRect.fromValue(this.CanvasKit, oval),\n startAngleInDegrees,\n sweepAngleInDegrees\n );\n return this;\n }\n\n addOval(oval: SkRect, isCCW?: boolean, startIndex?: number) {\n this.ref.addOval(\n JsiSkRect.fromValue(this.CanvasKit, oval),\n isCCW,\n startIndex\n );\n return this;\n }\n\n countPoints() {\n return this.ref.countPoints();\n }\n\n addPoly(points: SkPoint[], close: boolean) {\n this.ref.addPoly(\n points.map((p) => Array.from(JsiSkPoint.fromValue(p))).flat(),\n close\n );\n return this;\n }\n\n moveTo(x: number, y: number) {\n this.ref.moveTo(x, y);\n return this;\n }\n\n lineTo(x: number, y: number) {\n this.ref.lineTo(x, y);\n return this;\n }\n\n makeAsWinding() {\n const result = this.ref.makeAsWinding();\n return result === null ? result : this;\n }\n\n offset(dx: number, dy: number) {\n this.ref.offset(dx, dy);\n return this;\n }\n\n rArcTo(\n rx: number,\n ry: number,\n xAxisRotateInDegrees: number,\n useSmallArc: boolean,\n isCCW: boolean,\n dx: number,\n dy: number\n ) {\n this.ref.rArcTo(rx, ry, xAxisRotateInDegrees, useSmallArc, isCCW, dx, dy);\n return this;\n }\n\n rConicTo(dx1: number, dy1: number, dx2: number, dy2: number, w: number) {\n this.ref.rConicTo(dx1, dy1, dx2, dy2, w);\n return this;\n }\n\n rCubicTo(\n cpx1: number,\n cpy1: number,\n cpx2: number,\n cpy2: number,\n x: number,\n y: number\n ) {\n this.ref.rCubicTo(cpx1, cpy1, cpx2, cpy2, x, y);\n return this;\n }\n\n rMoveTo(x: number, y: number) {\n this.ref.rMoveTo(x, y);\n return this;\n }\n\n rLineTo(x: number, y: number) {\n this.ref.rLineTo(x, y);\n return this;\n }\n\n rQuadTo(x1: number, y1: number, x2: number, y2: number) {\n this.ref.rQuadTo(x1, y1, x2, y2);\n return this;\n }\n\n setFillType(fill: FillType) {\n this.ref.setFillType(getEnum(this.CanvasKit.FillType, fill));\n return this;\n }\n\n setIsVolatile(volatile: boolean) {\n this.ref.setIsVolatile(volatile);\n return this;\n }\n\n stroke(opts?: StrokeOpts) {\n const result = this.ref.stroke(\n opts === undefined\n ? undefined\n : {\n width: opts.width,\n // eslint-disable-next-line camelcase\n miter_limit: opts.width,\n precision: opts.width,\n join: optEnum(this.CanvasKit.StrokeJoin, opts.join),\n cap: optEnum(this.CanvasKit.StrokeCap, opts.cap),\n }\n );\n return result === null ? result : this;\n }\n\n close() {\n this.ref.close();\n return this;\n }\n\n reset() {\n this.ref.reset();\n return this;\n }\n\n rewind() {\n this.ref.rewind();\n return this;\n }\n\n computeTightBounds(): SkRect {\n return new JsiSkRect(this.CanvasKit, this.ref.computeTightBounds());\n }\n\n arcToOval(\n oval: SkRect,\n startAngleInDegrees: number,\n sweepAngleInDegrees: number,\n forceMoveTo: boolean\n ) {\n this.ref.arcToOval(\n JsiSkRect.fromValue(this.CanvasKit, oval),\n startAngleInDegrees,\n sweepAngleInDegrees,\n forceMoveTo\n );\n return this;\n }\n\n arcToRotated(\n rx: number,\n ry: number,\n xAxisRotateInDegrees: number,\n useSmallArc: boolean,\n isCCW: boolean,\n x: number,\n y: number\n ) {\n this.ref.arcToRotated(\n rx,\n ry,\n xAxisRotateInDegrees,\n useSmallArc,\n isCCW,\n x,\n y\n );\n return this;\n }\n\n arcToTangent(x1: number, y1: number, x2: number, y2: number, radius: number) {\n this.ref.arcToTangent(x1, y1, x2, y2, radius);\n return this;\n }\n\n conicTo(x1: number, y1: number, x2: number, y2: number, w: number) {\n this.ref.conicTo(x1, y1, x2, y2, w);\n return this;\n }\n\n contains(x: number, y: number) {\n return this.ref.contains(x, y);\n }\n\n copy() {\n return new JsiSkPath(this.CanvasKit, this.ref.copy());\n }\n\n cubicTo(\n cpx1: number,\n cpy1: number,\n cpx2: number,\n cpy2: number,\n x: number,\n y: number\n ) {\n this.ref.cubicTo(cpx1, cpy1, cpx2, cpy2, x, y);\n return this;\n }\n\n dash(on: number, off: number, phase: number) {\n return this.ref.dash(on, off, phase);\n }\n\n equals(other: SkPath) {\n return this.ref.equals(JsiSkPath.fromValue(other));\n }\n\n getBounds() {\n return new JsiSkRect(this.CanvasKit, this.ref.getBounds());\n }\n\n getFillType() {\n return this.ref.getFillType().value;\n }\n\n quadTo(x1: number, y1: number, x2: number, y2: number) {\n this.ref.quadTo(x1, y1, x2, y2);\n return this;\n }\n\n addRect(rect: SkRect, isCCW?: boolean) {\n this.ref.addRect(JsiSkRect.fromValue(this.CanvasKit, rect), isCCW);\n return this;\n }\n\n addRRect(rrect: InputRRect, isCCW?: boolean) {\n this.ref.addRRect(JsiSkRRect.fromValue(this.CanvasKit, rrect), isCCW);\n return this;\n }\n\n getPoint(index: number) {\n return new JsiSkPoint(this.CanvasKit, this.ref.getPoint(index));\n }\n\n isEmpty() {\n return this.ref.isEmpty();\n }\n\n isVolatile() {\n return this.ref.isVolatile();\n }\n\n addCircle(x: number, y: number, r: number) {\n this.ref.addCircle(x, y, r);\n return this;\n }\n\n getLastPt() {\n return new JsiSkPoint(\n this.CanvasKit,\n this.ref.getPoint(this.ref.countPoints() - 1)\n );\n }\n\n op(path: SkPath, op: PathOp) {\n return this.ref.op(\n JsiSkPath.fromValue(path),\n getEnum(this.CanvasKit.PathOp, op)\n );\n }\n\n simplify() {\n return this.ref.simplify();\n }\n\n toSVGString() {\n return this.ref.toSVGString();\n }\n\n trim(start: number, stop: number, isComplement: boolean) {\n const startT = pinT(start);\n const stopT = pinT(stop);\n if (startT === 0 && stopT === 1) {\n return this;\n }\n const result = this.ref.trim(startT, stopT, isComplement);\n return result === null ? result : this;\n }\n\n transform(m3: SkMatrix) {\n this.ref.transform(Array.isArray(m3) ? m3 : JsiSkMatrix.fromValue(m3));\n return this;\n }\n\n interpolate(end: SkPath, t: number, output?: SkPath) {\n const path = this.CanvasKit.Path.MakeFromPathInterpolation(\n this.ref,\n JsiSkPath.fromValue(end),\n t\n );\n if (path === null) {\n return null;\n }\n if (output) {\n (output as JsiSkPath).ref = path;\n return output;\n } else {\n return new JsiSkPath(this.CanvasKit, path);\n }\n }\n\n isInterpolatable(path2: SkPath): boolean {\n return this.CanvasKit.Path.CanInterpolate(\n this.ref,\n JsiSkPath.fromValue(path2)\n );\n }\n\n toCmds() {\n const cmds = this.ref.toCmds();\n const result = cmds.reduce<PathCommand[]>((acc, cmd, i) => {\n if (i === 0) {\n acc.push([]);\n }\n const current = acc[acc.length - 1];\n if (current.length === 0) {\n current.push(cmd);\n const length = CommandCount[current[0] as PathVerb];\n if (current.length === length && i !== cmds.length - 1) {\n acc.push([]);\n }\n } else {\n const length = CommandCount[current[0] as PathVerb];\n if (current.length < length) {\n current.push(cmd);\n }\n if (current.length === length && i !== cmds.length - 1) {\n acc.push([]);\n }\n }\n return acc;\n }, []);\n return result;\n }\n}\n"],"mappings":";;;;;;;AAEA;;AAaA;;AACA;;AACA;;AACA;;AACA;;;;AAEA,MAAMA,YAAY,GAAG;EACnB,CAACC,eAAA,CAASC,IAAV,GAAiB,CADE;EAEnB,CAACD,eAAA,CAASE,IAAV,GAAiB,CAFE;EAGnB,CAACF,eAAA,CAASG,IAAV,GAAiB,CAHE;EAInB,CAACH,eAAA,CAASI,KAAV,GAAkB,CAJC;EAKnB,CAACJ,eAAA,CAASK,KAAV,GAAkB,CALC;EAMnB,CAACL,eAAA,CAASM,KAAV,GAAkB;AANC,CAArB;;AASA,MAAMC,IAAI,GAAIC,CAAD,IAAeC,IAAI,CAACC,GAAL,CAASD,IAAI,CAACE,GAAL,CAASH,CAAT,EAAY,CAAZ,CAAT,EAAyB,CAAzB,CAA5B;;A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;UAC3BD,OAAO,CAACD,IAAR,CAAaF,GAAb;QACD;;QACD,IAAIG,OAAO,CAACC,MAAR,KAAmBA,MAAnB,IAA6BH,CAAC,KAAKJ,IAAI,CAACO,MAAL,GAAc,CAArD,EAAwD;UACtDL,GAAG,CAACG,IAAJ,CAAS,EAAT;QACD;MACF;;MACD,OAAOH,GAAP;IACD,CArBc,EAqBZ,EArBY,CAAf;IAsBA,OAAOvG,MAAP;EACD;;AA3WuE"}
1
+ {"version":3,"names":["CommandCount","PathVerb","Move","Line","Quad","Conic","Cubic","Close","pinT","t","Math","min","max","JsiSkPath","HostObject","constructor","CanvasKit","ref","delete","addPath","src","matrix","extend","args","fromValue","JsiSkMatrix","addArc","oval","startAngleInDegrees","sweepAngleInDegrees","JsiSkRect","addOval","isCCW","startIndex","countPoints","addPoly","points","close","map","p","Array","from","JsiSkPoint","flat","moveTo","x","y","lineTo","makeAsWinding","result","offset","dx","dy","rArcTo","rx","ry","xAxisRotateInDegrees","useSmallArc","rConicTo","dx1","dy1","dx2","dy2","w","rCubicTo","cpx1","cpy1","cpx2","cpy2","rMoveTo","rLineTo","rQuadTo","x1","y1","x2","y2","setFillType","fill","getEnum","FillType","setIsVolatile","volatile","stroke","opts","undefined","width","miter_limit","precision","join","optEnum","StrokeJoin","cap","StrokeCap","reset","rewind","computeTightBounds","arcToOval","forceMoveTo","arcToRotated","arcToTangent","radius","conicTo","contains","copy","cubicTo","dash","on","off","phase","equals","other","getBounds","getFillType","value","quadTo","addRect","rect","addRRect","rrect","JsiSkRRect","getPoint","index","isEmpty","isVolatile","addCircle","r","getLastPt","op","path","PathOp","simplify","toSVGString","trim","start","stop","isComplement","startT","stopT","transform","m","length","Error","interpolate","end","output","Path","MakeFromPathInterpolation","isInterpolatable","path2","CanInterpolate","toCmds","cmds","reduce","acc","cmd","i","push","current"],"sources":["JsiSkPath.ts"],"sourcesContent":["import type { CanvasKit, Matrix3x3, Path } from \"canvaskit-wasm\";\n\nimport { PathVerb } from \"../types\";\nimport type {\n FillType,\n PathCommand,\n PathOp,\n SkMatrix,\n SkPath,\n SkPoint,\n SkRect,\n InputRRect,\n StrokeOpts,\n InputMatrix,\n} from \"../types\";\n\nimport { getEnum, HostObject, optEnum } from \"./Host\";\nimport { JsiSkPoint } from \"./JsiSkPoint\";\nimport { JsiSkRect } from \"./JsiSkRect\";\nimport { JsiSkRRect } from \"./JsiSkRRect\";\nimport { JsiSkMatrix } from \"./JsiSkMatrix\";\n\nconst CommandCount = {\n [PathVerb.Move]: 3,\n [PathVerb.Line]: 3,\n [PathVerb.Quad]: 5,\n [PathVerb.Conic]: 6,\n [PathVerb.Cubic]: 7,\n [PathVerb.Close]: 1,\n};\n\nconst pinT = (t: number) => Math.min(Math.max(t, 0), 1);\n\nexport class JsiSkPath extends HostObject<Path, \"Path\"> implements SkPath {\n constructor(CanvasKit: CanvasKit, ref: Path) {\n super(CanvasKit, ref, \"Path\");\n }\n\n dispose = () => {\n this.ref.delete();\n };\n\n addPath(src: SkPath, matrix?: SkMatrix, extend = false) {\n const args = [\n JsiSkPath.fromValue(src),\n ...(matrix ? JsiSkMatrix.fromValue<Float32Array>(matrix) : []),\n extend,\n ];\n this.ref.addPath(...args);\n return this;\n }\n\n addArc(\n oval: SkRect,\n startAngleInDegrees: number,\n sweepAngleInDegrees: number\n ) {\n this.ref.addArc(\n JsiSkRect.fromValue(this.CanvasKit, oval),\n startAngleInDegrees,\n sweepAngleInDegrees\n );\n return this;\n }\n\n addOval(oval: SkRect, isCCW?: boolean, startIndex?: number) {\n this.ref.addOval(\n JsiSkRect.fromValue(this.CanvasKit, oval),\n isCCW,\n startIndex\n );\n return this;\n }\n\n countPoints() {\n return this.ref.countPoints();\n }\n\n addPoly(points: SkPoint[], close: boolean) {\n this.ref.addPoly(\n points.map((p) => Array.from(JsiSkPoint.fromValue(p))).flat(),\n close\n );\n return this;\n }\n\n moveTo(x: number, y: number) {\n this.ref.moveTo(x, y);\n return this;\n }\n\n lineTo(x: number, y: number) {\n this.ref.lineTo(x, y);\n return this;\n }\n\n makeAsWinding() {\n const result = this.ref.makeAsWinding();\n return result === null ? result : this;\n }\n\n offset(dx: number, dy: number) {\n this.ref.offset(dx, dy);\n return this;\n }\n\n rArcTo(\n rx: number,\n ry: number,\n xAxisRotateInDegrees: number,\n useSmallArc: boolean,\n isCCW: boolean,\n dx: number,\n dy: number\n ) {\n this.ref.rArcTo(rx, ry, xAxisRotateInDegrees, useSmallArc, isCCW, dx, dy);\n return this;\n }\n\n rConicTo(dx1: number, dy1: number, dx2: number, dy2: number, w: number) {\n this.ref.rConicTo(dx1, dy1, dx2, dy2, w);\n return this;\n }\n\n rCubicTo(\n cpx1: number,\n cpy1: number,\n cpx2: number,\n cpy2: number,\n x: number,\n y: number\n ) {\n this.ref.rCubicTo(cpx1, cpy1, cpx2, cpy2, x, y);\n return this;\n }\n\n rMoveTo(x: number, y: number) {\n this.ref.rMoveTo(x, y);\n return this;\n }\n\n rLineTo(x: number, y: number) {\n this.ref.rLineTo(x, y);\n return this;\n }\n\n rQuadTo(x1: number, y1: number, x2: number, y2: number) {\n this.ref.rQuadTo(x1, y1, x2, y2);\n return this;\n }\n\n setFillType(fill: FillType) {\n this.ref.setFillType(getEnum(this.CanvasKit.FillType, fill));\n return this;\n }\n\n setIsVolatile(volatile: boolean) {\n this.ref.setIsVolatile(volatile);\n return this;\n }\n\n stroke(opts?: StrokeOpts) {\n const result = this.ref.stroke(\n opts === undefined\n ? undefined\n : {\n width: opts.width,\n // eslint-disable-next-line camelcase\n miter_limit: opts.width,\n precision: opts.width,\n join: optEnum(this.CanvasKit.StrokeJoin, opts.join),\n cap: optEnum(this.CanvasKit.StrokeCap, opts.cap),\n }\n );\n return result === null ? result : this;\n }\n\n close() {\n this.ref.close();\n return this;\n }\n\n reset() {\n this.ref.reset();\n return this;\n }\n\n rewind() {\n this.ref.rewind();\n return this;\n }\n\n computeTightBounds(): SkRect {\n return new JsiSkRect(this.CanvasKit, this.ref.computeTightBounds());\n }\n\n arcToOval(\n oval: SkRect,\n startAngleInDegrees: number,\n sweepAngleInDegrees: number,\n forceMoveTo: boolean\n ) {\n this.ref.arcToOval(\n JsiSkRect.fromValue(this.CanvasKit, oval),\n startAngleInDegrees,\n sweepAngleInDegrees,\n forceMoveTo\n );\n return this;\n }\n\n arcToRotated(\n rx: number,\n ry: number,\n xAxisRotateInDegrees: number,\n useSmallArc: boolean,\n isCCW: boolean,\n x: number,\n y: number\n ) {\n this.ref.arcToRotated(\n rx,\n ry,\n xAxisRotateInDegrees,\n useSmallArc,\n isCCW,\n x,\n y\n );\n return this;\n }\n\n arcToTangent(x1: number, y1: number, x2: number, y2: number, radius: number) {\n this.ref.arcToTangent(x1, y1, x2, y2, radius);\n return this;\n }\n\n conicTo(x1: number, y1: number, x2: number, y2: number, w: number) {\n this.ref.conicTo(x1, y1, x2, y2, w);\n return this;\n }\n\n contains(x: number, y: number) {\n return this.ref.contains(x, y);\n }\n\n copy() {\n return new JsiSkPath(this.CanvasKit, this.ref.copy());\n }\n\n cubicTo(\n cpx1: number,\n cpy1: number,\n cpx2: number,\n cpy2: number,\n x: number,\n y: number\n ) {\n this.ref.cubicTo(cpx1, cpy1, cpx2, cpy2, x, y);\n return this;\n }\n\n dash(on: number, off: number, phase: number) {\n return this.ref.dash(on, off, phase);\n }\n\n equals(other: SkPath) {\n return this.ref.equals(JsiSkPath.fromValue(other));\n }\n\n getBounds() {\n return new JsiSkRect(this.CanvasKit, this.ref.getBounds());\n }\n\n getFillType() {\n return this.ref.getFillType().value;\n }\n\n quadTo(x1: number, y1: number, x2: number, y2: number) {\n this.ref.quadTo(x1, y1, x2, y2);\n return this;\n }\n\n addRect(rect: SkRect, isCCW?: boolean) {\n this.ref.addRect(JsiSkRect.fromValue(this.CanvasKit, rect), isCCW);\n return this;\n }\n\n addRRect(rrect: InputRRect, isCCW?: boolean) {\n this.ref.addRRect(JsiSkRRect.fromValue(this.CanvasKit, rrect), isCCW);\n return this;\n }\n\n getPoint(index: number) {\n return new JsiSkPoint(this.CanvasKit, this.ref.getPoint(index));\n }\n\n isEmpty() {\n return this.ref.isEmpty();\n }\n\n isVolatile() {\n return this.ref.isVolatile();\n }\n\n addCircle(x: number, y: number, r: number) {\n this.ref.addCircle(x, y, r);\n return this;\n }\n\n getLastPt() {\n return new JsiSkPoint(\n this.CanvasKit,\n this.ref.getPoint(this.ref.countPoints() - 1)\n );\n }\n\n op(path: SkPath, op: PathOp) {\n return this.ref.op(\n JsiSkPath.fromValue(path),\n getEnum(this.CanvasKit.PathOp, op)\n );\n }\n\n simplify() {\n return this.ref.simplify();\n }\n\n toSVGString() {\n return this.ref.toSVGString();\n }\n\n trim(start: number, stop: number, isComplement: boolean) {\n const startT = pinT(start);\n const stopT = pinT(stop);\n if (startT === 0 && stopT === 1) {\n return this;\n }\n const result = this.ref.trim(startT, stopT, isComplement);\n return result === null ? result : this;\n }\n\n transform(m: InputMatrix) {\n let matrix =\n m instanceof JsiSkMatrix\n ? Array.from(JsiSkMatrix.fromValue<Matrix3x3>(m))\n : (m as Exclude<InputMatrix, SkMatrix>);\n if (matrix.length === 16) {\n matrix = [\n matrix[0],\n matrix[1],\n matrix[3],\n matrix[4],\n matrix[5],\n matrix[7],\n matrix[12],\n matrix[13],\n matrix[15],\n ];\n } else if (matrix.length !== 9) {\n throw new Error(`Invalid matrix length: ${matrix.length}`);\n }\n this.ref.transform(matrix);\n return this;\n }\n\n interpolate(end: SkPath, t: number, output?: SkPath) {\n const path = this.CanvasKit.Path.MakeFromPathInterpolation(\n this.ref,\n JsiSkPath.fromValue(end),\n t\n );\n if (path === null) {\n return null;\n }\n if (output) {\n (output as JsiSkPath).ref = path;\n return output;\n } else {\n return new JsiSkPath(this.CanvasKit, path);\n }\n }\n\n isInterpolatable(path2: SkPath): boolean {\n return this.CanvasKit.Path.CanInterpolate(\n this.ref,\n JsiSkPath.fromValue(path2)\n );\n }\n\n toCmds() {\n const cmds = this.ref.toCmds();\n const result = cmds.reduce<PathCommand[]>((acc, cmd, i) => {\n if (i === 0) {\n acc.push([]);\n }\n const current = acc[acc.length - 1];\n if (current.length === 0) {\n current.push(cmd);\n const length = CommandCount[current[0] as PathVerb];\n if (current.length === length && i !== cmds.length - 1) {\n acc.push([]);\n }\n } else {\n const length = CommandCount[current[0] as PathVerb];\n if (current.length < length) {\n current.push(cmd);\n }\n if (current.length === length && i !== cmds.length - 1) {\n acc.push([]);\n }\n }\n return acc;\n }, []);\n return result;\n }\n}\n"],"mappings":";;;;;;;AAEA;;AAcA;;AACA;;AACA;;AACA;;AACA;;;;AAEA,MAAMA,YAAY,GAAG;EACnB,CAACC,eAAA,CAASC,IAAV,GAAiB,CADE;EAEnB,CAACD,eAAA,CAASE,IAAV,GAAiB,CAFE;EAGnB,CAACF,eAAA,CAASG,IAAV,GAAiB,CAHE;EAInB,CAACH,eAAA,CAASI,KAAV,GAAkB,CAJC;EAKnB,CAACJ,eAAA,CAASK,KAAV,GAAkB,CALC;EAMnB,CAACL,eAAA,CAASM,KAAV,GAAkB;AANC,CAArB;;AASA,MAAMC,IAAI,GAAIC,CAAD,IAAeC,IAAI,CAACC,GAAL,CAASD,IAAI,CAACE,GAAL,CAASH,CAAT,EAAY,CAAZ,CAAT,EAAyB,CAAzB,CAA5B;;AAEO,MAAMI,SAAN,SAAwBC,gBAAxB,CAAmE;EACxEC,WAAW,CAACC,SAAD,EAAuBC,GAAvB,EAAkC;IAC3C,MAAMD,SAAN,EAAiBC,GAAjB,EAAsB,MAAtB;;IAD2C,iCAInC,MAAM;MACd,KAAKA,GAAL,CAASC,MAAT;IACD,CAN4C;EAE5C;;EAMDC,OAAO,CAACC,GAAD,EAAcC,MAAd,EAAiD;IAAA,IAAhBC,MAAgB,uEAAP,KAAO;IACtD,MAAMC,IAAI,GAAG,CACXV,SAAS,CAACW,SAAV,CAAoBJ,GAApB,CADW,EAEX,IAAIC,MAAM,GAAGI,wBAAA,CAAYD,SAAZ,CAAoCH,MAApC,CAAH,GAAiD,EAA3D,CAFW,EAGXC,MA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AG5I,YAAY,CAAC6J,OAAO,CAAC,CAAD,CAAR,CAA3B;;QACA,IAAIA,OAAO,CAACjB,MAAR,GAAiBA,MAArB,EAA6B;UAC3BiB,OAAO,CAACD,IAAR,CAAaF,GAAb;QACD;;QACD,IAAIG,OAAO,CAACjB,MAAR,KAAmBA,MAAnB,IAA6Be,CAAC,KAAKJ,IAAI,CAACX,MAAL,GAAc,CAArD,EAAwD;UACtDa,GAAG,CAACG,IAAJ,CAAS,EAAT;QACD;MACF;;MACD,OAAOH,GAAP;IACD,CArBc,EAqBZ,EArBY,CAAf;IAsBA,OAAOxG,MAAP;EACD;;AA9XuE"}
@@ -0,0 +1,31 @@
1
+ import React from "react";
2
+ import type { Skia, SkRect } from "../skia/types";
3
+ import type { SkiaDomViewProps } from "./types";
4
+ export declare class SkiaJSDomView extends React.Component<SkiaDomViewProps & {
5
+ Skia: Skia;
6
+ }> {
7
+ constructor(props: SkiaDomViewProps & {
8
+ Skia: Skia;
9
+ });
10
+ private _nativeId;
11
+ get nativeId(): number;
12
+ componentDidUpdate(prevProps: SkiaDomViewProps & {
13
+ Skia: Skia;
14
+ }): void;
15
+ /**
16
+ * Creates a snapshot from the canvas in the surface
17
+ * @param rect Rect to use as bounds. Optional.
18
+ * @returns An Image object.
19
+ */
20
+ makeImageSnapshot(rect?: SkRect): import("../skia/types").SkImage;
21
+ /**
22
+ * Sends a redraw request to the native SkiaView.
23
+ */
24
+ redraw(): void;
25
+ private draw;
26
+ /**
27
+ * Clear up the dom node when unmounting to release resources.
28
+ */
29
+ componentWillUnmount(): void;
30
+ render(): React.JSX.Element;
31
+ }
@@ -0,0 +1,161 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SkiaJSDomView = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _Platform = require("../Platform");
11
+
12
+ var _SkiaPictureViewNativeComponent = _interopRequireDefault(require("../specs/SkiaPictureViewNativeComponent"));
13
+
14
+ var _types = require("../dom/types");
15
+
16
+ var _api = require("./api");
17
+
18
+ var _SkiaViewNativeId = require("./SkiaViewNativeId");
19
+
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
+
22
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
23
+
24
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
25
+
26
+ const NativeSkiaPictureView = _Platform.Platform.OS !== "web" ? _SkiaPictureViewNativeComponent.default : // eslint-disable-next-line @typescript-eslint/no-explicit-any
27
+ null;
28
+
29
+ class SkiaJSDomView extends _react.default.Component {
30
+ constructor(props) {
31
+ super(props);
32
+
33
+ _defineProperty(this, "_nativeId", void 0);
34
+
35
+ this._nativeId = _SkiaViewNativeId.SkiaViewNativeId.current++;
36
+ const {
37
+ root,
38
+ onTouch,
39
+ onSize
40
+ } = props;
41
+
42
+ if (root) {
43
+ assertSkiaViewApi();
44
+
45
+ _api.SkiaViewApi.setJsiProperty(this._nativeId, "root", root);
46
+ }
47
+
48
+ if (onTouch) {
49
+ assertSkiaViewApi();
50
+
51
+ _api.SkiaViewApi.setJsiProperty(this._nativeId, "onTouch", onTouch);
52
+ }
53
+
54
+ if (onSize) {
55
+ assertSkiaViewApi();
56
+
57
+ _api.SkiaViewApi.setJsiProperty(this._nativeId, "onSize", onSize);
58
+ }
59
+ }
60
+
61
+ get nativeId() {
62
+ return this._nativeId;
63
+ }
64
+
65
+ componentDidUpdate(prevProps) {
66
+ const {
67
+ root,
68
+ onTouch,
69
+ onSize
70
+ } = this.props;
71
+
72
+ if (root !== prevProps.root && root !== undefined) {
73
+ assertSkiaViewApi();
74
+ this.draw();
75
+ }
76
+
77
+ if (onTouch !== prevProps.onTouch) {
78
+ assertSkiaViewApi();
79
+
80
+ _api.SkiaViewApi.setJsiProperty(this._nativeId, "onTouch", onTouch);
81
+ }
82
+
83
+ if (onSize !== prevProps.onSize) {
84
+ assertSkiaViewApi();
85
+
86
+ _api.SkiaViewApi.setJsiProperty(this._nativeId, "onSize", onSize);
87
+ }
88
+ }
89
+ /**
90
+ * Creates a snapshot from the canvas in the surface
91
+ * @param rect Rect to use as bounds. Optional.
92
+ * @returns An Image object.
93
+ */
94
+
95
+
96
+ makeImageSnapshot(rect) {
97
+ assertSkiaViewApi();
98
+ return _api.SkiaViewApi.makeImageSnapshot(this._nativeId, rect);
99
+ }
100
+ /**
101
+ * Sends a redraw request to the native SkiaView.
102
+ */
103
+
104
+
105
+ redraw() {
106
+ assertSkiaViewApi();
107
+ this.draw(); //SkiaViewApi.requestRedraw(this._nativeId);
108
+ }
109
+
110
+ draw() {
111
+ const {
112
+ root,
113
+ Skia
114
+ } = this.props;
115
+
116
+ if (root !== undefined) {
117
+ assertSkiaViewApi();
118
+ const rec = Skia.PictureRecorder();
119
+ const canvas = rec.beginRecording();
120
+ const ctx = new _types.JsiDrawingContext(Skia, canvas);
121
+ root.render(ctx);
122
+ const picture = rec.finishRecordingAsPicture();
123
+
124
+ _api.SkiaViewApi.setJsiProperty(this._nativeId, "picture", picture);
125
+ }
126
+ }
127
+ /**
128
+ * Clear up the dom node when unmounting to release resources.
129
+ */
130
+
131
+
132
+ componentWillUnmount() {
133
+ assertSkiaViewApi();
134
+
135
+ _api.SkiaViewApi.setJsiProperty(this._nativeId, "picture", null);
136
+ }
137
+
138
+ render() {
139
+ const {
140
+ mode,
141
+ debug = false,
142
+ ...viewProps
143
+ } = this.props;
144
+ return /*#__PURE__*/_react.default.createElement(NativeSkiaPictureView, _extends({
145
+ collapsable: false,
146
+ nativeID: `${this._nativeId}`,
147
+ mode: mode,
148
+ debug: debug
149
+ }, viewProps));
150
+ }
151
+
152
+ }
153
+
154
+ exports.SkiaJSDomView = SkiaJSDomView;
155
+
156
+ const assertSkiaViewApi = () => {
157
+ if (_api.SkiaViewApi === null || _api.SkiaViewApi.setJsiProperty === null || _api.SkiaViewApi.callJsiMethod === null || _api.SkiaViewApi.requestRedraw === null || _api.SkiaViewApi.makeImageSnapshot === null) {
158
+ throw Error("Skia View Api was not found.");
159
+ }
160
+ };
161
+ //# sourceMappingURL=SkiaJSDomView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NativeSkiaPictureView","Platform","OS","SkiaPictureViewNativeComponent","SkiaJSDomView","React","Component","constructor","props","_nativeId","SkiaViewNativeId","current","root","onTouch","onSize","assertSkiaViewApi","SkiaViewApi","setJsiProperty","nativeId","componentDidUpdate","prevProps","undefined","draw","makeImageSnapshot","rect","redraw","Skia","rec","PictureRecorder","canvas","beginRecording","ctx","JsiDrawingContext","render","picture","finishRecordingAsPicture","componentWillUnmount","mode","debug","viewProps","callJsiMethod","requestRedraw","Error"],"sources":["SkiaJSDomView.tsx"],"sourcesContent":["import React from \"react\";\nimport type { HostComponent } from \"react-native\";\n\nimport type { Skia, SkRect } from \"../skia/types\";\nimport { Platform } from \"../Platform\";\nimport SkiaPictureViewNativeComponent from \"../specs/SkiaPictureViewNativeComponent\";\nimport { JsiDrawingContext } from \"../dom/types\";\n\nimport { SkiaViewApi } from \"./api\";\nimport type { SkiaPictureViewProps, SkiaDomViewProps } from \"./types\";\nimport { SkiaViewNativeId } from \"./SkiaViewNativeId\";\n\nconst NativeSkiaPictureView: HostComponent<SkiaPictureViewProps> =\n Platform.OS !== \"web\"\n ? SkiaPictureViewNativeComponent\n : // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (null as any);\n\nexport class SkiaJSDomView extends React.Component<\n SkiaDomViewProps & { Skia: Skia }\n> {\n constructor(props: SkiaDomViewProps & { Skia: Skia }) {\n super(props);\n this._nativeId = SkiaViewNativeId.current++;\n const { root, onTouch, onSize } = props;\n if (root) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"root\", root);\n }\n if (onTouch) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"onTouch\", onTouch);\n }\n if (onSize) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"onSize\", onSize);\n }\n }\n\n private _nativeId: number;\n\n public get nativeId() {\n return this._nativeId;\n }\n\n componentDidUpdate(prevProps: SkiaDomViewProps & { Skia: Skia }) {\n const { root, onTouch, onSize } = this.props;\n if (root !== prevProps.root && root !== undefined) {\n assertSkiaViewApi();\n this.draw();\n }\n if (onTouch !== prevProps.onTouch) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"onTouch\", onTouch);\n }\n if (onSize !== prevProps.onSize) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"onSize\", onSize);\n }\n }\n\n /**\n * Creates a snapshot from the canvas in the surface\n * @param rect Rect to use as bounds. Optional.\n * @returns An Image object.\n */\n public makeImageSnapshot(rect?: SkRect) {\n assertSkiaViewApi();\n return SkiaViewApi.makeImageSnapshot(this._nativeId, rect);\n }\n\n /**\n * Sends a redraw request to the native SkiaView.\n */\n public redraw() {\n assertSkiaViewApi();\n this.draw();\n //SkiaViewApi.requestRedraw(this._nativeId);\n }\n\n private draw() {\n const { root, Skia } = this.props;\n if (root !== undefined) {\n assertSkiaViewApi();\n const rec = Skia.PictureRecorder();\n const canvas = rec.beginRecording();\n const ctx = new JsiDrawingContext(Skia, canvas);\n root.render(ctx);\n const picture = rec.finishRecordingAsPicture();\n SkiaViewApi.setJsiProperty(this._nativeId, \"picture\", picture);\n }\n }\n\n /**\n * Clear up the dom node when unmounting to release resources.\n */\n componentWillUnmount(): void {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"picture\", null);\n }\n\n render() {\n const { mode, debug = false, ...viewProps } = this.props;\n return (\n <NativeSkiaPictureView\n collapsable={false}\n nativeID={`${this._nativeId}`}\n mode={mode}\n debug={debug}\n {...viewProps}\n />\n );\n }\n}\n\nconst assertSkiaViewApi = () => {\n if (\n SkiaViewApi === null ||\n SkiaViewApi.setJsiProperty === null ||\n SkiaViewApi.callJsiMethod === null ||\n SkiaViewApi.requestRedraw === null ||\n SkiaViewApi.makeImageSnapshot === null\n ) {\n throw Error(\"Skia View Api was not found.\");\n }\n};\n"],"mappings":";;;;;;;AAAA;;AAIA;;AACA;;AACA;;AAEA;;AAEA;;;;;;;;AAEA,MAAMA,qBAA0D,GAC9DC,kBAAA,CAASC,EAAT,KAAgB,KAAhB,GACIC,uCADJ,GAEI;AACC,IAJP;;AAMO,MAAMC,aAAN,SAA4BC,cAAA,CAAMC,SAAlC,CAEL;EACAC,WAAW,CAACC,KAAD,EAA2C;IACpD,MAAMA,KAAN;;IADoD;;IAEpD,KAAKC,SAAL,GAAiBC,kCAAA,CAAiBC,OAAjB,EAAjB;IACA,MAAM;MAAEC,IAAF;MAAQC,OAAR;MAAiBC;IAAjB,IAA4BN,KAAlC;;IACA,IAAII,IAAJ,EAAU;MACRG,iBAAiB;;MACjBC,gBAAA,CAAYC,cAAZ,CAA2B,KAAKR,SAAhC,EAA2C,MAA3C,EAAmDG,IAAnD;IACD;;IACD,IAAIC,OAAJ,EAAa;MACXE,iBAAiB;;MACjBC,gBAAA,CAAYC,cAAZ,CAA2B,KAAKR,SAAhC,EAA2C,SAA3C,EAAsDI,OAAtD;IACD;;IACD,IAAIC,MAAJ,EAAY;MACVC,iBAAiB;;MACjBC,gBAAA,CAAYC,cAAZ,CAA2B,KAAKR,SAAhC,EAA2C,QAA3C,EAAqDK,MAArD;IACD;EACF;;EAIkB,IAARI,QAAQ,GAAG;IACpB,OAAO,KAAKT,SAAZ;EACD;;EAEDU,kBAAkB,CAACC,SAAD,EAA+C;IAC/D,MAAM;MAAER,IAAF;MAAQC,OAAR;MAAiBC;IAAjB,IAA4B,KAAKN,KAAvC;;IACA,IAAII,IAAI,KAAKQ,SAAS,CAACR,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,CAA2B,KAAKR,SAAhC,EAA2C,SAA3C,EAAsD,IAAtD;EACD;;EAEDwB,MAAM,GAAG;IACP,MAAM;MAAEI,IAAF;MAAQC,KAAK,GAAG,KAAhB;MAAuB,GAAGC;IAA1B,IAAwC,KAAK/B,KAAnD;IACA,oBACE,6BAAC,qBAAD;MACE,WAAW,EAAE,KADf;MAEE,QAAQ,EAAG,GAAE,KAAKC,SAAU,EAF9B;MAGE,IAAI,EAAE4B,IAHR;MAIE,KAAK,EAAEC;IAJT,GAKMC,SALN,EADF;EASD;;AA5FD;;;;AA+FF,MAAMxB,iBAAiB,GAAG,MAAM;EAC9B,IACEC,gBAAA,KAAgB,IAAhB,IACAA,gBAAA,CAAYC,cAAZ,KAA+B,IAD/B,IAEAD,gBAAA,CAAYwB,aAAZ,KAA8B,IAF9B,IAGAxB,gBAAA,CAAYyB,aAAZ,KAA8B,IAH9B,IAIAzB,gBAAA,CAAYO,iBAAZ,KAAkC,IALpC,EAME;IACA,MAAMmB,KAAK,CAAC,8BAAD,CAAX;EACD;AACF,CAVD"}
@@ -0,0 +1 @@
1
+ export { SkiaDomView as SkiaJSDomView } from "./SkiaDomView";
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "SkiaJSDomView", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _SkiaDomView.SkiaDomView;
10
+ }
11
+ });
12
+
13
+ var _SkiaDomView = require("./SkiaDomView");
14
+ //# sourceMappingURL=SkiaJSDomView.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["SkiaJSDomView.web.tsx"],"sourcesContent":["export { SkiaDomView as SkiaJSDomView } from \"./SkiaDomView\";\n"],"mappings":";;;;;;;;;;;;AAAA"}
@@ -1,11 +1,12 @@
1
1
  import { useCallback, useMemo } from "react";
2
2
  import { interpolatePaths, interpolateVector } from "../../animation";
3
3
  import { Skia } from "../../skia";
4
+ import { Platform } from "../../Platform";
4
5
  import { useAnimatedReaction, useFrameCallback, useSharedValue, useDerivedValue } from "./moduleWrapper";
5
6
  export const notifyChange = value => {
6
7
  "worklet";
7
8
 
8
- if (_WORKLET) {
9
+ if (_WORKLET || Platform.OS === "web") {
9
10
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
11
  value._value = value.value;
11
12
  }
@@ -1 +1 @@
1
- {"version":3,"names":["useCallback","useMemo","interpolatePaths","interpolateVector","Skia","useAnimatedReaction","useFrameCallback","useSharedValue","useDerivedValue","notifyChange","value","_WORKLET","_value","usePathValue","cb","pathInit","Path","Make","path","reset","useClock","clock","callback","info","timeSinceFirstFrame","useInterpolator","factory","interpolator","input","output","options","init","result","val","usePathInterpolation","outputRange","useVectorInterpolation","Point"],"sources":["interpolators.ts"],"sourcesContent":["import type {\n ExtrapolationType,\n FrameInfo,\n SharedValue,\n} from \"react-native-reanimated\";\nimport { useCallback, useMemo } from \"react\";\n\nimport type { SkPath, SkPoint } from \"../../skia/types\";\nimport { interpolatePaths, interpolateVector } from \"../../animation\";\nimport { Skia } from \"../../skia\";\n\nimport {\n useAnimatedReaction,\n useFrameCallback,\n useSharedValue,\n useDerivedValue,\n} from \"./moduleWrapper\";\n\nexport const notifyChange = (value: SharedValue<unknown>) => {\n \"worklet\";\n if (_WORKLET) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (value as any)._value = value.value;\n }\n};\n\nexport const usePathValue = (cb: (path: SkPath) => void) => {\n const pathInit = useMemo(() => Skia.Path.Make(), []);\n const path = useSharedValue(pathInit);\n useDerivedValue(() => {\n path.value.reset();\n cb(path.value);\n notifyChange(path);\n });\n return path;\n};\n\nexport const useClock = () => {\n const clock = useSharedValue(0);\n const callback = useCallback(\n (info: FrameInfo) => {\n \"worklet\";\n clock.value = info.timeSinceFirstFrame;\n },\n [clock]\n );\n useFrameCallback(callback);\n return clock;\n};\n\n/**\n * @worklet\n */\ntype Interpolator<T> = (\n value: number,\n input: number[],\n output: T[],\n options: ExtrapolationType,\n result: T\n) => T;\n\nconst useInterpolator = <T>(\n factory: () => T,\n value: SharedValue<number>,\n interpolator: Interpolator<T>,\n input: number[],\n output: T[],\n options?: ExtrapolationType\n) => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const init = useMemo(() => factory(), []);\n const result = useSharedValue(init);\n useAnimatedReaction(\n () => value.value,\n (val) => {\n result.value = interpolator(val, input, output, options, result.value);\n notifyChange(result);\n },\n [input, output, options]\n );\n return result;\n};\n\nexport const usePathInterpolation = (\n value: SharedValue<number>,\n input: number[],\n outputRange: SkPath[],\n options?: ExtrapolationType\n) =>\n useInterpolator(\n () => Skia.Path.Make(),\n value,\n interpolatePaths,\n input,\n outputRange,\n options\n );\n\nexport const useVectorInterpolation = (\n value: SharedValue<number>,\n input: number[],\n outputRange: SkPoint[],\n options?: ExtrapolationType\n) =>\n useInterpolator(\n () => Skia.Point(0, 0),\n value,\n interpolateVector,\n input,\n outputRange,\n options\n );\n"],"mappings":"AAKA,SAASA,WAAT,EAAsBC,OAAtB,QAAqC,OAArC;AAGA,SAASC,gBAAT,EAA2BC,iBAA3B,QAAoD,iBAApD;AACA,SAASC,IAAT,QAAqB,YAArB;AAEA,SACEC,mBADF,EAEEC,gBAFF,EAGEC,cAHF,EAIEC,eAJF,QAKO,iBALP;AAOA,OAAO,MAAMC,YAAY,GAAIC,KAAD,IAAiC;EAC3D;;EACA,IAAIC,QAAJ,EAAc;IACZ;IACCD,KAAD,CAAeE,MAAf,GAAwBF,KAAK,CAACA,KAA9B;EACD;AACF,CANM;AAQP,OAAO,MAAMG,YAAY,GAAIC,EAAD,IAAgC;EAC1D,MAAMC,QAAQ,GAAGd,OAAO,CAAC,MAAMG,IAAI,CAACY,IAAL,CAAUC,IAAV,EAAP,EAAyB,EAAzB,CAAxB;EACA,MAAMC,IAAI,GAAGX,cAAc,CAACQ,QAAD,CAA3B;EACAP,eAAe,CAAC,MAAM;IACpBU,IAAI,CAACR,KAAL,CAA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Ha,EAIb0B,KAJa,EAKbO,WALa,EAMbL,OANa,CANV;AAeP,OAAO,MAAMM,sBAAsB,GAAG,CACpC1B,KADoC,EAEpCkB,KAFoC,EAGpCO,WAHoC,EAIpCL,OAJoC,KAMpCL,eAAe,CACb,MAAMrB,IAAI,CAACiC,KAAL,CAAW,CAAX,EAAc,CAAd,CADO,EAEb3B,KAFa,EAGbP,iBAHa,EAIbyB,KAJa,EAKbO,WALa,EAMbL,OANa,CANV"}
1
+ {"version":3,"names":["useCallback","useMemo","interpolatePaths","interpolateVector","Skia","Platform","useAnimatedReaction","useFrameCallback","useSharedValue","useDerivedValue","notifyChange","value","_WORKLET","OS","_value","usePathValue","cb","pathInit","Path","Make","path","reset","useClock","clock","callback","info","timeSinceFirstFrame","useInterpolator","factory","interpolator","input","output","options","init","result","val","usePathInterpolation","outputRange","useVectorInterpolation","Point"],"sources":["interpolators.ts"],"sourcesContent":["import type {\n ExtrapolationType,\n FrameInfo,\n SharedValue,\n} from \"react-native-reanimated\";\nimport { useCallback, useMemo } from \"react\";\n\nimport type { SkPath, SkPoint } from \"../../skia/types\";\nimport { interpolatePaths, interpolateVector } from \"../../animation\";\nimport { Skia } from \"../../skia\";\nimport { Platform } from \"../../Platform\";\n\nimport {\n useAnimatedReaction,\n useFrameCallback,\n useSharedValue,\n useDerivedValue,\n} from \"./moduleWrapper\";\n\nexport const notifyChange = (value: SharedValue<unknown>) => {\n \"worklet\";\n if (_WORKLET || Platform.OS === \"web\") {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (value as any)._value = value.value;\n }\n};\n\nexport const usePathValue = (cb: (path: SkPath) => void) => {\n const pathInit = useMemo(() => Skia.Path.Make(), []);\n const path = useSharedValue(pathInit);\n useDerivedValue(() => {\n path.value.reset();\n cb(path.value);\n notifyChange(path);\n });\n return path;\n};\n\nexport const useClock = () => {\n const clock = useSharedValue(0);\n const callback = useCallback(\n (info: FrameInfo) => {\n \"worklet\";\n clock.value = info.timeSinceFirstFrame;\n },\n [clock]\n );\n useFrameCallback(callback);\n return clock;\n};\n\n/**\n * @worklet\n */\ntype Interpolator<T> = (\n value: number,\n input: number[],\n output: T[],\n options: ExtrapolationType,\n result: T\n) => T;\n\nconst useInterpolator = <T>(\n factory: () => T,\n value: SharedValue<number>,\n interpolator: Interpolator<T>,\n input: number[],\n output: T[],\n options?: ExtrapolationType\n) => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const init = useMemo(() => factory(), []);\n const result = useSharedValue(init);\n useAnimatedReaction(\n () => value.value,\n (val) => {\n result.value = interpolator(val, input, output, options, result.value);\n notifyChange(result);\n },\n [input, output, options]\n );\n return result;\n};\n\nexport const usePathInterpolation = (\n value: SharedValue<number>,\n input: number[],\n outputRange: SkPath[],\n options?: ExtrapolationType\n) =>\n useInterpolator(\n () => Skia.Path.Make(),\n value,\n interpolatePaths,\n input,\n outputRange,\n options\n );\n\nexport const useVectorInterpolation = (\n value: SharedValue<number>,\n input: number[],\n outputRange: SkPoint[],\n options?: ExtrapolationType\n) =>\n useInterpolator(\n () => Skia.Point(0, 0),\n value,\n interpolateVector,\n input,\n outputRange,\n options\n );\n"],"mappings":"AAKA,SAASA,WAAT,EAAsBC,OAAtB,QAAqC,OAArC;AAGA,SAASC,gBAAT,EAA2BC,iBAA3B,QAAoD,iBAApD;AACA,SAASC,IAAT,QAAqB,YAArB;AACA,SAASC,QAAT,QAAyB,gBAAzB;AAEA,SACEC,mBADF,EAEEC,gBAFF,EAGEC,cAHF,EAIEC,eAJF,QAKO,iBALP;AAOA,OAAO,MAAMC,YAAY,GAAIC,KAAD,IAAiC;EAC3D;;EACA,IAAIC,QAAQ,IAAIP,QAAQ,CAACQ,EAAT,KAAgB,KAAhC,EAAuC;IACrC;IACCF,KAAD,CAAeG,MAAf,GAAwBH,KAAK,CAACA,KAA9B;EACD;AACF,CANM;AAQP,OAAO,MAAMI,YAAY,GAAIC,EAAD,IAAgC;EAC1D,MAAMC,QAAQ,GAAGhB,OAAO,CAAC,MAA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MAAME,oBAAoB,GAAG,CAClCzB,KADkC,EAElCmB,KAFkC,EAGlCO,WAHkC,EAIlCL,OAJkC,KAMlCL,eAAe,CACb,MAAMvB,IAAI,CAACc,IAAL,CAAUC,IAAV,EADO,EAEbR,KAFa,EAGbT,gBAHa,EAIb4B,KAJa,EAKbO,WALa,EAMbL,OANa,CANV;AAeP,OAAO,MAAMM,sBAAsB,GAAG,CACpC3B,KADoC,EAEpCmB,KAFoC,EAGpCO,WAHoC,EAIpCL,OAJoC,KAMpCL,eAAe,CACb,MAAMvB,IAAI,CAACmC,KAAL,CAAW,CAAX,EAAc,CAAd,CADO,EAEb5B,KAFa,EAGbR,iBAHa,EAIb2B,KAJa,EAKbO,WALa,EAMbL,OANa,CANV"}
@@ -2,8 +2,8 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
2
2
 
3
3
  import React, { useEffect, useCallback, useMemo, forwardRef, useRef } from "react";
4
4
  import { SkiaDomView } from "../views";
5
- import { SkiaDomView as SkiaDomViewWeb } from "../views/SkiaDomView.web";
6
5
  import { Skia } from "../skia/Skia";
6
+ import { SkiaJSDomView } from "../views/SkiaJSDomView";
7
7
  import { SkiaRoot } from "./Reconciler";
8
8
  import { NATIVE_DOM } from "./HostComponents";
9
9
  export const useCanvasRef = () => useRef(null);
@@ -75,8 +75,9 @@ export const Canvas = /*#__PURE__*/forwardRef((_ref, forwardedRef) => {
75
75
  debug: debug
76
76
  }, props));
77
77
  } else {
78
- return /*#__PURE__*/React.createElement(SkiaDomViewWeb // eslint-disable-next-line @typescript-eslint/no-explicit-any
79
- , _extends({
78
+ return /*#__PURE__*/React.createElement(SkiaJSDomView, _extends({
79
+ Skia: Skia // eslint-disable-next-line @typescript-eslint/no-explicit-any
80
+ ,
80
81
  ref: ref,
81
82
  style: style,
82
83
  root: root.dom,