Socket
Socket
Sign inDemoInstall

@loaders.gl/worker-utils

Package Overview
Dependencies
Maintainers
7
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 3.1.0-alpha.4 to 4.0.0-alpha.1

dist/index.js

8

dist/null-worker.js

@@ -90,5 +90,5 @@ /******/ (function(modules) { // webpackBootstrap

/***/ "../../node_modules/@babel/runtime/helpers/defineProperty.js":
/*!****************************************************************************************!*\
!*** /home/user/apps/loaders.gl/node_modules/@babel/runtime/helpers/defineProperty.js ***!
\****************************************************************************************/
/*!**************************************************************************************************!*\
!*** /home/user/apps/loaders.gl_duplicate/node_modules/@babel/runtime/helpers/defineProperty.js ***!
\**************************************************************************************************/
/*! no static exports found */

@@ -317,3 +317,3 @@ /***/ (function(module, exports) {

options = payload.options || {};
const resultIterator = processInBatches(inputBatches, options, context === null || context === void 0 ? void 0 : context.processInBatches);
const resultIterator = processInBatches(inputBatches, options, context);

@@ -320,0 +320,0 @@ for await (const batch of resultIterator) {

{
"name": "@loaders.gl/worker-utils",
"version": "3.1.0-alpha.4",
"version": "4.0.0-alpha.1",
"description": "Utilities for running tasks on worker threads",

@@ -19,4 +19,4 @@ "license": "MIT",

"types": "src/index.ts",
"main": "dist/es5/index.js",
"module": "dist/esm/index.js",
"main": "dist/index.js",
"module": "dist/index.js",
"sideEffects": false,

@@ -31,3 +31,3 @@ "files": [

"fs": false,
"./src/lib/node/require-utils.node.js": false,
"./src/lib/node/require-utils.node.ts": false,
"./dist/es5/lib/node/require-utils.node.js": false,

@@ -42,3 +42,3 @@ "./dist/esm/lib/node/require-utils.node.js": false,

"pre-build-disabled": "npm run build-bundle && npm run build-workers",
"build-bundle": "webpack --config ../../scripts/webpack/bundle.ts",
"build-bundle": "esbuild src/bundle.ts --outfile=dist/bundle.js",
"build-workers": "webpack --entry ./src/workers/null-worker.ts --output ./dist/null-worker.js --env.dev --config ../../scripts/webpack/worker.js"

@@ -49,3 +49,3 @@ },

},
"gitHead": "e309784af37ef9f3640c7733c7851124c72e1fa3"
"gitHead": "e48f5534fe7188c810f23f965a440c144b3cf6d0"
}

@@ -6,3 +6,3 @@ // Version constant cannot be imported, it needs to correspond to the build version of **this** module.

const DEFAULT_VERSION = 'beta';
declare let __VERSION__;
declare let __VERSION__: string;
export const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : DEFAULT_VERSION;

@@ -9,0 +9,0 @@ if (typeof __VERSION__ === 'undefined') {

@@ -11,3 +11,3 @@ /* global importScripts */

const loadLibraryPromises = {}; // promises
const loadLibraryPromises: Record<string, Promise<any>> = {}; // promises

@@ -39,3 +39,5 @@ /**

// Ensure libraries are only loaded once
loadLibraryPromises[libraryUrl] =
// eslint-disable-next-line @typescript-eslint/no-misused-promises
loadLibraryPromises[libraryUrl] || loadLibraryFromFile(libraryUrl);

@@ -46,3 +48,3 @@ return await loadLibraryPromises[libraryUrl];

// TODO - sort out how to resolve paths for main/worker and dev/prod
export function getLibraryUrl(library, moduleName?: string, options?): string {
export function getLibraryUrl(library: string, moduleName?: string, options?: any): string {
// Check if already a URL

@@ -79,3 +81,3 @@ if (library.startsWith('http')) {

async function loadLibraryFromFile(libraryUrl) {
async function loadLibraryFromFile(libraryUrl: string): Promise<any> {
if (libraryUrl.endsWith('wasm')) {

@@ -120,3 +122,3 @@ const response = await fetch(libraryUrl);

// we could create a`LibraryLoader` or`ModuleLoader`
function loadLibraryFromString(scriptSource, id) {
function loadLibraryFromString(scriptSource: string, id: string): null | any {
if (!isBrowser) {

@@ -123,0 +125,0 @@ return node.requireFromString && node.requireFromString(scriptSource, id);

@@ -47,3 +47,3 @@ /* eslint-disable no-console */

private port: number = 0;
private successTimer?;
private successTimer?: any; // NodeJS.Timeout;

@@ -50,0 +50,0 @@ // constructor(props?: {id?: string});

@@ -14,6 +14,10 @@ import type {

let requestId = 0;
let inputBatches;
let options;
let inputBatches: AsyncQueue<any>;
let options: {[key: string]: any};
export type ProcessOnMainThread = (data: any, options?: {[key: string]: any}, context?) => any;
export type ProcessOnMainThread = (
data: any,
options?: {[key: string]: any},
context?: WorkerContext
) => any;

@@ -49,5 +53,5 @@ /**

}
inputBatches = new AsyncQueue();
inputBatches = new AsyncQueue<any>();
options = payload.options || {};
const resultIterator = processInBatches(inputBatches, options, context?.processInBatches);
const resultIterator = processInBatches(inputBatches, options, context);
for await (const batch of resultIterator) {

@@ -76,3 +80,3 @@ WorkerBody.postMessage('output-batch', {result: batch});

function processOnMainThread(arrayBuffer, options = {}) {
function processOnMainThread(arrayBuffer: ArrayBuffer, options = {}) {
return new Promise((resolve, reject) => {

@@ -83,3 +87,3 @@ const id = requestId++;

*/
const onMessage = (type, payload) => {
const onMessage = (type: string, payload: WorkerMessagePayload) => {
if (payload.id !== id) {

@@ -86,0 +90,0 @@ // not ours

@@ -83,3 +83,3 @@ import type {

// Worker encountered an error
job.error(payload.error);
job.error(new Error(payload.error));
break;

@@ -86,0 +86,0 @@

@@ -32,3 +32,3 @@ import type {WorkerMessageData, WorkerMessageType, WorkerMessagePayload} from '../../types';

if (!onMessageWrapper) {
onMessageWrapper = (message) => {
onMessageWrapper = (message: MessageEvent<any>) => {
if (!isKnownMessage(message)) {

@@ -74,3 +74,3 @@ return;

// Filter out noise messages sent to workers
function isKnownMessage(message) {
function isKnownMessage(message: MessageEvent<any>) {
const {type, data} = message;

@@ -77,0 +77,0 @@ return (

@@ -45,3 +45,3 @@ import type {WorkerMessageType, WorkerMessagePayload} from '../../types';

*/
done(value): void {
done(value: any): void {
assert(this.isRunning);

@@ -55,3 +55,3 @@ this.isRunning = false;

*/
error(error): void {
error(error: Error): void {
assert(this.isRunning);

@@ -58,0 +58,0 @@ this.isRunning = false;

@@ -76,3 +76,3 @@ import {assert} from '../env-utils/assert';

*/
_getErrorFromErrorEvent(event) {
_getErrorFromErrorEvent(event: ErrorEvent): Error {
// Note Error object does not have the expected fields if loading failed completely

@@ -109,3 +109,3 @@ // https://developer.mozilla.org/en-US/docs/Web/API/Worker#Event_handlers

// This callback represents an uncaught exception in the worker thread
worker.onerror = (error) => {
worker.onerror = (error: ErrorEvent): void => {
this.onError(this._getErrorFromErrorEvent(error));

@@ -112,0 +112,0 @@ this.terminated = true;

@@ -43,3 +43,3 @@ // NOTE - there is a copy of this function is both in core and loader-utils

// https://developer.mozilla.org/en-US/docs/Web/API/Transferable
function isTransferable(object) {
function isTransferable(object: unknown) {
if (!object) {

@@ -46,0 +46,0 @@ return false;

@@ -12,3 +12,3 @@ /**

function stringifyJSON(v) {
function stringifyJSON(v: unknown) {
const cache = new Set();

@@ -15,0 +15,0 @@ return JSON.stringify(v, (key, value) => {

@@ -17,3 +17,3 @@ /**

process?: Process;
processInBatches?;
processInBatches?: ProcessInBatches;
};

@@ -20,0 +20,0 @@

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