@shopify/react-native-skia 0.1.139 → 0.1.142
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/CMakeLists.txt +5 -1
- package/android/build.gradle +3 -1
- package/android/cpp/rnskia-android/RNSkDrawViewImpl.cpp +2 -2
- package/android/cpp/rnskia-android/RNSkDrawViewImpl.h +1 -1
- package/android/cpp/rnskia-android/SkiaOpenGLRenderer.cpp +15 -16
- package/android/cpp/rnskia-android/SkiaOpenGLRenderer.h +2 -2
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaDrawView.java +69 -27
- package/cpp/rnskia/RNSkDrawView.cpp +66 -66
- package/cpp/rnskia/RNSkDrawView.h +22 -6
- package/cpp/rnskia/RNSkJsiViewApi.h +2 -2
- package/cpp/rnskia/values/RNSkComputedValue.h +10 -7
- package/cpp/rnskia/values/RNSkReadonlyValue.h +21 -2
- package/cpp/rnskia/values/RNSkValue.h +1 -0
- package/ios/RNSkia-iOS/RNSkDrawViewImpl.h +1 -1
- package/ios/RNSkia-iOS/RNSkDrawViewImpl.mm +2 -2
- package/ios/RNSkia-iOS/SkiaDrawView.mm +4 -0
- package/lib/commonjs/mock/index.js +3 -1
- package/lib/commonjs/mock/index.js.map +1 -1
- package/lib/commonjs/renderer/DependencyManager.js +1 -1
- package/lib/commonjs/renderer/DependencyManager.js.map +1 -1
- package/lib/commonjs/renderer/processors/Animations/Animations.js +18 -5
- package/lib/commonjs/renderer/processors/Animations/Animations.js.map +1 -1
- package/lib/commonjs/skia/core/Data.js +10 -22
- package/lib/commonjs/skia/core/Data.js.map +1 -1
- package/lib/commonjs/skia/core/Font.js +2 -3
- package/lib/commonjs/skia/core/Font.js.map +1 -1
- package/lib/commonjs/skia/core/Image.js.map +1 -1
- package/lib/commonjs/skia/core/SVG.js.map +1 -1
- package/lib/commonjs/skia/core/Typeface.js.map +1 -1
- package/lib/commonjs/skia/types/Data/Data.js +5 -0
- package/lib/commonjs/skia/types/Data/Data.js.map +1 -1
- package/lib/commonjs/skia/types/Image/ImageFactory.js +0 -2
- package/lib/commonjs/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/commonjs/skia/types/Path/Path.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkCanvas.js +9 -7
- package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPath.js +7 -5
- package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkRRect.js +8 -0
- package/lib/commonjs/skia/web/JsiSkRRect.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkRect.js +2 -2
- package/lib/commonjs/skia/web/JsiSkRect.js.map +1 -1
- package/lib/commonjs/values/hooks/useComputedValue.js +6 -2
- package/lib/commonjs/values/hooks/useComputedValue.js.map +1 -1
- package/lib/commonjs/values/index.js +13 -0
- package/lib/commonjs/values/index.js.map +1 -1
- package/lib/commonjs/values/selector.js +24 -0
- package/lib/commonjs/values/selector.js.map +1 -0
- package/lib/commonjs/values/web/RNSkComputedValue.js +8 -0
- package/lib/commonjs/values/web/RNSkComputedValue.js.map +1 -1
- package/lib/commonjs/values/web/RNSkReadonlyValue.js +4 -0
- package/lib/commonjs/values/web/RNSkReadonlyValue.js.map +1 -1
- package/lib/commonjs/views/useTouchHandler.js +13 -15
- package/lib/commonjs/views/useTouchHandler.js.map +1 -1
- package/lib/module/mock/index.js +2 -1
- package/lib/module/mock/index.js.map +1 -1
- package/lib/module/renderer/DependencyManager.js +2 -2
- package/lib/module/renderer/DependencyManager.js.map +1 -1
- package/lib/module/renderer/processors/Animations/Animations.js +13 -4
- package/lib/module/renderer/processors/Animations/Animations.js.map +1 -1
- package/lib/module/skia/core/Data.js +10 -20
- package/lib/module/skia/core/Data.js.map +1 -1
- package/lib/module/skia/core/Font.js +2 -3
- package/lib/module/skia/core/Font.js.map +1 -1
- package/lib/module/skia/core/Image.js.map +1 -1
- package/lib/module/skia/core/SVG.js.map +1 -1
- package/lib/module/skia/core/Typeface.js.map +1 -1
- package/lib/module/skia/types/Data/Data.js +1 -1
- package/lib/module/skia/types/Data/Data.js.map +1 -1
- package/lib/module/skia/types/Image/ImageFactory.js +0 -1
- package/lib/module/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/module/skia/types/Path/Path.js.map +1 -1
- package/lib/module/skia/web/JsiSkCanvas.js +8 -7
- package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/module/skia/web/JsiSkPath.js +6 -5
- package/lib/module/skia/web/JsiSkPath.js.map +1 -1
- package/lib/module/skia/web/JsiSkRRect.js +8 -0
- package/lib/module/skia/web/JsiSkRRect.js.map +1 -1
- package/lib/module/skia/web/JsiSkRect.js +2 -2
- package/lib/module/skia/web/JsiSkRect.js.map +1 -1
- package/lib/module/values/hooks/useComputedValue.js +7 -3
- package/lib/module/values/hooks/useComputedValue.js.map +1 -1
- package/lib/module/values/index.js +1 -0
- package/lib/module/values/index.js.map +1 -1
- package/lib/module/values/selector.js +15 -0
- package/lib/module/values/selector.js.map +1 -0
- package/lib/module/values/web/RNSkComputedValue.js +8 -0
- package/lib/module/values/web/RNSkComputedValue.js.map +1 -1
- package/lib/module/values/web/RNSkReadonlyValue.js +4 -0
- package/lib/module/values/web/RNSkReadonlyValue.js.map +1 -1
- package/lib/module/views/useTouchHandler.js +12 -14
- package/lib/module/views/useTouchHandler.js.map +1 -1
- package/lib/typescript/src/renderer/processors/Animations/Animations.d.ts +7 -2
- package/lib/typescript/src/skia/core/Data.d.ts +3 -5
- package/lib/typescript/src/skia/core/Font.d.ts +2 -2
- package/lib/typescript/src/skia/core/Image.d.ts +2 -2
- package/lib/typescript/src/skia/core/SVG.d.ts +2 -2
- package/lib/typescript/src/skia/core/Typeface.d.ts +2 -2
- package/lib/typescript/src/skia/types/Data/Data.d.ts +10 -3
- package/lib/typescript/src/skia/web/JsiSkRRect.d.ts +1 -0
- package/lib/typescript/src/skia/web/JsiSkRect.d.ts +1 -1
- package/lib/typescript/src/values/index.d.ts +1 -0
- package/lib/typescript/src/values/selector.d.ts +14 -0
- package/lib/typescript/src/values/types.d.ts +4 -0
- package/lib/typescript/src/values/web/RNSkComputedValue.d.ts +1 -0
- package/lib/typescript/src/values/web/RNSkReadonlyValue.d.ts +1 -0
- package/package.json +13 -8
- package/src/mock/index.ts +2 -1
- package/src/renderer/DependencyManager.tsx +5 -2
- package/src/renderer/processors/Animations/Animations.ts +27 -5
- package/src/skia/core/Data.ts +20 -51
- package/src/skia/core/Font.ts +4 -5
- package/src/skia/core/Image.ts +2 -2
- package/src/skia/core/SVG.ts +2 -2
- package/src/skia/core/Typeface.ts +2 -2
- package/src/skia/types/Data/Data.ts +11 -1
- package/src/skia/types/Image/ImageFactory.ts +0 -1
- package/src/skia/types/Path/Path.ts +0 -1
- package/src/skia/web/JsiSkCanvas.ts +22 -10
- package/src/skia/web/JsiSkPath.ts +14 -5
- package/src/skia/web/JsiSkRRect.ts +11 -0
- package/src/skia/web/JsiSkRect.ts +2 -5
- package/src/values/hooks/useComputedValue.ts +6 -3
- package/src/values/index.ts +1 -0
- package/src/values/selector.ts +24 -0
- package/src/values/types.ts +4 -0
- package/src/values/web/RNSkComputedValue.ts +6 -0
- package/src/values/web/RNSkReadonlyValue.ts +4 -0
- package/src/views/useTouchHandler.ts +15 -19
- package/android/README.md +0 -14
- package/cpp/skia/include/third_party/skcms/LICENSE +0 -29
- package/cpp/skia/include/third_party/vulkan/LICENSE +0 -29
- package/cpp/skia/readme.txt +0 -1
|
@@ -2,10 +2,10 @@ import { HostObject } from "./Host";
|
|
|
2
2
|
export class JsiSkRect extends HostObject {
|
|
3
3
|
static fromValue(CanvasKit, rect) {
|
|
4
4
|
if (rect instanceof JsiSkRect) {
|
|
5
|
-
return rect;
|
|
5
|
+
return rect.ref;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
return
|
|
8
|
+
return CanvasKit.XYWHRect(rect.x, rect.y, rect.width, rect.height);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
constructor(CanvasKit, ref) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["JsiSkRect.ts"],"names":["HostObject","JsiSkRect","fromValue","CanvasKit","rect","XYWHRect","x","y","width","height","constructor"
|
|
1
|
+
{"version":3,"sources":["JsiSkRect.ts"],"names":["HostObject","JsiSkRect","fromValue","CanvasKit","rect","ref","XYWHRect","x","y","width","height","constructor"],"mappings":"AAIA,SAASA,UAAT,QAA2B,QAA3B;AAEA,OAAO,MAAMC,SAAN,SAAwBD,UAAxB,CAAmE;AACxD,SAATE,SAAS,CAACC,SAAD,EAAuBC,IAAvB,EAAqC;AACnD,QAAIA,IAAI,YAAYH,SAApB,EAA+B;AAC7B,aAAOG,IAAI,CAACC,GAAZ;AACD;;AACD,WAAOF,SAAS,CAACG,QAAV,CAAmBF,IAAI,CAACG,CAAxB,EAA2BH,IAAI,CAACI,CAAhC,EAAmCJ,IAAI,CAACK,KAAxC,EAA+CL,IAAI,CAACM,MAApD,CAAP;AACD;;AAEDC,EAAAA,WAAW,CAACR,SAAD,EAAuBE,GAAvB,EAAkC;AAC3C,UAAMF,SAAN,EAAiBE,GAAjB,EAAsB,MAAtB;AACD;;AAEI,MAADE,CAAC,GAAG;AACN,WAAO,KAAKF,GAAL,CAAS,CAAT,CAAP;AACD;;AAEI,MAADG,CAAC,GAAG;AACN,WAAO,KAAKH,GAAL,CAAS,CAAT,CAAP;AACD;;AAEQ,MAALI,KAAK,GAAG;AACV,WAAO,KAAKJ,GAAL,CAAS,CAAT,IAAc,KAAKA,GAAL,CAAS,CAAT,CAArB;AACD;;AAES,MAANK,MAAM,GAAG;AACX,WAAO,KAAKL,GAAL,CAAS,CAAT,IAAc,KAAKA,GAAL,CAAS,CAAT,CAArB;AACD;;AA1BuE","sourcesContent":["import type { CanvasKit, Rect } from \"canvaskit-wasm\";\n\nimport type { SkRect } from \"../types\";\n\nimport { HostObject } from \"./Host\";\n\nexport class JsiSkRect extends HostObject<Rect, \"Rect\"> implements SkRect {\n static fromValue(CanvasKit: CanvasKit, rect: SkRect) {\n if (rect instanceof JsiSkRect) {\n return rect.ref;\n }\n return CanvasKit.XYWHRect(rect.x, rect.y, rect.width, rect.height);\n }\n\n constructor(CanvasKit: CanvasKit, ref: Rect) {\n super(CanvasKit, ref, \"Rect\");\n }\n\n get x() {\n return this.ref[0];\n }\n\n get y() {\n return this.ref[1];\n }\n\n get width() {\n return this.ref[2] - this.ref[0];\n }\n\n get height() {\n return this.ref[3] - this.ref[1];\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useMemo } from "react";
|
|
1
|
+
import { useEffect, useMemo } from "react";
|
|
2
2
|
import { ValueApi } from "../api";
|
|
3
3
|
import { isValue } from "../../renderer/processors/Animations";
|
|
4
4
|
/**
|
|
@@ -9,6 +9,10 @@ import { isValue } from "../../renderer/processors/Animations";
|
|
|
9
9
|
* @returns A readonly value
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
export const useComputedValue = (cb, values) =>
|
|
13
|
-
values)
|
|
12
|
+
export const useComputedValue = (cb, values) => {
|
|
13
|
+
const value = useMemo(() => ValueApi.createComputedValue(cb, values.filter(isValue)), // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
14
|
+
values);
|
|
15
|
+
useEffect(() => () => value.__invalidate(), [value]);
|
|
16
|
+
return value;
|
|
17
|
+
};
|
|
14
18
|
//# sourceMappingURL=useComputedValue.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useComputedValue.ts"],"names":["useMemo","ValueApi","isValue","useComputedValue","cb","values","createComputedValue","filter"],"mappings":"AAAA,SAASA,
|
|
1
|
+
{"version":3,"sources":["useComputedValue.ts"],"names":["useEffect","useMemo","ValueApi","isValue","useComputedValue","cb","values","value","createComputedValue","filter","__invalidate"],"mappings":"AAAA,SAASA,SAAT,EAAoBC,OAApB,QAAmC,OAAnC;AAEA,SAASC,QAAT,QAAyB,QAAzB;AACA,SAASC,OAAT,QAAwB,sCAAxB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,gBAAgB,GAAG,CAAIC,EAAJ,EAAiBC,MAAjB,KAAuC;AACrE,QAAMC,KAAK,GAAGN,OAAO,CACnB,MAAMC,QAAQ,CAACM,mBAAT,CAAgCH,EAAhC,EAAoCC,MAAM,CAACG,MAAP,CAAcN,OAAd,CAApC,CADa,EAEnB;AACAG,EAAAA,MAHmB,CAArB;AAKAN,EAAAA,SAAS,CAAC,MAAM,MAAMO,KAAK,CAACG,YAAN,EAAb,EAAmC,CAACH,KAAD,CAAnC,CAAT;AACA,SAAOA,KAAP;AACD,CARM","sourcesContent":["import { useEffect, useMemo } from \"react\";\n\nimport { ValueApi } from \"../api\";\nimport { isValue } from \"../../renderer/processors/Animations\";\n\n/**\n * Creates a new computed value - a value that will calculate its value depending\n * on other values.\n * @param cb Callback to calculate new value\n * @param values Dependant values\n * @returns A readonly value\n */\nexport const useComputedValue = <R>(cb: () => R, values: unknown[]) => {\n const value = useMemo(\n () => ValueApi.createComputedValue<R>(cb, values.filter(isValue)),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n values\n );\n useEffect(() => () => value.__invalidate(), [value]);\n return value;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAd;AACA,cAAc,SAAd;AACA,cAAc,OAAd","sourcesContent":["export * from \"./types\";\nexport * from \"./hooks\";\nexport * from \"./api\";\n"]}
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAd;AACA,cAAc,SAAd;AACA,cAAc,OAAd;AACA,cAAc,YAAd","sourcesContent":["export * from \"./types\";\nexport * from \"./hooks\";\nexport * from \"./api\";\nexport * from \"./selector\";\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wraps a Skia Value with a selector function. The selector function can access the
|
|
3
|
+
* inner values of the Skia Value so that we can dynamically ready array values and
|
|
4
|
+
* object values when doing animations in Skia.
|
|
5
|
+
* @param value Dependant value
|
|
6
|
+
* @param selector Selector function to calculate new value from the Skia Value's value
|
|
7
|
+
* @returns A descriptor that will be used by the reconciler to calculate the value
|
|
8
|
+
*/
|
|
9
|
+
export const Selector = (value, selector) => {
|
|
10
|
+
return {
|
|
11
|
+
selector,
|
|
12
|
+
value
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=selector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["selector.ts"],"names":["Selector","value","selector"],"mappings":"AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,QAAQ,GAAG,CACtBC,KADsB,EAEtBC,QAFsB,KAGY;AAClC,SAAO;AACLA,IAAAA,QADK;AAELD,IAAAA;AAFK,GAAP;AAID,CARM","sourcesContent":["import type { SkiaValue } from \"./types\";\n\nexport type SkiaSelector<TReturn, TInput = unknown> = {\n value: SkiaValue<TInput>;\n selector: (v: TInput) => TReturn;\n};\n\n/**\n * Wraps a Skia Value with a selector function. The selector function can access the\n * inner values of the Skia Value so that we can dynamically ready array values and\n * object values when doing animations in Skia.\n * @param value Dependant value\n * @param selector Selector function to calculate new value from the Skia Value's value\n * @returns A descriptor that will be used by the reconciler to calculate the value\n */\nexport const Selector = <TInput, TReturn>(\n value: SkiaValue<TInput>,\n selector: (v: TInput) => TReturn\n): SkiaSelector<TReturn, TInput> => {\n return {\n selector,\n value,\n };\n};\n"]}
|
|
@@ -35,6 +35,14 @@ export class RNSkComputedValue extends RNSkReadonlyValue {
|
|
|
35
35
|
|
|
36
36
|
unsubscribe() {
|
|
37
37
|
this._unsubscribers.forEach(unsubscribe => unsubscribe());
|
|
38
|
+
|
|
39
|
+
this._unsubscribers = [];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
__invalidate() {
|
|
43
|
+
this._unsubscribers.forEach(unsubscribe => unsubscribe());
|
|
44
|
+
|
|
45
|
+
this._unsubscribers = [];
|
|
38
46
|
}
|
|
39
47
|
|
|
40
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["RNSkComputedValue.ts"],"names":["RNSkReadonlyValue","RNSkComputedValue","constructor","callback","dependencies","unsubscribers","notifyUpdateRef","current","undefined","forEach","dep","push","addListener","_unsubscribers","dependecyUpdated","bind","_callback","update","unsubscribe"],"mappings":";;AAEA,SAASA,iBAAT,QAAkC,qBAAlC;AAEA,OAAO,MAAMC,iBAAN,SAAmCD,iBAAnC,CAAwD;AAC7DE,EAAAA,WAAW,CAACC,QAAD,EAAoBC,YAApB,EAAkD;AAC3D;AACA;AACA,UAAMC,aAAgC,GAAG,EAAzC;AACA,UAAMC,eAAsD,GAAG;AAC7DC,MAAAA,OAAO,EAAEC;AADoD,KAA/D;AAGAJ,IAAAA,YAAY,CAACK,OAAb,CAAsBC,GAAD,IAAS;AAC5B,UAAI,kBAAkBA,GAAlB,IAAyB,iBAAiBA,GAA9C,EAAmD;AACjDL,QAAAA,aAAa,CAACM,IAAd,CACGD,GAAD,CAAoCE,WAApC,CAAgD;AAAA;;AAAA,0CAC9CN,eAAe,CAACC,OAD8B,0DAC9C,2BAAAD,eAAe,CAD+B;AAAA,SAAhD,CADF;AAKD;AACF,KARD;AASA,UAAMH,QAAQ,EAAd;;AAhB2D;;AAAA;;AAiB3D,SAAKU,cAAL,GAAsBR,aAAtB;AACAC,IAAAA,eAAe,CAACC,OAAhB,GAA0B,KAAKO,gBAAL,CAAsBC,IAAtB,CAA2B,IAA3B,CAA1B;AACA,SAAKC,SAAL,GAAiBb,QAAjB;AACD;;AAEOW,EAAAA,gBAAgB,GAAG;AACzB,SAAKG,MAAL,CAAY,KAAKD,SAAL,EAAZ;AACD;;AAKME,EAAAA,WAAW,GAAG;AACnB,SAAKL,cAAL,CAAoBJ,OAApB,CAA6BS,WAAD,IAAiBA,WAAW,EAAxD;AACD;;
|
|
1
|
+
{"version":3,"sources":["RNSkComputedValue.ts"],"names":["RNSkReadonlyValue","RNSkComputedValue","constructor","callback","dependencies","unsubscribers","notifyUpdateRef","current","undefined","forEach","dep","push","addListener","_unsubscribers","dependecyUpdated","bind","_callback","update","unsubscribe","__invalidate"],"mappings":";;AAEA,SAASA,iBAAT,QAAkC,qBAAlC;AAEA,OAAO,MAAMC,iBAAN,SAAmCD,iBAAnC,CAAwD;AAC7DE,EAAAA,WAAW,CAACC,QAAD,EAAoBC,YAApB,EAAkD;AAC3D;AACA;AACA,UAAMC,aAAgC,GAAG,EAAzC;AACA,UAAMC,eAAsD,GAAG;AAC7DC,MAAAA,OAAO,EAAEC;AADoD,KAA/D;AAGAJ,IAAAA,YAAY,CAACK,OAAb,CAAsBC,GAAD,IAAS;AAC5B,UAAI,kBAAkBA,GAAlB,IAAyB,iBAAiBA,GAA9C,EAAmD;AACjDL,QAAAA,aAAa,CAACM,IAAd,CACGD,GAAD,CAAoCE,WAApC,CAAgD;AAAA;;AAAA,0CAC9CN,eAAe,CAACC,OAD8B,0DAC9C,2BAAAD,eAAe,CAD+B;AAAA,SAAhD,CADF;AAKD;AACF,KARD;AASA,UAAMH,QAAQ,EAAd;;AAhB2D;;AAAA;;AAiB3D,SAAKU,cAAL,GAAsBR,aAAtB;AACAC,IAAAA,eAAe,CAACC,OAAhB,GAA0B,KAAKO,gBAAL,CAAsBC,IAAtB,CAA2B,IAA3B,CAA1B;AACA,SAAKC,SAAL,GAAiBb,QAAjB;AACD;;AAEOW,EAAAA,gBAAgB,GAAG;AACzB,SAAKG,MAAL,CAAY,KAAKD,SAAL,EAAZ;AACD;;AAKME,EAAAA,WAAW,GAAG;AACnB,SAAKL,cAAL,CAAoBJ,OAApB,CAA6BS,WAAD,IAAiBA,WAAW,EAAxD;;AACA,SAAKL,cAAL,GAAsB,EAAtB;AACD;;AAEMM,EAAAA,YAAY,GAAS;AAC1B,SAAKN,cAAL,CAAoBJ,OAApB,CAA6BS,WAAD,IAAiBA,WAAW,EAAxD;;AACA,SAAKL,cAAL,GAAsB,EAAtB;AACD;;AAtC4D","sourcesContent":["import type { DependencyList } from \"react\";\n\nimport { RNSkReadonlyValue } from \"./RNSkReadonlyValue\";\n\nexport class RNSkComputedValue<T> extends RNSkReadonlyValue<T> {\n constructor(callback: () => T, dependencies: DependencyList) {\n // Initialize dependencies - we can't call this yet, since\n // super if not called and it requires a start value to be set.\n const unsubscribers: Array<() => void> = [];\n const notifyUpdateRef: { current: (() => void) | undefined } = {\n current: undefined,\n };\n dependencies.forEach((dep) => {\n if (\"__typename__\" in dep && \"addListener\" in dep) {\n unsubscribers.push(\n (dep as RNSkReadonlyValue<unknown>).addListener(() =>\n notifyUpdateRef.current?.()\n )\n );\n }\n });\n super(callback());\n this._unsubscribers = unsubscribers;\n notifyUpdateRef.current = this.dependecyUpdated.bind(this);\n this._callback = callback;\n }\n\n private dependecyUpdated() {\n this.update(this._callback());\n }\n\n private _callback: () => T;\n private _unsubscribers: Array<() => void>;\n\n public unsubscribe() {\n this._unsubscribers.forEach((unsubscribe) => unsubscribe());\n this._unsubscribers = [];\n }\n\n public __invalidate(): void {\n this._unsubscribers.forEach((unsubscribe) => unsubscribe());\n this._unsubscribers = [];\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["RNSkReadonlyValue.ts"],"names":["RNSkReadonlyValue","constructor","value","_current","notifyListeners","_listeners","forEach","cb","update","nextValue","current","addListener","push","splice","indexOf"],"mappings":";;AAEA,OAAO,MAAMA,iBAAN,CAAmD;AACxDC,EAAAA,WAAW,CAACC,KAAD,EAAW;AAAA;;AAAA,wCAK0B,EAL1B;;AAAA,0CAgBS,WAhBT;;AACpB,SAAKC,QAAL,GAAgBD,KAAhB;AACD;;AAKOE,EAAAA,eAAe,GAAS;AAC9B,SAAKC,UAAL,CAAgBC,OAAhB,CAAyBC,EAAD,IAAQA,EAAE,CAAC,KAAKJ,QAAN,CAAlC;AACD;;AAESK,EAAAA,MAAM,CAACC,SAAD,EAAqB;AACnC,SAAKN,QAAL,GAAgBM,SAAhB;AACA,SAAKL,eAAL;AACD;;AAIiB,MAAPM,OAAO,GAAM;AACtB,WAAO,KAAKP,QAAZ;AACD;;AAEMQ,EAAAA,WAAW,CAACJ,EAAD,EAAyB;AACzC,SAAKF,UAAL,CAAgBO,IAAhB,CAAqBL,EAArB;;AACA,WAAO,MAAM;AACX,WAAKF,UAAL,CAAgBQ,MAAhB,CAAuB,KAAKR,UAAL,CAAgBS,OAAhB,CAAwBP,EAAxB,CAAvB,EAAoD,CAApD;AACD,KAFD;AAGD;;
|
|
1
|
+
{"version":3,"sources":["RNSkReadonlyValue.ts"],"names":["RNSkReadonlyValue","constructor","value","_current","notifyListeners","_listeners","forEach","cb","update","nextValue","current","addListener","push","splice","indexOf","__invalidate"],"mappings":";;AAEA,OAAO,MAAMA,iBAAN,CAAmD;AACxDC,EAAAA,WAAW,CAACC,KAAD,EAAW;AAAA;;AAAA,wCAK0B,EAL1B;;AAAA,0CAgBS,WAhBT;;AACpB,SAAKC,QAAL,GAAgBD,KAAhB;AACD;;AAKOE,EAAAA,eAAe,GAAS;AAC9B,SAAKC,UAAL,CAAgBC,OAAhB,CAAyBC,EAAD,IAAQA,EAAE,CAAC,KAAKJ,QAAN,CAAlC;AACD;;AAESK,EAAAA,MAAM,CAACC,SAAD,EAAqB;AACnC,SAAKN,QAAL,GAAgBM,SAAhB;AACA,SAAKL,eAAL;AACD;;AAIiB,MAAPM,OAAO,GAAM;AACtB,WAAO,KAAKP,QAAZ;AACD;;AAEMQ,EAAAA,WAAW,CAACJ,EAAD,EAAyB;AACzC,SAAKF,UAAL,CAAgBO,IAAhB,CAAqBL,EAArB;;AACA,WAAO,MAAM;AACX,WAAKF,UAAL,CAAgBQ,MAAhB,CAAuB,KAAKR,UAAL,CAAgBS,OAAhB,CAAwBP,EAAxB,CAAvB,EAAoD,CAApD;AACD,KAFD;AAGD;;AAEMQ,EAAAA,YAAY,GAAS;AAC1B,SAAKV,UAAL,GAAkB,EAAlB;AACD;;AAhCuD","sourcesContent":["import type { SkiaValue } from \"../types\";\n\nexport class RNSkReadonlyValue<T> implements SkiaValue<T> {\n constructor(value: T) {\n this._current = value;\n }\n\n private _current: T;\n private _listeners: Array<(value: T) => void> = [];\n\n private notifyListeners(): void {\n this._listeners.forEach((cb) => cb(this._current));\n }\n\n protected update(nextValue: T): void {\n this._current = nextValue;\n this.notifyListeners();\n }\n\n public readonly __typename__ = \"RNSkValue\";\n\n public get current(): T {\n return this._current;\n }\n\n public addListener(cb: (value: T) => void) {\n this._listeners.push(cb);\n return () => {\n this._listeners.splice(this._listeners.indexOf(cb), 1);\n };\n }\n\n public __invalidate(): void {\n this._listeners = [];\n }\n}\n"]}
|
|
@@ -12,30 +12,29 @@ const useInternalTouchHandler = function (handlers) {
|
|
|
12
12
|
history.forEach(touches => {
|
|
13
13
|
// Enumerate touches
|
|
14
14
|
for (let i = 0; i < touches.length; i++) {
|
|
15
|
-
var _prevTouchInfoRef$cur, _prevTouchInfoRef$cur2,
|
|
15
|
+
var _prevTouchInfoRef$cur, _prevTouchInfoRef$cur2, _prevTouch$x, _prevTouch$y, _prevVelocityRef$curr, _prevVelocityRef$curr2, _prevVelocityRef$curr3, _prevVelocityRef$curr4;
|
|
16
16
|
|
|
17
17
|
if (!multiTouch && i > 0) {
|
|
18
18
|
break;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
const touch = touches[i];
|
|
21
|
+
const touch = touches[i];
|
|
22
|
+
const prevTouch = prevTouchInfoRef.current[touch.id]; // Calculate the velocity from the previous touch.
|
|
22
23
|
|
|
23
24
|
const timeDiffseconds = touch.timestamp - ((_prevTouchInfoRef$cur = (_prevTouchInfoRef$cur2 = prevTouchInfoRef.current[touch.id]) === null || _prevTouchInfoRef$cur2 === void 0 ? void 0 : _prevTouchInfoRef$cur2.timestamp) !== null && _prevTouchInfoRef$cur !== void 0 ? _prevTouchInfoRef$cur : touch.timestamp);
|
|
24
|
-
const distX = touch.x - ((
|
|
25
|
-
const distY = touch.y - ((
|
|
25
|
+
const distX = touch.x - ((_prevTouch$x = prevTouch === null || prevTouch === void 0 ? void 0 : prevTouch.x) !== null && _prevTouch$x !== void 0 ? _prevTouch$x : touch.x);
|
|
26
|
+
const distY = touch.y - ((_prevTouch$y = prevTouch === null || prevTouch === void 0 ? void 0 : prevTouch.y) !== null && _prevTouch$y !== void 0 ? _prevTouch$y : touch.y);
|
|
26
27
|
|
|
27
|
-
if (touch.type !== TouchType.Start && touch.type !== TouchType.End && touch.type !== TouchType.Cancelled) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
};
|
|
33
|
-
}
|
|
28
|
+
if (touch.type !== TouchType.Start && touch.type !== TouchType.End && touch.type !== TouchType.Cancelled && timeDiffseconds > 0) {
|
|
29
|
+
prevVelocityRef.current[touch.id] = {
|
|
30
|
+
x: distX / timeDiffseconds / PixelRatio.get(),
|
|
31
|
+
y: distY / timeDiffseconds / PixelRatio.get()
|
|
32
|
+
};
|
|
34
33
|
}
|
|
35
34
|
|
|
36
35
|
const extendedTouchInfo = { ...touch,
|
|
37
|
-
velocityX: (_prevVelocityRef$curr = prevVelocityRef.current[touch.id]) === null || _prevVelocityRef$
|
|
38
|
-
velocityY: (_prevVelocityRef$
|
|
36
|
+
velocityX: (_prevVelocityRef$curr = (_prevVelocityRef$curr2 = prevVelocityRef.current[touch.id]) === null || _prevVelocityRef$curr2 === void 0 ? void 0 : _prevVelocityRef$curr2.x) !== null && _prevVelocityRef$curr !== void 0 ? _prevVelocityRef$curr : 0,
|
|
37
|
+
velocityY: (_prevVelocityRef$curr3 = (_prevVelocityRef$curr4 = prevVelocityRef.current[touch.id]) === null || _prevVelocityRef$curr4 === void 0 ? void 0 : _prevVelocityRef$curr4.y) !== null && _prevVelocityRef$curr3 !== void 0 ? _prevVelocityRef$curr3 : 0
|
|
39
38
|
}; // Save previous touch
|
|
40
39
|
|
|
41
40
|
prevTouchInfoRef.current[touch.id] = touch;
|
|
@@ -46,7 +45,6 @@ const useInternalTouchHandler = function (handlers) {
|
|
|
46
45
|
} else if (touch.type === TouchType.Active) {
|
|
47
46
|
handlers.onActive && handlers.onActive(extendedTouchInfo);
|
|
48
47
|
} else {
|
|
49
|
-
handlers.onActive && handlers.onActive(extendedTouchInfo);
|
|
50
48
|
handlers.onEnd && handlers.onEnd(extendedTouchInfo);
|
|
51
49
|
}
|
|
52
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useTouchHandler.ts"],"names":["useCallback","useRef","PixelRatio","TouchType","useInternalTouchHandler","handlers","deps","multiTouch","prevTouchInfoRef","prevVelocityRef","history","forEach","touches","i","length","touch","
|
|
1
|
+
{"version":3,"sources":["useTouchHandler.ts"],"names":["useCallback","useRef","PixelRatio","TouchType","useInternalTouchHandler","handlers","deps","multiTouch","prevTouchInfoRef","prevVelocityRef","history","forEach","touches","i","length","touch","prevTouch","current","id","timeDiffseconds","timestamp","distX","x","distY","y","type","Start","End","Cancelled","get","extendedTouchInfo","velocityX","velocityY","onStart","Active","onActive","onEnd","useTouchHandler","useMultiTouchHandler"],"mappings":"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","sourcesContent":["import type { DependencyList } from \"react\";\nimport { useCallback, useRef } from \"react\";\nimport { PixelRatio } from \"react-native\";\n\nimport type { Vector } from \"../skia/types\";\n\nimport type {\n ExtendedTouchInfo,\n TouchHandlers,\n TouchHandler,\n TouchInfo,\n} from \"./types\";\nimport { TouchType } from \"./types\";\n\nconst useInternalTouchHandler = (\n handlers: TouchHandlers,\n deps: DependencyList = [],\n multiTouch = false\n): TouchHandler => {\n const prevTouchInfoRef = useRef<{ [key: number]: TouchInfo | undefined }>({});\n const prevVelocityRef = useRef<{ [key: number]: Vector | undefined }>({});\n\n return useCallback((history: Array<Array<TouchInfo>>) => {\n // Process all items in the current touch history\n history.forEach((touches) => {\n // Enumerate touches\n for (let i = 0; i < touches.length; i++) {\n if (!multiTouch && i > 0) {\n break;\n }\n\n const touch = touches[i];\n const prevTouch = prevTouchInfoRef.current[touch.id];\n // Calculate the velocity from the previous touch.\n const timeDiffseconds =\n touch.timestamp -\n (prevTouchInfoRef.current[touch.id]?.timestamp ?? touch.timestamp);\n\n const distX = touch.x - (prevTouch?.x ?? touch.x);\n const distY = touch.y - (prevTouch?.y ?? touch.y);\n\n if (\n touch.type !== TouchType.Start &&\n touch.type !== TouchType.End &&\n touch.type !== TouchType.Cancelled &&\n timeDiffseconds > 0\n ) {\n prevVelocityRef.current[touch.id] = {\n x: distX / timeDiffseconds / PixelRatio.get(),\n y: distY / timeDiffseconds / PixelRatio.get(),\n };\n }\n\n const extendedTouchInfo: ExtendedTouchInfo = {\n ...touch,\n velocityX: prevVelocityRef.current[touch.id]?.x ?? 0,\n velocityY: prevVelocityRef.current[touch.id]?.y ?? 0,\n };\n\n // Save previous touch\n prevTouchInfoRef.current[touch.id] = touch;\n\n if (touch.type === TouchType.Start) {\n delete prevVelocityRef.current[touch.id];\n handlers.onStart && handlers.onStart(touch);\n } else if (touch.type === TouchType.Active) {\n handlers.onActive && handlers.onActive(extendedTouchInfo);\n } else {\n handlers.onEnd && handlers.onEnd(extendedTouchInfo);\n }\n }\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n};\n\n/**\n * Provides a callback for handling touch events in the Skia View.\n * This touch handler only handles single touches.\n * @param handlers Callbacks for the different touch states\n * @param deps optional Dependency array to update the handlers\n * @returns A function that can be used from within the onDraw callback to\n * update and handle touch events. Call it with the touches property from\n * the info object.\n */\nexport const useTouchHandler = (\n handlers: TouchHandlers,\n deps: DependencyList = []\n): TouchHandler => {\n return useInternalTouchHandler(handlers, deps, false);\n};\n\n/**\n * Provides a callback for handling touch events in the Skia View.\n * This touch handler handles multiple touches.\n * @param handlers Callbacks for the different touch states\n * @param deps optional Dependency array to update the handlers\n * @returns A function that can be used from within the onDraw callback to\n * update and handle touch events. Call it with the touches property from\n * the info object.\n */\nexport const useMultiTouchHandler = (\n handlers: TouchHandlers,\n deps: DependencyList = []\n): TouchHandler => {\n return useInternalTouchHandler(handlers, deps, true);\n};\n"]}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import type { SkiaValue } from "../../../values";
|
|
1
|
+
import type { SkiaSelector, SkiaValue } from "../../../values";
|
|
2
2
|
export declare const isValue: (value: unknown) => value is SkiaValue<unknown>;
|
|
3
|
+
export declare const isSelector: <T, R>(value: unknown) => value is {
|
|
4
|
+
selector: (v: T) => R;
|
|
5
|
+
value: SkiaValue<T>;
|
|
6
|
+
};
|
|
3
7
|
export declare const isAnimated: <T>(props: AnimatedProps<T>) => boolean;
|
|
4
8
|
export declare const materialize: <T>(props: AnimatedProps<T>) => T;
|
|
9
|
+
export declare type AnimatedProp<T, P = any> = T | SkiaValue<T> | SkiaSelector<T, P>;
|
|
5
10
|
export declare type AnimatedProps<T> = {
|
|
6
|
-
[K in keyof T]:
|
|
11
|
+
[K in keyof T]: AnimatedProp<T[K]>;
|
|
7
12
|
};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const useRawData: <T>(source: DataSource | null | undefined, factory: (data: SkData) => T, onError?: ((err: Error) => void) | undefined, deps?: DependencyList | undefined) => T | null;
|
|
5
|
-
export declare const useData: (source: DataSource | null | undefined, onError?: ((err: Error) => void) | undefined, deps?: DependencyList | undefined) => SkData | null;
|
|
1
|
+
import type { SkData, DataSourceParam } from "../types";
|
|
2
|
+
export declare const useRawData: <T>(source: DataSourceParam, factory: (data: SkData) => T, onError?: ((err: Error) => void) | undefined) => T | null;
|
|
3
|
+
export declare const useData: (source: DataSourceParam, onError?: ((err: Error) => void) | undefined) => SkData | null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DataSourceParam } from "../types";
|
|
2
2
|
/**
|
|
3
3
|
* Returns a Skia Font object
|
|
4
4
|
* */
|
|
5
|
-
export declare const useFont: (font:
|
|
5
|
+
export declare const useFont: (font: DataSourceParam, size?: number | undefined, onError?: ((err: Error) => void) | undefined) => import("../types").SkFont | null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DataSourceParam } from "../types";
|
|
2
2
|
/**
|
|
3
3
|
* Returns a Skia Image object
|
|
4
4
|
* */
|
|
5
|
-
export declare const useImage: (source:
|
|
5
|
+
export declare const useImage: (source: DataSourceParam, onError?: ((err: Error) => void) | undefined) => import("../types").SkImage | null;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const useSVG: (source:
|
|
1
|
+
import type { DataSourceParam } from "../types";
|
|
2
|
+
export declare const useSVG: (source: DataSourceParam, onError?: ((err: Error) => void) | undefined) => import("../types").SkSVG | null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DataSourceParam } from "../types";
|
|
2
2
|
/**
|
|
3
3
|
* Returns a Skia Typeface object
|
|
4
4
|
* */
|
|
5
|
-
export declare const useTypeface: (source:
|
|
5
|
+
export declare const useTypeface: (source: DataSourceParam, onError?: ((err: Error) => void) | undefined) => import("../types").SkTypeface | null;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="react-native" />
|
|
3
1
|
import type { SkJSIInstance } from "../JsiInstance";
|
|
4
2
|
export declare type SkData = SkJSIInstance<"Data">;
|
|
5
|
-
|
|
3
|
+
declare type RNModule = number;
|
|
4
|
+
declare type ESModule = {
|
|
5
|
+
__esModule: true;
|
|
6
|
+
default: string;
|
|
7
|
+
};
|
|
8
|
+
export declare type DataModule = RNModule | ESModule;
|
|
9
|
+
export declare type DataSource = DataModule | string | Uint8Array;
|
|
10
|
+
export declare type DataSourceParam = DataSource | null | undefined;
|
|
11
|
+
export declare const isRNModule: (mod: DataModule) => mod is number;
|
|
12
|
+
export {};
|
|
@@ -3,6 +3,7 @@ import type { SkRRect } from "../types";
|
|
|
3
3
|
import { HostObject } from "./Host";
|
|
4
4
|
import { JsiSkRect } from "./JsiSkRect";
|
|
5
5
|
export declare class JsiSkRRect extends HostObject<RRect, "RRect"> implements SkRRect {
|
|
6
|
+
static fromValue(CanvasKit: CanvasKit, rect: SkRRect): Float32Array;
|
|
6
7
|
constructor(CanvasKit: CanvasKit, ref: RRect);
|
|
7
8
|
get rx(): number;
|
|
8
9
|
get ry(): number;
|
|
@@ -2,7 +2,7 @@ import type { CanvasKit, Rect } from "canvaskit-wasm";
|
|
|
2
2
|
import type { SkRect } from "../types";
|
|
3
3
|
import { HostObject } from "./Host";
|
|
4
4
|
export declare class JsiSkRect extends HostObject<Rect, "Rect"> implements SkRect {
|
|
5
|
-
static fromValue(CanvasKit: CanvasKit, rect: SkRect):
|
|
5
|
+
static fromValue(CanvasKit: CanvasKit, rect: SkRect): Float32Array;
|
|
6
6
|
constructor(CanvasKit: CanvasKit, ref: Rect);
|
|
7
7
|
get x(): number;
|
|
8
8
|
get y(): number;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { SkiaValue } from "./types";
|
|
2
|
+
export declare type SkiaSelector<TReturn, TInput = unknown> = {
|
|
3
|
+
value: SkiaValue<TInput>;
|
|
4
|
+
selector: (v: TInput) => TReturn;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Wraps a Skia Value with a selector function. The selector function can access the
|
|
8
|
+
* inner values of the Skia Value so that we can dynamically ready array values and
|
|
9
|
+
* object values when doing animations in Skia.
|
|
10
|
+
* @param value Dependant value
|
|
11
|
+
* @param selector Selector function to calculate new value from the Skia Value's value
|
|
12
|
+
* @returns A descriptor that will be used by the reconciler to calculate the value
|
|
13
|
+
*/
|
|
14
|
+
export declare const Selector: <TInput, TReturn>(value: SkiaValue<TInput>, selector: (v: TInput) => TReturn) => SkiaSelector<TReturn, TInput>;
|
|
@@ -8,6 +8,10 @@ export interface SkiaValue<T = number> {
|
|
|
8
8
|
* Returns unsubscribe method.
|
|
9
9
|
*/
|
|
10
10
|
addListener: (cb: (value: T) => void) => () => void;
|
|
11
|
+
/**
|
|
12
|
+
* Invalidates the value. Has different meaning depending on the type of the value.
|
|
13
|
+
*/
|
|
14
|
+
__invalidate: () => void;
|
|
11
15
|
/**
|
|
12
16
|
* Field to make typechecking easier
|
|
13
17
|
*/
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"setup-skia-web": "./scripts/setup-canvaskit.js"
|
|
8
8
|
},
|
|
9
9
|
"title": "React Native Skia",
|
|
10
|
-
"version": "0.1.
|
|
10
|
+
"version": "0.1.142",
|
|
11
11
|
"description": "High-performance React Native Graphics using Skia",
|
|
12
12
|
"main": "lib/module/index.js",
|
|
13
13
|
"files": [
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
],
|
|
38
38
|
"scripts": {
|
|
39
39
|
"tsc": "tsc --noEmit",
|
|
40
|
-
"lint": "eslint . --ext .ts,.tsx --max-warnings 0",
|
|
40
|
+
"lint": "eslint . --ext .ts,.tsx --max-warnings 0 --cache",
|
|
41
41
|
"test": "jest",
|
|
42
42
|
"postinstall": "node scripts/install-npm.js",
|
|
43
43
|
"build": "bob build"
|
|
@@ -69,18 +69,23 @@
|
|
|
69
69
|
"react-native": ">=0.63.0-rc.0 <1.0.x",
|
|
70
70
|
"react-native-reanimated": ">=2.0.0"
|
|
71
71
|
},
|
|
72
|
+
"peerDependenciesMeta": {
|
|
73
|
+
"react-native-reanimated": {
|
|
74
|
+
"optional": true
|
|
75
|
+
}
|
|
76
|
+
},
|
|
72
77
|
"devDependencies": {
|
|
73
|
-
"@types/jest": "^
|
|
78
|
+
"@types/jest": "^28.1.6",
|
|
74
79
|
"@types/react-native": "^0.65.0",
|
|
75
80
|
"@types/react-reconciler": "^0.26.4",
|
|
76
|
-
"eslint": "
|
|
77
|
-
"eslint-config-react-native-wcandillon": "
|
|
78
|
-
"eslint-plugin-reanimated": "
|
|
79
|
-
"jest": "
|
|
81
|
+
"eslint": "8.21.0",
|
|
82
|
+
"eslint-config-react-native-wcandillon": "3.9.0",
|
|
83
|
+
"eslint-plugin-reanimated": "2.0.0",
|
|
84
|
+
"jest": "28.1.3",
|
|
80
85
|
"react": "17.0.2",
|
|
81
86
|
"react-native": "0.66.2",
|
|
82
87
|
"react-native-builder-bob": "^0.18.2",
|
|
83
|
-
"ts-jest": "^
|
|
88
|
+
"ts-jest": "^28.0.7",
|
|
84
89
|
"typescript": "^4.6.4"
|
|
85
90
|
},
|
|
86
91
|
"dependencies": {
|
package/src/mock/index.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import type { Color, Skia as SkiaApi, SkRect, Vector } from "../skia/types";
|
|
4
4
|
import * as Values from "../values/web";
|
|
5
5
|
import * as ValuesHooks from "../values/hooks";
|
|
6
|
+
import { Selector } from "../values/selector";
|
|
6
7
|
import * as BaseSkia from "../skia/types";
|
|
7
8
|
import type * as SkiaExports from "../skia";
|
|
8
9
|
import type * as ExternalExports from "../external";
|
|
@@ -46,7 +47,6 @@ export const Mock: typeof SkiaExports &
|
|
|
46
47
|
Skia,
|
|
47
48
|
...BaseSkia,
|
|
48
49
|
// 2. Hooks
|
|
49
|
-
useDataCollection: Noop,
|
|
50
50
|
useRawData: Noop,
|
|
51
51
|
useData: Noop,
|
|
52
52
|
useFont: Noop,
|
|
@@ -87,6 +87,7 @@ export const Mock: typeof SkiaExports &
|
|
|
87
87
|
// ValueExports
|
|
88
88
|
...Values,
|
|
89
89
|
...ValuesHooks,
|
|
90
|
+
Selector,
|
|
90
91
|
// Animations
|
|
91
92
|
...timingFunctions,
|
|
92
93
|
...springFunctions,
|
|
@@ -3,7 +3,7 @@ import type { RefObject } from "react";
|
|
|
3
3
|
import type { SkiaView } from "../views";
|
|
4
4
|
import type { SkiaValue } from "../values";
|
|
5
5
|
|
|
6
|
-
import { isValue } from "./processors";
|
|
6
|
+
import { isSelector, isValue } from "./processors";
|
|
7
7
|
import type { Node } from "./nodes";
|
|
8
8
|
|
|
9
9
|
type Unsubscribe = () => void;
|
|
@@ -29,7 +29,10 @@ export class DependencyManager {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
subscribeNode(node: Node, props: Props) {
|
|
32
|
-
const values = Object.values(props)
|
|
32
|
+
const values = Object.values(props)
|
|
33
|
+
.filter((v) => isValue(v) || isSelector(v))
|
|
34
|
+
.map((v) => (isSelector(v) ? v.value : (v as SkiaValue<unknown>)));
|
|
35
|
+
|
|
33
36
|
if (values.length > 0) {
|
|
34
37
|
this.subscriptions.set(node, { values, unsubscribe: null });
|
|
35
38
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SkiaValue } from "../../../values";
|
|
1
|
+
import type { SkiaSelector, SkiaValue } from "../../../values";
|
|
2
2
|
import { mapKeys } from "../../typeddash";
|
|
3
3
|
|
|
4
4
|
export const isValue = (value: unknown): value is SkiaValue<unknown> => {
|
|
@@ -17,6 +17,24 @@ export const isValue = (value: unknown): value is SkiaValue<unknown> => {
|
|
|
17
17
|
return false;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
+
export const isSelector = <T, R>(
|
|
21
|
+
value: unknown
|
|
22
|
+
): value is {
|
|
23
|
+
selector: (v: T) => R;
|
|
24
|
+
value: SkiaValue<T>;
|
|
25
|
+
} => {
|
|
26
|
+
if (value) {
|
|
27
|
+
return (
|
|
28
|
+
typeof value === "object" &&
|
|
29
|
+
"selector" in value &&
|
|
30
|
+
"value" in value &&
|
|
31
|
+
(value as Record<string, unknown>).selector !== undefined &&
|
|
32
|
+
(value as Record<string, unknown>).value !== undefined
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
return false;
|
|
36
|
+
};
|
|
37
|
+
|
|
20
38
|
export const isAnimated = <T>(props: AnimatedProps<T>) => {
|
|
21
39
|
for (const value of Object.values(props)) {
|
|
22
40
|
if (isValue(value)) {
|
|
@@ -29,14 +47,18 @@ export const isAnimated = <T>(props: AnimatedProps<T>) => {
|
|
|
29
47
|
export const materialize = <T>(props: AnimatedProps<T>) => {
|
|
30
48
|
const result = { ...props };
|
|
31
49
|
mapKeys(props).forEach((key) => {
|
|
32
|
-
const
|
|
33
|
-
if (isValue(
|
|
34
|
-
result[key] = (
|
|
50
|
+
const prop = props[key];
|
|
51
|
+
if (isValue(prop)) {
|
|
52
|
+
result[key] = (prop as SkiaValue<T[typeof key]>).current;
|
|
53
|
+
} else if (isSelector(prop)) {
|
|
54
|
+
result[key] = prop.selector(prop.value.current) as T[typeof key];
|
|
35
55
|
}
|
|
36
56
|
});
|
|
37
57
|
return result as T;
|
|
38
58
|
};
|
|
39
59
|
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
61
|
+
export type AnimatedProp<T, P = any> = T | SkiaValue<T> | SkiaSelector<T, P>;
|
|
40
62
|
export type AnimatedProps<T> = {
|
|
41
|
-
[K in keyof T]:
|
|
63
|
+
[K in keyof T]: AnimatedProp<T[K]>;
|
|
42
64
|
};
|