@fusion.dev/helix-map 0.212.0 → 0.212.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.
@@ -59,14 +59,16 @@ export interface MapSnapshot {
59
59
  * The tiles' credit, read from their TileJSON's `attribution`, as runs of
60
60
  * words and links: for a framework that writes `picture` in an element of
61
61
  * its own, and the credit in a `<span slot="attribution">` with
62
- * `data-helix-map-credit`. Empty where the tiles name none.
62
+ * `data-helix-map-credit`. Empty where the tiles name none. For
63
+ * OpenFreeMap's tiles, the default, it is OpenFreeMap's credit even where
64
+ * their TileJSON does not answer in time.
63
65
  */
64
66
  credit: CreditPart[];
65
67
  /**
66
68
  * The picture, then the credit in the frame's `attribution` slot, as markup
67
69
  * to write in the frame after the element the renderer draws in. The credit
68
- * alone where the picture could not be drawn and the tiles' TileJSON was
69
- * read, and an empty string where neither is known.
70
+ * alone where the picture could not be drawn and the credit is known, and
71
+ * an empty string where neither is known.
70
72
  */
71
73
  markup: string;
72
74
  /** The picture alone, as markup. An empty string where it could not be drawn. */
@@ -112,5 +114,10 @@ export interface MapSnapshot {
112
114
  * nothing for a failed picture showed the map with no credit until the
113
115
  * renderer read its own, and a page that never loads one, never. Cache only a
114
116
  * snapshot whose `picture` is not empty.
117
+ *
118
+ * **OpenFreeMap's credit outlives its TileJSON.** Where the default tiles'
119
+ * TileJSON does not answer in time, the snapshot carries the credit
120
+ * OpenFreeMap names, the same credit the TileJSON gives. A snapshot of your
121
+ * own tiles whose TileJSON does not answer carries no credit.
115
122
  */
116
123
  export declare const mapSnapshot: (asked: MapView, options?: SnapshotOptions) => Promise<MapSnapshot>;
@@ -152,6 +152,7 @@ const simplified = (points) => {
152
152
  };
153
153
  const nothing = () => ({ credit: [], markup: '', picture: '' });
154
154
  const OPENFREEMAP = 'https://tiles.openfreemap.org/planet';
155
+ const OPENFREEMAP_CREDIT = '<a href="https://openfreemap.org" target="_blank">OpenFreeMap</a> <a href="https://www.openmaptiles.org/" target="_blank">&copy; OpenMapTiles</a> Data from <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>';
155
156
  const MOST_TILES = 40;
156
157
  const MARGIN = 16;
157
158
  export const mapSnapshot = async (asked, options = {}) => {
@@ -181,12 +182,17 @@ export const mapSnapshot = async (asked, options = {}) => {
181
182
  }),
182
183
  ]).finally(() => clearTimeout(timer));
183
184
  };
184
- const tiles = await get(options.tiles ?? OPENFREEMAP)
185
+ const tileJson = options.tiles ?? OPENFREEMAP;
186
+ const tiles = await get(tileJson)
185
187
  .then((response) => (response.ok ? response.json() : undefined))
186
188
  .catch(() => undefined);
187
189
  const template = tiles?.tiles?.[0];
188
190
  if (!template) {
189
- return nothing();
191
+ if (tileJson !== OPENFREEMAP) {
192
+ return nothing();
193
+ }
194
+ const credit = creditParts([OPENFREEMAP_CREDIT]);
195
+ return { credit, markup: creditMarkup(credit), picture: '' };
190
196
  }
191
197
  const attribution = tiles.attribution;
192
198
  const credit = typeof attribution === 'string' ? creditParts([attribution]) : [];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fusion.dev/helix-map",
3
3
  "description": "Connects the Helix Map frame to a map renderer: MapLibre, Leaflet, or a driver of your own.",
4
- "version": "0.212.0",
4
+ "version": "0.212.2",
5
5
  "license": "MIT",
6
6
  "author": "Ross Sheppard <ross.sheppard@fusion.dev>",
7
7
  "repository": {
@@ -44,14 +44,14 @@
44
44
  },
45
45
  "bugs": "https://github.com/project-fusion/fusion/issues",
46
46
  "dependencies": {
47
- "@fusion.dev/helix-core": "0.212.0",
48
- "@fusion.dev/helix-icons": "0.212.0",
47
+ "@fusion.dev/helix-core": "0.212.2",
48
+ "@fusion.dev/helix-icons": "0.212.2",
49
49
  "@mapbox/vector-tile": "^3.0.0",
50
50
  "pbf": "^5.1.2"
51
51
  },
52
52
  "devDependencies": {
53
- "@fusion.dev/helix-headless": "0.212.0",
54
- "@fusion.dev/helix-testing": "0.212.0",
53
+ "@fusion.dev/helix-headless": "0.212.2",
54
+ "@fusion.dev/helix-testing": "0.212.2",
55
55
  "@maplibre/maplibre-gl-style-spec": "^26.4.4",
56
56
  "@types/bun": "^1.4.2",
57
57
  "@types/leaflet": "^1.9.20",