@trailstash/ultra 4.3.0 → 5.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/.gitlab-ci.yml +1 -0
- package/MapLibre-Examples/color-relief.ultra +58 -0
- package/components/button-modal.js +8 -9
- package/components/code-editor.js +2 -0
- package/components/export-modal.js +282 -0
- package/components/fontawesome-icon.js +4 -0
- package/components/share-modal.js +14 -0
- package/components/ultra-ide.js +55 -13
- package/components/ultra-map.js +38 -10
- package/config.mjs +1 -1
- package/docs/assets/MapLibre-Examples/color-relief.png +0 -0
- package/docs/assets/showcase/Pride-Map.png +0 -0
- package/docs/further-reading.md +1 -1
- package/docs/open-with-ultra.md +94 -0
- package/docs/showcase.md +10 -0
- package/docs/style.md +2 -2
- package/docs/url-parameters.md +1 -1
- package/docs/yaml.md +23 -1
- package/index.html +11 -3
- package/index.js +1 -1
- package/lib/htmlExport.js +74 -0
- package/lib/localStorage.js +0 -3
- package/lib/queryProviders/geojson.js +2 -2
- package/lib/queryProviders/gpx.js +2 -2
- package/lib/queryProviders/kml.js +2 -2
- package/lib/queryProviders/raster.js +2 -2
- package/lib/queryProviders/tcx.js +2 -2
- package/lib/queryProviders/util.js +2 -2
- package/lib/queryProviders/vector.js +21 -18
- package/lib/sandbox.js +93 -0
- package/lib/sprites.js +5 -1
- package/lib/style.js +3 -3
- package/og:image.ultra +44 -0
- package/package.json +3 -2
- package/pages-config.mjs +12 -0
- package/static/og:image.png +0 -0
package/lib/sandbox.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
const makeSandbox = () => {
|
|
2
|
+
const iframe = window.document.createElement("iframe");
|
|
3
|
+
const sandboxId = crypto.randomUUID();
|
|
4
|
+
iframe.style.display = "none";
|
|
5
|
+
iframe.src =
|
|
6
|
+
"data:text/html;base64," +
|
|
7
|
+
btoa(`<!DOCTYPE html>
|
|
8
|
+
<script type="module">
|
|
9
|
+
const p = "${window.location.origin}"
|
|
10
|
+
|
|
11
|
+
window.addEventListener(
|
|
12
|
+
"message",
|
|
13
|
+
async (event) => {
|
|
14
|
+
console.debug(event);
|
|
15
|
+
|
|
16
|
+
if (event.origin !== p) return;
|
|
17
|
+
|
|
18
|
+
let id;
|
|
19
|
+
try {
|
|
20
|
+
const msg = JSON.parse(event.data);
|
|
21
|
+
id = msg.id;
|
|
22
|
+
console.debug(msg)
|
|
23
|
+
|
|
24
|
+
const { default: transform } = await import(msg.transform);
|
|
25
|
+
|
|
26
|
+
const o = await Promise.resolve(transform(msg.data));
|
|
27
|
+
event.source.postMessage(JSON.stringify({id: msg.id, data: o}), p);
|
|
28
|
+
} catch (e) {
|
|
29
|
+
event.source.postMessage(JSON.stringify({id: id, error: e.toString()}), p);
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
false,
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
window.parent.postMessage(JSON.stringify({id: "${sandboxId}"}), p);
|
|
36
|
+
</script>
|
|
37
|
+
`);
|
|
38
|
+
|
|
39
|
+
const run = (transform, data) => {
|
|
40
|
+
const messageID = crypto.randomUUID();
|
|
41
|
+
return new Promise((resolve, reject) => {
|
|
42
|
+
const listener = (event) => {
|
|
43
|
+
console.debug(event);
|
|
44
|
+
try {
|
|
45
|
+
const msg = JSON.parse(event.data);
|
|
46
|
+
if (msg.id === messageID) {
|
|
47
|
+
window.removeEventListener("message", listener, false);
|
|
48
|
+
if (msg.error) {
|
|
49
|
+
reject(msg.error);
|
|
50
|
+
} else {
|
|
51
|
+
resolve(msg.data);
|
|
52
|
+
}
|
|
53
|
+
} else {
|
|
54
|
+
console.warn("unexpected msg!");
|
|
55
|
+
}
|
|
56
|
+
} catch (e) {
|
|
57
|
+
console.error(e);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
window.addEventListener("message", listener, false);
|
|
62
|
+
iframe.contentWindow.postMessage(
|
|
63
|
+
JSON.stringify({
|
|
64
|
+
id: messageID,
|
|
65
|
+
transform: `data:text/javascript;base64,${btoa(transform)}`,
|
|
66
|
+
data,
|
|
67
|
+
}),
|
|
68
|
+
"*",
|
|
69
|
+
);
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return new Promise((resolve) => {
|
|
74
|
+
const listener = (event) => {
|
|
75
|
+
window.removeEventListener("message", listener, false);
|
|
76
|
+
console.debug(event);
|
|
77
|
+
try {
|
|
78
|
+
const msg = JSON.parse(event.data);
|
|
79
|
+
if (msg.id === sandboxId) {
|
|
80
|
+
resolve(run);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
console.warn("unexpected msg!");
|
|
84
|
+
} catch (e) {
|
|
85
|
+
console.error(e);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
window.addEventListener("message", listener, false);
|
|
90
|
+
window.document.body.appendChild(iframe);
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
export default makeSandbox;
|
package/lib/sprites.js
CHANGED
|
@@ -8,7 +8,11 @@ export const handleStyleImageMissing = async (ev) => {
|
|
|
8
8
|
image.crossOrigin = "anonymous";
|
|
9
9
|
image.src = ev.id;
|
|
10
10
|
await image.decode();
|
|
11
|
-
ev.target.addImage(
|
|
11
|
+
ev.target.addImage(
|
|
12
|
+
ev.id,
|
|
13
|
+
image,
|
|
14
|
+
Object.fromEntries(new URLSearchParams(new URL(ev.id).hash.slice(1))),
|
|
15
|
+
);
|
|
12
16
|
}
|
|
13
17
|
}
|
|
14
18
|
if (builtin) {
|
package/lib/style.js
CHANGED
|
@@ -58,10 +58,10 @@ export async function getStyle(style, source) {
|
|
|
58
58
|
// If the layer exists, merge with defined layer, remove from layers, and default to
|
|
59
59
|
// reinserting it at the same index
|
|
60
60
|
if (curLayerIdx >= 0) {
|
|
61
|
-
newLayer = {
|
|
61
|
+
newLayer = movePaintAndLayoutKeys({
|
|
62
62
|
...layers[curLayerIdx],
|
|
63
|
-
...
|
|
64
|
-
};
|
|
63
|
+
...layer,
|
|
64
|
+
});
|
|
65
65
|
layerIdx = curLayerIdx;
|
|
66
66
|
layers.splice(curLayerIdx, 1);
|
|
67
67
|
}
|
package/og:image.ultra
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
options:
|
|
3
|
+
attributionControl: {}
|
|
4
|
+
bounds:
|
|
5
|
+
- -140.625
|
|
6
|
+
- -29.840643
|
|
7
|
+
- 70.664062
|
|
8
|
+
- 60.759159
|
|
9
|
+
controls:
|
|
10
|
+
- type: HTMLControl
|
|
11
|
+
options:
|
|
12
|
+
html: >
|
|
13
|
+
<div class="cover">Ultra <img src="./logo.svg"></div>
|
|
14
|
+
css: >
|
|
15
|
+
.cover {
|
|
16
|
+
pointer-events: all;
|
|
17
|
+
background: rgba(255,255,255,0.5);
|
|
18
|
+
position: fixed;
|
|
19
|
+
text-align: center;
|
|
20
|
+
line-height: 100vh;
|
|
21
|
+
font-size: 128px;
|
|
22
|
+
font-weight: bold;
|
|
23
|
+
top: 0;
|
|
24
|
+
left: 0;
|
|
25
|
+
right: 0;
|
|
26
|
+
bottom: 0;
|
|
27
|
+
backdrop-filter: blur(5px);
|
|
28
|
+
-webkit-backdrop-filter: blur(5px);
|
|
29
|
+
}
|
|
30
|
+
.cover img {
|
|
31
|
+
height: 176px;
|
|
32
|
+
vertical-align: middle;
|
|
33
|
+
}
|
|
34
|
+
style:
|
|
35
|
+
layers:
|
|
36
|
+
- id: geolines
|
|
37
|
+
visibility: none
|
|
38
|
+
- id: geolines-label
|
|
39
|
+
visibility: none
|
|
40
|
+
- id: countries-label
|
|
41
|
+
visibility: none
|
|
42
|
+
extends: https://demotiles.maplibre.org/style.json
|
|
43
|
+
---
|
|
44
|
+
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "
|
|
6
|
+
"version": "5.0.0",
|
|
7
7
|
"description": "A web based tool for making MapLibre GL maps with data from sources such as Overpass, GeoJSON, GPX, KML, TCX, etc",
|
|
8
8
|
"main": "index.js",
|
|
9
9
|
"scripts": {
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/node": "^22.6.1",
|
|
46
46
|
"@unvt/sprite-one": "github:dschep/sprite-one",
|
|
47
|
+
"emoji-datasource-google": "^15.1.2",
|
|
47
48
|
"esbuild-jest": "^0.5.0",
|
|
48
49
|
"jest": "^29.7.0",
|
|
49
50
|
"jest-environment-jsdom": "^29.7.0",
|
|
@@ -70,7 +71,7 @@
|
|
|
70
71
|
"liquidjs": "^10.17.0",
|
|
71
72
|
"lodash.pick": "^4.4.0",
|
|
72
73
|
"lz-string": "^1.5.0",
|
|
73
|
-
"maplibre-gl": "^5.
|
|
74
|
+
"maplibre-gl": "^5.6.0",
|
|
74
75
|
"marked": "^14.1.2",
|
|
75
76
|
"node-events": "^0.0.2",
|
|
76
77
|
"normalize.css": "^8.0.1",
|
package/pages-config.mjs
ADDED
|
Binary file
|