@trailstash/ultra 3.1.0 → 3.1.1

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,7 @@ 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(settings.mapStyle, this.settings.mapStyle || UltraMap.defaults.mapStyle),
217
217
  });
218
218
 
219
219
  this.refs.downloadButton.data = null;
@@ -286,7 +286,7 @@ export class UltraIDE extends HTMLElement {
286
286
  const settings = parseSettings(this.query);
287
287
  this.refs.mapLibre.mapStyle = setBaseStyle(
288
288
  settings.mapStyle,
289
- this.settings.mapStyle,
289
+ this.settings.mapStyle || UltraMap.defaults.mapStyle,
290
290
  );
291
291
  this.refs.mapLibre.run();
292
292
  }
@@ -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") &&
@@ -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.1",
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