@shopify/react-native-skia 0.1.219 → 0.1.220
Sign up to get free protection for your applications and to get access to all the features.
- package/jestEnv.mjs +23 -0
- package/jestSetup.mjs +22 -0
- package/package.json +4 -3
package/jestEnv.mjs
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
/* eslint-disable import/no-default-export */
|
2
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
3
|
+
import { TestEnvironment } from "jest-environment-node";
|
4
|
+
import CanvasKitInit from "canvaskit-wasm/bin/full/canvaskit";
|
5
|
+
|
6
|
+
const CanvasKit = await CanvasKitInit({});
|
7
|
+
|
8
|
+
export default class SkiaEnvironment extends TestEnvironment {
|
9
|
+
constructor(config, context) {
|
10
|
+
super(config, context);
|
11
|
+
}
|
12
|
+
|
13
|
+
async setup() {
|
14
|
+
await super.setup();
|
15
|
+
this.global.CanvasKit = CanvasKit;
|
16
|
+
}
|
17
|
+
|
18
|
+
async teardown() {}
|
19
|
+
|
20
|
+
getVmContext() {
|
21
|
+
return super.getVmContext();
|
22
|
+
}
|
23
|
+
}
|
package/jestSetup.mjs
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
/* eslint-disable import/no-extraneous-dependencies */
|
2
|
+
import { jest } from "@jest/globals";
|
3
|
+
import CanvasKitInit from "canvaskit-wasm/bin/full/canvaskit";
|
4
|
+
import { Mock } from "@shopify/react-native-skia/lib/module/mock";
|
5
|
+
|
6
|
+
global.CanvasKit = await CanvasKitInit({});
|
7
|
+
|
8
|
+
jest.mock("@shopify/react-native-skia", () => {
|
9
|
+
jest.mock("@shopify/react-native-skia/lib/commonjs/Platform", () => {
|
10
|
+
const Noop = () => undefined;
|
11
|
+
return {
|
12
|
+
OS: "web",
|
13
|
+
PixelRatio: 1,
|
14
|
+
requireNativeComponent: Noop,
|
15
|
+
resolveAsset: Noop,
|
16
|
+
findNodeHandle: Noop,
|
17
|
+
NativeModules: Noop,
|
18
|
+
View: Noop,
|
19
|
+
};
|
20
|
+
});
|
21
|
+
return Mock(global.CanvasKit);
|
22
|
+
});
|
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.220",
|
11
11
|
"description": "High-performance React Native Graphics using Skia",
|
12
12
|
"main": "lib/module/index.js",
|
13
13
|
"files": [
|
@@ -25,7 +25,8 @@
|
|
25
25
|
"libs/android/**",
|
26
26
|
"index.js",
|
27
27
|
"jestSetup.js",
|
28
|
-
"
|
28
|
+
"jestSetup.mjs",
|
29
|
+
"jestEnv.mjs",
|
29
30
|
"cpp/**/*.{h,cpp}",
|
30
31
|
"ios",
|
31
32
|
"libs/ios/libskia.xcframework",
|
@@ -140,5 +141,5 @@
|
|
140
141
|
},
|
141
142
|
"types": "lib/typescript/index.d.ts",
|
142
143
|
"module": "lib/module/index.js",
|
143
|
-
"react-native": "
|
144
|
+
"react-native": "src/index.ts"
|
144
145
|
}
|