matterbridge 3.0.7-dev-20250618-fb768ee → 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
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the createZip function.
|
|
3
|
+
*
|
|
4
|
+
* @file createZip.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @date 2025-02-16
|
|
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
|
+
/**
|
|
24
|
+
* Creates a ZIP archive from the specified source pattern or directory and writes it to the specified output path.
|
|
25
|
+
*
|
|
26
|
+
* @param {string} outputPath - The path where the output ZIP file will be written.
|
|
27
|
+
* @param {string[]} sourcePaths - The source pattern or directory to be zipped (use path.join for sourcePath).
|
|
28
|
+
* @returns {Promise<number>} - A promise that resolves to the total number of bytes written to the ZIP file.
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* This function uses the `archiver` library to create a ZIP archive. It sets the compression level to 9 (maximum compression).
|
|
32
|
+
* The function ensures that the output file is properly closed after the archiving process is complete.
|
|
33
|
+
* It logs the progress and the total number of bytes written to the console.
|
|
34
|
+
*
|
|
35
|
+
* This function uses the `glob` library to match files based on the source pattern (internally converted in posix).
|
|
36
|
+
*/
|
|
37
|
+
export declare function createZip(outputPath: string, ...sourcePaths: string[]): Promise<number>;
|
|
38
|
+
//# sourceMappingURL=createZip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createZip.d.ts","sourceRoot":"","sources":["../../src/utils/createZip.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAQH;;;;;;;;;;;;;GAaG;AACH,wBAAsB,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,WAAW,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CA2E7F"}
|
package/dist/utils/createZip.js
CHANGED
|
@@ -1,6 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the createZip function.
|
|
3
|
+
*
|
|
4
|
+
* @file createZip.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @date 2025-02-16
|
|
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 { AnsiLogger } from '../logger/export.js';
|
|
25
|
+
/**
|
|
26
|
+
* Creates a ZIP archive from the specified source pattern or directory and writes it to the specified output path.
|
|
27
|
+
*
|
|
28
|
+
* @param {string} outputPath - The path where the output ZIP file will be written.
|
|
29
|
+
* @param {string[]} sourcePaths - The source pattern or directory to be zipped (use path.join for sourcePath).
|
|
30
|
+
* @returns {Promise<number>} - A promise that resolves to the total number of bytes written to the ZIP file.
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* This function uses the `archiver` library to create a ZIP archive. It sets the compression level to 9 (maximum compression).
|
|
34
|
+
* The function ensures that the output file is properly closed after the archiving process is complete.
|
|
35
|
+
* It logs the progress and the total number of bytes written to the console.
|
|
36
|
+
*
|
|
37
|
+
* This function uses the `glob` library to match files based on the source pattern (internally converted in posix).
|
|
38
|
+
*/
|
|
2
39
|
export async function createZip(outputPath, ...sourcePaths) {
|
|
3
|
-
const log = new AnsiLogger({ logName: 'Archive', logTimestampFormat: 4
|
|
40
|
+
const log = new AnsiLogger({ logName: 'Archive', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: "info" /* LogLevel.INFO */ });
|
|
4
41
|
const { default: archiver } = await import('archiver');
|
|
5
42
|
const { glob } = await import('glob');
|
|
6
43
|
const { createWriteStream, statSync } = await import('node:fs');
|
|
@@ -9,7 +46,7 @@ export async function createZip(outputPath, ...sourcePaths) {
|
|
|
9
46
|
return new Promise((resolve, reject) => {
|
|
10
47
|
const output = createWriteStream(outputPath);
|
|
11
48
|
const archive = archiver('zip', {
|
|
12
|
-
zlib: { level: 9 },
|
|
49
|
+
zlib: { level: 9 }, // Set compression level
|
|
13
50
|
});
|
|
14
51
|
output.on('close', () => {
|
|
15
52
|
log.debug(`archive ${outputPath} closed with ${archive.pointer()} total bytes`);
|
|
@@ -36,6 +73,7 @@ export async function createZip(outputPath, ...sourcePaths) {
|
|
|
36
73
|
});
|
|
37
74
|
archive.pipe(output);
|
|
38
75
|
for (const sourcePath of sourcePaths) {
|
|
76
|
+
// Check if the sourcePath is a file or directory
|
|
39
77
|
let stats;
|
|
40
78
|
try {
|
|
41
79
|
stats = statSync(sourcePath);
|
|
@@ -63,7 +101,9 @@ export async function createZip(outputPath, ...sourcePaths) {
|
|
|
63
101
|
archive.directory(sourcePath, path.basename(sourcePath));
|
|
64
102
|
}
|
|
65
103
|
}
|
|
104
|
+
// Finalize the archive (i.e., we are done appending files but streams have to finish yet)
|
|
66
105
|
log.debug(`finalizing archive ${outputPath}...`);
|
|
67
106
|
archive.finalize().catch(reject);
|
|
68
107
|
});
|
|
69
108
|
}
|
|
109
|
+
//# sourceMappingURL=createZip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createZip.js","sourceRoot":"","sources":["../../src/utils/createZip.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAKH,oBAAoB;AACpB,OAAO,EAAE,UAAU,EAA6B,MAAM,qBAAqB,CAAC;AAE5E;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,UAAkB,EAAE,GAAG,WAAqB;IAC1E,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,kBAAkB,qCAA6B,EAAE,QAAQ,4BAAe,EAAE,CAAC,CAAC;IAE7H,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC;IACvD,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC;IACtC,MAAM,EAAE,iBAAiB,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC;IAChE,MAAM,IAAI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gB,UAAU,EAAE,CAAC,CAAC;gBACxC,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;YAChE,CAAC;iBAAM,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;gBAC/B,GAAG,CAAC,KAAK,CAAC,qBAAqB,UAAU,EAAE,CAAC,CAAC;gBAC7C,OAAO,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;YAC3D,CAAC;QACH,CAAC;QACD,0FAA0F;QAC1F,GAAG,CAAC,KAAK,CAAC,sBAAsB,UAAU,KAAK,CAAC,CAAC;QACjD,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the deepCopy function.
|
|
3
|
+
*
|
|
4
|
+
* @file deepCopy.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @date 2025-02-16
|
|
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
|
+
/**
|
|
24
|
+
* Creates a deep copy of the given value.
|
|
25
|
+
*
|
|
26
|
+
* @template T - The type of the value being copied.
|
|
27
|
+
* @param {T} value - The value to be copied.
|
|
28
|
+
* @returns {T} - The deep copy of the value.
|
|
29
|
+
*/
|
|
30
|
+
export declare function deepCopy<T>(value: T): T;
|
|
31
|
+
//# sourceMappingURL=deepCopy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deepCopy.d.ts","sourceRoot":"","sources":["../../src/utils/deepCopy.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAwCvC"}
|
package/dist/utils/deepCopy.js
CHANGED
|
@@ -1,17 +1,52 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
/**
|
|
3
|
+
* This file contains the deepCopy function.
|
|
4
|
+
*
|
|
5
|
+
* @file deepCopy.ts
|
|
6
|
+
* @author Luca Liguori
|
|
7
|
+
* @date 2025-02-16
|
|
8
|
+
* @version 1.0.0
|
|
9
|
+
*
|
|
10
|
+
* Copyright 2025, 2026, 2027 Luca Liguori.
|
|
11
|
+
*
|
|
12
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
13
|
+
* you may not use this file except in compliance with the License.
|
|
14
|
+
* You may obtain a copy of the License at
|
|
15
|
+
*
|
|
16
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
17
|
+
*
|
|
18
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
19
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
20
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
|
+
* See the License for the specific language governing permissions and
|
|
22
|
+
* limitations under the License. *
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Creates a deep copy of the given value.
|
|
26
|
+
*
|
|
27
|
+
* @template T - The type of the value being copied.
|
|
28
|
+
* @param {T} value - The value to be copied.
|
|
29
|
+
* @returns {T} - The deep copy of the value.
|
|
30
|
+
*/
|
|
1
31
|
export function deepCopy(value) {
|
|
2
32
|
if (typeof value !== 'object' || value === null) {
|
|
33
|
+
// Primitive value (string, number, boolean, bigint, undefined, symbol) or null
|
|
3
34
|
return value;
|
|
4
35
|
}
|
|
5
36
|
else if (Array.isArray(value)) {
|
|
37
|
+
// Array: Recursively copy each element
|
|
6
38
|
return value.map((item) => deepCopy(item));
|
|
7
39
|
}
|
|
8
40
|
else if (value instanceof Date) {
|
|
41
|
+
// Date objects
|
|
9
42
|
return new Date(value.getTime());
|
|
10
43
|
}
|
|
11
44
|
else if (value instanceof RegExp) {
|
|
45
|
+
// RegExp objects
|
|
12
46
|
return new RegExp(value.source, value.flags);
|
|
13
47
|
}
|
|
14
48
|
else if (value instanceof Map) {
|
|
49
|
+
// Maps
|
|
15
50
|
const mapCopy = new Map();
|
|
16
51
|
for (const [origKey, origVal] of value.entries()) {
|
|
17
52
|
const clonedKey = deepCopy(origKey);
|
|
@@ -21,6 +56,7 @@ export function deepCopy(value) {
|
|
|
21
56
|
return mapCopy;
|
|
22
57
|
}
|
|
23
58
|
else if (value instanceof Set) {
|
|
59
|
+
// Sets
|
|
24
60
|
const setCopy = new Set();
|
|
25
61
|
value.forEach((item) => {
|
|
26
62
|
setCopy.add(deepCopy(item));
|
|
@@ -28,6 +64,7 @@ export function deepCopy(value) {
|
|
|
28
64
|
return setCopy;
|
|
29
65
|
}
|
|
30
66
|
else {
|
|
67
|
+
// Objects: Create a copy with the same prototype as the original
|
|
31
68
|
const proto = Object.getPrototypeOf(value);
|
|
32
69
|
const copy = Object.create(proto);
|
|
33
70
|
for (const key in value) {
|
|
@@ -38,3 +75,4 @@ export function deepCopy(value) {
|
|
|
38
75
|
return copy;
|
|
39
76
|
}
|
|
40
77
|
}
|
|
78
|
+
//# sourceMappingURL=deepCop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C;SAAM,IAAI,KAAK,YAAY,GAAG,EAAE,CAAC;QAChC,OAAO;QACP,MAAM,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACrB,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;QAC9B,CAAC,CAAC,CAAC;QACH,OAAO,OAAc,CAAC;IACxB,CAAC;SAAM,CAAC;QACN,iEAAiE;QACjE,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QAC3C,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAClC,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC;YACxB,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC;gBACrD,IAAI,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;YACnC,CAAC;QACH,CAAC;QACD,OAAO,IAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the deepEqual function.
|
|
3
|
+
*
|
|
4
|
+
* @file deepEqual.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @date 2025-02-16
|
|
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
|
+
/**
|
|
24
|
+
* Performs a deep comparison between two values to determine if they are equivalent.
|
|
25
|
+
* This comparison includes primitive types, arrays, and objects, allowing for optional
|
|
26
|
+
* exclusion of specific properties from the comparison in objects.
|
|
27
|
+
*
|
|
28
|
+
* @param {any} a The first value to compare.
|
|
29
|
+
* @param {any} b The second value to compare.
|
|
30
|
+
* @param {string[]} [excludeProperties=[]] An array of property names to exclude from the comparison in objects.
|
|
31
|
+
* @returns {boolean} True if the values are deeply equal, excluding any specified properties; otherwise, false.
|
|
32
|
+
*
|
|
33
|
+
* Note: This function utilizes recursion for deep comparison of nested structures and includes a debugging
|
|
34
|
+
* mechanism that can be toggled on or off for detailed comparison logging. It is important to ensure that
|
|
35
|
+
* objects do not contain circular references when enabling debug logging to avoid infinite loops.
|
|
36
|
+
*
|
|
37
|
+
* Example usage:
|
|
38
|
+
* ```
|
|
39
|
+
* const obj1 = { a: 1, b: { c: 2 } };
|
|
40
|
+
* const obj2 = { a: 1, b: { c: 2 } };
|
|
41
|
+
* console.log(deepEqual(obj1, obj2)); // true
|
|
42
|
+
*
|
|
43
|
+
* const arr1 = [1, 2, [3, 4]];
|
|
44
|
+
* const arr2 = [1, 2, [3, 4]];
|
|
45
|
+
* console.log(deepEqual(arr1, arr2)); // true
|
|
46
|
+
*
|
|
47
|
+
* const obj3 = { a: 1, b: { c: 2, d: 3 } };
|
|
48
|
+
* const obj4 = { a: 1, b: { c: 2 } };
|
|
49
|
+
* console.log(deepEqual(obj3, obj4, ['d'])); // true, excluding property 'd' from comparison
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare function deepEqual(a: any, b: any, excludeProperties?: string[]): boolean;
|
|
53
|
+
//# sourceMappingURL=deepEqual.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deepEqual.d.ts","sourceRoot":"","sources":["../../src/utils/deepEqual.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,iBAAiB,GAAE,MAAM,EAAO,GAAG,OAAO,CAsFnF"}
|
package/dist/utils/deepEqual.js
CHANGED
|
@@ -1,23 +1,88 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
/**
|
|
3
|
+
* This file contains the deepEqual function.
|
|
4
|
+
*
|
|
5
|
+
* @file deepEqual.ts
|
|
6
|
+
* @author Luca Liguori
|
|
7
|
+
* @date 2025-02-16
|
|
8
|
+
* @version 1.0.0
|
|
9
|
+
*
|
|
10
|
+
* Copyright 2025, 2026, 2027 Luca Liguori.
|
|
11
|
+
*
|
|
12
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
13
|
+
* you may not use this file except in compliance with the License.
|
|
14
|
+
* You may obtain a copy of the License at
|
|
15
|
+
*
|
|
16
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
17
|
+
*
|
|
18
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
19
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
20
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
|
+
* See the License for the specific language governing permissions and
|
|
22
|
+
* limitations under the License. *
|
|
23
|
+
*/
|
|
24
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
25
|
+
/**
|
|
26
|
+
* Performs a deep comparison between two values to determine if they are equivalent.
|
|
27
|
+
* This comparison includes primitive types, arrays, and objects, allowing for optional
|
|
28
|
+
* exclusion of specific properties from the comparison in objects.
|
|
29
|
+
*
|
|
30
|
+
* @param {any} a The first value to compare.
|
|
31
|
+
* @param {any} b The second value to compare.
|
|
32
|
+
* @param {string[]} [excludeProperties=[]] An array of property names to exclude from the comparison in objects.
|
|
33
|
+
* @returns {boolean} True if the values are deeply equal, excluding any specified properties; otherwise, false.
|
|
34
|
+
*
|
|
35
|
+
* Note: This function utilizes recursion for deep comparison of nested structures and includes a debugging
|
|
36
|
+
* mechanism that can be toggled on or off for detailed comparison logging. It is important to ensure that
|
|
37
|
+
* objects do not contain circular references when enabling debug logging to avoid infinite loops.
|
|
38
|
+
*
|
|
39
|
+
* Example usage:
|
|
40
|
+
* ```
|
|
41
|
+
* const obj1 = { a: 1, b: { c: 2 } };
|
|
42
|
+
* const obj2 = { a: 1, b: { c: 2 } };
|
|
43
|
+
* console.log(deepEqual(obj1, obj2)); // true
|
|
44
|
+
*
|
|
45
|
+
* const arr1 = [1, 2, [3, 4]];
|
|
46
|
+
* const arr2 = [1, 2, [3, 4]];
|
|
47
|
+
* console.log(deepEqual(arr1, arr2)); // true
|
|
48
|
+
*
|
|
49
|
+
* const obj3 = { a: 1, b: { c: 2, d: 3 } };
|
|
50
|
+
* const obj4 = { a: 1, b: { c: 2 } };
|
|
51
|
+
* console.log(deepEqual(obj3, obj4, ['d'])); // true, excluding property 'd' from comparison
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
1
54
|
export function deepEqual(a, b, excludeProperties = []) {
|
|
55
|
+
// Toggle debugging on or off easily
|
|
56
|
+
// const debug = false;
|
|
57
|
+
// Helper function for conditional logging
|
|
2
58
|
const debugLog = (...messages) => {
|
|
59
|
+
// if (debug) {
|
|
60
|
+
// console.log(...messages);
|
|
61
|
+
// }
|
|
3
62
|
};
|
|
63
|
+
// If both are the same instance, return true (handles primitives and same object references)
|
|
4
64
|
if (a === b) {
|
|
5
65
|
return true;
|
|
6
66
|
}
|
|
67
|
+
// If types are different, return false
|
|
7
68
|
if (typeof a !== typeof b) {
|
|
8
69
|
debugLog(`deepEqual false for typeof a: ${typeof a} typeof b: ${typeof b}`);
|
|
9
70
|
return false;
|
|
10
71
|
}
|
|
72
|
+
// If one of them is null (and we know they are not equal from the first check), return false
|
|
11
73
|
if (a == null || b == null) {
|
|
12
74
|
debugLog('deepEqual false for == null');
|
|
13
75
|
return false;
|
|
14
76
|
}
|
|
77
|
+
// Handle Dates compare by timestamp
|
|
15
78
|
if (a instanceof Date && b instanceof Date) {
|
|
16
79
|
return a.getTime() === b.getTime();
|
|
17
80
|
}
|
|
81
|
+
// Handle Regexps compare by their source & flags
|
|
18
82
|
if (a instanceof RegExp && b instanceof RegExp) {
|
|
19
83
|
return a.source === b.source && a.flags === b.flags;
|
|
20
84
|
}
|
|
85
|
+
// Handle Arrays
|
|
21
86
|
if (Array.isArray(a) && Array.isArray(b)) {
|
|
22
87
|
if (a.length !== b.length) {
|
|
23
88
|
debugLog(`deepEqual false for array a.length(${a.length}) !== b.length(${b.length})`);
|
|
@@ -33,26 +98,31 @@ export function deepEqual(a, b, excludeProperties = []) {
|
|
|
33
98
|
}
|
|
34
99
|
return true;
|
|
35
100
|
}
|
|
101
|
+
// Handle Objects (and exclude null, functions, and arrays)
|
|
36
102
|
if (typeof a === 'object' && typeof b === 'object') {
|
|
37
103
|
const aProps = Object.getOwnPropertyNames(a).filter((prop) => !excludeProperties.includes(prop));
|
|
38
104
|
const bProps = Object.getOwnPropertyNames(b).filter((prop) => !excludeProperties.includes(prop));
|
|
105
|
+
// If their property lengths are different, they're different objects
|
|
39
106
|
if (aProps.length !== bProps.length) {
|
|
40
107
|
debugLog(`deepEqual false for aProps.length(${aProps.length}) !== bProps.length(${bProps.length})`);
|
|
41
108
|
debugLog(`- aProps.length(${aProps.length}):`, aProps);
|
|
42
109
|
debugLog(`- bProps.length(${bProps.length}):`, bProps);
|
|
43
110
|
return false;
|
|
44
111
|
}
|
|
112
|
+
// Check each property in 'a' to see if it's in 'b' and if it's equal (deep check)
|
|
45
113
|
for (const prop of aProps) {
|
|
46
114
|
if (!Object.prototype.hasOwnProperty.call(b, prop)) {
|
|
47
115
|
debugLog(`deepEqual false for !b.hasOwnProperty(${prop})`);
|
|
48
116
|
return false;
|
|
49
117
|
}
|
|
50
118
|
if (!deepEqual(a[prop], b[prop], excludeProperties)) {
|
|
51
|
-
debugLog(`deepEqual false for !deepEqual(a[${prop}], b[${prop}])`);
|
|
119
|
+
debugLog(`deepEqual false for !deepEqual(a[${prop}], b[${prop}])` /* , a[prop], b[prop]*/);
|
|
52
120
|
return false;
|
|
53
121
|
}
|
|
54
122
|
}
|
|
55
123
|
return true;
|
|
56
124
|
}
|
|
125
|
+
// If none of the above, the objects are not equal
|
|
57
126
|
return false;
|
|
58
127
|
}
|
|
128
|
+
//# sourceMappingURL=deepEqual.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deepEqual.js","sourceRoot":"","sources":["../../src/utils/deepEqual.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,uDAAuD;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,SAAS,CAAC,CAAM,EAAE,CAAM,EAAE,oBAA8B,EAAE;IACxE,oCAAoC;IACpC,uBAAuB;IAEvB,0CAA0C;IAE1C,MAAM,QAAQ,GAAG,CAAC,GAAG,QAAe,EAAE,EAAE;QACtC,eAAe;QACf,4BAA4B;QAC5B,IAAI;IACN,CAAC,CAAC;IAEF,6FAA6F;IAC7F,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;IAED,uCAAuC;IACvC,IAAI,OAAO,CAAC,KAAK,OAAO,CAAC,EAAE,CAAC;QAC1B,QAAQ,CAAC,iCAAiC,OAAO,CAAC,cAAc,OAAO,CAAC,EAAE,CAAC,CAAC;QAC5E,OAAO,KAAK,CAAC;IACf,CAAC;IAED,6FAA6F;IAC7F,IAAI,CAAC,IAAI,IAAI,IAAI,CA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B,CAAC,EAAE,CAAC;gBACpD,QAAQ,CAAC,oCAAoC,IAAI,QAAQ,IAAI,IAAI,CAAC,uBAAuB,CAAC,CAAC;gBAC3F,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,kDAAkD;IAClD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './network.js';
|
|
2
|
+
export * from './commandLine.js';
|
|
3
|
+
export * from './isvalid.js';
|
|
4
|
+
export * from './colorUtils.js';
|
|
5
|
+
export * from './deepCopy.js';
|
|
6
|
+
export * from './deepEqual.js';
|
|
7
|
+
export * from './copyDirectory.js';
|
|
8
|
+
export * from './createDirectory.js';
|
|
9
|
+
export * from './createZip.js';
|
|
10
|
+
export * from './wait.js';
|
|
11
|
+
export * from './hex.js';
|
|
12
|
+
//# sourceMappingURL=export.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/utils/export.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
|
package/dist/utils/export.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.js","sourceRoot":"","sources":["../../src/utils/export.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the hex functions.
|
|
3
|
+
*
|
|
4
|
+
* @file hex.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @date 2025-05-06
|
|
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
|
+
/**
|
|
24
|
+
* Converts an ArrayBuffer or Uint8Array to a hexadecimal string.
|
|
25
|
+
*
|
|
26
|
+
* Accepts any {ArrayBufferLike} input: a raw ArrayBuffer (binary data storage) or
|
|
27
|
+
* a Uint8Array (TypedArray view over an ArrayBuffer). While an ArrayBuffer holds
|
|
28
|
+
* the raw memory, a Uint8Array is a typed view into that memory, letting you access
|
|
29
|
+
* its bytes directly. This function normalizes both by creating a Uint8Array view
|
|
30
|
+
* before conversion.
|
|
31
|
+
*
|
|
32
|
+
* @param {ArrayBufferLike} buffer - The buffer or typed-array view to convert.
|
|
33
|
+
* @returns {string} A lowercase hex string representation of the buffer's bytes.
|
|
34
|
+
*
|
|
35
|
+
* @throws {TypeError} If the input is not an ArrayBuffer or ArrayBufferView.
|
|
36
|
+
*/
|
|
37
|
+
export declare function bufferToHex(buffer: ArrayBufferLike): string;
|
|
38
|
+
/**
|
|
39
|
+
* Converts a hexadecimal string to a Uint8Array.
|
|
40
|
+
*
|
|
41
|
+
* @param {string} hex - The hex string to convert. Can include uppercase or lowercase characters.
|
|
42
|
+
* @returns {Uint8Array} A Uint8Array representing the corresponding binary data.
|
|
43
|
+
*
|
|
44
|
+
* @throws {TypeError} If the input is not a string.
|
|
45
|
+
* @throws {Error} If the input length is odd or contains non-hex characters.
|
|
46
|
+
*/
|
|
47
|
+
export declare function hexToBuffer(hex: string): Uint8Array;
|
|
48
|
+
//# sourceMappingURL=hex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hex.d.ts","sourceRoot":"","sources":["../../src/utils/hex.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAa3D;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAgCnD"}
|
package/dist/utils/hex.js
CHANGED
|
@@ -1,27 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the hex functions.
|
|
3
|
+
*
|
|
4
|
+
* @file hex.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @date 2025-05-06
|
|
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
|
+
/**
|
|
24
|
+
* Converts an ArrayBuffer or Uint8Array to a hexadecimal string.
|
|
25
|
+
*
|
|
26
|
+
* Accepts any {ArrayBufferLike} input: a raw ArrayBuffer (binary data storage) or
|
|
27
|
+
* a Uint8Array (TypedArray view over an ArrayBuffer). While an ArrayBuffer holds
|
|
28
|
+
* the raw memory, a Uint8Array is a typed view into that memory, letting you access
|
|
29
|
+
* its bytes directly. This function normalizes both by creating a Uint8Array view
|
|
30
|
+
* before conversion.
|
|
31
|
+
*
|
|
32
|
+
* @param {ArrayBufferLike} buffer - The buffer or typed-array view to convert.
|
|
33
|
+
* @returns {string} A lowercase hex string representation of the buffer's bytes.
|
|
34
|
+
*
|
|
35
|
+
* @throws {TypeError} If the input is not an ArrayBuffer or ArrayBufferView.
|
|
36
|
+
*/
|
|
1
37
|
export function bufferToHex(buffer) {
|
|
38
|
+
// Check if the input is an ArrayBuffer or ArrayBufferView
|
|
2
39
|
if (!(buffer instanceof ArrayBuffer || ArrayBuffer.isView(buffer))) {
|
|
3
40
|
throw new TypeError('Expected input to be an ArrayBuffer or ArrayBufferView');
|
|
4
41
|
}
|
|
42
|
+
// Create a Uint8Array view over the buffer
|
|
5
43
|
const bytes = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
|
|
44
|
+
// Convert each byte to 2-digit hex
|
|
6
45
|
return Array.from(bytes)
|
|
7
46
|
.map((byte) => byte.toString(16).padStart(2, '0'))
|
|
8
47
|
.join('');
|
|
9
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Converts a hexadecimal string to a Uint8Array.
|
|
51
|
+
*
|
|
52
|
+
* @param {string} hex - The hex string to convert. Can include uppercase or lowercase characters.
|
|
53
|
+
* @returns {Uint8Array} A Uint8Array representing the corresponding binary data.
|
|
54
|
+
*
|
|
55
|
+
* @throws {TypeError} If the input is not a string.
|
|
56
|
+
* @throws {Error} If the input length is odd or contains non-hex characters.
|
|
57
|
+
*/
|
|
10
58
|
export function hexToBuffer(hex) {
|
|
59
|
+
// Ensure the input is a string
|
|
11
60
|
if (typeof hex !== 'string') {
|
|
12
61
|
throw new TypeError('Expected a string for hex input');
|
|
13
62
|
}
|
|
63
|
+
// Trim any whitespace from the input string
|
|
14
64
|
const cleaned = hex.trim();
|
|
65
|
+
// Check if the length of the hex string is even
|
|
15
66
|
if (cleaned.length % 2 !== 0) {
|
|
16
67
|
throw new Error('Invalid hex string length, must be even');
|
|
17
68
|
}
|
|
69
|
+
// Validate that the string contains only valid hex characters
|
|
18
70
|
if (!/^[0-9a-fA-F]*$/.test(cleaned)) {
|
|
19
71
|
throw new Error('Invalid hex string, contains non-hex characters');
|
|
20
72
|
}
|
|
73
|
+
// Calculate the length of the resulting Uint8Array
|
|
21
74
|
const length = cleaned.length / 2;
|
|
75
|
+
// Create a Uint8Array to hold the binary data
|
|
22
76
|
const result = new Uint8Array(length);
|
|
77
|
+
// Convert each pair of hex characters into a byte
|
|
23
78
|
for (let i = 0; i < length; i++) {
|
|
24
79
|
result[i] = parseInt(cleaned.substr(i * 2, 2), 16);
|
|
25
80
|
}
|
|
81
|
+
// Return the resulting Uint8Array
|
|
26
82
|
return result;
|
|
27
83
|
}
|
|
84
|
+
//# sourceMappingURL=hex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hex.js","sourceRoot":"","sources":["../../src/utils/hex.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,WAAW,CAAC,MAAuB;IACjD,0DAA0D;IAC1D,IAAI,CAAC,CAAC,MAAM,YAAY,WAAW,IAAI,WAA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