dolphindb 2.0.929 → 2.0.931
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.d.ts +7 -8
- package/browser.js +15 -27
- package/browser.js.map +1 -1
- package/index.d.ts +7 -8
- package/index.js +15 -27
- package/index.js.map +1 -1
- package/package.json +4 -8
package/browser.d.ts
CHANGED
|
@@ -507,9 +507,9 @@ export declare class DDB {
|
|
|
507
507
|
pnode_run_defined: boolean;
|
|
508
508
|
/** DdbMessage listeners */
|
|
509
509
|
listeners: DdbMessageListener[];
|
|
510
|
-
pconnect:
|
|
511
|
-
ppnoderun:
|
|
512
|
-
presult:
|
|
510
|
+
pconnect: import("xshell/utils.browser.js").Deferred<void>;
|
|
511
|
+
ppnoderun: import("xshell/utils.browser.js").Deferred<void>;
|
|
512
|
+
presult: import("xshell/utils.browser.js").Deferred<DdbObj<DdbValue>>;
|
|
513
513
|
get connected(): boolean;
|
|
514
514
|
/**
|
|
515
515
|
使用 WebSocket URL 初始化连接到 DolphinDB 的实例(不建立实际的网络连接)
|
|
@@ -579,9 +579,8 @@ export declare class DDB {
|
|
|
579
579
|
- vars?: type === 'variable' 时必传,variable 指令中待上传的变量名
|
|
580
580
|
- listener?: 处理本次 rpc 期间的消息 (DdbMessage)
|
|
581
581
|
- parse_object?: 在本次 rpc 期间设置 parse_object, 结束后恢复原有
|
|
582
|
-
为 false 时返回的 DdbObj 仅含有 buffer 和 le,不做解析,以便后续转发、序列化
|
|
583
|
-
|
|
584
|
-
rpc<T extends DdbObj = DdbObj>(type: DdbRpcType, options: DdbRpcOptions): Promise<T>;
|
|
582
|
+
为 false 时返回的 DdbObj 仅含有 buffer 和 le,不做解析,以便后续转发、序列化 */
|
|
583
|
+
rpc<TResult extends DdbObj = DdbObj>(type: DdbRpcType, options: DdbRpcOptions): Promise<TResult>;
|
|
585
584
|
/** eval script through websocket (script command)
|
|
586
585
|
- script?: 执行的脚本 Script to execute
|
|
587
586
|
- options?: 执行选项 execution options
|
|
@@ -622,7 +621,7 @@ export declare class DDB {
|
|
|
622
621
|
When it is false, the returned DdbObj only contains buffer and le without parsing,
|
|
623
622
|
so as to facilitate subsequent forwarding and serialization
|
|
624
623
|
*/
|
|
625
|
-
call<
|
|
624
|
+
call<TResult extends DdbObj>(func: string, args?: (DdbObj | string | boolean)[], { urgent, node, nodes, func_type, add_node_alias, listener, parse_object, }?: {
|
|
626
625
|
urgent?: boolean;
|
|
627
626
|
node?: string;
|
|
628
627
|
nodes?: string[];
|
|
@@ -630,7 +629,7 @@ export declare class DDB {
|
|
|
630
629
|
add_node_alias?: boolean;
|
|
631
630
|
listener?: DdbMessageListener;
|
|
632
631
|
parse_object?: boolean;
|
|
633
|
-
}): Promise<
|
|
632
|
+
}): Promise<TResult>;
|
|
634
633
|
/** upload variable through websocket (variable command) */
|
|
635
634
|
upload(
|
|
636
635
|
/** 上传的变量名 Uploaded variables' name */
|
package/browser.js
CHANGED
|
@@ -5,7 +5,7 @@ import ipaddrjs from 'ipaddr.js';
|
|
|
5
5
|
const { fromByteArray: buf2ipaddr } = ipaddrjs;
|
|
6
6
|
import 'xshell/prototype.browser.js';
|
|
7
7
|
import { blue, cyan, green, grey, magenta } from 'xshell/chalk.browser.js';
|
|
8
|
-
import { concat, assert } from 'xshell/utils.browser.js';
|
|
8
|
+
import { concat, assert, defer } from 'xshell/utils.browser.js';
|
|
9
9
|
import { connect_websocket, WebSocketConnectionError } from 'xshell/net.browser.js';
|
|
10
10
|
import { t } from './i18n/index.js';
|
|
11
11
|
export var DdbForm;
|
|
@@ -2177,9 +2177,9 @@ export class DDB {
|
|
|
2177
2177
|
pnode_run_defined = false;
|
|
2178
2178
|
/** DdbMessage listeners */
|
|
2179
2179
|
listeners = [];
|
|
2180
|
-
pconnect =
|
|
2181
|
-
ppnoderun =
|
|
2182
|
-
presult =
|
|
2180
|
+
pconnect = defer(null);
|
|
2181
|
+
ppnoderun = defer(null);
|
|
2182
|
+
presult = defer(null);
|
|
2183
2183
|
get connected() {
|
|
2184
2184
|
return this.websocket?.readyState === WebSocket.OPEN;
|
|
2185
2185
|
}
|
|
@@ -2236,17 +2236,14 @@ export class DDB {
|
|
|
2236
2236
|
if (this.connected)
|
|
2237
2237
|
return;
|
|
2238
2238
|
const ptail = this.pconnect;
|
|
2239
|
-
|
|
2240
|
-
this.pconnect = new Promise((_resolve, _reject) => {
|
|
2241
|
-
resolve = _resolve;
|
|
2242
|
-
});
|
|
2239
|
+
const pconnect = this.pconnect = defer();
|
|
2243
2240
|
await ptail;
|
|
2244
2241
|
try {
|
|
2245
2242
|
if (!this.connected) {
|
|
2246
2243
|
this.on_message = buffer => {
|
|
2247
2244
|
assert(false, t('这是在调用 this.rpc 之前默认的 on_message, 不应该被调用到,除非建立连接后 server 先推送了 message'));
|
|
2248
2245
|
};
|
|
2249
|
-
this.presult =
|
|
2246
|
+
this.presult = defer(null);
|
|
2250
2247
|
this.pnode_run_defined = false;
|
|
2251
2248
|
try {
|
|
2252
2249
|
this.websocket = await connect_websocket(this.url, {
|
|
@@ -2277,7 +2274,7 @@ export class DDB {
|
|
|
2277
2274
|
}
|
|
2278
2275
|
}
|
|
2279
2276
|
finally {
|
|
2280
|
-
resolve();
|
|
2277
|
+
pconnect.resolve();
|
|
2281
2278
|
}
|
|
2282
2279
|
}
|
|
2283
2280
|
get_rpc_options({ urgent = false, secondary = false, async: _async = false, pickle = false, clear = false, api = false, compress = false, cancellable = true, priority = urgent ? 8 : 4, parallelism = 8, root_id = '', limit, } = {}) {
|
|
@@ -2324,8 +2321,7 @@ export class DDB {
|
|
|
2324
2321
|
- vars?: type === 'variable' 时必传,variable 指令中待上传的变量名
|
|
2325
2322
|
- listener?: 处理本次 rpc 期间的消息 (DdbMessage)
|
|
2326
2323
|
- parse_object?: 在本次 rpc 期间设置 parse_object, 结束后恢复原有
|
|
2327
|
-
为 false 时返回的 DdbObj 仅含有 buffer 和 le,不做解析,以便后续转发、序列化
|
|
2328
|
-
*/
|
|
2324
|
+
为 false 时返回的 DdbObj 仅含有 buffer 和 le,不做解析,以便后续转发、序列化 */
|
|
2329
2325
|
async rpc(type, options) {
|
|
2330
2326
|
if (!this.websocket)
|
|
2331
2327
|
await this.connect();
|
|
@@ -2336,10 +2332,7 @@ export class DDB {
|
|
|
2336
2332
|
if (func === 'pnode_run' && !this.pnode_run_defined) {
|
|
2337
2333
|
// 保证并发调用 rpc 时只定义一次 pnode_run
|
|
2338
2334
|
const ptail = this.ppnoderun;
|
|
2339
|
-
|
|
2340
|
-
this.ppnoderun = new Promise((_resolve, _reject) => {
|
|
2341
|
-
resolve = _resolve;
|
|
2342
|
-
});
|
|
2335
|
+
const ppnoderun = this.ppnoderun = defer();
|
|
2343
2336
|
await ptail;
|
|
2344
2337
|
try {
|
|
2345
2338
|
if (!this.pnode_run_defined)
|
|
@@ -2380,7 +2373,7 @@ export class DDB {
|
|
|
2380
2373
|
'}\n', { urgent: true });
|
|
2381
2374
|
}
|
|
2382
2375
|
finally {
|
|
2383
|
-
resolve();
|
|
2376
|
+
ppnoderun.resolve();
|
|
2384
2377
|
}
|
|
2385
2378
|
}
|
|
2386
2379
|
// this 上的当前配置需要在 message 到达后使用,先保存起来
|
|
@@ -2392,18 +2385,13 @@ export class DDB {
|
|
|
2392
2385
|
// 1. 并发多个请求只返回第一个结果(阻塞,需后续请求疏通)
|
|
2393
2386
|
// 2. windows 下 ddb server 返回多个相同的结果
|
|
2394
2387
|
const ptail = this.presult;
|
|
2395
|
-
|
|
2396
|
-
let reject;
|
|
2397
|
-
const presult = this.presult = new Promise((_resolve, _reject) => {
|
|
2398
|
-
resolve = _resolve;
|
|
2399
|
-
reject = _reject;
|
|
2400
|
-
});
|
|
2388
|
+
const presult = this.presult = defer();
|
|
2401
2389
|
try {
|
|
2402
2390
|
await ptail;
|
|
2403
2391
|
}
|
|
2404
2392
|
catch { }
|
|
2405
2393
|
// 临界区结束,只有一个 rpc 函数调用运行到这里,可以独占 this.on_message 然后写 WebSocket
|
|
2406
|
-
this.on_message =
|
|
2394
|
+
this.on_message = buffer => {
|
|
2407
2395
|
try {
|
|
2408
2396
|
const buf = new Uint8Array(buffer);
|
|
2409
2397
|
if (this.print_message_buffer)
|
|
@@ -2419,15 +2407,15 @@ export class DDB {
|
|
|
2419
2407
|
console.log(data);
|
|
2420
2408
|
return;
|
|
2421
2409
|
case 'object':
|
|
2422
|
-
resolve(data);
|
|
2410
|
+
presult.resolve(data);
|
|
2423
2411
|
return;
|
|
2424
2412
|
case 'error':
|
|
2425
|
-
reject(data);
|
|
2413
|
+
presult.reject(data);
|
|
2426
2414
|
return;
|
|
2427
2415
|
}
|
|
2428
2416
|
}
|
|
2429
2417
|
catch (error) {
|
|
2430
|
-
reject(error);
|
|
2418
|
+
presult.reject(error);
|
|
2431
2419
|
}
|
|
2432
2420
|
};
|
|
2433
2421
|
args = DdbObj.to_ddbobjs(args);
|