@loaders.gl/loader-utils 4.0.0-beta.2 → 4.0.0-beta.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.
- package/dist/index.cjs +1252 -0
- package/dist/index.d.ts +7 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -0
- package/dist/{esm/json-loader.js → json-loader.js} +1 -1
- package/dist/json-loader.js.map +1 -0
- package/dist/lib/binary-utils/array-buffer-utils.js.map +1 -0
- package/dist/{esm/lib → lib}/binary-utils/dataview-copy-utils.js +1 -1
- package/dist/lib/binary-utils/dataview-copy-utils.js.map +1 -0
- package/dist/lib/binary-utils/get-first-characters.js.map +1 -0
- package/dist/{esm/lib → lib}/binary-utils/memory-conversion-utils.js +1 -1
- package/dist/lib/binary-utils/memory-conversion-utils.js.map +1 -0
- package/dist/{esm/lib → lib}/binary-utils/memory-copy-utils.js +1 -1
- package/dist/lib/binary-utils/memory-copy-utils.js.map +1 -0
- package/dist/lib/env-utils/assert.js.map +1 -0
- package/dist/lib/env-utils/globals.js.map +1 -0
- package/dist/lib/file-provider/data-view-file.d.ts +4 -1
- package/dist/lib/file-provider/data-view-file.d.ts.map +1 -1
- package/dist/{esm/lib → lib}/file-provider/data-view-file.js +1 -2
- package/dist/lib/file-provider/data-view-file.js.map +1 -0
- package/dist/lib/file-provider/file-handle-file.d.ts +12 -19
- package/dist/lib/file-provider/file-handle-file.d.ts.map +1 -1
- package/dist/lib/file-provider/file-handle-file.js +56 -0
- package/dist/lib/file-provider/file-handle-file.js.map +1 -0
- package/dist/lib/file-provider/file-provider.d.ts +1 -0
- package/dist/lib/file-provider/file-provider.d.ts.map +1 -1
- package/dist/lib/file-provider/file-provider.js.map +1 -0
- package/dist/lib/files/blob-file.d.ts +16 -0
- package/dist/lib/files/blob-file.d.ts.map +1 -0
- package/dist/lib/files/blob-file.js +25 -0
- package/dist/lib/files/blob-file.js.map +1 -0
- package/dist/lib/files/file.d.ts +33 -0
- package/dist/lib/files/file.d.ts.map +1 -0
- package/dist/lib/files/file.js +2 -0
- package/dist/lib/files/file.js.map +1 -0
- package/dist/lib/files/http-file.d.ts +21 -0
- package/dist/lib/files/http-file.d.ts.map +1 -0
- package/dist/lib/files/http-file.js +79 -0
- package/dist/lib/files/http-file.js.map +1 -0
- package/dist/lib/files/node-file-facade.d.ts +18 -0
- package/dist/lib/files/node-file-facade.d.ts.map +1 -0
- package/dist/lib/files/node-file-facade.js +29 -0
- package/dist/lib/files/node-file-facade.js.map +1 -0
- package/dist/lib/files/sources.d.ts +1 -0
- package/dist/lib/files/sources.d.ts.map +1 -0
- package/dist/lib/files/sources.js +2 -0
- package/dist/lib/files/sources.js.map +1 -0
- package/dist/lib/filesystems/filesystem.d.ts +18 -65
- package/dist/lib/filesystems/filesystem.d.ts.map +1 -1
- package/dist/lib/filesystems/filesystem.js.map +1 -0
- package/dist/lib/filesystems/node-filesystem-facade.d.ts +23 -0
- package/dist/lib/filesystems/node-filesystem-facade.d.ts.map +1 -0
- package/dist/lib/filesystems/node-filesystem-facade.js +37 -0
- package/dist/lib/filesystems/node-filesystem-facade.js.map +1 -0
- package/dist/{esm/lib → lib}/iterators/async-iteration.js +1 -1
- package/dist/lib/iterators/async-iteration.js.map +1 -0
- package/dist/lib/iterators/text-iterators.js.map +1 -0
- package/dist/lib/node/buffer.browser.d.ts +1 -1
- package/dist/lib/node/buffer.browser.d.ts.map +1 -1
- package/dist/lib/node/buffer.browser.js.map +1 -0
- package/dist/lib/node/buffer.d.ts +1 -1
- package/dist/lib/node/buffer.d.ts.map +1 -1
- package/dist/lib/node/buffer.js.map +1 -0
- package/dist/lib/node/fs.browser.js.map +1 -0
- package/dist/lib/node/promisify.js.map +1 -0
- package/dist/lib/node/stream.browser.js.map +1 -0
- package/dist/lib/node/stream.js.map +1 -0
- package/dist/lib/option-utils/merge-loader-options.js.map +1 -0
- package/dist/lib/parser-utils/parse-json.js +9 -0
- package/dist/lib/parser-utils/parse-json.js.map +1 -0
- package/dist/{esm/lib → lib}/path-utils/file-aliases.js +1 -1
- package/dist/lib/path-utils/file-aliases.js.map +1 -0
- package/dist/lib/path-utils/get-cwd.js.map +1 -0
- package/dist/{esm/lib → lib}/path-utils/path.js +6 -6
- package/dist/lib/path-utils/path.js.map +1 -0
- package/dist/{esm/lib → lib}/request-utils/request-scheduler.js +6 -7
- package/dist/lib/request-utils/request-scheduler.js.map +1 -0
- package/dist/{esm/lib → lib}/sources/data-source.js +4 -5
- package/dist/lib/sources/data-source.js.map +1 -0
- package/dist/lib/sources/image-source.js +5 -0
- package/dist/lib/sources/image-source.js.map +1 -0
- package/dist/lib/sources/image-tile-source.js.map +1 -0
- package/dist/lib/sources/tile-source.js.map +1 -0
- package/dist/lib/sources/utils/image-type.js.map +1 -0
- package/dist/lib/sources/utils/utils.js.map +1 -0
- package/dist/lib/sources/vector-tile-source.js.map +1 -0
- package/dist/{esm/lib → lib}/worker-loader-utils/create-loader-worker.js +1 -1
- package/dist/lib/worker-loader-utils/create-loader-worker.js.map +1 -0
- package/dist/{esm/lib → lib}/worker-loader-utils/encode-with-worker.js +1 -1
- package/dist/lib/worker-loader-utils/encode-with-worker.js.map +1 -0
- package/dist/{esm/lib → lib}/worker-loader-utils/parse-with-worker.js +1 -1
- package/dist/lib/worker-loader-utils/parse-with-worker.js.map +1 -0
- package/dist/loader-types.js.map +1 -0
- package/dist/service-types.js.map +1 -0
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -0
- package/dist/workers/json-worker.js +4 -0
- package/dist/workers/json-worker.js.map +1 -0
- package/dist/writer-types.js.map +1 -0
- package/package.json +13 -5
- package/src/index.ts +10 -15
- package/src/lib/file-provider/data-view-file.ts +4 -2
- package/src/lib/file-provider/file-handle-file.ts +28 -44
- package/src/lib/file-provider/file-provider.ts +1 -0
- package/src/lib/files/blob-file.ts +32 -0
- package/src/lib/files/file.ts +37 -0
- package/src/lib/files/http-file.ts +120 -0
- package/src/lib/files/node-file-facade.ts +39 -0
- package/src/lib/files/sources.ts +150 -0
- package/src/lib/filesystems/filesystem.ts +19 -68
- package/src/lib/filesystems/node-filesystem-facade.ts +63 -0
- package/src/lib/node/buffer.browser.ts +1 -1
- package/src/lib/node/buffer.ts +1 -1
- package/src/types.ts +0 -4
- package/dist/es5/index.js +0 -389
- package/dist/es5/index.js.map +0 -1
- package/dist/es5/json-loader.js +0 -44
- package/dist/es5/json-loader.js.map +0 -1
- package/dist/es5/lib/binary-utils/array-buffer-utils.js +0 -80
- package/dist/es5/lib/binary-utils/array-buffer-utils.js.map +0 -1
- package/dist/es5/lib/binary-utils/dataview-copy-utils.js +0 -58
- package/dist/es5/lib/binary-utils/dataview-copy-utils.js.map +0 -1
- package/dist/es5/lib/binary-utils/get-first-characters.js +0 -31
- package/dist/es5/lib/binary-utils/get-first-characters.js.map +0 -1
- package/dist/es5/lib/binary-utils/memory-conversion-utils.js +0 -44
- package/dist/es5/lib/binary-utils/memory-conversion-utils.js.map +0 -1
- package/dist/es5/lib/binary-utils/memory-copy-utils.js +0 -34
- package/dist/es5/lib/binary-utils/memory-copy-utils.js.map +0 -1
- package/dist/es5/lib/env-utils/assert.js +0 -12
- package/dist/es5/lib/env-utils/assert.js.map +0 -1
- package/dist/es5/lib/env-utils/globals.js +0 -30
- package/dist/es5/lib/env-utils/globals.js.map +0 -1
- package/dist/es5/lib/file-provider/data-view-file.js +0 -146
- package/dist/es5/lib/file-provider/data-view-file.js.map +0 -1
- package/dist/es5/lib/file-provider/file-handle-file.js +0 -236
- package/dist/es5/lib/file-provider/file-handle-file.js.map +0 -1
- package/dist/es5/lib/file-provider/file-handle.js +0 -98
- package/dist/es5/lib/file-provider/file-handle.js.map +0 -1
- package/dist/es5/lib/file-provider/file-provider.js +0 -11
- package/dist/es5/lib/file-provider/file-provider.js.map +0 -1
- package/dist/es5/lib/filesystems/filesystem.js +0 -2
- package/dist/es5/lib/filesystems/filesystem.js.map +0 -1
- package/dist/es5/lib/filesystems/node-filesystem.js +0 -176
- package/dist/es5/lib/filesystems/node-filesystem.js.map +0 -1
- package/dist/es5/lib/filesystems/readable-file.js +0 -91
- package/dist/es5/lib/filesystems/readable-file.js.map +0 -1
- package/dist/es5/lib/filesystems/writable-file.js +0 -82
- package/dist/es5/lib/filesystems/writable-file.js.map +0 -1
- package/dist/es5/lib/iterators/async-iteration.js +0 -190
- package/dist/es5/lib/iterators/async-iteration.js.map +0 -1
- package/dist/es5/lib/iterators/text-iterators.js +0 -305
- package/dist/es5/lib/iterators/text-iterators.js.map +0 -1
- package/dist/es5/lib/node/buffer.browser.js +0 -14
- package/dist/es5/lib/node/buffer.browser.js.map +0 -1
- package/dist/es5/lib/node/buffer.js +0 -27
- package/dist/es5/lib/node/buffer.js.map +0 -1
- package/dist/es5/lib/node/fs.browser.js +0 -9
- package/dist/es5/lib/node/fs.browser.js.map +0 -1
- package/dist/es5/lib/node/fs.js +0 -82
- package/dist/es5/lib/node/fs.js.map +0 -1
- package/dist/es5/lib/node/promisify.js +0 -36
- package/dist/es5/lib/node/promisify.js.map +0 -1
- package/dist/es5/lib/node/stream.browser.js +0 -9
- package/dist/es5/lib/node/stream.browser.js.map +0 -1
- package/dist/es5/lib/node/stream.js +0 -15
- package/dist/es5/lib/node/stream.js.map +0 -1
- package/dist/es5/lib/option-utils/merge-loader-options.js +0 -30
- package/dist/es5/lib/option-utils/merge-loader-options.js.map +0 -1
- package/dist/es5/lib/parser-utils/parse-json.js +0 -15
- package/dist/es5/lib/parser-utils/parse-json.js.map +0 -1
- package/dist/es5/lib/path-utils/file-aliases.js +0 -33
- package/dist/es5/lib/path-utils/file-aliases.js.map +0 -1
- package/dist/es5/lib/path-utils/get-cwd.js +0 -15
- package/dist/es5/lib/path-utils/get-cwd.js.map +0 -1
- package/dist/es5/lib/path-utils/path.js +0 -136
- package/dist/es5/lib/path-utils/path.js.map +0 -1
- package/dist/es5/lib/request-utils/request-scheduler.js +0 -150
- package/dist/es5/lib/request-utils/request-scheduler.js.map +0 -1
- package/dist/es5/lib/sources/data-source.js +0 -67
- package/dist/es5/lib/sources/data-source.js.map +0 -1
- package/dist/es5/lib/sources/image-source.js +0 -31
- package/dist/es5/lib/sources/image-source.js.map +0 -1
- package/dist/es5/lib/sources/image-tile-source.js +0 -2
- package/dist/es5/lib/sources/image-tile-source.js.map +0 -1
- package/dist/es5/lib/sources/tile-source.js +0 -2
- package/dist/es5/lib/sources/tile-source.js.map +0 -1
- package/dist/es5/lib/sources/utils/image-type.js +0 -2
- package/dist/es5/lib/sources/utils/image-type.js.map +0 -1
- package/dist/es5/lib/sources/utils/utils.js +0 -36
- package/dist/es5/lib/sources/utils/utils.js.map +0 -1
- package/dist/es5/lib/sources/vector-tile-source.js +0 -2
- package/dist/es5/lib/sources/vector-tile-source.js.map +0 -1
- package/dist/es5/lib/worker-loader-utils/create-loader-worker.js +0 -142
- package/dist/es5/lib/worker-loader-utils/create-loader-worker.js.map +0 -1
- package/dist/es5/lib/worker-loader-utils/encode-with-worker.js +0 -18
- package/dist/es5/lib/worker-loader-utils/encode-with-worker.js.map +0 -1
- package/dist/es5/lib/worker-loader-utils/parse-with-worker.js +0 -115
- package/dist/es5/lib/worker-loader-utils/parse-with-worker.js.map +0 -1
- package/dist/es5/loader-types.js +0 -58
- package/dist/es5/loader-types.js.map +0 -1
- package/dist/es5/service-types.js +0 -2
- package/dist/es5/service-types.js.map +0 -1
- package/dist/es5/types.js +0 -2
- package/dist/es5/types.js.map +0 -1
- package/dist/es5/workers/json-worker.js +0 -6
- package/dist/es5/workers/json-worker.js.map +0 -1
- package/dist/es5/writer-types.js +0 -2
- package/dist/es5/writer-types.js.map +0 -1
- package/dist/esm/index.js +0 -36
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/json-loader.js.map +0 -1
- package/dist/esm/lib/binary-utils/array-buffer-utils.js.map +0 -1
- package/dist/esm/lib/binary-utils/dataview-copy-utils.js.map +0 -1
- package/dist/esm/lib/binary-utils/get-first-characters.js.map +0 -1
- package/dist/esm/lib/binary-utils/memory-conversion-utils.js.map +0 -1
- package/dist/esm/lib/binary-utils/memory-copy-utils.js.map +0 -1
- package/dist/esm/lib/env-utils/assert.js.map +0 -1
- package/dist/esm/lib/env-utils/globals.js.map +0 -1
- package/dist/esm/lib/file-provider/data-view-file.js.map +0 -1
- package/dist/esm/lib/file-provider/file-handle-file.js +0 -59
- package/dist/esm/lib/file-provider/file-handle-file.js.map +0 -1
- package/dist/esm/lib/file-provider/file-handle.js +0 -33
- package/dist/esm/lib/file-provider/file-handle.js.map +0 -1
- package/dist/esm/lib/file-provider/file-provider.js.map +0 -1
- package/dist/esm/lib/filesystems/filesystem.js.map +0 -1
- package/dist/esm/lib/filesystems/node-filesystem.js +0 -46
- package/dist/esm/lib/filesystems/node-filesystem.js.map +0 -1
- package/dist/esm/lib/filesystems/readable-file.js +0 -20
- package/dist/esm/lib/filesystems/readable-file.js.map +0 -1
- package/dist/esm/lib/filesystems/writable-file.js +0 -20
- package/dist/esm/lib/filesystems/writable-file.js.map +0 -1
- package/dist/esm/lib/iterators/async-iteration.js.map +0 -1
- package/dist/esm/lib/iterators/text-iterators.js.map +0 -1
- package/dist/esm/lib/node/buffer.browser.js.map +0 -1
- package/dist/esm/lib/node/buffer.js.map +0 -1
- package/dist/esm/lib/node/fs.browser.js.map +0 -1
- package/dist/esm/lib/node/fs.js +0 -29
- package/dist/esm/lib/node/fs.js.map +0 -1
- package/dist/esm/lib/node/promisify.js.map +0 -1
- package/dist/esm/lib/node/stream.browser.js.map +0 -1
- package/dist/esm/lib/node/stream.js.map +0 -1
- package/dist/esm/lib/option-utils/merge-loader-options.js.map +0 -1
- package/dist/esm/lib/parser-utils/parse-json.js +0 -9
- package/dist/esm/lib/parser-utils/parse-json.js.map +0 -1
- package/dist/esm/lib/path-utils/file-aliases.js.map +0 -1
- package/dist/esm/lib/path-utils/get-cwd.js.map +0 -1
- package/dist/esm/lib/path-utils/path.js.map +0 -1
- package/dist/esm/lib/request-utils/request-scheduler.js.map +0 -1
- package/dist/esm/lib/sources/data-source.js.map +0 -1
- package/dist/esm/lib/sources/image-source.js +0 -6
- package/dist/esm/lib/sources/image-source.js.map +0 -1
- package/dist/esm/lib/sources/image-tile-source.js.map +0 -1
- package/dist/esm/lib/sources/tile-source.js.map +0 -1
- package/dist/esm/lib/sources/utils/image-type.js.map +0 -1
- package/dist/esm/lib/sources/utils/utils.js.map +0 -1
- package/dist/esm/lib/sources/vector-tile-source.js.map +0 -1
- package/dist/esm/lib/worker-loader-utils/create-loader-worker.js.map +0 -1
- package/dist/esm/lib/worker-loader-utils/encode-with-worker.js.map +0 -1
- package/dist/esm/lib/worker-loader-utils/parse-with-worker.js.map +0 -1
- package/dist/esm/loader-types.js.map +0 -1
- package/dist/esm/service-types.js.map +0 -1
- package/dist/esm/types.js.map +0 -1
- package/dist/esm/workers/json-worker.js +0 -4
- package/dist/esm/workers/json-worker.js.map +0 -1
- package/dist/esm/writer-types.js.map +0 -1
- package/dist/lib/file-provider/file-handle.d.ts +0 -40
- package/dist/lib/file-provider/file-handle.d.ts.map +0 -1
- package/dist/lib/filesystems/node-filesystem.d.ts +0 -39
- package/dist/lib/filesystems/node-filesystem.d.ts.map +0 -1
- package/dist/lib/filesystems/readable-file.d.ts +0 -10
- package/dist/lib/filesystems/readable-file.d.ts.map +0 -1
- package/dist/lib/filesystems/writable-file.d.ts +0 -18
- package/dist/lib/filesystems/writable-file.d.ts.map +0 -1
- package/dist/lib/node/fs.d.ts +0 -30
- package/dist/lib/node/fs.d.ts.map +0 -1
- package/src/lib/file-provider/file-handle.ts +0 -79
- package/src/lib/filesystems/node-filesystem.ts +0 -67
- package/src/lib/filesystems/readable-file.ts +0 -30
- package/src/lib/filesystems/writable-file.ts +0 -44
- package/src/lib/node/fs.ts +0 -49
- /package/dist/{esm/lib → lib}/binary-utils/array-buffer-utils.js +0 -0
- /package/dist/{esm/lib → lib}/binary-utils/get-first-characters.js +0 -0
- /package/dist/{esm/lib → lib}/env-utils/assert.js +0 -0
- /package/dist/{esm/lib → lib}/env-utils/globals.js +0 -0
- /package/dist/{esm/lib → lib}/file-provider/file-provider.js +0 -0
- /package/dist/{esm/lib → lib}/filesystems/filesystem.js +0 -0
- /package/dist/{esm/lib → lib}/iterators/text-iterators.js +0 -0
- /package/dist/{esm/lib → lib}/node/buffer.browser.js +0 -0
- /package/dist/{esm/lib → lib}/node/buffer.js +0 -0
- /package/dist/{esm/lib → lib}/node/fs.browser.js +0 -0
- /package/dist/{esm/lib → lib}/node/promisify.js +0 -0
- /package/dist/{esm/lib → lib}/node/stream.browser.js +0 -0
- /package/dist/{esm/lib → lib}/node/stream.js +0 -0
- /package/dist/{esm/lib → lib}/option-utils/merge-loader-options.js +0 -0
- /package/dist/{esm/lib → lib}/path-utils/get-cwd.js +0 -0
- /package/dist/{esm/lib → lib}/sources/image-tile-source.js +0 -0
- /package/dist/{esm/lib → lib}/sources/tile-source.js +0 -0
- /package/dist/{esm/lib → lib}/sources/utils/image-type.js +0 -0
- /package/dist/{esm/lib → lib}/sources/utils/utils.js +0 -0
- /package/dist/{esm/lib → lib}/sources/vector-tile-source.js +0 -0
- /package/dist/{esm/loader-types.js → loader-types.js} +0 -0
- /package/dist/{esm/service-types.js → service-types.js} +0 -0
- /package/dist/{esm/types.js → types.js} +0 -0
- /package/dist/{esm/writer-types.js → writer-types.js} +0 -0
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
1
|
import { Stats } from '@probe.gl/stats';
|
|
3
2
|
const STAT_QUEUED_REQUESTS = 'Queued Requests';
|
|
4
3
|
const STAT_ACTIVE_REQUESTS = 'Active Requests';
|
|
@@ -13,12 +12,12 @@ const DEFAULT_PROPS = {
|
|
|
13
12
|
export default class RequestScheduler {
|
|
14
13
|
constructor() {
|
|
15
14
|
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
this.props = void 0;
|
|
16
|
+
this.stats = void 0;
|
|
17
|
+
this.activeRequestCount = 0;
|
|
18
|
+
this.requestQueue = [];
|
|
19
|
+
this.requestMap = new Map();
|
|
20
|
+
this.deferredUpdate = null;
|
|
22
21
|
this.props = {
|
|
23
22
|
...DEFAULT_PROPS,
|
|
24
23
|
...props
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-scheduler.js","names":["Stats","STAT_QUEUED_REQUESTS","STAT_ACTIVE_REQUESTS","STAT_CANCELLED_REQUESTS","STAT_QUEUED_REQUESTS_EVER","STAT_ACTIVE_REQUESTS_EVER","DEFAULT_PROPS","id","throttleRequests","maxRequests","RequestScheduler","constructor","props","arguments","length","undefined","stats","activeRequestCount","requestQueue","requestMap","Map","deferredUpdate","get","scheduleRequest","handle","getPriority","Promise","resolve","done","has","request","priority","promise","push","set","_issueNewRequests","_issueRequest","isDone","delete","setTimeout","_issueNewRequestsAsync","freeSlots","Math","max","_updateAllRequests","i","shift","_updateRequest","splice","sort","a","b"],"sources":["../../../src/lib/request-utils/request-scheduler.ts"],"sourcesContent":["import {Stats} from '@probe.gl/stats';\n\ntype Handle = any;\ntype DoneFunction = () => any;\ntype GetPriorityFunction = () => number;\ntype RequestResult = {\n done: DoneFunction;\n} | null;\n\n/** RequestScheduler Options */\nexport type RequestSchedulerProps = {\n id?: string;\n throttleRequests?: boolean;\n maxRequests?: number;\n};\n\nconst STAT_QUEUED_REQUESTS = 'Queued Requests';\nconst STAT_ACTIVE_REQUESTS = 'Active Requests';\nconst STAT_CANCELLED_REQUESTS = 'Cancelled Requests';\nconst STAT_QUEUED_REQUESTS_EVER = 'Queued Requests Ever';\nconst STAT_ACTIVE_REQUESTS_EVER = 'Active Requests Ever';\n\nconst DEFAULT_PROPS: Required<RequestSchedulerProps> = {\n id: 'request-scheduler',\n // Specifies if the request scheduler should throttle incoming requests, mainly for comparative testing\n throttleRequests: true,\n // The maximum number of simultaneous active requests. Un-throttled requests do not observe this limit.\n maxRequests: 6\n};\n\n/** Tracks one request */\ntype Request = {\n handle: Handle;\n priority: number;\n getPriority: GetPriorityFunction;\n resolve?: (value: any) => any;\n};\n\n/**\n * Used to issue a request, without having them \"deeply queued\" by the browser.\n * @todo - Track requests globally, across multiple servers\n */\nexport default class RequestScheduler {\n readonly props: Required<RequestSchedulerProps>;\n readonly stats: Stats;\n activeRequestCount: number = 0;\n\n /** Tracks the number of active requests and prioritizes/cancels queued requests. */\n private requestQueue: Request[] = [];\n private requestMap: Map<Handle, Promise<RequestResult>> = new Map();\n private deferredUpdate: any = null;\n\n constructor(props: RequestSchedulerProps = {}) {\n this.props = {...DEFAULT_PROPS, ...props};\n\n // Returns the statistics used by the request scheduler.\n this.stats = new Stats({id: this.props.id});\n this.stats.get(STAT_QUEUED_REQUESTS);\n this.stats.get(STAT_ACTIVE_REQUESTS);\n this.stats.get(STAT_CANCELLED_REQUESTS);\n this.stats.get(STAT_QUEUED_REQUESTS_EVER);\n this.stats.get(STAT_ACTIVE_REQUESTS_EVER);\n }\n\n /**\n * Called by an application that wants to issue a request, without having it deeply queued by the browser\n *\n * When the returned promise resolved, it is OK for the application to issue a request.\n * The promise resolves to an object that contains a `done` method.\n * When the application's request has completed (or failed), the application must call the `done` function\n *\n * @param handle\n * @param getPriority will be called when request \"slots\" open up,\n * allowing the caller to update priority or cancel the request\n * Highest priority executes first, priority < 0 cancels the request\n * @returns a promise\n * - resolves to a object (with a `done` field) when the request can be issued without queueing,\n * - resolves to `null` if the request has been cancelled (by the callback return < 0).\n * In this case the application should not issue the request\n */\n scheduleRequest(\n handle: Handle,\n getPriority: GetPriorityFunction = () => 0\n ): Promise<RequestResult> {\n // Allows throttling to be disabled\n if (!this.props.throttleRequests) {\n return Promise.resolve({done: () => {}});\n }\n\n // dedupe\n if (this.requestMap.has(handle)) {\n return this.requestMap.get(handle) as Promise<any>;\n }\n\n const request: Request = {handle, priority: 0, getPriority};\n const promise = new Promise<RequestResult>((resolve) => {\n // @ts-ignore\n request.resolve = resolve;\n return request;\n });\n\n this.requestQueue.push(request);\n this.requestMap.set(handle, promise);\n this._issueNewRequests();\n return promise;\n }\n\n // PRIVATE\n\n _issueRequest(request: Request): Promise<any> {\n const {handle, resolve} = request;\n let isDone = false;\n\n const done = () => {\n // can only be called once\n if (!isDone) {\n isDone = true;\n\n // Stop tracking a request - it has completed, failed, cancelled etc\n this.requestMap.delete(handle);\n this.activeRequestCount--;\n // A slot just freed up, see if any queued requests are waiting\n this._issueNewRequests();\n }\n };\n\n // Track this request\n this.activeRequestCount++;\n\n return resolve ? resolve({done}) : Promise.resolve({done});\n }\n\n /** We check requests asynchronously, to prevent multiple updates */\n _issueNewRequests(): void {\n if (!this.deferredUpdate) {\n this.deferredUpdate = setTimeout(() => this._issueNewRequestsAsync(), 0);\n }\n }\n\n /** Refresh all requests */\n _issueNewRequestsAsync() {\n // TODO - shouldn't we clear the timeout?\n this.deferredUpdate = null;\n\n const freeSlots = Math.max(this.props.maxRequests - this.activeRequestCount, 0);\n\n if (freeSlots === 0) {\n return;\n }\n\n this._updateAllRequests();\n\n // Resolve pending promises for the top-priority requests\n for (let i = 0; i < freeSlots; ++i) {\n const request = this.requestQueue.shift();\n if (request) {\n this._issueRequest(request); // eslint-disable-line @typescript-eslint/no-floating-promises\n }\n }\n\n // Uncomment to debug\n // console.log(`${freeSlots} free slots, ${this.requestQueue.length} queued requests`);\n }\n\n /** Ensure all requests have updated priorities, and that no longer valid requests are cancelled */\n _updateAllRequests() {\n const requestQueue = this.requestQueue;\n for (let i = 0; i < requestQueue.length; ++i) {\n const request = requestQueue[i];\n if (!this._updateRequest(request)) {\n // Remove the element and make sure to adjust the counter to account for shortened array\n requestQueue.splice(i, 1);\n this.requestMap.delete(request.handle);\n i--;\n }\n }\n\n // Sort the remaining requests based on priority\n requestQueue.sort((a, b) => a.priority - b.priority);\n }\n\n /** Update a single request by calling the callback */\n _updateRequest(request) {\n request.priority = request.getPriority(request.handle); // eslint-disable-line callback-return\n\n // by returning a negative priority, the callback cancels the request\n if (request.priority < 0) {\n request.resolve(null);\n return false;\n }\n return true;\n }\n}\n"],"mappings":"AAAA,SAAQA,KAAK,QAAO,iBAAiB;AAgBrC,MAAMC,oBAAoB,GAAG,iBAAiB;AAC9C,MAAMC,oBAAoB,GAAG,iBAAiB;AAC9C,MAAMC,uBAAuB,GAAG,oBAAoB;AACpD,MAAMC,yBAAyB,GAAG,sBAAsB;AACxD,MAAMC,yBAAyB,GAAG,sBAAsB;AAExD,MAAMC,aAA8C,GAAG;EACrDC,EAAE,EAAE,mBAAmB;EAEvBC,gBAAgB,EAAE,IAAI;EAEtBC,WAAW,EAAE;AACf,CAAC;AAcD,eAAe,MAAMC,gBAAgB,CAAC;EAUpCC,WAAWA,CAAA,EAAoC;IAAA,IAAnCC,KAA4B,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAAA,KATpCD,KAAK;IAAA,KACLI,KAAK;IAAA,KACdC,kBAAkB,GAAW,CAAC;IAAA,KAGtBC,YAAY,GAAc,EAAE;IAAA,KAC5BC,UAAU,GAAwC,IAAIC,GAAG,CAAC,CAAC;IAAA,KAC3DC,cAAc,GAAQ,IAAI;IAGhC,IAAI,CAACT,KAAK,GAAG;MAAC,GAAGN,aAAa;MAAE,GAAGM;IAAK,CAAC;IAGzC,IAAI,CAACI,KAAK,GAAG,IAAIhB,KAAK,CAAC;MAACO,EAAE,EAAE,IAAI,CAACK,KAAK,CAACL;IAAE,CAAC,CAAC;IAC3C,IAAI,CAACS,KAAK,CAACM,GAAG,CAACrB,oBAAoB,CAAC;IACpC,IAAI,CAACe,KAAK,CAACM,GAAG,CAACpB,oBAAoB,CAAC;IACpC,IAAI,CAACc,KAAK,CAACM,GAAG,CAACnB,uBAAuB,CAAC;IACvC,IAAI,CAACa,KAAK,CAACM,GAAG,CAA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,EAAE;QAEjCZ,YAAY,CAAC8B,MAAM,CAACH,CAAC,EAAE,CAAC,CAAC;QACzB,IAAI,CAAC1B,UAAU,CAACmB,MAAM,CAACR,OAAO,CAACN,MAAM,CAAC;QACtCqB,CAAC,EAAE;MACL;IACF;IAGA3B,YAAY,CAAC+B,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAACnB,QAAQ,GAAGoB,CAAC,CAACpB,QAAQ,CAAC;EACtD;EAGAgB,cAAcA,CAACjB,OAAO,EAAE;IACtBA,OAAO,CAACC,QAAQ,GAAGD,OAAO,CAACL,WAAW,CAACK,OAAO,CAACN,MAAM,CAAC;IAGtD,IAAIM,OAAO,CAACC,QAAQ,GAAG,CAAC,EAAE;MACxBD,OAAO,CAACH,OAAO,CAAC,IAAI,CAAC;MACrB,OAAO,KAAK;IACd;IACA,OAAO,IAAI;EACb;AACF"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
1
|
export class DataSource {
|
|
3
2
|
constructor(props) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
this.fetch = void 0;
|
|
4
|
+
this.loadOptions = void 0;
|
|
5
|
+
this._needsRefresh = true;
|
|
6
|
+
this.props = void 0;
|
|
8
7
|
this.props = {
|
|
9
8
|
...props
|
|
10
9
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-source.js","names":["DataSource","constructor","props","fetch","loadOptions","_needsRefresh","getFetchFunction","setProps","Object","assign","setNeedsRefresh","getNeedsRefresh","clear","arguments","length","undefined","needsRefresh","options","fetchFunction","url","fetchOptions"],"sources":["../../../src/lib/sources/data-source.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {LoaderOptions} from '@loaders.gl/loader-utils';\n\n/** Common properties for all data sources */\nexport type DataSourceProps = {\n /** LoaderOptions provide an option to override `fetch`. Will also be passed to any sub loaders */\n loadOptions?: LoaderOptions;\n};\n\n/** base class of all data sources */\nexport abstract class DataSource<PropsT extends DataSourceProps = DataSourceProps> {\n /** A resolved fetch function extracted from loadOptions prop */\n fetch: (url: string, options?: RequestInit) => Promise<Response>;\n /** The actual load options, if calling a loaders.gl loader */\n loadOptions: LoaderOptions;\n _needsRefresh: boolean = true;\n\n props: PropsT;\n\n constructor(props: PropsT) {\n this.props = {...props};\n this.loadOptions = {...props.loadOptions};\n this.fetch = getFetchFunction(this.loadOptions);\n }\n\n setProps(props: PropsT) {\n this.props = Object.assign(this.props, props);\n // TODO - add a shallow compare to avoid setting refresh if no change?\n this.setNeedsRefresh();\n }\n\n /** Mark this data source as needing a refresh (redraw) */\n setNeedsRefresh(): void {\n this._needsRefresh = true;\n }\n\n /**\n * Does this data source need refreshing?\n * @note The specifics of the refresh mechanism depends on type of data source\n */\n getNeedsRefresh(clear: boolean = true) {\n const needsRefresh = this._needsRefresh;\n if (clear) {\n this._needsRefresh = false;\n }\n return needsRefresh;\n }\n}\n\n/**\n * Gets the current fetch function from options\n * @todo - move to loader-utils module\n * @todo - use in core module counterpart\n * @param options\n * @param context\n */\nexport function getFetchFunction(options?: LoaderOptions) {\n const fetchFunction = options?.fetch;\n\n // options.fetch can be a function\n if (fetchFunction && typeof fetchFunction === 'function') {\n return (url: string, fetchOptions?: RequestInit) => fetchFunction(url, fetchOptions);\n }\n\n // options.fetch can be an options object, use global fetch with those options\n const fetchOptions = options?.fetch;\n if (fetchOptions && typeof fetchOptions !== 'function') {\n return (url) => fetch(url, fetchOptions);\n }\n\n // else return the global fetch function\n return (url) => fetch(url);\n}\n"],"mappings":"AAWA,OAAO,MAAeA,UAAU,CAAmD;EASjFC,WAAWA,CAACC,KAAa,EAAE;IAAA,KAP3BC,KAAK;IAAA,KAELC,WAAW;IAAA,KACXC,aAAa,GAAY,IAAI;IAAA,KAE7BH,KAAK;IAGH,IAAI,CAACA,KAAK,GAAG;MAAC,GAAGA;IAAK,CAAC;I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.js","names":["DataSource","ImageSource","type","testURL","url"],"sources":["../../../src/lib/sources/image-source.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {DataSourceProps} from './data-source';\nimport {DataSource} from './data-source';\nimport {ImageType} from './utils/image-type';\n\n/**\n * Normalized capabilities of an Image service\n * @example\n * The WMSService will normalize the response to the WMS `GetCapabilities`\n * data structure extracted from WMS XML response into an ImageSourceMetadata.\n */\nexport type ImageSourceMetadata = {\n name: string;\n title?: string;\n abstract?: string;\n keywords: string[];\n layers: ImageSourceLayer[];\n};\n\n/** Description of one data layer in the image source */\nexport type ImageSourceLayer = {\n /** Name of this layer */\n name?: string;\n /** Human readable title of this layer */\n title?: string;\n /** Coordinate systems supported by this layer */\n crs?: string[];\n /** layer limits in unspecified CRS:84-like lng/lat, for quick access w/o CRS calculations. */\n geographicBoundingBox?: [min: [x: number, y: number], max: [x: number, y: number]];\n /** Sub layers of this layer */\n layers?: ImageSourceLayer[];\n\n /** @deprecated from v3.4: non-vis.gl style bounding box. Use `.geographicBoundingBox` instead */\n boundingBox?: [number, number, number, number];\n};\n\n/** Generic parameters for requesting an image from an image source */\nexport type GetImageParameters = {\n /** Layers to render */\n layers: string | string[];\n /** Styling */\n styles?: unknown;\n /** bounding box of the requested map image */\n bbox: [number, number, number, number];\n /** pixel width of returned image */\n width: number;\n /** pixels */\n height: number;\n /** crs for the image (not the bounding box) */\n crs?: string;\n /** requested format for the return image */\n format?: 'image/png';\n};\n\n// Attempt to break down GetImageParameters\nexport type ImageFilters = {\n /** Layers to render */\n layers: string | string[];\n /** Styling */\n styles?: unknown;\n};\n\nexport type ImageRegion = {\n /** bounding box of the requested map image */\n bbox: [number, number, number, number];\n};\n\nexport type ImageFormat = {\n /** pixel width of returned image */\n width: number;\n /** pixels */\n height: number;\n /** crs for the image (not the bounding box) */\n crs?: string;\n /** requested format for the return image */\n format?: 'image/png';\n};\n\nexport type ImageSourceProps = DataSourceProps;\n\n/**\n * MapImageSource - data sources that allow data to be queried by (geospatial) extents\n * @note\n * - If geospatial, bounding box is expected to be in web mercator coordinates\n */\nexport abstract class ImageSource<\n PropsT extends ImageSourceProps = ImageSourceProps\n> extends DataSource<PropsT> {\n static type: string = 'template';\n static testURL = (url: string): boolean => false;\n\n abstract getMetadata(): Promise<ImageSourceMetadata>;\n abstract getImage(parameters: GetImageParameters): Promise<ImageType>;\n}\n"],"mappings":"SAGQA,UAAU;AAmFlB,OAAO,MAAeC,WAAW,SAEvBD,UAAU,CAAS;AAFPC,WAAW,CAGxBC,IAAI,GAAW,UAAU;AAHZD,WAAW,CAIxBE,OAAO,GAAIC,GAAW,IAAc,KAAK"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-tile-source.js","names":[],"sources":["../../../src/lib/sources/image-tile-source.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {ImageType} from './utils/image-type';\nimport type {TileSource, TileSourceMetadata} from './tile-source';\nimport type {GetTileParameters} from './tile-source';\n\n/**\n * MapTileSource - data sources that allow data to be queried by (geospatial) tile\n * @note If geospatial, bounding box is expected to be in web mercator coordinates\n */\nexport interface ImageTileSource<MetadataT extends TileSourceMetadata = TileSourceMetadata>\n extends TileSource<MetadataT> {\n getImageTile(parameters: GetTileParameters): Promise<ImageType | null>;\n}\n"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tile-source.js","names":[],"sources":["../../../src/lib/sources/tile-source.ts"],"sourcesContent":["// loaders.gl, MIT license\n\n/**\n * Normalized capabilities of an Image service\n * Sources are expected to normalize the response to capabilities\n * @example\n * A WMS service would normalize the response to the WMS `GetCapabilities` data structure extracted from WMS XML response\n * into an TileSourceMetadata.\n */\nexport type TileSourceMetadata = {\n format?: string;\n formatHeader?: unknown;\n\n /** Name of the tileset (extracted from JSON metadata if available) */\n name?: string;\n title?: string;\n abstract?: string;\n keywords?: string[];\n /** Attribution string (extracted from JSON metadata if available) */\n attributions?: string[];\n\n /** Minimal zoom level of tiles in this tileset */\n minZoom?: number;\n /** Maximal zoom level of tiles in this tileset */\n maxZoom?: number;\n /** Bounding box of tiles in this tileset `[[w, s], [e, n]]` */\n boundingBox?: [min: [x: number, y: number], max: [x: number, y: number]];\n\n /** Layer information */\n layer?: {\n name: string;\n title?: string;\n srs?: string[];\n boundingBox?: [number, number, number, number];\n layers: TileSourceLayer[];\n };\n};\n\n/**\n * Description of one data layer in the image source\n */\nexport type TileSourceLayer = {\n name: string;\n title?: string;\n srs?: string[];\n boundingBox?: [number, number, number, number];\n layers: TileSourceLayer[];\n};\n\n/**\n * Generic parameters for requesting an image from an image source\n */\nexport type GetTileParameters = {\n /** Layers to render */\n layers: string | string[];\n /** Styling */\n styles?: unknown;\n /** bounding box of the requested map image */\n zoom: number;\n /** tile x coordinate */\n x: number;\n /** tile y coordinate */\n y: number;\n /** srs for the image (not the bounding box) */\n srs?: string;\n /** requested format for the return image */\n format?: 'image/png';\n};\n\nexport type TileLoadParameters = {\n index: {x: number; y: number; z: number};\n id: string;\n bbox: TileBoundingBox;\n zoom?: number;\n url?: string | null;\n signal?: AbortSignal;\n userData?: Record<string, any>;\n};\n\n/** deck.gl compatible bounding box */\nexport type TileBoundingBox = NonGeoBoundingBox | GeoBoundingBox;\nexport type GeoBoundingBox = {west: number; north: number; east: number; south: number};\nexport type NonGeoBoundingBox = {left: number; top: number; right: number; bottom: number};\n\n/**\n * Props for a TileSource\n */\nexport type TileSourceProps = {};\n\n/**\n * MapTileSource - data sources that allow data to be queried by (geospatial) extents\n * @note\n * - If geospatial, bounding box is expected to be in web mercator coordinates\n */\nexport interface TileSource<MetadataT extends TileSourceMetadata> {\n getMetadata(): Promise<MetadataT>;\n /** Flat parameters */\n getTile(parameters: GetTileParameters): Promise<unknown>;\n /** deck.gl style parameters */\n getTileData(parameters: TileLoadParameters): Promise<unknown | null>;\n}\n"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-type.js","names":[],"sources":["../../../../src/lib/sources/utils/image-type.ts"],"sourcesContent":["/** Supported Image Types @note duplicates definition in images/schema to avoid circular deps */\nexport type ImageType = ImageBitmap | ImageDataType | HTMLImageElement;\n\n/** data images @note duplicates definition in images/schema to avoid circular deps */\nexport type ImageDataType = {\n data: Uint8Array;\n width: number;\n height: number;\n compressed?: boolean;\n};\n"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","names":["getFetchFunction","options","fetchFunction","fetch","url","fetchOptions","mergeImageServiceProps","props","loadOptions"],"sources":["../../../../src/lib/sources/utils/utils.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {LoaderOptions} from '@loaders.gl/loader-utils';\n\n/**\n * Gets the current fetch function from options\n * @todo - move to loader-utils module\n * @todo - use in core module counterpart\n * @param options\n * @param context\n */\nexport function getFetchFunction(options?: LoaderOptions) {\n const fetchFunction = options?.fetch;\n\n // options.fetch can be a function\n if (fetchFunction && typeof fetchFunction === 'function') {\n return (url: string, fetchOptions?: RequestInit) => fetchFunction(url, fetchOptions);\n }\n\n // options.fetch can be an options object, use global fetch with those options\n const fetchOptions = options?.fetch;\n if (fetchOptions && typeof fetchOptions !== 'function') {\n return (url) => fetch(url, fetchOptions);\n }\n\n // else return the global fetch function\n return (url) => fetch(url);\n}\n\nexport function mergeImageServiceProps<Props extends {loadOptions?: any}>(\n props: Props\n): Required<Props> {\n // @ts-expect-error\n return {\n // Default fetch\n ...props,\n loadOptions: {\n ...props.loadOptions,\n fetch: getFetchFunction(props.loadOptions)\n }\n };\n}\n"],"mappings":"AAWA,OAAO,SAASA,gBAAgBA,CAACC,OAAuB,EAAE;EACxD,MAAMC,aAAa,GAAGD,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEE,KAAK;EAGpC,IAAID,aAAa,IAAI,OAAOA,aAAa,KAAK,UAAU,EAAE;IACxD,OAAO,CAACE,GAAW,EAAEC,YAA0B,KAAKH,aAAa,CAACE,GAAG,EAAEC,YAAY,CAAC;EACtF;EAGA,MAAMA,YAAY,GAAGJ,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEE,KAAK;EACnC,IAAIE,YAAY,IAAI,OAAOA,YAAY,KAAK,UAAU,EAAE;IACtD,OAAQD,GAAG,IAAKD,KAAK,CAACC,GAAG,EAAEC,YAAY,CAAC;EAC1C;EAGA,OAAQD,GAAG,IAAKD,KAAK,CAACC,GAAG,CAAC;AAC5B;AAEA,OAAO,SAASE,sBAAsBA,CACpCC,KAAY,EACK;EAEjB,OAAO;IAEL,GAAGA,KAAK;IACRC,WAAW,EAAE;MACX,GAAGD,KAAK,CAACC,WAAW;MACpBL,KAAK,EAAEH,gBAAgB,CAACO,KAAK,CAACC,WAAW;IAC3C;EACF,CAAC;AACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vector-tile-source.js","names":[],"sources":["../../../src/lib/sources/vector-tile-source.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport {TileSource, TileSourceMetadata} from './tile-source';\nimport {GetTileParameters} from './tile-source';\n\n/**\n * MapTileSource - data sources that allow data to be queried by (geospatial) tile\n * @note If geospatial, bounding box is expected to be in web mercator coordinates\n */\nexport interface VectorTileSource<MetadataT extends TileSourceMetadata = TileSourceMetadata>\n extends TileSource<MetadataT> {\n getVectorTile(parameters: GetTileParameters): Promise<unknown | null>;\n}\n"],"mappings":""}
|
|
@@ -81,7 +81,7 @@ async function parseData(_ref) {
|
|
|
81
81
|
data = textDecoder.decode(arrayBuffer);
|
|
82
82
|
parser = loader.parseTextSync;
|
|
83
83
|
} else {
|
|
84
|
-
throw new Error(
|
|
84
|
+
throw new Error(`Could not load data with ${loader.name} loader`);
|
|
85
85
|
}
|
|
86
86
|
options = {
|
|
87
87
|
...options,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-loader-worker.js","names":["WorkerBody","requestId","createLoaderWorker","loader","inWorkerThread","onmessage","type","payload","input","options","context","result","parseData","arrayBuffer","_parse","parseOnMainThread","postMessage","error","message","Error","Promise","resolve","reject","id","onMessage","removeEventListener","addEventListener","_ref","data","parser","parseSync","parse","parseTextSync","textDecoder","TextDecoder","decode","name","modules","worker"],"sources":["../../../src/lib/worker-loader-utils/create-loader-worker.ts"],"sourcesContent":["/* eslint-disable no-restricted-globals */\nimport type {LoaderWithParser, LoaderOptions, LoaderContext} from '../../loader-types';\nimport {WorkerBody} from '@loaders.gl/worker-utils';\n// import {validateLoaderVersion} from './validate-loader-version';\n\nlet requestId = 0;\n\n/**\n * Set up a WebWorkerGlobalScope to talk with the main thread\n * @param loader\n */\nexport function createLoaderWorker(loader: LoaderWithParser) {\n // Check that we are actually in a worker thread\n if (!WorkerBody.inWorkerThread()) {\n return;\n }\n\n WorkerBody.onmessage = async (type, payload) => {\n switch (type) {\n case 'process':\n try {\n // validateLoaderVersion(loader, data.source.split('@')[1]);\n\n const {input, options = {}, context = {}} = payload;\n\n const result = await parseData({\n loader,\n arrayBuffer: input,\n options,\n // @ts-expect-error fetch missing\n context: {\n ...context,\n _parse: parseOnMainThread\n }\n });\n WorkerBody.postMessage('done', {result});\n } catch (error) {\n const message = error instanceof Error ? error.message : '';\n WorkerBody.postMessage('error', {error: message});\n }\n break;\n default:\n }\n };\n}\n\nfunction parseOnMainThread(\n arrayBuffer: ArrayBuffer,\n loader: any,\n options?: LoaderOptions,\n context?: LoaderContext\n): Promise<void> {\n return new Promise((resolve, reject) => {\n const id = requestId++;\n\n /**\n */\n const onMessage = (type, payload) => {\n if (payload.id !== id) {\n // not ours\n return;\n }\n\n switch (type) {\n case 'done':\n WorkerBody.removeEventListener(onMessage);\n resolve(payload.result);\n break;\n\n case 'error':\n WorkerBody.removeEventListener(onMessage);\n reject(payload.error);\n break;\n\n default:\n // ignore\n }\n };\n\n WorkerBody.addEventListener(onMessage);\n\n // Ask the main thread to decode data\n const payload = {id, input: arrayBuffer, options};\n WorkerBody.postMessage('process', payload);\n });\n}\n\n// TODO - Support byteOffset and byteLength (enabling parsing of embedded binaries without copies)\n// TODO - Why not support async loader.parse* funcs here?\n// TODO - Why not reuse a common function instead of reimplementing loader.parse* selection logic? Keeping loader small?\n// TODO - Lack of appropriate parser functions can be detected when we create worker, no need to wait until parse\nasync function parseData({\n loader,\n arrayBuffer,\n options,\n context\n}: {\n loader: LoaderWithParser;\n arrayBuffer: ArrayBuffer;\n options: LoaderOptions;\n context: LoaderContext;\n}) {\n let data;\n let parser;\n if (loader.parseSync || loader.parse) {\n data = arrayBuffer;\n parser = loader.parseSync || loader.parse;\n } else if (loader.parseTextSync) {\n const textDecoder = new TextDecoder();\n data = textDecoder.decode(arrayBuffer);\n parser = loader.parseTextSync;\n } else {\n throw new Error(`Could not load data with ${loader.name} loader`);\n }\n\n // TODO - proper merge in of loader options...\n options = {\n ...options,\n modules: (loader && loader.options && loader.options.modules) || {},\n worker: false\n };\n\n return await parser(data, {...options}, context, loader);\n}\n"],"mappings":"AAEA,SAAQA,UAAU,QAAO,0BAA0B;AAGnD,IAAIC,SAAS,GAAG,CAAC;AAMjB,OAAO,SAASC,kBAAkBA,CAACC,MAAwB,EAAE;EAE3D,IAAI,CAACH,UAAU,CAACI,cAAc,CAAC,CAAC,EAAE;IAChC;EACF;EAEAJ,UAAU,CAACK,SAAS,GAAG,OAAOC,IAAI,EAAEC,OAAO,KAAK;IAC9C,QAAQD,IAAI;MACV,KAAK,SAAS;QACZ,IAAI;UAGF,MAAM;YAACE,KAAK;YAAEC,OAAO,GAAG,CAAC,CAAC;YAAEC,OAAO,GAAG,CAAC;UAAC,CAAC,GAAGH,OAAO;UAEnD,MAAMI,MAAM,GAAG,MAAMC,SAAS,CAAC;YAC7BT,MAAM;YACNU,WAAW,EAAEL,KAAK;YAClBC,OAAO;YAEPC,OAAO,EAAE;cACP,GAAGA,OAAO;cACVI,MAAM,EAAEC;YACV;UACF,CAAC,CAAC;UACFf,UAAU,CAACgB,WAAW,CAAC,MAAM,EAAE;YAACL;UAAM,CAAC,CAAC;QAC1C,C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M,CAAC4B,KAAK,EAAE;IACpCH,IAAI,GAAGf,WAAW;IAClBgB,MAAM,GAAG1B,MAAM,CAAC2B,SAAS,IAAI3B,MAAM,CAAC4B,KAAK;EAC3C,CAAC,MAAM,IAAI5B,MAAM,CAAC6B,aAAa,EAAE;IAC/B,MAAMC,WAAW,GAAG,IAAIC,WAAW,CAAC,CAAC;IACrCN,IAAI,GAAGK,WAAW,CAACE,MAAM,CAACtB,WAAW,CAAC;IACtCgB,MAAM,GAAG1B,MAAM,CAAC6B,aAAa;EAC/B,CAAC,MAAM;IACL,MAAM,IAAIb,KAAK,CAAE,4BAA2BhB,MAAM,CAACiC,IAAK,SAAQ,CAAC;EACnE;EAGA3B,OAAO,GAAG;IACR,GAAGA,OAAO;IACV4B,OAAO,EAAGlC,MAAM,IAAIA,MAAM,CAACM,OAAO,IAAIN,MAAM,CAACM,OAAO,CAAC4B,OAAO,IAAK,CAAC,CAAC;IACnEC,MAAM,EAAE;EACV,CAAC;EAED,OAAO,MAAMT,MAAM,CAACD,IAAI,EAAE;IAAC,GAAGnB;EAAO,CAAC,EAAEC,OAAO,EAAEP,MAAM,CAAC;AAC1D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encode-with-worker.js","names":["WorkerFarm","isBrowser","canEncodeWithWorker","writer","options","isSupported","_nodeWorkers","worker"],"sources":["../../../src/lib/worker-loader-utils/encode-with-worker.ts"],"sourcesContent":["import {WorkerFarm} from '@loaders.gl/worker-utils';\nimport {Writer, WriterOptions} from '../../writer-types';\nimport {isBrowser} from '../env-utils/globals';\n\n/**\n * Determines if a loader can parse with worker\n * @param loader\n * @param options\n */\nexport function canEncodeWithWorker(writer: Writer, options?: WriterOptions) {\n if (!WorkerFarm.isSupported()) {\n return false;\n }\n\n // Node workers are still experimental\n if (!isBrowser && !options?._nodeWorkers) {\n return false;\n }\n\n return writer.worker && options?.worker;\n}\n"],"mappings":"AAAA,SAAQA,UAAU,QAAO,0BAA0B;AAAC,SAE5CC,SAAS;AAOjB,OAAO,SAASC,mBAAmBA,CAACC,MAAc,EAAEC,OAAuB,EAAE;EAC3E,IAAI,CAACJ,UAAU,CAACK,WAAW,CAAC,CAAC,EAAE;IAC7B,OAAO,KAAK;EACd;EAGA,IAAI,CAACJ,SAAS,IAAI,EAACG,OAAO,aAAPA,OAAO,eAAPA,OAAO,CAAEE,YAAY,GAAE;IACxC,OAAO,KAAK;EACd;EAEA,OAAOH,MAAM,CAACI,MAAM,KAAIH,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEG,MAAM;AACzC"}
|
|
@@ -57,7 +57,7 @@ async function onMessage(parseOnMainThread, job, type, payload) {
|
|
|
57
57
|
}
|
|
58
58
|
break;
|
|
59
59
|
default:
|
|
60
|
-
console.warn(
|
|
60
|
+
console.warn(`parse-with-worker unknown message ${type}`);
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
//# sourceMappingURL=parse-with-worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-with-worker.js","names":["isBrowser","WorkerFarm","getWorkerURL","canParseWithWorker","loader","options","isSupported","_nodeWorkers","worker","parseWithWorker","data","context","parseOnMainThread","name","id","url","workerFarm","getWorkerFarm","workerPool","getWorkerPool","JSON","parse","stringify","job","startJob","onMessage","bind","postMessage","input","result","type","payload","done","error","Error","message","console","warn"],"sources":["../../../src/lib/worker-loader-utils/parse-with-worker.ts"],"sourcesContent":["import {\n WorkerJob,\n WorkerMessageType,\n WorkerMessagePayload,\n isBrowser\n} from '@loaders.gl/worker-utils';\nimport type {Loader, LoaderOptions, LoaderContext} from '../../loader-types';\nimport {WorkerFarm, getWorkerURL} from '@loaders.gl/worker-utils';\n\n/**\n * Determines if a loader can parse with worker\n * @param loader\n * @param options\n */\nexport function canParseWithWorker(loader: Loader, options?: LoaderOptions) {\n if (!WorkerFarm.isSupported()) {\n return false;\n }\n\n // Node workers are still experimental\n if (!isBrowser && !options?._nodeWorkers) {\n return false;\n }\n\n return loader.worker && options?.worker;\n}\n\n/**\n * this function expects that the worker function sends certain messages,\n * this can be automated if the worker is wrapper by a call to createLoaderWorker in @loaders.gl/loader-utils.\n */\nexport async function parseWithWorker(\n loader: Loader,\n data: any,\n options?: LoaderOptions,\n context?: LoaderContext,\n parseOnMainThread?: (arrayBuffer: ArrayBuffer, options: {[key: string]: any}) => Promise<unknown>\n) {\n const name = loader.id; // TODO\n const url = getWorkerURL(loader, options);\n\n const workerFarm = WorkerFarm.getWorkerFarm(options);\n const workerPool = workerFarm.getWorkerPool({name, url});\n\n // options.log object contains functions which cannot be transferred\n // context.fetch & context.parse functions cannot be transferred\n // TODO - decide how to handle logging on workers\n options = JSON.parse(JSON.stringify(options));\n context = JSON.parse(JSON.stringify(context || {}));\n\n const job = await workerPool.startJob(\n 'process-on-worker',\n // @ts-expect-error\n onMessage.bind(null, parseOnMainThread) // eslint-disable-line @typescript-eslint/no-misused-promises\n );\n\n job.postMessage('process', {\n // @ts-ignore\n input: data,\n options,\n context\n });\n\n const result = await job.result;\n // TODO - what is going on here?\n return await result.result;\n}\n\n/**\n * Handle worker's responses to the main thread\n * @param job\n * @param type\n * @param payload\n */\nasync function onMessage(\n parseOnMainThread: (arrayBuffer: ArrayBuffer, options?: {[key: string]: any}) => Promise<void>,\n job: WorkerJob,\n type: WorkerMessageType,\n payload: WorkerMessagePayload\n) {\n switch (type) {\n case 'done':\n job.done(payload);\n break;\n\n case 'error':\n job.error(new Error(payload.error));\n break;\n\n case 'process':\n // Worker is asking for main thread to parseO\n const {id, input, options} = payload;\n try {\n const result = await parseOnMainThread(input, options);\n job.postMessage('done', {id, result});\n } catch (error) {\n const message = error instanceof Error ? error.message : 'unknown error';\n job.postMessage('error', {id, error: message});\n }\n break;\n\n default:\n // eslint-disable-next-line\n console.warn(`parse-with-worker unknown message ${type}`);\n }\n}\n"],"mappings":"AAAA,SAIEA,SAAS,QACJ,0BAA0B;AAEjC,SAAQC,UAAU,EAAEC,YAAY,QAAO,0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AAM;AAC5B;AAQA,eAAeJ,SAASA,CACtBb,iBAA8F,EAC9FW,GAAc,EACdO,IAAuB,EACvBC,OAA6B,EAC7B;EACA,QAAQD,IAAI;IACV,KAAK,MAAM;MACTP,GAAG,CAACS,IAAI,CAACD,OAAO,CAAC;MACjB;IAEF,KAAK,OAAO;MACVR,GAAG,CAACU,KAAK,CAAC,IAAIC,KAAK,CAACH,OAAO,CAACE,KAAK,CAAC,CAAC;MACnC;IAEF,KAAK,SAAS;MAEZ,MAAM;QAACnB,EAAE;QAAEc,KAAK;QAAEvB;MAAO,CAAC,GAAG0B,OAAO;MACpC,IAAI;QACF,MAAMF,MAAM,GAAG,MAAMjB,iBAAiB,CAACgB,KAAK,EAAEvB,OAAO,CAAC;QACtDkB,GAAG,CAACI,WAAW,CAAC,MAAM,EAAE;UAACb,EAAE;UAAEe;QAAM,CAAC,CAAC;MACvC,CAAC,CAAC,OAAOI,KAAK,EAAE;QACd,MAAME,OAAO,GAAGF,KAAK,YAAYC,KAAK,GAAGD,KAAK,CAACE,OAAO,GAAG,eAAe;QACxEZ,GAAG,CAACI,WAAW,CAAC,OAAO,EAAE;UAACb,EAAE;UAAEmB,KAAK,EAAEE;QAAO,CAAC,CAAC;MAChD;MACA;IAEF;MAEEC,OAAO,CAACC,IAAI,CAAE,qCAAoCP,IAAK,EAAC,CAAC;EAC7D;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader-types.js","names":["parseFromContext","data","loaders","options","context","_parse","parseSyncFromContext","loader","_parseSync","Error","parseInBatchesFromContext","_parseInBatches"],"sources":["../src/loader-types.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport {\n FetchLike,\n TransformBatches /* , DataType, SyncDataType, BatchableDataType */\n} from './types';\n\n// LOADERS\n\n/**\n * Core Loader Options\n */\nexport type LoaderOptions = {\n /** fetch options or a custom fetch function */\n fetch?: typeof fetch | FetchLike | RequestInit | null;\n /** Do not throw on errors */\n nothrow?: boolean;\n\n /** loader selection, search first for supplied mimeType */\n mimeType?: string;\n /** loader selection, provide fallback mimeType is server does not provide */\n fallbackMimeType?: string;\n /** loader selection, avoid searching registered loaders */\n ignoreRegisteredLoaders?: boolean;\n\n // general\n /** Experimental: Supply a logger to the parser */\n log?: any;\n /** Force to load WASM libraries from local file system in NodeJS or from loaders.gl CDN in a web browser */\n useLocalLibraries?: boolean;\n\n // batched parsing\n\n /** Size of each batch. `auto` matches batches to size of incoming chunks */\n batchSize?: number | 'auto';\n /** Minimal amount of time between batches */\n batchDebounceMs?: number;\n /** Stop loading after a given number of rows (compare SQL limit clause) */\n limit?: 0;\n /** Experimental: Stop loading after reaching */\n _limitMB?: 0;\n /** Generate metadata batches */\n metadata?: boolean;\n /** Transforms to run on incoming batches */\n transforms?: TransformBatches[];\n\n // workers\n\n /** CDN load workers from */\n CDN?: string | null;\n /** Set to `false` to disable workers */\n worker?: boolean;\n /** Number of concurrent workers (per loader) on desktop browser */\n maxConcurrency?: number;\n /** Number of concurrent workers (per loader) on mobile browsers */\n maxMobileConcurrency?: number;\n /** Set to `false` to prevent reuse workers */\n reuseWorkers?: boolean;\n /** Whether to use workers under Node.js (experimental) */\n _nodeWorkers?: boolean;\n /** set to 'test' to run local worker */\n _workerType?: string;\n\n /** @deprecated `options.batchType` removed, Use `options.<loader>.type` instead */\n batchType?: 'row' | 'columnar' | 'arrow';\n /** @deprecated `options.throw removed`, Use `options.nothrow` instead */\n throws?: boolean;\n /** @deprecated `options.dataType` no longer used */\n dataType?: never;\n /** @deprecated `options.uri` no longer used */\n uri?: never;\n /** @deprecated `options.method` removed. Use `options.fetch.method` */\n method?: never;\n /** @deprecated `options.headers` removed. Use `options.fetch.headers` */\n headers?: never;\n /** @deprecated `options.body` removed. Use `options.fetch.body` */\n body?: never;\n /** @deprecated `options.mode` removed. Use `options.fetch.mode` */\n mode?: never;\n /** @deprecated `options.credentials` removed. Use `options.fetch.credentials` */\n credentials?: never;\n /** @deprecated `options.cache` removed. Use `options.fetch.cache` */\n cache?: never;\n /** @deprecated `options.redirect` removed. Use `options.fetch.redirect` */\n redirect?: never;\n /** @deprecated `options.referrer` removed. Use `options.fetch.referrer` */\n referrer?: never;\n /** @deprecated `options.referrerPolicy` removed. Use `options.fetch.referrerPolicy` */\n referrerPolicy?: never;\n /** @deprecated `options.integrity` removed. Use `options.fetch.integrity` */\n integrity?: never;\n /** @deprecated `options.keepalive` removed. Use `options.fetch.keepalive` */\n keepalive?: never;\n /** @deprecated `options.signal` removed. Use `options.fetch.signal` */\n signal?: never;\n\n // Accept other keys (loader options objects, e.g. `options.csv`, `options.json` ...)\n [loaderId: string]: unknown;\n};\n\ntype PreloadOptions = {\n [key: string]: unknown;\n};\n\n/**\n * A worker loader definition that can be used with `@loaders.gl/core` functions\n */\nexport type Loader<DataT = any, BatchT = any, LoaderOptionsT = LoaderOptions> = {\n /** The result type of this loader */\n dataType?: DataT;\n /** The batched result type of this loader */\n batchType?: BatchT;\n\n /** Default Options */\n options: LoaderOptionsT;\n /** Deprecated Options */\n deprecatedOptions?: Record<string, string | Record<string, string>>;\n\n /** Human readable name */\n name: string;\n /** id should be the same as the field used in LoaderOptions */\n id: string;\n /** module is used to generate worker threads, need to be the module directory name */\n module: string;\n /** Version should be injected by build tools */\n version: string;\n /** A boolean, or a URL */\n worker?: string | boolean;\n // end Worker\n\n /** Which category does this loader belong to */\n category?: string;\n /** File extensions that are potential matches with this loader. */\n extensions: string[];\n /** MIMETypes that indicate a match with this loader. @note Some MIMETypes are generic and supported by many loaders */\n mimeTypes: string[];\n\n /** Is the input of this loader binary */\n binary?: boolean;\n /** Is the input of this loader text */\n text?: boolean;\n\n /** Test some initial bytes of content to see if this loader might be a match */\n tests?: (((ArrayBuffer: ArrayBuffer) => boolean) | ArrayBuffer | string)[];\n\n /** @deprecated */\n supported?: boolean;\n /** @deprecated */\n testText?: (string: string) => boolean;\n};\n\n/**\n * A \"bundled\" loader definition that can be used with `@loaders.gl/core` functions\n * If a worker loader is supported it will also be supported.\n */\nexport type LoaderWithParser<DataT = any, BatchT = any, LoaderOptionsT = LoaderOptions> = Loader<\n DataT,\n BatchT,\n LoaderOptionsT\n> & {\n /** Perform actions before load. @deprecated Not officially supported. */\n preload?: Preload;\n /** Parse atomically from an arraybuffer asynchronously */\n parse: (\n arrayBuffer: ArrayBuffer,\n options?: LoaderOptionsT,\n context?: LoaderContext\n ) => Promise<DataT>;\n parseFile?: (file: Blob, options?: LoaderOptionsT, context?: LoaderContext) => Promise<DataT>;\n /** Parse atomically from an arraybuffer synchronously */\n parseSync?: (\n arrayBuffer: ArrayBuffer,\n options?: LoaderOptionsT,\n context?: LoaderContext\n ) => DataT;\n /** Parse atomically from a string asynchronously */\n parseText?: (text: string, options?: LoaderOptionsT, context?: LoaderContext) => Promise<DataT>;\n /** Parse atomically from a string synchronously */\n parseTextSync?: (text: string, options?: LoaderOptionsT, context?: LoaderContext) => DataT;\n /** Parse batches of data from an iterator, return an iterator that yield parsed batches. */\n parseInBatches?: (\n iterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>,\n options?: LoaderOptionsT,\n context?: LoaderContext\n ) => AsyncIterable<BatchT>;\n /** Like `parseInBatches` for loaders that don't integrate with fetch. @deprecated Not officially supported. */\n parseFileInBatches?: (\n file: Blob,\n options?: LoaderOptionsT,\n context?: LoaderContext\n ) => AsyncIterable<BatchT>;\n};\n\n/**\n * A Loader context is provided as a third parameters to a loader object's\n * parse functions when that loader is called by other loaders rather then\n * directly by the application.\n *\n * - The context object allows the subloaders to be aware of the parameters and\n * options that the application provided in the top level call.\n * - The context also providedsaccess to parse functions so that the subloader\n * does not need to include the core module.\n * - In addition, the context's parse functions may also redirect loads from worker\n * threads back to main thread.\n */\nexport type LoaderContext = {\n /** Loader list provided to top-level loader call plus any sub loaders */\n loaders?: Loader[] | null;\n /** If URL is available. */\n url?: string;\n /** the file name component of the URL (leading path and query string removed) */\n filename?: string;\n /** the directory name component of the URL (leading path excluding file name and query string) */\n baseUrl?: string;\n /** Query string (characters after `?`) */\n queryString?: string;\n\n /** Provides access to any application overrides of fetch() */\n fetch: typeof fetch | FetchLike;\n\n /** TBD */\n response?: Response;\n\n /**\n * Parse function for subloaders. Avoids importing `core`. In workers, may redirect to main thread\n */\n _parse: (\n arrayBuffer: ArrayBuffer,\n loaders?: Loader | Loader[] | LoaderOptions,\n options?: LoaderOptions,\n context?: LoaderContext\n ) => Promise<any>;\n\n /**\n * ParseSync function. Avoids importing `core`. In workers, may redirect to main thread\n * @deprecated Do not call directly, use `parseSyncFromContext` instead\n */\n _parseSync?: (\n arrayBuffer: ArrayBuffer,\n loaders?: Loader | Loader[] | LoaderOptions,\n options?: LoaderOptions,\n context?: LoaderContext\n ) => any;\n\n /**\n * ParseInBatches function. Avoids importing `core`.\n * @deprecated Do not call directly, use `parseInBatchesFromContext` instead\n */\n _parseInBatches?: (\n iterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer> | Response,\n loaders?: Loader | Loader[] | LoaderOptions,\n options?: LoaderOptions,\n context?: LoaderContext\n ) => AsyncIterable<any> | Promise<AsyncIterable<any>>;\n};\n\n// type Parse = (\n// arrayBuffer: ArrayBuffer,\n// options?: LoaderOptions,\n// context?: LoaderContext\n// ) => Promise<any>;\n// type ParseSync = (\n// arrayBuffer: ArrayBuffer,\n// options?: LoaderOptions,\n// context?: LoaderContext\n// ) => any;\n// type ParseText = (text: string, options?: LoaderOptions) => Promise<any>;\n// type ParseTextSync = (text: string, options?: LoaderOptions) => any;\n// type ParseInBatches = (\n// iterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>,\n// options?: LoaderOptions,\n// context?: LoaderContext\n// ) => AsyncIterable<any>;\n// type ParseFileInBatches = (\n// file: Blob,\n// options?: LoaderOptions,\n// context?: LoaderContext\n// ) => AsyncIterable<any>;\n\ntype Preload = (url: string, options?: PreloadOptions) => any;\n\n/** Typescript helper to extract options type from a generic loader type */\nexport type LoaderOptionsType<T = Loader> = T extends Loader<any, any, infer Options>\n ? Options\n : never;\n/** Typescript helper to extract data type from a generic loader type */\nexport type LoaderReturnType<T = Loader> = T extends Loader<infer Return, any, any>\n ? Return\n : never;\n/** Typescript helper to extract batch type from a generic loader type */\nexport type LoaderBatchType<T = Loader> = T extends Loader<any, infer Batch, any> ? Batch : never;\n\n/**\n * Parses `data` asynchronously using the supplied loader, parse function provided via the loader context\n */\nexport async function parseFromContext<\n LoaderT extends Loader,\n OptionsT extends LoaderOptions = LoaderOptionsType<LoaderT>\n>(\n data: ArrayBuffer,\n loader: LoaderT,\n options: OptionsT | undefined,\n context: LoaderContext\n): Promise<LoaderReturnType<LoaderT>>;\n\n/**\n * Parses `data` asynchronously by matching one of the supplied loader\n */\nexport async function parseFromContext(\n data: ArrayBuffer,\n loaders: Loader[],\n options: LoaderOptions | undefined,\n context: LoaderContext\n): Promise<unknown>;\n\n/**\n * Parses `data` using a specified loader\n * @param data\n * @param loaders\n * @param options\n * @param context\n */\n// implementation signature\nexport async function parseFromContext(\n data: ArrayBuffer,\n loaders: Loader | Loader[],\n options: LoaderOptions | undefined,\n context: LoaderContext\n): Promise<unknown> {\n return context._parse(data, loaders, options, context);\n}\n\n/**\n * Parses `data` synchronously using the specified loader, parse function provided via the loader context\n */\nexport function parseSyncFromContext<\n LoaderT extends Loader,\n OptionsT extends LoaderOptions = LoaderOptionsType<LoaderT>\n>(\n data: ArrayBuffer,\n loader: LoaderT,\n options: OptionsT | undefined,\n context: LoaderContext\n): LoaderReturnType<LoaderT> {\n if (!context._parseSync) {\n throw new Error('parseSync');\n }\n return context._parseSync(data, loader, options, context);\n}\n\n/**\n * Parses `data` synchronously using a specified loader, parse function provided via the loader context\n */\nexport async function parseInBatchesFromContext<\n LoaderT extends Loader,\n OptionsT extends LoaderOptions = LoaderOptionsType<LoaderT>\n>(\n data: Iterable<ArrayBuffer> | AsyncIterable<ArrayBuffer> | Response,\n loader: LoaderT,\n options: OptionsT | undefined,\n context: LoaderContext\n): Promise<AsyncIterable<LoaderBatchType<LoaderT>>> {\n if (!context._parseInBatches) {\n throw new Error('parseInBatches');\n }\n return context._parseInBatches(data, loader, options, context);\n}\n"],"mappings":"AAmUA,OAAO,eAAeA,gBAAgBA,CACpCC,IAAiB,EACjBC,OAA0B,EAC1BC,OAAkC,EAClCC,OAAsB,EACJ;EAClB,OAAOA,OAAO,CAACC,MAAM,CAACJ,IAAI,EAAEC,OAAO,EAAEC,OAAO,EAAEC,OAAO,CAAC;AACxD;AAKA,OAAO,SAASE,oBAAoBA,CAIlCL,IAAiB,EACjBM,MAAe,EACfJ,OAA6B,EAC7BC,OAAsB,EACK;EAC3B,IAAI,CAACA,OAAO,CAACI,UAAU,EAAE;IACvB,MAAM,IAAIC,KAAK,CAAC,WAAW,CAAC;EAC9B;EACA,OAAOL,OAAO,CAACI,UAAU,CAACP,IAAI,EAAEM,MAAM,EAAEJ,OAAO,EAAEC,OAAO,CAAC;AAC3D;AAKA,OAAO,eAAeM,yBAAyBA,CAI7CT,IAAmE,EACnEM,MAAe,EACfJ,OAA6B,EAC7BC,OAAsB,EAC4B;EAClD,IAAI,CAACA,OAAO,CAACO,eAAe,EAAE;IAC5B,MAAM,IAAIF,KAAK,CAAC,gBAAgB,CAAC;EACnC;EACA,OAAOL,OAAO,CAACO,eAAe,CAACV,IAAI,EAAEM,MAAM,EAAEJ,OAAO,EAAEC,OAAO,CAAC;AAChE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-types.js","names":[],"sources":["../src/service-types.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {ImageSource, ImageSourceProps} from './lib/sources/image-source';\n\n/** Export interface source */\nexport interface Service<SourceT = ImageSource, SourcePropsT = ImageSourceProps> {\n source?: SourceT;\n props?: SourcePropsT;\n type: string;\n testURL: (url: string) => boolean;\n create(props: SourcePropsT): SourceT;\n}\n"],"mappings":""}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export type TypedIntArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array
|
|
1
|
+
export type TypedIntArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array;
|
|
2
2
|
export type TypedFloatArray = Uint16Array | Float32Array | Float64Array;
|
|
3
3
|
export type TypedArray = TypedIntArray | TypedFloatArray;
|
|
4
4
|
export type BigTypedArray = TypedArray | BigInt64Array | BigUint64Array;
|
|
5
|
-
export type TypedArrayConstructor = Int8ArrayConstructor | Uint8ArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor |
|
|
5
|
+
export type TypedArrayConstructor = Int8ArrayConstructor | Uint8ArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor;
|
|
6
6
|
export type BigTypedArrayConstructor = TypedArrayConstructor | BigInt64ArrayConstructor | BigUint64ArrayConstructor;
|
|
7
7
|
/** Any numeric array: typed array or `number[]` */
|
|
8
8
|
export type NumberArray = number[] | TypedArray;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,aAAa,GACrB,SAAS,GACT,UAAU,GACV,iBAAiB,GACjB,UAAU,GACV,WAAW,GACX,UAAU,GACV,WAAW,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,aAAa,GACrB,SAAS,GACT,UAAU,GACV,iBAAiB,GACjB,UAAU,GACV,WAAW,GACX,UAAU,GACV,WAAW,CAAC;AAEhB,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,YAAY,GAAG,YAAY,CAAC;AAExE,MAAM,MAAM,UAAU,GAAG,aAAa,GAAG,eAAe,CAAC;AAEzD,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8Array\n | Uint8Array\n | Uint8ClampedArray\n | Int16Array\n | Uint16Array\n | Int32Array\n | Uint32Array;\n\nexport type TypedFloatArray = Uint16Array | Float32Array | Float64Array;\n\nexport type TypedArray = TypedIntArray | TypedFloatArray;\n\nexport type BigTypedArray = TypedArray | BigInt64Array | BigUint64Array;\n\nexport type TypedArrayConstructor =\n | Int8ArrayConstructor\n | Uint8ArrayConstructor\n | Int16ArrayConstructor\n | Uint16ArrayConstructor\n | Int32ArrayConstructor\n | Uint32ArrayConstructor\n | Float32ArrayConstructor\n | Float64ArrayConstructor;\n\nexport type BigTypedArrayConstructor =\n | TypedArrayConstructor\n | BigInt64ArrayConstructor\n | BigUint64ArrayConstructor;\n\n/** Any numeric array: typed array or `number[]` */\nexport type NumberArray = number[] | TypedArray;\n\nexport type NumericArray = number[] | TypedArray;\n\n// FETCH\n\nexport type FetchLike = (url: string, options?: RequestInit) => Promise<Response>;\n\n// MISC TYPES\n\nexport type TransformBatches = (\n asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>\n) => AsyncIterable<ArrayBuffer>;\n\n/** Types that can be synchronously parsed */\nexport type SyncDataType = string | ArrayBuffer; // TODO File | Blob can be read synchronously...\n\n/** Types that can be parsed async */\nexport type DataType =\n | string\n | ArrayBuffer\n | File\n | Blob\n | Response\n | ReadableStream\n | Iterable<ArrayBuffer>\n | AsyncIterable<ArrayBuffer>;\n\n/** Types that can be parsed in batches */\nexport type BatchableDataType =\n | DataType\n | Iterable<ArrayBuffer>\n | AsyncIterable<ArrayBuffer>\n | Promise<AsyncIterable<ArrayBuffer>>;\n"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-worker.js","names":["createLoaderWorker","JSONLoader"],"sources":["../../src/workers/json-worker.ts"],"sourcesContent":["import {createLoaderWorker} from '../lib/worker-loader-utils/create-loader-worker';\nimport {JSONLoader} from '../json-loader';\n\ncreateLoaderWorker(JSONLoader);\n"],"mappings":"SAAQA,kBAAkB;AAAA,SAClBC,UAAU;AAElBD,kBAAkB,CAACC,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writer-types.js","names":[],"sources":["../src/writer-types.ts"],"sourcesContent":["// loaders.gl, MIT license\n\n// WRITERS\n\n/** Options for writers */\nexport type WriterOptions = {\n /** worker source. If is set will be used instead of loading worker from the Internet */\n source?: string | null;\n /** Force to load WASM libraries from local file system in NodeJS or from loaders.gl CDN in a web browser */\n useLocalLibraries?: boolean;\n /** writer-specific options */\n [writerId: string]: any;\n};\n\n/**\n * A writer definition that can be used with `@loaders.gl/core` functions\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport type Writer<DataT = unknown, BatchT = unknown, WriterOptionsT = WriterOptions> = {\n name: string;\n\n id: string;\n module: string;\n version: string;\n worker?: string | boolean;\n\n // TODO - are these are needed?\n extensions?: string[];\n mimeTypes?: string[];\n binary?: boolean;\n text?: boolean;\n\n options: WriterOptionsT;\n deprecatedOptions?: Record<string, string>;\n\n // encodeText?: EncodeText;\n // encode?: Encode;\n encode?(data: DataT, options?: WriterOptionsT): Promise<ArrayBuffer>;\n encodeSync?(data: DataT, options?: WriterOptionsT): ArrayBuffer;\n\n encodeText?(table: DataT, options?: WriterOptionsT): Promise<string>;\n encodeTextSync?(table: DataT, options?: WriterOptionsT): string;\n\n encodeInBatches?(data: AsyncIterable<any>, options?: WriterOptionsT): AsyncIterable<ArrayBuffer>;\n\n encodeURLtoURL?: (\n inputUrl: string,\n outputUrl: string,\n options?: WriterOptionsT\n ) => Promise<string>;\n};\n\n/** Typescript helper to extract the writer options type from a generic writer type */\nexport type WriterOptionsType<T = Writer> = T extends Writer<unknown, unknown, infer Options>\n ? Options\n : never;\n"],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/loader-utils",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.3",
|
|
4
4
|
"description": "Framework-independent loaders for 3D graphics formats",
|
|
5
5
|
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
6
7
|
"publishConfig": {
|
|
7
8
|
"access": "public"
|
|
8
9
|
},
|
|
@@ -18,8 +19,15 @@
|
|
|
18
19
|
"point cloud"
|
|
19
20
|
],
|
|
20
21
|
"types": "dist/index.d.ts",
|
|
21
|
-
"main": "dist/
|
|
22
|
-
"module": "dist/
|
|
22
|
+
"main": "dist/index.cjs",
|
|
23
|
+
"module": "dist/index.js",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"import": "./dist/index.js",
|
|
27
|
+
"require": "./dist/index.cjs",
|
|
28
|
+
"types": "./dist/index.d.ts"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
23
31
|
"sideEffects": false,
|
|
24
32
|
"files": [
|
|
25
33
|
"src",
|
|
@@ -42,8 +50,8 @@
|
|
|
42
50
|
"scripts": {},
|
|
43
51
|
"dependencies": {
|
|
44
52
|
"@babel/runtime": "^7.3.1",
|
|
45
|
-
"@loaders.gl/worker-utils": "4.0.0-beta.
|
|
53
|
+
"@loaders.gl/worker-utils": "4.0.0-beta.3",
|
|
46
54
|
"@probe.gl/stats": "^4.0.2"
|
|
47
55
|
},
|
|
48
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "7ba9621cc51c7a26c407086ac86171f35b8712af"
|
|
49
57
|
}
|
package/src/index.ts
CHANGED
|
@@ -110,32 +110,26 @@ export {promisify1, promisify2} from './lib/node/promisify';
|
|
|
110
110
|
import * as path from './lib/path-utils/path';
|
|
111
111
|
export {path};
|
|
112
112
|
|
|
113
|
-
// Use instead of importing 'fs' to avoid node dependencies`
|
|
114
|
-
import * as fs from './lib/node/fs';
|
|
115
|
-
export {fs};
|
|
116
|
-
|
|
117
113
|
// Use instead of importing 'stream' to avoid node dependencies`
|
|
118
114
|
import * as stream from './lib/node/stream';
|
|
119
115
|
export {stream};
|
|
120
116
|
|
|
121
117
|
// EXPERIMENTAL: FILE SYSTEMS
|
|
122
118
|
|
|
123
|
-
export type {
|
|
124
|
-
export {
|
|
119
|
+
export type {ReadableFile, WritableFile, Stat} from './lib/files/file';
|
|
120
|
+
export {BlobFile} from './lib/files/blob-file';
|
|
121
|
+
export {HttpFile} from './lib/files/http-file';
|
|
122
|
+
export {NodeFileFacade as NodeFile} from './lib/files/node-file-facade';
|
|
123
|
+
|
|
124
|
+
export type {FileSystem, RandomAccessFileSystem} from './lib/filesystems/filesystem';
|
|
125
|
+
export {NodeFileSystemFacade as NodeFilesystem} from './lib/filesystems/node-filesystem-facade';
|
|
125
126
|
|
|
127
|
+
// TODO - replace with ReadableFile
|
|
126
128
|
export type {FileProvider} from './lib/file-provider/file-provider';
|
|
127
129
|
export {isFileProvider} from './lib/file-provider/file-provider';
|
|
128
|
-
|
|
129
|
-
export {FileHandle} from './lib/file-provider/file-handle';
|
|
130
130
|
export {FileHandleFile} from './lib/file-provider/file-handle-file';
|
|
131
131
|
export {DataViewFile} from './lib/file-provider/data-view-file';
|
|
132
132
|
|
|
133
|
-
export type {ReadableFile} from './lib/filesystems/readable-file';
|
|
134
|
-
export {makeReadableFile} from './lib/filesystems/readable-file';
|
|
135
|
-
|
|
136
|
-
export type {WritableFile} from './lib/filesystems/writable-file';
|
|
137
|
-
export {makeWritableFile} from './lib/filesystems/writable-file';
|
|
138
|
-
|
|
139
133
|
// EXPERIMENTAL: DATA SOURCES
|
|
140
134
|
export type {Service} from './service-types';
|
|
141
135
|
|
|
@@ -150,7 +144,8 @@ export {ImageSource} from './lib/sources/image-source';
|
|
|
150
144
|
export type {
|
|
151
145
|
TileSourceProps,
|
|
152
146
|
TileSourceMetadata,
|
|
153
|
-
GetTileParameters
|
|
147
|
+
GetTileParameters,
|
|
148
|
+
TileLoadParameters
|
|
154
149
|
} from './lib/sources/tile-source';
|
|
155
150
|
export type {TileSource} from './lib/sources/tile-source';
|
|
156
151
|
|
|
@@ -12,7 +12,10 @@ const toNumber = (bigint: bigint) => {
|
|
|
12
12
|
return Number(bigint);
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Provides file data using DataView
|
|
17
|
+
* @deprecated - will be replaced with ReadableFile
|
|
18
|
+
*/
|
|
16
19
|
export class DataViewFile implements FileProvider {
|
|
17
20
|
/** The DataView from which data is provided */
|
|
18
21
|
private file: DataView;
|
|
@@ -21,7 +24,6 @@ export class DataViewFile implements FileProvider {
|
|
|
21
24
|
this.file = file;
|
|
22
25
|
}
|
|
23
26
|
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
25
27
|
async destroy(): Promise<void> {}
|
|
26
28
|
|
|
27
29
|
/**
|
|
@@ -1,49 +1,37 @@
|
|
|
1
|
+
// loaders.gl, MIT license
|
|
2
|
+
|
|
1
3
|
import {FileProvider} from './file-provider';
|
|
2
|
-
import {
|
|
3
|
-
import {resolvePath} from '../path-utils/file-aliases';
|
|
4
|
+
import {NodeFileFacade as NodeFile} from '../files/node-file-facade';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Provides file data using node fs library
|
|
8
|
+
* @deprecated - will be replaced with ReadableFile
|
|
7
9
|
*/
|
|
8
10
|
export class FileHandleFile implements FileProvider {
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
* @param path The path to the file in file system
|
|
12
|
-
*/
|
|
13
|
-
static async from(path: string): Promise<FileHandleFile> {
|
|
14
|
-
path = resolvePath(path);
|
|
15
|
-
const fileDescriptor = await FileHandle.open(path);
|
|
16
|
-
return new FileHandleFile(fileDescriptor, fileDescriptor.stat.size);
|
|
17
|
-
}
|
|
11
|
+
/** The FileHandle from which data is provided */
|
|
12
|
+
private file: NodeFile;
|
|
18
13
|
|
|
19
|
-
/**
|
|
20
|
-
* The FileHandle from which data is provided
|
|
21
|
-
*/
|
|
22
|
-
private fileDescriptor: FileHandle;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* The file length in bytes
|
|
26
|
-
*/
|
|
14
|
+
/** The file length in bytes */
|
|
27
15
|
private size: bigint;
|
|
28
16
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
this.
|
|
17
|
+
/** Create a new FileHandleFile */
|
|
18
|
+
constructor(path: string) {
|
|
19
|
+
this.file = new NodeFile(path, 'r');
|
|
20
|
+
this.size = this.file.bigsize;
|
|
32
21
|
}
|
|
33
22
|
|
|
34
23
|
/** Close file */
|
|
35
24
|
async destroy(): Promise<void> {
|
|
36
|
-
await this.
|
|
25
|
+
await this.file.close();
|
|
37
26
|
}
|
|
38
27
|
|
|
39
28
|
/**
|
|
40
29
|
* Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.
|
|
41
30
|
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
42
31
|
*/
|
|
43
|
-
async getUint8(offset: bigint): Promise<number> {
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
).at(0);
|
|
32
|
+
async getUint8(offset: number | bigint): Promise<number> {
|
|
33
|
+
const arrayBuffer = await this.file.read(offset, 1);
|
|
34
|
+
const val = new Uint8Array(arrayBuffer).at(0);
|
|
47
35
|
if (val === undefined) {
|
|
48
36
|
throw new Error('something went wrong');
|
|
49
37
|
}
|
|
@@ -54,10 +42,9 @@ export class FileHandleFile implements FileProvider {
|
|
|
54
42
|
* Gets an unsigned 16-bit integer at the specified byte offset from the start of the file.
|
|
55
43
|
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
56
44
|
*/
|
|
57
|
-
async getUint16(offset: bigint): Promise<number> {
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
).at(0);
|
|
45
|
+
async getUint16(offset: number | bigint): Promise<number> {
|
|
46
|
+
const arrayBuffer = await this.file.read(offset, 2);
|
|
47
|
+
const val = new Uint16Array(arrayBuffer).at(0);
|
|
61
48
|
if (val === undefined) {
|
|
62
49
|
throw new Error('something went wrong');
|
|
63
50
|
}
|
|
@@ -68,10 +55,9 @@ export class FileHandleFile implements FileProvider {
|
|
|
68
55
|
* Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
|
|
69
56
|
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
70
57
|
*/
|
|
71
|
-
async getUint32(offset: bigint): Promise<number> {
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
).at(0);
|
|
58
|
+
async getUint32(offset: number | bigint): Promise<number> {
|
|
59
|
+
const arrayBuffer = await this.file.read(offset, 4);
|
|
60
|
+
const val = new Uint32Array(arrayBuffer).at(0);
|
|
75
61
|
if (val === undefined) {
|
|
76
62
|
throw new Error('something went wrong');
|
|
77
63
|
}
|
|
@@ -82,10 +68,9 @@ export class FileHandleFile implements FileProvider {
|
|
|
82
68
|
* Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
|
|
83
69
|
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
84
70
|
*/
|
|
85
|
-
async getBigUint64(offset: bigint): Promise<bigint> {
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
).at(0);
|
|
71
|
+
async getBigUint64(offset: number | bigint): Promise<bigint> {
|
|
72
|
+
const arrayBuffer = await this.file.read(offset, 8);
|
|
73
|
+
const val = new BigInt64Array(arrayBuffer).at(0);
|
|
89
74
|
if (val === undefined) {
|
|
90
75
|
throw new Error('something went wrong');
|
|
91
76
|
}
|
|
@@ -94,17 +79,16 @@ export class FileHandleFile implements FileProvider {
|
|
|
94
79
|
|
|
95
80
|
/**
|
|
96
81
|
* returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
|
|
97
|
-
* @param
|
|
82
|
+
* @param startOffset The offset, in byte, from the start of the file where to start reading the data.
|
|
98
83
|
* @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
|
|
99
84
|
*/
|
|
100
|
-
async slice(
|
|
101
|
-
const bigLength = endOffset -
|
|
85
|
+
async slice(startOffset: bigint, endOffset: bigint): Promise<ArrayBuffer> {
|
|
86
|
+
const bigLength = endOffset - startOffset;
|
|
102
87
|
if (bigLength > Number.MAX_SAFE_INTEGER) {
|
|
103
88
|
throw new Error('too big slice');
|
|
104
89
|
}
|
|
105
90
|
const length = Number(bigLength);
|
|
106
|
-
return
|
|
107
|
-
.buffer;
|
|
91
|
+
return await this.file.read(startOffset, length);
|
|
108
92
|
}
|
|
109
93
|
|
|
110
94
|
/**
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// loaders.gl, MIT license
|
|
2
|
+
|
|
3
|
+
import {ReadableFile} from './file';
|
|
4
|
+
|
|
5
|
+
export class BlobFile implements ReadableFile {
|
|
6
|
+
readonly handle: Blob;
|
|
7
|
+
readonly size: number;
|
|
8
|
+
readonly bigsize: bigint;
|
|
9
|
+
readonly url: string;
|
|
10
|
+
|
|
11
|
+
constructor(blob: Blob | File | ArrayBuffer) {
|
|
12
|
+
this.handle = blob instanceof ArrayBuffer ? new Blob([blob]) : blob;
|
|
13
|
+
this.size = blob instanceof ArrayBuffer ? blob.byteLength : blob.size;
|
|
14
|
+
this.bigsize = BigInt(this.size);
|
|
15
|
+
this.url = blob instanceof File ? blob.name : '';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async close() {}
|
|
19
|
+
|
|
20
|
+
async stat() {
|
|
21
|
+
return {
|
|
22
|
+
size: this.handle.size,
|
|
23
|
+
bigsize: BigInt(this.handle.size),
|
|
24
|
+
isDirectory: false
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async read(start: number, length: number): Promise<ArrayBuffer> {
|
|
29
|
+
const arrayBuffer = await this.handle.slice(start, start + length).arrayBuffer();
|
|
30
|
+
return arrayBuffer;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// loaders.gl, MIT license
|
|
2
|
+
|
|
3
|
+
export type Stat = {
|
|
4
|
+
size: number;
|
|
5
|
+
bigsize: bigint;
|
|
6
|
+
isDirectory: boolean;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export interface ReadableFile {
|
|
10
|
+
/** The underlying file handle (Blob, Node.js file descriptor etc) */
|
|
11
|
+
readonly handle: unknown;
|
|
12
|
+
/** Length of file in bytes, if available */
|
|
13
|
+
readonly size: number;
|
|
14
|
+
/** Length of file in bytes, if available */
|
|
15
|
+
readonly bigsize: bigint;
|
|
16
|
+
/** Url, if available */
|
|
17
|
+
readonly url: string;
|
|
18
|
+
|
|
19
|
+
/** Read data */
|
|
20
|
+
read(start?: number | bigint, length?: number): Promise<ArrayBuffer>;
|
|
21
|
+
/** Read data */
|
|
22
|
+
fetchRange?(offset: number | bigint, length: number, signal?: AbortSignal): Promise<Response>;
|
|
23
|
+
/** Get information about file */
|
|
24
|
+
stat?(): Promise<Stat>;
|
|
25
|
+
/** Close the file */
|
|
26
|
+
close(): Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface WritableFile {
|
|
30
|
+
handle: unknown;
|
|
31
|
+
/** Write to file. The number of bytes written will be returned */
|
|
32
|
+
write: (arrayBuffer: ArrayBuffer, offset?: number | bigint, length?: number) => Promise<number>;
|
|
33
|
+
/** Get information about the file */
|
|
34
|
+
stat?(): Promise<Stat>;
|
|
35
|
+
/** Close the file */
|
|
36
|
+
close(): Promise<void>;
|
|
37
|
+
}
|