@aibee/crc-bmap 0.14.37 → 0.14.39

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/lib/meta.json CHANGED
@@ -1142,13 +1142,28 @@
1142
1142
  "format": "esm"
1143
1143
  },
1144
1144
  "../lib/src/utils/index-db.js": {
1145
- "bytes": 6422,
1145
+ "bytes": 9851,
1146
1146
  "imports": [
1147
1147
  {
1148
1148
  "path": "core-js/modules/es.error.cause.js",
1149
1149
  "kind": "import-statement",
1150
1150
  "external": true
1151
1151
  },
1152
+ {
1153
+ "path": "core-js/modules/web.dom-exception.constructor.js",
1154
+ "kind": "import-statement",
1155
+ "external": true
1156
+ },
1157
+ {
1158
+ "path": "core-js/modules/web.dom-exception.stack.js",
1159
+ "kind": "import-statement",
1160
+ "external": true
1161
+ },
1162
+ {
1163
+ "path": "core-js/modules/web.dom-exception.to-string-tag.js",
1164
+ "kind": "import-statement",
1165
+ "external": true
1166
+ },
1152
1167
  {
1153
1168
  "path": "<runtime>",
1154
1169
  "kind": "import-statement",
@@ -1350,8 +1365,13 @@
1350
1365
  "format": "esm"
1351
1366
  },
1352
1367
  "../lib/src/factory/img-texture.js": {
1353
- "bytes": 3369,
1368
+ "bytes": 4061,
1354
1369
  "imports": [
1370
+ {
1371
+ "path": "core-js/modules/es.error.cause.js",
1372
+ "kind": "import-statement",
1373
+ "external": true
1374
+ },
1355
1375
  {
1356
1376
  "path": "core-js/modules/web.dom-collections.iterator.js",
1357
1377
  "kind": "import-statement",
@@ -2010,8 +2030,43 @@
2010
2030
  "format": "esm"
2011
2031
  },
2012
2032
  "../lib/src/layer/poi-text-batch.js": {
2013
- "bytes": 13108,
2033
+ "bytes": 14619,
2014
2034
  "imports": [
2035
+ {
2036
+ "path": "core-js/modules/es.set.difference.v2.js",
2037
+ "kind": "import-statement",
2038
+ "external": true
2039
+ },
2040
+ {
2041
+ "path": "core-js/modules/es.set.intersection.v2.js",
2042
+ "kind": "import-statement",
2043
+ "external": true
2044
+ },
2045
+ {
2046
+ "path": "core-js/modules/es.set.is-disjoint-from.v2.js",
2047
+ "kind": "import-statement",
2048
+ "external": true
2049
+ },
2050
+ {
2051
+ "path": "core-js/modules/es.set.is-subset-of.v2.js",
2052
+ "kind": "import-statement",
2053
+ "external": true
2054
+ },
2055
+ {
2056
+ "path": "core-js/modules/es.set.is-superset-of.v2.js",
2057
+ "kind": "import-statement",
2058
+ "external": true
2059
+ },
2060
+ {
2061
+ "path": "core-js/modules/es.set.symmetric-difference.v2.js",
2062
+ "kind": "import-statement",
2063
+ "external": true
2064
+ },
2065
+ {
2066
+ "path": "core-js/modules/es.set.union.v2.js",
2067
+ "kind": "import-statement",
2068
+ "external": true
2069
+ },
2015
2070
  {
2016
2071
  "path": "core-js/modules/web.dom-collections.iterator.js",
2017
2072
  "kind": "import-statement",
@@ -2111,7 +2166,7 @@
2111
2166
  "format": "esm"
2112
2167
  },
2113
2168
  "../lib/src/layer/poi-icon-batch.js": {
2114
- "bytes": 10718,
2169
+ "bytes": 10922,
2115
2170
  "imports": [
2116
2171
  {
2117
2172
  "path": "core-js/modules/web.dom-collections.iterator.js",
@@ -2399,7 +2454,7 @@
2399
2454
  "format": "esm"
2400
2455
  },
2401
2456
  "../src/utils/index-db.ts": {
2402
- "bytes": 5584,
2457
+ "bytes": 8563,
2403
2458
  "imports": [
2404
2459
  {
2405
2460
  "path": "<runtime>",
@@ -2482,7 +2537,7 @@
2482
2537
  "format": "esm"
2483
2538
  },
2484
2539
  "../src/factory/img-texture.ts": {
2485
- "bytes": 3167,
2540
+ "bytes": 3732,
2486
2541
  "imports": [
2487
2542
  {
2488
2543
  "path": "three",
@@ -3420,7 +3475,7 @@
3420
3475
  "format": "esm"
3421
3476
  },
3422
3477
  "../lib/src/elements/poi2.js": {
3423
- "bytes": 34819,
3478
+ "bytes": 41716,
3424
3479
  "imports": [
3425
3480
  {
3426
3481
  "path": "../../../node_modules/.pnpm/@swc+helpers@0.5.17/node_modules/@swc/helpers/esm/_extends.js",
@@ -3437,6 +3492,41 @@
3437
3492
  "kind": "import-statement",
3438
3493
  "external": true
3439
3494
  },
3495
+ {
3496
+ "path": "core-js/modules/es.set.difference.v2.js",
3497
+ "kind": "import-statement",
3498
+ "external": true
3499
+ },
3500
+ {
3501
+ "path": "core-js/modules/es.set.intersection.v2.js",
3502
+ "kind": "import-statement",
3503
+ "external": true
3504
+ },
3505
+ {
3506
+ "path": "core-js/modules/es.set.is-disjoint-from.v2.js",
3507
+ "kind": "import-statement",
3508
+ "external": true
3509
+ },
3510
+ {
3511
+ "path": "core-js/modules/es.set.is-subset-of.v2.js",
3512
+ "kind": "import-statement",
3513
+ "external": true
3514
+ },
3515
+ {
3516
+ "path": "core-js/modules/es.set.is-superset-of.v2.js",
3517
+ "kind": "import-statement",
3518
+ "external": true
3519
+ },
3520
+ {
3521
+ "path": "core-js/modules/es.set.symmetric-difference.v2.js",
3522
+ "kind": "import-statement",
3523
+ "external": true
3524
+ },
3525
+ {
3526
+ "path": "core-js/modules/es.set.union.v2.js",
3527
+ "kind": "import-statement",
3528
+ "external": true
3529
+ },
3440
3530
  {
3441
3531
  "path": "core-js/modules/es.string.trim.js",
3442
3532
  "kind": "import-statement",
@@ -3476,7 +3566,7 @@
3476
3566
  "format": "esm"
3477
3567
  },
3478
3568
  "../lib/src/elements/floor.js": {
3479
- "bytes": 7381,
3569
+ "bytes": 7765,
3480
3570
  "imports": [
3481
3571
  {
3482
3572
  "path": "core-js/modules/web.dom-collections.iterator.js",
@@ -5022,7 +5112,7 @@
5022
5112
  "format": "esm"
5023
5113
  },
5024
5114
  "../lib/src/context/collision-system.js": {
5025
- "bytes": 6570,
5115
+ "bytes": 6772,
5026
5116
  "imports": [
5027
5117
  {
5028
5118
  "path": "core-js/modules/es.array.unshift.js",
@@ -5182,7 +5272,7 @@
5182
5272
  "format": "esm"
5183
5273
  },
5184
5274
  "../lib/src/loader/AibeeLoader/index.js": {
5185
- "bytes": 23146,
5275
+ "bytes": 24793,
5186
5276
  "imports": [
5187
5277
  {
5188
5278
  "path": "../../../node_modules/.pnpm/@swc+helpers@0.5.17/node_modules/@swc/helpers/esm/_extends.js",
@@ -5199,6 +5289,11 @@
5199
5289
  "kind": "import-statement",
5200
5290
  "external": true
5201
5291
  },
5292
+ {
5293
+ "path": "core-js/modules/es.error.cause.js",
5294
+ "kind": "import-statement",
5295
+ "external": true
5296
+ },
5202
5297
  {
5203
5298
  "path": "../lib/src/utils/index-db.js",
5204
5299
  "kind": "import-statement",
@@ -5327,7 +5422,7 @@
5327
5422
  "format": "esm"
5328
5423
  },
5329
5424
  "../lib/src/bmap.js": {
5330
- "bytes": 22666,
5425
+ "bytes": 24399,
5331
5426
  "imports": [
5332
5427
  {
5333
5428
  "path": "../../../node_modules/.pnpm/@swc+helpers@0.5.17/node_modules/@swc/helpers/esm/_extends.js",
@@ -5399,6 +5494,11 @@
5399
5494
  "kind": "import-statement",
5400
5495
  "original": "./loader"
5401
5496
  },
5497
+ {
5498
+ "path": "../lib/src/utils/index-db.js",
5499
+ "kind": "import-statement",
5500
+ "original": "./utils/index-db"
5501
+ },
5402
5502
  {
5403
5503
  "path": "<runtime>",
5404
5504
  "kind": "import-statement",
@@ -8080,11 +8180,31 @@
8080
8180
  "kind": "import-statement",
8081
8181
  "external": true
8082
8182
  },
8183
+ {
8184
+ "path": "core-js/modules/web.dom-exception.constructor.js",
8185
+ "kind": "import-statement",
8186
+ "external": true
8187
+ },
8188
+ {
8189
+ "path": "core-js/modules/web.dom-exception.stack.js",
8190
+ "kind": "import-statement",
8191
+ "external": true
8192
+ },
8193
+ {
8194
+ "path": "core-js/modules/web.dom-exception.to-string-tag.js",
8195
+ "kind": "import-statement",
8196
+ "external": true
8197
+ },
8083
8198
  {
8084
8199
  "path": "three",
8085
8200
  "kind": "import-statement",
8086
8201
  "external": true
8087
8202
  },
8203
+ {
8204
+ "path": "core-js/modules/es.error.cause.js",
8205
+ "kind": "import-statement",
8206
+ "external": true
8207
+ },
8088
8208
  {
8089
8209
  "path": "core-js/modules/web.dom-collections.iterator.js",
8090
8210
  "kind": "import-statement",
@@ -8400,6 +8520,41 @@
8400
8520
  "kind": "import-statement",
8401
8521
  "external": true
8402
8522
  },
8523
+ {
8524
+ "path": "core-js/modules/es.set.difference.v2.js",
8525
+ "kind": "import-statement",
8526
+ "external": true
8527
+ },
8528
+ {
8529
+ "path": "core-js/modules/es.set.intersection.v2.js",
8530
+ "kind": "import-statement",
8531
+ "external": true
8532
+ },
8533
+ {
8534
+ "path": "core-js/modules/es.set.is-disjoint-from.v2.js",
8535
+ "kind": "import-statement",
8536
+ "external": true
8537
+ },
8538
+ {
8539
+ "path": "core-js/modules/es.set.is-subset-of.v2.js",
8540
+ "kind": "import-statement",
8541
+ "external": true
8542
+ },
8543
+ {
8544
+ "path": "core-js/modules/es.set.is-superset-of.v2.js",
8545
+ "kind": "import-statement",
8546
+ "external": true
8547
+ },
8548
+ {
8549
+ "path": "core-js/modules/es.set.symmetric-difference.v2.js",
8550
+ "kind": "import-statement",
8551
+ "external": true
8552
+ },
8553
+ {
8554
+ "path": "core-js/modules/es.set.union.v2.js",
8555
+ "kind": "import-statement",
8556
+ "external": true
8557
+ },
8403
8558
  {
8404
8559
  "path": "core-js/modules/web.dom-collections.iterator.js",
8405
8560
  "kind": "import-statement",
@@ -8690,6 +8845,41 @@
8690
8845
  "kind": "import-statement",
8691
8846
  "external": true
8692
8847
  },
8848
+ {
8849
+ "path": "core-js/modules/es.set.difference.v2.js",
8850
+ "kind": "import-statement",
8851
+ "external": true
8852
+ },
8853
+ {
8854
+ "path": "core-js/modules/es.set.intersection.v2.js",
8855
+ "kind": "import-statement",
8856
+ "external": true
8857
+ },
8858
+ {
8859
+ "path": "core-js/modules/es.set.is-disjoint-from.v2.js",
8860
+ "kind": "import-statement",
8861
+ "external": true
8862
+ },
8863
+ {
8864
+ "path": "core-js/modules/es.set.is-subset-of.v2.js",
8865
+ "kind": "import-statement",
8866
+ "external": true
8867
+ },
8868
+ {
8869
+ "path": "core-js/modules/es.set.is-superset-of.v2.js",
8870
+ "kind": "import-statement",
8871
+ "external": true
8872
+ },
8873
+ {
8874
+ "path": "core-js/modules/es.set.symmetric-difference.v2.js",
8875
+ "kind": "import-statement",
8876
+ "external": true
8877
+ },
8878
+ {
8879
+ "path": "core-js/modules/es.set.union.v2.js",
8880
+ "kind": "import-statement",
8881
+ "external": true
8882
+ },
8693
8883
  {
8694
8884
  "path": "core-js/modules/es.string.trim.js",
8695
8885
  "kind": "import-statement",
@@ -9410,6 +9600,11 @@
9410
9600
  "kind": "import-statement",
9411
9601
  "external": true
9412
9602
  },
9603
+ {
9604
+ "path": "core-js/modules/es.error.cause.js",
9605
+ "kind": "import-statement",
9606
+ "external": true
9607
+ },
9413
9608
  {
9414
9609
  "path": "three",
9415
9610
  "kind": "import-statement",
@@ -10266,7 +10461,7 @@
10266
10461
  "bytesInOutput": 208
10267
10462
  },
10268
10463
  "../lib/src/bmap.js": {
10269
- "bytesInOutput": 11302
10464
+ "bytesInOutput": 11609
10270
10465
  },
10271
10466
  "../lib/src/context/context.js": {
10272
10467
  "bytesInOutput": 9505
@@ -10386,7 +10581,7 @@
10386
10581
  "bytesInOutput": 2371
10387
10582
  },
10388
10583
  "../lib/src/utils/index-db.js": {
10389
- "bytesInOutput": 1920
10584
+ "bytesInOutput": 2884
10390
10585
  },
10391
10586
  "../lib/src/factory/worker/sdf-text.worker.js": {
10392
10587
  "bytesInOutput": 97
@@ -10395,7 +10590,7 @@
10395
10590
  "bytesInOutput": 3816
10396
10591
  },
10397
10592
  "../lib/src/factory/img-texture.js": {
10398
- "bytesInOutput": 1581
10593
+ "bytesInOutput": 1890
10399
10594
  },
10400
10595
  "../lib/src/factory/model.js": {
10401
10596
  "bytesInOutput": 898
@@ -10452,7 +10647,7 @@
10452
10647
  "bytesInOutput": 4421
10453
10648
  },
10454
10649
  "../lib/src/elements/floor.js": {
10455
- "bytesInOutput": 4504
10650
+ "bytesInOutput": 4621
10456
10651
  },
10457
10652
  "../lib/src/elements/model.js": {
10458
10653
  "bytesInOutput": 410
@@ -10470,10 +10665,10 @@
10470
10665
  "bytesInOutput": 2126
10471
10666
  },
10472
10667
  "../lib/src/layer/poi-text-batch.js": {
10473
- "bytesInOutput": 6773
10668
+ "bytesInOutput": 7437
10474
10669
  },
10475
10670
  "../lib/src/layer/poi-icon-batch.js": {
10476
- "bytesInOutput": 5870
10671
+ "bytesInOutput": 5913
10477
10672
  },
10478
10673
  "../lib/src/layer/parking-layer.js": {
10479
10674
  "bytesInOutput": 4035
@@ -10509,7 +10704,7 @@
10509
10704
  "bytesInOutput": 1595
10510
10705
  },
10511
10706
  "../lib/src/elements/poi2.js": {
10512
- "bytesInOutput": 15800
10707
+ "bytesInOutput": 18439
10513
10708
  },
10514
10709
  "../lib/src/elements/heatmap.js": {
10515
10710
  "bytesInOutput": 2123
@@ -10602,13 +10797,13 @@
10602
10797
  "bytesInOutput": 186
10603
10798
  },
10604
10799
  "../lib/src/context/collision-system.js": {
10605
- "bytesInOutput": 2629
10800
+ "bytesInOutput": 2605
10606
10801
  },
10607
10802
  "../lib/src/config.js": {
10608
10803
  "bytesInOutput": 1360
10609
10804
  },
10610
10805
  "../lib/src/loader/AibeeLoader/index.js": {
10611
- "bytesInOutput": 10274
10806
+ "bytesInOutput": 10701
10612
10807
  },
10613
10808
  "../lib/src/loader/AibeeLoader/layer.js": {
10614
10809
  "bytesInOutput": 4435
@@ -10764,7 +10959,7 @@
10764
10959
  "bytesInOutput": 0
10765
10960
  }
10766
10961
  },
10767
- "bytes": 472254
10962
+ "bytes": 477700
10768
10963
  }
10769
10964
  }
10770
10965
  }
package/lib/src/bmap.d.ts CHANGED
@@ -43,6 +43,10 @@ export declare enum MapTypePolar {
43
43
  }
44
44
  export declare class BMap extends EventDispatcher<BmapEventMap> {
45
45
  private container;
46
+ /** 当前存活的 BMap 实例数;共享 db / factory 只在最后一个实例销毁时释放 */
47
+ private static liveCount;
48
+ /** dispose 幂等标记,避免同一个实例重复减少 liveCount */
49
+ private disposed;
46
50
  config: Config;
47
51
  context: Context;
48
52
  polarKeys: string[];
@@ -64,6 +64,21 @@ export declare class Poi2 extends Object3D<PoiEventMap2> {
64
64
  box: Box2;
65
65
  boxHelper?: HTMLDivElement;
66
66
  private _shouldShow;
67
+ /** 异步文字/图标初始化版本号;hide 或下一次重建会递增,旧请求据此失效 */
68
+ private textRevision;
69
+ /** show/hide 的版本号,避免旧的 show 在 await 之后继续操作新状态 */
70
+ private visibilityRevision;
71
+ /** 下一帧按最新 zoom/textHeight 再校准一次网格缩放 */
72
+ private scheduleScaleSync;
73
+ /** 图标初始化版本号,和 textRevision 同理 */
74
+ private iconRevision;
75
+ /** 下一帧的缩放校准任务,避免创建瞬间的 zoom/布局与渲染帧不一致 */
76
+ private scaleSyncRaf;
77
+ /** 只记录 SDK 自己创建的文字/背景网格,避免误销毁外部添加到 POI 的对象 */
78
+ private textObjects;
79
+ /** 只记录 SDK 自己创建的独立图标 sprite */
80
+ private iconSprites;
81
+ get shouldShow(): boolean;
67
82
  /** 文字布局结果(按 textTextureKey 缓存) */
68
83
  textLayoutMap: Record<string, TextLayoutResult>;
69
84
  /** 所属 PoiLayer2 的文字合批器;为空时保持旧的逐 POI Mesh 渲染 */
@@ -118,8 +133,24 @@ export declare class Poi2 extends Object3D<PoiEventMap2> {
118
133
  height: number;
119
134
  lines: number;
120
135
  } | null;
136
+ /**
137
+ * 标签挂载点相对 POI 位置在 z 方向上的抬升量。
138
+ * 逐 POI 网格(meshText / spriteIcon)、合批实例(PoiTextBatch / PoiIconBatch)
139
+ * 以及碰撞框原点(getLabelOriginWorldPosition)必须共用这一个值,
140
+ * 否则 3D 视角下包围盒会和实际绘制的标签错开。
141
+ * 纯文字时抬升量随 zoom 变化,合批需要在 zoom 变化时同步实例中心。
142
+ */
121
143
  get deltaZ(): number;
122
144
  get canSelect(): boolean;
145
+ /** 释放单个文字/背景网格的几何与材质 */
146
+ private disposeTextMesh;
147
+ /**
148
+ * 清掉 SDK 自己创建的所有文字/背景网格。
149
+ * 用 Set 记录所有权,而不是扫描 children/userData,避免误销毁外部对象。
150
+ */
151
+ private clearTextObjects;
152
+ /** 清掉 SDK 自己创建的所有独立图标 sprite */
153
+ private clearIconObjects;
123
154
  show(): Promise<void>;
124
155
  hide(): void;
125
156
  registryEvent(): void;
@@ -127,6 +158,8 @@ export declare class Poi2 extends Object3D<PoiEventMap2> {
127
158
  getPosition(): Vector3;
128
159
  initIcon(): Promise<Sprite<Object3DEventMap> | undefined>;
129
160
  get textTextureKey(): string;
161
+ /** 预生成当前文案的布局和包围盒,即使 POI 当前被碰撞隐藏也要做 */
162
+ private prepareTextLayout;
130
163
  _initTextTexture: () => Promise<void>;
131
164
  initTextTexture: () => Promise<void>;
132
165
  /** 计算文字的 SDF 布局(含换行),度量来自共享字形图集;结果会缓存到 textLayoutMap */
@@ -149,7 +182,8 @@ export declare class Poi2 extends Object3D<PoiEventMap2> {
149
182
  /**
150
183
  * 标签渲染原点的世界坐标,供碰撞检测投影使用。
151
184
  * 优先取文字/图标网格的实际世界坐标(包含 deltaZ 抬升与楼层等父级变换);
152
- * 标签被隐藏(网格未创建)时,按 deltaZ 估算。
185
+ * 合批模式下没有逐 POI 网格,按 deltaZ 估算——合批实例的挂载高度同样取自
186
+ * deltaZ(见 PoiTextBatch / PoiIconBatch),两边必须是同一个口径。
153
187
  * 这样包围盒的基准点与渲染一致,2D / 3D 视角下都不会错位。
154
188
  */
155
189
  getLabelOriginWorldPosition(target?: Vector3): Vector3;
@@ -5,6 +5,8 @@ export declare class ImgTextureFactory {
5
5
  static borderUrlTextureMap: Map<string, Texture | Promise<Texture>>;
6
6
  private static canvas;
7
7
  private static ctx;
8
+ /** 懒创建离屏画布;dispose 后下一次使用时会重新创建 */
9
+ private static ensureCanvas;
8
10
  static getTextureByUrl(url: string): Promise<Texture>;
9
11
  static getUrlTextureBorder(url: string, size: number, border: {
10
12
  width: number;
@@ -23,6 +23,8 @@ export declare class PoiTextBatch extends Object3D {
23
23
  dispose(): void;
24
24
  private get pixelRatio();
25
25
  private onZoomChange;
26
+ /** 把每个实例的中心 z 同步为 POI 当前的 deltaZ(不重建几何) */
27
+ private syncCenterZ;
26
28
  private writeOpacity;
27
29
  private scheduleRebuild;
28
30
  private clearBuckets;
@@ -30,6 +30,13 @@ interface AibeeLoaderEventMap {
30
30
  graphics: Graphic[];
31
31
  };
32
32
  };
33
+ /** 切楼层失败(数据不可用、缓存/网络异常等);调用方据此结束 loading */
34
+ 'switch-floor-error': {
35
+ data: {
36
+ floor: string;
37
+ error: unknown;
38
+ };
39
+ };
33
40
  }
34
41
  export interface AibeeFloorInfo {
35
42
  floor_id: number;
@@ -60,6 +67,8 @@ export interface PlaceConfig {
60
67
  }
61
68
  export declare class AibeeLoader extends EventDispatcher<AibeeLoaderEventMap> {
62
69
  bmap: BMap;
70
+ /** 防止 dispose 重复执行(BMap.dispose 和组件卸载可能都会调用) */
71
+ disposed: boolean;
63
72
  floors: AibeeFloorInfo[];
64
73
  initDbPromise: Promise<void>;
65
74
  /** 全场预热的完成信号;需要确保缓存已就绪时可 await 它 */
@@ -76,7 +85,7 @@ export declare class AibeeLoader extends EventDispatcher<AibeeLoaderEventMap> {
76
85
  initDb(): Promise<void>;
77
86
  load(data: number | string | AibeeFloorInfo[], placeConfig?: Partial<PlaceConfig>): Promise<void>;
78
87
  waitForPreload(): Promise<void>;
79
- setCacheData(storeName: string, key: string | number, data: any): Promise<unknown>;
88
+ setCacheData(storeName: string, key: string | number, data: any): Promise<any>;
80
89
  getCacheData<T>(storeName: string, key: string | number): Promise<T>;
81
90
  /**
82
91
  * 刚写入 IndexedDB 的数据,在 Safari/WKWebView 下可能因为事务提交时序短暂读不到。
@@ -11,6 +11,20 @@ export declare enum MAP_DB_TABLES {
11
11
  LAZY_POI = "lazy_poi",// 车位poi
12
12
  SDF_GLYPH = "sdf_glyph_1"
13
13
  }
14
+ /**
15
+ * 增加一个 db 持有者。由 BMap 在构造时调用,和 releaseDb 成对出现。
16
+ * 持有者存在期间,即使某个 AibeeLoader 被销毁,也不会关闭共享连接。
17
+ */
18
+ export declare function retainDb(): void;
19
+ /**
20
+ * 释放一个 db 持有者。只有最后一个持有者释放时才关闭连接。
21
+ */
22
+ export declare function releaseDb(): void;
23
+ /**
24
+ * 获取 indexDb 连接。
25
+ * 连接不可用时会重新打开;worker 里没有 window,允许 worker 自己打开自己的连接。
26
+ */
27
+ export declare function ensureDb(): Promise<IDBDatabase>;
14
28
  /**
15
29
  * 获取indexDb连接
16
30
  * @param database
@@ -27,7 +41,7 @@ export declare function createDb(database?: string, version?: number): Promise<{
27
41
  * @param db
28
42
  * @returns
29
43
  */
30
- export declare function get(storeName: string, key: string, db?: IDBDatabase): Promise<unknown>;
44
+ export declare function get(storeName: string, key: string, db?: IDBDatabase | null): Promise<any>;
31
45
  /**
32
46
  * 添加数据
33
47
  * @param storeName
@@ -36,14 +50,14 @@ export declare function get(storeName: string, key: string, db?: IDBDatabase): P
36
50
  * @param db
37
51
  * @returns
38
52
  */
39
- export declare function set(storeName: string, key: string, value: any, db?: IDBDatabase, forceAdd?: boolean): Promise<unknown>;
53
+ export declare function set(storeName: string, key: string, value: any, db?: IDBDatabase | null, forceAdd?: boolean): Promise<any>;
40
54
  /**
41
55
  * 创建数据表
42
56
  * @param storeName
43
57
  * @param db
44
58
  * @returns
45
59
  */
46
- export declare function createStore(storeName: string, db?: IDBDatabase): void;
60
+ export declare function createStore(storeName: string, db?: IDBDatabase | null): void;
47
61
  /**
48
62
  * 删除数据
49
63
  * @param storeName
@@ -51,7 +65,7 @@ export declare function createStore(storeName: string, db?: IDBDatabase): void;
51
65
  * @param db
52
66
  * @returns
53
67
  */
54
- export declare function remove(storeName: string, key: string, db?: IDBDatabase): Promise<unknown>;
68
+ export declare function remove(storeName: string, key: string, db?: IDBDatabase | null): Promise<any>;
55
69
  /**
56
70
  * 更新数据
57
71
  * @param storeName
@@ -60,5 +74,5 @@ export declare function remove(storeName: string, key: string, db?: IDBDatabase)
60
74
  * @param db
61
75
  * @returns
62
76
  */
63
- export declare function update(storeName: string, key: string, value: any, db?: IDBDatabase): Promise<unknown>;
64
- export declare function closeDb(db?: IDBDatabase): void;
77
+ export declare function update(storeName: string, key: string, value: any, db?: IDBDatabase | null): Promise<any>;
78
+ export declare function closeDb(db?: IDBDatabase | null): void;