matterbridge 3.0.7-dev-20250620-076b34c → 3.0.7
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/CHANGELOG.md +3 -2
- package/README-DEV.md +4 -4
- package/dist/cli.d.ts +29 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +62 -2
- package/dist/cli.js.map +1 -0
- package/dist/clusters/export.d.ts +2 -0
- package/dist/clusters/export.d.ts.map +1 -0
- package/dist/clusters/export.js +2 -0
- package/dist/clusters/export.js.map +1 -0
- package/dist/defaultConfigSchema.d.ts +27 -0
- package/dist/defaultConfigSchema.d.ts.map +1 -0
- package/dist/defaultConfigSchema.js +23 -0
- package/dist/defaultConfigSchema.js.map +1 -0
- package/dist/deviceManager.d.ts +114 -0
- package/dist/deviceManager.d.ts.map +1 -0
- package/dist/deviceManager.js +94 -1
- package/dist/deviceManager.js.map +1 -0
- package/dist/devices/export.d.ts +5 -0
- package/dist/devices/export.d.ts.map +1 -0
- package/dist/devices/export.js +2 -0
- package/dist/devices/export.js.map +1 -0
- package/dist/evse.d.ts +67 -0
- package/dist/evse.d.ts.map +1 -0
- package/dist/evse.js +65 -9
- package/dist/evse.js.map +1 -0
- package/dist/frontend.d.ts +256 -0
- package/dist/frontend.d.ts.map +1 -0
- package/dist/frontend.js +374 -16
- package/dist/frontend.js.map +1 -0
- package/dist/globalMatterbridge.d.ts +32 -0
- package/dist/globalMatterbridge.d.ts.map +1 -0
- package/dist/globalMatterbridge.js +20 -0
- package/dist/globalMatterbridge.js.map +1 -0
- package/dist/helpers.d.ts +47 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +51 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -1
- package/dist/index.js.map +1 -0
- package/dist/laundryWasher.d.ts +243 -0
- package/dist/laundryWasher.d.ts.map +1 -0
- package/dist/laundryWasher.js +92 -7
- package/dist/laundryWasher.js.map +1 -0
- package/dist/logger/export.d.ts +2 -0
- package/dist/logger/export.d.ts.map +1 -0
- package/dist/logger/export.js +1 -0
- package/dist/logger/export.js.map +1 -0
- package/dist/matter/behaviors.d.ts +2 -0
- package/dist/matter/behaviors.d.ts.map +1 -0
- package/dist/matter/behaviors.js +2 -0
- package/dist/matter/behaviors.js.map +1 -0
- package/dist/matter/clusters.d.ts +2 -0
- package/dist/matter/clusters.d.ts.map +1 -0
- package/dist/matter/clusters.js +2 -0
- package/dist/matter/clusters.js.map +1 -0
- package/dist/matter/devices.d.ts +2 -0
- package/dist/matter/devices.d.ts.map +1 -0
- package/dist/matter/devices.js +2 -0
- package/dist/matter/devices.js.map +1 -0
- package/dist/matter/endpoints.d.ts +2 -0
- package/dist/matter/endpoints.d.ts.map +1 -0
- package/dist/matter/endpoints.js +2 -0
- package/dist/matter/endpoints.js.map +1 -0
- package/dist/matter/export.d.ts +5 -0
- package/dist/matter/export.d.ts.map +1 -0
- package/dist/matter/export.js +2 -0
- package/dist/matter/export.js.map +1 -0
- package/dist/matter/types.d.ts +3 -0
- package/dist/matter/types.d.ts.map +1 -0
- package/dist/matter/types.js +2 -0
- package/dist/matter/types.js.map +1 -0
- package/dist/matterbridge.d.ts +445 -0
- package/dist/matterbridge.d.ts.map +1 -0
- package/dist/matterbridge.js +748 -46
- package/dist/matterbridge.js.map +1 -0
- package/dist/matterbridgeAccessoryPlatform.d.ts +40 -0
- package/dist/matterbridgeAccessoryPlatform.d.ts.map +1 -0
- package/dist/matterbridgeAccessoryPlatform.js +34 -0
- package/dist/matterbridgeAccessoryPlatform.js.map +1 -0
- package/dist/matterbridgeBehaviors.d.ts +1333 -0
- package/dist/matterbridgeBehaviors.d.ts.map +1 -0
- package/dist/matterbridgeBehaviors.js +54 -1
- package/dist/matterbridgeBehaviors.js.map +1 -0
- package/dist/matterbridgeDeviceTypes.d.ts +644 -0
- package/dist/matterbridgeDeviceTypes.d.ts.map +1 -0
- package/dist/matterbridgeDeviceTypes.js +578 -15
- package/dist/matterbridgeDeviceTypes.js.map +1 -0
- package/dist/matterbridgeDynamicPlatform.d.ts +40 -0
- package/dist/matterbridgeDynamicPlatform.d.ts.map +1 -0
- package/dist/matterbridgeDynamicPlatform.js +34 -0
- package/dist/matterbridgeDynamicPlatform.js.map +1 -0
- package/dist/matterbridgeEndpoint.d.ts +1145 -0
- package/dist/matterbridgeEndpoint.d.ts.map +1 -0
- package/dist/matterbridgeEndpoint.js +995 -40
- package/dist/matterbridgeEndpoint.js.map +1 -0
- package/dist/matterbridgeEndpointHelpers.d.ts +3083 -0
- package/dist/matterbridgeEndpointHelpers.d.ts.map +1 -0
- package/dist/matterbridgeEndpointHelpers.js +204 -10
- package/dist/matterbridgeEndpointHelpers.js.map +1 -0
- package/dist/matterbridgePlatform.d.ts +290 -0
- package/dist/matterbridgePlatform.d.ts.map +1 -0
- package/dist/matterbridgePlatform.js +221 -6
- package/dist/matterbridgePlatform.js.map +1 -0
- package/dist/matterbridgeTypes.d.ts +196 -0
- package/dist/matterbridgeTypes.d.ts.map +1 -0
- package/dist/matterbridgeTypes.js +24 -0
- package/dist/matterbridgeTypes.js.map +1 -0
- package/dist/pluginManager.d.ts +273 -0
- package/dist/pluginManager.d.ts.map +1 -0
- package/dist/pluginManager.js +269 -3
- package/dist/pluginManager.js.map +1 -0
- package/dist/roboticVacuumCleaner.d.ts +102 -0
- package/dist/roboticVacuumCleaner.d.ts.map +1 -0
- package/dist/roboticVacuumCleaner.js +81 -6
- package/dist/roboticVacuumCleaner.js.map +1 -0
- package/dist/shelly.d.ts +161 -0
- package/dist/shelly.d.ts.map +1 -0
- package/dist/shelly.js +155 -7
- package/dist/shelly.js.map +1 -0
- package/dist/storage/export.d.ts +2 -0
- package/dist/storage/export.d.ts.map +1 -0
- package/dist/storage/export.js +1 -0
- package/dist/storage/export.js.map +1 -0
- package/dist/update.d.ts +58 -0
- package/dist/update.d.ts.map +1 -0
- package/dist/update.js +53 -0
- package/dist/update.js.map +1 -0
- package/dist/utils/colorUtils.d.ts +61 -0
- package/dist/utils/colorUtils.d.ts.map +1 -0
- package/dist/utils/colorUtils.js +205 -2
- package/dist/utils/colorUtils.js.map +1 -0
- package/dist/utils/commandLine.d.ts +58 -0
- package/dist/utils/commandLine.d.ts.map +1 -0
- package/dist/utils/commandLine.js +53 -0
- package/dist/utils/commandLine.js.map +1 -0
- package/dist/utils/copyDirectory.d.ts +32 -0
- package/dist/utils/copyDirectory.d.ts.map +1 -0
- package/dist/utils/copyDirectory.js +37 -1
- package/dist/utils/copyDirectory.js.map +1 -0
- package/dist/utils/createDirectory.d.ts +32 -0
- package/dist/utils/createDirectory.d.ts.map +1 -0
- package/dist/utils/createDirectory.js +31 -0
- package/dist/utils/createDirectory.js.map +1 -0
- package/dist/utils/createZip.d.ts +38 -0
- package/dist/utils/createZip.d.ts.map +1 -0
- package/dist/utils/createZip.js +42 -2
- package/dist/utils/createZip.js.map +1 -0
- package/dist/utils/deepCopy.d.ts +31 -0
- package/dist/utils/deepCopy.d.ts.map +1 -0
- package/dist/utils/deepCopy.js +38 -0
- package/dist/utils/deepCopy.js.map +1 -0
- package/dist/utils/deepEqual.d.ts +53 -0
- package/dist/utils/deepEqual.d.ts.map +1 -0
- package/dist/utils/deepEqual.js +71 -1
- package/dist/utils/deepEqual.js.map +1 -0
- package/dist/utils/export.d.ts +12 -0
- package/dist/utils/export.d.ts.map +1 -0
- package/dist/utils/export.js +1 -0
- package/dist/utils/export.js.map +1 -0
- package/dist/utils/hex.d.ts +48 -0
- package/dist/utils/hex.d.ts.map +1 -0
- package/dist/utils/hex.js +57 -0
- package/dist/utils/hex.js.map +1 -0
- package/dist/utils/isvalid.d.ts +102 -0
- package/dist/utils/isvalid.d.ts.map +1 -0
- package/dist/utils/isvalid.js +100 -0
- package/dist/utils/isvalid.js.map +1 -0
- package/dist/utils/network.d.ts +69 -0
- package/dist/utils/network.d.ts.map +1 -0
- package/dist/utils/network.js +76 -5
- package/dist/utils/network.js.map +1 -0
- package/dist/utils/spawn.d.ts +12 -0
- package/dist/utils/spawn.d.ts.map +1 -0
- package/dist/utils/spawn.js +16 -0
- package/dist/utils/spawn.js.map +1 -0
- package/dist/utils/wait.d.ts +52 -0
- package/dist/utils/wait.d.ts.map +1 -0
- package/dist/utils/wait.js +58 -9
- package/dist/utils/wait.js.map +1 -0
- package/dist/waterHeater.d.ts +90 -0
- package/dist/waterHeater.d.ts.map +1 -0
- package/dist/waterHeater.js +62 -2
- package/dist/waterHeater.js.map +1 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -1
package/dist/shelly.js
CHANGED
|
@@ -1,13 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the shelly api functions.
|
|
3
|
+
*
|
|
4
|
+
* @file shelly.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @date 2025-02-19
|
|
7
|
+
* @version 1.1.0
|
|
8
|
+
*
|
|
9
|
+
* Copyright 2025, 2026, 2027 Luca Liguori.
|
|
10
|
+
*
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License. *
|
|
22
|
+
*/
|
|
1
23
|
import { WS_ID_SHELLY_MAIN_UPDATE, WS_ID_SHELLY_SYS_UPDATE } from './frontend.js';
|
|
2
24
|
import { debugStringify } from './logger/export.js';
|
|
3
25
|
let verifyIntervalSecs = 15;
|
|
4
26
|
let verifyTimeoutSecs = 600;
|
|
27
|
+
/**
|
|
28
|
+
* Sets the interval for verification in seconds.
|
|
29
|
+
*
|
|
30
|
+
* @param {number} seconds - The interval in seconds.
|
|
31
|
+
* @returns {void}
|
|
32
|
+
*/
|
|
5
33
|
export function setVerifyIntervalSecs(seconds) {
|
|
6
34
|
verifyIntervalSecs = seconds;
|
|
7
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Sets the timeout for verification in seconds.
|
|
38
|
+
*
|
|
39
|
+
* @param {number} seconds - The timeout in seconds.
|
|
40
|
+
* @returns {void}
|
|
41
|
+
*/
|
|
8
42
|
export function setVerifyTimeoutSecs(seconds) {
|
|
9
43
|
verifyTimeoutSecs = seconds;
|
|
10
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Fetches Shelly system updates. If available: logs the result, sends a snackbar message, and broadcasts the message.
|
|
47
|
+
*
|
|
48
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
49
|
+
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
50
|
+
*/
|
|
11
51
|
export async function getShellySysUpdate(matterbridge) {
|
|
12
52
|
try {
|
|
13
53
|
const updates = (await getShelly('/api/updates/sys/check'));
|
|
@@ -26,19 +66,33 @@ export async function getShellySysUpdate(matterbridge) {
|
|
|
26
66
|
matterbridge.log.error(`Error getting Shelly system updates: ${err instanceof Error ? err.message : String(err)}`);
|
|
27
67
|
}
|
|
28
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Triggers Shelly system updates.
|
|
71
|
+
*
|
|
72
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
73
|
+
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
74
|
+
*/
|
|
29
75
|
export async function triggerShellySysUpdate(matterbridge) {
|
|
30
76
|
try {
|
|
77
|
+
// Trigger the update request
|
|
31
78
|
await getShelly('/api/updates/sys/perform');
|
|
32
79
|
matterbridge.log.notice('Installing Shelly system update...');
|
|
33
80
|
matterbridge.matterbridgeInformation.shellySysUpdate = false;
|
|
34
81
|
matterbridge.frontend.wssSendSnackbarMessage('Installing Shelly system update...', 15);
|
|
35
82
|
matterbridge.frontend.wssBroadcastMessage(WS_ID_SHELLY_SYS_UPDATE, 'shelly-sys-update', { available: false });
|
|
83
|
+
// Begin polling update status
|
|
36
84
|
await verifyShellyUpdate(matterbridge, '/api/updates/sys/status', 'Shelly system update');
|
|
37
85
|
}
|
|
38
86
|
catch (err) {
|
|
39
87
|
matterbridge.log.error(`Error triggering Shelly system update: ${err instanceof Error ? err.message : String(err)}`);
|
|
40
88
|
}
|
|
41
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Fetches Shelly main updates. If available: logs the result, sends a snackbar message, and broadcasts the message.
|
|
92
|
+
*
|
|
93
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
94
|
+
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
95
|
+
*/
|
|
42
96
|
export async function getShellyMainUpdate(matterbridge) {
|
|
43
97
|
try {
|
|
44
98
|
const updates = (await getShelly('/api/updates/main/check'));
|
|
@@ -57,19 +111,33 @@ export async function getShellyMainUpdate(matterbridge) {
|
|
|
57
111
|
matterbridge.log.error(`Error getting Shelly main updates: ${err instanceof Error ? err.message : String(err)}`);
|
|
58
112
|
}
|
|
59
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* Triggers Shelly main updates.
|
|
116
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
117
|
+
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
118
|
+
*/
|
|
60
119
|
export async function triggerShellyMainUpdate(matterbridge) {
|
|
61
120
|
try {
|
|
121
|
+
// Trigger the perform-update request
|
|
62
122
|
await getShelly('/api/updates/main/perform');
|
|
63
123
|
matterbridge.log.notice('Installing Shelly software update...');
|
|
64
124
|
matterbridge.matterbridgeInformation.shellyMainUpdate = false;
|
|
65
125
|
matterbridge.frontend.wssSendSnackbarMessage('Installing Shelly software update...', 15);
|
|
66
126
|
matterbridge.frontend.wssBroadcastMessage(WS_ID_SHELLY_MAIN_UPDATE, 'shelly-main-update', { available: false });
|
|
127
|
+
// Begin polling the update status
|
|
67
128
|
await verifyShellyUpdate(matterbridge, '/api/updates/main/status', 'Shelly software update');
|
|
68
129
|
}
|
|
69
130
|
catch (err) {
|
|
70
131
|
matterbridge.log.error(`Error triggering Shelly main update: ${err instanceof Error ? err.message : String(err)}`);
|
|
71
132
|
}
|
|
72
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Verifies Shelly update.
|
|
136
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
137
|
+
* @param {string} api - The api to call: /api/updates/sys/status or /api/updates/main/status
|
|
138
|
+
* @param {string} name - The name of the update.
|
|
139
|
+
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
140
|
+
*/
|
|
73
141
|
export async function verifyShellyUpdate(matterbridge, api, name) {
|
|
74
142
|
return new Promise((resolve) => {
|
|
75
143
|
const timeout = setTimeout(() => {
|
|
@@ -77,9 +145,9 @@ export async function verifyShellyUpdate(matterbridge, api, name) {
|
|
|
77
145
|
matterbridge.frontend.wssSendCloseSnackbarMessage(`${name} in progress...`);
|
|
78
146
|
clearInterval(interval);
|
|
79
147
|
resolve();
|
|
80
|
-
}, verifyTimeoutSecs * 1000);
|
|
148
|
+
}, verifyTimeoutSecs * 1000); // 10 minutes
|
|
81
149
|
const interval = setInterval(() => {
|
|
82
|
-
getShelly(api, 10 * 1000)
|
|
150
|
+
getShelly(api, 10 * 1000) // 10 seconds
|
|
83
151
|
.then(async (data) => {
|
|
84
152
|
if (data.updatingInProgress) {
|
|
85
153
|
matterbridge.log.debug(`${name} in progress...`);
|
|
@@ -101,9 +169,15 @@ export async function verifyShellyUpdate(matterbridge, api, name) {
|
|
|
101
169
|
clearTimeout(timeout);
|
|
102
170
|
resolve();
|
|
103
171
|
});
|
|
104
|
-
}, verifyIntervalSecs * 1000);
|
|
172
|
+
}, verifyIntervalSecs * 1000); // 15 seconds
|
|
105
173
|
});
|
|
106
174
|
}
|
|
175
|
+
/**
|
|
176
|
+
* Triggers Shelly change network configuration.
|
|
177
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
178
|
+
* @param {object} config - The network configuration.
|
|
179
|
+
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
180
|
+
*/
|
|
107
181
|
export async function triggerShellyChangeIp(matterbridge, config) {
|
|
108
182
|
const api = config.type === 'static' ? '/api/network/connection/static' : '/api/network/connection/dynamic';
|
|
109
183
|
const data = { interface: 'end0' };
|
|
@@ -126,6 +200,11 @@ export async function triggerShellyChangeIp(matterbridge, config) {
|
|
|
126
200
|
matterbridge.frontend.wssSendSnackbarMessage('Error changing Shelly network configuration', 10, 'error');
|
|
127
201
|
}
|
|
128
202
|
}
|
|
203
|
+
/**
|
|
204
|
+
* Triggers Shelly system reboot.
|
|
205
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
206
|
+
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
207
|
+
*/
|
|
129
208
|
export async function triggerShellyReboot(matterbridge) {
|
|
130
209
|
matterbridge.log.debug(`Triggering Shelly system reboot`);
|
|
131
210
|
try {
|
|
@@ -143,6 +222,13 @@ export async function triggerShellyReboot(matterbridge) {
|
|
|
143
222
|
matterbridge.frontend.wssSendSnackbarMessage('Error rebooting Shelly board', 10, 'error');
|
|
144
223
|
}
|
|
145
224
|
}
|
|
225
|
+
/**
|
|
226
|
+
* Triggers Shelly soft reset.
|
|
227
|
+
* It will replaces network config with the default one (edn0 on dhcp).
|
|
228
|
+
*
|
|
229
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
230
|
+
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
231
|
+
*/
|
|
146
232
|
export async function triggerShellySoftReset(matterbridge) {
|
|
147
233
|
matterbridge.log.debug(`Triggering Shelly soft reset`);
|
|
148
234
|
try {
|
|
@@ -160,6 +246,13 @@ export async function triggerShellySoftReset(matterbridge) {
|
|
|
160
246
|
matterbridge.frontend.wssSendSnackbarMessage('Error resetting the network parameters on Shelly board', 10, 'error');
|
|
161
247
|
}
|
|
162
248
|
}
|
|
249
|
+
/**
|
|
250
|
+
* Triggers Shelly hard reset.
|
|
251
|
+
* It will do a hard reset and will remove both directories .matterbridge Matterbridge.
|
|
252
|
+
*
|
|
253
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
254
|
+
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
255
|
+
*/
|
|
163
256
|
export async function triggerShellyHardReset(matterbridge) {
|
|
164
257
|
matterbridge.log.debug(`Triggering Shelly hard reset`);
|
|
165
258
|
try {
|
|
@@ -177,6 +270,12 @@ export async function triggerShellyHardReset(matterbridge) {
|
|
|
177
270
|
matterbridge.frontend.wssSendSnackbarMessage('Error while factory resetting the Shelly board', 10, 'error');
|
|
178
271
|
}
|
|
179
272
|
}
|
|
273
|
+
/**
|
|
274
|
+
* Fetches Shelly system log and write it to shelly.log.
|
|
275
|
+
*
|
|
276
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
277
|
+
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
278
|
+
*/
|
|
180
279
|
export async function createShellySystemLog(matterbridge) {
|
|
181
280
|
const { promises: fs } = await import('node:fs');
|
|
182
281
|
const path = await import('node:path');
|
|
@@ -191,6 +290,27 @@ export async function createShellySystemLog(matterbridge) {
|
|
|
191
290
|
matterbridge.log.error(`Error getting Shelly system log: ${error instanceof Error ? error.message : error}`);
|
|
192
291
|
}
|
|
193
292
|
}
|
|
293
|
+
/**
|
|
294
|
+
* Perform a GET to Shelly board apis.
|
|
295
|
+
* @param {string} api - The api to call:
|
|
296
|
+
*
|
|
297
|
+
* /api/updates/sys/check => [{name:string; ...}]
|
|
298
|
+
* /api/updates/sys/perform => {"updatingInProgress":true} or {"updatingInProgress":false}
|
|
299
|
+
* /api/updates/sys/status => {"updatingInProgress":true} or {"updatingInProgress":false}
|
|
300
|
+
* /api/updates/main/check => [{name:string; ...}]
|
|
301
|
+
* /api/updates/main/perform => {"updatingInProgress":true} or {"updatingInProgress":false}
|
|
302
|
+
* /api/updates/main/status => {"updatingInProgress":true} or {"updatingInProgress":false}
|
|
303
|
+
*
|
|
304
|
+
* /api/logs/system => text
|
|
305
|
+
*
|
|
306
|
+
* /api/reset/soft => "ok" Replaces network config with default one (edn0 on dhcp)
|
|
307
|
+
* /api/reset/hard => reboot on success Hard reset makes soft reset + removing both directories .matterbridge Matterbridge + reboot
|
|
308
|
+
*
|
|
309
|
+
*
|
|
310
|
+
* @param {number} [timeout=60000] - The timeout duration in milliseconds (default is 60000ms).
|
|
311
|
+
* @returns {Promise<any>} A promise that resolves to the response.
|
|
312
|
+
* @throws {Error} If the request fails.
|
|
313
|
+
*/
|
|
194
314
|
export async function getShelly(api, timeout = 60000) {
|
|
195
315
|
const http = await import('node:http');
|
|
196
316
|
return new Promise((resolve, reject) => {
|
|
@@ -204,12 +324,13 @@ export async function getShelly(api, timeout = 60000) {
|
|
|
204
324
|
let data = '';
|
|
205
325
|
if (res.statusCode !== 200) {
|
|
206
326
|
clearTimeout(timeoutId);
|
|
207
|
-
res.resume();
|
|
208
|
-
req.destroy();
|
|
327
|
+
res.resume(); // Discard response data to close the socket properly
|
|
328
|
+
req.destroy(); // Forcefully close the request
|
|
209
329
|
reject(new Error(`Failed to fetch data. Status code: ${res.statusCode}`));
|
|
210
330
|
return;
|
|
211
331
|
}
|
|
212
332
|
res.on('data', (chunk) => {
|
|
333
|
+
// console.log(chunk);
|
|
213
334
|
data += chunk;
|
|
214
335
|
});
|
|
215
336
|
res.on('end', () => {
|
|
@@ -224,6 +345,7 @@ export async function getShelly(api, timeout = 60000) {
|
|
|
224
345
|
}
|
|
225
346
|
}
|
|
226
347
|
else {
|
|
348
|
+
// console.log(data);
|
|
227
349
|
resolve(data);
|
|
228
350
|
}
|
|
229
351
|
});
|
|
@@ -234,6 +356,29 @@ export async function getShelly(api, timeout = 60000) {
|
|
|
234
356
|
});
|
|
235
357
|
});
|
|
236
358
|
}
|
|
359
|
+
/**
|
|
360
|
+
* Perform a POST request to Shelly board apis.
|
|
361
|
+
* @param {string} api - The api to call:
|
|
362
|
+
*
|
|
363
|
+
* Set static ip
|
|
364
|
+
* /api/network/connection/static -d '{"interface": "end0", "addr": "10.11.12.101", "mask": "255.255.255.0", "gw": "10.11.12.1", "dns": "1.1.1.1"}' => {}
|
|
365
|
+
*
|
|
366
|
+
* Set dhcp
|
|
367
|
+
* /api/network/connection/dynamic -d '{"interface": "end0"}' => {}
|
|
368
|
+
*
|
|
369
|
+
* Reboot
|
|
370
|
+
* /api/system/reboot => {"success":true}
|
|
371
|
+
*
|
|
372
|
+
* curl -H "Content-Type: application/json" -X POST http://127.0.0.1:8101/api/network/connection/dynamic
|
|
373
|
+
* -d '{"interface": "end0"}'
|
|
374
|
+
*
|
|
375
|
+
* curl -H "Content-Type: application/json" -X POST http://127.0.0.1:8101/api/network/connection/static
|
|
376
|
+
* -d '{"interface": "end0", "addr": "192.168.1.64", "mask": "255.255.255.0", "gw": "192.168.1.1", "dns": "192.168.1.1"}'
|
|
377
|
+
*
|
|
378
|
+
* @param {number} [timeout=60000] - The timeout duration in milliseconds (default is 60000ms).
|
|
379
|
+
* @returns {Promise<any>} A promise that resolves to the response.
|
|
380
|
+
* @throws {Error} If the request fails.
|
|
381
|
+
*/
|
|
237
382
|
export async function postShelly(api, data, timeout = 60000) {
|
|
238
383
|
const http = await import('node:http');
|
|
239
384
|
return new Promise((resolve, reject) => {
|
|
@@ -254,10 +399,11 @@ export async function postShelly(api, data, timeout = 60000) {
|
|
|
254
399
|
};
|
|
255
400
|
const req = http.request(url, options, (res) => {
|
|
256
401
|
let responseData = '';
|
|
402
|
+
// Check for non-success status codes (e.g., 300+)
|
|
257
403
|
if (res.statusCode && res.statusCode >= 300) {
|
|
258
404
|
clearTimeout(timeoutId);
|
|
259
|
-
res.resume();
|
|
260
|
-
req.destroy();
|
|
405
|
+
res.resume(); // Discard response data to free up memory
|
|
406
|
+
req.destroy(); // Close the request
|
|
261
407
|
return reject(new Error(`Failed to post data. Status code: ${res.statusCode}`));
|
|
262
408
|
}
|
|
263
409
|
res.on('data', (chunk) => {
|
|
@@ -278,7 +424,9 @@ export async function postShelly(api, data, timeout = 60000) {
|
|
|
278
424
|
clearTimeout(timeoutId);
|
|
279
425
|
reject(new Error(`Request failed: ${error instanceof Error ? error.message : error}`));
|
|
280
426
|
});
|
|
427
|
+
// Send the JSON data
|
|
281
428
|
req.write(jsonData);
|
|
282
429
|
req.end();
|
|
283
430
|
});
|
|
284
431
|
}
|
|
432
|
+
//# sourceMappingURL=shelly.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shelly.js","sourceRoot":"","sources":["../src/shelly.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAKH,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGpD,IAAI,kBAAkB,GAAG,EAAE,CAAC;AAC5B,IAAI,iBAAiB,GAAG,GAAG,CAAC;AAE5B;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAAe;IACnD,kBAAkB,GAAG,OAAO,CAAC;AAC/B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAe;IAClD,iBAAiB,GAAG,OAAO,CAAC;AAC9B,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,YAA0B;IACjE,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,CAAC,MAAM,SAAS,CAAC,wBAAwB,CAAC,CAAuB,CAAC;QAClF,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO;QAEjC,YAAY,CAAC,uBAAuB,CAAC,eAAe,GAAG,IAAI,CAAC;QAC5D,YAAY,CAAC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AC;QACpB,GAAG,CAAC,GAAG,EAAE,CAAC;IACZ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/storage/export.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
|
package/dist/storage/export.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.js","sourceRoot":"","sources":["../../src/storage/export.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
|
package/dist/update.d.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the check updates functions.
|
|
3
|
+
*
|
|
4
|
+
* @file update.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @date 2025-02-24
|
|
7
|
+
* @version 1.0.0
|
|
8
|
+
*
|
|
9
|
+
* Copyright 2025, 2026, 2027 Luca Liguori.
|
|
10
|
+
*
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License. *
|
|
22
|
+
*/
|
|
23
|
+
import { Matterbridge } from './matterbridge.js';
|
|
24
|
+
import { RegisteredPlugin } from './matterbridgeTypes.js';
|
|
25
|
+
/**
|
|
26
|
+
* Checks for updates for Matterbridge and its plugins.
|
|
27
|
+
* If the 'shelly' parameter is present, also checks for Shelly updates.
|
|
28
|
+
*
|
|
29
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
30
|
+
* @returns {Promise<void>} A promise that resolves when the update checks are complete.
|
|
31
|
+
*/
|
|
32
|
+
export declare function checkUpdates(matterbridge: Matterbridge): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Retrieves the latest version of Matterbridge and updates the matterbridgeLatestVersion property.
|
|
35
|
+
* If there is an error retrieving the latest version, logs an error message.
|
|
36
|
+
*
|
|
37
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
38
|
+
* @returns {Promise<String | undefined>} A promise that resolves when the latest version is retrieved.
|
|
39
|
+
*/
|
|
40
|
+
export declare function getMatterbridgeLatestVersion(matterbridge: Matterbridge): Promise<string | undefined>;
|
|
41
|
+
/**
|
|
42
|
+
* Retrieves the latest dev version of Matterbridge and updates the matterbridgeDevVersion property.
|
|
43
|
+
* If there is an error retrieving the latest version, logs an error message.
|
|
44
|
+
*
|
|
45
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
46
|
+
* @returns {Promise<string | undefined>} A promise that resolves when the latest dev version is retrieved.
|
|
47
|
+
*/
|
|
48
|
+
export declare function getMatterbridgeDevVersion(matterbridge: Matterbridge): Promise<string | undefined>;
|
|
49
|
+
/**
|
|
50
|
+
* Retrieves the latest version of a plugin and updates the plugin's latestVersion property.
|
|
51
|
+
* If there is an error retrieving the latest version, logs an error message.
|
|
52
|
+
*
|
|
53
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
54
|
+
* @param {RegisteredPlugin} plugin - The plugin for which to retrieve the latest version.
|
|
55
|
+
* @returns {Promise<string | undefined>} A promise that resolves when the latest version is retrieved.
|
|
56
|
+
*/
|
|
57
|
+
export declare function getPluginLatestVersion(matterbridge: Matterbridge, plugin: RegisteredPlugin): Promise<string | undefined>;
|
|
58
|
+
//# sourceMappingURL=update.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../src/update.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAMH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAO,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAqB5E;AAED;;;;;;GAMG;AACH,wBAAsB,4BAA4B,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAmB1G;AAED;;;;;;GAMG;AACH,wBAAsB,yBAAyB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAmBvG;AAED;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAAC,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAgB9H"}
|
package/dist/update.js
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the check updates functions.
|
|
3
|
+
*
|
|
4
|
+
* @file update.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @date 2025-02-24
|
|
7
|
+
* @version 1.0.0
|
|
8
|
+
*
|
|
9
|
+
* Copyright 2025, 2026, 2027 Luca Liguori.
|
|
10
|
+
*
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License. *
|
|
22
|
+
*/
|
|
23
|
+
// AnsiLogger module
|
|
1
24
|
import { db, nt, wr } from 'node-ansi-logger';
|
|
2
25
|
import { plg } from './matterbridgeTypes.js';
|
|
26
|
+
/**
|
|
27
|
+
* Checks for updates for Matterbridge and its plugins.
|
|
28
|
+
* If the 'shelly' parameter is present, also checks for Shelly updates.
|
|
29
|
+
*
|
|
30
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
31
|
+
* @returns {Promise<void>} A promise that resolves when the update checks are complete.
|
|
32
|
+
*/
|
|
3
33
|
export async function checkUpdates(matterbridge) {
|
|
4
34
|
const { hasParameter } = await import('./utils/commandLine.js');
|
|
5
35
|
const latestVersion = getMatterbridgeLatestVersion(matterbridge);
|
|
@@ -19,6 +49,13 @@ export async function checkUpdates(matterbridge) {
|
|
|
19
49
|
}
|
|
20
50
|
await Promise.all([latestVersion, devVersion, ...pluginsVersions, ...shellyUpdates]);
|
|
21
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Retrieves the latest version of Matterbridge and updates the matterbridgeLatestVersion property.
|
|
54
|
+
* If there is an error retrieving the latest version, logs an error message.
|
|
55
|
+
*
|
|
56
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
57
|
+
* @returns {Promise<String | undefined>} A promise that resolves when the latest version is retrieved.
|
|
58
|
+
*/
|
|
22
59
|
export async function getMatterbridgeLatestVersion(matterbridge) {
|
|
23
60
|
const { getNpmPackageVersion } = await import('./utils/network.js');
|
|
24
61
|
try {
|
|
@@ -40,6 +77,13 @@ export async function getMatterbridgeLatestVersion(matterbridge) {
|
|
|
40
77
|
matterbridge.log.warn(`Error getting Matterbridge latest version: ${error instanceof Error ? error.message : error}`);
|
|
41
78
|
}
|
|
42
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* Retrieves the latest dev version of Matterbridge and updates the matterbridgeDevVersion property.
|
|
82
|
+
* If there is an error retrieving the latest version, logs an error message.
|
|
83
|
+
*
|
|
84
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
85
|
+
* @returns {Promise<string | undefined>} A promise that resolves when the latest dev version is retrieved.
|
|
86
|
+
*/
|
|
43
87
|
export async function getMatterbridgeDevVersion(matterbridge) {
|
|
44
88
|
const { getNpmPackageVersion } = await import('./utils/network.js');
|
|
45
89
|
try {
|
|
@@ -61,6 +105,14 @@ export async function getMatterbridgeDevVersion(matterbridge) {
|
|
|
61
105
|
matterbridge.log.warn(`Error getting Matterbridge latest dev version: ${error instanceof Error ? error.message : error}`);
|
|
62
106
|
}
|
|
63
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Retrieves the latest version of a plugin and updates the plugin's latestVersion property.
|
|
110
|
+
* If there is an error retrieving the latest version, logs an error message.
|
|
111
|
+
*
|
|
112
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
113
|
+
* @param {RegisteredPlugin} plugin - The plugin for which to retrieve the latest version.
|
|
114
|
+
* @returns {Promise<string | undefined>} A promise that resolves when the latest version is retrieved.
|
|
115
|
+
*/
|
|
64
116
|
export async function getPluginLatestVersion(matterbridge, plugin) {
|
|
65
117
|
const { getNpmPackageVersion } = await import('./utils/network.js');
|
|
66
118
|
try {
|
|
@@ -79,3 +131,4 @@ export async function getPluginLatestVersion(matterbridge, plugin) {
|
|
|
79
131
|
matterbridge.log.warn(`Error getting plugin ${plg}${plugin.name}${wr} latest version: ${error instanceof Error ? error.message : error}`);
|
|
80
132
|
}
|
|
81
133
|
}
|
|
134
|
+
//# sourceMappingURL=update.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update.js","sourceRoot":"","sources":["../src/update.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,oBAAoB;AACpB,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAI9C,OAAO,EAAE,GAAG,EAAoB,MAAM,wB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,MAAM,CAAC,cAAc,GAAG,GAAG,MAAM,CAAC,IAAI,GAAG,EAAE,qCAAqC,MAAM,CAAC,OAAO,qBAAqB,MAAM,CAAC,aAAa,GAAG,CAAC,CAAC;YAC7J,YAAY,CAAC,QAAQ,CAAC,sBAAsB,CAAC,SAAS,CAAC,CAAC;QAC1D,CAAC;aAAM,CAAC;YACN,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,cAAc,GAAG,GAAG,MAAM,CAAC,IAAI,GAAG,EAAE,oCAAoC,MAAM,CAAC,OAAO,qBAAqB,MAAM,CAAC,aAAa,GAAG,CAAC,CAAC;QAC7J,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,wBAAwB,GAAG,GAAG,MAAM,CAAC,IAAI,GAAG,EAAE,oBAAoB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;IAC5I,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the color utilities.
|
|
3
|
+
*
|
|
4
|
+
* @file colorUtils.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @date 2023-10-05
|
|
7
|
+
* @version 1.3.0
|
|
8
|
+
*
|
|
9
|
+
* Copyright 2023, 2024, 2025 Luca Liguori.
|
|
10
|
+
*
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License. *
|
|
22
|
+
*/
|
|
23
|
+
export interface RGB {
|
|
24
|
+
r: number;
|
|
25
|
+
g: number;
|
|
26
|
+
b: number;
|
|
27
|
+
}
|
|
28
|
+
export interface XY {
|
|
29
|
+
x: number;
|
|
30
|
+
y: number;
|
|
31
|
+
}
|
|
32
|
+
export interface HSL {
|
|
33
|
+
h: number;
|
|
34
|
+
s: number;
|
|
35
|
+
l: number;
|
|
36
|
+
}
|
|
37
|
+
export declare function hslColorToRgbColor(hue: number, saturation: number, luminance: number): RGB;
|
|
38
|
+
export declare function rgbColorToXYColor(rgb: RGB): XY;
|
|
39
|
+
export declare function xyColorToRgbColor(x: number, y: number, brightness?: number): RGB;
|
|
40
|
+
export declare function rgbColorToHslColor(rgb: RGB): HSL;
|
|
41
|
+
export declare function xyToHsl(x: number, y: number): HSL;
|
|
42
|
+
export declare function miredToKelvin(mired: number): number;
|
|
43
|
+
export declare function kelvinToMired(kelvin: number): number;
|
|
44
|
+
export declare function kelvinToRGB(kelvin: number): RGB;
|
|
45
|
+
/**
|
|
46
|
+
* Converts CIE color space to RGB color space
|
|
47
|
+
* @param {Number} x
|
|
48
|
+
* @param {Number} y
|
|
49
|
+
* @param {Number} brightness - Ranges from 1 to 254
|
|
50
|
+
* @return {Array} Array that contains the color values for red, green and blue
|
|
51
|
+
* From: https://github.com/usolved/cie-rgb-converter/blob/master/cie_rgb_converter.js
|
|
52
|
+
*/
|
|
53
|
+
/**
|
|
54
|
+
* Converts RGB color space to CIE color space
|
|
55
|
+
* @param {Number} red
|
|
56
|
+
* @param {Number} green
|
|
57
|
+
* @param {Number} blue
|
|
58
|
+
* @return {Array} Array that contains the CIE color values for x and y
|
|
59
|
+
* From: https://github.com/usolved/cie-rgb-converter/blob/master/cie_rgb_converter.js
|
|
60
|
+
*/
|
|
61
|
+
//# sourceMappingURL=colorUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colorUtils.d.ts","sourceRoot":"","sources":["../../src/utils/colorUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,MAAM,WAAW,GAAG;IAClB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,EAAE;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,GAAG;IAClB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,GAAG,CA+C1F;AAGD,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,GAAG,GAAG,EAAE,CA6B9C;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,UAAU,SAAM,GAAG,GAAG,CAgD7E;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,CAmChD;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,GAAG,CAGjD;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAsC/C;AAwDD;;;;;;;GAOG;AAsDH;;;;;;;GAOG"}
|