@iobroker/adapter-react-v5 4.6.13 → 4.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.
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const react_1 = __importDefault(require("react"));
7
+ const styles_1 = require("@mui/styles");
8
+ const material_1 = require("@mui/material");
9
+ const i18n_1 = __importDefault(require("./wrapper/i18n"));
10
+ const ConfigGeneric_1 = __importDefault(require("./ConfigGeneric"));
11
+ const styles = () => ({
12
+ indeterminate: {
13
+ opacity: 0.5,
14
+ },
15
+ control: {
16
+ flexDirection: 'row',
17
+ width: '100%',
18
+ },
19
+ });
20
+ class ConfigNumber extends ConfigGeneric_1.default {
21
+ componentDidMount() {
22
+ super.componentDidMount();
23
+ let _value = ConfigGeneric_1.default.getValue(this.props.data, this.props.attr);
24
+ if (_value === null || _value === undefined) {
25
+ _value = '';
26
+ }
27
+ this.setState({ _value: _value.toString(), oldValue: _value.toString() });
28
+ // this.props.registerOnForceUpdate(this.props.attr, this.onUpdate);
29
+ }
30
+ static getDerivedStateFromProps(props, state) {
31
+ if ((props.schema.min !== undefined && props.schema.min < 0) ||
32
+ (props.schema.max !== undefined && props.schema.max < 0)) {
33
+ return null;
34
+ }
35
+ const _value = ConfigGeneric_1.default.getValue(props.data, props.attr);
36
+ if (_value === null ||
37
+ _value === undefined ||
38
+ state.oldValue === null ||
39
+ state.oldValue === undefined ||
40
+ (_value.toString() !== parseFloat(state._value).toString() &&
41
+ _value.toString() !== state.oldValue.toString())) {
42
+ return { _value };
43
+ }
44
+ return null;
45
+ }
46
+ checkValue(value) {
47
+ if (value === null || value === undefined) {
48
+ return null;
49
+ }
50
+ value = value.toString().trim();
51
+ const f = value === '' ? 0 : parseFloat(value);
52
+ if (value !== '' && Number.isNaN(f)) {
53
+ return 'ra_Not a number';
54
+ }
55
+ // eslint-disable-next-line no-restricted-properties
56
+ if (value !== '' && window.isFinite(f)) {
57
+ if (this.props.schema.min !== undefined && f < this.props.schema.min) {
58
+ return 'ra_Too small';
59
+ }
60
+ if (this.props.schema.max !== undefined && f > this.props.schema.max) {
61
+ return 'ra_Too big';
62
+ }
63
+ if (value === '' || value === '-' || Number.isNaN(f)) {
64
+ return 'ra_Not a number';
65
+ }
66
+ return null;
67
+ }
68
+ return 'ra_Not a number';
69
+ }
70
+ renderItem(error, disabled) {
71
+ const isIndeterminate = Array.isArray(this.state.value) || this.state.value === ConfigGeneric_1.default.DIFFERENT_VALUE;
72
+ if (this.state.oldValue !== null && this.state.oldValue !== undefined) {
73
+ this.updateTimeout && clearTimeout(this.updateTimeout);
74
+ this.updateTimeout = setTimeout(() => {
75
+ this.updateTimeout = undefined;
76
+ this.setState({ oldValue: null });
77
+ }, 30);
78
+ }
79
+ else if (this.updateTimeout) {
80
+ clearTimeout(this.updateTimeout);
81
+ this.updateTimeout = undefined;
82
+ }
83
+ if (isIndeterminate) {
84
+ const arr = [...this.state.value].map(item => ({ label: item.toString(), value: item }));
85
+ arr.unshift({ label: i18n_1.default.t(ConfigGeneric_1.default.DIFFERENT_LABEL), value: ConfigGeneric_1.default.DIFFERENT_VALUE });
86
+ return react_1.default.createElement(material_1.Autocomplete, { className: this.props.classes.indeterminate, fullWidth: true, value: arr[0],
87
+ // @ts-expect-error needs investigation if this really has no effect
88
+ getOptionSelected: (option, value) => option.label === value.label, onChange: (_, value) => this.onChange(this.props.attr, value === null || value === void 0 ? void 0 : value.value), options: arr, getOptionLabel: option => option.label, renderInput: params => (react_1.default.createElement(material_1.TextField, Object.assign({ variant: "standard" }, params, { inputProps: { readOnly: this.props.schema.readOnly || false }, error: !!error, placeholder: this.getText(this.props.schema.placeholder), label: this.getText(this.props.schema.label), helperText: this.renderHelp(this.props.schema.help, this.props.schema.helpLink, this.props.schema.noTranslation), disabled: !!disabled }))) });
89
+ }
90
+ if (!error && this.state._value !== null && this.state._value !== undefined && this.state._value) {
91
+ error = this.checkValue(this.state._value);
92
+ if (error) {
93
+ error = i18n_1.default.t(error);
94
+ }
95
+ }
96
+ return react_1.default.createElement(material_1.FormControl, { variant: "standard", className: this.props.classes.control },
97
+ react_1.default.createElement(material_1.TextField, { variant: "standard", type: "number", fullWidth: true, inputProps: {
98
+ min: this.props.schema.min,
99
+ max: this.props.schema.max,
100
+ step: this.props.schema.step,
101
+ readOnly: this.props.schema.readOnly || false,
102
+ }, value: this.state._value === null || this.state._value === undefined ? '' : this.state._value, error: !!error, disabled: !!disabled, onChange: e => {
103
+ const _value = e.target.value; // value is always a string and it is validly formatted
104
+ const _error = this.checkValue(_value);
105
+ if (_error) {
106
+ this.onError(this.props.attr, i18n_1.default.t(_error));
107
+ }
108
+ else {
109
+ this.onError(this.props.attr); // clear error
110
+ }
111
+ this.setState({ _value, oldValue: this.state._value }, () => this.onChange(this.props.attr, parseFloat(_value)));
112
+ }, placeholder: this.getText(this.props.schema.placeholder), label: this.getText(this.props.schema.label), helperText: error && typeof error === 'string'
113
+ ? error
114
+ : this.renderHelp(this.props.schema.help, this.props.schema.helpLink, this.props.schema.noTranslation) }));
115
+ }
116
+ }
117
+ exports.default = (0, styles_1.withStyles)(styles)(ConfigNumber);
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const _default: React.JSXElementConstructor<any>;
3
+ export default _default;
@@ -0,0 +1,176 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const react_1 = __importDefault(require("react"));
7
+ const styles_1 = require("@mui/styles");
8
+ const material_1 = require("@mui/material");
9
+ const i18n_1 = __importDefault(require("./wrapper/i18n"));
10
+ const ConfigGeneric_1 = __importDefault(require("./ConfigGeneric"));
11
+ const styles = () => ({
12
+ indeterminate: {
13
+ opacity: 0.5,
14
+ },
15
+ control: {
16
+ flexDirection: 'row',
17
+ width: '100%',
18
+ },
19
+ warning: {
20
+ '& .Mui-error': {
21
+ color: 'orange',
22
+ },
23
+ },
24
+ });
25
+ class ConfigPort extends ConfigGeneric_1.default {
26
+ async componentDidMount() {
27
+ super.componentDidMount();
28
+ let _value = ConfigGeneric_1.default.getValue(this.props.data, this.props.attr);
29
+ if (_value === null || _value === undefined) {
30
+ _value = '';
31
+ }
32
+ this.setState({ _value: _value.toString(), oldValue: _value.toString() });
33
+ // read all instances
34
+ const instances = await this.props.socket.getAdapterInstances();
35
+ const ownId = `system.adapter.${this.props.adapterName}.${this.props.instance}`;
36
+ const instanceObj = await this.props.socket.getObject(ownId);
37
+ const ownHostname = instanceObj === null || instanceObj === void 0 ? void 0 : instanceObj.common.host;
38
+ const ports = [];
39
+ instances
40
+ .forEach(instance => {
41
+ var _a, _b, _c, _d;
42
+ // ignore own instance and instances on another host
43
+ if (!instance || instance._id === ownId || instance.common.host !== ownHostname) {
44
+ return;
45
+ }
46
+ // check port only if bind attribute is present too
47
+ if (!((_a = instance.native) === null || _a === void 0 ? void 0 : _a.bind)) {
48
+ return;
49
+ }
50
+ // if let's encrypt is enabled and update is enabled, then add port to check
51
+ if ((instance === null || instance === void 0 ? void 0 : instance.native) &&
52
+ instance.native.secure &&
53
+ instance.native.leEnabled &&
54
+ instance.native.leUpdate) {
55
+ const port = parseInt(instance.native.leCheckPort || instance.native.lePort, 10);
56
+ port && ports.push({
57
+ name: `${instance._id.replace('system.adapter.', '')} (LE)`,
58
+ port,
59
+ v6bind: instance.native.bind.includes(':') ? instance.native.bind : instance.native.v6bind,
60
+ bind: instance.native.bind,
61
+ enabled: !!((_b = instance.common) === null || _b === void 0 ? void 0 : _b.enabled),
62
+ });
63
+ }
64
+ const port = parseInt((_c = instance === null || instance === void 0 ? void 0 : instance.native) === null || _c === void 0 ? void 0 : _c.port, 10);
65
+ if (port) {
66
+ ports.push({
67
+ name: instance._id.replace('system.adapter.', ''),
68
+ bind: instance.native.bind,
69
+ v6bind: instance.native.bind.includes(':') ? instance.native.bind : instance.native.v6bind,
70
+ port,
71
+ enabled: !!((_d = instance.common) === null || _d === void 0 ? void 0 : _d.enabled),
72
+ });
73
+ }
74
+ });
75
+ this.setState({ ports });
76
+ }
77
+ static getDerivedStateFromProps(props, state) {
78
+ const _value = ConfigGeneric_1.default.getValue(props.data, props.attr);
79
+ if (_value === null || _value === undefined ||
80
+ state.oldValue === null || state.oldValue === undefined ||
81
+ (_value.toString() !== parseInt(state._value, 10).toString() &&
82
+ _value.toString() !== state.oldValue.toString())) {
83
+ return { _value };
84
+ }
85
+ return null;
86
+ }
87
+ checkValue(value) {
88
+ if (value === null || value === undefined) {
89
+ return null;
90
+ }
91
+ const min = this.props.schema.min || 20;
92
+ const max = this.props.schema.max || 0xFFFF;
93
+ value = value.toString().trim();
94
+ const f = value === '' ? 0 : parseInt(value, 10);
95
+ if (value !== '' && Number.isNaN(f)) {
96
+ return 'ra_Not a number';
97
+ }
98
+ // eslint-disable-next-line no-restricted-properties
99
+ if (value !== '' && window.isFinite(Number(value))) {
100
+ if (f < min) {
101
+ return 'ra_Too small';
102
+ }
103
+ if (f > max) {
104
+ return 'ra_Too big';
105
+ }
106
+ if (value === '' || value === '-' || Number.isNaN(f)) {
107
+ return 'ra_Not a number';
108
+ }
109
+ return null;
110
+ }
111
+ return 'ra_Not a number';
112
+ }
113
+ renderItem(error, disabled) {
114
+ if (this.state.oldValue !== null && this.state.oldValue !== undefined) {
115
+ this.updateTimeout && clearTimeout(this.updateTimeout);
116
+ this.updateTimeout = setTimeout(() => {
117
+ this.updateTimeout = undefined;
118
+ this.setState({ oldValue: null });
119
+ }, 30);
120
+ }
121
+ else if (this.updateTimeout) {
122
+ clearTimeout(this.updateTimeout);
123
+ this.updateTimeout = undefined;
124
+ }
125
+ const min = this.props.schema.min || 20;
126
+ const max = this.props.schema.max || 0xFFFF;
127
+ let warning;
128
+ if (this.state.ports) {
129
+ const num = parseInt(this.state._value, 10);
130
+ // filter ports only with the same bind address
131
+ // todo: IPv6 (v6bind or '::/0')
132
+ const ports = this.state.ports.filter(item => !this.props.data.bind ||
133
+ this.props.data.bind === item.bind ||
134
+ this.props.data.bind === '0.0.0.0' ||
135
+ item.bind === '0.0.0.0');
136
+ let idx = ports.findIndex(item => item.port === num && item.enabled);
137
+ if (idx !== -1) {
138
+ error = i18n_1.default.t('ra_Port is already used by %s', this.state.ports[idx].name);
139
+ }
140
+ else {
141
+ idx = ports.findIndex(item => item.port === num && !item.enabled);
142
+ if (idx !== -1) {
143
+ warning = true;
144
+ error = i18n_1.default.t('ra_Port could be used by %s', this.state.ports[idx].name);
145
+ }
146
+ }
147
+ }
148
+ if (!error && this.state._value !== null && this.state._value !== undefined) {
149
+ error = this.checkValue(this.state._value);
150
+ if (typeof error === 'string') {
151
+ error = i18n_1.default.t(error);
152
+ }
153
+ }
154
+ return react_1.default.createElement(material_1.TextField, { variant: "standard", type: "number", fullWidth: true, inputProps: {
155
+ min,
156
+ max,
157
+ readOnly: this.props.schema.readOnly || false,
158
+ }, value: this.state._value === null || this.state._value === undefined ? '' : this.state._value, error: !!error, disabled: !!disabled, className: warning ? this.props.classes.warning : '', onChange: e => {
159
+ const _value = Number(e.target.value.toString().replace(/[^0-9]/g, '')).toString();
160
+ const _error = this.checkValue(_value);
161
+ if (_error) {
162
+ this.onError(this.props.attr, i18n_1.default.t(_error));
163
+ }
164
+ else {
165
+ this.onError(this.props.attr); // clear error
166
+ }
167
+ this.setState({ _value, oldValue: this.state._value }, () => {
168
+ if (_value.trim() === parseInt(_value, 10).toString()) {
169
+ this.onChange(this.props.attr, parseInt(_value, 10) || 0);
170
+ }
171
+ });
172
+ }, placeholder: this.getText(this.props.schema.placeholder), label: this.getText(this.props.schema.label), helperText: error && typeof error === 'string' ? error : this.renderHelp(this.props.schema.help, this.props.schema.helpLink, this.props.schema.noTranslation) });
173
+ }
174
+ }
175
+ // @ts-expect-error check later on
176
+ exports.default = (0, styles_1.withStyles)(styles)(ConfigPort);
@@ -0,0 +1,2 @@
1
+ import AdminConnection from '../../../AdminConnection';
2
+ export default AdminConnection;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const AdminConnection_1 = __importDefault(require("../../../AdminConnection"));
7
+ exports.default = AdminConnection_1.default;
@@ -40,9 +40,9 @@ var MDUtils = /*#__PURE__*/function () {
40
40
  }, {
41
41
  key: "getTitle",
42
42
  value: function getTitle(text) {
43
- var _MDUtils$extractHeade = MDUtils.extractHeader(text),
44
- body = _MDUtils$extractHeade.body,
45
- header = _MDUtils$extractHeade.header;
43
+ var result = MDUtils.extractHeader(text);
44
+ var body = result.body;
45
+ var header = result.header;
46
46
  if (!header.title) {
47
47
  // remove {docsify-bla}
48
48
  body = body.replace(/{[^}]*}/g, '');
@@ -1 +1 @@
1
- {"version":3,"file":"MDUtils.js","names":["_react","_interopRequireDefault","require","_copyToClipboard","MDUtils","_classCallCheck2","_createClass2","key","value","text2link","text","m","match","replace","trim","toLowerCase","openLink","url","target","window","location","open","getTitle","_MDUtils$extractHeade","extractHeader","body","header","title","lines","split","i","length","startsWith","substring","attrs","pos","indexOf","_header","forEach","line","_pos","attr","parseFloat","toString","removeDocsify","doc","onCopy","e","copy","stopPropagation","preventDefault","_default","exports"],"sources":["MDUtils.js"],"sourcesContent":["/**\n * Copyright 2018-2023 Denis Haev (bluefox) <dogafox@gmail.com>\n *\n * MIT License\n *\n **/\nimport React from 'react';\nimport copy from './copy-to-clipboard';\n\nclass MDUtils {\n static text2link(text) {\n const m = text.match(/\\d+\\.\\)\\s/);\n if (m) {\n text = text.replace(m[0], m[0].replace(/\\s/, '&nbsp;'));\n }\n\n return text.replace(/[^a-zA-Zа-яА-Я0-9]/g, '').trim().replace(/\\s/g, '').toLowerCase();\n }\n\n static openLink(url, target) {\n if (target === 'this') {\n window.location = url;\n } else {\n window.open(url, target || '_blank');\n }\n }\n\n static getTitle(text) {\n let { body, header } = MDUtils.extractHeader(text);\n if (!header.title) {\n // remove {docsify-bla}\n body = body.replace(/{[^}]*}/g, '');\n body = body.trim();\n const lines = body.replace(/\\r/g, '').split('\\n');\n for (let i = 0; i < lines.length; i++) {\n if (lines[i].startsWith('# ')) {\n return lines[i].substring(2).trim();\n }\n }\n return '';\n }\n\n return header.title;\n }\n\n static extractHeader(text) {\n const attrs = {};\n if (text.substring(0, 3) === '---') {\n const pos = text.substring(3).indexOf('\\n---');\n if (pos !== -1) {\n const _header = text.substring(3, pos + 3);\n const lines = _header.replace(/\\r/g, '').split('\\n');\n lines.forEach(line => {\n if (!line.trim()) {\n return;\n }\n const _pos = line.indexOf(':');\n if (_pos !== -1) {\n const attr = line.substring(0, _pos).trim();\n attrs[attr] = line.substring(_pos + 1).trim();\n attrs[attr] = attrs[attr].replace(/^['\"]|['\"]$/g, '');\n if (attrs[attr] === 'true') {\n attrs[attr] = true;\n } else if (attrs[attr] === 'false') {\n attrs[attr] = false;\n } else if (parseFloat(attrs[attr]).toString() === attrs[attr]) {\n attrs[attr] = parseFloat(attrs[attr]);\n }\n } else {\n attrs[line.trim()] = true;\n }\n });\n text = text.substring(pos + 7);\n }\n }\n return { header: attrs, body: text };\n }\n\n static removeDocsify(text) {\n const m = text.match(/{docsify-[^}]*}/g);\n if (m) {\n m.forEach(doc => text = text.replace(doc, ''));\n }\n return text;\n }\n\n static onCopy(e, text) {\n copy(text);\n e && e.stopPropagation();\n e && e.preventDefault();\n }\n}\n\nexport default MDUtils;\n"],"mappings":";;;;;;;;;AAMA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAF,sBAAA,CAAAC,OAAA;AAPA;AACA;AACA;AACA;AACA;AACA;AALA,IASME,OAAO;EAAA,SAAAA,QAAA;IAAA,IAAAC,gBAAA,m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AAH,GAAA;IAAAC,KAAA,EAED,SAAAsC,OAAcC,CAAC,EAAErC,IAAI,EAAE;MACnB,IAAAsC,2BAAI,EAACtC,IAAI,CAAC;MACVqC,CAAC,IAAIA,CAAC,CAACE,eAAe,CAAC,CAAC;MACxBF,CAAC,IAAIA,CAAC,CAACG,cAAc,CAAC,CAAC;IAC3B;EAAC;EAAA,OAAA9C,OAAA;AAAA;AAAA,IAAA+C,QAAA,GAAAC,OAAA,cAGUhD,OAAO"}
1
+ {"version":3,"file":"MDUtils.js","names":["_react","_interopRequireDefault","require","_copyToClipboard","MDUtils","_classCallCheck2","_createClass2","key","value","text2link","text","m","match","replace","trim","toLowerCase","openLink","url","target","window","location","open","getTitle","result","extractHeader","body","header","title","lines","split","i","length","startsWith","substring","attrs","pos","indexOf","_header","forEach","line","_pos","attr","parseFloat","toString","removeDocsify","doc","onCopy","e","copy","stopPropagation","preventDefault","_default","exports"],"sources":["MDUtils.js"],"sourcesContent":["/**\n * Copyright 2018-2023 Denis Haev (bluefox) <dogafox@gmail.com>\n *\n * MIT License\n *\n **/\nimport React from 'react';\nimport copy from './copy-to-clipboard';\n\nclass MDUtils {\n static text2link(text) {\n const m = text.match(/\\d+\\.\\)\\s/);\n if (m) {\n text = text.replace(m[0], m[0].replace(/\\s/, '&nbsp;'));\n }\n\n return text.replace(/[^a-zA-Zа-яА-Я0-9]/g, '').trim().replace(/\\s/g, '').toLowerCase();\n }\n\n static openLink(url, target) {\n if (target === 'this') {\n window.location = url;\n } else {\n window.open(url, target || '_blank');\n }\n }\n\n static getTitle(text) {\n const result = MDUtils.extractHeader(text);\n let body = result.body;\n const header = result.header;\n if (!header.title) {\n // remove {docsify-bla}\n body = body.replace(/{[^}]*}/g, '');\n body = body.trim();\n const lines = body.replace(/\\r/g, '').split('\\n');\n for (let i = 0; i < lines.length; i++) {\n if (lines[i].startsWith('# ')) {\n return lines[i].substring(2).trim();\n }\n }\n return '';\n }\n\n return header.title;\n }\n\n static extractHeader(text) {\n const attrs = {};\n if (text.substring(0, 3) === '---') {\n const pos = text.substring(3).indexOf('\\n---');\n if (pos !== -1) {\n const _header = text.substring(3, pos + 3);\n const lines = _header.replace(/\\r/g, '').split('\\n');\n lines.forEach(line => {\n if (!line.trim()) {\n return;\n }\n const _pos = line.indexOf(':');\n if (_pos !== -1) {\n const attr = line.substring(0, _pos).trim();\n attrs[attr] = line.substring(_pos + 1).trim();\n attrs[attr] = attrs[attr].replace(/^['\"]|['\"]$/g, '');\n if (attrs[attr] === 'true') {\n attrs[attr] = true;\n } else if (attrs[attr] === 'false') {\n attrs[attr] = false;\n } else if (parseFloat(attrs[attr]).toString() === attrs[attr]) {\n attrs[attr] = parseFloat(attrs[attr]);\n }\n } else {\n attrs[line.trim()] = true;\n }\n });\n text = text.substring(pos + 7);\n }\n }\n return { header: attrs, body: text };\n }\n\n static removeDocsify(text) {\n const m = text.match(/{docsify-[^}]*}/g);\n if (m) {\n m.forEach(doc => text = text.replace(doc, ''));\n }\n return text;\n }\n\n static onCopy(e, text) {\n copy(text);\n e && e.stopPropagation();\n e && e.preventDefault();\n }\n}\n\nexport default MDUtils;\n"],"mappings":";;;;;;;;;AAMA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAF,sBAAA,CAAAC,OAAA;AAPA;AACA;AACA;AACA;AACA;AACA;AALA,IASME,OAAO;EAAA,SAAAA,QAAA;IAAA,IAAAC,gBAAA,mBAAAD,OAAA;EAAA;EAAA,IAAAE,aAAA,aAAAF,OAAA;IAAAG,GAAA;IAAAC,KAAA,EACT,SAAAC,UAAiBC,IAAI,EAAE;MACnB,IAAMC,CAAC,GAAGD,IAAI,CAACE,KAAK,CAAC,WAAW,CAAC;MACjC,IAAID,CAAC,EAAE;QACHD,IAAI,GAAGA,IAAI,CAACG,OAAO,CAACF,CAAC,CAAC,CAAC,CAAC,EAAEA,CAAC,CAAC,CAAC,CAAC,CAACE,OAAO,CAAC,IAAI,EAAE,QAAQ,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(cronspec, withSeconds, locale) {
434
434
  if (!_schedule.d && !_schedule.D) {
435
435
  outputText += " ".concat(locale['every day'], " ");
436
436
  }
437
- } else {
437
+ } else if (_schedule.h) {
438
+ // runs only at specific hours
438
439
  // Otherwise, list out every specified hour/minute value.
439
-
440
- if (_schedule.h) {
441
- // runs only at specific hours
442
- if (_schedule.m) {
443
- // and only at specific minutes
444
- if (_withSeconds) {
445
- if (!_schedule.s || _schedule.s.length === 60) {
446
- outputText += "".concat(locale['second of every'], " ").concat(numberList(_schedule.m), " ").concat(locale['minute past the'], " ").concat(numberList(_schedule.h), " ").concat(locale.hour);
447
- } else {
448
- outputText += "".concat(numberList(_schedule.s), " ").concat(locale['second of every'], " ").concat(numberList(_schedule.m), " ").concat(locale['minute past the'], " ").concat(numberList(_schedule.h), " ").concat(locale.hour);
449
- }
450
- } else {
451
- outputText += "".concat(numberList(_schedule.m), " ").concat(locale['minute past the'], " ").concat(numberList(_schedule.h), " ").concat(locale.hour);
452
- }
453
- } else {
454
- // specific hours, but every minute
455
- if (_withSeconds) {
456
- if (!_schedule.s || _schedule.s.length === 60) {
457
- outputText += "".concat(locale['second of every'], " ").concat(locale['minute of'], " ").concat(numberList(_schedule.h), " ").concat(locale.hour);
458
- } else {
459
- outputText += "".concat(numberList(_schedule.s), " ").concat(locale['second of every'], " ").concat(locale['minute of'], " ").concat(numberList(_schedule.h), " ").concat(locale.hour);
460
- }
461
- } else {
462
- outputText += "".concat(locale['minute of'], " ").concat(numberList(_schedule.h), " ").concat(locale.hour);
463
- }
464
- }
465
- } else if (_schedule.m) {
466
- // every hour, but specific minutes
440
+ if (_schedule.m) {
441
+ // and only at specific minutes
467
442
  if (_withSeconds) {
468
443
  if (!_schedule.s || _schedule.s.length === 60) {
469
- outputText += "".concat(locale['second of every'], " ").concat(numberList(_schedule.m), " ").concat(locale['minute every hour']);
444
+ outputText += "".concat(locale['second of every'], " ").concat(numberList(_schedule.m), " ").concat(locale['minute past the'], " ").concat(numberList(_schedule.h), " ").concat(locale.hour);
470
445
  } else {
471
- outputText += "".concat(numberList(_schedule.s), " ").concat(locale['second of every'], " ").concat(numberList(_schedule.m), " ").concat(locale['minute every hour']);
446
+ outputText += "".concat(numberList(_schedule.s), " ").concat(locale['second of every'], " ").concat(numberList(_schedule.m), " ").concat(locale['minute past the'], " ").concat(numberList(_schedule.h), " ").concat(locale.hour);
472
447
  }
473
448
  } else {
474
- outputText += "".concat(numberList(_schedule.m), " ").concat(locale['minute every hour']);
449
+ outputText += "".concat(numberList(_schedule.m), " ").concat(locale['minute past the'], " ").concat(numberList(_schedule.h), " ").concat(locale.hour);
475
450
  }
476
451
  } else if (_withSeconds) {
452
+ // specific hours, but every minute
477
453
  if (!_schedule.s || _schedule.s.length === 60) {
478
- outputText += locale.second;
454
+ outputText += "".concat(locale['second of every'], " ").concat(locale['minute of'], " ").concat(numberList(_schedule.h), " ").concat(locale.hour);
479
455
  } else {
480
- outputText += "".concat(numberList(_schedule.s), " ").concat(locale.second);
456
+ outputText += "".concat(numberList(_schedule.s), " ").concat(locale['second of every'], " ").concat(locale['minute of'], " ").concat(numberList(_schedule.h), " ").concat(locale.hour);
481
457
  }
482
458
  } else {
483
- // cronspec has "*" for both hour and minute
484
- outputText += locale.minute;
459
+ outputText += "".concat(locale['minute of'], " ").concat(numberList(_schedule.h), " ").concat(locale.hour);
485
460
  }
461
+ } else if (_schedule.m) {
462
+ // every hour, but specific minutes
463
+ if (_withSeconds) {
464
+ if (!_schedule.s || _schedule.s.length === 60) {
465
+ outputText += "".concat(locale['second of every'], " ").concat(numberList(_schedule.m), " ").concat(locale['minute every hour']);
466
+ } else {
467
+ outputText += "".concat(numberList(_schedule.s), " ").concat(locale['second of every'], " ").concat(numberList(_schedule.m), " ").concat(locale['minute every hour']);
468
+ }
469
+ } else {
470
+ outputText += "".concat(numberList(_schedule.m), " ").concat(locale['minute every hour']);
471
+ }
472
+ } else if (_withSeconds) {
473
+ if (!_schedule.s || _schedule.s.length === 60) {
474
+ outputText += locale.second;
475
+ } else {
476
+ outputText += "".concat(numberList(_schedule.s), " ").concat(locale.second);
477
+ }
478
+ } else {
479
+ // cronspec has "*" for both hour and minute
480
+ outputText += locale.minute;
486
481
  }
487
482
  if (_schedule.D) {
488
483
  // runs only on specific day(s) of month