@aibee/crc-bmap 0.4.0 → 0.4.1
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/bmap.cjs.min.js +7 -7
- package/lib/bmap.cjs.min.js.map +3 -3
- package/lib/bmap.esm.js +52 -16
- package/lib/bmap.esm.js.map +2 -2
- package/lib/bmap.esm.min.js +7 -7
- package/lib/bmap.esm.min.js.map +3 -3
- package/lib/bmap.min.js +7 -7
- package/lib/bmap.min.js.map +3 -3
- package/lib/src/loader/AibeeLoader/index.d.ts +3 -1
- package/lib/src/utils/index-db.d.ts +1 -1
- package/package.json +1 -1
package/lib/bmap.esm.js
CHANGED
|
@@ -10611,12 +10611,12 @@ async function downloadFileToJson(fileId, config) {
|
|
|
10611
10611
|
|
|
10612
10612
|
// src/utils/index-db.ts
|
|
10613
10613
|
var _db;
|
|
10614
|
-
function createDb(database = "aibee_map") {
|
|
10614
|
+
function createDb(database = "aibee_map", version = 1) {
|
|
10615
10615
|
return new Promise((resolve, reject) => {
|
|
10616
10616
|
if (_db) {
|
|
10617
10617
|
return resolve({ db: _db, type: "success" });
|
|
10618
10618
|
}
|
|
10619
|
-
const request = indexedDB.open(database);
|
|
10619
|
+
const request = indexedDB.open(database, version);
|
|
10620
10620
|
request.onupgradeneeded = function(event) {
|
|
10621
10621
|
_db = event.target.result;
|
|
10622
10622
|
console.log("onupgradeneeded");
|
|
@@ -10656,9 +10656,10 @@ function set(storeName, key, value, db = _db) {
|
|
|
10656
10656
|
if (!db) {
|
|
10657
10657
|
reject("\u6CA1\u6709db");
|
|
10658
10658
|
}
|
|
10659
|
-
return new Promise((resolve2, reject2) => {
|
|
10659
|
+
return new Promise(async (resolve2, reject2) => {
|
|
10660
|
+
const has = await get(storeName, key);
|
|
10660
10661
|
const objectStore = db.transaction([storeName], "readwrite").objectStore(storeName);
|
|
10661
|
-
const request = objectStore.add({ key, value });
|
|
10662
|
+
const request = has !== null ? objectStore.put({ key, value }) : objectStore.add({ key, value });
|
|
10662
10663
|
request.onsuccess = function(event) {
|
|
10663
10664
|
resolve2(event);
|
|
10664
10665
|
};
|
|
@@ -10696,8 +10697,10 @@ var defaultAibeeLoaderOption = {
|
|
|
10696
10697
|
};
|
|
10697
10698
|
var MapVersionStoreName = "map_version";
|
|
10698
10699
|
var RouteVersionStoreName = "route_version";
|
|
10700
|
+
var FacilityVersionStoreName = "facility_version";
|
|
10699
10701
|
var MapDataStoreName = "map_data";
|
|
10700
10702
|
var RoadNetworkDataStoreName = "road_network_data";
|
|
10703
|
+
var FacilityDataStoreName = "facility_data";
|
|
10701
10704
|
var ParkingTypeIconMap = {
|
|
10702
10705
|
half: half_default,
|
|
10703
10706
|
power: power_default,
|
|
@@ -10706,24 +10709,28 @@ var ParkingTypeIconMap = {
|
|
|
10706
10709
|
var AibeeLoader = class {
|
|
10707
10710
|
constructor(bmap) {
|
|
10708
10711
|
this.bmap = bmap;
|
|
10709
|
-
this.initDb();
|
|
10712
|
+
this.initDbPromise = this.initDb();
|
|
10710
10713
|
}
|
|
10711
10714
|
floors = [];
|
|
10715
|
+
initDbPromise = Promise.resolve();
|
|
10716
|
+
db = null;
|
|
10712
10717
|
async initDb() {
|
|
10713
10718
|
try {
|
|
10714
|
-
const { db, type } = await createDb();
|
|
10719
|
+
const { db, type } = await createDb("aibee_map", 2);
|
|
10715
10720
|
if (type === "onupgradeneeded") {
|
|
10716
10721
|
createStore(MapVersionStoreName);
|
|
10717
10722
|
createStore(RouteVersionStoreName);
|
|
10723
|
+
createStore(FacilityVersionStoreName);
|
|
10718
10724
|
createStore(MapDataStoreName);
|
|
10719
10725
|
createStore(RoadNetworkDataStoreName);
|
|
10726
|
+
createStore(FacilityDataStoreName);
|
|
10720
10727
|
}
|
|
10728
|
+
this.db = db;
|
|
10721
10729
|
} catch (e) {
|
|
10722
10730
|
console.log("[\u6253\u5F00indexDb\u9519\u8BEF]", e);
|
|
10723
10731
|
}
|
|
10724
10732
|
}
|
|
10725
10733
|
async load(data) {
|
|
10726
|
-
this.clear();
|
|
10727
10734
|
if (Array.isArray(data)) {
|
|
10728
10735
|
this.floors = data;
|
|
10729
10736
|
} else {
|
|
@@ -10734,10 +10741,10 @@ var AibeeLoader = class {
|
|
|
10734
10741
|
}
|
|
10735
10742
|
}
|
|
10736
10743
|
setCacheData(storeName, key, data) {
|
|
10737
|
-
return set(storeName, `${key}`, data);
|
|
10744
|
+
return this.initDbPromise.then(() => set(storeName, `${key}`, data, this.db));
|
|
10738
10745
|
}
|
|
10739
10746
|
getCacheData(storeName, key) {
|
|
10740
|
-
return get(storeName, `${key}
|
|
10747
|
+
return this.initDbPromise.then(() => get(storeName, `${key}`, this.db));
|
|
10741
10748
|
}
|
|
10742
10749
|
getFloorCacheKey(floorInfo) {
|
|
10743
10750
|
return `${floorInfo.floor_id}`;
|
|
@@ -10760,7 +10767,8 @@ var AibeeLoader = class {
|
|
|
10760
10767
|
}
|
|
10761
10768
|
}
|
|
10762
10769
|
return this.getFloorDataByFloorInfo(floorInfo);
|
|
10763
|
-
} catch {
|
|
10770
|
+
} catch (e) {
|
|
10771
|
+
console.log("[get floor data error]", e);
|
|
10764
10772
|
return this.getFloorDataByFloorInfo(floorInfo);
|
|
10765
10773
|
}
|
|
10766
10774
|
}
|
|
@@ -10807,8 +10815,34 @@ var AibeeLoader = class {
|
|
|
10807
10815
|
return res.filter((item) => item.points);
|
|
10808
10816
|
}
|
|
10809
10817
|
async getFacilitiesData() {
|
|
10810
|
-
|
|
10811
|
-
|
|
10818
|
+
const floorInfo = this.floors[0];
|
|
10819
|
+
if (!floorInfo) {
|
|
10820
|
+
return null;
|
|
10821
|
+
}
|
|
10822
|
+
const cacheKey = this.getFloorCacheKey(floorInfo);
|
|
10823
|
+
const getFacilityUrl = async () => {
|
|
10824
|
+
const res = await fetch(floorInfo.entry_infra_url).then((res2) => res2.json());
|
|
10825
|
+
if (res) {
|
|
10826
|
+
this.setCacheData(FacilityDataStoreName, cacheKey, res);
|
|
10827
|
+
this.setCacheData(FacilityVersionStoreName, cacheKey, floorInfo.version_id);
|
|
10828
|
+
}
|
|
10829
|
+
return res;
|
|
10830
|
+
};
|
|
10831
|
+
try {
|
|
10832
|
+
const cacheVersion = await this.getCacheData(FacilityVersionStoreName, cacheKey);
|
|
10833
|
+
if (cacheVersion === floorInfo.version_id) {
|
|
10834
|
+
const res = await this.getCacheData(
|
|
10835
|
+
FacilityDataStoreName,
|
|
10836
|
+
cacheKey
|
|
10837
|
+
);
|
|
10838
|
+
if (res) {
|
|
10839
|
+
return res;
|
|
10840
|
+
}
|
|
10841
|
+
}
|
|
10842
|
+
return getFacilityUrl();
|
|
10843
|
+
} catch (e) {
|
|
10844
|
+
console.log("[get facility error]", e);
|
|
10845
|
+
return getFacilityUrl();
|
|
10812
10846
|
}
|
|
10813
10847
|
}
|
|
10814
10848
|
// 空闲时间请求其他数据
|
|
@@ -10977,7 +11011,8 @@ var AibeeLoader = class {
|
|
|
10977
11011
|
icon: options.poi_info.icon,
|
|
10978
11012
|
text: options.poi_info.showName || options.store_name || options.poi_info.text,
|
|
10979
11013
|
position: { x: pos[0], y: pos[1], z: options.airHeight + options.height },
|
|
10980
|
-
icon_size: [18, 18]
|
|
11014
|
+
icon_size: [18, 18],
|
|
11015
|
+
level: options.poi_info.level || 0
|
|
10981
11016
|
});
|
|
10982
11017
|
floor.poiLayer2.pushPoi(poi);
|
|
10983
11018
|
if (poi) {
|
|
@@ -11005,7 +11040,8 @@ var AibeeLoader = class {
|
|
|
11005
11040
|
icon: options.poi_info.icon,
|
|
11006
11041
|
text: options.poi_info.showName || options.store_name || options.poi_info.text,
|
|
11007
11042
|
position: { x: pos[0], y: pos[1], z: options.airHeight + options.height },
|
|
11008
|
-
icon_size: [18, 18]
|
|
11043
|
+
icon_size: [18, 18],
|
|
11044
|
+
level: options.poi_info.level || 0
|
|
11009
11045
|
});
|
|
11010
11046
|
floor.poiLayer2.pushPoi(poi);
|
|
11011
11047
|
poi.userData.type = "facility";
|
|
@@ -11092,11 +11128,11 @@ var AibeeLoader = class {
|
|
|
11092
11128
|
floor.updateBox();
|
|
11093
11129
|
return floor;
|
|
11094
11130
|
}
|
|
11095
|
-
clear() {
|
|
11131
|
+
async clear() {
|
|
11132
|
+
await this.initDbPromise.then(() => closeDb());
|
|
11096
11133
|
}
|
|
11097
11134
|
dispose() {
|
|
11098
11135
|
this.clear();
|
|
11099
|
-
closeDb();
|
|
11100
11136
|
}
|
|
11101
11137
|
};
|
|
11102
11138
|
|