@loaders.gl/core 4.0.0-alpha.4 → 4.0.0-alpha.6
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/bundle.d.ts +2 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +2 -2
- package/dist/core-addons/write-file-browser.d.ts +1 -0
- package/dist/core-addons/write-file-browser.d.ts.map +1 -0
- package/dist/core-addons/write-file-browser.js +59 -1
- package/dist/dist.min.js +3874 -0
- package/dist/es5/bundle.js +6 -0
- package/dist/es5/bundle.js.map +1 -0
- package/dist/es5/core-addons/write-file-browser.js +2 -0
- package/dist/es5/core-addons/write-file-browser.js.map +1 -0
- package/dist/es5/index.js +377 -0
- package/dist/es5/index.js.map +1 -0
- package/dist/es5/iterators/batch-iterators/timed-batch-iterator.js +94 -0
- package/dist/es5/iterators/batch-iterators/timed-batch-iterator.js.map +1 -0
- package/dist/es5/iterators/make-iterator/make-array-buffer-iterator.js +42 -0
- package/dist/es5/iterators/make-iterator/make-array-buffer-iterator.js.map +1 -0
- package/dist/es5/iterators/make-iterator/make-blob-iterator.js +47 -0
- package/dist/es5/iterators/make-iterator/make-blob-iterator.js.map +1 -0
- package/dist/es5/iterators/make-iterator/make-iterator.js +31 -0
- package/dist/es5/iterators/make-iterator/make-iterator.js.map +1 -0
- package/dist/es5/iterators/make-iterator/make-stream-iterator.js +133 -0
- package/dist/es5/iterators/make-iterator/make-stream-iterator.js.map +1 -0
- package/dist/es5/iterators/make-iterator/make-string-iterator.js +38 -0
- package/dist/es5/iterators/make-iterator/make-string-iterator.js.map +1 -0
- package/dist/es5/iterators/make-stream/make-dom-stream.js +67 -0
- package/dist/es5/iterators/make-stream/make-dom-stream.js.map +1 -0
- package/dist/es5/iterators/make-stream/make-node-stream.js +168 -0
- package/dist/es5/iterators/make-stream/make-node-stream.js.map +1 -0
- package/dist/es5/javascript-utils/is-type.js +79 -0
- package/dist/es5/javascript-utils/is-type.js.map +1 -0
- package/dist/es5/lib/api/encode-table.js +159 -0
- package/dist/es5/lib/api/encode-table.js.map +1 -0
- package/dist/es5/lib/api/encode.js +244 -0
- package/dist/es5/lib/api/encode.js.map +1 -0
- package/dist/es5/lib/api/load-in-batches.js +63 -0
- package/dist/es5/lib/api/load-in-batches.js.map +1 -0
- package/dist/es5/lib/api/load.js +76 -0
- package/dist/es5/lib/api/load.js.map +1 -0
- package/dist/es5/lib/api/loader-options.js +19 -0
- package/dist/es5/lib/api/loader-options.js.map +1 -0
- package/dist/es5/lib/api/parse-in-batches.js +277 -0
- package/dist/es5/lib/api/parse-in-batches.js.map +1 -0
- package/dist/es5/lib/api/parse-sync.js +54 -0
- package/dist/es5/lib/api/parse-sync.js.map +1 -0
- package/dist/es5/lib/api/parse.js +143 -0
- package/dist/es5/lib/api/parse.js.map +1 -0
- package/dist/es5/lib/api/register-loaders.js +50 -0
- package/dist/es5/lib/api/register-loaders.js.map +1 -0
- package/dist/es5/lib/api/save.js +42 -0
- package/dist/es5/lib/api/save.js.map +1 -0
- package/dist/es5/lib/api/select-loader.js +303 -0
- package/dist/es5/lib/api/select-loader.js.map +1 -0
- package/dist/es5/lib/common.js +2 -0
- package/dist/es5/lib/common.js.map +1 -0
- package/dist/es5/lib/fetch/fetch-error-message.js +56 -0
- package/dist/es5/lib/fetch/fetch-error-message.js.map +1 -0
- package/dist/es5/lib/fetch/fetch-file.js +47 -0
- package/dist/es5/lib/fetch/fetch-file.js.map +1 -0
- package/dist/es5/lib/fetch/read-array-buffer.js +76 -0
- package/dist/es5/lib/fetch/read-array-buffer.js.map +1 -0
- package/dist/es5/lib/fetch/read-file.js +20 -0
- package/dist/es5/lib/fetch/read-file.js.map +1 -0
- package/dist/es5/lib/fetch/write-file.js +48 -0
- package/dist/es5/lib/fetch/write-file.js.map +1 -0
- package/dist/es5/lib/filesystems/browser-filesystem.js +249 -0
- package/dist/es5/lib/filesystems/browser-filesystem.js.map +1 -0
- package/dist/es5/lib/filesystems/filesystem.js +2 -0
- package/dist/es5/lib/filesystems/filesystem.js.map +1 -0
- package/dist/es5/lib/filesystems/read-array-buffer.js +41 -0
- package/dist/es5/lib/filesystems/read-array-buffer.js.map +1 -0
- package/dist/es5/lib/init.js +18 -0
- package/dist/es5/lib/init.js.map +1 -0
- package/dist/es5/lib/loader-utils/check-errors.js +57 -0
- package/dist/es5/lib/loader-utils/check-errors.js.map +1 -0
- package/dist/es5/lib/loader-utils/get-data.js +237 -0
- package/dist/es5/lib/loader-utils/get-data.js.map +1 -0
- package/dist/es5/lib/loader-utils/get-fetch-function.js +26 -0
- package/dist/es5/lib/loader-utils/get-fetch-function.js.map +1 -0
- package/dist/es5/lib/loader-utils/loader-context.js +41 -0
- package/dist/es5/lib/loader-utils/loader-context.js.map +1 -0
- package/dist/es5/lib/loader-utils/loggers.js +90 -0
- package/dist/es5/lib/loader-utils/loggers.js.map +1 -0
- package/dist/es5/lib/loader-utils/normalize-loader.js +44 -0
- package/dist/es5/lib/loader-utils/normalize-loader.js.map +1 -0
- package/dist/es5/lib/loader-utils/option-defaults.js +47 -0
- package/dist/es5/lib/loader-utils/option-defaults.js.map +1 -0
- package/dist/es5/lib/loader-utils/option-utils.js +132 -0
- package/dist/es5/lib/loader-utils/option-utils.js.map +1 -0
- package/dist/es5/lib/progress/fetch-progress.js +134 -0
- package/dist/es5/lib/progress/fetch-progress.js.map +1 -0
- package/dist/es5/lib/utils/log.js +12 -0
- package/dist/es5/lib/utils/log.js.map +1 -0
- package/dist/es5/lib/utils/mime-type-utils.js +24 -0
- package/dist/es5/lib/utils/mime-type-utils.js.map +1 -0
- package/dist/es5/lib/utils/resource-utils.js +58 -0
- package/dist/es5/lib/utils/resource-utils.js.map +1 -0
- package/dist/es5/lib/utils/response-utils.js +196 -0
- package/dist/es5/lib/utils/response-utils.js.map +1 -0
- package/dist/es5/null-loader.js +139 -0
- package/dist/es5/null-loader.js.map +1 -0
- package/dist/es5/workers/null-worker.js +6 -0
- package/dist/es5/workers/null-worker.js.map +1 -0
- package/dist/esm/bundle.js +4 -0
- package/dist/esm/bundle.js.map +1 -0
- package/dist/esm/core-addons/README.md +1 -0
- package/dist/esm/core-addons/write-file-browser.js +2 -0
- package/dist/esm/core-addons/write-file-browser.js.map +1 -0
- package/dist/esm/index.js +30 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/iterators/batch-iterators/timed-batch-iterator.js +16 -0
- package/dist/esm/iterators/batch-iterators/timed-batch-iterator.js.map +1 -0
- package/dist/esm/iterators/make-iterator/make-array-buffer-iterator.js +20 -0
- package/dist/esm/iterators/make-iterator/make-array-buffer-iterator.js.map +1 -0
- package/dist/esm/iterators/make-iterator/make-blob-iterator.js +12 -0
- package/dist/esm/iterators/make-iterator/make-blob-iterator.js.map +1 -0
- package/dist/esm/iterators/make-iterator/make-iterator.js +25 -0
- package/dist/esm/iterators/make-iterator/make-iterator.js.map +1 -0
- package/dist/esm/iterators/make-iterator/make-stream-iterator.js +32 -0
- package/dist/esm/iterators/make-iterator/make-stream-iterator.js.map +1 -0
- package/dist/esm/iterators/make-iterator/make-string-iterator.js +13 -0
- package/dist/esm/iterators/make-iterator/make-string-iterator.js.map +1 -0
- package/dist/esm/iterators/make-stream/make-dom-stream.js +29 -0
- package/dist/esm/iterators/make-stream/make-dom-stream.js.map +1 -0
- package/dist/esm/iterators/make-stream/make-node-stream.js +57 -0
- package/dist/esm/iterators/make-stream/make-node-stream.js.map +1 -0
- package/dist/esm/javascript-utils/is-type.js +19 -0
- package/dist/esm/javascript-utils/is-type.js.map +1 -0
- package/dist/esm/lib/api/encode-table.js +45 -0
- package/dist/esm/lib/api/encode-table.js.map +1 -0
- package/dist/esm/lib/api/encode.js +87 -0
- package/dist/esm/lib/api/encode.js.map +1 -0
- package/dist/esm/lib/api/load-in-batches.js +25 -0
- package/dist/esm/lib/api/load-in-batches.js.map +1 -0
- package/dist/esm/lib/api/load.js +26 -0
- package/dist/esm/lib/api/load.js.map +1 -0
- package/dist/esm/lib/api/loader-options.js +3 -0
- package/dist/esm/lib/api/loader-options.js.map +1 -0
- package/dist/esm/lib/api/parse-in-batches.js +85 -0
- package/dist/esm/lib/api/parse-in-batches.js.map +1 -0
- package/dist/esm/lib/api/parse-sync.js +47 -0
- package/dist/esm/lib/api/parse-sync.js.map +1 -0
- package/dist/esm/lib/api/parse.js +76 -0
- package/dist/esm/lib/api/parse.js.map +1 -0
- package/dist/esm/lib/api/register-loaders.js +25 -0
- package/dist/esm/lib/api/register-loaders.js.map +1 -0
- package/dist/esm/lib/api/save.js +11 -0
- package/dist/esm/lib/api/save.js.map +1 -0
- package/dist/esm/lib/api/select-loader.js +204 -0
- package/dist/esm/lib/api/select-loader.js.map +1 -0
- package/dist/esm/lib/common.js +2 -0
- package/dist/esm/lib/common.js.map +1 -0
- package/dist/esm/lib/fetch/fetch-error-message.js +18 -0
- package/dist/esm/lib/fetch/fetch-error-message.js.map +1 -0
- package/dist/esm/lib/fetch/fetch-file.js +14 -0
- package/dist/esm/lib/fetch/fetch-file.js.map +1 -0
- package/dist/esm/lib/fetch/read-array-buffer.js +23 -0
- package/dist/esm/lib/fetch/read-array-buffer.js.map +1 -0
- package/dist/esm/lib/fetch/read-file.js +15 -0
- package/dist/esm/lib/fetch/read-file.js.map +1 -0
- package/dist/esm/lib/fetch/write-file.js +21 -0
- package/dist/esm/lib/fetch/write-file.js.map +1 -0
- package/dist/esm/lib/filesystems/browser-filesystem.js +92 -0
- package/dist/esm/lib/filesystems/browser-filesystem.js.map +1 -0
- package/dist/esm/lib/filesystems/filesystem.js +2 -0
- package/dist/esm/lib/filesystems/filesystem.js.map +1 -0
- package/dist/esm/lib/filesystems/read-array-buffer.js +8 -0
- package/dist/esm/lib/filesystems/read-array-buffer.js.map +1 -0
- package/dist/esm/lib/init.js +11 -0
- package/dist/esm/lib/init.js.map +1 -0
- package/dist/esm/lib/loader-utils/check-errors.js +22 -0
- package/dist/esm/lib/loader-utils/check-errors.js.map +1 -0
- package/dist/esm/lib/loader-utils/get-data.js +103 -0
- package/dist/esm/lib/loader-utils/get-data.js.map +1 -0
- package/dist/esm/lib/loader-utils/get-fetch-function.js +18 -0
- package/dist/esm/lib/loader-utils/get-fetch-function.js.map +1 -0
- package/dist/esm/lib/loader-utils/loader-context.js +30 -0
- package/dist/esm/lib/loader-utils/loader-context.js.map +1 -0
- package/dist/esm/lib/loader-utils/loggers.js +50 -0
- package/dist/esm/lib/loader-utils/loggers.js.map +1 -0
- package/dist/esm/lib/loader-utils/normalize-loader.js +37 -0
- package/dist/esm/lib/loader-utils/normalize-loader.js.map +1 -0
- package/dist/esm/lib/loader-utils/option-defaults.js +39 -0
- package/dist/esm/lib/loader-utils/option-defaults.js.map +1 -0
- package/dist/esm/lib/loader-utils/option-utils.js +106 -0
- package/dist/esm/lib/loader-utils/option-utils.js.map +1 -0
- package/dist/esm/lib/progress/fetch-progress.js +52 -0
- package/dist/esm/lib/progress/fetch-progress.js.map +1 -0
- package/dist/esm/lib/utils/log.js +5 -0
- package/dist/esm/lib/utils/log.js.map +1 -0
- package/dist/esm/lib/utils/mime-type-utils.js +17 -0
- package/dist/esm/lib/utils/mime-type-utils.js.map +1 -0
- package/dist/esm/lib/utils/resource-utils.js +51 -0
- package/dist/esm/lib/utils/resource-utils.js.map +1 -0
- package/dist/esm/lib/utils/response-utils.js +91 -0
- package/dist/esm/lib/utils/response-utils.js.map +1 -0
- package/dist/esm/null-loader.js +45 -0
- package/dist/esm/null-loader.js.map +1 -0
- package/dist/esm/workers/null-worker.js +4 -0
- package/dist/esm/workers/null-worker.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +108 -31
- package/dist/iterators/batch-iterators/timed-batch-iterator.d.ts +5 -0
- package/dist/iterators/batch-iterators/timed-batch-iterator.d.ts.map +1 -0
- package/dist/iterators/batch-iterators/timed-batch-iterator.js +20 -17
- package/dist/iterators/make-iterator/make-array-buffer-iterator.d.ts +9 -0
- package/dist/iterators/make-iterator/make-array-buffer-iterator.d.ts.map +1 -0
- package/dist/iterators/make-iterator/make-array-buffer-iterator.js +25 -16
- package/dist/iterators/make-iterator/make-blob-iterator.d.ts +9 -0
- package/dist/iterators/make-iterator/make-blob-iterator.d.ts.map +1 -0
- package/dist/iterators/make-iterator/make-blob-iterator.js +20 -12
- package/dist/iterators/make-iterator/make-iterator.d.ts +19 -0
- package/dist/iterators/make-iterator/make-iterator.d.ts.map +1 -0
- package/dist/iterators/make-iterator/make-iterator.js +36 -29
- package/dist/iterators/make-iterator/make-stream-iterator.d.ts +11 -0
- package/dist/iterators/make-iterator/make-stream-iterator.d.ts.map +1 -0
- package/dist/iterators/make-iterator/make-stream-iterator.js +89 -32
- package/dist/iterators/make-iterator/make-string-iterator.d.ts +9 -0
- package/dist/iterators/make-iterator/make-string-iterator.d.ts.map +1 -0
- package/dist/iterators/make-iterator/make-string-iterator.js +22 -12
- package/dist/iterators/make-stream/make-dom-stream.d.ts +14 -0
- package/dist/iterators/make-stream/make-dom-stream.d.ts.map +1 -0
- package/dist/iterators/make-stream/make-dom-stream.js +44 -32
- package/dist/iterators/make-stream/make-node-stream.d.ts +11 -0
- package/dist/iterators/make-stream/make-node-stream.d.ts.map +1 -0
- package/dist/iterators/make-stream/make-node-stream.js +75 -70
- package/dist/javascript-utils/is-type.d.ts +22 -0
- package/dist/javascript-utils/is-type.d.ts.map +1 -0
- package/dist/javascript-utils/is-type.js +41 -21
- package/dist/lib/api/encode-table.d.ts +6 -0
- package/dist/lib/api/encode-table.d.ts.map +1 -0
- package/dist/lib/api/encode-table.js +54 -0
- package/dist/lib/api/encode.d.ts +26 -0
- package/dist/lib/api/encode.d.ts.map +1 -0
- package/dist/lib/api/encode.js +111 -81
- package/dist/lib/api/load-in-batches.d.ts +13 -0
- package/dist/lib/api/load-in-batches.d.ts.map +1 -0
- package/dist/lib/api/load-in-batches.js +30 -27
- package/dist/lib/api/load.d.ts +14 -0
- package/dist/lib/api/load.d.ts.map +1 -0
- package/dist/lib/api/load.js +42 -24
- package/dist/lib/api/loader-options.d.ts +3 -0
- package/dist/lib/api/loader-options.d.ts.map +1 -0
- package/dist/lib/api/loader-options.js +7 -0
- package/dist/lib/api/parse-in-batches.d.ts +10 -0
- package/dist/lib/api/parse-in-batches.d.ts.map +1 -0
- package/dist/lib/api/parse-in-batches.js +113 -92
- package/dist/lib/api/parse-sync.d.ts +10 -0
- package/dist/lib/api/parse-sync.d.ts.map +1 -0
- package/dist/lib/api/parse-sync.js +56 -54
- package/dist/lib/api/parse.d.ts +6 -0
- package/dist/lib/api/parse.d.ts.map +1 -0
- package/dist/lib/api/parse.js +81 -61
- package/dist/lib/api/register-loaders.d.ts +7 -0
- package/dist/lib/api/register-loaders.d.ts.map +1 -0
- package/dist/lib/api/register-loaders.js +29 -23
- package/dist/lib/api/save.d.ts +4 -0
- package/dist/lib/api/save.d.ts.map +1 -0
- package/dist/lib/api/save.js +13 -9
- package/dist/lib/api/select-loader.d.ts +22 -0
- package/dist/lib/api/select-loader.d.ts.map +1 -0
- package/dist/lib/api/select-loader.js +216 -194
- package/dist/lib/common.d.ts +2 -0
- package/dist/lib/common.d.ts.map +1 -0
- package/dist/lib/common.js +2 -2
- package/dist/lib/fetch/fetch-error-message.d.ts +3 -0
- package/dist/lib/fetch/fetch-error-message.d.ts.map +1 -0
- package/dist/lib/fetch/fetch-error-message.js +21 -17
- package/dist/lib/fetch/fetch-file.d.ts +13 -0
- package/dist/lib/fetch/fetch-file.d.ts.map +1 -0
- package/dist/lib/fetch/fetch-file.js +25 -15
- package/dist/lib/fetch/read-array-buffer.d.ts +17 -0
- package/dist/lib/fetch/read-array-buffer.d.ts.map +1 -0
- package/dist/lib/fetch/read-array-buffer.js +39 -27
- package/dist/lib/fetch/read-file.d.ts +5 -0
- package/dist/lib/fetch/read-file.d.ts.map +1 -0
- package/dist/lib/fetch/read-file.js +28 -16
- package/dist/lib/fetch/write-file.d.ts +3 -0
- package/dist/lib/fetch/write-file.d.ts.map +1 -0
- package/dist/lib/fetch/write-file.js +20 -23
- package/dist/lib/filesystems/browser-filesystem.d.ts +58 -0
- package/dist/lib/filesystems/browser-filesystem.d.ts.map +1 -0
- package/dist/lib/filesystems/browser-filesystem.js +118 -107
- package/dist/lib/filesystems/filesystem.d.ts +46 -0
- package/dist/lib/filesystems/filesystem.d.ts.map +1 -0
- package/dist/lib/filesystems/filesystem.js +2 -2
- package/dist/lib/filesystems/read-array-buffer.d.ts +19 -0
- package/dist/lib/filesystems/read-array-buffer.d.ts.map +1 -0
- package/dist/lib/filesystems/read-array-buffer.js +28 -8
- package/dist/lib/init.d.ts +3 -0
- package/dist/lib/init.d.ts.map +1 -0
- package/dist/lib/init.js +16 -6
- package/dist/lib/loader-utils/check-errors.d.ts +3 -0
- package/dist/lib/loader-utils/check-errors.d.ts.map +1 -0
- package/dist/lib/loader-utils/check-errors.js +26 -22
- package/dist/lib/loader-utils/get-data.d.ts +6 -0
- package/dist/lib/loader-utils/get-data.d.ts.map +1 -0
- package/dist/lib/loader-utils/get-data.js +122 -122
- package/dist/lib/loader-utils/get-fetch-function.d.ts +9 -0
- package/dist/lib/loader-utils/get-fetch-function.d.ts.map +1 -0
- package/dist/lib/loader-utils/get-fetch-function.js +31 -0
- package/dist/lib/loader-utils/loader-context.d.ts +13 -0
- package/dist/lib/loader-utils/loader-context.d.ts.map +1 -0
- package/dist/lib/loader-utils/loader-context.js +47 -34
- package/dist/lib/loader-utils/loggers.d.ts +17 -0
- package/dist/lib/loader-utils/loggers.d.ts.map +1 -0
- package/dist/lib/loader-utils/loggers.js +39 -46
- package/dist/lib/loader-utils/normalize-loader.d.ts +4 -0
- package/dist/lib/loader-utils/normalize-loader.d.ts.map +1 -0
- package/dist/lib/loader-utils/normalize-loader.js +50 -41
- package/dist/lib/loader-utils/option-defaults.d.ts +20 -0
- package/dist/lib/loader-utils/option-defaults.d.ts.map +1 -0
- package/dist/lib/loader-utils/option-defaults.js +41 -35
- package/dist/lib/loader-utils/option-utils.d.ts +34 -0
- package/dist/lib/loader-utils/option-utils.d.ts.map +1 -0
- package/dist/lib/loader-utils/option-utils.js +140 -120
- package/dist/lib/progress/fetch-progress.d.ts +6 -0
- package/dist/lib/progress/fetch-progress.d.ts.map +1 -0
- package/dist/lib/progress/fetch-progress.js +54 -56
- package/dist/lib/utils/log.d.ts +3 -0
- package/dist/lib/utils/log.d.ts.map +1 -0
- package/dist/lib/utils/log.js +6 -0
- package/dist/lib/utils/mime-type-utils.d.ts +20 -0
- package/dist/lib/utils/mime-type-utils.d.ts.map +1 -0
- package/dist/lib/utils/mime-type-utils.js +38 -17
- package/dist/lib/utils/resource-utils.d.ts +21 -0
- package/dist/lib/utils/resource-utils.d.ts.map +1 -0
- package/dist/lib/utils/resource-utils.js +70 -52
- package/dist/lib/utils/response-utils.d.ts +18 -0
- package/dist/lib/utils/response-utils.d.ts.map +1 -0
- package/dist/lib/utils/response-utils.js +104 -105
- package/dist/null-loader.d.ts +10 -0
- package/dist/null-loader.d.ts.map +1 -0
- package/dist/null-loader.js +53 -31
- package/dist/null-worker.js +61 -21
- package/dist/workers/null-worker.d.ts +2 -0
- package/dist/workers/null-worker.d.ts.map +1 -0
- package/dist/workers/null-worker.js +5 -4
- package/package.json +16 -15
- package/src/index.ts +20 -4
- package/src/iterators/make-stream/make-dom-stream.ts +10 -5
- package/src/iterators/make-stream/make-node-stream.ts +10 -9
- package/src/lib/api/encode-table.ts +71 -0
- package/src/lib/api/encode.ts +15 -5
- package/src/lib/api/load-in-batches.ts +1 -1
- package/src/lib/api/load.ts +39 -8
- package/src/lib/api/loader-options.ts +2 -0
- package/src/lib/api/parse.ts +39 -2
- package/src/lib/api/register-loaders.ts +1 -1
- package/src/lib/api/select-loader.ts +16 -0
- package/src/lib/init.ts +17 -0
- package/src/lib/loader-utils/get-fetch-function.ts +38 -0
- package/src/lib/loader-utils/loader-context.ts +1 -1
- package/src/lib/loader-utils/loggers.ts +1 -1
- package/src/lib/loader-utils/option-defaults.ts +3 -1
- package/src/lib/loader-utils/option-utils.ts +22 -46
- package/src/lib/progress/fetch-progress.ts +2 -2
- package/src/lib/utils/log.ts +4 -0
- package/src/lib/utils/response-utils.ts +2 -2
- package/src/null-loader.ts +17 -5
- package/dist/bundle.js.map +0 -1
- package/dist/core-addons/write-file-browser.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/iterators/batch-iterators/timed-batch-iterator.js.map +0 -1
- package/dist/iterators/make-iterator/make-array-buffer-iterator.js.map +0 -1
- package/dist/iterators/make-iterator/make-blob-iterator.js.map +0 -1
- package/dist/iterators/make-iterator/make-iterator.js.map +0 -1
- package/dist/iterators/make-iterator/make-stream-iterator.js.map +0 -1
- package/dist/iterators/make-iterator/make-string-iterator.js.map +0 -1
- package/dist/iterators/make-stream/make-dom-stream.js.map +0 -1
- package/dist/iterators/make-stream/make-node-stream.js.map +0 -1
- package/dist/iterators/make-stream/make-stream.js +0 -7
- package/dist/iterators/make-stream/make-stream.js.map +0 -1
- package/dist/javascript-utils/is-type.js.map +0 -1
- package/dist/lib/api/encode.js.map +0 -1
- package/dist/lib/api/load-in-batches.js.map +0 -1
- package/dist/lib/api/load.js.map +0 -1
- package/dist/lib/api/parse-in-batches.js.map +0 -1
- package/dist/lib/api/parse-sync.js.map +0 -1
- package/dist/lib/api/parse.js.map +0 -1
- package/dist/lib/api/register-loaders.js.map +0 -1
- package/dist/lib/api/save.js.map +0 -1
- package/dist/lib/api/select-loader.js.map +0 -1
- package/dist/lib/api/set-loader-options.js +0 -5
- package/dist/lib/api/set-loader-options.js.map +0 -1
- package/dist/lib/common.js.map +0 -1
- package/dist/lib/fetch/fetch-error-message.js.map +0 -1
- package/dist/lib/fetch/fetch-file.js.map +0 -1
- package/dist/lib/fetch/read-array-buffer.js.map +0 -1
- package/dist/lib/fetch/read-file.js.map +0 -1
- package/dist/lib/fetch/write-file.js.map +0 -1
- package/dist/lib/filesystems/browser-filesystem.js.map +0 -1
- package/dist/lib/filesystems/filesystem.js.map +0 -1
- package/dist/lib/filesystems/read-array-buffer.js.map +0 -1
- package/dist/lib/init.js.map +0 -1
- package/dist/lib/loader-utils/check-errors.js.map +0 -1
- package/dist/lib/loader-utils/get-data.js.map +0 -1
- package/dist/lib/loader-utils/loader-context.js.map +0 -1
- package/dist/lib/loader-utils/loggers.js.map +0 -1
- package/dist/lib/loader-utils/normalize-loader.js.map +0 -1
- package/dist/lib/loader-utils/option-defaults.js.map +0 -1
- package/dist/lib/loader-utils/option-utils.js.map +0 -1
- package/dist/lib/progress/fetch-progress.js.map +0 -1
- package/dist/lib/utils/mime-type-utils.js.map +0 -1
- package/dist/lib/utils/resource-utils.js.map +0 -1
- package/dist/lib/utils/response-utils.js.map +0 -1
- package/dist/null-loader.js.map +0 -1
- package/dist/workers/null-worker.js.map +0 -1
- package/src/iterators/make-stream/make-stream.ts +0 -19
- package/src/lib/api/set-loader-options.ts +0 -9
- package/src/lib/init.js +0 -10
- /package/dist/{core-addons → es5/core-addons}/README.md +0 -0
package/dist/dist.min.js
ADDED
|
@@ -0,0 +1,3874 @@
|
|
|
1
|
+
(() => {
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
9
|
+
var __esm = (fn, res) => function __init() {
|
|
10
|
+
return fn && (res = (0, fn[Object.keys(fn)[0]])(fn = 0)), res;
|
|
11
|
+
};
|
|
12
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
13
|
+
return mod || (0, cb[Object.keys(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
14
|
+
};
|
|
15
|
+
var __export = (target, all) => {
|
|
16
|
+
__markAsModule(target);
|
|
17
|
+
for (var name in all)
|
|
18
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
+
};
|
|
20
|
+
var __reExport = (target, module, desc) => {
|
|
21
|
+
if (module && typeof module === "object" || typeof module === "function") {
|
|
22
|
+
for (let key of __getOwnPropNames(module))
|
|
23
|
+
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
24
|
+
__defProp(target, key, { get: () => module[key], enumerable: !(desc = __getOwnPropDesc(module, key)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return target;
|
|
27
|
+
};
|
|
28
|
+
var __toModule = (module) => {
|
|
29
|
+
return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", module && module.__esModule && "default" in module ? { get: () => module.default, enumerable: true } : { value: module, enumerable: true })), module);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// ../loader-utils/src/lib/env-utils/assert.ts
|
|
33
|
+
function assert(condition, message) {
|
|
34
|
+
if (!condition) {
|
|
35
|
+
throw new Error(message || "loader assertion failed.");
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
var init_assert = __esm({
|
|
39
|
+
"../loader-utils/src/lib/env-utils/assert.ts"() {
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// ../loader-utils/src/lib/env-utils/globals.ts
|
|
44
|
+
var globals, self_, window_, global_, document_, isBrowser, isWorker, matches, nodeVersion;
|
|
45
|
+
var init_globals = __esm({
|
|
46
|
+
"../loader-utils/src/lib/env-utils/globals.ts"() {
|
|
47
|
+
globals = {
|
|
48
|
+
self: typeof self !== "undefined" && self,
|
|
49
|
+
window: typeof window !== "undefined" && window,
|
|
50
|
+
global: typeof global !== "undefined" && global,
|
|
51
|
+
document: typeof document !== "undefined" && document
|
|
52
|
+
};
|
|
53
|
+
self_ = globals.self || globals.window || globals.global || {};
|
|
54
|
+
window_ = globals.window || globals.self || globals.global || {};
|
|
55
|
+
global_ = globals.global || globals.self || globals.window || {};
|
|
56
|
+
document_ = globals.document || {};
|
|
57
|
+
isBrowser = Boolean(typeof process !== "object" || String(process) !== "[object process]" || process.browser);
|
|
58
|
+
isWorker = typeof importScripts === "function";
|
|
59
|
+
matches = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
|
|
60
|
+
nodeVersion = matches && parseFloat(matches[1]) || 0;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// ../worker-utils/src/lib/env-utils/version.ts
|
|
65
|
+
var DEFAULT_VERSION, VERSION;
|
|
66
|
+
var init_version = __esm({
|
|
67
|
+
"../worker-utils/src/lib/env-utils/version.ts"() {
|
|
68
|
+
DEFAULT_VERSION = "beta";
|
|
69
|
+
VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : DEFAULT_VERSION;
|
|
70
|
+
if (typeof __VERSION__ === "undefined") {
|
|
71
|
+
console.error("loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// ../worker-utils/src/lib/env-utils/assert.ts
|
|
77
|
+
function assert2(condition, message) {
|
|
78
|
+
if (!condition) {
|
|
79
|
+
throw new Error(message || "loaders.gl assertion failed.");
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
var init_assert2 = __esm({
|
|
83
|
+
"../worker-utils/src/lib/env-utils/assert.ts"() {
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// ../worker-utils/src/lib/env-utils/globals.ts
|
|
88
|
+
var globals2, self_2, window_2, global_2, document_2, isBrowser2, isMobile, matches2, nodeVersion2;
|
|
89
|
+
var init_globals2 = __esm({
|
|
90
|
+
"../worker-utils/src/lib/env-utils/globals.ts"() {
|
|
91
|
+
globals2 = {
|
|
92
|
+
self: typeof self !== "undefined" && self,
|
|
93
|
+
window: typeof window !== "undefined" && window,
|
|
94
|
+
global: typeof global !== "undefined" && global,
|
|
95
|
+
document: typeof document !== "undefined" && document
|
|
96
|
+
};
|
|
97
|
+
self_2 = globals2.self || globals2.window || globals2.global || {};
|
|
98
|
+
window_2 = globals2.window || globals2.self || globals2.global || {};
|
|
99
|
+
global_2 = globals2.global || globals2.self || globals2.window || {};
|
|
100
|
+
document_2 = globals2.document || {};
|
|
101
|
+
isBrowser2 = typeof process !== "object" || String(process) !== "[object process]" || process.browser;
|
|
102
|
+
isMobile = typeof window !== "undefined" && typeof window.orientation !== "undefined";
|
|
103
|
+
matches2 = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
|
|
104
|
+
nodeVersion2 = matches2 && parseFloat(matches2[1]) || 0;
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// ../worker-utils/src/lib/worker-farm/worker-job.ts
|
|
109
|
+
var WorkerJob;
|
|
110
|
+
var init_worker_job = __esm({
|
|
111
|
+
"../worker-utils/src/lib/worker-farm/worker-job.ts"() {
|
|
112
|
+
init_assert2();
|
|
113
|
+
WorkerJob = class {
|
|
114
|
+
constructor(jobName, workerThread) {
|
|
115
|
+
this.isRunning = true;
|
|
116
|
+
this._resolve = () => {
|
|
117
|
+
};
|
|
118
|
+
this._reject = () => {
|
|
119
|
+
};
|
|
120
|
+
this.name = jobName;
|
|
121
|
+
this.workerThread = workerThread;
|
|
122
|
+
this.result = new Promise((resolve2, reject) => {
|
|
123
|
+
this._resolve = resolve2;
|
|
124
|
+
this._reject = reject;
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
postMessage(type, payload) {
|
|
128
|
+
this.workerThread.postMessage({
|
|
129
|
+
source: "loaders.gl",
|
|
130
|
+
type,
|
|
131
|
+
payload
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
done(value) {
|
|
135
|
+
assert2(this.isRunning);
|
|
136
|
+
this.isRunning = false;
|
|
137
|
+
this._resolve(value);
|
|
138
|
+
}
|
|
139
|
+
error(error) {
|
|
140
|
+
assert2(this.isRunning);
|
|
141
|
+
this.isRunning = false;
|
|
142
|
+
this._reject(error);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
// ../worker-utils/src/lib/node/worker_threads-browser.ts
|
|
149
|
+
var Worker2;
|
|
150
|
+
var init_worker_threads_browser = __esm({
|
|
151
|
+
"../worker-utils/src/lib/node/worker_threads-browser.ts"() {
|
|
152
|
+
Worker2 = class {
|
|
153
|
+
terminate() {
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
// ../worker-utils/src/lib/worker-utils/get-loadable-worker-url.ts
|
|
160
|
+
function getLoadableWorkerURL(props) {
|
|
161
|
+
assert2(props.source && !props.url || !props.source && props.url);
|
|
162
|
+
let workerURL = workerURLCache.get(props.source || props.url);
|
|
163
|
+
if (!workerURL) {
|
|
164
|
+
if (props.url) {
|
|
165
|
+
workerURL = getLoadableWorkerURLFromURL(props.url);
|
|
166
|
+
workerURLCache.set(props.url, workerURL);
|
|
167
|
+
}
|
|
168
|
+
if (props.source) {
|
|
169
|
+
workerURL = getLoadableWorkerURLFromSource(props.source);
|
|
170
|
+
workerURLCache.set(props.source, workerURL);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
assert2(workerURL);
|
|
174
|
+
return workerURL;
|
|
175
|
+
}
|
|
176
|
+
function getLoadableWorkerURLFromURL(url) {
|
|
177
|
+
if (!url.startsWith("http")) {
|
|
178
|
+
return url;
|
|
179
|
+
}
|
|
180
|
+
const workerSource = buildScriptSource(url);
|
|
181
|
+
return getLoadableWorkerURLFromSource(workerSource);
|
|
182
|
+
}
|
|
183
|
+
function getLoadableWorkerURLFromSource(workerSource) {
|
|
184
|
+
const blob = new Blob([workerSource], { type: "application/javascript" });
|
|
185
|
+
return URL.createObjectURL(blob);
|
|
186
|
+
}
|
|
187
|
+
function buildScriptSource(workerUrl) {
|
|
188
|
+
return `try {
|
|
189
|
+
importScripts('${workerUrl}');
|
|
190
|
+
} catch (error) {
|
|
191
|
+
console.error(error);
|
|
192
|
+
throw error;
|
|
193
|
+
}`;
|
|
194
|
+
}
|
|
195
|
+
var workerURLCache;
|
|
196
|
+
var init_get_loadable_worker_url = __esm({
|
|
197
|
+
"../worker-utils/src/lib/worker-utils/get-loadable-worker-url.ts"() {
|
|
198
|
+
init_assert2();
|
|
199
|
+
workerURLCache = new Map();
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
// ../worker-utils/src/lib/worker-utils/get-transfer-list.ts
|
|
204
|
+
function getTransferList(object, recursive = true, transfers) {
|
|
205
|
+
const transfersSet = transfers || new Set();
|
|
206
|
+
if (!object) {
|
|
207
|
+
} else if (isTransferable(object)) {
|
|
208
|
+
transfersSet.add(object);
|
|
209
|
+
} else if (isTransferable(object.buffer)) {
|
|
210
|
+
transfersSet.add(object.buffer);
|
|
211
|
+
} else if (ArrayBuffer.isView(object)) {
|
|
212
|
+
} else if (recursive && typeof object === "object") {
|
|
213
|
+
for (const key in object) {
|
|
214
|
+
getTransferList(object[key], recursive, transfersSet);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return transfers === void 0 ? Array.from(transfersSet) : [];
|
|
218
|
+
}
|
|
219
|
+
function isTransferable(object) {
|
|
220
|
+
if (!object) {
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
if (object instanceof ArrayBuffer) {
|
|
224
|
+
return true;
|
|
225
|
+
}
|
|
226
|
+
if (typeof MessagePort !== "undefined" && object instanceof MessagePort) {
|
|
227
|
+
return true;
|
|
228
|
+
}
|
|
229
|
+
if (typeof ImageBitmap !== "undefined" && object instanceof ImageBitmap) {
|
|
230
|
+
return true;
|
|
231
|
+
}
|
|
232
|
+
if (typeof OffscreenCanvas !== "undefined" && object instanceof OffscreenCanvas) {
|
|
233
|
+
return true;
|
|
234
|
+
}
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
function getTransferListForWriter(object) {
|
|
238
|
+
if (object === null) {
|
|
239
|
+
return {};
|
|
240
|
+
}
|
|
241
|
+
const clone = Object.assign({}, object);
|
|
242
|
+
Object.keys(clone).forEach((key) => {
|
|
243
|
+
if (typeof object[key] === "object" && !ArrayBuffer.isView(object[key]) && !(object[key] instanceof Array)) {
|
|
244
|
+
clone[key] = getTransferListForWriter(object[key]);
|
|
245
|
+
} else if (typeof clone[key] === "function" || clone[key] instanceof RegExp) {
|
|
246
|
+
clone[key] = {};
|
|
247
|
+
} else {
|
|
248
|
+
clone[key] = object[key];
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
return clone;
|
|
252
|
+
}
|
|
253
|
+
var init_get_transfer_list = __esm({
|
|
254
|
+
"../worker-utils/src/lib/worker-utils/get-transfer-list.ts"() {
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
// ../worker-utils/src/lib/worker-farm/worker-thread.ts
|
|
259
|
+
var NOOP, WorkerThread;
|
|
260
|
+
var init_worker_thread = __esm({
|
|
261
|
+
"../worker-utils/src/lib/worker-farm/worker-thread.ts"() {
|
|
262
|
+
init_worker_threads_browser();
|
|
263
|
+
init_globals2();
|
|
264
|
+
init_assert2();
|
|
265
|
+
init_get_loadable_worker_url();
|
|
266
|
+
init_get_transfer_list();
|
|
267
|
+
NOOP = () => {
|
|
268
|
+
};
|
|
269
|
+
WorkerThread = class {
|
|
270
|
+
constructor(props) {
|
|
271
|
+
this.terminated = false;
|
|
272
|
+
this._loadableURL = "";
|
|
273
|
+
const { name, source, url } = props;
|
|
274
|
+
assert2(source || url);
|
|
275
|
+
this.name = name;
|
|
276
|
+
this.source = source;
|
|
277
|
+
this.url = url;
|
|
278
|
+
this.onMessage = NOOP;
|
|
279
|
+
this.onError = (error) => console.log(error);
|
|
280
|
+
this.worker = isBrowser2 ? this._createBrowserWorker() : this._createNodeWorker();
|
|
281
|
+
}
|
|
282
|
+
static isSupported() {
|
|
283
|
+
return typeof Worker !== "undefined" && isBrowser2 || typeof Worker2 !== "undefined" && !isBrowser2;
|
|
284
|
+
}
|
|
285
|
+
destroy() {
|
|
286
|
+
this.onMessage = NOOP;
|
|
287
|
+
this.onError = NOOP;
|
|
288
|
+
this.worker.terminate();
|
|
289
|
+
this.terminated = true;
|
|
290
|
+
}
|
|
291
|
+
get isRunning() {
|
|
292
|
+
return Boolean(this.onMessage);
|
|
293
|
+
}
|
|
294
|
+
postMessage(data, transferList) {
|
|
295
|
+
transferList = transferList || getTransferList(data);
|
|
296
|
+
this.worker.postMessage(data, transferList);
|
|
297
|
+
}
|
|
298
|
+
_getErrorFromErrorEvent(event) {
|
|
299
|
+
let message = "Failed to load ";
|
|
300
|
+
message += `worker ${this.name} from ${this.url}. `;
|
|
301
|
+
if (event.message) {
|
|
302
|
+
message += `${event.message} in `;
|
|
303
|
+
}
|
|
304
|
+
if (event.lineno) {
|
|
305
|
+
message += `:${event.lineno}:${event.colno}`;
|
|
306
|
+
}
|
|
307
|
+
return new Error(message);
|
|
308
|
+
}
|
|
309
|
+
_createBrowserWorker() {
|
|
310
|
+
this._loadableURL = getLoadableWorkerURL({ source: this.source, url: this.url });
|
|
311
|
+
const worker = new Worker(this._loadableURL, { name: this.name });
|
|
312
|
+
worker.onmessage = (event) => {
|
|
313
|
+
if (!event.data) {
|
|
314
|
+
this.onError(new Error("No data received"));
|
|
315
|
+
} else {
|
|
316
|
+
this.onMessage(event.data);
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
worker.onerror = (error) => {
|
|
320
|
+
this.onError(this._getErrorFromErrorEvent(error));
|
|
321
|
+
this.terminated = true;
|
|
322
|
+
};
|
|
323
|
+
worker.onmessageerror = (event) => console.error(event);
|
|
324
|
+
return worker;
|
|
325
|
+
}
|
|
326
|
+
_createNodeWorker() {
|
|
327
|
+
let worker;
|
|
328
|
+
if (this.url) {
|
|
329
|
+
const absolute = this.url.includes(":/") || this.url.startsWith("/");
|
|
330
|
+
const url = absolute ? this.url : `./${this.url}`;
|
|
331
|
+
worker = new Worker2(url, { eval: false });
|
|
332
|
+
} else if (this.source) {
|
|
333
|
+
worker = new Worker2(this.source, { eval: true });
|
|
334
|
+
} else {
|
|
335
|
+
throw new Error("no worker");
|
|
336
|
+
}
|
|
337
|
+
worker.on("message", (data) => {
|
|
338
|
+
this.onMessage(data);
|
|
339
|
+
});
|
|
340
|
+
worker.on("error", (error) => {
|
|
341
|
+
this.onError(error);
|
|
342
|
+
});
|
|
343
|
+
worker.on("exit", (code) => {
|
|
344
|
+
});
|
|
345
|
+
return worker;
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
// ../worker-utils/src/lib/worker-farm/worker-pool.ts
|
|
352
|
+
var WorkerPool;
|
|
353
|
+
var init_worker_pool = __esm({
|
|
354
|
+
"../worker-utils/src/lib/worker-farm/worker-pool.ts"() {
|
|
355
|
+
init_globals2();
|
|
356
|
+
init_worker_thread();
|
|
357
|
+
init_worker_job();
|
|
358
|
+
WorkerPool = class {
|
|
359
|
+
constructor(props) {
|
|
360
|
+
this.name = "unnamed";
|
|
361
|
+
this.maxConcurrency = 1;
|
|
362
|
+
this.maxMobileConcurrency = 1;
|
|
363
|
+
this.onDebug = () => {
|
|
364
|
+
};
|
|
365
|
+
this.reuseWorkers = true;
|
|
366
|
+
this.props = {};
|
|
367
|
+
this.jobQueue = [];
|
|
368
|
+
this.idleQueue = [];
|
|
369
|
+
this.count = 0;
|
|
370
|
+
this.isDestroyed = false;
|
|
371
|
+
this.source = props.source;
|
|
372
|
+
this.url = props.url;
|
|
373
|
+
this.setProps(props);
|
|
374
|
+
}
|
|
375
|
+
static isSupported() {
|
|
376
|
+
return WorkerThread.isSupported();
|
|
377
|
+
}
|
|
378
|
+
destroy() {
|
|
379
|
+
this.idleQueue.forEach((worker) => worker.destroy());
|
|
380
|
+
this.isDestroyed = true;
|
|
381
|
+
}
|
|
382
|
+
setProps(props) {
|
|
383
|
+
this.props = { ...this.props, ...props };
|
|
384
|
+
if (props.name !== void 0) {
|
|
385
|
+
this.name = props.name;
|
|
386
|
+
}
|
|
387
|
+
if (props.maxConcurrency !== void 0) {
|
|
388
|
+
this.maxConcurrency = props.maxConcurrency;
|
|
389
|
+
}
|
|
390
|
+
if (props.maxMobileConcurrency !== void 0) {
|
|
391
|
+
this.maxMobileConcurrency = props.maxMobileConcurrency;
|
|
392
|
+
}
|
|
393
|
+
if (props.reuseWorkers !== void 0) {
|
|
394
|
+
this.reuseWorkers = props.reuseWorkers;
|
|
395
|
+
}
|
|
396
|
+
if (props.onDebug !== void 0) {
|
|
397
|
+
this.onDebug = props.onDebug;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
async startJob(name, onMessage3 = (job, type, data) => job.done(data), onError = (job, error) => job.error(error)) {
|
|
401
|
+
const startPromise = new Promise((onStart) => {
|
|
402
|
+
this.jobQueue.push({ name, onMessage: onMessage3, onError, onStart });
|
|
403
|
+
return this;
|
|
404
|
+
});
|
|
405
|
+
this._startQueuedJob();
|
|
406
|
+
return await startPromise;
|
|
407
|
+
}
|
|
408
|
+
async _startQueuedJob() {
|
|
409
|
+
if (!this.jobQueue.length) {
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
const workerThread = this._getAvailableWorker();
|
|
413
|
+
if (!workerThread) {
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
const queuedJob = this.jobQueue.shift();
|
|
417
|
+
if (queuedJob) {
|
|
418
|
+
this.onDebug({
|
|
419
|
+
message: "Starting job",
|
|
420
|
+
name: queuedJob.name,
|
|
421
|
+
workerThread,
|
|
422
|
+
backlog: this.jobQueue.length
|
|
423
|
+
});
|
|
424
|
+
const job = new WorkerJob(queuedJob.name, workerThread);
|
|
425
|
+
workerThread.onMessage = (data) => queuedJob.onMessage(job, data.type, data.payload);
|
|
426
|
+
workerThread.onError = (error) => queuedJob.onError(job, error);
|
|
427
|
+
queuedJob.onStart(job);
|
|
428
|
+
try {
|
|
429
|
+
await job.result;
|
|
430
|
+
} finally {
|
|
431
|
+
this.returnWorkerToQueue(workerThread);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
returnWorkerToQueue(worker) {
|
|
436
|
+
const shouldDestroyWorker = this.isDestroyed || !this.reuseWorkers || this.count > this._getMaxConcurrency();
|
|
437
|
+
if (shouldDestroyWorker) {
|
|
438
|
+
worker.destroy();
|
|
439
|
+
this.count--;
|
|
440
|
+
} else {
|
|
441
|
+
this.idleQueue.push(worker);
|
|
442
|
+
}
|
|
443
|
+
if (!this.isDestroyed) {
|
|
444
|
+
this._startQueuedJob();
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
_getAvailableWorker() {
|
|
448
|
+
if (this.idleQueue.length > 0) {
|
|
449
|
+
return this.idleQueue.shift() || null;
|
|
450
|
+
}
|
|
451
|
+
if (this.count < this._getMaxConcurrency()) {
|
|
452
|
+
this.count++;
|
|
453
|
+
const name = `${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`;
|
|
454
|
+
return new WorkerThread({ name, source: this.source, url: this.url });
|
|
455
|
+
}
|
|
456
|
+
return null;
|
|
457
|
+
}
|
|
458
|
+
_getMaxConcurrency() {
|
|
459
|
+
return isMobile ? this.maxMobileConcurrency : this.maxConcurrency;
|
|
460
|
+
}
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
// ../worker-utils/src/lib/worker-farm/worker-farm.ts
|
|
466
|
+
var DEFAULT_PROPS, WorkerFarm;
|
|
467
|
+
var init_worker_farm = __esm({
|
|
468
|
+
"../worker-utils/src/lib/worker-farm/worker-farm.ts"() {
|
|
469
|
+
init_worker_pool();
|
|
470
|
+
init_worker_thread();
|
|
471
|
+
DEFAULT_PROPS = {
|
|
472
|
+
maxConcurrency: 3,
|
|
473
|
+
maxMobileConcurrency: 1,
|
|
474
|
+
reuseWorkers: true,
|
|
475
|
+
onDebug: () => {
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
WorkerFarm = class {
|
|
479
|
+
constructor(props) {
|
|
480
|
+
this.workerPools = new Map();
|
|
481
|
+
this.props = { ...DEFAULT_PROPS };
|
|
482
|
+
this.setProps(props);
|
|
483
|
+
this.workerPools = new Map();
|
|
484
|
+
}
|
|
485
|
+
static isSupported() {
|
|
486
|
+
return WorkerThread.isSupported();
|
|
487
|
+
}
|
|
488
|
+
static getWorkerFarm(props = {}) {
|
|
489
|
+
WorkerFarm._workerFarm = WorkerFarm._workerFarm || new WorkerFarm({});
|
|
490
|
+
WorkerFarm._workerFarm.setProps(props);
|
|
491
|
+
return WorkerFarm._workerFarm;
|
|
492
|
+
}
|
|
493
|
+
destroy() {
|
|
494
|
+
for (const workerPool of this.workerPools.values()) {
|
|
495
|
+
workerPool.destroy();
|
|
496
|
+
}
|
|
497
|
+
this.workerPools = new Map();
|
|
498
|
+
}
|
|
499
|
+
setProps(props) {
|
|
500
|
+
this.props = { ...this.props, ...props };
|
|
501
|
+
for (const workerPool of this.workerPools.values()) {
|
|
502
|
+
workerPool.setProps(this._getWorkerPoolProps());
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
getWorkerPool(options) {
|
|
506
|
+
const { name, source, url } = options;
|
|
507
|
+
let workerPool = this.workerPools.get(name);
|
|
508
|
+
if (!workerPool) {
|
|
509
|
+
workerPool = new WorkerPool({
|
|
510
|
+
name,
|
|
511
|
+
source,
|
|
512
|
+
url
|
|
513
|
+
});
|
|
514
|
+
workerPool.setProps(this._getWorkerPoolProps());
|
|
515
|
+
this.workerPools.set(name, workerPool);
|
|
516
|
+
}
|
|
517
|
+
return workerPool;
|
|
518
|
+
}
|
|
519
|
+
_getWorkerPoolProps() {
|
|
520
|
+
return {
|
|
521
|
+
maxConcurrency: this.props.maxConcurrency,
|
|
522
|
+
maxMobileConcurrency: this.props.maxMobileConcurrency,
|
|
523
|
+
reuseWorkers: this.props.reuseWorkers,
|
|
524
|
+
onDebug: this.props.onDebug
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
});
|
|
530
|
+
|
|
531
|
+
// ../worker-utils/src/lib/worker-api/get-worker-url.ts
|
|
532
|
+
function getWorkerName(worker) {
|
|
533
|
+
const warning = worker.version !== VERSION2 ? ` (worker-utils@${VERSION2})` : "";
|
|
534
|
+
return `${worker.name}@${worker.version}${warning}`;
|
|
535
|
+
}
|
|
536
|
+
function getWorkerURL(worker, options = {}) {
|
|
537
|
+
const workerOptions = options[worker.id] || {};
|
|
538
|
+
const workerFile = `${worker.id}-worker.js`;
|
|
539
|
+
let url = workerOptions.workerUrl;
|
|
540
|
+
if (!url && worker.id === "compression") {
|
|
541
|
+
url = options.workerUrl;
|
|
542
|
+
}
|
|
543
|
+
if (options._workerType === "test") {
|
|
544
|
+
url = `modules/${worker.module}/dist/${workerFile}`;
|
|
545
|
+
}
|
|
546
|
+
if (!url) {
|
|
547
|
+
let version = worker.version;
|
|
548
|
+
if (version === "latest") {
|
|
549
|
+
version = NPM_TAG;
|
|
550
|
+
}
|
|
551
|
+
const versionTag = version ? `@${version}` : "";
|
|
552
|
+
url = `https://unpkg.com/@loaders.gl/${worker.module}${versionTag}/dist/${workerFile}`;
|
|
553
|
+
}
|
|
554
|
+
assert2(url);
|
|
555
|
+
return url;
|
|
556
|
+
}
|
|
557
|
+
var NPM_TAG, VERSION2;
|
|
558
|
+
var init_get_worker_url = __esm({
|
|
559
|
+
"../worker-utils/src/lib/worker-api/get-worker-url.ts"() {
|
|
560
|
+
init_assert2();
|
|
561
|
+
init_version();
|
|
562
|
+
NPM_TAG = "beta";
|
|
563
|
+
VERSION2 = typeof VERSION !== "undefined" ? VERSION : NPM_TAG;
|
|
564
|
+
}
|
|
565
|
+
});
|
|
566
|
+
|
|
567
|
+
// ../worker-utils/src/lib/worker-api/process-on-worker.ts
|
|
568
|
+
async function processOnWorker(worker, data, options = {}, context = {}) {
|
|
569
|
+
const name = getWorkerName(worker);
|
|
570
|
+
const workerFarm = WorkerFarm.getWorkerFarm(options);
|
|
571
|
+
const { source } = options;
|
|
572
|
+
const workerPoolProps = { name, source };
|
|
573
|
+
if (!source) {
|
|
574
|
+
workerPoolProps.url = getWorkerURL(worker, options);
|
|
575
|
+
}
|
|
576
|
+
const workerPool = workerFarm.getWorkerPool(workerPoolProps);
|
|
577
|
+
const jobName = options.jobName || worker.name;
|
|
578
|
+
const job = await workerPool.startJob(jobName, onMessage.bind(null, context));
|
|
579
|
+
const transferableOptions = getTransferListForWriter(options);
|
|
580
|
+
job.postMessage("process", { input: data, options: transferableOptions });
|
|
581
|
+
const result = await job.result;
|
|
582
|
+
return result.result;
|
|
583
|
+
}
|
|
584
|
+
async function onMessage(context, job, type, payload) {
|
|
585
|
+
switch (type) {
|
|
586
|
+
case "done":
|
|
587
|
+
job.done(payload);
|
|
588
|
+
break;
|
|
589
|
+
case "error":
|
|
590
|
+
job.error(new Error(payload.error));
|
|
591
|
+
break;
|
|
592
|
+
case "process":
|
|
593
|
+
const { id, input, options } = payload;
|
|
594
|
+
try {
|
|
595
|
+
if (!context.process) {
|
|
596
|
+
job.postMessage("error", { id, error: "Worker not set up to process on main thread" });
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
599
|
+
const result = await context.process(input, options);
|
|
600
|
+
job.postMessage("done", { id, result });
|
|
601
|
+
} catch (error) {
|
|
602
|
+
const message = error instanceof Error ? error.message : "unknown error";
|
|
603
|
+
job.postMessage("error", { id, error: message });
|
|
604
|
+
}
|
|
605
|
+
break;
|
|
606
|
+
default:
|
|
607
|
+
console.warn(`process-on-worker: unknown message ${type}`);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
var init_process_on_worker = __esm({
|
|
611
|
+
"../worker-utils/src/lib/worker-api/process-on-worker.ts"() {
|
|
612
|
+
init_worker_farm();
|
|
613
|
+
init_get_worker_url();
|
|
614
|
+
init_get_transfer_list();
|
|
615
|
+
}
|
|
616
|
+
});
|
|
617
|
+
|
|
618
|
+
// ../worker-utils/src/lib/worker-api/validate-worker-version.ts
|
|
619
|
+
function validateWorkerVersion(worker, coreVersion = VERSION) {
|
|
620
|
+
assert2(worker, "no worker provided");
|
|
621
|
+
const workerVersion = worker.version;
|
|
622
|
+
if (!coreVersion || !workerVersion) {
|
|
623
|
+
return false;
|
|
624
|
+
}
|
|
625
|
+
return true;
|
|
626
|
+
}
|
|
627
|
+
var init_validate_worker_version = __esm({
|
|
628
|
+
"../worker-utils/src/lib/worker-api/validate-worker-version.ts"() {
|
|
629
|
+
init_assert2();
|
|
630
|
+
init_version();
|
|
631
|
+
}
|
|
632
|
+
});
|
|
633
|
+
|
|
634
|
+
// ../worker-utils/src/index.ts
|
|
635
|
+
var init_src = __esm({
|
|
636
|
+
"../worker-utils/src/index.ts"() {
|
|
637
|
+
init_assert2();
|
|
638
|
+
init_globals2();
|
|
639
|
+
init_worker_farm();
|
|
640
|
+
init_process_on_worker();
|
|
641
|
+
init_get_worker_url();
|
|
642
|
+
init_validate_worker_version();
|
|
643
|
+
}
|
|
644
|
+
});
|
|
645
|
+
|
|
646
|
+
// ../loader-utils/src/lib/worker-loader-utils/parse-with-worker.ts
|
|
647
|
+
function canParseWithWorker(loader, options) {
|
|
648
|
+
if (!WorkerFarm.isSupported()) {
|
|
649
|
+
return false;
|
|
650
|
+
}
|
|
651
|
+
if (!isBrowser2 && !options?._nodeWorkers) {
|
|
652
|
+
return false;
|
|
653
|
+
}
|
|
654
|
+
return loader.worker && options?.worker;
|
|
655
|
+
}
|
|
656
|
+
async function parseWithWorker(loader, data, options, context, parseOnMainThread) {
|
|
657
|
+
const name = loader.id;
|
|
658
|
+
const url = getWorkerURL(loader, options);
|
|
659
|
+
const workerFarm = WorkerFarm.getWorkerFarm(options);
|
|
660
|
+
const workerPool = workerFarm.getWorkerPool({ name, url });
|
|
661
|
+
options = JSON.parse(JSON.stringify(options));
|
|
662
|
+
context = JSON.parse(JSON.stringify(context || {}));
|
|
663
|
+
const job = await workerPool.startJob("process-on-worker", onMessage2.bind(null, parseOnMainThread));
|
|
664
|
+
job.postMessage("process", {
|
|
665
|
+
input: data,
|
|
666
|
+
options,
|
|
667
|
+
context
|
|
668
|
+
});
|
|
669
|
+
const result = await job.result;
|
|
670
|
+
return await result.result;
|
|
671
|
+
}
|
|
672
|
+
async function onMessage2(parseOnMainThread, job, type, payload) {
|
|
673
|
+
switch (type) {
|
|
674
|
+
case "done":
|
|
675
|
+
job.done(payload);
|
|
676
|
+
break;
|
|
677
|
+
case "error":
|
|
678
|
+
job.error(new Error(payload.error));
|
|
679
|
+
break;
|
|
680
|
+
case "process":
|
|
681
|
+
const { id, input, options } = payload;
|
|
682
|
+
try {
|
|
683
|
+
const result = await parseOnMainThread(input, options);
|
|
684
|
+
job.postMessage("done", { id, result });
|
|
685
|
+
} catch (error) {
|
|
686
|
+
const message = error instanceof Error ? error.message : "unknown error";
|
|
687
|
+
job.postMessage("error", { id, error: message });
|
|
688
|
+
}
|
|
689
|
+
break;
|
|
690
|
+
default:
|
|
691
|
+
console.warn(`parse-with-worker unknown message ${type}`);
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
var init_parse_with_worker = __esm({
|
|
695
|
+
"../loader-utils/src/lib/worker-loader-utils/parse-with-worker.ts"() {
|
|
696
|
+
init_src();
|
|
697
|
+
init_src();
|
|
698
|
+
}
|
|
699
|
+
});
|
|
700
|
+
|
|
701
|
+
// ../loader-utils/src/lib/worker-loader-utils/encode-with-worker.ts
|
|
702
|
+
function canEncodeWithWorker(writer, options) {
|
|
703
|
+
if (!WorkerFarm.isSupported()) {
|
|
704
|
+
return false;
|
|
705
|
+
}
|
|
706
|
+
if (!isBrowser && !options?._nodeWorkers) {
|
|
707
|
+
return false;
|
|
708
|
+
}
|
|
709
|
+
return writer.worker && options?.worker;
|
|
710
|
+
}
|
|
711
|
+
var init_encode_with_worker = __esm({
|
|
712
|
+
"../loader-utils/src/lib/worker-loader-utils/encode-with-worker.ts"() {
|
|
713
|
+
init_src();
|
|
714
|
+
init_globals();
|
|
715
|
+
}
|
|
716
|
+
});
|
|
717
|
+
|
|
718
|
+
// ../loader-utils/src/lib/binary-utils/array-buffer-utils.ts
|
|
719
|
+
function compareArrayBuffers(arrayBuffer1, arrayBuffer2, byteLength) {
|
|
720
|
+
byteLength = byteLength || arrayBuffer1.byteLength;
|
|
721
|
+
if (arrayBuffer1.byteLength < byteLength || arrayBuffer2.byteLength < byteLength) {
|
|
722
|
+
return false;
|
|
723
|
+
}
|
|
724
|
+
const array1 = new Uint8Array(arrayBuffer1);
|
|
725
|
+
const array2 = new Uint8Array(arrayBuffer2);
|
|
726
|
+
for (let i = 0; i < array1.length; ++i) {
|
|
727
|
+
if (array1[i] !== array2[i]) {
|
|
728
|
+
return false;
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
return true;
|
|
732
|
+
}
|
|
733
|
+
function concatenateArrayBuffers(...sources) {
|
|
734
|
+
const sourceArrays = sources.map((source2) => source2 instanceof ArrayBuffer ? new Uint8Array(source2) : source2);
|
|
735
|
+
const byteLength = sourceArrays.reduce((length, typedArray) => length + typedArray.byteLength, 0);
|
|
736
|
+
const result = new Uint8Array(byteLength);
|
|
737
|
+
let offset = 0;
|
|
738
|
+
for (const sourceArray of sourceArrays) {
|
|
739
|
+
result.set(sourceArray, offset);
|
|
740
|
+
offset += sourceArray.byteLength;
|
|
741
|
+
}
|
|
742
|
+
return result.buffer;
|
|
743
|
+
}
|
|
744
|
+
var init_array_buffer_utils = __esm({
|
|
745
|
+
"../loader-utils/src/lib/binary-utils/array-buffer-utils.ts"() {
|
|
746
|
+
}
|
|
747
|
+
});
|
|
748
|
+
|
|
749
|
+
// ../loader-utils/src/lib/iterators/text-iterators.ts
|
|
750
|
+
async function* makeTextDecoderIterator(arrayBufferIterator, options = {}) {
|
|
751
|
+
const textDecoder = new TextDecoder(void 0, options);
|
|
752
|
+
for await (const arrayBuffer of arrayBufferIterator) {
|
|
753
|
+
yield typeof arrayBuffer === "string" ? arrayBuffer : textDecoder.decode(arrayBuffer, { stream: true });
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
async function* makeTextEncoderIterator(textIterator) {
|
|
757
|
+
const textEncoder = new TextEncoder();
|
|
758
|
+
for await (const text of textIterator) {
|
|
759
|
+
yield typeof text === "string" ? textEncoder.encode(text) : text;
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
async function* makeLineIterator(textIterator) {
|
|
763
|
+
let previous = "";
|
|
764
|
+
for await (const textChunk of textIterator) {
|
|
765
|
+
previous += textChunk;
|
|
766
|
+
let eolIndex;
|
|
767
|
+
while ((eolIndex = previous.indexOf("\n")) >= 0) {
|
|
768
|
+
const line = previous.slice(0, eolIndex + 1);
|
|
769
|
+
previous = previous.slice(eolIndex + 1);
|
|
770
|
+
yield line;
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
if (previous.length > 0) {
|
|
774
|
+
yield previous;
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
async function* makeNumberedLineIterator(lineIterator) {
|
|
778
|
+
let counter = 1;
|
|
779
|
+
for await (const line of lineIterator) {
|
|
780
|
+
yield { counter, line };
|
|
781
|
+
counter++;
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
var init_text_iterators = __esm({
|
|
785
|
+
"../loader-utils/src/lib/iterators/text-iterators.ts"() {
|
|
786
|
+
}
|
|
787
|
+
});
|
|
788
|
+
|
|
789
|
+
// ../loader-utils/src/lib/iterators/async-iteration.ts
|
|
790
|
+
async function forEach(iterator, visitor) {
|
|
791
|
+
while (true) {
|
|
792
|
+
const { done, value } = await iterator.next();
|
|
793
|
+
if (done) {
|
|
794
|
+
iterator.return();
|
|
795
|
+
return;
|
|
796
|
+
}
|
|
797
|
+
const cancel = visitor(value);
|
|
798
|
+
if (cancel) {
|
|
799
|
+
return;
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
async function concatenateArrayBuffersAsync(asyncIterator) {
|
|
804
|
+
const arrayBuffers = [];
|
|
805
|
+
for await (const chunk of asyncIterator) {
|
|
806
|
+
arrayBuffers.push(chunk);
|
|
807
|
+
}
|
|
808
|
+
return concatenateArrayBuffers(...arrayBuffers);
|
|
809
|
+
}
|
|
810
|
+
var init_async_iteration = __esm({
|
|
811
|
+
"../loader-utils/src/lib/iterators/async-iteration.ts"() {
|
|
812
|
+
init_array_buffer_utils();
|
|
813
|
+
}
|
|
814
|
+
});
|
|
815
|
+
|
|
816
|
+
// ../../node_modules/@babel/runtime/helpers/esm/typeof.js
|
|
817
|
+
function _typeof(obj) {
|
|
818
|
+
"@babel/helpers - typeof";
|
|
819
|
+
return _typeof = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(obj2) {
|
|
820
|
+
return typeof obj2;
|
|
821
|
+
} : function(obj2) {
|
|
822
|
+
return obj2 && typeof Symbol == "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
823
|
+
}, _typeof(obj);
|
|
824
|
+
}
|
|
825
|
+
var init_typeof = __esm({
|
|
826
|
+
"../../node_modules/@babel/runtime/helpers/esm/typeof.js"() {
|
|
827
|
+
}
|
|
828
|
+
});
|
|
829
|
+
|
|
830
|
+
// ../../node_modules/@babel/runtime/helpers/esm/toPrimitive.js
|
|
831
|
+
function _toPrimitive(input, hint) {
|
|
832
|
+
if (_typeof(input) !== "object" || input === null)
|
|
833
|
+
return input;
|
|
834
|
+
var prim = input[Symbol.toPrimitive];
|
|
835
|
+
if (prim !== void 0) {
|
|
836
|
+
var res = prim.call(input, hint || "default");
|
|
837
|
+
if (_typeof(res) !== "object")
|
|
838
|
+
return res;
|
|
839
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
840
|
+
}
|
|
841
|
+
return (hint === "string" ? String : Number)(input);
|
|
842
|
+
}
|
|
843
|
+
var init_toPrimitive = __esm({
|
|
844
|
+
"../../node_modules/@babel/runtime/helpers/esm/toPrimitive.js"() {
|
|
845
|
+
init_typeof();
|
|
846
|
+
}
|
|
847
|
+
});
|
|
848
|
+
|
|
849
|
+
// ../../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
|
|
850
|
+
function _toPropertyKey(arg) {
|
|
851
|
+
var key = _toPrimitive(arg, "string");
|
|
852
|
+
return _typeof(key) === "symbol" ? key : String(key);
|
|
853
|
+
}
|
|
854
|
+
var init_toPropertyKey = __esm({
|
|
855
|
+
"../../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js"() {
|
|
856
|
+
init_typeof();
|
|
857
|
+
init_toPrimitive();
|
|
858
|
+
}
|
|
859
|
+
});
|
|
860
|
+
|
|
861
|
+
// ../../node_modules/@babel/runtime/helpers/esm/defineProperty.js
|
|
862
|
+
function _defineProperty(obj, key, value) {
|
|
863
|
+
key = _toPropertyKey(key);
|
|
864
|
+
if (key in obj) {
|
|
865
|
+
Object.defineProperty(obj, key, {
|
|
866
|
+
value,
|
|
867
|
+
enumerable: true,
|
|
868
|
+
configurable: true,
|
|
869
|
+
writable: true
|
|
870
|
+
});
|
|
871
|
+
} else {
|
|
872
|
+
obj[key] = value;
|
|
873
|
+
}
|
|
874
|
+
return obj;
|
|
875
|
+
}
|
|
876
|
+
var init_defineProperty = __esm({
|
|
877
|
+
"../../node_modules/@babel/runtime/helpers/esm/defineProperty.js"() {
|
|
878
|
+
init_toPropertyKey();
|
|
879
|
+
}
|
|
880
|
+
});
|
|
881
|
+
|
|
882
|
+
// ../../node_modules/@probe.gl/stats/dist/utils/hi-res-timestamp.js
|
|
883
|
+
function getHiResTimestamp() {
|
|
884
|
+
let timestamp;
|
|
885
|
+
if (typeof window !== "undefined" && window.performance) {
|
|
886
|
+
timestamp = window.performance.now();
|
|
887
|
+
} else if (typeof process !== "undefined" && process.hrtime) {
|
|
888
|
+
const timeParts = process.hrtime();
|
|
889
|
+
timestamp = timeParts[0] * 1e3 + timeParts[1] / 1e6;
|
|
890
|
+
} else {
|
|
891
|
+
timestamp = Date.now();
|
|
892
|
+
}
|
|
893
|
+
return timestamp;
|
|
894
|
+
}
|
|
895
|
+
var init_hi_res_timestamp = __esm({
|
|
896
|
+
"../../node_modules/@probe.gl/stats/dist/utils/hi-res-timestamp.js"() {
|
|
897
|
+
}
|
|
898
|
+
});
|
|
899
|
+
|
|
900
|
+
// ../../node_modules/@probe.gl/stats/dist/lib/stat.js
|
|
901
|
+
var Stat;
|
|
902
|
+
var init_stat = __esm({
|
|
903
|
+
"../../node_modules/@probe.gl/stats/dist/lib/stat.js"() {
|
|
904
|
+
init_defineProperty();
|
|
905
|
+
init_hi_res_timestamp();
|
|
906
|
+
Stat = class {
|
|
907
|
+
constructor(name, type) {
|
|
908
|
+
_defineProperty(this, "name", void 0);
|
|
909
|
+
_defineProperty(this, "type", void 0);
|
|
910
|
+
_defineProperty(this, "sampleSize", 1);
|
|
911
|
+
_defineProperty(this, "time", 0);
|
|
912
|
+
_defineProperty(this, "count", 0);
|
|
913
|
+
_defineProperty(this, "samples", 0);
|
|
914
|
+
_defineProperty(this, "lastTiming", 0);
|
|
915
|
+
_defineProperty(this, "lastSampleTime", 0);
|
|
916
|
+
_defineProperty(this, "lastSampleCount", 0);
|
|
917
|
+
_defineProperty(this, "_count", 0);
|
|
918
|
+
_defineProperty(this, "_time", 0);
|
|
919
|
+
_defineProperty(this, "_samples", 0);
|
|
920
|
+
_defineProperty(this, "_startTime", 0);
|
|
921
|
+
_defineProperty(this, "_timerPending", false);
|
|
922
|
+
this.name = name;
|
|
923
|
+
this.type = type;
|
|
924
|
+
this.reset();
|
|
925
|
+
}
|
|
926
|
+
reset() {
|
|
927
|
+
this.time = 0;
|
|
928
|
+
this.count = 0;
|
|
929
|
+
this.samples = 0;
|
|
930
|
+
this.lastTiming = 0;
|
|
931
|
+
this.lastSampleTime = 0;
|
|
932
|
+
this.lastSampleCount = 0;
|
|
933
|
+
this._count = 0;
|
|
934
|
+
this._time = 0;
|
|
935
|
+
this._samples = 0;
|
|
936
|
+
this._startTime = 0;
|
|
937
|
+
this._timerPending = false;
|
|
938
|
+
return this;
|
|
939
|
+
}
|
|
940
|
+
setSampleSize(samples) {
|
|
941
|
+
this.sampleSize = samples;
|
|
942
|
+
return this;
|
|
943
|
+
}
|
|
944
|
+
incrementCount() {
|
|
945
|
+
this.addCount(1);
|
|
946
|
+
return this;
|
|
947
|
+
}
|
|
948
|
+
decrementCount() {
|
|
949
|
+
this.subtractCount(1);
|
|
950
|
+
return this;
|
|
951
|
+
}
|
|
952
|
+
addCount(value) {
|
|
953
|
+
this._count += value;
|
|
954
|
+
this._samples++;
|
|
955
|
+
this._checkSampling();
|
|
956
|
+
return this;
|
|
957
|
+
}
|
|
958
|
+
subtractCount(value) {
|
|
959
|
+
this._count -= value;
|
|
960
|
+
this._samples++;
|
|
961
|
+
this._checkSampling();
|
|
962
|
+
return this;
|
|
963
|
+
}
|
|
964
|
+
addTime(time) {
|
|
965
|
+
this._time += time;
|
|
966
|
+
this.lastTiming = time;
|
|
967
|
+
this._samples++;
|
|
968
|
+
this._checkSampling();
|
|
969
|
+
return this;
|
|
970
|
+
}
|
|
971
|
+
timeStart() {
|
|
972
|
+
this._startTime = getHiResTimestamp();
|
|
973
|
+
this._timerPending = true;
|
|
974
|
+
return this;
|
|
975
|
+
}
|
|
976
|
+
timeEnd() {
|
|
977
|
+
if (!this._timerPending) {
|
|
978
|
+
return this;
|
|
979
|
+
}
|
|
980
|
+
this.addTime(getHiResTimestamp() - this._startTime);
|
|
981
|
+
this._timerPending = false;
|
|
982
|
+
this._checkSampling();
|
|
983
|
+
return this;
|
|
984
|
+
}
|
|
985
|
+
getSampleAverageCount() {
|
|
986
|
+
return this.sampleSize > 0 ? this.lastSampleCount / this.sampleSize : 0;
|
|
987
|
+
}
|
|
988
|
+
getSampleAverageTime() {
|
|
989
|
+
return this.sampleSize > 0 ? this.lastSampleTime / this.sampleSize : 0;
|
|
990
|
+
}
|
|
991
|
+
getSampleHz() {
|
|
992
|
+
return this.lastSampleTime > 0 ? this.sampleSize / (this.lastSampleTime / 1e3) : 0;
|
|
993
|
+
}
|
|
994
|
+
getAverageCount() {
|
|
995
|
+
return this.samples > 0 ? this.count / this.samples : 0;
|
|
996
|
+
}
|
|
997
|
+
getAverageTime() {
|
|
998
|
+
return this.samples > 0 ? this.time / this.samples : 0;
|
|
999
|
+
}
|
|
1000
|
+
getHz() {
|
|
1001
|
+
return this.time > 0 ? this.samples / (this.time / 1e3) : 0;
|
|
1002
|
+
}
|
|
1003
|
+
_checkSampling() {
|
|
1004
|
+
if (this._samples === this.sampleSize) {
|
|
1005
|
+
this.lastSampleTime = this._time;
|
|
1006
|
+
this.lastSampleCount = this._count;
|
|
1007
|
+
this.count += this._count;
|
|
1008
|
+
this.time += this._time;
|
|
1009
|
+
this.samples += this._samples;
|
|
1010
|
+
this._time = 0;
|
|
1011
|
+
this._count = 0;
|
|
1012
|
+
this._samples = 0;
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
};
|
|
1016
|
+
}
|
|
1017
|
+
});
|
|
1018
|
+
|
|
1019
|
+
// ../../node_modules/@probe.gl/stats/dist/lib/stats.js
|
|
1020
|
+
var Stats;
|
|
1021
|
+
var init_stats = __esm({
|
|
1022
|
+
"../../node_modules/@probe.gl/stats/dist/lib/stats.js"() {
|
|
1023
|
+
init_defineProperty();
|
|
1024
|
+
init_stat();
|
|
1025
|
+
Stats = class {
|
|
1026
|
+
constructor(options) {
|
|
1027
|
+
_defineProperty(this, "id", void 0);
|
|
1028
|
+
_defineProperty(this, "stats", {});
|
|
1029
|
+
this.id = options.id;
|
|
1030
|
+
this.stats = {};
|
|
1031
|
+
this._initializeStats(options.stats);
|
|
1032
|
+
Object.seal(this);
|
|
1033
|
+
}
|
|
1034
|
+
get(name) {
|
|
1035
|
+
let type = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "count";
|
|
1036
|
+
return this._getOrCreate({
|
|
1037
|
+
name,
|
|
1038
|
+
type
|
|
1039
|
+
});
|
|
1040
|
+
}
|
|
1041
|
+
get size() {
|
|
1042
|
+
return Object.keys(this.stats).length;
|
|
1043
|
+
}
|
|
1044
|
+
reset() {
|
|
1045
|
+
for (const stat2 of Object.values(this.stats)) {
|
|
1046
|
+
stat2.reset();
|
|
1047
|
+
}
|
|
1048
|
+
return this;
|
|
1049
|
+
}
|
|
1050
|
+
forEach(fn) {
|
|
1051
|
+
for (const stat2 of Object.values(this.stats)) {
|
|
1052
|
+
fn(stat2);
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
getTable() {
|
|
1056
|
+
const table = {};
|
|
1057
|
+
this.forEach((stat2) => {
|
|
1058
|
+
table[stat2.name] = {
|
|
1059
|
+
time: stat2.time || 0,
|
|
1060
|
+
count: stat2.count || 0,
|
|
1061
|
+
average: stat2.getAverageTime() || 0,
|
|
1062
|
+
hz: stat2.getHz() || 0
|
|
1063
|
+
};
|
|
1064
|
+
});
|
|
1065
|
+
return table;
|
|
1066
|
+
}
|
|
1067
|
+
_initializeStats() {
|
|
1068
|
+
let stats = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
|
|
1069
|
+
stats.forEach((stat2) => this._getOrCreate(stat2));
|
|
1070
|
+
}
|
|
1071
|
+
_getOrCreate(stat2) {
|
|
1072
|
+
const {
|
|
1073
|
+
name,
|
|
1074
|
+
type
|
|
1075
|
+
} = stat2;
|
|
1076
|
+
let result = this.stats[name];
|
|
1077
|
+
if (!result) {
|
|
1078
|
+
if (stat2 instanceof Stat) {
|
|
1079
|
+
result = stat2;
|
|
1080
|
+
} else {
|
|
1081
|
+
result = new Stat(name, type);
|
|
1082
|
+
}
|
|
1083
|
+
this.stats[name] = result;
|
|
1084
|
+
}
|
|
1085
|
+
return result;
|
|
1086
|
+
}
|
|
1087
|
+
};
|
|
1088
|
+
}
|
|
1089
|
+
});
|
|
1090
|
+
|
|
1091
|
+
// ../../node_modules/@probe.gl/stats/dist/index.js
|
|
1092
|
+
var init_dist = __esm({
|
|
1093
|
+
"../../node_modules/@probe.gl/stats/dist/index.js"() {
|
|
1094
|
+
init_stats();
|
|
1095
|
+
init_stat();
|
|
1096
|
+
init_hi_res_timestamp();
|
|
1097
|
+
}
|
|
1098
|
+
});
|
|
1099
|
+
|
|
1100
|
+
// ../loader-utils/src/lib/request-utils/request-scheduler.ts
|
|
1101
|
+
var STAT_QUEUED_REQUESTS, STAT_ACTIVE_REQUESTS, STAT_CANCELLED_REQUESTS, STAT_QUEUED_REQUESTS_EVER, STAT_ACTIVE_REQUESTS_EVER, DEFAULT_PROPS2, RequestScheduler;
|
|
1102
|
+
var init_request_scheduler = __esm({
|
|
1103
|
+
"../loader-utils/src/lib/request-utils/request-scheduler.ts"() {
|
|
1104
|
+
init_dist();
|
|
1105
|
+
STAT_QUEUED_REQUESTS = "Queued Requests";
|
|
1106
|
+
STAT_ACTIVE_REQUESTS = "Active Requests";
|
|
1107
|
+
STAT_CANCELLED_REQUESTS = "Cancelled Requests";
|
|
1108
|
+
STAT_QUEUED_REQUESTS_EVER = "Queued Requests Ever";
|
|
1109
|
+
STAT_ACTIVE_REQUESTS_EVER = "Active Requests Ever";
|
|
1110
|
+
DEFAULT_PROPS2 = {
|
|
1111
|
+
id: "request-scheduler",
|
|
1112
|
+
throttleRequests: true,
|
|
1113
|
+
maxRequests: 6
|
|
1114
|
+
};
|
|
1115
|
+
RequestScheduler = class {
|
|
1116
|
+
constructor(props = {}) {
|
|
1117
|
+
this.activeRequestCount = 0;
|
|
1118
|
+
this.requestQueue = [];
|
|
1119
|
+
this.requestMap = new Map();
|
|
1120
|
+
this.deferredUpdate = null;
|
|
1121
|
+
this.props = { ...DEFAULT_PROPS2, ...props };
|
|
1122
|
+
this.stats = new Stats({ id: this.props.id });
|
|
1123
|
+
this.stats.get(STAT_QUEUED_REQUESTS);
|
|
1124
|
+
this.stats.get(STAT_ACTIVE_REQUESTS);
|
|
1125
|
+
this.stats.get(STAT_CANCELLED_REQUESTS);
|
|
1126
|
+
this.stats.get(STAT_QUEUED_REQUESTS_EVER);
|
|
1127
|
+
this.stats.get(STAT_ACTIVE_REQUESTS_EVER);
|
|
1128
|
+
}
|
|
1129
|
+
scheduleRequest(handle, getPriority = () => 0) {
|
|
1130
|
+
if (!this.props.throttleRequests) {
|
|
1131
|
+
return Promise.resolve({ done: () => {
|
|
1132
|
+
} });
|
|
1133
|
+
}
|
|
1134
|
+
if (this.requestMap.has(handle)) {
|
|
1135
|
+
return this.requestMap.get(handle);
|
|
1136
|
+
}
|
|
1137
|
+
const request = { handle, priority: 0, getPriority };
|
|
1138
|
+
const promise = new Promise((resolve2) => {
|
|
1139
|
+
request.resolve = resolve2;
|
|
1140
|
+
return request;
|
|
1141
|
+
});
|
|
1142
|
+
this.requestQueue.push(request);
|
|
1143
|
+
this.requestMap.set(handle, promise);
|
|
1144
|
+
this._issueNewRequests();
|
|
1145
|
+
return promise;
|
|
1146
|
+
}
|
|
1147
|
+
_issueRequest(request) {
|
|
1148
|
+
const { handle, resolve: resolve2 } = request;
|
|
1149
|
+
let isDone = false;
|
|
1150
|
+
const done = () => {
|
|
1151
|
+
if (!isDone) {
|
|
1152
|
+
isDone = true;
|
|
1153
|
+
this.requestMap.delete(handle);
|
|
1154
|
+
this.activeRequestCount--;
|
|
1155
|
+
this._issueNewRequests();
|
|
1156
|
+
}
|
|
1157
|
+
};
|
|
1158
|
+
this.activeRequestCount++;
|
|
1159
|
+
return resolve2 ? resolve2({ done }) : Promise.resolve({ done });
|
|
1160
|
+
}
|
|
1161
|
+
_issueNewRequests() {
|
|
1162
|
+
if (!this.deferredUpdate) {
|
|
1163
|
+
this.deferredUpdate = setTimeout(() => this._issueNewRequestsAsync(), 0);
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
_issueNewRequestsAsync() {
|
|
1167
|
+
this.deferredUpdate = null;
|
|
1168
|
+
const freeSlots = Math.max(this.props.maxRequests - this.activeRequestCount, 0);
|
|
1169
|
+
if (freeSlots === 0) {
|
|
1170
|
+
return;
|
|
1171
|
+
}
|
|
1172
|
+
this._updateAllRequests();
|
|
1173
|
+
for (let i = 0; i < freeSlots; ++i) {
|
|
1174
|
+
const request = this.requestQueue.shift();
|
|
1175
|
+
if (request) {
|
|
1176
|
+
this._issueRequest(request);
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
_updateAllRequests() {
|
|
1181
|
+
const requestQueue = this.requestQueue;
|
|
1182
|
+
for (let i = 0; i < requestQueue.length; ++i) {
|
|
1183
|
+
const request = requestQueue[i];
|
|
1184
|
+
if (!this._updateRequest(request)) {
|
|
1185
|
+
requestQueue.splice(i, 1);
|
|
1186
|
+
this.requestMap.delete(request.handle);
|
|
1187
|
+
i--;
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
requestQueue.sort((a, b) => a.priority - b.priority);
|
|
1191
|
+
}
|
|
1192
|
+
_updateRequest(request) {
|
|
1193
|
+
request.priority = request.getPriority(request.handle);
|
|
1194
|
+
if (request.priority < 0) {
|
|
1195
|
+
request.resolve(null);
|
|
1196
|
+
return false;
|
|
1197
|
+
}
|
|
1198
|
+
return true;
|
|
1199
|
+
}
|
|
1200
|
+
};
|
|
1201
|
+
}
|
|
1202
|
+
});
|
|
1203
|
+
|
|
1204
|
+
// ../loader-utils/src/lib/path-utils/file-aliases.ts
|
|
1205
|
+
function setPathPrefix(prefix) {
|
|
1206
|
+
pathPrefix = prefix;
|
|
1207
|
+
}
|
|
1208
|
+
function getPathPrefix() {
|
|
1209
|
+
return pathPrefix;
|
|
1210
|
+
}
|
|
1211
|
+
function resolvePath(filename2) {
|
|
1212
|
+
for (const alias in fileAliases) {
|
|
1213
|
+
if (filename2.startsWith(alias)) {
|
|
1214
|
+
const replacement = fileAliases[alias];
|
|
1215
|
+
filename2 = filename2.replace(alias, replacement);
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
if (!filename2.startsWith("http://") && !filename2.startsWith("https://")) {
|
|
1219
|
+
filename2 = `${pathPrefix}${filename2}`;
|
|
1220
|
+
}
|
|
1221
|
+
return filename2;
|
|
1222
|
+
}
|
|
1223
|
+
var pathPrefix, fileAliases;
|
|
1224
|
+
var init_file_aliases = __esm({
|
|
1225
|
+
"../loader-utils/src/lib/path-utils/file-aliases.ts"() {
|
|
1226
|
+
pathPrefix = "";
|
|
1227
|
+
fileAliases = {};
|
|
1228
|
+
}
|
|
1229
|
+
});
|
|
1230
|
+
|
|
1231
|
+
// ../loader-utils/src/json-loader.ts
|
|
1232
|
+
function parseTextSync(text) {
|
|
1233
|
+
return JSON.parse(text);
|
|
1234
|
+
}
|
|
1235
|
+
var VERSION3, JSONLoader;
|
|
1236
|
+
var init_json_loader = __esm({
|
|
1237
|
+
"../loader-utils/src/json-loader.ts"() {
|
|
1238
|
+
VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
1239
|
+
JSONLoader = {
|
|
1240
|
+
name: "JSON",
|
|
1241
|
+
id: "json",
|
|
1242
|
+
module: "json",
|
|
1243
|
+
version: VERSION3,
|
|
1244
|
+
extensions: ["json", "geojson"],
|
|
1245
|
+
mimeTypes: ["application/json"],
|
|
1246
|
+
category: "json",
|
|
1247
|
+
text: true,
|
|
1248
|
+
parseTextSync,
|
|
1249
|
+
parse: async (arrayBuffer) => parseTextSync(new TextDecoder().decode(arrayBuffer)),
|
|
1250
|
+
options: {}
|
|
1251
|
+
};
|
|
1252
|
+
}
|
|
1253
|
+
});
|
|
1254
|
+
|
|
1255
|
+
// ../loader-utils/src/lib/node/buffer.browser.ts
|
|
1256
|
+
function toArrayBuffer(buffer) {
|
|
1257
|
+
return buffer;
|
|
1258
|
+
}
|
|
1259
|
+
function toBuffer(binaryData) {
|
|
1260
|
+
throw new Error("Buffer not supported in browser");
|
|
1261
|
+
}
|
|
1262
|
+
var init_buffer_browser = __esm({
|
|
1263
|
+
"../loader-utils/src/lib/node/buffer.browser.ts"() {
|
|
1264
|
+
}
|
|
1265
|
+
});
|
|
1266
|
+
|
|
1267
|
+
// ../loader-utils/src/lib/binary-utils/memory-conversion-utils.ts
|
|
1268
|
+
function isBuffer(value) {
|
|
1269
|
+
return value && typeof value === "object" && value.isBuffer;
|
|
1270
|
+
}
|
|
1271
|
+
function toBuffer2(data) {
|
|
1272
|
+
return toBuffer ? toBuffer(data) : data;
|
|
1273
|
+
}
|
|
1274
|
+
function toArrayBuffer2(data) {
|
|
1275
|
+
if (isBuffer(data)) {
|
|
1276
|
+
return toArrayBuffer(data);
|
|
1277
|
+
}
|
|
1278
|
+
if (data instanceof ArrayBuffer) {
|
|
1279
|
+
return data;
|
|
1280
|
+
}
|
|
1281
|
+
if (ArrayBuffer.isView(data)) {
|
|
1282
|
+
if (data.byteOffset === 0 && data.byteLength === data.buffer.byteLength) {
|
|
1283
|
+
return data.buffer;
|
|
1284
|
+
}
|
|
1285
|
+
return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
|
|
1286
|
+
}
|
|
1287
|
+
if (typeof data === "string") {
|
|
1288
|
+
const text = data;
|
|
1289
|
+
const uint8Array = new TextEncoder().encode(text);
|
|
1290
|
+
return uint8Array.buffer;
|
|
1291
|
+
}
|
|
1292
|
+
if (data && typeof data === "object" && data._toArrayBuffer) {
|
|
1293
|
+
return data._toArrayBuffer();
|
|
1294
|
+
}
|
|
1295
|
+
throw new Error("toArrayBuffer");
|
|
1296
|
+
}
|
|
1297
|
+
var init_memory_conversion_utils = __esm({
|
|
1298
|
+
"../loader-utils/src/lib/binary-utils/memory-conversion-utils.ts"() {
|
|
1299
|
+
init_buffer_browser();
|
|
1300
|
+
}
|
|
1301
|
+
});
|
|
1302
|
+
|
|
1303
|
+
// ../loader-utils/src/lib/node/promisify.ts
|
|
1304
|
+
function promisify2(fn) {
|
|
1305
|
+
return (arg1, arg2) => new Promise((resolve2, reject) => fn(arg1, arg2, (error, callbackArgs) => error ? reject(error) : resolve2(callbackArgs)));
|
|
1306
|
+
}
|
|
1307
|
+
function promisify3(fn) {
|
|
1308
|
+
return (arg1, arg2, arg3) => new Promise((resolve2, reject) => fn(arg1, arg2, arg3, (error, callbackArgs) => error ? reject(error) : resolve2(callbackArgs)));
|
|
1309
|
+
}
|
|
1310
|
+
var init_promisify = __esm({
|
|
1311
|
+
"../loader-utils/src/lib/node/promisify.ts"() {
|
|
1312
|
+
}
|
|
1313
|
+
});
|
|
1314
|
+
|
|
1315
|
+
// ../loader-utils/src/lib/path-utils/get-cwd.ts
|
|
1316
|
+
function getCWD() {
|
|
1317
|
+
if (typeof process !== "undefined" && typeof process.cwd !== "undefined") {
|
|
1318
|
+
return process.cwd();
|
|
1319
|
+
}
|
|
1320
|
+
const pathname = window.location?.pathname;
|
|
1321
|
+
return pathname?.slice(0, pathname.lastIndexOf("/") + 1) || "";
|
|
1322
|
+
}
|
|
1323
|
+
var init_get_cwd = __esm({
|
|
1324
|
+
"../loader-utils/src/lib/path-utils/get-cwd.ts"() {
|
|
1325
|
+
}
|
|
1326
|
+
});
|
|
1327
|
+
|
|
1328
|
+
// ../loader-utils/src/lib/path-utils/path.ts
|
|
1329
|
+
var path_exports = {};
|
|
1330
|
+
__export(path_exports, {
|
|
1331
|
+
dirname: () => dirname,
|
|
1332
|
+
filename: () => filename,
|
|
1333
|
+
join: () => join,
|
|
1334
|
+
resolve: () => resolve
|
|
1335
|
+
});
|
|
1336
|
+
function filename(url) {
|
|
1337
|
+
const slashIndex = url ? url.lastIndexOf("/") : -1;
|
|
1338
|
+
return slashIndex >= 0 ? url.substr(slashIndex + 1) : "";
|
|
1339
|
+
}
|
|
1340
|
+
function dirname(url) {
|
|
1341
|
+
const slashIndex = url ? url.lastIndexOf("/") : -1;
|
|
1342
|
+
return slashIndex >= 0 ? url.substr(0, slashIndex) : "";
|
|
1343
|
+
}
|
|
1344
|
+
function join(...parts) {
|
|
1345
|
+
const separator = "/";
|
|
1346
|
+
parts = parts.map((part, index) => {
|
|
1347
|
+
if (index) {
|
|
1348
|
+
part = part.replace(new RegExp(`^${separator}`), "");
|
|
1349
|
+
}
|
|
1350
|
+
if (index !== parts.length - 1) {
|
|
1351
|
+
part = part.replace(new RegExp(`${separator}$`), "");
|
|
1352
|
+
}
|
|
1353
|
+
return part;
|
|
1354
|
+
});
|
|
1355
|
+
return parts.join(separator);
|
|
1356
|
+
}
|
|
1357
|
+
function resolve(...components) {
|
|
1358
|
+
const paths = [];
|
|
1359
|
+
for (let _i = 0; _i < components.length; _i++) {
|
|
1360
|
+
paths[_i] = components[_i];
|
|
1361
|
+
}
|
|
1362
|
+
let resolvedPath = "";
|
|
1363
|
+
let resolvedAbsolute = false;
|
|
1364
|
+
let cwd;
|
|
1365
|
+
for (let i = paths.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
|
1366
|
+
let path;
|
|
1367
|
+
if (i >= 0) {
|
|
1368
|
+
path = paths[i];
|
|
1369
|
+
} else {
|
|
1370
|
+
if (cwd === void 0) {
|
|
1371
|
+
cwd = getCWD();
|
|
1372
|
+
}
|
|
1373
|
+
path = cwd;
|
|
1374
|
+
}
|
|
1375
|
+
if (path.length === 0) {
|
|
1376
|
+
continue;
|
|
1377
|
+
}
|
|
1378
|
+
resolvedPath = `${path}/${resolvedPath}`;
|
|
1379
|
+
resolvedAbsolute = path.charCodeAt(0) === SLASH;
|
|
1380
|
+
}
|
|
1381
|
+
resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute);
|
|
1382
|
+
if (resolvedAbsolute) {
|
|
1383
|
+
return `/${resolvedPath}`;
|
|
1384
|
+
} else if (resolvedPath.length > 0) {
|
|
1385
|
+
return resolvedPath;
|
|
1386
|
+
}
|
|
1387
|
+
return ".";
|
|
1388
|
+
}
|
|
1389
|
+
function normalizeStringPosix(path, allowAboveRoot) {
|
|
1390
|
+
let res = "";
|
|
1391
|
+
let lastSlash = -1;
|
|
1392
|
+
let dots = 0;
|
|
1393
|
+
let code;
|
|
1394
|
+
let isAboveRoot = false;
|
|
1395
|
+
for (let i = 0; i <= path.length; ++i) {
|
|
1396
|
+
if (i < path.length) {
|
|
1397
|
+
code = path.charCodeAt(i);
|
|
1398
|
+
} else if (code === SLASH) {
|
|
1399
|
+
break;
|
|
1400
|
+
} else {
|
|
1401
|
+
code = SLASH;
|
|
1402
|
+
}
|
|
1403
|
+
if (code === SLASH) {
|
|
1404
|
+
if (lastSlash === i - 1 || dots === 1) {
|
|
1405
|
+
} else if (lastSlash !== i - 1 && dots === 2) {
|
|
1406
|
+
if (res.length < 2 || !isAboveRoot || res.charCodeAt(res.length - 1) !== DOT || res.charCodeAt(res.length - 2) !== DOT) {
|
|
1407
|
+
if (res.length > 2) {
|
|
1408
|
+
const start = res.length - 1;
|
|
1409
|
+
let j = start;
|
|
1410
|
+
for (; j >= 0; --j) {
|
|
1411
|
+
if (res.charCodeAt(j) === SLASH) {
|
|
1412
|
+
break;
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
if (j !== start) {
|
|
1416
|
+
res = j === -1 ? "" : res.slice(0, j);
|
|
1417
|
+
lastSlash = i;
|
|
1418
|
+
dots = 0;
|
|
1419
|
+
isAboveRoot = false;
|
|
1420
|
+
continue;
|
|
1421
|
+
}
|
|
1422
|
+
} else if (res.length === 2 || res.length === 1) {
|
|
1423
|
+
res = "";
|
|
1424
|
+
lastSlash = i;
|
|
1425
|
+
dots = 0;
|
|
1426
|
+
isAboveRoot = false;
|
|
1427
|
+
continue;
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
if (allowAboveRoot) {
|
|
1431
|
+
if (res.length > 0) {
|
|
1432
|
+
res += "/..";
|
|
1433
|
+
} else {
|
|
1434
|
+
res = "..";
|
|
1435
|
+
}
|
|
1436
|
+
isAboveRoot = true;
|
|
1437
|
+
}
|
|
1438
|
+
} else {
|
|
1439
|
+
const slice = path.slice(lastSlash + 1, i);
|
|
1440
|
+
if (res.length > 0) {
|
|
1441
|
+
res += `/${slice}`;
|
|
1442
|
+
} else {
|
|
1443
|
+
res = slice;
|
|
1444
|
+
}
|
|
1445
|
+
isAboveRoot = false;
|
|
1446
|
+
}
|
|
1447
|
+
lastSlash = i;
|
|
1448
|
+
dots = 0;
|
|
1449
|
+
} else if (code === DOT && dots !== -1) {
|
|
1450
|
+
++dots;
|
|
1451
|
+
} else {
|
|
1452
|
+
dots = -1;
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
return res;
|
|
1456
|
+
}
|
|
1457
|
+
var SLASH, DOT;
|
|
1458
|
+
var init_path = __esm({
|
|
1459
|
+
"../loader-utils/src/lib/path-utils/path.ts"() {
|
|
1460
|
+
init_get_cwd();
|
|
1461
|
+
SLASH = 47;
|
|
1462
|
+
DOT = 46;
|
|
1463
|
+
}
|
|
1464
|
+
});
|
|
1465
|
+
|
|
1466
|
+
// (disabled):fs
|
|
1467
|
+
var require_fs = __commonJS({
|
|
1468
|
+
"(disabled):fs"() {
|
|
1469
|
+
}
|
|
1470
|
+
});
|
|
1471
|
+
|
|
1472
|
+
// ../loader-utils/src/lib/node/fs.ts
|
|
1473
|
+
var fs_exports = {};
|
|
1474
|
+
__export(fs_exports, {
|
|
1475
|
+
_readToArrayBuffer: () => _readToArrayBuffer,
|
|
1476
|
+
close: () => close,
|
|
1477
|
+
createWriteStream: () => createWriteStream,
|
|
1478
|
+
fstat: () => fstat,
|
|
1479
|
+
isSupported: () => isSupported,
|
|
1480
|
+
open: () => open,
|
|
1481
|
+
read: () => read,
|
|
1482
|
+
readFile: () => readFile,
|
|
1483
|
+
readFileSync: () => readFileSync,
|
|
1484
|
+
readdir: () => readdir,
|
|
1485
|
+
stat: () => stat,
|
|
1486
|
+
writeFile: () => writeFile,
|
|
1487
|
+
writeFileSync: () => writeFileSync
|
|
1488
|
+
});
|
|
1489
|
+
async function _readToArrayBuffer(fd, start, length) {
|
|
1490
|
+
const buffer = Buffer.alloc(length);
|
|
1491
|
+
const { bytesRead } = await read(fd, buffer, 0, length, start);
|
|
1492
|
+
if (bytesRead !== length) {
|
|
1493
|
+
throw new Error("fs.read failed");
|
|
1494
|
+
}
|
|
1495
|
+
return toArrayBuffer(buffer);
|
|
1496
|
+
}
|
|
1497
|
+
var import_fs, readdir, stat, readFile, readFileSync, writeFile, writeFileSync, open, close, read, fstat, createWriteStream, isSupported;
|
|
1498
|
+
var init_fs = __esm({
|
|
1499
|
+
"../loader-utils/src/lib/node/fs.ts"() {
|
|
1500
|
+
import_fs = __toModule(require_fs());
|
|
1501
|
+
init_buffer_browser();
|
|
1502
|
+
init_promisify();
|
|
1503
|
+
isSupported = Boolean(import_fs.default);
|
|
1504
|
+
try {
|
|
1505
|
+
readdir = promisify2(import_fs.default.readdir);
|
|
1506
|
+
stat = promisify2(import_fs.default.stat);
|
|
1507
|
+
readFile = import_fs.default.readFile;
|
|
1508
|
+
readFileSync = import_fs.default.readFileSync;
|
|
1509
|
+
writeFile = promisify3(import_fs.default.writeFile);
|
|
1510
|
+
writeFileSync = import_fs.default.writeFileSync;
|
|
1511
|
+
open = import_fs.default.open;
|
|
1512
|
+
close = (fd) => new Promise((resolve2, reject) => import_fs.default.close(fd, (err) => err ? reject(err) : resolve2()));
|
|
1513
|
+
read = import_fs.default.read;
|
|
1514
|
+
fstat = import_fs.default.fstat;
|
|
1515
|
+
createWriteStream = import_fs.default.createWriteStream;
|
|
1516
|
+
isSupported = Boolean(import_fs.default);
|
|
1517
|
+
} catch {
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
});
|
|
1521
|
+
|
|
1522
|
+
// ../loader-utils/src/index.ts
|
|
1523
|
+
var init_src2 = __esm({
|
|
1524
|
+
"../loader-utils/src/index.ts"() {
|
|
1525
|
+
init_assert();
|
|
1526
|
+
init_globals();
|
|
1527
|
+
init_parse_with_worker();
|
|
1528
|
+
init_encode_with_worker();
|
|
1529
|
+
init_array_buffer_utils();
|
|
1530
|
+
init_text_iterators();
|
|
1531
|
+
init_async_iteration();
|
|
1532
|
+
init_request_scheduler();
|
|
1533
|
+
init_file_aliases();
|
|
1534
|
+
init_json_loader();
|
|
1535
|
+
init_memory_conversion_utils();
|
|
1536
|
+
init_path();
|
|
1537
|
+
init_fs();
|
|
1538
|
+
}
|
|
1539
|
+
});
|
|
1540
|
+
|
|
1541
|
+
// src/javascript-utils/is-type.ts
|
|
1542
|
+
var isBoolean, isFunction, isObject, isPureObject, isPromise, isIterable, isAsyncIterable, isIterator, isResponse, isBlob, isBuffer2, isWritableDOMStream, isReadableDOMStream, isWritableNodeStream, isReadableNodeStream, isReadableStream, isWritableStream;
|
|
1543
|
+
var init_is_type = __esm({
|
|
1544
|
+
"src/javascript-utils/is-type.ts"() {
|
|
1545
|
+
isBoolean = (x) => typeof x === "boolean";
|
|
1546
|
+
isFunction = (x) => typeof x === "function";
|
|
1547
|
+
isObject = (x) => x !== null && typeof x === "object";
|
|
1548
|
+
isPureObject = (x) => isObject(x) && x.constructor === {}.constructor;
|
|
1549
|
+
isPromise = (x) => isObject(x) && isFunction(x.then);
|
|
1550
|
+
isIterable = (x) => x && typeof x[Symbol.iterator] === "function";
|
|
1551
|
+
isAsyncIterable = (x) => x && typeof x[Symbol.asyncIterator] === "function";
|
|
1552
|
+
isIterator = (x) => x && isFunction(x.next);
|
|
1553
|
+
isResponse = (x) => typeof Response !== "undefined" && x instanceof Response || x && x.arrayBuffer && x.text && x.json;
|
|
1554
|
+
isBlob = (x) => typeof Blob !== "undefined" && x instanceof Blob;
|
|
1555
|
+
isBuffer2 = (x) => x && typeof x === "object" && x.isBuffer;
|
|
1556
|
+
isWritableDOMStream = (x) => isObject(x) && isFunction(x.abort) && isFunction(x.getWriter);
|
|
1557
|
+
isReadableDOMStream = (x) => typeof ReadableStream !== "undefined" && x instanceof ReadableStream || isObject(x) && isFunction(x.tee) && isFunction(x.cancel) && isFunction(x.getReader);
|
|
1558
|
+
isWritableNodeStream = (x) => isObject(x) && isFunction(x.end) && isFunction(x.write) && isBoolean(x.writable);
|
|
1559
|
+
isReadableNodeStream = (x) => isObject(x) && isFunction(x.read) && isFunction(x.pipe) && isBoolean(x.readable);
|
|
1560
|
+
isReadableStream = (x) => isReadableDOMStream(x) || isReadableNodeStream(x);
|
|
1561
|
+
isWritableStream = (x) => isWritableDOMStream(x) || isWritableNodeStream(x);
|
|
1562
|
+
}
|
|
1563
|
+
});
|
|
1564
|
+
|
|
1565
|
+
// src/lib/utils/mime-type-utils.ts
|
|
1566
|
+
function parseMIMEType(mimeString) {
|
|
1567
|
+
const matches3 = MIME_TYPE_PATTERN.exec(mimeString);
|
|
1568
|
+
if (matches3) {
|
|
1569
|
+
return matches3[1];
|
|
1570
|
+
}
|
|
1571
|
+
return mimeString;
|
|
1572
|
+
}
|
|
1573
|
+
function parseMIMETypeFromURL(url) {
|
|
1574
|
+
const matches3 = DATA_URL_PATTERN.exec(url);
|
|
1575
|
+
if (matches3) {
|
|
1576
|
+
return matches3[1];
|
|
1577
|
+
}
|
|
1578
|
+
return "";
|
|
1579
|
+
}
|
|
1580
|
+
var DATA_URL_PATTERN, MIME_TYPE_PATTERN;
|
|
1581
|
+
var init_mime_type_utils = __esm({
|
|
1582
|
+
"src/lib/utils/mime-type-utils.ts"() {
|
|
1583
|
+
DATA_URL_PATTERN = /^data:([-\w.]+\/[-\w.+]+)(;|,)/;
|
|
1584
|
+
MIME_TYPE_PATTERN = /^([-\w.]+\/[-\w.+]+)/;
|
|
1585
|
+
}
|
|
1586
|
+
});
|
|
1587
|
+
|
|
1588
|
+
// src/lib/utils/resource-utils.ts
|
|
1589
|
+
function getResourceUrlAndType(resource) {
|
|
1590
|
+
if (isResponse(resource)) {
|
|
1591
|
+
const url = stripQueryString(resource.url || "");
|
|
1592
|
+
const contentTypeHeader = resource.headers.get("content-type") || "";
|
|
1593
|
+
return {
|
|
1594
|
+
url,
|
|
1595
|
+
type: parseMIMEType(contentTypeHeader) || parseMIMETypeFromURL(url)
|
|
1596
|
+
};
|
|
1597
|
+
}
|
|
1598
|
+
if (isBlob(resource)) {
|
|
1599
|
+
return {
|
|
1600
|
+
url: stripQueryString(resource.name || ""),
|
|
1601
|
+
type: resource.type || ""
|
|
1602
|
+
};
|
|
1603
|
+
}
|
|
1604
|
+
if (typeof resource === "string") {
|
|
1605
|
+
return {
|
|
1606
|
+
url: stripQueryString(resource),
|
|
1607
|
+
type: parseMIMETypeFromURL(resource)
|
|
1608
|
+
};
|
|
1609
|
+
}
|
|
1610
|
+
return {
|
|
1611
|
+
url: "",
|
|
1612
|
+
type: ""
|
|
1613
|
+
};
|
|
1614
|
+
}
|
|
1615
|
+
function getResourceContentLength(resource) {
|
|
1616
|
+
if (isResponse(resource)) {
|
|
1617
|
+
return resource.headers["content-length"] || -1;
|
|
1618
|
+
}
|
|
1619
|
+
if (isBlob(resource)) {
|
|
1620
|
+
return resource.size;
|
|
1621
|
+
}
|
|
1622
|
+
if (typeof resource === "string") {
|
|
1623
|
+
return resource.length;
|
|
1624
|
+
}
|
|
1625
|
+
if (resource instanceof ArrayBuffer) {
|
|
1626
|
+
return resource.byteLength;
|
|
1627
|
+
}
|
|
1628
|
+
if (ArrayBuffer.isView(resource)) {
|
|
1629
|
+
return resource.byteLength;
|
|
1630
|
+
}
|
|
1631
|
+
return -1;
|
|
1632
|
+
}
|
|
1633
|
+
function stripQueryString(url) {
|
|
1634
|
+
return url.replace(QUERY_STRING_PATTERN, "");
|
|
1635
|
+
}
|
|
1636
|
+
var QUERY_STRING_PATTERN;
|
|
1637
|
+
var init_resource_utils = __esm({
|
|
1638
|
+
"src/lib/utils/resource-utils.ts"() {
|
|
1639
|
+
init_is_type();
|
|
1640
|
+
init_mime_type_utils();
|
|
1641
|
+
QUERY_STRING_PATTERN = /\?.*/;
|
|
1642
|
+
}
|
|
1643
|
+
});
|
|
1644
|
+
|
|
1645
|
+
// src/lib/utils/response-utils.ts
|
|
1646
|
+
async function makeResponse(resource) {
|
|
1647
|
+
if (isResponse(resource)) {
|
|
1648
|
+
return resource;
|
|
1649
|
+
}
|
|
1650
|
+
const headers = {};
|
|
1651
|
+
const contentLength = getResourceContentLength(resource);
|
|
1652
|
+
if (contentLength >= 0) {
|
|
1653
|
+
headers["content-length"] = String(contentLength);
|
|
1654
|
+
}
|
|
1655
|
+
const { url, type } = getResourceUrlAndType(resource);
|
|
1656
|
+
if (type) {
|
|
1657
|
+
headers["content-type"] = type;
|
|
1658
|
+
}
|
|
1659
|
+
const initialDataUrl = await getInitialDataUrl(resource);
|
|
1660
|
+
if (initialDataUrl) {
|
|
1661
|
+
headers["x-first-bytes"] = initialDataUrl;
|
|
1662
|
+
}
|
|
1663
|
+
if (typeof resource === "string") {
|
|
1664
|
+
resource = new TextEncoder().encode(resource);
|
|
1665
|
+
}
|
|
1666
|
+
const response = new Response(resource, { headers });
|
|
1667
|
+
Object.defineProperty(response, "url", { value: url });
|
|
1668
|
+
return response;
|
|
1669
|
+
}
|
|
1670
|
+
async function checkResponse(response) {
|
|
1671
|
+
if (!response.ok) {
|
|
1672
|
+
const message = await getResponseError(response);
|
|
1673
|
+
throw new Error(message);
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
async function getResponseError(response) {
|
|
1677
|
+
let message = `Failed to fetch resource ${response.url} (${response.status}): `;
|
|
1678
|
+
try {
|
|
1679
|
+
const contentType = response.headers.get("Content-Type");
|
|
1680
|
+
let text = response.statusText;
|
|
1681
|
+
if (contentType.includes("application/json")) {
|
|
1682
|
+
text += ` ${await response.text()}`;
|
|
1683
|
+
}
|
|
1684
|
+
message += text;
|
|
1685
|
+
message = message.length > 60 ? `${message.slice(0, 60)}...` : message;
|
|
1686
|
+
} catch (error) {
|
|
1687
|
+
}
|
|
1688
|
+
return message;
|
|
1689
|
+
}
|
|
1690
|
+
async function getInitialDataUrl(resource) {
|
|
1691
|
+
const INITIAL_DATA_LENGTH = 5;
|
|
1692
|
+
if (typeof resource === "string") {
|
|
1693
|
+
return `data:,${resource.slice(0, INITIAL_DATA_LENGTH)}`;
|
|
1694
|
+
}
|
|
1695
|
+
if (resource instanceof Blob) {
|
|
1696
|
+
const blobSlice = resource.slice(0, 5);
|
|
1697
|
+
return await new Promise((resolve2) => {
|
|
1698
|
+
const reader = new FileReader();
|
|
1699
|
+
reader.onload = (event) => resolve2(event?.target?.result);
|
|
1700
|
+
reader.readAsDataURL(blobSlice);
|
|
1701
|
+
});
|
|
1702
|
+
}
|
|
1703
|
+
if (resource instanceof ArrayBuffer) {
|
|
1704
|
+
const slice = resource.slice(0, INITIAL_DATA_LENGTH);
|
|
1705
|
+
const base64 = arrayBufferToBase64(slice);
|
|
1706
|
+
return `data:base64,${base64}`;
|
|
1707
|
+
}
|
|
1708
|
+
return null;
|
|
1709
|
+
}
|
|
1710
|
+
function arrayBufferToBase64(buffer) {
|
|
1711
|
+
let binary = "";
|
|
1712
|
+
const bytes = new Uint8Array(buffer);
|
|
1713
|
+
for (let i = 0; i < bytes.byteLength; i++) {
|
|
1714
|
+
binary += String.fromCharCode(bytes[i]);
|
|
1715
|
+
}
|
|
1716
|
+
return btoa(binary);
|
|
1717
|
+
}
|
|
1718
|
+
var init_response_utils = __esm({
|
|
1719
|
+
"src/lib/utils/response-utils.ts"() {
|
|
1720
|
+
init_is_type();
|
|
1721
|
+
init_resource_utils();
|
|
1722
|
+
}
|
|
1723
|
+
});
|
|
1724
|
+
|
|
1725
|
+
// src/lib/fetch/fetch-file.ts
|
|
1726
|
+
async function fetchFile(url, options) {
|
|
1727
|
+
if (typeof url === "string") {
|
|
1728
|
+
url = resolvePath(url);
|
|
1729
|
+
let fetchOptions = options;
|
|
1730
|
+
if (options?.fetch && typeof options?.fetch !== "function") {
|
|
1731
|
+
fetchOptions = options.fetch;
|
|
1732
|
+
}
|
|
1733
|
+
return await fetch(url, fetchOptions);
|
|
1734
|
+
}
|
|
1735
|
+
return await makeResponse(url);
|
|
1736
|
+
}
|
|
1737
|
+
var init_fetch_file = __esm({
|
|
1738
|
+
"src/lib/fetch/fetch-file.ts"() {
|
|
1739
|
+
init_src2();
|
|
1740
|
+
init_response_utils();
|
|
1741
|
+
}
|
|
1742
|
+
});
|
|
1743
|
+
|
|
1744
|
+
// src/lib/fetch/read-array-buffer.ts
|
|
1745
|
+
async function readArrayBuffer(file, start, length) {
|
|
1746
|
+
if (typeof file === "number") {
|
|
1747
|
+
return await fs_exports._readToArrayBuffer(file, start, length);
|
|
1748
|
+
}
|
|
1749
|
+
if (!(file instanceof Blob)) {
|
|
1750
|
+
file = new Blob([file]);
|
|
1751
|
+
}
|
|
1752
|
+
const slice = file.slice(start, start + length);
|
|
1753
|
+
return await readBlob(slice);
|
|
1754
|
+
}
|
|
1755
|
+
async function readBlob(blob) {
|
|
1756
|
+
return await new Promise((resolve2, reject) => {
|
|
1757
|
+
const fileReader = new FileReader();
|
|
1758
|
+
fileReader.onload = (event) => resolve2(event?.target?.result);
|
|
1759
|
+
fileReader.onerror = (error) => reject(error);
|
|
1760
|
+
fileReader.readAsArrayBuffer(blob);
|
|
1761
|
+
});
|
|
1762
|
+
}
|
|
1763
|
+
var init_read_array_buffer = __esm({
|
|
1764
|
+
"src/lib/fetch/read-array-buffer.ts"() {
|
|
1765
|
+
init_src2();
|
|
1766
|
+
}
|
|
1767
|
+
});
|
|
1768
|
+
|
|
1769
|
+
// src/lib/fetch/read-file.ts
|
|
1770
|
+
function readFileSync2(url, options = {}) {
|
|
1771
|
+
url = resolvePath(url);
|
|
1772
|
+
if (!isBrowser) {
|
|
1773
|
+
const buffer = fs_exports.readFileSync(url, options);
|
|
1774
|
+
return typeof buffer !== "string" ? toArrayBuffer2(buffer) : buffer;
|
|
1775
|
+
}
|
|
1776
|
+
if (!options.nothrow) {
|
|
1777
|
+
assert(false);
|
|
1778
|
+
}
|
|
1779
|
+
return null;
|
|
1780
|
+
}
|
|
1781
|
+
var init_read_file = __esm({
|
|
1782
|
+
"src/lib/fetch/read-file.ts"() {
|
|
1783
|
+
init_src2();
|
|
1784
|
+
init_src2();
|
|
1785
|
+
}
|
|
1786
|
+
});
|
|
1787
|
+
|
|
1788
|
+
// src/lib/fetch/write-file.ts
|
|
1789
|
+
async function writeFile2(filePath, arrayBufferOrString, options) {
|
|
1790
|
+
filePath = resolvePath(filePath);
|
|
1791
|
+
if (!isBrowser) {
|
|
1792
|
+
await fs_exports.writeFile(filePath, toBuffer2(arrayBufferOrString), { flag: "w" });
|
|
1793
|
+
}
|
|
1794
|
+
assert(false);
|
|
1795
|
+
}
|
|
1796
|
+
function writeFileSync2(filePath, arrayBufferOrString, options) {
|
|
1797
|
+
filePath = resolvePath(filePath);
|
|
1798
|
+
if (!isBrowser) {
|
|
1799
|
+
fs_exports.writeFileSync(filePath, toBuffer2(arrayBufferOrString), { flag: "w" });
|
|
1800
|
+
}
|
|
1801
|
+
assert(false);
|
|
1802
|
+
}
|
|
1803
|
+
var init_write_file = __esm({
|
|
1804
|
+
"src/lib/fetch/write-file.ts"() {
|
|
1805
|
+
init_src2();
|
|
1806
|
+
init_src2();
|
|
1807
|
+
}
|
|
1808
|
+
});
|
|
1809
|
+
|
|
1810
|
+
// ../../node_modules/@probe.gl/env/dist/lib/is-electron.js
|
|
1811
|
+
function isElectron(mockUserAgent) {
|
|
1812
|
+
if (typeof window !== "undefined" && typeof window.process === "object" && window.process.type === "renderer") {
|
|
1813
|
+
return true;
|
|
1814
|
+
}
|
|
1815
|
+
if (typeof process !== "undefined" && typeof process.versions === "object" && Boolean(process.versions["electron"])) {
|
|
1816
|
+
return true;
|
|
1817
|
+
}
|
|
1818
|
+
const realUserAgent = typeof navigator === "object" && typeof navigator.userAgent === "string" && navigator.userAgent;
|
|
1819
|
+
const userAgent = mockUserAgent || realUserAgent;
|
|
1820
|
+
if (userAgent && userAgent.indexOf("Electron") >= 0) {
|
|
1821
|
+
return true;
|
|
1822
|
+
}
|
|
1823
|
+
return false;
|
|
1824
|
+
}
|
|
1825
|
+
var init_is_electron = __esm({
|
|
1826
|
+
"../../node_modules/@probe.gl/env/dist/lib/is-electron.js"() {
|
|
1827
|
+
}
|
|
1828
|
+
});
|
|
1829
|
+
|
|
1830
|
+
// ../../node_modules/@probe.gl/env/dist/lib/is-browser.js
|
|
1831
|
+
function isBrowser3() {
|
|
1832
|
+
const isNode = typeof process === "object" && String(process) === "[object process]" && !process.browser;
|
|
1833
|
+
return !isNode || isElectron();
|
|
1834
|
+
}
|
|
1835
|
+
var init_is_browser = __esm({
|
|
1836
|
+
"../../node_modules/@probe.gl/env/dist/lib/is-browser.js"() {
|
|
1837
|
+
init_is_electron();
|
|
1838
|
+
}
|
|
1839
|
+
});
|
|
1840
|
+
|
|
1841
|
+
// ../../node_modules/@probe.gl/env/dist/lib/globals.js
|
|
1842
|
+
var self_3, window_3, document_3, process_, console_, navigator_;
|
|
1843
|
+
var init_globals3 = __esm({
|
|
1844
|
+
"../../node_modules/@probe.gl/env/dist/lib/globals.js"() {
|
|
1845
|
+
self_3 = globalThis.self || globalThis.window || globalThis.global;
|
|
1846
|
+
window_3 = globalThis.window || globalThis.self || globalThis.global;
|
|
1847
|
+
document_3 = globalThis.document || {};
|
|
1848
|
+
process_ = globalThis.process || {};
|
|
1849
|
+
console_ = globalThis.console;
|
|
1850
|
+
navigator_ = globalThis.navigator || {};
|
|
1851
|
+
}
|
|
1852
|
+
});
|
|
1853
|
+
|
|
1854
|
+
// ../../node_modules/@probe.gl/env/dist/utils/globals.js
|
|
1855
|
+
var VERSION4, isBrowser4;
|
|
1856
|
+
var init_globals4 = __esm({
|
|
1857
|
+
"../../node_modules/@probe.gl/env/dist/utils/globals.js"() {
|
|
1858
|
+
init_is_browser();
|
|
1859
|
+
VERSION4 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "untranspiled source";
|
|
1860
|
+
isBrowser4 = isBrowser3();
|
|
1861
|
+
}
|
|
1862
|
+
});
|
|
1863
|
+
|
|
1864
|
+
// ../../node_modules/@probe.gl/env/dist/index.js
|
|
1865
|
+
var init_dist2 = __esm({
|
|
1866
|
+
"../../node_modules/@probe.gl/env/dist/index.js"() {
|
|
1867
|
+
init_globals4();
|
|
1868
|
+
init_globals3();
|
|
1869
|
+
init_is_browser();
|
|
1870
|
+
}
|
|
1871
|
+
});
|
|
1872
|
+
|
|
1873
|
+
// ../../node_modules/@probe.gl/log/dist/utils/local-storage.js
|
|
1874
|
+
function getStorage(type) {
|
|
1875
|
+
try {
|
|
1876
|
+
const storage = window[type];
|
|
1877
|
+
const x = "__storage_test__";
|
|
1878
|
+
storage.setItem(x, x);
|
|
1879
|
+
storage.removeItem(x);
|
|
1880
|
+
return storage;
|
|
1881
|
+
} catch (e) {
|
|
1882
|
+
return null;
|
|
1883
|
+
}
|
|
1884
|
+
}
|
|
1885
|
+
var LocalStorage;
|
|
1886
|
+
var init_local_storage = __esm({
|
|
1887
|
+
"../../node_modules/@probe.gl/log/dist/utils/local-storage.js"() {
|
|
1888
|
+
init_defineProperty();
|
|
1889
|
+
LocalStorage = class {
|
|
1890
|
+
constructor(id, defaultConfig) {
|
|
1891
|
+
let type = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "sessionStorage";
|
|
1892
|
+
_defineProperty(this, "storage", void 0);
|
|
1893
|
+
_defineProperty(this, "id", void 0);
|
|
1894
|
+
_defineProperty(this, "config", void 0);
|
|
1895
|
+
this.storage = getStorage(type);
|
|
1896
|
+
this.id = id;
|
|
1897
|
+
this.config = defaultConfig;
|
|
1898
|
+
this._loadConfiguration();
|
|
1899
|
+
}
|
|
1900
|
+
getConfiguration() {
|
|
1901
|
+
return this.config;
|
|
1902
|
+
}
|
|
1903
|
+
setConfiguration(configuration) {
|
|
1904
|
+
Object.assign(this.config, configuration);
|
|
1905
|
+
if (this.storage) {
|
|
1906
|
+
const serialized = JSON.stringify(this.config);
|
|
1907
|
+
this.storage.setItem(this.id, serialized);
|
|
1908
|
+
}
|
|
1909
|
+
}
|
|
1910
|
+
_loadConfiguration() {
|
|
1911
|
+
let configuration = {};
|
|
1912
|
+
if (this.storage) {
|
|
1913
|
+
const serializedConfiguration = this.storage.getItem(this.id);
|
|
1914
|
+
configuration = serializedConfiguration ? JSON.parse(serializedConfiguration) : {};
|
|
1915
|
+
}
|
|
1916
|
+
Object.assign(this.config, configuration);
|
|
1917
|
+
return this;
|
|
1918
|
+
}
|
|
1919
|
+
};
|
|
1920
|
+
}
|
|
1921
|
+
});
|
|
1922
|
+
|
|
1923
|
+
// ../../node_modules/@probe.gl/log/dist/utils/formatters.js
|
|
1924
|
+
function formatTime(ms) {
|
|
1925
|
+
let formatted;
|
|
1926
|
+
if (ms < 10) {
|
|
1927
|
+
formatted = "".concat(ms.toFixed(2), "ms");
|
|
1928
|
+
} else if (ms < 100) {
|
|
1929
|
+
formatted = "".concat(ms.toFixed(1), "ms");
|
|
1930
|
+
} else if (ms < 1e3) {
|
|
1931
|
+
formatted = "".concat(ms.toFixed(0), "ms");
|
|
1932
|
+
} else {
|
|
1933
|
+
formatted = "".concat((ms / 1e3).toFixed(2), "s");
|
|
1934
|
+
}
|
|
1935
|
+
return formatted;
|
|
1936
|
+
}
|
|
1937
|
+
function leftPad(string) {
|
|
1938
|
+
let length = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 8;
|
|
1939
|
+
const padLength = Math.max(length - string.length, 0);
|
|
1940
|
+
return "".concat(" ".repeat(padLength)).concat(string);
|
|
1941
|
+
}
|
|
1942
|
+
function formatImage(image, message, scale) {
|
|
1943
|
+
let maxWidth = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 600;
|
|
1944
|
+
const imageUrl = image.src.replace(/\(/g, "%28").replace(/\)/g, "%29");
|
|
1945
|
+
if (image.width > maxWidth) {
|
|
1946
|
+
scale = Math.min(scale, maxWidth / image.width);
|
|
1947
|
+
}
|
|
1948
|
+
const width = image.width * scale;
|
|
1949
|
+
const height = image.height * scale;
|
|
1950
|
+
const style = ["font-size:1px;", "padding:".concat(Math.floor(height / 2), "px ").concat(Math.floor(width / 2), "px;"), "line-height:".concat(height, "px;"), "background:url(".concat(imageUrl, ");"), "background-size:".concat(width, "px ").concat(height, "px;"), "color:transparent;"].join("");
|
|
1951
|
+
return ["".concat(message, " %c+"), style];
|
|
1952
|
+
}
|
|
1953
|
+
var init_formatters = __esm({
|
|
1954
|
+
"../../node_modules/@probe.gl/log/dist/utils/formatters.js"() {
|
|
1955
|
+
}
|
|
1956
|
+
});
|
|
1957
|
+
|
|
1958
|
+
// ../../node_modules/@probe.gl/log/dist/utils/color.js
|
|
1959
|
+
function getColor(color) {
|
|
1960
|
+
if (typeof color !== "string") {
|
|
1961
|
+
return color;
|
|
1962
|
+
}
|
|
1963
|
+
color = color.toUpperCase();
|
|
1964
|
+
return COLOR[color] || COLOR.WHITE;
|
|
1965
|
+
}
|
|
1966
|
+
function addColor(string, color, background) {
|
|
1967
|
+
if (!isBrowser3 && typeof string === "string") {
|
|
1968
|
+
if (color) {
|
|
1969
|
+
const colorCode = getColor(color);
|
|
1970
|
+
string = "[".concat(colorCode, "m").concat(string, "[39m");
|
|
1971
|
+
}
|
|
1972
|
+
if (background) {
|
|
1973
|
+
const colorCode = getColor(background);
|
|
1974
|
+
string = "[".concat(colorCode + BACKGROUND_INCREMENT, "m").concat(string, "[49m");
|
|
1975
|
+
}
|
|
1976
|
+
}
|
|
1977
|
+
return string;
|
|
1978
|
+
}
|
|
1979
|
+
var COLOR, BACKGROUND_INCREMENT;
|
|
1980
|
+
var init_color = __esm({
|
|
1981
|
+
"../../node_modules/@probe.gl/log/dist/utils/color.js"() {
|
|
1982
|
+
init_dist2();
|
|
1983
|
+
(function(COLOR2) {
|
|
1984
|
+
COLOR2[COLOR2["BLACK"] = 30] = "BLACK";
|
|
1985
|
+
COLOR2[COLOR2["RED"] = 31] = "RED";
|
|
1986
|
+
COLOR2[COLOR2["GREEN"] = 32] = "GREEN";
|
|
1987
|
+
COLOR2[COLOR2["YELLOW"] = 33] = "YELLOW";
|
|
1988
|
+
COLOR2[COLOR2["BLUE"] = 34] = "BLUE";
|
|
1989
|
+
COLOR2[COLOR2["MAGENTA"] = 35] = "MAGENTA";
|
|
1990
|
+
COLOR2[COLOR2["CYAN"] = 36] = "CYAN";
|
|
1991
|
+
COLOR2[COLOR2["WHITE"] = 37] = "WHITE";
|
|
1992
|
+
COLOR2[COLOR2["BRIGHT_BLACK"] = 90] = "BRIGHT_BLACK";
|
|
1993
|
+
COLOR2[COLOR2["BRIGHT_RED"] = 91] = "BRIGHT_RED";
|
|
1994
|
+
COLOR2[COLOR2["BRIGHT_GREEN"] = 92] = "BRIGHT_GREEN";
|
|
1995
|
+
COLOR2[COLOR2["BRIGHT_YELLOW"] = 93] = "BRIGHT_YELLOW";
|
|
1996
|
+
COLOR2[COLOR2["BRIGHT_BLUE"] = 94] = "BRIGHT_BLUE";
|
|
1997
|
+
COLOR2[COLOR2["BRIGHT_MAGENTA"] = 95] = "BRIGHT_MAGENTA";
|
|
1998
|
+
COLOR2[COLOR2["BRIGHT_CYAN"] = 96] = "BRIGHT_CYAN";
|
|
1999
|
+
COLOR2[COLOR2["BRIGHT_WHITE"] = 97] = "BRIGHT_WHITE";
|
|
2000
|
+
})(COLOR || (COLOR = {}));
|
|
2001
|
+
BACKGROUND_INCREMENT = 10;
|
|
2002
|
+
}
|
|
2003
|
+
});
|
|
2004
|
+
|
|
2005
|
+
// ../../node_modules/@probe.gl/log/dist/utils/autobind.js
|
|
2006
|
+
function autobind(obj) {
|
|
2007
|
+
let predefined = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : ["constructor"];
|
|
2008
|
+
const proto = Object.getPrototypeOf(obj);
|
|
2009
|
+
const propNames = Object.getOwnPropertyNames(proto);
|
|
2010
|
+
const object = obj;
|
|
2011
|
+
for (const key of propNames) {
|
|
2012
|
+
const value = object[key];
|
|
2013
|
+
if (typeof value === "function") {
|
|
2014
|
+
if (!predefined.find((name) => key === name)) {
|
|
2015
|
+
object[key] = value.bind(obj);
|
|
2016
|
+
}
|
|
2017
|
+
}
|
|
2018
|
+
}
|
|
2019
|
+
}
|
|
2020
|
+
var init_autobind = __esm({
|
|
2021
|
+
"../../node_modules/@probe.gl/log/dist/utils/autobind.js"() {
|
|
2022
|
+
}
|
|
2023
|
+
});
|
|
2024
|
+
|
|
2025
|
+
// ../../node_modules/@probe.gl/log/dist/utils/assert.js
|
|
2026
|
+
function assert3(condition, message) {
|
|
2027
|
+
if (!condition) {
|
|
2028
|
+
throw new Error(message || "Assertion failed");
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
var init_assert3 = __esm({
|
|
2032
|
+
"../../node_modules/@probe.gl/log/dist/utils/assert.js"() {
|
|
2033
|
+
}
|
|
2034
|
+
});
|
|
2035
|
+
|
|
2036
|
+
// ../../node_modules/@probe.gl/log/dist/utils/hi-res-timestamp.js
|
|
2037
|
+
function getHiResTimestamp2() {
|
|
2038
|
+
let timestamp;
|
|
2039
|
+
if (isBrowser3() && window_3.performance) {
|
|
2040
|
+
var _window$performance, _window$performance$n;
|
|
2041
|
+
timestamp = window_3 === null || window_3 === void 0 ? void 0 : (_window$performance = window_3.performance) === null || _window$performance === void 0 ? void 0 : (_window$performance$n = _window$performance.now) === null || _window$performance$n === void 0 ? void 0 : _window$performance$n.call(_window$performance);
|
|
2042
|
+
} else if ("hrtime" in process_) {
|
|
2043
|
+
var _process$hrtime;
|
|
2044
|
+
const timeParts = process_ === null || process_ === void 0 ? void 0 : (_process$hrtime = process_.hrtime) === null || _process$hrtime === void 0 ? void 0 : _process$hrtime.call(process_);
|
|
2045
|
+
timestamp = timeParts[0] * 1e3 + timeParts[1] / 1e6;
|
|
2046
|
+
} else {
|
|
2047
|
+
timestamp = Date.now();
|
|
2048
|
+
}
|
|
2049
|
+
return timestamp;
|
|
2050
|
+
}
|
|
2051
|
+
var init_hi_res_timestamp2 = __esm({
|
|
2052
|
+
"../../node_modules/@probe.gl/log/dist/utils/hi-res-timestamp.js"() {
|
|
2053
|
+
init_dist2();
|
|
2054
|
+
}
|
|
2055
|
+
});
|
|
2056
|
+
|
|
2057
|
+
// ../../node_modules/@probe.gl/log/dist/log.js
|
|
2058
|
+
function noop() {
|
|
2059
|
+
}
|
|
2060
|
+
function normalizeLogLevel(logLevel) {
|
|
2061
|
+
if (!logLevel) {
|
|
2062
|
+
return 0;
|
|
2063
|
+
}
|
|
2064
|
+
let resolvedLevel;
|
|
2065
|
+
switch (typeof logLevel) {
|
|
2066
|
+
case "number":
|
|
2067
|
+
resolvedLevel = logLevel;
|
|
2068
|
+
break;
|
|
2069
|
+
case "object":
|
|
2070
|
+
resolvedLevel = logLevel.logLevel || logLevel.priority || 0;
|
|
2071
|
+
break;
|
|
2072
|
+
default:
|
|
2073
|
+
return 0;
|
|
2074
|
+
}
|
|
2075
|
+
assert3(Number.isFinite(resolvedLevel) && resolvedLevel >= 0);
|
|
2076
|
+
return resolvedLevel;
|
|
2077
|
+
}
|
|
2078
|
+
function normalizeArguments(opts) {
|
|
2079
|
+
const {
|
|
2080
|
+
logLevel,
|
|
2081
|
+
message
|
|
2082
|
+
} = opts;
|
|
2083
|
+
opts.logLevel = normalizeLogLevel(logLevel);
|
|
2084
|
+
const args = opts.args ? Array.from(opts.args) : [];
|
|
2085
|
+
while (args.length && args.shift() !== message) {
|
|
2086
|
+
}
|
|
2087
|
+
switch (typeof logLevel) {
|
|
2088
|
+
case "string":
|
|
2089
|
+
case "function":
|
|
2090
|
+
if (message !== void 0) {
|
|
2091
|
+
args.unshift(message);
|
|
2092
|
+
}
|
|
2093
|
+
opts.message = logLevel;
|
|
2094
|
+
break;
|
|
2095
|
+
case "object":
|
|
2096
|
+
Object.assign(opts, logLevel);
|
|
2097
|
+
break;
|
|
2098
|
+
default:
|
|
2099
|
+
}
|
|
2100
|
+
if (typeof opts.message === "function") {
|
|
2101
|
+
opts.message = opts.message();
|
|
2102
|
+
}
|
|
2103
|
+
const messageType = typeof opts.message;
|
|
2104
|
+
assert3(messageType === "string" || messageType === "object");
|
|
2105
|
+
return Object.assign(opts, {
|
|
2106
|
+
args
|
|
2107
|
+
}, opts.opts);
|
|
2108
|
+
}
|
|
2109
|
+
function decorateMessage(id, message, opts) {
|
|
2110
|
+
if (typeof message === "string") {
|
|
2111
|
+
const time = opts.time ? leftPad(formatTime(opts.total)) : "";
|
|
2112
|
+
message = opts.time ? "".concat(id, ": ").concat(time, " ").concat(message) : "".concat(id, ": ").concat(message);
|
|
2113
|
+
message = addColor(message, opts.color, opts.background);
|
|
2114
|
+
}
|
|
2115
|
+
return message;
|
|
2116
|
+
}
|
|
2117
|
+
function logImageInNode(_ref2) {
|
|
2118
|
+
let {
|
|
2119
|
+
image,
|
|
2120
|
+
message = "",
|
|
2121
|
+
scale = 1
|
|
2122
|
+
} = _ref2;
|
|
2123
|
+
console.warn("removed");
|
|
2124
|
+
return noop;
|
|
2125
|
+
}
|
|
2126
|
+
function logImageInBrowser(_ref3) {
|
|
2127
|
+
let {
|
|
2128
|
+
image,
|
|
2129
|
+
message = "",
|
|
2130
|
+
scale = 1
|
|
2131
|
+
} = _ref3;
|
|
2132
|
+
if (typeof image === "string") {
|
|
2133
|
+
const img = new Image();
|
|
2134
|
+
img.onload = () => {
|
|
2135
|
+
const args = formatImage(img, message, scale);
|
|
2136
|
+
console.log(...args);
|
|
2137
|
+
};
|
|
2138
|
+
img.src = image;
|
|
2139
|
+
return noop;
|
|
2140
|
+
}
|
|
2141
|
+
const element = image.nodeName || "";
|
|
2142
|
+
if (element.toLowerCase() === "img") {
|
|
2143
|
+
console.log(...formatImage(image, message, scale));
|
|
2144
|
+
return noop;
|
|
2145
|
+
}
|
|
2146
|
+
if (element.toLowerCase() === "canvas") {
|
|
2147
|
+
const img = new Image();
|
|
2148
|
+
img.onload = () => console.log(...formatImage(img, message, scale));
|
|
2149
|
+
img.src = image.toDataURL();
|
|
2150
|
+
return noop;
|
|
2151
|
+
}
|
|
2152
|
+
return noop;
|
|
2153
|
+
}
|
|
2154
|
+
function getTableHeader(table) {
|
|
2155
|
+
for (const key in table) {
|
|
2156
|
+
for (const title in table[key]) {
|
|
2157
|
+
return title || "untitled";
|
|
2158
|
+
}
|
|
2159
|
+
}
|
|
2160
|
+
return "empty";
|
|
2161
|
+
}
|
|
2162
|
+
var originalConsole, DEFAULT_LOG_CONFIGURATION, cache, ONCE, Log;
|
|
2163
|
+
var init_log = __esm({
|
|
2164
|
+
"../../node_modules/@probe.gl/log/dist/log.js"() {
|
|
2165
|
+
init_defineProperty();
|
|
2166
|
+
init_dist2();
|
|
2167
|
+
init_local_storage();
|
|
2168
|
+
init_formatters();
|
|
2169
|
+
init_color();
|
|
2170
|
+
init_autobind();
|
|
2171
|
+
init_assert3();
|
|
2172
|
+
init_hi_res_timestamp2();
|
|
2173
|
+
originalConsole = {
|
|
2174
|
+
debug: isBrowser3() ? console.debug || console.log : console.log,
|
|
2175
|
+
log: console.log,
|
|
2176
|
+
info: console.info,
|
|
2177
|
+
warn: console.warn,
|
|
2178
|
+
error: console.error
|
|
2179
|
+
};
|
|
2180
|
+
DEFAULT_LOG_CONFIGURATION = {
|
|
2181
|
+
enabled: true,
|
|
2182
|
+
level: 0
|
|
2183
|
+
};
|
|
2184
|
+
cache = {};
|
|
2185
|
+
ONCE = {
|
|
2186
|
+
once: true
|
|
2187
|
+
};
|
|
2188
|
+
Log = class {
|
|
2189
|
+
constructor() {
|
|
2190
|
+
let {
|
|
2191
|
+
id
|
|
2192
|
+
} = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
|
|
2193
|
+
id: ""
|
|
2194
|
+
};
|
|
2195
|
+
_defineProperty(this, "id", void 0);
|
|
2196
|
+
_defineProperty(this, "VERSION", VERSION4);
|
|
2197
|
+
_defineProperty(this, "_startTs", getHiResTimestamp2());
|
|
2198
|
+
_defineProperty(this, "_deltaTs", getHiResTimestamp2());
|
|
2199
|
+
_defineProperty(this, "_storage", void 0);
|
|
2200
|
+
_defineProperty(this, "userData", {});
|
|
2201
|
+
_defineProperty(this, "LOG_THROTTLE_TIMEOUT", 0);
|
|
2202
|
+
this.id = id;
|
|
2203
|
+
this.userData = {};
|
|
2204
|
+
this._storage = new LocalStorage("__probe-".concat(this.id, "__"), DEFAULT_LOG_CONFIGURATION);
|
|
2205
|
+
this.timeStamp("".concat(this.id, " started"));
|
|
2206
|
+
autobind(this);
|
|
2207
|
+
Object.seal(this);
|
|
2208
|
+
}
|
|
2209
|
+
set level(newLevel) {
|
|
2210
|
+
this.setLevel(newLevel);
|
|
2211
|
+
}
|
|
2212
|
+
get level() {
|
|
2213
|
+
return this.getLevel();
|
|
2214
|
+
}
|
|
2215
|
+
isEnabled() {
|
|
2216
|
+
return this._storage.config.enabled;
|
|
2217
|
+
}
|
|
2218
|
+
getLevel() {
|
|
2219
|
+
return this._storage.config.level;
|
|
2220
|
+
}
|
|
2221
|
+
getTotal() {
|
|
2222
|
+
return Number((getHiResTimestamp2() - this._startTs).toPrecision(10));
|
|
2223
|
+
}
|
|
2224
|
+
getDelta() {
|
|
2225
|
+
return Number((getHiResTimestamp2() - this._deltaTs).toPrecision(10));
|
|
2226
|
+
}
|
|
2227
|
+
set priority(newPriority) {
|
|
2228
|
+
this.level = newPriority;
|
|
2229
|
+
}
|
|
2230
|
+
get priority() {
|
|
2231
|
+
return this.level;
|
|
2232
|
+
}
|
|
2233
|
+
getPriority() {
|
|
2234
|
+
return this.level;
|
|
2235
|
+
}
|
|
2236
|
+
enable() {
|
|
2237
|
+
let enabled = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
|
|
2238
|
+
this._storage.setConfiguration({
|
|
2239
|
+
enabled
|
|
2240
|
+
});
|
|
2241
|
+
return this;
|
|
2242
|
+
}
|
|
2243
|
+
setLevel(level) {
|
|
2244
|
+
this._storage.setConfiguration({
|
|
2245
|
+
level
|
|
2246
|
+
});
|
|
2247
|
+
return this;
|
|
2248
|
+
}
|
|
2249
|
+
get(setting) {
|
|
2250
|
+
return this._storage.config[setting];
|
|
2251
|
+
}
|
|
2252
|
+
set(setting, value) {
|
|
2253
|
+
this._storage.setConfiguration({
|
|
2254
|
+
[setting]: value
|
|
2255
|
+
});
|
|
2256
|
+
}
|
|
2257
|
+
settings() {
|
|
2258
|
+
if (console.table) {
|
|
2259
|
+
console.table(this._storage.config);
|
|
2260
|
+
} else {
|
|
2261
|
+
console.log(this._storage.config);
|
|
2262
|
+
}
|
|
2263
|
+
}
|
|
2264
|
+
assert(condition, message) {
|
|
2265
|
+
assert3(condition, message);
|
|
2266
|
+
}
|
|
2267
|
+
warn(message) {
|
|
2268
|
+
return this._getLogFunction(0, message, originalConsole.warn, arguments, ONCE);
|
|
2269
|
+
}
|
|
2270
|
+
error(message) {
|
|
2271
|
+
return this._getLogFunction(0, message, originalConsole.error, arguments);
|
|
2272
|
+
}
|
|
2273
|
+
deprecated(oldUsage, newUsage) {
|
|
2274
|
+
return this.warn("`".concat(oldUsage, "` is deprecated and will be removed in a later version. Use `").concat(newUsage, "` instead"));
|
|
2275
|
+
}
|
|
2276
|
+
removed(oldUsage, newUsage) {
|
|
2277
|
+
return this.error("`".concat(oldUsage, "` has been removed. Use `").concat(newUsage, "` instead"));
|
|
2278
|
+
}
|
|
2279
|
+
probe(logLevel, message) {
|
|
2280
|
+
return this._getLogFunction(logLevel, message, originalConsole.log, arguments, {
|
|
2281
|
+
time: true,
|
|
2282
|
+
once: true
|
|
2283
|
+
});
|
|
2284
|
+
}
|
|
2285
|
+
log(logLevel, message) {
|
|
2286
|
+
return this._getLogFunction(logLevel, message, originalConsole.debug, arguments);
|
|
2287
|
+
}
|
|
2288
|
+
info(logLevel, message) {
|
|
2289
|
+
return this._getLogFunction(logLevel, message, console.info, arguments);
|
|
2290
|
+
}
|
|
2291
|
+
once(logLevel, message) {
|
|
2292
|
+
return this._getLogFunction(logLevel, message, originalConsole.debug || originalConsole.info, arguments, ONCE);
|
|
2293
|
+
}
|
|
2294
|
+
table(logLevel, table, columns) {
|
|
2295
|
+
if (table) {
|
|
2296
|
+
return this._getLogFunction(logLevel, table, console.table || noop, columns && [columns], {
|
|
2297
|
+
tag: getTableHeader(table)
|
|
2298
|
+
});
|
|
2299
|
+
}
|
|
2300
|
+
return noop;
|
|
2301
|
+
}
|
|
2302
|
+
image(_ref) {
|
|
2303
|
+
let {
|
|
2304
|
+
logLevel,
|
|
2305
|
+
priority,
|
|
2306
|
+
image,
|
|
2307
|
+
message = "",
|
|
2308
|
+
scale = 1
|
|
2309
|
+
} = _ref;
|
|
2310
|
+
if (!this._shouldLog(logLevel || priority)) {
|
|
2311
|
+
return noop;
|
|
2312
|
+
}
|
|
2313
|
+
return isBrowser3() ? logImageInBrowser({
|
|
2314
|
+
image,
|
|
2315
|
+
message,
|
|
2316
|
+
scale
|
|
2317
|
+
}) : logImageInNode({
|
|
2318
|
+
image,
|
|
2319
|
+
message,
|
|
2320
|
+
scale
|
|
2321
|
+
});
|
|
2322
|
+
}
|
|
2323
|
+
time(logLevel, message) {
|
|
2324
|
+
return this._getLogFunction(logLevel, message, console.time ? console.time : console.info);
|
|
2325
|
+
}
|
|
2326
|
+
timeEnd(logLevel, message) {
|
|
2327
|
+
return this._getLogFunction(logLevel, message, console.timeEnd ? console.timeEnd : console.info);
|
|
2328
|
+
}
|
|
2329
|
+
timeStamp(logLevel, message) {
|
|
2330
|
+
return this._getLogFunction(logLevel, message, console.timeStamp || noop);
|
|
2331
|
+
}
|
|
2332
|
+
group(logLevel, message) {
|
|
2333
|
+
let opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {
|
|
2334
|
+
collapsed: false
|
|
2335
|
+
};
|
|
2336
|
+
const options = normalizeArguments({
|
|
2337
|
+
logLevel,
|
|
2338
|
+
message,
|
|
2339
|
+
opts
|
|
2340
|
+
});
|
|
2341
|
+
const {
|
|
2342
|
+
collapsed
|
|
2343
|
+
} = opts;
|
|
2344
|
+
options.method = (collapsed ? console.groupCollapsed : console.group) || console.info;
|
|
2345
|
+
return this._getLogFunction(options);
|
|
2346
|
+
}
|
|
2347
|
+
groupCollapsed(logLevel, message) {
|
|
2348
|
+
let opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
2349
|
+
return this.group(logLevel, message, Object.assign({}, opts, {
|
|
2350
|
+
collapsed: true
|
|
2351
|
+
}));
|
|
2352
|
+
}
|
|
2353
|
+
groupEnd(logLevel) {
|
|
2354
|
+
return this._getLogFunction(logLevel, "", console.groupEnd || noop);
|
|
2355
|
+
}
|
|
2356
|
+
withGroup(logLevel, message, func) {
|
|
2357
|
+
this.group(logLevel, message)();
|
|
2358
|
+
try {
|
|
2359
|
+
func();
|
|
2360
|
+
} finally {
|
|
2361
|
+
this.groupEnd(logLevel)();
|
|
2362
|
+
}
|
|
2363
|
+
}
|
|
2364
|
+
trace() {
|
|
2365
|
+
if (console.trace) {
|
|
2366
|
+
console.trace();
|
|
2367
|
+
}
|
|
2368
|
+
}
|
|
2369
|
+
_shouldLog(logLevel) {
|
|
2370
|
+
return this.isEnabled() && this.getLevel() >= normalizeLogLevel(logLevel);
|
|
2371
|
+
}
|
|
2372
|
+
_getLogFunction(logLevel, message, method, args, opts) {
|
|
2373
|
+
if (this._shouldLog(logLevel)) {
|
|
2374
|
+
opts = normalizeArguments({
|
|
2375
|
+
logLevel,
|
|
2376
|
+
message,
|
|
2377
|
+
args,
|
|
2378
|
+
opts
|
|
2379
|
+
});
|
|
2380
|
+
method = method || opts.method;
|
|
2381
|
+
assert3(method);
|
|
2382
|
+
opts.total = this.getTotal();
|
|
2383
|
+
opts.delta = this.getDelta();
|
|
2384
|
+
this._deltaTs = getHiResTimestamp2();
|
|
2385
|
+
const tag = opts.tag || opts.message;
|
|
2386
|
+
if (opts.once && tag) {
|
|
2387
|
+
if (!cache[tag]) {
|
|
2388
|
+
cache[tag] = getHiResTimestamp2();
|
|
2389
|
+
} else {
|
|
2390
|
+
return noop;
|
|
2391
|
+
}
|
|
2392
|
+
}
|
|
2393
|
+
message = decorateMessage(this.id, opts.message, opts);
|
|
2394
|
+
return method.bind(console, message, ...opts.args);
|
|
2395
|
+
}
|
|
2396
|
+
return noop;
|
|
2397
|
+
}
|
|
2398
|
+
};
|
|
2399
|
+
_defineProperty(Log, "VERSION", VERSION4);
|
|
2400
|
+
}
|
|
2401
|
+
});
|
|
2402
|
+
|
|
2403
|
+
// ../../node_modules/@probe.gl/log/dist/index.js
|
|
2404
|
+
var dist_default;
|
|
2405
|
+
var init_dist3 = __esm({
|
|
2406
|
+
"../../node_modules/@probe.gl/log/dist/index.js"() {
|
|
2407
|
+
init_log();
|
|
2408
|
+
init_log();
|
|
2409
|
+
dist_default = new Log({
|
|
2410
|
+
id: "@probe.gl/log"
|
|
2411
|
+
});
|
|
2412
|
+
}
|
|
2413
|
+
});
|
|
2414
|
+
|
|
2415
|
+
// src/lib/loader-utils/loggers.ts
|
|
2416
|
+
var probeLog, NullLog, ConsoleLog;
|
|
2417
|
+
var init_loggers = __esm({
|
|
2418
|
+
"src/lib/loader-utils/loggers.ts"() {
|
|
2419
|
+
init_dist3();
|
|
2420
|
+
probeLog = new Log({ id: "loaders.gl" });
|
|
2421
|
+
NullLog = class {
|
|
2422
|
+
log() {
|
|
2423
|
+
return () => {
|
|
2424
|
+
};
|
|
2425
|
+
}
|
|
2426
|
+
info() {
|
|
2427
|
+
return () => {
|
|
2428
|
+
};
|
|
2429
|
+
}
|
|
2430
|
+
warn() {
|
|
2431
|
+
return () => {
|
|
2432
|
+
};
|
|
2433
|
+
}
|
|
2434
|
+
error() {
|
|
2435
|
+
return () => {
|
|
2436
|
+
};
|
|
2437
|
+
}
|
|
2438
|
+
};
|
|
2439
|
+
ConsoleLog = class {
|
|
2440
|
+
constructor() {
|
|
2441
|
+
this.console = console;
|
|
2442
|
+
}
|
|
2443
|
+
log(...args) {
|
|
2444
|
+
return this.console.log.bind(this.console, ...args);
|
|
2445
|
+
}
|
|
2446
|
+
info(...args) {
|
|
2447
|
+
return this.console.info.bind(this.console, ...args);
|
|
2448
|
+
}
|
|
2449
|
+
warn(...args) {
|
|
2450
|
+
return this.console.warn.bind(this.console, ...args);
|
|
2451
|
+
}
|
|
2452
|
+
error(...args) {
|
|
2453
|
+
return this.console.error.bind(this.console, ...args);
|
|
2454
|
+
}
|
|
2455
|
+
};
|
|
2456
|
+
}
|
|
2457
|
+
});
|
|
2458
|
+
|
|
2459
|
+
// src/lib/loader-utils/option-defaults.ts
|
|
2460
|
+
var DEFAULT_LOADER_OPTIONS, REMOVED_LOADER_OPTIONS;
|
|
2461
|
+
var init_option_defaults = __esm({
|
|
2462
|
+
"src/lib/loader-utils/option-defaults.ts"() {
|
|
2463
|
+
init_src2();
|
|
2464
|
+
init_loggers();
|
|
2465
|
+
DEFAULT_LOADER_OPTIONS = {
|
|
2466
|
+
fetch: null,
|
|
2467
|
+
mimeType: void 0,
|
|
2468
|
+
nothrow: false,
|
|
2469
|
+
log: new ConsoleLog(),
|
|
2470
|
+
CDN: "https://unpkg.com/@loaders.gl",
|
|
2471
|
+
worker: true,
|
|
2472
|
+
maxConcurrency: 3,
|
|
2473
|
+
maxMobileConcurrency: 1,
|
|
2474
|
+
reuseWorkers: isBrowser,
|
|
2475
|
+
_nodeWorkers: false,
|
|
2476
|
+
_workerType: "",
|
|
2477
|
+
limit: 0,
|
|
2478
|
+
_limitMB: 0,
|
|
2479
|
+
batchSize: "auto",
|
|
2480
|
+
batchDebounceMs: 0,
|
|
2481
|
+
metadata: false,
|
|
2482
|
+
transforms: []
|
|
2483
|
+
};
|
|
2484
|
+
REMOVED_LOADER_OPTIONS = {
|
|
2485
|
+
throws: "nothrow",
|
|
2486
|
+
dataType: "(no longer used)",
|
|
2487
|
+
uri: "baseUri",
|
|
2488
|
+
method: "fetch.method",
|
|
2489
|
+
headers: "fetch.headers",
|
|
2490
|
+
body: "fetch.body",
|
|
2491
|
+
mode: "fetch.mode",
|
|
2492
|
+
credentials: "fetch.credentials",
|
|
2493
|
+
cache: "fetch.cache",
|
|
2494
|
+
redirect: "fetch.redirect",
|
|
2495
|
+
referrer: "fetch.referrer",
|
|
2496
|
+
referrerPolicy: "fetch.referrerPolicy",
|
|
2497
|
+
integrity: "fetch.integrity",
|
|
2498
|
+
keepalive: "fetch.keepalive",
|
|
2499
|
+
signal: "fetch.signal"
|
|
2500
|
+
};
|
|
2501
|
+
}
|
|
2502
|
+
});
|
|
2503
|
+
|
|
2504
|
+
// src/lib/loader-utils/option-utils.ts
|
|
2505
|
+
function getGlobalLoaderState() {
|
|
2506
|
+
globalThis.loaders = globalThis.loaders || {};
|
|
2507
|
+
const { loaders } = globalThis;
|
|
2508
|
+
loaders._state = loaders._state || {};
|
|
2509
|
+
return loaders._state;
|
|
2510
|
+
}
|
|
2511
|
+
function setGlobalOptions(options) {
|
|
2512
|
+
const state = getGlobalLoaderState();
|
|
2513
|
+
const globalOptions = getGlobalLoaderOptions();
|
|
2514
|
+
state.globalOptions = normalizeOptionsInternal(globalOptions, options);
|
|
2515
|
+
}
|
|
2516
|
+
function normalizeOptions(options, loader, loaders, url) {
|
|
2517
|
+
loaders = loaders || [];
|
|
2518
|
+
loaders = Array.isArray(loaders) ? loaders : [loaders];
|
|
2519
|
+
validateOptions(options, loaders);
|
|
2520
|
+
return normalizeOptionsInternal(loader, options, url);
|
|
2521
|
+
}
|
|
2522
|
+
function validateOptions(options, loaders) {
|
|
2523
|
+
validateOptionsObject(options, null, DEFAULT_LOADER_OPTIONS, REMOVED_LOADER_OPTIONS, loaders);
|
|
2524
|
+
for (const loader of loaders) {
|
|
2525
|
+
const idOptions = options && options[loader.id] || {};
|
|
2526
|
+
const loaderOptions = loader.options && loader.options[loader.id] || {};
|
|
2527
|
+
const deprecatedOptions = loader.deprecatedOptions && loader.deprecatedOptions[loader.id] || {};
|
|
2528
|
+
validateOptionsObject(idOptions, loader.id, loaderOptions, deprecatedOptions, loaders);
|
|
2529
|
+
}
|
|
2530
|
+
}
|
|
2531
|
+
function validateOptionsObject(options, id, defaultOptions, deprecatedOptions, loaders) {
|
|
2532
|
+
const loaderName = id || "Top level";
|
|
2533
|
+
const prefix = id ? `${id}.` : "";
|
|
2534
|
+
for (const key in options) {
|
|
2535
|
+
const isSubOptions = !id && isObject(options[key]);
|
|
2536
|
+
const isBaseUriOption = key === "baseUri" && !id;
|
|
2537
|
+
const isWorkerUrlOption = key === "workerUrl" && id;
|
|
2538
|
+
if (!(key in defaultOptions) && !isBaseUriOption && !isWorkerUrlOption) {
|
|
2539
|
+
if (key in deprecatedOptions) {
|
|
2540
|
+
probeLog.warn(`${loaderName} loader option '${prefix}${key}' no longer supported, use '${deprecatedOptions[key]}'`)();
|
|
2541
|
+
} else if (!isSubOptions) {
|
|
2542
|
+
const suggestion = findSimilarOption(key, loaders);
|
|
2543
|
+
probeLog.warn(`${loaderName} loader option '${prefix}${key}' not recognized. ${suggestion}`)();
|
|
2544
|
+
}
|
|
2545
|
+
}
|
|
2546
|
+
}
|
|
2547
|
+
}
|
|
2548
|
+
function findSimilarOption(optionKey, loaders) {
|
|
2549
|
+
const lowerCaseOptionKey = optionKey.toLowerCase();
|
|
2550
|
+
let bestSuggestion = "";
|
|
2551
|
+
for (const loader of loaders) {
|
|
2552
|
+
for (const key in loader.options) {
|
|
2553
|
+
if (optionKey === key) {
|
|
2554
|
+
return `Did you mean '${loader.id}.${key}'?`;
|
|
2555
|
+
}
|
|
2556
|
+
const lowerCaseKey = key.toLowerCase();
|
|
2557
|
+
const isPartialMatch = lowerCaseOptionKey.startsWith(lowerCaseKey) || lowerCaseKey.startsWith(lowerCaseOptionKey);
|
|
2558
|
+
if (isPartialMatch) {
|
|
2559
|
+
bestSuggestion = bestSuggestion || `Did you mean '${loader.id}.${key}'?`;
|
|
2560
|
+
}
|
|
2561
|
+
}
|
|
2562
|
+
}
|
|
2563
|
+
return bestSuggestion;
|
|
2564
|
+
}
|
|
2565
|
+
function normalizeOptionsInternal(loader, options, url) {
|
|
2566
|
+
const loaderDefaultOptions = loader.options || {};
|
|
2567
|
+
const mergedOptions = { ...loaderDefaultOptions };
|
|
2568
|
+
addUrlOptions(mergedOptions, url);
|
|
2569
|
+
if (mergedOptions.log === null) {
|
|
2570
|
+
mergedOptions.log = new NullLog();
|
|
2571
|
+
}
|
|
2572
|
+
mergeNestedFields(mergedOptions, getGlobalLoaderOptions());
|
|
2573
|
+
mergeNestedFields(mergedOptions, options);
|
|
2574
|
+
return mergedOptions;
|
|
2575
|
+
}
|
|
2576
|
+
function mergeNestedFields(mergedOptions, options) {
|
|
2577
|
+
for (const key in options) {
|
|
2578
|
+
if (key in options) {
|
|
2579
|
+
const value = options[key];
|
|
2580
|
+
if (isPureObject(value) && isPureObject(mergedOptions[key])) {
|
|
2581
|
+
mergedOptions[key] = {
|
|
2582
|
+
...mergedOptions[key],
|
|
2583
|
+
...options[key]
|
|
2584
|
+
};
|
|
2585
|
+
} else {
|
|
2586
|
+
mergedOptions[key] = options[key];
|
|
2587
|
+
}
|
|
2588
|
+
}
|
|
2589
|
+
}
|
|
2590
|
+
}
|
|
2591
|
+
function addUrlOptions(options, url) {
|
|
2592
|
+
if (url && !("baseUri" in options)) {
|
|
2593
|
+
options.baseUri = url;
|
|
2594
|
+
}
|
|
2595
|
+
}
|
|
2596
|
+
var getGlobalLoaderOptions;
|
|
2597
|
+
var init_option_utils = __esm({
|
|
2598
|
+
"src/lib/loader-utils/option-utils.ts"() {
|
|
2599
|
+
init_is_type();
|
|
2600
|
+
init_loggers();
|
|
2601
|
+
init_option_defaults();
|
|
2602
|
+
getGlobalLoaderOptions = () => {
|
|
2603
|
+
const state = getGlobalLoaderState();
|
|
2604
|
+
state.globalOptions = state.globalOptions || { ...DEFAULT_LOADER_OPTIONS };
|
|
2605
|
+
return state.globalOptions;
|
|
2606
|
+
};
|
|
2607
|
+
}
|
|
2608
|
+
});
|
|
2609
|
+
|
|
2610
|
+
// src/lib/api/loader-options.ts
|
|
2611
|
+
var init_loader_options = __esm({
|
|
2612
|
+
"src/lib/api/loader-options.ts"() {
|
|
2613
|
+
init_option_utils();
|
|
2614
|
+
init_option_utils();
|
|
2615
|
+
}
|
|
2616
|
+
});
|
|
2617
|
+
|
|
2618
|
+
// src/lib/loader-utils/normalize-loader.ts
|
|
2619
|
+
function isLoaderObject(loader) {
|
|
2620
|
+
if (!loader) {
|
|
2621
|
+
return false;
|
|
2622
|
+
}
|
|
2623
|
+
if (Array.isArray(loader)) {
|
|
2624
|
+
loader = loader[0];
|
|
2625
|
+
}
|
|
2626
|
+
const hasExtensions = Array.isArray(loader?.extensions);
|
|
2627
|
+
return hasExtensions;
|
|
2628
|
+
}
|
|
2629
|
+
function normalizeLoader(loader) {
|
|
2630
|
+
assert(loader, "null loader");
|
|
2631
|
+
assert(isLoaderObject(loader), "invalid loader");
|
|
2632
|
+
let options;
|
|
2633
|
+
if (Array.isArray(loader)) {
|
|
2634
|
+
options = loader[1];
|
|
2635
|
+
loader = loader[0];
|
|
2636
|
+
loader = {
|
|
2637
|
+
...loader,
|
|
2638
|
+
options: { ...loader.options, ...options }
|
|
2639
|
+
};
|
|
2640
|
+
}
|
|
2641
|
+
if (loader?.parseTextSync || loader?.parseText) {
|
|
2642
|
+
loader.text = true;
|
|
2643
|
+
}
|
|
2644
|
+
if (!loader.text) {
|
|
2645
|
+
loader.binary = true;
|
|
2646
|
+
}
|
|
2647
|
+
return loader;
|
|
2648
|
+
}
|
|
2649
|
+
var init_normalize_loader = __esm({
|
|
2650
|
+
"src/lib/loader-utils/normalize-loader.ts"() {
|
|
2651
|
+
init_src2();
|
|
2652
|
+
}
|
|
2653
|
+
});
|
|
2654
|
+
|
|
2655
|
+
// src/lib/api/register-loaders.ts
|
|
2656
|
+
function registerLoaders(loaders) {
|
|
2657
|
+
const loaderRegistry = getGlobalLoaderRegistry();
|
|
2658
|
+
loaders = Array.isArray(loaders) ? loaders : [loaders];
|
|
2659
|
+
for (const loader of loaders) {
|
|
2660
|
+
const normalizedLoader = normalizeLoader(loader);
|
|
2661
|
+
if (!loaderRegistry.find((registeredLoader) => normalizedLoader === registeredLoader)) {
|
|
2662
|
+
loaderRegistry.unshift(normalizedLoader);
|
|
2663
|
+
}
|
|
2664
|
+
}
|
|
2665
|
+
}
|
|
2666
|
+
function getRegisteredLoaders() {
|
|
2667
|
+
return getGlobalLoaderRegistry();
|
|
2668
|
+
}
|
|
2669
|
+
function _unregisterLoaders() {
|
|
2670
|
+
const state = getGlobalLoaderState();
|
|
2671
|
+
state.loaderRegistry = [];
|
|
2672
|
+
}
|
|
2673
|
+
var getGlobalLoaderRegistry;
|
|
2674
|
+
var init_register_loaders = __esm({
|
|
2675
|
+
"src/lib/api/register-loaders.ts"() {
|
|
2676
|
+
init_normalize_loader();
|
|
2677
|
+
init_option_utils();
|
|
2678
|
+
getGlobalLoaderRegistry = () => {
|
|
2679
|
+
const state = getGlobalLoaderState();
|
|
2680
|
+
state.loaderRegistry = state.loaderRegistry || [];
|
|
2681
|
+
return state.loaderRegistry;
|
|
2682
|
+
};
|
|
2683
|
+
}
|
|
2684
|
+
});
|
|
2685
|
+
|
|
2686
|
+
// src/lib/utils/log.ts
|
|
2687
|
+
var log;
|
|
2688
|
+
var init_log2 = __esm({
|
|
2689
|
+
"src/lib/utils/log.ts"() {
|
|
2690
|
+
init_dist3();
|
|
2691
|
+
log = new Log({ id: "loaders.gl" });
|
|
2692
|
+
}
|
|
2693
|
+
});
|
|
2694
|
+
|
|
2695
|
+
// src/lib/api/select-loader.ts
|
|
2696
|
+
async function selectLoader(data, loaders = [], options, context) {
|
|
2697
|
+
if (!validHTTPResponse(data)) {
|
|
2698
|
+
return null;
|
|
2699
|
+
}
|
|
2700
|
+
let loader = selectLoaderSync(data, loaders, { ...options, nothrow: true }, context);
|
|
2701
|
+
if (loader) {
|
|
2702
|
+
return loader;
|
|
2703
|
+
}
|
|
2704
|
+
if (isBlob(data)) {
|
|
2705
|
+
data = await data.slice(0, 10).arrayBuffer();
|
|
2706
|
+
loader = selectLoaderSync(data, loaders, options, context);
|
|
2707
|
+
}
|
|
2708
|
+
if (!loader && !options?.nothrow) {
|
|
2709
|
+
throw new Error(getNoValidLoaderMessage(data));
|
|
2710
|
+
}
|
|
2711
|
+
return loader;
|
|
2712
|
+
}
|
|
2713
|
+
function selectLoaderSync(data, loaders = [], options, context) {
|
|
2714
|
+
if (!validHTTPResponse(data)) {
|
|
2715
|
+
return null;
|
|
2716
|
+
}
|
|
2717
|
+
if (loaders && !Array.isArray(loaders)) {
|
|
2718
|
+
return normalizeLoader(loaders);
|
|
2719
|
+
}
|
|
2720
|
+
let candidateLoaders = [];
|
|
2721
|
+
if (loaders) {
|
|
2722
|
+
candidateLoaders = candidateLoaders.concat(loaders);
|
|
2723
|
+
}
|
|
2724
|
+
if (!options?.ignoreRegisteredLoaders) {
|
|
2725
|
+
candidateLoaders.push(...getRegisteredLoaders());
|
|
2726
|
+
}
|
|
2727
|
+
normalizeLoaders(candidateLoaders);
|
|
2728
|
+
const loader = selectLoaderInternal(data, candidateLoaders, options, context);
|
|
2729
|
+
if (!loader && !options?.nothrow) {
|
|
2730
|
+
throw new Error(getNoValidLoaderMessage(data));
|
|
2731
|
+
}
|
|
2732
|
+
return loader;
|
|
2733
|
+
}
|
|
2734
|
+
function selectLoaderInternal(data, loaders, options, context) {
|
|
2735
|
+
const { url, type } = getResourceUrlAndType(data);
|
|
2736
|
+
const testUrl = url || context?.url;
|
|
2737
|
+
let loader = null;
|
|
2738
|
+
let reason = "";
|
|
2739
|
+
if (options?.mimeType) {
|
|
2740
|
+
loader = findLoaderByMIMEType(loaders, options?.mimeType);
|
|
2741
|
+
reason = `match forced by supplied MIME type ${options?.mimeType}`;
|
|
2742
|
+
}
|
|
2743
|
+
loader = loader || findLoaderByUrl(loaders, testUrl);
|
|
2744
|
+
reason = reason || (loader ? `matched url ${testUrl}` : "");
|
|
2745
|
+
loader = loader || findLoaderByMIMEType(loaders, type);
|
|
2746
|
+
reason = reason || (loader ? `matched MIME type ${type}` : "");
|
|
2747
|
+
loader = loader || findLoaderByInitialBytes(loaders, data);
|
|
2748
|
+
reason = reason || (loader ? `matched initial data ${getFirstCharacters(data)}` : "");
|
|
2749
|
+
loader = loader || findLoaderByMIMEType(loaders, options?.fallbackMimeType);
|
|
2750
|
+
reason = reason || (loader ? `matched fallback MIME type ${type}` : "");
|
|
2751
|
+
if (reason) {
|
|
2752
|
+
log.log(1, `selectLoader selected ${loader?.name}: ${reason}.`);
|
|
2753
|
+
}
|
|
2754
|
+
return loader;
|
|
2755
|
+
}
|
|
2756
|
+
function validHTTPResponse(data) {
|
|
2757
|
+
if (data instanceof Response) {
|
|
2758
|
+
if (data.status === 204) {
|
|
2759
|
+
return false;
|
|
2760
|
+
}
|
|
2761
|
+
}
|
|
2762
|
+
return true;
|
|
2763
|
+
}
|
|
2764
|
+
function getNoValidLoaderMessage(data) {
|
|
2765
|
+
const { url, type } = getResourceUrlAndType(data);
|
|
2766
|
+
let message = "No valid loader found (";
|
|
2767
|
+
message += url ? `${path_exports.filename(url)}, ` : "no url provided, ";
|
|
2768
|
+
message += `MIME type: ${type ? `"${type}"` : "not provided"}, `;
|
|
2769
|
+
const firstCharacters = data ? getFirstCharacters(data) : "";
|
|
2770
|
+
message += firstCharacters ? ` first bytes: "${firstCharacters}"` : "first bytes: not available";
|
|
2771
|
+
message += ")";
|
|
2772
|
+
return message;
|
|
2773
|
+
}
|
|
2774
|
+
function normalizeLoaders(loaders) {
|
|
2775
|
+
for (const loader of loaders) {
|
|
2776
|
+
normalizeLoader(loader);
|
|
2777
|
+
}
|
|
2778
|
+
}
|
|
2779
|
+
function findLoaderByUrl(loaders, url) {
|
|
2780
|
+
const match = url && EXT_PATTERN.exec(url);
|
|
2781
|
+
const extension = match && match[1];
|
|
2782
|
+
return extension ? findLoaderByExtension(loaders, extension) : null;
|
|
2783
|
+
}
|
|
2784
|
+
function findLoaderByExtension(loaders, extension) {
|
|
2785
|
+
extension = extension.toLowerCase();
|
|
2786
|
+
for (const loader of loaders) {
|
|
2787
|
+
for (const loaderExtension of loader.extensions) {
|
|
2788
|
+
if (loaderExtension.toLowerCase() === extension) {
|
|
2789
|
+
return loader;
|
|
2790
|
+
}
|
|
2791
|
+
}
|
|
2792
|
+
}
|
|
2793
|
+
return null;
|
|
2794
|
+
}
|
|
2795
|
+
function findLoaderByMIMEType(loaders, mimeType) {
|
|
2796
|
+
for (const loader of loaders) {
|
|
2797
|
+
if (loader.mimeTypes && loader.mimeTypes.includes(mimeType)) {
|
|
2798
|
+
return loader;
|
|
2799
|
+
}
|
|
2800
|
+
if (mimeType === `application/x.${loader.id}`) {
|
|
2801
|
+
return loader;
|
|
2802
|
+
}
|
|
2803
|
+
}
|
|
2804
|
+
return null;
|
|
2805
|
+
}
|
|
2806
|
+
function findLoaderByInitialBytes(loaders, data) {
|
|
2807
|
+
if (!data) {
|
|
2808
|
+
return null;
|
|
2809
|
+
}
|
|
2810
|
+
for (const loader of loaders) {
|
|
2811
|
+
if (typeof data === "string") {
|
|
2812
|
+
if (testDataAgainstText(data, loader)) {
|
|
2813
|
+
return loader;
|
|
2814
|
+
}
|
|
2815
|
+
} else if (ArrayBuffer.isView(data)) {
|
|
2816
|
+
if (testDataAgainstBinary(data.buffer, data.byteOffset, loader)) {
|
|
2817
|
+
return loader;
|
|
2818
|
+
}
|
|
2819
|
+
} else if (data instanceof ArrayBuffer) {
|
|
2820
|
+
const byteOffset = 0;
|
|
2821
|
+
if (testDataAgainstBinary(data, byteOffset, loader)) {
|
|
2822
|
+
return loader;
|
|
2823
|
+
}
|
|
2824
|
+
}
|
|
2825
|
+
}
|
|
2826
|
+
return null;
|
|
2827
|
+
}
|
|
2828
|
+
function testDataAgainstText(data, loader) {
|
|
2829
|
+
if (loader.testText) {
|
|
2830
|
+
return loader.testText(data);
|
|
2831
|
+
}
|
|
2832
|
+
const tests = Array.isArray(loader.tests) ? loader.tests : [loader.tests];
|
|
2833
|
+
return tests.some((test) => data.startsWith(test));
|
|
2834
|
+
}
|
|
2835
|
+
function testDataAgainstBinary(data, byteOffset, loader) {
|
|
2836
|
+
const tests = Array.isArray(loader.tests) ? loader.tests : [loader.tests];
|
|
2837
|
+
return tests.some((test) => testBinary(data, byteOffset, loader, test));
|
|
2838
|
+
}
|
|
2839
|
+
function testBinary(data, byteOffset, loader, test) {
|
|
2840
|
+
if (test instanceof ArrayBuffer) {
|
|
2841
|
+
return compareArrayBuffers(test, data, test.byteLength);
|
|
2842
|
+
}
|
|
2843
|
+
switch (typeof test) {
|
|
2844
|
+
case "function":
|
|
2845
|
+
return test(data, loader);
|
|
2846
|
+
case "string":
|
|
2847
|
+
const magic = getMagicString(data, byteOffset, test.length);
|
|
2848
|
+
return test === magic;
|
|
2849
|
+
default:
|
|
2850
|
+
return false;
|
|
2851
|
+
}
|
|
2852
|
+
}
|
|
2853
|
+
function getFirstCharacters(data, length = 5) {
|
|
2854
|
+
if (typeof data === "string") {
|
|
2855
|
+
return data.slice(0, length);
|
|
2856
|
+
} else if (ArrayBuffer.isView(data)) {
|
|
2857
|
+
return getMagicString(data.buffer, data.byteOffset, length);
|
|
2858
|
+
} else if (data instanceof ArrayBuffer) {
|
|
2859
|
+
const byteOffset = 0;
|
|
2860
|
+
return getMagicString(data, byteOffset, length);
|
|
2861
|
+
}
|
|
2862
|
+
return "";
|
|
2863
|
+
}
|
|
2864
|
+
function getMagicString(arrayBuffer, byteOffset, length) {
|
|
2865
|
+
if (arrayBuffer.byteLength < byteOffset + length) {
|
|
2866
|
+
return "";
|
|
2867
|
+
}
|
|
2868
|
+
const dataView = new DataView(arrayBuffer);
|
|
2869
|
+
let magic = "";
|
|
2870
|
+
for (let i = 0; i < length; i++) {
|
|
2871
|
+
magic += String.fromCharCode(dataView.getUint8(byteOffset + i));
|
|
2872
|
+
}
|
|
2873
|
+
return magic;
|
|
2874
|
+
}
|
|
2875
|
+
var EXT_PATTERN;
|
|
2876
|
+
var init_select_loader = __esm({
|
|
2877
|
+
"src/lib/api/select-loader.ts"() {
|
|
2878
|
+
init_src2();
|
|
2879
|
+
init_normalize_loader();
|
|
2880
|
+
init_log2();
|
|
2881
|
+
init_resource_utils();
|
|
2882
|
+
init_register_loaders();
|
|
2883
|
+
init_is_type();
|
|
2884
|
+
EXT_PATTERN = /\.([^.]+)$/;
|
|
2885
|
+
}
|
|
2886
|
+
});
|
|
2887
|
+
|
|
2888
|
+
// src/iterators/make-iterator/make-string-iterator.ts
|
|
2889
|
+
function* makeStringIterator(string, options) {
|
|
2890
|
+
const chunkSize = options?.chunkSize || DEFAULT_CHUNK_SIZE;
|
|
2891
|
+
let offset = 0;
|
|
2892
|
+
const textEncoder = new TextEncoder();
|
|
2893
|
+
while (offset < string.length) {
|
|
2894
|
+
const chunkLength = Math.min(string.length - offset, chunkSize);
|
|
2895
|
+
const chunk = string.slice(offset, offset + chunkLength);
|
|
2896
|
+
offset += chunkLength;
|
|
2897
|
+
yield textEncoder.encode(chunk);
|
|
2898
|
+
}
|
|
2899
|
+
}
|
|
2900
|
+
var DEFAULT_CHUNK_SIZE;
|
|
2901
|
+
var init_make_string_iterator = __esm({
|
|
2902
|
+
"src/iterators/make-iterator/make-string-iterator.ts"() {
|
|
2903
|
+
DEFAULT_CHUNK_SIZE = 256 * 1024;
|
|
2904
|
+
}
|
|
2905
|
+
});
|
|
2906
|
+
|
|
2907
|
+
// src/iterators/make-iterator/make-array-buffer-iterator.ts
|
|
2908
|
+
function* makeArrayBufferIterator(arrayBuffer, options = {}) {
|
|
2909
|
+
const { chunkSize = DEFAULT_CHUNK_SIZE2 } = options;
|
|
2910
|
+
let byteOffset = 0;
|
|
2911
|
+
while (byteOffset < arrayBuffer.byteLength) {
|
|
2912
|
+
const chunkByteLength = Math.min(arrayBuffer.byteLength - byteOffset, chunkSize);
|
|
2913
|
+
const chunk = new ArrayBuffer(chunkByteLength);
|
|
2914
|
+
const sourceArray = new Uint8Array(arrayBuffer, byteOffset, chunkByteLength);
|
|
2915
|
+
const chunkArray = new Uint8Array(chunk);
|
|
2916
|
+
chunkArray.set(sourceArray);
|
|
2917
|
+
byteOffset += chunkByteLength;
|
|
2918
|
+
yield chunk;
|
|
2919
|
+
}
|
|
2920
|
+
}
|
|
2921
|
+
var DEFAULT_CHUNK_SIZE2;
|
|
2922
|
+
var init_make_array_buffer_iterator = __esm({
|
|
2923
|
+
"src/iterators/make-iterator/make-array-buffer-iterator.ts"() {
|
|
2924
|
+
DEFAULT_CHUNK_SIZE2 = 256 * 1024;
|
|
2925
|
+
}
|
|
2926
|
+
});
|
|
2927
|
+
|
|
2928
|
+
// src/iterators/make-iterator/make-blob-iterator.ts
|
|
2929
|
+
async function* makeBlobIterator(blob, options) {
|
|
2930
|
+
const chunkSize = options?.chunkSize || DEFAULT_CHUNK_SIZE3;
|
|
2931
|
+
let offset = 0;
|
|
2932
|
+
while (offset < blob.size) {
|
|
2933
|
+
const end = offset + chunkSize;
|
|
2934
|
+
const chunk = await blob.slice(offset, end).arrayBuffer();
|
|
2935
|
+
offset = end;
|
|
2936
|
+
yield chunk;
|
|
2937
|
+
}
|
|
2938
|
+
}
|
|
2939
|
+
var DEFAULT_CHUNK_SIZE3;
|
|
2940
|
+
var init_make_blob_iterator = __esm({
|
|
2941
|
+
"src/iterators/make-iterator/make-blob-iterator.ts"() {
|
|
2942
|
+
DEFAULT_CHUNK_SIZE3 = 1024 * 1024;
|
|
2943
|
+
}
|
|
2944
|
+
});
|
|
2945
|
+
|
|
2946
|
+
// src/iterators/make-iterator/make-stream-iterator.ts
|
|
2947
|
+
function makeStreamIterator(stream, options) {
|
|
2948
|
+
return isBrowser ? makeBrowserStreamIterator(stream, options) : makeNodeStreamIterator(stream, options);
|
|
2949
|
+
}
|
|
2950
|
+
async function* makeBrowserStreamIterator(stream, options) {
|
|
2951
|
+
const reader = stream.getReader();
|
|
2952
|
+
let nextBatchPromise;
|
|
2953
|
+
try {
|
|
2954
|
+
while (true) {
|
|
2955
|
+
const currentBatchPromise = nextBatchPromise || reader.read();
|
|
2956
|
+
if (options?._streamReadAhead) {
|
|
2957
|
+
nextBatchPromise = reader.read();
|
|
2958
|
+
}
|
|
2959
|
+
const { done, value } = await currentBatchPromise;
|
|
2960
|
+
if (done) {
|
|
2961
|
+
return;
|
|
2962
|
+
}
|
|
2963
|
+
yield toArrayBuffer2(value);
|
|
2964
|
+
}
|
|
2965
|
+
} catch (error) {
|
|
2966
|
+
reader.releaseLock();
|
|
2967
|
+
}
|
|
2968
|
+
}
|
|
2969
|
+
async function* makeNodeStreamIterator(stream, options) {
|
|
2970
|
+
for await (const chunk of stream) {
|
|
2971
|
+
yield toArrayBuffer2(chunk);
|
|
2972
|
+
}
|
|
2973
|
+
}
|
|
2974
|
+
var init_make_stream_iterator = __esm({
|
|
2975
|
+
"src/iterators/make-iterator/make-stream-iterator.ts"() {
|
|
2976
|
+
init_src2();
|
|
2977
|
+
}
|
|
2978
|
+
});
|
|
2979
|
+
|
|
2980
|
+
// src/iterators/make-iterator/make-iterator.ts
|
|
2981
|
+
function makeIterator(data, options) {
|
|
2982
|
+
if (typeof data === "string") {
|
|
2983
|
+
return makeStringIterator(data, options);
|
|
2984
|
+
}
|
|
2985
|
+
if (data instanceof ArrayBuffer) {
|
|
2986
|
+
return makeArrayBufferIterator(data, options);
|
|
2987
|
+
}
|
|
2988
|
+
if (isBlob(data)) {
|
|
2989
|
+
return makeBlobIterator(data, options);
|
|
2990
|
+
}
|
|
2991
|
+
if (isReadableStream(data)) {
|
|
2992
|
+
return makeStreamIterator(data, options);
|
|
2993
|
+
}
|
|
2994
|
+
if (isResponse(data)) {
|
|
2995
|
+
const response = data;
|
|
2996
|
+
return makeStreamIterator(response.body, options);
|
|
2997
|
+
}
|
|
2998
|
+
throw new Error("makeIterator");
|
|
2999
|
+
}
|
|
3000
|
+
var init_make_iterator = __esm({
|
|
3001
|
+
"src/iterators/make-iterator/make-iterator.ts"() {
|
|
3002
|
+
init_make_string_iterator();
|
|
3003
|
+
init_make_array_buffer_iterator();
|
|
3004
|
+
init_make_blob_iterator();
|
|
3005
|
+
init_make_stream_iterator();
|
|
3006
|
+
init_is_type();
|
|
3007
|
+
}
|
|
3008
|
+
});
|
|
3009
|
+
|
|
3010
|
+
// src/lib/loader-utils/get-data.ts
|
|
3011
|
+
function getArrayBufferOrStringFromDataSync(data, loader, options) {
|
|
3012
|
+
if (loader.text && typeof data === "string") {
|
|
3013
|
+
return data;
|
|
3014
|
+
}
|
|
3015
|
+
if (isBuffer2(data)) {
|
|
3016
|
+
data = data.buffer;
|
|
3017
|
+
}
|
|
3018
|
+
if (data instanceof ArrayBuffer) {
|
|
3019
|
+
const arrayBuffer = data;
|
|
3020
|
+
if (loader.text && !loader.binary) {
|
|
3021
|
+
const textDecoder = new TextDecoder("utf8");
|
|
3022
|
+
return textDecoder.decode(arrayBuffer);
|
|
3023
|
+
}
|
|
3024
|
+
return arrayBuffer;
|
|
3025
|
+
}
|
|
3026
|
+
if (ArrayBuffer.isView(data)) {
|
|
3027
|
+
if (loader.text && !loader.binary) {
|
|
3028
|
+
const textDecoder = new TextDecoder("utf8");
|
|
3029
|
+
return textDecoder.decode(data);
|
|
3030
|
+
}
|
|
3031
|
+
let arrayBuffer = data.buffer;
|
|
3032
|
+
const byteLength = data.byteLength || data.length;
|
|
3033
|
+
if (data.byteOffset !== 0 || byteLength !== arrayBuffer.byteLength) {
|
|
3034
|
+
arrayBuffer = arrayBuffer.slice(data.byteOffset, data.byteOffset + byteLength);
|
|
3035
|
+
}
|
|
3036
|
+
return arrayBuffer;
|
|
3037
|
+
}
|
|
3038
|
+
throw new Error(ERR_DATA);
|
|
3039
|
+
}
|
|
3040
|
+
async function getArrayBufferOrStringFromData(data, loader, options) {
|
|
3041
|
+
const isArrayBuffer = data instanceof ArrayBuffer || ArrayBuffer.isView(data);
|
|
3042
|
+
if (typeof data === "string" || isArrayBuffer) {
|
|
3043
|
+
return getArrayBufferOrStringFromDataSync(data, loader, options);
|
|
3044
|
+
}
|
|
3045
|
+
if (isBlob(data)) {
|
|
3046
|
+
data = await makeResponse(data);
|
|
3047
|
+
}
|
|
3048
|
+
if (isResponse(data)) {
|
|
3049
|
+
const response = data;
|
|
3050
|
+
await checkResponse(response);
|
|
3051
|
+
return loader.binary ? await response.arrayBuffer() : await response.text();
|
|
3052
|
+
}
|
|
3053
|
+
if (isReadableStream(data)) {
|
|
3054
|
+
data = makeIterator(data, options);
|
|
3055
|
+
}
|
|
3056
|
+
if (isIterable(data) || isAsyncIterable(data)) {
|
|
3057
|
+
return concatenateArrayBuffersAsync(data);
|
|
3058
|
+
}
|
|
3059
|
+
throw new Error(ERR_DATA);
|
|
3060
|
+
}
|
|
3061
|
+
async function getAsyncIterableFromData(data, options) {
|
|
3062
|
+
if (isIterator(data)) {
|
|
3063
|
+
return data;
|
|
3064
|
+
}
|
|
3065
|
+
if (isResponse(data)) {
|
|
3066
|
+
const response = data;
|
|
3067
|
+
await checkResponse(response);
|
|
3068
|
+
const body = await response.body;
|
|
3069
|
+
return makeIterator(body, options);
|
|
3070
|
+
}
|
|
3071
|
+
if (isBlob(data) || isReadableStream(data)) {
|
|
3072
|
+
return makeIterator(data, options);
|
|
3073
|
+
}
|
|
3074
|
+
if (isAsyncIterable(data)) {
|
|
3075
|
+
return data[Symbol.asyncIterator]();
|
|
3076
|
+
}
|
|
3077
|
+
return getIterableFromData(data);
|
|
3078
|
+
}
|
|
3079
|
+
function getIterableFromData(data) {
|
|
3080
|
+
if (ArrayBuffer.isView(data)) {
|
|
3081
|
+
return function* oneChunk() {
|
|
3082
|
+
yield data.buffer;
|
|
3083
|
+
}();
|
|
3084
|
+
}
|
|
3085
|
+
if (data instanceof ArrayBuffer) {
|
|
3086
|
+
return function* oneChunk() {
|
|
3087
|
+
yield data;
|
|
3088
|
+
}();
|
|
3089
|
+
}
|
|
3090
|
+
if (isIterator(data)) {
|
|
3091
|
+
return data;
|
|
3092
|
+
}
|
|
3093
|
+
if (isIterable(data)) {
|
|
3094
|
+
return data[Symbol.iterator]();
|
|
3095
|
+
}
|
|
3096
|
+
throw new Error(ERR_DATA);
|
|
3097
|
+
}
|
|
3098
|
+
var ERR_DATA;
|
|
3099
|
+
var init_get_data = __esm({
|
|
3100
|
+
"src/lib/loader-utils/get-data.ts"() {
|
|
3101
|
+
init_src2();
|
|
3102
|
+
init_is_type();
|
|
3103
|
+
init_make_iterator();
|
|
3104
|
+
init_response_utils();
|
|
3105
|
+
ERR_DATA = "Cannot convert supplied data type";
|
|
3106
|
+
}
|
|
3107
|
+
});
|
|
3108
|
+
|
|
3109
|
+
// src/lib/loader-utils/get-fetch-function.ts
|
|
3110
|
+
function getFetchFunction(options, context) {
|
|
3111
|
+
const globalOptions = getGlobalLoaderOptions();
|
|
3112
|
+
const fetchOptions = options || globalOptions;
|
|
3113
|
+
if (typeof fetchOptions.fetch === "function") {
|
|
3114
|
+
return fetchOptions.fetch;
|
|
3115
|
+
}
|
|
3116
|
+
if (isObject(fetchOptions.fetch)) {
|
|
3117
|
+
return (url) => fetchFile(url, fetchOptions);
|
|
3118
|
+
}
|
|
3119
|
+
if (context?.fetch) {
|
|
3120
|
+
return context?.fetch;
|
|
3121
|
+
}
|
|
3122
|
+
return fetchFile;
|
|
3123
|
+
}
|
|
3124
|
+
var init_get_fetch_function = __esm({
|
|
3125
|
+
"src/lib/loader-utils/get-fetch-function.ts"() {
|
|
3126
|
+
init_is_type();
|
|
3127
|
+
init_fetch_file();
|
|
3128
|
+
init_option_utils();
|
|
3129
|
+
}
|
|
3130
|
+
});
|
|
3131
|
+
|
|
3132
|
+
// src/lib/loader-utils/loader-context.ts
|
|
3133
|
+
function getLoaderContext(context, options, previousContext = null) {
|
|
3134
|
+
if (previousContext) {
|
|
3135
|
+
return previousContext;
|
|
3136
|
+
}
|
|
3137
|
+
const resolvedContext = {
|
|
3138
|
+
fetch: getFetchFunction(options, context),
|
|
3139
|
+
...context
|
|
3140
|
+
};
|
|
3141
|
+
if (!Array.isArray(resolvedContext.loaders)) {
|
|
3142
|
+
resolvedContext.loaders = null;
|
|
3143
|
+
}
|
|
3144
|
+
return resolvedContext;
|
|
3145
|
+
}
|
|
3146
|
+
function getLoadersFromContext(loaders, context) {
|
|
3147
|
+
if (!context && loaders && !Array.isArray(loaders)) {
|
|
3148
|
+
return loaders;
|
|
3149
|
+
}
|
|
3150
|
+
let candidateLoaders;
|
|
3151
|
+
if (loaders) {
|
|
3152
|
+
candidateLoaders = Array.isArray(loaders) ? loaders : [loaders];
|
|
3153
|
+
}
|
|
3154
|
+
if (context && context.loaders) {
|
|
3155
|
+
const contextLoaders = Array.isArray(context.loaders) ? context.loaders : [context.loaders];
|
|
3156
|
+
candidateLoaders = candidateLoaders ? [...candidateLoaders, ...contextLoaders] : contextLoaders;
|
|
3157
|
+
}
|
|
3158
|
+
return candidateLoaders && candidateLoaders.length ? candidateLoaders : null;
|
|
3159
|
+
}
|
|
3160
|
+
var init_loader_context = __esm({
|
|
3161
|
+
"src/lib/loader-utils/loader-context.ts"() {
|
|
3162
|
+
init_get_fetch_function();
|
|
3163
|
+
}
|
|
3164
|
+
});
|
|
3165
|
+
|
|
3166
|
+
// src/lib/api/parse.ts
|
|
3167
|
+
async function parse(data, loaders, options, context) {
|
|
3168
|
+
assert2(!context || typeof context === "object");
|
|
3169
|
+
if (loaders && !Array.isArray(loaders) && !isLoaderObject(loaders)) {
|
|
3170
|
+
context = void 0;
|
|
3171
|
+
options = loaders;
|
|
3172
|
+
loaders = void 0;
|
|
3173
|
+
}
|
|
3174
|
+
data = await data;
|
|
3175
|
+
options = options || {};
|
|
3176
|
+
const { url } = getResourceUrlAndType(data);
|
|
3177
|
+
const typedLoaders = loaders;
|
|
3178
|
+
const candidateLoaders = getLoadersFromContext(typedLoaders, context);
|
|
3179
|
+
const loader = await selectLoader(data, candidateLoaders, options);
|
|
3180
|
+
if (!loader) {
|
|
3181
|
+
return null;
|
|
3182
|
+
}
|
|
3183
|
+
options = normalizeOptions(options, loader, candidateLoaders, url);
|
|
3184
|
+
context = getLoaderContext({ url, parse, loaders: candidateLoaders }, options, context);
|
|
3185
|
+
return await parseWithLoader(loader, data, options, context);
|
|
3186
|
+
}
|
|
3187
|
+
async function parseWithLoader(loader, data, options, context) {
|
|
3188
|
+
validateWorkerVersion(loader);
|
|
3189
|
+
if (isResponse(data)) {
|
|
3190
|
+
const response = data;
|
|
3191
|
+
const { ok, redirected, status, statusText, type, url } = response;
|
|
3192
|
+
const headers = Object.fromEntries(response.headers.entries());
|
|
3193
|
+
context.response = { headers, ok, redirected, status, statusText, type, url };
|
|
3194
|
+
}
|
|
3195
|
+
data = await getArrayBufferOrStringFromData(data, loader, options);
|
|
3196
|
+
if (loader.parseTextSync && typeof data === "string") {
|
|
3197
|
+
options.dataType = "text";
|
|
3198
|
+
return loader.parseTextSync(data, options, context, loader);
|
|
3199
|
+
}
|
|
3200
|
+
if (canParseWithWorker(loader, options)) {
|
|
3201
|
+
return await parseWithWorker(loader, data, options, context, parse);
|
|
3202
|
+
}
|
|
3203
|
+
if (loader.parseText && typeof data === "string") {
|
|
3204
|
+
return await loader.parseText(data, options, context, loader);
|
|
3205
|
+
}
|
|
3206
|
+
if (loader.parse) {
|
|
3207
|
+
return await loader.parse(data, options, context, loader);
|
|
3208
|
+
}
|
|
3209
|
+
assert2(!loader.parseSync);
|
|
3210
|
+
throw new Error(`${loader.id} loader - no parser found and worker is disabled`);
|
|
3211
|
+
}
|
|
3212
|
+
var init_parse = __esm({
|
|
3213
|
+
"src/lib/api/parse.ts"() {
|
|
3214
|
+
init_src();
|
|
3215
|
+
init_src2();
|
|
3216
|
+
init_normalize_loader();
|
|
3217
|
+
init_is_type();
|
|
3218
|
+
init_option_utils();
|
|
3219
|
+
init_get_data();
|
|
3220
|
+
init_loader_context();
|
|
3221
|
+
init_resource_utils();
|
|
3222
|
+
init_select_loader();
|
|
3223
|
+
}
|
|
3224
|
+
});
|
|
3225
|
+
|
|
3226
|
+
// src/lib/api/parse-sync.ts
|
|
3227
|
+
function parseSync(data, loaders, options, context) {
|
|
3228
|
+
assert(!context || typeof context === "object");
|
|
3229
|
+
if (!Array.isArray(loaders) && !isLoaderObject(loaders)) {
|
|
3230
|
+
context = void 0;
|
|
3231
|
+
options = loaders;
|
|
3232
|
+
loaders = void 0;
|
|
3233
|
+
}
|
|
3234
|
+
options = options || {};
|
|
3235
|
+
const typedLoaders = loaders;
|
|
3236
|
+
const candidateLoaders = getLoadersFromContext(typedLoaders, context);
|
|
3237
|
+
const loader = selectLoaderSync(data, candidateLoaders, options);
|
|
3238
|
+
if (!loader) {
|
|
3239
|
+
return null;
|
|
3240
|
+
}
|
|
3241
|
+
options = normalizeOptions(options, loader, candidateLoaders);
|
|
3242
|
+
const { url } = getResourceUrlAndType(data);
|
|
3243
|
+
const parse2 = () => {
|
|
3244
|
+
throw new Error("parseSync called parse");
|
|
3245
|
+
};
|
|
3246
|
+
context = getLoaderContext({ url, parseSync, parse: parse2, loaders }, options);
|
|
3247
|
+
return parseWithLoaderSync(loader, data, options, context);
|
|
3248
|
+
}
|
|
3249
|
+
function parseWithLoaderSync(loader, data, options, context) {
|
|
3250
|
+
data = getArrayBufferOrStringFromDataSync(data, loader, options);
|
|
3251
|
+
if (loader.parseTextSync && typeof data === "string") {
|
|
3252
|
+
return loader.parseTextSync(data, options);
|
|
3253
|
+
}
|
|
3254
|
+
if (loader.parseSync && data instanceof ArrayBuffer) {
|
|
3255
|
+
return loader.parseSync(data, options, context);
|
|
3256
|
+
}
|
|
3257
|
+
throw new Error(`${loader.name} loader: 'parseSync' not supported by this loader, use 'parse' instead. ${context.url || ""}`);
|
|
3258
|
+
}
|
|
3259
|
+
var init_parse_sync = __esm({
|
|
3260
|
+
"src/lib/api/parse-sync.ts"() {
|
|
3261
|
+
init_src2();
|
|
3262
|
+
init_select_loader();
|
|
3263
|
+
init_normalize_loader();
|
|
3264
|
+
init_option_utils();
|
|
3265
|
+
init_get_data();
|
|
3266
|
+
init_loader_context();
|
|
3267
|
+
init_resource_utils();
|
|
3268
|
+
}
|
|
3269
|
+
});
|
|
3270
|
+
|
|
3271
|
+
// src/lib/api/parse-in-batches.ts
|
|
3272
|
+
async function parseInBatches(data, loaders, options, context) {
|
|
3273
|
+
assert(!context || typeof context === "object");
|
|
3274
|
+
if (!Array.isArray(loaders) && !isLoaderObject(loaders)) {
|
|
3275
|
+
context = void 0;
|
|
3276
|
+
options = loaders;
|
|
3277
|
+
loaders = void 0;
|
|
3278
|
+
}
|
|
3279
|
+
data = await data;
|
|
3280
|
+
options = options || {};
|
|
3281
|
+
const { url } = getResourceUrlAndType(data);
|
|
3282
|
+
const loader = await selectLoader(data, loaders, options);
|
|
3283
|
+
if (!loader) {
|
|
3284
|
+
return null;
|
|
3285
|
+
}
|
|
3286
|
+
options = normalizeOptions(options, loader, loaders, url);
|
|
3287
|
+
context = getLoaderContext({ url, parseInBatches, parse, loaders }, options, context);
|
|
3288
|
+
return await parseWithLoaderInBatches(loader, data, options, context);
|
|
3289
|
+
}
|
|
3290
|
+
async function parseWithLoaderInBatches(loader, data, options, context) {
|
|
3291
|
+
const outputIterator = await parseToOutputIterator(loader, data, options, context);
|
|
3292
|
+
if (!options.metadata) {
|
|
3293
|
+
return outputIterator;
|
|
3294
|
+
}
|
|
3295
|
+
const metadataBatch = {
|
|
3296
|
+
batchType: "metadata",
|
|
3297
|
+
metadata: {
|
|
3298
|
+
_loader: loader,
|
|
3299
|
+
_context: context
|
|
3300
|
+
},
|
|
3301
|
+
data: [],
|
|
3302
|
+
bytesUsed: 0
|
|
3303
|
+
};
|
|
3304
|
+
async function* makeMetadataBatchIterator(iterator) {
|
|
3305
|
+
yield metadataBatch;
|
|
3306
|
+
yield* iterator;
|
|
3307
|
+
}
|
|
3308
|
+
return makeMetadataBatchIterator(outputIterator);
|
|
3309
|
+
}
|
|
3310
|
+
async function parseToOutputIterator(loader, data, options, context) {
|
|
3311
|
+
const inputIterator = await getAsyncIterableFromData(data, options);
|
|
3312
|
+
const transformedIterator = await applyInputTransforms(inputIterator, options?.transforms || []);
|
|
3313
|
+
if (loader.parseInBatches) {
|
|
3314
|
+
return loader.parseInBatches(transformedIterator, options, context);
|
|
3315
|
+
}
|
|
3316
|
+
async function* parseChunkInBatches() {
|
|
3317
|
+
const arrayBuffer = await concatenateArrayBuffersAsync(transformedIterator);
|
|
3318
|
+
const parsedData = await parse(arrayBuffer, loader, { ...options, mimeType: loader.mimeTypes[0] }, context);
|
|
3319
|
+
const batch = {
|
|
3320
|
+
mimeType: loader.mimeTypes[0],
|
|
3321
|
+
shape: Array.isArray(parsedData) ? "row-table" : "unknown",
|
|
3322
|
+
batchType: "data",
|
|
3323
|
+
data: parsedData,
|
|
3324
|
+
length: Array.isArray(parsedData) ? parsedData.length : 1
|
|
3325
|
+
};
|
|
3326
|
+
yield batch;
|
|
3327
|
+
}
|
|
3328
|
+
return parseChunkInBatches();
|
|
3329
|
+
}
|
|
3330
|
+
async function applyInputTransforms(inputIterator, transforms = []) {
|
|
3331
|
+
let iteratorChain = inputIterator;
|
|
3332
|
+
for await (const transformBatches of transforms) {
|
|
3333
|
+
iteratorChain = transformBatches(iteratorChain);
|
|
3334
|
+
}
|
|
3335
|
+
return iteratorChain;
|
|
3336
|
+
}
|
|
3337
|
+
var init_parse_in_batches = __esm({
|
|
3338
|
+
"src/lib/api/parse-in-batches.ts"() {
|
|
3339
|
+
init_src2();
|
|
3340
|
+
init_normalize_loader();
|
|
3341
|
+
init_option_utils();
|
|
3342
|
+
init_loader_context();
|
|
3343
|
+
init_get_data();
|
|
3344
|
+
init_resource_utils();
|
|
3345
|
+
init_select_loader();
|
|
3346
|
+
init_parse();
|
|
3347
|
+
}
|
|
3348
|
+
});
|
|
3349
|
+
|
|
3350
|
+
// src/lib/api/load.ts
|
|
3351
|
+
async function load(url, loaders, options, context) {
|
|
3352
|
+
let resolvedLoaders;
|
|
3353
|
+
let resolvedOptions;
|
|
3354
|
+
if (!Array.isArray(loaders) && !isLoaderObject(loaders)) {
|
|
3355
|
+
resolvedLoaders = [];
|
|
3356
|
+
resolvedOptions = loaders;
|
|
3357
|
+
context = void 0;
|
|
3358
|
+
} else {
|
|
3359
|
+
resolvedLoaders = loaders;
|
|
3360
|
+
resolvedOptions = options;
|
|
3361
|
+
}
|
|
3362
|
+
const fetch2 = getFetchFunction(resolvedOptions);
|
|
3363
|
+
let data = url;
|
|
3364
|
+
if (typeof url === "string") {
|
|
3365
|
+
data = await fetch2(url);
|
|
3366
|
+
}
|
|
3367
|
+
if (isBlob(url)) {
|
|
3368
|
+
data = await fetch2(url);
|
|
3369
|
+
}
|
|
3370
|
+
return Array.isArray(resolvedLoaders) ? await parse(data, resolvedLoaders, resolvedOptions) : await parse(data, resolvedLoaders, resolvedOptions);
|
|
3371
|
+
}
|
|
3372
|
+
var init_load = __esm({
|
|
3373
|
+
"src/lib/api/load.ts"() {
|
|
3374
|
+
init_is_type();
|
|
3375
|
+
init_normalize_loader();
|
|
3376
|
+
init_get_fetch_function();
|
|
3377
|
+
init_parse();
|
|
3378
|
+
}
|
|
3379
|
+
});
|
|
3380
|
+
|
|
3381
|
+
// src/lib/api/load-in-batches.ts
|
|
3382
|
+
function loadInBatches(files, loaders, options, context) {
|
|
3383
|
+
if (!Array.isArray(loaders) && !isLoaderObject(loaders)) {
|
|
3384
|
+
context = void 0;
|
|
3385
|
+
options = loaders;
|
|
3386
|
+
loaders = null;
|
|
3387
|
+
}
|
|
3388
|
+
const fetch2 = getFetchFunction(options || {});
|
|
3389
|
+
if (!Array.isArray(files)) {
|
|
3390
|
+
return loadOneFileInBatches(files, loaders, options, fetch2);
|
|
3391
|
+
}
|
|
3392
|
+
const promises = files.map((file) => loadOneFileInBatches(file, loaders, options, fetch2));
|
|
3393
|
+
return promises;
|
|
3394
|
+
}
|
|
3395
|
+
async function loadOneFileInBatches(file, loaders, options, fetch2) {
|
|
3396
|
+
if (typeof file === "string") {
|
|
3397
|
+
const url = file;
|
|
3398
|
+
const response = await fetch2(url);
|
|
3399
|
+
return await parseInBatches(response, loaders, options);
|
|
3400
|
+
}
|
|
3401
|
+
return await parseInBatches(file, loaders, options);
|
|
3402
|
+
}
|
|
3403
|
+
var init_load_in_batches = __esm({
|
|
3404
|
+
"src/lib/api/load-in-batches.ts"() {
|
|
3405
|
+
init_normalize_loader();
|
|
3406
|
+
init_get_fetch_function();
|
|
3407
|
+
init_parse_in_batches();
|
|
3408
|
+
}
|
|
3409
|
+
});
|
|
3410
|
+
|
|
3411
|
+
// src/lib/api/encode-table.ts
|
|
3412
|
+
async function encodeTable(data, writer, options) {
|
|
3413
|
+
if (writer.encode) {
|
|
3414
|
+
return await writer.encode(data, options);
|
|
3415
|
+
}
|
|
3416
|
+
if (writer.encodeText) {
|
|
3417
|
+
const text = await writer.encodeText(data, options);
|
|
3418
|
+
return new TextEncoder().encode(text);
|
|
3419
|
+
}
|
|
3420
|
+
if (writer.encodeInBatches) {
|
|
3421
|
+
const batches = encodeTableInBatches(data, writer, options);
|
|
3422
|
+
const chunks = [];
|
|
3423
|
+
for await (const batch of batches) {
|
|
3424
|
+
chunks.push(batch);
|
|
3425
|
+
}
|
|
3426
|
+
return concatenateArrayBuffers(...chunks);
|
|
3427
|
+
}
|
|
3428
|
+
throw new Error("Writer could not encode data");
|
|
3429
|
+
}
|
|
3430
|
+
async function encodeTableAsText(data, writer, options) {
|
|
3431
|
+
if (writer.text && writer.encodeText) {
|
|
3432
|
+
return await writer.encodeText(data, options);
|
|
3433
|
+
}
|
|
3434
|
+
if (writer.text && (writer.encode || writer.encodeInBatches)) {
|
|
3435
|
+
const arrayBuffer = await encodeTable(data, writer, options);
|
|
3436
|
+
return new TextDecoder().decode(arrayBuffer);
|
|
3437
|
+
}
|
|
3438
|
+
throw new Error("Writer could not encode data as text");
|
|
3439
|
+
}
|
|
3440
|
+
function encodeTableInBatches(data, writer, options) {
|
|
3441
|
+
if (writer.encodeInBatches) {
|
|
3442
|
+
const dataIterator = getIterator(data);
|
|
3443
|
+
return writer.encodeInBatches(dataIterator, options);
|
|
3444
|
+
}
|
|
3445
|
+
throw new Error("Writer could not encode data in batches");
|
|
3446
|
+
}
|
|
3447
|
+
function getIterator(data) {
|
|
3448
|
+
const dataIterator = [{ table: data, start: 0, end: data.length }];
|
|
3449
|
+
return dataIterator;
|
|
3450
|
+
}
|
|
3451
|
+
var init_encode_table = __esm({
|
|
3452
|
+
"src/lib/api/encode-table.ts"() {
|
|
3453
|
+
init_src2();
|
|
3454
|
+
}
|
|
3455
|
+
});
|
|
3456
|
+
|
|
3457
|
+
// src/lib/api/encode.ts
|
|
3458
|
+
async function encode(data, writer, options) {
|
|
3459
|
+
const globalOptions = getGlobalLoaderOptions();
|
|
3460
|
+
options = { ...globalOptions, ...options };
|
|
3461
|
+
if (canEncodeWithWorker(writer, options)) {
|
|
3462
|
+
return await processOnWorker(writer, data, options);
|
|
3463
|
+
}
|
|
3464
|
+
if (writer.encode) {
|
|
3465
|
+
return await writer.encode(data, options);
|
|
3466
|
+
}
|
|
3467
|
+
if (writer.encodeSync) {
|
|
3468
|
+
return writer.encodeSync(data, options);
|
|
3469
|
+
}
|
|
3470
|
+
if (writer.encodeText) {
|
|
3471
|
+
return new TextEncoder().encode(await writer.encodeText(data, options));
|
|
3472
|
+
}
|
|
3473
|
+
if (writer.encodeInBatches) {
|
|
3474
|
+
const batches = encodeInBatches(data, writer, options);
|
|
3475
|
+
const chunks = [];
|
|
3476
|
+
for await (const batch of batches) {
|
|
3477
|
+
chunks.push(batch);
|
|
3478
|
+
}
|
|
3479
|
+
return concatenateArrayBuffers(...chunks);
|
|
3480
|
+
}
|
|
3481
|
+
if (!isBrowser && writer.encodeURLtoURL) {
|
|
3482
|
+
const tmpInputFilename = getTemporaryFilename("input");
|
|
3483
|
+
await writeFile2(tmpInputFilename, data);
|
|
3484
|
+
const tmpOutputFilename = getTemporaryFilename("output");
|
|
3485
|
+
const outputFilename = await encodeURLtoURL(tmpInputFilename, tmpOutputFilename, writer, options);
|
|
3486
|
+
const response = await fetchFile(outputFilename);
|
|
3487
|
+
return response.arrayBuffer();
|
|
3488
|
+
}
|
|
3489
|
+
throw new Error("Writer could not encode data");
|
|
3490
|
+
}
|
|
3491
|
+
function encodeSync(data, writer, options) {
|
|
3492
|
+
if (writer.encodeSync) {
|
|
3493
|
+
return writer.encodeSync(data, options);
|
|
3494
|
+
}
|
|
3495
|
+
throw new Error("Writer could not synchronously encode data");
|
|
3496
|
+
}
|
|
3497
|
+
async function encodeText(data, writer, options) {
|
|
3498
|
+
if (writer.text && writer.encodeText) {
|
|
3499
|
+
return await writer.encodeText(data, options);
|
|
3500
|
+
}
|
|
3501
|
+
if (writer.text && (writer.encode || writer.encodeInBatches)) {
|
|
3502
|
+
const arrayBuffer = await encode(data, writer, options);
|
|
3503
|
+
return new TextDecoder().decode(arrayBuffer);
|
|
3504
|
+
}
|
|
3505
|
+
throw new Error("Writer could not encode data as text");
|
|
3506
|
+
}
|
|
3507
|
+
function encodeInBatches(data, writer, options) {
|
|
3508
|
+
if (writer.encodeInBatches) {
|
|
3509
|
+
const dataIterator = getIterator2(data);
|
|
3510
|
+
return writer.encodeInBatches(dataIterator, options);
|
|
3511
|
+
}
|
|
3512
|
+
throw new Error("Writer could not encode data in batches");
|
|
3513
|
+
}
|
|
3514
|
+
async function encodeURLtoURL(inputUrl, outputUrl, writer, options) {
|
|
3515
|
+
inputUrl = resolvePath(inputUrl);
|
|
3516
|
+
outputUrl = resolvePath(outputUrl);
|
|
3517
|
+
if (isBrowser || !writer.encodeURLtoURL) {
|
|
3518
|
+
throw new Error();
|
|
3519
|
+
}
|
|
3520
|
+
const outputFilename = await writer.encodeURLtoURL(inputUrl, outputUrl, options);
|
|
3521
|
+
return outputFilename;
|
|
3522
|
+
}
|
|
3523
|
+
function getIterator2(data) {
|
|
3524
|
+
const dataIterator = [{ table: data, start: 0, end: data.length }];
|
|
3525
|
+
return dataIterator;
|
|
3526
|
+
}
|
|
3527
|
+
function getTemporaryFilename(filename2) {
|
|
3528
|
+
return `/tmp/${filename2}`;
|
|
3529
|
+
}
|
|
3530
|
+
var init_encode = __esm({
|
|
3531
|
+
"src/lib/api/encode.ts"() {
|
|
3532
|
+
init_src2();
|
|
3533
|
+
init_src();
|
|
3534
|
+
init_src2();
|
|
3535
|
+
init_src2();
|
|
3536
|
+
init_write_file();
|
|
3537
|
+
init_fetch_file();
|
|
3538
|
+
init_loader_options();
|
|
3539
|
+
}
|
|
3540
|
+
});
|
|
3541
|
+
|
|
3542
|
+
// src/lib/api/save.ts
|
|
3543
|
+
async function save(data, url, writer, options) {
|
|
3544
|
+
const encodedData = await encode(data, writer, options);
|
|
3545
|
+
return await writeFile2(url, encodedData);
|
|
3546
|
+
}
|
|
3547
|
+
function saveSync(data, url, writer, options) {
|
|
3548
|
+
const encodedData = encodeSync(data, writer, options);
|
|
3549
|
+
return writeFileSync2(url, encodedData);
|
|
3550
|
+
}
|
|
3551
|
+
var init_save = __esm({
|
|
3552
|
+
"src/lib/api/save.ts"() {
|
|
3553
|
+
init_encode();
|
|
3554
|
+
init_write_file();
|
|
3555
|
+
}
|
|
3556
|
+
});
|
|
3557
|
+
|
|
3558
|
+
// src/iterators/make-stream/make-dom-stream.ts
|
|
3559
|
+
function makeStream(source, options) {
|
|
3560
|
+
const iterator = source[Symbol.asyncIterator] ? source[Symbol.asyncIterator]() : source[Symbol.iterator]();
|
|
3561
|
+
return new ReadableStream({
|
|
3562
|
+
type: "bytes",
|
|
3563
|
+
async pull(controller) {
|
|
3564
|
+
try {
|
|
3565
|
+
const { done, value } = await iterator.next();
|
|
3566
|
+
if (done) {
|
|
3567
|
+
controller.close();
|
|
3568
|
+
} else {
|
|
3569
|
+
controller.enqueue(new Uint8Array(value));
|
|
3570
|
+
}
|
|
3571
|
+
} catch (error) {
|
|
3572
|
+
controller.error(error);
|
|
3573
|
+
}
|
|
3574
|
+
},
|
|
3575
|
+
async cancel() {
|
|
3576
|
+
await iterator?.return?.();
|
|
3577
|
+
}
|
|
3578
|
+
}, {
|
|
3579
|
+
highWaterMark: 2 ** 24,
|
|
3580
|
+
...options
|
|
3581
|
+
});
|
|
3582
|
+
}
|
|
3583
|
+
var init_make_dom_stream = __esm({
|
|
3584
|
+
"src/iterators/make-stream/make-dom-stream.ts"() {
|
|
3585
|
+
}
|
|
3586
|
+
});
|
|
3587
|
+
|
|
3588
|
+
// src/null-loader.ts
|
|
3589
|
+
function parseSync2(arrayBuffer, options, context) {
|
|
3590
|
+
if (!options.null.echoParameters)
|
|
3591
|
+
return null;
|
|
3592
|
+
context = context && JSON.parse(JSON.stringify(context));
|
|
3593
|
+
return { arrayBuffer, options, context };
|
|
3594
|
+
}
|
|
3595
|
+
var VERSION5, NullWorkerLoader, NullLoader;
|
|
3596
|
+
var init_null_loader = __esm({
|
|
3597
|
+
"src/null-loader.ts"() {
|
|
3598
|
+
VERSION5 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
3599
|
+
NullWorkerLoader = {
|
|
3600
|
+
name: "Null loader",
|
|
3601
|
+
id: "null",
|
|
3602
|
+
module: "core",
|
|
3603
|
+
version: VERSION5,
|
|
3604
|
+
worker: true,
|
|
3605
|
+
mimeTypes: ["application/x.empty"],
|
|
3606
|
+
extensions: ["null"],
|
|
3607
|
+
tests: [() => false],
|
|
3608
|
+
options: {
|
|
3609
|
+
null: {}
|
|
3610
|
+
}
|
|
3611
|
+
};
|
|
3612
|
+
NullLoader = {
|
|
3613
|
+
name: "Null loader",
|
|
3614
|
+
id: "null",
|
|
3615
|
+
module: "core",
|
|
3616
|
+
version: VERSION5,
|
|
3617
|
+
mimeTypes: ["application/x.empty"],
|
|
3618
|
+
extensions: ["null"],
|
|
3619
|
+
parse: async (arrayBuffer, options, context) => parseSync2(arrayBuffer, options, context),
|
|
3620
|
+
parseSync: parseSync2,
|
|
3621
|
+
parseInBatches: async function* generator(asyncIterator, options, context) {
|
|
3622
|
+
for await (const batch of asyncIterator) {
|
|
3623
|
+
yield parseSync2(batch, options, context);
|
|
3624
|
+
}
|
|
3625
|
+
},
|
|
3626
|
+
tests: [() => false],
|
|
3627
|
+
options: {
|
|
3628
|
+
null: {
|
|
3629
|
+
echoParameters: false
|
|
3630
|
+
}
|
|
3631
|
+
}
|
|
3632
|
+
};
|
|
3633
|
+
}
|
|
3634
|
+
});
|
|
3635
|
+
|
|
3636
|
+
// src/lib/progress/fetch-progress.ts
|
|
3637
|
+
async function fetchProgress(response, onProgress, onDone = () => {
|
|
3638
|
+
}, onError = () => {
|
|
3639
|
+
}) {
|
|
3640
|
+
response = await response;
|
|
3641
|
+
if (!response.ok) {
|
|
3642
|
+
return response;
|
|
3643
|
+
}
|
|
3644
|
+
const body = response.body;
|
|
3645
|
+
if (!body) {
|
|
3646
|
+
return response;
|
|
3647
|
+
}
|
|
3648
|
+
const contentLength = response.headers.get("content-length") || 0;
|
|
3649
|
+
const totalBytes = contentLength ? parseInt(contentLength) : 0;
|
|
3650
|
+
if (!(totalBytes > 0)) {
|
|
3651
|
+
return response;
|
|
3652
|
+
}
|
|
3653
|
+
if (typeof ReadableStream === "undefined" || !body.getReader) {
|
|
3654
|
+
return response;
|
|
3655
|
+
}
|
|
3656
|
+
const progressStream = new ReadableStream({
|
|
3657
|
+
async start(controller) {
|
|
3658
|
+
const reader = body.getReader();
|
|
3659
|
+
await read2(controller, reader, 0, totalBytes, onProgress, onDone, onError);
|
|
3660
|
+
}
|
|
3661
|
+
});
|
|
3662
|
+
return new Response(progressStream);
|
|
3663
|
+
}
|
|
3664
|
+
async function read2(controller, reader, loadedBytes, totalBytes, onProgress, onDone, onError) {
|
|
3665
|
+
try {
|
|
3666
|
+
const { done, value } = await reader.read();
|
|
3667
|
+
if (done) {
|
|
3668
|
+
onDone();
|
|
3669
|
+
controller.close();
|
|
3670
|
+
return;
|
|
3671
|
+
}
|
|
3672
|
+
loadedBytes += value.byteLength;
|
|
3673
|
+
const percent = Math.round(loadedBytes / totalBytes * 100);
|
|
3674
|
+
onProgress(percent, { loadedBytes, totalBytes });
|
|
3675
|
+
controller.enqueue(value);
|
|
3676
|
+
await read2(controller, reader, loadedBytes, totalBytes, onProgress, onDone, onError);
|
|
3677
|
+
} catch (error) {
|
|
3678
|
+
controller.error(error);
|
|
3679
|
+
onError(error);
|
|
3680
|
+
}
|
|
3681
|
+
}
|
|
3682
|
+
var init_fetch_progress = __esm({
|
|
3683
|
+
"src/lib/progress/fetch-progress.ts"() {
|
|
3684
|
+
}
|
|
3685
|
+
});
|
|
3686
|
+
|
|
3687
|
+
// src/lib/filesystems/browser-filesystem.ts
|
|
3688
|
+
var BrowserFileSystem;
|
|
3689
|
+
var init_browser_filesystem = __esm({
|
|
3690
|
+
"src/lib/filesystems/browser-filesystem.ts"() {
|
|
3691
|
+
BrowserFileSystem = class {
|
|
3692
|
+
constructor(files, options) {
|
|
3693
|
+
this.files = {};
|
|
3694
|
+
this.lowerCaseFiles = {};
|
|
3695
|
+
this.usedFiles = {};
|
|
3696
|
+
this._fetch = options?.fetch || fetch;
|
|
3697
|
+
for (let i = 0; i < files.length; ++i) {
|
|
3698
|
+
const file = files[i];
|
|
3699
|
+
this.files[file.name] = file;
|
|
3700
|
+
this.lowerCaseFiles[file.name.toLowerCase()] = file;
|
|
3701
|
+
this.usedFiles[file.name] = false;
|
|
3702
|
+
}
|
|
3703
|
+
this.fetch = this.fetch.bind(this);
|
|
3704
|
+
}
|
|
3705
|
+
async fetch(path, options) {
|
|
3706
|
+
if (path.includes("://")) {
|
|
3707
|
+
return this._fetch(path, options);
|
|
3708
|
+
}
|
|
3709
|
+
const file = this.files[path];
|
|
3710
|
+
if (!file) {
|
|
3711
|
+
return new Response(path, { status: 400, statusText: "NOT FOUND" });
|
|
3712
|
+
}
|
|
3713
|
+
const headers = new Headers(options?.headers);
|
|
3714
|
+
const range = headers.get("Range");
|
|
3715
|
+
const bytes = range && /bytes=($1)-($2)/.exec(range);
|
|
3716
|
+
if (bytes) {
|
|
3717
|
+
const start = parseInt(bytes[1]);
|
|
3718
|
+
const end = parseInt(bytes[2]);
|
|
3719
|
+
const data = await file.slice(start, end).arrayBuffer();
|
|
3720
|
+
const response2 = new Response(data);
|
|
3721
|
+
Object.defineProperty(response2, "url", { value: path });
|
|
3722
|
+
return response2;
|
|
3723
|
+
}
|
|
3724
|
+
const response = new Response(file);
|
|
3725
|
+
Object.defineProperty(response, "url", { value: path });
|
|
3726
|
+
return response;
|
|
3727
|
+
}
|
|
3728
|
+
async readdir(dirname2) {
|
|
3729
|
+
const files = [];
|
|
3730
|
+
for (const path in this.files) {
|
|
3731
|
+
files.push(path);
|
|
3732
|
+
}
|
|
3733
|
+
return files;
|
|
3734
|
+
}
|
|
3735
|
+
async stat(path, options) {
|
|
3736
|
+
const file = this.files[path];
|
|
3737
|
+
if (!file) {
|
|
3738
|
+
throw new Error(path);
|
|
3739
|
+
}
|
|
3740
|
+
return { size: file.size };
|
|
3741
|
+
}
|
|
3742
|
+
async unlink(path) {
|
|
3743
|
+
delete this.files[path];
|
|
3744
|
+
delete this.lowerCaseFiles[path];
|
|
3745
|
+
this.usedFiles[path] = true;
|
|
3746
|
+
}
|
|
3747
|
+
async open(pathname, flags, mode) {
|
|
3748
|
+
return this.files[pathname];
|
|
3749
|
+
}
|
|
3750
|
+
async read(fd, buffer, offset = 0, length = buffer.byteLength, position = null) {
|
|
3751
|
+
const file = fd;
|
|
3752
|
+
const startPosition = 0;
|
|
3753
|
+
const arrayBuffer = await file.slice(startPosition, startPosition + length).arrayBuffer();
|
|
3754
|
+
return { bytesRead: length, buffer: arrayBuffer };
|
|
3755
|
+
}
|
|
3756
|
+
async close(fd) {
|
|
3757
|
+
}
|
|
3758
|
+
_getFile(path, used) {
|
|
3759
|
+
const file = this.files[path] || this.lowerCaseFiles[path];
|
|
3760
|
+
if (file && used) {
|
|
3761
|
+
this.usedFiles[path] = true;
|
|
3762
|
+
}
|
|
3763
|
+
return file;
|
|
3764
|
+
}
|
|
3765
|
+
};
|
|
3766
|
+
}
|
|
3767
|
+
});
|
|
3768
|
+
|
|
3769
|
+
// src/index.ts
|
|
3770
|
+
var src_exports = {};
|
|
3771
|
+
__export(src_exports, {
|
|
3772
|
+
JSONLoader: () => JSONLoader,
|
|
3773
|
+
NullLoader: () => NullLoader,
|
|
3774
|
+
NullWorkerLoader: () => NullWorkerLoader,
|
|
3775
|
+
RequestScheduler: () => RequestScheduler,
|
|
3776
|
+
_BrowserFileSystem: () => BrowserFileSystem,
|
|
3777
|
+
_fetchProgress: () => fetchProgress,
|
|
3778
|
+
_unregisterLoaders: () => _unregisterLoaders,
|
|
3779
|
+
assert: () => assert,
|
|
3780
|
+
concatenateArrayBuffersAsync: () => concatenateArrayBuffersAsync,
|
|
3781
|
+
document: () => document_,
|
|
3782
|
+
encode: () => encode,
|
|
3783
|
+
encodeInBatches: () => encodeInBatches,
|
|
3784
|
+
encodeSync: () => encodeSync,
|
|
3785
|
+
encodeTable: () => encodeTable,
|
|
3786
|
+
encodeTableAsText: () => encodeTableAsText,
|
|
3787
|
+
encodeTableInBatches: () => encodeTableInBatches,
|
|
3788
|
+
encodeText: () => encodeText,
|
|
3789
|
+
encodeURLtoURL: () => encodeURLtoURL,
|
|
3790
|
+
fetchFile: () => fetchFile,
|
|
3791
|
+
forEach: () => forEach,
|
|
3792
|
+
getLoaderOptions: () => getGlobalLoaderOptions,
|
|
3793
|
+
getPathPrefix: () => getPathPrefix,
|
|
3794
|
+
global: () => global_,
|
|
3795
|
+
isAsyncIterable: () => isAsyncIterable,
|
|
3796
|
+
isBrowser: () => isBrowser,
|
|
3797
|
+
isIterable: () => isIterable,
|
|
3798
|
+
isIterator: () => isIterator,
|
|
3799
|
+
isPromise: () => isPromise,
|
|
3800
|
+
isPureObject: () => isPureObject,
|
|
3801
|
+
isReadableStream: () => isReadableStream,
|
|
3802
|
+
isResponse: () => isResponse,
|
|
3803
|
+
isWorker: () => isWorker,
|
|
3804
|
+
isWritableStream: () => isWritableStream,
|
|
3805
|
+
load: () => load,
|
|
3806
|
+
loadInBatches: () => loadInBatches,
|
|
3807
|
+
makeIterator: () => makeIterator,
|
|
3808
|
+
makeLineIterator: () => makeLineIterator,
|
|
3809
|
+
makeNumberedLineIterator: () => makeNumberedLineIterator,
|
|
3810
|
+
makeStream: () => makeStream,
|
|
3811
|
+
makeTextDecoderIterator: () => makeTextDecoderIterator,
|
|
3812
|
+
makeTextEncoderIterator: () => makeTextEncoderIterator,
|
|
3813
|
+
parse: () => parse,
|
|
3814
|
+
parseInBatches: () => parseInBatches,
|
|
3815
|
+
parseSync: () => parseSync,
|
|
3816
|
+
readArrayBuffer: () => readArrayBuffer,
|
|
3817
|
+
readFileSync: () => readFileSync2,
|
|
3818
|
+
registerLoaders: () => registerLoaders,
|
|
3819
|
+
resolvePath: () => resolvePath,
|
|
3820
|
+
save: () => save,
|
|
3821
|
+
saveSync: () => saveSync,
|
|
3822
|
+
selectLoader: () => selectLoader,
|
|
3823
|
+
selectLoaderSync: () => selectLoaderSync,
|
|
3824
|
+
self: () => self_,
|
|
3825
|
+
setLoaderOptions: () => setGlobalOptions,
|
|
3826
|
+
setPathPrefix: () => setPathPrefix,
|
|
3827
|
+
window: () => window_,
|
|
3828
|
+
writeFile: () => writeFile2,
|
|
3829
|
+
writeFileSync: () => writeFileSync2
|
|
3830
|
+
});
|
|
3831
|
+
var init_src3 = __esm({
|
|
3832
|
+
"src/index.ts"() {
|
|
3833
|
+
init_fetch_file();
|
|
3834
|
+
init_read_array_buffer();
|
|
3835
|
+
init_read_file();
|
|
3836
|
+
init_write_file();
|
|
3837
|
+
init_loader_options();
|
|
3838
|
+
init_register_loaders();
|
|
3839
|
+
init_select_loader();
|
|
3840
|
+
init_parse();
|
|
3841
|
+
init_parse_sync();
|
|
3842
|
+
init_parse_in_batches();
|
|
3843
|
+
init_load();
|
|
3844
|
+
init_load_in_batches();
|
|
3845
|
+
init_encode_table();
|
|
3846
|
+
init_encode();
|
|
3847
|
+
init_save();
|
|
3848
|
+
init_src2();
|
|
3849
|
+
init_src2();
|
|
3850
|
+
init_make_iterator();
|
|
3851
|
+
init_make_dom_stream();
|
|
3852
|
+
init_null_loader();
|
|
3853
|
+
init_src2();
|
|
3854
|
+
init_fetch_progress();
|
|
3855
|
+
init_browser_filesystem();
|
|
3856
|
+
init_register_loaders();
|
|
3857
|
+
init_src2();
|
|
3858
|
+
init_src2();
|
|
3859
|
+
init_src2();
|
|
3860
|
+
init_src2();
|
|
3861
|
+
init_is_type();
|
|
3862
|
+
}
|
|
3863
|
+
});
|
|
3864
|
+
|
|
3865
|
+
// src/bundle.ts
|
|
3866
|
+
var require_bundle = __commonJS({
|
|
3867
|
+
"src/bundle.ts"(exports, module) {
|
|
3868
|
+
var moduleExports = (init_src3(), src_exports);
|
|
3869
|
+
globalThis.loaders = globalThis.loaders || {};
|
|
3870
|
+
module.exports = Object.assign(globalThis.loaders, moduleExports);
|
|
3871
|
+
}
|
|
3872
|
+
});
|
|
3873
|
+
require_bundle();
|
|
3874
|
+
})();
|