Update Bot

This commit is contained in:
Syxpi
2025-09-07 17:02:01 +02:00
parent 207d4e8356
commit da3d85b6bc
4441 changed files with 646084 additions and 42 deletions

View File

@@ -0,0 +1,8 @@
import { Info, Tree } from "./tree";
declare type TypeName = string;
declare type Signature = string[];
export declare const add: (typename: TypeName, signature: Signature, additionalInfo?: Info | undefined, offset?: number | undefined) => void;
export declare const createTree: () => Tree;
declare const _default: () => Tree;
export default _default;
//# sourceMappingURL=pattern-tree.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"pattern-tree.d.ts","sourceRoot":"","sources":["../../src/model/pattern-tree.ts"],"names":[],"mappings":"AACA,OAAO,EAAiC,IAAI,EAAS,IAAI,EAAE,MAAM,QAAQ,CAAC;AAQ1E,aAAK,QAAQ,GAAG,MAAM,CAAC;AACvB,aAAK,SAAS,GAAG,MAAM,EAAE,CAAC;AAE1B,eAAO,MAAM,GAAG,aACJ,QAAQ,yCAED,IAAI,GAAG,SAAS,sCAwClC,CAAC;AA2xCF,eAAO,MAAM,UAAU,QAAO,IAAoB,CAAC;8BAChC,IAAI;AAAvB,wBAAwC"}

1163
node_modules/magic-bytes.js/dist/model/pattern-tree.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

3
node_modules/magic-bytes.js/dist/model/toHex.d.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
export declare const toHex: (num: number) => string;
export declare const fromHex: (hex: string) => number;
//# sourceMappingURL=toHex.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"toHex.d.ts","sourceRoot":"","sources":["../../src/model/toHex.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,KAAK,QAAS,MAAM,KAAG,MACsB,CAAC;AAC3D,eAAO,MAAM,OAAO,QAAS,MAAM,WAA8B,CAAC"}

8
node_modules/magic-bytes.js/dist/model/toHex.js generated vendored Normal file
View File

@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.fromHex = exports.toHex = void 0;
const hex = (num) => new Number(num).toString(16).toLowerCase();
const toHex = (num) => `0x${hex(num).length === 1 ? "0" + hex(num) : hex(num)}`;
exports.toHex = toHex;
const fromHex = (hex) => new Number(hex);
exports.fromHex = fromHex;

30
node_modules/magic-bytes.js/dist/model/tree.d.ts generated vendored Normal file
View File

@@ -0,0 +1,30 @@
export declare type PathlessNewNode = {
info: Info;
typename: string;
};
export declare type NewNode = PathlessNewNode & {
bytes: string[];
};
export declare type GuessedFile = Info & {
typename: string;
};
export declare type Info = {
mime?: string;
extension?: string;
};
export declare type Node = {
matches?: GuessedFile[];
bytes: {
[nextbyte: string]: Node;
};
};
export declare type Tree = {
noOffset: Node | null;
offset: {
[offsetByte: string]: Node;
};
};
export declare const merge: (node: NewNode, tree: Node) => Node;
export declare const createNode: (typename: string, bytes: string[], info?: Info | undefined) => NewNode;
export declare const createComplexNode: (typename: string, bytes: string[], info?: Info | undefined) => Node;
//# sourceMappingURL=tree.d.ts.map

1
node_modules/magic-bytes.js/dist/model/tree.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../src/model/tree.ts"],"names":[],"mappings":"AAAA,oBAAY,eAAe,GAAG;IAC5B,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,oBAAY,OAAO,GAAG,eAAe,GAAG;IACtC,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB,CAAC;AAEF,oBAAY,WAAW,GAAG,IAAI,GAAG;IAC/B,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,oBAAY,IAAI,GAAG;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,oBAAY,IAAI,GAAG;IACjB,OAAO,CAAC,EAAE,WAAW,EAAE,CAAC;IACxB,KAAK,EAAE;QACL,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;KAC1B,CAAC;CACH,CAAC;AAEF,oBAAY,IAAI,GAAG;IACjB,QAAQ,EAAE,IAAI,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE;QAAE,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;CACxC,CAAC;AAYF,eAAO,MAAM,KAAK,SAAU,OAAO,QAAQ,IAAI,KAAG,IA4BjD,CAAC;AAEF,eAAO,MAAM,UAAU,aACX,MAAM,SACT,MAAM,EAAE,8BAEd,OAEF,CAAC;AAEF,eAAO,MAAM,iBAAiB,aAClB,MAAM,SACT,MAAM,EAAE,8BAEd,IAmBF,CAAC"}

61
node_modules/magic-bytes.js/dist/model/tree.js generated vendored Normal file
View File

@@ -0,0 +1,61 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createComplexNode = exports.createNode = exports.merge = void 0;
const createMatch = (leaf) => ({
typename: leaf.typename,
mime: leaf.info.mime,
extension: leaf.info.extension,
});
const isLeafNode = (tree, path) => tree && path.length === 0;
const merge = (node, tree) => {
if (node.bytes.length === 0)
return tree;
const [currentByte, ...path] = node.bytes;
const currentTree = tree.bytes[currentByte];
// traversed to end. Just add key to leaf.
if (isLeafNode(currentTree, path)) {
const matchingNode = tree.bytes[currentByte];
tree.bytes[currentByte] = {
...matchingNode,
matches: [
...(matchingNode.matches ?? []),
createMatch(node),
],
};
return tree;
}
// Path exists already, Merge subtree
if (tree.bytes[currentByte]) {
tree.bytes[currentByte] = exports.merge(exports.createNode(node.typename, path, node.info), tree.bytes[currentByte]);
}
else { // Tree did not exist before
tree.bytes[currentByte] = exports.createComplexNode(node.typename, path, node.info);
}
return tree;
};
exports.merge = merge;
const createNode = (typename, bytes, info) => {
return { typename, bytes, info: info ? info : {} };
};
exports.createNode = createNode;
const createComplexNode = (typename, bytes, info) => {
let obj = {
bytes: {},
matches: undefined,
};
const [currentKey, ...path] = bytes;
if (bytes.length === 0) {
return {
matches: [
createMatch({
typename: typename,
info: info ? { extension: info.extension, mime: info.mime } : {},
}),
],
bytes: {},
};
}
obj.bytes[currentKey] = exports.createComplexNode(typename, path, info);
return obj;
};
exports.createComplexNode = createComplexNode;

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=tree.spec.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"tree.spec.d.ts","sourceRoot":"","sources":["../../src/model/tree.spec.ts"],"names":[],"mappings":""}

34
node_modules/magic-bytes.js/dist/model/tree.spec.js generated vendored Normal file
View File

@@ -0,0 +1,34 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tree_1 = require("./tree");
describe("tree", () => {
it("Creates complex node", () => {
const tree = tree_1.createComplexNode("mpe", ["0x00", "0x01"]);
expect(tree.bytes["0x00"].bytes["0x01"]).toHaveProperty("matches");
expect(tree.bytes["0x00"].bytes["0x01"]["matches"][0].typename).toBe("mpe");
});
it("Merges trees", () => {
const tree = tree_1.createComplexNode("pic", ["0x00"]);
const dba = tree_1.createNode("dba", ["0x00", "0x01", "0x02", "0x03"]);
const merged = tree_1.merge(dba, tree);
expect(merged.bytes["0x00"].matches[0].typename).toBe("pic");
expect(merged.bytes["0x00"].bytes["0x01"].bytes["0x02"].bytes["0x03"].matches[0]
.typename).toBe("dba");
});
it("Merges overlapping", () => {
const tree = tree_1.createComplexNode("pic", ["0x00"]);
const dba = tree_1.createNode("pif", ["0x00"]);
const merged = tree_1.merge(dba, tree);
expect(merged.bytes["0x00"].matches).toHaveLength(2);
});
it("Merges deep overlapping", () => {
const gifA = tree_1.createComplexNode("gif", ["0x47", "0x49", "0x46", "0x38", "0x37", "0x61"], { mime: "image/gif", extension: "gif" });
const gifB = tree_1.createNode("gif", ["0x47", "0x49", "0x46", "0x38", "0x38", "0x61"], { mime: "image/gif", extension: "gif" });
const gifC = tree_1.createNode("gif", ["0x47", "0x49", "0x46", "0x38", "0x39", "0x61"], { mime: "image/gif", extension: "gif" });
const mergeA = tree_1.merge(gifB, gifA);
const mergeB = tree_1.merge(gifC, mergeA);
expect(mergeB.bytes["0x47"].bytes["0x49"].bytes["0x46"].bytes["0x38"].bytes["0x37"].bytes["0x61"].matches[0]).toEqual({ typename: "gif", extension: "gif", mime: "image/gif" });
expect(mergeB.bytes["0x47"].bytes["0x49"].bytes["0x46"].bytes["0x38"].bytes["0x39"].bytes["0x61"].matches[0]).toEqual({ typename: "gif", extension: "gif", mime: "image/gif" });
expect(mergeB.bytes["0x47"].bytes["0x49"].bytes["0x46"].bytes["0x38"].bytes["0x38"].bytes["0x61"].matches[0]).toEqual({ typename: "gif", extension: "gif", mime: "image/gif" });
});
});