• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

visgl / loaders.gl / 20352100062

18 Dec 2025 09:37PM UTC coverage: 63.485% (+0.06%) from 63.426%
20352100062

push

github

web-flow
feat: LoaderOptions.core - improved loader type safety (#3112)

7255 of 9672 branches covered (75.01%)

Branch coverage included in aggregate %.

570 of 658 new or added lines in 65 files covered. (86.63%)

8 existing lines in 4 files now uncovered.

67412 of 107942 relevant lines covered (62.45%)

3436.69 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/modules/loader-utils/src/writer-types.ts
1
// loaders.gl
×
2
// SPDX-License-Identifier: MIT
×
3
// Copyright (c) vis.gl contributors
×
4

×
5
import type {Format} from './format-types';
×
6

×
7
// WRITERS
×
8

×
9
/** Options for writers */
×
10
export type WriterOptions = {
×
NEW
11
  core?: {
×
NEW
12
    /** worker source. If is set will be used instead of loading worker from the Internet */
×
NEW
13
    source?: string | null;
×
14

×
NEW
15
    // module loading
×
16

×
NEW
17
    /** Any additional JS libraries */
×
NEW
18
    modules?: Record<string, any>;
×
NEW
19
    /** Force to load WASM libraries from local file system in NodeJS or from loaders.gl CDN in a web browser */
×
NEW
20
    useLocalLibraries?: boolean;
×
NEW
21
    /** Whether to use workers under Node.js (experimental) */
×
NEW
22
    _nodeWorkers?: boolean;
×
NEW
23
    /** Set to `false` to disable workers */
×
NEW
24
    worker?: boolean;
×
NEW
25
    log?: any;
×
NEW
26
  };
×
27

×
28
  /** writer-specific options */
×
NEW
29
  [writerId: string]: Record<string, unknown> | undefined;
×
30
};
×
31

×
32
/**
×
33
 * A writer definition that can be used with `@loaders.gl/core` functions
×
34
 */
×
35
// eslint-disable-next-line @typescript-eslint/no-unused-vars
×
36
export type Writer<DataT = unknown, BatchT = unknown, WriterOptionsT = WriterOptions> = Format & {
×
37
  /** The result type of this loader  */
×
38
  dataType?: DataT;
×
39
  /** The batched result type of this loader  */
×
40
  batchType?: BatchT;
×
41
  /** Version should be injected by build tools */
×
42
  version: string;
×
43
  /** A boolean, or a URL */
×
44
  worker?: string | boolean;
×
45
  // end Worker
×
46
  options: WriterOptionsT;
×
47
  deprecatedOptions?: Record<string, string>;
×
48

×
49
  /** Human readable name */
×
50
  name: string;
×
51
  /** id should be the same as the field used in LoaderOptions */
×
52
  id: string;
×
53
  /** module is used to generate worker threads, need to be the module directory name */
×
54
  module: string;
×
55
  /** Which category does this loader belong to */
×
56
  category?: string;
×
57
  /** File extensions that are potential matches with this loader. */
×
58
  extensions: string[];
×
59
  /** MIMETypes that indicate a match with this loader. @note Some MIMETypes are generic and supported by many loaders */
×
60
  mimeTypes?: string[];
×
61
  /** Is the input of this loader binary */
×
62
  binary?: boolean;
×
63
  /** Is the input of this loader text */
×
64
  text?: boolean;
×
65
};
×
66

×
67
/**
×
68
 * A writer definition that can be used with `@loaders.gl/core` functions
×
69
 */
×
70
export type WriterWithEncoder<
×
71
  DataT = unknown,
×
72
  BatchT = unknown,
×
73
  WriterOptionsT = WriterOptions
×
74
> = Writer<DataT, BatchT, WriterOptionsT> & {
×
75
  /** Encode to binary,  asynchronously */
×
76
  encode(data: DataT, options?: WriterOptionsT): Promise<ArrayBuffer>;
×
77
  /** Encode to binary, synchronously */
×
78
  encodeSync?(data: DataT, options?: WriterOptionsT): ArrayBuffer;
×
79
  /** Encode to binary in batches */
×
80
  encodeInBatches?(data: AsyncIterable<any>, options?: WriterOptionsT): AsyncIterable<ArrayBuffer>;
×
81

×
82
  /** Encode to text, asynchronously. For text formats. */
×
83
  encodeText?(table: DataT, options?: WriterOptionsT): Promise<string>;
×
84
  /** Encode to text, synchronously. For text formats. */
×
85
  encodeTextSync?(table: DataT, options?: WriterOptionsT): string;
×
86
  /** Encode to text in batched. For text formats. */
×
87
  encodeTextInBatches?(
×
88
    data: AsyncIterable<any>,
×
89
    options?: WriterOptionsT
×
90
  ): AsyncIterable<ArrayBuffer>;
×
91

×
92
  encodeURLtoURL?: (
×
93
    inputUrl: string,
×
94
    outputUrl: string,
×
95
    options?: WriterOptionsT
×
96
  ) => Promise<string>;
×
97
};
×
98

×
99
/** Typescript helper to extract the writer options type from a writer type */
×
100
export type WriterOptionsType<T = Writer> =
×
101
  T extends Writer<unknown, unknown, infer OptionsType> ? OptionsType : never;
×
102
/** Typescript helper to extract input data type from a writer type */
×
103
export type WriterDataType<T = Writer> =
×
104
  T extends Writer<infer DataType, any, any> ? DataType : never;
×
105
export type WriterBatchType<T = Writer> =
×
106
  T extends Writer<any, infer BatchType, any> ? BatchType : never;
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc