barkoder-nativescript 0.0.3 → 0.0.5

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.
@@ -0,0 +1,431 @@
1
+ import { Observable } from 'tns-core-modules/data/observable';
2
+
3
+ import { View } from '@nativescript/core';
4
+ import { isAndroid, isIOS } from "@nativescript/core/platform";
5
+ import { BarkoderViewAndroid } from './barkoder-nativescript.android';
6
+ import { BarkoderViewIOS } from './barkoder-nativescript.ios';
7
+
8
+
9
+
10
+ let BarkoderView: typeof View;
11
+
12
+ if (isAndroid) {
13
+ BarkoderView = require('./barkoder-nativescript.android').BarkoderViewAndroid;
14
+ } else if (isIOS) {
15
+ BarkoderView = require('./barkoder-nativescript.ios').BarkoderViewIOS;
16
+ }
17
+
18
+ export { BarkoderView };
19
+
20
+ export namespace BarkoderConstants {
21
+
22
+
23
+ export enum DecoderType {
24
+ Aztec = 0,
25
+ AztecCompact = 1,
26
+ QR = 2,
27
+ QRMicro = 3,
28
+ Code128 = 4,
29
+ Code93 = 5,
30
+ Code39 = 6,
31
+ Codabar = 7,
32
+ Code11 = 8,
33
+ Msi = 9,
34
+ UpcA = 10,
35
+ UpcE = 11,
36
+ UpcE1 = 12,
37
+ Ean13 = 13,
38
+ Ean8 = 14,
39
+ PDF417 = 15,
40
+ PDF417Micro = 16,
41
+ Datamatrix = 17,
42
+ Code25 = 18,
43
+ Interleaved25 = 19,
44
+ ITF14 = 20,
45
+ IATA25 = 21,
46
+ Matrix25 = 22,
47
+ Datalogic25 = 23,
48
+ COOP25 = 24,
49
+ Code32 = 25,
50
+ Telepen = 26,
51
+ Dotcode = 27
52
+ }
53
+
54
+ export enum FormattingType {
55
+ Disabled = 0,
56
+ Automatic = 1,
57
+ GS1 = 2,
58
+ AAMVA = 3
59
+ }
60
+
61
+ export enum DecodingSpeed {
62
+ Fast = 0,
63
+ Normal = 1,
64
+ Slow = 2
65
+ }
66
+
67
+ export enum BarkoderResolution {
68
+ NORMAL = 'HD',
69
+ HIGH = 'Full HD'
70
+ }
71
+
72
+ export enum MsiCheckSumType {
73
+ Disabled = 0,
74
+ Mod10 = 1,
75
+ Mod11 = 2,
76
+ Mod1010 = 3,
77
+ Mod1110 = 4,
78
+ Mod11IBM = 5,
79
+ Mod1110IBM = 6
80
+ }
81
+
82
+ export enum Code11CheckSumType {
83
+ Disabled = 0,
84
+ Single = 1,
85
+ Double = 2
86
+ }
87
+
88
+ export enum Code39CheckSumType {
89
+ Disabled = 0,
90
+ Enabled = 1
91
+ }
92
+
93
+ export class Common extends Observable {
94
+
95
+ }
96
+
97
+ export interface BarkoderResultCallback {
98
+ scanningFinished(results: any[], thumbnails: any[], resultImage: any): void;
99
+ }
100
+
101
+ export interface MaxZoomAvailableCallback {
102
+ onMaxZoomAvailable(maxZoomFactor: any)
103
+ }
104
+
105
+ export interface FlashAvailableCallback {
106
+ onFlashAvailable(isFlashAvailable: any)
107
+ }
108
+
109
+ export class BarkoderConfig {
110
+ locationLineColor?: string;
111
+ locationLineWidth?: number;
112
+ roiLineColor?: string;
113
+ roiLineWidth?: number;
114
+ roiOverlayBackgroundColor?: string;
115
+ closeSessionOnResultEnabled?: boolean;
116
+ imageResultEnabled?: boolean;
117
+ locationInImageResultEnabled?: boolean;
118
+ locationInPreviewEnabled?: boolean;
119
+ pinchToZoomEnabled?: boolean;
120
+ regionOfInterestVisible?: boolean;
121
+ barkoderResolution?: number;
122
+ beepOnSuccessEnabled?: boolean;
123
+ vibrateOnSuccessEnabled?: boolean;
124
+ decoder?: DekoderConfig;
125
+
126
+ constructor(config: Partial<BarkoderConfig>) {
127
+ Object.assign(this, config);
128
+ }
129
+
130
+ toJsonString(): string {
131
+ const configAsJson: { [key: string]: any } = {
132
+ "locationLineColor": this.locationLineColor,
133
+ "locationLineWidth": this.locationLineWidth,
134
+ "roiLineColor": this.roiLineColor,
135
+ "roiLineWidth": this.roiLineWidth,
136
+ "roiOverlayBackgroundColor": this.roiOverlayBackgroundColor,
137
+ "closeSessionOnResultEnabled": this.closeSessionOnResultEnabled,
138
+ "imageResultEnabled": this.imageResultEnabled,
139
+ "locationInImageResultEnabled": this.locationInImageResultEnabled,
140
+ "locationInPreviewEnabled": this.locationInPreviewEnabled,
141
+ "pinchToZoomEnabled": this.pinchToZoomEnabled,
142
+ "regionOfInterestVisible": this.regionOfInterestVisible,
143
+ "barkoderResolution": this.barkoderResolution,
144
+ "beepOnSuccessEnabled": this.beepOnSuccessEnabled,
145
+ "vibrateOnSuccessEnabled": this.vibrateOnSuccessEnabled,
146
+ "decoder": this.decoder.toMap()
147
+ };
148
+
149
+ return JSON.stringify(configAsJson);
150
+ }
151
+ }
152
+
153
+
154
+
155
+ export class DekoderConfig {
156
+ aztec?: BarcodeConfig;
157
+ aztecCompact?: BarcodeConfig;
158
+ qr?: BarcodeConfig;
159
+ qrMicro?: BarcodeConfig;
160
+ code128?: BarcodeConfigWithLength;
161
+ code93?: BarcodeConfigWithLength;
162
+ code39?: Code39BarcodeConfig;
163
+ codabar?: BarcodeConfigWithLength;
164
+ code11?: Code11BarcodeConfig;
165
+ msi?: MSIBarcodeConfig;
166
+ upcA?: BarcodeConfig;
167
+ upcE?: BarcodeConfig;
168
+ upcE1?: BarcodeConfig;
169
+ ean13?: BarcodeConfig;
170
+ ean8?: BarcodeConfig;
171
+ pdf417?: BarcodeConfig;
172
+ pdf417Micro?: BarcodeConfig;
173
+ datamatrix?: DatamatrixBarcodeConfig;
174
+ code25?: BarcodeConfig;
175
+ interleaved25?: BarcodeConfig;
176
+ itf14?: BarcodeConfig;
177
+ iata25?: BarcodeConfig;
178
+ matrix25?: BarcodeConfig;
179
+ datalogic25?: BarcodeConfig;
180
+ coop25?: BarcodeConfig;
181
+ code32?: BarcodeConfig;
182
+ telepen?: BarcodeConfig;
183
+ dotcode?: BarcodeConfig;
184
+ general?: GeneralSettings;
185
+
186
+ constructor(config: Partial<DekoderConfig>) {
187
+ Object.assign(this, config);
188
+ }
189
+
190
+ toMap() {
191
+ const map = {
192
+ 'Aztec': this.aztec?.toMap(),
193
+ 'Aztec Compact': this.aztecCompact?.toMap(),
194
+ 'QR': this.qr?.toMap(),
195
+ 'QR Micro': this.qrMicro?.toMap(),
196
+ 'Code 128': this.code128?.toMap(),
197
+ 'Code 93': this.code93?.toMap(),
198
+ 'Code 39': this.code39?.toMap(),
199
+ 'Codabar': this.codabar?.toMap(),
200
+ 'Code 11': this.code11?.toMap(),
201
+ 'MSI': this.msi?.toMap(),
202
+ 'Upc-A': this.upcA?.toMap(),
203
+ 'Upc-E': this.upcE?.toMap(),
204
+ 'Upc-E1': this.upcE1?.toMap(),
205
+ 'Ean-13': this.ean13?.toMap(),
206
+ 'Ean-8': this.ean8?.toMap(),
207
+ 'PDF 417': this.pdf417?.toMap(),
208
+ 'PDF 417 Micro': this.pdf417Micro?.toMap(),
209
+ 'Datamatrix': this.datamatrix?.toMap(),
210
+ 'Code 25': this.code25?.toMap(),
211
+ 'Interleaved 2 of 5': this.interleaved25?.toMap(),
212
+ 'ITF 14': this.itf14?.toMap(),
213
+ 'IATA 25': this.iata25?.toMap(),
214
+ 'Matrix 25': this.matrix25?.toMap(),
215
+ 'Datalogic 25': this.datalogic25?.toMap(),
216
+ 'COOP 25': this.coop25?.toMap(),
217
+ 'Code 32': this.code32?.toMap(),
218
+ 'Telepen': this.telepen?.toMap(),
219
+ 'Dotcode': this.dotcode?.toMap(),
220
+ 'general': this.general?.toMap()
221
+ }
222
+
223
+ return map;
224
+ }
225
+ }
226
+
227
+ export class BarcodeConfig {
228
+ enabled?: boolean;
229
+
230
+ constructor(config: Partial<BarcodeConfig>) {
231
+ Object.assign(this, config);
232
+ }
233
+
234
+ toMap() {
235
+ const map = {
236
+ "enabled": this.enabled
237
+ }
238
+
239
+ return map;
240
+ }
241
+ }
242
+
243
+ export class BarcodeConfigWithLength {
244
+ enabled?: boolean;
245
+ private minLength?: number;
246
+ private maxLength?: number;
247
+
248
+ constructor(config: Partial<BarcodeConfigWithLength>) {
249
+ Object.assign(this, config);
250
+ }
251
+
252
+ toMap() {
253
+ const map = {
254
+ "enabled": this.enabled,
255
+ "minimumLength": this.minLength,
256
+ "maximumLength": this.maxLength
257
+ }
258
+
259
+ return map;
260
+ }
261
+
262
+ setLengthRange(minLength: number, maxLength: number) {
263
+ this.minLength = minLength;
264
+ this.maxLength = maxLength;
265
+ }
266
+ }
267
+
268
+ export class MSIBarcodeConfig {
269
+ enabled?: boolean;
270
+ private minLength?: number;
271
+ private maxLength?: number;
272
+ checksum?: MsiCheckSumType;
273
+
274
+ constructor(config: Partial<MSIBarcodeConfig>) {
275
+ Object.assign(this, config);
276
+ }
277
+
278
+ toMap() {
279
+ let map: { [key: string]: any } = {
280
+ "enabled": this.enabled,
281
+ "minimumLength": this.minLength,
282
+ "maximumLength": this.maxLength,
283
+ "checksum": this.checksum
284
+ }
285
+
286
+ return map;
287
+ }
288
+
289
+ setLengthRange(minLength: number, maxLength: number) {
290
+ this.minLength = minLength;
291
+ this.maxLength = maxLength;
292
+ }
293
+ }
294
+
295
+ export class Code39BarcodeConfig {
296
+ enabled?: boolean;
297
+ private minLength?: number;
298
+ private maxLength?: number;
299
+ checksum?: Code39CheckSumType;
300
+
301
+ constructor(config: Partial<Code39BarcodeConfig>) {
302
+ Object.assign(this, config);
303
+ }
304
+
305
+ toMap() {
306
+ let map: { [key: string]: any } = {
307
+ "enabled": this.enabled,
308
+ "minimumLength": this.minLength,
309
+ "maximumLength": this.maxLength,
310
+ "checksum": this.checksum
311
+ }
312
+
313
+ return map;
314
+ }
315
+
316
+ setLengthRange(minLength: number, maxLength: number) {
317
+ this.minLength = minLength;
318
+ this.maxLength = maxLength;
319
+ }
320
+ }
321
+
322
+ export class Code11BarcodeConfig {
323
+ enabled?: boolean;
324
+ private minLength?: number;
325
+ private maxLength?: number;
326
+ checksum?: Code11CheckSumType;
327
+
328
+ constructor(config: Partial<Code11BarcodeConfig>) {
329
+ Object.assign(this, config);
330
+ }
331
+
332
+ toMap() {
333
+ let map: { [key: string]: any } = {
334
+ "enabled": this.enabled,
335
+ "minimumLength": this.minLength,
336
+ "maximumLength": this.maxLength,
337
+ "checksum": this.checksum
338
+ }
339
+
340
+ return map;
341
+ }
342
+
343
+ setLengthRange(minLength: number, maxLength: number) {
344
+ this.minLength = minLength;
345
+ this.maxLength = maxLength;
346
+ }
347
+ }
348
+
349
+ export class DatamatrixBarcodeConfig {
350
+ enabled?: boolean;
351
+ dpmMode?: number;
352
+ private minLength?: number;
353
+ private maxLength?: number;
354
+
355
+ constructor(config: Partial<DatamatrixBarcodeConfig>) {
356
+ Object.assign(this, config);
357
+ }
358
+
359
+ toMap() {
360
+ let map: { [key: string]: any } = {
361
+ "enabled": this.enabled,
362
+ "dpmMode": this.dpmMode,
363
+ "minimumLength": this.minLength,
364
+ "maximumLength": this.maxLength,
365
+ }
366
+
367
+ return map;
368
+ }
369
+
370
+ setLengthRange(minLength: number, maxLength: number) {
371
+ this.minLength = minLength;
372
+ this.maxLength = maxLength;
373
+ }
374
+ }
375
+
376
+ export class GeneralSettings {
377
+ threadsLimit?: number;
378
+ decodingSpeed?: DecodingSpeed;
379
+ roiX?: number;
380
+ roiY?: number;
381
+ roiWidth?: number;
382
+ roiHeight?: number;
383
+ formattingType?: FormattingType;
384
+ encodingCharacterSet?: string;
385
+ upcEanDeblur?: number;
386
+ enableMisshaped1D? : number;
387
+
388
+ constructor(config: Partial<GeneralSettings>) {
389
+ Object.assign(this, config);
390
+ }
391
+
392
+ toMap() {
393
+ let map: { [key: string]: any } = {
394
+ "maxThreads": this.threadsLimit,
395
+ "decodingSpeed": this.decodingSpeed,
396
+ "roi_x": this.roiX,
397
+ "roi_y": this.roiY,
398
+ "roi_w": this.roiWidth,
399
+ "roi_h": this.roiHeight,
400
+ "formattingType": this.formattingType,
401
+ "encodingCharacterSet": this.encodingCharacterSet,
402
+ "upcEanDeblur": this.upcEanDeblur,
403
+ "enableMisshaped1D": this.enableMisshaped1D
404
+ }
405
+
406
+ return map;
407
+ }
408
+
409
+ setROI(x: number, y: number, width: number, height: number) {
410
+ this.roiX = x;
411
+ this.roiY = y;
412
+ this.roiWidth = width;
413
+ this.roiHeight = height;
414
+ }
415
+ }
416
+
417
+ }
418
+
419
+
420
+
421
+
422
+
423
+
424
+
425
+
426
+
427
+
428
+
429
+
430
+
431
+