styled-map-package 5.0.0-pre.4 → 5.0.0-pre.5

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 CHANGED
@@ -25,17 +25,23 @@ smp download https://demotiles.maplibre.org/style.json \
25
25
 
26
26
  **Options:**
27
27
 
28
- | Option | Description |
29
- | ---------------------- | ----------------------------------------------------------------- |
30
- | `-o, --output <file>` | Output file (writes to stdout if omitted) |
31
- | `-b, --bbox <w,s,e,n>` | Bounding box (west, south, east, north) |
32
- | `-z, --zoom <number>` | Max zoom level (0-22) |
33
- | `-t, --token <token>` | Mapbox access token (required for Mapbox styles) |
34
- | `-d, --dedupe` | Deduplicate tiles with identical content to reduce file size |
35
- | `--skip-local-glyphs` | Skip CJK/Hangul/Kana glyph ranges rendered locally by MapLibre GL |
28
+ | Option | Description |
29
+ | ---------------------- | ---------------------------------------------------------------------- |
30
+ | `-o, --output <file>` | Output file (writes to stdout if omitted) |
31
+ | `-b, --bbox <w,s,e,n>` | Bounding box (west, south, east, north) |
32
+ | `-z, --zoom <number>` | Max zoom level (0-22) |
33
+ | `-t, --token <token>` | Mapbox access token (required for Mapbox styles) |
34
+ | `-d, --dedupe` | Deduplicate tiles with identical content to reduce file size |
35
+ | `--skip-local-glyphs` | Skip CJK/Hangul/Kana glyph ranges rendered locally by MapLibre GL |
36
+ | `--buffer-tiles` | Download an extra tile ring around the bbox at each zoom below maxzoom |
36
37
 
37
38
  When run interactively, missing options are prompted for.
38
39
 
40
+ The `--buffer-tiles` flag downloads one extra tile ring around the bbox at every
41
+ zoom level below maxzoom, so the map is not clipped at the edges of the
42
+ downloaded area when zooming out. The buffer is not added at maxzoom. `smp view`
43
+ automatically renders these buffer tiles.
44
+
39
45
  ### `smp view`
40
46
 
41
47
  Preview a `.smp` file in a web browser.
@@ -46,13 +52,15 @@ smp view demotiles.smp --open
46
52
 
47
53
  **Options:**
48
54
 
49
- | Option | Description |
50
- | --------------------- | ----------------------------------------------------------------- |
51
- | `-o, --open` | Open in the default web browser |
52
- | `-p, --port <number>` | Port to serve on (default: 3000) |
53
- | `-f, --fallback` | Serve empty tiles and glyphs for missing resources instead of 404 |
55
+ | Option | Description |
56
+ | --------------------- | -------------------------------------------------------------------------- |
57
+ | `-o, --open` | Open in the default web browser |
58
+ | `-p, --port <number>` | Port to serve on (default: 3000) |
59
+ | `--no-fallback` | Return 404 for missing tiles and glyphs instead of serving empty fallbacks |
60
+
61
+ By default the viewer serves empty tiles and Noto Sans glyphs for any resource not present in the file, so incomplete packages (those covering a partial area or zoom range) preview without 404 errors. Missing vector tiles are served as empty MVTs, missing raster tiles as transparent pixels. Missing glyph ranges are served using bundled [Noto Sans](https://fonts.google.com/noto/specimen/Noto+Sans) glyphs (via [GoNotoKurrent](https://github.com/satbyy/go-noto-universal), covering 80+ scripts including Latin, Cyrillic, Greek, Arabic, Hebrew, Devanagari, Thai, and more). CJK and Hangul ranges are not bundled since MapLibre renders these client-side via `localIdeographFontFamily`. Pass `--no-fallback` to return 404s instead.
54
62
 
55
- The `--fallback` flag is useful for previewing SMP files that don't contain every tile or glyph range referenced by the style. Missing vector tiles are served as empty MVTs, missing raster tiles as transparent pixels. Missing glyph ranges are served using bundled [Noto Sans](https://fonts.google.com/noto/specimen/Noto+Sans) glyphs (via [GoNotoKurrent](https://github.com/satbyy/go-noto-universal), covering 80+ scripts including Latin, Cyrillic, Greek, Arabic, Hebrew, Devanagari, Thai, and more). CJK and Hangul ranges are not bundled since MapLibre renders these client-side via `localIdeographFontFamily`.
63
+ For packages downloaded with buffer tiles (recorded as `smp:bufferTiles` in the style metadata), the viewer also widens each source's `bounds` so the lower-zoom buffer tiles that extend beyond the data area are rendered rather than clipped. Combined with the empty-tile fallback, panning beyond the downloaded area shows blank tiles instead of console errors.
56
64
 
57
65
  ### `smp mbtiles`
58
66
 
@@ -41,14 +41,27 @@ program
41
41
  '-d, --dedupe',
42
42
  'deduplicate tiles with identical content to reduce file size',
43
43
  )
44
+ .option(
45
+ '--buffer-tiles',
46
+ 'download an extra tile ring around the bbox at each zoom level below maxzoom, so the map is not clipped at the edges when zooming out',
47
+ )
44
48
  .argument('[styleUrl]', 'URL to style to download', parseUrl)
45
49
  .action(
46
50
  async (
47
51
  styleUrl,
48
- { bbox, zoom, output, token, skipLocalGlyphs, dedupe },
52
+ { bbox, zoom, output, token, skipLocalGlyphs, dedupe, bufferTiles },
49
53
  ) => {
50
54
  await runDownload(
51
- { styleUrl, bbox, zoom, output, token, skipLocalGlyphs, dedupe },
55
+ {
56
+ styleUrl,
57
+ bbox,
58
+ zoom,
59
+ output,
60
+ token,
61
+ skipLocalGlyphs,
62
+ dedupe,
63
+ bufferTiles,
64
+ },
52
65
  {
53
66
  download,
54
67
  prompt: { input, number },
package/bin/smp-view.js CHANGED
@@ -20,8 +20,8 @@ program
20
20
  .option('-o, --open', 'open in the default web browser')
21
21
  .option('-p, --port <number>', 'port to serve on', (v) => parseInt(v), 3000)
22
22
  .option(
23
- '-f, --fallback',
24
- 'serve empty tiles and glyphs for missing resources instead of 404',
23
+ '--no-fallback',
24
+ 'return 404 for missing tiles and glyphs instead of serving empty fallbacks',
25
25
  )
26
26
  .argument('<file>', 'file to serve')
27
27
  .action(async (filepath, { open, port, fallback }) => {
@@ -59,6 +59,7 @@ export function parseUrl(url) {
59
59
  * @property {string | undefined} token
60
60
  * @property {boolean | undefined} skipLocalGlyphs
61
61
  * @property {boolean | undefined} dedupe
62
+ * @property {boolean | undefined} bufferTiles When set, download one extra tile ring around the bbox at each zoom level below maxzoom.
62
63
  */
63
64
 
64
65
  /**
@@ -77,7 +78,7 @@ export function parseUrl(url) {
77
78
  * @param {DownloadDeps} deps
78
79
  */
79
80
  export async function runDownload(
80
- { styleUrl, bbox, zoom, output, token, skipLocalGlyphs, dedupe },
81
+ { styleUrl, bbox, zoom, output, token, skipLocalGlyphs, dedupe, bufferTiles },
81
82
  deps,
82
83
  ) {
83
84
  const { download, prompt, isMapboxURL, mapboxApiUrl, isTTY } = deps
@@ -178,9 +179,11 @@ export async function runDownload(
178
179
  maxzoom: zoom,
179
180
  styleUrl,
180
181
  onprogress: (/** @type {any} */ p) => reporter.write(p),
181
- accessToken: token,
182
+ mapboxAccessToken: token,
182
183
  skipLocalGlyphs,
183
184
  dedupe,
185
+ // `--buffer-tiles` is a boolean flag on the CLI; map it to a one-tile ring.
186
+ bufferTiles: bufferTiles ? 1 : 0,
184
187
  })
185
188
  const outputStream = deps.createOutputStream(output)
186
189
  await readStream.pipeTo(
@@ -3,7 +3,7 @@
3
3
  * @property {number} port
4
4
  * @property {string} filepath
5
5
  * @property {boolean} [open]
6
- * @property {boolean} [fallback]
6
+ * @property {boolean} [fallback] Serve empty tiles and fallback glyphs for missing resources. Defaults to `true`; pass `false` to return 404s instead.
7
7
  */
8
8
 
9
9
  /**
@@ -26,13 +26,19 @@
26
26
  export async function runView({ port, filepath, open, fallback }, deps) {
27
27
  const { Reader, createServer, openApp, log, readViewerHtml } = deps
28
28
 
29
+ // Fallback is on by default; pass `fallback: false` to disable it. Pass the
30
+ // handlers explicitly (null to disable) rather than relying on the server's
31
+ // own defaults, since the CLI uses Noto glyphs rather than empty ones.
32
+ const useFallback = fallback !== false
33
+
29
34
  const reader = new Reader(filepath)
30
35
  const smpServer = createServer({
31
36
  base: '/map',
32
- ...(fallback && {
33
- fallbackTile: deps.emptyTileFallback,
34
- fallbackGlyph: deps.emptyGlyphFallback,
35
- }),
37
+ // Render buffer tiles that lie outside the data bounds for packages written
38
+ // with `smp:bufferTiles`. No-op for packages without that metadata.
39
+ expandBounds: true,
40
+ fallbackTile: useFallback ? deps.emptyTileFallback : null,
41
+ fallbackGlyph: useFallback ? deps.emptyGlyphFallback : null,
36
42
  })
37
43
 
38
44
  /** @param {Request} request */
@@ -32,6 +32,7 @@
32
32
  const map = new maplibregl.Map({
33
33
  container: 'map',
34
34
  style: 'map/style.json',
35
+ attributionControl: { compact: true },
35
36
  })
36
37
 
37
38
  map.on('error', (e) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "styled-map-package",
3
- "version": "5.0.0-pre.4",
3
+ "version": "5.0.0-pre.5",
4
4
  "description": "CLI for creating, viewing, and converting Styled Map Package (.smp) files",
5
5
  "type": "module",
6
6
  "bin": {
@@ -18,8 +18,8 @@
18
18
  "keywords": [],
19
19
  "license": "MIT",
20
20
  "dependencies": {
21
- "styled-map-package-api": "^5.0.0-pre.4",
22
- "smp-noto-glyphs": "^1.0.0-pre.0",
21
+ "styled-map-package-api": "^5.0.0-pre.5",
22
+ "smp-noto-glyphs": "^1.0.0-pre.1",
23
23
  "@inquirer/prompts": "^6.0.1",
24
24
  "@whatwg-node/server": "^0.10.17",
25
25
  "chalk": "^5.4.1",