@geolonia/embed 6.0.0-pre.5 → 6.0.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/.github/workflows/build.yml +4 -4
- package/.pinact.yml +5 -2
- package/.tool-versions +1 -1
- package/CHANGELOG.md +58 -0
- package/README.md +1 -1
- package/dist/embed +1 -1
- package/dist/embed-chunks/{d1fe32cb4bfb0e9c6575.js → 124e026690b0fa17700b.js} +1 -1
- package/dist/embed-chunks/9734b8bdf9fe84261b54.js +2 -0
- package/dist/embed-chunks/ae36f6b8e34f85ae3045.js +2 -0
- package/dist/embed-chunks/{4b5b1b54a5dac816ef15.js → db5eea9dfc49d1cf19e7.js} +1 -1
- package/dist/embed-core.d.ts +1 -1
- package/dist/embed-core.js +1 -1
- package/dist/embed-core.js.LICENSE.txt +1 -1
- package/dist/embed.d.ts +3 -3
- package/dist/embed.js +1 -1
- package/dist/embed.js.LICENSE.txt +1 -1
- package/dist/lib/parse-atts.d.ts +1 -1
- package/dist/lib/render.d.ts +2 -2
- package/dist/types-internal.d.ts +4 -0
- package/dist/types.d.ts +47 -6
- package/dist/version.d.ts +1 -1
- package/e2e/data-driven.spec.ts +61 -0
- package/eslint.config.js +15 -48
- package/package.json +15 -20
- package/src/embed-core.ts +5 -1
- package/src/embed.ts +7 -3
- package/src/lib/parse-atts.test.ts +152 -6
- package/src/lib/parse-atts.ts +110 -8
- package/src/lib/render.ts +31 -10
- package/src/lib/util.ts +1 -1
- package/src/testability.test.ts +20 -17
- package/src/types-internal.ts +18 -0
- package/src/types.ts +46 -4
- package/src/version.ts +1 -1
- package/tsconfig.build.json +5 -0
- package/tsconfig.json +5 -3
- package/webpack.config.js +2 -2
- package/dist/embed-chunks/00ecbfa5ec913dd002fb.js +0 -2
- package/dist/embed-chunks/52e84382012e7ba206d5.js +0 -2
- /package/dist/embed-chunks/{4574b15eb540c5efc533.js → 5f80e0235f4b38778d0d.js} +0 -0
- /package/dist/embed-chunks/{00ecbfa5ec913dd002fb.js.LICENSE.txt → 9734b8bdf9fe84261b54.js.LICENSE.txt} +0 -0
- /package/dist/embed-chunks/{52e84382012e7ba206d5.js.LICENSE.txt → ae36f6b8e34f85ae3045.js.LICENSE.txt} +0 -0
- /package/dist/embed-chunks/{ffdb8e820d823ee3571c.js → c83bb7c9a4a7ed9d5b23.js} +0 -0
package/src/lib/parse-atts.ts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
import type { ControlPosition } from 'maplibre-gl';
|
|
4
|
-
import {
|
|
4
|
+
import type { FeatureCollection } from 'geojson';
|
|
5
|
+
import {
|
|
6
|
+
getLang,
|
|
7
|
+
keyring,
|
|
8
|
+
type ChoroplethOptions,
|
|
9
|
+
type CircleOptions,
|
|
10
|
+
type GeoloniaMapOptions,
|
|
11
|
+
type HeatmapOptions,
|
|
12
|
+
} from '@geolonia/maps-core';
|
|
5
13
|
import type { EmbedAttributes } from '../types';
|
|
6
14
|
|
|
7
15
|
type ParseAttsParams = {
|
|
@@ -18,14 +26,16 @@ type ParseAttsParams = {
|
|
|
18
26
|
* `GeoloniaMapOptions` for maps-core.
|
|
19
27
|
*/
|
|
20
28
|
export default (
|
|
21
|
-
container,
|
|
29
|
+
container: HTMLElement,
|
|
22
30
|
params: ParseAttsParams = {},
|
|
23
31
|
): EmbedAttributes => {
|
|
32
|
+
// HTMLElement なら dataset は必ずあるが、plain object を渡していた頃の経路の
|
|
33
|
+
// 保険として残している。HTMLElement.dataset は readonly なのでキャストする。
|
|
24
34
|
if (!container.dataset) {
|
|
25
|
-
container.dataset = {};
|
|
35
|
+
(container as unknown as { dataset: DOMStringMap }).dataset = {};
|
|
26
36
|
}
|
|
27
37
|
|
|
28
|
-
let lang
|
|
38
|
+
let lang: string;
|
|
29
39
|
if (container.dataset.lang && container.dataset.lang === 'auto') {
|
|
30
40
|
lang = getLang();
|
|
31
41
|
} else if (container.dataset.lang && container.dataset.lang === 'ja') {
|
|
@@ -115,16 +125,107 @@ const isCssSelector = (value: string): Element | false => {
|
|
|
115
125
|
* a URL / inline JSON string, or a parsed FeatureCollection when the value is a
|
|
116
126
|
* CSS selector referencing an inline element.
|
|
117
127
|
*/
|
|
118
|
-
const resolveGeojson = (
|
|
119
|
-
value: string,
|
|
120
|
-
): string | GeoJSON.FeatureCollection => {
|
|
128
|
+
const resolveGeojson = (value: string): string | FeatureCollection => {
|
|
121
129
|
const el = isCssSelector(value);
|
|
122
130
|
if (el && el.textContent) {
|
|
123
|
-
return JSON.parse(el.textContent) as
|
|
131
|
+
return JSON.parse(el.textContent) as FeatureCollection;
|
|
124
132
|
}
|
|
125
133
|
return value;
|
|
126
134
|
};
|
|
127
135
|
|
|
136
|
+
/**
|
|
137
|
+
* Split a comma-separated list of CSS colors. Commas inside parentheses
|
|
138
|
+
* (`rgb(0, 0, 0)`) are part of the color, not separators.
|
|
139
|
+
*/
|
|
140
|
+
const parseColors = (value: string): string[] => {
|
|
141
|
+
const colors: string[] = [];
|
|
142
|
+
let depth = 0;
|
|
143
|
+
let current = '';
|
|
144
|
+
for (const char of value) {
|
|
145
|
+
if (char === '(') depth++;
|
|
146
|
+
if (char === ')') depth = Math.max(0, depth - 1);
|
|
147
|
+
if (char === ',' && depth === 0) {
|
|
148
|
+
colors.push(current);
|
|
149
|
+
current = '';
|
|
150
|
+
} else {
|
|
151
|
+
current += char;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
colors.push(current);
|
|
155
|
+
return colors.map((c) => c.trim()).filter((c) => c !== '');
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Parse `"min,max"` into a range, or `undefined` when it is not two numbers
|
|
160
|
+
* with min < max (a reversed range would paint everything in one color).
|
|
161
|
+
*/
|
|
162
|
+
const parseRange = (value: string): [number, number] | undefined => {
|
|
163
|
+
const parts = value.split(',').map((n) => n.trim());
|
|
164
|
+
if (parts.length !== 2 || parts.some((n) => n === '')) {
|
|
165
|
+
return undefined;
|
|
166
|
+
}
|
|
167
|
+
const [min, max] = parts.map(Number);
|
|
168
|
+
if (!Number.isFinite(min) || !Number.isFinite(max) || min >= max) {
|
|
169
|
+
return undefined;
|
|
170
|
+
}
|
|
171
|
+
return [min, max];
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Convert `data-choropleth` / `data-heatmap` / `data-circle-*` into maps-core's
|
|
176
|
+
* data-driven options. The `-colors` / `-range` attributes only apply when the
|
|
177
|
+
* attribute that turns the drawing on is present.
|
|
178
|
+
*/
|
|
179
|
+
const dataDrivenOptions = (
|
|
180
|
+
atts: EmbedAttributes,
|
|
181
|
+
): Pick<GeoloniaMapOptions, 'choropleth' | 'heatmap' | 'circle'> => {
|
|
182
|
+
const options: Pick<GeoloniaMapOptions, 'choropleth' | 'heatmap' | 'circle'> =
|
|
183
|
+
{};
|
|
184
|
+
|
|
185
|
+
if (atts.choropleth) {
|
|
186
|
+
const choropleth: ChoroplethOptions = { property: String(atts.choropleth) };
|
|
187
|
+
if (atts.choroplethColors) {
|
|
188
|
+
choropleth.colors = parseColors(String(atts.choroplethColors));
|
|
189
|
+
}
|
|
190
|
+
const range = atts.choroplethRange
|
|
191
|
+
? parseRange(String(atts.choroplethRange))
|
|
192
|
+
: undefined;
|
|
193
|
+
if (range) {
|
|
194
|
+
choropleth.range = range;
|
|
195
|
+
}
|
|
196
|
+
options.choropleth = choropleth;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const heatmapValue = String(atts.heatmap ?? '').trim();
|
|
200
|
+
const heatmapFlag = heatmapValue.toLowerCase();
|
|
201
|
+
if (heatmapValue && heatmapFlag !== 'off') {
|
|
202
|
+
const heatmap: HeatmapOptions = {};
|
|
203
|
+
if (heatmapFlag !== 'on') {
|
|
204
|
+
heatmap.weight = heatmapValue;
|
|
205
|
+
}
|
|
206
|
+
if (atts.heatmapColors) {
|
|
207
|
+
heatmap.colors = parseColors(String(atts.heatmapColors));
|
|
208
|
+
}
|
|
209
|
+
options.heatmap = heatmap;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (atts.circleSize || atts.circleColor) {
|
|
213
|
+
const circle: CircleOptions = {};
|
|
214
|
+
if (atts.circleSize) {
|
|
215
|
+
circle.size = String(atts.circleSize);
|
|
216
|
+
}
|
|
217
|
+
if (atts.circleColor) {
|
|
218
|
+
circle.color = String(atts.circleColor);
|
|
219
|
+
}
|
|
220
|
+
if (atts.circleColors) {
|
|
221
|
+
circle.colors = parseColors(String(atts.circleColors));
|
|
222
|
+
}
|
|
223
|
+
options.circle = circle;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return options;
|
|
227
|
+
};
|
|
228
|
+
|
|
128
229
|
/**
|
|
129
230
|
* Convert normalised {@link EmbedAttributes} into a typed `GeoloniaMapOptions`
|
|
130
231
|
* for maps-core's `GeoloniaMap` constructor.
|
|
@@ -195,6 +296,7 @@ export const attsToOptions = (
|
|
|
195
296
|
if (atts.simpleVector) {
|
|
196
297
|
options.simpleVector = String(atts.simpleVector);
|
|
197
298
|
}
|
|
299
|
+
Object.assign(options, dataDrivenOptions(atts));
|
|
198
300
|
|
|
199
301
|
if (
|
|
200
302
|
atts.minZoom !== '' &&
|
package/src/lib/render.ts
CHANGED
|
@@ -3,8 +3,15 @@ import '../style.css';
|
|
|
3
3
|
import { GeoloniaMap, keyring } from '@geolonia/maps-core';
|
|
4
4
|
import { checkPermission, parseScriptTagApiKey } from './util';
|
|
5
5
|
import parseAtts, { attsToOptions } from './parse-atts';
|
|
6
|
+
import type {
|
|
7
|
+
EmbedAttributes,
|
|
8
|
+
EmbedPlugin,
|
|
9
|
+
EmbedPluginAttributes,
|
|
10
|
+
} from '../types';
|
|
6
11
|
|
|
7
|
-
|
|
12
|
+
// 登録済みプラグインは個別の PluginAttributes を持ちうるので、配列としては
|
|
13
|
+
// それらをまとめて保持できる形にしておく (呼び出しは常に EmbedAttributes で行う)。
|
|
14
|
+
const plugins: EmbedPlugin<any>[] = [];
|
|
8
15
|
|
|
9
16
|
/**
|
|
10
17
|
* Move any inline HTML the author placed inside the map container into
|
|
@@ -45,21 +52,29 @@ export const renderGeoloniaMap = () => {
|
|
|
45
52
|
|
|
46
53
|
if (checkPermission()) {
|
|
47
54
|
let isDOMContentLoaded = false;
|
|
48
|
-
const alreadyRenderedMaps = [];
|
|
49
55
|
const isRemoved = Symbol('map-is-removed');
|
|
50
56
|
|
|
57
|
+
// 手動で remove された地図に印を付けるための symbol プロパティ。
|
|
58
|
+
type RemovableMap = GeoloniaMap & { [isRemoved]?: boolean };
|
|
59
|
+
|
|
60
|
+
const alreadyRenderedMaps: {
|
|
61
|
+
map: RemovableMap;
|
|
62
|
+
target: HTMLElement;
|
|
63
|
+
atts: EmbedAttributes;
|
|
64
|
+
}[] = [];
|
|
65
|
+
|
|
51
66
|
/**
|
|
52
67
|
*
|
|
53
68
|
* @param {HTMLElement} target
|
|
54
69
|
*/
|
|
55
|
-
const renderSingleMap = (target) => {
|
|
70
|
+
const renderSingleMap = (target: HTMLElement) => {
|
|
56
71
|
const atts = parseAtts(target);
|
|
57
72
|
|
|
58
73
|
// Dedup: if this container was already initialised (e.g. constructed
|
|
59
74
|
// programmatically before the lazy observer fired), reuse the instance.
|
|
60
75
|
// Must happen before extractPopupContent(), otherwise we'd wipe the
|
|
61
76
|
// already-rendered map DOM out of the container.
|
|
62
|
-
let map = target.geoloniaMap;
|
|
77
|
+
let map: RemovableMap | undefined = target.geoloniaMap;
|
|
63
78
|
if (!map) {
|
|
64
79
|
// Grab inline popup content before maps-core clears/renders the container.
|
|
65
80
|
extractPopupContent(target);
|
|
@@ -81,7 +96,10 @@ export const renderGeoloniaMap = () => {
|
|
|
81
96
|
map.remove();
|
|
82
97
|
}
|
|
83
98
|
});
|
|
84
|
-
|
|
99
|
+
// 親が無いコンテナは DOM から外されることがないので監視しない。
|
|
100
|
+
if (target.parentNode) {
|
|
101
|
+
observer.observe(target.parentNode, { childList: true });
|
|
102
|
+
}
|
|
85
103
|
|
|
86
104
|
// plugin
|
|
87
105
|
if (isDOMContentLoaded && !map[isRemoved]) {
|
|
@@ -108,7 +126,8 @@ export const renderGeoloniaMap = () => {
|
|
|
108
126
|
return;
|
|
109
127
|
}
|
|
110
128
|
try {
|
|
111
|
-
|
|
129
|
+
// 監視対象は下の querySelectorAll<HTMLElement> で集めた要素に限られる。
|
|
130
|
+
renderSingleMap(item.target as HTMLElement);
|
|
112
131
|
} catch (e) {
|
|
113
132
|
// Not throw error because, following maps will not be rendered.
|
|
114
133
|
console.error('[Geolonia] Failed to initialize map', e); // eslint-disable-line
|
|
@@ -117,10 +136,10 @@ export const renderGeoloniaMap = () => {
|
|
|
117
136
|
});
|
|
118
137
|
});
|
|
119
138
|
|
|
120
|
-
const containers = document.querySelectorAll(
|
|
139
|
+
const containers = document.querySelectorAll<HTMLElement>(
|
|
121
140
|
'.geolonia[data-lazy-loading="off"]',
|
|
122
141
|
);
|
|
123
|
-
const lazyContainers = document.querySelectorAll(
|
|
142
|
+
const lazyContainers = document.querySelectorAll<HTMLElement>(
|
|
124
143
|
'.geolonia:not([data-lazy-loading="off"])',
|
|
125
144
|
);
|
|
126
145
|
|
|
@@ -151,8 +170,10 @@ export const renderGeoloniaMap = () => {
|
|
|
151
170
|
}
|
|
152
171
|
};
|
|
153
172
|
|
|
154
|
-
|
|
155
|
-
|
|
173
|
+
// PluginAttributes を推論させる。EmbedPlugin<{ foo: string }> のように固有の
|
|
174
|
+
// data-* を要求するプラグインも、そのまま登録できるようにするため。
|
|
175
|
+
export const registerPlugin = <PluginAttributes extends EmbedPluginAttributes>(
|
|
176
|
+
plugin: EmbedPlugin<PluginAttributes>,
|
|
156
177
|
): void => {
|
|
157
178
|
plugins.push(plugin);
|
|
158
179
|
return void 0;
|
package/src/lib/util.ts
CHANGED
|
@@ -106,7 +106,7 @@ export function checkPermission() {
|
|
|
106
106
|
* So, it should be caught.
|
|
107
107
|
*/
|
|
108
108
|
try {
|
|
109
|
-
if (window.self.location.origin === window.top
|
|
109
|
+
if (window.self.location.origin === window.top?.location.origin) {
|
|
110
110
|
return true;
|
|
111
111
|
}
|
|
112
112
|
} catch {
|
package/src/testability.test.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { describe, it, expect
|
|
2
|
-
import { JSDOM } from 'jsdom';
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
3
2
|
|
|
4
3
|
// maplibre-gl v6 にデフォルトエクスポートは無いので名前空間でインポートする。
|
|
5
4
|
import * as maplibregl from 'maplibre-gl';
|
|
@@ -12,20 +11,14 @@ import * as maplibregl from 'maplibre-gl';
|
|
|
12
11
|
|
|
13
12
|
describe('maplibre-gl jsdom limitation', () => {
|
|
14
13
|
it('jsdom上ではMaplibre Mapインスタンス生成時にエラー(WebGL未対応のため)', () => {
|
|
15
|
-
//
|
|
16
|
-
|
|
14
|
+
// vitest.config.ts の environment: 'jsdom' が用意する document を使う。
|
|
15
|
+
// 以前はここで JSDOM を自前に生成して global.window / global.document を
|
|
16
|
+
// 差し替えていたが、vitest 5 では jsdom 環境の document が getter のみになり
|
|
17
|
+
// 代入できない (Cannot set property document of [object Window])。
|
|
18
|
+
// 環境として jsdom が既にあるので、器だけ用意すれば足りる。
|
|
19
|
+
document.body.innerHTML = '<div id="map"></div>';
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
'<!DOCTYPE html><html><body><div id="map"></div></body></html>',
|
|
20
|
-
{
|
|
21
|
-
url: 'http://localhost',
|
|
22
|
-
pretendToBeVisual: true,
|
|
23
|
-
},
|
|
24
|
-
);
|
|
25
|
-
// @ts-ignore
|
|
26
|
-
global.window = dom.window;
|
|
27
|
-
global.document = dom.window.document;
|
|
28
|
-
let errorCaught = null;
|
|
21
|
+
let errorCaught: unknown = null;
|
|
29
22
|
try {
|
|
30
23
|
new maplibregl.Map({
|
|
31
24
|
container: 'map',
|
|
@@ -38,10 +31,20 @@ describe('maplibre-gl jsdom limitation', () => {
|
|
|
38
31
|
}
|
|
39
32
|
expect(errorCaught).toBeInstanceOf(Error);
|
|
40
33
|
expect(
|
|
41
|
-
/webgl|WebGL|context|device|Not implemented/i.test(
|
|
34
|
+
/webgl|WebGL|context|device|Not implemented/i.test(
|
|
35
|
+
(errorCaught as Error).message,
|
|
36
|
+
),
|
|
42
37
|
).toBe(true);
|
|
43
38
|
|
|
44
|
-
|
|
39
|
+
// 実行すると jsdom が
|
|
40
|
+
// Not implemented: HTMLCanvasElement's getContext() method
|
|
41
|
+
// をテスト出力に書く。これは失敗ではなく、このテストが記録している
|
|
42
|
+
// 「jsdom には WebGL が無い」ことの証跡そのもの。
|
|
43
|
+
//
|
|
44
|
+
// 以前は console.error を spy で潰していたが、vitest 5 では jsdom 環境が
|
|
45
|
+
// 環境セットアップ時に VirtualConsole を作るため、テスト内で貼る spy では
|
|
46
|
+
// もう捕まえられない (environmentOptions.jsdom.console: true でも同じ)。
|
|
47
|
+
// 何も抑制しない spy を残すと誤解を生むので外してある。
|
|
45
48
|
});
|
|
46
49
|
|
|
47
50
|
it('【NOTE】描画テストが必要な場合はE2E(ブラウザ実行)で行うこと', () => {
|
package/src/types-internal.ts
CHANGED
|
@@ -1,4 +1,22 @@
|
|
|
1
|
+
// 型を持たないモジュールと、maps-core が実行時に生やすプロパティのための
|
|
2
|
+
// アンビエント宣言をここにまとめている。
|
|
3
|
+
|
|
1
4
|
declare module '*.svg' {
|
|
2
5
|
const content: string;
|
|
3
6
|
export default content;
|
|
4
7
|
}
|
|
8
|
+
|
|
9
|
+
// TypeScript 6 は型を持たないモジュールの副作用 import を TS2882 として
|
|
10
|
+
// 報告するようになった。webpack 側は css-loader / style-loader が処理する。
|
|
11
|
+
declare module '*.css';
|
|
12
|
+
|
|
13
|
+
// maps-core は初期化した地図インスタンスをコンテナ要素に生やす。
|
|
14
|
+
// render.ts の二重初期化チェックと e2e がこれを読んでいる。
|
|
15
|
+
//
|
|
16
|
+
// このファイルはアンビエント宣言のためのスクリプト (module ではない) なので、
|
|
17
|
+
// グローバルの HTMLElement をそのまま宣言マージする。declare global は module で
|
|
18
|
+
// しか使えず、module にすると上の declare module '*.svg' が書けなくなる。
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
20
|
+
interface HTMLElement {
|
|
21
|
+
geoloniaMap?: import('@geolonia/maps-core').GeoloniaMap;
|
|
22
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -171,13 +171,57 @@ export type EmbedAttributes = {
|
|
|
171
171
|
* @defaultValue `''`(off として扱われる)
|
|
172
172
|
*/
|
|
173
173
|
'3d': string;
|
|
174
|
+
/**
|
|
175
|
+
* `data-choropleth`:`data-geojson` のポリゴンを、このプロパティの値で塗り分ける。
|
|
176
|
+
* 既定値はなく、指定したときだけキーが入る。
|
|
177
|
+
*/
|
|
178
|
+
choropleth?: string;
|
|
179
|
+
/**
|
|
180
|
+
* `data-choropleth-colors`:塗り分けの色。値の小さい側から順にカンマで区切る。
|
|
181
|
+
* `data-choropleth` が無いときは無視する。
|
|
182
|
+
*/
|
|
183
|
+
choroplethColors?: string;
|
|
184
|
+
/**
|
|
185
|
+
* `data-choropleth-range`:色を割り当てる値の範囲。`"最小,最大"` 形式。
|
|
186
|
+
* 省略時や読めないときはデータの最小値と最大値を使う。
|
|
187
|
+
*/
|
|
188
|
+
choroplethRange?: string;
|
|
189
|
+
/**
|
|
190
|
+
* `data-heatmap`:`data-geojson` のポイントをヒートマップで描く。`'on'` で重みなし、
|
|
191
|
+
* プロパティ名でその値を重みにする。`'off'` または空なら描かない。
|
|
192
|
+
*/
|
|
193
|
+
heatmap?: string;
|
|
194
|
+
/**
|
|
195
|
+
* `data-heatmap-colors`:ヒートマップの色。密度の低い側から順にカンマで区切る。
|
|
196
|
+
* `data-heatmap` が無いときは無視する。
|
|
197
|
+
*/
|
|
198
|
+
heatmapColors?: string;
|
|
199
|
+
/** `data-circle-size`:ポイントの円の大きさに使うプロパティ名。 */
|
|
200
|
+
circleSize?: string;
|
|
201
|
+
/** `data-circle-color`:ポイントの円の色に使うプロパティ名。 */
|
|
202
|
+
circleColor?: string;
|
|
203
|
+
/**
|
|
204
|
+
* `data-circle-colors`:`data-circle-color` に使う色をカンマで区切る。
|
|
205
|
+
* `data-circle-size` と `data-circle-color` のどちらも無いときは無視する。
|
|
206
|
+
*/
|
|
207
|
+
circleColors?: string;
|
|
174
208
|
/**
|
|
175
209
|
* 追加の `data-*` 属性はそのまま透過される({@link EmbedPlugin} が利用する
|
|
176
210
|
* プラグイン固有の属性など)。
|
|
177
211
|
*/
|
|
178
|
-
[otherKey: string]: string | number;
|
|
212
|
+
[otherKey: string]: string | number | undefined;
|
|
179
213
|
};
|
|
180
214
|
|
|
215
|
+
/**
|
|
216
|
+
* プラグインが独自に読む `data-*` 属性の型。
|
|
217
|
+
*
|
|
218
|
+
* {@link EmbedAttributes} のインデックスシグネチャが `number` も許すのは、
|
|
219
|
+
* `maxZoom: 20` のように既定値が数値の組み込み属性があるため。一方こちらは
|
|
220
|
+
* プラグイン固有の `data-*` だけを指し、`parseAtts` が `container.dataset`
|
|
221
|
+
* (`DOMStringMap`) をそのまま広げて渡すので、実行時には必ず文字列か未定義になる。
|
|
222
|
+
*/
|
|
223
|
+
export type EmbedPluginAttributes = { [otherKey: string]: string | undefined };
|
|
224
|
+
|
|
181
225
|
/**
|
|
182
226
|
* 埋め込みプラグインの型。地図インスタンス、対象のコンテナ要素、正規化済みの
|
|
183
227
|
* {@link EmbedAttributes} を受け取って呼び出される。
|
|
@@ -188,9 +232,7 @@ export type EmbedAttributes = {
|
|
|
188
232
|
* 対しては呼び出されない。
|
|
189
233
|
*/
|
|
190
234
|
export type EmbedPlugin<
|
|
191
|
-
PluginAttributes extends
|
|
192
|
-
[otherKey: string]: string;
|
|
193
|
-
},
|
|
235
|
+
PluginAttributes extends EmbedPluginAttributes = EmbedPluginAttributes,
|
|
194
236
|
> = (
|
|
195
237
|
map: GeoloniaMap,
|
|
196
238
|
target: HTMLElement,
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '6.0.0
|
|
1
|
+
export const VERSION = '6.0.0';
|
package/tsconfig.build.json
CHANGED
package/tsconfig.json
CHANGED
|
@@ -12,13 +12,15 @@
|
|
|
12
12
|
"sourceMap": true,
|
|
13
13
|
"esModuleInterop": true,
|
|
14
14
|
"allowSyntheticDefaultImports": true,
|
|
15
|
-
|
|
15
|
+
"strict": true,
|
|
16
16
|
"forceConsistentCasingInFileNames": true,
|
|
17
17
|
"module": "esnext",
|
|
18
|
-
"moduleResolution": "
|
|
18
|
+
"moduleResolution": "bundler",
|
|
19
|
+
// TypeScript 6 は node_modules/@types を自動で全部取り込まなくなったので、
|
|
20
|
+
// グローバル型が要るものを明示する (process など)。
|
|
21
|
+
"types": ["node"],
|
|
19
22
|
"resolveJsonModule": true,
|
|
20
23
|
"isolatedModules": true,
|
|
21
|
-
"jsx": "react-jsx",
|
|
22
24
|
"noFallthroughCasesInSwitch": true,
|
|
23
25
|
"newLine": "lf"
|
|
24
26
|
},
|
package/webpack.config.js
CHANGED
|
@@ -83,7 +83,7 @@ const sharedConfig = {
|
|
|
83
83
|
},
|
|
84
84
|
},
|
|
85
85
|
{
|
|
86
|
-
test: /\.
|
|
86
|
+
test: /\.ts$/,
|
|
87
87
|
use: {
|
|
88
88
|
loader: 'ts-loader',
|
|
89
89
|
options: {
|
|
@@ -99,7 +99,7 @@ const sharedConfig = {
|
|
|
99
99
|
],
|
|
100
100
|
},
|
|
101
101
|
resolve: {
|
|
102
|
-
extensions: ['.
|
|
102
|
+
extensions: ['.ts', '.js'],
|
|
103
103
|
},
|
|
104
104
|
};
|
|
105
105
|
|