dolphindb 2.0.969 → 2.0.971
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/browser.js +50 -44
- package/browser.js.map +1 -1
- package/index.js +50 -44
- package/index.js.map +1 -1
- package/language.js +2 -0
- package/language.js.map +1 -1
- package/package.json +8 -8
- package/test.js.map +1 -1
package/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import DayjsCustomParseFormat from 'dayjs/plugin/customParseFormat.js';
|
|
|
4
4
|
dayjs.extend(DayjsCustomParseFormat);
|
|
5
5
|
import ipaddrjs from 'ipaddr.js';
|
|
6
6
|
const { fromByteArray: buf2ipaddr } = ipaddrjs;
|
|
7
|
-
import { concat, assert, inspect, typed_array_to_buffer, connect_websocket, WebSocket, Lock } from 'xshell';
|
|
7
|
+
import { concat, assert, inspect, typed_array_to_buffer, connect_websocket, WebSocket, Lock, genid } from 'xshell';
|
|
8
8
|
import { t } from './i18n/index.js';
|
|
9
9
|
import { DdbDecimal128Serializor } from './data-types/decimal-128.js';
|
|
10
10
|
import { BigInt128Array } from './shared/bigint-128-array.js';
|
|
@@ -2376,8 +2376,53 @@ class DDB {
|
|
|
2376
2376
|
// 独占资源后先检查状态
|
|
2377
2377
|
if (this.errored || !this.connected)
|
|
2378
2378
|
throw this.error || new DdbConnectionError(this);
|
|
2379
|
+
const args = DdbObj.to_ddbobjs(_args);
|
|
2380
|
+
const id = genid() % 1000;
|
|
2381
|
+
const rpc_id = ` (id = ${id})`;
|
|
2382
|
+
const command = this.enc.encode((() => {
|
|
2383
|
+
switch (type) {
|
|
2384
|
+
case 'function':
|
|
2385
|
+
if (this.verbose)
|
|
2386
|
+
console.log(func + inspect(args, { colors: false }) + rpc_id);
|
|
2387
|
+
return 'function\n' +
|
|
2388
|
+
`${func}\n` +
|
|
2389
|
+
`${args.length}\n` +
|
|
2390
|
+
`${Number(DDB.le_client)}\n`;
|
|
2391
|
+
case 'script':
|
|
2392
|
+
if (this.verbose)
|
|
2393
|
+
console.log(script + rpc_id);
|
|
2394
|
+
return 'script\n' +
|
|
2395
|
+
script;
|
|
2396
|
+
case 'variable':
|
|
2397
|
+
if (this.verbose)
|
|
2398
|
+
for (let i = 0; i < vars.length; i++)
|
|
2399
|
+
console.log(`${vars[i]} = ${inspect(args[i], { colors: false })}`);
|
|
2400
|
+
return 'variable\n' +
|
|
2401
|
+
`${vars.join(',')}\n` +
|
|
2402
|
+
`${vars.length}\n` +
|
|
2403
|
+
`${Number(DDB.le_client)}\n`;
|
|
2404
|
+
case 'connect':
|
|
2405
|
+
if (this.verbose)
|
|
2406
|
+
console.log('connect()' +
|
|
2407
|
+
(this.autologin ?
|
|
2408
|
+
'\n' +
|
|
2409
|
+
`login(${this.username.quote()}, ${this.password.quote()})`
|
|
2410
|
+
:
|
|
2411
|
+
'') +
|
|
2412
|
+
rpc_id);
|
|
2413
|
+
return 'connect\n' +
|
|
2414
|
+
// 详见 InterProcessIO.cpp#APISocketConsole::parseScript 中的
|
|
2415
|
+
// Util::startWith "connect"
|
|
2416
|
+
(this.autologin ?
|
|
2417
|
+
'login\n' +
|
|
2418
|
+
this.username + '\n' +
|
|
2419
|
+
this.password /* encrypted (可选参数) + '\n' + 'false' */
|
|
2420
|
+
:
|
|
2421
|
+
'');
|
|
2422
|
+
}
|
|
2423
|
+
})());
|
|
2379
2424
|
// 使用资源发送请求并等待请求完成
|
|
2380
|
-
|
|
2425
|
+
const result = await new Promise((resolve, reject) => {
|
|
2381
2426
|
this.on_error = () => {
|
|
2382
2427
|
// 这里一定有了 this.error, 不需要再 || new DdbConnectionError(this)
|
|
2383
2428
|
reject(this.error);
|
|
@@ -2410,54 +2455,15 @@ class DDB {
|
|
|
2410
2455
|
reject(error);
|
|
2411
2456
|
}
|
|
2412
2457
|
};
|
|
2413
|
-
const args = DdbObj.to_ddbobjs(_args);
|
|
2414
|
-
const command = this.enc.encode((() => {
|
|
2415
|
-
switch (type) {
|
|
2416
|
-
case 'function':
|
|
2417
|
-
if (this.verbose)
|
|
2418
|
-
console.log(func + inspect(args, { colors: false }));
|
|
2419
|
-
return 'function\n' +
|
|
2420
|
-
`${func}\n` +
|
|
2421
|
-
`${args.length}\n` +
|
|
2422
|
-
`${Number(DDB.le_client)}\n`;
|
|
2423
|
-
case 'script':
|
|
2424
|
-
if (this.verbose)
|
|
2425
|
-
console.log(script);
|
|
2426
|
-
return 'script\n' +
|
|
2427
|
-
script;
|
|
2428
|
-
case 'variable':
|
|
2429
|
-
if (this.verbose)
|
|
2430
|
-
for (let i = 0; i < vars.length; i++)
|
|
2431
|
-
console.log(`${vars[i]} = ${inspect(args[i], { colors: false })}`);
|
|
2432
|
-
return 'variable\n' +
|
|
2433
|
-
`${vars.join(',')}\n` +
|
|
2434
|
-
`${vars.length}\n` +
|
|
2435
|
-
`${Number(DDB.le_client)}\n`;
|
|
2436
|
-
case 'connect':
|
|
2437
|
-
if (this.verbose)
|
|
2438
|
-
console.log('connect()' +
|
|
2439
|
-
(this.autologin ?
|
|
2440
|
-
'\n' +
|
|
2441
|
-
`login(${this.username.quote()}, ${this.password.quote()})`
|
|
2442
|
-
:
|
|
2443
|
-
''));
|
|
2444
|
-
return 'connect\n' +
|
|
2445
|
-
// 详见 InterProcessIO.cpp#APISocketConsole::parseScript 中的
|
|
2446
|
-
// Util::startWith "connect"
|
|
2447
|
-
(this.autologin ?
|
|
2448
|
-
'login\n' +
|
|
2449
|
-
this.username + '\n' +
|
|
2450
|
-
this.password /* encrypted (可选参数) + '\n' + 'false' */
|
|
2451
|
-
:
|
|
2452
|
-
'');
|
|
2453
|
-
}
|
|
2454
|
-
})());
|
|
2455
2458
|
websocket.send(concat([
|
|
2456
2459
|
this.enc.encode(`API2 ${this.sid} ${command.length} / ${this.get_rpc_options({ urgent })}\n`),
|
|
2457
2460
|
command,
|
|
2458
2461
|
...args.map(arg => arg.pack())
|
|
2459
2462
|
]));
|
|
2460
2463
|
});
|
|
2464
|
+
if (this.verbose)
|
|
2465
|
+
console.log(result, rpc_id);
|
|
2466
|
+
return result;
|
|
2461
2467
|
});
|
|
2462
2468
|
}
|
|
2463
2469
|
/** eval script through websocket (script command)
|