From 33d90df844a7e35592e5de547ca4bdd96cfc579c Mon Sep 17 00:00:00 2001 From: Jerome Wu Date: Thu, 8 Sep 2022 18:04:55 +0800 Subject: [PATCH] Migrate to @types --- apps/node-ts/package.json | 1 + package-lock.json | 24 ++++++++++++++++++++++-- packages/libav-core-mt/package.json | 4 ++++ packages/libav/package.json | 1 + packages/libav/src/libav.ts | 10 ++++++---- packages/libav/src/open-media.ts | 8 ++++++++ 6 files changed, 42 insertions(+), 6 deletions(-) diff --git a/apps/node-ts/package.json b/apps/node-ts/package.json index e75ac6a..294ca59 100644 --- a/apps/node-ts/package.json +++ b/apps/node-ts/package.json @@ -24,6 +24,7 @@ "@ffmpeg/libav": "^0.0.1-alpha.0", "@ffmpeg/libav-core": "^0.0.1-alpha.1", "@ffmpeg/libav-core-mt": "^0.0.1-alpha.1", + "@types/ffmpeg__libav-core": "^0.0.0", "ts-node": "^10.9.1" } } diff --git a/package-lock.json b/package-lock.json index 8088dbd..7c40012 100644 --- a/package-lock.json +++ b/package-lock.json @@ -29,6 +29,7 @@ "@ffmpeg/libav": "^0.0.1-alpha.0", "@ffmpeg/libav-core": "^0.0.1-alpha.1", "@ffmpeg/libav-core-mt": "^0.0.1-alpha.1", + "@types/ffmpeg__libav-core": "^0.0.0", "ts-node": "^10.9.1" } }, @@ -2191,6 +2192,11 @@ "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.3.tgz", "integrity": "sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==" }, + "node_modules/@types/ffmpeg__libav-core": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/@types/ffmpeg__libav-core/-/ffmpeg__libav-core-0.0.0.tgz", + "integrity": "sha512-n4UJAwyTUUms4EwHVLYagD+RgAd1Y65dLpoTxuK1VI4Aoi4X/EuJDCo1P+Qk96dUeFoWx/Rhj7Y9N90CI5g1Dg==" + }, "node_modules/@types/json-schema": { "version": "7.0.11", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", @@ -9201,6 +9207,7 @@ "version": "0.0.1-alpha.0", "license": "MIT", "dependencies": { + "@types/ffmpeg__libav-core": "^0.0.0", "@types/node": "^18.7.8" }, "devDependencies": { @@ -9216,7 +9223,10 @@ "packages/libav-core-mt": { "name": "@ffmpeg/libav-core-mt", "version": "0.0.1-alpha.1", - "license": "MIT" + "license": "MIT", + "dependencies": { + "@types/ffmpeg__libav-core": "^0.0.0" + } }, "packages/libav-type": { "version": "0.0.1-alpha.0", @@ -9586,6 +9596,7 @@ "@ffmpeg/libav": { "version": "file:packages/libav", "requires": { + "@types/ffmpeg__libav-core": "^0.0.0", "@types/node": "^18.7.8", "rimraf": "^3.0.2", "typescript": "^4.8.2" @@ -9595,7 +9606,10 @@ "version": "file:packages/libav-core" }, "@ffmpeg/libav-core-mt": { - "version": "file:packages/libav-core-mt" + "version": "file:packages/libav-core-mt", + "requires": { + "@types/ffmpeg__libav-core": "*" + } }, "@gar/promisify": { "version": "1.1.3", @@ -11014,6 +11028,11 @@ "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.3.tgz", "integrity": "sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==" }, + "@types/ffmpeg__libav-core": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/@types/ffmpeg__libav-core/-/ffmpeg__libav-core-0.0.0.tgz", + "integrity": "sha512-n4UJAwyTUUms4EwHVLYagD+RgAd1Y65dLpoTxuK1VI4Aoi4X/EuJDCo1P+Qk96dUeFoWx/Rhj7Y9N90CI5g1Dg==" + }, "@types/json-schema": { "version": "7.0.11", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", @@ -14122,6 +14141,7 @@ "@ffmpeg/libav": "^0.0.1-alpha.0", "@ffmpeg/libav-core": "^0.0.1-alpha.1", "@ffmpeg/libav-core-mt": "^0.0.1-alpha.1", + "@types/ffmpeg__libav-core": "^0.0.0", "ts-node": "^10.9.1" } }, diff --git a/packages/libav-core-mt/package.json b/packages/libav-core-mt/package.json index 1040526..4534038 100644 --- a/packages/libav-core-mt/package.json +++ b/packages/libav-core-mt/package.json @@ -3,6 +3,7 @@ "version": "0.0.1-alpha.1", "description": "libav WebAssembly port", "main": "dist/libav-core.js", + "types": "dist/index.d.ts", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -24,5 +25,8 @@ "homepage": "https://github.com/ffmpegwasm/libav.wasm#readme", "publishConfig": { "access": "public" + }, + "dependencies": { + "@types/ffmpeg__libav-core": "^0.0.0" } } diff --git a/packages/libav/package.json b/packages/libav/package.json index 24a51dc..288c813 100644 --- a/packages/libav/package.json +++ b/packages/libav/package.json @@ -30,6 +30,7 @@ "access": "public" }, "dependencies": { + "@types/ffmpeg__libav-core": "^0.0.0", "@types/node": "^18.7.8" }, "devDependencies": { diff --git a/packages/libav/src/libav.ts b/packages/libav/src/libav.ts index 18ec2dd..289d4d9 100644 --- a/packages/libav/src/libav.ts +++ b/packages/libav/src/libav.ts @@ -1,12 +1,14 @@ -import { LibavCore } from "../../libav-type/index.d"; +import LibavCoreFactory from "ffmpeg__libav-core"; -let libav: LibavCore; +type Libav = Awaited>; -export const initLibav = (_libav: LibavCore) => { +let libav: Libav; + +export const initLibav = (_libav: Libav) => { libav = _libav; }; -export const getLibav = () => { +export const getLibav = (): Libav => { if (!libav) { console.error( "libav is not initialized, initLibav() should be called first!" diff --git a/packages/libav/src/open-media.ts b/packages/libav/src/open-media.ts index d8cfa18..30b78e8 100644 --- a/packages/libav/src/open-media.ts +++ b/packages/libav/src/open-media.ts @@ -4,13 +4,21 @@ import { getLibav } from "./libav"; export function openMedia(filename: string): IAVFormatContenxt | null { const { NULL, + // @ts-ignore _avformat_alloc_context, + // @ts-ignore _avformat_open_input, + // @ts-ignore _avformat_find_stream_info, + // @ts-ignore ref, + // @ts-ignore deref, + // @ts-ignore stringToPtr, + // @ts-ignore _free, + // @ts-ignore AVFormatContext, } = getLibav();