// loaders.gl // SPDX-License-Identifier: MIT // Copyright (c) vis.gl contributors import type {Format} from './format-types'; import type {DataSource, DataSourceOptions} from './lib/sources/data-source'; /** * A `Source` contains metadata and a factory method for creating instances of a specific `DataSource`. * It allows a list of `Source` objects to be passed to methods * @example * `createDataSource(... , [MVTSource, PMTilesSource, ...]) */ export interface Source< DataSourceT extends DataSource = DataSource< unknown, DataSourceOptions > > extends Format { /** Type of source created by this service */ dataSource?: DataSourceT; /** Type of options used when creating sources */ options?: DataSourceT['optionsType']; /** Name of the service */ name: string; id: string; /** Module containing the service */ module: string; /** Version of the loaders.gl package containing this service. */ version: string; /** URL extensions that this service uses */ extensions: string[]; /** MIME extensions that this service uses */ mimeTypes: string[]; /** Type string identifying this service, e.g. 'wms' */ type: string; /** Can source be created from a URL */ fromUrl: boolean; /** Can source be created from a Blob or File */ fromBlob: boolean; /** Default options */ defaultOptions: Omit< Required<{[K in keyof DataSourceT['options']]: Required}>, 'core' >; /** Check if a URL can support this service */ testURL: (url: string) => boolean; /** Test data */ testData?: (data: Blob) => boolean; /** Create a source */ createDataSource(data: string | Blob, options: Readonly): DataSourceT; } // T extends Source ? DataSource : never; // T extends Source ? PropsType : never; /** Typescript helper to extract input data type from a source type */ export type SourcePropsType = Required; /** Typescript helper to extract the source options type from a source type */ export type SourceDataSourceType = SourceT['dataSource']; /** Typescript helper to extract options type from an array of source types */ export type SourceArrayOptionsType = SourcesT[number]['options'] & DataSourceOptions; /** Typescript helper to extract data type from a source type */ export type SourceArrayDataSourceType = SourcesT[number]['dataSource']; /** Typescript helper to extract batch type from a source type */