@maiyunnet/kebab 3.0.3 → 3.1.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 +1 -1
- package/bin/kebab.js +1 -1
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/lib/captcha.js +2 -2
- package/lib/consistent.js +1 -1
- package/lib/core.d.ts +3 -3
- package/lib/core.js +29 -13
- package/lib/cron.d.ts +40 -0
- package/lib/cron.js +126 -0
- package/lib/crypto.js +2 -2
- package/lib/db.d.ts +4 -3
- package/lib/db.js +27 -15
- package/lib/dns.d.ts +1 -1
- package/lib/dns.js +7 -7
- package/lib/jwt.d.ts +3 -3
- package/lib/jwt.js +4 -4
- package/lib/kv.d.ts +4 -3
- package/lib/kv.js +21 -9
- package/lib/lan.js +1 -1
- package/lib/net/formdata.js +2 -2
- package/lib/net/request.d.ts +1 -1
- package/lib/net/request.js +2 -2
- package/lib/net/response.d.ts +1 -1
- package/lib/net.d.ts +2 -2
- package/lib/net.js +4 -4
- package/lib/s3.d.ts +1 -1
- package/lib/s3.js +2 -2
- package/lib/scan.d.ts +3 -3
- package/lib/scan.js +6 -6
- package/lib/session.d.ts +3 -3
- package/lib/session.js +6 -6
- package/lib/sql.d.ts +2 -2
- package/lib/sql.js +3 -3
- package/lib/ssh/sftp.js +2 -2
- package/lib/ssh/shell.js +1 -1
- package/lib/text.d.ts +2 -2
- package/lib/text.js +1 -1
- package/lib/time.d.ts +1 -1
- package/lib/time.js +1 -1
- package/lib/turnstile.d.ts +1 -1
- package/lib/turnstile.js +2 -2
- package/lib/ws.d.ts +2 -2
- package/lib/ws.js +2 -2
- package/lib/zip.d.ts +1 -1
- package/lib/zip.js +1 -1
- package/package.json +9 -6
- package/sys/child.js +6 -6
- package/sys/cmd.js +6 -6
- package/sys/master.js +8 -8
- package/sys/mod.d.ts +5 -5
- package/sys/mod.js +39 -16
- package/sys/route.d.ts +1 -1
- package/sys/route.js +11 -11
- package/www/example/ctr/main.d.ts +1 -1
- package/www/example/ctr/main.js +1 -1
- package/www/example/ctr/middle.d.ts +2 -2
- package/www/example/ctr/middle.js +1 -1
- package/www/example/ctr/test.d.ts +4 -2
- package/www/example/ctr/test.js +125 -42
- package/www/example/mod/test.d.ts +2 -2
- package/www/example/mod/test.js +2 -2
- package/www/example/mod/testdata.d.ts +1 -1
- package/www/example/mod/testdata.js +1 -1
- package/www/example/view/test.ejs +2 -1
- package/www/example/ws/mproxy.d.ts +1 -1
- package/www/example/ws/mproxy.js +3 -3
- package/www/example/ws/rproxy.d.ts +1 -1
- package/www/example/ws/rproxy.js +3 -3
- package/www/example/ws/rsocket.d.ts +1 -1
- package/www/example/ws/rsocket.js +3 -3
- package/www/example/ws/test.d.ts +1 -1
- package/www/example/ws/test.js +3 -3
package/www/example/ctr/test.js
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
// --- 库和定义 ---
|
|
2
|
-
import * as lCore from '
|
|
3
|
-
import * as lNet from '
|
|
4
|
-
import * as lDb from '
|
|
5
|
-
import * as lFs from '
|
|
6
|
-
import * as lText from '
|
|
7
|
-
import * as lCrypto from '
|
|
8
|
-
import * as lKv from '
|
|
9
|
-
import * as lCaptcha from '
|
|
10
|
-
import * as lTime from '
|
|
11
|
-
import * as lScan from '
|
|
12
|
-
import * as lSql from '
|
|
13
|
-
import * as lConsistent from '
|
|
14
|
-
import * as lSsh from '
|
|
15
|
-
import * as lJwt from '
|
|
16
|
-
import * as lWs from '
|
|
17
|
-
import * as lS3 from '
|
|
18
|
-
import * as lZip from '
|
|
19
|
-
import * as lBuffer from '
|
|
20
|
-
import * as lLan from '
|
|
21
|
-
import * as
|
|
22
|
-
import * as
|
|
2
|
+
import * as lCore from '#lib/core.js';
|
|
3
|
+
import * as lNet from '#lib/net.js';
|
|
4
|
+
import * as lDb from '#lib/db.js';
|
|
5
|
+
import * as lFs from '#lib/fs.js';
|
|
6
|
+
import * as lText from '#lib/text.js';
|
|
7
|
+
import * as lCrypto from '#lib/crypto.js';
|
|
8
|
+
import * as lKv from '#lib/kv.js';
|
|
9
|
+
import * as lCaptcha from '#lib/captcha.js';
|
|
10
|
+
import * as lTime from '#lib/time.js';
|
|
11
|
+
import * as lScan from '#lib/scan.js';
|
|
12
|
+
import * as lSql from '#lib/sql.js';
|
|
13
|
+
import * as lConsistent from '#lib/consistent.js';
|
|
14
|
+
import * as lSsh from '#lib/ssh.js';
|
|
15
|
+
import * as lJwt from '#lib/jwt.js';
|
|
16
|
+
import * as lWs from '#lib/ws.js';
|
|
17
|
+
import * as lS3 from '#lib/s3.js';
|
|
18
|
+
import * as lZip from '#lib/zip.js';
|
|
19
|
+
import * as lBuffer from '#lib/buffer.js';
|
|
20
|
+
import * as lLan from '#lib/lan.js';
|
|
21
|
+
import * as lCron from '#lib/cron.js';
|
|
22
|
+
import * as sCtr from '#sys/ctr.js';
|
|
23
|
+
import * as kebab from '#index.js';
|
|
23
24
|
// --- mod ---
|
|
24
25
|
import mTest from '../mod/test.js';
|
|
25
26
|
import mTestData from '../mod/testdata.js';
|
|
@@ -115,6 +116,7 @@ export default class extends sCtr.Ctr {
|
|
|
115
116
|
'<br><br><b style="color: red;">In a production environment, please delete "mod/test.ts", "mod/testdata.ts" files.</b>',
|
|
116
117
|
`<br><a href="${this._config.const.urlBase}test/mod-test">Click to see an example of a Test model</a>`,
|
|
117
118
|
`<br><a href="${this._config.const.urlBase}test/mod-split">View "test/mod-split"</a>`,
|
|
119
|
+
`<br><a href="${this._config.const.urlBase}test/mod-insert">View "test/mod-insert"</a>`,
|
|
118
120
|
'<br><br><b>Library test:</b>',
|
|
119
121
|
'<br><br><b>Captcha:</b>',
|
|
120
122
|
`<br><br><a href="${this._config.const.urlBase}test/captcha-fastbuild">View "test/captcha-fastbuild"</a>`,
|
|
@@ -200,6 +202,8 @@ export default class extends sCtr.Ctr {
|
|
|
200
202
|
`<br><br><a href="${this._config.const.urlBase}test/buffer">View "test/buffer"</a>`,
|
|
201
203
|
'<br><br><b>Lan:</b>',
|
|
202
204
|
`<br><br><a href="${this._config.const.urlBase}test/lan">View "test/lan"</a>`,
|
|
205
|
+
'<br><br><b>Cron:</b>',
|
|
206
|
+
`<br><br><a href="${this._config.const.urlBase}test/cron">View "test/cron"</a>`,
|
|
203
207
|
];
|
|
204
208
|
echo.push('<br><br>' + this._getEnd());
|
|
205
209
|
return echo.join('');
|
|
@@ -264,6 +268,7 @@ Result:<pre id="result">Nothing.</pre>${this._getEnd()}`;
|
|
|
264
268
|
'arr': [['a', 'x', 'hehe'], [0, 'The arr param is incorrect.']],
|
|
265
269
|
'type': [{ 'type': { 'a': 1, 'b': '' } }, [0, 'The reg param is incorrect']],
|
|
266
270
|
'json': [{ 'type': { 'a': '1', 'b': [ { 'c': 1 } ] } }, [0, 'The type param is incorrect']],
|
|
271
|
+
'json2': [{ 'type': { 'a': '1', 'b': 0, 'c?': { 'd': '1' } } }, [0, 'The json2 param is incorrect']],
|
|
267
272
|
}</pre>`];
|
|
268
273
|
const post = [
|
|
269
274
|
{},
|
|
@@ -340,7 +345,27 @@ Result:<pre id="result">Nothing.</pre>${this._getEnd()}`;
|
|
|
340
345
|
'arr': 'hehe',
|
|
341
346
|
'type': { 'a': 0, 'b': 'ok' },
|
|
342
347
|
'json': { 'a': 'a', 'b': [{ 'c': 1 }] },
|
|
343
|
-
}
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
'he': 'ok',
|
|
351
|
+
'json2': {},
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
'he': 'ok',
|
|
355
|
+
'json2': { 'a': '1' },
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
'he': 'ok',
|
|
359
|
+
'json2': { 'a': '1', 'c': { 'd': '1' } },
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
'he': 'ok',
|
|
363
|
+
'json2': { 'a': '1', 'b': 1 },
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
'he': 'ok',
|
|
367
|
+
'json2': { 'a': '1', 'b': 1, 'c': { 'd': '1' } },
|
|
368
|
+
},
|
|
344
369
|
];
|
|
345
370
|
for (const item of post) {
|
|
346
371
|
if (item.type) {
|
|
@@ -349,6 +374,9 @@ Result:<pre id="result">Nothing.</pre>${this._getEnd()}`;
|
|
|
349
374
|
if (item.json) {
|
|
350
375
|
item.json = JSON.stringify(item.json);
|
|
351
376
|
}
|
|
377
|
+
if (item.json2) {
|
|
378
|
+
item.json2 = JSON.stringify(item.json2);
|
|
379
|
+
}
|
|
352
380
|
echo.push(`<input type="button" value="Post '${lText.queryStringify(item, false).replace(/"/g, '"')}'" onclick="post('${lText.queryStringify(item)}')"><br>`);
|
|
353
381
|
}
|
|
354
382
|
echo.push(`<input type="button" value="Post FormData (fd.append('he', 'ho'))" onclick="postFd()"><br>`);
|
|
@@ -396,6 +424,9 @@ function postFd() {
|
|
|
396
424
|
if (this._post['json']) {
|
|
397
425
|
this._post['json'] = lText.parseJson(this._post['json']);
|
|
398
426
|
}
|
|
427
|
+
if (this._post['json2']) {
|
|
428
|
+
this._post['json2'] = lText.parseJson(this._post['json2']);
|
|
429
|
+
}
|
|
399
430
|
if (this._post['num2'] !== undefined) {
|
|
400
431
|
this._post['num2'] = parseFloat(this._post['num2']);
|
|
401
432
|
}
|
|
@@ -406,7 +437,8 @@ function postFd() {
|
|
|
406
437
|
'reg': ['/^[A-CX-Z5-7]+$/', [0, 'The reg param is incorrect.']],
|
|
407
438
|
'arr': [['a', 'x', 'hehe'], [0, 'The arr param is incorrect.']],
|
|
408
439
|
'type': [{ 'type': { 'a': 1, 'b': '' } }, [0, 'The type param is incorrect']],
|
|
409
|
-
'json': [{ 'type': { 'a': '1', 'b': [{ 'c': 1 }] } }, [0, 'The
|
|
440
|
+
'json': [{ 'type': { 'a': '1', 'b': [{ 'c': 1 }] } }, [0, 'The json param is incorrect']],
|
|
441
|
+
'json2': [{ 'type': { 'a': '1', 'b': 0, 'c?': { 'd': '1' } } }, [0, 'The json2 param is incorrect']],
|
|
410
442
|
}, retur)) {
|
|
411
443
|
return retur;
|
|
412
444
|
}
|
|
@@ -752,6 +784,24 @@ CREATE TABLE \`m_test_data_0\` (
|
|
|
752
784
|
await testData.create();
|
|
753
785
|
return [1, { 'id': id, 'index': index }];
|
|
754
786
|
}
|
|
787
|
+
async modInsert() {
|
|
788
|
+
const echo = ['<b style="color: red;">In a production environment, please delete "mod/test.php" and "mod/testdata.php" files.</b>'];
|
|
789
|
+
const db = lDb.get(this);
|
|
790
|
+
const datas = [];
|
|
791
|
+
for (let i = 0; i < 20; ++i) {
|
|
792
|
+
datas.push([
|
|
793
|
+
lCore.rand(100000, 999999),
|
|
794
|
+
lCore.random(16, lCore.RANDOM_LUNS),
|
|
795
|
+
lTime.stamp(),
|
|
796
|
+
]);
|
|
797
|
+
}
|
|
798
|
+
const res = await mTestData.insert(db, ['test_id', 'content', 'time_add'], datas, {
|
|
799
|
+
'pre': this,
|
|
800
|
+
'index': '0',
|
|
801
|
+
});
|
|
802
|
+
echo.push('<br><br>Result: ' + JSON.stringify(res));
|
|
803
|
+
return echo.join('') + '<br><br>' + this._getEnd();
|
|
804
|
+
}
|
|
755
805
|
captchaFastbuild() {
|
|
756
806
|
return lCaptcha.get(400, 100).getBuffer();
|
|
757
807
|
}
|
|
@@ -940,7 +990,7 @@ lCore.checkType(o8, type2): ${lCore.checkType(o8, type2)}
|
|
|
940
990
|
<br><br>${this._getEnd()}`;
|
|
941
991
|
}
|
|
942
992
|
coreMuid() {
|
|
943
|
-
const ac = this._get['ac'] ? this._get['ac'] : '';
|
|
993
|
+
const ac = lText.isTruthy(this._get['ac']) ? this._get['ac'] : '';
|
|
944
994
|
const echo = [
|
|
945
995
|
'<a href="' + this._config.const.urlBase + 'test/core-muid">Default</a> | ' +
|
|
946
996
|
'<a href="' + this._config.const.urlBase + 'test/core-muid?ac=big">Big</a> | ' +
|
|
@@ -1087,11 +1137,11 @@ to: ${to}`
|
|
|
1087
1137
|
echo.push(`<pre>const key = 'testkeyatestkeyatestkeyatestkeya';
|
|
1088
1138
|
const text = lCrypto.aesEncrypt('Original text', key);
|
|
1089
1139
|
JSON.stringify(text);</pre>${JSON.stringify(text)}`);
|
|
1090
|
-
let orig = lCrypto.aesDecrypt(text
|
|
1091
|
-
echo.push(`<pre>let orig = lCrypto.aesDecrypt(text
|
|
1140
|
+
let orig = lCrypto.aesDecrypt(lText.logicalOr(text, ''), key);
|
|
1141
|
+
echo.push(`<pre>let orig = lCrypto.aesDecrypt(lText.logicalOr(text, ''), key);
|
|
1092
1142
|
JSON.stringify(orig);</pre>${JSON.stringify(orig)}`);
|
|
1093
|
-
orig = lCrypto.aesDecrypt(text
|
|
1094
|
-
echo.push(`<pre>orig = lCrypto.aesDecrypt(text
|
|
1143
|
+
orig = lCrypto.aesDecrypt(lText.logicalOr(text, ''), 'otherKey');
|
|
1144
|
+
echo.push(`<pre>orig = lCrypto.aesDecrypt(lText.logicalOr(text, ''), 'otherKey');
|
|
1095
1145
|
JSON.stringify(orig);</pre>${JSON.stringify(orig)}`);
|
|
1096
1146
|
// ----------
|
|
1097
1147
|
echo.push('<br><br><b>AES-256-CFB:</b>');
|
|
@@ -1100,11 +1150,11 @@ JSON.stringify(orig);</pre>${JSON.stringify(orig)}`);
|
|
|
1100
1150
|
echo.push(`<pre>const iv = 'iloveuiloveuilov';
|
|
1101
1151
|
text = lCrypto.aesEncrypt('Original text', key, iv);
|
|
1102
1152
|
JSON.stringify(text);</pre>${JSON.stringify(text)}`);
|
|
1103
|
-
orig = lCrypto.aesDecrypt(text
|
|
1104
|
-
echo.push(`<pre>orig = lCrypto.aesDecrypt(text
|
|
1153
|
+
orig = lCrypto.aesDecrypt(lText.logicalOr(text, ''), key, iv);
|
|
1154
|
+
echo.push(`<pre>orig = lCrypto.aesDecrypt(lText.logicalOr(text, ''), key, iv);
|
|
1105
1155
|
JSON.stringify(orig);</pre>${JSON.stringify(orig)}`);
|
|
1106
|
-
orig = lCrypto.aesDecrypt(text
|
|
1107
|
-
echo.push(`<pre>orig = lCrypto.aesDecrypt(text
|
|
1156
|
+
orig = lCrypto.aesDecrypt(lText.logicalOr(text, ''), key, 'otherIv');
|
|
1157
|
+
echo.push(`<pre>orig = lCrypto.aesDecrypt(lText.logicalOr(text, ''), key, 'otherIv');
|
|
1108
1158
|
orig ? 'true' : 'false';</pre>${orig ? 'true' : 'false'}`);
|
|
1109
1159
|
// ----------
|
|
1110
1160
|
echo.push('<br><br><b>AES-256-CBC:</b>');
|
|
@@ -1112,11 +1162,11 @@ orig ? 'true' : 'false';</pre>${orig ? 'true' : 'false'}`);
|
|
|
1112
1162
|
echo.push(`<pre>const key = 'testkeyatestkeyatestkeyatestkeya';
|
|
1113
1163
|
text = lCrypto.aesEncrypt('Original text', key, iv, lCrypto.AES_256_CBC);
|
|
1114
1164
|
JSON.stringify(text);</pre>${JSON.stringify(text)}`);
|
|
1115
|
-
orig = lCrypto.aesDecrypt(text
|
|
1116
|
-
echo.push(`<pre>orig = lCrypto.aesDecrypt(text
|
|
1165
|
+
orig = lCrypto.aesDecrypt(lText.logicalOr(text, ''), key, iv, lCrypto.AES_256_CBC);
|
|
1166
|
+
echo.push(`<pre>orig = lCrypto.aesDecrypt(lText.logicalOr(text, ''), key, iv, lCrypto.AES_256_CBC);
|
|
1117
1167
|
JSON.stringify(orig);</pre>${JSON.stringify(orig)}`);
|
|
1118
|
-
orig = lCrypto.aesDecrypt(text
|
|
1119
|
-
echo.push(`<pre>orig = lCrypto.aesDecrypt(text
|
|
1168
|
+
orig = lCrypto.aesDecrypt(lText.logicalOr(text, ''), key, 'otherIv', lCrypto.AES_256_CBC);
|
|
1169
|
+
echo.push(`<pre>orig = lCrypto.aesDecrypt(lText.logicalOr(text, ''), key, 'otherIv', lCrypto.AES_256_CBC);
|
|
1120
1170
|
JSON.stringify(orig);</pre>${JSON.stringify(orig)}`);
|
|
1121
1171
|
// --- gcm ---
|
|
1122
1172
|
echo.push('<br><br><b>AES-256-GCM (TEXT):</b>');
|
|
@@ -1124,15 +1174,15 @@ JSON.stringify(orig);</pre>${JSON.stringify(orig)}`);
|
|
|
1124
1174
|
echo.push(`<pre>const key = 'testkeyatestkeyatestkeyatestkeya';
|
|
1125
1175
|
text = lCrypto.gcmEncrypt('Original text', key);
|
|
1126
1176
|
JSON.stringify(text);</pre>${lText.htmlescape(JSON.stringify(text))}`);
|
|
1127
|
-
orig = lCrypto.gcmDecrypt(text
|
|
1128
|
-
echo.push(`<pre>orig = lCrypto.gcmDecrypt(text
|
|
1177
|
+
orig = lCrypto.gcmDecrypt(lText.logicalOr(text, ''), key);
|
|
1178
|
+
echo.push(`<pre>orig = lCrypto.gcmDecrypt(lText.logicalOr(text, ''), key);
|
|
1129
1179
|
JSON.stringify(orig);</pre>${JSON.stringify(orig)}`);
|
|
1130
1180
|
echo.push('<br><br><b>AES-256-GCM (BUFFER):</b>');
|
|
1131
1181
|
const buffer = lCrypto.gcmEncrypt(Buffer.from('Original text'), key, 'buffer');
|
|
1132
1182
|
echo.push(`<pre>const key = 'testkeyatestkeyatestkeyatestkeya';
|
|
1133
1183
|
const buffer = lCrypto.gcmEncrypt(Buffer.from('Original text'), key);
|
|
1134
1184
|
console.log(buffer);</pre>${buffer ? lText.htmlescape(lText.stringifyBuffer(buffer)) : 'false'}`);
|
|
1135
|
-
const origBuffer = lCrypto.gcmDecrypt(buffer
|
|
1185
|
+
const origBuffer = lCrypto.gcmDecrypt(lText.isTruthy(buffer) ? buffer : Buffer.from(''), key, 'buffer');
|
|
1136
1186
|
echo.push(`<pre>const origBuffer = lCrypto.gcmDecrypt(buffer || Buffer.from(''), key, 'buffer');
|
|
1137
1187
|
console.log(origBuffer);</pre>${origBuffer ? lText.htmlescape(lText.stringifyBuffer(origBuffer)) : 'false'}
|
|
1138
1188
|
<pre>JSON.stringify(origBuffer ? origBuffer.toString() : false);</pre>${JSON.stringify(origBuffer ? origBuffer.toString() : false)}`);
|
|
@@ -1388,7 +1438,7 @@ echo[echo.length - 1] = echo[echo.length - 1].slice(0, -4);</pre>`);
|
|
|
1388
1438
|
echo.push("<pre>JSON.stringify(await kv.exists(['test', 'heheda']));</pre>" + JSON.stringify(await kv.exists(['test', 'heheda'])));
|
|
1389
1439
|
echo.push("<pre>JSON.stringify(await kv.mGet(['test', 'heheda']));</pre>" + JSON.stringify(await kv.mGet(['test', 'heheda'])));
|
|
1390
1440
|
echo.push("<pre>JSON.stringify(await kv.get('test'));</pre>" + JSON.stringify(await kv.get('test')));
|
|
1391
|
-
echo.push("<pre>JSON.stringify(await kv.set('test', $value ? $value : 'ok'));</pre>" + JSON.stringify(await kv.set('test', value ? value : 'ok')));
|
|
1441
|
+
echo.push("<pre>JSON.stringify(await kv.set('test', $value ? $value : 'ok'));</pre>" + JSON.stringify(await kv.set('test', lText.isTruthy(value) ? value : 'ok')));
|
|
1392
1442
|
echo.push("<pre>JSON.stringify(await kv.get('test'));</pre>" + JSON.stringify(await kv.get('test')));
|
|
1393
1443
|
}
|
|
1394
1444
|
return '<a href="' + this._config.const.urlBase + 'test/kv">Default</a> | ' +
|
|
@@ -1944,8 +1994,8 @@ function confirm() {
|
|
|
1944
1994
|
await this._startSession(link, false, { 'ttl': 60 });
|
|
1945
1995
|
echo.push(`await this._startSession(link, false, {'ttl': 60});
|
|
1946
1996
|
JSON.stringify(this._session);</pre>` + lText.htmlescape(JSON.stringify(this._session)));
|
|
1947
|
-
this._session['value'] =
|
|
1948
|
-
echo.push(`<pre>this._session['value'] = '${
|
|
1997
|
+
this._session['value'] = lText.logicalOr(this._get['value'], 'ok');
|
|
1998
|
+
echo.push(`<pre>this._session['value'] = '${lText.logicalOr(this._get['value'], 'ok')}';
|
|
1949
1999
|
JSON.stringify(this._session);</pre>` + lText.htmlescape(JSON.stringify(this._session)));
|
|
1950
2000
|
return '<a href="' + this._config.const.urlBase + 'test/session?s=' + this._get['s'] + '">Default</a> | ' +
|
|
1951
2001
|
'<a href="' + this._config.const.urlBase + 'test/session?s=' + this._get['s'] + '&value=aaa">Set "aaa"</a> | ' +
|
|
@@ -2888,6 +2938,39 @@ rtn.push(reader.readBCDString());</pre>${JSON.stringify(rtn)}`);
|
|
|
2888
2938
|
echo.push(`<pre>await lLan.scan();</pre>` + JSON.stringify(r2));
|
|
2889
2939
|
return echo.join('') + '<br><br>' + this._getEnd();
|
|
2890
2940
|
}
|
|
2941
|
+
async cron() {
|
|
2942
|
+
// --- 注意,这个只是演示,你实际需要在 ind 目录中创建计划任务 ---
|
|
2943
|
+
// --- 并用 --ind 单线程模式运行 ---
|
|
2944
|
+
const echo = [];
|
|
2945
|
+
let rtn = await lCron.regular({
|
|
2946
|
+
'name': 'test',
|
|
2947
|
+
'date': {
|
|
2948
|
+
'month': -1,
|
|
2949
|
+
'day': -1,
|
|
2950
|
+
'hour': -1,
|
|
2951
|
+
'minute': -1,
|
|
2952
|
+
'week': -1,
|
|
2953
|
+
},
|
|
2954
|
+
'callback': (date) => {
|
|
2955
|
+
lCore.debug(`[${date}] test task run`);
|
|
2956
|
+
},
|
|
2957
|
+
});
|
|
2958
|
+
echo.push(`<pre>await lCron.regular({
|
|
2959
|
+
'name': 'test',
|
|
2960
|
+
'date': {
|
|
2961
|
+
'month': -1,
|
|
2962
|
+
'day': -1,
|
|
2963
|
+
'hour': -1,
|
|
2964
|
+
'minute': -1,
|
|
2965
|
+
'week': -1,
|
|
2966
|
+
},
|
|
2967
|
+
'callback': (date) => {
|
|
2968
|
+
lCore.debug(\`[\${date}] test task run\`);
|
|
2969
|
+
},
|
|
2970
|
+
});</pre>${JSON.stringify(rtn)}
|
|
2971
|
+
<pre>${JSON.stringify(lCron.getRegulars(), null, 4)}</pre>`);
|
|
2972
|
+
return echo.join('') + '<br>' + this._getEnd();
|
|
2973
|
+
}
|
|
2891
2974
|
/**
|
|
2892
2975
|
* --- END ---
|
|
2893
2976
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import sMod from '
|
|
2
|
-
import * as types from '
|
|
1
|
+
import sMod from '#sys/mod.js';
|
|
2
|
+
import * as types from '#types/index.js';
|
|
3
3
|
export default class extends sMod {
|
|
4
4
|
protected static _$table: string;
|
|
5
5
|
protected static _$primary: string;
|
package/www/example/mod/test.js
CHANGED
package/www/example/ws/mproxy.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as sCtr from '
|
|
2
|
-
import * as lWs from '
|
|
3
|
-
import * as lCore from '
|
|
1
|
+
import * as sCtr from '#sys/ctr.js';
|
|
2
|
+
import * as lWs from '#lib/ws.js';
|
|
3
|
+
import * as lCore from '#lib/core.js';
|
|
4
4
|
export default class extends sCtr.Ctr {
|
|
5
5
|
async onLoad() {
|
|
6
6
|
lCore.debug('WebSocket mproxy test onLoad.');
|
package/www/example/ws/rproxy.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as sCtr from '
|
|
2
|
-
import * as lCore from '
|
|
3
|
-
import * as lWs from '
|
|
1
|
+
import * as sCtr from '#sys/ctr.js';
|
|
2
|
+
import * as lCore from '#lib/core.js';
|
|
3
|
+
import * as lWs from '#lib/ws.js';
|
|
4
4
|
export default class extends sCtr.Ctr {
|
|
5
5
|
async onLoad() {
|
|
6
6
|
lCore.debug('WebSocket rproxy test onLoad.');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as sCtr from '
|
|
2
|
-
import * as lWs from '
|
|
3
|
-
import * as lCore from '
|
|
1
|
+
import * as sCtr from '#sys/ctr.js';
|
|
2
|
+
import * as lWs from '#lib/ws.js';
|
|
3
|
+
import * as lCore from '#lib/core.js';
|
|
4
4
|
export default class extends sCtr.Ctr {
|
|
5
5
|
async onLoad() {
|
|
6
6
|
lCore.debug('WebSocket rsocket test onLoad.');
|
package/www/example/ws/test.d.ts
CHANGED
package/www/example/ws/test.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as sCtr from '
|
|
2
|
-
import * as lCrypto from '
|
|
3
|
-
import * as lCore from '
|
|
1
|
+
import * as sCtr from '#sys/ctr.js';
|
|
2
|
+
import * as lCrypto from '#lib/crypto.js';
|
|
3
|
+
import * as lCore from '#lib/core.js';
|
|
4
4
|
export default class extends sCtr.Ctr {
|
|
5
5
|
constructor() {
|
|
6
6
|
super(...arguments);
|