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.0-alpha.18 to 4.0.0-alpha.19

4

dist/es5/lib/env-utils/version.js

@@ -8,7 +8,7 @@ "use strict";

var DEFAULT_VERSION = 'beta';
var VERSION = typeof "4.0.0-alpha.18" !== 'undefined' ? "4.0.0-alpha.18" : DEFAULT_VERSION;
var VERSION = typeof "4.0.0-alpha.19" !== 'undefined' ? "4.0.0-alpha.19" : DEFAULT_VERSION;
exports.VERSION = VERSION;
if (typeof "4.0.0-alpha.18" === 'undefined') {
if (typeof "4.0.0-alpha.19" === 'undefined') {
console.error('loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.');
}
//# sourceMappingURL=version.js.map

@@ -19,3 +19,3 @@ "use strict";

var LATEST = 'beta';
var VERSION = typeof "4.0.0-alpha.18" !== 'undefined' ? "4.0.0-alpha.18" : LATEST;
var VERSION = typeof "4.0.0-alpha.19" !== 'undefined' ? "4.0.0-alpha.19" : LATEST;
var loadLibraryPromises = {};

@@ -29,2 +29,3 @@ function loadLibrary(_x) {

options,
libraryName,
_args = arguments;

@@ -36,11 +37,12 @@ return _regenerator.default.wrap(function _callee$(_context) {

options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
libraryName = _args.length > 3 && _args[3] !== undefined ? _args[3] : null;
if (moduleName) {
libraryUrl = getLibraryUrl(libraryUrl, moduleName, options);
libraryUrl = getLibraryUrl(libraryUrl, moduleName, options, libraryName);
}
loadLibraryPromises[libraryUrl] = loadLibraryPromises[libraryUrl] || loadLibraryFromFile(libraryUrl);
_context.next = 6;
_context.next = 7;
return loadLibraryPromises[libraryUrl];
case 6:
case 7:
return _context.abrupt("return", _context.sent);
case 7:
case 8:
case "end":

@@ -53,21 +55,24 @@ return _context.stop();

}
function getLibraryUrl(library, moduleName, options) {
if (library.startsWith('http')) {
function getLibraryUrl(library, moduleName) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var libraryName = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
if (!options.useLocalLibraries && library.startsWith('http')) {
return library;
}
libraryName = libraryName || library;
var modules = options.modules || {};
if (modules[library]) {
return modules[library];
if (modules[libraryName]) {
return modules[libraryName];
}
if (!_globals.isBrowser) {
return "modules/".concat(moduleName, "/dist/libs/").concat(library);
return "modules/".concat(moduleName, "/dist/libs/").concat(libraryName);
}
if (options.CDN) {
(0, _assert.assert)(options.CDN.startsWith('http'));
return "".concat(options.CDN, "/").concat(moduleName, "@").concat(VERSION, "/dist/libs/").concat(library);
return "".concat(options.CDN, "/").concat(moduleName, "@").concat(VERSION, "/dist/libs/").concat(libraryName);
}
if (_globals.isWorker) {
return "../src/libs/".concat(library);
return "../src/libs/".concat(libraryName);
}
return "modules/".concat(moduleName, "/src/libs/").concat(library);
return "modules/".concat(moduleName, "/src/libs/").concat(libraryName);
}

@@ -74,0 +79,0 @@ function loadLibraryFromFile(_x2) {

@@ -12,3 +12,3 @@ "use strict";

var NPM_TAG = 'beta';
var VERSION = typeof "4.0.0-alpha.18" !== 'undefined' ? "4.0.0-alpha.18" : NPM_TAG;
var VERSION = typeof "4.0.0-alpha.19" !== 'undefined' ? "4.0.0-alpha.19" : NPM_TAG;
function getWorkerName(worker) {

@@ -15,0 +15,0 @@ var warning = worker.version !== VERSION ? " (worker-utils@".concat(VERSION, ")") : '';

const DEFAULT_VERSION = 'beta';
export const VERSION = typeof "4.0.0-alpha.18" !== 'undefined' ? "4.0.0-alpha.18" : DEFAULT_VERSION;
if (typeof "4.0.0-alpha.18" === 'undefined') {
export const VERSION = typeof "4.0.0-alpha.19" !== 'undefined' ? "4.0.0-alpha.19" : DEFAULT_VERSION;
if (typeof "4.0.0-alpha.19" === 'undefined') {
console.error('loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.');
}
//# sourceMappingURL=version.js.map

@@ -6,3 +6,3 @@ import { global, isBrowser, isWorker } from '../env-utils/globals';

const LATEST = 'beta';
const VERSION = typeof "4.0.0-alpha.18" !== 'undefined' ? "4.0.0-alpha.18" : LATEST;
const VERSION = typeof "4.0.0-alpha.19" !== 'undefined' ? "4.0.0-alpha.19" : LATEST;
const loadLibraryPromises = {};

@@ -12,4 +12,5 @@ export async function loadLibrary(libraryUrl) {

let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
let libraryName = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
if (moduleName) {
libraryUrl = getLibraryUrl(libraryUrl, moduleName, options);
libraryUrl = getLibraryUrl(libraryUrl, moduleName, options, libraryName);
}

@@ -19,21 +20,24 @@ loadLibraryPromises[libraryUrl] = loadLibraryPromises[libraryUrl] || loadLibraryFromFile(libraryUrl);

}
export function getLibraryUrl(library, moduleName, options) {
if (library.startsWith('http')) {
export function getLibraryUrl(library, moduleName) {
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
let libraryName = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
if (!options.useLocalLibraries && library.startsWith('http')) {
return library;
}
libraryName = libraryName || library;
const modules = options.modules || {};
if (modules[library]) {
return modules[library];
if (modules[libraryName]) {
return modules[libraryName];
}
if (!isBrowser) {
return "modules/".concat(moduleName, "/dist/libs/").concat(library);
return "modules/".concat(moduleName, "/dist/libs/").concat(libraryName);
}
if (options.CDN) {
assert(options.CDN.startsWith('http'));
return "".concat(options.CDN, "/").concat(moduleName, "@").concat(VERSION, "/dist/libs/").concat(library);
return "".concat(options.CDN, "/").concat(moduleName, "@").concat(VERSION, "/dist/libs/").concat(libraryName);
}
if (isWorker) {
return "../src/libs/".concat(library);
return "../src/libs/".concat(libraryName);
}
return "modules/".concat(moduleName, "/src/libs/").concat(library);
return "modules/".concat(moduleName, "/src/libs/").concat(libraryName);
}

@@ -40,0 +44,0 @@ async function loadLibraryFromFile(libraryUrl) {

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

const NPM_TAG = 'beta';
const VERSION = typeof "4.0.0-alpha.18" !== 'undefined' ? "4.0.0-alpha.18" : NPM_TAG;
const VERSION = typeof "4.0.0-alpha.19" !== 'undefined' ? "4.0.0-alpha.19" : NPM_TAG;
export function getWorkerName(worker) {

@@ -8,0 +8,0 @@ const warning = worker.version !== VERSION ? " (worker-utils@".concat(VERSION, ")") : '';

@@ -16,4 +16,4 @@ /**

*/
export declare function loadLibrary(libraryUrl: string, moduleName?: string | null, options?: object): Promise<any>;
export declare function getLibraryUrl(library: string, moduleName?: string, options?: any): string;
export declare function loadLibrary(libraryUrl: string, moduleName?: string | null, options?: object, libraryName?: string | null): Promise<any>;
export declare function getLibraryUrl(library: string, moduleName?: string, options?: any, libraryName?: string | null): string;
//# sourceMappingURL=library-utils.d.ts.map

@@ -54,5 +54,5 @@ "use strict";

*/
async function loadLibrary(libraryUrl, moduleName = null, options = {}) {
async function loadLibrary(libraryUrl, moduleName = null, options = {}, libraryName = null) {
if (moduleName) {
libraryUrl = getLibraryUrl(libraryUrl, moduleName, options);
libraryUrl = getLibraryUrl(libraryUrl, moduleName, options, libraryName);
}

@@ -67,11 +67,12 @@ // Ensure libraries are only loaded once

// TODO - sort out how to resolve paths for main/worker and dev/prod
function getLibraryUrl(library, moduleName, options) {
function getLibraryUrl(library, moduleName, options = {}, libraryName = null) {
// Check if already a URL
if (library.startsWith('http')) {
if (!options.useLocalLibraries && library.startsWith('http')) {
return library;
}
libraryName = libraryName || library;
// Allow application to import and supply libraries through `options.modules`
const modules = options.modules || {};
if (modules[library]) {
return modules[library];
if (modules[libraryName]) {
return modules[libraryName];
}

@@ -81,3 +82,3 @@ // Load from local files, not from CDN scripts in Node.js

if (!globals_1.isBrowser) {
return `modules/${moduleName}/dist/libs/${library}`;
return `modules/${moduleName}/dist/libs/${libraryName}`;
}

@@ -87,9 +88,9 @@ // In browser, load from external scripts

(0, assert_1.assert)(options.CDN.startsWith('http'));
return `${options.CDN}/${moduleName}@${VERSION}/dist/libs/${library}`;
return `${options.CDN}/${moduleName}@${VERSION}/dist/libs/${libraryName}`;
}
// TODO - loading inside workers requires paths relative to worker script location...
if (globals_1.isWorker) {
return `../src/libs/${library}`;
return `../src/libs/${libraryName}`;
}
return `modules/${moduleName}/src/libs/${library}`;
return `modules/${moduleName}/src/libs/${libraryName}`;
}

@@ -96,0 +97,0 @@ exports.getLibraryUrl = getLibraryUrl;

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

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

},
"gitHead": "7bc633f46560f661bdd46cf1015ea27b3694ebce"
"gitHead": "2ca50ec4e1d312c124eb7c93c60ab6fd17ee833e"
}

@@ -34,6 +34,7 @@ /* global importScripts */

moduleName: string | null = null,
options: object = {}
options: object = {},
libraryName: string | null = null
): Promise<any> {
if (moduleName) {
libraryUrl = getLibraryUrl(libraryUrl, moduleName, options);
libraryUrl = getLibraryUrl(libraryUrl, moduleName, options, libraryName);
}

@@ -49,12 +50,19 @@ // Ensure libraries are only loaded once

// TODO - sort out how to resolve paths for main/worker and dev/prod
export function getLibraryUrl(library: string, moduleName?: string, options?: any): string {
export function getLibraryUrl(
library: string,
moduleName?: string,
options: any = {},
libraryName: string | null = null
): string {
// Check if already a URL
if (library.startsWith('http')) {
if (!options.useLocalLibraries && library.startsWith('http')) {
return library;
}
libraryName = libraryName || library;
// Allow application to import and supply libraries through `options.modules`
const modules = options.modules || {};
if (modules[library]) {
return modules[library];
if (modules[libraryName]) {
return modules[libraryName];
}

@@ -65,3 +73,3 @@

if (!isBrowser) {
return `modules/${moduleName}/dist/libs/${library}`;
return `modules/${moduleName}/dist/libs/${libraryName}`;
}

@@ -72,3 +80,3 @@

assert(options.CDN.startsWith('http'));
return `${options.CDN}/${moduleName}@${VERSION}/dist/libs/${library}`;
return `${options.CDN}/${moduleName}@${VERSION}/dist/libs/${libraryName}`;
}

@@ -78,6 +86,6 @@

if (isWorker) {
return `../src/libs/${library}`;
return `../src/libs/${libraryName}`;
}
return `modules/${moduleName}/src/libs/${library}`;
return `modules/${moduleName}/src/libs/${libraryName}`;
}

@@ -84,0 +92,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

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