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

@gltf-transform/core

Package Overview
Dependencies
Maintainers
1
Versions
208
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gltf-transform/core - npm Package Compare versions

Comparing version 3.2.0 to 3.2.1

8

dist/io/platform-io.d.ts

@@ -1,2 +0,2 @@

import { Format, VertexLayout } from '../constants.js';
import { VertexLayout } from '../constants.js';
import type { Document } from '../document.js';

@@ -33,3 +33,3 @@ import type { Extension } from '../extension.js';

/** Registers extensions, enabling I/O class to read and write glTF assets requiring them. */
registerExtensions(extensions: typeof Extension[]): this;
registerExtensions(extensions: (typeof Extension)[]): this;
/** Registers dependencies used (e.g. by extensions) in the I/O process. */

@@ -75,6 +75,2 @@ registerDependencies(dependencies: {

*/
/** @hidden */
protected detectFormat(uri: string): Format;
private _readGLTF;
private _readGLB;
private _readResourcesExternal;

@@ -81,0 +77,0 @@ private _readResourcesInternal;

import { PlatformIO } from './platform-io.js';
import { Format } from '../constants.js';
/**

@@ -41,4 +40,2 @@ * # WebIO

protected dirname(uri: string): string;
/** @hidden */
protected detectFormat(uri: string): Format;
}
{
"name": "@gltf-transform/core",
"version": "3.2.0",
"version": "3.2.1",
"repository": "github:donmccurdy/glTF-Transform",

@@ -49,3 +49,3 @@ "homepage": "https://gltf-transform.donmccurdy.com/",

"dependencies": {
"property-graph": "^1.1.0"
"property-graph": "^1.2.0"
},

@@ -55,3 +55,3 @@ "mangle": {

},
"gitHead": "618c506920dd49c49ec36287febac934b3b87d95"
"gitHead": "89108e04aae2de42aa66f31369d8f052c09fccc7"
}

@@ -6,3 +6,3 @@ import { Format, GLB_BUFFER, VertexLayout } from '../constants.js';

import type { GLTF } from '../types/gltf.js';
import { BufferUtils, FileUtils, HTTPUtils, ILogger, Logger, uuid } from '../utils/index.js';
import { BufferUtils, FileUtils, ILogger, Logger, uuid } from '../utils/index.js';
import { GLTFReader } from './reader.js';

@@ -50,3 +50,3 @@ import { GLTFWriter, WriterOptions } from './writer.js';

/** Registers extensions, enabling I/O class to read and write glTF assets requiring them. */
public registerExtensions(extensions: typeof Extension[]): this {
public registerExtensions(extensions: (typeof Extension)[]): this {
for (const extension of extensions) {

@@ -96,4 +96,11 @@ this._extensions.add(extension);

public async readAsJSON(uri: string): Promise<JSONDocument> {
const isGLB = uri.match(/^data:application\/octet-stream;/) || this.detectFormat(uri) === Format.GLB;
return isGLB ? this._readGLB(uri) : this._readGLTF(uri);
const view = await this.readURI(uri, 'view');
this.lastReadBytes = view.byteLength;
const jsonDoc = isGLB(view)
? this._binaryToJSON(view)
: { json: JSON.parse(BufferUtils.decodeText(view)), resources: {} };
// Read external resources first, before Data URIs are replaced.
await this._readResourcesExternal(jsonDoc, this.dirname(uri));
this._readResourcesInternal(jsonDoc);
return jsonDoc;
}

@@ -181,30 +188,2 @@

/** @hidden */
protected detectFormat(uri: string): Format {
// Overriden by WebIO, which only uses HTTPUtils.
const extension = HTTPUtils.isAbsoluteURL(uri) ? HTTPUtils.extension(uri) : FileUtils.extension(uri);
return extension === 'glb' ? Format.GLB : Format.GLTF;
}
private async _readGLTF(uri: string): Promise<JSONDocument> {
this.lastReadBytes = 0;
const jsonContent = await this.readURI(uri, 'text');
this.lastReadBytes += jsonContent.length;
const jsonDoc: JSONDocument = { json: JSON.parse(jsonContent), resources: {} };
// Read external resources first, before Data URIs are replaced.
await this._readResourcesExternal(jsonDoc, this.dirname(uri));
this._readResourcesInternal(jsonDoc);
return jsonDoc;
}
private async _readGLB(uri: string): Promise<JSONDocument> {
const view = await this.readURI(uri, 'view');
this.lastReadBytes = view.byteLength;
const jsonDoc = this._binaryToJSON(view);
// Read external resources first, before Data URIs are replaced.
await this._readResourcesExternal(jsonDoc, this.dirname(uri));
this._readResourcesInternal(jsonDoc);
return jsonDoc;
}
private async _readResourcesExternal(jsonDoc: JSONDocument, base: string): Promise<void> {

@@ -285,7 +264,4 @@ const images = jsonDoc.json.images || [];

// Decode and verify GLB header.
const header = new Uint32Array(glb.buffer, glb.byteOffset, 3);
if (header[0] !== 0x46546c67) {
throw new Error('Invalid glTF asset.');
} else if (header[1] !== 2) {
throw new Error(`Unsupported glTF binary version, "${header[1]}".`);
if (!isGLB(glb)) {
throw new Error('Invalid glTF 2.0 binary.');
}

@@ -331,1 +307,7 @@

}
function isGLB(view: Uint8Array): boolean {
if (view.byteLength < 3 * Uint32Array.BYTES_PER_ELEMENT) return false;
const header = new Uint32Array(view.buffer, view.byteOffset, 3);
return header[0] === 0x46546c67 && header[1] === 2;
}
import { PlatformIO } from './platform-io.js';
import { HTTPUtils } from '../utils/index.js';
import { Format } from '../constants.js';

@@ -63,7 +62,2 @@ /**

}
/** @hidden */
protected detectFormat(uri: string): Format {
return HTTPUtils.extension(uri) === 'glb' ? Format.GLB : Format.GLTF;
}
}

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 too big to display

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