// @ts-check import { GifNodeType } from "./constants.js"; /** @typedef {import("../../types/gif.d.ts").GifNode} GifNode */ /** * @param {Uint8Array} bytes * @returns {null | GifNode} The root node of the PNG tree, or null if the PNG is invalid. */ export default (bytes) => { /** @type {GifNode[]} */ const children = [ { type: GifNodeType.header, bytes: bytes.subarray(0, 6), children: [ { type: GifNodeType.headerSignature, bytes: bytes.subarray(0, 3), }, { type: GifNodeType.headerVersion, bytes: bytes.subarray(3, 6), }, ], }, ]; return { type: GifNodeType.root, bytes, children }; };