iobroker.javascript 7.2.0 → 7.4.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/README.md +13 -7
- package/admin/asset-manifest.json +15 -11
- package/admin/google-blockly/own/blocks_time.js +6 -5
- package/admin/google-blockly/own/blocks_words.js +2 -2
- package/admin/index_m.html +6 -4
- package/admin/static/css/{487.9934873c.chunk.css → 864.42bfc5f3.chunk.css} +1 -1
- package/admin/static/css/{487.9934873c.chunk.css.map → 864.42bfc5f3.chunk.css.map} +1 -1
- package/admin/static/js/238.c2010836.chunk.js.map +1 -1
- package/admin/static/js/360.01ffa94f.chunk.js +3 -0
- package/admin/static/js/360.01ffa94f.chunk.js.map +1 -0
- package/admin/static/js/694.9fd55578.chunk.js.map +1 -1
- package/admin/static/js/838.0ca9d95b.chunk.js +3 -0
- package/admin/static/js/838.0ca9d95b.chunk.js.map +1 -0
- package/admin/static/js/864.2929f700.chunk.js +2 -0
- package/admin/static/js/864.2929f700.chunk.js.map +1 -0
- package/admin/static/js/main.6bcb3d84.js +2 -0
- package/admin/static/js/main.6bcb3d84.js.map +1 -0
- package/admin/static/media/tileBlockly.42b0a9f0e66bc4e68f4b.png +0 -0
- package/admin/static/media/tileJS.8810e7b4835e61465c3a.png +0 -0
- package/admin/static/media/tileRules.7ed5885a66686cc288b1.png +0 -0
- package/admin/static/media/tileTS.446265dff5dc550d46a5.png +0 -0
- package/admin/tab.html +1 -1
- package/io-package.json +215 -52
- package/lib/sandbox.js +6 -6
- package/main.js +73 -37
- package/package.json +1 -1
- package/admin/static/js/360.8a86d051.chunk.js +0 -3
- package/admin/static/js/360.8a86d051.chunk.js.map +0 -1
- package/admin/static/js/487.08b3f5b3.chunk.js +0 -2
- package/admin/static/js/487.08b3f5b3.chunk.js.map +0 -1
- package/admin/static/js/838.7244f6d0.chunk.js +0 -3
- package/admin/static/js/838.7244f6d0.chunk.js.map +0 -1
- package/admin/static/js/main.23d47ef3.js +0 -2
- package/admin/static/js/main.23d47ef3.js.map +0 -1
- /package/admin/static/js/{360.8a86d051.chunk.js.LICENSE.txt → 360.01ffa94f.chunk.js.LICENSE.txt} +0 -0
- /package/admin/static/js/{838.7244f6d0.chunk.js.LICENSE.txt → 838.0ca9d95b.chunk.js.LICENSE.txt} +0 -0
package/main.js
CHANGED
|
@@ -22,7 +22,6 @@ const CoffeeScript = require('coffeescript');
|
|
|
22
22
|
const tsc = require('virtual-tsc');
|
|
23
23
|
const Mirror = require('./lib/mirror');
|
|
24
24
|
const fork = require('child_process').fork;
|
|
25
|
-
const { astroList } = require('./lib/consts');
|
|
26
25
|
|
|
27
26
|
const mods = {
|
|
28
27
|
fs: {},
|
|
@@ -67,6 +66,9 @@ const words = require('./lib/words');
|
|
|
67
66
|
const sandBox = require('./lib/sandbox');
|
|
68
67
|
const eventObj = require('./lib/eventObj');
|
|
69
68
|
const Scheduler = require('./lib/scheduler');
|
|
69
|
+
const { targetTsLib, tsCompilerOptions, jsDeclarationCompilerOptions } = require('./lib/typescriptSettings');
|
|
70
|
+
const { hashSource, isObject } = require('./lib/tools');
|
|
71
|
+
const { isDeepStrictEqual } = require('node:util');
|
|
70
72
|
const {
|
|
71
73
|
resolveTypescriptLibs,
|
|
72
74
|
resolveTypings,
|
|
@@ -74,14 +76,10 @@ const {
|
|
|
74
76
|
transformScriptBeforeCompilation,
|
|
75
77
|
transformGlobalDeclarations
|
|
76
78
|
} = require('./lib/typescriptTools');
|
|
77
|
-
const { targetTsLib, tsCompilerOptions, jsDeclarationCompilerOptions } = require('./lib/typescriptSettings');
|
|
78
|
-
const { hashSource, isObject } = require('./lib/tools');
|
|
79
79
|
|
|
80
80
|
const packageJson = require('./package.json');
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
const adapterName = packageJson.name.split('.').pop();
|
|
84
|
-
const scriptCodeMarker = 'script.js.';
|
|
81
|
+
const SCRIPT_CODE_MARKER = 'script.js.';
|
|
82
|
+
|
|
85
83
|
const stopCounters = {};
|
|
86
84
|
let setStateCountCheckInterval = null;
|
|
87
85
|
|
|
@@ -407,9 +405,7 @@ let adapter;
|
|
|
407
405
|
function startAdapter(options) {
|
|
408
406
|
options = options || {};
|
|
409
407
|
Object.assign(options, {
|
|
410
|
-
|
|
411
|
-
name: adapterName,
|
|
412
|
-
|
|
408
|
+
name: 'javascript',
|
|
413
409
|
useFormatDate: true, // load float formatting
|
|
414
410
|
|
|
415
411
|
/**
|
|
@@ -515,12 +511,12 @@ function startAdapter(options) {
|
|
|
515
511
|
stop(id);
|
|
516
512
|
|
|
517
513
|
// delete scriptEnabled.blabla variable
|
|
518
|
-
const idActive = 'scriptEnabled.' + id.substring(
|
|
514
|
+
const idActive = 'scriptEnabled.' + id.substring(SCRIPT_CODE_MARKER.length);
|
|
519
515
|
adapter.delObject(idActive);
|
|
520
516
|
adapter.delState(idActive);
|
|
521
517
|
|
|
522
518
|
// delete scriptProblem.blabla variable
|
|
523
|
-
const idProblem = 'scriptProblem.' + id.substring(
|
|
519
|
+
const idProblem = 'scriptProblem.' + id.substring(SCRIPT_CODE_MARKER.length);
|
|
524
520
|
adapter.delObject(idProblem);
|
|
525
521
|
adapter.delState(idProblem);
|
|
526
522
|
}
|
|
@@ -688,7 +684,7 @@ function startAdapter(options) {
|
|
|
688
684
|
const eventData = event.exception.values[0];
|
|
689
685
|
if (eventData.stacktrace && eventData.stacktrace.frames && Array.isArray(eventData.stacktrace.frames) && eventData.stacktrace.frames.length) {
|
|
690
686
|
// Exclude event if script Marker is included
|
|
691
|
-
if (eventData.stacktrace.frames.find(frame => frame.filename && frame.filename.includes(
|
|
687
|
+
if (eventData.stacktrace.frames.find(frame => frame.filename && frame.filename.includes(SCRIPT_CODE_MARKER))) {
|
|
692
688
|
return null;
|
|
693
689
|
}
|
|
694
690
|
//Exclude event if own directory is included but not inside own node_modules
|
|
@@ -741,7 +737,7 @@ function startAdapter(options) {
|
|
|
741
737
|
handler.cb.call(handler.sandbox, obj.message.data, result => {/* nop */ });
|
|
742
738
|
}
|
|
743
739
|
} catch (e) {
|
|
744
|
-
adapter.setState('scriptProblem.' + name.substring(
|
|
740
|
+
adapter.setState('scriptProblem.' + name.substring(SCRIPT_CODE_MARKER.length), true, true);
|
|
745
741
|
context.logError('Error in callback', e);
|
|
746
742
|
}
|
|
747
743
|
});
|
|
@@ -907,7 +903,7 @@ function startAdapter(options) {
|
|
|
907
903
|
// Identify unhandled errors originating from callbacks in scripts
|
|
908
904
|
// These are not caught by wrapping the execution code in try-catch
|
|
909
905
|
if (err && typeof err.stack === 'string') {
|
|
910
|
-
const scriptCodeMarkerIndex = err.stack.indexOf(
|
|
906
|
+
const scriptCodeMarkerIndex = err.stack.indexOf(SCRIPT_CODE_MARKER);
|
|
911
907
|
if (scriptCodeMarkerIndex > -1) {
|
|
912
908
|
// This is a script error
|
|
913
909
|
let scriptName = err.stack.substr(scriptCodeMarkerIndex);
|
|
@@ -1091,6 +1087,7 @@ function main() {
|
|
|
1091
1087
|
getData(() => {
|
|
1092
1088
|
context.scheduler = new Scheduler(adapter.log, Date, mods.suncalc, adapter.config.latitude, adapter.config.longitude);
|
|
1093
1089
|
dayTimeSchedules(adapter, context);
|
|
1090
|
+
sunTimeSchedules(adapter, context);
|
|
1094
1091
|
timeSchedule(adapter, context);
|
|
1095
1092
|
|
|
1096
1093
|
// Warning. It could have a side-effect in compact mode, so all adapters will accept self signed certificates
|
|
@@ -1319,7 +1316,8 @@ let knownGlobalDeclarationsByScript = {};
|
|
|
1319
1316
|
let globalScriptLines = 0;
|
|
1320
1317
|
// let activeRegEx = null;
|
|
1321
1318
|
let activeStr = ''; // enabled state prefix
|
|
1322
|
-
let
|
|
1319
|
+
let dayScheduleTimer = null; // schedule for astrological day
|
|
1320
|
+
let sunScheduleTimer = null; // schedule for sun moment times
|
|
1323
1321
|
let timeScheduleTimer = null; // schedule for astrological day
|
|
1324
1322
|
|
|
1325
1323
|
function getNextTimeEvent(time, useNextDay) {
|
|
@@ -1379,9 +1377,11 @@ function timeSchedule(adapter, context) {
|
|
|
1379
1377
|
}
|
|
1380
1378
|
}
|
|
1381
1379
|
if (context.timeSettings.leadingZeros) {
|
|
1382
|
-
hours = hours.toString().padStart(2, '0');
|
|
1380
|
+
hours = parseInt(hours.toString().padStart(2, '0'));
|
|
1383
1381
|
}
|
|
1384
|
-
|
|
1382
|
+
|
|
1383
|
+
adapter.setState('variables.dayTime', {val: `${hours}:${minutes.toString().padStart(2, '0')}`, ack: true});
|
|
1384
|
+
|
|
1385
1385
|
now.setMinutes(now.getMinutes() + 1);
|
|
1386
1386
|
now.setSeconds(0);
|
|
1387
1387
|
now.setMilliseconds(0);
|
|
@@ -1433,17 +1433,17 @@ function dayTimeSchedules(adapter, context) {
|
|
|
1433
1433
|
}
|
|
1434
1434
|
|
|
1435
1435
|
const val = state ? !!state.val : false;
|
|
1436
|
-
if (val !== isDay) {
|
|
1437
|
-
adapter.setState('variables.isDayTime', isDay, true);
|
|
1436
|
+
if (val !== isDay || state === null) {
|
|
1437
|
+
adapter.setState('variables.isDayTime', {val: isDay, ack: true});
|
|
1438
1438
|
}
|
|
1439
1439
|
});
|
|
1440
1440
|
|
|
1441
1441
|
adapter.getState('variables.isDaylightSaving', (err, state) => {
|
|
1442
1442
|
const isDayLightSaving = dstOffsetAtDate(nowDate) !== 0;
|
|
1443
|
-
|
|
1444
1443
|
const val = state ? !!state.val : false;
|
|
1445
|
-
|
|
1446
|
-
|
|
1444
|
+
|
|
1445
|
+
if (val !== isDayLightSaving || state === null) {
|
|
1446
|
+
adapter.setState('variables.isDaylightSaving', {val: isDayLightSaving, ack: true});
|
|
1447
1447
|
}
|
|
1448
1448
|
});
|
|
1449
1449
|
|
|
@@ -1456,11 +1456,46 @@ function dayTimeSchedules(adapter, context) {
|
|
|
1456
1456
|
nextTimeout = 3000;
|
|
1457
1457
|
}
|
|
1458
1458
|
|
|
1459
|
-
|
|
1459
|
+
dayScheduleTimer = setTimeout(dayTimeSchedules, nextTimeout, adapter, context);
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
async function sunTimeSchedules(adapter, context) {
|
|
1463
|
+
const todayDate = new Date();
|
|
1464
|
+
todayDate.setHours(0);
|
|
1465
|
+
todayDate.setMinutes(0);
|
|
1466
|
+
todayDate.setSeconds(1);
|
|
1467
|
+
todayDate.setDate(todayDate.getDate() + 1);
|
|
1468
|
+
|
|
1469
|
+
const times = mods.suncalc.getTimes(new Date(), adapter.config.latitude, adapter.config.longitude);
|
|
1470
|
+
|
|
1471
|
+
for (const t in times) {
|
|
1472
|
+
const h = times[t].getHours();
|
|
1473
|
+
const m = times[t].getMinutes();
|
|
1474
|
+
|
|
1475
|
+
const timeFormatted = `${h < 10 ? '0' + h : h}:${m < 10 ? '0' + m : m}`;
|
|
1476
|
+
const objId = `variables.astro.${t}`;
|
|
1477
|
+
|
|
1478
|
+
await adapter.setObjectNotExistsAsync(objId, {
|
|
1479
|
+
type: 'state',
|
|
1480
|
+
common: {
|
|
1481
|
+
name: `Astro ${t}`,
|
|
1482
|
+
type: 'string',
|
|
1483
|
+
role: 'value',
|
|
1484
|
+
read: true,
|
|
1485
|
+
write: false,
|
|
1486
|
+
},
|
|
1487
|
+
native: {},
|
|
1488
|
+
});
|
|
1489
|
+
await adapter.setStateAsync(objId, { val: timeFormatted, ack: true });
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
adapter.log.debug(`[sunTimeSchedules] Next: ${todayDate.toISOString()}`);
|
|
1493
|
+
sunScheduleTimer = setTimeout(sunTimeSchedules, todayDate.getTime() - Date.now(), adapter, context);
|
|
1460
1494
|
}
|
|
1461
1495
|
|
|
1462
1496
|
function stopTimeSchedules() {
|
|
1463
|
-
|
|
1497
|
+
dayScheduleTimer && clearTimeout(dayScheduleTimer);
|
|
1498
|
+
sunScheduleTimer && clearTimeout(sunScheduleTimer);
|
|
1464
1499
|
timeScheduleTimer && clearTimeout(timeScheduleTimer);
|
|
1465
1500
|
}
|
|
1466
1501
|
|
|
@@ -1553,13 +1588,13 @@ context.logError = function (msg, e, offs) {
|
|
|
1553
1588
|
};
|
|
1554
1589
|
|
|
1555
1590
|
function createActiveObject(id, enabled, cb) {
|
|
1556
|
-
const idActive = `${adapter.namespace}.scriptEnabled.${id.substring(
|
|
1591
|
+
const idActive = `${adapter.namespace}.scriptEnabled.${id.substring(SCRIPT_CODE_MARKER.length)}`;
|
|
1557
1592
|
|
|
1558
1593
|
if (!context.objects[idActive]) {
|
|
1559
1594
|
context.objects[idActive] = {
|
|
1560
1595
|
_id: idActive,
|
|
1561
1596
|
common: {
|
|
1562
|
-
name: `scriptEnabled.${id.substring(
|
|
1597
|
+
name: `scriptEnabled.${id.substring(SCRIPT_CODE_MARKER.length)}`,
|
|
1563
1598
|
desc: 'controls script activity',
|
|
1564
1599
|
type: 'boolean',
|
|
1565
1600
|
write: true,
|
|
@@ -1602,13 +1637,13 @@ function createActiveObject(id, enabled, cb) {
|
|
|
1602
1637
|
}
|
|
1603
1638
|
|
|
1604
1639
|
function createProblemObject(id, cb) {
|
|
1605
|
-
const idProblem = adapter.namespace + '.scriptProblem.' + id.substring(
|
|
1640
|
+
const idProblem = adapter.namespace + '.scriptProblem.' + id.substring(SCRIPT_CODE_MARKER.length);
|
|
1606
1641
|
|
|
1607
1642
|
if (!context.objects[idProblem]) {
|
|
1608
1643
|
context.objects[idProblem] = {
|
|
1609
1644
|
_id: idProblem,
|
|
1610
1645
|
common: {
|
|
1611
|
-
name: 'scriptProblem.' + id.substring(
|
|
1646
|
+
name: 'scriptProblem.' + id.substring(SCRIPT_CODE_MARKER.length),
|
|
1612
1647
|
desc: 'is the script has a problem',
|
|
1613
1648
|
type: 'boolean',
|
|
1614
1649
|
expert: true,
|
|
@@ -1754,7 +1789,8 @@ function installLibraries(callback) {
|
|
|
1754
1789
|
if (libraries[lib] && libraries[lib].trim()) {
|
|
1755
1790
|
libraries[lib] = libraries[lib].trim();
|
|
1756
1791
|
let libName = libraries[lib];
|
|
1757
|
-
|
|
1792
|
+
|
|
1793
|
+
const versionChunkPos = libName.indexOf('@', 1);
|
|
1758
1794
|
if (versionChunkPos > -1) {
|
|
1759
1795
|
libName = libName.slice(0, versionChunkPos);
|
|
1760
1796
|
}
|
|
@@ -1826,7 +1862,7 @@ function execute(script, name, verbose, debug) {
|
|
|
1826
1862
|
script.subscribesFile = {};
|
|
1827
1863
|
script.setStatePerMinuteCounter = 0;
|
|
1828
1864
|
script.setStatePerMinuteProblemCounter = 0;
|
|
1829
|
-
adapter.setState(`scriptProblem.${name.substring(
|
|
1865
|
+
adapter.setState(`scriptProblem.${name.substring(SCRIPT_CODE_MARKER.length)}`, { val: false, ack: true, expire: 1000 });
|
|
1830
1866
|
|
|
1831
1867
|
const sandbox = sandBox(script, name, verbose, debug, context);
|
|
1832
1868
|
|
|
@@ -1837,7 +1873,7 @@ function execute(script, name, verbose, debug) {
|
|
|
1837
1873
|
// lineOffset: globalScriptLines
|
|
1838
1874
|
});
|
|
1839
1875
|
} catch (e) {
|
|
1840
|
-
adapter.setState(`scriptProblem.${name.substring(
|
|
1876
|
+
adapter.setState(`scriptProblem.${name.substring(SCRIPT_CODE_MARKER.length)}`, { val: true, ack: true, c: 'execute' });
|
|
1841
1877
|
context.logError(name, e);
|
|
1842
1878
|
}
|
|
1843
1879
|
}
|
|
@@ -1897,7 +1933,7 @@ function updateLogSubscriptions() {
|
|
|
1897
1933
|
function stop(name, callback) {
|
|
1898
1934
|
adapter.log.info('Stop script ' + name);
|
|
1899
1935
|
|
|
1900
|
-
adapter.setState('scriptEnabled.' + name.substring(
|
|
1936
|
+
adapter.setState('scriptEnabled.' + name.substring(SCRIPT_CODE_MARKER.length), false, true);
|
|
1901
1937
|
|
|
1902
1938
|
if (context.messageBusHandlers[name]) {
|
|
1903
1939
|
delete context.messageBusHandlers[name];
|
|
@@ -2038,7 +2074,7 @@ function prepareScript(obj, callback) {
|
|
|
2038
2074
|
) {
|
|
2039
2075
|
const name = obj._id;
|
|
2040
2076
|
|
|
2041
|
-
const nameId = name.substring(
|
|
2077
|
+
const nameId = name.substring(SCRIPT_CODE_MARKER.length);
|
|
2042
2078
|
if (!nameId.length || nameId.endsWith('.')) {
|
|
2043
2079
|
adapter.log.error(`Script name ${name} is invalid!`);
|
|
2044
2080
|
typeof callback === 'function' && callback(false, name);
|
|
@@ -2139,7 +2175,7 @@ function prepareScript(obj, callback) {
|
|
|
2139
2175
|
let _name;
|
|
2140
2176
|
if (obj && obj._id) {
|
|
2141
2177
|
_name = obj._id;
|
|
2142
|
-
const scriptIdName = _name.substring(
|
|
2178
|
+
const scriptIdName = _name.substring(SCRIPT_CODE_MARKER.length);
|
|
2143
2179
|
|
|
2144
2180
|
if (!scriptIdName.length || scriptIdName.endsWith('.')) {
|
|
2145
2181
|
adapter.log.error(`Script name ${_name} is invalid!`);
|
|
@@ -2202,7 +2238,7 @@ async function getData(callback) {
|
|
|
2202
2238
|
if (!adapter.config.subscribe) {
|
|
2203
2239
|
if (err || !res) {
|
|
2204
2240
|
adapter.log.error(`Could not initialize states: ${err ? err.message : 'no result'}`);
|
|
2205
|
-
adapter.terminate(EXIT_CODES.START_IMMEDIATELY_AFTER_STOP);
|
|
2241
|
+
adapter.terminate(utils.EXIT_CODES.START_IMMEDIATELY_AFTER_STOP);
|
|
2206
2242
|
return;
|
|
2207
2243
|
}
|
|
2208
2244
|
context.states = Object.assign(res, context.states);
|
|
@@ -2226,7 +2262,7 @@ async function getData(callback) {
|
|
|
2226
2262
|
adapter.getObjectList({ include_docs: true }, (err, res) => {
|
|
2227
2263
|
if (err || !res || !res.rows) {
|
|
2228
2264
|
adapter.log.error(`Could not initialize objects: ${err ? err.message : 'no result'}`);
|
|
2229
|
-
adapter.terminate(EXIT_CODES.START_IMMEDIATELY_AFTER_STOP);
|
|
2265
|
+
adapter.terminate(utils.EXIT_CODES.START_IMMEDIATELY_AFTER_STOP);
|
|
2230
2266
|
return;
|
|
2231
2267
|
}
|
|
2232
2268
|
context.objects = {};
|