@adonis-agora/media 0.8.2 → 0.9.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.
Files changed (104) hide show
  1. package/CHANGELOG.md +76 -0
  2. package/README.md +2 -2
  3. package/dist/providers/media_provider.d.ts.map +1 -1
  4. package/dist/providers/media_provider.js +113 -0
  5. package/dist/providers/media_provider.js.map +1 -1
  6. package/dist/src/content_type.d.ts +6 -1
  7. package/dist/src/content_type.d.ts.map +1 -1
  8. package/dist/src/content_type.js +102 -7
  9. package/dist/src/content_type.js.map +1 -1
  10. package/dist/src/define_config.d.ts +88 -5
  11. package/dist/src/define_config.d.ts.map +1 -1
  12. package/dist/src/define_config.js +7 -2
  13. package/dist/src/define_config.js.map +1 -1
  14. package/dist/src/direct_upload.d.ts +177 -0
  15. package/dist/src/direct_upload.d.ts.map +1 -0
  16. package/dist/src/direct_upload.js +299 -0
  17. package/dist/src/direct_upload.js.map +1 -0
  18. package/dist/src/direct_upload_handler.d.ts +83 -0
  19. package/dist/src/direct_upload_handler.d.ts.map +1 -0
  20. package/dist/src/direct_upload_handler.js +180 -0
  21. package/dist/src/direct_upload_handler.js.map +1 -0
  22. package/dist/src/disks/factory.d.ts +11 -3
  23. package/dist/src/disks/factory.d.ts.map +1 -1
  24. package/dist/src/disks/factory.js +5 -3
  25. package/dist/src/disks/factory.js.map +1 -1
  26. package/dist/src/disks/s3.d.ts +10 -0
  27. package/dist/src/disks/s3.d.ts.map +1 -1
  28. package/dist/src/disks/s3.js +96 -22
  29. package/dist/src/disks/s3.js.map +1 -1
  30. package/dist/src/disks/sigv4.d.ts +58 -0
  31. package/dist/src/disks/sigv4.d.ts.map +1 -0
  32. package/dist/src/disks/sigv4.js +87 -0
  33. package/dist/src/disks/sigv4.js.map +1 -0
  34. package/dist/src/disks/xml_fallback.d.ts +3 -3
  35. package/dist/src/disks/xml_fallback.js +3 -3
  36. package/dist/src/errors.d.ts +104 -0
  37. package/dist/src/errors.d.ts.map +1 -1
  38. package/dist/src/errors.js +145 -0
  39. package/dist/src/errors.js.map +1 -1
  40. package/dist/src/hls/delivery.d.ts +112 -0
  41. package/dist/src/hls/delivery.d.ts.map +1 -0
  42. package/dist/src/hls/delivery.js +118 -0
  43. package/dist/src/hls/delivery.js.map +1 -0
  44. package/dist/src/hls/playlist.d.ts +67 -0
  45. package/dist/src/hls/playlist.d.ts.map +1 -0
  46. package/dist/src/hls/playlist.js +126 -0
  47. package/dist/src/hls/playlist.js.map +1 -0
  48. package/dist/src/index.d.ts +18 -3
  49. package/dist/src/index.d.ts.map +1 -1
  50. package/dist/src/index.js +13 -2
  51. package/dist/src/index.js.map +1 -1
  52. package/dist/src/media_collection.d.ts +8 -1
  53. package/dist/src/media_collection.d.ts.map +1 -1
  54. package/dist/src/media_collection.js +23 -1
  55. package/dist/src/media_collection.js.map +1 -1
  56. package/dist/src/media_library.d.ts +32 -2
  57. package/dist/src/media_library.d.ts.map +1 -1
  58. package/dist/src/media_library.js +218 -11
  59. package/dist/src/media_library.js.map +1 -1
  60. package/dist/src/media_manager.d.ts +37 -2
  61. package/dist/src/media_manager.d.ts.map +1 -1
  62. package/dist/src/media_manager.js +54 -1
  63. package/dist/src/media_manager.js.map +1 -1
  64. package/dist/src/media_record.d.ts +22 -2
  65. package/dist/src/media_record.d.ts.map +1 -1
  66. package/dist/src/testing/fake_transformer.d.ts +32 -0
  67. package/dist/src/testing/fake_transformer.d.ts.map +1 -0
  68. package/dist/src/testing/fake_transformer.js +32 -0
  69. package/dist/src/testing/fake_transformer.js.map +1 -0
  70. package/dist/src/testing/index.d.ts +2 -0
  71. package/dist/src/testing/index.d.ts.map +1 -1
  72. package/dist/src/testing/index.js +1 -0
  73. package/dist/src/testing/index.js.map +1 -1
  74. package/dist/src/transformer.d.ts +111 -0
  75. package/dist/src/transformer.d.ts.map +1 -0
  76. package/dist/src/transformer.js +2 -0
  77. package/dist/src/transformer.js.map +1 -0
  78. package/dist/src/transformers/factory.d.ts +30 -0
  79. package/dist/src/transformers/factory.d.ts.map +1 -0
  80. package/dist/src/transformers/factory.js +34 -0
  81. package/dist/src/transformers/factory.js.map +1 -0
  82. package/dist/src/transformers/hls.d.ts +110 -0
  83. package/dist/src/transformers/hls.d.ts.map +1 -0
  84. package/dist/src/transformers/hls.js +111 -0
  85. package/dist/src/transformers/hls.js.map +1 -0
  86. package/dist/src/transformers/mediabunny.d.ts +5 -0
  87. package/dist/src/transformers/mediabunny.d.ts.map +1 -0
  88. package/dist/src/transformers/mediabunny.js +150 -0
  89. package/dist/src/transformers/mediabunny.js.map +1 -0
  90. package/dist/src/transformers/mediabunny_loader.d.ts +15 -0
  91. package/dist/src/transformers/mediabunny_loader.d.ts.map +1 -0
  92. package/dist/src/transformers/mediabunny_loader.js +21 -0
  93. package/dist/src/transformers/mediabunny_loader.js.map +1 -0
  94. package/dist/src/transformers/probe.d.ts +56 -0
  95. package/dist/src/transformers/probe.d.ts.map +1 -0
  96. package/dist/src/transformers/probe.js +32 -0
  97. package/dist/src/transformers/probe.js.map +1 -0
  98. package/dist/src/transformers/source_file.d.ts +20 -0
  99. package/dist/src/transformers/source_file.d.ts.map +1 -0
  100. package/dist/src/transformers/source_file.js +30 -0
  101. package/dist/src/transformers/source_file.js.map +1 -0
  102. package/dist/stubs/config/media.stub +12 -0
  103. package/package.json +11 -7
  104. package/LICENSE +0 -21
@@ -0,0 +1,112 @@
1
+ import type { DeliveryResult } from '../delivery.js';
2
+ import type { MediaLibrary } from '../media_library.js';
3
+ /** Identifies one file of a media's HLS package, handed to the URL callbacks. */
4
+ export interface HlsFileRef {
5
+ mediaId: string;
6
+ /** Package-relative artifact path (`'index.m3u8'`, `'playlist-1.m3u8'`, `'segment-0-3.ts'`). */
7
+ file: string;
8
+ }
9
+ /** Builds the URL a rewritten playlist reference should point at. */
10
+ export type HlsUrlBuilder = (ref: HlsFileRef) => string | Promise<string>;
11
+ /** What {@link HlsDeliveryHandler.handle} is asked to serve. */
12
+ export interface HlsDeliveryRequest {
13
+ mediaId: string;
14
+ /**
15
+ * Which file of the package, relative to the conversion prefix. Omit for the entry (master)
16
+ * playlist. Validated against the conversion's persisted artifact list, so a request can never
17
+ * reach outside the package.
18
+ */
19
+ file?: string | undefined;
20
+ }
21
+ /**
22
+ * What serving one HLS package file yields: playlists come back as rewritten text (they are
23
+ * *always* rewritten, never proxied raw — raw ones reference the storage layout, not URLs), and
24
+ * media files come back as the usual {@link DeliveryResult} (`redirect` to a signed URL, or a
25
+ * `stream` to pipe).
26
+ */
27
+ export type HlsDeliveryResult = {
28
+ kind: 'playlist';
29
+ content: string;
30
+ contentType: string;
31
+ fileName: string;
32
+ } | DeliveryResult;
33
+ export interface HlsDeliveryHandlerOptions {
34
+ /** The {@link MediaLibrary} records are resolved from — or a `MediaManager`, whose `.library` is used. */
35
+ library: MediaLibrary | {
36
+ library: MediaLibrary;
37
+ };
38
+ /** Name of the HLS conversion on the record. Default `'hls'` (the {@link HlsTransformer} default). */
39
+ conversion?: string | undefined;
40
+ /**
41
+ * URL for a **sub-playlist** reference (master → media playlists, audio renditions). Required,
42
+ * and it should point back at a route of yours that calls this handler again — playlists must be
43
+ * rewritten on every hop, and your route is where your authorization runs. There is no safe
44
+ * library default: presigning a playlist would serve it raw from storage, whose relative
45
+ * references then resolve against the storage host and break (or leak).
46
+ */
47
+ urlForPlaylist: HlsUrlBuilder;
48
+ /**
49
+ * URL for a **media** reference (segments, init sections). Default: a presigned URL straight to
50
+ * the object on the disk (`segmentTtlSeconds` lifetime) — the common case, letting players pull
51
+ * segments from storage/CDN without the bytes transiting your app. Point it at your own proxy
52
+ * route instead when storage isn't reachable from clients (then serve those requests with
53
+ * {@link HlsDeliveryHandler.handle}, which streams media files per `segmentDelivery`).
54
+ */
55
+ urlForSegment?: HlsUrlBuilder | undefined;
56
+ /** Lifetime of default presigned segment URLs, seconds. Default 300. */
57
+ segmentTtlSeconds?: number | undefined;
58
+ /**
59
+ * How {@link HlsDeliveryHandler.handle} answers a request for a media file (it always answers
60
+ * playlists with rewritten text): `'redirect'` (default) to a presigned URL, or `'stream'` to
61
+ * proxy the bytes through the app.
62
+ */
63
+ segmentDelivery?: 'redirect' | 'stream' | undefined;
64
+ }
65
+ /**
66
+ * Framework-agnostic HLS read path — the {@link MediaDeliveryHandler} of a transformer-generated
67
+ * HLS package. One route of yours receives `(:mediaId, :file?)` and delegates here; the handler
68
+ * resolves the record's HLS conversion, validates the requested file against the package's
69
+ * persisted artifact list, and:
70
+ *
71
+ * - for a **playlist**: returns its content with every relative reference rewritten — sub-playlist
72
+ * references through your `urlForPlaylist` (auth stays yours), media references through
73
+ * `urlForSegment` or a presigned URL;
74
+ * - for a **media file**: returns a `redirect` (presigned) or a `stream`, per `segmentDelivery`.
75
+ *
76
+ * ```ts
77
+ * const hls = new HlsDeliveryHandler({
78
+ * library: media,
79
+ * urlForPlaylist: ({ mediaId, file }) => router.makeUrl('videos.hls', { id: mediaId, file }),
80
+ * })
81
+ *
82
+ * router.get('/videos/:id/hls/:file?', async ({ params, response, auth }) => {
83
+ * await authorize(auth.user, params.id) // ← the app's job, as everywhere
84
+ * const result = await hls.handle({ mediaId: params.id, file: params.file })
85
+ * if (result.kind === 'redirect') return response.redirect(result.url)
86
+ * if (result.kind === 'stream') {
87
+ * response.header('content-type', result.mimeType)
88
+ * return response.stream(result.stream)
89
+ * }
90
+ * response.header('content-type', result.contentType)
91
+ * return response.send(result.content)
92
+ * }).use(middleware.auth())
93
+ * ```
94
+ *
95
+ * **This handler performs NO authorization** — the same split as {@link MediaDeliveryHandler} and
96
+ * `TusUploadHandler`: guard the route before calling `handle`. Note that a presigned segment URL
97
+ * (the default) is itself a capability: whoever holds it can fetch that segment until the TTL
98
+ * expires. That is the standard HLS trade-off — keep `segmentTtlSeconds` short, or use
99
+ * `segmentDelivery: 'stream'` with a segment `urlForSegment` pointing back at your route to keep
100
+ * every byte behind your auth.
101
+ */
102
+ export declare class HlsDeliveryHandler {
103
+ private readonly library;
104
+ private readonly conversion;
105
+ private readonly urlForPlaylist;
106
+ private readonly urlForSegment;
107
+ private readonly segmentTtlSeconds;
108
+ private readonly segmentDelivery;
109
+ constructor(options: HlsDeliveryHandlerOptions);
110
+ handle(request: HlsDeliveryRequest): Promise<HlsDeliveryResult>;
111
+ }
112
+ //# sourceMappingURL=delivery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delivery.d.ts","sourceRoot":"","sources":["../../../src/hls/delivery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAOrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAQxD,iFAAiF;AACjF,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,gGAAgG;IAChG,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qEAAqE;AACrE,MAAM,MAAM,aAAa,GAAG,CAAC,GAAG,EAAE,UAAU,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAE1E,gEAAgE;AAChE,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B;AAED;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GACzB;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAC5E,cAAc,CAAC;AAEnB,MAAM,WAAW,yBAAyB;IACxC,0GAA0G;IAC1G,OAAO,EAAE,YAAY,GAAG;QAAE,OAAO,EAAE,YAAY,CAAA;KAAE,CAAC;IAClD,sGAAsG;IACtG,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC;;;;;;OAMG;IACH,cAAc,EAAE,aAAa,CAAC;IAC9B;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IAC1C,wEAAwE;IACxE,iBAAiB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC;;;;OAIG;IACH,eAAe,CAAC,EAAE,UAAU,GAAG,QAAQ,GAAG,SAAS,CAAC;CACrD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;IACvC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAgB;IAC/C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA4B;IAC1D,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAS;IAC3C,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAwB;gBAE5C,OAAO,EAAE,yBAAyB;IAUxC,MAAM,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC;CA+DtE"}
@@ -0,0 +1,118 @@
1
+ import { DEFAULT_DELIVERY_SIGNED_TTL_SECONDS } from '../delivery.js';
2
+ import { ConversionArtifactMissingError, MediaNotFoundError, TransformNotReadyError, } from '../errors.js';
3
+ import { HLS_PLAYLIST_CONTENT_TYPE, hlsArtifactContentType, resolvePackagePath, rewriteHlsPlaylist, } from './playlist.js';
4
+ /**
5
+ * Framework-agnostic HLS read path — the {@link MediaDeliveryHandler} of a transformer-generated
6
+ * HLS package. One route of yours receives `(:mediaId, :file?)` and delegates here; the handler
7
+ * resolves the record's HLS conversion, validates the requested file against the package's
8
+ * persisted artifact list, and:
9
+ *
10
+ * - for a **playlist**: returns its content with every relative reference rewritten — sub-playlist
11
+ * references through your `urlForPlaylist` (auth stays yours), media references through
12
+ * `urlForSegment` or a presigned URL;
13
+ * - for a **media file**: returns a `redirect` (presigned) or a `stream`, per `segmentDelivery`.
14
+ *
15
+ * ```ts
16
+ * const hls = new HlsDeliveryHandler({
17
+ * library: media,
18
+ * urlForPlaylist: ({ mediaId, file }) => router.makeUrl('videos.hls', { id: mediaId, file }),
19
+ * })
20
+ *
21
+ * router.get('/videos/:id/hls/:file?', async ({ params, response, auth }) => {
22
+ * await authorize(auth.user, params.id) // ← the app's job, as everywhere
23
+ * const result = await hls.handle({ mediaId: params.id, file: params.file })
24
+ * if (result.kind === 'redirect') return response.redirect(result.url)
25
+ * if (result.kind === 'stream') {
26
+ * response.header('content-type', result.mimeType)
27
+ * return response.stream(result.stream)
28
+ * }
29
+ * response.header('content-type', result.contentType)
30
+ * return response.send(result.content)
31
+ * }).use(middleware.auth())
32
+ * ```
33
+ *
34
+ * **This handler performs NO authorization** — the same split as {@link MediaDeliveryHandler} and
35
+ * `TusUploadHandler`: guard the route before calling `handle`. Note that a presigned segment URL
36
+ * (the default) is itself a capability: whoever holds it can fetch that segment until the TTL
37
+ * expires. That is the standard HLS trade-off — keep `segmentTtlSeconds` short, or use
38
+ * `segmentDelivery: 'stream'` with a segment `urlForSegment` pointing back at your route to keep
39
+ * every byte behind your auth.
40
+ */
41
+ export class HlsDeliveryHandler {
42
+ library;
43
+ conversion;
44
+ urlForPlaylist;
45
+ urlForSegment;
46
+ segmentTtlSeconds;
47
+ segmentDelivery;
48
+ constructor(options) {
49
+ const source = options.library;
50
+ this.library = 'library' in source ? source.library : source;
51
+ this.conversion = options.conversion ?? 'hls';
52
+ this.urlForPlaylist = options.urlForPlaylist;
53
+ this.urlForSegment = options.urlForSegment;
54
+ this.segmentTtlSeconds = options.segmentTtlSeconds ?? DEFAULT_DELIVERY_SIGNED_TTL_SECONDS;
55
+ this.segmentDelivery = options.segmentDelivery ?? 'redirect';
56
+ }
57
+ async handle(request) {
58
+ const { mediaId } = request;
59
+ const record = await this.library.find(mediaId);
60
+ if (!record)
61
+ throw new MediaNotFoundError(mediaId);
62
+ const variant = record.conversions[this.conversion];
63
+ if (!variant)
64
+ throw new TransformNotReadyError(mediaId, this.conversion);
65
+ if (variant.path === undefined || variant.disk === undefined) {
66
+ throw new ConversionArtifactMissingError(mediaId, this.conversion);
67
+ }
68
+ // The package's shape comes from what the transformer persisted; a hand-registered
69
+ // single-file conversion degrades to a one-file package.
70
+ const prefix = variant.prefix ?? variant.path.slice(0, variant.path.lastIndexOf('/') + 1);
71
+ const files = variant.files ?? [variant.path.slice(prefix.length)];
72
+ const entry = variant.path.slice(prefix.length);
73
+ const requested = request.file === undefined || request.file === '' ? entry : request.file;
74
+ // Membership in the persisted artifact list is the whole access check: no path arithmetic on
75
+ // caller input ever reaches the disk, so traversal is structurally impossible.
76
+ if (!files.includes(requested)) {
77
+ throw new MediaNotFoundError(`${mediaId}#${this.conversion}:${requested}`);
78
+ }
79
+ const disk = this.library.storage.disk(variant.disk);
80
+ const key = `${prefix}${requested}`;
81
+ if (requested.toLowerCase().endsWith('.m3u8')) {
82
+ const content = Buffer.from(await disk.getBytes(key)).toString('utf8');
83
+ const rewritten = await rewriteHlsPlaylist(content, async (ref) => {
84
+ const target = resolvePackagePath(requested, ref.uri);
85
+ // A relative reference that escapes the package or names a file the transformer never
86
+ // wrote is not ours to rewrite — leave it exactly as it was.
87
+ if (target === null || !files.includes(target))
88
+ return ref.uri;
89
+ if (ref.kind === 'playlist')
90
+ return this.urlForPlaylist({ mediaId, file: target });
91
+ if (this.urlForSegment)
92
+ return this.urlForSegment({ mediaId, file: target });
93
+ return disk.getSignedUrl(`${prefix}${target}`, { expiresIn: this.segmentTtlSeconds });
94
+ });
95
+ return {
96
+ kind: 'playlist',
97
+ content: rewritten,
98
+ contentType: HLS_PLAYLIST_CONTENT_TYPE,
99
+ fileName: requested,
100
+ };
101
+ }
102
+ if (this.segmentDelivery === 'redirect') {
103
+ return {
104
+ kind: 'redirect',
105
+ url: await disk.getSignedUrl(key, { expiresIn: this.segmentTtlSeconds }),
106
+ };
107
+ }
108
+ const metadata = await disk.getMetaData(key);
109
+ return {
110
+ kind: 'stream',
111
+ stream: await disk.getStream(key),
112
+ mimeType: metadata.contentType ?? hlsArtifactContentType(requested) ?? 'application/octet-stream',
113
+ size: metadata.contentLength,
114
+ fileName: requested.slice(requested.lastIndexOf('/') + 1),
115
+ };
116
+ }
117
+ }
118
+ //# sourceMappingURL=delivery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delivery.js","sourceRoot":"","sources":["../../../src/hls/delivery.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mCAAmC,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EACL,8BAA8B,EAC9B,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,yBAAyB,EACzB,sBAAsB,EACtB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,eAAe,CAAC;AAgEvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,OAAO,kBAAkB;IACZ,OAAO,CAAe;IACtB,UAAU,CAAS;IACnB,cAAc,CAAgB;IAC9B,aAAa,CAA4B;IACzC,iBAAiB,CAAS;IAC1B,eAAe,CAAwB;IAExD,YAAY,OAAkC;QAC5C,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,SAAS,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;QAC7D,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,KAAK,CAAC;QAC9C,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;QAC7C,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;QAC3C,IAAI,CAAC,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,IAAI,mCAAmC,CAAC;QAC1F,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,IAAI,UAAU,CAAC;IAC/D,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAA2B;QACtC,MAAM,E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AAI,EAAE,UAAU;gBAChB,OAAO,EAAE,SAAS;gBAClB,WAAW,EAAE,yBAAyB;gBACtC,QAAQ,EAAE,SAAS;aACpB,CAAC;QACJ,CAAC;QAED,IAAI,IAAI,CAAC,eAAe,KAAK,UAAU,EAAE,CAAC;YACxC,OAAO;gBACL,IAAI,EAAE,UAAU;gBAChB,GAAG,EAAE,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC;aACzE,CAAC;QACJ,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAC7C,OAAO;YACL,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,MAAM,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC;YACjC,QAAQ,EACN,QAAQ,CAAC,WAAW,IAAI,sBAAsB,CAAC,SAAS,CAAC,IAAI,0BAA0B;YACzF,IAAI,EAAE,QAAQ,CAAC,aAAa;YAC5B,QAAQ,EAAE,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;SAC1D,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * HLS playlist (`.m3u8`) reference rewriting — the read-side half of the HLS transformer.
3
+ *
4
+ * Playlists are STORED with references relative to the package's storage layout (that is what the
5
+ * muxer emits, and it keeps the stored artifacts location-agnostic). At serve time those
6
+ * references must become URLs the player can actually fetch — the app's authenticated proxy
7
+ * routes, presigned object URLs, a CDN — and only the app knows which. This module does the part
8
+ * that is the same everywhere: find every reference in a playlist, classify it, and let a
9
+ * callback decide the URL. See {@link HlsDeliveryHandler} for the assembled read path.
10
+ */
11
+ /** Content type playlists are served with (RFC 8216's `application/vnd.apple.mpegurl`). */
12
+ export declare const HLS_PLAYLIST_CONTENT_TYPE = "application/vnd.apple.mpegurl";
13
+ /** Content type for MPEG-TS segments. */
14
+ export declare const HLS_SEGMENT_CONTENT_TYPE = "video/mp2t";
15
+ /** One URI reference found in a playlist, handed to the {@link HlsUriRewriter}. */
16
+ export interface HlsUriRef {
17
+ /** The reference exactly as it appears in the playlist (may carry a query string). */
18
+ uri: string;
19
+ /**
20
+ * `'playlist'` for `.m3u8` references (variant streams in a master playlist, audio/subtitle
21
+ * renditions via `#EXT-X-MEDIA`), `'media'` for everything else (segments, `#EXT-X-MAP` init
22
+ * sections, keys). Classified by extension, ignoring any query/fragment.
23
+ */
24
+ kind: 'playlist' | 'media';
25
+ /**
26
+ * The tag whose `URI="…"` attribute holds this reference (`'EXT-X-MEDIA'`, `'EXT-X-MAP'`,
27
+ * `'EXT-X-I-FRAME-STREAM-INF'`, …), or `undefined` for a plain URI line.
28
+ */
29
+ tag?: string;
30
+ }
31
+ /**
32
+ * Maps one playlist reference to the URI that should replace it. Return the input unchanged to
33
+ * keep a reference as-is. May be async — building the replacement routinely involves presigning.
34
+ */
35
+ export type HlsUriRewriter = (ref: HlsUriRef) => string | Promise<string>;
36
+ /**
37
+ * Rewrite every **relative** URI reference in an HLS playlist through `rewrite`, covering all the
38
+ * places RFC 8216 puts one:
39
+ *
40
+ * - plain URI lines (segments in a media playlist, variant playlists in a master playlist),
41
+ * - `URI="…"` attributes on tags (`#EXT-X-MEDIA` audio/subtitle renditions, `#EXT-X-MAP` init
42
+ * sections, `#EXT-X-I-FRAME-STREAM-INF`, `#EXT-X-KEY`, …).
43
+ *
44
+ * Untouched, by design:
45
+ * - **absolute** references (`https://…`, protocol-relative `//…`, root-relative `/…`) — they no
46
+ * longer describe the storage layout, so rewriting them is not this function's business;
47
+ * - comments and every other tag/line, byte for byte (line endings included).
48
+ */
49
+ export declare function rewriteHlsPlaylist(content: string, rewrite: HlsUriRewriter): Promise<string>;
50
+ /**
51
+ * Whether a playlist reference is relative to the playlist's own location — the only kind that
52
+ * describes the storage layout and therefore the only kind {@link rewriteHlsPlaylist} rewrites.
53
+ * Anything carrying a scheme (`https:`, `data:`), protocol-relative (`//cdn/…`) or root-relative
54
+ * (`/api/…`) is already an address, not a layout detail.
55
+ */
56
+ export declare function isRelativeUri(uri: string): boolean;
57
+ /** Classify a reference by extension (query/fragment ignored): `.m3u8` ⇒ playlist, else media. */
58
+ export declare function classifyUri(uri: string): 'playlist' | 'media';
59
+ /**
60
+ * Resolve a reference found in playlist `fromFile` (both package-relative) to the package-relative
61
+ * path it points at, collapsing `.`/`..` segments. Returns `null` when the reference escapes the
62
+ * package root — the caller treats that as "not one of ours" and leaves it alone.
63
+ */
64
+ export declare function resolvePackagePath(fromFile: string, uri: string): string | null;
65
+ /** Content type for one artifact of an HLS package, by extension. */
66
+ export declare function hlsArtifactContentType(file: string): string | undefined;
67
+ //# sourceMappingURL=playlist.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"playlist.d.ts","sourceRoot":"","sources":["../../../src/hls/playlist.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,2FAA2F;AAC3F,eAAO,MAAM,yBAAyB,kCAAkC,CAAC;AAEzE,yCAAyC;AACzC,eAAO,MAAM,wBAAwB,eAAe,CAAC;AAErD,mFAAmF;AACnF,MAAM,WAAW,SAAS;IACxB,sFAAsF;IACtF,GAAG,EAAE,MAAM,CAAC;IACZ;;;;OAIG;IACH,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC;IAC3B;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,SAAS,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAE1E;;;;;;;;;;;;GAYG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,MAAM,CAAC,CAmBjB;AAyBD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAGlD;AAED,kGAAkG;AAClG,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,CAG7D;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAe/E;AAED,qEAAqE;AACrE,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CASvE"}
@@ -0,0 +1,126 @@
1
+ /**
2
+ * HLS playlist (`.m3u8`) reference rewriting — the read-side half of the HLS transformer.
3
+ *
4
+ * Playlists are STORED with references relative to the package's storage layout (that is what the
5
+ * muxer emits, and it keeps the stored artifacts location-agnostic). At serve time those
6
+ * references must become URLs the player can actually fetch — the app's authenticated proxy
7
+ * routes, presigned object URLs, a CDN — and only the app knows which. This module does the part
8
+ * that is the same everywhere: find every reference in a playlist, classify it, and let a
9
+ * callback decide the URL. See {@link HlsDeliveryHandler} for the assembled read path.
10
+ */
11
+ /** Content type playlists are served with (RFC 8216's `application/vnd.apple.mpegurl`). */
12
+ export const HLS_PLAYLIST_CONTENT_TYPE = 'application/vnd.apple.mpegurl';
13
+ /** Content type for MPEG-TS segments. */
14
+ export const HLS_SEGMENT_CONTENT_TYPE = 'video/mp2t';
15
+ /**
16
+ * Rewrite every **relative** URI reference in an HLS playlist through `rewrite`, covering all the
17
+ * places RFC 8216 puts one:
18
+ *
19
+ * - plain URI lines (segments in a media playlist, variant playlists in a master playlist),
20
+ * - `URI="…"` attributes on tags (`#EXT-X-MEDIA` audio/subtitle renditions, `#EXT-X-MAP` init
21
+ * sections, `#EXT-X-I-FRAME-STREAM-INF`, `#EXT-X-KEY`, …).
22
+ *
23
+ * Untouched, by design:
24
+ * - **absolute** references (`https://…`, protocol-relative `//…`, root-relative `/…`) — they no
25
+ * longer describe the storage layout, so rewriting them is not this function's business;
26
+ * - comments and every other tag/line, byte for byte (line endings included).
27
+ */
28
+ export async function rewriteHlsPlaylist(content, rewrite) {
29
+ // Split keeping the separators, so CRLF/LF survive exactly as they came.
30
+ const parts = content.split(/(\r?\n)/);
31
+ for (let i = 0; i < parts.length; i += 2) {
32
+ const line = parts[i];
33
+ if (line === undefined || line === '')
34
+ continue;
35
+ if (line.startsWith('#')) {
36
+ if (line.startsWith('#EXT'))
37
+ parts[i] = await rewriteTagUris(line, rewrite);
38
+ continue; // plain comment: untouched
39
+ }
40
+ const uri = line.trim();
41
+ if (uri === '' || !isRelativeUri(uri))
42
+ continue;
43
+ const replacement = await rewrite({ uri, kind: classifyUri(uri) });
44
+ // Preserve any surrounding whitespace on the line, replacing only the URI itself.
45
+ parts[i] = line.replace(uri, replacement);
46
+ }
47
+ return parts.join('');
48
+ }
49
+ const TAG_URI_ATTRIBUTE = /URI="([^"]*)"/g;
50
+ /** Rewrite every relative `URI="…"` attribute on one tag line. */
51
+ async function rewriteTagUris(line, rewrite) {
52
+ const colon = line.indexOf(':');
53
+ const tag = (colon === -1 ? line.slice(1) : line.slice(1, colon)).trim();
54
+ let output = '';
55
+ let consumed = 0;
56
+ for (const match of line.matchAll(TAG_URI_ATTRIBUTE)) {
57
+ const uri = match[1];
58
+ output += line.slice(consumed, match.index);
59
+ if (uri !== '' && isRelativeUri(uri)) {
60
+ const replacement = await rewrite({ uri, kind: classifyUri(uri), tag });
61
+ output += `URI="${replacement}"`;
62
+ }
63
+ else {
64
+ output += match[0];
65
+ }
66
+ consumed = match.index + match[0].length;
67
+ }
68
+ return output + line.slice(consumed);
69
+ }
70
+ /**
71
+ * Whether a playlist reference is relative to the playlist's own location — the only kind that
72
+ * describes the storage layout and therefore the only kind {@link rewriteHlsPlaylist} rewrites.
73
+ * Anything carrying a scheme (`https:`, `data:`), protocol-relative (`//cdn/…`) or root-relative
74
+ * (`/api/…`) is already an address, not a layout detail.
75
+ */
76
+ export function isRelativeUri(uri) {
77
+ if (uri.startsWith('/'))
78
+ return false; // covers '//' too
79
+ return !/^[a-z][a-z0-9+.-]*:/i.test(uri);
80
+ }
81
+ /** Classify a reference by extension (query/fragment ignored): `.m3u8` ⇒ playlist, else media. */
82
+ export function classifyUri(uri) {
83
+ const clean = uri.split(/[?#]/, 1)[0];
84
+ return clean.toLowerCase().endsWith('.m3u8') ? 'playlist' : 'media';
85
+ }
86
+ /**
87
+ * Resolve a reference found in playlist `fromFile` (both package-relative) to the package-relative
88
+ * path it points at, collapsing `.`/`..` segments. Returns `null` when the reference escapes the
89
+ * package root — the caller treats that as "not one of ours" and leaves it alone.
90
+ */
91
+ export function resolvePackagePath(fromFile, uri) {
92
+ const clean = uri.split(/[?#]/, 1)[0];
93
+ const slash = fromFile.lastIndexOf('/');
94
+ const base = slash === -1 ? '' : fromFile.slice(0, slash + 1);
95
+ const resolved = [];
96
+ for (const segment of `${base}${clean}`.split('/')) {
97
+ if (segment === '' || segment === '.')
98
+ continue;
99
+ if (segment === '..') {
100
+ if (resolved.length === 0)
101
+ return null;
102
+ resolved.pop();
103
+ continue;
104
+ }
105
+ resolved.push(segment);
106
+ }
107
+ return resolved.length === 0 ? null : resolved.join('/');
108
+ }
109
+ /** Content type for one artifact of an HLS package, by extension. */
110
+ export function hlsArtifactContentType(file) {
111
+ const lower = file.toLowerCase();
112
+ if (lower.endsWith('.m3u8'))
113
+ return HLS_PLAYLIST_CONTENT_TYPE;
114
+ if (lower.endsWith('.ts'))
115
+ return HLS_SEGMENT_CONTENT_TYPE;
116
+ if (lower.endsWith('.m4s') || lower.endsWith('.mp4'))
117
+ return 'video/mp4';
118
+ if (lower.endsWith('.aac'))
119
+ return 'audio/aac';
120
+ if (lower.endsWith('.mp3'))
121
+ return 'audio/mpeg';
122
+ if (lower.endsWith('.vtt'))
123
+ return 'text/vtt';
124
+ return undefined;
125
+ }
126
+ //# sourceMappingURL=playlist.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"playlist.js","sourceRoot":"","sources":["../../../src/hls/playlist.ts"],"names":[],"mappings":"AAAA;;;;;;;;;G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,OAAO,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC3D,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,sBAAsB,CAAC,IAAY;IACjD,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IACjC,IAAI,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC;QAAE,OAAO,yBAAyB,CAAC;IAC9D,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,wBAAwB,CAAC;IAC3D,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,WAAW,CAAC;IACzE,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,WAAW,CAAC;IAC/C,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,YAAY,CAAC;IAChD,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,UAAU,CAAC;IAC9C,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -1,17 +1,32 @@
1
- export { defineConfig, stores, processors, disks, uploadSessions } from './define_config.js';
2
- export type { MediaConfig, MediaUploadsConfig, MediaResumableConfig, MediaDeliveryConfig, StoreContext, StoreFactory, LucidStoreConfig, ImageProcessorFactory, DiskFactory, S3DiskConfig, S3Credentials, UploadMode, UploadSessionStoreContext, UploadSessionStoreFactory, LucidUploadSessionStoreConfig, } from './define_config.js';
1
+ export { defineConfig, stores, processors, disks, uploadSessions, transformers, } from './define_config.js';
2
+ export type { InferConversions, InferTransformers, MediaConfig, MediaUploadsConfig, MediaResumableConfig, MediaDirectUploadConfig, MediaDeliveryConfig, StoreContext, StoreFactory, LucidStoreConfig, ImageProcessorFactory, DiskFactory, S3DiskConfig, S3Credentials, UploadMode, UploadSessionStoreContext, UploadSessionStoreFactory, LucidUploadSessionStoreConfig, } from './define_config.js';
3
3
  export { MediaManager } from './media_manager.js';
4
4
  export type { MediaManagerOptions } from './media_manager.js';
5
5
  export { UploadManager } from './upload_manager.js';
6
6
  export type { UploadManagerOptions, InitiateDirectUploadInput, DirectUploadCreated, PresignPartInput, CompleteDirectUploadInput, AbortDirectUploadInput, ProxyUploadInput, } from './upload_manager.js';
7
7
  export { resolveUploadMode } from './upload_mode.js';
8
8
  export type { ResolvedUploadMode, UploadModeLevels } from './upload_mode.js';
9
+ export { DirectUploadManager, DEFAULT_DIRECT_PART_SIZE, MIN_DIRECT_PART_SIZE, MAX_DIRECT_PARTS, } from './direct_upload.js';
10
+ export type { DirectUploadManagerOptions, DirectUploadInitiateInput, DirectUploadCreatedSession, DirectUploadStatus, DirectUploadPartUrl, } from './direct_upload.js';
11
+ export { DirectUploadHandler } from './direct_upload_handler.js';
12
+ export type { DirectUploadHandlerOptions, DirectUploadRequest, DirectUploadResponse, } from './direct_upload_handler.js';
13
+ export { presignS3Url } from './disks/sigv4.js';
14
+ export type { PresignS3UrlInput, SigV4Credentials } from './disks/sigv4.js';
9
15
  export { ResumableUploadManager } from './resumable_upload.js';
10
16
  export type { ResumableUploadManagerOptions, UploadSession, UploadSessionStore, UploadSessionListFilter, CreateUploadInput, } from './resumable_upload.js';
11
17
  export { TusUploadHandler, parseTusMetadata, TUS_VERSION } from './tus.js';
12
18
  export type { TusRequest, TusResponse, TusUploadHandlerOptions } from './tus.js';
13
19
  export { MediaDeliveryHandler, resolveDeliveryMode, DEFAULT_DELIVERY_SIGNED_TTL_SECONDS, } from './delivery.js';
14
20
  export type { DeliveryMode, ResolvedDeliveryMode, DeliveryResult, DeliveryRequest, MediaDeliveryHandlerOptions, } from './delivery.js';
21
+ export type { Transformer, TransformerContext, TransformerWriteOptions, TransformResult, } from './transformer.js';
22
+ export { HlsTransformer, HLS_ENTRY_PLAYLIST, resolveWebCodecsSupport } from './transformers/hls.js';
23
+ export type { HlsTransformerOptions, HlsRemuxEngine, HlsRemuxRequest, HlsRemuxSummary, WebCodecsProvider, WebCodecsSupport, } from './transformers/hls.js';
24
+ export { MetadataProbeTransformer } from './transformers/probe.js';
25
+ export type { MetadataProbeTransformerOptions, MediaProbeEngine, MediaProbeSummary, } from './transformers/probe.js';
26
+ export { rewriteHlsPlaylist, isRelativeUri, classifyUri, resolvePackagePath, hlsArtifactContentType, HLS_PLAYLIST_CONTENT_TYPE, HLS_SEGMENT_CONTENT_TYPE, } from './hls/playlist.js';
27
+ export type { HlsUriRef, HlsUriRewriter } from './hls/playlist.js';
28
+ export { HlsDeliveryHandler } from './hls/delivery.js';
29
+ export type { HlsDeliveryHandlerOptions, HlsDeliveryRequest, HlsDeliveryResult, HlsFileRef, HlsUrlBuilder, } from './hls/delivery.js';
15
30
  export { detectMimeType, isDetectableMimeType, isClosedSignatureWhitelist, verifyContentAgainstWhitelist, SIGNATURE_HEAD_BYTES, } from './content_type.js';
16
31
  export type { ContentVerdict } from './content_type.js';
17
32
  export { createDriveBackedResolver } from './disks/drive.js';
@@ -32,6 +47,6 @@ export type { MediaCollectionConfig } from './media_collection.js';
32
47
  export type { ConversionPreset, ConversionResult, ImageProcessor } from './image_processor.js';
33
48
  export type { Disk, DiskResolver, DiskWriteOptions, DiskMetaData, SignedUrlOptions, MultipartPart, MultipartUploadDisk, ExtendedDisk, DiskCapabilities, DiskStat, CopyOptions, ListOptions, ListEntry, ListResult, } from './types.js';
34
49
  export type { MediaDiagnosticEvent, MediaDiagnosticPayloads, AttachPayload, DeletePayload, ConversionPayload, AttachmentCreatePayload, AttachmentDeletePayload, UploadStartPayload, UploadProgressPayload, UploadCompletePayload, UploadAbortPayload, } from './diagnostics.js';
35
- export { MimeNotAllowedError, ContentTypeMismatchError, ContentSignatureUnrecognizedError, DriveNotReadyError, MediaNotFoundError, MediaObjectMissingError, ConversionNotDefinedError, ImageProcessorMissingError, VariantNotFoundError, StoreNotConfiguredError, UploadNotSupportedError, UploadSessionNotFoundError, UploadOffsetConflictError, UploadSessionExpiredError, UploadSessionStoreNotConfiguredError, ResumableUploadsNotConfiguredError, } from './errors.js';
50
+ export { MimeNotAllowedError, ContentTypeMismatchError, ContentSignatureUnrecognizedError, DriveNotReadyError, MediaNotFoundError, MediaObjectMissingError, ConversionNotDefinedError, ConversionArtifactMissingError, TransformerNotDefinedError, TransformNotReadyError, TransformerConflictError, TransformerRuntimeMissingError, TransformerOutputError, HlsSourceUnsupportedError, ImageProcessorMissingError, VariantNotFoundError, StoreNotConfiguredError, UploadNotSupportedError, UploadSessionNotFoundError, UploadOffsetConflictError, UploadSessionExpiredError, UploadSessionStoreNotConfiguredError, ResumableUploadsNotConfiguredError, DirectUploadsNotConfiguredError, UploadPartSizeError, UploadPartOutOfRangeError, UploadPartsIncompleteError, } from './errors.js';
36
51
  export { configure } from '../configure.js';
37
52
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC7F,YAAY,EACV,WAAW,EACX,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,qBAAqB,EACrB,WAAW,EACX,YAAY,EACZ,aAAa,EACb,UAAU,EACV,yBAAyB,EACzB,yBAAyB,EACzB,6BAA6B,GAC9B,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,YAAY,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAG9D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,YAAY,EACV,oBAAoB,EACpB,yBAAyB,EACzB,mBAAmB,EACnB,gBAAgB,EAChB,y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AkB,EAClB,uBAAuB,EACvB,yBAAyB,EACzB,0BAA0B,EAC1B,oBAAoB,EACpB,uBAAuB,EACvB,uBAAuB,EACvB,0BAA0B,EAC1B,yBAAyB,EACzB,yBAAyB,EACzB,oCAAoC,EACpC,kCAAkC,GACnC,MAAM,aAAa,CAAC;AAIrB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,MAAM,EACN,UAAU,EACV,KAAK,EACL,cAAc,EACd,YAAY,GACb,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,gBAAgB,EAChB,iBAAiB,EACjB,WAAW,EACX,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACvB,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,qBAAqB,EACrB,WAAW,EACX,YAAY,EACZ,aAAa,EACb,UAAU,EACV,yBAAyB,EACzB,yBAAyB,EACzB,6BAA6B,GAC9B,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,YAAY,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAG9D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,YAAY,EACV,oBAAoB,EACpB,yBAAyB,EACzB,mBAAmB,EACnB,gBAAgB,EAChB,yBAAyB,EACzB,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,YAAY,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAG7E,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,0BAA0B,EA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,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,aAAa,CAAC;AAIrB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
package/dist/src/index.js CHANGED
@@ -1,15 +1,26 @@
1
1
  // Config idiom
2
- export { defineConfig, stores, processors, disks, uploadSessions } from './define_config.js';
2
+ export { defineConfig, stores, processors, disks, uploadSessions, transformers, } from './define_config.js';
3
3
  // Manager + layers
4
4
  export { MediaManager } from './media_manager.js';
5
5
  // Direct-S3 upload modes (proxy + direct multipart)
6
6
  export { UploadManager } from './upload_manager.js';
7
7
  export { resolveUploadMode } from './upload_mode.js';
8
+ // Session-backed direct uploads (browser→S3 multipart with a persisted, resumable session)
9
+ export { DirectUploadManager, DEFAULT_DIRECT_PART_SIZE, MIN_DIRECT_PART_SIZE, MAX_DIRECT_PARTS, } from './direct_upload.js';
10
+ export { DirectUploadHandler } from './direct_upload_handler.js';
11
+ // Hand-rolled SigV4 query presigner (what the S3 disk signs part/GET URLs with; exported for
12
+ // wiring presigned URLs outside the bundled disk)
13
+ export { presignS3Url } from './disks/sigv4.js';
8
14
  // Resumable (TUS) uploads
9
15
  export { ResumableUploadManager } from './resumable_upload.js';
10
16
  export { TusUploadHandler, parseTusMetadata, TUS_VERSION } from './tus.js';
11
17
  // Configurable delivery (the read-side counterpart to the upload modes)
12
18
  export { MediaDeliveryHandler, resolveDeliveryMode, DEFAULT_DELIVERY_SIGNED_TTL_SECONDS, } from './delivery.js';
19
+ export { HlsTransformer, HLS_ENTRY_PLAYLIST, resolveWebCodecsSupport } from './transformers/hls.js';
20
+ export { MetadataProbeTransformer } from './transformers/probe.js';
21
+ // HLS delivery (playlist rewriting + the framework-agnostic package handler)
22
+ export { rewriteHlsPlaylist, isRelativeUri, classifyUri, resolvePackagePath, hlsArtifactContentType, HLS_PLAYLIST_CONTENT_TYPE, HLS_SEGMENT_CONTENT_TYPE, } from './hls/playlist.js';
23
+ export { HlsDeliveryHandler } from './hls/delivery.js';
13
24
  // Real-content validation (magic-byte signatures behind `acceptsMimeTypes`)
14
25
  export { detectMimeType, isDetectableMimeType, isClosedSignatureWhitelist, verifyContentAgainstWhitelist, SIGNATURE_HEAD_BYTES, } from './content_type.js';
15
26
  // Drive-backed disk resolution (the provider's resolver; exported for wiring media outside AdonisJS)
@@ -22,7 +33,7 @@ export { StorageManager } from './storage_manager.js';
22
33
  export { DEFAULT_MEDIA_LIST_LIMIT, MAX_MEDIA_LIST_LIMIT, encodeMediaCursor, decodeMediaCursor, clampMediaListLimit, } from './media_store.js';
23
34
  export { MediaCollectionRegistry } from './media_collection.js';
24
35
  // Errors
25
- export { MimeNotAllowedError, ContentTypeMismatchError, ContentSignatureUnrecognizedError, DriveNotReadyError, MediaNotFoundError, MediaObjectMissingError, ConversionNotDefinedError, ImageProcessorMissingError, VariantNotFoundError, StoreNotConfiguredError, UploadNotSupportedError, UploadSessionNotFoundError, UploadOffsetConflictError, UploadSessionExpiredError, UploadSessionStoreNotConfiguredError, ResumableUploadsNotConfiguredError, } from './errors.js';
36
+ export { MimeNotAllowedError, ContentTypeMismatchError, ContentSignatureUnrecognizedError, DriveNotReadyError, MediaNotFoundError, MediaObjectMissingError, ConversionNotDefinedError, ConversionArtifactMissingError, TransformerNotDefinedError, TransformNotReadyError, TransformerConflictError, TransformerRuntimeMissingError, TransformerOutputError, HlsSourceUnsupportedError, ImageProcessorMissingError, VariantNotFoundError, StoreNotConfiguredError, UploadNotSupportedError, UploadSessionNotFoundError, UploadOffsetConflictError, UploadSessionExpiredError, UploadSessionStoreNotConfiguredError, ResumableUploadsNotConfiguredError, DirectUploadsNotConfiguredError, UploadPartSizeError, UploadPartOutOfRangeError, UploadPartsIncompleteError, } from './errors.js';
26
37
  // `node ace configure` reaches the hook through this entry point, not through the package's
27
38
  // `./configure` export path.
28
39
  export { configure } from '../configure.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAA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+BAA+B,EAC/B,mBAAmB,EACnB,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,aAAa,CAAC;AAErB,4FAA4F;AAC5F,6BAA6B;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import type { ConversionPreset } from './image_processor.js';
2
+ import type { Transformer } from './transformer.js';
2
3
  export interface MediaCollectionConfig {
3
4
  name: string;
4
5
  /** Single-file collection: attaching replaces any existing media. */
@@ -9,10 +10,16 @@ export interface MediaCollectionConfig {
9
10
  acceptsMimeTypes?: string[];
10
11
  /** Image conversion presets available for this collection. */
11
12
  conversions?: ConversionPreset[];
13
+ /**
14
+ * Content transformers available for this collection (e.g. `transformers.hls()`). Each produces
15
+ * a named entry in `record.conversions`, so transformer names and preset names share one
16
+ * namespace — a collision throws {@link TransformerConflictError} at construction.
17
+ */
18
+ transformers?: Transformer[];
12
19
  }
13
20
  export declare class MediaCollectionRegistry {
14
21
  private readonly map;
15
- constructor(collections?: MediaCollectionConfig[]);
22
+ constructor(collections?: readonly MediaCollectionConfig[]);
16
23
  /** Registered config for a collection, or a permissive default. */
17
24
  get(name: string): MediaCollectionConfig;
18
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"media_collection.d.ts","sourceRoot":"","sources":["../../src/media_collection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,qEAAqE;IACrE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,8EAA8E;IAC9E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wEAAwE;IACxE,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,8DAA8D;IAC9D,WAAW,CAAC,EAAE,gBAAgB,EAAE,CAAC;CAClC;AAED,qBAAa,uBAAuB;IAClC,OAAO,CAAC,QAAQ,CAAC,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