veryfi-lens-wasm 1.0.3 → 1.0.4
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/README.md +10 -7
- package/package.json +7 -4
- package/setup.mjs +42 -0
- package/setup.sh +3 -0
- package/copy-wasm.js +0 -39
- package/copy-wasm.sh +0 -24
- package/src/lens-ws.js +0 -0
- package/src/wasm/simd/simdBeauty.js +0 -5286
- package/src/wasm/simd/simdBeauty.worker.js +0 -124
- package/src/wasm/wasm2.js +0 -208
- package/src/wasm/wasm3.js +0 -477
package/README.md
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
1.
|
|
2
|
-
2.
|
|
3
|
-
3. Add id='
|
|
4
|
-
4.
|
|
1
|
+
1. run `npm exec veryfi-lens-wasm-setup`, provide it with path to directory where you will serve wasm files for next.js public/wasm
|
|
2
|
+
2. Import package
|
|
3
|
+
3. Add id='veryfi-container' to container you want lens to appear
|
|
4
|
+
4. Add id='blur-detector' to edit screen if you want to use it's logic
|
|
5
|
+
5. Create function
|
|
5
6
|
```
|
|
6
7
|
const startLens = async () => {
|
|
7
|
-
veryfiLens.setUserAgent(navigator.userAgent);
|
|
8
|
+
veryfiLens.setUserAgent(navigator.userAgent); // if package loads before navigator
|
|
8
9
|
veryfiLens.init(sessionToken);
|
|
9
10
|
veryfiLens.startCamera();
|
|
10
11
|
intervalRef = window.setInterval(() => {
|
|
@@ -13,9 +14,11 @@ const startLens = async () => {
|
|
|
13
14
|
};
|
|
14
15
|
```
|
|
15
16
|
5. Call it
|
|
16
|
-
6. Use
|
|
17
|
+
6. Use the following function on capture button
|
|
17
18
|
```
|
|
18
19
|
const takePhoto = () => {
|
|
19
|
-
veryfiLens.capture(setImage, setIsEditing);
|
|
20
|
+
veryfiLens.capture(setImage, setIsEditing);
|
|
21
|
+
// setImage is cropped image setter (for example react's useState hook) returns string
|
|
22
|
+
// setIsEditing returns boolean (we use it to change screens)
|
|
20
23
|
};
|
|
21
24
|
```
|
package/package.json
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "veryfi-lens-wasm",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Lens For Web SDK with WASM",
|
|
5
5
|
"main": "veryfi-lens.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"
|
|
7
|
+
"setup": "node setup.mjs"
|
|
8
|
+
},
|
|
9
|
+
"bin": {
|
|
10
|
+
"veryfi-lens-wasm-setup": "./setup.sh"
|
|
8
11
|
},
|
|
9
12
|
"author": "",
|
|
10
13
|
"license": "ISC",
|
|
11
14
|
"dependencies": {
|
|
12
15
|
"fs-extra": "^11.1.1",
|
|
13
|
-
"
|
|
14
|
-
"
|
|
16
|
+
"inquirer": "^8.0.0",
|
|
17
|
+
"path": "^0.12.7"
|
|
15
18
|
}
|
|
16
19
|
}
|
package/setup.mjs
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import inquirer from 'inquirer';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import fs from 'fs-extra';
|
|
4
|
+
|
|
5
|
+
const defaultPath = path.join(process.cwd(), './public/wasm');
|
|
6
|
+
|
|
7
|
+
const questions = [
|
|
8
|
+
{
|
|
9
|
+
type: 'input',
|
|
10
|
+
name: 'targetPath',
|
|
11
|
+
message: `Enter the path where you want to copy the WASM files (They have to be accessible to the browser with relative path) (current: ${defaultPath}):`,
|
|
12
|
+
default: defaultPath
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
type: 'confirm',
|
|
16
|
+
name: 'confirmCopy',
|
|
17
|
+
message: 'Do you want to proceed with the copying?',
|
|
18
|
+
default: true
|
|
19
|
+
}
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
inquirer.prompt(questions)
|
|
23
|
+
.then((answers) => {
|
|
24
|
+
if (answers.confirmCopy) {
|
|
25
|
+
const sourcePath = path.join(process.cwd(), 'node_modules/veryfi-lens-wasm/src/wasm');
|
|
26
|
+
const targetPath = path.isAbsolute(answers.targetPath)
|
|
27
|
+
? answers.targetPath
|
|
28
|
+
: path.join(process.cwd(), answers.targetPath);
|
|
29
|
+
|
|
30
|
+
fs.copySync(sourcePath, targetPath, { overwrite: true });
|
|
31
|
+
console.log('WASM files copied successfully.');
|
|
32
|
+
} else {
|
|
33
|
+
console.log('WASM files were not copied.');
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
.catch((error) => {
|
|
37
|
+
if (error.isTtyError) {
|
|
38
|
+
console.error('Prompt couldn\'t be rendered in the current environment.');
|
|
39
|
+
} else {
|
|
40
|
+
console.error('An error occurred:', error);
|
|
41
|
+
}
|
|
42
|
+
});
|
package/setup.sh
ADDED
package/copy-wasm.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const fs = require('fs-extra');
|
|
5
|
-
const readline = require('readline');
|
|
6
|
-
|
|
7
|
-
console.log('Starting postinstall script...');
|
|
8
|
-
|
|
9
|
-
const sourcePath = path.join(__dirname, 'src/wasm');
|
|
10
|
-
|
|
11
|
-
console.log('Source path:', sourcePath);
|
|
12
|
-
|
|
13
|
-
// Check if the environment is interactive
|
|
14
|
-
const hasInteractiveStdin = process.stdin.isTTY;
|
|
15
|
-
|
|
16
|
-
if (hasInteractiveStdin) {
|
|
17
|
-
const rl = readline.createInterface({
|
|
18
|
-
input: process.stdin,
|
|
19
|
-
output: process.stdout
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
rl.question('Please enter the path to your desired folder: ', (targetPath) => {
|
|
23
|
-
rl.question('Do you want to copy wasm files from veryfi-lens-wasm to the provided directory? (yes/no): ', (answer) => {
|
|
24
|
-
rl.close();
|
|
25
|
-
|
|
26
|
-
if (answer.toLowerCase() === 'yes' || answer.toLowerCase() === 'y') {
|
|
27
|
-
fs.copySync(sourcePath, targetPath, { overwrite: true });
|
|
28
|
-
console.log('WASM files copied successfully to', targetPath);
|
|
29
|
-
} else {
|
|
30
|
-
console.log('WASM files were not copied.');
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
} else {
|
|
35
|
-
const sourcePath = path.join(__dirname, 'src/wasm');
|
|
36
|
-
const defaultTargetPath = path.join(process.cwd(), 'public/wasm');
|
|
37
|
-
fs.copySync(sourcePath, defaultTargetPath, { overwrite: true });
|
|
38
|
-
console.log('WASM files copied without prompt due to non-interactive environment to', defaultTargetPath);
|
|
39
|
-
}
|
package/copy-wasm.sh
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
echo "Starting postinstall script..."
|
|
4
|
-
|
|
5
|
-
SOURCE_PATH="$(dirname "$0")/src/wasm"
|
|
6
|
-
|
|
7
|
-
# Check if the environment is interactive
|
|
8
|
-
if [ -t 0 ]; then
|
|
9
|
-
# Interactive mode
|
|
10
|
-
read -p "Please enter the path to your desired folder: " TARGET_PATH
|
|
11
|
-
read -p "Do you want to copy wasm files from veryfi-lens-wasm to the provided directory? (yes/no): " ANSWER
|
|
12
|
-
if [[ "$ANSWER" == "yes" || "$ANSWER" == "y" ]]; then
|
|
13
|
-
cp -R "$SOURCE_PATH" "$TARGET_PATH"
|
|
14
|
-
echo "WASM files copied successfully to $TARGET_PATH"
|
|
15
|
-
else
|
|
16
|
-
echo "WASM files were not copied."
|
|
17
|
-
fi
|
|
18
|
-
else
|
|
19
|
-
# Non-interactive mode
|
|
20
|
-
PROJECT_ROOT="$(dirname "$(dirname "$(dirname "$0")")")"
|
|
21
|
-
DEFAULT_TARGET_PATH="$PROJECT_ROOT/public/wasm"
|
|
22
|
-
cp -R "$SOURCE_PATH" "$DEFAULT_TARGET_PATH"
|
|
23
|
-
echo "WASM files copied without prompt due to non-interactive environment to $DEFAULT_TARGET_PATH"
|
|
24
|
-
fi
|
package/src/lens-ws.js
DELETED
|
File without changes
|