@pixelverse/strichjs-sdk 1.7.4 → 1.8.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/dist/strich.d.ts CHANGED
@@ -229,13 +229,6 @@ export declare interface EngineConfiguration {
229
229
  * @defaultValue false
230
230
  */
231
231
  invertedCodes?: boolean;
232
- /**
233
- * Time interval in milliseconds during which multiple detections of the same code are not repeated.
234
- *
235
- * @remarks It is recommended to set a duplicateInterval as scans are metered except in Enterprise subscriptions.
236
- * @defaultValue 750
237
- */
238
- duplicateInterval?: number;
239
232
  /**
240
233
  * Set the minimum occurrence count for 1D barcodes with weak checksums in a given time window for it be accepted.
241
234
  *
@@ -334,6 +327,71 @@ export declare interface FrameSourceConfiguration {
334
327
  constraints?: MediaStreamConstraints;
335
328
  }
336
329
 
330
+ /**
331
+ * Configuration object for {@link ImageScanner}.
332
+ *
333
+ * Specify which kind of 1D/2D barcodes should be detected using the
334
+ * {@link EngineConfiguration.symbologies} field.
335
+ *
336
+ * @example
337
+ * To read a QR Code from an image, use this configuration:
338
+ *
339
+ * ```javascript
340
+ * const cfg = {
341
+ * engine: { symbologies: ['qr'] }
342
+ * }
343
+ * ```
344
+ */
345
+ export declare interface ImageConfiguration {
346
+ /**
347
+ * Engine configuration
348
+ */
349
+ engine?: EngineConfiguration;
350
+ }
351
+
352
+ /**
353
+ * Scanner for static images, typically provided via an HTML input element.
354
+ *
355
+ * @remarks
356
+ * Make sure that the input image is sharp, and that the code to be scanned is in focus. Some images might not scan
357
+ * using ImageScanner, but can be scanned using camera-based scanning (BarcodeReader, PopupScanner). This is due to
358
+ * more frames being available for decoding, increasing the chances of getting a good quality sample.
359
+ *
360
+ * @example
361
+ * HTML:
362
+ * ```html
363
+ * <input id="image-input" type="file" accept="image/*" />
364
+ * ```
365
+ *
366
+ * JavaScript:
367
+ * ```javascript
368
+ * const imageInput = document.getElementById('image-input');
369
+ * imageInput.onchange = async () => {
370
+ * const detections = await ImageScanner.scan(image.files[0], {
371
+ * engine: { symbologies: ['qr'] }
372
+ * });
373
+ * }
374
+ * ```
375
+ */
376
+ export declare class ImageScanner {
377
+ /**
378
+ * Decode a barcode in a static image.
379
+ *
380
+ * @remarks
381
+ * By default, a single barcode is detected. In a future release, an option to detect multiple barcodes
382
+ * will be added.
383
+ *
384
+ * @param image - The image source, can be a HTMLImageElement, ImageData, ImageBitmap, File, Blob or a data URL.
385
+ * @param cfg - The engine configuration to use for barcode detection.
386
+ */
387
+ static scan(image: ImageSource, cfg: ImageConfiguration): Promise<CodeDetection[]>;
388
+ }
389
+
390
+ /**
391
+ * The types of image input {@link ImageScanner.scan} can process.
392
+ */
393
+ export declare type ImageSource = HTMLImageElement | ImageData | ImageBitmap | File | Blob | string;
394
+
337
395
  /**
338
396
  * Locator configuration
339
397
  */
@@ -713,6 +771,10 @@ export declare class SdkError extends Error {
713
771
  */
714
772
  detailMessage?: string;
715
773
  constructor(keyOrMessage: string, cause?: Error);
774
+ /**
775
+ * Create an SDK error with 'invalid input' semantics.
776
+ */
777
+ static invalidInputError(cause?: Error): SdkError;
716
778
  }
717
779
 
718
780
  /**