@dustid/dust-go-connect 0.1.6 → 0.1.7
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 +5 -5
- package/lib/index.js +1 -1
- package/lib/types.d.ts +5 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -62,18 +62,18 @@ webview isn't paused while the scanner is presented.
|
|
|
62
62
|
```typescript
|
|
63
63
|
type ScanPayload =
|
|
64
64
|
| {
|
|
65
|
-
type: '
|
|
65
|
+
type: 'DUST'
|
|
66
66
|
data: string
|
|
67
67
|
metadata?: ScanSettings
|
|
68
68
|
}
|
|
69
69
|
| {
|
|
70
|
-
type: '
|
|
70
|
+
type: 'QR'
|
|
71
71
|
data: string
|
|
72
72
|
metadata?: Record<string, any>
|
|
73
73
|
}
|
|
74
|
-
| { type: '
|
|
75
|
-
| { type: '
|
|
76
|
-
| { type: '
|
|
74
|
+
| { type: 'BARCODE'; data: string; metadata?: Record<string, any> }
|
|
75
|
+
| { type: 'DATA_MATRIX'; data: string; metadata?: Record<string, any> }
|
|
76
|
+
| { type: 'NFC'; Data: string; metadata?: Record<string, any> }
|
|
77
77
|
```
|
|
78
78
|
|
|
79
79
|
| Scan Events |
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
class w{callbacks=new Map;add(o,e){this.callbacks.set(o,e)}has(o){return this.callbacks.has(o)}clear(){this.callbacks.clear()}remove(o){if(!o&&!this.callbacks.size)return;if(!o){this.callbacks.clear();return}this.callbacks.delete(o)}dispatch(o){this.callbacks.forEach((e)=>{e(o)})}dispatchEvent(o,e){switch(o){case"scan":this.dispatch({type:"scan",payload:{type:"
|
|
1
|
+
class w{callbacks=new Map;add(o,e){this.callbacks.set(o,e)}has(o){return this.callbacks.has(o)}clear(){this.callbacks.clear()}remove(o){if(!o&&!this.callbacks.size)return;if(!o){this.callbacks.clear();return}this.callbacks.delete(o)}dispatch(o){this.callbacks.forEach((e)=>{e(o)})}dispatchEvent(o,e){switch(o){case"scan":this.dispatch({type:"scan",payload:{type:"DUST",data:e.data,metadata:e.metadata||{}}});break;case"hide":case"show":this.dispatch({type:o});break;default:throw Error(`Unknown event type: ${o}`)}}}class r extends w{static detected=Boolean(globalThis.window?.chrome?.webview);constructor(){if(!globalThis.window?.chrome?.webview)throw Error("Could not init ChromeWebViewDustGoConnector");super()}rewriteRedirect(o){return o}showScanner(){globalThis.window?.chrome?.webview?.postMessage("show")}hideScanner(){globalThis.window?.chrome?.webview?.postMessage("hide")}}class i extends w{appId;static detected=Boolean(globalThis.window?.ReactNativeWebView);constructor(){if(!globalThis.window?.ReactNativeWebView)throw Error("Could not init ReactNativeWebViewDustGoConnector");let o=globalThis.window?.ReactNativeWebView.injectedObjectJson(),e=JSON.parse(o??"{}");if(!("appId"in e)||typeof e.appId!=="string")throw Error("Could not validate injected JSON");super();this.appId=e.appId}rewriteRedirect(o){return new URL(o.href.replace(o.protocol,`${this.appId}:`))}showScanner(){globalThis.window?.ReactNativeWebView?.postMessage("show")}hideScanner(){globalThis.window?.ReactNativeWebView?.postMessage("hide")}}var a=()=>{return new Promise((o,e)=>{if(!window.dustGoConnector){e("DUST Go connector is not present");return}let n=Math.random().toString(36).substring(2,15),s=window.dustGoConnector;s.showScanner();let p=(t)=>{switch(t.type){case"scan":o(t.payload);break;case"hide":e("Scanner was hidden");break}s.remove(n)};s.add(n,p)})};if(i.detected)globalThis.window.dustGoConnector=new i;else if(r.detected)globalThis.window.dustGoConnector=new r;var C=globalThis.window?.dustGoConnector;export{a as scanAsync,C as connector};
|
package/lib/types.d.ts
CHANGED
|
@@ -44,23 +44,23 @@ export type EnrollMetadata = {
|
|
|
44
44
|
accuracy?: number;
|
|
45
45
|
};
|
|
46
46
|
export type ScanPayload = {
|
|
47
|
-
type: '
|
|
47
|
+
type: 'DUST';
|
|
48
48
|
data: string;
|
|
49
49
|
metadata?: ScanSettings;
|
|
50
50
|
} | {
|
|
51
|
-
type: '
|
|
51
|
+
type: 'QR';
|
|
52
52
|
data: string;
|
|
53
53
|
metadata?: Record<string, any>;
|
|
54
54
|
} | {
|
|
55
|
-
type: '
|
|
55
|
+
type: 'BARCODE';
|
|
56
56
|
data: string;
|
|
57
57
|
metadata?: Record<string, any>;
|
|
58
58
|
} | {
|
|
59
|
-
type: '
|
|
59
|
+
type: 'DATA_MATRIX';
|
|
60
60
|
data: string;
|
|
61
61
|
metadata?: Record<string, any>;
|
|
62
62
|
} | {
|
|
63
|
-
type: '
|
|
63
|
+
type: 'NFC';
|
|
64
64
|
data: string;
|
|
65
65
|
metadata?: Record<string, any>;
|
|
66
66
|
};
|