This repository has been archived by the owner on Oct 10, 2024. It is now read-only.
generated from capacitor-community/.github
-
Notifications
You must be signed in to change notification settings - Fork 175
/
definitions.ts
244 lines (205 loc) · 5.32 KB
/
definitions.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
export type CallbackID = string;
export interface BarcodeScannerPlugin {
prepare(options?: ScanOptions): Promise<void>;
hideBackground(): Promise<void>;
showBackground(): Promise<void>;
startScan(options?: ScanOptions): Promise<ScanResult>;
startScanning(options?: ScanOptions, callback?: (result: ScanResult, err?: any) => void): Promise<CallbackID>;
pauseScanning(): Promise<void>;
resumeScanning(): Promise<void>;
stopScan(options?: StopScanOptions): Promise<void>;
checkPermission(options?: CheckPermissionOptions): Promise<CheckPermissionResult>;
openAppSettings(): Promise<void>;
enableTorch(): Promise<void>;
disableTorch(): Promise<void>;
toggleTorch(): Promise<void>;
getTorchState(): Promise<TorchStateResult>;
}
const _SupportedFormat = {
// BEGIN 1D Product
/**
* Android only, UPC_A is part of EAN_13 according to Apple docs
*/
UPC_A: 'UPC_A',
UPC_E: 'UPC_E',
/**
* Android only
*/
UPC_EAN_EXTENSION: 'UPC_EAN_EXTENSION',
EAN_8: 'EAN_8',
EAN_13: 'EAN_13',
// END 1D Product
// BEGIN 1D Industrial
CODE_39: 'CODE_39',
/**
* iOS only
*/
CODE_39_MOD_43: 'CODE_39_MOD_43',
CODE_93: 'CODE_93',
CODE_128: 'CODE_128',
/**
* Android only
*/
CODABAR: 'CODABAR',
ITF: 'ITF',
/**
* iOS only
*/
ITF_14: 'ITF_14',
// END 1D Industrial
// BEGIN 2D
AZTEC: 'AZTEC',
DATA_MATRIX: 'DATA_MATRIX',
/**
* Android only
*/
MAXICODE: 'MAXICODE',
PDF_417: 'PDF_417',
QR_CODE: 'QR_CODE',
/**
* Android only
*/
RSS_14: 'RSS_14',
/**
* Android only
*/
RSS_EXPANDED: 'RSS_EXPANDED',
// END 2D
} as const;
export const SupportedFormat = _SupportedFormat satisfies {
[k in SupportedFormat]: k;
};
export type SupportedFormat = typeof _SupportedFormat[keyof typeof _SupportedFormat];
export const CameraDirection = {
FRONT: 'front',
BACK: 'back',
} as const;
export type CameraDirection = typeof CameraDirection[keyof typeof CameraDirection];
export interface ScanOptions {
/**
* This parameter can be used to make the scanner only recognize specific types of barcodes.
* If `targetedFormats` is _not specified_ or _left empty_, _all types_ of barcodes will be targeted.
*
* @since 1.2.0
*/
targetedFormats?: SupportedFormat[];
/**
* This parameter can be used to set the camera direction.
*
* @since 2.1.0
*/
cameraDirection?: CameraDirection;
}
export interface StopScanOptions {
/**
* If this is set to `true`, the `startScan` method will resolve.
* Additionally `hasContent` will be `false`.
* For more information see: https://github.com/capacitor-community/barcode-scanner/issues/17
*
* @default true
* @since 2.1.0
*/
resolveScan?: boolean;
}
export type ScanResult = IScanResultWithContent | IScanResultWithoutContent;
export interface IScanResultWithContent {
/**
* This indicates whether or not the scan resulted in readable content.
* When stopping the scan with `resolveScan` set to `true`, for example,
* this parameter is set to `false`, because no actual content was scanned.
*
* @since 1.0.0
*/
hasContent: true;
/**
* This holds the content of the barcode if available.
*
* @since 1.0.0
*/
content: string;
/**
* This returns format of scan result.
*
* @since 2.1.0
*/
format: string;
}
export interface IScanResultWithoutContent {
/**
* This indicates whether or not the scan resulted in readable content.
* When stopping the scan with `resolveScan` set to `true`, for example,
* this parameter is set to `false`, because no actual content was scanned.
*
* @since 1.0.0
*/
hasContent: false;
/**
* This holds the content of the barcode if available.
*
* @since 1.0.0
*/
content: undefined;
/**
* This returns format of scan result.
*
* @since 2.1.0
*/
format: undefined;
}
export interface CheckPermissionOptions {
/**
* If this is set to `true`, the user will be prompted for the permission.
* The prompt will only show if the permission was not yet granted and also not denied completely yet.
* For more information see: https://github.com/capacitor-community/barcode-scanner#permissions
*
* @default false
* @since 1.0.0
*/
force?: boolean;
}
export interface CheckPermissionResult {
/**
* When set to `true`, the ermission is granted.
*/
granted?: boolean;
/**
* When set to `true`, the permission is denied and cannot be prompted for.
* The `openAppSettings` method should be used to let the user grant the permission.
*
* @since 1.0.0
*/
denied?: boolean;
/**
* When this is set to `true`, the user was just prompted the permission.
* Ergo: a dialog, asking the user to grant the permission, was shown.
*
* @since 1.0.0
*/
asked?: boolean;
/**
* When this is set to `true`, the user has never been prompted the permission.
*
* @since 1.0.0
*/
neverAsked?: boolean;
/**
* iOS only
* When this is set to `true`, the permission cannot be requested for some reason.
*
* @since 1.0.0
*/
restricted?: boolean;
/**
* iOS only
* When this is set to `true`, the permission status cannot be retrieved.
*
* @since 1.0.0
*/
unknown?: boolean;
}
export interface TorchStateResult {
/**
* Whether or not the torch is currently enabled.
*/
isEnabled: boolean;
}