@victronenergy/mfd-modules 10.2.0 → 10.4.1
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/dist/src/Modules/App/App.provider.d.ts +2 -1
- package/dist/src/Modules/App/App.provider.d.ts.map +1 -1
- package/dist/src/Modules/App/App.provider.js +22 -0
- package/dist/src/Modules/App/App.provider.js.map +1 -1
- package/dist/src/Modules/App/App.store.d.ts +45 -8
- package/dist/src/Modules/App/App.store.d.ts.map +1 -1
- package/dist/src/Modules/App/App.store.js +71 -1
- package/dist/src/Modules/App/App.store.js.map +1 -1
- package/dist/src/utils/hsvw.d.ts +29 -0
- package/dist/src/utils/hsvw.d.ts.map +1 -1
- package/dist/src/utils/hsvw.js +69 -0
- package/dist/src/utils/hsvw.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.provider.d.ts","sourceRoot":"/","sources":["src/Modules/App/App.provider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"App.provider.d.ts","sourceRoot":"/","sources":["src/Modules/App/App.provider.ts"],"names":[],"mappings":"AAEA,OAAO,EAAuD,WAAW,EAAa,MAAM,aAAa,CAAA;AAGzG,eAAO,MAAM,MAAM,QAAO,WA6FzB,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useEffect, useMemo } from "react";
|
|
2
2
|
import { useMqtt, useTopicState } from "../Mqtt";
|
|
3
3
|
import { useAppStore } from "./App.store";
|
|
4
|
+
import { stringToHSVWPresets } from "../../utils/hsvw";
|
|
4
5
|
export var useApp = function () {
|
|
5
6
|
var appStore = useAppStore();
|
|
6
7
|
var mqtt = useMqtt();
|
|
@@ -14,6 +15,9 @@ export var useApp = function () {
|
|
|
14
15
|
},
|
|
15
16
|
guiVersion: "N/".concat(portalId, "/settings/0/Settings/Gui/RunningVersion"),
|
|
16
17
|
electricalPowerIndicator: "N/".concat(portalId, "/settings/0/Settings/Gui/ElectricalPowerIndicator"),
|
|
18
|
+
rgbColorPresetsArray: "N/".concat(portalId, "/settings/0/Settings/Gui2/Switchpane/Preset/RGB"),
|
|
19
|
+
rgbwColorPresetsArray: "N/".concat(portalId, "/settings/0/Settings/Gui2/Switchpane/Preset/RGBW"),
|
|
20
|
+
cctColorPresetsArray: "N/".concat(portalId, "/settings/0/Settings/Gui2/Switchpane/Preset/CCT"),
|
|
17
21
|
}); };
|
|
18
22
|
var topics = useMemo(function () { return getTopics(mqtt.portalId); }, [mqtt.portalId]);
|
|
19
23
|
var locked = useTopicState(topics.locked);
|
|
@@ -23,6 +27,9 @@ export var useApp = function () {
|
|
|
23
27
|
var volumeUnit = useTopicState(topics.units.volume);
|
|
24
28
|
var guiVersion = useTopicState(topics.guiVersion);
|
|
25
29
|
var electricalPowerIndicator = useTopicState(topics.electricalPowerIndicator);
|
|
30
|
+
var rgbColorPresetsCommaSeparatedString = useTopicState(topics.rgbColorPresetsArray);
|
|
31
|
+
var rgbwColorPresetsCommaSeparatedString = useTopicState(topics.rgbwColorPresetsArray);
|
|
32
|
+
var cctColorPresetsCommaSeparatedString = useTopicState(topics.cctColorPresetsArray);
|
|
26
33
|
useEffect(function () {
|
|
27
34
|
if (locked !== undefined) {
|
|
28
35
|
appStore.setLockedWithoutPersistence(!!locked);
|
|
@@ -58,6 +65,21 @@ export var useApp = function () {
|
|
|
58
65
|
appStore.setElectricalPowerIndicator(electricalPowerIndicator);
|
|
59
66
|
}
|
|
60
67
|
}, [electricalPowerIndicator]);
|
|
68
|
+
useEffect(function () {
|
|
69
|
+
if (rgbColorPresetsCommaSeparatedString !== undefined) {
|
|
70
|
+
appStore.setRGBColorPresets(stringToHSVWPresets(rgbColorPresetsCommaSeparatedString));
|
|
71
|
+
}
|
|
72
|
+
}, [rgbColorPresetsCommaSeparatedString]);
|
|
73
|
+
useEffect(function () {
|
|
74
|
+
if (rgbwColorPresetsCommaSeparatedString !== undefined) {
|
|
75
|
+
appStore.setRGBWColorPresets(stringToHSVWPresets(rgbwColorPresetsCommaSeparatedString));
|
|
76
|
+
}
|
|
77
|
+
}, [rgbwColorPresetsCommaSeparatedString]);
|
|
78
|
+
useEffect(function () {
|
|
79
|
+
if (cctColorPresetsCommaSeparatedString !== undefined) {
|
|
80
|
+
appStore.setCCTColorPresets(stringToHSVWPresets(cctColorPresetsCommaSeparatedString));
|
|
81
|
+
}
|
|
82
|
+
}, [cctColorPresetsCommaSeparatedString]);
|
|
61
83
|
return appStore;
|
|
62
84
|
};
|
|
63
85
|
//# sourceMappingURL=App.provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.provider.js","sourceRoot":"/","sources":["src/Modules/App/App.provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,EAAY,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC1D,OAAO,EAA0C,WAAW,
|
|
1
|
+
{"version":3,"file":"App.provider.js","sourceRoot":"/","sources":["src/Modules/App/App.provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,EAAY,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC1D,OAAO,EAA0C,WAAW,EAA0B,MAAM,aAAa,CAAA;AACzG,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAEtD,MAAM,CAAC,IAAM,MAAM,GAAG;IACpB,IAAM,QAAQ,GAAG,WAAW,EAAE,CAAA;IAC9B,IAAM,IAAI,GAAG,OAAO,EAAE,CAAA;IAEtB,IAAM,SAAS,GAAG,UAAC,QAAkB,IAAK,OAAA,CAAC;QACzC,MAAM,EAAE,YAAK,QAAQ,4CAAyC;QAC9D,eAAe,EAAE,YAAK,QAAQ,8BAA2B;QACzD,KAAK,EAAE;YACL,WAAW,EAAE,YAAK,QAAQ,kD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mC,KAAK,SAAS,EAAE,CAAC;YACtD,QAAQ,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,mCAAmC,CAAC,CAAC,CAAA;QACvF,CAAC;IACH,CAAC,EAAE,CAAC,mCAAmC,CAAC,CAAC,CAAA;IAEzC,SAAS,CAAC;QACR,IAAI,oCAAoC,KAAK,SAAS,EAAE,CAAC;YACvD,QAAQ,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,oCAAoC,CAAC,CAAC,CAAA;QACzF,CAAC;IACH,CAAC,EAAE,CAAC,oCAAoC,CAAC,CAAC,CAAA;IAE1C,SAAS,CAAC;QACR,IAAI,mCAAmC,KAAK,SAAS,EAAE,CAAC;YACtD,QAAQ,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,mCAAmC,CAAC,CAAC,CAAA;QACvF,CAAC;IACH,CAAC,EAAE,CAAC,mCAAmC,CAAC,CAAC,CAAA;IAEzC,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA","sourcesContent":["import { useEffect, useMemo } from \"react\"\nimport { PortalId, useMqtt, useTopicState } from \"../Mqtt\"\nimport { TemperatureUnit, SpeedUnit, VolumeUnit, useAppStore, AppProvider, PowerUnit } from \"./App.store\"\nimport { stringToHSVWPresets } from \"../../utils/hsvw\"\n\nexport const useApp = (): AppProvider => {\n const appStore = useAppStore()\n const mqtt = useMqtt()\n\n const getTopics = (portalId: PortalId) => ({\n locked: `N/${portalId}/settings/0/Settings/VenusApp/LockState`,\n firmwareVersion: `N/${portalId}/system/0/FirmwareVersion`,\n units: {\n temperature: `N/${portalId}/settings/0/Settings/System/Units/Temperature`,\n speed: `N/${portalId}/settings/0/Settings/Gps/SpeedUnit`,\n volume: `N/${portalId}/settings/0/Settings/System/VolumeUnit`,\n },\n guiVersion: `N/${portalId}/settings/0/Settings/Gui/RunningVersion`,\n electricalPowerIndicator: `N/${portalId}/settings/0/Settings/Gui/ElectricalPowerIndicator`,\n rgbColorPresetsArray: `N/${portalId}/settings/0/Settings/Gui2/Switchpane/Preset/RGB`,\n rgbwColorPresetsArray: `N/${portalId}/settings/0/Settings/Gui2/Switchpane/Preset/RGBW`,\n cctColorPresetsArray: `N/${portalId}/settings/0/Settings/Gui2/Switchpane/Preset/CCT`,\n })\n\n const topics = useMemo(() => getTopics(mqtt.portalId), [mqtt.portalId])\n\n const locked = useTopicState<number>(topics.locked)\n const firmwareVersion = useTopicState<string>(topics.firmwareVersion)\n const temperatureUnit = useTopicState<string>(topics.units.temperature)\n const speedUnit = useTopicState<string>(topics.units.speed)\n const volumeUnit = useTopicState<number>(topics.units.volume)\n const guiVersion = useTopicState<number>(topics.guiVersion)\n const electricalPowerIndicator = useTopicState<number>(topics.electricalPowerIndicator)\n const rgbColorPresetsCommaSeparatedString = useTopicState<string>(topics.rgbColorPresetsArray)\n const rgbwColorPresetsCommaSeparatedString = useTopicState<string>(topics.rgbwColorPresetsArray)\n const cctColorPresetsCommaSeparatedString = useTopicState<string>(topics.cctColorPresetsArray)\n\n useEffect(() => {\n if (locked !== undefined) {\n appStore.setLockedWithoutPersistence(!!locked)\n }\n }, [locked])\n\n useEffect(() => {\n if (firmwareVersion) {\n appStore.setFirmwareVersion(firmwareVersion)\n }\n }, [firmwareVersion])\n\n useEffect(() => {\n if (temperatureUnit !== undefined) {\n appStore.setUnit(\"temperature\", temperatureUnit as TemperatureUnit)\n }\n }, [temperatureUnit])\n\n useEffect(() => {\n if (speedUnit !== undefined) {\n appStore.setUnit(\"speed\", speedUnit as SpeedUnit)\n }\n }, [speedUnit])\n\n useEffect(() => {\n if (volumeUnit !== undefined) {\n appStore.setUnit(\"volume\", volumeUnit as VolumeUnit)\n }\n }, [volumeUnit])\n\n useEffect(() => {\n if (guiVersion) {\n appStore.setGuiVersion(guiVersion)\n }\n }, [guiVersion])\n\n useEffect(() => {\n if (electricalPowerIndicator !== undefined) {\n appStore.setElectricalPowerIndicator(electricalPowerIndicator as PowerUnit)\n }\n }, [electricalPowerIndicator])\n\n useEffect(() => {\n if (rgbColorPresetsCommaSeparatedString !== undefined) {\n appStore.setRGBColorPresets(stringToHSVWPresets(rgbColorPresetsCommaSeparatedString))\n }\n }, [rgbColorPresetsCommaSeparatedString])\n\n useEffect(() => {\n if (rgbwColorPresetsCommaSeparatedString !== undefined) {\n appStore.setRGBWColorPresets(stringToHSVWPresets(rgbwColorPresetsCommaSeparatedString))\n }\n }, [rgbwColorPresetsCommaSeparatedString])\n\n useEffect(() => {\n if (cctColorPresetsCommaSeparatedString !== undefined) {\n appStore.setCCTColorPresets(stringToHSVWPresets(cctColorPresetsCommaSeparatedString))\n }\n }, [cctColorPresetsCommaSeparatedString])\n\n return appStore\n}\n"]}
|
|
@@ -1,13 +1,37 @@
|
|
|
1
1
|
import { MqttStore } from "../Mqtt";
|
|
2
|
+
import { HSVWColorPresets } from "../../utils/hsvw";
|
|
3
|
+
export interface IUnit {
|
|
4
|
+
temperature: TemperatureUnit;
|
|
5
|
+
speed: SpeedUnit;
|
|
6
|
+
volume: VolumeUnit;
|
|
7
|
+
}
|
|
2
8
|
export interface AppState {
|
|
3
9
|
page: string;
|
|
4
10
|
locked: boolean;
|
|
5
11
|
remote: boolean;
|
|
12
|
+
language?: string;
|
|
13
|
+
firmwareVersion: string;
|
|
14
|
+
units: IUnit;
|
|
15
|
+
guiVersion: number;
|
|
16
|
+
electricalPowerIndicator: PowerUnit;
|
|
17
|
+
rgbColorPresets: HSVWColorPresets;
|
|
18
|
+
rgbwColorPresets: HSVWColorPresets;
|
|
19
|
+
cctColorPresets: HSVWColorPresets;
|
|
20
|
+
humanReadableFirmwareVersion: string;
|
|
21
|
+
temperatureUnitToHumanReadable: string;
|
|
22
|
+
temperatureUnit: TemperatureUnit;
|
|
23
|
+
speedUnitToHumanReadable: string;
|
|
24
|
+
speedUnit: SpeedUnit;
|
|
25
|
+
volumeUnitToHumanReadable: string;
|
|
26
|
+
volumeUnit: VolumeUnit;
|
|
27
|
+
toggleRemote: () => void;
|
|
28
|
+
toggleLocked: () => void;
|
|
29
|
+
setPage: (page: string) => void;
|
|
6
30
|
}
|
|
7
|
-
interface
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
31
|
+
export interface AppProvider extends AppState {
|
|
32
|
+
updateRGBColorPresets: (presets: HSVWColorPresets) => void;
|
|
33
|
+
updateRGBWColorPresets: (presets: HSVWColorPresets) => void;
|
|
34
|
+
updateCCTColorPresets: (presets: HSVWColorPresets) => void;
|
|
11
35
|
}
|
|
12
36
|
export type TemperatureUnit = "fahrenheit" | "celsius";
|
|
13
37
|
export type SpeedUnit = "km/h" | "m/s" | "mph" | "kt";
|
|
@@ -17,7 +41,12 @@ export declare enum VolumeUnit {
|
|
|
17
41
|
GALLONS_IMPERIAL = 2,
|
|
18
42
|
GALLONS_US = 3
|
|
19
43
|
}
|
|
20
|
-
export declare
|
|
44
|
+
export declare enum PowerUnit {
|
|
45
|
+
WATTS = 0,
|
|
46
|
+
AMPS = 1,
|
|
47
|
+
MIXED = 2
|
|
48
|
+
}
|
|
49
|
+
export declare class AppStore implements AppProvider {
|
|
21
50
|
page: string;
|
|
22
51
|
locked: boolean;
|
|
23
52
|
remote: boolean;
|
|
@@ -26,7 +55,10 @@ export declare class AppStore {
|
|
|
26
55
|
firmwareVersion: string;
|
|
27
56
|
units: IUnit;
|
|
28
57
|
guiVersion: number;
|
|
29
|
-
electricalPowerIndicator:
|
|
58
|
+
electricalPowerIndicator: PowerUnit;
|
|
59
|
+
rgbColorPresets: HSVWColorPresets;
|
|
60
|
+
rgbwColorPresets: HSVWColorPresets;
|
|
61
|
+
cctColorPresets: HSVWColorPresets;
|
|
30
62
|
constructor(mqttStore: MqttStore);
|
|
31
63
|
get humanReadableFirmwareVersion(): any;
|
|
32
64
|
get temperatureUnitToHumanReadable(): "°C" | "°F";
|
|
@@ -44,8 +76,13 @@ export declare class AppStore {
|
|
|
44
76
|
setFirmwareVersion: (firmwareVersion: string) => string;
|
|
45
77
|
setUnit: <K extends keyof IUnit>(unit: K, value: IUnit[K]) => void;
|
|
46
78
|
setGuiVersion: (guiVersion: number) => number;
|
|
47
|
-
setElectricalPowerIndicator: (electricalPowerIndicator:
|
|
79
|
+
setElectricalPowerIndicator: (electricalPowerIndicator: PowerUnit) => PowerUnit;
|
|
80
|
+
setRGBColorPresets: (presets: HSVWColorPresets) => HSVWColorPresets;
|
|
81
|
+
setRGBWColorPresets: (presets: HSVWColorPresets) => HSVWColorPresets;
|
|
82
|
+
setCCTColorPresets: (presets: HSVWColorPresets) => HSVWColorPresets;
|
|
83
|
+
updateRGBColorPresets: (presets: HSVWColorPresets) => void;
|
|
84
|
+
updateRGBWColorPresets: (presets: HSVWColorPresets) => void;
|
|
85
|
+
updateCCTColorPresets: (presets: HSVWColorPresets) => void;
|
|
48
86
|
}
|
|
49
87
|
export declare function useAppStore(): AppStore;
|
|
50
|
-
export {};
|
|
51
88
|
//# sourceMappingURL=App.store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.store.d.ts","sourceRoot":"/","sources":["src/Modules/App/App.store.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAW,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"App.store.d.ts","sourceRoot":"/","sources":["src/Modules/App/App.store.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAW,MAAM,SAAS,CAAA;AAC5C,OAAO,EAAyB,gBAAgB,EAAuB,MAAM,kBAAkB,CAAA;AAE/F,MAAM,WAAW,KAAK;IACpB,WAAW,EAAE,eAAe,CAAA;IAC5B,KAAK,EAAE,SAAS,CAAA;IAChB,MAAM,EAAE,UAAU,CAAA;CACnB;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,OAAO,CAAA;IACf,MAAM,EAAE,OAAO,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,eAAe,EAAE,MAAM,CAAA;IACvB,KAAK,EAAE,KAAK,CAAA;IACZ,UA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HumanReadable } from "../../utils/util";
|
|
15
15
|
import { VIEWS } from "../../utils/constants";
|
|
16
16
|
import { useMqtt } from "../Mqtt";
|
|
17
|
+
import { emptyHSVWColorPresets, hwvwPresetsToString } from "../../utils/hsvw";
|
|
17
18
|
export var VolumeUnit;
|
|
18
19
|
(function (VolumeUnit) {
|
|
19
20
|
VolumeUnit[VolumeUnit["CUBIC_METERS"] = 0] = "CUBIC_METERS";
|
|
@@ -21,6 +22,12 @@ export var VolumeUnit;
|
|
|
21
22
|
VolumeUnit[VolumeUnit["GALLONS_IMPERIAL"] = 2] = "GALLONS_IMPERIAL";
|
|
22
23
|
VolumeUnit[VolumeUnit["GALLONS_US"] = 3] = "GALLONS_US";
|
|
23
24
|
})(VolumeUnit || (VolumeUnit = {}));
|
|
25
|
+
export var PowerUnit;
|
|
26
|
+
(function (PowerUnit) {
|
|
27
|
+
PowerUnit[PowerUnit["WATTS"] = 0] = "WATTS";
|
|
28
|
+
PowerUnit[PowerUnit["AMPS"] = 1] = "AMPS";
|
|
29
|
+
PowerUnit[PowerUnit["MIXED"] = 2] = "MIXED";
|
|
30
|
+
})(PowerUnit || (PowerUnit = {}));
|
|
24
31
|
var store;
|
|
25
32
|
var AppStore = /** @class */ (function () {
|
|
26
33
|
function AppStore(mqttStore) {
|
|
@@ -84,6 +91,24 @@ var AppStore = /** @class */ (function () {
|
|
|
84
91
|
writable: true,
|
|
85
92
|
value: void 0
|
|
86
93
|
});
|
|
94
|
+
Object.defineProperty(this, "rgbColorPresets", {
|
|
95
|
+
enumerable: true,
|
|
96
|
+
configurable: true,
|
|
97
|
+
writable: true,
|
|
98
|
+
value: void 0
|
|
99
|
+
});
|
|
100
|
+
Object.defineProperty(this, "rgbwColorPresets", {
|
|
101
|
+
enumerable: true,
|
|
102
|
+
configurable: true,
|
|
103
|
+
writable: true,
|
|
104
|
+
value: void 0
|
|
105
|
+
});
|
|
106
|
+
Object.defineProperty(this, "cctColorPresets", {
|
|
107
|
+
enumerable: true,
|
|
108
|
+
configurable: true,
|
|
109
|
+
writable: true,
|
|
110
|
+
value: void 0
|
|
111
|
+
});
|
|
87
112
|
Object.defineProperty(this, "setPage", {
|
|
88
113
|
enumerable: true,
|
|
89
114
|
configurable: true,
|
|
@@ -165,6 +190,48 @@ var AppStore = /** @class */ (function () {
|
|
|
165
190
|
return (_this.electricalPowerIndicator = electricalPowerIndicator);
|
|
166
191
|
}
|
|
167
192
|
});
|
|
193
|
+
Object.defineProperty(this, "setRGBColorPresets", {
|
|
194
|
+
enumerable: true,
|
|
195
|
+
configurable: true,
|
|
196
|
+
writable: true,
|
|
197
|
+
value: function (presets) { return (_this.rgbColorPresets = presets); }
|
|
198
|
+
});
|
|
199
|
+
Object.defineProperty(this, "setRGBWColorPresets", {
|
|
200
|
+
enumerable: true,
|
|
201
|
+
configurable: true,
|
|
202
|
+
writable: true,
|
|
203
|
+
value: function (presets) { return (_this.rgbwColorPresets = presets); }
|
|
204
|
+
});
|
|
205
|
+
Object.defineProperty(this, "setCCTColorPresets", {
|
|
206
|
+
enumerable: true,
|
|
207
|
+
configurable: true,
|
|
208
|
+
writable: true,
|
|
209
|
+
value: function (presets) { return (_this.cctColorPresets = presets); }
|
|
210
|
+
});
|
|
211
|
+
Object.defineProperty(this, "updateRGBColorPresets", {
|
|
212
|
+
enumerable: true,
|
|
213
|
+
configurable: true,
|
|
214
|
+
writable: true,
|
|
215
|
+
value: function (presets) {
|
|
216
|
+
_this.mqtt.publish("W/".concat(_this.mqtt.portalId, "/settings/0/Settings/Gui2/Switchpane/Preset/RGB"), hwvwPresetsToString(presets));
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
Object.defineProperty(this, "updateRGBWColorPresets", {
|
|
220
|
+
enumerable: true,
|
|
221
|
+
configurable: true,
|
|
222
|
+
writable: true,
|
|
223
|
+
value: function (presets) {
|
|
224
|
+
_this.mqtt.publish("W/".concat(_this.mqtt.portalId, "/settings/0/Settings/Gui2/Switchpane/Preset/RGBW"), hwvwPresetsToString(presets));
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
Object.defineProperty(this, "updateCCTColorPresets", {
|
|
228
|
+
enumerable: true,
|
|
229
|
+
configurable: true,
|
|
230
|
+
writable: true,
|
|
231
|
+
value: function (presets) {
|
|
232
|
+
_this.mqtt.publish("W/".concat(_this.mqtt.portalId, "/settings/0/Settings/Gui2/Switchpane/Preset/CCT"), hwvwPresetsToString(presets));
|
|
233
|
+
}
|
|
234
|
+
});
|
|
168
235
|
makeAutoObservable(this, { mqtt: false });
|
|
169
236
|
this.mqtt = mqttStore;
|
|
170
237
|
this.firmwareVersion = "-";
|
|
@@ -174,7 +241,10 @@ var AppStore = /** @class */ (function () {
|
|
|
174
241
|
volume: VolumeUnit.CUBIC_METERS,
|
|
175
242
|
};
|
|
176
243
|
this.guiVersion = 2;
|
|
177
|
-
this.electricalPowerIndicator =
|
|
244
|
+
this.electricalPowerIndicator = PowerUnit.AMPS;
|
|
245
|
+
this.rgbColorPresets = emptyHSVWColorPresets;
|
|
246
|
+
this.rgbwColorPresets = emptyHSVWColorPresets;
|
|
247
|
+
this.cctColorPresets = emptyHSVWColorPresets;
|
|
178
248
|
}
|
|
179
249
|
Object.defineProperty(AppStore.prototype, "humanReadableFirmwareVersion", {
|
|
180
250
|
get: function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.store.js","sourceRoot":"/","sources":["src/Modules/App/App.store.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAC7C,OAAO,EAAa,OAAO,EAAE,MAAM,SAAS,CAAA;AAgB5C,MAAM,CAAN,IAAY,UAKX;AALD,WAAY,UAAU;IACpB,2DAAgB,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KAAK,CAAC,MAAM,CAAA;QAC1B,CAAC;;;OAAA;IAkCH,eAAC;AAAD,CAAC,AAvGD,IAuGC;;AAED,SAAS,eAAe,CAAC,SAAoB;IAC3C,IAAM,MAAM,GAAG,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,IAAI,QAAQ,CAAC,SAAS,CAAC,CAAA;IAC/C,4CAA4C;IAC5C,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO,MAAM,CAAA;IAChD,sCAAsC;IACtC,IAAI,CAAC,KAAK;QAAE,KAAK,GAAG,MAAM,CAAA;IAE1B,OAAO,MAAM,CAAA;AACf,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,IAAM,IAAI,GAAG,OAAO,EAAE,CAAA;IACtB,OAAO,OAAO,CAAC,cAAM,OAAA,eAAe,CAAC,IAAI,CAAC,EAArB,CAAqB,EAAE,EAAE,CAAC,CAAA;AACjD,CAAC","sourcesContent":["import { makeAutoObservable } from \"mobx\"\nimport { useMemo } from \"react\"\nimport { versionToHumanReadable } from \"../../utils/util\"\nimport { VIEWS } from \"../../utils/constants\"\nimport { MqttStore, useMqtt } from \"../Mqtt\"\n\nexport interface AppState {\n page: string\n locked: boolean\n remote: boolean\n}\n\ninterface IUnit {\n temperature: TemperatureUnit\n speed: SpeedUnit\n volume: VolumeUnit\n}\n\nexport type TemperatureUnit = \"fahrenheit\" | \"celsius\"\nexport type SpeedUnit = \"km/h\" | \"m/s\" | \"mph\" | \"kt\"\nexport enum VolumeUnit {\n CUBIC_METERS = 0,\n LITRES = 1,\n GALLONS_IMPERIAL = 2,\n GALLONS_US = 3,\n}\n\nlet store: AppStore\n\nexport class AppStore {\n page: string = VIEWS.METRICS\n locked: boolean = false\n // figure out whether we are connecting to VRM provided MQTT broker\n // see https://github.com/victronenergy/dbus-flashmq?tab=readme-ov-file#determining-the-broker-url-for-a-given-installation\n remote: boolean =\n typeof window !== \"undefined\" &&\n window?.location.protocol === \"https:\" &&\n window?.location.hostname.endsWith(\"victronenergy.com\") &&\n (window?.location.hostname.startsWith(\"mqtt\") || window?.location.hostname.startsWith(\"webmqtt\"))\n language?: string\n mqtt: MqttStore\n firmwareVersion: string\n units: IUnit\n guiVersion: number\n electricalPowerIndicator: number\n\n constructor(mqttStore: MqttStore) {\n makeAutoObservable(this, { mqtt: false })\n this.mqtt = mqttStore\n this.firmwareVersion = \"-\"\n this.units = {\n temperature: \"celsius\",\n speed: \"km/h\",\n volume: VolumeUnit.CUBIC_METERS,\n }\n this.guiVersion = 2\n this.electricalPowerIndicator = 1\n }\n\n get humanReadableFirmwareVersion() {\n return versionToHumanReadable(+this.firmwareVersion) || \"-\"\n }\n\n get temperatureUnitToHumanReadable() {\n if (this.units.temperature === \"celsius\") {\n return \"°C\"\n }\n\n return \"°F\"\n }\n\n get temperatureUnit() {\n return this.units.temperature\n }\n\n get speedUnitToHumanReadable() {\n return this.units.speed\n }\n\n get speedUnit() {\n return this.units.speed\n }\n\n get volumeUnitToHumanReadable() {\n switch (this.units.volume) {\n case VolumeUnit.CUBIC_METERS:\n return \"m³\"\n case VolumeUnit.LITRES:\n return \"l\"\n case VolumeUnit.GALLONS_IMPERIAL:\n return \"gal\"\n case VolumeUnit.GALLONS_US:\n return \"gal\"\n }\n }\n\n get volumeUnit() {\n return this.units.volume\n }\n\n setPage = (page: string) => (this.page = page)\n setLockedWithoutPersistence = (locked: boolean) => (this.locked = locked)\n setRemote = (remote: boolean) => {\n this.remote = remote\n\n // @ts-expect-error Missing TS declaration for venusNativeApp\n if (window?.venusNativeApp) {\n if (remote) {\n // @ts-expect-error Missing TS declaration for venusNativeApp\n window.venusNativeApp.switchToRemote()\n } else {\n // @ts-expect-error Missing TS declaration for venusNativeApp\n window.venusNativeApp.switchToLocal()\n }\n }\n }\n toggleRemote = () => this.setRemote(!this.remote)\n toggleLocked = () => {\n this.mqtt.publish(`N/${this.mqtt.portalId}/settings/0/Settings/VenusApp/LockState`, +!this.locked)\n this.locked = !this.locked\n }\n setLanguage = (language: string) => (this.language = language)\n setFirmwareVersion = (firmwareVersion: string) => (this.firmwareVersion = firmwareVersion)\n setUnit = <K extends keyof IUnit>(unit: K, value: IUnit[K]) => {\n this.units = {\n ...this.units,\n [unit]: value,\n }\n }\n setGuiVersion = (guiVersion: number) => (this.guiVersion = guiVersion)\n setElectricalPowerIndicator = (electricalPowerIndicator: number) =>\n (this.electricalPowerIndicator = electricalPowerIndicator)\n}\n\nfunction initializeStore(mqttStore: MqttStore) {\n const _store = store ?? new AppStore(mqttStore)\n // For SSG and SSR always create a new store\n if (typeof window === \"undefined\") return _store\n // Create the store once in the client\n if (!store) store = _store\n\n return _store\n}\n\nexport function useAppStore() {\n const mqtt = useMqtt()\n return useMemo(() => initializeStore(mqtt), [])\n}\n"]}
|
|
1
|
+
{"version":3,"file":"App.store.js","sourceRoot":"/","sources":["src/Modules/App/App.store.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAC7C,OAAO,EAAa,OAAO,EAAE,MAAM,SAAS,CAAA;AAC5C,OAAO,EAAE,qBAAqB,EAAoB,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AA2C/F,MAAM,CAAN,IAAY,UAKX;AALD,WAAY,UAAU;IACpB,2DAAgB,CAAA;IAChB,+CAAU,CAAA;IACV,mEAAoB,CAAA;IACpB,uDAAc,CAAA;AAChB,CAAC,EALW,UAAU,KAAV,UAAU,QAKrB;AACD,MAAM,CAAN,IAAY,SAIX;AAJD,WAAY,SAAS;IACnB,2CAAS,CAAA;IACT,yCAAQ,CAAA;IACR,2CAAS,CAAA;AACX,CAAC,EAJW,SAAS,KAAT,SAAS,QAIpB;AAED,IAAI,KAAe,CAAA;AAEnB;I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CAAsC;IACtC,IAAI,CAAC,KAAK;QAAE,KAAK,GAAG,MAAM,CAAA;IAE1B,OAAO,MAAM,CAAA;AACf,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,IAAM,IAAI,GAAG,OAAO,EAAE,CAAA;IACtB,OAAO,OAAO,CAAC,cAAM,OAAA,eAAe,CAAC,IAAI,CAAC,EAArB,CAAqB,EAAE,EAAE,CAAC,CAAA;AACjD,CAAC","sourcesContent":["import { makeAutoObservable } from \"mobx\"\nimport { useMemo } from \"react\"\nimport { versionToHumanReadable } from \"../../utils/util\"\nimport { VIEWS } from \"../../utils/constants\"\nimport { MqttStore, useMqtt } from \"../Mqtt\"\nimport { emptyHSVWColorPresets, HSVWColorPresets, hwvwPresetsToString } from \"../../utils/hsvw\"\n\nexport interface IUnit {\n temperature: TemperatureUnit\n speed: SpeedUnit\n volume: VolumeUnit\n}\n\nexport interface AppState {\n page: string\n locked: boolean\n remote: boolean\n language?: string\n firmwareVersion: string\n units: IUnit\n guiVersion: number\n electricalPowerIndicator: PowerUnit\n\n rgbColorPresets: HSVWColorPresets\n rgbwColorPresets: HSVWColorPresets\n cctColorPresets: HSVWColorPresets\n\n humanReadableFirmwareVersion: string\n temperatureUnitToHumanReadable: string\n temperatureUnit: TemperatureUnit\n speedUnitToHumanReadable: string\n speedUnit: SpeedUnit\n volumeUnitToHumanReadable: string\n volumeUnit: VolumeUnit\n\n toggleRemote: () => void\n toggleLocked: () => void\n setPage: (page: string) => void\n}\n\nexport interface AppProvider extends AppState {\n updateRGBColorPresets: (presets: HSVWColorPresets) => void\n updateRGBWColorPresets: (presets: HSVWColorPresets) => void\n updateCCTColorPresets: (presets: HSVWColorPresets) => void\n}\n\nexport type TemperatureUnit = \"fahrenheit\" | \"celsius\"\nexport type SpeedUnit = \"km/h\" | \"m/s\" | \"mph\" | \"kt\"\nexport enum VolumeUnit {\n CUBIC_METERS = 0,\n LITRES = 1,\n GALLONS_IMPERIAL = 2,\n GALLONS_US = 3,\n}\nexport enum PowerUnit {\n WATTS = 0,\n AMPS = 1,\n MIXED = 2, // AC in Watts, DC in Ampers\n}\n\nlet store: AppStore\n\nexport class AppStore implements AppProvider {\n page: string = VIEWS.METRICS\n locked: boolean = false\n // figure out whether we are connecting to VRM provided MQTT broker\n // see https://github.com/victronenergy/dbus-flashmq?tab=readme-ov-file#determining-the-broker-url-for-a-given-installation\n remote: boolean =\n typeof window !== \"undefined\" &&\n window?.location.protocol === \"https:\" &&\n window?.location.hostname.endsWith(\"victronenergy.com\") &&\n (window?.location.hostname.startsWith(\"mqtt\") || window?.location.hostname.startsWith(\"webmqtt\"))\n language?: string\n mqtt: MqttStore\n firmwareVersion: string\n units: IUnit\n guiVersion: number\n electricalPowerIndicator: PowerUnit\n\n rgbColorPresets: HSVWColorPresets\n rgbwColorPresets: HSVWColorPresets\n cctColorPresets: HSVWColorPresets\n\n constructor(mqttStore: MqttStore) {\n makeAutoObservable(this, { mqtt: false })\n this.mqtt = mqttStore\n this.firmwareVersion = \"-\"\n this.units = {\n temperature: \"celsius\",\n speed: \"km/h\",\n volume: VolumeUnit.CUBIC_METERS,\n }\n this.guiVersion = 2\n this.electricalPowerIndicator = PowerUnit.AMPS\n this.rgbColorPresets = emptyHSVWColorPresets\n this.rgbwColorPresets = emptyHSVWColorPresets\n this.cctColorPresets = emptyHSVWColorPresets\n }\n\n get humanReadableFirmwareVersion() {\n return versionToHumanReadable(+this.firmwareVersion) || \"-\"\n }\n\n get temperatureUnitToHumanReadable() {\n if (this.units.temperature === \"celsius\") {\n return \"°C\"\n }\n\n return \"°F\"\n }\n\n get temperatureUnit() {\n return this.units.temperature\n }\n\n get speedUnitToHumanReadable() {\n return this.units.speed\n }\n\n get speedUnit() {\n return this.units.speed\n }\n\n get volumeUnitToHumanReadable() {\n switch (this.units.volume) {\n case VolumeUnit.CUBIC_METERS:\n return \"m³\"\n case VolumeUnit.LITRES:\n return \"l\"\n case VolumeUnit.GALLONS_IMPERIAL:\n return \"gal\"\n case VolumeUnit.GALLONS_US:\n return \"gal\"\n }\n }\n\n get volumeUnit() {\n return this.units.volume\n }\n\n setPage = (page: string) => (this.page = page)\n setLockedWithoutPersistence = (locked: boolean) => (this.locked = locked)\n setRemote = (remote: boolean) => {\n this.remote = remote\n\n // @ts-expect-error Missing TS declaration for venusNativeApp\n if (window?.venusNativeApp) {\n if (remote) {\n // @ts-expect-error Missing TS declaration for venusNativeApp\n window.venusNativeApp.switchToRemote()\n } else {\n // @ts-expect-error Missing TS declaration for venusNativeApp\n window.venusNativeApp.switchToLocal()\n }\n }\n }\n toggleRemote = () => this.setRemote(!this.remote)\n toggleLocked = () => {\n this.mqtt.publish(`N/${this.mqtt.portalId}/settings/0/Settings/VenusApp/LockState`, +!this.locked)\n this.locked = !this.locked\n }\n setLanguage = (language: string) => (this.language = language)\n setFirmwareVersion = (firmwareVersion: string) => (this.firmwareVersion = firmwareVersion)\n setUnit = <K extends keyof IUnit>(unit: K, value: IUnit[K]) => {\n this.units = {\n ...this.units,\n [unit]: value,\n }\n }\n setGuiVersion = (guiVersion: number) => (this.guiVersion = guiVersion)\n setElectricalPowerIndicator = (electricalPowerIndicator: PowerUnit) =>\n (this.electricalPowerIndicator = electricalPowerIndicator)\n\n setRGBColorPresets = (presets: HSVWColorPresets) => (this.rgbColorPresets = presets)\n setRGBWColorPresets = (presets: HSVWColorPresets) => (this.rgbwColorPresets = presets)\n setCCTColorPresets = (presets: HSVWColorPresets) => (this.cctColorPresets = presets)\n\n updateRGBColorPresets = (presets: HSVWColorPresets) => {\n this.mqtt.publish(\n `W/${this.mqtt.portalId}/settings/0/Settings/Gui2/Switchpane/Preset/RGB`,\n hwvwPresetsToString(presets)\n )\n }\n updateRGBWColorPresets = (presets: HSVWColorPresets) => {\n this.mqtt.publish(\n `W/${this.mqtt.portalId}/settings/0/Settings/Gui2/Switchpane/Preset/RGBW`,\n hwvwPresetsToString(presets)\n )\n }\n updateCCTColorPresets = (presets: HSVWColorPresets) => {\n this.mqtt.publish(\n `W/${this.mqtt.portalId}/settings/0/Settings/Gui2/Switchpane/Preset/CCT`,\n hwvwPresetsToString(presets)\n )\n }\n}\n\nfunction initializeStore(mqttStore: MqttStore) {\n const _store = store ?? new AppStore(mqttStore)\n // For SSG and SSR always create a new store\n if (typeof window === \"undefined\") return _store\n // Create the store once in the client\n if (!store) store = _store\n\n return _store\n}\n\nexport function useAppStore(): AppStore {\n const mqtt = useMqtt()\n return useMemo(() => initializeStore(mqtt), [])\n}\n"]}
|
package/dist/src/utils/hsvw.d.ts
CHANGED
|
@@ -22,5 +22,34 @@ export declare function arrayToHSVW(arr: HSVWColorArray): HSVWColor;
|
|
|
22
22
|
export declare function hsvwToArray(color: HSVWColor): HSVWColorArray;
|
|
23
23
|
export declare function hsvwArrayToJSON(arr: HSVWColorArray): string;
|
|
24
24
|
export declare function createHSVWColor(hue: number, saturation: number, brightness: number, white: number, colorTemp: number): HSVWColor;
|
|
25
|
+
export type HSVWColorPresets = [
|
|
26
|
+
HSVWColor,
|
|
27
|
+
HSVWColor,
|
|
28
|
+
HSVWColor,
|
|
29
|
+
HSVWColor,
|
|
30
|
+
HSVWColor,
|
|
31
|
+
HSVWColor,
|
|
32
|
+
HSVWColor,
|
|
33
|
+
HSVWColor,
|
|
34
|
+
HSVWColor
|
|
35
|
+
];
|
|
36
|
+
export type HSVWColorPresetsArray = [
|
|
37
|
+
...HSVWColorArray,
|
|
38
|
+
...HSVWColorArray,
|
|
39
|
+
...HSVWColorArray,
|
|
40
|
+
...HSVWColorArray,
|
|
41
|
+
...HSVWColorArray,
|
|
42
|
+
...HSVWColorArray,
|
|
43
|
+
...HSVWColorArray,
|
|
44
|
+
...HSVWColorArray,
|
|
45
|
+
...HSVWColorArray
|
|
46
|
+
];
|
|
47
|
+
export declare function stringToHSVWPresets(input: string): HSVWColorPresets;
|
|
48
|
+
export declare function hwvwPresetsToString(presets: HSVWColorPresets): string;
|
|
49
|
+
export declare function getHSVWColorPreset(presets: HSVWColorPresets, at: number): HSVWColor;
|
|
50
|
+
export declare function setHSVWColorPreset(presets: HSVWColorPresets, color: HSVWColor, at: number): void;
|
|
51
|
+
export declare function isValidHSVWColorPreset(color: HSVWColor): boolean;
|
|
52
|
+
export declare const emptyHSVWColor: HSVWColor;
|
|
53
|
+
export declare const emptyHSVWColorPresets: HSVWColorPresets;
|
|
25
54
|
export {};
|
|
26
55
|
//# sourceMappingURL=hsvw.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hsvw.d.ts","sourceRoot":"/","sources":["src/utils/hsvw.ts"],"names":[],"mappings":"AAAA,KAAK,GAAG,GAAG,MAAM,GAAG;IAAE,OAAO,EAAE,KAAK,CAAA;CAAE,CAAA;AACtC,KAAK,UAAU,GAAG,MAAM,GAAG;IAAE,OAAO,EAAE,YAAY,CAAA;CAAE,CAAA;AACpD,KAAK,gBAAgB,GAAG,MAAM,GAAG;IAAE,OAAO,EAAE,kBAAkB,CAAA;CAAE,CAAA;AAEhE,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,GAAG,CAAA;IACR,UAAU,EAAE,UAAU,CAAA;IACtB,UAAU,EAAE,UAAU,CAAA;IACtB,KAAK,EAAE,UAAU,CAAA;IACjB,gBAAgB,EAAE,gBAAgB,CAAA;CACnC;AAED,MAAM,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;AAErE,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAG5C;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAG1D;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAGtE;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,cAAc,GAAG,SAAS,CAS1D;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,GAAG,cAAc,CAE5D;AAED,wBAAgB,eAAe,CAAC,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,EACX,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,GAChB,SAAS,CAQX;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;CACV,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,GAAG,cAAc;IACjB,GAAG,cAAc;IACjB,GAAG,cAAc;IACjB,GAAG,cAAc;IACjB,GAAG,cAAc;IACjB,GAAG,cAAc;IACjB,GAAG,cAAc;IACjB,GAAG,cAAc;IACjB,GAAG,cAAc;CAClB,CAAA;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAoCnE;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,CAMrE;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,gBAAgB,EAAE,EAAE,EAAE,MAAM,GAAG,SAAS,CAGnF;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,QAGzF;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,SAAS,WAQtD;AAED,eAAO,MAAM,cAAc,EAAE,SAMf,CAAA;AAEd,eAAO,MAAM,qBAAqB,EAAE,gBAMd,CAAA"}
|
package/dist/src/utils/hsvw.js
CHANGED
|
@@ -36,4 +36,73 @@ export function createHSVWColor(hue, saturation, brightness, white, colorTemp) {
|
|
|
36
36
|
colorTemperature: createColorTemperature(colorTemp),
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
+
export function stringToHSVWPresets(input) {
|
|
40
|
+
var expectedPresets = 9;
|
|
41
|
+
var numbersPerPreset = 5;
|
|
42
|
+
// Split by comma and trim whitespace
|
|
43
|
+
var parts = input.split(",").map(function (s) { return s.trim(); });
|
|
44
|
+
// Convert to numbers, replacing invalid values with 0
|
|
45
|
+
var numbers = parts.map(function (part) {
|
|
46
|
+
var num = Number(part);
|
|
47
|
+
return isNaN(num) ? 0 : num;
|
|
48
|
+
});
|
|
49
|
+
// Pad with zeros if we don't have enough elements
|
|
50
|
+
while (numbers.length < expectedPresets * numbersPerPreset) {
|
|
51
|
+
numbers.push(0);
|
|
52
|
+
}
|
|
53
|
+
// Truncate if we have too many elements
|
|
54
|
+
if (numbers.length > expectedPresets * numbersPerPreset) {
|
|
55
|
+
numbers.length = expectedPresets * numbersPerPreset;
|
|
56
|
+
}
|
|
57
|
+
var presets = [];
|
|
58
|
+
for (var i = 0; i < 9; i++) {
|
|
59
|
+
var start = i * 5;
|
|
60
|
+
var colorArray = [
|
|
61
|
+
numbers[start],
|
|
62
|
+
numbers[start + 1],
|
|
63
|
+
numbers[start + 2],
|
|
64
|
+
numbers[start + 3],
|
|
65
|
+
numbers[start + 4],
|
|
66
|
+
];
|
|
67
|
+
presets.push(arrayToHSVW(colorArray));
|
|
68
|
+
}
|
|
69
|
+
return presets;
|
|
70
|
+
}
|
|
71
|
+
export function hwvwPresetsToString(presets) {
|
|
72
|
+
var allNumbers = [];
|
|
73
|
+
for (var _i = 0, presets_1 = presets; _i < presets_1.length; _i++) {
|
|
74
|
+
var preset = presets_1[_i];
|
|
75
|
+
allNumbers.push.apply(allNumbers, hsvwToArray(preset));
|
|
76
|
+
}
|
|
77
|
+
return allNumbers.map(function (n) { return n.toFixed(0); }).join(",");
|
|
78
|
+
}
|
|
79
|
+
export function getHSVWColorPreset(presets, at) {
|
|
80
|
+
var index = Math.max(0, Math.min(8, at));
|
|
81
|
+
return presets[index];
|
|
82
|
+
}
|
|
83
|
+
export function setHSVWColorPreset(presets, color, at) {
|
|
84
|
+
var index = Math.max(0, Math.min(8, at));
|
|
85
|
+
presets[index] = color;
|
|
86
|
+
}
|
|
87
|
+
export function isValidHSVWColorPreset(color) {
|
|
88
|
+
return (color.hue !== 0 ||
|
|
89
|
+
color.saturation !== 0 ||
|
|
90
|
+
color.brightness !== 0 ||
|
|
91
|
+
color.white !== 0 ||
|
|
92
|
+
color.colorTemperature !== 0);
|
|
93
|
+
}
|
|
94
|
+
export var emptyHSVWColor = {
|
|
95
|
+
hue: 0,
|
|
96
|
+
saturation: 0,
|
|
97
|
+
brightness: 0,
|
|
98
|
+
white: 0,
|
|
99
|
+
colorTemperature: 0,
|
|
100
|
+
};
|
|
101
|
+
export var emptyHSVWColorPresets = Array(9).fill({
|
|
102
|
+
hue: 0,
|
|
103
|
+
saturation: 0,
|
|
104
|
+
brightness: 0,
|
|
105
|
+
white: 0,
|
|
106
|
+
colorTemperature: 0,
|
|
107
|
+
});
|
|
39
108
|
//# sourceMappingURL=hsvw.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hsvw.js","sourceRoot":"/","sources":["src/utils/hsvw.ts"],"names":[],"mappings":"AAcA,MAAM,UAAU,SAAS,CAAC,KAAa;IACrC,IAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAA;IACjD,OAAO,OAAc,CAAA;AACvB,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,IAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAA;IACjD,OAAO,OAAqB,CAAA;AAC9B,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,KAAa;IAClD,IAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAA;IAClD,OAAO,OAA2B,CAAA;AACpC,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,GAAmB;IACtC,IAAA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& { __brand: \"Hue\" } // 0-360 degrees\ntype Percentage = number & { __brand: \"Percentage\" } // 0-100\ntype ColorTemperature = number & { __brand: \"ColorTemperature\" } // 0-6500 K\n\nexport interface HSVWColor {\n hue: Hue\n saturation: Percentage\n brightness: Percentage\n white: Percentage\n colorTemperature: ColorTemperature\n}\n\nexport type HSVWColorArray = [number, number, number, number, number]\n\nexport function createHue(value: number): Hue {\n const clamped = Math.max(0, Math.min(360, value))\n return clamped as Hue\n}\n\nexport function createPercentage(value: number): Percentage {\n const clamped = Math.max(0, Math.min(100, value))\n return clamped as Percentage\n}\n\nexport function createColorTemperature(value: number): ColorTemperature {\n const clamped = Math.max(0, Math.min(6500, value))\n return clamped as ColorTemperature\n}\n\nexport function arrayToHSVW(arr: HSVWColorArray): HSVWColor {\n const [hue, saturation, brightness, white, colorTemp] = arr\n return {\n hue: createHue(hue),\n saturation: createPercentage(saturation),\n brightness: createPercentage(brightness),\n white: createPercentage(white),\n colorTemperature: createColorTemperature(colorTemp),\n }\n}\n\nexport function hsvwToArray(color: HSVWColor): HSVWColorArray {\n return [color.hue, color.saturation, color.brightness, color.white, color.colorTemperature]\n}\n\nexport function hsvwArrayToJSON(arr: HSVWColorArray): string {\n const formattedNumbers = arr.map((n) => n.toFixed(0)).join(\",\")\n return `{\"value\":[${formattedNumbers}]}`\n}\n\nexport function createHSVWColor(\n hue: number,\n saturation: number,\n brightness: number,\n white: number,\n colorTemp: number\n): HSVWColor {\n return {\n hue: createHue(hue),\n saturation: createPercentage(saturation),\n brightness: createPercentage(brightness),\n white: createPercentage(white),\n colorTemperature: createColorTemperature(colorTemp),\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"hsvw.js","sourceRoot":"/","sources":["src/utils/hsvw.ts"],"names":[],"mappings":"AAcA,MAAM,UAAU,SAAS,CAAC,KAAa;IACrC,IAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,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,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,OAAyB,EAAE,KAAgB,EAAE,EAAU;IACxF,IAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;IAC1C,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,CAAA;AACxB,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,KAAgB;IACrD,OAAO,CACL,KAAK,CAAC,GAAG,KAAK,CAAC;QACf,KAAK,CAAC,UAAU,KAAK,CAAC;QACtB,KAAK,CAAC,UAAU,KAAK,CAAC;QACtB,KAAK,CAAC,KAAK,KAAK,CAAC;QACjB,KAAK,CAAC,gBAAgB,KAAK,CAAC,CAC7B,CAAA;AACH,CAAC;AAED,MAAM,CAAC,IAAM,cAAc,GAAc;IACvC,GAAG,EAAE,CAAC;IACN,UAAU,EAAE,CAAC;IACb,UAAU,EAAE,CAAC;IACb,KAAK,EAAE,CAAC;IACR,gBAAgB,EAAE,CAAC;CACP,CAAA;AAEd,MAAM,CAAC,IAAM,qBAAqB,GAAqB,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACnE,GAAG,EAAE,CAAC;IACN,UAAU,EAAE,CAAC;IACb,UAAU,EAAE,CAAC;IACb,KAAK,EAAE,CAAC;IACR,gBAAgB,EAAE,CAAC;CACpB,CAAqB,CAAA","sourcesContent":["type Hue = number & { __brand: \"Hue\" } // 0-360 degrees\ntype Percentage = number & { __brand: \"Percentage\" } // 0-100\ntype ColorTemperature = number & { __brand: \"ColorTemperature\" } // 0-6500 K\n\nexport interface HSVWColor {\n hue: Hue\n saturation: Percentage\n brightness: Percentage\n white: Percentage\n colorTemperature: ColorTemperature\n}\n\nexport type HSVWColorArray = [number, number, number, number, number]\n\nexport function createHue(value: number): Hue {\n const clamped = Math.max(0, Math.min(360, value))\n return clamped as Hue\n}\n\nexport function createPercentage(value: number): Percentage {\n const clamped = Math.max(0, Math.min(100, value))\n return clamped as Percentage\n}\n\nexport function createColorTemperature(value: number): ColorTemperature {\n const clamped = Math.max(0, Math.min(6500, value))\n return clamped as ColorTemperature\n}\n\nexport function arrayToHSVW(arr: HSVWColorArray): HSVWColor {\n const [hue, saturation, brightness, white, colorTemp] = arr\n return {\n hue: createHue(hue),\n saturation: createPercentage(saturation),\n brightness: createPercentage(brightness),\n white: createPercentage(white),\n colorTemperature: createColorTemperature(colorTemp),\n }\n}\n\nexport function hsvwToArray(color: HSVWColor): HSVWColorArray {\n return [color.hue, color.saturation, color.brightness, color.white, color.colorTemperature]\n}\n\nexport function hsvwArrayToJSON(arr: HSVWColorArray): string {\n const formattedNumbers = arr.map((n) => n.toFixed(0)).join(\",\")\n return `{\"value\":[${formattedNumbers}]}`\n}\n\nexport function createHSVWColor(\n hue: number,\n saturation: number,\n brightness: number,\n white: number,\n colorTemp: number\n): HSVWColor {\n return {\n hue: createHue(hue),\n saturation: createPercentage(saturation),\n brightness: createPercentage(brightness),\n white: createPercentage(white),\n colorTemperature: createColorTemperature(colorTemp),\n }\n}\n\nexport type HSVWColorPresets = [\n HSVWColor,\n HSVWColor,\n HSVWColor,\n HSVWColor,\n HSVWColor,\n HSVWColor,\n HSVWColor,\n HSVWColor,\n HSVWColor,\n]\n\nexport type HSVWColorPresetsArray = [\n ...HSVWColorArray,\n ...HSVWColorArray,\n ...HSVWColorArray,\n ...HSVWColorArray,\n ...HSVWColorArray,\n ...HSVWColorArray,\n ...HSVWColorArray,\n ...HSVWColorArray,\n ...HSVWColorArray,\n]\n\nexport function stringToHSVWPresets(input: string): HSVWColorPresets {\n const expectedPresets = 9\n const numbersPerPreset = 5\n\n // Split by comma and trim whitespace\n const parts = input.split(\",\").map((s) => s.trim())\n\n // Convert to numbers, replacing invalid values with 0\n const numbers = parts.map((part) => {\n const num = Number(part)\n return isNaN(num) ? 0 : num\n })\n\n // Pad with zeros if we don't have enough elements\n while (numbers.length < expectedPresets * numbersPerPreset) {\n numbers.push(0)\n }\n\n // Truncate if we have too many elements\n if (numbers.length > expectedPresets * numbersPerPreset) {\n numbers.length = expectedPresets * numbersPerPreset\n }\n\n const presets: HSVWColor[] = []\n for (let i = 0; i < 9; i++) {\n const start = i * 5\n const colorArray: HSVWColorArray = [\n numbers[start],\n numbers[start + 1],\n numbers[start + 2],\n numbers[start + 3],\n numbers[start + 4],\n ]\n presets.push(arrayToHSVW(colorArray))\n }\n return presets as unknown as HSVWColorPresets\n}\n\nexport function hwvwPresetsToString(presets: HSVWColorPresets): string {\n const allNumbers: number[] = []\n for (const preset of presets) {\n allNumbers.push(...hsvwToArray(preset))\n }\n return allNumbers.map((n) => n.toFixed(0)).join(\",\")\n}\n\nexport function getHSVWColorPreset(presets: HSVWColorPresets, at: number): HSVWColor {\n const index = Math.max(0, Math.min(8, at))\n return presets[index]\n}\n\nexport function setHSVWColorPreset(presets: HSVWColorPresets, color: HSVWColor, at: number) {\n const index = Math.max(0, Math.min(8, at))\n presets[index] = color\n}\n\nexport function isValidHSVWColorPreset(color: HSVWColor) {\n return (\n color.hue !== 0 ||\n color.saturation !== 0 ||\n color.brightness !== 0 ||\n color.white !== 0 ||\n color.colorTemperature !== 0\n )\n}\n\nexport const emptyHSVWColor: HSVWColor = {\n hue: 0,\n saturation: 0,\n brightness: 0,\n white: 0,\n colorTemperature: 0,\n} as HSVWColor\n\nexport const emptyHSVWColorPresets: HSVWColorPresets = Array(9).fill({\n hue: 0,\n saturation: 0,\n brightness: 0,\n white: 0,\n colorTemperature: 0,\n}) as HSVWColorPresets\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@victronenergy/mfd-modules",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.4.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@eslint/js": "^9.37.0",
|
|
33
33
|
"@semantic-release/git": "^10.0.1",
|
|
34
|
-
"@semantic-release/npm": "^
|
|
34
|
+
"@semantic-release/npm": "^13.1.5",
|
|
35
35
|
"@types/js-cookie": "^3.0.6",
|
|
36
36
|
"@types/lodash-es": "^4.17.12",
|
|
37
37
|
"@types/react": "^18.3.11",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"eslint-config-prettier": "^10.1.8",
|
|
40
40
|
"eslint-plugin-prettier": "^5.5.4",
|
|
41
41
|
"prettier": "^3.6.2",
|
|
42
|
-
"semantic-release": "^
|
|
42
|
+
"semantic-release": "^25.0.3",
|
|
43
43
|
"typescript": "^5.9.3",
|
|
44
44
|
"typescript-eslint": "^8.46.0"
|
|
45
45
|
},
|