chiitiler 1.19.0 → 1.20.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.
package/dist/cli.js CHANGED
@@ -86,20 +86,20 @@ export function createProgram() {
86
86
  program
87
87
  .command('tile-server')
88
88
  .option('-c, --cache <type>', 'cache type', 'none')
89
- .option('-ctl --cache-ttl', 'cache ttl', '3600')
90
- .option('-mci --memory-cache-max-item-count', 'memory cache max item count', '1000')
91
- .option('-fcd --file-cache-dir <dir>', 'file cache directory', './.cache')
92
- .option('-s3r --s3-region <region-name>', 's3 bucket region for get/put', 'us-east-1')
93
- .option('-s3b --s3-cache-bucket <bucket-name>', 's3 cache bucket name', '')
94
- .option('-s3e --s3-endpoint <url>', 's3 endpoint url', '')
95
- .option('-3p --s3-force-path-style', 's3 force path style', '')
96
- .option('-gcsb --gcs-cache-bucket <bucket-name>', 'gcs cache bucket name', '')
97
- .option('-gcsp --gcs-project-id <project-id>', 'gcs project id', '')
98
- .option('-gcsk --gcs-key-filename <key-filename>', 'gcs key filename', '')
99
- .option('-gcsp --gcs-cache-prefix <prefix>', 'gcs cache prefix', '')
100
- .option('-gcse --gcs-api-endpoint <api-endpoint>', 'gcs api endpoint', '')
101
- .option('-p --port <port>', 'port number')
102
- .option('-D --debug', 'debug mode')
89
+ .option('--cache-ttl', 'cache ttl', '3600')
90
+ .option('--memory-cache-max-item-count', 'memory cache max item count', '1000')
91
+ .option('--file-cache-dir <dir>', 'file cache directory', './.cache')
92
+ .option('--s3-region <region-name>', 's3 bucket region for get/put', 'us-east-1')
93
+ .option('--s3-cache-bucket <bucket-name>', 's3 cache bucket name', '')
94
+ .option('--s3-endpoint <url>', 's3 endpoint url', '')
95
+ .option('--s3-force-path-style', 's3 force path style', '')
96
+ .option('--gcs-cache-bucket <bucket-name>', 'gcs cache bucket name', '')
97
+ .option('--gcs-project-id <project-id>', 'gcs project id', '')
98
+ .option('--gcs-key-filename <key-filename>', 'gcs key filename', '')
99
+ .option('--gcs-cache-prefix <prefix>', 'gcs cache prefix', '')
100
+ .option('--gcs-api-endpoint <api-endpoint>', 'gcs api endpoint', '')
101
+ .option('-p, --port <port>', 'port number')
102
+ .option('-D, --debug', 'debug mode')
103
103
  .action((options) => {
104
104
  const serverOptions = {
105
105
  cache: parseCacheStrategy(options.cache, {
@@ -1,6 +1,5 @@
1
1
  import sharp from 'sharp';
2
- // @ts-ignore
3
- import SphericalMercator from '@mapbox/sphericalmercator';
2
+ import { SphericalMercator } from '@mapbox/sphericalmercator';
4
3
  const mercator = new SphericalMercator();
5
4
  import { LRUCache } from 'lru-cache';
6
5
  import { renderTile, render } from './rasterize.js';
@@ -1,5 +1,4 @@
1
- // @ts-ignore
2
- import SphericalMercator from '@mapbox/sphericalmercator';
1
+ import { SphericalMercator } from '@mapbox/sphericalmercator';
3
2
  import { getRenderPool } from './pool.js';
4
3
  function getTileCenter(z, x, y, tileSize = 256) {
5
4
  const mercator = new SphericalMercator({
@@ -1,6 +1,8 @@
1
1
  import { Cache } from '../cache/index.js';
2
2
  /**
3
- * retrieve sources from the uri
3
+ * retrieve sources from the uri.
4
+ * Concurrent requests for the same uri share a single in-flight fetch
5
+ * (single-flight) to avoid duplicate downloads.
4
6
  * @param uri
5
7
  * @param cache {Cache} - Cache Strategy. Affect only for http(s) sources.
6
8
  * @returns
@@ -6,30 +6,40 @@ import { getS3Source } from './s3.js';
6
6
  import { getGCSSource } from './gcs.js';
7
7
  import { getCogSource } from './cog.js';
8
8
  import { noneCache } from '../cache/index.js';
9
+ async function fetchSource(uri, cache) {
10
+ if (uri.startsWith('http://') || uri.startsWith('https://'))
11
+ return getHttpSource(uri, cache);
12
+ if (uri.startsWith('file://'))
13
+ return getFilesystemSource(uri);
14
+ if (uri.startsWith('s3://'))
15
+ return getS3Source(uri);
16
+ if (uri.startsWith('gs://'))
17
+ return getGCSSource(uri);
18
+ if (uri.startsWith('mbtiles://'))
19
+ return getMbtilesSource(uri);
20
+ if (uri.startsWith('pmtiles://'))
21
+ return getPmtilesSource(uri, cache);
22
+ if (uri.startsWith('cog://'))
23
+ return getCogSource(uri);
24
+ return null;
25
+ }
26
+ const inFlight = new Map();
9
27
  /**
10
- * retrieve sources from the uri
28
+ * retrieve sources from the uri.
29
+ * Concurrent requests for the same uri share a single in-flight fetch
30
+ * (single-flight) to avoid duplicate downloads.
11
31
  * @param uri
12
32
  * @param cache {Cache} - Cache Strategy. Affect only for http(s) sources.
13
33
  * @returns
14
34
  */
15
35
  async function getSource(uri, cache = noneCache()) {
16
- let data = null;
17
- if (uri.startsWith('http://') || uri.startsWith('https://'))
18
- data = await getHttpSource(uri, cache);
19
- else if (uri.startsWith('file://'))
20
- data = await getFilesystemSource(uri);
21
- else if (uri.startsWith('s3://'))
22
- data = await getS3Source(uri);
23
- else if (uri.startsWith('gs://'))
24
- data = await getGCSSource(uri);
25
- else if (uri.startsWith('mbtiles://'))
26
- data = await getMbtilesSource(uri);
27
- else if (uri.startsWith('pmtiles://'))
28
- data = await getPmtilesSource(uri, cache);
29
- else if (uri.startsWith('cog://'))
30
- data = await getCogSource(uri);
31
- else
32
- return null;
33
- return data;
36
+ const existing = inFlight.get(uri);
37
+ if (existing !== undefined)
38
+ return existing;
39
+ const promise = fetchSource(uri, cache).finally(() => {
40
+ inFlight.delete(uri);
41
+ });
42
+ inFlight.set(uri, promise);
43
+ return promise;
34
44
  }
35
45
  export { getSource };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "chiitiler",
4
- "version": "1.19.0",
4
+ "version": "1.20.0",
5
5
  "description": "Tiny map rendering server for MapLibre Style Spec",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
@@ -24,33 +24,33 @@
24
24
  "url": "https://github.com/Kanahiro/chiitiler"
25
25
  },
26
26
  "devDependencies": {
27
- "@tsconfig/node24": "^24.0.0",
27
+ "@tsconfig/node24": "^24.0.4",
28
28
  "@types/better-sqlite3": "^7.6.13",
29
- "@types/node": "^24.0.0",
30
- "@vitest/coverage-v8": "^4.0.16",
31
- "esbuild": "^0.27.2",
32
- "image-size": "^1.1.1",
29
+ "@types/node": "^25.6.0",
30
+ "@vitest/coverage-v8": "^4.1.4",
31
+ "esbuild": "^0.28.0",
32
+ "image-size": "^2.0.2",
33
33
  "tsx": "^4.21.0",
34
- "typescript": "^5.9.3",
35
- "vitest": "^4.0.16"
34
+ "typescript": "^6.0.3",
35
+ "vitest": "^4.1.4"
36
36
  },
37
37
  "dependencies": {
38
- "@aws-sdk/client-s3": "^3.418.0",
39
- "@google-cloud/storage": "^7.15.2",
40
- "@hono/node-server": "^1.19.8",
41
- "@mapbox/sphericalmercator": "^1.2.0",
42
- "@mapbox/tilebelt": "^1.0.2",
43
- "@maplibre/maplibre-gl-native": "^6.3.0",
44
- "@maplibre/maplibre-gl-style-spec": "^24.4.1",
45
- "better-sqlite3": "12.6.0",
46
- "commander": "^11.0.0",
47
- "file-system-cache": "^2.4.4",
38
+ "@aws-sdk/client-s3": "^3.1032.0",
39
+ "@google-cloud/storage": "^7.19.0",
40
+ "@hono/node-server": "^1.19.14",
41
+ "@mapbox/sphericalmercator": "^2.0.2",
42
+ "@mapbox/tilebelt": "^2.0.3",
43
+ "@maplibre/maplibre-gl-native": "^6.4.1",
44
+ "@maplibre/maplibre-gl-style-spec": "^24.8.1",
45
+ "better-sqlite3": "12.9.0",
46
+ "commander": "^14.0.3",
47
+ "file-system-cache": "^2.4.7",
48
48
  "higuruma": "^0.1.6",
49
- "hono": "^4.11.3",
50
- "lightning-pool": "^4.2.2",
51
- "lru-cache": "^11.0.0",
52
- "maplibre-gl": "^5.15.0",
53
- "pmtiles": "^3.0.5",
49
+ "hono": "^4.12.14",
50
+ "lightning-pool": "^4.12.0",
51
+ "lru-cache": "^11.3.5",
52
+ "maplibre-gl": "^5.23.0",
53
+ "pmtiles": "^4.4.1",
54
54
  "sharp": "^0.34.5"
55
55
  }
56
56
  }