scandit-datacapture-frameworks-core 8.0.0 → 8.1.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/__mocks__/Defaults.ts +1 -1
- package/dist/dts/EventEmitter.d.ts +1 -2
- package/dist/dts/FactoryMaker.d.ts +5 -5
- package/dist/dts/camera/Camera.d.ts +11 -11
- package/dist/dts/camera/CameraController.d.ts +14 -11
- package/dist/dts/camera/CameraSettings.d.ts +2 -2
- package/dist/dts/camerahelpers/CameraOwnershipHelper.d.ts +1 -1
- package/dist/dts/camerahelpers/CameraOwnershipManager.d.ts +1 -1
- package/dist/dts/common/Brush.d.ts +3 -3
- package/dist/dts/common/ScanditIconType.d.ts +1 -1
- package/dist/dts/context/DataCaptureContext.d.ts +5 -5
- package/dist/dts/context/controller/DataCaptureContextController.d.ts +12 -12
- package/dist/dts/controllers/{BaseNewController.d.ts → BaseController.d.ts} +1 -1
- package/dist/dts/controllers/index.d.ts +1 -1
- package/dist/dts/defaults/CoreDefaults.d.ts +1 -1
- package/dist/dts/defaults/loadCoreDefaults.d.ts +1 -1
- package/dist/dts/feedback/Feedback.d.ts +3 -3
- package/dist/dts/feedback/FeedbackController.d.ts +10 -6
- package/dist/dts/frame/ImageFrameSource.d.ts +1 -1
- package/dist/dts/frame/ImageFrameSourceController.d.ts +5 -9
- package/dist/dts/helpers/Helpers.d.ts +1 -0
- package/dist/dts/helpers/index.d.ts +1 -0
- package/dist/dts/index.d.ts +3 -1
- package/dist/dts/proxies/BaseProxy.d.ts +7 -0
- package/dist/dts/proxies/NativeCaller.d.ts +6 -4
- package/dist/dts/proxies/NativeProxy.d.ts +7 -5
- package/dist/dts/proxies/ProxyRegistration.d.ts +5 -0
- package/dist/dts/proxies/index.d.ts +2 -2
- package/dist/dts/proxy-registration.d.ts +2 -0
- package/dist/dts/proxy-types.d.ts +5 -0
- package/dist/dts/view/ControlImage.d.ts +1 -1
- package/dist/dts/view/DataCaptureView.d.ts +6 -6
- package/dist/dts/view/DataCaptureViewController.d.ts +44 -17
- package/dist/dts/viewfinder/AimerViewfinder.d.ts +1 -1
- package/dist/dts/viewfinder/LaserlineViewfinder.d.ts +1 -1
- package/dist/dts/viewfinder/RectangularViewfinder.d.ts +8 -8
- package/dist/index.js +482 -695
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
- package/test/ProxyRegistration.test.ts +75 -0
- package/dist/dts/BaseController.d.ts +0 -50
- package/dist/dts/proxies/AdvancedInstanceAwareNativeProxy.d.ts +0 -30
- package/dist/dts/proxies/BaseInstanceAwareNativeProxy.d.ts +0 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scandit-datacapture-frameworks-core",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.1.0",
|
|
4
4
|
"description": "Core common package",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Scandit",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"scripts": {
|
|
13
13
|
"build": "rollup -c rollup.config.js --bundleConfigAsCjs",
|
|
14
14
|
"clean": "rimraf .rollup.cache dist",
|
|
15
|
+
"lint": "eslint ./src",
|
|
15
16
|
"prepack": "pnpm run build",
|
|
16
17
|
"test": "jest --passWithNoTests",
|
|
17
18
|
"coverage": "jest --coverage --passWithNoTests"
|
|
@@ -23,4 +24,4 @@
|
|
|
23
24
|
"eventemitter3"
|
|
24
25
|
],
|
|
25
26
|
"packageManager": "pnpm@10.15.0"
|
|
26
|
-
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { registerProxies, NativeCallerProvider } from '../src/proxies/ProxyRegistration';
|
|
2
|
+
import { FactoryMaker } from '../src/FactoryMaker';
|
|
3
|
+
import { NativeCaller } from '../src/proxies/NativeCaller';
|
|
4
|
+
|
|
5
|
+
describe('ProxyRegistration', () => {
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
FactoryMaker.instances.clear();
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('should register all provided proxy types', () => {
|
|
11
|
+
const mockCaller: NativeCaller = {
|
|
12
|
+
callFn: jest.fn(),
|
|
13
|
+
registerEvent: jest.fn(),
|
|
14
|
+
unregisterEvent: jest.fn(),
|
|
15
|
+
eventHook: jest.fn()
|
|
16
|
+
};
|
|
17
|
+
const mockProvider: NativeCallerProvider = {
|
|
18
|
+
getNativeCaller: jest.fn(() => mockCaller)
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const proxyTypes = ['ProxyA', 'ProxyB', 'ProxyC'];
|
|
22
|
+
registerProxies(proxyTypes, mockProvider);
|
|
23
|
+
|
|
24
|
+
proxyTypes.forEach(proxyType => {
|
|
25
|
+
expect(FactoryMaker.instances.has(proxyType)).toBe(true);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('should call provider.getNativeCaller for each proxy type when instantiated', () => {
|
|
30
|
+
const mockCaller: NativeCaller = {
|
|
31
|
+
callFn: jest.fn(),
|
|
32
|
+
registerEvent: jest.fn(),
|
|
33
|
+
unregisterEvent: jest.fn(),
|
|
34
|
+
eventHook: jest.fn()
|
|
35
|
+
};
|
|
36
|
+
const mockProvider: NativeCallerProvider = {
|
|
37
|
+
getNativeCaller: jest.fn(() => mockCaller)
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const proxyTypes = ['ProxyA', 'ProxyB'];
|
|
41
|
+
registerProxies(proxyTypes, mockProvider);
|
|
42
|
+
|
|
43
|
+
// Force lazy instantiation
|
|
44
|
+
proxyTypes.forEach(proxyType => {
|
|
45
|
+
FactoryMaker.getInstance(proxyType);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
expect(mockProvider.getNativeCaller).toHaveBeenCalledTimes(2);
|
|
49
|
+
expect(mockProvider.getNativeCaller).toHaveBeenCalledWith('ProxyA');
|
|
50
|
+
expect(mockProvider.getNativeCaller).toHaveBeenCalledWith('ProxyB');
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('should create new proxy instances for each call to createInstance', () => {
|
|
54
|
+
const mockCaller: NativeCaller = {
|
|
55
|
+
callFn: jest.fn(),
|
|
56
|
+
registerEvent: jest.fn(),
|
|
57
|
+
unregisterEvent: jest.fn(),
|
|
58
|
+
eventHook: jest.fn()
|
|
59
|
+
};
|
|
60
|
+
const mockProvider: NativeCallerProvider = {
|
|
61
|
+
getNativeCaller: jest.fn(() => mockCaller)
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
registerProxies(['ProxyA'], mockProvider);
|
|
65
|
+
|
|
66
|
+
const instance1 = FactoryMaker.createInstance('ProxyA');
|
|
67
|
+
const instance2 = FactoryMaker.createInstance('ProxyA');
|
|
68
|
+
|
|
69
|
+
expect(instance1).toBeDefined();
|
|
70
|
+
expect(instance2).toBeDefined();
|
|
71
|
+
expect(instance1).not.toBe(instance2);
|
|
72
|
+
expect(mockProvider.getNativeCaller).toHaveBeenCalledTimes(2);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from "./EventEmitter";
|
|
2
|
-
import { NativeCaller, ProxyEvent } from "./proxies";
|
|
3
|
-
export declare class BaseController<PROXY> {
|
|
4
|
-
protected eventEmitter: EventEmitter;
|
|
5
|
-
private proxyName;
|
|
6
|
-
protected get _proxy(): PROXY;
|
|
7
|
-
constructor(proxyName: string);
|
|
8
|
-
}
|
|
9
|
-
export declare class BaseNativeProxy {
|
|
10
|
-
protected eventEmitter: EventEmitter;
|
|
11
|
-
constructor();
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* AdvancedNativeProxy will provide an easy way to communicate between native proxies
|
|
15
|
-
* and other parts of the architecture such as the controller layer
|
|
16
|
-
*/
|
|
17
|
-
export declare class AdvancedNativeProxy extends BaseNativeProxy {
|
|
18
|
-
protected nativeCaller: NativeCaller;
|
|
19
|
-
protected events: ProxyEvent[];
|
|
20
|
-
protected eventSubscriptions: Map<string, any>;
|
|
21
|
-
[k: string]: any;
|
|
22
|
-
constructor(nativeCaller: NativeCaller, events?: ProxyEvent[]);
|
|
23
|
-
dispose(): Promise<void>;
|
|
24
|
-
_call(fnName: string, args: object | undefined | null): Promise<any>;
|
|
25
|
-
private _registerEvent;
|
|
26
|
-
private _unregisterEvent;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Function to create a custom AdvancedNativeProxy. This will return an object which will provide dynamically the
|
|
30
|
-
* methods specified in the PROXY interface.
|
|
31
|
-
*
|
|
32
|
-
* The Proxy interface implemented in order to call native methods will require a special mark
|
|
33
|
-
* `$methodName` for method calls
|
|
34
|
-
* `on$methodName` for the listeners added to the events defined in eventsEnum
|
|
35
|
-
* @param nativeCaller
|
|
36
|
-
* @param eventsEnum
|
|
37
|
-
*/
|
|
38
|
-
export declare function createAdvancedNativeProxy<PROXY>(nativeCaller: NativeCaller, eventsEnum?: any): PROXY;
|
|
39
|
-
/**
|
|
40
|
-
* Function to create a custom AdvancedNativeProxy. This will return an object which will provide dynamically the
|
|
41
|
-
* methods specified in the PROXY interface.
|
|
42
|
-
*
|
|
43
|
-
* The Proxy interface implemented in order to call native methods will require a special mark
|
|
44
|
-
* `$methodName` for method calls
|
|
45
|
-
* `on$methodName` for the listeners added to the events defined in eventsEnum
|
|
46
|
-
* @param klass
|
|
47
|
-
* @param nativeCaller
|
|
48
|
-
* @param eventsEnum
|
|
49
|
-
*/
|
|
50
|
-
export declare function createAdvancedNativeFromCtorProxy<PROXY>(klass: new (nativeCaller: NativeCaller, events: ProxyEvent[]) => Partial<PROXY>, nativeCaller: NativeCaller, eventsEnum?: any): PROXY;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { BaseInstanceAwareNativeProxy } from "./BaseInstanceAwareNativeProxy";
|
|
2
|
-
import { NativeCaller } from "./NativeCaller";
|
|
3
|
-
import { ProxyEvent } from "./ProxyEvent";
|
|
4
|
-
/**
|
|
5
|
-
* AdvancedNativeProxy will provide an easy way to communicate between native proxies
|
|
6
|
-
* and other parts of the architecture such as the controller layer
|
|
7
|
-
*/
|
|
8
|
-
export declare class AdvancedInstanceAwareNativeProxy extends BaseInstanceAwareNativeProxy {
|
|
9
|
-
protected nativeCaller: NativeCaller;
|
|
10
|
-
protected events: ProxyEvent[];
|
|
11
|
-
protected eventSubscriptions: Map<string, any>;
|
|
12
|
-
private eventHandlers;
|
|
13
|
-
[k: string]: any;
|
|
14
|
-
constructor(nativeCaller: NativeCaller, events?: ProxyEvent[]);
|
|
15
|
-
dispose(): Promise<void>;
|
|
16
|
-
_call(fnName: string, args: object | undefined | null): Promise<any>;
|
|
17
|
-
private _registerEvent;
|
|
18
|
-
private _unregisterEvent;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Function to create a custom AdvancedNativeProxy. This will return an object which will provide dynamically the
|
|
22
|
-
* methods specified in the PROXY interface.
|
|
23
|
-
*
|
|
24
|
-
* The Proxy interface implemented in order to call native methods will require a special mark
|
|
25
|
-
* `$methodName` for method calls
|
|
26
|
-
* `on$methodName` for the listeners added to the events defined in eventsEnum
|
|
27
|
-
* @param nativeCaller
|
|
28
|
-
* @param eventsEnum
|
|
29
|
-
*/
|
|
30
|
-
export declare function createAdvancedInstanceAwareNativeProxy<PROXY>(nativeCaller: NativeCaller, eventsEnum?: any): PROXY;
|