@better-media/plugin-media-processing 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +35 -0
- package/dist/index.d.mts +19 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +38 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 abenezeratnafu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
|
20
|
+
ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# @better-media/plugin-media-processing
|
|
2
|
+
|
|
3
|
+
Media processing (image, video) plugin for the Better Media framework.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Image Resizing**: Resize to specific dimensions or percentages.
|
|
8
|
+
- **Transcoding**: Convert to WebP, AVIF, JPEG, or other formats.
|
|
9
|
+
- **Sharp-based**: Uses high-performance Node.js processing.
|
|
10
|
+
- **Background Support**: Supports enqueuing processing jobs via job adapters.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pnpm add @better-media/plugin-media-processing sharp
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { mediaProcessingPlugin } from "@better-media/plugin-media-processing";
|
|
22
|
+
|
|
23
|
+
const media = createBetterMedia({
|
|
24
|
+
plugins: [
|
|
25
|
+
mediaProcessingPlugin({
|
|
26
|
+
outputs: [
|
|
27
|
+
{ suffix: "-thumbnail", width: 200 },
|
|
28
|
+
{ suffix: "-high-res", format: "webp" },
|
|
29
|
+
],
|
|
30
|
+
}),
|
|
31
|
+
],
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
See the [better-media.dev/docs/plugins/media-processing](https://better-media.dev/docs/plugins/media-processing) for more configuration options.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { PipelinePlugin } from '@better-media/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Media processing plugin configuration (stub; no image/video processing yet).
|
|
5
|
+
*/
|
|
6
|
+
interface MediaProcessingPluginOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Execution mode. Default: "background".
|
|
9
|
+
*/
|
|
10
|
+
executionMode?: "sync" | "background";
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Media processing plugin for the Better Media pipeline (stub).
|
|
15
|
+
* Currently logs on `process:run`; thumbnail/metadata handling is not implemented.
|
|
16
|
+
*/
|
|
17
|
+
declare function mediaProcessingPlugin(opts?: MediaProcessingPluginOptions): PipelinePlugin;
|
|
18
|
+
|
|
19
|
+
export { type MediaProcessingPluginOptions, mediaProcessingPlugin };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { PipelinePlugin } from '@better-media/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Media processing plugin configuration (stub; no image/video processing yet).
|
|
5
|
+
*/
|
|
6
|
+
interface MediaProcessingPluginOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Execution mode. Default: "background".
|
|
9
|
+
*/
|
|
10
|
+
executionMode?: "sync" | "background";
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Media processing plugin for the Better Media pipeline (stub).
|
|
15
|
+
* Currently logs on `process:run`; thumbnail/metadata handling is not implemented.
|
|
16
|
+
*/
|
|
17
|
+
declare function mediaProcessingPlugin(opts?: MediaProcessingPluginOptions): PipelinePlugin;
|
|
18
|
+
|
|
19
|
+
export { type MediaProcessingPluginOptions, mediaProcessingPlugin };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/runtime/runner.ts
|
|
4
|
+
async function runMediaProcessing(context, _api, opts) {
|
|
5
|
+
const { file } = context;
|
|
6
|
+
console.log("[media-processing] process:run (stub \u2014 sharp/ffmpeg disabled)", {
|
|
7
|
+
key: file.key,
|
|
8
|
+
mimeType: file.mimeType,
|
|
9
|
+
executionMode: opts.executionMode ?? "background"
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// src/index.ts
|
|
14
|
+
function mediaProcessingPlugin(opts = {}) {
|
|
15
|
+
const executionMode = opts.executionMode ?? "background";
|
|
16
|
+
const isBackground = executionMode === "background";
|
|
17
|
+
return {
|
|
18
|
+
name: "media-processing",
|
|
19
|
+
runtimeManifest: {
|
|
20
|
+
id: "better-media-processing",
|
|
21
|
+
version: "1.0.0",
|
|
22
|
+
trustLevel: "untrusted",
|
|
23
|
+
capabilities: ["file.read", "metadata.write.own", "processing.write.own"],
|
|
24
|
+
namespace: "media-processing"
|
|
25
|
+
},
|
|
26
|
+
executionMode,
|
|
27
|
+
intensive: isBackground,
|
|
28
|
+
apply(runtime) {
|
|
29
|
+
runtime.hooks["process:run"].tap(
|
|
30
|
+
"media-processing",
|
|
31
|
+
async (context, api) => runMediaProcessing(context, api, opts),
|
|
32
|
+
{ mode: executionMode }
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
exports.mediaProcessingPlugin = mediaProcessingPlugin;
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/runtime/runner.ts","../src/index.ts"],"names":[],"mappings":";;;AAGA,eAAsB,kBAAA,CACpB,OAAA,EACA,IAAA,EACA,IAAA,EACe;AACf,EAAA,MAAM,EAAE,MAAK,GAAI,OAAA;AACjB,EAAA,OAAA,CAAQ,IAAI,oEAAA,EAAiE;AAAA,IAC3E,KAAK,IAAA,CAAK,GAAA;AAAA,IACV,UAAU,IAAA,CAAK,QAAA;AAAA,IACf,aAAA,EAAe,KAAK,aAAA,IAAiB;AAAA,GACtC,CAAA;AACH;;;ACJO,SAAS,qBAAA,CAAsB,IAAA,GAAqC,EAAC,EAAmB;AAC7F,EAAA,MAAM,aAAA,GAAgB,KAAK,aAAA,IAAiB,YAAA;AAC5C,EAAA,MAAM,eAAe,aAAA,KAAkB,YAAA;AAEvC,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,kBAAA;AAAA,IACN,eAAA,EAAiB;AAAA,MACf,EAAA,EAAI,yBAAA;AAAA,MACJ,OAAA,EAAS,OAAA;AAAA,MACT,UAAA,EAAY,WAAA;AAAA,MACZ,YAAA,EAAc,CAAC,WAAA,EAAa,oBAAA,EAAsB,sBAAsB,CAAA;AAAA,MACxE,SAAA,EAAW;AAAA,KACb;AAAA,IACA,aAAA;AAAA,IACA,SAAA,EAAW,YAAA;AAAA,IACX,MAAM,OAAA,EAAuB;AAC3B,MAAA,OAAA,CAAQ,KAAA,CAAM,aAAa,CAAA,CAAE,GAAA;AAAA,QAC3B,kBAAA;AAAA,QACA,OAAO,OAAA,EAA0B,GAAA,KAAmB,kBAAA,CAAmB,OAAA,EAAS,KAAK,IAAI,CAAA;AAAA,QACzF,EAAE,MAAM,aAAA;AAAc,OACxB;AAAA,IACF;AAAA,GACF;AACF","file":"index.js","sourcesContent":["import type { PipelineContext, PluginApi } from \"@better-media/core\";\nimport type { MediaProcessingPluginOptions } from \"../interfaces/options.interface\";\n\nexport async function runMediaProcessing(\n context: PipelineContext,\n _api: PluginApi,\n opts: MediaProcessingPluginOptions\n): Promise<void> {\n const { file } = context;\n console.log(\"[media-processing] process:run (stub — sharp/ffmpeg disabled)\", {\n key: file.key,\n mimeType: file.mimeType,\n executionMode: opts.executionMode ?? \"background\",\n });\n}\n","import type { PipelinePlugin, MediaRuntime, PipelineContext, PluginApi } from \"@better-media/core\";\nimport type { MediaProcessingPluginOptions } from \"./interfaces/options.interface\";\nimport { runMediaProcessing } from \"./runtime/runner\";\n\nexport type { MediaProcessingPluginOptions } from \"./interfaces/options.interface\";\n\n/**\n * Media processing plugin for the Better Media pipeline (stub).\n * Currently logs on `process:run`; thumbnail/metadata handling is not implemented.\n */\nexport function mediaProcessingPlugin(opts: MediaProcessingPluginOptions = {}): PipelinePlugin {\n const executionMode = opts.executionMode ?? \"background\";\n const isBackground = executionMode === \"background\";\n\n return {\n name: \"media-processing\",\n runtimeManifest: {\n id: \"better-media-processing\",\n version: \"1.0.0\",\n trustLevel: \"untrusted\",\n capabilities: [\"file.read\", \"metadata.write.own\", \"processing.write.own\"],\n namespace: \"media-processing\",\n },\n executionMode,\n intensive: isBackground,\n apply(runtime: MediaRuntime) {\n runtime.hooks[\"process:run\"].tap(\n \"media-processing\",\n async (context: PipelineContext, api: PluginApi) => runMediaProcessing(context, api, opts),\n { mode: executionMode }\n );\n },\n };\n}\n"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// src/runtime/runner.ts
|
|
2
|
+
async function runMediaProcessing(context, _api, opts) {
|
|
3
|
+
const { file } = context;
|
|
4
|
+
console.log("[media-processing] process:run (stub \u2014 sharp/ffmpeg disabled)", {
|
|
5
|
+
key: file.key,
|
|
6
|
+
mimeType: file.mimeType,
|
|
7
|
+
executionMode: opts.executionMode ?? "background"
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// src/index.ts
|
|
12
|
+
function mediaProcessingPlugin(opts = {}) {
|
|
13
|
+
const executionMode = opts.executionMode ?? "background";
|
|
14
|
+
const isBackground = executionMode === "background";
|
|
15
|
+
return {
|
|
16
|
+
name: "media-processing",
|
|
17
|
+
runtimeManifest: {
|
|
18
|
+
id: "better-media-processing",
|
|
19
|
+
version: "1.0.0",
|
|
20
|
+
trustLevel: "untrusted",
|
|
21
|
+
capabilities: ["file.read", "metadata.write.own", "processing.write.own"],
|
|
22
|
+
namespace: "media-processing"
|
|
23
|
+
},
|
|
24
|
+
executionMode,
|
|
25
|
+
intensive: isBackground,
|
|
26
|
+
apply(runtime) {
|
|
27
|
+
runtime.hooks["process:run"].tap(
|
|
28
|
+
"media-processing",
|
|
29
|
+
async (context, api) => runMediaProcessing(context, api, opts),
|
|
30
|
+
{ mode: executionMode }
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export { mediaProcessingPlugin };
|
|
37
|
+
//# sourceMappingURL=index.mjs.map
|
|
38
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/runtime/runner.ts","../src/index.ts"],"names":[],"mappings":";AAGA,eAAsB,kBAAA,CACpB,OAAA,EACA,IAAA,EACA,IAAA,EACe;AACf,EAAA,MAAM,EAAE,MAAK,GAAI,OAAA;AACjB,EAAA,OAAA,CAAQ,IAAI,oEAAA,EAAiE;AAAA,IAC3E,KAAK,IAAA,CAAK,GAAA;AAAA,IACV,UAAU,IAAA,CAAK,QAAA;AAAA,IACf,aAAA,EAAe,KAAK,aAAA,IAAiB;AAAA,GACtC,CAAA;AACH;;;ACJO,SAAS,qBAAA,CAAsB,IAAA,GAAqC,EAAC,EAAmB;AAC7F,EAAA,MAAM,aAAA,GAAgB,KAAK,aAAA,IAAiB,YAAA;AAC5C,EAAA,MAAM,eAAe,aAAA,KAAkB,YAAA;AAEvC,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,kBAAA;AAAA,IACN,eAAA,EAAiB;AAAA,MACf,EAAA,EAAI,yBAAA;AAAA,MACJ,OAAA,EAAS,OAAA;AAAA,MACT,UAAA,EAAY,WAAA;AAAA,MACZ,YAAA,EAAc,CAAC,WAAA,EAAa,oBAAA,EAAsB,sBAAsB,CAAA;AAAA,MACxE,SAAA,EAAW;AAAA,KACb;AAAA,IACA,aAAA;AAAA,IACA,SAAA,EAAW,YAAA;AAAA,IACX,MAAM,OAAA,EAAuB;AAC3B,MAAA,OAAA,CAAQ,KAAA,CAAM,aAAa,CAAA,CAAE,GAAA;AAAA,QAC3B,kBAAA;AAAA,QACA,OAAO,OAAA,EAA0B,GAAA,KAAmB,kBAAA,CAAmB,OAAA,EAAS,KAAK,IAAI,CAAA;AAAA,QACzF,EAAE,MAAM,aAAA;AAAc,OACxB;AAAA,IACF;AAAA,GACF;AACF","file":"index.mjs","sourcesContent":["import type { PipelineContext, PluginApi } from \"@better-media/core\";\nimport type { MediaProcessingPluginOptions } from \"../interfaces/options.interface\";\n\nexport async function runMediaProcessing(\n context: PipelineContext,\n _api: PluginApi,\n opts: MediaProcessingPluginOptions\n): Promise<void> {\n const { file } = context;\n console.log(\"[media-processing] process:run (stub — sharp/ffmpeg disabled)\", {\n key: file.key,\n mimeType: file.mimeType,\n executionMode: opts.executionMode ?? \"background\",\n });\n}\n","import type { PipelinePlugin, MediaRuntime, PipelineContext, PluginApi } from \"@better-media/core\";\nimport type { MediaProcessingPluginOptions } from \"./interfaces/options.interface\";\nimport { runMediaProcessing } from \"./runtime/runner\";\n\nexport type { MediaProcessingPluginOptions } from \"./interfaces/options.interface\";\n\n/**\n * Media processing plugin for the Better Media pipeline (stub).\n * Currently logs on `process:run`; thumbnail/metadata handling is not implemented.\n */\nexport function mediaProcessingPlugin(opts: MediaProcessingPluginOptions = {}): PipelinePlugin {\n const executionMode = opts.executionMode ?? \"background\";\n const isBackground = executionMode === \"background\";\n\n return {\n name: \"media-processing\",\n runtimeManifest: {\n id: \"better-media-processing\",\n version: \"1.0.0\",\n trustLevel: \"untrusted\",\n capabilities: [\"file.read\", \"metadata.write.own\", \"processing.write.own\"],\n namespace: \"media-processing\",\n },\n executionMode,\n intensive: isBackground,\n apply(runtime: MediaRuntime) {\n runtime.hooks[\"process:run\"].tap(\n \"media-processing\",\n async (context: PipelineContext, api: PluginApi) => runMediaProcessing(context, api, opts),\n { mode: executionMode }\n );\n },\n };\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@better-media/plugin-media-processing",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Media processing plugin for Better Media pipeline",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@better-media/core": "0.1.0"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [],
|
|
23
|
+
"author": "Abenezer Atnafu",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/AbenezerAtnafu/better-media.git"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://better-media.dev",
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/AbenezerAtnafu/better-media/issues"
|
|
32
|
+
},
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsup",
|
|
38
|
+
"dev": "tsup --watch",
|
|
39
|
+
"typecheck": "tsc --noEmit",
|
|
40
|
+
"lint": "eslint .",
|
|
41
|
+
"test": "jest"
|
|
42
|
+
}
|
|
43
|
+
}
|