Socket
Socket
Sign inDemoInstall

ktx-parse

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ktx-parse - npm Package Compare versions

Comparing version 0.5.0 to 0.6.0

1

dist/buffer-reader.d.ts

@@ -11,4 +11,5 @@ export declare class BufferReader {

_nextInt32(): number;
_nextUint8Array(len: number): Uint8Array;
_skip(bytes: number): this;
_scan(maxByteLength: number, term?: number): Uint8Array;
}

25

dist/ktx-parse.esm.js

@@ -343,2 +343,8 @@ ///////////////////////////////////////////////////

_nextUint8Array(len) {
const value = new Uint8Array(this._dataView.buffer, this._dataView.byteOffset + this._offset, len);
this._offset += len;
return value;
}
_skip(bytes) {

@@ -371,3 +377,3 @@ this._offset += bytes;

///////////////////////////////////////////////////
const KTX_WRITER = "KTX-Parse v" + "0.5.0";
const KTX_WRITER = "KTX-Parse v" + "0.6.0";
const NUL = new Uint8Array([0x00]); ///////////////////////////////////////////////////

@@ -548,8 +554,13 @@ // KTX2 Header.

const key = decodeText(keyData);
container.keyValue[key] = kvdReader._nextUint8Array(keyValueByteLength - keyData.byteLength - 1);
const valueData = kvdReader._scan(keyValueByteLength - keyData.byteLength);
if (key.match(/^ktx/i)) {
const text = decodeText(container.keyValue[key]);
container.keyValue[key] = text.substring(0, text.lastIndexOf('\x00'));
}
container.keyValue[key] = key.match(/^ktx/i) ? decodeText(valueData) : valueData; // 4-byte alignment.
const kvPadding = keyValueByteLength % 4 ? 4 - keyValueByteLength % 4 : 0; // align(4)
// 4-byte alignment.
if (kvdReader._offset % 4) kvdReader._skip(4 - kvdReader._offset % 4);
kvdReader._skip(kvPadding);
} ///////////////////////////////////////////////////

@@ -673,7 +684,7 @@ // Supercompression Global Data (SGD).

const keyData = encodeText(key);
const valueData = typeof value === 'string' ? encodeText(value) : value;
const kvByteLength = keyData.byteLength + 1 + valueData.byteLength + 1;
const valueData = typeof value === 'string' ? concat([encodeText(value), NUL]) : value;
const kvByteLength = keyData.byteLength + 1 + valueData.byteLength;
const kvPadding = kvByteLength % 4 ? 4 - kvByteLength % 4 : 0; // align(4)
keyValueData.push(concat([new Uint32Array([kvByteLength]), keyData, NUL, valueData, NUL, new Uint8Array(kvPadding).fill(0x00) // align(4)
keyValueData.push(concat([new Uint32Array([kvByteLength]), keyData, NUL, valueData, new Uint8Array(kvPadding).fill(0x00) // align(4)
]));

@@ -680,0 +691,0 @@ }

@@ -343,2 +343,8 @@ ///////////////////////////////////////////////////

_nextUint8Array(len) {
const value = new Uint8Array(this._dataView.buffer, this._dataView.byteOffset + this._offset, len);
this._offset += len;
return value;
}
_skip(bytes) {

@@ -367,3 +373,3 @@ this._offset += bytes;

///////////////////////////////////////////////////
const KTX_WRITER = `KTX-Parse v${"0.5.0"}`;
const KTX_WRITER = `KTX-Parse v${"0.6.0"}`;
const NUL = new Uint8Array([0x00]); ///////////////////////////////////////////////////

@@ -544,8 +550,13 @@ // KTX2 Header.

const key = decodeText(keyData);
container.keyValue[key] = kvdReader._nextUint8Array(keyValueByteLength - keyData.byteLength - 1);
const valueData = kvdReader._scan(keyValueByteLength - keyData.byteLength);
if (key.match(/^ktx/i)) {
const text = decodeText(container.keyValue[key]);
container.keyValue[key] = text.substring(0, text.lastIndexOf('\x00'));
}
container.keyValue[key] = key.match(/^ktx/i) ? decodeText(valueData) : valueData; // 4-byte alignment.
const kvPadding = keyValueByteLength % 4 ? 4 - keyValueByteLength % 4 : 0; // align(4)
// 4-byte alignment.
if (kvdReader._offset % 4) kvdReader._skip(4 - kvdReader._offset % 4);
kvdReader._skip(kvPadding);
} ///////////////////////////////////////////////////

@@ -680,7 +691,7 @@ // Supercompression Global Data (SGD).

const keyData = encodeText(key);
const valueData = typeof value === 'string' ? encodeText(value) : value;
const kvByteLength = keyData.byteLength + 1 + valueData.byteLength + 1;
const valueData = typeof value === 'string' ? concat([encodeText(value), NUL]) : value;
const kvByteLength = keyData.byteLength + 1 + valueData.byteLength;
const kvPadding = kvByteLength % 4 ? 4 - kvByteLength % 4 : 0; // align(4)
keyValueData.push(concat([new Uint32Array([kvByteLength]), keyData, NUL, valueData, NUL, new Uint8Array(kvPadding).fill(0x00) // align(4)
keyValueData.push(concat([new Uint32Array([kvByteLength]), keyData, NUL, valueData, new Uint8Array(kvPadding).fill(0x00) // align(4)
]));

@@ -687,0 +698,0 @@ }

{
"name": "ktx-parse",
"version": "0.5.0",
"version": "0.6.0",
"description": "KTX 2.0 (.ktx2) parser and serializer.",

@@ -31,17 +31,17 @@ "type": "module",

"devDependencies": {
"@typescript-eslint/eslint-plugin": "5.53.0",
"ava": "5.2.0",
"c8": "7.13.0",
"eslint": "8.34.0",
"eslint-config-prettier": "8.6.0",
"@typescript-eslint/eslint-plugin": "5.61.0",
"ava": "5.3.1",
"c8": "8.0.0",
"eslint": "8.44.0",
"eslint-config-prettier": "8.8.0",
"glob": "8.1.0",
"glob-promise": "6.0.2",
"glob-promise": "6.0.3",
"microbundle": "0.15.1",
"prettier": "2.8.4",
"rimraf": "4.1.2",
"prettier": "2.8.8",
"rimraf": "5.0.1",
"source-map-support": "0.5.21",
"ts-node": "10.9.1",
"typedoc": "0.23.25",
"typedoc-plugin-markdown": "3.14.0",
"typescript": "4.9.5"
"typedoc": "0.24.8",
"typedoc-plugin-markdown": "3.15.3",
"typescript": "5.1.6"
},

@@ -48,0 +48,0 @@ "files": [

# ktx-parse
[![Latest NPM release](https://img.shields.io/npm/v/ktx-parse.svg)](https://www.npmjs.com/package/ktx-parse)
[![Minzipped size](https://badgen.net/bundlephobia/minzip/ktx-parse)](https://bundlephobia.com/result?p=ktx-parse)
[![npm bundle size](https://img.shields.io/bundlephobia/minzip/ktx-parse)](https://bundlephobia.com/package/ktx-parse)
[![License](https://img.shields.io/badge/license-MIT-007ec6.svg)](https://github.com/donmccurdy/KTX-Parse/blob/main/LICENSE)

@@ -6,0 +6,0 @@ [![CI](https://github.com/donmccurdy/KTX-parse/workflows/CI/badge.svg?branch=main&event=push)](https://github.com/donmccurdy/KTX-parse/actions?query=workflow%3ACI)

@@ -46,2 +46,8 @@ export class BufferReader {

_nextUint8Array(len: number) {
const value = new Uint8Array(this._dataView.buffer, this._dataView.byteOffset + this._offset, len);
this._offset += len;
return value;
}
_skip(bytes: number) {

@@ -48,0 +54,0 @@ this._offset += bytes;

@@ -161,7 +161,12 @@ import { BufferReader } from './buffer-reader.js';

const valueData = kvdReader._scan(keyValueByteLength - keyData.byteLength);
container.keyValue[key] = key.match(/^ktx/i) ? decodeText(valueData) : valueData;
container.keyValue[key] = kvdReader._nextUint8Array(keyValueByteLength - keyData.byteLength - 1);
if (key.match(/^ktx/i)) {
const text = decodeText(container.keyValue[key] as Uint8Array);
container.keyValue[key] = text.substring(0, text.lastIndexOf('\x00'));
}
const kvPadding = keyValueByteLength % 4 ? 4 - (keyValueByteLength % 4) : 0; // align(4)
// 4-byte alignment.
if (kvdReader._offset % 4) kvdReader._skip(4 - (kvdReader._offset % 4));
kvdReader._skip(kvPadding);
}

@@ -168,0 +173,0 @@

@@ -73,4 +73,4 @@ import { HEADER_BYTE_LENGTH, KTX2_ID, KTX_WRITER, NUL } from './constants-internal.js';

const keyData = encodeText(key);
const valueData = typeof value === 'string' ? encodeText(value) : value;
const kvByteLength = keyData.byteLength + 1 + valueData.byteLength + 1;
const valueData = typeof value === 'string' ? concat([encodeText(value), NUL]) : value;
const kvByteLength = keyData.byteLength + 1 + valueData.byteLength;
const kvPadding = kvByteLength % 4 ? 4 - (kvByteLength % 4) : 0; // align(4)

@@ -83,3 +83,2 @@ keyValueData.push(

valueData,
NUL,
new Uint8Array(kvPadding).fill(0x00), // align(4)

@@ -86,0 +85,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

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