@regulaforensics/ionic-native-document-reader 6.6.0 → 6.7.0
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/example/package.json +3 -3
- package/example/src/app/home/home.page.html +2 -2
- package/example/src/app/home/home.page.scss +8 -0
- package/example/src/app/home/home.page.ts +19 -10
- package/index.d.ts +92 -10
- package/index.js +181 -15
- package/ngx/index.d.ts +92 -10
- package/ngx/index.js +187 -19
- package/package.json +1 -1
- package/reactExample/README.md +24 -0
- package/reactExample/android/app/build/.npmkeep +0 -0
- package/reactExample/android/app/build.gradle +51 -0
- package/reactExample/android/app/proguard-rules.pro +21 -0
- package/reactExample/android/app/src/androidTest/java/com/getcapacitor/myapp/ExampleInstrumentedTest.java +26 -0
- package/reactExample/android/app/src/main/AndroidManifest.xml +45 -0
- package/reactExample/android/app/src/main/java/com/regula/documentreader/MainActivity.java +5 -0
- package/reactExample/android/app/src/main/res/drawable/ic_launcher_background.xml +170 -0
- package/reactExample/android/app/src/main/res/drawable/splash.png +0 -0
- package/reactExample/android/app/src/main/res/drawable-land-hdpi/splash.png +0 -0
- package/reactExample/android/app/src/main/res/drawable-land-mdpi/splash.png +0 -0
- package/reactExample/android/app/src/main/res/drawable-land-xhdpi/splash.png +0 -0
- package/reactExample/android/app/src/main/res/drawable-land-xxhdpi/splash.png +0 -0
- package/reactExample/android/app/src/main/res/drawable-land-xxxhdpi/splash.png +0 -0
- package/reactExample/android/app/src/main/res/drawable-port-hdpi/splash.png +0 -0
- package/reactExample/android/app/src/main/res/drawable-port-mdpi/splash.png +0 -0
- package/reactExample/android/app/src/main/res/drawable-port-xhdpi/splash.png +0 -0
- package/reactExample/android/app/src/main/res/drawable-port-xxhdpi/splash.png +0 -0
- package/reactExample/android/app/src/main/res/drawable-port-xxxhdpi/splash.png +0 -0
- package/reactExample/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml +34 -0
- package/reactExample/android/app/src/main/res/layout/activity_main.xml +12 -0
- package/reactExample/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +5 -0
- package/reactExample/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +5 -0
- package/reactExample/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/reactExample/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png +0 -0
- package/reactExample/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/reactExample/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/reactExample/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png +0 -0
- package/reactExample/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/reactExample/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/reactExample/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png +0 -0
- package/reactExample/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/reactExample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/reactExample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png +0 -0
- package/reactExample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/reactExample/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/reactExample/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png +0 -0
- package/reactExample/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/reactExample/android/app/src/main/res/values/ic_launcher_background.xml +4 -0
- package/reactExample/android/app/src/main/res/values/strings.xml +7 -0
- package/reactExample/android/app/src/main/res/values/styles.xml +22 -0
- package/reactExample/android/app/src/main/res/xml/file_paths.xml +5 -0
- package/reactExample/android/app/src/test/java/com/getcapacitor/myapp/ExampleUnitTest.java +18 -0
- package/reactExample/android/build.gradle +26 -0
- package/reactExample/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/reactExample/android/gradle/wrapper/gradle-wrapper.properties +5 -0
- package/reactExample/android/gradle.properties +24 -0
- package/reactExample/android/gradlew +185 -0
- package/reactExample/android/gradlew.bat +89 -0
- package/reactExample/android/settings.gradle +5 -0
- package/reactExample/android/variables.gradle +14 -0
- package/reactExample/capacitor.config.ts +10 -0
- package/reactExample/ionic.config.json +7 -0
- package/reactExample/ios/App/App/App.entitlements +11 -0
- package/reactExample/ios/App/App/AppDelegate.swift +60 -0
- package/reactExample/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@1x.png +0 -0
- package/reactExample/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@2x-1.png +0 -0
- package/reactExample/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@2x.png +0 -0
- package/reactExample/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@3x.png +0 -0
- package/reactExample/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@1x.png +0 -0
- package/reactExample/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@2x-1.png +0 -0
- package/reactExample/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@2x.png +0 -0
- package/reactExample/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@3x.png +0 -0
- package/reactExample/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@1x.png +0 -0
- package/reactExample/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@2x-1.png +0 -0
- package/reactExample/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@2x.png +0 -0
- package/reactExample/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@3x.png +0 -0
- package/reactExample/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png +0 -0
- package/reactExample/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-60x60@2x.png +0 -0
- package/reactExample/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-60x60@3x.png +0 -0
- package/reactExample/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-76x76@1x.png +0 -0
- package/reactExample/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-76x76@2x.png +0 -0
- package/reactExample/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-83.5x83.5@2x.png +0 -0
- package/reactExample/ios/App/App/Assets.xcassets/AppIcon.appiconset/Contents.json +116 -0
- package/reactExample/ios/App/App/Assets.xcassets/Contents.json +6 -0
- package/reactExample/ios/App/App/Assets.xcassets/Splash.imageset/Contents.json +23 -0
- package/reactExample/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-1.png +0 -0
- package/reactExample/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-2.png +0 -0
- package/reactExample/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732.png +0 -0
- package/reactExample/ios/App/App/Base.lproj/LaunchScreen.storyboard +32 -0
- package/reactExample/ios/App/App/Base.lproj/Main.storyboard +19 -0
- package/reactExample/ios/App/App/Info.plist +70 -0
- package/reactExample/ios/App/App/capacitor.config.json +6 -0
- package/reactExample/ios/App/App/config.xml +19 -0
- package/reactExample/ios/App/App.xcodeproj/project.pbxproj +422 -0
- package/reactExample/ios/App/App.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/reactExample/ios/App/App.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/reactExample/ios/App/App.xcworkspace/contents.xcworkspacedata +10 -0
- package/reactExample/ios/App/App.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/reactExample/ios/App/Podfile +23 -0
- package/reactExample/package.json +84 -0
- package/reactExample/public/assets/icon/favicon.png +0 -0
- package/reactExample/public/assets/icon/icon.png +0 -0
- package/reactExample/public/assets/img/id.png +0 -0
- package/reactExample/public/assets/img/portrait.png +0 -0
- package/reactExample/public/assets/shapes.svg +1 -0
- package/reactExample/public/index.html +114 -0
- package/reactExample/public/manifest.json +21 -0
- package/reactExample/src/App.test.tsx +8 -0
- package/reactExample/src/App.tsx +42 -0
- package/reactExample/src/assets/img/id.png +0 -0
- package/reactExample/src/assets/img/portrait.png +0 -0
- package/reactExample/src/index.tsx +22 -0
- package/reactExample/src/pages/Home.tsx +340 -0
- package/reactExample/src/react-app-env.d.ts +1 -0
- package/reactExample/src/reportWebVitals.ts +15 -0
- package/reactExample/src/service-worker.ts +80 -0
- package/reactExample/src/serviceWorkerRegistration.ts +142 -0
- package/reactExample/src/setupTests.ts +14 -0
- package/reactExample/src/theme/variables.css +236 -0
- package/reactExample/tsconfig.json +27 -0
- package/index.ts +0 -7366
- package/ngx/index.metadata.json +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg width="350" height="140" xmlns="http://www.w3.org/2000/svg" style="background:#f6f7f9"><g fill="none" fill-rule="evenodd"><path fill="#F04141" style="mix-blend-mode:multiply" d="M61.905-34.23l96.194 54.51-66.982 54.512L22 34.887z"/><circle fill="#10DC60" style="mix-blend-mode:multiply" cx="155.5" cy="135.5" r="57.5"/><path fill="#3880FF" style="mix-blend-mode:multiply" d="M208.538 9.513l84.417 15.392L223.93 93.93z"/><path fill="#FFCE00" style="mix-blend-mode:multiply" d="M268.625 106.557l46.332-26.75 46.332 26.75v53.5l-46.332 26.75-46.332-26.75z"/><circle fill="#7044FF" style="mix-blend-mode:multiply" cx="299.5" cy="9.5" r="38.5"/><rect fill="#11D3EA" style="mix-blend-mode:multiply" transform="rotate(-60 148.47 37.886)" x="143.372" y="-7.056" width="10.196" height="89.884" rx="5.098"/><path d="M-25.389 74.253l84.86 8.107c5.498.525 9.53 5.407 9.004 10.905a10 10 0 0 1-.057.477l-12.36 85.671a10.002 10.002 0 0 1-11.634 8.42l-86.351-15.226c-5.44-.959-9.07-6.145-8.112-11.584l13.851-78.551a10 10 0 0 1 10.799-8.219z" fill="#7044FF" style="mix-blend-mode:multiply"/><circle fill="#0CD1E8" style="mix-blend-mode:multiply" cx="273.5" cy="106.5" r="20.5"/></g></svg>
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="utf-8" />
|
|
6
|
+
<title>Ionic App</title>
|
|
7
|
+
|
|
8
|
+
<base href="/" />
|
|
9
|
+
|
|
10
|
+
<meta name="color-scheme" content="light dark" />
|
|
11
|
+
<meta name="viewport" content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
|
12
|
+
<meta name="format-detection" content="telephone=no" />
|
|
13
|
+
<meta name="msapplication-tap-highlight" content="no" />
|
|
14
|
+
|
|
15
|
+
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
|
16
|
+
|
|
17
|
+
<link rel="shortcut icon" type="image/png" href="%PUBLIC_URL%/assets/icon/favicon.png" />
|
|
18
|
+
|
|
19
|
+
<!-- add to homescreen for ios -->
|
|
20
|
+
<meta name="apple-mobile-web-app-capable" content="yes" />
|
|
21
|
+
<meta name="apple-mobile-web-app-title" content="Ionic App" />
|
|
22
|
+
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
|
|
23
|
+
</head>
|
|
24
|
+
|
|
25
|
+
<body>
|
|
26
|
+
<div class="rfidUI" style="text-align: center; background-color: #F5FCFF; height: 100%; width:100%; display: none;">
|
|
27
|
+
<div style="position: absolute; top: 50%; left: 50%; width:100%; -ms-transform: translate(-50%, -50%); transform: translate(-50%, -50%); ">
|
|
28
|
+
<p class="rfidUIHeader">Reading RFID</p>
|
|
29
|
+
<p class="rfidDescription">Place your phone on top of the NFC tag</p>
|
|
30
|
+
<progress class="rfidProgress" value="0" max="100"></progress>
|
|
31
|
+
<br><br><br>
|
|
32
|
+
<button class="cancelButton">X</button>
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
<div class="mainUI" style="text-align: center;background-color: #F5FCFF;height: 100%;">
|
|
36
|
+
<div style="align-items: center; text-align: center; width: 100%">
|
|
37
|
+
<br>
|
|
38
|
+
<p class="status">Ready</p>
|
|
39
|
+
</div>
|
|
40
|
+
<div style=" align-items:center; text-align: center;display: inline-block;">
|
|
41
|
+
<p style="margin-bottom: 5px">Portrait</p>
|
|
42
|
+
<img style="height: 133px; width: 100px" src="assets/img/portrait.png" resizeMode="contain" class="portraitImage" />
|
|
43
|
+
</div>
|
|
44
|
+
<div style="align-items: center; text-align: center; display: inline-block;">
|
|
45
|
+
<p style="margin-bottom: 5px">Document</p>
|
|
46
|
+
<img style="height: 133px;" src="assets/img/id.png" resizeMode="contain" class="documentImage" />
|
|
47
|
+
</div>
|
|
48
|
+
<br><br>
|
|
49
|
+
<div class="scenariosRadioGroup" style="position: absolute; bottom: 100px; top: 230px; left: 75px; padding: 5px; text-align:left; overflow: auto">
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
<div style="position: absolute; bottom: 10px; width: 100%; text-align: center; align-items: center">
|
|
53
|
+
<div id="rfidDiv" style="flex-direction: row; padding: 5px">
|
|
54
|
+
<input type="checkbox" class="rfidCheckbox" name="rfid" disabled=true></input><span class="rfidCheckboxText" style="color: lightgrey"> Process rfid reading(unavailable)</span><br>
|
|
55
|
+
</div>
|
|
56
|
+
<div style="flex-direction: row; padding: 10px">
|
|
57
|
+
<button class="showScannerButton" style="margin-right: 20px">scan doc</button>
|
|
58
|
+
<button class="showImagePicker" style="margin-left: 20px">scan image</button>
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
<style type="text/css">
|
|
65
|
+
button {
|
|
66
|
+
width: 40%;
|
|
67
|
+
-moz-box-shadow: inset 0px -3px 7px 0px #29bbff;
|
|
68
|
+
-webkit-box-shadow: inset 0px -3px 7px 0px #29bbff;
|
|
69
|
+
box-shadow: inset 0px -3px 7px 0px #29bbff;
|
|
70
|
+
background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #2dabf9), color-stop(1, #0688fa));
|
|
71
|
+
background: -moz-linear-gradient(top, #2dabf9 5%, #0688fa 100%);
|
|
72
|
+
background: -webkit-linear-gradient(top, #2dabf9 5%, #0688fa 100%);
|
|
73
|
+
background: -o-linear-gradient(top, #2dabf9 5%, #0688fa 100%);
|
|
74
|
+
background: -ms-linear-gradient(top, #2dabf9 5%, #0688fa 100%);
|
|
75
|
+
background: linear-gradient(to bottom, #2dabf9 5%, #0688fa 100%);
|
|
76
|
+
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#2dabf9', endColorstr='#0688fa', GradientType=0);
|
|
77
|
+
background-color: #2dabf9;
|
|
78
|
+
-moz-border-radius: 3px;
|
|
79
|
+
-webkit-border-radius: 3px;
|
|
80
|
+
border-radius: 3px;
|
|
81
|
+
border: 1px solid #0b0e07;
|
|
82
|
+
display: inline-block;
|
|
83
|
+
cursor: pointer;
|
|
84
|
+
color: #ffffff;
|
|
85
|
+
font-family: Arial;
|
|
86
|
+
font-size: 15px;
|
|
87
|
+
padding: 9px 23px;
|
|
88
|
+
text-decoration: none;
|
|
89
|
+
text-shadow: 0px 1px 0px #263666;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
button:hover {
|
|
93
|
+
background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #0688fa), color-stop(1, #2dabf9));
|
|
94
|
+
background: -moz-linear-gradient(top, #0688fa 5%, #2dabf9 100%);
|
|
95
|
+
background: -webkit-linear-gradient(top, #0688fa 5%, #2dabf9 100%);
|
|
96
|
+
background: -o-linear-gradient(top, #0688fa 5%, #2dabf9 100%);
|
|
97
|
+
background: -ms-linear-gradient(top, #0688fa 5%, #2dabf9 100%);
|
|
98
|
+
background: linear-gradient(to bottom, #0688fa 5%, #2dabf9 100%);
|
|
99
|
+
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#0688fa', endColorstr='#2dabf9', GradientType=0);
|
|
100
|
+
background-color: #0688fa;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
button:active {
|
|
104
|
+
position: relative;
|
|
105
|
+
top: 1px;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
div {
|
|
109
|
+
color: black;
|
|
110
|
+
}
|
|
111
|
+
</style>
|
|
112
|
+
</body>
|
|
113
|
+
|
|
114
|
+
</html>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"short_name": "Ionic App",
|
|
3
|
+
"name": "My Ionic App",
|
|
4
|
+
"icons": [
|
|
5
|
+
{
|
|
6
|
+
"src": "assets/icon/favicon.png",
|
|
7
|
+
"sizes": "64x64 32x32 24x24 16x16",
|
|
8
|
+
"type": "image/x-icon"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"src": "assets/icon/icon.png",
|
|
12
|
+
"type": "image/png",
|
|
13
|
+
"sizes": "512x512",
|
|
14
|
+
"purpose": "maskable"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"start_url": ".",
|
|
18
|
+
"display": "standalone",
|
|
19
|
+
"theme_color": "#ffffff",
|
|
20
|
+
"background_color": "#ffffff"
|
|
21
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Redirect, Route } from 'react-router-dom';
|
|
2
|
+
import { IonApp, IonRouterOutlet, setupIonicReact } from '@ionic/react';
|
|
3
|
+
import { IonReactRouter } from '@ionic/react-router';
|
|
4
|
+
import Home from './pages/Home';
|
|
5
|
+
|
|
6
|
+
/* Core CSS required for Ionic components to work properly */
|
|
7
|
+
import '@ionic/react/css/core.css';
|
|
8
|
+
|
|
9
|
+
/* Basic CSS for apps built with Ionic */
|
|
10
|
+
import '@ionic/react/css/normalize.css';
|
|
11
|
+
import '@ionic/react/css/structure.css';
|
|
12
|
+
import '@ionic/react/css/typography.css';
|
|
13
|
+
|
|
14
|
+
/* Optional CSS utils that can be commented out */
|
|
15
|
+
import '@ionic/react/css/padding.css';
|
|
16
|
+
import '@ionic/react/css/float-elements.css';
|
|
17
|
+
import '@ionic/react/css/text-alignment.css';
|
|
18
|
+
import '@ionic/react/css/text-transformation.css';
|
|
19
|
+
import '@ionic/react/css/flex-utils.css';
|
|
20
|
+
import '@ionic/react/css/display.css';
|
|
21
|
+
|
|
22
|
+
/* Theme variables */
|
|
23
|
+
import './theme/variables.css';
|
|
24
|
+
|
|
25
|
+
setupIonicReact();
|
|
26
|
+
|
|
27
|
+
const App: React.FC = () => (
|
|
28
|
+
<IonApp>
|
|
29
|
+
<IonReactRouter>
|
|
30
|
+
<IonRouterOutlet>
|
|
31
|
+
<Route exact path="/home">
|
|
32
|
+
<Home />
|
|
33
|
+
</Route>
|
|
34
|
+
<Route exact path="/">
|
|
35
|
+
<Redirect to="/home" />
|
|
36
|
+
</Route>
|
|
37
|
+
</IonRouterOutlet>
|
|
38
|
+
</IonReactRouter>
|
|
39
|
+
</IonApp>
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
export default App;
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom';
|
|
3
|
+
import App from './App';
|
|
4
|
+
import * as serviceWorkerRegistration from './serviceWorkerRegistration';
|
|
5
|
+
import reportWebVitals from './reportWebVitals';
|
|
6
|
+
|
|
7
|
+
ReactDOM.render(
|
|
8
|
+
<React.StrictMode>
|
|
9
|
+
<App />
|
|
10
|
+
</React.StrictMode>,
|
|
11
|
+
document.getElementById('root')
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
// If you want your app to work offline and load faster, you can change
|
|
15
|
+
// unregister() to register() below. Note this comes with some pitfalls.
|
|
16
|
+
// Learn more about service workers: https://cra.link/PWA
|
|
17
|
+
serviceWorkerRegistration.unregister();
|
|
18
|
+
|
|
19
|
+
// If you want to start measuring performance in your app, pass a function
|
|
20
|
+
// to log results (for example: reportWebVitals(console.log))
|
|
21
|
+
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
|
|
22
|
+
reportWebVitals();
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import { IonPage, isPlatform } from '@ionic/react';
|
|
2
|
+
import { DocumentReader, DocumentReaderScenario, Enum, DocumentReaderCompletion, DocumentReaderResults, DocumentReaderNotification } from '@regulaforensics/ionic-native-document-reader';
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { DirectoryEntry, Entry, File, FileEntry, IFile } from '@awesome-cordova-plugins/file'
|
|
5
|
+
import { AndroidPermissions } from "@awesome-cordova-plugins/android-permissions"
|
|
6
|
+
import { ImagePicker } from "@awesome-cordova-plugins/image-picker"
|
|
7
|
+
|
|
8
|
+
var doRfid: boolean = false
|
|
9
|
+
var isReadingRfidCustomUi: boolean = false
|
|
10
|
+
var isReadingRfid: boolean = false
|
|
11
|
+
var rfidUIHeader: string = "Reading RFID"
|
|
12
|
+
var rfidUIHeaderColor: string = "black"
|
|
13
|
+
var rfidDescription: string = "Place your phone on top of the NFC tag"
|
|
14
|
+
var rfidProgress: number = -1
|
|
15
|
+
|
|
16
|
+
const status = document.querySelector('.status') as HTMLElement
|
|
17
|
+
const portraitImage = document.querySelector('.portraitImage') as any
|
|
18
|
+
const documentImage = document.querySelector('.documentImage') as any
|
|
19
|
+
const showScannerButton = document.querySelector('.showScannerButton') as HTMLElement
|
|
20
|
+
const showImagePicker = document.querySelector('.showImagePicker') as HTMLElement
|
|
21
|
+
const scenariosRadioGroup = document.querySelector('.scenariosRadioGroup') as HTMLElement
|
|
22
|
+
const rfidCheckbox = document.querySelector('.rfidCheckbox') as HTMLIonCheckboxElement
|
|
23
|
+
const rfidCheckboxText = document.querySelector('.rfidCheckboxText') as HTMLElement
|
|
24
|
+
const rfidUI = document.querySelector('.rfidUI') as HTMLElement
|
|
25
|
+
const mainUI = document.querySelector('.mainUI') as HTMLElement
|
|
26
|
+
const rfidUIHeaderRef = document.querySelector('.rfidUIHeader') as HTMLElement
|
|
27
|
+
const rfidDescriptionRef = document.querySelector('.rfidDescription') as HTMLElement
|
|
28
|
+
const rfidProgressRef = document.querySelector('.rfidProgress') as HTMLIonProgressBarElement
|
|
29
|
+
const cancelButtonRef = document.querySelector('.cancelButton') as HTMLElement
|
|
30
|
+
|
|
31
|
+
var error1 = (e: any) => {
|
|
32
|
+
console.log(e)
|
|
33
|
+
status.innerHTML = e
|
|
34
|
+
status.style.backgroundColor = "red"
|
|
35
|
+
}
|
|
36
|
+
var error2 = (e: any) => {
|
|
37
|
+
e = JSON.stringify(e, undefined, 2)
|
|
38
|
+
console.log(e)
|
|
39
|
+
alert(e)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
cancelButtonRef.addEventListener("click", stopRfid)
|
|
43
|
+
updateUI()
|
|
44
|
+
status.innerHTML = "loading......"
|
|
45
|
+
status.style.backgroundColor = "grey"
|
|
46
|
+
document.addEventListener("deviceready", onDeviceReady, false);
|
|
47
|
+
|
|
48
|
+
function onDeviceReady() {
|
|
49
|
+
readFile("public/assets", "regula.license", (license: any) => {
|
|
50
|
+
DocumentReader.prepareDatabase("Full").subscribe((response: string) => {
|
|
51
|
+
if (response != "database prepared")
|
|
52
|
+
status.innerHTML = "Downloading database: " + response + "%"
|
|
53
|
+
else {
|
|
54
|
+
status.innerHTML = "Loading......"
|
|
55
|
+
DocumentReader.initializeReader({
|
|
56
|
+
license: license,
|
|
57
|
+
delayedNNLoad: true
|
|
58
|
+
}).then((_r: string) => onInitialized()).catch(error1)
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function addCertificates() {
|
|
65
|
+
File.resolveDirectoryUrl(File.applicationDirectory + "certificates").then((dir: DirectoryEntry) => {
|
|
66
|
+
dir.createReader().readEntries((entries: Entry[]) => {
|
|
67
|
+
for (let i = 0; i < entries.length; i++) {
|
|
68
|
+
if (entries[i].isFile) {
|
|
69
|
+
var findExt = entries[i].name.split('.')
|
|
70
|
+
var pkdResourceType = 0
|
|
71
|
+
if (findExt.length > 0)
|
|
72
|
+
pkdResourceType = Enum.PKDResourceType.getType(findExt[findExt.length - 1].toLowerCase())
|
|
73
|
+
readFile("certificates", entries[i].name, (file: any, resType: any) => {
|
|
74
|
+
resType = resType[0]
|
|
75
|
+
var certificates = []
|
|
76
|
+
certificates.push({
|
|
77
|
+
'binaryData': file,
|
|
78
|
+
'resourceType': resType
|
|
79
|
+
})
|
|
80
|
+
DocumentReader.addPKDCertificates(certificates).then((_r: string) => console.log("certificate added")).catch(error1)
|
|
81
|
+
}, pkdResourceType)
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function readFile(dirPath: string, fileName: string, callback: any, ...items: any) {
|
|
89
|
+
File.resolveDirectoryUrl(File.applicationDirectory + dirPath).then((dir: DirectoryEntry) => File.getFile(dir, fileName, {})).then((fileEntry: FileEntry) => fileEntry.file((file: IFile) => {
|
|
90
|
+
var reader = new FileReader()
|
|
91
|
+
reader.onloadend = (evt) => {
|
|
92
|
+
var data = reader.result as String
|
|
93
|
+
data = data.substring(data.indexOf(',') + 1)
|
|
94
|
+
callback(data, items)
|
|
95
|
+
}
|
|
96
|
+
reader.readAsDataURL(file)
|
|
97
|
+
}))
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function updateUI() {
|
|
101
|
+
mainUI.style.display = isReadingRfidCustomUi ? "none" : ""
|
|
102
|
+
rfidUI.style.display = isReadingRfidCustomUi ? "" : "none"
|
|
103
|
+
rfidUIHeaderRef.innerHTML = rfidUIHeader
|
|
104
|
+
rfidUIHeaderRef.style.color = rfidUIHeaderColor
|
|
105
|
+
rfidDescriptionRef.innerHTML = rfidDescription
|
|
106
|
+
rfidProgressRef.value = rfidProgress
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function stopRfid() {
|
|
110
|
+
hideRfidUI()
|
|
111
|
+
DocumentReader.stopRFIDReader()
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function handleCompletion(completion?: DocumentReaderCompletion) {
|
|
115
|
+
if (completion == undefined) return;
|
|
116
|
+
if (isReadingRfidCustomUi && (completion.action === Enum.DocReaderAction.CANCEL || completion.action === Enum.DocReaderAction.ERROR))
|
|
117
|
+
hideRfidUI()
|
|
118
|
+
if (isReadingRfidCustomUi && completion.action === Enum.DocReaderAction.NOTIFICATION)
|
|
119
|
+
updateRfidUI(completion.results!.documentReaderNotification!)
|
|
120
|
+
if (completion.action === Enum.DocReaderAction.COMPLETE)
|
|
121
|
+
if (isReadingRfidCustomUi) {
|
|
122
|
+
if (completion.results!.rfidResult !== 1)
|
|
123
|
+
restartRfidUI()
|
|
124
|
+
else {
|
|
125
|
+
hideRfidUI()
|
|
126
|
+
displayResults(completion.results!)
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
else
|
|
130
|
+
handleResults(completion.results!)
|
|
131
|
+
if (completion.action === Enum.DocReaderAction.TIMEOUT)
|
|
132
|
+
handleResults(completion.results!)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function showRfidUI() {
|
|
136
|
+
// show animation
|
|
137
|
+
isReadingRfidCustomUi = true
|
|
138
|
+
updateUI()
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function hideRfidUI() {
|
|
142
|
+
// show animation
|
|
143
|
+
restartRfidUI()
|
|
144
|
+
isReadingRfidCustomUi = false
|
|
145
|
+
rfidUIHeader = "Reading RFID"
|
|
146
|
+
rfidUIHeaderColor = "black"
|
|
147
|
+
updateUI()
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function restartRfidUI() {
|
|
151
|
+
rfidUIHeaderColor = "red"
|
|
152
|
+
rfidUIHeader = "Failed!"
|
|
153
|
+
rfidDescription = "Place your phone on top of the NFC tag"
|
|
154
|
+
rfidProgress = -1
|
|
155
|
+
updateUI()
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function updateRfidUI(notification: DocumentReaderNotification) {
|
|
159
|
+
if (notification.code === Enum.eRFID_NotificationCodes.RFID_NOTIFICATION_PCSC_READING_DATAGROUP)
|
|
160
|
+
rfidDescription = Enum.eRFID_DataFile_Type.getTranslation(notification.dataFileType!)
|
|
161
|
+
rfidUIHeader = "Reading RFID"
|
|
162
|
+
rfidUIHeaderColor = "black"
|
|
163
|
+
rfidProgress = notification.value!
|
|
164
|
+
updateUI()
|
|
165
|
+
if (isPlatform("ios"))
|
|
166
|
+
DocumentReader.setRfidSessionStatus(rfidDescription + "\n" + notification.value + "%")
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function customRFID() {
|
|
170
|
+
showRfidUI()
|
|
171
|
+
DocumentReader.readRFID().subscribe((m: string) =>
|
|
172
|
+
handleCompletion(DocumentReaderCompletion.fromJson(JSON.parse(m))))
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function usualRFID() {
|
|
176
|
+
isReadingRfid = true
|
|
177
|
+
var notification = "rfidNotificationCompletionEvent"
|
|
178
|
+
var paCert = "paCertificateCompletionEvent"
|
|
179
|
+
var taCert = "taCertificateCompletionEvent"
|
|
180
|
+
var taSig = "taSignatureCompletionEvent"
|
|
181
|
+
DocumentReader.startRFIDReader().subscribe((m: string) => {
|
|
182
|
+
if (m.substring(0, notification.length) === notification) {
|
|
183
|
+
m = m.substring(notification.length, m.length)
|
|
184
|
+
console.log(notification + ": " + m)
|
|
185
|
+
} else if (m.substring(0, paCert.length) === paCert) {
|
|
186
|
+
m = m.substring(paCert.length, m.length)
|
|
187
|
+
console.log(paCert + ": " + m)
|
|
188
|
+
} else if (m.substring(0, taCert.length) === taCert) {
|
|
189
|
+
m = m.substring(taCert.length, m.length)
|
|
190
|
+
console.log(taCert + ": " + m)
|
|
191
|
+
} else if (m.substring(0, taSig.length) === taSig) {
|
|
192
|
+
m = m.substring(taSig.length, m.length)
|
|
193
|
+
console.log(taSig + ": " + m)
|
|
194
|
+
} else
|
|
195
|
+
handleCompletion(DocumentReaderCompletion.fromJson(JSON.parse(m)))
|
|
196
|
+
})
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function onInitialized() {
|
|
200
|
+
status.innerHTML = "Ready"
|
|
201
|
+
status.style.backgroundColor = "green"
|
|
202
|
+
showScannerButton.addEventListener("click", scan)
|
|
203
|
+
if (isPlatform("android"))
|
|
204
|
+
showImagePicker.addEventListener("click", recognizeAndroid)
|
|
205
|
+
if (isPlatform("ios"))
|
|
206
|
+
showImagePicker.addEventListener("click", recognize)
|
|
207
|
+
DocumentReader.setConfig({
|
|
208
|
+
functionality: {
|
|
209
|
+
videoCaptureMotionControl: true,
|
|
210
|
+
showCaptureButton: true
|
|
211
|
+
},
|
|
212
|
+
customization: {
|
|
213
|
+
showResultStatusMessages: true,
|
|
214
|
+
showStatusMessages: true
|
|
215
|
+
},
|
|
216
|
+
processParams: {
|
|
217
|
+
scenario: "Mrz",
|
|
218
|
+
doRfid: false
|
|
219
|
+
},
|
|
220
|
+
})
|
|
221
|
+
DocumentReader.getAvailableScenarios().then((sc: string) =>
|
|
222
|
+
DocumentReader.isRFIDAvailableForUse().then((canRfid: boolean) =>
|
|
223
|
+
postInitialize(JSON.parse(sc), canRfid)))
|
|
224
|
+
DocumentReader.setRfidDelegate(Enum.RFIDDelegate.NO_PA)
|
|
225
|
+
// addCertificates()
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function postInitialize(scenarios: Array<any>, canRfid: boolean) {
|
|
229
|
+
var inputs = []
|
|
230
|
+
for (let index of scenarios) {
|
|
231
|
+
var input = document.createElement("input")
|
|
232
|
+
inputs.push(input)
|
|
233
|
+
input.type = "radio"
|
|
234
|
+
input.name = "scenario"
|
|
235
|
+
input.value = (DocumentReaderScenario.fromJson(typeof index === "string" ? JSON.parse(index) : index)!.name)!
|
|
236
|
+
if (index == 0)
|
|
237
|
+
input.checked = true
|
|
238
|
+
input.onclick = () => DocumentReader.setConfig({ processParams: { scenario: DocumentReaderScenario.fromJson(typeof index === "string" ? JSON.parse(index) : index)!.name } })
|
|
239
|
+
input.style.display = "inline-block"
|
|
240
|
+
}
|
|
241
|
+
for (let input of inputs) {
|
|
242
|
+
scenariosRadioGroup.appendChild(input)
|
|
243
|
+
var label = document.createElement("span")
|
|
244
|
+
label.innerHTML = input.value
|
|
245
|
+
label.style.display = "inline-block"
|
|
246
|
+
label.style.width = "200px"
|
|
247
|
+
label.onclick = () => input.click()
|
|
248
|
+
scenariosRadioGroup.appendChild(label)
|
|
249
|
+
scenariosRadioGroup.appendChild(document.createElement("br"))
|
|
250
|
+
}
|
|
251
|
+
if (canRfid) {
|
|
252
|
+
rfidCheckbox.disabled = false
|
|
253
|
+
rfidCheckboxText.style.color = "black"
|
|
254
|
+
rfidCheckboxText.innerHTML = "Process rfid reading"
|
|
255
|
+
rfidCheckbox.onclick = () => doRfid = !doRfid
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function handleResults(results: DocumentReaderResults) {
|
|
260
|
+
clearResults()
|
|
261
|
+
if (doRfid && !isReadingRfid && results != null && results.chipPage != 0) {
|
|
262
|
+
// customRFID()
|
|
263
|
+
usualRFID()
|
|
264
|
+
} else {
|
|
265
|
+
isReadingRfid = false
|
|
266
|
+
displayResults(results)
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function displayResults(results: DocumentReaderResults) {
|
|
271
|
+
if (results == null) return
|
|
272
|
+
|
|
273
|
+
DocumentReader.textFieldValueByType(results, Enum.eVisualFieldType.FT_SURNAME_AND_GIVEN_NAMES).then((value: string | undefined) => {
|
|
274
|
+
if (value != null) {
|
|
275
|
+
status.innerHTML = value
|
|
276
|
+
status.style.backgroundColor = "green"
|
|
277
|
+
}
|
|
278
|
+
})
|
|
279
|
+
|
|
280
|
+
DocumentReader.graphicFieldImageByType(results, Enum.eGraphicFieldType.GF_DOCUMENT_IMAGE).then((value: string | undefined) => {
|
|
281
|
+
if (value != null)
|
|
282
|
+
documentImage.src = "data:image/png;base64," + value
|
|
283
|
+
})
|
|
284
|
+
|
|
285
|
+
DocumentReader.graphicFieldImageByType(results, Enum.eGraphicFieldType.GF_PORTRAIT).then((value: string | undefined) => {
|
|
286
|
+
if (value != null)
|
|
287
|
+
portraitImage.src = "data:image/png;base64," + value
|
|
288
|
+
})
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function clearResults() {
|
|
292
|
+
status.innerHTML = "Ready"
|
|
293
|
+
documentImage.src = "assets/img/id.png"
|
|
294
|
+
portraitImage.src = "assets/img/portrait.png"
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function scan() {
|
|
298
|
+
DocumentReader.showScanner().subscribe((m: string) =>
|
|
299
|
+
handleCompletion(DocumentReaderCompletion.fromJson(JSON.parse(m))))
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function recognize() {
|
|
303
|
+
ImagePicker.getPictures({ maximumImagesCount: 1 }).then((results: any) => {
|
|
304
|
+
if (results.length > 0) {
|
|
305
|
+
clearResults()
|
|
306
|
+
status.innerHTML = "copying image......"
|
|
307
|
+
status.style.backgroundColor = "grey"
|
|
308
|
+
}
|
|
309
|
+
File.readAsDataURL((isPlatform("ios") ? "file://" : "") + results[0].substring(0, (results[0] as string).lastIndexOf("/")), results[0].substring((results[0] as string).lastIndexOf("/") + 1)).then((file => {
|
|
310
|
+
status.innerHTML = "processing image......"
|
|
311
|
+
status.style.backgroundColor = "grey"
|
|
312
|
+
let fileString = (file as string)
|
|
313
|
+
DocumentReader.recognizeImage(fileString.substring(fileString.indexOf(",") + 1)).subscribe((m: string) =>
|
|
314
|
+
handleCompletion(DocumentReaderCompletion.fromJson(JSON.parse(m))))
|
|
315
|
+
})).catch(error2)
|
|
316
|
+
}, error2)
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function recognizeAndroid() {
|
|
320
|
+
AndroidPermissions.checkPermission(AndroidPermissions.PERMISSION.READ_EXTERNAL_STORAGE).then((result: any) => {
|
|
321
|
+
if (result.hasPermission)
|
|
322
|
+
recognize()
|
|
323
|
+
else
|
|
324
|
+
AndroidPermissions.requestPermission(AndroidPermissions.PERMISSION.READ_EXTERNAL_STORAGE).then((result: any) => {
|
|
325
|
+
if (result.hasPermission)
|
|
326
|
+
recognize()
|
|
327
|
+
else
|
|
328
|
+
console.log("storage permission denied")
|
|
329
|
+
}, (err: any) => console.log(JSON.stringify(err)))
|
|
330
|
+
}, (err: any) => console.log(JSON.stringify(err)))
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
const Home: React.FC = () => {
|
|
334
|
+
return (
|
|
335
|
+
<IonPage>
|
|
336
|
+
</IonPage>
|
|
337
|
+
);
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
export default Home;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="react-scripts" />
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ReportHandler } from 'web-vitals';
|
|
2
|
+
|
|
3
|
+
const reportWebVitals = (onPerfEntry?: ReportHandler) => {
|
|
4
|
+
if (onPerfEntry && onPerfEntry instanceof Function) {
|
|
5
|
+
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
|
|
6
|
+
getCLS(onPerfEntry);
|
|
7
|
+
getFID(onPerfEntry);
|
|
8
|
+
getFCP(onPerfEntry);
|
|
9
|
+
getLCP(onPerfEntry);
|
|
10
|
+
getTTFB(onPerfEntry);
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default reportWebVitals;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/// <reference lib="webworker" />
|
|
2
|
+
/* eslint-disable no-restricted-globals */
|
|
3
|
+
|
|
4
|
+
// This service worker can be customized!
|
|
5
|
+
// See https://developers.google.com/web/tools/workbox/modules
|
|
6
|
+
// for the list of available Workbox modules, or add any other
|
|
7
|
+
// code you'd like.
|
|
8
|
+
// You can also remove this file if you'd prefer not to use a
|
|
9
|
+
// service worker, and the Workbox build step will be skipped.
|
|
10
|
+
|
|
11
|
+
import { clientsClaim } from 'workbox-core';
|
|
12
|
+
import { ExpirationPlugin } from 'workbox-expiration';
|
|
13
|
+
import { precacheAndRoute, createHandlerBoundToURL } from 'workbox-precaching';
|
|
14
|
+
import { registerRoute } from 'workbox-routing';
|
|
15
|
+
import { StaleWhileRevalidate } from 'workbox-strategies';
|
|
16
|
+
|
|
17
|
+
declare const self: ServiceWorkerGlobalScope;
|
|
18
|
+
|
|
19
|
+
clientsClaim();
|
|
20
|
+
|
|
21
|
+
// Precache all of the assets generated by your build process.
|
|
22
|
+
// Their URLs are injected into the manifest variable below.
|
|
23
|
+
// This variable must be present somewhere in your service worker file,
|
|
24
|
+
// even if you decide not to use precaching. See https://cra.link/PWA
|
|
25
|
+
precacheAndRoute(self.__WB_MANIFEST);
|
|
26
|
+
|
|
27
|
+
// Set up App Shell-style routing, so that all navigation requests
|
|
28
|
+
// are fulfilled with your index.html shell. Learn more at
|
|
29
|
+
// https://developers.google.com/web/fundamentals/architecture/app-shell
|
|
30
|
+
const fileExtensionRegexp = new RegExp('/[^/?]+\\.[^/]+$');
|
|
31
|
+
registerRoute(
|
|
32
|
+
// Return false to exempt requests from being fulfilled by index.html.
|
|
33
|
+
({ request, url }: { request: Request; url: URL }) => {
|
|
34
|
+
// If this isn't a navigation, skip.
|
|
35
|
+
if (request.mode !== 'navigate') {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// If this is a URL that starts with /_, skip.
|
|
40
|
+
if (url.pathname.startsWith('/_')) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// If this looks like a URL for a resource, because it contains
|
|
45
|
+
// a file extension, skip.
|
|
46
|
+
if (url.pathname.match(fileExtensionRegexp)) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Return true to signal that we want to use the handler.
|
|
51
|
+
return true;
|
|
52
|
+
},
|
|
53
|
+
createHandlerBoundToURL(process.env.PUBLIC_URL + '/index.html')
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
// An example runtime caching route for requests that aren't handled by the
|
|
57
|
+
// precache, in this case same-origin .png requests like those from in public/
|
|
58
|
+
registerRoute(
|
|
59
|
+
// Add in any other file extensions or routing criteria as needed.
|
|
60
|
+
({ url }) => url.origin === self.location.origin && url.pathname.endsWith('.png'),
|
|
61
|
+
// Customize this strategy as needed, e.g., by changing to CacheFirst.
|
|
62
|
+
new StaleWhileRevalidate({
|
|
63
|
+
cacheName: 'images',
|
|
64
|
+
plugins: [
|
|
65
|
+
// Ensure that once this runtime cache reaches a maximum size the
|
|
66
|
+
// least-recently used images are removed.
|
|
67
|
+
new ExpirationPlugin({ maxEntries: 50 }),
|
|
68
|
+
],
|
|
69
|
+
})
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
// This allows the web app to trigger skipWaiting via
|
|
73
|
+
// registration.waiting.postMessage({type: 'SKIP_WAITING'})
|
|
74
|
+
self.addEventListener('message', (event) => {
|
|
75
|
+
if (event.data && event.data.type === 'SKIP_WAITING') {
|
|
76
|
+
self.skipWaiting();
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// Any other custom service worker logic can go here.
|