@react-native-ohos/react-native-skia 1.3.9 → 1.3.11
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/LICENSE.md +6 -6
- package/README.md +8 -8
- package/harmony/skia.har +0 -0
- package/package.json +136 -134
- package/scripts/setup-canvaskit.js +105 -105
- package/src/external/reanimated/Video.ts +17 -0
- package/src/external/reanimated/useVideo.ts +179 -170
- package/src/index.ts +3 -3
- package/lib/commonjs/external/reanimated/useVideo.js +0 -155
- package/lib/commonjs/external/reanimated/useVideo.js.map +0 -1
- package/lib/commonjs/index.js +0 -28
- package/lib/commonjs/index.js.map +0 -1
- package/lib/module/external/reanimated/useVideo.js +0 -147
- package/lib/module/external/reanimated/useVideo.js.map +0 -1
- package/lib/module/index.js +0 -4
- package/lib/module/index.js.map +0 -1
- package/lib/typescript/index.d.ts +0 -1
- package/lib/typescript/jestEnv.d.mts +0 -5
- package/lib/typescript/jestSetup.d.mts +0 -1
- package/lib/typescript/jestSetup.d.ts +0 -1
- package/lib/typescript/src/external/reanimated/useVideo.d.ts +0 -22
- package/lib/typescript/src/index.d.ts +0 -3
package/LICENSE.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
Copyright 2021-present, Shopify Inc.
|
|
2
|
-
|
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
-
|
|
5
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
-
|
|
1
|
+
Copyright 2021-present, Shopify Inc.
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
7
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
# React Native Skia
|
|
2
|
-
|
|
3
|
-
High-performance 2d Graphics for React Native using Skia
|
|
4
|
-
|
|
5
|
-
<img width="400" alt="skia" src="https://user-images.githubusercontent.com/306134/146549218-b7959ad9-0107-4c1c-b439-b96c780f5230.png">
|
|
6
|
-
|
|
7
|
-
Checkout the full documentation [here](https://shopify.github.io/react-native-skia).
|
|
8
|
-
|
|
1
|
+
# React Native Skia
|
|
2
|
+
|
|
3
|
+
High-performance 2d Graphics for React Native using Skia
|
|
4
|
+
|
|
5
|
+
<img width="400" alt="skia" src="https://user-images.githubusercontent.com/306134/146549218-b7959ad9-0107-4c1c-b439-b96c780f5230.png">
|
|
6
|
+
|
|
7
|
+
Checkout the full documentation [here](https://shopify.github.io/react-native-skia).
|
|
8
|
+
|
|
9
9
|
Documentation on the library development is available [here](https://github.com/Shopify/react-native-skia#library-development).
|
package/harmony/skia.har
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,134 +1,136 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@react-native-ohos/react-native-skia",
|
|
3
|
-
"harmony": {
|
|
4
|
-
"alias": "@shopify/react-native-skia",
|
|
5
|
-
"redirectInternalImports": true,
|
|
6
|
-
"autolinking": {
|
|
7
|
-
"etsPackageClassName":"SkiaPackage",
|
|
8
|
-
"cppPackageClassName":"SkiaPackage",
|
|
9
|
-
"cmakeLibraryTargetName": "rnoh_skia",
|
|
10
|
-
"ohPackageName": "@react-native-ohos/react-native-skia"
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
"publishConfig": {
|
|
14
|
-
"access": "public"
|
|
15
|
-
},
|
|
16
|
-
"bin": {
|
|
17
|
-
"setup-skia-web": "./scripts/setup-canvaskit.js"
|
|
18
|
-
},
|
|
19
|
-
"title": "React Native Skia",
|
|
20
|
-
"version": "1.3.
|
|
21
|
-
"description": "High-performance React Native Graphics using Skia",
|
|
22
|
-
"main": "lib/module/index.js",
|
|
23
|
-
"react-native": "src/index.ts",
|
|
24
|
-
"module": "lib/module/index.js",
|
|
25
|
-
"types": "lib/typescript/index.d.ts",
|
|
26
|
-
"files": [
|
|
27
|
-
"harmony",
|
|
28
|
-
"src",
|
|
29
|
-
"lib",
|
|
30
|
-
"scripts/setup-canvaskit.js"
|
|
31
|
-
],
|
|
32
|
-
"scripts": {
|
|
33
|
-
"tsc": "tsc --noEmit",
|
|
34
|
-
"lint": "eslint . --ext .ts,.tsx --max-warnings 0 --cache",
|
|
35
|
-
"test": "jest",
|
|
36
|
-
"e2e": "E2E=true yarn test -i e2e",
|
|
37
|
-
"build": "bob build && merge-dirs lib/typescript/src lib/commonjs && merge-dirs lib/typescript/src lib/module",
|
|
38
|
-
"release": "semantic-release"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
"react
|
|
66
|
-
"
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
"@
|
|
80
|
-
"@types/
|
|
81
|
-
"@types/
|
|
82
|
-
"@types/
|
|
83
|
-
"@types/
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"eslint
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
"react
|
|
95
|
-
"react-native
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
"
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
"
|
|
112
|
-
"
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
"
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@react-native-ohos/react-native-skia",
|
|
3
|
+
"harmony": {
|
|
4
|
+
"alias": "@shopify/react-native-skia",
|
|
5
|
+
"redirectInternalImports": true,
|
|
6
|
+
"autolinking": {
|
|
7
|
+
"etsPackageClassName":"SkiaPackage",
|
|
8
|
+
"cppPackageClassName":"SkiaPackage",
|
|
9
|
+
"cmakeLibraryTargetName": "rnoh_skia",
|
|
10
|
+
"ohPackageName": "@react-native-ohos/react-native-skia"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"bin": {
|
|
17
|
+
"setup-skia-web": "./scripts/setup-canvaskit.js"
|
|
18
|
+
},
|
|
19
|
+
"title": "React Native Skia",
|
|
20
|
+
"version": "1.3.11",
|
|
21
|
+
"description": "High-performance React Native Graphics using Skia",
|
|
22
|
+
"main": "lib/module/index.js",
|
|
23
|
+
"react-native": "src/index.ts",
|
|
24
|
+
"module": "lib/module/index.js",
|
|
25
|
+
"types": "lib/typescript/index.d.ts",
|
|
26
|
+
"files": [
|
|
27
|
+
"harmony",
|
|
28
|
+
"src",
|
|
29
|
+
"lib",
|
|
30
|
+
"scripts/setup-canvaskit.js"
|
|
31
|
+
],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"tsc": "tsc --noEmit",
|
|
34
|
+
"lint": "eslint . --ext .ts,.tsx --max-warnings 0 --cache",
|
|
35
|
+
"test": "jest",
|
|
36
|
+
"e2e": "E2E=true yarn test -i e2e",
|
|
37
|
+
"build": "bob build && merge-dirs lib/typescript/src lib/commonjs && merge-dirs lib/typescript/src lib/module",
|
|
38
|
+
"release": "semantic-release",
|
|
39
|
+
"prepack": "node scripts/copy-tgz-to-root.js",
|
|
40
|
+
"postpack": "node scripts/copy-tgz-to-root.js"
|
|
41
|
+
},
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "git+https://gitcode.com/openharmony-sig/rntpc_react-native-skia.git",
|
|
45
|
+
"baseUrl": "https://gitcode.com/openharmony-sig/rntpc_react-native-skia"
|
|
46
|
+
},
|
|
47
|
+
"keywords": [
|
|
48
|
+
"react-native"
|
|
49
|
+
],
|
|
50
|
+
"author": "Shopify Inc.",
|
|
51
|
+
"contributors": [
|
|
52
|
+
{
|
|
53
|
+
"name": "Christian Falch",
|
|
54
|
+
"email": "christian.falch@gmail.com"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"name": "William Candillon",
|
|
58
|
+
"email": "wcandillon@gmail.com"
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
"license": "MIT",
|
|
62
|
+
"licenseFilename": "LICENSE.md",
|
|
63
|
+
"readmeFilename": "README.md",
|
|
64
|
+
"peerDependencies": {
|
|
65
|
+
"react": "*",
|
|
66
|
+
"react-native": "*",
|
|
67
|
+
"react-native-reanimated": ">=2.0.0",
|
|
68
|
+
"@shopify/react-native-skia": "1.3.7"
|
|
69
|
+
},
|
|
70
|
+
"peerDependenciesMeta": {
|
|
71
|
+
"react-native-reanimated": {
|
|
72
|
+
"optional": true
|
|
73
|
+
},
|
|
74
|
+
"react-native": {
|
|
75
|
+
"optional": true
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
"devDependencies": {
|
|
79
|
+
"@babel/plugin-proposal-nullish-coalescing-operator": "7.18.6",
|
|
80
|
+
"@types/jest": "29.5.6",
|
|
81
|
+
"@types/pixelmatch": "5.2.4",
|
|
82
|
+
"@types/pngjs": "6.0.1",
|
|
83
|
+
"@types/react": "18.2.37",
|
|
84
|
+
"@types/react-reconciler": "0.26.7",
|
|
85
|
+
"@types/ws": "8.5.3",
|
|
86
|
+
"eslint": "8.21.0",
|
|
87
|
+
"eslint-config-react-native-wcandillon": "3.10.2",
|
|
88
|
+
"eslint-plugin-reanimated": "2.0.0",
|
|
89
|
+
"jest": "29.6.4",
|
|
90
|
+
"jest-diff": "29.7.0",
|
|
91
|
+
"merge-dirs": "0.2.1",
|
|
92
|
+
"pixelmatch": "5.3.0",
|
|
93
|
+
"pngjs": "6.0.0",
|
|
94
|
+
"react": "18.2.0",
|
|
95
|
+
"react-native": "0.72.5",
|
|
96
|
+
"react-native-builder-bob": "0.18.2",
|
|
97
|
+
"react-native-reanimated": "3.6.2",
|
|
98
|
+
"ts-jest": "29.1.1",
|
|
99
|
+
"typescript": "5.1.6",
|
|
100
|
+
"ws": "8.17.1"
|
|
101
|
+
},
|
|
102
|
+
"dependencies": {
|
|
103
|
+
"canvaskit-wasm": "0.39.1",
|
|
104
|
+
"react-reconciler": "0.27.0"
|
|
105
|
+
},
|
|
106
|
+
"eslintIgnore": [
|
|
107
|
+
"node_modules/",
|
|
108
|
+
"lib/"
|
|
109
|
+
],
|
|
110
|
+
"codegenConfig": {
|
|
111
|
+
"name": "rnskia",
|
|
112
|
+
"type": "all",
|
|
113
|
+
"jsSrcsDir": "src/specs",
|
|
114
|
+
"android": {
|
|
115
|
+
"javaPackageName": "com.shopify.reactnative.skia"
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
"react-native-builder-bob": {
|
|
119
|
+
"source": "src",
|
|
120
|
+
"output": "lib",
|
|
121
|
+
"targets": [
|
|
122
|
+
"commonjs",
|
|
123
|
+
[
|
|
124
|
+
"module",
|
|
125
|
+
{
|
|
126
|
+
"configFile": "./.babelrc"
|
|
127
|
+
}
|
|
128
|
+
],
|
|
129
|
+
"typescript"
|
|
130
|
+
]
|
|
131
|
+
},
|
|
132
|
+
"resolutions": {
|
|
133
|
+
"@typescript-eslint/eslint-plugin": "6.10.0",
|
|
134
|
+
"@typescript-eslint/parser": "6.10.0"
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -1,105 +1,105 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/* eslint-disable max-len */
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* A script to automate the setup of `@shopify/react-native-skia` for web.
|
|
6
|
-
* The only requirement is that your project supports a 'static' folder (often named '/public').
|
|
7
|
-
* In `@expo/webpack-config` this is `./web` (default for now).
|
|
8
|
-
*
|
|
9
|
-
* This script does the following:
|
|
10
|
-
* 0. Try to detect if it's an expo project and if the bundler is set to metro
|
|
11
|
-
* 1. Resolve the public path relative to wherever the script is being run.
|
|
12
|
-
* 2. Log out some useful info about the web setup, just in case anything goes wrong.
|
|
13
|
-
* 3. Resolve the installed wasm file `canvaskit-wasm/bin/full/canvaskit.wasm`
|
|
14
|
-
* from `@shopify/react-native-skia -> canvaskit`.
|
|
15
|
-
* 4. Recursively ensure the path exists and copy the file into the desired location.
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* Usage:
|
|
19
|
-
* $ `npx <script>`
|
|
20
|
-
*
|
|
21
|
-
* On webpack:
|
|
22
|
-
* -> Copies the file to `<project>/web/static/js/canvaskit.wasm`
|
|
23
|
-
* on metro:
|
|
24
|
-
* -> Copies the file to `<project>/public/canvaskit.wasm`
|
|
25
|
-
*
|
|
26
|
-
* Tooling that uses a custom static assets folder, like `/assets` for example:
|
|
27
|
-
* $ `npx <script> assets`
|
|
28
|
-
*
|
|
29
|
-
* -> Copies the file to `<project>/assets/canvaskit.wasm`
|
|
30
|
-
*
|
|
31
|
-
*/
|
|
32
|
-
const fs = require("fs");
|
|
33
|
-
const path = require("path");
|
|
34
|
-
|
|
35
|
-
const args = process.argv.slice(2);
|
|
36
|
-
|
|
37
|
-
const gray = (text) => `\x1b[90m${text}\x1b[0m`;
|
|
38
|
-
const lime = (text) => `\x1b[32m${text}\x1b[0m`;
|
|
39
|
-
|
|
40
|
-
function getWetherItsAnExpoProjectWithMetro() {
|
|
41
|
-
try {
|
|
42
|
-
const appJsonPath = path.join(process.cwd(), 'app.json');
|
|
43
|
-
|
|
44
|
-
console.log(
|
|
45
|
-
`› Reading Expo settings from (if any):\n ${gray(appJsonPath)}`
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
const appJson = require(appJsonPath);
|
|
49
|
-
const isAnExpoProjectWithMetro = appJson.expo && appJson.expo.web && appJson.expo.web.bundler === 'metro';
|
|
50
|
-
if (isAnExpoProjectWithMetro) {
|
|
51
|
-
console.log(` ${gray(`Expo project with metro bundler detected`)}\n`);
|
|
52
|
-
return true;
|
|
53
|
-
} else {
|
|
54
|
-
console.log(` ${gray(`Metro bundler not detected. Assuming the project is using Webpack.`)}\n`);
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
} catch (error) {
|
|
58
|
-
console.log(` ${gray(`No Expo settings found`)}\n`);
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function getWasmFilePath() {
|
|
64
|
-
try {
|
|
65
|
-
return require.resolve("canvaskit-wasm/bin/full/canvaskit.wasm");
|
|
66
|
-
} catch (error) {
|
|
67
|
-
console.error(
|
|
68
|
-
`Could not find 'canvaskit-wasm'. Please install '@shopify/react-native-skia' and ensure it can be resolved from your project: ${process.cwd()}`
|
|
69
|
-
);
|
|
70
|
-
process.exit(1);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function getOutputFilePath(isAnExpoProjectWithMetro) {
|
|
75
|
-
// Default to using `web` public path.
|
|
76
|
-
const publicFolder = path.resolve(args[0] || ((isAnExpoProjectWithMetro) ? "public" : "web/static/js"));
|
|
77
|
-
const publicLocation = "./canvaskit.wasm";
|
|
78
|
-
const output = path.join(publicFolder, publicLocation);
|
|
79
|
-
|
|
80
|
-
console.log(
|
|
81
|
-
`› Copying 'canvaskit.wasm' file to public folder:\n ${gray(output)}\n`
|
|
82
|
-
);
|
|
83
|
-
return output;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function copyFile(from, to) {
|
|
87
|
-
const data = fs.readFileSync(from);
|
|
88
|
-
fs.mkdirSync(path.dirname(to), { recursive: true });
|
|
89
|
-
fs.writeFileSync(to, data);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
(() => {
|
|
93
|
-
// Automatically detect if it's an expo project with a metro bundler
|
|
94
|
-
const isAnExpoProjectWithMetro = getWetherItsAnExpoProjectWithMetro();
|
|
95
|
-
|
|
96
|
-
// Copy the WASM file to `<static>/canvaskit.wasm`
|
|
97
|
-
copyFile(getWasmFilePath(), getOutputFilePath(isAnExpoProjectWithMetro));
|
|
98
|
-
|
|
99
|
-
console.log(lime("› Success! You are almost there:"));
|
|
100
|
-
console.log(
|
|
101
|
-
gray(
|
|
102
|
-
"› To load React Native Skia Web, follow these instructions : https://shopify.github.io/react-native-skia/docs/getting-started/web"
|
|
103
|
-
)
|
|
104
|
-
);
|
|
105
|
-
})();
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/* eslint-disable max-len */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A script to automate the setup of `@shopify/react-native-skia` for web.
|
|
6
|
+
* The only requirement is that your project supports a 'static' folder (often named '/public').
|
|
7
|
+
* In `@expo/webpack-config` this is `./web` (default for now).
|
|
8
|
+
*
|
|
9
|
+
* This script does the following:
|
|
10
|
+
* 0. Try to detect if it's an expo project and if the bundler is set to metro
|
|
11
|
+
* 1. Resolve the public path relative to wherever the script is being run.
|
|
12
|
+
* 2. Log out some useful info about the web setup, just in case anything goes wrong.
|
|
13
|
+
* 3. Resolve the installed wasm file `canvaskit-wasm/bin/full/canvaskit.wasm`
|
|
14
|
+
* from `@shopify/react-native-skia -> canvaskit`.
|
|
15
|
+
* 4. Recursively ensure the path exists and copy the file into the desired location.
|
|
16
|
+
*
|
|
17
|
+
*
|
|
18
|
+
* Usage:
|
|
19
|
+
* $ `npx <script>`
|
|
20
|
+
*
|
|
21
|
+
* On webpack:
|
|
22
|
+
* -> Copies the file to `<project>/web/static/js/canvaskit.wasm`
|
|
23
|
+
* on metro:
|
|
24
|
+
* -> Copies the file to `<project>/public/canvaskit.wasm`
|
|
25
|
+
*
|
|
26
|
+
* Tooling that uses a custom static assets folder, like `/assets` for example:
|
|
27
|
+
* $ `npx <script> assets`
|
|
28
|
+
*
|
|
29
|
+
* -> Copies the file to `<project>/assets/canvaskit.wasm`
|
|
30
|
+
*
|
|
31
|
+
*/
|
|
32
|
+
const fs = require("fs");
|
|
33
|
+
const path = require("path");
|
|
34
|
+
|
|
35
|
+
const args = process.argv.slice(2);
|
|
36
|
+
|
|
37
|
+
const gray = (text) => `\x1b[90m${text}\x1b[0m`;
|
|
38
|
+
const lime = (text) => `\x1b[32m${text}\x1b[0m`;
|
|
39
|
+
|
|
40
|
+
function getWetherItsAnExpoProjectWithMetro() {
|
|
41
|
+
try {
|
|
42
|
+
const appJsonPath = path.join(process.cwd(), 'app.json');
|
|
43
|
+
|
|
44
|
+
console.log(
|
|
45
|
+
`› Reading Expo settings from (if any):\n ${gray(appJsonPath)}`
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
const appJson = require(appJsonPath);
|
|
49
|
+
const isAnExpoProjectWithMetro = appJson.expo && appJson.expo.web && appJson.expo.web.bundler === 'metro';
|
|
50
|
+
if (isAnExpoProjectWithMetro) {
|
|
51
|
+
console.log(` ${gray(`Expo project with metro bundler detected`)}\n`);
|
|
52
|
+
return true;
|
|
53
|
+
} else {
|
|
54
|
+
console.log(` ${gray(`Metro bundler not detected. Assuming the project is using Webpack.`)}\n`);
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
} catch (error) {
|
|
58
|
+
console.log(` ${gray(`No Expo settings found`)}\n`);
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function getWasmFilePath() {
|
|
64
|
+
try {
|
|
65
|
+
return require.resolve("canvaskit-wasm/bin/full/canvaskit.wasm");
|
|
66
|
+
} catch (error) {
|
|
67
|
+
console.error(
|
|
68
|
+
`Could not find 'canvaskit-wasm'. Please install '@shopify/react-native-skia' and ensure it can be resolved from your project: ${process.cwd()}`
|
|
69
|
+
);
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function getOutputFilePath(isAnExpoProjectWithMetro) {
|
|
75
|
+
// Default to using `web` public path.
|
|
76
|
+
const publicFolder = path.resolve(args[0] || ((isAnExpoProjectWithMetro) ? "public" : "web/static/js"));
|
|
77
|
+
const publicLocation = "./canvaskit.wasm";
|
|
78
|
+
const output = path.join(publicFolder, publicLocation);
|
|
79
|
+
|
|
80
|
+
console.log(
|
|
81
|
+
`› Copying 'canvaskit.wasm' file to public folder:\n ${gray(output)}\n`
|
|
82
|
+
);
|
|
83
|
+
return output;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function copyFile(from, to) {
|
|
87
|
+
const data = fs.readFileSync(from);
|
|
88
|
+
fs.mkdirSync(path.dirname(to), { recursive: true });
|
|
89
|
+
fs.writeFileSync(to, data);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
(() => {
|
|
93
|
+
// Automatically detect if it's an expo project with a metro bundler
|
|
94
|
+
const isAnExpoProjectWithMetro = getWetherItsAnExpoProjectWithMetro();
|
|
95
|
+
|
|
96
|
+
// Copy the WASM file to `<static>/canvaskit.wasm`
|
|
97
|
+
copyFile(getWasmFilePath(), getOutputFilePath(isAnExpoProjectWithMetro));
|
|
98
|
+
|
|
99
|
+
console.log(lime("› Success! You are almost there:"));
|
|
100
|
+
console.log(
|
|
101
|
+
gray(
|
|
102
|
+
"› To load React Native Skia Web, follow these instructions : https://shopify.github.io/react-native-skia/docs/getting-started/web"
|
|
103
|
+
)
|
|
104
|
+
);
|
|
105
|
+
})();
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { SkImage,SkJSIInstance } from "@shopify/react-native-skia";
|
|
2
|
+
|
|
3
|
+
export type VideoRotation = 0 | 90 | 180 | 270;
|
|
4
|
+
|
|
5
|
+
export interface Video extends SkJSIInstance<"Video"> {
|
|
6
|
+
duration(): number;
|
|
7
|
+
framerate(): number;
|
|
8
|
+
nextImage(): SkImage | null;
|
|
9
|
+
seek(time: number): void;
|
|
10
|
+
rotation(): VideoRotation;
|
|
11
|
+
size(): { width: number; height: number };
|
|
12
|
+
pause(): void;
|
|
13
|
+
play(): void;
|
|
14
|
+
setVolume(volume: number): void;
|
|
15
|
+
setLoop(loop: boolean): void;
|
|
16
|
+
stop(): void;
|
|
17
|
+
}
|