Compare commits

15 Commits

Author SHA1 Message Date
4bc9acdada fix: added missing ffprobe-wasm.mjs & renamed to match repo 2026-02-26 23:57:03 +01:00
f97fb957dc fix?: undefined tags
Signed-off-by: Alix von Schirp <github@avonschirp.bootmedia.de>
2026-02-22 18:23:29 +01:00
d9013772ef chore: bump pre-release-minor, update submod ref
Signed-off-by: Alix von Schirp <github@avonschirp.bootmedia.de>
2026-02-22 01:58:57 +01:00
fad46dbae1 chore: update package.json
Signed-off-by: Alix von Schirp <github@avonschirp.bootmedia.de>
2026-02-21 01:28:05 +01:00
98151ecaef chore: update submodule ref
Signed-off-by: Alix von Schirp <github@avonschirp.bootmedia.de>
2026-02-19 21:51:48 +01:00
efa4e6f0a2 chore: update submodule ref
Signed-off-by: Alix von Schirp <github@avonschirp.bootmedia.de>
2026-02-19 21:42:09 +01:00
24a55c018f fix: make vite 7 compliant
Signed-off-by: Alix von Schirp <github@avonschirp.bootmedia.de>
2026-02-19 20:38:55 +01:00
bc9e1670b2 fix: add vite plugins for wasm
Signed-off-by: Alix von Schirp <github@avonschirp.bootmedia.de>
2026-02-19 13:44:55 +01:00
c0e13cdaa1 chore: update submodule ref
Signed-off-by: Alix von Schirp <github@avonschirp.bootmedia.de>
2026-02-19 13:44:39 +01:00
3d1951c50a chore: update submodule ref
Signed-off-by: Alix von Schirp <github@avonschirp.bootmedia.de>
2026-02-19 12:43:27 +01:00
90864d1b05 fix: rename ffprobe-wasm.js to .mjs on build
Signed-off-by: Alix von Schirp <github@avonschirp.bootmedia.de>
2026-02-19 12:36:22 +01:00
e7dbb8c0c9 chore: update submodule ref
Signed-off-by: Alix von Schirp <github@avonschirp.bootmedia.de>
2026-02-19 10:05:02 +01:00
cece48aaeb chore: change submodule ref
Signed-off-by: Alix von Schirp <github@avonschirp.bootmedia.de>
2026-02-18 22:50:08 +01:00
5214d5c530 chore: updates to submodule
Signed-off-by: Alix von Schirp <github@avonschirp.bootmedia.de>
2026-02-18 21:30:44 +01:00
ff2bef3e9c deps: update devDependencies
Signed-off-by: Alix von Schirp <github@avonschirp.bootmedia.de>
2026-02-18 20:40:23 +01:00
8 changed files with 1921 additions and 695 deletions

2
.gitmodules vendored
View File

@@ -1,3 +1,3 @@
[submodule "ffprobe-wasm-app"] [submodule "ffprobe-wasm-app"]
path = ffprobe-wasm-app path = ffprobe-wasm-app
url = https://github.com/alfg/ffprobe-wasm url = https://git.cislabs.de/cis-oss/ffprobe-wasm

View File

@@ -12,14 +12,13 @@ cd ffprobe-wasm-app
docker-compose run ffprobe-wasm make docker-compose run ffprobe-wasm make
cd .. cd ..
cp -R ffprobe-wasm-app/dist dist cp -R ffprobe-wasm-app/dist dist
node scripts/replace.js
cp src/*.d.* dist cp src/*.d.* dist
# Build browser/node workers # Build browser/node workers
npm run build npm run build
# Remove unnecessary files # Remove unnecessary files
rm dist/browser-vite.* dist/ffprobe-wasm.d.mts dist/ffprobe-wasm.mjs dist/worker-browser.* rm dist/browser-vite.* dist/worker-browser.*
# Copy files for npm publish # Copy files for npm publish
cp package.json LICENSE README.md dist cp package.json LICENSE README.md dist

2522
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,13 +1,10 @@
{ {
"name": "ffprobe-wasm", "name": "@cis-oss/avprobe-wasm",
"version": "0.3.0", "version": "0.3.2",
"description": "ffprobe-like for browser and node, powered by WebAssembly", "description": "ffprobe-like for browser and node, powered by WebAssembly",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/tfoxy/ffprobe-wasm" "url": "https://git.cislabs.de/cis-oss/ffprobe-wasm-npm"
},
"bugs": {
"url": "https://github.com/tfoxy/ffprobe-wasm/issues"
}, },
"keywords": [ "keywords": [
"ffprobe", "ffprobe",
@@ -15,7 +12,11 @@
"ffmpeg", "ffmpeg",
"video" "video"
], ],
"author": "Tomás Fox <tomas.c.fox@gmail.com>", "author": {
"name": "Alix von Schirp",
"url": "https://b00tload.space",
"email": "hi@b00tload.space"
},
"license": "MIT", "license": "MIT",
"exports": { "exports": {
"node": "./node.mjs", "node": "./node.mjs",
@@ -31,8 +32,10 @@
"vite": "vite build" "vite": "vite build"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^17.0.21", "@types/node": "^25.2.3",
"typescript": "^4.5.5", "typescript": "^5.9.3",
"vite": "^2.8.6" "vite": "^7.3.1",
"vite-plugin-top-level-await": "^1.6.0",
"vite-plugin-wasm": "^3.5.0"
} }
} }

View File

@@ -1,27 +0,0 @@
const { readFile, writeFile } = require("fs/promises");
const { dirname, resolve } = require("path");
main();
async function main() {
const root = dirname(__dirname);
const wasmJsPath = resolve(root, "dist/ffprobe-wasm.mjs");
let content = await readFile(wasmJsPath, { encoding: "utf8" });
content = `\
import initWasmInstance from "./ffprobe-wasm.wasm";
const initWasm = (info) =>
initWasmInstance(info).then((exports) => ({ instance: { exports } }));
${content}`;
content = content.replace(`import.meta.url`, `''`);
content = content.replace(
`instantiateAsync().catch(readyPromiseReject)`,
`initWasm(info).then(receiveInstantiatedSource, readyPromiseReject)`
);
await writeFile(wasmJsPath, content, { encoding: "utf8" });
}

View File

@@ -92,7 +92,7 @@ export function createListener(
function serializeStreams(streams: Vector<Raw<Stream>>) { function serializeStreams(streams: Vector<Raw<Stream>>) {
return vectorToArray(streams).map((stream) => ({ return vectorToArray(streams).map((stream) => ({
...stream, ...stream,
tags: dictionaryVectorToRecord(stream.tags), tags: (stream && stream.tags) ? dictionaryVectorToRecord(stream.tags) : {},
})); }));
} }
@@ -109,16 +109,19 @@ export function createListener(
const rawInfo = get_file_info(`/work/${fileName}`); const rawInfo = get_file_info(`/work/${fileName}`);
// Safety check on rawInfo itself
if (!rawInfo) throw new Error("FFprobe failed to return file info");
return { return {
streams: serializeStreams(rawInfo.streams), streams: serializeStreams(rawInfo.streams),
chapters: vectorToArray(rawInfo.chapters).map((chapter) => ({ chapters: rawInfo.chapters ? vectorToArray(rawInfo.chapters).map((chapter) => ({
...chapter, ...chapter,
tags: dictionaryVectorToRecord(chapter.tags), tags: chapter.tags ? dictionaryVectorToRecord(chapter.tags) : {},
})), })) : [],
format: { format: {
...rawInfo.format, ...rawInfo.format,
tags: dictionaryVectorToRecord(rawInfo.format.tags), tags: (rawInfo.format && rawInfo.format.tags) ? dictionaryVectorToRecord(rawInfo.format.tags) : {},
}, }
}; };
} finally { } finally {
// Cleanup mount. // Cleanup mount.

View File

@@ -1,5 +1,7 @@
import { resolve } from "path"; import { resolve } from "path";
import { defineConfig } from "vite"; import { defineConfig } from "vite";
import topLevelAwait from "vite-plugin-top-level-await";
import wasm from "vite-plugin-wasm";
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default defineConfig({ export default defineConfig({
@@ -14,18 +16,16 @@ export default defineConfig({
minify: false, minify: false,
sourcemap: true, sourcemap: true,
}, },
worker: {
plugins: [ plugins: [
{
name: "append-source-url", wasm(),
generateBundle(options, bundle) { topLevelAwait()
Object.entries(bundle).forEach(([file, output]) => {
if (output.type === "chunk") {
output.code += `\n//# sourceURL=${file}`;
}
});
},
},
], ],
worker: {
plugins: () => [
wasm(),
topLevelAwait(),
],
format: "es"
}, },
}); });