@loaders.gl/loader-utils 4.1.0-alpha.2 → 4.1.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +31 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/json-loader.js +1 -1
- package/dist/json-loader.js.map +1 -1
- package/dist/lib/binary-utils/get-first-characters.d.ts.map +1 -1
- package/dist/lib/binary-utils/get-first-characters.js.map +1 -1
- package/dist/lib/binary-utils/memory-conversion-utils.d.ts.map +1 -1
- package/dist/lib/binary-utils/memory-conversion-utils.js.map +1 -1
- package/dist/lib/file-provider/file-handle-file.d.ts +11 -3
- package/dist/lib/file-provider/file-handle-file.d.ts.map +1 -1
- package/dist/lib/file-provider/file-handle-file.js +9 -4
- package/dist/lib/file-provider/file-handle-file.js.map +1 -1
- package/dist/lib/files/blob-file.d.ts.map +1 -1
- package/dist/lib/files/blob-file.js.map +1 -1
- package/dist/lib/files/file.d.ts.map +1 -1
- package/dist/lib/files/file.js.map +1 -1
- package/dist/lib/files/http-file.d.ts.map +1 -1
- package/dist/lib/files/http-file.js.map +1 -1
- package/dist/lib/files/node-file-facade.d.ts +5 -1
- package/dist/lib/files/node-file-facade.d.ts.map +1 -1
- package/dist/lib/files/node-file-facade.js +6 -0
- package/dist/lib/files/node-file-facade.js.map +1 -1
- package/dist/lib/filesystems/filesystem.d.ts.map +1 -1
- package/dist/lib/filesystems/filesystem.js.map +1 -1
- package/dist/lib/filesystems/node-filesystem-facade.d.ts.map +1 -1
- package/dist/lib/filesystems/node-filesystem-facade.js.map +1 -1
- package/dist/lib/node/buffer.browser.d.ts.map +1 -1
- package/dist/lib/node/buffer.browser.js.map +1 -1
- package/dist/lib/node/buffer.d.ts.map +1 -1
- package/dist/lib/node/buffer.js.map +1 -1
- package/dist/lib/node/stream.d.ts.map +1 -1
- package/dist/lib/node/stream.js.map +1 -1
- package/dist/lib/option-utils/merge-loader-options.d.ts.map +1 -1
- package/dist/lib/option-utils/merge-loader-options.js +5 -1
- package/dist/lib/option-utils/merge-loader-options.js.map +1 -1
- package/dist/lib/sources/data-source.d.ts.map +1 -1
- package/dist/lib/sources/data-source.js.map +1 -1
- package/dist/lib/sources/image-source.d.ts.map +1 -1
- package/dist/lib/sources/image-source.js.map +1 -1
- package/dist/lib/sources/image-tile-source.d.ts.map +1 -1
- package/dist/lib/sources/image-tile-source.js.map +1 -1
- package/dist/lib/sources/tile-source-adapter.d.ts.map +1 -1
- package/dist/lib/sources/tile-source-adapter.js.map +1 -1
- package/dist/lib/sources/tile-source.d.ts.map +1 -1
- package/dist/lib/sources/tile-source.js.map +1 -1
- package/dist/lib/sources/utils/utils.d.ts.map +1 -1
- package/dist/lib/sources/utils/utils.js.map +1 -1
- package/dist/lib/sources/vector-tile-source.d.ts.map +1 -1
- package/dist/lib/sources/vector-tile-source.js.map +1 -1
- package/dist/loader-types.d.ts +4 -4
- package/dist/loader-types.d.ts.map +1 -1
- package/dist/loader-types.js.map +1 -1
- package/dist/service-types.d.ts.map +1 -1
- package/dist/service-types.js.map +1 -1
- package/dist/writer-types.d.ts +10 -2
- package/dist/writer-types.d.ts.map +1 -1
- package/dist/writer-types.js.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +2 -1
- package/src/lib/binary-utils/get-first-characters.ts +2 -1
- package/src/lib/binary-utils/memory-conversion-utils.ts +2 -1
- package/src/lib/file-provider/file-handle-file.ts +21 -8
- package/src/lib/files/blob-file.ts +2 -1
- package/src/lib/files/file.ts +2 -1
- package/src/lib/files/http-file.ts +2 -1
- package/src/lib/files/node-file-facade.ts +13 -2
- package/src/lib/filesystems/filesystem.ts +2 -1
- package/src/lib/filesystems/node-filesystem-facade.ts +2 -1
- package/src/lib/node/buffer.browser.ts +2 -1
- package/src/lib/node/buffer.ts +2 -1
- package/src/lib/node/stream.ts +2 -1
- package/src/lib/option-utils/merge-loader-options.ts +11 -3
- package/src/lib/sources/data-source.ts +2 -1
- package/src/lib/sources/image-source.ts +2 -1
- package/src/lib/sources/image-tile-source.ts +2 -1
- package/src/lib/sources/tile-source-adapter.ts +2 -1
- package/src/lib/sources/tile-source.ts +2 -1
- package/src/lib/sources/utils/utils.ts +2 -1
- package/src/lib/sources/vector-tile-source.ts +2 -1
- package/src/loader-types.ts +7 -5
- package/src/service-types.ts +2 -1
- package/src/writer-types.ts +15 -4
package/dist/index.cjs
CHANGED
|
@@ -129,13 +129,17 @@ var nodeVersion = matches && parseFloat(matches[1]) || 0;
|
|
|
129
129
|
function mergeLoaderOptions(baseOptions, newOptions) {
|
|
130
130
|
return mergeOptionsRecursively(baseOptions || {}, newOptions);
|
|
131
131
|
}
|
|
132
|
-
function mergeOptionsRecursively(baseOptions, newOptions) {
|
|
132
|
+
function mergeOptionsRecursively(baseOptions, newOptions, level = 0) {
|
|
133
|
+
if (level > 3) {
|
|
134
|
+
return newOptions;
|
|
135
|
+
}
|
|
133
136
|
const options = { ...baseOptions };
|
|
134
137
|
for (const [key, newValue] of Object.entries(newOptions)) {
|
|
135
138
|
if (newValue && typeof newValue === "object" && !Array.isArray(newValue)) {
|
|
136
139
|
options[key] = mergeOptionsRecursively(
|
|
137
140
|
options[key] || {},
|
|
138
|
-
newOptions[key]
|
|
141
|
+
newOptions[key],
|
|
142
|
+
level + 1
|
|
139
143
|
);
|
|
140
144
|
} else {
|
|
141
145
|
options[key] = newOptions[key];
|
|
@@ -1018,6 +1022,14 @@ var NodeFileFacade = class {
|
|
|
1018
1022
|
async stat() {
|
|
1019
1023
|
throw NOT_IMPLEMENTED;
|
|
1020
1024
|
}
|
|
1025
|
+
/** Truncates the file descriptor. Only available on NodeFile. */
|
|
1026
|
+
async truncate(length) {
|
|
1027
|
+
throw NOT_IMPLEMENTED;
|
|
1028
|
+
}
|
|
1029
|
+
/** Append data to a file. Only available on NodeFile. */
|
|
1030
|
+
async append(data) {
|
|
1031
|
+
throw NOT_IMPLEMENTED;
|
|
1032
|
+
}
|
|
1021
1033
|
/** Close the file */
|
|
1022
1034
|
async close() {
|
|
1023
1035
|
}
|
|
@@ -1073,9 +1085,22 @@ var isFileProvider = (fileProvider) => {
|
|
|
1073
1085
|
// src/lib/file-provider/file-handle-file.ts
|
|
1074
1086
|
var FileHandleFile = class {
|
|
1075
1087
|
/** Create a new FileHandleFile */
|
|
1076
|
-
constructor(path) {
|
|
1077
|
-
this.file = new NodeFileFacade(path, "r");
|
|
1078
|
-
|
|
1088
|
+
constructor(path, append = false) {
|
|
1089
|
+
this.file = new NodeFileFacade(path, append ? "a+" : "r");
|
|
1090
|
+
}
|
|
1091
|
+
/**
|
|
1092
|
+
* Truncates the file descriptor.
|
|
1093
|
+
* @param length desired file lenght
|
|
1094
|
+
*/
|
|
1095
|
+
async truncate(length) {
|
|
1096
|
+
await this.file.truncate(length);
|
|
1097
|
+
}
|
|
1098
|
+
/**
|
|
1099
|
+
* Append data to a file.
|
|
1100
|
+
* @param buffer data to append
|
|
1101
|
+
*/
|
|
1102
|
+
async append(buffer) {
|
|
1103
|
+
await this.file.append(buffer);
|
|
1079
1104
|
}
|
|
1080
1105
|
/** Close file */
|
|
1081
1106
|
async destroy() {
|
|
@@ -1146,7 +1171,7 @@ var FileHandleFile = class {
|
|
|
1146
1171
|
* the length (in bytes) of the data.
|
|
1147
1172
|
*/
|
|
1148
1173
|
get length() {
|
|
1149
|
-
return this.
|
|
1174
|
+
return this.file.bigsize;
|
|
1150
1175
|
}
|
|
1151
1176
|
};
|
|
1152
1177
|
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["parseFromContext","parseSyncFromContext","parseInBatchesFromContext","assert","isBrowser","isWorker","nodeVersion","self","window","global","document","mergeLoaderOptions","createLoaderWorker","parseWithWorker","canParseWithWorker","canEncodeWithWorker","parseJSON","sliceArrayBuffer","concatenateArrayBuffers","concatenateTypedArrays","compareArrayBuffers","padToNBytes","copyToArray","copyArrayBuffer","padStringToByteAlignment","copyStringToDataView","copyBinaryToDataView","copyPaddedArrayBufferToDataView","copyPaddedStringToDataView","getFirstCharacters","getMagicString","makeTextEncoderIterator","makeTextDecoderIterator","makeLineIterator","makeNumberedLineIterator","forEach","concatenateArrayBuffersAsync","default","RequestScheduler","setPathPrefix","getPathPrefix","resolvePath","addAliases","_addAliases","JSONLoader","isBuffer","toBuffer","toArrayBuffer","promisify1","promisify2","path","stream","BlobFile","HttpFile","NodeFileFacade","NodeFile","NodeFileSystemFacade","NodeFilesystem","isFileProvider","FileHandleFile","DataViewFile","DataSource","ImageSource"],"sources":["../src/index.ts"],"sourcesContent":["// loaders.gl
|
|
1
|
+
{"version":3,"file":"index.js","names":["parseFromContext","parseSyncFromContext","parseInBatchesFromContext","assert","isBrowser","isWorker","nodeVersion","self","window","global","document","mergeLoaderOptions","createLoaderWorker","parseWithWorker","canParseWithWorker","canEncodeWithWorker","parseJSON","sliceArrayBuffer","concatenateArrayBuffers","concatenateTypedArrays","compareArrayBuffers","padToNBytes","copyToArray","copyArrayBuffer","padStringToByteAlignment","copyStringToDataView","copyBinaryToDataView","copyPaddedArrayBufferToDataView","copyPaddedStringToDataView","getFirstCharacters","getMagicString","makeTextEncoderIterator","makeTextDecoderIterator","makeLineIterator","makeNumberedLineIterator","forEach","concatenateArrayBuffersAsync","default","RequestScheduler","setPathPrefix","getPathPrefix","resolvePath","addAliases","_addAliases","JSONLoader","isBuffer","toBuffer","toArrayBuffer","promisify1","promisify2","path","stream","BlobFile","HttpFile","NodeFileFacade","NodeFile","NodeFileSystemFacade","NodeFilesystem","isFileProvider","FileHandleFile","DataViewFile","DataSource","ImageSource"],"sources":["../src/index.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// TYPES\n\nexport type {\n // misc\n DataType,\n SyncDataType,\n BatchableDataType,\n // numeric array types\n TypedArray,\n BigTypedArray,\n TypedArrayConstructor,\n BigTypedArrayConstructor,\n NumberArray,\n NumericArray,\n // fetch\n FetchLike\n} from './types';\n\n// loaders\n\nexport type {\n Loader,\n LoaderWithParser,\n LoaderContext,\n LoaderOptions,\n LoaderOptionsType,\n LoaderReturnType,\n LoaderBatchType\n} from './loader-types';\n\nexport {parseFromContext, parseSyncFromContext, parseInBatchesFromContext} from './loader-types';\n\n// writers\n\nexport type {Writer, WriterWithEncoder, WriterOptions, WriterOptionsType} from './writer-types';\n\n// GENERAL UTILS\nexport {assert} from './lib/env-utils/assert';\nexport {\n isBrowser,\n isWorker,\n nodeVersion,\n self,\n window,\n global,\n document\n} from './lib/env-utils/globals';\n\nexport {mergeLoaderOptions} from './lib/option-utils/merge-loader-options';\n\n// LOADERS.GL-SPECIFIC WORKER UTILS\nexport {createLoaderWorker} from './lib/worker-loader-utils/create-loader-worker';\nexport {parseWithWorker, canParseWithWorker} from './lib/worker-loader-utils/parse-with-worker';\nexport {canEncodeWithWorker} from './lib/worker-loader-utils/encode-with-worker';\n\n// PARSER UTILS\nexport {parseJSON} from './lib/parser-utils/parse-json';\n\n// MEMORY COPY UTILS\nexport {\n sliceArrayBuffer,\n concatenateArrayBuffers,\n concatenateTypedArrays,\n compareArrayBuffers\n} from './lib/binary-utils/array-buffer-utils';\nexport {padToNBytes, copyToArray, copyArrayBuffer} from './lib/binary-utils/memory-copy-utils';\nexport {\n padStringToByteAlignment,\n copyStringToDataView,\n copyBinaryToDataView,\n copyPaddedArrayBufferToDataView,\n copyPaddedStringToDataView\n} from './lib/binary-utils/dataview-copy-utils';\nexport {getFirstCharacters, getMagicString} from './lib/binary-utils/get-first-characters';\n\n// ITERATOR UTILS\nexport {\n makeTextEncoderIterator,\n makeTextDecoderIterator,\n makeLineIterator,\n makeNumberedLineIterator\n} from './lib/iterators/text-iterators';\nexport {forEach, concatenateArrayBuffersAsync} from './lib/iterators/async-iteration';\n\n// REQUEST UTILS\nexport {default as RequestScheduler} from './lib/request-utils/request-scheduler';\n\n// PATH HELPERS\nexport {setPathPrefix, getPathPrefix, resolvePath} from './lib/path-utils/file-aliases';\nexport {addAliases as _addAliases} from './lib/path-utils/file-aliases';\n\n// MICRO LOADERS\nexport {JSONLoader} from './json-loader';\n\n// NODE support\n\n// Node.js emulation (can be used in browser)\n\n// Avoid direct use of `Buffer` which pulls in 50KB polyfill\nexport {isBuffer, toBuffer, toArrayBuffer} from './lib/binary-utils/memory-conversion-utils';\n\n// Note.js wrappers (can be safely imported, but not used in browser)\n\n// Use instead of importing 'util' to avoid node dependencies\nexport {promisify1, promisify2} from './lib/node/promisify';\n\n// `path` replacement (avoids bundling big path polyfill)\nimport * as path from './lib/path-utils/path';\nexport {path};\n\n// Use instead of importing 'stream' to avoid node dependencies`\nimport * as stream from './lib/node/stream';\nexport {stream};\n\n// EXPERIMENTAL: FILE SYSTEMS\n\nexport type {ReadableFile, WritableFile, Stat} from './lib/files/file';\nexport {BlobFile} from './lib/files/blob-file';\nexport {HttpFile} from './lib/files/http-file';\nexport {NodeFileFacade as NodeFile} from './lib/files/node-file-facade';\n\nexport type {FileSystem, RandomAccessFileSystem} from './lib/filesystems/filesystem';\nexport {NodeFileSystemFacade as NodeFilesystem} from './lib/filesystems/node-filesystem-facade';\n\n// TODO - replace with ReadableFile\nexport type {FileProvider} from './lib/file-provider/file-provider';\nexport {isFileProvider} from './lib/file-provider/file-provider';\nexport {FileHandleFile} from './lib/file-provider/file-handle-file';\nexport {DataViewFile} from './lib/file-provider/data-view-file';\n\n// EXPERIMENTAL: DATA SOURCES\nexport type {Service} from './service-types';\n\nexport type {DataSourceProps} from './lib/sources/data-source';\nexport {DataSource} from './lib/sources/data-source';\n\nexport type {ImageType} from './lib/sources/utils/image-type';\nexport type {ImageSourceProps, ImageSourceMetadata} from './lib/sources/image-source';\nexport type {GetImageParameters} from './lib/sources/image-source';\nexport {ImageSource} from './lib/sources/image-source';\n\nexport type {\n TileSourceProps,\n TileSourceMetadata,\n GetTileParameters,\n TileLoadParameters\n} from './lib/sources/tile-source';\nexport type {TileSource} from './lib/sources/tile-source';\n\nexport type {ImageTileSource} from './lib/sources/image-tile-source';\n\nexport type {VectorTileSource} from './lib/sources/vector-tile-source';\n"],"mappings":"SAkCQA,gBAAgB,EAAEC,oBAAoB,EAAEC,yBAAyB;AAAA,SAOjEC,MAAM;AAAA,SAEZC,SAAS,EACTC,QAAQ,EACRC,WAAW,EACXC,IAAI,EACJC,MAAM,EACNC,MAAM,EACNC,QAAQ;AAAA,SAGFC,kBAAkB;AAAA,SAGlBC,kBAAkB;AAAA,SAClBC,eAAe,EAAEC,kBAAkB;AAAA,SACnCC,mBAAmB;AAAA,SAGnBC,SAAS;AAAA,SAIfC,gBAAgB,EAChBC,uBAAuB,EACvBC,sBAAsB,EACtBC,mBAAmB;AAAA,SAEbC,WAAW,EAAEC,WAAW,EAAEC,eAAe;AAAA,SAE/CC,wBAAwB,EACxBC,oBAAoB,EACpBC,oBAAoB,EACpBC,+BAA+B,EAC/BC,0BAA0B;AAAA,SAEpBC,kBAAkB,EAAEC,cAAc;AAAA,SAIxCC,uBAAuB,EACvBC,uBAAuB,EACvBC,gBAAgB,EAChBC,wBAAwB;AAAA,SAElBC,OAAO,EAAEC,4BAA4B;AAAA,SAGrCC,OAAO,IAAIC,gBAAgB;AAAA,SAG3BC,aAAa,EAAEC,aAAa,EAAEC,WAAW;AAAA,SACzCC,UAAU,IAAIC,WAAW;AAAA,SAGzBC,UAAU;AAAA,SAOVC,QAAQ,EAAEC,QAAQ,EAAEC,aAAa;AAAA,SAKjCC,UAAU,EAAEC,UAAU;AAAA,OAGvB,KAAKC,IAAI;AAChB,SAAQA,IAAI;AAAE,OAGP,KAAKC,MAAM;AAClB,SAAQA,MAAM;AAAE,SAKRC,QAAQ;AAAA,SACRC,QAAQ;AAAA,SACRC,cAAc,IAAIC,QAAQ;AAAA,SAG1BC,oBAAoB,IAAIC,cAAc;AAAA,SAItCC,cAAc;AAAA,SACdC,cAAc;AAAA,SACdC,YAAY;AAAA,SAMZC,UAAU;AAAA,SAKVC,WAAW"}
|
package/dist/json-loader.js
CHANGED
package/dist/json-loader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-loader.js","names":["VERSION","
|
|
1
|
+
{"version":3,"file":"json-loader.js","names":["VERSION","JSONLoader","name","id","module","version","extensions","mimeTypes","category","text","parseTextSync","parse","arrayBuffer","TextDecoder","decode","options","JSON"],"sources":["../src/json-loader.ts"],"sourcesContent":["import type {LoaderWithParser, LoaderOptions} from './loader-types';\nimport type {Table, TableBatch} from '@loaders.gl/schema';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport type JSONLoaderOptions = LoaderOptions;\n\n/**\n * A JSON Micro loader (minimal bundle size)\n * Alternative to `@loaders.gl/json`\n */\nexport const JSONLoader: LoaderWithParser<Table, TableBatch, JSONLoaderOptions> = {\n name: 'JSON',\n id: 'json',\n module: 'json',\n version: VERSION,\n extensions: ['json', 'geojson'],\n mimeTypes: ['application/json'],\n category: 'json',\n text: true,\n parseTextSync,\n parse: async (arrayBuffer) => parseTextSync(new TextDecoder().decode(arrayBuffer)),\n options: {}\n};\n\n// TODO - Better error handling!\nfunction parseTextSync(text) {\n return JSON.parse(text);\n}\n"],"mappings":"AAKA,MAAMA,OAAO,GAAG,sBAAkB,KAAK,WAAW,qBAAiB,QAAQ;AAQ3E,OAAO,MAAMC,UAAkE,GAAG;EAChFC,IAAI,EAAE,MAAM;EACZC,EAAE,EAAE,MAAM;EACVC,MAAM,EAAE,MAAM;EACdC,OAAO,EAAEL,OAAO;EAChBM,UAAU,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC;EAC/BC,SAAS,EAAE,CAAC,kBAAkB,CAAC;EAC/BC,QAAQ,EAAE,MAAM;EAChBC,IAAI,EAAE,IAAI;EACVC,aAAa;EACbC,KAAK,EAAE,MAAOC,WAAW,IAAKF,aAAa,CAAC,IAAIG,WAAW,CAAC,CAAC,CAACC,MAAM,CAACF,WAAW,CAAC,CAAC;EAClFG,OAAO,EAAE,CAAC;AACZ,CAAC;AAGD,SAASL,aAAaA,CAACD,IAAI,EAAE;EAC3B,OAAOO,IAAI,CAACL,KAAK,CAACF,IAAI,CAAC;AACzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-first-characters.d.ts","sourceRoot":"","sources":["../../../src/lib/binary-utils/get-first-characters.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-first-characters.d.ts","sourceRoot":"","sources":["../../../src/lib/binary-utils/get-first-characters.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,EAAE,MAAM,GAAE,MAAU,GAAG,MAAM,CAWzF;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,GACb,MAAM,CAUR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-first-characters.js","names":["getFirstCharacters","data","length","arguments","undefined","slice","ArrayBuffer","isView","getMagicString","buffer","byteOffset","arrayBuffer","byteLength","dataView","DataView","magic","i","String","fromCharCode","getUint8"],"sources":["../../../src/lib/binary-utils/get-first-characters.ts"],"sourcesContent":["// loaders.gl
|
|
1
|
+
{"version":3,"file":"get-first-characters.js","names":["getFirstCharacters","data","length","arguments","undefined","slice","ArrayBuffer","isView","getMagicString","buffer","byteOffset","arrayBuffer","byteLength","dataView","DataView","magic","i","String","fromCharCode","getUint8"],"sources":["../../../src/lib/binary-utils/get-first-characters.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n/**\n * Get the first characters from a binary file (interpret the first bytes as an ASCII string)\n * @param data\n * @param length\n * @returns\n */\nexport function getFirstCharacters(data: string | ArrayBuffer, length: number = 5): string {\n if (typeof data === 'string') {\n return data.slice(0, length);\n } else if (ArrayBuffer.isView(data)) {\n // Typed Arrays can have offsets into underlying buffer\n return getMagicString(data.buffer, data.byteOffset, length);\n } else if (data instanceof ArrayBuffer) {\n const byteOffset = 0;\n return getMagicString(data, byteOffset, length);\n }\n return '';\n}\n\n/**\n * Gets a magic string from a \"file\"\n * Typically used to check or detect file format\n * @param arrayBuffer\n * @param byteOffset\n * @param length\n * @returns\n */\nexport function getMagicString(\n arrayBuffer: ArrayBuffer,\n byteOffset: number,\n length: number\n): string {\n if (arrayBuffer.byteLength <= byteOffset + length) {\n return '';\n }\n const dataView = new DataView(arrayBuffer);\n let magic = '';\n for (let i = 0; i < length; i++) {\n magic += String.fromCharCode(dataView.getUint8(byteOffset + i));\n }\n return magic;\n}\n"],"mappings":"AAUA,OAAO,SAASA,kBAAkBA,CAACC,IAA0B,EAA8B;EAAA,IAA5BC,MAAc,GAAAC,SAAA,CAAAD,MAAA,QAAAC,SAAA,QAAAC,SAAA,GAAAD,SAAA,MAAG,CAAC;EAC/E,IAAI,OAAOF,IAAI,KAAK,QAAQ,EAAE;IAC5B,OAAOA,IAAI,CAACI,KAAK,CAAC,CAAC,EAAEH,MAAM,CAAC;EAC9B,CAAC,MAAM,IAAII,WAAW,CAACC,MAAM,CAACN,IAAI,CAAC,EAAE;IAEnC,OAAOO,cAAc,CAACP,IAAI,CAACQ,MAAM,EAAER,IAAI,CAACS,UAAU,EAAER,MAAM,CAAC;EAC7D,CAAC,MAAM,IAAID,IAAI,YAAYK,WAAW,EAAE;IACtC,MAAMI,UAAU,GAAG,CAAC;IACpB,OAAOF,cAAc,CAACP,IAAI,EAAES,UAAU,EAAER,MAAM,CAAC;EACjD;EACA,OAAO,EAAE;AACX;AAUA,OAAO,SAASM,cAAcA,CAC5BG,WAAwB,EACxBD,UAAkB,EAClBR,MAAc,EACN;EACR,IAAIS,WAAW,CAACC,UAAU,IAAIF,UAAU,GAAGR,MAAM,EAAE;IACjD,OAAO,EAAE;EACX;EACA,MAAMW,QAAQ,GAAG,IAAIC,QAAQ,CAACH,WAAW,CAAC;EAC1C,IAAII,KAAK,GAAG,EAAE;EACd,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGd,MAAM,EAAEc,CAAC,EAAE,EAAE;IAC/BD,KAAK,IAAIE,MAAM,CAACC,YAAY,CAACL,QAAQ,CAACM,QAAQ,CAACT,UAAU,GAAGM,CAAC,CAAC,CAAC;EACjE;EACA,OAAOD,KAAK;AACd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory-conversion-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/binary-utils/memory-conversion-utils.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"memory-conversion-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/binary-utils/memory-conversion-utils.ts"],"names":[],"mappings":";AAMA;;GAEG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAE5C;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,CAE1C;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,WAAW,CA8BxD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory-conversion-utils.js","names":["node","isBuffer","value","toBuffer","data","toArrayBuffer","ArrayBuffer","isView","byteOffset","byteLength","buffer","slice","text","uint8Array","TextEncoder","encode","_toArrayBuffer","Error"],"sources":["../../../src/lib/binary-utils/memory-conversion-utils.ts"],"sourcesContent":["// loaders.gl
|
|
1
|
+
{"version":3,"file":"memory-conversion-utils.js","names":["node","isBuffer","value","toBuffer","data","toArrayBuffer","ArrayBuffer","isView","byteOffset","byteLength","buffer","slice","text","uint8Array","TextEncoder","encode","_toArrayBuffer","Error"],"sources":["../../../src/lib/binary-utils/memory-conversion-utils.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport * as node from '../node/buffer';\n\n/**\n * Check for Node.js `Buffer` (without triggering bundler to include Buffer polyfill on browser)\n */\nexport function isBuffer(value: any): boolean {\n return value && typeof value === 'object' && value.isBuffer;\n}\n\n/**\n * Converts to Node.js `Buffer` (without triggering bundler to include Buffer polyfill on browser)\n * @todo better data type\n */\nexport function toBuffer(data: any): Buffer {\n return node.toBuffer ? node.toBuffer(data) : data;\n}\n\n/**\n * Convert an object to an array buffer\n */\nexport function toArrayBuffer(data: unknown): ArrayBuffer {\n // Note: Should be called first, Buffers can trigger other detections below\n if (isBuffer(data)) {\n return node.toArrayBuffer(data);\n }\n\n if (data instanceof ArrayBuffer) {\n return data;\n }\n\n // Careful - Node Buffers look like Uint8Arrays (keep after isBuffer)\n if (ArrayBuffer.isView(data)) {\n if (data.byteOffset === 0 && data.byteLength === data.buffer.byteLength) {\n return data.buffer;\n }\n return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);\n }\n\n if (typeof data === 'string') {\n const text = data;\n const uint8Array = new TextEncoder().encode(text);\n return uint8Array.buffer;\n }\n\n // HACK to support Blob polyfill\n if (data && typeof data === 'object' && (data as any)._toArrayBuffer) {\n return (data as any)._toArrayBuffer();\n }\n\n throw new Error('toArrayBuffer');\n}\n"],"mappings":"OAIO,KAAKA,IAAI;AAKhB,OAAO,SAASC,QAAQA,CAACC,KAAU,EAAW;EAC5C,OAAOA,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,CAACD,QAAQ;AAC7D;AAMA,OAAO,SAASE,QAAQA,CAACC,IAAS,EAAU;EAC1C,OAAOJ,IAAI,CAACG,QAAQ,GAAGH,IAAI,CAACG,QAAQ,CAACC,IAAI,CAAC,GAAGA,IAAI;AACnD;AAKA,OAAO,SAASC,aAAaA,CAACD,IAAa,EAAe;EAExD,IAAIH,QAAQ,CAACG,IAAI,CAAC,EAAE;IAClB,OAAOJ,IAAI,CAACK,aAAa,CAACD,IAAI,CAAC;EACjC;EAEA,IAAIA,IAAI,YAAYE,WAAW,EAAE;IAC/B,OAAOF,IAAI;EACb;EAGA,IAAIE,WAAW,CAACC,MAAM,CAACH,IAAI,CAAC,EAAE;IAC5B,IAAIA,IAAI,CAACI,UAAU,KAAK,CAAC,IAAIJ,IAAI,CAACK,UAAU,KAAKL,IAAI,CAACM,MAAM,CAACD,UAAU,EAAE;MACvE,OAAOL,IAAI,CAACM,MAAM;IACpB;IACA,OAAON,IAAI,CAACM,MAAM,CAACC,KAAK,CAACP,IAAI,CAACI,UAAU,EAAEJ,IAAI,CAACI,UAAU,GAAGJ,IAAI,CAACK,UAAU,CAAC;EAC9E;EAEA,IAAI,OAAOL,IAAI,KAAK,QAAQ,EAAE;IAC5B,MAAMQ,IAAI,GAAGR,IAAI;IACjB,MAAMS,UAAU,GAAG,IAAIC,WAAW,CAAC,CAAC,CAACC,MAAM,CAACH,IAAI,CAAC;IACjD,OAAOC,UAAU,CAACH,MAAM;EAC1B;EAGA,IAAIN,IAAI,IAAI,OAAOA,IAAI,KAAK,QAAQ,IAAKA,IAAI,CAASY,cAAc,EAAE;IACpE,OAAQZ,IAAI,CAASY,cAAc,CAAC,CAAC;EACvC;EAEA,MAAM,IAAIC,KAAK,CAAC,eAAe,CAAC;AAClC"}
|
|
@@ -6,10 +6,18 @@ import { FileProvider } from './file-provider';
|
|
|
6
6
|
export declare class FileHandleFile implements FileProvider {
|
|
7
7
|
/** The FileHandle from which data is provided */
|
|
8
8
|
private file;
|
|
9
|
-
/** The file length in bytes */
|
|
10
|
-
private size;
|
|
11
9
|
/** Create a new FileHandleFile */
|
|
12
|
-
constructor(path: string);
|
|
10
|
+
constructor(path: string, append?: boolean);
|
|
11
|
+
/**
|
|
12
|
+
* Truncates the file descriptor.
|
|
13
|
+
* @param length desired file lenght
|
|
14
|
+
*/
|
|
15
|
+
truncate(length: number): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Append data to a file.
|
|
18
|
+
* @param buffer data to append
|
|
19
|
+
*/
|
|
20
|
+
append(buffer: Uint8Array): Promise<void>;
|
|
13
21
|
/** Close file */
|
|
14
22
|
destroy(): Promise<void>;
|
|
15
23
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-handle-file.d.ts","sourceRoot":"","sources":["../../../src/lib/file-provider/file-handle-file.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"file-handle-file.d.ts","sourceRoot":"","sources":["../../../src/lib/file-provider/file-handle-file.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAG7C;;;GAGG;AACH,qBAAa,cAAe,YAAW,YAAY;IACjD,iDAAiD;IACjD,OAAO,CAAC,IAAI,CAAW;IAEvB,kCAAkC;gBACtB,IAAI,EAAE,MAAM,EAAE,MAAM,GAAE,OAAe;IAIjD;;;OAGG;IACG,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7C;;;OAGG;IACG,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/C,iBAAiB;IACX,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9B;;;OAGG;IACG,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IASxD;;;OAGG;IACG,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IASzD;;;OAGG;IACG,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IASzD;;;OAGG;IACG,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAS5D;;;;OAIG;IACG,KAAK,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IASzE;;OAEG;IACH,IAAI,MAAM,IAAI,MAAM,CAEnB;CACF"}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { NodeFileFacade as NodeFile } from "../files/node-file-facade.js";
|
|
2
2
|
export class FileHandleFile {
|
|
3
3
|
constructor(path) {
|
|
4
|
+
let append = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
4
5
|
this.file = void 0;
|
|
5
|
-
this.
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
this.file = new NodeFile(path, append ? 'a+' : 'r');
|
|
7
|
+
}
|
|
8
|
+
async truncate(length) {
|
|
9
|
+
await this.file.truncate(length);
|
|
10
|
+
}
|
|
11
|
+
async append(buffer) {
|
|
12
|
+
await this.file.append(buffer);
|
|
8
13
|
}
|
|
9
14
|
async destroy() {
|
|
10
15
|
await this.file.close();
|
|
@@ -50,7 +55,7 @@ export class FileHandleFile {
|
|
|
50
55
|
return await this.file.read(startOffset, length);
|
|
51
56
|
}
|
|
52
57
|
get length() {
|
|
53
|
-
return this.
|
|
58
|
+
return this.file.bigsize;
|
|
54
59
|
}
|
|
55
60
|
}
|
|
56
61
|
//# sourceMappingURL=file-handle-file.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-handle-file.js","names":["NodeFileFacade","NodeFile","FileHandleFile","constructor","path","file","
|
|
1
|
+
{"version":3,"file":"file-handle-file.js","names":["NodeFileFacade","NodeFile","FileHandleFile","constructor","path","append","arguments","length","undefined","file","truncate","buffer","destroy","close","getUint8","offset","arrayBuffer","read","val","Uint8Array","at","Error","getUint16","Uint16Array","getUint32","Uint32Array","getBigUint64","BigInt64Array","slice","startOffset","endOffset","bigLength","Number","MAX_SAFE_INTEGER","bigsize"],"sources":["../../../src/lib/file-provider/file-handle-file.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {FileProvider} from './file-provider';\nimport {NodeFileFacade as NodeFile} from '../files/node-file-facade';\n\n/**\n * Provides file data using node fs library\n * @deprecated - will be replaced with ReadableFile\n */\nexport class FileHandleFile implements FileProvider {\n /** The FileHandle from which data is provided */\n private file: NodeFile;\n\n /** Create a new FileHandleFile */\n constructor(path: string, append: boolean = false) {\n this.file = new NodeFile(path, append ? 'a+' : 'r');\n }\n\n /**\n * Truncates the file descriptor.\n * @param length desired file lenght\n */\n async truncate(length: number): Promise<void> {\n await this.file.truncate(length);\n }\n\n /**\n * Append data to a file.\n * @param buffer data to append\n */\n async append(buffer: Uint8Array): Promise<void> {\n await this.file.append(buffer);\n }\n\n /** Close file */\n async destroy(): Promise<void> {\n await this.file.close();\n }\n\n /**\n * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getUint8(offset: number | bigint): Promise<number> {\n const arrayBuffer = await this.file.read(offset, 1);\n const val = new Uint8Array(arrayBuffer).at(0);\n if (val === undefined) {\n throw new Error('something went wrong');\n }\n return val;\n }\n\n /**\n * Gets an unsigned 16-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getUint16(offset: number | bigint): Promise<number> {\n const arrayBuffer = await this.file.read(offset, 2);\n const val = new Uint16Array(arrayBuffer).at(0);\n if (val === undefined) {\n throw new Error('something went wrong');\n }\n return val;\n }\n\n /**\n * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getUint32(offset: number | bigint): Promise<number> {\n const arrayBuffer = await this.file.read(offset, 4);\n const val = new Uint32Array(arrayBuffer).at(0);\n if (val === undefined) {\n throw new Error('something went wrong');\n }\n return val;\n }\n\n /**\n * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getBigUint64(offset: number | bigint): Promise<bigint> {\n const arrayBuffer = await this.file.read(offset, 8);\n const val = new BigInt64Array(arrayBuffer).at(0);\n if (val === undefined) {\n throw new Error('something went wrong');\n }\n return val;\n }\n\n /**\n * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.\n * @param startOffset The offset, in byte, from the start of the file where to start reading the data.\n * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.\n */\n async slice(startOffset: bigint, endOffset: bigint): Promise<ArrayBuffer> {\n const bigLength = endOffset - startOffset;\n if (bigLength > Number.MAX_SAFE_INTEGER) {\n throw new Error('too big slice');\n }\n const length = Number(bigLength);\n return await this.file.read(startOffset, length);\n }\n\n /**\n * the length (in bytes) of the data.\n */\n get length(): bigint {\n return this.file.bigsize;\n }\n}\n"],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blob-file.d.ts","sourceRoot":"","sources":["../../../src/lib/files/blob-file.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"blob-file.d.ts","sourceRoot":"","sources":["../../../src/lib/files/blob-file.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,YAAY,EAAC,MAAM,QAAQ,CAAC;AAEpC;;GAEG;AACH,qBAAa,QAAS,YAAW,YAAY;IAC3C,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;gBAET,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,WAAW;IAOrC,KAAK;IAEL,IAAI;;;;;IAQJ,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;CAIhE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blob-file.js","names":["BlobFile","constructor","blob","handle","size","bigsize","url","ArrayBuffer","Blob","byteLength","BigInt","File","name","close","stat","isDirectory","read","start","length","arrayBuffer","slice"],"sources":["../../../src/lib/files/blob-file.ts"],"sourcesContent":["// loaders.gl
|
|
1
|
+
{"version":3,"file":"blob-file.js","names":["BlobFile","constructor","blob","handle","size","bigsize","url","ArrayBuffer","Blob","byteLength","BigInt","File","name","close","stat","isDirectory","read","start","length","arrayBuffer","slice"],"sources":["../../../src/lib/files/blob-file.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {ReadableFile} from './file';\n\n/**\n * BlobFile provides a \"file like interface\" to the data in a Blob or File object\n */\nexport class BlobFile implements ReadableFile {\n readonly handle: Blob;\n readonly size: number;\n readonly bigsize: bigint;\n readonly url: string;\n\n constructor(blob: Blob | File | ArrayBuffer) {\n this.handle = blob instanceof ArrayBuffer ? new Blob([blob]) : blob;\n this.size = blob instanceof ArrayBuffer ? blob.byteLength : blob.size;\n this.bigsize = BigInt(this.size);\n this.url = blob instanceof File ? blob.name : '';\n }\n\n async close() {}\n\n async stat() {\n return {\n size: this.handle.size,\n bigsize: BigInt(this.handle.size),\n isDirectory: false\n };\n }\n\n async read(start: number, length: number): Promise<ArrayBuffer> {\n const arrayBuffer = await this.handle.slice(start, start + length).arrayBuffer();\n return arrayBuffer;\n }\n}\n"],"mappings":"AASA,OAAO,MAAMA,QAAQ,CAAyB;EAM5CC,WAAWA,CAACC,IAA+B,EAAE;IAAA,KALpCC,MAAM;IAAA,KACNC,IAAI;IAAA,KACJC,OAAO;IAAA,KACPC,GAAG;IAGV,IAAI,CAACH,MAAM,GAAGD,IAAI,YAAYK,WAAW,GAAG,IAAIC,IAAI,CAAC,CAACN,IAAI,CAAC,CAAC,GAAGA,IAAI;IACnE,IAAI,CAACE,IAAI,GAAGF,IAAI,YAAYK,WAAW,GAAGL,IAAI,CAACO,UAAU,GAAGP,IAAI,CAACE,IAAI;IACrE,IAAI,CAACC,OAAO,GAAGK,MAAM,CAAC,IAAI,CAACN,IAAI,CAAC;IAChC,IAAI,CAACE,GAAG,GAAGJ,IAAI,YAAYS,IAAI,GAAGT,IAAI,CAACU,IAAI,GAAG,EAAE;EAClD;EAEA,MAAMC,KAAKA,CAAA,EAAG,CAAC;EAEf,MAAMC,IAAIA,CAAA,EAAG;IACX,OAAO;MACLV,IAAI,EAAE,IAAI,CAACD,MAAM,CAACC,IAAI;MACtBC,OAAO,EAAEK,MAAM,CAAC,IAAI,CAACP,MAAM,CAACC,IAAI,CAAC;MACjCW,WAAW,EAAE;IACf,CAAC;EACH;EAEA,MAAMC,IAAIA,CAACC,KAAa,EAAEC,MAAc,EAAwB;IAC9D,MAAMC,WAAW,GAAG,MAAM,IAAI,CAAChB,MAAM,CAACiB,KAAK,CAACH,KAAK,EAAEA,KAAK,GAAGC,MAAM,CAAC,CAACC,WAAW,CAAC,CAAC;IAChF,OAAOA,WAAW;EACpB;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../../src/lib/files/file.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../../src/lib/files/file.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,IAAI,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,MAAM,WAAW,YAAY;IAC3B,qEAAqE;IACrE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,4CAA4C;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,4CAA4C;IAC5C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,wBAAwB;IACxB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB,gBAAgB;IAChB,IAAI,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IACrE,gBAAgB;IAChB,UAAU,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC9F,iCAAiC;IACjC,IAAI,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,qBAAqB;IACrB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,OAAO,CAAC;IAChB,kEAAkE;IAClE,KAAK,EAAE,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAChG,qCAAqC;IACrC,IAAI,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,qBAAqB;IACrB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.js","names":[],"sources":["../../../src/lib/files/file.ts"],"sourcesContent":["// loaders.gl
|
|
1
|
+
{"version":3,"file":"file.js","names":[],"sources":["../../../src/lib/files/file.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nexport type Stat = {\n size: number;\n bigsize: bigint;\n isDirectory: boolean;\n};\n\nexport interface ReadableFile {\n /** The underlying file handle (Blob, Node.js file descriptor etc) */\n readonly handle: unknown;\n /** Length of file in bytes, if available */\n readonly size: number;\n /** Length of file in bytes, if available */\n readonly bigsize: bigint;\n /** Url, if available */\n readonly url: string;\n\n /** Read data */\n read(start?: number | bigint, length?: number): Promise<ArrayBuffer>;\n /** Read data */\n fetchRange?(offset: number | bigint, length: number, signal?: AbortSignal): Promise<Response>;\n /** Get information about file */\n stat?(): Promise<Stat>;\n /** Close the file */\n close(): Promise<void>;\n}\n\nexport interface WritableFile {\n handle: unknown;\n /** Write to file. The number of bytes written will be returned */\n write: (arrayBuffer: ArrayBuffer, offset?: number | bigint, length?: number) => Promise<number>;\n /** Get information about the file */\n stat?(): Promise<Stat>;\n /** Close the file */\n close(): Promise<void>;\n}\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-file.d.ts","sourceRoot":"","sources":["../../../src/lib/files/http-file.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"http-file.d.ts","sourceRoot":"","sources":["../../../src/lib/files/http-file.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,YAAY,EAAE,IAAI,EAAC,MAAM,QAAQ,CAAC;AAE1C,qBAAa,QAAS,YAAW,YAAY;IAC3C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAK;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAM;IAC9B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;gBAET,GAAG,EAAE,MAAM;IAKjB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAEtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAarB,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAMzE;;;;;;;OAOG;IAEG,UAAU,CACd,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,QAAQ,CAAC;CAsErB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-file.js","names":["HttpFile","constructor","url","handle","size","bigsize","close","stat","response","fetch","method","ok","Error","parseInt","headers","get","BigInt","isDirectory","read","offset","length","fetchRange","arrayBuffer","signal","nOffset","Number","nLength","controller","AbortController","Range","status","contentLength","abort","contentRange","startsWith","actualLength","substr"],"sources":["../../../src/lib/files/http-file.ts"],"sourcesContent":["// loaders.gl
|
|
1
|
+
{"version":3,"file":"http-file.js","names":["HttpFile","constructor","url","handle","size","bigsize","close","stat","response","fetch","method","ok","Error","parseInt","headers","get","BigInt","isDirectory","read","offset","length","fetchRange","arrayBuffer","signal","nOffset","Number","nLength","controller","AbortController","Range","status","contentLength","abort","contentRange","startsWith","actualLength","substr"],"sources":["../../../src/lib/files/http-file.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {ReadableFile, Stat} from './file';\n\nexport class HttpFile implements ReadableFile {\n readonly handle: string;\n readonly size: number = 0;\n readonly bigsize: bigint = 0n;\n readonly url: string;\n\n constructor(url: string) {\n this.handle = url;\n this.url = url;\n }\n\n async close(): Promise<void> {}\n\n async stat(): Promise<Stat> {\n const response = await fetch(this.handle, {method: 'HEAD'});\n if (!response.ok) {\n throw new Error(`Failed to fetch HEAD ${this.handle}`);\n }\n const size = parseInt(response.headers.get('Content-Length') || '0');\n return {\n size,\n bigsize: BigInt(size),\n isDirectory: false\n };\n }\n\n async read(offset: number | bigint, length: number): Promise<ArrayBuffer> {\n const response = await this.fetchRange(offset, length);\n const arrayBuffer = await response.arrayBuffer();\n return arrayBuffer;\n }\n\n /**\n *\n * @param offset\n * @param length\n * @param signal\n * @returns\n * @see https://github.com/protomaps/PMTiles\n */\n // eslint-disable-next-line complexity\n async fetchRange(\n offset: number | bigint,\n length: number,\n signal?: AbortSignal\n ): Promise<Response> {\n const nOffset = Number(offset);\n const nLength = Number(length);\n\n let controller: AbortController | undefined;\n if (!signal) {\n // ToDO why is it so important to abort in case 200?\n // TODO check this works or assert 206\n controller = new AbortController();\n signal = controller.signal;\n }\n\n const url = this.handle;\n let response = await fetch(url, {\n signal,\n headers: {Range: `bytes=${nOffset}-${nOffset + nLength - 1}`}\n });\n\n switch (response.status) {\n case 206: // Partial Content success\n // This is the expected success code for a range request\n break;\n\n case 200:\n // some well-behaved backends, e.g. DigitalOcean CDN, respond with 200 instead of 206\n // but we also need to detect no support for Byte Serving which is returning the whole file\n const contentLength = response.headers.get('Content-Length');\n if (!contentLength || Number(contentLength) > length) {\n if (controller) {\n controller.abort();\n }\n throw Error(\n 'content-length header missing or exceeding request. Server must support HTTP Byte Serving.'\n );\n }\n\n // @eslint-disable-next-line no-fallthrough\n case 416: // \"Range Not Satisfiable\"\n // some HTTP servers don't accept ranges beyond the end of the resource.\n // Retry with the exact length\n // TODO: can return 416 with offset > 0 if content changed, which will have a blank etag.\n // See https://github.com/protomaps/PMTiles/issues/90\n if (offset === 0) {\n const contentRange = response.headers.get('Content-Range');\n if (!contentRange || !contentRange.startsWith('bytes *')) {\n throw Error('Missing content-length on 416 response');\n }\n const actualLength = Number(contentRange.substr(8));\n response = await fetch(this.url, {\n signal,\n headers: {Range: `bytes=0-${actualLength - 1}`}\n });\n }\n break;\n\n default:\n if (response.status >= 300) {\n throw Error(`Bad response code: ${response.status}`);\n }\n }\n\n return response;\n // const data = await response.arrayBuffer();\n // return {\n // data,\n // etag: response.headers.get('ETag') || undefined,\n // cacheControl: response.headers.get('Cache-Control') || undefined,\n // expires: response.headers.get('Expires') || undefined\n // };\n }\n}\n"],"mappings":"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"}
|
|
@@ -5,13 +5,17 @@ export declare class NodeFileFacade implements ReadableFile, WritableFile {
|
|
|
5
5
|
size: number;
|
|
6
6
|
bigsize: bigint;
|
|
7
7
|
url: string;
|
|
8
|
-
constructor(url: string, flags?: 'r' | 'w' | 'wx', mode?: number);
|
|
8
|
+
constructor(url: string, flags?: 'r' | 'w' | 'wx' | 'a+', mode?: number);
|
|
9
9
|
/** Read data */
|
|
10
10
|
read(start?: number | bigint, end?: number | bigint): Promise<ArrayBuffer>;
|
|
11
11
|
/** Write to file. The number of bytes written will be returned */
|
|
12
12
|
write(arrayBuffer: ArrayBuffer, offset?: number | bigint, length?: number | bigint): Promise<number>;
|
|
13
13
|
/** Get information about file */
|
|
14
14
|
stat(): Promise<Stat>;
|
|
15
|
+
/** Truncates the file descriptor. Only available on NodeFile. */
|
|
16
|
+
truncate(length: number): Promise<void>;
|
|
17
|
+
/** Append data to a file. Only available on NodeFile. */
|
|
18
|
+
append(data: Uint8Array): Promise<void>;
|
|
15
19
|
/** Close the file */
|
|
16
20
|
close(): Promise<void>;
|
|
17
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-file-facade.d.ts","sourceRoot":"","sources":["../../../src/lib/files/node-file-facade.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"node-file-facade.d.ts","sourceRoot":"","sources":["../../../src/lib/files/node-file-facade.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,YAAY,EAAE,YAAY,EAAE,IAAI,EAAC,MAAM,QAAQ,CAAC;AAIxD,kFAAkF;AAClF,qBAAa,cAAe,YAAW,YAAY,EAAE,YAAY;IAC/D,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,MAAM,CAAK;IACjB,OAAO,EAAE,MAAM,CAAM;IACrB,GAAG,EAAE,MAAM,CAAM;gBAEL,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,EAAE,IAAI,CAAC,EAAE,MAAM;IAUvE,gBAAgB;IACV,IAAI,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAGhF,kEAAkE;IAC5D,KAAK,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAG1G,iCAAiC;IAC3B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,iEAAiE;IAC3D,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7C,yDAAyD;IACnD,MAAM,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAG7C,qBAAqB;IACf,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAC7B"}
|
|
@@ -24,6 +24,12 @@ export class NodeFileFacade {
|
|
|
24
24
|
async stat() {
|
|
25
25
|
throw NOT_IMPLEMENTED;
|
|
26
26
|
}
|
|
27
|
+
async truncate(length) {
|
|
28
|
+
throw NOT_IMPLEMENTED;
|
|
29
|
+
}
|
|
30
|
+
async append(data) {
|
|
31
|
+
throw NOT_IMPLEMENTED;
|
|
32
|
+
}
|
|
27
33
|
async close() {}
|
|
28
34
|
}
|
|
29
35
|
//# sourceMappingURL=node-file-facade.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-file-facade.js","names":["isBrowser","NOT_IMPLEMENTED","Error","NodeFileFacade","constructor","url","flags","mode","_globalThis$loaders","handle","size","bigsize","globalThis","loaders","NodeFile","read","start","end","write","arrayBuffer","offset","length","stat","close"],"sources":["../../../src/lib/files/node-file-facade.ts"],"sourcesContent":["// loaders.gl
|
|
1
|
+
{"version":3,"file":"node-file-facade.js","names":["isBrowser","NOT_IMPLEMENTED","Error","NodeFileFacade","constructor","url","flags","mode","_globalThis$loaders","handle","size","bigsize","globalThis","loaders","NodeFile","read","start","end","write","arrayBuffer","offset","length","stat","truncate","append","data","close"],"sources":["../../../src/lib/files/node-file-facade.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {isBrowser} from '../env-utils/globals';\nimport {ReadableFile, WritableFile, Stat} from './file';\n\nconst NOT_IMPLEMENTED = new Error('Not implemented');\n\n/** This class is a facade that gets replaced with an actual NodeFile instance */\nexport class NodeFileFacade implements ReadableFile, WritableFile {\n handle: unknown;\n size: number = 0;\n bigsize: bigint = 0n;\n url: string = '';\n\n constructor(url: string, flags?: 'r' | 'w' | 'wx' | 'a+', mode?: number) {\n // Return the actual implementation instance\n if (globalThis.loaders?.NodeFile) {\n return new globalThis.loaders.NodeFile(url, flags, mode);\n }\n if (isBrowser) {\n throw new Error('Can\\'t instantiate NodeFile in browser.');\n }\n throw new Error('Can\\'t instantiate NodeFile. Make sure to import @loaders.gl/polyfills first.');\n }\n /** Read data */\n async read(start?: number | bigint, end?: number | bigint): Promise<ArrayBuffer> {\n throw NOT_IMPLEMENTED;\n }\n /** Write to file. The number of bytes written will be returned */\n async write(arrayBuffer: ArrayBuffer, offset?: number | bigint, length?: number | bigint): Promise<number> {\n throw NOT_IMPLEMENTED;\n }\n /** Get information about file */\n async stat(): Promise<Stat> {\n throw NOT_IMPLEMENTED;\n }\n\n /** Truncates the file descriptor. Only available on NodeFile. */\n async truncate(length: number): Promise<void> {\n throw NOT_IMPLEMENTED;\n }\n\n /** Append data to a file. Only available on NodeFile. */\n async append(data: Uint8Array): Promise<void> {\n throw NOT_IMPLEMENTED;\n }\n /** Close the file */\n async close(): Promise<void> {}\n}\n"],"mappings":"SAIQA,SAAS;AAGjB,MAAMC,eAAe,GAAG,IAAIC,KAAK,CAAC,iBAAiB,CAAC;AAGpD,OAAO,MAAMC,cAAc,CAAuC;EAMhEC,WAAWA,CAACC,GAAW,EAAEC,KAA+B,EAAEC,IAAa,EAAE;IAAA,IAAAC,mBAAA;IAAA,KALzEC,MAAM;IAAA,KACNC,IAAI,GAAW,CAAC;IAAA,KAChBC,OAAO,GAAW,EAAE;IAAA,KACpBN,GAAG,GAAW,EAAE;IAId,KAAAG,mBAAA,GAAII,UAAU,CAACC,OAAO,cAAAL,mBAAA,eAAlBA,mBAAA,CAAoBM,QAAQ,EAAE;MAChC,OAAO,IAAIF,UAAU,CAACC,OAAO,CAACC,QAAQ,CAACT,GAAG,EAAEC,KAAK,EAAEC,IAAI,CAAC;IAC1D;IACA,IAAIP,SAAS,EAAE;MACb,MAAM,IAAIE,KAAK,CAAC,yCAAyC,CAAC;IAC5D;IACA,MAAM,IAAIA,KAAK,CAAC,+EAA+E,CAAC;EAClG;EAEA,MAAMa,IAAIA,CAACC,KAAuB,EAAEC,GAAqB,EAAwB;IAC/E,MAAMhB,eAAe;EACvB;EAEA,MAAMiB,KAAKA,CAACC,WAAwB,EAAEC,MAAwB,EAAEC,MAAwB,EAAmB;IACzG,MAAMpB,eAAe;EACvB;EAEA,MAAMqB,IAAIA,CAAA,EAAkB;IAC1B,MAAMrB,eAAe;EACvB;EAGA,MAAMsB,QAAQA,CAACF,MAAc,EAAiB;IAC5C,MAAMpB,eAAe;EACvB;EAGA,MAAMuB,MAAMA,CAACC,IAAgB,EAAiB;IAC5C,MAAMxB,eAAe;EACvB;EAEA,MAAMyB,KAAKA,CAAA,EAAkB,CAAC;AAChC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filesystem.d.ts","sourceRoot":"","sources":["../../../src/lib/filesystems/filesystem.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"filesystem.d.ts","sourceRoot":"","sources":["../../../src/lib/filesystems/filesystem.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,YAAY,EAAE,YAAY,EAAC,MAAM,eAAe,CAAC;AAEzD;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,mDAAmD;IACnD,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAC,SAAS,CAAC,EAAE,OAAO,CAAA;KAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAE9E,6DAA6D;IAC7D,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,CAAC,CAAC;IAElE,0CAA0C;IAC1C,MAAM,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAErC,yEAAyE;IACzE,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC/D;AAED;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,UAAU;IACxD,8BAA8B;IAC9B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAE3B,8BAA8B;IAC9B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAE3B,2BAA2B;IAC3B,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IAEnE,2BAA2B;IAC3B,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,IAAI,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CAC1F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filesystem.js","names":[],"sources":["../../../src/lib/filesystems/filesystem.ts"],"sourcesContent":["// loaders.gl
|
|
1
|
+
{"version":3,"file":"filesystem.js","names":[],"sources":["../../../src/lib/filesystems/filesystem.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {ReadableFile, WritableFile} from '../files/file';\n\n/**\n * A FileSystem interface can encapsulate various file sources,\n * a FileList, a Node.js filesystem, a ZipFile, a GoogleDrive etc.\n */\nexport interface FileSystem {\n /** Return a list of file names in a \"directory\" */\n readdir(dirname?: string, options?: {recursive?: boolean}): Promise<string[]>;\n\n /** Gets information from a local file from the filesystem */\n stat(filename: string, options?: object): Promise<{size: number}>;\n\n /** Removes a file from the file system */\n unlink?(path: string): Promise<void>;\n\n /** Fetches the full contents of a file from the filesystem (or a URL) */\n fetch(path: string, options?: RequestInit): Promise<Response>;\n}\n\n/**\n * A random access file system, open readable and/or writable files\n */\nexport interface RandomAccessFileSystem extends FileSystem {\n /** Can open readable files */\n readonly readable: boolean;\n\n /** Can open writable files */\n readonly writable: boolean;\n\n /** Open a readable file */\n openReadableFile(path: string, flags?: 'r'): Promise<ReadableFile>;\n\n /** Open a writable file */\n openWritableFile(path: string, flags?: 'w' | 'wx', mode?: number): Promise<WritableFile>;\n}\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-filesystem-facade.d.ts","sourceRoot":"","sources":["../../../src/lib/filesystems/node-filesystem-facade.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"node-filesystem-facade.d.ts","sourceRoot":"","sources":["../../../src/lib/filesystems/node-filesystem-facade.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,IAAI,EAAC,MAAM,eAAe,CAAC;AACnC,OAAO,EAAC,cAAc,IAAI,QAAQ,EAAC,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAC,sBAAsB,EAAC,MAAM,cAAc,CAAC;AAIpD;;;;;GAKG;AACH,qBAAa,oBAAqB,YAAW,sBAAsB;gBAErD,OAAO,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC;IAgBzC,QAAQ,CAAC,QAAQ,QAAQ;IACzB,QAAQ,CAAC,QAAQ,QAAQ;IAEnB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,KAAA,GAAG,OAAO,CAAC,QAAQ,CAAC;IAKxD,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,KAAA,EAAE,IAAI,KAAA,GAAG,OAAO,CAAC,QAAQ,CAAC;IAM9D,OAAO,CAAC,OAAO,SAAM,EAAE,OAAO,CAAC,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAIvD,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/C,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAInC,KAAK,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC;CAGzE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-filesystem-facade.js","names":["isBrowser","NOT_IMPLEMENTED","Error","NodeFileSystemFacade","constructor","options","_globalThis$loaders","readable","writable","globalThis","loaders","NodeFileSystem","openReadableFile","path","flags","openWritableFile","mode","readdir","dirname","arguments","length","undefined","stat","unlink","fetch"],"sources":["../../../src/lib/filesystems/node-filesystem-facade.ts"],"sourcesContent":["// loaders.gl
|
|
1
|
+
{"version":3,"file":"node-filesystem-facade.js","names":["isBrowser","NOT_IMPLEMENTED","Error","NodeFileSystemFacade","constructor","options","_globalThis$loaders","readable","writable","globalThis","loaders","NodeFileSystem","openReadableFile","path","flags","openWritableFile","mode","readdir","dirname","arguments","length","undefined","stat","unlink","fetch"],"sources":["../../../src/lib/filesystems/node-filesystem-facade.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {isBrowser} from '../env-utils/globals';\nimport {Stat} from '../files/file';\nimport {NodeFileFacade as NodeFile} from '../files/node-file-facade';\nimport {RandomAccessFileSystem} from './filesystem';\n\nconst NOT_IMPLEMENTED = new Error('Not implemented');\n\n/**\n * FileSystem pass-through for Node.js\n * Compatible with BrowserFileSystem.\n * @note Dummy implementation, not used (constructor returns a real NodeFileSystem instance)\n * @param options\n */\nexport class NodeFileSystemFacade implements RandomAccessFileSystem {\n // implements FileSystem\n constructor(options: {[key: string]: any}) {\n if (globalThis.loaders?.NodeFileSystem) {\n return new globalThis.loaders.NodeFileSystem(options);\n }\n if (isBrowser) {\n throw new Error('Can\\'t instantiate NodeFileSystem in browser.');\n }\n throw new Error(\n 'Can\\'t instantiate NodeFileSystem. Make sure to import @loaders.gl/polyfills first.'\n );\n }\n\n // DUMMY IMPLEMENTATION, not used (constructor returns a real NodeFileSystem instance)\n\n // implements RandomAccessReadFileSystem\n\n readonly readable = true;\n readonly writable = true;\n\n async openReadableFile(path: string, flags): Promise<NodeFile> {\n throw NOT_IMPLEMENTED;\n }\n\n // implements RandomAccessWriteFileSystem\n async openWritableFile(path: string, flags, mode): Promise<NodeFile> {\n throw NOT_IMPLEMENTED;\n }\n\n // Implements file system\n\n async readdir(dirname = '.', options?: {}): Promise<string[]> {\n throw NOT_IMPLEMENTED;\n }\n\n async stat(path: string, options?: {}): Promise<Stat> {\n throw NOT_IMPLEMENTED;\n }\n\n async unlink(path: string): Promise<void> {\n throw NOT_IMPLEMENTED;\n }\n\n async fetch(path: RequestInfo, options?: RequestInit): Promise<Response> {\n throw NOT_IMPLEMENTED;\n }\n}\n"],"mappings":"SAIQA,SAAS;AAKjB,MAAMC,eAAe,GAAG,IAAIC,KAAK,CAAC,iBAAiB,CAAC;AAQpD,OAAO,MAAMC,oBAAoB,CAAmC;EAElEC,WAAWA,CAACC,OAA6B,EAAE;IAAA,IAAAC,mBAAA;IAAA,KAgBlCC,QAAQ,GAAG,IAAI;IAAA,KACfC,QAAQ,GAAG,IAAI;IAhBtB,KAAAF,mBAAA,GAAIG,UAAU,CAACC,OAAO,cAAAJ,mBAAA,eAAlBA,mBAAA,CAAoBK,cAAc,EAAE;MACtC,OAAO,IAAIF,UAAU,CAACC,OAAO,CAACC,cAAc,CAACN,OAAO,CAAC;IACvD;IACA,IAAIL,SAAS,EAAE;MACb,MAAM,IAAIE,KAAK,CAAC,+CAA+C,CAAC;IAClE;IACA,MAAM,IAAIA,KAAK,CACb,qFACF,CAAC;EACH;EASA,MAAMU,gBAAgBA,CAACC,IAAY,EAAEC,KAAK,EAAqB;IAC7D,MAAMb,eAAe;EACvB;EAGA,MAAMc,gBAAgBA,CAACF,IAAY,EAAEC,KAAK,EAAEE,IAAI,EAAqB;IACnE,MAAMf,eAAe;EACvB;EAIA,MAAMgB,OAAOA,CAAA,EAAiD;IAAA,IAAhDC,OAAO,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,GAAG;IAAA,IAAEd,OAAY,GAAAc,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;IACvC,MAAMpB,eAAe;EACvB;EAEA,MAAMqB,IAAIA,CAACT,IAAY,EAAER,OAAY,EAAiB;IACpD,MAAMJ,eAAe;EACvB;EAEA,MAAMsB,MAAMA,CAACV,IAAY,EAAiB;IACxC,MAAMZ,eAAe;EACvB;EAEA,MAAMuB,KAAKA,CAACX,IAAiB,EAAER,OAAqB,EAAqB;IACvE,MAAMJ,eAAe;EACvB;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer.browser.d.ts","sourceRoot":"","sources":["../../../src/lib/node/buffer.browser.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"buffer.browser.d.ts","sourceRoot":"","sources":["../../../src/lib/node/buffer.browser.ts"],"names":[],"mappings":";AAOA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,KAAA,OAEnC;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,UAAU,EAAE,WAAW,GAAG,MAAM,GAAG,MAAM,CAEjE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer.browser.js","names":["toArrayBuffer","buffer","toBuffer","binaryData","Error"],"sources":["../../../src/lib/node/buffer.browser.ts"],"sourcesContent":["// loaders.gl
|
|
1
|
+
{"version":3,"file":"buffer.browser.js","names":["toArrayBuffer","buffer","toBuffer","binaryData","Error"],"sources":["../../../src/lib/node/buffer.browser.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// Isolates Buffer references to ensure they are only bundled under Node.js (avoids big webpack polyfill)\n// this file is selected by the package.json \"browser\" field).\n\n/**\n * Convert Buffer to ArrayBuffer\n * Converts Node.js `Buffer` to `ArrayBuffer` (without triggering bundler to include Buffer polyfill on browser)\n * @todo better data type\n */\nexport function toArrayBuffer(buffer) {\n return buffer;\n}\n\n/**\n * Convert (copy) ArrayBuffer to Buffer\n */\nexport function toBuffer(binaryData: ArrayBuffer | Buffer): Buffer {\n throw new Error('Buffer not supported in browser');\n}\n"],"mappings":"AAYA,OAAO,SAASA,aAAaA,CAACC,MAAM,EAAE;EACpC,OAAOA,MAAM;AACf;AAKA,OAAO,SAASC,QAAQA,CAACC,UAAgC,EAAU;EACjE,MAAM,IAAIC,KAAK,CAAC,iCAAiC,CAAC;AACpD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../../../src/lib/node/buffer.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../../../src/lib/node/buffer.ts"],"names":[],"mappings":";AAOA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,KAAA,OAOnC;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,UAAU,EAAE,WAAW,GAAG,MAAM,GAAG,MAAM,CAejE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer.js","names":["toArrayBuffer","buffer","Buffer","isBuffer","typedArray","Uint8Array","byteOffset","length","slice","toBuffer","binaryData","ArrayBuffer","isView","from","Error"],"sources":["../../../src/lib/node/buffer.ts"],"sourcesContent":["// loaders.gl
|
|
1
|
+
{"version":3,"file":"buffer.js","names":["toArrayBuffer","buffer","Buffer","isBuffer","typedArray","Uint8Array","byteOffset","length","slice","toBuffer","binaryData","ArrayBuffer","isView","from","Error"],"sources":["../../../src/lib/node/buffer.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// Isolates Buffer references to ensure they are only bundled under Node.js (avoids big webpack polyfill)\n// this file is selected by the package.json \"browser\" field).\n\n/**\n * Convert Buffer to ArrayBuffer\n * Converts Node.js `Buffer` to `ArrayBuffer` (without triggering bundler to include Buffer polyfill on browser)\n * @todo better data type\n */\nexport function toArrayBuffer(buffer) {\n // TODO - per docs we should just be able to call buffer.buffer, but there are issues\n if (Buffer.isBuffer(buffer)) {\n const typedArray = new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.length);\n return typedArray.slice().buffer;\n }\n return buffer;\n}\n\n/**\n * Convert (copy) ArrayBuffer to Buffer\n */\nexport function toBuffer(binaryData: ArrayBuffer | Buffer): Buffer {\n if (Buffer.isBuffer(binaryData)) {\n return binaryData;\n }\n\n if (ArrayBuffer.isView(binaryData)) {\n binaryData = binaryData.buffer;\n }\n\n // TODO - move to loaders.gl/polyfills\n if (typeof Buffer !== 'undefined' && binaryData instanceof ArrayBuffer) {\n return Buffer.from(binaryData);\n }\n\n throw new Error('toBuffer');\n}\n"],"mappings":"AAYA,OAAO,SAASA,aAAaA,CAACC,MAAM,EAAE;EAEpC,IAAIC,MAAM,CAACC,QAAQ,CAACF,MAAM,CAAC,EAAE;IAC3B,MAAMG,UAAU,GAAG,IAAIC,UAAU,CAACJ,MAAM,CAACA,MAAM,EAAEA,MAAM,CAACK,UAAU,EAAEL,MAAM,CAACM,MAAM,CAAC;IAClF,OAAOH,UAAU,CAACI,KAAK,CAAC,CAAC,CAACP,MAAM;EAClC;EACA,OAAOA,MAAM;AACf;AAKA,OAAO,SAASQ,QAAQA,CAACC,UAAgC,EAAU;EACjE,IAAIR,MAAM,CAACC,QAAQ,CAACO,UAAU,CAAC,EAAE;IAC/B,OAAOA,UAAU;EACnB;EAEA,IAAIC,WAAW,CAACC,MAAM,CAACF,UAAU,CAAC,EAAE;IAClCA,UAAU,GAAGA,UAAU,CAACT,MAAM;EAChC;EAGA,IAAI,OAAOC,MAAM,KAAK,WAAW,IAAIQ,UAAU,YAAYC,WAAW,EAAE;IACtE,OAAOT,MAAM,CAACW,IAAI,CAACH,UAAU,CAAC;EAChC;EAEA,MAAM,IAAII,KAAK,CAAC,UAAU,CAAC;AAC7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../../src/lib/node/stream.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../../src/lib/node/stream.ts"],"names":[],"mappings":";AAIA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC,YAAY,EAAC,QAAQ,EAAC,MAAM,QAAQ,CAAC;AAErC,wCAAwC;AACxC,eAAO,MAAM,SAAS,yBAAmB,CAAC;AAE1C,eAAO,MAAM,WAAW,SAAkB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.js","names":["stream","Transform","isSupported","Boolean"],"sources":["../../../src/lib/node/stream.ts"],"sourcesContent":["// loaders.gl
|
|
1
|
+
{"version":3,"file":"stream.js","names":["stream","Transform","isSupported","Boolean"],"sources":["../../../src/lib/node/stream.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport * as stream from 'stream';\n\nexport type {Writable} from 'stream';\n\n/** Wrapper for Node.js stream method */\nexport const Transform = stream.Transform;\n\nexport const isSupported = Boolean(stream);\n"],"mappings":"AAIA,OAAO,KAAKA,MAAM,MAAM,QAAQ;AAKhC,OAAO,MAAMC,SAAS,GAAGD,MAAM,CAACC,SAAS;AAEzC,OAAO,MAAMC,WAAW,GAAGC,OAAO,CAACH,MAAM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge-loader-options.d.ts","sourceRoot":"","sources":["../../../src/lib/option-utils/merge-loader-options.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"merge-loader-options.d.ts","sourceRoot":"","sources":["../../../src/lib/option-utils/merge-loader-options.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAC;AAEjD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,SAAS,aAAa,EAC9D,WAAW,EAAE,OAAO,GAAG,SAAS,EAChC,UAAU,EAAE,OAAO,GAClB,OAAO,CAET"}
|
|
@@ -2,12 +2,16 @@ export function mergeLoaderOptions(baseOptions, newOptions) {
|
|
|
2
2
|
return mergeOptionsRecursively(baseOptions || {}, newOptions);
|
|
3
3
|
}
|
|
4
4
|
function mergeOptionsRecursively(baseOptions, newOptions) {
|
|
5
|
+
let level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
6
|
+
if (level > 3) {
|
|
7
|
+
return newOptions;
|
|
8
|
+
}
|
|
5
9
|
const options = {
|
|
6
10
|
...baseOptions
|
|
7
11
|
};
|
|
8
12
|
for (const [key, newValue] of Object.entries(newOptions)) {
|
|
9
13
|
if (newValue && typeof newValue === 'object' && !Array.isArray(newValue)) {
|
|
10
|
-
options[key] = mergeOptionsRecursively(options[key] || {}, newOptions[key]);
|
|
14
|
+
options[key] = mergeOptionsRecursively(options[key] || {}, newOptions[key], level + 1);
|
|
11
15
|
} else {
|
|
12
16
|
options[key] = newOptions[key];
|
|
13
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge-loader-options.js","names":["mergeLoaderOptions","baseOptions","newOptions","mergeOptionsRecursively","options","key","newValue","Object","entries","Array","isArray"],"sources":["../../../src/lib/option-utils/merge-loader-options.ts"],"sourcesContent":["// loaders.gl
|
|
1
|
+
{"version":3,"file":"merge-loader-options.js","names":["mergeLoaderOptions","baseOptions","newOptions","mergeOptionsRecursively","level","arguments","length","undefined","options","key","newValue","Object","entries","Array","isArray"],"sources":["../../../src/lib/option-utils/merge-loader-options.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {LoaderOptions} from '../../loader-types';\n\n/**\n *\n * @param baseOptions Can be undefined, in which case a fresh options object will be minted\n * @param newOptions\n * @returns\n */\nexport function mergeLoaderOptions<Options extends LoaderOptions>(\n baseOptions: Options | undefined,\n newOptions: Options\n): Options {\n return mergeOptionsRecursively(baseOptions || {}, newOptions) as Options;\n}\n\nfunction mergeOptionsRecursively(\n baseOptions: Record<string, unknown>,\n newOptions: Record<string, unknown>,\n level = 0\n): Record<string, unknown> {\n // Sanity check (jest test runner overwrites the console object which can lead to infinite recursion)\n if (level > 3) {\n return newOptions;\n }\n\n const options = {...baseOptions};\n for (const [key, newValue] of Object.entries(newOptions)) {\n if (newValue && typeof newValue === 'object' && !Array.isArray(newValue)) {\n options[key] = mergeOptionsRecursively(\n (options[key] as Record<string, unknown>) || {},\n newOptions[key] as Record<string, unknown>,\n level + 1\n );\n // Object.assign(options[key] as object, newOptions[key]);\n } else {\n options[key] = newOptions[key];\n }\n }\n return options as Record<string, unknown>;\n}\n"],"mappings":"AAYA,OAAO,SAASA,kBAAkBA,CAChCC,WAAgC,EAChCC,UAAmB,EACV;EACT,OAAOC,uBAAuB,CAACF,WAAW,IAAI,CAAC,CAAC,EAAEC,UAAU,CAAC;AAC/D;AAEA,SAASC,uBAAuBA,CAC9BF,WAAoC,EACpCC,UAAmC,EAEV;EAAA,IADzBE,KAAK,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;EAGT,IAAID,KAAK,GAAG,CAAC,EAAE;IACb,OAAOF,UAAU;EACnB;EAEA,MAAMM,OAAO,GAAG;IAAC,GAAGP;EAAW,CAAC;EAChC,KAAK,MAAM,CAACQ,GAAG,EAAEC,QAAQ,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACV,UAAU,CAAC,EAAE;IACxD,IAAIQ,QAAQ,IAAI,OAAOA,QAAQ,KAAK,QAAQ,IAAI,CAACG,KAAK,CAACC,OAAO,CAACJ,QAAQ,CAAC,EAAE;MACxEF,OAAO,CAACC,GAAG,CAAC,GAAGN,uBAAuB,CACnCK,OAAO,CAACC,GAAG,CAAC,IAAgC,CAAC,CAAC,EAC/CP,UAAU,CAACO,GAAG,CAAC,EACfL,KAAK,GAAG,CACV,CAAC;IAEH,CAAC,MAAM;MACLI,OAAO,CAACC,GAAG,CAAC,GAAGP,UAAU,CAACO,GAAG,CAAC;IAChC;EACF;EACA,OAAOD,OAAO;AAChB"}
|