@loaders.gl/loader-utils 3.4.0-alpha.2 → 3.4.0-alpha.3
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.map +1 -1
- package/dist/es5/json-loader.js +7 -11
- package/dist/es5/json-loader.js.map +1 -1
- package/dist/es5/lib/binary-utils/array-buffer-utils.js +1 -8
- package/dist/es5/lib/binary-utils/array-buffer-utils.js.map +1 -1
- package/dist/es5/lib/binary-utils/dataview-copy-utils.js +0 -5
- package/dist/es5/lib/binary-utils/dataview-copy-utils.js.map +1 -1
- package/dist/es5/lib/binary-utils/get-first-characters.js +0 -2
- package/dist/es5/lib/binary-utils/get-first-characters.js.map +1 -1
- package/dist/es5/lib/binary-utils/memory-conversion-utils.js +0 -5
- package/dist/es5/lib/binary-utils/memory-conversion-utils.js.map +1 -1
- package/dist/es5/lib/binary-utils/memory-copy-utils.js +0 -3
- package/dist/es5/lib/binary-utils/memory-copy-utils.js.map +1 -1
- package/dist/es5/lib/env-utils/assert.js.map +1 -1
- package/dist/es5/lib/env-utils/globals.js +1 -5
- package/dist/es5/lib/env-utils/globals.js.map +1 -1
- package/dist/es5/lib/filesystems/node-filesystem.js +86 -100
- package/dist/es5/lib/filesystems/node-filesystem.js.map +1 -1
- package/dist/es5/lib/filesystems/readable-file.js +24 -33
- package/dist/es5/lib/filesystems/readable-file.js.map +1 -1
- package/dist/es5/lib/filesystems/writable-file.js +18 -25
- package/dist/es5/lib/filesystems/writable-file.js.map +1 -1
- package/dist/es5/lib/iterators/async-iteration.js +134 -140
- package/dist/es5/lib/iterators/async-iteration.js.map +1 -1
- package/dist/es5/lib/iterators/text-iterators.js +207 -221
- package/dist/es5/lib/iterators/text-iterators.js.map +1 -1
- package/dist/es5/lib/node/buffer.browser.js +0 -2
- package/dist/es5/lib/node/buffer.browser.js.map +1 -1
- package/dist/es5/lib/node/buffer.js +0 -2
- package/dist/es5/lib/node/buffer.js.map +1 -1
- package/dist/es5/lib/node/fs.js +19 -30
- package/dist/es5/lib/node/fs.js.map +1 -1
- package/dist/es5/lib/node/promisify.js +0 -1
- package/dist/es5/lib/node/promisify.js.map +1 -1
- package/dist/es5/lib/node/stream.js +1 -5
- package/dist/es5/lib/node/stream.js.map +1 -1
- package/dist/es5/lib/option-utils/merge-loader-options.js +0 -1
- package/dist/es5/lib/option-utils/merge-loader-options.js.map +1 -1
- package/dist/es5/lib/parser-utils/parse-json.js.map +1 -1
- package/dist/es5/lib/path-utils/file-aliases.js +0 -5
- package/dist/es5/lib/path-utils/file-aliases.js.map +1 -1
- 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 +105 -5
- package/dist/es5/lib/path-utils/path.js.map +1 -1
- package/dist/es5/lib/request-utils/request-scheduler.js +6 -29
- package/dist/es5/lib/request-utils/request-scheduler.js.map +1 -1
- package/dist/es5/lib/worker-loader-utils/create-loader-worker.js +69 -79
- package/dist/es5/lib/worker-loader-utils/create-loader-worker.js.map +1 -1
- package/dist/es5/lib/worker-loader-utils/encode-with-worker.js +0 -1
- package/dist/es5/lib/worker-loader-utils/encode-with-worker.js.map +1 -1
- package/dist/es5/lib/worker-loader-utils/parse-with-worker.js +70 -77
- package/dist/es5/lib/worker-loader-utils/parse-with-worker.js.map +1 -1
- package/dist/es5/types.js.map +1 -1
- package/dist/es5/workers/json-worker.js.map +1 -1
- package/dist/esm/index.js +0 -15
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/json-loader.js +1 -4
- package/dist/esm/json-loader.js.map +1 -1
- package/dist/esm/lib/binary-utils/array-buffer-utils.js +0 -8
- package/dist/esm/lib/binary-utils/array-buffer-utils.js.map +1 -1
- package/dist/esm/lib/binary-utils/dataview-copy-utils.js +0 -7
- package/dist/esm/lib/binary-utils/dataview-copy-utils.js.map +1 -1
- package/dist/esm/lib/binary-utils/get-first-characters.js +0 -3
- package/dist/esm/lib/binary-utils/get-first-characters.js.map +1 -1
- package/dist/esm/lib/binary-utils/memory-conversion-utils.js +0 -7
- package/dist/esm/lib/binary-utils/memory-conversion-utils.js.map +1 -1
- package/dist/esm/lib/binary-utils/memory-copy-utils.js +0 -4
- package/dist/esm/lib/binary-utils/memory-copy-utils.js.map +1 -1
- package/dist/esm/lib/env-utils/assert.js +0 -1
- package/dist/esm/lib/env-utils/assert.js.map +1 -1
- package/dist/esm/lib/env-utils/globals.js +1 -7
- package/dist/esm/lib/env-utils/globals.js.map +1 -1
- package/dist/esm/lib/filesystems/node-filesystem.js +0 -1
- package/dist/esm/lib/filesystems/node-filesystem.js.map +1 -1
- package/dist/esm/lib/filesystems/readable-file.js +0 -2
- package/dist/esm/lib/filesystems/readable-file.js.map +1 -1
- package/dist/esm/lib/filesystems/writable-file.js +0 -1
- package/dist/esm/lib/filesystems/writable-file.js.map +1 -1
- package/dist/esm/lib/iterators/async-iteration.js +0 -2
- package/dist/esm/lib/iterators/async-iteration.js.map +1 -1
- package/dist/esm/lib/iterators/text-iterators.js +13 -12
- package/dist/esm/lib/iterators/text-iterators.js.map +1 -1
- package/dist/esm/lib/node/buffer.browser.js +0 -3
- package/dist/esm/lib/node/buffer.browser.js.map +1 -1
- package/dist/esm/lib/node/buffer.js +0 -3
- package/dist/esm/lib/node/buffer.js.map +1 -1
- package/dist/esm/lib/node/fs.js +1 -8
- package/dist/esm/lib/node/fs.js.map +1 -1
- package/dist/esm/lib/node/promisify.js +0 -2
- package/dist/esm/lib/node/promisify.js.map +1 -1
- package/dist/esm/lib/node/stream.js +1 -5
- package/dist/esm/lib/node/stream.js.map +1 -1
- package/dist/esm/lib/option-utils/merge-loader-options.js +0 -2
- package/dist/esm/lib/option-utils/merge-loader-options.js.map +1 -1
- package/dist/esm/lib/parser-utils/parse-json.js +0 -1
- package/dist/esm/lib/parser-utils/parse-json.js.map +1 -1
- package/dist/esm/lib/path-utils/file-aliases.js +0 -6
- package/dist/esm/lib/path-utils/file-aliases.js.map +1 -1
- 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 +104 -6
- package/dist/esm/lib/path-utils/path.js.map +1 -1
- package/dist/esm/lib/request-utils/request-scheduler.js +0 -16
- package/dist/esm/lib/request-utils/request-scheduler.js.map +1 -1
- package/dist/esm/lib/worker-loader-utils/create-loader-worker.js +0 -10
- package/dist/esm/lib/worker-loader-utils/create-loader-worker.js.map +1 -1
- package/dist/esm/lib/worker-loader-utils/encode-with-worker.js +0 -2
- package/dist/esm/lib/worker-loader-utils/encode-with-worker.js.map +1 -1
- package/dist/esm/lib/worker-loader-utils/parse-with-worker.js +1 -8
- package/dist/esm/lib/worker-loader-utils/parse-with-worker.js.map +1 -1
- package/dist/esm/types.js.map +1 -1
- 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 +8 -0
- package/dist/lib/path-utils/path.d.ts.map +1 -1
- package/dist/lib/path-utils/path.js +141 -3
- package/dist/lib/worker-loader-utils/create-loader-worker.js +1 -1
- package/dist/types.d.ts +7 -7
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/lib/path-utils/get-cwd.ts +9 -0
- package/src/lib/path-utils/path.ts +138 -4
- package/src/types.ts +7 -7
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import { isBrowser } from '@loaders.gl/worker-utils';
|
|
2
2
|
import { WorkerFarm, getWorkerURL } from '@loaders.gl/worker-utils';
|
|
3
|
-
|
|
4
3
|
export function canParseWithWorker(loader, options) {
|
|
5
4
|
if (!WorkerFarm.isSupported()) {
|
|
6
5
|
return false;
|
|
7
6
|
}
|
|
8
|
-
|
|
9
7
|
if (!isBrowser && !(options !== null && options !== void 0 && options._nodeWorkers)) {
|
|
10
8
|
return false;
|
|
11
9
|
}
|
|
12
10
|
return loader.worker && (options === null || options === void 0 ? void 0 : options.worker);
|
|
13
11
|
}
|
|
14
|
-
|
|
15
12
|
export async function parseWithWorker(loader, data, options, context, parseOnMainThread) {
|
|
16
13
|
const name = loader.id;
|
|
17
14
|
const url = getWorkerURL(loader, options);
|
|
@@ -20,12 +17,9 @@ export async function parseWithWorker(loader, data, options, context, parseOnMai
|
|
|
20
17
|
name,
|
|
21
18
|
url
|
|
22
19
|
});
|
|
23
|
-
|
|
24
20
|
options = JSON.parse(JSON.stringify(options));
|
|
25
21
|
context = JSON.parse(JSON.stringify(context || {}));
|
|
26
|
-
const job = await workerPool.startJob('process-on-worker',
|
|
27
|
-
onMessage.bind(null, parseOnMainThread));
|
|
28
|
-
|
|
22
|
+
const job = await workerPool.startJob('process-on-worker', onMessage.bind(null, parseOnMainThread));
|
|
29
23
|
job.postMessage('process', {
|
|
30
24
|
input: data,
|
|
31
25
|
options,
|
|
@@ -34,7 +28,6 @@ export async function parseWithWorker(loader, data, options, context, parseOnMai
|
|
|
34
28
|
const result = await job.result;
|
|
35
29
|
return await result.result;
|
|
36
30
|
}
|
|
37
|
-
|
|
38
31
|
async function onMessage(parseOnMainThread, job, type, payload) {
|
|
39
32
|
switch (type) {
|
|
40
33
|
case 'done':
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-with-worker.js","names":["isBrowser","WorkerFarm","getWorkerURL","canParseWithWorker","loader","options","isSupported","_nodeWorkers","worker","parseWithWorker","data","context","parseOnMainThread","name","id","url","workerFarm","getWorkerFarm","workerPool","getWorkerPool","JSON","parse","stringify","job","startJob","onMessage","bind","postMessage","input","result","type","payload","done","error","Error","message","console","warn"],"sources":["../../../../src/lib/worker-loader-utils/parse-with-worker.ts"],"sourcesContent":["import {\n WorkerJob,\n WorkerMessageType,\n WorkerMessagePayload,\n isBrowser\n} from '@loaders.gl/worker-utils';\nimport type {Loader, LoaderOptions, LoaderContext} from '../../types';\nimport {WorkerFarm, getWorkerURL} from '@loaders.gl/worker-utils';\n\n/**\n * Determines if a loader can parse with worker\n * @param loader\n * @param options\n */\nexport function canParseWithWorker(loader: Loader, options?: LoaderOptions) {\n if (!WorkerFarm.isSupported()) {\n return false;\n }\n\n // Node workers are still experimental\n if (!isBrowser && !options?._nodeWorkers) {\n return false;\n }\n\n return loader.worker && options?.worker;\n}\n\n/**\n * this function expects that the worker function sends certain messages,\n * this can be automated if the worker is wrapper by a call to createLoaderWorker in @loaders.gl/loader-utils.\n */\nexport async function parseWithWorker(\n loader: Loader,\n data: any,\n options?: LoaderOptions,\n context?: LoaderContext,\n parseOnMainThread?: (arrayBuffer: ArrayBuffer, options: {[key: string]: any}) => Promise<void>\n) {\n const name = loader.id; // TODO\n const url = getWorkerURL(loader, options);\n\n const workerFarm = WorkerFarm.getWorkerFarm(options);\n const workerPool = workerFarm.getWorkerPool({name, url});\n\n // options.log object contains functions which cannot be transferred\n // context.fetch & context.parse functions cannot be transferred\n // TODO - decide how to handle logging on workers\n options = JSON.parse(JSON.stringify(options));\n context = JSON.parse(JSON.stringify(context || {}));\n\n const job = await workerPool.startJob(\n 'process-on-worker',\n // @ts-expect-error\n onMessage.bind(null, parseOnMainThread) // eslint-disable-line @typescript-eslint/no-misused-promises\n );\n\n job.postMessage('process', {\n // @ts-ignore\n input: data,\n options,\n context\n });\n\n const result = await job.result;\n // TODO - what is going on here?\n return await result.result;\n}\n\n/**\n * Handle worker's responses to the main thread\n * @param job\n * @param type\n * @param payload\n */\nasync function onMessage(\n parseOnMainThread: (arrayBuffer: ArrayBuffer, options?: {[key: string]: any}) => Promise<void>,\n job: WorkerJob,\n type: WorkerMessageType,\n payload: WorkerMessagePayload\n) {\n switch (type) {\n case 'done':\n job.done(payload);\n break;\n\n case 'error':\n job.error(new Error(payload.error));\n break;\n\n case 'process':\n // Worker is asking for main thread to parseO\n const {id, input, options} = payload;\n try {\n const result = await parseOnMainThread(input, options);\n job.postMessage('done', {id, result});\n } catch (error) {\n const message = error instanceof Error ? error.message : 'unknown error';\n job.postMessage('error', {id, error: message});\n }\n break;\n\n default:\n // eslint-disable-next-line\n console.warn(`parse-with-worker unknown message ${type}`);\n }\n}\n"],"mappings":"AAAA,SAIEA,SAAS,QACJ,0BAA0B;AAEjC,SAAQC,UAAU,EAAEC,YAAY,QAAO,0BAA0B
|
|
1
|
+
{"version":3,"file":"parse-with-worker.js","names":["isBrowser","WorkerFarm","getWorkerURL","canParseWithWorker","loader","options","isSupported","_nodeWorkers","worker","parseWithWorker","data","context","parseOnMainThread","name","id","url","workerFarm","getWorkerFarm","workerPool","getWorkerPool","JSON","parse","stringify","job","startJob","onMessage","bind","postMessage","input","result","type","payload","done","error","Error","message","console","warn","concat"],"sources":["../../../../src/lib/worker-loader-utils/parse-with-worker.ts"],"sourcesContent":["import {\n WorkerJob,\n WorkerMessageType,\n WorkerMessagePayload,\n isBrowser\n} from '@loaders.gl/worker-utils';\nimport type {Loader, LoaderOptions, LoaderContext} from '../../types';\nimport {WorkerFarm, getWorkerURL} from '@loaders.gl/worker-utils';\n\n/**\n * Determines if a loader can parse with worker\n * @param loader\n * @param options\n */\nexport function canParseWithWorker(loader: Loader, options?: LoaderOptions) {\n if (!WorkerFarm.isSupported()) {\n return false;\n }\n\n // Node workers are still experimental\n if (!isBrowser && !options?._nodeWorkers) {\n return false;\n }\n\n return loader.worker && options?.worker;\n}\n\n/**\n * this function expects that the worker function sends certain messages,\n * this can be automated if the worker is wrapper by a call to createLoaderWorker in @loaders.gl/loader-utils.\n */\nexport async function parseWithWorker(\n loader: Loader,\n data: any,\n options?: LoaderOptions,\n context?: LoaderContext,\n parseOnMainThread?: (arrayBuffer: ArrayBuffer, options: {[key: string]: any}) => Promise<void>\n) {\n const name = loader.id; // TODO\n const url = getWorkerURL(loader, options);\n\n const workerFarm = WorkerFarm.getWorkerFarm(options);\n const workerPool = workerFarm.getWorkerPool({name, url});\n\n // options.log object contains functions which cannot be transferred\n // context.fetch & context.parse functions cannot be transferred\n // TODO - decide how to handle logging on workers\n options = JSON.parse(JSON.stringify(options));\n context = JSON.parse(JSON.stringify(context || {}));\n\n const job = await workerPool.startJob(\n 'process-on-worker',\n // @ts-expect-error\n onMessage.bind(null, parseOnMainThread) // eslint-disable-line @typescript-eslint/no-misused-promises\n );\n\n job.postMessage('process', {\n // @ts-ignore\n input: data,\n options,\n context\n });\n\n const result = await job.result;\n // TODO - what is going on here?\n return await result.result;\n}\n\n/**\n * Handle worker's responses to the main thread\n * @param job\n * @param type\n * @param payload\n */\nasync function onMessage(\n parseOnMainThread: (arrayBuffer: ArrayBuffer, options?: {[key: string]: any}) => Promise<void>,\n job: WorkerJob,\n type: WorkerMessageType,\n payload: WorkerMessagePayload\n) {\n switch (type) {\n case 'done':\n job.done(payload);\n break;\n\n case 'error':\n job.error(new Error(payload.error));\n break;\n\n case 'process':\n // Worker is asking for main thread to parseO\n const {id, input, options} = payload;\n try {\n const result = await parseOnMainThread(input, options);\n job.postMessage('done', {id, result});\n } catch (error) {\n const message = error instanceof Error ? error.message : 'unknown error';\n job.postMessage('error', {id, error: message});\n }\n break;\n\n default:\n // eslint-disable-next-line\n console.warn(`parse-with-worker unknown message ${type}`);\n }\n}\n"],"mappings":"AAAA,SAIEA,SAAS,QACJ,0BAA0B;AAEjC,SAAQC,UAAU,EAAEC,YAAY,QAAO,0BAA0B;AAOjE,OAAO,SAASC,kBAAkBA,CAACC,MAAc,EAAEC,OAAuB,EAAE;EAC1E,IAAI,CAACJ,UAAU,CAACK,WAAW,EAAE,EAAE;IAC7B,OAAO,KAAK;EACd;EAGA,IAAI,CAACN,SAAS,IAAI,EAACK,OAAO,aAAPA,OAAO,eAAPA,OAAO,CAAEE,YAAY,GAAE;IACxC,OAAO,KAAK;EACd;EAEA,OAAOH,MAAM,CAACI,MAAM,KAAIH,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEG,MAAM;AACzC;AAMA,OAAO,eAAeC,eAAeA,CACnCL,MAAc,EACdM,IAAS,EACTL,OAAuB,EACvBM,OAAu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B,CAACgB,KAAK,EAAEvB,OAAO,CAAC;QACtDkB,GAAG,CAACI,WAAW,CAAC,MAAM,EAAE;UAACb,EAAE;UAAEe;QAAM,CAAC,CAAC;MACvC,CAAC,CAAC,OAAOI,KAAK,EAAE;QACd,MAAME,OAAO,GAAGF,KAAK,YAAYC,KAAK,GAAGD,KAAK,CAACE,OAAO,GAAG,eAAe;QACxEZ,GAAG,CAACI,WAAW,CAAC,OAAO,EAAE;UAACb,EAAE;UAAEmB,KAAK,EAAEE;QAAO,CAAC,CAAC;MAChD;MACA;IAEF;MAEEC,OAAO,CAACC,IAAI,sCAAAC,MAAA,CAAsCR,IAAI,EAAG;EAAC;AAEhE"}
|
package/dist/esm/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../src/types.ts"],"sourcesContent":["// Typed arrays\n\nexport type TypedIntArray =\n | Int8Array\n | Uint8Array\n | Uint8ClampedArray\n | Int16Array\n | Uint16Array\n | Int32Array\n | Uint32Array\n | Int32Array\n | Uint32Array;\n\nexport type TypedFloatArray = Uint16Array | Float32Array | Float64Array;\n\nexport type TypedArray = TypedIntArray | TypedFloatArray;\n\nexport type NumericArray = Array<number> | TypedIntArray | TypedFloatArray;\n\ntype FetchLike = (url: string, options?: RequestInit) => Promise<Response>;\n\n/**\n * Core Loader Options\n */\nexport type LoaderOptions = {\n /** fetch options or a custom fetch function */\n fetch?: typeof fetch | FetchLike | RequestInit | null;\n /** Do not throw on errors */\n nothrow?: boolean;\n\n /** loader selection, search first for supplied mimeType */\n mimeType?: string;\n /** loader selection, provide fallback mimeType is server does not provide */\n fallbackMimeType?: string;\n /** loader selection, avoid searching registered loaders */\n ignoreRegisteredLoaders?: boolean;\n\n // general\n /** Experimental: Supply a logger to the parser */\n log?: any;\n\n // batched parsing\n\n /** Size of each batch. `auto` matches batches to size of incoming chunks */\n batchSize?: number | 'auto';\n /** Minimal amount of time between batches */\n batchDebounceMs?: number;\n /** Stop loading after a given number of rows (compare SQL limit clause) */\n limit?: 0;\n /** Experimental: Stop loading after reaching */\n _limitMB?: 0;\n /** Generate metadata batches */\n metadata?: boolean;\n /** Transforms to run on incoming batches */\n transforms?: TransformBatches[];\n\n // workers\n\n /** CDN load workers from */\n CDN?: string | null;\n /** Set to `false` to disable workers */\n worker?: boolean;\n /** Number of concurrent workers (per loader) on desktop browser */\n maxConcurrency?: number;\n /** Number of concurrent workers (per loader) on mobile browsers */\n maxMobileConcurrency?: number;\n /** Set to `false` to prevent reuse workers */\n reuseWorkers?: boolean;\n /** Whether to use workers under Node.js (experimental) */\n _nodeWorkers?: boolean;\n /** set to 'test' to run local worker */\n _workerType?: string;\n\n /** @deprecated `options.batchType` removed, Use `options.<loader>.type` instead */\n batchType?: 'row' | 'columnar' | 'arrow';\n /** @deprecated `options.throw removed`, Use `options.nothrow` instead */\n throws?: boolean;\n /** @deprecated `options.dataType` no longer used */\n dataType?: never;\n /** @deprecated `options.uri` no longer used */\n uri?: never;\n /** @deprecated `options.method` removed. Use `options.fetch.method` */\n method?: never;\n /** @deprecated `options.headers` removed. Use `options.fetch.headers` */\n headers?: never;\n /** @deprecated `options.body` removed. Use `options.fetch.body` */\n body?: never;\n /** @deprecated `options.mode` removed. Use `options.fetch.mode` */\n mode?: never;\n /** @deprecated `options.credentials` removed. Use `options.fetch.credentials` */\n credentials?: never;\n /** @deprecated `options.cache` removed. Use `options.fetch.cache` */\n cache?: never;\n /** @deprecated `options.redirect` removed. Use `options.fetch.redirect` */\n redirect?: never;\n /** @deprecated `options.referrer` removed. Use `options.fetch.referrer` */\n referrer?: never;\n /** @deprecated `options.referrerPolicy` removed. Use `options.fetch.referrerPolicy` */\n referrerPolicy?: never;\n /** @deprecated `options.integrity` removed. Use `options.fetch.integrity` */\n integrity?: never;\n /** @deprecated `options.keepalive` removed. Use `options.fetch.keepalive` */\n keepalive?: never;\n /** @deprecated `options.signal` removed. Use `options.fetch.signal` */\n signal?: never;\n\n // Accept other keys (loader options objects, e.g. `options.csv`, `options.json` ...)\n [loaderId: string]: unknown;\n};\n\ntype PreloadOptions = {\n [key: string]: unknown;\n};\n\n/**\n * A worker loader definition that can be used with `@loaders.gl/core` functions\n */\nexport type Loader = {\n // Worker\n name: string;\n id: string;\n module: string;\n version: string;\n worker?: string | boolean;\n options: LoaderOptions;\n deprecatedOptions?: object;\n // end Worker\n\n category?: string;\n extensions: string[];\n mimeTypes: string[];\n\n binary?: boolean;\n text?: boolean;\n\n tests?: (((ArrayBuffer) => boolean) | ArrayBuffer | string)[];\n\n // TODO - deprecated\n supported?: boolean;\n testText?: (string) => boolean;\n};\n\n/**\n * A \"bundled\" loader definition that can be used with `@loaders.gl/core` functions\n * If a worker loader is supported it will also be supported.\n */\nexport type LoaderWithParser = Loader & {\n // TODO - deprecated\n testText?: (string) => boolean;\n\n parse: Parse;\n preload?: Preload;\n parseSync?: ParseSync;\n parseText?: ParseText;\n parseTextSync?: ParseTextSync;\n parseInBatches?: ParseInBatches;\n parseFileInBatches?: ParseFileInBatches;\n};\n\n/** Options for writers */\nexport type WriterOptions = {\n /** worker source. If is set will be used instead of loading worker from the Internet */\n souce?: string | null;\n /** writer-specific options */\n [writerId: string]: any;\n};\n\n/**\n * A writer definition that can be used with `@loaders.gl/core` functions\n */\nexport type Writer = {\n name: string;\n\n id: string;\n module: string;\n version: string;\n worker?: string | boolean;\n\n options: WriterOptions;\n deprecatedOptions?: object;\n\n // TODO - are these are needed?\n binary?: boolean;\n extensions?: string[];\n mimeTypes?: string[];\n text?: boolean;\n\n encode?: Encode;\n encodeSync?: EncodeSync;\n encodeInBatches?: EncodeInBatches;\n encodeURLtoURL?: EncodeURLtoURL;\n encodeText?: EncodeText;\n};\n\nexport type LoaderContext = {\n loaders?: Loader[] | null;\n url?: string;\n\n fetch: typeof fetch | FetchLike;\n response?: Response;\n parse: (\n arrayBuffer: ArrayBuffer,\n loaders
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../src/types.ts"],"sourcesContent":["// Typed arrays\n\nexport type TypedIntArray =\n | Int8Array\n | Uint8Array\n | Uint8ClampedArray\n | Int16Array\n | Uint16Array\n | Int32Array\n | Uint32Array\n | Int32Array\n | Uint32Array;\n\nexport type TypedFloatArray = Uint16Array | Float32Array | Float64Array;\n\nexport type TypedArray = TypedIntArray | TypedFloatArray;\n\nexport type NumericArray = Array<number> | TypedIntArray | TypedFloatArray;\n\ntype FetchLike = (url: string, options?: RequestInit) => Promise<Response>;\n\n/**\n * Core Loader Options\n */\nexport type LoaderOptions = {\n /** fetch options or a custom fetch function */\n fetch?: typeof fetch | FetchLike | RequestInit | null;\n /** Do not throw on errors */\n nothrow?: boolean;\n\n /** loader selection, search first for supplied mimeType */\n mimeType?: string;\n /** loader selection, provide fallback mimeType is server does not provide */\n fallbackMimeType?: string;\n /** loader selection, avoid searching registered loaders */\n ignoreRegisteredLoaders?: boolean;\n\n // general\n /** Experimental: Supply a logger to the parser */\n log?: any;\n\n // batched parsing\n\n /** Size of each batch. `auto` matches batches to size of incoming chunks */\n batchSize?: number | 'auto';\n /** Minimal amount of time between batches */\n batchDebounceMs?: number;\n /** Stop loading after a given number of rows (compare SQL limit clause) */\n limit?: 0;\n /** Experimental: Stop loading after reaching */\n _limitMB?: 0;\n /** Generate metadata batches */\n metadata?: boolean;\n /** Transforms to run on incoming batches */\n transforms?: TransformBatches[];\n\n // workers\n\n /** CDN load workers from */\n CDN?: string | null;\n /** Set to `false` to disable workers */\n worker?: boolean;\n /** Number of concurrent workers (per loader) on desktop browser */\n maxConcurrency?: number;\n /** Number of concurrent workers (per loader) on mobile browsers */\n maxMobileConcurrency?: number;\n /** Set to `false` to prevent reuse workers */\n reuseWorkers?: boolean;\n /** Whether to use workers under Node.js (experimental) */\n _nodeWorkers?: boolean;\n /** set to 'test' to run local worker */\n _workerType?: string;\n\n /** @deprecated `options.batchType` removed, Use `options.<loader>.type` instead */\n batchType?: 'row' | 'columnar' | 'arrow';\n /** @deprecated `options.throw removed`, Use `options.nothrow` instead */\n throws?: boolean;\n /** @deprecated `options.dataType` no longer used */\n dataType?: never;\n /** @deprecated `options.uri` no longer used */\n uri?: never;\n /** @deprecated `options.method` removed. Use `options.fetch.method` */\n method?: never;\n /** @deprecated `options.headers` removed. Use `options.fetch.headers` */\n headers?: never;\n /** @deprecated `options.body` removed. Use `options.fetch.body` */\n body?: never;\n /** @deprecated `options.mode` removed. Use `options.fetch.mode` */\n mode?: never;\n /** @deprecated `options.credentials` removed. Use `options.fetch.credentials` */\n credentials?: never;\n /** @deprecated `options.cache` removed. Use `options.fetch.cache` */\n cache?: never;\n /** @deprecated `options.redirect` removed. Use `options.fetch.redirect` */\n redirect?: never;\n /** @deprecated `options.referrer` removed. Use `options.fetch.referrer` */\n referrer?: never;\n /** @deprecated `options.referrerPolicy` removed. Use `options.fetch.referrerPolicy` */\n referrerPolicy?: never;\n /** @deprecated `options.integrity` removed. Use `options.fetch.integrity` */\n integrity?: never;\n /** @deprecated `options.keepalive` removed. Use `options.fetch.keepalive` */\n keepalive?: never;\n /** @deprecated `options.signal` removed. Use `options.fetch.signal` */\n signal?: never;\n\n // Accept other keys (loader options objects, e.g. `options.csv`, `options.json` ...)\n [loaderId: string]: unknown;\n};\n\ntype PreloadOptions = {\n [key: string]: unknown;\n};\n\n/**\n * A worker loader definition that can be used with `@loaders.gl/core` functions\n */\nexport type Loader = {\n // Worker\n name: string;\n id: string;\n module: string;\n version: string;\n worker?: string | boolean;\n options: LoaderOptions;\n deprecatedOptions?: object;\n // end Worker\n\n category?: string;\n extensions: string[];\n mimeTypes: string[];\n\n binary?: boolean;\n text?: boolean;\n\n tests?: (((ArrayBuffer: ArrayBuffer) => boolean) | ArrayBuffer | string)[];\n\n // TODO - deprecated\n supported?: boolean;\n testText?: (string: string) => boolean;\n};\n\n/**\n * A \"bundled\" loader definition that can be used with `@loaders.gl/core` functions\n * If a worker loader is supported it will also be supported.\n */\nexport type LoaderWithParser = Loader & {\n // TODO - deprecated\n testText?: (string: string) => boolean;\n\n parse: Parse;\n preload?: Preload;\n parseSync?: ParseSync;\n parseText?: ParseText;\n parseTextSync?: ParseTextSync;\n parseInBatches?: ParseInBatches;\n parseFileInBatches?: ParseFileInBatches;\n};\n\n/** Options for writers */\nexport type WriterOptions = {\n /** worker source. If is set will be used instead of loading worker from the Internet */\n souce?: string | null;\n /** writer-specific options */\n [writerId: string]: any;\n};\n\n/**\n * A writer definition that can be used with `@loaders.gl/core` functions\n */\nexport type Writer = {\n name: string;\n\n id: string;\n module: string;\n version: string;\n worker?: string | boolean;\n\n options: WriterOptions;\n deprecatedOptions?: object;\n\n // TODO - are these are needed?\n binary?: boolean;\n extensions?: string[];\n mimeTypes?: string[];\n text?: boolean;\n\n encode?: Encode;\n encodeSync?: EncodeSync;\n encodeInBatches?: EncodeInBatches;\n encodeURLtoURL?: EncodeURLtoURL;\n encodeText?: EncodeText;\n};\n\nexport type LoaderContext = {\n loaders?: Loader[] | null;\n url?: string;\n\n fetch: typeof fetch | FetchLike;\n response?: Response;\n parse: (\n arrayBuffer: ArrayBuffer,\n loaders?: Loader | Loader[] | LoaderOptions,\n options?: LoaderOptions,\n context?: LoaderContext\n ) => Promise<any>;\n parseSync?: (\n arrayBuffer: ArrayBuffer,\n loaders?: Loader | Loader[] | LoaderOptions,\n options?: LoaderOptions,\n context?: LoaderContext\n ) => any;\n parseInBatches?: (\n iterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>,\n loaders?: Loader | Loader[] | LoaderOptions,\n options?: LoaderOptions,\n context?: LoaderContext\n ) => AsyncIterable<any> | Promise<AsyncIterable<any>>;\n};\n\ntype Parse = (\n arrayBuffer: ArrayBuffer,\n options?: LoaderOptions,\n context?: LoaderContext\n) => Promise<any>;\ntype ParseSync = (\n arrayBuffer: ArrayBuffer,\n options?: LoaderOptions,\n context?: LoaderContext\n) => any;\ntype ParseText = (text: string, options?: LoaderOptions) => Promise<any>;\ntype ParseTextSync = (text: string, options?: LoaderOptions) => any;\ntype ParseInBatches = (\n iterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>,\n options?: LoaderOptions,\n context?: LoaderContext\n) => AsyncIterable<any>;\ntype ParseFileInBatches = (\n file: Blob,\n options?: LoaderOptions,\n context?: LoaderContext\n) => AsyncIterable<any>;\n\ntype Encode = (data: any, options?: WriterOptions) => Promise<ArrayBuffer>;\ntype EncodeSync = (data: any, options?: WriterOptions) => ArrayBuffer;\n// TODO\ntype EncodeText = Function;\ntype EncodeInBatches = Function;\ntype EncodeURLtoURL = (\n inputUrl: string,\n outputUrl: string,\n options?: WriterOptions\n) => Promise<string>;\ntype Preload = (url: string, options?: PreloadOptions) => any;\n\nexport type TransformBatches = (\n asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>\n) => AsyncIterable<ArrayBuffer>;\n\n/** Types that can be synchronously parsed */\nexport type SyncDataType = string | ArrayBuffer; // TODO File | Blob can be read synchronously...\n\n/** Types that can be parsed async */\nexport type DataType =\n | string\n | ArrayBuffer\n | File\n | Blob\n | Response\n | ReadableStream\n | Iterable<ArrayBuffer>\n | AsyncIterable<ArrayBuffer>;\n\n/** Types that can be parsed in batches */\nexport type BatchableDataType =\n | DataType\n | Iterable<ArrayBuffer>\n | AsyncIterable<ArrayBuffer>\n | Promise<AsyncIterable<ArrayBuffer>>;\n\n/**\n * A FileSystem interface can encapsulate a FileList, a ZipFile, a GoogleDrive etc.\n */\nexport interface IFileSystem {\n /**\n * Return a list of file names\n * @param dirname directory name. file system root directory if omitted\n */\n readdir(dirname?: string, options?: {recursive?: boolean}): Promise<string[]>;\n\n /**\n * Gets information from a local file from the filesystem\n * @param filename file name to stat\n * @param options currently unused\n * @throws if filename is not in local filesystem\n */\n stat(filename: string, options?: object): Promise<{size: number}>;\n\n /**\n * Fetches a local file from the filesystem (or a URL)\n * @param filename\n * @param options\n */\n fetch(filename: string, options?: object): Promise<Response>;\n}\n\ntype ReadOptions = {buffer?: ArrayBuffer; offset?: number; length?: number; position?: number};\nexport interface IRandomAccessReadFileSystem extends IFileSystem {\n open(path: string, flags: string | number, mode?: any): Promise<any>;\n close(fd: any): Promise<void>;\n fstat(fd: any): Promise<object>;\n read(fd: any, options?: ReadOptions): Promise<{bytesRead: number; buffer: Buffer}>;\n}\n"],"mappings":""}
|
|
@@ -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;
|
|
@@ -13,4 +13,12 @@ export declare function dirname(url: string): string;
|
|
|
13
13
|
* @param parts
|
|
14
14
|
*/
|
|
15
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;
|
|
16
24
|
//# sourceMappingURL=path.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../src/lib/path-utils/path.ts"],"names":[],"mappings":"
|
|
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,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Beginning of a minimal implementation of the Node.js path API, that doesn't pull in big polyfills.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.join = exports.dirname = exports.filename = void 0;
|
|
4
|
+
exports.resolve = exports.join = exports.dirname = exports.filename = void 0;
|
|
5
|
+
const get_cwd_1 = require("./get-cwd");
|
|
5
6
|
/**
|
|
6
7
|
* Replacement for Node.js path.filename
|
|
7
8
|
* @param url
|
|
8
9
|
*/
|
|
9
10
|
function filename(url) {
|
|
10
|
-
const slashIndex = url
|
|
11
|
+
const slashIndex = url ? url.lastIndexOf('/') : -1;
|
|
11
12
|
return slashIndex >= 0 ? url.substr(slashIndex + 1) : '';
|
|
12
13
|
}
|
|
13
14
|
exports.filename = filename;
|
|
@@ -16,7 +17,7 @@ exports.filename = filename;
|
|
|
16
17
|
* @param url
|
|
17
18
|
*/
|
|
18
19
|
function dirname(url) {
|
|
19
|
-
const slashIndex = url
|
|
20
|
+
const slashIndex = url ? url.lastIndexOf('/') : -1;
|
|
20
21
|
return slashIndex >= 0 ? url.substr(0, slashIndex) : '';
|
|
21
22
|
}
|
|
22
23
|
exports.dirname = dirname;
|
|
@@ -38,3 +39,140 @@ function join(...parts) {
|
|
|
38
39
|
return parts.join(separator);
|
|
39
40
|
}
|
|
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}`;
|
|
82
|
+
}
|
|
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
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return res;
|
|
178
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createLoaderWorker = void 0;
|
|
4
4
|
const worker_utils_1 = require("@loaders.gl/worker-utils");
|
|
5
|
-
// import {validateLoaderVersion} from './validate-loader-version';
|
|
5
|
+
// import {validateLoaderVersion} from './validate-loader-version.js';
|
|
6
6
|
let requestId = 0;
|
|
7
7
|
/**
|
|
8
8
|
* Set up a WebWorkerGlobalScope to talk with the main thread
|
package/dist/types.d.ts
CHANGED
|
@@ -99,16 +99,16 @@ export type Loader = {
|
|
|
99
99
|
mimeTypes: string[];
|
|
100
100
|
binary?: boolean;
|
|
101
101
|
text?: boolean;
|
|
102
|
-
tests?: (((ArrayBuffer:
|
|
102
|
+
tests?: (((ArrayBuffer: ArrayBuffer) => boolean) | ArrayBuffer | string)[];
|
|
103
103
|
supported?: boolean;
|
|
104
|
-
testText?: (string:
|
|
104
|
+
testText?: (string: string) => boolean;
|
|
105
105
|
};
|
|
106
106
|
/**
|
|
107
107
|
* A "bundled" loader definition that can be used with `@loaders.gl/core` functions
|
|
108
108
|
* If a worker loader is supported it will also be supported.
|
|
109
109
|
*/
|
|
110
110
|
export type LoaderWithParser = Loader & {
|
|
111
|
-
testText?: (string:
|
|
111
|
+
testText?: (string: string) => boolean;
|
|
112
112
|
parse: Parse;
|
|
113
113
|
preload?: Preload;
|
|
114
114
|
parseSync?: ParseSync;
|
|
@@ -150,9 +150,9 @@ export type LoaderContext = {
|
|
|
150
150
|
url?: string;
|
|
151
151
|
fetch: typeof fetch | FetchLike;
|
|
152
152
|
response?: Response;
|
|
153
|
-
parse: (arrayBuffer: ArrayBuffer, loaders?:
|
|
154
|
-
parseSync?: (arrayBuffer: ArrayBuffer, loaders?:
|
|
155
|
-
parseInBatches?: (iterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>, loaders?:
|
|
153
|
+
parse: (arrayBuffer: ArrayBuffer, loaders?: Loader | Loader[] | LoaderOptions, options?: LoaderOptions, context?: LoaderContext) => Promise<any>;
|
|
154
|
+
parseSync?: (arrayBuffer: ArrayBuffer, loaders?: Loader | Loader[] | LoaderOptions, options?: LoaderOptions, context?: LoaderContext) => any;
|
|
155
|
+
parseInBatches?: (iterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>, loaders?: Loader | Loader[] | LoaderOptions, options?: LoaderOptions, context?: LoaderContext) => AsyncIterable<any> | Promise<AsyncIterable<any>>;
|
|
156
156
|
};
|
|
157
157
|
type Parse = (arrayBuffer: ArrayBuffer, options?: LoaderOptions, context?: LoaderContext) => Promise<any>;
|
|
158
158
|
type ParseSync = (arrayBuffer: ArrayBuffer, options?: LoaderOptions, context?: LoaderContext) => any;
|
|
@@ -207,7 +207,7 @@ type ReadOptions = {
|
|
|
207
207
|
position?: number;
|
|
208
208
|
};
|
|
209
209
|
export interface IRandomAccessReadFileSystem extends IFileSystem {
|
|
210
|
-
open(path: string, flags:
|
|
210
|
+
open(path: string, flags: string | number, mode?: any): Promise<any>;
|
|
211
211
|
close(fd: any): Promise<void>;
|
|
212
212
|
fstat(fd: any): Promise<object>;
|
|
213
213
|
read(fd: any, options?: ReadOptions): Promise<{
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAEA,MAAM,MAAM,aAAa,GACrB,SAAS,GACT,UAAU,GACV,iBAAiB,GACjB,UAAU,GACV,WAAW,GACX,UAAU,GACV,WAAW,GACX,UAAU,GACV,WAAW,CAAC;AAEhB,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,YAAY,GAAG,YAAY,CAAC;AAExE,MAAM,MAAM,UAAU,GAAG,aAAa,GAAG,eAAe,CAAC;AAEzD,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,aAAa,GAAG,eAAe,CAAC;AAE3E,KAAK,SAAS,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAE3E;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,+CAA+C;IAC/C,KAAK,CAAC,EAAE,OAAO,KAAK,GAAG,SAAS,GAAG,WAAW,GAAG,IAAI,CAAC;IACtD,6BAA6B;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6EAA6E;IAC7E,gBAAgB,C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EAAE,CAAC,CAAC;IAE9E;;;;;OAKG;IACH,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,CAAC,CAAC;IAElE;;;;OAIG;IACH,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC9D;AAED,KAAK,WAAW,GAAG;IAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAC,CAAC;AAC/F,MAAM,WAAW,2BAA4B,SAAQ,WAAW;IAC9D,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IACrE,KAAK,CAAC,EAAE,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,KAAK,CAAC,EAAE,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAChC,IAAI,CAAC,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,CAAC,CAAC;CACpF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/loader-utils",
|
|
3
|
-
"version": "3.4.0-alpha.
|
|
3
|
+
"version": "3.4.0-alpha.3",
|
|
4
4
|
"description": "Framework-independent loaders for 3D graphics formats",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"scripts": {},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@babel/runtime": "^7.3.1",
|
|
41
|
-
"@loaders.gl/worker-utils": "3.4.0-alpha.
|
|
41
|
+
"@loaders.gl/worker-utils": "3.4.0-alpha.3",
|
|
42
42
|
"@probe.gl/stats": "^4.0.1"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "a954528dd1d78a1f128d8f6b07e4baeb7a296924"
|
|
45
45
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// loaders.gl MIT license
|
|
2
|
+
|
|
3
|
+
export function getCWD() {
|
|
4
|
+
if (typeof process !== 'undefined' && typeof process.cwd !== 'undefined') {
|
|
5
|
+
return process.cwd();
|
|
6
|
+
}
|
|
7
|
+
const pathname = window.location?.pathname;
|
|
8
|
+
return pathname?.slice(0, pathname.lastIndexOf('/') + 1) || '';
|
|
9
|
+
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
// Beginning of a minimal implementation of the Node.js path API, that doesn't pull in big polyfills.
|
|
2
2
|
|
|
3
|
+
import {getCWD} from './get-cwd';
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* Replacement for Node.js path.filename
|
|
5
7
|
* @param url
|
|
6
8
|
*/
|
|
7
9
|
export function filename(url: string): string {
|
|
8
|
-
const slashIndex = url
|
|
9
|
-
return slashIndex >= 0 ? url.substr(
|
|
10
|
+
const slashIndex = url ? url.lastIndexOf('/') : -1;
|
|
11
|
+
return slashIndex >= 0 ? url.substr(slashIndex + 1) : '';
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
/**
|
|
@@ -14,8 +16,8 @@ export function filename(url: string): string {
|
|
|
14
16
|
* @param url
|
|
15
17
|
*/
|
|
16
18
|
export function dirname(url: string): string {
|
|
17
|
-
const slashIndex = url
|
|
18
|
-
return slashIndex >= 0 ? url.substr(0, slashIndex
|
|
19
|
+
const slashIndex = url ? url.lastIndexOf('/') : -1;
|
|
20
|
+
return slashIndex >= 0 ? url.substr(0, slashIndex) : '';
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
/**
|
|
@@ -35,3 +37,135 @@ export function join(...parts: string[]): string {
|
|
|
35
37
|
});
|
|
36
38
|
return parts.join(separator);
|
|
37
39
|
}
|
|
40
|
+
|
|
41
|
+
/* eslint-disable no-continue */
|
|
42
|
+
|
|
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
|
+
export function resolve(...components: string[]): string {
|
|
51
|
+
const paths: string[] = [];
|
|
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: string | undefined;
|
|
58
|
+
for (let i = paths.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
|
59
|
+
let path: string | undefined;
|
|
60
|
+
if (i >= 0) {
|
|
61
|
+
path = paths[i];
|
|
62
|
+
} else {
|
|
63
|
+
if (cwd === undefined) {
|
|
64
|
+
cwd = getCWD();
|
|
65
|
+
}
|
|
66
|
+
path = cwd;
|
|
67
|
+
}
|
|
68
|
+
// Skip empty entries
|
|
69
|
+
if (path.length === 0) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
resolvedPath = `${path}/${resolvedPath}`;
|
|
73
|
+
resolvedAbsolute = path.charCodeAt(0) === SLASH;
|
|
74
|
+
}
|
|
75
|
+
// At this point the path should be resolved to a full absolute path, but
|
|
76
|
+
// handle relative paths to be safe (might happen when process.cwd() fails)
|
|
77
|
+
// Normalize the path (removes leading slash)
|
|
78
|
+
resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute);
|
|
79
|
+
if (resolvedAbsolute) {
|
|
80
|
+
return `/${resolvedPath}`;
|
|
81
|
+
} else if (resolvedPath.length > 0) {
|
|
82
|
+
return resolvedPath;
|
|
83
|
+
}
|
|
84
|
+
return '.';
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const SLASH = 47;
|
|
88
|
+
const DOT = 46;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Resolves . and .. elements in a path with directory names
|
|
92
|
+
* Forked from BTOdell/path-resolve under MIT license
|
|
93
|
+
* @see https://github.com/BTOdell/path-resolve/blob/master/LICENSE
|
|
94
|
+
*/
|
|
95
|
+
/* eslint-disable max-depth */
|
|
96
|
+
// eslint-disable-next-line complexity, max-statements
|
|
97
|
+
function normalizeStringPosix(path: string, allowAboveRoot: boolean): string {
|
|
98
|
+
let res = '';
|
|
99
|
+
let lastSlash = -1;
|
|
100
|
+
let dots = 0;
|
|
101
|
+
let code: number | undefined;
|
|
102
|
+
let isAboveRoot = false;
|
|
103
|
+
|
|
104
|
+
for (let i = 0; i <= path.length; ++i) {
|
|
105
|
+
if (i < path.length) {
|
|
106
|
+
code = path.charCodeAt(i);
|
|
107
|
+
} else if (code === SLASH) {
|
|
108
|
+
break;
|
|
109
|
+
} else {
|
|
110
|
+
code = SLASH;
|
|
111
|
+
}
|
|
112
|
+
if (code === SLASH) {
|
|
113
|
+
if (lastSlash === i - 1 || dots === 1) {
|
|
114
|
+
// NOOP
|
|
115
|
+
} else if (lastSlash !== i - 1 && dots === 2) {
|
|
116
|
+
if (
|
|
117
|
+
res.length < 2 ||
|
|
118
|
+
!isAboveRoot ||
|
|
119
|
+
res.charCodeAt(res.length - 1) !== DOT ||
|
|
120
|
+
res.charCodeAt(res.length - 2) !== DOT
|
|
121
|
+
) {
|
|
122
|
+
if (res.length > 2) {
|
|
123
|
+
const start = res.length - 1;
|
|
124
|
+
let j = start;
|
|
125
|
+
for (; j >= 0; --j) {
|
|
126
|
+
if (res.charCodeAt(j) === SLASH) {
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (j !== start) {
|
|
131
|
+
res = j === -1 ? '' : res.slice(0, j);
|
|
132
|
+
lastSlash = i;
|
|
133
|
+
dots = 0;
|
|
134
|
+
isAboveRoot = false;
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
} else if (res.length === 2 || res.length === 1) {
|
|
138
|
+
res = '';
|
|
139
|
+
lastSlash = i;
|
|
140
|
+
dots = 0;
|
|
141
|
+
isAboveRoot = false;
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (allowAboveRoot) {
|
|
146
|
+
if (res.length > 0) {
|
|
147
|
+
res += '/..';
|
|
148
|
+
} else {
|
|
149
|
+
res = '..';
|
|
150
|
+
}
|
|
151
|
+
isAboveRoot = true;
|
|
152
|
+
}
|
|
153
|
+
} else {
|
|
154
|
+
const slice = path.slice(lastSlash + 1, i);
|
|
155
|
+
if (res.length > 0) {
|
|
156
|
+
res += `/${slice}`;
|
|
157
|
+
} else {
|
|
158
|
+
res = slice;
|
|
159
|
+
}
|
|
160
|
+
isAboveRoot = false;
|
|
161
|
+
}
|
|
162
|
+
lastSlash = i;
|
|
163
|
+
dots = 0;
|
|
164
|
+
} else if (code === DOT && dots !== -1) {
|
|
165
|
+
++dots;
|
|
166
|
+
} else {
|
|
167
|
+
dots = -1;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return res;
|
|
171
|
+
}
|