matterbridge 3.5.0-dev-20260119-f9ea00e → 3.5.1-dev-20260121-22e98b4
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 +133 -117
- package/bin/mb_coap.js +1 -1
- package/bin/mb_mdns.js +1 -1
- package/dist/broadcastServer.js +1 -2
- package/dist/cli.d.ts +1 -2
- package/dist/cli.js +1 -5
- package/dist/cliHistory.js +1 -1
- package/dist/deviceManager.js +1 -1
- package/dist/frontend.js +2 -7
- package/dist/helpers.js +1 -1
- package/dist/matterNode.js +1 -5
- package/dist/matterbridge.js +14 -18
- package/dist/matterbridgeEndpoint.d.ts +2 -0
- package/dist/matterbridgeEndpoint.js +41 -2
- package/dist/matterbridgeEndpointHelpers.js +1 -3
- package/dist/matterbridgePlatform.js +1 -2
- package/dist/{dgram/mb_mdns.js → mb_mdns.js} +13 -1
- package/dist/pluginManager.js +3 -4
- package/dist/{utils/spawn.js → spawn.js} +2 -2
- package/dist/update.js +6 -7
- package/dist/utils/export.d.ts +1 -12
- package/dist/utils/export.js +1 -12
- package/dist/workerGlobalPrefix.js +1 -3
- package/frontend/build/assets/index.js +4 -4
- package/frontend/package.json +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +5 -5
- package/dist/dgram/coap.d.ts +0 -34
- package/dist/dgram/coap.js +0 -252
- package/dist/dgram/dgram.d.ts +0 -45
- package/dist/dgram/dgram.js +0 -251
- package/dist/dgram/mdns.d.ts +0 -188
- package/dist/dgram/mdns.js +0 -702
- package/dist/dgram/multicast.d.ts +0 -18
- package/dist/dgram/multicast.js +0 -118
- package/dist/dgram/unicast.d.ts +0 -11
- package/dist/dgram/unicast.js +0 -40
- package/dist/utils/colorUtils.d.ts +0 -24
- package/dist/utils/colorUtils.js +0 -187
- package/dist/utils/commandLine.d.ts +0 -6
- package/dist/utils/commandLine.js +0 -63
- package/dist/utils/copyDirectory.d.ts +0 -2
- package/dist/utils/copyDirectory.js +0 -39
- package/dist/utils/createDirectory.d.ts +0 -2
- package/dist/utils/createDirectory.js +0 -21
- package/dist/utils/createZip.d.ts +0 -1
- package/dist/utils/createZip.js +0 -69
- package/dist/utils/deepCopy.d.ts +0 -1
- package/dist/utils/deepCopy.js +0 -40
- package/dist/utils/deepEqual.d.ts +0 -1
- package/dist/utils/deepEqual.js +0 -58
- package/dist/utils/error.d.ts +0 -3
- package/dist/utils/error.js +0 -12
- package/dist/utils/format.d.ts +0 -4
- package/dist/utils/format.js +0 -29
- package/dist/utils/hex.d.ts +0 -4
- package/dist/utils/hex.js +0 -118
- package/dist/utils/inspector.d.ts +0 -24
- package/dist/utils/inspector.js +0 -200
- package/dist/utils/isValid.d.ts +0 -10
- package/dist/utils/isValid.js +0 -69
- package/dist/utils/network.d.ts +0 -25
- package/dist/utils/network.js +0 -193
- package/dist/utils/tracker.d.ts +0 -52
- package/dist/utils/tracker.js +0 -201
- package/dist/utils/wait.d.ts +0 -3
- package/dist/utils/wait.js +0 -73
- /package/dist/{dgram/mb_coap.d.ts → mb_coap.d.ts} +0 -0
- /package/dist/{dgram/mb_coap.js → mb_coap.js} +0 -0
- /package/dist/{dgram/mb_mdns.d.ts → mb_mdns.d.ts} +0 -0
- /package/dist/{utils/spawn.d.ts → spawn.d.ts} +0 -0
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { AddressInfo } from 'node:net';
|
|
2
|
-
import { Dgram } from './dgram.js';
|
|
3
|
-
export declare const MDNS_MULTICAST_IPV4_ADDRESS = "224.0.0.251";
|
|
4
|
-
export declare const MDNS_MULTICAST_IPV6_ADDRESS = "ff02::fb";
|
|
5
|
-
export declare const MDNS_MULTICAST_PORT = 5353;
|
|
6
|
-
export declare const COAP_MULTICAST_IPV4_ADDRESS = "224.0.1.187";
|
|
7
|
-
export declare const COAP_MULTICAST_IPV6_ADDRESS = "ff02::fd";
|
|
8
|
-
export declare const COAP_MULTICAST_PORT = 5683;
|
|
9
|
-
export declare class Multicast extends Dgram {
|
|
10
|
-
multicastAddress: string;
|
|
11
|
-
multicastPort: number;
|
|
12
|
-
outgoingInterfaceAddress: string | undefined;
|
|
13
|
-
joinedInterfaces: string[];
|
|
14
|
-
constructor(name: string, multicastAddress: string, multicastPort: number, socketType: 'udp4' | 'udp6', reuseAddr?: boolean | undefined, interfaceName?: string, interfaceAddress?: string, outgoingInterfaceAddress?: string);
|
|
15
|
-
start(): void;
|
|
16
|
-
onListening(address: AddressInfo): void;
|
|
17
|
-
stop(): void;
|
|
18
|
-
}
|
package/dist/dgram/multicast.js
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import os from 'node:os';
|
|
2
|
-
import { BLUE, CYAN, db, RED, YELLOW } from 'node-ansi-logger';
|
|
3
|
-
import { Dgram } from './dgram.js';
|
|
4
|
-
export const MDNS_MULTICAST_IPV4_ADDRESS = '224.0.0.251';
|
|
5
|
-
export const MDNS_MULTICAST_IPV6_ADDRESS = 'ff02::fb';
|
|
6
|
-
export const MDNS_MULTICAST_PORT = 5353;
|
|
7
|
-
export const COAP_MULTICAST_IPV4_ADDRESS = '224.0.1.187';
|
|
8
|
-
export const COAP_MULTICAST_IPV6_ADDRESS = 'ff02::fd';
|
|
9
|
-
export const COAP_MULTICAST_PORT = 5683;
|
|
10
|
-
export class Multicast extends Dgram {
|
|
11
|
-
multicastAddress;
|
|
12
|
-
multicastPort;
|
|
13
|
-
outgoingInterfaceAddress;
|
|
14
|
-
joinedInterfaces = [];
|
|
15
|
-
constructor(name, multicastAddress, multicastPort, socketType, reuseAddr = true, interfaceName, interfaceAddress, outgoingInterfaceAddress) {
|
|
16
|
-
super(name, socketType, reuseAddr, interfaceName, interfaceAddress);
|
|
17
|
-
this.multicastAddress = multicastAddress;
|
|
18
|
-
this.multicastPort = multicastPort;
|
|
19
|
-
this.outgoingInterfaceAddress = outgoingInterfaceAddress;
|
|
20
|
-
}
|
|
21
|
-
start() {
|
|
22
|
-
if (this.socketType === 'udp4') {
|
|
23
|
-
this.log.debug(`Starting ipv4 dgram multicast socket...`);
|
|
24
|
-
this.interfaceAddress = this.interfaceAddress ?? this.getIpv4InterfaceAddress(this.interfaceName);
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
this.log.debug(`Starting ipv6 dgram multicast socket...`);
|
|
28
|
-
this.interfaceAddress = this.interfaceAddress ?? this.getIpv6InterfaceAddress(this.interfaceName);
|
|
29
|
-
}
|
|
30
|
-
this.log.debug(`Binding dgram multicast socket to ${BLUE}${this.interfaceAddress}${db}:${BLUE}${this.multicastPort}${db} on interface ${CYAN}${this.interfaceName}${db}`);
|
|
31
|
-
this.socket.bind(this.multicastPort, this.interfaceAddress, () => {
|
|
32
|
-
const address = this.socket.address();
|
|
33
|
-
this.log.debug(`Dgram multicast socket bound to ${BLUE}${address.family}${db} ${BLUE}${address.address}${db}:${BLUE}${address.port}${db}`);
|
|
34
|
-
this.emit('bound', address);
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
onListening(address) {
|
|
38
|
-
this.log.debug(`Dgram multicast socket listening on ${BLUE}${address.family}${db} ${BLUE}${address.address}${db}:${BLUE}${address.port}${db}`);
|
|
39
|
-
this.socket.setBroadcast(true);
|
|
40
|
-
this.log.debug(`Dgram multicast socket broadcast enabled`);
|
|
41
|
-
this.socket.setTTL(255);
|
|
42
|
-
this.log.debug(`Dgram multicast socket TTL set to 255`);
|
|
43
|
-
this.socket.setMulticastTTL(255);
|
|
44
|
-
this.log.debug(`Dgram multicast socket multicast TTL set to 255`);
|
|
45
|
-
this.socket.setMulticastLoopback(true);
|
|
46
|
-
this.log.debug(`Dgram multicast socket multicast loopback enabled`);
|
|
47
|
-
Object.entries(os.networkInterfaces()).forEach(([name, interfaces]) => {
|
|
48
|
-
this.log.debug(`Dgram multicast socket processing interface ${CYAN}${name}${db}`);
|
|
49
|
-
if (!interfaces)
|
|
50
|
-
return;
|
|
51
|
-
if (this.interfaceName && name !== this.interfaceName)
|
|
52
|
-
return;
|
|
53
|
-
let iface;
|
|
54
|
-
let membershipInterface;
|
|
55
|
-
const ifaceIpv4 = interfaces.find((iface) => iface.family === 'IPv4' && this.socketType === 'udp4');
|
|
56
|
-
if (ifaceIpv4) {
|
|
57
|
-
iface = ifaceIpv4;
|
|
58
|
-
membershipInterface = ifaceIpv4.address;
|
|
59
|
-
}
|
|
60
|
-
const ifaceIpv6 = interfaces.find((iface) => iface.family === 'IPv6' && this.socketType === 'udp6');
|
|
61
|
-
if (ifaceIpv6) {
|
|
62
|
-
iface = ifaceIpv6;
|
|
63
|
-
membershipInterface = ifaceIpv6.address + (ifaceIpv6.scopeid !== undefined ? (process.platform === 'win32' ? '%' + String(ifaceIpv6.scopeid) : '%' + name) : '');
|
|
64
|
-
}
|
|
65
|
-
const ifaceUla = interfaces.find((iface) => iface.family === 'IPv6' && this.socketType === 'udp6' && iface.address.startsWith('fd'));
|
|
66
|
-
if (ifaceUla) {
|
|
67
|
-
iface = ifaceUla;
|
|
68
|
-
membershipInterface = ifaceUla.address + (ifaceUla.scopeid !== undefined ? (process.platform === 'win32' ? '%' + String(ifaceUla.scopeid) : '%' + name) : '');
|
|
69
|
-
}
|
|
70
|
-
const ifaceUla64 = interfaces.find((iface) => iface.family === 'IPv6' && this.socketType === 'udp6' && iface.address.startsWith('fd') && iface.netmask === 'ffff:ffff:ffff:ffff::');
|
|
71
|
-
if (ifaceUla64) {
|
|
72
|
-
iface = ifaceUla64;
|
|
73
|
-
membershipInterface = ifaceUla64.address + (ifaceUla64.scopeid !== undefined ? (process.platform === 'win32' ? '%' + String(ifaceUla64.scopeid) : '%' + name) : '');
|
|
74
|
-
}
|
|
75
|
-
const ifaceLinkLocal = interfaces.find((iface) => iface.family === 'IPv6' && this.socketType === 'udp6' && iface.address.startsWith('fe80'));
|
|
76
|
-
if (ifaceLinkLocal) {
|
|
77
|
-
iface = ifaceLinkLocal;
|
|
78
|
-
membershipInterface = ifaceLinkLocal.address + (ifaceLinkLocal.scopeid !== undefined ? (process.platform === 'win32' ? '%' + String(ifaceLinkLocal.scopeid) : '%' + name) : '');
|
|
79
|
-
}
|
|
80
|
-
if (iface && membershipInterface) {
|
|
81
|
-
try {
|
|
82
|
-
this.socket.addMembership(this.multicastAddress, membershipInterface);
|
|
83
|
-
this.joinedInterfaces.push(membershipInterface);
|
|
84
|
-
this.log.debug(`Dgram multicast socket joined multicast group ${BLUE}${this.multicastAddress}${db} on interface ${CYAN}${name}${db} ${BLUE}${iface.family}${db} ${BLUE}${iface.address}${db} ${BLUE}${iface.scopeid}${db} >>> ${YELLOW}${membershipInterface}${db}`);
|
|
85
|
-
}
|
|
86
|
-
catch (error) {
|
|
87
|
-
this.log.debug(`Dgram multicast socket failed to join multicast group ${BLUE}${this.multicastAddress}${db} on interface ${CYAN}${name}${db} ${BLUE}${iface.family}${db} ${BLUE}${iface.address}${db} ${BLUE}${iface.scopeid}${db} >>> ${RED}${membershipInterface}${db}: ${error instanceof Error ? error.message : error}`);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
let interfaceAddress = this.outgoingInterfaceAddress || this.interfaceAddress;
|
|
92
|
-
if (!this.outgoingInterfaceAddress && this.socketType === 'udp4' && this.interfaceAddress === '0.0.0.0') {
|
|
93
|
-
interfaceAddress = this.getIpv4InterfaceAddress(this.interfaceName);
|
|
94
|
-
}
|
|
95
|
-
if (!this.outgoingInterfaceAddress && this.socketType === 'udp6' && this.interfaceAddress === '::') {
|
|
96
|
-
interfaceAddress = '::' + this.getIpv6ScopeId(this.interfaceName);
|
|
97
|
-
}
|
|
98
|
-
this.log.debug(`Dgram multicast socket setting multicastInterface to ${BLUE}${interfaceAddress}${db} for ${BLUE}${address.family}${db} ${BLUE}${address.address}${db}:${BLUE}${address.port}${db}`);
|
|
99
|
-
this.socket.setMulticastInterface(interfaceAddress);
|
|
100
|
-
this.log.debug(`Dgram multicast socket multicastInterface set to ${BLUE}${interfaceAddress}${db}`);
|
|
101
|
-
this.emit('ready', address);
|
|
102
|
-
}
|
|
103
|
-
stop() {
|
|
104
|
-
this.log.debug('Stopping dgram multicast socket...');
|
|
105
|
-
this.joinedInterfaces.forEach((membershipInterface) => {
|
|
106
|
-
try {
|
|
107
|
-
this.socket.dropMembership(this.multicastAddress, membershipInterface);
|
|
108
|
-
this.log.debug(`Dgram multicast socket dropped multicast group ${BLUE}${this.multicastAddress}${db} on interface ${YELLOW}${membershipInterface}${db}`);
|
|
109
|
-
}
|
|
110
|
-
catch (error) {
|
|
111
|
-
this.log.debug(`Dgram multicast socket failed to drop multicast group ${BLUE}${this.multicastAddress}${db} on interface ${RED}${membershipInterface}${db}: ${error}`);
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
this.joinedInterfaces = [];
|
|
115
|
-
this.socket.close();
|
|
116
|
-
this.log.debug('Stopped dgram multicast socket.');
|
|
117
|
-
}
|
|
118
|
-
}
|
package/dist/dgram/unicast.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { AddressInfo } from 'node:net';
|
|
2
|
-
import { RemoteInfo } from 'node:dgram';
|
|
3
|
-
import { Dgram } from './dgram.js';
|
|
4
|
-
export declare class Unicast extends Dgram {
|
|
5
|
-
port: number | undefined;
|
|
6
|
-
constructor(name: string, socketType: 'udp4' | 'udp6', reuseAddr?: boolean | undefined, interfaceName?: string, interfaceAddress?: string, port?: number);
|
|
7
|
-
start(): void;
|
|
8
|
-
onListening(address: AddressInfo): void;
|
|
9
|
-
onMessage(msg: Buffer, rinfo: RemoteInfo): void;
|
|
10
|
-
stop(): void;
|
|
11
|
-
}
|
package/dist/dgram/unicast.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { BLUE, db } from 'node-ansi-logger';
|
|
2
|
-
import { Dgram } from './dgram.js';
|
|
3
|
-
export class Unicast extends Dgram {
|
|
4
|
-
port;
|
|
5
|
-
constructor(name, socketType, reuseAddr = true, interfaceName, interfaceAddress, port) {
|
|
6
|
-
super(name, socketType, reuseAddr, interfaceName, interfaceAddress);
|
|
7
|
-
this.port = port;
|
|
8
|
-
}
|
|
9
|
-
start() {
|
|
10
|
-
if (this.socketType === 'udp4') {
|
|
11
|
-
this.log.debug(`Starting ipv4 dgram unicast socket...`);
|
|
12
|
-
this.interfaceAddress = this.interfaceAddress ?? (this.interfaceName ? this.getIpv4InterfaceAddress(this.interfaceName) : undefined);
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
this.log.debug(`Starting ipv6 dgram unicast socket...`);
|
|
16
|
-
this.interfaceAddress = this.interfaceAddress ?? (this.interfaceName ? this.getIpv6InterfaceAddress(this.interfaceName) : undefined);
|
|
17
|
-
}
|
|
18
|
-
this.interfaceNetmask = this.interfaceAddress ? this.getNetmask(this.interfaceAddress) : undefined;
|
|
19
|
-
this.log.debug(`Binding dgram unicast socket to ${BLUE}${this.interfaceAddress || 'all available addresses'}${db} on port ${BLUE}${this.port || 'any available port'}${db}...`);
|
|
20
|
-
this.socket.bind(this.port, this.interfaceAddress, () => {
|
|
21
|
-
const address = this.socket.address();
|
|
22
|
-
this.log.debug(`Dgram unicast socket bound to ${BLUE}${address.family}${db} ${BLUE}${address.address}${db}:${BLUE}${address.port}${db}`);
|
|
23
|
-
this.emit('bound', address);
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
onListening(address) {
|
|
27
|
-
this.log.debug(`Dgram unicast socket listening on ${BLUE}${address.family}${db} ${BLUE}${address.address}${db}:${BLUE}${address.port}${db}`);
|
|
28
|
-
this.socket.setBroadcast(true);
|
|
29
|
-
this.log.debug(`Dgram unicast socket broadcast enabled`);
|
|
30
|
-
this.emit('ready', address);
|
|
31
|
-
}
|
|
32
|
-
onMessage(msg, rinfo) {
|
|
33
|
-
this.log.debug(`Socket received a message from ${BLUE}${rinfo.family}${db} ${BLUE}${rinfo.address}${db}:${BLUE}${rinfo.port}${db}`);
|
|
34
|
-
}
|
|
35
|
-
stop() {
|
|
36
|
-
this.log.debug('Stopping dgram unicast socket...');
|
|
37
|
-
this.socket.close();
|
|
38
|
-
this.log.debug('Stopped dgram unicast socket.');
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export interface RGB {
|
|
2
|
-
r: number;
|
|
3
|
-
g: number;
|
|
4
|
-
b: number;
|
|
5
|
-
}
|
|
6
|
-
export interface XY {
|
|
7
|
-
x: number;
|
|
8
|
-
y: number;
|
|
9
|
-
}
|
|
10
|
-
export interface HSL {
|
|
11
|
-
h: number;
|
|
12
|
-
s: number;
|
|
13
|
-
l: number;
|
|
14
|
-
}
|
|
15
|
-
export declare function hslColorToRgbColor(hue: number, saturation: number, luminance: number): RGB;
|
|
16
|
-
export declare function rgbColorToXYColor(rgb: RGB): XY;
|
|
17
|
-
export declare function xyColorToRgbColor(x: number, y: number, brightness?: number): RGB;
|
|
18
|
-
export declare function rgbColorToHslColor(rgb: RGB): HSL;
|
|
19
|
-
export declare function xyToHsl(x: number, y: number): HSL;
|
|
20
|
-
export declare function miredToKelvin(mired: number): number;
|
|
21
|
-
export declare const miredsToKelvin: typeof miredToKelvin;
|
|
22
|
-
export declare function kelvinToMired(kelvin: number): number;
|
|
23
|
-
export declare const kelvinToMireds: typeof kelvinToMired;
|
|
24
|
-
export declare function kelvinToRGB(kelvin: number): RGB;
|
package/dist/utils/colorUtils.js
DELETED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import { assert } from 'node:console';
|
|
2
|
-
export function hslColorToRgbColor(hue, saturation, luminance) {
|
|
3
|
-
if (hue === 360) {
|
|
4
|
-
hue = 0;
|
|
5
|
-
}
|
|
6
|
-
assert(hue >= 0 && hue <= 359, 'hslColorToRgbColor Hue error');
|
|
7
|
-
assert(saturation >= 0 && saturation <= 100, 'hslColorToRgbColor Saturation error');
|
|
8
|
-
assert(luminance === 50, 'hslColorToRgbColor Luminance error');
|
|
9
|
-
saturation /= 100;
|
|
10
|
-
luminance /= 100;
|
|
11
|
-
let r, g, b;
|
|
12
|
-
if (saturation === 0) {
|
|
13
|
-
r = g = b = luminance;
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
const hue2rgb = (p, q, t) => {
|
|
17
|
-
if (t < 0) {
|
|
18
|
-
t += 1;
|
|
19
|
-
}
|
|
20
|
-
if (t > 1) {
|
|
21
|
-
t -= 1;
|
|
22
|
-
}
|
|
23
|
-
if (t < 1 / 6) {
|
|
24
|
-
return p + (q - p) * 6 * t;
|
|
25
|
-
}
|
|
26
|
-
if (t < 1 / 2) {
|
|
27
|
-
return q;
|
|
28
|
-
}
|
|
29
|
-
if (t < 2 / 3) {
|
|
30
|
-
return p + (q - p) * (2 / 3 - t) * 6;
|
|
31
|
-
}
|
|
32
|
-
return p;
|
|
33
|
-
};
|
|
34
|
-
const q = luminance < 0.5 ? luminance * (1 + saturation) : luminance + saturation - luminance * saturation;
|
|
35
|
-
const p = 2 * luminance - q;
|
|
36
|
-
r = hue2rgb(p, q, hue / 360 + 1 / 3);
|
|
37
|
-
g = hue2rgb(p, q, hue / 360);
|
|
38
|
-
b = hue2rgb(p, q, hue / 360 - 1 / 3);
|
|
39
|
-
}
|
|
40
|
-
return {
|
|
41
|
-
r: Math.ceil(r * 255),
|
|
42
|
-
g: Math.ceil(g * 255),
|
|
43
|
-
b: Math.ceil(b * 255),
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
export function rgbColorToXYColor(rgb) {
|
|
47
|
-
let r = rgb.r / 255;
|
|
48
|
-
let g = rgb.g / 255;
|
|
49
|
-
let b = rgb.b / 255;
|
|
50
|
-
r = r > 0.04045 ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92;
|
|
51
|
-
g = g > 0.04045 ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92;
|
|
52
|
-
b = b > 0.04045 ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92;
|
|
53
|
-
r = r * 100;
|
|
54
|
-
g = g * 100;
|
|
55
|
-
b = b * 100;
|
|
56
|
-
const X = r * 0.664511 + g * 0.154324 + b * 0.162028;
|
|
57
|
-
const Y = r * 0.283881 + g * 0.668433 + b * 0.047685;
|
|
58
|
-
const Z = r * 0.000088 + g * 0.07231 + b * 0.986039;
|
|
59
|
-
let x = X / (X + Y + Z);
|
|
60
|
-
let y = Y / (X + Y + Z);
|
|
61
|
-
x = Math.round(x * 10000) / 10000;
|
|
62
|
-
y = Math.round(y * 10000) / 10000;
|
|
63
|
-
return { x, y };
|
|
64
|
-
}
|
|
65
|
-
export function xyColorToRgbColor(x, y, brightness = 254) {
|
|
66
|
-
const z = 1.0 - x - y;
|
|
67
|
-
const Y = (brightness / 254).toFixed(2);
|
|
68
|
-
const X = (Number(Y) / y) * x;
|
|
69
|
-
const Z = (Number(Y) / y) * z;
|
|
70
|
-
let red = X * 1.656492 - Number(Y) * 0.354851 - Z * 0.255038;
|
|
71
|
-
let green = -X * 0.707196 + Number(Y) * 1.655397 + Z * 0.036152;
|
|
72
|
-
let blue = X * 0.051713 - Number(Y) * 0.121364 + Z * 1.01153;
|
|
73
|
-
if (red > blue && red > green && red > 1.0) {
|
|
74
|
-
green = green / red;
|
|
75
|
-
blue = blue / red;
|
|
76
|
-
red = 1.0;
|
|
77
|
-
}
|
|
78
|
-
else if (green > blue && green > red && green > 1.0) {
|
|
79
|
-
red = red / green;
|
|
80
|
-
blue = blue / green;
|
|
81
|
-
green = 1.0;
|
|
82
|
-
}
|
|
83
|
-
else if (blue > red && blue > green && blue > 1.0) {
|
|
84
|
-
red = red / blue;
|
|
85
|
-
green = green / blue;
|
|
86
|
-
blue = 1.0;
|
|
87
|
-
}
|
|
88
|
-
red = red <= 0.0031308 ? 12.92 * red : (1.0 + 0.055) * Math.pow(red, 1.0 / 2.4) - 0.055;
|
|
89
|
-
green = green <= 0.0031308 ? 12.92 * green : (1.0 + 0.055) * Math.pow(green, 1.0 / 2.4) - 0.055;
|
|
90
|
-
blue = blue <= 0.0031308 ? 12.92 * blue : (1.0 + 0.055) * Math.pow(blue, 1.0 / 2.4) - 0.055;
|
|
91
|
-
red = Math.round(red * 255);
|
|
92
|
-
green = Math.round(green * 255);
|
|
93
|
-
blue = Math.round(blue * 255);
|
|
94
|
-
if (isNaN(red) || red < 0) {
|
|
95
|
-
red = 0;
|
|
96
|
-
}
|
|
97
|
-
if (isNaN(green) || green < 0) {
|
|
98
|
-
green = 0;
|
|
99
|
-
}
|
|
100
|
-
if (isNaN(blue) || blue < 0) {
|
|
101
|
-
blue = 0;
|
|
102
|
-
}
|
|
103
|
-
return {
|
|
104
|
-
r: red === 0 ? 0 : red,
|
|
105
|
-
g: green === 0 ? 0 : green,
|
|
106
|
-
b: blue === 0 ? 0 : blue,
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
export function rgbColorToHslColor(rgb) {
|
|
110
|
-
const r = rgb.r / 255;
|
|
111
|
-
const g = rgb.g / 255;
|
|
112
|
-
const b = rgb.b / 255;
|
|
113
|
-
const max = Math.max(r, g, b);
|
|
114
|
-
const min = Math.min(r, g, b);
|
|
115
|
-
let h = 0, s = 0;
|
|
116
|
-
const l = (max + min) / 2;
|
|
117
|
-
if (max === min) {
|
|
118
|
-
h = s = 0;
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
const d = max - min;
|
|
122
|
-
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
123
|
-
switch (max) {
|
|
124
|
-
case r:
|
|
125
|
-
h = (g - b) / d + (g < b ? 6 : 0);
|
|
126
|
-
break;
|
|
127
|
-
case g:
|
|
128
|
-
h = (b - r) / d + 2;
|
|
129
|
-
break;
|
|
130
|
-
case b:
|
|
131
|
-
h = (r - g) / d + 4;
|
|
132
|
-
break;
|
|
133
|
-
}
|
|
134
|
-
h /= 6;
|
|
135
|
-
}
|
|
136
|
-
return {
|
|
137
|
-
h: Math.round(h * 360),
|
|
138
|
-
s: Math.round(s * 100),
|
|
139
|
-
l: Math.round(l * 100),
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
export function xyToHsl(x, y) {
|
|
143
|
-
const rgb = xyColorToRgbColor(x, y);
|
|
144
|
-
return rgbColorToHslColor(rgb);
|
|
145
|
-
}
|
|
146
|
-
export function miredToKelvin(mired) {
|
|
147
|
-
return Math.round(1000000 / mired);
|
|
148
|
-
}
|
|
149
|
-
export const miredsToKelvin = miredToKelvin;
|
|
150
|
-
export function kelvinToMired(kelvin) {
|
|
151
|
-
return Math.round(1000000 / kelvin);
|
|
152
|
-
}
|
|
153
|
-
export const kelvinToMireds = kelvinToMired;
|
|
154
|
-
export function kelvinToRGB(kelvin) {
|
|
155
|
-
kelvin = Math.max(1000, Math.min(40000, kelvin)) / 100;
|
|
156
|
-
let r, g, b;
|
|
157
|
-
if (kelvin <= 66) {
|
|
158
|
-
r = 255;
|
|
159
|
-
}
|
|
160
|
-
else {
|
|
161
|
-
r = kelvin - 60;
|
|
162
|
-
r = 329.698727446 * Math.pow(r, -0.1332047592);
|
|
163
|
-
r = Math.max(0, Math.min(255, r));
|
|
164
|
-
}
|
|
165
|
-
if (kelvin <= 66) {
|
|
166
|
-
g = kelvin;
|
|
167
|
-
g = 99.4708025861 * Math.log(g) - 161.1195681661;
|
|
168
|
-
g = Math.max(0, Math.min(255, g));
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
g = kelvin - 60;
|
|
172
|
-
g = 288.1221695283 * Math.pow(g, -0.0755148492);
|
|
173
|
-
g = Math.max(0, Math.min(255, g));
|
|
174
|
-
}
|
|
175
|
-
if (kelvin >= 66) {
|
|
176
|
-
b = 255;
|
|
177
|
-
}
|
|
178
|
-
else if (kelvin <= 19) {
|
|
179
|
-
b = 0;
|
|
180
|
-
}
|
|
181
|
-
else {
|
|
182
|
-
b = kelvin - 10;
|
|
183
|
-
b = 138.5177312231 * Math.log(b) - 305.0447927307;
|
|
184
|
-
b = Math.max(0, Math.min(255, b));
|
|
185
|
-
}
|
|
186
|
-
return { r: Math.round(r), g: Math.round(g), b: Math.round(b) };
|
|
187
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare function hasParameter(name: string): boolean;
|
|
2
|
-
export declare function hasAnyParameter(...params: string[]): boolean;
|
|
3
|
-
export declare function getParameter(name: string): string | undefined;
|
|
4
|
-
export declare function getIntParameter(name: string): number | undefined;
|
|
5
|
-
export declare function getIntArrayParameter(name: string): number[] | undefined;
|
|
6
|
-
export declare function getStringArrayParameter(name: string): string[] | undefined;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { isValidNumber } from './isValid.js';
|
|
2
|
-
export function hasParameter(name) {
|
|
3
|
-
const commandArguments = process.argv.slice(2);
|
|
4
|
-
let markerIncluded = commandArguments.includes(`-${name}`);
|
|
5
|
-
if (!markerIncluded)
|
|
6
|
-
markerIncluded = commandArguments.includes(`--${name}`);
|
|
7
|
-
return markerIncluded;
|
|
8
|
-
}
|
|
9
|
-
export function hasAnyParameter(...params) {
|
|
10
|
-
return params.some((param) => {
|
|
11
|
-
return hasParameter(param);
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
export function getParameter(name) {
|
|
15
|
-
const commandArguments = process.argv.slice(2);
|
|
16
|
-
let markerIndex = commandArguments.indexOf(`-${name}`);
|
|
17
|
-
if (markerIndex === -1)
|
|
18
|
-
markerIndex = commandArguments.indexOf(`--${name}`);
|
|
19
|
-
if (markerIndex === -1 || markerIndex + 1 === commandArguments.length || commandArguments[markerIndex + 1].startsWith('-'))
|
|
20
|
-
return undefined;
|
|
21
|
-
return commandArguments[markerIndex + 1];
|
|
22
|
-
}
|
|
23
|
-
export function getIntParameter(name) {
|
|
24
|
-
const value = getParameter(name);
|
|
25
|
-
if (value === undefined)
|
|
26
|
-
return undefined;
|
|
27
|
-
const intValue = parseInt(value, 10);
|
|
28
|
-
if (!isValidNumber(intValue))
|
|
29
|
-
return undefined;
|
|
30
|
-
return intValue;
|
|
31
|
-
}
|
|
32
|
-
export function getIntArrayParameter(name) {
|
|
33
|
-
const commandArguments = process.argv.slice(2);
|
|
34
|
-
let markerIndex = commandArguments.indexOf(`--${name}`);
|
|
35
|
-
if (markerIndex < 0)
|
|
36
|
-
markerIndex = commandArguments.indexOf(`-${name}`);
|
|
37
|
-
if (markerIndex < 0)
|
|
38
|
-
return undefined;
|
|
39
|
-
const intValues = [];
|
|
40
|
-
for (let i = markerIndex + 1; i < commandArguments.length && !commandArguments[i].startsWith('-'); i++) {
|
|
41
|
-
const intValue = parseInt(commandArguments[i], 10);
|
|
42
|
-
if (isValidNumber(intValue))
|
|
43
|
-
intValues.push(intValue);
|
|
44
|
-
}
|
|
45
|
-
if (intValues.length === 0)
|
|
46
|
-
return undefined;
|
|
47
|
-
return intValues;
|
|
48
|
-
}
|
|
49
|
-
export function getStringArrayParameter(name) {
|
|
50
|
-
const commandArguments = process.argv.slice(2);
|
|
51
|
-
let markerIndex = commandArguments.indexOf(`--${name}`);
|
|
52
|
-
if (markerIndex < 0)
|
|
53
|
-
markerIndex = commandArguments.indexOf(`-${name}`);
|
|
54
|
-
if (markerIndex < 0)
|
|
55
|
-
return undefined;
|
|
56
|
-
const values = [];
|
|
57
|
-
for (let i = markerIndex + 1; i < commandArguments.length && !commandArguments[i].startsWith('-'); i++) {
|
|
58
|
-
values.push(commandArguments[i]);
|
|
59
|
-
}
|
|
60
|
-
if (values.length === 0)
|
|
61
|
-
return undefined;
|
|
62
|
-
return values;
|
|
63
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
export async function copyDirectory(srcDir, destDir, log) {
|
|
2
|
-
if (srcDir === '') {
|
|
3
|
-
throw new Error('Source directory must be specified.');
|
|
4
|
-
}
|
|
5
|
-
if (destDir === '') {
|
|
6
|
-
throw new Error('Destination directory must be specified.');
|
|
7
|
-
}
|
|
8
|
-
if (!srcDir) {
|
|
9
|
-
throw new Error('Source directory must be specified.');
|
|
10
|
-
}
|
|
11
|
-
if (!destDir) {
|
|
12
|
-
throw new Error('Destination directory must be specified.');
|
|
13
|
-
}
|
|
14
|
-
if (srcDir === destDir) {
|
|
15
|
-
throw new Error('Source and destination directories must be different.');
|
|
16
|
-
}
|
|
17
|
-
const fs = await import('node:fs').then((mod) => mod.promises);
|
|
18
|
-
const path = await import('node:path');
|
|
19
|
-
log?.debug(`copyDirectory: copying directory from ${srcDir} to ${destDir}`);
|
|
20
|
-
try {
|
|
21
|
-
await fs.mkdir(destDir, { recursive: true });
|
|
22
|
-
const entries = await fs.readdir(srcDir, { withFileTypes: true });
|
|
23
|
-
for (const entry of entries) {
|
|
24
|
-
const srcPath = path.join(srcDir, entry.name);
|
|
25
|
-
const destPath = path.join(destDir, entry.name);
|
|
26
|
-
if (entry.isDirectory()) {
|
|
27
|
-
await copyDirectory(srcPath, destPath);
|
|
28
|
-
}
|
|
29
|
-
else if (entry.isFile()) {
|
|
30
|
-
await fs.copyFile(srcPath, destPath);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
catch (error) {
|
|
36
|
-
log?.error(`copyDirectory error copying from ${srcDir} to ${destDir}: ${error instanceof Error ? error.message : error}`);
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { promises as fs } from 'node:fs';
|
|
2
|
-
export async function createDirectory(path, name, log) {
|
|
3
|
-
try {
|
|
4
|
-
await fs.access(path);
|
|
5
|
-
log.debug(`Directory ${name} already exists at path: ${path}`);
|
|
6
|
-
}
|
|
7
|
-
catch (err) {
|
|
8
|
-
if (err.code === 'ENOENT') {
|
|
9
|
-
try {
|
|
10
|
-
await fs.mkdir(path, { recursive: true });
|
|
11
|
-
log.info(`Created ${name}: ${path}`);
|
|
12
|
-
}
|
|
13
|
-
catch (err) {
|
|
14
|
-
log.error(`Error creating dir ${name} path ${path}: ${err}`);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
log.error(`Error accessing dir ${name} path ${path}: ${err}`);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function createZip(outputPath: string, ...sourcePaths: string[]): Promise<number>;
|
package/dist/utils/createZip.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { AnsiLogger } from '../logger/export.js';
|
|
2
|
-
export async function createZip(outputPath, ...sourcePaths) {
|
|
3
|
-
const log = new AnsiLogger({ logName: 'Archive', logTimestampFormat: 4, logLevel: "info" });
|
|
4
|
-
const { default: archiver } = await import('archiver');
|
|
5
|
-
const { glob } = await import('glob');
|
|
6
|
-
const { createWriteStream, statSync } = await import('node:fs');
|
|
7
|
-
const path = await import('node:path');
|
|
8
|
-
log.debug(`creating archive ${outputPath} from ${sourcePaths.join(', ')} ...`);
|
|
9
|
-
return new Promise((resolve, reject) => {
|
|
10
|
-
const output = createWriteStream(outputPath);
|
|
11
|
-
const archive = archiver('zip', {
|
|
12
|
-
zlib: { level: 9 },
|
|
13
|
-
});
|
|
14
|
-
output.on('close', () => {
|
|
15
|
-
log.debug(`archive ${outputPath} closed with ${archive.pointer()} total bytes`);
|
|
16
|
-
resolve(archive.pointer());
|
|
17
|
-
});
|
|
18
|
-
output.on('end', () => {
|
|
19
|
-
log.debug(`archive ${outputPath} data has been drained ${archive.pointer()} total bytes`);
|
|
20
|
-
});
|
|
21
|
-
archive.on('error', (error) => {
|
|
22
|
-
log.error(`archive error: ${error.message}`);
|
|
23
|
-
reject(error);
|
|
24
|
-
});
|
|
25
|
-
archive.on('warning', (error) => {
|
|
26
|
-
if (error.code === 'ENOENT') {
|
|
27
|
-
log.warn(`archive warning: ${error.message}`);
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
log.error(`archive warning: ${error.message}`);
|
|
31
|
-
reject(error);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
archive.on('entry', (entry) => {
|
|
35
|
-
log.debug(`- archive entry: ${entry.name}`);
|
|
36
|
-
});
|
|
37
|
-
archive.pipe(output);
|
|
38
|
-
for (const sourcePath of sourcePaths) {
|
|
39
|
-
let stats;
|
|
40
|
-
try {
|
|
41
|
-
stats = statSync(sourcePath);
|
|
42
|
-
}
|
|
43
|
-
catch (error) {
|
|
44
|
-
if (sourcePath.includes('*')) {
|
|
45
|
-
const files = glob.sync(sourcePath.replace(/\\/g, '/'));
|
|
46
|
-
log.debug(`adding files matching glob pattern: ${sourcePath}`);
|
|
47
|
-
for (const file of files) {
|
|
48
|
-
log.debug(`- glob file: ${file}`);
|
|
49
|
-
archive.file(file, { name: file });
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
log.error(`no files or directory found for pattern ${sourcePath}: ${error}`);
|
|
54
|
-
}
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
if (stats.isFile()) {
|
|
58
|
-
log.debug(`adding file: ${sourcePath}`);
|
|
59
|
-
archive.file(sourcePath, { name: path.basename(sourcePath) });
|
|
60
|
-
}
|
|
61
|
-
else if (stats.isDirectory()) {
|
|
62
|
-
log.debug(`adding directory: ${sourcePath}`);
|
|
63
|
-
archive.directory(sourcePath, path.basename(sourcePath));
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
log.debug(`finalizing archive ${outputPath}...`);
|
|
67
|
-
archive.finalize().catch(reject);
|
|
68
|
-
});
|
|
69
|
-
}
|
package/dist/utils/deepCopy.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function deepCopy<T>(value: T): T;
|
package/dist/utils/deepCopy.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
export function deepCopy(value) {
|
|
2
|
-
if (typeof value !== 'object' || value === null) {
|
|
3
|
-
return value;
|
|
4
|
-
}
|
|
5
|
-
else if (Array.isArray(value)) {
|
|
6
|
-
return value.map((item) => deepCopy(item));
|
|
7
|
-
}
|
|
8
|
-
else if (value instanceof Date) {
|
|
9
|
-
return new Date(value.getTime());
|
|
10
|
-
}
|
|
11
|
-
else if (value instanceof RegExp) {
|
|
12
|
-
return new RegExp(value.source, value.flags);
|
|
13
|
-
}
|
|
14
|
-
else if (value instanceof Map) {
|
|
15
|
-
const mapCopy = new Map();
|
|
16
|
-
for (const [origKey, origVal] of value.entries()) {
|
|
17
|
-
const clonedKey = deepCopy(origKey);
|
|
18
|
-
const clonedVal = deepCopy(origVal);
|
|
19
|
-
mapCopy.set(clonedKey, clonedVal);
|
|
20
|
-
}
|
|
21
|
-
return mapCopy;
|
|
22
|
-
}
|
|
23
|
-
else if (value instanceof Set) {
|
|
24
|
-
const setCopy = new Set();
|
|
25
|
-
value.forEach((item) => {
|
|
26
|
-
setCopy.add(deepCopy(item));
|
|
27
|
-
});
|
|
28
|
-
return setCopy;
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
const proto = Object.getPrototypeOf(value);
|
|
32
|
-
const copy = Object.create(proto);
|
|
33
|
-
for (const key in value) {
|
|
34
|
-
if (Object.prototype.hasOwnProperty.call(value, key)) {
|
|
35
|
-
copy[key] = deepCopy(value[key]);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return copy;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function deepEqual(a: any, b: any, excludeProperties?: string[]): boolean;
|