dolphindb 2.0.943 → 2.0.944

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 CHANGED
@@ -508,6 +508,8 @@ export declare class DDB {
508
508
  python: boolean;
509
509
  /** 是否为流数据连接,非流数据这个字段恒为 null Whether it is a streaming data connection, this field is always null for non-streaming data */
510
510
  streaming: StreamingData;
511
+ /** 是否打印每个 rpc 的信息用于调试 */
512
+ verbose: boolean;
511
513
  print_message_buffer: boolean;
512
514
  print_object_buffer: boolean;
513
515
  print_message: boolean;
@@ -530,6 +532,7 @@ export declare class DDB {
530
532
  - password?: DolphinDB 登录密码,默认 `'123456'` DolphinDB password, default `'123456'`
531
533
  - python?: 设置 python session flag,默认 `false` set python session flag, default `false`
532
534
  - streaming?: 设置该选项后,该 WebSocket 连接只用于流数据 When this option is set, the WebSocket connection is only used for streaming data
535
+ - verbose?: 是否打印每个 rpc 的信息用于调试
533
536
 
534
537
  @example
535
538
  let ddb = new DDB('ws://127.0.0.1:8848')
@@ -548,6 +551,7 @@ export declare class DDB {
548
551
  password?: string;
549
552
  python?: boolean;
550
553
  streaming?: StreamingParams;
554
+ verbose?: boolean;
551
555
  });
552
556
  private on_message;
553
557
  private on_error;
package/browser.js CHANGED
@@ -2154,6 +2154,8 @@ export class DdbConnectionError extends Error {
2154
2154
  ddb;
2155
2155
  constructor(ddb, error) {
2156
2156
  super(error?.message || `${ddb.url} ${t('连接出错了,可能由于网络原因连接已被关闭,或服务器断开连接')}`, { cause: error });
2157
+ if (error)
2158
+ this.cause = error;
2157
2159
  this.ddb = ddb;
2158
2160
  }
2159
2161
  }
@@ -2194,6 +2196,8 @@ export class DDB {
2194
2196
  python = false;
2195
2197
  /** 是否为流数据连接,非流数据这个字段恒为 null Whether it is a streaming data connection, this field is always null for non-streaming data */
2196
2198
  streaming = null;
2199
+ /** 是否打印每个 rpc 的信息用于调试 */
2200
+ verbose = false;
2197
2201
  // --- 内部选项, 状态
2198
2202
  print_message_buffer = false;
2199
2203
  print_object_buffer = false;
@@ -2219,6 +2223,7 @@ export class DDB {
2219
2223
  - password?: DolphinDB 登录密码,默认 `'123456'` DolphinDB password, default `'123456'`
2220
2224
  - python?: 设置 python session flag,默认 `false` set python session flag, default `false`
2221
2225
  - streaming?: 设置该选项后,该 WebSocket 连接只用于流数据 When this option is set, the WebSocket connection is only used for streaming data
2226
+ - verbose?: 是否打印每个 rpc 的信息用于调试
2222
2227
 
2223
2228
  @example
2224
2229
  let ddb = new DDB('ws://127.0.0.1:8848')
@@ -2232,14 +2237,20 @@ export class DDB {
2232
2237
  })
2233
2238
  */
2234
2239
  constructor(url, options = {}) {
2235
- if (!url) {
2236
- const _url = new URL(location.href);
2237
- const dev = _url.pathname.endsWith('/console/');
2238
- const hostname = _url.searchParams.get('hostname') || (dev ? '127.0.0.1' : location.hostname);
2239
- const port = _url.searchParams.get('port') || (dev ? '8848' : location.port);
2240
- url = `${dev ? (_url.searchParams.get('tls') === '1' ? 'wss' : 'ws') : (location.protocol === 'https:' ? 'wss' : 'ws')}://${hostname}${port ? `:${port}` : ''}/`;
2240
+ const _url = new URL(location.href);
2241
+ const { searchParams, pathname } = _url;
2242
+ if (url)
2243
+ this.url = url;
2244
+ else {
2245
+ const dev = pathname.endsWith('/console/');
2246
+ const hostname = searchParams.get('hostname') || (dev ? '127.0.0.1' : location.hostname);
2247
+ const port = searchParams.get('port') || (dev ? '8848' : location.port);
2248
+ url = `${dev ? (searchParams.get('tls') === '1' ? 'wss' : 'ws') : (location.protocol === 'https:' ? 'wss' : 'ws')}://${hostname}${port ? `:${port}` : ''}/`;
2241
2249
  }
2242
- this.url = url;
2250
+ this.verbose = options.verbose === undefined ?
2251
+ searchParams.get('verbose') === '1'
2252
+ :
2253
+ options.verbose;
2243
2254
  if (options.autologin !== undefined)
2244
2255
  this.autologin = options.autologin;
2245
2256
  if (options.username !== undefined)
@@ -2460,19 +2471,28 @@ export class DDB {
2460
2471
  const command = this.enc.encode((() => {
2461
2472
  switch (type) {
2462
2473
  case 'function':
2474
+ if (this.verbose)
2475
+ console.log(func + args.map(arg => arg.toString()).join(', ').bracket());
2463
2476
  return 'function\n' +
2464
2477
  `${func}\n` +
2465
2478
  `${args.length}\n` +
2466
2479
  `${Number(DDB.le_client)}\n`;
2467
2480
  case 'script':
2481
+ if (this.verbose)
2482
+ console.log(script);
2468
2483
  return 'script\n' +
2469
2484
  script;
2470
2485
  case 'variable':
2486
+ if (this.verbose)
2487
+ for (let i = 0; i < vars.length; i++)
2488
+ console.log(`${vars[i]} = ${args[i].toString()}`);
2471
2489
  return 'variable\n' +
2472
2490
  `${vars.join(',')}\n` +
2473
2491
  `${vars.length}\n` +
2474
2492
  `${Number(DDB.le_client)}\n`;
2475
2493
  case 'connect':
2494
+ if (this.verbose)
2495
+ console.log('connect()');
2476
2496
  return 'connect\n';
2477
2497
  }
2478
2498
  })());