@regulaforensics/document-reader 9.9.1123-beta → 9.9.1135-nightly

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.
Files changed (48) hide show
  1. package/RNDocumentReader.podspec +21 -0
  2. package/android/build.gradle +2 -2
  3. package/android/cordova.gradle +2 -2
  4. package/app.plugin.js +2 -3
  5. package/examples/capacitor/package.json +1 -1
  6. package/examples/ionic/config.xml +1 -1
  7. package/examples/ionic/index.tsx +3 -8
  8. package/examples/{ionic-cocoapods → ionic}/package-lock.json +2335 -2277
  9. package/examples/ionic/package.json +31 -22
  10. package/examples/ionic/tsconfig.json +1 -0
  11. package/examples/react_native/app.config.ts +2 -1
  12. package/examples/react_native/package-lock.json +9185 -0
  13. package/examples/react_native/package.json +17 -12
  14. package/examples/react_native/vendor/image-size-metro-compat/index.cjs +16 -0
  15. package/examples/react_native/vendor/image-size-metro-compat/package.json +8 -0
  16. package/package.json +1 -1
  17. package/plugin.xml +11 -11
  18. package/test/package-lock.json +2 -5
  19. package/Package.swift +0 -27
  20. package/examples/ionic-cocoapods/README.md +0 -22
  21. package/examples/ionic-cocoapods/angular.json +0 -39
  22. package/examples/ionic-cocoapods/assets/.gitkeep +0 -0
  23. package/examples/ionic-cocoapods/config.xml +0 -63
  24. package/examples/ionic-cocoapods/images/document.png +0 -0
  25. package/examples/ionic-cocoapods/images/icon.png +0 -0
  26. package/examples/ionic-cocoapods/images/portrait.png +0 -0
  27. package/examples/ionic-cocoapods/index.html +0 -19
  28. package/examples/ionic-cocoapods/index.tsx +0 -58
  29. package/examples/ionic-cocoapods/ionic.config.json +0 -7
  30. package/examples/ionic-cocoapods/package.json +0 -58
  31. package/examples/ionic-cocoapods/scripts/android.sh +0 -8
  32. package/examples/ionic-cocoapods/scripts/ios.sh +0 -8
  33. package/examples/ionic-cocoapods/scripts/setup.sh +0 -8
  34. package/examples/ionic-cocoapods/src/extra/bt_device.tsx +0 -33
  35. package/examples/ionic-cocoapods/src/extra/custom_rfid.tsx +0 -61
  36. package/examples/ionic-cocoapods/src/main.css +0 -148
  37. package/examples/ionic-cocoapods/src/main.html +0 -38
  38. package/examples/ionic-cocoapods/src/main.tsx +0 -172
  39. package/examples/ionic-cocoapods/tsconfig.json +0 -14
  40. package/react-native-document-reader.podspec +0 -14
  41. /package/{Sources/document-reader/include/document-reader → ios}/CVDDocumentReader.h +0 -0
  42. /package/{Sources/document-reader → ios}/CVDDocumentReader.m +0 -0
  43. /package/{Sources/document-reader/include/document-reader → ios}/RGLWConfig.h +0 -0
  44. /package/{Sources/document-reader → ios}/RGLWConfig.m +0 -0
  45. /package/{Sources/document-reader/include/document-reader → ios}/RGLWJSONConstructor.h +0 -0
  46. /package/{Sources/document-reader → ios}/RGLWJSONConstructor.m +0 -0
  47. /package/{Sources/document-reader/include/document-reader → ios}/RGLWMain.h +0 -0
  48. /package/{Sources/document-reader → ios}/RGLWMain.m +0 -0
@@ -8,26 +8,31 @@
8
8
  "start": "expo start"
9
9
  },
10
10
  "dependencies": {
11
- "@regulaforensics/document-reader": "9.9.1123-beta",
11
+ "@regulaforensics/document-reader": "9.9.1135-nightly",
12
12
  "@regulaforensics/document-reader-core-fullauthrfid": "9.8.2974",
13
13
  "@regulaforensics/document-reader-btdevice": "9.8.68",
14
+ "react-native": "^0.81.4",
14
15
  "react-native-fs": "^2.20.0",
15
16
  "react-native-image-picker": "^8.2.1",
16
- "react-native-webview": "^14.0.1",
17
- "react-native": "0.88.0-rc.0",
18
- "react": "19.2.3",
19
- "@types/react": "19.2.18",
20
- "expo": "58.0.0-preview.3",
21
- "expo-dev-client": "58.0.3",
22
- "@expo/config-plugins": "58.0.0",
23
- "expo-build-properties": "58.0.3",
17
+ "react-native-webview": "^13.16.0",
18
+ "@react-native/metro-config": "^0.81.1",
19
+ "react": "^19.1.1",
20
+ "@types/react": "^19.1.13",
21
+ "expo": "^54.0.7",
22
+ "expo-dev-client": "^6.0.12",
24
23
  "expo-custom-assets": "^1.5.0",
25
- "typescript": "^7.0.2"
24
+ "expo-build-properties": "^1.0.8",
25
+ "typescript": "5.9.2",
26
+ "image-size": "file:vendor/image-size-metro-compat"
26
27
  },
27
28
  "overrides": {
29
+ "postcss": "^8.5.10",
28
30
  "uuid": "^14.0.0",
29
- "expo-custom-assets": {
30
- "expo": "$expo"
31
+ "js-yaml": "^4.1.1",
32
+ "brace-expansion": "5.0.9",
33
+ "image-size": "$image-size",
34
+ "glob@7.2.3": {
35
+ "minimatch": "10.2.6"
31
36
  }
32
37
  }
33
38
  }
@@ -0,0 +1,16 @@
1
+ const fs = require('node:fs')
2
+ const next = require('image-size-next')
3
+
4
+ function imageSize(input) {
5
+ const data = typeof input === 'string'
6
+ ? fs.readFileSync(input)
7
+ : input
8
+
9
+ return next.imageSize(data)
10
+ }
11
+
12
+ module.exports = imageSize
13
+ module.exports.default = imageSize
14
+ module.exports.imageSize = imageSize
15
+ module.exports.disableTypes = next.disableTypes
16
+ module.exports.types = next.types
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "image-size",
3
+ "version": "2.1.1-compat.0",
4
+ "main": "index.cjs",
5
+ "dependencies": {
6
+ "image-size-next": "2.1.1"
7
+ }
8
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@regulaforensics/document-reader",
3
- "version": "9.9.1123-beta",
3
+ "version": "9.9.1135-nightly",
4
4
  "description": "This is an npm module for Regula Document Reader SDK. It allows you to read various kinds of identification documents using your phone's camera.",
5
5
  "main": "www/react-native/index.js",
6
6
  "module": "www/capacitor/index.js",
package/plugin.xml CHANGED
@@ -1,5 +1,5 @@
1
1
  <?xml version='1.0' encoding='utf-8'?>
2
- <plugin id="@regulaforensics/document-reader" version="9.9.1123-beta" xmlns="http://apache.org/cordova/ns/plugins/1.0">
2
+ <plugin id="@regulaforensics/document-reader" version="9.9.1135-nightly" xmlns="http://apache.org/cordova/ns/plugins/1.0">
3
3
  <name>DocumentReader</name>
4
4
  <description>Cordova plugin for Regula Document Reader SDK</description>
5
5
  <license>commercial</license>
@@ -9,27 +9,27 @@
9
9
  <clobbers target="DocumentReaderPlugin" />
10
10
  </js-module>
11
11
 
12
- <platform name="ios" package="swift">
12
+ <platform name="ios">
13
13
  <config-file target="config.xml" parent="/widget">
14
14
  <feature name="DocumentReader">
15
15
  <param name="ios-package" value="CVDDocumentReader" />
16
16
  </feature>
17
17
  <preference name="deployment-target" value="13.0" />
18
18
  </config-file>
19
- <header-file src="Sources/document-reader/include/document-reader/CVDDocumentReader.h" />
20
- <source-file src="Sources/document-reader/CVDDocumentReader.m" />
21
- <header-file src="Sources/document-reader/include/document-reader/RGLWMain.h" />
22
- <source-file src="Sources/document-reader/RGLWMain.m" />
23
- <header-file src="Sources/document-reader/include/document-reader/RGLWJSONConstructor.h" />
24
- <source-file src="Sources/document-reader/RGLWJSONConstructor.m" />
25
- <header-file src="Sources/document-reader/include/document-reader/RGLWConfig.h" />
26
- <source-file src="Sources/document-reader/RGLWConfig.m" />
19
+ <header-file src="ios/CVDDocumentReader.h" />
20
+ <source-file src="ios/CVDDocumentReader.m" />
21
+ <header-file src="ios/RGLWMain.h" />
22
+ <source-file src="ios/RGLWMain.m" />
23
+ <header-file src="ios/RGLWJSONConstructor.h" />
24
+ <source-file src="ios/RGLWJSONConstructor.m" />
25
+ <header-file src="ios/RGLWConfig.h" />
26
+ <source-file src="ios/RGLWConfig.m" />
27
27
  <podspec>
28
28
  <config>
29
29
  <source url="https://github.com/regulaforensics/podspecs.git" />
30
30
  </config>
31
31
  <pods>
32
- <pod name="DocumentReader" spec="9.8.6944" nospm="true" />
32
+ <pod name="DocumentReaderNightly" spec="9.9.7006" />
33
33
  </pods>
34
34
  </podspec>
35
35
  </platform>
@@ -13,12 +13,9 @@
13
13
  },
14
14
  "..": {
15
15
  "name": "@regulaforensics/document-reader",
16
- "version": "9.9.1123-beta",
16
+ "version": "1.0.0",
17
17
  "dev": true,
18
- "license": "commercial",
19
- "dependencies": {
20
- "@expo/config-plugins": "^10.0.0"
21
- }
18
+ "license": "commercial"
22
19
  },
23
20
  "node_modules/@esbuild/aix-ppc64": {
24
21
  "version": "0.25.9",
package/Package.swift DELETED
@@ -1,27 +0,0 @@
1
- // swift-tools-version: 5.9
2
-
3
- import PackageDescription
4
-
5
- let package = Package(
6
- name: "@regulaforensics/document-reader",
7
- platforms: [.iOS(.v15)],
8
- products: [.library(name: "@regulaforensics/document-reader", targets: ["@regulaforensics/document-reader"])],
9
- dependencies: [
10
- .package(url: "https://github.com/apache/cordova-ios.git", branch: "master"),
11
- .package(
12
- url: "https://github.com/regulaforensics/DocumentReader-Swift-Package",
13
- exact: "9.8.6944"
14
- )
15
- ],
16
- targets: [
17
- .target(
18
- name: "@regulaforensics/document-reader",
19
- dependencies: [
20
- .product(name: "Cordova", package: "cordova-ios"),
21
- .product(name: "DocumentReader", package: "DocumentReader-Swift-Package")
22
- ],
23
- path: "Sources/document-reader",
24
- cSettings: [.headerSearchPath("include/document-reader")]
25
- )
26
- ]
27
- )
@@ -1,22 +0,0 @@
1
- # Regula Document Reader Ionic demo application
2
-
3
- ## How to build demo application
4
- 1. Download or the clone current repository using the command `git clone https://github.com/regulaforensics/npm-document-reader.git`.
5
- 2. Put `regula.license` file at `assets/` (you can get a trial license [here](https://client.regulaforensics.com)).
6
- 3. Put `db.dat` file at `assets/` (you can get a trial database [here](https://client.regulaforensics.com/customer/databases))
7
- 4. Execute `npm run setup` within this directory.
8
- 5. Run the app:
9
- * IOS: `npm run ios`.
10
- * Android: `npm run android`.
11
-
12
- **Note**: this is just one way of running the app. You can also pass `-o` or `--open` argument to the command, and this will open Xcode/Android Studio, then run the app directly from the IDE. Overall, this is a more consistent way, so if you're having troubles running the app from terminal, try running it from the IDE.
13
-
14
- ## Additional examples
15
-
16
- ### Bluetooth device
17
-
18
- In order to connect to an external scanning device, change the `useBtDevice` constant to true in `src/extra/bt_device`, and set `btDeviceName` to the name of your device. After running the app, click `Connect`.
19
-
20
- ### RFID self hosted UI
21
-
22
- This app also demonstraits how you can implement your own UI for the RFID reading process. To enable it, change the `useRfidSelfHostedUI` constant to true in `src/extra/custom_rfid`. Run the app and initiate RFID reading.
@@ -1,39 +0,0 @@
1
- {
2
- "version": 1,
3
- "projects": {
4
- "app": {
5
- "root": "",
6
- "sourceRoot": "src",
7
- "projectType": "application",
8
- "architect": {
9
- "build": {
10
- "builder": "@angular-devkit/build-angular:browser",
11
- "options": {
12
- "outputPath": "www",
13
- "index": "index.html",
14
- "main": "index.tsx",
15
- "tsConfig": "tsconfig.json",
16
- "assets": [
17
- {
18
- "glob": "**/*",
19
- "input": "assets",
20
- "output": "assets"
21
- },
22
- {
23
- "glob": "**/*",
24
- "input": "images",
25
- "output": "images"
26
- }
27
- ]
28
- }
29
- },
30
- "ionic-cordova-build": {
31
- "builder": "@ionic/cordova-builders:cordova-build",
32
- "options": {
33
- "browserTarget": "app:build"
34
- }
35
- }
36
- }
37
- }
38
- }
39
- }
File without changes
@@ -1,63 +0,0 @@
1
- <?xml version='1.0' encoding='utf-8'?>
2
- <widget android-packageName="com.regula.example.dr.ionic" ios-CFBundleIdentifier="com.regula.example.dr.ionic" version="1.0.0"
3
- xmlns:android="http://schemas.android.com/apk/res/android">
4
- <name>Document</name>
5
- <icon src="images/icon.png" />
6
- <platform name="android">
7
- <resource-file src="assets/db.dat" target="app/src/main/assets/Regula/db.dat" />
8
- <preference name="orientation" value="portrait" />
9
- <preference name="AndroidEdgeToEdge" value="true" />
10
- <preference name="android-minSdkVersion" value="24" />
11
- <preference name="android-targetSdkVersion" value="36" />
12
- <preference name="GradlePluginKotlinEnabled" value="true" />
13
- <config-file parent="/*" target="AndroidManifest.xml">
14
- <uses-permission android:name="android.permission.NFC" />
15
- <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
16
- </config-file>
17
- <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
18
- <application android:usesCleartextTraffic="true" />
19
- </edit-config>
20
- </platform>
21
- <platform name="ios">
22
- <resource-file src="assets/db.dat" />
23
- <preference name="deployment-target" value="15.0" />
24
- <preference name="orientation" value="portrait" />
25
- <allow-intent href="itms:*" />
26
- <allow-intent href="itms-apps:*" />
27
- <config-file parent="NSCameraUsageDescription" target="*-Info.plist">
28
- <string>To use camera</string>
29
- </config-file>
30
- <config-file parent="NSPhotoLibraryUsageDescription" target="*-Info.plist">
31
- <string>To pick images</string>
32
- </config-file>
33
- <config-file parent="NSBluetoothAlwaysUsageDescription" target="*-Info.plist">
34
- <string>To use btdevice</string>
35
- </config-file>
36
- <config-file parent="NFCReaderUsageDescription" target="*-Info.plist">
37
- <string>To use NFC</string>
38
- </config-file>
39
- <config-file parent="com.apple.developer.nfc.readersession.iso7816.select-identifiers" target="*-Info.plist">
40
- <array>
41
- <string>A0000002471001</string>
42
- <string>E80704007F00070302</string>
43
- <string>A000000167455349474E</string>
44
- <string>A0000002480100</string>
45
- <string>A0000002480200</string>
46
- <string>A0000002480300</string>
47
- <string>A0000002480400</string>
48
- <string>A00000045645444C2D3031</string>
49
- <string>D2760000850101</string>
50
- </array>
51
- </config-file>
52
- <config-file parent="com.apple.developer.nfc.readersession.formats" target="*-Debug.plist">
53
- <array>
54
- <string>TAG</string>
55
- </array>
56
- </config-file>
57
- <config-file parent="com.apple.developer.nfc.readersession.formats" target="*-Release.plist">
58
- <array>
59
- <string>TAG</string>
60
- </array>
61
- </config-file>
62
- </platform>
63
- </widget>
@@ -1,19 +0,0 @@
1
- <head>
2
- <meta name="viewport"
3
- content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
4
- <base href="/" />
5
- </head>
6
-
7
- <body>
8
- <ion-app>
9
- <app-root></app-root>
10
- </ion-app>
11
- </body>
12
-
13
- <style>
14
- html,
15
- body {
16
- height: 100%;
17
- margin: 0;
18
- }
19
- </style>
@@ -1,58 +0,0 @@
1
- import 'zone.js';
2
- import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'
3
- import { BrowserModule } from '@angular/platform-browser'
4
- import { IonicModule, Platform } from '@ionic/angular'
5
- import { NgModule } from '@angular/core'
6
-
7
- import { Component } from '@angular/core'
8
- import { File } from '@awesome-cordova-plugins/file'
9
- import { Camera, DestinationType, MediaType, PictureSourceType } from '@awesome-cordova-plugins/camera/ngx'
10
-
11
- import { main } from './src/main'
12
-
13
- export async function loadAsset(path: string): Promise<string> {
14
- var dir = await File.resolveDirectoryUrl(File.applicationDirectory + "www/assets")
15
- var fileEntry = await File.getFile(dir, path, null)
16
- var result = await new Promise<string>((resolve, _) => {
17
- fileEntry.file(file => {
18
- var reader = new FileReader()
19
- reader.onloadend = (_) => resolve(reader.result as string)
20
- reader.readAsDataURL(file)
21
- })
22
- })
23
- return result
24
- }
25
-
26
- export async function pickImage(): Promise<string | null> {
27
- return await cameraInstance.getPicture({
28
- destinationType: DestinationType.DATA_URL,
29
- mediaType: MediaType.PICTURE,
30
- sourceType: PictureSourceType.PHOTOLIBRARY
31
- })
32
- }
33
-
34
- var cameraInstance: Camera
35
- @Component({
36
- selector: 'app-root',
37
- templateUrl: 'src/main.html',
38
- styleUrl: 'src/main.css'
39
- })
40
- class Main {
41
- constructor(platform: Platform, camera: Camera) {
42
- (async () => {
43
- cameraInstance = camera
44
- await platform.ready()
45
- await new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)))
46
- main()
47
- })()
48
- }
49
- }
50
-
51
- @NgModule({
52
- bootstrap: [Main],
53
- providers: [Platform, Camera],
54
- imports: [BrowserModule, IonicModule.forRoot()]
55
- })
56
- class MainModule { }
57
-
58
- platformBrowserDynamic().bootstrapModule(MainModule)
@@ -1,7 +0,0 @@
1
- {
2
- "name": "DocumentReader",
3
- "integrations": {
4
- "cordova": {}
5
- },
6
- "type": "angular"
7
- }
@@ -1,58 +0,0 @@
1
- {
2
- "name": "document-reader",
3
- "scripts": {
4
- "setup": "scripts/setup.sh",
5
- "ios": "scripts/ios.sh",
6
- "android": "scripts/android.sh"
7
- },
8
- "dependencies": {
9
- "@angular-devkit/build-angular": "^21.2.16",
10
- "@angular/cli": "^21.2.16",
11
- "@angular/common": "^21.2.17",
12
- "@angular/compiler-cli": "^21.2.17",
13
- "@angular/core": "^21.2.17",
14
- "@angular/forms": "^21.2.17",
15
- "@angular/platform-browser-dynamic": "^21.2.17",
16
- "@angular/router": "^21.2.17",
17
- "@ionic/angular": "^8.8.11",
18
- "@ionic/cordova-builders": "^12.3.0",
19
- "@awesome-cordova-plugins/camera": "^8.1.0",
20
- "@awesome-cordova-plugins/file": "^8.1.0",
21
- "@regulaforensics/document-reader": "9.9.1123-beta",
22
- "@regulaforensics/document-reader-core-fullauthrfid": "9.8.2974",
23
- "@regulaforensics/document-reader-btdevice": "9.8.68",
24
- "cordova-android": "^14.0.1",
25
- "cordova-ios": "^7.1.1",
26
- "cordova-plugin-camera": "^8.0.0",
27
- "cordova-plugin-file": "^8.1.3",
28
- "cordova-plugin-ionic-webview": "^5.0.1"
29
- },
30
- "overrides": {
31
- "ajv": "^8.18.0",
32
- "serialize-javascript": "^7.0.4",
33
- "undici": "^7.24.0",
34
- "picomatch": "^4.0.4",
35
- "postcss": "^8.5.10",
36
- "uuid": "^14.0.0",
37
- "vite": "^7.3.2",
38
- "webpack-dev-server": "^5.2.4",
39
- "@babel/core": "^7.29.0",
40
- "esbuild": "^0.28.1",
41
- "http-proxy-middleware": "^3.0.7",
42
- "piscina": "^5.2.0"
43
- },
44
- "cordova": {
45
- "plugins": {
46
- "@regulaforensics/document-reader": {},
47
- "@regulaforensics/document-reader-core-fullauthrfid": {},
48
- "@regulaforensics/document-reader-btdevice": {},
49
- "cordova-plugin-file": {},
50
- "cordova-plugin-camera": {},
51
- "cordova-plugin-ionic-webview": {}
52
- },
53
- "platforms": [
54
- "android",
55
- "ios"
56
- ]
57
- }
58
- }
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- if [[ $npm_config_o || $npm_config_open ]]; then
4
- ionic cordova build android
5
- open -a 'Android Studio' platforms/android
6
- else
7
- ionic cordova run android
8
- fi
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- if [[ $npm_config_o || $npm_config_open ]]; then
4
- ionic cordova prepare ios
5
- open platforms/ios/Document.xcworkspace
6
- else
7
- ionic cordova run ios
8
- fi
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -e
3
-
4
- npm install
5
- ionic cordova prepare || {
6
- pod repo update
7
- ionic cordova prepare
8
- }
@@ -1,33 +0,0 @@
1
- import { DocumentReader, InitConfig } from "@regulaforensics/document-reader"
2
- import { handleException, init, setStatus } from "../main"
3
-
4
- export const useBtDevice = false
5
- export const btDeviceName = "Regula 0000"
6
-
7
- export function setupBTDevice() {
8
- var connectButton = document.getElementById("connect")!
9
- connectButton.style.display = "flex"
10
- connectButton.onclick = () => connect()
11
- setStatus("Connect to a bluetooth device")
12
- }
13
-
14
- async function connect() {
15
- setStatus("Searching for devices...")
16
- if (await DocumentReader.instance.connectBluetoothDevice(btDeviceName)) {
17
- await init()
18
- DocumentReader.instance.functionality.useAuthenticator = true
19
- document.getElementById("connect")!.style.display = "none"
20
- } else
21
- setStatus("Failed to connect")
22
- }
23
-
24
- export async function initializeWithBTDevice() {
25
- setStatus("Initializing...")
26
-
27
- var initConfig = InitConfig.withBleDevice()
28
- initConfig.delayedNNLoad = true
29
- var [success, error] = await DocumentReader.instance.initialize(initConfig)
30
-
31
- handleException(error)
32
- return success
33
- }
@@ -1,61 +0,0 @@
1
- import { DocReaderAction, DocumentReader, RFIDConfig, RFIDDataFileType, RFIDNotificationCodes } from "@regulaforensics/document-reader"
2
- import { displayResults, setStatus } from "../main"
3
-
4
- export const useRfidSelfHostedUI = false
5
-
6
- export function rfidSelfHostedUI() {
7
- var config = RFIDConfig.withoutUI((action, results, _) => {
8
- if (DocReaderAction.stopped(action)) stop()
9
- if (DocReaderAction.finished(action)) displayResults(results)
10
- if (DocReaderAction.interrupted(action)) setStatus("Error reading RFID")
11
- })
12
-
13
- config.onProgress = async (notification) => {
14
- if (notification.progress == 1) return
15
- if (notification.notificationCode == RFIDNotificationCodes.PCSC_READING_DATAGROUP)
16
- setDescription(await RFIDDataFileType.getTranslation(notification.dataFileType))
17
- setStatus("Reading RFID")
18
- setProgress(notification.progress)
19
- }
20
-
21
- setup()
22
- DocumentReader.instance.rfid(config)
23
- }
24
-
25
- function setup() {
26
- setStatus("Reading RFID")
27
- setDescription("Place your phone on top of the NFC tag")
28
- setProgress(-1)
29
- currentProgress = -1
30
- setShowing(true)
31
- document.getElementById("cancel-rfid")!.onclick = () => stop()
32
- }
33
-
34
- function stop() {
35
- DocumentReader.instance.stopRFIDReader()
36
- displayResults(null)
37
- setShowing(false)
38
- }
39
-
40
- function setDescription(data: string) {
41
- document.getElementById("rfid-description")!.innerHTML = data
42
- }
43
-
44
- var currentProgress = -1
45
- function setProgress(next: number) {
46
- var progress = document.getElementById("progress")!
47
- // make progress bar look better
48
- if (next == 0) return // ignore idle 0s, leave progress at 100 while its not moving
49
- if (next < currentProgress) next = 0 // move to 0 if progress finaly started moving
50
- if (next >= 95) next = 100 // rfid never returns 100 and it looks ugly, fix it
51
- if (next < currentProgress) progress.style.transition = 'none' // instantly reset progress
52
- else progress.style.transition = 'width 0.5s' // smoothly increase progress
53
-
54
- progress.style.width = next + "%"
55
- currentProgress = next
56
- }
57
-
58
- function setShowing(data: boolean) {
59
- document.getElementById("main")!.style.display = data ? "none" : "flex"
60
- document.getElementById("custom-rfid")!.style.display = data ? "flex" : "none"
61
- }