@shopify/react-native-skia 0.1.186 → 0.1.187
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/globalJestSetup.js +6 -0
- package/jestSetup.js +2 -3
- package/lib/commonjs/mock/index.d.ts +2 -15
- package/lib/commonjs/mock/index.js +37 -111
- package/lib/commonjs/mock/index.js.map +1 -1
- package/lib/module/mock/index.d.ts +2 -15
- package/lib/module/mock/index.js +33 -96
- package/lib/module/mock/index.js.map +1 -1
- package/lib/typescript/globalJestSetup.d.ts +2 -0
- package/lib/typescript/src/mock/index.d.ts +2 -15
- package/package.json +2 -1
- package/src/mock/index.ts +35 -99
package/jestSetup.js
CHANGED
@@ -1,15 +1,2 @@
|
|
1
|
-
import type {
|
2
|
-
|
3
|
-
import type * as ValueExports from "../values";
|
4
|
-
import type * as AnimationExports from "../animation";
|
5
|
-
import { ShaderLib } from "../renderer/components/shaders/ShaderLib";
|
6
|
-
export declare const Skia: SkiaApi;
|
7
|
-
export declare const vec: (x?: number, y?: number) => {
|
8
|
-
x: number;
|
9
|
-
y: number;
|
10
|
-
};
|
11
|
-
export declare const Mock: typeof SkiaExports & typeof ValueExports & typeof AnimationExports & {
|
12
|
-
createDrawing: () => any;
|
13
|
-
createDeclaration: () => any;
|
14
|
-
ShaderLib: typeof ShaderLib;
|
15
|
-
};
|
1
|
+
import type { CanvasKit } from "canvaskit-wasm";
|
2
|
+
export declare const Mock: (CanvasKit: CanvasKit) => any;
|
@@ -3,123 +3,49 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
6
|
+
exports.Mock = void 0;
|
7
7
|
|
8
|
-
var
|
8
|
+
var _web = require("../skia/web");
|
9
9
|
|
10
|
-
var
|
10
|
+
var _web2 = require("../values/web");
|
11
11
|
|
12
|
-
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
13
|
+
const Noop = () => undefined;
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
var timingFunctions = _interopRequireWildcard(require("../animation/timing"));
|
17
|
-
|
18
|
-
var springFunctions = _interopRequireWildcard(require("../animation/spring"));
|
19
|
-
|
20
|
-
var decayFunctions = _interopRequireWildcard(require("../animation/decay"));
|
21
|
-
|
22
|
-
var interpolateFn = _interopRequireWildcard(require("../animation/functions/interpolate"));
|
23
|
-
|
24
|
-
var interpolatePathFn = _interopRequireWildcard(require("../animation/functions/interpolatePaths"));
|
25
|
-
|
26
|
-
var interpolateVectorFn = _interopRequireWildcard(require("../animation/functions/interpolateVector"));
|
27
|
-
|
28
|
-
var _ShaderLib = require("../renderer/components/shaders/ShaderLib");
|
29
|
-
|
30
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
31
|
-
|
32
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
33
|
-
|
34
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
35
|
-
class Stub {
|
36
|
-
constructor() {
|
37
|
-
return new Proxy(() => {}, {
|
38
|
-
get: () => new Stub(),
|
39
|
-
apply: () => new Stub(),
|
40
|
-
set: () => true
|
41
|
-
});
|
42
|
-
}
|
43
|
-
|
44
|
-
}
|
45
|
-
|
46
|
-
const Noop = () => {};
|
47
|
-
|
48
|
-
const Skia = new Stub();
|
49
|
-
exports.Skia = Skia;
|
50
|
-
|
51
|
-
const vec = (x, y) => ({
|
52
|
-
x: x ?? 0,
|
53
|
-
y: y ?? x ?? 0
|
15
|
+
const NoopValue = () => ({
|
16
|
+
current: 0
|
54
17
|
});
|
55
18
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
sub: (a, b) => vec(a.x - b.x, a.y - b.y),
|
86
|
-
neg: a => vec(-a.x, -a.y),
|
87
|
-
dist: (a, b) => Math.hypot(a.x - b.x, a.y - b.y),
|
88
|
-
translate: _ref => {
|
89
|
-
let {
|
90
|
-
x,
|
91
|
-
y
|
92
|
-
} = _ref;
|
93
|
-
return [{
|
94
|
-
translateX: x
|
95
|
-
}, {
|
96
|
-
translateY: y
|
97
|
-
}];
|
98
|
-
},
|
99
|
-
bounds: Noop,
|
100
|
-
topLeft: Noop,
|
101
|
-
topRight: Noop,
|
102
|
-
bottomLeft: Noop,
|
103
|
-
bottomRight: Noop,
|
104
|
-
center: Noop,
|
105
|
-
processTransform2d: Noop,
|
106
|
-
// ValueExports
|
107
|
-
...Values,
|
108
|
-
...ValuesHooks,
|
109
|
-
Selector: _selector.Selector,
|
110
|
-
// Animations
|
111
|
-
...timingFunctions,
|
112
|
-
...springFunctions,
|
113
|
-
...decayFunctions,
|
114
|
-
...interpolateFn,
|
115
|
-
...interpolatePathFn,
|
116
|
-
...interpolateVectorFn,
|
117
|
-
interpolateColors: (_value, _inputRange, _outputRange) => Float32Array.of(0, 0, 0, 0),
|
118
|
-
mixColors: (_v, _x, _y) => Float32Array.of(0, 0, 0, 0),
|
119
|
-
ShaderLib: _ShaderLib.ShaderLib,
|
120
|
-
createDrawing: Noop,
|
121
|
-
createDeclaration: Noop,
|
122
|
-
makeImageFromView: Noop
|
19
|
+
const Mock = CanvasKit => {
|
20
|
+
global.SkiaApi = (0, _web.JsiSkApi)(CanvasKit);
|
21
|
+
global.SkiaValueApi = _web2.ValueApi;
|
22
|
+
const Skia = global.SkiaApi;
|
23
|
+
return {
|
24
|
+
Skia,
|
25
|
+
...require("../renderer/components"),
|
26
|
+
...require("../skia"),
|
27
|
+
...require("../values"),
|
28
|
+
...require("../animation"),
|
29
|
+
...require("../dom/types"),
|
30
|
+
...require("../dom/nodes"),
|
31
|
+
// We could use the real Canvas if we mock the SkiaView component for node
|
32
|
+
Canvas: Noop,
|
33
|
+
useValue: NoopValue,
|
34
|
+
useComputedValue: NoopValue,
|
35
|
+
useTouchHandler: Noop,
|
36
|
+
useTiming: NoopValue,
|
37
|
+
useLoop: NoopValue,
|
38
|
+
useSpring: NoopValue,
|
39
|
+
useClockValue: NoopValue,
|
40
|
+
useValueEffect: Noop,
|
41
|
+
useRawData: Noop,
|
42
|
+
useData: Noop,
|
43
|
+
useFont: () => Skia.Font(undefined, 0),
|
44
|
+
useTypeface: () => null,
|
45
|
+
useImage: () => null,
|
46
|
+
useSVG: () => null
|
47
|
+
};
|
123
48
|
};
|
49
|
+
|
124
50
|
exports.Mock = Mock;
|
125
51
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["Noop","undefined","NoopValue","current","Mock","CanvasKit","global","SkiaApi","JsiSkApi","SkiaValueApi","ValueApi","Skia","require","Canvas","useValue","useComputedValue","useTouchHandler","useTiming","useLoop","useSpring","useClockValue","useValueEffect","useRawData","useData","useFont","Font","useTypeface","useImage","useSVG"],"sources":["index.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport { JsiSkApi } from \"../skia/web\";\nimport { ValueApi } from \"../values/web\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst Noop: () => any = () => undefined;\nconst NoopValue = () => ({ current: 0 });\n\nexport const Mock = (CanvasKit: CanvasKit) => {\n global.SkiaApi = JsiSkApi(CanvasKit);\n global.SkiaValueApi = ValueApi;\n const Skia = global.SkiaApi;\n return {\n Skia,\n ...require(\"../renderer/components\"),\n ...require(\"../skia\"),\n ...require(\"../values\"),\n ...require(\"../animation\"),\n ...require(\"../dom/types\"),\n ...require(\"../dom/nodes\"),\n // We could use the real Canvas if we mock the SkiaView component for node\n Canvas: Noop,\n useValue: NoopValue,\n useComputedValue: NoopValue,\n useTouchHandler: Noop,\n useTiming: NoopValue,\n useLoop: NoopValue,\n useSpring: NoopValue,\n useClockValue: NoopValue,\n useValueEffect: Noop,\n useRawData: Noop,\n useData: Noop,\n useFont: () => Skia.Font(undefined, 0),\n useTypeface: () => null,\n useImage: () => null,\n useSVG: () => null,\n };\n};\n"],"mappings":";;;;;;;AAEA;;AACA;;AAEA;AACA,MAAMA,IAAe,GAAG,MAAMC,SAA9B;;AACA,MAAMC,SAAS,GAAG,OAAO;EAAEC,OAAO,EAAE;AAAX,CAAP,CAAlB;;AAEO,MAAMC,IAAI,GAAIC,SAAD,IAA0B;EAC5CC,MAAM,CAACC,OAAP,GAAiB,IAAAC,aAAA,EAASH,SAAT,CAAjB;EACAC,MAAM,CAACG,YAAP,GAAsBC,cAAtB;EACA,MAAMC,IAAI,GAAGL,MAAM,CAACC,OAApB;EACA,OAAO;IACLI,IADK;IAEL,GAAGC,OAAO,CAAC,wBAAD,CAFL;IAGL,GAAGA,OAAO,CAAC,SAAD,CAHL;IAIL,GAAGA,OAAO,CAAC,WAAD,CAJL;IAKL,GAAGA,OAAO,CAAC,cAAD,CALL;IAML,GAAGA,OAAO,CAAC,cAAD,CANL;IAOL,GAAGA,OAAO,CAAC,cAAD,CAPL;IAQL;IACAC,MAAM,EAAEb,IATH;IAULc,QAAQ,EAAEZ,SAVL;IAWLa,gBAAgB,EAAEb,SAXb;IAYLc,eAAe,EAAEhB,IAZZ;IAaLiB,SAAS,EAAEf,SAbN;IAcLgB,OAAO,EAAEhB,SAdJ;IAeLiB,SAAS,EAAEjB,SAfN;IAgBLkB,aAAa,EAAElB,SAhBV;IAiBLmB,cAAc,EAAErB,IAjBX;IAkBLsB,UAAU,EAAEtB,IAlBP;IAmBLuB,OAAO,EAAEvB,IAnBJ;IAoBLwB,OAAO,EAAE,MAAMb,IAAI,CAACc,IAAL,CAAUxB,SAAV,EAAqB,CAArB,CApBV;IAqBLyB,WAAW,EAAE,MAAM,IArBd;IAsBLC,QAAQ,EAAE,MAAM,IAtBX;IAuBLC,MAAM,EAAE,MAAM;EAvBT,CAAP;AAyBD,CA7BM"}
|
@@ -1,15 +1,2 @@
|
|
1
|
-
import type {
|
2
|
-
|
3
|
-
import type * as ValueExports from "../values";
|
4
|
-
import type * as AnimationExports from "../animation";
|
5
|
-
import { ShaderLib } from "../renderer/components/shaders/ShaderLib";
|
6
|
-
export declare const Skia: SkiaApi;
|
7
|
-
export declare const vec: (x?: number, y?: number) => {
|
8
|
-
x: number;
|
9
|
-
y: number;
|
10
|
-
};
|
11
|
-
export declare const Mock: typeof SkiaExports & typeof ValueExports & typeof AnimationExports & {
|
12
|
-
createDrawing: () => any;
|
13
|
-
createDeclaration: () => any;
|
14
|
-
ShaderLib: typeof ShaderLib;
|
15
|
-
};
|
1
|
+
import type { CanvasKit } from "canvaskit-wasm";
|
2
|
+
export declare const Mock: (CanvasKit: CanvasKit) => any;
|
package/lib/module/mock/index.js
CHANGED
@@ -1,103 +1,40 @@
|
|
1
|
-
|
2
|
-
import
|
3
|
-
import * as ValuesHooks from "../values/hooks";
|
4
|
-
import { Selector } from "../values/selector";
|
5
|
-
import * as BaseSkia from "../skia/types";
|
6
|
-
import * as timingFunctions from "../animation/timing";
|
7
|
-
import * as springFunctions from "../animation/spring";
|
8
|
-
import * as decayFunctions from "../animation/decay";
|
9
|
-
import * as interpolateFn from "../animation/functions/interpolate";
|
10
|
-
import * as interpolatePathFn from "../animation/functions/interpolatePaths";
|
11
|
-
import * as interpolateVectorFn from "../animation/functions/interpolateVector";
|
12
|
-
import { ShaderLib } from "../renderer/components/shaders/ShaderLib";
|
1
|
+
import { JsiSkApi } from "../skia/web";
|
2
|
+
import { ValueApi } from "../values/web"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
13
3
|
|
14
|
-
|
15
|
-
constructor() {
|
16
|
-
return new Proxy(() => {}, {
|
17
|
-
get: () => new Stub(),
|
18
|
-
apply: () => new Stub(),
|
19
|
-
set: () => true
|
20
|
-
});
|
21
|
-
}
|
4
|
+
const Noop = () => undefined;
|
22
5
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
export const Skia = new Stub();
|
28
|
-
export const vec = (x, y) => {
|
29
|
-
var _ref;
|
6
|
+
const NoopValue = () => ({
|
7
|
+
current: 0
|
8
|
+
});
|
30
9
|
|
10
|
+
export const Mock = CanvasKit => {
|
11
|
+
global.SkiaApi = JsiSkApi(CanvasKit);
|
12
|
+
global.SkiaValueApi = ValueApi;
|
13
|
+
const Skia = global.SkiaApi;
|
31
14
|
return {
|
32
|
-
|
33
|
-
|
15
|
+
Skia,
|
16
|
+
...require("../renderer/components"),
|
17
|
+
...require("../skia"),
|
18
|
+
...require("../values"),
|
19
|
+
...require("../animation"),
|
20
|
+
...require("../dom/types"),
|
21
|
+
...require("../dom/nodes"),
|
22
|
+
// We could use the real Canvas if we mock the SkiaView component for node
|
23
|
+
Canvas: Noop,
|
24
|
+
useValue: NoopValue,
|
25
|
+
useComputedValue: NoopValue,
|
26
|
+
useTouchHandler: Noop,
|
27
|
+
useTiming: NoopValue,
|
28
|
+
useLoop: NoopValue,
|
29
|
+
useSpring: NoopValue,
|
30
|
+
useClockValue: NoopValue,
|
31
|
+
useValueEffect: Noop,
|
32
|
+
useRawData: Noop,
|
33
|
+
useData: Noop,
|
34
|
+
useFont: () => Skia.Font(undefined, 0),
|
35
|
+
useTypeface: () => null,
|
36
|
+
useImage: () => null,
|
37
|
+
useSVG: () => null
|
34
38
|
};
|
35
39
|
};
|
36
|
-
export const Mock = {
|
37
|
-
// SkiaExports
|
38
|
-
// 1. Skia API. BaseSkia contains the enums, and functions like isPaint etc
|
39
|
-
Skia,
|
40
|
-
...BaseSkia,
|
41
|
-
// 2. Hooks
|
42
|
-
useRawData: Noop,
|
43
|
-
useData: Noop,
|
44
|
-
useFont: Noop,
|
45
|
-
useTypeface: Noop,
|
46
|
-
useImage: Noop,
|
47
|
-
useSVG: Noop,
|
48
|
-
createPicture: Noop,
|
49
|
-
// 3. Point/Rect/Transform utilities
|
50
|
-
vec,
|
51
|
-
rect: (x, y, width, height) => ({
|
52
|
-
x,
|
53
|
-
y,
|
54
|
-
width,
|
55
|
-
height
|
56
|
-
}),
|
57
|
-
rrect: (r, rx, ry) => ({
|
58
|
-
rect: r,
|
59
|
-
rx,
|
60
|
-
ry
|
61
|
-
}),
|
62
|
-
point: vec,
|
63
|
-
add: (a, b) => vec(a.x + b.x, a.y + b.y),
|
64
|
-
sub: (a, b) => vec(a.x - b.x, a.y - b.y),
|
65
|
-
neg: a => vec(-a.x, -a.y),
|
66
|
-
dist: (a, b) => Math.hypot(a.x - b.x, a.y - b.y),
|
67
|
-
translate: _ref2 => {
|
68
|
-
let {
|
69
|
-
x,
|
70
|
-
y
|
71
|
-
} = _ref2;
|
72
|
-
return [{
|
73
|
-
translateX: x
|
74
|
-
}, {
|
75
|
-
translateY: y
|
76
|
-
}];
|
77
|
-
},
|
78
|
-
bounds: Noop,
|
79
|
-
topLeft: Noop,
|
80
|
-
topRight: Noop,
|
81
|
-
bottomLeft: Noop,
|
82
|
-
bottomRight: Noop,
|
83
|
-
center: Noop,
|
84
|
-
processTransform2d: Noop,
|
85
|
-
// ValueExports
|
86
|
-
...Values,
|
87
|
-
...ValuesHooks,
|
88
|
-
Selector,
|
89
|
-
// Animations
|
90
|
-
...timingFunctions,
|
91
|
-
...springFunctions,
|
92
|
-
...decayFunctions,
|
93
|
-
...interpolateFn,
|
94
|
-
...interpolatePathFn,
|
95
|
-
...interpolateVectorFn,
|
96
|
-
interpolateColors: (_value, _inputRange, _outputRange) => Float32Array.of(0, 0, 0, 0),
|
97
|
-
mixColors: (_v, _x, _y) => Float32Array.of(0, 0, 0, 0),
|
98
|
-
ShaderLib,
|
99
|
-
createDrawing: Noop,
|
100
|
-
createDeclaration: Noop,
|
101
|
-
makeImageFromView: Noop
|
102
|
-
};
|
103
40
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["JsiSkApi","ValueApi","Noop","undefined","NoopValue","current","Mock","CanvasKit","global","SkiaApi","SkiaValueApi","Skia","require","Canvas","useValue","useComputedValue","useTouchHandler","useTiming","useLoop","useSpring","useClockValue","useValueEffect","useRawData","useData","useFont","Font","useTypeface","useImage","useSVG"],"sources":["index.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport { JsiSkApi } from \"../skia/web\";\nimport { ValueApi } from \"../values/web\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst Noop: () => any = () => undefined;\nconst NoopValue = () => ({ current: 0 });\n\nexport const Mock = (CanvasKit: CanvasKit) => {\n global.SkiaApi = JsiSkApi(CanvasKit);\n global.SkiaValueApi = ValueApi;\n const Skia = global.SkiaApi;\n return {\n Skia,\n ...require(\"../renderer/components\"),\n ...require(\"../skia\"),\n ...require(\"../values\"),\n ...require(\"../animation\"),\n ...require(\"../dom/types\"),\n ...require(\"../dom/nodes\"),\n // We could use the real Canvas if we mock the SkiaView component for node\n Canvas: Noop,\n useValue: NoopValue,\n useComputedValue: NoopValue,\n useTouchHandler: Noop,\n useTiming: NoopValue,\n useLoop: NoopValue,\n useSpring: NoopValue,\n useClockValue: NoopValue,\n useValueEffect: Noop,\n useRawData: Noop,\n useData: Noop,\n useFont: () => Skia.Font(undefined, 0),\n useTypeface: () => null,\n useImage: () => null,\n useSVG: () => null,\n };\n};\n"],"mappings":"AAEA,SAASA,QAAT,QAAyB,aAAzB;AACA,SAASC,QAAT,QAAyB,eAAzB,C,CAEA;;AACA,MAAMC,IAAe,GAAG,MAAMC,SAA9B;;AACA,MAAMC,SAAS,GAAG,OAAO;EAAEC,OAAO,EAAE;AAAX,CAAP,CAAlB;;AAEA,OAAO,MAAMC,IAAI,GAAIC,SAAD,IAA0B;EAC5CC,MAAM,CAACC,OAAP,GAAiBT,QAAQ,CAACO,SAAD,CAAzB;EACAC,MAAM,CAACE,YAAP,GAAsBT,QAAtB;EACA,MAAMU,IAAI,GAAGH,MAAM,CAACC,OAApB;EACA,OAAO;IACLE,IADK;IAEL,GAAGC,OAAO,CAAC,wBAAD,CAFL;IAGL,GAAGA,OAAO,CAAC,SAAD,CAHL;IAIL,GAAGA,OAAO,CAAC,WAAD,CAJL;IAKL,GAAGA,OAAO,CAAC,cAAD,CALL;IAML,GAAGA,OAAO,CAAC,cAAD,CANL;IAOL,GAAGA,OAAO,CAAC,cAAD,CAPL;IAQL;IACAC,MAAM,EAAEX,IATH;IAULY,QAAQ,EAAEV,SAVL;IAWLW,gBAAgB,EAAEX,SAXb;IAYLY,eAAe,EAAEd,IAZZ;IAaLe,SAAS,EAAEb,SAbN;IAcLc,OAAO,EAAEd,SAdJ;IAeLe,SAAS,EAAEf,SAfN;IAgBLgB,aAAa,EAAEhB,SAhBV;IAiBLiB,cAAc,EAAEnB,IAjBX;IAkBLoB,UAAU,EAAEpB,IAlBP;IAmBLqB,OAAO,EAAErB,IAnBJ;IAoBLsB,OAAO,EAAE,MAAMb,IAAI,CAACc,IAAL,CAAUtB,SAAV,EAAqB,CAArB,CApBV;IAqBLuB,WAAW,EAAE,MAAM,IArBd;IAsBLC,QAAQ,EAAE,MAAM,IAtBX;IAuBLC,MAAM,EAAE,MAAM;EAvBT,CAAP;AAyBD,CA7BM"}
|
@@ -1,15 +1,2 @@
|
|
1
|
-
import type {
|
2
|
-
|
3
|
-
import type * as ValueExports from "../values";
|
4
|
-
import type * as AnimationExports from "../animation";
|
5
|
-
import { ShaderLib } from "../renderer/components/shaders/ShaderLib";
|
6
|
-
export declare const Skia: SkiaApi;
|
7
|
-
export declare const vec: (x?: number, y?: number) => {
|
8
|
-
x: number;
|
9
|
-
y: number;
|
10
|
-
};
|
11
|
-
export declare const Mock: typeof SkiaExports & typeof ValueExports & typeof AnimationExports & {
|
12
|
-
createDrawing: () => any;
|
13
|
-
createDeclaration: () => any;
|
14
|
-
ShaderLib: typeof ShaderLib;
|
15
|
-
};
|
1
|
+
import type { CanvasKit } from "canvaskit-wasm";
|
2
|
+
export declare const Mock: (CanvasKit: CanvasKit) => any;
|
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.187",
|
11
11
|
"description": "High-performance React Native Graphics using Skia",
|
12
12
|
"main": "lib/module/index.js",
|
13
13
|
"files": [
|
@@ -25,6 +25,7 @@
|
|
25
25
|
"libs/android/**",
|
26
26
|
"index.js",
|
27
27
|
"jestSetup.js",
|
28
|
+
"globalJestSetup.js",
|
28
29
|
"cpp/**/*.{h,cpp}",
|
29
30
|
"ios",
|
30
31
|
"libs/ios/libskia.xcframework",
|
package/src/mock/index.ts
CHANGED
@@ -1,103 +1,39 @@
|
|
1
|
-
|
1
|
+
import type { CanvasKit } from "canvaskit-wasm";
|
2
2
|
|
3
|
-
import
|
4
|
-
import
|
5
|
-
import * as ValuesHooks from "../values/hooks";
|
6
|
-
import { Selector } from "../values/selector";
|
7
|
-
import * as BaseSkia from "../skia/types";
|
8
|
-
import type * as SkiaExports from "../skia";
|
9
|
-
import type * as ValueExports from "../values";
|
10
|
-
import type * as AnimationExports from "../animation";
|
11
|
-
import * as timingFunctions from "../animation/timing";
|
12
|
-
import * as springFunctions from "../animation/spring";
|
13
|
-
import * as decayFunctions from "../animation/decay";
|
14
|
-
import * as interpolateFn from "../animation/functions/interpolate";
|
15
|
-
import * as interpolatePathFn from "../animation/functions/interpolatePaths";
|
16
|
-
import * as interpolateVectorFn from "../animation/functions/interpolateVector";
|
17
|
-
import { ShaderLib } from "../renderer/components/shaders/ShaderLib";
|
3
|
+
import { JsiSkApi } from "../skia/web";
|
4
|
+
import { ValueApi } from "../values/web";
|
18
5
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
get: () => new Stub(),
|
23
|
-
apply: () => new Stub(),
|
24
|
-
set: () => true,
|
25
|
-
});
|
26
|
-
}
|
27
|
-
}
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
7
|
+
const Noop: () => any = () => undefined;
|
8
|
+
const NoopValue = () => ({ current: 0 });
|
28
9
|
|
29
|
-
const
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
y,
|
59
|
-
width,
|
60
|
-
height,
|
61
|
-
}),
|
62
|
-
rrect: (r: SkRect, rx: number, ry: number) => ({
|
63
|
-
rect: r,
|
64
|
-
rx,
|
65
|
-
ry,
|
66
|
-
}),
|
67
|
-
point: vec,
|
68
|
-
add: (a: Vector, b: Vector) => vec(a.x + b.x, a.y + b.y),
|
69
|
-
sub: (a: Vector, b: Vector) => vec(a.x - b.x, a.y - b.y),
|
70
|
-
neg: (a: Vector) => vec(-a.x, -a.y),
|
71
|
-
dist: (a: Vector, b: Vector) => Math.hypot(a.x - b.x, a.y - b.y),
|
72
|
-
translate: ({ x, y }: Vector) =>
|
73
|
-
[{ translateX: x }, { translateY: y }] as const,
|
74
|
-
|
75
|
-
bounds: Noop,
|
76
|
-
topLeft: Noop,
|
77
|
-
topRight: Noop,
|
78
|
-
bottomLeft: Noop,
|
79
|
-
bottomRight: Noop,
|
80
|
-
center: Noop,
|
81
|
-
processTransform2d: Noop,
|
82
|
-
// ValueExports
|
83
|
-
...Values,
|
84
|
-
...ValuesHooks,
|
85
|
-
Selector,
|
86
|
-
// Animations
|
87
|
-
...timingFunctions,
|
88
|
-
...springFunctions,
|
89
|
-
...decayFunctions,
|
90
|
-
...interpolateFn,
|
91
|
-
...interpolatePathFn,
|
92
|
-
...interpolateVectorFn,
|
93
|
-
interpolateColors: (
|
94
|
-
_value: number,
|
95
|
-
_inputRange: number[],
|
96
|
-
_outputRange: Color[]
|
97
|
-
) => Float32Array.of(0, 0, 0, 0),
|
98
|
-
mixColors: (_v: number, _x: Color, _y: Color) => Float32Array.of(0, 0, 0, 0),
|
99
|
-
ShaderLib,
|
100
|
-
createDrawing: Noop,
|
101
|
-
createDeclaration: Noop,
|
102
|
-
makeImageFromView: Noop,
|
10
|
+
export const Mock = (CanvasKit: CanvasKit) => {
|
11
|
+
global.SkiaApi = JsiSkApi(CanvasKit);
|
12
|
+
global.SkiaValueApi = ValueApi;
|
13
|
+
const Skia = global.SkiaApi;
|
14
|
+
return {
|
15
|
+
Skia,
|
16
|
+
...require("../renderer/components"),
|
17
|
+
...require("../skia"),
|
18
|
+
...require("../values"),
|
19
|
+
...require("../animation"),
|
20
|
+
...require("../dom/types"),
|
21
|
+
...require("../dom/nodes"),
|
22
|
+
// We could use the real Canvas if we mock the SkiaView component for node
|
23
|
+
Canvas: Noop,
|
24
|
+
useValue: NoopValue,
|
25
|
+
useComputedValue: NoopValue,
|
26
|
+
useTouchHandler: Noop,
|
27
|
+
useTiming: NoopValue,
|
28
|
+
useLoop: NoopValue,
|
29
|
+
useSpring: NoopValue,
|
30
|
+
useClockValue: NoopValue,
|
31
|
+
useValueEffect: Noop,
|
32
|
+
useRawData: Noop,
|
33
|
+
useData: Noop,
|
34
|
+
useFont: () => Skia.Font(undefined, 0),
|
35
|
+
useTypeface: () => null,
|
36
|
+
useImage: () => null,
|
37
|
+
useSVG: () => null,
|
38
|
+
};
|
103
39
|
};
|