@shopify/react-native-skia 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- package/android/src/main/java/com/shopify/reactnative/skia/ViewScreenshotService.java +13 -8
- package/cpp/rnskia/RNSkPlatformContext.h +2 -2
- package/ios/RNSkia-iOS/RNSkiOSPlatformContext.mm +1 -5
- package/ios/RNSkia-iOS/SkiaCVPixelBufferUtils.h +42 -7
- package/ios/RNSkia-iOS/SkiaCVPixelBufferUtils.mm +178 -5
- package/ios/RNSkia-iOS/SkiaMetalSurfaceFactory.mm +8 -11
- package/lib/commonjs/external/ModuleProxy.d.ts +10 -0
- package/lib/commonjs/external/ModuleProxy.js +36 -0
- package/lib/commonjs/external/ModuleProxy.js.map +1 -0
- package/lib/commonjs/external/reanimated/ReanimatedProxy.d.ts +3 -0
- package/lib/commonjs/external/reanimated/ReanimatedProxy.js +18 -0
- package/lib/commonjs/external/reanimated/ReanimatedProxy.js.map +1 -0
- package/lib/commonjs/external/reanimated/buffers.js +9 -6
- package/lib/commonjs/external/reanimated/buffers.js.map +1 -1
- package/lib/commonjs/external/reanimated/interpolators.js +8 -7
- package/lib/commonjs/external/reanimated/interpolators.js.map +1 -1
- package/lib/commonjs/external/reanimated/renderHelpers.js +27 -11
- package/lib/commonjs/external/reanimated/renderHelpers.js.map +1 -1
- package/lib/commonjs/external/reanimated/textures.js +4 -3
- package/lib/commonjs/external/reanimated/textures.js.map +1 -1
- package/lib/commonjs/external/reanimated/useAnimatedImageValue.js +6 -6
- package/lib/commonjs/external/reanimated/useAnimatedImageValue.js.map +1 -1
- package/lib/commonjs/external/reanimated/useDerivedValueOnJS.js +6 -5
- package/lib/commonjs/external/reanimated/useDerivedValueOnJS.js.map +1 -1
- package/lib/commonjs/renderer/Offscreen.js +1 -5
- package/lib/commonjs/renderer/Offscreen.js.map +1 -1
- package/lib/commonjs/skia/types/NativeBuffer/NativeBufferFactory.d.ts +1 -1
- package/lib/commonjs/skia/types/NativeBuffer/NativeBufferFactory.js.map +1 -1
- package/lib/commonjs/specs/NativeSkiaModule.web.d.ts +0 -2
- package/lib/commonjs/specs/NativeSkiaModule.web.js +0 -8
- package/lib/commonjs/specs/NativeSkiaModule.web.js.map +1 -1
- package/lib/module/external/ModuleProxy.d.ts +10 -0
- package/lib/module/external/ModuleProxy.js +28 -0
- package/lib/module/external/ModuleProxy.js.map +1 -0
- package/lib/module/external/reanimated/ReanimatedProxy.d.ts +3 -0
- package/lib/module/external/reanimated/ReanimatedProxy.js +12 -0
- package/lib/module/external/reanimated/ReanimatedProxy.js.map +1 -0
- package/lib/module/external/reanimated/buffers.js +8 -6
- package/lib/module/external/reanimated/buffers.js.map +1 -1
- package/lib/module/external/reanimated/interpolators.js +7 -7
- package/lib/module/external/reanimated/interpolators.js.map +1 -1
- package/lib/module/external/reanimated/renderHelpers.js +26 -11
- package/lib/module/external/reanimated/renderHelpers.js.map +1 -1
- package/lib/module/external/reanimated/textures.js +3 -3
- package/lib/module/external/reanimated/textures.js.map +1 -1
- package/lib/module/external/reanimated/useAnimatedImageValue.js +5 -6
- package/lib/module/external/reanimated/useAnimatedImageValue.js.map +1 -1
- package/lib/module/external/reanimated/useDerivedValueOnJS.js +5 -5
- package/lib/module/external/reanimated/useDerivedValueOnJS.js.map +1 -1
- package/lib/module/renderer/Offscreen.js +1 -5
- package/lib/module/renderer/Offscreen.js.map +1 -1
- package/lib/module/skia/types/NativeBuffer/NativeBufferFactory.d.ts +1 -1
- package/lib/module/skia/types/NativeBuffer/NativeBufferFactory.js.map +1 -1
- package/lib/module/specs/NativeSkiaModule.web.d.ts +0 -2
- package/lib/module/specs/NativeSkiaModule.web.js +0 -3
- package/lib/module/specs/NativeSkiaModule.web.js.map +1 -1
- package/lib/typescript/src/external/ModuleProxy.d.ts +10 -0
- package/lib/typescript/src/external/reanimated/ReanimatedProxy.d.ts +3 -0
- package/lib/typescript/src/skia/types/NativeBuffer/NativeBufferFactory.d.ts +1 -1
- package/lib/typescript/src/specs/NativeSkiaModule.web.d.ts +0 -2
- package/libs/ios/libskia.xcframework/Info.plist +5 -5
- package/libs/ios/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
- package/libs/ios/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
- package/libs/ios/libskottie.xcframework/Info.plist +5 -5
- package/libs/ios/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
- package/libs/ios/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
- package/libs/ios/libskparagraph.xcframework/ios-arm64_arm64e/libskparagraph.a +0 -0
- package/libs/ios/libskparagraph.xcframework/ios-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
- package/libs/ios/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
- package/libs/ios/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
- package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
- package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
- package/libs/ios/libskunicode.xcframework/ios-arm64_arm64e/libskunicode.a +0 -0
- package/libs/ios/libskunicode.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode.a +0 -0
- package/libs/ios/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
- package/libs/ios/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
- package/package.json +1 -1
- package/src/external/ModuleProxy.ts +30 -0
- package/src/external/reanimated/ReanimatedProxy.ts +18 -0
- package/src/external/reanimated/buffers.ts +7 -6
- package/src/external/reanimated/interpolators.ts +7 -12
- package/src/external/reanimated/renderHelpers.ts +31 -18
- package/src/external/reanimated/textures.tsx +3 -3
- package/src/external/reanimated/useAnimatedImageValue.ts +5 -10
- package/src/external/reanimated/useDerivedValueOnJS.ts +5 -10
- package/src/renderer/Offscreen.tsx +1 -7
- package/src/skia/types/NativeBuffer/NativeBufferFactory.ts +1 -1
- package/src/specs/NativeSkiaModule.web.ts +0 -4
- package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaDrawViewManagerDelegate.java +0 -34
- package/cpp/skia/include/gpu/GrBackendDrawableInfo.h +0 -9
- package/lib/commonjs/external/reanimated/moduleWrapper.d.ts +0 -15
- package/lib/commonjs/external/reanimated/moduleWrapper.js +0 -46
- package/lib/commonjs/external/reanimated/moduleWrapper.js.map +0 -1
- package/lib/module/external/reanimated/moduleWrapper.d.ts +0 -15
- package/lib/module/external/reanimated/moduleWrapper.js +0 -37
- package/lib/module/external/reanimated/moduleWrapper.js.map +0 -1
- package/lib/typescript/src/external/reanimated/moduleWrapper.d.ts +0 -15
- package/src/external/reanimated/moduleWrapper.ts +0 -83
@@ -1,15 +1,30 @@
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
2
2
|
|
3
|
-
import
|
3
|
+
import Rea from "./ReanimatedProxy";
|
4
|
+
let HAS_REANIMATED = false;
|
5
|
+
let HAS_REANIMATED_3 = false;
|
6
|
+
try {
|
7
|
+
require("react-native-reanimated");
|
8
|
+
HAS_REANIMATED = true;
|
9
|
+
const reanimatedVersion = require("react-native-reanimated/package.json").version;
|
10
|
+
if (reanimatedVersion && (reanimatedVersion >= "3.0.0" || reanimatedVersion.includes("3.0.0-"))) {
|
11
|
+
HAS_REANIMATED_3 = true;
|
12
|
+
}
|
13
|
+
} catch (e) {
|
14
|
+
HAS_REANIMATED = false;
|
15
|
+
}
|
4
16
|
const _bindings = new WeakMap();
|
5
17
|
export const unbindReanimatedNode = node => {
|
18
|
+
if (!HAS_REANIMATED) {
|
19
|
+
return;
|
20
|
+
}
|
6
21
|
const previousMapperId = _bindings.get(node);
|
7
22
|
if (previousMapperId !== undefined) {
|
8
|
-
stopMapper(previousMapperId);
|
23
|
+
Rea.stopMapper(previousMapperId);
|
9
24
|
}
|
10
25
|
};
|
11
26
|
export function extractReanimatedProps(props) {
|
12
|
-
if (!
|
27
|
+
if (!HAS_REANIMATED) {
|
13
28
|
return [props, {}];
|
14
29
|
}
|
15
30
|
const reanimatedProps = {};
|
@@ -19,7 +34,7 @@ export function extractReanimatedProps(props) {
|
|
19
34
|
continue;
|
20
35
|
}
|
21
36
|
const propValue = props[propName];
|
22
|
-
if (isSharedValue(propValue)) {
|
37
|
+
if (Rea.isSharedValue(propValue)) {
|
23
38
|
reanimatedProps[propName] = propValue;
|
24
39
|
otherProps[propName] = propValue.value;
|
25
40
|
} else {
|
@@ -32,7 +47,7 @@ function bindReanimatedProps2(container, node, reanimatedProps) {
|
|
32
47
|
const sharedValues = Object.values(reanimatedProps);
|
33
48
|
const previousMapperId = _bindings.get(node);
|
34
49
|
if (previousMapperId !== undefined) {
|
35
|
-
stopMapper(previousMapperId);
|
50
|
+
Rea.stopMapper(previousMapperId);
|
36
51
|
}
|
37
52
|
if (sharedValues.length > 0) {
|
38
53
|
const viewId = container.getNativeId();
|
@@ -53,32 +68,32 @@ function bindReanimatedProps2(container, node, reanimatedProps) {
|
|
53
68
|
container.redraw();
|
54
69
|
}
|
55
70
|
};
|
56
|
-
const mapperId = startMapper(() => {
|
71
|
+
const mapperId = Rea.startMapper(() => {
|
57
72
|
"worklet";
|
58
73
|
|
59
|
-
runOnJS(updateProps)();
|
74
|
+
Rea.runOnJS(updateProps)();
|
60
75
|
}, sharedValues);
|
61
76
|
_bindings.set(node, mapperId);
|
62
77
|
}
|
63
78
|
}
|
64
79
|
export function bindReanimatedProps(container, node, reanimatedProps) {
|
65
|
-
if (
|
80
|
+
if (HAS_REANIMATED && !HAS_REANIMATED_3) {
|
66
81
|
return bindReanimatedProps2(container, node, reanimatedProps);
|
67
82
|
}
|
68
|
-
if (!
|
83
|
+
if (!HAS_REANIMATED) {
|
69
84
|
return;
|
70
85
|
}
|
71
86
|
const sharedValues = Object.values(reanimatedProps);
|
72
87
|
const previousMapperId = _bindings.get(node);
|
73
88
|
if (previousMapperId !== undefined) {
|
74
|
-
stopMapper(previousMapperId);
|
89
|
+
Rea.stopMapper(previousMapperId);
|
75
90
|
}
|
76
91
|
if (sharedValues.length > 0) {
|
77
92
|
const viewId = container.getNativeId();
|
78
93
|
const {
|
79
94
|
SkiaViewApi
|
80
95
|
} = global;
|
81
|
-
const mapperId = startMapper(() => {
|
96
|
+
const mapperId = Rea.startMapper(() => {
|
82
97
|
"worklet";
|
83
98
|
|
84
99
|
if (node) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["Rea","HAS_REANIMATED","HAS_REANIMATED_3","require","reanimatedVersion","version","includes","e","_bindings","WeakMap","unbindReanimatedNode","node","previousMapperId","get","undefined","stopMapper","extractReanimatedProps","props","reanimatedProps","otherProps","propName","propValue","isSharedValue","value","bindReanimatedProps2","container","sharedValues","Object","values","length","viewId","getNativeId","SkiaViewApi","global","updateProps","setProp","requestRedraw","redraw","mapperId","startMapper","runOnJS","set","bindReanimatedProps"],"sources":["renderHelpers.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type { Container } from \"../../renderer/Container\";\nimport type { AnimatedProps } from \"../../renderer/processors\";\nimport type { Node } from \"../../dom/types\";\n\nimport Rea from \"./ReanimatedProxy\";\n\nlet HAS_REANIMATED = false;\nlet HAS_REANIMATED_3 = false;\ntry {\n require(\"react-native-reanimated\");\n HAS_REANIMATED = true;\n const reanimatedVersion =\n require(\"react-native-reanimated/package.json\").version;\n if (\n reanimatedVersion &&\n (reanimatedVersion >= \"3.0.0\" || reanimatedVersion.includes(\"3.0.0-\"))\n ) {\n HAS_REANIMATED_3 = true;\n }\n} catch (e) {\n HAS_REANIMATED = false;\n}\n\nconst _bindings = new WeakMap<Node<unknown>, unknown>();\n\nexport const unbindReanimatedNode = (node: Node<unknown>) => {\n if (!HAS_REANIMATED) {\n return;\n }\n const previousMapperId = _bindings.get(node);\n if (previousMapperId !== undefined) {\n Rea.stopMapper(previousMapperId as number);\n }\n};\n\nexport function extractReanimatedProps(props: AnimatedProps<any>) {\n if (!HAS_REANIMATED) {\n return [props, {}];\n }\n const reanimatedProps = {} as AnimatedProps<any>;\n const otherProps = {} as AnimatedProps<any>;\n for (const propName in props) {\n if (propName === \"children\") {\n continue;\n }\n const propValue = props[propName];\n if (Rea.isSharedValue(propValue)) {\n reanimatedProps[propName] = propValue;\n otherProps[propName] = propValue.value;\n } else {\n otherProps[propName] = propValue;\n }\n }\n return [otherProps, reanimatedProps];\n}\n\nfunction bindReanimatedProps2(\n container: Container,\n node: Node<any>,\n reanimatedProps: AnimatedProps<any>\n) {\n const sharedValues = Object.values(reanimatedProps);\n const previousMapperId = _bindings.get(node);\n if (previousMapperId !== undefined) {\n Rea.stopMapper(previousMapperId as number);\n }\n if (sharedValues.length > 0) {\n const viewId = container.getNativeId();\n const { SkiaViewApi } = global;\n const updateProps = () => {\n for (const propName in reanimatedProps) {\n node && node.setProp(propName, reanimatedProps[propName].value);\n }\n // On React Native we use the SkiaViewApi to redraw because it can\n // run on the worklet thread (container.redraw can't)\n // if SkiaViewApi is undefined, we are on web and container.redraw()\n // can safely be invoked\n if (SkiaViewApi) {\n SkiaViewApi.requestRedraw(viewId);\n } else {\n container.redraw();\n }\n };\n const mapperId = Rea.startMapper(() => {\n \"worklet\";\n Rea.runOnJS(updateProps)();\n }, sharedValues);\n _bindings.set(node, mapperId);\n }\n}\n\nexport function bindReanimatedProps(\n container: Container,\n node: Node<any>,\n reanimatedProps: AnimatedProps<any>\n) {\n if (HAS_REANIMATED && !HAS_REANIMATED_3) {\n return bindReanimatedProps2(container, node, reanimatedProps);\n }\n if (!HAS_REANIMATED) {\n return;\n }\n const sharedValues = Object.values(reanimatedProps);\n const previousMapperId = _bindings.get(node);\n if (previousMapperId !== undefined) {\n Rea.stopMapper(previousMapperId as number);\n }\n if (sharedValues.length > 0) {\n const viewId = container.getNativeId();\n const { SkiaViewApi } = global;\n const mapperId = Rea.startMapper(() => {\n \"worklet\";\n if (node) {\n for (const propName in reanimatedProps) {\n node.setProp(propName, reanimatedProps[propName].value);\n }\n }\n // On React Native we use the SkiaViewApi to redraw because it can\n // run on the worklet thread (container.redraw can't)\n // if SkiaViewApi is undefined, we are on web and container.redraw()\n // can safely be invoked\n if (SkiaViewApi) {\n SkiaViewApi.requestRedraw(viewId);\n } else {\n container.redraw();\n }\n }, sharedValues);\n _bindings.set(node, mapperId);\n }\n}\n"],"mappings":"AAAA;;AAMA,OAAOA,GAAG,MAAM,mBAAmB;AAEnC,IAAIC,cAAc,GAAG,KAAK;AAC1B,IAAIC,gBAAgB,GAAG,KAAK;AAC5B,IAAI;EACFC,OAAO,CAAC,yBAAyB,CAAC;EAClCF,cAAc,GAAG,IAAI;EACrB,MAAMG,iBAAiB,GACrBD,OAAO,CAAC,sCAAsC,CAAC,CAACE,OAAO;EACzD,IACED,iBAAiB,KAChBA,iBAAiB,IAAI,OAAO,IAAIA,iBAAiB,CAACE,QAAQ,CAAC,QAAQ,CAAC,CAAC,EACtE;IACAJ,gBAAgB,GAAG,IAAI;EACzB;AACF,CAAC,CAAC,OAAOK,CAAC,EAAE;EACVN,cAAc,GAAG,KAAK;AACxB;AAEA,MAAMO,SAAS,GAAG,IAAIC,OAAO,CAAyB,CAAC;AAEvD,OAAO,MAAMC,oBAAoB,GAAIC,IAAmB,IAAK;EAC3D,IAAI,CAACV,cAAc,EAAE;IACnB;EACF;EACA,MAAMW,gBAAgB,GAAGJ,SAAS,CAACK,GAAG,CAACF,IAAI,CAAC;EAC5C,IAAIC,gBAAgB,KAAKE,SAAS,EAAE;IAClCd,GAAG,CAACe,UAAU,CAACH,gBAA0B,CAAC;EAC5C;AACF,CAAC;AAED,OAAO,SAASI,sBAAsBA,CAACC,KAAyB,EAAE;EAChE,IAAI,CAAChB,cAAc,EAAE;IACnB,OAAO,CAACgB,KAAK,EAAE,CAAC,CAAC,CAAC;EACpB;EACA,MAAMC,eAAe,GAAG,CAAC,CAAuB;EAChD,MAAMC,UAAU,GAAG,CAAC,CAAuB;EAC3C,KAAK,MAAMC,QAAQ,IAAIH,K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BlB,SAAS,CAACiC,GAAG,CAAC9B,IAAI,EAAE2B,QAAQ,CAAC;EAC/B;AACF"}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { useEffect, useMemo } from "react";
|
2
2
|
import { drawAsImageFromPicture, drawAsPicture } from "../../renderer/Offscreen";
|
3
3
|
import { Skia, useImage } from "../../skia";
|
4
|
-
import
|
4
|
+
import Rea from "./ReanimatedProxy";
|
5
5
|
const createTexture = (texture, picture, size) => {
|
6
6
|
"worklet";
|
7
7
|
|
@@ -31,10 +31,10 @@ export const useTextureValueFromPicture = (picture, size) => {
|
|
31
31
|
return usePictureAsTexture(picture, size);
|
32
32
|
};
|
33
33
|
export const usePictureAsTexture = (picture, size) => {
|
34
|
-
const texture = useSharedValue(null);
|
34
|
+
const texture = Rea.useSharedValue(null);
|
35
35
|
useEffect(() => {
|
36
36
|
if (picture !== null) {
|
37
|
-
runOnUI(createTexture)(texture, picture, size);
|
37
|
+
Rea.runOnUI(createTexture)(texture, picture, size);
|
38
38
|
}
|
39
39
|
}, [texture, picture, size]);
|
40
40
|
return texture;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["useEffect","useMemo","drawAsImageFromPicture","drawAsPicture","Skia","useImage","
|
1
|
+
{"version":3,"names":["useEffect","useMemo","drawAsImageFromPicture","drawAsPicture","Skia","useImage","Rea","createTexture","texture","picture","size","value","useTexture","element","width","height","x","y","usePictureAsTexture","useTextureAsValue","console","warn","useTextureValueFromPicture","useSharedValue","runOnUI","useImageAsTexture","source","image","recorder","PictureRecorder","canvas","beginRecording","drawImage","finishRecordingAsPicture"],"sources":["textures.tsx"],"sourcesContent":["import { useEffect, useMemo } from \"react\";\nimport type { ReactElement } from \"react\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nimport type {\n DataSourceParam,\n SkImage,\n SkPicture,\n SkSize,\n} from \"../../skia/types\";\nimport {\n drawAsImageFromPicture,\n drawAsPicture,\n} from \"../../renderer/Offscreen\";\nimport { Skia, useImage } from \"../../skia\";\n\nimport Rea from \"./ReanimatedProxy\";\n\nconst createTexture = (\n texture: SharedValue<SkImage | null>,\n picture: SkPicture,\n size: SkSize\n) => {\n \"worklet\";\n texture.value = drawAsImageFromPicture(picture, size);\n};\n\nexport const useTexture = (element: ReactElement, size: SkSize) => {\n const { width, height } = size;\n const picture = useMemo(() => {\n return drawAsPicture(element, {\n x: 0,\n y: 0,\n width,\n height,\n });\n }, [element, width, height]);\n return usePictureAsTexture(picture, size);\n};\n\nexport const useTextureAsValue = (element: ReactElement, size: SkSize) => {\n console.warn(\"useTextureAsValue has been renamed to use useTexture\");\n return useTexture(element, size);\n};\n\nexport const useTextureValueFromPicture = (\n picture: SkPicture | null,\n size: SkSize\n) => {\n console.warn(\n \"useTextureValueFromPicture has been renamed to use usePictureAsTexture\"\n );\n return usePictureAsTexture(picture, size);\n};\n\nexport const usePictureAsTexture = (\n picture: SkPicture | null,\n size: SkSize\n) => {\n const texture = Rea.useSharedValue<SkImage | null>(null);\n useEffect(() => {\n if (picture !== null) {\n Rea.runOnUI(createTexture)(texture, picture, size);\n }\n }, [texture, picture, size]);\n return texture;\n};\n\nexport const useImageAsTexture = (source: DataSourceParam) => {\n const image = useImage(source);\n const size = useMemo(() => {\n if (image) {\n return { width: image.width(), height: image.height() };\n }\n return { width: 0, height: 0 };\n }, [image]);\n const picture = useMemo(() => {\n if (image) {\n const recorder = Skia.PictureRecorder();\n const canvas = recorder.beginRecording({\n x: 0,\n y: 0,\n width: size.width,\n height: size.height,\n });\n canvas.drawImage(image, 0, 0);\n return recorder.finishRecordingAsPicture();\n } else {\n return null;\n }\n }, [size, image]);\n return usePictureAsTexture(picture, size);\n};\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,OAAO,QAAQ,OAAO;AAU1C,SACEC,sBAAsB,EACtBC,aAAa,QACR,0BAA0B;AACjC,SAASC,IAAI,EAAEC,QAAQ,QAAQ,YAAY;AAE3C,OAAOC,GAAG,MAAM,mBAAmB;AAEnC,MAAMC,a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,CAACF,OAAO,EAAEC,OAAO,EAAEC,IAAI,CAAC,CAAC;EAC5B,OAAOF,OAAO;AAChB,CAAC;AAED,OAAO,MAAMiB,iBAAiB,GAAIC,MAAuB,IAAK;EAC5D,MAAMC,KAAK,GAAGtB,QAAQ,CAACqB,MAAM,CAAC;EAC9B,MAAMhB,IAAI,GAAGT,OAAO,CAAC,MAAM;IACzB,IAAI0B,KAAK,EAAE;MACT,OAAO;QAAEb,KAAK,EAAEa,KAAK,CAACb,KAAK,CAAC,CAAC;QAAEC,MAAM,EAAEY,KAAK,CAACZ,MAAM,CAAC;MAAE,CAAC;IACzD;IACA,OAAO;MAAED,KAAK,EAAE,CAAC;MAAEC,MAAM,EAAE;IAAE,CAAC;EAChC,CAAC,EAAE,CAACY,KAAK,CAAC,CAAC;EACX,MAAMlB,OAAO,GAAGR,OAAO,CAAC,MAAM;IAC5B,IAAI0B,KAAK,EAAE;MACT,MAAMC,QAAQ,GAAGxB,IAAI,CAACyB,eAAe,CAAC,CAAC;MACvC,MAAMC,MAAM,GAAGF,QAAQ,CAACG,cAAc,CAAC;QACrCf,CAAC,EAAE,CAAC;QACJC,CAAC,EAAE,CAAC;QACJH,KAAK,EAAEJ,IAAI,CAACI,KAAK;QACjBC,MAAM,EAAEL,IAAI,CAACK;MACf,CAAC,CAAC;MACFe,MAAM,CAACE,SAAS,CAACL,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;MAC7B,OAAOC,QAAQ,CAACK,wBAAwB,CAAC,CAAC;IAC5C,CAAC,MAAM;MACL,OAAO,IAAI;IACb;EACF,CAAC,EAAE,CAACvB,IAAI,EAAEiB,KAAK,CAAC,CAAC;EACjB,OAAOT,mBAAmB,CAACT,OAAO,EAAEC,IAAI,CAAC;AAC3C,CAAC"}
|
@@ -1,19 +1,18 @@
|
|
1
1
|
import { useEffect } from "react";
|
2
2
|
import { useAnimatedImage } from "../../skia/core/AnimatedImage";
|
3
|
-
import
|
3
|
+
import Rea from "./ReanimatedProxy";
|
4
4
|
const DEFAULT_FRAME_DURATION = 60;
|
5
5
|
export const useAnimatedImageValue = (source, paused) => {
|
6
|
-
|
7
|
-
const defaultPaused = useSharedValue(false);
|
6
|
+
const defaultPaused = Rea.useSharedValue(false);
|
8
7
|
const isPaused = paused !== null && paused !== void 0 ? paused : defaultPaused;
|
9
|
-
const currentFrame = useSharedValue(null);
|
10
|
-
const lastTimestamp = useSharedValue(-1);
|
8
|
+
const currentFrame = Rea.useSharedValue(null);
|
9
|
+
const lastTimestamp = Rea.useSharedValue(-1);
|
11
10
|
const animatedImage = useAnimatedImage(source, err => {
|
12
11
|
console.error(err);
|
13
12
|
throw new Error(`Could not load animated image - got '${err.message}'`);
|
14
13
|
}, false);
|
15
14
|
const frameDuration = (animatedImage === null || animatedImage === void 0 ? void 0 : animatedImage.currentFrameDuration()) || DEFAULT_FRAME_DURATION;
|
16
|
-
useFrameCallback(frameInfo => {
|
15
|
+
Rea.useFrameCallback(frameInfo => {
|
17
16
|
if (!animatedImage) {
|
18
17
|
currentFrame.value = null;
|
19
18
|
return;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["useEffect","useAnimatedImage","
|
1
|
+
{"version":3,"names":["useEffect","useAnimatedImage","Rea","DEFAULT_FRAME_DURATION","useAnimatedImageValue","source","paused","defaultPaused","useSharedValue","isPaused","currentFrame","lastTimestamp","animatedImage","err","console","error","Error","message","frameDuration","currentFrameDuration","useFrameCallback","frameInfo","value","timestamp","elapsed","decodeNextFrame","dispose","getCurrentFrame"],"sources":["useAnimatedImageValue.ts"],"sourcesContent":["import { useEffect } from \"react\";\nimport { type FrameInfo, type SharedValue } from \"react-native-reanimated\";\n\nimport { useAnimatedImage } from \"../../skia/core/AnimatedImage\";\nimport type { DataSourceParam, SkImage } from \"../../skia/types\";\n\nimport Rea from \"./ReanimatedProxy\";\n\nconst DEFAULT_FRAME_DURATION = 60;\n\nexport const useAnimatedImageValue = (\n source: DataSourceParam,\n paused?: SharedValue<boolean>\n) => {\n const defaultPaused = Rea.useSharedValue(false);\n const isPaused = paused ?? defaultPaused;\n const currentFrame = Rea.useSharedValue<null | SkImage>(null);\n const lastTimestamp = Rea.useSharedValue(-1);\n const animatedImage = useAnimatedImage(\n source,\n (err) => {\n console.error(err);\n throw new Error(`Could not load animated image - got '${err.message}'`);\n },\n false\n );\n const frameDuration =\n animatedImage?.currentFrameDuration() || DEFAULT_FRAME_DURATION;\n\n Rea.useFrameCallback((frameInfo: FrameInfo) => {\n if (!animatedImage) {\n currentFrame.value = null;\n return;\n }\n if (isPaused.value && lastTimestamp.value !== -1) {\n return;\n }\n const { timestamp } = frameInfo;\n const elapsed = timestamp - lastTimestamp.value;\n\n // Check if it's time to switch frames based on GIF frame duration\n if (elapsed < frameDuration) {\n return;\n }\n\n // Update the current frame\n animatedImage.decodeNextFrame();\n if (currentFrame.value) {\n currentFrame.value.dispose();\n }\n currentFrame.value = animatedImage.getCurrentFrame();\n\n // Update the last timestamp\n lastTimestamp.value = timestamp;\n });\n useEffect(() => {\n return () => {\n animatedImage?.dispose();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n return currentFrame;\n};\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,OAAO;AAGjC,SAASC,gBAAgB,QAAQ,+BAA+B;AAGhE,OAAOC,GAAG,MAAM,mBAAmB;AAEnC,MAAMC,sBAAsB,GAAG,EAAE;AAEjC,OAAO,MAAMC,qBAAqB,GAAGA,CACnCC,MAAuB,EACvBC,MAA6B,KAC1B;EACH,MAAMC,aAAa,GAAGL,GAAG,CAACM,cAAc,CAAC,KAAK,CAAC;EAC/C,MAAMC,QAAQ,GAAGH,MAAM,aAANA,MAAM,cAANA,MAAM,GAAIC,aAAa;EACxC,MAAMG,YAAY,GAAGR,GAAG,CAACM,cAAc,CAAiB,IAAI,CAAC;EAC7D,MAAMG,aAAa,GAAGT,GAAG,CAACM,cAAc,CAAC,CAAC,CAAC,CAAC;EAC5C,MAAMI,aAAa,GAAGX,gBAAgB,CACpCI,MAAM,EACLQ,GAAG,IAAK;IACPC,OAAO,CAACC,KAAK,CAACF,GAAG,CAAC;IAClB,MAAM,IAAIG,KAAK,CAAE,wCAAuCH,GAAG,CAACI,OAAQ,GAAE,CAAC;EACzE,CAAC,EACD,KACF,CAAC;EACD,MAAMC,aAAa,GACjB,CAAAN,aAAa,aAAbA,aAAa,uBAAbA,aAAa,CAAEO,oBAAoB,CAAC,CAAC,KAAIhB,sBAAsB;EAEjED,GAAG,CAACkB,gBAAgB,CAAEC,SAAoB,IAAK;IAC7C,IAAI,CAACT,aAAa,EAAE;MAClBF,YAAY,CAACY,KAAK,GAAG,IAAI;MACzB;IACF;IACA,IAAIb,QAAQ,CAACa,KAAK,IAAIX,aAAa,CAACW,KAAK,KAAK,CAAC,CAAC,EAAE;MAChD;IACF;IACA,MAAM;MAAEC;IAAU,CAAC,GAAGF,SAAS;IAC/B,MAAMG,OAAO,GAAGD,SAAS,GAAGZ,aAAa,CAACW,KAAK;;IAE/C;IACA,IAAIE,OAAO,GAAGN,aAAa,EAAE;MAC3B;IACF;;IAEA;IACAN,aAAa,CAACa,eAAe,CAAC,CAAC;IAC/B,IAAIf,YAAY,CAACY,KAAK,EAAE;MACtBZ,YAAY,CAACY,KAAK,CAACI,OAAO,CAAC,CAAC;IAC9B;IACAhB,YAAY,CAACY,KAAK,GAAGV,aAAa,CAACe,eAAe,CAAC,CAAC;;IAEpD;IACAhB,aAAa,CAACW,KAAK,GAAGC,SAAS;EACjC,CAAC,CAAC;EACFvB,SAAS,CAAC,MAAM;IACd,OAAO,MAAM;MACXY,aAAa,aAAbA,aAAa,eAAbA,aAAa,CAAEc,OAAO,CAAC,CAAC;IAC1B,CAAC;IACD;EACF,CAAC,EAAE,EAAE,CAAC;EACN,OAAOhB,YAAY;AACrB,CAAC"}
|
@@ -1,15 +1,15 @@
|
|
1
1
|
import { useEffect, useMemo } from "react";
|
2
|
-
import
|
2
|
+
import Rea from "./ReanimatedProxy";
|
3
3
|
export const useDerivedValueOnJS = (fn, deps) => {
|
4
4
|
const init = useMemo(() => fn(), [fn]);
|
5
|
-
const value = useSharedValue(init);
|
5
|
+
const value = Rea.useSharedValue(init);
|
6
6
|
useEffect(() => {
|
7
|
-
const mapperId = startMapper(() => {
|
7
|
+
const mapperId = Rea.startMapper(() => {
|
8
8
|
"worklet";
|
9
9
|
|
10
|
-
runOnJS(fn)();
|
10
|
+
Rea.runOnJS(fn)();
|
11
11
|
}, deps);
|
12
|
-
return () => stopMapper(mapperId);
|
12
|
+
return () => Rea.stopMapper(mapperId);
|
13
13
|
}, [deps, fn]);
|
14
14
|
return value;
|
15
15
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["useEffect","useMemo","
|
1
|
+
{"version":3,"names":["useEffect","useMemo","Rea","useDerivedValueOnJS","fn","deps","init","value","useSharedValue","mapperId","startMapper","runOnJS","stopMapper"],"sources":["useDerivedValueOnJS.ts"],"sourcesContent":["import { useEffect, useMemo } from \"react\";\n\nimport Rea from \"./ReanimatedProxy\";\n\nexport const useDerivedValueOnJS = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n fn: () => any,\n deps: unknown[]\n) => {\n const init = useMemo(() => fn(), [fn]);\n const value = Rea.useSharedValue(init);\n useEffect(() => {\n const mapperId = Rea.startMapper(() => {\n \"worklet\";\n Rea.runOnJS(fn)();\n }, deps);\n return () => Rea.stopMapper(mapperId);\n }, [deps, fn]);\n return value;\n};\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,OAAO,QAAQ,OAAO;AAE1C,OAAOC,GAAG,MAAM,mBAAmB;AAEnC,OAAO,MAAMC,mBAAmB,GAAGA,CAEjCC,EAAa,EACbC,IAAe,KACZ;EACH,MAAMC,IAAI,GAAGL,OAAO,CAAC,MAAMG,EAAE,CAAC,CAAC,EAAE,CAACA,EAAE,CAAC,CAAC;EACtC,MAAMG,KAAK,GAAGL,GAAG,CAACM,cAAc,CAACF,IAAI,CAAC;EACtCN,SAAS,CAAC,MAAM;IACd,MAAMS,QAAQ,GAAGP,GAAG,CAACQ,WAAW,CAAC,MAAM;MACrC,SAAS;;MACTR,GAAG,CAACS,OAAO,CAACP,EAAE,CAAC,CAAC,CAAC;IACnB,CAAC,EAAEC,IAAI,CAAC;IACR,OAAO,MAAMH,GAAG,CAACU,UAAU,CAACH,QAAQ,CAAC;EACvC,CAAC,EAAE,CAACJ,IAAI,EAAED,EAAE,CAAC,CAAC;EACd,OAAOG,KAAK;AACd,CAAC"}
|
@@ -23,15 +23,11 @@ export const drawAsPicture = (element, bounds) => {
|
|
23
23
|
export const drawAsImage = (element, size) => {
|
24
24
|
return drawAsImageFromPicture(drawAsPicture(element), size);
|
25
25
|
};
|
26
|
-
|
27
|
-
// TODO: We're not sure yet why PixelRatio is not needed here.
|
28
|
-
const pd = 1;
|
29
26
|
export const drawAsImageFromPicture = (picture, size) => {
|
30
27
|
"worklet";
|
31
28
|
|
32
|
-
const surface = Skia.Surface.MakeOffscreen(size.width
|
29
|
+
const surface = Skia.Surface.MakeOffscreen(size.width, size.height);
|
33
30
|
const canvas = surface.getCanvas();
|
34
|
-
canvas.scale(pd, pd);
|
35
31
|
canvas.drawPicture(picture);
|
36
32
|
surface.flush();
|
37
33
|
const image = surface.makeImageSnapshot();
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["JsiDrawingContext","Skia","Platform","SkiaRoot","isOnMainThread","_WORKLET","OS","drawAsPicture","element","bounds","recorder","PictureRecorder","canvas","beginRecording","root","render","ctx","dom","picture","finishRecordingAsPicture","unmount","drawAsImage","size","drawAsImageFromPicture","
|
1
|
+
{"version":3,"names":["JsiDrawingContext","Skia","Platform","SkiaRoot","isOnMainThread","_WORKLET","OS","drawAsPicture","element","bounds","recorder","PictureRecorder","canvas","beginRecording","root","render","ctx","dom","picture","finishRecordingAsPicture","unmount","drawAsImage","size","drawAsImageFromPicture","surface","Surface","MakeOffscreen","width","height","getCanvas","drawPicture","flush","image","makeImageSnapshot","makeNonTextureImage"],"sources":["Offscreen.tsx"],"sourcesContent":["import type { ReactElement } from \"react\";\n\nimport { JsiDrawingContext } from \"../dom/types\";\nimport type { SkPicture, SkRect, SkSize } from \"../skia/types\";\nimport { Skia } from \"../skia\";\nimport { Platform } from \"../Platform\";\n\nimport { SkiaRoot } from \"./Reconciler\";\n\n// We call it main thread because on web main is JS thread\nexport const isOnMainThread = () => {\n \"worklet\";\n return (\n (typeof _WORKLET !== \"undefined\" && _WORKLET === true) ||\n Platform.OS === \"web\"\n );\n};\n\nexport const drawAsPicture = (element: ReactElement, bounds?: SkRect) => {\n const recorder = Skia.PictureRecorder();\n const canvas = recorder.beginRecording(bounds);\n const root = new SkiaRoot(Skia, false);\n root.render(element);\n const ctx = new JsiDrawingContext(Skia, canvas);\n root.dom.render(ctx);\n const picture = recorder.finishRecordingAsPicture();\n root.unmount();\n return picture;\n};\n\nexport const drawAsImage = (element: ReactElement, size: SkSize) => {\n return drawAsImageFromPicture(drawAsPicture(element), size);\n};\n\nexport const drawAsImageFromPicture = (picture: SkPicture, size: SkSize) => {\n \"worklet\";\n const surface = Skia.Surface.MakeOffscreen(size.width, size.height)!;\n const canvas = surface.getCanvas();\n canvas.drawPicture(picture);\n surface.flush();\n const image = surface.makeImageSnapshot();\n // If we are not on the main thread or if we are on Web, we need to make the image non-texture.\n if (!isOnMainThread() || Platform.OS === \"web\") {\n return image.makeNonTextureImage();\n } else {\n return image;\n }\n};\n"],"mappings":"AAEA,SAASA,iBAAiB,QAAQ,cAAc;AAEhD,SAASC,IAAI,QAAQ,SAAS;AAC9B,SAASC,QAAQ,QAAQ,aAAa;AAEtC,SAASC,QAAQ,QAAQ,cAAc;;AAEvC;AACA,OAAO,MAAMC,cAAc,GAAGA,CAAA,KAAM;EAClC,SAAS;;EACT,OACG,OAAOC,QAAQ,KAAK,WAAW,IAAIA,QAAQ,KAAK,IAAI,IACrDH,QAAQ,CAACI,EAAE,KAAK,KAAK;AAEzB,CAAC;AAED,OAAO,MAAMC,aAAa,GAA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,OAAOF,KAAK;EACd;AACF,CAAC"}
|
@@ -8,7 +8,7 @@ export declare const isNativeBufferWeb: (buffer: NativeBuffer) => buffer is Canv
|
|
8
8
|
export declare const isNativeBufferNode: (buffer: NativeBuffer) => buffer is ArrayBuffer;
|
9
9
|
export interface NativeBufferFactory {
|
10
10
|
/**
|
11
|
-
* Copy pixels to a
|
11
|
+
* Copy pixels to a native buffer.
|
12
12
|
*/
|
13
13
|
MakeFromImage: (image: SkImage) => NativeBuffer;
|
14
14
|
/**
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["isNativeBufferAddr","buffer","BigInt","isNativeBufferWeb","HTMLVideoElement","HTMLCanvasElement","ImageBitmap","OffscreenCanvas","VideoFrame","HTMLImageElement","SVGImageElement","isNativeBufferNode","ArrayBuffer"],"sources":["NativeBufferFactory.ts"],"sourcesContent":["import type { SkImage } from \"../Image\";\n\nexport type NativeBuffer<\n T extends bigint | ArrayBuffer | CanvasImageSource | unknown = unknown\n> = T;\n\nexport type NativeBufferAddr = NativeBuffer<bigint>;\nexport type NativeBufferWeb = NativeBuffer<CanvasImageSource>;\nexport type NativeBufferNode = NativeBuffer<ArrayBuffer>;\n\nexport const isNativeBufferAddr = (\n buffer: NativeBuffer\n): buffer is NativeBufferAddr => buffer instanceof BigInt;\nexport const isNativeBufferWeb = (\n buffer: NativeBuffer\n): buffer is NativeBufferWeb =>\n buffer instanceof HTMLVideoElement ||\n buffer instanceof HTMLCanvasElement ||\n buffer instanceof ImageBitmap ||\n buffer instanceof OffscreenCanvas ||\n buffer instanceof VideoFrame ||\n buffer instanceof HTMLImageElement ||\n buffer instanceof SVGImageElement;\n\nexport const isNativeBufferNode = (\n buffer: NativeBuffer\n): buffer is NativeBufferNode => buffer instanceof ArrayBuffer;\n\nexport interface NativeBufferFactory {\n /**\n * Copy pixels to a
|
1
|
+
{"version":3,"names":["isNativeBufferAddr","buffer","BigInt","isNativeBufferWeb","HTMLVideoElement","HTMLCanvasElement","ImageBitmap","OffscreenCanvas","VideoFrame","HTMLImageElement","SVGImageElement","isNativeBufferNode","ArrayBuffer"],"sources":["NativeBufferFactory.ts"],"sourcesContent":["import type { SkImage } from \"../Image\";\n\nexport type NativeBuffer<\n T extends bigint | ArrayBuffer | CanvasImageSource | unknown = unknown\n> = T;\n\nexport type NativeBufferAddr = NativeBuffer<bigint>;\nexport type NativeBufferWeb = NativeBuffer<CanvasImageSource>;\nexport type NativeBufferNode = NativeBuffer<ArrayBuffer>;\n\nexport const isNativeBufferAddr = (\n buffer: NativeBuffer\n): buffer is NativeBufferAddr => buffer instanceof BigInt;\nexport const isNativeBufferWeb = (\n buffer: NativeBuffer\n): buffer is NativeBufferWeb =>\n buffer instanceof HTMLVideoElement ||\n buffer instanceof HTMLCanvasElement ||\n buffer instanceof ImageBitmap ||\n buffer instanceof OffscreenCanvas ||\n buffer instanceof VideoFrame ||\n buffer instanceof HTMLImageElement ||\n buffer instanceof SVGImageElement;\n\nexport const isNativeBufferNode = (\n buffer: NativeBuffer\n): buffer is NativeBufferNode => buffer instanceof ArrayBuffer;\n\nexport interface NativeBufferFactory {\n /**\n * Copy pixels to a native buffer.\n */\n MakeFromImage: (image: SkImage) => NativeBuffer;\n /**\n * Release a platform buffer that was created with `MakeFromImage`.\n */\n Release: (platformBuffer: NativeBuffer) => void;\n}\n"],"mappings":"AAUA,OAAO,MAAMA,kBAAkB,GAC7BC,MAAoB,IACWA,MAAM,YAAYC,MAAM;AACzD,OAAO,MAAMC,iBAAiB,GAC5BF,MAAoB,IAEpBA,MAAM,YAAYG,gBAAgB,IAClCH,MAAM,YAAYI,iBAAiB,IACnCJ,MAAM,YAAYK,WAAW,IAC7BL,MAAM,YAAYM,eAAe,IACjCN,MAAM,YAAYO,UAAU,IAC5BP,MAAM,YAAYQ,gBAAgB,IAClCR,MAAM,YAAYS,eAAe;AAEnC,OAAO,MAAMC,kBAAkB,GAC7BV,MAAoB,IACWA,MAAM,YAAYW,WAAW"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":[
|
1
|
+
{"version":3,"names":[],"sources":["NativeSkiaModule.web.ts"],"sourcesContent":[""],"mappings":""}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
type ImportType = ReturnType<typeof require>;
|
2
|
+
/**
|
3
|
+
* Create a lazily-imported module proxy.
|
4
|
+
* This is useful for lazily requiring optional dependencies.
|
5
|
+
*/
|
6
|
+
export declare const createModuleProxy: <TModule>(getModule: () => ImportType) => TModule;
|
7
|
+
export declare class OptionalDependencyNotInstalledError extends Error {
|
8
|
+
constructor(name: string);
|
9
|
+
}
|
10
|
+
export {};
|
@@ -8,7 +8,7 @@ export declare const isNativeBufferWeb: (buffer: NativeBuffer) => buffer is Canv
|
|
8
8
|
export declare const isNativeBufferNode: (buffer: NativeBuffer) => buffer is ArrayBuffer;
|
9
9
|
export interface NativeBufferFactory {
|
10
10
|
/**
|
11
|
-
* Copy pixels to a
|
11
|
+
* Copy pixels to a native buffer.
|
12
12
|
*/
|
13
13
|
MakeFromImage: (image: SkImage) => NativeBuffer;
|
14
14
|
/**
|
@@ -6,32 +6,32 @@
|
|
6
6
|
<array>
|
7
7
|
<dict>
|
8
8
|
<key>LibraryIdentifier</key>
|
9
|
-
<string>ios-
|
9
|
+
<string>ios-arm64_arm64e_x86_64-simulator</string>
|
10
10
|
<key>LibraryPath</key>
|
11
11
|
<string>libskia.a</string>
|
12
12
|
<key>SupportedArchitectures</key>
|
13
13
|
<array>
|
14
14
|
<string>arm64</string>
|
15
15
|
<string>arm64e</string>
|
16
|
+
<string>x86_64</string>
|
16
17
|
</array>
|
17
18
|
<key>SupportedPlatform</key>
|
18
19
|
<string>ios</string>
|
20
|
+
<key>SupportedPlatformVariant</key>
|
21
|
+
<string>simulator</string>
|
19
22
|
</dict>
|
20
23
|
<dict>
|
21
24
|
<key>LibraryIdentifier</key>
|
22
|
-
<string>ios-
|
25
|
+
<string>ios-arm64_arm64e</string>
|
23
26
|
<key>LibraryPath</key>
|
24
27
|
<string>libskia.a</string>
|
25
28
|
<key>SupportedArchitectures</key>
|
26
29
|
<array>
|
27
30
|
<string>arm64</string>
|
28
31
|
<string>arm64e</string>
|
29
|
-
<string>x86_64</string>
|
30
32
|
</array>
|
31
33
|
<key>SupportedPlatform</key>
|
32
34
|
<string>ios</string>
|
33
|
-
<key>SupportedPlatformVariant</key>
|
34
|
-
<string>simulator</string>
|
35
35
|
</dict>
|
36
36
|
</array>
|
37
37
|
<key>CFBundlePackageType</key>
|
Binary file
|
Binary file
|
@@ -6,32 +6,32 @@
|
|
6
6
|
<array>
|
7
7
|
<dict>
|
8
8
|
<key>LibraryIdentifier</key>
|
9
|
-
<string>ios-
|
9
|
+
<string>ios-arm64_arm64e</string>
|
10
10
|
<key>LibraryPath</key>
|
11
11
|
<string>libskottie.a</string>
|
12
12
|
<key>SupportedArchitectures</key>
|
13
13
|
<array>
|
14
14
|
<string>arm64</string>
|
15
15
|
<string>arm64e</string>
|
16
|
-
<string>x86_64</string>
|
17
16
|
</array>
|
18
17
|
<key>SupportedPlatform</key>
|
19
18
|
<string>ios</string>
|
20
|
-
<key>SupportedPlatformVariant</key>
|
21
|
-
<string>simulator</string>
|
22
19
|
</dict>
|
23
20
|
<dict>
|
24
21
|
<key>LibraryIdentifier</key>
|
25
|
-
<string>ios-
|
22
|
+
<string>ios-arm64_arm64e_x86_64-simulator</string>
|
26
23
|
<key>LibraryPath</key>
|
27
24
|
<string>libskottie.a</string>
|
28
25
|
<key>SupportedArchitectures</key>
|
29
26
|
<array>
|
30
27
|
<string>arm64</string>
|
31
28
|
<string>arm64e</string>
|
29
|
+
<string>x86_64</string>
|
32
30
|
</array>
|
33
31
|
<key>SupportedPlatform</key>
|
34
32
|
<string>ios</string>
|
33
|
+
<key>SupportedPlatformVariant</key>
|
34
|
+
<string>simulator</string>
|
35
35
|
</dict>
|
36
36
|
</array>
|
37
37
|
<key>CFBundlePackageType</key>
|
Binary file
|
Binary file
|
Binary file
|
package/libs/ios/libskparagraph.xcframework/ios-arm64_arm64e_x86_64-simulator/libskparagraph.a
CHANGED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
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": "1.2.
|
10
|
+
"version": "1.2.2",
|
11
11
|
"description": "High-performance React Native Graphics using Skia",
|
12
12
|
"main": "lib/module/index.js",
|
13
13
|
"react-native": "src/index.ts",
|
@@ -0,0 +1,30 @@
|
|
1
|
+
// https://github.com/mrousavy/react-native-vision-camera/blob/main/package/src/dependencies/ModuleProxy.ts
|
2
|
+
type ImportType = ReturnType<typeof require>;
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Create a lazily-imported module proxy.
|
6
|
+
* This is useful for lazily requiring optional dependencies.
|
7
|
+
*/
|
8
|
+
export const createModuleProxy = <TModule>(
|
9
|
+
getModule: () => ImportType
|
10
|
+
): TModule => {
|
11
|
+
const holder: { module: TModule | undefined } = { module: undefined };
|
12
|
+
|
13
|
+
const proxy = new Proxy(holder, {
|
14
|
+
get: (target, property) => {
|
15
|
+
if (target.module == null) {
|
16
|
+
// lazy initialize module via require()
|
17
|
+
// caller needs to make sure the require() call is wrapped in a try/catch
|
18
|
+
target.module = getModule() as TModule;
|
19
|
+
}
|
20
|
+
return target.module[property as keyof typeof holder.module];
|
21
|
+
},
|
22
|
+
});
|
23
|
+
return proxy as unknown as TModule;
|
24
|
+
};
|
25
|
+
|
26
|
+
export class OptionalDependencyNotInstalledError extends Error {
|
27
|
+
constructor(name: string) {
|
28
|
+
super(`${name} is not installed!`);
|
29
|
+
}
|
30
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import type * as ReanimatedT from "react-native-reanimated";
|
2
|
+
|
3
|
+
import {
|
4
|
+
OptionalDependencyNotInstalledError,
|
5
|
+
createModuleProxy,
|
6
|
+
} from "../ModuleProxy";
|
7
|
+
type TReanimated = typeof ReanimatedT;
|
8
|
+
|
9
|
+
const Reanimated = createModuleProxy<TReanimated>(() => {
|
10
|
+
try {
|
11
|
+
return require("react-native-reanimated");
|
12
|
+
} catch (e) {
|
13
|
+
throw new OptionalDependencyNotInstalledError("react-native-reanimated");
|
14
|
+
}
|
15
|
+
});
|
16
|
+
|
17
|
+
// eslint-disable-next-line import/no-default-export
|
18
|
+
export default Reanimated;
|
@@ -4,17 +4,18 @@ import type { WorkletFunction } from "react-native-reanimated/lib/typescript/rea
|
|
4
4
|
import type { SkColor, SkHostRect, SkPoint, SkRSXform } from "../../skia/types";
|
5
5
|
import { Skia } from "../../skia";
|
6
6
|
|
7
|
-
import { startMapper, stopMapper, makeMutable } from "./moduleWrapper";
|
8
7
|
import { notifyChange } from "./interpolators";
|
8
|
+
import Rea from "./ReanimatedProxy";
|
9
9
|
|
10
10
|
type Modifier<T> = (input: T, index: number) => void;
|
11
11
|
|
12
|
-
const useBufferValue = <T>(size: number, bufferInitializer: () => T) =>
|
13
|
-
useMemo(
|
14
|
-
() => makeMutable(new Array(size).fill(0).map(bufferInitializer)),
|
12
|
+
const useBufferValue = <T>(size: number, bufferInitializer: () => T) => {
|
13
|
+
return useMemo(
|
14
|
+
() => Rea.makeMutable(new Array(size).fill(0).map(bufferInitializer)),
|
15
15
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
16
16
|
[size]
|
17
17
|
);
|
18
|
+
};
|
18
19
|
|
19
20
|
const useBuffer = <T>(
|
20
21
|
size: number,
|
@@ -24,7 +25,7 @@ const useBuffer = <T>(
|
|
24
25
|
const values = useBufferValue(size, bufferInitializer);
|
25
26
|
const mod = modifier as WorkletFunction;
|
26
27
|
const deps = [size, ...Object.values(mod.__closure ?? {})];
|
27
|
-
const mapperId = startMapper(() => {
|
28
|
+
const mapperId = Rea.startMapper(() => {
|
28
29
|
"worklet";
|
29
30
|
values.value.forEach((val, index) => {
|
30
31
|
modifier(val, index);
|
@@ -34,7 +35,7 @@ const useBuffer = <T>(
|
|
34
35
|
|
35
36
|
useEffect(() => {
|
36
37
|
return () => {
|
37
|
-
stopMapper(mapperId);
|
38
|
+
Rea.stopMapper(mapperId);
|
38
39
|
};
|
39
40
|
}, [mapperId]);
|
40
41
|
|