@india-boundary-corrector/leaflet-layer 0.0.1 → 0.0.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/README.md +9 -20
- package/dist/index.cjs +6 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.global.js +13 -4
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/index.js +1 -0
package/dist/index.global.js
CHANGED
|
@@ -28,17 +28,23 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
// ../data/version.js
|
|
31
|
-
var packageVersion = "0.0.
|
|
31
|
+
var packageVersion = "0.0.2";
|
|
32
32
|
|
|
33
33
|
// ../data/index.js
|
|
34
34
|
var import_meta = {};
|
|
35
35
|
var PACKAGE_NAME = "@india-boundary-corrector/data";
|
|
36
36
|
var PMTILES_FILENAME = "india_boundary_corrections.pmtiles";
|
|
37
37
|
var DEFAULT_CDN_URL = `https://unpkg.com/${PACKAGE_NAME}@${packageVersion}/${PMTILES_FILENAME}`;
|
|
38
|
+
function shouldUseCdnFallback(hostname) {
|
|
39
|
+
return hostname === "esm.sh";
|
|
40
|
+
}
|
|
38
41
|
function detectPmtilesUrl() {
|
|
39
42
|
try {
|
|
40
43
|
if (typeof import_meta !== "undefined" && import_meta.url) {
|
|
41
44
|
const moduleUrl = new URL(".", import_meta.url);
|
|
45
|
+
if (shouldUseCdnFallback(moduleUrl.hostname)) {
|
|
46
|
+
return DEFAULT_CDN_URL;
|
|
47
|
+
}
|
|
42
48
|
return new URL(PMTILES_FILENAME, moduleUrl).href;
|
|
43
49
|
}
|
|
44
50
|
} catch {
|
|
@@ -2702,7 +2708,7 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
2702
2708
|
if (!maskCanvas || maskCanvas.width !== tileSize || maskCanvas.height !== tileSize) {
|
|
2703
2709
|
maskCanvas = new OffscreenCanvas(tileSize, tileSize);
|
|
2704
2710
|
}
|
|
2705
|
-
const maskCtx = maskCanvas.getContext("2d");
|
|
2711
|
+
const maskCtx = maskCanvas.getContext("2d", { willReadFrequently: true });
|
|
2706
2712
|
maskCtx.fillStyle = "black";
|
|
2707
2713
|
maskCtx.fillRect(0, 0, tileSize, tileSize);
|
|
2708
2714
|
maskCtx.strokeStyle = "white";
|
|
@@ -2904,8 +2910,11 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
2904
2910
|
const useOsm = zoom >= zoomThreshold;
|
|
2905
2911
|
const addLayerName = useOsm ? "to-add-osm" : "to-add-ne";
|
|
2906
2912
|
const delLayerName = useOsm ? "to-del-osm" : "to-del-ne";
|
|
2907
|
-
|
|
2908
|
-
|
|
2913
|
+
if (!this._canvas || this._canvas.width !== tileSize) {
|
|
2914
|
+
this._canvas = new OffscreenCanvas(tileSize, tileSize);
|
|
2915
|
+
}
|
|
2916
|
+
const canvas = this._canvas;
|
|
2917
|
+
const ctx = canvas.getContext("2d", { willReadFrequently: true });
|
|
2909
2918
|
const blob = new Blob([rasterTile]);
|
|
2910
2919
|
const imageBitmap = await createImageBitmap(blob);
|
|
2911
2920
|
ctx.drawImage(imageBitmap, 0, 0, tileSize, tileSize);
|