mirror of
https://gitlab.com/upRootNutrition/zookeeper.git
synced 2025-06-16 02:15:12 -05:00
feat: init
This commit is contained in:
parent
8379d09058
commit
2cfa016090
2929 changed files with 299087 additions and 3 deletions
1
node_modules/magic-bytes.js/.gitattributes
generated
vendored
Normal file
1
node_modules/magic-bytes.js/.gitattributes
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
*.srt text eol=crlf
|
39
node_modules/magic-bytes.js/.github/workflows/build-and-test.yml
generated
vendored
Normal file
39
node_modules/magic-bytes.js/.github/workflows/build-and-test.yml
generated
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
|
||||
name: Build and test
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
jobs:
|
||||
buildAndTest:
|
||||
name: Build and test (Node.js v${{ matrix.node-version }})
|
||||
timeout-minutes: 15
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write # to be able to publish a GitHub release
|
||||
issues: write # to be able to comment on released issues
|
||||
pull-requests: write # to be able to comment on released pull requests
|
||||
id-token: write # to enable use of OIDC for npm provenance
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [18]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
- name: Install install dependencies
|
||||
run: npm ci
|
||||
- name: test
|
||||
run: npm test
|
||||
- name: build
|
||||
run: npm run build
|
||||
- name: release new version
|
||||
run: npm run semantic-release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
#- run: npm publish
|
||||
# env:
|
||||
# NODE_AUTH_TOKEN: ${{ secrets.NPM_SECRET_TOKEN }}
|
48
node_modules/magic-bytes.js/.github/workflows/static-webapp.yml
generated
vendored
Normal file
48
node_modules/magic-bytes.js/.github/workflows/static-webapp.yml
generated
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
# Simple workflow for deploying static content to GitHub Pages
|
||||
name: Deploy static webapp to Pages
|
||||
on:
|
||||
# Runs on pushes targeting the default branch
|
||||
push:
|
||||
branches: ["master"]
|
||||
|
||||
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
||||
permissions:
|
||||
contents: read
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
|
||||
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
|
||||
concurrency:
|
||||
group: "pages"
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
# Single deploy job since we're just deploying
|
||||
deploy:
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Setup Pages
|
||||
uses: actions/configure-pages@v3
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
- name: Install install dependencies
|
||||
run: npm ci
|
||||
- name: build
|
||||
run: npm run build:example:webapp
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-pages-artifact@v2
|
||||
with:
|
||||
# Upload entire repository
|
||||
path: './example/webapp/dist'
|
||||
- name: Deploy to GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v2
|
1
node_modules/magic-bytes.js/.prettierignore
generated
vendored
Normal file
1
node_modules/magic-bytes.js/.prettierignore
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
src/pattern-tree.snapshot.ts
|
21
node_modules/magic-bytes.js/LICENSE
generated
vendored
Normal file
21
node_modules/magic-bytes.js/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2022 Lars Kölpin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
109
node_modules/magic-bytes.js/README.md
generated
vendored
Normal file
109
node_modules/magic-bytes.js/README.md
generated
vendored
Normal file
|
@ -0,0 +1,109 @@
|
|||
# Magic bytes
|
||||
|
||||
[](https://github.com/LarsKoelpin/magic-bytes/actions/workflows/build-and-test.yml)
|
||||
|
||||
Magic Bytes is a javascript library analyzing the first bytes of a file to tell you its type.
|
||||
Use it inside your browser or serversided using nodejs.
|
||||
|
||||
The procedure is based on https://en.wikipedia.org/wiki/List_of_file_signatures.
|
||||
|
||||
|
||||
> [!NOTE]
|
||||
> A small note on versioning.
|
||||
> Strictly speaking, each new filetype which is supported by this library can break someones' API.
|
||||
> Please note that this library adds new filetypes with minor release.
|
||||
> This means files, which validate to "null" in some versions, may find a result in a new version.
|
||||
>
|
||||
> Or in some cases the library will find more results, than before. So don't depend on the found-array size in
|
||||
> any shape or form.
|
||||
> Filetypes will not be remoevd tho
|
||||
|
||||
# Installation
|
||||
Run `npm install magic-bytes.js`
|
||||
|
||||
|
||||
# Interactive example
|
||||
There is an interactive example present at https://larskoelpin.github.io/magic-bytes/.
|
||||
|
||||
# Usage
|
||||
|
||||
The following functions are available:
|
||||
* `filetypeinfo(bytes: number[])` Contains typeinformation like name, extension and mime type: `[{typename: "zip"}, {typename: "jar"}]`
|
||||
* `filetypename(bytes: number[])` : Contains type names only: `["zip", "jar"]`
|
||||
* `filetypemime(bytes: number[])` : Contains type mime types only: `["application/zip", "application/jar"]`
|
||||
* `filetypeextension(bytes: number[])` : Contains type extensions only: `["zip", "jar"]`
|
||||
|
||||
Both function return an empty array `[]` otherwise, which means it could not detect the file signature. Keep in mind that
|
||||
txt files for example fall in this category.
|
||||
|
||||
You don't have to load the whole file in memory. For validating a file uploaded to S3 using Lambda for example, it may be
|
||||
enough to load the files first 100 bytes and validate against them. This is especially useful for big files.
|
||||
|
||||
see examples for practical usage.
|
||||
|
||||
On server:
|
||||
```javascript
|
||||
import filetype from 'magic-bytes.js'
|
||||
|
||||
filetype(fs.readFileSync("myimage.png")) // ["png"]
|
||||
```
|
||||
|
||||
|
||||
To run an HTML-Example checkout the project and run
|
||||
|
||||
```
|
||||
npm install; npm run example
|
||||
```
|
||||
|
||||
This opens an HTML example using magic bytes as a window variable. It kinda looks like that.
|
||||
|
||||
```html
|
||||
<input type="file" id="file" />
|
||||
|
||||
<script src="node_modules/magic-bytes.js/dist/browser.js" type="application/javascript"></script>
|
||||
<script>
|
||||
document.getElementById("file").addEventListener('change', (event, x) => {
|
||||
const fileReader = new FileReader();
|
||||
fileReader.onloadend = (f) => {
|
||||
const bytes = new Uint8Array(f.target.result);
|
||||
console.log("Possible filetypes: " + filetypeinfo(bytes))
|
||||
}
|
||||
fileReader.readAsArrayBuffer(event.target.files[0])
|
||||
})
|
||||
</script>
|
||||
```
|
||||
|
||||
|
||||
# Tests
|
||||
Run `npm test`
|
||||
|
||||
# Example
|
||||
See examples/
|
||||
|
||||
# How does it work
|
||||
The `create-snapshot.js` creates a new tree. The tree has a similar shape to the following
|
||||
```json
|
||||
{
|
||||
"0x47": {
|
||||
"0x49": {
|
||||
"0x46": {
|
||||
"0x38": {
|
||||
"0x37": {
|
||||
"0x61": {
|
||||
"matches": [
|
||||
{
|
||||
"typename": "gif",
|
||||
"mime": "image/gif",
|
||||
"extension": "gif"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
It acts as a giant lookup map for the given byte signatures.
|
1
node_modules/magic-bytes.js/commitlint.config.js
generated
vendored
Normal file
1
node_modules/magic-bytes.js/commitlint.config.js
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
module.exports = {extends: ['@commitlint/config-conventional']}
|
7
node_modules/magic-bytes.js/dist/index.d.ts
generated
vendored
Normal file
7
node_modules/magic-bytes.js/dist/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
import { GuessedFile } from "./model/tree";
|
||||
export declare const filetypeinfo: (bytes: number[] | Uint8Array | Uint8ClampedArray) => GuessedFile[];
|
||||
export default filetypeinfo;
|
||||
export declare const filetypename: (bytes: number[] | Uint8Array | Uint8ClampedArray) => string[];
|
||||
export declare const filetypemime: (bytes: number[] | Uint8Array | Uint8ClampedArray) => string[];
|
||||
export declare const filetypeextension: (bytes: number[] | Uint8Array | Uint8ClampedArray) => string[];
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
node_modules/magic-bytes.js/dist/index.d.ts.map
generated
vendored
Normal file
1
node_modules/magic-bytes.js/dist/index.d.ts.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAc,MAAM,cAAc,CAAC;AAIvD,eAAO,MAAM,YAAY,UAChB,MAAM,EAAE,GAAG,UAAU,GAAG,iBAAiB,KAC/C,WAAW,EAkBb,CAAC;AA0BF,eAAe,YAAY,CAAC;AAE5B,eAAO,MAAM,YAAY,UAChB,MAAM,EAAE,GAAG,UAAU,GAAG,iBAAiB,KAC/C,MAAM,EAAgD,CAAC;AAE1D,eAAO,MAAM,YAAY,UAChB,MAAM,EAAE,GAAG,UAAU,GAAG,iBAAiB,KAC/C,MAAM,EAGiC,CAAC;AAE3C,eAAO,MAAM,iBAAiB,UACrB,MAAM,EAAE,GAAG,UAAU,GAAG,iBAAiB,KAC/C,MAAM,EAGiC,CAAC"}
|
60
node_modules/magic-bytes.js/dist/index.js
generated
vendored
Normal file
60
node_modules/magic-bytes.js/dist/index.js
generated
vendored
Normal file
|
@ -0,0 +1,60 @@
|
|||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.filetypeextension = exports.filetypemime = exports.filetypename = exports.filetypeinfo = void 0;
|
||||
const pattern_tree_1 = __importDefault(require("./model/pattern-tree"));
|
||||
const toHex_1 = require("./model/toHex");
|
||||
const patternTree = pattern_tree_1.default();
|
||||
const filetypeinfo = (bytes) => {
|
||||
let tree = patternTree;
|
||||
for (const k of Object.keys(tree.offset)) {
|
||||
const offset = toHex_1.fromHex(k);
|
||||
const offsetExceedsFile = offset >= bytes.length;
|
||||
if (offsetExceedsFile) {
|
||||
continue;
|
||||
}
|
||||
const node = patternTree.offset[k];
|
||||
const guessed = walkTree(offset, bytes, node);
|
||||
if (guessed.length > 0) {
|
||||
return guessed;
|
||||
}
|
||||
}
|
||||
if (tree.noOffset === null) {
|
||||
return [];
|
||||
}
|
||||
return walkTree(0, bytes, tree.noOffset);
|
||||
};
|
||||
exports.filetypeinfo = filetypeinfo;
|
||||
const walkTree = (index, bytes, node) => {
|
||||
let step = node;
|
||||
let guessFile = [];
|
||||
while (true) {
|
||||
const currentByte = toHex_1.toHex(bytes[index]);
|
||||
if (step.bytes["?"] && !step.bytes[currentByte]) {
|
||||
step = step.bytes["?"];
|
||||
}
|
||||
else {
|
||||
step = step.bytes[currentByte];
|
||||
}
|
||||
if (!step) {
|
||||
return guessFile;
|
||||
}
|
||||
if (step && step.matches) {
|
||||
guessFile = step.matches.slice(0);
|
||||
}
|
||||
index += 1;
|
||||
}
|
||||
};
|
||||
exports.default = exports.filetypeinfo;
|
||||
const filetypename = (bytes) => exports.filetypeinfo(bytes).map((e) => e.typename);
|
||||
exports.filetypename = filetypename;
|
||||
const filetypemime = (bytes) => exports.filetypeinfo(bytes)
|
||||
.map((e) => (e.mime ? e.mime : null))
|
||||
.filter((x) => x !== null);
|
||||
exports.filetypemime = filetypemime;
|
||||
const filetypeextension = (bytes) => exports.filetypeinfo(bytes)
|
||||
.map((e) => (e.extension ? e.extension : null))
|
||||
.filter((x) => x !== null);
|
||||
exports.filetypeextension = filetypeextension;
|
2
node_modules/magic-bytes.js/dist/index.spec.d.ts
generated
vendored
Normal file
2
node_modules/magic-bytes.js/dist/index.spec.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
export {};
|
||||
//# sourceMappingURL=index.spec.d.ts.map
|
1
node_modules/magic-bytes.js/dist/index.spec.d.ts.map
generated
vendored
Normal file
1
node_modules/magic-bytes.js/dist/index.spec.d.ts.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"index.spec.d.ts","sourceRoot":"","sources":["../src/index.spec.ts"],"names":[],"mappings":""}
|
4
node_modules/magic-bytes.js/dist/model/pattern-tree.d.ts
generated
vendored
Normal file
4
node_modules/magic-bytes.js/dist/model/pattern-tree.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
import { Tree } from "./tree";
|
||||
declare const _default: () => Tree;
|
||||
export default _default;
|
||||
//# sourceMappingURL=pattern-tree.d.ts.map
|
1
node_modules/magic-bytes.js/dist/model/pattern-tree.d.ts.map
generated
vendored
Normal file
1
node_modules/magic-bytes.js/dist/model/pattern-tree.d.ts.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"pattern-tree.d.ts","sourceRoot":"","sources":["../../src/model/pattern-tree.ts"],"names":[],"mappings":"AACA,OAAO,EAA8C,IAAI,EAAE,MAAM,QAAQ,CAAC;8BAu0CvD,IAAI;AAAvB,wBAAwC"}
|
1155
node_modules/magic-bytes.js/dist/model/pattern-tree.js
generated
vendored
Normal file
1155
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
3
node_modules/magic-bytes.js/dist/model/toHex.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
export declare const toHex: (num: number) => string;
|
||||
export declare const fromHex: (hex: string) => number;
|
||||
//# sourceMappingURL=toHex.d.ts.map
|
1
node_modules/magic-bytes.js/dist/model/toHex.d.ts.map
generated
vendored
Normal file
1
node_modules/magic-bytes.js/dist/model/toHex.d.ts.map
generated
vendored
Normal 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
8
node_modules/magic-bytes.js/dist/model/toHex.js
generated
vendored
Normal 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
30
node_modules/magic-bytes.js/dist/model/tree.d.ts
generated
vendored
Normal 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
1
node_modules/magic-bytes.js/dist/model/tree.d.ts.map
generated
vendored
Normal 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;AAcF,eAAO,MAAM,KAAK,SAAU,OAAO,QAAQ,IAAI,KAAG,IAoCjD,CAAC;AAEF,eAAO,MAAM,UAAU,aACX,MAAM,SACT,MAAM,EAAE,8BAEd,OAEF,CAAC;AAEF,eAAO,MAAM,iBAAiB,aAClB,MAAM,SACT,MAAM,EAAE,8BAEd,IAoBF,CAAC"}
|
70
node_modules/magic-bytes.js/dist/model/tree.js
generated
vendored
Normal file
70
node_modules/magic-bytes.js/dist/model/tree.js
generated
vendored
Normal file
|
@ -0,0 +1,70 @@
|
|||
"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 isMatchingNode = (tree, path) => tree && path.length === 0;
|
||||
const head = (arr) => arr[0];
|
||||
const tail = (arr) => arr.slice(1, arr.length);
|
||||
const merge = (node, tree) => {
|
||||
if (node.bytes.length === 0)
|
||||
return tree;
|
||||
const currentByte = head(node.bytes); // 0
|
||||
const path = tail(node.bytes); // [1,2]
|
||||
const currentTree = tree.bytes[currentByte];
|
||||
// traversed to end. Just add key to leaf.
|
||||
if (isMatchingNode(currentTree, path)) {
|
||||
const matchingNode = tree.bytes[currentByte];
|
||||
tree.bytes[currentByte] = {
|
||||
...matchingNode,
|
||||
matches: [
|
||||
...(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]);
|
||||
return tree;
|
||||
}
|
||||
// Tree did not exist before
|
||||
if (!tree.bytes[currentByte]) {
|
||||
tree.bytes[currentByte] = {
|
||||
...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 = head(bytes); // 0
|
||||
const path = tail(bytes); // [1,2]
|
||||
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;
|
2
node_modules/magic-bytes.js/dist/model/tree.spec.d.ts
generated
vendored
Normal file
2
node_modules/magic-bytes.js/dist/model/tree.spec.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
export {};
|
||||
//# sourceMappingURL=tree.spec.d.ts.map
|
1
node_modules/magic-bytes.js/dist/model/tree.spec.d.ts.map
generated
vendored
Normal file
1
node_modules/magic-bytes.js/dist/model/tree.spec.d.ts.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"tree.spec.d.ts","sourceRoot":"","sources":["../../src/model/tree.spec.ts"],"names":[],"mappings":""}
|
5
node_modules/magic-bytes.js/jest.config.js
generated
vendored
Normal file
5
node_modules/magic-bytes.js/jest.config.js
generated
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
|
||||
module.exports = {
|
||||
preset: 'ts-jest',
|
||||
testEnvironment: 'node',
|
||||
};
|
72
node_modules/magic-bytes.js/package.json
generated
vendored
Normal file
72
node_modules/magic-bytes.js/package.json
generated
vendored
Normal file
|
@ -0,0 +1,72 @@
|
|||
{
|
||||
"name": "magic-bytes.js",
|
||||
"version": "1.10.0",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"release": {
|
||||
"branches": [
|
||||
"master"
|
||||
],
|
||||
"plugins": [
|
||||
"@semantic-release/commit-analyzer",
|
||||
"@semantic-release/release-notes-generator",
|
||||
"@semantic-release/npm",
|
||||
"@semantic-release/github",
|
||||
"@semantic-release/git"
|
||||
]
|
||||
},
|
||||
"scripts": {
|
||||
"prettier": "prettier --write \"{src,__{tests,mocks}__}/**/*.{tsx,ts}\"",
|
||||
"pre-test": "jest --clear-cache",
|
||||
"test": "jest",
|
||||
"build": "tsc",
|
||||
"example:html": "webpack --config example/html/webpack.config.js; open example/html/index.html",
|
||||
"example:webapp": "vite --config example/webapp/vite.config.js example/webapp",
|
||||
"build:example:webapp": "vite --config example/webapp/vite.config.js build example/webapp",
|
||||
"semantic-release": "semantic-release"
|
||||
},
|
||||
"repository": {
|
||||
"url": "https://github.com/LarsKoelpin/magic-bytes",
|
||||
"type": "git"
|
||||
},
|
||||
"author": "Lars Kölpin",
|
||||
"license": "MIT",
|
||||
"description": "Detect Filetype by bytes",
|
||||
"keywords": [
|
||||
"magic-bytes",
|
||||
"mime",
|
||||
"filetype",
|
||||
"file",
|
||||
"extension",
|
||||
"magic byte",
|
||||
"magic number",
|
||||
"mime",
|
||||
"mimetype",
|
||||
"validation",
|
||||
"javascript",
|
||||
"upload"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@babel/preset-typescript": "^7.15.0",
|
||||
"@changesets/cli": "^2.16.0",
|
||||
"@commitlint/cli": "^17.7.1",
|
||||
"@commitlint/config-conventional": "^17.7.0",
|
||||
"@semantic-release/git": "^10.0.1",
|
||||
"@types/jest": "^27.0.1",
|
||||
"@types/node": "^16.6.2",
|
||||
"husky": "^8.0.3",
|
||||
"jest": "^27.0.6",
|
||||
"open": "^9.1.0",
|
||||
"prettier": "^2.6.1",
|
||||
"prettier-plugin-organize-imports": "^2.3.4",
|
||||
"regenerator-runtime": "^0.11.1",
|
||||
"semantic-release": "^22.0.5",
|
||||
"ts-jest": "^27.0.5",
|
||||
"ts-loader": "^9.4.4",
|
||||
"ts-node": "^10.2.1",
|
||||
"typescript": "^4.3.5",
|
||||
"vite": "^4.4.9",
|
||||
"webpack-cli": "^5.1.4"
|
||||
}
|
||||
}
|
78
node_modules/magic-bytes.js/tsconfig.json
generated
vendored
Normal file
78
node_modules/magic-bytes.js/tsconfig.json
generated
vendored
Normal file
|
@ -0,0 +1,78 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
/* Visit https://aka.ms/tsconfig.json to read more about this file */
|
||||
|
||||
/* Basic Options */
|
||||
// "incremental": true, /* Enable incremental compilation */
|
||||
"target": "ES2020" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */,
|
||||
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
|
||||
"lib": [
|
||||
"ES2020"
|
||||
] /* Specify library files to be included in the compilation. */,
|
||||
// "allowJs": true, /* Allow javascript files to be compiled. */
|
||||
// "checkJs": true, /* Report errors in .js files. */
|
||||
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
|
||||
"declaration": true /* Generates corresponding '.d.ts' file. */,
|
||||
"declarationMap": true /* Generates a sourcemap for each corresponding '.d.ts' file. */,
|
||||
"sourceMap": false /* Generates corresponding '.map' file. */,
|
||||
// "outFile": "./", /* Concatenate and emit output to single file. */
|
||||
"outDir": "./dist" /* Redirect output structure to the directory. */,
|
||||
"rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */,
|
||||
// "composite": true, /* Enable project compilation */
|
||||
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
||||
// "removeComments": true, /* Do not emit comments to output. */
|
||||
// "noEmit": true, /* Do not emit outputs. */
|
||||
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
||||
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
||||
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
||||
|
||||
/* Strict Type-Checking Options */
|
||||
"strict": true /* Enable all strict type-checking options. */,
|
||||
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||
// "strictNullChecks": true, /* Enable strict null checks. */
|
||||
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
||||
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
||||
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
||||
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
||||
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
||||
|
||||
/* Additional Checks */
|
||||
// "noUnusedLocals": true, /* Report errors on unused locals. */
|
||||
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
||||
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
||||
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
||||
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
|
||||
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */
|
||||
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
|
||||
|
||||
/* Module Resolution Options */
|
||||
"moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
|
||||
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
||||
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
||||
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
||||
// "typeRoots": [], /* List of folders to include type definitions from. */
|
||||
"types": [
|
||||
"node",
|
||||
"jest"
|
||||
] /* Type declaration files to be included in compilation. */,
|
||||
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
||||
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
|
||||
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
||||
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
||||
|
||||
/* Source Map Options */
|
||||
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
|
||||
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
||||
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
|
||||
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
|
||||
|
||||
/* Experimental Options */
|
||||
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
||||
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
||||
|
||||
/* Advanced Options */
|
||||
"skipLibCheck": true /* Skip type checking of declaration files. */,
|
||||
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
|
||||
},
|
||||
"include": ["src/**/*"]
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue