@loaders.gl/worker-utils
Advanced tools
Comparing version 4.2.0-alpha.6 to 4.2.0-beta.1
@@ -14,3 +14,3 @@ // loaders.gl | ||
// __VERSION__ is injected by babel-plugin-version-inline | ||
if (typeof "4.2.0-alpha.5" === 'undefined') { | ||
if (typeof "4.2.0-alpha.6" === 'undefined') { | ||
// eslint-disable-next-line | ||
@@ -21,3 +21,3 @@ console.warn('loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.'); | ||
else { | ||
globalThis._loadersgl_.version = "4.2.0-alpha.5"; | ||
globalThis._loadersgl_.version = "4.2.0-alpha.6"; | ||
} | ||
@@ -24,0 +24,0 @@ } |
@@ -6,3 +6,2 @@ // loaders.gl | ||
import { isBrowser, isWorker } from "../env-utils/globals.js"; | ||
import * as node from "../node/require-utils.node.js"; | ||
import { assert } from "../env-utils/assert.js"; | ||
@@ -44,2 +43,3 @@ import { VERSION } from "../env-utils/version.js"; | ||
// Allow application to import and supply libraries through `options.modules` | ||
// TODO - See js-module-utils in loader-utils | ||
const modules = options.modules || {}; | ||
@@ -77,3 +77,4 @@ if (modules[libraryName]) { | ||
try { | ||
return node && node.requireFromFile && (await node.requireFromFile(libraryUrl)); | ||
const { requireFromFile } = globalThis.loaders || {}; | ||
return await requireFromFile?.(libraryUrl); | ||
} | ||
@@ -114,3 +115,4 @@ catch (error) { | ||
if (!isBrowser) { | ||
return node.requireFromString && node.requireFromString(scriptSource, id); | ||
const { requireFromString } = globalThis.loaders || {}; | ||
return requireFromString?.(scriptSource, id); | ||
} | ||
@@ -151,7 +153,8 @@ if (isWorker) { | ||
async function loadAsArrayBuffer(url) { | ||
if (isBrowser || !node.readFileAsArrayBuffer || url.startsWith('http')) { | ||
const { readFileAsArrayBuffer } = globalThis.loaders || {}; | ||
if (isBrowser || !readFileAsArrayBuffer || url.startsWith('http')) { | ||
const response = await fetch(url); | ||
return await response.arrayBuffer(); | ||
} | ||
return await node.readFileAsArrayBuffer(url); | ||
return await readFileAsArrayBuffer(url); | ||
} | ||
@@ -164,7 +167,8 @@ /** | ||
async function loadAsText(url) { | ||
if (isBrowser || !node.readFileAsText || url.startsWith('http')) { | ||
const { readFileAsText } = globalThis.loaders || {}; | ||
if (isBrowser || !readFileAsText || url.startsWith('http')) { | ||
const response = await fetch(url); | ||
return await response.text(); | ||
} | ||
return await node.readFileAsText(url); | ||
return await readFileAsText(url); | ||
} |
{ | ||
"name": "@loaders.gl/worker-utils", | ||
"version": "4.2.0-alpha.6", | ||
"version": "4.2.0-beta.1", | ||
"description": "Utilities for running tasks on worker threads", | ||
@@ -55,3 +55,3 @@ "license": "MIT", | ||
}, | ||
"gitHead": "37bd8ca71763529f18727ee4bf29dd176aa914ca" | ||
"gitHead": "c386a9196516fe3ff24847b40e6c77be039cf905" | ||
} |
@@ -7,3 +7,2 @@ // loaders.gl | ||
import {isBrowser, isWorker} from '../env-utils/globals'; | ||
import * as node from '../node/require-utils.node'; | ||
import {assert} from '../env-utils/assert'; | ||
@@ -61,2 +60,3 @@ import {VERSION} from '../env-utils/version'; | ||
// Allow application to import and supply libraries through `options.modules` | ||
// TODO - See js-module-utils in loader-utils | ||
const modules = options.modules || {}; | ||
@@ -100,3 +100,4 @@ if (modules[libraryName]) { | ||
try { | ||
return node && node.requireFromFile && (await node.requireFromFile(libraryUrl)); | ||
const {requireFromFile} = globalThis.loaders || {}; | ||
return await requireFromFile?.(libraryUrl); | ||
} catch (error) { | ||
@@ -139,3 +140,4 @@ console.error(error); // eslint-disable-line no-console | ||
if (!isBrowser) { | ||
return node.requireFromString && node.requireFromString(scriptSource, id); | ||
const {requireFromString} = globalThis.loaders || {}; | ||
return requireFromString?.(scriptSource, id); | ||
} | ||
@@ -179,7 +181,8 @@ | ||
async function loadAsArrayBuffer(url: string): Promise<ArrayBuffer> { | ||
if (isBrowser || !node.readFileAsArrayBuffer || url.startsWith('http')) { | ||
const {readFileAsArrayBuffer} = globalThis.loaders || {}; | ||
if (isBrowser || !readFileAsArrayBuffer || url.startsWith('http')) { | ||
const response = await fetch(url); | ||
return await response.arrayBuffer(); | ||
} | ||
return await node.readFileAsArrayBuffer(url); | ||
return await readFileAsArrayBuffer(url); | ||
} | ||
@@ -193,7 +196,8 @@ | ||
async function loadAsText(url: string): Promise<string> { | ||
if (isBrowser || !node.readFileAsText || url.startsWith('http')) { | ||
const {readFileAsText} = globalThis.loaders || {}; | ||
if (isBrowser || !readFileAsText || url.startsWith('http')) { | ||
const response = await fetch(url); | ||
return await response.text(); | ||
} | ||
return await node.readFileAsText(url); | ||
return await readFileAsText(url); | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
0
10
325162
105
5496