From 8c3d5898bcbdec5c3d99950bd0752e845555a1e3 Mon Sep 17 00:00:00 2001 From: Erwan Vivien Date: Mon, 26 May 2025 11:14:32 +0200 Subject: [PATCH 01/16] feat: add ESLint config --- eslint.config.js | 21 + package-lock.json | 1557 +++++++++++++++++++++-- package.json | 12 +- src/DataStream.ts | 41 +- src/box-diff.ts | 6 +- src/box.ts | 23 +- src/boxes/co64.ts | 2 +- src/boxes/ctts.ts | 2 +- src/boxes/dac3.ts | 6 +- src/boxes/dec3.ts | 10 +- src/boxes/dfLa.ts | 13 +- src/boxes/displays/naluArrays.ts | 4 +- src/boxes/displays/parameterSetArray.ts | 2 +- src/boxes/displays/pixel.ts | 7 +- src/boxes/dref.ts | 4 +- src/boxes/elst.ts | 2 +- src/boxes/esds.ts | 4 +- src/boxes/lhvC.ts | 2 +- src/boxes/sampleentries/sampleentry.ts | 12 +- src/boxes/samplegroups/dtrt.ts | 2 +- src/boxes/samplegroups/mvif.ts | 2 +- src/boxes/samplegroups/scif.ts | 2 +- src/boxes/samplegroups/scnm.ts | 2 +- src/boxes/samplegroups/stsa.ts | 2 +- src/boxes/samplegroups/tsas.ts | 2 +- src/boxes/samplegroups/tscl.ts | 2 +- src/boxes/samplegroups/vipr.ts | 2 +- src/boxes/sbgp.ts | 2 +- src/boxes/sbpm.ts | 4 +- src/boxes/sgpd.ts | 4 +- src/boxes/ssix.ts | 2 +- src/boxes/stdp.ts | 2 +- src/boxes/stsd.ts | 2 +- src/boxes/stsh.ts | 2 +- src/boxes/stss.ts | 2 +- src/boxes/taic.ts | 2 +- src/boxes/trep.ts | 4 +- src/buffer.ts | 9 +- src/descriptor.ts | 13 +- src/isofile.ts | 47 +- src/log.ts | 6 +- src/text-mp4.ts | 14 +- 42 files changed, 1615 insertions(+), 246 deletions(-) create mode 100644 eslint.config.js diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 00000000..a0852dc5 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,21 @@ +import js from '@eslint/js'; +import globals from 'globals'; +import tseslint from 'typescript-eslint'; +import json from '@eslint/json'; +import { defineConfig } from 'eslint/config'; + +export default defineConfig([ + { files: ['**/*.{js,mjs,cjs,ts,mts,cts}'], plugins: { js }, extends: ['js/recommended'] }, + { files: ['**/*.{js,mjs,cjs,ts,mts,cts}'], languageOptions: { globals: globals.browser } }, + tseslint.configs.recommended, + { files: ['**/*.json'], plugins: { json }, language: 'json/json', extends: ['json/recommended'] }, + { + rules: { + '@typescript-eslint/no-unused-vars': [ + 'error', + { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }, + ], + 'no-unused-vars': 'off', + }, + }, +]); diff --git a/package-lock.json b/package-lock.json index d883b435..14019095 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,11 +11,16 @@ "devDependencies": { "@commitlint/cli": "^19.8.1", "@commitlint/config-conventional": "^19.8.1", + "@eslint/js": "^9.27.0", + "@eslint/json": "^0.12.0", "@types/node": "^22.15.21", "dpdm": "^3.14.0", + "eslint": "^9.27.0", + "globals": "^16.2.0", "husky": "^9.1.7", "tsup": "^8.3.5", - "typescript": "^5.6.3" + "typescript": "^5.6.3", + "typescript-eslint": "^8.32.1" }, "engines": { "node": ">=20.8.1" @@ -781,6 +786,289 @@ "node": ">=18" } }, + "node_modules/@eslint-community/eslint-utils": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.7.0.tgz", + "integrity": "sha512-dyybb3AcajC7uha6CvhdVRJqaKyn7w2YKqKyAN37NKYgZT36w+iRb0Dymmc5qEJ549c/S31cMMSFd75bteCpCw==", + "dev": true, + "license": "MIT", + "dependencies": { + "eslint-visitor-keys": "^3.4.3" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" + } + }, + "node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint-community/regexpp": { + "version": "4.12.1", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.1.tgz", + "integrity": "sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, + "node_modules/@eslint/config-array": { + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.20.0.tgz", + "integrity": "sha512-fxlS1kkIjx8+vy2SjuCB94q3htSNrufYTXubwiBFeaQHbH6Ipi43gFJq2zCMt6PHhImH3Xmr0NksKDvchWlpQQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/object-schema": "^2.1.6", + "debug": "^4.3.1", + "minimatch": "^3.1.2" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/config-helpers": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/@eslint/config-helpers/-/config-helpers-0.2.2.tgz", + "integrity": "sha512-+GPzk8PlG0sPpzdU5ZvIRMPidzAnZDl/s9L+y13iodqvb8leL53bTannOrQ/Im7UkpsmFU5Ily5U60LWixnmLg==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/core": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.12.0.tgz", + "integrity": "sha512-cmrR6pytBuSMTaBweKoGMwu3EiHiEC+DoyupPmlZ0HxBJBtIxwe+j/E4XPIKNx+Q74c8lXKPwYawBf5glsTkHg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@types/json-schema": "^7.0.15" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/eslintrc": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.3.1.tgz", + "integrity": "sha512-gtF186CXhIl1p4pJNGZw8Yc6RlshoePRvE0X91oPGb3vZ8pM3qOS9W9NGPat9LziaBV7XrJWGylNQXkGcnM3IQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^10.0.1", + "globals": "^14.0.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", + "minimatch": "^3.1.2", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint/eslintrc/node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/@eslint/eslintrc/node_modules/globals": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", + "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@eslint/eslintrc/node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@eslint/js": { + "version": "9.27.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.27.0.tgz", + "integrity": "sha512-G5JD9Tu5HJEu4z2Uo4aHY2sLV64B7CDMXxFzqzjl3NKd6RVzSXNoE80jk7Y0lJkTTkjiIhBAqmlYwjuBY3tvpA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://eslint.org/donate" + } + }, + "node_modules/@eslint/json": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/@eslint/json/-/json-0.12.0.tgz", + "integrity": "sha512-n/7dz8HFStpEe4o5eYk0tdkBdGUS/ZGb0GQCeDWN1ZmRq67HMHK4vC33b0rQlTT6xdZoX935P4vstiWVk5Ying==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/core": "^0.12.0", + "@eslint/plugin-kit": "^0.2.7", + "@humanwhocodes/momoa": "^3.3.4", + "natural-compare": "^1.4.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/object-schema": { + "version": "2.1.6", + "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-2.1.6.tgz", + "integrity": "sha512-RBMg5FRL0I0gs51M/guSAj5/e14VQ4tpZnQNWwuDT66P14I43ItmPfIZRhO9fUVIPOAQXU47atlywZ/czoqFPA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/plugin-kit": { + "version": "0.2.8", + "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.2.8.tgz", + "integrity": "sha512-ZAoA40rNMPwSm+AeHpCq8STiNAwzWLJuP8Xv4CHIc9wv/PSuExjMrmjfYNj682vW0OOiZ1HKxzvjQr9XZIisQA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/core": "^0.13.0", + "levn": "^0.4.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/plugin-kit/node_modules/@eslint/core": { + "version": "0.13.0", + "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.13.0.tgz", + "integrity": "sha512-yfkgDw1KR66rkT5A8ci4irzDysN7FRpq3ttJolR88OqQikAWqwA8j5VZyas+vjyBNFIJ7MfybJ9plMILI2UrCw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@types/json-schema": "^7.0.15" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@humanfs/core": { + "version": "0.19.1", + "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.1.tgz", + "integrity": "sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanfs/node": { + "version": "0.16.6", + "resolved": "https://registry.npmjs.org/@humanfs/node/-/node-0.16.6.tgz", + "integrity": "sha512-YuI2ZHQL78Q5HbhDiBA1X4LmYdXCKCMQIfw0pw7piHJwyREFebJUvrQN4cMssyES6x+vfUbx1CIpaQUKYdQZOw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@humanfs/core": "^0.19.1", + "@humanwhocodes/retry": "^0.3.0" + }, + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanfs/node/node_modules/@humanwhocodes/retry": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.3.1.tgz", + "integrity": "sha512-JBxkERygn7Bv/GbN5Rv8Ul6LVknS+5Bp6RgDC/O8gEBU/yeH5Ui5C/OlWrTb6qct7LjjfT6Re2NxB0ln0yYybA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12.22" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@humanwhocodes/momoa": { + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/@humanwhocodes/momoa/-/momoa-3.3.8.tgz", + "integrity": "sha512-/3PZzor2imi/RLLcnHztkwA79txiVvW145Ve2cp5dxRcH5qOUNJPToasqLFHniTfw4B4lT7jGDdBOPXbXYlIMQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18" + } + }, + "node_modules/@humanwhocodes/retry": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.4.3.tgz", + "integrity": "sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, "node_modules/@isaacs/cliui": { "version": "8.0.2", "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", @@ -937,6 +1225,44 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/@pkgjs/parseargs": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", @@ -1245,6 +1571,13 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/json-schema": { + "version": "7.0.15", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/node": { "version": "22.15.21", "resolved": "https://registry.npmjs.org/@types/node/-/node-22.15.21.tgz", @@ -1255,82 +1588,321 @@ "undici-types": "~6.21.0" } }, - "node_modules/ajv": { - "version": "8.17.1", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz", - "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", + "node_modules/@typescript-eslint/eslint-plugin": { + "version": "8.32.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.32.1.tgz", + "integrity": "sha512-6u6Plg9nP/J1GRpe/vcjjabo6Uc5YQPAMxsgQyGC/I0RuukiG1wIe3+Vtg3IrSCVJDmqK3j8adrtzXSENRtFgg==", "dev": true, "license": "MIT", "dependencies": { - "fast-deep-equal": "^3.1.3", - "fast-uri": "^3.0.1", - "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2" + "@eslint-community/regexpp": "^4.10.0", + "@typescript-eslint/scope-manager": "8.32.1", + "@typescript-eslint/type-utils": "8.32.1", + "@typescript-eslint/utils": "8.32.1", + "@typescript-eslint/visitor-keys": "8.32.1", + "graphemer": "^1.4.0", + "ignore": "^7.0.0", + "natural-compare": "^1.4.0", + "ts-api-utils": "^2.1.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^8.0.0 || ^8.0.0-alpha.0", + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <5.9.0" } }, - "node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "node_modules/@typescript-eslint/eslint-plugin/node_modules/ignore": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.4.tgz", + "integrity": "sha512-gJzzk+PQNznz8ysRrC0aOkBNVRBDtE1n53IqyqEf3PXrYwomFs5q4pGMizBMJF+ykh03insJ27hB8gSrD2Hn8A==", "dev": true, "license": "MIT", "engines": { - "node": ">=8" + "node": ">= 4" } }, - "node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "node_modules/@typescript-eslint/parser": { + "version": "8.32.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.32.1.tgz", + "integrity": "sha512-LKMrmwCPoLhM45Z00O1ulb6jwyVr2kr3XJp+G+tSEZcbauNnScewcQwtJqXDhXeYPDEjZ8C1SjXm015CirEmGg==", "dev": true, + "license": "MIT", "dependencies": { - "color-convert": "^2.0.1" + "@typescript-eslint/scope-manager": "8.32.1", + "@typescript-eslint/types": "8.32.1", + "@typescript-eslint/typescript-estree": "8.32.1", + "@typescript-eslint/visitor-keys": "8.32.1", + "debug": "^4.3.4" }, "engines": { - "node": ">=8" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <5.9.0" } }, - "node_modules/any-promise": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", - "integrity": "sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==", + "node_modules/@typescript-eslint/scope-manager": { + "version": "8.32.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.32.1.tgz", + "integrity": "sha512-7IsIaIDeZn7kffk7qXC3o6Z4UblZJKV3UBpkvRNpr5NSyLji7tvTcvmnMNYuYLyh26mN8W723xpo3i4MlD33vA==", "dev": true, - "license": "MIT" + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.32.1", + "@typescript-eslint/visitor-keys": "8.32.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } }, - "node_modules/argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "node_modules/@typescript-eslint/type-utils": { + "version": "8.32.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.32.1.tgz", + "integrity": "sha512-mv9YpQGA8iIsl5KyUPi+FGLm7+bA4fgXaeRcFKRDRwDMu4iwrSHeDPipwueNXhdIIZltwCJv+NkxftECbIZWfA==", "dev": true, - "license": "Python-2.0" + "license": "MIT", + "dependencies": { + "@typescript-eslint/typescript-estree": "8.32.1", + "@typescript-eslint/utils": "8.32.1", + "debug": "^4.3.4", + "ts-api-utils": "^2.1.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <5.9.0" + } }, - "node_modules/array-ify": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/array-ify/-/array-ify-1.0.0.tgz", - "integrity": "sha512-c5AMf34bKdvPhQ7tBGhqkgKNUzMr4WUs+WDtC2ZUGOUncbxKMTvqxYctiseW3+L4bA8ec+GcZ6/A/FW4m8ukng==", + "node_modules/@typescript-eslint/types": { + "version": "8.32.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.32.1.tgz", + "integrity": "sha512-YmybwXUJcgGqgAp6bEsgpPXEg6dcCyPyCSr0CAAueacR/CCBi25G3V8gGQ2kRzQRBNol7VQknxMs9HvVa9Rvfg==", "dev": true, - "license": "MIT" - }, - "node_modules/balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } }, - "node_modules/base64-js": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", - "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "node_modules/@typescript-eslint/typescript-estree": { + "version": "8.32.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.32.1.tgz", + "integrity": "sha512-Y3AP9EIfYwBb4kWGb+simvPaqQoT5oJuzzj9m0i6FCY6SPvlomY2Ei4UEMm7+FXtlNJbor80ximyslzaQF6xhg==", "dev": true, - "funding": [ - { + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.32.1", + "@typescript-eslint/visitor-keys": "8.32.1", + "debug": "^4.3.4", + "fast-glob": "^3.3.2", + "is-glob": "^4.0.3", + "minimatch": "^9.0.4", + "semver": "^7.6.0", + "ts-api-utils": "^2.1.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <5.9.0" + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@typescript-eslint/utils": { + "version": "8.32.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.32.1.tgz", + "integrity": "sha512-DsSFNIgLSrc89gpq1LJB7Hm1YpuhK086DRDJSNrewcGvYloWW1vZLHBTIvarKZDcAORIy/uWNx8Gad+4oMpkSA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.7.0", + "@typescript-eslint/scope-manager": "8.32.1", + "@typescript-eslint/types": "8.32.1", + "@typescript-eslint/typescript-estree": "8.32.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <5.9.0" + } + }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "8.32.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.32.1.tgz", + "integrity": "sha512-ar0tjQfObzhSaW3C3QNmTc5ofj0hDoNQ5XWrCy6zDyabdr0TWhCkClp+rywGNj/odAFBVzzJrK4tEq5M4Hmu4w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.32.1", + "eslint-visitor-keys": "^4.2.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/acorn": { + "version": "8.14.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.1.tgz", + "integrity": "sha512-OvQ/2pUDKmgfCg++xsTX1wGxfTaszcHVcTctW4UJB4hibJx2HXxxO5UmVgyjMa+ZDsiaf5wWLXYpRWMmBI0QHg==", + "dev": true, + "license": "MIT", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/ajv": { + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz", + "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.3", + "fast-uri": "^3.0.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/any-promise": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", + "integrity": "sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==", + "dev": true, + "license": "MIT" + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true, + "license": "Python-2.0" + }, + "node_modules/array-ify": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/array-ify/-/array-ify-1.0.0.tgz", + "integrity": "sha512-c5AMf34bKdvPhQ7tBGhqkgKNUzMr4WUs+WDtC2ZUGOUncbxKMTvqxYctiseW3+L4bA8ec+GcZ6/A/FW4m8ukng==", + "dev": true, + "license": "MIT" + }, + "node_modules/balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "dev": true, + "funding": [ + { "type": "github", "url": "https://github.com/sponsors/feross" }, @@ -1403,6 +1975,30 @@ "safe-buffer": "~5.2.0" } }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "dev": true, + "license": "MIT", + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/buffer": { "version": "5.7.1", "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", @@ -1560,6 +2156,13 @@ "dot-prop": "^5.1.0" } }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true, + "license": "MIT" + }, "node_modules/confbox": { "version": "0.1.8", "resolved": "https://registry.npmjs.org/confbox/-/confbox-0.1.8.tgz", @@ -1711,6 +2314,31 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/debug": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz", + "integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/deep-is": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "dev": true, + "license": "MIT" + }, "node_modules/defaults": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.4.tgz", @@ -1901,6 +2529,313 @@ "node": ">=6" } }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint": { + "version": "9.27.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.27.0.tgz", + "integrity": "sha512-ixRawFQuMB9DZ7fjU3iGGganFDp3+45bPOdaRurcFHSXO1e/sYwUX/FtQZpLZJR6SjMoJH8hR2pPEAfDyCoU2Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.12.1", + "@eslint/config-array": "^0.20.0", + "@eslint/config-helpers": "^0.2.1", + "@eslint/core": "^0.14.0", + "@eslint/eslintrc": "^3.3.1", + "@eslint/js": "9.27.0", + "@eslint/plugin-kit": "^0.3.1", + "@humanfs/node": "^0.16.6", + "@humanwhocodes/module-importer": "^1.0.1", + "@humanwhocodes/retry": "^0.4.2", + "@types/estree": "^1.0.6", + "@types/json-schema": "^7.0.15", + "ajv": "^6.12.4", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.6", + "debug": "^4.3.2", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^8.3.0", + "eslint-visitor-keys": "^4.2.0", + "espree": "^10.3.0", + "esquery": "^1.5.0", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^8.0.0", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "ignore": "^5.2.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.1.2", + "natural-compare": "^1.4.0", + "optionator": "^0.9.3" + }, + "bin": { + "eslint": "bin/eslint.js" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://eslint.org/donate" + }, + "peerDependencies": { + "jiti": "*" + }, + "peerDependenciesMeta": { + "jiti": { + "optional": true + } + } + }, + "node_modules/eslint-scope": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.3.0.tgz", + "integrity": "sha512-pUNxi75F8MJ/GdeKtVLSbYg4ZI34J6C0C7sbL4YOp2exGwen7ZsuBqKzUhXd0qMQ362yET3z+uPwKeg/0C2XCQ==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-visitor-keys": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", + "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint/node_modules/@eslint/core": { + "version": "0.14.0", + "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.14.0.tgz", + "integrity": "sha512-qIbV0/JZr7iSDjqAc60IqbLdsj9GDt16xQtWD+B78d/HAlvysGdZZ6rpJHGAc2T0FQx1X6thsSPdnoiGKdNtdg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@types/json-schema": "^7.0.15" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/eslint/node_modules/@eslint/plugin-kit": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.3.1.tgz", + "integrity": "sha512-0J+zgWxHN+xXONWIyPWKFMgVuJoZuGiIFu8yxk7RJjxkzpGmyja5wRFqZIVtjDVOQpV+Rw0iOAjYPE2eQyjr0w==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/core": "^0.14.0", + "levn": "^0.4.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/eslint/node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/eslint/node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "license": "MIT", + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint/node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true, + "license": "MIT" + }, + "node_modules/eslint/node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint/node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint/node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint/node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/eslint/node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/espree": { + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-10.3.0.tgz", + "integrity": "sha512-0QYC8b24HWY8zjRnDTL6RiHfDbAWn63qb4LMj1Z4b076A4une81+z03Kg7l7mn/48PUTqoLptSXez8oknU8Clg==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "acorn": "^8.14.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^4.2.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/esquery": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.6.0.tgz", + "integrity": "sha512-ca9pw9fomFcKPvFLXhBKUK90ZvGibiGOvRJNbjljY7s7uq/5YO4BOzcYtJqExdx99rF6aAcnRxHmcUHcz6sQsg==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "estraverse": "^5.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "estraverse": "^5.2.0" + }, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=4.0" + } + }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -1908,6 +2843,50 @@ "dev": true, "license": "MIT" }, + "node_modules/fast-glob": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.3.tgz", + "integrity": "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.8" + }, + "engines": { + "node": ">=8.6.0" + } + }, + "node_modules/fast-glob/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", + "dev": true, + "license": "MIT" + }, "node_modules/fast-uri": { "version": "3.0.6", "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.0.6.tgz", @@ -1925,6 +2904,42 @@ ], "license": "BSD-3-Clause" }, + "node_modules/fastq": { + "version": "1.19.1", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.19.1.tgz", + "integrity": "sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "reusify": "^1.0.4" + } + }, + "node_modules/file-entry-cache": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", + "integrity": "sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "flat-cache": "^4.0.0" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dev": true, + "license": "MIT", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/find-up": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-7.0.0.tgz", @@ -1955,6 +2970,27 @@ "rollup": "^4.34.8" } }, + "node_modules/flat-cache": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-4.0.1.tgz", + "integrity": "sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==", + "dev": true, + "license": "MIT", + "dependencies": { + "flatted": "^3.2.9", + "keyv": "^4.5.4" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/flatted": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.3.tgz", + "integrity": "sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg==", + "dev": true, + "license": "ISC" + }, "node_modules/foreground-child": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.1.tgz", @@ -2027,6 +3063,19 @@ "node": ">=16" } }, + "node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, "node_modules/global-directory": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/global-directory/-/global-directory-4.0.1.tgz", @@ -2043,12 +3092,32 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/globals": { + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-16.2.0.tgz", + "integrity": "sha512-O+7l9tPdHCU320IigZZPj5zmRCFG9xHmx9cU8FqU2Rp+JN714seHV+2S9+JslCpY4gJwU2vOGox0wzgae/MCEg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/graceful-fs": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz", "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==", "dev": true }, + "node_modules/graphemer": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", + "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", + "dev": true, + "license": "MIT" + }, "node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", @@ -2095,6 +3164,16 @@ ], "license": "BSD-3-Clause" }, + "node_modules/ignore": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", + "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, "node_modules/import-fresh": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz", @@ -2133,6 +3212,16 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.8.19" + } + }, "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", @@ -2156,6 +3245,16 @@ "dev": true, "license": "MIT" }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", @@ -2165,6 +3264,19 @@ "node": ">=8" } }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/is-interactive": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-1.0.0.tgz", @@ -2175,6 +3287,16 @@ "node": ">=8" } }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, "node_modules/is-obj": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-2.0.0.tgz", @@ -2273,6 +3395,13 @@ "js-yaml": "bin/js-yaml.js" } }, + "node_modules/json-buffer": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", + "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", + "dev": true, + "license": "MIT" + }, "node_modules/json-parse-even-better-errors": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", @@ -2287,6 +3416,13 @@ "dev": true, "license": "MIT" }, + "node_modules/json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", + "dev": true, + "license": "MIT" + }, "node_modules/jsonfile": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", @@ -2326,6 +3462,30 @@ "node": "*" } }, + "node_modules/keyv": { + "version": "4.5.4", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", + "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", + "dev": true, + "license": "MIT", + "dependencies": { + "json-buffer": "3.0.1" + } + }, + "node_modules/levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/lilconfig": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-3.1.3.tgz", @@ -2482,6 +3642,30 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "node_modules/micromatch": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", + "dev": true, + "license": "MIT", + "dependencies": { + "braces": "^3.0.3", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, "node_modules/mimic-fn": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", @@ -2492,6 +3676,19 @@ "node": ">=6" } }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, "node_modules/minimist": { "version": "1.2.8", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", @@ -2525,18 +3722,12 @@ "ufo": "^1.5.4" } }, - "node_modules/mlly/node_modules/acorn": { - "version": "8.14.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.1.tgz", - "integrity": "sha512-OvQ/2pUDKmgfCg++xsTX1wGxfTaszcHVcTctW4UJB4hibJx2HXxxO5UmVgyjMa+ZDsiaf5wWLXYpRWMmBI0QHg==", + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true, - "license": "MIT", - "bin": { - "acorn": "bin/acorn" - }, - "engines": { - "node": ">=0.4.0" - } + "license": "MIT" }, "node_modules/mz": { "version": "2.7.0", @@ -2550,6 +3741,13 @@ "thenify-all": "^1.0.0" } }, + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", + "dev": true, + "license": "MIT" + }, "node_modules/object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", @@ -2575,6 +3773,24 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/optionator": { + "version": "0.9.4", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", + "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==", + "dev": true, + "license": "MIT", + "dependencies": { + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.5" + }, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/ora": { "version": "5.4.1", "resolved": "https://registry.npmjs.org/ora/-/ora-5.4.1.tgz", @@ -2728,6 +3944,19 @@ "dev": true, "license": "ISC" }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/pirates": { "version": "4.0.7", "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.7.tgz", @@ -2793,6 +4022,47 @@ } } }, + "node_modules/prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -2836,6 +4106,17 @@ "node": ">=8" } }, + "node_modules/reusify": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.1.0.tgz", + "integrity": "sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==", + "dev": true, + "license": "MIT", + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.10.0" + } + }, "node_modules/rollup": { "version": "4.41.1", "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.41.1.tgz", @@ -2876,6 +4157,30 @@ "fsevents": "~2.3.2" } }, + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "queue-microtask": "^1.2.2" + } + }, "node_modules/semver": { "version": "7.7.2", "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz", @@ -2985,6 +4290,19 @@ "node": ">=8" } }, + "node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/sucrase": { "version": "3.35.0", "resolved": "https://registry.npmjs.org/sucrase/-/sucrase-3.35.0.tgz", @@ -3172,6 +4490,19 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, "node_modules/tr46": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/tr46/-/tr46-1.0.1.tgz", @@ -3182,16 +4513,6 @@ "punycode": "^2.1.0" } }, - "node_modules/tr46/node_modules/punycode": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", - "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, "node_modules/tree-kill": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", @@ -3202,6 +4523,19 @@ "tree-kill": "cli.js" } }, + "node_modules/ts-api-utils": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.1.0.tgz", + "integrity": "sha512-CUgTZL1irw8u29bzrOD/nH85jqyc74D6SshFgujOIA7osm2Rz7dYH77agkx7H4FBNxDq7Cjf+IjaX/8zwFW+ZQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18.12" + }, + "peerDependencies": { + "typescript": ">=4.8.4" + } + }, "node_modules/ts-interface-checker": { "version": "0.1.13", "resolved": "https://registry.npmjs.org/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz", @@ -3285,31 +4619,6 @@ "url": "https://paulmillr.com/funding/" } }, - "node_modules/tsup/node_modules/debug": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz", - "integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "ms": "^2.1.3" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/tsup/node_modules/ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "dev": true, - "license": "MIT" - }, "node_modules/tsup/node_modules/readdirp": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz", @@ -3337,6 +4646,19 @@ "node": ">= 8" } }, + "node_modules/type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "license": "MIT", + "dependencies": { + "prelude-ls": "^1.2.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/typescript": { "version": "5.8.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz", @@ -3351,6 +4673,29 @@ "node": ">=14.17" } }, + "node_modules/typescript-eslint": { + "version": "8.32.1", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.32.1.tgz", + "integrity": "sha512-D7el+eaDHAmXvrZBy1zpzSNIRqnCOrkwTgZxTu3MUqRWk8k0q9m9Ho4+vPf7iHtgUfrK/o8IZaEApsxPlHTFCg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/eslint-plugin": "8.32.1", + "@typescript-eslint/parser": "8.32.1", + "@typescript-eslint/utils": "8.32.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <5.9.0" + } + }, "node_modules/ufo": { "version": "1.6.1", "resolved": "https://registry.npmjs.org/ufo/-/ufo-1.6.1.tgz", @@ -3387,6 +4732,16 @@ "node": ">= 10.0.0" } }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "punycode": "^2.1.0" + } + }, "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", @@ -3422,6 +4777,16 @@ "webidl-conversions": "^4.0.2" } }, + "node_modules/word-wrap": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", diff --git a/package.json b/package.json index 807303a5..069c2cec 100644 --- a/package.json +++ b/package.json @@ -54,16 +54,22 @@ "build": "tsup", "circular": "dpdm -T ./entries/all.ts", "types": "tsc --noEmit --project tsconfig.json", - "test": "npm run build && npm run types && npm run circular" + "test": "npm run lint && npm run build && npm run types && npm run circular", + "lint": "eslint src --ext .ts,.js" }, "devDependencies": { "@commitlint/cli": "^19.8.1", "@commitlint/config-conventional": "^19.8.1", + "@eslint/js": "^9.27.0", + "@eslint/json": "^0.12.0", "@types/node": "^22.15.21", "dpdm": "^3.14.0", + "eslint": "^9.27.0", + "globals": "^16.2.0", "husky": "^9.1.7", "tsup": "^8.3.5", - "typescript": "^5.6.3" + "typescript": "^5.6.3", + "typescript-eslint": "^8.32.1" }, "packageManager": "npm@11.4.1" -} +} \ No newline at end of file diff --git a/src/DataStream.ts b/src/DataStream.ts index d5ba1c90..f9b63727 100644 --- a/src/DataStream.ts +++ b/src/DataStream.ts @@ -32,7 +32,7 @@ type ReadTypeReturnValue = // TODO: check range/support for 64-bits numbers in JavaScript export class DataStream { - static DataStream: {}; + static DataStream: Record; // for backward compatibility _buffer?: MP4BoxBuffer; _byteOffset?: number; @@ -210,7 +210,7 @@ export class DataStream { return this.position >= this._byteLength; } - #isTupleType(type: any): type is TupleType { + #isTupleType(type: unknown): type is TupleType { return Array.isArray(type) && type.length === 3 && type[0] === '[]'; } @@ -1207,7 +1207,7 @@ export class DataStream { let lengthOverride: number | null = null; let charset: Charset = 'ASCII'; - let pos = this.position; + const pos = this.position; let parsedType = type as ParsedType; @@ -1476,7 +1476,7 @@ export class DataStream { let lengthOverride: number | null = null; let charset: Charset = 'ASCII'; - let pos = this.position; + const pos = this.position; let parsedType = type as ParsedType; if (typeof parsedType == 'string' && /:/.test(parsedType)) { @@ -1570,19 +1570,22 @@ export class DataStream { default: if (this.#isTupleType(parsedType)) { const [, ta, len] = parsedType; - const length = - typeof len === 'function' - ? len(struct, this, parsedType) - : typeof len == 'string' && struct[len] != null - ? // @ts-expect-error FIXME: Struct[string] is currently of type Type - parseInt(struct[len]) - : typeof len === 'number' - ? len - : len === '*' - ? null - : parseInt(len); + let length: number | null = null; + if (typeof len == 'function') { + length = len(struct, this, parsedType); + } else if (typeof len == 'string' && struct[len] != null) { + // @ts-expect-error FIXME: Struct[string] is currently of type Type + length = parseInt(struct[len]); + } else if (typeof len === 'number') { + length = len; + } else if (len === '*') { + length = null; + } else { + length = parseInt(len); + } + if (typeof ta == 'string') { - let tap = ta.replace(/(le|be)$/, ''); + const tap = ta.replace(/(le|be)$/, ''); let endianness: null | boolean = null; if (/le$/.test(ta)) { endianness = DataStream.LITTLE_ENDIAN; @@ -1620,7 +1623,7 @@ export class DataStream { if (length === null) { value = []; while (!this.isEof()) { - let u = this.readType(ta, struct); + const u = this.readType(ta, struct); if (u == null) break; value.push(u); } @@ -1644,7 +1647,7 @@ export class DataStream { break; } value.push(type); - } catch (e) { + } catch { this.position = pos; break; } @@ -1720,7 +1723,7 @@ export class DataStream { * @return Int8Array to the DataStream backing buffer. * @bundle DataStream-map.js */ - mapInt8Array(length: number, endianness?: boolean) { + mapInt8Array(length: number, _endianness?: boolean) { this._realloc(length * 1); const arr = new Int8Array(this._buffer, this.byteOffset + this.position, length); this.position += length * 1; diff --git a/src/box-diff.ts b/src/box-diff.ts index 628d3648..5da892f7 100644 --- a/src/box-diff.ts +++ b/src/box-diff.ts @@ -37,7 +37,7 @@ export function boxEqualFields(box_a: Box, box_b: Box) { if (box_a && !box_b) return false; let prop: string; for (prop in box_a) { - if (DIFF_BOXES_PROP_NAMES.indexOf(prop as any) > -1) { + if ((DIFF_BOXES_PROP_NAMES as readonly string[]).indexOf(prop) > -1) { continue; // } else if (excluded_fields && excluded_fields.indexOf(prop) > -1) { // continue; @@ -63,7 +63,7 @@ export function boxEqualFields(box_a: Box, box_b: Box) { prop === 'modification_time' ) { continue; - } else if (DIFF_PRIMITIVE_ARRAY_PROP_NAMES.indexOf(prop as any) > -1) { + } else if ((DIFF_PRIMITIVE_ARRAY_PROP_NAMES as readonly string[]).indexOf(prop) > -1) { continue; } else { if (box_a[prop] !== box_b[prop]) { @@ -80,7 +80,7 @@ export function boxEqual(box_a: Box, box_b: Box) { return false; } for (let j = 0; j < DIFF_BOXES_PROP_NAMES.length; j++) { - let name = DIFF_BOXES_PROP_NAMES[j]; + const name = DIFF_BOXES_PROP_NAMES[j]; if (box_a[name] && box_b[name]) { if (!boxEqual(box_a[name], box_b[name])) { return false; diff --git a/src/box.ts b/src/box.ts index 2fbc58cd..8402646d 100644 --- a/src/box.ts +++ b/src/box.ts @@ -231,7 +231,7 @@ export class ContainerBox extends Box { this.printHeader(output); for (let i = 0; i < this.boxes.length; i++) { if (this.boxes[i]) { - let prev_indent = output.indent; + const prev_indent = output.indent; output.indent += ' '; this.boxes[i].print(output); output.indent = prev_indent; @@ -254,7 +254,7 @@ export class ContainerBox extends Box { if (this.subBoxNames && this.subBoxNames.indexOf(box.type) != -1) { this[this.subBoxNames[this.subBoxNames.indexOf(box.type)] + 's'].push(box); } else { - let box_type = box.type !== 'uuid' ? box.type : box.uuid; + const box_type = box.type !== 'uuid' ? box.type : box.uuid; if (this[box_type]) { Log.warn( 'ContainerBox', @@ -292,10 +292,7 @@ export class SampleGroupEntry { export class TrackGroupTypeBox extends FullBox { track_group_id: number; - constructor( - public type: string, - size: number, - ) { + constructor(public type: string, size: number) { super(size); } @@ -360,12 +357,7 @@ export class SingleItemTypeReferenceBoxLarge extends Box { /** @bundle parsing/TrakReference.js */ export class TrackReferenceTypeBox extends Box { - constructor( - public type: string, - size: number, - public hdr_size: number, - public start: number, - ) { + constructor(public type: string, size: number, public hdr_size: number, public start: number) { super(size); } @@ -394,7 +386,7 @@ export function parseUUID(stream: MultiBufferStream | MP4BoxStream) { export function parseHex16(stream: MultiBufferStream | MP4BoxStream) { let hex16 = ''; for (let i = 0; i < 16; i++) { - let hex = stream.readUint8().toString(16); + const hex = stream.readUint8().toString(16); hex16 += hex.length === 1 ? '0' + hex : hex; } return hex16; @@ -406,9 +398,8 @@ export function parseOneBox( parentSize?: number, ) { let box: Box; - let start = stream.getPosition(); + const start = stream.getPosition(); let hdr_size = 0; - let diff: string | number; let uuid: string; if (stream.getEndPosition() - start < 8) { Log.debug('BoxParser', 'Not enough data in stream to parse the type and size of the box'); @@ -544,7 +535,7 @@ export function parseOneBox( } // @ts-expect-error FIXME: figure out stream-types box.parse(stream); - diff = stream.getPosition() - (box.start + box.size); + const diff = stream.getPosition() - (box.start + box.size); if (diff < 0) { Log.warn( 'BoxParser', diff --git a/src/boxes/co64.ts b/src/boxes/co64.ts index 0888dff5..112e3843 100644 --- a/src/boxes/co64.ts +++ b/src/boxes/co64.ts @@ -9,7 +9,7 @@ export class co64Box extends FullBox { parse(stream: MultiBufferStream) { this.parseFullHeader(stream); - let entry_count = stream.readUint32(); + const entry_count = stream.readUint32(); this.chunk_offsets = []; if (this.version === 0) { for (let i = 0; i < entry_count; i++) { diff --git a/src/boxes/ctts.ts b/src/boxes/ctts.ts index b8ada965..734e7dcc 100644 --- a/src/boxes/ctts.ts +++ b/src/boxes/ctts.ts @@ -12,7 +12,7 @@ export class cttsBox extends FullBox { parse(stream: MultiBufferStream) { this.parseFullHeader(stream); - let entry_count = stream.readUint32(); + const entry_count = stream.readUint32(); this.sample_counts = []; this.sample_offsets = []; if (this.version === 0) { diff --git a/src/boxes/dac3.ts b/src/boxes/dac3.ts index 2e7e15b9..3dfb55c3 100644 --- a/src/boxes/dac3.ts +++ b/src/boxes/dac3.ts @@ -13,9 +13,9 @@ export class dac3Box extends Box { bit_rate_code: number; parse(stream: MultiBufferStream) { - let tmp_byte1 = stream.readUint8(); - let tmp_byte2 = stream.readUint8(); - let tmp_byte3 = stream.readUint8(); + const tmp_byte1 = stream.readUint8(); + const tmp_byte2 = stream.readUint8(); + const tmp_byte3 = stream.readUint8(); this.fscod = tmp_byte1 >> 6; this.bsid = (tmp_byte1 >> 1) & 0x1f; this.bsmod = ((tmp_byte1 & 0x1) << 2) | ((tmp_byte2 >> 6) & 0x3); diff --git a/src/boxes/dec3.ts b/src/boxes/dec3.ts index c97b74cd..8c4c3388 100644 --- a/src/boxes/dec3.ts +++ b/src/boxes/dec3.ts @@ -20,15 +20,15 @@ export class dec3Box extends Box { ind_subs: Array; parse(stream: MultiBufferStream) { - let tmp_16 = stream.readUint16(); + const tmp_16 = stream.readUint16(); this.data_rate = tmp_16 >> 3; this.num_ind_sub = tmp_16 & 0x7; this.ind_subs = []; for (let i = 0; i < this.num_ind_sub + 1; i++) { - let tmp_byte1 = stream.readUint8(); - let tmp_byte2 = stream.readUint8(); - let tmp_byte3 = stream.readUint8(); - let ind_sub: IndSub = { + const tmp_byte1 = stream.readUint8(); + const tmp_byte2 = stream.readUint8(); + const tmp_byte3 = stream.readUint8(); + const ind_sub: IndSub = { fscod: tmp_byte1 >> 6, bsid: (tmp_byte1 >> 1) & 0x1f, bsmod: ((tmp_byte1 & 0x1) << 4) | ((tmp_byte2 >> 4) & 0xf), diff --git a/src/boxes/dfLa.ts b/src/boxes/dfLa.ts index 2164ecf6..27a02d6c 100644 --- a/src/boxes/dfLa.ts +++ b/src/boxes/dfLa.ts @@ -25,8 +25,8 @@ export class dfLaBox extends FullBox { 'RESERVED', ]; - // for (i=0; ; i++) { // to end of box - do { + let i: number; + for (i = 0; i < 1_000_000; i++) { const flagAndType = stream.readUint8(); const type = Math.min(flagAndType & BLOCKTYPE_MASK, knownBlockTypes.length - 1); @@ -49,10 +49,15 @@ export class dfLaBox extends FullBox { boxesFound.push(knownBlockTypes[type]); - if (!!(flagAndType & LASTMETADATABLOCKFLAG_MASK)) { + if (flagAndType & LASTMETADATABLOCKFLAG_MASK) { break; } - } while (true); + } + + // Defensive + if (i >= 1_000_000) { + throw new Error('dfLaBox: Too many metadata blocks found, parsing stopped'); + } this.numMetadataBlocks = boxesFound.length + ' (' + boxesFound.join(', ') + ')'; } diff --git a/src/boxes/displays/naluArrays.ts b/src/boxes/displays/naluArrays.ts index d44b032d..fa6413bb 100644 --- a/src/boxes/displays/naluArrays.ts +++ b/src/boxes/displays/naluArrays.ts @@ -7,12 +7,12 @@ export class NALUArrays extends Array { str += ''; for (let i = 0; i < this.length; i++) { - let nalu_array = this[i]; + const nalu_array = this[i]; str += ''; str += "" + nalu_array.completeness + ''; str += "" + nalu_array.nalu_type + ''; for (let j = 0; j < nalu_array.length; j++) { - let nalu = nalu_array[j]; + const nalu = nalu_array[j]; if (j !== 0) str += ''; str += ''; str += nalu.data.reduce(function (str, byte) { diff --git a/src/boxes/displays/parameterSetArray.ts b/src/boxes/displays/parameterSetArray.ts index 871cc910..eaa4facd 100644 --- a/src/boxes/displays/parameterSetArray.ts +++ b/src/boxes/displays/parameterSetArray.ts @@ -7,7 +7,7 @@ export class ParameterSetArray extends Array { str += ''; for (let i = 0; i < this.length; i++) { - let nalu = this[i]; + const nalu = this[i]; str += ''; str += '' + nalu.length + ''; str += ''; diff --git a/src/boxes/displays/pixel.ts b/src/boxes/displays/pixel.ts index e36c9472..8d17a95a 100644 --- a/src/boxes/displays/pixel.ts +++ b/src/boxes/displays/pixel.ts @@ -1,10 +1,5 @@ -import type { Nalu, NaluArray } from '@types'; - export class Pixel { - constructor( - public bad_pixel_row: number, - public bad_pixel_column: number, - ) {} + constructor(public bad_pixel_row: number, public bad_pixel_column: number) {} toString() { return '[row: ' + this.bad_pixel_row + ', column: ' + this.bad_pixel_column + ']'; } diff --git a/src/boxes/dref.ts b/src/boxes/dref.ts index 14123879..c1191369 100644 --- a/src/boxes/dref.ts +++ b/src/boxes/dref.ts @@ -14,9 +14,9 @@ export class drefBox extends FullBox { this.entries = []; const entry_count = stream.readUint32(); for (let i = 0; i < entry_count; i++) { - let ret = parseOneBox(stream, false, this.size - (stream.getPosition() - this.start)); + const ret = parseOneBox(stream, false, this.size - (stream.getPosition() - this.start)); if (ret.code === OK) { - let box = ret.box; + const box = ret.box; this.entries.push(box); } else { return; diff --git a/src/boxes/elst.ts b/src/boxes/elst.ts index 97b4988b..5fa36019 100644 --- a/src/boxes/elst.ts +++ b/src/boxes/elst.ts @@ -13,7 +13,7 @@ export class elstBox extends FullBox { this.entries = []; const entry_count = stream.readUint32(); for (let i = 0; i < entry_count; i++) { - let entry: Entry = { + const entry: Entry = { segment_duration: this.version === 1 ? stream.readUint64() : stream.readUint32(), media_time: this.version === 1 ? stream.readInt64() : stream.readInt32(), media_rate_integer: stream.readInt16(), diff --git a/src/boxes/esds.ts b/src/boxes/esds.ts index 0b380577..be60e7f1 100644 --- a/src/boxes/esds.ts +++ b/src/boxes/esds.ts @@ -12,10 +12,10 @@ export class esdsBox extends FullBox { parse(stream: MultiBufferStream) { this.parseFullHeader(stream); - let esd_data = stream.readUint8Array(this.size - this.hdr_size); + const esd_data = stream.readUint8Array(this.size - this.hdr_size); // NOTE: This used to be `typeof MPEG4DescriptorParser !== 'undefined'` if ('MPEG4DescriptorParser' in DescriptorRegistry) { - let esd_parser = new DescriptorRegistry.MPEG4DescriptorParser(); + const esd_parser = new DescriptorRegistry.MPEG4DescriptorParser(); this.esd = esd_parser.parseOneDescriptor( new DataStream(esd_data.buffer, 0, DataStream.BIG_ENDIAN), ) as ES_Descriptor; diff --git a/src/boxes/lhvC.ts b/src/boxes/lhvC.ts index b567b250..5e8da890 100644 --- a/src/boxes/lhvC.ts +++ b/src/boxes/lhvC.ts @@ -28,7 +28,7 @@ export class lhvCBox extends Box { const numOfArrays = stream.readUint8(); for (let i = 0; i < numOfArrays; i++) { - let nalu_array = [] as NaluArray; + const nalu_array = [] as NaluArray; this.nalu_arrays.push(nalu_array); tmp_byte = stream.readUint8(); nalu_array.completeness = (tmp_byte & 0x80) >> 7; diff --git a/src/boxes/sampleentries/sampleentry.ts b/src/boxes/sampleentries/sampleentry.ts index 30dd4f0a..6ae098db 100644 --- a/src/boxes/sampleentries/sampleentry.ts +++ b/src/boxes/sampleentries/sampleentry.ts @@ -194,11 +194,9 @@ class vvcCSampleEntryBase extends VisualSampleEntry { if (this.vvcC.general_constraint_info) { const bytes = []; let byte = 0; - // @ts-ignore FIXME: shouldn't it be ptl_frame_only_constraint_flag? - byte |= this.vvcC.ptl_frame_only_constraint << 7; - // @ts-ignore FIXME: shouldn't it be ptl_multilayer_enabled_flag? - byte |= this.vvcC.ptl_multilayer_enabled << 6; - let last_nonzero; + byte |= this.vvcC.ptl_frame_only_constraint_flag << 7; + byte |= this.vvcC.ptl_multilayer_enabled_flag << 6; + let last_nonzero: number | undefined = undefined; for (let i = 0; i < this.vvcC.general_constraint_info.length; ++i) { byte |= (this.vvcC.general_constraint_info[i] >> 2) & 0x3f; bytes.push(byte); @@ -221,7 +219,7 @@ class vvcCSampleEntryBase extends VisualSampleEntry { num_held_bits += 8; while (num_held_bits >= 5) { - let val = (held_bits >> (num_held_bits - 5)) & 0x1f; + const val = (held_bits >> (num_held_bits - 5)) & 0x1f; constraint_string += base32_chars[val]; num_held_bits -= 5; @@ -260,7 +258,7 @@ class vpcCSampleEntryBase extends VisualSampleEntry { vpcC: vpcCBox; vpcCs: Array; getCodec() { - let baseCodec = super.getCodec(); + const baseCodec = super.getCodec(); let level: number | string = this.vpcC.level; if (level == 0) { level = '00'; diff --git a/src/boxes/samplegroups/dtrt.ts b/src/boxes/samplegroups/dtrt.ts index c57f440c..e344491b 100644 --- a/src/boxes/samplegroups/dtrt.ts +++ b/src/boxes/samplegroups/dtrt.ts @@ -3,7 +3,7 @@ import type { MultiBufferStream } from '#/buffer'; import { Log } from '#/log'; export class dtrtSampleGroupEntry extends SampleGroupEntry { - parse(stream: MultiBufferStream) { + parse(_stream: MultiBufferStream) { Log.warn('BoxParser', 'Sample Group type: ' + this.grouping_type + ' not fully parsed'); } } diff --git a/src/boxes/samplegroups/mvif.ts b/src/boxes/samplegroups/mvif.ts index b332a033..1757bcea 100644 --- a/src/boxes/samplegroups/mvif.ts +++ b/src/boxes/samplegroups/mvif.ts @@ -3,7 +3,7 @@ import type { MultiBufferStream } from '#/buffer'; import { Log } from '#/log'; export class mvifSampleGroupEntry extends SampleGroupEntry { - parse(stream: MultiBufferStream) { + parse(_stream: MultiBufferStream) { Log.warn('BoxParser', 'Sample Group type: ' + this.grouping_type + ' not fully parsed'); } } diff --git a/src/boxes/samplegroups/scif.ts b/src/boxes/samplegroups/scif.ts index 8afa0c86..780ff1f1 100644 --- a/src/boxes/samplegroups/scif.ts +++ b/src/boxes/samplegroups/scif.ts @@ -3,7 +3,7 @@ import type { MultiBufferStream } from '#/buffer'; import { Log } from '#/log'; export class scifSampleGroupEntry extends SampleGroupEntry { - parse(stream: MultiBufferStream) { + parse(_stream: MultiBufferStream) { Log.warn('BoxParser', 'Sample Group type: ' + this.grouping_type + ' not fully parsed'); } } diff --git a/src/boxes/samplegroups/scnm.ts b/src/boxes/samplegroups/scnm.ts index a6514809..acb713d3 100644 --- a/src/boxes/samplegroups/scnm.ts +++ b/src/boxes/samplegroups/scnm.ts @@ -3,7 +3,7 @@ import type { MultiBufferStream } from '#/buffer'; import { Log } from '#/log'; export class scnmSampleGroupEntry extends SampleGroupEntry { - parse(stream: MultiBufferStream) { + parse(_stream: MultiBufferStream) { Log.warn('BoxParser', 'Sample Group type: ' + this.grouping_type + ' not fully parsed'); } } diff --git a/src/boxes/samplegroups/stsa.ts b/src/boxes/samplegroups/stsa.ts index fef1f839..95c40a45 100644 --- a/src/boxes/samplegroups/stsa.ts +++ b/src/boxes/samplegroups/stsa.ts @@ -3,7 +3,7 @@ import { Log } from '#//log'; import type { MultiBufferStream } from '#/buffer'; export class stsaSampleGroupEntry extends SampleGroupEntry { - parse(stream: MultiBufferStream) { + parse(_stream: MultiBufferStream) { Log.warn('BoxParser', 'Sample Group type: ' + this.grouping_type + ' not fully parsed'); } } diff --git a/src/boxes/samplegroups/tsas.ts b/src/boxes/samplegroups/tsas.ts index 913716c3..622233d1 100644 --- a/src/boxes/samplegroups/tsas.ts +++ b/src/boxes/samplegroups/tsas.ts @@ -3,7 +3,7 @@ import { Log } from '#//log'; import type { MultiBufferStream } from '#/buffer'; export class tsasSampleGroupEntry extends SampleGroupEntry { - parse(stream: MultiBufferStream) { + parse(_stream: MultiBufferStream) { Log.warn('BoxParser', 'Sample Group type: ' + this.grouping_type + ' not fully parsed'); } } diff --git a/src/boxes/samplegroups/tscl.ts b/src/boxes/samplegroups/tscl.ts index 50c391a9..ae351ff5 100644 --- a/src/boxes/samplegroups/tscl.ts +++ b/src/boxes/samplegroups/tscl.ts @@ -3,7 +3,7 @@ import { Log } from '#//log'; import type { MultiBufferStream } from '#/buffer'; export class tsclSampleGroupEntry extends SampleGroupEntry { - parse(stream: MultiBufferStream) { + parse(_stream: MultiBufferStream) { Log.warn('BoxParser', 'Sample Group type: ' + this.grouping_type + ' not fully parsed'); } } diff --git a/src/boxes/samplegroups/vipr.ts b/src/boxes/samplegroups/vipr.ts index 1d3b1fb5..46923e74 100644 --- a/src/boxes/samplegroups/vipr.ts +++ b/src/boxes/samplegroups/vipr.ts @@ -3,7 +3,7 @@ import { Log } from '#//log'; import type { MultiBufferStream } from '#/buffer'; export class viprSampleGroupEntry extends SampleGroupEntry { - parse(stream: MultiBufferStream) { + parse(_stream: MultiBufferStream) { Log.warn('BoxParser', 'Sample Group type: ' + this.grouping_type + ' not fully parsed'); } } diff --git a/src/boxes/sbgp.ts b/src/boxes/sbgp.ts index ad808b6c..7482b0a8 100644 --- a/src/boxes/sbgp.ts +++ b/src/boxes/sbgp.ts @@ -42,7 +42,7 @@ export class sbgpBox extends FullBox { stream.writeUint32(this.grouping_type_parameter); stream.writeUint32(this.entries.length); for (let i = 0; i < this.entries.length; i++) { - let entry = this.entries[i]; + const entry = this.entries[i]; stream.writeInt32(entry.sample_count); stream.writeInt32(entry.group_description_index); } diff --git a/src/boxes/sbpm.ts b/src/boxes/sbpm.ts index d652ab70..3058b961 100644 --- a/src/boxes/sbpm.ts +++ b/src/boxes/sbpm.ts @@ -38,8 +38,8 @@ export class sbpmBox extends FullBox { this.bad_columns.push(stream.readUint32()); } for (let i = 0; i < this.num_bad_pixels; i++) { - let row = stream.readUint32(); - let col = stream.readUint32(); + const row = stream.readUint32(); + const col = stream.readUint32(); this.bad_pixels.push(new Pixel(row, col)); } } diff --git a/src/boxes/sgpd.ts b/src/boxes/sgpd.ts index 8ab4849d..bbb7a72b 100644 --- a/src/boxes/sgpd.ts +++ b/src/boxes/sgpd.ts @@ -88,7 +88,7 @@ export class sgpdBox extends FullBox { this.flags = 0; this.size = 12; for (let i = 0; i < this.entries.length; i++) { - let entry = this.entries[i]; + const entry = this.entries[i]; if (this.version === 1) { if (this.default_length === 0) { this.size += 4; @@ -106,7 +106,7 @@ export class sgpdBox extends FullBox { } stream.writeUint32(this.entries.length); for (let i = 0; i < this.entries.length; i++) { - let entry = this.entries[i]; + const entry = this.entries[i]; if (this.version === 1) { if (this.default_length === 0) { stream.writeUint32(entry.description_length); diff --git a/src/boxes/ssix.ts b/src/boxes/ssix.ts index 96e82ff5..2dd50269 100644 --- a/src/boxes/ssix.ts +++ b/src/boxes/ssix.ts @@ -25,7 +25,7 @@ export class ssixBox extends FullBox { subsegment.ranges = []; const range_count = stream.readUint32(); for (let j = 0; j < range_count; j++) { - let range = {} as Range; + const range = {} as Range; subsegment.ranges.push(range); range.level = stream.readUint8(); range.range_size = stream.readUint24(); diff --git a/src/boxes/stdp.ts b/src/boxes/stdp.ts index 447cf394..7ef4d5cb 100644 --- a/src/boxes/stdp.ts +++ b/src/boxes/stdp.ts @@ -9,7 +9,7 @@ export class stdpBox extends FullBox { parse(stream: MultiBufferStream) { this.parseFullHeader(stream); - let count = (this.size - this.hdr_size) / 2; + const count = (this.size - this.hdr_size) / 2; this.priority = []; for (let i = 0; i < count; i++) { this.priority[i] = stream.readUint16(); diff --git a/src/boxes/stsd.ts b/src/boxes/stsd.ts index eb1726c9..33278155 100644 --- a/src/boxes/stsd.ts +++ b/src/boxes/stsd.ts @@ -18,7 +18,7 @@ export class stsdBox extends FullBox { const entryCount = stream.readUint32(); for (let i = 1; i <= entryCount; i++) { - let ret = parseOneBox(stream, true, this.size - (stream.getPosition() - this.start)); + const ret = parseOneBox(stream, true, this.size - (stream.getPosition() - this.start)); if (ret.code === OK) { let box: SampleEntry; diff --git a/src/boxes/stsh.ts b/src/boxes/stsh.ts index 4cb777d0..a7d4afe6 100644 --- a/src/boxes/stsh.ts +++ b/src/boxes/stsh.ts @@ -10,7 +10,7 @@ export class stshBox extends FullBox { parse(stream: MultiBufferStream) { this.parseFullHeader(stream); - let entry_count = stream.readUint32(); + const entry_count = stream.readUint32(); this.shadowed_sample_numbers = []; this.sync_sample_numbers = []; if (this.version === 0) { diff --git a/src/boxes/stss.ts b/src/boxes/stss.ts index 3c47fee3..4957f7d0 100644 --- a/src/boxes/stss.ts +++ b/src/boxes/stss.ts @@ -9,7 +9,7 @@ export class stssBox extends FullBox { parse(stream: MultiBufferStream) { this.parseFullHeader(stream); - let entry_count = stream.readUint32(); + const entry_count = stream.readUint32(); if (this.version === 0) { this.sample_numbers = []; for (let i = 0; i < entry_count; i++) { diff --git a/src/boxes/taic.ts b/src/boxes/taic.ts index 7aa3e3f6..04a60981 100644 --- a/src/boxes/taic.ts +++ b/src/boxes/taic.ts @@ -14,7 +14,7 @@ export class taicBox extends FullBox { this.time_uncertainty = stream.readUint64(); this.clock_resolution = stream.readUint32(); this.clock_drift_rate = stream.readInt32(); - var reserved_byte = stream.readUint8(); + const reserved_byte = stream.readUint8(); this.clock_type = (reserved_byte & 0xc0) >> 6; } } diff --git a/src/boxes/trep.ts b/src/boxes/trep.ts index ca8fc2b5..f115aa44 100644 --- a/src/boxes/trep.ts +++ b/src/boxes/trep.ts @@ -13,9 +13,9 @@ export class trepBox extends FullBox { this.track_ID = stream.readUint32(); this.boxes = []; while (stream.getPosition() < this.start + this.size) { - let ret = parseOneBox(stream, false, this.size - (stream.getPosition() - this.start)); + const ret = parseOneBox(stream, false, this.size - (stream.getPosition() - this.start)); if (ret.code === OK) { - let box = ret.box; + const box = ret.box; this.boxes.push(box); } else { return; diff --git a/src/buffer.ts b/src/buffer.ts index 5af855e3..2cebee5b 100644 --- a/src/buffer.ts +++ b/src/buffer.ts @@ -31,7 +31,6 @@ export class MultiBufferStream extends DataStream { bufferIndex: number; constructor(buffer?: MP4BoxBuffer) { - // @ts-ignore FIXME expects byteLength super(new ArrayBuffer(), 0, DataStream.BIG_ENDIAN); // List of ArrayBuffers, with a fileStart property, sorted in fileStart order and non-overlapping this.buffers = []; @@ -282,7 +281,7 @@ export class MultiBufferStream extends DataStream { * should be marked as used for garbage collection * @return {Number} the index of the buffer holding the seeked file position, -1 if not found. */ - findPosition(fromStart: boolean, filePosition: number, markAsUsed: boolean) { + findPosition(fromStart: boolean, filePosition: number, markAsUsed: boolean): number { let index = -1; let i = fromStart === true ? 0 : this.bufferIndex; @@ -324,8 +323,8 @@ export class MultiBufferStream extends DataStream { * @param {Number} inputindex Index of the buffer to start from * @return {Number} The largest file position found in the buffers */ - findEndContiguousBuf(inputindex?: number) { - let index = inputindex !== undefined ? inputindex : this.bufferIndex; + findEndContiguousBuf(inputindex?: number): number { + const index = inputindex !== undefined ? inputindex : this.bufferIndex; let currentBuf = this.buffers[index]; /* find the end of the contiguous range of data */ if (this.buffers.length > index + 1) { @@ -348,7 +347,7 @@ export class MultiBufferStream extends DataStream { * @return {Number} the largest position in the current buffer or in the buffer and the next contiguous * buffer that holds the given position */ - getEndFilePositionAfter(pos: number) { + getEndFilePositionAfter(pos: number): number { const index = this.findPosition(true, pos, false); if (index !== -1) { return this.findEndContiguousBuf(index); diff --git a/src/descriptor.ts b/src/descriptor.ts index 95ed4acc..70fbe6e0 100644 --- a/src/descriptor.ts +++ b/src/descriptor.ts @@ -16,10 +16,7 @@ export class Descriptor { descs = []; data: Uint8Array; - constructor( - public tag: number, - public size: number, - ) {} + constructor(public tag: number, public size: number) {} parse(stream: DataStream) { this.data = stream.readUint8Array(this.size); @@ -35,16 +32,12 @@ export class Descriptor { } parseOneDescriptor(stream: DataStream): DescriptorKinds { - let hdrSize = 0; let size = 0; const tag = stream.readUint8(); - hdrSize++; let byteRead = stream.readUint8(); - hdrSize++; while (byteRead & 0x80) { size = (size << 7) + (byteRead & 0x7f); byteRead = stream.readUint8(); - hdrSize++; } size = (size << 7) + (byteRead & 0x7f); Log.debug( @@ -66,10 +59,10 @@ export class Descriptor { } parseRemainingDescriptors(stream: DataStream) { - let start = stream.position; + const start = stream.position; while (stream.position < start + this.size) { console.log('this.parseOneDescriptor', this, this.parseOneDescriptor); - let desc = this.parseOneDescriptor?.(stream); + const desc = this.parseOneDescriptor?.(stream); this.descs.push(desc); } } diff --git a/src/isofile.ts b/src/isofile.ts index 156c6e29..90d42a51 100644 --- a/src/isofile.ts +++ b/src/isofile.ts @@ -143,7 +143,7 @@ export interface IsoFileOptions { default_sample_flags?: number; } -export class ISOFile { +export class ISOFile { /** MutiBufferStream object used to parse boxes */ stream: MultiBufferStream; /** Array of all boxes (in order) found in the file */ @@ -270,7 +270,7 @@ export class ISOFile { user?: TSampleUser, { nbSamples: nb_samples = 1000 }: { nbSamples?: number } = {}, ) { - let trak = this.getTrackById(id); + const trak = this.getTrackById(id); if (trak) { this.extractedTracks.push({ id, @@ -286,7 +286,7 @@ export class ISOFile { unsetExtractionOptions(id: number) { let index = -1; for (let i = 0; i < this.extractedTracks.length; i++) { - let extractTrack = this.extractedTracks[i]; + const extractTrack = this.extractedTracks[i]; if (extractTrack.id == id) { index = i; } @@ -297,7 +297,7 @@ export class ISOFile { } parse() { - let parseBoxHeadersOnly = false; + const parseBoxHeadersOnly = false; if (this.restoreParsePosition) { if (!this.restoreParsePosition()) { @@ -367,9 +367,8 @@ export class ISOFile { break; } } - if (this.updateUsedBytes) { - this.updateUsedBytes(box, ret); - } + + this.updateUsedBytes(box, ret); } } } @@ -1502,7 +1501,7 @@ export class ISOFile { ISOFile.initSampleGroups(trak, traf, traf.sbgps, trak.mdia.minf.stbl.sgpds, traf.sgpds); } for (let j = 0; j < traf.truns.length; j++) { - let trun = traf.truns[j]; + const trun = traf.truns[j]; for (let k = 0; k < trun.sample_count; k++) { const description_index = default_sample_description_index - 1; @@ -1670,10 +1669,10 @@ export class ISOFile { /* The sample has only been partially fetched, we need to check in all buffers */ while (true) { - let index = this.stream.findPosition(true, sample.offset + sample.alreadyRead, false); + const index = this.stream.findPosition(true, sample.offset + sample.alreadyRead, false); if (index > -1) { const buffer = this.stream.buffers[index]; - let lengthAfterStart = + const lengthAfterStart = buffer.byteLength - (sample.offset + sample.alreadyRead - buffer.fileStart); if (sample.size - sample.alreadyRead <= lengthAfterStart) { /* the (rest of the) sample is entirely contained in this buffer */ @@ -1814,7 +1813,7 @@ export class ISOFile { return null; } for (let j = 0; j < this.moov.traks.length; j++) { - let trak = this.moov.traks[j]; + const trak = this.moov.traks[j]; if (trak.tkhd.track_id == id) return trak; } return null; @@ -1893,7 +1892,7 @@ export class ISOFile { } if (meta.iref) { for (let i = 0; i < meta.iref.references.length; i++) { - let ref = meta.iref.references[i]; + const ref = meta.iref.references[i]; for (let j = 0; j < ref.references.length; j++) { items[ref.from_item_ID].ref_to.push({ type: ref.type, id: ref.references[j] }); } @@ -1901,9 +1900,9 @@ export class ISOFile { } if (meta.iprp) { for (let k = 0; k < meta.iprp.ipmas.length; k++) { - let ipma = meta.iprp.ipmas[k]; + const ipma = meta.iprp.ipmas[k]; for (let i = 0; i < ipma.associations.length; i++) { - let association = ipma.associations[i]; + const association = ipma.associations[i]; const item = items[association.id] ?? entity_groups[association.id]; if (item) { if (item.properties === undefined) { @@ -1912,12 +1911,12 @@ export class ISOFile { }; } for (let j = 0; j < association.props.length; j++) { - let propEntry = association.props[j]; + const propEntry = association.props[j]; if ( propEntry.property_index > 0 && propEntry.property_index - 1 < meta.iprp.ipco.boxes.length ) { - let propbox = meta.iprp.ipco.boxes[propEntry.property_index - 1]; + const propbox = meta.iprp.ipco.boxes[propEntry.property_index - 1]; item.properties[propbox.type] = propbox; item.properties.boxes.push(propbox); } @@ -2078,7 +2077,7 @@ export class ISOFile { /** @bundle isofile-item-processing.js */ processItems(callback: (item: Item) => void) { - for (let i in this.items) { + for (const i in this.items) { const item = this.items[i]; this.getItem(item.id); if (callback && !item.sent) { @@ -2091,7 +2090,7 @@ export class ISOFile { /** @bundle isofile-item-processing.js */ hasItem(name: string) { - for (let i in this.items) { + for (const i in this.items) { const item = this.items[i]; if (item.name === name) { return item.id; @@ -2193,7 +2192,7 @@ export class ISOFile { /* indicate that the parsing should start from the end of the box */ this.lastBoxStartPosition = box.start + box.size; /* let's see if we have the end of the box in the other buffers */ - let found = this.stream.seek(box.start + box.size, false, this.discardMdatData); + const found = this.stream.seek(box.start + box.size, false, this.discardMdatData); if (found) { /* found the end of the box */ this.parsingMdat = null; @@ -2228,7 +2227,7 @@ export class ISOFile { (TODO: we could skip 'free' boxes ...) or we did not have enough data to parse the type and size of the box, we try to concatenate the current buffer with the next buffer to restart parsing */ - let merged = this.stream.mergeNextBuffer ? this.stream.mergeNextBuffer() : false; + const merged = this.stream.mergeNextBuffer ? this.stream.mergeNextBuffer() : false; if (merged) { /* The next buffer was contiguous, the merging succeeded, we can now continue parsing, @@ -2295,7 +2294,7 @@ export class ISOFile { } /** @bundle isofile-advanced-parsing.js */ - updateUsedBytes(box: Box, ret: ReturnType) { + updateUsedBytes(box: Box, _ret: ReturnType) { if (this.stream.addUsedBytes) { if (box.type === 'mdat') { /* for an mdat box, only its header is considered used, other bytes will be used when sample data is requested */ @@ -2395,7 +2394,6 @@ export class ISOFile { vmhd.graphicsmode = 0; vmhd.opcolor = [0, 0, 0]; - sample_description_entry; (sample_description_entry as VisualSampleEntry).width = options.width; (sample_description_entry as VisualSampleEntry).height = options.height; (sample_description_entry as VisualSampleEntry).horizresolution = 0x48 << 16; @@ -2511,7 +2509,7 @@ export class ISOFile { offset?: number; } = {}, ) { - let trak = this.getTrackById(track_id); + const trak = this.getTrackById(track_id); if (trak === null) return; const descriptionIndex = sample_description_index ? sample_description_index - 1 : 0; @@ -2561,8 +2559,7 @@ export class ISOFile { /** @bundle isofile-advanced-creation.js */ createSingleSampleMoof(sample: Sample) { let sample_flags = 0; - if (sample.is_sync) - sample_flags = 1 << 25; // sample_depends_on_none (I picture) + if (sample.is_sync) sample_flags = 1 << 25; // sample_depends_on_none (I picture) else sample_flags = 1 << 16; // non-sync const moof = new moofBox(); diff --git a/src/log.ts b/src/log.ts index 33c51063..7cb37eed 100644 --- a/src/log.ts +++ b/src/log.ts @@ -31,7 +31,7 @@ export class Log { ); } } - static log(module: { msg: string }, msg?: string) { + static log(module: { msg: string }, _msg?: string) { this.debug(module.msg); } static info(module: string, msg?: string) { @@ -103,8 +103,8 @@ export class Log { /* Helper function to stringify HTML5 TimeRanges objects */ static printRanges(ranges: { length: number; - start: (index: number) => any; - end: (index: number) => any; + start: (index: number) => number; + end: (index: number) => number; }) { const length = ranges.length; if (length > 0) { diff --git a/src/text-mp4.ts b/src/text-mp4.ts index 98a4b2d9..911ebcc0 100644 --- a/src/text-mp4.ts +++ b/src/text-mp4.ts @@ -39,7 +39,7 @@ export class VTTin4Parser { const cues = this.parseSample(data); let string = ''; for (let i = 0; i < cues.length; i++) { - let cueIn4 = cues[i]; + const cueIn4 = cues[i]; string += secToTimestamp(startTime) + ' --> ' + secToTimestamp(endTime) + '\r\n'; // @ts-expect-error FIXME: which box should get a payl-property? string += cueIn4.payl.text; @@ -75,17 +75,13 @@ export class XMLSubtitlein4Parser { export class Textin4Parser { parseSample(sample: Sample) { - let textString: string; - let stream = new MP4BoxStream(sample.data.buffer); - textString = stream.readString(sample.data.length); - return textString; + const stream = new MP4BoxStream(sample.data.buffer); + return stream.readString(sample.data.length); } parseConfig(data: TypedArray) { - let textString: string; - let stream = new MP4BoxStream(data.buffer); + const stream = new MP4BoxStream(data.buffer); stream.readUint32(); // version & flags - textString = stream.readCString(); - return textString; + return stream.readCString(); } } From 27ba5da684ee41cb1cf81ae371284ec857ed38ce Mon Sep 17 00:00:00 2001 From: Erwan Vivien Date: Mon, 26 May 2025 11:17:57 +0200 Subject: [PATCH 02/16] feat: ESLint add eqeqeq rule --- eslint.config.js | 4 + src/DataStream.ts | 128 ++++++++++++------------- src/box.ts | 8 +- src/boxes/a1lx.ts | 2 +- src/boxes/ccst.ts | 4 +- src/boxes/cmex.ts | 4 +- src/boxes/ctts.ts | 2 +- src/boxes/emsg.ts | 4 +- src/boxes/mdhd.ts | 2 +- src/boxes/mehd.ts | 2 +- src/boxes/mvhd.ts | 2 +- src/boxes/sampleentries/sampleentry.ts | 6 +- src/boxes/sbpm.ts | 2 +- src/boxes/subs.ts | 2 +- src/boxes/tfdt.ts | 2 +- src/boxes/tkhd.ts | 2 +- src/boxes/uncC.ts | 4 +- src/boxes/vvcC.ts | 2 +- src/descriptor.ts | 2 +- src/isofile.ts | 32 +++---- src/log.ts | 8 +- 21 files changed, 114 insertions(+), 110 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index a0852dc5..466224f6 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -11,6 +11,10 @@ export default defineConfig([ { files: ['**/*.json'], plugins: { json }, language: 'json/json', extends: ['json/recommended'] }, { rules: { + eqeqeq: ['error', 'always'], + 'linebreak-style': ['error', 'unix'], + 'one-var': ['error', 'never'], + semi: ['error', 'always'], '@typescript-eslint/no-unused-vars': [ 'error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }, diff --git a/src/DataStream.ts b/src/DataStream.ts index f9b63727..0a4866a0 100644 --- a/src/DataStream.ts +++ b/src/DataStream.ts @@ -64,7 +64,7 @@ export class DataStream { this.buffer = new MP4BoxBuffer(arrayBuffer || 0); } this.position = 0; - this.endianness = endianness == null ? DataStream.LITTLE_ENDIAN : endianness; + this.endianness = endianness === null ? DataStream.LITTLE_ENDIAN : endianness; } getPosition() { @@ -108,7 +108,7 @@ export class DataStream { * growing the buffer with writes and not filling the extra space completely). */ _trimAlloc() { - if (this._byteLength == this._buffer.byteLength) { + if (this._byteLength === this._buffer.byteLength) { return; } const buf = new MP4BoxBuffer(this._byteLength); @@ -238,7 +238,7 @@ export class DataStream { * @return The read Int32Array. */ readInt32Array(length: number | null, endianness?: boolean | null) { - length = length == null ? this.byteLength - this.position / 4 : length; + length = length === null ? this.byteLength - this.position / 4 : length; const arr = new Int32Array(length); DataStream.memcpy( arr.buffer, @@ -247,7 +247,7 @@ export class DataStream { this.byteOffset + this.position, length * arr.BYTES_PER_ELEMENT, ); - DataStream.arrayToNative(arr, endianness == null ? this.endianness : endianness); + DataStream.arrayToNative(arr, endianness === null ? this.endianness : endianness); this.position += arr.byteLength; return arr; } @@ -260,7 +260,7 @@ export class DataStream { * @return The read Int16Array. */ readInt16Array(length: number | null, endianness?: boolean | null) { - length = length == null ? this.byteLength - this.position / 2 : length; + length = length === null ? this.byteLength - this.position / 2 : length; const arr = new Int16Array(length); DataStream.memcpy( arr.buffer, @@ -269,7 +269,7 @@ export class DataStream { this.byteOffset + this.position, length * arr.BYTES_PER_ELEMENT, ); - DataStream.arrayToNative(arr, endianness == null ? this.endianness : endianness); + DataStream.arrayToNative(arr, endianness === null ? this.endianness : endianness); this.position += arr.byteLength; return arr; } @@ -282,7 +282,7 @@ export class DataStream { * @return The read Int8Array. */ readInt8Array(length: number | null) { - length = length == null ? this.byteLength - this.position : length; + length = length === null ? this.byteLength - this.position : length; const arr = new Int8Array(length); DataStream.memcpy( arr.buffer, @@ -303,7 +303,7 @@ export class DataStream { * @return The read Uint32Array. */ readUint32Array(length: number | null, endianness?: boolean | null) { - length = length == null ? this.byteLength - this.position / 4 : length; + length = length === null ? this.byteLength - this.position / 4 : length; const arr = new Uint32Array(length); DataStream.memcpy( arr.buffer, @@ -312,7 +312,7 @@ export class DataStream { this.byteOffset + this.position, length * arr.BYTES_PER_ELEMENT, ); - DataStream.arrayToNative(arr, endianness == null ? this.endianness : endianness); + DataStream.arrayToNative(arr, endianness === null ? this.endianness : endianness); this.position += arr.byteLength; return arr; } @@ -325,7 +325,7 @@ export class DataStream { * @return The read Uint16Array. */ readUint16Array(length: number | null, endianness?: boolean) { - length = length == null ? this.byteLength - this.position / 2 : length; + length = length === null ? this.byteLength - this.position / 2 : length; const arr = new Uint16Array(length); DataStream.memcpy( arr.buffer, @@ -334,7 +334,7 @@ export class DataStream { this.byteOffset + this.position, length * arr.BYTES_PER_ELEMENT, ); - DataStream.arrayToNative(arr, endianness == null ? this.endianness : endianness); + DataStream.arrayToNative(arr, endianness === null ? this.endianness : endianness); this.position += arr.byteLength; return arr; } @@ -347,7 +347,7 @@ export class DataStream { * @return The read Uint8Array. */ readUint8Array(length: number | null) { - length = length == null ? this.byteLength - this.position : length; + length = length === null ? this.byteLength - this.position : length; const arr = new Uint8Array(length); DataStream.memcpy( arr.buffer, @@ -368,7 +368,7 @@ export class DataStream { * @return The read Float64Array. */ readFloat64Array(length: number | null, endianness?: boolean) { - length = length == null ? this.byteLength - this.position / 8 : length; + length = length === null ? this.byteLength - this.position / 8 : length; const arr = new Float64Array(length); DataStream.memcpy( arr.buffer, @@ -377,7 +377,7 @@ export class DataStream { this.byteOffset + this.position, length * arr.BYTES_PER_ELEMENT, ); - DataStream.arrayToNative(arr, endianness == null ? this.endianness : endianness); + DataStream.arrayToNative(arr, endianness === null ? this.endianness : endianness); this.position += arr.byteLength; return arr; } @@ -390,7 +390,7 @@ export class DataStream { * @return The read Float32Array. */ readFloat32Array(length: number | null, endianness?: boolean) { - length = length == null ? this.byteLength - this.position / 4 : length; + length = length === null ? this.byteLength - this.position / 4 : length; const arr = new Float32Array(length); DataStream.memcpy( arr.buffer, @@ -399,7 +399,7 @@ export class DataStream { this.byteOffset + this.position, length * arr.BYTES_PER_ELEMENT, ); - DataStream.arrayToNative(arr, endianness == null ? this.endianness : endianness); + DataStream.arrayToNative(arr, endianness === null ? this.endianness : endianness); this.position += arr.byteLength; return arr; } @@ -413,7 +413,7 @@ export class DataStream { readInt32(endianness?: boolean | null) { const v = this._dataView.getInt32( this.position, - endianness == null ? this.endianness : endianness, + endianness === null ? this.endianness : endianness, ); this.position += 4; return v; @@ -428,7 +428,7 @@ export class DataStream { readInt16(endianness?: boolean) { const v = this._dataView.getInt16( this.position, - endianness == null ? this.endianness : endianness, + endianness === null ? this.endianness : endianness, ); this.position += 2; return v; @@ -454,7 +454,7 @@ export class DataStream { readUint32(endianness?: boolean | null) { const v = this._dataView.getUint32( this.position, - endianness == null ? this.endianness : endianness, + endianness === null ? this.endianness : endianness, ); this.position += 4; return v; @@ -469,7 +469,7 @@ export class DataStream { readUint16(endianness?: boolean | null) { const v = this._dataView.getUint16( this.position, - endianness == null ? this.endianness : endianness, + endianness === null ? this.endianness : endianness, ); this.position += 2; return v; @@ -495,7 +495,7 @@ export class DataStream { readFloat32(endianness?: boolean | null) { const value = this._dataView.getFloat32( this.position, - endianness == null ? this.endianness : endianness, + endianness === null ? this.endianness : endianness, ); this.position += 4; return value; @@ -510,7 +510,7 @@ export class DataStream { readFloat64(endianness?: boolean | null) { const value = this._dataView.getFloat64( this.position, - endianness == null ? this.endianness : endianness, + endianness === null ? this.endianness : endianness, ); this.position += 8; return value; @@ -554,7 +554,7 @@ export class DataStream { * @return The converted typed array. */ static arrayToNative(typedArray: TypedArray, endianness?: boolean) { - if (endianness == this.endianness) { + if (endianness === this.endianness) { return typedArray; } else { return this.flipArrayEndianness(typedArray); @@ -570,7 +570,7 @@ export class DataStream { * @return The converted typed array. */ static nativeToEndian(typedArray: TypedArray, littleEndian: boolean) { - if (this.endianness == littleEndian) { + if (this.endianness === littleEndian) { return typedArray; } else { return this.flipArrayEndianness(typedArray); @@ -612,9 +612,9 @@ export class DataStream { * @return The read string. */ readString(length: number, encoding?: Charset | null): string { - if (encoding == null || encoding == 'ASCII') { + if (encoding === null || encoding === 'ASCII') { return fromCharCodeUint8( - this.mapUint8Array(length == null ? this.byteLength - this.position : length), + this.mapUint8Array(length === null ? this.byteLength - this.position : length), ); } else { return new TextDecoder(encoding).decode(this.mapUint8Array(length)); @@ -633,14 +633,14 @@ export class DataStream { const blen = this.byteLength - this.position; const u8 = new Uint8Array(this._buffer, this._byteOffset + this.position); let len = blen; - if (length != null) { + if (length !== null) { len = Math.min(length, blen); } for (; i < len && u8[i] !== 0; i++); // find first zero byte const s = fromCharCodeUint8(this.mapUint8Array(i)); - if (length != null) { + if (length !== null) { this.position += len - i; - } else if (i != blen) { + } else if (i !== blen) { this.position += 1; // trailing zero if not at end of buffer } return s; @@ -956,7 +956,7 @@ export class DataStream { this._dataView.setBigInt64( this.position, BigInt(value), - endianness == null ? this.endianness : endianness, + endianness === null ? this.endianness : endianness, ); this.position += 8; } @@ -973,7 +973,7 @@ export class DataStream { this._dataView.setInt32( this.position, value, - endianness == null ? this.endianness : endianness, + endianness === null ? this.endianness : endianness, ); this.position += 4; } @@ -990,7 +990,7 @@ export class DataStream { this._dataView.setInt16( this.position, value, - endianness == null ? this.endianness : endianness, + endianness === null ? this.endianness : endianness, ); this.position += 2; } @@ -1019,7 +1019,7 @@ export class DataStream { this._dataView.setUint32( this.position, value, - endianness == null ? this.endianness : endianness, + endianness === null ? this.endianness : endianness, ); this.position += 4; } @@ -1036,7 +1036,7 @@ export class DataStream { this._dataView.setUint16( this.position, value, - endianness == null ? this.endianness : endianness, + endianness === null ? this.endianness : endianness, ); this.position += 2; } @@ -1065,7 +1065,7 @@ export class DataStream { this._dataView.setFloat32( this.position, value, - endianness == null ? this.endianness : endianness, + endianness === null ? this.endianness : endianness, ); this.position += 4; } @@ -1082,7 +1082,7 @@ export class DataStream { this._dataView.setFloat64( this.position, value, - endianness == null ? this.endianness : endianness, + endianness === null ? this.endianness : endianness, ); this.position += 8; } @@ -1099,7 +1099,7 @@ export class DataStream { * @bundle DataStream-write.js */ writeUCS2String(value: string, endianness: boolean, lengthOverride?: number) { - if (lengthOverride == null) { + if (lengthOverride === null) { lengthOverride = value.length; } let i: number; @@ -1122,8 +1122,8 @@ export class DataStream { */ writeString(value: string, encoding?: string, length?: number) { let i = 0; - if (encoding == null || encoding == 'ASCII') { - if (length != null) { + if (encoding === null || encoding === 'ASCII') { + if (length !== null) { const len = Math.min(value.length, length); for (i = 0; i < len; i++) { this.writeUint8(value.charCodeAt(i)); @@ -1154,7 +1154,7 @@ export class DataStream { */ writeCString(value: string, length?: number) { let i = 0; - if (length != null) { + if (length !== null) { const len = Math.min(value.length, length); for (i = 0; i < len; i++) { this.writeUint8(value.charCodeAt(i)); @@ -1199,9 +1199,9 @@ export class DataStream { * @bundle DataStream-write.js */ writeType(type: T, value: ValueFromType, struct?: Record) { - if (typeof type == 'function') { + if (typeof type === 'function') { return type(this, value); - } else if (typeof type == 'object' && !(type instanceof Array)) { + } else if (typeof type === 'object' && !(type instanceof Array)) { return type.set(this, value, struct); } @@ -1211,12 +1211,12 @@ export class DataStream { let parsedType = type as ParsedType; - if (typeof type == 'string' && /:/.test(type)) { + if (typeof type === 'string' && /:/.test(type)) { const tp = type.split(':'); parsedType = tp[0] as `cstring` | `string`; lengthOverride = parseInt(tp[1]); } - if (typeof parsedType == 'string' && /,/.test(parsedType)) { + if (typeof parsedType === 'string' && /,/.test(parsedType)) { const tp = parsedType.split(','); parsedType = tp[0] as `cstring` | `string`; // NOTE: this said `charset = parseInt(tp[1])` before; @@ -1311,7 +1311,7 @@ export class DataStream { break; } } - if (lengthOverride != null) { + if (lengthOverride !== null) { this.position = pos; this._realloc(lengthOverride); this.position = pos + lengthOverride; @@ -1425,7 +1425,7 @@ export class DataStream { for (let i = 0; i < structDefinition.length; i += 1) { const t = structDefinition[i][1]; const v = this.readType(t, struct); - if (v == null) { + if (v === null) { if (this.failurePosition === 0) { this.failurePosition = this.position; } @@ -1461,13 +1461,13 @@ export class DataStream { * @bundle DataStream-read-struct.js */ readType(type: T, struct: Record): ReadTypeReturnValue { - if (typeof type == 'function') { + if (typeof type === 'function') { return type(this, struct); } - if (typeof type == 'object' && !(type instanceof Array)) { + if (typeof type === 'object' && !(type instanceof Array)) { return type.get(this, struct); } - if (type instanceof Array && type.length != 3) { + if (type instanceof Array && type.length !== 3) { // NOTE: this said `return this.readStruct(type, struct);` before return this.readStruct(type); } @@ -1479,12 +1479,12 @@ export class DataStream { const pos = this.position; let parsedType = type as ParsedType; - if (typeof parsedType == 'string' && /:/.test(parsedType)) { + if (typeof parsedType === 'string' && /:/.test(parsedType)) { const tp = parsedType.split(':'); parsedType = tp[0] as ParsedType; lengthOverride = parseInt(tp[1]); } - if (typeof parsedType == 'string' && /,/.test(parsedType)) { + if (typeof parsedType === 'string' && /,/.test(parsedType)) { const tp = parsedType.split(','); parsedType = tp[0] as ParsedType; // NOTE: this was `charset = parseInt(tp[1]);` before @@ -1571,9 +1571,9 @@ export class DataStream { if (this.#isTupleType(parsedType)) { const [, ta, len] = parsedType; let length: number | null = null; - if (typeof len == 'function') { + if (typeof len === 'function') { length = len(struct, this, parsedType); - } else if (typeof len == 'string' && struct[len] != null) { + } else if (typeof len === 'string' && struct[len] !== null) { // @ts-expect-error FIXME: Struct[string] is currently of type Type length = parseInt(struct[len]); } else if (typeof len === 'number') { @@ -1584,7 +1584,7 @@ export class DataStream { length = parseInt(len); } - if (typeof ta == 'string') { + if (typeof ta === 'string') { const tap = ta.replace(/(le|be)$/, ''); let endianness: null | boolean = null; if (/le$/.test(ta)) { @@ -1624,7 +1624,7 @@ export class DataStream { value = []; while (!this.isEof()) { const u = this.readType(ta, struct); - if (u == null) break; + if (u === null) break; value.push(u); } } else { @@ -1642,7 +1642,7 @@ export class DataStream { const pos = this.position; try { const type = this.readType(ta, struct); - if (type == null) { + if (type === null) { this.position = pos; break; } @@ -1656,7 +1656,7 @@ export class DataStream { value = new Array(length); for (let i = 0; i < length; i++) { const type = this.readType(ta, struct); - if (type == null) return null; + if (type === null) return null; value[i] = type; } } @@ -1664,7 +1664,7 @@ export class DataStream { break; } } - if (lengthOverride != null) { + if (lengthOverride !== null) { this.position = pos + lengthOverride; } @@ -1687,7 +1687,7 @@ export class DataStream { mapInt32Array(length: number, endianness?: boolean) { this._realloc(length * 4); const arr = new Int32Array(this._buffer, this.byteOffset + this.position, length); - DataStream.arrayToNative(arr, endianness == null ? DataStream.endianness : endianness); + DataStream.arrayToNative(arr, endianness === null ? DataStream.endianness : endianness); this.position += length * 4; return arr; } @@ -1708,7 +1708,7 @@ export class DataStream { mapInt16Array(length: number, endianness: boolean) { this._realloc(length * 2); const arr = new Int16Array(this._buffer, this.byteOffset + this.position, length); - DataStream.arrayToNative(arr, endianness == null ? this.endianness : endianness); + DataStream.arrayToNative(arr, endianness === null ? this.endianness : endianness); this.position += length * 2; return arr; } @@ -1746,7 +1746,7 @@ export class DataStream { mapUint32Array(length: number, endianness?: boolean) { this._realloc(length * 4); const arr = new Uint32Array(this._buffer, this.byteOffset + this.position, length); - DataStream.arrayToNative(arr, endianness == null ? this.endianness : endianness); + DataStream.arrayToNative(arr, endianness === null ? this.endianness : endianness); this.position += length * 4; return arr; } @@ -1767,7 +1767,7 @@ export class DataStream { mapUint16Array(length: number, endianness?: boolean) { this._realloc(length * 2); const arr = new Uint16Array(this._buffer, this.byteOffset + this.position, length); - DataStream.arrayToNative(arr, endianness == null ? this.endianness : endianness); + DataStream.arrayToNative(arr, endianness === null ? this.endianness : endianness); this.position += length * 2; return arr; } @@ -1788,7 +1788,7 @@ export class DataStream { mapFloat64Array(length: number, endianness?: boolean) { this._realloc(length * 8); const arr = new Float64Array(this._buffer, this.byteOffset + this.position, length); - DataStream.arrayToNative(arr, endianness == null ? this.endianness : endianness); + DataStream.arrayToNative(arr, endianness === null ? this.endianness : endianness); this.position += length * 8; return arr; } @@ -1809,7 +1809,7 @@ export class DataStream { mapFloat32Array(length: number, endianness?: boolean) { this._realloc(length * 4); const arr = new Float32Array(this._buffer, this.byteOffset + this.position, length); - DataStream.arrayToNative(arr, endianness == null ? this.endianness : endianness); + DataStream.arrayToNative(arr, endianness === null ? this.endianness : endianness); this.position += length * 4; return arr; } diff --git a/src/box.ts b/src/box.ts index 8402646d..54fd3431 100644 --- a/src/box.ts +++ b/src/box.ts @@ -127,7 +127,7 @@ export class Box { /** @bundle box-parse.js */ parse(stream: MultiBufferStream) { - if (this.type != 'mdat') { + if (this.type !== 'mdat') { this.data = stream.readUint8Array(this.size - this.hdr_size); } else { if (this.size === 0) { @@ -251,7 +251,7 @@ export class ContainerBox extends Box { } /* store the box in the 'boxes' array to preserve box order (for offset) but also store box in a property for more direct access */ this.boxes.push(box); - if (this.subBoxNames && this.subBoxNames.indexOf(box.type) != -1) { + if (this.subBoxNames && this.subBoxNames.indexOf(box.type) !== -1) { this[this.subBoxNames[this.subBoxNames.indexOf(box.type)] + 's'].push(box); } else { const box_type = box.type !== 'uuid' ? box.type : box.uuid; @@ -417,7 +417,7 @@ export function parseOneBox( "Found box of type '" + type + "' and size " + size + ' at position ' + start, ); hdr_size = 8; - if (type == 'uuid') { + if (type === 'uuid') { if (stream.getEndPosition() - stream.getPosition() < 16 || parentSize - hdr_size < 16) { stream.seek(start); Log.debug('BoxParser', 'Not enough bytes left in the parent box to parse a UUID box'); @@ -427,7 +427,7 @@ export function parseOneBox( hdr_size += 16; box_type = uuid; } - if (size == 1) { + if (size === 1) { if ( stream.getEndPosition() - stream.getPosition() < 8 || (parentSize && parentSize - hdr_size < 8) diff --git a/src/boxes/a1lx.ts b/src/boxes/a1lx.ts index ba70307e..005fef2c 100644 --- a/src/boxes/a1lx.ts +++ b/src/boxes/a1lx.ts @@ -12,7 +12,7 @@ export class a1lxBox extends Box { const FieldLength = ((large_size & 1) + 1) * 16; this.layer_size = []; for (let i = 0; i < 3; i++) { - if (FieldLength == 16) { + if (FieldLength === 16) { this.layer_size[i] = stream.readUint16(); } else { this.layer_size[i] = stream.readUint32(); diff --git a/src/boxes/ccst.ts b/src/boxes/ccst.ts index c2405c7b..f7d2559c 100644 --- a/src/boxes/ccst.ts +++ b/src/boxes/ccst.ts @@ -12,8 +12,8 @@ export class ccstBox extends FullBox { parse(stream: MultiBufferStream) { this.parseFullHeader(stream); const flags = stream.readUint8(); - this.all_ref_pics_intra = (flags & 0x80) == 0x80; - this.intra_pred_used = (flags & 0x40) == 0x40; + this.all_ref_pics_intra = (flags & 0x80) === 0x80; + this.intra_pred_used = (flags & 0x40) === 0x40; this.max_ref_per_pic = (flags & 0x3f) >> 2; stream.readUint24(); } diff --git a/src/boxes/cmex.ts b/src/boxes/cmex.ts index 0bee2e49..05afcd5e 100644 --- a/src/boxes/cmex.ts +++ b/src/boxes/cmex.ts @@ -26,7 +26,7 @@ export class cmexBox extends Box { this.pos_z = stream.readInt32(); } if (this.flags & 0x8) { - if (this.version == 0) { + if (this.version === 0) { if (this.flags & 0x10) { this.quat_x = stream.readInt32(); this.quat_y = stream.readInt32(); @@ -36,7 +36,7 @@ export class cmexBox extends Box { this.quat_y = stream.readInt16(); this.quat_z = stream.readInt16(); } - } else if (this.version == 1) { + } else if (this.version === 1) { //ViewpointGlobalCoordinateSysRotationStruct rot; } } diff --git a/src/boxes/ctts.ts b/src/boxes/ctts.ts index 734e7dcc..c1ade417 100644 --- a/src/boxes/ctts.ts +++ b/src/boxes/ctts.ts @@ -27,7 +27,7 @@ export class cttsBox extends FullBox { } this.sample_offsets.push(value); } - } else if (this.version == 1) { + } else if (this.version === 1) { for (let i = 0; i < entry_count; i++) { this.sample_counts.push(stream.readUint32()); this.sample_offsets.push(stream.readInt32()); /* signed */ diff --git a/src/boxes/emsg.ts b/src/boxes/emsg.ts index 7c867201..71448fdc 100644 --- a/src/boxes/emsg.ts +++ b/src/boxes/emsg.ts @@ -16,7 +16,7 @@ export class emsgBox extends FullBox { parse(stream: MultiBufferStream) { this.parseFullHeader(stream); - if (this.version == 1) { + if (this.version === 1) { this.timescale = stream.readUint32(); this.presentation_time = stream.readUint64(); this.event_duration = stream.readUint32(); @@ -35,7 +35,7 @@ export class emsgBox extends FullBox { this.size - this.hdr_size - (4 * 4 + (this.scheme_id_uri.length + 1) + (this.value.length + 1)); - if (this.version == 1) { + if (this.version === 1) { message_size -= 4; } this.message_data = stream.readUint8Array(message_size); diff --git a/src/boxes/mdhd.ts b/src/boxes/mdhd.ts index d5c42048..e83ac8db 100644 --- a/src/boxes/mdhd.ts +++ b/src/boxes/mdhd.ts @@ -12,7 +12,7 @@ export class mdhdBox extends FullBox { parse(stream: MultiBufferStream) { this.parseFullHeader(stream); - if (this.version == 1) { + if (this.version === 1) { this.creation_time = stream.readUint64(); this.modification_time = stream.readUint64(); this.timescale = stream.readUint32(); diff --git a/src/boxes/mehd.ts b/src/boxes/mehd.ts index 2be8490c..fadb8540 100644 --- a/src/boxes/mehd.ts +++ b/src/boxes/mehd.ts @@ -14,7 +14,7 @@ export class mehdBox extends FullBox { Log.warn('BoxParser', 'mehd box incorrectly uses flags set to 1, converting version to 1'); this.version = 1; } - if (this.version == 1) { + if (this.version === 1) { this.fragment_duration = stream.readUint64(); } else { this.fragment_duration = stream.readUint32(); diff --git a/src/boxes/mvhd.ts b/src/boxes/mvhd.ts index f020dbbc..87f45c46 100644 --- a/src/boxes/mvhd.ts +++ b/src/boxes/mvhd.ts @@ -17,7 +17,7 @@ export class mvhdBox extends FullBox { parse(stream: MultiBufferStream) { this.parseFullHeader(stream); - if (this.version == 1) { + if (this.version === 1) { this.creation_time = stream.readUint64(); this.modification_time = stream.readUint64(); this.timescale = stream.readUint32(); diff --git a/src/boxes/sampleentries/sampleentry.ts b/src/boxes/sampleentries/sampleentry.ts index 6ae098db..3eaed865 100644 --- a/src/boxes/sampleentries/sampleentry.ts +++ b/src/boxes/sampleentries/sampleentry.ts @@ -124,7 +124,7 @@ class hvcCSampleEntryBase extends VisualSampleEntry { let reversed = 0; for (let i = 0; i < 32; i++) { reversed |= val & 1; - if (i == 31) break; + if (i === 31) break; reversed <<= 1; val >>= 1; } @@ -260,11 +260,11 @@ class vpcCSampleEntryBase extends VisualSampleEntry { getCodec() { const baseCodec = super.getCodec(); let level: number | string = this.vpcC.level; - if (level == 0) { + if (level === 0) { level = '00'; } let bitDepth: number | string = this.vpcC.bitDepth; - if (bitDepth == 8) { + if (bitDepth === 8) { bitDepth = '08'; } return `${baseCodec}.0${this.vpcC.profile}.${level}.${bitDepth}`; diff --git a/src/boxes/sbpm.ts b/src/boxes/sbpm.ts index 3058b961..deab4ab2 100644 --- a/src/boxes/sbpm.ts +++ b/src/boxes/sbpm.ts @@ -24,7 +24,7 @@ export class sbpmBox extends FullBox { this.component_index.push(stream.readUint16()); } const flags = stream.readUint8(); - this.correction_applied = 0x80 == (flags & 0x80); + this.correction_applied = 0x80 === (flags & 0x80); this.num_bad_rows = stream.readUint32(); this.num_bad_cols = stream.readUint32(); this.num_bad_pixels = stream.readUint32(); diff --git a/src/boxes/subs.ts b/src/boxes/subs.ts index 6fec7daa..0cd20936 100644 --- a/src/boxes/subs.ts +++ b/src/boxes/subs.ts @@ -29,7 +29,7 @@ export class subsBox extends FullBox { for (let j = 0; j < subsample_count; j++) { const subsample = {} as SubSample; sampleInfo.subsamples.push(subsample); - if (this.version == 1) { + if (this.version === 1) { subsample.size = stream.readUint32(); } else { subsample.size = stream.readUint16(); diff --git a/src/boxes/tfdt.ts b/src/boxes/tfdt.ts index 4aabbb44..7a4faddc 100644 --- a/src/boxes/tfdt.ts +++ b/src/boxes/tfdt.ts @@ -9,7 +9,7 @@ export class tfdtBox extends FullBox { parse(stream: MultiBufferStream) { this.parseFullHeader(stream); - if (this.version == 1) { + if (this.version === 1) { this.baseMediaDecodeTime = stream.readUint64(); } else { this.baseMediaDecodeTime = stream.readUint32(); diff --git a/src/boxes/tkhd.ts b/src/boxes/tkhd.ts index 55d0e4d9..52d0f7d4 100644 --- a/src/boxes/tkhd.ts +++ b/src/boxes/tkhd.ts @@ -19,7 +19,7 @@ export class tkhdBox extends FullBox { parse(stream: MultiBufferStream) { this.parseFullHeader(stream); - if (this.version == 1) { + if (this.version === 1) { this.creation_time = stream.readUint64(); this.modification_time = stream.readUint64(); this.track_id = stream.readUint32(); diff --git a/src/boxes/uncC.ts b/src/boxes/uncC.ts index 604f12e9..31dbdf79 100644 --- a/src/boxes/uncC.ts +++ b/src/boxes/uncC.ts @@ -28,9 +28,9 @@ export class uncCBox extends FullBox { parse(stream: MultiBufferStream) { this.parseFullHeader(stream); this.profile = stream.readString(4); - if (this.version == 1) { + if (this.version === 1) { // Nothing - just the profile - } else if (this.version == 0) { + } else if (this.version === 0) { this.component_count = stream.readUint32(); this.component_index = []; this.component_bit_depth_minus_one = []; diff --git a/src/boxes/vvcC.ts b/src/boxes/vvcC.ts index 64836215..0cd530d5 100644 --- a/src/boxes/vvcC.ts +++ b/src/boxes/vvcC.ts @@ -147,7 +147,7 @@ export class vvcCBox extends FullBox { nalu_array.nalu_type = bitReader.extract_bits(5); let numNalus = 1; - if (nalu_array.nalu_type != VVC_NALU_DEC_PARAM && nalu_array.nalu_type != VVC_NALU_OPI) { + if (nalu_array.nalu_type !== VVC_NALU_DEC_PARAM && nalu_array.nalu_type !== VVC_NALU_OPI) { numNalus = stream.readUint16(); } diff --git a/src/descriptor.ts b/src/descriptor.ts index 70fbe6e0..0bf2b0b4 100644 --- a/src/descriptor.ts +++ b/src/descriptor.ts @@ -24,7 +24,7 @@ export class Descriptor { findDescriptor(tag: number) { for (let i = 0; i < this.descs.length; i++) { - if (this.descs[i].tag == tag) { + if (this.descs[i].tag === tag) { return this.descs[i]; } } diff --git a/src/isofile.ts b/src/isofile.ts index 90d42a51..6f80afa5 100644 --- a/src/isofile.ts +++ b/src/isofile.ts @@ -256,7 +256,7 @@ export class ISOFile { let index = -1; for (let i = 0; i < this.fragmentedTracks.length; i++) { const fragTrack = this.fragmentedTracks[i]; - if (fragTrack.id == id) { + if (fragTrack.id === id) { index = i; } } @@ -287,7 +287,7 @@ export class ISOFile { let index = -1; for (let i = 0; i < this.extractedTracks.length; i++) { const extractTrack = this.extractedTracks[i]; - if (extractTrack.id == id) { + if (extractTrack.id === id) { index = i; } } @@ -502,7 +502,7 @@ export class ISOFile { } const _1904 = new Date('1904-01-01T00:00:00Z').getTime(); - const isFragmented = this.moov.mvex != null; + const isFragmented = this.moov.mvex !== null; const movie: Movie = { hasMoov: true, @@ -512,7 +512,7 @@ export class ISOFile { fragment_duration: isFragmented && this.moov.mvex.mehd ? this.moov.mvex.mehd.fragment_duration : undefined, isProgressive: this.isProgressive, - hasIOD: this.moov.iods != null, + hasIOD: this.moov.iods !== null, brands: [this.ftyp.major_brand].concat(this.ftyp.compatible_brands), created: new Date(_1904 + this.moov.mvhd.creation_time * 1000), modified: new Date(_1904 + this.moov.mvhd.modification_time * 1000), @@ -755,7 +755,7 @@ export class ISOFile { } static _sweep(type: BoxKind['type'], result: Array, returnEarly: boolean) { - if (this.type && this.type == type) result.push(this); + if (this.type && this.type === type) result.push(this); for (const box in this.boxes) { if (result.length && returnEarly) return; ISOFile._sweep.call(this.boxes[box], type, result, returnEarly); @@ -960,7 +960,7 @@ export class ISOFile { createFragment(track_id: number, sampleNumber: number, _stream: DataStream) { const trak = this.getTrackById(track_id); const sample = this.getSample(trak, sampleNumber); - if (sample == null) { + if (sample === null) { this.setNextSeekPositionFromSample(trak.samples[sampleNumber]); return null; } @@ -1119,7 +1119,7 @@ export class ISOFile { } const stss = trak.mdia.minf.stbl.stss; const k = trak.mdia.minf.stbl.boxes.indexOf(stss); - if (k != -1) trak.mdia.minf.stbl.boxes[k] = null; + if (k !== -1) trak.mdia.minf.stbl.boxes[k] = null; } } @@ -1410,7 +1410,7 @@ export class ISOFile { sample.cts = sample.dts; } if (stss) { - if (j == stss.sample_numbers[last_stss_index] - 1) { + if (j === stss.sample_numbers[last_stss_index] - 1) { // sample numbers are 1-based sample.is_sync = true; last_stss_index++; @@ -1419,7 +1419,7 @@ export class ISOFile { sample.degradation_priority = 0; } if (subs) { - if (subs.entries[subs_entry_index].sample_delta + last_subs_sample_index == j + 1) { + if (subs.entries[subs_entry_index].sample_delta + last_subs_sample_index === j + 1) { sample.subsamples = subs.entries[subs_entry_index].subsamples; last_subs_sample_index += subs.entries[subs_entry_index].sample_delta; subs_entry_index++; @@ -1435,7 +1435,7 @@ export class ISOFile { sample.degradation_priority = 0; } if (subs) { - if (subs.entries[subs_entry_index].sample_delta + last_subs_sample_index == j) { + if (subs.entries[subs_entry_index].sample_delta + last_subs_sample_index === j) { sample.subsamples = subs.entries[subs_entry_index].subsamples; last_subs_sample_index += subs.entries[subs_entry_index].sample_delta; } @@ -1469,7 +1469,7 @@ export class ISOFile { while (this.lastMoofIndex < this.moofs.length) { const box = this.moofs[this.lastMoofIndex]; this.lastMoofIndex++; - if (box.type == 'moof') { + if (box.type === 'moof') { const moof = box; for (let i = 0; i < moof.trafs.length; i++) { const traf = moof.trafs[i]; @@ -1662,7 +1662,7 @@ export class ISOFile { this.samplesDataSize + ')', ); - } else if (sample.alreadyRead == sample.size) { + } else if (sample.alreadyRead === sample.size) { /* Already fetched entirely */ return sample; } @@ -1798,7 +1798,7 @@ export class ISOFile { if (!this.moov || !this.moov.mvex) return null; for (let i = 0; i < this.moov.mvex.trexs.length; i++) { const trex = this.moov.mvex.trexs[i]; - if (trex.track_id == id) return trex; + if (trex.track_id === id) return trex; } return null; } @@ -1814,7 +1814,7 @@ export class ISOFile { } for (let j = 0; j < this.moov.traks.length; j++) { const trak = this.moov.traks[j]; - if (trak.tkhd.track_id == id) return trak; + if (trak.tkhd.track_id === id) return trak; } return null; } @@ -1880,7 +1880,7 @@ export class ISOFile { length: itemloc.extents[j].extent_length, alreadyRead: 0, }; - if (itemloc.construction_method == 1) { + if (itemloc.construction_method === 1) { item.extents[j].offset += meta.idat.start + meta.idat.hdr_size; } item.size += item.extents[j].length; @@ -2125,7 +2125,7 @@ export class ISOFile { } else { item = this.getPrimaryItem(); } - if (item == null) return null; + if (item === null) return null; const file = new ISOFile(); file.discardMdatData = false; diff --git a/src/log.ts b/src/log.ts index 7cb37eed..a3941b27 100644 --- a/src/log.ts +++ b/src/log.ts @@ -13,10 +13,10 @@ let log_level = LOG_LEVEL_ERROR; export class Log { static setLogLevel(level: { (module: string, msg?: string): void }) { - if (level == this.debug) log_level = LOG_LEVEL_DEBUG; - else if (level == this.info) log_level = LOG_LEVEL_INFO; - else if (level == this.warn) log_level = LOG_LEVEL_WARNING; - else if (level == this.error) log_level = LOG_LEVEL_ERROR; + if (level === this.debug) log_level = LOG_LEVEL_DEBUG; + else if (level === this.info) log_level = LOG_LEVEL_INFO; + else if (level === this.warn) log_level = LOG_LEVEL_WARNING; + else if (level === this.error) log_level = LOG_LEVEL_ERROR; else log_level = LOG_LEVEL_ERROR; } static debug(module: string, msg?: string) { From 5ec019e76e7b7d961643c8988d70edd33a77ecd9 Mon Sep 17 00:00:00 2001 From: Erwan Vivien Date: Mon, 26 May 2025 11:21:48 +0200 Subject: [PATCH 03/16] feat: ESLint add no-throw-literal rule --- eslint.config.js | 1 + src/DataStream.ts | 2 +- src/boxes/iloc.ts | 12 ++++++------ src/buffer.ts | 4 ++-- src/isofile.ts | 6 +++--- src/stream.ts | 12 ++++++------ 6 files changed, 19 insertions(+), 18 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 466224f6..78f877c2 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -15,6 +15,7 @@ export default defineConfig([ 'linebreak-style': ['error', 'unix'], 'one-var': ['error', 'never'], semi: ['error', 'always'], + 'no-throw-literal': 'error', '@typescript-eslint/no-unused-vars': [ 'error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }, diff --git a/src/DataStream.ts b/src/DataStream.ts index 0a4866a0..33341475 100644 --- a/src/DataStream.ts +++ b/src/DataStream.ts @@ -679,7 +679,7 @@ export class DataStream { a.click(); window.URL.revokeObjectURL(url); } else { - throw "DataStream.save: Can't create object URL."; + throw new Error("DataStream.save: Can't create object URL."); } } diff --git a/src/boxes/iloc.ts b/src/boxes/iloc.ts index 549b7aa1..b1f5e896 100644 --- a/src/boxes/iloc.ts +++ b/src/boxes/iloc.ts @@ -44,7 +44,7 @@ export class ilocBox extends FullBox { } else if (this.version === 2) { item_count = stream.readUint32(); } else { - throw 'version of iloc box not supported'; + throw new Error('version of iloc box not supported'); } for (let i = 0; i < item_count; i++) { let item_ID = 0; @@ -56,7 +56,7 @@ export class ilocBox extends FullBox { } else if (this.version === 2) { item_ID = stream.readUint32(); } else { - throw 'version of iloc box not supported'; + throw new Error('version of iloc box not supported'); } if (this.version === 1 || this.version === 2) { construction_method = stream.readUint16() & 0xf; @@ -76,7 +76,7 @@ export class ilocBox extends FullBox { base_offset = stream.readUint64(); break; default: - throw 'Error reading base offset size'; + throw new Error('Error reading base offset size'); } const extents: Array = []; @@ -99,7 +99,7 @@ export class ilocBox extends FullBox { extent_index = stream.readUint64(); break; default: - throw 'Error reading extent index'; + throw new Error('Error reading extent index'); } } @@ -114,7 +114,7 @@ export class ilocBox extends FullBox { extent_offset = stream.readUint64(); break; default: - throw 'Error reading extent index'; + throw new Error('Error reading extent index'); } switch (this.length_size) { @@ -128,7 +128,7 @@ export class ilocBox extends FullBox { extent_length = stream.readUint64(); break; default: - throw 'Error reading extent index'; + throw new Error('Error reading extent index'); } extents.push({ extent_index, extent_length, extent_offset }); diff --git a/src/buffer.ts b/src/buffer.ts index 2cebee5b..fd77dc31 100644 --- a/src/buffer.ts +++ b/src/buffer.ts @@ -412,7 +412,7 @@ export class MultiBufferStream extends DataStream { */ getPosition() { if (this.bufferIndex === -1 || this.buffers[this.bufferIndex] === null) { - throw 'Error accessing position in the MultiBufferStream'; + throw new Error('Error accessing position in the MultiBufferStream'); } return this.buffers[this.bufferIndex].fileStart + this.position; } @@ -427,7 +427,7 @@ export class MultiBufferStream extends DataStream { getEndPosition() { if (this.bufferIndex === -1 || this.buffers[this.bufferIndex] === null) { - throw 'Error accessing position in the MultiBufferStream'; + throw new Error('Error accessing position in the MultiBufferStream'); } return this.buffers[this.bufferIndex].fileStart + this.byteLength; } diff --git a/src/isofile.ts b/src/isofile.ts index 6f80afa5..6b40f110 100644 --- a/src/isofile.ts +++ b/src/isofile.ts @@ -376,10 +376,10 @@ export class ISOFile { checkBuffer(ab?: MP4BoxBuffer) { if (ab === null || ab === undefined) { - throw 'Buffer must be defined and non empty'; + throw new Error('Buffer must be defined and non empty'); } if (ab.fileStart === undefined) { - throw 'Buffer must have a fileStart property'; + throw new Error('Buffer must have a fileStart property'); } if (ab.byteLength === 0) { Log.warn('ISOFile', 'Ignoring empty buffer (fileStart: ' + ab.fileStart + ')'); @@ -893,7 +893,7 @@ export class ISOFile { const moov = this.moov; let seek_info = { offset: Infinity, time: Infinity }; if (!this.moov) { - throw 'Cannot seek: moov not received!'; + throw new Error('Cannot seek: moov not received!'); } else { for (let i = 0; i < moov.traks.length; i++) { const trak = moov.traks[i]; diff --git a/src/stream.ts b/src/stream.ts index f6abdac8..0fa0030f 100644 --- a/src/stream.ts +++ b/src/stream.ts @@ -8,7 +8,7 @@ export class MP4BoxStream { this.buffer = arrayBuffer; this.dataview = new DataView(arrayBuffer); } else { - throw 'Needs an array buffer'; + throw new Error('Needs an array buffer'); } } @@ -62,7 +62,7 @@ export class MP4BoxStream { break; case 3: if (signed) { - throw 'No method for reading signed 24 bits values'; + throw new Error('No method for reading signed 24 bits values'); } else { res = this.dataview.getUint8(this.position) << 16; res |= this.dataview.getUint8(this.position + 1) << 8; @@ -78,19 +78,19 @@ export class MP4BoxStream { break; case 8: if (signed) { - throw 'No method for reading signed 64 bits values'; + throw new Error('No method for reading signed 64 bits values'); } else { res = this.dataview.getUint32(this.position) << 32; res |= this.dataview.getUint32(this.position + 4); } break; default: - throw 'readInt method not implemented for size: ' + size; + throw new Error(`readInt method not implemented for size: ${size}`); } this.position += size; return res; } else { - throw 'Not enough bytes in buffer'; + throw new Error('Not enough bytes in buffer'); } } @@ -122,7 +122,7 @@ export class MP4BoxStream { } return s; } else { - throw 'Not enough bytes in buffer'; + throw new Error('Not enough bytes in buffer'); } } From 4c5157e24c53ea3b4670299c913156acd360606d Mon Sep 17 00:00:00 2001 From: Erwan Vivien Date: Mon, 26 May 2025 11:22:49 +0200 Subject: [PATCH 04/16] feat: ESLint add @typescript-eslint/consistent-type-imports rule --- eslint.config.js | 1 + src/audio.ts | 2 +- src/box.ts | 4 ++-- src/boxes/avcC.ts | 4 ++-- src/boxes/dref.ts | 3 ++- src/boxes/hvcC.ts | 4 ++-- src/boxes/iinf.ts | 2 +- src/boxes/meta.ts | 12 ++++++------ src/boxes/qt/tapt.ts | 6 +++--- src/boxes/sampleentries/sampleentry.ts | 14 +++++++------- src/create-file.ts | 2 +- src/descriptor.ts | 4 ++-- src/isofile.ts | 12 ++++++------ src/text-mp4.ts | 3 ++- 14 files changed, 38 insertions(+), 35 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 78f877c2..b635a8f2 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -21,6 +21,7 @@ export default defineConfig([ { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }, ], 'no-unused-vars': 'off', + '@typescript-eslint/consistent-type-imports': 'error', }, }, ]); diff --git a/src/audio.ts b/src/audio.ts index d04692b2..ff9dabdd 100644 --- a/src/audio.ts +++ b/src/audio.ts @@ -1,4 +1,4 @@ -import { MP4BoxStream } from '#/stream'; +import type { MP4BoxStream } from '#/stream'; export class AudioSpecificConfig { samplingFrequencyIndex?: number; diff --git a/src/box.ts b/src/box.ts index 54fd3431..e1d80c3f 100644 --- a/src/box.ts +++ b/src/box.ts @@ -5,10 +5,10 @@ import { MultiBufferStream } from '#/buffer'; import { ERR_NOT_ENOUGH_DATA, MAX_SIZE, OK } from '#/constants'; -import { DataStream } from '#/DataStream'; +import type { DataStream } from '#/DataStream'; import { Log } from '#/log'; import { BoxRegistry } from '#/registry'; -import { MP4BoxStream } from '#/stream'; +import type { MP4BoxStream } from '#/stream'; import type { BoxKind, Extends, Output, Reference } from '@types'; export class Box { diff --git a/src/boxes/avcC.ts b/src/boxes/avcC.ts index b8190b53..828ca800 100644 --- a/src/boxes/avcC.ts +++ b/src/boxes/avcC.ts @@ -1,7 +1,7 @@ import { Box } from '#/box'; import type { MultiBufferStream } from '#/buffer'; -import { DataStream } from '#/DataStream'; -import { MP4BoxStream } from '#/stream'; +import type { DataStream } from '#/DataStream'; +import type { MP4BoxStream } from '#/stream'; import type { ParameterSetArray } from './displays/parameterSetArray'; export class avcCBox extends Box { diff --git a/src/boxes/dref.ts b/src/boxes/dref.ts index c1191369..cab0d2f9 100644 --- a/src/boxes/dref.ts +++ b/src/boxes/dref.ts @@ -1,4 +1,5 @@ -import { Box, FullBox, parseOneBox } from '#/box'; +import type { Box} from '#/box'; +import { FullBox, parseOneBox } from '#/box'; import type { MultiBufferStream } from '#/buffer'; import { OK } from '#/constants'; import { Log } from '#/log'; diff --git a/src/boxes/hvcC.ts b/src/boxes/hvcC.ts index b7f6cb1c..af956de3 100644 --- a/src/boxes/hvcC.ts +++ b/src/boxes/hvcC.ts @@ -1,6 +1,6 @@ import { Box } from '#/box'; -import { DataStream } from '#/DataStream'; -import { MP4BoxStream } from '#/stream'; +import type { DataStream } from '#/DataStream'; +import type { MP4BoxStream } from '#/stream'; import type { NaluArray } from '@types'; import type { NALUArrays } from './displays/naluArrays'; diff --git a/src/boxes/iinf.ts b/src/boxes/iinf.ts index 9027459f..91129b56 100644 --- a/src/boxes/iinf.ts +++ b/src/boxes/iinf.ts @@ -1,5 +1,5 @@ import { FullBox, parseOneBox } from '#/box'; -import { infeBox } from '#/boxes/infe'; +import type { infeBox } from '#/boxes/infe'; import type { MultiBufferStream } from '#/buffer'; import { OK } from '#/constants'; import { Log } from '#/log'; diff --git a/src/boxes/meta.ts b/src/boxes/meta.ts index d572d45f..c1c031c6 100644 --- a/src/boxes/meta.ts +++ b/src/boxes/meta.ts @@ -1,10 +1,10 @@ import { ContainerBox, FullBox } from '#/box'; -import { dinfBox, grplBox, idatBox, iproBox, iprpBox } from '#/boxes/defaults'; -import { hdlrBox } from '#/boxes/hdlr'; -import { iinfBox } from '#/boxes/iinf'; -import { ilocBox } from '#/boxes/iloc'; -import { irefBox } from '#/boxes/iref'; -import { pitmBox } from '#/boxes/pitm'; +import type { dinfBox, grplBox, idatBox, iproBox, iprpBox } from '#/boxes/defaults'; +import type { hdlrBox } from '#/boxes/hdlr'; +import type { iinfBox } from '#/boxes/iinf'; +import type { ilocBox } from '#/boxes/iloc'; +import type { irefBox } from '#/boxes/iref'; +import type { pitmBox } from '#/boxes/pitm'; import type { MultiBufferStream } from '#/buffer'; export class metaBox extends FullBox { diff --git a/src/boxes/qt/tapt.ts b/src/boxes/qt/tapt.ts index 644a37cc..ecf44ef3 100644 --- a/src/boxes/qt/tapt.ts +++ b/src/boxes/qt/tapt.ts @@ -1,7 +1,7 @@ import { ContainerBox } from '#/box'; -import { clefBox } from '#/boxes/qt/clef'; -import { enofBox } from '#/boxes/qt/enof'; -import { profBox } from '#/boxes/qt/prof'; +import type { clefBox } from '#/boxes/qt/clef'; +import type { enofBox } from '#/boxes/qt/enof'; +import type { profBox } from '#/boxes/qt/prof'; export class taptBox extends ContainerBox { type = 'tapt' as const; diff --git a/src/boxes/sampleentries/sampleentry.ts b/src/boxes/sampleentries/sampleentry.ts index 3eaed865..dd5f3818 100644 --- a/src/boxes/sampleentries/sampleentry.ts +++ b/src/boxes/sampleentries/sampleentry.ts @@ -1,10 +1,10 @@ -import { av1CBox } from '#/boxes/av1C'; -import { avcCBox } from '#/boxes/avcC'; -import { sinfBox } from '#/boxes/defaults'; -import { esdsBox } from '#/boxes/esds'; -import { hvcCBox } from '#/boxes/hvcC'; -import { vpcCBox } from '#/boxes/vpcC'; -import { vvcCBox } from '#/boxes/vvcC'; +import type { av1CBox } from '#/boxes/av1C'; +import type { avcCBox } from '#/boxes/avcC'; +import type { sinfBox } from '#/boxes/defaults'; +import type { esdsBox } from '#/boxes/esds'; +import type { hvcCBox } from '#/boxes/hvcC'; +import type { vpcCBox } from '#/boxes/vpcC'; +import type { vvcCBox } from '#/boxes/vvcC'; import { AudioSampleEntry, MetadataSampleEntry, diff --git a/src/create-file.ts b/src/create-file.ts index 41899382..b67b9c30 100644 --- a/src/create-file.ts +++ b/src/create-file.ts @@ -3,7 +3,7 @@ * License: BSD-3-Clause (see LICENSE file) */ -import { MultiBufferStream } from '#/buffer'; +import type { MultiBufferStream } from '#/buffer'; import { ISOFile } from '#/isofile'; export function createFile(keepMdatData = true, stream?: MultiBufferStream) { diff --git a/src/descriptor.ts b/src/descriptor.ts index 0bf2b0b4..acdab49e 100644 --- a/src/descriptor.ts +++ b/src/descriptor.ts @@ -3,8 +3,8 @@ * License: BSD-3-Clause (see LICENSE file) */ -import { MultiBufferStream } from '#/buffer'; -import { DataStream } from '#/DataStream'; +import type { MultiBufferStream } from '#/buffer'; +import type { DataStream } from '#/DataStream'; import { Log } from '#/log'; const ES_DescrTag = 0x03; diff --git a/src/isofile.ts b/src/isofile.ts index 6b40f110..c0289e45 100644 --- a/src/isofile.ts +++ b/src/isofile.ts @@ -27,7 +27,7 @@ import { hdlrBox } from '#/boxes/hdlr'; import { hvcCBox } from '#/boxes/hvcC'; import { mdhdBox } from '#/boxes/mdhd'; import { mehdBox } from '#/boxes/mehd'; -import { metaBox } from '#/boxes/meta'; +import type { metaBox } from '#/boxes/meta'; import { mfhdBox } from '#/boxes/mfhd'; import { mvhdBox } from '#/boxes/mvhd'; import { stppSampleEntry } from '#/boxes/sampleentries'; @@ -39,10 +39,10 @@ import { SystemSampleEntry, VisualSampleEntry, } from '#/boxes/sampleentries/base'; -import { sbgpBox } from '#/boxes/sbgp'; -import { sdtpBox } from '#/boxes/sdtp'; -import { sgpdBox } from '#/boxes/sgpd'; -import { sidxBox } from '#/boxes/sidx'; +import type { sbgpBox } from '#/boxes/sbgp'; +import type { sdtpBox } from '#/boxes/sdtp'; +import type { sgpdBox } from '#/boxes/sgpd'; +import type { sidxBox } from '#/boxes/sidx'; import { smhdBox } from '#/boxes/smhd'; import { stcoBox } from '#/boxes/stco'; import { sthdBox } from '#/boxes/sthd'; @@ -95,7 +95,7 @@ import type { SubSample, Track, } from '@types'; -import { MP4BoxBuffer } from './mp4boxbuffer'; +import type { MP4BoxBuffer } from './mp4boxbuffer'; export class SampleGroupInfo { last_sample_in_run = -1; diff --git a/src/text-mp4.ts b/src/text-mp4.ts index 911ebcc0..0ac4dbc7 100644 --- a/src/text-mp4.ts +++ b/src/text-mp4.ts @@ -1,4 +1,5 @@ -import { Box, parseOneBox } from '#/box'; +import type { Box} from '#/box'; +import { parseOneBox } from '#/box'; import { OK } from '#/constants'; import { MP4BoxStream } from '#/stream'; import type { Sample, TypedArray } from '@types'; From 8b85971aef8a6c1d0196fa5dc9eeadb494b0ac37 Mon Sep 17 00:00:00 2001 From: Erwan Vivien Date: Mon, 26 May 2025 11:23:22 +0200 Subject: [PATCH 05/16] feat: ESLint add no-nested-ternary rule --- eslint.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/eslint.config.js b/eslint.config.js index b635a8f2..073f85c7 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -22,6 +22,7 @@ export default defineConfig([ ], 'no-unused-vars': 'off', '@typescript-eslint/consistent-type-imports': 'error', + 'no-nested-ternary': 'error', }, }, ]); From 69ad3b92b59ca7e48763b8fe5010ddb80fccfe94 Mon Sep 17 00:00:00 2001 From: Erwan Vivien Date: Mon, 26 May 2025 11:24:44 +0200 Subject: [PATCH 06/16] feat: ESLint add @typescript-eslint/consistent-type-definitions rule --- eslint.config.js | 1 + src/boxes/dec3.ts | 4 ++-- src/boxes/iloc.ts | 4 ++-- src/boxes/ipma.ts | 4 ++-- src/boxes/leva.ts | 4 ++-- src/boxes/sbgp.ts | 4 ++-- src/boxes/sidx.ts | 4 ++-- src/boxes/ssix.ts | 8 ++++---- src/boxes/subs.ts | 4 ++-- src/isofile.ts | 4 ++-- 10 files changed, 21 insertions(+), 20 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 073f85c7..b2b21154 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -23,6 +23,7 @@ export default defineConfig([ 'no-unused-vars': 'off', '@typescript-eslint/consistent-type-imports': 'error', 'no-nested-ternary': 'error', + '@typescript-eslint/consistent-type-definitions': ['error', 'type'], }, }, ]); diff --git a/src/boxes/dec3.ts b/src/boxes/dec3.ts index 8c4c3388..695f345b 100644 --- a/src/boxes/dec3.ts +++ b/src/boxes/dec3.ts @@ -1,7 +1,7 @@ import { Box } from '#/box'; import type { MultiBufferStream } from '#/buffer'; -interface IndSub { +type IndSub = { fscod: number; bsid: number; bsmod: number; @@ -9,7 +9,7 @@ interface IndSub { lfeon: number; num_dep_sub: number; chan_loc?: number; -} +}; export class dec3Box extends Box { type = 'dec3' as const; diff --git a/src/boxes/iloc.ts b/src/boxes/iloc.ts index b1f5e896..f2e96ca7 100644 --- a/src/boxes/iloc.ts +++ b/src/boxes/iloc.ts @@ -1,11 +1,11 @@ import { FullBox } from '#/box'; import type { MultiBufferStream } from '#/buffer'; -export interface Extent { +export type Extent = { extent_index: number; extent_offset: number; extent_length: number; -} +}; export class ilocBox extends FullBox { type = 'iloc' as const; diff --git a/src/boxes/ipma.ts b/src/boxes/ipma.ts index acc2639c..2baa4d8f 100644 --- a/src/boxes/ipma.ts +++ b/src/boxes/ipma.ts @@ -1,10 +1,10 @@ import { FullBox } from '#/box'; import type { MultiBufferStream } from '#/buffer'; -export interface Assocation { +export type Assocation = { id: number; props: Array<{ property_index: number; essential: boolean }>; -} +}; export class ipmaBox extends FullBox { type = 'ipma' as const; diff --git a/src/boxes/leva.ts b/src/boxes/leva.ts index 08ace565..6065ebd6 100644 --- a/src/boxes/leva.ts +++ b/src/boxes/leva.ts @@ -2,14 +2,14 @@ import { Log } from '#//log'; import { FullBox } from '#/box'; import type { MultiBufferStream } from '#/buffer'; -interface Level { +type Level = { padding_flag: number; track_ID: number; assignment_type: number; grouping_type: string; grouping_type_parameter: number; sub_track_id: number; -} +}; export class levaBox extends FullBox { type = 'leva' as const; diff --git a/src/boxes/sbgp.ts b/src/boxes/sbgp.ts index 7482b0a8..5139858f 100644 --- a/src/boxes/sbgp.ts +++ b/src/boxes/sbgp.ts @@ -1,10 +1,10 @@ import { FullBox } from '#/box'; import type { MultiBufferStream } from '#/buffer'; -interface Entry { +type Entry = { sample_count: number; group_description_index: number; -} +}; export class sbgpBox extends FullBox { type = 'sbgp' as const; diff --git a/src/boxes/sidx.ts b/src/boxes/sidx.ts index 0c12f0e4..cc248e7e 100644 --- a/src/boxes/sidx.ts +++ b/src/boxes/sidx.ts @@ -1,14 +1,14 @@ import { FullBox } from '#/box'; import type { MultiBufferStream } from '#/buffer'; -interface Reference { +type Reference = { reference_type: number; referenced_size: number; subsegment_duration: number; starts_with_SAP: number; SAP_type: number; SAP_delta_time: number; -} +}; export class sidxBox extends FullBox { type = 'sidx' as const; diff --git a/src/boxes/ssix.ts b/src/boxes/ssix.ts index 2dd50269..599126e0 100644 --- a/src/boxes/ssix.ts +++ b/src/boxes/ssix.ts @@ -1,13 +1,13 @@ import { FullBox } from '#/box'; import type { MultiBufferStream } from '#/buffer'; -interface Range { +type Range = { level: number; range_size: number; -} -interface SubSegment { +}; +type SubSegment = { ranges: Array; -} +}; export class ssixBox extends FullBox { type = 'ssix' as const; diff --git a/src/boxes/subs.ts b/src/boxes/subs.ts index 0cd20936..035cba09 100644 --- a/src/boxes/subs.ts +++ b/src/boxes/subs.ts @@ -2,11 +2,11 @@ import { FullBox } from '#/box'; import type { MultiBufferStream } from '#/buffer'; import type { SubSample } from '@types'; -interface SampleInfo { +type SampleInfo = { size: number; sample_delta: number; subsamples: SubSample[]; -} +}; export class subsBox extends FullBox { type = 'subs' as const; diff --git a/src/isofile.ts b/src/isofile.ts index c0289e45..4b8b5169 100644 --- a/src/isofile.ts +++ b/src/isofile.ts @@ -112,7 +112,7 @@ export class SampleGroupInfo { ) {} } -export interface IsoFileOptions { +export type IsoFileOptions = { brands?: Array; description_boxes?: Array; duration?: number; @@ -141,7 +141,7 @@ export interface IsoFileOptions { default_sample_duration?: number; default_sample_size?: number; default_sample_flags?: number; -} +}; export class ISOFile { /** MutiBufferStream object used to parse boxes */ From 6eeb16251316681343f75ead7926c4f96493c5b5 Mon Sep 17 00:00:00 2001 From: Erwan Vivien Date: Mon, 26 May 2025 11:30:05 +0200 Subject: [PATCH 07/16] feat: ESLint curly rule --- eslint.config.js | 1 + src/DataStream.ts | 16 ++++-- src/box-diff.ts | 4 +- src/box.ts | 4 +- src/boxes/displays/naluArrays.ts | 4 +- src/boxes/sampleentries/sampleentry.ts | 4 +- src/descriptor.ts | 4 +- src/isofile.ts | 76 +++++++++++++++++++------- src/log.ts | 20 +++++-- 9 files changed, 99 insertions(+), 34 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index b2b21154..8b3b2e59 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -24,6 +24,7 @@ export default defineConfig([ '@typescript-eslint/consistent-type-imports': 'error', 'no-nested-ternary': 'error', '@typescript-eslint/consistent-type-definitions': ['error', 'type'], + curly: ['error', 'all'], }, }, ]); diff --git a/src/DataStream.ts b/src/DataStream.ts index 33341475..a8898a8b 100644 --- a/src/DataStream.ts +++ b/src/DataStream.ts @@ -59,7 +59,9 @@ export class DataStream { this.buffer = arrayBuffer; } else if (arrayBuffer instanceof DataView) { this.dataView = arrayBuffer; - if (byteOffset) this._byteOffset += byteOffset; + if (byteOffset) { + this._byteOffset += byteOffset; + } } else { this.buffer = new MP4BoxBuffer(arrayBuffer || 0); } @@ -636,7 +638,9 @@ export class DataStream { if (length !== null) { len = Math.min(length, blen); } - for (; i < len && u8[i] !== 0; i++); // find first zero byte + for (; i < len && u8[i] !== 0; i++) { + // find first zero byte + } const s = fromCharCodeUint8(this.mapUint8Array(i)); if (length !== null) { this.position += len - i; @@ -1624,7 +1628,9 @@ export class DataStream { value = []; while (!this.isEof()) { const u = this.readType(ta, struct); - if (u === null) break; + if (u === null) { + break; + } value.push(u); } } else { @@ -1656,7 +1662,9 @@ export class DataStream { value = new Array(length); for (let i = 0; i < length; i++) { const type = this.readType(ta, struct); - if (type === null) return null; + if (type === null) { + return null; + } value[i] = type; } } diff --git a/src/box-diff.ts b/src/box-diff.ts index 5da892f7..128ccf16 100644 --- a/src/box-diff.ts +++ b/src/box-diff.ts @@ -34,7 +34,9 @@ export const DIFF_PRIMITIVE_ARRAY_PROP_NAMES = [ /** @bundle box-diff.js */ export function boxEqualFields(box_a: Box, box_b: Box) { - if (box_a && !box_b) return false; + if (box_a && !box_b) { + return false; + } let prop: string; for (prop in box_a) { if ((DIFF_BOXES_PROP_NAMES as readonly string[]).indexOf(prop) > -1) { diff --git a/src/box.ts b/src/box.ts index e1d80c3f..50e07c0d 100644 --- a/src/box.ts +++ b/src/box.ts @@ -555,7 +555,9 @@ export function parseOneBox( diff + ' more bytes than the indicated box data size, seeking backwards', ); - if (box.size !== 0) stream.seek(box.start + box.size); + if (box.size !== 0) { + stream.seek(box.start + box.size); + } } return { code: OK, box, size: box.size }; } diff --git a/src/boxes/displays/naluArrays.ts b/src/boxes/displays/naluArrays.ts index fa6413bb..e453ab99 100644 --- a/src/boxes/displays/naluArrays.ts +++ b/src/boxes/displays/naluArrays.ts @@ -13,7 +13,9 @@ export class NALUArrays extends Array { str += "" + nalu_array.nalu_type + ''; for (let j = 0; j < nalu_array.length; j++) { const nalu = nalu_array[j]; - if (j !== 0) str += ''; + if (j !== 0) { + str += ''; + } str += ''; str += nalu.data.reduce(function (str, byte) { return str + byte.toString(16).padStart(2, '0'); diff --git a/src/boxes/sampleentries/sampleentry.ts b/src/boxes/sampleentries/sampleentry.ts index dd5f3818..ae218c10 100644 --- a/src/boxes/sampleentries/sampleentry.ts +++ b/src/boxes/sampleentries/sampleentry.ts @@ -124,7 +124,9 @@ class hvcCSampleEntryBase extends VisualSampleEntry { let reversed = 0; for (let i = 0; i < 32; i++) { reversed |= val & 1; - if (i === 31) break; + if (i === 31) { + break; + } reversed <<= 1; val >>= 1; } diff --git a/src/descriptor.ts b/src/descriptor.ts index acdab49e..9cd95ef3 100644 --- a/src/descriptor.ts +++ b/src/descriptor.ts @@ -116,7 +116,9 @@ export class ES_Descriptor extends Descriptor { getAudioConfig() { const dcd = this.findDescriptor(DecoderConfigDescrTag); - if (!dcd) return null; + if (!dcd) { + return null; + } const dsi = dcd.findDescriptor(DecSpecificInfoTag); if (dsi && dsi.data) { let audioObjectType = (dsi.data[0] & 0xf8) >> 3; diff --git a/src/isofile.ts b/src/isofile.ts index 4b8b5169..325f9656 100644 --- a/src/isofile.ts +++ b/src/isofile.ts @@ -416,7 +416,9 @@ export class ISOFile { /* Check if the moovStart callback needs to be called */ if (this.moovStartFound && !this.moovStartSent) { this.moovStartSent = true; - if (this.onMoovStart) this.onMoovStart(); + if (this.onMoovStart) { + this.onMoovStart(); + } } if (this.moov) { @@ -617,7 +619,9 @@ export class ISOFile { movie.mime += 'application/mp4; codecs="'; } for (let i = 0; i < movie.tracks.length; i++) { - if (i !== 0) movie.mime += ','; + if (i !== 0) { + movie.mime += ','; + } movie.mime += movie.tracks[i].codec; } movie.mime += '"; profiles="'; @@ -639,7 +643,9 @@ export class ISOFile { } processSamples(last?: boolean) { - if (!this.sampleProcessingStarted) return; + if (!this.sampleProcessingStarted) { + return; + } /* For each track marked for fragmentation, check if the next sample is there (i.e. if the sample information is known (i.e. moof has arrived) and if it has been downloaded) @@ -755,9 +761,13 @@ export class ISOFile { } static _sweep(type: BoxKind['type'], result: Array, returnEarly: boolean) { - if (this.type && this.type === type) result.push(this); + if (this.type && this.type === type) { + result.push(this); + } for (const box in this.boxes) { - if (result.length && returnEarly) return; + if (result.length && returnEarly) { + return; + } ISOFile._sweep.call(this.boxes[box], type, result, returnEarly); } } @@ -781,7 +791,9 @@ export class ISOFile { releaseUsedSamples(id: number, sampleNum: number) { let size = 0; const trak = this.getTrackById(id); - if (!trak.lastValidSample) trak.lastValidSample = 0; + if (!trak.lastValidSample) { + trak.lastValidSample = 0; + } for (let i = trak.lastValidSample; i < sampleNum; i++) { size += this.releaseSample(trak, i); } @@ -1119,7 +1131,9 @@ export class ISOFile { } const stss = trak.mdia.minf.stbl.stss; const k = trak.mdia.minf.stbl.boxes.indexOf(stss); - if (k !== -1) trak.mdia.minf.stbl.boxes[k] = null; + if (k !== -1) { + trak.mdia.minf.stbl.boxes[k] = null; + } } } @@ -1710,7 +1724,9 @@ export class ISOFile { } else { /* the sample does not end in this buffer */ - if (lengthAfterStart === 0) return null; + if (lengthAfterStart === 0) { + return null; + } Log.debug( 'ISOFile', @@ -1795,10 +1811,14 @@ export class ISOFile { * @bundle isofile-sample-processing.js */ getTrexById(id: number) { - if (!this.moov || !this.moov.mvex) return null; + if (!this.moov || !this.moov.mvex) { + return null; + } for (let i = 0; i < this.moov.mvex.trexs.length; i++) { const trex = this.moov.mvex.trexs[i]; - if (trex.track_id === id) return trex; + if (trex.track_id === id) { + return trex; + } } return null; } @@ -1814,7 +1834,9 @@ export class ISOFile { } for (let j = 0; j < this.moov.traks.length; j++) { const trak = this.moov.traks[j]; - if (trak.tkhd.track_id === id) return trak; + if (trak.tkhd.track_id === id) { + return trak; + } } return null; } @@ -1824,9 +1846,15 @@ export class ISOFile { const items = this.items; const entity_groups = this.entity_groups; const meta = this.meta; - if (meta === null || meta === undefined) return; - if (meta.hdlr === undefined) return; - if (meta.iinf === undefined) return; + if (meta === null || meta === undefined) { + return; + } + if (meta.hdlr === undefined) { + return; + } + if (meta.iinf === undefined) { + return; + } for (let i = 0; i < meta.iinf.item_infos.length; i++) { const id = meta.iinf.item_infos[i].item_ID; items[id] = { @@ -2125,7 +2153,9 @@ export class ISOFile { } else { item = this.getPrimaryItem(); } - if (item === null) return null; + if (item === null) { + return null; + } const file = new ISOFile(); file.discardMdatData = false; @@ -2384,7 +2414,9 @@ export class ISOFile { const sampleEntry = BoxRegistry[`${options.type}SampleEntry`]; - if (!sampleEntry) return; + if (!sampleEntry) { + return; + } const sample_description_entry = new sampleEntry(); sample_description_entry.data_reference_index = 1; @@ -2510,7 +2542,9 @@ export class ISOFile { } = {}, ) { const trak = this.getTrackById(track_id); - if (trak === null) return; + if (trak === null) { + return; + } const descriptionIndex = sample_description_index ? sample_description_index - 1 : 0; @@ -2559,8 +2593,12 @@ export class ISOFile { /** @bundle isofile-advanced-creation.js */ createSingleSampleMoof(sample: Sample) { let sample_flags = 0; - if (sample.is_sync) sample_flags = 1 << 25; // sample_depends_on_none (I picture) - else sample_flags = 1 << 16; // non-sync + if (sample.is_sync) { + sample_flags = 1 << 25; + } // sample_depends_on_none (I picture) + else { + sample_flags = 1 << 16; + } // non-sync const moof = new moofBox(); diff --git a/src/log.ts b/src/log.ts index a3941b27..52853b49 100644 --- a/src/log.ts +++ b/src/log.ts @@ -13,11 +13,17 @@ let log_level = LOG_LEVEL_ERROR; export class Log { static setLogLevel(level: { (module: string, msg?: string): void }) { - if (level === this.debug) log_level = LOG_LEVEL_DEBUG; - else if (level === this.info) log_level = LOG_LEVEL_INFO; - else if (level === this.warn) log_level = LOG_LEVEL_WARNING; - else if (level === this.error) log_level = LOG_LEVEL_ERROR; - else log_level = LOG_LEVEL_ERROR; + if (level === this.debug) { + log_level = LOG_LEVEL_DEBUG; + } else if (level === this.info) { + log_level = LOG_LEVEL_INFO; + } else if (level === this.warn) { + log_level = LOG_LEVEL_WARNING; + } else if (level === this.error) { + log_level = LOG_LEVEL_ERROR; + } else { + log_level = LOG_LEVEL_ERROR; + } } static debug(module: string, msg?: string) { if (console.debug === undefined) { @@ -110,7 +116,9 @@ export class Log { if (length > 0) { let str = ''; for (let i = 0; i < length; i++) { - if (i > 0) str += ','; + if (i > 0) { + str += ','; + } str += '[' + Log.getDurationString(ranges.start(i)) + From a4cab4584692f4491cad0297a8d2da225db0cec0 Mon Sep 17 00:00:00 2001 From: Erwan Vivien Date: Mon, 26 May 2025 11:32:34 +0200 Subject: [PATCH 08/16] feat: ESLint no-implicit-coercion rule --- eslint.config.js | 1 + src/DataStream.ts | 12 ++++++------ src/boxes/sampleentries/sampleentry.ts | 1 - src/buffer.ts | 9 +-------- src/log.ts | 2 +- src/text-mp4.ts | 4 ++-- 6 files changed, 11 insertions(+), 18 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 8b3b2e59..ed0e8670 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -25,6 +25,7 @@ export default defineConfig([ 'no-nested-ternary': 'error', '@typescript-eslint/consistent-type-definitions': ['error', 'type'], curly: ['error', 'all'], + 'no-implicit-coercion': ['error', {}], }, }, ]); diff --git a/src/DataStream.ts b/src/DataStream.ts index a8898a8b..1721f4d0 100644 --- a/src/DataStream.ts +++ b/src/DataStream.ts @@ -226,9 +226,9 @@ export class DataStream { * @return Uint8Array to the DataStream backing buffer. */ mapUint8Array(length: number) { - this._realloc(length * 1); + this._realloc(length); const arr = new Uint8Array(this._buffer, this.byteOffset + this.position, length); - this.position += length * 1; + this.position += length; return arr; } @@ -789,7 +789,7 @@ export class DataStream { * @bundle DataStream-write.js */ writeInt8Array(array: ArrayLike) { - this._realloc(array.length * 1); + this._realloc(array.length); if ( array instanceof Int8Array && this.byteOffset + (this.position % array.BYTES_PER_ELEMENT) === 0 @@ -872,7 +872,7 @@ export class DataStream { * @bundle DataStream-write.js */ writeUint8Array(array: ArrayLike) { - this._realloc(array.length * 1); + this._realloc(array.length); if ( array instanceof Uint8Array && this.byteOffset + (this.position % array.BYTES_PER_ELEMENT) === 0 @@ -1732,9 +1732,9 @@ export class DataStream { * @bundle DataStream-map.js */ mapInt8Array(length: number, _endianness?: boolean) { - this._realloc(length * 1); + this._realloc(length); const arr = new Int8Array(this._buffer, this.byteOffset + this.position, length); - this.position += length * 1; + this.position += length; return arr; } diff --git a/src/boxes/sampleentries/sampleentry.ts b/src/boxes/sampleentries/sampleentry.ts index ae218c10..6d265161 100644 --- a/src/boxes/sampleentries/sampleentry.ts +++ b/src/boxes/sampleentries/sampleentry.ts @@ -106,7 +106,6 @@ class hvcCSampleEntryBase extends VisualSampleEntry { baseCodec += '.'; switch (this.hvcC.general_profile_space) { case 0: - baseCodec += ''; break; case 1: baseCodec += 'A'; diff --git a/src/buffer.ts b/src/buffer.ts index fd77dc31..d336fe62 100644 --- a/src/buffer.ts +++ b/src/buffer.ts @@ -216,14 +216,7 @@ export class MultiBufferStream extends DataStream { } else { log( 'MultiBufferStream', - '' + - this.buffers.length + - ' stored buffer(s) (' + - used + - '/' + - total + - ' bytes), continuous ranges: ' + - bufferedString, + `${this.buffers.length} stored buffer(s) (${used}/${total} bytes), continuous ranges: ${bufferedString}`, ); } } diff --git a/src/log.ts b/src/log.ts index 52853b49..ef72ab9a 100644 --- a/src/log.ts +++ b/src/log.ts @@ -72,7 +72,7 @@ export class Log { let neg: boolean; /* Helper function to print a number on a fixed number of digits */ function pad(number: string | number, length: number) { - const str = '' + number; + const str = String(number); const a = str.split('.'); while (a[0].length < length) { a[0] = '0' + a[0]; diff --git a/src/text-mp4.ts b/src/text-mp4.ts index 0ac4dbc7..c7f8759f 100644 --- a/src/text-mp4.ts +++ b/src/text-mp4.ts @@ -1,4 +1,4 @@ -import type { Box} from '#/box'; +import type { Box } from '#/box'; import { parseOneBox } from '#/box'; import { OK } from '#/constants'; import { MP4BoxStream } from '#/stream'; @@ -35,7 +35,7 @@ export class VTTin4Parser { const m = Math.floor((insec - h * 3600) / 60); const s = Math.floor(insec - h * 3600 - m * 60); const ms = Math.floor((insec - h * 3600 - m * 60 - s) * 1000); - return '' + pad(h, 2) + ':' + pad(m, 2) + ':' + pad(s, 2) + '.' + pad(ms, 3); + return `${pad(h, 2)}:${pad(m, 2)}:${pad(s, 2)}.${pad(ms, 3)}`; } const cues = this.parseSample(data); let string = ''; From 78659046d340375a7cbbf1e260dda937d5fb6d1e Mon Sep 17 00:00:00 2001 From: DenizUgur Date: Mon, 26 May 2025 12:46:32 -0700 Subject: [PATCH 09/16] chore: change rules a bit --- .editorconfig | 13 +++++++++++++ .prettierrc | 1 + eslint.config.js | 5 ++--- package.json | 4 ++-- 4 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..6e87a003 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +# Editor configuration, see http://editorconfig.org +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +max_line_length = off +trim_trailing_whitespace = false diff --git a/.prettierrc b/.prettierrc index ade8e400..61482dd4 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,5 +1,6 @@ { "trailingComma": "all", + "endOfLine": "lf", "tabWidth": 2, "printWidth": 100, "semi": true, diff --git a/eslint.config.js b/eslint.config.js index ed0e8670..3959ec39 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -12,7 +12,6 @@ export default defineConfig([ { rules: { eqeqeq: ['error', 'always'], - 'linebreak-style': ['error', 'unix'], 'one-var': ['error', 'never'], semi: ['error', 'always'], 'no-throw-literal': 'error', @@ -23,8 +22,8 @@ export default defineConfig([ 'no-unused-vars': 'off', '@typescript-eslint/consistent-type-imports': 'error', 'no-nested-ternary': 'error', - '@typescript-eslint/consistent-type-definitions': ['error', 'type'], - curly: ['error', 'all'], + '@typescript-eslint/consistent-type-definitions': ['error', 'interface'], + curly: ['error', 'multi-line'], 'no-implicit-coercion': ['error', {}], }, }, diff --git a/package.json b/package.json index 069c2cec..fdc8587b 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "circular": "dpdm -T ./entries/all.ts", "types": "tsc --noEmit --project tsconfig.json", "test": "npm run lint && npm run build && npm run types && npm run circular", - "lint": "eslint src --ext .ts,.js" + "lint": "eslint" }, "devDependencies": { "@commitlint/cli": "^19.8.1", @@ -72,4 +72,4 @@ "typescript-eslint": "^8.32.1" }, "packageManager": "npm@11.4.1" -} \ No newline at end of file +} From f75c3a5cab97ca2a084babcbf223288444a54449 Mon Sep 17 00:00:00 2001 From: Erwan Vivien Date: Mon, 26 May 2025 22:28:57 +0200 Subject: [PATCH 10/16] chore: fix ESLint to use recommandations --- .husky/install.mjs | 2 + entries/types.ts | 102 +++++++++++----------- eslint.config.js | 31 +++---- package.json | 2 +- src/DataStream.ts | 4 +- src/box-diff.ts | 4 +- src/box.ts | 8 +- src/boxes/EntityToGroup/base.ts | 2 +- src/boxes/EntityToGroup/index.ts | 6 +- src/boxes/a1lx.ts | 2 +- src/boxes/cdef.ts | 6 +- src/boxes/cmpd.ts | 4 +- src/boxes/co64.ts | 2 +- src/boxes/ctts.ts | 6 +- src/boxes/dOps.ts | 2 +- src/boxes/dec3.ts | 6 +- src/boxes/defaults.ts | 114 ++++++++++++------------- src/boxes/dref.ts | 2 +- src/boxes/ftyp.ts | 2 +- src/boxes/iinf.ts | 2 +- src/boxes/iloc.ts | 10 +-- src/boxes/ipma.ts | 8 +- src/boxes/iref.ts | 2 +- src/boxes/leva.ts | 6 +- src/boxes/mdcv.ts | 2 +- src/boxes/meta.ts | 20 ++--- src/boxes/padb.ts | 2 +- src/boxes/pdin.ts | 4 +- src/boxes/pixi.ts | 2 +- src/boxes/prdi.ts | 2 +- src/boxes/pssh.ts | 2 +- src/boxes/qt/tapt.ts | 6 +- src/boxes/saio.ts | 2 +- src/boxes/saiz.ts | 2 +- src/boxes/sampleentries/base.ts | 4 +- src/boxes/sampleentries/sampleentry.ts | 20 ++--- src/boxes/samplegroups/alst.ts | 6 +- src/boxes/samplegroups/avss.ts | 4 +- src/boxes/samplegroups/rash.ts | 4 +- src/boxes/sbgp.ts | 6 +- src/boxes/sbpm.ts | 6 +- src/boxes/sdtp.ts | 8 +- src/boxes/sidx.ts | 4 +- src/boxes/ssix.ts | 10 +-- src/boxes/stco.ts | 14 +-- src/boxes/stdp.ts | 2 +- src/boxes/stri.ts | 2 +- src/boxes/stsc.ts | 8 +- src/boxes/stsd.ts | 2 +- src/boxes/stsg.ts | 2 +- src/boxes/stsh.ts | 4 +- src/boxes/stss.ts | 2 +- src/boxes/stsz.ts | 2 +- src/boxes/stts.ts | 6 +- src/boxes/styp.ts | 2 +- src/boxes/stz2.ts | 2 +- src/boxes/subs.ts | 4 +- src/boxes/tfra.ts | 2 +- src/boxes/tref.ts | 2 +- src/boxes/trun.ts | 8 +- src/boxes/tsel.ts | 2 +- src/boxes/tyco.ts | 2 +- src/boxes/uncC.ts | 8 +- src/boxes/vmhd.ts | 4 +- src/boxes/vvcC.ts | 6 +- src/buffer.ts | 4 +- src/descriptor.ts | 2 - src/isofile.ts | 64 +++++++------- src/log.ts | 36 ++++---- src/text-mp4.ts | 5 +- tsup.config.ts | 2 +- 71 files changed, 324 insertions(+), 326 deletions(-) diff --git a/.husky/install.mjs b/.husky/install.mjs index 95b1d382..897e473e 100644 --- a/.husky/install.mjs +++ b/.husky/install.mjs @@ -1,3 +1,5 @@ +/* eslint-disable no-undef */ + // Skip Husky install in production and CI if (process.env.NODE_ENV === 'production' || process.env.CI === 'true') { process.exit(0); diff --git a/entries/types.ts b/entries/types.ts index f0f3868e..2d450dd1 100644 --- a/entries/types.ts +++ b/entries/types.ts @@ -7,9 +7,13 @@ import type { SampleEntry } from './all'; import type * as BOXES from './all-boxes'; type AllBoxes = Partial & Partial; + +// Unsure of the implications of changing this namespace export +// Prefer to keep it as is for compatibility +// eslint-disable-next-line @typescript-eslint/no-namespace export namespace MP4Box { - export interface BoxRegistry extends AllBoxes {} - export interface DescriptorRegistry extends Partial {} + export type BoxRegistry = AllBoxes; + export type DescriptorRegistry = Partial; } export type TypedArray = @@ -26,7 +30,7 @@ export type TypedArray = | BigUint64Array; export type ValueOf = T[keyof T]; -export type InstanceOf = T extends new (...args: Array) => infer R ? R : never; +export type InstanceOf = T extends new (...args: unknown[]) => infer R ? R : never; export type KindOf = InstanceOf>; export type Extends = { [TKey in keyof TObject]: TObject[TKey] extends TExtends ? TObject[TKey] : undefined; @@ -53,7 +57,7 @@ export interface ExtractedTrack { user: TUser; trak: trakBox; nb_samples: number; - samples: Array; + samples: Sample[]; } export interface Sample { @@ -77,9 +81,9 @@ export interface Sample { number: number; offset: number; pts?: number; - sample_groups?: Array; + sample_groups?: SampleGroup[]; size: number; - subsamples?: Array; + subsamples?: SubSample[]; timescale: number; track_id: number; } @@ -110,9 +114,9 @@ export interface Track { movie_timescale: number; name: string; nb_samples: number; - references: Array<{ track_ids: ArrayLike; type: string }>; + references: { track_ids: ArrayLike; type: string }[]; samples_duration: number; - samples?: Array; + samples?: Sample[]; size: number; timescale: number; track_height: number; @@ -124,40 +128,40 @@ export interface Track { export interface Movie { hasMoov: boolean; - audioTracks: Array; - brands: Array; + audioTracks: Track[]; + brands: string[]; created: Date; duration: number; fragment_duration: number | undefined; hasIOD: boolean; - hintTracks: Array; + hintTracks: Track[]; isFragmented: boolean; isProgressive: boolean; - metadataTracks: Array; + metadataTracks: Track[]; mime: string; modified: Date; - otherTracks: Array; - subtitleTracks: Array; + otherTracks: Track[]; + subtitleTracks: Track[]; timescale: number; - tracks: Array; - videoTracks: Array; + tracks: Track[]; + videoTracks: Track[]; } export interface Description { default_group_description_index: number; - entries: Array; + entries: (SampleGroupEntry | SampleEntry)[]; used: boolean; version: number; } -export type IncompleteBox = { +export interface IncompleteBox { box?: Box; code: number; hdr_size?: number; size?: number; start?: number; type?: string; -}; +} export interface Item { alreadyRead?: number; @@ -165,20 +169,20 @@ export interface Item { content_type?: string; item_uri_type: string; data?: Uint8Array; - extents?: Array<{ + extents?: { alreadyRead?: number; length: number; offset: number; - }>; + }[]; id?: number; name?: string; primary?: boolean; - properties?: { boxes: Array }; + properties?: { boxes: Box[] }; protection?: BOXES.sinfBox; - ref_to?: Array<{ + ref_to?: { type: string; id: Reference; - }>; + }[]; sent?: boolean; size?: number; source?: Box; @@ -187,10 +191,10 @@ export interface Item { export interface EntityGroup { id: number; - entity_ids: Array; + entity_ids: number[]; type: string; properties?: { - boxes: Array; + boxes: Box[]; }; } @@ -211,7 +215,7 @@ export interface Nalu { length?: number; } -export type NaluArray = Array & { +export type NaluArray = Nalu[] & { completeness: number; nalu_type: number; length: number; @@ -301,10 +305,12 @@ export type StringType = | EncodedLengthStringType | EndianStringType; -export type GetterSetterType = { +// Unsure why changing `any` to `unknown` causes issues in some places. +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export interface GetterSetterType { get(dataStream: DataStream, struct: Record): T; set?(dataStream: DataStream, value: T, struct?: Record): void; -}; +} export type TupleType = [ '[]', @@ -317,7 +323,7 @@ export type TupleType = [ ), ]; -export type FnType = (dataStream: DataStream, struct: T) => number; +export type FnType = (dataStream: DataStream, struct: T) => number; export type Type = | NumberType @@ -337,30 +343,30 @@ export type ParsedType = | SimpleNumberType | EndianNumberType; -export type StructDefinition = Array<[name: string, type: Type]>; +export type StructDefinition = [name: string, type: Type][]; export type ValueFromType = TValue extends StringType ? string : TValue extends NumberType - ? number - : TValue extends FnType - ? ReturnType - : TValue extends GetterSetterType - ? ReturnType - : TValue extends ['[]', NumberType, infer TAmount] - ? TAmount extends number - ? TupleOf - : TAmount extends () => infer TReturnType - ? TReturnType extends number - ? TupleOf - : never - : Array - : TValue extends StructDefinition - ? StructDataFromStructDefinition - : never; + ? number + : TValue extends FnType + ? ReturnType + : TValue extends GetterSetterType + ? ReturnType + : TValue extends ['[]', NumberType, infer TAmount] + ? TAmount extends number + ? TupleOf + : TAmount extends () => infer TReturnType + ? TReturnType extends number + ? TupleOf + : never + : number[] + : TValue extends StructDefinition + ? StructDataFromStructDefinition + : never; export type StructDataFromStructDefinition = { - [TKey in T[number][0]]: Extract[1] extends infer TValue + [TKey in T[number][0]]: Extract[1] extends infer TValue ? TValue extends Type ? ValueFromType : never diff --git a/eslint.config.js b/eslint.config.js index 3959ec39..e930ef43 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,30 +1,23 @@ -import js from '@eslint/js'; -import globals from 'globals'; +import eslint from '@eslint/js'; import tseslint from 'typescript-eslint'; -import json from '@eslint/json'; -import { defineConfig } from 'eslint/config'; -export default defineConfig([ - { files: ['**/*.{js,mjs,cjs,ts,mts,cts}'], plugins: { js }, extends: ['js/recommended'] }, - { files: ['**/*.{js,mjs,cjs,ts,mts,cts}'], languageOptions: { globals: globals.browser } }, - tseslint.configs.recommended, - { files: ['**/*.json'], plugins: { json }, language: 'json/json', extends: ['json/recommended'] }, +export default tseslint.config( + { ignores: ['dist', '**/*.js'] }, + eslint.configs.recommended, + + tseslint.configs.strict, + tseslint.configs.stylistic, { rules: { - eqeqeq: ['error', 'always'], - 'one-var': ['error', 'never'], - semi: ['error', 'always'], - 'no-throw-literal': 'error', + // Override no-unused-vars to allow unused variables that start with an underscore '@typescript-eslint/no-unused-vars': [ 'error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }, ], + // Disable the base rule 'no-unused-vars' to avoid conflicts with TypeScript's rule 'no-unused-vars': 'off', - '@typescript-eslint/consistent-type-imports': 'error', - 'no-nested-ternary': 'error', - '@typescript-eslint/consistent-type-definitions': ['error', 'interface'], - curly: ['error', 'multi-line'], - 'no-implicit-coercion': ['error', {}], + // Disable @typescript-eslint/prefer-for-of we have too much for now + '@typescript-eslint/prefer-for-of': 'off', }, }, -]); +); diff --git a/package.json b/package.json index fdc8587b..c43228fb 100644 --- a/package.json +++ b/package.json @@ -72,4 +72,4 @@ "typescript-eslint": "^8.32.1" }, "packageManager": "npm@11.4.1" -} +} \ No newline at end of file diff --git a/src/DataStream.ts b/src/DataStream.ts index 1721f4d0..ed404eea 100644 --- a/src/DataStream.ts +++ b/src/DataStream.ts @@ -23,7 +23,7 @@ type ReadTypeReturnValue = | Float32Array | Float64Array | null - | Array + | ReadTypeReturnValue[] | { [key: string]: ReadTypeReturnValue; }; @@ -1824,7 +1824,7 @@ export class DataStream { } function fromCharCodeUint8(uint8arr: Uint8Array) { - const arr: Array = []; + const arr: number[] = []; for (let i = 0; i < uint8arr.length; i++) { arr[i] = uint8arr[i]; } diff --git a/src/box-diff.ts b/src/box-diff.ts index 128ccf16..d54abe13 100644 --- a/src/box-diff.ts +++ b/src/box-diff.ts @@ -51,9 +51,9 @@ export function boxEqualFields(box_a: Box, box_b: Box) { continue; } else if ( ('subBoxNames' in box_a && - (box_a.subBoxNames as Array).indexOf(prop.slice(0, 4)) > -1) || + (box_a.subBoxNames as string[]).indexOf(prop.slice(0, 4)) > -1) || ('subBoxNames' in box_b && - (box_b.subBoxNames as Array).indexOf(prop.slice(0, 4)) > -1) + (box_b.subBoxNames as string[]).indexOf(prop.slice(0, 4)) > -1) ) { continue; } else { diff --git a/src/box.ts b/src/box.ts index 50e07c0d..a3705c6f 100644 --- a/src/box.ts +++ b/src/box.ts @@ -12,8 +12,8 @@ import type { MP4BoxStream } from '#/stream'; import type { BoxKind, Extends, Output, Reference } from '@types'; export class Box { - boxes?: Array; - data: Array | Uint8Array; + boxes?: Box[]; + data: number[] | Uint8Array; has_unparsed_data?: boolean; hdr_size?: number; language: number; @@ -306,7 +306,7 @@ export class TrackGroupTypeBox extends FullBox { /** @bundle parsing/singleitemtypereference.js */ export class SingleItemTypeReferenceBox extends Box { from_item_ID: number; - references: Array; + references: Reference[]; constructor( public type: string, @@ -332,7 +332,7 @@ export class SingleItemTypeReferenceBox extends Box { /** @bundle parsing/singleitemtypereferencelarge.js */ export class SingleItemTypeReferenceBoxLarge extends Box { from_item_ID: number; - references: Array; + references: Reference[]; constructor( public type: string, diff --git a/src/boxes/EntityToGroup/base.ts b/src/boxes/EntityToGroup/base.ts index 4ad244f9..10d4e582 100644 --- a/src/boxes/EntityToGroup/base.ts +++ b/src/boxes/EntityToGroup/base.ts @@ -5,7 +5,7 @@ import type { MultiBufferStream } from '#/buffer'; export class EntityToGroup extends FullBox { group_id: number; num_entities_in_group: number; - entity_ids: Array; + entity_ids: number[]; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/EntityToGroup/index.ts b/src/boxes/EntityToGroup/index.ts index 1ee05c38..860aef91 100644 --- a/src/boxes/EntityToGroup/index.ts +++ b/src/boxes/EntityToGroup/index.ts @@ -101,9 +101,9 @@ export class prgrBox extends EntityToGroup { export class pymdBox extends EntityToGroup { tile_size_x: number; tile_size_y: number; - layer_binning: Array; - tiles_in_layer_column_minus1: Array; - tiles_in_layer_row_minus1: Array; + layer_binning: number[]; + tiles_in_layer_column_minus1: number[]; + tiles_in_layer_row_minus1: number[]; type = 'pymd' as const; box_name = 'Image pyramid'; diff --git a/src/boxes/a1lx.ts b/src/boxes/a1lx.ts index 005fef2c..e8dca414 100644 --- a/src/boxes/a1lx.ts +++ b/src/boxes/a1lx.ts @@ -5,7 +5,7 @@ export class a1lxBox extends Box { type = 'a1lx' as const; box_name = 'AV1LayeredImageIndexingProperty'; - layer_size: Array; + layer_size: number[]; parse(stream: MultiBufferStream) { const large_size = stream.readUint8() & 1; diff --git a/src/boxes/cdef.ts b/src/boxes/cdef.ts index 5fccf74a..046c4089 100644 --- a/src/boxes/cdef.ts +++ b/src/boxes/cdef.ts @@ -6,9 +6,9 @@ export class cdefBox extends Box { box_name = 'ComponentDefinitionBox'; channel_count: number; - channel_indexes: Array; - channel_types: Array; - channel_associations: Array; + channel_indexes: number[]; + channel_types: number[]; + channel_associations: number[]; parse(stream: MultiBufferStream) { this.channel_count = stream.readUint16(); diff --git a/src/boxes/cmpd.ts b/src/boxes/cmpd.ts index b7f619aa..a442385e 100644 --- a/src/boxes/cmpd.ts +++ b/src/boxes/cmpd.ts @@ -6,8 +6,8 @@ export class cmpdBox extends Box { box_name = 'ComponentDefinitionBox'; component_count: number; - component_types: Array; - component_type_urls: Array; + component_types: number[]; + component_type_urls: string[]; parse(stream: MultiBufferStream) { this.component_count = stream.readUint32(); diff --git a/src/boxes/co64.ts b/src/boxes/co64.ts index 112e3843..e281e618 100644 --- a/src/boxes/co64.ts +++ b/src/boxes/co64.ts @@ -5,7 +5,7 @@ export class co64Box extends FullBox { type = 'co64' as const; box_name = 'ChunkLargeOffsetBox'; - chunk_offsets: Array; + chunk_offsets: number[]; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/ctts.ts b/src/boxes/ctts.ts index c1ade417..c39db460 100644 --- a/src/boxes/ctts.ts +++ b/src/boxes/ctts.ts @@ -7,8 +7,8 @@ export class cttsBox extends FullBox { type = 'ctts' as const; box_name = 'CompositionOffsetBox'; - sample_counts: Array; - sample_offsets: Array; + sample_counts: number[]; + sample_offsets: number[]; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); @@ -53,7 +53,7 @@ export class cttsBox extends FullBox { } /** @bundle box-unpack.js */ - unpack(samples: Array) { + unpack(samples: Sample[]) { let k = 0; for (let i = 0; i < this.sample_counts.length; i++) { for (let j = 0; j < this.sample_counts[i]; j++) { diff --git a/src/boxes/dOps.ts b/src/boxes/dOps.ts index cefd6f56..008a87d4 100644 --- a/src/boxes/dOps.ts +++ b/src/boxes/dOps.ts @@ -13,7 +13,7 @@ export class dOpsBox extends Box { ChannelMappingFamily: number; StreamCount: number; CoupledCount: number; - ChannelMapping: Array; + ChannelMapping: number[]; parse(stream: MultiBufferStream) { this.Version = stream.readUint8(); diff --git a/src/boxes/dec3.ts b/src/boxes/dec3.ts index 695f345b..306901c3 100644 --- a/src/boxes/dec3.ts +++ b/src/boxes/dec3.ts @@ -1,7 +1,7 @@ import { Box } from '#/box'; import type { MultiBufferStream } from '#/buffer'; -type IndSub = { +interface IndSub { fscod: number; bsid: number; bsmod: number; @@ -9,7 +9,7 @@ type IndSub = { lfeon: number; num_dep_sub: number; chan_loc?: number; -}; +} export class dec3Box extends Box { type = 'dec3' as const; @@ -17,7 +17,7 @@ export class dec3Box extends Box { data_rate: number; num_ind_sub: number; - ind_subs: Array; + ind_subs: IndSub[]; parse(stream: MultiBufferStream) { const tmp_16 = stream.readUint16(); diff --git a/src/boxes/defaults.ts b/src/boxes/defaults.ts index 65238cbe..9584ec6a 100644 --- a/src/boxes/defaults.ts +++ b/src/boxes/defaults.ts @@ -112,7 +112,7 @@ export class iproBox extends FullBox { type = 'ipro' as const; box_name = 'ItemProtectionBox'; - sinfs: Array = []; + sinfs: sinfBox[] = []; get protections() { return this.sinfs; } @@ -129,36 +129,36 @@ export class moovBox extends ContainerBox { box_name = 'MovieBox'; timescale: number; mvhd: mvhdBox; - mvhds: Array; + mvhds: mvhdBox[]; mvex: mvexBox; - mvexs: Array; + mvexs: mvexBox[]; iods: iodsBox; - iodss: Array; + iodss: iodsBox[]; trak: trakBox; - traks: Array = []; - psshs: Array = []; + traks: trakBox[] = []; + psshs: psshBox[] = []; subBoxNames = ['trak', 'pssh'] as const; } export class trakBox extends ContainerBox { type = 'trak' as const; box_name = 'TrackBox'; mdia: mdiaBox; - mdias: Array; + mdias: mdiaBox[]; tkhd: tkhdBox; - tkhds: Array; + tkhds: tkhdBox[]; tref: trefBox; - trefs: Array; + trefs: trefBox[]; edts: edtsBox; - edtss: Array; + edtss: edtsBox[]; udta: udtaBox; - udtas: Array; + udtas: udtaBox[]; samples_duration: number; - samples: Array; + samples: Sample[]; samples_size: number; nextSample: number; lastValidSample: number; - sample_groups_info: Array; + sample_groups_info: SampleGroupInfo[]; first_dts: number; first_traf_merged: boolean; has_fragment_subsamples: boolean; @@ -167,39 +167,39 @@ export class edtsBox extends ContainerBox { type = 'edts' as const; box_name = 'EditBox'; elst: elstBox; - elsts: Array; + elsts: elstBox[]; } export class mdiaBox extends ContainerBox { type = 'mdia' as const; box_name = 'MediaBox'; elng: elngBox; - elngs: Array; + elngs: elngBox[]; hdlr: hdlrBox; - hdlrs: Array; + hdlrs: hdlrBox[]; mdhd: mdhdBox; - mdhds: Array; + mdhds: mdhdBox[]; minf: minfBox; - minfs: Array; + minfs: minfBox[]; } export class minfBox extends ContainerBox { type = 'minf' as const; box_name = 'MediaInformationBox'; stbl: stblBox; - stbls: Array; + stbls: stblBox[]; hmhd: hmhdBox; - hmhds: Array; + hmhds: hmhdBox[]; vmhd?: vmhdBox; - vmhds?: Array; + vmhds?: vmhdBox[]; smhd?: smhdBox; - smhds?: Array; + smhds?: smhdBox[]; sthd?: sthdBox; - sthds?: Array; + sthds?: sthdBox[]; nmhd?: nmhdBox; - nmhds?: Array; + nmhds?: nmhdBox[]; dinf: dinfBox; - dinfs: Array; + dinfs: dinfBox[]; dref: drefBox; - drefs: Array; + drefs: drefBox[]; } export class dinfBox extends ContainerBox { type = 'dinf' as const; @@ -209,34 +209,34 @@ export class stblBox extends ContainerBox { type = 'stbl' as const; box_name = 'SampleTableBox'; cslg: cslgBox; - cslgs: Array; + cslgs: cslgBox[]; stsd: stsdBox; - stsds: Array; + stsds: stsdBox[]; stsc: stscBox; - stscs: Array; + stscs: stscBox[]; stco: stcoBox; - stcos: Array; + stcos: stcoBox[]; co64: co64Box; - co64s: Array; + co64s: co64Box[]; stsz: stszBox; - stszs: Array; + stszs: stszBox[]; stz2: stz2Box; - stz2s: Array; + stz2s: stz2Box[]; stts: sttsBox; - sttss: Array; + sttss: sttsBox[]; ctts: cttsBox; - cttss: Array; + cttss: cttsBox[]; stss: stssBox; - stsss: Array; + stsss: stssBox[]; subs: subsBox; - subss: Array; + subss: subsBox[]; stdp: stdpBox; - stdps: Array; + stdps: stdpBox[]; sdtp: sdtpBox; - sdtps: Array; + sdtps: sdtpBox[]; - sgpds: Array = []; - sbgps: Array = []; + sgpds: sgpdBox[] = []; + sbgps: sbgpBox[] = []; subBoxNames = ['sgpd', 'sbgp']; } export class mvexBox extends ContainerBox { @@ -244,39 +244,39 @@ export class mvexBox extends ContainerBox { box_name = 'MovieExtendsBox'; trex: trexBox; mehd: mehdBox; - mehds: Array; + mehds: mehdBox[]; - trexs: Array = []; + trexs: trexBox[] = []; subBoxNames = ['trex']; } export class moofBox extends ContainerBox { type = 'moof' as const; box_name = 'MovieFragmentBox'; mfhd: mfhdBox; - mfhds: Array; + mfhds: mfhdBox[]; traf: trafBox; - trafs: Array = []; + trafs: trafBox[] = []; subBoxNames = ['traf']; } export class trafBox extends ContainerBox { type = 'traf' as const; box_name = 'TrackFragmentBox'; subs: subsBox; - subss: Array; + subss: subsBox[]; tfdt: tfdtBox; - tfdts: Array; + tfdts: tfdtBox[]; tfhd: tfhdBox; - tfhds: Array; + tfhds: tfhdBox[]; trun: trunBox; first_sample_index: number; sample_number: number; - sample_groups_info: Array; + sample_groups_info: SampleGroupInfo[]; - truns: Array = []; - sgpds: Array = []; - sbgps: Array = []; + truns: trunBox[] = []; + sgpds: sgpdBox[] = []; + sbgps: sbgpBox[] = []; subBoxNames = ['trun', 'sgpd', 'sbgp']; } export class vttcBox extends ContainerBox { @@ -287,7 +287,7 @@ export class vttcBox extends ContainerBox { export class mfraBox extends ContainerBox { type = 'mfra' as const; box_name = 'MovieFragmentRandomAccessBox'; - tfras: Array = []; + tfras: tfraBox[] = []; subBoxNames = ['tfra'] as const; } export class mecoBox extends ContainerBox { @@ -330,7 +330,7 @@ export class trgrBox extends ContainerBox { export class udtaBox extends ContainerBox { type = 'udta' as const; box_name = 'UserDataBox'; - kinds: Array = []; + kinds: kindBox[] = []; subBoxNames = ['kind'] as const; } export class iprpBox extends ContainerBox { @@ -338,7 +338,7 @@ export class iprpBox extends ContainerBox { box_name = 'ItemPropertiesBox'; ipco: ipcoBox; - ipmas: Array = []; + ipmas: ipmaBox[] = []; subBoxNames = ['ipma'] as const; } export class ipcoBox extends ContainerBox { @@ -348,7 +348,7 @@ export class ipcoBox extends ContainerBox { export class grplBox extends ContainerBox { type = 'grpl' as const; box_name = 'GroupsListBox'; - declare boxes: Array; + declare boxes: EntityToGroup[]; } export class j2kHBox extends ContainerBox { type = 'j2kH' as const; @@ -357,6 +357,6 @@ export class j2kHBox extends ContainerBox { export class etypBox extends ContainerBox { type = 'etyp' as const; box_name = 'ExtendedTypeBox'; - tycos: Array = []; + tycos: tycoBox[] = []; subBoxNames = ['tyco'] as const; } diff --git a/src/boxes/dref.ts b/src/boxes/dref.ts index cab0d2f9..a5bef0ce 100644 --- a/src/boxes/dref.ts +++ b/src/boxes/dref.ts @@ -8,7 +8,7 @@ export class drefBox extends FullBox { type = 'dref' as const; box_name = 'DataReferenceBox'; - entries: Array; + entries: Box[]; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/ftyp.ts b/src/boxes/ftyp.ts index 107ddc80..966c3554 100644 --- a/src/boxes/ftyp.ts +++ b/src/boxes/ftyp.ts @@ -7,7 +7,7 @@ export class ftypBox extends Box { major_brand: string; minor_version: number; - compatible_brands: Array; + compatible_brands: string[]; parse(stream: MultiBufferStream) { let toparse = this.size - this.hdr_size; diff --git a/src/boxes/iinf.ts b/src/boxes/iinf.ts index 91129b56..ba2a6bbf 100644 --- a/src/boxes/iinf.ts +++ b/src/boxes/iinf.ts @@ -11,7 +11,7 @@ export class iinfBox extends FullBox { version: number; entry_count: number; - item_infos: Array; + item_infos: infeBox[]; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/iloc.ts b/src/boxes/iloc.ts index f2e96ca7..c94396d1 100644 --- a/src/boxes/iloc.ts +++ b/src/boxes/iloc.ts @@ -1,11 +1,11 @@ import { FullBox } from '#/box'; import type { MultiBufferStream } from '#/buffer'; -export type Extent = { +export interface Extent { extent_index: number; extent_offset: number; extent_length: number; -}; +} export class ilocBox extends FullBox { type = 'iloc' as const; @@ -15,13 +15,13 @@ export class ilocBox extends FullBox { length_size: number; base_offset_size: number; index_size: number; - items: Array<{ + items: { base_offset: number; construction_method: number; item_ID: number; data_reference_index: number; extents: Extent[]; - }>; + }[]; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); @@ -79,7 +79,7 @@ export class ilocBox extends FullBox { throw new Error('Error reading base offset size'); } - const extents: Array = []; + const extents: Extent[] = []; const extent_count = stream.readUint16(); for (let j = 0; j < extent_count; j++) { diff --git a/src/boxes/ipma.ts b/src/boxes/ipma.ts index 2baa4d8f..609ff991 100644 --- a/src/boxes/ipma.ts +++ b/src/boxes/ipma.ts @@ -1,16 +1,16 @@ import { FullBox } from '#/box'; import type { MultiBufferStream } from '#/buffer'; -export type Assocation = { +export interface Assocation { id: number; - props: Array<{ property_index: number; essential: boolean }>; -}; + props: { property_index: number; essential: boolean }[]; +} export class ipmaBox extends FullBox { type = 'ipma' as const; box_name = 'ItemPropertyAssociationBox'; - associations: Array; + associations: Assocation[]; version: number; flags: number; diff --git a/src/boxes/iref.ts b/src/boxes/iref.ts index 4706fc08..4c6200f0 100644 --- a/src/boxes/iref.ts +++ b/src/boxes/iref.ts @@ -34,7 +34,7 @@ export class irefBox extends FullBox { type = 'iref' as const; box_name = 'ItemReferenceBox'; - references: { references: Array; from_item_ID: number; type: string }[]; + references: { references: Reference[]; from_item_ID: number; type: string }[]; version: number; parse(stream: MultiBufferStream) { diff --git a/src/boxes/leva.ts b/src/boxes/leva.ts index 6065ebd6..99e8a605 100644 --- a/src/boxes/leva.ts +++ b/src/boxes/leva.ts @@ -2,20 +2,20 @@ import { Log } from '#//log'; import { FullBox } from '#/box'; import type { MultiBufferStream } from '#/buffer'; -type Level = { +interface Level { padding_flag: number; track_ID: number; assignment_type: number; grouping_type: string; grouping_type_parameter: number; sub_track_id: number; -}; +} export class levaBox extends FullBox { type = 'leva' as const; box_name = 'LevelAssignmentBox'; - levels: Array; + levels: Level[]; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/mdcv.ts b/src/boxes/mdcv.ts index 27164ef5..1254bf1d 100644 --- a/src/boxes/mdcv.ts +++ b/src/boxes/mdcv.ts @@ -6,7 +6,7 @@ export class mdcvBox extends Box { type = 'mdcv' as const; box_name = 'MasteringDisplayColourVolumeBox'; - display_primaries: Array; + display_primaries: ColorPoint[]; white_point: ColorPoint; max_display_mastering_luminance: number; min_display_mastering_luminance: number; diff --git a/src/boxes/meta.ts b/src/boxes/meta.ts index c1c031c6..f57726c6 100644 --- a/src/boxes/meta.ts +++ b/src/boxes/meta.ts @@ -12,25 +12,25 @@ export class metaBox extends FullBox { box_name = 'MetaBox'; hdlr: hdlrBox; - hdlrs: Array; + hdlrs: hdlrBox[]; iinf: iinfBox; - iinfs: Array; + iinfs: iinfBox[]; idat: idatBox; - idats: Array; + idats: idatBox[]; ipro: iproBox; - ipros: Array; + ipros: iproBox[]; grpl: grplBox; - grpls: Array; + grpls: grplBox[]; iloc: ilocBox; - ilocs: Array; + ilocs: ilocBox[]; iprp: iprpBox; - iprps: Array; + iprps: iprpBox[]; pitm: pitmBox; - pitms: Array; + pitms: pitmBox[]; iref: irefBox; - irefs: Array; + irefs: irefBox[]; dinf: dinfBox; - dinfs: Array; + dinfs: dinfBox[]; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/padb.ts b/src/boxes/padb.ts index 6c0e9bd1..cbe2dcc5 100644 --- a/src/boxes/padb.ts +++ b/src/boxes/padb.ts @@ -12,7 +12,7 @@ export class padbBox extends FullBox { type = 'padb' as const; box_name = 'PaddingBitsBox'; - padbits: Array; + padbits: PaddingBit[]; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/pdin.ts b/src/boxes/pdin.ts index 41c09b48..bacefaae 100644 --- a/src/boxes/pdin.ts +++ b/src/boxes/pdin.ts @@ -5,8 +5,8 @@ export class pdinBox extends Box { type = 'pdin' as const; box_name = 'ProgressiveDownloadInfoBox'; - rate: Array; - initial_delay: Array; + rate: number[]; + initial_delay: number[]; parse(stream: MultiBufferStream) { const count = (this.size - this.hdr_size) / 8; diff --git a/src/boxes/pixi.ts b/src/boxes/pixi.ts index d5594fe7..e50e438e 100644 --- a/src/boxes/pixi.ts +++ b/src/boxes/pixi.ts @@ -6,7 +6,7 @@ export class pixiBox extends FullBox { box_name = 'PixelInformationProperty'; num_channels: number; - bits_per_channels: Array; + bits_per_channels: number[]; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/prdi.ts b/src/boxes/prdi.ts index 9b72d3ba..10ac58a8 100644 --- a/src/boxes/prdi.ts +++ b/src/boxes/prdi.ts @@ -6,7 +6,7 @@ export class prdiBox extends FullBox { box_name = 'ProgressiveDerivedImageItemInformationProperty'; step_count: number; - item_count: Array; + item_count: number[]; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/pssh.ts b/src/boxes/pssh.ts index c6288a96..e90b5eb6 100644 --- a/src/boxes/pssh.ts +++ b/src/boxes/pssh.ts @@ -6,7 +6,7 @@ export class psshBox extends FullBox { box_name = 'ProtectionSystemSpecificHeaderBox'; system_id: string; - kid: Array; + kid: string[]; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/qt/tapt.ts b/src/boxes/qt/tapt.ts index ecf44ef3..0f971b6c 100644 --- a/src/boxes/qt/tapt.ts +++ b/src/boxes/qt/tapt.ts @@ -7,8 +7,8 @@ export class taptBox extends ContainerBox { type = 'tapt' as const; box_name = 'TrackApertureModeDimensionsBox'; - clef: Array = []; - prof: Array = []; - enof: Array = []; + clef: clefBox[] = []; + prof: profBox[] = []; + enof: enofBox[] = []; subBoxNames = ['clef', 'prof', 'enof'] as const; } diff --git a/src/boxes/saio.ts b/src/boxes/saio.ts index 0f68eda0..d17ca815 100644 --- a/src/boxes/saio.ts +++ b/src/boxes/saio.ts @@ -7,7 +7,7 @@ export class saioBox extends FullBox { aux_info_type: string; aux_info_type_parameter: number; - offset: Array; + offset: number[]; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/saiz.ts b/src/boxes/saiz.ts index ae36316e..823babab 100644 --- a/src/boxes/saiz.ts +++ b/src/boxes/saiz.ts @@ -9,7 +9,7 @@ export class saizBox extends FullBox { aux_info_type_parameter: number; default_sample_info_size: number; sample_count: number; - sample_info_size: Array; + sample_info_size: number[]; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/sampleentries/base.ts b/src/boxes/sampleentries/base.ts index aa19a935..54ea1603 100644 --- a/src/boxes/sampleentries/base.ts +++ b/src/boxes/sampleentries/base.ts @@ -156,9 +156,9 @@ export class TextSampleEntry extends SampleEntry {} //Base SampleEntry types for Audio and Video with specific parsing export class VisualSampleEntry extends SampleEntry { avcC?: avcCBox; - avcCs?: Array; + avcCs?: avcCBox[]; hvcC?: hvcCBox; - hvcCs?: Array; + hvcCs?: hvcCBox[]; width: number; height: number; diff --git a/src/boxes/sampleentries/sampleentry.ts b/src/boxes/sampleentries/sampleentry.ts index 6d265161..77dd7815 100644 --- a/src/boxes/sampleentries/sampleentry.ts +++ b/src/boxes/sampleentries/sampleentry.ts @@ -26,7 +26,7 @@ function decimalToHex(d: number | string, padding?: number | null) { class avcCSampleEntryBase extends VisualSampleEntry { declare avcC: avcCBox; - declare avcCs: Array; + declare avcCs: avcCBox[]; /** @bundle box-codecs.js */ getCodec() { @@ -60,7 +60,7 @@ export class avc4SampleEntry extends avcCSampleEntryBase { export class av01SampleEntry extends VisualSampleEntry { av1C: av1CBox; - av1Cs: Array; + av1Cs: av1CBox[]; type = 'av01' as const; @@ -97,7 +97,7 @@ export class dav1SampleEntry extends VisualSampleEntry { class hvcCSampleEntryBase extends VisualSampleEntry { declare hvcC: hvcCBox; - declare hvcCs: Array; + declare hvcCs: hvcCBox[]; /** @bundle box-codecs.js */ getCodec(): string { @@ -179,7 +179,7 @@ export class dvheSampleEntry extends VisualSampleEntry { /** @babel box-codecs.js */ class vvcCSampleEntryBase extends VisualSampleEntry { vvcC: vvcCBox; - vvcCs: Array; + vvcCs: vvcCBox[]; getCodec() { let baseCodec = super.getCodec(); if (this.vvcC) { @@ -257,7 +257,7 @@ export class vvcNSampleEntry extends VisualSampleEntry { class vpcCSampleEntryBase extends VisualSampleEntry { vpcC: vpcCBox; - vpcCs: Array; + vpcCs: vpcCBox[]; getCodec() { const baseCodec = super.getCodec(); let level: number | string = this.vpcC.level; @@ -302,7 +302,7 @@ export class uncvSampleEntry extends VisualSampleEntry { export class mp4aSampleEntry extends AudioSampleEntry { esds: esdsBox; - esdss: Array; + esdss: esdsBox[]; type = 'mp4a' as const; @@ -364,28 +364,28 @@ export class encaSampleEntry extends AudioSampleEntry { } export class encuSampleEntry extends SubtitleSampleEntry { - sinfs: Array = []; + sinfs: sinfBox[] = []; subBoxNames = ['sinf'] as const; type = 'encu' as const; } export class encsSampleEntry extends SystemSampleEntry { - sinfs: Array = []; + sinfs: sinfBox[] = []; subBoxNames = ['sinf'] as const; type = 'encs' as const; } export class enctSampleEntry extends TextSampleEntry { - sinfs: Array = []; + sinfs: sinfBox[] = []; subBoxNames = ['sinf'] as const; type = 'enct' as const; } export class encmSampleEntry extends MetadataSampleEntry { - sinfs: Array = []; + sinfs: sinfBox[] = []; subBoxNames = ['sinf'] as const; type = 'encm' as const; diff --git a/src/boxes/samplegroups/alst.ts b/src/boxes/samplegroups/alst.ts index 3551416c..bdc5285e 100644 --- a/src/boxes/samplegroups/alst.ts +++ b/src/boxes/samplegroups/alst.ts @@ -3,9 +3,9 @@ import type { MultiBufferStream } from '#/buffer'; export class alstSampleGroupEntry extends SampleGroupEntry { first_output_sample: number; - sample_offset: Array; - num_output_samples: Array; - num_total_samples: Array; + sample_offset: number[]; + num_output_samples: number[]; + num_total_samples: number[]; parse(stream: MultiBufferStream) { const roll_count = stream.readUint16(); diff --git a/src/boxes/samplegroups/avss.ts b/src/boxes/samplegroups/avss.ts index 2faf81b9..6158aa4b 100644 --- a/src/boxes/samplegroups/avss.ts +++ b/src/boxes/samplegroups/avss.ts @@ -10,11 +10,11 @@ export class avssSampleGroupEntry extends SampleGroupEntry { accurateStatisticsFlag: number; avgBitRate: number; avgFrameRate: number; - dependency: Array<{ + dependency: { subSeqDirectionFlag: number; layerNumber: number; subSequenceIdentifier: number; - }>; + }[]; parse(stream: MultiBufferStream) { this.subSequenceIdentifier = stream.readUint16(); diff --git a/src/boxes/samplegroups/rash.ts b/src/boxes/samplegroups/rash.ts index f43ffb2d..5a2c91a4 100644 --- a/src/boxes/samplegroups/rash.ts +++ b/src/boxes/samplegroups/rash.ts @@ -4,8 +4,8 @@ import { Log } from '#/log'; export class rashSampleGroupEntry extends SampleGroupEntry { operation_point_count: number; - target_rate_share: number | Array; - available_bitrate: Array; + target_rate_share: number | number[]; + available_bitrate: number[]; maximum_bitrate: number; minimum_bitrate: number; discard_priority: number; diff --git a/src/boxes/sbgp.ts b/src/boxes/sbgp.ts index 5139858f..2276010b 100644 --- a/src/boxes/sbgp.ts +++ b/src/boxes/sbgp.ts @@ -1,10 +1,10 @@ import { FullBox } from '#/box'; import type { MultiBufferStream } from '#/buffer'; -type Entry = { +interface Entry { sample_count: number; group_description_index: number; -}; +} export class sbgpBox extends FullBox { type = 'sbgp' as const; @@ -12,7 +12,7 @@ export class sbgpBox extends FullBox { grouping_type: string; grouping_type_parameter: number; - entries: Array; + entries: Entry[]; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/sbpm.ts b/src/boxes/sbpm.ts index deab4ab2..86baa9d2 100644 --- a/src/boxes/sbpm.ts +++ b/src/boxes/sbpm.ts @@ -7,13 +7,13 @@ export class sbpmBox extends FullBox { box_name = 'SensorBadPixelsMapBox'; component_count: number; - component_index: Array; + component_index: number[]; correction_applied: boolean; num_bad_rows: number; num_bad_cols: number; num_bad_pixels: number; - bad_rows: Array; - bad_columns: Array; + bad_rows: number[]; + bad_columns: number[]; bad_pixels: Pixel[]; parse(stream: MultiBufferStream) { diff --git a/src/boxes/sdtp.ts b/src/boxes/sdtp.ts index cddf73e6..ab72e1ed 100644 --- a/src/boxes/sdtp.ts +++ b/src/boxes/sdtp.ts @@ -5,10 +5,10 @@ export class sdtpBox extends FullBox { type = 'sdtp' as const; box_name = 'SampleDependencyTypeBox'; - is_leading: Array; - sample_depends_on: Array; - sample_is_depended_on: Array; - sample_has_redundancy: Array; + is_leading: number[]; + sample_depends_on: number[]; + sample_is_depended_on: number[]; + sample_has_redundancy: number[]; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/sidx.ts b/src/boxes/sidx.ts index cc248e7e..0c12f0e4 100644 --- a/src/boxes/sidx.ts +++ b/src/boxes/sidx.ts @@ -1,14 +1,14 @@ import { FullBox } from '#/box'; import type { MultiBufferStream } from '#/buffer'; -type Reference = { +interface Reference { reference_type: number; referenced_size: number; subsegment_duration: number; starts_with_SAP: number; SAP_type: number; SAP_delta_time: number; -}; +} export class sidxBox extends FullBox { type = 'sidx' as const; diff --git a/src/boxes/ssix.ts b/src/boxes/ssix.ts index 599126e0..286608e9 100644 --- a/src/boxes/ssix.ts +++ b/src/boxes/ssix.ts @@ -1,13 +1,13 @@ import { FullBox } from '#/box'; import type { MultiBufferStream } from '#/buffer'; -type Range = { +interface Range { level: number; range_size: number; -}; -type SubSegment = { - ranges: Array; -}; +} +interface SubSegment { + ranges: Range[]; +} export class ssixBox extends FullBox { type = 'ssix' as const; diff --git a/src/boxes/stco.ts b/src/boxes/stco.ts index c3fe4577..79ecfe3b 100644 --- a/src/boxes/stco.ts +++ b/src/boxes/stco.ts @@ -6,7 +6,7 @@ export class stcoBox extends FullBox { type = 'stco' as const; box_name = 'ChunkOffsetBox'; - chunk_offsets: Array; + chunk_offsets: number[]; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); @@ -23,16 +23,16 @@ export class stcoBox extends FullBox { write(stream: MultiBufferStream) { this.version = 0; this.flags = 0; - this.size = 4 + 4 * this.chunk_offsets!.length; + this.size = 4 + 4 * this.chunk_offsets.length; this.writeHeader(stream); - stream.writeUint32(this.chunk_offsets!.length); - stream.writeUint32Array(this.chunk_offsets!); + stream.writeUint32(this.chunk_offsets.length); + stream.writeUint32Array(this.chunk_offsets); } /** @bundle box-unpack.js */ - unpack(samples: Array) { - for (let i = 0; i < this.chunk_offsets!.length; i++) { - samples[i].offset = this.chunk_offsets![i]; + unpack(samples: Sample[]) { + for (let i = 0; i < this.chunk_offsets.length; i++) { + samples[i].offset = this.chunk_offsets[i]; } } } diff --git a/src/boxes/stdp.ts b/src/boxes/stdp.ts index 7ef4d5cb..5806a708 100644 --- a/src/boxes/stdp.ts +++ b/src/boxes/stdp.ts @@ -5,7 +5,7 @@ export class stdpBox extends FullBox { type = 'stpd' as const; box_name = 'DegradationPriorityBox'; - priority: Array; + priority: number[]; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/stri.ts b/src/boxes/stri.ts index 71cf1e00..788799a3 100644 --- a/src/boxes/stri.ts +++ b/src/boxes/stri.ts @@ -8,7 +8,7 @@ export class striBox extends FullBox { switch_group: number; alternate_group: number; sub_track_id: number; - attribute_list: Array; + attribute_list: number[]; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/stsc.ts b/src/boxes/stsc.ts index c5929290..d9ded6c7 100644 --- a/src/boxes/stsc.ts +++ b/src/boxes/stsc.ts @@ -6,9 +6,9 @@ export class stscBox extends FullBox { type = 'stsc' as const; box_name = 'SampleToChunkBox'; - first_chunk: Array; - samples_per_chunk: Array; - sample_description_index: Array; + first_chunk: number[]; + samples_per_chunk: number[]; + sample_description_index: number[]; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); @@ -38,7 +38,7 @@ export class stscBox extends FullBox { } } - unpack(samples: Array) { + unpack(samples: Sample[]) { let l = 0; let m = 0; for (let i = 0; i < this.first_chunk.length; i++) { diff --git a/src/boxes/stsd.ts b/src/boxes/stsd.ts index 33278155..57d48cde 100644 --- a/src/boxes/stsd.ts +++ b/src/boxes/stsd.ts @@ -9,7 +9,7 @@ export class stsdBox extends FullBox { type = 'stsd' as const; box_name = 'SampleDescriptionBox'; - entries: Array; + entries: SampleEntry[]; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/stsg.ts b/src/boxes/stsg.ts index 03c183fd..26c865be 100644 --- a/src/boxes/stsg.ts +++ b/src/boxes/stsg.ts @@ -6,7 +6,7 @@ export class stsgBox extends FullBox { box_name = 'SubTrackSampleGroupBox'; grouping_type: number; - group_description_index: Array; + group_description_index: number[]; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/stsh.ts b/src/boxes/stsh.ts index a7d4afe6..4b895dc8 100644 --- a/src/boxes/stsh.ts +++ b/src/boxes/stsh.ts @@ -5,8 +5,8 @@ export class stshBox extends FullBox { type = 'stsh' as const; box_name = 'ShadowSyncSampleBox'; - shadowed_sample_numbers: Array; - sync_sample_numbers: Array; + shadowed_sample_numbers: number[]; + sync_sample_numbers: number[]; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/stss.ts b/src/boxes/stss.ts index 4957f7d0..68b07dca 100644 --- a/src/boxes/stss.ts +++ b/src/boxes/stss.ts @@ -5,7 +5,7 @@ export class stssBox extends FullBox { type = 'stss' as const; box_name = 'SyncSampleBox'; - sample_numbers: Array; + sample_numbers: number[]; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/stsz.ts b/src/boxes/stsz.ts index 9a57ca70..ec95936d 100644 --- a/src/boxes/stsz.ts +++ b/src/boxes/stsz.ts @@ -5,7 +5,7 @@ export class stszBox extends FullBox { type = 'stsz' as const; box_name = 'SampleSizeBox'; - sample_sizes: Array; + sample_sizes: number[]; sample_size: number; sample_count: number; diff --git a/src/boxes/stts.ts b/src/boxes/stts.ts index ba6e4d28..5d819ba8 100644 --- a/src/boxes/stts.ts +++ b/src/boxes/stts.ts @@ -7,8 +7,8 @@ export class sttsBox extends FullBox { type = 'stts' as const; box_name = 'TimeToSampleBox'; - sample_counts: Array = []; - sample_deltas: Array = []; + sample_counts: number[] = []; + sample_deltas: number[] = []; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); @@ -45,7 +45,7 @@ export class sttsBox extends FullBox { } /** @bundle box-unpack.js */ - unpack(samples: Array) { + unpack(samples: Sample[]) { let k = 0; for (let i = 0; i < this.sample_counts.length; i++) { for (let j = 0; j < this.sample_counts[i]; j++) { diff --git a/src/boxes/styp.ts b/src/boxes/styp.ts index 6a7f2b82..6a6eae84 100644 --- a/src/boxes/styp.ts +++ b/src/boxes/styp.ts @@ -7,7 +7,7 @@ export class stypBox extends Box { major_brand: string; minor_version: number; - compatible_brands: Array; + compatible_brands: string[]; parse(stream: MultiBufferStream) { let toparse = this.size - this.hdr_size; diff --git a/src/boxes/stz2.ts b/src/boxes/stz2.ts index ba181b7e..32a55bb9 100644 --- a/src/boxes/stz2.ts +++ b/src/boxes/stz2.ts @@ -6,7 +6,7 @@ export class stz2Box extends FullBox { type = 'stz2' as const; box_name = 'CompactSampleSizeBox'; - sample_sizes: Array; + sample_sizes: number[]; reserved: number; field_size: number; diff --git a/src/boxes/subs.ts b/src/boxes/subs.ts index 035cba09..0cd20936 100644 --- a/src/boxes/subs.ts +++ b/src/boxes/subs.ts @@ -2,11 +2,11 @@ import { FullBox } from '#/box'; import type { MultiBufferStream } from '#/buffer'; import type { SubSample } from '@types'; -type SampleInfo = { +interface SampleInfo { size: number; sample_delta: number; subsamples: SubSample[]; -}; +} export class subsBox extends FullBox { type = 'subs' as const; diff --git a/src/boxes/tfra.ts b/src/boxes/tfra.ts index 7c964052..9f0ba147 100644 --- a/src/boxes/tfra.ts +++ b/src/boxes/tfra.ts @@ -10,7 +10,7 @@ export class tfraBox extends FullBox { length_size_of_traf_num: number; length_size_of_trun_num: number; length_size_of_sample_num: number; - entries: Array; + entries: SampleEntry[]; time: number; moof_offset: number; traf_number: number; diff --git a/src/boxes/tref.ts b/src/boxes/tref.ts index d294771f..785d1a3b 100644 --- a/src/boxes/tref.ts +++ b/src/boxes/tref.ts @@ -6,7 +6,7 @@ import { Log } from '#/log'; export class trefBox extends ContainerBox { type = 'tref' as const; - declare boxes: Array; + declare boxes: TrackReferenceTypeBox[]; parse(stream: MultiBufferStream) { while (stream.getPosition() < this.start + this.size) { diff --git a/src/boxes/trun.ts b/src/boxes/trun.ts index 00e4b038..826010ea 100644 --- a/src/boxes/trun.ts +++ b/src/boxes/trun.ts @@ -16,10 +16,10 @@ export class trunBox extends FullBox { sample_count: number; data_offset: number; first_sample_flags: number; - sample_duration: Array; - sample_size: Array; - sample_flags: Array; - sample_composition_time_offset: Array; + sample_duration: number[]; + sample_size: number[]; + sample_flags: number[]; + sample_composition_time_offset: number[]; data_offset_position: number; parse(stream: MultiBufferStream) { diff --git a/src/boxes/tsel.ts b/src/boxes/tsel.ts index 150d2c43..fa5c8900 100644 --- a/src/boxes/tsel.ts +++ b/src/boxes/tsel.ts @@ -6,7 +6,7 @@ export class tselBox extends FullBox { box_name = 'TrackSelectionBox'; switch_group: number; - attribute_list: Array; + attribute_list: number[]; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/tyco.ts b/src/boxes/tyco.ts index 268da053..9fab9824 100644 --- a/src/boxes/tyco.ts +++ b/src/boxes/tyco.ts @@ -5,7 +5,7 @@ export class tycoBox extends Box { type = 'tyco' as const; box_name = 'TypeCombinationBox'; - compatible_brands: Array; + compatible_brands: string[]; parse(stream: MultiBufferStream) { const count = (this.size - this.hdr_size) / 4; diff --git a/src/boxes/uncC.ts b/src/boxes/uncC.ts index 31dbdf79..09fe8449 100644 --- a/src/boxes/uncC.ts +++ b/src/boxes/uncC.ts @@ -7,10 +7,10 @@ export class uncCBox extends FullBox { profile: string; component_count: number; - component_index: Array; - component_bit_depth_minus_one: Array; - component_format: Array; - component_align_size: Array; + component_index: number[]; + component_bit_depth_minus_one: number[]; + component_format: number[]; + component_align_size: number[]; sampling_type: number; interleave_type: number; block_size: number; diff --git a/src/boxes/vmhd.ts b/src/boxes/vmhd.ts index cfa3002c..f15d43d8 100644 --- a/src/boxes/vmhd.ts +++ b/src/boxes/vmhd.ts @@ -20,7 +20,7 @@ export class vmhdBox extends FullBox { this.flags = 1; this.size = 8; this.writeHeader(stream); - stream.writeUint16(this.graphicsmode!); - stream.writeUint16Array(this.opcolor!); + stream.writeUint16(this.graphicsmode); + stream.writeUint16Array(this.opcolor); } } diff --git a/src/boxes/vvcC.ts b/src/boxes/vvcC.ts index 0cd530d5..f572623b 100644 --- a/src/boxes/vvcC.ts +++ b/src/boxes/vvcC.ts @@ -21,13 +21,13 @@ export class vvcCBox extends FullBox { ptl_multilayer_enabled_flag: number; general_constraint_info: Uint8Array; ptl_sublayer_present_mask: number; - sublayer_level_idc: Array; + sublayer_level_idc: number[]; ptl_num_sub_profiles: number; - general_sub_profile_idc: Array; + general_sub_profile_idc: number[]; max_picture_width: number; max_picture_height: number; avg_frame_rate: number; - nalu_arrays: Array; + nalu_arrays: NaluArray[]; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/buffer.ts b/src/buffer.ts index d336fe62..433637f1 100644 --- a/src/buffer.ts +++ b/src/buffer.ts @@ -27,7 +27,7 @@ function concatBuffers(buffer1: ArrayBuffer, buffer2: ArrayBuffer) { * It inherits also from DataStream for all read/write/alloc operations */ export class MultiBufferStream extends DataStream { - buffers: Array; + buffers: MP4BoxBuffer[]; bufferIndex: number; constructor(buffer?: MP4BoxBuffer) { @@ -94,7 +94,7 @@ export class MultiBufferStream extends DataStream { let i = 0; /* TODO: improve insertion if many buffers */ for (; i < this.buffers.length; i++) { - const b = this.buffers[i]!; + const b = this.buffers[i]; if (ab.fileStart <= b.fileStart) { /* the insertion position is found */ if (ab.fileStart === b.fileStart) { diff --git a/src/descriptor.ts b/src/descriptor.ts index 9cd95ef3..cc249b7c 100644 --- a/src/descriptor.ts +++ b/src/descriptor.ts @@ -190,8 +190,6 @@ const descTagToName = { }; export class MPEG4DescriptorParser { - constructor() {} - getDescriptorName(tag: number) { return descTagToName[tag]; } diff --git a/src/isofile.ts b/src/isofile.ts index 325f9656..a25ecf84 100644 --- a/src/isofile.ts +++ b/src/isofile.ts @@ -112,9 +112,9 @@ export class SampleGroupInfo { ) {} } -export type IsoFileOptions = { - brands?: Array; - description_boxes?: Array; +export interface IsoFileOptions { + brands?: string[]; + description_boxes?: BoxKind[]; duration?: number; height?: number; id?: number; @@ -141,17 +141,17 @@ export type IsoFileOptions = { default_sample_duration?: number; default_sample_size?: number; default_sample_flags?: number; -}; +} export class ISOFile { /** MutiBufferStream object used to parse boxes */ stream: MultiBufferStream; /** Array of all boxes (in order) found in the file */ - boxes: Array = []; + boxes: Box[] = []; /** Array of all mdats */ - mdats: Array = []; + mdats: mdatBox[] = []; /** Array of all moofs */ - moofs: Array = []; + moofs: moofBox[] = []; /** Boolean indicating if the file is compatible with progressive parsing (moov first) */ isProgressive = false; /** Boolean used to fire moov start event only once */ @@ -175,7 +175,7 @@ export class ISOFile { ) => void) | null = null; /** Callback to call when samples are ready */ - onSamples: ((id: number, user: TSampleUser, samples: Array) => void) | null = null; + onSamples: ((id: number, user: TSampleUser, samples: Sample[]) => void) | null = null; /** Callback to call when there is an error in the parsing or processing of samples */ onError: (() => void) | null = null; @@ -183,9 +183,9 @@ export class ISOFile { /** Boolean indicating if the moov box run-length encoded tables of sample information have been processed */ sampleListBuilt = false; /** Array of Track objects for which fragmentation of samples is requested */ - fragmentedTracks: Array> = []; + fragmentedTracks: FragmentedTrack[] = []; /** Array of Track objects for which extraction of samples is requested */ - extractedTracks: Array> = []; + extractedTracks: ExtractedTrack[] = []; /** Boolean indicating that fragmention is ready */ isFragmentationInitialized = false; /** Boolean indicating that fragmented has started */ @@ -200,10 +200,10 @@ export class ISOFile { sidxSent = false; /** @bundle isofile-item-processing.js */ - items: Array = []; + items: Item[] = []; /** @bundle isofile-item-processing.js */ - entity_groups: Array = []; + entity_groups: EntityGroup[] = []; /** * size of the buffers allocated for samples @@ -212,18 +212,18 @@ export class ISOFile { itemsDataSize = 0; moov: moovBox; - moovs: Array; + moovs: moovBox[]; sidx: sidxBox; - sidxs: Array; + sidxs: sidxBox[]; meta: metaBox; - metas: Array; + metas: metaBox[]; ftyp: ftypBox; - ftyps: Array; + ftyps: ftypBox[]; nextSeekPosition: number; initial_duration: number; static type: BoxKind['type']; - static boxes: Array; + static boxes: Box[]; constructor(stream?: MultiBufferStream) { this.stream = stream || new MultiBufferStream(); @@ -518,13 +518,13 @@ export class ISOFile { brands: [this.ftyp.major_brand].concat(this.ftyp.compatible_brands), created: new Date(_1904 + this.moov.mvhd.creation_time * 1000), modified: new Date(_1904 + this.moov.mvhd.modification_time * 1000), - tracks: [] as Array, - audioTracks: [] as Array, - videoTracks: [] as Array, - subtitleTracks: [] as Array, - metadataTracks: [] as Array, - hintTracks: [] as Array, - otherTracks: [] as Array, + tracks: [] as Track[], + audioTracks: [] as Track[], + videoTracks: [] as Track[], + subtitleTracks: [] as Track[], + metadataTracks: [] as Track[], + hintTracks: [] as Track[], + otherTracks: [] as Track[], mime: '', }; @@ -760,7 +760,7 @@ export class ISOFile { return result; } - static _sweep(type: BoxKind['type'], result: Array, returnEarly: boolean) { + static _sweep(type: BoxKind['type'], result: (typeof ISOFile)[], returnEarly: boolean) { if (this.type && this.type === type) { result.push(this); } @@ -835,7 +835,7 @@ export class ISOFile { seekTrack(time: number, useRap: boolean, trak: trakBox) { let rap_seek_sample_num = 0; let seek_sample_num = 0; - let timescale: number = null!; + let timescale: number; if (trak.samples.length === 0) { Log.info( @@ -945,7 +945,7 @@ export class ISOFile { } } - equal(b: { boxes: Array }) { + equal(b: { boxes: Box[] }) { let box_index = 0; while (box_index < this.boxes.length && box_index < b.boxes.length) { const a_box = this.boxes[box_index]; @@ -1067,7 +1067,7 @@ export class ISOFile { this.nextMoofNumber = 0; this.resetTables(); } - const initSegs: Array<{ id: number; user: TSegmentUser; buffer: MP4BoxBuffer }> = []; + const initSegs: { id: number; user: TSegmentUser; buffer: MP4BoxBuffer }[] = []; for (let i = 0; i < this.fragmentedTracks.length; i++) { const moov = new moovBox(); moov.mvhd = this.moov.mvhd; @@ -1141,9 +1141,9 @@ export class ISOFile { static initSampleGroups( trak: trakBox, traf: trafBox | null, - sbgps: Array, - trak_sgpds: Array, - traf_sgpds?: Array, + sbgps: sbgpBox[], + trak_sgpds: sgpdBox[], + traf_sgpds?: sgpdBox[], ) { if (traf) { traf.sample_groups_info = []; @@ -1211,7 +1211,7 @@ export class ISOFile { trak: trakBox, sample: Sample, sample_number: number, - sample_groups_info: Array, + sample_groups_info: SampleGroupInfo[], ) { sample.sample_groups = []; for (const k in sample_groups_info) { diff --git a/src/log.ts b/src/log.ts index ef72ab9a..7e8f6aa7 100644 --- a/src/log.ts +++ b/src/log.ts @@ -11,8 +11,8 @@ const LOG_LEVEL_DEBUG = 1; let log_level = LOG_LEVEL_ERROR; -export class Log { - static setLogLevel(level: { (module: string, msg?: string): void }) { +export const Log = { + setLogLevel(level: (module: string, msg?: string) => void) { if (level === this.debug) { log_level = LOG_LEVEL_DEBUG; } else if (level === this.info) { @@ -24,8 +24,8 @@ export class Log { } else { log_level = LOG_LEVEL_ERROR; } - } - static debug(module: string, msg?: string) { + }, + debug(module: string, msg?: string) { if (console.debug === undefined) { console.debug = console.log; } @@ -36,11 +36,11 @@ export class Log { msg, ); } - } - static log(module: { msg: string }, _msg?: string) { + }, + log(module: { msg: string }, _msg?: string) { this.debug(module.msg); - } - static info(module: string, msg?: string) { + }, + info(module: string, msg?: string) { if (LOG_LEVEL_INFO >= log_level) { console.info( '[' + Log.getDurationString(new Date().getTime() - start.getTime(), 1000) + ']', @@ -48,8 +48,8 @@ export class Log { msg, ); } - } - static warn(module: string, msg?: string) { + }, + warn(module: string, msg?: string) { if (LOG_LEVEL_WARNING >= log_level) { console.warn( '[' + Log.getDurationString(new Date().getTime() - start.getTime(), 1000) + ']', @@ -57,8 +57,8 @@ export class Log { msg, ); } - } - static error(module: string, msg?: string) { + }, + error(module: string, msg?: string) { if (LOG_LEVEL_ERROR >= log_level) { console.error( '[' + Log.getDurationString(new Date().getTime() - start.getTime(), 1000) + ']', @@ -66,9 +66,9 @@ export class Log { msg, ); } - } + }, /* Helper function to print a duration value in the form H:MM:SS.MS */ - static getDurationString(duration: number, _timescale?: number) { + getDurationString(duration: number, _timescale?: number) { let neg: boolean; /* Helper function to print a number on a fixed number of digits */ function pad(number: string | number, length: number) { @@ -105,9 +105,9 @@ export class Log { '.' + pad(msec, 3) ); - } + }, /* Helper function to stringify HTML5 TimeRanges objects */ - static printRanges(ranges: { + printRanges(ranges: { length: number; start: (index: number) => number; end: (index: number) => number; @@ -130,5 +130,5 @@ export class Log { } else { return '(empty)'; } - } -} + }, +}; diff --git a/src/text-mp4.ts b/src/text-mp4.ts index c7f8759f..16e2a183 100644 --- a/src/text-mp4.ts +++ b/src/text-mp4.ts @@ -39,8 +39,7 @@ export class VTTin4Parser { } const cues = this.parseSample(data); let string = ''; - for (let i = 0; i < cues.length; i++) { - const cueIn4 = cues[i]; + for (const cueIn4 of cues) { string += secToTimestamp(startTime) + ' --> ' + secToTimestamp(endTime) + '\r\n'; // @ts-expect-error FIXME: which box should get a payl-property? string += cueIn4.payl.text; @@ -52,7 +51,7 @@ export class VTTin4Parser { export class XMLSubtitlein4Parser { parseSample(sample: Sample) { const res = { - resources: [] as Array, + resources: [] as Uint8Array[], documentString: '', document: undefined as undefined | Document, }; diff --git a/tsup.config.ts b/tsup.config.ts index f6313419..548f6df6 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -30,7 +30,7 @@ const regularBuild = defineConfig({ dts: true, }); -let build: Array = []; +const build: (typeof iifeBuild | typeof regularBuild)[] = []; if (PUBLISH_TO_NPM) { build.push(regularBuild); } else { From 6594af8c6389614bb2fd2a398a25f44cd4a53324 Mon Sep 17 00:00:00 2001 From: Erwan Vivien Date: Mon, 26 May 2025 22:38:22 +0200 Subject: [PATCH 11/16] chore: add Prettier ESLint plugin --- entries/types.ts | 32 +++++----- eslint.config.js | 2 + package-lock.json | 115 ++++++++++++++++++++++++++++++++++++ package.json | 5 +- src/box-diff.ts | 6 +- src/box.ts | 12 +++- src/boxes/cslg.ts | 12 ++-- src/boxes/displays/pixel.ts | 5 +- src/boxes/dref.ts | 2 +- src/descriptor.ts | 5 +- 10 files changed, 165 insertions(+), 31 deletions(-) diff --git a/entries/types.ts b/entries/types.ts index 2d450dd1..cc68304b 100644 --- a/entries/types.ts +++ b/entries/types.ts @@ -348,22 +348,22 @@ export type StructDefinition = [name: string, type: Type][]; export type ValueFromType = TValue extends StringType ? string : TValue extends NumberType - ? number - : TValue extends FnType - ? ReturnType - : TValue extends GetterSetterType - ? ReturnType - : TValue extends ['[]', NumberType, infer TAmount] - ? TAmount extends number - ? TupleOf - : TAmount extends () => infer TReturnType - ? TReturnType extends number - ? TupleOf - : never - : number[] - : TValue extends StructDefinition - ? StructDataFromStructDefinition - : never; + ? number + : TValue extends FnType + ? ReturnType + : TValue extends GetterSetterType + ? ReturnType + : TValue extends ['[]', NumberType, infer TAmount] + ? TAmount extends number + ? TupleOf + : TAmount extends () => infer TReturnType + ? TReturnType extends number + ? TupleOf + : never + : number[] + : TValue extends StructDefinition + ? StructDataFromStructDefinition + : never; export type StructDataFromStructDefinition = { [TKey in T[number][0]]: Extract[1] extends infer TValue diff --git a/eslint.config.js b/eslint.config.js index e930ef43..1cca32b3 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,5 +1,6 @@ import eslint from '@eslint/js'; import tseslint from 'typescript-eslint'; +import eslintPlugin from 'eslint-plugin-prettier/recommended'; export default tseslint.config( { ignores: ['dist', '**/*.js'] }, @@ -20,4 +21,5 @@ export default tseslint.config( '@typescript-eslint/prefer-for-of': 'off', }, }, + eslintPlugin, ); diff --git a/package-lock.json b/package-lock.json index 14019095..d51537f6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,8 +16,11 @@ "@types/node": "^22.15.21", "dpdm": "^3.14.0", "eslint": "^9.27.0", + "eslint-config-prettier": "^10.1.5", + "eslint-plugin-prettier": "^5.4.0", "globals": "^16.2.0", "husky": "^9.1.7", + "prettier": "^3.5.3", "tsup": "^8.3.5", "typescript": "^5.6.3", "typescript-eslint": "^8.32.1" @@ -1274,6 +1277,19 @@ "node": ">=14" } }, + "node_modules/@pkgr/core": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.2.4.tgz", + "integrity": "sha512-ROFF39F6ZrnzSUEmQQZUar0Jt4xVoP9WnDRdWwF4NNcXs3xBTLgBUDoOwW141y1jP+S8nahIbdxbFC7IShw9Iw==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.20.0 || ^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/pkgr" + } + }, "node_modules/@rollup/rollup-android-arm-eabi": { "version": "4.41.1", "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.41.1.tgz", @@ -2603,6 +2619,53 @@ } } }, + "node_modules/eslint-config-prettier": { + "version": "10.1.5", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-10.1.5.tgz", + "integrity": "sha512-zc1UmCpNltmVY34vuLRV61r1K27sWuX39E+uyUnY8xS2Bex88VV9cugG+UZbRSRGtGyFboj+D8JODyme1plMpw==", + "dev": true, + "license": "MIT", + "bin": { + "eslint-config-prettier": "bin/cli.js" + }, + "funding": { + "url": "https://opencollective.com/eslint-config-prettier" + }, + "peerDependencies": { + "eslint": ">=7.0.0" + } + }, + "node_modules/eslint-plugin-prettier": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.4.0.tgz", + "integrity": "sha512-BvQOvUhkVQM1i63iMETK9Hjud9QhqBnbtT1Zc642p9ynzBuCe5pybkOnvqZIBypXmMlsGcnU4HZ8sCTPfpAexA==", + "dev": true, + "license": "MIT", + "dependencies": { + "prettier-linter-helpers": "^1.0.0", + "synckit": "^0.11.0" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint-plugin-prettier" + }, + "peerDependencies": { + "@types/eslint": ">=8.0.0", + "eslint": ">=8.0.0", + "eslint-config-prettier": ">= 7.0.0 <10.0.0 || >=10.1.0", + "prettier": ">=3.0.0" + }, + "peerDependenciesMeta": { + "@types/eslint": { + "optional": true + }, + "eslint-config-prettier": { + "optional": true + } + } + }, "node_modules/eslint-scope": { "version": "8.3.0", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.3.0.tgz", @@ -2843,6 +2906,13 @@ "dev": true, "license": "MIT" }, + "node_modules/fast-diff": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz", + "integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==", + "dev": true, + "license": "Apache-2.0" + }, "node_modules/fast-glob": { "version": "3.3.3", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.3.tgz", @@ -4032,6 +4102,35 @@ "node": ">= 0.8.0" } }, + "node_modules/prettier": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.5.3.tgz", + "integrity": "sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw==", + "dev": true, + "license": "MIT", + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/prettier-linter-helpers": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", + "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-diff": "^1.1.2" + }, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", @@ -4395,6 +4494,22 @@ "node": ">=8" } }, + "node_modules/synckit": { + "version": "0.11.6", + "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.11.6.tgz", + "integrity": "sha512-2pR2ubZSV64f/vqm9eLPz/KOvR9Dm+Co/5ChLgeHl0yEDRc6h5hXHoxEQH8Y5Ljycozd3p1k5TTSVdzYGkPvLw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@pkgr/core": "^0.2.4" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/synckit" + } + }, "node_modules/text-extensions": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/text-extensions/-/text-extensions-2.4.0.tgz", diff --git a/package.json b/package.json index c43228fb..fbdb2837 100644 --- a/package.json +++ b/package.json @@ -65,11 +65,14 @@ "@types/node": "^22.15.21", "dpdm": "^3.14.0", "eslint": "^9.27.0", + "eslint-config-prettier": "^10.1.5", + "eslint-plugin-prettier": "^5.4.0", "globals": "^16.2.0", "husky": "^9.1.7", + "prettier": "^3.5.3", "tsup": "^8.3.5", "typescript": "^5.6.3", "typescript-eslint": "^8.32.1" }, "packageManager": "npm@11.4.1" -} \ No newline at end of file +} diff --git a/src/box-diff.ts b/src/box-diff.ts index d54abe13..8ce4feb3 100644 --- a/src/box-diff.ts +++ b/src/box-diff.ts @@ -50,10 +50,8 @@ export function boxEqualFields(box_a: Box, box_b: Box) { } else if (typeof box_a[prop] === 'function' || typeof box_b[prop] === 'function') { continue; } else if ( - ('subBoxNames' in box_a && - (box_a.subBoxNames as string[]).indexOf(prop.slice(0, 4)) > -1) || - ('subBoxNames' in box_b && - (box_b.subBoxNames as string[]).indexOf(prop.slice(0, 4)) > -1) + ('subBoxNames' in box_a && (box_a.subBoxNames as string[]).indexOf(prop.slice(0, 4)) > -1) || + ('subBoxNames' in box_b && (box_b.subBoxNames as string[]).indexOf(prop.slice(0, 4)) > -1) ) { continue; } else { diff --git a/src/box.ts b/src/box.ts index a3705c6f..45f46227 100644 --- a/src/box.ts +++ b/src/box.ts @@ -292,7 +292,10 @@ export class SampleGroupEntry { export class TrackGroupTypeBox extends FullBox { track_group_id: number; - constructor(public type: string, size: number) { + constructor( + public type: string, + size: number, + ) { super(size); } @@ -357,7 +360,12 @@ export class SingleItemTypeReferenceBoxLarge extends Box { /** @bundle parsing/TrakReference.js */ export class TrackReferenceTypeBox extends Box { - constructor(public type: string, size: number, public hdr_size: number, public start: number) { + constructor( + public type: string, + size: number, + public hdr_size: number, + public start: number, + ) { super(size); } diff --git a/src/boxes/cslg.ts b/src/boxes/cslg.ts index d04eae20..41f4d0cc 100644 --- a/src/boxes/cslg.ts +++ b/src/boxes/cslg.ts @@ -33,11 +33,13 @@ export class cslgBox extends FullBox { /** @bundle writing/cslg.js */ write(stream: MultiBufferStream) { this.version = 0; - if ((this.compositionToDTSShift > INT32_MAX) || - (this.leastDecodeToDisplayDelta > INT32_MAX) || - (this.greatestDecodeToDisplayDelta > INT32_MAX) || - (this.compositionStartTime > INT32_MAX) || - (this.compositionEndTime > INT32_MAX)) { + if ( + this.compositionToDTSShift > INT32_MAX || + this.leastDecodeToDisplayDelta > INT32_MAX || + this.greatestDecodeToDisplayDelta > INT32_MAX || + this.compositionStartTime > INT32_MAX || + this.compositionEndTime > INT32_MAX + ) { this.version = 1; } this.flags = 0; diff --git a/src/boxes/displays/pixel.ts b/src/boxes/displays/pixel.ts index 8d17a95a..f564b13f 100644 --- a/src/boxes/displays/pixel.ts +++ b/src/boxes/displays/pixel.ts @@ -1,5 +1,8 @@ export class Pixel { - constructor(public bad_pixel_row: number, public bad_pixel_column: number) {} + constructor( + public bad_pixel_row: number, + public bad_pixel_column: number, + ) {} toString() { return '[row: ' + this.bad_pixel_row + ', column: ' + this.bad_pixel_column + ']'; } diff --git a/src/boxes/dref.ts b/src/boxes/dref.ts index a5bef0ce..13e1ea07 100644 --- a/src/boxes/dref.ts +++ b/src/boxes/dref.ts @@ -1,4 +1,4 @@ -import type { Box} from '#/box'; +import type { Box } from '#/box'; import { FullBox, parseOneBox } from '#/box'; import type { MultiBufferStream } from '#/buffer'; import { OK } from '#/constants'; diff --git a/src/descriptor.ts b/src/descriptor.ts index cc249b7c..f7527c67 100644 --- a/src/descriptor.ts +++ b/src/descriptor.ts @@ -16,7 +16,10 @@ export class Descriptor { descs = []; data: Uint8Array; - constructor(public tag: number, public size: number) {} + constructor( + public tag: number, + public size: number, + ) {} parse(stream: DataStream) { this.data = stream.readUint8Array(this.size); From d43d781fd3e7c2940cad5aec8ada4c8f03a7349d Mon Sep 17 00:00:00 2001 From: DenizUgur Date: Mon, 26 May 2025 16:38:43 -0700 Subject: [PATCH 12/16] fix: minor fixes --- .husky/install.mjs | 2 -- .vscode/settings.json | 7 +++++++ entries/types.ts | 14 ++++---------- eslint.config.js | 2 +- src/registry.ts | 2 +- 5 files changed, 13 insertions(+), 14 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.husky/install.mjs b/.husky/install.mjs index 897e473e..95b1d382 100644 --- a/.husky/install.mjs +++ b/.husky/install.mjs @@ -1,5 +1,3 @@ -/* eslint-disable no-undef */ - // Skip Husky install in production and CI if (process.env.NODE_ENV === 'production' || process.env.CI === 'true') { process.exit(0); diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..4c2e136e --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "eslint.useFlatConfig": true, + "eslint.workingDirectories": [{ "mode": "auto" }], + "eslint.options": { + "overrideConfigFile": "./eslint.config.js" + } +} diff --git a/entries/types.ts b/entries/types.ts index cc68304b..f9e1ef57 100644 --- a/entries/types.ts +++ b/entries/types.ts @@ -8,13 +8,8 @@ import type * as BOXES from './all-boxes'; type AllBoxes = Partial & Partial; -// Unsure of the implications of changing this namespace export -// Prefer to keep it as is for compatibility -// eslint-disable-next-line @typescript-eslint/no-namespace -export namespace MP4Box { - export type BoxRegistry = AllBoxes; - export type DescriptorRegistry = Partial; -} +export type BoxRegistry = AllBoxes; +export type DescriptorRegistry = Partial; export type TypedArray = | Int8Array @@ -41,8 +36,8 @@ export type TupleOf = R['length'] exten : TupleOf; export type NumberTuple = TupleOf; -export type BoxKind = InstanceOf>; -export type SampleEntryKind = InstanceOf>; +export type BoxKind = InstanceOf>; +export type SampleEntryKind = InstanceOf>; export interface FragmentedTrack { id: number; @@ -305,7 +300,6 @@ export type StringType = | EncodedLengthStringType | EndianStringType; -// Unsure why changing `any` to `unknown` causes issues in some places. // eslint-disable-next-line @typescript-eslint/no-explicit-any export interface GetterSetterType { get(dataStream: DataStream, struct: Record): T; diff --git a/eslint.config.js b/eslint.config.js index 1cca32b3..fc045cd4 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -3,7 +3,7 @@ import tseslint from 'typescript-eslint'; import eslintPlugin from 'eslint-plugin-prettier/recommended'; export default tseslint.config( - { ignores: ['dist', '**/*.js'] }, + { ignores: ['dist', '**/*.{mjs,js}'] }, eslint.configs.recommended, tseslint.configs.strict, diff --git a/src/registry.ts b/src/registry.ts index 8a17a43c..9ca976b7 100644 --- a/src/registry.ts +++ b/src/registry.ts @@ -1,4 +1,4 @@ -import type { MP4Box } from '@types'; +import type * as MP4Box from '@types'; export const BoxRegistry = {} as MP4Box.BoxRegistry; export function registerBoxes(registry: T) { From 1fab8a7229e5a2d32f7df911d792eddc0e84848e Mon Sep 17 00:00:00 2001 From: DenizUgur Date: Mon, 26 May 2025 17:08:45 -0700 Subject: [PATCH 13/16] chore: try to minimize the diff --- entries/types.ts | 54 ++++---- eslint.config.js | 8 ++ src/DataStream.ts | 61 ++++----- src/audio.ts | 2 +- src/box-diff.ts | 16 +-- src/box.ts | 18 ++- src/boxes/EntityToGroup/base.ts | 2 +- src/boxes/EntityToGroup/index.ts | 6 +- src/boxes/a1lx.ts | 2 +- src/boxes/avcC.ts | 4 +- src/boxes/cdef.ts | 6 +- src/boxes/cmpd.ts | 4 +- src/boxes/co64.ts | 2 +- src/boxes/ctts.ts | 6 +- src/boxes/dOps.ts | 2 +- src/boxes/dec3.ts | 2 +- src/boxes/defaults.ts | 114 ++++++++-------- src/boxes/dfLa.ts | 18 +-- src/boxes/displays/naluArrays.ts | 4 +- src/boxes/dref.ts | 5 +- src/boxes/elst.ts | 2 +- src/boxes/ftyp.ts | 2 +- src/boxes/hvcC.ts | 4 +- src/boxes/iinf.ts | 4 +- src/boxes/iloc.ts | 20 +-- src/boxes/ipma.ts | 4 +- src/boxes/iref.ts | 2 +- src/boxes/leva.ts | 2 +- src/boxes/mdcv.ts | 2 +- src/boxes/meta.ts | 32 ++--- src/boxes/padb.ts | 2 +- src/boxes/pdin.ts | 4 +- src/boxes/pixi.ts | 2 +- src/boxes/prdi.ts | 2 +- src/boxes/pssh.ts | 2 +- src/boxes/qt/tapt.ts | 12 +- src/boxes/saio.ts | 2 +- src/boxes/saiz.ts | 2 +- src/boxes/sampleentries/base.ts | 4 +- src/boxes/sampleentries/sampleentry.ts | 39 +++--- src/boxes/samplegroups/alst.ts | 6 +- src/boxes/samplegroups/avss.ts | 4 +- src/boxes/samplegroups/rash.ts | 4 +- src/boxes/sbgp.ts | 2 +- src/boxes/sbpm.ts | 8 +- src/boxes/sdtp.ts | 8 +- src/boxes/sgpd.ts | 2 +- src/boxes/sidx.ts | 2 +- src/boxes/ssix.ts | 4 +- src/boxes/stco.ts | 4 +- src/boxes/stdp.ts | 2 +- src/boxes/stri.ts | 2 +- src/boxes/stsc.ts | 8 +- src/boxes/stsd.ts | 2 +- src/boxes/stsg.ts | 2 +- src/boxes/stsh.ts | 4 +- src/boxes/stss.ts | 2 +- src/boxes/stsz.ts | 2 +- src/boxes/stts.ts | 6 +- src/boxes/styp.ts | 2 +- src/boxes/stz2.ts | 2 +- src/boxes/subs.ts | 4 +- src/boxes/tfra.ts | 2 +- src/boxes/tref.ts | 2 +- src/boxes/trun.ts | 8 +- src/boxes/tsel.ts | 2 +- src/boxes/tyco.ts | 2 +- src/boxes/uncC.ts | 8 +- src/boxes/uuid/index.ts | 2 +- src/boxes/vvcC.ts | 6 +- src/buffer.ts | 27 ++-- src/create-file.ts | 2 +- src/descriptor.ts | 8 +- src/isofile.ts | 180 ++++++++++--------------- src/log.ts | 22 +-- src/stream.ts | 12 +- src/text-mp4.ts | 18 +-- tsup.config.ts | 2 +- 78 files changed, 404 insertions(+), 462 deletions(-) diff --git a/entries/types.ts b/entries/types.ts index f9e1ef57..98c7f212 100644 --- a/entries/types.ts +++ b/entries/types.ts @@ -25,13 +25,13 @@ export type TypedArray = | BigUint64Array; export type ValueOf = T[keyof T]; -export type InstanceOf = T extends new (...args: unknown[]) => infer R ? R : never; +export type InstanceOf = T extends new (...args: Array) => infer R ? R : never; export type KindOf = InstanceOf>; export type Extends = { [TKey in keyof TObject]: TObject[TKey] extends TExtends ? TObject[TKey] : undefined; }[keyof TObject]; -export type TupleOf = R['length'] extends N +export type TupleOf = []> = R['length'] extends N ? R : TupleOf; export type NumberTuple = TupleOf; @@ -52,7 +52,7 @@ export interface ExtractedTrack { user: TUser; trak: trakBox; nb_samples: number; - samples: Sample[]; + samples: Array; } export interface Sample { @@ -76,9 +76,9 @@ export interface Sample { number: number; offset: number; pts?: number; - sample_groups?: SampleGroup[]; + sample_groups?: Array; size: number; - subsamples?: SubSample[]; + subsamples?: Array; timescale: number; track_id: number; } @@ -98,7 +98,7 @@ export interface Track { created: Date; cts_shift: BOXES.cslgBox; duration: number; - edits?: Entry[]; + edits?: Array; id: number; kind: BOXES.kindBox | { schemeURI: ''; value: '' }; language: string; @@ -109,9 +109,9 @@ export interface Track { movie_timescale: number; name: string; nb_samples: number; - references: { track_ids: ArrayLike; type: string }[]; + references: Array<{ track_ids: ArrayLike; type: string }>; samples_duration: number; - samples?: Sample[]; + samples?: Array; size: number; timescale: number; track_height: number; @@ -123,28 +123,28 @@ export interface Track { export interface Movie { hasMoov: boolean; - audioTracks: Track[]; - brands: string[]; + audioTracks: Array; + brands: Array; created: Date; duration: number; fragment_duration: number | undefined; hasIOD: boolean; - hintTracks: Track[]; + hintTracks: Array; isFragmented: boolean; isProgressive: boolean; - metadataTracks: Track[]; + metadataTracks: Array; mime: string; modified: Date; - otherTracks: Track[]; - subtitleTracks: Track[]; + otherTracks: Array; + subtitleTracks: Array; timescale: number; - tracks: Track[]; - videoTracks: Track[]; + tracks: Array; + videoTracks: Array; } export interface Description { default_group_description_index: number; - entries: (SampleGroupEntry | SampleEntry)[]; + entries: Array; used: boolean; version: number; } @@ -164,20 +164,20 @@ export interface Item { content_type?: string; item_uri_type: string; data?: Uint8Array; - extents?: { + extents?: Array<{ alreadyRead?: number; length: number; offset: number; - }[]; + }>; id?: number; name?: string; primary?: boolean; - properties?: { boxes: Box[] }; + properties?: { boxes: Array }; protection?: BOXES.sinfBox; - ref_to?: { + ref_to?: Array<{ type: string; id: Reference; - }[]; + }>; sent?: boolean; size?: number; source?: Box; @@ -186,10 +186,10 @@ export interface Item { export interface EntityGroup { id: number; - entity_ids: number[]; + entity_ids: Array; type: string; properties?: { - boxes: Box[]; + boxes: Array; }; } @@ -210,7 +210,7 @@ export interface Nalu { length?: number; } -export type NaluArray = Nalu[] & { +export type NaluArray = Array & { completeness: number; nalu_type: number; length: number; @@ -337,7 +337,7 @@ export type ParsedType = | SimpleNumberType | EndianNumberType; -export type StructDefinition = [name: string, type: Type][]; +export type StructDefinition = Array<[name: string, type: Type]>; export type ValueFromType = TValue extends StringType ? string @@ -354,7 +354,7 @@ export type ValueFromType = TValue extends StringType ? TReturnType extends number ? TupleOf : never - : number[] + : Array : TValue extends StructDefinition ? StructDataFromStructDefinition : never; diff --git a/eslint.config.js b/eslint.config.js index fc045cd4..4e38cdba 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -19,6 +19,14 @@ export default tseslint.config( 'no-unused-vars': 'off', // Disable @typescript-eslint/prefer-for-of we have too much for now '@typescript-eslint/prefer-for-of': 'off', + // Prefer to use Array over T[] + '@typescript-eslint/array-type': ['error', { default: 'generic' }], + // Use interfaces for object type definitions + '@typescript-eslint/consistent-type-definitions': ['error', 'interface'], + // Don't require curly braces for simple if statements + curly: ['error', 'multi-line'], + // Enforce strict equality checks + eqeqeq: 'error', }, }, eslintPlugin, diff --git a/src/DataStream.ts b/src/DataStream.ts index ed404eea..19ffc4ed 100644 --- a/src/DataStream.ts +++ b/src/DataStream.ts @@ -23,7 +23,7 @@ type ReadTypeReturnValue = | Float32Array | Float64Array | null - | ReadTypeReturnValue[] + | Array | { [key: string]: ReadTypeReturnValue; }; @@ -32,7 +32,7 @@ type ReadTypeReturnValue = // TODO: check range/support for 64-bits numbers in JavaScript export class DataStream { - static DataStream: Record; // for backward compatibility + static DataStream: DataStream; _buffer?: MP4BoxBuffer; _byteOffset?: number; @@ -59,9 +59,7 @@ export class DataStream { this.buffer = arrayBuffer; } else if (arrayBuffer instanceof DataView) { this.dataView = arrayBuffer; - if (byteOffset) { - this._byteOffset += byteOffset; - } + if (byteOffset) this._byteOffset += byteOffset; } else { this.buffer = new MP4BoxBuffer(arrayBuffer || 0); } @@ -226,9 +224,9 @@ export class DataStream { * @return Uint8Array to the DataStream backing buffer. */ mapUint8Array(length: number) { - this._realloc(length); + this._realloc(length * 1); const arr = new Uint8Array(this._buffer, this.byteOffset + this.position, length); - this.position += length; + this.position += length * 1; return arr; } @@ -638,9 +636,7 @@ export class DataStream { if (length !== null) { len = Math.min(length, blen); } - for (; i < len && u8[i] !== 0; i++) { - // find first zero byte - } + for (; i < len && u8[i] !== 0; i++); // find first zero byte const s = fromCharCodeUint8(this.mapUint8Array(i)); if (length !== null) { this.position += len - i; @@ -683,7 +679,7 @@ export class DataStream { a.click(); window.URL.revokeObjectURL(url); } else { - throw new Error("DataStream.save: Can't create object URL."); + throw "DataStream.save: Can't create object URL."; } } @@ -789,7 +785,7 @@ export class DataStream { * @bundle DataStream-write.js */ writeInt8Array(array: ArrayLike) { - this._realloc(array.length); + this._realloc(array.length * 1); if ( array instanceof Int8Array && this.byteOffset + (this.position % array.BYTES_PER_ELEMENT) === 0 @@ -872,7 +868,7 @@ export class DataStream { * @bundle DataStream-write.js */ writeUint8Array(array: ArrayLike) { - this._realloc(array.length); + this._realloc(array.length * 1); if ( array instanceof Uint8Array && this.byteOffset + (this.position % array.BYTES_PER_ELEMENT) === 0 @@ -1574,20 +1570,17 @@ export class DataStream { default: if (this.#isTupleType(parsedType)) { const [, ta, len] = parsedType; - let length: number | null = null; - if (typeof len === 'function') { - length = len(struct, this, parsedType); - } else if (typeof len === 'string' && struct[len] !== null) { - // @ts-expect-error FIXME: Struct[string] is currently of type Type - length = parseInt(struct[len]); - } else if (typeof len === 'number') { - length = len; - } else if (len === '*') { - length = null; - } else { - length = parseInt(len); - } - + const length = + typeof len === 'function' + ? len(struct, this, parsedType) + : typeof len === 'string' && struct[len] !== null + ? // @ts-expect-error FIXME: Struct[string] is currently of type Type + parseInt(struct[len]) + : typeof len === 'number' + ? len + : len === '*' + ? null + : parseInt(len); if (typeof ta === 'string') { const tap = ta.replace(/(le|be)$/, ''); let endianness: null | boolean = null; @@ -1628,9 +1621,7 @@ export class DataStream { value = []; while (!this.isEof()) { const u = this.readType(ta, struct); - if (u === null) { - break; - } + if (u === null) break; value.push(u); } } else { @@ -1662,9 +1653,7 @@ export class DataStream { value = new Array(length); for (let i = 0; i < length; i++) { const type = this.readType(ta, struct); - if (type === null) { - return null; - } + if (type === null) return null; value[i] = type; } } @@ -1732,9 +1721,9 @@ export class DataStream { * @bundle DataStream-map.js */ mapInt8Array(length: number, _endianness?: boolean) { - this._realloc(length); + this._realloc(length * 1); const arr = new Int8Array(this._buffer, this.byteOffset + this.position, length); - this.position += length; + this.position += length * 1; return arr; } @@ -1824,7 +1813,7 @@ export class DataStream { } function fromCharCodeUint8(uint8arr: Uint8Array) { - const arr: number[] = []; + const arr: Array = []; for (let i = 0; i < uint8arr.length; i++) { arr[i] = uint8arr[i]; } diff --git a/src/audio.ts b/src/audio.ts index ff9dabdd..d04692b2 100644 --- a/src/audio.ts +++ b/src/audio.ts @@ -1,4 +1,4 @@ -import type { MP4BoxStream } from '#/stream'; +import { MP4BoxStream } from '#/stream'; export class AudioSpecificConfig { samplingFrequencyIndex?: number; diff --git a/src/box-diff.ts b/src/box-diff.ts index 8ce4feb3..950800ac 100644 --- a/src/box-diff.ts +++ b/src/box-diff.ts @@ -34,15 +34,11 @@ export const DIFF_PRIMITIVE_ARRAY_PROP_NAMES = [ /** @bundle box-diff.js */ export function boxEqualFields(box_a: Box, box_b: Box) { - if (box_a && !box_b) { - return false; - } + if (box_a && !box_b) return false; let prop: string; for (prop in box_a) { - if ((DIFF_BOXES_PROP_NAMES as readonly string[]).indexOf(prop) > -1) { + if (DIFF_BOXES_PROP_NAMES.find(name => name === prop)) { continue; - // } else if (excluded_fields && excluded_fields.indexOf(prop) > -1) { - // continue; } else if (box_a[prop] instanceof Box || box_b[prop] instanceof Box) { continue; } else if (typeof box_a[prop] === 'undefined' || typeof box_b[prop] === 'undefined') { @@ -50,8 +46,10 @@ export function boxEqualFields(box_a: Box, box_b: Box) { } else if (typeof box_a[prop] === 'function' || typeof box_b[prop] === 'function') { continue; } else if ( - ('subBoxNames' in box_a && (box_a.subBoxNames as string[]).indexOf(prop.slice(0, 4)) > -1) || - ('subBoxNames' in box_b && (box_b.subBoxNames as string[]).indexOf(prop.slice(0, 4)) > -1) + ('subBoxNames' in box_a && + (box_a.subBoxNames as Array).indexOf(prop.slice(0, 4)) > -1) || + ('subBoxNames' in box_b && + (box_b.subBoxNames as Array).indexOf(prop.slice(0, 4)) > -1) ) { continue; } else { @@ -63,7 +61,7 @@ export function boxEqualFields(box_a: Box, box_b: Box) { prop === 'modification_time' ) { continue; - } else if ((DIFF_PRIMITIVE_ARRAY_PROP_NAMES as readonly string[]).indexOf(prop) > -1) { + } else if (DIFF_PRIMITIVE_ARRAY_PROP_NAMES.find(name => name === prop)) { continue; } else { if (box_a[prop] !== box_b[prop]) { diff --git a/src/box.ts b/src/box.ts index 45f46227..21c15685 100644 --- a/src/box.ts +++ b/src/box.ts @@ -5,15 +5,15 @@ import { MultiBufferStream } from '#/buffer'; import { ERR_NOT_ENOUGH_DATA, MAX_SIZE, OK } from '#/constants'; -import type { DataStream } from '#/DataStream'; +import { DataStream } from '#/DataStream'; import { Log } from '#/log'; import { BoxRegistry } from '#/registry'; -import type { MP4BoxStream } from '#/stream'; +import { MP4BoxStream } from '#/stream'; import type { BoxKind, Extends, Output, Reference } from '@types'; export class Box { - boxes?: Box[]; - data: number[] | Uint8Array; + boxes?: Array; + data: Array | Uint8Array; has_unparsed_data?: boolean; hdr_size?: number; language: number; @@ -209,7 +209,7 @@ export class FullBox extends Box { } export class ContainerBox extends Box { - subBoxNames?: readonly string[]; + subBoxNames?: ReadonlyArray; /** @bundle box-write.js */ write(stream: MultiBufferStream) { @@ -309,7 +309,7 @@ export class TrackGroupTypeBox extends FullBox { /** @bundle parsing/singleitemtypereference.js */ export class SingleItemTypeReferenceBox extends Box { from_item_ID: number; - references: Reference[]; + references: Array; constructor( public type: string, @@ -335,7 +335,7 @@ export class SingleItemTypeReferenceBox extends Box { /** @bundle parsing/singleitemtypereferencelarge.js */ export class SingleItemTypeReferenceBoxLarge extends Box { from_item_ID: number; - references: Reference[]; + references: Array; constructor( public type: string, @@ -563,9 +563,7 @@ export function parseOneBox( diff + ' more bytes than the indicated box data size, seeking backwards', ); - if (box.size !== 0) { - stream.seek(box.start + box.size); - } + if (box.size !== 0) stream.seek(box.start + box.size); } return { code: OK, box, size: box.size }; } diff --git a/src/boxes/EntityToGroup/base.ts b/src/boxes/EntityToGroup/base.ts index 10d4e582..4ad244f9 100644 --- a/src/boxes/EntityToGroup/base.ts +++ b/src/boxes/EntityToGroup/base.ts @@ -5,7 +5,7 @@ import type { MultiBufferStream } from '#/buffer'; export class EntityToGroup extends FullBox { group_id: number; num_entities_in_group: number; - entity_ids: number[]; + entity_ids: Array; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/EntityToGroup/index.ts b/src/boxes/EntityToGroup/index.ts index 860aef91..1ee05c38 100644 --- a/src/boxes/EntityToGroup/index.ts +++ b/src/boxes/EntityToGroup/index.ts @@ -101,9 +101,9 @@ export class prgrBox extends EntityToGroup { export class pymdBox extends EntityToGroup { tile_size_x: number; tile_size_y: number; - layer_binning: number[]; - tiles_in_layer_column_minus1: number[]; - tiles_in_layer_row_minus1: number[]; + layer_binning: Array; + tiles_in_layer_column_minus1: Array; + tiles_in_layer_row_minus1: Array; type = 'pymd' as const; box_name = 'Image pyramid'; diff --git a/src/boxes/a1lx.ts b/src/boxes/a1lx.ts index e8dca414..005fef2c 100644 --- a/src/boxes/a1lx.ts +++ b/src/boxes/a1lx.ts @@ -5,7 +5,7 @@ export class a1lxBox extends Box { type = 'a1lx' as const; box_name = 'AV1LayeredImageIndexingProperty'; - layer_size: number[]; + layer_size: Array; parse(stream: MultiBufferStream) { const large_size = stream.readUint8() & 1; diff --git a/src/boxes/avcC.ts b/src/boxes/avcC.ts index 828ca800..b8190b53 100644 --- a/src/boxes/avcC.ts +++ b/src/boxes/avcC.ts @@ -1,7 +1,7 @@ import { Box } from '#/box'; import type { MultiBufferStream } from '#/buffer'; -import type { DataStream } from '#/DataStream'; -import type { MP4BoxStream } from '#/stream'; +import { DataStream } from '#/DataStream'; +import { MP4BoxStream } from '#/stream'; import type { ParameterSetArray } from './displays/parameterSetArray'; export class avcCBox extends Box { diff --git a/src/boxes/cdef.ts b/src/boxes/cdef.ts index 046c4089..5fccf74a 100644 --- a/src/boxes/cdef.ts +++ b/src/boxes/cdef.ts @@ -6,9 +6,9 @@ export class cdefBox extends Box { box_name = 'ComponentDefinitionBox'; channel_count: number; - channel_indexes: number[]; - channel_types: number[]; - channel_associations: number[]; + channel_indexes: Array; + channel_types: Array; + channel_associations: Array; parse(stream: MultiBufferStream) { this.channel_count = stream.readUint16(); diff --git a/src/boxes/cmpd.ts b/src/boxes/cmpd.ts index a442385e..b7f619aa 100644 --- a/src/boxes/cmpd.ts +++ b/src/boxes/cmpd.ts @@ -6,8 +6,8 @@ export class cmpdBox extends Box { box_name = 'ComponentDefinitionBox'; component_count: number; - component_types: number[]; - component_type_urls: string[]; + component_types: Array; + component_type_urls: Array; parse(stream: MultiBufferStream) { this.component_count = stream.readUint32(); diff --git a/src/boxes/co64.ts b/src/boxes/co64.ts index e281e618..112e3843 100644 --- a/src/boxes/co64.ts +++ b/src/boxes/co64.ts @@ -5,7 +5,7 @@ export class co64Box extends FullBox { type = 'co64' as const; box_name = 'ChunkLargeOffsetBox'; - chunk_offsets: number[]; + chunk_offsets: Array; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/ctts.ts b/src/boxes/ctts.ts index c39db460..c1ade417 100644 --- a/src/boxes/ctts.ts +++ b/src/boxes/ctts.ts @@ -7,8 +7,8 @@ export class cttsBox extends FullBox { type = 'ctts' as const; box_name = 'CompositionOffsetBox'; - sample_counts: number[]; - sample_offsets: number[]; + sample_counts: Array; + sample_offsets: Array; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); @@ -53,7 +53,7 @@ export class cttsBox extends FullBox { } /** @bundle box-unpack.js */ - unpack(samples: Sample[]) { + unpack(samples: Array) { let k = 0; for (let i = 0; i < this.sample_counts.length; i++) { for (let j = 0; j < this.sample_counts[i]; j++) { diff --git a/src/boxes/dOps.ts b/src/boxes/dOps.ts index 008a87d4..cefd6f56 100644 --- a/src/boxes/dOps.ts +++ b/src/boxes/dOps.ts @@ -13,7 +13,7 @@ export class dOpsBox extends Box { ChannelMappingFamily: number; StreamCount: number; CoupledCount: number; - ChannelMapping: number[]; + ChannelMapping: Array; parse(stream: MultiBufferStream) { this.Version = stream.readUint8(); diff --git a/src/boxes/dec3.ts b/src/boxes/dec3.ts index 306901c3..8c4c3388 100644 --- a/src/boxes/dec3.ts +++ b/src/boxes/dec3.ts @@ -17,7 +17,7 @@ export class dec3Box extends Box { data_rate: number; num_ind_sub: number; - ind_subs: IndSub[]; + ind_subs: Array; parse(stream: MultiBufferStream) { const tmp_16 = stream.readUint16(); diff --git a/src/boxes/defaults.ts b/src/boxes/defaults.ts index 9584ec6a..65238cbe 100644 --- a/src/boxes/defaults.ts +++ b/src/boxes/defaults.ts @@ -112,7 +112,7 @@ export class iproBox extends FullBox { type = 'ipro' as const; box_name = 'ItemProtectionBox'; - sinfs: sinfBox[] = []; + sinfs: Array = []; get protections() { return this.sinfs; } @@ -129,36 +129,36 @@ export class moovBox extends ContainerBox { box_name = 'MovieBox'; timescale: number; mvhd: mvhdBox; - mvhds: mvhdBox[]; + mvhds: Array; mvex: mvexBox; - mvexs: mvexBox[]; + mvexs: Array; iods: iodsBox; - iodss: iodsBox[]; + iodss: Array; trak: trakBox; - traks: trakBox[] = []; - psshs: psshBox[] = []; + traks: Array = []; + psshs: Array = []; subBoxNames = ['trak', 'pssh'] as const; } export class trakBox extends ContainerBox { type = 'trak' as const; box_name = 'TrackBox'; mdia: mdiaBox; - mdias: mdiaBox[]; + mdias: Array; tkhd: tkhdBox; - tkhds: tkhdBox[]; + tkhds: Array; tref: trefBox; - trefs: trefBox[]; + trefs: Array; edts: edtsBox; - edtss: edtsBox[]; + edtss: Array; udta: udtaBox; - udtas: udtaBox[]; + udtas: Array; samples_duration: number; - samples: Sample[]; + samples: Array; samples_size: number; nextSample: number; lastValidSample: number; - sample_groups_info: SampleGroupInfo[]; + sample_groups_info: Array; first_dts: number; first_traf_merged: boolean; has_fragment_subsamples: boolean; @@ -167,39 +167,39 @@ export class edtsBox extends ContainerBox { type = 'edts' as const; box_name = 'EditBox'; elst: elstBox; - elsts: elstBox[]; + elsts: Array; } export class mdiaBox extends ContainerBox { type = 'mdia' as const; box_name = 'MediaBox'; elng: elngBox; - elngs: elngBox[]; + elngs: Array; hdlr: hdlrBox; - hdlrs: hdlrBox[]; + hdlrs: Array; mdhd: mdhdBox; - mdhds: mdhdBox[]; + mdhds: Array; minf: minfBox; - minfs: minfBox[]; + minfs: Array; } export class minfBox extends ContainerBox { type = 'minf' as const; box_name = 'MediaInformationBox'; stbl: stblBox; - stbls: stblBox[]; + stbls: Array; hmhd: hmhdBox; - hmhds: hmhdBox[]; + hmhds: Array; vmhd?: vmhdBox; - vmhds?: vmhdBox[]; + vmhds?: Array; smhd?: smhdBox; - smhds?: smhdBox[]; + smhds?: Array; sthd?: sthdBox; - sthds?: sthdBox[]; + sthds?: Array; nmhd?: nmhdBox; - nmhds?: nmhdBox[]; + nmhds?: Array; dinf: dinfBox; - dinfs: dinfBox[]; + dinfs: Array; dref: drefBox; - drefs: drefBox[]; + drefs: Array; } export class dinfBox extends ContainerBox { type = 'dinf' as const; @@ -209,34 +209,34 @@ export class stblBox extends ContainerBox { type = 'stbl' as const; box_name = 'SampleTableBox'; cslg: cslgBox; - cslgs: cslgBox[]; + cslgs: Array; stsd: stsdBox; - stsds: stsdBox[]; + stsds: Array; stsc: stscBox; - stscs: stscBox[]; + stscs: Array; stco: stcoBox; - stcos: stcoBox[]; + stcos: Array; co64: co64Box; - co64s: co64Box[]; + co64s: Array; stsz: stszBox; - stszs: stszBox[]; + stszs: Array; stz2: stz2Box; - stz2s: stz2Box[]; + stz2s: Array; stts: sttsBox; - sttss: sttsBox[]; + sttss: Array; ctts: cttsBox; - cttss: cttsBox[]; + cttss: Array; stss: stssBox; - stsss: stssBox[]; + stsss: Array; subs: subsBox; - subss: subsBox[]; + subss: Array; stdp: stdpBox; - stdps: stdpBox[]; + stdps: Array; sdtp: sdtpBox; - sdtps: sdtpBox[]; + sdtps: Array; - sgpds: sgpdBox[] = []; - sbgps: sbgpBox[] = []; + sgpds: Array = []; + sbgps: Array = []; subBoxNames = ['sgpd', 'sbgp']; } export class mvexBox extends ContainerBox { @@ -244,39 +244,39 @@ export class mvexBox extends ContainerBox { box_name = 'MovieExtendsBox'; trex: trexBox; mehd: mehdBox; - mehds: mehdBox[]; + mehds: Array; - trexs: trexBox[] = []; + trexs: Array = []; subBoxNames = ['trex']; } export class moofBox extends ContainerBox { type = 'moof' as const; box_name = 'MovieFragmentBox'; mfhd: mfhdBox; - mfhds: mfhdBox[]; + mfhds: Array; traf: trafBox; - trafs: trafBox[] = []; + trafs: Array = []; subBoxNames = ['traf']; } export class trafBox extends ContainerBox { type = 'traf' as const; box_name = 'TrackFragmentBox'; subs: subsBox; - subss: subsBox[]; + subss: Array; tfdt: tfdtBox; - tfdts: tfdtBox[]; + tfdts: Array; tfhd: tfhdBox; - tfhds: tfhdBox[]; + tfhds: Array; trun: trunBox; first_sample_index: number; sample_number: number; - sample_groups_info: SampleGroupInfo[]; + sample_groups_info: Array; - truns: trunBox[] = []; - sgpds: sgpdBox[] = []; - sbgps: sbgpBox[] = []; + truns: Array = []; + sgpds: Array = []; + sbgps: Array = []; subBoxNames = ['trun', 'sgpd', 'sbgp']; } export class vttcBox extends ContainerBox { @@ -287,7 +287,7 @@ export class vttcBox extends ContainerBox { export class mfraBox extends ContainerBox { type = 'mfra' as const; box_name = 'MovieFragmentRandomAccessBox'; - tfras: tfraBox[] = []; + tfras: Array = []; subBoxNames = ['tfra'] as const; } export class mecoBox extends ContainerBox { @@ -330,7 +330,7 @@ export class trgrBox extends ContainerBox { export class udtaBox extends ContainerBox { type = 'udta' as const; box_name = 'UserDataBox'; - kinds: kindBox[] = []; + kinds: Array = []; subBoxNames = ['kind'] as const; } export class iprpBox extends ContainerBox { @@ -338,7 +338,7 @@ export class iprpBox extends ContainerBox { box_name = 'ItemPropertiesBox'; ipco: ipcoBox; - ipmas: ipmaBox[] = []; + ipmas: Array = []; subBoxNames = ['ipma'] as const; } export class ipcoBox extends ContainerBox { @@ -348,7 +348,7 @@ export class ipcoBox extends ContainerBox { export class grplBox extends ContainerBox { type = 'grpl' as const; box_name = 'GroupsListBox'; - declare boxes: EntityToGroup[]; + declare boxes: Array; } export class j2kHBox extends ContainerBox { type = 'j2kH' as const; @@ -357,6 +357,6 @@ export class j2kHBox extends ContainerBox { export class etypBox extends ContainerBox { type = 'etyp' as const; box_name = 'ExtendedTypeBox'; - tycos: tycoBox[] = []; + tycos: Array = []; subBoxNames = ['tyco'] as const; } diff --git a/src/boxes/dfLa.ts b/src/boxes/dfLa.ts index 27a02d6c..d9ff25d0 100644 --- a/src/boxes/dfLa.ts +++ b/src/boxes/dfLa.ts @@ -25,10 +25,9 @@ export class dfLaBox extends FullBox { 'RESERVED', ]; - let i: number; - for (i = 0; i < 1_000_000; i++) { - const flagAndType = stream.readUint8(); - + let flagAndType: number; + do { + flagAndType = stream.readUint8(); const type = Math.min(flagAndType & BLOCKTYPE_MASK, knownBlockTypes.length - 1); // if this is a STREAMINFO block, read the true samplerate since this @@ -48,16 +47,7 @@ export class dfLaBox extends FullBox { } boxesFound.push(knownBlockTypes[type]); - - if (flagAndType & LASTMETADATABLOCKFLAG_MASK) { - break; - } - } - - // Defensive - if (i >= 1_000_000) { - throw new Error('dfLaBox: Too many metadata blocks found, parsing stopped'); - } + } while (!(flagAndType & LASTMETADATABLOCKFLAG_MASK)); this.numMetadataBlocks = boxesFound.length + ' (' + boxesFound.join(', ') + ')'; } diff --git a/src/boxes/displays/naluArrays.ts b/src/boxes/displays/naluArrays.ts index e453ab99..fa6413bb 100644 --- a/src/boxes/displays/naluArrays.ts +++ b/src/boxes/displays/naluArrays.ts @@ -13,9 +13,7 @@ export class NALUArrays extends Array { str += "" + nalu_array.nalu_type + ''; for (let j = 0; j < nalu_array.length; j++) { const nalu = nalu_array[j]; - if (j !== 0) { - str += ''; - } + if (j !== 0) str += ''; str += ''; str += nalu.data.reduce(function (str, byte) { return str + byte.toString(16).padStart(2, '0'); diff --git a/src/boxes/dref.ts b/src/boxes/dref.ts index 13e1ea07..c1191369 100644 --- a/src/boxes/dref.ts +++ b/src/boxes/dref.ts @@ -1,5 +1,4 @@ -import type { Box } from '#/box'; -import { FullBox, parseOneBox } from '#/box'; +import { Box, FullBox, parseOneBox } from '#/box'; import type { MultiBufferStream } from '#/buffer'; import { OK } from '#/constants'; import { Log } from '#/log'; @@ -8,7 +7,7 @@ export class drefBox extends FullBox { type = 'dref' as const; box_name = 'DataReferenceBox'; - entries: Box[]; + entries: Array; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/elst.ts b/src/boxes/elst.ts index 5fa36019..7cc49e79 100644 --- a/src/boxes/elst.ts +++ b/src/boxes/elst.ts @@ -6,7 +6,7 @@ export class elstBox extends FullBox { type = 'elst' as const; box_name = 'EditListBox'; - entries: Entry[]; + entries: Array; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/ftyp.ts b/src/boxes/ftyp.ts index 966c3554..107ddc80 100644 --- a/src/boxes/ftyp.ts +++ b/src/boxes/ftyp.ts @@ -7,7 +7,7 @@ export class ftypBox extends Box { major_brand: string; minor_version: number; - compatible_brands: string[]; + compatible_brands: Array; parse(stream: MultiBufferStream) { let toparse = this.size - this.hdr_size; diff --git a/src/boxes/hvcC.ts b/src/boxes/hvcC.ts index af956de3..b7f6cb1c 100644 --- a/src/boxes/hvcC.ts +++ b/src/boxes/hvcC.ts @@ -1,6 +1,6 @@ import { Box } from '#/box'; -import type { DataStream } from '#/DataStream'; -import type { MP4BoxStream } from '#/stream'; +import { DataStream } from '#/DataStream'; +import { MP4BoxStream } from '#/stream'; import type { NaluArray } from '@types'; import type { NALUArrays } from './displays/naluArrays'; diff --git a/src/boxes/iinf.ts b/src/boxes/iinf.ts index ba2a6bbf..9027459f 100644 --- a/src/boxes/iinf.ts +++ b/src/boxes/iinf.ts @@ -1,5 +1,5 @@ import { FullBox, parseOneBox } from '#/box'; -import type { infeBox } from '#/boxes/infe'; +import { infeBox } from '#/boxes/infe'; import type { MultiBufferStream } from '#/buffer'; import { OK } from '#/constants'; import { Log } from '#/log'; @@ -11,7 +11,7 @@ export class iinfBox extends FullBox { version: number; entry_count: number; - item_infos: infeBox[]; + item_infos: Array; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/iloc.ts b/src/boxes/iloc.ts index c94396d1..828dd9cd 100644 --- a/src/boxes/iloc.ts +++ b/src/boxes/iloc.ts @@ -15,13 +15,13 @@ export class ilocBox extends FullBox { length_size: number; base_offset_size: number; index_size: number; - items: { + items: Array<{ base_offset: number; construction_method: number; item_ID: number; data_reference_index: number; - extents: Extent[]; - }[]; + extents: Array; + }>; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); @@ -44,7 +44,7 @@ export class ilocBox extends FullBox { } else if (this.version === 2) { item_count = stream.readUint32(); } else { - throw new Error('version of iloc box not supported'); + throw 'version of iloc box not supported'; } for (let i = 0; i < item_count; i++) { let item_ID = 0; @@ -56,7 +56,7 @@ export class ilocBox extends FullBox { } else if (this.version === 2) { item_ID = stream.readUint32(); } else { - throw new Error('version of iloc box not supported'); + throw 'version of iloc box not supported'; } if (this.version === 1 || this.version === 2) { construction_method = stream.readUint16() & 0xf; @@ -76,10 +76,10 @@ export class ilocBox extends FullBox { base_offset = stream.readUint64(); break; default: - throw new Error('Error reading base offset size'); + throw 'Error reading base offset size'; } - const extents: Extent[] = []; + const extents: Array = []; const extent_count = stream.readUint16(); for (let j = 0; j < extent_count; j++) { @@ -99,7 +99,7 @@ export class ilocBox extends FullBox { extent_index = stream.readUint64(); break; default: - throw new Error('Error reading extent index'); + throw 'Error reading extent index'; } } @@ -114,7 +114,7 @@ export class ilocBox extends FullBox { extent_offset = stream.readUint64(); break; default: - throw new Error('Error reading extent index'); + throw 'Error reading extent index'; } switch (this.length_size) { @@ -128,7 +128,7 @@ export class ilocBox extends FullBox { extent_length = stream.readUint64(); break; default: - throw new Error('Error reading extent index'); + throw 'Error reading extent index'; } extents.push({ extent_index, extent_length, extent_offset }); diff --git a/src/boxes/ipma.ts b/src/boxes/ipma.ts index 609ff991..acc2639c 100644 --- a/src/boxes/ipma.ts +++ b/src/boxes/ipma.ts @@ -3,14 +3,14 @@ import type { MultiBufferStream } from '#/buffer'; export interface Assocation { id: number; - props: { property_index: number; essential: boolean }[]; + props: Array<{ property_index: number; essential: boolean }>; } export class ipmaBox extends FullBox { type = 'ipma' as const; box_name = 'ItemPropertyAssociationBox'; - associations: Assocation[]; + associations: Array; version: number; flags: number; diff --git a/src/boxes/iref.ts b/src/boxes/iref.ts index 4c6200f0..26949741 100644 --- a/src/boxes/iref.ts +++ b/src/boxes/iref.ts @@ -34,7 +34,7 @@ export class irefBox extends FullBox { type = 'iref' as const; box_name = 'ItemReferenceBox'; - references: { references: Reference[]; from_item_ID: number; type: string }[]; + references: Array<{ references: Array; from_item_ID: number; type: string }>; version: number; parse(stream: MultiBufferStream) { diff --git a/src/boxes/leva.ts b/src/boxes/leva.ts index 99e8a605..08ace565 100644 --- a/src/boxes/leva.ts +++ b/src/boxes/leva.ts @@ -15,7 +15,7 @@ export class levaBox extends FullBox { type = 'leva' as const; box_name = 'LevelAssignmentBox'; - levels: Level[]; + levels: Array; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/mdcv.ts b/src/boxes/mdcv.ts index 1254bf1d..27164ef5 100644 --- a/src/boxes/mdcv.ts +++ b/src/boxes/mdcv.ts @@ -6,7 +6,7 @@ export class mdcvBox extends Box { type = 'mdcv' as const; box_name = 'MasteringDisplayColourVolumeBox'; - display_primaries: ColorPoint[]; + display_primaries: Array; white_point: ColorPoint; max_display_mastering_luminance: number; min_display_mastering_luminance: number; diff --git a/src/boxes/meta.ts b/src/boxes/meta.ts index f57726c6..d572d45f 100644 --- a/src/boxes/meta.ts +++ b/src/boxes/meta.ts @@ -1,10 +1,10 @@ import { ContainerBox, FullBox } from '#/box'; -import type { dinfBox, grplBox, idatBox, iproBox, iprpBox } from '#/boxes/defaults'; -import type { hdlrBox } from '#/boxes/hdlr'; -import type { iinfBox } from '#/boxes/iinf'; -import type { ilocBox } from '#/boxes/iloc'; -import type { irefBox } from '#/boxes/iref'; -import type { pitmBox } from '#/boxes/pitm'; +import { dinfBox, grplBox, idatBox, iproBox, iprpBox } from '#/boxes/defaults'; +import { hdlrBox } from '#/boxes/hdlr'; +import { iinfBox } from '#/boxes/iinf'; +import { ilocBox } from '#/boxes/iloc'; +import { irefBox } from '#/boxes/iref'; +import { pitmBox } from '#/boxes/pitm'; import type { MultiBufferStream } from '#/buffer'; export class metaBox extends FullBox { @@ -12,25 +12,25 @@ export class metaBox extends FullBox { box_name = 'MetaBox'; hdlr: hdlrBox; - hdlrs: hdlrBox[]; + hdlrs: Array; iinf: iinfBox; - iinfs: iinfBox[]; + iinfs: Array; idat: idatBox; - idats: idatBox[]; + idats: Array; ipro: iproBox; - ipros: iproBox[]; + ipros: Array; grpl: grplBox; - grpls: grplBox[]; + grpls: Array; iloc: ilocBox; - ilocs: ilocBox[]; + ilocs: Array; iprp: iprpBox; - iprps: iprpBox[]; + iprps: Array; pitm: pitmBox; - pitms: pitmBox[]; + pitms: Array; iref: irefBox; - irefs: irefBox[]; + irefs: Array; dinf: dinfBox; - dinfs: dinfBox[]; + dinfs: Array; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/padb.ts b/src/boxes/padb.ts index cbe2dcc5..6c0e9bd1 100644 --- a/src/boxes/padb.ts +++ b/src/boxes/padb.ts @@ -12,7 +12,7 @@ export class padbBox extends FullBox { type = 'padb' as const; box_name = 'PaddingBitsBox'; - padbits: PaddingBit[]; + padbits: Array; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/pdin.ts b/src/boxes/pdin.ts index bacefaae..41c09b48 100644 --- a/src/boxes/pdin.ts +++ b/src/boxes/pdin.ts @@ -5,8 +5,8 @@ export class pdinBox extends Box { type = 'pdin' as const; box_name = 'ProgressiveDownloadInfoBox'; - rate: number[]; - initial_delay: number[]; + rate: Array; + initial_delay: Array; parse(stream: MultiBufferStream) { const count = (this.size - this.hdr_size) / 8; diff --git a/src/boxes/pixi.ts b/src/boxes/pixi.ts index e50e438e..d5594fe7 100644 --- a/src/boxes/pixi.ts +++ b/src/boxes/pixi.ts @@ -6,7 +6,7 @@ export class pixiBox extends FullBox { box_name = 'PixelInformationProperty'; num_channels: number; - bits_per_channels: number[]; + bits_per_channels: Array; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/prdi.ts b/src/boxes/prdi.ts index 10ac58a8..9b72d3ba 100644 --- a/src/boxes/prdi.ts +++ b/src/boxes/prdi.ts @@ -6,7 +6,7 @@ export class prdiBox extends FullBox { box_name = 'ProgressiveDerivedImageItemInformationProperty'; step_count: number; - item_count: number[]; + item_count: Array; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/pssh.ts b/src/boxes/pssh.ts index e90b5eb6..c6288a96 100644 --- a/src/boxes/pssh.ts +++ b/src/boxes/pssh.ts @@ -6,7 +6,7 @@ export class psshBox extends FullBox { box_name = 'ProtectionSystemSpecificHeaderBox'; system_id: string; - kid: string[]; + kid: Array; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/qt/tapt.ts b/src/boxes/qt/tapt.ts index 0f971b6c..644a37cc 100644 --- a/src/boxes/qt/tapt.ts +++ b/src/boxes/qt/tapt.ts @@ -1,14 +1,14 @@ import { ContainerBox } from '#/box'; -import type { clefBox } from '#/boxes/qt/clef'; -import type { enofBox } from '#/boxes/qt/enof'; -import type { profBox } from '#/boxes/qt/prof'; +import { clefBox } from '#/boxes/qt/clef'; +import { enofBox } from '#/boxes/qt/enof'; +import { profBox } from '#/boxes/qt/prof'; export class taptBox extends ContainerBox { type = 'tapt' as const; box_name = 'TrackApertureModeDimensionsBox'; - clef: clefBox[] = []; - prof: profBox[] = []; - enof: enofBox[] = []; + clef: Array = []; + prof: Array = []; + enof: Array = []; subBoxNames = ['clef', 'prof', 'enof'] as const; } diff --git a/src/boxes/saio.ts b/src/boxes/saio.ts index d17ca815..0f68eda0 100644 --- a/src/boxes/saio.ts +++ b/src/boxes/saio.ts @@ -7,7 +7,7 @@ export class saioBox extends FullBox { aux_info_type: string; aux_info_type_parameter: number; - offset: number[]; + offset: Array; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/saiz.ts b/src/boxes/saiz.ts index 823babab..ae36316e 100644 --- a/src/boxes/saiz.ts +++ b/src/boxes/saiz.ts @@ -9,7 +9,7 @@ export class saizBox extends FullBox { aux_info_type_parameter: number; default_sample_info_size: number; sample_count: number; - sample_info_size: number[]; + sample_info_size: Array; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/sampleentries/base.ts b/src/boxes/sampleentries/base.ts index 54ea1603..aa19a935 100644 --- a/src/boxes/sampleentries/base.ts +++ b/src/boxes/sampleentries/base.ts @@ -156,9 +156,9 @@ export class TextSampleEntry extends SampleEntry {} //Base SampleEntry types for Audio and Video with specific parsing export class VisualSampleEntry extends SampleEntry { avcC?: avcCBox; - avcCs?: avcCBox[]; + avcCs?: Array; hvcC?: hvcCBox; - hvcCs?: hvcCBox[]; + hvcCs?: Array; width: number; height: number; diff --git a/src/boxes/sampleentries/sampleentry.ts b/src/boxes/sampleentries/sampleentry.ts index 77dd7815..3eaed865 100644 --- a/src/boxes/sampleentries/sampleentry.ts +++ b/src/boxes/sampleentries/sampleentry.ts @@ -1,10 +1,10 @@ -import type { av1CBox } from '#/boxes/av1C'; -import type { avcCBox } from '#/boxes/avcC'; -import type { sinfBox } from '#/boxes/defaults'; -import type { esdsBox } from '#/boxes/esds'; -import type { hvcCBox } from '#/boxes/hvcC'; -import type { vpcCBox } from '#/boxes/vpcC'; -import type { vvcCBox } from '#/boxes/vvcC'; +import { av1CBox } from '#/boxes/av1C'; +import { avcCBox } from '#/boxes/avcC'; +import { sinfBox } from '#/boxes/defaults'; +import { esdsBox } from '#/boxes/esds'; +import { hvcCBox } from '#/boxes/hvcC'; +import { vpcCBox } from '#/boxes/vpcC'; +import { vvcCBox } from '#/boxes/vvcC'; import { AudioSampleEntry, MetadataSampleEntry, @@ -26,7 +26,7 @@ function decimalToHex(d: number | string, padding?: number | null) { class avcCSampleEntryBase extends VisualSampleEntry { declare avcC: avcCBox; - declare avcCs: avcCBox[]; + declare avcCs: Array; /** @bundle box-codecs.js */ getCodec() { @@ -60,7 +60,7 @@ export class avc4SampleEntry extends avcCSampleEntryBase { export class av01SampleEntry extends VisualSampleEntry { av1C: av1CBox; - av1Cs: av1CBox[]; + av1Cs: Array; type = 'av01' as const; @@ -97,7 +97,7 @@ export class dav1SampleEntry extends VisualSampleEntry { class hvcCSampleEntryBase extends VisualSampleEntry { declare hvcC: hvcCBox; - declare hvcCs: hvcCBox[]; + declare hvcCs: Array; /** @bundle box-codecs.js */ getCodec(): string { @@ -106,6 +106,7 @@ class hvcCSampleEntryBase extends VisualSampleEntry { baseCodec += '.'; switch (this.hvcC.general_profile_space) { case 0: + baseCodec += ''; break; case 1: baseCodec += 'A'; @@ -123,9 +124,7 @@ class hvcCSampleEntryBase extends VisualSampleEntry { let reversed = 0; for (let i = 0; i < 32; i++) { reversed |= val & 1; - if (i === 31) { - break; - } + if (i === 31) break; reversed <<= 1; val >>= 1; } @@ -179,7 +178,7 @@ export class dvheSampleEntry extends VisualSampleEntry { /** @babel box-codecs.js */ class vvcCSampleEntryBase extends VisualSampleEntry { vvcC: vvcCBox; - vvcCs: vvcCBox[]; + vvcCs: Array; getCodec() { let baseCodec = super.getCodec(); if (this.vvcC) { @@ -257,7 +256,7 @@ export class vvcNSampleEntry extends VisualSampleEntry { class vpcCSampleEntryBase extends VisualSampleEntry { vpcC: vpcCBox; - vpcCs: vpcCBox[]; + vpcCs: Array; getCodec() { const baseCodec = super.getCodec(); let level: number | string = this.vpcC.level; @@ -302,7 +301,7 @@ export class uncvSampleEntry extends VisualSampleEntry { export class mp4aSampleEntry extends AudioSampleEntry { esds: esdsBox; - esdss: esdsBox[]; + esdss: Array; type = 'mp4a' as const; @@ -364,28 +363,28 @@ export class encaSampleEntry extends AudioSampleEntry { } export class encuSampleEntry extends SubtitleSampleEntry { - sinfs: sinfBox[] = []; + sinfs: Array = []; subBoxNames = ['sinf'] as const; type = 'encu' as const; } export class encsSampleEntry extends SystemSampleEntry { - sinfs: sinfBox[] = []; + sinfs: Array = []; subBoxNames = ['sinf'] as const; type = 'encs' as const; } export class enctSampleEntry extends TextSampleEntry { - sinfs: sinfBox[] = []; + sinfs: Array = []; subBoxNames = ['sinf'] as const; type = 'enct' as const; } export class encmSampleEntry extends MetadataSampleEntry { - sinfs: sinfBox[] = []; + sinfs: Array = []; subBoxNames = ['sinf'] as const; type = 'encm' as const; diff --git a/src/boxes/samplegroups/alst.ts b/src/boxes/samplegroups/alst.ts index bdc5285e..3551416c 100644 --- a/src/boxes/samplegroups/alst.ts +++ b/src/boxes/samplegroups/alst.ts @@ -3,9 +3,9 @@ import type { MultiBufferStream } from '#/buffer'; export class alstSampleGroupEntry extends SampleGroupEntry { first_output_sample: number; - sample_offset: number[]; - num_output_samples: number[]; - num_total_samples: number[]; + sample_offset: Array; + num_output_samples: Array; + num_total_samples: Array; parse(stream: MultiBufferStream) { const roll_count = stream.readUint16(); diff --git a/src/boxes/samplegroups/avss.ts b/src/boxes/samplegroups/avss.ts index 6158aa4b..2faf81b9 100644 --- a/src/boxes/samplegroups/avss.ts +++ b/src/boxes/samplegroups/avss.ts @@ -10,11 +10,11 @@ export class avssSampleGroupEntry extends SampleGroupEntry { accurateStatisticsFlag: number; avgBitRate: number; avgFrameRate: number; - dependency: { + dependency: Array<{ subSeqDirectionFlag: number; layerNumber: number; subSequenceIdentifier: number; - }[]; + }>; parse(stream: MultiBufferStream) { this.subSequenceIdentifier = stream.readUint16(); diff --git a/src/boxes/samplegroups/rash.ts b/src/boxes/samplegroups/rash.ts index 5a2c91a4..f43ffb2d 100644 --- a/src/boxes/samplegroups/rash.ts +++ b/src/boxes/samplegroups/rash.ts @@ -4,8 +4,8 @@ import { Log } from '#/log'; export class rashSampleGroupEntry extends SampleGroupEntry { operation_point_count: number; - target_rate_share: number | number[]; - available_bitrate: number[]; + target_rate_share: number | Array; + available_bitrate: Array; maximum_bitrate: number; minimum_bitrate: number; discard_priority: number; diff --git a/src/boxes/sbgp.ts b/src/boxes/sbgp.ts index 2276010b..7482b0a8 100644 --- a/src/boxes/sbgp.ts +++ b/src/boxes/sbgp.ts @@ -12,7 +12,7 @@ export class sbgpBox extends FullBox { grouping_type: string; grouping_type_parameter: number; - entries: Entry[]; + entries: Array; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/sbpm.ts b/src/boxes/sbpm.ts index 86baa9d2..e6b1665f 100644 --- a/src/boxes/sbpm.ts +++ b/src/boxes/sbpm.ts @@ -7,14 +7,14 @@ export class sbpmBox extends FullBox { box_name = 'SensorBadPixelsMapBox'; component_count: number; - component_index: number[]; + component_index: Array; correction_applied: boolean; num_bad_rows: number; num_bad_cols: number; num_bad_pixels: number; - bad_rows: number[]; - bad_columns: number[]; - bad_pixels: Pixel[]; + bad_rows: Array; + bad_columns: Array; + bad_pixels: Array; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/sdtp.ts b/src/boxes/sdtp.ts index ab72e1ed..cddf73e6 100644 --- a/src/boxes/sdtp.ts +++ b/src/boxes/sdtp.ts @@ -5,10 +5,10 @@ export class sdtpBox extends FullBox { type = 'sdtp' as const; box_name = 'SampleDependencyTypeBox'; - is_leading: number[]; - sample_depends_on: number[]; - sample_is_depended_on: number[]; - sample_has_redundancy: number[]; + is_leading: Array; + sample_depends_on: Array; + sample_is_depended_on: Array; + sample_has_redundancy: Array; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/sgpd.ts b/src/boxes/sgpd.ts index bbb7a72b..91c111ba 100644 --- a/src/boxes/sgpd.ts +++ b/src/boxes/sgpd.ts @@ -31,7 +31,7 @@ export class sgpdBox extends FullBox { default_length: number; default_group_description_index: number; default_sample_description_index: number; - entries: SampleGroupEntry[]; + entries: Array; used: boolean; parse(stream: MultiBufferStream) { diff --git a/src/boxes/sidx.ts b/src/boxes/sidx.ts index 0c12f0e4..08f7c151 100644 --- a/src/boxes/sidx.ts +++ b/src/boxes/sidx.ts @@ -18,7 +18,7 @@ export class sidxBox extends FullBox { timescale: number; earliest_presentation_time: number; first_offset: number; - references: Reference[]; + references: Array; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/ssix.ts b/src/boxes/ssix.ts index 286608e9..ff4b8194 100644 --- a/src/boxes/ssix.ts +++ b/src/boxes/ssix.ts @@ -6,14 +6,14 @@ interface Range { range_size: number; } interface SubSegment { - ranges: Range[]; + ranges: Array; } export class ssixBox extends FullBox { type = 'ssix' as const; box_name = 'CompressedSubsegmentIndexBox'; - subsegments: SubSegment[]; + subsegments: Array; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/stco.ts b/src/boxes/stco.ts index 79ecfe3b..f048327a 100644 --- a/src/boxes/stco.ts +++ b/src/boxes/stco.ts @@ -6,7 +6,7 @@ export class stcoBox extends FullBox { type = 'stco' as const; box_name = 'ChunkOffsetBox'; - chunk_offsets: number[]; + chunk_offsets: Array; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); @@ -30,7 +30,7 @@ export class stcoBox extends FullBox { } /** @bundle box-unpack.js */ - unpack(samples: Sample[]) { + unpack(samples: Array) { for (let i = 0; i < this.chunk_offsets.length; i++) { samples[i].offset = this.chunk_offsets[i]; } diff --git a/src/boxes/stdp.ts b/src/boxes/stdp.ts index 5806a708..7ef4d5cb 100644 --- a/src/boxes/stdp.ts +++ b/src/boxes/stdp.ts @@ -5,7 +5,7 @@ export class stdpBox extends FullBox { type = 'stpd' as const; box_name = 'DegradationPriorityBox'; - priority: number[]; + priority: Array; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/stri.ts b/src/boxes/stri.ts index 788799a3..71cf1e00 100644 --- a/src/boxes/stri.ts +++ b/src/boxes/stri.ts @@ -8,7 +8,7 @@ export class striBox extends FullBox { switch_group: number; alternate_group: number; sub_track_id: number; - attribute_list: number[]; + attribute_list: Array; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/stsc.ts b/src/boxes/stsc.ts index d9ded6c7..c5929290 100644 --- a/src/boxes/stsc.ts +++ b/src/boxes/stsc.ts @@ -6,9 +6,9 @@ export class stscBox extends FullBox { type = 'stsc' as const; box_name = 'SampleToChunkBox'; - first_chunk: number[]; - samples_per_chunk: number[]; - sample_description_index: number[]; + first_chunk: Array; + samples_per_chunk: Array; + sample_description_index: Array; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); @@ -38,7 +38,7 @@ export class stscBox extends FullBox { } } - unpack(samples: Sample[]) { + unpack(samples: Array) { let l = 0; let m = 0; for (let i = 0; i < this.first_chunk.length; i++) { diff --git a/src/boxes/stsd.ts b/src/boxes/stsd.ts index 57d48cde..33278155 100644 --- a/src/boxes/stsd.ts +++ b/src/boxes/stsd.ts @@ -9,7 +9,7 @@ export class stsdBox extends FullBox { type = 'stsd' as const; box_name = 'SampleDescriptionBox'; - entries: SampleEntry[]; + entries: Array; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/stsg.ts b/src/boxes/stsg.ts index 26c865be..03c183fd 100644 --- a/src/boxes/stsg.ts +++ b/src/boxes/stsg.ts @@ -6,7 +6,7 @@ export class stsgBox extends FullBox { box_name = 'SubTrackSampleGroupBox'; grouping_type: number; - group_description_index: number[]; + group_description_index: Array; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/stsh.ts b/src/boxes/stsh.ts index 4b895dc8..a7d4afe6 100644 --- a/src/boxes/stsh.ts +++ b/src/boxes/stsh.ts @@ -5,8 +5,8 @@ export class stshBox extends FullBox { type = 'stsh' as const; box_name = 'ShadowSyncSampleBox'; - shadowed_sample_numbers: number[]; - sync_sample_numbers: number[]; + shadowed_sample_numbers: Array; + sync_sample_numbers: Array; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/stss.ts b/src/boxes/stss.ts index 68b07dca..4957f7d0 100644 --- a/src/boxes/stss.ts +++ b/src/boxes/stss.ts @@ -5,7 +5,7 @@ export class stssBox extends FullBox { type = 'stss' as const; box_name = 'SyncSampleBox'; - sample_numbers: number[]; + sample_numbers: Array; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/stsz.ts b/src/boxes/stsz.ts index ec95936d..9a57ca70 100644 --- a/src/boxes/stsz.ts +++ b/src/boxes/stsz.ts @@ -5,7 +5,7 @@ export class stszBox extends FullBox { type = 'stsz' as const; box_name = 'SampleSizeBox'; - sample_sizes: number[]; + sample_sizes: Array; sample_size: number; sample_count: number; diff --git a/src/boxes/stts.ts b/src/boxes/stts.ts index 5d819ba8..ba6e4d28 100644 --- a/src/boxes/stts.ts +++ b/src/boxes/stts.ts @@ -7,8 +7,8 @@ export class sttsBox extends FullBox { type = 'stts' as const; box_name = 'TimeToSampleBox'; - sample_counts: number[] = []; - sample_deltas: number[] = []; + sample_counts: Array = []; + sample_deltas: Array = []; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); @@ -45,7 +45,7 @@ export class sttsBox extends FullBox { } /** @bundle box-unpack.js */ - unpack(samples: Sample[]) { + unpack(samples: Array) { let k = 0; for (let i = 0; i < this.sample_counts.length; i++) { for (let j = 0; j < this.sample_counts[i]; j++) { diff --git a/src/boxes/styp.ts b/src/boxes/styp.ts index 6a6eae84..6a7f2b82 100644 --- a/src/boxes/styp.ts +++ b/src/boxes/styp.ts @@ -7,7 +7,7 @@ export class stypBox extends Box { major_brand: string; minor_version: number; - compatible_brands: string[]; + compatible_brands: Array; parse(stream: MultiBufferStream) { let toparse = this.size - this.hdr_size; diff --git a/src/boxes/stz2.ts b/src/boxes/stz2.ts index 32a55bb9..ba181b7e 100644 --- a/src/boxes/stz2.ts +++ b/src/boxes/stz2.ts @@ -6,7 +6,7 @@ export class stz2Box extends FullBox { type = 'stz2' as const; box_name = 'CompactSampleSizeBox'; - sample_sizes: number[]; + sample_sizes: Array; reserved: number; field_size: number; diff --git a/src/boxes/subs.ts b/src/boxes/subs.ts index 0cd20936..16b91847 100644 --- a/src/boxes/subs.ts +++ b/src/boxes/subs.ts @@ -5,14 +5,14 @@ import type { SubSample } from '@types'; interface SampleInfo { size: number; sample_delta: number; - subsamples: SubSample[]; + subsamples: Array; } export class subsBox extends FullBox { type = 'subs' as const; box_name = 'SubSampleInformationBox'; - entries: SampleInfo[]; + entries: Array; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/tfra.ts b/src/boxes/tfra.ts index 9f0ba147..7c964052 100644 --- a/src/boxes/tfra.ts +++ b/src/boxes/tfra.ts @@ -10,7 +10,7 @@ export class tfraBox extends FullBox { length_size_of_traf_num: number; length_size_of_trun_num: number; length_size_of_sample_num: number; - entries: SampleEntry[]; + entries: Array; time: number; moof_offset: number; traf_number: number; diff --git a/src/boxes/tref.ts b/src/boxes/tref.ts index 785d1a3b..d294771f 100644 --- a/src/boxes/tref.ts +++ b/src/boxes/tref.ts @@ -6,7 +6,7 @@ import { Log } from '#/log'; export class trefBox extends ContainerBox { type = 'tref' as const; - declare boxes: TrackReferenceTypeBox[]; + declare boxes: Array; parse(stream: MultiBufferStream) { while (stream.getPosition() < this.start + this.size) { diff --git a/src/boxes/trun.ts b/src/boxes/trun.ts index 826010ea..00e4b038 100644 --- a/src/boxes/trun.ts +++ b/src/boxes/trun.ts @@ -16,10 +16,10 @@ export class trunBox extends FullBox { sample_count: number; data_offset: number; first_sample_flags: number; - sample_duration: number[]; - sample_size: number[]; - sample_flags: number[]; - sample_composition_time_offset: number[]; + sample_duration: Array; + sample_size: Array; + sample_flags: Array; + sample_composition_time_offset: Array; data_offset_position: number; parse(stream: MultiBufferStream) { diff --git a/src/boxes/tsel.ts b/src/boxes/tsel.ts index fa5c8900..150d2c43 100644 --- a/src/boxes/tsel.ts +++ b/src/boxes/tsel.ts @@ -6,7 +6,7 @@ export class tselBox extends FullBox { box_name = 'TrackSelectionBox'; switch_group: number; - attribute_list: number[]; + attribute_list: Array; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/boxes/tyco.ts b/src/boxes/tyco.ts index 9fab9824..268da053 100644 --- a/src/boxes/tyco.ts +++ b/src/boxes/tyco.ts @@ -5,7 +5,7 @@ export class tycoBox extends Box { type = 'tyco' as const; box_name = 'TypeCombinationBox'; - compatible_brands: string[]; + compatible_brands: Array; parse(stream: MultiBufferStream) { const count = (this.size - this.hdr_size) / 4; diff --git a/src/boxes/uncC.ts b/src/boxes/uncC.ts index 09fe8449..31dbdf79 100644 --- a/src/boxes/uncC.ts +++ b/src/boxes/uncC.ts @@ -7,10 +7,10 @@ export class uncCBox extends FullBox { profile: string; component_count: number; - component_index: number[]; - component_bit_depth_minus_one: number[]; - component_format: number[]; - component_align_size: number[]; + component_index: Array; + component_bit_depth_minus_one: Array; + component_format: Array; + component_align_size: Array; sampling_type: number; interleave_type: number; block_size: number; diff --git a/src/boxes/uuid/index.ts b/src/boxes/uuid/index.ts index f4146cfa..7b8f9f9d 100644 --- a/src/boxes/uuid/index.ts +++ b/src/boxes/uuid/index.ts @@ -64,7 +64,7 @@ export const UUID_BOXES = { uuid = 'd4807ef2ca3946958e5426cb9e46a79f' as const; fragment_count: number; - entries: { absolute_time: number; absolute_duration: number }[]; + entries: Array<{ absolute_time: number; absolute_duration: number }>; parse(stream: MultiBufferStream): void { this.parseFullHeader(stream); diff --git a/src/boxes/vvcC.ts b/src/boxes/vvcC.ts index f572623b..0cd530d5 100644 --- a/src/boxes/vvcC.ts +++ b/src/boxes/vvcC.ts @@ -21,13 +21,13 @@ export class vvcCBox extends FullBox { ptl_multilayer_enabled_flag: number; general_constraint_info: Uint8Array; ptl_sublayer_present_mask: number; - sublayer_level_idc: number[]; + sublayer_level_idc: Array; ptl_num_sub_profiles: number; - general_sub_profile_idc: number[]; + general_sub_profile_idc: Array; max_picture_width: number; max_picture_height: number; avg_frame_rate: number; - nalu_arrays: NaluArray[]; + nalu_arrays: Array; parse(stream: MultiBufferStream) { this.parseFullHeader(stream); diff --git a/src/buffer.ts b/src/buffer.ts index 433637f1..dceda729 100644 --- a/src/buffer.ts +++ b/src/buffer.ts @@ -27,7 +27,7 @@ function concatBuffers(buffer1: ArrayBuffer, buffer2: ArrayBuffer) { * It inherits also from DataStream for all read/write/alloc operations */ export class MultiBufferStream extends DataStream { - buffers: MP4BoxBuffer[]; + buffers: Array; bufferIndex: number; constructor(buffer?: MP4BoxBuffer) { @@ -101,7 +101,7 @@ export class MultiBufferStream extends DataStream { /* The new buffer overlaps with an existing buffer */ if (ab.byteLength > b.byteLength) { /* the new buffer is bigger than the existing one - remove the existing buffer and try again to insert + remove the existing buffer and try again to insert the new buffer to check overlap with the next ones */ this.buffers.splice(i, 1); i--; @@ -135,7 +135,7 @@ export class MultiBufferStream extends DataStream { ')', ); this.buffers.splice(i, 0, ab); - /* if this new buffer is inserted in the first place in the list of the buffer, + /* if this new buffer is inserted in the first place in the list of the buffer, and the DataStream is initialized, make it the buffer used for parsing */ if (i === 0) { this.buffer = ab; @@ -164,7 +164,7 @@ export class MultiBufferStream extends DataStream { 'Appending new buffer (fileStart: ' + ab.fileStart + ' - Length: ' + ab.byteLength + ')', ); this.buffers.push(ab); - /* if this new buffer is inserted in the first place in the list of the buffer, + /* if this new buffer is inserted in the first place in the list of the buffer, and the DataStream is initialized, make it the buffer used for parsing */ if (i === 0) { this.buffer = ab; @@ -216,7 +216,14 @@ export class MultiBufferStream extends DataStream { } else { log( 'MultiBufferStream', - `${this.buffers.length} stored buffer(s) (${used}/${total} bytes), continuous ranges: ${bufferedString}`, + '' + + this.buffers.length + + ' stored buffer(s) (' + + used + + '/' + + total + + ' bytes), continuous ranges: ' + + bufferedString, ); } } @@ -274,7 +281,7 @@ export class MultiBufferStream extends DataStream { * should be marked as used for garbage collection * @return {Number} the index of the buffer holding the seeked file position, -1 if not found. */ - findPosition(fromStart: boolean, filePosition: number, markAsUsed: boolean): number { + findPosition(fromStart: boolean, filePosition: number, markAsUsed: boolean) { let index = -1; let i = fromStart === true ? 0 : this.bufferIndex; @@ -316,7 +323,7 @@ export class MultiBufferStream extends DataStream { * @param {Number} inputindex Index of the buffer to start from * @return {Number} The largest file position found in the buffers */ - findEndContiguousBuf(inputindex?: number): number { + findEndContiguousBuf(inputindex?: number) { const index = inputindex !== undefined ? inputindex : this.bufferIndex; let currentBuf = this.buffers[index]; /* find the end of the contiguous range of data */ @@ -340,7 +347,7 @@ export class MultiBufferStream extends DataStream { * @return {Number} the largest position in the current buffer or in the buffer and the next contiguous * buffer that holds the given position */ - getEndFilePositionAfter(pos: number): number { + getEndFilePositionAfter(pos: number) { const index = this.findPosition(true, pos, false); if (index !== -1) { return this.findEndContiguousBuf(index); @@ -405,7 +412,7 @@ export class MultiBufferStream extends DataStream { */ getPosition() { if (this.bufferIndex === -1 || this.buffers[this.bufferIndex] === null) { - throw new Error('Error accessing position in the MultiBufferStream'); + throw 'Error accessing position in the MultiBufferStream'; } return this.buffers[this.bufferIndex].fileStart + this.position; } @@ -420,7 +427,7 @@ export class MultiBufferStream extends DataStream { getEndPosition() { if (this.bufferIndex === -1 || this.buffers[this.bufferIndex] === null) { - throw new Error('Error accessing position in the MultiBufferStream'); + throw 'Error accessing position in the MultiBufferStream'; } return this.buffers[this.bufferIndex].fileStart + this.byteLength; } diff --git a/src/create-file.ts b/src/create-file.ts index b67b9c30..41899382 100644 --- a/src/create-file.ts +++ b/src/create-file.ts @@ -3,7 +3,7 @@ * License: BSD-3-Clause (see LICENSE file) */ -import type { MultiBufferStream } from '#/buffer'; +import { MultiBufferStream } from '#/buffer'; import { ISOFile } from '#/isofile'; export function createFile(keepMdatData = true, stream?: MultiBufferStream) { diff --git a/src/descriptor.ts b/src/descriptor.ts index f7527c67..7a210265 100644 --- a/src/descriptor.ts +++ b/src/descriptor.ts @@ -3,8 +3,8 @@ * License: BSD-3-Clause (see LICENSE file) */ -import type { MultiBufferStream } from '#/buffer'; -import type { DataStream } from '#/DataStream'; +import { MultiBufferStream } from '#/buffer'; +import { DataStream } from '#/DataStream'; import { Log } from '#/log'; const ES_DescrTag = 0x03; @@ -119,9 +119,7 @@ export class ES_Descriptor extends Descriptor { getAudioConfig() { const dcd = this.findDescriptor(DecoderConfigDescrTag); - if (!dcd) { - return null; - } + if (!dcd) return null; const dsi = dcd.findDescriptor(DecSpecificInfoTag); if (dsi && dsi.data) { let audioObjectType = (dsi.data[0] & 0xf8) >> 3; diff --git a/src/isofile.ts b/src/isofile.ts index a25ecf84..46ed768d 100644 --- a/src/isofile.ts +++ b/src/isofile.ts @@ -27,7 +27,7 @@ import { hdlrBox } from '#/boxes/hdlr'; import { hvcCBox } from '#/boxes/hvcC'; import { mdhdBox } from '#/boxes/mdhd'; import { mehdBox } from '#/boxes/mehd'; -import type { metaBox } from '#/boxes/meta'; +import { metaBox } from '#/boxes/meta'; import { mfhdBox } from '#/boxes/mfhd'; import { mvhdBox } from '#/boxes/mvhd'; import { stppSampleEntry } from '#/boxes/sampleentries'; @@ -39,10 +39,10 @@ import { SystemSampleEntry, VisualSampleEntry, } from '#/boxes/sampleentries/base'; -import type { sbgpBox } from '#/boxes/sbgp'; -import type { sdtpBox } from '#/boxes/sdtp'; -import type { sgpdBox } from '#/boxes/sgpd'; -import type { sidxBox } from '#/boxes/sidx'; +import { sbgpBox } from '#/boxes/sbgp'; +import { sdtpBox } from '#/boxes/sdtp'; +import { sgpdBox } from '#/boxes/sgpd'; +import { sidxBox } from '#/boxes/sidx'; import { smhdBox } from '#/boxes/smhd'; import { stcoBox } from '#/boxes/stco'; import { sthdBox } from '#/boxes/sthd'; @@ -95,7 +95,7 @@ import type { SubSample, Track, } from '@types'; -import type { MP4BoxBuffer } from './mp4boxbuffer'; +import { MP4BoxBuffer } from './mp4boxbuffer'; export class SampleGroupInfo { last_sample_in_run = -1; @@ -113,8 +113,8 @@ export class SampleGroupInfo { } export interface IsoFileOptions { - brands?: string[]; - description_boxes?: BoxKind[]; + brands?: Array; + description_boxes?: Array; duration?: number; height?: number; id?: number; @@ -147,11 +147,11 @@ export class ISOFile { /** MutiBufferStream object used to parse boxes */ stream: MultiBufferStream; /** Array of all boxes (in order) found in the file */ - boxes: Box[] = []; + boxes: Array = []; /** Array of all mdats */ - mdats: mdatBox[] = []; + mdats: Array = []; /** Array of all moofs */ - moofs: moofBox[] = []; + moofs: Array = []; /** Boolean indicating if the file is compatible with progressive parsing (moov first) */ isProgressive = false; /** Boolean used to fire moov start event only once */ @@ -175,7 +175,7 @@ export class ISOFile { ) => void) | null = null; /** Callback to call when samples are ready */ - onSamples: ((id: number, user: TSampleUser, samples: Sample[]) => void) | null = null; + onSamples: ((id: number, user: TSampleUser, samples: Array) => void) | null = null; /** Callback to call when there is an error in the parsing or processing of samples */ onError: (() => void) | null = null; @@ -183,9 +183,9 @@ export class ISOFile { /** Boolean indicating if the moov box run-length encoded tables of sample information have been processed */ sampleListBuilt = false; /** Array of Track objects for which fragmentation of samples is requested */ - fragmentedTracks: FragmentedTrack[] = []; + fragmentedTracks: Array> = []; /** Array of Track objects for which extraction of samples is requested */ - extractedTracks: ExtractedTrack[] = []; + extractedTracks: Array> = []; /** Boolean indicating that fragmention is ready */ isFragmentationInitialized = false; /** Boolean indicating that fragmented has started */ @@ -200,10 +200,10 @@ export class ISOFile { sidxSent = false; /** @bundle isofile-item-processing.js */ - items: Item[] = []; + items: Array = []; /** @bundle isofile-item-processing.js */ - entity_groups: EntityGroup[] = []; + entity_groups: Array = []; /** * size of the buffers allocated for samples @@ -212,18 +212,18 @@ export class ISOFile { itemsDataSize = 0; moov: moovBox; - moovs: moovBox[]; + moovs: Array; sidx: sidxBox; - sidxs: sidxBox[]; + sidxs: Array; meta: metaBox; - metas: metaBox[]; + metas: Array; ftyp: ftypBox; - ftyps: ftypBox[]; + ftyps: Array; nextSeekPosition: number; initial_duration: number; static type: BoxKind['type']; - static boxes: Box[]; + static boxes: Array; constructor(stream?: MultiBufferStream) { this.stream = stream || new MultiBufferStream(); @@ -367,8 +367,9 @@ export class ISOFile { break; } } - - this.updateUsedBytes(box, ret); + if (this.updateUsedBytes) { + this.updateUsedBytes(box, ret); + } } } } @@ -376,10 +377,10 @@ export class ISOFile { checkBuffer(ab?: MP4BoxBuffer) { if (ab === null || ab === undefined) { - throw new Error('Buffer must be defined and non empty'); + throw 'Buffer must be defined and non empty'; } if (ab.fileStart === undefined) { - throw new Error('Buffer must have a fileStart property'); + throw 'Buffer must have a fileStart property'; } if (ab.byteLength === 0) { Log.warn('ISOFile', 'Ignoring empty buffer (fileStart: ' + ab.fileStart + ')'); @@ -416,9 +417,7 @@ export class ISOFile { /* Check if the moovStart callback needs to be called */ if (this.moovStartFound && !this.moovStartSent) { this.moovStartSent = true; - if (this.onMoovStart) { - this.onMoovStart(); - } + if (this.onMoovStart) this.onMoovStart(); } if (this.moov) { @@ -518,13 +517,13 @@ export class ISOFile { brands: [this.ftyp.major_brand].concat(this.ftyp.compatible_brands), created: new Date(_1904 + this.moov.mvhd.creation_time * 1000), modified: new Date(_1904 + this.moov.mvhd.modification_time * 1000), - tracks: [] as Track[], - audioTracks: [] as Track[], - videoTracks: [] as Track[], - subtitleTracks: [] as Track[], - metadataTracks: [] as Track[], - hintTracks: [] as Track[], - otherTracks: [] as Track[], + tracks: [] as Array, + audioTracks: [] as Array, + videoTracks: [] as Array, + subtitleTracks: [] as Array, + metadataTracks: [] as Array, + hintTracks: [] as Array, + otherTracks: [] as Array, mime: '', }; @@ -619,9 +618,7 @@ export class ISOFile { movie.mime += 'application/mp4; codecs="'; } for (let i = 0; i < movie.tracks.length; i++) { - if (i !== 0) { - movie.mime += ','; - } + if (i !== 0) movie.mime += ','; movie.mime += movie.tracks[i].codec; } movie.mime += '"; profiles="'; @@ -643,9 +640,7 @@ export class ISOFile { } processSamples(last?: boolean) { - if (!this.sampleProcessingStarted) { - return; - } + if (!this.sampleProcessingStarted) return; /* For each track marked for fragmentation, check if the next sample is there (i.e. if the sample information is known (i.e. moof has arrived) and if it has been downloaded) @@ -760,14 +755,10 @@ export class ISOFile { return result; } - static _sweep(type: BoxKind['type'], result: (typeof ISOFile)[], returnEarly: boolean) { - if (this.type && this.type === type) { - result.push(this); - } + static _sweep(type: BoxKind['type'], result: Array, returnEarly: boolean) { + if (this.type && this.type === type) result.push(this); for (const box in this.boxes) { - if (result.length && returnEarly) { - return; - } + if (result.length && returnEarly) return; ISOFile._sweep.call(this.boxes[box], type, result, returnEarly); } } @@ -791,9 +782,7 @@ export class ISOFile { releaseUsedSamples(id: number, sampleNum: number) { let size = 0; const trak = this.getTrackById(id); - if (!trak.lastValidSample) { - trak.lastValidSample = 0; - } + if (!trak.lastValidSample) trak.lastValidSample = 0; for (let i = trak.lastValidSample; i < sampleNum; i++) { size += this.releaseSample(trak, i); } @@ -835,7 +824,7 @@ export class ISOFile { seekTrack(time: number, useRap: boolean, trak: trakBox) { let rap_seek_sample_num = 0; let seek_sample_num = 0; - let timescale: number; + let timescale: number = null; if (trak.samples.length === 0) { Log.info( @@ -905,7 +894,7 @@ export class ISOFile { const moov = this.moov; let seek_info = { offset: Infinity, time: Infinity }; if (!this.moov) { - throw new Error('Cannot seek: moov not received!'); + throw 'Cannot seek: moov not received!'; } else { for (let i = 0; i < moov.traks.length; i++) { const trak = moov.traks[i]; @@ -945,7 +934,7 @@ export class ISOFile { } } - equal(b: { boxes: Box[] }) { + equal(b: { boxes: Array }) { let box_index = 0; while (box_index < this.boxes.length && box_index < b.boxes.length) { const a_box = this.boxes[box_index]; @@ -1067,7 +1056,7 @@ export class ISOFile { this.nextMoofNumber = 0; this.resetTables(); } - const initSegs: { id: number; user: TSegmentUser; buffer: MP4BoxBuffer }[] = []; + const initSegs: Array<{ id: number; user: TSegmentUser; buffer: MP4BoxBuffer }> = []; for (let i = 0; i < this.fragmentedTracks.length; i++) { const moov = new moovBox(); moov.mvhd = this.moov.mvhd; @@ -1131,9 +1120,7 @@ export class ISOFile { } const stss = trak.mdia.minf.stbl.stss; const k = trak.mdia.minf.stbl.boxes.indexOf(stss); - if (k !== -1) { - trak.mdia.minf.stbl.boxes[k] = null; - } + if (k !== -1) trak.mdia.minf.stbl.boxes[k] = null; } } @@ -1141,9 +1128,9 @@ export class ISOFile { static initSampleGroups( trak: trakBox, traf: trafBox | null, - sbgps: sbgpBox[], - trak_sgpds: sgpdBox[], - traf_sgpds?: sgpdBox[], + sbgps: Array, + trak_sgpds: Array, + traf_sgpds?: Array, ) { if (traf) { traf.sample_groups_info = []; @@ -1211,7 +1198,7 @@ export class ISOFile { trak: trakBox, sample: Sample, sample_number: number, - sample_groups_info: SampleGroupInfo[], + sample_groups_info: Array, ) { sample.sample_groups = []; for (const k in sample_groups_info) { @@ -1724,9 +1711,7 @@ export class ISOFile { } else { /* the sample does not end in this buffer */ - if (lengthAfterStart === 0) { - return null; - } + if (lengthAfterStart === 0) return null; Log.debug( 'ISOFile', @@ -1811,14 +1796,10 @@ export class ISOFile { * @bundle isofile-sample-processing.js */ getTrexById(id: number) { - if (!this.moov || !this.moov.mvex) { - return null; - } + if (!this.moov || !this.moov.mvex) return null; for (let i = 0; i < this.moov.mvex.trexs.length; i++) { const trex = this.moov.mvex.trexs[i]; - if (trex.track_id === id) { - return trex; - } + if (trex.track_id === id) return trex; } return null; } @@ -1834,9 +1815,7 @@ export class ISOFile { } for (let j = 0; j < this.moov.traks.length; j++) { const trak = this.moov.traks[j]; - if (trak.tkhd.track_id === id) { - return trak; - } + if (trak.tkhd.track_id === id) return trak; } return null; } @@ -1846,15 +1825,9 @@ export class ISOFile { const items = this.items; const entity_groups = this.entity_groups; const meta = this.meta; - if (meta === null || meta === undefined) { - return; - } - if (meta.hdlr === undefined) { - return; - } - if (meta.iinf === undefined) { - return; - } + if (meta === null || meta === undefined) return; + if (meta.hdlr === undefined) return; + if (meta.iinf === undefined) return; for (let i = 0; i < meta.iinf.item_infos.length; i++) { const id = meta.iinf.item_infos[i].item_ID; items[id] = { @@ -2153,9 +2126,7 @@ export class ISOFile { } else { item = this.getPrimaryItem(); } - if (item === null) { - return null; - } + if (item === null) return null; const file = new ISOFile(); file.discardMdatData = false; @@ -2209,7 +2180,7 @@ export class ISOFile { if (ret.type === 'mdat') { /* we had enough bytes to get its type and size and it's an 'mdat' */ - /* special handling for mdat boxes, since we don't actually need to parse it linearly + /* special handling for mdat boxes, since we don't actually need to parse it linearly we create the box */ const box = new mdatBox(ret.size); this.parsingMdat = box; @@ -2232,12 +2203,12 @@ export class ISOFile { /* 'mdat' end not found in the existing buffers */ /* determine the next position in the file to start parsing from */ if (!this.moovStartFound) { - /* moov not find yet, - the file probably has 'mdat' at the beginning, and 'moov' at the end, + /* moov not find yet, + the file probably has 'mdat' at the beginning, and 'moov' at the end, indicate that the downloader should not try to download those bytes now */ this.nextParsePosition = box.start + box.size; } else { - /* we have the start of the moov box, + /* we have the start of the moov box, the next bytes should try to complete the current 'mdat' */ this.nextParsePosition = this.stream.findEndContiguousBuf(); } @@ -2255,12 +2226,12 @@ export class ISOFile { } /* either it's not an mdat box (and we need to parse it, we cannot skip it) (TODO: we could skip 'free' boxes ...) - or we did not have enough data to parse the type and size of the box, + or we did not have enough data to parse the type and size of the box, we try to concatenate the current buffer with the next buffer to restart parsing */ const merged = this.stream.mergeNextBuffer ? this.stream.mergeNextBuffer() : false; if (merged) { /* The next buffer was contiguous, the merging succeeded, - we can now continue parsing, + we can now continue parsing, the next best position to parse is at the end of this new buffer */ this.nextParsePosition = this.stream.getEndPosition(); return true; @@ -2273,7 +2244,7 @@ export class ISOFile { this.nextParsePosition = this.stream.getEndPosition(); } else { /* we had enough bytes to parse size and type of the incomplete box - if we haven't found yet the moov box, skip this one and try the next one + if we haven't found yet the moov box, skip this one and try the next one if we have found the moov box, let's continue linear parsing */ if (this.moovStartFound) { this.nextParsePosition = this.stream.getEndPosition(); @@ -2303,8 +2274,8 @@ export class ISOFile { /* we can parse more in this buffer */ return true; } else { - /* we don't have the end of this mdat yet, - indicate that the next byte to fetch is the end of the buffers we have so far, + /* we don't have the end of this mdat yet, + indicate that the next byte to fetch is the end of the buffers we have so far, return and wait for more buffer to come */ this.nextParsePosition = this.stream.findEndContiguousBuf(); return false; @@ -2414,9 +2385,7 @@ export class ISOFile { const sampleEntry = BoxRegistry[`${options.type}SampleEntry`]; - if (!sampleEntry) { - return; - } + if (!sampleEntry) return; const sample_description_entry = new sampleEntry(); sample_description_entry.data_reference_index = 1; @@ -2537,14 +2506,12 @@ export class ISOFile { is_depended_on?: number; has_redundancy?: number; degradation_priority?: number; - subsamples?: SubSample[]; + subsamples?: Array; offset?: number; } = {}, ) { const trak = this.getTrackById(track_id); - if (trak === null) { - return; - } + if (trak === null) return; const descriptionIndex = sample_description_index ? sample_description_index - 1 : 0; @@ -2593,12 +2560,9 @@ export class ISOFile { /** @bundle isofile-advanced-creation.js */ createSingleSampleMoof(sample: Sample) { let sample_flags = 0; - if (sample.is_sync) { - sample_flags = 1 << 25; - } // sample_depends_on_none (I picture) - else { - sample_flags = 1 << 16; - } // non-sync + if (sample.is_sync) + sample_flags = 1 << 25; // sample_depends_on_none (I picture) + else sample_flags = 1 << 16; // non-sync const moof = new moofBox(); diff --git a/src/log.ts b/src/log.ts index 7e8f6aa7..3807fab6 100644 --- a/src/log.ts +++ b/src/log.ts @@ -13,17 +13,11 @@ let log_level = LOG_LEVEL_ERROR; export const Log = { setLogLevel(level: (module: string, msg?: string) => void) { - if (level === this.debug) { - log_level = LOG_LEVEL_DEBUG; - } else if (level === this.info) { - log_level = LOG_LEVEL_INFO; - } else if (level === this.warn) { - log_level = LOG_LEVEL_WARNING; - } else if (level === this.error) { - log_level = LOG_LEVEL_ERROR; - } else { - log_level = LOG_LEVEL_ERROR; - } + if (level === this.debug) log_level = LOG_LEVEL_DEBUG; + else if (level === this.info) log_level = LOG_LEVEL_INFO; + else if (level === this.warn) log_level = LOG_LEVEL_WARNING; + else if (level === this.error) log_level = LOG_LEVEL_ERROR; + else log_level = LOG_LEVEL_ERROR; }, debug(module: string, msg?: string) { if (console.debug === undefined) { @@ -72,7 +66,7 @@ export const Log = { let neg: boolean; /* Helper function to print a number on a fixed number of digits */ function pad(number: string | number, length: number) { - const str = String(number); + const str = '' + number; const a = str.split('.'); while (a[0].length < length) { a[0] = '0' + a[0]; @@ -116,9 +110,7 @@ export const Log = { if (length > 0) { let str = ''; for (let i = 0; i < length; i++) { - if (i > 0) { - str += ','; - } + if (i > 0) str += ','; str += '[' + Log.getDurationString(ranges.start(i)) + diff --git a/src/stream.ts b/src/stream.ts index 0fa0030f..f6abdac8 100644 --- a/src/stream.ts +++ b/src/stream.ts @@ -8,7 +8,7 @@ export class MP4BoxStream { this.buffer = arrayBuffer; this.dataview = new DataView(arrayBuffer); } else { - throw new Error('Needs an array buffer'); + throw 'Needs an array buffer'; } } @@ -62,7 +62,7 @@ export class MP4BoxStream { break; case 3: if (signed) { - throw new Error('No method for reading signed 24 bits values'); + throw 'No method for reading signed 24 bits values'; } else { res = this.dataview.getUint8(this.position) << 16; res |= this.dataview.getUint8(this.position + 1) << 8; @@ -78,19 +78,19 @@ export class MP4BoxStream { break; case 8: if (signed) { - throw new Error('No method for reading signed 64 bits values'); + throw 'No method for reading signed 64 bits values'; } else { res = this.dataview.getUint32(this.position) << 32; res |= this.dataview.getUint32(this.position + 4); } break; default: - throw new Error(`readInt method not implemented for size: ${size}`); + throw 'readInt method not implemented for size: ' + size; } this.position += size; return res; } else { - throw new Error('Not enough bytes in buffer'); + throw 'Not enough bytes in buffer'; } } @@ -122,7 +122,7 @@ export class MP4BoxStream { } return s; } else { - throw new Error('Not enough bytes in buffer'); + throw 'Not enough bytes in buffer'; } } diff --git a/src/text-mp4.ts b/src/text-mp4.ts index 16e2a183..fbcdac90 100644 --- a/src/text-mp4.ts +++ b/src/text-mp4.ts @@ -1,5 +1,4 @@ -import type { Box } from '#/box'; -import { parseOneBox } from '#/box'; +import { Box, parseOneBox } from '#/box'; import { OK } from '#/constants'; import { MP4BoxStream } from '#/stream'; import type { Sample, TypedArray } from '@types'; @@ -10,7 +9,7 @@ import type { Sample, TypedArray } from '@types'; */ export class VTTin4Parser { parseSample(data: TypedArray) { - const cues: Box[] = []; + const cues: Array = []; const stream = new MP4BoxStream(data.buffer); while (!stream.isEos()) { @@ -35,11 +34,12 @@ export class VTTin4Parser { const m = Math.floor((insec - h * 3600) / 60); const s = Math.floor(insec - h * 3600 - m * 60); const ms = Math.floor((insec - h * 3600 - m * 60 - s) * 1000); - return `${pad(h, 2)}:${pad(m, 2)}:${pad(s, 2)}.${pad(ms, 3)}`; + return '' + pad(h, 2) + ':' + pad(m, 2) + ':' + pad(s, 2) + '.' + pad(ms, 3); } const cues = this.parseSample(data); let string = ''; - for (const cueIn4 of cues) { + for (let i = 0; i < cues.length; i++) { + const cueIn4 = cues[i]; string += secToTimestamp(startTime) + ' --> ' + secToTimestamp(endTime) + '\r\n'; // @ts-expect-error FIXME: which box should get a payl-property? string += cueIn4.payl.text; @@ -51,7 +51,7 @@ export class VTTin4Parser { export class XMLSubtitlein4Parser { parseSample(sample: Sample) { const res = { - resources: [] as Uint8Array[], + resources: [] as Array, documentString: '', document: undefined as undefined | Document, }; @@ -76,12 +76,14 @@ export class XMLSubtitlein4Parser { export class Textin4Parser { parseSample(sample: Sample) { const stream = new MP4BoxStream(sample.data.buffer); - return stream.readString(sample.data.length); + const textString = stream.readString(sample.data.length); + return textString; } parseConfig(data: TypedArray) { const stream = new MP4BoxStream(data.buffer); stream.readUint32(); // version & flags - return stream.readCString(); + const textString = stream.readCString(); + return textString; } } diff --git a/tsup.config.ts b/tsup.config.ts index 548f6df6..8d870ede 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -30,7 +30,7 @@ const regularBuild = defineConfig({ dts: true, }); -const build: (typeof iifeBuild | typeof regularBuild)[] = []; +const build: Array = []; if (PUBLISH_TO_NPM) { build.push(regularBuild); } else { From 6fef57aa56f9b3789b7b5e8328d43c3f71d78fe2 Mon Sep 17 00:00:00 2001 From: DenizUgur Date: Mon, 26 May 2025 17:16:15 -0700 Subject: [PATCH 14/16] fix: dfLa --- src/boxes/dfLa.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/boxes/dfLa.ts b/src/boxes/dfLa.ts index d9ff25d0..a2c385a7 100644 --- a/src/boxes/dfLa.ts +++ b/src/boxes/dfLa.ts @@ -47,7 +47,7 @@ export class dfLaBox extends FullBox { } boxesFound.push(knownBlockTypes[type]); - } while (!(flagAndType & LASTMETADATABLOCKFLAG_MASK)); + } while (flagAndType & LASTMETADATABLOCKFLAG_MASK); this.numMetadataBlocks = boxesFound.length + ' (' + boxesFound.join(', ') + ')'; } From 72c27514c5073daae24f812b203ece25eefe8653 Mon Sep 17 00:00:00 2001 From: DenizUgur Date: Mon, 26 May 2025 17:17:58 -0700 Subject: [PATCH 15/16] chore: remove obsolete deps --- package-lock.json | 81 ----------------------------------------------- package.json | 2 -- 2 files changed, 83 deletions(-) diff --git a/package-lock.json b/package-lock.json index d51537f6..e578e9f7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,13 +12,11 @@ "@commitlint/cli": "^19.8.1", "@commitlint/config-conventional": "^19.8.1", "@eslint/js": "^9.27.0", - "@eslint/json": "^0.12.0", "@types/node": "^22.15.21", "dpdm": "^3.14.0", "eslint": "^9.27.0", "eslint-config-prettier": "^10.1.5", "eslint-plugin-prettier": "^5.4.0", - "globals": "^16.2.0", "husky": "^9.1.7", "prettier": "^3.5.3", "tsup": "^8.3.5", @@ -856,19 +854,6 @@ "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, - "node_modules/@eslint/core": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.12.0.tgz", - "integrity": "sha512-cmrR6pytBuSMTaBweKoGMwu3EiHiEC+DoyupPmlZ0HxBJBtIxwe+j/E4XPIKNx+Q74c8lXKPwYawBf5glsTkHg==", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "@types/json-schema": "^7.0.15" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - } - }, "node_modules/@eslint/eslintrc": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.3.1.tgz", @@ -943,22 +928,6 @@ "url": "https://eslint.org/donate" } }, - "node_modules/@eslint/json": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/@eslint/json/-/json-0.12.0.tgz", - "integrity": "sha512-n/7dz8HFStpEe4o5eYk0tdkBdGUS/ZGb0GQCeDWN1ZmRq67HMHK4vC33b0rQlTT6xdZoX935P4vstiWVk5Ying==", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "@eslint/core": "^0.12.0", - "@eslint/plugin-kit": "^0.2.7", - "@humanwhocodes/momoa": "^3.3.4", - "natural-compare": "^1.4.0" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - } - }, "node_modules/@eslint/object-schema": { "version": "2.1.6", "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-2.1.6.tgz", @@ -969,33 +938,6 @@ "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, - "node_modules/@eslint/plugin-kit": { - "version": "0.2.8", - "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.2.8.tgz", - "integrity": "sha512-ZAoA40rNMPwSm+AeHpCq8STiNAwzWLJuP8Xv4CHIc9wv/PSuExjMrmjfYNj682vW0OOiZ1HKxzvjQr9XZIisQA==", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "@eslint/core": "^0.13.0", - "levn": "^0.4.1" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - } - }, - "node_modules/@eslint/plugin-kit/node_modules/@eslint/core": { - "version": "0.13.0", - "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.13.0.tgz", - "integrity": "sha512-yfkgDw1KR66rkT5A8ci4irzDysN7FRpq3ttJolR88OqQikAWqwA8j5VZyas+vjyBNFIJ7MfybJ9plMILI2UrCw==", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "@types/json-schema": "^7.0.15" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - } - }, "node_modules/@humanfs/core": { "version": "0.19.1", "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.1.tgz", @@ -1048,16 +990,6 @@ "url": "https://github.com/sponsors/nzakas" } }, - "node_modules/@humanwhocodes/momoa": { - "version": "3.3.8", - "resolved": "https://registry.npmjs.org/@humanwhocodes/momoa/-/momoa-3.3.8.tgz", - "integrity": "sha512-/3PZzor2imi/RLLcnHztkwA79txiVvW145Ve2cp5dxRcH5qOUNJPToasqLFHniTfw4B4lT7jGDdBOPXbXYlIMQ==", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": ">=18" - } - }, "node_modules/@humanwhocodes/retry": { "version": "0.4.3", "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.4.3.tgz", @@ -3162,19 +3094,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/globals": { - "version": "16.2.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-16.2.0.tgz", - "integrity": "sha512-O+7l9tPdHCU320IigZZPj5zmRCFG9xHmx9cU8FqU2Rp+JN714seHV+2S9+JslCpY4gJwU2vOGox0wzgae/MCEg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/graceful-fs": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz", diff --git a/package.json b/package.json index fbdb2837..bb0b599e 100644 --- a/package.json +++ b/package.json @@ -61,13 +61,11 @@ "@commitlint/cli": "^19.8.1", "@commitlint/config-conventional": "^19.8.1", "@eslint/js": "^9.27.0", - "@eslint/json": "^0.12.0", "@types/node": "^22.15.21", "dpdm": "^3.14.0", "eslint": "^9.27.0", "eslint-config-prettier": "^10.1.5", "eslint-plugin-prettier": "^5.4.0", - "globals": "^16.2.0", "husky": "^9.1.7", "prettier": "^3.5.3", "tsup": "^8.3.5", From 465368f3a596e1e81cdfe93a92101997d5a46f39 Mon Sep 17 00:00:00 2001 From: DenizUgur Date: Mon, 26 May 2025 17:26:13 -0700 Subject: [PATCH 16/16] chore: revert editorconfig --- .editorconfig | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 6e87a003..00000000 --- a/.editorconfig +++ /dev/null @@ -1,13 +0,0 @@ -# Editor configuration, see http://editorconfig.org -root = true - -[*] -charset = utf-8 -indent_style = space -indent_size = 2 -insert_final_newline = true -trim_trailing_whitespace = true - -[*.md] -max_line_length = off -trim_trailing_whitespace = false