Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@loaders.gl/loader-utils

Package Overview
Dependencies
Maintainers
9
Versions
320
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 1.3.3 to 2.0.0-alpha.1

dist/es5/lib/get-first-characters.js

28

dist/es5/index.js

@@ -32,2 +32,8 @@ "use strict";

});
Object.defineProperty(exports, "getZeroOffsetArrayBuffer", {
enumerable: true,
get: function get() {
return _memoryCopyUtils.getZeroOffsetArrayBuffer;
}
});
Object.defineProperty(exports, "copyPaddedArrayBufferToDataView", {

@@ -63,2 +69,20 @@ enumerable: true,

});
Object.defineProperty(exports, "getFirstCharacters", {
enumerable: true,
get: function get() {
return _getFirstCharacters.getFirstCharacters;
}
});
Object.defineProperty(exports, "getMagicString", {
enumerable: true,
get: function get() {
return _getFirstCharacters.getMagicString;
}
});
Object.defineProperty(exports, "parseJSON", {
enumerable: true,
get: function get() {
return _parseJson.parseJSON;
}
});
Object.defineProperty(exports, "_getMeshSize", {

@@ -85,2 +109,6 @@ enumerable: true,

var _getFirstCharacters = require("./lib/get-first-characters");
var _parseJson = require("./lib/parse-json");
var _meshUtils = require("./categories/mesh/mesh-utils");

@@ -87,0 +115,0 @@

@@ -7,2 +7,3 @@ "use strict";

exports.padTo4Bytes = padTo4Bytes;
exports.getZeroOffsetArrayBuffer = getZeroOffsetArrayBuffer;
exports.copyArrayBuffer = copyArrayBuffer;

@@ -15,2 +16,8 @@ exports.copyToArray = copyToArray;

function getZeroOffsetArrayBuffer(arrayBuffer, byteOffset, byteLength) {
var subArray = byteLength ? new Uint8Array(arrayBuffer).subarray(byteOffset, byteOffset + byteLength) : new Uint8Array(arrayBuffer).subarray(byteOffset);
var arrayCopy = new Uint8Array(subArray);
return arrayCopy.buffer;
}
function copyArrayBuffer(targetBuffer, sourceBuffer, byteOffset) {

@@ -17,0 +24,0 @@ var byteLength = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : sourceBuffer.byteLength;

127

dist/es5/worker-utils/create-worker.js

@@ -21,4 +21,45 @@ "use strict";

var requestId = 0;
var parse = function parse(arraybuffer) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var url = arguments.length > 2 ? arguments[2] : undefined;
return new Promise(function (resolve, reject) {
var id = requestId++;
var onMessage = function onMessage(_ref) {
var data = _ref.data;
if (!data || data.id !== id) {
return;
}
switch (data.type) {
case 'process-done':
self.removeEventListener('message', onMessage);
resolve(data.result);
break;
case 'process-error':
self.removeEventListener('message', onMessage);
reject(data.message);
break;
default:
}
};
self.addEventListener('message', onMessage);
self.postMessage({
type: 'process',
id: id,
arraybuffer: arraybuffer,
options: options,
url: url
}, [arraybuffer]);
});
};
self.onmessage = function () {
var _ref = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(evt) {
var _ref2 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(evt) {
var data, arraybuffer, _data$byteOffset, byteOffset, _data$byteLength, byteLength, _data$options, options, result, transferList;

@@ -43,3 +84,12 @@

_context.next = 7;
return parseData(loader, arraybuffer, byteOffset, byteLength, options);
return parseData({
loader: loader,
arraybuffer: arraybuffer,
byteOffset: byteOffset,
byteLength: byteLength,
options: options,
context: {
parse: parse
}
});

@@ -73,49 +123,8 @@ case 7:

return function (_x) {
return _ref.apply(this, arguments);
return _ref2.apply(this, arguments);
};
}();
var requestId = 0;
self.parse = function (arraybuffer) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var url = arguments.length > 2 ? arguments[2] : undefined;
return new Promise(function (resolve, reject) {
var id = requestId++;
var onMessage = function onMessage(_ref2) {
var data = _ref2.data;
if (!data || data.id !== id) {
return;
}
switch (data.type) {
case 'process-done':
self.removeEventListener('message', onMessage);
resolve(data.result);
break;
case 'process-error':
self.removeEventListener('message', onMessage);
reject(data.message);
break;
default:
}
};
self.addEventListener('message', onMessage);
self.postMessage({
type: 'process',
id: id,
arraybuffer: arraybuffer,
options: options,
url: url
}, [arraybuffer]);
});
};
}
function parseData(_x2, _x3, _x4, _x5, _x6) {
function parseData(_x2) {
return _parseData.apply(this, arguments);

@@ -125,4 +134,4 @@ }

function _parseData() {
_parseData = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2(loader, arraybuffer, byteOffset, byteLength, options) {
var data, parser, textDecoder;
_parseData = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2(_ref3) {
var loader, arraybuffer, byteOffset, byteLength, options, context, data, parser, textDecoder;
return _regenerator["default"].wrap(function _callee2$(_context2) {

@@ -132,4 +141,6 @@ while (1) {

case 0:
loader = _ref3.loader, arraybuffer = _ref3.arraybuffer, byteOffset = _ref3.byteOffset, byteLength = _ref3.byteLength, options = _ref3.options, context = _ref3.context;
if (!(loader.parseSync || loader.parse)) {
_context2.next = 5;
_context2.next = 6;
break;

@@ -140,8 +151,8 @@ }

parser = loader.parseSync || loader.parse;
_context2.next = 12;
_context2.next = 13;
break;
case 5:
case 6:
if (!loader.parseTextSync) {
_context2.next = 11;
_context2.next = 12;
break;

@@ -153,16 +164,16 @@ }

parser = loader.parseTextSync;
_context2.next = 12;
_context2.next = 13;
break;
case 11:
case 12:
throw new Error("Could not load data with ".concat(loader.name, " loader"));
case 12:
_context2.next = 14;
return parser(data, options);
case 13:
_context2.next = 15;
return parser(data, options, context, loader);
case 14:
case 15:
return _context2.abrupt("return", _context2.sent);
case 15:
case 16:
case "end":

@@ -169,0 +180,0 @@ return _context2.stop();

export { default as createWorker } from './worker-utils/create-worker';
export { padTo4Bytes, copyToArray, copyArrayBuffer } from './lib/memory-copy-utils';
export { padTo4Bytes, copyToArray, copyArrayBuffer, getZeroOffsetArrayBuffer } from './lib/memory-copy-utils';
export { copyPaddedArrayBufferToDataView, copyPaddedStringToDataView } from './lib/binary-copy-utils';
export { padStringToByteAlignment, copyStringToDataView, copyBinaryToDataView } from './lib/encode-utils';
export { getFirstCharacters, getMagicString } from './lib/get-first-characters';
export { parseJSON } from './lib/parse-json';
export { getMeshSize as _getMeshSize } from './categories/mesh/mesh-utils';
export { default as assert } from './lib/utils/assert';
//# sourceMappingURL=index.js.map
export function padTo4Bytes(byteLength) {
return byteLength + 3 & ~3;
}
export function getZeroOffsetArrayBuffer(arrayBuffer, byteOffset, byteLength) {
const subArray = byteLength ? new Uint8Array(arrayBuffer).subarray(byteOffset, byteOffset + byteLength) : new Uint8Array(arrayBuffer).subarray(byteOffset);
const arrayCopy = new Uint8Array(subArray);
return arrayCopy.buffer;
}
export function copyArrayBuffer(targetBuffer, sourceBuffer, byteOffset, byteLength = sourceBuffer.byteLength) {

@@ -5,0 +10,0 @@ const targetArray = new Uint8Array(targetBuffer, byteOffset, byteLength);

@@ -7,35 +7,5 @@ import getTransferList from './get-transfer-list';

self.onmessage = async evt => {
const {
data
} = evt;
try {
if (!isKnownMessage(data, loader.name)) {
return;
}
const {
arraybuffer,
byteOffset = 0,
byteLength = 0,
options = {}
} = data;
const result = await parseData(loader, arraybuffer, byteOffset, byteLength, options);
const transferList = getTransferList(result);
self.postMessage({
type: 'done',
result
}, transferList);
} catch (error) {
self.postMessage({
type: 'error',
message: error.message
});
}
};
let requestId = 0;
self.parse = (arraybuffer, options = {}, url) => new Promise((resolve, reject) => {
const parse = (arraybuffer, options = {}, url) => new Promise((resolve, reject) => {
const id = requestId++;

@@ -74,5 +44,51 @@

});
self.onmessage = async evt => {
const {
data
} = evt;
try {
if (!isKnownMessage(data, loader.name)) {
return;
}
const {
arraybuffer,
byteOffset = 0,
byteLength = 0,
options = {}
} = data;
const result = await parseData({
loader,
arraybuffer,
byteOffset,
byteLength,
options,
context: {
parse
}
});
const transferList = getTransferList(result);
self.postMessage({
type: 'done',
result
}, transferList);
} catch (error) {
self.postMessage({
type: 'error',
message: error.message
});
}
};
}
async function parseData(loader, arraybuffer, byteOffset, byteLength, options) {
async function parseData({
loader,
arraybuffer,
byteOffset,
byteLength,
options,
context
}) {
let data;

@@ -92,3 +108,3 @@ let parser;

return await parser(data, options);
return await parser(data, options, context, loader);
}

@@ -95,0 +111,0 @@

export { default as createWorker } from './worker-utils/create-worker';
export { padTo4Bytes, copyToArray, copyArrayBuffer } from './lib/memory-copy-utils';
export { padTo4Bytes, copyToArray, copyArrayBuffer, getZeroOffsetArrayBuffer } from './lib/memory-copy-utils';
export { copyPaddedArrayBufferToDataView, copyPaddedStringToDataView } from './lib/binary-copy-utils';
export { padStringToByteAlignment, copyStringToDataView, copyBinaryToDataView } from './lib/encode-utils';
export { getFirstCharacters, getMagicString } from './lib/get-first-characters';
export { parseJSON } from './lib/parse-json';
export { getMeshSize as _getMeshSize } from './categories/mesh/mesh-utils';
export { default as assert } from './lib/utils/assert';
//# sourceMappingURL=index.js.map
export function padTo4Bytes(byteLength) {
return byteLength + 3 & ~3;
}
export function getZeroOffsetArrayBuffer(arrayBuffer, byteOffset, byteLength) {
var subArray = byteLength ? new Uint8Array(arrayBuffer).subarray(byteOffset, byteOffset + byteLength) : new Uint8Array(arrayBuffer).subarray(byteOffset);
var arrayCopy = new Uint8Array(subArray);
return arrayCopy.buffer;
}
export function copyArrayBuffer(targetBuffer, sourceBuffer, byteOffset) {

@@ -5,0 +10,0 @@ var byteLength = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : sourceBuffer.byteLength;

@@ -9,4 +9,45 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";

var requestId = 0;
var parse = function parse(arraybuffer) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var url = arguments.length > 2 ? arguments[2] : undefined;
return new Promise(function (resolve, reject) {
var id = requestId++;
var onMessage = function onMessage(_ref) {
var data = _ref.data;
if (!data || data.id !== id) {
return;
}
switch (data.type) {
case 'process-done':
self.removeEventListener('message', onMessage);
resolve(data.result);
break;
case 'process-error':
self.removeEventListener('message', onMessage);
reject(data.message);
break;
default:
}
};
self.addEventListener('message', onMessage);
self.postMessage({
type: 'process',
id: id,
arraybuffer: arraybuffer,
options: options,
url: url
}, [arraybuffer]);
});
};
self.onmessage = function () {
var _ref = _asyncToGenerator(_regeneratorRuntime.mark(function _callee(evt) {
var _ref2 = _asyncToGenerator(_regeneratorRuntime.mark(function _callee(evt) {
var data, arraybuffer, _data$byteOffset, byteOffset, _data$byteLength, byteLength, _data$options, options, result, transferList;

@@ -31,3 +72,12 @@

_context.next = 7;
return parseData(loader, arraybuffer, byteOffset, byteLength, options);
return parseData({
loader: loader,
arraybuffer: arraybuffer,
byteOffset: byteOffset,
byteLength: byteLength,
options: options,
context: {
parse: parse
}
});

@@ -61,49 +111,8 @@ case 7:

return function (_x) {
return _ref.apply(this, arguments);
return _ref2.apply(this, arguments);
};
}();
var requestId = 0;
self.parse = function (arraybuffer) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var url = arguments.length > 2 ? arguments[2] : undefined;
return new Promise(function (resolve, reject) {
var id = requestId++;
var onMessage = function onMessage(_ref2) {
var data = _ref2.data;
if (!data || data.id !== id) {
return;
}
switch (data.type) {
case 'process-done':
self.removeEventListener('message', onMessage);
resolve(data.result);
break;
case 'process-error':
self.removeEventListener('message', onMessage);
reject(data.message);
break;
default:
}
};
self.addEventListener('message', onMessage);
self.postMessage({
type: 'process',
id: id,
arraybuffer: arraybuffer,
options: options,
url: url
}, [arraybuffer]);
});
};
}
function parseData(_x2, _x3, _x4, _x5, _x6) {
function parseData(_x2) {
return _parseData.apply(this, arguments);

@@ -113,4 +122,4 @@ }

function _parseData() {
_parseData = _asyncToGenerator(_regeneratorRuntime.mark(function _callee2(loader, arraybuffer, byteOffset, byteLength, options) {
var data, parser, textDecoder;
_parseData = _asyncToGenerator(_regeneratorRuntime.mark(function _callee2(_ref3) {
var loader, arraybuffer, byteOffset, byteLength, options, context, data, parser, textDecoder;
return _regeneratorRuntime.wrap(function _callee2$(_context2) {

@@ -120,4 +129,6 @@ while (1) {

case 0:
loader = _ref3.loader, arraybuffer = _ref3.arraybuffer, byteOffset = _ref3.byteOffset, byteLength = _ref3.byteLength, options = _ref3.options, context = _ref3.context;
if (!(loader.parseSync || loader.parse)) {
_context2.next = 5;
_context2.next = 6;
break;

@@ -128,8 +139,8 @@ }

parser = loader.parseSync || loader.parse;
_context2.next = 12;
_context2.next = 13;
break;
case 5:
case 6:
if (!loader.parseTextSync) {
_context2.next = 11;
_context2.next = 12;
break;

@@ -141,16 +152,16 @@ }

parser = loader.parseTextSync;
_context2.next = 12;
_context2.next = 13;
break;
case 11:
case 12:
throw new Error("Could not load data with ".concat(loader.name, " loader"));
case 12:
_context2.next = 14;
return parser(data, options);
case 13:
_context2.next = 15;
return parser(data, options, context, loader);
case 14:
case 15:
return _context2.abrupt("return", _context2.sent);
case 15:
case 16:
case "end":

@@ -157,0 +168,0 @@ return _context2.stop();

{
"name": "@loaders.gl/loader-utils",
"version": "1.3.3",
"version": "2.0.0-alpha.1",
"description": "Framework-independent loaders for 3D graphics formats",

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

},
"gitHead": "6a8d559e11613dc1dd94a12e4ea5df05c0184ae6"
"gitHead": "cff57d05c0495fa661119005cffd886ed6ed1025"
}

@@ -5,3 +5,8 @@ // WORKER UTILS

// MEMORY COPY UTILS
export {padTo4Bytes, copyToArray, copyArrayBuffer} from './lib/memory-copy-utils';
export {
padTo4Bytes,
copyToArray,
copyArrayBuffer,
getZeroOffsetArrayBuffer
} from './lib/memory-copy-utils';
export {copyPaddedArrayBufferToDataView, copyPaddedStringToDataView} from './lib/binary-copy-utils';

@@ -14,2 +19,6 @@ export {

export {getFirstCharacters, getMagicString} from './lib/get-first-characters';
export {parseJSON} from './lib/parse-json';
// MESH CATEGORY UTILS

@@ -16,0 +25,0 @@ export {getMeshSize as _getMeshSize} from './categories/mesh/mesh-utils';

@@ -5,2 +5,11 @@ export function padTo4Bytes(byteLength) {

// Copy a view of an ArrayBuffer into new ArrayBuffer with byteOffset = 0
export function getZeroOffsetArrayBuffer(arrayBuffer, byteOffset, byteLength) {
const subArray = byteLength
? new Uint8Array(arrayBuffer).subarray(byteOffset, byteOffset + byteLength)
: new Uint8Array(arrayBuffer).subarray(byteOffset);
const arrayCopy = new Uint8Array(subArray);
return arrayCopy.buffer;
}
/* Creates a new Uint8Array based on two different ArrayBuffers

@@ -7,0 +16,0 @@ * @private

@@ -12,22 +12,4 @@ /* eslint-disable no-restricted-globals */

self.onmessage = async evt => {
const {data} = evt;
try {
if (!isKnownMessage(data, loader.name)) {
return;
}
const {arraybuffer, byteOffset = 0, byteLength = 0, options = {}} = data;
const result = await parseData(loader, arraybuffer, byteOffset, byteLength, options);
const transferList = getTransferList(result);
self.postMessage({type: 'done', result}, transferList);
} catch (error) {
self.postMessage({type: 'error', message: error.message});
}
};
let requestId = 0;
self.parse = (arraybuffer, options = {}, url) =>
const parse = (arraybuffer, options = {}, url) =>
new Promise((resolve, reject) => {

@@ -60,2 +42,27 @@ const id = requestId++;

});
self.onmessage = async evt => {
const {data} = evt;
try {
if (!isKnownMessage(data, loader.name)) {
return;
}
const {arraybuffer, byteOffset = 0, byteLength = 0, options = {}} = data;
const result = await parseData({
loader,
arraybuffer,
byteOffset,
byteLength,
options,
context: {parse}
});
const transferList = getTransferList(result);
self.postMessage({type: 'done', result}, transferList);
} catch (error) {
self.postMessage({type: 'error', message: error.message});
}
};
}

@@ -67,3 +74,3 @@

// TODO - Lack of appropriate parser functions can be detected when we create worker, no need to wait until parse
async function parseData(loader, arraybuffer, byteOffset, byteLength, options) {
async function parseData({loader, arraybuffer, byteOffset, byteLength, options, context}) {
let data;

@@ -82,3 +89,3 @@ let parser;

return await parser(data, options);
return await parser(data, options, context, loader);
}

@@ -85,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

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