Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
27 lines
779 B
Plaintext
27 lines
779 B
Plaintext
'use strict';
|
|
|
|
// lib/types/utils.ts
|
|
var decoder = new TextDecoder();
|
|
var toUTF8String = (input, start = 0, end = input.length) => decoder.decode(input.slice(start, end));
|
|
var getView = (input, offset) => new DataView(input.buffer, input.byteOffset + offset);
|
|
var readUInt32LE = (input, offset = 0) => getView(input, offset).getUint32(0, true);
|
|
|
|
// lib/types/ktx.ts
|
|
var KTX = {
|
|
validate: (input) => {
|
|
const signature = toUTF8String(input, 1, 7);
|
|
return ["KTX 11", "KTX 20"].includes(signature);
|
|
},
|
|
calculate: (input) => {
|
|
const type = input[5] === 49 ? "ktx" : "ktx2";
|
|
const offset = type === "ktx" ? 36 : 20;
|
|
return {
|
|
height: readUInt32LE(input, offset + 4),
|
|
width: readUInt32LE(input, offset),
|
|
type
|
|
};
|
|
}
|
|
};
|
|
|
|
exports.KTX = KTX;
|