@mapcreator/sdk 0.0.9 → 0.0.10
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/dist/{esm/HighlightManager.d.ts → HighlightManager.d.ts} +2 -2
- package/dist/{esm/MCMap.d.ts → MCMap.d.ts} +1 -1
- package/dist/{esm/PopupManager.d.ts → PopupManager.d.ts} +4 -4
- package/dist/{esm/Registry.d.ts → Registry.d.ts} +3 -3
- package/dist/{esm/adornments → adornments}/categoricalLegend.d.ts +1 -1
- package/dist/{esm/adornments → adornments}/connectedLegend.d.ts +2 -2
- package/dist/{esm/adornments → adornments}/customAdornment.d.ts +1 -1
- package/dist/{esm/adornments → adornments}/heading.d.ts +1 -1
- package/dist/adornments/insetMap.d.ts +3 -0
- package/dist/{esm/adornments → adornments}/manualLegend.d.ts +1 -1
- package/dist/adornments/northArrow.d.ts +3 -0
- package/dist/adornments/scalebar.d.ts +3 -0
- package/dist/{esm/constants → constants}/index.d.ts +2 -2
- package/dist/{esm/controls → controls}/fullscreenControls.d.ts +1 -1
- package/dist/{esm/controls → controls}/geocoderControl.d.ts +1 -1
- package/dist/{esm/controls → controls}/geolocationControls.d.ts +1 -1
- package/dist/controls/refreshMapControls.d.ts +3 -0
- package/dist/controls/webControls.d.ts +4 -0
- package/dist/{esm/controls → controls}/zoomControls.d.ts +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/locales/da_DK/strings.json.d.ts +10 -0
- package/dist/locales/de_DE/strings.json.d.ts +10 -0
- package/dist/locales/en_GB/strings.json.d.ts +10 -0
- package/dist/locales/es_ES/strings.json.d.ts +10 -0
- package/dist/locales/fr_FR/strings.json.d.ts +10 -0
- package/dist/locales/it_IT/strings.json.d.ts +10 -0
- package/dist/locales/nl_NL/strings.json.d.ts +10 -0
- package/dist/mapcreator-sdk.js +39590 -0
- package/dist/models/area.d.ts +5 -0
- package/dist/models/circle.d.ts +5 -0
- package/dist/models/dot.d.ts +3 -0
- package/dist/models/line.d.ts +4 -0
- package/dist/models/marker.d.ts +5 -0
- package/dist/models/polygon.d.ts +5 -0
- package/dist/{esm/renderAdornments.d.ts → renderAdornments.d.ts} +3 -3
- package/dist/{esm/types → types}/index.d.ts +1 -1
- package/dist/{esm/types → types}/mapstyle.d.ts +2 -6
- package/dist/{esm/utils → utils}/choropleth.d.ts +3 -3
- package/dist/{esm/utils → utils}/geolocation.d.ts +1 -1
- package/dist/{esm/utils → utils}/graphhopper.d.ts +1 -1
- package/dist/{esm/utils → utils}/helpers.d.ts +2 -2
- package/dist/{esm/utils → utils}/language.d.ts +1 -1
- package/dist/{esm/utils → utils}/models.d.ts +4 -4
- package/dist/{esm/utils → utils}/overlays.d.ts +1 -1
- package/dist/{esm/utils → utils}/svgHelpers.d.ts +3 -4
- package/dist/{esm/utils → utils}/template.d.ts +2 -2
- package/dist/{esm/utils → utils}/youtube.d.ts +1 -1
- package/package.json +7 -6
- package/dist/esm/HighlightManager.js +0 -203
- package/dist/esm/MCMap.js +0 -254
- package/dist/esm/PopupManager.js +0 -297
- package/dist/esm/Registry.js +0 -74
- package/dist/esm/adornments/categoricalLegend.js +0 -141
- package/dist/esm/adornments/connectedLegend.js +0 -393
- package/dist/esm/adornments/customAdornment.js +0 -29
- package/dist/esm/adornments/heading.js +0 -71
- package/dist/esm/adornments/insetMap.d.ts +0 -3
- package/dist/esm/adornments/insetMap.js +0 -351
- package/dist/esm/adornments/manualLegend.js +0 -15
- package/dist/esm/adornments/northArrow.d.ts +0 -3
- package/dist/esm/adornments/northArrow.js +0 -24
- package/dist/esm/adornments/scalebar.d.ts +0 -3
- package/dist/esm/adornments/scalebar.js +0 -176
- package/dist/esm/constants/index.js +0 -53
- package/dist/esm/controls/controls.js +0 -7
- package/dist/esm/controls/fullscreenControls.js +0 -29
- package/dist/esm/controls/geocoderControl.js +0 -202
- package/dist/esm/controls/geolocationControls.js +0 -65
- package/dist/esm/controls/refreshMapControls.d.ts +0 -3
- package/dist/esm/controls/refreshMapControls.js +0 -26
- package/dist/esm/controls/webControls.d.ts +0 -4
- package/dist/esm/controls/webControls.js +0 -40
- package/dist/esm/controls/zoomControls.js +0 -23
- package/dist/esm/i18n.js +0 -21
- package/dist/esm/index.d.ts +0 -5
- package/dist/esm/index.js +0 -5
- package/dist/esm/locales/da_DK/strings.json +0 -7
- package/dist/esm/locales/de_DE/strings.json +0 -7
- package/dist/esm/locales/en_GB/strings.json +0 -7
- package/dist/esm/locales/es_ES/strings.json +0 -7
- package/dist/esm/locales/fr_FR/strings.json +0 -7
- package/dist/esm/locales/it_IT/strings.json +0 -7
- package/dist/esm/locales/nl_NL/strings.json +0 -7
- package/dist/esm/models/area.d.ts +0 -5
- package/dist/esm/models/area.js +0 -165
- package/dist/esm/models/circle.d.ts +0 -5
- package/dist/esm/models/circle.js +0 -110
- package/dist/esm/models/dot.d.ts +0 -3
- package/dist/esm/models/dot.js +0 -42
- package/dist/esm/models/line.d.ts +0 -4
- package/dist/esm/models/line.js +0 -117
- package/dist/esm/models/marker.d.ts +0 -5
- package/dist/esm/models/marker.js +0 -179
- package/dist/esm/models/polygon.d.ts +0 -5
- package/dist/esm/models/polygon.js +0 -80
- package/dist/esm/renderAdornments.js +0 -129
- package/dist/esm/types/geometry.js +0 -1
- package/dist/esm/types/index.js +0 -1
- package/dist/esm/types/jobObject.js +0 -1
- package/dist/esm/types/mapstyle.js +0 -1
- package/dist/esm/utils/browser.js +0 -6
- package/dist/esm/utils/choropleth.js +0 -110
- package/dist/esm/utils/fullscreen.js +0 -40
- package/dist/esm/utils/geolocation.js +0 -93
- package/dist/esm/utils/graphhopper.js +0 -41
- package/dist/esm/utils/helpers.js +0 -116
- package/dist/esm/utils/language.js +0 -170
- package/dist/esm/utils/models.js +0 -103
- package/dist/esm/utils/overlays.js +0 -87
- package/dist/esm/utils/scalebar.js +0 -52
- package/dist/esm/utils/svgHelpers.js +0 -1512
- package/dist/esm/utils/template.js +0 -120
- package/dist/esm/utils/youtube.js +0 -64
- /package/dist/{esm/controls → controls}/controls.d.ts +0 -0
- /package/dist/{esm/i18n.d.ts → i18n.d.ts} +0 -0
- /package/dist/{esm/types → types}/geometry.d.ts +0 -0
- /package/dist/{esm/types → types}/jobObject.d.ts +0 -0
- /package/dist/{esm/utils → utils}/browser.d.ts +0 -0
- /package/dist/{esm/utils → utils}/fullscreen.d.ts +0 -0
- /package/dist/{esm/utils → utils}/scalebar.d.ts +0 -0
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import prevButtonIcon from '@/images/popup-previous.svg?raw';
|
|
2
|
-
import closeButtonIcon from '@/images/popup-close.svg?raw';
|
|
3
|
-
import nextButtonIcon from '@/images/popup-next.svg?raw';
|
|
4
|
-
import alertIcon from '@/images/alert-triangle.svg?raw';
|
|
5
|
-
import { t } from '@/i18n';
|
|
6
|
-
import { getEmbedUrlFromYoutubeUrl } from '@/utils/youtube';
|
|
7
|
-
import { bindingToString, getYoutubeVideoId, resolveBinding } from '@/utils/helpers';
|
|
8
|
-
export function buildTemplate(template, popupMedia, bindings, mode) {
|
|
9
|
-
let mediaHtml;
|
|
10
|
-
if (popupMedia?.type === 'video') {
|
|
11
|
-
mediaHtml =
|
|
12
|
-
mode === 'preview'
|
|
13
|
-
? getYoutubePlaceholder(popupMedia.src, bindings)
|
|
14
|
-
: `
|
|
15
|
-
<div class="youtube-container">
|
|
16
|
-
<iframe
|
|
17
|
-
src="${getEmbedUrlFromYoutubeUrl(popupMedia, bindings)}"
|
|
18
|
-
width="100%" height="300" style="border: none" allowfullscreen>
|
|
19
|
-
</iframe>
|
|
20
|
-
</div>
|
|
21
|
-
`;
|
|
22
|
-
}
|
|
23
|
-
else if (popupMedia?.type === 'image') {
|
|
24
|
-
const src = resolveBinding(popupMedia.src, bindings);
|
|
25
|
-
const alt = resolveBinding(popupMedia.alt, bindings);
|
|
26
|
-
const fillClass = popupMedia.fill ? 'fill' : '';
|
|
27
|
-
mediaHtml = `
|
|
28
|
-
<div class="image-container ${fillClass}">
|
|
29
|
-
<img src="${src}" alt="${alt}" />
|
|
30
|
-
</div>
|
|
31
|
-
`;
|
|
32
|
-
}
|
|
33
|
-
mediaHtml = mediaHtml ? `<div class="media-content">${mediaHtml}</div>` : '';
|
|
34
|
-
const textHtml = template
|
|
35
|
-
? `<div class="text-content">${parseTemplate(template, bindings)}</div>`
|
|
36
|
-
: '';
|
|
37
|
-
return `
|
|
38
|
-
<div class="popup-scroll-wrapper">
|
|
39
|
-
<div class="mc-popup">
|
|
40
|
-
${mediaHtml}
|
|
41
|
-
${textHtml}
|
|
42
|
-
</div>
|
|
43
|
-
</div>
|
|
44
|
-
`;
|
|
45
|
-
}
|
|
46
|
-
export const closeButtonHtml = `
|
|
47
|
-
<button class="mc-popup-button close">
|
|
48
|
-
${closeButtonIcon}
|
|
49
|
-
</button>
|
|
50
|
-
`;
|
|
51
|
-
export const cycleButtonsHtml = `
|
|
52
|
-
<div class="cycle-buttons">
|
|
53
|
-
<button class="mc-popup-button prev">
|
|
54
|
-
${prevButtonIcon}
|
|
55
|
-
</button>
|
|
56
|
-
<button class="mc-popup-button next">
|
|
57
|
-
${nextButtonIcon}
|
|
58
|
-
</button>
|
|
59
|
-
</div>
|
|
60
|
-
`;
|
|
61
|
-
/**
|
|
62
|
-
* @todo Use DOM
|
|
63
|
-
*/
|
|
64
|
-
function parseTemplate(template, bindings) {
|
|
65
|
-
// Copied from https://gitlab.com/mapcreator/mapcreator/-/blob/master/src/utils/template.ts#L11
|
|
66
|
-
if (!template) {
|
|
67
|
-
return '';
|
|
68
|
-
}
|
|
69
|
-
const reAnchors = />\$(.+?)</gi;
|
|
70
|
-
const reMentionSpan = /<span\s+class="mention"\s+data-mention-id="[^"]*">(.*?)<\/span>/gim;
|
|
71
|
-
const reAttributes = /(\S+?)\s*=\s*"\$([^"]+?)"/g;
|
|
72
|
-
const reMentionYoutube = /youtube\.com\/embed\/\$([^"'<>\\]+)/gi;
|
|
73
|
-
// Remove image placeholder
|
|
74
|
-
template = template.replace(/placeholder="[^"]+"/, '');
|
|
75
|
-
template = template.replace(/onerror="[^"]+"/, '');
|
|
76
|
-
// Replace youtube mention
|
|
77
|
-
template = template.replace(reMentionYoutube, (match, name) => {
|
|
78
|
-
const string = bindingToString(bindings[name]);
|
|
79
|
-
return string ? `youtube.com/embed/${getYoutubeVideoId(string)}?` : '';
|
|
80
|
-
});
|
|
81
|
-
// Replace all generically bound attributes
|
|
82
|
-
template = template.replace(reAttributes, (match, attr, name) => {
|
|
83
|
-
const string = bindingToString(bindings[name]);
|
|
84
|
-
if (['src', 'href'].includes(attr) && !string) {
|
|
85
|
-
return '';
|
|
86
|
-
}
|
|
87
|
-
if (['src', 'href'].includes(attr)) {
|
|
88
|
-
// Skip normalization for known protocols
|
|
89
|
-
if (/^(mailto:|tel:|ftp:|data:|http:\/\/|https:\/\/)/i.test(string)) {
|
|
90
|
-
return ` ${attr}="${string}"`;
|
|
91
|
-
}
|
|
92
|
-
return ` ${attr}="${normalizeUrl(string)}"`;
|
|
93
|
-
}
|
|
94
|
-
return ` ${attr}="${string}"`;
|
|
95
|
-
});
|
|
96
|
-
// Replace $foo with the correct value
|
|
97
|
-
template = template.replace(reAnchors, (match, name) => `>${bindingToString(bindings[name])}<`);
|
|
98
|
-
// Remove mention anchors <span class=\"mention\" data-mention-id=\"mc-type\">$mc-type</span>
|
|
99
|
-
template = template.replace(reMentionSpan, (_, name) => name);
|
|
100
|
-
return template;
|
|
101
|
-
}
|
|
102
|
-
function normalizeUrl(url) {
|
|
103
|
-
if (!/^https?:\/\//i.test(url)) {
|
|
104
|
-
return `https://${url}`;
|
|
105
|
-
}
|
|
106
|
-
return url;
|
|
107
|
-
}
|
|
108
|
-
function getYoutubePlaceholder(url, bindings) {
|
|
109
|
-
const id = getYoutubeVideoId(resolveBinding(url, bindings));
|
|
110
|
-
const thumbnailUrl = `https://img.youtube.com/vi/${id}/hqdefault.jpg`;
|
|
111
|
-
return `
|
|
112
|
-
<div class="youtube-placeholder">
|
|
113
|
-
<img src="${thumbnailUrl}" />
|
|
114
|
-
<div class="popup-alert">
|
|
115
|
-
<div class="alert-icon">${alertIcon}</div>
|
|
116
|
-
<div>${t('videoAlert')}</div>
|
|
117
|
-
</div>
|
|
118
|
-
</div>
|
|
119
|
-
`;
|
|
120
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { resolveBinding } from '@/utils/helpers';
|
|
2
|
-
export function getEmbedUrlFromYoutubeUrl(popupmedia, bindings) {
|
|
3
|
-
const { allowFullscreen, loop } = popupmedia;
|
|
4
|
-
const src = resolveBinding(popupmedia.src, bindings);
|
|
5
|
-
let embedUrl;
|
|
6
|
-
const idMatch = src.match(/(?:youtube\.com\/(?:watch\?.*v=|embed\/|v\/)|youtu\.be\/)([-\w]{11})/);
|
|
7
|
-
const id = idMatch?.[1];
|
|
8
|
-
if (id) {
|
|
9
|
-
embedUrl = `https://www.youtube.com/embed/${id}`;
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
embedUrl = src;
|
|
13
|
-
}
|
|
14
|
-
const params = [];
|
|
15
|
-
if (!allowFullscreen) {
|
|
16
|
-
params.push('fs=0');
|
|
17
|
-
}
|
|
18
|
-
if (loop && id) {
|
|
19
|
-
params.push(`loop=1&playlist=${id}`);
|
|
20
|
-
}
|
|
21
|
-
embedUrl = convertYouTubeTimeParam(embedUrl);
|
|
22
|
-
embedUrl = stripSiParam(embedUrl);
|
|
23
|
-
if (params.length) {
|
|
24
|
-
const separator = embedUrl.includes('?') ? '&' : '?';
|
|
25
|
-
embedUrl += `${separator}${params.join('&')}`;
|
|
26
|
-
}
|
|
27
|
-
return embedUrl;
|
|
28
|
-
}
|
|
29
|
-
function stripSiParam(url) {
|
|
30
|
-
return url.replace(/([?&])si=[^&]+(&)?/, (_, sep, tail) => {
|
|
31
|
-
if (sep === '?' && !tail) {
|
|
32
|
-
return '';
|
|
33
|
-
}
|
|
34
|
-
if (sep === '?' && tail) {
|
|
35
|
-
return '?';
|
|
36
|
-
}
|
|
37
|
-
return tail ? '&' : '';
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
function convertYouTubeTimeParam(url) {
|
|
41
|
-
const urlObj = new URL(url);
|
|
42
|
-
const t = urlObj.searchParams.get('t');
|
|
43
|
-
if (!t) {
|
|
44
|
-
return url;
|
|
45
|
-
}
|
|
46
|
-
let seconds = 0;
|
|
47
|
-
const timeRegex = /^((\d+)m)?((\d+)s)?$/;
|
|
48
|
-
if (/^\d+$/.test(t)) {
|
|
49
|
-
seconds = parseInt(t, 10);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
const match = t.match(timeRegex);
|
|
53
|
-
if (match) {
|
|
54
|
-
const minutes = parseInt(match[2] || '0', 10);
|
|
55
|
-
const secs = parseInt(match[4] || '0', 10);
|
|
56
|
-
seconds = minutes * 60 + secs;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
if (seconds > 0) {
|
|
60
|
-
urlObj.searchParams.delete('t');
|
|
61
|
-
urlObj.searchParams.set('start', String(seconds));
|
|
62
|
-
}
|
|
63
|
-
return urlObj.toString();
|
|
64
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|