@shopify/react-native-skia 0.1.145 → 0.1.146
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/cpp/api/JsiSkContourMeasure.h +4 -4
- package/cpp/api/JsiSkDataFactory.h +3 -3
- package/cpp/api/JsiSkFont.h +1 -1
- package/cpp/api/JsiSkPathFactory.h +1 -1
- package/cpp/api/JsiSkPictureFactory.h +1 -1
- package/cpp/api/JsiSkRuntimeEffect.h +6 -6
- package/cpp/api/JsiSkRuntimeEffectFactory.h +1 -1
- package/cpp/jsi/JsiSimpleValueWrapper.h +27 -27
- package/cpp/jsi/JsiValueWrapper.h +127 -0
- package/cpp/rnskia/RNSkDrawView.cpp +41 -17
- package/cpp/rnskia/RNSkDrawView.h +17 -19
- package/cpp/rnskia/RNSkJsiViewApi.h +180 -166
- package/cpp/rnskia/values/RNSkComputedValue.h +11 -11
- package/cpp/rnskia/values/RNSkReadonlyValue.h +19 -19
- package/cpp/rnskia/values/RNSkValue.h +13 -13
- package/cpp/utils/RNSkLog.h +4 -4
- package/lib/commonjs/renderer/HostConfig.js +17 -1
- package/lib/commonjs/renderer/HostConfig.js.map +1 -1
- package/lib/commonjs/views/SkiaView.js +11 -27
- package/lib/commonjs/views/SkiaView.js.map +1 -1
- package/lib/commonjs/views/types.js.map +1 -1
- package/lib/module/renderer/HostConfig.js +17 -1
- package/lib/module/renderer/HostConfig.js.map +1 -1
- package/lib/module/views/SkiaView.js +11 -26
- package/lib/module/views/SkiaView.js.map +1 -1
- package/lib/module/views/types.js.map +1 -1
- package/lib/typescript/src/views/SkiaView.d.ts +1 -11
- package/lib/typescript/src/views/types.d.ts +5 -5
- package/package.json +1 -1
- package/src/renderer/HostConfig.ts +11 -1
- package/src/views/SkiaView.tsx +17 -28
- package/src/views/types.ts +7 -6
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { ViewProps } from "react-native";
|
2
|
-
import type { SkImage, SkRect
|
2
|
+
import type { SkCanvas, SkImage, SkRect } from "../skia/types";
|
3
3
|
import type { SkiaValue } from "../values";
|
4
4
|
export declare type DrawMode = "continuous" | "default";
|
5
5
|
export declare type NativeSkiaViewProps = ViewProps & {
|
@@ -45,11 +45,11 @@ export interface ValueListener {
|
|
45
45
|
removeListener: (id: number) => void;
|
46
46
|
}
|
47
47
|
export interface ISkiaViewApi {
|
48
|
-
|
49
|
-
|
50
|
-
setDrawCallback: (nativeId: number, callback: RNSkiaDrawCallback | undefined) => void;
|
51
|
-
setDrawMode: (nativeId: number, mode: DrawMode) => void;
|
48
|
+
setJsiProperty: <T>(nativeId: number, name: string, value: T) => void;
|
49
|
+
callJsiMethod: <T extends Array<unknown>>(nativeId: number, name: string, ...args: T) => void;
|
52
50
|
registerValuesInView: (nativeId: number, values: SkiaValue<unknown>[]) => () => void;
|
51
|
+
requestRedraw: (nativeId: number) => void;
|
52
|
+
makeImageSnapshot: (nativeId: number, rect?: SkRect) => SkImage;
|
53
53
|
}
|
54
54
|
export interface SkiaViewProps extends ViewProps {
|
55
55
|
/**
|
package/package.json
CHANGED
@@ -265,7 +265,17 @@ export const skHostConfig: SkiaHostConfig = {
|
|
265
265
|
return;
|
266
266
|
}
|
267
267
|
bustBranchMemoization(instance);
|
268
|
-
instance
|
268
|
+
if (instance instanceof DrawingNode) {
|
269
|
+
const { onDraw, skipProcessing, ...props } = nextProps;
|
270
|
+
instance.props = props;
|
271
|
+
} else if (instance instanceof DeclarationNode) {
|
272
|
+
const { onDeclare, ...props } = nextProps;
|
273
|
+
instance.props = props;
|
274
|
+
} else {
|
275
|
+
throw new Error(
|
276
|
+
"Unsupported instance commitUpdate " + instance.constructor.name
|
277
|
+
);
|
278
|
+
}
|
269
279
|
},
|
270
280
|
|
271
281
|
commitTextUpdate: (
|
package/src/views/SkiaView.tsx
CHANGED
@@ -5,7 +5,7 @@ import type { SkRect } from "../skia/types";
|
|
5
5
|
import type { SkiaValue } from "../values";
|
6
6
|
|
7
7
|
import { SkiaViewApi } from "./api";
|
8
|
-
import type {
|
8
|
+
import type { NativeSkiaViewProps, SkiaViewProps } from "./types";
|
9
9
|
|
10
10
|
let SkiaViewNativeId = 1000;
|
11
11
|
|
@@ -19,8 +19,8 @@ export class SkiaView extends React.Component<SkiaViewProps> {
|
|
19
19
|
this._nativeId = SkiaViewNativeId++;
|
20
20
|
const { onDraw } = props;
|
21
21
|
if (onDraw) {
|
22
|
-
|
23
|
-
SkiaViewApi.
|
22
|
+
assertSkiaViewApi();
|
23
|
+
SkiaViewApi.setJsiProperty(this._nativeId, "drawCallback", onDraw);
|
24
24
|
}
|
25
25
|
}
|
26
26
|
|
@@ -33,8 +33,8 @@ export class SkiaView extends React.Component<SkiaViewProps> {
|
|
33
33
|
componentDidUpdate(prevProps: SkiaViewProps) {
|
34
34
|
const { onDraw } = this.props;
|
35
35
|
if (onDraw !== prevProps.onDraw) {
|
36
|
-
|
37
|
-
SkiaViewApi.
|
36
|
+
assertSkiaViewApi();
|
37
|
+
SkiaViewApi.setJsiProperty(this._nativeId, "drawCallback", onDraw);
|
38
38
|
}
|
39
39
|
}
|
40
40
|
|
@@ -44,7 +44,7 @@ export class SkiaView extends React.Component<SkiaViewProps> {
|
|
44
44
|
* @returns An Image object.
|
45
45
|
*/
|
46
46
|
public makeImageSnapshot(rect?: SkRect) {
|
47
|
-
|
47
|
+
assertSkiaViewApi();
|
48
48
|
return SkiaViewApi.makeImageSnapshot(this._nativeId, rect);
|
49
49
|
}
|
50
50
|
|
@@ -52,22 +52,8 @@ export class SkiaView extends React.Component<SkiaViewProps> {
|
|
52
52
|
* Sends a redraw request to the native SkiaView.
|
53
53
|
*/
|
54
54
|
public redraw() {
|
55
|
-
|
56
|
-
SkiaViewApi.
|
57
|
-
}
|
58
|
-
|
59
|
-
/**
|
60
|
-
* Updates the drawing mode for the skia view. This is the same
|
61
|
-
* as declaratively setting the mode property on the SkiaView.
|
62
|
-
* There are two drawing modes, "continuous" and "default",
|
63
|
-
* where the continuous mode will continuously redraw the view and
|
64
|
-
* the default mode will only redraw when any of the regular react
|
65
|
-
* properties are changed like size and margins.
|
66
|
-
* @param mode Drawing mode to use.
|
67
|
-
*/
|
68
|
-
public setDrawMode(mode: DrawMode) {
|
69
|
-
assertDrawCallbacksEnabled();
|
70
|
-
SkiaViewApi.setDrawMode(this._nativeId, mode);
|
55
|
+
assertSkiaViewApi();
|
56
|
+
SkiaViewApi.requestRedraw(this._nativeId);
|
71
57
|
}
|
72
58
|
|
73
59
|
/**
|
@@ -75,8 +61,8 @@ export class SkiaView extends React.Component<SkiaViewProps> {
|
|
75
61
|
* The view will redraw itself when any of the values change.
|
76
62
|
* @param values Values to register
|
77
63
|
*/
|
78
|
-
public registerValues(values: SkiaValue<unknown>[]) {
|
79
|
-
|
64
|
+
public registerValues(values: SkiaValue<unknown>[]): () => void {
|
65
|
+
assertSkiaViewApi();
|
80
66
|
return SkiaViewApi.registerValuesInView(this._nativeId, values);
|
81
67
|
}
|
82
68
|
|
@@ -94,12 +80,15 @@ export class SkiaView extends React.Component<SkiaViewProps> {
|
|
94
80
|
}
|
95
81
|
}
|
96
82
|
|
97
|
-
const
|
83
|
+
const assertSkiaViewApi = () => {
|
98
84
|
if (
|
99
85
|
SkiaViewApi === null ||
|
100
|
-
SkiaViewApi.
|
101
|
-
SkiaViewApi.
|
86
|
+
SkiaViewApi.setJsiProperty === null ||
|
87
|
+
SkiaViewApi.callJsiMethod === null ||
|
88
|
+
SkiaViewApi.registerValuesInView === null ||
|
89
|
+
SkiaViewApi.requestRedraw === null ||
|
90
|
+
SkiaViewApi.makeImageSnapshot === null
|
102
91
|
) {
|
103
|
-
throw Error("Skia Api
|
92
|
+
throw Error("Skia View Api was not found.");
|
104
93
|
}
|
105
94
|
};
|
package/src/views/types.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { ViewProps } from "react-native";
|
2
2
|
|
3
|
-
import type { SkImage, SkRect
|
3
|
+
import type { SkCanvas, SkImage, SkRect } from "../skia/types";
|
4
4
|
import type { SkiaValue } from "../values";
|
5
5
|
|
6
6
|
export type DrawMode = "continuous" | "default";
|
@@ -58,17 +58,18 @@ export interface ValueListener {
|
|
58
58
|
}
|
59
59
|
|
60
60
|
export interface ISkiaViewApi {
|
61
|
-
|
62
|
-
|
63
|
-
setDrawCallback: (
|
61
|
+
setJsiProperty: <T>(nativeId: number, name: string, value: T) => void;
|
62
|
+
callJsiMethod: <T extends Array<unknown>>(
|
64
63
|
nativeId: number,
|
65
|
-
|
64
|
+
name: string,
|
65
|
+
...args: T
|
66
66
|
) => void;
|
67
|
-
setDrawMode: (nativeId: number, mode: DrawMode) => void;
|
68
67
|
registerValuesInView: (
|
69
68
|
nativeId: number,
|
70
69
|
values: SkiaValue<unknown>[]
|
71
70
|
) => () => void;
|
71
|
+
requestRedraw: (nativeId: number) => void;
|
72
|
+
makeImageSnapshot: (nativeId: number, rect?: SkRect) => SkImage;
|
72
73
|
}
|
73
74
|
|
74
75
|
export interface SkiaViewProps extends ViewProps {
|