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,73 +0,0 @@
1
- import * as stream from 'stream';
2
- import * as readable_stream from 'readable-stream';
3
- import { Transform, TransformOptions } from 'readable-stream';
4
-
5
- /** @import { TransformOptions } from 'readable-stream' */
6
- /**
7
- * Create a writable stream from an async function. Default concurrecy is 16 -
8
- * this is the number of parallel functions that will be pending before
9
- * backpressure is applied on the stream.
10
- *
11
- * @template {(...args: any[]) => Promise<void>} T
12
- * @param {T} fn
13
- * @returns {import('readable-stream').Writable}
14
- */
15
- declare function writeStreamFromAsync<T extends (...args: any[]) => Promise<void>>(fn: T, { concurrency }?: {
16
- concurrency?: number | undefined;
17
- }): readable_stream.Writable;
18
- /**
19
- * From https://github.com/nodejs/node/blob/430c0269/lib/internal/webstreams/adapters.js#L509
20
- *
21
- * @param {ReadableStream} readableStream
22
- * @param {{
23
- * highWaterMark? : number,
24
- * encoding? : string,
25
- * objectMode? : boolean,
26
- * signal? : AbortSignal,
27
- * }} [options]
28
- * @returns {import('stream').Readable}
29
- */
30
- declare function fromWebReadableStream(readableStream: ReadableStream, options?: {
31
- highWaterMark?: number;
32
- encoding?: string;
33
- objectMode?: boolean;
34
- signal?: AbortSignal;
35
- }): stream.Readable;
36
- /**
37
- * @param {unknown} obj
38
- * @returns {obj is ReadableStream}
39
- */
40
- declare function isWebReadableStream(obj: unknown): obj is ReadableStream;
41
- /** @typedef {(opts: { totalBytes: number, chunkBytes: number }) => void} ProgressCallback */
42
- /** @typedef {TransformOptions & { onprogress?: ProgressCallback }} ProgressStreamOptions */
43
- /**
44
- * Passthrough stream that counts the bytes passing through it. Pass an optional
45
- * `onprogress` callback that will be called with the accumulated total byte
46
- * count and the chunk byte count after each chunk.
47
- * @extends {Transform}
48
- */
49
- declare class ProgressStream extends Transform {
50
- /**
51
- * @param {ProgressStreamOptions} [opts]
52
- */
53
- constructor({ onprogress, ...opts }?: ProgressStreamOptions);
54
- /** Total bytes that have passed through this stream */
55
- get byteLength(): number;
56
- /**
57
- * @override
58
- * @param {Buffer | Uint8Array} chunk
59
- * @param {Parameters<Transform['_transform']>[1]} encoding
60
- * @param {Parameters<Transform['_transform']>[2]} callback
61
- */
62
- override _transform(chunk: Buffer | Uint8Array, encoding: Parameters<Transform["_transform"]>[1], callback: Parameters<Transform["_transform"]>[2]): void;
63
- #private;
64
- }
65
- type ProgressCallback = (opts: {
66
- totalBytes: number;
67
- chunkBytes: number;
68
- }) => void;
69
- type ProgressStreamOptions = TransformOptions & {
70
- onprogress?: ProgressCallback;
71
- };
72
-
73
- export { type ProgressCallback, ProgressStream, type ProgressStreamOptions, fromWebReadableStream, isWebReadableStream, writeStreamFromAsync };
@@ -1,103 +0,0 @@
1
- import { Readable, Writable, Transform } from "readable-stream";
2
- function writeStreamFromAsync(fn, { concurrency = 16 } = {}) {
3
- return new Writable({
4
- highWaterMark: concurrency,
5
- objectMode: true,
6
- write(chunk, encoding, callback) {
7
- fn.apply(null, chunk).then(() => callback(), callback);
8
- }
9
- });
10
- }
11
- function fromWebReadableStream(readableStream, options = {}) {
12
- if (!isWebReadableStream(readableStream)) {
13
- throw new Error("First argument must be a ReadableStream");
14
- }
15
- const { highWaterMark, encoding, objectMode = false, signal } = options;
16
- if (encoding !== void 0 && !Buffer.isEncoding(encoding))
17
- throw new Error("Invalid encoding");
18
- const reader = readableStream.getReader();
19
- let closed = false;
20
- const readable = new Readable({
21
- objectMode,
22
- highWaterMark,
23
- encoding,
24
- // @ts-ignore
25
- signal,
26
- read() {
27
- reader.read().then(
28
- (chunk) => {
29
- if (chunk.done) {
30
- readable.push(null);
31
- } else {
32
- readable.push(chunk.value);
33
- }
34
- },
35
- (error) => readable.destroy(error)
36
- );
37
- },
38
- destroy(error, callback) {
39
- function done() {
40
- try {
41
- callback(error);
42
- } catch (error2) {
43
- process.nextTick(() => {
44
- throw error2;
45
- });
46
- }
47
- }
48
- if (!closed) {
49
- reader.cancel(error).then(done, done);
50
- return;
51
- }
52
- done();
53
- }
54
- });
55
- reader.closed.then(
56
- () => {
57
- closed = true;
58
- },
59
- (error) => {
60
- closed = true;
61
- readable.destroy(error);
62
- }
63
- );
64
- return readable;
65
- }
66
- function isWebReadableStream(obj) {
67
- return !!(typeof obj === "object" && obj !== null && "pipeThrough" in obj && typeof obj.pipeThrough === "function" && "getReader" in obj && typeof obj.getReader === "function" && "cancel" in obj && typeof obj.cancel === "function");
68
- }
69
- class ProgressStream extends Transform {
70
- #onprogress;
71
- #byteLength = 0;
72
- /**
73
- * @param {ProgressStreamOptions} [opts]
74
- */
75
- constructor({ onprogress, ...opts } = {}) {
76
- super(opts);
77
- this.#onprogress = onprogress;
78
- }
79
- /** Total bytes that have passed through this stream */
80
- get byteLength() {
81
- return this.#byteLength;
82
- }
83
- /**
84
- * @override
85
- * @param {Buffer | Uint8Array} chunk
86
- * @param {Parameters<Transform['_transform']>[1]} encoding
87
- * @param {Parameters<Transform['_transform']>[2]} callback
88
- */
89
- _transform(chunk, encoding, callback) {
90
- this.#byteLength += chunk.length;
91
- this.#onprogress?.({
92
- totalBytes: this.#byteLength,
93
- chunkBytes: chunk.length
94
- });
95
- callback(null, chunk);
96
- }
97
- }
98
- export {
99
- ProgressStream,
100
- fromWebReadableStream,
101
- isWebReadableStream,
102
- writeStreamFromAsync
103
- };
@@ -1,126 +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 style_exports = {};
20
- __export(style_exports, {
21
- assertTileJSON: () => assertTileJSON,
22
- isInlinedSource: () => isInlinedSource,
23
- mapFontStacks: () => mapFontStacks,
24
- replaceFontStacks: () => replaceFontStacks,
25
- validateStyle: () => validateStyle
26
- });
27
- module.exports = __toCommonJS(style_exports);
28
- var import_maplibre_gl_style_spec = require("@maplibre/maplibre-gl-style-spec");
29
- function replaceFontStacks(style, fonts) {
30
- const mappedLayers = mapFontStacks(style.layers, (fontStack) => {
31
- let match;
32
- for (const font of fontStack) {
33
- if (fonts.includes(font)) {
34
- match = font;
35
- break;
36
- }
37
- }
38
- return [match || fonts[0]];
39
- });
40
- style.layers = mappedLayers;
41
- return style;
42
- }
43
- function mapFontStacks(layers, callbackFn) {
44
- return layers.map((layer) => {
45
- if (layer.type !== "symbol" || !layer.layout || !layer.layout["text-font"])
46
- return layer;
47
- const textFont = layer.layout["text-font"];
48
- let mappedValue;
49
- if (isExpression(textFont)) {
50
- mappedValue = mapArrayExpressionValue(textFont, callbackFn);
51
- } else if (Array.isArray(textFont)) {
52
- mappedValue = callbackFn(textFont);
53
- } else {
54
- console.warn(
55
- "Deprecated function definitions are not supported, font stack has not been transformed."
56
- );
57
- console.dir(textFont, { depth: null });
58
- return layer;
59
- }
60
- return {
61
- ...layer,
62
- layout: {
63
- ...layer.layout,
64
- "text-font": mappedValue
65
- }
66
- };
67
- });
68
- }
69
- function isExpression(value) {
70
- return Array.isArray(value) && value.length > 0 && typeof value[0] === "string" && value[0] in import_maplibre_gl_style_spec.expressions;
71
- }
72
- function mapArrayExpressionValue(expression, callbackFn) {
73
- if (expression[0] === "literal" && Array.isArray(expression[1])) {
74
- return ["literal", callbackFn(expression[1])];
75
- } else {
76
- return [
77
- expression[0],
78
- ...expression.slice(1).map(
79
- // @ts-ignore
80
- (x) => {
81
- if (isExpression(x)) {
82
- return mapArrayExpressionValue(x, callbackFn);
83
- } else {
84
- return x;
85
- }
86
- }
87
- )
88
- ];
89
- }
90
- }
91
- function assertTileJSON(tilejson) {
92
- if (typeof tilejson !== "object" || tilejson === null) {
93
- throw new Error("Invalid TileJSON");
94
- }
95
- if (!("tiles" in tilejson) || !Array.isArray(tilejson.tiles) || tilejson.tiles.length === 0 || tilejson.tiles.some((tile) => typeof tile !== "string")) {
96
- throw new Error("Invalid TileJSON: missing or invalid tiles property");
97
- }
98
- }
99
- const validateStyle = (
100
- /** @type {{ (style: unknown): style is StyleSpecification, errors: ValidationError[] }} */
101
- ((style) => {
102
- validateStyle.errors = (0, import_maplibre_gl_style_spec.validateStyleMin)(
103
- /** @type {StyleSpecification} */
104
- style
105
- );
106
- if (validateStyle.errors.length) return false;
107
- return true;
108
- })
109
- );
110
- function isInlinedSource(source) {
111
- if (source.type === "geojson") {
112
- return typeof source.data === "object";
113
- } else if (source.type === "vector" || source.type === "raster" || source.type === "raster-dem") {
114
- return "tiles" in source;
115
- } else {
116
- return true;
117
- }
118
- }
119
- // Annotate the CommonJS export names for ESM import in node:
120
- 0 && (module.exports = {
121
- assertTileJSON,
122
- isInlinedSource,
123
- mapFontStacks,
124
- replaceFontStacks,
125
- validateStyle
126
- });
@@ -1,69 +0,0 @@
1
- import { BBox } from './geo.cjs';
2
- import { I as InlinedSource } from '../types-yLQy3AKR.cjs';
3
- import * as _maplibre_maplibre_gl_style_spec from '@maplibre/maplibre-gl-style-spec';
4
- import { StyleSpecification, ValidationError } from '@maplibre/maplibre-gl-style-spec';
5
- import 'geojson';
6
- import 'stream';
7
- import 'type-fest';
8
- import 'readable-stream';
9
- import 'events';
10
-
11
- /** @import {StyleSpecification, ExpressionSpecification, ValidationError} from '@maplibre/maplibre-gl-style-spec' */
12
- /**
13
- * For a given style, replace all font stacks (`text-field` properties) with the
14
- * provided fonts. If no matching font is found, the first font in the stack is
15
- * used.
16
- *
17
- * *Modifies the input style object*
18
- *
19
- * @param {StyleSpecification} style
20
- * @param {string[]} fonts
21
- */
22
- declare function replaceFontStacks(style: StyleSpecification, fonts: string[]): StyleSpecification;
23
- /**
24
- * From given style layers, create a new style by calling the provided callback
25
- * function on every font stack defined in the style.
26
- *
27
- * @param {StyleSpecification['layers']} layers
28
- * @param {(fontStack: string[]) => string[]} callbackFn
29
- * @returns {StyleSpecification['layers']}
30
- */
31
- declare function mapFontStacks(layers: StyleSpecification["layers"], callbackFn: (fontStack: string[]) => string[]): StyleSpecification["layers"];
32
- /**
33
- * @typedef {object} TileJSONPartial
34
- * @property {string[]} tiles
35
- * @property {string} [description]
36
- * @property {string} [attribution]
37
- * @property {object[]} [vector_layers]
38
- * @property {import('./geo.js').BBox} [bounds]
39
- * @property {number} [maxzoom]
40
- * @property {number} [minzoom]
41
- */
42
- /**
43
- *
44
- * @param {unknown} tilejson
45
- * @returns {asserts tilejson is TileJSONPartial}
46
- */
47
- declare function assertTileJSON(tilejson: unknown): asserts tilejson is TileJSONPartial;
48
- /**
49
- * Check whether a source is already inlined (e.g. does not reference a TileJSON or GeoJSON url)
50
- *
51
- * @param {import('@maplibre/maplibre-gl-style-spec').SourceSpecification} source
52
- * @returns {source is import('../types.js').InlinedSource}
53
- */
54
- declare function isInlinedSource(source: _maplibre_maplibre_gl_style_spec.SourceSpecification): source is InlinedSource;
55
- declare const validateStyle: {
56
- (style: unknown): style is StyleSpecification;
57
- errors: ValidationError[];
58
- };
59
- type TileJSONPartial = {
60
- tiles: string[];
61
- description?: string | undefined;
62
- attribution?: string | undefined;
63
- vector_layers?: object[] | undefined;
64
- bounds?: BBox | undefined;
65
- maxzoom?: number | undefined;
66
- minzoom?: number | undefined;
67
- };
68
-
69
- export { type TileJSONPartial, assertTileJSON, isInlinedSource, mapFontStacks, replaceFontStacks, validateStyle };
@@ -1,69 +0,0 @@
1
- import { BBox } from './geo.js';
2
- import { I as InlinedSource } from '../types-yLQy3AKR.js';
3
- import * as _maplibre_maplibre_gl_style_spec from '@maplibre/maplibre-gl-style-spec';
4
- import { StyleSpecification, ValidationError } from '@maplibre/maplibre-gl-style-spec';
5
- import 'geojson';
6
- import 'stream';
7
- import 'type-fest';
8
- import 'readable-stream';
9
- import 'events';
10
-
11
- /** @import {StyleSpecification, ExpressionSpecification, ValidationError} from '@maplibre/maplibre-gl-style-spec' */
12
- /**
13
- * For a given style, replace all font stacks (`text-field` properties) with the
14
- * provided fonts. If no matching font is found, the first font in the stack is
15
- * used.
16
- *
17
- * *Modifies the input style object*
18
- *
19
- * @param {StyleSpecification} style
20
- * @param {string[]} fonts
21
- */
22
- declare function replaceFontStacks(style: StyleSpecification, fonts: string[]): StyleSpecification;
23
- /**
24
- * From given style layers, create a new style by calling the provided callback
25
- * function on every font stack defined in the style.
26
- *
27
- * @param {StyleSpecification['layers']} layers
28
- * @param {(fontStack: string[]) => string[]} callbackFn
29
- * @returns {StyleSpecification['layers']}
30
- */
31
- declare function mapFontStacks(layers: StyleSpecification["layers"], callbackFn: (fontStack: string[]) => string[]): StyleSpecification["layers"];
32
- /**
33
- * @typedef {object} TileJSONPartial
34
- * @property {string[]} tiles
35
- * @property {string} [description]
36
- * @property {string} [attribution]
37
- * @property {object[]} [vector_layers]
38
- * @property {import('./geo.js').BBox} [bounds]
39
- * @property {number} [maxzoom]
40
- * @property {number} [minzoom]
41
- */
42
- /**
43
- *
44
- * @param {unknown} tilejson
45
- * @returns {asserts tilejson is TileJSONPartial}
46
- */
47
- declare function assertTileJSON(tilejson: unknown): asserts tilejson is TileJSONPartial;
48
- /**
49
- * Check whether a source is already inlined (e.g. does not reference a TileJSON or GeoJSON url)
50
- *
51
- * @param {import('@maplibre/maplibre-gl-style-spec').SourceSpecification} source
52
- * @returns {source is import('../types.js').InlinedSource}
53
- */
54
- declare function isInlinedSource(source: _maplibre_maplibre_gl_style_spec.SourceSpecification): source is InlinedSource;
55
- declare const validateStyle: {
56
- (style: unknown): style is StyleSpecification;
57
- errors: ValidationError[];
58
- };
59
- type TileJSONPartial = {
60
- tiles: string[];
61
- description?: string | undefined;
62
- attribution?: string | undefined;
63
- vector_layers?: object[] | undefined;
64
- bounds?: BBox | undefined;
65
- maxzoom?: number | undefined;
66
- minzoom?: number | undefined;
67
- };
68
-
69
- export { type TileJSONPartial, assertTileJSON, isInlinedSource, mapFontStacks, replaceFontStacks, validateStyle };
@@ -1,98 +0,0 @@
1
- import { expressions, validateStyleMin } from "@maplibre/maplibre-gl-style-spec";
2
- function replaceFontStacks(style, fonts) {
3
- const mappedLayers = mapFontStacks(style.layers, (fontStack) => {
4
- let match;
5
- for (const font of fontStack) {
6
- if (fonts.includes(font)) {
7
- match = font;
8
- break;
9
- }
10
- }
11
- return [match || fonts[0]];
12
- });
13
- style.layers = mappedLayers;
14
- return style;
15
- }
16
- function mapFontStacks(layers, callbackFn) {
17
- return layers.map((layer) => {
18
- if (layer.type !== "symbol" || !layer.layout || !layer.layout["text-font"])
19
- return layer;
20
- const textFont = layer.layout["text-font"];
21
- let mappedValue;
22
- if (isExpression(textFont)) {
23
- mappedValue = mapArrayExpressionValue(textFont, callbackFn);
24
- } else if (Array.isArray(textFont)) {
25
- mappedValue = callbackFn(textFont);
26
- } else {
27
- console.warn(
28
- "Deprecated function definitions are not supported, font stack has not been transformed."
29
- );
30
- console.dir(textFont, { depth: null });
31
- return layer;
32
- }
33
- return {
34
- ...layer,
35
- layout: {
36
- ...layer.layout,
37
- "text-font": mappedValue
38
- }
39
- };
40
- });
41
- }
42
- function isExpression(value) {
43
- return Array.isArray(value) && value.length > 0 && typeof value[0] === "string" && value[0] in expressions;
44
- }
45
- function mapArrayExpressionValue(expression, callbackFn) {
46
- if (expression[0] === "literal" && Array.isArray(expression[1])) {
47
- return ["literal", callbackFn(expression[1])];
48
- } else {
49
- return [
50
- expression[0],
51
- ...expression.slice(1).map(
52
- // @ts-ignore
53
- (x) => {
54
- if (isExpression(x)) {
55
- return mapArrayExpressionValue(x, callbackFn);
56
- } else {
57
- return x;
58
- }
59
- }
60
- )
61
- ];
62
- }
63
- }
64
- function assertTileJSON(tilejson) {
65
- if (typeof tilejson !== "object" || tilejson === null) {
66
- throw new Error("Invalid TileJSON");
67
- }
68
- if (!("tiles" in tilejson) || !Array.isArray(tilejson.tiles) || tilejson.tiles.length === 0 || tilejson.tiles.some((tile) => typeof tile !== "string")) {
69
- throw new Error("Invalid TileJSON: missing or invalid tiles property");
70
- }
71
- }
72
- const validateStyle = (
73
- /** @type {{ (style: unknown): style is StyleSpecification, errors: ValidationError[] }} */
74
- ((style) => {
75
- validateStyle.errors = validateStyleMin(
76
- /** @type {StyleSpecification} */
77
- style
78
- );
79
- if (validateStyle.errors.length) return false;
80
- return true;
81
- })
82
- );
83
- function isInlinedSource(source) {
84
- if (source.type === "geojson") {
85
- return typeof source.data === "object";
86
- } else if (source.type === "vector" || source.type === "raster" || source.type === "raster-dem") {
87
- return "tiles" in source;
88
- } else {
89
- return true;
90
- }
91
- }
92
- export {
93
- assertTileJSON,
94
- isInlinedSource,
95
- mapFontStacks,
96
- replaceFontStacks,
97
- validateStyle
98
- };
@@ -1,118 +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 templates_exports = {};
20
- __export(templates_exports, {
21
- FONTS_FOLDER: () => FONTS_FOLDER,
22
- GLYPH_URI: () => GLYPH_URI,
23
- SOURCES_FOLDER: () => SOURCES_FOLDER,
24
- STYLE_FILE: () => STYLE_FILE,
25
- URI_BASE: () => URI_BASE,
26
- URI_SCHEME: () => URI_SCHEME,
27
- getContentType: () => getContentType,
28
- getGlyphFilename: () => getGlyphFilename,
29
- getResourceType: () => getResourceType,
30
- getSpriteFilename: () => getSpriteFilename,
31
- getSpriteUri: () => getSpriteUri,
32
- getTileFilename: () => getTileFilename,
33
- getTileUri: () => getTileUri,
34
- replaceVariables: () => replaceVariables
35
- });
36
- module.exports = __toCommonJS(templates_exports);
37
- const URI_SCHEME = "smp";
38
- const URI_BASE = URI_SCHEME + "://maps.v1/";
39
- const STYLE_FILE = "style.json";
40
- const SOURCES_FOLDER = "s";
41
- const SPRITES_FOLDER = "sprites";
42
- const FONTS_FOLDER = "fonts";
43
- const TILE_FILE = SOURCES_FOLDER + "/{sourceId}/{z}/{x}/{y}{ext}";
44
- const SPRITE_FILE = SPRITES_FOLDER + "/{id}/sprite{pixelRatio}{ext}";
45
- const GLYPH_FILE = FONTS_FOLDER + "/{fontstack}/{range}.pbf.gz";
46
- const GLYPH_URI = URI_BASE + GLYPH_FILE;
47
- const pathToResouceType = (
48
- /** @type {const} */
49
- {
50
- [TILE_FILE.split("/")[0] + "/"]: "tile",
51
- [SPRITE_FILE.split("/")[0] + "/"]: "sprite",
52
- [GLYPH_FILE.split("/")[0] + "/"]: "glyph"
53
- }
54
- );
55
- function getResourceType(path) {
56
- if (path === "style.json") return "style";
57
- for (const [prefix, type] of Object.entries(pathToResouceType)) {
58
- if (path.startsWith(prefix)) return type;
59
- }
60
- throw new Error(`Unknown resource type for path: ${path}`);
61
- }
62
- function getContentType(path) {
63
- if (path.endsWith(".json")) return "application/json; charset=utf-8";
64
- if (path.endsWith(".pbf.gz") || path.endsWith(".pbf"))
65
- return "application/x-protobuf";
66
- if (path.endsWith(".png")) return "image/png";
67
- if (path.endsWith(".jpg")) return "image/jpeg";
68
- if (path.endsWith(".webp")) return "image/webp";
69
- if (path.endsWith(".mvt.gz") || path.endsWith(".mvt"))
70
- return "application/vnd.mapbox-vector-tile";
71
- throw new Error(`Unknown content type for path: ${path}`);
72
- }
73
- function getTileFilename({ sourceId, z, x, y, format }) {
74
- const ext = "." + format + (format === "mvt" ? ".gz" : "");
75
- return replaceVariables(TILE_FILE, { sourceId, z, x, y, ext });
76
- }
77
- function getSpriteFilename({ id, pixelRatio, ext }) {
78
- return replaceVariables(SPRITE_FILE, {
79
- id,
80
- pixelRatio: getPixelRatioString(pixelRatio),
81
- ext
82
- });
83
- }
84
- function getGlyphFilename({ fontstack, range }) {
85
- return replaceVariables(GLYPH_FILE, { fontstack, range });
86
- }
87
- function getSpriteUri(id = "default") {
88
- return URI_BASE + replaceVariables(SPRITE_FILE, { id, pixelRatio: "", ext: "" });
89
- }
90
- function getTileUri({ sourceId, format }) {
91
- const ext = "." + format + (format === "mvt" ? ".gz" : "");
92
- return URI_BASE + TILE_FILE.replace("{sourceId}", sourceId).replace("{ext}", ext);
93
- }
94
- function getPixelRatioString(pixelRatio) {
95
- return pixelRatio === 1 ? "" : `@${pixelRatio}x`;
96
- }
97
- function replaceVariables(template, variables) {
98
- return template.replace(/{(.*?)}/g, (match, varName) => {
99
- return varName in variables ? String(variables[varName]) : match;
100
- });
101
- }
102
- // Annotate the CommonJS export names for ESM import in node:
103
- 0 && (module.exports = {
104
- FONTS_FOLDER,
105
- GLYPH_URI,
106
- SOURCES_FOLDER,
107
- STYLE_FILE,
108
- URI_BASE,
109
- URI_SCHEME,
110
- getContentType,
111
- getGlyphFilename,
112
- getResourceType,
113
- getSpriteFilename,
114
- getSpriteUri,
115
- getTileFilename,
116
- getTileUri,
117
- replaceVariables
118
- });