tiny-essentials 1.29.1 → 1.29.2

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 (128) hide show
  1. package/changelog/1/29/2.md +82 -0
  2. package/dist/v1/TinyBasicsEs.min.js +1 -1
  3. package/dist/v1/TinyEssentials.min.js +1 -1
  4. package/dist/v1/TinyFetchLoader.min.js +1 -0
  5. package/dist/v1/TinyImageLoader.min.js +1 -0
  6. package/dist/v1/TinyMediaCache.min.js +1 -0
  7. package/dist/v1/TinyMediaLoader.min.js +1 -0
  8. package/dist/v1/basics/index.cjs +5 -0
  9. package/dist/v1/basics/index.d.mts +2 -1
  10. package/dist/v1/basics/index.d.mts.map +1 -1
  11. package/dist/v1/basics/index.mjs +2 -1
  12. package/dist/v1/basics/media/youtube.cjs +275 -0
  13. package/dist/v1/basics/media/youtube.d.mts +107 -0
  14. package/dist/v1/basics/media/youtube.d.mts.map +1 -0
  15. package/dist/v1/basics/media/youtube.mjs +214 -0
  16. package/dist/v1/index.cjs +13 -0
  17. package/dist/v1/index.d.mts +6 -1
  18. package/dist/v1/index.d.mts.map +1 -1
  19. package/dist/v1/index.mjs +7 -2
  20. package/dist/v1/libs/fs/plugins/OPFS/StorageBucket.cjs +0 -1
  21. package/dist/v1/libs/fs/plugins/OPFS/StorageBucket.d.mts +0 -1
  22. package/dist/v1/libs/fs/plugins/OPFS/StorageBucket.d.mts.map +1 -1
  23. package/dist/v1/libs/fs/plugins/OPFS/StorageBucket.mjs +0 -1
  24. package/dist/v1/libs/fs/plugins/OPFS/index.cjs +0 -8
  25. package/dist/v1/libs/fs/plugins/OPFS/index.d.mts +0 -8
  26. package/dist/v1/libs/fs/plugins/OPFS/index.d.mts.map +1 -1
  27. package/dist/v1/libs/fs/plugins/OPFS/index.mjs +0 -8
  28. package/dist/v1/libs/html/TinyHtml.cjs +1 -1
  29. package/dist/v1/libs/html/TinyHtml.d.mts +2 -2
  30. package/dist/v1/libs/html/TinyHtml.d.mts.map +1 -1
  31. package/dist/v1/libs/html/TinyHtml.mjs +1 -1
  32. package/dist/v1/libs/html/loader/TinyMediaLoader.cjs +1999 -0
  33. package/dist/v1/libs/html/loader/TinyMediaLoader.d.mts +999 -0
  34. package/dist/v1/libs/html/loader/TinyMediaLoader.d.mts.map +1 -0
  35. package/dist/v1/libs/html/loader/TinyMediaLoader.mjs +1852 -0
  36. package/dist/v1/libs/html/loader/beta/formats/TinyAudioLoader.cjs +77 -0
  37. package/dist/v1/libs/html/loader/beta/formats/TinyAudioLoader.d.mts +103 -0
  38. package/dist/v1/libs/html/loader/beta/formats/TinyAudioLoader.d.mts.map +1 -0
  39. package/dist/v1/libs/html/loader/beta/formats/TinyAudioLoader.mjs +67 -0
  40. package/dist/v1/libs/html/loader/beta/formats/TinyContentLoader.cjs +630 -0
  41. package/dist/v1/libs/html/loader/beta/formats/TinyContentLoader.d.mts +138 -0
  42. package/dist/v1/libs/html/loader/beta/formats/TinyContentLoader.d.mts.map +1 -0
  43. package/dist/v1/libs/html/loader/beta/formats/TinyContentLoader.mjs +576 -0
  44. package/dist/v1/libs/html/loader/beta/formats/TinyVideoLoader.cjs +70 -0
  45. package/dist/v1/libs/html/loader/beta/formats/TinyVideoLoader.d.mts +100 -0
  46. package/dist/v1/libs/html/loader/beta/formats/TinyVideoLoader.d.mts.map +1 -0
  47. package/dist/v1/libs/html/loader/beta/formats/TinyVideoLoader.mjs +60 -0
  48. package/dist/v1/libs/html/loader/beta/probe/TinyMediaProbe.cjs +946 -0
  49. package/dist/v1/libs/html/loader/beta/probe/TinyMediaProbe.d.mts +67 -0
  50. package/dist/v1/libs/html/loader/beta/probe/TinyMediaProbe.d.mts.map +1 -0
  51. package/dist/v1/libs/html/loader/beta/probe/TinyMediaProbe.mjs +896 -0
  52. package/dist/v1/libs/html/loader/formats/TinyFetchLoader.cjs +225 -0
  53. package/dist/v1/libs/html/loader/formats/TinyFetchLoader.d.mts +149 -0
  54. package/dist/v1/libs/html/loader/formats/TinyFetchLoader.d.mts.map +1 -0
  55. package/dist/v1/libs/html/loader/formats/TinyFetchLoader.mjs +197 -0
  56. package/dist/v1/libs/html/loader/formats/TinyImageLoader.cjs +1454 -0
  57. package/dist/v1/libs/html/loader/formats/TinyImageLoader.d.mts +200 -0
  58. package/dist/v1/libs/html/loader/formats/TinyImageLoader.d.mts.map +1 -0
  59. package/dist/v1/libs/html/loader/formats/TinyImageLoader.mjs +1317 -0
  60. package/dist/v1/libs/html/loader/probe/TinyImageProbe.cjs +668 -0
  61. package/dist/v1/libs/html/loader/probe/TinyImageProbe.d.mts +83 -0
  62. package/dist/v1/libs/html/loader/probe/TinyImageProbe.d.mts.map +1 -0
  63. package/dist/v1/libs/html/loader/probe/TinyImageProbe.mjs +626 -0
  64. package/dist/v1/libs/html/loader/utils/TinyBufferReader.cjs +277 -0
  65. package/dist/v1/libs/html/loader/utils/TinyBufferReader.d.mts +118 -0
  66. package/dist/v1/libs/html/loader/utils/TinyBufferReader.d.mts.map +1 -0
  67. package/dist/v1/libs/html/loader/utils/TinyBufferReader.mjs +247 -0
  68. package/dist/v1/libs/html/loader/utils/TinyIsoBox.cjs +128 -0
  69. package/dist/v1/libs/html/loader/utils/TinyIsoBox.d.mts +49 -0
  70. package/dist/v1/libs/html/loader/utils/TinyIsoBox.d.mts.map +1 -0
  71. package/dist/v1/libs/html/loader/utils/TinyIsoBox.mjs +116 -0
  72. package/dist/v1/libs/html/loader/utils/TinyMediaCache.cjs +796 -0
  73. package/dist/v1/libs/html/loader/utils/TinyMediaCache.d.mts +354 -0
  74. package/dist/v1/libs/html/loader/utils/TinyMediaCache.d.mts.map +1 -0
  75. package/dist/v1/libs/html/loader/utils/TinyMediaCache.mjs +734 -0
  76. package/dist/v1/libs/html/loader/utils/TinyMediaMirror.cjs +302 -0
  77. package/dist/v1/libs/html/loader/utils/TinyMediaMirror.d.mts +256 -0
  78. package/dist/v1/libs/html/loader/utils/TinyMediaMirror.d.mts.map +1 -0
  79. package/dist/v1/libs/html/loader/utils/TinyMediaMirror.mjs +280 -0
  80. package/dist/v1/libs/html/loader/utils/TinyMediaProgress.cjs +194 -0
  81. package/dist/v1/libs/html/loader/utils/TinyMediaProgress.d.mts +138 -0
  82. package/dist/v1/libs/html/loader/utils/TinyMediaProgress.d.mts.map +1 -0
  83. package/dist/v1/libs/html/loader/utils/TinyMediaProgress.mjs +175 -0
  84. package/dist/v1/libs/tools/TinyPkgExportValidator.cjs +359 -55
  85. package/dist/v1/libs/tools/TinyPkgExportValidator.d.mts +64 -6
  86. package/dist/v1/libs/tools/TinyPkgExportValidator.d.mts.map +1 -1
  87. package/dist/v1/libs/tools/TinyPkgExportValidator.mjs +320 -57
  88. package/dist/v1/libs/worker/engine/TinyWebWorkerEngine.cjs +0 -1
  89. package/dist/v1/libs/worker/engine/TinyWebWorkerEngine.d.mts +0 -1
  90. package/dist/v1/libs/worker/engine/TinyWebWorkerEngine.d.mts.map +1 -1
  91. package/dist/v1/libs/worker/engine/TinyWebWorkerEngine.mjs +0 -1
  92. package/dist/v1/webTemplates/bootstrap/5.3/scss/background/_background-grid.scss +15 -0
  93. package/dist/v1/webTemplates/bootstrap/5.3/scss/components/buttons/_buttons-contrast.scss +208 -0
  94. package/dist/v1/webTemplates/bootstrap/5.3/scss/components/buttons/_buttons-ghost.scss +89 -0
  95. package/dist/v1/webTemplates/bootstrap/5.3/scss/components/icon/_cube-icon.scss +65 -0
  96. package/dist/v1/webTemplates/bootstrap/5.3/scss/components/icon/_sphere-pulse.scss +39 -0
  97. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/_badges.scss +90 -0
  98. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/_bootstrap-overrides.scss +495 -0
  99. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/_buttons.scss +390 -0
  100. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/_colors.scss +213 -0
  101. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/_effects.scss +153 -0
  102. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/_forms-tones.scss +69 -0
  103. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/_forms.scss +323 -0
  104. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/_global.scss +31 -0
  105. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/_links.scss +47 -0
  106. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/_tables.scss +25 -0
  107. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/_theme.scss +21 -0
  108. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/_tokens.scss +161 -0
  109. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/_utilities.scss +81 -0
  110. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/_variables.scss +63 -0
  111. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/plugins/_form-tone-mixins.scss +236 -0
  112. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/plugins/_sizing.scss +68 -0
  113. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/plugins/_tone-mixins.scss +392 -0
  114. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/plugins/_typography.scss +112 -0
  115. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/plugins/background/_tiny_gradient_1.scss +131 -0
  116. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/plugins/colors/_pink.scss +47 -0
  117. package/docs/v1/Exports.md +33 -2
  118. package/docs/v1/README.md +9 -0
  119. package/docs/v1/basics/youtube.md +204 -0
  120. package/docs/v1/libs/html/loader/TinyFetchLoader.md +114 -0
  121. package/docs/v1/libs/html/loader/TinyImageLoader.md +141 -0
  122. package/docs/v1/libs/html/loader/TinyMediaCache.md +166 -0
  123. package/docs/v1/libs/html/loader/TinyMediaLoader.md +300 -0
  124. package/docs/v1/libs/tools/TinyPkgExportValidator.md +55 -0
  125. package/docs/v1/webTemplates/bootstrap/5.3/DeepStrap.md +177 -0
  126. package/package.json +244 -8
  127. /package/dist/v1/webTemplates/bootstrap/5.3/scss/input/{Placeholder-Colors-Fix.scss → _placeholder-colors-fix.scss} +0 -0
  128. /package/dist/v1/webTemplates/bootstrap/5.3/scss/spacing/{Spacing-Plus.scss → _spacing-plus.scss} +0 -0
@@ -0,0 +1,999 @@
1
+ /**
2
+ * @fileoverview Base class for controllable media loading (images and videos).
3
+ * Provides a state machine, lifecycle events, cache detection and metadata
4
+ * extraction shared by every concrete media loader.
5
+ */
6
+ import type { ICustomEventEmitter } from '../../../jsdoc/EventEmitter.mjs';
7
+ /** @import { ICustomEventEmitter } from '../../../jsdoc/EventEmitter.mjs' */
8
+ import TinyMediaProgress from './utils/TinyMediaProgress.mjs';
9
+ import TinyMediaCache from './utils/TinyMediaCache.mjs';
10
+ import TinyMediaMirror from './utils/TinyMediaMirror.mjs';
11
+ export type MediaMirrorEntry<Name extends string, Args extends unknown[]> = import('./utils/TinyMediaMirror.mjs').MediaMirrorEntry<Name, Args>;
12
+ export type MediaMirrorEvent<Name extends string, Args extends unknown[]> = import('./utils/TinyMediaMirror.mjs').MediaMirrorEvent<Name, Args>;
13
+ export type MediaLoaderOptions<HTMLMainElement extends HTMLImageElement | HTMLVideoElement | HTMLAudioElement> = {
14
+ /**
15
+ * - The media source URL.
16
+ */
17
+ src?: string;
18
+ /**
19
+ * - Maximum time in milliseconds before the load is aborted.
20
+ */
21
+ timeout?: number;
22
+ /**
23
+ * - An existing DOM element to adopt.
24
+ */
25
+ element?: HTMLMainElement | null;
26
+ /**
27
+ * - Whether an external `src` change triggers a reload.
28
+ */
29
+ autoReload?: boolean;
30
+ /**
31
+ * - Whether the original URL is mirrored into the `original-src` attribute.
32
+ */
33
+ originalSrc?: boolean;
34
+ /**
35
+ * - Whether to decode image dimensions from the response headers using WebCodecs.
36
+ */
37
+ earlyDecode?: boolean;
38
+ /**
39
+ * - Whether to render progressively during fetch (default true).
40
+ */
41
+ progressive?: boolean;
42
+ /**
43
+ * - Whether to perform a HEAD request to fetch HTTP headers before downloading.
44
+ */
45
+ useHeadRequest?: boolean;
46
+ /**
47
+ * - Whether concurrent loads of the same source share a single download (default true).
48
+ */
49
+ mirror?: boolean;
50
+ /**
51
+ * - An optional shared memory cache.
52
+ */
53
+ cache?: TinyMediaCache | null;
54
+ /**
55
+ * - The request body forwarded to the transport.
56
+ */
57
+ body?: BodyInit;
58
+ };
59
+ export type MediaSrcChangePayload = {
60
+ /**
61
+ * - The new source URL.
62
+ */
63
+ src: string;
64
+ /**
65
+ * - The previous source URL.
66
+ */
67
+ previousSrc: string;
68
+ };
69
+ export type MediaSrcTransitionPayload = {
70
+ /**
71
+ * - The original network source URL.
72
+ */
73
+ src: string;
74
+ /**
75
+ * - The internal object URL, or null when it is cleared.
76
+ */
77
+ internalSrc: string | null;
78
+ };
79
+ export type MediaMetadata = {
80
+ /**
81
+ * - The resolved source URL.
82
+ */
83
+ src: string;
84
+ /**
85
+ * - The media MIME type (e.g., "image/png").
86
+ */
87
+ type: string;
88
+ /**
89
+ * - The intrinsic width in pixels.
90
+ */
91
+ width: number;
92
+ /**
93
+ * - The intrinsic height in pixels.
94
+ */
95
+ height: number;
96
+ /**
97
+ * - The duration in seconds (0 for images).
98
+ */
99
+ duration: number;
100
+ /**
101
+ * - The decoded size in bytes (0 when unknown).
102
+ */
103
+ size: number;
104
+ /**
105
+ * - Whether the media was served from the cache.
106
+ */
107
+ fromCache: boolean;
108
+ /**
109
+ * - The total load time in milliseconds.
110
+ */
111
+ loadTime: number;
112
+ /**
113
+ * - The epoch timestamp when the load finished.
114
+ */
115
+ timestamp: number;
116
+ /**
117
+ * - The animation data.
118
+ */
119
+ animation: import('./probe/TinyImageProbe.mjs').AnimationProbeData | null;
120
+ /**
121
+ * - All HTTP response headers captured during the fetch.
122
+ */
123
+ httpHeaders?: Record<string, string>;
124
+ };
125
+ export type MediaChunkPayload = {
126
+ /**
127
+ * - The binary chunk.
128
+ */
129
+ chunk: Uint8Array;
130
+ /**
131
+ * - The total bytes downloaded so far.
132
+ */
133
+ loaded: number;
134
+ /**
135
+ * - The total bytes of the media (0 when unknown).
136
+ */
137
+ total: number;
138
+ };
139
+ export type MediaMirrorPayload = {
140
+ /**
141
+ * - The source URL shared by both loaders.
142
+ */
143
+ src: string;
144
+ /**
145
+ * - The normalized registry key.
146
+ */
147
+ key: string;
148
+ /**
149
+ * - The size of the shared payload in bytes.
150
+ */
151
+ size: number;
152
+ /**
153
+ * - The number of loaders attached to the download.
154
+ */
155
+ mirrors: number;
156
+ /**
157
+ * - The number of historical events caught up on attach.
158
+ */
159
+ replayed: number;
160
+ };
161
+ export type MediaMetadataDetails = {
162
+ /**
163
+ * - The media MIME type.
164
+ */
165
+ type: string;
166
+ /**
167
+ * - The intrinsic width in pixels.
168
+ */
169
+ width: number;
170
+ /**
171
+ * - The intrinsic height in pixels.
172
+ */
173
+ height: number;
174
+ /**
175
+ * - The duration in seconds.
176
+ */
177
+ duration: number;
178
+ /**
179
+ * - The decoded size in bytes.
180
+ */
181
+ size: number;
182
+ };
183
+ export type DecoderCreator = (mime: string) => MediaEarlyDecoder;
184
+ export type MediaLoadHandler = (metadata: MediaMetadata) => void;
185
+ export type MediaErrorHandler = (error: Error) => void;
186
+ export type MediaStartHandler = (payload: {
187
+ src: string;
188
+ }) => void;
189
+ export type MediaSrcChangeHandler = (payload: MediaSrcChangePayload) => void;
190
+ export type MediaVoidHandler = () => void;
191
+ export type MediaStateChangePayload = {
192
+ /**
193
+ * - The new state.
194
+ */
195
+ state: string;
196
+ /**
197
+ * - The previous state.
198
+ */
199
+ previous: string;
200
+ /**
201
+ * - The source URL the transition belongs to.
202
+ */
203
+ src: string;
204
+ };
205
+ export type MediaTimeoutPayload = {
206
+ /**
207
+ * - The source URL that timed out.
208
+ */
209
+ src: string;
210
+ /**
211
+ * - The configured timeout in milliseconds.
212
+ */
213
+ timeout: number;
214
+ };
215
+ export type MediaEarlyDecoder = {
216
+ /**
217
+ * - Pushes a chunk into the decoder.
218
+ */
219
+ write: (chunk: Uint8Array) => void;
220
+ /**
221
+ * - Closes the decoder and releases its resources.
222
+ */
223
+ close: () => void;
224
+ /**
225
+ * - Flushes the metadata that is only known at the end of the stream.
226
+ */
227
+ finalize?: () => Partial<MediaMetadata> | null;
228
+ };
229
+ export type MediaMetadataType = 'HEAD' | 'GET' | 'PROBE' | 'DECODE' | 'CACHE' | 'LOADED_METADATA' | 'DURATION_CHANGE' | 'PROBE_ANIMATION' | 'MIRROR';
230
+ export type MediaLoaderEvents = {
231
+ /**
232
+ * - Emitted when a media load process begins.
233
+ */
234
+ loadstart: (payload: {
235
+ src: string;
236
+ }) => void;
237
+ /**
238
+ * - Emitted when the media has been fully loaded and decoded.
239
+ */
240
+ loaded: (metadata: MediaMetadata) => void;
241
+ /**
242
+ * - Emitted when the loading process finishes, regardless of success or failure.
243
+ */
244
+ loadend: (payload: {
245
+ src: string;
246
+ state: string;
247
+ }) => void;
248
+ /**
249
+ * - Emitted when the current load operation is cancelled.
250
+ */
251
+ abort: (payload: {
252
+ src: string;
253
+ }) => void;
254
+ /**
255
+ * - Emitted when an unrecoverable error occurs during loading.
256
+ */
257
+ error: (error: Error) => void;
258
+ /**
259
+ * - Emitted when the load operation exceeds the configured timeout.
260
+ */
261
+ timeout: (payload: MediaTimeoutPayload) => void;
262
+ /**
263
+ * - Emitted periodically to provide download progress updates.
264
+ */
265
+ progress: (payload: import('./utils/TinyMediaProgress.mjs').MediaProgressSnapshot) => void;
266
+ /**
267
+ * - Emitted whenever media metadata is partially or fully resolved.
268
+ */
269
+ metadata: (metadata: MediaMetadata, type: MediaMetadataType) => void;
270
+ /**
271
+ * - Emitted when the main HTTP response for the media resource is received.
272
+ */
273
+ response: (response: Response) => void;
274
+ /**
275
+ * - Emitted when the HTTP HEAD response is received.
276
+ */
277
+ headResponse: (response: Response) => void;
278
+ /**
279
+ * - Emitted when the source URL of the loader is changed.
280
+ */
281
+ srcchange: (payload: MediaSrcChangePayload) => void;
282
+ /**
283
+ * - Emitted when the element's source swaps between a network URL and an internal object URL.
284
+ */
285
+ srctransition: (payload: MediaSrcTransitionPayload) => void;
286
+ /**
287
+ * - Emitted when the resource is not found in the cache.
288
+ */
289
+ cachemiss: (entry: import('./utils/TinyMediaCache.mjs').MediaCacheEntry) => void;
290
+ /**
291
+ * - Emitted when the resource is successfully retrieved from the cache.
292
+ */
293
+ cachehit: (entry: import('./utils/TinyMediaCache.mjs').MediaCacheEntry) => void;
294
+ /**
295
+ * - Emitted when the loader transitions from one state to another.
296
+ */
297
+ statechange: (payload: MediaStateChangePayload) => void;
298
+ /**
299
+ * - Emitted every time a binary data chunk is received during streaming.
300
+ */
301
+ chunk: (payload: MediaChunkPayload) => void;
302
+ /**
303
+ * - Emitted when the download is shared with another loader.
304
+ */
305
+ mirror: (payload: MediaMirrorPayload) => void;
306
+ /**
307
+ * - Emitted when the loader is destroyed and its resources are released.
308
+ */
309
+ destroy: () => void;
310
+ };
311
+ /**
312
+ * @template {string} Name
313
+ * @template {unknown[]} Args
314
+ * @typedef {import('./utils/TinyMediaMirror.mjs').MediaMirrorEntry<Name, Args>} MediaMirrorEntry
315
+ */
316
+ /**
317
+ * @template {string} Name
318
+ * @template {unknown[]} Args
319
+ * @typedef {import('./utils/TinyMediaMirror.mjs').MediaMirrorEvent<Name, Args>} MediaMirrorEvent
320
+ */
321
+ /**
322
+ * Describes the configuration object accepted by the {@link TinyMediaLoader} constructor.
323
+ * Every property is optional, so a loader can be created empty and configured later.
324
+ * @template {HTMLImageElement|HTMLVideoElement|HTMLAudioElement} HTMLMainElement
325
+ * @typedef {Object} MediaLoaderOptions
326
+ * @property {string} [src] - The media source URL.
327
+ * @property {number} [timeout] - Maximum time in milliseconds before the load is aborted.
328
+ * @property {HTMLMainElement|null} [element] - An existing DOM element to adopt.
329
+ * @property {boolean} [autoReload] - Whether an external `src` change triggers a reload.
330
+ * @property {boolean} [originalSrc] - Whether the original URL is mirrored into the `original-src` attribute.
331
+ * @property {boolean} [earlyDecode] - Whether to decode image dimensions from the response headers using WebCodecs.
332
+ * @property {boolean} [progressive] - Whether to render progressively during fetch (default true).
333
+ * @property {boolean} [useHeadRequest] - Whether to perform a HEAD request to fetch HTTP headers before downloading.
334
+ * @property {boolean} [mirror] - Whether concurrent loads of the same source share a single download (default true).
335
+ * @property {TinyMediaCache|null} [cache] - An optional shared memory cache.
336
+ * @property {BodyInit} [body] - The request body forwarded to the transport.
337
+ */
338
+ /**
339
+ * Describes the payload emitted whenever the source URL changes, whether the change
340
+ * originated inside the loader or from an external DOM mutation.
341
+ * @typedef {Object} MediaSrcChangePayload
342
+ * @property {string} src - The new source URL.
343
+ * @property {string} previousSrc - The previous source URL.
344
+ */
345
+ /**
346
+ * Describes the payload emitted when the element swaps the network source for
347
+ * an internal object URL (or the reverse) during a streamed load.
348
+ * @typedef {Object} MediaSrcTransitionPayload
349
+ * @property {string} src - The original network source URL.
350
+ * @property {string|null} internalSrc - The internal object URL, or null when it is cleared.
351
+ */
352
+ /**
353
+ * Describes the immutable snapshot of everything known about a finished load.
354
+ * @typedef {Object} MediaMetadata
355
+ * @property {string} src - The resolved source URL.
356
+ * @property {string} type - The media MIME type (e.g., "image/png").
357
+ * @property {number} width - The intrinsic width in pixels.
358
+ * @property {number} height - The intrinsic height in pixels.
359
+ * @property {number} duration - The duration in seconds (0 for images).
360
+ * @property {number} size - The decoded size in bytes (0 when unknown).
361
+ * @property {boolean} fromCache - Whether the media was served from the cache.
362
+ * @property {number} loadTime - The total load time in milliseconds.
363
+ * @property {number} timestamp - The epoch timestamp when the load finished.
364
+ * @property {import('./probe/TinyImageProbe.mjs').AnimationProbeData | null} animation - The animation data.
365
+ * @property {Record<string, string>} [httpHeaders] - All HTTP response headers captured during the fetch.
366
+ */
367
+ /**
368
+ * Describes the payload emitted when a new chunk is downloaded.
369
+ * @typedef {Object} MediaChunkPayload
370
+ * @property {Uint8Array} chunk - The binary chunk.
371
+ * @property {number} loaded - The total bytes downloaded so far.
372
+ * @property {number} total - The total bytes of the media (0 when unknown).
373
+ */
374
+ /**
375
+ * Describes the payload emitted when a loader attaches to an in-flight download.
376
+ * @typedef {Object} MediaMirrorPayload
377
+ * @property {string} src - The source URL shared by both loaders.
378
+ * @property {string} key - The normalized registry key.
379
+ * @property {number} size - The size of the shared payload in bytes.
380
+ * @property {number} mirrors - The number of loaders attached to the download.
381
+ * @property {number} replayed - The number of historical events caught up on attach.
382
+ */
383
+ /**
384
+ * Describes the media specific values returned by the abstract `_getMetadataDetails` hook
385
+ * and merged into the final {@link MediaMetadata} object.
386
+ * @typedef {Object} MediaMetadataDetails
387
+ * @property {string} type - The media MIME type.
388
+ * @property {number} width - The intrinsic width in pixels.
389
+ * @property {number} height - The intrinsic height in pixels.
390
+ * @property {number} duration - The duration in seconds.
391
+ * @property {number} size - The decoded size in bytes.
392
+ */
393
+ /**
394
+ * @callback DecoderCreator
395
+ * Builds a decoder backed by the container header parser.
396
+ * @param {string} mime - The video MIME type.
397
+ * @returns {MediaEarlyDecoder} The decoder.
398
+ */
399
+ /**
400
+ * Handles a successful media load.
401
+ * @typedef {(metadata: MediaMetadata) => void} MediaLoadHandler
402
+ */
403
+ /**
404
+ * Handles a failed media load.
405
+ * @typedef {(error: Error) => void} MediaErrorHandler
406
+ */
407
+ /**
408
+ * Handles the start of a media load.
409
+ * @typedef {(payload: { src: string }) => void} MediaStartHandler
410
+ */
411
+ /**
412
+ * Handles a source URL change.
413
+ * @typedef {(payload: MediaSrcChangePayload) => void} MediaSrcChangeHandler
414
+ */
415
+ /**
416
+ * Handles an event that carries no payload.
417
+ * @typedef {() => void} MediaVoidHandler
418
+ */
419
+ /**
420
+ * Describes the payload emitted on every state machine transition.
421
+ * @typedef {Object} MediaStateChangePayload
422
+ * @property {string} state - The new state.
423
+ * @property {string} previous - The previous state.
424
+ * @property {string} src - The source URL the transition belongs to.
425
+ */
426
+ /**
427
+ * Describes the payload emitted when a load exceeds the configured timeout.
428
+ * @typedef {Object} MediaTimeoutPayload
429
+ * @property {string} src - The source URL that timed out.
430
+ * @property {number} timeout - The configured timeout in milliseconds.
431
+ */
432
+ /**
433
+ * Handle returned by the early decoder factory. It is a thin wrapper around the
434
+ * WebCodecs `ImageDecoder` so the loader can push chunks and release the
435
+ * decoder without knowing whether the API is available.
436
+ * @typedef {Object} MediaEarlyDecoder
437
+ * @property {(chunk: Uint8Array) => void} write - Pushes a chunk into the decoder.
438
+ * @property {() => void} close - Closes the decoder and releases its resources.
439
+ * @property {() => Partial<MediaMetadata>|null} [finalize] - Flushes the metadata that is only known at the end of the stream.
440
+ */
441
+ /**
442
+ * @typedef {'HEAD'|'GET'|'PROBE'|'DECODE'|'CACHE'|'LOADED_METADATA'|'DURATION_CHANGE'|'PROBE_ANIMATION'|'MIRROR'} MediaMetadataType
443
+ */
444
+ /**
445
+ * Describes every event emitted by {@link TinyMediaLoader}.
446
+ *
447
+ * The keys are the event names, and the values are the listener signatures.
448
+ * This is the shape expected by `ICustomEventEmitter<MediaLoaderEvents>`.
449
+ * @typedef {Object} MediaLoaderEvents
450
+ * @property {(payload: { src: string }) => void} loadstart - Emitted when a media load process begins.
451
+ * @property {(metadata: MediaMetadata) => void} loaded - Emitted when the media has been fully loaded and decoded.
452
+ * @property {(payload: { src: string, state: string }) => void} loadend - Emitted when the loading process finishes, regardless of success or failure.
453
+ * @property {(payload: { src: string }) => void} abort - Emitted when the current load operation is cancelled.
454
+ * @property {(error: Error) => void} error - Emitted when an unrecoverable error occurs during loading.
455
+ * @property {(payload: MediaTimeoutPayload) => void} timeout - Emitted when the load operation exceeds the configured timeout.
456
+ * @property {(payload: import('./utils/TinyMediaProgress.mjs').MediaProgressSnapshot) => void} progress - Emitted periodically to provide download progress updates.
457
+ * @property {(metadata: MediaMetadata, type: MediaMetadataType) => void} metadata - Emitted whenever media metadata is partially or fully resolved.
458
+ * @property {(response: Response) => void} response - Emitted when the main HTTP response for the media resource is received.
459
+ * @property {(response: Response) => void} headResponse - Emitted when the HTTP HEAD response is received.
460
+ * @property {(payload: MediaSrcChangePayload) => void} srcchange - Emitted when the source URL of the loader is changed.
461
+ * @property {(payload: MediaSrcTransitionPayload) => void} srctransition - Emitted when the element's source swaps between a network URL and an internal object URL.
462
+ * @property {(entry: import('./utils/TinyMediaCache.mjs').MediaCacheEntry) => void} cachemiss - Emitted when the resource is not found in the cache.
463
+ * @property {(entry: import('./utils/TinyMediaCache.mjs').MediaCacheEntry) => void} cachehit - Emitted when the resource is successfully retrieved from the cache.
464
+ * @property {(payload: MediaStateChangePayload) => void} statechange - Emitted when the loader transitions from one state to another.
465
+ * @property {(payload: MediaChunkPayload) => void} chunk - Emitted every time a binary data chunk is received during streaming.
466
+ * @property {(payload: MediaMirrorPayload) => void} mirror - Emitted when the download is shared with another loader.
467
+ * @property {() => void} destroy - Emitted when the loader is destroyed and its resources are released.
468
+ */
469
+ /** @type {new () => ICustomEventEmitter<MediaLoaderEvents>} */
470
+ declare const TypedEmitter: new () => ICustomEventEmitter<MediaLoaderEvents>;
471
+ /**
472
+ * Base class that orchestrates the full lifecycle of a media element.
473
+ * It must be extended. Concrete subclasses implement `_createElement`,
474
+ * `_startLoad`, `_getMetadataDetails`, `_abort` and `_cleanup`.
475
+ * @abstract
476
+ * @template {HTMLImageElement|HTMLVideoElement|HTMLAudioElement} HTMLMainElement
477
+ * @augments TypedEmitter
478
+ */
479
+ declare class TinyMediaLoader<HTMLMainElement extends HTMLImageElement | HTMLVideoElement | HTMLAudioElement> extends TypedEmitter {
480
+ #private;
481
+ /**
482
+ * The registry that deduplicates concurrent downloads.
483
+ * @returns {typeof TinyMediaMirror} The shared mirror registry.
484
+ */
485
+ static get TinyMediaMirror(): typeof TinyMediaMirror;
486
+ /**
487
+ * Immutable state machine values used by every media loader.
488
+ */
489
+ static MediaState: Readonly<{
490
+ IDLE: "idle";
491
+ LOADING: "loading";
492
+ LOADED: "loaded";
493
+ ERROR: "error";
494
+ DESTROYED: "destroyed";
495
+ }>;
496
+ /**
497
+ * The uppercase tag name of the element this loader manages.
498
+ * Subclasses must override it so the constructor can validate adopted elements.
499
+ * @returns {string} The uppercase tag name, or an empty string when the subclass does not override it.
500
+ */
501
+ static get tagName(): string;
502
+ /**
503
+ * @param {MediaLoaderOptions<HTMLMainElement>} [options] - The loader configuration.
504
+ * @throws {TypeError} If `options` is not a plain object.
505
+ * @throws {TypeError} If `options.src` is not a string.
506
+ * @throws {RangeError} If `options.timeout` is not a positive number.
507
+ * @throws {TypeError} If `options.element` is neither null nor an HTMLElement.
508
+ * @throws {TypeError} If `options.element` does not match the loader tag name.
509
+ */
510
+ constructor(options?: MediaLoaderOptions<HTMLMainElement>);
511
+ /**
512
+ * Emits an event and, when this loader leads a mirrored download, broadcasts
513
+ * it to every attached mirror. The local listeners always run first so a slow
514
+ * mirror can never delay the loader that owns the network request.
515
+ * @template {keyof MediaLoaderEvents} K
516
+ * @param {K} name - The event name.
517
+ * @param {Parameters<MediaLoaderEvents[K]>} args - The event arguments.
518
+ * @returns {boolean} True when the event had listeners.
519
+ */
520
+ emit<K extends keyof MediaLoaderEvents>(name: K, ...args: Parameters<MediaLoaderEvents[K]>): boolean;
521
+ /**
522
+ * Whether concurrent loads of the same source share a single download.
523
+ * @returns {boolean} True when mirroring is enabled.
524
+ */
525
+ get mirror(): boolean;
526
+ /**
527
+ * Whether the last download was served by another loader.
528
+ * @returns {boolean} True when the payload was shared by a mirrored download.
529
+ */
530
+ get mirrored(): boolean;
531
+ /**
532
+ * The HTTP response received from the media resource.
533
+ * @returns {Response|null} The response object, or null if no response has been received yet.
534
+ */
535
+ get response(): Response | null;
536
+ /**
537
+ * The HTTP response received from the preliminary HEAD request.
538
+ * @returns {Response|null} The response object, or null if no HEAD request was performed or received.
539
+ */
540
+ get headResponse(): Response | null;
541
+ /**
542
+ * Whether to perform a HEAD request to fetch HTTP headers before downloading.
543
+ * @returns {boolean}
544
+ */
545
+ get useHeadRequest(): boolean;
546
+ /**
547
+ * The object URL created for a streamed blob, when one exists.
548
+ * @returns {string|null} The active object URL, or null when none was created.
549
+ */
550
+ get objectUrl(): string | null;
551
+ /**
552
+ * The current source URL.
553
+ * @returns {string} The current source URL, or an empty string when unset.
554
+ */
555
+ get src(): string;
556
+ /**
557
+ * The internal object URL currently assigned to the element.
558
+ * @returns {string|null} The object URL assigned internally, or null when the element uses the network source.
559
+ */
560
+ get internalSrc(): string | null;
561
+ /**
562
+ * Whether the loader mirrors the original URL into the `original-src` attribute.
563
+ * @returns {boolean} True when the attribute is managed by this loader.
564
+ */
565
+ get originalSrc(): boolean;
566
+ /**
567
+ * Whether the loader decodes the image dimensions from the response headers
568
+ * through the WebCodecs `ImageDecoder`.
569
+ * @returns {boolean} True when early decoding is enabled.
570
+ */
571
+ get earlyDecode(): boolean;
572
+ /**
573
+ * Whether the loader progressively updates the media element while downloading.
574
+ * @returns {boolean} True when progressive loading is enabled.
575
+ */
576
+ get progressive(): boolean;
577
+ /**
578
+ * Updates the source URL and mirrors it into the DOM element.
579
+ * @param {string} value - The new source URL.
580
+ * @throws {TypeError} If `value` is not a string.
581
+ */
582
+ set src(value: string);
583
+ /**
584
+ * Indicates whether the last load was cancelled through {@link TinyMediaLoader#abort}.
585
+ * @returns {boolean} True when the in-flight load was aborted.
586
+ */
587
+ get aborted(): boolean;
588
+ /**
589
+ * Indicates whether this loader currently holds a reference on a shared cache entry.
590
+ * @returns {boolean} True while a cache reference is held.
591
+ */
592
+ get cacheAcquired(): boolean;
593
+ /**
594
+ * Indicates whether an external `src` change triggers an automatic reload.
595
+ * @returns {boolean} True when automatic reloading is enabled.
596
+ */
597
+ get autoReload(): boolean;
598
+ /**
599
+ * Indicates whether the last load was served from the cache.
600
+ * @returns {boolean} True when the last load was a cache hit.
601
+ */
602
+ get cacheHint(): boolean;
603
+ /**
604
+ * The epoch timestamp, in milliseconds, captured when the last load finished.
605
+ * @returns {number} The end timestamp, or 0 when no load has finished yet.
606
+ */
607
+ get endTime(): number;
608
+ /**
609
+ * The high resolution timestamp captured when the last load started.
610
+ * @returns {number} The start timestamp, or 0 when no load has started yet.
611
+ */
612
+ get startTime(): number;
613
+ /**
614
+ * The current lifecycle state.
615
+ * @returns {string} One of the {@link TinyMediaLoader.MediaState} values.
616
+ */
617
+ get state(): string;
618
+ /**
619
+ * The underlying DOM element (available after construction of the subclass).
620
+ * @returns {HTMLMainElement|null} The managed element, or null before it is created.
621
+ */
622
+ get element(): HTMLMainElement | null;
623
+ /**
624
+ * A defensive copy of the last known metadata.
625
+ * @returns {MediaMetadata} A shallow copy that is safe for the caller to mutate.
626
+ */
627
+ get metadata(): MediaMetadata;
628
+ /**
629
+ * The total size in bytes of the media downloaded through the streaming path.
630
+ * @returns {number} The number of bytes streamed, or `0` when the media was not streamed.
631
+ */
632
+ get resourceSize(): number;
633
+ /**
634
+ * @returns {boolean} True while the media is loading.
635
+ */
636
+ get isLoading(): boolean;
637
+ /**
638
+ * @returns {boolean} True when the media has finished loading.
639
+ */
640
+ get isLoaded(): boolean;
641
+ /**
642
+ * @returns {boolean} True when the last load failed.
643
+ */
644
+ get hasError(): boolean;
645
+ /**
646
+ * The active progress tracker, or null when the load has not started.
647
+ * @returns {TinyMediaProgress|null}
648
+ */
649
+ get progress(): TinyMediaProgress | null;
650
+ /**
651
+ * The shared memory cache, or null when disabled.
652
+ * @returns {TinyMediaCache|null}
653
+ */
654
+ get cache(): TinyMediaCache | null;
655
+ /**
656
+ * @param {TinyMediaCache|null} value - The new cache instance.
657
+ * @throws {TypeError} If `value` is neither a TinyMediaCache nor null.
658
+ */
659
+ set cache(value: TinyMediaCache | null);
660
+ /**
661
+ * The AbortController bound to the current load.
662
+ * @returns {AbortController}
663
+ */
664
+ get signal(): AbortController;
665
+ /**
666
+ * The request body forwarded to the transport. It is ignored by `GET` and
667
+ * `HEAD`, which the Fetch specification forbids from carrying a body.
668
+ * @returns {BodyInit|undefined}
669
+ */
670
+ get body(): BodyInit | undefined;
671
+ /**
672
+ * @param {BodyInit|undefined} value - The request body.
673
+ */
674
+ set body(value: BodyInit | undefined);
675
+ /**
676
+ * Whether another loader is already downloading the current source.
677
+ * @returns {boolean} True when a mirrored download is in flight.
678
+ */
679
+ get pending(): boolean;
680
+ /**
681
+ * The fetch implementation used to download the media.
682
+ * Subclasses may override it to inject a custom transport.
683
+ * @returns {typeof globalThis.fetch} The fetch implementation.
684
+ */
685
+ get _fetch(): typeof globalThis.fetch;
686
+ /**
687
+ * Replaces the fetch implementation used to download the media.
688
+ * @param {typeof globalThis.fetch} implementation - The fetch implementation.
689
+ * @throws {TypeError} If `implementation` is not a function.
690
+ */
691
+ set _fetch(implementation: typeof globalThis.fetch);
692
+ /**
693
+ * Extra options forwarded to the fetch implementation.
694
+ * Subclasses may override it to send headers, credentials or a body.
695
+ * @returns {RequestInit} The fetch options.
696
+ */
697
+ get _requestInit(): RequestInit;
698
+ /**
699
+ * @param {RequestInit} params - The fetch options.
700
+ */
701
+ set _requestInit(params: RequestInit);
702
+ /**
703
+ * Checks whether a URL already has a live payload held by the shared memory
704
+ * cache, without acquiring a reference and without touching the network.
705
+ *
706
+ * The lookup is strictly read-only: it never increments the `hits`/`misses`
707
+ * counters, never revives an expired entry and never creates an object URL.
708
+ * Use it to decide *whether* to call {@link TinyMediaLoader#load}, never as a
709
+ * replacement for it.
710
+ * @param {string} [src] - The URL to test. Defaults to the current source.
711
+ * @returns {boolean} True when the cache holds a live entry for the URL.
712
+ * @throws {TypeError} If `src` is not a string.
713
+ * @throws {Error} If the underlying cache was destroyed.
714
+ */
715
+ isCached(src?: string): boolean;
716
+ /**
717
+ * Whether the current source is already available in the shared memory cache.
718
+ * @returns {boolean} True when the current source can load without a network request.
719
+ */
720
+ get cached(): boolean;
721
+ /**
722
+ * Reads the cache entry of a URL without acquiring a reference.
723
+ * @param {string} [src] - The URL to inspect. Defaults to the current source.
724
+ * @returns {import('./utils/TinyMediaCache.mjs').MediaCacheEntry|null} The cached entry, or null.
725
+ * @throws {TypeError} If `src` is not a string.
726
+ * @throws {Error} If the underlying cache was destroyed.
727
+ */
728
+ peekCache(src?: string): import('./utils/TinyMediaCache.mjs').MediaCacheEntry | null;
729
+ /**
730
+ * Registers a decoder factory for a specific MIME type.
731
+ * This allows the loader to instantiate the correct decoder for different media formats.
732
+ * @protected
733
+ * @param {string} mime - The MIME type (or prefix) that this decoder handles.
734
+ * @param {DecoderCreator} callback - The factory function used to create the decoder.
735
+ * @returns {void}
736
+ */
737
+ protected _insertDecoder(mime: string, callback: DecoderCreator): void;
738
+ /**
739
+ * Creates a fresh progress tracker for the current load.
740
+ * @protected
741
+ * @param {number} [total] - The total number of bytes (0 when unknown).
742
+ * @returns {TinyMediaProgress} The freshly created and already started progress tracker.
743
+ * @throws {TypeError} If `total` is not a finite number.
744
+ * @throws {RangeError} If `total` is negative.
745
+ */
746
+ protected _createProgress(total?: number): TinyMediaProgress;
747
+ /**
748
+ * Emits a progress snapshot when a tracker is active.
749
+ * @protected
750
+ * @returns {void}
751
+ */
752
+ protected _emitProgress(): void;
753
+ /**
754
+ * Merges a partial metadata patch into the current snapshot and notifies the
755
+ * listeners. It is called as soon as the response headers arrive, so a
756
+ * consumer can render the file type and size before the download finishes.
757
+ * Keys whose value is `undefined` are ignored, so a decoder that cannot
758
+ * resolve a dimension never clobbers a value that was already known.
759
+ * @protected
760
+ * @param {Partial<MediaMetadata>} patch - The values to merge.
761
+ * @param {MediaMetadataType} type - The action type.
762
+ * @returns {void}
763
+ * @throws {TypeError} If `patch` is not a plain object.
764
+ */
765
+ protected _emitMetadata(patch: Partial<MediaMetadata>, type: MediaMetadataType): void;
766
+ /**
767
+ * Registers a DOM listener that is removed on the next load or on destroy.
768
+ * @protected
769
+ * @param {HTMLMainElement} element - The source element.
770
+ * @param {string} type - The DOM event name.
771
+ * @param {EventListener} handler - The listener to register.
772
+ * @returns {void}
773
+ * @throws {TypeError} If any argument has an invalid type.
774
+ */
775
+ protected _on(element: HTMLMainElement, type: string, handler: EventListener): void;
776
+ /**
777
+ * Forwards DOM events from an element to this emitter.
778
+ * @protected
779
+ * @param {HTMLMainElement} element - The source element.
780
+ * @param {string[]} events - The DOM event names to forward.
781
+ * @returns {void}
782
+ * @throws {TypeError} If `events` is not an array of non-empty strings.
783
+ */
784
+ protected _forwardEvents(element: HTMLMainElement, events: string[]): void;
785
+ /**
786
+ * Removes every forwarded DOM listener.
787
+ * @protected
788
+ * @returns {void}
789
+ */
790
+ protected _detachEvents(): void;
791
+ /**
792
+ * Starts loading the media and resolves with the final metadata.
793
+ * @returns {Promise<MediaMetadata>} A promise that resolves with the final metadata of the loaded media.
794
+ * @throws {Error} If the loader was destroyed or has no source.
795
+ */
796
+ load(): Promise<MediaMetadata>;
797
+ /**
798
+ * Resets the state machine and loads the current source again.
799
+ * @returns {Promise<MediaMetadata>} A promise that resolves with the metadata of the new load.
800
+ * @throws {Error} If the loader is loading or was destroyed.
801
+ */
802
+ reload(): Promise<MediaMetadata>;
803
+ /**
804
+ * Cancels the in-flight load, if any.
805
+ * @returns {boolean} True when a load was cancelled.
806
+ */
807
+ abort(): boolean;
808
+ /**
809
+ * Appends the media element to a container.
810
+ * @param {HTMLMainElement} container - The parent element.
811
+ * @returns {TinyMediaLoader<HTMLMainElement>} The current instance for chaining.
812
+ * @throws {TypeError} If `container` is not an HTMLElement.
813
+ * @throws {Error} If the element has not been created yet.
814
+ */
815
+ mount(container: HTMLMainElement): TinyMediaLoader<HTMLMainElement>;
816
+ /**
817
+ * Releases every resource and detaches all listeners.
818
+ * @returns {void}
819
+ */
820
+ destroy(): void;
821
+ /**
822
+ * Returns the adopted element, creating a new one when none was provided.
823
+ * Subclasses must call this inside `_startLoad`.
824
+ * @protected
825
+ * @returns {HTMLMainElement}
826
+ */
827
+ protected _resolveElement(): HTMLMainElement;
828
+ /**
829
+ * Registers a concrete DOM element. Kept for advanced subclasses.
830
+ * @protected
831
+ * @param {HTMLMainElement} element - The element to expose through `element`.
832
+ * @returns {void}
833
+ * @throws {TypeError} If `element` is not an HTMLElement.
834
+ */
835
+ protected _setElement(element: HTMLMainElement): void;
836
+ /**
837
+ * Flags that the media was served from the cache before the network layer ran.
838
+ * @protected
839
+ * @param {boolean} value - The cache hint.
840
+ * @returns {void}
841
+ * @throws {TypeError} If `value` is not a boolean.
842
+ */
843
+ protected _setCacheHint(value: boolean): void;
844
+ /**
845
+ * Records the internal object URL assigned to the element so the mutation
846
+ * observer treats the swap as an internal transition instead of an external
847
+ * source change. It also mirrors the network URL into the `original-src`
848
+ * attribute while an object URL is active.
849
+ * @protected
850
+ * @param {string|null} url - The object URL assigned internally, or null to clear it.
851
+ * @returns {void}
852
+ * @throws {TypeError} If `url` is neither a string nor null.
853
+ */
854
+ protected _setInternalSrc(url: string | null): void;
855
+ /**
856
+ * Waits for a media element to become ready while staying bound to the
857
+ * current abort signal. The returned promise rejects as soon as the loader is
858
+ * aborted, which prevents the caller from awaiting a download that will never
859
+ * finish.
860
+ * @protected
861
+ * @param {HTMLMainElement} element - The media element being loaded.
862
+ * @param {string} [readyEvent] - The DOM event that signals a successful load.
863
+ * @returns {Promise<void>} Resolves once the media is ready.
864
+ * @throws {TypeError} If `element` is not an HTMLElement.
865
+ * @throws {TypeError} If `readyEvent` is not a string.
866
+ */
867
+ protected _waitForMedia(element: HTMLMainElement, readyEvent?: string): Promise<void>;
868
+ /**
869
+ * Stores a downloaded blob in the shared cache when one is configured and
870
+ * returns the URL the element must render. When no cache is present the blob
871
+ * is exposed through a private object URL instead. An entry that is already
872
+ * cached is reused, because replacing it would revoke the object URL that
873
+ * another loader may still be rendering.
874
+ * @protected
875
+ * @param {Blob} blob - The downloaded blob.
876
+ * @returns {string} The URL the element must use as its source.
877
+ * @throws {TypeError} If `blob` is not a Blob.
878
+ */
879
+ protected _cacheBlob(blob: Blob): string;
880
+ /**
881
+ * Downloads a media resource through fetch. When another loader is already
882
+ * downloading the same URL, the request is not repeated: the promise resolves
883
+ * with the very same {@link Blob} instance that the leading loader receives.
884
+ * @protected
885
+ * @template {keyof MediaLoaderEvents} K
886
+ * @param {string} url - The resource to download.
887
+ * @param {(chunk: BlobPart, chunks: BlobPart[]) => void} [onChunk] - Optional chunk callback.
888
+ * @param {number} [startByte=0] - The byte offset to start downloading from.
889
+ * @param {AbortSignal|null} [customSignal=null] - Signal to abort only the fetch without aborting the loader.
890
+ * @returns {Promise<Blob>} The fully downloaded blob.
891
+ * @throws {TypeError} If `url` is not a string.
892
+ */
893
+ protected _downloadStream<K extends keyof MediaLoaderEvents>(url: string, onChunk?: (chunk: BlobPart, chunks: BlobPart[]) => void, startByte?: number, customSignal?: AbortSignal | null): Promise<Blob>;
894
+ /**
895
+ * Acquires the current source from the shared cache and remembers the
896
+ * reference. A successful acquisition flags the metadata so the final
897
+ * snapshot reports `fromCache: true` and restores the values that the
898
+ * download path would have recorded, since no network request runs here.
899
+ * @protected
900
+ * @returns {import('./utils/TinyMediaCache.mjs').MediaCacheEntry|null}
901
+ */
902
+ protected _acquireFromCache(): import('./utils/TinyMediaCache.mjs').MediaCacheEntry | null;
903
+ /**
904
+ * Releases the reference held on the shared cache entry, when present.
905
+ * @protected
906
+ * @returns {void}
907
+ */
908
+ protected _releaseFromCache(): void;
909
+ /**
910
+ * The total time spent loading, in milliseconds.
911
+ * @protected
912
+ * @returns {number}
913
+ */
914
+ protected _getLoadTime(): number;
915
+ /**
916
+ * Uses the Resource Timing API to detect a cache hit.
917
+ * @protected
918
+ * @returns {boolean}
919
+ */
920
+ protected _detectCache(): boolean;
921
+ /**
922
+ * Records the exact byte size of the media when it is known without the
923
+ * Resource Timing API, for example right after a streamed download.
924
+ * @protected
925
+ * @param {number} size - The size in bytes.
926
+ * @returns {void}
927
+ * @throws {RangeError} If `size` is not a positive number.
928
+ */
929
+ protected _setResourceSize(size: number): void;
930
+ /**
931
+ * Reads the decoded size of the resource. It prefers the size captured from a
932
+ * streamed blob and falls back to the Resource Timing API, whose entries are
933
+ * keyed by absolute URL.
934
+ * @protected
935
+ * @returns {number} The size in bytes, or 0 when unavailable.
936
+ */
937
+ protected _getResourceSize(): number;
938
+ /**
939
+ * Discards every pending mutation record.
940
+ * Subclasses must call this right after mutating the element internally,
941
+ * otherwise the observer reports a false external change.
942
+ * @protected
943
+ * @returns {void}
944
+ */
945
+ protected _flushMutations(): void;
946
+ /**
947
+ * Creates an object URL for a blob and revokes the previous one.
948
+ * @protected
949
+ * @param {Blob} blob - The blob to expose through an object URL.
950
+ * @returns {string} The newly created object URL.
951
+ * @throws {TypeError} If `blob` is not a Blob.
952
+ */
953
+ protected _createObjectUrl(blob: Blob): string;
954
+ /**
955
+ * Revokes the current object URL, if any.
956
+ * @protected
957
+ * @returns {void}
958
+ */
959
+ protected _revokeObjectUrl(): void;
960
+ /**
961
+ * Creates a brand new element. Must be implemented by subclasses.
962
+ * @abstract
963
+ * @protected
964
+ * @returns {HTMLMainElement}
965
+ */
966
+ protected _createElement(): HTMLMainElement;
967
+ /**
968
+ * Performs the actual load. Must be implemented by subclasses.
969
+ * @abstract
970
+ * @protected
971
+ * @returns {Promise<void>}
972
+ */
973
+ protected _startLoad(): Promise<void>;
974
+ /**
975
+ * Returns the media-specific metadata. Must be implemented by subclasses.
976
+ * @abstract
977
+ * @protected
978
+ * @returns {MediaMetadataDetails} The media specific metadata details.
979
+ */
980
+ protected _getMetadataDetails(): MediaMetadataDetails;
981
+ /**
982
+ * Aborts the network activity of the coupled element. It works for `<img>`,
983
+ * `<audio>` and `<video>`: all three expose `removeAttribute`, while only the
984
+ * media elements expose `pause` and `load`. Subclasses that hold extra
985
+ * resources must override this method and call `super._abort()`.
986
+ * @protected
987
+ * @returns {void}
988
+ */
989
+ protected _abort(): void;
990
+ /**
991
+ * Releases any listener or timer created by the subclass.
992
+ * @abstract
993
+ * @protected
994
+ * @returns {void}
995
+ */
996
+ protected _cleanup(): void;
997
+ }
998
+ export default TinyMediaLoader;
999
+ //# sourceMappingURL=TinyMediaLoader.d.mts.map