@geolonia/embed 6.0.0 → 6.1.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.
@@ -13,8 +13,3 @@ export declare function parseScriptTagApiKey(doc?: Document): {
13
13
  apiKey: string;
14
14
  stage: string;
15
15
  } | null;
16
- /**
17
- * Detect whether the embed is allowed to render in the current (possibly
18
- * iframed) context. Embed-specific: not provided by maps-core.
19
- */
20
- export declare function checkPermission(): boolean;
package/dist/types.d.ts CHANGED
@@ -104,9 +104,14 @@ export type EmbedAttributes = {
104
104
  */
105
105
  geoloniaControl: string;
106
106
  /**
107
- * `data-geojson`:GeoJSON のソース。URL、インラインの JSON 文字列、または
108
- * インライン要素(`<script type="application/json">` など)を指す CSS セレクタの
109
- * いずれか。
107
+ * `data-geojson`:GeoJSON のソース。URL(`https://...`、`/data.geojson`、
108
+ * `./data.geojson`、`../data.geojson` など)か、地図コンテナの外に置いた、中身が
109
+ * GeoJSON の FeatureCollection の要素(`<script type="application/json">` など)を
110
+ * 指す CSS セレクタのいずれか。
111
+ *
112
+ * これ以外の値(インラインの JSON 文字列、`./` を付けない相対パス、何も指さない
113
+ * セレクタなど)は扱えず、地物は描かれない(多くの場合はエラーになる)。対応外の
114
+ * 値で起きることの詳細は https://github.com/geolonia/embed/issues/570 を参照。
110
115
  * @defaultValue `''`
111
116
  */
112
117
  geojson: string;
@@ -127,10 +132,13 @@ export type EmbedAttributes = {
127
132
  */
128
133
  style: string;
129
134
  /**
130
- * `data-lang`:ラベルの言語。`data-lang` に指定できるのは `'ja'`、`'en'`、
131
- * `'auto'` など。`parseAtts` は `'ja'` のみを `'ja'` に解決し、それ以外の明示値は
132
- * `'en'` に解決する(`'ja-jp'` も `'en'` になる)。`'auto'` および未指定のときは
133
- * ブラウザ言語(`getLang()` の結果。`'ja'` または `'en'`)になる。
135
+ * `data-lang`:ラベルとジェスチャー制御の文言の言語。指定した値はそのまま
136
+ * maps-core に渡る。`'ja'` と `'ja-jp'` は日本語、`'auto'` と空文字はブラウザ
137
+ * 言語に従い、それ以外の値は英語になる。比較は大文字と小文字を区別するので、
138
+ * `'ja-JP'` は英語になる。ラベルに効くのは、`data-style` を省略したときか
139
+ * Geolonia のスタイル名を指定したときだけ。`'ja'`、`'en'`、`'auto'`、空文字以外の
140
+ * 値では、`'ja-jp'` も含めてジェスチャー制御が付かない
141
+ * (https://github.com/geolonia/embed/issues/571)。
134
142
  * @defaultValue 未指定のときは `getLang()` の結果(`'ja'` または `'en'`)
135
143
  */
136
144
  lang: string;
@@ -177,6 +185,8 @@ export type EmbedAttributes = {
177
185
  choropleth?: string;
178
186
  /**
179
187
  * `data-choropleth-colors`:塗り分けの色。値の小さい側から順にカンマで区切る。
188
+ * `値:色` の組をカンマで区切ると、値ごとの色の対応表になる(`data-choropleth-range`
189
+ * は使わない)。組の読み方は `data-circle-colors` と同じ。
180
190
  * `data-choropleth` が無いときは無視する。
181
191
  */
182
192
  choroplethColors?: string;
@@ -192,6 +202,7 @@ export type EmbedAttributes = {
192
202
  heatmap?: string;
193
203
  /**
194
204
  * `data-heatmap-colors`:ヒートマップの色。密度の低い側から順にカンマで区切る。
205
+ * 密度に対する色なので、`値:色` の組(対応表)には対応しない。
195
206
  * `data-heatmap` が無いときは無視する。
196
207
  */
197
208
  heatmapColors?: string;
@@ -201,9 +212,136 @@ export type EmbedAttributes = {
201
212
  circleColor?: string;
202
213
  /**
203
214
  * `data-circle-colors`:`data-circle-color` に使う色をカンマで区切る。
215
+ * `normal:#3b82f6, danger:#ef4444` のように `値:色` の組をカンマで区切ると、
216
+ * 値ごとの色の対応表になる。組の読み方は次のとおり。
217
+ *
218
+ * - 組が 1 つでもあれば対応表として読む。`:` の無い項目と色が空の組は、
219
+ * コンソールに警告を出して無視する。
220
+ * - 値と色は、括弧の外にある最後の `:` で分ける。値に `:` を含めてよい。
221
+ * - 項目は括弧の外のカンマで区切る。括弧の中のカンマ(`rgb(0, 0, 0)`)は
222
+ * 区切りとして扱わないので、括弧は閉じて書く。閉じていない `(` があると、
223
+ * それより後ろのカンマと `:` を区切りとして読まない。
224
+ * - 値と色の前後の空白は除く。同じ値の組が複数あれば後のものを使う。
225
+ * - 使える組が 1 つも無ければ、指定しなかったときと同じ既定の色になる。
226
+ * - 対応表にない値の地物の色は、maps-core の `ColorMap` の規則に従う。
227
+ *
204
228
  * `data-circle-size` と `data-circle-color` のどちらも無いときは無視する。
205
229
  */
206
230
  circleColors?: string;
231
+ /**
232
+ * `data-extrusion`:`data-geojson` のポリゴンを、このプロパティの値に応じた高さで
233
+ * 立体的に描く。色も、`data-extrusion-color` を省略すると同じプロパティで決める。
234
+ * 地物の simplestyle の `fill` と `data-choropleth` より優先する。立体に見せるには
235
+ * `data-pitch` も指定する。`data-geojson` が無いときは何も描かない。
236
+ */
237
+ extrusion?: string;
238
+ /**
239
+ * `data-extrusion-max-height`:`data-extrusion-height-range` の最大値に割り当てる
240
+ * 高さ(メートル)。`data-extrusion-height-scale` があるときは使わない。数値として
241
+ * 読めないときは無視する。`data-extrusion` が無いときは無視する。
242
+ */
243
+ extrusionMaxHeight?: string;
244
+ /**
245
+ * `data-extrusion-height-scale`:値 1 あたりの高さ(メートル)。指定すると高さは
246
+ * 「値 × この数」になる。数値として読めないときは無視する。`data-extrusion` が
247
+ * 無いときは無視する。
248
+ */
249
+ extrusionHeightScale?: string;
250
+ /**
251
+ * `data-extrusion-height-range`:高さ 0 から最大の高さに割り当てる値の範囲。
252
+ * `"最小,最大"` 形式。省略時や読めないときはデータの値から決める。
253
+ * `data-extrusion` が無いときは無視する。
254
+ */
255
+ extrusionHeightRange?: string;
256
+ /**
257
+ * `data-extrusion-color`:色に使うプロパティ名。省略すると `data-extrusion` と同じ
258
+ * プロパティで色分けする。`data-extrusion` が無いときは無視する。
259
+ */
260
+ extrusionColor?: string;
261
+ /**
262
+ * `data-extrusion-colors`:色。数値は値の小さい側から順に、カテゴリは出現順に
263
+ * 割り当てる色をカンマで区切る。`値:色` の組をカンマで区切ると、値ごとの色の
264
+ * 対応表になる(`data-extrusion-color-range` は使わない)。組の読み方は
265
+ * `data-circle-colors` と同じ。`data-extrusion` が無いときは無視する。
266
+ */
267
+ extrusionColors?: string;
268
+ /**
269
+ * `data-extrusion-color-range`:数値の色を割り当てる値の範囲。`"最小,最大"` 形式。
270
+ * 省略時や読めないときはデータの最小値と最大値を使う。`data-extrusion` が無い
271
+ * ときは無視する。
272
+ */
273
+ extrusionColorRange?: string;
274
+ /**
275
+ * `data-mask`:指定した範囲の外側を暗くする。境界の GeoJSON の URL(`http://` か
276
+ * `https://` で始まるもの、または `/` か `.` で始まるパス)を指定する。それ以外の
277
+ * 値は maps-core がコンソールにエラーを出して無視する。中心(`data-lat` と
278
+ * `data-lng` の両方)、`data-geojson`、`data-simple-vector` のどれも指定して
279
+ * いないときは、境界の範囲に合わせて表示する。
280
+ */
281
+ mask?: string;
282
+ /**
283
+ * `data-mask-color`:範囲の外側を塗る色。省略すると maps-core の既定値(黒)。
284
+ * `data-mask` が無いときは無視する。
285
+ */
286
+ maskColor?: string;
287
+ /**
288
+ * `data-mask-opacity`:範囲の外側を塗る不透明度(0 から 1)。数値として読めない
289
+ * ときは無視する。0 から 1 の外の値は maps-core がコンソールにエラーを出して
290
+ * 既定値(0.3)を使う。`data-mask` が無いときは無視する。
291
+ */
292
+ maskOpacity?: string;
293
+ /**
294
+ * `data-mask-outline`(`'on'` / `'off'`):境界に線を引く。線は `data-mask-color`
295
+ * の色で太さ 2 ピクセル。`data-mask` が無いときは無視する。
296
+ * @defaultValue 未指定のときは引かない
297
+ */
298
+ maskOutline?: string;
299
+ /**
300
+ * `data-projection`:地図の投影。`'globe'` で地球儀、`'mercator'` で平面に
301
+ * する。値は前後の空白を除いて maps-core に渡り、それ以外の値は maps-core が
302
+ * コンソールにエラーを出して無視する。省略したときと空のときは、スタイルの投影(無ければ
303
+ * mercator)のまま。
304
+ */
305
+ projection?: string;
306
+ /**
307
+ * `data-raster-tiles`:重ねるラスタタイルの URL のテンプレート。`{z}`、`{x}`、
308
+ * `{y}` を含める。スタイルの最初の symbol レイヤ(ラベル)の下に 1 枚重ね、
309
+ * symbol レイヤが無いスタイルではスタイルのレイヤの一番上に重ねる。どちらの
310
+ * 場合も `data-geojson` と `data-simple-vector` のレイヤはその上に描く。含まない
311
+ * ときは maps-core がコンソールに警告を出して重ねない。
312
+ */
313
+ rasterTiles?: string;
314
+ /**
315
+ * `data-raster-tiles-attribution`:重ねたタイルの出典。地図の出典表示に加わる。
316
+ * HTML として表示するので、ページの作者が書いた値だけを入れ、URL のパラメータ
317
+ * など外から受け取った値を入れない。空のときと、`data-raster-tiles` が無いときは
318
+ * 無視する。
319
+ */
320
+ rasterTilesAttribution?: string;
321
+ /**
322
+ * `data-raster-tiles-opacity`:重ねたタイルの不透明度(0 から 1)。範囲を超える
323
+ * 値は maps-core が範囲内に収める。数値として読めないときは無視する(maps-core
324
+ * の既定値 1 になる)。`data-raster-tiles` が無いときは無視する。
325
+ */
326
+ rasterTilesOpacity?: string;
327
+ /**
328
+ * `data-raster-tiles-size`:タイル 1 枚の大きさ(ピクセル)。数値として読めない
329
+ * ときは無視する(maps-core の既定値 256 になる)。`data-raster-tiles` が無い
330
+ * ときは無視する。
331
+ */
332
+ rasterTilesSize?: string;
333
+ /**
334
+ * `data-raster-tiles-min-zoom`:タイルが配信されている最小ズーム。これより
335
+ * 小さいズームではタイルを読み込まない。数値として読めないときは無視する。
336
+ * `data-raster-tiles` が無いときは無視する。
337
+ */
338
+ rasterTilesMinZoom?: string;
339
+ /**
340
+ * `data-raster-tiles-max-zoom`:タイルが配信されている最大ズーム。これより
341
+ * 大きいズームでは、このズームのタイルを引き伸ばして表示する。数値として
342
+ * 読めないときは無視する。`data-raster-tiles` が無いときは無視する。
343
+ */
344
+ rasterTilesMaxZoom?: string;
207
345
  /**
208
346
  * 追加の `data-*` 属性はそのまま透過される({@link EmbedPlugin} が利用する
209
347
  * プラグイン固有の属性など)。
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "6.0.0";
1
+ export declare const VERSION = "6.1.0";
@@ -3,10 +3,11 @@ import { TEST_URL, mockGeoloniaTiles, waitForStyleLoad, hasLayer } from './helpe
3
3
 
4
4
  // embed (wrapper) 固有: data-choropleth / data-heatmap / data-circle-* を読んで
5
5
  // maps-core の choropleth / heatmap / circle オプションへ渡す (embed#546)。
6
- // 式がどう描かれるか (option → 描画) は maps-core 側 E2E (maps-core#156) が担保する。
6
+ // -colors の値と色の組は ColorMap として渡す (embed#573)。data-extrusion-* は extrusion へ渡す (embed#579)。
7
+ // 式がどう描かれるか (option → 描画) は maps-core 側のテスト (maps-core#156、extrusion は maps-core#162) が担保する。
7
8
  // ここでは、属性で指定したプロパティ名と色がレイヤーの paint に届き、MapLibre が
8
9
  // その式を受け付ける (error イベントもページのエラーも出ない) ことを見る。
9
- test.describe('data-choropleth / data-heatmap / data-circle-* フォワーディング (wrapper-only)', () => {
10
+ test.describe('data-choropleth / data-heatmap / data-circle-* / data-extrusion-* フォワーディング (wrapper-only)', () => {
10
11
  let pageErrors: string[];
11
12
 
12
13
  test.beforeEach(async ({ page }) => {
@@ -25,6 +26,12 @@ test.describe('data-choropleth / data-heatmap / data-circle-* フォワーディ
25
26
  ['#heatmap', 'geolonia-simple-style-heatmap', 'heatmap-color', ['#00ff00', '#0000ff']],
26
27
  ['#circle', 'geolonia-simple-style-circle-points', 'circle-radius', ['"weight"']],
27
28
  ['#circle', 'geolonia-simple-style-circle-points', 'circle-color', ['"category"', '#00ff00', '#0000ff']],
29
+ // 値と色の組 (embed#573): 値ごとの match 式になる
30
+ ['#choropleth-map', 'geolonia-simple-style-polygon', 'fill-color', ['"match"', '"value"', '"10"', '#00ff00', '"90"', 'rgb(0, 0, 255)']],
31
+ ['#circle-map', 'geolonia-simple-style-circle-points', 'circle-color', ['"match"', '"category"', '"a"', '#00ff00', '"b"', '#0000ff']],
32
+ // 立体表示 (embed#579)
33
+ ['#extrusion', 'geolonia-simple-style-polygon-extrusion', 'fill-extrusion-height', ['"value"', '2000']],
34
+ ['#extrusion', 'geolonia-simple-style-polygon-extrusion', 'fill-extrusion-color', ['"match"', '"value"', '"10"', '#00ff00', '"90"', '#0000ff']],
28
35
  ] as const) {
29
36
  test(`${selector} の ${property} に属性の指定が届く`, async ({ page }) => {
30
37
  await waitForStyleLoad(page, selector);
@@ -1,35 +1,50 @@
1
1
  import { test, expect } from '@playwright/test';
2
- import { TEST_URL, mockGeoloniaTiles, waitForMapLoad, hasMapInstance } from './helper';
2
+ import { BASE_URL, LOAD_TIMEOUT, TEST_URL, mockGeoloniaTiles, waitForMapLoad, hasMapInstance } from './helper';
3
3
 
4
- // embed (wrapper) 固有: checkPermission() による iframe 埋め込み制限。
5
- // maps-core にこのゲートは無い。
6
- //
7
- // 拒否される側 (iframe + API key 無し + 非特例 origin) の E2E 再現は難しいため skip し、
8
- // ここでは「非 iframe では拒否されず描画される」= 許可側の経路のみを守る。
9
- test.describe('iframe 許可チェック / checkPermission (wrapper-only)', () => {
10
- test('非 iframe では拒否されず地図が描画される (iframe 拒否メッセージが出ない)', async ({ page }) => {
4
+ // 子フレーム用の別オリジン。リクエストは route で dev サーバーへ転送する
5
+ const OTHER_ORIGIN = 'http://embed-iframe.test';
6
+
7
+ // embed (wrapper) 固有: class="geolonia" の要素は、iframe の中でも API キーの有無に関係なく地図になる。
8
+ test.describe('iframe の中での描画 (wrapper-only)', () => {
9
+ test('非 iframe で地図が描画される', async ({ page }) => {
10
+ await mockGeoloniaTiles(page);
11
+ await page.goto(`${TEST_URL}/basic.html`);
12
+ await waitForMapLoad(page);
13
+
14
+ expect(await hasMapInstance(page, '#map')).toBe(true);
15
+ });
16
+
17
+ test('API キー無しの embed を別オリジンの iframe に入れても地図が描画される', async ({ page }) => {
11
18
  const consoleErrors: string[] = [];
12
19
  page.on('console', (msg) => {
13
20
  if (msg.type() === 'error') consoleErrors.push(msg.text());
14
21
  });
15
22
 
16
23
  await mockGeoloniaTiles(page);
17
- await page.goto(`${TEST_URL}/basic.html`);
18
- await waitForMapLoad(page);
24
+ await page.route(`${OTHER_ORIGIN}/**`, async (route) => {
25
+ const url = route.request().url().replace(OTHER_ORIGIN, BASE_URL);
26
+ await route.fulfill({ response: await route.fetch({ url }) });
27
+ });
28
+ await page.goto(`${TEST_URL}/iframe.html?origin=${encodeURIComponent(OTHER_ORIGIN)}`);
19
29
 
20
- // 描画されている = checkPermission が許可した
21
- expect(await hasMapInstance(page, '#map')).toBe(true);
30
+ const frame = page.frameLocator('#frame');
31
+ await expect(frame.locator('#map canvas')).toBeVisible({ timeout: 10000 });
22
32
 
23
- // iframe 拒否のメッセージは出ていないこと
33
+ const child = page.frames().find((f) => f.url().endsWith('/e2e/no-api-key.html'));
34
+ expect(child).toBeDefined();
35
+ // waitForStyleLoad と同じ条件で、子フレームの地図がスタイルまで読み終えるのを待つ
36
+ await child!.waitForFunction(
37
+ () => {
38
+ const map = (document.querySelector('#map') as any)?.geoloniaMap;
39
+ return !!(map && map.loaded() && map.isStyleLoaded());
40
+ },
41
+ undefined,
42
+ { timeout: LOAD_TIMEOUT },
43
+ );
44
+ expect(new URL(child!.url()).origin).toBe(OTHER_ORIGIN);
45
+ expect(
46
+ await child!.evaluate(() => !!(document.querySelector('#map') as any)?.geoloniaMap),
47
+ ).toBe(true);
24
48
  expect(consoleErrors.some((t) => t.includes("can't display our map in iframe"))).toBe(false);
25
49
  });
26
-
27
- // 拒否ケース (iframe + API key 無し → console.error) は E2E では再現が難しい:
28
- // - ローカルでは特例 origin (codepen 等) + referrer を満たせない
29
- // - child frame の console は親フレームから capture しにくい
30
- // このゲートは checkPermission() のユニットテスト (window.self/parent/location をモック) で
31
- // 検証する方が現実的。E2E では skip する (silent に落とさず明示)。
32
- test.skip('iframe + API key 無し → 拒否される (ユニットテストで担保)', async () => {
33
- // intentionally skipped — see comment above
34
- });
35
50
  });
@@ -0,0 +1,75 @@
1
+ import { test, expect } from '@playwright/test';
2
+ import { TEST_URL, mockGeoloniaTiles, waitForStyleLoad, hasLayer, hasSource } from './helper';
3
+
4
+ // embed (wrapper) 固有: data-mask と data-mask-* を読んで maps-core の mask オプションへ渡す (embed#572)。
5
+ // 境界をどうくり抜いて描くかは maps-core 側のテスト (maps-core#171) が担保する。
6
+ // ここでは、属性の値がマスクのレイヤに届き、MapLibre のエラーもページのエラーも出ないことを見る。
7
+
8
+ const AREA = {
9
+ type: 'FeatureCollection',
10
+ features: [
11
+ {
12
+ type: 'Feature',
13
+ properties: {},
14
+ geometry: {
15
+ type: 'Polygon',
16
+ coordinates: [[[139.0, 35.0], [139.2, 35.0], [139.2, 35.1], [139.0, 35.1], [139.0, 35.0]]],
17
+ },
18
+ },
19
+ ],
20
+ };
21
+
22
+ test.describe('data-mask-* フォワーディング (wrapper-only)', () => {
23
+ let pageErrors: string[];
24
+
25
+ test.beforeEach(async ({ page }) => {
26
+ pageErrors = [];
27
+ page.on('pageerror', (error) => pageErrors.push(error.message));
28
+ page.on('console', (message) => {
29
+ if (message.type() === 'error') pageErrors.push(message.text());
30
+ });
31
+ await mockGeoloniaTiles(page);
32
+ await page.route(/mask\.example\.com\//, (route) =>
33
+ route.fulfill({
34
+ status: 200,
35
+ contentType: 'application/geo+json',
36
+ headers: { 'access-control-allow-origin': '*' },
37
+ body: JSON.stringify(AREA),
38
+ }),
39
+ );
40
+ await page.goto(`${TEST_URL}/mask.html`);
41
+ });
42
+
43
+ test('data-mask-* の指定がマスクと境界線のレイヤに届く', async ({ page }) => {
44
+ await waitForStyleLoad(page, '#mask');
45
+ await expect.poll(() => hasSource(page, 'geolonia-mask', '#mask')).toBe(true);
46
+ expect(await hasLayer(page, 'geolonia-mask', '#mask')).toBe(true);
47
+ expect(await hasLayer(page, 'geolonia-mask-outline', '#mask')).toBe(true);
48
+
49
+ const paint = await page.evaluate(() => {
50
+ const map = (document.querySelector('#mask') as any).geoloniaMap;
51
+ return {
52
+ fillColor: map.getPaintProperty('geolonia-mask', 'fill-color'),
53
+ fillOpacity: map.getPaintProperty('geolonia-mask', 'fill-opacity'),
54
+ lineColor: map.getPaintProperty('geolonia-mask-outline', 'line-color'),
55
+ };
56
+ });
57
+ expect(paint).toEqual({ fillColor: '#123456', fillOpacity: 0.5, lineColor: '#123456' });
58
+
59
+ // 境界の GeoJSON を取得して、範囲をくり抜いた面(MultiPolygon の Feature)がソースに入る
60
+ await expect
61
+ .poll(() =>
62
+ page.evaluate(() => {
63
+ const map = (document.querySelector('#mask') as any).geoloniaMap;
64
+ return map
65
+ .getSource('geolonia-mask')
66
+ .getData()
67
+ .then((data: any) => data.geometry?.type ?? null);
68
+ }),
69
+ )
70
+ .toBe('MultiPolygon');
71
+
72
+ expect(await page.evaluate(() => (window as any).__mapErrors.mask)).toEqual([]);
73
+ expect(pageErrors).toEqual([]);
74
+ });
75
+ });
@@ -0,0 +1,71 @@
1
+ import { test, expect } from '@playwright/test';
2
+ import { TEST_URL, mockGeoloniaTiles, waitForStyleLoad, hasLayer, hasSource } from './helper';
3
+
4
+ // embed (wrapper) 固有: data-projection と data-raster-tiles-* を読んで maps-core の
5
+ // projection / rasterTiles オプションへ渡す (embed#577、embed#578)。
6
+ // オプションがどう描かれるかは maps-core 側のテスト (maps-core#180、maps-core#182) が担保する。
7
+ // ここでは、属性の値がオプションとして届き、MapLibre のエラーもページのエラーも出ないことを見る。
8
+
9
+ // 1x1 の透明な PNG
10
+ const PNG_1X1 = Buffer.from(
11
+ 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==',
12
+ 'base64',
13
+ );
14
+
15
+ test.describe('data-projection / data-raster-tiles-* フォワーディング (wrapper-only)', () => {
16
+ let pageErrors: string[];
17
+
18
+ test.beforeEach(async ({ page }) => {
19
+ pageErrors = [];
20
+ page.on('pageerror', (error) => pageErrors.push(error.message));
21
+ page.on('console', (message) => {
22
+ if (message.type() === 'error') pageErrors.push(message.text());
23
+ });
24
+ await mockGeoloniaTiles(page);
25
+ await page.route(/raster-tiles\.example\.com\//, (route) =>
26
+ route.fulfill({ status: 200, contentType: 'image/png', body: PNG_1X1 }),
27
+ );
28
+ await page.goto(`${TEST_URL}/projection-raster-tiles.html`);
29
+ });
30
+
31
+ const mapErrorsOf = (page: import('@playwright/test').Page, id: string) =>
32
+ page.evaluate((id) => (window as any).__mapErrors[id], id);
33
+
34
+ test('data-projection="globe" で投影が globe になる', async ({ page }) => {
35
+ await waitForStyleLoad(page, '#globe');
36
+ await expect
37
+ .poll(() =>
38
+ page.evaluate(() => {
39
+ const el = document.querySelector('#globe') as any;
40
+ return el.geoloniaMap.getProjection()?.type;
41
+ }),
42
+ )
43
+ .toBe('globe');
44
+ expect(await mapErrorsOf(page, 'globe')).toEqual([]);
45
+ expect(pageErrors).toEqual([]);
46
+ });
47
+
48
+ test('data-raster-tiles-* の指定がソースとレイヤに届く', async ({ page }) => {
49
+ await waitForStyleLoad(page, '#raster');
50
+ await expect.poll(() => hasSource(page, 'geolonia-raster-tiles', '#raster')).toBe(true);
51
+ expect(await hasLayer(page, 'geolonia-raster-tiles', '#raster')).toBe(true);
52
+
53
+ const { source, opacity } = await page.evaluate(() => {
54
+ const map = (document.querySelector('#raster') as any).geoloniaMap;
55
+ return {
56
+ source: map.getStyle().sources['geolonia-raster-tiles'],
57
+ opacity: map.getPaintProperty('geolonia-raster-tiles', 'raster-opacity'),
58
+ };
59
+ });
60
+ expect(source).toMatchObject({
61
+ type: 'raster',
62
+ tiles: ['https://raster-tiles.example.com/{z}/{x}/{y}.png'],
63
+ tileSize: 256,
64
+ maxzoom: 12,
65
+ attribution: 'Raster fixture',
66
+ });
67
+ expect(opacity).toBe(0.5);
68
+ expect(await mapErrorsOf(page, 'raster')).toEqual([]);
69
+ expect(pageErrors).toEqual([]);
70
+ });
71
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geolonia/embed",
3
- "version": "6.0.0",
3
+ "version": "6.1.0",
4
4
  "description": "Geolonia embed JS API",
5
5
  "main": "dist/embed.js",
6
6
  "types": "dist/embed.d.ts",
@@ -53,7 +53,7 @@
53
53
  "webpack-dev-server": "^6.0.0"
54
54
  },
55
55
  "dependencies": {
56
- "@geolonia/maps-core": "^0.8.0",
56
+ "@geolonia/maps-core": "^0.9.0",
57
57
  "@playwright/test": "^1.61.1",
58
58
  "maplibre-gl": "6.16.0"
59
59
  },
@@ -8,6 +8,12 @@
8
8
  # ビルドスクリプトを実行しなくても動作する。
9
9
  ignoreScripts: true
10
10
 
11
+ # minimumReleaseAgeExclude: 公開から日の浅い版を入れない pnpm の検査
12
+ # (minimumReleaseAge)から外すパッケージ。自社のパッケージを公開直後に取り込む
13
+ # ときだけ、その版に限って足す。版を指定するので、次の版は再び検査の対象になる。
14
+ minimumReleaseAgeExclude:
15
+ - '@geolonia/maps-core@0.9.0'
16
+
11
17
  # pmOnFail: `packageManager` のバージョン不一致チェックをスキップする
12
18
  # (pnpm のドキュメント上は旧 `managePackageManagerVersions: false` 相当)。
13
19
  #