@loaders.gl/loader-utils 4.0.0-alpha.4 → 4.0.0-alpha.6
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 +328 -0
- package/dist/es5/index.js.map +1 -0
- package/dist/es5/json-loader.js +44 -0
- package/dist/es5/json-loader.js.map +1 -0
- package/dist/es5/lib/binary-utils/array-buffer-utils.js +80 -0
- package/dist/es5/lib/binary-utils/array-buffer-utils.js.map +1 -0
- package/dist/es5/lib/binary-utils/dataview-copy-utils.js +58 -0
- package/dist/es5/lib/binary-utils/dataview-copy-utils.js.map +1 -0
- package/dist/es5/lib/binary-utils/get-first-characters.js +31 -0
- package/dist/es5/lib/binary-utils/get-first-characters.js.map +1 -0
- package/dist/es5/lib/binary-utils/memory-conversion-utils.js +44 -0
- package/dist/es5/lib/binary-utils/memory-conversion-utils.js.map +1 -0
- package/dist/es5/lib/binary-utils/memory-copy-utils.js +34 -0
- package/dist/es5/lib/binary-utils/memory-copy-utils.js.map +1 -0
- package/dist/es5/lib/env-utils/assert.js +12 -0
- package/dist/es5/lib/env-utils/assert.js.map +1 -0
- package/dist/es5/lib/env-utils/globals.js +30 -0
- package/dist/es5/lib/env-utils/globals.js.map +1 -0
- package/dist/es5/lib/filesystems/node-filesystem.js +210 -0
- package/dist/es5/lib/filesystems/node-filesystem.js.map +1 -0
- package/dist/es5/lib/filesystems/readable-file.js +91 -0
- package/dist/es5/lib/filesystems/readable-file.js.map +1 -0
- package/dist/es5/lib/filesystems/writable-file.js +82 -0
- package/dist/es5/lib/filesystems/writable-file.js.map +1 -0
- package/dist/es5/lib/iterators/async-iteration.js +190 -0
- package/dist/es5/lib/iterators/async-iteration.js.map +1 -0
- package/dist/es5/lib/iterators/text-iterators.js +305 -0
- package/dist/es5/lib/iterators/text-iterators.js.map +1 -0
- package/dist/es5/lib/node/buffer.browser.js +14 -0
- package/dist/es5/lib/node/buffer.browser.js.map +1 -0
- package/dist/es5/lib/node/buffer.js +27 -0
- package/dist/es5/lib/node/buffer.js.map +1 -0
- package/dist/es5/lib/node/fs.js +88 -0
- package/dist/es5/lib/node/fs.js.map +1 -0
- package/dist/es5/lib/node/promisify.js +36 -0
- package/dist/es5/lib/node/promisify.js.map +1 -0
- package/dist/es5/lib/node/stream.js +16 -0
- package/dist/es5/lib/node/stream.js.map +1 -0
- package/dist/es5/lib/option-utils/merge-loader-options.js +30 -0
- package/dist/es5/lib/option-utils/merge-loader-options.js.map +1 -0
- package/dist/es5/lib/parser-utils/parse-json.js +15 -0
- package/dist/es5/lib/parser-utils/parse-json.js.map +1 -0
- package/dist/es5/lib/path-utils/file-aliases.js +33 -0
- package/dist/es5/lib/path-utils/file-aliases.js.map +1 -0
- package/dist/es5/lib/path-utils/get-cwd.js +15 -0
- package/dist/es5/lib/path-utils/get-cwd.js.map +1 -0
- package/dist/es5/lib/path-utils/path.js +136 -0
- package/dist/es5/lib/path-utils/path.js.map +1 -0
- package/dist/es5/lib/request-utils/request-scheduler.js +150 -0
- package/dist/es5/lib/request-utils/request-scheduler.js.map +1 -0
- package/dist/es5/lib/worker-loader-utils/create-loader-worker.js +142 -0
- package/dist/es5/lib/worker-loader-utils/create-loader-worker.js.map +1 -0
- package/dist/es5/lib/worker-loader-utils/encode-with-worker.js +18 -0
- package/dist/es5/lib/worker-loader-utils/encode-with-worker.js.map +1 -0
- package/dist/es5/lib/worker-loader-utils/parse-with-worker.js +115 -0
- package/dist/es5/lib/worker-loader-utils/parse-with-worker.js.map +1 -0
- package/dist/es5/types.js +2 -0
- package/dist/es5/types.js.map +1 -0
- package/dist/es5/workers/json-worker.js +6 -0
- package/dist/es5/workers/json-worker.js.map +1 -0
- package/dist/esm/index.js +29 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/json-loader.js +18 -0
- package/dist/esm/json-loader.js.map +1 -0
- package/dist/esm/lib/binary-utils/array-buffer-utils.js +52 -0
- package/dist/esm/lib/binary-utils/array-buffer-utils.js.map +1 -0
- package/dist/{lib/binary-utils/binary-copy-utils.js → esm/lib/binary-utils/dataview-copy-utils.js} +27 -4
- package/dist/esm/lib/binary-utils/dataview-copy-utils.js.map +1 -0
- package/dist/esm/lib/binary-utils/get-first-characters.js +24 -0
- package/dist/esm/lib/binary-utils/get-first-characters.js.map +1 -0
- package/dist/esm/lib/binary-utils/memory-conversion-utils.js +31 -0
- package/dist/esm/lib/binary-utils/memory-conversion-utils.js.map +1 -0
- package/dist/esm/lib/binary-utils/memory-copy-utils.js +26 -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 +53 -0
- package/dist/esm/lib/filesystems/node-filesystem.js.map +1 -0
- package/dist/esm/lib/filesystems/readable-file.js +20 -0
- package/dist/esm/lib/filesystems/readable-file.js.map +1 -0
- package/dist/esm/lib/filesystems/writable-file.js +20 -0
- package/dist/esm/lib/filesystems/writable-file.js.map +1 -0
- package/dist/esm/lib/iterators/async-iteration.js +32 -0
- package/dist/esm/lib/iterators/async-iteration.js.map +1 -0
- package/dist/esm/lib/iterators/text-iterators.js +47 -0
- package/dist/esm/lib/iterators/text-iterators.js.map +1 -0
- package/dist/esm/lib/node/buffer.browser.js +7 -0
- package/dist/esm/lib/node/buffer.browser.js.map +1 -0
- package/dist/esm/lib/node/buffer.js +20 -0
- package/dist/esm/lib/node/buffer.js.map +1 -0
- package/dist/esm/lib/node/fs.js +40 -0
- package/dist/esm/lib/node/fs.js.map +1 -0
- package/dist/esm/lib/node/promisify.js +10 -0
- package/dist/esm/lib/node/promisify.js.map +1 -0
- package/dist/esm/lib/node/stream.js +7 -0
- package/dist/esm/lib/node/stream.js.map +1 -0
- package/dist/esm/lib/option-utils/merge-loader-options.js +17 -0
- package/dist/esm/lib/option-utils/merge-loader-options.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 +24 -0
- package/dist/esm/lib/path-utils/file-aliases.js.map +1 -0
- package/dist/esm/lib/path-utils/get-cwd.js +9 -0
- package/dist/esm/lib/path-utils/get-cwd.js.map +1 -0
- package/dist/esm/lib/path-utils/path.js +127 -0
- package/dist/esm/lib/path-utils/path.js.map +1 -0
- package/dist/esm/lib/request-utils/request-scheduler.js +120 -0
- package/dist/esm/lib/request-utils/request-scheduler.js.map +1 -0
- package/dist/esm/lib/worker-loader-utils/create-loader-worker.js +95 -0
- package/dist/esm/lib/worker-loader-utils/create-loader-worker.js.map +1 -0
- package/dist/esm/lib/worker-loader-utils/encode-with-worker.js +12 -0
- package/dist/esm/lib/worker-loader-utils/encode-with-worker.js.map +1 -0
- package/dist/esm/lib/worker-loader-utils/parse-with-worker.js +63 -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 +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +122 -26
- package/dist/json-loader.d.ts +9 -0
- package/dist/json-loader.d.ts.map +1 -0
- package/dist/json-loader.js +24 -18
- package/dist/lib/binary-utils/array-buffer-utils.d.ts +27 -0
- package/dist/lib/binary-utils/array-buffer-utils.d.ts.map +1 -0
- package/dist/lib/binary-utils/array-buffer-utils.js +78 -80
- package/dist/lib/binary-utils/dataview-copy-utils.d.ts +43 -0
- package/dist/lib/binary-utils/dataview-copy-utils.d.ts.map +1 -0
- package/dist/lib/binary-utils/dataview-copy-utils.js +97 -0
- package/dist/lib/binary-utils/get-first-characters.d.ts +17 -0
- package/dist/lib/binary-utils/get-first-characters.d.ts.map +1 -0
- package/dist/lib/binary-utils/get-first-characters.js +43 -25
- package/dist/lib/binary-utils/memory-conversion-utils.d.ts +15 -0
- package/dist/lib/binary-utils/memory-conversion-utils.d.ts.map +1 -0
- package/dist/lib/binary-utils/memory-conversion-utils.js +73 -0
- 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 +39 -0
- package/dist/lib/filesystems/node-filesystem.d.ts.map +1 -0
- package/dist/lib/filesystems/node-filesystem.js +72 -59
- package/dist/lib/filesystems/readable-file.d.ts +10 -0
- package/dist/lib/filesystems/readable-file.d.ts.map +1 -0
- package/dist/lib/filesystems/readable-file.js +25 -0
- package/dist/lib/filesystems/writable-file.d.ts +18 -0
- package/dist/lib/filesystems/writable-file.d.ts.map +1 -0
- package/dist/lib/filesystems/writable-file.js +48 -0
- 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.browser.d.ts +12 -0
- package/dist/lib/node/buffer.browser.d.ts.map +1 -0
- package/dist/lib/node/buffer.browser.js +22 -0
- package/dist/lib/node/buffer.d.ts +12 -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 +25 -0
- package/dist/lib/node/fs.d.ts.map +1 -0
- package/dist/lib/node/fs.js +48 -26
- package/dist/lib/node/promisify.d.ts +13 -0
- package/dist/lib/node/promisify.d.ts.map +1 -0
- package/dist/lib/node/promisify.js +22 -0
- package/dist/lib/node/stream.d.ts +4 -0
- package/dist/lib/node/stream.d.ts.map +1 -0
- package/dist/lib/node/stream.js +17 -0
- package/dist/lib/option-utils/merge-loader-options.d.ts +9 -0
- package/dist/lib/option-utils/merge-loader-options.d.ts.map +1 -0
- package/dist/lib/option-utils/merge-loader-options.js +27 -0
- 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/get-cwd.d.ts +2 -0
- package/dist/lib/path-utils/get-cwd.d.ts.map +1 -0
- package/dist/lib/path-utils/get-cwd.js +12 -0
- package/dist/lib/path-utils/path.d.ts +24 -0
- package/dist/lib/path-utils/path.d.ts.map +1 -0
- package/dist/lib/path-utils/path.js +173 -19
- 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 +92 -96
- package/dist/lib/worker-loader-utils/encode-with-worker.d.ts +8 -0
- package/dist/lib/worker-loader-utils/encode-with-worker.d.ts.map +1 -0
- package/dist/lib/worker-loader-utils/encode-with-worker.js +21 -0
- 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 +77 -60
- package/dist/types.d.ts +220 -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 +14 -24
- package/src/index.ts +32 -18
- package/src/json-loader.ts +5 -4
- package/src/lib/binary-utils/array-buffer-utils.ts +4 -40
- package/src/lib/binary-utils/{binary-copy-utils.ts → dataview-copy-utils.ts} +57 -5
- package/src/lib/binary-utils/get-first-characters.ts +17 -1
- package/src/lib/binary-utils/memory-conversion-utils.ts +53 -0
- package/src/lib/filesystems/readable-file.ts +30 -0
- package/src/lib/filesystems/writable-file.ts +44 -0
- package/src/lib/node/buffer.browser.ts +20 -0
- package/src/lib/node/buffer.ts +12 -11
- package/src/lib/node/fs.ts +51 -16
- package/src/lib/node/promisify.ts +70 -0
- package/src/lib/node/stream.ts +18 -0
- package/src/lib/option-utils/merge-loader-options.ts +35 -0
- package/src/lib/path-utils/get-cwd.ts +9 -0
- package/src/lib/path-utils/path.ts +138 -4
- package/src/lib/worker-loader-utils/create-loader-worker.ts +3 -2
- package/src/lib/worker-loader-utils/encode-with-worker.ts +21 -0
- package/src/lib/worker-loader-utils/parse-with-worker.ts +16 -3
- package/src/types.ts +156 -93
- 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 +0 -16
- package/dist/lib/binary-utils/buffer-utils.js.map +0 -1
- package/dist/lib/binary-utils/encode-utils.js +0 -31
- 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 +0 -3
- 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/types.js.map +0 -1
- package/dist/workers/json-worker.js.map +0 -1
- package/src/lib/binary-utils/buffer-utils.ts +0 -28
- package/src/lib/binary-utils/encode-utils.ts +0 -32
- package/src/lib/node/util.ts +0 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-json.d.ts","sourceRoot":"","sources":["../../../src/lib/parser-utils/parse-json.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAM7C"}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseJSON = void 0;
|
|
4
|
+
const get_first_characters_1 = require("../binary-utils/get-first-characters");
|
|
5
|
+
/**
|
|
6
|
+
* Minimal JSON parser that throws more meaningful error messages
|
|
7
|
+
*/
|
|
8
|
+
function parseJSON(string) {
|
|
9
|
+
try {
|
|
10
|
+
return JSON.parse(string);
|
|
11
|
+
}
|
|
12
|
+
catch (_) {
|
|
13
|
+
throw new Error(`Failed to parse JSON from data starting with "${(0, get_first_characters_1.getFirstCharacters)(string)}"`);
|
|
14
|
+
}
|
|
8
15
|
}
|
|
9
|
-
|
|
16
|
+
exports.parseJSON = parseJSON;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare function setPathPrefix(prefix: string): void;
|
|
2
|
+
export declare function getPathPrefix(): string;
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param aliases
|
|
6
|
+
*
|
|
7
|
+
* Note: addAliases are an experimental export, they are only for testing of loaders.gl loaders
|
|
8
|
+
* not intended as a generic aliasing mechanism
|
|
9
|
+
*/
|
|
10
|
+
export declare function addAliases(aliases: {
|
|
11
|
+
[aliasPath: string]: string;
|
|
12
|
+
}): void;
|
|
13
|
+
/**
|
|
14
|
+
* Resolves aliases and adds path-prefix to paths
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolvePath(filename: string): string;
|
|
17
|
+
//# sourceMappingURL=file-aliases.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-aliases.d.ts","sourceRoot":"","sources":["../../../src/lib/path-utils/file-aliases.ts"],"names":[],"mappings":"AAQA,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAElD;AAKD,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE;IAAC,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAA;CAAC,GAAG,IAAI,CAEvE;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAWpD"}
|
|
@@ -1,26 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Simple file alias mechanisms for tests.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.resolvePath = exports.addAliases = exports.getPathPrefix = exports.setPathPrefix = void 0;
|
|
1
5
|
let pathPrefix = '';
|
|
2
6
|
const fileAliases = {};
|
|
3
|
-
|
|
4
|
-
|
|
7
|
+
/*
|
|
8
|
+
* Set a relative path prefix
|
|
9
|
+
*/
|
|
10
|
+
function setPathPrefix(prefix) {
|
|
11
|
+
pathPrefix = prefix;
|
|
5
12
|
}
|
|
6
|
-
|
|
7
|
-
|
|
13
|
+
exports.setPathPrefix = setPathPrefix;
|
|
14
|
+
/*
|
|
15
|
+
* Get the relative path prefix
|
|
16
|
+
*/
|
|
17
|
+
function getPathPrefix() {
|
|
18
|
+
return pathPrefix;
|
|
8
19
|
}
|
|
9
|
-
|
|
10
|
-
|
|
20
|
+
exports.getPathPrefix = getPathPrefix;
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @param aliases
|
|
24
|
+
*
|
|
25
|
+
* Note: addAliases are an experimental export, they are only for testing of loaders.gl loaders
|
|
26
|
+
* not intended as a generic aliasing mechanism
|
|
27
|
+
*/
|
|
28
|
+
function addAliases(aliases) {
|
|
29
|
+
Object.assign(fileAliases, aliases);
|
|
11
30
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
31
|
+
exports.addAliases = addAliases;
|
|
32
|
+
/**
|
|
33
|
+
* Resolves aliases and adds path-prefix to paths
|
|
34
|
+
*/
|
|
35
|
+
function resolvePath(filename) {
|
|
36
|
+
for (const alias in fileAliases) {
|
|
37
|
+
if (filename.startsWith(alias)) {
|
|
38
|
+
const replacement = fileAliases[alias];
|
|
39
|
+
filename = filename.replace(alias, replacement);
|
|
40
|
+
}
|
|
17
41
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return filename;
|
|
42
|
+
if (!filename.startsWith('http://') && !filename.startsWith('https://')) {
|
|
43
|
+
filename = `${pathPrefix}${filename}`;
|
|
44
|
+
}
|
|
45
|
+
return filename;
|
|
25
46
|
}
|
|
26
|
-
|
|
47
|
+
exports.resolvePath = resolvePath;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-cwd.d.ts","sourceRoot":"","sources":["../../../src/lib/path-utils/get-cwd.ts"],"names":[],"mappings":"AAEA,wBAAgB,MAAM,WAMrB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// loaders.gl MIT license
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.getCWD = void 0;
|
|
5
|
+
function getCWD() {
|
|
6
|
+
if (typeof process !== 'undefined' && typeof process.cwd !== 'undefined') {
|
|
7
|
+
return process.cwd();
|
|
8
|
+
}
|
|
9
|
+
const pathname = window.location?.pathname;
|
|
10
|
+
return pathname?.slice(0, pathname.lastIndexOf('/') + 1) || '';
|
|
11
|
+
}
|
|
12
|
+
exports.getCWD = getCWD;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Replacement for Node.js path.filename
|
|
3
|
+
* @param url
|
|
4
|
+
*/
|
|
5
|
+
export declare function filename(url: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Replacement for Node.js path.dirname
|
|
8
|
+
* @param url
|
|
9
|
+
*/
|
|
10
|
+
export declare function dirname(url: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Replacement for Node.js path.join
|
|
13
|
+
* @param parts
|
|
14
|
+
*/
|
|
15
|
+
export declare function join(...parts: string[]): string;
|
|
16
|
+
/**
|
|
17
|
+
* https://nodejs.org/api/path.html#path_path_resolve_paths
|
|
18
|
+
* @param paths A sequence of paths or path segments.
|
|
19
|
+
* @return resolved path
|
|
20
|
+
* Forked from BTOdell/path-resolve under MIT license
|
|
21
|
+
* @see https://github.com/BTOdell/path-resolve/blob/master/LICENSE
|
|
22
|
+
*/
|
|
23
|
+
export declare function resolve(...components: string[]): string;
|
|
24
|
+
//# sourceMappingURL=path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../src/lib/path-utils/path.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG5C;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG3C;AAED;;;GAGG;AACH,wBAAgB,IAAI,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAY/C;AAID;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,GAAG,UAAU,EAAE,MAAM,EAAE,GAAG,MAAM,CAmCvD"}
|
|
@@ -1,24 +1,178 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// Beginning of a minimal implementation of the Node.js path API, that doesn't pull in big polyfills.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.resolve = exports.join = exports.dirname = exports.filename = void 0;
|
|
5
|
+
const get_cwd_1 = require("./get-cwd");
|
|
6
|
+
/**
|
|
7
|
+
* Replacement for Node.js path.filename
|
|
8
|
+
* @param url
|
|
9
|
+
*/
|
|
10
|
+
function filename(url) {
|
|
11
|
+
const slashIndex = url ? url.lastIndexOf('/') : -1;
|
|
12
|
+
return slashIndex >= 0 ? url.substr(slashIndex + 1) : '';
|
|
4
13
|
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
14
|
+
exports.filename = filename;
|
|
15
|
+
/**
|
|
16
|
+
* Replacement for Node.js path.dirname
|
|
17
|
+
* @param url
|
|
18
|
+
*/
|
|
19
|
+
function dirname(url) {
|
|
20
|
+
const slashIndex = url ? url.lastIndexOf('/') : -1;
|
|
21
|
+
return slashIndex >= 0 ? url.substr(0, slashIndex) : '';
|
|
8
22
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
23
|
+
exports.dirname = dirname;
|
|
24
|
+
/**
|
|
25
|
+
* Replacement for Node.js path.join
|
|
26
|
+
* @param parts
|
|
27
|
+
*/
|
|
28
|
+
function join(...parts) {
|
|
29
|
+
const separator = '/';
|
|
30
|
+
parts = parts.map((part, index) => {
|
|
31
|
+
if (index) {
|
|
32
|
+
part = part.replace(new RegExp(`^${separator}`), '');
|
|
33
|
+
}
|
|
34
|
+
if (index !== parts.length - 1) {
|
|
35
|
+
part = part.replace(new RegExp(`${separator}$`), '');
|
|
36
|
+
}
|
|
37
|
+
return part;
|
|
38
|
+
});
|
|
39
|
+
return parts.join(separator);
|
|
40
|
+
}
|
|
41
|
+
exports.join = join;
|
|
42
|
+
/* eslint-disable no-continue */
|
|
43
|
+
/**
|
|
44
|
+
* https://nodejs.org/api/path.html#path_path_resolve_paths
|
|
45
|
+
* @param paths A sequence of paths or path segments.
|
|
46
|
+
* @return resolved path
|
|
47
|
+
* Forked from BTOdell/path-resolve under MIT license
|
|
48
|
+
* @see https://github.com/BTOdell/path-resolve/blob/master/LICENSE
|
|
49
|
+
*/
|
|
50
|
+
function resolve(...components) {
|
|
51
|
+
const paths = [];
|
|
52
|
+
for (let _i = 0; _i < components.length; _i++) {
|
|
53
|
+
paths[_i] = components[_i];
|
|
54
|
+
}
|
|
55
|
+
let resolvedPath = '';
|
|
56
|
+
let resolvedAbsolute = false;
|
|
57
|
+
let cwd;
|
|
58
|
+
for (let i = paths.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
|
59
|
+
let path;
|
|
60
|
+
if (i >= 0) {
|
|
61
|
+
path = paths[i];
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
if (cwd === undefined) {
|
|
65
|
+
cwd = (0, get_cwd_1.getCWD)();
|
|
66
|
+
}
|
|
67
|
+
path = cwd;
|
|
68
|
+
}
|
|
69
|
+
// Skip empty entries
|
|
70
|
+
if (path.length === 0) {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
resolvedPath = `${path}/${resolvedPath}`;
|
|
74
|
+
resolvedAbsolute = path.charCodeAt(0) === SLASH;
|
|
75
|
+
}
|
|
76
|
+
// At this point the path should be resolved to a full absolute path, but
|
|
77
|
+
// handle relative paths to be safe (might happen when process.cwd() fails)
|
|
78
|
+
// Normalize the path (removes leading slash)
|
|
79
|
+
resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute);
|
|
80
|
+
if (resolvedAbsolute) {
|
|
81
|
+
return `/${resolvedPath}`;
|
|
14
82
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
83
|
+
else if (resolvedPath.length > 0) {
|
|
84
|
+
return resolvedPath;
|
|
85
|
+
}
|
|
86
|
+
return '.';
|
|
87
|
+
}
|
|
88
|
+
exports.resolve = resolve;
|
|
89
|
+
const SLASH = 47;
|
|
90
|
+
const DOT = 46;
|
|
91
|
+
/**
|
|
92
|
+
* Resolves . and .. elements in a path with directory names
|
|
93
|
+
* Forked from BTOdell/path-resolve under MIT license
|
|
94
|
+
* @see https://github.com/BTOdell/path-resolve/blob/master/LICENSE
|
|
95
|
+
*/
|
|
96
|
+
/* eslint-disable max-depth */
|
|
97
|
+
// eslint-disable-next-line complexity, max-statements
|
|
98
|
+
function normalizeStringPosix(path, allowAboveRoot) {
|
|
99
|
+
let res = '';
|
|
100
|
+
let lastSlash = -1;
|
|
101
|
+
let dots = 0;
|
|
102
|
+
let code;
|
|
103
|
+
let isAboveRoot = false;
|
|
104
|
+
for (let i = 0; i <= path.length; ++i) {
|
|
105
|
+
if (i < path.length) {
|
|
106
|
+
code = path.charCodeAt(i);
|
|
107
|
+
}
|
|
108
|
+
else if (code === SLASH) {
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
code = SLASH;
|
|
113
|
+
}
|
|
114
|
+
if (code === SLASH) {
|
|
115
|
+
if (lastSlash === i - 1 || dots === 1) {
|
|
116
|
+
// NOOP
|
|
117
|
+
}
|
|
118
|
+
else if (lastSlash !== i - 1 && dots === 2) {
|
|
119
|
+
if (res.length < 2 ||
|
|
120
|
+
!isAboveRoot ||
|
|
121
|
+
res.charCodeAt(res.length - 1) !== DOT ||
|
|
122
|
+
res.charCodeAt(res.length - 2) !== DOT) {
|
|
123
|
+
if (res.length > 2) {
|
|
124
|
+
const start = res.length - 1;
|
|
125
|
+
let j = start;
|
|
126
|
+
for (; j >= 0; --j) {
|
|
127
|
+
if (res.charCodeAt(j) === SLASH) {
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (j !== start) {
|
|
132
|
+
res = j === -1 ? '' : res.slice(0, j);
|
|
133
|
+
lastSlash = i;
|
|
134
|
+
dots = 0;
|
|
135
|
+
isAboveRoot = false;
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
else if (res.length === 2 || res.length === 1) {
|
|
140
|
+
res = '';
|
|
141
|
+
lastSlash = i;
|
|
142
|
+
dots = 0;
|
|
143
|
+
isAboveRoot = false;
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (allowAboveRoot) {
|
|
148
|
+
if (res.length > 0) {
|
|
149
|
+
res += '/..';
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
res = '..';
|
|
153
|
+
}
|
|
154
|
+
isAboveRoot = true;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
const slice = path.slice(lastSlash + 1, i);
|
|
159
|
+
if (res.length > 0) {
|
|
160
|
+
res += `/${slice}`;
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
res = slice;
|
|
164
|
+
}
|
|
165
|
+
isAboveRoot = false;
|
|
166
|
+
}
|
|
167
|
+
lastSlash = i;
|
|
168
|
+
dots = 0;
|
|
169
|
+
}
|
|
170
|
+
else if (code === DOT && dots !== -1) {
|
|
171
|
+
++dots;
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
dots = -1;
|
|
175
|
+
}
|
|
18
176
|
}
|
|
19
|
-
|
|
20
|
-
return part;
|
|
21
|
-
});
|
|
22
|
-
return parts.join(separator);
|
|
177
|
+
return res;
|
|
23
178
|
}
|
|
24
|
-
//# sourceMappingURL=path.js.map
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Stats } from '@probe.gl/stats';
|
|
2
|
+
type Handle = any;
|
|
3
|
+
type DoneFunction = () => any;
|
|
4
|
+
type GetPriorityFunction = () => number;
|
|
5
|
+
type RequestResult = {
|
|
6
|
+
done: DoneFunction;
|
|
7
|
+
} | null;
|
|
8
|
+
/** RequestScheduler Options */
|
|
9
|
+
export type RequestSchedulerProps = {
|
|
10
|
+
id?: string;
|
|
11
|
+
throttleRequests?: boolean;
|
|
12
|
+
maxRequests?: number;
|
|
13
|
+
};
|
|
14
|
+
/** Tracks one request */
|
|
15
|
+
type Request = {
|
|
16
|
+
handle: Handle;
|
|
17
|
+
priority: number;
|
|
18
|
+
getPriority: GetPriorityFunction;
|
|
19
|
+
resolve?: (value: any) => any;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Used to issue a request, without having them "deeply queued" by the browser.
|
|
23
|
+
* @todo - Track requests globally, across multiple servers
|
|
24
|
+
*/
|
|
25
|
+
export default class RequestScheduler {
|
|
26
|
+
readonly props: Required<RequestSchedulerProps>;
|
|
27
|
+
readonly stats: Stats;
|
|
28
|
+
activeRequestCount: number;
|
|
29
|
+
/** Tracks the number of active requests and prioritizes/cancels queued requests. */
|
|
30
|
+
private requestQueue;
|
|
31
|
+
private requestMap;
|
|
32
|
+
private deferredUpdate;
|
|
33
|
+
constructor(props?: RequestSchedulerProps);
|
|
34
|
+
/**
|
|
35
|
+
* Called by an application that wants to issue a request, without having it deeply queued by the browser
|
|
36
|
+
*
|
|
37
|
+
* When the returned promise resolved, it is OK for the application to issue a request.
|
|
38
|
+
* The promise resolves to an object that contains a `done` method.
|
|
39
|
+
* When the application's request has completed (or failed), the application must call the `done` function
|
|
40
|
+
*
|
|
41
|
+
* @param handle
|
|
42
|
+
* @param getPriority will be called when request "slots" open up,
|
|
43
|
+
* allowing the caller to update priority or cancel the request
|
|
44
|
+
* Highest priority executes first, priority < 0 cancels the request
|
|
45
|
+
* @returns a promise
|
|
46
|
+
* - resolves to a object (with a `done` field) when the request can be issued without queueing,
|
|
47
|
+
* - resolves to `null` if the request has been cancelled (by the callback return < 0).
|
|
48
|
+
* In this case the application should not issue the request
|
|
49
|
+
*/
|
|
50
|
+
scheduleRequest(handle: Handle, getPriority?: GetPriorityFunction): Promise<RequestResult>;
|
|
51
|
+
_issueRequest(request: Request): Promise<any>;
|
|
52
|
+
/** We check requests asynchronously, to prevent multiple updates */
|
|
53
|
+
_issueNewRequests(): void;
|
|
54
|
+
/** Refresh all requests */
|
|
55
|
+
_issueNewRequestsAsync(): void;
|
|
56
|
+
/** Ensure all requests have updated priorities, and that no longer valid requests are cancelled */
|
|
57
|
+
_updateAllRequests(): void;
|
|
58
|
+
/** Update a single request by calling the callback */
|
|
59
|
+
_updateRequest(request: any): boolean;
|
|
60
|
+
}
|
|
61
|
+
export {};
|
|
62
|
+
//# sourceMappingURL=request-scheduler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-scheduler.d.ts","sourceRoot":"","sources":["../../../src/lib/request-utils/request-scheduler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,iBAAiB,CAAC;AAEtC,KAAK,MAAM,GAAG,GAAG,CAAC;AAClB,KAAK,YAAY,GAAG,MAAM,GAAG,CAAC;AAC9B,KAAK,mBAAmB,GAAG,MAAM,MAAM,CAAC;AACxC,KAAK,aAAa,GAAG;IACnB,IAAI,EAAE,YAAY,CAAC;CACpB,GAAG,IAAI,CAAC;AAET,+BAA+B;AAC/B,MAAM,MAAM,qBAAqB,GAAG;IAClC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAgBF,yBAAyB;AACzB,KAAK,OAAO,GAAG;IACb,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,mBAAmB,CAAC;IACjC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC;CAC/B,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,gBAAgB;IACnC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,qBAAqB,CAAC,CAAC;IAChD,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,kBAAkB,EAAE,MAAM,CAAK;IAE/B,oFAAoF;IACpF,OAAO,CAAC,YAAY,CAAiB;IACrC,OAAO,CAAC,UAAU,CAAkD;IACpE,OAAO,CAAC,cAAc,CAAa;gBAEvB,KAAK,GAAE,qBAA0B;IAY7C;;;;;;;;;;;;;;;OAeG;IACH,eAAe,CACb,MAAM,EAAE,MAAM,EACd,WAAW,GAAE,mBAA6B,GACzC,OAAO,CAAC,aAAa,CAAC;IA0BzB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC;IAuB7C,oEAAoE;IACpE,iBAAiB,IAAI,IAAI;IAMzB,4BAA4B;IAC5B,sBAAsB;IAwBtB,mGAAmG;IACnG,kBAAkB;IAgBlB,sDAAsD;IACtD,cAAc,CAAC,OAAO,KAAA;CAUvB"}
|