@shopify/react-native-skia 2.2.6 → 2.2.8
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/recorder/DrawingCtx.h +15 -0
- package/cpp/api/recorder/JsiRecorder.h +2 -1
- package/cpp/api/recorder/RNRecorder.h +2 -2
- package/cpp/api/recorder/Shaders.h +6 -5
- package/lib/commonjs/skia/types/Recorder.d.ts +1 -1
- package/lib/commonjs/skia/types/Recorder.js.map +1 -1
- package/lib/commonjs/sksg/Container.d.ts +3 -39
- package/lib/commonjs/sksg/Container.js +3 -195
- package/lib/commonjs/sksg/Container.js.map +1 -1
- package/lib/commonjs/sksg/Container.native.d.ts +14 -0
- package/lib/commonjs/sksg/Container.native.js +81 -0
- package/lib/commonjs/sksg/Container.native.js.map +1 -0
- package/lib/commonjs/sksg/Container.web.d.ts +14 -0
- package/lib/commonjs/sksg/Container.web.js +91 -0
- package/lib/commonjs/sksg/Container.web.js.map +1 -0
- package/lib/commonjs/sksg/HostConfig.d.ts +1 -1
- package/lib/commonjs/sksg/HostConfig.js.map +1 -1
- package/lib/commonjs/sksg/Reconciler.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.d.ts +1 -1
- package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.js +2 -2
- package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/Recorder.d.ts +1 -1
- package/lib/commonjs/sksg/Recorder/Recorder.js +3 -2
- package/lib/commonjs/sksg/Recorder/Recorder.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/Visitor.js +2 -2
- package/lib/commonjs/sksg/Recorder/Visitor.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/Shaders.js +3 -3
- package/lib/commonjs/sksg/Recorder/commands/Shaders.js.map +1 -1
- package/lib/commonjs/sksg/StaticContainer.d.ts +24 -0
- package/lib/commonjs/sksg/StaticContainer.js +70 -0
- package/lib/commonjs/sksg/StaticContainer.js.map +1 -0
- package/lib/module/skia/types/Recorder.d.ts +1 -1
- package/lib/module/skia/types/Recorder.js.map +1 -1
- package/lib/module/sksg/Container.d.ts +3 -39
- package/lib/module/sksg/Container.js +2 -192
- package/lib/module/sksg/Container.js.map +1 -1
- package/lib/module/sksg/Container.native.d.ts +14 -0
- package/lib/module/sksg/Container.native.js +73 -0
- package/lib/module/sksg/Container.native.js.map +1 -0
- package/lib/module/sksg/Container.web.d.ts +14 -0
- package/lib/module/sksg/Container.web.js +83 -0
- package/lib/module/sksg/Container.web.js.map +1 -0
- package/lib/module/sksg/HostConfig.d.ts +1 -1
- package/lib/module/sksg/HostConfig.js.map +1 -1
- package/lib/module/sksg/Reconciler.js.map +1 -1
- package/lib/module/sksg/Recorder/ReanimatedRecorder.d.ts +1 -1
- package/lib/module/sksg/Recorder/ReanimatedRecorder.js +2 -2
- package/lib/module/sksg/Recorder/ReanimatedRecorder.js.map +1 -1
- package/lib/module/sksg/Recorder/Recorder.d.ts +1 -1
- package/lib/module/sksg/Recorder/Recorder.js +3 -2
- package/lib/module/sksg/Recorder/Recorder.js.map +1 -1
- package/lib/module/sksg/Recorder/Visitor.js +2 -2
- package/lib/module/sksg/Recorder/Visitor.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/Shaders.js +3 -3
- package/lib/module/sksg/Recorder/commands/Shaders.js.map +1 -1
- package/lib/module/sksg/StaticContainer.d.ts +24 -0
- package/lib/module/sksg/StaticContainer.js +62 -0
- package/lib/module/sksg/StaticContainer.js.map +1 -0
- package/lib/typescript/lib/commonjs/sksg/Container.d.ts +2 -42
- package/lib/typescript/lib/commonjs/sksg/Container.native.d.ts +11 -0
- package/lib/typescript/lib/commonjs/sksg/Container.web.d.ts +15 -0
- package/lib/typescript/lib/commonjs/sksg/Reconciler.d.ts +1 -45
- package/lib/typescript/lib/commonjs/sksg/Recorder/ReanimatedRecorder.d.ts +1 -1
- package/lib/typescript/lib/commonjs/sksg/Recorder/Recorder.d.ts +1 -1
- package/lib/typescript/lib/commonjs/sksg/StaticContainer.d.ts +23 -0
- package/lib/typescript/lib/module/sksg/Container.d.ts +2 -42
- package/lib/typescript/lib/module/sksg/Container.native.d.ts +11 -0
- package/lib/typescript/lib/module/sksg/Container.web.d.ts +15 -0
- package/lib/typescript/lib/module/sksg/Reconciler.d.ts +1 -45
- package/lib/typescript/lib/module/sksg/Recorder/ReanimatedRecorder.d.ts +1 -1
- package/lib/typescript/lib/module/sksg/Recorder/Recorder.d.ts +1 -1
- package/lib/typescript/lib/module/sksg/StaticContainer.d.ts +22 -0
- package/lib/typescript/src/skia/types/Recorder.d.ts +1 -1
- package/lib/typescript/src/sksg/Container.d.ts +3 -39
- package/lib/typescript/src/sksg/Container.native.d.ts +14 -0
- package/lib/typescript/src/sksg/Container.web.d.ts +14 -0
- package/lib/typescript/src/sksg/HostConfig.d.ts +1 -1
- package/lib/typescript/src/sksg/Recorder/ReanimatedRecorder.d.ts +1 -1
- package/lib/typescript/src/sksg/Recorder/Recorder.d.ts +1 -1
- package/lib/typescript/src/sksg/StaticContainer.d.ts +24 -0
- package/package.json +1 -1
- package/src/renderer/__tests__/e2e/Shader.spec.tsx +93 -0
- package/src/skia/types/Recorder.ts +5 -1
- package/src/sksg/Container.native.ts +86 -0
- package/src/sksg/Container.ts +3 -223
- package/src/sksg/Container.web.ts +95 -0
- package/src/sksg/HostConfig.ts +1 -1
- package/src/sksg/Reconciler.ts +1 -1
- package/src/sksg/Recorder/ReanimatedRecorder.ts +6 -2
- package/src/sksg/Recorder/Recorder.ts +6 -2
- package/src/sksg/Recorder/Visitor.ts +2 -2
- package/src/sksg/Recorder/commands/Shaders.ts +8 -3
- package/src/sksg/StaticContainer.ts +83 -0
@@ -0,0 +1,62 @@
|
|
1
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
2
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
3
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
4
|
+
import { Recorder } from "./Recorder/Recorder";
|
5
|
+
import { visit } from "./Recorder/Visitor";
|
6
|
+
import { replay } from "./Recorder/Player";
|
7
|
+
import { createDrawingContext } from "./Recorder/DrawingContext";
|
8
|
+
import "../views/api";
|
9
|
+
export class Container {
|
10
|
+
constructor(Skia) {
|
11
|
+
this.Skia = Skia;
|
12
|
+
_defineProperty(this, "_root", []);
|
13
|
+
_defineProperty(this, "recording", null);
|
14
|
+
_defineProperty(this, "unmounted", false);
|
15
|
+
}
|
16
|
+
get root() {
|
17
|
+
return this._root;
|
18
|
+
}
|
19
|
+
set root(value) {
|
20
|
+
this._root = value;
|
21
|
+
}
|
22
|
+
mount() {
|
23
|
+
this.unmounted = false;
|
24
|
+
}
|
25
|
+
unmount() {
|
26
|
+
this.unmounted = true;
|
27
|
+
}
|
28
|
+
drawOnCanvas(canvas) {
|
29
|
+
if (!this.recording) {
|
30
|
+
throw new Error("No recording to draw");
|
31
|
+
}
|
32
|
+
const ctx = createDrawingContext(this.Skia, this.recording.paintPool, canvas);
|
33
|
+
replay(ctx, this.recording.commands);
|
34
|
+
}
|
35
|
+
}
|
36
|
+
export class StaticContainer extends Container {
|
37
|
+
constructor(Skia, nativeId, onSize) {
|
38
|
+
super(Skia);
|
39
|
+
this.nativeId = nativeId;
|
40
|
+
this.onSize = onSize;
|
41
|
+
}
|
42
|
+
redraw() {
|
43
|
+
const recorder = new Recorder();
|
44
|
+
visit(recorder, this.root);
|
45
|
+
this.recording = recorder.getRecording();
|
46
|
+
const isOnScreen = this.nativeId !== -1;
|
47
|
+
if (isOnScreen) {
|
48
|
+
if (this.onSize) {
|
49
|
+
const size = SkiaViewApi.size(this.nativeId);
|
50
|
+
if (size.width !== this.onSize.value.width || size.height !== this.onSize.value.height) {
|
51
|
+
this.onSize.value = size;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
const rec = this.Skia.PictureRecorder();
|
55
|
+
const canvas = rec.beginRecording();
|
56
|
+
this.drawOnCanvas(canvas);
|
57
|
+
const picture = rec.finishRecordingAsPicture();
|
58
|
+
SkiaViewApi.setJsiProperty(this.nativeId, "picture", picture);
|
59
|
+
}
|
60
|
+
}
|
61
|
+
}
|
62
|
+
//# sourceMappingURL=StaticContainer.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["Recorder","visit","replay","createDrawingContext","Container","constructor","Skia","_defineProperty","root","_root","value","mount","unmounted","unmount","drawOnCanvas","canvas","recording","Error","ctx","paintPool","commands","StaticContainer","nativeId","onSize","redraw","recorder","getRecording","isOnScreen","size","SkiaViewApi","width","height","rec","PictureRecorder","beginRecording","picture","finishRecordingAsPicture","setJsiProperty"],"sources":["StaticContainer.ts"],"sourcesContent":["import type { SharedValue } from \"react-native-reanimated\";\n\nimport type { Skia, SkCanvas, SkSize } from \"../skia/types\";\n\nimport type { Node } from \"./Node\";\nimport type { Recording } from \"./Recorder/Recorder\";\nimport { Recorder } from \"./Recorder/Recorder\";\nimport { visit } from \"./Recorder/Visitor\";\nimport { replay } from \"./Recorder/Player\";\nimport { createDrawingContext } from \"./Recorder/DrawingContext\";\n\nimport \"../views/api\";\n\nexport abstract class Container {\n private _root: Node[] = [];\n protected recording: Recording | null = null;\n protected unmounted = false;\n\n constructor(protected Skia: Skia) {}\n\n get root() {\n return this._root;\n }\n\n set root(value: Node[]) {\n this._root = value;\n }\n\n mount() {\n this.unmounted = false;\n }\n\n unmount() {\n this.unmounted = true;\n }\n\n drawOnCanvas(canvas: SkCanvas) {\n if (!this.recording) {\n throw new Error(\"No recording to draw\");\n }\n const ctx = createDrawingContext(\n this.Skia,\n this.recording.paintPool,\n canvas\n );\n replay(ctx, this.recording.commands);\n }\n\n abstract redraw(): void;\n}\n\nexport class StaticContainer extends Container {\n constructor(\n Skia: Skia,\n private nativeId: number,\n private onSize?: SharedValue<SkSize>\n ) {\n super(Skia);\n }\n\n redraw() {\n const recorder = new Recorder();\n visit(recorder, this.root);\n this.recording = recorder.getRecording();\n const isOnScreen = this.nativeId !== -1;\n if (isOnScreen) {\n if (this.onSize) {\n const size = SkiaViewApi.size(this.nativeId);\n if (\n size.width !== this.onSize.value.width ||\n size.height !== this.onSize.value.height\n ) {\n this.onSize.value = size;\n }\n }\n const rec = this.Skia.PictureRecorder();\n const canvas = rec.beginRecording();\n this.drawOnCanvas(canvas);\n const picture = rec.finishRecordingAsPicture();\n SkiaViewApi.setJsiProperty(this.nativeId, \"picture\", picture);\n }\n }\n}\n"],"mappings":";;;AAMA,SAASA,QAAQ,QAAQ,qBAAqB;AAC9C,SAASC,KAAK,QAAQ,oBAAoB;AAC1C,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,oBAAoB,QAAQ,2BAA2B;AAEhE,OAAO,cAAc;AAErB,OAAO,MAAeC,SAAS,CAAC;EAK9BC,WAAWA,CAAWC,IAAU,EAAE;IAAA,KAAZA,IAAU,GAAVA,IAAU;IAAAC,eAAA,gBAJR,EAAE;IAAAA,eAAA,oBACc,IAAI;IAAAA,eAAA,oBACtB,KAAK;EAEQ;EAEnC,IAAIC,IAAIA,CAAA,EAAG;IACT,OAAO,IAAI,CAACC,KAAK;EACnB;EAEA,IAAID,IAAIA,CAACE,KAAa,EAAE;IACtB,IAAI,CAACD,KAAK,GAAGC,KAAK;EACpB;EAEAC,KAAKA,CAAA,EAAG;IACN,IAAI,CAACC,SAAS,GAAG,KAAK;EACxB;EAEAC,OAAOA,CAAA,EAAG;IACR,IAAI,CAACD,SAAS,GAAG,IAAI;EACvB;EAEAE,YAAYA,CAACC,MAAgB,EAAE;IAC7B,IAAI,CAAC,IAAI,CAACC,SAAS,EAAE;MACnB,MAAM,IAAIC,KAAK,CAAC,sBAAsB,CAAC;IACzC;IACA,MAAMC,GAAG,GAAGf,oBAAoB,CAC9B,IAAI,CAACG,IAAI,EACT,IAAI,CAACU,SAAS,CAACG,SAAS,EACxBJ,MACF,CAAC;IACDb,MAAM,CAACgB,GAAG,EAAE,IAAI,CAACF,SAAS,CAACI,QAAQ,CAAC;EACtC;AAGF;AAEA,OAAO,MAAMC,eAAe,SAASjB,SAAS,CAAC;EAC7CC,WAAWA,CACTC,IAAU,EACFgB,QAAgB,EAChBC,MAA4B,EACpC;IACA,KAAK,CAACjB,IAAI,CAAC;IAAC,KAHJgB,QAAgB,GAAhBA,QAAgB;IAAA,KAChBC,MAA4B,GAA5BA,MAA4B;EAGtC;EAEAC,MAAMA,CAAA,EAAG;IACP,MAAMC,QAAQ,GAAG,IAAIzB,QAAQ,CAAC,CAAC;IAC/BC,KAAK,CAACwB,QAAQ,EAAE,IAAI,CAACjB,IAAI,CAAC;IAC1B,IAAI,CAACQ,SAAS,GAAGS,QAAQ,CAACC,YAAY,CAAC,CAAC;IACxC,MAAMC,UAAU,GAAG,IAAI,CAACL,QAAQ,KAAK,CAAC,CAAC;IACvC,IAAIK,UAAU,EAAE;MACd,IAAI,IAAI,CAACJ,MAAM,EAAE;QACf,MAAMK,IAAI,GAAGC,WAAW,CAACD,IAAI,CAAC,IAAI,CAACN,QAAQ,CAAC;QAC5C,IACEM,IAAI,CAACE,KAAK,KAAK,IAAI,CAACP,MAAM,CAACb,KAAK,CAACoB,KAAK,IACtCF,IAAI,CAACG,MAAM,KAAK,IAAI,CAACR,MAAM,CAACb,KAAK,CAACqB,MAAM,EACxC;UACA,IAAI,CAACR,MAAM,CAACb,KAAK,GAAGkB,IAAI;QAC1B;MACF;MACA,MAAMI,GAAG,GAAG,IAAI,CAAC1B,IAAI,CAAC2B,eAAe,CAAC,CAAC;MACvC,MAAMlB,MAAM,GAAGiB,GAAG,CAACE,cAAc,CAAC,CAAC;MACnC,IAAI,CAACpB,YAAY,CAACC,MAAM,CAAC;MACzB,MAAMoB,OAAO,GAAGH,GAAG,CAACI,wBAAwB,CAAC,CAAC;MAC9CP,WAAW,CAACQ,cAAc,CAAC,IAAI,CAACf,QAAQ,EAAE,SAAS,EAAEa,OAAO,CAAC;IAC/D;EACF;AACF","ignoreList":[]}
|
@@ -1,43 +1,3 @@
|
|
1
1
|
export const __esModule: boolean;
|
2
|
-
export
|
3
|
-
|
4
|
-
Skia: any;
|
5
|
-
set root(value: any);
|
6
|
-
get root(): any;
|
7
|
-
_root: any;
|
8
|
-
mount(): void;
|
9
|
-
unmounted: boolean | undefined;
|
10
|
-
unmount(): void;
|
11
|
-
drawOnCanvas(canvas: any): void;
|
12
|
-
}
|
13
|
-
export function createContainer(Skia: any, nativeId: any, onSize: any): NativeReanimatedContainer | ReanimatedContainer | StaticContainer;
|
14
|
-
declare class NativeReanimatedContainer extends Container {
|
15
|
-
constructor(Skia: any, nativeId: any, onSize: any);
|
16
|
-
nativeId: any;
|
17
|
-
onSize: any;
|
18
|
-
redraw(): void;
|
19
|
-
mapperId: any;
|
20
|
-
}
|
21
|
-
declare class ReanimatedContainer extends Container {
|
22
|
-
constructor(Skia: any, nativeId: any, onSize: any);
|
23
|
-
nativeId: any;
|
24
|
-
onSize: any;
|
25
|
-
redraw(): void;
|
26
|
-
recording: {
|
27
|
-
commands: any;
|
28
|
-
paintPool: never[];
|
29
|
-
} | undefined;
|
30
|
-
mapperId: any;
|
31
|
-
}
|
32
|
-
declare class StaticContainer extends Container {
|
33
|
-
constructor(Skia: any, nativeId: any, onSize: any);
|
34
|
-
nativeId: any;
|
35
|
-
onSize: any;
|
36
|
-
redraw(): void;
|
37
|
-
recording: {
|
38
|
-
commands: any;
|
39
|
-
paintPool: never[];
|
40
|
-
animationValues: any;
|
41
|
-
} | undefined;
|
42
|
-
}
|
43
|
-
export {};
|
2
|
+
export function createContainer(Skia: any, nativeId: any, onSize: any): _StaticContainer.StaticContainer;
|
3
|
+
import _StaticContainer = require("./StaticContainer");
|
@@ -0,0 +1,11 @@
|
|
1
|
+
export const __esModule: boolean;
|
2
|
+
export function createContainer(Skia: any, nativeId: any, onSize: any): _StaticContainer.StaticContainer | NativeReanimatedContainer;
|
3
|
+
import _StaticContainer = require("./StaticContainer");
|
4
|
+
declare class NativeReanimatedContainer extends _StaticContainer.Container {
|
5
|
+
constructor(Skia: any, nativeId: any, onSize: any);
|
6
|
+
nativeId: any;
|
7
|
+
onSize: any;
|
8
|
+
redraw(): void;
|
9
|
+
mapperId: any;
|
10
|
+
}
|
11
|
+
export {};
|
@@ -0,0 +1,15 @@
|
|
1
|
+
export const __esModule: boolean;
|
2
|
+
export function createContainer(Skia: any, nativeId: any, onSize: any): _StaticContainer.StaticContainer | ReanimatedContainer;
|
3
|
+
import _StaticContainer = require("./StaticContainer");
|
4
|
+
declare class ReanimatedContainer extends _StaticContainer.Container {
|
5
|
+
constructor(Skia: any, nativeId: any, onSize: any);
|
6
|
+
nativeId: any;
|
7
|
+
onSize: any;
|
8
|
+
redraw(): void;
|
9
|
+
recording: {
|
10
|
+
commands: any;
|
11
|
+
paintPool: never[];
|
12
|
+
} | undefined;
|
13
|
+
mapperId: any;
|
14
|
+
}
|
15
|
+
export {};
|
@@ -2,51 +2,7 @@ export const __esModule: boolean;
|
|
2
2
|
export class SkiaSGRoot {
|
3
3
|
constructor(Skia: any, nativeId: number | undefined, onSize: any);
|
4
4
|
Skia: any;
|
5
|
-
container:
|
6
|
-
nativeId: any;
|
7
|
-
onSize: any;
|
8
|
-
redraw(): void;
|
9
|
-
mapperId: any;
|
10
|
-
Skia: any;
|
11
|
-
root: any;
|
12
|
-
_root: any;
|
13
|
-
mount(): void;
|
14
|
-
unmounted: boolean | undefined;
|
15
|
-
unmount(): void;
|
16
|
-
drawOnCanvas(canvas: any): void;
|
17
|
-
} | {
|
18
|
-
nativeId: any;
|
19
|
-
onSize: any;
|
20
|
-
redraw(): void;
|
21
|
-
recording: {
|
22
|
-
commands: any;
|
23
|
-
paintPool: never[];
|
24
|
-
} | undefined;
|
25
|
-
mapperId: any;
|
26
|
-
Skia: any;
|
27
|
-
root: any;
|
28
|
-
_root: any;
|
29
|
-
mount(): void;
|
30
|
-
unmounted: boolean | undefined;
|
31
|
-
unmount(): void;
|
32
|
-
drawOnCanvas(canvas: any): void;
|
33
|
-
} | {
|
34
|
-
nativeId: any;
|
35
|
-
onSize: any;
|
36
|
-
redraw(): void;
|
37
|
-
recording: {
|
38
|
-
commands: any;
|
39
|
-
paintPool: never[];
|
40
|
-
animationValues: any;
|
41
|
-
} | undefined;
|
42
|
-
Skia: any;
|
43
|
-
root: any;
|
44
|
-
_root: any;
|
45
|
-
mount(): void;
|
46
|
-
unmounted: boolean | undefined;
|
47
|
-
unmount(): void;
|
48
|
-
drawOnCanvas(canvas: any): void;
|
49
|
-
};
|
5
|
+
container: import("./StaticContainer").StaticContainer;
|
50
6
|
root: any;
|
51
7
|
get sg(): {
|
52
8
|
type: any;
|
@@ -14,7 +14,7 @@ export class ReanimatedRecorder {
|
|
14
14
|
pushPathEffect(pathEffectType: any, props: any): void;
|
15
15
|
pushImageFilter(imageFilterType: any, props: any): void;
|
16
16
|
pushColorFilter(colorFilterType: any, props: any): void;
|
17
|
-
pushShader(shaderType: any, props: any): void;
|
17
|
+
pushShader(shaderType: any, props: any, children: any): void;
|
18
18
|
pushBlurMaskFilter(props: any): void;
|
19
19
|
composePathEffect(): void;
|
20
20
|
composeColorFilter(): void;
|
@@ -19,7 +19,7 @@ export class Recorder {
|
|
19
19
|
pushPathEffect(pathEffectType: any, props: any): void;
|
20
20
|
pushImageFilter(imageFilterType: any, props: any): void;
|
21
21
|
pushColorFilter(colorFilterType: any, props: any): void;
|
22
|
-
pushShader(shaderType: any, props: any): void;
|
22
|
+
pushShader(shaderType: any, props: any, children: any): void;
|
23
23
|
pushBlurMaskFilter(props: any): void;
|
24
24
|
composePathEffect(): void;
|
25
25
|
composeColorFilter(): void;
|
@@ -0,0 +1,23 @@
|
|
1
|
+
export const __esModule: boolean;
|
2
|
+
export class Container {
|
3
|
+
constructor(Skia: any);
|
4
|
+
Skia: any;
|
5
|
+
set root(value: any);
|
6
|
+
get root(): any;
|
7
|
+
_root: any;
|
8
|
+
mount(): void;
|
9
|
+
unmounted: boolean | undefined;
|
10
|
+
unmount(): void;
|
11
|
+
drawOnCanvas(canvas: any): void;
|
12
|
+
}
|
13
|
+
export class StaticContainer extends Container {
|
14
|
+
constructor(Skia: any, nativeId: any, onSize: any);
|
15
|
+
nativeId: any;
|
16
|
+
onSize: any;
|
17
|
+
redraw(): void;
|
18
|
+
recording: {
|
19
|
+
commands: any;
|
20
|
+
paintPool: never[];
|
21
|
+
animationValues: any;
|
22
|
+
} | undefined;
|
23
|
+
}
|
@@ -1,42 +1,2 @@
|
|
1
|
-
export
|
2
|
-
|
3
|
-
Skia: any;
|
4
|
-
set root(value: any);
|
5
|
-
get root(): any;
|
6
|
-
_root: any;
|
7
|
-
mount(): void;
|
8
|
-
unmounted: boolean | undefined;
|
9
|
-
unmount(): void;
|
10
|
-
drawOnCanvas(canvas: any): void;
|
11
|
-
}
|
12
|
-
export function createContainer(Skia: any, nativeId: any, onSize: any): StaticContainer | ReanimatedContainer | NativeReanimatedContainer;
|
13
|
-
declare class StaticContainer extends Container {
|
14
|
-
constructor(Skia: any, nativeId: any, onSize: any);
|
15
|
-
nativeId: any;
|
16
|
-
onSize: any;
|
17
|
-
redraw(): void;
|
18
|
-
recording: {
|
19
|
-
commands: any;
|
20
|
-
paintPool: never[];
|
21
|
-
animationValues: any;
|
22
|
-
} | undefined;
|
23
|
-
}
|
24
|
-
declare class ReanimatedContainer extends Container {
|
25
|
-
constructor(Skia: any, nativeId: any, onSize: any);
|
26
|
-
nativeId: any;
|
27
|
-
onSize: any;
|
28
|
-
redraw(): void;
|
29
|
-
recording: {
|
30
|
-
commands: any;
|
31
|
-
paintPool: never[];
|
32
|
-
} | undefined;
|
33
|
-
mapperId: any;
|
34
|
-
}
|
35
|
-
declare class NativeReanimatedContainer extends Container {
|
36
|
-
constructor(Skia: any, nativeId: any, onSize: any);
|
37
|
-
nativeId: any;
|
38
|
-
onSize: any;
|
39
|
-
redraw(): void;
|
40
|
-
mapperId: any;
|
41
|
-
}
|
42
|
-
export {};
|
1
|
+
export function createContainer(Skia: any, nativeId: any, onSize: any): StaticContainer;
|
2
|
+
import { StaticContainer } from "./StaticContainer";
|
@@ -0,0 +1,11 @@
|
|
1
|
+
export function createContainer(Skia: any, nativeId: any, onSize: any): StaticContainer | NativeReanimatedContainer;
|
2
|
+
import { StaticContainer } from "./StaticContainer";
|
3
|
+
declare class NativeReanimatedContainer extends Container {
|
4
|
+
constructor(Skia: any, nativeId: any, onSize: any);
|
5
|
+
nativeId: any;
|
6
|
+
onSize: any;
|
7
|
+
redraw(): void;
|
8
|
+
mapperId: any;
|
9
|
+
}
|
10
|
+
import { Container } from "./StaticContainer";
|
11
|
+
export {};
|
@@ -0,0 +1,15 @@
|
|
1
|
+
export function createContainer(Skia: any, nativeId: any, onSize: any): StaticContainer | ReanimatedContainer;
|
2
|
+
import { StaticContainer } from "./StaticContainer";
|
3
|
+
declare class ReanimatedContainer extends Container {
|
4
|
+
constructor(Skia: any, nativeId: any, onSize: any);
|
5
|
+
nativeId: any;
|
6
|
+
onSize: any;
|
7
|
+
redraw(): void;
|
8
|
+
recording: {
|
9
|
+
commands: any;
|
10
|
+
paintPool: never[];
|
11
|
+
} | undefined;
|
12
|
+
mapperId: any;
|
13
|
+
}
|
14
|
+
import { Container } from "./StaticContainer";
|
15
|
+
export {};
|
@@ -1,51 +1,7 @@
|
|
1
1
|
export class SkiaSGRoot {
|
2
2
|
constructor(Skia: any, nativeId: number | undefined, onSize: any);
|
3
3
|
Skia: any;
|
4
|
-
container:
|
5
|
-
nativeId: any;
|
6
|
-
onSize: any;
|
7
|
-
redraw(): void;
|
8
|
-
recording: {
|
9
|
-
commands: any;
|
10
|
-
paintPool: never[];
|
11
|
-
animationValues: any;
|
12
|
-
} | undefined;
|
13
|
-
Skia: any;
|
14
|
-
root: any;
|
15
|
-
_root: any;
|
16
|
-
mount(): void;
|
17
|
-
unmounted: boolean | undefined;
|
18
|
-
unmount(): void;
|
19
|
-
drawOnCanvas(canvas: any): void;
|
20
|
-
} | {
|
21
|
-
nativeId: any;
|
22
|
-
onSize: any;
|
23
|
-
redraw(): void;
|
24
|
-
recording: {
|
25
|
-
commands: any;
|
26
|
-
paintPool: never[];
|
27
|
-
} | undefined;
|
28
|
-
mapperId: any;
|
29
|
-
Skia: any;
|
30
|
-
root: any;
|
31
|
-
_root: any;
|
32
|
-
mount(): void;
|
33
|
-
unmounted: boolean | undefined;
|
34
|
-
unmount(): void;
|
35
|
-
drawOnCanvas(canvas: any): void;
|
36
|
-
} | {
|
37
|
-
nativeId: any;
|
38
|
-
onSize: any;
|
39
|
-
redraw(): void;
|
40
|
-
mapperId: any;
|
41
|
-
Skia: any;
|
42
|
-
root: any;
|
43
|
-
_root: any;
|
44
|
-
mount(): void;
|
45
|
-
unmounted: boolean | undefined;
|
46
|
-
unmount(): void;
|
47
|
-
drawOnCanvas(canvas: any): void;
|
48
|
-
};
|
4
|
+
container: import("./StaticContainer").StaticContainer;
|
49
5
|
root: any;
|
50
6
|
get sg(): {
|
51
7
|
type: any;
|
@@ -13,7 +13,7 @@ export class ReanimatedRecorder {
|
|
13
13
|
pushPathEffect(pathEffectType: any, props: any): void;
|
14
14
|
pushImageFilter(imageFilterType: any, props: any): void;
|
15
15
|
pushColorFilter(colorFilterType: any, props: any): void;
|
16
|
-
pushShader(shaderType: any, props: any): void;
|
16
|
+
pushShader(shaderType: any, props: any, children: any): void;
|
17
17
|
pushBlurMaskFilter(props: any): void;
|
18
18
|
composePathEffect(): void;
|
19
19
|
composeColorFilter(): void;
|
@@ -18,7 +18,7 @@ export class Recorder {
|
|
18
18
|
pushPathEffect(pathEffectType: any, props: any): void;
|
19
19
|
pushImageFilter(imageFilterType: any, props: any): void;
|
20
20
|
pushColorFilter(colorFilterType: any, props: any): void;
|
21
|
-
pushShader(shaderType: any, props: any): void;
|
21
|
+
pushShader(shaderType: any, props: any, children: any): void;
|
22
22
|
pushBlurMaskFilter(props: any): void;
|
23
23
|
composePathEffect(): void;
|
24
24
|
composeColorFilter(): void;
|
@@ -0,0 +1,22 @@
|
|
1
|
+
export class Container {
|
2
|
+
constructor(Skia: any);
|
3
|
+
Skia: any;
|
4
|
+
set root(value: any);
|
5
|
+
get root(): any;
|
6
|
+
_root: any;
|
7
|
+
mount(): void;
|
8
|
+
unmounted: boolean | undefined;
|
9
|
+
unmount(): void;
|
10
|
+
drawOnCanvas(canvas: any): void;
|
11
|
+
}
|
12
|
+
export class StaticContainer extends Container {
|
13
|
+
constructor(Skia: any, nativeId: any, onSize: any);
|
14
|
+
nativeId: any;
|
15
|
+
onSize: any;
|
16
|
+
redraw(): void;
|
17
|
+
recording: {
|
18
|
+
commands: any;
|
19
|
+
paintPool: never[];
|
20
|
+
animationValues: any;
|
21
|
+
} | undefined;
|
22
|
+
}
|
@@ -12,7 +12,7 @@ export interface BaseRecorder {
|
|
12
12
|
pushPathEffect(pathEffectType: NodeType, props: AnimatedProps<unknown>): void;
|
13
13
|
pushImageFilter(imageFilterType: NodeType, props: AnimatedProps<unknown>): void;
|
14
14
|
pushColorFilter(colorFilterType: NodeType, props: AnimatedProps<unknown>): void;
|
15
|
-
pushShader(shaderType: NodeType, props: AnimatedProps<unknown
|
15
|
+
pushShader(shaderType: NodeType, props: AnimatedProps<unknown>, children: number): void;
|
16
16
|
pushBlurMaskFilter(props: AnimatedProps<BlurMaskFilterProps>): void;
|
17
17
|
composePathEffect(): void;
|
18
18
|
composeColorFilter(): void;
|
@@ -1,40 +1,4 @@
|
|
1
1
|
import type { SharedValue } from "react-native-reanimated";
|
2
|
-
import type { Skia,
|
3
|
-
import
|
4
|
-
|
5
|
-
import "../views/api";
|
6
|
-
export declare abstract class Container {
|
7
|
-
protected Skia: Skia;
|
8
|
-
private _root;
|
9
|
-
protected recording: Recording | null;
|
10
|
-
protected unmounted: boolean;
|
11
|
-
constructor(Skia: Skia);
|
12
|
-
get root(): Node[];
|
13
|
-
set root(value: Node[]);
|
14
|
-
mount(): void;
|
15
|
-
unmount(): void;
|
16
|
-
drawOnCanvas(canvas: SkCanvas): void;
|
17
|
-
abstract redraw(): void;
|
18
|
-
}
|
19
|
-
declare class StaticContainer extends Container {
|
20
|
-
private nativeId;
|
21
|
-
private onSize?;
|
22
|
-
constructor(Skia: Skia, nativeId: number, onSize?: SharedValue<SkSize> | undefined);
|
23
|
-
redraw(): void;
|
24
|
-
}
|
25
|
-
declare class ReanimatedContainer extends Container {
|
26
|
-
private nativeId;
|
27
|
-
private onSize?;
|
28
|
-
private mapperId;
|
29
|
-
constructor(Skia: Skia, nativeId: number, onSize?: SharedValue<SkSize> | undefined);
|
30
|
-
redraw(): void;
|
31
|
-
}
|
32
|
-
declare class NativeReanimatedContainer extends Container {
|
33
|
-
private nativeId;
|
34
|
-
private onSize?;
|
35
|
-
private mapperId;
|
36
|
-
constructor(Skia: Skia, nativeId: number, onSize?: SharedValue<SkSize> | undefined);
|
37
|
-
redraw(): void;
|
38
|
-
}
|
39
|
-
export declare const createContainer: (Skia: Skia, nativeId: number, onSize?: SharedValue<SkSize>) => StaticContainer | ReanimatedContainer | NativeReanimatedContainer;
|
40
|
-
export {};
|
2
|
+
import type { Skia, SkSize } from "../skia/types";
|
3
|
+
import { StaticContainer } from "./StaticContainer";
|
4
|
+
export declare const createContainer: (Skia: Skia, nativeId: number, onSize?: SharedValue<SkSize>) => StaticContainer;
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import type { SharedValue } from "react-native-reanimated";
|
2
|
+
import type { Skia, SkSize } from "../skia/types";
|
3
|
+
import { Container, StaticContainer } from "./StaticContainer";
|
4
|
+
import "../skia/NativeSetup";
|
5
|
+
import "../views/api";
|
6
|
+
declare class NativeReanimatedContainer extends Container {
|
7
|
+
private nativeId;
|
8
|
+
private onSize?;
|
9
|
+
private mapperId;
|
10
|
+
constructor(Skia: Skia, nativeId: number, onSize?: SharedValue<SkSize> | undefined);
|
11
|
+
redraw(): void;
|
12
|
+
}
|
13
|
+
export declare const createContainer: (Skia: Skia, nativeId: number, onSize?: SharedValue<SkSize>) => StaticContainer | NativeReanimatedContainer;
|
14
|
+
export {};
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import type { SharedValue } from "react-native-reanimated";
|
2
|
+
import type { Skia, SkSize } from "../skia/types";
|
3
|
+
import { Container, StaticContainer } from "./StaticContainer";
|
4
|
+
import "../skia/NativeSetup";
|
5
|
+
import "../views/api";
|
6
|
+
declare class ReanimatedContainer extends Container {
|
7
|
+
private nativeId;
|
8
|
+
private onSize?;
|
9
|
+
private mapperId;
|
10
|
+
constructor(Skia: Skia, nativeId: number, onSize?: SharedValue<SkSize> | undefined);
|
11
|
+
redraw(): void;
|
12
|
+
}
|
13
|
+
export declare const createContainer: (Skia: Skia, nativeId: number, onSize?: SharedValue<SkSize>) => StaticContainer | ReanimatedContainer;
|
14
|
+
export {};
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import type { HostConfig } from "react-reconciler";
|
2
2
|
import type { NodeType } from "../dom/types";
|
3
3
|
import type { Node } from "./Node";
|
4
|
-
import type { Container } from "./
|
4
|
+
import type { Container } from "./StaticContainer";
|
5
5
|
export declare const debug: (...args: Parameters<typeof console.log>) => void;
|
6
6
|
type Instance = Node;
|
7
7
|
type Props = object;
|
@@ -18,7 +18,7 @@ export declare class ReanimatedRecorder implements BaseRecorder {
|
|
18
18
|
pushPathEffect(pathEffectType: NodeType, props: AnimatedProps<unknown>): void;
|
19
19
|
pushImageFilter(imageFilterType: NodeType, props: AnimatedProps<unknown>): void;
|
20
20
|
pushColorFilter(colorFilterType: NodeType, props: AnimatedProps<unknown>): void;
|
21
|
-
pushShader(shaderType: NodeType, props: AnimatedProps<unknown
|
21
|
+
pushShader(shaderType: NodeType, props: AnimatedProps<unknown>, children: number): void;
|
22
22
|
pushBlurMaskFilter(props: AnimatedProps<BlurMaskFilterProps>): void;
|
23
23
|
composePathEffect(): void;
|
24
24
|
composeColorFilter(): void;
|
@@ -28,7 +28,7 @@ export declare class Recorder implements BaseRecorder {
|
|
28
28
|
pushPathEffect(pathEffectType: NodeType, props: AnimatedProps<unknown>): void;
|
29
29
|
pushImageFilter(imageFilterType: NodeType, props: AnimatedProps<unknown>): void;
|
30
30
|
pushColorFilter(colorFilterType: NodeType, props: AnimatedProps<unknown>): void;
|
31
|
-
pushShader(shaderType: NodeType, props: AnimatedProps<unknown
|
31
|
+
pushShader(shaderType: NodeType, props: AnimatedProps<unknown>, children: number): void;
|
32
32
|
pushBlurMaskFilter(props: AnimatedProps<BlurMaskFilterProps>): void;
|
33
33
|
composePathEffect(): void;
|
34
34
|
composeColorFilter(): void;
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import type { SharedValue } from "react-native-reanimated";
|
2
|
+
import type { Skia, SkCanvas, SkSize } from "../skia/types";
|
3
|
+
import type { Node } from "./Node";
|
4
|
+
import type { Recording } from "./Recorder/Recorder";
|
5
|
+
import "../views/api";
|
6
|
+
export declare abstract class Container {
|
7
|
+
protected Skia: Skia;
|
8
|
+
private _root;
|
9
|
+
protected recording: Recording | null;
|
10
|
+
protected unmounted: boolean;
|
11
|
+
constructor(Skia: Skia);
|
12
|
+
get root(): Node[];
|
13
|
+
set root(value: Node[]);
|
14
|
+
mount(): void;
|
15
|
+
unmount(): void;
|
16
|
+
drawOnCanvas(canvas: SkCanvas): void;
|
17
|
+
abstract redraw(): void;
|
18
|
+
}
|
19
|
+
export declare class StaticContainer extends Container {
|
20
|
+
private nativeId;
|
21
|
+
private onSize?;
|
22
|
+
constructor(Skia: Skia, nativeId: number, onSize?: SharedValue<SkSize> | undefined);
|
23
|
+
redraw(): void;
|
24
|
+
}
|
package/package.json
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
"setup-skia-web": "scripts/setup-canvaskit.js"
|
9
9
|
},
|
10
10
|
"title": "React Native Skia",
|
11
|
-
"version": "2.2.
|
11
|
+
"version": "2.2.8",
|
12
12
|
"description": "High-performance React Native Graphics using Skia",
|
13
13
|
"main": "lib/module/index.js",
|
14
14
|
"react-native": "src/index.ts",
|
@@ -257,4 +257,97 @@ vec4 main(vec2 pos) {
|
|
257
257
|
);
|
258
258
|
checkImage(img, docPath("shaders/color.png"));
|
259
259
|
});
|
260
|
+
it("should display a mix of red and lightblue color", async () => {
|
261
|
+
const { Skia } = importSkia();
|
262
|
+
const colorSelection = Skia.RuntimeEffect.Make(`uniform shader child1;
|
263
|
+
uniform shader child2;
|
264
|
+
|
265
|
+
vec4 main(vec2 pos) {
|
266
|
+
vec4 c1 = child1.eval(pos);
|
267
|
+
vec4 c2 = child2.eval(pos);
|
268
|
+
return mix(c1, c2, 0.5);
|
269
|
+
}`)!;
|
270
|
+
const img = await surface.draw(
|
271
|
+
<Fill>
|
272
|
+
<Shader source={colorSelection}>
|
273
|
+
<ColorShader color="lightblue" />
|
274
|
+
<ColorShader color="red" />
|
275
|
+
</Shader>
|
276
|
+
</Fill>
|
277
|
+
);
|
278
|
+
checkImage(img, docPath("shaders/mixed-colors.png"));
|
279
|
+
});
|
280
|
+
it("should display a mix of red and lightblue from custom shaders", async () => {
|
281
|
+
const { Skia } = importSkia();
|
282
|
+
const colorSelection = Skia.RuntimeEffect.Make(`uniform shader child1;
|
283
|
+
uniform shader child2;
|
284
|
+
|
285
|
+
vec4 main(vec2 pos) {
|
286
|
+
vec4 c1 = child1.eval(pos);
|
287
|
+
vec4 c2 = child2.eval(pos);
|
288
|
+
return mix(c1, c2, 0.5);
|
289
|
+
}`)!;
|
290
|
+
expect(colorSelection).toBeDefined();
|
291
|
+
const colorShader = Skia.RuntimeEffect.Make(`
|
292
|
+
uniform vec4 color;
|
293
|
+
|
294
|
+
vec4 main(vec2 pos) {
|
295
|
+
return color;
|
296
|
+
}
|
297
|
+
`)!;
|
298
|
+
expect(colorShader).toBeDefined();
|
299
|
+
const img = await surface.draw(
|
300
|
+
<Fill>
|
301
|
+
<Shader source={colorSelection}>
|
302
|
+
<Shader
|
303
|
+
source={colorShader}
|
304
|
+
uniforms={{ color: Skia.Color("lightblue") }}
|
305
|
+
/>
|
306
|
+
<Shader
|
307
|
+
source={colorShader}
|
308
|
+
uniforms={{ color: Skia.Color("red") }}
|
309
|
+
/>
|
310
|
+
</Shader>
|
311
|
+
</Fill>
|
312
|
+
);
|
313
|
+
checkImage(img, docPath("shaders/mixed-colors.png"));
|
314
|
+
});
|
315
|
+
|
316
|
+
it("should display different results based on children order", async () => {
|
317
|
+
const { Skia } = importSkia();
|
318
|
+
const orderSensitiveShader = Skia.RuntimeEffect.Make(`uniform shader child1;
|
319
|
+
uniform shader child2;
|
320
|
+
|
321
|
+
vec4 main(vec2 pos) {
|
322
|
+
vec4 c1 = child1.eval(pos);
|
323
|
+
vec4 c2 = child2.eval(pos);
|
324
|
+
// Order-dependent: blend child2 over child1 with position-based alpha
|
325
|
+
float alpha = pos.x / 256.0;
|
326
|
+
return mix(c1, c2, alpha);
|
327
|
+
}`)!;
|
328
|
+
expect(orderSensitiveShader).toBeDefined();
|
329
|
+
const colorShader = Skia.RuntimeEffect.Make(`
|
330
|
+
uniform vec4 color;
|
331
|
+
|
332
|
+
vec4 main(vec2 pos) {
|
333
|
+
return color;
|
334
|
+
}
|
335
|
+
`)!;
|
336
|
+
expect(colorShader).toBeDefined();
|
337
|
+
const img = await surface.draw(
|
338
|
+
<Fill>
|
339
|
+
<Shader source={orderSensitiveShader}>
|
340
|
+
<Shader
|
341
|
+
source={colorShader}
|
342
|
+
uniforms={{ color: Skia.Color("blue") }}
|
343
|
+
/>
|
344
|
+
<Shader
|
345
|
+
source={colorShader}
|
346
|
+
uniforms={{ color: Skia.Color("yellow") }}
|
347
|
+
/>
|
348
|
+
</Shader>
|
349
|
+
</Fill>
|
350
|
+
);
|
351
|
+
checkImage(img, docPath("shaders/order-dependent.png"));
|
352
|
+
});
|
260
353
|
});
|