@versatiles/svg-renderer 2.3.0 → 2.4.0
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/dist/index.d.ts +18 -5
- package/dist/index.js +5710 -131
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3068,11 +3068,19 @@ interface FetchResponse {
|
|
|
3068
3068
|
arrayBuffer(): Promise<ArrayBuffer>;
|
|
3069
3069
|
json(): Promise<unknown>;
|
|
3070
3070
|
}
|
|
3071
|
+
/**
|
|
3072
|
+
* The part of `fetch`'s `RequestInit` the renderer passes. It sends request headers only
|
|
3073
|
+
* to read part of a file: a `Range` header for a PMTiles archive.
|
|
3074
|
+
*/
|
|
3075
|
+
interface FetchRequestInit {
|
|
3076
|
+
headers?: Record<string, string>;
|
|
3077
|
+
}
|
|
3071
3078
|
/**
|
|
3072
3079
|
* Loads a URL, like `fetch`: the renderer loads tiles, sprites, TileJSON documents and GeoJSON data through it. It is called
|
|
3073
|
-
* with the URL
|
|
3080
|
+
* with the URL, and for part of a file with request headers as well, and should resolve to
|
|
3081
|
+
* a `Response`.
|
|
3074
3082
|
*/
|
|
3075
|
-
type FetchFunction = (url: string) => Promise<FetchResponse>;
|
|
3083
|
+
type FetchFunction = (url: string, init?: FetchRequestInit) => Promise<FetchResponse>;
|
|
3076
3084
|
|
|
3077
3085
|
/** Options for {@link SVGMapRenderer}: what stays the same for every view of the map. */
|
|
3078
3086
|
interface SVGMapRendererOptions {
|
|
@@ -3083,7 +3091,9 @@ interface SVGMapRendererOptions {
|
|
|
3083
3091
|
* (`url: '.../tiles.json'`), which is fetched once, like the sprite, with
|
|
3084
3092
|
* {@link SVGMapRendererOptions.fetch}. As in MapLibre GL JS, `tiles`, `minzoom`,
|
|
3085
3093
|
* `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
|
|
3094
|
+
* relative tile URLs are resolved against the document's URL. A PMTiles archive
|
|
3095
|
+
* (`url: 'pmtiles://https://.../tiles.pmtiles'`) is read as with the `pmtiles` protocol in
|
|
3096
|
+
* MapLibre GL JS, which needs no setup here. A GeoJSON source's `data`
|
|
3087
3097
|
* may be a URL too. A source whose TileJSON or GeoJSON cannot be loaded is left out, and
|
|
3088
3098
|
* the next render tries again.
|
|
3089
3099
|
*/
|
|
@@ -3130,6 +3140,9 @@ interface SVGMapRendererOptions {
|
|
|
3130
3140
|
* Loads tiles, sprites, TileJSON documents and GeoJSON data, like `fetch`, which is the default. Pass your own to send
|
|
3131
3141
|
* headers, go through a proxy, or keep tiles in a cache on disk.
|
|
3132
3142
|
*
|
|
3143
|
+
* It is called with the URL only, except to read part of a file, a PMTiles archive: then
|
|
3144
|
+
* also with `{ headers: { Range: 'bytes=…' } }`, which it should pass on.
|
|
3145
|
+
*
|
|
3133
3146
|
* It must return a real `Response`, and its status matters: a 404 or 204 means the
|
|
3134
3147
|
* server has no such tile, which is remembered (see {@link SVGMapRendererOptions.tileCacheSize}); any other
|
|
3135
3148
|
* error status, or a rejected promise, counts as failed, and the next render tries
|
|
@@ -3239,7 +3252,7 @@ declare class SVGMapRenderer {
|
|
|
3239
3252
|
*/
|
|
3240
3253
|
renderSVG(view?: ViewOptions): Promise<string>;
|
|
3241
3254
|
/**
|
|
3242
|
-
* Forgets the fetched tiles, sprite, TileJSON documents and GeoJSON data, so the next render fetches them again, e.g.
|
|
3255
|
+
* Forgets the fetched tiles, sprite, TileJSON documents, PMTiles directories and GeoJSON data, so the next render fetches them again, e.g.
|
|
3243
3256
|
* after they were updated on the server, or to free their memory.
|
|
3244
3257
|
*/
|
|
3245
3258
|
clearCache(): void;
|
|
@@ -3330,4 +3343,4 @@ interface RenderToSVGOptions extends Omit<SVGMapRendererOptions, 'tileCacheSize'
|
|
|
3330
3343
|
declare function renderToSVG(options: RenderToSVGOptions): Promise<string>;
|
|
3331
3344
|
|
|
3332
3345
|
export { SVGMapRenderer, renderToSVG };
|
|
3333
|
-
export type { FetchFunction, FetchResponse, GlobalState, RenderToSVGOptions, SVGMapRendererOptions, ViewOptions };
|
|
3346
|
+
export type { FetchFunction, FetchRequestInit, FetchResponse, GlobalState, RenderToSVGOptions, SVGMapRendererOptions, ViewOptions };
|