@trailstash/ultra 3.1.0 → 3.1.2

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/cli/build.js CHANGED
@@ -36,7 +36,7 @@ export const buildOptions = (config, watch = false) => ({
36
36
  plugins: [
37
37
  copy({
38
38
  assets: {
39
- from: [path.join(ultraRoot, "static/*")],
39
+ from: [path.join(ultraRoot, "static/**/*")],
40
40
  to: [path.join(process.cwd(), "./dist")],
41
41
  },
42
42
  watch,
@@ -213,7 +213,10 @@ export class UltraIDE extends HTMLElement {
213
213
  };
214
214
  Object.assign(this.refs.mapLibre, {
215
215
  ...pick(settings, UltraMap.RUNTIME_SETTINGS),
216
- mapStyle: setBaseStyle(settings.mapStyle, this.settings.mapStyle),
216
+ mapStyle: setBaseStyle(
217
+ settings.mapStyle,
218
+ this.settings.mapStyle || UltraMap.defaults.mapStyle,
219
+ ),
217
220
  });
218
221
 
219
222
  this.refs.downloadButton.data = null;
@@ -286,7 +289,7 @@ export class UltraIDE extends HTMLElement {
286
289
  const settings = parseSettings(this.query);
287
290
  this.refs.mapLibre.mapStyle = setBaseStyle(
288
291
  settings.mapStyle,
289
- this.settings.mapStyle,
292
+ this.settings.mapStyle || UltraMap.defaults.mapStyle,
290
293
  );
291
294
  this.refs.mapLibre.run();
292
295
  }
@@ -1,3 +1,5 @@
1
+ import { fetchIfHTTPS } from "./util.js";
2
+
1
3
  const layers = (source) => [
2
4
  {
3
5
  id: `${source}-geojson-fill`,
@@ -117,18 +119,11 @@ const geoJsonTypes = [
117
119
  "MultiPolygon",
118
120
  ];
119
121
  async function detect(query) {
120
- try {
121
- if (query.startsWith("https://")) {
122
- const resp = await fetch(query, { cors: true });
123
- if (resp.ok) {
124
- query = await resp.text();
125
- }
126
- }
127
- } catch {}
122
+ query = await fetchIfHTTPS(query);
128
123
  try {
129
124
  const json = JSON.parse(query);
130
125
  if (geoJsonTypes.includes(json.type)) {
131
- return query;
126
+ return true;
132
127
  }
133
128
  } catch {}
134
129
  }
@@ -1,3 +1,4 @@
1
+ import { fetchIfHTTPS } from "./util.js";
1
2
  import { gpx } from "@tmcw/togeojson";
2
3
 
3
4
  const layers = (source) => [
@@ -65,20 +66,13 @@ const layers = (source) => [
65
66
  ];
66
67
 
67
68
  const detect = async (query) => {
68
- try {
69
- if (query.startsWith("https://")) {
70
- const resp = await fetch(query, { cors: true });
71
- if (resp.ok) {
72
- query = await resp.text();
73
- }
74
- }
75
- } catch {}
69
+ query = await fetchIfHTTPS(query);
76
70
  const doc = new window.DOMParser().parseFromString(query, "text/xml");
77
71
  if (
78
72
  !doc.querySelector("parsererror") &&
79
73
  Array.from(doc.childNodes).some((x) => x.nodeName === "gpx")
80
74
  ) {
81
- return query;
75
+ return true;
82
76
  }
83
77
  };
84
78
 
@@ -1,3 +1,4 @@
1
+ import { fetchIfHTTPS } from "./util.js";
1
2
  import { kml } from "@tmcw/togeojson";
2
3
 
3
4
  const layers = (source) => [
@@ -77,18 +78,7 @@ const detect = async (query) => {
77
78
  if (query.startsWith("https://www.google.com/maps/d/")) {
78
79
  return true;
79
80
  }
80
- if (query.startsWith("https://")) {
81
- try {
82
- const resp = await fetch(query, { cors: true });
83
- if (resp.ok) {
84
- query = await resp.text();
85
- } else {
86
- return false;
87
- }
88
- } catch {
89
- return false;
90
- }
91
- }
81
+ query = await fetchIfHTTPS(query);
92
82
  const doc = new window.DOMParser().parseFromString(query, "text/xml");
93
83
  return (
94
84
  !doc.querySelector("parsererror") &&
@@ -33,6 +33,13 @@ const overpassQLRegexes = [
33
33
  /out( geom| center| skel)?;/,
34
34
  ];
35
35
  function detect(query) {
36
+ const doc = new window.DOMParser().parseFromString(query, "text/xml");
37
+ if (
38
+ !doc.querySelector("parsererror") &&
39
+ Array.from(doc.childNodes).some((x) => x.nodeName === "osm-script")
40
+ ) {
41
+ return true;
42
+ }
36
43
  for (const re of overpassQLRegexes) {
37
44
  if (query.match(re)) {
38
45
  return query;
@@ -1,3 +1,4 @@
1
+ import { fetchIfHTTPS } from "./util.js";
1
2
  import { tcx } from "@tmcw/togeojson";
2
3
 
3
4
  const layers = (source) => [
@@ -65,14 +66,7 @@ const layers = (source) => [
65
66
  ];
66
67
 
67
68
  const detect = async (query) => {
68
- try {
69
- if (query.startsWith("https://")) {
70
- const resp = await fetch(query, { cors: true });
71
- if (resp.ok) {
72
- query = await resp.text();
73
- }
74
- }
75
- } catch {}
69
+ query = await fetchIfHTTPS(query);
76
70
  const doc = new window.DOMParser().parseFromString(query, "text/xml");
77
71
  if (
78
72
  !doc.querySelector("parsererror") &&
@@ -0,0 +1,11 @@
1
+ export const fetchIfHTTPS = async (query) => {
2
+ if (query.startsWith("https://")) {
3
+ try {
4
+ const resp = await fetch(query, { cors: true });
5
+ if (resp.ok) {
6
+ query = await resp.text();
7
+ }
8
+ } catch {}
9
+ }
10
+ return query;
11
+ };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.1.0",
6
+ "version": "3.1.2",
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": {
package/cli/.build.js.swo DELETED
Binary file