@geolonia/maps-core 0.5.1 → 0.7.0

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
@@ -10,7 +10,93 @@ Designed to be side-effect-free and DOM-independent, serving as the shared found
10
10
  npm install @geolonia/maps-core maplibre-gl
11
11
  ```
12
12
 
13
- `maplibre-gl` is a peer dependency.
13
+ `maplibre-gl` is a peer dependency. v6.x is required (`^6.0.0`).
14
+
15
+ This package is ESM-only, following MapLibre GL JS v6. There is no `require()`
16
+ entry point. If you need a script-tag build, use the UMD bundle attached to each
17
+ [GitHub Release](https://github.com/geolonia/maps-core/releases) — it is
18
+ self-contained and needs no worker setup. It does run its worker from a Blob
19
+ URL, so a page with a Content-Security-Policy needs `worker-src blob:`.
20
+
21
+ ### Worker setup
22
+
23
+ MapLibre GL JS v6 ships ESM-only and loads its worker from a real URL resolved
24
+ against `import.meta.url`. Most bundlers do not carry that file over on their
25
+ own, so the map silently never finishes loading unless you point MapLibre at
26
+ the worker yourself. Do this once, before the first map is created.
27
+
28
+ Two files are involved, not one: `maplibre-gl-worker.mjs` is a small shim that
29
+ imports `./maplibre-gl-shared.mjs` as a sibling. That splits the setups in two.
30
+ Run the worker through the bundler's own worker pipeline and it comes out as a
31
+ self-contained chunk, with nothing else to place. Copy or serve the shim
32
+ verbatim instead, and the sibling has to sit next to it in the output — miss it
33
+ and the worker dies on its first import, with no exception and no console error.
34
+
35
+ Vite has such a pipeline, and `?worker&url` is what routes the file through it:
36
+
37
+ ```typescript
38
+ // Vite
39
+ import workerUrl from 'maplibre-gl/dist/maplibre-gl-worker.mjs?worker&url';
40
+ import { setWorkerUrl } from 'maplibre-gl';
41
+
42
+ setWorkerUrl(workerUrl);
43
+ ```
44
+
45
+ Plain `?url` is not enough — it emits the shim verbatim, which puts you in the
46
+ second case without the sibling.
47
+
48
+ webpack is in that second case: copy both files into the output and point at the
49
+ copy. Note that `new URL('maplibre-gl/dist/maplibre-gl-worker.mjs', import.meta.url)`
50
+ does *not* work — webpack emits the shim on its own, leaving the sibling import
51
+ to 404.
52
+
53
+ ```bash
54
+ npm install --save-dev copy-webpack-plugin
55
+ ```
56
+
57
+ ```js
58
+ // webpack.config.js
59
+ const CopyPlugin = require('copy-webpack-plugin');
60
+
61
+ module.exports = {
62
+ plugins: [
63
+ new CopyPlugin({
64
+ patterns: [
65
+ {
66
+ from: require.resolve('maplibre-gl/dist/maplibre-gl-worker.mjs'),
67
+ to: 'maplibre-gl-worker.mjs',
68
+ },
69
+ {
70
+ from: require.resolve('maplibre-gl/dist/maplibre-gl-shared.mjs'),
71
+ to: 'maplibre-gl-shared.mjs',
72
+ },
73
+ ],
74
+ }),
75
+ ],
76
+ };
77
+ ```
78
+
79
+ ```typescript
80
+ import { setWorkerUrl } from 'maplibre-gl';
81
+
82
+ setWorkerUrl('maplibre-gl-worker.mjs');
83
+ ```
84
+
85
+ For esbuild, Rollup and Turbopack, see
86
+ [the MapLibre docs](https://maplibre.org/maplibre-gl-js/docs/) — and work out
87
+ which of the two cases above your setup lands in.
88
+
89
+ Loading MapLibre from a CDN as an ES module needs no setup: the worker URL is
90
+ derived from the module's own URL. Cross-origin, MapLibre starts that worker
91
+ from a same-origin Blob URL, so the page needs `worker-src blob:`. If your CSP
92
+ cannot allow that, host the two worker files yourself and name the worker
93
+ explicitly before creating a map:
94
+
95
+ ```typescript
96
+ import { setWorkerUrl } from 'maplibre-gl';
97
+
98
+ setWorkerUrl('/path/to/maplibre-gl-worker.mjs');
99
+ ```
14
100
 
15
101
  ## Usage
16
102
 
@@ -75,9 +161,51 @@ const map = new GeoloniaMap({
75
161
  clusterColor: '#ff0000',
76
162
  simpleVector: 'my-tileset', // Vector tile URL or tileset ID
77
163
  '3d': false,
164
+ errorMessage: undefined, // Message shown when the map fails to initialize
78
165
  });
79
166
  ```
80
167
 
168
+ #### `errorMessage`
169
+
170
+ When the map cannot be initialized (typically because WebGL is unavailable on the
171
+ device), the container is replaced with a message telling the visitor what to try:
172
+ restart the browser, restart the device, try another browser, update the graphics
173
+ driver, and contact the site owner if it still fails. The message is shortened, and
174
+ finally reduced to the headline alone, as the map container gets smaller.
175
+
176
+ Pass `errorMessage` to take that over:
177
+
178
+ ```typescript
179
+ // Replace the wording. The value is rendered as plain text, not as HTML.
180
+ new GeoloniaMap({ container: '#map', errorMessage: 'Sorry, the map is unavailable.' });
181
+
182
+ // Show nothing at all, e.g. when the page renders its own fallback.
183
+ new GeoloniaMap({ container: '#map', errorMessage: false });
184
+ ```
185
+
186
+ #### `transformRequest`
187
+
188
+ Works like MapLibre's `transformRequest`, and is also called for the requests that maps-core rewrites itself: Geolonia sources (`api.geolonia.com` and the Geolonia tile hosts) and Geolonia sprites. For those, the function receives the URL after maps-core has added `key` and `sessionId`, so the parameters are kept as long as you build on the URL you are given.
189
+
190
+ - Return a `RequestParameters` object to use it as is.
191
+ - Return `undefined` to keep the request maps-core built.
192
+ - A `Promise` may be returned. If it resolves to `undefined`, the request maps-core built is used.
193
+
194
+ ```typescript
195
+ new GeoloniaMap({
196
+ container: '#map',
197
+ transformRequest: (url, resourceType) => {
198
+ // Load another tileset from the Geolonia tile server
199
+ if (resourceType === 'Source' && url.includes('tileserver.geolonia.com/oneself/')) {
200
+ return { url: url.replace('/oneself/', '/my-tileset/') };
201
+ }
202
+ return undefined;
203
+ },
204
+ });
205
+ ```
206
+
207
+ Replacing the function later with `map.setTransformRequest()` also removes the maps-core rewriting, including `key` and `sessionId`.
208
+
81
209
  ### `GeoloniaMarker`
82
210
 
83
211
  Extends `maplibregl.Marker` with Geolonia's default marker style.
@@ -123,7 +251,7 @@ keyring.setStage('v1');
123
251
 
124
252
  ```bash
125
253
  npm install
126
- npm run build # ESM + CJS + DTS
254
+ npm run build # ESM + DTS
127
255
  npm run test # Vitest unit tests
128
256
  npm run e2e # Playwright E2E tests
129
257
  npm run lint # Biome
@@ -1,4 +1,5 @@
1
- import maplibregl, { IControl, ControlPosition, Map, MapOptions, ExpiryData, StyleSpecification, StyleSwapOptions, StyleOptions, GetResourceResponse, MarkerOptions } from 'maplibre-gl';
1
+ import * as maplibregl from 'maplibre-gl';
2
+ import { IControl, ControlPosition, Map, MapOptions, RequestTransformFunction, ExpiryData, StyleSpecification, StyleSwapOptions, StyleOptions, GetResourceResponse, MarkerOptions } from 'maplibre-gl';
2
3
 
3
4
  /**
4
5
  * Shadow DOM を用いたカスタム帰属表示コントロールの実装です。
@@ -161,7 +162,8 @@ type GeoloniaMapOptions = MapOptions & {
161
162
  apiKey?: string;
162
163
  /**
163
164
  * API のステージ(`'dev'` / `'v1'` など)。API エンドポイントの選択に使う。
164
- * @defaultValue `'dev'`
165
+ * 省略時は共有キーリングの現在のステージを使う。別の地図が `stage` を指定してキーリングを変更済みの場合は、その値になる。
166
+ * @defaultValue `'v1'`(キーリングの初期値)
165
167
  */
166
168
  stage?: string;
167
169
  /**
@@ -170,6 +172,18 @@ type GeoloniaMapOptions = MapOptions & {
170
172
  * @defaultValue `'geolonia/basic-v2'`
171
173
  */
172
174
  style?: string;
175
+ /**
176
+ * リクエストを送る直前に URL やヘッダーを書き換える関数。MapLibre の `transformRequest` と同じ形。
177
+ *
178
+ * Geolonia のソース(`api.geolonia.com` と Geolonia のタイルホスト)とスプライトのリクエストでは、
179
+ * maps-core が `key` や `sessionId` を付けた後の URL が渡される。
180
+ * `undefined` を返すと maps-core の変換結果がそのまま使われる。
181
+ * Promise を返してもよい。解決値が `undefined` のときも maps-core の変換結果が使われる。
182
+ *
183
+ * `map.setTransformRequest()` で差し替えると maps-core の変換も外れる。後から変えるときは、
184
+ * maps-core が付ける `key` や `sessionId` を自分で付ける必要がある。
185
+ */
186
+ transformRequest?: RequestTransformFunction | null;
173
187
  /**
174
188
  * ラベルの言語。`'ja'` / `'en'` / `'auto'`(ブラウザ言語に従う)。
175
189
  * `'auto'` または未指定のときは `getLang()` の結果(`'ja'` または `'en'`)になる。
@@ -248,6 +262,13 @@ type GeoloniaMapOptions = MapOptions & {
248
262
  * @defaultValue `false`
249
263
  */
250
264
  "3d"?: boolean;
265
+ /**
266
+ * 地図の初期化に失敗したときに表示する文言。
267
+ * 文字列を指定するとその文言に差し替える(HTML としては解釈しない)。
268
+ * `false` または `'off'` を指定するとエラー表示自体を行わない。
269
+ * 未指定のときは、原因と利用者が試せる復旧手順を示す既定の案内を表示する。
270
+ */
271
+ errorMessage?: string | false;
251
272
  };
252
273
 
253
274
  type GetImageCallback = (error?: Error | null, image?: HTMLImageElement | ImageBitmap | null, expiry?: ExpiryData | null) => void;
package/dist/npm/index.js CHANGED
@@ -7,7 +7,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
7
7
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
8
8
 
9
9
  // src/lib/maplibre-util.ts
10
- import maplibregl from "maplibre-gl";
10
+ import * as maplibregl from "maplibre-gl";
11
11
  var _docStyle, _userSelect, _selectProp, _transformProp;
12
12
  var _DOM = class _DOM {
13
13
  static testProp(props) {
@@ -481,11 +481,11 @@ var GeoloniaControl = class {
481
481
  };
482
482
 
483
483
  // src/lib/geolonia-map.ts
484
- import maplibregl5 from "maplibre-gl";
484
+ import * as maplibregl5 from "maplibre-gl";
485
485
  import { Protocol } from "pmtiles";
486
486
 
487
487
  // src/lib/geolonia-marker.ts
488
- import maplibregl2 from "maplibre-gl";
488
+ import * as maplibregl2 from "maplibre-gl";
489
489
  import tinycolor from "tinycolor2";
490
490
  var MARKER_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 67">
491
491
  <path class="left" d="M26 0C11.664 0 0 11.663 0 26c0 22.14 26 41 26 41V26h0C26 11.663 26 0 26 0z" fill="#E4402F"/>
@@ -536,7 +536,7 @@ var GeoloniaMarker = class extends maplibregl2.Marker {
536
536
  // src/lib/simplestyle.ts
537
537
  import bbox from "@turf/bbox";
538
538
  import turfCenter from "@turf/center";
539
- import maplibregl3 from "maplibre-gl";
539
+ import * as maplibregl3 from "maplibre-gl";
540
540
 
541
541
  // src/lib/keyring.ts
542
542
  var DEFAULT_STAGE = "v1";
@@ -743,15 +743,57 @@ function handleRestrictedMode(map) {
743
743
  container.classList.add("geolonia__restricted-mode-image-container");
744
744
  }
745
745
  }
746
- function handleErrorMode(container) {
746
+ function handleErrorMode(container, options = {}) {
747
+ if (options.message === false) {
748
+ return;
749
+ }
750
+ const message = (options.message ?? "").trim();
751
+ if (message.toLowerCase() === "off") {
752
+ return;
753
+ }
754
+ container.classList.add("geolonia__error-host");
747
755
  const errorContainer = document.createElement("div");
748
756
  errorContainer.classList.add("geolonia__error-container");
749
757
  const div = document.createElement("div");
750
- const h2 = document.createElement("h2");
751
- h2.textContent = "Geolonia Maps";
752
- div.appendChild(h2);
753
758
  div.classList.add("geolonia__error-message");
754
- div.innerHTML += '<div class="geolonia__error-message-description">\u5730\u56F3\u306E\u521D\u671F\u5316\u306B\u5931\u6557\u3057\u307E\u3057\u305F\u3002\u7BA1\u7406\u8005\u306B\u304A\u554F\u3044\u5408\u308F\u305B\u4E0B\u3055\u3044\u3002</div>';
759
+ div.setAttribute("role", "alert");
760
+ const description = document.createElement("div");
761
+ description.classList.add("geolonia__error-message-description");
762
+ if (message) {
763
+ description.textContent = message;
764
+ div.appendChild(description);
765
+ } else {
766
+ const title = document.createElement("h2");
767
+ title.classList.add("geolonia__error-message-title");
768
+ title.textContent = "\u5730\u56F3\u3092\u8868\u793A\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F";
769
+ div.appendChild(title);
770
+ const lead = document.createElement("p");
771
+ lead.classList.add("geolonia__error-message-lead");
772
+ lead.textContent = "\u304A\u4F7F\u3044\u306E\u74B0\u5883\u3067\u5730\u56F3\u306E\u63CF\u753B\u6A5F\u80FD\uFF08WebGL\uFF09\u304C\u5229\u7528\u3067\u304D\u306A\u3044\u72B6\u614B\u306B\u306A\u3063\u3066\u3044\u308B\u53EF\u80FD\u6027\u304C\u3042\u308A\u307E\u3059\u3002\u6B21\u306E\u9806\u306B\u304A\u8A66\u3057\u304F\u3060\u3055\u3044\u3002";
773
+ description.appendChild(lead);
774
+ const steps = document.createElement("ol");
775
+ steps.classList.add("geolonia__error-message-steps");
776
+ for (const step of [
777
+ "\u30D6\u30E9\u30A6\u30B6\u3092\u3059\u3079\u3066\u9589\u3058\u3066\u3001\u958B\u304D\u76F4\u3059",
778
+ "\u30D1\u30BD\u30B3\u30F3\u3084\u30B9\u30DE\u30FC\u30C8\u30D5\u30A9\u30F3\u3092\u518D\u8D77\u52D5\u3059\u308B",
779
+ "\u5225\u306E\u30D6\u30E9\u30A6\u30B6\u3067\u958B\u304F",
780
+ "\u30D1\u30BD\u30B3\u30F3\u306E\u5834\u5408\u306F\u3001\u30B0\u30E9\u30D5\u30A3\u30C3\u30AF\u30C9\u30E9\u30A4\u30D0\u3092\u66F4\u65B0\u3059\u308B"
781
+ ]) {
782
+ const li = document.createElement("li");
783
+ li.textContent = step;
784
+ steps.appendChild(li);
785
+ }
786
+ description.appendChild(steps);
787
+ const contact = document.createElement("p");
788
+ contact.classList.add("geolonia__error-message-contact");
789
+ contact.textContent = "\u89E3\u6C7A\u3057\u306A\u3044\u5834\u5408\u306F\u3001\u3053\u306E\u30B5\u30A4\u30C8\u306E\u7A93\u53E3\u307E\u3067\u3054\u9023\u7D61\u304F\u3060\u3055\u3044\u3002";
790
+ description.appendChild(contact);
791
+ const brief = document.createElement("p");
792
+ brief.classList.add("geolonia__error-message-brief");
793
+ brief.textContent = "\u30D6\u30E9\u30A6\u30B6\u3084\u7AEF\u672B\u3092\u518D\u8D77\u52D5\u3059\u308B\u3068\u89E3\u6D88\u3059\u308B\u5834\u5408\u304C\u3042\u308A\u307E\u3059\u3002";
794
+ description.appendChild(brief);
795
+ div.appendChild(description);
796
+ }
755
797
  errorContainer.appendChild(div);
756
798
  container.appendChild(errorContainer);
757
799
  }
@@ -1267,7 +1309,7 @@ var SimpleStyle = class {
1267
1309
 
1268
1310
  // src/lib/simplestyle-vector.ts
1269
1311
  import turfCenter2 from "@turf/center";
1270
- import maplibregl4 from "maplibre-gl";
1312
+ import * as maplibregl4 from "maplibre-gl";
1271
1313
  var textColor2 = "#000000";
1272
1314
  var textHaloColor2 = "#FFFFFF";
1273
1315
  var backgroundColor2 = "rgba(255, 0, 0, 0.4)";
@@ -1642,6 +1684,61 @@ function normalizeConstructorArg(arg) {
1642
1684
  return arg;
1643
1685
  }
1644
1686
 
1687
+ // src/lib/transform-request.ts
1688
+ function transformGeoloniaRequest(url, resourceType, { apiKey, stage, sessionId: sessionId2, sourcesUrl }) {
1689
+ if (resourceType === "Source" && url.startsWith("https://api.geolonia.com")) {
1690
+ return { url: sourcesUrl, request: { url: sourcesUrl } };
1691
+ }
1692
+ let transformedUrl = url;
1693
+ if (url.startsWith("geolonia://")) {
1694
+ const tilesMatch = url.match(
1695
+ /^geolonia:\/\/tiles\/(?<username>.+)\/(?<customtileId>.+)/
1696
+ );
1697
+ if (tilesMatch?.groups) {
1698
+ transformedUrl = `https://tileserver.geolonia.com/customtiles/${tilesMatch.groups.customtileId}/tiles.json`;
1699
+ }
1700
+ }
1701
+ const transformedUrlObj = new URL(transformedUrl);
1702
+ const geoloniaTilesHost = isGeoloniaTilesHost(transformedUrlObj);
1703
+ if (resourceType === "Source" && geoloniaTilesHost) {
1704
+ if (stage === "dev" && transformedUrlObj.hostname === "tileserver.geolonia.com") {
1705
+ transformedUrlObj.hostname = "tileserver-dev.geolonia.com";
1706
+ }
1707
+ transformedUrlObj.searchParams.set("sessionId", sessionId2);
1708
+ transformedUrlObj.searchParams.set("key", apiKey);
1709
+ const transformed = transformedUrlObj.toString();
1710
+ return { url: transformed, request: { url: transformed } };
1711
+ }
1712
+ if ((resourceType === "SpriteJSON" || resourceType === "SpriteImage") && transformedUrl.match(/^https:\/\/api\.geolonia\.com\/(dev|v1)\/sprites\//)) {
1713
+ const pathParts = transformedUrlObj.pathname.split("/");
1714
+ pathParts[1] = stage;
1715
+ transformedUrlObj.pathname = pathParts.join("/");
1716
+ transformedUrlObj.searchParams.set("key", apiKey);
1717
+ const transformed = transformedUrlObj.toString();
1718
+ return { url: transformed, request: { url: transformed } };
1719
+ }
1720
+ return { url: transformedUrl };
1721
+ }
1722
+ function isThenable(value) {
1723
+ return typeof value === "object" && value !== null && typeof value.then === "function";
1724
+ }
1725
+ function createTransformRequest(context) {
1726
+ const { userTransformRequest } = context;
1727
+ return (url, resourceType) => {
1728
+ const core = transformGeoloniaRequest(url, resourceType, context);
1729
+ if (typeof userTransformRequest !== "function") {
1730
+ return core.request;
1731
+ }
1732
+ const userResult = userTransformRequest(core.url, resourceType);
1733
+ if (isThenable(userResult)) {
1734
+ return Promise.resolve(userResult).then(
1735
+ (resolved) => resolved ?? core.request ?? { url: core.url }
1736
+ );
1737
+ }
1738
+ return userResult ?? core.request;
1739
+ };
1740
+ }
1741
+
1645
1742
  // src/lib/geolonia-map.ts
1646
1743
  var pmtilesRegistered = false;
1647
1744
  function ensurePMTiles() {
@@ -1714,44 +1811,13 @@ var GeoloniaMap = class extends maplibregl5.Map {
1714
1811
  const sourcesUrl = new URL(`${apiUrl}/sources`);
1715
1812
  sourcesUrl.searchParams.set("key", apiKey);
1716
1813
  sourcesUrl.searchParams.set("sessionId", sessionId2);
1717
- const userTransformRequest = options.transformRequest;
1718
- const transformRequest = (url, resourceType) => {
1719
- if (resourceType === "Source" && url.startsWith("https://api.geolonia.com")) {
1720
- return { url: sourcesUrl.toString() };
1721
- }
1722
- let transformedUrl = url;
1723
- if (url.startsWith("geolonia://")) {
1724
- const tilesMatch = url.match(
1725
- /^geolonia:\/\/tiles\/(?<username>.+)\/(?<customtileId>.+)/
1726
- );
1727
- if (tilesMatch?.groups) {
1728
- transformedUrl = `https://tileserver.geolonia.com/customtiles/${tilesMatch.groups.customtileId}/tiles.json`;
1729
- }
1730
- }
1731
- const transformedUrlObj = new URL(transformedUrl);
1732
- const geoloniaTilesHost = isGeoloniaTilesHost(transformedUrlObj);
1733
- if (resourceType === "Source" && geoloniaTilesHost) {
1734
- if (stage === "dev" && transformedUrlObj.hostname === "tileserver.geolonia.com") {
1735
- transformedUrlObj.hostname = "tileserver-dev.geolonia.com";
1736
- }
1737
- transformedUrlObj.searchParams.set("sessionId", sessionId2);
1738
- transformedUrlObj.searchParams.set("key", apiKey);
1739
- return { url: transformedUrlObj.toString() };
1740
- }
1741
- if ((resourceType === "SpriteJSON" || resourceType === "SpriteImage") && transformedUrl.match(
1742
- /^https:\/\/api\.geolonia\.com\/(dev|v1)\/sprites\//
1743
- )) {
1744
- const pathParts = transformedUrlObj.pathname.split("/");
1745
- pathParts[1] = stage;
1746
- transformedUrlObj.pathname = pathParts.join("/");
1747
- transformedUrlObj.searchParams.set("key", apiKey);
1748
- return { url: transformedUrlObj.toString() };
1749
- }
1750
- if (typeof userTransformRequest === "function") {
1751
- return userTransformRequest(transformedUrl, resourceType);
1752
- }
1753
- return void 0;
1754
- };
1814
+ const transformRequest = createTransformRequest({
1815
+ apiKey,
1816
+ stage,
1817
+ sessionId: sessionId2,
1818
+ sourcesUrl: sourcesUrl.toString(),
1819
+ userTransformRequest: options.transformRequest
1820
+ });
1755
1821
  let loading;
1756
1822
  const showLoader = options.loader !== false;
1757
1823
  if (showLoader) {
@@ -1790,14 +1856,16 @@ var GeoloniaMap = class extends maplibregl5.Map {
1790
1856
  "cluster",
1791
1857
  "clusterColor",
1792
1858
  "simpleVector",
1793
- "3d"
1859
+ "3d",
1860
+ "errorMessage"
1794
1861
  ]) {
1795
1862
  delete mapOptions[key];
1796
1863
  }
1797
1864
  try {
1798
1865
  super(mapOptions);
1799
1866
  } catch (error) {
1800
- handleErrorMode(container);
1867
+ container.querySelector(".loading-geolonia-map")?.remove();
1868
+ handleErrorMode(container, { message: options.errorMessage });
1801
1869
  throw error;
1802
1870
  }
1803
1871
  this.geoloniaSourcesUrl = sourcesUrl;
@@ -2011,7 +2079,7 @@ var GeoloniaMap = class extends maplibregl5.Map {
2011
2079
  };
2012
2080
 
2013
2081
  // src/version.ts
2014
- var VERSION = "0.5.1";
2082
+ var VERSION = "0.7.0";
2015
2083
  export {
2016
2084
  attribution_default as CustomAttributionControl,
2017
2085
  DEFAULT_STAGE,
package/package.json CHANGED
@@ -1,15 +1,13 @@
1
1
  {
2
2
  "name": "@geolonia/maps-core",
3
- "version": "0.5.1",
3
+ "version": "0.7.0",
4
4
  "type": "module",
5
- "main": "dist/npm/index.cjs",
6
5
  "module": "dist/npm/index.js",
7
6
  "types": "dist/npm/index.d.ts",
8
7
  "exports": {
9
8
  ".": {
10
9
  "types": "./dist/npm/index.d.ts",
11
- "import": "./dist/npm/index.js",
12
- "require": "./dist/npm/index.cjs"
10
+ "import": "./dist/npm/index.js"
13
11
  },
14
12
  "./css": "./src/assets/style.css"
15
13
  },
@@ -19,29 +17,30 @@
19
17
  ],
20
18
  "dependencies": {
21
19
  "@geolonia/maplibre-gesture-handling": "^3.0.0",
22
- "@turf/bbox": "^7.3.4",
23
- "@turf/center": "^7.3.4",
24
- "pmtiles": "^4.4.0",
25
- "sanitize-html": "^2.17.4",
20
+ "@turf/bbox": "^7.4.0",
21
+ "@turf/center": "^7.4.0",
22
+ "pmtiles": "^4.5.0",
23
+ "sanitize-html": "^2.17.7",
26
24
  "tinycolor2": "^1.4.1"
27
25
  },
28
26
  "peerDependencies": {
29
- "maplibre-gl": "^5.0.0"
27
+ "maplibre-gl": "^6.0.0"
30
28
  },
31
29
  "devDependencies": {
32
- "@biomejs/biome": "^2.0.0",
33
- "@playwright/test": "^1.58.2",
30
+ "@biomejs/biome": "^2.5.14",
31
+ "@playwright/test": "^1.63.0",
34
32
  "@types/sanitize-html": "^2.16.1",
35
33
  "@types/tinycolor2": "^1.4.6",
36
- "@vitest/coverage-v8": "^4.1.2",
37
- "jsdom": "^29.0.1",
38
- "maplibre-gl": "5.24.0",
34
+ "@vitest/coverage-v8": "^5.0.3",
35
+ "esbuild": "^0.28.2",
36
+ "jsdom": "^30.1.1",
37
+ "maplibre-gl": "6.11.2",
39
38
  "tsup": "^8",
40
39
  "typedoc": "^0.28.20",
41
- "typedoc-plugin-markdown": "^4.12.0",
40
+ "typedoc-plugin-markdown": "^4.13.1",
42
41
  "typescript": "^5.8",
43
- "vite": "^8.0.16",
44
- "vitest": "^4.1.2"
42
+ "vite": "^8.3.1",
43
+ "vitest": "^5.0.2"
45
44
  },
46
45
  "scripts": {
47
46
  "build": "tsup",
@@ -112,6 +112,17 @@
112
112
  }
113
113
 
114
114
  /* Style for error message */
115
+
116
+ /* エラー表示の絶対配置が地図コンテナ基準になるようにする。 */
117
+ .geolonia__error-host {
118
+ position: relative;
119
+ }
120
+
121
+ /*
122
+ * 文言は「手順を書き切った版」と「短縮版」の両方が DOM にあり、
123
+ * どちらを見せるかは地図コンテナの広さで切り替える。
124
+ * コンテナクエリ非対応のブラウザでは手順を書き切った版が出る(情報が減る側に倒さない)。
125
+ */
115
126
  .geolonia__error-container {
116
127
  display: flex;
117
128
  justify-content: center;
@@ -121,22 +132,82 @@
121
132
  background-color: #dedede;
122
133
  z-index: 9999;
123
134
  position: absolute;
135
+ container-type: size;
136
+ container-name: geolonia-error;
124
137
  }
125
138
 
126
139
  .geolonia__error-message {
127
- max-width: 300px;
140
+ max-width: 360px;
141
+ max-height: calc(100% - 20px);
142
+ overflow: auto;
128
143
  background-color: #ffffff;
129
144
  margin: 10px;
130
145
  padding: 0.75rem 1.25rem;
131
146
  border-radius: 6px;
132
- position: absolute;
133
147
  z-index: 99999;
134
148
  word-wrap: break-word;
135
149
  box-shadow: 0 4px 10px #0000001a;
150
+ font-size: 14px;
151
+ line-height: 1.6;
152
+ color: #333333;
153
+ }
154
+
155
+ .geolonia__error-message-title {
156
+ margin: 0 0 0.5em;
157
+ font-size: 16px;
158
+ line-height: 1.4;
136
159
  }
137
160
 
138
161
  .geolonia__error-message-description {
139
- margin: 15px 0;
162
+ margin: 0;
163
+ }
164
+
165
+ .geolonia__error-message-lead {
166
+ margin: 0 0 0.5em;
167
+ }
168
+
169
+ .geolonia__error-message-steps {
170
+ margin: 0 0 0.5em;
171
+ padding-left: 1.4em;
172
+ }
173
+
174
+ .geolonia__error-message-contact {
175
+ margin: 0;
176
+ }
177
+
178
+ .geolonia__error-message-brief {
179
+ display: none;
180
+ margin: 0;
181
+ }
182
+
183
+ /* 中くらいの地図:手順リストは収まらないので 1 行の短縮版に切り替える */
184
+ @container geolonia-error ((max-width: 379px) or (max-height: 259px)) {
185
+ .geolonia__error-message-lead,
186
+ .geolonia__error-message-steps,
187
+ .geolonia__error-message-contact {
188
+ display: none;
189
+ }
190
+
191
+ .geolonia__error-message-brief {
192
+ display: block;
193
+ }
194
+ }
195
+
196
+ /* 小さい地図:見出しだけにする */
197
+ @container geolonia-error ((max-width: 239px) or (max-height: 139px)) {
198
+ .geolonia__error-message {
199
+ padding: 0.5rem 0.75rem;
200
+ font-size: 13px;
201
+ }
202
+
203
+ .geolonia__error-message-title {
204
+ margin: 0;
205
+ font-size: 14px;
206
+ }
207
+
208
+ .geolonia__error-message-brief {
209
+ display: none;
210
+ }
140
211
  }
141
212
 
142
213
  /* CSS for Attribution */