styled-map-package-api 5.0.0-pre.3 → 5.0.0-pre.4

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 (94) hide show
  1. package/README.md +94 -0
  2. package/dist/download.d.ts +11 -21
  3. package/dist/fallbacks.d.ts +32 -0
  4. package/dist/from-mbtiles.d.ts +1 -3
  5. package/dist/index.d.ts +11 -24
  6. package/dist/reader.d.ts +28 -12
  7. package/dist/server.d.ts +23 -14
  8. package/dist/style-downloader.d.ts +13 -19
  9. package/dist/tile-downloader.d.ts +13 -23
  10. package/dist/types.d.ts +61 -0
  11. package/dist/utils/errors.d.ts +2 -4
  12. package/dist/utils/fetch.d.ts +3 -8
  13. package/dist/utils/file-formats.d.ts +3 -10
  14. package/dist/utils/geo.d.ts +17 -9
  15. package/dist/utils/mapbox.d.ts +8 -10
  16. package/dist/utils/misc.d.ts +3 -5
  17. package/dist/utils/streams.d.ts +6 -10
  18. package/dist/utils/style.d.ts +27 -16
  19. package/dist/utils/templates.d.ts +30 -25
  20. package/dist/validator.d.ts +66 -0
  21. package/dist/writer.d.ts +157 -4
  22. package/lib/download.js +125 -0
  23. package/lib/fallbacks.js +157 -0
  24. package/lib/from-mbtiles.js +131 -0
  25. package/lib/index.js +12 -0
  26. package/lib/reader.js +360 -0
  27. package/lib/server.js +222 -0
  28. package/lib/style-downloader.js +369 -0
  29. package/lib/tile-downloader.js +189 -0
  30. package/lib/types.ts +99 -0
  31. package/lib/utils/errors.js +24 -0
  32. package/lib/utils/fetch.js +104 -0
  33. package/lib/utils/file-formats.js +92 -0
  34. package/lib/utils/geo.js +97 -0
  35. package/lib/utils/mapbox.js +155 -0
  36. package/{dist/utils/misc.d.cts → lib/utils/misc.js} +9 -5
  37. package/lib/utils/streams.js +101 -0
  38. package/lib/utils/style.js +206 -0
  39. package/lib/utils/templates.js +165 -0
  40. package/lib/validator.js +789 -0
  41. package/lib/writer.js +652 -0
  42. package/package.json +30 -78
  43. package/dist/download.cjs +0 -100
  44. package/dist/download.d.cts +0 -63
  45. package/dist/download.js +0 -76
  46. package/dist/from-mbtiles.cjs +0 -127
  47. package/dist/from-mbtiles.d.cts +0 -14
  48. package/dist/from-mbtiles.js +0 -103
  49. package/dist/index.cjs +0 -46
  50. package/dist/index.d.cts +0 -24
  51. package/dist/index.js +0 -16
  52. package/dist/reader.cjs +0 -287
  53. package/dist/reader.d.cts +0 -67
  54. package/dist/reader.js +0 -259
  55. package/dist/server.cjs +0 -73
  56. package/dist/server.d.cts +0 -45
  57. package/dist/server.js +0 -49
  58. package/dist/style-downloader.cjs +0 -314
  59. package/dist/style-downloader.d.cts +0 -118
  60. package/dist/style-downloader.js +0 -290
  61. package/dist/tile-downloader.cjs +0 -156
  62. package/dist/tile-downloader.d.cts +0 -82
  63. package/dist/tile-downloader.js +0 -124
  64. package/dist/types-Bhn0-Ldk.d.cts +0 -201
  65. package/dist/types-Bhn0-Ldk.d.ts +0 -201
  66. package/dist/utils/errors.cjs +0 -41
  67. package/dist/utils/errors.d.cts +0 -18
  68. package/dist/utils/errors.js +0 -16
  69. package/dist/utils/fetch.cjs +0 -97
  70. package/dist/utils/fetch.d.cts +0 -50
  71. package/dist/utils/fetch.js +0 -63
  72. package/dist/utils/file-formats.cjs +0 -96
  73. package/dist/utils/file-formats.d.cts +0 -32
  74. package/dist/utils/file-formats.js +0 -70
  75. package/dist/utils/geo.cjs +0 -84
  76. package/dist/utils/geo.d.cts +0 -46
  77. package/dist/utils/geo.js +0 -56
  78. package/dist/utils/mapbox.cjs +0 -121
  79. package/dist/utils/mapbox.d.cts +0 -43
  80. package/dist/utils/mapbox.js +0 -91
  81. package/dist/utils/misc.cjs +0 -39
  82. package/dist/utils/misc.js +0 -13
  83. package/dist/utils/streams.cjs +0 -99
  84. package/dist/utils/streams.d.cts +0 -49
  85. package/dist/utils/streams.js +0 -73
  86. package/dist/utils/style.cjs +0 -126
  87. package/dist/utils/style.d.cts +0 -66
  88. package/dist/utils/style.js +0 -98
  89. package/dist/utils/templates.cjs +0 -124
  90. package/dist/utils/templates.d.cts +0 -79
  91. package/dist/utils/templates.js +0 -85
  92. package/dist/writer.cjs +0 -539
  93. package/dist/writer.d.cts +0 -4
  94. package/dist/writer.js +0 -516
package/dist/writer.d.cts DELETED
@@ -1,4 +0,0 @@
1
- export { G as GlyphInfo, d as GlyphRange, e as SUPPORTED_SOURCE_TYPES, f as Source, g as SourceInfo, c as TileFormat, T as TileInfo, W as Writer, h as WriterOptions } from './types-Bhn0-Ldk.cjs';
2
- import '@maplibre/maplibre-gl-style-spec';
3
- import 'geojson';
4
- import 'type-fest';
package/dist/writer.js DELETED
@@ -1,516 +0,0 @@
1
- import { validateStyleMin, migrate } from "@maplibre/maplibre-gl-style-spec";
2
- import { bbox } from "@turf/bbox";
3
- import { excludeKeys } from "filter-obj";
4
- import { ZipWriter } from "zip-writer";
5
- import { getTileFormatFromStream } from "./utils/file-formats.js";
6
- import { MAX_BOUNDS, tileToBBox, unionBBox } from "./utils/geo.js";
7
- import { clone } from "./utils/misc.js";
8
- import { writeStreamFromAsync } from "./utils/streams.js";
9
- import { replaceFontStacks } from "./utils/style.js";
10
- import {
11
- FONTS_FOLDER,
12
- FORMAT_VERSION,
13
- getGlyphFilename,
14
- getSpriteFilename,
15
- getSpriteUri,
16
- getTileFilename,
17
- getTileUri,
18
- GLYPH_URI,
19
- SOURCES_FOLDER,
20
- STYLE_FILE,
21
- VERSION_FILE
22
- } from "./utils/templates.js";
23
- const SUPPORTED_SOURCE_TYPES = (
24
- /** @type {const} */
25
- [
26
- "raster",
27
- "vector",
28
- "geojson"
29
- ]
30
- );
31
- class Writer {
32
- #zipWriter = new ZipWriter();
33
- /** @type {Set<string>} */
34
- #addedFiles = /* @__PURE__ */ new Set();
35
- /** @type {Set<string>} */
36
- #fonts = /* @__PURE__ */ new Set();
37
- /** @type {Set<string>} */
38
- #addedSpriteIds = /* @__PURE__ */ new Set();
39
- /** @type {Map<string, SourceInfo>} */
40
- #sources = /* @__PURE__ */ new Map();
41
- /** @type {StyleSpecification} */
42
- #style;
43
- /** @type {ReadableStream<Uint8Array>} */
44
- #outputStream;
45
- /** @type {ReadableStreamDefaultController<Uint8Array>} */
46
- #outputController;
47
- /** @type {boolean} */
48
- #dedupe;
49
- /** @type {Map<string, string>} hash → first entry name */
50
- #tileHashes = /* @__PURE__ */ new Map();
51
- /** @type {Array<{ name: string, originalName: string }>} */
52
- #duplicateEntries = [];
53
- static SUPPORTED_SOURCE_TYPES = SUPPORTED_SOURCE_TYPES;
54
- /**
55
- * @param {any} style A v7 or v8 MapLibre style. v7 styles will be migrated to
56
- * v8. (There are currently no typescript declarations for v7 styles, hence
57
- * this is typed as `any` and validated internally)
58
- * @param {WriterOptions} [options]
59
- */
60
- constructor(style, { dedupe = false } = {}) {
61
- if (!style || !("version" in style)) {
62
- throw new Error("Invalid style");
63
- }
64
- if (style.version !== 7 && style.version !== 8) {
65
- throw new Error(`Invalid style: Unsupported version v${style.version}`);
66
- }
67
- if (!Array.isArray(style.layers)) {
68
- throw new Error("Invalid style: missing layers property");
69
- }
70
- const styleCopy = clone(style);
71
- migrate(styleCopy);
72
- const errors = validateStyleMin(styleCopy);
73
- if (errors.length) {
74
- throw new AggregateError(errors, "Invalid style");
75
- }
76
- this.#style = styleCopy;
77
- this.#dedupe = dedupe;
78
- for (const [sourceId, source] of Object.entries(this.#style.sources)) {
79
- if (source.type !== "geojson") continue;
80
- this.#addSource(sourceId, source);
81
- }
82
- const zipReader = this.#zipWriter.readable.getReader();
83
- let outputController;
84
- this.#outputStream = new ReadableStream({
85
- start(controller) {
86
- outputController = controller;
87
- },
88
- async pull(controller) {
89
- try {
90
- const { done, value } = await zipReader.read();
91
- if (done) {
92
- controller.close();
93
- } else {
94
- controller.enqueue(
95
- /** @type {Uint8Array} */
96
- value
97
- );
98
- }
99
- } catch (err) {
100
- controller.error(err);
101
- }
102
- },
103
- cancel(reason) {
104
- zipReader.cancel(reason);
105
- }
106
- });
107
- this.#outputController = outputController;
108
- }
109
- /**
110
- * @returns {ReadableStream<Uint8Array>} Readable stream of the styled map package
111
- */
112
- get outputStream() {
113
- return this.#outputStream;
114
- }
115
- /**
116
- * Abort the output stream with an error. Call this if an error occurs during
117
- * writing to propagate the error to consumers of `outputStream`.
118
- *
119
- * @param {Error} reason
120
- */
121
- abort(reason) {
122
- this.#outputController.error(reason);
123
- }
124
- #getBounds() {
125
- let bounds;
126
- let maxzoom = 0;
127
- for (const { source } of this.#sources.values()) {
128
- if (source.type === "geojson") {
129
- if (isEmptyFeatureCollection(source.data)) continue;
130
- const bbox2 = get2DBBox(source.data.bbox);
131
- bounds = bounds ? unionBBox([bounds, bbox2]) : [...bbox2];
132
- } else {
133
- if (source.maxzoom < maxzoom) continue;
134
- if (source.maxzoom === maxzoom) {
135
- bounds = bounds ? unionBBox([bounds, source.bounds]) : source.bounds;
136
- } else {
137
- bounds = source.bounds;
138
- maxzoom = source.maxzoom;
139
- }
140
- }
141
- }
142
- return bounds;
143
- }
144
- #getMaxZoom() {
145
- let maxzoom = 0;
146
- for (const { source } of this.#sources.values()) {
147
- const sourceMaxzoom = (
148
- // For GeoJSON sources, the maxzoom is 16 unless otherwise set
149
- source.type === "geojson" ? source.maxzoom || 16 : source.maxzoom
150
- );
151
- maxzoom = Math.max(maxzoom, sourceMaxzoom);
152
- }
153
- return maxzoom;
154
- }
155
- /**
156
- * Add a source definition to the styled map package
157
- *
158
- * @param {string} sourceId
159
- * @param {InputSource} source
160
- * @returns {SourceInfo}
161
- */
162
- #addSource(sourceId, source) {
163
- const encodedSourceId = encodeSourceId(this.#sources.size);
164
- const tileSourceOverrides = {
165
- minzoom: 0,
166
- maxzoom: 0,
167
- bounds: (
168
- /** @type {import('./utils/geo.js').BBox} */
169
- [...MAX_BOUNDS]
170
- ),
171
- tiles: (
172
- /** @type {string[]} */
173
- []
174
- )
175
- };
176
- let smpSource;
177
- switch (source.type) {
178
- case "raster":
179
- case "vector":
180
- smpSource = {
181
- ...excludeKeys(source, ["tiles", "url"]),
182
- ...tileSourceOverrides
183
- };
184
- break;
185
- case "geojson":
186
- smpSource = {
187
- ...source,
188
- maxzoom: 0,
189
- data: typeof source.data !== "string" ? (
190
- // Add a bbox property to the GeoJSON data if it doesn't already have one
191
- { ...source.data, bbox: source.data.bbox || bbox(source.data) }
192
- ) : (
193
- // If GeoJSON data is referenced by a URL, start with an empty FeatureCollection
194
- {
195
- type: "FeatureCollection",
196
- features: [],
197
- bbox: [0, 0, 0, 0]
198
- }
199
- )
200
- };
201
- break;
202
- }
203
- const sourceInfo = {
204
- source: smpSource,
205
- encodedSourceId
206
- };
207
- this.#sources.set(sourceId, sourceInfo);
208
- return sourceInfo;
209
- }
210
- /**
211
- * Add a tile to the styled map package
212
- *
213
- * @param {Source} tileData
214
- * @param {TileInfo} opts
215
- */
216
- async addTile(tileData, { z, x, y, sourceId, format }) {
217
- let sourceInfo = this.#sources.get(sourceId);
218
- if (!sourceInfo) {
219
- const source2 = this.#style.sources[sourceId];
220
- if (!source2) {
221
- throw new Error(`Source not referenced in style.json: ${sourceId}`);
222
- }
223
- if (source2.type !== "raster" && source2.type !== "vector") {
224
- throw new Error(`Unsupported source type: ${source2.type}`);
225
- }
226
- sourceInfo = this.#addSource(sourceId, source2);
227
- }
228
- const { source, encodedSourceId } = sourceInfo;
229
- if (source.type !== "raster" && source.type !== "vector") {
230
- throw new Error(`Unsupported source type: ${source.type}`);
231
- }
232
- if (!format) {
233
- ;
234
- [format, tileData] = await getTileFormatFromStream(toWebStream(tileData));
235
- }
236
- if (!sourceInfo.format) {
237
- sourceInfo.format = format;
238
- } else if (sourceInfo.format !== format) {
239
- throw new Error(
240
- `Tile format mismatch for source ${sourceId}: expected ${sourceInfo.format}, got ${format}`
241
- );
242
- }
243
- const bbox2 = tileToBBox({ z, x, y });
244
- if (z > source.maxzoom) {
245
- source.maxzoom = z;
246
- source.bounds = bbox2;
247
- } else if (z === source.maxzoom) {
248
- source.bounds = unionBBox([source.bounds, bbox2]);
249
- }
250
- const name = getTileFilename({ sourceId: encodedSourceId, z, x, y, format });
251
- if (this.#dedupe) {
252
- const data = await toUint8Array(tileData);
253
- const hash = await hashData(data);
254
- if (this.#addedFiles.has(name)) {
255
- throw new Error(`${name} already added`);
256
- }
257
- this.#addedFiles.add(name);
258
- const existingName = this.#tileHashes.get(hash);
259
- if (existingName) {
260
- this.#duplicateEntries.push({ name, originalName: existingName });
261
- return;
262
- }
263
- this.#tileHashes.set(hash, name);
264
- const readable = toWebStream(data);
265
- await this.#zipWriter.addEntry({ readable, name, store: true });
266
- return;
267
- }
268
- return this.#append(tileData, { name, store: true });
269
- }
270
- /**
271
- * Create a write stream for adding tiles to the styled map package
272
- *
273
- * @param {object} opts
274
- * @param {number} [opts.concurrency=16] The number of concurrent writes
275
- *
276
- * @returns
277
- */
278
- createTileWriteStream({ concurrency = 16 } = {}) {
279
- return writeStreamFromAsync(this.addTile.bind(this), { concurrency });
280
- }
281
- /**
282
- * Add a sprite to the styled map package
283
- *
284
- * @param {object} options
285
- * @param {Source} options.json
286
- * @param {Source} options.png
287
- * @param {number} [options.pixelRatio]
288
- * @param {string} [options.id='default']
289
- * @returns {Promise<void>}
290
- */
291
- async addSprite({ json, png, pixelRatio = 1, id = "default" }) {
292
- this.#addedSpriteIds.add(id);
293
- const jsonName = getSpriteFilename({ id, pixelRatio, ext: ".json" });
294
- const pngName = getSpriteFilename({ id, pixelRatio, ext: ".png" });
295
- await Promise.all([
296
- this.#append(json, { name: jsonName }),
297
- this.#append(png, { name: pngName })
298
- ]);
299
- }
300
- /**
301
- * Add glyphs to the styled map package
302
- *
303
- * @param {Source} glyphData
304
- * @param {GlyphInfo} glyphInfo
305
- * @returns {Promise<void>}
306
- */
307
- addGlyphs(glyphData, { font: fontName, range }) {
308
- this.#fonts.add(fontName);
309
- const name = getGlyphFilename({ fontstack: fontName, range });
310
- return this.#append(glyphData, { name });
311
- }
312
- /**
313
- * Create a write stream for adding glyphs to the styled map package
314
- *
315
- * @param {object} opts
316
- * @param {number} [opts.concurrency=16] The number of concurrent writes
317
- * @returns
318
- */
319
- createGlyphWriteStream({ concurrency = 16 } = {}) {
320
- return writeStreamFromAsync(this.addGlyphs.bind(this), { concurrency });
321
- }
322
- /**
323
- * Finalize the styled map package and write the style to the archive.
324
- * This method must be called to complete the archive.
325
- * You must wait for your destination write stream to 'finish' before using the output.
326
- */
327
- async finish() {
328
- await this.#append(FORMAT_VERSION, { name: VERSION_FILE });
329
- this.#prepareStyle();
330
- const style = JSON.stringify(this.#style);
331
- await this.#append(style, { name: STYLE_FILE });
332
- let entries = await this.#zipWriter.entries();
333
- if (this.#duplicateEntries.length > 0) {
334
- const entriesByName = new Map(entries.map((e) => [e.name, e]));
335
- for (const { name, originalName } of this.#duplicateEntries) {
336
- const original = entriesByName.get(originalName);
337
- if (!original) {
338
- throw new Error(`Original entry ${originalName} not found`);
339
- }
340
- entries.push({ ...original, name });
341
- }
342
- }
343
- const sortedEntries = sortEntries(entries);
344
- await this.#zipWriter.finalize({ entries: sortedEntries });
345
- }
346
- /**
347
- * Mutates the style object to prepare it for writing to the archive.
348
- * Deterministic: can be run more than once with the same result.
349
- */
350
- #prepareStyle() {
351
- if (this.#sources.size === 0) {
352
- throw new Error("Missing sources: add at least one source");
353
- }
354
- if (this.#style.glyphs && this.#fonts.size === 0) {
355
- throw new Error(
356
- "Missing fonts: style references glyphs but no fonts added"
357
- );
358
- }
359
- replaceFontStacks(this.#style, [...this.#fonts]);
360
- if (this.#style.glyphs) {
361
- this.#style.glyphs = GLYPH_URI;
362
- }
363
- if (typeof this.#style.sprite === "string") {
364
- if (!this.#addedSpriteIds.has("default")) {
365
- throw new Error(
366
- "Missing sprite: style references sprite but none added"
367
- );
368
- }
369
- this.#style.sprite = getSpriteUri();
370
- } else if (Array.isArray(this.#style.sprite)) {
371
- this.#style.sprite = this.#style.sprite.map(({ id }) => {
372
- if (!this.#addedSpriteIds.has(id)) {
373
- throw new Error(
374
- `Missing sprite: style references sprite ${id} but none added`
375
- );
376
- }
377
- return { id, url: getSpriteUri(id) };
378
- });
379
- }
380
- this.#style.sources = {};
381
- for (const [sourceId, { source, encodedSourceId, format = "mvt" }] of this.#sources) {
382
- if (source.type === "geojson" && isEmptyFeatureCollection(source.data)) {
383
- continue;
384
- }
385
- this.#style.sources[sourceId] = source;
386
- if (!("tiles" in source)) continue;
387
- source.tiles = [getTileUri({ sourceId: encodedSourceId, format })];
388
- }
389
- this.#style.layers = this.#style.layers.filter(
390
- (layer) => !("source" in layer) || !!this.#style.sources[layer.source]
391
- );
392
- const metadata = this.#style.metadata || (this.#style.metadata = {});
393
- const bounds = this.#getBounds();
394
- if (bounds) {
395
- metadata["smp:bounds"] = bounds;
396
- const [w, s, e, n] = bounds;
397
- this.#style.center = [w + (e - w) / 2, s + (n - s) / 2];
398
- }
399
- metadata["smp:maxzoom"] = this.#getMaxZoom();
400
- metadata["smp:sourceFolders"] = {};
401
- for (const [sourceId, { encodedSourceId }] of this.#sources) {
402
- metadata["smp:sourceFolders"][sourceId] = encodedSourceId;
403
- }
404
- this.#style.zoom = Math.max(0, this.#getMaxZoom() - 2);
405
- }
406
- /**
407
- *
408
- * @param {Source} source
409
- * @param {{ name: string, store?: boolean }} options
410
- * @returns {Promise<void>}
411
- */
412
- async #append(source, { name, store = false }) {
413
- if (this.#addedFiles.has(name)) {
414
- throw new Error(`${name} already added`);
415
- }
416
- this.#addedFiles.add(name);
417
- const readable = toWebStream(source);
418
- await this.#zipWriter.addEntry({ readable, name, store });
419
- }
420
- }
421
- function encodeSourceId(sourceIndex) {
422
- return sourceIndex.toString(36);
423
- }
424
- function toWebStream(source) {
425
- if (typeof source === "string") {
426
- const bytes = new TextEncoder().encode(source);
427
- return new ReadableStream({
428
- start(controller) {
429
- controller.enqueue(bytes);
430
- controller.close();
431
- }
432
- });
433
- }
434
- if (source instanceof Uint8Array) {
435
- return new ReadableStream({
436
- start(controller) {
437
- controller.enqueue(
438
- new Uint8Array(source.buffer, source.byteOffset, source.byteLength)
439
- );
440
- controller.close();
441
- }
442
- });
443
- }
444
- return (
445
- /** @type {ReadableStream<Uint8Array>} */
446
- source
447
- );
448
- }
449
- function isEmptyFeatureCollection(data) {
450
- return data.type === "FeatureCollection" && data.features.length === 0;
451
- }
452
- function get2DBBox(bbox2) {
453
- if (bbox2.length === 4) return bbox2;
454
- return [bbox2[0], bbox2[1], bbox2[3], bbox2[4]];
455
- }
456
- async function toUint8Array(source) {
457
- if (source instanceof Uint8Array) return source;
458
- if (typeof source === "string") return new TextEncoder().encode(source);
459
- const reader = (
460
- /** @type {ReadableStream<Uint8Array>} */
461
- source.getReader()
462
- );
463
- const chunks = [];
464
- let totalLength = 0;
465
- while (true) {
466
- const { done, value } = await reader.read();
467
- if (done) break;
468
- chunks.push(value);
469
- totalLength += value.byteLength;
470
- }
471
- const result = new Uint8Array(totalLength);
472
- let offset = 0;
473
- for (const chunk of chunks) {
474
- result.set(chunk, offset);
475
- offset += chunk.byteLength;
476
- }
477
- return result;
478
- }
479
- async function hashData(data) {
480
- let c = globalThis.crypto;
481
- if (!c) {
482
- c = (await import("node:crypto")).webcrypto;
483
- }
484
- const buf = await c.subtle.digest("SHA-256", data);
485
- return Array.from(new Uint8Array(buf)).map((b) => b.toString(16).padStart(2, "0")).join("");
486
- }
487
- function sortEntries(entries) {
488
- return [...entries].sort((a, b) => {
489
- if (a.name === VERSION_FILE) return -1;
490
- if (b.name === VERSION_FILE) return 1;
491
- if (a.name === STYLE_FILE) return -1;
492
- if (b.name === STYLE_FILE) return 1;
493
- const foldersA = a.name.split("/");
494
- const foldersB = b.name.split("/");
495
- const aIsFirst = foldersA[0] === FONTS_FOLDER && foldersA[2] === "0-255.pbf.gz";
496
- const bIsFirst = foldersB[0] === FONTS_FOLDER && foldersB[2] === "0-255.pbf.gz";
497
- if (aIsFirst && bIsFirst)
498
- return a.name < b.name ? -1 : a.name > b.name ? 1 : 0;
499
- if (aIsFirst) return -1;
500
- if (bIsFirst) return 1;
501
- if (foldersA[0] === SOURCES_FOLDER && foldersB[0] !== SOURCES_FOLDER)
502
- return -1;
503
- if (foldersB[0] === SOURCES_FOLDER && foldersA[0] !== SOURCES_FOLDER)
504
- return 1;
505
- if (foldersA[0] === SOURCES_FOLDER && foldersB[0] === SOURCES_FOLDER) {
506
- const zoomA = +foldersA[2];
507
- const zoomB = +foldersB[2];
508
- return zoomA - zoomB;
509
- }
510
- return 0;
511
- });
512
- }
513
- export {
514
- SUPPORTED_SOURCE_TYPES,
515
- Writer
516
- };