mirta 0.1.0 → 0.1.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/index.mjs +9 -7
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -56,18 +56,18 @@ function createControl(context, controlId, options) {
|
|
|
56
56
|
};
|
|
57
57
|
const valueReceived = useEvent();
|
|
58
58
|
const valueChanged = useEvent();
|
|
59
|
-
let
|
|
59
|
+
let localValue;
|
|
60
60
|
/**
|
|
61
61
|
* Устанавливает новое значение, если оно отличается от существующего.
|
|
62
62
|
* @param newValue Устанавливаемое значение.
|
|
63
63
|
* @param preventEmit Предотвращает отправку значения в устройство.
|
|
64
64
|
**/
|
|
65
65
|
function setValue(newValue, preventEmit = false) {
|
|
66
|
-
const oldValue =
|
|
66
|
+
const oldValue = localValue;
|
|
67
67
|
valueReceived.raise(newValue, oldValue);
|
|
68
68
|
if (oldValue === newValue)
|
|
69
69
|
return;
|
|
70
|
-
|
|
70
|
+
localValue = newValue;
|
|
71
71
|
if (!preventEmit)
|
|
72
72
|
emitValue(newValue);
|
|
73
73
|
valueChanged.raise(newValue, oldValue);
|
|
@@ -93,13 +93,13 @@ function createControl(context, controlId, options) {
|
|
|
93
93
|
});
|
|
94
94
|
return {
|
|
95
95
|
get value() {
|
|
96
|
-
if (
|
|
96
|
+
if (localValue === undefined) {
|
|
97
97
|
if (options.forceDefault)
|
|
98
|
-
return
|
|
98
|
+
return localValue = defaultValue;
|
|
99
99
|
if (!options.lazyInit)
|
|
100
|
-
return
|
|
100
|
+
return localValue ??= control.safe?.getValue();
|
|
101
101
|
}
|
|
102
|
-
return
|
|
102
|
+
return localValue;
|
|
103
103
|
},
|
|
104
104
|
set value(newValue) {
|
|
105
105
|
if (isReadonly) {
|
|
@@ -221,6 +221,8 @@ function createDevice(deviceType, deviceId, propDefs, props, options) {
|
|
|
221
221
|
type: controlDef.type,
|
|
222
222
|
defaultValue: controlDef.defaultValue,
|
|
223
223
|
isReadonly: controlDef.isReadonly,
|
|
224
|
+
forceDefault: controlDef.forceDefault,
|
|
225
|
+
lazyInit: controlDef.lazyInit,
|
|
224
226
|
});
|
|
225
227
|
controls[key] = control;
|
|
226
228
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mirta",
|
|
3
3
|
"description": "The powerful framework to write smart home automation scripts.",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.1",
|
|
5
5
|
"license": "Unlicense",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"mirta",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"url": "https://pay.cloudtips.ru/p/58512cca"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@mirta/basics": "0.1.
|
|
40
|
-
"@mirta/
|
|
41
|
-
"@mirta/
|
|
39
|
+
"@mirta/basics": "0.1.1",
|
|
40
|
+
"@mirta/polyfills": "0.1.1",
|
|
41
|
+
"@mirta/globals": "0.1.1"
|
|
42
42
|
},
|
|
43
43
|
"publishConfig": {
|
|
44
44
|
"access": "public"
|