From 590545e40e55e18019ad81e25d1d5dfc985958bb Mon Sep 17 00:00:00 2001 From: Yahweasel Date: Thu, 19 Dec 2024 09:28:15 -0500 Subject: [PATCH] Adding a types-only package --- Makefile | 8 ++++++++ Makefile.m4 | 8 ++++++++ README.md | 5 ++++- package-one-variant.json | 2 +- package-types-only.json | 28 ++++++++++++++++++++++++++++ 5 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 package-types-only.json diff --git a/Makefile b/Makefile index d4a8c5b..70d579a 100644 --- a/Makefile +++ b/Makefile @@ -927,6 +927,7 @@ release: extract mkdir dist/release/libav.js-$(LIBAVJS_VERSION) cp -a README.md docs dist/release/libav.js-$(LIBAVJS_VERSION)/ mkdir dist/release/libav.js-$(LIBAVJS_VERSION)/dist + $(MAKE) dist/release/libav.js-types-$(LIBAVJS_VERSION) for v in $(RELEASE_VARIANTS); \ do \ $(MAKE) build-$$v; \ @@ -959,6 +960,12 @@ dist/release/libav.js-$(LIBAVJS_VERSION)-%: build-% sed 's/@VARIANT/$(*)/g ; s/@VERSION/$(LIBAVJS_VERSION)/g ; s/@VER/$(LIBAVJS_VERSION_SHORT)/g' \ package-one-variant.json > $(@)/package.json +dist/release/libav.js-types-$(LIBAVJS_VERSION): dist/libav.types.d.ts + mkdir -p $(@)/dist + cp dist/libav.types.d.ts $(@)/dist + sed 's/@VERSION/$(LIBAVJS_VERSION)/g ; s/@VER/$(LIBAVJS_VERSION_SHORT)/g' \ + package-types-only.json > $(@)/package.json + npm-publish: cd dist/release && unzip libav.js-$(LIBAVJS_VERSION).zip cd dist/release/libav.js-$(LIBAVJS_VERSION) && \ @@ -966,6 +973,7 @@ npm-publish: rm -f dist/*.dbg.* dist/*-av1* dist/*-vp9* dist/*.asm.mjs && \ npm publish rm -rf dist/release/libav.js-$(LIBAVJS_VERSION) + ( cd dist/release/libav.js-types-$(LIBAVJS_VERSION) && npm publish --access=public ) for v in $(RELEASE_VARIANTS); \ do \ ( cd dist/release/libav.js-$(LIBAVJS_VERSION)-$$v && npm publish --access=public ) \ diff --git a/Makefile.m4 b/Makefile.m4 index dcfc7fa..72f7f73 100644 --- a/Makefile.m4 +++ b/Makefile.m4 @@ -187,6 +187,7 @@ release: extract mkdir dist/release/libav.js-$(LIBAVJS_VERSION) cp -a README.md docs dist/release/libav.js-$(LIBAVJS_VERSION)/ mkdir dist/release/libav.js-$(LIBAVJS_VERSION)/dist + $(MAKE) dist/release/libav.js-types-$(LIBAVJS_VERSION) for v in $(RELEASE_VARIANTS); \ do \ $(MAKE) build-$$v; \ @@ -219,6 +220,12 @@ dist/release/libav.js-$(LIBAVJS_VERSION)-%: build-% sed 's/@VARIANT/$(*)/g ; s/@VERSION/$(LIBAVJS_VERSION)/g ; s/@VER/$(LIBAVJS_VERSION_SHORT)/g' \ package-one-variant.json > $(@)/package.json +dist/release/libav.js-types-$(LIBAVJS_VERSION): dist/libav.types.d.ts + mkdir -p $(@)/dist + cp dist/libav.types.d.ts $(@)/dist + sed 's/@VERSION/$(LIBAVJS_VERSION)/g ; s/@VER/$(LIBAVJS_VERSION_SHORT)/g' \ + package-types-only.json > $(@)/package.json + npm-publish: cd dist/release && unzip libav.js-$(LIBAVJS_VERSION).zip cd dist/release/libav.js-$(LIBAVJS_VERSION) && \ @@ -226,6 +233,7 @@ npm-publish: rm -f dist/*.dbg.* dist/*-av1* dist/*-vp9* dist/*.asm.mjs && \ npm publish rm -rf dist/release/libav.js-$(LIBAVJS_VERSION) + ( cd dist/release/libav.js-types-$(LIBAVJS_VERSION) && npm publish --access=public ) for v in $(RELEASE_VARIANTS); \ do \ ( cd dist/release/libav.js-$(LIBAVJS_VERSION)-$$v && npm publish --access=public ) \ diff --git a/README.md b/README.md index b122b9b..8410ada 100644 --- a/README.md +++ b/README.md @@ -161,7 +161,10 @@ released version, it is sufficient to provide the `sources` directory. libav.js is published to NPM as `libav.js`, and each released variant is published in a much smaller NPM package as `@libav.js/variant-`. The -CDN example above uses the `@libav.js/variant-default` package, for example. +CDN example above uses the `@libav.js/variant-default` package, for example. The +`@libav.js/types` package is also provided with only the types (`.d.ts` file), +and if using TypeScript, you are highly recommended to use it, to avoid bringing +entire variants in as dependencies of your own packages. ### Why the version number in the filenames? diff --git a/package-one-variant.json b/package-one-variant.json index b763e62..667c2f3 100644 --- a/package-one-variant.json +++ b/package-one-variant.json @@ -1,7 +1,7 @@ { "name": "@libav.js/variant-@VARIANT", "version": "@VER", - "description": "A compilation of the libraries associated with handling audio and video in ffmpeg—libavformat, libavcodec, libavfilter, libavutil and libswresample—for WebAssembly and asm.js, and thus the web.", + "description": "A compilation of the libraries associated with handling audio and video in ffmpeg—libavformat, libavcodec, libavfilter, libavutil and libswresample—for WebAssembly and asm.js, and thus the web. This package includes only one variant.", "main": "dist/libav-@VARIANT.js", "types": "dist/libav.types.d.ts", "exports": { diff --git a/package-types-only.json b/package-types-only.json new file mode 100644 index 0000000..352aea7 --- /dev/null +++ b/package-types-only.json @@ -0,0 +1,28 @@ +{ + "name": "@libav.js/types", + "version": "@VER", + "description": "A compilation of the libraries associated with handling audio and video in ffmpeg—libavformat, libavcodec, libavfilter, libavutil and libswresample—for WebAssembly and asm.js, and thus the web. This package includes only the types.", + "types": "dist/libav.types.d.ts", + "repository": { + "type": "git", + "url": "git+https://github.com/Yahweasel/libav.js.git" + }, + "keywords": [ + "ffmpeg", + "libav", + "audio", + "video", + "av", + "encode", + "decode", + "transcode", + "mux", + "demux" + ], + "author": "Yahweasel", + "license": "LGPL-2.1", + "bugs": { + "url": "https://github.com/Yahweasel/libav.js/issues" + }, + "homepage": "https://github.com/Yahweasel/libav.js#readme" +}