styled-map-package 4.0.1 → 5.0.0-pre.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 (85) hide show
  1. package/bin/smp-download.js +10 -6
  2. package/bin/smp-mbtiles.js +5 -7
  3. package/bin/smp-view.js +34 -26
  4. package/lib/reporters.js +92 -0
  5. package/package.json +8 -187
  6. package/LICENSE.md +0 -7
  7. package/README.md +0 -28
  8. package/dist/download.cjs +0 -101
  9. package/dist/download.d.cts +0 -65
  10. package/dist/download.d.ts +0 -65
  11. package/dist/download.js +0 -77
  12. package/dist/from-mbtiles.cjs +0 -91
  13. package/dist/from-mbtiles.d.cts +0 -17
  14. package/dist/from-mbtiles.d.ts +0 -17
  15. package/dist/from-mbtiles.js +0 -57
  16. package/dist/index.cjs +0 -49
  17. package/dist/index.d.cts +0 -27
  18. package/dist/index.d.ts +0 -27
  19. package/dist/index.js +0 -18
  20. package/dist/reader-watch.cjs +0 -135
  21. package/dist/reader-watch.d.cts +0 -24
  22. package/dist/reader-watch.d.ts +0 -24
  23. package/dist/reader-watch.js +0 -101
  24. package/dist/reader.cjs +0 -167
  25. package/dist/reader.d.cts +0 -62
  26. package/dist/reader.d.ts +0 -62
  27. package/dist/reader.js +0 -138
  28. package/dist/reporters.cjs +0 -122
  29. package/dist/reporters.d.cts +0 -10
  30. package/dist/reporters.d.ts +0 -10
  31. package/dist/reporters.js +0 -88
  32. package/dist/server.cjs +0 -78
  33. package/dist/server.d.cts +0 -48
  34. package/dist/server.d.ts +0 -48
  35. package/dist/server.js +0 -54
  36. package/dist/style-downloader.cjs +0 -312
  37. package/dist/style-downloader.d.cts +0 -120
  38. package/dist/style-downloader.d.ts +0 -120
  39. package/dist/style-downloader.js +0 -288
  40. package/dist/tile-downloader.cjs +0 -158
  41. package/dist/tile-downloader.d.cts +0 -84
  42. package/dist/tile-downloader.d.ts +0 -84
  43. package/dist/tile-downloader.js +0 -126
  44. package/dist/types-B4Xn1F9K.d.cts +0 -189
  45. package/dist/types-B4Xn1F9K.d.ts +0 -189
  46. package/dist/utils/errors.cjs +0 -41
  47. package/dist/utils/errors.d.cts +0 -18
  48. package/dist/utils/errors.d.ts +0 -18
  49. package/dist/utils/errors.js +0 -16
  50. package/dist/utils/fetch.cjs +0 -96
  51. package/dist/utils/fetch.d.cts +0 -51
  52. package/dist/utils/fetch.d.ts +0 -51
  53. package/dist/utils/fetch.js +0 -62
  54. package/dist/utils/file-formats.cjs +0 -98
  55. package/dist/utils/file-formats.d.cts +0 -35
  56. package/dist/utils/file-formats.d.ts +0 -35
  57. package/dist/utils/file-formats.js +0 -62
  58. package/dist/utils/geo.cjs +0 -84
  59. package/dist/utils/geo.d.cts +0 -46
  60. package/dist/utils/geo.d.ts +0 -46
  61. package/dist/utils/geo.js +0 -56
  62. package/dist/utils/mapbox.cjs +0 -121
  63. package/dist/utils/mapbox.d.cts +0 -43
  64. package/dist/utils/mapbox.d.ts +0 -43
  65. package/dist/utils/mapbox.js +0 -91
  66. package/dist/utils/misc.cjs +0 -39
  67. package/dist/utils/misc.d.cts +0 -22
  68. package/dist/utils/misc.d.ts +0 -22
  69. package/dist/utils/misc.js +0 -13
  70. package/dist/utils/streams.cjs +0 -130
  71. package/dist/utils/streams.d.cts +0 -73
  72. package/dist/utils/streams.d.ts +0 -73
  73. package/dist/utils/streams.js +0 -103
  74. package/dist/utils/style.cjs +0 -126
  75. package/dist/utils/style.d.cts +0 -69
  76. package/dist/utils/style.d.ts +0 -69
  77. package/dist/utils/style.js +0 -98
  78. package/dist/utils/templates.cjs +0 -114
  79. package/dist/utils/templates.d.cts +0 -78
  80. package/dist/utils/templates.d.ts +0 -78
  81. package/dist/utils/templates.js +0 -79
  82. package/dist/writer.cjs +0 -401
  83. package/dist/writer.d.cts +0 -7
  84. package/dist/writer.d.ts +0 -7
  85. package/dist/writer.js +0 -374
@@ -1,114 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var templates_exports = {};
20
- __export(templates_exports, {
21
- GLYPH_URI: () => GLYPH_URI,
22
- STYLE_FILE: () => STYLE_FILE,
23
- URI_BASE: () => URI_BASE,
24
- URI_SCHEME: () => URI_SCHEME,
25
- getContentType: () => getContentType,
26
- getGlyphFilename: () => getGlyphFilename,
27
- getResourceType: () => getResourceType,
28
- getSpriteFilename: () => getSpriteFilename,
29
- getSpriteUri: () => getSpriteUri,
30
- getTileFilename: () => getTileFilename,
31
- getTileUri: () => getTileUri,
32
- replaceVariables: () => replaceVariables
33
- });
34
- module.exports = __toCommonJS(templates_exports);
35
- const URI_SCHEME = "smp";
36
- const URI_BASE = URI_SCHEME + "://maps.v1/";
37
- const STYLE_FILE = "style.json";
38
- const SOURCES_FOLDER = "s";
39
- const SPRITES_FOLDER = "sprites";
40
- const FONTS_FOLDER = "fonts";
41
- const TILE_FILE = SOURCES_FOLDER + "/{sourceId}/{z}/{x}/{y}{ext}";
42
- const SPRITE_FILE = SPRITES_FOLDER + "/{id}/sprite{pixelRatio}{ext}";
43
- const GLYPH_FILE = FONTS_FOLDER + "/{fontstack}/{range}.pbf.gz";
44
- const GLYPH_URI = URI_BASE + GLYPH_FILE;
45
- const pathToResouceType = (
46
- /** @type {const} */
47
- {
48
- [TILE_FILE.split("/")[0] + "/"]: "tile",
49
- [SPRITE_FILE.split("/")[0] + "/"]: "sprite",
50
- [GLYPH_FILE.split("/")[0] + "/"]: "glyph"
51
- }
52
- );
53
- function getResourceType(path) {
54
- if (path === "style.json") return "style";
55
- for (const [prefix, type] of Object.entries(pathToResouceType)) {
56
- if (path.startsWith(prefix)) return type;
57
- }
58
- throw new Error(`Unknown resource type for path: ${path}`);
59
- }
60
- function getContentType(path) {
61
- if (path.endsWith(".json")) return "application/json; charset=utf-8";
62
- if (path.endsWith(".pbf.gz") || path.endsWith(".pbf"))
63
- return "application/x-protobuf";
64
- if (path.endsWith(".png")) return "image/png";
65
- if (path.endsWith(".jpg")) return "image/jpeg";
66
- if (path.endsWith(".webp")) return "image/webp";
67
- if (path.endsWith(".mvt.gz") || path.endsWith(".mvt"))
68
- return "application/vnd.mapbox-vector-tile";
69
- throw new Error(`Unknown content type for path: ${path}`);
70
- }
71
- function getTileFilename({ sourceId, z, x, y, format }) {
72
- const ext = "." + format + (format === "mvt" ? ".gz" : "");
73
- return replaceVariables(TILE_FILE, { sourceId, z, x, y, ext });
74
- }
75
- function getSpriteFilename({ id, pixelRatio, ext }) {
76
- return replaceVariables(SPRITE_FILE, {
77
- id,
78
- pixelRatio: getPixelRatioString(pixelRatio),
79
- ext
80
- });
81
- }
82
- function getGlyphFilename({ fontstack, range }) {
83
- return replaceVariables(GLYPH_FILE, { fontstack, range });
84
- }
85
- function getSpriteUri(id = "default") {
86
- return URI_BASE + replaceVariables(SPRITE_FILE, { id, pixelRatio: "", ext: "" });
87
- }
88
- function getTileUri({ sourceId, format }) {
89
- const ext = "." + format + (format === "mvt" ? ".gz" : "");
90
- return URI_BASE + TILE_FILE.replace("{sourceId}", sourceId).replace("{ext}", ext);
91
- }
92
- function getPixelRatioString(pixelRatio) {
93
- return pixelRatio === 1 ? "" : `@${pixelRatio}x`;
94
- }
95
- function replaceVariables(template, variables) {
96
- return template.replace(/{(.*?)}/g, (match, varName) => {
97
- return varName in variables ? String(variables[varName]) : match;
98
- });
99
- }
100
- // Annotate the CommonJS export names for ESM import in node:
101
- 0 && (module.exports = {
102
- GLYPH_URI,
103
- STYLE_FILE,
104
- URI_BASE,
105
- URI_SCHEME,
106
- getContentType,
107
- getGlyphFilename,
108
- getResourceType,
109
- getSpriteFilename,
110
- getSpriteUri,
111
- getTileFilename,
112
- getTileUri,
113
- replaceVariables
114
- });
@@ -1,78 +0,0 @@
1
- import * as type_fest from 'type-fest';
2
- import { T as TileInfo, d as GlyphRange, c as TileFormat } from '../types-B4Xn1F9K.cjs';
3
- import '@maplibre/maplibre-gl-style-spec';
4
- import 'geojson';
5
- import 'stream';
6
- import 'readable-stream';
7
- import 'events';
8
-
9
- /**
10
- * @param {string} path
11
- * @returns
12
- */
13
- declare function getResourceType(path: string): "sprite" | "style" | "tile" | "glyph";
14
- /**
15
- * Determine the content type of a file based on its extension.
16
- *
17
- * @param {string} path
18
- */
19
- declare function getContentType(path: string): "application/json; charset=utf-8" | "application/x-protobuf" | "image/png" | "image/jpeg" | "image/webp" | "application/vnd.mapbox-vector-tile";
20
- /**
21
- * Get the filename for a tile, given the TileInfo
22
- *
23
- * @param {import("type-fest").SetRequired<import("../writer.js").TileInfo, 'format'>} tileInfo
24
- * @returns
25
- */
26
- declare function getTileFilename({ sourceId, z, x, y, format }: type_fest.SetRequired<TileInfo, "format">): string;
27
- /**
28
- * Get a filename for a sprite file, given the sprite id, pixel ratio and extension
29
- *
30
- * @param {{ id: string, pixelRatio: number, ext: '.json' | '.png'}} spriteInfo
31
- */
32
- declare function getSpriteFilename({ id, pixelRatio, ext }: {
33
- id: string;
34
- pixelRatio: number;
35
- ext: ".json" | ".png";
36
- }): string;
37
- /**
38
- * Get the filename for a glyph file, given the fontstack and range
39
- *
40
- * @param {object} options
41
- * @param {string} options.fontstack
42
- * @param {import("../writer.js").GlyphRange} options.range
43
- */
44
- declare function getGlyphFilename({ fontstack, range }: {
45
- fontstack: string;
46
- range: GlyphRange;
47
- }): string;
48
- /**
49
- * Get the URI template for the sprites in the style
50
- */
51
- declare function getSpriteUri(id?: string): string;
52
- /**
53
- * Get the URI template for tiles in the style
54
- *
55
- * @param {object} opts
56
- * @param {string} opts.sourceId
57
- * @param {import("../writer.js").TileFormat} opts.format
58
- * @returns
59
- */
60
- declare function getTileUri({ sourceId, format }: {
61
- sourceId: string;
62
- format: TileFormat;
63
- }): string;
64
- /**
65
- * Replaces variables in a string with values provided in an object. Variables
66
- * in the string are denoted by curly braces, e.g., {variableName}.
67
- *
68
- * @param {string} template - The string containing variables wrapped in curly braces.
69
- * @param {Record<string, string | number>} variables - An object where the keys correspond to variable names and values correspond to the replacement values.
70
- * @returns {string} The string with the variables replaced by their corresponding values.
71
- */
72
- declare function replaceVariables(template: string, variables: Record<string, string | number>): string;
73
- declare const URI_SCHEME: "smp";
74
- declare const URI_BASE: string;
75
- declare const STYLE_FILE: "style.json";
76
- declare const GLYPH_URI: string;
77
-
78
- export { GLYPH_URI, STYLE_FILE, URI_BASE, URI_SCHEME, getContentType, getGlyphFilename, getResourceType, getSpriteFilename, getSpriteUri, getTileFilename, getTileUri, replaceVariables };
@@ -1,78 +0,0 @@
1
- import * as type_fest from 'type-fest';
2
- import { T as TileInfo, d as GlyphRange, c as TileFormat } from '../types-B4Xn1F9K.js';
3
- import '@maplibre/maplibre-gl-style-spec';
4
- import 'geojson';
5
- import 'stream';
6
- import 'readable-stream';
7
- import 'events';
8
-
9
- /**
10
- * @param {string} path
11
- * @returns
12
- */
13
- declare function getResourceType(path: string): "sprite" | "style" | "tile" | "glyph";
14
- /**
15
- * Determine the content type of a file based on its extension.
16
- *
17
- * @param {string} path
18
- */
19
- declare function getContentType(path: string): "application/json; charset=utf-8" | "application/x-protobuf" | "image/png" | "image/jpeg" | "image/webp" | "application/vnd.mapbox-vector-tile";
20
- /**
21
- * Get the filename for a tile, given the TileInfo
22
- *
23
- * @param {import("type-fest").SetRequired<import("../writer.js").TileInfo, 'format'>} tileInfo
24
- * @returns
25
- */
26
- declare function getTileFilename({ sourceId, z, x, y, format }: type_fest.SetRequired<TileInfo, "format">): string;
27
- /**
28
- * Get a filename for a sprite file, given the sprite id, pixel ratio and extension
29
- *
30
- * @param {{ id: string, pixelRatio: number, ext: '.json' | '.png'}} spriteInfo
31
- */
32
- declare function getSpriteFilename({ id, pixelRatio, ext }: {
33
- id: string;
34
- pixelRatio: number;
35
- ext: ".json" | ".png";
36
- }): string;
37
- /**
38
- * Get the filename for a glyph file, given the fontstack and range
39
- *
40
- * @param {object} options
41
- * @param {string} options.fontstack
42
- * @param {import("../writer.js").GlyphRange} options.range
43
- */
44
- declare function getGlyphFilename({ fontstack, range }: {
45
- fontstack: string;
46
- range: GlyphRange;
47
- }): string;
48
- /**
49
- * Get the URI template for the sprites in the style
50
- */
51
- declare function getSpriteUri(id?: string): string;
52
- /**
53
- * Get the URI template for tiles in the style
54
- *
55
- * @param {object} opts
56
- * @param {string} opts.sourceId
57
- * @param {import("../writer.js").TileFormat} opts.format
58
- * @returns
59
- */
60
- declare function getTileUri({ sourceId, format }: {
61
- sourceId: string;
62
- format: TileFormat;
63
- }): string;
64
- /**
65
- * Replaces variables in a string with values provided in an object. Variables
66
- * in the string are denoted by curly braces, e.g., {variableName}.
67
- *
68
- * @param {string} template - The string containing variables wrapped in curly braces.
69
- * @param {Record<string, string | number>} variables - An object where the keys correspond to variable names and values correspond to the replacement values.
70
- * @returns {string} The string with the variables replaced by their corresponding values.
71
- */
72
- declare function replaceVariables(template: string, variables: Record<string, string | number>): string;
73
- declare const URI_SCHEME: "smp";
74
- declare const URI_BASE: string;
75
- declare const STYLE_FILE: "style.json";
76
- declare const GLYPH_URI: string;
77
-
78
- export { GLYPH_URI, STYLE_FILE, URI_BASE, URI_SCHEME, getContentType, getGlyphFilename, getResourceType, getSpriteFilename, getSpriteUri, getTileFilename, getTileUri, replaceVariables };
@@ -1,79 +0,0 @@
1
- const URI_SCHEME = "smp";
2
- const URI_BASE = URI_SCHEME + "://maps.v1/";
3
- const STYLE_FILE = "style.json";
4
- const SOURCES_FOLDER = "s";
5
- const SPRITES_FOLDER = "sprites";
6
- const FONTS_FOLDER = "fonts";
7
- const TILE_FILE = SOURCES_FOLDER + "/{sourceId}/{z}/{x}/{y}{ext}";
8
- const SPRITE_FILE = SPRITES_FOLDER + "/{id}/sprite{pixelRatio}{ext}";
9
- const GLYPH_FILE = FONTS_FOLDER + "/{fontstack}/{range}.pbf.gz";
10
- const GLYPH_URI = URI_BASE + GLYPH_FILE;
11
- const pathToResouceType = (
12
- /** @type {const} */
13
- {
14
- [TILE_FILE.split("/")[0] + "/"]: "tile",
15
- [SPRITE_FILE.split("/")[0] + "/"]: "sprite",
16
- [GLYPH_FILE.split("/")[0] + "/"]: "glyph"
17
- }
18
- );
19
- function getResourceType(path) {
20
- if (path === "style.json") return "style";
21
- for (const [prefix, type] of Object.entries(pathToResouceType)) {
22
- if (path.startsWith(prefix)) return type;
23
- }
24
- throw new Error(`Unknown resource type for path: ${path}`);
25
- }
26
- function getContentType(path) {
27
- if (path.endsWith(".json")) return "application/json; charset=utf-8";
28
- if (path.endsWith(".pbf.gz") || path.endsWith(".pbf"))
29
- return "application/x-protobuf";
30
- if (path.endsWith(".png")) return "image/png";
31
- if (path.endsWith(".jpg")) return "image/jpeg";
32
- if (path.endsWith(".webp")) return "image/webp";
33
- if (path.endsWith(".mvt.gz") || path.endsWith(".mvt"))
34
- return "application/vnd.mapbox-vector-tile";
35
- throw new Error(`Unknown content type for path: ${path}`);
36
- }
37
- function getTileFilename({ sourceId, z, x, y, format }) {
38
- const ext = "." + format + (format === "mvt" ? ".gz" : "");
39
- return replaceVariables(TILE_FILE, { sourceId, z, x, y, ext });
40
- }
41
- function getSpriteFilename({ id, pixelRatio, ext }) {
42
- return replaceVariables(SPRITE_FILE, {
43
- id,
44
- pixelRatio: getPixelRatioString(pixelRatio),
45
- ext
46
- });
47
- }
48
- function getGlyphFilename({ fontstack, range }) {
49
- return replaceVariables(GLYPH_FILE, { fontstack, range });
50
- }
51
- function getSpriteUri(id = "default") {
52
- return URI_BASE + replaceVariables(SPRITE_FILE, { id, pixelRatio: "", ext: "" });
53
- }
54
- function getTileUri({ sourceId, format }) {
55
- const ext = "." + format + (format === "mvt" ? ".gz" : "");
56
- return URI_BASE + TILE_FILE.replace("{sourceId}", sourceId).replace("{ext}", ext);
57
- }
58
- function getPixelRatioString(pixelRatio) {
59
- return pixelRatio === 1 ? "" : `@${pixelRatio}x`;
60
- }
61
- function replaceVariables(template, variables) {
62
- return template.replace(/{(.*?)}/g, (match, varName) => {
63
- return varName in variables ? String(variables[varName]) : match;
64
- });
65
- }
66
- export {
67
- GLYPH_URI,
68
- STYLE_FILE,
69
- URI_BASE,
70
- URI_SCHEME,
71
- getContentType,
72
- getGlyphFilename,
73
- getResourceType,
74
- getSpriteFilename,
75
- getSpriteUri,
76
- getTileFilename,
77
- getTileUri,
78
- replaceVariables
79
- };