styled-map-package 4.0.1 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (189) hide show
  1. package/bin/smp-download.js +1 -1
  2. package/bin/smp-view.js +32 -23
  3. package/dist/download.d.cts +1 -1
  4. package/dist/download.d.ts +1 -1
  5. package/dist/index.d.cts +2 -2
  6. package/dist/index.d.ts +2 -2
  7. package/dist/reader-watch.d.cts +1 -1
  8. package/dist/reader-watch.d.ts +1 -1
  9. package/dist/reader.cjs +2 -1
  10. package/dist/reader.d.cts +1 -1
  11. package/dist/reader.d.ts +1 -1
  12. package/dist/reader.js +2 -1
  13. package/dist/server.d.cts +1 -1
  14. package/dist/server.d.ts +1 -1
  15. package/dist/style-downloader.cjs +2 -2
  16. package/dist/style-downloader.d.cts +1 -1
  17. package/dist/style-downloader.d.ts +1 -1
  18. package/dist/style-downloader.js +2 -2
  19. package/dist/tile-downloader.cjs +2 -2
  20. package/dist/tile-downloader.d.cts +1 -1
  21. package/dist/tile-downloader.d.ts +1 -1
  22. package/dist/tile-downloader.js +2 -2
  23. package/dist/{types-B4Xn1F9K.d.cts → types-yLQy3AKR.d.cts} +6 -3
  24. package/dist/{types-B4Xn1F9K.d.ts → types-yLQy3AKR.d.ts} +6 -3
  25. package/dist/utils/file-formats.d.cts +1 -1
  26. package/dist/utils/file-formats.d.ts +1 -1
  27. package/dist/utils/style.cjs +2 -2
  28. package/dist/utils/style.d.cts +1 -1
  29. package/dist/utils/style.d.ts +1 -1
  30. package/dist/utils/style.js +2 -2
  31. package/dist/utils/templates.cjs +4 -0
  32. package/dist/utils/templates.d.cts +4 -2
  33. package/dist/utils/templates.d.ts +4 -2
  34. package/dist/utils/templates.js +2 -0
  35. package/dist/writer.cjs +51 -3
  36. package/dist/writer.d.cts +1 -1
  37. package/dist/writer.d.ts +1 -1
  38. package/dist/writer.js +53 -3
  39. package/node_modules/@node-rs/crc32/LICENSE +21 -0
  40. package/node_modules/@node-rs/crc32/README.md +61 -0
  41. package/node_modules/@node-rs/crc32/browser.js +1 -0
  42. package/node_modules/@node-rs/crc32/index.d.ts +5 -0
  43. package/node_modules/@node-rs/crc32/index.js +368 -0
  44. package/node_modules/@node-rs/crc32/package.json +97 -0
  45. package/node_modules/@node-rs/crc32-linux-x64-gnu/README.md +3 -0
  46. package/node_modules/@node-rs/crc32-linux-x64-gnu/crc32.linux-x64-gnu.node +0 -0
  47. package/node_modules/@node-rs/crc32-linux-x64-gnu/package.json +43 -0
  48. package/node_modules/@node-rs/crc32-linux-x64-musl/README.md +3 -0
  49. package/node_modules/@node-rs/crc32-linux-x64-musl/crc32.linux-x64-musl.node +0 -0
  50. package/node_modules/@node-rs/crc32-linux-x64-musl/package.json +43 -0
  51. package/node_modules/define-data-property/.eslintrc +24 -0
  52. package/node_modules/define-data-property/.github/FUNDING.yml +12 -0
  53. package/node_modules/define-data-property/.nycrc +13 -0
  54. package/node_modules/define-data-property/CHANGELOG.md +70 -0
  55. package/node_modules/define-data-property/LICENSE +21 -0
  56. package/node_modules/define-data-property/README.md +67 -0
  57. package/node_modules/define-data-property/index.d.ts +12 -0
  58. package/node_modules/define-data-property/index.js +56 -0
  59. package/node_modules/define-data-property/package.json +106 -0
  60. package/node_modules/define-data-property/test/index.js +392 -0
  61. package/node_modules/define-data-property/tsconfig.json +59 -0
  62. package/node_modules/define-properties/.editorconfig +13 -0
  63. package/node_modules/define-properties/.eslintrc +19 -0
  64. package/node_modules/define-properties/.github/FUNDING.yml +12 -0
  65. package/node_modules/define-properties/.nycrc +9 -0
  66. package/node_modules/define-properties/CHANGELOG.md +91 -0
  67. package/node_modules/define-properties/LICENSE +21 -0
  68. package/node_modules/define-properties/README.md +84 -0
  69. package/node_modules/define-properties/index.js +47 -0
  70. package/node_modules/define-properties/package.json +88 -0
  71. package/node_modules/es-define-property/.eslintrc +13 -0
  72. package/node_modules/es-define-property/.github/FUNDING.yml +12 -0
  73. package/node_modules/es-define-property/.nycrc +9 -0
  74. package/node_modules/es-define-property/CHANGELOG.md +29 -0
  75. package/node_modules/es-define-property/LICENSE +21 -0
  76. package/node_modules/es-define-property/README.md +49 -0
  77. package/node_modules/es-define-property/index.d.ts +3 -0
  78. package/node_modules/es-define-property/index.js +14 -0
  79. package/node_modules/es-define-property/package.json +81 -0
  80. package/node_modules/es-define-property/test/index.js +56 -0
  81. package/node_modules/es-define-property/tsconfig.json +10 -0
  82. package/node_modules/es-errors/.eslintrc +5 -0
  83. package/node_modules/es-errors/.github/FUNDING.yml +12 -0
  84. package/node_modules/es-errors/CHANGELOG.md +40 -0
  85. package/node_modules/es-errors/LICENSE +21 -0
  86. package/node_modules/es-errors/README.md +55 -0
  87. package/node_modules/es-errors/eval.d.ts +3 -0
  88. package/node_modules/es-errors/eval.js +4 -0
  89. package/node_modules/es-errors/index.d.ts +3 -0
  90. package/node_modules/es-errors/index.js +4 -0
  91. package/node_modules/es-errors/package.json +80 -0
  92. package/node_modules/es-errors/range.d.ts +3 -0
  93. package/node_modules/es-errors/range.js +4 -0
  94. package/node_modules/es-errors/ref.d.ts +3 -0
  95. package/node_modules/es-errors/ref.js +4 -0
  96. package/node_modules/es-errors/syntax.d.ts +3 -0
  97. package/node_modules/es-errors/syntax.js +4 -0
  98. package/node_modules/es-errors/test/index.js +19 -0
  99. package/node_modules/es-errors/tsconfig.json +49 -0
  100. package/node_modules/es-errors/type.d.ts +3 -0
  101. package/node_modules/es-errors/type.js +4 -0
  102. package/node_modules/es-errors/uri.d.ts +3 -0
  103. package/node_modules/es-errors/uri.js +4 -0
  104. package/node_modules/globalthis/.eslintrc +18 -0
  105. package/node_modules/globalthis/.nycrc +10 -0
  106. package/node_modules/globalthis/CHANGELOG.md +109 -0
  107. package/node_modules/globalthis/LICENSE +21 -0
  108. package/node_modules/globalthis/README.md +70 -0
  109. package/node_modules/globalthis/auto.js +3 -0
  110. package/node_modules/globalthis/implementation.browser.js +11 -0
  111. package/node_modules/globalthis/implementation.js +3 -0
  112. package/node_modules/globalthis/index.js +19 -0
  113. package/node_modules/globalthis/package.json +99 -0
  114. package/node_modules/globalthis/polyfill.js +10 -0
  115. package/node_modules/globalthis/shim.js +29 -0
  116. package/node_modules/globalthis/test/implementation.js +11 -0
  117. package/node_modules/globalthis/test/index.js +11 -0
  118. package/node_modules/globalthis/test/native.js +26 -0
  119. package/node_modules/globalthis/test/shimmed.js +29 -0
  120. package/node_modules/globalthis/test/tests.js +36 -0
  121. package/node_modules/gopd/.eslintrc +16 -0
  122. package/node_modules/gopd/.github/FUNDING.yml +12 -0
  123. package/node_modules/gopd/CHANGELOG.md +45 -0
  124. package/node_modules/gopd/LICENSE +21 -0
  125. package/node_modules/gopd/README.md +40 -0
  126. package/node_modules/gopd/gOPD.d.ts +1 -0
  127. package/node_modules/gopd/gOPD.js +4 -0
  128. package/node_modules/gopd/index.d.ts +5 -0
  129. package/node_modules/gopd/index.js +15 -0
  130. package/node_modules/gopd/package.json +77 -0
  131. package/node_modules/gopd/test/index.js +36 -0
  132. package/node_modules/gopd/tsconfig.json +9 -0
  133. package/node_modules/has-property-descriptors/.eslintrc +13 -0
  134. package/node_modules/has-property-descriptors/.github/FUNDING.yml +12 -0
  135. package/node_modules/has-property-descriptors/.nycrc +9 -0
  136. package/node_modules/has-property-descriptors/CHANGELOG.md +35 -0
  137. package/node_modules/has-property-descriptors/LICENSE +21 -0
  138. package/node_modules/has-property-descriptors/README.md +43 -0
  139. package/node_modules/has-property-descriptors/index.js +22 -0
  140. package/node_modules/has-property-descriptors/package.json +77 -0
  141. package/node_modules/has-property-descriptors/test/index.js +57 -0
  142. package/node_modules/is-it-type/License +19 -0
  143. package/node_modules/is-it-type/README.md +102 -0
  144. package/node_modules/is-it-type/changelog.md +239 -0
  145. package/node_modules/is-it-type/dist/cjs/is-it-type.js +173 -0
  146. package/node_modules/is-it-type/dist/cjs/is-it-type.js.map +1 -0
  147. package/node_modules/is-it-type/dist/cjs/is-it-type.min.js +2 -0
  148. package/node_modules/is-it-type/dist/cjs/is-it-type.min.js.map +1 -0
  149. package/node_modules/is-it-type/dist/esm/is-it-type.js +143 -0
  150. package/node_modules/is-it-type/dist/esm/is-it-type.js.map +1 -0
  151. package/node_modules/is-it-type/dist/esm/is-it-type.min.js +2 -0
  152. package/node_modules/is-it-type/dist/esm/is-it-type.min.js.map +1 -0
  153. package/node_modules/is-it-type/dist/esm/package.json +3 -0
  154. package/node_modules/is-it-type/dist/umd/is-it-type.js +450 -0
  155. package/node_modules/is-it-type/dist/umd/is-it-type.js.map +1 -0
  156. package/node_modules/is-it-type/dist/umd/is-it-type.min.js +2 -0
  157. package/node_modules/is-it-type/dist/umd/is-it-type.min.js.map +1 -0
  158. package/node_modules/is-it-type/es/index.js +8 -0
  159. package/node_modules/is-it-type/es/package.json +3 -0
  160. package/node_modules/is-it-type/index.js +10 -0
  161. package/node_modules/is-it-type/package.json +87 -0
  162. package/node_modules/is-it-type/src/index.js +169 -0
  163. package/node_modules/object-keys/.editorconfig +13 -0
  164. package/node_modules/object-keys/.eslintrc +17 -0
  165. package/node_modules/object-keys/.travis.yml +277 -0
  166. package/node_modules/object-keys/CHANGELOG.md +232 -0
  167. package/node_modules/object-keys/LICENSE +21 -0
  168. package/node_modules/object-keys/README.md +76 -0
  169. package/node_modules/object-keys/implementation.js +122 -0
  170. package/node_modules/object-keys/index.js +32 -0
  171. package/node_modules/object-keys/isArguments.js +17 -0
  172. package/node_modules/object-keys/package.json +88 -0
  173. package/node_modules/object-keys/test/index.js +5 -0
  174. package/node_modules/simple-invariant/License +19 -0
  175. package/node_modules/simple-invariant/README.md +64 -0
  176. package/node_modules/simple-invariant/changelog.md +31 -0
  177. package/node_modules/simple-invariant/index.js +19 -0
  178. package/node_modules/simple-invariant/package.json +50 -0
  179. package/node_modules/yauzl-promise/License +19 -0
  180. package/node_modules/yauzl-promise/README.md +440 -0
  181. package/node_modules/yauzl-promise/index.js +10 -0
  182. package/node_modules/yauzl-promise/lib/entry.js +312 -0
  183. package/node_modules/yauzl-promise/lib/index.js +160 -0
  184. package/node_modules/yauzl-promise/lib/reader.js +289 -0
  185. package/node_modules/yauzl-promise/lib/shared.js +20 -0
  186. package/node_modules/yauzl-promise/lib/utils.js +105 -0
  187. package/node_modules/yauzl-promise/lib/zip.js +1224 -0
  188. package/node_modules/yauzl-promise/package.json +56 -0
  189. package/package.json +9 -11
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { Command, InvalidArgumentError } from '@commander-js/extra-typings'
3
2
  import { input, number } from '@inquirer/prompts'
3
+ import { Command, InvalidArgumentError } from 'commander'
4
4
  import fs from 'fs'
5
5
  import { pipeline } from 'stream/promises'
6
6
 
package/bin/smp-view.js CHANGED
@@ -1,8 +1,9 @@
1
1
  #!/usr/bin/env node
2
- import fastifyStatic from '@fastify/static'
3
2
  import { createServerAdapter } from '@whatwg-node/server'
4
3
  import { Command } from 'commander'
5
- import fastify from 'fastify'
4
+ import fsPromises from 'fs/promises'
5
+ import http from 'http'
6
+ import { AutoRouter } from 'itty-router'
6
7
  import openApp from 'open'
7
8
 
8
9
  import path from 'node:path'
@@ -28,37 +29,45 @@ program
28
29
  program.parseAsync(process.argv)
29
30
 
30
31
  /**
31
- * Serve a styled map package on the given port (defaults to 3000). Use the
32
- * fastify plugin in `./server.js` for more flexibility.
32
+ * Serve a styled map package on the given port (defaults to 3000).
33
33
  *
34
34
  * @param {object} opts
35
35
  * @param {number} [opts.port]
36
36
  * @param {string} opts.filepath
37
37
  * @returns
38
38
  */
39
- function serve({ port = 3000, filepath }) {
39
+ async function serve({ port = 3000, filepath }) {
40
40
  const reader = new Reader(path.relative(process.cwd(), filepath))
41
41
  const smpServer = createServer({ base: '/map' })
42
- const serverAdapter = createServerAdapter((request) => {
43
- return smpServer.fetch(request, reader)
44
- })
45
-
46
- const server = fastify()
47
42
 
48
- server.register(fastifyStatic, {
49
- root: new URL('../map-viewer', import.meta.url),
50
- serve: false,
43
+ const router = AutoRouter()
44
+ router.get('/', async () => {
45
+ const index = await fsPromises.readFile(
46
+ new URL('../map-viewer/index.html', import.meta.url),
47
+ )
48
+ return new Response(new Uint8Array(index), {
49
+ headers: {
50
+ 'Content-Type': 'text/html',
51
+ 'Content-Length': String(index.byteLength),
52
+ 'Cache-Control': 'public, max-age=0',
53
+ },
54
+ })
51
55
  })
52
- server.get('/', async (request, reply) => {
53
- return reply.sendFile('index.html')
56
+ router.all('/map/*', (request) => {
57
+ return smpServer.fetch(request, reader)
54
58
  })
55
-
56
- server.route({
57
- url: '/map/*',
58
- method: ['GET', 'HEAD', 'OPTIONS'],
59
- handler: (req, reply) => {
60
- return serverAdapter.handleNodeRequestAndResponse(req, reply)
61
- },
59
+ const server = http.createServer(createServerAdapter(router.fetch))
60
+ return new Promise((resolve, reject) => {
61
+ server.listen(port, '127.0.0.1', () => {
62
+ const address = server.address()
63
+ if (typeof address === 'string') {
64
+ resolve(`http://${address}`)
65
+ } else if (address === null) {
66
+ reject(new Error('Failed to get server address'))
67
+ } else {
68
+ resolve(`http://${address.address}:${address.port}`)
69
+ }
70
+ })
71
+ server.on('error', reject)
62
72
  })
63
- return server.listen({ port })
64
73
  }
@@ -1,6 +1,6 @@
1
1
  import { GlyphDownloadStats } from './style-downloader.cjs';
2
2
  import { TileDownloadStats } from './tile-downloader.cjs';
3
- import { D as DownloadStream } from './types-B4Xn1F9K.cjs';
3
+ import { D as DownloadStream } from './types-yLQy3AKR.cjs';
4
4
  import { BBox } from './utils/geo.cjs';
5
5
  import 'ky';
6
6
  import 'stream';
@@ -1,6 +1,6 @@
1
1
  import { GlyphDownloadStats } from './style-downloader.js';
2
2
  import { TileDownloadStats } from './tile-downloader.js';
3
- import { D as DownloadStream } from './types-B4Xn1F9K.js';
3
+ import { D as DownloadStream } from './types-yLQy3AKR.js';
4
4
  import { BBox } from './utils/geo.js';
5
5
  import 'ky';
6
6
  import 'stream';
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as SMPSource$1, a as SMPStyle$1 } from './types-B4Xn1F9K.cjs';
2
- export { W as Writer } from './types-B4Xn1F9K.cjs';
1
+ import { S as SMPSource$1, a as SMPStyle$1 } from './types-yLQy3AKR.cjs';
2
+ export { W as Writer } from './types-yLQy3AKR.cjs';
3
3
  export { Reader } from './reader.cjs';
4
4
  export { ReaderWatch } from './reader-watch.cjs';
5
5
  export { createServer } from './server.cjs';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as SMPSource$1, a as SMPStyle$1 } from './types-B4Xn1F9K.js';
2
- export { W as Writer } from './types-B4Xn1F9K.js';
1
+ import { S as SMPSource$1, a as SMPStyle$1 } from './types-yLQy3AKR.js';
2
+ export { W as Writer } from './types-yLQy3AKR.js';
3
3
  export { Reader } from './reader.js';
4
4
  export { ReaderWatch } from './reader-watch.js';
5
5
  export { createServer } from './server.js';
@@ -1,4 +1,4 @@
1
- import { a as SMPStyle } from './types-B4Xn1F9K.cjs';
1
+ import { a as SMPStyle } from './types-yLQy3AKR.cjs';
2
2
  import { Reader } from './reader.cjs';
3
3
  import '@maplibre/maplibre-gl-style-spec';
4
4
  import 'geojson';
@@ -1,4 +1,4 @@
1
- import { a as SMPStyle } from './types-B4Xn1F9K.js';
1
+ import { a as SMPStyle } from './types-yLQy3AKR.js';
2
2
  import { Reader } from './reader.js';
3
3
  import '@maplibre/maplibre-gl-style-spec';
4
4
  import 'geojson';
package/dist/reader.cjs CHANGED
@@ -145,7 +145,8 @@ class Reader {
145
145
  async close() {
146
146
  if (this.#closePromise) return this.#closePromise;
147
147
  this.#closePromise = (async () => {
148
- const zip = await this.#zipPromise;
148
+ const zip = await this.#zipPromise.catch(import_misc.noop);
149
+ if (!zip) return;
149
150
  await zip.close();
150
151
  })();
151
152
  return this.#closePromise;
package/dist/reader.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as stream from 'stream';
2
- import { a as SMPStyle } from './types-B4Xn1F9K.cjs';
2
+ import { a as SMPStyle } from './types-yLQy3AKR.cjs';
3
3
  import * as yauzl_promise from 'yauzl-promise';
4
4
  import '@maplibre/maplibre-gl-style-spec';
5
5
  import 'geojson';
package/dist/reader.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as stream from 'stream';
2
- import { a as SMPStyle } from './types-B4Xn1F9K.js';
2
+ import { a as SMPStyle } from './types-yLQy3AKR.js';
3
3
  import * as yauzl_promise from 'yauzl-promise';
4
4
  import '@maplibre/maplibre-gl-style-spec';
5
5
  import 'geojson';
package/dist/reader.js CHANGED
@@ -117,7 +117,8 @@ class Reader {
117
117
  async close() {
118
118
  if (this.#closePromise) return this.#closePromise;
119
119
  this.#closePromise = (async () => {
120
- const zip = await this.#zipPromise;
120
+ const zip = await this.#zipPromise.catch(noop);
121
+ if (!zip) return;
121
122
  await zip.close();
122
123
  })();
123
124
  return this.#closePromise;
package/dist/server.d.cts CHANGED
@@ -2,7 +2,7 @@ import { RequestLike } from 'itty-router';
2
2
  import { Reader } from './reader.cjs';
3
3
  import { IttyRouter } from 'itty-router/IttyRouter';
4
4
  import 'stream';
5
- import './types-B4Xn1F9K.cjs';
5
+ import './types-yLQy3AKR.cjs';
6
6
  import '@maplibre/maplibre-gl-style-spec';
7
7
  import 'geojson';
8
8
  import 'type-fest';
package/dist/server.d.ts CHANGED
@@ -2,7 +2,7 @@ import { RequestLike } from 'itty-router';
2
2
  import { Reader } from './reader.js';
3
3
  import { IttyRouter } from 'itty-router/IttyRouter';
4
4
  import 'stream';
5
- import './types-B4Xn1F9K.js';
5
+ import './types-yLQy3AKR.js';
6
6
  import '@maplibre/maplibre-gl-style-spec';
7
7
  import 'geojson';
8
8
  import 'type-fest';
@@ -252,7 +252,7 @@ class StyleDownloader {
252
252
  skipped: 0,
253
253
  totalBytes: 0
254
254
  };
255
- const tiles = async function* () {
255
+ const tiles = (async function* () {
256
256
  const inlinedStyle = await _this.getStyle();
257
257
  for await (const [sourceId, source] of Object.entries(
258
258
  inlinedStyle.sources
@@ -284,7 +284,7 @@ class StyleDownloader {
284
284
  sourceTiles.skipped.map((tile) => ({ ...tile, sourceId }))
285
285
  );
286
286
  }
287
- }();
287
+ })();
288
288
  Object.defineProperty(tiles, "skipped", {
289
289
  get() {
290
290
  return skipped;
@@ -1,7 +1,7 @@
1
1
  import * as ky from 'ky';
2
2
  import { BBox } from './utils/geo.cjs';
3
3
  import * as stream from 'stream';
4
- import { b as StyleInlinedSources, G as GlyphInfo, T as TileInfo } from './types-B4Xn1F9K.cjs';
4
+ import { b as StyleInlinedSources, G as GlyphInfo, T as TileInfo } from './types-yLQy3AKR.cjs';
5
5
  import { TileDownloadStats } from './tile-downloader.cjs';
6
6
  import { StyleSpecification } from '@maplibre/maplibre-gl-style-spec';
7
7
  import 'geojson';
@@ -1,7 +1,7 @@
1
1
  import * as ky from 'ky';
2
2
  import { BBox } from './utils/geo.js';
3
3
  import * as stream from 'stream';
4
- import { b as StyleInlinedSources, G as GlyphInfo, T as TileInfo } from './types-B4Xn1F9K.js';
4
+ import { b as StyleInlinedSources, G as GlyphInfo, T as TileInfo } from './types-yLQy3AKR.js';
5
5
  import { TileDownloadStats } from './tile-downloader.js';
6
6
  import { StyleSpecification } from '@maplibre/maplibre-gl-style-spec';
7
7
  import 'geojson';
@@ -229,7 +229,7 @@ class StyleDownloader {
229
229
  skipped: 0,
230
230
  totalBytes: 0
231
231
  };
232
- const tiles = async function* () {
232
+ const tiles = (async function* () {
233
233
  const inlinedStyle = await _this.getStyle();
234
234
  for await (const [sourceId, source] of Object.entries(
235
235
  inlinedStyle.sources
@@ -261,7 +261,7 @@ class StyleDownloader {
261
261
  sourceTiles.skipped.map((tile) => ({ ...tile, sourceId }))
262
262
  );
263
263
  }
264
- }();
264
+ })();
265
265
  Object.defineProperty(tiles, "skipped", {
266
266
  get() {
267
267
  return skipped;
@@ -77,7 +77,7 @@ function downloadTiles({
77
77
  stats.skipped = skipped.length;
78
78
  onprogress(stats);
79
79
  }
80
- const tiles = async function* () {
80
+ const tiles = (async function* () {
81
81
  const queue = new import_yocto_queue.default();
82
82
  const tiles2 = tileIterator({
83
83
  bounds,
@@ -115,7 +115,7 @@ function downloadTiles({
115
115
  }
116
116
  yield [stream, { ...tileInfo, format }];
117
117
  }
118
- }();
118
+ })();
119
119
  Object.defineProperty(tiles, "skipped", {
120
120
  get() {
121
121
  return skipped;
@@ -1,4 +1,4 @@
1
- import { T as TileInfo$1 } from './types-B4Xn1F9K.cjs';
1
+ import { T as TileInfo$1 } from './types-yLQy3AKR.cjs';
2
2
  import * as stream from 'stream';
3
3
  import { BBox } from './utils/geo.cjs';
4
4
  import { FetchQueue } from './utils/fetch.cjs';
@@ -1,4 +1,4 @@
1
- import { T as TileInfo$1 } from './types-B4Xn1F9K.js';
1
+ import { T as TileInfo$1 } from './types-yLQy3AKR.js';
2
2
  import * as stream from 'stream';
3
3
  import { BBox } from './utils/geo.js';
4
4
  import { FetchQueue } from './utils/fetch.js';
@@ -46,7 +46,7 @@ function downloadTiles({
46
46
  stats.skipped = skipped.length;
47
47
  onprogress(stats);
48
48
  }
49
- const tiles = async function* () {
49
+ const tiles = (async function* () {
50
50
  const queue = new Queue();
51
51
  const tiles2 = tileIterator({
52
52
  bounds,
@@ -84,7 +84,7 @@ function downloadTiles({
84
84
  }
85
85
  yield [stream, { ...tileInfo, format }];
86
86
  }
87
- }();
87
+ })();
88
88
  Object.defineProperty(tiles, "skipped", {
89
89
  get() {
90
90
  return skipped;
@@ -1,4 +1,4 @@
1
- import { SourceSpecification, GeoJSONSourceSpecification, VectorSourceSpecification, RasterSourceSpecification, RasterDEMSourceSpecification, StyleSpecification } from '@maplibre/maplibre-gl-style-spec';
1
+ import { StyleSpecification, SourceSpecification, GeoJSONSourceSpecification, VectorSourceSpecification, RasterSourceSpecification, RasterDEMSourceSpecification } from '@maplibre/maplibre-gl-style-spec';
2
2
  import { GeoJSON, BBox } from 'geojson';
3
3
  import * as stream from 'stream';
4
4
  import { Readable } from 'stream';
@@ -111,9 +111,12 @@ declare class Writer extends EventEmitter<[never]> {
111
111
  * This method must be called to complete the archive.
112
112
  * You must wait for your destination write stream to 'finish' before using the output.
113
113
  */
114
- finish(): void;
114
+ finish(): Promise<void>;
115
115
  #private;
116
116
  }
117
+ type ZipEntry = {
118
+ name: string;
119
+ };
117
120
  type Source = string | Buffer | Uint8Array | stream.Readable;
118
121
  type SourceInternal = string | Buffer | stream.Readable;
119
122
  type GlyphRange = `${number}-${number}`;
@@ -186,4 +189,4 @@ interface DownloadStream extends Readable {
186
189
  }
187
190
  type OmitUnion<T, K extends keyof any> = T extends unknown ? Omit<T, K> : never;
188
191
 
189
- 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 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 SourceInternal as g, type SourceInfo as h };
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,4 +1,4 @@
1
- import { SourceSpecification, GeoJSONSourceSpecification, VectorSourceSpecification, RasterSourceSpecification, RasterDEMSourceSpecification, StyleSpecification } from '@maplibre/maplibre-gl-style-spec';
1
+ import { StyleSpecification, SourceSpecification, GeoJSONSourceSpecification, VectorSourceSpecification, RasterSourceSpecification, RasterDEMSourceSpecification } from '@maplibre/maplibre-gl-style-spec';
2
2
  import { GeoJSON, BBox } from 'geojson';
3
3
  import * as stream from 'stream';
4
4
  import { Readable } from 'stream';
@@ -111,9 +111,12 @@ declare class Writer extends EventEmitter<[never]> {
111
111
  * This method must be called to complete the archive.
112
112
  * You must wait for your destination write stream to 'finish' before using the output.
113
113
  */
114
- finish(): void;
114
+ finish(): Promise<void>;
115
115
  #private;
116
116
  }
117
+ type ZipEntry = {
118
+ name: string;
119
+ };
117
120
  type Source = string | Buffer | Uint8Array | stream.Readable;
118
121
  type SourceInternal = string | Buffer | stream.Readable;
119
122
  type GlyphRange = `${number}-${number}`;
@@ -186,4 +189,4 @@ interface DownloadStream extends Readable {
186
189
  }
187
190
  type OmitUnion<T, K extends keyof any> = T extends unknown ? Omit<T, K> : never;
188
191
 
189
- 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 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 SourceInternal as g, type SourceInfo as h };
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,5 +1,5 @@
1
1
  import * as stream from 'stream';
2
- import { c as TileFormat } from '../types-B4Xn1F9K.cjs';
2
+ import { c as TileFormat } from '../types-yLQy3AKR.cjs';
3
3
  import '@maplibre/maplibre-gl-style-spec';
4
4
  import 'geojson';
5
5
  import 'type-fest';
@@ -1,5 +1,5 @@
1
1
  import * as stream from 'stream';
2
- import { c as TileFormat } from '../types-B4Xn1F9K.js';
2
+ import { c as TileFormat } from '../types-yLQy3AKR.js';
3
3
  import '@maplibre/maplibre-gl-style-spec';
4
4
  import 'geojson';
5
5
  import 'type-fest';
@@ -98,14 +98,14 @@ function assertTileJSON(tilejson) {
98
98
  }
99
99
  const validateStyle = (
100
100
  /** @type {{ (style: unknown): style is StyleSpecification, errors: ValidationError[] }} */
101
- (style) => {
101
+ ((style) => {
102
102
  validateStyle.errors = (0, import_maplibre_gl_style_spec.validateStyleMin)(
103
103
  /** @type {StyleSpecification} */
104
104
  style
105
105
  );
106
106
  if (validateStyle.errors.length) return false;
107
107
  return true;
108
- }
108
+ })
109
109
  );
110
110
  function isInlinedSource(source) {
111
111
  if (source.type === "geojson") {
@@ -1,5 +1,5 @@
1
1
  import { BBox } from './geo.cjs';
2
- import { I as InlinedSource } from '../types-B4Xn1F9K.cjs';
2
+ import { I as InlinedSource } from '../types-yLQy3AKR.cjs';
3
3
  import * as _maplibre_maplibre_gl_style_spec from '@maplibre/maplibre-gl-style-spec';
4
4
  import { StyleSpecification, ValidationError } from '@maplibre/maplibre-gl-style-spec';
5
5
  import 'geojson';
@@ -1,5 +1,5 @@
1
1
  import { BBox } from './geo.js';
2
- import { I as InlinedSource } from '../types-B4Xn1F9K.js';
2
+ import { I as InlinedSource } from '../types-yLQy3AKR.js';
3
3
  import * as _maplibre_maplibre_gl_style_spec from '@maplibre/maplibre-gl-style-spec';
4
4
  import { StyleSpecification, ValidationError } from '@maplibre/maplibre-gl-style-spec';
5
5
  import 'geojson';
@@ -71,14 +71,14 @@ function assertTileJSON(tilejson) {
71
71
  }
72
72
  const validateStyle = (
73
73
  /** @type {{ (style: unknown): style is StyleSpecification, errors: ValidationError[] }} */
74
- (style) => {
74
+ ((style) => {
75
75
  validateStyle.errors = validateStyleMin(
76
76
  /** @type {StyleSpecification} */
77
77
  style
78
78
  );
79
79
  if (validateStyle.errors.length) return false;
80
80
  return true;
81
- }
81
+ })
82
82
  );
83
83
  function isInlinedSource(source) {
84
84
  if (source.type === "geojson") {
@@ -18,7 +18,9 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var templates_exports = {};
20
20
  __export(templates_exports, {
21
+ FONTS_FOLDER: () => FONTS_FOLDER,
21
22
  GLYPH_URI: () => GLYPH_URI,
23
+ SOURCES_FOLDER: () => SOURCES_FOLDER,
22
24
  STYLE_FILE: () => STYLE_FILE,
23
25
  URI_BASE: () => URI_BASE,
24
26
  URI_SCHEME: () => URI_SCHEME,
@@ -99,7 +101,9 @@ function replaceVariables(template, variables) {
99
101
  }
100
102
  // Annotate the CommonJS export names for ESM import in node:
101
103
  0 && (module.exports = {
104
+ FONTS_FOLDER,
102
105
  GLYPH_URI,
106
+ SOURCES_FOLDER,
103
107
  STYLE_FILE,
104
108
  URI_BASE,
105
109
  URI_SCHEME,
@@ -1,5 +1,5 @@
1
1
  import * as type_fest from 'type-fest';
2
- import { T as TileInfo, d as GlyphRange, c as TileFormat } from '../types-B4Xn1F9K.cjs';
2
+ import { d as GlyphRange, T as TileInfo, c as TileFormat } from '../types-yLQy3AKR.cjs';
3
3
  import '@maplibre/maplibre-gl-style-spec';
4
4
  import 'geojson';
5
5
  import 'stream';
@@ -73,6 +73,8 @@ declare function replaceVariables(template: string, variables: Record<string, st
73
73
  declare const URI_SCHEME: "smp";
74
74
  declare const URI_BASE: string;
75
75
  declare const STYLE_FILE: "style.json";
76
+ declare const SOURCES_FOLDER: "s";
77
+ declare const FONTS_FOLDER: "fonts";
76
78
  declare const GLYPH_URI: string;
77
79
 
78
- export { GLYPH_URI, STYLE_FILE, URI_BASE, URI_SCHEME, getContentType, getGlyphFilename, getResourceType, getSpriteFilename, getSpriteUri, getTileFilename, getTileUri, replaceVariables };
80
+ export { FONTS_FOLDER, GLYPH_URI, SOURCES_FOLDER, STYLE_FILE, URI_BASE, URI_SCHEME, getContentType, getGlyphFilename, getResourceType, getSpriteFilename, getSpriteUri, getTileFilename, getTileUri, replaceVariables };
@@ -1,5 +1,5 @@
1
1
  import * as type_fest from 'type-fest';
2
- import { T as TileInfo, d as GlyphRange, c as TileFormat } from '../types-B4Xn1F9K.js';
2
+ import { d as GlyphRange, T as TileInfo, c as TileFormat } from '../types-yLQy3AKR.js';
3
3
  import '@maplibre/maplibre-gl-style-spec';
4
4
  import 'geojson';
5
5
  import 'stream';
@@ -73,6 +73,8 @@ declare function replaceVariables(template: string, variables: Record<string, st
73
73
  declare const URI_SCHEME: "smp";
74
74
  declare const URI_BASE: string;
75
75
  declare const STYLE_FILE: "style.json";
76
+ declare const SOURCES_FOLDER: "s";
77
+ declare const FONTS_FOLDER: "fonts";
76
78
  declare const GLYPH_URI: string;
77
79
 
78
- export { GLYPH_URI, STYLE_FILE, URI_BASE, URI_SCHEME, getContentType, getGlyphFilename, getResourceType, getSpriteFilename, getSpriteUri, getTileFilename, getTileUri, replaceVariables };
80
+ export { FONTS_FOLDER, GLYPH_URI, SOURCES_FOLDER, STYLE_FILE, URI_BASE, URI_SCHEME, getContentType, getGlyphFilename, getResourceType, getSpriteFilename, getSpriteUri, getTileFilename, getTileUri, replaceVariables };
@@ -64,7 +64,9 @@ function replaceVariables(template, variables) {
64
64
  });
65
65
  }
66
66
  export {
67
+ FONTS_FOLDER,
67
68
  GLYPH_URI,
69
+ SOURCES_FOLDER,
68
70
  STYLE_FILE,
69
71
  URI_BASE,
70
72
  URI_SCHEME,
package/dist/writer.cjs CHANGED
@@ -295,11 +295,12 @@ class Writer extends import_events.EventEmitter {
295
295
  * This method must be called to complete the archive.
296
296
  * You must wait for your destination write stream to 'finish' before using the output.
297
297
  */
298
- finish() {
298
+ async finish() {
299
299
  this.#prepareStyle();
300
300
  const style = JSON.stringify(this.#style);
301
- this.#append(style, { name: import_templates.STYLE_FILE });
302
- this.#archive.finalize();
301
+ await this.#append(style, { name: import_templates.STYLE_FILE });
302
+ sortEntries(this.#archive);
303
+ await this.#archive.finalize();
303
304
  }
304
305
  /**
305
306
  * Mutates the style object to prepare it for writing to the archive.
@@ -394,6 +395,53 @@ function get2DBBox(bbox2) {
394
395
  if (bbox2.length === 4) return bbox2;
395
396
  return [bbox2[0], bbox2[1], bbox2[3], bbox2[4]];
396
397
  }
398
+ function sortEntries(archive) {
399
+ const entries = (
400
+ /** @type {unknown} */
401
+ archive._module?.engine?._entries
402
+ );
403
+ if (!Array.isArray(entries)) {
404
+ throw new Error(
405
+ "Cannot find zip entries: check implementation changes in Archiver"
406
+ );
407
+ }
408
+ const sortedEntries = entries.sort(
409
+ /**
410
+ * @param {unknown} a
411
+ * @param {unknown} b
412
+ */
413
+ function(a, b) {
414
+ assertValidEntry(a);
415
+ assertValidEntry(b);
416
+ if (a.name === "style.json") return -1;
417
+ if (b.name === "style.json") return 1;
418
+ const foldersA = a.name.split("/");
419
+ const foldersB = b.name.split("/");
420
+ if (foldersA[0] === import_templates.FONTS_FOLDER && foldersA[2] === "0-255.pbf.gz")
421
+ return -1;
422
+ if (foldersB[0] === import_templates.FONTS_FOLDER && foldersB[2] === "0-255.pbf.gz")
423
+ return 1;
424
+ if (foldersA[0] === import_templates.SOURCES_FOLDER && foldersB[0] !== import_templates.SOURCES_FOLDER)
425
+ return -1;
426
+ if (foldersB[0] === import_templates.SOURCES_FOLDER && foldersA[0] !== import_templates.SOURCES_FOLDER)
427
+ return 1;
428
+ if (foldersA[0] === import_templates.SOURCES_FOLDER && foldersB[0] === import_templates.SOURCES_FOLDER) {
429
+ const zoomA = +foldersA[2];
430
+ const zoomB = +foldersB[2];
431
+ return zoomA - zoomB;
432
+ }
433
+ return 0;
434
+ }
435
+ );
436
+ archive._module.engine._entries = sortedEntries;
437
+ }
438
+ function assertValidEntry(maybeEntry) {
439
+ if (!maybeEntry || typeof maybeEntry !== "object" || !("name" in maybeEntry) || typeof maybeEntry.name !== "string") {
440
+ throw new Error(
441
+ "Unexpected zip entry type: check implementation changes in Archiver"
442
+ );
443
+ }
444
+ }
397
445
  // Annotate the CommonJS export names for ESM import in node:
398
446
  0 && (module.exports = {
399
447
  SUPPORTED_SOURCE_TYPES,
package/dist/writer.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { G as GlyphInfo, d as GlyphRange, e as SUPPORTED_SOURCE_TYPES, f as Source, h as SourceInfo, g as SourceInternal, c as TileFormat, T as TileInfo, W as Writer } from './types-B4Xn1F9K.cjs';
1
+ export { G as GlyphInfo, d as GlyphRange, e as SUPPORTED_SOURCE_TYPES, f as Source, g as SourceInfo, h as SourceInternal, c as TileFormat, T as TileInfo, W as Writer, Z as ZipEntry } from './types-yLQy3AKR.cjs';
2
2
  import 'readable-stream';
3
3
  import 'stream';
4
4
  import 'events';
package/dist/writer.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { G as GlyphInfo, d as GlyphRange, e as SUPPORTED_SOURCE_TYPES, f as Source, h as SourceInfo, g as SourceInternal, c as TileFormat, T as TileInfo, W as Writer } from './types-B4Xn1F9K.js';
1
+ export { G as GlyphInfo, d as GlyphRange, e as SUPPORTED_SOURCE_TYPES, f as Source, g as SourceInfo, h as SourceInternal, c as TileFormat, T as TileInfo, W as Writer, Z as ZipEntry } from './types-yLQy3AKR.js';
2
2
  import 'readable-stream';
3
3
  import 'stream';
4
4
  import 'events';