scandit-capacitor-datacapture-core 8.5.2 → 8.6.0-beta.1
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/ScanditCapacitorDatacaptureCore.podspec +1 -1
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/scandit/capacitor/datacapture/core/handlers/DataCaptureViewHandler.java +7 -5
- package/android/src/main/java/com/scandit/capacitor/datacapture/core/utils/CapacitorExtensions.java +2 -3
- package/dist/core.js +471 -1
- package/dist/core.js.map +1 -1
- package/dist/dts/core.d.ts +2151 -0
- package/dist/dts/index.d.ts +116 -8
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/package.json +4 -7
- package/dist/dts/definitions.d.ts +0 -92
- package/dist/dts/ts/Capacitor/Capacitor.d.ts +0 -27
- package/dist/dts/ts/Capacitor/CommonCapacitor.d.ts +0 -14
- package/dist/dts/ts/Capacitor/CoreNativeCallerProvider.d.ts +0 -4
- package/dist/dts/ts/Capacitor/VolumeButtonObserverProxy.d.ts +0 -11
- package/dist/dts/ts/Capacitor/initProxy.d.ts +0 -1
- package/dist/dts/ts/DataCaptureVersion.d.ts +0 -3
- package/dist/dts/ts/DataCaptureView.d.ts +0 -65
- package/dist/dts/ts/VolumeButtonObserver.d.ts +0 -7
- package/dist/dts/web.d.ts +0 -6
package/android/build.gradle
CHANGED
|
@@ -9,6 +9,7 @@ package com.scandit.capacitor.datacapture.core.handlers;
|
|
|
9
9
|
import static com.scandit.capacitor.datacapture.core.utils.CapacitorExtensions.*;
|
|
10
10
|
|
|
11
11
|
import android.annotation.SuppressLint;
|
|
12
|
+
import android.content.Context;
|
|
12
13
|
import android.graphics.Color;
|
|
13
14
|
import android.os.Handler;
|
|
14
15
|
import android.os.Looper;
|
|
@@ -170,7 +171,7 @@ public class DataCaptureViewHandler {
|
|
|
170
171
|
if (imeHeight == lastKnownImeHeight) return;
|
|
171
172
|
lastKnownImeHeight = imeHeight;
|
|
172
173
|
|
|
173
|
-
int originalHeight = (int) pxFromDp(latestInfo.getHeight());
|
|
174
|
+
int originalHeight = (int) pxFromDp(latestInfo.getHeight(), dcView.getContext());
|
|
174
175
|
ViewGroup.LayoutParams params = dcView.getLayoutParams();
|
|
175
176
|
params.height =
|
|
176
177
|
imeHeight > 0 ? Math.max(0, originalHeight - imeHeight) : originalHeight;
|
|
@@ -280,13 +281,14 @@ public class DataCaptureViewHandler {
|
|
|
280
281
|
new Runnable() {
|
|
281
282
|
@Override
|
|
282
283
|
public void run() {
|
|
284
|
+
Context context = view.getContext();
|
|
283
285
|
view.setVisibility(isVisible ? View.VISIBLE : View.GONE);
|
|
284
|
-
view.setX(pxFromDp(latestInfo.getLeft()));
|
|
285
|
-
view.setY(pxFromDp(latestInfo.getTop()));
|
|
286
|
+
view.setX(pxFromDp(latestInfo.getLeft(), context));
|
|
287
|
+
view.setY(pxFromDp(latestInfo.getTop(), context));
|
|
286
288
|
ViewGroup.LayoutParams params = view.getLayoutParams();
|
|
287
|
-
params.width = (int) pxFromDp(latestInfo.getWidth());
|
|
289
|
+
params.width = (int) pxFromDp(latestInfo.getWidth(), context);
|
|
288
290
|
// Account for keyboard: if keyboard is open, reduce height.
|
|
289
|
-
int originalHeight = (int) pxFromDp(latestInfo.getHeight());
|
|
291
|
+
int originalHeight = (int) pxFromDp(latestInfo.getHeight(), context);
|
|
290
292
|
params.height =
|
|
291
293
|
lastKnownImeHeight > 0
|
|
292
294
|
? Math.max(0, originalHeight - lastKnownImeHeight)
|
package/android/src/main/java/com/scandit/capacitor/datacapture/core/utils/CapacitorExtensions.java
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
|
|
7
7
|
package com.scandit.capacitor.datacapture.core.utils;
|
|
8
8
|
|
|
9
|
+
import android.content.Context;
|
|
9
10
|
import android.view.View;
|
|
10
11
|
import android.view.ViewGroup;
|
|
11
|
-
import com.scandit.datacapture.core.internal.sdk.AppAndroidEnvironment;
|
|
12
12
|
|
|
13
13
|
public final class CapacitorExtensions {
|
|
14
14
|
|
|
@@ -16,8 +16,7 @@ public final class CapacitorExtensions {
|
|
|
16
16
|
// Private constructor to prevent instantiation
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
public static float pxFromDp(float dp) {
|
|
20
|
-
android.content.Context context = AppAndroidEnvironment.INSTANCE.getApplicationContext();
|
|
19
|
+
public static float pxFromDp(float dp, Context context) {
|
|
21
20
|
float displayDensity = context.getResources().getDisplayMetrics().density;
|
|
22
21
|
return (dp * displayDensity + 0.5f);
|
|
23
22
|
}
|
package/dist/core.js
CHANGED
|
@@ -1834,6 +1834,42 @@ class CoreProxyAdapter {
|
|
|
1834
1834
|
return result;
|
|
1835
1835
|
});
|
|
1836
1836
|
}
|
|
1837
|
+
/**
|
|
1838
|
+
* Adds an NV21 frame to the tracked sequence frame source with the given id
|
|
1839
|
+
* @param frameSourceId The id of the sequence frame source the frame is added to
|
|
1840
|
+
* @param width Frame width in pixels
|
|
1841
|
+
* @param height Frame height in pixels
|
|
1842
|
+
* @param frameData Base64-encoded NV21 frame bytes
|
|
1843
|
+
*/
|
|
1844
|
+
addFrameToSequenceFrameSource(_a) {
|
|
1845
|
+
return __awaiter(this, arguments, void 0, function* ({ frameSourceId, width, height, frameData, }) {
|
|
1846
|
+
const result = yield this.proxy.$executeCore({
|
|
1847
|
+
moduleName: 'CoreModule',
|
|
1848
|
+
methodName: 'addFrameToSequenceFrameSource',
|
|
1849
|
+
isEventRegistration: false,
|
|
1850
|
+
frameSourceId,
|
|
1851
|
+
width,
|
|
1852
|
+
height,
|
|
1853
|
+
frameData,
|
|
1854
|
+
});
|
|
1855
|
+
return result;
|
|
1856
|
+
});
|
|
1857
|
+
}
|
|
1858
|
+
/**
|
|
1859
|
+
* Returns the current state of the tracked sequence frame source with the given id
|
|
1860
|
+
* @param frameSourceId The id of the sequence frame source to get the state of
|
|
1861
|
+
*/
|
|
1862
|
+
getSequenceFrameSourceState(_a) {
|
|
1863
|
+
return __awaiter(this, arguments, void 0, function* ({ frameSourceId }) {
|
|
1864
|
+
const result = yield this.proxy.$executeCore({
|
|
1865
|
+
moduleName: 'CoreModule',
|
|
1866
|
+
methodName: 'getSequenceFrameSourceState',
|
|
1867
|
+
isEventRegistration: false,
|
|
1868
|
+
frameSourceId,
|
|
1869
|
+
});
|
|
1870
|
+
return JSON.parse(result.data);
|
|
1871
|
+
});
|
|
1872
|
+
}
|
|
1837
1873
|
/**
|
|
1838
1874
|
* Registers a persistent listener for torch state change events
|
|
1839
1875
|
*/
|
|
@@ -2511,6 +2547,26 @@ class DataCaptureContext extends DefaultSerializeable {
|
|
|
2511
2547
|
}
|
|
2512
2548
|
});
|
|
2513
2549
|
}
|
|
2550
|
+
/**
|
|
2551
|
+
* Mirror a frame-source change that already occurred on the native side (e.g. a
|
|
2552
|
+
* CameraSwitchControl tap handled by the native camera switcher, which swaps the context's
|
|
2553
|
+
* active camera on its own). Repoints the TS-side frame source and active-context pointers
|
|
2554
|
+
* WITHOUT re-serializing to native — native is already in this state, so calling
|
|
2555
|
+
* setFrameSource() would trigger a redundant, and failing, swap.
|
|
2556
|
+
*
|
|
2557
|
+
* Private on purpose: framework-internal callers (CameraSwitchControlController) reach it
|
|
2558
|
+
* through the PrivateDataCaptureContext cast, keeping it off the public SDK surface.
|
|
2559
|
+
*/
|
|
2560
|
+
adoptActiveFrameSource(frameSource) {
|
|
2561
|
+
if (this._frameSource === frameSource) {
|
|
2562
|
+
return;
|
|
2563
|
+
}
|
|
2564
|
+
if (this._frameSource) {
|
|
2565
|
+
this._frameSource.context = null;
|
|
2566
|
+
}
|
|
2567
|
+
this._frameSource = frameSource;
|
|
2568
|
+
frameSource.context = this;
|
|
2569
|
+
}
|
|
2514
2570
|
addListener(listener) {
|
|
2515
2571
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2516
2572
|
if (this.listeners.length === 0) {
|
|
@@ -3152,6 +3208,191 @@ __decorate([
|
|
|
3152
3208
|
ignoreFromSerialization
|
|
3153
3209
|
], ImageFrameSource.prototype, "controller", void 0);
|
|
3154
3210
|
|
|
3211
|
+
class SequenceFrameSourceController extends BaseController {
|
|
3212
|
+
constructor(sequenceFrameSource) {
|
|
3213
|
+
super('CoreProxy');
|
|
3214
|
+
this.handleDidChangeStateEventWrapper = (ev) => {
|
|
3215
|
+
return this.handleDidChangeStateEvent(ev);
|
|
3216
|
+
};
|
|
3217
|
+
this.sequenceFrameSource = sequenceFrameSource;
|
|
3218
|
+
this.adapter = new CoreProxyAdapter(this._proxy);
|
|
3219
|
+
void this.subscribeListener();
|
|
3220
|
+
}
|
|
3221
|
+
get privateSequenceFrameSource() {
|
|
3222
|
+
return this.sequenceFrameSource;
|
|
3223
|
+
}
|
|
3224
|
+
getCurrentState() {
|
|
3225
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3226
|
+
return yield this.adapter.getSequenceFrameSourceState({
|
|
3227
|
+
frameSourceId: this.privateSequenceFrameSource._id,
|
|
3228
|
+
});
|
|
3229
|
+
});
|
|
3230
|
+
}
|
|
3231
|
+
switchToDesiredState(desiredState) {
|
|
3232
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3233
|
+
yield this.adapter.switchCameraToDesiredState({
|
|
3234
|
+
stateJson: desiredState.toString(),
|
|
3235
|
+
});
|
|
3236
|
+
});
|
|
3237
|
+
}
|
|
3238
|
+
addFrame(width, height, frameData) {
|
|
3239
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3240
|
+
yield this.adapter.addFrameToSequenceFrameSource({
|
|
3241
|
+
frameSourceId: this.privateSequenceFrameSource._id,
|
|
3242
|
+
width,
|
|
3243
|
+
height,
|
|
3244
|
+
frameData,
|
|
3245
|
+
});
|
|
3246
|
+
});
|
|
3247
|
+
}
|
|
3248
|
+
subscribeListener() {
|
|
3249
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3250
|
+
yield this.adapter.registerFrameSourceListener();
|
|
3251
|
+
this._proxy.subscribeForEvents([FrameSourceListenerEvents.didChangeState]);
|
|
3252
|
+
this._proxy.eventEmitter.on(FrameSourceListenerEvents.didChangeState, this.handleDidChangeStateEventWrapper);
|
|
3253
|
+
});
|
|
3254
|
+
}
|
|
3255
|
+
unsubscribeListener() {
|
|
3256
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3257
|
+
yield this.adapter.unregisterFrameSourceListener();
|
|
3258
|
+
this._proxy.unsubscribeFromEvents([FrameSourceListenerEvents.didChangeState]);
|
|
3259
|
+
this._proxy.eventEmitter.off(FrameSourceListenerEvents.didChangeState, this.handleDidChangeStateEventWrapper);
|
|
3260
|
+
});
|
|
3261
|
+
}
|
|
3262
|
+
dispose() {
|
|
3263
|
+
void this.unsubscribeListener();
|
|
3264
|
+
this._proxy.dispose();
|
|
3265
|
+
}
|
|
3266
|
+
handleDidChangeStateEvent(ev) {
|
|
3267
|
+
const event = EventDataParser.parseIfShouldHandle(ev, {});
|
|
3268
|
+
if (event === SKIP) {
|
|
3269
|
+
return;
|
|
3270
|
+
}
|
|
3271
|
+
if (event === null) {
|
|
3272
|
+
console.error('SequenceFrameSourceController didChangeState payload is null');
|
|
3273
|
+
return;
|
|
3274
|
+
}
|
|
3275
|
+
const newState = event.state;
|
|
3276
|
+
this.privateSequenceFrameSource.listeners.forEach(listener => {
|
|
3277
|
+
if (listener.didChangeState) {
|
|
3278
|
+
listener.didChangeState(this.sequenceFrameSource, newState);
|
|
3279
|
+
}
|
|
3280
|
+
});
|
|
3281
|
+
}
|
|
3282
|
+
}
|
|
3283
|
+
|
|
3284
|
+
/**
|
|
3285
|
+
* A frame source that processes frames fed to it via {@link SequenceFrameSource.addFrame},
|
|
3286
|
+
* in the order they are added. Use it when the camera is not handled by the SDK (e.g. when
|
|
3287
|
+
* another framework owns the camera).
|
|
3288
|
+
*/
|
|
3289
|
+
class SequenceFrameSource extends DefaultSerializeable {
|
|
3290
|
+
set context(newContext) {
|
|
3291
|
+
if (newContext == null) {
|
|
3292
|
+
void this.controller.unsubscribeListener();
|
|
3293
|
+
}
|
|
3294
|
+
else if (this._context == null) {
|
|
3295
|
+
void this.controller.subscribeListener();
|
|
3296
|
+
}
|
|
3297
|
+
this._context = newContext;
|
|
3298
|
+
}
|
|
3299
|
+
get context() {
|
|
3300
|
+
return this._context;
|
|
3301
|
+
}
|
|
3302
|
+
get desiredState() {
|
|
3303
|
+
return this._desiredState;
|
|
3304
|
+
}
|
|
3305
|
+
/**
|
|
3306
|
+
* Creates a sequence frame source for the given camera position. On iOS the lens position
|
|
3307
|
+
* (0.0-1.0) sets the capture device lens position; on Android it is ignored.
|
|
3308
|
+
*/
|
|
3309
|
+
static create(position, lensPosition) {
|
|
3310
|
+
const sequenceFrameSource = new SequenceFrameSource();
|
|
3311
|
+
sequenceFrameSource.position = position;
|
|
3312
|
+
sequenceFrameSource._lensPosition = lensPosition !== null && lensPosition !== void 0 ? lensPosition : 1;
|
|
3313
|
+
return sequenceFrameSource;
|
|
3314
|
+
}
|
|
3315
|
+
static fromJSON(json) {
|
|
3316
|
+
return SequenceFrameSource.create(json.position, json.lensPosition);
|
|
3317
|
+
}
|
|
3318
|
+
constructor() {
|
|
3319
|
+
super();
|
|
3320
|
+
this.type = 'sequence';
|
|
3321
|
+
this._lensPosition = 1;
|
|
3322
|
+
this._id = `${Date.now()}-${SequenceFrameSource.nextInstanceId++}`;
|
|
3323
|
+
this._desiredState = FrameSourceState.Off;
|
|
3324
|
+
this.listeners = [];
|
|
3325
|
+
this._context = null;
|
|
3326
|
+
this.controller = new SequenceFrameSourceController(this);
|
|
3327
|
+
}
|
|
3328
|
+
switchToDesiredState(state) {
|
|
3329
|
+
this._desiredState = state;
|
|
3330
|
+
return this.controller.switchToDesiredState(state);
|
|
3331
|
+
}
|
|
3332
|
+
/**
|
|
3333
|
+
* Adds a frame with the given width and height. The frame data must be the Base64 encoding
|
|
3334
|
+
* of the raw NV21 bytes of the frame. If this frame source is on and connected to a
|
|
3335
|
+
* data capture context, this is the next frame that will be processed.
|
|
3336
|
+
*/
|
|
3337
|
+
addFrame(width, height, frameData) {
|
|
3338
|
+
return this.controller.addFrame(width, height, frameData);
|
|
3339
|
+
}
|
|
3340
|
+
addListener(listener) {
|
|
3341
|
+
if (listener == null) {
|
|
3342
|
+
return;
|
|
3343
|
+
}
|
|
3344
|
+
if (this.listeners.includes(listener)) {
|
|
3345
|
+
return;
|
|
3346
|
+
}
|
|
3347
|
+
this.listeners.push(listener);
|
|
3348
|
+
}
|
|
3349
|
+
removeListener(listener) {
|
|
3350
|
+
if (listener == null) {
|
|
3351
|
+
return;
|
|
3352
|
+
}
|
|
3353
|
+
if (!this.listeners.includes(listener)) {
|
|
3354
|
+
return;
|
|
3355
|
+
}
|
|
3356
|
+
this.listeners.splice(this.listeners.indexOf(listener), 1);
|
|
3357
|
+
}
|
|
3358
|
+
getCurrentState() {
|
|
3359
|
+
return this.controller.getCurrentState();
|
|
3360
|
+
}
|
|
3361
|
+
didChange() {
|
|
3362
|
+
if (this.context) {
|
|
3363
|
+
return this.context.update();
|
|
3364
|
+
}
|
|
3365
|
+
return Promise.resolve();
|
|
3366
|
+
}
|
|
3367
|
+
setNativeFrameSourceIsBeingCreated() {
|
|
3368
|
+
// SequenceFrameSource has no asynchronous native initialization step, so
|
|
3369
|
+
// there is nothing to track here. The method exists only to satisfy the
|
|
3370
|
+
// PrivateFrameSource contract that DataCaptureContext.setFrameSource()
|
|
3371
|
+
// invokes on every frame source.
|
|
3372
|
+
}
|
|
3373
|
+
}
|
|
3374
|
+
// The native handlers key their instance-reuse and addFrame routing on this id, so it must
|
|
3375
|
+
// be unique across instances — a timestamp alone can collide within the same millisecond.
|
|
3376
|
+
SequenceFrameSource.nextInstanceId = 0;
|
|
3377
|
+
__decorate([
|
|
3378
|
+
nameForSerialization('lensPosition')
|
|
3379
|
+
], SequenceFrameSource.prototype, "_lensPosition", void 0);
|
|
3380
|
+
__decorate([
|
|
3381
|
+
nameForSerialization('id')
|
|
3382
|
+
], SequenceFrameSource.prototype, "_id", void 0);
|
|
3383
|
+
__decorate([
|
|
3384
|
+
nameForSerialization('desiredState')
|
|
3385
|
+
], SequenceFrameSource.prototype, "_desiredState", void 0);
|
|
3386
|
+
__decorate([
|
|
3387
|
+
ignoreFromSerialization
|
|
3388
|
+
], SequenceFrameSource.prototype, "listeners", void 0);
|
|
3389
|
+
__decorate([
|
|
3390
|
+
ignoreFromSerialization
|
|
3391
|
+
], SequenceFrameSource.prototype, "_context", void 0);
|
|
3392
|
+
__decorate([
|
|
3393
|
+
ignoreFromSerialization
|
|
3394
|
+
], SequenceFrameSource.prototype, "controller", void 0);
|
|
3395
|
+
|
|
3155
3396
|
class PrivateFrameData {
|
|
3156
3397
|
get imageBuffers() {
|
|
3157
3398
|
return this._imageBuffers;
|
|
@@ -3188,6 +3429,86 @@ class PrivateFrameData {
|
|
|
3188
3429
|
}
|
|
3189
3430
|
}
|
|
3190
3431
|
|
|
3432
|
+
/**
|
|
3433
|
+
* Keeps the TS-side camera state in sync with the native camera switcher.
|
|
3434
|
+
*
|
|
3435
|
+
* The native `CameraSwitchControl` swaps the DataCaptureContext's active camera on its own when
|
|
3436
|
+
* tapped; the TS layer is never told, so `DataCaptureContext.frameSource` and the two cameras'
|
|
3437
|
+
* `_desiredState` drift out of sync (leading to "Unable to switch the camera" rejections when the
|
|
3438
|
+
* app later acts on a camera native no longer treats as active). This controller listens to the
|
|
3439
|
+
* frame-source state events (which carry the camera position) and repoints the TS state to mirror
|
|
3440
|
+
* the native switch — without issuing any native call, since native is already in that state.
|
|
3441
|
+
*/
|
|
3442
|
+
class CameraSwitchControlController extends BaseController {
|
|
3443
|
+
constructor(control) {
|
|
3444
|
+
super('CoreProxy');
|
|
3445
|
+
this.subscribed = false;
|
|
3446
|
+
// Arrow-function wrapper (matches CameraController) so `this` stays bound and always current.
|
|
3447
|
+
this.handleDidChangeStateWrapper = (ev) => {
|
|
3448
|
+
return this.handleDidChangeState(ev);
|
|
3449
|
+
};
|
|
3450
|
+
this.control = control;
|
|
3451
|
+
this.adapter = new CoreProxyAdapter(this._proxy);
|
|
3452
|
+
}
|
|
3453
|
+
subscribe() {
|
|
3454
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3455
|
+
if (this.subscribed) {
|
|
3456
|
+
return;
|
|
3457
|
+
}
|
|
3458
|
+
this.subscribed = true;
|
|
3459
|
+
yield this.adapter.registerFrameSourceListener();
|
|
3460
|
+
this._proxy.subscribeForEvents([FrameSourceListenerEvents.didChangeState]);
|
|
3461
|
+
this._proxy.eventEmitter.on(FrameSourceListenerEvents.didChangeState, this.handleDidChangeStateWrapper);
|
|
3462
|
+
});
|
|
3463
|
+
}
|
|
3464
|
+
unsubscribe() {
|
|
3465
|
+
if (!this.subscribed) {
|
|
3466
|
+
return;
|
|
3467
|
+
}
|
|
3468
|
+
this.subscribed = false;
|
|
3469
|
+
// Only detach our JS handler. We intentionally do NOT unregister the native frame-source
|
|
3470
|
+
// listener — the active camera's own CameraController may still depend on it.
|
|
3471
|
+
this._proxy.eventEmitter.off(FrameSourceListenerEvents.didChangeState, this.handleDidChangeStateWrapper);
|
|
3472
|
+
}
|
|
3473
|
+
handleDidChangeState(ev) {
|
|
3474
|
+
var _a;
|
|
3475
|
+
const event = EventDataParser.parseIfShouldHandle(ev, {});
|
|
3476
|
+
if (event === SKIP || event === null) {
|
|
3477
|
+
return;
|
|
3478
|
+
}
|
|
3479
|
+
// Only react when a camera reaches a STABLE up state (on/standby). Transition states
|
|
3480
|
+
// (starting, bootingUp, …) must never be written into `desiredState`: that field serializes
|
|
3481
|
+
// to native, whose state machine rejects transition values as a desired state
|
|
3482
|
+
// (BAR_REQUIRES(!isTransition(state)) in async_start_stop_state_machine.cc → abort).
|
|
3483
|
+
// The paired "off" event for the outgoing camera is likewise ignored.
|
|
3484
|
+
if (event.state !== FrameSourceState.On && event.state !== FrameSourceState.Standby) {
|
|
3485
|
+
return;
|
|
3486
|
+
}
|
|
3487
|
+
const context = (_a = this.control.attachedView) === null || _a === void 0 ? void 0 : _a.context;
|
|
3488
|
+
if (!context) {
|
|
3489
|
+
return;
|
|
3490
|
+
}
|
|
3491
|
+
const primary = this.control.primaryCamera;
|
|
3492
|
+
const secondary = this.control.secondaryCamera;
|
|
3493
|
+
const next = event.cameraPosition === primary.position
|
|
3494
|
+
? primary
|
|
3495
|
+
: event.cameraPosition === secondary.position
|
|
3496
|
+
? secondary
|
|
3497
|
+
: null;
|
|
3498
|
+
if (!next || context.frameSource === next) {
|
|
3499
|
+
return;
|
|
3500
|
+
}
|
|
3501
|
+
const previous = context.frameSource;
|
|
3502
|
+
context.adoptActiveFrameSource(next);
|
|
3503
|
+
next._desiredState = event.state;
|
|
3504
|
+
next.currentCameraState = event.state;
|
|
3505
|
+
if (previous) {
|
|
3506
|
+
previous._desiredState = FrameSourceState.Off;
|
|
3507
|
+
previous.currentCameraState = FrameSourceState.Off;
|
|
3508
|
+
}
|
|
3509
|
+
}
|
|
3510
|
+
}
|
|
3511
|
+
|
|
3191
3512
|
class FrameDataController extends BaseController {
|
|
3192
3513
|
constructor() {
|
|
3193
3514
|
super('CoreProxy');
|
|
@@ -4578,6 +4899,155 @@ __decorate([
|
|
|
4578
4899
|
nameForSerialization('accessibilityHintWhenOn')
|
|
4579
4900
|
], TorchSwitchControl.prototype, "accessibilityHintWhenOn", void 0);
|
|
4580
4901
|
|
|
4902
|
+
class CameraSwitchControl extends DefaultSerializeable {
|
|
4903
|
+
get view() {
|
|
4904
|
+
return this._view;
|
|
4905
|
+
}
|
|
4906
|
+
// Attaching to / detaching from a view is the lifecycle hook for keeping the TS camera state
|
|
4907
|
+
// in sync with the native camera switcher: subscribe while attached, unsubscribe when removed.
|
|
4908
|
+
set view(view) {
|
|
4909
|
+
var _a, _b;
|
|
4910
|
+
this._view = view;
|
|
4911
|
+
if (view) {
|
|
4912
|
+
this.controller = (_a = this.controller) !== null && _a !== void 0 ? _a : new CameraSwitchControlController(this);
|
|
4913
|
+
void this.controller.subscribe();
|
|
4914
|
+
}
|
|
4915
|
+
else {
|
|
4916
|
+
(_b = this.controller) === null || _b === void 0 ? void 0 : _b.unsubscribe();
|
|
4917
|
+
}
|
|
4918
|
+
}
|
|
4919
|
+
/** @internal Read-only view access for the sync controller. */
|
|
4920
|
+
get attachedView() {
|
|
4921
|
+
return this._view;
|
|
4922
|
+
}
|
|
4923
|
+
constructor(primaryCamera, secondaryCamera) {
|
|
4924
|
+
super();
|
|
4925
|
+
this.type = 'camera';
|
|
4926
|
+
this.icon = {
|
|
4927
|
+
primaryCamera: { default: null, pressed: null },
|
|
4928
|
+
secondaryCamera: { default: null, pressed: null },
|
|
4929
|
+
};
|
|
4930
|
+
this._view = null;
|
|
4931
|
+
this.controller = null;
|
|
4932
|
+
this.anchor = null;
|
|
4933
|
+
this.offset = null;
|
|
4934
|
+
this.accessibilityLabelWhenWorldFacing = null;
|
|
4935
|
+
this.accessibilityHintWhenWorldFacing = null;
|
|
4936
|
+
this.accessibilityLabelWhenUserFacing = null;
|
|
4937
|
+
this.accessibilityHintWhenUserFacing = null;
|
|
4938
|
+
this._primaryCamera = primaryCamera;
|
|
4939
|
+
this._secondaryCamera = secondaryCamera;
|
|
4940
|
+
}
|
|
4941
|
+
get primaryCamera() {
|
|
4942
|
+
return this._primaryCamera;
|
|
4943
|
+
}
|
|
4944
|
+
get secondaryCamera() {
|
|
4945
|
+
return this._secondaryCamera;
|
|
4946
|
+
}
|
|
4947
|
+
get primaryCameraImage() {
|
|
4948
|
+
var _a, _b;
|
|
4949
|
+
if (((_a = this.icon.primaryCamera.default) === null || _a === void 0 ? void 0 : _a.isBase64EncodedImage()) == true) {
|
|
4950
|
+
return (_b = this.icon.primaryCamera.default) === null || _b === void 0 ? void 0 : _b.data;
|
|
4951
|
+
}
|
|
4952
|
+
return null;
|
|
4953
|
+
}
|
|
4954
|
+
set primaryCameraImage(primaryCameraImage) {
|
|
4955
|
+
var _a;
|
|
4956
|
+
this.icon.primaryCamera.default = ControlImage.fromBase64EncodedImage(primaryCameraImage);
|
|
4957
|
+
void ((_a = this.view) === null || _a === void 0 ? void 0 : _a['controlUpdated']());
|
|
4958
|
+
}
|
|
4959
|
+
get primaryCameraPressedImage() {
|
|
4960
|
+
var _a, _b;
|
|
4961
|
+
if (((_a = this.icon.primaryCamera.pressed) === null || _a === void 0 ? void 0 : _a.isBase64EncodedImage()) == true) {
|
|
4962
|
+
return (_b = this.icon.primaryCamera.pressed) === null || _b === void 0 ? void 0 : _b.data;
|
|
4963
|
+
}
|
|
4964
|
+
return null;
|
|
4965
|
+
}
|
|
4966
|
+
set primaryCameraPressedImage(primaryCameraPressedImage) {
|
|
4967
|
+
var _a;
|
|
4968
|
+
this.icon.primaryCamera.pressed = ControlImage.fromBase64EncodedImage(primaryCameraPressedImage);
|
|
4969
|
+
void ((_a = this.view) === null || _a === void 0 ? void 0 : _a['controlUpdated']());
|
|
4970
|
+
}
|
|
4971
|
+
get secondaryCameraImage() {
|
|
4972
|
+
var _a, _b;
|
|
4973
|
+
if (((_a = this.icon.secondaryCamera.default) === null || _a === void 0 ? void 0 : _a.isBase64EncodedImage()) == true) {
|
|
4974
|
+
return (_b = this.icon.secondaryCamera.default) === null || _b === void 0 ? void 0 : _b.data;
|
|
4975
|
+
}
|
|
4976
|
+
return null;
|
|
4977
|
+
}
|
|
4978
|
+
set secondaryCameraImage(secondaryCameraImage) {
|
|
4979
|
+
var _a;
|
|
4980
|
+
this.icon.secondaryCamera.default = ControlImage.fromBase64EncodedImage(secondaryCameraImage);
|
|
4981
|
+
void ((_a = this.view) === null || _a === void 0 ? void 0 : _a['controlUpdated']());
|
|
4982
|
+
}
|
|
4983
|
+
get secondaryCameraPressedImage() {
|
|
4984
|
+
var _a, _b;
|
|
4985
|
+
if (((_a = this.icon.secondaryCamera.pressed) === null || _a === void 0 ? void 0 : _a.isBase64EncodedImage()) == true) {
|
|
4986
|
+
return (_b = this.icon.secondaryCamera.pressed) === null || _b === void 0 ? void 0 : _b.data;
|
|
4987
|
+
}
|
|
4988
|
+
return null;
|
|
4989
|
+
}
|
|
4990
|
+
set secondaryCameraPressedImage(secondaryCameraPressedImage) {
|
|
4991
|
+
var _a;
|
|
4992
|
+
this.icon.secondaryCamera.pressed = ControlImage.fromBase64EncodedImage(secondaryCameraPressedImage);
|
|
4993
|
+
void ((_a = this.view) === null || _a === void 0 ? void 0 : _a['controlUpdated']());
|
|
4994
|
+
}
|
|
4995
|
+
setPrimaryCameraImage(resource) {
|
|
4996
|
+
var _a;
|
|
4997
|
+
this.icon.primaryCamera.default = ControlImage.fromResourceName(resource);
|
|
4998
|
+
void ((_a = this.view) === null || _a === void 0 ? void 0 : _a['controlUpdated']());
|
|
4999
|
+
}
|
|
5000
|
+
setPrimaryCameraPressedImage(resource) {
|
|
5001
|
+
var _a;
|
|
5002
|
+
this.icon.primaryCamera.pressed = ControlImage.fromResourceName(resource);
|
|
5003
|
+
void ((_a = this.view) === null || _a === void 0 ? void 0 : _a['controlUpdated']());
|
|
5004
|
+
}
|
|
5005
|
+
setSecondaryCameraImage(resource) {
|
|
5006
|
+
var _a;
|
|
5007
|
+
this.icon.secondaryCamera.default = ControlImage.fromResourceName(resource);
|
|
5008
|
+
void ((_a = this.view) === null || _a === void 0 ? void 0 : _a['controlUpdated']());
|
|
5009
|
+
}
|
|
5010
|
+
setSecondaryCameraPressedImage(resource) {
|
|
5011
|
+
var _a;
|
|
5012
|
+
this.icon.secondaryCamera.pressed = ControlImage.fromResourceName(resource);
|
|
5013
|
+
void ((_a = this.view) === null || _a === void 0 ? void 0 : _a['controlUpdated']());
|
|
5014
|
+
}
|
|
5015
|
+
}
|
|
5016
|
+
__decorate([
|
|
5017
|
+
nameForSerialization('primaryCamera')
|
|
5018
|
+
], CameraSwitchControl.prototype, "_primaryCamera", void 0);
|
|
5019
|
+
__decorate([
|
|
5020
|
+
nameForSerialization('secondaryCamera')
|
|
5021
|
+
], CameraSwitchControl.prototype, "_secondaryCamera", void 0);
|
|
5022
|
+
__decorate([
|
|
5023
|
+
ignoreFromSerialization
|
|
5024
|
+
], CameraSwitchControl.prototype, "_view", void 0);
|
|
5025
|
+
__decorate([
|
|
5026
|
+
ignoreFromSerialization
|
|
5027
|
+
], CameraSwitchControl.prototype, "controller", void 0);
|
|
5028
|
+
__decorate([
|
|
5029
|
+
ignoreFromSerializationIfNull
|
|
5030
|
+
], CameraSwitchControl.prototype, "anchor", void 0);
|
|
5031
|
+
__decorate([
|
|
5032
|
+
ignoreFromSerializationIfNull
|
|
5033
|
+
], CameraSwitchControl.prototype, "offset", void 0);
|
|
5034
|
+
__decorate([
|
|
5035
|
+
ignoreFromSerializationIfNull,
|
|
5036
|
+
nameForSerialization('accessibilityLabelWhenWorldFacing')
|
|
5037
|
+
], CameraSwitchControl.prototype, "accessibilityLabelWhenWorldFacing", void 0);
|
|
5038
|
+
__decorate([
|
|
5039
|
+
ignoreFromSerializationIfNull,
|
|
5040
|
+
nameForSerialization('accessibilityHintWhenWorldFacing')
|
|
5041
|
+
], CameraSwitchControl.prototype, "accessibilityHintWhenWorldFacing", void 0);
|
|
5042
|
+
__decorate([
|
|
5043
|
+
ignoreFromSerializationIfNull,
|
|
5044
|
+
nameForSerialization('accessibilityLabelWhenUserFacing')
|
|
5045
|
+
], CameraSwitchControl.prototype, "accessibilityLabelWhenUserFacing", void 0);
|
|
5046
|
+
__decorate([
|
|
5047
|
+
ignoreFromSerializationIfNull,
|
|
5048
|
+
nameForSerialization('accessibilityHintWhenUserFacing')
|
|
5049
|
+
], CameraSwitchControl.prototype, "accessibilityHintWhenUserFacing", void 0);
|
|
5050
|
+
|
|
4581
5051
|
var VideoResolution;
|
|
4582
5052
|
(function (VideoResolution) {
|
|
4583
5053
|
/** @deprecated Auto is deprecated. Please use the capture mode's recommendedCameraSettings for the best results. */
|
|
@@ -5435,5 +5905,5 @@ var ClusteringMode;
|
|
|
5435
5905
|
ClusteringMode["AutoWithManualCorrection"] = "autoWithManualCorrection";
|
|
5436
5906
|
})(ClusteringMode || (ClusteringMode = {}));
|
|
5437
5907
|
|
|
5438
|
-
export { AimerViewfinder, Anchor, BaseController, BaseDataCaptureView, Brush, CORE_PROXY_TYPE_NAMES, Camera, CameraController, CameraOwnershipHelper, CameraOwnershipManager, CameraPosition, CameraSettings, ClusteringMode, Color, ContextStatus, ControlImage, CoreProxyAdapter, DataCaptureContext, DataCaptureContextEvents, DataCaptureContextSettings, DataCaptureViewController, DataCaptureViewEvents, DefaultSerializeable, Direction, EventDataParser, EventEmitter, Expiration, FactoryMaker, Feedback, FocusGestureListenerEvents, FocusGestureStrategy, FocusRange, FontFamily, FrameDataController, FrameDataSettings, FrameDataSettingsBuilder, FrameSourceListenerEvents, FrameSourceState, HTMLElementState, HtmlElementPosition, HtmlElementSize, ImageBuffer, ImageFrameSource, LaserlineViewfinder, LicenseInfo, LogoStyle, MacroMode, MacroModeListenerEvents, MarginsWithUnit, MeasureUnit, NativeProxy, NoViewfinder, NoneLocationSelection, NumberWithUnit, Observable, OpenSourceSoftwareLicenseInfo, Orientation, PinchToZoom, Point, PointWithUnit, PrivateFocusGestureDeserializer, PrivateFrameData, PrivateZoomGestureDeserializer, Quadrilateral, RadiusLocationSelection, Rect, RectWithUnit, RectangularLocationSelection, RectangularViewfinder, RectangularViewfinderAnimation, RectangularViewfinderLineStyle, RectangularViewfinderStyle, SKIP, ScanIntention, ScanditIcon, ScanditIconBuilder, ScanditIconShape, ScanditIconType, SelectionMode, Size, SizeWithAspect, SizeWithUnit, SizeWithUnitAndAspect, SizingMode, Sound, SwipeToZoom, TapToFocus, TextAlignment, TorchListenerEvents, TorchState, TorchSwitchControl, Vibration, VibrationType, VideoResolution, WaveFormVibration, ZoomGestureListenerEvents, ZoomListenerEvents, ZoomSwitchControl, ZoomSwitchOrientation, createNativeProxy, ensureCoreDefaults, generateIdentifier, getCoreDefaults, ignoreFromSerialization, ignoreFromSerializationIfNull, loadCoreDefaults, nameForSerialization, registerCoreProxies, registerProxies, serializationDefault, setCoreDefaultsLoader };
|
|
5908
|
+
export { AimerViewfinder, Anchor, BaseController, BaseDataCaptureView, Brush, CORE_PROXY_TYPE_NAMES, Camera, CameraController, CameraOwnershipHelper, CameraOwnershipManager, CameraPosition, CameraSettings, CameraSwitchControl, CameraSwitchControlController, ClusteringMode, Color, ContextStatus, ControlImage, CoreProxyAdapter, DataCaptureContext, DataCaptureContextEvents, DataCaptureContextSettings, DataCaptureViewController, DataCaptureViewEvents, DefaultSerializeable, Direction, EventDataParser, EventEmitter, Expiration, FactoryMaker, Feedback, FocusGestureListenerEvents, FocusGestureStrategy, FocusRange, FontFamily, FrameDataController, FrameDataSettings, FrameDataSettingsBuilder, FrameSourceListenerEvents, FrameSourceState, HTMLElementState, HtmlElementPosition, HtmlElementSize, ImageBuffer, ImageFrameSource, LaserlineViewfinder, LicenseInfo, LogoStyle, MacroMode, MacroModeListenerEvents, MarginsWithUnit, MeasureUnit, NativeProxy, NoViewfinder, NoneLocationSelection, NumberWithUnit, Observable, OpenSourceSoftwareLicenseInfo, Orientation, PinchToZoom, Point, PointWithUnit, PrivateFocusGestureDeserializer, PrivateFrameData, PrivateZoomGestureDeserializer, Quadrilateral, RadiusLocationSelection, Rect, RectWithUnit, RectangularLocationSelection, RectangularViewfinder, RectangularViewfinderAnimation, RectangularViewfinderLineStyle, RectangularViewfinderStyle, SKIP, ScanIntention, ScanditIcon, ScanditIconBuilder, ScanditIconShape, ScanditIconType, SelectionMode, SequenceFrameSource, Size, SizeWithAspect, SizeWithUnit, SizeWithUnitAndAspect, SizingMode, Sound, SwipeToZoom, TapToFocus, TextAlignment, TorchListenerEvents, TorchState, TorchSwitchControl, Vibration, VibrationType, VideoResolution, WaveFormVibration, ZoomGestureListenerEvents, ZoomListenerEvents, ZoomSwitchControl, ZoomSwitchOrientation, createNativeProxy, ensureCoreDefaults, generateIdentifier, getCoreDefaults, ignoreFromSerialization, ignoreFromSerializationIfNull, loadCoreDefaults, nameForSerialization, registerCoreProxies, registerProxies, serializationDefault, setCoreDefaultsLoader };
|
|
5439
5909
|
//# sourceMappingURL=core.js.map
|