@chrtco/sdk 0.7.0 → 0.7.2
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/dist/atlas/browser.cjs +208 -14
- package/dist/atlas/browser.cjs.map +1 -1
- package/dist/atlas/browser.d.cts +63 -1
- package/dist/atlas/browser.d.ts +63 -1
- package/dist/atlas/browser.js +203 -13
- package/dist/atlas/browser.js.map +1 -1
- package/dist/index.cjs +41 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +41 -41
- package/dist/index.js.map +1 -1
- package/package.json +20 -3
package/dist/atlas/browser.d.cts
CHANGED
|
@@ -17,6 +17,68 @@ declare function loadS52SymbolImages(map: maplibregl.Map, colorTable?: ColorTabl
|
|
|
17
17
|
*/
|
|
18
18
|
declare function reloadS52SymbolImages(map: maplibregl.Map, colorTable: ColorTableName): Promise<void>;
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Browser-only IndexedDB cache for S-52 symbol bitmaps.
|
|
22
|
+
*
|
|
23
|
+
* **First visit** — decodes 363 themed SVGs via the proven `new Image()` +
|
|
24
|
+
* `data:` URL path (identical to `./s52-svg-loader-browser`), adds them to
|
|
25
|
+
* the map immediately, AND in a non-blocking background task converts each
|
|
26
|
+
* decoded image to an `ImageBitmap` and persists it to IndexedDB keyed by
|
|
27
|
+
* `(atlasVersion, colorTable, symbolName)`.
|
|
28
|
+
*
|
|
29
|
+
* **Subsequent visits** — bulk-reads the bitmaps from IDB in a single
|
|
30
|
+
* transaction and `addImage`s them synchronously before any SVG parsing.
|
|
31
|
+
* The live-decode loop only runs for cache misses (atlas version mismatch,
|
|
32
|
+
* cleared storage, theme switch with no prior visit on that theme).
|
|
33
|
+
*
|
|
34
|
+
* **Hardening pass after PR #513**:
|
|
35
|
+
*
|
|
36
|
+
* - Originally tried `createImageBitmap(svgBlob)` — Chromium silently throws
|
|
37
|
+
* `InvalidStateError` for SVG inputs even though the function exists. The
|
|
38
|
+
* per-symbol catch swallowed the error and zero symbols got added to the
|
|
39
|
+
* map. Buoys / lights / beacons disappeared.
|
|
40
|
+
* - The fix is to NEVER let an SVG go through `createImageBitmap` directly.
|
|
41
|
+
* We decode via `new Image()` (which DOES handle SVG everywhere), then
|
|
42
|
+
* route the decoded image through a canvas → `createImageBitmap(canvas)`
|
|
43
|
+
* to get an IDB-storable bitmap. Canvas inputs to `createImageBitmap` are
|
|
44
|
+
* universally supported.
|
|
45
|
+
* - First-visit `addImage` happens off the HTMLImageElement, not the
|
|
46
|
+
* bitmap. The IDB persist is "best effort, never blocks the map" — any
|
|
47
|
+
* bitmap-conversion failure leaves the symbol on the map and just skips
|
|
48
|
+
* the cache write.
|
|
49
|
+
*
|
|
50
|
+
* Gracefully degrades to `loadS52SymbolImages` when IndexedDB is
|
|
51
|
+
* unavailable (private-mode lockdown, exotic browser).
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
interface LoadCachedOptions {
|
|
55
|
+
/**
|
|
56
|
+
* If true, skip the IDB read and force a full live-decode + repopulate.
|
|
57
|
+
* Theme is part of the key so this is rarely needed; left as an escape
|
|
58
|
+
* hatch.
|
|
59
|
+
*/
|
|
60
|
+
forceRefresh?: boolean;
|
|
61
|
+
}
|
|
62
|
+
/** Stable atlas version, exposed for diagnostics and tests. */
|
|
63
|
+
declare function getS52AtlasVersion(): string;
|
|
64
|
+
/**
|
|
65
|
+
* Drop-in replacement for `loadS52SymbolImages`. On first visit, decodes
|
|
66
|
+
* via the same `new Image()` path the live loader uses and persists each
|
|
67
|
+
* decoded symbol to IndexedDB in a non-blocking background task. On
|
|
68
|
+
* subsequent visits, bulk-hydrates from IDB before any SVG parsing.
|
|
69
|
+
*
|
|
70
|
+
* Falls back to `loadS52SymbolImages` when IndexedDB or canvas-to-bitmap
|
|
71
|
+
* conversion isn't available.
|
|
72
|
+
*/
|
|
73
|
+
declare function loadS52SymbolImagesCached(map: maplibregl.Map, colorTable?: ColorTableName, opts?: LoadCachedOptions): Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* Theme-switch equivalent of `reloadS52SymbolImages` that routes through
|
|
76
|
+
* the IDB-backed path.
|
|
77
|
+
*/
|
|
78
|
+
declare function reloadS52SymbolImagesCached(map: maplibregl.Map, colorTable: ColorTableName): Promise<void>;
|
|
79
|
+
/** Test/debug helper — wipes the entire bitmap store. */
|
|
80
|
+
declare function clearS52SymbolImageCache(): Promise<void>;
|
|
81
|
+
|
|
20
82
|
/**
|
|
21
83
|
* Browser-only nautical symbol image loaders. Sourced from `./symbols.ts`'s
|
|
22
84
|
* pure data; pushes themed icons into a MapLibre map via `new Image()` +
|
|
@@ -30,4 +92,4 @@ declare function loadSymbolImages(map: maplibregl.Map): Promise<void>;
|
|
|
30
92
|
*/
|
|
31
93
|
declare function loadThemedBridgeImages(map: maplibregl.Map, colorTable: ColorTableName): Promise<void>;
|
|
32
94
|
|
|
33
|
-
export { loadS52SymbolImages, loadSymbolImages, loadThemedBridgeImages, reloadS52SymbolImages };
|
|
95
|
+
export { type LoadCachedOptions, clearS52SymbolImageCache, getS52AtlasVersion, loadS52SymbolImages, loadS52SymbolImagesCached, loadSymbolImages, loadThemedBridgeImages, reloadS52SymbolImages, reloadS52SymbolImagesCached };
|
package/dist/atlas/browser.d.ts
CHANGED
|
@@ -17,6 +17,68 @@ declare function loadS52SymbolImages(map: maplibregl.Map, colorTable?: ColorTabl
|
|
|
17
17
|
*/
|
|
18
18
|
declare function reloadS52SymbolImages(map: maplibregl.Map, colorTable: ColorTableName): Promise<void>;
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Browser-only IndexedDB cache for S-52 symbol bitmaps.
|
|
22
|
+
*
|
|
23
|
+
* **First visit** — decodes 363 themed SVGs via the proven `new Image()` +
|
|
24
|
+
* `data:` URL path (identical to `./s52-svg-loader-browser`), adds them to
|
|
25
|
+
* the map immediately, AND in a non-blocking background task converts each
|
|
26
|
+
* decoded image to an `ImageBitmap` and persists it to IndexedDB keyed by
|
|
27
|
+
* `(atlasVersion, colorTable, symbolName)`.
|
|
28
|
+
*
|
|
29
|
+
* **Subsequent visits** — bulk-reads the bitmaps from IDB in a single
|
|
30
|
+
* transaction and `addImage`s them synchronously before any SVG parsing.
|
|
31
|
+
* The live-decode loop only runs for cache misses (atlas version mismatch,
|
|
32
|
+
* cleared storage, theme switch with no prior visit on that theme).
|
|
33
|
+
*
|
|
34
|
+
* **Hardening pass after PR #513**:
|
|
35
|
+
*
|
|
36
|
+
* - Originally tried `createImageBitmap(svgBlob)` — Chromium silently throws
|
|
37
|
+
* `InvalidStateError` for SVG inputs even though the function exists. The
|
|
38
|
+
* per-symbol catch swallowed the error and zero symbols got added to the
|
|
39
|
+
* map. Buoys / lights / beacons disappeared.
|
|
40
|
+
* - The fix is to NEVER let an SVG go through `createImageBitmap` directly.
|
|
41
|
+
* We decode via `new Image()` (which DOES handle SVG everywhere), then
|
|
42
|
+
* route the decoded image through a canvas → `createImageBitmap(canvas)`
|
|
43
|
+
* to get an IDB-storable bitmap. Canvas inputs to `createImageBitmap` are
|
|
44
|
+
* universally supported.
|
|
45
|
+
* - First-visit `addImage` happens off the HTMLImageElement, not the
|
|
46
|
+
* bitmap. The IDB persist is "best effort, never blocks the map" — any
|
|
47
|
+
* bitmap-conversion failure leaves the symbol on the map and just skips
|
|
48
|
+
* the cache write.
|
|
49
|
+
*
|
|
50
|
+
* Gracefully degrades to `loadS52SymbolImages` when IndexedDB is
|
|
51
|
+
* unavailable (private-mode lockdown, exotic browser).
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
interface LoadCachedOptions {
|
|
55
|
+
/**
|
|
56
|
+
* If true, skip the IDB read and force a full live-decode + repopulate.
|
|
57
|
+
* Theme is part of the key so this is rarely needed; left as an escape
|
|
58
|
+
* hatch.
|
|
59
|
+
*/
|
|
60
|
+
forceRefresh?: boolean;
|
|
61
|
+
}
|
|
62
|
+
/** Stable atlas version, exposed for diagnostics and tests. */
|
|
63
|
+
declare function getS52AtlasVersion(): string;
|
|
64
|
+
/**
|
|
65
|
+
* Drop-in replacement for `loadS52SymbolImages`. On first visit, decodes
|
|
66
|
+
* via the same `new Image()` path the live loader uses and persists each
|
|
67
|
+
* decoded symbol to IndexedDB in a non-blocking background task. On
|
|
68
|
+
* subsequent visits, bulk-hydrates from IDB before any SVG parsing.
|
|
69
|
+
*
|
|
70
|
+
* Falls back to `loadS52SymbolImages` when IndexedDB or canvas-to-bitmap
|
|
71
|
+
* conversion isn't available.
|
|
72
|
+
*/
|
|
73
|
+
declare function loadS52SymbolImagesCached(map: maplibregl.Map, colorTable?: ColorTableName, opts?: LoadCachedOptions): Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* Theme-switch equivalent of `reloadS52SymbolImages` that routes through
|
|
76
|
+
* the IDB-backed path.
|
|
77
|
+
*/
|
|
78
|
+
declare function reloadS52SymbolImagesCached(map: maplibregl.Map, colorTable: ColorTableName): Promise<void>;
|
|
79
|
+
/** Test/debug helper — wipes the entire bitmap store. */
|
|
80
|
+
declare function clearS52SymbolImageCache(): Promise<void>;
|
|
81
|
+
|
|
20
82
|
/**
|
|
21
83
|
* Browser-only nautical symbol image loaders. Sourced from `./symbols.ts`'s
|
|
22
84
|
* pure data; pushes themed icons into a MapLibre map via `new Image()` +
|
|
@@ -30,4 +92,4 @@ declare function loadSymbolImages(map: maplibregl.Map): Promise<void>;
|
|
|
30
92
|
*/
|
|
31
93
|
declare function loadThemedBridgeImages(map: maplibregl.Map, colorTable: ColorTableName): Promise<void>;
|
|
32
94
|
|
|
33
|
-
export { loadS52SymbolImages, loadSymbolImages, loadThemedBridgeImages, reloadS52SymbolImages };
|
|
95
|
+
export { type LoadCachedOptions, clearS52SymbolImageCache, getS52AtlasVersion, loadS52SymbolImages, loadS52SymbolImagesCached, loadSymbolImages, loadThemedBridgeImages, reloadS52SymbolImages, reloadS52SymbolImagesCached };
|
package/dist/atlas/browser.js
CHANGED
|
@@ -3,10 +3,10 @@ var S52_DAY = {
|
|
|
3
3
|
// Depth
|
|
4
4
|
NODTA: "#a4a4a4",
|
|
5
5
|
DEPIT: "#009678",
|
|
6
|
-
DEPVS: "#
|
|
7
|
-
DEPMS: "#
|
|
8
|
-
DEPMD: "#
|
|
9
|
-
DEPDW: "#
|
|
6
|
+
DEPVS: "#7fbfdf",
|
|
7
|
+
DEPMS: "#a7d4e8",
|
|
8
|
+
DEPMD: "#cae7f3",
|
|
9
|
+
DEPDW: "#ecf7fc",
|
|
10
10
|
// Land / topography
|
|
11
11
|
LANDA: "#e6d1a1",
|
|
12
12
|
LANDF: "#c8b078",
|
|
@@ -85,10 +85,10 @@ var S52_DAY = {
|
|
|
85
85
|
var S52_DUSK = {
|
|
86
86
|
NODTA: "#6b6b6b",
|
|
87
87
|
DEPIT: "#006650",
|
|
88
|
-
DEPVS: "#
|
|
89
|
-
DEPMS: "#
|
|
90
|
-
DEPMD: "#
|
|
91
|
-
DEPDW: "#
|
|
88
|
+
DEPVS: "#487085",
|
|
89
|
+
DEPMS: "#608a9d",
|
|
90
|
+
DEPMD: "#7ba6b8",
|
|
91
|
+
DEPDW: "#95bfd0",
|
|
92
92
|
LANDA: "#8a7d5e",
|
|
93
93
|
LANDF: "#7a6a48",
|
|
94
94
|
CHBRN: "#6e4e30",
|
|
@@ -156,10 +156,10 @@ var S52_DUSK = {
|
|
|
156
156
|
var S52_NIGHT = {
|
|
157
157
|
NODTA: "#3a3a32",
|
|
158
158
|
DEPIT: "#003828",
|
|
159
|
-
DEPVS: "#
|
|
160
|
-
DEPMS: "#
|
|
161
|
-
DEPMD: "#
|
|
162
|
-
DEPDW: "#
|
|
159
|
+
DEPVS: "#356577",
|
|
160
|
+
DEPMS: "#265066",
|
|
161
|
+
DEPMD: "#102e44",
|
|
162
|
+
DEPDW: "#051a28",
|
|
163
163
|
LANDA: "#3a3020",
|
|
164
164
|
LANDF: "#302818",
|
|
165
165
|
CHBRN: "#382410",
|
|
@@ -778,6 +778,192 @@ async function reloadS52SymbolImages(map, colorTable) {
|
|
|
778
778
|
await Promise.all(promises);
|
|
779
779
|
}
|
|
780
780
|
|
|
781
|
+
// src/atlas/s52-image-cache.ts
|
|
782
|
+
var SDF_SYMBOLS2 = /* @__PURE__ */ new Set(["LIGHTS11", "LIGHTS13"]);
|
|
783
|
+
var LOGICAL_SIZE2 = 32;
|
|
784
|
+
var PIXEL_RATIO2 = 2;
|
|
785
|
+
var RENDER_SIZE2 = LOGICAL_SIZE2 * PIXEL_RATIO2;
|
|
786
|
+
var DB_NAME = "chrt-s52-atlas";
|
|
787
|
+
var DB_VERSION = 1;
|
|
788
|
+
var STORE_NAME = "bitmaps";
|
|
789
|
+
var PARAM_VERSION = "v2";
|
|
790
|
+
function computeAtlasVersion() {
|
|
791
|
+
const names = Object.keys(ALL_S52_SVGS).sort().join("|");
|
|
792
|
+
let h = 2166136261;
|
|
793
|
+
for (let i = 0; i < names.length; i++) {
|
|
794
|
+
h ^= names.charCodeAt(i);
|
|
795
|
+
h = Math.imul(h, 16777619);
|
|
796
|
+
}
|
|
797
|
+
return `${PARAM_VERSION}-${(h >>> 0).toString(16)}-${Object.keys(ALL_S52_SVGS).length}`;
|
|
798
|
+
}
|
|
799
|
+
var ATLAS_VERSION = /* @__PURE__ */ computeAtlasVersion();
|
|
800
|
+
function makeKey(colorTable, name) {
|
|
801
|
+
return `${ATLAS_VERSION}:${colorTable}:${name}`;
|
|
802
|
+
}
|
|
803
|
+
function upsampleSvg2(svg2) {
|
|
804
|
+
return svg2.replace(
|
|
805
|
+
/width="(\d+)"\s+height="(\d+)"/,
|
|
806
|
+
`width="${RENDER_SIZE2}" height="${RENDER_SIZE2}"`
|
|
807
|
+
);
|
|
808
|
+
}
|
|
809
|
+
function prepareSvg2(rawSvg, colorTable) {
|
|
810
|
+
return upsampleSvg2(applyStrokeBoost(applyColorTheme(rawSvg, colorTable), S52_STROKE_BOOST));
|
|
811
|
+
}
|
|
812
|
+
function hasIndexedDB() {
|
|
813
|
+
return typeof indexedDB !== "undefined";
|
|
814
|
+
}
|
|
815
|
+
function hasCanvasToBitmap() {
|
|
816
|
+
return typeof createImageBitmap === "function" && typeof document !== "undefined" && typeof document.createElement === "function";
|
|
817
|
+
}
|
|
818
|
+
var dbPromise = null;
|
|
819
|
+
function openDb() {
|
|
820
|
+
if (!hasIndexedDB()) return Promise.reject(new Error("IndexedDB not available"));
|
|
821
|
+
if (dbPromise) return dbPromise;
|
|
822
|
+
dbPromise = new Promise((resolve, reject) => {
|
|
823
|
+
const req = indexedDB.open(DB_NAME, DB_VERSION);
|
|
824
|
+
req.onupgradeneeded = () => {
|
|
825
|
+
const db = req.result;
|
|
826
|
+
if (!db.objectStoreNames.contains(STORE_NAME)) {
|
|
827
|
+
db.createObjectStore(STORE_NAME);
|
|
828
|
+
}
|
|
829
|
+
};
|
|
830
|
+
req.onsuccess = () => resolve(req.result);
|
|
831
|
+
req.onerror = () => reject(req.error ?? new Error("indexedDB.open failed"));
|
|
832
|
+
req.onblocked = () => reject(new Error("indexedDB.open blocked"));
|
|
833
|
+
});
|
|
834
|
+
dbPromise.catch(() => {
|
|
835
|
+
dbPromise = null;
|
|
836
|
+
});
|
|
837
|
+
return dbPromise;
|
|
838
|
+
}
|
|
839
|
+
async function idbPut(key, value) {
|
|
840
|
+
const db = await openDb();
|
|
841
|
+
return new Promise((resolve, reject) => {
|
|
842
|
+
const tx = db.transaction(STORE_NAME, "readwrite");
|
|
843
|
+
const store = tx.objectStore(STORE_NAME);
|
|
844
|
+
const req = store.put(value, key);
|
|
845
|
+
req.onsuccess = () => resolve();
|
|
846
|
+
req.onerror = () => reject(req.error);
|
|
847
|
+
});
|
|
848
|
+
}
|
|
849
|
+
async function idbGetAllForTheme(colorTable) {
|
|
850
|
+
const out = /* @__PURE__ */ new Map();
|
|
851
|
+
const db = await openDb();
|
|
852
|
+
const names = Object.keys(ALL_S52_SVGS);
|
|
853
|
+
await new Promise((resolve, reject) => {
|
|
854
|
+
const tx = db.transaction(STORE_NAME, "readonly");
|
|
855
|
+
const store = tx.objectStore(STORE_NAME);
|
|
856
|
+
tx.oncomplete = () => resolve();
|
|
857
|
+
tx.onerror = () => reject(tx.error);
|
|
858
|
+
tx.onabort = () => reject(tx.error ?? new Error("idb txn aborted"));
|
|
859
|
+
for (const name of names) {
|
|
860
|
+
const req = store.get(makeKey(colorTable, name));
|
|
861
|
+
req.onsuccess = () => {
|
|
862
|
+
const bm = req.result;
|
|
863
|
+
if (bm) out.set(name, bm);
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
});
|
|
867
|
+
return out;
|
|
868
|
+
}
|
|
869
|
+
function decodeSvgToImage(themedSvg) {
|
|
870
|
+
return new Promise((resolve) => {
|
|
871
|
+
const img = new Image(RENDER_SIZE2, RENDER_SIZE2);
|
|
872
|
+
img.onload = () => resolve(img);
|
|
873
|
+
img.onerror = () => resolve(null);
|
|
874
|
+
img.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(themedSvg)}`;
|
|
875
|
+
});
|
|
876
|
+
}
|
|
877
|
+
async function imageToBitmap(img) {
|
|
878
|
+
try {
|
|
879
|
+
const canvas = document.createElement("canvas");
|
|
880
|
+
canvas.width = RENDER_SIZE2;
|
|
881
|
+
canvas.height = RENDER_SIZE2;
|
|
882
|
+
const ctx = canvas.getContext("2d");
|
|
883
|
+
if (!ctx) return null;
|
|
884
|
+
ctx.drawImage(img, 0, 0, RENDER_SIZE2, RENDER_SIZE2);
|
|
885
|
+
return await createImageBitmap(canvas);
|
|
886
|
+
} catch {
|
|
887
|
+
return null;
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
function addImageToMap(map, name, image) {
|
|
891
|
+
if (map.hasImage(name)) return;
|
|
892
|
+
try {
|
|
893
|
+
map.addImage(name, image, {
|
|
894
|
+
sdf: SDF_SYMBOLS2.has(name),
|
|
895
|
+
pixelRatio: PIXEL_RATIO2
|
|
896
|
+
});
|
|
897
|
+
} catch {
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
function getS52AtlasVersion() {
|
|
901
|
+
return ATLAS_VERSION;
|
|
902
|
+
}
|
|
903
|
+
async function loadS52SymbolImagesCached(map, colorTable = "DAY", opts = {}) {
|
|
904
|
+
if (!hasIndexedDB() || !hasCanvasToBitmap()) {
|
|
905
|
+
return loadS52SymbolImages(map, colorTable);
|
|
906
|
+
}
|
|
907
|
+
const names = Object.keys(ALL_S52_SVGS);
|
|
908
|
+
let cached;
|
|
909
|
+
if (opts.forceRefresh) {
|
|
910
|
+
cached = /* @__PURE__ */ new Map();
|
|
911
|
+
} else {
|
|
912
|
+
try {
|
|
913
|
+
cached = await idbGetAllForTheme(colorTable);
|
|
914
|
+
} catch {
|
|
915
|
+
cached = /* @__PURE__ */ new Map();
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
for (const [name, bitmap] of cached) {
|
|
919
|
+
addImageToMap(map, name, bitmap);
|
|
920
|
+
}
|
|
921
|
+
const missing = names.filter((n) => !cached.has(n) && !map.hasImage(n));
|
|
922
|
+
if (missing.length === 0) return;
|
|
923
|
+
await Promise.all(
|
|
924
|
+
missing.map(async (name) => {
|
|
925
|
+
const rawSvg = ALL_S52_SVGS[name];
|
|
926
|
+
if (!rawSvg) return;
|
|
927
|
+
const themed = prepareSvg2(rawSvg, colorTable);
|
|
928
|
+
const img = await decodeSvgToImage(themed);
|
|
929
|
+
if (!img) return;
|
|
930
|
+
addImageToMap(map, name, img);
|
|
931
|
+
try {
|
|
932
|
+
const bitmap = await imageToBitmap(img);
|
|
933
|
+
if (!bitmap) return;
|
|
934
|
+
await idbPut(makeKey(colorTable, name), bitmap);
|
|
935
|
+
} catch {
|
|
936
|
+
}
|
|
937
|
+
})
|
|
938
|
+
);
|
|
939
|
+
}
|
|
940
|
+
async function reloadS52SymbolImagesCached(map, colorTable) {
|
|
941
|
+
if (!hasIndexedDB() || !hasCanvasToBitmap()) {
|
|
942
|
+
return reloadS52SymbolImages(map, colorTable);
|
|
943
|
+
}
|
|
944
|
+
for (const name of Object.keys(ALL_S52_SVGS)) {
|
|
945
|
+
try {
|
|
946
|
+
if (map.hasImage(name)) map.removeImage(name);
|
|
947
|
+
} catch {
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
return loadS52SymbolImagesCached(map, colorTable);
|
|
951
|
+
}
|
|
952
|
+
async function clearS52SymbolImageCache() {
|
|
953
|
+
if (!hasIndexedDB()) return;
|
|
954
|
+
try {
|
|
955
|
+
const db = await openDb();
|
|
956
|
+
await new Promise((resolve, reject) => {
|
|
957
|
+
const tx = db.transaction(STORE_NAME, "readwrite");
|
|
958
|
+
const store = tx.objectStore(STORE_NAME);
|
|
959
|
+
const req = store.clear();
|
|
960
|
+
req.onsuccess = () => resolve();
|
|
961
|
+
req.onerror = () => reject(req.error);
|
|
962
|
+
});
|
|
963
|
+
} catch {
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
|
|
781
967
|
// src/atlas/symbols.ts
|
|
782
968
|
var SIZE = 32;
|
|
783
969
|
function svg(inner) {
|
|
@@ -3207,9 +3393,13 @@ async function loadThemedBridgeImages(map, colorTable) {
|
|
|
3207
3393
|
await Promise.all(promises);
|
|
3208
3394
|
}
|
|
3209
3395
|
export {
|
|
3396
|
+
clearS52SymbolImageCache,
|
|
3397
|
+
getS52AtlasVersion,
|
|
3210
3398
|
loadS52SymbolImages,
|
|
3399
|
+
loadS52SymbolImagesCached,
|
|
3211
3400
|
loadSymbolImages,
|
|
3212
3401
|
loadThemedBridgeImages,
|
|
3213
|
-
reloadS52SymbolImages
|
|
3402
|
+
reloadS52SymbolImages,
|
|
3403
|
+
reloadS52SymbolImagesCached
|
|
3214
3404
|
};
|
|
3215
3405
|
//# sourceMappingURL=browser.js.map
|