import * as ky from 'ky'; import { BBox } from './utils/geo.js'; import * as stream from 'stream'; import { b as StyleInlinedSources, G as GlyphInfo, T as TileInfo } from './types-yLQy3AKR.js'; import { TileDownloadStats } from './tile-downloader.js'; import { StyleSpecification } from '@maplibre/maplibre-gl-style-spec'; import 'geojson'; import 'type-fest'; import 'readable-stream'; import 'events'; import './utils/fetch.js'; import './utils/streams.js'; /** @import { SourceSpecification, StyleSpecification } from '@maplibre/maplibre-gl-style-spec' */ /** @import { TileInfo, GlyphInfo, GlyphRange } from './writer.js' */ /** @import { TileDownloadStats } from './tile-downloader.js' */ /** @import { StyleInlinedSources, InlinedSource } from './types.js'*/ /** @typedef { import('ky').ResponsePromise & { body: ReadableStream } } ResponsePromise */ /** @import { DownloadResponse } from './utils/fetch.js' */ /** * @typedef {object} GlyphDownloadStats * @property {number} total * @property {number} downloaded * @property {number} totalBytes */ /** * Download a style and its resources for offline use. Please check the terms of * service of the map provider you are using before downloading any resources. */ declare class StyleDownloader { /** * @param {string | StyleSpecification} style A url to a style JSON file or a style object * @param {object} [opts] * @param {number} [opts.concurrency=8] * @param {string} [opts.mapboxAccessToken] Downloading a style from Mapbox requires an access token */ constructor(style: string | StyleSpecification, { concurrency, mapboxAccessToken }?: { concurrency?: number | undefined; mapboxAccessToken?: string | undefined; }); /** * Number of active downloads. */ get active(): number; /** * Download the style JSON for this style and inline the sources * * @returns {Promise} */ getStyle(): Promise; /** * Download the sprite PNGs and JSON files for this style. Returns an async * generator of json and png readable streams, and the sprite id and pixel * ratio. Downloads pixel ratios `1` and `2`. * * @returns {AsyncGenerator<{ json: import('stream').Readable, png: import('stream').Readable, id: string, pixelRatio: number }>} */ getSprites(): AsyncGenerator<{ json: stream.Readable; png: stream.Readable; id: string; pixelRatio: number; }>; /** * Download all the glyphs for the fonts used in this style. When font stacks * are used in the style.json (e.g. lists of prefered fonts like with CSS), * then the first font in the stack is downloaded. Defaults to downloading all * UTF character ranges, which may be overkill for some styles. TODO: add more * options here. * * Returns an async generator of readable streams of glyph data and glyph info * objects. * * @param {object} opts * @param {(progress: GlyphDownloadStats) => void} [opts.onprogress] * @returns {AsyncGenerator<[import('stream').Readable, GlyphInfo]>} */ getGlyphs({ onprogress }?: { onprogress?: ((progress: GlyphDownloadStats) => void) | undefined; }): AsyncGenerator<[stream.Readable, GlyphInfo]>; /** * Get all the tiles for this style within the given bounds and zoom range. * Returns an async generator of readable streams of tile data and tile info * objects. * * The returned iterator also has a `skipped` property which is an * array of tiles which could not be downloaded, and a `stats` property which * is an object with the total number of tiles, downloaded tiles, and total * bytes downloaded. * * @param {object} opts * @param {import('./utils/geo.js').BBox} opts.bounds * @param {number} opts.maxzoom * @param {(progress: TileDownloadStats) => void} [opts.onprogress] * @param {boolean} [opts.trackErrors=false] Include errors in the returned array of skipped tiles - this has memory overhead so should only be used for debugging. * @returns {AsyncGenerator<[import('stream').Readable, TileInfo]> & { readonly skipped: Array, readonly stats: TileDownloadStats }} */ getTiles({ bounds, maxzoom, onprogress, trackErrors }: { bounds: BBox; maxzoom: number; onprogress?: ((progress: TileDownloadStats) => void) | undefined; trackErrors?: boolean | undefined; }): AsyncGenerator<[stream.Readable, TileInfo]> & { readonly skipped: Array; readonly stats: TileDownloadStats; }; #private; } type ResponsePromise = ky.ResponsePromise & { body: ReadableStream; }; type GlyphDownloadStats = { total: number; downloaded: number; totalBytes: number; }; export { type GlyphDownloadStats, type ResponsePromise, StyleDownloader };