edilkamin 1.7.3 → 1.8.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/.github/workflows/cli-tests.yml +6 -0
- package/README.md +36 -3
- package/dist/cjs/package.json +95 -0
- package/dist/cjs/src/bluetooth-utils.d.ts +13 -0
- package/dist/cjs/src/bluetooth-utils.js +28 -0
- package/dist/cjs/src/bluetooth-utils.test.js +35 -0
- package/dist/cjs/src/bluetooth.d.ts +40 -0
- package/dist/cjs/src/bluetooth.js +107 -0
- package/dist/cjs/src/browser-bundle.test.js +64 -0
- package/dist/cjs/src/buffer-utils.js +78 -0
- package/dist/cjs/src/buffer-utils.test.js +186 -0
- package/dist/cjs/src/cli.js +253 -0
- package/dist/cjs/src/configureAmplify.test.js +42 -0
- package/dist/cjs/src/constants.js +9 -0
- package/dist/{esm → cjs/src}/index.d.ts +2 -1
- package/dist/cjs/src/index.js +24 -0
- package/dist/cjs/src/library.js +324 -0
- package/dist/cjs/src/library.test.js +547 -0
- package/dist/cjs/src/serial-utils.js +50 -0
- package/dist/cjs/src/serial-utils.test.js +50 -0
- package/dist/cjs/src/token-storage.js +119 -0
- package/dist/{esm → cjs/src}/types.d.ts +14 -1
- package/dist/cjs/src/types.js +2 -0
- package/dist/esm/package.json +95 -0
- package/dist/esm/src/bluetooth-utils.d.ts +13 -0
- package/dist/esm/src/bluetooth-utils.js +25 -0
- package/dist/esm/src/bluetooth-utils.test.d.ts +1 -0
- package/dist/esm/src/bluetooth-utils.test.js +33 -0
- package/dist/esm/src/bluetooth.d.ts +40 -0
- package/dist/esm/src/bluetooth.js +100 -0
- package/dist/esm/src/browser-bundle.test.d.ts +1 -0
- package/dist/esm/{browser-bundle.test.js → src/browser-bundle.test.js} +1 -1
- package/dist/esm/src/buffer-utils.d.ts +25 -0
- package/dist/esm/src/buffer-utils.test.d.ts +1 -0
- package/dist/esm/src/cli.d.ts +3 -0
- package/dist/esm/src/configureAmplify.test.d.ts +1 -0
- package/dist/esm/src/constants.d.ts +4 -0
- package/dist/esm/src/index.d.ts +7 -0
- package/dist/esm/{index.js → src/index.js} +1 -0
- package/dist/esm/src/library.d.ts +55 -0
- package/dist/esm/src/library.test.d.ts +1 -0
- package/dist/esm/src/serial-utils.d.ts +33 -0
- package/dist/esm/src/serial-utils.test.d.ts +1 -0
- package/dist/esm/src/token-storage.d.ts +14 -0
- package/dist/esm/src/types.d.ts +86 -0
- package/dist/esm/src/types.js +1 -0
- package/package.json +22 -11
- package/src/bluetooth-utils.test.ts +46 -0
- package/src/bluetooth-utils.ts +29 -0
- package/src/bluetooth.ts +115 -0
- package/src/browser-bundle.test.ts +1 -1
- package/src/index.ts +2 -0
- package/src/types.ts +15 -0
- package/tsconfig.cjs.json +2 -2
- package/tsconfig.json +3 -3
- /package/dist/{esm/browser-bundle.test.d.ts → cjs/src/bluetooth-utils.test.d.ts} +0 -0
- /package/dist/{esm/buffer-utils.test.d.ts → cjs/src/browser-bundle.test.d.ts} +0 -0
- /package/dist/{esm → cjs/src}/buffer-utils.d.ts +0 -0
- /package/dist/{esm/configureAmplify.test.d.ts → cjs/src/buffer-utils.test.d.ts} +0 -0
- /package/dist/{esm → cjs/src}/cli.d.ts +0 -0
- /package/dist/{esm/library.test.d.ts → cjs/src/configureAmplify.test.d.ts} +0 -0
- /package/dist/{esm → cjs/src}/constants.d.ts +0 -0
- /package/dist/{esm → cjs/src}/library.d.ts +0 -0
- /package/dist/{esm/serial-utils.test.d.ts → cjs/src/library.test.d.ts} +0 -0
- /package/dist/{esm → cjs/src}/serial-utils.d.ts +0 -0
- /package/dist/{esm/types.js → cjs/src/serial-utils.test.d.ts} +0 -0
- /package/dist/{esm → cjs/src}/token-storage.d.ts +0 -0
- /package/dist/esm/{buffer-utils.js → src/buffer-utils.js} +0 -0
- /package/dist/esm/{buffer-utils.test.js → src/buffer-utils.test.js} +0 -0
- /package/dist/esm/{cli.js → src/cli.js} +0 -0
- /package/dist/esm/{configureAmplify.test.js → src/configureAmplify.test.js} +0 -0
- /package/dist/esm/{constants.js → src/constants.js} +0 -0
- /package/dist/esm/{library.js → src/library.js} +0 -0
- /package/dist/esm/{library.test.js → src/library.test.js} +0 -0
- /package/dist/esm/{serial-utils.js → src/serial-utils.js} +0 -0
- /package/dist/esm/{serial-utils.test.js → src/serial-utils.test.js} +0 -0
- /package/dist/esm/{token-storage.js → src/token-storage.js} +0 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a Node.js Buffer object serialized to JSON.
|
|
3
|
+
* This format is used by the Edilkamin API for gzip-compressed fields.
|
|
4
|
+
*/
|
|
5
|
+
interface BufferEncodedType {
|
|
6
|
+
type: "Buffer";
|
|
7
|
+
data: number[];
|
|
8
|
+
}
|
|
9
|
+
interface CommandsType {
|
|
10
|
+
power: boolean;
|
|
11
|
+
}
|
|
12
|
+
interface TemperaturesType {
|
|
13
|
+
board: number;
|
|
14
|
+
enviroment: number;
|
|
15
|
+
}
|
|
16
|
+
interface StatusType {
|
|
17
|
+
commands: CommandsType;
|
|
18
|
+
temperatures: TemperaturesType;
|
|
19
|
+
}
|
|
20
|
+
interface UserParametersType {
|
|
21
|
+
enviroment_1_temperature: number;
|
|
22
|
+
enviroment_2_temperature: number;
|
|
23
|
+
enviroment_3_temperature: number;
|
|
24
|
+
is_auto: boolean;
|
|
25
|
+
is_sound_active: boolean;
|
|
26
|
+
}
|
|
27
|
+
interface DeviceInfoType {
|
|
28
|
+
status: StatusType;
|
|
29
|
+
nvm: {
|
|
30
|
+
user_parameters: UserParametersType;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Raw device info response that may contain Buffer-encoded compressed fields.
|
|
35
|
+
* Used internally before processing; external callers receive DeviceInfoType.
|
|
36
|
+
*/
|
|
37
|
+
interface DeviceInfoRawType {
|
|
38
|
+
status: StatusType | BufferEncodedType;
|
|
39
|
+
nvm: {
|
|
40
|
+
user_parameters: UserParametersType;
|
|
41
|
+
} | BufferEncodedType;
|
|
42
|
+
component_info?: BufferEncodedType | Record<string, unknown>;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Request body for registering a device with a user account.
|
|
46
|
+
* All fields are required by the API.
|
|
47
|
+
*/
|
|
48
|
+
interface DeviceAssociationBody {
|
|
49
|
+
macAddress: string;
|
|
50
|
+
deviceName: string;
|
|
51
|
+
deviceRoom: string;
|
|
52
|
+
serialNumber: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Request body for editing a device's name and room.
|
|
56
|
+
* MAC address is specified in the URL path, not the body.
|
|
57
|
+
* Serial number cannot be changed after registration.
|
|
58
|
+
*/
|
|
59
|
+
interface EditDeviceAssociationBody {
|
|
60
|
+
deviceName: string;
|
|
61
|
+
deviceRoom: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Response from device registration endpoint.
|
|
65
|
+
* Structure based on Android app behavior - may need adjustment after testing.
|
|
66
|
+
*/
|
|
67
|
+
interface DeviceAssociationResponse {
|
|
68
|
+
macAddress: string;
|
|
69
|
+
deviceName: string;
|
|
70
|
+
deviceRoom: string;
|
|
71
|
+
serialNumber: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Represents a discovered Edilkamin device from Bluetooth scanning.
|
|
75
|
+
*/
|
|
76
|
+
interface DiscoveredDevice {
|
|
77
|
+
/** BLE MAC address as discovered */
|
|
78
|
+
bleMac: string;
|
|
79
|
+
/** WiFi MAC address (BLE MAC - 2), used for API calls */
|
|
80
|
+
wifiMac: string;
|
|
81
|
+
/** Device name (typically "EDILKAMIN_EP") */
|
|
82
|
+
name: string;
|
|
83
|
+
/** Signal strength in dBm (optional, not all platforms provide this) */
|
|
84
|
+
rssi?: number;
|
|
85
|
+
}
|
|
86
|
+
export type { BufferEncodedType, CommandsType, DeviceAssociationBody, DeviceAssociationResponse, DeviceInfoRawType, DeviceInfoType, DiscoveredDevice, EditDeviceAssociationBody, StatusType, TemperaturesType, UserParametersType, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,19 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "edilkamin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "",
|
|
5
|
-
"main": "dist/cjs/index.js",
|
|
6
|
-
"module": "dist/esm/index.js",
|
|
7
|
-
"types": "dist/esm/index.d.ts",
|
|
5
|
+
"main": "dist/cjs/src/index.js",
|
|
6
|
+
"module": "dist/esm/src/index.js",
|
|
7
|
+
"types": "dist/esm/src/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"import": {
|
|
11
|
-
"types": "./dist/esm/index.d.ts",
|
|
12
|
-
"default": "./dist/esm/index.js"
|
|
11
|
+
"types": "./dist/esm/src/index.d.ts",
|
|
12
|
+
"default": "./dist/esm/src/index.js"
|
|
13
13
|
},
|
|
14
14
|
"require": {
|
|
15
|
-
"types": "./dist/cjs/index.d.ts",
|
|
16
|
-
"default": "./dist/cjs/index.js"
|
|
15
|
+
"types": "./dist/cjs/src/index.d.ts",
|
|
16
|
+
"default": "./dist/cjs/src/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"./bluetooth": {
|
|
20
|
+
"import": {
|
|
21
|
+
"types": "./dist/esm/src/bluetooth.d.ts",
|
|
22
|
+
"default": "./dist/esm/src/bluetooth.js"
|
|
23
|
+
},
|
|
24
|
+
"require": {
|
|
25
|
+
"types": "./dist/cjs/src/bluetooth.d.ts",
|
|
26
|
+
"default": "./dist/cjs/src/bluetooth.js"
|
|
17
27
|
}
|
|
18
28
|
}
|
|
19
29
|
},
|
|
@@ -43,7 +53,7 @@
|
|
|
43
53
|
},
|
|
44
54
|
"homepage": "https://github.com/AndreMiras/edilkamin.js#readme",
|
|
45
55
|
"bin": {
|
|
46
|
-
"edilkamin": "dist/cjs/cli.js"
|
|
56
|
+
"edilkamin": "dist/cjs/src/cli.js"
|
|
47
57
|
},
|
|
48
58
|
"nyc": {
|
|
49
59
|
"reporter": [
|
|
@@ -57,12 +67,13 @@
|
|
|
57
67
|
"pako": "^2.1.0"
|
|
58
68
|
},
|
|
59
69
|
"devDependencies": {
|
|
60
|
-
"@aws-amplify/cli": "^7.6.21",
|
|
61
70
|
"@eslint/eslintrc": "^3.2.0",
|
|
62
71
|
"@eslint/js": "^9.16.0",
|
|
63
72
|
"@types/mocha": "^10.0.10",
|
|
73
|
+
"@types/node": "^25.0.2",
|
|
64
74
|
"@types/pako": "^2.0.4",
|
|
65
75
|
"@types/sinon": "^17.0.3",
|
|
76
|
+
"@types/web-bluetooth": "^0.0.21",
|
|
66
77
|
"@typescript-eslint/eslint-plugin": "^8.17.0",
|
|
67
78
|
"@typescript-eslint/parser": "^8.17.0",
|
|
68
79
|
"esbuild": "^0.27.1",
|
|
@@ -79,6 +90,6 @@
|
|
|
79
90
|
"typescript": "^5.7.2"
|
|
80
91
|
},
|
|
81
92
|
"optionalDependencies": {
|
|
82
|
-
"commander": "^
|
|
93
|
+
"commander": "^14.0.2"
|
|
83
94
|
}
|
|
84
95
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { strict as assert } from "assert";
|
|
2
|
+
|
|
3
|
+
import { bleToWifiMac } from "./bluetooth-utils";
|
|
4
|
+
|
|
5
|
+
describe("bleToWifiMac", () => {
|
|
6
|
+
it("converts BLE MAC with colons to WiFi MAC", () => {
|
|
7
|
+
assert.equal(bleToWifiMac("A8:03:2A:FE:D5:0A"), "a8032afed508");
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it("converts BLE MAC without separators", () => {
|
|
11
|
+
assert.equal(bleToWifiMac("a8032afed50a"), "a8032afed508");
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("converts BLE MAC with dashes", () => {
|
|
15
|
+
assert.equal(bleToWifiMac("A8-03-2A-FE-D5-0A"), "a8032afed508");
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("handles lowercase input", () => {
|
|
19
|
+
assert.equal(bleToWifiMac("a8:03:2a:fe:d5:0a"), "a8032afed508");
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("handles edge case where subtraction crosses byte boundary", () => {
|
|
23
|
+
// FF:FF:FF:FF:FF:01 - 2 = FF:FF:FF:FF:FE:FF
|
|
24
|
+
assert.equal(bleToWifiMac("FF:FF:FF:FF:FF:01"), "fffffffffeff");
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("handles minimum value edge case", () => {
|
|
28
|
+
// 00:00:00:00:00:02 - 2 = 00:00:00:00:00:00
|
|
29
|
+
assert.equal(bleToWifiMac("00:00:00:00:00:02"), "000000000000");
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("throws on invalid MAC format - too short", () => {
|
|
33
|
+
assert.throws(() => bleToWifiMac("A8:03:2A"), /Invalid MAC address format/);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("throws on invalid MAC format - invalid characters", () => {
|
|
37
|
+
assert.throws(
|
|
38
|
+
() => bleToWifiMac("G8:03:2A:FE:D5:0A"),
|
|
39
|
+
/Invalid MAC address format/,
|
|
40
|
+
);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("throws on empty string", () => {
|
|
44
|
+
assert.throws(() => bleToWifiMac(""), /Invalid MAC address format/);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a BLE MAC address to WiFi MAC address.
|
|
3
|
+
* The WiFi MAC is the BLE MAC minus 2 in hexadecimal.
|
|
4
|
+
*
|
|
5
|
+
* @param bleMac - BLE MAC address (with or without colons/dashes)
|
|
6
|
+
* @returns WiFi MAC address in lowercase without separators
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* bleToWifiMac("A8:03:2A:FE:D5:0A") // returns "a8032afed508"
|
|
10
|
+
* bleToWifiMac("a8032afed50a") // returns "a8032afed508"
|
|
11
|
+
*/
|
|
12
|
+
const bleToWifiMac = (bleMac: string): string => {
|
|
13
|
+
// Remove colons, dashes, and convert to lowercase
|
|
14
|
+
const normalized = bleMac.replace(/[:-]/g, "").toLowerCase();
|
|
15
|
+
|
|
16
|
+
// Validate MAC address format (12 hex characters)
|
|
17
|
+
if (!/^[0-9a-f]{12}$/.test(normalized)) {
|
|
18
|
+
throw new Error(`Invalid MAC address format: ${bleMac}`);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Convert to number, subtract 2, convert back to hex
|
|
22
|
+
const bleValue = BigInt(`0x${normalized}`);
|
|
23
|
+
const wifiValue = bleValue - BigInt(2);
|
|
24
|
+
|
|
25
|
+
// Pad to 12 characters and return lowercase
|
|
26
|
+
return wifiValue.toString(16).padStart(12, "0");
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { bleToWifiMac };
|
package/src/bluetooth.ts
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { bleToWifiMac } from "./bluetooth-utils";
|
|
2
|
+
import { DiscoveredDevice } from "./types";
|
|
3
|
+
|
|
4
|
+
/** Device name broadcast by Edilkamin stoves */
|
|
5
|
+
const EDILKAMIN_DEVICE_NAME = "EDILKAMIN_EP";
|
|
6
|
+
|
|
7
|
+
/** GATT Service UUID for Edilkamin devices (0xABF0) */
|
|
8
|
+
const EDILKAMIN_SERVICE_UUID = 0xabf0;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Check if Web Bluetooth API is available in the current browser.
|
|
12
|
+
*
|
|
13
|
+
* @returns true if Web Bluetooth is supported
|
|
14
|
+
*/
|
|
15
|
+
const isWebBluetoothSupported = (): boolean => {
|
|
16
|
+
return typeof navigator !== "undefined" && "bluetooth" in navigator;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Scan for nearby Edilkamin stoves using the Web Bluetooth API.
|
|
21
|
+
*
|
|
22
|
+
* This function triggers the browser's Bluetooth device picker dialog,
|
|
23
|
+
* filtered to show only devices named "EDILKAMIN_EP".
|
|
24
|
+
*
|
|
25
|
+
* Note: Web Bluetooth requires:
|
|
26
|
+
* - HTTPS or localhost
|
|
27
|
+
* - User gesture (button click)
|
|
28
|
+
* - Chrome/Edge/Opera (not Firefox/Safari)
|
|
29
|
+
*
|
|
30
|
+
* @returns Promise resolving to array of discovered devices
|
|
31
|
+
* @throws Error if Web Bluetooth is not supported or user cancels
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* const devices = await scanForDevices();
|
|
35
|
+
* console.log(devices[0].wifiMac); // Use this for API calls
|
|
36
|
+
*/
|
|
37
|
+
const scanForDevices = async (): Promise<DiscoveredDevice[]> => {
|
|
38
|
+
if (!isWebBluetoothSupported()) {
|
|
39
|
+
throw new Error(
|
|
40
|
+
"Web Bluetooth API is not supported in this browser. " +
|
|
41
|
+
"Use Chrome, Edge, or Opera on desktop/Android. " +
|
|
42
|
+
"On iOS, use the Bluefy browser app.",
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
// Request device - this opens the browser's device picker
|
|
48
|
+
const device = await navigator.bluetooth.requestDevice({
|
|
49
|
+
filters: [{ name: EDILKAMIN_DEVICE_NAME }],
|
|
50
|
+
optionalServices: [EDILKAMIN_SERVICE_UUID],
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// Extract BLE MAC from device ID if available
|
|
54
|
+
// Note: device.id format varies by platform, may need adjustment
|
|
55
|
+
const bleMac = device.id || "";
|
|
56
|
+
const name = device.name || EDILKAMIN_DEVICE_NAME;
|
|
57
|
+
|
|
58
|
+
// Calculate WiFi MAC for API calls
|
|
59
|
+
let wifiMac = "";
|
|
60
|
+
if (bleMac && /^[0-9a-f:-]{12,17}$/i.test(bleMac)) {
|
|
61
|
+
try {
|
|
62
|
+
wifiMac = bleToWifiMac(bleMac);
|
|
63
|
+
} catch {
|
|
64
|
+
// device.id may not be a valid MAC format on all platforms
|
|
65
|
+
wifiMac = "";
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const discoveredDevice: DiscoveredDevice = {
|
|
70
|
+
bleMac,
|
|
71
|
+
wifiMac,
|
|
72
|
+
name,
|
|
73
|
+
// RSSI not directly available from requestDevice
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
return [discoveredDevice];
|
|
77
|
+
} catch (error) {
|
|
78
|
+
if (error instanceof Error) {
|
|
79
|
+
if (error.name === "NotFoundError") {
|
|
80
|
+
// User cancelled the device picker
|
|
81
|
+
return [];
|
|
82
|
+
}
|
|
83
|
+
throw error;
|
|
84
|
+
}
|
|
85
|
+
throw new Error("Unknown error during Bluetooth scan");
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Scan for devices with a custom filter.
|
|
91
|
+
* Advanced function for users who need more control over device selection.
|
|
92
|
+
*
|
|
93
|
+
* @param options - Web Bluetooth requestDevice options
|
|
94
|
+
* @returns Promise resolving to the selected BluetoothDevice
|
|
95
|
+
*/
|
|
96
|
+
const scanWithOptions = async (
|
|
97
|
+
options: RequestDeviceOptions,
|
|
98
|
+
): Promise<BluetoothDevice> => {
|
|
99
|
+
if (!isWebBluetoothSupported()) {
|
|
100
|
+
throw new Error("Web Bluetooth API is not supported in this browser.");
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return navigator.bluetooth.requestDevice(options);
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export {
|
|
107
|
+
EDILKAMIN_DEVICE_NAME,
|
|
108
|
+
EDILKAMIN_SERVICE_UUID,
|
|
109
|
+
isWebBluetoothSupported,
|
|
110
|
+
scanForDevices,
|
|
111
|
+
scanWithOptions,
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
// Re-export DiscoveredDevice for convenience
|
|
115
|
+
export type { DiscoveredDevice } from "./types";
|
|
@@ -7,7 +7,7 @@ describe("browser-bundle", () => {
|
|
|
7
7
|
// without requiring Node.js built-in modules (fs, os, path).
|
|
8
8
|
// If this test fails, it means Node.js-only code has leaked into the main exports.
|
|
9
9
|
const result = await esbuild.build({
|
|
10
|
-
entryPoints: ["dist/esm/index.js"],
|
|
10
|
+
entryPoints: ["dist/esm/src/index.js"],
|
|
11
11
|
platform: "browser",
|
|
12
12
|
bundle: true,
|
|
13
13
|
write: false,
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { configure } from "./library";
|
|
2
2
|
|
|
3
|
+
export { bleToWifiMac } from "./bluetooth-utils";
|
|
3
4
|
export { decompressBuffer, isBuffer, processResponse } from "./buffer-utils";
|
|
4
5
|
export { API_URL, NEW_API_URL, OLD_API_URL } from "./constants";
|
|
5
6
|
export { configure, getSession, signIn } from "./library";
|
|
@@ -15,6 +16,7 @@ export {
|
|
|
15
16
|
DeviceAssociationResponse,
|
|
16
17
|
DeviceInfoRawType,
|
|
17
18
|
DeviceInfoType,
|
|
19
|
+
DiscoveredDevice,
|
|
18
20
|
EditDeviceAssociationBody,
|
|
19
21
|
StatusType,
|
|
20
22
|
TemperaturesType,
|
package/src/types.ts
CHANGED
|
@@ -82,6 +82,20 @@ interface DeviceAssociationResponse {
|
|
|
82
82
|
serialNumber: string;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Represents a discovered Edilkamin device from Bluetooth scanning.
|
|
87
|
+
*/
|
|
88
|
+
interface DiscoveredDevice {
|
|
89
|
+
/** BLE MAC address as discovered */
|
|
90
|
+
bleMac: string;
|
|
91
|
+
/** WiFi MAC address (BLE MAC - 2), used for API calls */
|
|
92
|
+
wifiMac: string;
|
|
93
|
+
/** Device name (typically "EDILKAMIN_EP") */
|
|
94
|
+
name: string;
|
|
95
|
+
/** Signal strength in dBm (optional, not all platforms provide this) */
|
|
96
|
+
rssi?: number;
|
|
97
|
+
}
|
|
98
|
+
|
|
85
99
|
export type {
|
|
86
100
|
BufferEncodedType,
|
|
87
101
|
CommandsType,
|
|
@@ -89,6 +103,7 @@ export type {
|
|
|
89
103
|
DeviceAssociationResponse,
|
|
90
104
|
DeviceInfoRawType,
|
|
91
105
|
DeviceInfoType,
|
|
106
|
+
DiscoveredDevice,
|
|
92
107
|
EditDeviceAssociationBody,
|
|
93
108
|
StatusType,
|
|
94
109
|
TemperaturesType,
|
package/tsconfig.cjs.json
CHANGED
package/tsconfig.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"target": "es6",
|
|
4
|
-
"
|
|
4
|
+
"lib": ["ES6", "DOM"],
|
|
5
5
|
"moduleResolution": "node",
|
|
6
6
|
"outDir": "dist",
|
|
7
|
-
"rootDir": "
|
|
7
|
+
"rootDir": ".",
|
|
8
8
|
"strict": true,
|
|
9
9
|
"declaration": true,
|
|
10
10
|
"esModuleInterop": true,
|
|
@@ -13,5 +13,5 @@
|
|
|
13
13
|
"noUnusedParameters": true,
|
|
14
14
|
"preserveConstEnums": true
|
|
15
15
|
},
|
|
16
|
-
"include": ["src/**/*.ts"]
|
|
16
|
+
"include": ["src/**/*.ts", "package.json"]
|
|
17
17
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|