scandit-datacapture-frameworks-core 8.3.0-beta.1 → 8.3.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.
@@ -1,6 +1,6 @@
1
1
  import { loadCoreDefaults } from '../src';
2
2
 
3
- const mockCoreDefaultsData = {
3
+ export const mockCoreDefaultsData: any = {
4
4
  "Camera": {
5
5
  "defaultPosition": "worldFacing",
6
6
  "Settings": {
@@ -10,6 +10,11 @@ const mockCoreDefaultsData = {
10
10
  "focusRange": "near",
11
11
  "preferredResolution": "auto",
12
12
  "shouldPreferSmoothAutoFocus": false,
13
+ "torchLevel": 1,
14
+ "macroMode": "auto",
15
+ "adaptiveExposure": false,
16
+ "manualLensPosition": -1,
17
+ "focusStrategy": "auto",
13
18
  "properties": {}
14
19
  },
15
20
  "availablePositions": ["worldFacing", "userFacing"]
@@ -6,11 +6,14 @@ import { MacroMode } from "./MacroMode";
6
6
  export interface CameraSettingsJSON {
7
7
  preferredResolution: string;
8
8
  zoomFactor: number;
9
- focusRange: string;
10
9
  zoomGestureZoomFactor: number;
11
- focusGestureStrategy: string;
10
+ macroMode?: string;
11
+ adaptiveExposure?: boolean;
12
+ torchLevel?: number;
13
+ focusRange?: string;
14
+ focusGestureStrategy?: string;
12
15
  shouldPreferSmoothAutoFocus: boolean;
13
- properties: {
16
+ properties?: {
14
17
  [key: string]: any;
15
18
  };
16
19
  }
@@ -1,4 +1,4 @@
1
- import { StringSerializeable } from "../serializable";
1
+ import { StringSerializeable } from '../serializable';
2
2
  export type ColorJSON = string;
3
3
  export interface PrivateColor {
4
4
  fromJSON(json: ColorJSON): Color;
@@ -9,6 +9,8 @@ export interface CameraSettingsDefaults {
9
9
  zoomGestureZoomFactor: number;
10
10
  focusGestureStrategy: FocusGestureStrategy;
11
11
  shouldPreferSmoothAutoFocus: boolean;
12
+ manualLensPosition: number;
13
+ focusStrategy: string;
12
14
  torchLevel: number;
13
15
  macroMode: MacroMode;
14
16
  adaptiveExposure: boolean;
package/dist/index.js CHANGED
@@ -1279,8 +1279,7 @@ class Color {
1279
1279
  return new Color(Color.normalizeHex(hex));
1280
1280
  }
1281
1281
  static fromRGBA(red, green, blue, alpha = 1) {
1282
- const hexString = [red, green, blue, this.normalizeAlpha(alpha)]
1283
- .reduce((hex, colorComponent) => hex + this.numberToHex(colorComponent), '');
1282
+ const hexString = [red, green, blue, this.normalizeAlpha(alpha)].reduce((hex, colorComponent) => hex + this.numberToHex(colorComponent), '');
1284
1283
  return new Color(hexString);
1285
1284
  }
1286
1285
  static hexToNumber(hex) {
@@ -1304,13 +1303,16 @@ class Color {
1304
1303
  }
1305
1304
  // double digits if single digit
1306
1305
  if (hex.length < 6) {
1307
- hex = hex.split('').map(s => s + s).join('');
1306
+ hex = hex
1307
+ .split('')
1308
+ .map(s => s + s)
1309
+ .join('');
1308
1310
  }
1309
1311
  // add alpha if missing
1310
1312
  if (hex.length === 6) {
1311
1313
  hex = hex + 'FF';
1312
1314
  }
1313
- return '#' + hex.toUpperCase();
1315
+ return hex.toUpperCase();
1314
1316
  }
1315
1317
  static normalizeAlpha(alpha) {
1316
1318
  if (alpha > 0 && alpha <= 1) {
@@ -1326,7 +1328,7 @@ class Color {
1326
1328
  return Color.fromHex(newHex);
1327
1329
  }
1328
1330
  toJSON() {
1329
- return this.hexadecimalString;
1331
+ return '#' + this.hexadecimalString;
1330
1332
  }
1331
1333
  }
1332
1334
 
@@ -4358,13 +4360,19 @@ class CameraSettings extends DefaultSerializeable {
4358
4360
  this.focus.shouldPreferSmoothAutoFocus = newShouldPreferSmoothAutoFocus;
4359
4361
  }
4360
4362
  static fromJSON(json) {
4363
+ var _a, _b, _c;
4361
4364
  const settings = new CameraSettings();
4362
4365
  settings.preferredResolution = json.preferredResolution;
4363
4366
  settings.zoomFactor = json.zoomFactor;
4364
- settings.focusRange = json.focusRange;
4365
4367
  settings.zoomGestureZoomFactor = json.zoomGestureZoomFactor;
4368
+ settings.macroMode = ((_a = json.macroMode) !== null && _a !== void 0 ? _a : CameraSettings.coreDefaults.Camera.Settings.macroMode);
4369
+ settings.adaptiveExposure = (_b = json.adaptiveExposure) !== null && _b !== void 0 ? _b : CameraSettings.coreDefaults.Camera.Settings.adaptiveExposure;
4370
+ settings.torchLevel = (_c = json.torchLevel) !== null && _c !== void 0 ? _c : CameraSettings.coreDefaults.Camera.Settings.torchLevel;
4371
+ settings.focusRange = json.focusRange;
4366
4372
  settings.focusGestureStrategy = json.focusGestureStrategy;
4367
4373
  settings.shouldPreferSmoothAutoFocus = json.shouldPreferSmoothAutoFocus;
4374
+ // manualLensPosition, focusStrategy (and on iOS: range) arrive in the properties bag
4375
+ // and are routed to the focus bag by setProperty via focusHiddenProperties
4368
4376
  if (json.properties !== undefined) {
4369
4377
  for (const key of Object.keys(json.properties)) {
4370
4378
  settings.setProperty(key, json.properties[key]);
@@ -4373,7 +4381,7 @@ class CameraSettings extends DefaultSerializeable {
4373
4381
  return settings;
4374
4382
  }
4375
4383
  constructor(settings) {
4376
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
4384
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
4377
4385
  super();
4378
4386
  this.preferredResolution = CameraSettings.coreDefaults.Camera.Settings.preferredResolution;
4379
4387
  this.zoomFactor = CameraSettings.coreDefaults.Camera.Settings.zoomFactor;
@@ -4391,7 +4399,9 @@ class CameraSettings extends DefaultSerializeable {
4391
4399
  this.focus = {
4392
4400
  range: CameraSettings.coreDefaults.Camera.Settings.focusRange,
4393
4401
  focusGestureStrategy: CameraSettings.coreDefaults.Camera.Settings.focusGestureStrategy,
4394
- shouldPreferSmoothAutoFocus: CameraSettings.coreDefaults.Camera.Settings.shouldPreferSmoothAutoFocus
4402
+ shouldPreferSmoothAutoFocus: CameraSettings.coreDefaults.Camera.Settings.shouldPreferSmoothAutoFocus,
4403
+ manualLensPosition: CameraSettings.coreDefaults.Camera.Settings.manualLensPosition,
4404
+ focusStrategy: CameraSettings.coreDefaults.Camera.Settings.focusStrategy,
4395
4405
  };
4396
4406
  this.preferredResolution = (_a = settings === null || settings === void 0 ? void 0 : settings.preferredResolution) !== null && _a !== void 0 ? _a : CameraSettings.coreDefaults.Camera.Settings.preferredResolution;
4397
4407
  this.zoomFactor = (_b = settings === null || settings === void 0 ? void 0 : settings.zoomFactor) !== null && _b !== void 0 ? _b : CameraSettings.coreDefaults.Camera.Settings.zoomFactor;
@@ -4403,6 +4413,8 @@ class CameraSettings extends DefaultSerializeable {
4403
4413
  range: (_g = settings === null || settings === void 0 ? void 0 : settings.focusRange) !== null && _g !== void 0 ? _g : CameraSettings.coreDefaults.Camera.Settings.focusRange,
4404
4414
  focusGestureStrategy: (_h = settings === null || settings === void 0 ? void 0 : settings.focusGestureStrategy) !== null && _h !== void 0 ? _h : CameraSettings.coreDefaults.Camera.Settings.focusGestureStrategy,
4405
4415
  shouldPreferSmoothAutoFocus: (_j = settings === null || settings === void 0 ? void 0 : settings.shouldPreferSmoothAutoFocus) !== null && _j !== void 0 ? _j : CameraSettings.coreDefaults.Camera.Settings.shouldPreferSmoothAutoFocus,
4416
+ manualLensPosition: (_k = settings === null || settings === void 0 ? void 0 : settings.focus) === null || _k === void 0 ? void 0 : _k.manualLensPosition,
4417
+ focusStrategy: (_l = settings === null || settings === void 0 ? void 0 : settings.focus) === null || _l === void 0 ? void 0 : _l.focusStrategy,
4406
4418
  };
4407
4419
  if (settings !== undefined && settings !== null) {
4408
4420
  Object.getOwnPropertyNames(settings).forEach(propertyName => {
@@ -4608,7 +4620,7 @@ class LaserlineViewfinder extends DefaultSerializeable {
4608
4620
  }
4609
4621
 
4610
4622
  function parseDefaults(jsonDefaults) {
4611
- var _a, _b, _c;
4623
+ var _a, _b, _c, _d, _e;
4612
4624
  const coreDefaults = {
4613
4625
  Camera: {
4614
4626
  Settings: {
@@ -4621,6 +4633,8 @@ function parseDefaults(jsonDefaults) {
4621
4633
  torchLevel: (_a = jsonDefaults.Camera.Settings.torchLevel) !== null && _a !== void 0 ? _a : 1.0,
4622
4634
  macroMode: ((_b = jsonDefaults.Camera.Settings.macroMode) !== null && _b !== void 0 ? _b : 'auto'),
4623
4635
  adaptiveExposure: (_c = jsonDefaults.Camera.Settings.adaptiveExposure) !== null && _c !== void 0 ? _c : false,
4636
+ manualLensPosition: (_d = jsonDefaults.Camera.Settings.manualLensPosition) !== null && _d !== void 0 ? _d : 0,
4637
+ focusStrategy: (_e = jsonDefaults.Camera.Settings.focusStrategy) !== null && _e !== void 0 ? _e : 'auto',
4624
4638
  properties: jsonDefaults.Camera.Settings.properties,
4625
4639
  },
4626
4640
  defaultPosition: (jsonDefaults.Camera.defaultPosition || null),