@trailstash/ultra 3.8.3 → 3.8.5
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
CHANGED
|
@@ -40,7 +40,7 @@ export class CodeEditor extends HTMLElement {
|
|
|
40
40
|
shadow.adoptedStyleSheets.push(style);
|
|
41
41
|
const textarea = h(
|
|
42
42
|
"textarea",
|
|
43
|
-
{ autofocus: this.autofocus, spellcheck: false },
|
|
43
|
+
{ autofocus: this.autofocus, spellcheck: false, autocapitalize: "off" },
|
|
44
44
|
this.source,
|
|
45
45
|
);
|
|
46
46
|
this.refs = { textarea };
|
package/components/ultra-ide.js
CHANGED
|
@@ -167,7 +167,7 @@ export class UltraIDE extends HTMLElement {
|
|
|
167
167
|
this.refs = {
|
|
168
168
|
navBar: shadow.querySelector("nav-bar"),
|
|
169
169
|
codeEditor: shadow.querySelector("code-editor"),
|
|
170
|
-
|
|
170
|
+
ultraMap: shadow.querySelector("ultra-map"),
|
|
171
171
|
runButton: shadow.querySelector("run-button"),
|
|
172
172
|
downloadButton: shadow.querySelector("download-button"),
|
|
173
173
|
shareButton: shadow.querySelector("share-button"),
|
|
@@ -190,8 +190,8 @@ export class UltraIDE extends HTMLElement {
|
|
|
190
190
|
"exit-fullscreen",
|
|
191
191
|
this.onExitFullscreen,
|
|
192
192
|
);
|
|
193
|
-
this.refs.
|
|
194
|
-
this.refs.
|
|
193
|
+
this.refs.ultraMap.map.on("moveend", this.onMoveEnd);
|
|
194
|
+
this.refs.ultraMap.map.once("idle", this.onMoveEnd);
|
|
195
195
|
|
|
196
196
|
// initialize share values
|
|
197
197
|
this.refs.shareButton.query = this.query;
|
|
@@ -219,7 +219,7 @@ export class UltraIDE extends HTMLElement {
|
|
|
219
219
|
...this.settings,
|
|
220
220
|
...parseSettings(this.query),
|
|
221
221
|
};
|
|
222
|
-
Object.assign(this.refs.
|
|
222
|
+
Object.assign(this.refs.ultraMap, {
|
|
223
223
|
...pick(settings, UltraMap.RUNTIME_SETTINGS),
|
|
224
224
|
mapStyle: setBaseStyle(
|
|
225
225
|
settings.mapStyle,
|
|
@@ -229,7 +229,7 @@ export class UltraIDE extends HTMLElement {
|
|
|
229
229
|
|
|
230
230
|
this.refs.downloadButton.data = null;
|
|
231
231
|
this.controller = new AbortController();
|
|
232
|
-
this.refs.downloadButton.data = await this.refs.
|
|
232
|
+
this.refs.downloadButton.data = await this.refs.ultraMap.run(
|
|
233
233
|
this.controller,
|
|
234
234
|
);
|
|
235
235
|
delete this.controller;
|
|
@@ -237,7 +237,7 @@ export class UltraIDE extends HTMLElement {
|
|
|
237
237
|
this.refs.runButton.loading = false;
|
|
238
238
|
} catch (err) {
|
|
239
239
|
this.resetMap();
|
|
240
|
-
this.refs.
|
|
240
|
+
this.refs.ultraMap.run();
|
|
241
241
|
this.refs.runButton.loading = false;
|
|
242
242
|
if (err.name != "AbortError") {
|
|
243
243
|
alert(err);
|
|
@@ -251,12 +251,12 @@ export class UltraIDE extends HTMLElement {
|
|
|
251
251
|
delete this.controller;
|
|
252
252
|
}
|
|
253
253
|
this.resetMap();
|
|
254
|
-
this.refs.
|
|
254
|
+
this.refs.ultraMap.run();
|
|
255
255
|
this.refs.runButton.loading = false;
|
|
256
256
|
}
|
|
257
257
|
resetMap() {
|
|
258
258
|
Object.assign(
|
|
259
|
-
this.refs.
|
|
259
|
+
this.refs.ultraMap,
|
|
260
260
|
pick(
|
|
261
261
|
{
|
|
262
262
|
...UltraMap.defaults,
|
|
@@ -274,8 +274,8 @@ export class UltraIDE extends HTMLElement {
|
|
|
274
274
|
settings.options?.zoom === undefined) &&
|
|
275
275
|
settings.options?.bounds === undefined
|
|
276
276
|
) {
|
|
277
|
-
params.center = this.refs.
|
|
278
|
-
params.zoom = this.refs.
|
|
277
|
+
params.center = this.refs.ultraMap.center.toArray();
|
|
278
|
+
params.zoom = this.refs.ultraMap.zoom;
|
|
279
279
|
}
|
|
280
280
|
window.location = toQueryParams(params);
|
|
281
281
|
}
|
|
@@ -285,8 +285,8 @@ export class UltraIDE extends HTMLElement {
|
|
|
285
285
|
localStorage.setItem("query", this.query);
|
|
286
286
|
}
|
|
287
287
|
onMoveEnd() {
|
|
288
|
-
const zoom = this.refs.
|
|
289
|
-
const center = this.refs.
|
|
288
|
+
const zoom = this.refs.ultraMap.zoom;
|
|
289
|
+
const center = this.refs.ultraMap.center.toArray();
|
|
290
290
|
this.refs.shareButton.zoom = zoom;
|
|
291
291
|
this.refs.shareButton.center = center;
|
|
292
292
|
}
|
|
@@ -295,11 +295,11 @@ export class UltraIDE extends HTMLElement {
|
|
|
295
295
|
style: e.detail.value,
|
|
296
296
|
});
|
|
297
297
|
const settings = parseSettings(this.query);
|
|
298
|
-
this.refs.
|
|
298
|
+
this.refs.ultraMap.mapStyle = setBaseStyle(
|
|
299
299
|
settings.mapStyle,
|
|
300
300
|
this.settings.mapStyle || UltraMap.defaults.mapStyle,
|
|
301
301
|
);
|
|
302
|
-
this.refs.
|
|
302
|
+
this.refs.ultraMap.run();
|
|
303
303
|
}
|
|
304
304
|
|
|
305
305
|
onEnterFullscreen() {
|
|
@@ -14,14 +14,15 @@ const overpassQLRegexes = [
|
|
|
14
14
|
/\({{bbox}}\)/,
|
|
15
15
|
/\[out:json\]/,
|
|
16
16
|
/\[out:xml\]/,
|
|
17
|
-
/node\[[
|
|
18
|
-
/way\[[
|
|
19
|
-
/relation\[[
|
|
20
|
-
/nwr\[[
|
|
21
|
-
/nw\[[
|
|
22
|
-
/nr\[[
|
|
23
|
-
/wr\[[
|
|
24
|
-
/area\[[
|
|
17
|
+
/node\[[^\]]+]/,
|
|
18
|
+
/way\[[^\]]+]/,
|
|
19
|
+
/relation\[[^\]]+]/,
|
|
20
|
+
/nwr\[[^\]]+]/,
|
|
21
|
+
/nw\[[^\]]+]/,
|
|
22
|
+
/nr\[[^\]]+]/,
|
|
23
|
+
/wr\[[^\]]+]/,
|
|
24
|
+
/area\[[^\]]+]/,
|
|
25
|
+
|
|
25
26
|
/node\([^)]\)/,
|
|
26
27
|
/way\([^)]\)/,
|
|
27
28
|
/relation\([^)]\)/,
|
|
@@ -30,7 +31,8 @@ const overpassQLRegexes = [
|
|
|
30
31
|
/nr\([^)]\)/,
|
|
31
32
|
/wr\([^)]\)/,
|
|
32
33
|
/area\([^)]\)/,
|
|
33
|
-
|
|
34
|
+
|
|
35
|
+
/out( meta| geom| center| skel)*;/,
|
|
34
36
|
];
|
|
35
37
|
function detect(query) {
|
|
36
38
|
const doc = new window.DOMParser().parseFromString(query, "text/xml");
|
|
@@ -42,9 +44,10 @@ function detect(query) {
|
|
|
42
44
|
}
|
|
43
45
|
for (const re of overpassQLRegexes) {
|
|
44
46
|
if (query.match(re)) {
|
|
45
|
-
return
|
|
47
|
+
return true;
|
|
46
48
|
}
|
|
47
49
|
}
|
|
50
|
+
return false;
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
const overpass = {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment jsdom
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import overpass from "./overpass.js";
|
|
6
|
+
|
|
7
|
+
describe("overpass", () => {
|
|
8
|
+
it("should detect Overpass XML", () => {
|
|
9
|
+
expect(overpass.detect("<osm-script></osm-script>")).toEqual(true);
|
|
10
|
+
});
|
|
11
|
+
it("should detect OverpassQL", () => {
|
|
12
|
+
expect(overpass.detect("node(8072127669);out;")).toEqual(true);
|
|
13
|
+
expect(
|
|
14
|
+
overpass.detect("node[amenity=bicycle_repair_station];out meta;"),
|
|
15
|
+
).toEqual(true);
|
|
16
|
+
expect(
|
|
17
|
+
overpass.detect(
|
|
18
|
+
"[bbox:-85.05112899999985,-143.4237868840288,85.05112900000006,143.19307950688642];way[highway];out geom;",
|
|
19
|
+
),
|
|
20
|
+
).toEqual(true);
|
|
21
|
+
expect(
|
|
22
|
+
overpass.detect(`[bbox:-85.05112899999985,-143.4237868840288,85.05112900000006,143.19307950688642];
|
|
23
|
+
(
|
|
24
|
+
way[highway=path];
|
|
25
|
+
way[highway=footway];
|
|
26
|
+
way[highway=cycleway];
|
|
27
|
+
way[highway=steps];
|
|
28
|
+
);
|
|
29
|
+
out meta geom;`),
|
|
30
|
+
).toEqual(true);
|
|
31
|
+
});
|
|
32
|
+
});
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "3.8.
|
|
6
|
+
"version": "3.8.5",
|
|
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": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"build:pages": "mkdir -p public && cp -Lr dist/* public/.",
|
|
18
18
|
"start": "node ./bin/run.js serve",
|
|
19
19
|
"format": "prettier --print-width=80 --write '**/*.js' '**/*.json' README.md '**/*.css'",
|
|
20
|
-
"test": "
|
|
20
|
+
"test": "jest"
|
|
21
21
|
},
|
|
22
22
|
"type": "module",
|
|
23
23
|
"repository": {
|
|
@@ -44,6 +44,9 @@
|
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/node": "^22.6.1",
|
|
46
46
|
"@unvt/sprite-one": "^0.1.1",
|
|
47
|
+
"esbuild-jest": "^0.5.0",
|
|
48
|
+
"jest": "^29.7.0",
|
|
49
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
47
50
|
"prettier": "^3.3.3",
|
|
48
51
|
"puppeteer": "^23.4.0",
|
|
49
52
|
"svg2png": "^4.1.1",
|
|
@@ -83,5 +86,10 @@
|
|
|
83
86
|
"commands": "./cli",
|
|
84
87
|
"dirname": "ultra",
|
|
85
88
|
"topicSeparator": " "
|
|
89
|
+
},
|
|
90
|
+
"jest": {
|
|
91
|
+
"transform": {
|
|
92
|
+
"^.+\\.js$": "esbuild-jest"
|
|
93
|
+
}
|
|
86
94
|
}
|
|
87
95
|
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { h } from "../lib/dom.js";
|
|
2
|
-
import buttonStyle from "./button.css";
|
|
3
|
-
import { style as buttonCSS } from "./button.js";
|
|
4
|
-
import { normalizeCSS } from "../lib/normalize.js";
|
|
5
|
-
|
|
6
|
-
export const css = new CSSStyleSheet();
|
|
7
|
-
css.replaceSync(`
|
|
8
|
-
button:after {
|
|
9
|
-
content: " Share";
|
|
10
|
-
}
|
|
11
|
-
@media (max-width: 900px) {
|
|
12
|
-
button:after {
|
|
13
|
-
content: "";
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
`);
|
|
17
|
-
|
|
18
|
-
export class ShareButton extends HTMLElement {
|
|
19
|
-
constructor() {
|
|
20
|
-
super();
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
connectedCallback() {
|
|
24
|
-
const shadow = this.attachShadow({ mode: "open" });
|
|
25
|
-
|
|
26
|
-
shadow.adoptedStyleSheets.push(normalizeCSS);
|
|
27
|
-
shadow.adoptedStyleSheets.push(buttonCSS);
|
|
28
|
-
shadow.adoptedStyleSheets.push(css);
|
|
29
|
-
|
|
30
|
-
const button = h("button", {}, h("fa-icon", { icon: "link" }));
|
|
31
|
-
this.refs = { button };
|
|
32
|
-
|
|
33
|
-
shadow.appendChild(button);
|
|
34
|
-
}
|
|
35
|
-
}
|