@shopify/react-native-skia 1.5.8 → 1.5.9
Sign up to get free protection for your applications and to get access to all the features.
- package/android/CMakeLists.txt +0 -1
- package/android/cpp/jni/JniPlatformContext.cpp +0 -49
- package/android/cpp/jni/include/JniPlatformContext.h +1 -17
- package/android/cpp/jni/include/JniSkiaBaseView.h +0 -2
- package/android/cpp/jni/include/JniSkiaDomView.h +0 -3
- package/android/cpp/jni/include/JniSkiaManager.h +0 -2
- package/android/cpp/jni/include/JniSkiaPictureView.h +0 -3
- package/android/cpp/rnskia-android/MainThreadDispatcher.h +69 -0
- package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +4 -11
- package/android/cpp/rnskia-android/RNSkAndroidView.h +3 -13
- package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp +0 -1
- package/android/src/main/java/com/shopify/reactnative/skia/PlatformContext.java +0 -85
- package/android/src/main/java/com/shopify/reactnative/skia/RNSkiaModule.java +1 -21
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaManager.java +0 -4
- package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaDomViewManagerDelegate.java +1 -4
- package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaDomViewManagerInterface.java +0 -1
- package/cpp/rnskia/RNSkManager.cpp +2 -3
- package/cpp/rnskia/RNSkPlatformContext.h +2 -114
- package/cpp/rnskia/RNSkView.h +16 -75
- package/ios/RNSkia-iOS/RNSkiOSPlatformContext.h +1 -10
- package/ios/RNSkia-iOS/RNSkiOSPlatformContext.mm +0 -16
- package/ios/RNSkia-iOS/SkiaDomView.mm +0 -1
- package/ios/RNSkia-iOS/SkiaDomViewManager.mm +0 -6
- package/ios/RNSkia-iOS/SkiaPictureView.mm +0 -1
- package/ios/RNSkia-iOS/SkiaPictureViewManager.mm +0 -6
- package/ios/RNSkia-iOS/SkiaUIView.h +0 -1
- package/ios/RNSkia-iOS/SkiaUIView.mm +1 -14
- package/lib/commonjs/renderer/Canvas.d.ts +1 -0
- package/lib/commonjs/renderer/Canvas.js +5 -5
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.d.ts +0 -1
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js.map +1 -1
- package/lib/commonjs/views/SkiaBaseWebView.d.ts +1 -12
- package/lib/commonjs/views/SkiaBaseWebView.js +1 -19
- package/lib/commonjs/views/SkiaBaseWebView.js.map +1 -1
- package/lib/commonjs/views/SkiaDomView.d.ts +8 -1
- package/lib/commonjs/views/SkiaDomView.js +14 -2
- package/lib/commonjs/views/SkiaDomView.js.map +1 -1
- package/lib/commonjs/views/SkiaDomView.web.d.ts +3 -3
- package/lib/commonjs/views/SkiaDomView.web.js.map +1 -1
- package/lib/commonjs/views/SkiaJSDomView.d.ts +12 -6
- package/lib/commonjs/views/SkiaJSDomView.js +12 -3
- package/lib/commonjs/views/SkiaJSDomView.js.map +1 -1
- package/lib/commonjs/views/SkiaPictureView.d.ts +8 -1
- package/lib/commonjs/views/SkiaPictureView.js +14 -1
- package/lib/commonjs/views/SkiaPictureView.js.map +1 -1
- package/lib/commonjs/views/SkiaPictureView.web.d.ts +3 -3
- package/lib/commonjs/views/SkiaPictureView.web.js.map +1 -1
- package/lib/commonjs/views/types.d.ts +2 -12
- package/lib/commonjs/views/types.js.map +1 -1
- package/lib/module/renderer/Canvas.d.ts +1 -0
- package/lib/module/renderer/Canvas.js +5 -5
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/specs/SkiaPictureViewNativeComponent.d.ts +0 -1
- package/lib/module/specs/SkiaPictureViewNativeComponent.js.map +1 -1
- package/lib/module/views/SkiaBaseWebView.d.ts +1 -12
- package/lib/module/views/SkiaBaseWebView.js +1 -19
- package/lib/module/views/SkiaBaseWebView.js.map +1 -1
- package/lib/module/views/SkiaDomView.d.ts +8 -1
- package/lib/module/views/SkiaDomView.js +14 -2
- package/lib/module/views/SkiaDomView.js.map +1 -1
- package/lib/module/views/SkiaDomView.web.d.ts +3 -3
- package/lib/module/views/SkiaDomView.web.js.map +1 -1
- package/lib/module/views/SkiaJSDomView.d.ts +12 -6
- package/lib/module/views/SkiaJSDomView.js +12 -3
- package/lib/module/views/SkiaJSDomView.js.map +1 -1
- package/lib/module/views/SkiaPictureView.d.ts +8 -1
- package/lib/module/views/SkiaPictureView.js +14 -1
- package/lib/module/views/SkiaPictureView.js.map +1 -1
- package/lib/module/views/SkiaPictureView.web.d.ts +3 -3
- package/lib/module/views/SkiaPictureView.web.js.map +1 -1
- package/lib/module/views/types.d.ts +2 -12
- package/lib/module/views/types.js.map +1 -1
- package/lib/typescript/lib/commonjs/views/SkiaBaseWebView.d.ts +0 -11
- package/lib/typescript/lib/commonjs/views/SkiaDomView.d.ts +3 -0
- package/lib/typescript/lib/commonjs/views/SkiaJSDomView.d.ts +2 -0
- package/lib/typescript/lib/commonjs/views/SkiaPictureView.d.ts +3 -0
- package/lib/typescript/lib/module/views/SkiaBaseWebView.d.ts +0 -11
- package/lib/typescript/lib/module/views/SkiaDomView.d.ts +3 -0
- package/lib/typescript/lib/module/views/SkiaJSDomView.d.ts +2 -0
- package/lib/typescript/lib/module/views/SkiaPictureView.d.ts +3 -0
- package/lib/typescript/src/renderer/Canvas.d.ts +1 -0
- package/lib/typescript/src/specs/SkiaPictureViewNativeComponent.d.ts +0 -1
- package/lib/typescript/src/views/SkiaBaseWebView.d.ts +1 -12
- package/lib/typescript/src/views/SkiaDomView.d.ts +8 -1
- package/lib/typescript/src/views/SkiaDomView.web.d.ts +3 -3
- package/lib/typescript/src/views/SkiaJSDomView.d.ts +12 -6
- package/lib/typescript/src/views/SkiaPictureView.d.ts +8 -1
- package/lib/typescript/src/views/SkiaPictureView.web.d.ts +3 -3
- package/lib/typescript/src/views/types.d.ts +2 -12
- package/package.json +1 -1
- package/src/renderer/Canvas.tsx +4 -3
- package/src/specs/SkiaPictureViewNativeComponent.ts +0 -1
- package/src/views/SkiaBaseWebView.tsx +3 -19
- package/src/views/SkiaDomView.tsx +23 -4
- package/src/views/SkiaDomView.web.tsx +3 -3
- package/src/views/SkiaJSDomView.tsx +30 -9
- package/src/views/SkiaPictureView.tsx +22 -2
- package/src/views/SkiaPictureView.web.tsx +3 -3
- package/src/views/types.ts +2 -13
- package/cpp/rnskia/RNSkDispatchQueue.cpp +0 -73
- package/cpp/rnskia/RNSkDispatchQueue.h +0 -49
- package/ios/RNSkia-iOS/DisplayLink.h +0 -17
- package/ios/RNSkia-iOS/DisplayLink.mm +0 -41
@@ -1,13 +1,12 @@
|
|
1
1
|
import React from "react";
|
2
2
|
import type { SkRect, SkCanvas } from "../skia/types";
|
3
|
-
import type {
|
3
|
+
import type { SkiaBaseViewProps } from "./types";
|
4
4
|
export declare abstract class SkiaBaseWebView<TProps extends SkiaBaseViewProps> extends React.Component<TProps> {
|
5
5
|
constructor(props: TProps);
|
6
6
|
private _surface;
|
7
7
|
private _unsubscriptions;
|
8
8
|
private _canvas;
|
9
9
|
private _canvasRef;
|
10
|
-
private _mode;
|
11
10
|
private _redrawRequests;
|
12
11
|
private requestId;
|
13
12
|
protected width: number;
|
@@ -36,16 +35,6 @@ export declare abstract class SkiaBaseWebView<TProps extends SkiaBaseViewProps>
|
|
36
35
|
*/
|
37
36
|
private tick;
|
38
37
|
redraw(): void;
|
39
|
-
/**
|
40
|
-
* Updates the drawing mode for the skia view. This is the same
|
41
|
-
* as declaratively setting the mode property on the SkiaView.
|
42
|
-
* There are two drawing modes, "continuous" and "default",
|
43
|
-
* where the continuous mode will continuously redraw the view and
|
44
|
-
* the default mode will only redraw when any of the regular react
|
45
|
-
* properties are changed like size and margins.
|
46
|
-
* @param mode Drawing mode to use.
|
47
|
-
*/
|
48
|
-
setDrawMode(mode: DrawMode): void;
|
49
38
|
private onLayout;
|
50
39
|
render(): React.JSX.Element;
|
51
40
|
}
|
@@ -9,19 +9,16 @@ import { Platform } from "../Platform";
|
|
9
9
|
const pd = Platform.PixelRatio;
|
10
10
|
export class SkiaBaseWebView extends React.Component {
|
11
11
|
constructor(props) {
|
12
|
-
var _props$mode;
|
13
12
|
super(props);
|
14
13
|
_defineProperty(this, "_surface", null);
|
15
14
|
_defineProperty(this, "_unsubscriptions", []);
|
16
15
|
_defineProperty(this, "_canvas", null);
|
17
16
|
_defineProperty(this, "_canvasRef", /*#__PURE__*/React.createRef());
|
18
|
-
_defineProperty(this, "_mode", void 0);
|
19
17
|
_defineProperty(this, "_redrawRequests", 0);
|
20
18
|
_defineProperty(this, "requestId", 0);
|
21
19
|
_defineProperty(this, "width", 0);
|
22
20
|
_defineProperty(this, "height", 0);
|
23
21
|
_defineProperty(this, "onLayout", this.onLayoutEvent.bind(this));
|
24
|
-
this._mode = (_props$mode = props.mode) !== null && _props$mode !== void 0 ? _props$mode : "default";
|
25
22
|
}
|
26
23
|
unsubscribeAll() {
|
27
24
|
this._unsubscriptions.forEach(u => u());
|
@@ -98,7 +95,7 @@ export class SkiaBaseWebView extends React.Component {
|
|
98
95
|
* Sends a redraw request to the native SkiaView.
|
99
96
|
*/
|
100
97
|
tick() {
|
101
|
-
if (this.
|
98
|
+
if (this._redrawRequests > 0) {
|
102
99
|
this._redrawRequests = 0;
|
103
100
|
if (this._canvas) {
|
104
101
|
var _this$_surface3;
|
@@ -116,23 +113,8 @@ export class SkiaBaseWebView extends React.Component {
|
|
116
113
|
redraw() {
|
117
114
|
this._redrawRequests++;
|
118
115
|
}
|
119
|
-
|
120
|
-
/**
|
121
|
-
* Updates the drawing mode for the skia view. This is the same
|
122
|
-
* as declaratively setting the mode property on the SkiaView.
|
123
|
-
* There are two drawing modes, "continuous" and "default",
|
124
|
-
* where the continuous mode will continuously redraw the view and
|
125
|
-
* the default mode will only redraw when any of the regular react
|
126
|
-
* properties are changed like size and margins.
|
127
|
-
* @param mode Drawing mode to use.
|
128
|
-
*/
|
129
|
-
setDrawMode(mode) {
|
130
|
-
this._mode = mode;
|
131
|
-
this.tick();
|
132
|
-
}
|
133
116
|
render() {
|
134
117
|
const {
|
135
|
-
mode,
|
136
118
|
debug = false,
|
137
119
|
...viewProps
|
138
120
|
} = this.props;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["React","JsiSkSurface","Platform","pd","PixelRatio","SkiaBaseWebView","Component","constructor","props","
|
1
|
+
{"version":3,"names":["React","JsiSkSurface","Platform","pd","PixelRatio","SkiaBaseWebView","Component","constructor","props","_defineProperty","createRef","onLayoutEvent","bind","unsubscribeAll","_unsubscriptions","forEach","u","evt","CanvasKit","global","canvas","_canvasRef","current","width","clientWidth","height","clientHeight","surface","MakeWebGLCanvasSurface","Error","_surface","_canvas","getCanvas","redraw","onLayout","getSize","componentDidMount","tick","componentDidUpdate","componentWillUnmount","cancelAnimationFrame","requestId","_this$_canvasRef$curr","getContext","getExtension","loseContext","makeImageSnapshot","rect","_this$_surface","_this$_surface2","clear","TRANSPARENT","renderInCanvas","ref","flush","_redrawRequests","_this$_surface3","Float32Array","of","save","scale","restore","requestAnimationFrame","render","debug","viewProps","createElement","View","_extends","style","display","flex"],"sources":["SkiaBaseWebView.tsx"],"sourcesContent":["/* global HTMLCanvasElement */\nimport React from \"react\";\nimport type { LayoutChangeEvent } from \"react-native\";\n\nimport type { SkRect, SkCanvas } from \"../skia/types\";\nimport { JsiSkSurface } from \"../skia/web/JsiSkSurface\";\nimport { Platform } from \"../Platform\";\n\nimport type { SkiaBaseViewProps } from \"./types\";\n\nconst pd = Platform.PixelRatio;\n\nexport abstract class SkiaBaseWebView<\n TProps extends SkiaBaseViewProps\n> extends React.Component<TProps> {\n constructor(props: TProps) {\n super(props);\n }\n\n private _surface: JsiSkSurface | null = null;\n private _unsubscriptions: Array<() => void> = [];\n private _canvas: SkCanvas | null = null;\n private _canvasRef = React.createRef<HTMLCanvasElement>();\n private _redrawRequests = 0;\n private requestId = 0;\n\n protected width = 0;\n protected height = 0;\n\n private unsubscribeAll() {\n this._unsubscriptions.forEach((u) => u());\n this._unsubscriptions = [];\n }\n\n private onLayoutEvent(evt: LayoutChangeEvent) {\n const { CanvasKit } = global;\n // Reset canvas / surface on layout change\n const canvas = this._canvasRef.current;\n if (canvas) {\n this.width = canvas.clientWidth;\n this.height = canvas.clientHeight;\n canvas.width = this.width * pd;\n canvas.height = this.height * pd;\n const surface = CanvasKit.MakeWebGLCanvasSurface(canvas);\n if (!surface) {\n throw new Error(\"Could not create surface\");\n }\n this._surface = new JsiSkSurface(CanvasKit, surface);\n this._canvas = this._surface.getCanvas();\n this.redraw();\n }\n // Call onLayout callback if it exists\n if (this.props.onLayout) {\n this.props.onLayout(evt);\n }\n }\n\n protected getSize() {\n return { width: this.width, height: this.height };\n }\n\n componentDidMount() {\n // Start render loop\n this.tick();\n }\n\n componentDidUpdate() {\n this.redraw();\n }\n\n componentWillUnmount() {\n this.unsubscribeAll();\n cancelAnimationFrame(this.requestId);\n // eslint-disable-next-line max-len\n // https://stackoverflow.com/questions/23598471/how-do-i-clean-up-and-unload-a-webgl-canvas-context-from-gpu-after-use\n // https://developer.mozilla.org/en-US/docs/Web/API/WEBGL_lose_context\n // We delete the context, only if the context has been intialized\n if (this._surface) {\n this._canvasRef.current\n ?.getContext(\"webgl2\")\n ?.getExtension(\"WEBGL_lose_context\")\n ?.loseContext();\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 this._canvas!.clear(CanvasKit.TRANSPARENT);\n this.renderInCanvas(this._canvas!);\n this._surface?.ref.flush();\n return this._surface?.makeImageSnapshot(rect);\n }\n\n /**\n * Override to render\n */\n protected abstract renderInCanvas(canvas: SkCanvas): void;\n\n /**\n * Sends a redraw request to the native SkiaView.\n */\n private tick() {\n if (this._redrawRequests > 0) {\n this._redrawRequests = 0;\n if (this._canvas) {\n const canvas = this._canvas!;\n canvas.clear(Float32Array.of(0, 0, 0, 0));\n canvas.save();\n canvas.scale(pd, pd);\n this.renderInCanvas(canvas);\n canvas.restore();\n this._surface?.ref.flush();\n }\n }\n this.requestId = requestAnimationFrame(this.tick.bind(this));\n }\n\n public redraw() {\n this._redrawRequests++;\n }\n\n private onLayout = this.onLayoutEvent.bind(this);\n\n render() {\n const { debug = false, ...viewProps } = this.props;\n return (\n <Platform.View {...viewProps} onLayout={this.onLayout}>\n <canvas ref={this._canvasRef} style={{ display: \"flex\", flex: 1 }} />\n </Platform.View>\n );\n }\n}\n"],"mappings":";;;;AAAA;AACA,OAAOA,KAAK,MAAM,OAAO;AAIzB,SAASC,YAAY,QAAQ,0BAA0B;AACvD,SAASC,QAAQ,QAAQ,aAAa;AAItC,MAAMC,EAAE,GAAGD,QAAQ,CAACE,UAAU;AAE9B,OAAO,MAAeC,eAAe,SAE3BL,KAAK,CAACM,SAAS,CAAS;EAChCC,WAAWA,CAACC,KAAa,EAAE;IACzB,KAAK,CAACA,KAAK,CAAC;IAACC,eAAA,mBAGyB,IAAI;IAAAA,eAAA,2BACE,EAAE;IAAAA,eAAA,kBACb,IAAI;IAAAA,eAAA,kCAClBT,KAAK,CAACU,SAAS,CAAoB,CAAC;IAAAD,eAAA,0BAC/B,CAAC;IAAAA,eAAA,oBACP,CAAC;IAAAA,eAAA,gBAEH,CAAC;IAAAA,eAAA,iBACA,CAAC;IAAAA,eAAA,mBAkGD,IAAI,CAACE,aAAa,CAACC,IAAI,CAAC,IAAI,CAAC;EA5GhD;EAYQC,cAAcA,CAAA,EAAG;IACvB,IAAI,CAACC,gBAAgB,CAACC,OAAO,CAAEC,CAAC,IAAKA,CAAC,CAAC,CAAC,CAAC;IACzC,IAAI,CAACF,gBAAgB,GAAG,EAAE;EAC5B;EAEQH,aAAaA,CAACM,GAAsB,EAAE;IAC5C,MAAM;MAAEC;IAAU,CAAC,GAAGC,MAAM;IAC5B;IACA,MAAMC,MAAM,GAAG,IAAI,CAACC,UAAU,CAACC,OAAO;IACtC,IAAIF,MAAM,EAAE;MACV,IAAI,CAACG,KAAK,GAAGH,MAAM,CAACI,WAAW;MAC/B,IAAI,CAACC,MAAM,GAAGL,MAAM,CAACM,Y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,SAAS,GAAGqB,qBAAqB,CAAC,IAAI,CAACzB,IAAI,CAACzB,IAAI,CAAC,IAAI,CAAC,CAAC;EAC9D;EAEOqB,MAAMA,CAAA,EAAG;IACd,IAAI,CAACsB,eAAe,EAAE;EACxB;EAIAQ,MAAMA,CAAA,EAAG;IACP,MAAM;MAAEC,KAAK,GAAG,KAAK;MAAE,GAAGC;IAAU,CAAC,GAAG,IAAI,CAACzD,KAAK;IAClD,oBACER,KAAA,CAAAkE,aAAA,CAAChE,QAAQ,CAACiE,IAAI,EAAAC,QAAA,KAAKH,SAAS;MAAE/B,QAAQ,EAAE,IAAI,CAACA;IAAS,iBACpDlC,KAAA,CAAAkE,aAAA;MAAQb,GAAG,EAAE,IAAI,CAAChC,UAAW;MAACgD,KAAK,EAAE;QAAEC,OAAO,EAAE,MAAM;QAAEC,IAAI,EAAE;MAAE;IAAE,CAAE,CACvD,CAAC;EAEpB;AACF","ignoreList":[]}
|
@@ -1,11 +1,17 @@
|
|
1
1
|
import React from "react";
|
2
2
|
import type { SkRect } from "../skia/types";
|
3
|
-
import type {
|
3
|
+
import type { SkiaDomViewNativeProps } from "./types";
|
4
|
+
interface SkiaDomViewProps extends SkiaDomViewNativeProps {
|
5
|
+
mode?: "default" | "continuous";
|
6
|
+
}
|
4
7
|
export declare class SkiaDomView extends React.Component<SkiaDomViewProps> {
|
5
8
|
constructor(props: SkiaDomViewProps);
|
6
9
|
private _nativeId;
|
10
|
+
private requestId;
|
7
11
|
get nativeId(): number;
|
8
12
|
componentDidUpdate(prevProps: SkiaDomViewProps): void;
|
13
|
+
componentWillUnmount(): void;
|
14
|
+
private tick;
|
9
15
|
/**
|
10
16
|
* Creates a snapshot from the canvas in the surface
|
11
17
|
* @param rect Rect to use as bounds. Optional.
|
@@ -24,3 +30,4 @@ export declare class SkiaDomView extends React.Component<SkiaDomViewProps> {
|
|
24
30
|
redraw(): void;
|
25
31
|
render(): React.JSX.Element;
|
26
32
|
}
|
33
|
+
export {};
|
@@ -14,6 +14,7 @@ export class SkiaDomView extends React.Component {
|
|
14
14
|
constructor(props) {
|
15
15
|
super(props);
|
16
16
|
_defineProperty(this, "_nativeId", void 0);
|
17
|
+
_defineProperty(this, "requestId", 0);
|
17
18
|
this._nativeId = SkiaViewNativeId.current++;
|
18
19
|
const {
|
19
20
|
root,
|
@@ -27,6 +28,7 @@ export class SkiaDomView extends React.Component {
|
|
27
28
|
assertSkiaViewApi();
|
28
29
|
SkiaViewApi.setJsiProperty(this._nativeId, "onSize", onSize);
|
29
30
|
}
|
31
|
+
this.tick();
|
30
32
|
}
|
31
33
|
get nativeId() {
|
32
34
|
return this._nativeId;
|
@@ -44,6 +46,18 @@ export class SkiaDomView extends React.Component {
|
|
44
46
|
assertSkiaViewApi();
|
45
47
|
SkiaViewApi.setJsiProperty(this._nativeId, "onSize", onSize);
|
46
48
|
}
|
49
|
+
this.tick();
|
50
|
+
}
|
51
|
+
componentWillUnmount() {
|
52
|
+
if (this.requestId) {
|
53
|
+
cancelAnimationFrame(this.requestId);
|
54
|
+
}
|
55
|
+
}
|
56
|
+
tick() {
|
57
|
+
this.redraw();
|
58
|
+
if (this.props.mode === "continuous") {
|
59
|
+
this.requestId = requestAnimationFrame(this.tick.bind(this));
|
60
|
+
}
|
47
61
|
}
|
48
62
|
|
49
63
|
/**
|
@@ -75,14 +89,12 @@ export class SkiaDomView extends React.Component {
|
|
75
89
|
}
|
76
90
|
render() {
|
77
91
|
const {
|
78
|
-
mode,
|
79
92
|
debug = false,
|
80
93
|
...viewProps
|
81
94
|
} = this.props;
|
82
95
|
return /*#__PURE__*/React.createElement(NativeSkiaDomView, _extends({
|
83
96
|
collapsable: false,
|
84
97
|
nativeID: `${this._nativeId}`,
|
85
|
-
mode: mode,
|
86
98
|
debug: debug
|
87
99
|
}, viewProps));
|
88
100
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["React","Platform","SkiaDomViewNativeComponent","SkiaViewApi","SkiaViewNativeId","NativeSkiaDomView","OS","SkiaDomView","Component","constructor","props","_defineProperty","_nativeId","current","root","onSize","assertSkiaViewApi","setJsiProperty","nativeId","componentDidUpdate","prevProps","
|
1
|
+
{"version":3,"names":["React","Platform","SkiaDomViewNativeComponent","SkiaViewApi","SkiaViewNativeId","NativeSkiaDomView","OS","SkiaDomView","Component","constructor","props","_defineProperty","_nativeId","current","root","onSize","assertSkiaViewApi","setJsiProperty","tick","nativeId","componentDidUpdate","prevProps","componentWillUnmount","requestId","cancelAnimationFrame","redraw","mode","requestAnimationFrame","bind","makeImageSnapshot","rect","makeImageSnapshotAsync","requestRedraw","render","debug","viewProps","createElement","_extends","collapsable","nativeID","Error"],"sources":["SkiaDomView.tsx"],"sourcesContent":["import React from \"react\";\nimport type { HostComponent } from \"react-native\";\n\nimport type { SkRect } from \"../skia/types\";\nimport { Platform } from \"../Platform\";\nimport SkiaDomViewNativeComponent from \"../specs/SkiaDomViewNativeComponent\";\n\nimport { SkiaViewApi } from \"./api\";\nimport type { SkiaDomViewNativeProps } from \"./types\";\nimport { SkiaViewNativeId } from \"./SkiaViewNativeId\";\n\nconst NativeSkiaDomView: HostComponent<SkiaDomViewNativeProps> =\n Platform.OS !== \"web\"\n ? SkiaDomViewNativeComponent\n : // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (null as any);\n\ninterface SkiaDomViewProps extends SkiaDomViewNativeProps {\n mode?: \"default\" | \"continuous\";\n}\n\nexport class SkiaDomView extends React.Component<SkiaDomViewProps> {\n constructor(props: SkiaDomViewProps) {\n super(props);\n this._nativeId = SkiaViewNativeId.current++;\n const { root, onSize } = props;\n if (root) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"root\", root);\n }\n if (onSize) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"onSize\", onSize);\n }\n this.tick();\n }\n\n private _nativeId: number;\n private requestId = 0;\n\n public get nativeId() {\n return this._nativeId;\n }\n\n componentDidUpdate(prevProps: SkiaDomViewProps) {\n const { root, onSize } = this.props;\n if (root !== prevProps.root) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"root\", root);\n }\n if (onSize !== prevProps.onSize) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"onSize\", onSize);\n }\n this.tick();\n }\n\n componentWillUnmount(): void {\n if (this.requestId) {\n cancelAnimationFrame(this.requestId);\n }\n }\n\n private tick() {\n this.redraw();\n if (this.props.mode === \"continuous\") {\n this.requestId = requestAnimationFrame(this.tick.bind(this));\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 * 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 makeImageSnapshotAsync(rect?: SkRect) {\n assertSkiaViewApi();\n return SkiaViewApi.makeImageSnapshotAsync(this._nativeId, rect);\n }\n\n /**\n * Sends a redraw request to the native SkiaView.\n */\n public redraw() {\n assertSkiaViewApi();\n SkiaViewApi.requestRedraw(this._nativeId);\n }\n\n render() {\n const { debug = false, ...viewProps } = this.props;\n return (\n <NativeSkiaDomView\n collapsable={false}\n nativeID={`${this._nativeId}`}\n debug={debug}\n {...viewProps}\n />\n );\n }\n}\n\nconst assertSkiaViewApi = () => {\n if (\n SkiaViewApi === null ||\n SkiaViewApi.setJsiProperty === null ||\n SkiaViewApi.requestRedraw === null ||\n SkiaViewApi.makeImageSnapshot === null\n ) {\n throw Error(\"Skia View Api was not found.\");\n }\n};\n"],"mappings":";;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AAIzB,SAASC,QAAQ,QAAQ,aAAa;AACtC,OAAOC,0BAA0B,MAAM,qCAAqC;AAE5E,SAASC,WAAW,QAAQ,OAAO;AAEnC,SAASC,gBAAgB,QAAQ,oBAAoB;AAErD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W,KAAK,IAAI,IACpBA,WAAW,CAACc,cAAc,KAAK,IAAI,IACnCd,WAAW,CAAC6B,aAAa,KAAK,IAAI,IAClC7B,WAAW,CAAC0B,iBAAiB,KAAK,IAAI,EACtC;IACA,MAAMW,KAAK,CAAC,8BAA8B,CAAC;EAC7C;AACF,CAAC","ignoreList":[]}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import type { SkCanvas } from "../skia/types";
|
2
2
|
import { SkiaBaseWebView } from "./SkiaBaseWebView";
|
3
|
-
import type {
|
4
|
-
export declare class SkiaDomView extends SkiaBaseWebView<
|
5
|
-
constructor(props:
|
3
|
+
import type { SkiaDomViewNativeProps } from "./types";
|
4
|
+
export declare class SkiaDomView extends SkiaBaseWebView<SkiaDomViewNativeProps> {
|
5
|
+
constructor(props: SkiaDomViewNativeProps);
|
6
6
|
protected renderInCanvas(canvas: SkCanvas): void;
|
7
7
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["Skia","JsiDrawingContext","SkiaBaseWebView","SkiaDomView","constructor","props","renderInCanvas","canvas","onSize","width","height","getSize","value","root","ctx","render"],"sources":["SkiaDomView.web.tsx"],"sourcesContent":["import { Skia } from \"../skia\";\nimport type { SkCanvas } from \"../skia/types\";\nimport { JsiDrawingContext } from \"../dom/types/DrawingContext\";\n\nimport { SkiaBaseWebView } from \"./SkiaBaseWebView\";\nimport type {
|
1
|
+
{"version":3,"names":["Skia","JsiDrawingContext","SkiaBaseWebView","SkiaDomView","constructor","props","renderInCanvas","canvas","onSize","width","height","getSize","value","root","ctx","render"],"sources":["SkiaDomView.web.tsx"],"sourcesContent":["import { Skia } from \"../skia\";\nimport type { SkCanvas } from \"../skia/types\";\nimport { JsiDrawingContext } from \"../dom/types/DrawingContext\";\n\nimport { SkiaBaseWebView } from \"./SkiaBaseWebView\";\nimport type { SkiaDomViewNativeProps } from \"./types\";\n\nexport class SkiaDomView extends SkiaBaseWebView<SkiaDomViewNativeProps> {\n constructor(props: SkiaDomViewNativeProps) {\n super(props);\n }\n\n protected renderInCanvas(canvas: SkCanvas): void {\n if (this.props.onSize) {\n const { width, height } = this.getSize();\n this.props.onSize.value = { width, height };\n }\n if (this.props.root) {\n const ctx = new JsiDrawingContext(Skia, canvas);\n this.props.root.render(ctx);\n }\n }\n}\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,SAAS;AAE9B,SAASC,iBAAiB,QAAQ,6BAA6B;AAE/D,SAASC,eAAe,QAAQ,mBAAmB;AAGnD,OAAO,MAAMC,WAAW,SAASD,eAAe,CAAyB;EACvEE,WAAWA,CAACC,KAA6B,EAAE;IACzC,KAAK,CAACA,KAAK,CAAC;EACd;EAEUC,cAAcA,CAACC,MAAgB,EAAQ;IAC/C,IAAI,IAAI,CAACF,KAAK,CAACG,MAAM,EAAE;MACrB,MAAM;QAAEC,KAAK;QAAEC;MAAO,CAAC,GAAG,IAAI,CAACC,OAAO,CAAC,CAAC;MACxC,IAAI,CAACN,KAAK,CAACG,MAAM,CAACI,KAAK,GAAG;QAAEH,KAAK;QAAEC;MAAO,CAAC;IAC7C;IACA,IAAI,IAAI,CAACL,KAAK,CAACQ,IAAI,EAAE;MACnB,MAAMC,GAAG,GAAG,IAAIb,iBAAiB,CAACD,IAAI,EAAEO,MAAM,CAAC;MAC/C,IAAI,CAACF,KAAK,CAACQ,IAAI,CAACE,MAAM,CAACD,GAAG,CAAC;IAC7B;EACF;AACF","ignoreList":[]}
|
@@ -1,13 +1,18 @@
|
|
1
1
|
import React from "react";
|
2
2
|
import type { Skia, SkRect } from "../skia/types";
|
3
|
-
import type {
|
4
|
-
|
3
|
+
import type { SkiaDomViewNativeProps } from "./types";
|
4
|
+
interface SkiaDomViewProps extends SkiaDomViewNativeProps {
|
5
|
+
mode?: "default" | "continuous";
|
6
|
+
}
|
7
|
+
type SkiaJSDomViewProps = SkiaDomViewProps & {
|
5
8
|
Skia: Skia;
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
9
|
+
mode?: "default" | "continuous";
|
10
|
+
};
|
11
|
+
export declare class SkiaJSDomView extends React.Component<SkiaJSDomViewProps> {
|
12
|
+
constructor(props: SkiaJSDomViewProps);
|
10
13
|
private _nativeId;
|
14
|
+
private requestId;
|
15
|
+
private tick;
|
11
16
|
get nativeId(): number;
|
12
17
|
componentDidUpdate(prevProps: SkiaDomViewProps & {
|
13
18
|
Skia: Skia;
|
@@ -29,3 +34,4 @@ export declare class SkiaJSDomView extends React.Component<SkiaDomViewProps & {
|
|
29
34
|
componentWillUnmount(): void;
|
30
35
|
render(): React.JSX.Element;
|
31
36
|
}
|
37
|
+
export {};
|
@@ -15,6 +15,7 @@ export class SkiaJSDomView extends React.Component {
|
|
15
15
|
constructor(props) {
|
16
16
|
super(props);
|
17
17
|
_defineProperty(this, "_nativeId", void 0);
|
18
|
+
_defineProperty(this, "requestId", 0);
|
18
19
|
this._nativeId = SkiaViewNativeId.current++;
|
19
20
|
const {
|
20
21
|
root,
|
@@ -28,6 +29,13 @@ export class SkiaJSDomView extends React.Component {
|
|
28
29
|
assertSkiaViewApi();
|
29
30
|
SkiaViewApi.setJsiProperty(this._nativeId, "onSize", onSize);
|
30
31
|
}
|
32
|
+
this.tick();
|
33
|
+
}
|
34
|
+
tick() {
|
35
|
+
this.redraw();
|
36
|
+
if (this.props.mode === "continuous") {
|
37
|
+
this.requestId = requestAnimationFrame(this.tick.bind(this));
|
38
|
+
}
|
31
39
|
}
|
32
40
|
get nativeId() {
|
33
41
|
return this._nativeId;
|
@@ -45,6 +53,7 @@ export class SkiaJSDomView extends React.Component {
|
|
45
53
|
assertSkiaViewApi();
|
46
54
|
SkiaViewApi.setJsiProperty(this._nativeId, "onSize", onSize);
|
47
55
|
}
|
56
|
+
this.tick();
|
48
57
|
}
|
49
58
|
|
50
59
|
/**
|
@@ -63,7 +72,6 @@ export class SkiaJSDomView extends React.Component {
|
|
63
72
|
redraw() {
|
64
73
|
assertSkiaViewApi();
|
65
74
|
this.draw();
|
66
|
-
//SkiaViewApi.requestRedraw(this._nativeId);
|
67
75
|
}
|
68
76
|
draw() {
|
69
77
|
const {
|
@@ -87,17 +95,18 @@ export class SkiaJSDomView extends React.Component {
|
|
87
95
|
componentWillUnmount() {
|
88
96
|
assertSkiaViewApi();
|
89
97
|
SkiaViewApi.setJsiProperty(this._nativeId, "picture", null);
|
98
|
+
if (this.requestId) {
|
99
|
+
cancelAnimationFrame(this.requestId);
|
100
|
+
}
|
90
101
|
}
|
91
102
|
render() {
|
92
103
|
const {
|
93
|
-
mode,
|
94
104
|
debug = false,
|
95
105
|
...viewProps
|
96
106
|
} = this.props;
|
97
107
|
return /*#__PURE__*/React.createElement(NativeSkiaPictureView, _extends({
|
98
108
|
collapsable: false,
|
99
109
|
nativeID: `${this._nativeId}`,
|
100
|
-
mode: mode,
|
101
110
|
debug: debug
|
102
111
|
}, viewProps));
|
103
112
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["React","Platform","SkiaPictureViewNativeComponent","JsiDrawingContext","SkiaViewApi","SkiaViewNativeId","NativeSkiaPictureView","OS","SkiaJSDomView","Component","constructor","props","_defineProperty","_nativeId","current","root","onSize","assertSkiaViewApi","setJsiProperty","nativeId","componentDidUpdate","prevProps","undefined","draw","makeImageSnapshot","rect","
|
1
|
+
{"version":3,"names":["React","Platform","SkiaPictureViewNativeComponent","JsiDrawingContext","SkiaViewApi","SkiaViewNativeId","NativeSkiaPictureView","OS","SkiaJSDomView","Component","constructor","props","_defineProperty","_nativeId","current","root","onSize","assertSkiaViewApi","setJsiProperty","tick","redraw","mode","requestId","requestAnimationFrame","bind","nativeId","componentDidUpdate","prevProps","undefined","draw","makeImageSnapshot","rect","Skia","rec","PictureRecorder","canvas","beginRecording","ctx","render","picture","finishRecordingAsPicture","componentWillUnmount","cancelAnimationFrame","debug","viewProps","createElement","_extends","collapsable","nativeID","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 {\n SkiaPictureViewNativeProps,\n SkiaDomViewNativeProps,\n} from \"./types\";\nimport { SkiaViewNativeId } from \"./SkiaViewNativeId\";\n\nconst NativeSkiaPictureView: HostComponent<SkiaPictureViewNativeProps> =\n Platform.OS !== \"web\"\n ? SkiaPictureViewNativeComponent\n : // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (null as any);\n\ninterface SkiaDomViewProps extends SkiaDomViewNativeProps {\n mode?: \"default\" | \"continuous\";\n}\n\ntype SkiaJSDomViewProps = SkiaDomViewProps & {\n Skia: Skia;\n mode?: \"default\" | \"continuous\";\n};\n\nexport class SkiaJSDomView extends React.Component<SkiaJSDomViewProps> {\n constructor(props: SkiaJSDomViewProps) {\n super(props);\n this._nativeId = SkiaViewNativeId.current++;\n const { root, onSize } = props;\n if (root) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"root\", root);\n }\n if (onSize) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"onSize\", onSize);\n }\n this.tick();\n }\n\n private _nativeId: number;\n private requestId = 0;\n\n private tick() {\n this.redraw();\n if (this.props.mode === \"continuous\") {\n this.requestId = requestAnimationFrame(this.tick.bind(this));\n }\n }\n\n public get nativeId() {\n return this._nativeId;\n }\n\n componentDidUpdate(prevProps: SkiaDomViewProps & { Skia: Skia }) {\n const { root, onSize } = this.props;\n if (root !== prevProps.root && root !== undefined) {\n assertSkiaViewApi();\n this.draw();\n }\n if (onSize !== prevProps.onSize) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"onSize\", onSize);\n }\n this.tick();\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 }\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 if (this.requestId) {\n cancelAnimationFrame(this.requestId);\n }\n }\n\n render() {\n const { debug = false, ...viewProps } = this.props;\n return (\n <NativeSkiaPictureView\n collapsable={false}\n nativeID={`${this._nativeId}`}\n debug={debug}\n {...viewProps}\n />\n );\n }\n}\n\nconst assertSkiaViewApi = () => {\n if (\n SkiaViewApi === null ||\n SkiaViewApi.setJsiProperty === null ||\n SkiaViewApi.requestRedraw === null ||\n SkiaViewApi.makeImageSnapshot === null\n ) {\n throw Error(\"Skia View Api was not found.\");\n }\n};\n"],"mappings":";;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AAIzB,SAASC,QAAQ,QAAQ,aAAa;AACtC,OAAOC,8BAA8B,MAAM,yCAAyC;AACpF,SAASC,iBAAiB,QAAQ,cAAc;AAEhD,SAASC,WAAW,QAAQ,OAAO;AAKnC,SAASC,gBAAgB,QAAQ,oBAAoB;AAErD,MAAMC,qBAAgE,GACpEL,QAAQ,CAACM,EAAE,KAAK,KAAK,GACjBL,8BAA8B;AAC9B;AACC,IAAY;AAWnB,OAAO,MAAMM,aAAa,SAASR,KAAK,CAACS,SAAS,CAAqB;EACrEC,WAAWA,CAACC,KAAyB,EAAE;IACrC,KAA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D,oBACEX,KAAA,CAAA6C,aAAA,CAACvC,qBAAqB,EAAAwC,QAAA;MACpBC,WAAW,EAAE,KAAM;MACnBC,QAAQ,EAAE,GAAG,IAAI,CAACnC,SAAS,EAAG;MAC9B8B,KAAK,EAAEA;IAAM,GACTC,SAAS,CACd,CAAC;EAEN;AACF;AAEA,MAAM3B,iBAAiB,GAAGA,CAAA,KAAM;EAC9B,IACEb,WAAW,KAAK,IAAI,IACpBA,WAAW,CAACc,cAAc,KAAK,IAAI,IACnCd,WAAW,CAAC6C,aAAa,KAAK,IAAI,IAClC7C,WAAW,CAAC0B,iBAAiB,KAAK,IAAI,EACtC;IACA,MAAMoB,KAAK,CAAC,8BAA8B,CAAC;EAC7C;AACF,CAAC","ignoreList":[]}
|
@@ -1,11 +1,17 @@
|
|
1
1
|
import React from "react";
|
2
2
|
import type { SkRect } from "../skia/types";
|
3
|
-
import type {
|
3
|
+
import type { SkiaPictureViewNativeProps } from "./types";
|
4
|
+
interface SkiaPictureViewProps extends SkiaPictureViewNativeProps {
|
5
|
+
mode?: "default" | "continuous";
|
6
|
+
}
|
4
7
|
export declare class SkiaPictureView extends React.Component<SkiaPictureViewProps> {
|
8
|
+
private requestId;
|
5
9
|
constructor(props: SkiaPictureViewProps);
|
6
10
|
private _nativeId;
|
7
11
|
get nativeId(): number;
|
8
12
|
componentDidUpdate(prevProps: SkiaPictureViewProps): void;
|
13
|
+
componentWillUnmount(): void;
|
14
|
+
private tick;
|
9
15
|
/**
|
10
16
|
* Creates a snapshot from the canvas in the surface
|
11
17
|
* @param rect Rect to use as bounds. Optional.
|
@@ -18,3 +24,4 @@ export declare class SkiaPictureView extends React.Component<SkiaPictureViewProp
|
|
18
24
|
redraw(): void;
|
19
25
|
render(): React.JSX.Element;
|
20
26
|
}
|
27
|
+
export {};
|
@@ -10,6 +10,7 @@ const NativeSkiaPictureView = SkiaPictureViewNativeComponent;
|
|
10
10
|
export class SkiaPictureView extends React.Component {
|
11
11
|
constructor(props) {
|
12
12
|
super(props);
|
13
|
+
_defineProperty(this, "requestId", 0);
|
13
14
|
_defineProperty(this, "_nativeId", void 0);
|
14
15
|
this._nativeId = SkiaViewNativeId.current++;
|
15
16
|
const {
|
@@ -24,6 +25,7 @@ export class SkiaPictureView extends React.Component {
|
|
24
25
|
assertSkiaViewApi();
|
25
26
|
SkiaViewApi.setJsiProperty(this._nativeId, "onSize", onSize);
|
26
27
|
}
|
28
|
+
this.tick();
|
27
29
|
}
|
28
30
|
get nativeId() {
|
29
31
|
return this._nativeId;
|
@@ -41,6 +43,18 @@ export class SkiaPictureView extends React.Component {
|
|
41
43
|
assertSkiaViewApi();
|
42
44
|
SkiaViewApi.setJsiProperty(this._nativeId, "onSize", onSize);
|
43
45
|
}
|
46
|
+
this.tick();
|
47
|
+
}
|
48
|
+
componentWillUnmount() {
|
49
|
+
if (this.requestId) {
|
50
|
+
cancelAnimationFrame(this.requestId);
|
51
|
+
}
|
52
|
+
}
|
53
|
+
tick() {
|
54
|
+
this.redraw();
|
55
|
+
if (this.props.mode === "continuous") {
|
56
|
+
this.requestId = requestAnimationFrame(this.tick.bind(this));
|
57
|
+
}
|
44
58
|
}
|
45
59
|
|
46
60
|
/**
|
@@ -69,7 +83,6 @@ export class SkiaPictureView extends React.Component {
|
|
69
83
|
return /*#__PURE__*/React.createElement(NativeSkiaPictureView, _extends({
|
70
84
|
collapsable: false,
|
71
85
|
nativeID: `${this._nativeId}`,
|
72
|
-
mode: mode !== null && mode !== void 0 ? mode : "default",
|
73
86
|
debug: debug
|
74
87
|
}, viewProps));
|
75
88
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["React","SkiaPictureViewNativeComponent","SkiaViewApi","SkiaViewNativeId","NativeSkiaPictureView","SkiaPictureView","Component","constructor","props","_defineProperty","_nativeId","current","picture","onSize","assertSkiaViewApi","setJsiProperty","nativeId","componentDidUpdate","prevProps","
|
1
|
+
{"version":3,"names":["React","SkiaPictureViewNativeComponent","SkiaViewApi","SkiaViewNativeId","NativeSkiaPictureView","SkiaPictureView","Component","constructor","props","_defineProperty","_nativeId","current","picture","onSize","assertSkiaViewApi","setJsiProperty","tick","nativeId","componentDidUpdate","prevProps","componentWillUnmount","requestId","cancelAnimationFrame","redraw","mode","requestAnimationFrame","bind","makeImageSnapshot","rect","requestRedraw","render","debug","viewProps","createElement","_extends","collapsable","nativeID","Error"],"sources":["SkiaPictureView.tsx"],"sourcesContent":["import React from \"react\";\n\nimport type { SkRect } from \"../skia/types\";\nimport SkiaPictureViewNativeComponent from \"../specs/SkiaPictureViewNativeComponent\";\n\nimport { SkiaViewApi } from \"./api\";\nimport type { SkiaPictureViewNativeProps } from \"./types\";\nimport { SkiaViewNativeId } from \"./SkiaViewNativeId\";\n\nconst NativeSkiaPictureView = SkiaPictureViewNativeComponent;\n\ninterface SkiaPictureViewProps extends SkiaPictureViewNativeProps {\n mode?: \"default\" | \"continuous\";\n}\n\nexport class SkiaPictureView extends React.Component<SkiaPictureViewProps> {\n private requestId = 0;\n\n constructor(props: SkiaPictureViewProps) {\n super(props);\n this._nativeId = SkiaViewNativeId.current++;\n const { picture, onSize } = props;\n if (picture) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"picture\", picture);\n }\n if (onSize) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"onSize\", onSize);\n }\n this.tick();\n }\n\n private _nativeId: number;\n\n public get nativeId() {\n return this._nativeId;\n }\n\n componentDidUpdate(prevProps: SkiaPictureViewProps) {\n const { picture, onSize } = this.props;\n if (picture !== prevProps.picture) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"picture\", picture);\n }\n if (onSize !== prevProps.onSize) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"onSize\", onSize);\n }\n this.tick();\n }\n\n componentWillUnmount() {\n if (this.requestId) {\n cancelAnimationFrame(this.requestId);\n }\n }\n\n private tick() {\n this.redraw();\n if (this.props.mode === \"continuous\") {\n this.requestId = requestAnimationFrame(this.tick.bind(this));\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 SkiaViewApi.requestRedraw(this._nativeId);\n }\n\n render() {\n const { mode, debug = false, ...viewProps } = this.props;\n return (\n <NativeSkiaPictureView\n collapsable={false}\n nativeID={`${this._nativeId}`}\n debug={debug}\n {...viewProps}\n />\n );\n }\n}\n\nconst assertSkiaViewApi = () => {\n if (\n SkiaViewApi === null ||\n SkiaViewApi.setJsiProperty === null ||\n SkiaViewApi.requestRedraw === null ||\n SkiaViewApi.makeImageSnapshot === null\n ) {\n throw Error(\"Skia View Api was not found.\");\n }\n};\n"],"mappings":";;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AAGzB,OAAOC,8BAA8B,MAAM,yCAAyC;AAEpF,SAASC,WAAW,QAAQ,OAAO;AAEnC,SAASC,gBAAgB,QAAQ,oBAAoB;AAErD,MAAMC,qBAAqB,GAAGH,8BAA8B;AAM5D,OAAO,MAAMI,eAAe,SAASL,KAAK,CAACM,SAAS,CAAuB;EAGzEC,WAAWA,CAACC,KAA2B,EAAE;IACvC,KAAK,CAACA,KAAK,CAAC;IAACC,eAAA,oBAHK,CAAC;IAAAA,eAAA;IAInB,IAAI,CAACC,SAAS,GAAGP,gBAAgB,CAACQ,OAAO,EAAE;IAC3C,MAAM;MAAEC,OAAO;MAAEC;IAAO,CAAC,GAAGL,KAAK;IACjC,IAAII,OAAO,EAAE;MACXE,iBAAiB,CAAC,CAAC;MACnBZ,WAAW,CAACa,cAAc,CAAC,IAAI,CAACL,SAAS,EAAE,SAAS,EAAEE,OAAO,CAAC;IAChE;IACA,IAAIC,MAAM,EAAE;MACVC,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AEA;AACF;AACA;EACSL,MAAMA,CAAA,EAAG;IACdT,iBAAiB,CAAC,CAAC;IACnBZ,WAAW,CAAC2B,aAAa,CAAC,IAAI,CAACnB,SAAS,CAAC;EAC3C;EAEAoB,MAAMA,CAAA,EAAG;IACP,MAAM;MAAEN,IAAI;MAAEO,KAAK,GAAG,KAAK;MAAE,GAAGC;IAAU,CAAC,GAAG,IAAI,CAACxB,KAAK;IACxD,oBACER,KAAA,CAAAiC,aAAA,CAAC7B,qBAAqB,EAAA8B,QAAA;MACpBC,WAAW,EAAE,KAAM;MACnBC,QAAQ,EAAE,GAAG,IAAI,CAAC1B,SAAS,EAAG;MAC9BqB,KAAK,EAAEA;IAAM,GACTC,SAAS,CACd,CAAC;EAEN;AACF;AAEA,MAAMlB,iBAAiB,GAAGA,CAAA,KAAM;EAC9B,IACEZ,WAAW,KAAK,IAAI,IACpBA,WAAW,CAACa,cAAc,KAAK,IAAI,IACnCb,WAAW,CAAC2B,aAAa,KAAK,IAAI,IAClC3B,WAAW,CAACyB,iBAAiB,KAAK,IAAI,EACtC;IACA,MAAMU,KAAK,CAAC,8BAA8B,CAAC;EAC7C;AACF,CAAC","ignoreList":[]}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import type { SkCanvas } from "../skia/types";
|
2
|
-
import type {
|
2
|
+
import type { SkiaPictureViewNativeProps } from "./types";
|
3
3
|
import { SkiaBaseWebView } from "./SkiaBaseWebView";
|
4
|
-
export declare class SkiaPictureView extends SkiaBaseWebView<
|
5
|
-
constructor(props:
|
4
|
+
export declare class SkiaPictureView extends SkiaBaseWebView<SkiaPictureViewNativeProps> {
|
5
|
+
constructor(props: SkiaPictureViewNativeProps);
|
6
6
|
protected renderInCanvas(canvas: SkCanvas): void;
|
7
7
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["SkiaBaseWebView","SkiaPictureView","constructor","props","renderInCanvas","canvas","picture","drawPicture"],"sources":["SkiaPictureView.web.tsx"],"sourcesContent":["import type { SkCanvas } from \"../skia/types\";\n\nimport type {
|
1
|
+
{"version":3,"names":["SkiaBaseWebView","SkiaPictureView","constructor","props","renderInCanvas","canvas","picture","drawPicture"],"sources":["SkiaPictureView.web.tsx"],"sourcesContent":["import type { SkCanvas } from \"../skia/types\";\n\nimport type { SkiaPictureViewNativeProps } from \"./types\";\nimport { SkiaBaseWebView } from \"./SkiaBaseWebView\";\n\nexport class SkiaPictureView extends SkiaBaseWebView<SkiaPictureViewNativeProps> {\n constructor(props: SkiaPictureViewNativeProps) {\n super(props);\n }\n\n protected renderInCanvas(canvas: SkCanvas): void {\n if (this.props.picture) {\n canvas.drawPicture(this.props.picture);\n }\n }\n}\n"],"mappings":"AAGA,SAASA,eAAe,QAAQ,mBAAmB;AAEnD,OAAO,MAAMC,eAAe,SAASD,eAAe,CAA6B;EAC/EE,WAAWA,CAACC,KAAiC,EAAE;IAC7C,KAAK,CAACA,KAAK,CAAC;EACd;EAEUC,cAAcA,CAACC,MAAgB,EAAQ;IAC/C,IAAI,IAAI,CAACF,KAAK,CAACG,OAAO,EAAE;MACtBD,MAAM,CAACE,WAAW,CAAC,IAAI,CAACJ,KAAK,CAACG,OAAO,CAAC;IACxC;EACF;AACF","ignoreList":[]}
|
@@ -2,9 +2,7 @@ import type { ViewProps } from "react-native";
|
|
2
2
|
import type { GroupProps, RenderNode } from "../dom/types";
|
3
3
|
import type { SkImage, SkPicture, SkRect, SkSize } from "../skia/types";
|
4
4
|
import type { SharedValueType } from "../renderer/processors/Animations/Animations";
|
5
|
-
export type DrawMode = "continuous" | "default";
|
6
5
|
export type NativeSkiaViewProps = ViewProps & {
|
7
|
-
mode?: DrawMode;
|
8
6
|
debug?: boolean;
|
9
7
|
};
|
10
8
|
export interface DrawingInfo {
|
@@ -19,14 +17,6 @@ export interface ISkiaViewApi {
|
|
19
17
|
makeImageSnapshotAsync: (nativeId: number, rect?: SkRect) => Promise<SkImage>;
|
20
18
|
}
|
21
19
|
export interface SkiaBaseViewProps extends ViewProps {
|
22
|
-
/**
|
23
|
-
* Sets the drawing mode for the skia view. There are two drawing
|
24
|
-
* modes, "continuous" and "default", where the continuous mode will
|
25
|
-
* continuously redraw the view, and the default mode will only
|
26
|
-
* redraw when any of the regular react properties are changed like
|
27
|
-
* sizes and margins.
|
28
|
-
*/
|
29
|
-
mode?: DrawMode;
|
30
20
|
/**
|
31
21
|
* When set to true the view will display information about the
|
32
22
|
* average time it takes to render.
|
@@ -38,9 +28,9 @@ export interface SkiaBaseViewProps extends ViewProps {
|
|
38
28
|
*/
|
39
29
|
onSize?: SharedValueType<SkSize>;
|
40
30
|
}
|
41
|
-
export interface
|
31
|
+
export interface SkiaPictureViewNativeProps extends SkiaBaseViewProps {
|
42
32
|
picture?: SkPicture;
|
43
33
|
}
|
44
|
-
export interface
|
34
|
+
export interface SkiaDomViewNativeProps extends SkiaBaseViewProps {
|
45
35
|
root?: RenderNode<GroupProps>;
|
46
36
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { ViewProps } from \"react-native\";\n\nimport type { GroupProps, RenderNode } from \"../dom/types\";\nimport type { SkImage, SkPicture, SkRect, SkSize } from \"../skia/types\";\nimport type { SharedValueType } from \"../renderer/processors/Animations/Animations\";\n\nexport type
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { ViewProps } from \"react-native\";\n\nimport type { GroupProps, RenderNode } from \"../dom/types\";\nimport type { SkImage, SkPicture, SkRect, SkSize } from \"../skia/types\";\nimport type { SharedValueType } from \"../renderer/processors/Animations/Animations\";\n\nexport type NativeSkiaViewProps = ViewProps & {\n debug?: boolean;\n};\n\nexport interface DrawingInfo {\n width: number;\n height: number;\n timestamp: number;\n}\n\nexport interface ISkiaViewApi {\n setJsiProperty: <T>(nativeId: number, name: string, value: T) => void;\n requestRedraw: (nativeId: number) => void;\n makeImageSnapshot: (nativeId: number, rect?: SkRect) => SkImage;\n makeImageSnapshotAsync: (nativeId: number, rect?: SkRect) => Promise<SkImage>;\n}\n\nexport interface SkiaBaseViewProps extends ViewProps {\n /**\n * When set to true the view will display information about the\n * average time it takes to render.\n */\n debug?: boolean;\n /**\n * Pass an animated value to the onSize property to get updates when\n * the Skia view is resized.\n */\n onSize?: SharedValueType<SkSize>;\n}\n\nexport interface SkiaPictureViewNativeProps extends SkiaBaseViewProps {\n picture?: SkPicture;\n}\n\nexport interface SkiaDomViewNativeProps extends SkiaBaseViewProps {\n root?: RenderNode<GroupProps>;\n}\n"],"mappings":"","ignoreList":[]}
|
@@ -3,7 +3,6 @@ declare const SkiaBaseWebView_base: any;
|
|
3
3
|
export class SkiaBaseWebView extends SkiaBaseWebView_base {
|
4
4
|
[x: string]: any;
|
5
5
|
constructor(props: any);
|
6
|
-
_mode: any;
|
7
6
|
unsubscribeAll(): void;
|
8
7
|
_unsubscriptions: any[] | undefined;
|
9
8
|
onLayoutEvent(evt: any): void;
|
@@ -34,16 +33,6 @@ export class SkiaBaseWebView extends SkiaBaseWebView_base {
|
|
34
33
|
_redrawRequests: number | undefined;
|
35
34
|
requestId: number | undefined;
|
36
35
|
redraw(): void;
|
37
|
-
/**
|
38
|
-
* Updates the drawing mode for the skia view. This is the same
|
39
|
-
* as declaratively setting the mode property on the SkiaView.
|
40
|
-
* There are two drawing modes, "continuous" and "default",
|
41
|
-
* where the continuous mode will continuously redraw the view and
|
42
|
-
* the default mode will only redraw when any of the regular react
|
43
|
-
* properties are changed like size and margins.
|
44
|
-
* @param mode Drawing mode to use.
|
45
|
-
*/
|
46
|
-
setDrawMode(mode: any): void;
|
47
36
|
render(): any;
|
48
37
|
}
|
49
38
|
import _JsiSkSurface = require("../skia/web/JsiSkSurface");
|
@@ -6,6 +6,9 @@ export class SkiaDomView extends SkiaDomView_base {
|
|
6
6
|
_nativeId: number;
|
7
7
|
get nativeId(): number;
|
8
8
|
componentDidUpdate(prevProps: any): void;
|
9
|
+
componentWillUnmount(): void;
|
10
|
+
tick(): void;
|
11
|
+
requestId: number | undefined;
|
9
12
|
/**
|
10
13
|
* Creates a snapshot from the canvas in the surface
|
11
14
|
* @param rect Rect to use as bounds. Optional.
|
@@ -6,6 +6,9 @@ export class SkiaPictureView extends SkiaPictureView_base {
|
|
6
6
|
_nativeId: number;
|
7
7
|
get nativeId(): number;
|
8
8
|
componentDidUpdate(prevProps: any): void;
|
9
|
+
componentWillUnmount(): void;
|
10
|
+
tick(): void;
|
11
|
+
requestId: number | undefined;
|
9
12
|
/**
|
10
13
|
* Creates a snapshot from the canvas in the surface
|
11
14
|
* @param rect Rect to use as bounds. Optional.
|