@loaders.gl/loader-utils 3.1.0-alpha.4 → 3.1.0-alpha.5

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.
Files changed (76) hide show
  1. package/dist/es5/index.js +46 -48
  2. package/dist/es5/index.js.map +1 -1
  3. package/dist/es5/json-loader.js +5 -33
  4. package/dist/es5/json-loader.js.map +1 -1
  5. package/dist/es5/lib/binary-utils/array-buffer-utils.js +23 -58
  6. package/dist/es5/lib/binary-utils/array-buffer-utils.js.map +1 -1
  7. package/dist/es5/lib/binary-utils/binary-copy-utils.js +7 -7
  8. package/dist/es5/lib/binary-utils/binary-copy-utils.js.map +1 -1
  9. package/dist/es5/lib/binary-utils/buffer-utils.js +4 -10
  10. package/dist/es5/lib/binary-utils/buffer-utils.js.map +1 -1
  11. package/dist/es5/lib/binary-utils/encode-utils.js +7 -7
  12. package/dist/es5/lib/binary-utils/encode-utils.js.map +1 -1
  13. package/dist/es5/lib/binary-utils/get-first-characters.js +5 -7
  14. package/dist/es5/lib/binary-utils/get-first-characters.js.map +1 -1
  15. package/dist/es5/lib/binary-utils/memory-copy-utils.js +6 -7
  16. package/dist/es5/lib/binary-utils/memory-copy-utils.js.map +1 -1
  17. package/dist/es5/lib/env-utils/globals.js +9 -14
  18. package/dist/es5/lib/env-utils/globals.js.map +1 -1
  19. package/dist/es5/lib/filesystems/node-filesystem.js +50 -243
  20. package/dist/es5/lib/filesystems/node-filesystem.js.map +1 -1
  21. package/dist/es5/lib/iterators/async-iteration.js +27 -242
  22. package/dist/es5/lib/iterators/async-iteration.js.map +1 -1
  23. package/dist/es5/lib/iterators/text-iterators.js +35 -410
  24. package/dist/es5/lib/iterators/text-iterators.js.map +1 -1
  25. package/dist/es5/lib/node/buffer.js +4 -4
  26. package/dist/es5/lib/node/buffer.js.map +1 -1
  27. package/dist/es5/lib/node/fs.js +20 -51
  28. package/dist/es5/lib/node/fs.js.map +1 -1
  29. package/dist/es5/lib/node/util.js +3 -5
  30. package/dist/es5/lib/node/util.js.map +1 -1
  31. package/dist/es5/lib/path-utils/file-aliases.js +4 -4
  32. package/dist/es5/lib/path-utils/file-aliases.js.map +1 -1
  33. package/dist/es5/lib/path-utils/path.js +5 -9
  34. package/dist/es5/lib/path-utils/path.js.map +1 -1
  35. package/dist/es5/lib/request-utils/request-scheduler.js +96 -124
  36. package/dist/es5/lib/request-utils/request-scheduler.js.map +1 -1
  37. package/dist/es5/lib/worker-loader-utils/create-loader-worker.js +63 -132
  38. package/dist/es5/lib/worker-loader-utils/create-loader-worker.js.map +1 -1
  39. package/dist/es5/lib/worker-loader-utils/parse-with-worker.js +51 -111
  40. package/dist/es5/lib/worker-loader-utils/parse-with-worker.js.map +1 -1
  41. package/dist/esm/json-loader.js +1 -1
  42. package/dist/esm/lib/parser-utils/parse-json.js +1 -1
  43. package/dist/esm/lib/parser-utils/parse-json.js.map +1 -1
  44. package/dist/esm/lib/path-utils/file-aliases.js +1 -1
  45. package/dist/esm/lib/path-utils/file-aliases.js.map +1 -1
  46. package/dist/esm/lib/path-utils/path.js +2 -2
  47. package/dist/esm/lib/path-utils/path.js.map +1 -1
  48. package/dist/esm/lib/worker-loader-utils/create-loader-worker.js +1 -1
  49. package/dist/esm/lib/worker-loader-utils/create-loader-worker.js.map +1 -1
  50. package/dist/esm/lib/worker-loader-utils/parse-with-worker.js +1 -1
  51. package/dist/esm/lib/worker-loader-utils/parse-with-worker.js.map +1 -1
  52. package/dist/index.d.ts +26 -0
  53. package/dist/json-loader.d.ts +21 -0
  54. package/dist/lib/binary-utils/array-buffer-utils.d.ts +30 -0
  55. package/dist/lib/binary-utils/binary-copy-utils.d.ts +23 -0
  56. package/dist/lib/binary-utils/buffer-utils.d.ts +15 -0
  57. package/dist/lib/binary-utils/encode-utils.d.ts +3 -0
  58. package/dist/lib/binary-utils/get-first-characters.d.ts +2 -0
  59. package/dist/lib/binary-utils/memory-copy-utils.d.ts +24 -0
  60. package/dist/lib/env-utils/assert.d.ts +5 -0
  61. package/dist/lib/env-utils/globals.d.ts +14 -0
  62. package/dist/lib/filesystems/node-filesystem.d.ts +37 -0
  63. package/dist/lib/iterators/async-iteration.d.ts +19 -0
  64. package/dist/lib/iterators/text-iterators.d.ts +18 -0
  65. package/dist/lib/node/buffer.d.ts +9 -0
  66. package/dist/lib/node/fs.d.ts +25 -0
  67. package/dist/lib/node/util.d.ts +4 -0
  68. package/dist/lib/parser-utils/parse-json.d.ts +4 -0
  69. package/dist/lib/path-utils/file-aliases.d.ts +16 -0
  70. package/dist/lib/path-utils/path.d.ts +15 -0
  71. package/dist/lib/request-utils/request-scheduler.d.ts +61 -0
  72. package/dist/lib/worker-loader-utils/create-loader-worker.d.ts +6 -0
  73. package/dist/lib/worker-loader-utils/parse-with-worker.d.ts +14 -0
  74. package/dist/types.d.ts +206 -0
  75. package/dist/workers/json-worker.d.ts +1 -0
  76. package/package.json +5 -4
@@ -0,0 +1,37 @@
1
+ /// <reference types="node" />
2
+ import * as fs from '../node/fs';
3
+ import { IFileSystem, IRandomAccessReadFileSystem } from '../../types';
4
+ declare type Stat = {
5
+ size: number;
6
+ isDirectory: () => boolean;
7
+ info?: fs.Stats;
8
+ };
9
+ declare type ReadOptions = {
10
+ buffer?: Buffer;
11
+ offset?: number;
12
+ length?: number;
13
+ position?: number;
14
+ };
15
+ /**
16
+ * FileSystem pass-through for Node.js
17
+ * Compatible with BrowserFileSystem.
18
+ * @param options
19
+ */
20
+ export default class NodeFileSystem implements IFileSystem, IRandomAccessReadFileSystem {
21
+ constructor(options: {
22
+ [key: string]: any;
23
+ });
24
+ readdir(dirname?: string, options?: {}): Promise<any[]>;
25
+ stat(path: string, options?: {}): Promise<Stat>;
26
+ fetch(path: string, options: {
27
+ [key: string]: any;
28
+ }): Promise<any>;
29
+ open(path: string, flags: string | number, mode?: any): Promise<number>;
30
+ close(fd: number): Promise<void>;
31
+ fstat(fd: number): Promise<Stat>;
32
+ read(fd: number, { buffer, offset, length, position }: ReadOptions): Promise<{
33
+ bytesRead: number;
34
+ buffer: Buffer;
35
+ }>;
36
+ }
37
+ export {};
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Iterate over async iterator, without resetting iterator if end is not reached
3
+ * - forEach intentionally does not reset iterator if exiting loop prematurely
4
+ * so that iteration can continue in a second loop
5
+ * - It is recommended to use a standard for-await as last loop to ensure
6
+ * iterator gets properly reset
7
+ *
8
+ * TODO - optimize using sync iteration if argument is an Iterable?
9
+ *
10
+ * @param iterator
11
+ * @param visitor
12
+ */
13
+ export declare function forEach(iterator: any, visitor: any): Promise<void>;
14
+ /**
15
+ * Concatenates all data chunks yielded by an (async) iterator
16
+ * This function can e.g. be used to enable atomic parsers to work on (async) iterator inputs
17
+ */
18
+ export declare function concatenateArrayBuffersAsync(asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>): Promise<ArrayBuffer>;
19
+ export declare function concatenateStringsAsync(asyncIterator: AsyncIterable<string> | Iterable<string>): Promise<string>;
@@ -0,0 +1,18 @@
1
+ export declare function makeTextDecoderIterator(arrayBufferIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>, options?: TextDecoderOptions): AsyncIterable<string>;
2
+ export declare function makeTextEncoderIterator(textIterator: AsyncIterable<string> | Iterable<ArrayBuffer>): AsyncIterable<ArrayBuffer>;
3
+ /**
4
+ * @param textIterator async iterable yielding strings
5
+ * @returns an async iterable over lines
6
+ * See http://2ality.com/2018/04/async-iter-nodejs.html
7
+ */
8
+ export declare function makeLineIterator(textIterator: AsyncIterable<string>): AsyncIterable<string>;
9
+ /**
10
+ * @param lineIterator async iterable yielding lines
11
+ * @returns async iterable yielding numbered lines
12
+ *
13
+ * See http://2ality.com/2018/04/async-iter-nodejs.html
14
+ */
15
+ export declare function makeNumberedLineIterator(lineIterator: AsyncIterable<string>): AsyncIterable<{
16
+ counter: number;
17
+ line: string;
18
+ }>;
@@ -0,0 +1,9 @@
1
+ /// <reference types="node" />
2
+ /**
3
+ * Convert Buffer to ArrayBuffer
4
+ */
5
+ export declare function toArrayBuffer(buffer: any): any;
6
+ /**
7
+ * Convert (copy) ArrayBuffer to Buffer
8
+ */
9
+ export declare function toBuffer(binaryData: any): void | Buffer;
@@ -0,0 +1,25 @@
1
+ /// <reference types="node" />
2
+ import fs from 'fs';
3
+ export type { Stats } from 'fs';
4
+ /** Wrapper for Node.js fs method */
5
+ export declare const readdir: typeof fs.readdir.__promisify__;
6
+ /** Wrapper for Node.js fs method */
7
+ export declare const stat: typeof fs.stat.__promisify__;
8
+ /** Wrapper for Node.js fs method */
9
+ export declare const readFile: typeof fs.readFile.__promisify__;
10
+ /** Wrapper for Node.js fs method */
11
+ export declare const readFileSync: typeof fs.readFileSync;
12
+ /** Wrapper for Node.js fs method */
13
+ export declare const writeFile: typeof fs.writeFile.__promisify__;
14
+ /** Wrapper for Node.js fs method */
15
+ export declare const writeFileSync: typeof fs.writeFileSync;
16
+ /** Wrapper for Node.js fs method */
17
+ export declare const open: typeof fs.open.__promisify__;
18
+ /** Wrapper for Node.js fs method */
19
+ export declare const close: typeof fs.close.__promisify__;
20
+ /** Wrapper for Node.js fs method */
21
+ export declare const read: typeof fs.read.__promisify__;
22
+ /** Wrapper for Node.js fs method */
23
+ export declare const fstat: typeof fs.fstat.__promisify__;
24
+ export declare const isSupported: boolean;
25
+ export declare function _readToArrayBuffer(fd: number, start: number, length: number): Promise<any>;
@@ -0,0 +1,4 @@
1
+ /// <reference types="node" />
2
+ import * as util from 'util';
3
+ /** Wrapper for Node.js promisify */
4
+ export declare const promisify: typeof util.promisify;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Minimal JSON parser that throws more meaningful error messages
3
+ */
4
+ export declare function parseJSON(string: string): any;
@@ -0,0 +1,16 @@
1
+ export declare function setPathPrefix(prefix: string): void;
2
+ export declare function getPathPrefix(): string;
3
+ /**
4
+ *
5
+ * @param aliases
6
+ *
7
+ * Note: addAliases are an experimental export, they are only for testing of loaders.gl loaders
8
+ * not intended as a generic aliasing mechanism
9
+ */
10
+ export declare function addAliases(aliases: {
11
+ [aliasPath: string]: string;
12
+ }): void;
13
+ /**
14
+ * Resolves aliases and adds path-prefix to paths
15
+ */
16
+ export declare function resolvePath(filename: string): string;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Replacement for Node.js path.filename
3
+ * @param url
4
+ */
5
+ export declare function filename(url: string): string;
6
+ /**
7
+ * Replacement for Node.js path.dirname
8
+ * @param url
9
+ */
10
+ export declare function dirname(url: string): string;
11
+ /**
12
+ * Replacement for Node.js path.join
13
+ * @param parts
14
+ */
15
+ export declare function join(...parts: string[]): string;
@@ -0,0 +1,61 @@
1
+ import { Stats } from '@probe.gl/stats';
2
+ declare type Handle = any;
3
+ declare type DoneFunction = () => any;
4
+ declare type GetPriorityFunction = () => number;
5
+ declare type RequestResult = {
6
+ done: DoneFunction;
7
+ } | null;
8
+ /** RequestScheduler Options */
9
+ export declare type RequestSchedulerProps = {
10
+ id?: string;
11
+ throttleRequests?: boolean;
12
+ maxRequests?: number;
13
+ };
14
+ /** Tracks one request */
15
+ declare type Request = {
16
+ handle: Handle;
17
+ priority: number;
18
+ getPriority: GetPriorityFunction;
19
+ resolve?: (value: any) => any;
20
+ };
21
+ /**
22
+ * Used to issue a request, without having them "deeply queued" by the browser.
23
+ * @todo - Track requests globally, across multiple servers
24
+ */
25
+ export default class RequestScheduler {
26
+ readonly props: Required<RequestSchedulerProps>;
27
+ readonly stats: Stats;
28
+ activeRequestCount: number;
29
+ /** Tracks the number of active requests and prioritizes/cancels queued requests. */
30
+ private requestQueue;
31
+ private requestMap;
32
+ private deferredUpdate;
33
+ constructor(props?: RequestSchedulerProps);
34
+ /**
35
+ * Called by an application that wants to issue a request, without having it deeply queued by the browser
36
+ *
37
+ * When the returned promise resolved, it is OK for the application to issue a request.
38
+ * The promise resolves to an object that contains a `done` method.
39
+ * When the application's request has completed (or failed), the application must call the `done` function
40
+ *
41
+ * @param handle
42
+ * @param getPriority will be called when request "slots" open up,
43
+ * allowing the caller to update priority or cancel the request
44
+ * Highest priority executes first, priority < 0 cancels the request
45
+ * @returns a promise
46
+ * - resolves to a object (with a `done` field) when the request can be issued without queueing,
47
+ * - resolves to `null` if the request has been cancelled (by the callback return < 0).
48
+ * In this case the application should not issue the request
49
+ */
50
+ scheduleRequest(handle: Handle, getPriority?: GetPriorityFunction): Promise<RequestResult>;
51
+ _issueRequest(request: Request): Promise<any>;
52
+ /** We check requests asynchronously, to prevent multiple updates */
53
+ _issueNewRequests(): void;
54
+ /** Refresh all requests */
55
+ _issueNewRequestsAsync(): void;
56
+ /** Ensure all requests have updated priorities, and that no longer valid requests are cancelled */
57
+ _updateAllRequests(): void;
58
+ /** Update a single request by calling the callback */
59
+ _updateRequest(request: any): boolean;
60
+ }
61
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { LoaderWithParser } from '../../types';
2
+ /**
3
+ * Set up a WebWorkerGlobalScope to talk with the main thread
4
+ * @param loader
5
+ */
6
+ export declare function createLoaderWorker(loader: LoaderWithParser): void;
@@ -0,0 +1,14 @@
1
+ import type { Loader, LoaderOptions, LoaderContext } from '../../types';
2
+ /**
3
+ * Determines if a loader can parse with worker
4
+ * @param loader
5
+ * @param options
6
+ */
7
+ export declare function canParseWithWorker(loader: Loader, options?: LoaderOptions): boolean | "" | undefined;
8
+ /**
9
+ * this function expects that the worker function sends certain messages,
10
+ * this can be automated if the worker is wrapper by a call to createLoaderWorker in @loaders.gl/loader-utils.
11
+ */
12
+ export declare function parseWithWorker(loader: Loader, data: any, options?: LoaderOptions, context?: LoaderContext, parseOnMainThread?: (arrayBuffer: ArrayBuffer, options: {
13
+ [key: string]: any;
14
+ }) => Promise<void>): Promise<any>;
@@ -0,0 +1,206 @@
1
+ /// <reference types="node" />
2
+ export declare type TypedIntArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Int32Array | Uint32Array;
3
+ export declare type TypedFloatArray = Uint16Array | Float32Array | Float64Array;
4
+ export declare type TypedArray = TypedIntArray | TypedFloatArray;
5
+ export declare type NumericArray = Array<number> | TypedIntArray | TypedFloatArray;
6
+ declare type FetchLike = (url: string, options?: RequestInit) => Promise<Response>;
7
+ export declare type LoaderOptions = {
8
+ /** fetch options or a custom fetch function */
9
+ fetch?: typeof fetch | FetchLike | RequestInit | null;
10
+ /** Do not throw on errors */
11
+ nothrow?: boolean;
12
+ /** loader selection, search first for supplied mimeType */
13
+ mimeType?: string;
14
+ /** loader selection, provide fallback mimeType is server does not provide */
15
+ fallbackMimeType?: string;
16
+ /** loader selection, avoid searching registered loaders */
17
+ ignoreRegisteredLoaders?: boolean;
18
+ /** Experimental: Supply a logger to the parser */
19
+ log?: any;
20
+ /** Size of each batch. `auto` matches batches to size of incoming chunks */
21
+ batchSize?: number | 'auto';
22
+ /** Minimal amount of time between batches */
23
+ batchDebounceMs?: number;
24
+ /** Stop loading after a given number of rows (compare SQL limit clause) */
25
+ limit?: 0;
26
+ /** Experimental: Stop loading after reaching */
27
+ _limitMB?: 0;
28
+ /** Generate metadata batches */
29
+ metadata?: boolean;
30
+ /** Transforms to run on incoming batches */
31
+ transforms?: TransformBatches[];
32
+ /** CDN load workers from */
33
+ CDN?: string;
34
+ /** Set to `false` to disable workers */
35
+ worker?: boolean;
36
+ /** Number of concurrent workers (per loader) on desktop browser */
37
+ maxConcurrency?: number;
38
+ /** Number of concurrent workers (per loader) on mobile browsers */
39
+ maxMobileConcurrency?: number;
40
+ /** Set to `false` to prevent reuse workers */
41
+ reuseWorkers?: boolean;
42
+ /** set to 'test' to run worker type */
43
+ _workerType?: string;
44
+ /** @deprecated `options.batchType` removed, Use `options.<loader>.type` instead */
45
+ batchType?: 'row' | 'columnar' | 'arrow';
46
+ /** @deprecated `options.throw removed`, Use `options.nothrow` instead */
47
+ throws?: boolean;
48
+ /** @deprecated `options.dataType` no longer used */
49
+ dataType?: any;
50
+ /** @deprecated `options.uri` no longer used */
51
+ uri?: any;
52
+ /** @deprecated `options.method` removed. Use `options.fetch.method` */
53
+ method?: any;
54
+ /** @deprecated `options.headers` removed. Use `options.fetch.headers` */
55
+ headers?: any;
56
+ /** @deprecated `options.body` removed. Use `options.fetch.body` */
57
+ body?: any;
58
+ /** @deprecated `options.mode` removed. Use `options.fetch.mode` */
59
+ mode?: any;
60
+ /** @deprecated `options.credentials` removed. Use `options.fetch.credentials` */
61
+ credentials?: any;
62
+ /** @deprecated `options.cache` removed. Use `options.fetch.cache` */
63
+ cache?: any;
64
+ /** @deprecated `options.redirect` removed. Use `options.fetch.redirect` */
65
+ redirect?: any;
66
+ /** @deprecated `options.referrer` removed. Use `options.fetch.referrer` */
67
+ referrer?: any;
68
+ /** @deprecated `options.referrerPolicy` removed. Use `options.fetch.referrerPolicy` */
69
+ referrerPolicy?: any;
70
+ /** @deprecated `options.integrity` removed. Use `options.fetch.integrity` */
71
+ integrity?: any;
72
+ /** @deprecated `options.keepalive` removed. Use `options.fetch.keepalive` */
73
+ keepalive?: any;
74
+ /** @deprecated `options.signal` removed. Use `options.fetch.signal` */
75
+ signal?: any;
76
+ [loaderId: string]: any;
77
+ };
78
+ declare type PreloadOptions = {
79
+ [key: string]: any;
80
+ };
81
+ /**
82
+ * A worker loader definition that can be used with `@loaders.gl/core` functions
83
+ */
84
+ export declare type Loader = {
85
+ name: string;
86
+ id: string;
87
+ module: string;
88
+ version: string;
89
+ worker?: string | boolean;
90
+ options: object;
91
+ deprecatedOptions?: object;
92
+ category?: string;
93
+ extensions: string[];
94
+ mimeTypes: string[];
95
+ binary?: boolean;
96
+ text?: boolean;
97
+ tests?: (((ArrayBuffer: any) => boolean) | ArrayBuffer | string)[];
98
+ supported?: boolean;
99
+ testText?: (string: any) => boolean;
100
+ };
101
+ /**
102
+ * A "bundled" loader definition that can be used with `@loaders.gl/core` functions
103
+ * If a worker loader is supported it will also be supported.
104
+ */
105
+ export declare type LoaderWithParser = Loader & {
106
+ testText?: (string: any) => boolean;
107
+ parse: Parse;
108
+ preload?: Preload;
109
+ parseSync?: ParseSync;
110
+ parseText?: ParseText;
111
+ parseTextSync?: ParseTextSync;
112
+ parseInBatches?: ParseInBatches;
113
+ parseFileInBatches?: ParseFileInBatches;
114
+ };
115
+ /** Options for writers */
116
+ export declare type WriterOptions = {};
117
+ /**
118
+ * A writer definition that can be used with `@loaders.gl/core` functions
119
+ */
120
+ export declare type Writer = {
121
+ name: string;
122
+ id: string;
123
+ module: string;
124
+ version: string;
125
+ options: object;
126
+ deprecatedOptions?: object;
127
+ binary?: boolean;
128
+ extensions?: string[];
129
+ mimeTypes?: string[];
130
+ text?: boolean;
131
+ encode?: Encode;
132
+ encodeSync?: EncodeSync;
133
+ encodeInBatches?: EncodeInBatches;
134
+ encodeURLtoURL?: EncodeURLtoURL;
135
+ encodeText?: EncodeText;
136
+ };
137
+ export declare type LoaderContext = {
138
+ loaders?: Loader[] | null;
139
+ url?: string;
140
+ fetch: typeof fetch;
141
+ parse: (arrayBuffer: ArrayBuffer, loaders?: any, options?: LoaderOptions, context?: LoaderContext) => Promise<any>;
142
+ parseSync?: (arrayBuffer: ArrayBuffer, loaders?: any, options?: LoaderOptions, context?: LoaderContext) => any;
143
+ parseInBatches?: (iterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>, loaders?: any, options?: LoaderOptions, context?: LoaderContext) => AsyncIterable<any> | Promise<AsyncIterable<any>>;
144
+ };
145
+ declare type Parse = (arrayBuffer: ArrayBuffer, options?: LoaderOptions, context?: LoaderContext) => Promise<any>;
146
+ declare type ParseSync = (arrayBuffer: ArrayBuffer, options?: LoaderOptions, context?: LoaderContext) => any;
147
+ declare type ParseText = (text: string, options?: LoaderOptions) => Promise<any>;
148
+ declare type ParseTextSync = (text: string, options?: LoaderOptions) => any;
149
+ declare type ParseInBatches = (iterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>, options?: LoaderOptions, context?: LoaderContext) => AsyncIterable<any>;
150
+ declare type ParseFileInBatches = (file: Blob, options?: LoaderOptions, context?: LoaderContext) => AsyncIterable<any>;
151
+ declare type Encode = (data: any, options?: WriterOptions) => Promise<ArrayBuffer>;
152
+ declare type EncodeSync = (data: any, options?: WriterOptions) => ArrayBuffer;
153
+ declare type EncodeText = Function;
154
+ declare type EncodeInBatches = Function;
155
+ declare type EncodeURLtoURL = (inputUrl: string, outputUrl: string, options?: WriterOptions) => Promise<string>;
156
+ declare type Preload = (url: string, options?: PreloadOptions) => any;
157
+ export declare type TransformBatches = (asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>) => AsyncIterable<ArrayBuffer>;
158
+ /** Types that can be synchronously parsed */
159
+ export declare type SyncDataType = string | ArrayBuffer;
160
+ /** Types that can be parsed async */
161
+ export declare type DataType = string | ArrayBuffer | File | Blob | Response | ReadableStream | Iterable<ArrayBuffer> | AsyncIterable<ArrayBuffer>;
162
+ /** Types that can be parsed in batches */
163
+ export declare type BatchableDataType = DataType | Iterable<ArrayBuffer> | AsyncIterable<ArrayBuffer> | Promise<AsyncIterable<ArrayBuffer>>;
164
+ /**
165
+ * A FileSystem interface can encapsulate a FileList, a ZipFile, a GoogleDrive etc.
166
+ */
167
+ export interface IFileSystem {
168
+ /**
169
+ * Return a list of file names
170
+ * @param dirname directory name. file system root directory if omitted
171
+ */
172
+ readdir(dirname?: string, options?: {
173
+ recursive?: boolean;
174
+ }): Promise<string[]>;
175
+ /**
176
+ * Gets information from a local file from the filesystem
177
+ * @param filename file name to stat
178
+ * @param options currently unused
179
+ * @throws if filename is not in local filesystem
180
+ */
181
+ stat(filename: string, options?: object): Promise<{
182
+ size: number;
183
+ }>;
184
+ /**
185
+ * Fetches a local file from the filesystem (or a URL)
186
+ * @param filename
187
+ * @param options
188
+ */
189
+ fetch(filename: string, options?: object): Promise<Response>;
190
+ }
191
+ declare type ReadOptions = {
192
+ buffer?: ArrayBuffer;
193
+ offset?: number;
194
+ length?: number;
195
+ position?: number;
196
+ };
197
+ export interface IRandomAccessReadFileSystem extends IFileSystem {
198
+ open(path: string, flags: any, mode?: any): Promise<any>;
199
+ close(fd: any): Promise<void>;
200
+ fstat(fd: any): Promise<object>;
201
+ read(fd: any, options?: ReadOptions): Promise<{
202
+ bytesRead: number;
203
+ buffer: Buffer;
204
+ }>;
205
+ }
206
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/loader-utils",
3
- "version": "3.1.0-alpha.4",
3
+ "version": "3.1.0-alpha.5",
4
4
  "description": "Framework-independent loaders for 3D graphics formats",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -17,7 +17,7 @@
17
17
  "mesh",
18
18
  "point cloud"
19
19
  ],
20
- "types": "src/index.ts",
20
+ "types": "dist/index.d.ts",
21
21
  "main": "dist/es5/index.js",
22
22
  "module": "dist/esm/index.js",
23
23
  "sideEffects": false,
@@ -44,12 +44,13 @@
44
44
  },
45
45
  "scripts": {
46
46
  "pre-build-disabled": "npm run build-bundle",
47
+ "post-build": "tsc",
47
48
  "build-bundle": "webpack --config ../../scripts/webpack/bundle.js"
48
49
  },
49
50
  "dependencies": {
50
51
  "@babel/runtime": "^7.3.1",
51
- "@loaders.gl/worker-utils": "3.1.0-alpha.4",
52
+ "@loaders.gl/worker-utils": "3.1.0-alpha.5",
52
53
  "@probe.gl/stats": "^3.4.0"
53
54
  },
54
- "gitHead": "e309784af37ef9f3640c7733c7851124c72e1fa3"
55
+ "gitHead": "352241dd910a8c6307a235dadbe154ca915b885b"
55
56
  }