@loaders.gl/core
Advanced tools
Comparing version 4.0.1 to 4.0.2
@@ -24,3 +24,3 @@ import { concatenateArrayBuffers } from '@loaders.gl/loader-utils'; | ||
} | ||
if (writer.text && (writer.encode || writer.encodeInBatches)) { | ||
if (writer.text) { | ||
const arrayBuffer = await encodeTable(data, writer, options); | ||
@@ -27,0 +27,0 @@ return new TextDecoder().decode(arrayBuffer); |
@@ -54,3 +54,3 @@ import { canEncodeWithWorker } from '@loaders.gl/loader-utils'; | ||
} | ||
if (writer.text && (writer.encode || writer.encodeInBatches)) { | ||
if (writer.text) { | ||
const arrayBuffer = await encode(data, writer, options); | ||
@@ -57,0 +57,0 @@ return new TextDecoder().decode(arrayBuffer); |
@@ -39,3 +39,3 @@ "use strict"; | ||
// ../worker-utils/src/lib/worker-farm/worker-body.ts | ||
function getParentPort() { | ||
async function getParentPort() { | ||
let parentPort; | ||
@@ -46,2 +46,9 @@ try { | ||
} catch { | ||
try { | ||
eval("globalThis.workerThreadsPromise = import('worker_threads')"); | ||
const workerThreads = await globalThis.workerThreadsPromise; | ||
parentPort = workerThreads.parentPort; | ||
} catch (error) { | ||
console.error(error.message); | ||
} | ||
} | ||
@@ -53,4 +60,4 @@ return parentPort; | ||
/** Check that we are actually in a worker thread */ | ||
static inWorkerThread() { | ||
return typeof self !== "undefined" || Boolean(getParentPort()); | ||
static async inWorkerThread() { | ||
return typeof self !== "undefined" || Boolean(await getParentPort()); | ||
} | ||
@@ -61,23 +68,24 @@ /* | ||
static set onmessage(onMessage) { | ||
function handleMessage(message) { | ||
const parentPort3 = getParentPort(); | ||
const { type, payload } = parentPort3 ? message : message.data; | ||
async function handleMessage(message) { | ||
const parentPort2 = await getParentPort(); | ||
const { type, payload } = parentPort2 ? message : message.data; | ||
onMessage(type, payload); | ||
} | ||
const parentPort2 = getParentPort(); | ||
if (parentPort2) { | ||
parentPort2.on("message", handleMessage); | ||
parentPort2.on("exit", () => console.debug("Node worker closing")); | ||
} else { | ||
globalThis.onmessage = handleMessage; | ||
} | ||
getParentPort().then((parentPort2) => { | ||
if (parentPort2) { | ||
parentPort2.on("message", handleMessage); | ||
parentPort2.on("exit", () => console.debug("Node worker closing")); | ||
} else { | ||
globalThis.onmessage = handleMessage; | ||
} | ||
}); | ||
} | ||
static addEventListener(onMessage) { | ||
static async addEventListener(onMessage) { | ||
let onMessageWrapper = onMessageWrapperMap.get(onMessage); | ||
if (!onMessageWrapper) { | ||
onMessageWrapper = (message) => { | ||
onMessageWrapper = async (message) => { | ||
if (!isKnownMessage(message)) { | ||
return; | ||
} | ||
const parentPort3 = getParentPort(); | ||
const parentPort3 = await getParentPort(); | ||
const { type, payload } = parentPort3 ? message : message.data; | ||
@@ -87,3 +95,3 @@ onMessage(type, payload); | ||
} | ||
const parentPort2 = getParentPort(); | ||
const parentPort2 = await getParentPort(); | ||
if (parentPort2) { | ||
@@ -95,6 +103,6 @@ console.error("not implemented"); | ||
} | ||
static removeEventListener(onMessage) { | ||
static async removeEventListener(onMessage) { | ||
const onMessageWrapper = onMessageWrapperMap.get(onMessage); | ||
onMessageWrapperMap.delete(onMessage); | ||
const parentPort2 = getParentPort(); | ||
const parentPort2 = await getParentPort(); | ||
if (parentPort2) { | ||
@@ -111,6 +119,6 @@ console.error("not implemented"); | ||
*/ | ||
static postMessage(type, payload) { | ||
static async postMessage(type, payload) { | ||
const data = { source: "loaders.gl", type, payload }; | ||
const transferList = getTransferList(payload); | ||
const parentPort2 = getParentPort(); | ||
const parentPort2 = await getParentPort(); | ||
if (parentPort2) { | ||
@@ -130,4 +138,4 @@ parentPort2.postMessage(data, transferList); | ||
var requestId = 0; | ||
function createLoaderWorker(loader) { | ||
if (!WorkerBody.inWorkerThread()) { | ||
async function createLoaderWorker(loader) { | ||
if (!await WorkerBody.inWorkerThread()) { | ||
return; | ||
@@ -211,3 +219,3 @@ } | ||
// src/null-loader.ts | ||
var VERSION = true ? "4.0.1" : "latest"; | ||
var VERSION = true ? "4.0.2" : "latest"; | ||
var NullLoader = { | ||
@@ -214,0 +222,0 @@ name: "Null loader", |
@@ -39,3 +39,3 @@ "use strict"; | ||
// ../worker-utils/src/lib/worker-farm/worker-body.ts | ||
function getParentPort() { | ||
async function getParentPort() { | ||
let parentPort; | ||
@@ -46,2 +46,9 @@ try { | ||
} catch { | ||
try { | ||
eval("globalThis.workerThreadsPromise = import('worker_threads')"); | ||
const workerThreads = await globalThis.workerThreadsPromise; | ||
parentPort = workerThreads.parentPort; | ||
} catch (error) { | ||
console.error(error.message); | ||
} | ||
} | ||
@@ -53,4 +60,4 @@ return parentPort; | ||
/** Check that we are actually in a worker thread */ | ||
static inWorkerThread() { | ||
return typeof self !== "undefined" || Boolean(getParentPort()); | ||
static async inWorkerThread() { | ||
return typeof self !== "undefined" || Boolean(await getParentPort()); | ||
} | ||
@@ -61,23 +68,24 @@ /* | ||
static set onmessage(onMessage) { | ||
function handleMessage(message) { | ||
const parentPort3 = getParentPort(); | ||
const { type, payload } = parentPort3 ? message : message.data; | ||
async function handleMessage(message) { | ||
const parentPort2 = await getParentPort(); | ||
const { type, payload } = parentPort2 ? message : message.data; | ||
onMessage(type, payload); | ||
} | ||
const parentPort2 = getParentPort(); | ||
if (parentPort2) { | ||
parentPort2.on("message", handleMessage); | ||
parentPort2.on("exit", () => console.debug("Node worker closing")); | ||
} else { | ||
globalThis.onmessage = handleMessage; | ||
} | ||
getParentPort().then((parentPort2) => { | ||
if (parentPort2) { | ||
parentPort2.on("message", handleMessage); | ||
parentPort2.on("exit", () => console.debug("Node worker closing")); | ||
} else { | ||
globalThis.onmessage = handleMessage; | ||
} | ||
}); | ||
} | ||
static addEventListener(onMessage) { | ||
static async addEventListener(onMessage) { | ||
let onMessageWrapper = onMessageWrapperMap.get(onMessage); | ||
if (!onMessageWrapper) { | ||
onMessageWrapper = (message) => { | ||
onMessageWrapper = async (message) => { | ||
if (!isKnownMessage(message)) { | ||
return; | ||
} | ||
const parentPort3 = getParentPort(); | ||
const parentPort3 = await getParentPort(); | ||
const { type, payload } = parentPort3 ? message : message.data; | ||
@@ -87,3 +95,3 @@ onMessage(type, payload); | ||
} | ||
const parentPort2 = getParentPort(); | ||
const parentPort2 = await getParentPort(); | ||
if (parentPort2) { | ||
@@ -95,6 +103,6 @@ console.error("not implemented"); | ||
} | ||
static removeEventListener(onMessage) { | ||
static async removeEventListener(onMessage) { | ||
const onMessageWrapper = onMessageWrapperMap.get(onMessage); | ||
onMessageWrapperMap.delete(onMessage); | ||
const parentPort2 = getParentPort(); | ||
const parentPort2 = await getParentPort(); | ||
if (parentPort2) { | ||
@@ -111,6 +119,6 @@ console.error("not implemented"); | ||
*/ | ||
static postMessage(type, payload) { | ||
static async postMessage(type, payload) { | ||
const data = { source: "loaders.gl", type, payload }; | ||
const transferList = getTransferList(payload); | ||
const parentPort2 = getParentPort(); | ||
const parentPort2 = await getParentPort(); | ||
if (parentPort2) { | ||
@@ -130,4 +138,4 @@ parentPort2.postMessage(data, transferList); | ||
var requestId = 0; | ||
function createLoaderWorker(loader) { | ||
if (!WorkerBody.inWorkerThread()) { | ||
async function createLoaderWorker(loader) { | ||
if (!await WorkerBody.inWorkerThread()) { | ||
return; | ||
@@ -211,3 +219,3 @@ } | ||
// src/null-loader.ts | ||
var VERSION = true ? "4.0.1" : "latest"; | ||
var VERSION = true ? "4.0.2" : "latest"; | ||
var NullLoader = { | ||
@@ -214,0 +222,0 @@ name: "Null loader", |
{ | ||
"name": "@loaders.gl/core", | ||
"version": "4.0.1", | ||
"version": "4.0.2", | ||
"description": "The core API for working with loaders.gl loaders and writers", | ||
@@ -52,7 +52,7 @@ "license": "MIT", | ||
"@babel/runtime": "^7.3.1", | ||
"@loaders.gl/loader-utils": "4.0.1", | ||
"@loaders.gl/worker-utils": "4.0.1", | ||
"@loaders.gl/loader-utils": "4.0.2", | ||
"@loaders.gl/worker-utils": "4.0.2", | ||
"@probe.gl/log": "^4.0.2" | ||
}, | ||
"gitHead": "765e5a26a6bf3f2cc02cabffc4a1e3665ec92a53" | ||
"gitHead": "471058d109d5652f28c32c1f296fd632f9a5c806" | ||
} |
@@ -48,3 +48,3 @@ // loaders.gl, MIT license | ||
if (writer.text && (writer.encode || writer.encodeInBatches)) { | ||
if (writer.text) { | ||
const arrayBuffer = await encodeTable(data, writer, options); | ||
@@ -51,0 +51,0 @@ return new TextDecoder().decode(arrayBuffer); |
@@ -100,3 +100,3 @@ // loaders.gl, MIT license | ||
if (writer.text && (writer.encode || writer.encodeInBatches)) { | ||
if (writer.text) { | ||
const arrayBuffer = await encode(data, writer, options); | ||
@@ -103,0 +103,0 @@ return new TextDecoder().decode(arrayBuffer); |
Sorry, the diff of this file is too big to display
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
573722
229
10405
+ Added@loaders.gl/loader-utils@4.0.2(transitive)
+ Added@loaders.gl/worker-utils@4.0.2(transitive)
- Removed@loaders.gl/loader-utils@4.0.1(transitive)
- Removed@loaders.gl/worker-utils@4.0.1(transitive)