chiitiler 1.22.1 → 1.22.3

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
@@ -60,6 +60,7 @@ You're done. That same endpoint works as an XYZ tile source for Leaflet, MapLibr
60
60
  - **[PLATEAU VIEW](https://plateauview.mlit.go.jp/)** — Cesium.js imagery via `/tiles`
61
61
  - **[qgis-amazonlocationservice-plugin](https://github.com/dayjournal/qgis-amazonlocationservice-plugin)** — QGIS integration
62
62
  - **[Allmaps Latest](https://bsky.app/profile/latest.allmaps.org)** — Bluesky bot
63
+ - **[Kumoy](https://www.kumoy.io/)** - used for thumbnail image of designed maps
63
64
 
64
65
  ## HTTP API
65
66
 
@@ -1,4 +1,4 @@
1
- import sharp from 'sharp';
1
+ import { type Sharp } from 'sharp';
2
2
  import type { StyleSpecification } from '@maplibre/maplibre-gl-style-spec';
3
3
  import type { Cache } from '../cache/index.js';
4
4
  type GetRenderedTileOptions = {
@@ -13,7 +13,7 @@ type GetRenderedTileOptions = {
13
13
  quality: number;
14
14
  };
15
15
  type SupportedFormat = 'png' | 'jpeg' | 'jpg' | 'webp';
16
- declare function getRenderedTile({ stylejson, z, x, y, tileSize, cache, margin, ext, quality, }: GetRenderedTileOptions): Promise<sharp.Sharp>;
16
+ declare function getRenderedTile({ stylejson, z, x, y, tileSize, cache, margin, ext, quality, }: GetRenderedTileOptions): Promise<Sharp>;
17
17
  type GetRenderedClipOptions = {
18
18
  stylejson: string | StyleSpecification;
19
19
  bbox: [number, number, number, number];
@@ -22,7 +22,7 @@ type GetRenderedClipOptions = {
22
22
  ext: SupportedFormat;
23
23
  quality: number;
24
24
  };
25
- declare function getRenderedClip({ stylejson, bbox, size, cache, ext, quality, }: GetRenderedClipOptions): Promise<sharp.Sharp>;
25
+ declare function getRenderedClip({ stylejson, bbox, size, cache, ext, quality, }: GetRenderedClipOptions): Promise<Sharp>;
26
26
  type GetRenderedCameraOptions = {
27
27
  stylejson: string | StyleSpecification;
28
28
  cache: Cache;
@@ -35,5 +35,5 @@ type GetRenderedCameraOptions = {
35
35
  height: number;
36
36
  width: number;
37
37
  };
38
- declare function getRenderedCamera(options: GetRenderedCameraOptions): Promise<sharp.Sharp>;
38
+ declare function getRenderedCamera(options: GetRenderedCameraOptions): Promise<Sharp>;
39
39
  export { getRenderedTile, getRenderedClip, getRenderedCamera, type GetRenderedClipOptions, type GetRenderedTileOptions, type GetRenderedCameraOptions, type SupportedFormat, };
@@ -1,2 +1,2 @@
1
- declare function getFilesystemSource(uri: string): Promise<Buffer<ArrayBufferLike> | null>;
1
+ declare function getFilesystemSource(uri: string): Promise<Buffer | null>;
2
2
  export { getFilesystemSource };
package/dist/source/fs.js CHANGED
@@ -1,15 +1,25 @@
1
- import fs from 'fs';
2
- function getFilesystemSource(uri) {
3
- return new Promise((resolve, _) => {
4
- fs.readFile(uri.replace('file://', ''), (err, data) => {
5
- if (err) {
6
- console.error(`[ERROR]: ${err}`);
7
- resolve(null);
8
- }
9
- else {
10
- resolve(data);
11
- }
12
- });
13
- });
1
+ import fs from 'node:fs/promises';
2
+ async function getFilesystemSource(uri) {
3
+ const path = uri.replace('file://', '');
4
+ const data = await fs.readFile(path).catch(() => null);
5
+ if (data !== null)
6
+ return data;
7
+ // maplibre-gl-native percent-encodes {fontstack} in glyphs URLs
8
+ // (e.g. "Noto Sans Regular" -> "Noto%20Sans%20Regular"),
9
+ // so retry with the percent-decoded path
10
+ let decodedPath;
11
+ try {
12
+ decodedPath = decodeURIComponent(path);
13
+ }
14
+ catch {
15
+ decodedPath = path;
16
+ }
17
+ if (decodedPath !== path) {
18
+ const decodedData = await fs.readFile(decodedPath).catch(() => null);
19
+ if (decodedData !== null)
20
+ return decodedData;
21
+ }
22
+ console.error(`[ERROR]: failed to read ${path}`);
23
+ return null;
14
24
  }
15
25
  export { getFilesystemSource };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "chiitiler",
4
- "version": "1.22.1",
4
+ "version": "1.22.3",
5
5
  "description": "Tiny map rendering server for MapLibre Style Spec",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
@@ -50,6 +50,6 @@
50
50
  "lru-cache": "^11.3.5",
51
51
  "maplibre-gl": "^5.23.0",
52
52
  "pmtiles": "^4.4.1",
53
- "sharp": "^0.34.5"
53
+ "sharp": "^0.35.3"
54
54
  }
55
55
  }