@loaders.gl/pmtiles 4.3.0-alpha.2 → 4.3.0-alpha.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.
@@ -1 +1 @@
1
- {"version":3,"file":"pmtiles-source.d.ts","sourceRoot":"","sources":["../src/pmtiles-source.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,oBAAoB,CAAC;AAC/C,OAAO,KAAK,EAAC,iBAAiB,EAAE,qBAAqB,EAAC,MAAM,0BAA0B,CAAC;AACvF,OAAO,KAAK,EAAC,SAAS,EAAE,eAAe,EAAC,MAAM,0BAA0B,CAAC;AACzE,OAAO,KAAK,EAAC,eAAe,EAAE,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAC,UAAU,EAAc,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAc,kBAAkB,EAAC,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAY,gBAAgB,EAAE,qBAAqB,EAAC,MAAM,iBAAiB,CAAC;AAEnF,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAGnC,OAAO,KAAK,EAAC,eAAe,EAAC,+BAA4B;AAMzD,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,iBAAiB,CAAC,OAAO,EAAE,YAAY,IAAI,OAAO,GAAG;IAC/D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,YAAY,EAAE,CAAC,KAAK,EAAE,YAAY,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AAC,WAAW,GAAG,IAAI,CAAC;IAcnE,WAAW,CAAC,UAAU,EAAE,qBAAqB,GAAG,OAAO,CAAC,GAAG,CAAC;IAa5D,YAAY,CAAC,UAAU,EAAE,iBAAiB,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;IAOtE,aAAa,CAAC,UAAU,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;CAc5E"}
@@ -9,32 +9,37 @@ const { PMTiles } = pmtiles;
9
9
  import { parsePMTilesHeader } from "./lib/parse-pmtiles.js";
10
10
  import { BlobSource } from "./lib/blob-source.js";
11
11
  const VERSION = '1.0.0';
12
- export const PMTilesService = {
12
+ /**
13
+ * Creates vector tile data sources for PMTiles urls or blobs
14
+ */
15
+ export const PMTilesSource = {
13
16
  name: 'PMTiles',
14
17
  id: 'pmtiles',
15
18
  module: 'pmtiles',
16
19
  version: VERSION,
17
20
  extensions: ['pmtiles'],
18
21
  mimeTypes: ['application/octet-stream'],
19
- options: {
20
- pmtiles: {}
21
- },
22
- createSource: (props) => new PMTilesSource(props)
22
+ options: { url: undefined, pmtiles: {} },
23
+ type: 'pmtiles',
24
+ fromUrl: true,
25
+ fromBlob: true,
26
+ testURL: (url) => url.endsWith('.pmtiles'),
27
+ createDataSource: (url, props) => new PMTilesTileSource(url, props)
23
28
  };
24
29
  /**
25
30
  * A PMTiles data source
26
31
  * @note Can be either a raster or vector tile source depending on the contents of the PMTiles file.
27
32
  */
28
- export class PMTilesSource extends DataSource {
33
+ export class PMTilesTileSource extends DataSource {
29
34
  data;
30
35
  props;
31
36
  mimeType = null;
32
37
  pmtiles;
33
38
  metadata;
34
- constructor(props) {
39
+ constructor(data, props) {
35
40
  super(props);
36
41
  this.props = props;
37
- const url = typeof props.url === 'string' ? resolvePath(props.url) : new BlobSource(props.url, 'pmtiles');
42
+ const url = typeof data === 'string' ? resolvePath(data) : new BlobSource(data, 'pmtiles');
38
43
  this.data = props.url;
39
44
  this.pmtiles = new PMTiles(url);
40
45
  this.getTileData = this.getTileData.bind(this);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/pmtiles",
3
- "version": "4.3.0-alpha.2",
3
+ "version": "4.3.0-alpha.3",
4
4
  "description": "Framework-independent loader for the pmtiles format",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -46,14 +46,14 @@
46
46
  "build-bundle-dev": "ocular-bundle ./bundle.ts --env=dev --output=dist/dist.dev.js"
47
47
  },
48
48
  "dependencies": {
49
- "@loaders.gl/images": "4.3.0-alpha.2",
50
- "@loaders.gl/loader-utils": "4.3.0-alpha.2",
51
- "@loaders.gl/mvt": "4.3.0-alpha.2",
52
- "@loaders.gl/schema": "4.3.0-alpha.2",
49
+ "@loaders.gl/images": "4.3.0-alpha.3",
50
+ "@loaders.gl/loader-utils": "4.3.0-alpha.3",
51
+ "@loaders.gl/mvt": "4.3.0-alpha.3",
52
+ "@loaders.gl/schema": "4.3.0-alpha.3",
53
53
  "pmtiles": "^3.0.4"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "@loaders.gl/core": "^4.0.0"
57
57
  },
58
- "gitHead": "77a3cb538ab7a1fbf74245f25590210451689f5c"
58
+ "gitHead": "3213679d79e6ff2814d48fd3337acfa446c74099"
59
59
  }
package/src/index.ts CHANGED
@@ -2,6 +2,8 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- export type {PMTilesMetadata} from './lib/parse-pmtiles';
6
- export type {PMTilesSourceProps} from './pmtiles-source';
7
5
  export {PMTilesSource} from './pmtiles-source';
6
+
7
+ export type {PMTilesMetadata} from './lib/parse-pmtiles';
8
+ export type {PMTilesTileSourceProps} from './pmtiles-source';
9
+ export {PMTilesTileSource} from './pmtiles-source';
@@ -3,10 +3,14 @@
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
5
  import type {Schema} from '@loaders.gl/schema';
6
- import type {GetTileParameters, GetTileDataParameters} from '@loaders.gl/loader-utils';
7
- import type {ImageType, DataSourceProps} from '@loaders.gl/loader-utils';
8
- import type {ImageTileSource, VectorTileSource} from '@loaders.gl/loader-utils';
9
- import {DataSource, resolvePath} from '@loaders.gl/loader-utils';
6
+ import type {Source} from '@loaders.gl/loader-utils';
7
+ import type {
8
+ VectorTileSource,
9
+ GetTileParameters,
10
+ GetTileDataParameters
11
+ } from '@loaders.gl/loader-utils';
12
+ import type {ImageTileSource, ImageType} from '@loaders.gl/loader-utils';
13
+ import {DataSource, DataSourceProps, resolvePath} from '@loaders.gl/loader-utils';
10
14
  import {ImageLoader, ImageLoaderOptions} from '@loaders.gl/images';
11
15
  import {MVTLoader, MVTLoaderOptions, TileJSONLoaderOptions} from '@loaders.gl/mvt';
12
16
 
@@ -19,57 +23,50 @@ import {BlobSource} from './lib/blob-source';
19
23
 
20
24
  const VERSION = '1.0.0';
21
25
 
22
- export type Service = {
23
- name: string;
24
- id: string;
25
- module: string;
26
- version: string;
27
- extensions: string[];
28
- mimeTypes: string[];
29
- options: Record<string, unknown>;
30
- };
31
-
32
- export type ServiceWithSource<SourceT, SourcePropsT> = Service & {
33
- _source?: SourceT;
34
- _sourceProps?: SourcePropsT;
35
- createSource: (props: SourcePropsT) => SourceT;
36
- };
37
-
38
- export const PMTilesService: ServiceWithSource<PMTilesSource, PMTilesSourceProps> = {
26
+ /**
27
+ * Creates vector tile data sources for PMTiles urls or blobs
28
+ */
29
+ export const PMTilesSource = {
39
30
  name: 'PMTiles',
40
31
  id: 'pmtiles',
41
32
  module: 'pmtiles',
42
33
  version: VERSION,
43
34
  extensions: ['pmtiles'],
44
35
  mimeTypes: ['application/octet-stream'],
45
- options: {
46
- pmtiles: {}
47
- },
48
- createSource: (props: PMTilesSourceProps) => new PMTilesSource(props)
49
- };
36
+ options: {url: undefined!, pmtiles: {}},
37
+ type: 'pmtiles',
38
+ fromUrl: true,
39
+ fromBlob: true,
40
+
41
+ testURL: (url: string) => url.endsWith('.pmtiles'),
42
+ createDataSource: (url: string | Blob, props: PMTilesTileSourceProps) =>
43
+ new PMTilesTileSource(url, props)
44
+ } as const satisfies Source<PMTilesTileSource, PMTilesTileSourceProps>;
50
45
 
51
- export type PMTilesSourceProps = DataSourceProps & {
46
+ export type PMTilesTileSourceProps = DataSourceProps & {
52
47
  url: string | Blob;
53
48
  attributions?: string[];
54
- loadOptions?: TileJSONLoaderOptions & MVTLoaderOptions & ImageLoaderOptions;
49
+ pmtiles?: {
50
+ loadOptions?: TileJSONLoaderOptions & MVTLoaderOptions & ImageLoaderOptions;
51
+ // TODO - add options here
52
+ };
55
53
  };
56
54
 
57
55
  /**
58
56
  * A PMTiles data source
59
57
  * @note Can be either a raster or vector tile source depending on the contents of the PMTiles file.
60
58
  */
61
- export class PMTilesSource extends DataSource implements ImageTileSource, VectorTileSource {
59
+ export class PMTilesTileSource extends DataSource implements ImageTileSource, VectorTileSource {
62
60
  data: string | Blob;
63
- props: PMTilesSourceProps;
61
+ props: PMTilesTileSourceProps;
64
62
  mimeType: string | null = null;
65
63
  pmtiles: pmtiles.PMTiles;
66
64
  metadata: Promise<PMTilesMetadata>;
67
65
 
68
- constructor(props: PMTilesSourceProps) {
66
+ constructor(data: string | Blob, props: PMTilesTileSourceProps) {
69
67
  super(props);
70
68
  this.props = props;
71
- const url =
72
- typeof props.url === 'string' ? resolvePath(props.url) : new BlobSource(props.url, 'pmtiles');
69
+ const url = typeof data === 'string' ? resolvePath(data) : new BlobSource(data, 'pmtiles');
73
70
  this.data = props.url;
74
71
  this.pmtiles = new PMTiles(url);
75
72
  this.getTileData = this.getTileData.bind(this);