styled-map-package-api 5.0.0-pre.2 → 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.
- package/README.md +94 -0
- package/dist/download.d.ts +11 -21
- package/dist/fallbacks.d.ts +32 -0
- package/dist/from-mbtiles.d.ts +1 -3
- package/dist/index.d.ts +11 -24
- package/dist/reader.d.ts +28 -12
- package/dist/server.d.ts +23 -14
- package/dist/style-downloader.d.ts +13 -19
- package/dist/tile-downloader.d.ts +13 -23
- package/dist/types.d.ts +61 -0
- package/dist/utils/errors.d.ts +2 -4
- package/dist/utils/fetch.d.ts +3 -8
- package/dist/utils/file-formats.d.ts +3 -10
- package/dist/utils/geo.d.ts +17 -9
- package/dist/utils/mapbox.d.ts +8 -10
- package/dist/utils/misc.d.ts +3 -5
- package/dist/utils/streams.d.ts +6 -10
- package/dist/utils/style.d.ts +27 -16
- package/dist/utils/templates.d.ts +30 -25
- package/dist/validator.d.ts +66 -0
- package/dist/writer.d.ts +157 -4
- package/lib/download.js +125 -0
- package/lib/fallbacks.js +157 -0
- package/lib/from-mbtiles.js +131 -0
- package/lib/index.js +12 -0
- package/lib/reader.js +360 -0
- package/lib/server.js +222 -0
- package/lib/style-downloader.js +369 -0
- package/lib/tile-downloader.js +189 -0
- package/lib/types.ts +99 -0
- package/lib/utils/errors.js +24 -0
- package/lib/utils/fetch.js +104 -0
- package/lib/utils/file-formats.js +92 -0
- package/lib/utils/geo.js +97 -0
- package/lib/utils/mapbox.js +155 -0
- package/{dist/utils/misc.d.cts → lib/utils/misc.js} +9 -5
- package/lib/utils/streams.js +101 -0
- package/lib/utils/style.js +206 -0
- package/lib/utils/templates.js +165 -0
- package/lib/validator.js +789 -0
- package/lib/writer.js +652 -0
- package/package.json +30 -78
- package/dist/download.cjs +0 -100
- package/dist/download.d.cts +0 -63
- package/dist/download.js +0 -76
- package/dist/from-mbtiles.cjs +0 -108
- package/dist/from-mbtiles.d.cts +0 -14
- package/dist/from-mbtiles.js +0 -84
- package/dist/index.cjs +0 -46
- package/dist/index.d.cts +0 -24
- package/dist/index.js +0 -16
- package/dist/reader.cjs +0 -287
- package/dist/reader.d.cts +0 -67
- package/dist/reader.js +0 -259
- package/dist/server.cjs +0 -73
- package/dist/server.d.cts +0 -45
- package/dist/server.js +0 -49
- package/dist/style-downloader.cjs +0 -314
- package/dist/style-downloader.d.cts +0 -118
- package/dist/style-downloader.js +0 -290
- package/dist/tile-downloader.cjs +0 -156
- package/dist/tile-downloader.d.cts +0 -82
- package/dist/tile-downloader.js +0 -124
- package/dist/types-qfyJk4ot.d.cts +0 -200
- package/dist/types-qfyJk4ot.d.ts +0 -200
- package/dist/utils/errors.cjs +0 -41
- package/dist/utils/errors.d.cts +0 -18
- package/dist/utils/errors.js +0 -16
- package/dist/utils/fetch.cjs +0 -97
- package/dist/utils/fetch.d.cts +0 -50
- package/dist/utils/fetch.js +0 -63
- package/dist/utils/file-formats.cjs +0 -96
- package/dist/utils/file-formats.d.cts +0 -32
- package/dist/utils/file-formats.js +0 -70
- package/dist/utils/geo.cjs +0 -84
- package/dist/utils/geo.d.cts +0 -46
- package/dist/utils/geo.js +0 -56
- package/dist/utils/mapbox.cjs +0 -121
- package/dist/utils/mapbox.d.cts +0 -43
- package/dist/utils/mapbox.js +0 -91
- package/dist/utils/misc.cjs +0 -39
- package/dist/utils/misc.js +0 -13
- package/dist/utils/streams.cjs +0 -99
- package/dist/utils/streams.d.cts +0 -49
- package/dist/utils/streams.js +0 -73
- package/dist/utils/style.cjs +0 -126
- package/dist/utils/style.d.cts +0 -66
- package/dist/utils/style.js +0 -98
- package/dist/utils/templates.cjs +0 -124
- package/dist/utils/templates.d.cts +0 -79
- package/dist/utils/templates.js +0 -85
- package/dist/writer.cjs +0 -539
- package/dist/writer.d.cts +0 -4
- package/dist/writer.js +0 -516
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
import { StyleSpecification, SourceSpecification, GeoJSONSourceSpecification, VectorSourceSpecification, RasterSourceSpecification, RasterDEMSourceSpecification } from '@maplibre/maplibre-gl-style-spec';
|
|
2
|
-
import { GeoJSON, BBox } from 'geojson';
|
|
3
|
-
import { SetRequired } from 'type-fest';
|
|
4
|
-
|
|
5
|
-
/** @typedef {string | Uint8Array | ReadableStream } Source */
|
|
6
|
-
/** @typedef {`${number}-${number}`} GlyphRange */
|
|
7
|
-
/** @typedef {'png' | 'mvt' | 'jpg' | 'webp'} TileFormat */
|
|
8
|
-
/**
|
|
9
|
-
* @typedef {object} SourceInfo
|
|
10
|
-
* @property {import('./types.js').SMPSource} source
|
|
11
|
-
* @property {string} encodedSourceId
|
|
12
|
-
* @property {TileFormat} [format]
|
|
13
|
-
*/
|
|
14
|
-
/**
|
|
15
|
-
* @typedef {object} TileInfo
|
|
16
|
-
* @property {number} z
|
|
17
|
-
* @property {number} x
|
|
18
|
-
* @property {number} y
|
|
19
|
-
* @property {string} sourceId
|
|
20
|
-
* @property {TileFormat} [format]
|
|
21
|
-
*/
|
|
22
|
-
/**
|
|
23
|
-
* @typedef {object} GlyphInfo
|
|
24
|
-
* @property {string} font
|
|
25
|
-
* @property {GlyphRange} range
|
|
26
|
-
*/
|
|
27
|
-
/** @import { StyleSpecification } from '@maplibre/maplibre-gl-style-spec' */
|
|
28
|
-
/** @import { InputSource, SMPSource } from './types.js' */
|
|
29
|
-
declare const SUPPORTED_SOURCE_TYPES: readonly ["raster", "vector", "geojson"];
|
|
30
|
-
/**
|
|
31
|
-
* @typedef {object} WriterOptions
|
|
32
|
-
* @property {boolean} [dedupe] When true, duplicate tiles (with identical
|
|
33
|
-
* content) are stored only once in the archive. Additional entries in the
|
|
34
|
-
* central directory point to the same data. This reduces file size for
|
|
35
|
-
* tilesets with many repeated tiles (e.g. ocean tiles).
|
|
36
|
-
*/
|
|
37
|
-
/**
|
|
38
|
-
* Write a styled map package to a stream. Stream `writer.outputStream` to a
|
|
39
|
-
* destination, e.g. `fs.createWriteStream('my-map.styledmap')`. You must call
|
|
40
|
-
* `witer.finish()` and then wait for your writable stream to `finish` before
|
|
41
|
-
* using the output.
|
|
42
|
-
*/
|
|
43
|
-
declare class Writer {
|
|
44
|
-
static SUPPORTED_SOURCE_TYPES: readonly ["raster", "vector", "geojson"];
|
|
45
|
-
/**
|
|
46
|
-
* @param {any} style A v7 or v8 MapLibre style. v7 styles will be migrated to
|
|
47
|
-
* v8. (There are currently no typescript declarations for v7 styles, hence
|
|
48
|
-
* this is typed as `any` and validated internally)
|
|
49
|
-
* @param {WriterOptions} [options]
|
|
50
|
-
*/
|
|
51
|
-
constructor(style: any, { dedupe }?: WriterOptions);
|
|
52
|
-
/**
|
|
53
|
-
* @returns {ReadableStream<Uint8Array>} Readable stream of the styled map package
|
|
54
|
-
*/
|
|
55
|
-
get outputStream(): ReadableStream<Uint8Array>;
|
|
56
|
-
/**
|
|
57
|
-
* Abort the output stream with an error. Call this if an error occurs during
|
|
58
|
-
* writing to propagate the error to consumers of `outputStream`.
|
|
59
|
-
*
|
|
60
|
-
* @param {Error} reason
|
|
61
|
-
*/
|
|
62
|
-
abort(reason: Error): void;
|
|
63
|
-
/**
|
|
64
|
-
* Add a tile to the styled map package
|
|
65
|
-
*
|
|
66
|
-
* @param {Source} tileData
|
|
67
|
-
* @param {TileInfo} opts
|
|
68
|
-
*/
|
|
69
|
-
addTile(tileData: Source, { z, x, y, sourceId, format }: TileInfo): Promise<void>;
|
|
70
|
-
/**
|
|
71
|
-
* Create a write stream for adding tiles to the styled map package
|
|
72
|
-
*
|
|
73
|
-
* @param {object} opts
|
|
74
|
-
* @param {number} [opts.concurrency=16] The number of concurrent writes
|
|
75
|
-
*
|
|
76
|
-
* @returns
|
|
77
|
-
*/
|
|
78
|
-
createTileWriteStream({ concurrency }?: {
|
|
79
|
-
concurrency?: number | undefined;
|
|
80
|
-
}): WritableStream<any>;
|
|
81
|
-
/**
|
|
82
|
-
* Add a sprite to the styled map package
|
|
83
|
-
*
|
|
84
|
-
* @param {object} options
|
|
85
|
-
* @param {Source} options.json
|
|
86
|
-
* @param {Source} options.png
|
|
87
|
-
* @param {number} [options.pixelRatio]
|
|
88
|
-
* @param {string} [options.id='default']
|
|
89
|
-
* @returns {Promise<void>}
|
|
90
|
-
*/
|
|
91
|
-
addSprite({ json, png, pixelRatio, id }: {
|
|
92
|
-
json: Source;
|
|
93
|
-
png: Source;
|
|
94
|
-
pixelRatio?: number | undefined;
|
|
95
|
-
id?: string | undefined;
|
|
96
|
-
}): Promise<void>;
|
|
97
|
-
/**
|
|
98
|
-
* Add glyphs to the styled map package
|
|
99
|
-
*
|
|
100
|
-
* @param {Source} glyphData
|
|
101
|
-
* @param {GlyphInfo} glyphInfo
|
|
102
|
-
* @returns {Promise<void>}
|
|
103
|
-
*/
|
|
104
|
-
addGlyphs(glyphData: Source, { font: fontName, range }: GlyphInfo): Promise<void>;
|
|
105
|
-
/**
|
|
106
|
-
* Create a write stream for adding glyphs to the styled map package
|
|
107
|
-
*
|
|
108
|
-
* @param {object} opts
|
|
109
|
-
* @param {number} [opts.concurrency=16] The number of concurrent writes
|
|
110
|
-
* @returns
|
|
111
|
-
*/
|
|
112
|
-
createGlyphWriteStream({ concurrency }?: {
|
|
113
|
-
concurrency?: number | undefined;
|
|
114
|
-
}): WritableStream<any>;
|
|
115
|
-
/**
|
|
116
|
-
* Finalize the styled map package and write the style to the archive.
|
|
117
|
-
* This method must be called to complete the archive.
|
|
118
|
-
* You must wait for your destination write stream to 'finish' before using the output.
|
|
119
|
-
*/
|
|
120
|
-
finish(): Promise<void>;
|
|
121
|
-
#private;
|
|
122
|
-
}
|
|
123
|
-
type Source = string | Uint8Array | ReadableStream;
|
|
124
|
-
type GlyphRange = `${number}-${number}`;
|
|
125
|
-
type TileFormat = "png" | "mvt" | "jpg" | "webp";
|
|
126
|
-
type SourceInfo = {
|
|
127
|
-
source: SMPSource;
|
|
128
|
-
encodedSourceId: string;
|
|
129
|
-
format?: TileFormat | undefined;
|
|
130
|
-
};
|
|
131
|
-
type TileInfo = {
|
|
132
|
-
z: number;
|
|
133
|
-
x: number;
|
|
134
|
-
y: number;
|
|
135
|
-
sourceId: string;
|
|
136
|
-
format?: TileFormat | undefined;
|
|
137
|
-
};
|
|
138
|
-
type GlyphInfo = {
|
|
139
|
-
font: string;
|
|
140
|
-
range: GlyphRange;
|
|
141
|
-
};
|
|
142
|
-
type WriterOptions = {
|
|
143
|
-
/**
|
|
144
|
-
* When true, duplicate tiles (with identical
|
|
145
|
-
* content) are stored only once in the archive. Additional entries in the
|
|
146
|
-
* central directory point to the same data. This reduces file size for
|
|
147
|
-
* tilesets with many repeated tiles (e.g. ocean tiles).
|
|
148
|
-
*/
|
|
149
|
-
dedupe?: boolean | undefined;
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
type TransformInlinedSource<T extends SourceSpecification> = T extends GeoJSONSourceSpecification ? OmitUnion<T, 'data'> & {
|
|
153
|
-
data: GeoJSON;
|
|
154
|
-
} : T extends VectorSourceSpecification | RasterSourceSpecification | RasterDEMSourceSpecification ? SetRequired<OmitUnion<T, 'url'>, 'tiles'> : T;
|
|
155
|
-
/**
|
|
156
|
-
* This is a slightly stricter version of SourceSpecification that requires
|
|
157
|
-
* sources to be inlined (e.g. no urls to TileJSON or GeoJSON files).
|
|
158
|
-
*/
|
|
159
|
-
type InlinedSource = TransformInlinedSource<SourceSpecification>;
|
|
160
|
-
type SupportedInlinedSource = Extract<InlinedSource, {
|
|
161
|
-
type: (typeof SUPPORTED_SOURCE_TYPES)[number];
|
|
162
|
-
}>;
|
|
163
|
-
/**
|
|
164
|
-
* This is a slightly stricter version of StyleSpecification that requires
|
|
165
|
-
* sources to be inlined (e.g. no urls to TileJSON or GeoJSON files).
|
|
166
|
-
*/
|
|
167
|
-
type StyleInlinedSources = Omit<StyleSpecification, 'sources'> & {
|
|
168
|
-
sources: {
|
|
169
|
-
[_: string]: InlinedSource;
|
|
170
|
-
};
|
|
171
|
-
};
|
|
172
|
-
type SMPSource = TransformSMPInputSource<SupportedInlinedSource>;
|
|
173
|
-
/**
|
|
174
|
-
* This is a slightly stricter version of StyleSpecification that is provided in
|
|
175
|
-
* a Styled Map Package. Tile sources must have tile URLs inlined (they cannot
|
|
176
|
-
* refer to a TileJSON url), and they must have bounds, minzoom, and maxzoom.
|
|
177
|
-
* GeoJSON sources must have inlined GeoJSON (not a URL to a GeoJSON file).
|
|
178
|
-
*/
|
|
179
|
-
type SMPStyle = TransformSMPStyle<StyleSpecification>;
|
|
180
|
-
type TransformSMPInputSource<T extends SupportedInlinedSource> = T extends GeoJSONSourceSpecification ? T & {
|
|
181
|
-
data: {
|
|
182
|
-
bbox: BBox;
|
|
183
|
-
};
|
|
184
|
-
} : T extends RasterSourceSpecification | VectorSourceSpecification ? SetRequired<T, 'bounds' | 'minzoom' | 'maxzoom'> : T;
|
|
185
|
-
type TransformSMPStyle<T extends StyleSpecification> = Omit<T, 'sources'> & {
|
|
186
|
-
metadata: {
|
|
187
|
-
'smp:bounds': [number, number, number, number];
|
|
188
|
-
'smp:maxzoom': 0;
|
|
189
|
-
'smp:sourceFolders': {
|
|
190
|
-
[_: string]: string;
|
|
191
|
-
};
|
|
192
|
-
};
|
|
193
|
-
sources: {
|
|
194
|
-
[_: string]: SMPSource;
|
|
195
|
-
};
|
|
196
|
-
};
|
|
197
|
-
type DownloadStream = ReadableStream<Uint8Array>;
|
|
198
|
-
type OmitUnion<T, K extends keyof any> = T extends unknown ? Omit<T, K> : never;
|
|
199
|
-
|
|
200
|
-
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 SourceInfo as g, type WriterOptions as h };
|
package/dist/types-qfyJk4ot.d.ts
DELETED
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
import { StyleSpecification, SourceSpecification, GeoJSONSourceSpecification, VectorSourceSpecification, RasterSourceSpecification, RasterDEMSourceSpecification } from '@maplibre/maplibre-gl-style-spec';
|
|
2
|
-
import { GeoJSON, BBox } from 'geojson';
|
|
3
|
-
import { SetRequired } from 'type-fest';
|
|
4
|
-
|
|
5
|
-
/** @typedef {string | Uint8Array | ReadableStream } Source */
|
|
6
|
-
/** @typedef {`${number}-${number}`} GlyphRange */
|
|
7
|
-
/** @typedef {'png' | 'mvt' | 'jpg' | 'webp'} TileFormat */
|
|
8
|
-
/**
|
|
9
|
-
* @typedef {object} SourceInfo
|
|
10
|
-
* @property {import('./types.js').SMPSource} source
|
|
11
|
-
* @property {string} encodedSourceId
|
|
12
|
-
* @property {TileFormat} [format]
|
|
13
|
-
*/
|
|
14
|
-
/**
|
|
15
|
-
* @typedef {object} TileInfo
|
|
16
|
-
* @property {number} z
|
|
17
|
-
* @property {number} x
|
|
18
|
-
* @property {number} y
|
|
19
|
-
* @property {string} sourceId
|
|
20
|
-
* @property {TileFormat} [format]
|
|
21
|
-
*/
|
|
22
|
-
/**
|
|
23
|
-
* @typedef {object} GlyphInfo
|
|
24
|
-
* @property {string} font
|
|
25
|
-
* @property {GlyphRange} range
|
|
26
|
-
*/
|
|
27
|
-
/** @import { StyleSpecification } from '@maplibre/maplibre-gl-style-spec' */
|
|
28
|
-
/** @import { InputSource, SMPSource } from './types.js' */
|
|
29
|
-
declare const SUPPORTED_SOURCE_TYPES: readonly ["raster", "vector", "geojson"];
|
|
30
|
-
/**
|
|
31
|
-
* @typedef {object} WriterOptions
|
|
32
|
-
* @property {boolean} [dedupe] When true, duplicate tiles (with identical
|
|
33
|
-
* content) are stored only once in the archive. Additional entries in the
|
|
34
|
-
* central directory point to the same data. This reduces file size for
|
|
35
|
-
* tilesets with many repeated tiles (e.g. ocean tiles).
|
|
36
|
-
*/
|
|
37
|
-
/**
|
|
38
|
-
* Write a styled map package to a stream. Stream `writer.outputStream` to a
|
|
39
|
-
* destination, e.g. `fs.createWriteStream('my-map.styledmap')`. You must call
|
|
40
|
-
* `witer.finish()` and then wait for your writable stream to `finish` before
|
|
41
|
-
* using the output.
|
|
42
|
-
*/
|
|
43
|
-
declare class Writer {
|
|
44
|
-
static SUPPORTED_SOURCE_TYPES: readonly ["raster", "vector", "geojson"];
|
|
45
|
-
/**
|
|
46
|
-
* @param {any} style A v7 or v8 MapLibre style. v7 styles will be migrated to
|
|
47
|
-
* v8. (There are currently no typescript declarations for v7 styles, hence
|
|
48
|
-
* this is typed as `any` and validated internally)
|
|
49
|
-
* @param {WriterOptions} [options]
|
|
50
|
-
*/
|
|
51
|
-
constructor(style: any, { dedupe }?: WriterOptions);
|
|
52
|
-
/**
|
|
53
|
-
* @returns {ReadableStream<Uint8Array>} Readable stream of the styled map package
|
|
54
|
-
*/
|
|
55
|
-
get outputStream(): ReadableStream<Uint8Array>;
|
|
56
|
-
/**
|
|
57
|
-
* Abort the output stream with an error. Call this if an error occurs during
|
|
58
|
-
* writing to propagate the error to consumers of `outputStream`.
|
|
59
|
-
*
|
|
60
|
-
* @param {Error} reason
|
|
61
|
-
*/
|
|
62
|
-
abort(reason: Error): void;
|
|
63
|
-
/**
|
|
64
|
-
* Add a tile to the styled map package
|
|
65
|
-
*
|
|
66
|
-
* @param {Source} tileData
|
|
67
|
-
* @param {TileInfo} opts
|
|
68
|
-
*/
|
|
69
|
-
addTile(tileData: Source, { z, x, y, sourceId, format }: TileInfo): Promise<void>;
|
|
70
|
-
/**
|
|
71
|
-
* Create a write stream for adding tiles to the styled map package
|
|
72
|
-
*
|
|
73
|
-
* @param {object} opts
|
|
74
|
-
* @param {number} [opts.concurrency=16] The number of concurrent writes
|
|
75
|
-
*
|
|
76
|
-
* @returns
|
|
77
|
-
*/
|
|
78
|
-
createTileWriteStream({ concurrency }?: {
|
|
79
|
-
concurrency?: number | undefined;
|
|
80
|
-
}): WritableStream<any>;
|
|
81
|
-
/**
|
|
82
|
-
* Add a sprite to the styled map package
|
|
83
|
-
*
|
|
84
|
-
* @param {object} options
|
|
85
|
-
* @param {Source} options.json
|
|
86
|
-
* @param {Source} options.png
|
|
87
|
-
* @param {number} [options.pixelRatio]
|
|
88
|
-
* @param {string} [options.id='default']
|
|
89
|
-
* @returns {Promise<void>}
|
|
90
|
-
*/
|
|
91
|
-
addSprite({ json, png, pixelRatio, id }: {
|
|
92
|
-
json: Source;
|
|
93
|
-
png: Source;
|
|
94
|
-
pixelRatio?: number | undefined;
|
|
95
|
-
id?: string | undefined;
|
|
96
|
-
}): Promise<void>;
|
|
97
|
-
/**
|
|
98
|
-
* Add glyphs to the styled map package
|
|
99
|
-
*
|
|
100
|
-
* @param {Source} glyphData
|
|
101
|
-
* @param {GlyphInfo} glyphInfo
|
|
102
|
-
* @returns {Promise<void>}
|
|
103
|
-
*/
|
|
104
|
-
addGlyphs(glyphData: Source, { font: fontName, range }: GlyphInfo): Promise<void>;
|
|
105
|
-
/**
|
|
106
|
-
* Create a write stream for adding glyphs to the styled map package
|
|
107
|
-
*
|
|
108
|
-
* @param {object} opts
|
|
109
|
-
* @param {number} [opts.concurrency=16] The number of concurrent writes
|
|
110
|
-
* @returns
|
|
111
|
-
*/
|
|
112
|
-
createGlyphWriteStream({ concurrency }?: {
|
|
113
|
-
concurrency?: number | undefined;
|
|
114
|
-
}): WritableStream<any>;
|
|
115
|
-
/**
|
|
116
|
-
* Finalize the styled map package and write the style to the archive.
|
|
117
|
-
* This method must be called to complete the archive.
|
|
118
|
-
* You must wait for your destination write stream to 'finish' before using the output.
|
|
119
|
-
*/
|
|
120
|
-
finish(): Promise<void>;
|
|
121
|
-
#private;
|
|
122
|
-
}
|
|
123
|
-
type Source = string | Uint8Array | ReadableStream;
|
|
124
|
-
type GlyphRange = `${number}-${number}`;
|
|
125
|
-
type TileFormat = "png" | "mvt" | "jpg" | "webp";
|
|
126
|
-
type SourceInfo = {
|
|
127
|
-
source: SMPSource;
|
|
128
|
-
encodedSourceId: string;
|
|
129
|
-
format?: TileFormat | undefined;
|
|
130
|
-
};
|
|
131
|
-
type TileInfo = {
|
|
132
|
-
z: number;
|
|
133
|
-
x: number;
|
|
134
|
-
y: number;
|
|
135
|
-
sourceId: string;
|
|
136
|
-
format?: TileFormat | undefined;
|
|
137
|
-
};
|
|
138
|
-
type GlyphInfo = {
|
|
139
|
-
font: string;
|
|
140
|
-
range: GlyphRange;
|
|
141
|
-
};
|
|
142
|
-
type WriterOptions = {
|
|
143
|
-
/**
|
|
144
|
-
* When true, duplicate tiles (with identical
|
|
145
|
-
* content) are stored only once in the archive. Additional entries in the
|
|
146
|
-
* central directory point to the same data. This reduces file size for
|
|
147
|
-
* tilesets with many repeated tiles (e.g. ocean tiles).
|
|
148
|
-
*/
|
|
149
|
-
dedupe?: boolean | undefined;
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
type TransformInlinedSource<T extends SourceSpecification> = T extends GeoJSONSourceSpecification ? OmitUnion<T, 'data'> & {
|
|
153
|
-
data: GeoJSON;
|
|
154
|
-
} : T extends VectorSourceSpecification | RasterSourceSpecification | RasterDEMSourceSpecification ? SetRequired<OmitUnion<T, 'url'>, 'tiles'> : T;
|
|
155
|
-
/**
|
|
156
|
-
* This is a slightly stricter version of SourceSpecification that requires
|
|
157
|
-
* sources to be inlined (e.g. no urls to TileJSON or GeoJSON files).
|
|
158
|
-
*/
|
|
159
|
-
type InlinedSource = TransformInlinedSource<SourceSpecification>;
|
|
160
|
-
type SupportedInlinedSource = Extract<InlinedSource, {
|
|
161
|
-
type: (typeof SUPPORTED_SOURCE_TYPES)[number];
|
|
162
|
-
}>;
|
|
163
|
-
/**
|
|
164
|
-
* This is a slightly stricter version of StyleSpecification that requires
|
|
165
|
-
* sources to be inlined (e.g. no urls to TileJSON or GeoJSON files).
|
|
166
|
-
*/
|
|
167
|
-
type StyleInlinedSources = Omit<StyleSpecification, 'sources'> & {
|
|
168
|
-
sources: {
|
|
169
|
-
[_: string]: InlinedSource;
|
|
170
|
-
};
|
|
171
|
-
};
|
|
172
|
-
type SMPSource = TransformSMPInputSource<SupportedInlinedSource>;
|
|
173
|
-
/**
|
|
174
|
-
* This is a slightly stricter version of StyleSpecification that is provided in
|
|
175
|
-
* a Styled Map Package. Tile sources must have tile URLs inlined (they cannot
|
|
176
|
-
* refer to a TileJSON url), and they must have bounds, minzoom, and maxzoom.
|
|
177
|
-
* GeoJSON sources must have inlined GeoJSON (not a URL to a GeoJSON file).
|
|
178
|
-
*/
|
|
179
|
-
type SMPStyle = TransformSMPStyle<StyleSpecification>;
|
|
180
|
-
type TransformSMPInputSource<T extends SupportedInlinedSource> = T extends GeoJSONSourceSpecification ? T & {
|
|
181
|
-
data: {
|
|
182
|
-
bbox: BBox;
|
|
183
|
-
};
|
|
184
|
-
} : T extends RasterSourceSpecification | VectorSourceSpecification ? SetRequired<T, 'bounds' | 'minzoom' | 'maxzoom'> : T;
|
|
185
|
-
type TransformSMPStyle<T extends StyleSpecification> = Omit<T, 'sources'> & {
|
|
186
|
-
metadata: {
|
|
187
|
-
'smp:bounds': [number, number, number, number];
|
|
188
|
-
'smp:maxzoom': 0;
|
|
189
|
-
'smp:sourceFolders': {
|
|
190
|
-
[_: string]: string;
|
|
191
|
-
};
|
|
192
|
-
};
|
|
193
|
-
sources: {
|
|
194
|
-
[_: string]: SMPSource;
|
|
195
|
-
};
|
|
196
|
-
};
|
|
197
|
-
type DownloadStream = ReadableStream<Uint8Array>;
|
|
198
|
-
type OmitUnion<T, K extends keyof any> = T extends unknown ? Omit<T, K> : never;
|
|
199
|
-
|
|
200
|
-
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 SourceInfo as g, type WriterOptions as h };
|
package/dist/utils/errors.cjs
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var errors_exports = {};
|
|
20
|
-
__export(errors_exports, {
|
|
21
|
-
ENOENT: () => ENOENT,
|
|
22
|
-
isFileNotThereError: () => isFileNotThereError
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(errors_exports);
|
|
25
|
-
class ENOENT extends Error {
|
|
26
|
-
code = "ENOENT";
|
|
27
|
-
/** @param {string} path */
|
|
28
|
-
constructor(path) {
|
|
29
|
-
const message = `ENOENT: no such file or directory, open '${path}'`;
|
|
30
|
-
super(message);
|
|
31
|
-
this.path = path;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
function isFileNotThereError(error) {
|
|
35
|
-
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "EPERM");
|
|
36
|
-
}
|
|
37
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
-
0 && (module.exports = {
|
|
39
|
-
ENOENT,
|
|
40
|
-
isFileNotThereError
|
|
41
|
-
});
|
package/dist/utils/errors.d.cts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns true if the error if because a file is not found. On Windows, some
|
|
3
|
-
* operations like fs.watch() throw an EPERM error rather than ENOENT.
|
|
4
|
-
*
|
|
5
|
-
* @param {unknown} error
|
|
6
|
-
* @returns {error is Error & { code: 'ENOENT' | 'EPERM' }}
|
|
7
|
-
*/
|
|
8
|
-
declare function isFileNotThereError(error: unknown): error is Error & {
|
|
9
|
-
code: "ENOENT" | "EPERM";
|
|
10
|
-
};
|
|
11
|
-
declare class ENOENT extends Error {
|
|
12
|
-
/** @param {string} path */
|
|
13
|
-
constructor(path: string);
|
|
14
|
-
code: string;
|
|
15
|
-
path: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export { ENOENT, isFileNotThereError };
|
package/dist/utils/errors.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
class ENOENT extends Error {
|
|
2
|
-
code = "ENOENT";
|
|
3
|
-
/** @param {string} path */
|
|
4
|
-
constructor(path) {
|
|
5
|
-
const message = `ENOENT: no such file or directory, open '${path}'`;
|
|
6
|
-
super(message);
|
|
7
|
-
this.path = path;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
function isFileNotThereError(error) {
|
|
11
|
-
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "EPERM");
|
|
12
|
-
}
|
|
13
|
-
export {
|
|
14
|
-
ENOENT,
|
|
15
|
-
isFileNotThereError
|
|
16
|
-
};
|
package/dist/utils/fetch.cjs
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var fetch_exports = {};
|
|
30
|
-
__export(fetch_exports, {
|
|
31
|
-
FetchQueue: () => FetchQueue
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(fetch_exports);
|
|
34
|
-
var import_ky = __toESM(require("ky"), 1);
|
|
35
|
-
var import_p_limit = __toESM(require("p-limit"), 1);
|
|
36
|
-
var import_streams = require('./streams.cjs');
|
|
37
|
-
class FetchQueue {
|
|
38
|
-
/** @type {import('p-limit').LimitFunction} */
|
|
39
|
-
#limit;
|
|
40
|
-
/** @param {number} concurrency */
|
|
41
|
-
constructor(concurrency) {
|
|
42
|
-
this.#limit = (0, import_p_limit.default)(concurrency);
|
|
43
|
-
}
|
|
44
|
-
get activeCount() {
|
|
45
|
-
return this.#limit.activeCount;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Fetch a URL, limiting the number of concurrent downloads. Resolves with a
|
|
49
|
-
* `DownloadResponse`, which is a parsed from the Fetch `Response` objects,
|
|
50
|
-
* with `body` as a web ReadableStream, and the MIME type and content length
|
|
51
|
-
* of the response.
|
|
52
|
-
*
|
|
53
|
-
* NB: The response body stream must be consumed to the end, otherwise the
|
|
54
|
-
* queue will never be emptied.
|
|
55
|
-
*
|
|
56
|
-
* @param {string} url
|
|
57
|
-
* @param {{ onprogress?: import('./streams.js').ProgressCallback }} opts
|
|
58
|
-
* @returns {Promise<DownloadResponse>}
|
|
59
|
-
*/
|
|
60
|
-
fetch(url, { onprogress } = {}) {
|
|
61
|
-
return new Promise((resolveResponse, rejectResponse) => {
|
|
62
|
-
this.#limit(fetchStream, {
|
|
63
|
-
url,
|
|
64
|
-
onresponse: resolveResponse,
|
|
65
|
-
onerror: rejectResponse,
|
|
66
|
-
onprogress
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
async function fetchStream({ url, onresponse, onerror, onprogress }) {
|
|
72
|
-
try {
|
|
73
|
-
const response = await (0, import_ky.default)(url, { retry: 3 });
|
|
74
|
-
if (!response.body) {
|
|
75
|
-
throw new Error("No body in response");
|
|
76
|
-
}
|
|
77
|
-
const contentType = response.headers.get("content-type");
|
|
78
|
-
const mimeType = typeof contentType === "string" ? contentType.split(";")[0] : null;
|
|
79
|
-
const contentLengthHeader = response.headers.get("content-length");
|
|
80
|
-
const contentLength = contentLengthHeader === null ? null : parseInt(contentLengthHeader, 10);
|
|
81
|
-
const passthrough = new TransformStream();
|
|
82
|
-
const pipePromise = response.body.pipeTo(passthrough.writable);
|
|
83
|
-
let body = passthrough.readable;
|
|
84
|
-
if (onprogress) {
|
|
85
|
-
const progress = new import_streams.ProgressStream({ onprogress });
|
|
86
|
-
body = body.pipeThrough(progress);
|
|
87
|
-
}
|
|
88
|
-
onresponse({ body, mimeType, contentLength });
|
|
89
|
-
await pipePromise;
|
|
90
|
-
} catch (err) {
|
|
91
|
-
onerror(err instanceof Error ? err : new Error("Unknown error"));
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
95
|
-
0 && (module.exports = {
|
|
96
|
-
FetchQueue
|
|
97
|
-
});
|
package/dist/utils/fetch.d.cts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { ProgressCallback } from './streams.cjs';
|
|
2
|
-
import 'stream/web';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @typedef {object} DownloadResponse
|
|
6
|
-
* @property {ReadableStream<Uint8Array>} body Web ReadableStream of the response body
|
|
7
|
-
* @property {string | null} mimeType Content mime-type (from http content-type header)
|
|
8
|
-
* @property {number | null} contentLength Content length in bytes (from http content-length header)
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* A wrapper for fetch that limits the number of concurrent downloads.
|
|
12
|
-
*/
|
|
13
|
-
declare class FetchQueue {
|
|
14
|
-
/** @param {number} concurrency */
|
|
15
|
-
constructor(concurrency: number);
|
|
16
|
-
get activeCount(): number;
|
|
17
|
-
/**
|
|
18
|
-
* Fetch a URL, limiting the number of concurrent downloads. Resolves with a
|
|
19
|
-
* `DownloadResponse`, which is a parsed from the Fetch `Response` objects,
|
|
20
|
-
* with `body` as a web ReadableStream, and the MIME type and content length
|
|
21
|
-
* of the response.
|
|
22
|
-
*
|
|
23
|
-
* NB: The response body stream must be consumed to the end, otherwise the
|
|
24
|
-
* queue will never be emptied.
|
|
25
|
-
*
|
|
26
|
-
* @param {string} url
|
|
27
|
-
* @param {{ onprogress?: import('./streams.js').ProgressCallback }} opts
|
|
28
|
-
* @returns {Promise<DownloadResponse>}
|
|
29
|
-
*/
|
|
30
|
-
fetch(url: string, { onprogress }?: {
|
|
31
|
-
onprogress?: ProgressCallback;
|
|
32
|
-
}): Promise<DownloadResponse>;
|
|
33
|
-
#private;
|
|
34
|
-
}
|
|
35
|
-
type DownloadResponse = {
|
|
36
|
-
/**
|
|
37
|
-
* Web ReadableStream of the response body
|
|
38
|
-
*/
|
|
39
|
-
body: ReadableStream<Uint8Array>;
|
|
40
|
-
/**
|
|
41
|
-
* Content mime-type (from http content-type header)
|
|
42
|
-
*/
|
|
43
|
-
mimeType: string | null;
|
|
44
|
-
/**
|
|
45
|
-
* Content length in bytes (from http content-length header)
|
|
46
|
-
*/
|
|
47
|
-
contentLength: number | null;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export { type DownloadResponse, FetchQueue };
|
package/dist/utils/fetch.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import ky from "ky";
|
|
2
|
-
import pLimit from "p-limit";
|
|
3
|
-
import { ProgressStream } from "./streams.js";
|
|
4
|
-
class FetchQueue {
|
|
5
|
-
/** @type {import('p-limit').LimitFunction} */
|
|
6
|
-
#limit;
|
|
7
|
-
/** @param {number} concurrency */
|
|
8
|
-
constructor(concurrency) {
|
|
9
|
-
this.#limit = pLimit(concurrency);
|
|
10
|
-
}
|
|
11
|
-
get activeCount() {
|
|
12
|
-
return this.#limit.activeCount;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Fetch a URL, limiting the number of concurrent downloads. Resolves with a
|
|
16
|
-
* `DownloadResponse`, which is a parsed from the Fetch `Response` objects,
|
|
17
|
-
* with `body` as a web ReadableStream, and the MIME type and content length
|
|
18
|
-
* of the response.
|
|
19
|
-
*
|
|
20
|
-
* NB: The response body stream must be consumed to the end, otherwise the
|
|
21
|
-
* queue will never be emptied.
|
|
22
|
-
*
|
|
23
|
-
* @param {string} url
|
|
24
|
-
* @param {{ onprogress?: import('./streams.js').ProgressCallback }} opts
|
|
25
|
-
* @returns {Promise<DownloadResponse>}
|
|
26
|
-
*/
|
|
27
|
-
fetch(url, { onprogress } = {}) {
|
|
28
|
-
return new Promise((resolveResponse, rejectResponse) => {
|
|
29
|
-
this.#limit(fetchStream, {
|
|
30
|
-
url,
|
|
31
|
-
onresponse: resolveResponse,
|
|
32
|
-
onerror: rejectResponse,
|
|
33
|
-
onprogress
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
async function fetchStream({ url, onresponse, onerror, onprogress }) {
|
|
39
|
-
try {
|
|
40
|
-
const response = await ky(url, { retry: 3 });
|
|
41
|
-
if (!response.body) {
|
|
42
|
-
throw new Error("No body in response");
|
|
43
|
-
}
|
|
44
|
-
const contentType = response.headers.get("content-type");
|
|
45
|
-
const mimeType = typeof contentType === "string" ? contentType.split(";")[0] : null;
|
|
46
|
-
const contentLengthHeader = response.headers.get("content-length");
|
|
47
|
-
const contentLength = contentLengthHeader === null ? null : parseInt(contentLengthHeader, 10);
|
|
48
|
-
const passthrough = new TransformStream();
|
|
49
|
-
const pipePromise = response.body.pipeTo(passthrough.writable);
|
|
50
|
-
let body = passthrough.readable;
|
|
51
|
-
if (onprogress) {
|
|
52
|
-
const progress = new ProgressStream({ onprogress });
|
|
53
|
-
body = body.pipeThrough(progress);
|
|
54
|
-
}
|
|
55
|
-
onresponse({ body, mimeType, contentLength });
|
|
56
|
-
await pipePromise;
|
|
57
|
-
} catch (err) {
|
|
58
|
-
onerror(err instanceof Error ? err : new Error("Unknown error"));
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
export {
|
|
62
|
-
FetchQueue
|
|
63
|
-
};
|