Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

## @geolonia/embed

### v6.0.0-pre.4

- **Breaking**: バンドルする maplibre-gl を v6 系(`6.11.2`)へ更新しました([#518](https://github.com/geolonia/embed/issues/518))。`@geolonia/maps-core` `^0.6.0` の `peerDependencies` が `maplibre-gl: ^6.0.0` になったことへの追従です。maplibre-gl v6 にデフォルトエクスポートはありません。`window.geolonia` 経由で maplibre の API を直接触っている場合は [maplibre-gl v6 の変更点](https://github.com/maplibre/maplibre-gl-js/releases) を確認してください。
- **Fix**: UMD バンドルで地図が表示されない問題に対処しました。maplibre-gl v6 は worker を `import.meta.url` 基準で解決しますが、UMD 出力では webpack が `import.meta.url` をビルド時に解決してしまうため、実行時に worker を読み込めません。embed は 1 ファイルで完結する配布形態を保つため、worker を esbuild で自己完結する 1 ファイルへ束ねてバンドルへ埋め込み、実行時に Blob URL 化して maplibre に渡します。
- **Note**: このため worker は `blob:` URL から起動します。Content-Security-Policy を設定しているページでは `worker-src blob:` の許可が必要です。
- **Note**: worker を埋め込むぶん配布ファイルが大きくなります。`dist/embed.js` は gzip で約 297 KB → 455 KB になりました。
- **Internal**: `@geolonia/maps-core` `^0.6.0` に依存します。0.6.0 は ESM-only(`main` と `exports.require` を廃止)ですが、embed は webpack で `exports.import` を解決するため影響はありません。
- **Internal**: dependabot の [#498](https://github.com/geolonia/embed/pull/498) 相当のセキュリティ更新を取り込みました(`jsdom` `^29.1.1`、`webpack-dev-server` `^5.2.6` と、webpack / postcss / js-yaml / follow-redirects / shell-quote 等の推移的依存)。いずれも開発時のみの依存で、配布物には含まれません。

### v6.0.0-pre.3

- **Fix**: maplibre-gl 5.11.0 以降で帰属表示が空になる問題を修正しました([#512](https://github.com/geolonia/embed/issues/512))。ソースに指定した `attribution` だけでなく、ベーススタイルの `© Geolonia` / `© OpenStreetMap` も表示されない状態でした。修正の実体は [maps-core#102](https://github.com/geolonia/maps-core/pull/102) で、embed 側は依存を更新して取り込みます。
Expand Down
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Or

### Using with npm (for React, Next.js, Astro, Fresh, etc.)

For modern web frameworks, use `@geolonia/embed/core` — a side-effect-free entry point designed for programmatic use.
For modern web frameworks, use `@geolonia/embed/core` — an entry point designed for programmatic use.

```shell
npm install @geolonia/embed
Expand All @@ -61,7 +61,16 @@ const map = new GeoloniaMap({
});
```

Unlike the default `@geolonia/embed` entry point, `/core` does **not** automatically scan the DOM or set `window.geolonia`. This makes it safe to use in SSR environments and avoids double-initialization issues in frameworks like React, Preact, and Vue.
Unlike the default `@geolonia/embed` entry point, `/core` does **not** automatically scan the DOM or set `window.geolonia`. This makes it safe to use in SSR environments and avoids double-initialization issues in frameworks like React, Preact, and Vue. (Its only import-time side effect is registering the bundled MapLibre worker, which is skipped outside the browser.)

### Content Security Policy

`@geolonia/embed` ships as a single file, so the MapLibre worker is embedded in the bundle and started from a `blob:` URL.
If your page sets a Content Security Policy, allow `blob:` as a worker source:

```
Content-Security-Policy: worker-src blob:;
```

### Using External Styles Without API Key

Expand Down
6 changes: 3 additions & 3 deletions docs/embed-core.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
* MapLibre GL JS
* @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v5.19.0/LICENSE.txt
*/
* MapLibre GL JS
* @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v6.11.2/LICENSE.txt
*/
6 changes: 3 additions & 3 deletions docs/embed.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
* MapLibre GL JS
* @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v5.19.0/LICENSE.txt
*/
* MapLibre GL JS
* @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v6.11.2/LICENSE.txt
*/
27 changes: 27 additions & 0 deletions e2e/umd-worker.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { test, expect } from '@playwright/test';
import { TEST_URL, mockGeoloniaTiles, waitForStyleLoad } from './helper';

/**
* embed は UMD で配る。maplibre-gl v6 の worker は `import.meta.url` 基準で解決される
* が、UMD 出力では webpack が `import.meta.url` をビルドマシンのファイルパスへ置換する
* ため、maplibre は worker URL を空文字へフォールバックする。この失敗は例外もコンソール
* エラーも出さず「地図だけが出ない」形で現れるので、worker が実際に登録されているかを
* 明示的に確かめる (#518)。
*
* 実体は `src/lib/maplibre-worker.ts` が worker をバンドル内の文字列から Blob URL 化して
* `setWorkerUrl()` に渡している。
*/
test.describe('UMD バンドルの maplibre worker (#518)', () => {
test('worker URL が Blob URL として登録され、スタイルが読み込まれる', async ({
page,
}) => {
await mockGeoloniaTiles(page);
await page.goto(`${TEST_URL}/basic.html`);
await waitForStyleLoad(page, '#map');

const workerUrl = await page.evaluate(() =>
(window as any).geolonia.getWorkerUrl(),
);
expect(workerUrl).toMatch(/^blob:/);
});
});
Loading
Loading