@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.
@@ -0,0 +1,6 @@
1
+ module.exports = async () => {
2
+ const {
3
+ LoadSkiaWeb,
4
+ } = require("@shopify/react-native-skia/lib/commonjs/web/LoadSkiaWeb");
5
+ await LoadSkiaWeb();
6
+ };
package/jestSetup.js CHANGED
@@ -1,5 +1,4 @@
1
1
  /* globals jest */
2
- jest.mock(
3
- "@shopify/react-native-skia",
4
- () => require("@shopify/react-native-skia/lib/commonjs/mock").Mock
2
+ jest.mock("@shopify/react-native-skia", () =>
3
+ require("@shopify/react-native-skia/lib/commonjs/mock").Mock(global.CanvasKit)
5
4
  );
@@ -1,15 +1,2 @@
1
- import type { Skia as SkiaApi } from "../skia/types";
2
- import type * as SkiaExports from "../skia";
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.vec = exports.Skia = exports.Mock = void 0;
6
+ exports.Mock = void 0;
7
7
 
8
- var Values = _interopRequireWildcard(require("../values/web"));
8
+ var _web = require("../skia/web");
9
9
 
10
- var ValuesHooks = _interopRequireWildcard(require("../values/hooks"));
10
+ var _web2 = require("../values/web");
11
11
 
12
- var _selector = require("../values/selector");
12
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
+ const Noop = () => undefined;
13
14
 
14
- var BaseSkia = _interopRequireWildcard(require("../skia/types"));
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
- exports.vec = vec;
57
- const Mock = {
58
- // SkiaExports
59
- // 1. Skia API. BaseSkia contains the enums, and functions like isPaint etc
60
- Skia,
61
- ...BaseSkia,
62
- // 2. Hooks
63
- useRawData: Noop,
64
- useData: Noop,
65
- useFont: Noop,
66
- useTypeface: Noop,
67
- useImage: Noop,
68
- useSVG: Noop,
69
- createPicture: Noop,
70
- // 3. Point/Rect/Transform utilities
71
- vec,
72
- rect: (x, y, width, height) => ({
73
- x,
74
- y,
75
- width,
76
- height
77
- }),
78
- rrect: (r, rx, ry) => ({
79
- rect: r,
80
- rx,
81
- ry
82
- }),
83
- point: vec,
84
- add: (a, b) => vec(a.x + b.x, a.y + b.y),
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":["Stub","constructor","Proxy","get","apply","set","Noop","Skia","vec","x","y","Mock","BaseSkia","useRawData","useData","useFont","useTypeface","useImage","useSVG","createPicture","rect","width","height","rrect","r","rx","ry","point","add","a","b","sub","neg","dist","Math","hypot","translate","translateX","translateY","bounds","topLeft","topRight","bottomLeft","bottomRight","center","processTransform2d","Values","ValuesHooks","Selector","timingFunctions","springFunctions","decayFunctions","interpolateFn","interpolatePathFn","interpolateVectorFn","interpolateColors","_value","_inputRange","_outputRange","Float32Array","of","mixColors","_v","_x","_y","ShaderLib","createDrawing","createDeclaration","makeImageFromView"],"sources":["index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type { Color, Skia as SkiaApi, SkRect, Vector } from \"../skia/types\";\nimport * as Values from \"../values/web\";\nimport * as ValuesHooks from \"../values/hooks\";\nimport { Selector } from \"../values/selector\";\nimport * as BaseSkia from \"../skia/types\";\nimport type * as SkiaExports from \"../skia\";\nimport type * as ValueExports from \"../values\";\nimport type * as AnimationExports from \"../animation\";\nimport * as timingFunctions from \"../animation/timing\";\nimport * as springFunctions from \"../animation/spring\";\nimport * as decayFunctions from \"../animation/decay\";\nimport * as interpolateFn from \"../animation/functions/interpolate\";\nimport * as interpolatePathFn from \"../animation/functions/interpolatePaths\";\nimport * as interpolateVectorFn from \"../animation/functions/interpolateVector\";\nimport { ShaderLib } from \"../renderer/components/shaders/ShaderLib\";\n\nclass Stub {\n constructor() {\n return new Proxy(() => {}, {\n get: () => new Stub(),\n apply: () => new Stub(),\n set: () => true,\n });\n }\n}\n\nconst Noop: () => any = () => {};\n\nexport const Skia: SkiaApi = new Stub() as any;\n\nexport const vec = (x?: number, y?: number) => ({ x: x ?? 0, y: y ?? x ?? 0 });\n\nexport const Mock: typeof SkiaExports &\n typeof ValueExports &\n typeof AnimationExports & {\n createDrawing: () => any;\n createDeclaration: () => any;\n ShaderLib: typeof ShaderLib;\n } = {\n // SkiaExports\n // 1. Skia API. BaseSkia contains the enums, and functions like isPaint etc\n Skia,\n ...BaseSkia,\n // 2. Hooks\n useRawData: Noop,\n useData: Noop,\n useFont: Noop,\n useTypeface: Noop,\n useImage: Noop,\n useSVG: Noop,\n createPicture: Noop,\n // 3. Point/Rect/Transform utilities\n vec,\n rect: (x: number, y: number, width: number, height: number) => ({\n x,\n y,\n width,\n height,\n }),\n rrect: (r: SkRect, rx: number, ry: number) => ({\n rect: r,\n rx,\n ry,\n }),\n point: vec,\n add: (a: Vector, b: Vector) => vec(a.x + b.x, a.y + b.y),\n sub: (a: Vector, b: Vector) => vec(a.x - b.x, a.y - b.y),\n neg: (a: Vector) => vec(-a.x, -a.y),\n dist: (a: Vector, b: Vector) => Math.hypot(a.x - b.x, a.y - b.y),\n translate: ({ x, y }: Vector) =>\n [{ translateX: x }, { translateY: y }] as const,\n\n bounds: Noop,\n topLeft: Noop,\n topRight: Noop,\n bottomLeft: Noop,\n bottomRight: Noop,\n center: Noop,\n processTransform2d: Noop,\n // ValueExports\n ...Values,\n ...ValuesHooks,\n Selector,\n // Animations\n ...timingFunctions,\n ...springFunctions,\n ...decayFunctions,\n ...interpolateFn,\n ...interpolatePathFn,\n ...interpolateVectorFn,\n interpolateColors: (\n _value: number,\n _inputRange: number[],\n _outputRange: Color[]\n ) => Float32Array.of(0, 0, 0, 0),\n mixColors: (_v: number, _x: Color, _y: Color) => Float32Array.of(0, 0, 0, 0),\n ShaderLib,\n createDrawing: Noop,\n createDeclaration: Noop,\n makeImageFromView: Noop,\n};\n"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AAIA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAhBA;AAkBA,MAAMA,IAAN,CAAW;EACTC,WAAW,GAAG;IACZ,OAAO,IAAIC,KAAJ,CAAU,MAAM,CAAE,CAAlB,EAAoB;MACzBC,GAAG,EAAE,MAAM,IAAIH,IAAJ,EADc;MAEzBI,KAAK,EAAE,MAAM,IAAIJ,IAAJ,EAFY;MAGzBK,GAAG,EAAE,MAAM;IAHc,CAApB,CAAP;EAKD;;AAPQ;;AAUX,MAAMC,IAAe,GAAG,MAAM,CAAE,CAAhC;;AAEO,MAAMC,IAAa,GAAG,IAAIP,IAAJ,EAAtB;;;AAEA,MAAMQ,GAAG,GAAG,CAACC,CAAD,EAAaC,CAAb,MAA6B;EAAED,CAAC,EAAEA,CAAC,IAAI,CAAV;EAAaC,CAAC,EAAEA,CAAC,IAAID,CAAL,IAAU;AAA1B,CAA7B,CAAZ;;;AAEA,MAAME,IAMV,GAAG;EACJ;EACA;EACAJ,IAHI;EAIJ,GAAGK,QAJC;EAKJ;EACAC,UAAU,EAAEP,IANR;EAOJQ,OAAO,EAAER,IAPL;EAQJS,OAAO,EAAET,IARL;EASJU,WAAW,EAAEV,IATT;EAUJW,QAAQ,EAAEX,IAVN;EAWJY,MAAM,EAAEZ,IAXJ;EAYJa,aAAa,EAAEb,IAZX;EAaJ;EACAE,GAdI;EAeJY,IAAI,EAAE,CAACX,CAAD,EAA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AQ,EAAEnC,IApCN;EAqCJoC,UAAU,EAAEpC,IArCR;EAsCJqC,WAAW,EAAErC,IAtCT;EAuCJsC,MAAM,EAAEtC,IAvCJ;EAwCJuC,kBAAkB,EAAEvC,IAxChB;EAyCJ;EACA,GAAGwC,MA1CC;EA2CJ,GAAGC,WA3CC;EA4CJC,QAAQ,EAARA,kBA5CI;EA6CJ;EACA,GAAGC,eA9CC;EA+CJ,GAAGC,eA/CC;EAgDJ,GAAGC,cAhDC;EAiDJ,GAAGC,aAjDC;EAkDJ,GAAGC,iBAlDC;EAmDJ,GAAGC,mBAnDC;EAoDJC,iBAAiB,EAAE,CACjBC,MADiB,EAEjBC,WAFiB,EAGjBC,YAHiB,KAIdC,YAAY,CAACC,EAAb,CAAgB,CAAhB,EAAmB,CAAnB,EAAsB,CAAtB,EAAyB,CAAzB,CAxDD;EAyDJC,SAAS,EAAE,CAACC,EAAD,EAAaC,EAAb,EAAwBC,EAAxB,KAAsCL,YAAY,CAACC,EAAb,CAAgB,CAAhB,EAAmB,CAAnB,EAAsB,CAAtB,EAAyB,CAAzB,CAzD7C;EA0DJK,SAAS,EAATA,oBA1DI;EA2DJC,aAAa,EAAE5D,IA3DX;EA4DJ6D,iBAAiB,EAAE7D,IA5Df;EA6DJ8D,iBAAiB,EAAE9D;AA7Df,CANC"}
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 { Skia as SkiaApi } from "../skia/types";
2
- import type * as SkiaExports from "../skia";
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;
@@ -1,103 +1,40 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import * as Values from "../values/web";
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
- class Stub {
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
- const Noop = () => {};
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
- x: x !== null && x !== void 0 ? x : 0,
33
- y: (_ref = y !== null && y !== void 0 ? y : x) !== null && _ref !== void 0 ? _ref : 0
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":["Values","ValuesHooks","Selector","BaseSkia","timingFunctions","springFunctions","decayFunctions","interpolateFn","interpolatePathFn","interpolateVectorFn","ShaderLib","Stub","constructor","Proxy","get","apply","set","Noop","Skia","vec","x","y","Mock","useRawData","useData","useFont","useTypeface","useImage","useSVG","createPicture","rect","width","height","rrect","r","rx","ry","point","add","a","b","sub","neg","dist","Math","hypot","translate","translateX","translateY","bounds","topLeft","topRight","bottomLeft","bottomRight","center","processTransform2d","interpolateColors","_value","_inputRange","_outputRange","Float32Array","of","mixColors","_v","_x","_y","createDrawing","createDeclaration","makeImageFromView"],"sources":["index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type { Color, Skia as SkiaApi, SkRect, Vector } from \"../skia/types\";\nimport * as Values from \"../values/web\";\nimport * as ValuesHooks from \"../values/hooks\";\nimport { Selector } from \"../values/selector\";\nimport * as BaseSkia from \"../skia/types\";\nimport type * as SkiaExports from \"../skia\";\nimport type * as ValueExports from \"../values\";\nimport type * as AnimationExports from \"../animation\";\nimport * as timingFunctions from \"../animation/timing\";\nimport * as springFunctions from \"../animation/spring\";\nimport * as decayFunctions from \"../animation/decay\";\nimport * as interpolateFn from \"../animation/functions/interpolate\";\nimport * as interpolatePathFn from \"../animation/functions/interpolatePaths\";\nimport * as interpolateVectorFn from \"../animation/functions/interpolateVector\";\nimport { ShaderLib } from \"../renderer/components/shaders/ShaderLib\";\n\nclass Stub {\n constructor() {\n return new Proxy(() => {}, {\n get: () => new Stub(),\n apply: () => new Stub(),\n set: () => true,\n });\n }\n}\n\nconst Noop: () => any = () => {};\n\nexport const Skia: SkiaApi = new Stub() as any;\n\nexport const vec = (x?: number, y?: number) => ({ x: x ?? 0, y: y ?? x ?? 0 });\n\nexport const Mock: typeof SkiaExports &\n typeof ValueExports &\n typeof AnimationExports & {\n createDrawing: () => any;\n createDeclaration: () => any;\n ShaderLib: typeof ShaderLib;\n } = {\n // SkiaExports\n // 1. Skia API. BaseSkia contains the enums, and functions like isPaint etc\n Skia,\n ...BaseSkia,\n // 2. Hooks\n useRawData: Noop,\n useData: Noop,\n useFont: Noop,\n useTypeface: Noop,\n useImage: Noop,\n useSVG: Noop,\n createPicture: Noop,\n // 3. Point/Rect/Transform utilities\n vec,\n rect: (x: number, y: number, width: number, height: number) => ({\n x,\n y,\n width,\n height,\n }),\n rrect: (r: SkRect, rx: number, ry: number) => ({\n rect: r,\n rx,\n ry,\n }),\n point: vec,\n add: (a: Vector, b: Vector) => vec(a.x + b.x, a.y + b.y),\n sub: (a: Vector, b: Vector) => vec(a.x - b.x, a.y - b.y),\n neg: (a: Vector) => vec(-a.x, -a.y),\n dist: (a: Vector, b: Vector) => Math.hypot(a.x - b.x, a.y - b.y),\n translate: ({ x, y }: Vector) =>\n [{ translateX: x }, { translateY: y }] as const,\n\n bounds: Noop,\n topLeft: Noop,\n topRight: Noop,\n bottomLeft: Noop,\n bottomRight: Noop,\n center: Noop,\n processTransform2d: Noop,\n // ValueExports\n ...Values,\n ...ValuesHooks,\n Selector,\n // Animations\n ...timingFunctions,\n ...springFunctions,\n ...decayFunctions,\n ...interpolateFn,\n ...interpolatePathFn,\n ...interpolateVectorFn,\n interpolateColors: (\n _value: number,\n _inputRange: number[],\n _outputRange: Color[]\n ) => Float32Array.of(0, 0, 0, 0),\n mixColors: (_v: number, _x: Color, _y: Color) => Float32Array.of(0, 0, 0, 0),\n ShaderLib,\n createDrawing: Noop,\n createDeclaration: Noop,\n makeImageFromView: Noop,\n};\n"],"mappings":"AAAA;AAGA,OAAO,KAAKA,MAAZ,MAAwB,eAAxB;AACA,OAAO,KAAKC,WAAZ,MAA6B,iBAA7B;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,OAAO,KAAKC,QAAZ,MAA0B,eAA1B;AAIA,OAAO,KAAKC,eAAZ,MAAiC,qBAAjC;AACA,OAAO,KAAKC,eAAZ,MAAiC,qBAAjC;AACA,OAAO,KAAKC,cAAZ,MAAgC,oBAAhC;AACA,OAAO,KAAKC,aAAZ,MAA+B,oCAA/B;AACA,OAAO,KAAKC,iBAAZ,MAAmC,yCAAnC;AACA,OAAO,KAAKC,mBAAZ,MAAqC,0CAArC;AACA,SAASC,SAAT,QAA0B,0CAA1B;;AAEA,MAAMC,IAAN,CAAW;EACTC,WAAW,GAAG;IACZ,OAAO,IAAIC,KAAJ,CAAU,MAAM,CAAE,CAAlB,EAAoB;MACzBC,GAAG,EAAE,MAAM,IAAIH,IAAJ,EADc;MAEzBI,KAAK,EAAE,MAAM,IAAIJ,IAAJ,EAFY;MAGzBK,GAAG,EAAE,MAAM;IAHc,CAApB,CAAP;EAKD;;AAPQ;;AAUX,MAAMC,IAAe,GAA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ACC,EAAb,CAAgB,CAAhB,EAAmB,CAAnB,EAAsB,CAAtB,EAAyB,CAAzB,CAzD7C;EA0DJnD,SA1DI;EA2DJwD,aAAa,EAAEjD,IA3DX;EA4DJkD,iBAAiB,EAAElD,IA5Df;EA6DJmD,iBAAiB,EAAEnD;AA7Df,CANC"}
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"}
@@ -0,0 +1,2 @@
1
+ declare function _exports(): Promise<void>;
2
+ export = _exports;
@@ -1,15 +1,2 @@
1
- import type { Skia as SkiaApi } from "../skia/types";
2
- import type * as SkiaExports from "../skia";
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.186",
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
- /* eslint-disable @typescript-eslint/no-explicit-any */
1
+ import type { CanvasKit } from "canvaskit-wasm";
2
2
 
3
- import type { Color, Skia as SkiaApi, SkRect, Vector } from "../skia/types";
4
- import * as Values from "../values/web";
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
- class Stub {
20
- constructor() {
21
- return new Proxy(() => {}, {
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 Noop: () => any = () => {};
30
-
31
- export const Skia: SkiaApi = new Stub() as any;
32
-
33
- export const vec = (x?: number, y?: number) => ({ x: x ?? 0, y: y ?? x ?? 0 });
34
-
35
- export const Mock: typeof SkiaExports &
36
- typeof ValueExports &
37
- typeof AnimationExports & {
38
- createDrawing: () => any;
39
- createDeclaration: () => any;
40
- ShaderLib: typeof ShaderLib;
41
- } = {
42
- // SkiaExports
43
- // 1. Skia API. BaseSkia contains the enums, and functions like isPaint etc
44
- Skia,
45
- ...BaseSkia,
46
- // 2. Hooks
47
- useRawData: Noop,
48
- useData: Noop,
49
- useFont: Noop,
50
- useTypeface: Noop,
51
- useImage: Noop,
52
- useSVG: Noop,
53
- createPicture: Noop,
54
- // 3. Point/Rect/Transform utilities
55
- vec,
56
- rect: (x: number, y: number, width: number, height: number) => ({
57
- x,
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
  };