@aguacerowx/mapsgl 0.0.47 → 0.0.48

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aguacerowx/mapsgl",
3
- "version": "0.0.47",
3
+ "version": "0.0.48",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -7,8 +7,34 @@ import pkg from '../package.json' with { type: 'json' };
7
7
  export const JSDELIVR_BASIS_BASE_URL = `https://cdn.jsdelivr.net/npm/@aguacerowx/mapsgl@${pkg.version}/basis/`;
8
8
 
9
9
  /**
10
- * Default: resolve `mapsgl/basis/` relative to this module. In Vite production builds this becomes
11
- * your app origin `/basis/`, so place copies under `public/basis/` (or sync from `node_modules/@aguacerowx/mapsgl/basis`).
10
+ * Default: resolve `mapsgl/basis/` inside this package.
11
+ *
12
+ * We cannot use `new URL('..', new URL('.', import.meta.url))`: Vite aliases `@aguacerowx/mapsgl` to
13
+ * `mapsgl/index.js`, so the "directory" of this module is often `.../mapsgl/` and `..` becomes the
14
+ * monorepo `packages/` folder — wrong (`packages/basis/` instead of `packages/mapsgl/basis/`).
15
+ * Webpack also rejects `new URL('../basis/', import.meta.url)` as an unresolved module, so we locate
16
+ * the `mapsgl` path segment and append `basis/`.
17
+ *
18
+ * In Vite production builds the folder URL becomes your app origin `/basis/`, so place copies under
19
+ * `public/basis/` (or sync from `node_modules/@aguacerowx/mapsgl/basis`).
12
20
  * For CDN-only, pass {@link JSDELIVR_BASIS_BASE_URL} as `WeatherLayerManager({ basisBaseUrl: ... })`.
13
21
  */
14
- export const DEFAULT_BASIS_BASE_URL = new URL(/* @vite-ignore */ '../basis/', import.meta.url).href;
22
+ const _mapsglRootHref = (() => {
23
+ const u = import.meta.url;
24
+ const slashIdx = u.indexOf('/mapsgl/');
25
+ if (slashIdx >= 0) {
26
+ return u.slice(0, slashIdx + '/mapsgl/'.length);
27
+ }
28
+ // e.g. cdn.jsdelivr.net/.../mapsgl@0.0.47/dist/... (no `/mapsgl/` substring)
29
+ const atMatch = u.match(/\/mapsgl@[^/]+\//);
30
+ if (atMatch && atMatch.index !== undefined) {
31
+ return u.slice(0, atMatch.index + atMatch[0].length);
32
+ }
33
+ const srcMarker = '/src/';
34
+ const j = u.lastIndexOf(srcMarker);
35
+ if (j >= 0) {
36
+ return `${u.slice(0, j)}/`;
37
+ }
38
+ return new URL('../', new URL('.', u)).href;
39
+ })();
40
+ export const DEFAULT_BASIS_BASE_URL = new URL('basis/', _mapsglRootHref).href;