Socket
Socket
Sign inDemoInstall

@loaders.gl/worker-utils

Package Overview
Dependencies
Maintainers
9
Versions
198
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@loaders.gl/worker-utils - npm Package Compare versions

Comparing version 4.0.3 to 4.0.4

1

dist/index.d.ts

@@ -10,2 +10,3 @@ import type { WorkerObject } from './types';

export { default as WorkerBody } from './lib/worker-farm/worker-body';
export type { ProcessOnWorkerOptions } from './lib/worker-api/process-on-worker';
export { processOnWorker, canProcessOnWorker } from './lib/worker-api/process-on-worker';

@@ -12,0 +13,0 @@ export { createWorker } from './lib/worker-api/create-worker';

10

dist/lib/node/worker_threads-browser.d.ts

@@ -1,7 +0,11 @@

export declare class Worker {
/** Browser polyfill for Node.js built-in `worker_threads` module.
* These fills are non-functional, and just intended to ensure that
* `import 'worker_threads` doesn't break browser builds.
* The replacement is done in package.json browser field
*/
export declare class NodeWorker {
terminate(): void;
}
export { Worker as NodeWorker };
export { Worker as NodeWorkerType };
export type { NodeWorker as NodeWorkerType };
export declare const parentPort: null;
//# sourceMappingURL=worker_threads-browser.d.ts.map

@@ -1,7 +0,5 @@

export class Worker {
export class NodeWorker {
terminate() {}
}
export { Worker as NodeWorker };
export { Worker as NodeWorkerType };
export const parentPort = null;
//# sourceMappingURL=worker_threads-browser.js.map
/// <reference types="node" />
import * as WorkerThreads from 'worker_threads';
export * from 'worker_threads';
export declare const parentPort: WorkerThreads.MessagePort | null;
export declare const NodeWorker: typeof WorkerThreads.Worker;
export type NodeWorkerType = WorkerThreads.Worker;
//# sourceMappingURL=worker_threads.d.ts.map
import * as WorkerThreads from 'worker_threads';
export * from 'worker_threads';
export const parentPort = WorkerThreads === null || WorkerThreads === void 0 ? void 0 : WorkerThreads.parentPort;
export const NodeWorker = WorkerThreads.Worker;
//# sourceMappingURL=worker_threads.js.map
import type { WorkerObject, WorkerOptions, WorkerContext } from '../../types';
type ProcessOnWorkerOptions = WorkerOptions & {
/** Options for worker processing */
export type ProcessOnWorkerOptions = WorkerOptions & {
jobName?: string;

@@ -19,3 +20,2 @@ [key: string]: any;

export declare function processOnWorker(worker: WorkerObject, data: any, options?: ProcessOnWorkerOptions, context?: WorkerContext): Promise<any>;
export {};
//# sourceMappingURL=process-on-worker.d.ts.map
import { getTransferList } from "../worker-utils/get-transfer-list.js";
import { parentPort } from "../node/worker_threads.js";
async function getParentPort() {
let parentPort;
try {
eval('globalThis.parentPort = require(\'worker_threads\').parentPort');
parentPort = globalThis.parentPort;
} catch {
try {
eval('globalThis.workerThreadsPromise = import(\'worker_threads\')');
const workerThreads = await globalThis.workerThreadsPromise;
parentPort = workerThreads.parentPort;
} catch (error) {
console.error(error.message);
}
}
return parentPort;

@@ -17,0 +5,0 @@ }

"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));

@@ -105,17 +132,15 @@ // src/lib/async-queue/async-queue.ts

// src/lib/node/worker_threads.ts
var worker_threads_exports = {};
__export(worker_threads_exports, {
NodeWorker: () => NodeWorker,
parentPort: () => parentPort
});
var WorkerThreads = __toESM(require("worker_threads"), 1);
__reExport(worker_threads_exports, require("worker_threads"));
var parentPort = WorkerThreads == null ? void 0 : WorkerThreads.parentPort;
var NodeWorker = WorkerThreads.Worker;
// src/lib/worker-farm/worker-body.ts
async function getParentPort() {
let parentPort;
try {
eval("globalThis.parentPort = require('worker_threads').parentPort");
parentPort = globalThis.parentPort;
} catch {
try {
eval("globalThis.workerThreadsPromise = import('worker_threads')");
const workerThreads = await globalThis.workerThreadsPromise;
parentPort = workerThreads.parentPort;
} catch (error) {
console.error(error.message);
}
}
return parentPort;

@@ -122,0 +147,0 @@ }

@@ -108,17 +108,7 @@ "use strict";

// src/lib/node/worker_threads-browser.ts
var parentPort = null;
// src/lib/worker-farm/worker-body.ts
async function getParentPort() {
let parentPort;
try {
eval("globalThis.parentPort = require('worker_threads').parentPort");
parentPort = globalThis.parentPort;
} catch {
try {
eval("globalThis.workerThreadsPromise = import('worker_threads')");
const workerThreads = await globalThis.workerThreadsPromise;
parentPort = workerThreads.parentPort;
} catch (error) {
console.error(error.message);
}
}
return parentPort;

@@ -125,0 +115,0 @@ }

{
"name": "@loaders.gl/worker-utils",
"version": "4.0.3",
"version": "4.0.4",
"description": "Utilities for running tasks on worker threads",

@@ -55,3 +55,3 @@ "license": "MIT",

},
"gitHead": "03c871839b36c997249dabae1844df53a35d3760"
"gitHead": "4dc810fa04bb400f4aedfef98a83c7ef882ed3d7"
}

@@ -0,1 +1,4 @@

// loaders.gl, MIT license
// Copyright (c) vis.gl contributors
import type {WorkerObject} from './types';

@@ -28,2 +31,4 @@ import {VERSION} from './lib/env-utils/version';

// PROCESS ON WORKER
export type {ProcessOnWorkerOptions} from './lib/worker-api/process-on-worker';
export {processOnWorker, canProcessOnWorker} from './lib/worker-api/process-on-worker';

@@ -30,0 +35,0 @@ export {createWorker} from './lib/worker-api/create-worker';

@@ -0,1 +1,4 @@

// loaders.gl, MIT license
// Copyright (c) vis.gl contributors
// From https://github.com/rauschma/async-iter-demo/tree/master/src under MIT license

@@ -2,0 +5,0 @@ // http://2ality.com/2016/10/asynchronous-iteration.html

@@ -0,1 +1,4 @@

// loaders.gl, MIT license
// Copyright (c) vis.gl contributors
// Replacement for the external assert method to reduce bundle size

@@ -2,0 +5,0 @@ // Note: We don't use the second "message" argument in calling code,

@@ -0,1 +1,4 @@

// loaders.gl, MIT license
// Copyright (c) vis.gl contributors
// Purpose: include this in your module to avoids adding dependencies on

@@ -2,0 +5,0 @@ // micro modules like 'global' and 'is-browser';

@@ -0,1 +1,4 @@

// loaders.gl, MIT license
// Copyright (c) vis.gl contributors
// Version constant cannot be imported, it needs to correspond to the build version of **this** module.

@@ -2,0 +5,0 @@

@@ -0,1 +1,4 @@

// loaders.gl, MIT license
// Copyright (c) vis.gl contributors
/* global importScripts */

@@ -2,0 +5,0 @@ import {isBrowser, isWorker} from '../env-utils/globals';

@@ -0,1 +1,4 @@

// loaders.gl, MIT license
// Copyright (c) vis.gl contributors
// Fork of https://github.com/floatdrop/require-from-string/blob/master/index.js

@@ -2,0 +5,0 @@ // Copyright (c) Vsevolod Strukchinsky <floatdrop@gmail.com> (github.com/floatdrop)

@@ -1,12 +0,15 @@

// Browser fills for Node.js built-in `worker_threads` module.
// These fills are non-functional, and just intended to ensure that
// `import 'worker_threads` doesn't break browser builds.
// The replacement is done in package.json browser field
export class Worker {
// loaders.gl, MIT license
// Copyright (c) vis.gl contributors
/** Browser polyfill for Node.js built-in `worker_threads` module.
* These fills are non-functional, and just intended to ensure that
* `import 'worker_threads` doesn't break browser builds.
* The replacement is done in package.json browser field
*/
export class NodeWorker {
terminate() {}
}
export {Worker as NodeWorker};
export {Worker as NodeWorkerType};
export type {NodeWorker as NodeWorkerType};
export const parentPort = null;

@@ -6,3 +6,4 @@ // loaders.gl, MIT license

export * from 'worker_threads';
export const parentPort = WorkerThreads?.parentPort;
export const NodeWorker = WorkerThreads.Worker;
export type NodeWorkerType = WorkerThreads.Worker;

@@ -0,1 +1,4 @@

// loaders.gl, MIT license
// Copyright (c) vis.gl contributors
/* eslint-disable no-console */

@@ -2,0 +5,0 @@ // Avoid using named imports for Node builtins to help with "empty" resolution

@@ -0,1 +1,4 @@

// loaders.gl, MIT license
// Copyright (c) vis.gl contributors
import ChildProcess from 'child_process';

@@ -2,0 +5,0 @@

@@ -0,1 +1,4 @@

// loaders.gl, MIT license
// Copyright (c) vis.gl contributors
import type {

@@ -2,0 +5,0 @@ WorkerMessageType,

// loaders.gl, MIT license
// Copyright (c) vis.gl contributors
// loaders.gl, MIT license
// Copyright (c) vis.gl contributors
import type {WorkerObject, WorkerOptions} from '../../types';

@@ -5,0 +8,0 @@ import {assert} from '../env-utils/assert';

@@ -0,1 +1,4 @@

// loaders.gl, MIT license
// Copyright (c) vis.gl contributors
import type {

@@ -13,3 +16,4 @@ WorkerObject,

type ProcessOnWorkerOptions = WorkerOptions & {
/** Options for worker processing */
export type ProcessOnWorkerOptions = WorkerOptions & {
jobName?: string;

@@ -16,0 +20,0 @@ [key: string]: any;

@@ -0,1 +1,4 @@

// loaders.gl, MIT license
// Copyright (c) vis.gl contributors
import type {WorkerObject} from '../../types';

@@ -2,0 +5,0 @@ import {assert} from '../env-utils/assert';

@@ -0,3 +1,7 @@

// loaders.gl, MIT license
// Copyright (c) vis.gl contributors
import type {WorkerMessageData, WorkerMessageType, WorkerMessagePayload} from '../../types';
import {getTransferList} from '../worker-utils/get-transfer-list';
import {TransferListItem, parentPort} from '../node/worker_threads';

@@ -7,17 +11,17 @@ /** Vile hack to defeat over-zealous bundlers from stripping out the require */

// const isNode = globalThis.process;
let parentPort;
try {
// prettier-ignore
eval('globalThis.parentPort = require(\'worker_threads\').parentPort'); // eslint-disable-line no-eval
parentPort = globalThis.parentPort;
} catch {
try {
// prettier-ignore
eval('globalThis.workerThreadsPromise = import(\'worker_threads\')'); // eslint-disable-line no-eval
const workerThreads = await globalThis.workerThreadsPromise;
parentPort = workerThreads.parentPort;
} catch (error) {
console.error((error as Error).message); // eslint-disable-line no-console
}
}
// let parentPort;
// try {
// // prettier-ignore
// eval('globalThis.parentPort = require(\'worker_threads\').parentPort'); // eslint-disable-line no-eval
// parentPort = globalThis.parentPort;
// } catch {
// try {
// // prettier-ignore
// eval('globalThis.workerThreadsPromise = import(\'worker_threads\')'); // eslint-disable-line no-eval
// const workerThreads = await globalThis.workerThreadsPromise;
// parentPort = workerThreads.parentPort;
// } catch (error) {
// console.error((error as Error).message); // eslint-disable-line no-console
// }
// }
return parentPort;

@@ -111,4 +115,6 @@ }

// console.log('posting message', data);
const transferList = getTransferList(payload);
// Cast to Node compatible transfer list
const transferList = getTransferList(payload) as TransferListItem[];
const parentPort = await getParentPort();

@@ -119,3 +125,3 @@ if (parentPort) {

} else {
// @ts-ignore
// @ts-expect-error Outside of worker scopes this call has a third parameter
globalThis.postMessage(data, transferList);

@@ -122,0 +128,0 @@ }

@@ -0,1 +1,4 @@

// loaders.gl, MIT license
// Copyright (c) vis.gl contributors
import WorkerPool from './worker-pool';

@@ -2,0 +5,0 @@ import WorkerThread from './worker-thread';

@@ -0,1 +1,4 @@

// loaders.gl, MIT license
// Copyright (c) vis.gl contributors
import type {WorkerMessageType, WorkerMessagePayload} from '../../types';

@@ -2,0 +5,0 @@ import WorkerThread from './worker-thread';

@@ -0,1 +1,4 @@

// loaders.gl, MIT license
// Copyright (c) vis.gl contributors
import type {WorkerMessageType, WorkerMessagePayload} from '../../types';

@@ -2,0 +5,0 @@ import {isMobile, isBrowser} from '../env-utils/globals';

@@ -0,1 +1,4 @@

// loaders.gl, MIT license
// Copyright (c) vis.gl contributors
import {assert} from '../env-utils/assert';

@@ -2,0 +5,0 @@

@@ -0,1 +1,4 @@

// loaders.gl, MIT license
// Copyright (c) vis.gl contributors
// NOTE - there is a copy of this function is both in core and loader-utils

@@ -2,0 +5,0 @@ // core does not need all the utils in loader-utils, just this one.

@@ -0,1 +1,4 @@

// loaders.gl, MIT license
// Copyright (c) vis.gl contributors
/**

@@ -2,0 +5,0 @@ * Recursively drop non serializable values like functions and regexps.

@@ -0,1 +1,4 @@

// loaders.gl, MIT license
// Copyright (c) vis.gl contributors
/**

@@ -2,0 +5,0 @@ * Worker Options

@@ -0,1 +1,4 @@

// loaders.gl, MIT license
// Copyright (c) vis.gl contributors
import {createWorker} from '../lib/worker-api/create-worker';

@@ -2,0 +5,0 @@

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc