@adonis-agora/media 0.8.2 → 0.10.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/CHANGELOG.md +88 -0
- package/README.md +2 -2
- package/dist/providers/media_provider.d.ts.map +1 -1
- package/dist/providers/media_provider.js +138 -0
- package/dist/providers/media_provider.js.map +1 -1
- package/dist/src/content_type.d.ts +6 -1
- package/dist/src/content_type.d.ts.map +1 -1
- package/dist/src/content_type.js +102 -7
- package/dist/src/content_type.js.map +1 -1
- package/dist/src/define_config.d.ts +104 -5
- package/dist/src/define_config.d.ts.map +1 -1
- package/dist/src/define_config.js +7 -2
- package/dist/src/define_config.js.map +1 -1
- package/dist/src/diagnostics.d.ts +7 -0
- package/dist/src/diagnostics.d.ts.map +1 -1
- package/dist/src/diagnostics.js +20 -0
- package/dist/src/diagnostics.js.map +1 -1
- package/dist/src/direct_upload.d.ts +177 -0
- package/dist/src/direct_upload.d.ts.map +1 -0
- package/dist/src/direct_upload.js +299 -0
- package/dist/src/direct_upload.js.map +1 -0
- package/dist/src/direct_upload_handler.d.ts +117 -0
- package/dist/src/direct_upload_handler.d.ts.map +1 -0
- package/dist/src/direct_upload_handler.js +277 -0
- package/dist/src/direct_upload_handler.js.map +1 -0
- package/dist/src/disks/factory.d.ts +11 -3
- package/dist/src/disks/factory.d.ts.map +1 -1
- package/dist/src/disks/factory.js +5 -3
- package/dist/src/disks/factory.js.map +1 -1
- package/dist/src/disks/s3.d.ts +10 -0
- package/dist/src/disks/s3.d.ts.map +1 -1
- package/dist/src/disks/s3.js +96 -22
- package/dist/src/disks/s3.js.map +1 -1
- package/dist/src/disks/sigv4.d.ts +58 -0
- package/dist/src/disks/sigv4.d.ts.map +1 -0
- package/dist/src/disks/sigv4.js +87 -0
- package/dist/src/disks/sigv4.js.map +1 -0
- package/dist/src/disks/xml_fallback.d.ts +3 -3
- package/dist/src/disks/xml_fallback.js +3 -3
- package/dist/src/errors.d.ts +104 -0
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/errors.js +145 -0
- package/dist/src/errors.js.map +1 -1
- package/dist/src/hls/delivery.d.ts +112 -0
- package/dist/src/hls/delivery.d.ts.map +1 -0
- package/dist/src/hls/delivery.js +118 -0
- package/dist/src/hls/delivery.js.map +1 -0
- package/dist/src/hls/playlist.d.ts +67 -0
- package/dist/src/hls/playlist.d.ts.map +1 -0
- package/dist/src/hls/playlist.js +126 -0
- package/dist/src/hls/playlist.js.map +1 -0
- package/dist/src/index.d.ts +19 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +13 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/media_collection.d.ts +8 -1
- package/dist/src/media_collection.d.ts.map +1 -1
- package/dist/src/media_collection.js +23 -1
- package/dist/src/media_collection.js.map +1 -1
- package/dist/src/media_library.d.ts +32 -2
- package/dist/src/media_library.d.ts.map +1 -1
- package/dist/src/media_library.js +218 -11
- package/dist/src/media_library.js.map +1 -1
- package/dist/src/media_manager.d.ts +37 -2
- package/dist/src/media_manager.d.ts.map +1 -1
- package/dist/src/media_manager.js +54 -1
- package/dist/src/media_manager.js.map +1 -1
- package/dist/src/media_record.d.ts +22 -2
- package/dist/src/media_record.d.ts.map +1 -1
- package/dist/src/testing/fake_transformer.d.ts +32 -0
- package/dist/src/testing/fake_transformer.d.ts.map +1 -0
- package/dist/src/testing/fake_transformer.js +32 -0
- package/dist/src/testing/fake_transformer.js.map +1 -0
- package/dist/src/testing/index.d.ts +2 -0
- package/dist/src/testing/index.d.ts.map +1 -1
- package/dist/src/testing/index.js +1 -0
- package/dist/src/testing/index.js.map +1 -1
- package/dist/src/transformer.d.ts +111 -0
- package/dist/src/transformer.d.ts.map +1 -0
- package/dist/src/transformer.js +2 -0
- package/dist/src/transformer.js.map +1 -0
- package/dist/src/transformers/factory.d.ts +30 -0
- package/dist/src/transformers/factory.d.ts.map +1 -0
- package/dist/src/transformers/factory.js +34 -0
- package/dist/src/transformers/factory.js.map +1 -0
- package/dist/src/transformers/hls.d.ts +110 -0
- package/dist/src/transformers/hls.d.ts.map +1 -0
- package/dist/src/transformers/hls.js +111 -0
- package/dist/src/transformers/hls.js.map +1 -0
- package/dist/src/transformers/mediabunny.d.ts +5 -0
- package/dist/src/transformers/mediabunny.d.ts.map +1 -0
- package/dist/src/transformers/mediabunny.js +150 -0
- package/dist/src/transformers/mediabunny.js.map +1 -0
- package/dist/src/transformers/mediabunny_loader.d.ts +15 -0
- package/dist/src/transformers/mediabunny_loader.d.ts.map +1 -0
- package/dist/src/transformers/mediabunny_loader.js +21 -0
- package/dist/src/transformers/mediabunny_loader.js.map +1 -0
- package/dist/src/transformers/probe.d.ts +56 -0
- package/dist/src/transformers/probe.d.ts.map +1 -0
- package/dist/src/transformers/probe.js +32 -0
- package/dist/src/transformers/probe.js.map +1 -0
- package/dist/src/transformers/source_file.d.ts +20 -0
- package/dist/src/transformers/source_file.d.ts.map +1 -0
- package/dist/src/transformers/source_file.js +30 -0
- package/dist/src/transformers/source_file.js.map +1 -0
- package/dist/src/types.d.ts +80 -0
- package/dist/src/types.d.ts.map +1 -1
- package/dist/stubs/config/media.stub +12 -0
- package/package.json +11 -7
- package/LICENSE +0 -21
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { createReadStream } from 'node:fs';
|
|
2
|
+
import { readdir, stat } from 'node:fs/promises';
|
|
3
|
+
import { mkdir } from 'node:fs/promises';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { hlsArtifactContentType } from '../hls/playlist.js';
|
|
6
|
+
import { loadMediabunny } from './mediabunny_loader.js';
|
|
7
|
+
import { withSourceFile } from './source_file.js';
|
|
8
|
+
/**
|
|
9
|
+
* Detect how (whether) WebCodecs is available: `'native'` when the runtime already exposes
|
|
10
|
+
* `VideoEncoder`, `'injected'` when a {@link WebCodecsProvider} supplies one, `'absent'` otherwise.
|
|
11
|
+
* `'absent'` means encoding is impossible — transforms stay stream-copy only, and a transformer
|
|
12
|
+
* that cannot proceed without an encoder should throw `TransformerRuntimeMissingError`.
|
|
13
|
+
*/
|
|
14
|
+
export async function resolveWebCodecsSupport(provider) {
|
|
15
|
+
if (globalThis.VideoEncoder !== undefined)
|
|
16
|
+
return 'native';
|
|
17
|
+
if (provider && (await provider()).VideoEncoder !== undefined)
|
|
18
|
+
return 'injected';
|
|
19
|
+
return 'absent';
|
|
20
|
+
}
|
|
21
|
+
/** File name of the entry (master) playlist an {@link HlsTransformer} produces. */
|
|
22
|
+
export const HLS_ENTRY_PLAYLIST = 'index.m3u8';
|
|
23
|
+
/**
|
|
24
|
+
* The built-in video {@link Transformer}: converts a stored video into an HLS package — MPEG-TS
|
|
25
|
+
* segments plus media playlists behind one master playlist — written under the conversion prefix
|
|
26
|
+
* and persisted as `record.conversions['hls']` with duration/resolution/codec metadata.
|
|
27
|
+
*
|
|
28
|
+
* **Remux-only by default.** The engine (mediabunny, pure JS — no ffmpeg binary) stream-copies
|
|
29
|
+
* the source's h264/aac tracks into segments without re-encoding, because encoding needs
|
|
30
|
+
* WebCodecs, which Node does not provide. Two consequences, both deliberate:
|
|
31
|
+
*
|
|
32
|
+
* - a source whose codecs MPEG-TS cannot carry (vp9, av1…) fails with a clear, definitive
|
|
33
|
+
* `HlsSourceUnsupportedError` — unless a {@link WebCodecsProvider} is configured, which enables
|
|
34
|
+
* the engine's re-encode fallback;
|
|
35
|
+
* - the package has a single variant at the original resolution. Multi-quality renditions are the
|
|
36
|
+
* documented evolution once an encoder is present (mediabunny supports fan-out video options),
|
|
37
|
+
* not something this transformer fakes today.
|
|
38
|
+
*
|
|
39
|
+
* The engine also carries the subtle bit the naive implementation gets wrong: AAC audio with
|
|
40
|
+
* priming (an mp4 edit list) starts at a **negative** timestamp, and a conversion trimmed at t=0
|
|
41
|
+
* would kick that track off the stream-copy fast path — impossible without an encoder. The
|
|
42
|
+
* conversion is therefore trimmed at the source's real first timestamp, shifting all tracks
|
|
43
|
+
* equally (sync is unchanged) and keeping every track copyable.
|
|
44
|
+
*
|
|
45
|
+
* Serving the result is the other half: playlists are stored with storage-relative references and
|
|
46
|
+
* must be rewritten per request — see {@link HlsDeliveryHandler}.
|
|
47
|
+
*/
|
|
48
|
+
export class HlsTransformer {
|
|
49
|
+
name;
|
|
50
|
+
eager;
|
|
51
|
+
targetDuration;
|
|
52
|
+
webcodecs;
|
|
53
|
+
engine;
|
|
54
|
+
constructor(options = {}) {
|
|
55
|
+
this.name = options.name ?? 'hls';
|
|
56
|
+
this.eager = options.eager ?? false;
|
|
57
|
+
this.targetDuration = options.targetDuration ?? 4;
|
|
58
|
+
this.webcodecs = options.webcodecs;
|
|
59
|
+
this.engine = options.engine;
|
|
60
|
+
}
|
|
61
|
+
async transform(context) {
|
|
62
|
+
const engine = this.engine ?? (await loadMediabunny(this.name)).createHlsEngine();
|
|
63
|
+
return withSourceFile(context, async ({ sourcePath, tempDir }) => {
|
|
64
|
+
const outputDir = join(tempDir, 'hls');
|
|
65
|
+
await mkdir(outputDir, { recursive: true });
|
|
66
|
+
const summary = await engine.remux({
|
|
67
|
+
sourcePath,
|
|
68
|
+
outputDir,
|
|
69
|
+
entryName: HLS_ENTRY_PLAYLIST,
|
|
70
|
+
targetDuration: this.targetDuration,
|
|
71
|
+
webcodecs: this.webcodecs,
|
|
72
|
+
});
|
|
73
|
+
// Upload the whole package the engine wrote — playlists and segments alike — streaming each
|
|
74
|
+
// file (a segment never has to fit in memory). Sorted for deterministic order in
|
|
75
|
+
// `conversions[name].files`.
|
|
76
|
+
const files = (await readdir(outputDir, { recursive: true })).sort();
|
|
77
|
+
let segmentCount = 0;
|
|
78
|
+
let playlistCount = 0;
|
|
79
|
+
for (const file of files) {
|
|
80
|
+
const relative = file.split('\\').join('/');
|
|
81
|
+
const local = join(outputDir, file);
|
|
82
|
+
const info = await stat(local);
|
|
83
|
+
if (!info.isFile())
|
|
84
|
+
continue;
|
|
85
|
+
if (relative.toLowerCase().endsWith('.m3u8'))
|
|
86
|
+
playlistCount += 1;
|
|
87
|
+
else
|
|
88
|
+
segmentCount += 1;
|
|
89
|
+
const contentType = hlsArtifactContentType(relative);
|
|
90
|
+
await context.write(relative, createReadStream(local), {
|
|
91
|
+
contentLength: info.size,
|
|
92
|
+
...(contentType !== undefined ? { contentType } : {}),
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
entry: HLS_ENTRY_PLAYLIST,
|
|
97
|
+
meta: compactMeta({
|
|
98
|
+
...summary,
|
|
99
|
+
segmentCount,
|
|
100
|
+
playlistCount,
|
|
101
|
+
targetDuration: this.targetDuration,
|
|
102
|
+
}),
|
|
103
|
+
};
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/** Drop `undefined` values so the persisted meta round-trips identically through JSON stores. */
|
|
108
|
+
export function compactMeta(meta) {
|
|
109
|
+
return Object.fromEntries(Object.entries(meta).filter(([, value]) => value !== undefined));
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=hls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hls.js","sourceRoot":"","sources":["../../../src/transformers/hls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAqBlD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,QAA4B;IAE5B,IAAK,UAAsC,CAAC,YAAY,KAAK,SAAS;QAAE,OAAO,QAAQ,CAAC;IACxF,I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AAI,CAAC,cAAc;iBACpC,CAAC;aACH,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED,iGAAiG;AACjG,MAAM,UAAU,WAAW,CAAC,IAA6B;IACvD,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC;AAC7F,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mediabunny.d.ts","sourceRoot":"","sources":["../../../src/transformers/mediabunny.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,cAAc,EAAuD,MAAM,UAAU,CAAC;AACpG,OAAO,KAAK,EAAE,gBAAgB,EAAqB,MAAM,YAAY,CAAC;AA+DtE,wBAAgB,eAAe,IAAI,cAAc,CA8DhD;AAED,wBAAgB,iBAAiB,IAAI,gBAAgB,CAiCpD"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { ALL_FORMATS, Conversion, FilePathSource, FilePathTarget, HlsOutputFormat, Input, MpegTsOutputFormat, Output, PathedTarget, } from 'mediabunny';
|
|
3
|
+
import { HlsSourceUnsupportedError } from '../errors.js';
|
|
4
|
+
/**
|
|
5
|
+
* The mediabunny-backed engines — the ONLY module in the package that imports the optional
|
|
6
|
+
* `mediabunny` peer, reached lazily through `mediabunny_loader.ts` at first transform.
|
|
7
|
+
*
|
|
8
|
+
* Why mediabunny: pure TypeScript, no ffmpeg binary — a production container without system
|
|
9
|
+
* ffmpeg (the usual case) remuxes fine. The trade-off is that *encoding* rides on WebCodecs,
|
|
10
|
+
* which Node lacks, hence the remux-only default and the {@link WebCodecsProvider} injection
|
|
11
|
+
* seam documented on `HlsTransformer`.
|
|
12
|
+
*/
|
|
13
|
+
/** The WebCodecs API surface mediabunny reads from `globalThis`. */
|
|
14
|
+
const WEBCODECS_GLOBALS = [
|
|
15
|
+
'VideoEncoder',
|
|
16
|
+
'VideoDecoder',
|
|
17
|
+
'AudioEncoder',
|
|
18
|
+
'AudioDecoder',
|
|
19
|
+
'VideoFrame',
|
|
20
|
+
'AudioData',
|
|
21
|
+
'EncodedVideoChunk',
|
|
22
|
+
'EncodedAudioChunk',
|
|
23
|
+
];
|
|
24
|
+
/**
|
|
25
|
+
* Install an injected WebCodecs implementation onto `globalThis` — only the classes that are
|
|
26
|
+
* missing; a native implementation is never overwritten. Global mutation is deliberate and
|
|
27
|
+
* additive: `globalThis` is where the WebCodecs spec (and therefore mediabunny) looks the API up,
|
|
28
|
+
* so "injecting an implementation" and "installing it globally" are the same thing. Installing
|
|
29
|
+
* per-conversion and uninstalling after would race concurrent transforms for zero benefit.
|
|
30
|
+
*/
|
|
31
|
+
async function installWebCodecs(provider) {
|
|
32
|
+
if (!provider)
|
|
33
|
+
return;
|
|
34
|
+
const implementation = await provider();
|
|
35
|
+
const globals = globalThis;
|
|
36
|
+
for (const name of WEBCODECS_GLOBALS) {
|
|
37
|
+
if (globals[name] === undefined && implementation[name] !== undefined) {
|
|
38
|
+
globals[name] = implementation[name];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** Best-effort technical summary of an input — never fails the transform over metadata. */
|
|
43
|
+
async function summarize(input) {
|
|
44
|
+
const summary = {};
|
|
45
|
+
try {
|
|
46
|
+
summary.durationSeconds = await input.computeDuration();
|
|
47
|
+
const video = await input.getPrimaryVideoTrack();
|
|
48
|
+
if (video) {
|
|
49
|
+
summary.width = await video.getDisplayWidth();
|
|
50
|
+
summary.height = await video.getDisplayHeight();
|
|
51
|
+
summary.videoCodec = await video.getCodec();
|
|
52
|
+
}
|
|
53
|
+
const audio = await input.getPrimaryAudioTrack();
|
|
54
|
+
if (audio) {
|
|
55
|
+
summary.audioCodec = await audio.getCodec();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
// metadata is a bonus; the artifacts are the product
|
|
60
|
+
}
|
|
61
|
+
return summary;
|
|
62
|
+
}
|
|
63
|
+
export function createHlsEngine() {
|
|
64
|
+
return {
|
|
65
|
+
async remux(request) {
|
|
66
|
+
await installWebCodecs(request.webcodecs);
|
|
67
|
+
const input = new Input({
|
|
68
|
+
source: new FilePathSource(request.sourcePath),
|
|
69
|
+
formats: ALL_FORMATS,
|
|
70
|
+
});
|
|
71
|
+
try {
|
|
72
|
+
const output = new Output({
|
|
73
|
+
format: new HlsOutputFormat({
|
|
74
|
+
segmentFormat: new MpegTsOutputFormat(),
|
|
75
|
+
targetDuration: request.targetDuration,
|
|
76
|
+
}),
|
|
77
|
+
// The HLS output is many files; each one lands in the local output directory.
|
|
78
|
+
target: new PathedTarget(join(request.outputDir, request.entryName), (target) => new FilePathTarget(target.path)),
|
|
79
|
+
});
|
|
80
|
+
// THE gotcha: AAC audio with priming (an mp4 edit list) starts at a NEGATIVE timestamp.
|
|
81
|
+
// Mediabunny's default trims the conversion at t=0, which would throw that audio track off
|
|
82
|
+
// the packet-copy fast path — and re-encoding it needs an encoder we may not have.
|
|
83
|
+
// Trimming at the source's real first timestamp keeps every track a pure stream copy; all
|
|
84
|
+
// tracks shift equally, so A/V sync is untouched.
|
|
85
|
+
const firstTimestamp = await input.getFirstTimestamp();
|
|
86
|
+
const conversion = await Conversion.init({
|
|
87
|
+
input,
|
|
88
|
+
output,
|
|
89
|
+
trim: { start: firstTimestamp },
|
|
90
|
+
});
|
|
91
|
+
// With no video/audio options, mediabunny copies compatible tracks and re-encodes the
|
|
92
|
+
// rest — but re-encoding needs an encoder, so without WebCodecs an incompatible track is
|
|
93
|
+
// DISCARDED instead. Silently shipping a video without its audio (or vice versa) is not a
|
|
94
|
+
// conversion, it is data loss: fail loudly, with the codec and the reason per track.
|
|
95
|
+
if (conversion.discardedTracks.length > 0) {
|
|
96
|
+
const reasons = await Promise.all(conversion.discardedTracks.map(async (discarded) => {
|
|
97
|
+
const codec = await discarded.track.getCodec().catch(() => null);
|
|
98
|
+
return `${discarded.track.type}/${codec ?? 'unknown'}: ${discarded.reason}`;
|
|
99
|
+
}));
|
|
100
|
+
throw new HlsSourceUnsupportedError(reasons.join('; '));
|
|
101
|
+
}
|
|
102
|
+
if (!conversion.isValid) {
|
|
103
|
+
throw new HlsSourceUnsupportedError('the file contains no usable track');
|
|
104
|
+
}
|
|
105
|
+
const summary = await summarize(input);
|
|
106
|
+
await conversion.execute();
|
|
107
|
+
return summary;
|
|
108
|
+
}
|
|
109
|
+
finally {
|
|
110
|
+
input.dispose();
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
export function createProbeEngine() {
|
|
116
|
+
return {
|
|
117
|
+
async probe(sourcePath) {
|
|
118
|
+
const input = new Input({ source: new FilePathSource(sourcePath), formats: ALL_FORMATS });
|
|
119
|
+
try {
|
|
120
|
+
const format = await input.getFormat();
|
|
121
|
+
const summary = {
|
|
122
|
+
format: format.name,
|
|
123
|
+
mimeType: await input.getMimeType(),
|
|
124
|
+
durationSeconds: await input.computeDuration(),
|
|
125
|
+
hasVideo: false,
|
|
126
|
+
hasAudio: false,
|
|
127
|
+
};
|
|
128
|
+
const video = await input.getPrimaryVideoTrack();
|
|
129
|
+
if (video) {
|
|
130
|
+
summary.hasVideo = true;
|
|
131
|
+
summary.width = await video.getDisplayWidth();
|
|
132
|
+
summary.height = await video.getDisplayHeight();
|
|
133
|
+
summary.videoCodec = await video.getCodec();
|
|
134
|
+
}
|
|
135
|
+
const audio = await input.getPrimaryAudioTrack();
|
|
136
|
+
if (audio) {
|
|
137
|
+
summary.hasAudio = true;
|
|
138
|
+
summary.audioCodec = await audio.getCodec();
|
|
139
|
+
summary.audioSampleRate = await audio.getSampleRate();
|
|
140
|
+
summary.audioChannels = await audio.getNumberOfChannels();
|
|
141
|
+
}
|
|
142
|
+
return summary;
|
|
143
|
+
}
|
|
144
|
+
finally {
|
|
145
|
+
input.dispose();
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=mediabunny.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mediabunny.js","sourceRoot":"","sources":["../../../src/transformers/mediabunny.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EACL,WAAW,EACX,UAAU,EACV,cAAc,EACd,cAAc,EACd,eAAe,EACf,KAAK,EACL,kBAAkB,EAClB,MAAM,EACN,YAAY,GACb,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAIzD;;;;;;;;GAQG;AAEH,oEAAoE;AACpE,MAAM,iBAAiB,GAAG;IACxB,cAAc;IACd,cAAc;IACd,cAAc;IACd,cAAc;IACd,YAAY;IACZ,WAAW;IACX,mBAAmB;IACnB,mBAAmB;CACX,CAAC;AAEX;;;;;;GAMG;AACH,KAAK,UAAU,gBAAgB,CAAC,QAAuC;IACrE,IAAI,CAAC,QAAQ;QAAE,OAAO;IACtB,MAAM,cAAc,GAAG,MAAM,QAAQ,EAAE,CAAC;IACxC,MAAM,OAAO,GAAG,UAAqC,CAAC;IACtD,KAAK,MAAM,IAAI,IAAI,iBAAiB,EAAE,CAAC;QACrC,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,SAAS,IAAI,cAAc,CAAC,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;YACtE,OAAO,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;AACH,CAAC;AAED,2FAA2F;AAC3F,KAAK,UAAU,SAAS,CAAC,KAAY;IACnC,MAAM,OAAO,GAAoB,EAAE,CAAC;IACpC,IAAI,CAAC;QACH,OAAO,CAAC,eAAe,GAAG,MAAM,KAAK,CAAC,eAAe,EAAE,CA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G,MAAM,KAAK,CAAC,mBAAmB,EAAE,CAAC;gBAC5D,CAAC;gBACD,OAAO,OAAO,CAAC;YACjB,CAAC;oBAAS,CAAC;gBACT,KAAK,CAAC,OAAO,EAAE,CAAC;YAClB,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { HlsRemuxEngine } from './hls.js';
|
|
2
|
+
import type { MediaProbeEngine } from './probe.js';
|
|
3
|
+
/** The engine factories `./mediabunny.js` exports (the only module that imports the peer). */
|
|
4
|
+
export interface MediabunnyEngineModule {
|
|
5
|
+
createHlsEngine(): HlsRemuxEngine;
|
|
6
|
+
createProbeEngine(): MediaProbeEngine;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Load the mediabunny-backed engine module, translating a missing optional peer into the typed
|
|
10
|
+
* {@link TransformerRuntimeMissingError} instead of a raw `ERR_MODULE_NOT_FOUND` five imports deep.
|
|
11
|
+
* Import happens here — at first transform — never at boot: configuring a transformer must not
|
|
12
|
+
* load its engine (the same laziness `processors.sharp()` and `disks.s3()` follow).
|
|
13
|
+
*/
|
|
14
|
+
export declare function loadMediabunny(transformerName: string): Promise<MediabunnyEngineModule>;
|
|
15
|
+
//# sourceMappingURL=mediabunny_loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mediabunny_loader.d.ts","sourceRoot":"","sources":["../../../src/transformers/mediabunny_loader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,8FAA8F;AAC9F,MAAM,WAAW,sBAAsB;IACrC,eAAe,IAAI,cAAc,CAAC;IAClC,iBAAiB,IAAI,gBAAgB,CAAC;CACvC;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAiB7F"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { TransformerRuntimeMissingError } from '../errors.js';
|
|
2
|
+
/**
|
|
3
|
+
* Load the mediabunny-backed engine module, translating a missing optional peer into the typed
|
|
4
|
+
* {@link TransformerRuntimeMissingError} instead of a raw `ERR_MODULE_NOT_FOUND` five imports deep.
|
|
5
|
+
* Import happens here — at first transform — never at boot: configuring a transformer must not
|
|
6
|
+
* load its engine (the same laziness `processors.sharp()` and `disks.s3()` follow).
|
|
7
|
+
*/
|
|
8
|
+
export async function loadMediabunny(transformerName) {
|
|
9
|
+
try {
|
|
10
|
+
return await import('./mediabunny.js');
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
if (error.code === 'ERR_MODULE_NOT_FOUND' &&
|
|
14
|
+
error instanceof Error &&
|
|
15
|
+
error.message.includes('mediabunny')) {
|
|
16
|
+
throw new TransformerRuntimeMissingError(transformerName, "the optional peer dependency 'mediabunny'", 'Install it (`pnpm add mediabunny`) or inject a custom `engine`.');
|
|
17
|
+
}
|
|
18
|
+
throw error;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=mediabunny_loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mediabunny_loader.js","sourceRoot":"","sources":["../../../src/transformers/mediabunny_loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAC;AAU9D;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,eAAuB;IAC1D,IAAI,CAAC;QACH,OAAO,MAAM,MAAM,CAAC,iBAAiB,CAAC,CAAC;IACzC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IACG,KAA2B,CAAC,IAAI,KAAK,sBAAsB;YAC5D,KAAK,YAAY,KAAK;YACtB,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,EACpC,CAAC;YACD,MAAM,IAAI,8BAA8B,CACtC,eAAe,EACf,2CAA2C,EAC3C,iEAAiE,CAClE,CAAC;QACJ,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { TransformResult, Transformer, TransformerContext } from '../transformer.js';
|
|
2
|
+
/** What probing a media file yields — persisted verbatim as the conversion's `meta`. */
|
|
3
|
+
export interface MediaProbeSummary {
|
|
4
|
+
/** Container format name (e.g. `MP4`), when the engine can tell. */
|
|
5
|
+
format?: string;
|
|
6
|
+
/** Full MIME type including codecs parameter, when the engine can tell. */
|
|
7
|
+
mimeType?: string;
|
|
8
|
+
durationSeconds?: number;
|
|
9
|
+
width?: number;
|
|
10
|
+
height?: number;
|
|
11
|
+
videoCodec?: string | null;
|
|
12
|
+
audioCodec?: string | null;
|
|
13
|
+
audioSampleRate?: number;
|
|
14
|
+
audioChannels?: number;
|
|
15
|
+
hasVideo: boolean;
|
|
16
|
+
hasAudio: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The engine seam of {@link MetadataProbeTransformer}: local file in, metadata out. Default engine
|
|
20
|
+
* is mediabunny (lazy); tests inject a fake.
|
|
21
|
+
*/
|
|
22
|
+
export interface MediaProbeEngine {
|
|
23
|
+
probe(sourcePath: string): Promise<MediaProbeSummary>;
|
|
24
|
+
}
|
|
25
|
+
export interface MetadataProbeTransformerOptions<Name extends string = 'probe'> {
|
|
26
|
+
/** Conversion name on the record. Default `'probe'`. */
|
|
27
|
+
name?: Name;
|
|
28
|
+
/**
|
|
29
|
+
* Run inside attach. Default `false`: probing is CPU-cheap but reads the original, and on a
|
|
30
|
+
* remote disk that read is a download. Opt in for collections of small files.
|
|
31
|
+
*/
|
|
32
|
+
eager?: boolean;
|
|
33
|
+
/** Replace the mediabunny engine (mainly for tests). */
|
|
34
|
+
engine?: MediaProbeEngine;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The built-in **metadata-only** {@link Transformer}: reads a media file's technical metadata —
|
|
38
|
+
* duration, resolution, codecs, channel layout — and persists it as
|
|
39
|
+
* `record.conversions['probe'].meta`, writing **no artifact at all**. The reference implementation
|
|
40
|
+
* of the "derive metadata, not files" transformer shape; the model for a blurhash/thumbhash
|
|
41
|
+
* placeholder transformer.
|
|
42
|
+
*
|
|
43
|
+
* ```ts
|
|
44
|
+
* await media.library.transform(id, 'probe')
|
|
45
|
+
* const record = await media.library.find(id)
|
|
46
|
+
* record.conversions.probe?.meta // { durationSeconds: 41.6, width: 1920, ... }
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare class MetadataProbeTransformer<Name extends string = 'probe'> implements Transformer {
|
|
50
|
+
readonly name: Name;
|
|
51
|
+
readonly eager: boolean;
|
|
52
|
+
private readonly engine;
|
|
53
|
+
constructor(options?: MetadataProbeTransformerOptions<Name>);
|
|
54
|
+
transform(context: TransformerContext): Promise<TransformResult>;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=probe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"probe.d.ts","sourceRoot":"","sources":["../../../src/transformers/probe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAK1F,wFAAwF;AACxF,MAAM,WAAW,iBAAiB;IAChC,oEAAoE;IACpE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;CACvD;AAED,MAAM,WAAW,+BAA+B,CAAC,IAAI,SAAS,MAAM,GAAG,OAAO;IAC5E,wDAAwD;IACxD,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,wDAAwD;IACxD,MAAM,CAAC,EAAE,gBAAgB,CAAC;CAC3B;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,wBAAwB,CAAC,IAAI,SAAS,MAAM,GAAG,OAAO,CAAE,YAAW,WAAW;IACzF,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA+B;gBAE1C,OAAO,GAAE,+BAA+B,CAAC,IAAI,CAAM;IAMzD,SAAS,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,eAAe,CAAC;CAKvE"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { compactMeta } from './hls.js';
|
|
2
|
+
import { loadMediabunny } from './mediabunny_loader.js';
|
|
3
|
+
import { withSourceFile } from './source_file.js';
|
|
4
|
+
/**
|
|
5
|
+
* The built-in **metadata-only** {@link Transformer}: reads a media file's technical metadata —
|
|
6
|
+
* duration, resolution, codecs, channel layout — and persists it as
|
|
7
|
+
* `record.conversions['probe'].meta`, writing **no artifact at all**. The reference implementation
|
|
8
|
+
* of the "derive metadata, not files" transformer shape; the model for a blurhash/thumbhash
|
|
9
|
+
* placeholder transformer.
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* await media.library.transform(id, 'probe')
|
|
13
|
+
* const record = await media.library.find(id)
|
|
14
|
+
* record.conversions.probe?.meta // { durationSeconds: 41.6, width: 1920, ... }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export class MetadataProbeTransformer {
|
|
18
|
+
name;
|
|
19
|
+
eager;
|
|
20
|
+
engine;
|
|
21
|
+
constructor(options = {}) {
|
|
22
|
+
this.name = options.name ?? 'probe';
|
|
23
|
+
this.eager = options.eager ?? false;
|
|
24
|
+
this.engine = options.engine;
|
|
25
|
+
}
|
|
26
|
+
async transform(context) {
|
|
27
|
+
const engine = this.engine ?? (await loadMediabunny(this.name)).createProbeEngine();
|
|
28
|
+
const summary = await withSourceFile(context, ({ sourcePath }) => engine.probe(sourcePath));
|
|
29
|
+
return { meta: compactMeta({ ...summary }) };
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=probe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"probe.js","sourceRoot":"","sources":["../../../src/transformers/probe.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAuClD;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,wBAAwB;IAC1B,IAAI,CAAO;IACX,KAAK,CAAU;IACP,MAAM,CAA+B;IAEtD,YAAY,UAAiD,EAAE;QAC7D,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,IAAK,OAAgB,CAAC;QAC9C,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,KAAK,CAAC;QACpC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,OAA2B;QACzC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;QACpF,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,OAAO,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;QAC5F,OAAO,EAAE,IAAI,EAAE,WAAW,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC,EAAE,CAAC;IAC/C,CAAC;CACF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { TransformerContext } from '../transformer.js';
|
|
2
|
+
/** What {@link withSourceFile} hands its callback. */
|
|
3
|
+
export interface MaterializedSource {
|
|
4
|
+
/** Local path of the original's bytes. */
|
|
5
|
+
sourcePath: string;
|
|
6
|
+
/** The temp directory the source lives in — free scratch space, removed when the callback ends. */
|
|
7
|
+
tempDir: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Materialize a media original into a local temp file for the duration of `fn`, then remove the
|
|
11
|
+
* whole temp directory — success or failure.
|
|
12
|
+
*
|
|
13
|
+
* File-based media engines (mediabunny, and most others) want random access to a local path, while
|
|
14
|
+
* a disk object only offers bytes/stream — so file-shaped transformers all start with this same
|
|
15
|
+
* dance. The bytes are **streamed** to disk, never buffered whole: the typical subject is a video.
|
|
16
|
+
* The file keeps the original's extension purely as a debugging nicety; engines detect the real
|
|
17
|
+
* format from content.
|
|
18
|
+
*/
|
|
19
|
+
export declare function withSourceFile<T>(context: TransformerContext, fn: (source: MaterializedSource) => Promise<T>): Promise<T>;
|
|
20
|
+
//# sourceMappingURL=source_file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source_file.d.ts","sourceRoot":"","sources":["../../../src/transformers/source_file.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,sDAAsD;AACtD,MAAM,WAAW,kBAAkB;IACjC,0CAA0C;IAC1C,UAAU,EAAE,MAAM,CAAC;IACnB,mGAAmG;IACnG,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;GASG;AACH,wBAAsB,cAAc,CAAC,CAAC,EACpC,OAAO,EAAE,kBAAkB,EAC3B,EAAE,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,OAAO,CAAC,CAAC,CAAC,GAC7C,OAAO,CAAC,CAAC,CAAC,CAYZ"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { createWriteStream } from 'node:fs';
|
|
2
|
+
import { mkdtemp, rm } from 'node:fs/promises';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import { extname, join } from 'node:path';
|
|
5
|
+
import { pipeline } from 'node:stream/promises';
|
|
6
|
+
/**
|
|
7
|
+
* Materialize a media original into a local temp file for the duration of `fn`, then remove the
|
|
8
|
+
* whole temp directory — success or failure.
|
|
9
|
+
*
|
|
10
|
+
* File-based media engines (mediabunny, and most others) want random access to a local path, while
|
|
11
|
+
* a disk object only offers bytes/stream — so file-shaped transformers all start with this same
|
|
12
|
+
* dance. The bytes are **streamed** to disk, never buffered whole: the typical subject is a video.
|
|
13
|
+
* The file keeps the original's extension purely as a debugging nicety; engines detect the real
|
|
14
|
+
* format from content.
|
|
15
|
+
*/
|
|
16
|
+
export async function withSourceFile(context, fn) {
|
|
17
|
+
const tempDir = await mkdtemp(join(tmpdir(), 'agora-media-transform-'));
|
|
18
|
+
try {
|
|
19
|
+
const extension = extname(context.record.fileName);
|
|
20
|
+
const sourcePath = join(tempDir, `source${extension || '.bin'}`);
|
|
21
|
+
await pipeline(await context.getStream(), createWriteStream(sourcePath));
|
|
22
|
+
return await fn({ sourcePath, tempDir });
|
|
23
|
+
}
|
|
24
|
+
finally {
|
|
25
|
+
await rm(tempDir, { recursive: true, force: true }).catch(() => {
|
|
26
|
+
// best-effort: temp cleanup must never mask the transform's own outcome
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=source_file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source_file.js","sourceRoot":"","sources":["../../../src/transformers/source_file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAWhD;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,OAA2B,EAC3B,EAA8C;IAE9C,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,wBAAwB,CAAC,CAAC,CAAC;IACxE,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACnD,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,EAAE,SAAS,SAAS,IAAI,MAAM,EAAE,CAAC,CAAC;QACjE,MAAM,QAAQ,CAAC,MAAM,OAAO,CAAC,SAAS,EAAE,EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAC,CAAC;QACzE,OAAO,MAAM,EAAE,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,CAAC;IAC3C,CAAC;YAAS,CAAC;QACT,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;YAC7D,wEAAwE;QAC1E,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
package/dist/src/types.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { Readable } from 'node:stream';
|
|
2
|
+
import type { DirectUploadCreatedSession } from './direct_upload.js';
|
|
3
|
+
import type { DirectUploadResponse } from './direct_upload_handler.js';
|
|
4
|
+
import type { AttachExistingInput } from './media_library.js';
|
|
5
|
+
import type { MediaRecord } from './media_record.js';
|
|
2
6
|
/**
|
|
3
7
|
* The minimal disk surface `@adonis-agora/media` needs — a structural subset of an
|
|
4
8
|
* `@adonisjs/drive` (flydrive) Disk, so a real Drive disk satisfies it directly. The library
|
|
@@ -173,4 +177,80 @@ export interface MultipartUploadDisk {
|
|
|
173
177
|
* Omitting the name yields the configured default disk.
|
|
174
178
|
*/
|
|
175
179
|
export type DiskResolver = (name?: string) => Disk;
|
|
180
|
+
/**
|
|
181
|
+
* The app's decision for ONE direct upload, returned by {@link DirectUploadPolicy.onInitiate}. The
|
|
182
|
+
* library owns the invariant mechanics (open the multipart upload, presign, persist the session,
|
|
183
|
+
* confirm parts, assemble, adopt); the policy supplies the variant — above all the final object
|
|
184
|
+
* {@link key}, resolved server-side per user/tenant (the client sends a `fileName`, never a key).
|
|
185
|
+
*
|
|
186
|
+
* `response` is merged onto the `201` body the client receives (after the session fields), so a
|
|
187
|
+
* policy can hand the client extra data — e.g. the app-side `directUploadSessionId` it just
|
|
188
|
+
* persisted. `rollback` runs if anything after `onInitiate` throws (MIME gate, S3 open), letting the
|
|
189
|
+
* policy undo app-side state it already created.
|
|
190
|
+
*/
|
|
191
|
+
export type InitiateDecision<C> = {
|
|
192
|
+
key: string;
|
|
193
|
+
collection?: string;
|
|
194
|
+
disk?: string;
|
|
195
|
+
visibility?: 'public' | 'private';
|
|
196
|
+
partSize?: number;
|
|
197
|
+
metadata?: Record<string, string>;
|
|
198
|
+
response?: Record<string, unknown>;
|
|
199
|
+
context?: C;
|
|
200
|
+
rollback?: () => void | Promise<void>;
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* How a completed upload maps onto the media library, returned by
|
|
204
|
+
* {@link DirectUploadPolicy.resolveComplete}. `target` is everything `attachExisting` needs to adopt
|
|
205
|
+
* the already-uploaded object (minus `key`/`disk`/`size`, which the session already fixes).
|
|
206
|
+
*/
|
|
207
|
+
export type CompleteResolution<C> = {
|
|
208
|
+
sessionId: string;
|
|
209
|
+
target: Omit<AttachExistingInput, 'key' | 'disk' | 'size'>;
|
|
210
|
+
context?: C;
|
|
211
|
+
};
|
|
212
|
+
/** Which policy phase failed, with the decision/resolution in flight — handed to {@link DirectUploadPolicy.mapError}. */
|
|
213
|
+
export type PolicyErrorInfo<C> = {
|
|
214
|
+
phase: 'initiate';
|
|
215
|
+
decision?: InitiateDecision<C> | undefined;
|
|
216
|
+
} | {
|
|
217
|
+
phase: 'complete';
|
|
218
|
+
resolution?: CompleteResolution<C> | undefined;
|
|
219
|
+
} | {
|
|
220
|
+
phase: 'abort';
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* The app-injected strategy that turns the framework-neutral {@link DirectUploadHandler} into a
|
|
224
|
+
* complete upload feature. The handler stays dumb and authorization-free; the policy answers the
|
|
225
|
+
* app-specific questions — where the object lives (`onInitiate`), what it becomes on completion
|
|
226
|
+
* (`resolveComplete`/`onComplete`), and how failures read as HTTP (`mapError`).
|
|
227
|
+
*
|
|
228
|
+
* Methods (not arrow properties) on purpose: TypeScript checks method parameters bivariantly, so an
|
|
229
|
+
* app's `DirectUploadPolicy<HttpContext, FileUpload>` is assignable to the handler's
|
|
230
|
+
* `DirectUploadPolicy<unknown, unknown>` without a cast.
|
|
231
|
+
*/
|
|
232
|
+
export interface DirectUploadPolicy<Ctx, C> {
|
|
233
|
+
onInitiate(ctx: Ctx, input: {
|
|
234
|
+
fileName: string;
|
|
235
|
+
size: number;
|
|
236
|
+
contentType?: string | undefined;
|
|
237
|
+
metadata?: Record<string, string> | undefined;
|
|
238
|
+
}): Promise<InitiateDecision<C>> | InitiateDecision<C>;
|
|
239
|
+
onInitiated?(ctx: Ctx, info: {
|
|
240
|
+
decision: InitiateDecision<C>;
|
|
241
|
+
session: DirectUploadCreatedSession;
|
|
242
|
+
}): Promise<void> | void;
|
|
243
|
+
resolveComplete(ctx: Ctx, input: {
|
|
244
|
+
id: string;
|
|
245
|
+
parts?: MultipartPart[] | undefined;
|
|
246
|
+
}): Promise<CompleteResolution<C>> | CompleteResolution<C>;
|
|
247
|
+
onComplete(ctx: Ctx, info: {
|
|
248
|
+
record: MediaRecord;
|
|
249
|
+
resolution: CompleteResolution<C>;
|
|
250
|
+
}): Promise<unknown>;
|
|
251
|
+
onAbort?(ctx: Ctx, input: {
|
|
252
|
+
id: string;
|
|
253
|
+
}): Promise<void> | void;
|
|
254
|
+
mapError?(ctx: Ctx, error: unknown, info: PolicyErrorInfo<C>): Promise<DirectUploadResponse | undefined> | DirectUploadResponse | undefined;
|
|
255
|
+
}
|
|
176
256
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/src/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;;;;;;;GASG;AACH,MAAM,WAAW,IAAI;IACnB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,UAA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CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAC1D,UAAU,CACR,GAAG,EAAE,GAAG,EACR,IAAI,EAAE;QAAE,MAAM,EAAE,WAAW,CAAC;QAAC,UAAU,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAA;KAAE,GAC/D,OAAO,CAAC,OAAO,CAAC,CAAC;IACpB,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAChE,QAAQ,CAAC,CACP,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,GACvB,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC,GAAG,oBAAoB,GAAG,SAAS,CAAC;CACjF"}
|
|
@@ -55,5 +55,17 @@ export default defineConfig({
|
|
|
55
55
|
// sessionTtlSeconds: 24 * 60 * 60,
|
|
56
56
|
// routes: { enabled: true, prefix: '/media/uploads/tus' },
|
|
57
57
|
// },
|
|
58
|
+
//
|
|
59
|
+
// // Session-backed direct uploads — the browser PUTs multipart parts straight to S3 through
|
|
60
|
+
// // presigned URLs (bytes never pass through the app), and the session (uploadId, part size,
|
|
61
|
+
// // confirmed ETags) persists server-side so an interrupted upload resumes after a page
|
|
62
|
+
// // reload. Needs a multipart-capable disk (disks.s3()); shares the session tables above.
|
|
63
|
+
// direct: {
|
|
64
|
+
// store: 'lucid',
|
|
65
|
+
// stores: { lucid: uploadSessions.lucid() },
|
|
66
|
+
// partSize: 20 * 1024 * 1024,
|
|
67
|
+
// sessionTtlSeconds: 24 * 60 * 60,
|
|
68
|
+
// routes: { enabled: true, prefix: '/media/uploads/direct/sessions', collection: 'videos' },
|
|
69
|
+
// },
|
|
58
70
|
// },
|
|
59
71
|
})
|