scandit-capacitor-datacapture-barcode 8.7.0 → 8.7.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/ScanditCapacitorDatacaptureBarcode.podspec +1 -1
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/scandit/capacitor/datacapture/barcode/ScanditBarcodeNative.java +5 -0
- package/dist/barcode.js +81 -90
- package/dist/barcode.js.map +1 -1
- package/dist/dts/barcode.d.ts +5 -7
- package/package.json +2 -2
package/android/build.gradle
CHANGED
package/android/src/main/java/com/scandit/capacitor/datacapture/barcode/ScanditBarcodeNative.java
CHANGED
|
@@ -214,6 +214,11 @@ public class ScanditBarcodeNative extends Plugin implements Emitter {
|
|
|
214
214
|
return this.hasListenersForEvent(eventName);
|
|
215
215
|
}
|
|
216
216
|
|
|
217
|
+
@Override
|
|
218
|
+
public boolean hasRegisteredViewListenersForEvent(int viewId, @NonNull String eventName) {
|
|
219
|
+
return false;
|
|
220
|
+
}
|
|
221
|
+
|
|
217
222
|
@PluginMethod
|
|
218
223
|
public void getDynamicDefaults(PluginCall call) {
|
|
219
224
|
try {
|
package/dist/barcode.js
CHANGED
|
@@ -16924,16 +16924,11 @@ class BarcodeCountViewEventHandlers {
|
|
|
16924
16924
|
const listener = this.view.listener;
|
|
16925
16925
|
if (listener && typeof listener.iconForRecognizedBarcode === 'function') {
|
|
16926
16926
|
// Opted in, so the listener's answer stands -- null included, which clears the icon.
|
|
16927
|
-
icon = listener.iconForRecognizedBarcode(this.view.platformView, trackedBarcode);
|
|
16927
|
+
icon = BarcodeCountViewEventHandlers.iconOrDefault(() => listener.iconForRecognizedBarcode(this.view.platformView, trackedBarcode), getBarcodeCountDefaults().BarcodeCountView.defaultRecognizedIcon);
|
|
16928
16928
|
}
|
|
16929
16929
|
else {
|
|
16930
|
-
// Not opted in
|
|
16931
|
-
//
|
|
16932
|
-
// that only wants taps or brushes lands here for every tracked barcode. Since the
|
|
16933
|
-
// bridge now forwards a null icon as a removal, answering null would silently strip
|
|
16934
|
-
// icons from apps that never asked to control them. Mirrors Flutter, which substitutes
|
|
16935
|
-
// the default for a listener that is not a BarcodeCountViewExtendedListener
|
|
16936
|
-
// (barcode_count_view.dart:1309-1311).
|
|
16930
|
+
// Not opted in: answer with the default. The controller registers only the
|
|
16931
|
+
// implemented iconFor* events, so this runs while a listener swap is in flight.
|
|
16937
16932
|
icon = getBarcodeCountDefaults().BarcodeCountView.defaultRecognizedIcon;
|
|
16938
16933
|
}
|
|
16939
16934
|
const finishPayload = buildTrackedBarcodeIconPayload(trackedBarcode, icon);
|
|
@@ -16962,16 +16957,11 @@ class BarcodeCountViewEventHandlers {
|
|
|
16962
16957
|
const listener = this.view.listener;
|
|
16963
16958
|
if (listener && typeof listener.iconForRecognizedBarcodeNotInList === 'function') {
|
|
16964
16959
|
// Opted in, so the listener's answer stands -- null included, which clears the icon.
|
|
16965
|
-
icon = listener.iconForRecognizedBarcodeNotInList(this.view.platformView, trackedBarcode);
|
|
16960
|
+
icon = BarcodeCountViewEventHandlers.iconOrDefault(() => listener.iconForRecognizedBarcodeNotInList(this.view.platformView, trackedBarcode), getBarcodeCountDefaults().BarcodeCountView.defaultNotInListIcon);
|
|
16966
16961
|
}
|
|
16967
16962
|
else {
|
|
16968
|
-
// Not opted in
|
|
16969
|
-
//
|
|
16970
|
-
// that only wants taps or brushes lands here for every tracked barcode. Since the
|
|
16971
|
-
// bridge now forwards a null icon as a removal, answering null would silently strip
|
|
16972
|
-
// icons from apps that never asked to control them. Mirrors Flutter, which substitutes
|
|
16973
|
-
// the default for a listener that is not a BarcodeCountViewExtendedListener
|
|
16974
|
-
// (barcode_count_view.dart:1309-1311).
|
|
16963
|
+
// Not opted in: answer with the default. The controller registers only the
|
|
16964
|
+
// implemented iconFor* events, so this runs while a listener swap is in flight.
|
|
16975
16965
|
icon = getBarcodeCountDefaults().BarcodeCountView.defaultNotInListIcon;
|
|
16976
16966
|
}
|
|
16977
16967
|
const finishPayload = buildTrackedBarcodeIconPayload(trackedBarcode, icon);
|
|
@@ -17000,16 +16990,11 @@ class BarcodeCountViewEventHandlers {
|
|
|
17000
16990
|
const listener = this.view.listener;
|
|
17001
16991
|
if (listener && typeof listener.iconForAcceptedBarcode === 'function') {
|
|
17002
16992
|
// Opted in, so the listener's answer stands -- null included, which clears the icon.
|
|
17003
|
-
icon = listener.iconForAcceptedBarcode(this.view.platformView, trackedBarcode);
|
|
16993
|
+
icon = BarcodeCountViewEventHandlers.iconOrDefault(() => listener.iconForAcceptedBarcode(this.view.platformView, trackedBarcode), getBarcodeCountDefaults().BarcodeCountView.defaultAcceptedIcon);
|
|
17004
16994
|
}
|
|
17005
16995
|
else {
|
|
17006
|
-
// Not opted in
|
|
17007
|
-
//
|
|
17008
|
-
// that only wants taps or brushes lands here for every tracked barcode. Since the
|
|
17009
|
-
// bridge now forwards a null icon as a removal, answering null would silently strip
|
|
17010
|
-
// icons from apps that never asked to control them. Mirrors Flutter, which substitutes
|
|
17011
|
-
// the default for a listener that is not a BarcodeCountViewExtendedListener
|
|
17012
|
-
// (barcode_count_view.dart:1309-1311).
|
|
16996
|
+
// Not opted in: answer with the default. The controller registers only the
|
|
16997
|
+
// implemented iconFor* events, so this runs while a listener swap is in flight.
|
|
17013
16998
|
icon = getBarcodeCountDefaults().BarcodeCountView.defaultAcceptedIcon;
|
|
17014
16999
|
}
|
|
17015
17000
|
const finishPayload = buildTrackedBarcodeIconPayload(trackedBarcode, icon);
|
|
@@ -17038,16 +17023,11 @@ class BarcodeCountViewEventHandlers {
|
|
|
17038
17023
|
const listener = this.view.listener;
|
|
17039
17024
|
if (listener && typeof listener.iconForRejectedBarcode === 'function') {
|
|
17040
17025
|
// Opted in, so the listener's answer stands -- null included, which clears the icon.
|
|
17041
|
-
icon = listener.iconForRejectedBarcode(this.view.platformView, trackedBarcode);
|
|
17026
|
+
icon = BarcodeCountViewEventHandlers.iconOrDefault(() => listener.iconForRejectedBarcode(this.view.platformView, trackedBarcode), getBarcodeCountDefaults().BarcodeCountView.defaultRejectedIcon);
|
|
17042
17027
|
}
|
|
17043
17028
|
else {
|
|
17044
|
-
// Not opted in
|
|
17045
|
-
//
|
|
17046
|
-
// that only wants taps or brushes lands here for every tracked barcode. Since the
|
|
17047
|
-
// bridge now forwards a null icon as a removal, answering null would silently strip
|
|
17048
|
-
// icons from apps that never asked to control them. Mirrors Flutter, which substitutes
|
|
17049
|
-
// the default for a listener that is not a BarcodeCountViewExtendedListener
|
|
17050
|
-
// (barcode_count_view.dart:1309-1311).
|
|
17029
|
+
// Not opted in: answer with the default. The controller registers only the
|
|
17030
|
+
// implemented iconFor* events, so this runs while a listener swap is in flight.
|
|
17051
17031
|
icon = getBarcodeCountDefaults().BarcodeCountView.defaultRejectedIcon;
|
|
17052
17032
|
}
|
|
17053
17033
|
const finishPayload = buildTrackedBarcodeIconPayload(trackedBarcode, icon);
|
|
@@ -17058,6 +17038,16 @@ class BarcodeCountViewEventHandlers {
|
|
|
17058
17038
|
});
|
|
17059
17039
|
});
|
|
17060
17040
|
}
|
|
17041
|
+
// A throwing app callback still gets a finish call, or native would keep no icon at all.
|
|
17042
|
+
static iconOrDefault(callback, fallback) {
|
|
17043
|
+
try {
|
|
17044
|
+
return callback();
|
|
17045
|
+
}
|
|
17046
|
+
catch (error) {
|
|
17047
|
+
console.error(`BarcodeCountView iconFor* listener failed: ${String(error)}`);
|
|
17048
|
+
return fallback;
|
|
17049
|
+
}
|
|
17050
|
+
}
|
|
17061
17051
|
// Fire-and-forget ARE events are parsed strictly: a payload that fails the generated schema
|
|
17062
17052
|
// parse is logged once and dropped, so a value outside the schema (for example an unknown error
|
|
17063
17053
|
// reason) never reaches a listener. The frame metadata is built from the parsed payload. Nothing
|
|
@@ -17191,7 +17181,8 @@ var BarcodeCountAdaptiveRecognitionEvents;
|
|
|
17191
17181
|
class BarcodeCountViewController extends BaseController {
|
|
17192
17182
|
constructor(view, barcodeCount) {
|
|
17193
17183
|
super('BarcodeCountViewProxy');
|
|
17194
|
-
this.
|
|
17184
|
+
this.iconListener = null;
|
|
17185
|
+
this.iconListenerViewId = null;
|
|
17195
17186
|
this.isViewListenerRegistered = false;
|
|
17196
17187
|
this.isModeListenerRegistered = false;
|
|
17197
17188
|
this.isStatusProviderRegistered = false;
|
|
@@ -17218,18 +17209,6 @@ class BarcodeCountViewController extends BaseController {
|
|
|
17218
17209
|
this.handleBrushForRejectedBarcodeWrapper = (ev) => {
|
|
17219
17210
|
return this.eventHandlers.handleBrushForRejectedBarcode(ev);
|
|
17220
17211
|
};
|
|
17221
|
-
this.handleIconForRecognizedBarcodeWrapper = (ev) => {
|
|
17222
|
-
return this.eventHandlers.handleIconForRecognizedBarcode(ev);
|
|
17223
|
-
};
|
|
17224
|
-
this.handleIconForRecognizedBarcodeNotInListWrapper = (ev) => {
|
|
17225
|
-
return this.eventHandlers.handleIconForRecognizedBarcodeNotInList(ev);
|
|
17226
|
-
};
|
|
17227
|
-
this.handleIconForAcceptedBarcodeWrapper = (ev) => {
|
|
17228
|
-
return this.eventHandlers.handleIconForAcceptedBarcode(ev);
|
|
17229
|
-
};
|
|
17230
|
-
this.handleIconForRejectedBarcodeWrapper = (ev) => {
|
|
17231
|
-
return this.eventHandlers.handleIconForRejectedBarcode(ev);
|
|
17232
|
-
};
|
|
17233
17212
|
this.handleFilteredBarcodeTappedWrapper = (ev) => {
|
|
17234
17213
|
this.eventHandlers.handleFilteredBarcodeTapped(ev);
|
|
17235
17214
|
};
|
|
@@ -17380,21 +17359,14 @@ class BarcodeCountViewController extends BaseController {
|
|
|
17380
17359
|
if (!this.isViewCreated) {
|
|
17381
17360
|
return;
|
|
17382
17361
|
}
|
|
17383
|
-
//
|
|
17384
|
-
// the
|
|
17385
|
-
// is subscribed to it, so a blanket subscription would make every existing app that
|
|
17386
|
-
// registers any view listener pay four native->JS->native round trips per tracked barcode
|
|
17387
|
-
// just to hand back the default icon native had already drawn.
|
|
17362
|
+
// The iconFor* events are not subscribed here: syncIconEventRegistration puts them in the
|
|
17363
|
+
// ListenerRegistry for the callbacks the listener implements.
|
|
17388
17364
|
this._proxy.subscribeForEvents(BarcodeCountViewController.nonIconViewListenerEvents);
|
|
17389
|
-
this.
|
|
17365
|
+
yield this.syncIconEventRegistration(this.view.listener);
|
|
17390
17366
|
this._proxy.eventEmitter.on(BarcodeCountViewListenerEvents.brushForRecognizedBarcode, this.handleBrushForRecognizedBarcodeWrapper);
|
|
17391
17367
|
this._proxy.eventEmitter.on(BarcodeCountViewListenerEvents.brushForRecognizedBarcodeNotInList, this.handleBrushForRecognizedBarcodeNotInListWrapper);
|
|
17392
17368
|
this._proxy.eventEmitter.on(BarcodeCountViewListenerEvents.brushForAcceptedBarcode, this.handleBrushForAcceptedBarcodeWrapper);
|
|
17393
17369
|
this._proxy.eventEmitter.on(BarcodeCountViewListenerEvents.brushForRejectedBarcode, this.handleBrushForRejectedBarcodeWrapper);
|
|
17394
|
-
this._proxy.eventEmitter.on(BarcodeCountViewListenerEvents.iconForRecognizedBarcode, this.handleIconForRecognizedBarcodeWrapper);
|
|
17395
|
-
this._proxy.eventEmitter.on(BarcodeCountViewListenerEvents.iconForRecognizedBarcodeNotInList, this.handleIconForRecognizedBarcodeNotInListWrapper);
|
|
17396
|
-
this._proxy.eventEmitter.on(BarcodeCountViewListenerEvents.iconForAcceptedBarcode, this.handleIconForAcceptedBarcodeWrapper);
|
|
17397
|
-
this._proxy.eventEmitter.on(BarcodeCountViewListenerEvents.iconForRejectedBarcode, this.handleIconForRejectedBarcodeWrapper);
|
|
17398
17370
|
this._proxy.eventEmitter.on(BarcodeCountViewListenerEvents.filteredBarcodeTapped, this.handleFilteredBarcodeTappedWrapper);
|
|
17399
17371
|
this._proxy.eventEmitter.on(BarcodeCountViewListenerEvents.recognizedBarcodeNotInListTapped, this.handleRecognizedBarcodeNotInListTappedWrapper);
|
|
17400
17372
|
this._proxy.eventEmitter.on(BarcodeCountViewListenerEvents.recognizedBarcodeTapped, this.handleRecognizedBarcodeTappedWrapper);
|
|
@@ -17443,8 +17415,10 @@ class BarcodeCountViewController extends BaseController {
|
|
|
17443
17415
|
if (listener != null) {
|
|
17444
17416
|
yield this.registerViewListener();
|
|
17445
17417
|
// registerViewListener returns early once registered, so a listener swapped in later
|
|
17446
|
-
// would otherwise keep the icon
|
|
17447
|
-
this.
|
|
17418
|
+
// would otherwise keep the icon registration the FIRST listener decided on.
|
|
17419
|
+
if (this.isViewListenerRegistered) {
|
|
17420
|
+
yield this.syncIconEventRegistration(listener);
|
|
17421
|
+
}
|
|
17448
17422
|
}
|
|
17449
17423
|
else {
|
|
17450
17424
|
yield this.unregisterViewListener();
|
|
@@ -17734,32 +17708,54 @@ class BarcodeCountViewController extends BaseController {
|
|
|
17734
17708
|
hasTransformer: hasTransformer,
|
|
17735
17709
|
});
|
|
17736
17710
|
}
|
|
17737
|
-
|
|
17738
|
-
|
|
17739
|
-
|
|
17740
|
-
const listener = this.view.listener;
|
|
17741
|
-
if (listener == null) {
|
|
17742
|
-
return false;
|
|
17743
|
-
}
|
|
17744
|
-
return BarcodeCountViewController.iconViewListenerEvents.some(event => {
|
|
17745
|
-
const callbackName = event.substring(event.indexOf('.') + 1);
|
|
17746
|
-
return typeof listener[callbackName] === 'function';
|
|
17747
|
-
});
|
|
17711
|
+
static listenerImplements(listener, eventName) {
|
|
17712
|
+
const callbackName = eventName.substring(eventName.indexOf('.') + 1);
|
|
17713
|
+
return typeof listener[callbackName] === 'function';
|
|
17748
17714
|
}
|
|
17749
|
-
|
|
17750
|
-
|
|
17751
|
-
|
|
17752
|
-
|
|
17753
|
-
|
|
17754
|
-
|
|
17755
|
-
|
|
17756
|
-
|
|
17757
|
-
|
|
17758
|
-
|
|
17759
|
-
else {
|
|
17760
|
-
this._proxy.unsubscribeFromEvents(BarcodeCountViewController.iconViewListenerEvents);
|
|
17715
|
+
iconEventHandler(eventName) {
|
|
17716
|
+
switch (eventName) {
|
|
17717
|
+
case BarcodeCountViewListenerEvents.iconForRecognizedBarcodeNotInList:
|
|
17718
|
+
return ev => this.eventHandlers.handleIconForRecognizedBarcodeNotInList(ev);
|
|
17719
|
+
case BarcodeCountViewListenerEvents.iconForAcceptedBarcode:
|
|
17720
|
+
return ev => this.eventHandlers.handleIconForAcceptedBarcode(ev);
|
|
17721
|
+
case BarcodeCountViewListenerEvents.iconForRejectedBarcode:
|
|
17722
|
+
return ev => this.eventHandlers.handleIconForRejectedBarcode(ev);
|
|
17723
|
+
default:
|
|
17724
|
+
return ev => this.eventHandlers.handleIconForRecognizedBarcode(ev);
|
|
17761
17725
|
}
|
|
17762
|
-
|
|
17726
|
+
}
|
|
17727
|
+
// Registers each iconFor* event only for a callback the listener implements. Add before remove:
|
|
17728
|
+
// an event both listeners share never leaves the native registry, so an iconFor* event in flight
|
|
17729
|
+
// during a swap still reaches a handler and gets its finish call.
|
|
17730
|
+
syncIconEventRegistration(next) {
|
|
17731
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17732
|
+
const previous = this.iconListener;
|
|
17733
|
+
const previousViewId = this.iconListenerViewId;
|
|
17734
|
+
const viewId = this.view.viewId;
|
|
17735
|
+
if (previous === next && (next === null || previousViewId === viewId)) {
|
|
17736
|
+
return;
|
|
17737
|
+
}
|
|
17738
|
+
this.iconListener = next;
|
|
17739
|
+
this.iconListenerViewId = next ? viewId : null;
|
|
17740
|
+
const pending = [];
|
|
17741
|
+
if (next) {
|
|
17742
|
+
for (const eventName of BarcodeCountViewController.iconViewListenerEvents) {
|
|
17743
|
+
if (BarcodeCountViewController.listenerImplements(next, eventName)) {
|
|
17744
|
+
const handle = this.iconEventHandler(eventName);
|
|
17745
|
+
pending.push(ListenerRegistry.addListener(eventName, { viewId }, next, (_listeners, ev) => handle(ev)));
|
|
17746
|
+
}
|
|
17747
|
+
}
|
|
17748
|
+
}
|
|
17749
|
+
if (previous && previousViewId !== null) {
|
|
17750
|
+
const previousTarget = { viewId: previousViewId };
|
|
17751
|
+
for (const eventName of BarcodeCountViewController.iconViewListenerEvents) {
|
|
17752
|
+
if (ListenerRegistry.listenersFor(eventName, previousTarget).includes(previous)) {
|
|
17753
|
+
pending.push(ListenerRegistry.removeListener(eventName, previousTarget, previous));
|
|
17754
|
+
}
|
|
17755
|
+
}
|
|
17756
|
+
}
|
|
17757
|
+
yield Promise.all(pending);
|
|
17758
|
+
});
|
|
17763
17759
|
}
|
|
17764
17760
|
unregisterViewScopedListeners(viewId) {
|
|
17765
17761
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -17785,16 +17781,12 @@ class BarcodeCountViewController extends BaseController {
|
|
|
17785
17781
|
if (!this.isViewListenerRegistered) {
|
|
17786
17782
|
return;
|
|
17787
17783
|
}
|
|
17788
|
-
this._proxy.unsubscribeFromEvents(
|
|
17789
|
-
this.
|
|
17784
|
+
this._proxy.unsubscribeFromEvents(BarcodeCountViewController.nonIconViewListenerEvents);
|
|
17785
|
+
yield this.syncIconEventRegistration(null);
|
|
17790
17786
|
this._proxy.eventEmitter.off(BarcodeCountViewListenerEvents.brushForRecognizedBarcode, this.handleBrushForRecognizedBarcodeWrapper);
|
|
17791
17787
|
this._proxy.eventEmitter.off(BarcodeCountViewListenerEvents.brushForRecognizedBarcodeNotInList, this.handleBrushForRecognizedBarcodeNotInListWrapper);
|
|
17792
17788
|
this._proxy.eventEmitter.off(BarcodeCountViewListenerEvents.brushForAcceptedBarcode, this.handleBrushForAcceptedBarcodeWrapper);
|
|
17793
17789
|
this._proxy.eventEmitter.off(BarcodeCountViewListenerEvents.brushForRejectedBarcode, this.handleBrushForRejectedBarcodeWrapper);
|
|
17794
|
-
this._proxy.eventEmitter.off(BarcodeCountViewListenerEvents.iconForRecognizedBarcode, this.handleIconForRecognizedBarcodeWrapper);
|
|
17795
|
-
this._proxy.eventEmitter.off(BarcodeCountViewListenerEvents.iconForRecognizedBarcodeNotInList, this.handleIconForRecognizedBarcodeNotInListWrapper);
|
|
17796
|
-
this._proxy.eventEmitter.off(BarcodeCountViewListenerEvents.iconForAcceptedBarcode, this.handleIconForAcceptedBarcodeWrapper);
|
|
17797
|
-
this._proxy.eventEmitter.off(BarcodeCountViewListenerEvents.iconForRejectedBarcode, this.handleIconForRejectedBarcodeWrapper);
|
|
17798
17790
|
this._proxy.eventEmitter.off(BarcodeCountViewListenerEvents.filteredBarcodeTapped, this.handleFilteredBarcodeTappedWrapper);
|
|
17799
17791
|
this._proxy.eventEmitter.off(BarcodeCountViewListenerEvents.recognizedBarcodeNotInListTapped, this.handleRecognizedBarcodeNotInListTappedWrapper);
|
|
17800
17792
|
this._proxy.eventEmitter.off(BarcodeCountViewListenerEvents.recognizedBarcodeTapped, this.handleRecognizedBarcodeTappedWrapper);
|
|
@@ -17834,9 +17826,8 @@ class BarcodeCountViewController extends BaseController {
|
|
|
17834
17826
|
return data;
|
|
17835
17827
|
}
|
|
17836
17828
|
}
|
|
17837
|
-
//
|
|
17838
|
-
//
|
|
17839
|
-
// registerViewListener.
|
|
17829
|
+
// The four iconFor* events go through the ListenerRegistry, one per implemented callback, so
|
|
17830
|
+
// native answers nil (no default flash) only for an event the app will reply to.
|
|
17840
17831
|
BarcodeCountViewController.iconViewListenerEvents = [
|
|
17841
17832
|
BarcodeCountViewListenerEvents.iconForRecognizedBarcode,
|
|
17842
17833
|
BarcodeCountViewListenerEvents.iconForRecognizedBarcodeNotInList,
|