@india-boundary-corrector/data 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 CHANGED
@@ -1,5 +1,7 @@
1
1
  # @india-boundary-corrector/data
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/@india-boundary-corrector/data)](https://www.npmjs.com/package/@india-boundary-corrector/data)
4
+
3
5
  PMTiles data package for India boundary corrections.
4
6
 
5
7
  ## Layers
package/index.js CHANGED
@@ -18,6 +18,17 @@ export const layers = {
18
18
  toDelNe: 'to-del-ne',
19
19
  };
20
20
 
21
+ /**
22
+ * Check if a URL hostname should use CDN fallback.
23
+ * Some CDNs like esm.sh don't host static files, so we need to fall back to unpkg.
24
+ * @param {string} hostname - The hostname to check
25
+ * @returns {boolean} True if CDN fallback should be used
26
+ */
27
+ export function shouldUseCdnFallback(hostname) {
28
+ // esm.sh doesn't host static files, only transforms JS modules
29
+ return hostname === 'esm.sh';
30
+ }
31
+
21
32
  /**
22
33
  * Detect the PMTiles URL from various sources:
23
34
  * 1. import.meta.url (for ESM bundlers - most reliable)
@@ -32,6 +43,10 @@ function detectPmtilesUrl() {
32
43
  try {
33
44
  if (typeof import.meta !== 'undefined' && import.meta.url) {
34
45
  const moduleUrl = new URL('.', import.meta.url);
46
+ // Some CDNs don't host static files, fall back to unpkg
47
+ if (shouldUseCdnFallback(moduleUrl.hostname)) {
48
+ return DEFAULT_CDN_URL;
49
+ }
35
50
  return new URL(PMTILES_FILENAME, moduleUrl).href;
36
51
  }
37
52
  } catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@india-boundary-corrector/data",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "PMTiles data for India boundary corrections (NE and OSM layers)",
5
5
  "type": "module",
6
6
  "main": "index.js",
package/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // Auto-generated by scripts/generate-version.js - DO NOT EDIT
2
- export const packageVersion = '0.0.1';
2
+ export const packageVersion = '0.0.2';