@pixelverse/strichjs-sdk 0.8.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/LICENSE +3 -0
- package/NOTICE +277 -0
- package/README.md +6 -0
- package/dist/strich.d.ts +440 -0
- package/dist/strich.js +3175 -0
- package/package.json +66 -0
package/dist/strich.d.ts
ADDED
|
@@ -0,0 +1,440 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encapsulation of a JWT-based license.
|
|
3
|
+
*
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
interface License {
|
|
7
|
+
iss: string;
|
|
8
|
+
sub: string;
|
|
9
|
+
iat: number;
|
|
10
|
+
nbf: number;
|
|
11
|
+
aud: string[];
|
|
12
|
+
exp?: number;
|
|
13
|
+
capabilities: {
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
};
|
|
16
|
+
version: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* STRICH SDK error class
|
|
20
|
+
*/
|
|
21
|
+
export class SdkError extends Error {
|
|
22
|
+
/**
|
|
23
|
+
* Flag indicating if this error is related to camera access.
|
|
24
|
+
*/
|
|
25
|
+
duringCameraAccess: boolean;
|
|
26
|
+
constructor(message: string, cause?: Error);
|
|
27
|
+
/**
|
|
28
|
+
* Create an SDK error from a getUserMedia exception.
|
|
29
|
+
* See: https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#exceptions
|
|
30
|
+
*
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
static fromGetUserMediaError(err: Error): SdkError;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Configuration for the frame source (camera).
|
|
37
|
+
*/
|
|
38
|
+
export interface FrameSourceConfiguration {
|
|
39
|
+
/**
|
|
40
|
+
* Video frame resolution.
|
|
41
|
+
*
|
|
42
|
+
* The default resolution is 720p, which is usually enough for good quality
|
|
43
|
+
* barcodes. You can try higher resolutions if you have very fine or
|
|
44
|
+
* degraded codes, at the expense of higher computational requirements.
|
|
45
|
+
*
|
|
46
|
+
* @default hd
|
|
47
|
+
*/
|
|
48
|
+
resolution?: 'hd' | 'full-hd' | 'auto';
|
|
49
|
+
/**
|
|
50
|
+
* Allow other properties (for internal purposes)
|
|
51
|
+
*/
|
|
52
|
+
[key: string]: unknown;
|
|
53
|
+
}
|
|
54
|
+
export function defaultFrameSourceConfiguration(): FrameSourceConfiguration;
|
|
55
|
+
/**
|
|
56
|
+
* The region of interest is specified as an inset between screen edge and RoE on each side,
|
|
57
|
+
* expressed as a fractional value (between 0 and 0.5).
|
|
58
|
+
*
|
|
59
|
+
* For instance, to have an area that occupies the middle 80% horizontal area and 50% vertical area, you would
|
|
60
|
+
* specify the region of interest as follows:
|
|
61
|
+
*
|
|
62
|
+
* ```json
|
|
63
|
+
* { left: 0.1, right: 0.1, top: 0.25, bottom: 0.25 }
|
|
64
|
+
* ```
|
|
65
|
+
* (10% width inset on each side, 25% height inset on each side)
|
|
66
|
+
*/
|
|
67
|
+
export interface RegionOfInterest {
|
|
68
|
+
/**
|
|
69
|
+
* Left inset, relative [0 .. 0.5]
|
|
70
|
+
*
|
|
71
|
+
* @default A default is selected at run-time depending on enabled symbologies.
|
|
72
|
+
*/
|
|
73
|
+
left: number;
|
|
74
|
+
/**
|
|
75
|
+
* Top inset, relative [0 .. 0.5]
|
|
76
|
+
*
|
|
77
|
+
* @default A default is selected at run-time depending on enabled symbologies.
|
|
78
|
+
*/
|
|
79
|
+
top: number;
|
|
80
|
+
/**
|
|
81
|
+
* Right inset, relative [0 .. 0.5]
|
|
82
|
+
*
|
|
83
|
+
* @default A default is selected at run-time depending on enabled symbologies.
|
|
84
|
+
*/
|
|
85
|
+
right: number;
|
|
86
|
+
/**
|
|
87
|
+
* Bottom inset, relative [0 .. 0.5]
|
|
88
|
+
*
|
|
89
|
+
* @default A default is selected at run-time depending on enabled symbologies.
|
|
90
|
+
*/
|
|
91
|
+
bottom: number;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Locator configuration
|
|
95
|
+
*/
|
|
96
|
+
export interface LocatorConfiguration {
|
|
97
|
+
/**
|
|
98
|
+
* The region of interest in viewport coordinates.
|
|
99
|
+
*/
|
|
100
|
+
regionOfInterest?: RegionOfInterest;
|
|
101
|
+
/**
|
|
102
|
+
* Disregard colorful areas, assumes that codes are printed black on white.
|
|
103
|
+
* This is an advanced configuration option, use with care.
|
|
104
|
+
*
|
|
105
|
+
* @default false
|
|
106
|
+
*/
|
|
107
|
+
chromaReject?: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Allow other properties (for internal purposes)
|
|
110
|
+
*
|
|
111
|
+
* @internal
|
|
112
|
+
*/
|
|
113
|
+
[key: string]: unknown;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* The supported symbologies.
|
|
117
|
+
*/
|
|
118
|
+
export type SymbologyName = 'ean13' | 'ean8' | 'upca' | 'upce' | 'databar' | 'databar-exp' | 'code39' | 'code93' | 'code128' | 'i25' | 'codabar' | 'qr' | 'aztec' | 'datamatrix';
|
|
119
|
+
/**
|
|
120
|
+
* Engine configuration
|
|
121
|
+
*/
|
|
122
|
+
export interface EngineConfiguration {
|
|
123
|
+
/**
|
|
124
|
+
* The enabled symbologies.
|
|
125
|
+
*
|
|
126
|
+
* It is highly recommended to configure only the symbologies required by
|
|
127
|
+
* your application.
|
|
128
|
+
*
|
|
129
|
+
* @default undefined (all symbologies enabled - NOT RECOMMENDED)
|
|
130
|
+
*/
|
|
131
|
+
symbologies?: SymbologyName[];
|
|
132
|
+
/**
|
|
133
|
+
* The number of scanlines to run over a located barcode candidate.
|
|
134
|
+
*
|
|
135
|
+
* @default 10
|
|
136
|
+
*/
|
|
137
|
+
numScanlines?: number;
|
|
138
|
+
/**
|
|
139
|
+
* The number of scanlines that need to decodd successfully for a valid
|
|
140
|
+
* decode.
|
|
141
|
+
*
|
|
142
|
+
* Increasing this parameter reduces the possibility of a misread, but
|
|
143
|
+
* makes it more likely for degraded codes to not be read at all.
|
|
144
|
+
*
|
|
145
|
+
* The default value is two scanlines and usually should not be changed.
|
|
146
|
+
*
|
|
147
|
+
* @default 2
|
|
148
|
+
*/
|
|
149
|
+
minScanlinesNeeded?: number;
|
|
150
|
+
/**
|
|
151
|
+
* Toggle fallback scanning.
|
|
152
|
+
*
|
|
153
|
+
* Enables additional scan passes if no barcodes were found in areas identified as candidates in the
|
|
154
|
+
* location process. Can help with obscured/low contrast barcodes, at the expension of minor additional
|
|
155
|
+
* complexity.
|
|
156
|
+
*
|
|
157
|
+
* @default true
|
|
158
|
+
* @internal
|
|
159
|
+
*/
|
|
160
|
+
fallbackScan?: boolean;
|
|
161
|
+
/**
|
|
162
|
+
* Toggle image preprocessing for 1D barcodes.
|
|
163
|
+
*
|
|
164
|
+
* Can help with degraded/damaged barcodes, at the expense of additional computational complexity.
|
|
165
|
+
*
|
|
166
|
+
* @default true
|
|
167
|
+
* @internal
|
|
168
|
+
*/
|
|
169
|
+
preProcess1D?: boolean;
|
|
170
|
+
/** @internal */
|
|
171
|
+
simple1DMode?: boolean;
|
|
172
|
+
/**
|
|
173
|
+
* Toggle recognition of inverted 2D codes (light on dark background).
|
|
174
|
+
* Currently, this is only supported for 2D codes.
|
|
175
|
+
*
|
|
176
|
+
* @default false
|
|
177
|
+
*/
|
|
178
|
+
invertedCodes?: boolean;
|
|
179
|
+
/**
|
|
180
|
+
* Time interval in milliseconds during which multiple detections of the same code are not repeated.
|
|
181
|
+
*
|
|
182
|
+
* The default behavior is to pass through detections as they are detected and not perform any filtering.
|
|
183
|
+
*
|
|
184
|
+
* It is recommended to set a low duplicateInterval as scans are metered in non-Enterprise subscriptions.
|
|
185
|
+
*/
|
|
186
|
+
duplicateInterval?: number;
|
|
187
|
+
/**
|
|
188
|
+
* Allow other properties (for internal purposes)
|
|
189
|
+
*
|
|
190
|
+
* @internal
|
|
191
|
+
*/
|
|
192
|
+
[key: string]: unknown;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Overlay configuration
|
|
196
|
+
*/
|
|
197
|
+
export interface OverlayConfiguration {
|
|
198
|
+
/**
|
|
199
|
+
* Indicate if a horizontal line should be drawn to aid in positioning 1D barcodes.
|
|
200
|
+
*
|
|
201
|
+
* @default true
|
|
202
|
+
*/
|
|
203
|
+
showTargetingLine?: boolean;
|
|
204
|
+
/**
|
|
205
|
+
* Indicate if the overlay should draw the bounding boxes of detected barcodes on top of the camera preview.
|
|
206
|
+
*
|
|
207
|
+
* @default true
|
|
208
|
+
*/
|
|
209
|
+
showDetections?: boolean;
|
|
210
|
+
/**
|
|
211
|
+
* Indicate if the camera selector should be shown in the overlay.
|
|
212
|
+
*
|
|
213
|
+
* @default true
|
|
214
|
+
*/
|
|
215
|
+
showCameraSelector?: boolean;
|
|
216
|
+
/**
|
|
217
|
+
* Indicate if the flashlight toggle should be shown in the overlay.
|
|
218
|
+
*
|
|
219
|
+
* Flashlight functionality is not supported in some browsers.
|
|
220
|
+
*
|
|
221
|
+
* @default true
|
|
222
|
+
*/
|
|
223
|
+
showFlashlight?: boolean;
|
|
224
|
+
/**
|
|
225
|
+
* Allow other properties (for internal purposes)
|
|
226
|
+
*
|
|
227
|
+
* @internal
|
|
228
|
+
*/
|
|
229
|
+
[key: string]: unknown;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* User feedback configuration
|
|
233
|
+
*/
|
|
234
|
+
export interface FeedbackConfiguration {
|
|
235
|
+
/**
|
|
236
|
+
* If true, an audible beep will be emitted upon successful scan.
|
|
237
|
+
*
|
|
238
|
+
* @default true
|
|
239
|
+
*/
|
|
240
|
+
audio?: boolean;
|
|
241
|
+
/**
|
|
242
|
+
* If true, a vibration will be emitted upon successful scan (where supported by device).
|
|
243
|
+
*
|
|
244
|
+
* @default true
|
|
245
|
+
*/
|
|
246
|
+
vibration?: boolean;
|
|
247
|
+
/**
|
|
248
|
+
* Allow other properties (for internal purposes)
|
|
249
|
+
*
|
|
250
|
+
* @internal
|
|
251
|
+
*/
|
|
252
|
+
[key: string]: unknown;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* BarcodeReader configuration object.
|
|
256
|
+
*/
|
|
257
|
+
export interface Configuration {
|
|
258
|
+
/**
|
|
259
|
+
* CSS Selector referencing an element that will host the visible elements of
|
|
260
|
+
* the BarcodeReader.
|
|
261
|
+
*
|
|
262
|
+
* Make sure the selector only matches a single element.
|
|
263
|
+
*/
|
|
264
|
+
selector: string;
|
|
265
|
+
/**
|
|
266
|
+
* Mode: can be 'immediate' (default) for always-on scanning, and 'touch', to only scan when a touch occurs.
|
|
267
|
+
*
|
|
268
|
+
* @default immediate
|
|
269
|
+
*/
|
|
270
|
+
mode?: 'immediate' | 'touch';
|
|
271
|
+
/**
|
|
272
|
+
* Frame source configuration
|
|
273
|
+
*/
|
|
274
|
+
frameSource?: FrameSourceConfiguration;
|
|
275
|
+
/**
|
|
276
|
+
* Locator configuration
|
|
277
|
+
*/
|
|
278
|
+
locator?: LocatorConfiguration;
|
|
279
|
+
/**
|
|
280
|
+
* Engine configuration
|
|
281
|
+
*/
|
|
282
|
+
engine?: EngineConfiguration;
|
|
283
|
+
/**
|
|
284
|
+
* Overlay configuration
|
|
285
|
+
*/
|
|
286
|
+
overlay?: OverlayConfiguration;
|
|
287
|
+
/**
|
|
288
|
+
* Feedback configuration
|
|
289
|
+
*/
|
|
290
|
+
feedback?: FeedbackConfiguration;
|
|
291
|
+
/**
|
|
292
|
+
* Allow other properties (for internal purposes)
|
|
293
|
+
*
|
|
294
|
+
* @internal
|
|
295
|
+
*/
|
|
296
|
+
[key: string]: unknown;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* A point in two-dimensional space.
|
|
300
|
+
*
|
|
301
|
+
* The y coordinate origin starts at the top.
|
|
302
|
+
*/
|
|
303
|
+
export interface Point {
|
|
304
|
+
x: number;
|
|
305
|
+
y: number;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* The size of a bounding box, represented by its width and height.
|
|
309
|
+
*/
|
|
310
|
+
export interface Size {
|
|
311
|
+
width: number;
|
|
312
|
+
height: number;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* An axis-aligned rectangle in two-dimensional space.
|
|
316
|
+
*/
|
|
317
|
+
export interface Rect {
|
|
318
|
+
/**
|
|
319
|
+
* The origin of the rectangle.
|
|
320
|
+
*/
|
|
321
|
+
origin: Point;
|
|
322
|
+
/**
|
|
323
|
+
* The size of the rectangle.
|
|
324
|
+
*/
|
|
325
|
+
size: Size;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Before the STRICH SDK {@link BarcodeReader} can be used, a one-time initialization of the SDK must be performed.
|
|
329
|
+
*/
|
|
330
|
+
export class StrichSDK {
|
|
331
|
+
/** @internal */
|
|
332
|
+
static license: License;
|
|
333
|
+
/** @internal */
|
|
334
|
+
static deviceId: string | null;
|
|
335
|
+
/** @internal */
|
|
336
|
+
static customId: string | null;
|
|
337
|
+
/**
|
|
338
|
+
* Return the version of the STRICH SDK.
|
|
339
|
+
*/
|
|
340
|
+
static version(): string;
|
|
341
|
+
/**
|
|
342
|
+
* Return true if the SDK was successfully initialized, false otherwise.
|
|
343
|
+
*/
|
|
344
|
+
static isInitialized(): boolean;
|
|
345
|
+
/**
|
|
346
|
+
* One-time initialization of the SDK.
|
|
347
|
+
*
|
|
348
|
+
* @param licenseKey The license key obtained from the Customer Portal.
|
|
349
|
+
*/
|
|
350
|
+
static initialize(licenseKey: string): Promise<void>;
|
|
351
|
+
/**
|
|
352
|
+
* Set custom ID for analytics.
|
|
353
|
+
*
|
|
354
|
+
* The custom ID is independent of the device ID, and can be used for machine identifiers, user identifiers or any
|
|
355
|
+
* other identifiers.
|
|
356
|
+
*
|
|
357
|
+
* If the custom ID includes user-identifying data, you are responsible for obtaining consent.
|
|
358
|
+
*
|
|
359
|
+
* @param customId The custom ID. Use `null` to unset the custom ID.
|
|
360
|
+
* @default No custom ID is set by default
|
|
361
|
+
*/
|
|
362
|
+
static setCustomId(customId: string | null): void;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* A code detection reported by the STRICH SDK.
|
|
366
|
+
*/
|
|
367
|
+
export interface CodeDetection {
|
|
368
|
+
/**
|
|
369
|
+
* The textual data contained in the code.
|
|
370
|
+
*/
|
|
371
|
+
data: string;
|
|
372
|
+
/**
|
|
373
|
+
* The type of detected code.
|
|
374
|
+
*/
|
|
375
|
+
typeName: string;
|
|
376
|
+
/**
|
|
377
|
+
* The bounding rectangle in which the code was detected.
|
|
378
|
+
*
|
|
379
|
+
* Note: this might not be precise, especially for 1D barcodes.
|
|
380
|
+
*/
|
|
381
|
+
boundingRect: Rect;
|
|
382
|
+
/**
|
|
383
|
+
* The time of detection.
|
|
384
|
+
*/
|
|
385
|
+
time: number;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* BarcodeReader is the primary interface of the STRICH SDK.
|
|
389
|
+
*/
|
|
390
|
+
export class BarcodeReader {
|
|
391
|
+
/**
|
|
392
|
+
* User-supplied barcode detection handler.
|
|
393
|
+
*
|
|
394
|
+
* This is a synchronous call, so further processing will not happen until the handler returns.
|
|
395
|
+
*/
|
|
396
|
+
detected?: (detections: CodeDetection[]) => (void);
|
|
397
|
+
/**
|
|
398
|
+
* Create a new BarcodeReader using a Configuration.
|
|
399
|
+
*
|
|
400
|
+
* @param configuration A configuration object.
|
|
401
|
+
*/
|
|
402
|
+
constructor(configuration: Configuration);
|
|
403
|
+
/**
|
|
404
|
+
* Initialize the BarcodeReader instance.
|
|
405
|
+
*
|
|
406
|
+
*
|
|
407
|
+
*
|
|
408
|
+
* @return A promise resolving to an initialized BarcodeReader instance, or an error object.
|
|
409
|
+
*/
|
|
410
|
+
initialize(): Promise<BarcodeReader>;
|
|
411
|
+
/**
|
|
412
|
+
* Start scanning for barcodes.
|
|
413
|
+
*/
|
|
414
|
+
start(): Promise<void>;
|
|
415
|
+
/**
|
|
416
|
+
* Stop the BarcodeReader instance.
|
|
417
|
+
*
|
|
418
|
+
* This will temporarily suspend processing of camera frames / detection of codes.
|
|
419
|
+
*/
|
|
420
|
+
stop(): Promise<void>;
|
|
421
|
+
/**
|
|
422
|
+
* Destroy this BarcodeReader instance, making it unusable.
|
|
423
|
+
*
|
|
424
|
+
* This will release all associated resources, and should be called whenever an application no longer needs to
|
|
425
|
+
* scan.
|
|
426
|
+
*/
|
|
427
|
+
destroy(): void;
|
|
428
|
+
/**
|
|
429
|
+
* Show/hide the BarcodeReader instance.
|
|
430
|
+
*
|
|
431
|
+
* @param visible True/false for visible/hidden
|
|
432
|
+
*/
|
|
433
|
+
setVisible(visible: boolean): Promise<void>;
|
|
434
|
+
/**
|
|
435
|
+
* @return the current visibility of this BarcodeReader instance
|
|
436
|
+
*/
|
|
437
|
+
getVisible(): boolean;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
//# sourceMappingURL=strich.d.ts.map
|