@loaders.gl/loader-utils 3.1.0-alpha.3 → 3.1.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es5/index.js +323 -0
- package/dist/es5/index.js.map +1 -0
- package/dist/es5/json-loader.js +29 -0
- package/dist/es5/json-loader.js.map +1 -0
- package/dist/es5/lib/binary-utils/array-buffer-utils.js +102 -0
- package/dist/es5/lib/binary-utils/array-buffer-utils.js.map +1 -0
- package/dist/es5/lib/binary-utils/binary-copy-utils.js +35 -0
- package/dist/es5/lib/binary-utils/binary-copy-utils.js.map +1 -0
- package/dist/es5/lib/binary-utils/buffer-utils.js +32 -0
- package/dist/es5/lib/binary-utils/buffer-utils.js.map +1 -0
- package/dist/es5/lib/binary-utils/encode-utils.js +42 -0
- package/dist/es5/lib/binary-utils/encode-utils.js.map +1 -0
- package/dist/es5/lib/binary-utils/get-first-characters.js +36 -0
- package/dist/es5/lib/binary-utils/get-first-characters.js.map +1 -0
- package/dist/es5/lib/binary-utils/memory-copy-utils.js +39 -0
- package/dist/es5/lib/binary-utils/memory-copy-utils.js.map +1 -0
- package/dist/es5/lib/env-utils/assert.js +13 -0
- package/dist/es5/lib/env-utils/assert.js.map +1 -0
- package/dist/es5/lib/env-utils/globals.js +28 -0
- package/dist/es5/lib/env-utils/globals.js.map +1 -0
- package/dist/es5/lib/filesystems/node-filesystem.js +74 -0
- package/dist/es5/lib/filesystems/node-filesystem.js.map +1 -0
- package/dist/es5/lib/iterators/async-iteration.js +51 -0
- package/dist/es5/lib/iterators/async-iteration.js.map +1 -0
- package/dist/es5/lib/iterators/text-iterators.js +59 -0
- package/dist/es5/lib/iterators/text-iterators.js.map +1 -0
- package/dist/es5/lib/node/buffer.js +38 -0
- package/dist/es5/lib/node/buffer.js.map +1 -0
- package/dist/es5/lib/node/fs.js +52 -0
- package/dist/es5/lib/node/fs.js.map +1 -0
- package/dist/es5/lib/node/util.js +16 -0
- package/dist/es5/lib/node/util.js.map +1 -0
- package/dist/es5/lib/parser-utils/parse-json.js +17 -0
- package/dist/es5/lib/parser-utils/parse-json.js.map +1 -0
- package/dist/es5/lib/path-utils/file-aliases.js +39 -0
- package/dist/es5/lib/path-utils/file-aliases.js.map +1 -0
- package/dist/es5/lib/path-utils/path.js +35 -0
- package/dist/es5/lib/path-utils/path.js.map +1 -0
- package/dist/es5/lib/request-utils/request-scheduler.js +154 -0
- package/dist/es5/lib/request-utils/request-scheduler.js.map +1 -0
- package/dist/es5/lib/worker-loader-utils/create-loader-worker.js +117 -0
- package/dist/es5/lib/worker-loader-utils/create-loader-worker.js.map +1 -0
- package/dist/es5/lib/worker-loader-utils/parse-with-worker.js +76 -0
- package/dist/es5/lib/worker-loader-utils/parse-with-worker.js.map +1 -0
- package/dist/es5/types.js +2 -0
- package/dist/{types.js.map → es5/types.js.map} +0 -0
- package/dist/es5/workers/json-worker.js +8 -0
- package/dist/es5/workers/json-worker.js.map +1 -0
- package/dist/esm/index.js +26 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/json-loader.js +21 -0
- package/dist/esm/json-loader.js.map +1 -0
- package/dist/esm/lib/binary-utils/array-buffer-utils.js +86 -0
- package/dist/esm/lib/binary-utils/array-buffer-utils.js.map +1 -0
- package/dist/esm/lib/binary-utils/binary-copy-utils.js +25 -0
- package/dist/esm/lib/binary-utils/binary-copy-utils.js.map +1 -0
- package/dist/esm/lib/binary-utils/buffer-utils.js +16 -0
- package/dist/esm/lib/binary-utils/buffer-utils.js.map +1 -0
- package/dist/esm/lib/binary-utils/encode-utils.js +31 -0
- package/dist/esm/lib/binary-utils/encode-utils.js.map +1 -0
- package/dist/esm/lib/binary-utils/get-first-characters.js +27 -0
- package/dist/esm/lib/binary-utils/get-first-characters.js.map +1 -0
- package/dist/esm/lib/binary-utils/memory-copy-utils.js +27 -0
- package/dist/esm/lib/binary-utils/memory-copy-utils.js.map +1 -0
- package/dist/esm/lib/env-utils/assert.js +6 -0
- package/dist/esm/lib/env-utils/assert.js.map +1 -0
- package/dist/esm/lib/env-utils/globals.js +16 -0
- package/dist/esm/lib/env-utils/globals.js.map +1 -0
- package/dist/esm/lib/filesystems/node-filesystem.js +60 -0
- package/dist/esm/lib/filesystems/node-filesystem.js.map +1 -0
- package/dist/esm/lib/iterators/async-iteration.js +39 -0
- package/dist/esm/lib/iterators/async-iteration.js.map +1 -0
- package/dist/esm/lib/iterators/text-iterators.js +46 -0
- package/dist/esm/lib/iterators/text-iterators.js.map +1 -0
- package/dist/esm/lib/node/buffer.js +28 -0
- package/dist/esm/lib/node/buffer.js.map +1 -0
- package/dist/esm/lib/node/fs.js +27 -0
- package/dist/esm/lib/node/fs.js.map +1 -0
- package/dist/esm/lib/node/util.js +3 -0
- package/dist/esm/lib/node/util.js.map +1 -0
- package/dist/esm/lib/parser-utils/parse-json.js +9 -0
- package/dist/esm/lib/parser-utils/parse-json.js.map +1 -0
- package/dist/esm/lib/path-utils/file-aliases.js +26 -0
- package/dist/esm/lib/path-utils/file-aliases.js.map +1 -0
- package/dist/esm/lib/path-utils/path.js +24 -0
- package/dist/esm/lib/path-utils/path.js.map +1 -0
- package/dist/esm/lib/request-utils/request-scheduler.js +146 -0
- package/dist/esm/lib/request-utils/request-scheduler.js.map +1 -0
- package/dist/esm/lib/worker-loader-utils/create-loader-worker.js +102 -0
- package/dist/esm/lib/worker-loader-utils/create-loader-worker.js.map +1 -0
- package/dist/esm/lib/worker-loader-utils/parse-with-worker.js +64 -0
- package/dist/esm/lib/worker-loader-utils/parse-with-worker.js.map +1 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/workers/json-worker.js +4 -0
- package/dist/esm/workers/json-worker.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +111 -26
- package/dist/json-loader.d.ts +22 -0
- package/dist/json-loader.d.ts.map +1 -0
- package/dist/json-loader.js +25 -18
- package/dist/lib/binary-utils/array-buffer-utils.d.ts +31 -0
- package/dist/lib/binary-utils/array-buffer-utils.d.ts.map +1 -0
- package/dist/lib/binary-utils/array-buffer-utils.js +108 -79
- package/dist/lib/binary-utils/binary-copy-utils.d.ts +24 -0
- package/dist/lib/binary-utils/binary-copy-utils.d.ts.map +1 -0
- package/dist/lib/binary-utils/binary-copy-utils.js +48 -22
- package/dist/lib/binary-utils/buffer-utils.d.ts +16 -0
- package/dist/lib/binary-utils/buffer-utils.d.ts.map +1 -0
- package/dist/lib/binary-utils/buffer-utils.js +47 -13
- package/dist/lib/binary-utils/encode-utils.d.ts +4 -0
- package/dist/lib/binary-utils/encode-utils.d.ts.map +1 -0
- package/dist/lib/binary-utils/encode-utils.js +30 -26
- package/dist/lib/binary-utils/get-first-characters.d.ts +3 -0
- package/dist/lib/binary-utils/get-first-characters.d.ts.map +1 -0
- package/dist/lib/binary-utils/get-first-characters.js +28 -25
- package/dist/lib/binary-utils/memory-copy-utils.d.ts +25 -0
- package/dist/lib/binary-utils/memory-copy-utils.d.ts.map +1 -0
- package/dist/lib/binary-utils/memory-copy-utils.js +58 -24
- package/dist/lib/env-utils/assert.d.ts +6 -0
- package/dist/lib/env-utils/assert.d.ts.map +1 -0
- package/dist/lib/env-utils/assert.js +12 -5
- package/dist/lib/env-utils/globals.d.ts +15 -0
- package/dist/lib/env-utils/globals.d.ts.map +1 -0
- package/dist/lib/env-utils/globals.js +23 -9
- package/dist/lib/filesystems/node-filesystem.d.ts +38 -0
- package/dist/lib/filesystems/node-filesystem.d.ts.map +1 -0
- package/dist/lib/filesystems/node-filesystem.js +68 -59
- package/dist/lib/iterators/async-iteration.d.ts +20 -0
- package/dist/lib/iterators/async-iteration.d.ts.map +1 -0
- package/dist/lib/iterators/async-iteration.js +49 -35
- package/dist/lib/iterators/text-iterators.d.ts +19 -0
- package/dist/lib/iterators/text-iterators.d.ts.map +1 -0
- package/dist/lib/iterators/text-iterators.js +56 -41
- package/dist/lib/node/buffer.d.ts +10 -0
- package/dist/lib/node/buffer.d.ts.map +1 -0
- package/dist/lib/node/buffer.js +33 -25
- package/dist/lib/node/fs.d.ts +26 -0
- package/dist/lib/node/fs.d.ts.map +1 -0
- package/dist/lib/node/fs.js +41 -26
- package/dist/lib/node/util.d.ts +5 -0
- package/dist/lib/node/util.d.ts.map +1 -0
- package/dist/lib/node/util.js +25 -3
- package/dist/lib/parser-utils/parse-json.d.ts +5 -0
- package/dist/lib/parser-utils/parse-json.d.ts.map +1 -0
- package/dist/lib/parser-utils/parse-json.js +15 -8
- package/dist/lib/path-utils/file-aliases.d.ts +17 -0
- package/dist/lib/path-utils/file-aliases.d.ts.map +1 -0
- package/dist/lib/path-utils/file-aliases.js +40 -19
- package/dist/lib/path-utils/path.d.ts +16 -0
- package/dist/lib/path-utils/path.d.ts.map +1 -0
- package/dist/lib/path-utils/path.js +37 -21
- package/dist/lib/request-utils/request-scheduler.d.ts +62 -0
- package/dist/lib/request-utils/request-scheduler.d.ts.map +1 -0
- package/dist/lib/request-utils/request-scheduler.js +127 -131
- package/dist/lib/worker-loader-utils/create-loader-worker.d.ts +7 -0
- package/dist/lib/worker-loader-utils/create-loader-worker.d.ts.map +1 -0
- package/dist/lib/worker-loader-utils/create-loader-worker.js +91 -96
- package/dist/lib/worker-loader-utils/parse-with-worker.d.ts +15 -0
- package/dist/lib/worker-loader-utils/parse-with-worker.d.ts.map +1 -0
- package/dist/lib/worker-loader-utils/parse-with-worker.js +69 -60
- package/dist/types.d.ts +207 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -2
- package/dist/workers/json-worker.d.ts +2 -0
- package/dist/workers/json-worker.d.ts.map +1 -0
- package/dist/workers/json-worker.js +5 -4
- package/package.json +7 -10
- package/src/lib/worker-loader-utils/parse-with-worker.ts +6 -5
- package/dist/index.js.map +0 -1
- package/dist/json-loader.js.map +0 -1
- package/dist/lib/binary-utils/array-buffer-utils.js.map +0 -1
- package/dist/lib/binary-utils/binary-copy-utils.js.map +0 -1
- package/dist/lib/binary-utils/buffer-utils.js.map +0 -1
- package/dist/lib/binary-utils/encode-utils.js.map +0 -1
- package/dist/lib/binary-utils/get-first-characters.js.map +0 -1
- package/dist/lib/binary-utils/memory-copy-utils.js.map +0 -1
- package/dist/lib/env-utils/assert.js.map +0 -1
- package/dist/lib/env-utils/globals.js.map +0 -1
- package/dist/lib/filesystems/node-filesystem.js.map +0 -1
- package/dist/lib/iterators/async-iteration.js.map +0 -1
- package/dist/lib/iterators/text-iterators.js.map +0 -1
- package/dist/lib/node/buffer.js.map +0 -1
- package/dist/lib/node/fs.js.map +0 -1
- package/dist/lib/node/util.js.map +0 -1
- package/dist/lib/parser-utils/parse-json.js.map +0 -1
- package/dist/lib/path-utils/file-aliases.js.map +0 -1
- package/dist/lib/path-utils/path.js.map +0 -1
- package/dist/lib/request-utils/request-scheduler.js.map +0 -1
- package/dist/lib/worker-loader-utils/create-loader-worker.js.map +0 -1
- package/dist/lib/worker-loader-utils/parse-with-worker.js.map +0 -1
- package/dist/workers/json-worker.js.map +0 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.padToNBytes = padToNBytes;
|
|
7
|
+
exports.copyArrayBuffer = copyArrayBuffer;
|
|
8
|
+
exports.copyToArray = copyToArray;
|
|
9
|
+
|
|
10
|
+
var _assert = require("../env-utils/assert");
|
|
11
|
+
|
|
12
|
+
function padToNBytes(byteLength, padding) {
|
|
13
|
+
(0, _assert.assert)(byteLength >= 0);
|
|
14
|
+
(0, _assert.assert)(padding > 0);
|
|
15
|
+
return byteLength + (padding - 1) & ~(padding - 1);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function copyArrayBuffer(targetBuffer, sourceBuffer, byteOffset, byteLength = sourceBuffer.byteLength) {
|
|
19
|
+
const targetArray = new Uint8Array(targetBuffer, byteOffset, byteLength);
|
|
20
|
+
const sourceArray = new Uint8Array(sourceBuffer);
|
|
21
|
+
targetArray.set(sourceArray);
|
|
22
|
+
return targetBuffer;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function copyToArray(source, target, targetOffset) {
|
|
26
|
+
let sourceArray;
|
|
27
|
+
|
|
28
|
+
if (source instanceof ArrayBuffer) {
|
|
29
|
+
sourceArray = new Uint8Array(source);
|
|
30
|
+
} else {
|
|
31
|
+
const srcByteOffset = source.byteOffset;
|
|
32
|
+
const srcByteLength = source.byteLength;
|
|
33
|
+
sourceArray = new Uint8Array(source.buffer || source.arrayBuffer, srcByteOffset, srcByteLength);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
target.set(sourceArray, targetOffset);
|
|
37
|
+
return targetOffset + padToNBytes(sourceArray.byteLength, 4);
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=memory-copy-utils.js.map
|
|
@@ -0,0 +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,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"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.assert = assert;
|
|
7
|
+
|
|
8
|
+
function assert(condition, message) {
|
|
9
|
+
if (!condition) {
|
|
10
|
+
throw new Error(message || 'loader assertion failed.');
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=assert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/env-utils/assert.ts"],"names":["assert","condition","message","Error"],"mappings":";;;;;;;AAIO,SAASA,MAAT,CAAgBC,SAAhB,EAAgCC,OAAhC,EAAwD;AAC7D,MAAI,CAACD,SAAL,EAAgB;AACd,UAAM,IAAIE,KAAJ,CAAUD,OAAO,IAAI,0BAArB,CAAN;AACD;AACF","sourcesContent":["/**\n * Throws an `Error` with the optional `message` if `condition` is falsy\n * @note Replacement for the external assert method to reduce bundle size\n */\nexport function assert(condition: any, message?: string): void {\n if (!condition) {\n throw new Error(message || 'loader assertion failed.');\n }\n}\n"],"file":"assert.js"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.nodeVersion = exports.isWorker = exports.isBrowser = exports.document = exports.global = exports.window = exports.self = void 0;
|
|
7
|
+
const globals = {
|
|
8
|
+
self: typeof self !== 'undefined' && self,
|
|
9
|
+
window: typeof window !== 'undefined' && window,
|
|
10
|
+
global: typeof global !== 'undefined' && global,
|
|
11
|
+
document: typeof document !== 'undefined' && document
|
|
12
|
+
};
|
|
13
|
+
const self_ = globals.self || globals.window || globals.global || {};
|
|
14
|
+
exports.self = self_;
|
|
15
|
+
const window_ = globals.window || globals.self || globals.global || {};
|
|
16
|
+
exports.window = window_;
|
|
17
|
+
const global_ = globals.global || globals.self || globals.window || {};
|
|
18
|
+
exports.global = global_;
|
|
19
|
+
const document_ = globals.document || {};
|
|
20
|
+
exports.document = document_;
|
|
21
|
+
const isBrowser = Boolean(typeof process !== 'object' || String(process) !== '[object process]' || process.browser);
|
|
22
|
+
exports.isBrowser = isBrowser;
|
|
23
|
+
const isWorker = typeof importScripts === 'function';
|
|
24
|
+
exports.isWorker = isWorker;
|
|
25
|
+
const matches = typeof process !== 'undefined' && process.version && /v([0-9]*)/.exec(process.version);
|
|
26
|
+
const nodeVersion = matches && parseFloat(matches[1]) || 0;
|
|
27
|
+
exports.nodeVersion = nodeVersion;
|
|
28
|
+
//# sourceMappingURL=globals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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;;AAKO,MAAMK,SAAkB,GAE7BC,OAAO,CAAC,OAAOC,OAAP,KAAmB,QAAnB,IAA+BC,MAAM,CAACD,OAAD,CAAN,KAAoB,kBAAnD,IAAyEA,OAAO,CAACE,OAAlF,CAFF;;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 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"}
|
|
@@ -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,GAAG,GAAX,EAAgBJ,OAAhB,EAA8C;AACzD,WAAO,MAAMK,EAAE,CAACF,OAAH,CAAWC,OAAX,EAAoBJ,OAApB,CAAb;AACD;;AAES,QAAJM,IAAI,CAACC,IAAD,EAAeP,OAAf,EAA4C;AACpD,UAAMQ,IAAI,GAAG,MAAMH,EAAE,CAACC,IAAH,CAAQC,IAAR,EAAcP,OAAd,CAAnB;AACA,WAAO;AAACS,MAAAA,IAAI,EAAEC,MAAM,CAACF,IAAI,CAACC,IAAN,CAAb;AAA0BE,MAAAA,WAAW,EAAE,MAAM,KAA7C;AAAoDH,MAAAA;AAApD,KAAP;AACD;;AAEU,QAALP,KAAK,CAACM,IAAD,EAAeP,OAAf,EAA8C;AAGvD,UAAMY,aAAa,GAAGZ,OAAO,CAACC,KAAR,IAAiB,KAAKA,KAA5C;AACA,WAAOW,aAAa,CAACL,IAAD,EAAOP,OAAP,CAApB;AACD;;AAGS,QAAJa,IAAI,CAACN,IAAD,EAAeO,KAAf,EAAuCC,IAAvC,EAAoE;AAC5E,WAAO,MAAMV,EAAE,CAACQ,IAAH,CAAQN,IAAR,EAAcO,KAAd,CAAb;AACD;;AAEU,QAALE,KAAK,CAACC,EAAD,EAA4B;AACrC,WAAO,MAAMZ,EAAE,CAACW,KAAH,CAASC,EAAT,CAAb;AACD;;AAEU,QAALC,KAAK,CAACD,EAAD,EAA4B;AACrC,UAAMT,IAAI,GAAG,MAAMH,EAAE,CAACa,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,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 '../../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"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.forEach = forEach;
|
|
7
|
+
exports.concatenateArrayBuffersAsync = concatenateArrayBuffersAsync;
|
|
8
|
+
exports.concatenateStringsAsync = concatenateStringsAsync;
|
|
9
|
+
|
|
10
|
+
var _arrayBufferUtils = require("../binary-utils/array-buffer-utils");
|
|
11
|
+
|
|
12
|
+
async function forEach(iterator, visitor) {
|
|
13
|
+
while (true) {
|
|
14
|
+
const {
|
|
15
|
+
done,
|
|
16
|
+
value
|
|
17
|
+
} = await iterator.next();
|
|
18
|
+
|
|
19
|
+
if (done) {
|
|
20
|
+
iterator.return();
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const cancel = visitor(value);
|
|
25
|
+
|
|
26
|
+
if (cancel) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function concatenateArrayBuffersAsync(asyncIterator) {
|
|
33
|
+
const arrayBuffers = [];
|
|
34
|
+
|
|
35
|
+
for await (const chunk of asyncIterator) {
|
|
36
|
+
arrayBuffers.push(chunk);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return (0, _arrayBufferUtils.concatenateArrayBuffers)(...arrayBuffers);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function concatenateStringsAsync(asyncIterator) {
|
|
43
|
+
const strings = [];
|
|
44
|
+
|
|
45
|
+
for await (const chunk of asyncIterator) {
|
|
46
|
+
strings.push(chunk);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return strings.join('');
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=async-iteration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/iterators/async-iteration.ts"],"names":["forEach","iterator","visitor","done","value","next","return","cancel","concatenateArrayBuffersAsync","asyncIterator","arrayBuffers","chunk","push","concatenateStringsAsync","strings","join"],"mappings":";;;;;;;;;AAAA;;AAgBO,eAAeA,OAAf,CAAuBC,QAAvB,EAAiCC,OAAjC,EAA0C;AAE/C,SAAO,IAAP,EAAa;AACX,UAAM;AAACC,MAAAA,IAAD;AAAOC,MAAAA;AAAP,QAAgB,MAAMH,QAAQ,CAACI,IAAT,EAA5B;;AACA,QAAIF,IAAJ,EAAU;AACRF,MAAAA,QAAQ,CAACK,MAAT;AACA;AACD;;AACD,UAAMC,MAAM,GAAGL,OAAO,CAACE,KAAD,CAAtB;;AACA,QAAIG,MAAJ,EAAY;AACV;AACD;AACF;AACF;;AASM,eAAeC,4BAAf,CACLC,aADK,EAEiB;AACtB,QAAMC,YAA2B,GAAG,EAApC;;AACA,aAAW,MAAMC,KAAjB,IAA0BF,aAA1B,EAAyC;AACvCC,IAAAA,YAAY,CAACE,IAAb,CAAkBD,KAAlB;AACD;;AACD,SAAO,+CAAwB,GAAGD,YAA3B,CAAP;AACD;;AAEM,eAAeG,uBAAf,CACLJ,aADK,EAEY;AACjB,QAAMK,OAAiB,GAAG,EAA1B;;AACA,aAAW,MAAMH,KAAjB,IAA0BF,aAA1B,EAAyC;AACvCK,IAAAA,OAAO,CAACF,IAAR,CAAaD,KAAb;AACD;;AACD,SAAOG,OAAO,CAACC,IAAR,CAAa,EAAb,CAAP;AACD","sourcesContent":["import {concatenateArrayBuffers} from '../binary-utils/array-buffer-utils';\n\n// GENERAL UTILITIES\n\n/**\n * Iterate over async iterator, without resetting iterator if end is not reached\n * - forEach intentionally does not reset iterator if exiting loop prematurely\n * so that iteration can continue in a second loop\n * - It is recommended to use a standard for-await as last loop to ensure\n * iterator gets properly reset\n *\n * TODO - optimize using sync iteration if argument is an Iterable?\n *\n * @param iterator\n * @param visitor\n */\nexport async function forEach(iterator, visitor) {\n // eslint-disable-next-line\n while (true) {\n const {done, value} = await iterator.next();\n if (done) {\n iterator.return();\n return;\n }\n const cancel = visitor(value);\n if (cancel) {\n return;\n }\n }\n}\n\n// Breaking big data into iterable chunks, concatenating iterable chunks into big data objects\n\n/**\n * Concatenates all data chunks yielded by an (async) iterator\n * This function can e.g. be used to enable atomic parsers to work on (async) iterator inputs\n */\n\nexport async function concatenateArrayBuffersAsync(\n asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>\n): Promise<ArrayBuffer> {\n const arrayBuffers: ArrayBuffer[] = [];\n for await (const chunk of asyncIterator) {\n arrayBuffers.push(chunk);\n }\n return concatenateArrayBuffers(...arrayBuffers);\n}\n\nexport async function concatenateStringsAsync(\n asyncIterator: AsyncIterable<string> | Iterable<string>\n): Promise<string> {\n const strings: string[] = [];\n for await (const chunk of asyncIterator) {\n strings.push(chunk);\n }\n return strings.join('');\n}\n"],"file":"async-iteration.js"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.makeTextDecoderIterator = makeTextDecoderIterator;
|
|
7
|
+
exports.makeTextEncoderIterator = makeTextEncoderIterator;
|
|
8
|
+
exports.makeLineIterator = makeLineIterator;
|
|
9
|
+
exports.makeNumberedLineIterator = makeNumberedLineIterator;
|
|
10
|
+
|
|
11
|
+
async function* makeTextDecoderIterator(arrayBufferIterator, options = {}) {
|
|
12
|
+
const textDecoder = new TextDecoder(undefined, options);
|
|
13
|
+
|
|
14
|
+
for await (const arrayBuffer of arrayBufferIterator) {
|
|
15
|
+
yield typeof arrayBuffer === 'string' ? arrayBuffer : textDecoder.decode(arrayBuffer, {
|
|
16
|
+
stream: true
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async function* makeTextEncoderIterator(textIterator) {
|
|
22
|
+
const textEncoder = new TextEncoder();
|
|
23
|
+
|
|
24
|
+
for await (const text of textIterator) {
|
|
25
|
+
yield typeof text === 'string' ? textEncoder.encode(text) : text;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async function* makeLineIterator(textIterator) {
|
|
30
|
+
let previous = '';
|
|
31
|
+
|
|
32
|
+
for await (const textChunk of textIterator) {
|
|
33
|
+
previous += textChunk;
|
|
34
|
+
let eolIndex;
|
|
35
|
+
|
|
36
|
+
while ((eolIndex = previous.indexOf('\n')) >= 0) {
|
|
37
|
+
const line = previous.slice(0, eolIndex + 1);
|
|
38
|
+
previous = previous.slice(eolIndex + 1);
|
|
39
|
+
yield line;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (previous.length > 0) {
|
|
44
|
+
yield previous;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function* makeNumberedLineIterator(lineIterator) {
|
|
49
|
+
let counter = 1;
|
|
50
|
+
|
|
51
|
+
for await (const line of lineIterator) {
|
|
52
|
+
yield {
|
|
53
|
+
counter,
|
|
54
|
+
line
|
|
55
|
+
};
|
|
56
|
+
counter++;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=text-iterators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/iterators/text-iterators.ts"],"names":["makeTextDecoderIterator","arrayBufferIterator","options","textDecoder","TextDecoder","undefined","arrayBuffer","decode","stream","makeTextEncoderIterator","textIterator","textEncoder","TextEncoder","text","encode","makeLineIterator","previous","textChunk","eolIndex","indexOf","line","slice","length","makeNumberedLineIterator","lineIterator","counter"],"mappings":";;;;;;;;;;AAGO,gBAAgBA,uBAAhB,CACLC,mBADK,EAELC,OAA2B,GAAG,EAFzB,EAGkB;AACvB,QAAMC,WAAW,GAAG,IAAIC,WAAJ,CAAgBC,SAAhB,EAA2BH,OAA3B,CAApB;;AACA,aAAW,MAAMI,WAAjB,IAAgCL,mBAAhC,EAAqD;AACnD,UAAM,OAAOK,WAAP,KAAuB,QAAvB,GACFA,WADE,GAEFH,WAAW,CAACI,MAAZ,CAAmBD,WAAnB,EAAgC;AAACE,MAAAA,MAAM,EAAE;AAAT,KAAhC,CAFJ;AAGD;AACF;;AAOM,gBAAgBC,uBAAhB,CACLC,YADK,EAEuB;AAC5B,QAAMC,WAAW,GAAG,IAAIC,WAAJ,EAApB;;AACA,aAAW,MAAMC,IAAjB,IAAyBH,YAAzB,EAAuC;AACrC,UAAM,OAAOG,IAAP,KAAgB,QAAhB,GAA2BF,WAAW,CAACG,MAAZ,CAAmBD,IAAnB,CAA3B,GAAsDA,IAA5D;AACD;AACF;;AAQM,gBAAgBE,gBAAhB,CACLL,YADK,EAEkB;AACvB,MAAIM,QAAQ,GAAG,EAAf;;AACA,aAAW,MAAMC,SAAjB,IAA8BP,YAA9B,EAA4C;AAC1CM,IAAAA,QAAQ,IAAIC,SAAZ;AACA,QAAIC,QAAJ;;AACA,WAAO,CAACA,QAAQ,GAAGF,QAAQ,CAACG,OAAT,CAAiB,IAAjB,CAAZ,KAAuC,CAA9C,EAAiD;AAE/C,YAAMC,IAAI,GAAGJ,QAAQ,CAACK,KAAT,CAAe,CAAf,EAAkBH,QAAQ,GAAG,CAA7B,CAAb;AACAF,MAAAA,QAAQ,GAAGA,QAAQ,CAACK,KAAT,CAAeH,QAAQ,GAAG,CAA1B,CAAX;AACA,YAAME,IAAN;AACD;AACF;;AAED,MAAIJ,QAAQ,CAACM,MAAT,GAAkB,CAAtB,EAAyB;AACvB,UAAMN,QAAN;AACD;AACF;;AAQM,gBAAgBO,wBAAhB,CACLC,YADK,EAE2C;AAChD,MAAIC,OAAO,GAAG,CAAd;;AACA,aAAW,MAAML,IAAjB,IAAyBI,YAAzB,EAAuC;AACrC,UAAM;AAACC,MAAAA,OAAD;AAAUL,MAAAA;AAAV,KAAN;AACAK,IAAAA,OAAO;AACR;AACF","sourcesContent":["// TextDecoder iterators\n// TextDecoder will keep any partial undecoded bytes between calls to `decode`\n\nexport async function* makeTextDecoderIterator(\n arrayBufferIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>,\n options: TextDecoderOptions = {}\n): AsyncIterable<string> {\n const textDecoder = new TextDecoder(undefined, options);\n for await (const arrayBuffer of arrayBufferIterator) {\n yield typeof arrayBuffer === 'string'\n ? arrayBuffer\n : textDecoder.decode(arrayBuffer, {stream: true});\n }\n}\n\n// TextEncoder iterator\n// TODO - this is not useful unless min chunk size is given\n// TextEncoder will keep any partial undecoded bytes between calls to `encode`\n// If iterator does not yield strings, assume arrayBuffer and return unencoded\n\nexport async function* makeTextEncoderIterator(\n textIterator: AsyncIterable<string> | Iterable<ArrayBuffer>\n): AsyncIterable<ArrayBuffer> {\n const textEncoder = new TextEncoder();\n for await (const text of textIterator) {\n yield typeof text === 'string' ? textEncoder.encode(text) : text;\n }\n}\n\n/**\n * @param textIterator async iterable yielding strings\n * @returns an async iterable over lines\n * See http://2ality.com/2018/04/async-iter-nodejs.html\n */\n\nexport async function* makeLineIterator(\n textIterator: AsyncIterable<string>\n): AsyncIterable<string> {\n let previous = '';\n for await (const textChunk of textIterator) {\n previous += textChunk;\n let eolIndex;\n while ((eolIndex = previous.indexOf('\\n')) >= 0) {\n // line includes the EOL\n const line = previous.slice(0, eolIndex + 1);\n previous = previous.slice(eolIndex + 1);\n yield line;\n }\n }\n\n if (previous.length > 0) {\n yield previous;\n }\n}\n\n/**\n * @param lineIterator async iterable yielding lines\n * @returns async iterable yielding numbered lines\n *\n * See http://2ality.com/2018/04/async-iter-nodejs.html\n */\nexport async function* makeNumberedLineIterator(\n lineIterator: AsyncIterable<string>\n): AsyncIterable<{counter: number; line: string}> {\n let counter = 1;\n for await (const line of lineIterator) {\n yield {counter, line};\n counter++;\n }\n}\n"],"file":"text-iterators.js"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.toArrayBuffer = toArrayBuffer;
|
|
7
|
+
exports.toBuffer = toBuffer;
|
|
8
|
+
|
|
9
|
+
var _assert = require("../env-utils/assert");
|
|
10
|
+
|
|
11
|
+
function toArrayBuffer(buffer) {
|
|
12
|
+
if (Buffer.isBuffer(buffer)) {
|
|
13
|
+
const typedArray = new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.length);
|
|
14
|
+
return typedArray.slice().buffer;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return buffer;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function toBuffer(binaryData) {
|
|
21
|
+
if (ArrayBuffer.isView(binaryData)) {
|
|
22
|
+
binaryData = binaryData.buffer;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (typeof Buffer !== 'undefined' && binaryData instanceof ArrayBuffer) {
|
|
26
|
+
const buffer = new Buffer(binaryData.byteLength);
|
|
27
|
+
const view = new Uint8Array(binaryData);
|
|
28
|
+
|
|
29
|
+
for (let i = 0; i < buffer.length; ++i) {
|
|
30
|
+
buffer[i] = view[i];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return buffer;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return (0, _assert.assert)(false);
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=buffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,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;;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,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,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"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports._readToArrayBuffer = _readToArrayBuffer;
|
|
9
|
+
exports.isSupported = exports.fstat = exports.read = exports.close = exports.open = exports.writeFileSync = exports.writeFile = exports.readFileSync = exports.readFile = exports.stat = exports.readdir = void 0;
|
|
10
|
+
|
|
11
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
12
|
+
|
|
13
|
+
var _buffer = require("./buffer");
|
|
14
|
+
|
|
15
|
+
var _util = require("./util");
|
|
16
|
+
|
|
17
|
+
const readdir = (0, _util.promisify)(_fs.default.readdir);
|
|
18
|
+
exports.readdir = readdir;
|
|
19
|
+
const stat = (0, _util.promisify)(_fs.default.stat);
|
|
20
|
+
exports.stat = stat;
|
|
21
|
+
const readFile = (0, _util.promisify)(_fs.default.readFile);
|
|
22
|
+
exports.readFile = readFile;
|
|
23
|
+
const readFileSync = _fs.default.readFileSync;
|
|
24
|
+
exports.readFileSync = readFileSync;
|
|
25
|
+
const writeFile = (0, _util.promisify)(_fs.default.writeFile);
|
|
26
|
+
exports.writeFile = writeFile;
|
|
27
|
+
const writeFileSync = _fs.default.writeFileSync;
|
|
28
|
+
exports.writeFileSync = writeFileSync;
|
|
29
|
+
const open = (0, _util.promisify)(_fs.default.open);
|
|
30
|
+
exports.open = open;
|
|
31
|
+
const close = (0, _util.promisify)(_fs.default.close);
|
|
32
|
+
exports.close = close;
|
|
33
|
+
const read = (0, _util.promisify)(_fs.default.read);
|
|
34
|
+
exports.read = read;
|
|
35
|
+
const fstat = (0, _util.promisify)(_fs.default.fstat);
|
|
36
|
+
exports.fstat = fstat;
|
|
37
|
+
const isSupported = Boolean(_fs.default);
|
|
38
|
+
exports.isSupported = isSupported;
|
|
39
|
+
|
|
40
|
+
async function _readToArrayBuffer(fd, start, length) {
|
|
41
|
+
const buffer = Buffer.alloc(length);
|
|
42
|
+
const {
|
|
43
|
+
bytesRead
|
|
44
|
+
} = await read(fd, buffer, 0, length, start);
|
|
45
|
+
|
|
46
|
+
if (bytesRead !== length) {
|
|
47
|
+
throw new Error('fs.read failed');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return (0, _buffer.toArrayBuffer)(buffer);
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=fs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/node/fs.ts"],"names":["readdir","fs","stat","readFile","readFileSync","writeFile","writeFileSync","open","close","read","fstat","isSupported","Boolean","_readToArrayBuffer","fd","start","length","buffer","Buffer","alloc","bytesRead","Error"],"mappings":";;;;;;;;;;AACA;;AACA;;AACA;;AAOO,MAAMA,OAAO,GAAG,qBAAUC,YAAGD,OAAb,CAAhB;;AAEA,MAAME,IAAI,GAAG,qBAAUD,YAAGC,IAAb,CAAb;;AAGA,MAAMC,QAAQ,GAAG,qBAAUF,YAAGE,QAAb,CAAjB;;AAEA,MAAMC,YAAY,GAAGH,YAAGG,YAAxB;;AAEA,MAAMC,SAAS,GAAG,qBAAUJ,YAAGI,SAAb,CAAlB;;AAEA,MAAMC,aAAa,GAAGL,YAAGK,aAAzB;;AAKA,MAAMC,IAAI,GAAG,qBAAUN,YAAGM,IAAb,CAAb;;AAEA,MAAMC,KAAK,GAAG,qBAAUP,YAAGO,KAAb,CAAd;;AAEA,MAAMC,IAAI,GAAG,qBAAUR,YAAGQ,IAAb,CAAb;;AAEA,MAAMC,KAAK,GAAG,qBAAUT,YAAGS,KAAb,CAAd;;AAEA,MAAMC,WAAW,GAAGC,OAAO,CAACX,WAAD,CAA3B;;;AAEA,eAAeY,kBAAf,CAAkCC,EAAlC,EAA8CC,KAA9C,EAA6DC,MAA7D,EAA6E;AAClF,QAAMC,MAAM,GAAGC,MAAM,CAACC,KAAP,CAAaH,MAAb,CAAf;AACA,QAAM;AAACI,IAAAA;AAAD,MAAc,MAAMX,IAAI,CAACK,EAAD,EAAKG,MAAL,EAAa,CAAb,EAAgBD,MAAhB,EAAwBD,KAAxB,CAA9B;;AACA,MAAIK,SAAS,KAAKJ,MAAlB,EAA0B;AACxB,UAAM,IAAIK,KAAJ,CAAU,gBAAV,CAAN;AACD;;AACD,SAAO,2BAAcJ,MAAd,CAAP;AACD","sourcesContent":["// fs wrapper (promisified fs + avoids bundling fs in browsers)\nimport fs from 'fs';\nimport {toArrayBuffer} from './buffer';\nimport {promisify} from './util';\n\nexport type {Stats} from 'fs';\n\n// paths\n\n/** Wrapper for Node.js fs method */\nexport const readdir = promisify(fs.readdir);\n/** Wrapper for Node.js fs method */\nexport const stat = promisify(fs.stat);\n\n/** Wrapper for Node.js fs method */\nexport const readFile = promisify(fs.readFile);\n/** Wrapper for Node.js fs method */\nexport const readFileSync = fs.readFileSync;\n/** Wrapper for Node.js fs method */\nexport const writeFile = promisify(fs.writeFile);\n/** Wrapper for Node.js fs method */\nexport const writeFileSync = fs.writeFileSync;\n\n// file descriptors\n\n/** Wrapper for Node.js fs method */\nexport const open = promisify(fs.open);\n/** Wrapper for Node.js fs method */\nexport const close = promisify(fs.close);\n/** Wrapper for Node.js fs method */\nexport const read = promisify(fs.read);\n/** Wrapper for Node.js fs method */\nexport const fstat = promisify(fs.fstat);\n\nexport const isSupported = Boolean(fs);\n\nexport async function _readToArrayBuffer(fd: number, start: number, length: number) {\n const buffer = Buffer.alloc(length);\n const {bytesRead} = await read(fd, buffer, 0, length, start);\n if (bytesRead !== length) {\n throw new Error('fs.read failed');\n }\n return toArrayBuffer(buffer);\n}\n"],"file":"fs.js"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.promisify = void 0;
|
|
7
|
+
|
|
8
|
+
var util = _interopRequireWildcard(require("util"));
|
|
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
|
+
const promisify = util.promisify;
|
|
15
|
+
exports.promisify = promisify;
|
|
16
|
+
//# sourceMappingURL=util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/node/util.ts"],"names":["promisify","util"],"mappings":";;;;;;;AAAA;;;;;;AAGO,MAAMA,SAAS,GAAGC,IAAI,CAACD,SAAvB","sourcesContent":["import * as util from 'util';\n\n/** Wrapper for Node.js promisify */\nexport const promisify = util.promisify;\n"],"file":"util.js"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.parseJSON = parseJSON;
|
|
7
|
+
|
|
8
|
+
var _getFirstCharacters = require("../binary-utils/get-first-characters");
|
|
9
|
+
|
|
10
|
+
function parseJSON(string) {
|
|
11
|
+
try {
|
|
12
|
+
return JSON.parse(string);
|
|
13
|
+
} catch (_) {
|
|
14
|
+
throw new Error("Failed to parse JSON from data starting with \"".concat((0, _getFirstCharacters.getFirstCharacters)(string), "\""));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=parse-json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/parser-utils/parse-json.ts"],"names":["parseJSON","string","JSON","parse","_","Error"],"mappings":";;;;;;;AAAA;;AAKO,SAASA,SAAT,CAAmBC,MAAnB,EAAwC;AAC7C,MAAI;AACF,WAAOC,IAAI,CAACC,KAAL,CAAWF,MAAX,CAAP;AACD,GAFD,CAEE,OAAOG,CAAP,EAAU;AACV,UAAM,IAAIC,KAAJ,0DAA2D,4CAAmBJ,MAAnB,CAA3D,QAAN;AACD;AACF","sourcesContent":["import {getFirstCharacters} from '../binary-utils/get-first-characters';\n\n/**\n * Minimal JSON parser that throws more meaningful error messages\n */\nexport function parseJSON(string: string): any {\n try {\n return JSON.parse(string);\n } catch (_) {\n throw new Error(`Failed to parse JSON from data starting with \"${getFirstCharacters(string)}\"`);\n }\n}\n"],"file":"parse-json.js"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.setPathPrefix = setPathPrefix;
|
|
7
|
+
exports.getPathPrefix = getPathPrefix;
|
|
8
|
+
exports.addAliases = addAliases;
|
|
9
|
+
exports.resolvePath = resolvePath;
|
|
10
|
+
let pathPrefix = '';
|
|
11
|
+
const fileAliases = {};
|
|
12
|
+
|
|
13
|
+
function setPathPrefix(prefix) {
|
|
14
|
+
pathPrefix = prefix;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function getPathPrefix() {
|
|
18
|
+
return pathPrefix;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function addAliases(aliases) {
|
|
22
|
+
Object.assign(fileAliases, aliases);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function resolvePath(filename) {
|
|
26
|
+
for (const alias in fileAliases) {
|
|
27
|
+
if (filename.startsWith(alias)) {
|
|
28
|
+
const replacement = fileAliases[alias];
|
|
29
|
+
filename = filename.replace(alias, replacement);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (!filename.startsWith('http://') && !filename.startsWith('https://')) {
|
|
34
|
+
filename = "".concat(pathPrefix).concat(filename);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return filename;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=file-aliases.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/path-utils/file-aliases.ts"],"names":["pathPrefix","fileAliases","setPathPrefix","prefix","getPathPrefix","addAliases","aliases","Object","assign","resolvePath","filename","alias","startsWith","replacement","replace"],"mappings":";;;;;;;;;AAEA,IAAIA,UAAU,GAAG,EAAjB;AACA,MAAMC,WAA0C,GAAG,EAAnD;;AAKO,SAASC,aAAT,CAAuBC,MAAvB,EAA6C;AAClDH,EAAAA,UAAU,GAAGG,MAAb;AACD;;AAKM,SAASC,aAAT,GAAiC;AACtC,SAAOJ,UAAP;AACD;;AASM,SAASK,UAAT,CAAoBC,OAApB,EAAkE;AACvEC,EAAAA,MAAM,CAACC,MAAP,CAAcP,WAAd,EAA2BK,OAA3B;AACD;;AAKM,SAASG,WAAT,CAAqBC,QAArB,EAA+C;AACpD,OAAK,MAAMC,KAAX,IAAoBV,WAApB,EAAiC;AAC/B,QAAIS,QAAQ,CAACE,UAAT,CAAoBD,KAApB,CAAJ,EAAgC;AAC9B,YAAME,WAAW,GAAGZ,WAAW,CAACU,KAAD,CAA/B;AACAD,MAAAA,QAAQ,GAAGA,QAAQ,CAACI,OAAT,CAAiBH,KAAjB,EAAwBE,WAAxB,CAAX;AACD;AACF;;AACD,MAAI,CAACH,QAAQ,CAACE,UAAT,CAAoB,SAApB,CAAD,IAAmC,CAACF,QAAQ,CAACE,UAAT,CAAoB,UAApB,CAAxC,EAAyE;AACvEF,IAAAA,QAAQ,aAAMV,UAAN,SAAmBU,QAAnB,CAAR;AACD;;AACD,SAAOA,QAAP;AACD","sourcesContent":["// Simple file alias mechanisms for tests.\n\nlet pathPrefix = '';\nconst fileAliases: {[aliasPath: string]: string} = {};\n\n/*\n * Set a relative path prefix\n */\nexport function setPathPrefix(prefix: string): void {\n pathPrefix = prefix;\n}\n\n/*\n * Get the relative path prefix\n */\nexport function getPathPrefix(): string {\n return pathPrefix;\n}\n\n/**\n *\n * @param aliases\n *\n * Note: addAliases are an experimental export, they are only for testing of loaders.gl loaders\n * not intended as a generic aliasing mechanism\n */\nexport function addAliases(aliases: {[aliasPath: string]: string}): void {\n Object.assign(fileAliases, aliases);\n}\n\n/**\n * Resolves aliases and adds path-prefix to paths\n */\nexport function resolvePath(filename: string): string {\n for (const alias in fileAliases) {\n if (filename.startsWith(alias)) {\n const replacement = fileAliases[alias];\n filename = filename.replace(alias, replacement);\n }\n }\n if (!filename.startsWith('http://') && !filename.startsWith('https://')) {\n filename = `${pathPrefix}${filename}`;\n }\n return filename;\n}\n"],"file":"file-aliases.js"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.filename = filename;
|
|
7
|
+
exports.dirname = dirname;
|
|
8
|
+
exports.join = join;
|
|
9
|
+
|
|
10
|
+
function filename(url) {
|
|
11
|
+
const slashIndex = url && url.lastIndexOf('/');
|
|
12
|
+
return slashIndex >= 0 ? url.substr(slashIndex + 1) : '';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function dirname(url) {
|
|
16
|
+
const slashIndex = url && url.lastIndexOf('/');
|
|
17
|
+
return slashIndex >= 0 ? url.substr(0, slashIndex) : '';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function join(...parts) {
|
|
21
|
+
const separator = '/';
|
|
22
|
+
parts = parts.map((part, index) => {
|
|
23
|
+
if (index) {
|
|
24
|
+
part = part.replace(new RegExp("^".concat(separator)), '');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (index !== parts.length - 1) {
|
|
28
|
+
part = part.replace(new RegExp("".concat(separator, "$")), '');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return part;
|
|
32
|
+
});
|
|
33
|
+
return parts.join(separator);
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,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;;AAMM,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;;AAMM,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,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"}
|