@versatiles/svg-renderer 2.3.0 → 2.4.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.
Files changed (3) hide show
  1. package/dist/index.d.ts +25 -5
  2. package/dist/index.js +5782 -137
  3. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -2738,6 +2738,12 @@ declare class Feature implements Feature$1 {
2738
2738
  * clipped edges along the tile border are not part of the outline.
2739
2739
  */
2740
2740
  readonly outline?: Geometry;
2741
+ /**
2742
+ * The polygon as an opaque fill draws it — when it differs from the polygon's rings, i.e.
2743
+ * when the polygon was clipped to its tile: clipped a little beyond the tile instead, so
2744
+ * that it overlaps its continuation in the next tile, and no seam shows between them.
2745
+ */
2746
+ readonly fillGeometry?: Geometry;
2741
2747
  /**
2742
2748
  * For each line of the geometry, how far along the line in its tile it starts, in pixels
2743
2749
  * — where the line was clipped to its tile, which cut off its start. A dash pattern
@@ -2751,6 +2757,7 @@ declare class Feature implements Feature$1 {
2751
2757
  patterns?: Patterns;
2752
2758
  geometry: Geometry;
2753
2759
  outline?: Geometry;
2760
+ fillGeometry?: Geometry;
2754
2761
  lineStarts?: number[];
2755
2762
  });
2756
2763
  getBbox(): Bbox;
@@ -3068,11 +3075,19 @@ interface FetchResponse {
3068
3075
  arrayBuffer(): Promise<ArrayBuffer>;
3069
3076
  json(): Promise<unknown>;
3070
3077
  }
3078
+ /**
3079
+ * The part of `fetch`'s `RequestInit` the renderer passes. It sends request headers only
3080
+ * to read part of a file: a `Range` header for a PMTiles archive.
3081
+ */
3082
+ interface FetchRequestInit {
3083
+ headers?: Record<string, string>;
3084
+ }
3071
3085
  /**
3072
3086
  * Loads a URL, like `fetch`: the renderer loads tiles, sprites, TileJSON documents and GeoJSON data through it. It is called
3073
- * with the URL only, and should resolve to a `Response`.
3087
+ * with the URL, and for part of a file with request headers as well, and should resolve to
3088
+ * a `Response`.
3074
3089
  */
3075
- type FetchFunction = (url: string) => Promise<FetchResponse>;
3090
+ type FetchFunction = (url: string, init?: FetchRequestInit) => Promise<FetchResponse>;
3076
3091
 
3077
3092
  /** Options for {@link SVGMapRenderer}: what stays the same for every view of the map. */
3078
3093
  interface SVGMapRendererOptions {
@@ -3083,7 +3098,9 @@ interface SVGMapRendererOptions {
3083
3098
  * (`url: '.../tiles.json'`), which is fetched once, like the sprite, with
3084
3099
  * {@link SVGMapRendererOptions.fetch}. As in MapLibre GL JS, `tiles`, `minzoom`,
3085
3100
  * `maxzoom` and the like come from the document unless the style sets them, and
3086
- * relative tile URLs are resolved against the document's URL. A GeoJSON source's `data`
3101
+ * relative tile URLs are resolved against the document's URL. A PMTiles archive
3102
+ * (`url: 'pmtiles://https://.../tiles.pmtiles'`) is read as with the `pmtiles` protocol in
3103
+ * MapLibre GL JS, which needs no setup here. A GeoJSON source's `data`
3087
3104
  * may be a URL too. A source whose TileJSON or GeoJSON cannot be loaded is left out, and
3088
3105
  * the next render tries again.
3089
3106
  */
@@ -3130,6 +3147,9 @@ interface SVGMapRendererOptions {
3130
3147
  * Loads tiles, sprites, TileJSON documents and GeoJSON data, like `fetch`, which is the default. Pass your own to send
3131
3148
  * headers, go through a proxy, or keep tiles in a cache on disk.
3132
3149
  *
3150
+ * It is called with the URL only, except to read part of a file, a PMTiles archive: then
3151
+ * also with `{ headers: { Range: 'bytes=…' } }`, which it should pass on.
3152
+ *
3133
3153
  * It must return a real `Response`, and its status matters: a 404 or 204 means the
3134
3154
  * server has no such tile, which is remembered (see {@link SVGMapRendererOptions.tileCacheSize}); any other
3135
3155
  * error status, or a rejected promise, counts as failed, and the next render tries
@@ -3239,7 +3259,7 @@ declare class SVGMapRenderer {
3239
3259
  */
3240
3260
  renderSVG(view?: ViewOptions): Promise<string>;
3241
3261
  /**
3242
- * Forgets the fetched tiles, sprite, TileJSON documents and GeoJSON data, so the next render fetches them again, e.g.
3262
+ * Forgets the fetched tiles, sprite, TileJSON documents, PMTiles directories and GeoJSON data, so the next render fetches them again, e.g.
3243
3263
  * after they were updated on the server, or to free their memory.
3244
3264
  */
3245
3265
  clearCache(): void;
@@ -3330,4 +3350,4 @@ interface RenderToSVGOptions extends Omit<SVGMapRendererOptions, 'tileCacheSize'
3330
3350
  declare function renderToSVG(options: RenderToSVGOptions): Promise<string>;
3331
3351
 
3332
3352
  export { SVGMapRenderer, renderToSVG };
3333
- export type { FetchFunction, FetchResponse, GlobalState, RenderToSVGOptions, SVGMapRendererOptions, ViewOptions };
3353
+ export type { FetchFunction, FetchRequestInit, FetchResponse, GlobalState, RenderToSVGOptions, SVGMapRendererOptions, ViewOptions };