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
319
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 4.0.0-beta.2 to 4.0.0-beta.3

dist/index.cjs

17

dist/index.d.ts

@@ -26,17 +26,14 @@ export type { DataType, SyncDataType, BatchableDataType, TypedArray, BigTypedArray, TypedArrayConstructor, BigTypedArrayConstructor, NumberArray, NumericArray, FetchLike } from './types';

export { path };
import * as fs from './lib/node/fs';
export { fs };
import * as stream from './lib/node/stream';
export { stream };
export type { FileSystem, RandomAccessReadFileSystem } from './lib/filesystems/filesystem';
export { NodeFileSystem as _NodeFileSystem } from './lib/filesystems/node-filesystem';
export type { ReadableFile, WritableFile, Stat } from './lib/files/file';
export { BlobFile } from './lib/files/blob-file';
export { HttpFile } from './lib/files/http-file';
export { NodeFileFacade as NodeFile } from './lib/files/node-file-facade';
export type { FileSystem, RandomAccessFileSystem } from './lib/filesystems/filesystem';
export { NodeFileSystemFacade as NodeFilesystem } from './lib/filesystems/node-filesystem-facade';
export type { FileProvider } from './lib/file-provider/file-provider';
export { isFileProvider } from './lib/file-provider/file-provider';
export { FileHandle } from './lib/file-provider/file-handle';
export { FileHandleFile } from './lib/file-provider/file-handle-file';
export { DataViewFile } from './lib/file-provider/data-view-file';
export type { ReadableFile } from './lib/filesystems/readable-file';
export { makeReadableFile } from './lib/filesystems/readable-file';
export type { WritableFile } from './lib/filesystems/writable-file';
export { makeWritableFile } from './lib/filesystems/writable-file';
export type { Service } from './service-types';

@@ -49,3 +46,3 @@ export type { DataSourceProps } from './lib/sources/data-source';

export { ImageSource } from './lib/sources/image-source';
export type { TileSourceProps, TileSourceMetadata, GetTileParameters } from './lib/sources/tile-source';
export type { TileSourceProps, TileSourceMetadata, GetTileParameters, TileLoadParameters } from './lib/sources/tile-source';
export type { TileSource } from './lib/sources/tile-source';

@@ -52,0 +49,0 @@ export type { ImageTileSource } from './lib/sources/image-tile-source';

import { FileProvider } from './file-provider';
/** Provides file data using DataView */
/**
* Provides file data using DataView
* @deprecated - will be replaced with ReadableFile
*/
export declare class DataViewFile implements FileProvider {

@@ -4,0 +7,0 @@ /** The DataView from which data is provided */

import { FileProvider } from './file-provider';
/**
* Provides file data using node fs library
* @deprecated - will be replaced with ReadableFile
*/
export declare class FileHandleFile implements FileProvider {
/**
* Returns a new copy of FileHandleFile
* @param path The path to the file in file system
*/
static from(path: string): Promise<FileHandleFile>;
/**
* The FileHandle from which data is provided
*/
private fileDescriptor;
/**
* The file length in bytes
*/
/** The FileHandle from which data is provided */
private file;
/** The file length in bytes */
private size;
private constructor();
/** Create a new FileHandleFile */
constructor(path: string);
/** Close file */

@@ -26,3 +19,3 @@ destroy(): Promise<void>;

*/
getUint8(offset: bigint): Promise<number>;
getUint8(offset: number | bigint): Promise<number>;
/**

@@ -32,3 +25,3 @@ * Gets an unsigned 16-bit integer at the specified byte offset from the start of the file.

*/
getUint16(offset: bigint): Promise<number>;
getUint16(offset: number | bigint): Promise<number>;
/**

@@ -38,3 +31,3 @@ * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.

*/
getUint32(offset: bigint): Promise<number>;
getUint32(offset: number | bigint): Promise<number>;
/**

@@ -44,9 +37,9 @@ * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.

*/
getBigUint64(offset: bigint): Promise<bigint>;
getBigUint64(offset: number | bigint): Promise<bigint>;
/**
* returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
* @param startOffsset The offset, in byte, from the start of the file where to start reading the data.
* @param startOffset The offset, in byte, from the start of the file where to start reading the data.
* @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
*/
slice(startOffsset: bigint, endOffset: bigint): Promise<ArrayBuffer>;
slice(startOffset: bigint, endOffset: bigint): Promise<ArrayBuffer>;
/**

@@ -53,0 +46,0 @@ * the length (in bytes) of the data.

/**
* Interface for providing file data
* @deprecated - will be replaced with ReadableFile
*/

@@ -4,0 +5,0 @@ export interface FileProvider {

@@ -1,80 +0,33 @@

export type ReadOptions = {};
export type Stat = {
size: number;
isDirectory: () => boolean;
};
import { ReadableFile, WritableFile } from '../files/file';
/**
* A FileSystem interface can encapsulate various file sources,
* a FileList, a ZipFile, a GoogleDrive etc.
* a FileList, a Node.js filesystem, a ZipFile, a GoogleDrive etc.
*/
export interface FileSystem {
/**
* Return a list of file names
* @param dirname directory name. file system root directory if omitted
*/
/** Return a list of file names in a "directory" */
readdir(dirname?: string, options?: {
recursive?: boolean;
}): Promise<string[]>;
/**
* Gets information from a local file from the filesystem
* @param filename file name to stat
* @param options currently unused
* @throws if filename is not in local filesystem
*/
/** Gets information from a local file from the filesystem */
stat(filename: string, options?: object): Promise<{
size: number;
}>;
/**
* Fetches a local file from the filesystem (or a URL)
* @param filename
* @param options
*/
fetch(filename: RequestInfo, options?: RequestInit): Promise<Response>;
/** Removes a file from the file system */
unlink?(path: string): Promise<void>;
/** Fetches the full contents of a file from the filesystem (or a URL) */
fetch(path: string, options?: RequestInit): Promise<Response>;
}
/**
* A random access file system
* A random access file system, open readable and/or writable files
*/
export interface RandomAccessReadFileSystem extends FileSystem {
open(path: string, flags: unknown, mode?: unknown): Promise<any>;
close(fd: unknown): Promise<void>;
fstat(fd: unknown): Promise<Stat>;
read(fd: any, options?: ReadOptions): Promise<{
bytesRead: number;
buffer: Uint8Array;
}>;
export interface RandomAccessFileSystem extends FileSystem {
/** Can open readable files */
readonly readable: boolean;
/** Can open writable files */
readonly writable: boolean;
/** Open a readable file */
openReadableFile(path: string, flags?: 'r'): Promise<ReadableFile>;
/** Open a writable file */
openWritableFile(path: string, flags?: 'w' | 'wx', mode?: number): Promise<WritableFile>;
}
/**
* A FileSystem interface can encapsulate a FileList, a ZipFile, a GoogleDrive etc.
*
export interface IFileSystem {
/**
* Return a list of file names
* @param dirname directory name. file system root directory if omitted
*
readdir(dirname?: string, options?: {recursive?: boolean}): Promise<string[]>;
/**
* Gets information from a local file from the filesystem
* @param filename file name to stat
* @param options currently unused
* @throws if filename is not in local filesystem
*
stat(filename: string, options?: object): Promise<{size: number}>;
/**
* Fetches a local file from the filesystem (or a URL)
* @param filename
* @param options
*
fetch(filename: string, options?: object): Promise<Response>;
}
type ReadOptions = {buffer?: ArrayBuffer; offset?: number; length?: number; position?: number};
export interface IRandomAccessReadFileSystem extends IFileSystem {
open(path: string, flags: string | number, mode?: any): Promise<any>;
close(fd: any): Promise<void>;
fstat(fd: any): Promise<object>;
read(fd: any, options?: ReadOptions): Promise<{bytesRead: number; buffer: Buffer}>;
}
*/
//# sourceMappingURL=filesystem.d.ts.map

@@ -11,3 +11,3 @@ /// <reference types="node" />

*/
export declare function toBuffer(binaryData: ArrayBuffer | ArrayBuffer | Buffer): Buffer;
export declare function toBuffer(binaryData: ArrayBuffer | Buffer): Buffer;
//# sourceMappingURL=buffer.browser.d.ts.map

@@ -11,3 +11,3 @@ /// <reference types="node" />

*/
export declare function toBuffer(binaryData: ArrayBuffer | ArrayBuffer | Buffer): Buffer;
export declare function toBuffer(binaryData: ArrayBuffer | Buffer): Buffer;
//# sourceMappingURL=buffer.d.ts.map

@@ -1,6 +0,6 @@

export type TypedIntArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Int32Array | Uint32Array;
export type TypedIntArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array;
export type TypedFloatArray = Uint16Array | Float32Array | Float64Array;
export type TypedArray = TypedIntArray | TypedFloatArray;
export type BigTypedArray = TypedArray | BigInt64Array | BigUint64Array;
export type TypedArrayConstructor = Int8ArrayConstructor | Uint8ArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor;
export type TypedArrayConstructor = Int8ArrayConstructor | Uint8ArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor;
export type BigTypedArrayConstructor = TypedArrayConstructor | BigInt64ArrayConstructor | BigUint64ArrayConstructor;

@@ -7,0 +7,0 @@ /** Any numeric array: typed array or `number[]` */

{
"name": "@loaders.gl/loader-utils",
"version": "4.0.0-beta.2",
"version": "4.0.0-beta.3",
"description": "Framework-independent loaders for 3D graphics formats",
"license": "MIT",
"type": "module",
"publishConfig": {

@@ -21,4 +22,11 @@ "access": "public"

"types": "dist/index.d.ts",
"main": "dist/es5/index.js",
"module": "dist/esm/index.js",
"main": "dist/index.cjs",
"module": "dist/index.js",
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.cjs",
"types": "./dist/index.d.ts"
}
},
"sideEffects": false,

@@ -46,6 +54,6 @@ "files": [

"@babel/runtime": "^7.3.1",
"@loaders.gl/worker-utils": "4.0.0-beta.2",
"@loaders.gl/worker-utils": "4.0.0-beta.3",
"@probe.gl/stats": "^4.0.2"
},
"gitHead": "79c2033f755e88e11bc30a04428e3666b177b8fc"
"gitHead": "7ba9621cc51c7a26c407086ac86171f35b8712af"
}

@@ -113,6 +113,2 @@ // loaders.gl, MIT license

// Use instead of importing 'fs' to avoid node dependencies`
import * as fs from './lib/node/fs';
export {fs};
// Use instead of importing 'stream' to avoid node dependencies`

@@ -124,18 +120,16 @@ import * as stream from './lib/node/stream';

export type {FileSystem, RandomAccessReadFileSystem} from './lib/filesystems/filesystem';
export {NodeFileSystem as _NodeFileSystem} from './lib/filesystems/node-filesystem';
export type {ReadableFile, WritableFile, Stat} from './lib/files/file';
export {BlobFile} from './lib/files/blob-file';
export {HttpFile} from './lib/files/http-file';
export {NodeFileFacade as NodeFile} from './lib/files/node-file-facade';
export type {FileSystem, RandomAccessFileSystem} from './lib/filesystems/filesystem';
export {NodeFileSystemFacade as NodeFilesystem} from './lib/filesystems/node-filesystem-facade';
// TODO - replace with ReadableFile
export type {FileProvider} from './lib/file-provider/file-provider';
export {isFileProvider} from './lib/file-provider/file-provider';
export {FileHandle} from './lib/file-provider/file-handle';
export {FileHandleFile} from './lib/file-provider/file-handle-file';
export {DataViewFile} from './lib/file-provider/data-view-file';
export type {ReadableFile} from './lib/filesystems/readable-file';
export {makeReadableFile} from './lib/filesystems/readable-file';
export type {WritableFile} from './lib/filesystems/writable-file';
export {makeWritableFile} from './lib/filesystems/writable-file';
// EXPERIMENTAL: DATA SOURCES

@@ -155,3 +149,4 @@ export type {Service} from './service-types';

TileSourceMetadata,
GetTileParameters
GetTileParameters,
TileLoadParameters
} from './lib/sources/tile-source';

@@ -158,0 +153,0 @@ export type {TileSource} from './lib/sources/tile-source';

@@ -15,3 +15,6 @@ import {FileProvider} from './file-provider';

/** Provides file data using DataView */
/**
* Provides file data using DataView
* @deprecated - will be replaced with ReadableFile
*/
export class DataViewFile implements FileProvider {

@@ -25,3 +28,2 @@ /** The DataView from which data is provided */

// eslint-disable-next-line @typescript-eslint/no-empty-function
async destroy(): Promise<void> {}

@@ -28,0 +30,0 @@

@@ -0,32 +1,21 @@

// loaders.gl, MIT license
import {FileProvider} from './file-provider';
import {FileHandle} from './file-handle';
import {resolvePath} from '../path-utils/file-aliases';
import {NodeFileFacade as NodeFile} from '../files/node-file-facade';
/**
* Provides file data using node fs library
* @deprecated - will be replaced with ReadableFile
*/
export class FileHandleFile implements FileProvider {
/**
* Returns a new copy of FileHandleFile
* @param path The path to the file in file system
*/
static async from(path: string): Promise<FileHandleFile> {
path = resolvePath(path);
const fileDescriptor = await FileHandle.open(path);
return new FileHandleFile(fileDescriptor, fileDescriptor.stat.size);
}
/** The FileHandle from which data is provided */
private file: NodeFile;
/**
* The FileHandle from which data is provided
*/
private fileDescriptor: FileHandle;
/**
* The file length in bytes
*/
/** The file length in bytes */
private size: bigint;
private constructor(fileDescriptor: FileHandle, size: bigint) {
this.fileDescriptor = fileDescriptor;
this.size = size;
/** Create a new FileHandleFile */
constructor(path: string) {
this.file = new NodeFile(path, 'r');
this.size = this.file.bigsize;
}

@@ -36,3 +25,3 @@

async destroy(): Promise<void> {
await this.fileDescriptor.close();
await this.file.close();
}

@@ -44,6 +33,5 @@

*/
async getUint8(offset: bigint): Promise<number> {
const val = new Uint8Array(
(await this.fileDescriptor.read(Buffer.alloc(1), 0, 1, offset)).buffer.buffer
).at(0);
async getUint8(offset: number | bigint): Promise<number> {
const arrayBuffer = await this.file.read(offset, 1);
const val = new Uint8Array(arrayBuffer).at(0);
if (val === undefined) {

@@ -59,6 +47,5 @@ throw new Error('something went wrong');

*/
async getUint16(offset: bigint): Promise<number> {
const val = new Uint16Array(
(await this.fileDescriptor.read(Buffer.alloc(2), 0, 2, offset)).buffer.buffer
).at(0);
async getUint16(offset: number | bigint): Promise<number> {
const arrayBuffer = await this.file.read(offset, 2);
const val = new Uint16Array(arrayBuffer).at(0);
if (val === undefined) {

@@ -74,6 +61,5 @@ throw new Error('something went wrong');

*/
async getUint32(offset: bigint): Promise<number> {
const val = new Uint32Array(
(await this.fileDescriptor.read(Buffer.alloc(4), 0, 4, offset)).buffer.buffer
).at(0);
async getUint32(offset: number | bigint): Promise<number> {
const arrayBuffer = await this.file.read(offset, 4);
const val = new Uint32Array(arrayBuffer).at(0);
if (val === undefined) {

@@ -89,6 +75,5 @@ throw new Error('something went wrong');

*/
async getBigUint64(offset: bigint): Promise<bigint> {
const val = new BigInt64Array(
(await this.fileDescriptor.read(Buffer.alloc(8), 0, 8, offset)).buffer.buffer
).at(0);
async getBigUint64(offset: number | bigint): Promise<bigint> {
const arrayBuffer = await this.file.read(offset, 8);
const val = new BigInt64Array(arrayBuffer).at(0);
if (val === undefined) {

@@ -102,7 +87,7 @@ throw new Error('something went wrong');

* returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
* @param startOffsset The offset, in byte, from the start of the file where to start reading the data.
* @param startOffset The offset, in byte, from the start of the file where to start reading the data.
* @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
*/
async slice(startOffsset: bigint, endOffset: bigint): Promise<ArrayBuffer> {
const bigLength = endOffset - startOffsset;
async slice(startOffset: bigint, endOffset: bigint): Promise<ArrayBuffer> {
const bigLength = endOffset - startOffset;
if (bigLength > Number.MAX_SAFE_INTEGER) {

@@ -112,4 +97,3 @@ throw new Error('too big slice');

const length = Number(bigLength);
return (await this.fileDescriptor.read(Buffer.alloc(length), 0, length, startOffsset)).buffer
.buffer;
return await this.file.read(startOffset, length);
}

@@ -116,0 +100,0 @@

/**
* Interface for providing file data
* @deprecated - will be replaced with ReadableFile
*/

@@ -4,0 +5,0 @@ export interface FileProvider {

// loaders.gl, MIT license
export type ReadOptions = {};
import {ReadableFile, WritableFile} from '../files/file';
export type Stat = {
size: number;
isDirectory: () => boolean;
};
/**
* A FileSystem interface can encapsulate various file sources,
* a FileList, a ZipFile, a GoogleDrive etc.
* a FileList, a Node.js filesystem, a ZipFile, a GoogleDrive etc.
*/
export interface FileSystem {
/**
* Return a list of file names
* @param dirname directory name. file system root directory if omitted
*/
/** Return a list of file names in a "directory" */
readdir(dirname?: string, options?: {recursive?: boolean}): Promise<string[]>;
/**
* Gets information from a local file from the filesystem
* @param filename file name to stat
* @param options currently unused
* @throws if filename is not in local filesystem
*/
/** Gets information from a local file from the filesystem */
stat(filename: string, options?: object): Promise<{size: number}>;
/**
* Fetches a local file from the filesystem (or a URL)
* @param filename
* @param options
*/
fetch(filename: RequestInfo, options?: RequestInit): Promise<Response>;
/** Removes a file from the file system */
unlink?(path: string): Promise<void>;
/** Fetches the full contents of a file from the filesystem (or a URL) */
fetch(path: string, options?: RequestInit): Promise<Response>;
}
/**
* A random access file system
* A random access file system, open readable and/or writable files
*/
export interface RandomAccessReadFileSystem extends FileSystem {
open(path: string, flags: unknown, mode?: unknown): Promise<any>;
close(fd: unknown): Promise<void>;
fstat(fd: unknown): Promise<Stat>;
read(fd: any, options?: ReadOptions): Promise<{bytesRead: number; buffer: Uint8Array}>;
// read(
// fd: any,
// buffer: ArrayBuffer | ArrayBufferView,
// offset?: number,
// length?: number,
// position?: number
// ): Promise<{bytesRead: number; buffer: ArrayBuffer}>;
}
export interface RandomAccessFileSystem extends FileSystem {
/** Can open readable files */
readonly readable: boolean;
/**
* A FileSystem interface can encapsulate a FileList, a ZipFile, a GoogleDrive etc.
*
export interface IFileSystem {
/**
* Return a list of file names
* @param dirname directory name. file system root directory if omitted
*
readdir(dirname?: string, options?: {recursive?: boolean}): Promise<string[]>;
/** Can open writable files */
readonly writable: boolean;
/**
* Gets information from a local file from the filesystem
* @param filename file name to stat
* @param options currently unused
* @throws if filename is not in local filesystem
*
stat(filename: string, options?: object): Promise<{size: number}>;
/** Open a readable file */
openReadableFile(path: string, flags?: 'r'): Promise<ReadableFile>;
/**
* Fetches a local file from the filesystem (or a URL)
* @param filename
* @param options
*
fetch(filename: string, options?: object): Promise<Response>;
/** Open a writable file */
openWritableFile(path: string, flags?: 'w' | 'wx', mode?: number): Promise<WritableFile>;
}
type ReadOptions = {buffer?: ArrayBuffer; offset?: number; length?: number; position?: number};
export interface IRandomAccessReadFileSystem extends IFileSystem {
open(path: string, flags: string | number, mode?: any): Promise<any>;
close(fd: any): Promise<void>;
fstat(fd: any): Promise<object>;
read(fd: any, options?: ReadOptions): Promise<{bytesRead: number; buffer: Buffer}>;
}
*/

@@ -18,4 +18,4 @@ // loaders.gl, MIT license

*/
export function toBuffer(binaryData: ArrayBuffer | ArrayBuffer | Buffer): Buffer {
export function toBuffer(binaryData: ArrayBuffer | Buffer): Buffer {
throw new Error('Buffer not supported in browser');
}

@@ -23,3 +23,3 @@ // loaders.gl, MIT license

*/
export function toBuffer(binaryData: ArrayBuffer | ArrayBuffer | Buffer): Buffer {
export function toBuffer(binaryData: ArrayBuffer | Buffer): Buffer {
if (Buffer.isBuffer(binaryData)) {

@@ -26,0 +26,0 @@ return binaryData;

@@ -10,4 +10,2 @@ // Typed arrays

| Int32Array
| Uint32Array
| Int32Array
| Uint32Array;

@@ -28,4 +26,2 @@

| Uint32ArrayConstructor
| Int32ArrayConstructor
| Uint32ArrayConstructor
| Float32ArrayConstructor

@@ -32,0 +28,0 @@ | Float64ArrayConstructor;

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