dolphindb 3.0.209 → 3.0.210

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 CHANGED
@@ -607,6 +607,11 @@ export interface StreamingMessage <TRows = any> extends StreamingParams {
607
607
  }
608
608
  ```
609
609
 
610
+ To close streaming data subscription, use the following two methods to disconnect:
611
+ - Automatically disconnect by closing the browser page
612
+ - Manually disconnect by calling `sddb.disconnect()`
613
+
614
+
610
615
  ## Development Method
611
616
 
612
617
  ```shell
package/README.zh.md CHANGED
@@ -589,6 +589,10 @@ export interface StreamingMessage <TRows = any> extends StreamingParams {
589
589
  }
590
590
  ```
591
591
 
592
+ 关闭流数据订阅使用下面两种断开连接的方法
593
+ - 关闭浏览器页面自动断开连接
594
+ - 调用 `sddb.disconnect()` 手动断开连接
595
+
592
596
 
593
597
  ### 开发方法
594
598
 
package/browser.d.ts CHANGED
@@ -281,6 +281,7 @@ export interface DdbMatrixData {
281
281
  }
282
282
  export type IotVectorItemValue = [number | string | bigint | boolean][];
283
283
  export type DdbIotAnyVector = DdbObj<IotVectorItemValue>;
284
+ export type JsSimpleType = DdbObj | string | boolean | null | undefined;
284
285
  /** 可以表示所有 DolphinDB 数据库中的数据类型 Can represent data types in all DolphinDB databases */
285
286
  export declare class DdbObj<TValue extends DdbValue = DdbValue> {
286
287
  static dec: TextDecoder;
@@ -357,10 +358,10 @@ export declare class DdbObj<TValue extends DdbValue = DdbValue> {
357
358
  }, limit?: number): TensorData;
358
359
  toString(options?: InspectOptions): string;
359
360
  inspect_type(): string;
360
- /** 自动转换 js string, boolean 为 DdbObj */
361
- static to_ddbobj(value: DdbObj | string | boolean): DdbObj;
361
+ /** 自动转换 JsSimpleType 为 DdbObj */
362
+ static to_ddbobj(value: JsSimpleType): DdbObj;
362
363
  /** 转换 js 数组为 DdbObj[] */
363
- static to_ddbobjs(values: (DdbObj | string | boolean)[]): DdbObj<DdbValue>[];
364
+ static to_ddbobjs(values: JsSimpleType[]): DdbObj<DdbValue>[];
364
365
  /** @deprecated 用 data() */
365
366
  to_cols(): {
366
367
  title: string;
@@ -421,6 +422,7 @@ export interface ConvertOptions {
421
422
  export declare function convert(type: DdbType, value: DdbValue, le: boolean, { blob, char, timestamp }?: ConvertOptions): string | number | bigint | boolean | number[] | Uint8Array<ArrayBufferLike> | DdbFunctionDefValue | DdbDurationValue | DdbDecimal32Value | DdbDecimal64Value | Int8Array<ArrayBufferLike> | Int16Array<ArrayBufferLike> | Int32Array<ArrayBufferLike> | Float32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike> | BigInt64Array<ArrayBufferLike> | BigInt128Array | string[] | Uint8Array<ArrayBufferLike>[] | DdbObj<DdbValue>[] | IotVectorItemValue | DdbSymbolExtendedValue | DdbArrayVectorValue | DdbDecimal32VectorValue | DdbDecimal64VectorValue | DdbDecimal128VectorValue | DdbDurationVectorValue | DdbMatrixValue | DdbChartValue | DdbTensorValue;
422
423
  /** 转换一个向量到 js 原生数组 */
423
424
  export declare function converts(type: DdbType, value: DdbVectorValue, rows: number, le: boolean, options?: ConvertOptions): any[] | Uint8Array;
425
+ /** 构造 void 类型,默认为 `DdbVoidType.undefined` */
424
426
  export declare class DdbVoid extends DdbObj<undefined> {
425
427
  constructor(value?: DdbVoidType);
426
428
  }
package/browser.js CHANGED
@@ -1549,10 +1549,14 @@ export class DdbObj {
1549
1549
  return `${DdbForm[this.form]} ${tname}`;
1550
1550
  }
1551
1551
  }
1552
- /** 自动转换 js string, boolean 为 DdbObj */
1552
+ /** 自动转换 JsSimpleType 为 DdbObj */
1553
1553
  static to_ddbobj(value) {
1554
1554
  if (value && value instanceof DdbObj)
1555
1555
  return value;
1556
+ if (value === undefined)
1557
+ return new DdbVoid();
1558
+ if (value === null)
1559
+ return new DdbVoid(DdbVoidType.null);
1556
1560
  const type = typeof value;
1557
1561
  switch (type) {
1558
1562
  case 'string':
@@ -2148,6 +2152,7 @@ export function converts(type, value, rows, le, options) {
2148
2152
  }).flat();
2149
2153
  }
2150
2154
  }
2155
+ /** 构造 void 类型,默认为 `DdbVoidType.undefined` */
2151
2156
  export class DdbVoid extends DdbObj {
2152
2157
  constructor(value = DdbVoidType.undefined) {
2153
2158
  super({
@@ -3301,9 +3306,12 @@ export class DDB {
3301
3306
  for (const arg of args)
3302
3307
  if (arg && arg instanceof DdbObj)
3303
3308
  has_ddbobj = true;
3309
+ else if (arg === undefined || arg === null) {
3310
+ // simple
3311
+ }
3304
3312
  else {
3305
3313
  const type = typeof arg;
3306
- if (type === 'string' || type === 'boolean') { }
3314
+ if (type === 'string' || type === 'boolean') { } // simple
3307
3315
  else
3308
3316
  simple = false;
3309
3317
  }
@@ -3396,15 +3404,10 @@ export class DDB {
3396
3404
  /** index of line feed 0 */
3397
3405
  const ilf0 = buf.indexOf(0x0a); // '\n'
3398
3406
  const parts = this.dec.decode(buf.subarray(0, ilf0)).split(' ');
3399
- /** session id */
3400
- const sid = parts[0];
3401
- if (sid !== this.sid) {
3402
- console.log(t('session id 从 {{sid}} 变为 {{sid_}}', { sid: this.sid, sid_: sid }));
3403
- this.sid = sid;
3404
- }
3405
- /** 返回对象的数量 */
3406
- const nobj = Number(parts[1]);
3407
- /** 大小端: 协议中大端为 0, 小端为 1 */
3407
+ this.sid = parts[0];
3408
+ // 返回对象的数量
3409
+ // const nobj = Number(parts[1])
3410
+ // 大小端: 协议中大端为 0, 小端为 1
3408
3411
  this.le = Number(parts[2]) !== 0;
3409
3412
  const ils1 = ilf0 + 1;
3410
3413
  const ilf1 = buf.indexOf(0x0a, ils1); // '\n'