@pixelverse/strichjs-sdk 1.3.4 → 1.4.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/CHANGELOG.md +17 -0
- package/dist/strich.d.ts +155 -57
- package/dist/strich.js +1 -1
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.4.0] - 2023-12-29
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- Fixed a performance issue that manifested itself on less powerful devices where the majority of processing time was spent on GPU->CPU buffer transfers, leading to up to 60% performance increase in some situations.
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
- `BarcodeReader.destroy()` now returns a Promise that resolves when the `BarcodeReader` and its resources are destroyed. The returned Promise is typically already resolved, unless `destroy()` is called while the BarcodeReader is being initialized, in which case the destruction happens after initialization completes. Previously, calling `destroy()` while `initialize()` was still pending caused a crash. Existing application code that calls `destroy()` does not need to be adapted.
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- Added basic overlay styling capabilities to overlay. The color of the viewfinder, camera selector control and flashlight icons can now be set via overlay configuration property `primaryColor`. The color of highlighted barcode detections can be set using `highlightColor`, and the `cornerRadius` property can be used to apply rounded corners to the viewfinder and camera selector control. The color of the targeting line when a linear barcode is detected can be set using `targetingLineActiveColor`. The defaults for all these properties match the previous hard-coded values, so if you are happy with the look & feel, you don't have to do anything.
|
|
16
|
+
- Added overlay configuration property `filterCameras` to control filtering of camera devices shown in camera selector. If set to true `true` (default), only back-facing camera devices are listed. If set to `false`, all camera devices available in the browser are listed.
|
|
17
|
+
- If a `BarcodeReader` could not be initialized due to missing browser capabilities like WebAssembly, WebGL or getUserMedia, mention the missing capability in the `detailMessage` property of the thrown `SdkError`.
|
|
18
|
+
- Report the detected code's location as a quadrilateral instead of an axis-aligned bounding box in the new `quadrilateral` property of the `CodeDetection`. The overlay will also use this more precise location for drawing the detections if `drawDetections` is enabled.
|
|
19
|
+
|
|
3
20
|
## [1.3.4] - 2023-11-28
|
|
4
21
|
|
|
5
22
|
### Fixed
|
package/dist/strich.d.ts
CHANGED
|
@@ -37,21 +37,23 @@ export interface FrameSourceConfiguration {
|
|
|
37
37
|
/**
|
|
38
38
|
* Video frame resolution.
|
|
39
39
|
*
|
|
40
|
+
* @remarks
|
|
40
41
|
* The default resolution is 720p, which is usually enough for good quality
|
|
41
42
|
* barcodes. You can try higher resolutions if you have very fine or
|
|
42
43
|
* degraded codes, at the expense of higher computational requirements.
|
|
43
44
|
*
|
|
44
|
-
* @
|
|
45
|
+
* @defaultValue hd
|
|
45
46
|
*/
|
|
46
47
|
resolution?: 'hd' | 'full-hd' | 'auto';
|
|
47
48
|
/**
|
|
48
49
|
* Remember the camera that was last used to successfully scan a code.
|
|
49
50
|
*
|
|
51
|
+
* @remarks
|
|
50
52
|
* If this is set to true, the frame source will remember the camera used
|
|
51
53
|
* whenever a code was successfully scanned, and attempt to use the same
|
|
52
54
|
* camera again when re-initialized.
|
|
53
55
|
*
|
|
54
|
-
* @
|
|
56
|
+
* @defaultValue false
|
|
55
57
|
*/
|
|
56
58
|
rememberCameraDeviceId?: boolean;
|
|
57
59
|
}
|
|
@@ -70,27 +72,27 @@ export function defaultFrameSourceConfiguration(): FrameSourceConfiguration;
|
|
|
70
72
|
*/
|
|
71
73
|
export interface RegionOfInterest {
|
|
72
74
|
/**
|
|
73
|
-
* Left inset, relative [0 .. 0.5]
|
|
75
|
+
* Left inset, relative [0 .. 0.5].
|
|
74
76
|
*
|
|
75
|
-
* @
|
|
77
|
+
* @example 0.1
|
|
76
78
|
*/
|
|
77
79
|
left: number;
|
|
78
80
|
/**
|
|
79
|
-
* Top inset, relative [0 .. 0.5]
|
|
81
|
+
* Top inset, relative [0 .. 0.5].
|
|
80
82
|
*
|
|
81
|
-
* @
|
|
83
|
+
* @example 0.25
|
|
82
84
|
*/
|
|
83
85
|
top: number;
|
|
84
86
|
/**
|
|
85
|
-
* Right inset, relative [0 .. 0.5]
|
|
87
|
+
* Right inset, relative [0 .. 0.5].
|
|
86
88
|
*
|
|
87
|
-
* @
|
|
89
|
+
* @example 0.1
|
|
88
90
|
*/
|
|
89
91
|
right: number;
|
|
90
92
|
/**
|
|
91
93
|
* Bottom inset, relative [0 .. 0.5]
|
|
92
94
|
*
|
|
93
|
-
* @
|
|
95
|
+
* @example 0.25
|
|
94
96
|
*/
|
|
95
97
|
bottom: number;
|
|
96
98
|
}
|
|
@@ -100,27 +102,33 @@ export interface RegionOfInterest {
|
|
|
100
102
|
export interface LocatorConfiguration {
|
|
101
103
|
/**
|
|
102
104
|
* The region of interest in viewport coordinates.
|
|
105
|
+
*
|
|
106
|
+
* @remarks if no region of interest is specified, an appropriate one will automatically be selected at run-time
|
|
107
|
+
* depending on the configured symbologies.
|
|
103
108
|
*/
|
|
104
109
|
regionOfInterest?: RegionOfInterest;
|
|
105
110
|
/**
|
|
106
|
-
* Disregard colorful areas,
|
|
107
|
-
* This is an advanced configuration option, use with care.
|
|
111
|
+
* Disregard colorful areas, assume barcodes are printed black on white.
|
|
108
112
|
*
|
|
109
|
-
* @
|
|
113
|
+
* @remarks This is an advanced setting and should normally not be changed.
|
|
114
|
+
* @defaultValue false
|
|
110
115
|
*/
|
|
111
116
|
chromaReject?: boolean;
|
|
112
117
|
/**
|
|
113
118
|
* The locator implementation to use. This should normally not be changed, unless it is specifically required
|
|
114
119
|
* to target WebGL 1.
|
|
115
120
|
*
|
|
116
|
-
* @
|
|
121
|
+
* @remarks This is an advanced setting and should normally not be changed, unless targeting WebGL1 and not
|
|
122
|
+
* WebGL2 is explicitly required.
|
|
123
|
+
* @defaultValue auto
|
|
117
124
|
*/
|
|
118
125
|
impl?: 'auto' | 'webgl1' | 'webgl2';
|
|
119
126
|
/**
|
|
120
|
-
*
|
|
121
|
-
* Some older iOS versions have issues with WebGL2 asynchronous readbacks.
|
|
127
|
+
* Disable asynchronous reads from GPU when using `webgl2` {@link impl}.
|
|
122
128
|
*
|
|
123
|
-
* @
|
|
129
|
+
* @remarks Some older iOS versions have issues with WebGL2 asynchronous reads. There is usually no need to change
|
|
130
|
+
* this setting from its default.
|
|
131
|
+
* @defaultValue false
|
|
124
132
|
*/
|
|
125
133
|
forceSyncReadback?: boolean;
|
|
126
134
|
}
|
|
@@ -152,63 +160,64 @@ export interface EngineConfiguration {
|
|
|
152
160
|
/**
|
|
153
161
|
* The enabled symbologies.
|
|
154
162
|
*
|
|
155
|
-
*
|
|
156
|
-
* your application.
|
|
157
|
-
*
|
|
163
|
+
* @remarks
|
|
164
|
+
* It is highly recommended to configure only the symbologies required by your application.
|
|
158
165
|
* An empty array or undefined is interpreted as 'all symbologies enabled'.
|
|
159
166
|
*
|
|
160
|
-
* @
|
|
167
|
+
* @example ['qr', 'code128']
|
|
168
|
+
*
|
|
169
|
+
* @default
|
|
170
|
+
* ```undefined```
|
|
171
|
+
* (all symbologies enabled - NOT RECOMMENDED)
|
|
161
172
|
*/
|
|
162
173
|
symbologies?: (SymbologyName | SymbologySpec)[];
|
|
163
174
|
/**
|
|
164
175
|
* The number of scanlines to run over a located barcode candidate.
|
|
165
176
|
*
|
|
166
|
-
* @
|
|
177
|
+
* @defaultValue 10
|
|
167
178
|
*/
|
|
168
179
|
numScanlines?: number;
|
|
169
180
|
/**
|
|
170
|
-
* The number of scanlines that need to
|
|
171
|
-
* decode.
|
|
181
|
+
* The number of scanlines that need to decoded successfully for a valid decode.
|
|
172
182
|
*
|
|
183
|
+
* @remarks
|
|
173
184
|
* Increasing this parameter reduces the possibility of a misread, but
|
|
174
185
|
* makes it more likely for degraded codes to not be read at all.
|
|
175
186
|
*
|
|
176
187
|
* The default value is two scanlines and usually should not be changed.
|
|
177
188
|
*
|
|
178
|
-
* @
|
|
189
|
+
* @defaultValue 2
|
|
179
190
|
*/
|
|
180
191
|
minScanlinesNeeded?: number;
|
|
181
192
|
/**
|
|
182
193
|
* Toggle recognition of inverted barcodes (light print on dark background).
|
|
183
194
|
*
|
|
184
|
-
* @
|
|
195
|
+
* @remarks
|
|
196
|
+
* This should only be enabled if you need to detect these barcodes, as additional processing will take place.
|
|
197
|
+
*
|
|
198
|
+
* @defaultValue false
|
|
185
199
|
*/
|
|
186
200
|
invertedCodes?: boolean;
|
|
187
201
|
/**
|
|
188
202
|
* Time interval in milliseconds during which multiple detections of the same code are not repeated.
|
|
189
203
|
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
* It is recommended to set a low duplicateInterval as scans are metered in non-Enterprise subscriptions.
|
|
204
|
+
* @remarks It is recommended to set a duplicateInterval as scans are metered except in Enterprise subscriptions.
|
|
205
|
+
* @defaultValue 750
|
|
193
206
|
*/
|
|
194
207
|
duplicateInterval?: number;
|
|
195
208
|
/**
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
* This parameter sets the minimum threshold for the number of detections of a barcode in the hysteresis
|
|
199
|
-
* window for it to be accepted.
|
|
209
|
+
* Set the minimum occurrence count for 1D barcodes with weak checksums in a given time window for it be accepted.
|
|
200
210
|
*
|
|
211
|
+
* @remarks
|
|
201
212
|
* Setting this parameter to 0 disables hysteresis (default behavior for versions <= 1.1.0)
|
|
202
213
|
*
|
|
203
|
-
* @
|
|
214
|
+
* @defaultValue 2
|
|
204
215
|
*/
|
|
205
216
|
hysteresisMinCount?: number;
|
|
206
217
|
/**
|
|
207
|
-
*
|
|
218
|
+
* Set the duration of the hysteresis window in milliseconds.
|
|
208
219
|
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
* @default 350
|
|
220
|
+
* @defaultValue 350
|
|
212
221
|
*/
|
|
213
222
|
hysteresisInterval?: number;
|
|
214
223
|
}
|
|
@@ -219,41 +228,113 @@ export interface OverlayConfiguration {
|
|
|
219
228
|
/**
|
|
220
229
|
* Indicate if a horizontal line should be drawn to aid in positioning 1D barcodes.
|
|
221
230
|
*
|
|
222
|
-
* @
|
|
231
|
+
* @defaultValue true
|
|
232
|
+
* @category Styling
|
|
223
233
|
*/
|
|
224
234
|
showTargetingLine?: boolean;
|
|
225
235
|
/**
|
|
226
236
|
* Indicate if the overlay should draw the bounding boxes of detected barcodes on top of the camera preview.
|
|
227
237
|
*
|
|
228
|
-
* @
|
|
238
|
+
* @defaultValue true
|
|
239
|
+
* @category Styling
|
|
229
240
|
*/
|
|
230
241
|
showDetections?: boolean;
|
|
231
242
|
/**
|
|
232
243
|
* Indicate if the camera selector should be shown in the overlay.
|
|
233
244
|
*
|
|
234
|
-
* @
|
|
245
|
+
* @defaultValue true
|
|
246
|
+
* @category Interaction
|
|
235
247
|
*/
|
|
236
248
|
showCameraSelector?: boolean;
|
|
237
249
|
/**
|
|
238
|
-
*
|
|
250
|
+
* Filter cameras returned by the browser.
|
|
239
251
|
*
|
|
240
|
-
*
|
|
252
|
+
* If set to true, only cameras that are deemed appropriate for barcode scanning will be
|
|
253
|
+
* offered in the camera selector.
|
|
241
254
|
*
|
|
242
|
-
* @
|
|
255
|
+
* @defaultValue true
|
|
256
|
+
* @category Interaction
|
|
257
|
+
*/
|
|
258
|
+
filterCameras?: boolean;
|
|
259
|
+
/**
|
|
260
|
+
* Indicate if the flashlight toggle should be shown in the overlay.
|
|
261
|
+
*
|
|
262
|
+
* @remarks Flashlight functionality is not supported in some browsers.
|
|
263
|
+
* @defaultValue true
|
|
264
|
+
* @category Interaction
|
|
243
265
|
*/
|
|
244
266
|
showFlashlight?: boolean;
|
|
245
267
|
/**
|
|
246
|
-
*
|
|
268
|
+
* Indicate if single-tapping the overlay should attempt to trigger autofocus.
|
|
269
|
+
*
|
|
270
|
+
* @remarks Triggering autofocus is currently only available on Android devices.
|
|
271
|
+
* @defaultValue true
|
|
272
|
+
* @category Interaction
|
|
247
273
|
*/
|
|
248
274
|
focusOnTap?: boolean;
|
|
275
|
+
/**
|
|
276
|
+
* Color to use for drawing UI elements such as the view finder and camera selector. Must be specified in rgb()
|
|
277
|
+
* format, with the color components given as integers with no separating whitespace.
|
|
278
|
+
*
|
|
279
|
+
* @defaultValue rgb(255,255,255)
|
|
280
|
+
* @category Styling
|
|
281
|
+
*/
|
|
282
|
+
primaryColor?: string;
|
|
283
|
+
/**
|
|
284
|
+
* Color to use for filling area of detected barcodes. Must be specified in rgb() format, with the color
|
|
285
|
+
* components given as integers with no separating whitespace. The fill will become transparent when the
|
|
286
|
+
* detection becomes stale.
|
|
287
|
+
*
|
|
288
|
+
* @remarks Only has an effect if {@link showDetections} is true.
|
|
289
|
+
* @defaultValue rgb(0,0,255)
|
|
290
|
+
* @category Styling
|
|
291
|
+
*/
|
|
292
|
+
detectionFillColor?: string;
|
|
293
|
+
/**
|
|
294
|
+
* Color to use for drawing a border around the area of detected barcodes. Must be specified in rgb() format,
|
|
295
|
+
* with the color components given as integers with no separating whitespace. The border will become transparent
|
|
296
|
+
* when the detection becomes stale.
|
|
297
|
+
*
|
|
298
|
+
* @remarks Only has an effect if {@link showDetections} is true.
|
|
299
|
+
* @defaultValue undefined
|
|
300
|
+
* @category Styling
|
|
301
|
+
*/
|
|
302
|
+
detectionBorderColor?: string;
|
|
303
|
+
/**
|
|
304
|
+
* The border width in pixels to use for drawing a border around the area of detected barcodes.
|
|
305
|
+
*
|
|
306
|
+
* @remarks
|
|
307
|
+
* The allowed range is 0 to 4 pixels. Values outside the range are clamped.
|
|
308
|
+
*
|
|
309
|
+
* @defaultValue 0
|
|
310
|
+
* @category Styling
|
|
311
|
+
*/
|
|
312
|
+
detectionBorderWidth?: number;
|
|
313
|
+
/**
|
|
314
|
+
* Color to use for drawing the horizontal targeting line when a barcode was detected.
|
|
315
|
+
* Must be specified in rgb() format, with the color components given as integers with no separating whitespace.
|
|
316
|
+
*
|
|
317
|
+
* @defaultvalue rgb(255,0,0)
|
|
318
|
+
* @category Styling
|
|
319
|
+
*/
|
|
320
|
+
targetingLineActiveColor?: string;
|
|
321
|
+
/**
|
|
322
|
+
* Corner radius in pixels for rectangular elements such as view finder and camera selector.
|
|
323
|
+
*
|
|
324
|
+
* The allowed range of the corner radius is 0 to 8 pixels.
|
|
325
|
+
*
|
|
326
|
+
* @defaultValue 0
|
|
327
|
+
* @category Styling
|
|
328
|
+
*/
|
|
329
|
+
cornerRadius?: number;
|
|
249
330
|
/**
|
|
250
331
|
* Override the STRICH logo displayed in the bottom-right corner with a custom image.
|
|
251
332
|
*
|
|
252
|
-
* The image is supplied as a URL (e.g. https://example.com/assets/overlay.png) or inline as a data URL
|
|
253
|
-
*
|
|
254
|
-
* recommended) and a recommended size of 140x30 pixels.
|
|
333
|
+
* The image is supplied as a URL (e.g. https://example.com/assets/overlay.png) or inline as a data URL. The image
|
|
334
|
+
* should have a transparent background (WebP or PNG format). The recommended size is 140x30 pixels.
|
|
255
335
|
*
|
|
256
|
-
* This is an enterprise-only capability.
|
|
336
|
+
* @remarks This is an enterprise-only capability.
|
|
337
|
+
* @category Styling
|
|
257
338
|
*/
|
|
258
339
|
customLogoSrc?: string;
|
|
259
340
|
}
|
|
@@ -262,15 +343,15 @@ export interface OverlayConfiguration {
|
|
|
262
343
|
*/
|
|
263
344
|
export interface FeedbackConfiguration {
|
|
264
345
|
/**
|
|
265
|
-
*
|
|
346
|
+
* Toggle audible beep upon successful scan.
|
|
266
347
|
*
|
|
267
|
-
* @
|
|
348
|
+
* @defaultValue true
|
|
268
349
|
*/
|
|
269
350
|
audio?: boolean;
|
|
270
351
|
/**
|
|
271
|
-
*
|
|
352
|
+
* Toggle vibration upon successful scan, if supported by device.
|
|
272
353
|
*
|
|
273
|
-
* @
|
|
354
|
+
* @defaultValue true
|
|
274
355
|
*/
|
|
275
356
|
vibration?: boolean;
|
|
276
357
|
}
|
|
@@ -279,16 +360,16 @@ export interface FeedbackConfiguration {
|
|
|
279
360
|
*/
|
|
280
361
|
export interface Configuration {
|
|
281
362
|
/**
|
|
282
|
-
* CSS Selector or reference to the HTML element that will host the visible elements of
|
|
283
|
-
* the BarcodeReader.
|
|
363
|
+
* CSS Selector or reference to the HTML element that will host the visible elements of the BarcodeReader.
|
|
284
364
|
*
|
|
285
|
-
*
|
|
365
|
+
* @remarks
|
|
366
|
+
* When using a selector, make sure the selector only matches a single element, e.g. by using an ID.
|
|
286
367
|
*/
|
|
287
368
|
selector: string | HTMLElement;
|
|
288
369
|
/**
|
|
289
370
|
* Mode: can be 'immediate' (default) for always-on scanning, and 'touch', to only scan when a touch occurs.
|
|
290
371
|
*
|
|
291
|
-
* @
|
|
372
|
+
* @defaultValue immediate
|
|
292
373
|
*/
|
|
293
374
|
mode?: 'immediate' | 'touch';
|
|
294
375
|
/**
|
|
@@ -353,6 +434,15 @@ export interface Rect {
|
|
|
353
434
|
*/
|
|
354
435
|
size: Size;
|
|
355
436
|
}
|
|
437
|
+
/**
|
|
438
|
+
* A non-intersecting polygon with four points.
|
|
439
|
+
*/
|
|
440
|
+
export interface Quadrilateral {
|
|
441
|
+
/**
|
|
442
|
+
* The 4 points forming the quadrilateral.
|
|
443
|
+
*/
|
|
444
|
+
points: Point[];
|
|
445
|
+
}
|
|
356
446
|
/**
|
|
357
447
|
* Before the STRICH SDK {@link BarcodeReader} can be used, a one-time initialization of the SDK must be performed.
|
|
358
448
|
*/
|
|
@@ -422,6 +512,12 @@ export interface CodeDetection {
|
|
|
422
512
|
* Note: this might not be precise, especially for 1D barcodes.
|
|
423
513
|
*/
|
|
424
514
|
boundingRect: Rect;
|
|
515
|
+
/**
|
|
516
|
+
* The quadrilateral in which the code was detected.
|
|
517
|
+
*
|
|
518
|
+
* For rotated or warped codes, this might contain a more precise location estimate than boundingRect.
|
|
519
|
+
*/
|
|
520
|
+
quadrilateral: Quadrilateral;
|
|
425
521
|
/**
|
|
426
522
|
* The time of detection.
|
|
427
523
|
*/
|
|
@@ -477,8 +573,10 @@ export class BarcodeReader {
|
|
|
477
573
|
*
|
|
478
574
|
* This will release all associated resources, and should be called whenever an application no longer needs to
|
|
479
575
|
* scan.
|
|
576
|
+
*
|
|
577
|
+
* @return Promise that resolves when the BarcodeReader and its associated resources are fully destroyed.
|
|
480
578
|
*/
|
|
481
|
-
destroy(): void
|
|
579
|
+
destroy(): Promise<void>;
|
|
482
580
|
/**
|
|
483
581
|
* Show/hide the BarcodeReader instance.
|
|
484
582
|
*
|