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,96 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var fetch_exports = {};
30
- __export(fetch_exports, {
31
- FetchQueue: () => FetchQueue
32
- });
33
- module.exports = __toCommonJS(fetch_exports);
34
- var import_ky = __toESM(require("ky"), 1);
35
- var import_p_event = require("p-event");
36
- var import_p_limit = __toESM(require("p-limit"), 1);
37
- var import_streams = require('./streams.cjs');
38
- class FetchQueue {
39
- /** @type {import('p-limit').LimitFunction} */
40
- #limit;
41
- /** @param {number} concurrency */
42
- constructor(concurrency) {
43
- this.#limit = (0, import_p_limit.default)(concurrency);
44
- }
45
- get activeCount() {
46
- return this.#limit.activeCount;
47
- }
48
- /**
49
- * Fetch a URL, limiting the number of concurrent downloads. Resolves with a
50
- * `DownloadResponse`, which is a parsed from the Fetch `Response` objects,
51
- * with `body` as a Node readable stream, and the MIME type and content length
52
- * of the response.
53
- *
54
- * NB: The response body stream must be consumed to the end, otherwise the
55
- * queue will never be emptied.
56
- *
57
- * @param {string} url
58
- * @param {{ onprogress?: import('./streams.js').ProgressCallback }} opts
59
- * @returns {Promise<DownloadResponse>}
60
- */
61
- fetch(url, { onprogress } = {}) {
62
- return new Promise((resolveResponse, rejectResponse) => {
63
- this.#limit(fetchStream, {
64
- url,
65
- onresponse: resolveResponse,
66
- onerror: rejectResponse,
67
- onprogress
68
- });
69
- });
70
- }
71
- }
72
- async function fetchStream({ url, onresponse, onerror, onprogress }) {
73
- try {
74
- const response = await (0, import_ky.default)(url, { retry: 3 });
75
- if (!response.body) {
76
- throw new Error("No body in response");
77
- }
78
- const body = (0, import_streams.fromWebReadableStream)(response.body);
79
- const contentType = response.headers.get("content-type");
80
- const mimeType = typeof contentType === "string" ? contentType.split(";")[0] : null;
81
- const contentLengthHeader = response.headers.get("content-length");
82
- const contentLength = contentLengthHeader === null ? null : parseInt(contentLengthHeader, 10);
83
- onresponse({
84
- body: onprogress ? body.pipe(new import_streams.ProgressStream({ onprogress })) : body,
85
- mimeType,
86
- contentLength
87
- });
88
- await (0, import_p_event.pEvent)(body, "end");
89
- } catch (err) {
90
- onerror(err instanceof Error ? err : new Error("Unknown error"));
91
- }
92
- }
93
- // Annotate the CommonJS export names for ESM import in node:
94
- 0 && (module.exports = {
95
- FetchQueue
96
- });
@@ -1,51 +0,0 @@
1
- import * as stream from 'stream';
2
- import { ProgressCallback } from './streams.cjs';
3
- import 'readable-stream';
4
-
5
- /**
6
- * @typedef {object} DownloadResponse
7
- * @property {import('stream').Readable} body Node ReadableStream of the response body
8
- * @property {string | null} mimeType Content mime-type (from http content-type header)
9
- * @property {number | null} contentLength Content length in bytes (from http content-length header)
10
- */
11
- /**
12
- * A wrapper for fetch that limits the number of concurrent downloads.
13
- */
14
- declare class FetchQueue {
15
- /** @param {number} concurrency */
16
- constructor(concurrency: number);
17
- get activeCount(): number;
18
- /**
19
- * Fetch a URL, limiting the number of concurrent downloads. Resolves with a
20
- * `DownloadResponse`, which is a parsed from the Fetch `Response` objects,
21
- * with `body` as a Node readable stream, and the MIME type and content length
22
- * of the response.
23
- *
24
- * NB: The response body stream must be consumed to the end, otherwise the
25
- * queue will never be emptied.
26
- *
27
- * @param {string} url
28
- * @param {{ onprogress?: import('./streams.js').ProgressCallback }} opts
29
- * @returns {Promise<DownloadResponse>}
30
- */
31
- fetch(url: string, { onprogress }?: {
32
- onprogress?: ProgressCallback;
33
- }): Promise<DownloadResponse>;
34
- #private;
35
- }
36
- type DownloadResponse = {
37
- /**
38
- * Node ReadableStream of the response body
39
- */
40
- body: stream.Readable;
41
- /**
42
- * Content mime-type (from http content-type header)
43
- */
44
- mimeType: string | null;
45
- /**
46
- * Content length in bytes (from http content-length header)
47
- */
48
- contentLength: number | null;
49
- };
50
-
51
- export { type DownloadResponse, FetchQueue };
@@ -1,51 +0,0 @@
1
- import * as stream from 'stream';
2
- import { ProgressCallback } from './streams.js';
3
- import 'readable-stream';
4
-
5
- /**
6
- * @typedef {object} DownloadResponse
7
- * @property {import('stream').Readable} body Node ReadableStream of the response body
8
- * @property {string | null} mimeType Content mime-type (from http content-type header)
9
- * @property {number | null} contentLength Content length in bytes (from http content-length header)
10
- */
11
- /**
12
- * A wrapper for fetch that limits the number of concurrent downloads.
13
- */
14
- declare class FetchQueue {
15
- /** @param {number} concurrency */
16
- constructor(concurrency: number);
17
- get activeCount(): number;
18
- /**
19
- * Fetch a URL, limiting the number of concurrent downloads. Resolves with a
20
- * `DownloadResponse`, which is a parsed from the Fetch `Response` objects,
21
- * with `body` as a Node readable stream, and the MIME type and content length
22
- * of the response.
23
- *
24
- * NB: The response body stream must be consumed to the end, otherwise the
25
- * queue will never be emptied.
26
- *
27
- * @param {string} url
28
- * @param {{ onprogress?: import('./streams.js').ProgressCallback }} opts
29
- * @returns {Promise<DownloadResponse>}
30
- */
31
- fetch(url: string, { onprogress }?: {
32
- onprogress?: ProgressCallback;
33
- }): Promise<DownloadResponse>;
34
- #private;
35
- }
36
- type DownloadResponse = {
37
- /**
38
- * Node ReadableStream of the response body
39
- */
40
- body: stream.Readable;
41
- /**
42
- * Content mime-type (from http content-type header)
43
- */
44
- mimeType: string | null;
45
- /**
46
- * Content length in bytes (from http content-length header)
47
- */
48
- contentLength: number | null;
49
- };
50
-
51
- export { type DownloadResponse, FetchQueue };
@@ -1,62 +0,0 @@
1
- import ky from "ky";
2
- import { pEvent } from "p-event";
3
- import pLimit from "p-limit";
4
- import { fromWebReadableStream, ProgressStream } from "./streams.js";
5
- class FetchQueue {
6
- /** @type {import('p-limit').LimitFunction} */
7
- #limit;
8
- /** @param {number} concurrency */
9
- constructor(concurrency) {
10
- this.#limit = pLimit(concurrency);
11
- }
12
- get activeCount() {
13
- return this.#limit.activeCount;
14
- }
15
- /**
16
- * Fetch a URL, limiting the number of concurrent downloads. Resolves with a
17
- * `DownloadResponse`, which is a parsed from the Fetch `Response` objects,
18
- * with `body` as a Node readable stream, and the MIME type and content length
19
- * of the response.
20
- *
21
- * NB: The response body stream must be consumed to the end, otherwise the
22
- * queue will never be emptied.
23
- *
24
- * @param {string} url
25
- * @param {{ onprogress?: import('./streams.js').ProgressCallback }} opts
26
- * @returns {Promise<DownloadResponse>}
27
- */
28
- fetch(url, { onprogress } = {}) {
29
- return new Promise((resolveResponse, rejectResponse) => {
30
- this.#limit(fetchStream, {
31
- url,
32
- onresponse: resolveResponse,
33
- onerror: rejectResponse,
34
- onprogress
35
- });
36
- });
37
- }
38
- }
39
- async function fetchStream({ url, onresponse, onerror, onprogress }) {
40
- try {
41
- const response = await ky(url, { retry: 3 });
42
- if (!response.body) {
43
- throw new Error("No body in response");
44
- }
45
- const body = fromWebReadableStream(response.body);
46
- const contentType = response.headers.get("content-type");
47
- const mimeType = typeof contentType === "string" ? contentType.split(";")[0] : null;
48
- const contentLengthHeader = response.headers.get("content-length");
49
- const contentLength = contentLengthHeader === null ? null : parseInt(contentLengthHeader, 10);
50
- onresponse({
51
- body: onprogress ? body.pipe(new ProgressStream({ onprogress })) : body,
52
- mimeType,
53
- contentLength
54
- });
55
- await pEvent(body, "end");
56
- } catch (err) {
57
- onerror(err instanceof Error ? err : new Error("Unknown error"));
58
- }
59
- }
60
- export {
61
- FetchQueue
62
- };
@@ -1,98 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var file_formats_exports = {};
30
- __export(file_formats_exports, {
31
- getFormatFromMimeType: () => getFormatFromMimeType,
32
- getTileFormatFromBuffer: () => getTileFormatFromBuffer,
33
- getTileFormatFromStream: () => getTileFormatFromStream
34
- });
35
- module.exports = __toCommonJS(file_formats_exports);
36
- var import_buffer_peek_stream = __toESM(require("buffer-peek-stream"), 1);
37
- var import_misc = require('./misc.cjs');
38
- const peek = import_buffer_peek_stream.default.promise;
39
- const MAGIC_BYTES = (
40
- /** @type {const} */
41
- {
42
- png: [137, 80, 78, 71, 13, 10, 26, 10],
43
- jpg: [255, 216, 255],
44
- // eslint-disable-next-line no-sparse-arrays
45
- webp: [82, 73, 70, 70, , , , , 87, 69, 66, 80],
46
- // Include the compression-type byte, which is always 0x08 (DEFLATE) for gzip
47
- gz: [31, 139, 8]
48
- }
49
- );
50
- const MIME_TYPES = (
51
- /** @type {const} */
52
- {
53
- "image/png": "png",
54
- "image/jpeg": "jpg",
55
- "image/webp": "webp"
56
- }
57
- );
58
- const magicByteMap = /* @__PURE__ */ new Map();
59
- for (const [ext, bytes] of Object.entries(MAGIC_BYTES)) {
60
- magicByteMap.set(
61
- bytes[0],
62
- // @ts-ignore
63
- ext
64
- );
65
- }
66
- function getTileFormatFromBuffer(buf) {
67
- const ext = magicByteMap.get(buf[0]);
68
- if (!ext) {
69
- throw new Error("Unknown file type");
70
- }
71
- const sig = MAGIC_BYTES[ext];
72
- for (let i = 1; i < sig.length; i++) {
73
- if (typeof sig[i] !== "undefined" && sig[i] !== buf[i]) {
74
- throw new Error("Unknown file type");
75
- }
76
- }
77
- if (ext === "gz") {
78
- return "mvt";
79
- }
80
- return ext;
81
- }
82
- async function getTileFormatFromStream(tileData) {
83
- const [peekedData, outputStream] = await peek(tileData, 16 * 1024);
84
- tileData = outputStream;
85
- const format = getTileFormatFromBuffer(peekedData);
86
- return [format, outputStream];
87
- }
88
- function getFormatFromMimeType(mimeType) {
89
- if (mimeType.startsWith("application/")) return "mvt";
90
- if ((0, import_misc.hasOwn)(MIME_TYPES, mimeType)) return MIME_TYPES[mimeType];
91
- throw new Error("Unsupported MIME type " + mimeType);
92
- }
93
- // Annotate the CommonJS export names for ESM import in node:
94
- 0 && (module.exports = {
95
- getFormatFromMimeType,
96
- getTileFormatFromBuffer,
97
- getTileFormatFromStream
98
- });
@@ -1,35 +0,0 @@
1
- import * as stream from 'stream';
2
- import { c as TileFormat } from '../types-yLQy3AKR.cjs';
3
- import '@maplibre/maplibre-gl-style-spec';
4
- import 'geojson';
5
- import 'type-fest';
6
- import 'readable-stream';
7
- import 'events';
8
-
9
- /**
10
- * For a given buffer, determine the tile format based on the magic bytes.
11
- * Will throw for unknown file types.
12
- * Smaller and faster version of magic-bytes.js due to the limited use case.
13
- *
14
- * @param {Buffer | Uint8Array} buf
15
- * @returns {import("../writer.js").TileFormat}
16
- */
17
- declare function getTileFormatFromBuffer(buf: Buffer | Uint8Array): TileFormat;
18
- /**
19
- * Determine the tile format from either a readable stream, buffer or Uint8Array
20
- * from the magic bytes at the start of the file. Used if data is served without
21
- * a content-type header.
22
- *
23
- * @param {import('stream').Readable} tileData
24
- * @returns {Promise<[import("../writer.js").TileFormat, import('stream').Readable]>}
25
- */
26
- declare function getTileFormatFromStream(tileData: stream.Readable): Promise<[TileFormat, stream.Readable]>;
27
- /**
28
- * Get the tile format from a MIME type. Throws for unsupported types.
29
- *
30
- * @param {string} mimeType
31
- * @returns {import("../writer.js").TileFormat}
32
- */
33
- declare function getFormatFromMimeType(mimeType: string): TileFormat;
34
-
35
- export { getFormatFromMimeType, getTileFormatFromBuffer, getTileFormatFromStream };
@@ -1,35 +0,0 @@
1
- import * as stream from 'stream';
2
- import { c as TileFormat } from '../types-yLQy3AKR.js';
3
- import '@maplibre/maplibre-gl-style-spec';
4
- import 'geojson';
5
- import 'type-fest';
6
- import 'readable-stream';
7
- import 'events';
8
-
9
- /**
10
- * For a given buffer, determine the tile format based on the magic bytes.
11
- * Will throw for unknown file types.
12
- * Smaller and faster version of magic-bytes.js due to the limited use case.
13
- *
14
- * @param {Buffer | Uint8Array} buf
15
- * @returns {import("../writer.js").TileFormat}
16
- */
17
- declare function getTileFormatFromBuffer(buf: Buffer | Uint8Array): TileFormat;
18
- /**
19
- * Determine the tile format from either a readable stream, buffer or Uint8Array
20
- * from the magic bytes at the start of the file. Used if data is served without
21
- * a content-type header.
22
- *
23
- * @param {import('stream').Readable} tileData
24
- * @returns {Promise<[import("../writer.js").TileFormat, import('stream').Readable]>}
25
- */
26
- declare function getTileFormatFromStream(tileData: stream.Readable): Promise<[TileFormat, stream.Readable]>;
27
- /**
28
- * Get the tile format from a MIME type. Throws for unsupported types.
29
- *
30
- * @param {string} mimeType
31
- * @returns {import("../writer.js").TileFormat}
32
- */
33
- declare function getFormatFromMimeType(mimeType: string): TileFormat;
34
-
35
- export { getFormatFromMimeType, getTileFormatFromBuffer, getTileFormatFromStream };
@@ -1,62 +0,0 @@
1
- import BufferPeerStream from "buffer-peek-stream";
2
- import { hasOwn } from "./misc.js";
3
- const peek = BufferPeerStream.promise;
4
- const MAGIC_BYTES = (
5
- /** @type {const} */
6
- {
7
- png: [137, 80, 78, 71, 13, 10, 26, 10],
8
- jpg: [255, 216, 255],
9
- // eslint-disable-next-line no-sparse-arrays
10
- webp: [82, 73, 70, 70, , , , , 87, 69, 66, 80],
11
- // Include the compression-type byte, which is always 0x08 (DEFLATE) for gzip
12
- gz: [31, 139, 8]
13
- }
14
- );
15
- const MIME_TYPES = (
16
- /** @type {const} */
17
- {
18
- "image/png": "png",
19
- "image/jpeg": "jpg",
20
- "image/webp": "webp"
21
- }
22
- );
23
- const magicByteMap = /* @__PURE__ */ new Map();
24
- for (const [ext, bytes] of Object.entries(MAGIC_BYTES)) {
25
- magicByteMap.set(
26
- bytes[0],
27
- // @ts-ignore
28
- ext
29
- );
30
- }
31
- function getTileFormatFromBuffer(buf) {
32
- const ext = magicByteMap.get(buf[0]);
33
- if (!ext) {
34
- throw new Error("Unknown file type");
35
- }
36
- const sig = MAGIC_BYTES[ext];
37
- for (let i = 1; i < sig.length; i++) {
38
- if (typeof sig[i] !== "undefined" && sig[i] !== buf[i]) {
39
- throw new Error("Unknown file type");
40
- }
41
- }
42
- if (ext === "gz") {
43
- return "mvt";
44
- }
45
- return ext;
46
- }
47
- async function getTileFormatFromStream(tileData) {
48
- const [peekedData, outputStream] = await peek(tileData, 16 * 1024);
49
- tileData = outputStream;
50
- const format = getTileFormatFromBuffer(peekedData);
51
- return [format, outputStream];
52
- }
53
- function getFormatFromMimeType(mimeType) {
54
- if (mimeType.startsWith("application/")) return "mvt";
55
- if (hasOwn(MIME_TYPES, mimeType)) return MIME_TYPES[mimeType];
56
- throw new Error("Unsupported MIME type " + mimeType);
57
- }
58
- export {
59
- getFormatFromMimeType,
60
- getTileFormatFromBuffer,
61
- getTileFormatFromStream
62
- };
@@ -1,84 +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 geo_exports = {};
20
- __export(geo_exports, {
21
- MAX_BOUNDS: () => MAX_BOUNDS,
22
- getQuadkey: () => getQuadkey,
23
- getTileUrl: () => getTileUrl,
24
- tileToBBox: () => tileToBBox,
25
- unionBBox: () => unionBBox
26
- });
27
- module.exports = __toCommonJS(geo_exports);
28
- const r2d = 180 / Math.PI;
29
- const MAX_BOUNDS = (
30
- /** @type {BBox} */
31
- [
32
- -180,
33
- -85.051129,
34
- 180,
35
- 85.051129
36
- ]
37
- );
38
- function tileToBBox({ x, y, z }) {
39
- const e = tile2lon({ x: x + 1, z });
40
- const w = tile2lon({ x, z });
41
- const s = tile2lat({ y: y + 1, z });
42
- const n = tile2lat({ y, z });
43
- return [w, s, e, n];
44
- }
45
- function getQuadkey({ x, y, z }) {
46
- let quadkey = "";
47
- let mask;
48
- for (let i = z; i > 0; i--) {
49
- mask = 1 << i - 1;
50
- quadkey += (x & mask ? 1 : 0) + (y & mask ? 2 : 0);
51
- }
52
- return quadkey;
53
- }
54
- function getTileUrl(urls, { x, y, z, scheme = "xyz" }) {
55
- const bboxEspg3857 = tileToBBox({ x, y: Math.pow(2, z) - y - 1, z });
56
- const quadkey = getQuadkey({ x, y, z });
57
- return urls[(x + y) % urls.length].replace("{prefix}", (x % 16).toString(16) + (y % 16).toString(16)).replace(/{z}/g, String(z)).replace(/{x}/g, String(x)).replace(/{y}/g, String(scheme === "tms" ? Math.pow(2, z) - y - 1 : y)).replace("{quadkey}", quadkey).replace("{bbox-epsg-3857}", bboxEspg3857.join(","));
58
- }
59
- function unionBBox(bboxes) {
60
- let [w, s, e, n] = bboxes[0];
61
- for (let i = 1; i < bboxes.length; i++) {
62
- const [w1, s1, e1, n1] = bboxes[i];
63
- w = Math.min(w, w1);
64
- s = Math.min(s, s1);
65
- e = Math.max(e, e1);
66
- n = Math.max(n, n1);
67
- }
68
- return [w, s, e, n];
69
- }
70
- function tile2lon({ x, z }) {
71
- return x / Math.pow(2, z) * 360 - 180;
72
- }
73
- function tile2lat({ y, z }) {
74
- const n = Math.PI - 2 * Math.PI * y / Math.pow(2, z);
75
- return r2d * Math.atan(0.5 * (Math.exp(n) - Math.exp(-n)));
76
- }
77
- // Annotate the CommonJS export names for ESM import in node:
78
- 0 && (module.exports = {
79
- MAX_BOUNDS,
80
- getQuadkey,
81
- getTileUrl,
82
- tileToBBox,
83
- unionBBox
84
- });
@@ -1,46 +0,0 @@
1
- /**
2
- * @typedef {[number, number, number, number]} BBox
3
- */
4
- /**
5
- * Return the bounding box for the given tile.
6
- *
7
- * @param {{ x: number, y: number, z: number }} tile
8
- * @returns {BBox} Bounding Box [w, s, e, n]
9
- */
10
- declare function tileToBBox({ x, y, z }: {
11
- x: number;
12
- y: number;
13
- z: number;
14
- }): BBox;
15
- /**
16
- * @param {{ x: number, y: number, z: number }} tile
17
- */
18
- declare function getQuadkey({ x, y, z }: {
19
- x: number;
20
- y: number;
21
- z: number;
22
- }): string;
23
- /**
24
- * From an array of tile URL templates, get the URL for the given tile.
25
- *
26
- * @param {string[]} urls
27
- * @param {{ x: number, y: number, z: number, scheme?: 'xyz' | 'tms' }} opts
28
- */
29
- declare function getTileUrl(urls: string[], { x, y, z, scheme }: {
30
- x: number;
31
- y: number;
32
- z: number;
33
- scheme?: "xyz" | "tms";
34
- }): string;
35
- /**
36
- * Returns a bbox that is the smallest bounding box that contains all the input bboxes.
37
- *
38
- * @param {[BBox, ...BBox[]]} bboxes
39
- * @returns {BBox} Bounding Box [w, s, e, n]
40
- */
41
- declare function unionBBox(bboxes: [BBox, ...BBox[]]): BBox;
42
- /** Spherical Mercator max bounds, rounded to 6 decimal places */
43
- declare const MAX_BOUNDS: BBox;
44
- type BBox = [number, number, number, number];
45
-
46
- export { type BBox, MAX_BOUNDS, getQuadkey, getTileUrl, tileToBBox, unionBBox };
@@ -1,46 +0,0 @@
1
- /**
2
- * @typedef {[number, number, number, number]} BBox
3
- */
4
- /**
5
- * Return the bounding box for the given tile.
6
- *
7
- * @param {{ x: number, y: number, z: number }} tile
8
- * @returns {BBox} Bounding Box [w, s, e, n]
9
- */
10
- declare function tileToBBox({ x, y, z }: {
11
- x: number;
12
- y: number;
13
- z: number;
14
- }): BBox;
15
- /**
16
- * @param {{ x: number, y: number, z: number }} tile
17
- */
18
- declare function getQuadkey({ x, y, z }: {
19
- x: number;
20
- y: number;
21
- z: number;
22
- }): string;
23
- /**
24
- * From an array of tile URL templates, get the URL for the given tile.
25
- *
26
- * @param {string[]} urls
27
- * @param {{ x: number, y: number, z: number, scheme?: 'xyz' | 'tms' }} opts
28
- */
29
- declare function getTileUrl(urls: string[], { x, y, z, scheme }: {
30
- x: number;
31
- y: number;
32
- z: number;
33
- scheme?: "xyz" | "tms";
34
- }): string;
35
- /**
36
- * Returns a bbox that is the smallest bounding box that contains all the input bboxes.
37
- *
38
- * @param {[BBox, ...BBox[]]} bboxes
39
- * @returns {BBox} Bounding Box [w, s, e, n]
40
- */
41
- declare function unionBBox(bboxes: [BBox, ...BBox[]]): BBox;
42
- /** Spherical Mercator max bounds, rounded to 6 decimal places */
43
- declare const MAX_BOUNDS: BBox;
44
- type BBox = [number, number, number, number];
45
-
46
- export { type BBox, MAX_BOUNDS, getQuadkey, getTileUrl, tileToBBox, unionBBox };