@loaders.gl/loader-utils 3.0.12 → 3.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/es5/json-loader.js +1 -1
- package/dist/es5/json-loader.js.map +1 -1
- package/dist/es5/lib/binary-utils/array-buffer-utils.js +3 -9
- package/dist/es5/lib/binary-utils/array-buffer-utils.js.map +1 -1
- package/dist/es5/lib/binary-utils/buffer-utils.js +5 -4
- package/dist/es5/lib/binary-utils/buffer-utils.js.map +1 -1
- package/dist/es5/lib/env-utils/globals.js +1 -1
- package/dist/es5/lib/env-utils/globals.js.map +1 -1
- package/dist/es5/lib/filesystems/node-filesystem.js.map +1 -1
- package/dist/es5/lib/node/buffer.js +2 -2
- package/dist/es5/lib/node/buffer.js.map +1 -1
- package/dist/es5/lib/path-utils/path.js +6 -0
- package/dist/es5/lib/path-utils/path.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/binary-utils/array-buffer-utils.js +3 -3
- package/dist/esm/lib/binary-utils/array-buffer-utils.js.map +1 -1
- package/dist/esm/lib/binary-utils/buffer-utils.js +5 -4
- package/dist/esm/lib/binary-utils/buffer-utils.js.map +1 -1
- package/dist/esm/lib/env-utils/globals.js +1 -1
- package/dist/esm/lib/env-utils/globals.js.map +1 -1
- package/dist/esm/lib/filesystems/node-filesystem.js.map +1 -1
- package/dist/esm/lib/node/buffer.js +2 -2
- package/dist/esm/lib/node/buffer.js.map +1 -1
- package/dist/esm/lib/path-utils/path.js +4 -0
- package/dist/esm/lib/path-utils/path.js.map +1 -1
- package/package.json +3 -3
- package/src/lib/binary-utils/array-buffer-utils.ts +3 -4
- package/src/lib/binary-utils/buffer-utils.ts +5 -5
- package/src/lib/env-utils/globals.ts +1 -1
- package/src/lib/filesystems/node-filesystem.ts +1 -1
- package/src/lib/node/buffer.ts +2 -2
- package/src/lib/path-utils/path.ts +9 -0
- package/src/types.ts +7 -1
package/dist/es5/json-loader.js
CHANGED
|
@@ -11,7 +11,7 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
|
|
|
11
11
|
|
|
12
12
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
13
|
|
|
14
|
-
var VERSION = typeof "3.0.
|
|
14
|
+
var VERSION = typeof "3.1.0-alpha.4" !== 'undefined' ? "3.1.0-alpha.4" : 'latest';
|
|
15
15
|
var JSONLoader = {
|
|
16
16
|
name: 'JSON',
|
|
17
17
|
id: 'json',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/json-loader.ts"],"names":["VERSION","JSONLoader","name","id","module","version","extensions","mimeTypes","category","text","parseTextSync","parse","arrayBuffer","TextDecoder","decode","options","JSON","_typecheckJSONLoader"],"mappings":";;;;;;;;;;;;;AAIA,IAAMA,OAAO,GAAG,
|
|
1
|
+
{"version":3,"sources":["../../src/json-loader.ts"],"names":["VERSION","JSONLoader","name","id","module","version","extensions","mimeTypes","category","text","parseTextSync","parse","arrayBuffer","TextDecoder","decode","options","JSON","_typecheckJSONLoader"],"mappings":";;;;;;;;;;;;;AAIA,IAAMA,OAAO,GAAG,2BAAuB,WAAvB,qBAAmD,QAAnE;AAMO,IAAMC,UAAU,GAAG;AACxBC,EAAAA,IAAI,EAAE,MADkB;AAExBC,EAAAA,EAAE,EAAE,MAFoB;AAGxBC,EAAAA,MAAM,EAAE,MAHgB;AAIxBC,EAAAA,OAAO,EAAEL,OAJe;AAKxBM,EAAAA,UAAU,EAAE,CAAC,MAAD,EAAS,SAAT,CALY;AAMxBC,EAAAA,SAAS,EAAE,CAAC,kBAAD,CANa;AAOxBC,EAAAA,QAAQ,EAAE,MAPc;AAQxBC,EAAAA,IAAI,EAAE,IARkB;AASxBC,EAAAA,aAAa,EAAbA,aATwB;AAUxBC,EAAAA,KAAK;AAAA,2EAAE,iBAAOC,WAAP;AAAA;AAAA;AAAA;AAAA;AAAA,+CAAuBF,aAAa,CAAC,IAAIG,WAAJ,GAAkBC,MAAlB,CAAyBF,WAAzB,CAAD,CAApC;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAAF;;AAAA;AAAA;AAAA;;AAAA;AAAA,KAVmB;AAWxBG,EAAAA,OAAO,EAAE;AAXe,CAAnB;;;AAeP,SAASL,aAAT,CAAuBD,IAAvB,EAA6B;AAC3B,SAAOO,IAAI,CAACL,KAAL,CAAWF,IAAX,CAAP;AACD;;AAEM,IAAMQ,oBAAsC,GAAGhB,UAA/C","sourcesContent":["import type {LoaderWithParser} from './types';\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\n/**\n * A JSON Micro loader (minimal bundle size)\n * Alternative to `@loaders.gl/json`\n */\nexport const JSONLoader = {\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 - deprecated\nfunction parseTextSync(text) {\n return JSON.parse(text);\n}\n\nexport const _typecheckJSONLoader: LoaderWithParser = JSONLoader;\n"],"file":"json-loader.js"}
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
-
var _typeof3 = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
@@ -15,11 +13,7 @@ exports.sliceArrayBuffer = sliceArrayBuffer;
|
|
|
15
13
|
|
|
16
14
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
17
15
|
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
|
-
|
|
22
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
16
|
+
var _bufferUtils = require("./buffer-utils");
|
|
23
17
|
|
|
24
18
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
25
19
|
|
|
@@ -28,8 +22,8 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
28
22
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
29
23
|
|
|
30
24
|
function toArrayBuffer(data) {
|
|
31
|
-
if (
|
|
32
|
-
|
|
25
|
+
if ((0, _bufferUtils.isBuffer)(data)) {
|
|
26
|
+
return (0, _bufferUtils.bufferToArrayBuffer)(data);
|
|
33
27
|
}
|
|
34
28
|
|
|
35
29
|
if (data instanceof ArrayBuffer) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/binary-utils/array-buffer-utils.ts"],"names":["toArrayBuffer","data","
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/binary-utils/array-buffer-utils.ts"],"names":["toArrayBuffer","data","ArrayBuffer","isView","byteOffset","byteLength","buffer","slice","text","uint8Array","TextEncoder","encode","_toArrayBuffer","Error","compareArrayBuffers","arrayBuffer1","arrayBuffer2","array1","Uint8Array","array2","i","length","concatenateArrayBuffers","sources","sourceArrays","map","source2","reduce","typedArray","result","offset","sourceArray","set","concatenateTypedArrays","typedArrays","arrays","TypedArrayConstructor","constructor","sumLength","acc","value","array","sliceArrayBuffer","arrayBuffer","subArray","undefined","subarray","arrayCopy"],"mappings":";;;;;;;;;;;;;;;AACA;;;;;;;;AAKO,SAASA,aAAT,CAAuBC,IAAvB,EAA+C;AAEpD,MAAI,2BAASA,IAAT,CAAJ,EAAoB;AAClB,WAAO,sCAAoBA,IAApB,CAAP;AACD;;AAED,MAAIA,IAAI,YAAYC,WAApB,EAAiC;AAC/B,WAAOD,IAAP;AACD;;AAGD,MAAIC,WAAW,CAACC,MAAZ,CAAmBF,IAAnB,CAAJ,EAA8B;AAC5B,QAAIA,IAAI,CAACG,UAAL,KAAoB,C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AAd,EAAkD,CAAlD,CAAlB;AAEA,MAAMQ,MAAM,GAAG,IAAIO,qBAAJ,CAA0BE,SAA1B,CAAf;AACA,MAAIR,MAAM,GAAG,CAAb;;AACA,6BAAoBK,MAApB,6BAA4B;AAAvB,QAAMM,KAAK,cAAX;AACHZ,IAAAA,MAAM,CAACG,GAAP,CAAWS,KAAX,EAAkBX,MAAlB;AACAA,IAAAA,MAAM,IAAIW,KAAK,CAACpB,MAAhB;AACD;;AACD,SAAOQ,MAAP;AACD;;AAQM,SAASa,gBAAT,CACLC,WADK,EAELvC,UAFK,EAGLC,UAHK,EAIQ;AACb,MAAMuC,QAAQ,GACZvC,UAAU,KAAKwC,SAAf,GACI,IAAI3B,UAAJ,CAAeyB,WAAf,EAA4BG,QAA5B,CAAqC1C,UAArC,EAAiDA,UAAU,GAAGC,UAA9D,CADJ,GAEI,IAAIa,UAAJ,CAAeyB,WAAf,EAA4BG,QAA5B,CAAqC1C,UAArC,CAHN;AAIA,MAAM2C,SAAS,GAAG,IAAI7B,UAAJ,CAAe0B,QAAf,CAAlB;AACA,SAAOG,SAAS,CAACzC,MAAjB;AACD","sourcesContent":["import {TypedArray} from '../../types';\nimport {isBuffer, bufferToArrayBuffer} from './buffer-utils';\n\n/**\n * Convert an object to an array buffer\n */\nexport function toArrayBuffer(data: any): ArrayBuffer {\n // Note: Should be called first, Buffers can trigger other detections below\n if (isBuffer(data)) {\n return bufferToArrayBuffer(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._toArrayBuffer) {\n return data._toArrayBuffer();\n }\n\n throw new Error('toArrayBuffer');\n}\n\n/**\n * compare two binary arrays for equality\n * @param {ArrayBuffer} a\n * @param {ArrayBuffer} b\n * @param {number} byteLength\n */\nexport function compareArrayBuffers(\n arrayBuffer1: ArrayBuffer,\n arrayBuffer2: ArrayBuffer,\n byteLength?: number\n): boolean {\n byteLength = byteLength || arrayBuffer1.byteLength;\n if (arrayBuffer1.byteLength < byteLength || arrayBuffer2.byteLength < byteLength) {\n return false;\n }\n const array1 = new Uint8Array(arrayBuffer1);\n const array2 = new Uint8Array(arrayBuffer2);\n for (let i = 0; i < array1.length; ++i) {\n if (array1[i] !== array2[i]) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Concatenate a sequence of ArrayBuffers\n * @return A concatenated ArrayBuffer\n */\nexport function concatenateArrayBuffers(...sources: (ArrayBuffer | Uint8Array)[]): ArrayBuffer {\n // Make sure all inputs are wrapped in typed arrays\n const sourceArrays = sources.map((source2) =>\n source2 instanceof ArrayBuffer ? new Uint8Array(source2) : source2\n );\n\n // Get length of all inputs\n const byteLength = sourceArrays.reduce((length, typedArray) => length + typedArray.byteLength, 0);\n\n // Allocate array with space for all inputs\n const result = new Uint8Array(byteLength);\n\n // Copy the subarrays\n let offset = 0;\n for (const sourceArray of sourceArrays) {\n result.set(sourceArray, offset);\n offset += sourceArray.byteLength;\n }\n\n // We work with ArrayBuffers, discard the typed array wrapper\n return result.buffer;\n}\n\n/**\n * Concatenate arbitrary count of typed arrays\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\n * @param {...*} arrays - list of arrays. All arrays should be the same type\n * @return A concatenated TypedArray\n */\nexport function concatenateTypedArrays<T>(...typedArrays: T[]): T {\n // @ts-ignore\n const arrays = typedArrays as TypedArray[];\n // @ts-ignore\n const TypedArrayConstructor = (arrays && arrays.length > 1 && arrays[0].constructor) || null;\n if (!TypedArrayConstructor) {\n throw new Error(\n '\"concatenateTypedArrays\" - incorrect quantity of arguments or arguments have incompatible data types'\n );\n }\n\n const sumLength = arrays.reduce((acc, value) => acc + value.length, 0);\n // @ts-ignore typescript does not like dynamic constructors\n const result = new TypedArrayConstructor(sumLength);\n let offset = 0;\n for (const array of arrays) {\n result.set(array, offset);\n offset += array.length;\n }\n return result;\n}\n\n/**\n * Copy a view of an ArrayBuffer into new ArrayBuffer with byteOffset = 0\n * @param arrayBuffer\n * @param byteOffset\n * @param byteLength\n */\nexport function sliceArrayBuffer(\n arrayBuffer: ArrayBuffer,\n byteOffset: number,\n byteLength?: number\n): ArrayBuffer {\n const subArray =\n byteLength !== undefined\n ? new Uint8Array(arrayBuffer).subarray(byteOffset, byteOffset + byteLength)\n : new Uint8Array(arrayBuffer).subarray(byteOffset);\n const arrayCopy = new Uint8Array(subArray);\n return arrayCopy.buffer;\n}\n"],"file":"array-buffer-utils.js"}
|
|
@@ -27,11 +27,12 @@ function toBuffer(data) {
|
|
|
27
27
|
return node.toBuffer ? node.toBuffer(data) : data;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
function bufferToArrayBuffer(
|
|
31
|
-
if (
|
|
32
|
-
|
|
30
|
+
function bufferToArrayBuffer(buffer) {
|
|
31
|
+
if (isBuffer(buffer)) {
|
|
32
|
+
var typedArray = new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.length);
|
|
33
|
+
return typedArray.slice().buffer;
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
return
|
|
36
|
+
return buffer;
|
|
36
37
|
}
|
|
37
38
|
//# sourceMappingURL=buffer-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/binary-utils/buffer-utils.ts"],"names":["isBuffer","value","toBuffer","data","node","bufferToArrayBuffer","
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/binary-utils/buffer-utils.ts"],"names":["isBuffer","value","toBuffer","data","node","bufferToArrayBuffer","buffer","typedArray","Uint8Array","byteOffset","length","slice"],"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;AAKO,SAASA,QAAT,CAAkBC,KAAlB,EAAuC;AAC5C,SAAOA,KAAK,IAAI,sBAAOA,KAAP,MAAiB,QAA1B,IAAsCA,KAAK,CAACD,QAAnD;AACD;;AAMM,SAASE,QAAT,CAAkBC,IAAlB,EAAqC;AAC1C,SAAOC,IAAI,CAACF,QAAL,GAAgBE,IAAI,CAACF,QAAL,CAAcC,IAAd,CAAhB,GAAsCA,IAA7C;AACD;;AAMM,SAASE,mBAAT,CAA6BC,MAA7B,EAAuD;AAC5D,MAAIN,QAAQ,CAACM,MAAD,CAAZ,EAAsB;AACpB,QAAMC,UAAU,GAAG,IAAIC,UAAJ,CAAeF,MAAM,CAACA,MAAtB,EAA8BA,MAAM,CAACG,UAArC,EAAiDH,MAAM,CAACI,MAAxD,CAAnB;AACA,WAAOH,UAAU,CAACI,KAAX,GAAmBL,MAA1B;AACD;;AACD,SAAOA,MAAP;AACD","sourcesContent":["import * 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 * Converts Node.js `Buffer` to `ArrayBuffer` (without triggering bundler to include Buffer polyfill on browser)\n * @todo better data type\n */\nexport function bufferToArrayBuffer(buffer: any): ArrayBuffer {\n if (isBuffer(buffer)) {\n const typedArray = new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.length);\n return typedArray.slice().buffer;\n }\n return buffer;\n}\n"],"file":"buffer-utils.js"}
|
|
@@ -23,7 +23,7 @@ var global_ = globals.global || globals.self || globals.window || {};
|
|
|
23
23
|
exports.global = global_;
|
|
24
24
|
var document_ = globals.document || {};
|
|
25
25
|
exports.document = document_;
|
|
26
|
-
var isBrowser = (typeof process === "undefined" ? "undefined" : (0, _typeof2.default)(process)) !== 'object' || String(process) !== '[object process]' || process.browser;
|
|
26
|
+
var isBrowser = Boolean((typeof process === "undefined" ? "undefined" : (0, _typeof2.default)(process)) !== 'object' || String(process) !== '[object process]' || process.browser);
|
|
27
27
|
exports.isBrowser = isBrowser;
|
|
28
28
|
var isWorker = typeof importScripts === 'function';
|
|
29
29
|
exports.isWorker = isWorker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/env-utils/globals.ts"],"names":["globals","self","window","global","document","self_","window_","global_","document_","isBrowser","process","String","browser","isWorker","importScripts","matches","version","exec","nodeVersion","parseFloat"],"mappings":";;;;;;;;;;;AAIA,IAAMA,OAAO,GAAG;AACdC,EAAAA,IAAI,EAAE,OAAOA,IAAP,KAAgB,WAAhB,IAA+BA,IADvB;AAEdC,EAAAA,MAAM,EAAE,OAAOA,MAAP,KAAkB,WAAlB,IAAiCA,MAF3B;AAGdC,EAAAA,MAAM,EAAE,OAAOA,MAAP,KAAkB,WAAlB,IAAiCA,MAH3B;AAIdC,EAAAA,QAAQ,EAAE,OAAOA,QAAP,KAAoB,WAApB,IAAmCA;AAJ/B,CAAhB;AAQA,IAAMC,KAAU,GAAGL,OAAO,CAACC,IAAR,IAAgBD,OAAO,CAACE,MAAxB,IAAkCF,OAAO,CAACG,MAA1C,IAAoD,EAAvE;;AACA,IAAMG,OAAY,GAAGN,OAAO,CAACE,MAAR,IAAkBF,OAAO,CAACC,IAA1B,IAAkCD,OAAO,CAACG,MAA1C,IAAoD,EAAzE;;AACA,IAAMI,OAAY,GAAGP,OAAO,CAACG,MAAR,IAAkBH,OAAO,CAACC,IAA1B,IAAkCD,OAAO,CAACE,MAA1C,IAAoD,EAAzE;;AACA,IAAMM,SAAc,GAAGR,OAAO,CAACI,QAAR,IAAoB,EAA3C;;AAKO,IAAMK,SAAkB,
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/env-utils/globals.ts"],"names":["globals","self","window","global","document","self_","window_","global_","document_","isBrowser","Boolean","process","String","browser","isWorker","importScripts","matches","version","exec","nodeVersion","parseFloat"],"mappings":";;;;;;;;;;;AAIA,IAAMA,OAAO,GAAG;AACdC,EAAAA,IAAI,EAAE,OAAOA,IAAP,KAAgB,WAAhB,IAA+BA,IADvB;AAEdC,EAAAA,MAAM,EAAE,OAAOA,MAAP,KAAkB,WAAlB,IAAiCA,MAF3B;AAGdC,EAAAA,MAAM,EAAE,OAAOA,MAAP,KAAkB,WAAlB,IAAiCA,MAH3B;AAIdC,EAAAA,QAAQ,EAAE,OAAOA,QAAP,KAAoB,WAApB,IAAmCA;AAJ/B,CAAhB;AAQA,IAAMC,KAAU,GAAGL,OAAO,CAACC,IAAR,IAAgBD,OAAO,CAACE,MAAxB,IAAkCF,OAAO,CAACG,MAA1C,IAAoD,EAAvE;;AACA,IAAMG,OAAY,GAAGN,OAAO,CAACE,MAAR,IAAkBF,OAAO,CAACC,IAA1B,IAAkCD,OAAO,CAACG,MAA1C,IAAoD,EAAzE;;AACA,IAAMI,OAAY,GAAGP,OAAO,CAACG,MAAR,IAAkBH,OAAO,CAACC,IAA1B,IAAkCD,OAAO,CAACE,MAA1C,IAAoD,EAAzE;;AACA,IAAMM,SAAc,GAAGR,OAAO,CAACI,QAAR,IAAoB,EAA3C;;AAKO,IAAMK,SAAkB,GAE7BC,OAAO,CAAC,QAAOC,OAAP,uDAAOA,OAAP,OAAmB,QAAnB,IAA+BC,MAAM,CAACD,OAAD,CAAN,KAAoB,kBAAnD,IAAyEA,OAAO,CAACE,OAAlF,CAFF;;AAKA,IAAMC,QAAiB,GAAG,OAAOC,aAAP,KAAyB,UAAnD;;AAGP,IAAMC,OAAO,GACX,OAAOL,OAAP,KAAmB,WAAnB,IAAkCA,OAAO,CAACM,OAA1C,IAAqD,YAAYC,IAAZ,CAAiBP,OAAO,CAACM,OAAzB,CADvD;AAGO,IAAME,WAAmB,GAAIH,OAAO,IAAII,UAAU,CAACJ,OAAO,CAAC,CAAD,CAAR,CAAtB,IAAuC,CAAnE","sourcesContent":["// Purpose: include this in your module to avoid\n// dependencies on micro modules like 'global' and 'is-browser';\n\n/* eslint-disable no-restricted-globals */\nconst globals = {\n self: typeof self !== 'undefined' && self,\n window: typeof window !== 'undefined' && window,\n global: typeof global !== 'undefined' && global,\n document: typeof document !== 'undefined' && document\n};\n\ntype obj = {[key: string]: any};\nconst self_: obj = globals.self || globals.window || globals.global || {};\nconst window_: obj = globals.window || globals.self || globals.global || {};\nconst global_: obj = globals.global || globals.self || globals.window || {};\nconst document_: obj = globals.document || {};\n\nexport {self_ as self, window_ as window, global_ as global, document_ as document};\n\n/** true if running in a browser */\nexport const isBrowser: boolean =\n // @ts-ignore process does not exist on browser\n Boolean(typeof process !== 'object' || String(process) !== '[object process]' || process.browser);\n\n/** true if running in a worker thread */\nexport const isWorker: boolean = typeof importScripts === 'function';\n\n// Extract node major version\nconst matches =\n typeof process !== 'undefined' && process.version && /v([0-9]*)/.exec(process.version);\n/** Major Node version (as a number) */\nexport const nodeVersion: number = (matches && parseFloat(matches[1])) || 0;\n"],"file":"globals.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/filesystems/node-filesystem.ts"],"names":["NodeFileSystem","options","fetch","_fetch","dirname","fs","readdir","path","stat","info","size","Number","isDirectory","fallbackFetch","flags","mode","open","fd","close","fstat","buffer","offset","length","byteLength","position","totalBytesRead","read","bytesRead"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;;;;;IAuBqBA,c;AAEnB,0BAAYC,OAAZ,EAA2C;AAAA;AACzC,SAAKC,KAAL,GAAaD,OAAO,CAACE,MAArB;AACD;;;;;+EAED;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAcC,gBAAAA,OAAd,2DAAwB,GAAxB;AAA6BH,gBAAAA,OAA7B;AAAA;AAAA,uBACeI,EAAE,CAACC,OAAH,CAAWF,OAAX,EAAoBH,OAApB,CADf;;AAAA;A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AAAA,IADR;AAAA,kDAESA,IAFT;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;;4EAKA,kBACEQ,EADF;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA,mCAGGG,MAHH,EAGGA,MAHH,4BAGY,IAHZ,mCAGkBC,MAHlB,EAGkBA,MAHlB,4BAG2B,CAH3B,mCAG8BC,MAH9B,EAG8BA,MAH9B,4BAGuCF,MAAM,CAACG,UAH9C,qCAG0DC,QAH1D,EAG0DA,QAH1D,8BAGqE,IAHrE;AAKMC,gBAAAA,cALN,GAKuB,CALvB;;AAAA;AAAA,sBAOSA,cAAc,GAAGH,MAP1B;AAAA;AAAA;AAAA;;AAAA;AAAA,uBAQ8BjB,EAAE,CAACqB,IAAH,CACxBT,EADwB,EAExBG,MAFwB,EAGxBC,MAAM,GAAGI,cAHe,EAIxBH,MAAM,GAAGG,cAJe,EAKxBD,QAAQ,GAAGC,cALa,CAR9B;;AAAA;AAAA;AAQWE,gBAAAA,SARX,kBAQWA,SARX;AAeIF,gBAAAA,cAAc,IAAIE,SAAlB;AAfJ;AAAA;;AAAA;AAAA,kDAiBS;AAACA,kBAAAA,SAAS,EAAEF,cAAZ;AAA4BL,kBAAAA,MAAM,EAANA;AAA5B,iBAjBT;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O","sourcesContent":["import * as fs from '../node/fs';\nimport {IFileSystem, IRandomAccessReadFileSystem} from '
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/filesystems/node-filesystem.ts"],"names":["NodeFileSystem","options","fetch","_fetch","dirname","fs","readdir","path","stat","info","size","Number","isDirectory","fallbackFetch","flags","mode","open","fd","close","fstat","buffer","offset","length","byteLength","position","totalBytesRead","read","bytesRead"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;;;;;IAuBqBA,c;AAEnB,0BAAYC,OAAZ,EAA2C;AAAA;AACzC,SAAKC,KAAL,GAAaD,OAAO,CAACE,MAArB;AACD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AA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;;6EAIA,kBAAYA,EAAZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBACqBZ,EAAE,CAACc,KAAH,CAASF,EAAT,CADrB;;AAAA;AACQR,gBAAAA,IADR;AAAA,kDAESA,IAFT;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;;4EAKA,kBACEQ,EADF;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA,mCAGGG,MAHH,EAGGA,MAHH,4BAGY,IAHZ,mCAGkBC,MAHlB,EAGkBA,MAHlB,4BAG2B,CAH3B,mCAG8BC,MAH9B,EAG8BA,MAH9B,4BAGuCF,MAAM,CAACG,UAH9C,qCAG0DC,QAH1D,EAG0DA,QAH1D,8BAGqE,IAHrE;AAKMC,gBAAAA,cALN,GAKuB,CALvB;;AAAA;AAAA,sBAOSA,cAAc,GAAGH,MAP1B;AAAA;AAAA;AAAA;;AAAA;AAAA,uBAQ8BjB,EAAE,CAACqB,IAAH,CACxBT,EADwB,EAExBG,MAFwB,EAGxBC,MAAM,GAAGI,cAHe,EAIxBH,MAAM,GAAGG,cAJe,EAKxBD,QAAQ,GAAGC,cALa,CAR9B;;AAAA;AAAA;AAQWE,gBAAAA,SARX,kBAQWA,SARX;AAeIF,gBAAAA,cAAc,IAAIE,SAAlB;AAfJ;AAAA;;AAAA;AAAA,kDAiBS;AAACA,kBAAAA,SAAS,EAAEF,cAAZ;AAA4BL,kBAAAA,MAAM,EAANA;AAA5B,iBAjBT;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O","sourcesContent":["import * as fs from '../node/fs';\nimport {IFileSystem, IRandomAccessReadFileSystem} from '../../types';\n// import {fetchFile} from \"../fetch/fetch-file\"\n// import {selectLoader} from \"../api/select-loader\";\n\ntype Stat = {\n size: number;\n isDirectory: () => boolean;\n info?: fs.Stats;\n};\n\ntype ReadOptions = {\n buffer?: Buffer;\n offset?: number;\n length?: number;\n position?: number;\n};\n\n/**\n * FileSystem pass-through for Node.js\n * Compatible with BrowserFileSystem.\n * @param options\n */\nexport default class NodeFileSystem implements IFileSystem, IRandomAccessReadFileSystem {\n // implements IFileSystem\n constructor(options: {[key: string]: any}) {\n this.fetch = options._fetch;\n }\n\n async readdir(dirname = '.', options?: {}): Promise<any[]> {\n return await fs.readdir(dirname, options);\n }\n\n async stat(path: string, options?: {}): Promise<Stat> {\n const info = await fs.stat(path, options);\n return {size: Number(info.size), isDirectory: () => false, info};\n }\n\n async fetch(path: string, options: {[key: string]: any}) {\n // Falls back to handle https:/http:/data: etc fetches\n // eslint-disable-next-line\n const fallbackFetch = options.fetch || this.fetch;\n return fallbackFetch(path, options);\n }\n\n // implements IRandomAccessFileSystem\n async open(path: string, flags: string | number, mode?: any): Promise<number> {\n return await fs.open(path, flags);\n }\n\n async close(fd: number): Promise<void> {\n return await fs.close(fd);\n }\n\n async fstat(fd: number): Promise<Stat> {\n const info = await fs.fstat(fd);\n return info;\n }\n\n async read(\n fd: number,\n // @ts-ignore Possibly null\n {buffer = null, offset = 0, length = buffer.byteLength, position = null}: ReadOptions\n ): Promise<{bytesRead: number; buffer: Buffer}> {\n let totalBytesRead = 0;\n // Read in loop until we get required number of bytes\n while (totalBytesRead < length) {\n const {bytesRead} = await fs.read(\n fd,\n buffer,\n offset + totalBytesRead,\n length - totalBytesRead,\n position + totalBytesRead\n );\n totalBytesRead += bytesRead;\n }\n return {bytesRead: totalBytesRead, buffer};\n }\n}\n"],"file":"node-filesystem.js"}
|
|
@@ -10,8 +10,8 @@ var _assert = require("../env-utils/assert");
|
|
|
10
10
|
|
|
11
11
|
function toArrayBuffer(buffer) {
|
|
12
12
|
if (Buffer.isBuffer(buffer)) {
|
|
13
|
-
var typedArray = new Uint8Array(buffer);
|
|
14
|
-
return typedArray.buffer;
|
|
13
|
+
var typedArray = new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.length);
|
|
14
|
+
return typedArray.slice().buffer;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
return buffer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/node/buffer.ts"],"names":["toArrayBuffer","buffer","Buffer","isBuffer","typedArray","Uint8Array","toBuffer","binaryData","ArrayBuffer","isView","byteLength","view","i"
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/node/buffer.ts"],"names":["toArrayBuffer","buffer","Buffer","isBuffer","typedArray","Uint8Array","byteOffset","length","slice","toBuffer","binaryData","ArrayBuffer","isView","byteLength","view","i"],"mappings":";;;;;;;;AAGA;;AAKO,SAASA,aAAT,CAAuBC,MAAvB,EAA+B;AAEpC,MAAIC,MAAM,CAACC,QAAP,CAAgBF,MAAhB,CAAJ,EAA6B;AAC3B,QAAMG,UAAU,GAAG,IAAIC,UAAJ,CAAeJ,MAAM,CAACA,MAAtB,EAA8BA,MAAM,CAACK,UAArC,EAAiDL,MAAM,CAACM,MAAxD,CAAnB;AACA,WAAOH,UAAU,CAACI,KAAX,GAAmBP,MAA1B;AACD;;AACD,SAAOA,MAAP;AACD;;AAKM,SAASQ,QAAT,CAAkBC,UAAlB,EAA8B;AACnC,MAAIC,WAAW,CAACC,MAAZ,CAAmBF,UAAnB,CAAJ,EAAoC;AAClCA,IAAAA,UAAU,GAAGA,UAAU,CAACT,MAAxB;AACD;;AAED,MAAI,OAAOC,MAAP,KAAkB,WAAlB,IAAiCQ,UAAU,YAAYC,WAA3D,EAAwE;AACtE,QAAMV,MAAM,GAAG,IAAIC,MAAJ,CAAWQ,UAAU,CAACG,UAAtB,CAAf;AACA,QAAMC,IAAI,GAAG,IAAIT,UAAJ,CAAeK,UAAf,CAAb;;AACA,SAAK,IAAIK,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGd,MAAM,CAACM,MAA3B,EAAmC,EAAEQ,CAArC,EAAwC;AACtCd,MAAAA,MAAM,CAACc,CAAD,CAAN,GAAYD,IAAI,CAACC,CAAD,CAAhB;AACD;;AACD,WAAOd,MAAP;AACD;;AAED,SAAO,oBAAO,KAAP,CAAP;AACD","sourcesContent":["// Isolates Buffer references to ensure they are only bundled under Node.js (avoids big webpack polyfill)\n// this file is not visible to webpack (it is excluded in the package.json \"browser\" field).\n\nimport {assert} from '../env-utils/assert';\n\n/**\n * Convert Buffer to ArrayBuffer\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) {\n if (ArrayBuffer.isView(binaryData)) {\n binaryData = binaryData.buffer;\n }\n\n if (typeof Buffer !== 'undefined' && binaryData instanceof ArrayBuffer) {\n const buffer = new Buffer(binaryData.byteLength);\n const view = new Uint8Array(binaryData);\n for (let i = 0; i < buffer.length; ++i) {\n buffer[i] = view[i];\n }\n return buffer;\n }\n\n return assert(false);\n}\n"],"file":"buffer.js"}
|
|
@@ -3,9 +3,15 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.filename = filename;
|
|
6
7
|
exports.dirname = dirname;
|
|
7
8
|
exports.join = join;
|
|
8
9
|
|
|
10
|
+
function filename(url) {
|
|
11
|
+
var slashIndex = url && url.lastIndexOf('/');
|
|
12
|
+
return slashIndex >= 0 ? url.substr(slashIndex + 1) : '';
|
|
13
|
+
}
|
|
14
|
+
|
|
9
15
|
function dirname(url) {
|
|
10
16
|
var slashIndex = url && url.lastIndexOf('/');
|
|
11
17
|
return slashIndex >= 0 ? url.substr(0, slashIndex) : '';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/path-utils/path.ts"],"names":["
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/path-utils/path.ts"],"names":["filename","url","slashIndex","lastIndexOf","substr","dirname","join","parts","separator","map","part","index","replace","RegExp","length"],"mappings":";;;;;;;;;AAMO,SAASA,QAAT,CAAkBC,GAAlB,EAAuC;AAC5C,MAAMC,UAAU,GAAGD,GAAG,IAAIA,GAAG,CAACE,WAAJ,CAAgB,GAAhB,CAA1B;AACA,SAAOD,UAAU,IAAI,CAAd,GAAkBD,GAAG,CAACG,MAAJ,CAAYF,UAAD,GAAyB,CAApC,CAAlB,GAA2D,EAAlE;AACD;;AAMM,SAASG,OAAT,CAAiBJ,GAAjB,EAAsC;AAC3C,MAAMC,UAAU,GAAGD,GAAG,IAAIA,GAAG,CAACE,WAAJ,CAAgB,GAAhB,CAA1B;AACA,SAAOD,UAAU,IAAI,CAAd,GAAkBD,GAAG,CAACG,MAAJ,CAAW,CAAX,EAAcF,UAAd,CAAlB,GAAwD,EAA/D;AACD;;AAMM,SAASI,IAAT,GAA0C;AAAA,oCAAzBC,KAAyB;AAAzBA,IAAAA,KAAyB;AAAA;;AAC/C,MAAMC,SAAS,GAAG,GAAlB;AACAD,EAAAA,KAAK,GAAGA,KAAK,CAACE,GAAN,CAAU,UAACC,IAAD,EAAOC,KAAP,EAAiB;AACjC,QAAIA,KAAJ,EAAW;AACTD,MAAAA,IAAI,GAAGA,IAAI,CAACE,OAAL,CAAa,IAAIC,MAAJ,YAAeL,SAAf,EAAb,EAA0C,EAA1C,CAAP;AACD;;AACD,QAAIG,KAAK,KAAKJ,KAAK,CAACO,MAAN,GAAe,CAA7B,EAAgC;AAC9BJ,MAAAA,IAAI,GAAGA,IAAI,CAACE,OAAL,CAAa,IAAIC,MAAJ,WAAcL,SAAd,OAAb,EAA0C,EAA1C,CAAP;AACD;;AACD,WAAOE,IAAP;AACD,GARO,CAAR;AASA,SAAOH,KAAK,CAACD,IAAN,CAAWE,SAAX,CAAP;AACD","sourcesContent":["// Beginning of a minimal implementation of the Node.js path API, that doesn't pull in big polyfills.\n\n/**\n * Replacement for Node.js path.filename\n * @param url\n */\nexport function filename(url: string): string {\n const slashIndex = url && url.lastIndexOf('/');\n return slashIndex >= 0 ? url.substr((slashIndex as number) + 1) : '';\n}\n\n/**\n * Replacement for Node.js path.dirname\n * @param url\n */\nexport function dirname(url: string): string {\n const slashIndex = url && url.lastIndexOf('/');\n return slashIndex >= 0 ? url.substr(0, slashIndex as number) : '';\n}\n\n/**\n * Replacement for Node.js path.join\n * @param parts\n */\nexport function join(...parts: string[]): string {\n const separator = '/';\n parts = parts.map((part, index) => {\n if (index) {\n part = part.replace(new RegExp(`^${separator}`), '');\n }\n if (index !== parts.length - 1) {\n part = part.replace(new RegExp(`${separator}$`), '');\n }\n return part;\n });\n return parts.join(separator);\n}\n"],"file":"path.js"}
|
package/dist/esm/json-loader.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/json-loader.ts"],"names":["VERSION","JSONLoader","name","id","module","version","extensions","mimeTypes","category","text","parseTextSync","parse","arrayBuffer","TextDecoder","decode","options","JSON","_typecheckJSONLoader"],"mappings":"AAIA,MAAMA,OAAO,GAAG,
|
|
1
|
+
{"version":3,"sources":["../../src/json-loader.ts"],"names":["VERSION","JSONLoader","name","id","module","version","extensions","mimeTypes","category","text","parseTextSync","parse","arrayBuffer","TextDecoder","decode","options","JSON","_typecheckJSONLoader"],"mappings":"AAIA,MAAMA,OAAO,GAAG,2BAAuB,WAAvB,qBAAmD,QAAnE;AAMA,OAAO,MAAMC,UAAU,GAAG;AACxBC,EAAAA,IAAI,EAAE,MADkB;AAExBC,EAAAA,EAAE,EAAE,MAFoB;AAGxBC,EAAAA,MAAM,EAAE,MAHgB;AAIxBC,EAAAA,OAAO,EAAEL,OAJe;AAKxBM,EAAAA,UAAU,EAAE,CAAC,MAAD,EAAS,SAAT,CALY;AAMxBC,EAAAA,SAAS,EAAE,CAAC,kBAAD,CANa;AAOxBC,EAAAA,QAAQ,EAAE,MAPc;AAQxBC,EAAAA,IAAI,EAAE,IARkB;AASxBC,EAAAA,aATwB;AAUxBC,EAAAA,KAAK,EAAE,MAAOC,WAAP,IAAuBF,aAAa,CAAC,IAAIG,WAAJ,GAAkBC,MAAlB,CAAyBF,WAAzB,CAAD,CAVnB;AAWxBG,EAAAA,OAAO,EAAE;AAXe,CAAnB;;AAeP,SAASL,aAAT,CAAuBD,IAAvB,EAA6B;AAC3B,SAAOO,IAAI,CAACL,KAAL,CAAWF,IAAX,CAAP;AACD;;AAED,OAAO,MAAMQ,oBAAsC,GAAGhB,UAA/C","sourcesContent":["import type {LoaderWithParser} from './types';\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\n/**\n * A JSON Micro loader (minimal bundle size)\n * Alternative to `@loaders.gl/json`\n */\nexport const JSONLoader = {\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 - deprecated\nfunction parseTextSync(text) {\n return JSON.parse(text);\n}\n\nexport const _typecheckJSONLoader: LoaderWithParser = JSONLoader;\n"],"file":"json-loader.js"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { isBuffer, bufferToArrayBuffer } from './buffer-utils';
|
|
2
2
|
export function toArrayBuffer(data) {
|
|
3
|
-
if (
|
|
4
|
-
|
|
3
|
+
if (isBuffer(data)) {
|
|
4
|
+
return bufferToArrayBuffer(data);
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
if (data instanceof ArrayBuffer) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/binary-utils/array-buffer-utils.ts"],"names":["
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/binary-utils/array-buffer-utils.ts"],"names":["isBuffer","bufferToArrayBuffer","toArrayBuffer","data","ArrayBuffer","isView","byteOffset","byteLength","buffer","slice","text","uint8Array","TextEncoder","encode","_toArrayBuffer","Error","compareArrayBuffers","arrayBuffer1","arrayBuffer2","array1","Uint8Array","array2","i","length","concatenateArrayBuffers","sources","sourceArrays","map","source2","reduce","typedArray","result","offset","sourceArray","set","concatenateTypedArrays","typedArrays","arrays","TypedArrayConstructor","constructor","sumLength","acc","value","array","sliceArrayBuffer","arrayBuffer","subArray","undefined","subarray","arrayCopy"],"mappings":"AACA,SAAQA,QAAR,EAAkBC,mBAAlB,QAA4C,gBAA5C;AAKA,OAAO,SAASC,aAAT,CAAuBC,IAAvB,EAA+C;AAEpD,MAAIH,QAAQ,CAACG,IAAD,CAAZ,EAAoB;AAClB,WAAOF,mBAAmB,CAACE,IAAD,CAA1B;AACD;;AAED,MAAIA,IAAI,YAAYC,WAApB,EAAiC;AAC/B,WAAOD,IAAP;AACD;;AAGD,MAAIC,WAAW,CAACC,MAAZ,CAAmBF,IAAnB,CAAJ,EAA8B;AAC5B,QAAIA,IAAI,CAACG,UAAL,KAAoB,CAApB,IAAyBH,IAAI,CAACI,UAAL,KAAoBJ,IAAI,CAACK,MAAL,CAAYD,UAA7D,EAAyE;AACvE,aAAOJ,IAAI,CAACK,MAAZ;AACD;;AACD,WAAOL,IAAI,CAACK,MAAL,CAAYC,KAAZ,CAAkBN,IAAI,CAACG,UAAvB,EAAmCH,IAAI,CAACG,UAAL,GAAkBH,IAAI,CAACI,UAA1D,CAAP;AACD;;AAED,MAAI,OAAOJ,IAAP,KAAgB,QAApB,EAA8B;AAC5B,UAAMO,IAAI,GAAGP,IAAb;AACA,UAAMQ,UAAU,GAAG,IAAIC,WAAJ,GAAkBC,MAAlB,CAAyBH,IAAzB,CAAnB;AACA,WAAOC,UAAU,CAACH,MAAlB;AACD;;AAGD,MAAIL,IAAI,IAAI,OAAOA,IAAP,KAAgB,QAA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,SAAS,CAACzC,MAAjB;AACD","sourcesContent":["import {TypedArray} from '../../types';\nimport {isBuffer, bufferToArrayBuffer} from './buffer-utils';\n\n/**\n * Convert an object to an array buffer\n */\nexport function toArrayBuffer(data: any): ArrayBuffer {\n // Note: Should be called first, Buffers can trigger other detections below\n if (isBuffer(data)) {\n return bufferToArrayBuffer(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._toArrayBuffer) {\n return data._toArrayBuffer();\n }\n\n throw new Error('toArrayBuffer');\n}\n\n/**\n * compare two binary arrays for equality\n * @param {ArrayBuffer} a\n * @param {ArrayBuffer} b\n * @param {number} byteLength\n */\nexport function compareArrayBuffers(\n arrayBuffer1: ArrayBuffer,\n arrayBuffer2: ArrayBuffer,\n byteLength?: number\n): boolean {\n byteLength = byteLength || arrayBuffer1.byteLength;\n if (arrayBuffer1.byteLength < byteLength || arrayBuffer2.byteLength < byteLength) {\n return false;\n }\n const array1 = new Uint8Array(arrayBuffer1);\n const array2 = new Uint8Array(arrayBuffer2);\n for (let i = 0; i < array1.length; ++i) {\n if (array1[i] !== array2[i]) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Concatenate a sequence of ArrayBuffers\n * @return A concatenated ArrayBuffer\n */\nexport function concatenateArrayBuffers(...sources: (ArrayBuffer | Uint8Array)[]): ArrayBuffer {\n // Make sure all inputs are wrapped in typed arrays\n const sourceArrays = sources.map((source2) =>\n source2 instanceof ArrayBuffer ? new Uint8Array(source2) : source2\n );\n\n // Get length of all inputs\n const byteLength = sourceArrays.reduce((length, typedArray) => length + typedArray.byteLength, 0);\n\n // Allocate array with space for all inputs\n const result = new Uint8Array(byteLength);\n\n // Copy the subarrays\n let offset = 0;\n for (const sourceArray of sourceArrays) {\n result.set(sourceArray, offset);\n offset += sourceArray.byteLength;\n }\n\n // We work with ArrayBuffers, discard the typed array wrapper\n return result.buffer;\n}\n\n/**\n * Concatenate arbitrary count of typed arrays\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\n * @param {...*} arrays - list of arrays. All arrays should be the same type\n * @return A concatenated TypedArray\n */\nexport function concatenateTypedArrays<T>(...typedArrays: T[]): T {\n // @ts-ignore\n const arrays = typedArrays as TypedArray[];\n // @ts-ignore\n const TypedArrayConstructor = (arrays && arrays.length > 1 && arrays[0].constructor) || null;\n if (!TypedArrayConstructor) {\n throw new Error(\n '\"concatenateTypedArrays\" - incorrect quantity of arguments or arguments have incompatible data types'\n );\n }\n\n const sumLength = arrays.reduce((acc, value) => acc + value.length, 0);\n // @ts-ignore typescript does not like dynamic constructors\n const result = new TypedArrayConstructor(sumLength);\n let offset = 0;\n for (const array of arrays) {\n result.set(array, offset);\n offset += array.length;\n }\n return result;\n}\n\n/**\n * Copy a view of an ArrayBuffer into new ArrayBuffer with byteOffset = 0\n * @param arrayBuffer\n * @param byteOffset\n * @param byteLength\n */\nexport function sliceArrayBuffer(\n arrayBuffer: ArrayBuffer,\n byteOffset: number,\n byteLength?: number\n): ArrayBuffer {\n const subArray =\n byteLength !== undefined\n ? new Uint8Array(arrayBuffer).subarray(byteOffset, byteOffset + byteLength)\n : new Uint8Array(arrayBuffer).subarray(byteOffset);\n const arrayCopy = new Uint8Array(subArray);\n return arrayCopy.buffer;\n}\n"],"file":"array-buffer-utils.js"}
|
|
@@ -5,11 +5,12 @@ export function isBuffer(value) {
|
|
|
5
5
|
export function toBuffer(data) {
|
|
6
6
|
return node.toBuffer ? node.toBuffer(data) : data;
|
|
7
7
|
}
|
|
8
|
-
export function bufferToArrayBuffer(
|
|
9
|
-
if (
|
|
10
|
-
|
|
8
|
+
export function bufferToArrayBuffer(buffer) {
|
|
9
|
+
if (isBuffer(buffer)) {
|
|
10
|
+
const typedArray = new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.length);
|
|
11
|
+
return typedArray.slice().buffer;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
return
|
|
14
|
+
return buffer;
|
|
14
15
|
}
|
|
15
16
|
//# sourceMappingURL=buffer-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/binary-utils/buffer-utils.ts"],"names":["node","isBuffer","value","toBuffer","data","bufferToArrayBuffer","
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/binary-utils/buffer-utils.ts"],"names":["node","isBuffer","value","toBuffer","data","bufferToArrayBuffer","buffer","typedArray","Uint8Array","byteOffset","length","slice"],"mappings":"AAAA,OAAO,KAAKA,IAAZ,MAAsB,gBAAtB;AAKA,OAAO,SAASC,QAAT,CAAkBC,KAAlB,EAAuC;AAC5C,SAAOA,KAAK,IAAI,OAAOA,KAAP,KAAiB,QAA1B,IAAsCA,KAAK,CAACD,QAAnD;AACD;AAMD,OAAO,SAASE,QAAT,CAAkBC,IAAlB,EAAqC;AAC1C,SAAOJ,IAAI,CAACG,QAAL,GAAgBH,IAAI,CAACG,QAAL,CAAcC,IAAd,CAAhB,GAAsCA,IAA7C;AACD;AAMD,OAAO,SAASC,mBAAT,CAA6BC,MAA7B,EAAuD;AAC5D,MAAIL,QAAQ,CAACK,MAAD,CAAZ,EAAsB;AACpB,UAAMC,UAAU,GAAG,IAAIC,UAAJ,CAAeF,MAAM,CAACA,MAAtB,EAA8BA,MAAM,CAACG,UAArC,EAAiDH,MAAM,CAACI,MAAxD,CAAnB;AACA,WAAOH,UAAU,CAACI,KAAX,GAAmBL,MAA1B;AACD;;AACD,SAAOA,MAAP;AACD","sourcesContent":["import * 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 * Converts Node.js `Buffer` to `ArrayBuffer` (without triggering bundler to include Buffer polyfill on browser)\n * @todo better data type\n */\nexport function bufferToArrayBuffer(buffer: any): ArrayBuffer {\n if (isBuffer(buffer)) {\n const typedArray = new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.length);\n return typedArray.slice().buffer;\n }\n return buffer;\n}\n"],"file":"buffer-utils.js"}
|
|
@@ -9,7 +9,7 @@ const window_ = globals.window || globals.self || globals.global || {};
|
|
|
9
9
|
const global_ = globals.global || globals.self || globals.window || {};
|
|
10
10
|
const document_ = globals.document || {};
|
|
11
11
|
export { self_ as self, window_ as window, global_ as global, document_ as document };
|
|
12
|
-
export const isBrowser = typeof process !== 'object' || String(process) !== '[object process]' || process.browser;
|
|
12
|
+
export const isBrowser = Boolean(typeof process !== 'object' || String(process) !== '[object process]' || process.browser);
|
|
13
13
|
export const isWorker = typeof importScripts === 'function';
|
|
14
14
|
const matches = typeof process !== 'undefined' && process.version && /v([0-9]*)/.exec(process.version);
|
|
15
15
|
export const nodeVersion = matches && parseFloat(matches[1]) || 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/env-utils/globals.ts"],"names":["globals","self","window","global","document","self_","window_","global_","document_","isBrowser","process","String","browser","isWorker","importScripts","matches","version","exec","nodeVersion","parseFloat"],"mappings":"AAIA,MAAMA,OAAO,GAAG;AACdC,EAAAA,IAAI,EAAE,OAAOA,IAAP,KAAgB,WAAhB,IAA+BA,IADvB;AAEdC,EAAAA,MAAM,EAAE,OAAOA,MAAP,KAAkB,WAAlB,IAAiCA,MAF3B;AAGdC,EAAAA,MAAM,EAAE,OAAOA,MAAP,KAAkB,WAAlB,IAAiCA,MAH3B;AAIdC,EAAAA,QAAQ,EAAE,OAAOA,QAAP,KAAoB,WAApB,IAAmCA;AAJ/B,CAAhB;AAQA,MAAMC,KAAU,GAAGL,OAAO,CAACC,IAAR,IAAgBD,OAAO,CAACE,MAAxB,IAAkCF,OAAO,CAACG,MAA1C,IAAoD,EAAvE;AACA,MAAMG,OAAY,GAAGN,OAAO,CAACE,MAAR,IAAkBF,OAAO,CAACC,IAA1B,IAAkCD,OAAO,CAACG,MAA1C,IAAoD,EAAzE;AACA,MAAMI,OAAY,GAAGP,OAAO,CAACG,MAAR,IAAkBH,OAAO,CAACC,IAA1B,IAAkCD,OAAO,CAACE,MAA1C,IAAoD,EAAzE;AACA,MAAMM,SAAc,GAAGR,OAAO,CAACI,QAAR,IAAoB,EAA3C;AAEA,SAAQC,KAAK,IAAIJ,IAAjB,EAAuBK,OAAO,IAAIJ,MAAlC,EAA0CK,OAAO,IAAIJ,MAArD,EAA6DK,SAAS,IAAIJ,QAA1E;AAGA,OAAO,MAAMK,SAAkB,
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/env-utils/globals.ts"],"names":["globals","self","window","global","document","self_","window_","global_","document_","isBrowser","Boolean","process","String","browser","isWorker","importScripts","matches","version","exec","nodeVersion","parseFloat"],"mappings":"AAIA,MAAMA,OAAO,GAAG;AACdC,EAAAA,IAAI,EAAE,OAAOA,IAAP,KAAgB,WAAhB,IAA+BA,IADvB;AAEdC,EAAAA,MAAM,EAAE,OAAOA,MAAP,KAAkB,WAAlB,IAAiCA,MAF3B;AAGdC,EAAAA,MAAM,EAAE,OAAOA,MAAP,KAAkB,WAAlB,IAAiCA,MAH3B;AAIdC,EAAAA,QAAQ,EAAE,OAAOA,QAAP,KAAoB,WAApB,IAAmCA;AAJ/B,CAAhB;AAQA,MAAMC,KAAU,GAAGL,OAAO,CAACC,IAAR,IAAgBD,OAAO,CAACE,MAAxB,IAAkCF,OAAO,CAACG,MAA1C,IAAoD,EAAvE;AACA,MAAMG,OAAY,GAAGN,OAAO,CAACE,MAAR,IAAkBF,OAAO,CAACC,IAA1B,IAAkCD,OAAO,CAACG,MAA1C,IAAoD,EAAzE;AACA,MAAMI,OAAY,GAAGP,OAAO,CAACG,MAAR,IAAkBH,OAAO,CAACC,IAA1B,IAAkCD,OAAO,CAACE,MAA1C,IAAoD,EAAzE;AACA,MAAMM,SAAc,GAAGR,OAAO,CAACI,QAAR,IAAoB,EAA3C;AAEA,SAAQC,KAAK,IAAIJ,IAAjB,EAAuBK,OAAO,IAAIJ,MAAlC,EAA0CK,OAAO,IAAIJ,MAArD,EAA6DK,SAAS,IAAIJ,QAA1E;AAGA,OAAO,MAAMK,SAAkB,GAE7BC,OAAO,CAAC,OAAOC,OAAP,KAAmB,QAAnB,IAA+BC,MAAM,CAACD,OAAD,CAAN,KAAoB,kBAAnD,IAAyEA,OAAO,CAACE,OAAlF,CAFF;AAKP,OAAO,MAAMC,QAAiB,GAAG,OAAOC,aAAP,KAAyB,UAAnD;AAGP,MAAMC,OAAO,GACX,OAAOL,OAAP,KAAmB,WAAnB,IAAkCA,OAAO,CAACM,OAA1C,IAAqD,YAAYC,IAAZ,CAAiBP,OAAO,CAACM,OAAzB,CADvD;AAGA,OAAO,MAAME,WAAmB,GAAIH,OAAO,IAAII,UAAU,CAACJ,OAAO,CAAC,CAAD,CAAR,CAAtB,IAAuC,CAAnE","sourcesContent":["// Purpose: include this in your module to avoid\n// dependencies on micro modules like 'global' and 'is-browser';\n\n/* eslint-disable no-restricted-globals */\nconst globals = {\n self: typeof self !== 'undefined' && self,\n window: typeof window !== 'undefined' && window,\n global: typeof global !== 'undefined' && global,\n document: typeof document !== 'undefined' && document\n};\n\ntype obj = {[key: string]: any};\nconst self_: obj = globals.self || globals.window || globals.global || {};\nconst window_: obj = globals.window || globals.self || globals.global || {};\nconst global_: obj = globals.global || globals.self || globals.window || {};\nconst document_: obj = globals.document || {};\n\nexport {self_ as self, window_ as window, global_ as global, document_ as document};\n\n/** true if running in a browser */\nexport const isBrowser: boolean =\n // @ts-ignore process does not exist on browser\n Boolean(typeof process !== 'object' || String(process) !== '[object process]' || process.browser);\n\n/** true if running in a worker thread */\nexport const isWorker: boolean = typeof importScripts === 'function';\n\n// Extract node major version\nconst matches =\n typeof process !== 'undefined' && process.version && /v([0-9]*)/.exec(process.version);\n/** Major Node version (as a number) */\nexport const nodeVersion: number = (matches && parseFloat(matches[1])) || 0;\n"],"file":"globals.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/filesystems/node-filesystem.ts"],"names":["fs","NodeFileSystem","constructor","options","fetch","_fetch","readdir","dirname","stat","path","info","size","Number","isDirectory","fallbackFetch","open","flags","mode","close","fd","fstat","read","buffer","offset","length","byteLength","position","totalBytesRead","bytesRead"],"mappings":"AAAA,OAAO,KAAKA,EAAZ,MAAoB,YAApB;AAuBA,eAAe,MAAMC,cAAN,CAAyE;AAEtFC,EAAAA,WAAW,CAACC,OAAD,EAAgC;AACzC,SAAKC,KAAL,GAAaD,OAAO,CAACE,MAArB;AACD;;AAEY,QAAPC,OAAO,CAACC,OAAO,GAAG,GAAX,EAAgBJ,OAAhB,EAA8C;AACzD,WAAO,MAAMH,EAAE,CAACM,OAAH,CAAWC,OAAX,EAAoBJ,OAApB,CAAb;AACD;;AAES,QAAJK,IAAI,CAACC,IAAD,EAAeN,OAAf,EAA4C;AACpD,UAAMO,IAAI,GAAG,MAAMV,EAAE,CAACQ,IAAH,CAAQC,IAAR,EAAcN,OAAd,CAAnB;AACA,WAAO;AAACQ,MAAAA,IAAI,EAAEC,MAAM,CAACF,IAAI,CAACC,IAAN,CAAb;AAA0BE,MAAAA,WAAW,EAAE,MAAM,KAA7C;AAAoDH,MAAAA;AAApD,KAAP;AACD;;AAEU,QAALN,KAAK,CAACK,IAAD,EAAeN,OAAf,EAA8C;AAGvD,UAAMW,aAAa,GAAGX,OAAO,CAACC,KAAR,IAAiB,KAAKA,KAA5C;AACA,WAAOU,aAAa,CAACL,IAAD,EAAON,OAAP,CAApB;AACD;;AAGS,QAAJY,IAAI,CAACN,IAAD,EAAeO,KAAf,EAAuCC,IAAvC,EAAoE;AAC5E,WAAO,MAAMjB,EAAE,CAACe,IAAH,CAAQN,IAAR,EAAcO,KAAd,CAAb;AACD;;AAEU,QAALE,KAAK,CAACC,EAAD,EAA4B;AACrC,WAAO,MAAMnB,EAAE,CAACkB,KAAH,CAASC,EAAT,CAAb;AACD;;AAEU,QAALC,KAAK,CAACD,EAAD,EAA4B;AACrC,UAAMT,IAAI,GAAG,MAAMV,EAAE,CAACoB,KAAH,CAASD,EAAT,CAAnB;AACA,WAAOT,IAAP;AACD;;AAES,QAAJW,IAAI,CACRF,EADQ,EAGR;AAACG,IAAAA,MAAM,GAAG,IAAV;AAAgBC,IAAAA,MAAM,GAAG,CAAzB;AAA4BC,IAAAA,MAAM,GAAGF,MAAM,CAACG,UAA5C;AAAwDC,IAAAA,QAAQ,GAAG;AAAnE,GAHQ,EAIsC;AAC9C,QAAIC,cAAc,GAAG,CAArB;;AAEA,WAAOA,cAAc,GAAGH,MAAxB,EAAgC;AAC9B,YAAM;AAACI,QAAAA;AAAD,UAAc,MAAM5B,EAAE,CAACqB,IAAH,CACxBF,EADwB,EAExBG,MAFwB,EAGxBC,MAAM,GAAGI,cAHe,EAIxBH,MAAM,GAAGG,cAJe,EAKxBD,QAAQ,GAAGC,cALa,CAA1B;AAOAA,MAAAA,cAAc,IAAIC,SAAlB;AACD;;AACD,WAAO;AAACA,MAAAA,SAAS,EAAED,cAAZ;AAA4BL,MAAAA;AAA5B,KAAP;AACD;;AAtDqF","sourcesContent":["import * as fs from '../node/fs';\nimport {IFileSystem, IRandomAccessReadFileSystem} from '
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/filesystems/node-filesystem.ts"],"names":["fs","NodeFileSystem","constructor","options","fetch","_fetch","readdir","dirname","stat","path","info","size","Number","isDirectory","fallbackFetch","open","flags","mode","close","fd","fstat","read","buffer","offset","length","byteLength","position","totalBytesRead","bytesRead"],"mappings":"AAAA,OAAO,KAAKA,EAAZ,MAAoB,YAApB;AAuBA,eAAe,MAAMC,cAAN,CAAyE;AAEtFC,EAAAA,WAAW,CAACC,OAAD,EAAgC;AACzC,SAAKC,KAAL,GAAaD,OAAO,CAACE,MAArB;AACD;;AAEY,QAAPC,OAAO,CAACC,OAAO,GAAG,GAAX,EAAgBJ,OAAhB,EAA8C;AACzD,WAAO,MAAMH,EAAE,CAACM,OAAH,CAAWC,OAAX,EAAoBJ,OAApB,CAAb;AACD;;AAES,QAAJK,IAAI,CAACC,IAAD,EAAeN,OAAf,EAA4C;AACpD,UAAMO,IAAI,GAAG,MAAMV,EAAE,CAACQ,IAAH,CAAQC,IAAR,EAAcN,OAAd,CAAnB;AACA,WAAO;AAACQ,MAAAA,IAAI,EAAEC,MAAM,CAACF,IAAI,CAACC,IAAN,CAAb;AAA0BE,MAAAA,WAAW,EAAE,MAAM,KAA7C;AAAoDH,MAAAA;AAApD,KAAP;AACD;;AAEU,QAALN,KAAK,CAACK,IAAD,EAAeN,OAAf,EAA8C;AAGvD,UAAMW,aAAa,GAAGX,OAAO,CAACC,KAAR,IAAiB,KAAKA,KAA5C;AACA,WAAOU,aAAa,CAACL,IAAD,EAAON,OAAP,CAApB;AACD;;AAGS,QAAJY,IAAI,CAACN,IAAD,EAAeO,KAAf,EAAuCC,IAAvC,EAAoE;AAC5E,WAAO,MAAMjB,EAAE,CAACe,IAAH,CAAQN,IAAR,EAAcO,KAAd,CAAb;AACD;;AAEU,QAALE,KAAK,CAACC,EAAD,EAA4B;AACrC,WAAO,MAAMnB,EAAE,CAACkB,KAAH,CAASC,EAAT,CAAb;AACD;;AAEU,QAALC,KAAK,CAACD,EAAD,EAA4B;AACrC,UAAMT,IAAI,GAAG,MAAMV,EAAE,CAACoB,KAAH,CAASD,EAAT,CAAnB;AACA,WAAOT,IAAP;AACD;;AAES,QAAJW,IAAI,CACRF,EADQ,EAGR;AAACG,IAAAA,MAAM,GAAG,IAAV;AAAgBC,IAAAA,MAAM,GAAG,CAAzB;AAA4BC,IAAAA,MAAM,GAAGF,MAAM,CAACG,UAA5C;AAAwDC,IAAAA,QAAQ,GAAG;AAAnE,GAHQ,EAIsC;AAC9C,QAAIC,cAAc,GAAG,CAArB;;AAEA,WAAOA,cAAc,GAAGH,MAAxB,EAAgC;AAC9B,YAAM;AAACI,QAAAA;AAAD,UAAc,MAAM5B,EAAE,CAACqB,IAAH,CACxBF,EADwB,EAExBG,MAFwB,EAGxBC,MAAM,GAAGI,cAHe,EAIxBH,MAAM,GAAGG,cAJe,EAKxBD,QAAQ,GAAGC,cALa,CAA1B;AAOAA,MAAAA,cAAc,IAAIC,SAAlB;AACD;;AACD,WAAO;AAACA,MAAAA,SAAS,EAAED,cAAZ;AAA4BL,MAAAA;AAA5B,KAAP;AACD;;AAtDqF","sourcesContent":["import * as fs from '../node/fs';\nimport {IFileSystem, IRandomAccessReadFileSystem} from '../../types';\n// import {fetchFile} from \"../fetch/fetch-file\"\n// import {selectLoader} from \"../api/select-loader\";\n\ntype Stat = {\n size: number;\n isDirectory: () => boolean;\n info?: fs.Stats;\n};\n\ntype ReadOptions = {\n buffer?: Buffer;\n offset?: number;\n length?: number;\n position?: number;\n};\n\n/**\n * FileSystem pass-through for Node.js\n * Compatible with BrowserFileSystem.\n * @param options\n */\nexport default class NodeFileSystem implements IFileSystem, IRandomAccessReadFileSystem {\n // implements IFileSystem\n constructor(options: {[key: string]: any}) {\n this.fetch = options._fetch;\n }\n\n async readdir(dirname = '.', options?: {}): Promise<any[]> {\n return await fs.readdir(dirname, options);\n }\n\n async stat(path: string, options?: {}): Promise<Stat> {\n const info = await fs.stat(path, options);\n return {size: Number(info.size), isDirectory: () => false, info};\n }\n\n async fetch(path: string, options: {[key: string]: any}) {\n // Falls back to handle https:/http:/data: etc fetches\n // eslint-disable-next-line\n const fallbackFetch = options.fetch || this.fetch;\n return fallbackFetch(path, options);\n }\n\n // implements IRandomAccessFileSystem\n async open(path: string, flags: string | number, mode?: any): Promise<number> {\n return await fs.open(path, flags);\n }\n\n async close(fd: number): Promise<void> {\n return await fs.close(fd);\n }\n\n async fstat(fd: number): Promise<Stat> {\n const info = await fs.fstat(fd);\n return info;\n }\n\n async read(\n fd: number,\n // @ts-ignore Possibly null\n {buffer = null, offset = 0, length = buffer.byteLength, position = null}: ReadOptions\n ): Promise<{bytesRead: number; buffer: Buffer}> {\n let totalBytesRead = 0;\n // Read in loop until we get required number of bytes\n while (totalBytesRead < length) {\n const {bytesRead} = await fs.read(\n fd,\n buffer,\n offset + totalBytesRead,\n length - totalBytesRead,\n position + totalBytesRead\n );\n totalBytesRead += bytesRead;\n }\n return {bytesRead: totalBytesRead, buffer};\n }\n}\n"],"file":"node-filesystem.js"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { assert } from '../env-utils/assert';
|
|
2
2
|
export function toArrayBuffer(buffer) {
|
|
3
3
|
if (Buffer.isBuffer(buffer)) {
|
|
4
|
-
const typedArray = new Uint8Array(buffer);
|
|
5
|
-
return typedArray.buffer;
|
|
4
|
+
const typedArray = new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.length);
|
|
5
|
+
return typedArray.slice().buffer;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
return buffer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/node/buffer.ts"],"names":["assert","toArrayBuffer","buffer","Buffer","isBuffer","typedArray","Uint8Array","toBuffer","binaryData","ArrayBuffer","isView","byteLength","view","i"
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/node/buffer.ts"],"names":["assert","toArrayBuffer","buffer","Buffer","isBuffer","typedArray","Uint8Array","byteOffset","length","slice","toBuffer","binaryData","ArrayBuffer","isView","byteLength","view","i"],"mappings":"AAGA,SAAQA,MAAR,QAAqB,qBAArB;AAKA,OAAO,SAASC,aAAT,CAAuBC,MAAvB,EAA+B;AAEpC,MAAIC,MAAM,CAACC,QAAP,CAAgBF,MAAhB,CAAJ,EAA6B;AAC3B,UAAMG,UAAU,GAAG,IAAIC,UAAJ,CAAeJ,MAAM,CAACA,MAAtB,EAA8BA,MAAM,CAACK,UAArC,EAAiDL,MAAM,CAACM,MAAxD,CAAnB;AACA,WAAOH,UAAU,CAACI,KAAX,GAAmBP,MAA1B;AACD;;AACD,SAAOA,MAAP;AACD;AAKD,OAAO,SAASQ,QAAT,CAAkBC,UAAlB,EAA8B;AACnC,MAAIC,WAAW,CAACC,MAAZ,CAAmBF,UAAnB,CAAJ,EAAoC;AAClCA,IAAAA,UAAU,GAAGA,UAAU,CAACT,MAAxB;AACD;;AAED,MAAI,OAAOC,MAAP,KAAkB,WAAlB,IAAiCQ,UAAU,YAAYC,WAA3D,EAAwE;AACtE,UAAMV,MAAM,GAAG,IAAIC,MAAJ,CAAWQ,UAAU,CAACG,UAAtB,CAAf;AACA,UAAMC,IAAI,GAAG,IAAIT,UAAJ,CAAeK,UAAf,CAAb;;AACA,SAAK,IAAIK,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGd,MAAM,CAACM,MAA3B,EAAmC,EAAEQ,CAArC,EAAwC;AACtCd,MAAAA,MAAM,CAACc,CAAD,CAAN,GAAYD,IAAI,CAACC,CAAD,CAAhB;AACD;;AACD,WAAOd,MAAP;AACD;;AAED,SAAOF,MAAM,CAAC,KAAD,CAAb;AACD","sourcesContent":["// Isolates Buffer references to ensure they are only bundled under Node.js (avoids big webpack polyfill)\n// this file is not visible to webpack (it is excluded in the package.json \"browser\" field).\n\nimport {assert} from '../env-utils/assert';\n\n/**\n * Convert Buffer to ArrayBuffer\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) {\n if (ArrayBuffer.isView(binaryData)) {\n binaryData = binaryData.buffer;\n }\n\n if (typeof Buffer !== 'undefined' && binaryData instanceof ArrayBuffer) {\n const buffer = new Buffer(binaryData.byteLength);\n const view = new Uint8Array(binaryData);\n for (let i = 0; i < buffer.length; ++i) {\n buffer[i] = view[i];\n }\n return buffer;\n }\n\n return assert(false);\n}\n"],"file":"buffer.js"}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
export function filename(url) {
|
|
2
|
+
const slashIndex = url && url.lastIndexOf('/');
|
|
3
|
+
return slashIndex >= 0 ? url.substr(slashIndex + 1) : '';
|
|
4
|
+
}
|
|
1
5
|
export function dirname(url) {
|
|
2
6
|
const slashIndex = url && url.lastIndexOf('/');
|
|
3
7
|
return slashIndex >= 0 ? url.substr(0, slashIndex) : '';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/path-utils/path.ts"],"names":["
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/path-utils/path.ts"],"names":["filename","url","slashIndex","lastIndexOf","substr","dirname","join","parts","separator","map","part","index","replace","RegExp","length"],"mappings":"AAMA,OAAO,SAASA,QAAT,CAAkBC,GAAlB,EAAuC;AAC5C,QAAMC,UAAU,GAAGD,GAAG,IAAIA,GAAG,CAACE,WAAJ,CAAgB,GAAhB,CAA1B;AACA,SAAOD,UAAU,IAAI,CAAd,GAAkBD,GAAG,CAACG,MAAJ,CAAYF,UAAD,GAAyB,CAApC,CAAlB,GAA2D,EAAlE;AACD;AAMD,OAAO,SAASG,OAAT,CAAiBJ,GAAjB,EAAsC;AAC3C,QAAMC,UAAU,GAAGD,GAAG,IAAIA,GAAG,CAACE,WAAJ,CAAgB,GAAhB,CAA1B;AACA,SAAOD,UAAU,IAAI,CAAd,GAAkBD,GAAG,CAACG,MAAJ,CAAW,CAAX,EAAcF,UAAd,CAAlB,GAAwD,EAA/D;AACD;AAMD,OAAO,SAASI,IAAT,CAAc,GAAGC,KAAjB,EAA0C;AAC/C,QAAMC,SAAS,GAAG,GAAlB;AACAD,EAAAA,KAAK,GAAGA,KAAK,CAACE,GAAN,CAAU,CAACC,IAAD,EAAOC,KAAP,KAAiB;AACjC,QAAIA,KAAJ,EAAW;AACTD,MAAAA,IAAI,GAAGA,IAAI,CAACE,OAAL,CAAa,IAAIC,MAAJ,CAAY,IAAGL,SAAU,EAAzB,CAAb,EAA0C,EAA1C,CAAP;AACD;;AACD,QAAIG,KAAK,KAAKJ,KAAK,CAACO,MAAN,GAAe,CAA7B,EAAgC;AAC9BJ,MAAAA,IAAI,GAAGA,IAAI,CAACE,OAAL,CAAa,IAAIC,MAAJ,CAAY,GAAEL,SAAU,GAAxB,CAAb,EAA0C,EAA1C,CAAP;AACD;;AACD,WAAOE,IAAP;AACD,GARO,CAAR;AASA,SAAOH,KAAK,CAACD,IAAN,CAAWE,SAAX,CAAP;AACD","sourcesContent":["// Beginning of a minimal implementation of the Node.js path API, that doesn't pull in big polyfills.\n\n/**\n * Replacement for Node.js path.filename\n * @param url\n */\nexport function filename(url: string): string {\n const slashIndex = url && url.lastIndexOf('/');\n return slashIndex >= 0 ? url.substr((slashIndex as number) + 1) : '';\n}\n\n/**\n * Replacement for Node.js path.dirname\n * @param url\n */\nexport function dirname(url: string): string {\n const slashIndex = url && url.lastIndexOf('/');\n return slashIndex >= 0 ? url.substr(0, slashIndex as number) : '';\n}\n\n/**\n * Replacement for Node.js path.join\n * @param parts\n */\nexport function join(...parts: string[]): string {\n const separator = '/';\n parts = parts.map((part, index) => {\n if (index) {\n part = part.replace(new RegExp(`^${separator}`), '');\n }\n if (index !== parts.length - 1) {\n part = part.replace(new RegExp(`${separator}$`), '');\n }\n return part;\n });\n return parts.join(separator);\n}\n"],"file":"path.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/loader-utils",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.1.0-alpha.4",
|
|
4
4
|
"description": "Framework-independent loaders for 3D graphics formats",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@babel/runtime": "^7.3.1",
|
|
51
|
-
"@loaders.gl/worker-utils": "3.0.
|
|
51
|
+
"@loaders.gl/worker-utils": "3.1.0-alpha.4",
|
|
52
52
|
"@probe.gl/stats": "^3.4.0"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "e309784af37ef9f3640c7733c7851124c72e1fa3"
|
|
55
55
|
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import {TypedArray} from '../../types';
|
|
2
|
-
import
|
|
2
|
+
import {isBuffer, bufferToArrayBuffer} from './buffer-utils';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Convert an object to an array buffer
|
|
6
6
|
*/
|
|
7
7
|
export function toArrayBuffer(data: any): ArrayBuffer {
|
|
8
8
|
// Note: Should be called first, Buffers can trigger other detections below
|
|
9
|
-
if (
|
|
10
|
-
|
|
11
|
-
data = node.bufferToArrayBuffer(data);
|
|
9
|
+
if (isBuffer(data)) {
|
|
10
|
+
return bufferToArrayBuffer(data);
|
|
12
11
|
}
|
|
13
12
|
|
|
14
13
|
if (data instanceof ArrayBuffer) {
|
|
@@ -19,10 +19,10 @@ export function toBuffer(data: any): Buffer {
|
|
|
19
19
|
* Converts Node.js `Buffer` to `ArrayBuffer` (without triggering bundler to include Buffer polyfill on browser)
|
|
20
20
|
* @todo better data type
|
|
21
21
|
*/
|
|
22
|
-
export function bufferToArrayBuffer(
|
|
23
|
-
if (
|
|
24
|
-
|
|
25
|
-
return
|
|
22
|
+
export function bufferToArrayBuffer(buffer: any): ArrayBuffer {
|
|
23
|
+
if (isBuffer(buffer)) {
|
|
24
|
+
const typedArray = new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.length);
|
|
25
|
+
return typedArray.slice().buffer;
|
|
26
26
|
}
|
|
27
|
-
return
|
|
27
|
+
return buffer;
|
|
28
28
|
}
|
|
@@ -20,7 +20,7 @@ export {self_ as self, window_ as window, global_ as global, document_ as docume
|
|
|
20
20
|
/** true if running in a browser */
|
|
21
21
|
export const isBrowser: boolean =
|
|
22
22
|
// @ts-ignore process does not exist on browser
|
|
23
|
-
typeof process !== 'object' || String(process) !== '[object process]' || process.browser;
|
|
23
|
+
Boolean(typeof process !== 'object' || String(process) !== '[object process]' || process.browser);
|
|
24
24
|
|
|
25
25
|
/** true if running in a worker thread */
|
|
26
26
|
export const isWorker: boolean = typeof importScripts === 'function';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as fs from '../node/fs';
|
|
2
|
-
import {IFileSystem, IRandomAccessReadFileSystem} from '
|
|
2
|
+
import {IFileSystem, IRandomAccessReadFileSystem} from '../../types';
|
|
3
3
|
// import {fetchFile} from "../fetch/fetch-file"
|
|
4
4
|
// import {selectLoader} from "../api/select-loader";
|
|
5
5
|
|
package/src/lib/node/buffer.ts
CHANGED
|
@@ -9,8 +9,8 @@ import {assert} from '../env-utils/assert';
|
|
|
9
9
|
export function toArrayBuffer(buffer) {
|
|
10
10
|
// TODO - per docs we should just be able to call buffer.buffer, but there are issues
|
|
11
11
|
if (Buffer.isBuffer(buffer)) {
|
|
12
|
-
const typedArray = new Uint8Array(buffer);
|
|
13
|
-
return typedArray.buffer;
|
|
12
|
+
const typedArray = new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.length);
|
|
13
|
+
return typedArray.slice().buffer;
|
|
14
14
|
}
|
|
15
15
|
return buffer;
|
|
16
16
|
}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
// Beginning of a minimal implementation of the Node.js path API, that doesn't pull in big polyfills.
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Replacement for Node.js path.filename
|
|
5
|
+
* @param url
|
|
6
|
+
*/
|
|
7
|
+
export function filename(url: string): string {
|
|
8
|
+
const slashIndex = url && url.lastIndexOf('/');
|
|
9
|
+
return slashIndex >= 0 ? url.substr((slashIndex as number) + 1) : '';
|
|
10
|
+
}
|
|
11
|
+
|
|
3
12
|
/**
|
|
4
13
|
* Replacement for Node.js path.dirname
|
|
5
14
|
* @param url
|
package/src/types.ts
CHANGED
|
@@ -150,6 +150,7 @@ export type LoaderWithParser = Loader & {
|
|
|
150
150
|
parseText?: ParseText;
|
|
151
151
|
parseTextSync?: ParseTextSync;
|
|
152
152
|
parseInBatches?: ParseInBatches;
|
|
153
|
+
parseFileInBatches?: ParseFileInBatches;
|
|
153
154
|
};
|
|
154
155
|
|
|
155
156
|
/** Options for writers */
|
|
@@ -203,7 +204,7 @@ export type LoaderContext = {
|
|
|
203
204
|
loaders?,
|
|
204
205
|
options?: LoaderOptions,
|
|
205
206
|
context?: LoaderContext
|
|
206
|
-
) => AsyncIterable<any
|
|
207
|
+
) => AsyncIterable<any> | Promise<AsyncIterable<any>>;
|
|
207
208
|
};
|
|
208
209
|
|
|
209
210
|
type Parse = (
|
|
@@ -223,6 +224,11 @@ type ParseInBatches = (
|
|
|
223
224
|
options?: LoaderOptions,
|
|
224
225
|
context?: LoaderContext
|
|
225
226
|
) => AsyncIterable<any>;
|
|
227
|
+
type ParseFileInBatches = (
|
|
228
|
+
file: Blob,
|
|
229
|
+
options?: LoaderOptions,
|
|
230
|
+
context?: LoaderContext
|
|
231
|
+
) => AsyncIterable<any>;
|
|
226
232
|
|
|
227
233
|
type Encode = (data: any, options?: WriterOptions) => Promise<ArrayBuffer>;
|
|
228
234
|
type EncodeSync = (data: any, options?: WriterOptions) => ArrayBuffer;
|