@loaders.gl/loader-utils 3.0.9 → 3.0.13

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.
Files changed (76) hide show
  1. package/dist/es5/index.js +69 -53
  2. package/dist/es5/index.js.map +1 -1
  3. package/dist/es5/json-loader.js +5 -33
  4. package/dist/es5/json-loader.js.map +1 -1
  5. package/dist/es5/lib/binary-utils/array-buffer-utils.js +33 -66
  6. package/dist/es5/lib/binary-utils/array-buffer-utils.js.map +1 -1
  7. package/dist/es5/lib/binary-utils/binary-copy-utils.js +7 -7
  8. package/dist/es5/lib/binary-utils/binary-copy-utils.js.map +1 -1
  9. package/dist/es5/lib/binary-utils/buffer-utils.js +4 -10
  10. package/dist/es5/lib/binary-utils/buffer-utils.js.map +1 -1
  11. package/dist/es5/lib/binary-utils/encode-utils.js +7 -7
  12. package/dist/es5/lib/binary-utils/encode-utils.js.map +1 -1
  13. package/dist/es5/lib/binary-utils/get-first-characters.js +5 -7
  14. package/dist/es5/lib/binary-utils/get-first-characters.js.map +1 -1
  15. package/dist/es5/lib/binary-utils/memory-copy-utils.js +6 -7
  16. package/dist/es5/lib/binary-utils/memory-copy-utils.js.map +1 -1
  17. package/dist/es5/lib/env-utils/globals.js +9 -14
  18. package/dist/es5/lib/env-utils/globals.js.map +1 -1
  19. package/dist/es5/lib/filesystems/node-filesystem.js +74 -0
  20. package/dist/es5/lib/filesystems/node-filesystem.js.map +1 -0
  21. package/dist/es5/lib/iterators/async-iteration.js +27 -242
  22. package/dist/es5/lib/iterators/async-iteration.js.map +1 -1
  23. package/dist/es5/lib/iterators/text-iterators.js +35 -410
  24. package/dist/es5/lib/iterators/text-iterators.js.map +1 -1
  25. package/dist/es5/lib/node/{buffer-utils.node.js → buffer.js} +5 -5
  26. package/dist/es5/lib/node/buffer.js.map +1 -0
  27. package/dist/es5/lib/node/fs.js +30 -61
  28. package/dist/es5/lib/node/fs.js.map +1 -1
  29. package/dist/es5/lib/node/util.js +16 -0
  30. package/dist/es5/lib/node/util.js.map +1 -0
  31. package/dist/es5/lib/path-utils/file-aliases.js +4 -4
  32. package/dist/es5/lib/path-utils/file-aliases.js.map +1 -1
  33. package/dist/es5/lib/path-utils/path.js +4 -8
  34. package/dist/es5/lib/path-utils/path.js.map +1 -1
  35. package/dist/es5/lib/request-utils/request-scheduler.js +96 -124
  36. package/dist/es5/lib/request-utils/request-scheduler.js.map +1 -1
  37. package/dist/es5/lib/worker-loader-utils/create-loader-worker.js +63 -132
  38. package/dist/es5/lib/worker-loader-utils/create-loader-worker.js.map +1 -1
  39. package/dist/es5/lib/worker-loader-utils/parse-with-worker.js +51 -111
  40. package/dist/es5/lib/worker-loader-utils/parse-with-worker.js.map +1 -1
  41. package/dist/esm/index.js +8 -4
  42. package/dist/esm/index.js.map +1 -1
  43. package/dist/esm/json-loader.js +1 -1
  44. package/dist/esm/json-loader.js.map +1 -1
  45. package/dist/esm/lib/binary-utils/array-buffer-utils.js +8 -4
  46. package/dist/esm/lib/binary-utils/array-buffer-utils.js.map +1 -1
  47. package/dist/esm/lib/binary-utils/buffer-utils.js +1 -1
  48. package/dist/esm/lib/binary-utils/buffer-utils.js.map +1 -1
  49. package/dist/esm/lib/filesystems/node-filesystem.js +60 -0
  50. package/dist/esm/lib/filesystems/node-filesystem.js.map +1 -0
  51. package/dist/esm/lib/node/{buffer-utils.node.js → buffer.js} +1 -1
  52. package/dist/esm/lib/node/buffer.js.map +1 -0
  53. package/dist/esm/lib/node/fs.js +12 -14
  54. package/dist/esm/lib/node/fs.js.map +1 -1
  55. package/dist/esm/lib/node/util.js +3 -0
  56. package/dist/esm/lib/node/util.js.map +1 -0
  57. package/dist/esm/lib/parser-utils/parse-json.js +1 -1
  58. package/dist/esm/lib/parser-utils/parse-json.js.map +1 -1
  59. package/dist/esm/lib/path-utils/file-aliases.js +1 -1
  60. package/dist/esm/lib/path-utils/file-aliases.js.map +1 -1
  61. package/dist/esm/lib/path-utils/path.js +2 -2
  62. package/dist/esm/lib/path-utils/path.js.map +1 -1
  63. package/dist/esm/lib/worker-loader-utils/create-loader-worker.js +1 -1
  64. package/dist/esm/lib/worker-loader-utils/create-loader-worker.js.map +1 -1
  65. package/dist/esm/lib/worker-loader-utils/parse-with-worker.js +1 -1
  66. package/dist/esm/lib/worker-loader-utils/parse-with-worker.js.map +1 -1
  67. package/package.json +13 -8
  68. package/src/index.ts +26 -8
  69. package/src/lib/binary-utils/array-buffer-utils.ts +8 -5
  70. package/src/lib/binary-utils/buffer-utils.ts +1 -1
  71. package/src/lib/filesystems/node-filesystem.ts +79 -0
  72. package/src/lib/node/{buffer-utils.node.ts → buffer.ts} +0 -0
  73. package/src/lib/node/fs.ts +29 -13
  74. package/src/lib/node/util.ts +4 -0
  75. package/dist/es5/lib/node/buffer-utils.node.js.map +0 -1
  76. package/dist/esm/lib/node/buffer-utils.node.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/binary-utils/array-buffer-utils.ts"],"names":["toArrayBuffer","data","node","ArrayBuffer","isView","buffer","text","uint8Array","TextEncoder","encode","_toArrayBuffer","Error","compareArrayBuffers","arrayBuffer1","arrayBuffer2","byteLength","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","byteOffset","subArray","undefined","subarray","arrayCopy"],"mappings":";;;;;;;;;;;;;;;;;AACA;;;;;;;;;;;;AAKO,SAASA,aAAT,CAAuBC,IAAvB,EAA+C;AAEpD,MAAIC,IAAI,CAACF,aAAT,EAAwB;AAEtBC,IAAAA,IAAI,GAAGC,IAAI,CAACF,aAAL,CAAmBC,IAAnB,CAAP;AACD;;AAED,MAAIA,IAAI,YAAYE,WAApB,EAAiC;AAC/B,WAAOF,IAAP;AACD;;AAGD,MAAIE,WAAW,CAACC,MAAZ,CAAmBH,IA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AP,CAAWS,KAAX,EAAkBX,MAAlB;AACAA,IAAAA,MAAM,IAAIW,KAAK,CAACpB,MAAhB;AACD;;AACD,SAAOQ,MAAP;AACD;;AAQM,SAASa,gBAAT,CACLC,WADK,EAELC,UAFK,EAGL5B,UAHK,EAIQ;AACb,MAAM6B,QAAQ,GACZ7B,UAAU,KAAK8B,SAAf,GACI,IAAI5B,UAAJ,CAAeyB,WAAf,EAA4BI,QAA5B,CAAqCH,UAArC,EAAiDA,UAAU,GAAG5B,UAA9D,CADJ,GAEI,IAAIE,UAAJ,CAAeyB,WAAf,EAA4BI,QAA5B,CAAqCH,UAArC,CAHN;AAIA,MAAMI,SAAS,GAAG,IAAI9B,UAAJ,CAAe2B,QAAf,CAAlB;AACA,SAAOG,SAAS,CAAC1C,MAAjB;AACD","sourcesContent":["import {TypedArray} from '../../types';\nimport * as node from '../node/buffer-utils.node';\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 (node.toArrayBuffer) {\n // TODO - per docs we should just be able to call buffer.buffer, but there are issues\n data = node.toArrayBuffer(data);\n }\n\n if (data instanceof ArrayBuffer) {\n return data;\n }\n\n // Careful - Node Buffers will look like ArrayBuffers (keep after isBuffer)\n if (ArrayBuffer.isView(data)) {\n return data.buffer;\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"}
1
+ {"version":3,"sources":["../../../../src/lib/binary-utils/array-buffer-utils.ts"],"names":["toArrayBuffer","data","node","isBuffer","bufferToArrayBuffer","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,MAAIC,IAAI,CAACC,QAAL,CAAcF,IAAd,CAAJ,EAAyB;AAEvBA,IAAAA,IAAI,GAAGC,IAAI,CAACE,mBAAL,CAAyBH,IAAzB,CAAP;AACD;;AAED,MAAIA,IAAI,YAAYI,WAApB,EAAiC;AAC/B,WAAOJ,IAAP;AACD;;AAGD,MAAII,WAAW,CAACC,MAAZ,CAAmBL,IAAnB,CAAJ,EAA8B;AAC5B,QAAIA,IAAI,CAACM,UAAL,KAAoB,CAApB,IAAyBN,IAAI,CAACO,UAAL,KAAoBP,IAAI,CAACQ,MAAL,CAAYD,UAA7D,EAAyE;AACvE,aAAOP,IAAI,CAACQ,MAAZ;AACD;;AACD,WAAOR,IAAI,CAACQ,MAAL,CAAYC,KAAZ,CAAkBT,IAAI,CAACM,UAAvB,EAAmCN,IAAI,CAACM,UAAL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,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,QAAM2C,SAAS,GAAG,IAAI7B,UAAJ,CAAe0B,QAAf,CAAlB;AACA,SAAOG,SAAS,CAACzC,MAAjB;AACD","sourcesContent":["import {TypedArray} from '../../types';\nimport * as node 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 (node.isBuffer(data)) {\n // TODO - per docs we should just be able to call buffer.buffer, but there are issues\n data = node.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"}
@@ -9,15 +9,15 @@ exports.copyPaddedStringToDataView = copyPaddedStringToDataView;
9
9
  var _memoryCopyUtils = require("./memory-copy-utils");
10
10
 
11
11
  function copyPaddedArrayBufferToDataView(dataView, byteOffset, sourceBuffer, padding) {
12
- var paddedLength = (0, _memoryCopyUtils.padToNBytes)(sourceBuffer.byteLength, padding);
13
- var padLength = paddedLength - sourceBuffer.byteLength;
12
+ const paddedLength = (0, _memoryCopyUtils.padToNBytes)(sourceBuffer.byteLength, padding);
13
+ const padLength = paddedLength - sourceBuffer.byteLength;
14
14
 
15
15
  if (dataView) {
16
- var targetArray = new Uint8Array(dataView.buffer, dataView.byteOffset + byteOffset, sourceBuffer.byteLength);
17
- var sourceArray = new Uint8Array(sourceBuffer);
16
+ const targetArray = new Uint8Array(dataView.buffer, dataView.byteOffset + byteOffset, sourceBuffer.byteLength);
17
+ const sourceArray = new Uint8Array(sourceBuffer);
18
18
  targetArray.set(sourceArray);
19
19
 
20
- for (var i = 0; i < padLength; ++i) {
20
+ for (let i = 0; i < padLength; ++i) {
21
21
  dataView.setUint8(byteOffset + sourceBuffer.byteLength + i, 0x20);
22
22
  }
23
23
  }
@@ -27,8 +27,8 @@ function copyPaddedArrayBufferToDataView(dataView, byteOffset, sourceBuffer, pad
27
27
  }
28
28
 
29
29
  function copyPaddedStringToDataView(dataView, byteOffset, string, padding) {
30
- var textEncoder = new TextEncoder();
31
- var stringBuffer = textEncoder.encode(string);
30
+ const textEncoder = new TextEncoder();
31
+ const stringBuffer = textEncoder.encode(string);
32
32
  byteOffset = copyPaddedArrayBufferToDataView(dataView, byteOffset, stringBuffer, padding);
33
33
  return byteOffset;
34
34
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/binary-utils/binary-copy-utils.ts"],"names":["copyPaddedArrayBufferToDataView","dataView","byteOffset","sourceBuffer","padding","paddedLength","byteLength","padLength","targetArray","Uint8Array","buffer","sourceArray","set","i","setUint8","copyPaddedStringToDataView","string","textEncoder","TextEncoder","stringBuffer","encode"],"mappings":";;;;;;;;AACA;;AAYO,SAASA,+BAAT,CACLC,QADK,EAELC,UAFK,EAGLC,YAHK,EAILC,OAJK,EAKL;AACA,MAAMC,YAAY,GAAG,kCAAYF,YAAY,CAACG,UAAzB,EAAqCF,OAArC,CAArB;AACA,MAAMG,SAAS,GAAGF,YAAY,GAAGF,YAAY,CAACG,UAA9C;;AAEA,MAAIL,QAAJ,EAAc;AAEZ,QAAMO,WAAW,GAAG,IAAIC,UAAJ,CAClBR,QAAQ,CAACS,MADS,EAElBT,QAAQ,CAACC,UAAT,GAAsBA,UAFJ,EAGlBC,YAAY,CAACG,UAHK,CAApB;AAKA,QAAMK,WAAW,GAAG,IAAIF,UAAJ,CAAeN,YAAf,CAApB;AACAK,IAAAA,WAAW,CAACI,GAAZ,CAAgBD,WAAhB;;AAGA,SAAK,IAAIE,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGN,SAApB,EAA+B,EAAEM,CAAjC,EAAoC;AAElCZ,MAAAA,QAAQ,CAACa,QAAT,CAAkBZ,UAAU,GAAGC,YAAY,CAACG,UAA1B,GAAuCO,CAAzD,EAA4D,IAA5D;AACD;AACF;;AACDX,EAAAA,UAAU,IAAIG,YAAd;AACA,SAAOH,UAAP;AACD;;AAYM,SAASa,0BAAT,CACLd,QADK,EAELC,UAFK,EAGLc,MAHK,EAILZ,OAJK,EAKG;AACR,MAAMa,WAAW,GAAG,IAAIC,WAAJ,EAApB;AAGA,MAAMC,YAAY,GAAGF,WAAW,CAACG,MAAZ,CAAmBJ,MAAnB,CAArB;AAEAd,EAAAA,UAAU,GAAGF,+BAA+B,CAACC,QAAD,EAAWC,UAAX,EAAuBiB,YAAvB,EAAqCf,OAArC,CAA5C;AAEA,SAAOF,UAAP;AACD","sourcesContent":["import {TypedArray} from '../../types';\nimport {padToNBytes} from './memory-copy-utils';\n\n/**\n * Copy sourceBuffer to dataView with some padding\n *\n * @param {DataView | null} dataView - destination data container. If null - only new offset is calculated\n * @param {number} byteOffset - destination byte offset to copy to\n * @param {Array | TypedArray} sourceBuffer - source data buffer\n * @param {number} padding - pad the resulting array to multiple of \"padding\" bytes. Additional bytes are filled with 0x20 (ASCII space)\n *\n * @return new byteOffset of resulting dataView\n */\nexport function copyPaddedArrayBufferToDataView(\n dataView: DataView | null,\n byteOffset: number,\n sourceBuffer: TypedArray,\n padding: number\n) {\n const paddedLength = padToNBytes(sourceBuffer.byteLength, padding);\n const padLength = paddedLength - sourceBuffer.byteLength;\n\n if (dataView) {\n // Copy array\n const targetArray = new Uint8Array(\n dataView.buffer,\n dataView.byteOffset + byteOffset,\n sourceBuffer.byteLength\n );\n const sourceArray = new Uint8Array(sourceBuffer);\n targetArray.set(sourceArray);\n\n // Add PADDING\n for (let i = 0; i < padLength; ++i) {\n // json chunk is padded with spaces (ASCII 0x20)\n dataView.setUint8(byteOffset + sourceBuffer.byteLength + i, 0x20);\n }\n }\n byteOffset += paddedLength;\n return byteOffset;\n}\n\n/**\n * Copy string to dataView with some padding\n *\n * @param {DataView | null} dataView - destination data container. If null - only new offset is calculated\n * @param {number} byteOffset - destination byte offset to copy to\n * @param {string} string - source string\n * @param {number} padding - pad the resulting array to multiple of \"padding\" bytes. Additional bytes are filled with 0x20 (ASCII space)\n *\n * @return new byteOffset of resulting dataView\n */\nexport function copyPaddedStringToDataView(\n dataView: DataView | null,\n byteOffset: number,\n string: string,\n padding: number\n): number {\n const textEncoder = new TextEncoder();\n // PERFORMANCE IDEA: We encode twice, once to get size and once to store\n // PERFORMANCE IDEA: Use TextEncoder.encodeInto() to avoid temporary copy\n const stringBuffer = textEncoder.encode(string);\n\n byteOffset = copyPaddedArrayBufferToDataView(dataView, byteOffset, stringBuffer, padding);\n\n return byteOffset;\n}\n"],"file":"binary-copy-utils.js"}
1
+ {"version":3,"sources":["../../../../src/lib/binary-utils/binary-copy-utils.ts"],"names":["copyPaddedArrayBufferToDataView","dataView","byteOffset","sourceBuffer","padding","paddedLength","byteLength","padLength","targetArray","Uint8Array","buffer","sourceArray","set","i","setUint8","copyPaddedStringToDataView","string","textEncoder","TextEncoder","stringBuffer","encode"],"mappings":";;;;;;;;AACA;;AAYO,SAASA,+BAAT,CACLC,QADK,EAELC,UAFK,EAGLC,YAHK,EAILC,OAJK,EAKL;AACA,QAAMC,YAAY,GAAG,kCAAYF,YAAY,CAACG,UAAzB,EAAqCF,OAArC,CAArB;AACA,QAAMG,SAAS,GAAGF,YAAY,GAAGF,YAAY,CAACG,UAA9C;;AAEA,MAAIL,QAAJ,EAAc;AAEZ,UAAMO,WAAW,GAAG,IAAIC,UAAJ,CAClBR,QAAQ,CAACS,MADS,EAElBT,QAAQ,CAACC,UAAT,GAAsBA,UAFJ,EAGlBC,YAAY,CAACG,UAHK,CAApB;AAKA,UAAMK,WAAW,GAAG,IAAIF,UAAJ,CAAeN,YAAf,CAApB;AACAK,IAAAA,WAAW,CAACI,GAAZ,CAAgBD,WAAhB;;AAGA,SAAK,IAAIE,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGN,SAApB,EAA+B,EAAEM,CAAjC,EAAoC;AAElCZ,MAAAA,QAAQ,CAACa,QAAT,CAAkBZ,UAAU,GAAGC,YAAY,CAACG,UAA1B,GAAuCO,CAAzD,EAA4D,IAA5D;AACD;AACF;;AACDX,EAAAA,UAAU,IAAIG,YAAd;AACA,SAAOH,UAAP;AACD;;AAYM,SAASa,0BAAT,CACLd,QADK,EAELC,UAFK,EAGLc,MAHK,EAILZ,OAJK,EAKG;AACR,QAAMa,WAAW,GAAG,IAAIC,WAAJ,EAApB;AAGA,QAAMC,YAAY,GAAGF,WAAW,CAACG,MAAZ,CAAmBJ,MAAnB,CAArB;AAEAd,EAAAA,UAAU,GAAGF,+BAA+B,CAACC,QAAD,EAAWC,UAAX,EAAuBiB,YAAvB,EAAqCf,OAArC,CAA5C;AAEA,SAAOF,UAAP;AACD","sourcesContent":["import {TypedArray} from '../../types';\nimport {padToNBytes} from './memory-copy-utils';\n\n/**\n * Copy sourceBuffer to dataView with some padding\n *\n * @param {DataView | null} dataView - destination data container. If null - only new offset is calculated\n * @param {number} byteOffset - destination byte offset to copy to\n * @param {Array | TypedArray} sourceBuffer - source data buffer\n * @param {number} padding - pad the resulting array to multiple of \"padding\" bytes. Additional bytes are filled with 0x20 (ASCII space)\n *\n * @return new byteOffset of resulting dataView\n */\nexport function copyPaddedArrayBufferToDataView(\n dataView: DataView | null,\n byteOffset: number,\n sourceBuffer: TypedArray,\n padding: number\n) {\n const paddedLength = padToNBytes(sourceBuffer.byteLength, padding);\n const padLength = paddedLength - sourceBuffer.byteLength;\n\n if (dataView) {\n // Copy array\n const targetArray = new Uint8Array(\n dataView.buffer,\n dataView.byteOffset + byteOffset,\n sourceBuffer.byteLength\n );\n const sourceArray = new Uint8Array(sourceBuffer);\n targetArray.set(sourceArray);\n\n // Add PADDING\n for (let i = 0; i < padLength; ++i) {\n // json chunk is padded with spaces (ASCII 0x20)\n dataView.setUint8(byteOffset + sourceBuffer.byteLength + i, 0x20);\n }\n }\n byteOffset += paddedLength;\n return byteOffset;\n}\n\n/**\n * Copy string to dataView with some padding\n *\n * @param {DataView | null} dataView - destination data container. If null - only new offset is calculated\n * @param {number} byteOffset - destination byte offset to copy to\n * @param {string} string - source string\n * @param {number} padding - pad the resulting array to multiple of \"padding\" bytes. Additional bytes are filled with 0x20 (ASCII space)\n *\n * @return new byteOffset of resulting dataView\n */\nexport function copyPaddedStringToDataView(\n dataView: DataView | null,\n byteOffset: number,\n string: string,\n padding: number\n): number {\n const textEncoder = new TextEncoder();\n // PERFORMANCE IDEA: We encode twice, once to get size and once to store\n // PERFORMANCE IDEA: Use TextEncoder.encodeInto() to avoid temporary copy\n const stringBuffer = textEncoder.encode(string);\n\n byteOffset = copyPaddedArrayBufferToDataView(dataView, byteOffset, stringBuffer, padding);\n\n return byteOffset;\n}\n"],"file":"binary-copy-utils.js"}
@@ -1,9 +1,5 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- var _typeof3 = require("@babel/runtime/helpers/typeof");
6
-
7
3
  Object.defineProperty(exports, "__esModule", {
8
4
  value: true
9
5
  });
@@ -11,16 +7,14 @@ exports.isBuffer = isBuffer;
11
7
  exports.toBuffer = toBuffer;
12
8
  exports.bufferToArrayBuffer = bufferToArrayBuffer;
13
9
 
14
- var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
15
-
16
- var node = _interopRequireWildcard(require("../node/buffer-utils.node"));
10
+ var node = _interopRequireWildcard(require("../node/buffer"));
17
11
 
18
- 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); }
12
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
13
 
20
- 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; }
14
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof 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; }
21
15
 
22
16
  function isBuffer(value) {
23
- return value && (0, _typeof2.default)(value) === 'object' && value.isBuffer;
17
+ return value && typeof value === 'object' && value.isBuffer;
24
18
  }
25
19
 
26
20
  function toBuffer(data) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/binary-utils/buffer-utils.ts"],"names":["isBuffer","value","toBuffer","data","node","bufferToArrayBuffer","toArrayBuffer"],"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,CAA6BF,IAA7B,EAAqD;AAC1D,MAAIC,IAAI,CAACE,aAAT,EAAwB;AAEtB,WAAOF,IAAI,CAACE,aAAL,CAAmBH,IAAnB,CAAP;AACD;;AACD,SAAOA,IAAP;AACD","sourcesContent":["import * as node from '../node/buffer-utils.node';\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(data: any): ArrayBuffer {\n if (node.toArrayBuffer) {\n // TODO - per docs we should just be able to call buffer.buffer, but there are issues\n return node.toArrayBuffer(data);\n }\n return data;\n}\n"],"file":"buffer-utils.js"}
1
+ {"version":3,"sources":["../../../../src/lib/binary-utils/buffer-utils.ts"],"names":["isBuffer","value","toBuffer","data","node","bufferToArrayBuffer","toArrayBuffer"],"mappings":";;;;;;;;;AAAA;;;;;;AAKO,SAASA,QAAT,CAAkBC,KAAlB,EAAuC;AAC5C,SAAOA,KAAK,IAAI,OAAOA,KAAP,KAAiB,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,CAA6BF,IAA7B,EAAqD;AAC1D,MAAIC,IAAI,CAACE,aAAT,EAAwB;AAEtB,WAAOF,IAAI,CAACE,aAAL,CAAmBH,IAAnB,CAAP;AACD;;AACD,SAAOA,IAAP;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(data: any): ArrayBuffer {\n if (node.toArrayBuffer) {\n // TODO - per docs we should just be able to call buffer.buffer, but there are issues\n return node.toArrayBuffer(data);\n }\n return data;\n}\n"],"file":"buffer-utils.js"}
@@ -8,12 +8,12 @@ exports.copyStringToDataView = copyStringToDataView;
8
8
  exports.copyBinaryToDataView = copyBinaryToDataView;
9
9
 
10
10
  function padStringToByteAlignment(string, byteAlignment) {
11
- var length = string.length;
12
- var paddedLength = Math.ceil(length / byteAlignment) * byteAlignment;
13
- var padding = paddedLength - length;
14
- var whitespace = '';
11
+ const length = string.length;
12
+ const paddedLength = Math.ceil(length / byteAlignment) * byteAlignment;
13
+ const padding = paddedLength - length;
14
+ let whitespace = '';
15
15
 
16
- for (var i = 0; i < padding; ++i) {
16
+ for (let i = 0; i < padding; ++i) {
17
17
  whitespace += ' ';
18
18
  }
19
19
 
@@ -22,7 +22,7 @@ function padStringToByteAlignment(string, byteAlignment) {
22
22
 
23
23
  function copyStringToDataView(dataView, byteOffset, string, byteLength) {
24
24
  if (dataView) {
25
- for (var i = 0; i < byteLength; i++) {
25
+ for (let i = 0; i < byteLength; i++) {
26
26
  dataView.setUint8(byteOffset + i, string.charCodeAt(i));
27
27
  }
28
28
  }
@@ -32,7 +32,7 @@ function copyStringToDataView(dataView, byteOffset, string, byteLength) {
32
32
 
33
33
  function copyBinaryToDataView(dataView, byteOffset, binary, byteLength) {
34
34
  if (dataView) {
35
- for (var i = 0; i < byteLength; i++) {
35
+ for (let i = 0; i < byteLength; i++) {
36
36
  dataView.setUint8(byteOffset + i, binary[i]);
37
37
  }
38
38
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/binary-utils/encode-utils.ts"],"names":["padStringToByteAlignment","string","byteAlignment","length","paddedLength","Math","ceil","padding","whitespace","i","copyStringToDataView","dataView","byteOffset","byteLength","setUint8","charCodeAt","copyBinaryToDataView","binary"],"mappings":";;;;;;;;;AAIO,SAASA,wBAAT,CAAkCC,MAAlC,EAA0CC,aAA1C,EAAyD;AAC9D,MAAMC,MAAM,GAAGF,MAAM,CAACE,MAAtB;AACA,MAAMC,YAAY,GAAGC,IAAI,CAACC,IAAL,CAAUH,MAAM,GAAGD,aAAnB,IAAoCA,aAAzD;AACA,MAAMK,OAAO,GAAGH,YAAY,GAAGD,MAA/B;AACA,MAAIK,UAAU,GAAG,EAAjB;;AACA,OAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGF,OAApB,EAA6B,EAAEE,CAA/B,EAAkC;AAChCD,IAAAA,UAAU,IAAI,GAAd;AACD;;AACD,SAAOP,MAAM,GAAGO,UAAhB;AACD;;AAEM,SAASE,oBAAT,CAA8BC,QAA9B,EAAwCC,UAAxC,EAAoDX,MAApD,EAA4DY,UAA5D,EAAwE;AAC7E,MAAIF,QAAJ,EAAc;AACZ,SAAK,IAAIF,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGI,UAApB,EAAgCJ,CAAC,EAAjC,EAAqC;AACnCE,MAAAA,QAAQ,CAACG,QAAT,CAAkBF,UAAU,GAAGH,CAA/B,EAAkCR,MAAM,CAACc,UAAP,CAAkBN,CAAlB,CAAlC;AACD;AACF;;AACD,SAAOG,UAAU,GAAGC,UAApB;AACD;;AAEM,SAASG,oBAAT,CAA8BL,QAA9B,EAAwCC,UAAxC,EAAoDK,MAApD,EAA4DJ,UAA5D,EAAwE;AAC7E,MAAIF,QAAJ,EAAc;AACZ,SAAK,IAAIF,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGI,UAApB,EAAgCJ,CAAC,EAAjC,EAAqC;AACnCE,MAAAA,QAAQ,CAACG,QAAT,CAAkBF,UAAU,GAAGH,CAA/B,EAAkCQ,MAAM,CAACR,CAAD,CAAxC;AACD;AACF;;AACD,SAAOG,UAAU,GAAGC,UAApB;AACD","sourcesContent":["// Note: These were broken out from gltf loader...\n// eslint-disable-next-line complexity\n\n// PERFORMANCE IDEA: No need to copy string twice...\nexport function padStringToByteAlignment(string, byteAlignment) {\n const length = string.length;\n const paddedLength = Math.ceil(length / byteAlignment) * byteAlignment; // Round up to the required alignment\n const padding = paddedLength - length;\n let whitespace = '';\n for (let i = 0; i < padding; ++i) {\n whitespace += ' ';\n }\n return string + whitespace;\n}\n\nexport function copyStringToDataView(dataView, byteOffset, string, byteLength) {\n if (dataView) {\n for (let i = 0; i < byteLength; i++) {\n dataView.setUint8(byteOffset + i, string.charCodeAt(i));\n }\n }\n return byteOffset + byteLength;\n}\n\nexport function copyBinaryToDataView(dataView, byteOffset, binary, byteLength) {\n if (dataView) {\n for (let i = 0; i < byteLength; i++) {\n dataView.setUint8(byteOffset + i, binary[i]);\n }\n }\n return byteOffset + byteLength;\n}\n"],"file":"encode-utils.js"}
1
+ {"version":3,"sources":["../../../../src/lib/binary-utils/encode-utils.ts"],"names":["padStringToByteAlignment","string","byteAlignment","length","paddedLength","Math","ceil","padding","whitespace","i","copyStringToDataView","dataView","byteOffset","byteLength","setUint8","charCodeAt","copyBinaryToDataView","binary"],"mappings":";;;;;;;;;AAIO,SAASA,wBAAT,CAAkCC,MAAlC,EAA0CC,aAA1C,EAAyD;AAC9D,QAAMC,MAAM,GAAGF,MAAM,CAACE,MAAtB;AACA,QAAMC,YAAY,GAAGC,IAAI,CAACC,IAAL,CAAUH,MAAM,GAAGD,aAAnB,IAAoCA,aAAzD;AACA,QAAMK,OAAO,GAAGH,YAAY,GAAGD,MAA/B;AACA,MAAIK,UAAU,GAAG,EAAjB;;AACA,OAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGF,OAApB,EAA6B,EAAEE,CAA/B,EAAkC;AAChCD,IAAAA,UAAU,IAAI,GAAd;AACD;;AACD,SAAOP,MAAM,GAAGO,UAAhB;AACD;;AAEM,SAASE,oBAAT,CAA8BC,QAA9B,EAAwCC,UAAxC,EAAoDX,MAApD,EAA4DY,UAA5D,EAAwE;AAC7E,MAAIF,QAAJ,EAAc;AACZ,SAAK,IAAIF,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGI,UAApB,EAAgCJ,CAAC,EAAjC,EAAqC;AACnCE,MAAAA,QAAQ,CAACG,QAAT,CAAkBF,UAAU,GAAGH,CAA/B,EAAkCR,MAAM,CAACc,UAAP,CAAkBN,CAAlB,CAAlC;AACD;AACF;;AACD,SAAOG,UAAU,GAAGC,UAApB;AACD;;AAEM,SAASG,oBAAT,CAA8BL,QAA9B,EAAwCC,UAAxC,EAAoDK,MAApD,EAA4DJ,UAA5D,EAAwE;AAC7E,MAAIF,QAAJ,EAAc;AACZ,SAAK,IAAIF,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGI,UAApB,EAAgCJ,CAAC,EAAjC,EAAqC;AACnCE,MAAAA,QAAQ,CAACG,QAAT,CAAkBF,UAAU,GAAGH,CAA/B,EAAkCQ,MAAM,CAACR,CAAD,CAAxC;AACD;AACF;;AACD,SAAOG,UAAU,GAAGC,UAApB;AACD","sourcesContent":["// Note: These were broken out from gltf loader...\n// eslint-disable-next-line complexity\n\n// PERFORMANCE IDEA: No need to copy string twice...\nexport function padStringToByteAlignment(string, byteAlignment) {\n const length = string.length;\n const paddedLength = Math.ceil(length / byteAlignment) * byteAlignment; // Round up to the required alignment\n const padding = paddedLength - length;\n let whitespace = '';\n for (let i = 0; i < padding; ++i) {\n whitespace += ' ';\n }\n return string + whitespace;\n}\n\nexport function copyStringToDataView(dataView, byteOffset, string, byteLength) {\n if (dataView) {\n for (let i = 0; i < byteLength; i++) {\n dataView.setUint8(byteOffset + i, string.charCodeAt(i));\n }\n }\n return byteOffset + byteLength;\n}\n\nexport function copyBinaryToDataView(dataView, byteOffset, binary, byteLength) {\n if (dataView) {\n for (let i = 0; i < byteLength; i++) {\n dataView.setUint8(byteOffset + i, binary[i]);\n }\n }\n return byteOffset + byteLength;\n}\n"],"file":"encode-utils.js"}
@@ -6,15 +6,13 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.getFirstCharacters = getFirstCharacters;
7
7
  exports.getMagicString = getMagicString;
8
8
 
9
- function getFirstCharacters(data) {
10
- var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 5;
11
-
9
+ function getFirstCharacters(data, length = 5) {
12
10
  if (typeof data === 'string') {
13
11
  return data.slice(0, length);
14
12
  } else if (ArrayBuffer.isView(data)) {
15
13
  return getMagicString(data.buffer, data.byteOffset, length);
16
14
  } else if (data instanceof ArrayBuffer) {
17
- var byteOffset = 0;
15
+ const byteOffset = 0;
18
16
  return getMagicString(data, byteOffset, length);
19
17
  }
20
18
 
@@ -26,10 +24,10 @@ function getMagicString(arrayBuffer, byteOffset, length) {
26
24
  return '';
27
25
  }
28
26
 
29
- var dataView = new DataView(arrayBuffer);
30
- var magic = '';
27
+ const dataView = new DataView(arrayBuffer);
28
+ let magic = '';
31
29
 
32
- for (var i = 0; i < length; i++) {
30
+ for (let i = 0; i < length; i++) {
33
31
  magic += String.fromCharCode(dataView.getUint8(byteOffset + i));
34
32
  }
35
33
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/binary-utils/get-first-characters.ts"],"names":["getFirstCharacters","data","length","slice","ArrayBuffer","isView","getMagicString","buffer","byteOffset","arrayBuffer","byteLength","dataView","DataView","magic","i","String","fromCharCode","getUint8"],"mappings":";;;;;;;;AAAO,SAASA,kBAAT,CAA4BC,IAA5B,EAAsD;AAAA,MAApBC,MAAoB,uEAAX,CAAW;;AAC3D,MAAI,OAAOD,IAAP,KAAgB,QAApB,EAA8B;AAC5B,WAAOA,IAAI,CAACE,KAAL,CAAW,CAAX,EAAcD,MAAd,CAAP;AACD,GAFD,MAEO,IAAIE,WAAW,CAACC,MAAZ,CAAmBJ,IAAnB,CAAJ,EAA8B;AAEnC,WAAOK,cAAc,CAACL,IAAI,CAACM,MAAN,EAAcN,IAAI,CAACO,UAAnB,EAA+BN,MAA/B,CAArB;AACD,GAHM,MAGA,IAAID,IAAI,YAAYG,WAApB,EAAiC;AACtC,QAAMI,UAAU,GAAG,CAAnB;AACA,WAAOF,cAAc,CAACL,IAAD,EAAOO,UAAP,EAAmBN,MAAnB,CAArB;AACD;;AACD,SAAO,EAAP;AACD;;AAEM,SAASI,cAAT,CACLG,WADK,EAELD,UAFK,EAGLN,MAHK,EAIG;AACR,MAAIO,WAAW,CAACC,UAAZ,IAA0BF,UAAU,GAAGN,MAA3C,EAAmD;AACjD,WAAO,EAAP;AACD;;AACD,MAAMS,QAAQ,GAAG,IAAIC,QAAJ,CAAaH,WAAb,CAAjB;AACA,MAAII,KAAK,GAAG,EAAZ;;AACA,OAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGZ,MAApB,EAA4BY,CAAC,EAA7B,EAAiC;AAC/BD,IAAAA,KAAK,IAAIE,MAAM,CAACC,YAAP,CAAoBL,QAAQ,CAACM,QAAT,CAAkBT,UAAU,GAAGM,CAA/B,CAApB,CAAT;AACD;;AACD,SAAOD,KAAP;AACD","sourcesContent":["export function getFirstCharacters(data, length = 5): string {\n if (typeof data === 'string') {\n return data.slice(0, length);\n } else if (ArrayBuffer.isView(data)) {\n // Typed Arrays can have offsets into underlying buffer\n return getMagicString(data.buffer, data.byteOffset, length);\n } else if (data instanceof ArrayBuffer) {\n const byteOffset = 0;\n return getMagicString(data, byteOffset, length);\n }\n return '';\n}\n\nexport function getMagicString(\n arrayBuffer: ArrayBuffer,\n byteOffset: number,\n length: number\n): string {\n if (arrayBuffer.byteLength <= byteOffset + length) {\n return '';\n }\n const dataView = new DataView(arrayBuffer);\n let magic = '';\n for (let i = 0; i < length; i++) {\n magic += String.fromCharCode(dataView.getUint8(byteOffset + i));\n }\n return magic;\n}\n"],"file":"get-first-characters.js"}
1
+ {"version":3,"sources":["../../../../src/lib/binary-utils/get-first-characters.ts"],"names":["getFirstCharacters","data","length","slice","ArrayBuffer","isView","getMagicString","buffer","byteOffset","arrayBuffer","byteLength","dataView","DataView","magic","i","String","fromCharCode","getUint8"],"mappings":";;;;;;;;AAAO,SAASA,kBAAT,CAA4BC,IAA5B,EAAkCC,MAAM,GAAG,CAA3C,EAAsD;AAC3D,MAAI,OAAOD,IAAP,KAAgB,QAApB,EAA8B;AAC5B,WAAOA,IAAI,CAACE,KAAL,CAAW,CAAX,EAAcD,MAAd,CAAP;AACD,GAFD,MAEO,IAAIE,WAAW,CAACC,MAAZ,CAAmBJ,IAAnB,CAAJ,EAA8B;AAEnC,WAAOK,cAAc,CAACL,IAAI,CAACM,MAAN,EAAcN,IAAI,CAACO,UAAnB,EAA+BN,MAA/B,CAArB;AACD,GAHM,MAGA,IAAID,IAAI,YAAYG,WAApB,EAAiC;AACtC,UAAMI,UAAU,GAAG,CAAnB;AACA,WAAOF,cAAc,CAACL,IAAD,EAAOO,UAAP,EAAmBN,MAAnB,CAArB;AACD;;AACD,SAAO,EAAP;AACD;;AAEM,SAASI,cAAT,CACLG,WADK,EAELD,UAFK,EAGLN,MAHK,EAIG;AACR,MAAIO,WAAW,CAACC,UAAZ,IAA0BF,UAAU,GAAGN,MAA3C,EAAmD;AACjD,WAAO,EAAP;AACD;;AACD,QAAMS,QAAQ,GAAG,IAAIC,QAAJ,CAAaH,WAAb,CAAjB;AACA,MAAII,KAAK,GAAG,EAAZ;;AACA,OAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGZ,MAApB,EAA4BY,CAAC,EAA7B,EAAiC;AAC/BD,IAAAA,KAAK,IAAIE,MAAM,CAACC,YAAP,CAAoBL,QAAQ,CAACM,QAAT,CAAkBT,UAAU,GAAGM,CAA/B,CAApB,CAAT;AACD;;AACD,SAAOD,KAAP;AACD","sourcesContent":["export function getFirstCharacters(data, length = 5): string {\n if (typeof data === 'string') {\n return data.slice(0, length);\n } else if (ArrayBuffer.isView(data)) {\n // Typed Arrays can have offsets into underlying buffer\n return getMagicString(data.buffer, data.byteOffset, length);\n } else if (data instanceof ArrayBuffer) {\n const byteOffset = 0;\n return getMagicString(data, byteOffset, length);\n }\n return '';\n}\n\nexport function getMagicString(\n arrayBuffer: ArrayBuffer,\n byteOffset: number,\n length: number\n): string {\n if (arrayBuffer.byteLength <= byteOffset + length) {\n return '';\n }\n const dataView = new DataView(arrayBuffer);\n let magic = '';\n for (let i = 0; i < length; i++) {\n magic += String.fromCharCode(dataView.getUint8(byteOffset + i));\n }\n return magic;\n}\n"],"file":"get-first-characters.js"}
@@ -15,22 +15,21 @@ function padToNBytes(byteLength, padding) {
15
15
  return byteLength + (padding - 1) & ~(padding - 1);
16
16
  }
17
17
 
18
- function copyArrayBuffer(targetBuffer, sourceBuffer, byteOffset) {
19
- var byteLength = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : sourceBuffer.byteLength;
20
- var targetArray = new Uint8Array(targetBuffer, byteOffset, byteLength);
21
- var sourceArray = new Uint8Array(sourceBuffer);
18
+ function copyArrayBuffer(targetBuffer, sourceBuffer, byteOffset, byteLength = sourceBuffer.byteLength) {
19
+ const targetArray = new Uint8Array(targetBuffer, byteOffset, byteLength);
20
+ const sourceArray = new Uint8Array(sourceBuffer);
22
21
  targetArray.set(sourceArray);
23
22
  return targetBuffer;
24
23
  }
25
24
 
26
25
  function copyToArray(source, target, targetOffset) {
27
- var sourceArray;
26
+ let sourceArray;
28
27
 
29
28
  if (source instanceof ArrayBuffer) {
30
29
  sourceArray = new Uint8Array(source);
31
30
  } else {
32
- var srcByteOffset = source.byteOffset;
33
- var srcByteLength = source.byteLength;
31
+ const srcByteOffset = source.byteOffset;
32
+ const srcByteLength = source.byteLength;
34
33
  sourceArray = new Uint8Array(source.buffer || source.arrayBuffer, srcByteOffset, srcByteLength);
35
34
  }
36
35
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/binary-utils/memory-copy-utils.ts"],"names":["padToNBytes","byteLength","padding","copyArrayBuffer","targetBuffer","sourceBuffer","byteOffset","targetArray","Uint8Array","sourceArray","set","copyToArray","source","target","targetOffset","ArrayBuffer","srcByteOffset","srcByteLength","buffer","arrayBuffer"],"mappings":";;;;;;;;;AAAA;;AASO,SAASA,WAAT,CAAqBC,UAArB,EAAyCC,OAAzC,EAAkE;AACvE,sBAAOD,UAAU,IAAI,CAArB;AACA,sBAAOC,OAAO,GAAG,CAAjB;AACA,SAAQD,UAAU,IAAIC,OAAO,GAAG,CAAd,CAAX,GAA+B,EAAEA,OAAO,GAAG,CAAZ,CAAtC;AACD;;AAQM,SAASC,eAAT,CACLC,YADK,EAELC,YAFK,EAGLC,UAHK,EAKQ;AAAA,MADbL,UACa,uEADQI,YAAY,CAACJ,UACrB;AACb,MAAMM,WAAW,GAAG,IAAIC,UAAJ,CAAeJ,YAAf,EAA6BE,UAA7B,EAAyCL,UAAzC,CAApB;AACA,MAAMQ,WAAW,GAAG,IAAID,UAAJ,CAAeH,YAAf,CAApB;AACAE,EAAAA,WAAW,CAACG,GAAZ,CAAgBD,WAAhB;AACA,SAAOL,YAAP;AACD;;AAUM,SAASO,WAAT,CAAqBC,MAArB,EAAgDC,MAAhD,EAA6DC,YAA7D,EAA2F;AAChG,MAAIL,WAAJ;;AAEA,MAAIG,MAAM,YAAYG,WAAtB,EAAmC;AACjCN,IAAAA,WAAW,GAAG,IAAID,UAAJ,CAAeI,MAAf,CAAd;AACD,GAFD,MAEO;AAOL,QAAMI,aAAa,GAAGJ,MAAM,CAACN,UAA7B;AACA,QAAMW,aAAa,GAAGL,MAAM,CAACX,UAA7B;AAGAQ,IAAAA,WAAW,GAAG,IAAID,UAAJ,CAAeI,MAAM,CAACM,MAAP,IAAiBN,MAAM,CAACO,WAAvC,EAAoDH,aAApD,EAAmEC,aAAnE,CAAd;AACD;;AAGDJ,EAAAA,MAAM,CAACH,GAAP,CAAWD,WAAX,EAAwBK,YAAxB;AAEA,SAAOA,YAAY,GAAGd,WAAW,CAACS,WAAW,CAACR,UAAb,EAAyB,CAAzB,CAAjC;AACD","sourcesContent":["import {assert} from '../env-utils/assert';\n\n/**\n * Calculate new size of an arrayBuffer to be aligned to an n-byte boundary\n * This function increases `byteLength` by the minimum delta,\n * allowing the total length to be divided by `padding`\n * @param byteLength\n * @param padding\n */\nexport function padToNBytes(byteLength: number, padding: number): number {\n assert(byteLength >= 0); // `Incorrect 'byteLength' value: ${byteLength}`\n assert(padding > 0); // `Incorrect 'padding' value: ${padding}`\n return (byteLength + (padding - 1)) & ~(padding - 1);\n}\n\n/**\n * Creates a new Uint8Array based on two different ArrayBuffers\n * @param targetBuffer The first buffer.\n * @param sourceBuffer The second buffer.\n * @return The new ArrayBuffer created out of the two.\n */\nexport function copyArrayBuffer(\n targetBuffer: ArrayBuffer,\n sourceBuffer: ArrayBuffer,\n byteOffset: number,\n byteLength: number = sourceBuffer.byteLength\n): ArrayBuffer {\n const targetArray = new Uint8Array(targetBuffer, byteOffset, byteLength);\n const sourceArray = new Uint8Array(sourceBuffer);\n targetArray.set(sourceArray);\n return targetBuffer;\n}\n\n/**\n * Copy from source to target at the targetOffset\n *\n * @param source - The data to copy\n * @param target - The destination to copy data into\n * @param targetOffset - The start offset into target to place the copied data\n * @returns the new offset taking into account proper padding\n */\nexport function copyToArray(source: ArrayBuffer | any, target: any, targetOffset: number): number {\n let sourceArray;\n\n if (source instanceof ArrayBuffer) {\n sourceArray = new Uint8Array(source);\n } else {\n // Pack buffer onto the big target array\n //\n // 'source.data.buffer' could be a view onto a larger buffer.\n // We MUST use this constructor to ensure the byteOffset and byteLength is\n // set to correct values from 'source.data' and not the underlying\n // buffer for target.set() to work properly.\n const srcByteOffset = source.byteOffset;\n const srcByteLength = source.byteLength;\n // In gltf parser it is set as \"arrayBuffer\" instead of \"buffer\"\n // https://github.com/visgl/loaders.gl/blob/1e3a82a0a65d7b6a67b1e60633453e5edda2960a/modules/gltf/src/lib/parse-gltf.js#L85\n sourceArray = new Uint8Array(source.buffer || source.arrayBuffer, srcByteOffset, srcByteLength);\n }\n\n // Pack buffer onto the big target array\n target.set(sourceArray, targetOffset);\n\n return targetOffset + padToNBytes(sourceArray.byteLength, 4);\n}\n"],"file":"memory-copy-utils.js"}
1
+ {"version":3,"sources":["../../../../src/lib/binary-utils/memory-copy-utils.ts"],"names":["padToNBytes","byteLength","padding","copyArrayBuffer","targetBuffer","sourceBuffer","byteOffset","targetArray","Uint8Array","sourceArray","set","copyToArray","source","target","targetOffset","ArrayBuffer","srcByteOffset","srcByteLength","buffer","arrayBuffer"],"mappings":";;;;;;;;;AAAA;;AASO,SAASA,WAAT,CAAqBC,UAArB,EAAyCC,OAAzC,EAAkE;AACvE,sBAAOD,UAAU,IAAI,CAArB;AACA,sBAAOC,OAAO,GAAG,CAAjB;AACA,SAAQD,UAAU,IAAIC,OAAO,GAAG,CAAd,CAAX,GAA+B,EAAEA,OAAO,GAAG,CAAZ,CAAtC;AACD;;AAQM,SAASC,eAAT,CACLC,YADK,EAELC,YAFK,EAGLC,UAHK,EAILL,UAAkB,GAAGI,YAAY,CAACJ,UAJ7B,EAKQ;AACb,QAAMM,WAAW,GAAG,IAAIC,UAAJ,CAAeJ,YAAf,EAA6BE,UAA7B,EAAyCL,UAAzC,CAApB;AACA,QAAMQ,WAAW,GAAG,IAAID,UAAJ,CAAeH,YAAf,CAApB;AACAE,EAAAA,WAAW,CAACG,GAAZ,CAAgBD,WAAhB;AACA,SAAOL,YAAP;AACD;;AAUM,SAASO,WAAT,CAAqBC,MAArB,EAAgDC,MAAhD,EAA6DC,YAA7D,EAA2F;AAChG,MAAIL,WAAJ;;AAEA,MAAIG,MAAM,YAAYG,WAAtB,EAAmC;AACjCN,IAAAA,WAAW,GAAG,IAAID,UAAJ,CAAeI,MAAf,CAAd;AACD,GAFD,MAEO;AAOL,UAAMI,aAAa,GAAGJ,MAAM,CAACN,UAA7B;AACA,UAAMW,aAAa,GAAGL,MAAM,CAACX,UAA7B;AAGAQ,IAAAA,WAAW,GAAG,IAAID,UAAJ,CAAeI,MAAM,CAACM,MAAP,IAAiBN,MAAM,CAACO,WAAvC,EAAoDH,aAApD,EAAmEC,aAAnE,CAAd;AACD;;AAGDJ,EAAAA,MAAM,CAACH,GAAP,CAAWD,WAAX,EAAwBK,YAAxB;AAEA,SAAOA,YAAY,GAAGd,WAAW,CAACS,WAAW,CAACR,UAAb,EAAyB,CAAzB,CAAjC;AACD","sourcesContent":["import {assert} from '../env-utils/assert';\n\n/**\n * Calculate new size of an arrayBuffer to be aligned to an n-byte boundary\n * This function increases `byteLength` by the minimum delta,\n * allowing the total length to be divided by `padding`\n * @param byteLength\n * @param padding\n */\nexport function padToNBytes(byteLength: number, padding: number): number {\n assert(byteLength >= 0); // `Incorrect 'byteLength' value: ${byteLength}`\n assert(padding > 0); // `Incorrect 'padding' value: ${padding}`\n return (byteLength + (padding - 1)) & ~(padding - 1);\n}\n\n/**\n * Creates a new Uint8Array based on two different ArrayBuffers\n * @param targetBuffer The first buffer.\n * @param sourceBuffer The second buffer.\n * @return The new ArrayBuffer created out of the two.\n */\nexport function copyArrayBuffer(\n targetBuffer: ArrayBuffer,\n sourceBuffer: ArrayBuffer,\n byteOffset: number,\n byteLength: number = sourceBuffer.byteLength\n): ArrayBuffer {\n const targetArray = new Uint8Array(targetBuffer, byteOffset, byteLength);\n const sourceArray = new Uint8Array(sourceBuffer);\n targetArray.set(sourceArray);\n return targetBuffer;\n}\n\n/**\n * Copy from source to target at the targetOffset\n *\n * @param source - The data to copy\n * @param target - The destination to copy data into\n * @param targetOffset - The start offset into target to place the copied data\n * @returns the new offset taking into account proper padding\n */\nexport function copyToArray(source: ArrayBuffer | any, target: any, targetOffset: number): number {\n let sourceArray;\n\n if (source instanceof ArrayBuffer) {\n sourceArray = new Uint8Array(source);\n } else {\n // Pack buffer onto the big target array\n //\n // 'source.data.buffer' could be a view onto a larger buffer.\n // We MUST use this constructor to ensure the byteOffset and byteLength is\n // set to correct values from 'source.data' and not the underlying\n // buffer for target.set() to work properly.\n const srcByteOffset = source.byteOffset;\n const srcByteLength = source.byteLength;\n // In gltf parser it is set as \"arrayBuffer\" instead of \"buffer\"\n // https://github.com/visgl/loaders.gl/blob/1e3a82a0a65d7b6a67b1e60633453e5edda2960a/modules/gltf/src/lib/parse-gltf.js#L85\n sourceArray = new Uint8Array(source.buffer || source.arrayBuffer, srcByteOffset, srcByteLength);\n }\n\n // Pack buffer onto the big target array\n target.set(sourceArray, targetOffset);\n\n return targetOffset + padToNBytes(sourceArray.byteLength, 4);\n}\n"],"file":"memory-copy-utils.js"}
@@ -1,33 +1,28 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports.nodeVersion = exports.isWorker = exports.isBrowser = exports.document = exports.global = exports.window = exports.self = void 0;
9
-
10
- var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
11
-
12
- var globals = {
7
+ const globals = {
13
8
  self: typeof self !== 'undefined' && self,
14
9
  window: typeof window !== 'undefined' && window,
15
10
  global: typeof global !== 'undefined' && global,
16
11
  document: typeof document !== 'undefined' && document
17
12
  };
18
- var self_ = globals.self || globals.window || globals.global || {};
13
+ const self_ = globals.self || globals.window || globals.global || {};
19
14
  exports.self = self_;
20
- var window_ = globals.window || globals.self || globals.global || {};
15
+ const window_ = globals.window || globals.self || globals.global || {};
21
16
  exports.window = window_;
22
- var global_ = globals.global || globals.self || globals.window || {};
17
+ const global_ = globals.global || globals.self || globals.window || {};
23
18
  exports.global = global_;
24
- var document_ = globals.document || {};
19
+ const document_ = globals.document || {};
25
20
  exports.document = document_;
26
- var isBrowser = (typeof process === "undefined" ? "undefined" : (0, _typeof2.default)(process)) !== 'object' || String(process) !== '[object process]' || process.browser;
21
+ const isBrowser = typeof process !== 'object' || String(process) !== '[object process]' || process.browser;
27
22
  exports.isBrowser = isBrowser;
28
- var isWorker = typeof importScripts === 'function';
23
+ const isWorker = typeof importScripts === 'function';
29
24
  exports.isWorker = isWorker;
30
- var matches = typeof process !== 'undefined' && process.version && /v([0-9]*)/.exec(process.version);
31
- var nodeVersion = matches && parseFloat(matches[1]) || 0;
25
+ const matches = typeof process !== 'undefined' && process.version && /v([0-9]*)/.exec(process.version);
26
+ const nodeVersion = matches && parseFloat(matches[1]) || 0;
32
27
  exports.nodeVersion = nodeVersion;
33
28
  //# sourceMappingURL=globals.js.map
@@ -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,GAE7B,QAAOC,OAAP,uDAAOA,OAAP,OAAmB,QAAnB,IAA+BC,MAAM,CAACD,OAAD,CAAN,KAAoB,kBAAnD,IAAyEA,OAAO,CAACE,OAF5E;;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 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
+ {"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;;AAKO,MAAMK,SAAkB,GAE7B,OAAOC,OAAP,KAAmB,QAAnB,IAA+BC,MAAM,CAACD,OAAD,CAAN,KAAoB,kBAAnD,IAAyEA,OAAO,CAACE,OAF5E;;AAKA,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;AAGO,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 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"}
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var fs = _interopRequireWildcard(require("../node/fs"));
9
+
10
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
11
+
12
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof 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; }
13
+
14
+ class NodeFileSystem {
15
+ constructor(options) {
16
+ this.fetch = options._fetch;
17
+ }
18
+
19
+ async readdir(dirname = '.', options) {
20
+ return await fs.readdir(dirname, options);
21
+ }
22
+
23
+ async stat(path, options) {
24
+ const info = await fs.stat(path, options);
25
+ return {
26
+ size: Number(info.size),
27
+ isDirectory: () => false,
28
+ info
29
+ };
30
+ }
31
+
32
+ async fetch(path, options) {
33
+ const fallbackFetch = options.fetch || this.fetch;
34
+ return fallbackFetch(path, options);
35
+ }
36
+
37
+ async open(path, flags, mode) {
38
+ return await fs.open(path, flags);
39
+ }
40
+
41
+ async close(fd) {
42
+ return await fs.close(fd);
43
+ }
44
+
45
+ async fstat(fd) {
46
+ const info = await fs.fstat(fd);
47
+ return info;
48
+ }
49
+
50
+ async read(fd, {
51
+ buffer = null,
52
+ offset = 0,
53
+ length = buffer.byteLength,
54
+ position = null
55
+ }) {
56
+ let totalBytesRead = 0;
57
+
58
+ while (totalBytesRead < length) {
59
+ const {
60
+ bytesRead
61
+ } = await fs.read(fd, buffer, offset + totalBytesRead, length - totalBytesRead, position + totalBytesRead);
62
+ totalBytesRead += bytesRead;
63
+ }
64
+
65
+ return {
66
+ bytesRead: totalBytesRead,
67
+ buffer
68
+ };
69
+ }
70
+
71
+ }
72
+
73
+ exports.default = NodeFileSystem;
74
+ //# sourceMappingURL=node-filesystem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/lib/filesystems/node-filesystem.ts"],"names":["NodeFileSystem","constructor","options","fetch","_fetch","readdir","dirname","fs","stat","path","info","size","Number","isDirectory","fallbackFetch","open","flags","mode","close","fd","fstat","read","buffer","offset","length","byteLength","position","totalBytesRead","bytesRead"],"mappings":";;;;;;;AAAA;;;;;;AAuBe,MAAMA,cAAN,CAAyE;AAEtFC,EAAAA,WAAW,CAACC,OAAD,EAAgC;AACzC,SAAKC,KAAL,GAAaD,OAAO,CAACE,MAArB;AACD;;AAEY,QAAPC,OAAO,CAACC,OAAO,G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AAM;AAACI,QAAAA;AAAD,UAAc,MAAMrB,EAAE,CAACc,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 '@loaders.gl/loader-utils';\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"}