styled-map-package 4.1.0 → 5.0.0-pre.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 (238) hide show
  1. package/README.md +47 -7
  2. package/bin/smp-download.js +27 -151
  3. package/bin/smp-mbtiles.js +12 -7
  4. package/bin/smp-view.js +32 -54
  5. package/lib/commands/download.js +188 -0
  6. package/lib/commands/mbtiles.js +21 -0
  7. package/lib/commands/view.js +57 -0
  8. package/lib/reporters.js +92 -0
  9. package/package.json +9 -181
  10. package/LICENSE.md +0 -7
  11. package/dist/download.cjs +0 -101
  12. package/dist/download.d.cts +0 -65
  13. package/dist/download.d.ts +0 -65
  14. package/dist/download.js +0 -77
  15. package/dist/from-mbtiles.cjs +0 -91
  16. package/dist/from-mbtiles.d.cts +0 -17
  17. package/dist/from-mbtiles.d.ts +0 -17
  18. package/dist/from-mbtiles.js +0 -57
  19. package/dist/index.cjs +0 -49
  20. package/dist/index.d.cts +0 -27
  21. package/dist/index.d.ts +0 -27
  22. package/dist/index.js +0 -18
  23. package/dist/reader-watch.cjs +0 -135
  24. package/dist/reader-watch.d.cts +0 -24
  25. package/dist/reader-watch.d.ts +0 -24
  26. package/dist/reader-watch.js +0 -101
  27. package/dist/reader.cjs +0 -168
  28. package/dist/reader.d.cts +0 -62
  29. package/dist/reader.d.ts +0 -62
  30. package/dist/reader.js +0 -139
  31. package/dist/reporters.cjs +0 -122
  32. package/dist/reporters.d.cts +0 -10
  33. package/dist/reporters.d.ts +0 -10
  34. package/dist/reporters.js +0 -88
  35. package/dist/server.cjs +0 -78
  36. package/dist/server.d.cts +0 -48
  37. package/dist/server.d.ts +0 -48
  38. package/dist/server.js +0 -54
  39. package/dist/style-downloader.cjs +0 -312
  40. package/dist/style-downloader.d.cts +0 -120
  41. package/dist/style-downloader.d.ts +0 -120
  42. package/dist/style-downloader.js +0 -288
  43. package/dist/tile-downloader.cjs +0 -158
  44. package/dist/tile-downloader.d.cts +0 -84
  45. package/dist/tile-downloader.d.ts +0 -84
  46. package/dist/tile-downloader.js +0 -126
  47. package/dist/types-yLQy3AKR.d.cts +0 -192
  48. package/dist/types-yLQy3AKR.d.ts +0 -192
  49. package/dist/utils/errors.cjs +0 -41
  50. package/dist/utils/errors.d.cts +0 -18
  51. package/dist/utils/errors.d.ts +0 -18
  52. package/dist/utils/errors.js +0 -16
  53. package/dist/utils/fetch.cjs +0 -96
  54. package/dist/utils/fetch.d.cts +0 -51
  55. package/dist/utils/fetch.d.ts +0 -51
  56. package/dist/utils/fetch.js +0 -62
  57. package/dist/utils/file-formats.cjs +0 -98
  58. package/dist/utils/file-formats.d.cts +0 -35
  59. package/dist/utils/file-formats.d.ts +0 -35
  60. package/dist/utils/file-formats.js +0 -62
  61. package/dist/utils/geo.cjs +0 -84
  62. package/dist/utils/geo.d.cts +0 -46
  63. package/dist/utils/geo.d.ts +0 -46
  64. package/dist/utils/geo.js +0 -56
  65. package/dist/utils/mapbox.cjs +0 -121
  66. package/dist/utils/mapbox.d.cts +0 -43
  67. package/dist/utils/mapbox.d.ts +0 -43
  68. package/dist/utils/mapbox.js +0 -91
  69. package/dist/utils/misc.cjs +0 -39
  70. package/dist/utils/misc.d.cts +0 -22
  71. package/dist/utils/misc.d.ts +0 -22
  72. package/dist/utils/misc.js +0 -13
  73. package/dist/utils/streams.cjs +0 -130
  74. package/dist/utils/streams.d.cts +0 -73
  75. package/dist/utils/streams.d.ts +0 -73
  76. package/dist/utils/streams.js +0 -103
  77. package/dist/utils/style.cjs +0 -126
  78. package/dist/utils/style.d.cts +0 -69
  79. package/dist/utils/style.d.ts +0 -69
  80. package/dist/utils/style.js +0 -98
  81. package/dist/utils/templates.cjs +0 -118
  82. package/dist/utils/templates.d.cts +0 -80
  83. package/dist/utils/templates.d.ts +0 -80
  84. package/dist/utils/templates.js +0 -81
  85. package/dist/writer.cjs +0 -449
  86. package/dist/writer.d.cts +0 -7
  87. package/dist/writer.d.ts +0 -7
  88. package/dist/writer.js +0 -424
  89. package/node_modules/@node-rs/crc32/LICENSE +0 -21
  90. package/node_modules/@node-rs/crc32/README.md +0 -61
  91. package/node_modules/@node-rs/crc32/browser.js +0 -1
  92. package/node_modules/@node-rs/crc32/index.d.ts +0 -5
  93. package/node_modules/@node-rs/crc32/index.js +0 -368
  94. package/node_modules/@node-rs/crc32/package.json +0 -97
  95. package/node_modules/@node-rs/crc32-linux-x64-gnu/README.md +0 -3
  96. package/node_modules/@node-rs/crc32-linux-x64-gnu/crc32.linux-x64-gnu.node +0 -0
  97. package/node_modules/@node-rs/crc32-linux-x64-gnu/package.json +0 -43
  98. package/node_modules/@node-rs/crc32-linux-x64-musl/README.md +0 -3
  99. package/node_modules/@node-rs/crc32-linux-x64-musl/crc32.linux-x64-musl.node +0 -0
  100. package/node_modules/@node-rs/crc32-linux-x64-musl/package.json +0 -43
  101. package/node_modules/define-data-property/.eslintrc +0 -24
  102. package/node_modules/define-data-property/.github/FUNDING.yml +0 -12
  103. package/node_modules/define-data-property/.nycrc +0 -13
  104. package/node_modules/define-data-property/CHANGELOG.md +0 -70
  105. package/node_modules/define-data-property/LICENSE +0 -21
  106. package/node_modules/define-data-property/README.md +0 -67
  107. package/node_modules/define-data-property/index.d.ts +0 -12
  108. package/node_modules/define-data-property/index.js +0 -56
  109. package/node_modules/define-data-property/package.json +0 -106
  110. package/node_modules/define-data-property/test/index.js +0 -392
  111. package/node_modules/define-data-property/tsconfig.json +0 -59
  112. package/node_modules/define-properties/.editorconfig +0 -13
  113. package/node_modules/define-properties/.eslintrc +0 -19
  114. package/node_modules/define-properties/.github/FUNDING.yml +0 -12
  115. package/node_modules/define-properties/.nycrc +0 -9
  116. package/node_modules/define-properties/CHANGELOG.md +0 -91
  117. package/node_modules/define-properties/LICENSE +0 -21
  118. package/node_modules/define-properties/README.md +0 -84
  119. package/node_modules/define-properties/index.js +0 -47
  120. package/node_modules/define-properties/package.json +0 -88
  121. package/node_modules/es-define-property/.eslintrc +0 -13
  122. package/node_modules/es-define-property/.github/FUNDING.yml +0 -12
  123. package/node_modules/es-define-property/.nycrc +0 -9
  124. package/node_modules/es-define-property/CHANGELOG.md +0 -29
  125. package/node_modules/es-define-property/LICENSE +0 -21
  126. package/node_modules/es-define-property/README.md +0 -49
  127. package/node_modules/es-define-property/index.d.ts +0 -3
  128. package/node_modules/es-define-property/index.js +0 -14
  129. package/node_modules/es-define-property/package.json +0 -81
  130. package/node_modules/es-define-property/test/index.js +0 -56
  131. package/node_modules/es-define-property/tsconfig.json +0 -10
  132. package/node_modules/es-errors/.eslintrc +0 -5
  133. package/node_modules/es-errors/.github/FUNDING.yml +0 -12
  134. package/node_modules/es-errors/CHANGELOG.md +0 -40
  135. package/node_modules/es-errors/LICENSE +0 -21
  136. package/node_modules/es-errors/README.md +0 -55
  137. package/node_modules/es-errors/eval.d.ts +0 -3
  138. package/node_modules/es-errors/eval.js +0 -4
  139. package/node_modules/es-errors/index.d.ts +0 -3
  140. package/node_modules/es-errors/index.js +0 -4
  141. package/node_modules/es-errors/package.json +0 -80
  142. package/node_modules/es-errors/range.d.ts +0 -3
  143. package/node_modules/es-errors/range.js +0 -4
  144. package/node_modules/es-errors/ref.d.ts +0 -3
  145. package/node_modules/es-errors/ref.js +0 -4
  146. package/node_modules/es-errors/syntax.d.ts +0 -3
  147. package/node_modules/es-errors/syntax.js +0 -4
  148. package/node_modules/es-errors/test/index.js +0 -19
  149. package/node_modules/es-errors/tsconfig.json +0 -49
  150. package/node_modules/es-errors/type.d.ts +0 -3
  151. package/node_modules/es-errors/type.js +0 -4
  152. package/node_modules/es-errors/uri.d.ts +0 -3
  153. package/node_modules/es-errors/uri.js +0 -4
  154. package/node_modules/globalthis/.eslintrc +0 -18
  155. package/node_modules/globalthis/.nycrc +0 -10
  156. package/node_modules/globalthis/CHANGELOG.md +0 -109
  157. package/node_modules/globalthis/LICENSE +0 -21
  158. package/node_modules/globalthis/README.md +0 -70
  159. package/node_modules/globalthis/auto.js +0 -3
  160. package/node_modules/globalthis/implementation.browser.js +0 -11
  161. package/node_modules/globalthis/implementation.js +0 -3
  162. package/node_modules/globalthis/index.js +0 -19
  163. package/node_modules/globalthis/package.json +0 -99
  164. package/node_modules/globalthis/polyfill.js +0 -10
  165. package/node_modules/globalthis/shim.js +0 -29
  166. package/node_modules/globalthis/test/implementation.js +0 -11
  167. package/node_modules/globalthis/test/index.js +0 -11
  168. package/node_modules/globalthis/test/native.js +0 -26
  169. package/node_modules/globalthis/test/shimmed.js +0 -29
  170. package/node_modules/globalthis/test/tests.js +0 -36
  171. package/node_modules/gopd/.eslintrc +0 -16
  172. package/node_modules/gopd/.github/FUNDING.yml +0 -12
  173. package/node_modules/gopd/CHANGELOG.md +0 -45
  174. package/node_modules/gopd/LICENSE +0 -21
  175. package/node_modules/gopd/README.md +0 -40
  176. package/node_modules/gopd/gOPD.d.ts +0 -1
  177. package/node_modules/gopd/gOPD.js +0 -4
  178. package/node_modules/gopd/index.d.ts +0 -5
  179. package/node_modules/gopd/index.js +0 -15
  180. package/node_modules/gopd/package.json +0 -77
  181. package/node_modules/gopd/test/index.js +0 -36
  182. package/node_modules/gopd/tsconfig.json +0 -9
  183. package/node_modules/has-property-descriptors/.eslintrc +0 -13
  184. package/node_modules/has-property-descriptors/.github/FUNDING.yml +0 -12
  185. package/node_modules/has-property-descriptors/.nycrc +0 -9
  186. package/node_modules/has-property-descriptors/CHANGELOG.md +0 -35
  187. package/node_modules/has-property-descriptors/LICENSE +0 -21
  188. package/node_modules/has-property-descriptors/README.md +0 -43
  189. package/node_modules/has-property-descriptors/index.js +0 -22
  190. package/node_modules/has-property-descriptors/package.json +0 -77
  191. package/node_modules/has-property-descriptors/test/index.js +0 -57
  192. package/node_modules/is-it-type/License +0 -19
  193. package/node_modules/is-it-type/README.md +0 -102
  194. package/node_modules/is-it-type/changelog.md +0 -239
  195. package/node_modules/is-it-type/dist/cjs/is-it-type.js +0 -173
  196. package/node_modules/is-it-type/dist/cjs/is-it-type.js.map +0 -1
  197. package/node_modules/is-it-type/dist/cjs/is-it-type.min.js +0 -2
  198. package/node_modules/is-it-type/dist/cjs/is-it-type.min.js.map +0 -1
  199. package/node_modules/is-it-type/dist/esm/is-it-type.js +0 -143
  200. package/node_modules/is-it-type/dist/esm/is-it-type.js.map +0 -1
  201. package/node_modules/is-it-type/dist/esm/is-it-type.min.js +0 -2
  202. package/node_modules/is-it-type/dist/esm/is-it-type.min.js.map +0 -1
  203. package/node_modules/is-it-type/dist/esm/package.json +0 -3
  204. package/node_modules/is-it-type/dist/umd/is-it-type.js +0 -450
  205. package/node_modules/is-it-type/dist/umd/is-it-type.js.map +0 -1
  206. package/node_modules/is-it-type/dist/umd/is-it-type.min.js +0 -2
  207. package/node_modules/is-it-type/dist/umd/is-it-type.min.js.map +0 -1
  208. package/node_modules/is-it-type/es/index.js +0 -8
  209. package/node_modules/is-it-type/es/package.json +0 -3
  210. package/node_modules/is-it-type/index.js +0 -10
  211. package/node_modules/is-it-type/package.json +0 -87
  212. package/node_modules/is-it-type/src/index.js +0 -169
  213. package/node_modules/object-keys/.editorconfig +0 -13
  214. package/node_modules/object-keys/.eslintrc +0 -17
  215. package/node_modules/object-keys/.travis.yml +0 -277
  216. package/node_modules/object-keys/CHANGELOG.md +0 -232
  217. package/node_modules/object-keys/LICENSE +0 -21
  218. package/node_modules/object-keys/README.md +0 -76
  219. package/node_modules/object-keys/implementation.js +0 -122
  220. package/node_modules/object-keys/index.js +0 -32
  221. package/node_modules/object-keys/isArguments.js +0 -17
  222. package/node_modules/object-keys/package.json +0 -88
  223. package/node_modules/object-keys/test/index.js +0 -5
  224. package/node_modules/simple-invariant/License +0 -19
  225. package/node_modules/simple-invariant/README.md +0 -64
  226. package/node_modules/simple-invariant/changelog.md +0 -31
  227. package/node_modules/simple-invariant/index.js +0 -19
  228. package/node_modules/simple-invariant/package.json +0 -50
  229. package/node_modules/yauzl-promise/License +0 -19
  230. package/node_modules/yauzl-promise/README.md +0 -440
  231. package/node_modules/yauzl-promise/index.js +0 -10
  232. package/node_modules/yauzl-promise/lib/entry.js +0 -312
  233. package/node_modules/yauzl-promise/lib/index.js +0 -160
  234. package/node_modules/yauzl-promise/lib/reader.js +0 -289
  235. package/node_modules/yauzl-promise/lib/shared.js +0 -20
  236. package/node_modules/yauzl-promise/lib/utils.js +0 -105
  237. package/node_modules/yauzl-promise/lib/zip.js +0 -1224
  238. package/node_modules/yauzl-promise/package.json +0 -56
@@ -1,84 +0,0 @@
1
- import { T as TileInfo$1 } from './types-yLQy3AKR.js';
2
- import * as stream from 'stream';
3
- import { BBox } from './utils/geo.js';
4
- import { FetchQueue } from './utils/fetch.js';
5
- import '@maplibre/maplibre-gl-style-spec';
6
- import 'geojson';
7
- import 'type-fest';
8
- import 'readable-stream';
9
- import 'events';
10
- import './utils/streams.js';
11
-
12
- /** @typedef {Omit<import('./writer.js').TileInfo, 'sourceId'>} TileInfo */
13
- /**
14
- * @typedef {object} TileDownloadStats
15
- * @property {number} total
16
- * @property {number} downloaded
17
- * @property {number} skipped
18
- * @property {number} totalBytes
19
- */
20
- /**
21
- * Download tiles from a list of tile URLs within a bounding box and zoom range.
22
- * Returns an async generator of tile data as readable streams and tile info objects.
23
- *
24
- * @param {object} opts
25
- * @param {string[]} opts.tileUrls Array of tile URL templates. Use `{x}`, `{y}`, `{z}` placeholders, and optional `{scheme}` placeholder which can be `xyz` or `tms`.
26
- * @param {import('./utils/geo.js').BBox} opts.bounds Bounding box of the area to download
27
- * @param {number} opts.maxzoom Maximum zoom level to download
28
- * @param {(progress: TileDownloadStats) => void} [opts.onprogress] Callback to report download progress
29
- * @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.
30
- * @param {import('./utils/geo.js').BBox} [opts.sourceBounds=MAX_BOUNDS] Bounding box of source data.
31
- * @param {boolean} [opts.boundsBuffer=false] Buffer the bounds by one tile at each zoom level to ensure no tiles are missed at the edges. With this set to false, in most instances the map will appear incomplete when viewed because the downloaded tiles at lower zoom levels will not cover the map view area.
32
- * @param {number} [opts.minzoom=0] Minimum zoom level to download (for most cases this should be left as `0` - the size overhead is minimal, because each zoom level has 4x as many tiles)
33
- * @param {number} [opts.concurrency=8] Number of concurrent downloads (ignored if `fetchQueue` is provided)
34
- * @param {FetchQueue} [opts.fetchQueue=new FetchQueue(concurrency)] Optional fetch queue to use for downloading tiles
35
- * @param {'xyz' | 'tms'} [opts.scheme='xyz'] Tile scheme to use for tile URLs
36
- * @returns {AsyncGenerator<[import('stream').Readable, TileInfo]> & { readonly skipped: Array<TileInfo & { error?: Error }>, readonly stats: TileDownloadStats }}
37
- */
38
- declare function downloadTiles({ tileUrls, bounds, maxzoom, onprogress, trackErrors, sourceBounds, boundsBuffer, minzoom, concurrency, fetchQueue, scheme, }: {
39
- tileUrls: string[];
40
- bounds: BBox;
41
- maxzoom: number;
42
- onprogress?: ((progress: TileDownloadStats) => void) | undefined;
43
- trackErrors?: boolean | undefined;
44
- sourceBounds?: BBox | undefined;
45
- boundsBuffer?: boolean | undefined;
46
- minzoom?: number | undefined;
47
- concurrency?: number | undefined;
48
- fetchQueue?: FetchQueue | undefined;
49
- scheme?: "xyz" | "tms" | undefined;
50
- }): AsyncGenerator<[stream.Readable, TileInfo]> & {
51
- readonly skipped: Array<TileInfo & {
52
- error?: Error;
53
- }>;
54
- readonly stats: TileDownloadStats;
55
- };
56
- /**
57
- *
58
- * @param {object} opts
59
- * @param {import('./utils/geo.js').BBox} [opts.bounds]
60
- * @param {import('./utils/geo.js').BBox} [opts.sourceBounds]
61
- * @param {boolean} [opts.boundsBuffer]
62
- * @param {number} [opts.minzoom]
63
- * @param {number} opts.maxzoom
64
- */
65
- declare function tileIterator({ bounds, minzoom, maxzoom, sourceBounds, boundsBuffer, }: {
66
- bounds?: BBox | undefined;
67
- sourceBounds?: BBox | undefined;
68
- boundsBuffer?: boolean | undefined;
69
- minzoom?: number | undefined;
70
- maxzoom: number;
71
- }): Generator<{
72
- x: number;
73
- y: number;
74
- z: number;
75
- }, void, unknown>;
76
- type TileInfo = Omit<TileInfo$1, "sourceId">;
77
- type TileDownloadStats = {
78
- total: number;
79
- downloaded: number;
80
- skipped: number;
81
- totalBytes: number;
82
- };
83
-
84
- export { type TileDownloadStats, type TileInfo, downloadTiles, tileIterator };
@@ -1,126 +0,0 @@
1
- import SphericalMercator from "@mapbox/sphericalmercator";
2
- import Queue from "yocto-queue";
3
- import zlib from "zlib";
4
- import { FetchQueue } from "./utils/fetch.js";
5
- import {
6
- getFormatFromMimeType,
7
- getTileFormatFromStream
8
- } from "./utils/file-formats.js";
9
- import { getTileUrl, MAX_BOUNDS } from "./utils/geo.js";
10
- import { noop } from "./utils/misc.js";
11
- function downloadTiles({
12
- tileUrls,
13
- bounds,
14
- maxzoom,
15
- onprogress = noop,
16
- trackErrors = false,
17
- sourceBounds = MAX_BOUNDS,
18
- boundsBuffer = false,
19
- minzoom = 0,
20
- concurrency = 8,
21
- fetchQueue = new FetchQueue(concurrency),
22
- scheme = "xyz"
23
- }) {
24
- const skipped = [];
25
- let completed = 0;
26
- let stats = {
27
- total: 0,
28
- downloaded: 0,
29
- skipped: 0,
30
- totalBytes: 0
31
- };
32
- function onDownloadProgress({ chunkBytes }) {
33
- stats.totalBytes += chunkBytes;
34
- onprogress(stats);
35
- }
36
- function onDownloadError(error, tileInfo) {
37
- if (trackErrors) {
38
- skipped.push({ ...tileInfo, error });
39
- } else {
40
- skipped.push(tileInfo);
41
- }
42
- onprogress(stats);
43
- }
44
- function onDownloadComplete() {
45
- stats.downloaded = ++completed - skipped.length;
46
- stats.skipped = skipped.length;
47
- onprogress(stats);
48
- }
49
- const tiles = (async function* () {
50
- const queue = new Queue();
51
- const tiles2 = tileIterator({
52
- bounds,
53
- minzoom,
54
- maxzoom,
55
- sourceBounds,
56
- boundsBuffer
57
- });
58
- for (const { x, y, z } of tiles2) {
59
- const tileURL = getTileUrl(tileUrls, { x, y, z, scheme });
60
- const tileInfo = { z, x, y };
61
- const result = fetchQueue.fetch(tileURL, { onprogress: onDownloadProgress }).catch((err) => onDownloadError(err, tileInfo));
62
- queue.enqueue([result, tileInfo]);
63
- }
64
- stats.total = queue.size;
65
- if (onprogress) onprogress(stats);
66
- for (const [result, tileInfo] of queue) {
67
- const downloadResponse = await result.catch(noop);
68
- if (!downloadResponse) continue;
69
- let { body, mimeType } = downloadResponse;
70
- body.on("end", onDownloadComplete);
71
- body.on("error", (err) => onDownloadError(err, tileInfo));
72
- let format;
73
- if (mimeType) {
74
- format = getFormatFromMimeType(mimeType);
75
- } else {
76
- ;
77
- [format, body] = await getTileFormatFromStream(body);
78
- }
79
- let stream = body;
80
- if (format === "mvt") {
81
- const gzipStream = zlib.createGzip();
82
- stream = body.pipe(gzipStream);
83
- stream.on("error", (err) => gzipStream.destroy(err));
84
- }
85
- yield [stream, { ...tileInfo, format }];
86
- }
87
- })();
88
- Object.defineProperty(tiles, "skipped", {
89
- get() {
90
- return skipped;
91
- }
92
- });
93
- Object.defineProperty(tiles, "stats", {
94
- get() {
95
- return stats;
96
- }
97
- });
98
- return tiles;
99
- }
100
- function* tileIterator({
101
- bounds = [...MAX_BOUNDS],
102
- minzoom = 0,
103
- maxzoom,
104
- sourceBounds,
105
- boundsBuffer = false
106
- }) {
107
- const sm = new SphericalMercator({ size: 256 });
108
- for (let z = minzoom; z <= maxzoom; z++) {
109
- let { minX, minY, maxX, maxY } = sm.xyz([...bounds], z);
110
- let sourceXYBounds = sourceBounds ? sm.xyz([...sourceBounds], z) : { minX, minY, maxX, maxY };
111
- const buffer = boundsBuffer ? 1 : 0;
112
- minX = Math.max(0, minX - buffer, sourceXYBounds.minX);
113
- minY = Math.max(0, minY - buffer, sourceXYBounds.minY);
114
- maxX = Math.min(Math.pow(2, z) - 1, maxX + buffer, sourceXYBounds.maxX);
115
- maxY = Math.min(Math.pow(2, z) - 1, maxY + buffer, sourceXYBounds.maxY);
116
- for (let x = minX; x <= maxX; x++) {
117
- for (let y = minY; y <= maxY; y++) {
118
- yield { x, y, z };
119
- }
120
- }
121
- }
122
- }
123
- export {
124
- downloadTiles,
125
- tileIterator
126
- };
@@ -1,192 +0,0 @@
1
- import { StyleSpecification, SourceSpecification, GeoJSONSourceSpecification, VectorSourceSpecification, RasterSourceSpecification, RasterDEMSourceSpecification } from '@maplibre/maplibre-gl-style-spec';
2
- import { GeoJSON, BBox } from 'geojson';
3
- import * as stream from 'stream';
4
- import { Readable } from 'stream';
5
- import { SetRequired } from 'type-fest';
6
- import * as readable_stream from 'readable-stream';
7
- import { EventEmitter } from 'events';
8
-
9
- /** @typedef {string | Buffer | Uint8Array | import('stream').Readable } Source */
10
- /** @typedef {string | Buffer | import('stream').Readable} SourceInternal */
11
- /** @typedef {`${number}-${number}`} GlyphRange */
12
- /** @typedef {'png' | 'mvt' | 'jpg' | 'webp'} TileFormat */
13
- /**
14
- * @typedef {object} SourceInfo
15
- * @property {import('./types.js').SMPSource} source
16
- * @property {string} encodedSourceId
17
- * @property {TileFormat} [format]
18
- */
19
- /**
20
- * @typedef {object} TileInfo
21
- * @property {number} z
22
- * @property {number} x
23
- * @property {number} y
24
- * @property {string} sourceId
25
- * @property {TileFormat} [format]
26
- */
27
- /**
28
- * @typedef {object} GlyphInfo
29
- * @property {string} font
30
- * @property {GlyphRange} range
31
- */
32
- /** @import { StyleSpecification } from '@maplibre/maplibre-gl-style-spec' */
33
- /** @import { InputSource, SMPSource } from './types.js' */
34
- declare const SUPPORTED_SOURCE_TYPES: readonly ["raster", "vector", "geojson"];
35
- /**
36
- * Write a styled map package to a stream. Stream `writer.outputStream` to a
37
- * destination, e.g. `fs.createWriteStream('my-map.styledmap')`. You must call
38
- * `witer.finish()` and then wait for your writable stream to `finish` before
39
- * using the output.
40
- */
41
- declare class Writer extends EventEmitter<[never]> {
42
- static SUPPORTED_SOURCE_TYPES: readonly ["raster", "vector", "geojson"];
43
- /**
44
- * @param {any} style A v7 or v8 MapLibre style. v7 styles will be migrated to
45
- * v8. (There are currently no typescript declarations for v7 styles, hence
46
- * this is typed as `any` and validated internally)
47
- * @param {object} opts
48
- * @param {number} [opts.highWaterMark=1048576] The maximum number of bytes to buffer during write
49
- */
50
- constructor(style: any, { highWaterMark }?: {
51
- highWaterMark?: number | undefined;
52
- });
53
- /**
54
- * @returns {import('stream').Readable} Readable stream of the styled map package
55
- */
56
- get outputStream(): stream.Readable;
57
- /**
58
- * Add a tile to the styled map package
59
- *
60
- * @param {Source} tileData
61
- * @param {TileInfo} opts
62
- */
63
- addTile(tileData: Source, { z, x, y, sourceId, format }: TileInfo): Promise<void>;
64
- /**
65
- * Create a write stream for adding tiles to the styled map package
66
- *
67
- * @param {object} opts
68
- * @param {number} [opts.concurrency=16] The number of concurrent writes
69
- *
70
- * @returns
71
- */
72
- createTileWriteStream({ concurrency }?: {
73
- concurrency?: number | undefined;
74
- }): readable_stream.Writable;
75
- /**
76
- * Add a sprite to the styled map package
77
- *
78
- * @param {object} options
79
- * @param {Source} options.json
80
- * @param {Source} options.png
81
- * @param {number} [options.pixelRatio]
82
- * @param {string} [options.id='default']
83
- * @returns {Promise<void>}
84
- */
85
- addSprite({ json, png, pixelRatio, id }: {
86
- json: Source;
87
- png: Source;
88
- pixelRatio?: number | undefined;
89
- id?: string | undefined;
90
- }): Promise<void>;
91
- /**
92
- * Add glyphs to the styled map package
93
- *
94
- * @param {Source} glyphData
95
- * @param {GlyphInfo} glyphInfo
96
- * @returns {Promise<void>}
97
- */
98
- addGlyphs(glyphData: Source, { font: fontName, range }: GlyphInfo): Promise<void>;
99
- /**
100
- * Create a write stream for adding glyphs to the styled map package
101
- *
102
- * @param {object} opts
103
- * @param {number} [opts.concurrency=16] The number of concurrent writes
104
- * @returns
105
- */
106
- createGlyphWriteStream({ concurrency }?: {
107
- concurrency?: number | undefined;
108
- }): readable_stream.Writable;
109
- /**
110
- * Finalize the styled map package and write the style to the archive.
111
- * This method must be called to complete the archive.
112
- * You must wait for your destination write stream to 'finish' before using the output.
113
- */
114
- finish(): Promise<void>;
115
- #private;
116
- }
117
- type ZipEntry = {
118
- name: string;
119
- };
120
- type Source = string | Buffer | Uint8Array | stream.Readable;
121
- type SourceInternal = string | Buffer | stream.Readable;
122
- type GlyphRange = `${number}-${number}`;
123
- type TileFormat = "png" | "mvt" | "jpg" | "webp";
124
- type SourceInfo = {
125
- source: SMPSource;
126
- encodedSourceId: string;
127
- format?: TileFormat | undefined;
128
- };
129
- type TileInfo = {
130
- z: number;
131
- x: number;
132
- y: number;
133
- sourceId: string;
134
- format?: TileFormat | undefined;
135
- };
136
- type GlyphInfo = {
137
- font: string;
138
- range: GlyphRange;
139
- };
140
-
141
- type TransformInlinedSource<T extends SourceSpecification> = T extends GeoJSONSourceSpecification ? OmitUnion<T, 'data'> & {
142
- data: GeoJSON;
143
- } : T extends VectorSourceSpecification | RasterSourceSpecification | RasterDEMSourceSpecification ? SetRequired<OmitUnion<T, 'url'>, 'tiles'> : T;
144
- /**
145
- * This is a slightly stricter version of SourceSpecification that requires
146
- * sources to be inlined (e.g. no urls to TileJSON or GeoJSON files).
147
- */
148
- type InlinedSource = TransformInlinedSource<SourceSpecification>;
149
- type SupportedInlinedSource = Extract<InlinedSource, {
150
- type: (typeof SUPPORTED_SOURCE_TYPES)[number];
151
- }>;
152
- /**
153
- * This is a slightly stricter version of StyleSpecification that requires
154
- * sources to be inlined (e.g. no urls to TileJSON or GeoJSON files).
155
- */
156
- type StyleInlinedSources = Omit<StyleSpecification, 'sources'> & {
157
- sources: {
158
- [_: string]: InlinedSource;
159
- };
160
- };
161
- type SMPSource = TransformSMPInputSource<SupportedInlinedSource>;
162
- /**
163
- * This is a slightly stricter version of StyleSpecification that is provided in
164
- * a Styled Map Package. Tile sources must have tile URLs inlined (they cannot
165
- * refer to a TileJSON url), and they must have bounds, minzoom, and maxzoom.
166
- * GeoJSON sources must have inlined GeoJSON (not a URL to a GeoJSON file).
167
- */
168
- type SMPStyle = TransformSMPStyle<StyleSpecification>;
169
- type TransformSMPInputSource<T extends SupportedInlinedSource> = T extends GeoJSONSourceSpecification ? T & {
170
- data: {
171
- bbox: BBox;
172
- };
173
- } : T extends RasterSourceSpecification | VectorSourceSpecification ? SetRequired<T, 'bounds' | 'minzoom' | 'maxzoom'> : T;
174
- type TransformSMPStyle<T extends StyleSpecification> = Omit<T, 'sources'> & {
175
- metadata: {
176
- 'smp:bounds': [number, number, number, number];
177
- 'smp:maxzoom': 0;
178
- 'smp:sourceFolders': {
179
- [_: string]: string;
180
- };
181
- };
182
- sources: {
183
- [_: string]: SMPSource;
184
- };
185
- };
186
- interface DownloadStream extends Readable {
187
- iterator(...args: Parameters<Readable['iterator']>): AsyncIterableIterator<Buffer>;
188
- [Symbol.asyncIterator](): AsyncIterableIterator<Buffer>;
189
- }
190
- type OmitUnion<T, K extends keyof any> = T extends unknown ? Omit<T, K> : never;
191
-
192
- export { type DownloadStream as D, type GlyphInfo as G, type InlinedSource as I, type SMPSource as S, type TileInfo as T, Writer as W, type ZipEntry as Z, type SMPStyle as a, type StyleInlinedSources as b, type TileFormat as c, type GlyphRange as d, SUPPORTED_SOURCE_TYPES as e, type Source as f, type SourceInfo as g, type SourceInternal as h };
@@ -1,192 +0,0 @@
1
- import { StyleSpecification, SourceSpecification, GeoJSONSourceSpecification, VectorSourceSpecification, RasterSourceSpecification, RasterDEMSourceSpecification } from '@maplibre/maplibre-gl-style-spec';
2
- import { GeoJSON, BBox } from 'geojson';
3
- import * as stream from 'stream';
4
- import { Readable } from 'stream';
5
- import { SetRequired } from 'type-fest';
6
- import * as readable_stream from 'readable-stream';
7
- import { EventEmitter } from 'events';
8
-
9
- /** @typedef {string | Buffer | Uint8Array | import('stream').Readable } Source */
10
- /** @typedef {string | Buffer | import('stream').Readable} SourceInternal */
11
- /** @typedef {`${number}-${number}`} GlyphRange */
12
- /** @typedef {'png' | 'mvt' | 'jpg' | 'webp'} TileFormat */
13
- /**
14
- * @typedef {object} SourceInfo
15
- * @property {import('./types.js').SMPSource} source
16
- * @property {string} encodedSourceId
17
- * @property {TileFormat} [format]
18
- */
19
- /**
20
- * @typedef {object} TileInfo
21
- * @property {number} z
22
- * @property {number} x
23
- * @property {number} y
24
- * @property {string} sourceId
25
- * @property {TileFormat} [format]
26
- */
27
- /**
28
- * @typedef {object} GlyphInfo
29
- * @property {string} font
30
- * @property {GlyphRange} range
31
- */
32
- /** @import { StyleSpecification } from '@maplibre/maplibre-gl-style-spec' */
33
- /** @import { InputSource, SMPSource } from './types.js' */
34
- declare const SUPPORTED_SOURCE_TYPES: readonly ["raster", "vector", "geojson"];
35
- /**
36
- * Write a styled map package to a stream. Stream `writer.outputStream` to a
37
- * destination, e.g. `fs.createWriteStream('my-map.styledmap')`. You must call
38
- * `witer.finish()` and then wait for your writable stream to `finish` before
39
- * using the output.
40
- */
41
- declare class Writer extends EventEmitter<[never]> {
42
- static SUPPORTED_SOURCE_TYPES: readonly ["raster", "vector", "geojson"];
43
- /**
44
- * @param {any} style A v7 or v8 MapLibre style. v7 styles will be migrated to
45
- * v8. (There are currently no typescript declarations for v7 styles, hence
46
- * this is typed as `any` and validated internally)
47
- * @param {object} opts
48
- * @param {number} [opts.highWaterMark=1048576] The maximum number of bytes to buffer during write
49
- */
50
- constructor(style: any, { highWaterMark }?: {
51
- highWaterMark?: number | undefined;
52
- });
53
- /**
54
- * @returns {import('stream').Readable} Readable stream of the styled map package
55
- */
56
- get outputStream(): stream.Readable;
57
- /**
58
- * Add a tile to the styled map package
59
- *
60
- * @param {Source} tileData
61
- * @param {TileInfo} opts
62
- */
63
- addTile(tileData: Source, { z, x, y, sourceId, format }: TileInfo): Promise<void>;
64
- /**
65
- * Create a write stream for adding tiles to the styled map package
66
- *
67
- * @param {object} opts
68
- * @param {number} [opts.concurrency=16] The number of concurrent writes
69
- *
70
- * @returns
71
- */
72
- createTileWriteStream({ concurrency }?: {
73
- concurrency?: number | undefined;
74
- }): readable_stream.Writable;
75
- /**
76
- * Add a sprite to the styled map package
77
- *
78
- * @param {object} options
79
- * @param {Source} options.json
80
- * @param {Source} options.png
81
- * @param {number} [options.pixelRatio]
82
- * @param {string} [options.id='default']
83
- * @returns {Promise<void>}
84
- */
85
- addSprite({ json, png, pixelRatio, id }: {
86
- json: Source;
87
- png: Source;
88
- pixelRatio?: number | undefined;
89
- id?: string | undefined;
90
- }): Promise<void>;
91
- /**
92
- * Add glyphs to the styled map package
93
- *
94
- * @param {Source} glyphData
95
- * @param {GlyphInfo} glyphInfo
96
- * @returns {Promise<void>}
97
- */
98
- addGlyphs(glyphData: Source, { font: fontName, range }: GlyphInfo): Promise<void>;
99
- /**
100
- * Create a write stream for adding glyphs to the styled map package
101
- *
102
- * @param {object} opts
103
- * @param {number} [opts.concurrency=16] The number of concurrent writes
104
- * @returns
105
- */
106
- createGlyphWriteStream({ concurrency }?: {
107
- concurrency?: number | undefined;
108
- }): readable_stream.Writable;
109
- /**
110
- * Finalize the styled map package and write the style to the archive.
111
- * This method must be called to complete the archive.
112
- * You must wait for your destination write stream to 'finish' before using the output.
113
- */
114
- finish(): Promise<void>;
115
- #private;
116
- }
117
- type ZipEntry = {
118
- name: string;
119
- };
120
- type Source = string | Buffer | Uint8Array | stream.Readable;
121
- type SourceInternal = string | Buffer | stream.Readable;
122
- type GlyphRange = `${number}-${number}`;
123
- type TileFormat = "png" | "mvt" | "jpg" | "webp";
124
- type SourceInfo = {
125
- source: SMPSource;
126
- encodedSourceId: string;
127
- format?: TileFormat | undefined;
128
- };
129
- type TileInfo = {
130
- z: number;
131
- x: number;
132
- y: number;
133
- sourceId: string;
134
- format?: TileFormat | undefined;
135
- };
136
- type GlyphInfo = {
137
- font: string;
138
- range: GlyphRange;
139
- };
140
-
141
- type TransformInlinedSource<T extends SourceSpecification> = T extends GeoJSONSourceSpecification ? OmitUnion<T, 'data'> & {
142
- data: GeoJSON;
143
- } : T extends VectorSourceSpecification | RasterSourceSpecification | RasterDEMSourceSpecification ? SetRequired<OmitUnion<T, 'url'>, 'tiles'> : T;
144
- /**
145
- * This is a slightly stricter version of SourceSpecification that requires
146
- * sources to be inlined (e.g. no urls to TileJSON or GeoJSON files).
147
- */
148
- type InlinedSource = TransformInlinedSource<SourceSpecification>;
149
- type SupportedInlinedSource = Extract<InlinedSource, {
150
- type: (typeof SUPPORTED_SOURCE_TYPES)[number];
151
- }>;
152
- /**
153
- * This is a slightly stricter version of StyleSpecification that requires
154
- * sources to be inlined (e.g. no urls to TileJSON or GeoJSON files).
155
- */
156
- type StyleInlinedSources = Omit<StyleSpecification, 'sources'> & {
157
- sources: {
158
- [_: string]: InlinedSource;
159
- };
160
- };
161
- type SMPSource = TransformSMPInputSource<SupportedInlinedSource>;
162
- /**
163
- * This is a slightly stricter version of StyleSpecification that is provided in
164
- * a Styled Map Package. Tile sources must have tile URLs inlined (they cannot
165
- * refer to a TileJSON url), and they must have bounds, minzoom, and maxzoom.
166
- * GeoJSON sources must have inlined GeoJSON (not a URL to a GeoJSON file).
167
- */
168
- type SMPStyle = TransformSMPStyle<StyleSpecification>;
169
- type TransformSMPInputSource<T extends SupportedInlinedSource> = T extends GeoJSONSourceSpecification ? T & {
170
- data: {
171
- bbox: BBox;
172
- };
173
- } : T extends RasterSourceSpecification | VectorSourceSpecification ? SetRequired<T, 'bounds' | 'minzoom' | 'maxzoom'> : T;
174
- type TransformSMPStyle<T extends StyleSpecification> = Omit<T, 'sources'> & {
175
- metadata: {
176
- 'smp:bounds': [number, number, number, number];
177
- 'smp:maxzoom': 0;
178
- 'smp:sourceFolders': {
179
- [_: string]: string;
180
- };
181
- };
182
- sources: {
183
- [_: string]: SMPSource;
184
- };
185
- };
186
- interface DownloadStream extends Readable {
187
- iterator(...args: Parameters<Readable['iterator']>): AsyncIterableIterator<Buffer>;
188
- [Symbol.asyncIterator](): AsyncIterableIterator<Buffer>;
189
- }
190
- type OmitUnion<T, K extends keyof any> = T extends unknown ? Omit<T, K> : never;
191
-
192
- export { type DownloadStream as D, type GlyphInfo as G, type InlinedSource as I, type SMPSource as S, type TileInfo as T, Writer as W, type ZipEntry as Z, type SMPStyle as a, type StyleInlinedSources as b, type TileFormat as c, type GlyphRange as d, SUPPORTED_SOURCE_TYPES as e, type Source as f, type SourceInfo as g, type SourceInternal as h };
@@ -1,41 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var errors_exports = {};
20
- __export(errors_exports, {
21
- ENOENT: () => ENOENT,
22
- isFileNotThereError: () => isFileNotThereError
23
- });
24
- module.exports = __toCommonJS(errors_exports);
25
- class ENOENT extends Error {
26
- code = "ENOENT";
27
- /** @param {string} path */
28
- constructor(path) {
29
- const message = `ENOENT: no such file or directory, open '${path}'`;
30
- super(message);
31
- this.path = path;
32
- }
33
- }
34
- function isFileNotThereError(error) {
35
- return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "EPERM");
36
- }
37
- // Annotate the CommonJS export names for ESM import in node:
38
- 0 && (module.exports = {
39
- ENOENT,
40
- isFileNotThereError
41
- });
@@ -1,18 +0,0 @@
1
- /**
2
- * Returns true if the error if because a file is not found. On Windows, some
3
- * operations like fs.watch() throw an EPERM error rather than ENOENT.
4
- *
5
- * @param {unknown} error
6
- * @returns {error is Error & { code: 'ENOENT' | 'EPERM' }}
7
- */
8
- declare function isFileNotThereError(error: unknown): error is Error & {
9
- code: "ENOENT" | "EPERM";
10
- };
11
- declare class ENOENT extends Error {
12
- /** @param {string} path */
13
- constructor(path: string);
14
- code: string;
15
- path: string;
16
- }
17
-
18
- export { ENOENT, isFileNotThereError };
@@ -1,18 +0,0 @@
1
- /**
2
- * Returns true if the error if because a file is not found. On Windows, some
3
- * operations like fs.watch() throw an EPERM error rather than ENOENT.
4
- *
5
- * @param {unknown} error
6
- * @returns {error is Error & { code: 'ENOENT' | 'EPERM' }}
7
- */
8
- declare function isFileNotThereError(error: unknown): error is Error & {
9
- code: "ENOENT" | "EPERM";
10
- };
11
- declare class ENOENT extends Error {
12
- /** @param {string} path */
13
- constructor(path: string);
14
- code: string;
15
- path: string;
16
- }
17
-
18
- export { ENOENT, isFileNotThereError };
@@ -1,16 +0,0 @@
1
- class ENOENT extends Error {
2
- code = "ENOENT";
3
- /** @param {string} path */
4
- constructor(path) {
5
- const message = `ENOENT: no such file or directory, open '${path}'`;
6
- super(message);
7
- this.path = path;
8
- }
9
- }
10
- function isFileNotThereError(error) {
11
- return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "EPERM");
12
- }
13
- export {
14
- ENOENT,
15
- isFileNotThereError
16
- };