@geolonia/embed 5.0.0 → 5.0.3
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 +16 -14
- package/.nvmrc +1 -1
- package/.prettierrc.json +4 -0
- package/.tool-versions +1 -1
- package/README.md +7 -1
- package/dist/embed +1 -1
- package/dist/embed-chunks/2489af4328c51b71e92d.js +2 -0
- package/dist/embed-chunks/6e05bbf5f391fda5b858.js +1 -0
- package/dist/embed.js +1 -1
- package/dist/src/embed.d.ts +3 -1
- package/dist/src/lib/geolonia-map.d.ts +1 -2
- package/dist/src/lib/geolonia-marker.d.ts +1 -2
- package/dist/src/lib/util.d.ts +1 -0
- package/dist/src/version.d.ts +1 -1
- package/e2e/map.spec.ts +1 -1
- package/eslint.config.js +232 -0
- package/package.json +20 -11
- package/src/embed.ts +13 -7
- package/src/lib/CustomAttributionControl.ts +52 -29
- package/src/lib/geolonia-map.ts +126 -39
- package/src/lib/geolonia-marker.ts +9 -6
- package/src/lib/keyring.test.ts +18 -0
- package/src/lib/keyring.ts +11 -13
- package/src/lib/maplibre-util.ts +31 -19
- package/src/lib/parse-atts.test.ts +3 -4
- package/src/lib/parse-atts.ts +1 -1
- package/src/lib/render.ts +18 -7
- package/src/lib/simplestyle-vector.ts +42 -13
- package/src/lib/simplestyle.test.ts +80 -69
- package/src/lib/simplestyle.ts +55 -34
- package/src/lib/util.test.ts +71 -22
- package/src/lib/util.ts +88 -32
- package/src/testability.test.ts +7 -4
- package/webpack.config.js +10 -1
- package/.eslintignore +0 -3
- package/.eslintrc.js +0 -17
- package/.prettierrc.js +0 -1
- package/dist/embed-chunks/416af3373e37004e65f4.js +0 -1
- package/dist/embed-chunks/488aacb380a87ea633f6.js +0 -2
- /package/dist/embed-chunks/{488aacb380a87ea633f6.js.LICENSE.txt → 2489af4328c51b71e92d.js.LICENSE.txt} +0 -0
package/src/lib/util.test.ts
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
2
|
-
|
|
3
1
|
import assert from 'assert';
|
|
4
2
|
import { JSDOM } from 'jsdom';
|
|
5
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
getContainer,
|
|
5
|
+
getLang,
|
|
6
|
+
getOptions,
|
|
7
|
+
getStyle,
|
|
8
|
+
handleMarkerOptions,
|
|
9
|
+
isDomElement,
|
|
10
|
+
isURL,
|
|
11
|
+
isGeoloniaTilesHost,
|
|
12
|
+
parseControlOption,
|
|
13
|
+
parseSimpleVector,
|
|
14
|
+
sanitizeDescription,
|
|
15
|
+
loadImageCompatibility,
|
|
16
|
+
} from './util';
|
|
6
17
|
|
|
7
18
|
const base = 'https://base.example.com/parent/';
|
|
8
19
|
|
|
@@ -47,12 +58,38 @@ describe('Tests for util.js', () => {
|
|
|
47
58
|
assert.deepEqual(false, isURL('example.com/hello'));
|
|
48
59
|
});
|
|
49
60
|
|
|
61
|
+
describe('isGeoloniaTilesHost', () => {
|
|
62
|
+
it('detects primary tileserver hostname', () => {
|
|
63
|
+
const url =
|
|
64
|
+
'https://tileserver.geolonia.com/v3/tiles.json?key=YOUR-API-KEY';
|
|
65
|
+
assert.strictEqual(isGeoloniaTilesHost(url), true);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('detects tiles.geolonia.com subdomains', () => {
|
|
69
|
+
const url = new URL('https://osm.v2.tiles.geolonia.com/tiles.json');
|
|
70
|
+
assert.strictEqual(isGeoloniaTilesHost(url), true);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('detects tiles.geolonia.com subdomains', () => {
|
|
74
|
+
const url = new URL('https://osm.v3.tiles.geolonia.com/tiles.json');
|
|
75
|
+
assert.strictEqual(isGeoloniaTilesHost(url), true);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('returns false for other hosts or invalid urls', () => {
|
|
79
|
+
assert.strictEqual(isGeoloniaTilesHost('https://example.com/tiles'), false);
|
|
80
|
+
assert.strictEqual(isGeoloniaTilesHost('not-a-url'), false);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
50
84
|
it('should detect the object is DOM correctly', () => {
|
|
51
85
|
const { document: mocDocument } = new JSDOM(`<html><body>
|
|
52
86
|
<div class="test-class"></div>
|
|
53
87
|
</body></html>`).window;
|
|
54
88
|
|
|
55
|
-
assert.deepEqual(
|
|
89
|
+
assert.deepEqual(
|
|
90
|
+
true,
|
|
91
|
+
isDomElement(mocDocument.querySelector('.test-class')),
|
|
92
|
+
);
|
|
56
93
|
assert.deepEqual(false, isDomElement('hello world'));
|
|
57
94
|
assert.deepEqual(false, isDomElement({ hello: 'world' }));
|
|
58
95
|
});
|
|
@@ -83,7 +120,8 @@ describe('Tests for util.js', () => {
|
|
|
83
120
|
assert.deepEqual(false, getContainer('#fail-element'));
|
|
84
121
|
assert.deepEqual(false, getContainer({ container: '#fail-element' }));
|
|
85
122
|
assert.deepEqual(false, getContainer('fail-element'));
|
|
86
|
-
assert.deepEqual(false, getContainer({ container: 'fail-element' }));
|
|
123
|
+
assert.deepEqual(false, getContainer({ container: 'fail-element' }));
|
|
124
|
+
});
|
|
87
125
|
|
|
88
126
|
it('should merge legacyoptions into options as expected.', () => {
|
|
89
127
|
const dom = new JSDOM(`<html><body>
|
|
@@ -94,7 +132,10 @@ describe('Tests for util.js', () => {
|
|
|
94
132
|
global.window = dom.window;
|
|
95
133
|
global.document = dom.window.document;
|
|
96
134
|
|
|
97
|
-
const options1 = handleMarkerOptions(
|
|
135
|
+
const options1 = handleMarkerOptions(
|
|
136
|
+
document.getElementById('test-element'),
|
|
137
|
+
{ color: '#FF1122' },
|
|
138
|
+
);
|
|
98
139
|
assert.deepEqual(document.getElementById('test-element'), options1.element);
|
|
99
140
|
assert.deepEqual(options1.color, '#FF1122');
|
|
100
141
|
|
|
@@ -135,10 +176,22 @@ describe('Tests for util.js', () => {
|
|
|
135
176
|
key: '1234',
|
|
136
177
|
};
|
|
137
178
|
|
|
138
|
-
assert.deepEqual(
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
179
|
+
assert.deepEqual(
|
|
180
|
+
'https://cdn.geolonia.com/style/hello/world/en.json',
|
|
181
|
+
getStyle('hello/world', atts),
|
|
182
|
+
);
|
|
183
|
+
assert.deepEqual(
|
|
184
|
+
'https://example.com/style.json',
|
|
185
|
+
getStyle('https://example.com/style.json', atts),
|
|
186
|
+
);
|
|
187
|
+
assert.deepEqual(
|
|
188
|
+
'https://base.example.com/parent/style.json',
|
|
189
|
+
getStyle('./style.json', atts),
|
|
190
|
+
);
|
|
191
|
+
assert.deepEqual(
|
|
192
|
+
'https://base.example.com/style.json',
|
|
193
|
+
getStyle('/style.json', atts),
|
|
194
|
+
);
|
|
142
195
|
});
|
|
143
196
|
|
|
144
197
|
it('should handle maplibregl options `minZoom` and `maxZoom` well', () => {
|
|
@@ -188,18 +241,12 @@ describe('Tests for util.js', () => {
|
|
|
188
241
|
|
|
189
242
|
it('should parse simple vector value with http.', () => {
|
|
190
243
|
const attributeValue = 'https://example.com/path/to/tile.json';
|
|
191
|
-
assert.strictEqual(
|
|
192
|
-
attributeValue,
|
|
193
|
-
parseSimpleVector(attributeValue),
|
|
194
|
-
);
|
|
244
|
+
assert.strictEqual(attributeValue, parseSimpleVector(attributeValue));
|
|
195
245
|
});
|
|
196
246
|
|
|
197
247
|
it('should parse simple vector value with geolonia schema.', () => {
|
|
198
248
|
const attributeValue = 'geolonia://tiles/username/ct_123';
|
|
199
|
-
assert.strictEqual(
|
|
200
|
-
attributeValue,
|
|
201
|
-
parseSimpleVector(attributeValue),
|
|
202
|
-
);
|
|
249
|
+
assert.strictEqual(attributeValue, parseSimpleVector(attributeValue));
|
|
203
250
|
});
|
|
204
251
|
|
|
205
252
|
it('should parse simple vector value with customtile ID', () => {
|
|
@@ -212,7 +259,8 @@ describe('Tests for util.js', () => {
|
|
|
212
259
|
|
|
213
260
|
describe('Tests for sanitizeDescription', async () => {
|
|
214
261
|
it('should sanitize description', async () => {
|
|
215
|
-
const description =
|
|
262
|
+
const description =
|
|
263
|
+
'<script>alert("hello");</script>ここが集合場所です。13時までに集合してください。';
|
|
216
264
|
assert.strictEqual(
|
|
217
265
|
'ここが集合場所です。13時までに集合してください。',
|
|
218
266
|
await sanitizeDescription(description),
|
|
@@ -221,7 +269,8 @@ describe('Tests for util.js', () => {
|
|
|
221
269
|
|
|
222
270
|
it('should not sanitize img tag, but should sanitize attributes other than "src", "srcset", "alt", "title", "width", "height", "loading"', async () => {
|
|
223
271
|
// Ref. https://www.npmjs.com/package/sanitize-html
|
|
224
|
-
const description =
|
|
272
|
+
const description =
|
|
273
|
+
'<img decoding="auto" src="hibiya-park.jpeg" /><br />ここが集合場所です。13時までに集合してください。';
|
|
225
274
|
assert.strictEqual(
|
|
226
275
|
'<img src="hibiya-park.jpeg" /><br />ここが集合場所です。13時までに集合してください。',
|
|
227
276
|
await sanitizeDescription(description),
|
|
@@ -229,7 +278,8 @@ describe('Tests for util.js', () => {
|
|
|
229
278
|
});
|
|
230
279
|
|
|
231
280
|
it('should not sanitize "class" attribute', async () => {
|
|
232
|
-
const description =
|
|
281
|
+
const description =
|
|
282
|
+
'<span class="red">ここが集合場所です。13時までに集合してください。</span>';
|
|
233
283
|
assert.strictEqual(
|
|
234
284
|
'<span class="red">ここが集合場所です。13時までに集合してください。</span>',
|
|
235
285
|
await sanitizeDescription(description),
|
|
@@ -238,7 +288,6 @@ describe('Tests for util.js', () => {
|
|
|
238
288
|
});
|
|
239
289
|
});
|
|
240
290
|
|
|
241
|
-
|
|
242
291
|
describe('loadImageCompatibility', () => {
|
|
243
292
|
it('should call the callback with response data when the promise resolves', (done) => {
|
|
244
293
|
// モックされた成功した promise
|
package/src/lib/util.ts
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
import { keyring } from './keyring';
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
GetResourceResponse,
|
|
6
|
+
MapOptions,
|
|
7
|
+
MarkerOptions,
|
|
8
|
+
ExpiryData,
|
|
9
|
+
} from 'maplibre-gl';
|
|
5
10
|
|
|
6
11
|
// GetImageCallback extracted from maplibre-gl v3.6.2 ( https://github.com/maplibre/maplibre-gl-js/releases/tag/v3.6.2 )
|
|
7
|
-
export type GetImageCallback = (
|
|
12
|
+
export type GetImageCallback = (
|
|
13
|
+
error?: Error | null,
|
|
14
|
+
image?: HTMLImageElement | ImageBitmap | null,
|
|
15
|
+
expiry?: ExpiryData | null,
|
|
16
|
+
) => void;
|
|
8
17
|
|
|
9
18
|
/**
|
|
10
19
|
*
|
|
@@ -18,7 +27,7 @@ export function isURL(str: string): string | false {
|
|
|
18
27
|
try {
|
|
19
28
|
return new URL(str, location.href).href;
|
|
20
29
|
} catch (error) {
|
|
21
|
-
console.error('[Geolonia]', error) // eslint-disable-line
|
|
30
|
+
console.error('[Geolonia]', error); // eslint-disable-line
|
|
22
31
|
return false;
|
|
23
32
|
}
|
|
24
33
|
}
|
|
@@ -26,6 +35,20 @@ export function isURL(str: string): string | false {
|
|
|
26
35
|
return false;
|
|
27
36
|
}
|
|
28
37
|
|
|
38
|
+
export function isGeoloniaTilesHost(url: string | URL): boolean {
|
|
39
|
+
try {
|
|
40
|
+
const urlObj = typeof url === 'string' ? new URL(url) : url;
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
// NOTE: geolonia use tileserver.geolonia.com or *.tiles.geolonia.com for tile server. Other domains is NOT allowed.
|
|
44
|
+
urlObj.hostname === 'tileserver.geolonia.com' ||
|
|
45
|
+
urlObj.hostname.endsWith('.tiles.geolonia.com')
|
|
46
|
+
);
|
|
47
|
+
} catch {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
29
52
|
export function checkPermission() {
|
|
30
53
|
// It looks that isn't iFrame, so returs true.
|
|
31
54
|
if (window.self === window.parent) {
|
|
@@ -45,7 +68,10 @@ export function checkPermission() {
|
|
|
45
68
|
window.self.location.origin === 'https://cdpn.io' ||
|
|
46
69
|
window.self.location.origin === 'https://codepen.io'
|
|
47
70
|
) {
|
|
48
|
-
if (
|
|
71
|
+
if (
|
|
72
|
+
window.self !== window.parent &&
|
|
73
|
+
window.document.referrer.indexOf('https://codepen.io') === 0
|
|
74
|
+
) {
|
|
49
75
|
return true;
|
|
50
76
|
}
|
|
51
77
|
}
|
|
@@ -54,7 +80,10 @@ export function checkPermission() {
|
|
|
54
80
|
* For the https://jsfiddle.net/
|
|
55
81
|
*/
|
|
56
82
|
if (window.self.location.origin === 'https://fiddle.jshell.net') {
|
|
57
|
-
if (
|
|
83
|
+
if (
|
|
84
|
+
window.self !== window.parent &&
|
|
85
|
+
window.document.referrer.indexOf('https://jsfiddle.net') === 0
|
|
86
|
+
) {
|
|
58
87
|
return true;
|
|
59
88
|
}
|
|
60
89
|
}
|
|
@@ -67,7 +96,10 @@ export function checkPermission() {
|
|
|
67
96
|
* another one is in new window.
|
|
68
97
|
*/
|
|
69
98
|
if (window.self.location.origin.match(/csb\.app$/)) {
|
|
70
|
-
if (
|
|
99
|
+
if (
|
|
100
|
+
window.self !== window.parent &&
|
|
101
|
+
window.document.referrer.indexOf('https://codesandbox.io') === 0
|
|
102
|
+
) {
|
|
71
103
|
return true;
|
|
72
104
|
}
|
|
73
105
|
}
|
|
@@ -80,7 +112,7 @@ export function checkPermission() {
|
|
|
80
112
|
if (window.self.location.origin === window.top.location.origin) {
|
|
81
113
|
return true;
|
|
82
114
|
}
|
|
83
|
-
} catch
|
|
115
|
+
} catch {
|
|
84
116
|
return false;
|
|
85
117
|
}
|
|
86
118
|
|
|
@@ -88,11 +120,11 @@ export function checkPermission() {
|
|
|
88
120
|
}
|
|
89
121
|
|
|
90
122
|
export function getLang() {
|
|
91
|
-
const lang =
|
|
92
|
-
window.navigator.languages &&
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
123
|
+
const lang =
|
|
124
|
+
(window.navigator.languages &&
|
|
125
|
+
window.navigator.languages[0] &&
|
|
126
|
+
window.navigator.languages[0].toLowerCase()) ||
|
|
127
|
+
window.navigator.language.toLowerCase();
|
|
96
128
|
|
|
97
129
|
if (lang === 'ja' || lang === 'ja-jp') {
|
|
98
130
|
return 'ja';
|
|
@@ -108,7 +140,10 @@ export function isScrollable() {
|
|
|
108
140
|
const body = document.body;
|
|
109
141
|
const html = document.documentElement;
|
|
110
142
|
|
|
111
|
-
return
|
|
143
|
+
return (
|
|
144
|
+
body.scrollHeight > body.clientHeight ||
|
|
145
|
+
html.scrollHeight > html.clientHeight
|
|
146
|
+
);
|
|
112
147
|
}
|
|
113
148
|
|
|
114
149
|
/**
|
|
@@ -117,10 +152,13 @@ export function isScrollable() {
|
|
|
117
152
|
* @param {*} o
|
|
118
153
|
*/
|
|
119
154
|
export function isDomElement(o): o is HTMLElement {
|
|
120
|
-
return
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
155
|
+
return typeof HTMLElement === 'object'
|
|
156
|
+
? o instanceof HTMLElement // DOM2
|
|
157
|
+
: o &&
|
|
158
|
+
typeof o === 'object' &&
|
|
159
|
+
o !== null &&
|
|
160
|
+
o.nodeType === 1 &&
|
|
161
|
+
typeof o.nodeName === 'string';
|
|
124
162
|
}
|
|
125
163
|
|
|
126
164
|
/**
|
|
@@ -130,18 +168,23 @@ export function isDomElement(o): o is HTMLElement {
|
|
|
130
168
|
* @param {*} arg
|
|
131
169
|
* @return {HTMLElement | false}
|
|
132
170
|
*/
|
|
133
|
-
export function getContainer(
|
|
171
|
+
export function getContainer(
|
|
172
|
+
arg: HTMLElement | string | { container: HTMLElement | string },
|
|
173
|
+
): HTMLElement | false {
|
|
134
174
|
if (isDomElement(arg)) {
|
|
135
175
|
return arg;
|
|
136
176
|
} else if (typeof arg === 'string') {
|
|
137
|
-
const el =
|
|
177
|
+
const el =
|
|
178
|
+
(document.querySelector(arg) as HTMLElement) ||
|
|
179
|
+
document.getElementById(arg);
|
|
138
180
|
return el || false;
|
|
139
|
-
|
|
140
181
|
} else if (arg.container) {
|
|
141
182
|
if (isDomElement(arg.container)) {
|
|
142
183
|
return arg.container;
|
|
143
184
|
} else if (typeof arg.container === 'string') {
|
|
144
|
-
const el =
|
|
185
|
+
const el =
|
|
186
|
+
(document.querySelector(arg.container) as HTMLElement) ||
|
|
187
|
+
document.getElementById(arg.container);
|
|
145
188
|
return el || false;
|
|
146
189
|
}
|
|
147
190
|
}
|
|
@@ -155,7 +198,10 @@ export function getContainer(arg: HTMLElement | string | { container: HTMLElemen
|
|
|
155
198
|
* @param {*} options
|
|
156
199
|
* @param {*} legacyOptions
|
|
157
200
|
*/
|
|
158
|
-
export function handleMarkerOptions(
|
|
201
|
+
export function handleMarkerOptions(
|
|
202
|
+
options: MarkerOptions | null | undefined | false,
|
|
203
|
+
legacyOptions: MarkerOptions,
|
|
204
|
+
) {
|
|
159
205
|
if (options && isDomElement(options)) {
|
|
160
206
|
options = {
|
|
161
207
|
element: options as HTMLElement,
|
|
@@ -199,12 +245,15 @@ export function getOptions(container, params, atts): MapOptions {
|
|
|
199
245
|
bearing: parseFloat(atts.bearing),
|
|
200
246
|
pitch: parseFloat(atts.pitch),
|
|
201
247
|
zoom: parseFloat(atts.zoom),
|
|
202
|
-
hash:
|
|
248
|
+
hash: atts.hash === 'on',
|
|
203
249
|
localIdeographFontFamily: 'sans-serif',
|
|
204
250
|
attributionControl: false,
|
|
205
251
|
};
|
|
206
252
|
|
|
207
|
-
if (
|
|
253
|
+
if (
|
|
254
|
+
atts.minZoom !== '' &&
|
|
255
|
+
(Number(atts.minZoom) === 0 || Number(atts.minZoom))
|
|
256
|
+
) {
|
|
208
257
|
options.minZoom = Number(atts.minZoom);
|
|
209
258
|
}
|
|
210
259
|
|
|
@@ -224,7 +273,11 @@ export function getOptions(container, params, atts): MapOptions {
|
|
|
224
273
|
*/
|
|
225
274
|
export function parseControlOption(att) {
|
|
226
275
|
const normalizedAtt = att.toLowerCase();
|
|
227
|
-
if (
|
|
276
|
+
if (
|
|
277
|
+
['top-right', 'bottom-right', 'bottom-left', 'top-left'].includes(
|
|
278
|
+
normalizedAtt,
|
|
279
|
+
)
|
|
280
|
+
) {
|
|
228
281
|
return { enabled: true, position: normalizedAtt };
|
|
229
282
|
} else if (['on', 'off'].includes(normalizedAtt)) {
|
|
230
283
|
return { enabled: normalizedAtt === 'on', position: void 0 };
|
|
@@ -249,9 +302,9 @@ export const getSessionId = (digit) => {
|
|
|
249
302
|
} else {
|
|
250
303
|
const array = new Uint8Array(digit / 2);
|
|
251
304
|
window.crypto.getRandomValues(array);
|
|
252
|
-
const value = Array
|
|
253
|
-
|
|
254
|
-
|
|
305
|
+
const value = Array.from(array, (dec) =>
|
|
306
|
+
dec.toString(16).padStart(2, '0'),
|
|
307
|
+
).join('');
|
|
255
308
|
sessionId = value;
|
|
256
309
|
return value;
|
|
257
310
|
}
|
|
@@ -276,7 +329,6 @@ export const handleRestrictedMode = (map) => {
|
|
|
276
329
|
};
|
|
277
330
|
|
|
278
331
|
export const handleErrorMode = (container) => {
|
|
279
|
-
|
|
280
332
|
const errorContainer = document.createElement('div');
|
|
281
333
|
errorContainer.classList.add('geolonia__error-container');
|
|
282
334
|
|
|
@@ -287,7 +339,8 @@ export const handleErrorMode = (container) => {
|
|
|
287
339
|
div.appendChild(h1);
|
|
288
340
|
|
|
289
341
|
div.classList.add('geolonia__error-message');
|
|
290
|
-
div.innerHTML +=
|
|
342
|
+
div.innerHTML +=
|
|
343
|
+
'<div class="geolonia__error-message-description">地図の初期化に失敗しました。管理者にお問い合わせ下さい。開発者の方は開発者ツールでエラー詳細をご確認下さい。</div>';
|
|
291
344
|
|
|
292
345
|
errorContainer.appendChild(div);
|
|
293
346
|
container.appendChild(errorContainer);
|
|
@@ -296,8 +349,11 @@ export const handleErrorMode = (container) => {
|
|
|
296
349
|
export const sanitizeDescription = async (description) => {
|
|
297
350
|
const { default: sanitizeHtml } = await import('sanitize-html');
|
|
298
351
|
return sanitizeHtml(description, {
|
|
299
|
-
allowedTags: sanitizeHtml.defaults.allowedTags.concat([
|
|
300
|
-
allowedAttributes: {
|
|
352
|
+
allowedTags: sanitizeHtml.defaults.allowedTags.concat(['img']),
|
|
353
|
+
allowedAttributes: {
|
|
354
|
+
...sanitizeHtml.defaults.allowedAttributes,
|
|
355
|
+
'*': ['class'],
|
|
356
|
+
},
|
|
301
357
|
});
|
|
302
358
|
};
|
|
303
359
|
|
package/src/testability.test.ts
CHANGED
|
@@ -10,10 +10,13 @@ import maplibregl from 'maplibre-gl';
|
|
|
10
10
|
|
|
11
11
|
describe('maplibre-gl jsdom limitation', () => {
|
|
12
12
|
it('jsdom上ではMaplibre Mapインスタンス生成時にエラー(WebGL未対応のため)', () => {
|
|
13
|
-
const dom = new JSDOM(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
const dom = new JSDOM(
|
|
14
|
+
'<!DOCTYPE html><html><body><div id="map"></div></body></html>',
|
|
15
|
+
{
|
|
16
|
+
url: 'http://localhost',
|
|
17
|
+
pretendToBeVisual: true, // jsdomを視覚的な環境として
|
|
18
|
+
},
|
|
19
|
+
);
|
|
17
20
|
// @ts-ignore
|
|
18
21
|
global.window = dom.window;
|
|
19
22
|
global.document = dom.window.document;
|
package/webpack.config.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
|
|
3
|
+
const { DefinePlugin } = require('webpack');
|
|
3
4
|
|
|
5
|
+
const plugins = [
|
|
6
|
+
new DefinePlugin({
|
|
7
|
+
'process.env.MAP_PLATFORM_STAGE': JSON.stringify(process.env.MAP_PLATFORM_STAGE || 'dev'),
|
|
8
|
+
}),
|
|
9
|
+
];
|
|
10
|
+
if (process.env.ANALYZE === 'true') {
|
|
11
|
+
plugins.push(new BundleAnalyzerPlugin());
|
|
12
|
+
}
|
|
4
13
|
module.exports = {
|
|
5
14
|
entry: './src/embed.ts',
|
|
6
15
|
output: {
|
|
@@ -14,7 +23,7 @@ module.exports = {
|
|
|
14
23
|
type: 'umd',
|
|
15
24
|
},
|
|
16
25
|
},
|
|
17
|
-
plugins:
|
|
26
|
+
plugins: plugins,
|
|
18
27
|
module: {
|
|
19
28
|
rules: [
|
|
20
29
|
{
|
package/.eslintignore
DELETED
package/.eslintrc.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
env: {
|
|
3
|
-
browser: true,
|
|
4
|
-
commonjs: true,
|
|
5
|
-
es6: true,
|
|
6
|
-
node: true,
|
|
7
|
-
mocha: true,
|
|
8
|
-
},
|
|
9
|
-
extends: ['@geolonia'],
|
|
10
|
-
parserOptions: {
|
|
11
|
-
sourceType: 'module',
|
|
12
|
-
project: './tsconfig.json',
|
|
13
|
-
},
|
|
14
|
-
rules: {
|
|
15
|
-
'@typescript-eslint/ban-ts-comment': 'off',
|
|
16
|
-
},
|
|
17
|
-
};
|
package/.prettierrc.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = {}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunkgeoloniaEmbed=self.webpackChunkgeoloniaEmbed||[]).push([[445],{9746:()=>{},9977:()=>{},197:()=>{},1866:()=>{},2739:()=>{}}]);
|