@geolonia/embed 6.0.0-pre.3 → 6.0.0-pre.5

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.
Files changed (40) hide show
  1. package/.github/dependabot.yml +89 -0
  2. package/.github/workflows/build.yml +84 -32
  3. package/.pinact.yml +80 -0
  4. package/.tool-versions +1 -0
  5. package/CHANGELOG.md +26 -0
  6. package/README.md +47 -9
  7. package/dist/embed +1 -1
  8. package/dist/embed-chunks/00ecbfa5ec913dd002fb.js +2 -0
  9. package/dist/embed-chunks/4574b15eb540c5efc533.js +1 -0
  10. package/dist/embed-chunks/4b5b1b54a5dac816ef15.js +1 -0
  11. package/dist/embed-chunks/52e84382012e7ba206d5.js +2 -0
  12. package/dist/embed-chunks/d1fe32cb4bfb0e9c6575.js +1 -0
  13. package/dist/embed-chunks/ffdb8e820d823ee3571c.js +1 -0
  14. package/dist/embed-core.d.ts +4 -1
  15. package/dist/embed-core.js +1 -1
  16. package/dist/embed-core.js.LICENSE.txt +3 -3
  17. package/dist/embed.js +1 -1
  18. package/dist/embed.js.LICENSE.txt +3 -3
  19. package/dist/lib/maplibre-worker.d.ts +26 -0
  20. package/dist/version.d.ts +1 -1
  21. package/e2e/helper.ts +2 -1
  22. package/e2e/production-bundle.spec.ts +56 -0
  23. package/e2e/umd-worker.spec.ts +27 -0
  24. package/package.json +24 -23
  25. package/playwright.config.ts +1 -1
  26. package/pnpm-workspace.yaml +23 -0
  27. package/src/embed-core.ts +8 -1
  28. package/src/embed.ts +5 -0
  29. package/src/lib/maplibre-worker.ts +52 -0
  30. package/src/testability.test.ts +2 -1
  31. package/src/version.ts +1 -1
  32. package/webpack.config.js +62 -1
  33. package/dist/embed-chunks/1492645e3d07fd3de940.js +0 -1
  34. package/dist/embed-chunks/4ada77b78cc0cc5ccef9.js +0 -1
  35. package/dist/embed-chunks/6e05bbf5f391fda5b858.js +0 -1
  36. package/dist/embed-chunks/8176630945512b29f294.js +0 -2
  37. package/dist/embed-chunks/c783fffcd28083f7d5cb.js +0 -2
  38. package/dist/embed-chunks/f2124097fda51d0079ee.js +0 -1
  39. /package/dist/embed-chunks/{8176630945512b29f294.js.LICENSE.txt → 00ecbfa5ec913dd002fb.js.LICENSE.txt} +0 -0
  40. /package/dist/embed-chunks/{c783fffcd28083f7d5cb.js.LICENSE.txt → 52e84382012e7ba206d5.js.LICENSE.txt} +0 -0
@@ -1,4 +1,4 @@
1
1
  /**
2
- * MapLibre GL JS
3
- * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v5.19.0/LICENSE.txt
4
- */
2
+ * MapLibre GL JS
3
+ * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v6.12.0/LICENSE.txt
4
+ */
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @file UMD バンドルで maplibre-gl v6 の worker を動かすための設定。
3
+ *
4
+ * maplibre-gl v6 は worker を `import.meta.url` 基準の実 URL として解決しますが、
5
+ * webpack の `library.type: 'umd'` 出力では `import.meta.url` がビルド時に
6
+ * ビルドマシンのファイルパス (`file:///...`) へ置換されます。maplibre はこれを
7
+ * `https?:` でないと判断して worker URL を空文字へフォールバックするため、
8
+ * **例外もコンソールエラーも出ないまま地図だけが表示されない** 状態になります。
9
+ *
10
+ * embed は「1 ファイルを置くだけで動く」ことが利点なので、worker を別ファイルとして
11
+ * 配るのではなくバンドルへ文字列として埋め込み、実行時に Blob URL 化して maplibre へ
12
+ * 渡します。埋め込む中身は `webpack.config.js` の `bundleMaplibreWorkerSource()` が
13
+ * esbuild で自己完結する 1 ファイルへ束ねたものです(maps-core の `src/umd.ts` と同じ方式)。
14
+ *
15
+ * Blob worker を使うため、CSP を設定しているページでは `worker-src blob:` が必要です。
16
+ *
17
+ * @see https://github.com/geolonia/embed/issues/518
18
+ */
19
+ /**
20
+ * 埋め込んだ worker を Blob URL 化して maplibre に登録する。
21
+ *
22
+ * 置換されていない環境(vitest など webpack を通らない実行)や、ブラウザ外
23
+ * (SSR。Node にも Blob / URL.createObjectURL はあるので window で判定する)
24
+ * では何もしない。その場合は maplibre 既定の解決にそのまま任せる。
25
+ */
26
+ export declare const installMaplibreWorker: () => void;
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "6.0.0-pre.3";
1
+ export declare const VERSION = "6.0.0-pre.5";
package/e2e/helper.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Page } from '@playwright/test';
2
2
 
3
- export const TEST_URL = 'http://localhost:3000/e2e';
3
+ export const BASE_URL = 'http://localhost:3000';
4
+ export const TEST_URL = `${BASE_URL}/e2e`;
4
5
  export const LOAD_TIMEOUT = 5000;
5
6
 
6
7
  /** 地図コンテナと canvas の出現を待つ。既存テスト互換。 */
@@ -0,0 +1,56 @@
1
+ import { test, expect } from '@playwright/test';
2
+ import { BASE_URL, TEST_URL, mockGeoloniaTiles, waitForStyleLoad } from './helper';
3
+
4
+ /**
5
+ * production 出力 (`dist/embed.js` を docs/ へコピーしたもの) を直接読み込んで検証する。
6
+ *
7
+ * 他の spec が読む `../embed` は dev サーバーが生成するバンドルで、mode も
8
+ * minify も production とは別物。配布するのは production 出力のほうなのに、
9
+ * これまでどこでも実行されていなかった。
10
+ *
11
+ * minify やローダーの更新で production だけが壊れる事故を拾うのが目的。実際
12
+ * #527 の css-loader 7 / style-loader 4 への更新では、production バンドルが
13
+ * CSS を注入できるかを確かめる手段が無く、その場限りのテストを書いて確認していた。
14
+ */
15
+ const BUNDLE_URL = `${BASE_URL}/embed.js`;
16
+
17
+ test.describe('production バンドル', () => {
18
+ test('地図が描画され、CSS が注入される', async ({ page, request }) => {
19
+ // `docs/embed.js` は .gitignore 対象で、`pnpm run build` でしか作られない。
20
+ // CI は build ジョブの成果物を展開しているので、無ければ設定の不備として落とす。
21
+ const bundle = await request.get(BUNDLE_URL);
22
+ if (!bundle.ok()) {
23
+ if (process.env.CI) {
24
+ throw new Error(
25
+ `${BUNDLE_URL} が ${bundle.status()} を返しました。` +
26
+ 'e2e ジョブで build ジョブの成果物が展開されているか確認してください。',
27
+ );
28
+ }
29
+ test.skip(
30
+ true,
31
+ '`pnpm run build` を実行すると production バンドルの検証が走ります',
32
+ );
33
+ }
34
+
35
+ const errors: string[] = [];
36
+ page.on('pageerror', (e) => errors.push(e.message));
37
+
38
+ await mockGeoloniaTiles(page);
39
+ await page.goto(`${TEST_URL}/production-bundle.html`);
40
+ await waitForStyleLoad(page, '#map');
41
+
42
+ await expect(page.locator('#map canvas')).toBeVisible();
43
+
44
+ // style-loader が maplibre の CSS を <style> として注入しているか。
45
+ // ローダーの更新でここが壊れるとコントロール類の見た目だけが崩れ、
46
+ // canvas は出るので気づきにくい。
47
+ const injectedMaplibreCss = await page.evaluate(() =>
48
+ [...document.querySelectorAll('style')].some((s) =>
49
+ s.textContent?.includes('maplibregl-ctrl'),
50
+ ),
51
+ );
52
+ expect(injectedMaplibreCss).toBe(true);
53
+
54
+ expect(errors).toEqual([]);
55
+ });
56
+ });
@@ -0,0 +1,27 @@
1
+ import { test, expect } from '@playwright/test';
2
+ import { TEST_URL, mockGeoloniaTiles, waitForStyleLoad } from './helper';
3
+
4
+ /**
5
+ * embed は UMD で配る。maplibre-gl v6 の worker は `import.meta.url` 基準で解決される
6
+ * が、UMD 出力では webpack が `import.meta.url` をビルドマシンのファイルパスへ置換する
7
+ * ため、maplibre は worker URL を空文字へフォールバックする。この失敗は例外もコンソール
8
+ * エラーも出さず「地図だけが出ない」形で現れるので、worker が実際に登録されているかを
9
+ * 明示的に確かめる (#518)。
10
+ *
11
+ * 実体は `src/lib/maplibre-worker.ts` が worker をバンドル内の文字列から Blob URL 化して
12
+ * `setWorkerUrl()` に渡している。
13
+ */
14
+ test.describe('UMD バンドルの maplibre worker (#518)', () => {
15
+ test('worker URL が Blob URL として登録され、スタイルが読み込まれる', async ({
16
+ page,
17
+ }) => {
18
+ await mockGeoloniaTiles(page);
19
+ await page.goto(`${TEST_URL}/basic.html`);
20
+ await waitForStyleLoad(page, '#map');
21
+
22
+ const workerUrl = await page.evaluate(() =>
23
+ (window as any).geolonia.getWorkerUrl(),
24
+ );
25
+ expect(workerUrl).toMatch(/^blob:/);
26
+ });
27
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geolonia/embed",
3
- "version": "6.0.0-pre.3",
3
+ "version": "6.0.0-pre.5",
4
4
  "description": "Geolonia embed JS API",
5
5
  "main": "dist/embed.js",
6
6
  "types": "dist/src/embed.d.ts",
@@ -14,18 +14,6 @@
14
14
  "default": "./dist/embed-core.js"
15
15
  }
16
16
  },
17
- "scripts": {
18
- "start": "MAP_PLATFORM_STAGE=v1 webpack serve --config ./docs/webpack.config.js",
19
- "build": "npm run build:version && npm run build:embed",
20
- "build:version": "node ./scripts/build-version.mjs",
21
- "build:embed": "MAP_PLATFORM_STAGE=v1 webpack --mode production && cp ./dist/embed.js ./dist/embed && cp -r ./dist/* ./docs/ && rm -rf ./docs/*.d.ts ./docs/lib/",
22
- "analyze": "ANALYZE=true MAP_PLATFORM_STAGE=v1 webpack --mode production",
23
- "format": "prettier \"./src/**/*.ts\" --write",
24
- "lint": "eslint .",
25
- "test": "vitest run",
26
- "e2e": "playwright test",
27
- "docs:api": "typedoc"
28
- },
29
17
  "author": "Geolonia (https://geolonia.com)",
30
18
  "repository": {
31
19
  "type": "git",
@@ -40,12 +28,13 @@
40
28
  "@eslint/compat": "^1.4.1",
41
29
  "@eslint/eslintrc": "^3.3.1",
42
30
  "@eslint/js": "^9.39.1",
31
+ "@types/geojson": "^7946.0.16",
43
32
  "@types/jsdom": "^21.1.7",
44
33
  "@types/node": "^24.0.4",
45
34
  "@typescript-eslint/eslint-plugin": "^8.46.4",
46
35
  "@typescript-eslint/parser": "^8.46.4",
47
- "babel-loader": "^9.1.0",
48
- "css-loader": "^6.7.2",
36
+ "css-loader": "^7.1.5",
37
+ "esbuild": "^0.28.2",
49
38
  "eslint": "^9.39.1",
50
39
  "eslint-config-prettier": "^10.1.8",
51
40
  "eslint-plugin-import": "^2.32.0",
@@ -53,10 +42,10 @@
53
42
  "eslint-plugin-react": "^7.37.5",
54
43
  "eslint-plugin-react-hooks": "^7.0.1",
55
44
  "globals": "^16.5.0",
56
- "jsdom": "^20.0.3",
45
+ "jsdom": "^29.1.1",
57
46
  "node-fetch": "2",
58
47
  "prettier": "^3.6.2",
59
- "style-loader": "^3.3.1",
48
+ "style-loader": "^4.0.0",
60
49
  "svg-inline-loader": "^0.8.2",
61
50
  "ts-loader": "^9.4.3",
62
51
  "typedoc": "^0.28.20",
@@ -64,13 +53,25 @@
64
53
  "typescript": "^5.1.3",
65
54
  "vitest": "^4.1.1",
66
55
  "webpack": "^5.75.0",
67
- "webpack-bundle-analyzer": "^4.7.0",
68
- "webpack-cli": "^5.0.1",
69
- "webpack-dev-server": "^4.11.1"
56
+ "webpack-bundle-analyzer": "^5.4.0",
57
+ "webpack-cli": "^7.2.3",
58
+ "webpack-dev-server": "^6.0.0"
70
59
  },
71
60
  "dependencies": {
72
- "@geolonia/maps-core": "^0.5.1",
61
+ "@geolonia/maps-core": "^0.6.0",
73
62
  "@playwright/test": "^1.61.1",
74
- "maplibre-gl": "5.19.0"
63
+ "maplibre-gl": "6.12.0"
64
+ },
65
+ "scripts": {
66
+ "start": "MAP_PLATFORM_STAGE=v1 webpack serve --config ./docs/webpack.config.js",
67
+ "build": "pnpm run build:version && pnpm run build:embed",
68
+ "build:version": "node ./scripts/build-version.mjs",
69
+ "build:embed": "MAP_PLATFORM_STAGE=v1 webpack --mode production && cp ./dist/embed.js ./dist/embed && cp -r ./dist/* ./docs/ && rm -rf ./docs/*.d.ts ./docs/lib/",
70
+ "analyze": "ANALYZE=true MAP_PLATFORM_STAGE=v1 webpack --mode production",
71
+ "format": "prettier \"./src/**/*.ts\" --write",
72
+ "lint": "eslint .",
73
+ "test": "vitest run",
74
+ "e2e": "playwright test",
75
+ "docs:api": "typedoc"
75
76
  }
76
- }
77
+ }
@@ -46,7 +46,7 @@ export default defineConfig({
46
46
 
47
47
  /* Run your local dev server before starting the tests */
48
48
  webServer: {
49
- command: 'npm run start',
49
+ command: 'pnpm run start',
50
50
  url: 'http://localhost:3000',
51
51
  reuseExistingServer: !process.env.CI,
52
52
  },
@@ -0,0 +1,23 @@
1
+ # pnpm の設定ファイル。pnpm 11 以降、これらの設定は .npmrc ではなくここで指定する。
2
+ #
3
+ # ignoreScripts: 依存パッケージのライフサイクルスクリプトを実行しない。
4
+ # 以前は .npmrc の `ignore-scripts=true` で同じことをしていたが、pnpm は .npmrc の
5
+ # この設定を読まないため移設した。設定が無いと pnpm は esbuild のビルドスクリプトを
6
+ # 無視したことを ERR_PNPM_IGNORED_BUILDS として扱い、install が失敗する。
7
+ # esbuild は 0.25 以降プラットフォーム別パッケージを optionalDependencies で解決するので、
8
+ # ビルドスクリプトを実行しなくても動作する。
9
+ ignoreScripts: true
10
+
11
+ # pmOnFail: `packageManager` のバージョン不一致チェックをスキップする
12
+ # (pnpm のドキュメント上は旧 `managePackageManagerVersions: false` 相当)。
13
+ #
14
+ # 既定の `download` だと、pnpm 12 は宣言された pnpm 自身を解決するための
15
+ # "env lockfile" を pnpm-lock.yaml の 1 つ目の YAML ドキュメントとして書く。
16
+ # GitHub の依存グラフの静的パーサーは 1 つ目しか読まないため、グラフには
17
+ # pnpm と @pnpm/exe.* だけが載り、npm パッケージが 1 つも入らなくなる。
18
+ # その結果 Dependabot アラートも届かない (dependabot/dependabot-core#15904)。
19
+ #
20
+ # `ignore` にすると env lockfile が作られず lock は単一ドキュメントに戻るので、
21
+ # パーサーが実依存を読めるようになる。
22
+ # CI は pnpm/action-setup が packageManager を読んで版を揃えるため影響はない。
23
+ pmOnFail: ignore
package/src/embed-core.ts CHANGED
@@ -1,12 +1,19 @@
1
1
  /**
2
- * @file Side-effect-free entry point for programmatic use (e.g. React wrapper).
2
+ * @file Entry point for programmatic use (e.g. React wrapper).
3
3
  * Does NOT call renderGeoloniaMap() or set window.geolonia.
4
4
  *
5
5
  * The Geolonia core (map, marker, simplestyle, keyring, PMTiles protocol
6
6
  * registration, ...) now lives in `@geolonia/maps-core`; this entry simply
7
7
  * re-exports it alongside embed-specific helpers (registerPlugin, version).
8
+ *
9
+ * 唯一の副作用として、UMD 出力で maplibre が worker を解決できない問題への対処
10
+ * (`installMaplibreWorker()`) をここで行う。詳細は `./lib/maplibre-worker` を参照。
8
11
  */
9
12
 
13
+ import { installMaplibreWorker } from './lib/maplibre-worker';
14
+
15
+ installMaplibreWorker();
16
+
10
17
  export {
11
18
  GeoloniaMap,
12
19
  GeoloniaMarker,
package/src/embed.ts CHANGED
@@ -5,6 +5,7 @@
5
5
  import * as maplibregl from 'maplibre-gl';
6
6
  import { GeoloniaMap, GeoloniaMarker, SimpleStyle } from '@geolonia/maps-core';
7
7
  import { VERSION as embedVersion } from './version';
8
+ import { installMaplibreWorker } from './lib/maplibre-worker';
8
9
  import { registerPlugin, renderGeoloniaMap } from './lib/render';
9
10
 
10
11
  export type { GeoloniaMapOptions } from '@geolonia/maps-core';
@@ -33,6 +34,10 @@ declare global {
33
34
  }
34
35
  }
35
36
 
37
+ // UMD 出力では maplibre が worker を自力で解決できない。地図を作る前に
38
+ // バンドルへ埋め込んだ worker を登録する (#518)。
39
+ installMaplibreWorker();
40
+
36
41
  const geolonia: Geolonia = Object.assign(window.geolonia || {}, maplibregl, {
37
42
  Map: GeoloniaMap,
38
43
  Marker: GeoloniaMarker,
@@ -0,0 +1,52 @@
1
+ /**
2
+ * @file UMD バンドルで maplibre-gl v6 の worker を動かすための設定。
3
+ *
4
+ * maplibre-gl v6 は worker を `import.meta.url` 基準の実 URL として解決しますが、
5
+ * webpack の `library.type: 'umd'` 出力では `import.meta.url` がビルド時に
6
+ * ビルドマシンのファイルパス (`file:///...`) へ置換されます。maplibre はこれを
7
+ * `https?:` でないと判断して worker URL を空文字へフォールバックするため、
8
+ * **例外もコンソールエラーも出ないまま地図だけが表示されない** 状態になります。
9
+ *
10
+ * embed は「1 ファイルを置くだけで動く」ことが利点なので、worker を別ファイルとして
11
+ * 配るのではなくバンドルへ文字列として埋め込み、実行時に Blob URL 化して maplibre へ
12
+ * 渡します。埋め込む中身は `webpack.config.js` の `bundleMaplibreWorkerSource()` が
13
+ * esbuild で自己完結する 1 ファイルへ束ねたものです(maps-core の `src/umd.ts` と同じ方式)。
14
+ *
15
+ * Blob worker を使うため、CSP を設定しているページでは `worker-src blob:` が必要です。
16
+ *
17
+ * @see https://github.com/geolonia/embed/issues/518
18
+ */
19
+
20
+ import { setWorkerUrl } from 'maplibre-gl';
21
+
22
+ /** webpack の DefinePlugin がビルド時に worker のソース文字列へ置換する。 */
23
+ declare const __MAPLIBRE_WORKER_SOURCE__: string;
24
+
25
+ /**
26
+ * 埋め込んだ worker を Blob URL 化して maplibre に登録する。
27
+ *
28
+ * 置換されていない環境(vitest など webpack を通らない実行)や、ブラウザ外
29
+ * (SSR。Node にも Blob / URL.createObjectURL はあるので window で判定する)
30
+ * では何もしない。その場合は maplibre 既定の解決にそのまま任せる。
31
+ */
32
+ export const installMaplibreWorker = (): void => {
33
+ const source =
34
+ typeof __MAPLIBRE_WORKER_SOURCE__ === 'string'
35
+ ? __MAPLIBRE_WORKER_SOURCE__
36
+ : '';
37
+ if (!source) {
38
+ return;
39
+ }
40
+ if (
41
+ typeof window === 'undefined' ||
42
+ typeof Blob === 'undefined' ||
43
+ typeof URL === 'undefined' ||
44
+ typeof URL.createObjectURL !== 'function'
45
+ ) {
46
+ return;
47
+ }
48
+
49
+ setWorkerUrl(
50
+ URL.createObjectURL(new Blob([source], { type: 'text/javascript' })),
51
+ );
52
+ };
@@ -1,7 +1,8 @@
1
1
  import { describe, it, expect, vi } from 'vitest';
2
2
  import { JSDOM } from 'jsdom';
3
3
 
4
- import maplibregl from 'maplibre-gl';
4
+ // maplibre-gl v6 にデフォルトエクスポートは無いので名前空間でインポートする。
5
+ import * as maplibregl from 'maplibre-gl';
5
6
 
6
7
  /**
7
8
  * このテストは、jsdom環境ではmaplibre-glのMapインスタンスが
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '6.0.0-pre.2';
1
+ export const VERSION = '6.0.0-pre.5';
package/webpack.config.js CHANGED
@@ -1,10 +1,62 @@
1
1
  const path = require('path');
2
2
  const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
3
- const { DefinePlugin } = require('webpack');
3
+ const { BannerPlugin, DefinePlugin } = require('webpack');
4
+ const esbuild = require('esbuild');
5
+
6
+ /**
7
+ * maplibre-gl v6 の worker を、依存する `maplibre-gl-shared.mjs` ごと自己完結する
8
+ * 1 ファイルへ束ね、その中身を文字列として返す。
9
+ *
10
+ * v6 の worker は `import.meta.url` 基準の実 URL として解決されるが、UMD 出力では
11
+ * webpack が `import.meta.url` をビルドマシンの `file:///...` へ置換してしまい、
12
+ * maplibre はそれを `https?:` でないと判断して worker URL を空文字へフォールバックする
13
+ * (例外もエラーも出ないまま地図だけが出ない)。UMD の利点である単一ファイル配布を保つため、
14
+ * 別ファイルを配るのではなくバンドルへ埋め込む。`src/lib/maplibre-worker.ts` を参照。
15
+ *
16
+ * @see https://github.com/geolonia/embed/issues/518
17
+ * @returns {string} worker のソースコード
18
+ */
19
+ const bundleMaplibreWorkerSource = () => {
20
+ const result = esbuild.buildSync({
21
+ entryPoints: [require.resolve('maplibre-gl/dist/maplibre-gl-worker.mjs')],
22
+ bundle: true,
23
+ format: 'esm',
24
+ minify: true,
25
+ write: false,
26
+ });
27
+ return result.outputFiles[0].text;
28
+ };
29
+
30
+ /**
31
+ * バンドルした maplibre-gl のライセンス表記。
32
+ *
33
+ * maplibre-gl のソース先頭には `@license` コメントがあり、通常は terser の
34
+ * extractComments が `<bundle>.js.LICENSE.txt` へ切り出す。ただし terser はコメント単体
35
+ * ではなく「コメントが付いているコード」を基準に扱うため、そのコードが削除・並べ替えされると
36
+ * コメントごと消え、extractComments まで届かない。
37
+ *
38
+ * embed.js は `Object.assign(..., maplibregl, ...)` で名前空間を丸ごと使うので偶然残るが、
39
+ * embed-core.js は一部のシンボルしか使わないため消える。実際 6.0.0-pre.4 の
40
+ * `dist/embed-core.js` は maplibre を同梱しながらライセンス表記が無い状態で公開された
41
+ * (6.0.0-pre.3 までは残っていた)。偶然に頼らず明示する。
42
+ *
43
+ * バージョンは maplibre-gl から読むので手で追従する必要はない。maplibre を同梱しなくなったら
44
+ * この banner も外すこと。
45
+ */
46
+ const maplibreLicenseBanner = `/**
47
+ * MapLibre GL JS
48
+ * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v${require('maplibre-gl/package.json').version}/LICENSE.txt
49
+ */`;
4
50
 
5
51
  const plugins = [
6
52
  new DefinePlugin({
7
53
  'process.env.MAP_PLATFORM_STAGE': JSON.stringify(process.env.MAP_PLATFORM_STAGE || 'dev'),
54
+ __MAPLIBRE_WORKER_SOURCE__: JSON.stringify(bundleMaplibreWorkerSource()),
55
+ }),
56
+ new BannerPlugin({
57
+ banner: maplibreLicenseBanner,
58
+ raw: true,
59
+ entryOnly: true,
8
60
  }),
9
61
  ];
10
62
  if (process.env.ANALYZE === 'true') {
@@ -15,6 +67,15 @@ const sharedConfig = {
15
67
  plugins: plugins,
16
68
  module: {
17
69
  rules: [
70
+ {
71
+ // maplibre-gl v6 は worker URL のフォールバック経路で
72
+ // `new URL(expr, import.meta.url)` を使う。webpack はこれを解決できない
73
+ // asset 参照と見なして "Critical dependency" を警告し、dist ディレクトリ全体の
74
+ // context module を作る。worker は DefinePlugin による埋め込みで解決済みで
75
+ // この経路には到達しないため、maplibre に限って `new URL()` の asset 解釈を切る。
76
+ test: /[\\/]node_modules[\\/]maplibre-gl[\\/].+\.mjs$/,
77
+ parser: { url: false },
78
+ },
18
79
  {
19
80
  test: /\.svg$/,
20
81
  use: {
@@ -1 +0,0 @@
1
- (self.webpackChunkgeoloniaEmbedCore=self.webpackChunkgeoloniaEmbedCore||[]).push([[445],{197:()=>{},1866:()=>{},2739:()=>{},9746:()=>{},9977:()=>{}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunkgeoloniaEmbed=self.webpackChunkgeoloniaEmbed||[]).push([[521],{7521:(e,t,s)=>{s.d(t,{default:()=>h});const l={altKey:{en:"alt",ja:"Alt"},ctrlKey:{en:"Ctrl",ja:"Ctrl"},metaKey:{en:"⌘",ja:"⌘"}},n={en:e=>({wheel:`Use ${l[e].en} + scroll to zoom the map.`,touch:"Use two fingers to move the map."}),ja:e=>({wheel:`${l[e].ja} キーを押しながらスクロールしてください。`,touch:"2本指を使って操作してください。"})};function i(e){const t=function(e){switch(e){case"alt":return"altKey";case"ctrl":return"ctrlKey";case"meta":return"metaKey";default:return function(){const e=navigator.userAgentData;return e?.platform?"macOS"===e.platform:/mac/i.test(navigator.platform)}()?"metaKey":"ctrlKey"}}(e.modifierKey),s="auto"!==e.lang&&e.lang?e.lang:function(){const e=(navigator.languages?.[0]??navigator.language).toLowerCase();return"ja"===e||"ja-jp"===e?"ja":"en"}(),l=n[s](t);return{backgroundColor:e.backgroundColor??"rgba(0, 0, 0, 0.8)",textColor:e.textColor??"#ffffff",textMessage:e.textMessage??l.wheel,textMessageMobile:e.textMessageMobile??l.touch,timeout:e.timeout??2e3,modifierKey:t}}const h=class{constructor(e={}){this.fullscreen=!1,this.timer=null,this.settings=i(e),this.handleWheel=this.onWheel.bind(this),this.handleHelpWheel=this.onHelpWheel.bind(this),this.handleHelpTouchStart=this.onHelpTouchStart.bind(this),this.handleMoveStart=this.onMoveStart.bind(this),this.handleFullscreenChange=this.onFullscreenChange.bind(this)}onAdd(e){this.map=e;const t=document.createElement("div");t.className="gesture-handling-help-overlay",t.style.backgroundColor=this.settings.backgroundColor,t.style.position="absolute",t.style.display="none",t.style.zIndex="9999",t.style.justifyContent="center",t.style.alignItems="center";const s=document.createElement("div");s.style.textAlign="center",s.style.color=this.settings.textColor,t.appendChild(s),this.helpElement=t,e.scrollZoom.disable(),t.addEventListener("wheel",this.handleHelpWheel),t.addEventListener("touchstart",this.handleHelpTouchStart,{passive:!1}),e.getContainer().addEventListener("wheel",this.handleWheel),e.on("movestart",this.handleMoveStart),document.addEventListener("fullscreenchange",this.handleFullscreenChange);const l=document.createElement("div");return l.className="maplibregl-ctrl",l.style.display="none",l}onRemove(){this.clearTimer(),this.helpElement&&(this.helpElement.removeEventListener("wheel",this.handleHelpWheel),this.helpElement.removeEventListener("touchstart",this.handleHelpTouchStart),this.hideHelp(),this.helpElement=void 0),this.map&&(this.map.getContainer().removeEventListener("wheel",this.handleWheel),this.map.off("movestart",this.handleMoveStart),this.map.scrollZoom.enable(),this.map=void 0),document.removeEventListener("fullscreenchange",this.handleFullscreenChange)}getDefaultPosition(){return"top-left"}showHelp(e){const t=this.map,s=this.helpElement;if(!t||!s)return;s.style.top="0",s.style.left="0",s.style.width="100%",s.style.height="100%",s.style.display="flex";const l=s.firstElementChild;l&&(l.innerText=e),t.getContainer().appendChild(s)}hideHelp(){const e=this.helpElement;e&&(e.style.display="none",e.remove())}clearTimer(){null!==this.timer&&(clearTimeout(this.timer),this.timer=null)}onWheel(e){const t=this.map;t&&(e[this.settings.modifierKey]||this.fullscreen?(e.preventDefault(),t.scrollZoom.isEnabled()||(t.scrollZoom.reset(),t.scrollZoom.enable())):(t.scrollZoom.disable(),this.showHelp(this.settings.textMessage),this.clearTimer(),this.timer=setTimeout(()=>{this.hideHelp()},this.settings.timeout)))}onHelpWheel(e){e[this.settings.modifierKey]||this.fullscreen?(e.preventDefault(),this.clearTimer(),this.hideHelp()):(this.clearTimer(),this.timer=setTimeout(()=>{this.hideHelp()},this.settings.timeout))}onHelpTouchStart(e){const t=this.map;t&&e.touches&&(e.touches.length>=2||this.fullscreen)&&(this.clearTimer(),this.hideHelp(),t.dragPan.enable(),e.preventDefault())}onMoveStart(e){const t=this.map;t&&e.originalEvent&&"touches"in e.originalEvent&&e.originalEvent.touches.length<2&&!this.fullscreen&&(this.showHelp(this.settings.textMessageMobile),t.dragPan.disable(),this.clearTimer(),this.timer=setTimeout(()=>{t.dragPan.enable(),this.hideHelp()},this.settings.timeout))}onFullscreenChange(){this.fullscreen=!!document.fullscreenElement}}}}]);
@@ -1 +0,0 @@
1
- (self.webpackChunkgeoloniaEmbed=self.webpackChunkgeoloniaEmbed||[]).push([[445],{197:()=>{},1866:()=>{},2739:()=>{},9746:()=>{},9977:()=>{}}]);