@loaders.gl/loader-utils 4.0.0-beta.1 → 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.browser.js +0 -172
- package/dist/es5/lib/filesystems/node-filesystem.browser.js.map +0 -1
- package/dist/es5/lib/filesystems/node-filesystem.js +0 -210
- 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.browser.js +0 -42
- package/dist/esm/lib/filesystems/node-filesystem.browser.js.map +0 -1
- package/dist/esm/lib/filesystems/node-filesystem.js +0 -53
- 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.browser.d.ts +0 -39
- package/dist/lib/filesystems/node-filesystem.browser.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.browser.ts +0 -61
- package/src/lib/filesystems/node-filesystem.ts +0 -79
- 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
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,1252 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
BlobFile: () => BlobFile,
|
|
24
|
+
DataSource: () => DataSource,
|
|
25
|
+
DataViewFile: () => DataViewFile,
|
|
26
|
+
FileHandleFile: () => FileHandleFile,
|
|
27
|
+
HttpFile: () => HttpFile,
|
|
28
|
+
ImageSource: () => ImageSource,
|
|
29
|
+
JSONLoader: () => JSONLoader,
|
|
30
|
+
NodeFile: () => NodeFileFacade,
|
|
31
|
+
NodeFilesystem: () => NodeFileSystemFacade,
|
|
32
|
+
RequestScheduler: () => RequestScheduler,
|
|
33
|
+
_addAliases: () => addAliases,
|
|
34
|
+
assert: () => assert,
|
|
35
|
+
canEncodeWithWorker: () => canEncodeWithWorker,
|
|
36
|
+
canParseWithWorker: () => canParseWithWorker,
|
|
37
|
+
compareArrayBuffers: () => compareArrayBuffers,
|
|
38
|
+
concatenateArrayBuffers: () => concatenateArrayBuffers,
|
|
39
|
+
concatenateArrayBuffersAsync: () => concatenateArrayBuffersAsync,
|
|
40
|
+
concatenateTypedArrays: () => concatenateTypedArrays,
|
|
41
|
+
copyArrayBuffer: () => copyArrayBuffer,
|
|
42
|
+
copyBinaryToDataView: () => copyBinaryToDataView,
|
|
43
|
+
copyPaddedArrayBufferToDataView: () => copyPaddedArrayBufferToDataView,
|
|
44
|
+
copyPaddedStringToDataView: () => copyPaddedStringToDataView,
|
|
45
|
+
copyStringToDataView: () => copyStringToDataView,
|
|
46
|
+
copyToArray: () => copyToArray,
|
|
47
|
+
createLoaderWorker: () => createLoaderWorker,
|
|
48
|
+
document: () => document_,
|
|
49
|
+
forEach: () => forEach,
|
|
50
|
+
getFirstCharacters: () => getFirstCharacters,
|
|
51
|
+
getMagicString: () => getMagicString,
|
|
52
|
+
getPathPrefix: () => getPathPrefix,
|
|
53
|
+
global: () => global_,
|
|
54
|
+
isBrowser: () => isBrowser,
|
|
55
|
+
isBuffer: () => isBuffer,
|
|
56
|
+
isFileProvider: () => isFileProvider,
|
|
57
|
+
isWorker: () => isWorker,
|
|
58
|
+
makeLineIterator: () => makeLineIterator,
|
|
59
|
+
makeNumberedLineIterator: () => makeNumberedLineIterator,
|
|
60
|
+
makeTextDecoderIterator: () => makeTextDecoderIterator,
|
|
61
|
+
makeTextEncoderIterator: () => makeTextEncoderIterator,
|
|
62
|
+
mergeLoaderOptions: () => mergeLoaderOptions,
|
|
63
|
+
nodeVersion: () => nodeVersion,
|
|
64
|
+
padStringToByteAlignment: () => padStringToByteAlignment,
|
|
65
|
+
padToNBytes: () => padToNBytes,
|
|
66
|
+
parseFromContext: () => parseFromContext,
|
|
67
|
+
parseInBatchesFromContext: () => parseInBatchesFromContext,
|
|
68
|
+
parseJSON: () => parseJSON,
|
|
69
|
+
parseSyncFromContext: () => parseSyncFromContext,
|
|
70
|
+
parseWithWorker: () => parseWithWorker,
|
|
71
|
+
path: () => path_exports,
|
|
72
|
+
promisify1: () => promisify1,
|
|
73
|
+
promisify2: () => promisify2,
|
|
74
|
+
resolvePath: () => resolvePath,
|
|
75
|
+
self: () => self_,
|
|
76
|
+
setPathPrefix: () => setPathPrefix,
|
|
77
|
+
sliceArrayBuffer: () => sliceArrayBuffer,
|
|
78
|
+
stream: () => stream_browser_exports,
|
|
79
|
+
toArrayBuffer: () => toArrayBuffer2,
|
|
80
|
+
toBuffer: () => toBuffer2,
|
|
81
|
+
window: () => window_
|
|
82
|
+
});
|
|
83
|
+
module.exports = __toCommonJS(src_exports);
|
|
84
|
+
|
|
85
|
+
// src/loader-types.ts
|
|
86
|
+
async function parseFromContext(data, loaders, options, context) {
|
|
87
|
+
return context._parse(data, loaders, options, context);
|
|
88
|
+
}
|
|
89
|
+
function parseSyncFromContext(data, loader, options, context) {
|
|
90
|
+
if (!context._parseSync) {
|
|
91
|
+
throw new Error("parseSync");
|
|
92
|
+
}
|
|
93
|
+
return context._parseSync(data, loader, options, context);
|
|
94
|
+
}
|
|
95
|
+
async function parseInBatchesFromContext(data, loader, options, context) {
|
|
96
|
+
if (!context._parseInBatches) {
|
|
97
|
+
throw new Error("parseInBatches");
|
|
98
|
+
}
|
|
99
|
+
return context._parseInBatches(data, loader, options, context);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// src/lib/env-utils/assert.ts
|
|
103
|
+
function assert(condition, message) {
|
|
104
|
+
if (!condition) {
|
|
105
|
+
throw new Error(message || "loader assertion failed.");
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// src/lib/env-utils/globals.ts
|
|
110
|
+
var globals = {
|
|
111
|
+
self: typeof self !== "undefined" && self,
|
|
112
|
+
window: typeof window !== "undefined" && window,
|
|
113
|
+
global: typeof global !== "undefined" && global,
|
|
114
|
+
document: typeof document !== "undefined" && document
|
|
115
|
+
};
|
|
116
|
+
var self_ = globals.self || globals.window || globals.global || {};
|
|
117
|
+
var window_ = globals.window || globals.self || globals.global || {};
|
|
118
|
+
var global_ = globals.global || globals.self || globals.window || {};
|
|
119
|
+
var document_ = globals.document || {};
|
|
120
|
+
var isBrowser = (
|
|
121
|
+
// @ts-ignore process does not exist on browser
|
|
122
|
+
Boolean(typeof process !== "object" || String(process) !== "[object process]" || process.browser)
|
|
123
|
+
);
|
|
124
|
+
var isWorker = typeof importScripts === "function";
|
|
125
|
+
var matches = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
|
|
126
|
+
var nodeVersion = matches && parseFloat(matches[1]) || 0;
|
|
127
|
+
|
|
128
|
+
// src/lib/option-utils/merge-loader-options.ts
|
|
129
|
+
function mergeLoaderOptions(baseOptions, newOptions) {
|
|
130
|
+
return mergeOptionsRecursively(baseOptions || {}, newOptions);
|
|
131
|
+
}
|
|
132
|
+
function mergeOptionsRecursively(baseOptions, newOptions) {
|
|
133
|
+
const options = { ...baseOptions };
|
|
134
|
+
for (const [key, newValue] of Object.entries(newOptions)) {
|
|
135
|
+
if (newValue && typeof newValue === "object" && !Array.isArray(newValue)) {
|
|
136
|
+
options[key] = mergeOptionsRecursively(
|
|
137
|
+
options[key] || {},
|
|
138
|
+
newOptions[key]
|
|
139
|
+
);
|
|
140
|
+
} else {
|
|
141
|
+
options[key] = newOptions[key];
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return options;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// src/lib/worker-loader-utils/create-loader-worker.ts
|
|
148
|
+
var import_worker_utils = require("@loaders.gl/worker-utils");
|
|
149
|
+
var requestId = 0;
|
|
150
|
+
function createLoaderWorker(loader) {
|
|
151
|
+
if (!import_worker_utils.WorkerBody.inWorkerThread()) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
import_worker_utils.WorkerBody.onmessage = async (type, payload) => {
|
|
155
|
+
switch (type) {
|
|
156
|
+
case "process":
|
|
157
|
+
try {
|
|
158
|
+
const { input, options = {}, context = {} } = payload;
|
|
159
|
+
const result = await parseData({
|
|
160
|
+
loader,
|
|
161
|
+
arrayBuffer: input,
|
|
162
|
+
options,
|
|
163
|
+
// @ts-expect-error fetch missing
|
|
164
|
+
context: {
|
|
165
|
+
...context,
|
|
166
|
+
_parse: parseOnMainThread
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
import_worker_utils.WorkerBody.postMessage("done", { result });
|
|
170
|
+
} catch (error) {
|
|
171
|
+
const message = error instanceof Error ? error.message : "";
|
|
172
|
+
import_worker_utils.WorkerBody.postMessage("error", { error: message });
|
|
173
|
+
}
|
|
174
|
+
break;
|
|
175
|
+
default:
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
function parseOnMainThread(arrayBuffer, loader, options, context) {
|
|
180
|
+
return new Promise((resolve2, reject) => {
|
|
181
|
+
const id = requestId++;
|
|
182
|
+
const onMessage2 = (type, payload2) => {
|
|
183
|
+
if (payload2.id !== id) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
switch (type) {
|
|
187
|
+
case "done":
|
|
188
|
+
import_worker_utils.WorkerBody.removeEventListener(onMessage2);
|
|
189
|
+
resolve2(payload2.result);
|
|
190
|
+
break;
|
|
191
|
+
case "error":
|
|
192
|
+
import_worker_utils.WorkerBody.removeEventListener(onMessage2);
|
|
193
|
+
reject(payload2.error);
|
|
194
|
+
break;
|
|
195
|
+
default:
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
import_worker_utils.WorkerBody.addEventListener(onMessage2);
|
|
199
|
+
const payload = { id, input: arrayBuffer, options };
|
|
200
|
+
import_worker_utils.WorkerBody.postMessage("process", payload);
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
async function parseData({
|
|
204
|
+
loader,
|
|
205
|
+
arrayBuffer,
|
|
206
|
+
options,
|
|
207
|
+
context
|
|
208
|
+
}) {
|
|
209
|
+
let data;
|
|
210
|
+
let parser;
|
|
211
|
+
if (loader.parseSync || loader.parse) {
|
|
212
|
+
data = arrayBuffer;
|
|
213
|
+
parser = loader.parseSync || loader.parse;
|
|
214
|
+
} else if (loader.parseTextSync) {
|
|
215
|
+
const textDecoder = new TextDecoder();
|
|
216
|
+
data = textDecoder.decode(arrayBuffer);
|
|
217
|
+
parser = loader.parseTextSync;
|
|
218
|
+
} else {
|
|
219
|
+
throw new Error(`Could not load data with ${loader.name} loader`);
|
|
220
|
+
}
|
|
221
|
+
options = {
|
|
222
|
+
...options,
|
|
223
|
+
modules: loader && loader.options && loader.options.modules || {},
|
|
224
|
+
worker: false
|
|
225
|
+
};
|
|
226
|
+
return await parser(data, { ...options }, context, loader);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// src/lib/worker-loader-utils/parse-with-worker.ts
|
|
230
|
+
var import_worker_utils2 = require("@loaders.gl/worker-utils");
|
|
231
|
+
var import_worker_utils3 = require("@loaders.gl/worker-utils");
|
|
232
|
+
function canParseWithWorker(loader, options) {
|
|
233
|
+
if (!import_worker_utils3.WorkerFarm.isSupported()) {
|
|
234
|
+
return false;
|
|
235
|
+
}
|
|
236
|
+
if (!import_worker_utils2.isBrowser && !(options == null ? void 0 : options._nodeWorkers)) {
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
return loader.worker && (options == null ? void 0 : options.worker);
|
|
240
|
+
}
|
|
241
|
+
async function parseWithWorker(loader, data, options, context, parseOnMainThread2) {
|
|
242
|
+
const name = loader.id;
|
|
243
|
+
const url = (0, import_worker_utils3.getWorkerURL)(loader, options);
|
|
244
|
+
const workerFarm = import_worker_utils3.WorkerFarm.getWorkerFarm(options);
|
|
245
|
+
const workerPool = workerFarm.getWorkerPool({ name, url });
|
|
246
|
+
options = JSON.parse(JSON.stringify(options));
|
|
247
|
+
context = JSON.parse(JSON.stringify(context || {}));
|
|
248
|
+
const job = await workerPool.startJob(
|
|
249
|
+
"process-on-worker",
|
|
250
|
+
// @ts-expect-error
|
|
251
|
+
onMessage.bind(null, parseOnMainThread2)
|
|
252
|
+
// eslint-disable-line @typescript-eslint/no-misused-promises
|
|
253
|
+
);
|
|
254
|
+
job.postMessage("process", {
|
|
255
|
+
// @ts-ignore
|
|
256
|
+
input: data,
|
|
257
|
+
options,
|
|
258
|
+
context
|
|
259
|
+
});
|
|
260
|
+
const result = await job.result;
|
|
261
|
+
return await result.result;
|
|
262
|
+
}
|
|
263
|
+
async function onMessage(parseOnMainThread2, job, type, payload) {
|
|
264
|
+
switch (type) {
|
|
265
|
+
case "done":
|
|
266
|
+
job.done(payload);
|
|
267
|
+
break;
|
|
268
|
+
case "error":
|
|
269
|
+
job.error(new Error(payload.error));
|
|
270
|
+
break;
|
|
271
|
+
case "process":
|
|
272
|
+
const { id, input, options } = payload;
|
|
273
|
+
try {
|
|
274
|
+
const result = await parseOnMainThread2(input, options);
|
|
275
|
+
job.postMessage("done", { id, result });
|
|
276
|
+
} catch (error) {
|
|
277
|
+
const message = error instanceof Error ? error.message : "unknown error";
|
|
278
|
+
job.postMessage("error", { id, error: message });
|
|
279
|
+
}
|
|
280
|
+
break;
|
|
281
|
+
default:
|
|
282
|
+
console.warn(`parse-with-worker unknown message ${type}`);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// src/lib/worker-loader-utils/encode-with-worker.ts
|
|
287
|
+
var import_worker_utils4 = require("@loaders.gl/worker-utils");
|
|
288
|
+
function canEncodeWithWorker(writer, options) {
|
|
289
|
+
if (!import_worker_utils4.WorkerFarm.isSupported()) {
|
|
290
|
+
return false;
|
|
291
|
+
}
|
|
292
|
+
if (!isBrowser && !(options == null ? void 0 : options._nodeWorkers)) {
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
return writer.worker && (options == null ? void 0 : options.worker);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// src/lib/binary-utils/get-first-characters.ts
|
|
299
|
+
function getFirstCharacters(data, length = 5) {
|
|
300
|
+
if (typeof data === "string") {
|
|
301
|
+
return data.slice(0, length);
|
|
302
|
+
} else if (ArrayBuffer.isView(data)) {
|
|
303
|
+
return getMagicString(data.buffer, data.byteOffset, length);
|
|
304
|
+
} else if (data instanceof ArrayBuffer) {
|
|
305
|
+
const byteOffset = 0;
|
|
306
|
+
return getMagicString(data, byteOffset, length);
|
|
307
|
+
}
|
|
308
|
+
return "";
|
|
309
|
+
}
|
|
310
|
+
function getMagicString(arrayBuffer, byteOffset, length) {
|
|
311
|
+
if (arrayBuffer.byteLength <= byteOffset + length) {
|
|
312
|
+
return "";
|
|
313
|
+
}
|
|
314
|
+
const dataView = new DataView(arrayBuffer);
|
|
315
|
+
let magic = "";
|
|
316
|
+
for (let i = 0; i < length; i++) {
|
|
317
|
+
magic += String.fromCharCode(dataView.getUint8(byteOffset + i));
|
|
318
|
+
}
|
|
319
|
+
return magic;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// src/lib/parser-utils/parse-json.ts
|
|
323
|
+
function parseJSON(string) {
|
|
324
|
+
try {
|
|
325
|
+
return JSON.parse(string);
|
|
326
|
+
} catch (_) {
|
|
327
|
+
throw new Error(`Failed to parse JSON from data starting with "${getFirstCharacters(string)}"`);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// src/lib/binary-utils/array-buffer-utils.ts
|
|
332
|
+
function compareArrayBuffers(arrayBuffer1, arrayBuffer2, byteLength) {
|
|
333
|
+
byteLength = byteLength || arrayBuffer1.byteLength;
|
|
334
|
+
if (arrayBuffer1.byteLength < byteLength || arrayBuffer2.byteLength < byteLength) {
|
|
335
|
+
return false;
|
|
336
|
+
}
|
|
337
|
+
const array1 = new Uint8Array(arrayBuffer1);
|
|
338
|
+
const array2 = new Uint8Array(arrayBuffer2);
|
|
339
|
+
for (let i = 0; i < array1.length; ++i) {
|
|
340
|
+
if (array1[i] !== array2[i]) {
|
|
341
|
+
return false;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
return true;
|
|
345
|
+
}
|
|
346
|
+
function concatenateArrayBuffers(...sources) {
|
|
347
|
+
const sourceArrays = sources.map(
|
|
348
|
+
(source2) => source2 instanceof ArrayBuffer ? new Uint8Array(source2) : source2
|
|
349
|
+
);
|
|
350
|
+
const byteLength = sourceArrays.reduce((length, typedArray) => length + typedArray.byteLength, 0);
|
|
351
|
+
const result = new Uint8Array(byteLength);
|
|
352
|
+
let offset = 0;
|
|
353
|
+
for (const sourceArray of sourceArrays) {
|
|
354
|
+
result.set(sourceArray, offset);
|
|
355
|
+
offset += sourceArray.byteLength;
|
|
356
|
+
}
|
|
357
|
+
return result.buffer;
|
|
358
|
+
}
|
|
359
|
+
function concatenateTypedArrays(...typedArrays) {
|
|
360
|
+
const arrays = typedArrays;
|
|
361
|
+
const TypedArrayConstructor = arrays && arrays.length > 1 && arrays[0].constructor || null;
|
|
362
|
+
if (!TypedArrayConstructor) {
|
|
363
|
+
throw new Error(
|
|
364
|
+
'"concatenateTypedArrays" - incorrect quantity of arguments or arguments have incompatible data types'
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
const sumLength = arrays.reduce((acc, value) => acc + value.length, 0);
|
|
368
|
+
const result = new TypedArrayConstructor(sumLength);
|
|
369
|
+
let offset = 0;
|
|
370
|
+
for (const array of arrays) {
|
|
371
|
+
result.set(array, offset);
|
|
372
|
+
offset += array.length;
|
|
373
|
+
}
|
|
374
|
+
return result;
|
|
375
|
+
}
|
|
376
|
+
function sliceArrayBuffer(arrayBuffer, byteOffset, byteLength) {
|
|
377
|
+
const subArray = byteLength !== void 0 ? new Uint8Array(arrayBuffer).subarray(byteOffset, byteOffset + byteLength) : new Uint8Array(arrayBuffer).subarray(byteOffset);
|
|
378
|
+
const arrayCopy = new Uint8Array(subArray);
|
|
379
|
+
return arrayCopy.buffer;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
// src/lib/binary-utils/memory-copy-utils.ts
|
|
383
|
+
function padToNBytes(byteLength, padding) {
|
|
384
|
+
assert(byteLength >= 0);
|
|
385
|
+
assert(padding > 0);
|
|
386
|
+
return byteLength + (padding - 1) & ~(padding - 1);
|
|
387
|
+
}
|
|
388
|
+
function copyArrayBuffer(targetBuffer, sourceBuffer, byteOffset, byteLength = sourceBuffer.byteLength) {
|
|
389
|
+
const targetArray = new Uint8Array(targetBuffer, byteOffset, byteLength);
|
|
390
|
+
const sourceArray = new Uint8Array(sourceBuffer);
|
|
391
|
+
targetArray.set(sourceArray);
|
|
392
|
+
return targetBuffer;
|
|
393
|
+
}
|
|
394
|
+
function copyToArray(source, target, targetOffset) {
|
|
395
|
+
let sourceArray;
|
|
396
|
+
if (source instanceof ArrayBuffer) {
|
|
397
|
+
sourceArray = new Uint8Array(source);
|
|
398
|
+
} else {
|
|
399
|
+
const srcByteOffset = source.byteOffset;
|
|
400
|
+
const srcByteLength = source.byteLength;
|
|
401
|
+
sourceArray = new Uint8Array(source.buffer || source.arrayBuffer, srcByteOffset, srcByteLength);
|
|
402
|
+
}
|
|
403
|
+
target.set(sourceArray, targetOffset);
|
|
404
|
+
return targetOffset + padToNBytes(sourceArray.byteLength, 4);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// src/lib/binary-utils/dataview-copy-utils.ts
|
|
408
|
+
function padStringToByteAlignment(string, byteAlignment) {
|
|
409
|
+
const length = string.length;
|
|
410
|
+
const paddedLength = Math.ceil(length / byteAlignment) * byteAlignment;
|
|
411
|
+
const padding = paddedLength - length;
|
|
412
|
+
let whitespace = "";
|
|
413
|
+
for (let i = 0; i < padding; ++i) {
|
|
414
|
+
whitespace += " ";
|
|
415
|
+
}
|
|
416
|
+
return string + whitespace;
|
|
417
|
+
}
|
|
418
|
+
function copyStringToDataView(dataView, byteOffset, string, byteLength) {
|
|
419
|
+
if (dataView) {
|
|
420
|
+
for (let i = 0; i < byteLength; i++) {
|
|
421
|
+
dataView.setUint8(byteOffset + i, string.charCodeAt(i));
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
return byteOffset + byteLength;
|
|
425
|
+
}
|
|
426
|
+
function copyBinaryToDataView(dataView, byteOffset, binary, byteLength) {
|
|
427
|
+
if (dataView) {
|
|
428
|
+
for (let i = 0; i < byteLength; i++) {
|
|
429
|
+
dataView.setUint8(byteOffset + i, binary[i]);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
return byteOffset + byteLength;
|
|
433
|
+
}
|
|
434
|
+
function copyPaddedArrayBufferToDataView(dataView, byteOffset, sourceBuffer, padding) {
|
|
435
|
+
const paddedLength = padToNBytes(sourceBuffer.byteLength, padding);
|
|
436
|
+
const padLength = paddedLength - sourceBuffer.byteLength;
|
|
437
|
+
if (dataView) {
|
|
438
|
+
const targetArray = new Uint8Array(
|
|
439
|
+
dataView.buffer,
|
|
440
|
+
dataView.byteOffset + byteOffset,
|
|
441
|
+
sourceBuffer.byteLength
|
|
442
|
+
);
|
|
443
|
+
const sourceArray = new Uint8Array(sourceBuffer);
|
|
444
|
+
targetArray.set(sourceArray);
|
|
445
|
+
for (let i = 0; i < padLength; ++i) {
|
|
446
|
+
dataView.setUint8(byteOffset + sourceBuffer.byteLength + i, 32);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
byteOffset += paddedLength;
|
|
450
|
+
return byteOffset;
|
|
451
|
+
}
|
|
452
|
+
function copyPaddedStringToDataView(dataView, byteOffset, string, padding) {
|
|
453
|
+
const textEncoder = new TextEncoder();
|
|
454
|
+
const stringBuffer = textEncoder.encode(string);
|
|
455
|
+
byteOffset = copyPaddedArrayBufferToDataView(dataView, byteOffset, stringBuffer, padding);
|
|
456
|
+
return byteOffset;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
// src/lib/iterators/text-iterators.ts
|
|
460
|
+
async function* makeTextDecoderIterator(arrayBufferIterator, options = {}) {
|
|
461
|
+
const textDecoder = new TextDecoder(void 0, options);
|
|
462
|
+
for await (const arrayBuffer of arrayBufferIterator) {
|
|
463
|
+
yield typeof arrayBuffer === "string" ? arrayBuffer : textDecoder.decode(arrayBuffer, { stream: true });
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
async function* makeTextEncoderIterator(textIterator) {
|
|
467
|
+
const textEncoder = new TextEncoder();
|
|
468
|
+
for await (const text of textIterator) {
|
|
469
|
+
yield typeof text === "string" ? textEncoder.encode(text) : text;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
async function* makeLineIterator(textIterator) {
|
|
473
|
+
let previous = "";
|
|
474
|
+
for await (const textChunk of textIterator) {
|
|
475
|
+
previous += textChunk;
|
|
476
|
+
let eolIndex;
|
|
477
|
+
while ((eolIndex = previous.indexOf("\n")) >= 0) {
|
|
478
|
+
const line = previous.slice(0, eolIndex + 1);
|
|
479
|
+
previous = previous.slice(eolIndex + 1);
|
|
480
|
+
yield line;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
if (previous.length > 0) {
|
|
484
|
+
yield previous;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
async function* makeNumberedLineIterator(lineIterator) {
|
|
488
|
+
let counter = 1;
|
|
489
|
+
for await (const line of lineIterator) {
|
|
490
|
+
yield { counter, line };
|
|
491
|
+
counter++;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
// src/lib/iterators/async-iteration.ts
|
|
496
|
+
async function forEach(iterator, visitor) {
|
|
497
|
+
while (true) {
|
|
498
|
+
const { done, value } = await iterator.next();
|
|
499
|
+
if (done) {
|
|
500
|
+
iterator.return();
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
const cancel = visitor(value);
|
|
504
|
+
if (cancel) {
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
async function concatenateArrayBuffersAsync(asyncIterator) {
|
|
510
|
+
const arrayBuffers = [];
|
|
511
|
+
for await (const chunk of asyncIterator) {
|
|
512
|
+
arrayBuffers.push(chunk);
|
|
513
|
+
}
|
|
514
|
+
return concatenateArrayBuffers(...arrayBuffers);
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
// src/lib/request-utils/request-scheduler.ts
|
|
518
|
+
var import_stats = require("@probe.gl/stats");
|
|
519
|
+
var STAT_QUEUED_REQUESTS = "Queued Requests";
|
|
520
|
+
var STAT_ACTIVE_REQUESTS = "Active Requests";
|
|
521
|
+
var STAT_CANCELLED_REQUESTS = "Cancelled Requests";
|
|
522
|
+
var STAT_QUEUED_REQUESTS_EVER = "Queued Requests Ever";
|
|
523
|
+
var STAT_ACTIVE_REQUESTS_EVER = "Active Requests Ever";
|
|
524
|
+
var DEFAULT_PROPS = {
|
|
525
|
+
id: "request-scheduler",
|
|
526
|
+
// Specifies if the request scheduler should throttle incoming requests, mainly for comparative testing
|
|
527
|
+
throttleRequests: true,
|
|
528
|
+
// The maximum number of simultaneous active requests. Un-throttled requests do not observe this limit.
|
|
529
|
+
maxRequests: 6
|
|
530
|
+
};
|
|
531
|
+
var RequestScheduler = class {
|
|
532
|
+
constructor(props = {}) {
|
|
533
|
+
this.activeRequestCount = 0;
|
|
534
|
+
/** Tracks the number of active requests and prioritizes/cancels queued requests. */
|
|
535
|
+
this.requestQueue = [];
|
|
536
|
+
this.requestMap = /* @__PURE__ */ new Map();
|
|
537
|
+
this.deferredUpdate = null;
|
|
538
|
+
this.props = { ...DEFAULT_PROPS, ...props };
|
|
539
|
+
this.stats = new import_stats.Stats({ id: this.props.id });
|
|
540
|
+
this.stats.get(STAT_QUEUED_REQUESTS);
|
|
541
|
+
this.stats.get(STAT_ACTIVE_REQUESTS);
|
|
542
|
+
this.stats.get(STAT_CANCELLED_REQUESTS);
|
|
543
|
+
this.stats.get(STAT_QUEUED_REQUESTS_EVER);
|
|
544
|
+
this.stats.get(STAT_ACTIVE_REQUESTS_EVER);
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Called by an application that wants to issue a request, without having it deeply queued by the browser
|
|
548
|
+
*
|
|
549
|
+
* When the returned promise resolved, it is OK for the application to issue a request.
|
|
550
|
+
* The promise resolves to an object that contains a `done` method.
|
|
551
|
+
* When the application's request has completed (or failed), the application must call the `done` function
|
|
552
|
+
*
|
|
553
|
+
* @param handle
|
|
554
|
+
* @param getPriority will be called when request "slots" open up,
|
|
555
|
+
* allowing the caller to update priority or cancel the request
|
|
556
|
+
* Highest priority executes first, priority < 0 cancels the request
|
|
557
|
+
* @returns a promise
|
|
558
|
+
* - resolves to a object (with a `done` field) when the request can be issued without queueing,
|
|
559
|
+
* - resolves to `null` if the request has been cancelled (by the callback return < 0).
|
|
560
|
+
* In this case the application should not issue the request
|
|
561
|
+
*/
|
|
562
|
+
scheduleRequest(handle, getPriority = () => 0) {
|
|
563
|
+
if (!this.props.throttleRequests) {
|
|
564
|
+
return Promise.resolve({ done: () => {
|
|
565
|
+
} });
|
|
566
|
+
}
|
|
567
|
+
if (this.requestMap.has(handle)) {
|
|
568
|
+
return this.requestMap.get(handle);
|
|
569
|
+
}
|
|
570
|
+
const request = { handle, priority: 0, getPriority };
|
|
571
|
+
const promise = new Promise((resolve2) => {
|
|
572
|
+
request.resolve = resolve2;
|
|
573
|
+
return request;
|
|
574
|
+
});
|
|
575
|
+
this.requestQueue.push(request);
|
|
576
|
+
this.requestMap.set(handle, promise);
|
|
577
|
+
this._issueNewRequests();
|
|
578
|
+
return promise;
|
|
579
|
+
}
|
|
580
|
+
// PRIVATE
|
|
581
|
+
_issueRequest(request) {
|
|
582
|
+
const { handle, resolve: resolve2 } = request;
|
|
583
|
+
let isDone = false;
|
|
584
|
+
const done = () => {
|
|
585
|
+
if (!isDone) {
|
|
586
|
+
isDone = true;
|
|
587
|
+
this.requestMap.delete(handle);
|
|
588
|
+
this.activeRequestCount--;
|
|
589
|
+
this._issueNewRequests();
|
|
590
|
+
}
|
|
591
|
+
};
|
|
592
|
+
this.activeRequestCount++;
|
|
593
|
+
return resolve2 ? resolve2({ done }) : Promise.resolve({ done });
|
|
594
|
+
}
|
|
595
|
+
/** We check requests asynchronously, to prevent multiple updates */
|
|
596
|
+
_issueNewRequests() {
|
|
597
|
+
if (!this.deferredUpdate) {
|
|
598
|
+
this.deferredUpdate = setTimeout(() => this._issueNewRequestsAsync(), 0);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
/** Refresh all requests */
|
|
602
|
+
_issueNewRequestsAsync() {
|
|
603
|
+
this.deferredUpdate = null;
|
|
604
|
+
const freeSlots = Math.max(this.props.maxRequests - this.activeRequestCount, 0);
|
|
605
|
+
if (freeSlots === 0) {
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
608
|
+
this._updateAllRequests();
|
|
609
|
+
for (let i = 0; i < freeSlots; ++i) {
|
|
610
|
+
const request = this.requestQueue.shift();
|
|
611
|
+
if (request) {
|
|
612
|
+
this._issueRequest(request);
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
/** Ensure all requests have updated priorities, and that no longer valid requests are cancelled */
|
|
617
|
+
_updateAllRequests() {
|
|
618
|
+
const requestQueue = this.requestQueue;
|
|
619
|
+
for (let i = 0; i < requestQueue.length; ++i) {
|
|
620
|
+
const request = requestQueue[i];
|
|
621
|
+
if (!this._updateRequest(request)) {
|
|
622
|
+
requestQueue.splice(i, 1);
|
|
623
|
+
this.requestMap.delete(request.handle);
|
|
624
|
+
i--;
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
requestQueue.sort((a, b) => a.priority - b.priority);
|
|
628
|
+
}
|
|
629
|
+
/** Update a single request by calling the callback */
|
|
630
|
+
_updateRequest(request) {
|
|
631
|
+
request.priority = request.getPriority(request.handle);
|
|
632
|
+
if (request.priority < 0) {
|
|
633
|
+
request.resolve(null);
|
|
634
|
+
return false;
|
|
635
|
+
}
|
|
636
|
+
return true;
|
|
637
|
+
}
|
|
638
|
+
};
|
|
639
|
+
|
|
640
|
+
// src/lib/path-utils/file-aliases.ts
|
|
641
|
+
var pathPrefix = "";
|
|
642
|
+
var fileAliases = {};
|
|
643
|
+
function setPathPrefix(prefix) {
|
|
644
|
+
pathPrefix = prefix;
|
|
645
|
+
}
|
|
646
|
+
function getPathPrefix() {
|
|
647
|
+
return pathPrefix;
|
|
648
|
+
}
|
|
649
|
+
function addAliases(aliases) {
|
|
650
|
+
Object.assign(fileAliases, aliases);
|
|
651
|
+
}
|
|
652
|
+
function resolvePath(filename2) {
|
|
653
|
+
for (const alias in fileAliases) {
|
|
654
|
+
if (filename2.startsWith(alias)) {
|
|
655
|
+
const replacement = fileAliases[alias];
|
|
656
|
+
filename2 = filename2.replace(alias, replacement);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
if (!filename2.startsWith("http://") && !filename2.startsWith("https://")) {
|
|
660
|
+
filename2 = `${pathPrefix}${filename2}`;
|
|
661
|
+
}
|
|
662
|
+
return filename2;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
// src/json-loader.ts
|
|
666
|
+
var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
667
|
+
var JSONLoader = {
|
|
668
|
+
name: "JSON",
|
|
669
|
+
id: "json",
|
|
670
|
+
module: "json",
|
|
671
|
+
version: VERSION,
|
|
672
|
+
extensions: ["json", "geojson"],
|
|
673
|
+
mimeTypes: ["application/json"],
|
|
674
|
+
category: "json",
|
|
675
|
+
text: true,
|
|
676
|
+
parseTextSync,
|
|
677
|
+
parse: async (arrayBuffer) => parseTextSync(new TextDecoder().decode(arrayBuffer)),
|
|
678
|
+
options: {}
|
|
679
|
+
};
|
|
680
|
+
function parseTextSync(text) {
|
|
681
|
+
return JSON.parse(text);
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
// src/lib/node/buffer.browser.ts
|
|
685
|
+
function toArrayBuffer(buffer) {
|
|
686
|
+
return buffer;
|
|
687
|
+
}
|
|
688
|
+
function toBuffer(binaryData) {
|
|
689
|
+
throw new Error("Buffer not supported in browser");
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
// src/lib/binary-utils/memory-conversion-utils.ts
|
|
693
|
+
function isBuffer(value) {
|
|
694
|
+
return value && typeof value === "object" && value.isBuffer;
|
|
695
|
+
}
|
|
696
|
+
function toBuffer2(data) {
|
|
697
|
+
return toBuffer ? toBuffer(data) : data;
|
|
698
|
+
}
|
|
699
|
+
function toArrayBuffer2(data) {
|
|
700
|
+
if (isBuffer(data)) {
|
|
701
|
+
return toArrayBuffer(data);
|
|
702
|
+
}
|
|
703
|
+
if (data instanceof ArrayBuffer) {
|
|
704
|
+
return data;
|
|
705
|
+
}
|
|
706
|
+
if (ArrayBuffer.isView(data)) {
|
|
707
|
+
if (data.byteOffset === 0 && data.byteLength === data.buffer.byteLength) {
|
|
708
|
+
return data.buffer;
|
|
709
|
+
}
|
|
710
|
+
return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
|
|
711
|
+
}
|
|
712
|
+
if (typeof data === "string") {
|
|
713
|
+
const text = data;
|
|
714
|
+
const uint8Array = new TextEncoder().encode(text);
|
|
715
|
+
return uint8Array.buffer;
|
|
716
|
+
}
|
|
717
|
+
if (data && typeof data === "object" && data._toArrayBuffer) {
|
|
718
|
+
return data._toArrayBuffer();
|
|
719
|
+
}
|
|
720
|
+
throw new Error("toArrayBuffer");
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
// src/lib/node/promisify.ts
|
|
724
|
+
function promisify1(fn) {
|
|
725
|
+
return (args) => new Promise(
|
|
726
|
+
(resolve2, reject) => fn(args, (error, callbackArgs) => error ? reject(error) : resolve2(callbackArgs))
|
|
727
|
+
);
|
|
728
|
+
}
|
|
729
|
+
function promisify2(fn) {
|
|
730
|
+
return (arg1, arg2) => new Promise(
|
|
731
|
+
(resolve2, reject) => fn(arg1, arg2, (error, callbackArgs) => error ? reject(error) : resolve2(callbackArgs))
|
|
732
|
+
);
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
// src/lib/path-utils/path.ts
|
|
736
|
+
var path_exports = {};
|
|
737
|
+
__export(path_exports, {
|
|
738
|
+
dirname: () => dirname,
|
|
739
|
+
filename: () => filename,
|
|
740
|
+
join: () => join,
|
|
741
|
+
resolve: () => resolve
|
|
742
|
+
});
|
|
743
|
+
|
|
744
|
+
// src/lib/path-utils/get-cwd.ts
|
|
745
|
+
function getCWD() {
|
|
746
|
+
var _a;
|
|
747
|
+
if (typeof process !== "undefined" && typeof process.cwd !== "undefined") {
|
|
748
|
+
return process.cwd();
|
|
749
|
+
}
|
|
750
|
+
const pathname = (_a = window.location) == null ? void 0 : _a.pathname;
|
|
751
|
+
return (pathname == null ? void 0 : pathname.slice(0, pathname.lastIndexOf("/") + 1)) || "";
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
// src/lib/path-utils/path.ts
|
|
755
|
+
function filename(url) {
|
|
756
|
+
const slashIndex = url ? url.lastIndexOf("/") : -1;
|
|
757
|
+
return slashIndex >= 0 ? url.substr(slashIndex + 1) : "";
|
|
758
|
+
}
|
|
759
|
+
function dirname(url) {
|
|
760
|
+
const slashIndex = url ? url.lastIndexOf("/") : -1;
|
|
761
|
+
return slashIndex >= 0 ? url.substr(0, slashIndex) : "";
|
|
762
|
+
}
|
|
763
|
+
function join(...parts) {
|
|
764
|
+
const separator = "/";
|
|
765
|
+
parts = parts.map((part, index) => {
|
|
766
|
+
if (index) {
|
|
767
|
+
part = part.replace(new RegExp(`^${separator}`), "");
|
|
768
|
+
}
|
|
769
|
+
if (index !== parts.length - 1) {
|
|
770
|
+
part = part.replace(new RegExp(`${separator}$`), "");
|
|
771
|
+
}
|
|
772
|
+
return part;
|
|
773
|
+
});
|
|
774
|
+
return parts.join(separator);
|
|
775
|
+
}
|
|
776
|
+
function resolve(...components) {
|
|
777
|
+
const paths = [];
|
|
778
|
+
for (let _i = 0; _i < components.length; _i++) {
|
|
779
|
+
paths[_i] = components[_i];
|
|
780
|
+
}
|
|
781
|
+
let resolvedPath = "";
|
|
782
|
+
let resolvedAbsolute = false;
|
|
783
|
+
let cwd;
|
|
784
|
+
for (let i = paths.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
|
785
|
+
let path;
|
|
786
|
+
if (i >= 0) {
|
|
787
|
+
path = paths[i];
|
|
788
|
+
} else {
|
|
789
|
+
if (cwd === void 0) {
|
|
790
|
+
cwd = getCWD();
|
|
791
|
+
}
|
|
792
|
+
path = cwd;
|
|
793
|
+
}
|
|
794
|
+
if (path.length === 0) {
|
|
795
|
+
continue;
|
|
796
|
+
}
|
|
797
|
+
resolvedPath = `${path}/${resolvedPath}`;
|
|
798
|
+
resolvedAbsolute = path.charCodeAt(0) === SLASH;
|
|
799
|
+
}
|
|
800
|
+
resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute);
|
|
801
|
+
if (resolvedAbsolute) {
|
|
802
|
+
return `/${resolvedPath}`;
|
|
803
|
+
} else if (resolvedPath.length > 0) {
|
|
804
|
+
return resolvedPath;
|
|
805
|
+
}
|
|
806
|
+
return ".";
|
|
807
|
+
}
|
|
808
|
+
var SLASH = 47;
|
|
809
|
+
var DOT = 46;
|
|
810
|
+
function normalizeStringPosix(path, allowAboveRoot) {
|
|
811
|
+
let res = "";
|
|
812
|
+
let lastSlash = -1;
|
|
813
|
+
let dots = 0;
|
|
814
|
+
let code;
|
|
815
|
+
let isAboveRoot = false;
|
|
816
|
+
for (let i = 0; i <= path.length; ++i) {
|
|
817
|
+
if (i < path.length) {
|
|
818
|
+
code = path.charCodeAt(i);
|
|
819
|
+
} else if (code === SLASH) {
|
|
820
|
+
break;
|
|
821
|
+
} else {
|
|
822
|
+
code = SLASH;
|
|
823
|
+
}
|
|
824
|
+
if (code === SLASH) {
|
|
825
|
+
if (lastSlash === i - 1 || dots === 1) {
|
|
826
|
+
} else if (lastSlash !== i - 1 && dots === 2) {
|
|
827
|
+
if (res.length < 2 || !isAboveRoot || res.charCodeAt(res.length - 1) !== DOT || res.charCodeAt(res.length - 2) !== DOT) {
|
|
828
|
+
if (res.length > 2) {
|
|
829
|
+
const start = res.length - 1;
|
|
830
|
+
let j = start;
|
|
831
|
+
for (; j >= 0; --j) {
|
|
832
|
+
if (res.charCodeAt(j) === SLASH) {
|
|
833
|
+
break;
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
if (j !== start) {
|
|
837
|
+
res = j === -1 ? "" : res.slice(0, j);
|
|
838
|
+
lastSlash = i;
|
|
839
|
+
dots = 0;
|
|
840
|
+
isAboveRoot = false;
|
|
841
|
+
continue;
|
|
842
|
+
}
|
|
843
|
+
} else if (res.length === 2 || res.length === 1) {
|
|
844
|
+
res = "";
|
|
845
|
+
lastSlash = i;
|
|
846
|
+
dots = 0;
|
|
847
|
+
isAboveRoot = false;
|
|
848
|
+
continue;
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
if (allowAboveRoot) {
|
|
852
|
+
if (res.length > 0) {
|
|
853
|
+
res += "/..";
|
|
854
|
+
} else {
|
|
855
|
+
res = "..";
|
|
856
|
+
}
|
|
857
|
+
isAboveRoot = true;
|
|
858
|
+
}
|
|
859
|
+
} else {
|
|
860
|
+
const slice = path.slice(lastSlash + 1, i);
|
|
861
|
+
if (res.length > 0) {
|
|
862
|
+
res += `/${slice}`;
|
|
863
|
+
} else {
|
|
864
|
+
res = slice;
|
|
865
|
+
}
|
|
866
|
+
isAboveRoot = false;
|
|
867
|
+
}
|
|
868
|
+
lastSlash = i;
|
|
869
|
+
dots = 0;
|
|
870
|
+
} else if (code === DOT && dots !== -1) {
|
|
871
|
+
++dots;
|
|
872
|
+
} else {
|
|
873
|
+
dots = -1;
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
return res;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
// src/lib/node/stream.browser.ts
|
|
880
|
+
var stream_browser_exports = {};
|
|
881
|
+
__export(stream_browser_exports, {
|
|
882
|
+
isSupported: () => isSupported
|
|
883
|
+
});
|
|
884
|
+
var isSupported = false;
|
|
885
|
+
|
|
886
|
+
// src/lib/files/blob-file.ts
|
|
887
|
+
var BlobFile = class {
|
|
888
|
+
constructor(blob) {
|
|
889
|
+
this.handle = blob instanceof ArrayBuffer ? new Blob([blob]) : blob;
|
|
890
|
+
this.size = blob instanceof ArrayBuffer ? blob.byteLength : blob.size;
|
|
891
|
+
this.bigsize = BigInt(this.size);
|
|
892
|
+
this.url = blob instanceof File ? blob.name : "";
|
|
893
|
+
}
|
|
894
|
+
async close() {
|
|
895
|
+
}
|
|
896
|
+
async stat() {
|
|
897
|
+
return {
|
|
898
|
+
size: this.handle.size,
|
|
899
|
+
bigsize: BigInt(this.handle.size),
|
|
900
|
+
isDirectory: false
|
|
901
|
+
};
|
|
902
|
+
}
|
|
903
|
+
async read(start, length) {
|
|
904
|
+
const arrayBuffer = await this.handle.slice(start, start + length).arrayBuffer();
|
|
905
|
+
return arrayBuffer;
|
|
906
|
+
}
|
|
907
|
+
};
|
|
908
|
+
|
|
909
|
+
// src/lib/files/http-file.ts
|
|
910
|
+
var HttpFile = class {
|
|
911
|
+
constructor(url) {
|
|
912
|
+
this.size = 0;
|
|
913
|
+
this.bigsize = 0n;
|
|
914
|
+
this.handle = url;
|
|
915
|
+
this.url = url;
|
|
916
|
+
}
|
|
917
|
+
async close() {
|
|
918
|
+
}
|
|
919
|
+
async stat() {
|
|
920
|
+
const response = await fetch(this.handle, { method: "HEAD" });
|
|
921
|
+
if (!response.ok) {
|
|
922
|
+
throw new Error(`Failed to fetch HEAD ${this.handle}`);
|
|
923
|
+
}
|
|
924
|
+
const size = parseInt(response.headers.get("Content-Length") || "0");
|
|
925
|
+
return {
|
|
926
|
+
size,
|
|
927
|
+
bigsize: BigInt(size),
|
|
928
|
+
isDirectory: false
|
|
929
|
+
};
|
|
930
|
+
}
|
|
931
|
+
async read(offset, length) {
|
|
932
|
+
const response = await this.fetchRange(offset, length);
|
|
933
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
934
|
+
return arrayBuffer;
|
|
935
|
+
}
|
|
936
|
+
/**
|
|
937
|
+
*
|
|
938
|
+
* @param offset
|
|
939
|
+
* @param length
|
|
940
|
+
* @param signal
|
|
941
|
+
* @returns
|
|
942
|
+
* @see https://github.com/protomaps/PMTiles
|
|
943
|
+
*/
|
|
944
|
+
// eslint-disable-next-line complexity
|
|
945
|
+
async fetchRange(offset, length, signal) {
|
|
946
|
+
const nOffset = Number(offset);
|
|
947
|
+
const nLength = Number(length);
|
|
948
|
+
let controller;
|
|
949
|
+
if (!signal) {
|
|
950
|
+
controller = new AbortController();
|
|
951
|
+
signal = controller.signal;
|
|
952
|
+
}
|
|
953
|
+
const url = this.handle;
|
|
954
|
+
let response = await fetch(url, {
|
|
955
|
+
signal,
|
|
956
|
+
headers: { Range: `bytes=${nOffset}-${nOffset + nLength - 1}` }
|
|
957
|
+
});
|
|
958
|
+
switch (response.status) {
|
|
959
|
+
case 206:
|
|
960
|
+
break;
|
|
961
|
+
case 200:
|
|
962
|
+
const contentLength = response.headers.get("Content-Length");
|
|
963
|
+
if (!contentLength || Number(contentLength) > length) {
|
|
964
|
+
if (controller) {
|
|
965
|
+
controller.abort();
|
|
966
|
+
}
|
|
967
|
+
throw Error(
|
|
968
|
+
"content-length header missing or exceeding request. Server must support HTTP Byte Serving."
|
|
969
|
+
);
|
|
970
|
+
}
|
|
971
|
+
case 416:
|
|
972
|
+
if (offset === 0) {
|
|
973
|
+
const contentRange = response.headers.get("Content-Range");
|
|
974
|
+
if (!contentRange || !contentRange.startsWith("bytes *")) {
|
|
975
|
+
throw Error("Missing content-length on 416 response");
|
|
976
|
+
}
|
|
977
|
+
const actualLength = Number(contentRange.substr(8));
|
|
978
|
+
response = await fetch(this.url, {
|
|
979
|
+
signal,
|
|
980
|
+
headers: { Range: `bytes=0-${actualLength - 1}` }
|
|
981
|
+
});
|
|
982
|
+
}
|
|
983
|
+
break;
|
|
984
|
+
default:
|
|
985
|
+
if (response.status >= 300) {
|
|
986
|
+
throw Error(`Bad response code: ${response.status}`);
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
return response;
|
|
990
|
+
}
|
|
991
|
+
};
|
|
992
|
+
|
|
993
|
+
// src/lib/files/node-file-facade.ts
|
|
994
|
+
var NOT_IMPLEMENTED = new Error("Not implemented");
|
|
995
|
+
var NodeFileFacade = class {
|
|
996
|
+
constructor(url, flags, mode) {
|
|
997
|
+
this.size = 0;
|
|
998
|
+
this.bigsize = 0n;
|
|
999
|
+
this.url = "";
|
|
1000
|
+
var _a;
|
|
1001
|
+
if ((_a = globalThis.loaders) == null ? void 0 : _a.NodeFile) {
|
|
1002
|
+
return new globalThis.loaders.NodeFile(url, flags, mode);
|
|
1003
|
+
}
|
|
1004
|
+
if (isBrowser) {
|
|
1005
|
+
throw new Error("Can't instantiate NodeFile in browser.");
|
|
1006
|
+
}
|
|
1007
|
+
throw new Error("Can't instantiate NodeFile. Make sure to import @loaders.gl/polyfills first.");
|
|
1008
|
+
}
|
|
1009
|
+
/** Read data */
|
|
1010
|
+
async read(start, end) {
|
|
1011
|
+
throw NOT_IMPLEMENTED;
|
|
1012
|
+
}
|
|
1013
|
+
/** Write to file. The number of bytes written will be returned */
|
|
1014
|
+
async write(arrayBuffer, offset, length) {
|
|
1015
|
+
throw NOT_IMPLEMENTED;
|
|
1016
|
+
}
|
|
1017
|
+
/** Get information about file */
|
|
1018
|
+
async stat() {
|
|
1019
|
+
throw NOT_IMPLEMENTED;
|
|
1020
|
+
}
|
|
1021
|
+
/** Close the file */
|
|
1022
|
+
async close() {
|
|
1023
|
+
}
|
|
1024
|
+
};
|
|
1025
|
+
|
|
1026
|
+
// src/lib/filesystems/node-filesystem-facade.ts
|
|
1027
|
+
var NOT_IMPLEMENTED2 = new Error("Not implemented");
|
|
1028
|
+
var NodeFileSystemFacade = class {
|
|
1029
|
+
// implements FileSystem
|
|
1030
|
+
constructor(options) {
|
|
1031
|
+
// DUMMY IMPLEMENTATION, not used (constructor returns a real NodeFileSystem instance)
|
|
1032
|
+
// implements RandomAccessReadFileSystem
|
|
1033
|
+
this.readable = true;
|
|
1034
|
+
this.writable = true;
|
|
1035
|
+
var _a;
|
|
1036
|
+
if ((_a = globalThis.loaders) == null ? void 0 : _a.NodeFileSystem) {
|
|
1037
|
+
return new globalThis.loaders.NodeFileSystem(options);
|
|
1038
|
+
}
|
|
1039
|
+
if (isBrowser) {
|
|
1040
|
+
throw new Error("Can't instantiate NodeFileSystem in browser.");
|
|
1041
|
+
}
|
|
1042
|
+
throw new Error(
|
|
1043
|
+
"Can't instantiate NodeFileSystem. Make sure to import @loaders.gl/polyfills first."
|
|
1044
|
+
);
|
|
1045
|
+
}
|
|
1046
|
+
async openReadableFile(path, flags) {
|
|
1047
|
+
throw NOT_IMPLEMENTED2;
|
|
1048
|
+
}
|
|
1049
|
+
// implements RandomAccessWriteFileSystem
|
|
1050
|
+
async openWritableFile(path, flags, mode) {
|
|
1051
|
+
throw NOT_IMPLEMENTED2;
|
|
1052
|
+
}
|
|
1053
|
+
// Implements file system
|
|
1054
|
+
async readdir(dirname2 = ".", options) {
|
|
1055
|
+
throw NOT_IMPLEMENTED2;
|
|
1056
|
+
}
|
|
1057
|
+
async stat(path, options) {
|
|
1058
|
+
throw NOT_IMPLEMENTED2;
|
|
1059
|
+
}
|
|
1060
|
+
async unlink(path) {
|
|
1061
|
+
throw NOT_IMPLEMENTED2;
|
|
1062
|
+
}
|
|
1063
|
+
async fetch(path, options) {
|
|
1064
|
+
throw NOT_IMPLEMENTED2;
|
|
1065
|
+
}
|
|
1066
|
+
};
|
|
1067
|
+
|
|
1068
|
+
// src/lib/file-provider/file-provider.ts
|
|
1069
|
+
var isFileProvider = (fileProvider) => {
|
|
1070
|
+
return (fileProvider == null ? void 0 : fileProvider.getUint8) && (fileProvider == null ? void 0 : fileProvider.slice) && (fileProvider == null ? void 0 : fileProvider.length);
|
|
1071
|
+
};
|
|
1072
|
+
|
|
1073
|
+
// src/lib/file-provider/file-handle-file.ts
|
|
1074
|
+
var FileHandleFile = class {
|
|
1075
|
+
/** Create a new FileHandleFile */
|
|
1076
|
+
constructor(path) {
|
|
1077
|
+
this.file = new NodeFileFacade(path, "r");
|
|
1078
|
+
this.size = this.file.bigsize;
|
|
1079
|
+
}
|
|
1080
|
+
/** Close file */
|
|
1081
|
+
async destroy() {
|
|
1082
|
+
await this.file.close();
|
|
1083
|
+
}
|
|
1084
|
+
/**
|
|
1085
|
+
* Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.
|
|
1086
|
+
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
1087
|
+
*/
|
|
1088
|
+
async getUint8(offset) {
|
|
1089
|
+
const arrayBuffer = await this.file.read(offset, 1);
|
|
1090
|
+
const val = new Uint8Array(arrayBuffer).at(0);
|
|
1091
|
+
if (val === void 0) {
|
|
1092
|
+
throw new Error("something went wrong");
|
|
1093
|
+
}
|
|
1094
|
+
return val;
|
|
1095
|
+
}
|
|
1096
|
+
/**
|
|
1097
|
+
* Gets an unsigned 16-bit integer at the specified byte offset from the start of the file.
|
|
1098
|
+
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
1099
|
+
*/
|
|
1100
|
+
async getUint16(offset) {
|
|
1101
|
+
const arrayBuffer = await this.file.read(offset, 2);
|
|
1102
|
+
const val = new Uint16Array(arrayBuffer).at(0);
|
|
1103
|
+
if (val === void 0) {
|
|
1104
|
+
throw new Error("something went wrong");
|
|
1105
|
+
}
|
|
1106
|
+
return val;
|
|
1107
|
+
}
|
|
1108
|
+
/**
|
|
1109
|
+
* Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
|
|
1110
|
+
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
1111
|
+
*/
|
|
1112
|
+
async getUint32(offset) {
|
|
1113
|
+
const arrayBuffer = await this.file.read(offset, 4);
|
|
1114
|
+
const val = new Uint32Array(arrayBuffer).at(0);
|
|
1115
|
+
if (val === void 0) {
|
|
1116
|
+
throw new Error("something went wrong");
|
|
1117
|
+
}
|
|
1118
|
+
return val;
|
|
1119
|
+
}
|
|
1120
|
+
/**
|
|
1121
|
+
* Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
|
|
1122
|
+
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
1123
|
+
*/
|
|
1124
|
+
async getBigUint64(offset) {
|
|
1125
|
+
const arrayBuffer = await this.file.read(offset, 8);
|
|
1126
|
+
const val = new BigInt64Array(arrayBuffer).at(0);
|
|
1127
|
+
if (val === void 0) {
|
|
1128
|
+
throw new Error("something went wrong");
|
|
1129
|
+
}
|
|
1130
|
+
return val;
|
|
1131
|
+
}
|
|
1132
|
+
/**
|
|
1133
|
+
* returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
|
|
1134
|
+
* @param startOffset The offset, in byte, from the start of the file where to start reading the data.
|
|
1135
|
+
* @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
|
|
1136
|
+
*/
|
|
1137
|
+
async slice(startOffset, endOffset) {
|
|
1138
|
+
const bigLength = endOffset - startOffset;
|
|
1139
|
+
if (bigLength > Number.MAX_SAFE_INTEGER) {
|
|
1140
|
+
throw new Error("too big slice");
|
|
1141
|
+
}
|
|
1142
|
+
const length = Number(bigLength);
|
|
1143
|
+
return await this.file.read(startOffset, length);
|
|
1144
|
+
}
|
|
1145
|
+
/**
|
|
1146
|
+
* the length (in bytes) of the data.
|
|
1147
|
+
*/
|
|
1148
|
+
get length() {
|
|
1149
|
+
return this.size;
|
|
1150
|
+
}
|
|
1151
|
+
};
|
|
1152
|
+
|
|
1153
|
+
// src/lib/file-provider/data-view-file.ts
|
|
1154
|
+
var toNumber = (bigint) => {
|
|
1155
|
+
if (bigint > Number.MAX_SAFE_INTEGER) {
|
|
1156
|
+
throw new Error("Offset is out of bounds");
|
|
1157
|
+
}
|
|
1158
|
+
return Number(bigint);
|
|
1159
|
+
};
|
|
1160
|
+
var DataViewFile = class {
|
|
1161
|
+
constructor(file) {
|
|
1162
|
+
this.file = file;
|
|
1163
|
+
}
|
|
1164
|
+
async destroy() {
|
|
1165
|
+
}
|
|
1166
|
+
/**
|
|
1167
|
+
* Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.
|
|
1168
|
+
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
1169
|
+
*/
|
|
1170
|
+
async getUint8(offset) {
|
|
1171
|
+
return this.file.getUint8(toNumber(offset));
|
|
1172
|
+
}
|
|
1173
|
+
/**
|
|
1174
|
+
* Gets an unsigned 16-bit intege at the specified byte offset from the start of the file.
|
|
1175
|
+
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
1176
|
+
*/
|
|
1177
|
+
async getUint16(offset) {
|
|
1178
|
+
return this.file.getUint16(toNumber(offset), true);
|
|
1179
|
+
}
|
|
1180
|
+
/**
|
|
1181
|
+
* Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
|
|
1182
|
+
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
1183
|
+
*/
|
|
1184
|
+
async getUint32(offset) {
|
|
1185
|
+
return this.file.getUint32(toNumber(offset), true);
|
|
1186
|
+
}
|
|
1187
|
+
/**
|
|
1188
|
+
* Gets an unsigned 64-bit integer at the specified byte offset from the start of the file.
|
|
1189
|
+
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
1190
|
+
*/
|
|
1191
|
+
async getBigUint64(offset) {
|
|
1192
|
+
return this.file.getBigUint64(toNumber(offset), true);
|
|
1193
|
+
}
|
|
1194
|
+
/**
|
|
1195
|
+
* returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
|
|
1196
|
+
* @param startOffset The offset, in bytes, from the start of the file where to start reading the data.
|
|
1197
|
+
* @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
|
|
1198
|
+
*/
|
|
1199
|
+
async slice(startOffset, endOffset) {
|
|
1200
|
+
return this.file.buffer.slice(toNumber(startOffset), toNumber(endOffset));
|
|
1201
|
+
}
|
|
1202
|
+
/** the length (in bytes) of the data. */
|
|
1203
|
+
get length() {
|
|
1204
|
+
return BigInt(this.file.byteLength);
|
|
1205
|
+
}
|
|
1206
|
+
};
|
|
1207
|
+
|
|
1208
|
+
// src/lib/sources/data-source.ts
|
|
1209
|
+
var DataSource = class {
|
|
1210
|
+
constructor(props) {
|
|
1211
|
+
this._needsRefresh = true;
|
|
1212
|
+
this.props = { ...props };
|
|
1213
|
+
this.loadOptions = { ...props.loadOptions };
|
|
1214
|
+
this.fetch = getFetchFunction(this.loadOptions);
|
|
1215
|
+
}
|
|
1216
|
+
setProps(props) {
|
|
1217
|
+
this.props = Object.assign(this.props, props);
|
|
1218
|
+
this.setNeedsRefresh();
|
|
1219
|
+
}
|
|
1220
|
+
/** Mark this data source as needing a refresh (redraw) */
|
|
1221
|
+
setNeedsRefresh() {
|
|
1222
|
+
this._needsRefresh = true;
|
|
1223
|
+
}
|
|
1224
|
+
/**
|
|
1225
|
+
* Does this data source need refreshing?
|
|
1226
|
+
* @note The specifics of the refresh mechanism depends on type of data source
|
|
1227
|
+
*/
|
|
1228
|
+
getNeedsRefresh(clear = true) {
|
|
1229
|
+
const needsRefresh = this._needsRefresh;
|
|
1230
|
+
if (clear) {
|
|
1231
|
+
this._needsRefresh = false;
|
|
1232
|
+
}
|
|
1233
|
+
return needsRefresh;
|
|
1234
|
+
}
|
|
1235
|
+
};
|
|
1236
|
+
function getFetchFunction(options) {
|
|
1237
|
+
const fetchFunction = options == null ? void 0 : options.fetch;
|
|
1238
|
+
if (fetchFunction && typeof fetchFunction === "function") {
|
|
1239
|
+
return (url, fetchOptions2) => fetchFunction(url, fetchOptions2);
|
|
1240
|
+
}
|
|
1241
|
+
const fetchOptions = options == null ? void 0 : options.fetch;
|
|
1242
|
+
if (fetchOptions && typeof fetchOptions !== "function") {
|
|
1243
|
+
return (url) => fetch(url, fetchOptions);
|
|
1244
|
+
}
|
|
1245
|
+
return (url) => fetch(url);
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
// src/lib/sources/image-source.ts
|
|
1249
|
+
var ImageSource = class extends DataSource {
|
|
1250
|
+
};
|
|
1251
|
+
ImageSource.type = "template";
|
|
1252
|
+
ImageSource.testURL = (url) => false;
|