@victronenergy/mfd-modules 9.6.1 → 9.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/Modules/App/App.provider.d.ts.map +1 -1
- package/dist/src/Modules/App/App.provider.js +28 -7
- package/dist/src/Modules/App/App.provider.js.map +1 -1
- package/dist/src/Modules/App/App.store.d.ts +14 -3
- package/dist/src/Modules/App/App.store.d.ts.map +1 -1
- package/dist/src/Modules/App/App.store.js +62 -12
- package/dist/src/Modules/App/App.store.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.provider.d.ts","sourceRoot":"/","sources":["src/Modules/App/App.provider.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"App.provider.d.ts","sourceRoot":"/","sources":["src/Modules/App/App.provider.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,MAAM,sCAqElB,CAAA"}
|
|
@@ -9,6 +9,8 @@ export var useApp = function () {
|
|
|
9
9
|
firmwareVersion: "N/".concat(portalId, "/system/0/FirmwareVersion"),
|
|
10
10
|
units: {
|
|
11
11
|
temperature: "N/".concat(portalId, "/settings/0/Settings/System/Units/Temperature"),
|
|
12
|
+
speed: "N/".concat(portalId, "/settings/0/Settings/Gps/SpeedUnit"),
|
|
13
|
+
volume: "N/".concat(portalId, "/settings/0/Settings/System/VolumeUnit"),
|
|
12
14
|
},
|
|
13
15
|
guiVersion: "N/".concat(portalId, "/settings/0/Settings/Gui/RunningVersion"),
|
|
14
16
|
electricalPowerIndicator: "N/".concat(portalId, "/settings/0/Settings/Gui/ElectricalPowerIndicator"),
|
|
@@ -16,26 +18,45 @@ export var useApp = function () {
|
|
|
16
18
|
var topics = useMemo(function () { return getTopics(mqtt.portalId); }, [mqtt.portalId]);
|
|
17
19
|
var locked = useTopicState(topics.locked);
|
|
18
20
|
var firmwareVersion = useTopicState(topics.firmwareVersion);
|
|
19
|
-
var
|
|
21
|
+
var temperatureUnit = useTopicState(topics.units.temperature);
|
|
22
|
+
var speedUnit = useTopicState(topics.units.speed);
|
|
23
|
+
var volumeUnit = useTopicState(topics.units.volume);
|
|
20
24
|
var guiVersion = useTopicState(topics.guiVersion);
|
|
21
25
|
var electricalPowerIndicator = useTopicState(topics.electricalPowerIndicator);
|
|
22
26
|
useEffect(function () {
|
|
23
27
|
if (locked !== undefined) {
|
|
24
28
|
appStore.setLockedWithoutPersistence(!!locked);
|
|
25
29
|
}
|
|
26
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
27
30
|
}, [locked]);
|
|
28
31
|
useEffect(function () {
|
|
29
|
-
|
|
32
|
+
if (firmwareVersion) {
|
|
33
|
+
appStore.setFirmwareVersion(firmwareVersion);
|
|
34
|
+
}
|
|
30
35
|
}, [firmwareVersion]);
|
|
31
36
|
useEffect(function () {
|
|
32
|
-
|
|
33
|
-
|
|
37
|
+
if (temperatureUnit) {
|
|
38
|
+
appStore.setUnit("temperature", temperatureUnit);
|
|
39
|
+
}
|
|
40
|
+
}, [temperatureUnit]);
|
|
41
|
+
useEffect(function () {
|
|
42
|
+
if (speedUnit) {
|
|
43
|
+
appStore.setUnit("speed", speedUnit);
|
|
44
|
+
}
|
|
45
|
+
}, [speedUnit]);
|
|
46
|
+
useEffect(function () {
|
|
47
|
+
if (volumeUnit) {
|
|
48
|
+
appStore.setUnit("volume", volumeUnit);
|
|
49
|
+
}
|
|
50
|
+
}, [volumeUnit]);
|
|
34
51
|
useEffect(function () {
|
|
35
|
-
|
|
52
|
+
if (guiVersion) {
|
|
53
|
+
appStore.setGuiVersion(guiVersion);
|
|
54
|
+
}
|
|
36
55
|
}, [guiVersion]);
|
|
37
56
|
useEffect(function () {
|
|
38
|
-
electricalPowerIndicator !== undefined
|
|
57
|
+
if (electricalPowerIndicator !== undefined) {
|
|
58
|
+
appStore.setElectricalPowerIndicator(electricalPowerIndicator);
|
|
59
|
+
}
|
|
39
60
|
}, [electricalPowerIndicator]);
|
|
40
61
|
return appStore;
|
|
41
62
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.provider.js","sourceRoot":"/","sources":["src/Modules/App/App.provider.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
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,EAAE,MAAM,aAAa,CAAA;AAEjF,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,kDAA+C;YACzE,KAAK,EAAE,YAAK,QAAQ,uCAAoC;YACxD,MAAM,EAAE,YAAK,QAAQ,2CAAwC;SAC9D;QACD,UAAU,EAAE,YAAK,QAAQ,4CAAyC;QAClE,wBAAwB,EAAE,YAAK,QAAQ,sDAAmD;KAC3F,CAAC,EAVwC,CAUxC,CAAA;IAEF,IAAM,MAAM,GAAG,OAAO,CAAC,cAAM,OAAA,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAxB,CAAwB,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAA;IAEvE,IAAM,MAAM,GAAG,aAAa,CAAS,MAAM,CAAC,MAAM,CAAC,CAAA;IACnD,IAAM,eAAe,GAAG,aAAa,CAAS,MAAM,CAAC,eAAe,CAAC,CAA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SAAS,CAAC;QACR,IAAI,UAAU,EAAE,CAAC;YACf,QAAQ,CAAC,aAAa,CAAC,UAAU,CAAC,CAAA;QACpC,CAAC;IACH,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAA;IAEhB,SAAS,CAAC;QACR,IAAI,wBAAwB,KAAK,SAAS,EAAE,CAAC;YAC3C,QAAQ,CAAC,2BAA2B,CAAC,wBAAwB,CAAC,CAAA;QAChE,CAAC;IACH,CAAC,EAAE,CAAC,wBAAwB,CAAC,CAAC,CAAA;IAE9B,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA","sourcesContent":["import { useEffect, useMemo } from \"react\"\nimport { PortalId, useMqtt, useTopicState } from \"../Mqtt\"\nimport { TemperatureUnit, SpeedUnit, VolumeUnit, useAppStore } from \"./App.store\"\n\nexport const useApp = () => {\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 })\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\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) {\n appStore.setUnit(\"temperature\", temperatureUnit as TemperatureUnit)\n }\n }, [temperatureUnit])\n\n useEffect(() => {\n if (speedUnit) {\n appStore.setUnit(\"speed\", speedUnit as SpeedUnit)\n }\n }, [speedUnit])\n\n useEffect(() => {\n if (volumeUnit) {\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)\n }\n }, [electricalPowerIndicator])\n\n return appStore\n}\n"]}
|
|
@@ -6,8 +6,17 @@ export interface AppState {
|
|
|
6
6
|
}
|
|
7
7
|
interface IUnit {
|
|
8
8
|
temperature: TemperatureUnit;
|
|
9
|
+
speed: SpeedUnit;
|
|
10
|
+
volume: VolumeUnit;
|
|
9
11
|
}
|
|
10
12
|
export type TemperatureUnit = "fahrenheit" | "celsius";
|
|
13
|
+
export type SpeedUnit = "km/h" | "m/s" | "mph" | "kt";
|
|
14
|
+
export declare enum VolumeUnit {
|
|
15
|
+
CUBIC_METERS = 0,
|
|
16
|
+
LITRES = 1,
|
|
17
|
+
GALLONS_IMPERIAL = 2,
|
|
18
|
+
GALLONS_US = 3
|
|
19
|
+
}
|
|
11
20
|
export declare class AppStore {
|
|
12
21
|
page: string;
|
|
13
22
|
locked: boolean;
|
|
@@ -22,6 +31,10 @@ export declare class AppStore {
|
|
|
22
31
|
get humanReadableFirmwareVersion(): any;
|
|
23
32
|
get temperatureUnitToHumanReadable(): "°C" | "°F";
|
|
24
33
|
get temperatureUnit(): TemperatureUnit;
|
|
34
|
+
get speedUnitToHumanReadable(): SpeedUnit;
|
|
35
|
+
get speedUnit(): SpeedUnit;
|
|
36
|
+
get volumeUnitToHumanReadable(): "m³" | "l" | "gal";
|
|
37
|
+
get volumeUnit(): VolumeUnit;
|
|
25
38
|
setPage: (page: string) => string;
|
|
26
39
|
setLockedWithoutPersistence: (locked: boolean) => boolean;
|
|
27
40
|
setRemote: (remote: boolean) => void;
|
|
@@ -29,9 +42,7 @@ export declare class AppStore {
|
|
|
29
42
|
toggleLocked: () => void;
|
|
30
43
|
setLanguage: (language: string) => string;
|
|
31
44
|
setFirmwareVersion: (firmwareVersion: string) => string;
|
|
32
|
-
setUnit: (unit:
|
|
33
|
-
temperature: TemperatureUnit;
|
|
34
|
-
};
|
|
45
|
+
setUnit: <K extends keyof IUnit>(unit: K, value: IUnit[K]) => void;
|
|
35
46
|
setGuiVersion: (guiVersion: number) => number;
|
|
36
47
|
setElectricalPowerIndicator: (electricalPowerIndicator: number) => number;
|
|
37
48
|
}
|
|
@@ -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;AAE5C,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,OAAO,CAAA;IACf,MAAM,EAAE,OAAO,CAAA;CAChB;AAED,UAAU,KAAK;IACb,WAAW,EAAE,eAAe,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;AAE5C,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,OAAO,CAAA;IACf,MAAM,EAAE,OAAO,CAAA;CAChB;AAED,UAAU,KAAK;IACb,WAAW,EAAE,eAAe,CAAA;IAC5B,KAAK,EAAE,SAAS,CAAA;IACh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14,6 +14,13 @@ import { useMemo } from "react";
|
|
|
14
14
|
import { versionToHumanReadable } from "../../utils/util";
|
|
15
15
|
import { VIEWS } from "../../utils/constants";
|
|
16
16
|
import { useMqtt } from "../Mqtt";
|
|
17
|
+
export var VolumeUnit;
|
|
18
|
+
(function (VolumeUnit) {
|
|
19
|
+
VolumeUnit[VolumeUnit["CUBIC_METERS"] = 0] = "CUBIC_METERS";
|
|
20
|
+
VolumeUnit[VolumeUnit["LITRES"] = 1] = "LITRES";
|
|
21
|
+
VolumeUnit[VolumeUnit["GALLONS_IMPERIAL"] = 2] = "GALLONS_IMPERIAL";
|
|
22
|
+
VolumeUnit[VolumeUnit["GALLONS_US"] = 3] = "GALLONS_US";
|
|
23
|
+
})(VolumeUnit || (VolumeUnit = {}));
|
|
17
24
|
var store;
|
|
18
25
|
var AppStore = /** @class */ (function () {
|
|
19
26
|
function AppStore(mqttStore) {
|
|
@@ -36,7 +43,9 @@ var AppStore = /** @class */ (function () {
|
|
|
36
43
|
enumerable: true,
|
|
37
44
|
configurable: true,
|
|
38
45
|
writable: true,
|
|
39
|
-
value: typeof window !== "undefined" &&
|
|
46
|
+
value: typeof window !== "undefined" &&
|
|
47
|
+
(window === null || window === void 0 ? void 0 : window.location.protocol) === "https:" &&
|
|
48
|
+
(window === null || window === void 0 ? void 0 : window.location.hostname.endsWith("victronenergy.com")) &&
|
|
40
49
|
((window === null || window === void 0 ? void 0 : window.location.hostname.startsWith("mqtt")) || (window === null || window === void 0 ? void 0 : window.location.hostname.startsWith("webmqtt")))
|
|
41
50
|
});
|
|
42
51
|
Object.defineProperty(this, "language", {
|
|
@@ -79,13 +88,13 @@ var AppStore = /** @class */ (function () {
|
|
|
79
88
|
enumerable: true,
|
|
80
89
|
configurable: true,
|
|
81
90
|
writable: true,
|
|
82
|
-
value: function (page) { return _this.page = page; }
|
|
91
|
+
value: function (page) { return (_this.page = page); }
|
|
83
92
|
});
|
|
84
93
|
Object.defineProperty(this, "setLockedWithoutPersistence", {
|
|
85
94
|
enumerable: true,
|
|
86
95
|
configurable: true,
|
|
87
96
|
writable: true,
|
|
88
|
-
value: function (locked) { return _this.locked = locked; }
|
|
97
|
+
value: function (locked) { return (_this.locked = locked); }
|
|
89
98
|
});
|
|
90
99
|
Object.defineProperty(this, "setRemote", {
|
|
91
100
|
enumerable: true,
|
|
@@ -93,14 +102,14 @@ var AppStore = /** @class */ (function () {
|
|
|
93
102
|
writable: true,
|
|
94
103
|
value: function (remote) {
|
|
95
104
|
_this.remote = remote;
|
|
96
|
-
// @ts-
|
|
105
|
+
// @ts-expect-error Missing TS declaration for venusNativeApp
|
|
97
106
|
if (window === null || window === void 0 ? void 0 : window.venusNativeApp) {
|
|
98
107
|
if (remote) {
|
|
99
|
-
// @ts-
|
|
108
|
+
// @ts-expect-error Missing TS declaration for venusNativeApp
|
|
100
109
|
window.venusNativeApp.switchToRemote();
|
|
101
110
|
}
|
|
102
111
|
else {
|
|
103
|
-
// @ts-
|
|
112
|
+
// @ts-expect-error Missing TS declaration for venusNativeApp
|
|
104
113
|
window.venusNativeApp.switchToLocal();
|
|
105
114
|
}
|
|
106
115
|
}
|
|
@@ -125,13 +134,13 @@ var AppStore = /** @class */ (function () {
|
|
|
125
134
|
enumerable: true,
|
|
126
135
|
configurable: true,
|
|
127
136
|
writable: true,
|
|
128
|
-
value: function (language) { return _this.language = language; }
|
|
137
|
+
value: function (language) { return (_this.language = language); }
|
|
129
138
|
});
|
|
130
139
|
Object.defineProperty(this, "setFirmwareVersion", {
|
|
131
140
|
enumerable: true,
|
|
132
141
|
configurable: true,
|
|
133
142
|
writable: true,
|
|
134
|
-
value: function (firmwareVersion) { return _this.firmwareVersion = firmwareVersion; }
|
|
143
|
+
value: function (firmwareVersion) { return (_this.firmwareVersion = firmwareVersion); }
|
|
135
144
|
});
|
|
136
145
|
Object.defineProperty(this, "setUnit", {
|
|
137
146
|
enumerable: true,
|
|
@@ -139,26 +148,30 @@ var AppStore = /** @class */ (function () {
|
|
|
139
148
|
writable: true,
|
|
140
149
|
value: function (unit, value) {
|
|
141
150
|
var _a;
|
|
142
|
-
|
|
151
|
+
_this.units = __assign(__assign({}, _this.units), (_a = {}, _a[unit] = value, _a));
|
|
143
152
|
}
|
|
144
153
|
});
|
|
145
154
|
Object.defineProperty(this, "setGuiVersion", {
|
|
146
155
|
enumerable: true,
|
|
147
156
|
configurable: true,
|
|
148
157
|
writable: true,
|
|
149
|
-
value: function (guiVersion) { return _this.guiVersion = guiVersion; }
|
|
158
|
+
value: function (guiVersion) { return (_this.guiVersion = guiVersion); }
|
|
150
159
|
});
|
|
151
160
|
Object.defineProperty(this, "setElectricalPowerIndicator", {
|
|
152
161
|
enumerable: true,
|
|
153
162
|
configurable: true,
|
|
154
163
|
writable: true,
|
|
155
|
-
value: function (electricalPowerIndicator) {
|
|
164
|
+
value: function (electricalPowerIndicator) {
|
|
165
|
+
return (_this.electricalPowerIndicator = electricalPowerIndicator);
|
|
166
|
+
}
|
|
156
167
|
});
|
|
157
168
|
makeAutoObservable(this, { mqtt: false });
|
|
158
169
|
this.mqtt = mqttStore;
|
|
159
170
|
this.firmwareVersion = "-";
|
|
160
171
|
this.units = {
|
|
161
|
-
temperature: "celsius"
|
|
172
|
+
temperature: "celsius",
|
|
173
|
+
speed: "km/h",
|
|
174
|
+
volume: VolumeUnit.CUBIC_METERS,
|
|
162
175
|
};
|
|
163
176
|
this.guiVersion = 2;
|
|
164
177
|
this.electricalPowerIndicator = 1;
|
|
@@ -187,6 +200,43 @@ var AppStore = /** @class */ (function () {
|
|
|
187
200
|
enumerable: false,
|
|
188
201
|
configurable: true
|
|
189
202
|
});
|
|
203
|
+
Object.defineProperty(AppStore.prototype, "speedUnitToHumanReadable", {
|
|
204
|
+
get: function () {
|
|
205
|
+
return this.units.speed;
|
|
206
|
+
},
|
|
207
|
+
enumerable: false,
|
|
208
|
+
configurable: true
|
|
209
|
+
});
|
|
210
|
+
Object.defineProperty(AppStore.prototype, "speedUnit", {
|
|
211
|
+
get: function () {
|
|
212
|
+
return this.units.speed;
|
|
213
|
+
},
|
|
214
|
+
enumerable: false,
|
|
215
|
+
configurable: true
|
|
216
|
+
});
|
|
217
|
+
Object.defineProperty(AppStore.prototype, "volumeUnitToHumanReadable", {
|
|
218
|
+
get: function () {
|
|
219
|
+
switch (this.units.volume) {
|
|
220
|
+
case VolumeUnit.CUBIC_METERS:
|
|
221
|
+
return "m³";
|
|
222
|
+
case VolumeUnit.LITRES:
|
|
223
|
+
return "l";
|
|
224
|
+
case VolumeUnit.GALLONS_IMPERIAL:
|
|
225
|
+
return "gal";
|
|
226
|
+
case VolumeUnit.GALLONS_US:
|
|
227
|
+
return "gal";
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
enumerable: false,
|
|
231
|
+
configurable: true
|
|
232
|
+
});
|
|
233
|
+
Object.defineProperty(AppStore.prototype, "volumeUnit", {
|
|
234
|
+
get: function () {
|
|
235
|
+
return this.units.volume;
|
|
236
|
+
},
|
|
237
|
+
enumerable: false,
|
|
238
|
+
configurable: true
|
|
239
|
+
});
|
|
190
240
|
return AppStore;
|
|
191
241
|
}());
|
|
192
242
|
export { AppStore };
|
|
@@ -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;
|
|
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,OA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,CAAA;gBACb,KAAK,UAAU,CAAC,MAAM;oBACpB,OAAO,GAAG,CAAA;gBACZ,KAAK,UAAU,CAAC,gBAAgB;oBAC9B,OAAO,KAAK,CAAA;gBACd,KAAK,UAAU,CAAC,UAAU;oBACxB,OAAO,KAAK,CAAA;YAChB,CAAC;QACH,CAAC;;;OAAA;IAED,sBAAI,gCAAU;aAAd;YACE,OAAO,IAAI,CAAC,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"]}
|