@loaders.gl/loader-utils 4.0.0-alpha.8 → 4.0.0-beta.1
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/es5/index.js +63 -2
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/json-loader.js +1 -1
- package/dist/es5/json-loader.js.map +1 -1
- package/dist/es5/lib/file-provider/data-view-file.js +146 -0
- package/dist/es5/lib/file-provider/data-view-file.js.map +1 -0
- package/dist/es5/lib/file-provider/file-handle-file.js +236 -0
- package/dist/es5/lib/file-provider/file-handle-file.js.map +1 -0
- package/dist/es5/lib/file-provider/file-handle.js +98 -0
- package/dist/es5/lib/file-provider/file-handle.js.map +1 -0
- package/dist/es5/lib/file-provider/file-provider.js +11 -0
- package/dist/es5/lib/file-provider/file-provider.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/node-filesystem.browser.js +172 -0
- package/dist/es5/lib/filesystems/node-filesystem.browser.js.map +1 -0
- package/dist/es5/lib/filesystems/node-filesystem.js +2 -2
- package/dist/es5/lib/filesystems/node-filesystem.js.map +1 -1
- package/dist/es5/lib/node/fs.browser.js +9 -0
- package/dist/es5/lib/node/fs.browser.js.map +1 -0
- package/dist/es5/lib/node/fs.js +28 -34
- package/dist/es5/lib/node/fs.js.map +1 -1
- package/dist/es5/lib/node/stream.browser.js +9 -0
- package/dist/es5/lib/node/stream.browser.js.map +1 -0
- package/dist/es5/lib/node/stream.js +6 -7
- package/dist/es5/lib/node/stream.js.map +1 -1
- package/dist/es5/lib/option-utils/merge-loader-options.js +1 -1
- package/dist/es5/lib/option-utils/merge-loader-options.js.map +1 -1
- package/dist/es5/lib/sources/data-source.js +67 -0
- package/dist/es5/lib/sources/data-source.js.map +1 -0
- package/dist/es5/lib/sources/image-source.js +31 -0
- package/dist/es5/lib/sources/image-source.js.map +1 -0
- package/dist/es5/lib/sources/image-tile-source.js +2 -0
- package/dist/es5/lib/sources/image-tile-source.js.map +1 -0
- package/dist/es5/lib/sources/tile-source.js +2 -0
- package/dist/es5/lib/sources/tile-source.js.map +1 -0
- package/dist/es5/lib/sources/utils/image-type.js +2 -0
- package/dist/es5/lib/sources/utils/image-type.js.map +1 -0
- package/dist/es5/lib/sources/utils/utils.js +36 -0
- package/dist/es5/lib/sources/utils/utils.js.map +1 -0
- package/dist/es5/lib/sources/vector-tile-source.js +2 -0
- package/dist/es5/lib/sources/vector-tile-source.js.map +1 -0
- package/dist/es5/lib/worker-loader-utils/create-loader-worker.js +2 -2
- package/dist/es5/lib/worker-loader-utils/create-loader-worker.js.map +1 -1
- package/dist/es5/lib/worker-loader-utils/encode-with-worker.js.map +1 -1
- package/dist/es5/lib/worker-loader-utils/parse-with-worker.js.map +1 -1
- package/dist/es5/loader-types.js +58 -0
- package/dist/es5/loader-types.js.map +1 -0
- package/dist/es5/service-types.js +2 -0
- package/dist/es5/service-types.js.map +1 -0
- package/dist/es5/types.js.map +1 -1
- package/dist/es5/writer-types.js +2 -0
- package/dist/es5/writer-types.js.map +1 -0
- package/dist/esm/index.js +8 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/json-loader.js +1 -1
- package/dist/esm/json-loader.js.map +1 -1
- package/dist/esm/lib/file-provider/data-view-file.js +33 -0
- package/dist/esm/lib/file-provider/data-view-file.js.map +1 -0
- package/dist/esm/lib/file-provider/file-handle-file.js +59 -0
- package/dist/esm/lib/file-provider/file-handle-file.js.map +1 -0
- package/dist/esm/lib/file-provider/file-handle.js +33 -0
- package/dist/esm/lib/file-provider/file-handle.js.map +1 -0
- package/dist/esm/lib/file-provider/file-provider.js +4 -0
- package/dist/esm/lib/file-provider/file-provider.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/node-filesystem.browser.js +42 -0
- package/dist/esm/lib/filesystems/node-filesystem.browser.js.map +1 -0
- package/dist/esm/lib/filesystems/node-filesystem.js +1 -1
- package/dist/esm/lib/filesystems/node-filesystem.js.map +1 -1
- package/dist/esm/lib/node/fs.browser.js +2 -0
- package/dist/esm/lib/node/fs.browser.js.map +1 -0
- package/dist/esm/lib/node/fs.js +16 -27
- package/dist/esm/lib/node/fs.js.map +1 -1
- package/dist/esm/lib/node/stream.browser.js +2 -0
- package/dist/esm/lib/node/stream.browser.js.map +1 -0
- package/dist/esm/lib/node/stream.js +2 -5
- package/dist/esm/lib/node/stream.js.map +1 -1
- package/dist/esm/lib/option-utils/merge-loader-options.js +1 -1
- package/dist/esm/lib/option-utils/merge-loader-options.js.map +1 -1
- package/dist/esm/lib/sources/data-source.js +43 -0
- package/dist/esm/lib/sources/data-source.js.map +1 -0
- package/dist/esm/lib/sources/image-source.js +6 -0
- package/dist/esm/lib/sources/image-source.js.map +1 -0
- package/dist/esm/lib/sources/image-tile-source.js +2 -0
- package/dist/esm/lib/sources/image-tile-source.js.map +1 -0
- package/dist/esm/lib/sources/tile-source.js +2 -0
- package/dist/esm/lib/sources/tile-source.js.map +1 -0
- package/dist/esm/lib/sources/utils/image-type.js +2 -0
- package/dist/esm/lib/sources/utils/image-type.js.map +1 -0
- package/dist/esm/lib/sources/utils/utils.js +21 -0
- package/dist/esm/lib/sources/utils/utils.js.map +1 -0
- package/dist/esm/lib/sources/vector-tile-source.js +2 -0
- package/dist/esm/lib/sources/vector-tile-source.js.map +1 -0
- package/dist/esm/lib/worker-loader-utils/create-loader-worker.js +2 -2
- package/dist/esm/lib/worker-loader-utils/create-loader-worker.js.map +1 -1
- package/dist/esm/lib/worker-loader-utils/encode-with-worker.js.map +1 -1
- package/dist/esm/lib/worker-loader-utils/parse-with-worker.js.map +1 -1
- package/dist/esm/loader-types.js +16 -0
- package/dist/esm/loader-types.js.map +1 -0
- package/dist/esm/service-types.js +2 -0
- package/dist/esm/service-types.js.map +1 -0
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/writer-types.js +2 -0
- package/dist/esm/writer-types.js.map +1 -0
- package/dist/index.d.ts +22 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/json-loader.d.ts +1 -1
- package/dist/json-loader.d.ts.map +1 -1
- package/dist/lib/file-provider/data-view-file.d.ts +37 -0
- package/dist/lib/file-provider/data-view-file.d.ts.map +1 -0
- package/dist/lib/file-provider/file-handle-file.d.ts +53 -0
- package/dist/lib/file-provider/file-handle-file.d.ts.map +1 -0
- package/dist/lib/file-provider/file-handle.d.ts +40 -0
- package/dist/lib/file-provider/file-handle.d.ts.map +1 -0
- package/dist/lib/file-provider/file-provider.d.ts +45 -0
- package/dist/lib/file-provider/file-provider.d.ts.map +1 -0
- package/dist/lib/filesystems/filesystem.d.ts +80 -0
- package/dist/lib/filesystems/filesystem.d.ts.map +1 -0
- package/dist/lib/filesystems/node-filesystem.browser.d.ts +39 -0
- package/dist/lib/filesystems/node-filesystem.browser.d.ts.map +1 -0
- package/dist/lib/filesystems/node-filesystem.d.ts +3 -3
- package/dist/lib/filesystems/node-filesystem.d.ts.map +1 -1
- package/dist/lib/node/fs.browser.d.ts +2 -0
- package/dist/lib/node/fs.browser.d.ts.map +1 -0
- package/dist/lib/node/fs.d.ts +19 -14
- package/dist/lib/node/fs.d.ts.map +1 -1
- package/dist/lib/node/stream.browser.d.ts +2 -0
- package/dist/lib/node/stream.browser.d.ts.map +1 -0
- package/dist/lib/node/stream.d.ts +4 -1
- package/dist/lib/node/stream.d.ts.map +1 -1
- package/dist/lib/option-utils/merge-loader-options.d.ts +1 -1
- package/dist/lib/option-utils/merge-loader-options.d.ts.map +1 -1
- package/dist/lib/sources/data-source.d.ts +33 -0
- package/dist/lib/sources/data-source.d.ts.map +1 -0
- package/dist/lib/sources/image-source.d.ts +81 -0
- package/dist/lib/sources/image-source.d.ts.map +1 -0
- package/dist/lib/sources/image-tile-source.d.ts +11 -0
- package/dist/lib/sources/image-tile-source.d.ts.map +1 -0
- package/dist/lib/sources/tile-source.d.ts +105 -0
- package/dist/lib/sources/tile-source.d.ts.map +1 -0
- package/dist/lib/sources/utils/image-type.d.ts +10 -0
- package/dist/lib/sources/utils/image-type.d.ts.map +1 -0
- package/dist/lib/sources/utils/utils.d.ts +13 -0
- package/dist/lib/sources/utils/utils.d.ts.map +1 -0
- package/dist/lib/sources/vector-tile-source.d.ts +10 -0
- package/dist/lib/sources/vector-tile-source.d.ts.map +1 -0
- package/dist/lib/worker-loader-utils/create-loader-worker.d.ts +1 -1
- package/dist/lib/worker-loader-utils/create-loader-worker.d.ts.map +1 -1
- package/dist/lib/worker-loader-utils/encode-with-worker.d.ts +1 -1
- package/dist/lib/worker-loader-utils/encode-with-worker.d.ts.map +1 -1
- package/dist/lib/worker-loader-utils/parse-with-worker.d.ts +2 -2
- package/dist/lib/worker-loader-utils/parse-with-worker.d.ts.map +1 -1
- package/dist/loader-types.d.ts +209 -0
- package/dist/loader-types.d.ts.map +1 -0
- package/dist/service-types.d.ts +10 -0
- package/dist/service-types.d.ts.map +1 -0
- package/dist/types.d.ts +1 -240
- package/dist/types.d.ts.map +1 -1
- package/dist/writer-types.d.ts +34 -0
- package/dist/writer-types.d.ts.map +1 -0
- package/package.json +9 -5
- package/src/index.ts +57 -17
- package/src/json-loader.ts +1 -1
- package/src/lib/file-provider/data-view-file.ts +72 -0
- package/src/lib/file-provider/file-handle-file.ts +116 -0
- package/src/lib/file-provider/file-handle.ts +79 -0
- package/src/lib/file-provider/file-provider.ts +56 -0
- package/src/lib/filesystems/filesystem.ts +87 -0
- package/src/lib/filesystems/node-filesystem.browser.ts +61 -0
- package/src/lib/filesystems/node-filesystem.ts +4 -4
- package/src/lib/node/fs.browser.ts +1 -0
- package/src/lib/node/fs.ts +20 -50
- package/src/lib/node/stream.browser.ts +1 -0
- package/src/lib/node/stream.ts +3 -11
- package/src/lib/option-utils/merge-loader-options.ts +2 -2
- package/src/lib/sources/data-source.ts +74 -0
- package/src/lib/sources/image-source.ts +95 -0
- package/src/lib/sources/image-tile-source.ts +14 -0
- package/src/lib/sources/tile-source.ts +101 -0
- package/src/lib/sources/utils/image-type.ts +10 -0
- package/src/lib/sources/utils/utils.ts +42 -0
- package/src/lib/sources/vector-tile-source.ts +13 -0
- package/src/lib/worker-loader-utils/create-loader-worker.ts +20 -4
- package/src/lib/worker-loader-utils/encode-with-worker.ts +1 -1
- package/src/lib/worker-loader-utils/parse-with-worker.ts +2 -2
- package/src/loader-types.ts +367 -0
- package/src/service-types.ts +12 -0
- package/src/types.ts +2 -351
- package/src/writer-types.ts +56 -0
- package/dist/index.js +0 -122
- package/dist/json-loader.js +0 -27
- package/dist/lib/binary-utils/array-buffer-utils.js +0 -84
- package/dist/lib/binary-utils/dataview-copy-utils.js +0 -97
- package/dist/lib/binary-utils/get-first-characters.js +0 -45
- package/dist/lib/binary-utils/memory-conversion-utils.js +0 -73
- package/dist/lib/binary-utils/memory-copy-utils.js +0 -61
- package/dist/lib/env-utils/assert.js +0 -13
- package/dist/lib/env-utils/globals.js +0 -30
- package/dist/lib/filesystems/node-filesystem.js +0 -73
- package/dist/lib/filesystems/readable-file.js +0 -25
- package/dist/lib/filesystems/writable-file.js +0 -48
- package/dist/lib/iterators/async-iteration.js +0 -53
- package/dist/lib/iterators/text-iterators.js +0 -61
- package/dist/lib/node/buffer.browser.js +0 -22
- package/dist/lib/node/buffer.js +0 -36
- package/dist/lib/node/fs.js +0 -49
- package/dist/lib/node/promisify.js +0 -22
- package/dist/lib/node/stream.js +0 -17
- package/dist/lib/option-utils/merge-loader-options.js +0 -27
- package/dist/lib/parser-utils/parse-json.js +0 -16
- package/dist/lib/path-utils/file-aliases.js +0 -47
- package/dist/lib/path-utils/get-cwd.js +0 -12
- package/dist/lib/path-utils/path.js +0 -178
- package/dist/lib/request-utils/request-scheduler.js +0 -142
- package/dist/lib/worker-loader-utils/create-loader-worker.js +0 -98
- package/dist/lib/worker-loader-utils/encode-with-worker.js +0 -21
- package/dist/lib/worker-loader-utils/parse-with-worker.js +0 -81
- package/dist/types.js +0 -3
- package/dist/workers/json-worker.js +0 -5
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// loaders./gl, MIT license
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.copyPaddedStringToDataView = exports.copyPaddedArrayBufferToDataView = exports.copyBinaryToDataView = exports.copyStringToDataView = exports.padStringToByteAlignment = void 0;
|
|
5
|
-
const memory_copy_utils_1 = require("./memory-copy-utils");
|
|
6
|
-
/**
|
|
7
|
-
* Helper function that pads a string with spaces to fit a certain byte alignment
|
|
8
|
-
* @param string
|
|
9
|
-
* @param byteAlignment
|
|
10
|
-
* @returns
|
|
11
|
-
*
|
|
12
|
-
* @todo PERFORMANCE IDEA: No need to copy string twice...
|
|
13
|
-
*/
|
|
14
|
-
function padStringToByteAlignment(string, byteAlignment) {
|
|
15
|
-
const length = string.length;
|
|
16
|
-
const paddedLength = Math.ceil(length / byteAlignment) * byteAlignment; // Round up to the required alignment
|
|
17
|
-
const padding = paddedLength - length;
|
|
18
|
-
let whitespace = '';
|
|
19
|
-
for (let i = 0; i < padding; ++i) {
|
|
20
|
-
whitespace += ' ';
|
|
21
|
-
}
|
|
22
|
-
return string + whitespace;
|
|
23
|
-
}
|
|
24
|
-
exports.padStringToByteAlignment = padStringToByteAlignment;
|
|
25
|
-
/**
|
|
26
|
-
*
|
|
27
|
-
* @param dataView
|
|
28
|
-
* @param byteOffset
|
|
29
|
-
* @param string
|
|
30
|
-
* @param byteLength
|
|
31
|
-
* @returns
|
|
32
|
-
*/
|
|
33
|
-
function copyStringToDataView(dataView, byteOffset, string, byteLength) {
|
|
34
|
-
if (dataView) {
|
|
35
|
-
for (let i = 0; i < byteLength; i++) {
|
|
36
|
-
dataView.setUint8(byteOffset + i, string.charCodeAt(i));
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return byteOffset + byteLength;
|
|
40
|
-
}
|
|
41
|
-
exports.copyStringToDataView = copyStringToDataView;
|
|
42
|
-
function copyBinaryToDataView(dataView, byteOffset, binary, byteLength) {
|
|
43
|
-
if (dataView) {
|
|
44
|
-
for (let i = 0; i < byteLength; i++) {
|
|
45
|
-
dataView.setUint8(byteOffset + i, binary[i]);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return byteOffset + byteLength;
|
|
49
|
-
}
|
|
50
|
-
exports.copyBinaryToDataView = copyBinaryToDataView;
|
|
51
|
-
/**
|
|
52
|
-
* Copy sourceBuffer to dataView with some padding
|
|
53
|
-
*
|
|
54
|
-
* @param dataView - destination data container. If null - only new offset is calculated
|
|
55
|
-
* @param byteOffset - destination byte offset to copy to
|
|
56
|
-
* @param sourceBuffer - source data buffer
|
|
57
|
-
* @param padding - pad the resulting array to multiple of "padding" bytes. Additional bytes are filled with 0x20 (ASCII space)
|
|
58
|
-
*
|
|
59
|
-
* @return new byteOffset of resulting dataView
|
|
60
|
-
*/
|
|
61
|
-
function copyPaddedArrayBufferToDataView(dataView, byteOffset, sourceBuffer, padding) {
|
|
62
|
-
const paddedLength = (0, memory_copy_utils_1.padToNBytes)(sourceBuffer.byteLength, padding);
|
|
63
|
-
const padLength = paddedLength - sourceBuffer.byteLength;
|
|
64
|
-
if (dataView) {
|
|
65
|
-
// Copy array
|
|
66
|
-
const targetArray = new Uint8Array(dataView.buffer, dataView.byteOffset + byteOffset, sourceBuffer.byteLength);
|
|
67
|
-
const sourceArray = new Uint8Array(sourceBuffer);
|
|
68
|
-
targetArray.set(sourceArray);
|
|
69
|
-
// Add PADDING
|
|
70
|
-
for (let i = 0; i < padLength; ++i) {
|
|
71
|
-
// json chunk is padded with spaces (ASCII 0x20)
|
|
72
|
-
dataView.setUint8(byteOffset + sourceBuffer.byteLength + i, 0x20);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
byteOffset += paddedLength;
|
|
76
|
-
return byteOffset;
|
|
77
|
-
}
|
|
78
|
-
exports.copyPaddedArrayBufferToDataView = copyPaddedArrayBufferToDataView;
|
|
79
|
-
/**
|
|
80
|
-
* Copy string to dataView with some padding
|
|
81
|
-
*
|
|
82
|
-
* @param {DataView | null} dataView - destination data container. If null - only new offset is calculated
|
|
83
|
-
* @param {number} byteOffset - destination byte offset to copy to
|
|
84
|
-
* @param {string} string - source string
|
|
85
|
-
* @param {number} padding - pad the resulting array to multiple of "padding" bytes. Additional bytes are filled with 0x20 (ASCII space)
|
|
86
|
-
*
|
|
87
|
-
* @return new byteOffset of resulting dataView
|
|
88
|
-
*/
|
|
89
|
-
function copyPaddedStringToDataView(dataView, byteOffset, string, padding) {
|
|
90
|
-
const textEncoder = new TextEncoder();
|
|
91
|
-
// PERFORMANCE IDEA: We encode twice, once to get size and once to store
|
|
92
|
-
// PERFORMANCE IDEA: Use TextEncoder.encodeInto() to avoid temporary copy
|
|
93
|
-
const stringBuffer = textEncoder.encode(string);
|
|
94
|
-
byteOffset = copyPaddedArrayBufferToDataView(dataView, byteOffset, stringBuffer, padding);
|
|
95
|
-
return byteOffset;
|
|
96
|
-
}
|
|
97
|
-
exports.copyPaddedStringToDataView = copyPaddedStringToDataView;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// loaders.gl, MIT license
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.getMagicString = exports.getFirstCharacters = void 0;
|
|
5
|
-
/**
|
|
6
|
-
* Get the first characters from a binary file (interpret the first bytes as an ASCII string)
|
|
7
|
-
* @param data
|
|
8
|
-
* @param length
|
|
9
|
-
* @returns
|
|
10
|
-
*/
|
|
11
|
-
function getFirstCharacters(data, length = 5) {
|
|
12
|
-
if (typeof data === 'string') {
|
|
13
|
-
return data.slice(0, length);
|
|
14
|
-
}
|
|
15
|
-
else if (ArrayBuffer.isView(data)) {
|
|
16
|
-
// Typed Arrays can have offsets into underlying buffer
|
|
17
|
-
return getMagicString(data.buffer, data.byteOffset, length);
|
|
18
|
-
}
|
|
19
|
-
else if (data instanceof ArrayBuffer) {
|
|
20
|
-
const byteOffset = 0;
|
|
21
|
-
return getMagicString(data, byteOffset, length);
|
|
22
|
-
}
|
|
23
|
-
return '';
|
|
24
|
-
}
|
|
25
|
-
exports.getFirstCharacters = getFirstCharacters;
|
|
26
|
-
/**
|
|
27
|
-
* Gets a magic string from a "file"
|
|
28
|
-
* Typically used to check or detect file format
|
|
29
|
-
* @param arrayBuffer
|
|
30
|
-
* @param byteOffset
|
|
31
|
-
* @param length
|
|
32
|
-
* @returns
|
|
33
|
-
*/
|
|
34
|
-
function getMagicString(arrayBuffer, byteOffset, length) {
|
|
35
|
-
if (arrayBuffer.byteLength <= byteOffset + length) {
|
|
36
|
-
return '';
|
|
37
|
-
}
|
|
38
|
-
const dataView = new DataView(arrayBuffer);
|
|
39
|
-
let magic = '';
|
|
40
|
-
for (let i = 0; i < length; i++) {
|
|
41
|
-
magic += String.fromCharCode(dataView.getUint8(byteOffset + i));
|
|
42
|
-
}
|
|
43
|
-
return magic;
|
|
44
|
-
}
|
|
45
|
-
exports.getMagicString = getMagicString;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// loaders.gl, MIT license
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
-
}) : function(o, v) {
|
|
17
|
-
o["default"] = v;
|
|
18
|
-
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
-
if (mod && mod.__esModule) return mod;
|
|
21
|
-
var result = {};
|
|
22
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
-
__setModuleDefault(result, mod);
|
|
24
|
-
return result;
|
|
25
|
-
};
|
|
26
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.toArrayBuffer = exports.toBuffer = exports.isBuffer = void 0;
|
|
28
|
-
const node = __importStar(require("../node/buffer"));
|
|
29
|
-
/**
|
|
30
|
-
* Check for Node.js `Buffer` (without triggering bundler to include Buffer polyfill on browser)
|
|
31
|
-
*/
|
|
32
|
-
function isBuffer(value) {
|
|
33
|
-
return value && typeof value === 'object' && value.isBuffer;
|
|
34
|
-
}
|
|
35
|
-
exports.isBuffer = isBuffer;
|
|
36
|
-
/**
|
|
37
|
-
* Converts to Node.js `Buffer` (without triggering bundler to include Buffer polyfill on browser)
|
|
38
|
-
* @todo better data type
|
|
39
|
-
*/
|
|
40
|
-
function toBuffer(data) {
|
|
41
|
-
return node.toBuffer ? node.toBuffer(data) : data;
|
|
42
|
-
}
|
|
43
|
-
exports.toBuffer = toBuffer;
|
|
44
|
-
/**
|
|
45
|
-
* Convert an object to an array buffer
|
|
46
|
-
*/
|
|
47
|
-
function toArrayBuffer(data) {
|
|
48
|
-
// Note: Should be called first, Buffers can trigger other detections below
|
|
49
|
-
if (isBuffer(data)) {
|
|
50
|
-
return node.toArrayBuffer(data);
|
|
51
|
-
}
|
|
52
|
-
if (data instanceof ArrayBuffer) {
|
|
53
|
-
return data;
|
|
54
|
-
}
|
|
55
|
-
// Careful - Node Buffers look like Uint8Arrays (keep after isBuffer)
|
|
56
|
-
if (ArrayBuffer.isView(data)) {
|
|
57
|
-
if (data.byteOffset === 0 && data.byteLength === data.buffer.byteLength) {
|
|
58
|
-
return data.buffer;
|
|
59
|
-
}
|
|
60
|
-
return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
|
|
61
|
-
}
|
|
62
|
-
if (typeof data === 'string') {
|
|
63
|
-
const text = data;
|
|
64
|
-
const uint8Array = new TextEncoder().encode(text);
|
|
65
|
-
return uint8Array.buffer;
|
|
66
|
-
}
|
|
67
|
-
// HACK to support Blob polyfill
|
|
68
|
-
if (data && typeof data === 'object' && data._toArrayBuffer) {
|
|
69
|
-
return data._toArrayBuffer();
|
|
70
|
-
}
|
|
71
|
-
throw new Error('toArrayBuffer');
|
|
72
|
-
}
|
|
73
|
-
exports.toArrayBuffer = toArrayBuffer;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.copyToArray = exports.copyArrayBuffer = exports.padToNBytes = void 0;
|
|
4
|
-
const assert_1 = require("../env-utils/assert");
|
|
5
|
-
/**
|
|
6
|
-
* Calculate new size of an arrayBuffer to be aligned to an n-byte boundary
|
|
7
|
-
* This function increases `byteLength` by the minimum delta,
|
|
8
|
-
* allowing the total length to be divided by `padding`
|
|
9
|
-
* @param byteLength
|
|
10
|
-
* @param padding
|
|
11
|
-
*/
|
|
12
|
-
function padToNBytes(byteLength, padding) {
|
|
13
|
-
(0, assert_1.assert)(byteLength >= 0); // `Incorrect 'byteLength' value: ${byteLength}`
|
|
14
|
-
(0, assert_1.assert)(padding > 0); // `Incorrect 'padding' value: ${padding}`
|
|
15
|
-
return (byteLength + (padding - 1)) & ~(padding - 1);
|
|
16
|
-
}
|
|
17
|
-
exports.padToNBytes = padToNBytes;
|
|
18
|
-
/**
|
|
19
|
-
* Creates a new Uint8Array based on two different ArrayBuffers
|
|
20
|
-
* @param targetBuffer The first buffer.
|
|
21
|
-
* @param sourceBuffer The second buffer.
|
|
22
|
-
* @return The new ArrayBuffer created out of the two.
|
|
23
|
-
*/
|
|
24
|
-
function copyArrayBuffer(targetBuffer, sourceBuffer, byteOffset, byteLength = sourceBuffer.byteLength) {
|
|
25
|
-
const targetArray = new Uint8Array(targetBuffer, byteOffset, byteLength);
|
|
26
|
-
const sourceArray = new Uint8Array(sourceBuffer);
|
|
27
|
-
targetArray.set(sourceArray);
|
|
28
|
-
return targetBuffer;
|
|
29
|
-
}
|
|
30
|
-
exports.copyArrayBuffer = copyArrayBuffer;
|
|
31
|
-
/**
|
|
32
|
-
* Copy from source to target at the targetOffset
|
|
33
|
-
*
|
|
34
|
-
* @param source - The data to copy
|
|
35
|
-
* @param target - The destination to copy data into
|
|
36
|
-
* @param targetOffset - The start offset into target to place the copied data
|
|
37
|
-
* @returns the new offset taking into account proper padding
|
|
38
|
-
*/
|
|
39
|
-
function copyToArray(source, target, targetOffset) {
|
|
40
|
-
let sourceArray;
|
|
41
|
-
if (source instanceof ArrayBuffer) {
|
|
42
|
-
sourceArray = new Uint8Array(source);
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
// Pack buffer onto the big target array
|
|
46
|
-
//
|
|
47
|
-
// 'source.data.buffer' could be a view onto a larger buffer.
|
|
48
|
-
// We MUST use this constructor to ensure the byteOffset and byteLength is
|
|
49
|
-
// set to correct values from 'source.data' and not the underlying
|
|
50
|
-
// buffer for target.set() to work properly.
|
|
51
|
-
const srcByteOffset = source.byteOffset;
|
|
52
|
-
const srcByteLength = source.byteLength;
|
|
53
|
-
// In gltf parser it is set as "arrayBuffer" instead of "buffer"
|
|
54
|
-
// https://github.com/visgl/loaders.gl/blob/1e3a82a0a65d7b6a67b1e60633453e5edda2960a/modules/gltf/src/lib/parse-gltf.js#L85
|
|
55
|
-
sourceArray = new Uint8Array(source.buffer || source.arrayBuffer, srcByteOffset, srcByteLength);
|
|
56
|
-
}
|
|
57
|
-
// Pack buffer onto the big target array
|
|
58
|
-
target.set(sourceArray, targetOffset);
|
|
59
|
-
return targetOffset + padToNBytes(sourceArray.byteLength, 4);
|
|
60
|
-
}
|
|
61
|
-
exports.copyToArray = copyToArray;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assert = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Throws an `Error` with the optional `message` if `condition` is falsy
|
|
6
|
-
* @note Replacement for the external assert method to reduce bundle size
|
|
7
|
-
*/
|
|
8
|
-
function assert(condition, message) {
|
|
9
|
-
if (!condition) {
|
|
10
|
-
throw new Error(message || 'loader assertion failed.');
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
exports.assert = assert;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Purpose: include this in your module to avoid
|
|
3
|
-
// dependencies on micro modules like 'global' and 'is-browser';
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.nodeVersion = exports.isWorker = exports.isBrowser = exports.document = exports.global = exports.window = exports.self = void 0;
|
|
6
|
-
/* eslint-disable no-restricted-globals */
|
|
7
|
-
const globals = {
|
|
8
|
-
self: typeof self !== 'undefined' && self,
|
|
9
|
-
window: typeof window !== 'undefined' && window,
|
|
10
|
-
global: typeof global !== 'undefined' && global,
|
|
11
|
-
document: typeof document !== 'undefined' && document
|
|
12
|
-
};
|
|
13
|
-
const self_ = globals.self || globals.window || globals.global || {};
|
|
14
|
-
exports.self = self_;
|
|
15
|
-
const window_ = globals.window || globals.self || globals.global || {};
|
|
16
|
-
exports.window = window_;
|
|
17
|
-
const global_ = globals.global || globals.self || globals.window || {};
|
|
18
|
-
exports.global = global_;
|
|
19
|
-
const document_ = globals.document || {};
|
|
20
|
-
exports.document = document_;
|
|
21
|
-
/** true if running in a browser */
|
|
22
|
-
exports.isBrowser =
|
|
23
|
-
// @ts-ignore process does not exist on browser
|
|
24
|
-
Boolean(typeof process !== 'object' || String(process) !== '[object process]' || process.browser);
|
|
25
|
-
/** true if running in a worker thread */
|
|
26
|
-
exports.isWorker = typeof importScripts === 'function';
|
|
27
|
-
// Extract node major version
|
|
28
|
-
const matches = typeof process !== 'undefined' && process.version && /v([0-9]*)/.exec(process.version);
|
|
29
|
-
/** Major Node version (as a number) */
|
|
30
|
-
exports.nodeVersion = (matches && parseFloat(matches[1])) || 0;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
const fs = __importStar(require("../node/fs"));
|
|
27
|
-
/**
|
|
28
|
-
* FileSystem pass-through for Node.js
|
|
29
|
-
* Compatible with BrowserFileSystem.
|
|
30
|
-
* @param options
|
|
31
|
-
*/
|
|
32
|
-
class NodeFileSystem {
|
|
33
|
-
// implements IFileSystem
|
|
34
|
-
constructor(options) {
|
|
35
|
-
this.fetch = options._fetch;
|
|
36
|
-
}
|
|
37
|
-
async readdir(dirname = '.', options) {
|
|
38
|
-
return await fs.readdir(dirname, options);
|
|
39
|
-
}
|
|
40
|
-
async stat(path, options) {
|
|
41
|
-
const info = await fs.stat(path, options);
|
|
42
|
-
return { size: Number(info.size), isDirectory: () => false, info };
|
|
43
|
-
}
|
|
44
|
-
async fetch(path, options) {
|
|
45
|
-
// Falls back to handle https:/http:/data: etc fetches
|
|
46
|
-
// eslint-disable-next-line
|
|
47
|
-
const fallbackFetch = options.fetch || this.fetch;
|
|
48
|
-
return fallbackFetch(path, options);
|
|
49
|
-
}
|
|
50
|
-
// implements IRandomAccessFileSystem
|
|
51
|
-
async open(path, flags, mode) {
|
|
52
|
-
return await fs.open(path, flags);
|
|
53
|
-
}
|
|
54
|
-
async close(fd) {
|
|
55
|
-
return await fs.close(fd);
|
|
56
|
-
}
|
|
57
|
-
async fstat(fd) {
|
|
58
|
-
const info = await fs.fstat(fd);
|
|
59
|
-
return info;
|
|
60
|
-
}
|
|
61
|
-
async read(fd,
|
|
62
|
-
// @ts-ignore Possibly null
|
|
63
|
-
{ buffer = null, offset = 0, length = buffer.byteLength, position = null }) {
|
|
64
|
-
let totalBytesRead = 0;
|
|
65
|
-
// Read in loop until we get required number of bytes
|
|
66
|
-
while (totalBytesRead < length) {
|
|
67
|
-
const { bytesRead } = await fs.read(fd, buffer, offset + totalBytesRead, length - totalBytesRead, position + totalBytesRead);
|
|
68
|
-
totalBytesRead += bytesRead;
|
|
69
|
-
}
|
|
70
|
-
return { bytesRead: totalBytesRead, buffer };
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
exports.default = NodeFileSystem;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// loaders.gl, MIT license
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.makeReadableFile = void 0;
|
|
5
|
-
/** Helper function to create an envelope reader for a binary memory input */
|
|
6
|
-
function makeReadableFile(data) {
|
|
7
|
-
if (data instanceof ArrayBuffer) {
|
|
8
|
-
const arrayBuffer = data;
|
|
9
|
-
return {
|
|
10
|
-
read: async (start, length) => Buffer.from(data, start, length),
|
|
11
|
-
close: async () => { },
|
|
12
|
-
size: arrayBuffer.byteLength
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
const blob = data;
|
|
16
|
-
return {
|
|
17
|
-
read: async (start, length) => {
|
|
18
|
-
const arrayBuffer = await blob.slice(start, start + length).arrayBuffer();
|
|
19
|
-
return Buffer.from(arrayBuffer);
|
|
20
|
-
},
|
|
21
|
-
close: async () => { },
|
|
22
|
-
size: blob.size
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
exports.makeReadableFile = makeReadableFile;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.makeWritableFile = void 0;
|
|
27
|
-
// Forked from https://github.com/kbajalc/parquets under MIT license (Copyright (c) 2017 ironSource Ltd.)
|
|
28
|
-
const globals_1 = require("../env-utils/globals");
|
|
29
|
-
const fs = __importStar(require("../node/fs"));
|
|
30
|
-
/** Helper function to create an envelope reader for a binary memory input */
|
|
31
|
-
function makeWritableFile(pathOrStream, options) {
|
|
32
|
-
if (globals_1.isBrowser) {
|
|
33
|
-
return {
|
|
34
|
-
write: async () => { },
|
|
35
|
-
close: async () => { }
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
const outputStream = typeof pathOrStream === 'string' ? fs.createWriteStream(pathOrStream, options) : pathOrStream;
|
|
39
|
-
return {
|
|
40
|
-
write: async (buffer) => new Promise((resolve, reject) => {
|
|
41
|
-
outputStream.write(buffer, (err) => (err ? reject(err) : resolve()));
|
|
42
|
-
}),
|
|
43
|
-
close: () => new Promise((resolve, reject) => {
|
|
44
|
-
outputStream.close((err) => (err ? reject(err) : resolve()));
|
|
45
|
-
})
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
exports.makeWritableFile = makeWritableFile;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.concatenateStringsAsync = exports.concatenateArrayBuffersAsync = exports.forEach = void 0;
|
|
4
|
-
const array_buffer_utils_1 = require("../binary-utils/array-buffer-utils");
|
|
5
|
-
// GENERAL UTILITIES
|
|
6
|
-
/**
|
|
7
|
-
* Iterate over async iterator, without resetting iterator if end is not reached
|
|
8
|
-
* - forEach intentionally does not reset iterator if exiting loop prematurely
|
|
9
|
-
* so that iteration can continue in a second loop
|
|
10
|
-
* - It is recommended to use a standard for-await as last loop to ensure
|
|
11
|
-
* iterator gets properly reset
|
|
12
|
-
*
|
|
13
|
-
* TODO - optimize using sync iteration if argument is an Iterable?
|
|
14
|
-
*
|
|
15
|
-
* @param iterator
|
|
16
|
-
* @param visitor
|
|
17
|
-
*/
|
|
18
|
-
async function forEach(iterator, visitor) {
|
|
19
|
-
// eslint-disable-next-line
|
|
20
|
-
while (true) {
|
|
21
|
-
const { done, value } = await iterator.next();
|
|
22
|
-
if (done) {
|
|
23
|
-
iterator.return();
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
const cancel = visitor(value);
|
|
27
|
-
if (cancel) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
exports.forEach = forEach;
|
|
33
|
-
// Breaking big data into iterable chunks, concatenating iterable chunks into big data objects
|
|
34
|
-
/**
|
|
35
|
-
* Concatenates all data chunks yielded by an (async) iterator
|
|
36
|
-
* This function can e.g. be used to enable atomic parsers to work on (async) iterator inputs
|
|
37
|
-
*/
|
|
38
|
-
async function concatenateArrayBuffersAsync(asyncIterator) {
|
|
39
|
-
const arrayBuffers = [];
|
|
40
|
-
for await (const chunk of asyncIterator) {
|
|
41
|
-
arrayBuffers.push(chunk);
|
|
42
|
-
}
|
|
43
|
-
return (0, array_buffer_utils_1.concatenateArrayBuffers)(...arrayBuffers);
|
|
44
|
-
}
|
|
45
|
-
exports.concatenateArrayBuffersAsync = concatenateArrayBuffersAsync;
|
|
46
|
-
async function concatenateStringsAsync(asyncIterator) {
|
|
47
|
-
const strings = [];
|
|
48
|
-
for await (const chunk of asyncIterator) {
|
|
49
|
-
strings.push(chunk);
|
|
50
|
-
}
|
|
51
|
-
return strings.join('');
|
|
52
|
-
}
|
|
53
|
-
exports.concatenateStringsAsync = concatenateStringsAsync;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// TextDecoder iterators
|
|
3
|
-
// TextDecoder will keep any partial undecoded bytes between calls to `decode`
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.makeNumberedLineIterator = exports.makeLineIterator = exports.makeTextEncoderIterator = exports.makeTextDecoderIterator = void 0;
|
|
6
|
-
async function* makeTextDecoderIterator(arrayBufferIterator, options = {}) {
|
|
7
|
-
const textDecoder = new TextDecoder(undefined, options);
|
|
8
|
-
for await (const arrayBuffer of arrayBufferIterator) {
|
|
9
|
-
yield typeof arrayBuffer === 'string'
|
|
10
|
-
? arrayBuffer
|
|
11
|
-
: textDecoder.decode(arrayBuffer, { stream: true });
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.makeTextDecoderIterator = makeTextDecoderIterator;
|
|
15
|
-
// TextEncoder iterator
|
|
16
|
-
// TODO - this is not useful unless min chunk size is given
|
|
17
|
-
// TextEncoder will keep any partial undecoded bytes between calls to `encode`
|
|
18
|
-
// If iterator does not yield strings, assume arrayBuffer and return unencoded
|
|
19
|
-
async function* makeTextEncoderIterator(textIterator) {
|
|
20
|
-
const textEncoder = new TextEncoder();
|
|
21
|
-
for await (const text of textIterator) {
|
|
22
|
-
yield typeof text === 'string' ? textEncoder.encode(text) : text;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.makeTextEncoderIterator = makeTextEncoderIterator;
|
|
26
|
-
/**
|
|
27
|
-
* @param textIterator async iterable yielding strings
|
|
28
|
-
* @returns an async iterable over lines
|
|
29
|
-
* See http://2ality.com/2018/04/async-iter-nodejs.html
|
|
30
|
-
*/
|
|
31
|
-
async function* makeLineIterator(textIterator) {
|
|
32
|
-
let previous = '';
|
|
33
|
-
for await (const textChunk of textIterator) {
|
|
34
|
-
previous += textChunk;
|
|
35
|
-
let eolIndex;
|
|
36
|
-
while ((eolIndex = previous.indexOf('\n')) >= 0) {
|
|
37
|
-
// line includes the EOL
|
|
38
|
-
const line = previous.slice(0, eolIndex + 1);
|
|
39
|
-
previous = previous.slice(eolIndex + 1);
|
|
40
|
-
yield line;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
if (previous.length > 0) {
|
|
44
|
-
yield previous;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
exports.makeLineIterator = makeLineIterator;
|
|
48
|
-
/**
|
|
49
|
-
* @param lineIterator async iterable yielding lines
|
|
50
|
-
* @returns async iterable yielding numbered lines
|
|
51
|
-
*
|
|
52
|
-
* See http://2ality.com/2018/04/async-iter-nodejs.html
|
|
53
|
-
*/
|
|
54
|
-
async function* makeNumberedLineIterator(lineIterator) {
|
|
55
|
-
let counter = 1;
|
|
56
|
-
for await (const line of lineIterator) {
|
|
57
|
-
yield { counter, line };
|
|
58
|
-
counter++;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
exports.makeNumberedLineIterator = makeNumberedLineIterator;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// loaders.gl, MIT license
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.toBuffer = exports.toArrayBuffer = void 0;
|
|
5
|
-
// Isolates Buffer references to ensure they are only bundled under Node.js (avoids big webpack polyfill)
|
|
6
|
-
// this file is selected by the package.json "browser" field).
|
|
7
|
-
/**
|
|
8
|
-
* Convert Buffer to ArrayBuffer
|
|
9
|
-
* Converts Node.js `Buffer` to `ArrayBuffer` (without triggering bundler to include Buffer polyfill on browser)
|
|
10
|
-
* @todo better data type
|
|
11
|
-
*/
|
|
12
|
-
function toArrayBuffer(buffer) {
|
|
13
|
-
return buffer;
|
|
14
|
-
}
|
|
15
|
-
exports.toArrayBuffer = toArrayBuffer;
|
|
16
|
-
/**
|
|
17
|
-
* Convert (copy) ArrayBuffer to Buffer
|
|
18
|
-
*/
|
|
19
|
-
function toBuffer(binaryData) {
|
|
20
|
-
throw new Error('Buffer not supported in browser');
|
|
21
|
-
}
|
|
22
|
-
exports.toBuffer = toBuffer;
|
package/dist/lib/node/buffer.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// loaders.gl, MIT license
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.toBuffer = exports.toArrayBuffer = void 0;
|
|
5
|
-
// Isolates Buffer references to ensure they are only bundled under Node.js (avoids big webpack polyfill)
|
|
6
|
-
// this file is selected by the package.json "browser" field).
|
|
7
|
-
/**
|
|
8
|
-
* Convert Buffer to ArrayBuffer
|
|
9
|
-
* Converts Node.js `Buffer` to `ArrayBuffer` (without triggering bundler to include Buffer polyfill on browser)
|
|
10
|
-
* @todo better data type
|
|
11
|
-
*/
|
|
12
|
-
function toArrayBuffer(buffer) {
|
|
13
|
-
// TODO - per docs we should just be able to call buffer.buffer, but there are issues
|
|
14
|
-
if (Buffer.isBuffer(buffer)) {
|
|
15
|
-
const typedArray = new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.length);
|
|
16
|
-
return typedArray.slice().buffer;
|
|
17
|
-
}
|
|
18
|
-
return buffer;
|
|
19
|
-
}
|
|
20
|
-
exports.toArrayBuffer = toArrayBuffer;
|
|
21
|
-
/**
|
|
22
|
-
* Convert (copy) ArrayBuffer to Buffer
|
|
23
|
-
*/
|
|
24
|
-
function toBuffer(binaryData) {
|
|
25
|
-
if (Buffer.isBuffer(binaryData)) {
|
|
26
|
-
return binaryData;
|
|
27
|
-
}
|
|
28
|
-
if (ArrayBuffer.isView(binaryData)) {
|
|
29
|
-
binaryData = binaryData.buffer;
|
|
30
|
-
}
|
|
31
|
-
if (typeof Buffer !== 'undefined' && binaryData instanceof ArrayBuffer) {
|
|
32
|
-
return Buffer.from(binaryData);
|
|
33
|
-
}
|
|
34
|
-
throw new Error('toBuffer');
|
|
35
|
-
}
|
|
36
|
-
exports.toBuffer = toBuffer;
|