@ovok/native 0.4.10 → 1.0.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/LICENSE +667 -8
- package/lib/commonjs/modules/bt-management/services/bt-manager.js +13 -15
- package/lib/commonjs/modules/bt-management/services/bt-manager.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/device-creator.js +1 -7
- package/lib/commonjs/modules/bt-management/services/device-creator.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/devices/bc01/bc01.device.js +51 -113
- package/lib/commonjs/modules/bt-management/services/devices/bc01/bc01.device.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/devices/bc01/bc01.main-services.js +77 -41
- package/lib/commonjs/modules/bt-management/services/devices/bc01/bc01.main-services.js.map +1 -1
- package/lib/module/modules/bt-management/services/bt-manager.js +13 -15
- package/lib/module/modules/bt-management/services/bt-manager.js.map +1 -1
- package/lib/module/modules/bt-management/services/device-creator.js +1 -7
- package/lib/module/modules/bt-management/services/device-creator.js.map +1 -1
- package/lib/module/modules/bt-management/services/devices/bc01/bc01.device.js +51 -113
- package/lib/module/modules/bt-management/services/devices/bc01/bc01.device.js.map +1 -1
- package/lib/module/modules/bt-management/services/devices/bc01/bc01.main-services.js +77 -41
- package/lib/module/modules/bt-management/services/devices/bc01/bc01.main-services.js.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/bt-manager.d.ts +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/bt-manager.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/device-creator.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bc01/bc01.device.d.ts +13 -33
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bc01/bc01.device.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bc01/bc01.main-services.d.ts +17 -11
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bc01/bc01.main-services.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/services/bt-manager.d.ts +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/bt-manager.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/services/device-creator.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/services/devices/bc01/bc01.device.d.ts +13 -33
- package/lib/typescript/module/src/modules/bt-management/services/devices/bc01/bc01.device.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/services/devices/bc01/bc01.main-services.d.ts +17 -11
- package/lib/typescript/module/src/modules/bt-management/services/devices/bc01/bc01.main-services.d.ts.map +1 -1
- package/package.json +13 -12
- package/lib/commonjs/modules/bt-management/services/devices/bc01/bc01-command-sequencer.js +0 -184
- package/lib/commonjs/modules/bt-management/services/devices/bc01/bc01-command-sequencer.js.map +0 -1
- package/lib/commonjs/modules/bt-management/services/devices/bc01/bc01-frame-parser.js +0 -114
- package/lib/commonjs/modules/bt-management/services/devices/bc01/bc01-frame-parser.js.map +0 -1
- package/lib/module/modules/bt-management/services/devices/bc01/bc01-command-sequencer.js +0 -180
- package/lib/module/modules/bt-management/services/devices/bc01/bc01-command-sequencer.js.map +0 -1
- package/lib/module/modules/bt-management/services/devices/bc01/bc01-frame-parser.js +0 -110
- package/lib/module/modules/bt-management/services/devices/bc01/bc01-frame-parser.js.map +0 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bc01/bc01-command-sequencer.d.ts +0 -53
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bc01/bc01-command-sequencer.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bc01/bc01-frame-parser.d.ts +0 -53
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bc01/bc01-frame-parser.d.ts.map +0 -1
- package/lib/typescript/module/src/modules/bt-management/services/devices/bc01/bc01-command-sequencer.d.ts +0 -53
- package/lib/typescript/module/src/modules/bt-management/services/devices/bc01/bc01-command-sequencer.d.ts.map +0 -1
- package/lib/typescript/module/src/modules/bt-management/services/devices/bc01/bc01-frame-parser.d.ts +0 -53
- package/lib/typescript/module/src/modules/bt-management/services/devices/bc01/bc01-frame-parser.d.ts.map +0 -1
|
@@ -13,6 +13,7 @@ export declare class BTManager<T extends readonly AcceptedDevice[]> {
|
|
|
13
13
|
private stateChangeListener;
|
|
14
14
|
private eventSubscriptions;
|
|
15
15
|
private deviceCreator;
|
|
16
|
+
private lastScanTimestamp;
|
|
16
17
|
constructor(bleManager: BleManager, acceptedDevices: T);
|
|
17
18
|
destroy: () => void;
|
|
18
19
|
startScan: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bt-manager.d.ts","sourceRoot":"","sources":["../../../../../../../src/modules/bt-management/services/bt-manager.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,UAAU,EAKX,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG1D,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,qBAAa,SAAS,CAAC,CAAC,SAAS,SAAS,cAAc,EAAE;
|
|
1
|
+
{"version":3,"file":"bt-manager.d.ts","sourceRoot":"","sources":["../../../../../../../src/modules/bt-management/services/bt-manager.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,UAAU,EAKX,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAC;A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BAA8B,CAUpC;CACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device-creator.d.ts","sourceRoot":"","sources":["../../../../../../../src/modules/bt-management/services/device-creator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAMrD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AA6D9D,qBAAa,aAAa,CAAC,CAAC,SAAS,SAAS,cAAc,EAAE;IAKhD,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IAJhD,OAAO,CAAC,eAAe,CAAuC;IAC9D,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAO;IACtC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAsC;gBAEvC,mBAAmB,EAAE,CAAC;IAI5C,aAAa,GAAI,WAAW,MAAM,KAAG,WAAW,CAAC,CAAC,CAAC,GAAG,SAAS,CAkBpE;IAEK,YAAY,CAAC,CAAC,SAAS,SAAS,EACrC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAC5B,eAAe,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"device-creator.d.ts","sourceRoot":"","sources":["../../../../../../../src/modules/bt-management/services/device-creator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAMrD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AA6D9D,qBAAa,aAAa,CAAC,CAAC,SAAS,SAAS,cAAc,EAAE;IAKhD,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IAJhD,OAAO,CAAC,eAAe,CAAuC;IAC9D,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAO;IACtC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAsC;gBAEvC,mBAAmB,EAAE,CAAC;IAI5C,aAAa,GAAI,WAAW,MAAM,KAAG,WAAW,CAAC,CAAC,CAAC,GAAG,SAAS,CAkBpE;IAEK,YAAY,CAAC,CAAC,SAAS,SAAS,EACrC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAC5B,eAAe,CAAC,CAAC,CAAC;IAmCd,OAAO,aAEZ;IAEF;;;OAGG;IACH,OAAO,CAAC,eAAe,CAmBrB;IAEF,OAAO,CAAC,eAAe;CAexB"}
|
package/lib/typescript/module/src/modules/bt-management/services/devices/bc01/bc01.device.d.ts
CHANGED
|
@@ -1,53 +1,33 @@
|
|
|
1
|
-
import { Device } from "react-native-ble-plx";
|
|
2
|
-
import { CreateDeviceParams } from "../../../types/create-device-params";
|
|
3
|
-
import { DependentResultHandlerParams } from "../../../types/dependent-result-handler-params";
|
|
4
1
|
import { MeasurementTypeForDevices } from "../../../types/device-measurement-map";
|
|
5
2
|
import { IntegratedDevices } from "../../../types/integrated-devices";
|
|
3
|
+
import { MeasurementWithCaseType } from "../../../types/measurement-with-case-type";
|
|
6
4
|
import { IService } from "../../../types/service.type";
|
|
7
5
|
import { BTManagedDevice } from "../bt-managed-device";
|
|
8
6
|
/**
|
|
9
7
|
* Contec BC401 (BC01) urine analyzer driver.
|
|
10
8
|
*
|
|
11
|
-
* The BC401 is a
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* documented in `bc01-command-sequencer.ts`. Every record arrives as one
|
|
16
|
-
* 16-byte E1/E2 frame on 0xFF02.
|
|
9
|
+
* The BC401 is a single-shot device: the patient dips a URS-7 strip, presses
|
|
10
|
+
* the button, and the device pushes exactly one result frame on 0xFF01. There
|
|
11
|
+
* is no streaming state, no per-tick updates, and no measurement session to
|
|
12
|
+
* open — the device auto-starts on button press.
|
|
17
13
|
*/
|
|
18
14
|
export declare class BC01Device extends BTManagedDevice<IntegratedDevices.BC01> {
|
|
19
15
|
protected onStreamStart: () => void;
|
|
20
16
|
protected mainServices: IService[];
|
|
21
17
|
/**
|
|
22
18
|
* 90 s covers the maximum firmware-side reagent-pad settle time on a URS-7
|
|
23
|
-
* strip
|
|
24
|
-
*
|
|
25
|
-
* times out and the driver surfaces "device unreachable".
|
|
19
|
+
* strip. If the device does not push a result frame within that window the
|
|
20
|
+
* data-processor times out and the driver surfaces "device unreachable".
|
|
26
21
|
*/
|
|
27
22
|
protected stuckDataTimeout: number;
|
|
28
|
-
constructor(device: Device, params: CreateDeviceParams<IntegratedDevices.BC01>);
|
|
29
|
-
/**
|
|
30
|
-
* Returns true once the notification buffer holds a complete BC401 frame,
|
|
31
|
-
* classified by its opening opcode. Anything else — a heartbeat opcode we
|
|
32
|
-
* do not recognise, or a partial buffer — is held back until enough bytes
|
|
33
|
-
* arrive to make sense of it. There is no aa55 header on this hardware.
|
|
34
|
-
*/
|
|
35
23
|
protected validatePackage: (pkg: string[]) => boolean;
|
|
24
|
+
protected handleSuccessResult(successResult: MeasurementWithCaseType<MeasurementTypeForDevices<[IntegratedDevices.BC01]>>): void | boolean;
|
|
25
|
+
private handleUrinalysisResult;
|
|
36
26
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* reading directly through `onResult`. The frame is then handed back as
|
|
41
|
-
* `OTHER` so the state machine does not report it a second time and does
|
|
42
|
-
* not dedupe consecutive records that happen to share the same opcode.
|
|
43
|
-
*/
|
|
44
|
-
protected handleDependentResult: (data: DependentResultHandlerParams<MeasurementTypeForDevices<[IntegratedDevices.BC01]>>) => DependentResultHandlerParams<MeasurementTypeForDevices<[IntegratedDevices.BC01]>>;
|
|
45
|
-
/**
|
|
46
|
-
* Nothing to do here for the BC401. Every reading arrives through the
|
|
47
|
-
* dependent-result path, and the state machine sees only the `OTHER`-typed
|
|
48
|
-
* echo we return from `handleDependentResult`.
|
|
27
|
+
* A well-formed frame with all analyte fields still undefined means the
|
|
28
|
+
* device produced an empty read — typically a strip inserted upside down or
|
|
29
|
+
* removed before the reagent-pad timer completed.
|
|
49
30
|
*/
|
|
50
|
-
|
|
51
|
-
private reportUrsRecord;
|
|
31
|
+
private checkIfHasError;
|
|
52
32
|
}
|
|
53
33
|
//# sourceMappingURL=bc01.device.d.ts.map
|
package/lib/typescript/module/src/modules/bt-management/services/devices/bc01/bc01.device.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bc01.device.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/bt-management/services/devices/bc01/bc01.device.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bc01.device.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/bt-management/services/devices/bc01/bc01.device.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAC;AACpF,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAIvD;;;;;;;GAOG;AACH,qBAAa,UAAW,SAAQ,eAAe,CAAC,iBAAiB,CAAC,IAAI,CAAC;IACrE,SAAS,CAAC,aAAa,EAAE,MAAM,IAAI,CAAY;IAE/C,SAAS,CAAC,YAAY,EAAE,QAAQ,EAAE,CAAoB;IAEtD;;;;OAIG;IACH,SAAS,CAAC,gBAAgB,SAAU;IAEpC,SAAS,CAAC,eAAe,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,OAAO,CAgCnD;IAEF,SAAS,CAAC,mBAAmB,CAC3B,aAAa,EAAE,uBAAuB,CACpC,yBAAyB,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CACpD,GACA,IAAI,GAAG,OAAO;IAkBjB,OAAO,CAAC,sBAAsB;IAc9B;;;;OAIG;IACH,OAAO,CAAC,eAAe;CA2BxB"}
|
|
@@ -2,20 +2,26 @@ import { IService } from "../../../types/service.type";
|
|
|
2
2
|
/**
|
|
3
3
|
* Contec BC401 (a.k.a. BC01) urine analyzer — GATT profile.
|
|
4
4
|
*
|
|
5
|
-
* The BC401 uses Contec's proprietary FF12 service, shared across their
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* in `bc01-command-sequencer.ts`.
|
|
5
|
+
* The BC401 uses Contec's proprietary FF12 service, shared across their consumer
|
|
6
|
+
* medical devices. A single result notification carries a 7-parameter URS-7
|
|
7
|
+
* strip readout expanded into eleven analyte values on the wire.
|
|
9
8
|
*
|
|
10
9
|
* Service 0xFF12
|
|
11
|
-
* Notify (result)
|
|
12
|
-
* Write (command)
|
|
10
|
+
* Notify (result) 0xFF01 — CCCD 0x2902 must be written 01 00 to enable
|
|
11
|
+
* Write (command) 0xFF02 — RESET / SET_UNIT / REQUEST_HISTORY
|
|
13
12
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
13
|
+
* Wire layout of a result frame (Contec URS-7 firmware ≥ 1.2.x):
|
|
14
|
+
* [0..1] header "aa 55" — Contec sentinel
|
|
15
|
+
* [2] length byte after header
|
|
16
|
+
* [3] command "a1" == RESULT_URS7
|
|
17
|
+
* [4] strip type "07" == 7-panel
|
|
18
|
+
* [5..15] values one byte per analyte, encoding the discrete
|
|
19
|
+
* level index into diagnosticResults[key]
|
|
20
|
+
* [16] checksum xor over [2..15]
|
|
21
|
+
*
|
|
22
|
+
* Byte positions calibrated against PHMS 3.0.03 Android app; older firmware
|
|
23
|
+
* (< 1.2.x) uses a different command byte and is not supported by this driver
|
|
24
|
+
* (the validator will reject those frames).
|
|
19
25
|
*/
|
|
20
26
|
export declare const bc01MainServices: IService[];
|
|
21
27
|
//# sourceMappingURL=bc01.main-services.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bc01.main-services.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/bt-management/services/devices/bc01/bc01.main-services.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD
|
|
1
|
+
{"version":3,"file":"bc01.main-services.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/bt-management/services/devices/bc01/bc01.main-services.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,gBAAgB,EAAE,QAAQ,EAuFtC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ovok/native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "React native component sdk for OVOK",
|
|
5
5
|
"source": "./src/index.tsx",
|
|
6
6
|
"main": "./lib/commonjs/index.js",
|
|
@@ -68,6 +68,7 @@
|
|
|
68
68
|
"@medplum/expo-polyfills": "^3.2.23"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
+
"@babel/core": "^7.29.0",
|
|
71
72
|
"@commitlint/config-conventional": "^17.0.2",
|
|
72
73
|
"@eslint/compat": "^1.2.2",
|
|
73
74
|
"@eslint/js": "^9.13.0",
|
|
@@ -80,9 +81,9 @@
|
|
|
80
81
|
"@react-native-community/datetimepicker": "^9.1.0",
|
|
81
82
|
"@react-native-community/netinfo": "^12.0.1",
|
|
82
83
|
"@react-native-google-signin/google-signin": "^16.1.2",
|
|
83
|
-
"@react-native/babel-preset": "^0.
|
|
84
|
+
"@react-native/babel-preset": "^0.86.0",
|
|
84
85
|
"@react-native/eslint-config": "^0.73.1",
|
|
85
|
-
"@react-native/jest-preset": "^0.
|
|
86
|
+
"@react-native/jest-preset": "^0.86.0",
|
|
86
87
|
"@release-it/conventional-changelog": "^5.0.0",
|
|
87
88
|
"@sentry/react-native": "~7.11.0",
|
|
88
89
|
"@shopify/flash-list": "2.0.2",
|
|
@@ -106,11 +107,11 @@
|
|
|
106
107
|
"eslint-plugin-react-hooks": "^5.0.0",
|
|
107
108
|
"eslint-plugin-testing-library": "^6.4.0",
|
|
108
109
|
"eslint-plugin-unused-imports": "^4.1.4",
|
|
109
|
-
"expo-apple-authentication": "~
|
|
110
|
+
"expo-apple-authentication": "~57.0.2",
|
|
110
111
|
"expo-health-connect": "^0.1.1",
|
|
111
|
-
"expo-image": "~
|
|
112
|
-
"expo-linear-gradient": "~
|
|
113
|
-
"expo-web-browser": "~
|
|
112
|
+
"expo-image": "~57.0.5",
|
|
113
|
+
"expo-linear-gradient": "~57.0.2",
|
|
114
|
+
"expo-web-browser": "~57.0.3",
|
|
114
115
|
"formik": "^2.4.9",
|
|
115
116
|
"globals": "^15.11.0",
|
|
116
117
|
"i18next": "^26.3.1",
|
|
@@ -122,23 +123,23 @@
|
|
|
122
123
|
"react": "19.2.3",
|
|
123
124
|
"react-dom": "19.2.3",
|
|
124
125
|
"react-i18next": "^17.0.8",
|
|
125
|
-
"react-native": "0.
|
|
126
|
+
"react-native": "0.86.3",
|
|
126
127
|
"react-native-ble-plx": "^3.5.1",
|
|
127
128
|
"react-native-blob-util": "^0.24.9",
|
|
128
129
|
"react-native-builder-bob": "^0.30.2",
|
|
129
130
|
"react-native-element-dropdown": "^2.12.2",
|
|
130
|
-
"react-native-gesture-handler": "~2.
|
|
131
|
+
"react-native-gesture-handler": "~2.32.0",
|
|
131
132
|
"react-native-health-connect": "^3.5.3",
|
|
132
|
-
"react-native-keyboard-controller": "
|
|
133
|
+
"react-native-keyboard-controller": "1.21.9",
|
|
133
134
|
"react-native-modal-datetime-picker": "^18.0.0",
|
|
134
135
|
"react-native-paper": "^5.13.1",
|
|
135
136
|
"react-native-pdf": "^6.7.7",
|
|
136
137
|
"react-native-permissions": "^5.6.0",
|
|
137
|
-
"react-native-reanimated": "
|
|
138
|
+
"react-native-reanimated": "4.5.1",
|
|
138
139
|
"react-native-render-html": "^6.3.4",
|
|
139
140
|
"react-native-safe-area-context": "5.7.0",
|
|
140
141
|
"react-native-svg": "15.15.4",
|
|
141
|
-
"react-native-worklets": "0.
|
|
142
|
+
"react-native-worklets": "0.10.1",
|
|
142
143
|
"react-test-renderer": "19.2.3",
|
|
143
144
|
"release-it": "^19.0.6",
|
|
144
145
|
"socket.io-client": "^4.8.3",
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.bc01CommandSequencerInternals = exports.Bc01CommandSequencer = void 0;
|
|
7
|
-
var _hexToByte = require("../../../utils/hex-to-byte.js");
|
|
8
|
-
/**
|
|
9
|
-
* The FF01/FF02 opcodes the BC401 firmware speaks, as reverse-engineered from
|
|
10
|
-
* PHMS 3.0.03 (`I1/b.java` for the switch, `B3/B5.java` for the builders and
|
|
11
|
-
* checksum, `L1/f.java` for the reset write).
|
|
12
|
-
*/
|
|
13
|
-
const OP_RESET = 0x80;
|
|
14
|
-
const OP_REQUEST_VERSION = 0x82;
|
|
15
|
-
const OP_SET_TIME = 0x83;
|
|
16
|
-
const OP_REQUEST_COUNT = 0x90;
|
|
17
|
-
const OP_REQUEST_RECORDS = 0x92;
|
|
18
|
-
|
|
19
|
-
/** Payload byte for `OP_REQUEST_RECORDS` that acknowledges the last record of the set. */
|
|
20
|
-
const ACK_LAST_OF_SET = 0x7e;
|
|
21
|
-
|
|
22
|
-
/** Payload byte for `OP_REQUEST_COUNT` and the initial `OP_REQUEST_RECORDS`. */
|
|
23
|
-
const REQUEST_ALL = 0x00;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Device-to-host frame prefixes the FSM keys on. Values are decimal opcodes as
|
|
27
|
-
* they appear in the decompiled Java (`switch(bArr[0])`), rendered here as
|
|
28
|
-
* their real hex opcodes.
|
|
29
|
-
*/
|
|
30
|
-
const RX = {
|
|
31
|
-
ACK: 0xf0,
|
|
32
|
-
VERSION_REPLY: 0xf2,
|
|
33
|
-
TIME_SYNC_ACK: 0xf3,
|
|
34
|
-
COUNT_REPLY: 0xe0,
|
|
35
|
-
STORED_RECORD_URS: 0xe1,
|
|
36
|
-
STORED_RECORD_PAGED: 0xe2,
|
|
37
|
-
FINISH: 0xe3
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
/** Position in a 16-byte URS record where the flags byte sits; bit 0x40 marks the last of a set. */
|
|
41
|
-
const RECORD_FLAGS_INDEX = 1;
|
|
42
|
-
const RECORD_LAST_OF_SET_BIT = 0x40;
|
|
43
|
-
/**
|
|
44
|
-
* Formats one byte as a two-digit lowercase hex string, matching the way the
|
|
45
|
-
* SDK's transport already spells raw bytes.
|
|
46
|
-
*/
|
|
47
|
-
const asHex = byte => (byte & 0xff).toString(16).padStart(2, "0");
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* BC401 checksum: sum of the low 7 bits of every byte, folded back into 7 bits.
|
|
51
|
-
* Matches `B5.a` in the decompiled Java exactly.
|
|
52
|
-
*/
|
|
53
|
-
const bc401Checksum = bytes => bytes.reduce((acc, byte) => acc + (byte & 0x7f), 0) & 0x7f;
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Builds a "one payload byte plus checksum" command frame. This is the shape
|
|
57
|
-
* of every BC401 host-to-device command that carries an argument: opcode,
|
|
58
|
-
* argument, checksum-over-both.
|
|
59
|
-
*/
|
|
60
|
-
const buildCommand = (opcode, arg) => {
|
|
61
|
-
const chk = bc401Checksum([opcode, arg]);
|
|
62
|
-
return [opcode, arg, chk];
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Builds the two-byte reset frame. It is the one command that does not carry
|
|
67
|
-
* an argument or a checksum — PHMS writes it as `[0x80, 0x00]` verbatim
|
|
68
|
-
* (`L1/f.java:694`).
|
|
69
|
-
*/
|
|
70
|
-
const buildResetCommand = () => [OP_RESET, 0x00];
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Builds the request-version reply. The Java sends it as `[0x82, 0x02]` where
|
|
74
|
-
* `0x02` doubles as the checksum of `0x82` under the BC401 rule
|
|
75
|
-
* (`0x82 & 0x7f = 0x02`), so the same formula that guards every other command
|
|
76
|
-
* produces the right byte here.
|
|
77
|
-
*/
|
|
78
|
-
const buildRequestVersionCommand = () => {
|
|
79
|
-
const chk = bc401Checksum([OP_REQUEST_VERSION]);
|
|
80
|
-
return [OP_REQUEST_VERSION, chk];
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Builds the `SET_TIME` frame for the moment the sequencer receives it. The
|
|
85
|
-
* device does not run its own clock across power cycles, so timestamps on
|
|
86
|
-
* stored records only make sense once the app tells it what "now" is.
|
|
87
|
-
* Millisecond field is written little-endian, matching `I1/b.java`.
|
|
88
|
-
*/
|
|
89
|
-
const buildSetTimeCommand = now => {
|
|
90
|
-
const yy = now.getFullYear() - 2000;
|
|
91
|
-
const mo = now.getMonth() + 1;
|
|
92
|
-
const dd = now.getDate();
|
|
93
|
-
const hh = now.getHours();
|
|
94
|
-
const mi = now.getMinutes();
|
|
95
|
-
const ss = now.getSeconds();
|
|
96
|
-
const ms = now.getMilliseconds();
|
|
97
|
-
const msLo = ms & 0xff;
|
|
98
|
-
const msHi = ms >> 8 & 0xff;
|
|
99
|
-
const payload = [OP_SET_TIME, yy, mo, dd, hh, mi, ss, msLo, msHi];
|
|
100
|
-
const chk = bc401Checksum(payload);
|
|
101
|
-
return [...payload, chk];
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Walks the BC401 through its post-reset handshake and pulls every stored
|
|
106
|
-
* record.
|
|
107
|
-
*
|
|
108
|
-
* The device is self-clocking: it answers each command with a single frame,
|
|
109
|
-
* and the first byte of that frame names what it is. So the sequencer keeps
|
|
110
|
-
* no counter of its own — it looks at the reply, decides what belongs next,
|
|
111
|
-
* and returns that. A frame whose opcode is not part of the handshake is left
|
|
112
|
-
* unanswered so the driver's stuck-data watchdog surfaces the stall rather
|
|
113
|
-
* than the sequencer sending a command the device did not ask for.
|
|
114
|
-
*
|
|
115
|
-
* `initialCommands()` returns only the reset. The rest of the handshake -
|
|
116
|
-
* VERSION, SET_TIME, GET_COUNT, GET_RECORDS - is driven entirely by the
|
|
117
|
-
* device's own replies, because sending them any earlier would race the
|
|
118
|
-
* firmware boot the reset triggers.
|
|
119
|
-
*/
|
|
120
|
-
// eslint-disable-next-line import/group-exports
|
|
121
|
-
class Bc01CommandSequencer {
|
|
122
|
-
isDone = false;
|
|
123
|
-
|
|
124
|
-
/** Injectable for tests; production reads `Date.now()`. */
|
|
125
|
-
|
|
126
|
-
constructor(params, clock = () => new Date()) {
|
|
127
|
-
this.params = params;
|
|
128
|
-
this.clock = clock;
|
|
129
|
-
}
|
|
130
|
-
initialCommands = () => [this.commandFor(buildResetCommand())];
|
|
131
|
-
nextCommand = frame => {
|
|
132
|
-
if (this.isDone || frame.length === 0) {
|
|
133
|
-
return undefined;
|
|
134
|
-
}
|
|
135
|
-
const opcode = (0, _hexToByte.hexToByte)(frame[0] ?? "0");
|
|
136
|
-
switch (opcode) {
|
|
137
|
-
case RX.ACK:
|
|
138
|
-
return [this.commandFor(buildRequestVersionCommand())];
|
|
139
|
-
case RX.VERSION_REPLY:
|
|
140
|
-
return [this.commandFor(buildSetTimeCommand(this.clock()))];
|
|
141
|
-
case RX.TIME_SYNC_ACK:
|
|
142
|
-
return [this.commandFor(buildCommand(OP_REQUEST_COUNT, REQUEST_ALL))];
|
|
143
|
-
case RX.COUNT_REPLY:
|
|
144
|
-
return [this.commandFor(buildCommand(OP_REQUEST_RECORDS, REQUEST_ALL))];
|
|
145
|
-
case RX.STORED_RECORD_URS:
|
|
146
|
-
case RX.STORED_RECORD_PAGED:
|
|
147
|
-
return this.answerStoredRecord(frame);
|
|
148
|
-
case RX.FINISH:
|
|
149
|
-
this.isDone = true;
|
|
150
|
-
return undefined;
|
|
151
|
-
default:
|
|
152
|
-
return undefined;
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* The device pages every record it holds, one 16-byte frame at a time. Only
|
|
158
|
-
* the frame whose flags byte carries `0x40` needs an acknowledgement; every
|
|
159
|
-
* other page is a status update we let ride while the transfer continues.
|
|
160
|
-
*/
|
|
161
|
-
answerStoredRecord = frame => {
|
|
162
|
-
const flags = (0, _hexToByte.hexToByte)(frame[RECORD_FLAGS_INDEX] ?? "0");
|
|
163
|
-
if ((flags & RECORD_LAST_OF_SET_BIT) === 0) {
|
|
164
|
-
return undefined;
|
|
165
|
-
}
|
|
166
|
-
return [this.commandFor(buildCommand(OP_REQUEST_RECORDS, ACK_LAST_OF_SET))];
|
|
167
|
-
};
|
|
168
|
-
commandFor = bytes => ({
|
|
169
|
-
...this.params.write,
|
|
170
|
-
frame: bytes.map(asHex),
|
|
171
|
-
withoutResponse: true
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
// eslint-disable-next-line import/group-exports
|
|
176
|
-
exports.Bc01CommandSequencer = Bc01CommandSequencer;
|
|
177
|
-
const bc01CommandSequencerInternals = exports.bc01CommandSequencerInternals = {
|
|
178
|
-
bc401Checksum,
|
|
179
|
-
buildCommand,
|
|
180
|
-
buildResetCommand,
|
|
181
|
-
buildRequestVersionCommand,
|
|
182
|
-
buildSetTimeCommand
|
|
183
|
-
};
|
|
184
|
-
//# sourceMappingURL=bc01-command-sequencer.js.map
|
package/lib/commonjs/modules/bt-management/services/devices/bc01/bc01-command-sequencer.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_hexToByte","require","OP_RESET","OP_REQUEST_VERSION","OP_SET_TIME","OP_REQUEST_COUNT","OP_REQUEST_RECORDS","ACK_LAST_OF_SET","REQUEST_ALL","RX","ACK","VERSION_REPLY","TIME_SYNC_ACK","COUNT_REPLY","STORED_RECORD_URS","STORED_RECORD_PAGED","FINISH","RECORD_FLAGS_INDEX","RECORD_LAST_OF_SET_BIT","asHex","byte","toString","padStart","bc401Checksum","bytes","reduce","acc","buildCommand","opcode","arg","chk","buildResetCommand","buildRequestVersionCommand","buildSetTimeCommand","now","yy","getFullYear","mo","getMonth","dd","getDate","hh","getHours","mi","getMinutes","ss","getSeconds","ms","getMilliseconds","msLo","msHi","payload","Bc01CommandSequencer","isDone","constructor","params","clock","Date","initialCommands","commandFor","nextCommand","frame","length","undefined","hexToByte","answerStoredRecord","flags","write","map","withoutResponse","exports","bc01CommandSequencerInternals"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/bc01/bc01-command-sequencer.ts"],"mappings":";;;;;;AAEA,IAAAA,UAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA,MAAMC,QAAQ,GAAG,IAAI;AACrB,MAAMC,kBAAkB,GAAG,IAAI;AAC/B,MAAMC,WAAW,GAAG,IAAI;AACxB,MAAMC,gBAAgB,GAAG,IAAI;AAC7B,MAAMC,kBAAkB,GAAG,IAAI;;AAE/B;AACA,MAAMC,eAAe,GAAG,IAAI;;AAE5B;AACA,MAAMC,WAAW,GAAG,IAAI;;AAExB;AACA;AACA;AACA;AACA;AACA,MAAMC,EAAE,GAAG;EACTC,GAAG,EAAE,IAAI;EACTC,aAAa,EAAE,IAAI;EACnBC,aAAa,EAAE,IAAI;EACnBC,WAAW,EAAE,IAAI;EACjBC,iBAAiB,EAAE,IAAI;EACvBC,mBAAmB,EAAE,IAAI;EACzBC,MAAM,EAAE;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AK;IACpBN,KAAK,EAAErC,KAAK,CAAC4C,GAAG,CAACjD,KAAK,CAAC;IACvBkD,eAAe,EAAE;EACnB,CAAC,CAAC;AACJ;;AAEA;AAAAC,OAAA,CAAAlB,oBAAA,GAAAA,oBAAA;AACO,MAAMmB,6BAA6B,GAAAD,OAAA,CAAAC,6BAAA,GAAG;EAC3ChD,aAAa;EACbI,YAAY;EACZI,iBAAiB;EACjBC,0BAA0B;EAC1BC;AACF,CAAC","ignoreList":[]}
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.parseBc01Record = exports.isBc01Record = exports.BC01_URS_OPCODE = exports.BC01_RECORD_LENGTH = exports.BC01_PAGED_URS_OPCODE = exports.BC01_LAST_OF_SET_BIT = exports.BC01_ANALYTE_ORDER = void 0;
|
|
7
|
-
var _hexToByte = require("../../../utils/hex-to-byte.js");
|
|
8
|
-
/** BC401 stored-record frame is always sixteen bytes: header, timestamp, analytes, checksum. */
|
|
9
|
-
const BC01_RECORD_LENGTH = exports.BC01_RECORD_LENGTH = 16;
|
|
10
|
-
|
|
11
|
-
/** The two opcodes the firmware uses for a stored URS-7 record. */
|
|
12
|
-
const BC01_URS_OPCODE = exports.BC01_URS_OPCODE = 0xe1;
|
|
13
|
-
const BC01_PAGED_URS_OPCODE = exports.BC01_PAGED_URS_OPCODE = 0xe2;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* The bit `0x40` of the flags byte marks the last record of a paginated set.
|
|
17
|
-
* The sequencer keys off it to send the `[0x92, 0x7E, chk]` acknowledgement.
|
|
18
|
-
*/
|
|
19
|
-
const BC01_LAST_OF_SET_BIT = exports.BC01_LAST_OF_SET_BIT = 0x40;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* A pad reading of `7` means the strip was not measured on that reagent.
|
|
23
|
-
* We drop those pads from the output rather than reporting them as level "7".
|
|
24
|
-
*/
|
|
25
|
-
const UNMEASURED = 7;
|
|
26
|
-
const YEAR_BASE = 2000;
|
|
27
|
-
const MONTH_MASK = 0x0f;
|
|
28
|
-
const DAY_MASK = 0x1f;
|
|
29
|
-
const HOUR_MASK = 0x1f;
|
|
30
|
-
const MINUTE_MASK = 0x3f;
|
|
31
|
-
const SECOND_MASK = 0x3f;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* URS-7 pad names, in the exact order they occupy the packed 3-bit slots
|
|
35
|
-
* across bytes 8..14 (see M1/a.java). The eleventh slot is a Contec-firmware
|
|
36
|
-
* field the vendor's own catalog calls "vc" and no other name is documented.
|
|
37
|
-
*/
|
|
38
|
-
const BC01_ANALYTE_ORDER = exports.BC01_ANALYTE_ORDER = ["uro", "bld", "bil", "ket", "glu", "pro", "ph", "nit", "leu", "sg", "vc"];
|
|
39
|
-
|
|
40
|
-
/** Where the packed analyte pairs start in a 16-byte E1/E2 frame. */
|
|
41
|
-
const ANALYTES_START = 8;
|
|
42
|
-
|
|
43
|
-
/** The result of decoding one 16-byte record. `lastOfSet` is what the sequencer keys on. */
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Extracts one pad's level index from the packed byte. Two pads share a byte:
|
|
47
|
-
* the first uses the low 3 bits, the second uses bits 3..5. Bit 6 and 7 are
|
|
48
|
-
* unused reserved space per the vendor's own decoding in M1/a.java.
|
|
49
|
-
*/
|
|
50
|
-
const readPad = (packed, slot) => slot === 0 ? packed & 0x07 : packed >> 3 & 0x07;
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Decodes a 16-byte E1 or E2 frame into its timestamp and analyte indices.
|
|
54
|
-
*
|
|
55
|
-
* Returns `undefined` for any frame that is not the right length or does not
|
|
56
|
-
* open with an E1/E2 opcode — the caller is not asked to guess whether a
|
|
57
|
-
* frame is a record or a heartbeat, and a frame that fails these checks is
|
|
58
|
-
* skipped rather than parsed into a plausible-looking wrong reading.
|
|
59
|
-
*
|
|
60
|
-
* The checksum byte is not verified here: the SDK's read path already ensures
|
|
61
|
-
* frame integrity before the parser sees the bytes, and a URS-7 pad value can
|
|
62
|
-
* only land in [0, 7] anyway — a corrupt payload would fail the pad-value
|
|
63
|
-
* check before it made it into a measurement.
|
|
64
|
-
*/
|
|
65
|
-
const parseBc01Record = frame => {
|
|
66
|
-
if (frame.length < BC01_RECORD_LENGTH) {
|
|
67
|
-
return undefined;
|
|
68
|
-
}
|
|
69
|
-
const opcode = (0, _hexToByte.hexToByte)(frame[0] ?? "");
|
|
70
|
-
if (opcode !== BC01_URS_OPCODE && opcode !== BC01_PAGED_URS_OPCODE) {
|
|
71
|
-
return undefined;
|
|
72
|
-
}
|
|
73
|
-
const flags = (0, _hexToByte.hexToByte)(frame[1] ?? "");
|
|
74
|
-
const yy = (0, _hexToByte.hexToByte)(frame[2] ?? "") + YEAR_BASE;
|
|
75
|
-
const mm = (0, _hexToByte.hexToByte)(frame[3] ?? "") & MONTH_MASK;
|
|
76
|
-
const dd = (0, _hexToByte.hexToByte)(frame[4] ?? "") & DAY_MASK;
|
|
77
|
-
const hh = (0, _hexToByte.hexToByte)(frame[5] ?? "") & HOUR_MASK;
|
|
78
|
-
const mi = (0, _hexToByte.hexToByte)(frame[6] ?? "") & MINUTE_MASK;
|
|
79
|
-
const ss = (0, _hexToByte.hexToByte)(frame[7] ?? "") & SECOND_MASK;
|
|
80
|
-
const timestamp = new Date(yy, mm - 1, dd, hh, mi, ss, 0);
|
|
81
|
-
const values = {};
|
|
82
|
-
BC01_ANALYTE_ORDER.forEach((analyte, position) => {
|
|
83
|
-
const byteIndex = ANALYTES_START + Math.floor(position / 2);
|
|
84
|
-
const slot = position % 2;
|
|
85
|
-
const packed = (0, _hexToByte.hexToByte)(frame[byteIndex] ?? "");
|
|
86
|
-
const level = readPad(packed, slot);
|
|
87
|
-
if (level === UNMEASURED) {
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
values[analyte] = level;
|
|
91
|
-
});
|
|
92
|
-
return {
|
|
93
|
-
timestamp,
|
|
94
|
-
lastOfSet: (flags & BC01_LAST_OF_SET_BIT) !== 0,
|
|
95
|
-
pageIndex: flags & 0x0f,
|
|
96
|
-
values
|
|
97
|
-
};
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* True when the buffer holds a complete BC401 stored record. Used by the
|
|
102
|
-
* driver's `validatePackage` hook so the SDK's read path only advances once
|
|
103
|
-
* the notification carries a whole 16-byte frame.
|
|
104
|
-
*/
|
|
105
|
-
exports.parseBc01Record = parseBc01Record;
|
|
106
|
-
const isBc01Record = frame => {
|
|
107
|
-
if (frame.length < BC01_RECORD_LENGTH) {
|
|
108
|
-
return false;
|
|
109
|
-
}
|
|
110
|
-
const opcode = (0, _hexToByte.hexToByte)(frame[0] ?? "");
|
|
111
|
-
return opcode === BC01_URS_OPCODE || opcode === BC01_PAGED_URS_OPCODE;
|
|
112
|
-
};
|
|
113
|
-
exports.isBc01Record = isBc01Record;
|
|
114
|
-
//# sourceMappingURL=bc01-frame-parser.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_hexToByte","require","BC01_RECORD_LENGTH","exports","BC01_URS_OPCODE","BC01_PAGED_URS_OPCODE","BC01_LAST_OF_SET_BIT","UNMEASURED","YEAR_BASE","MONTH_MASK","DAY_MASK","HOUR_MASK","MINUTE_MASK","SECOND_MASK","BC01_ANALYTE_ORDER","ANALYTES_START","readPad","packed","slot","parseBc01Record","frame","length","undefined","opcode","hexToByte","flags","yy","mm","dd","hh","mi","ss","timestamp","Date","values","forEach","analyte","position","byteIndex","Math","floor","level","lastOfSet","pageIndex","isBc01Record"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/bc01/bc01-frame-parser.ts"],"mappings":";;;;;;AAEA,IAAAA,UAAA,GAAAC,OAAA;AAEA;AACA,MAAMC,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAA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