tiny-essentials 1.29.0 → 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 (131) hide show
  1. package/changelog/1/29/1.md +11 -0
  2. package/changelog/1/29/2.md +82 -0
  3. package/dist/v1/TinyBasicsEs.min.js +1 -1
  4. package/dist/v1/TinyEssentials.min.js +1 -1
  5. package/dist/v1/TinyFetchLoader.min.js +1 -0
  6. package/dist/v1/TinyImageLoader.min.js +1 -0
  7. package/dist/v1/TinyMediaCache.min.js +1 -0
  8. package/dist/v1/TinyMediaLoader.min.js +1 -0
  9. package/dist/v1/basics/index.cjs +5 -0
  10. package/dist/v1/basics/index.d.mts +2 -1
  11. package/dist/v1/basics/index.d.mts.map +1 -1
  12. package/dist/v1/basics/index.mjs +2 -1
  13. package/dist/v1/basics/media/youtube.cjs +275 -0
  14. package/dist/v1/basics/media/youtube.d.mts +107 -0
  15. package/dist/v1/basics/media/youtube.d.mts.map +1 -0
  16. package/dist/v1/basics/media/youtube.mjs +214 -0
  17. package/dist/v1/index.cjs +13 -0
  18. package/dist/v1/index.d.mts +6 -1
  19. package/dist/v1/index.d.mts.map +1 -1
  20. package/dist/v1/index.mjs +7 -2
  21. package/dist/v1/libs/fs/plugins/OPFS/StorageBucket.cjs +0 -1
  22. package/dist/v1/libs/fs/plugins/OPFS/StorageBucket.d.mts +0 -1
  23. package/dist/v1/libs/fs/plugins/OPFS/StorageBucket.d.mts.map +1 -1
  24. package/dist/v1/libs/fs/plugins/OPFS/StorageBucket.mjs +0 -1
  25. package/dist/v1/libs/fs/plugins/OPFS/index.cjs +0 -8
  26. package/dist/v1/libs/fs/plugins/OPFS/index.d.mts +0 -8
  27. package/dist/v1/libs/fs/plugins/OPFS/index.d.mts.map +1 -1
  28. package/dist/v1/libs/fs/plugins/OPFS/index.mjs +0 -8
  29. package/dist/v1/libs/html/TinyHtml.cjs +1 -1
  30. package/dist/v1/libs/html/TinyHtml.d.mts +2 -2
  31. package/dist/v1/libs/html/TinyHtml.d.mts.map +1 -1
  32. package/dist/v1/libs/html/TinyHtml.mjs +1 -1
  33. package/dist/v1/libs/html/loader/TinyMediaLoader.cjs +1999 -0
  34. package/dist/v1/libs/html/loader/TinyMediaLoader.d.mts +999 -0
  35. package/dist/v1/libs/html/loader/TinyMediaLoader.d.mts.map +1 -0
  36. package/dist/v1/libs/html/loader/TinyMediaLoader.mjs +1852 -0
  37. package/dist/v1/libs/html/loader/beta/formats/TinyAudioLoader.cjs +77 -0
  38. package/dist/v1/libs/html/loader/beta/formats/TinyAudioLoader.d.mts +103 -0
  39. package/dist/v1/libs/html/loader/beta/formats/TinyAudioLoader.d.mts.map +1 -0
  40. package/dist/v1/libs/html/loader/beta/formats/TinyAudioLoader.mjs +67 -0
  41. package/dist/v1/libs/html/loader/beta/formats/TinyContentLoader.cjs +630 -0
  42. package/dist/v1/libs/html/loader/beta/formats/TinyContentLoader.d.mts +138 -0
  43. package/dist/v1/libs/html/loader/beta/formats/TinyContentLoader.d.mts.map +1 -0
  44. package/dist/v1/libs/html/loader/beta/formats/TinyContentLoader.mjs +576 -0
  45. package/dist/v1/libs/html/loader/beta/formats/TinyVideoLoader.cjs +70 -0
  46. package/dist/v1/libs/html/loader/beta/formats/TinyVideoLoader.d.mts +100 -0
  47. package/dist/v1/libs/html/loader/beta/formats/TinyVideoLoader.d.mts.map +1 -0
  48. package/dist/v1/libs/html/loader/beta/formats/TinyVideoLoader.mjs +60 -0
  49. package/dist/v1/libs/html/loader/beta/probe/TinyMediaProbe.cjs +946 -0
  50. package/dist/v1/libs/html/loader/beta/probe/TinyMediaProbe.d.mts +67 -0
  51. package/dist/v1/libs/html/loader/beta/probe/TinyMediaProbe.d.mts.map +1 -0
  52. package/dist/v1/libs/html/loader/beta/probe/TinyMediaProbe.mjs +896 -0
  53. package/dist/v1/libs/html/loader/formats/TinyFetchLoader.cjs +225 -0
  54. package/dist/v1/libs/html/loader/formats/TinyFetchLoader.d.mts +149 -0
  55. package/dist/v1/libs/html/loader/formats/TinyFetchLoader.d.mts.map +1 -0
  56. package/dist/v1/libs/html/loader/formats/TinyFetchLoader.mjs +197 -0
  57. package/dist/v1/libs/html/loader/formats/TinyImageLoader.cjs +1454 -0
  58. package/dist/v1/libs/html/loader/formats/TinyImageLoader.d.mts +200 -0
  59. package/dist/v1/libs/html/loader/formats/TinyImageLoader.d.mts.map +1 -0
  60. package/dist/v1/libs/html/loader/formats/TinyImageLoader.mjs +1317 -0
  61. package/dist/v1/libs/html/loader/probe/TinyImageProbe.cjs +668 -0
  62. package/dist/v1/libs/html/loader/probe/TinyImageProbe.d.mts +83 -0
  63. package/dist/v1/libs/html/loader/probe/TinyImageProbe.d.mts.map +1 -0
  64. package/dist/v1/libs/html/loader/probe/TinyImageProbe.mjs +626 -0
  65. package/dist/v1/libs/html/loader/utils/TinyBufferReader.cjs +277 -0
  66. package/dist/v1/libs/html/loader/utils/TinyBufferReader.d.mts +118 -0
  67. package/dist/v1/libs/html/loader/utils/TinyBufferReader.d.mts.map +1 -0
  68. package/dist/v1/libs/html/loader/utils/TinyBufferReader.mjs +247 -0
  69. package/dist/v1/libs/html/loader/utils/TinyIsoBox.cjs +128 -0
  70. package/dist/v1/libs/html/loader/utils/TinyIsoBox.d.mts +49 -0
  71. package/dist/v1/libs/html/loader/utils/TinyIsoBox.d.mts.map +1 -0
  72. package/dist/v1/libs/html/loader/utils/TinyIsoBox.mjs +116 -0
  73. package/dist/v1/libs/html/loader/utils/TinyMediaCache.cjs +796 -0
  74. package/dist/v1/libs/html/loader/utils/TinyMediaCache.d.mts +354 -0
  75. package/dist/v1/libs/html/loader/utils/TinyMediaCache.d.mts.map +1 -0
  76. package/dist/v1/libs/html/loader/utils/TinyMediaCache.mjs +734 -0
  77. package/dist/v1/libs/html/loader/utils/TinyMediaMirror.cjs +302 -0
  78. package/dist/v1/libs/html/loader/utils/TinyMediaMirror.d.mts +256 -0
  79. package/dist/v1/libs/html/loader/utils/TinyMediaMirror.d.mts.map +1 -0
  80. package/dist/v1/libs/html/loader/utils/TinyMediaMirror.mjs +280 -0
  81. package/dist/v1/libs/html/loader/utils/TinyMediaProgress.cjs +194 -0
  82. package/dist/v1/libs/html/loader/utils/TinyMediaProgress.d.mts +138 -0
  83. package/dist/v1/libs/html/loader/utils/TinyMediaProgress.d.mts.map +1 -0
  84. package/dist/v1/libs/html/loader/utils/TinyMediaProgress.mjs +175 -0
  85. package/dist/v1/libs/tools/TinyPkgExportValidator.cjs +359 -55
  86. package/dist/v1/libs/tools/TinyPkgExportValidator.d.mts +64 -6
  87. package/dist/v1/libs/tools/TinyPkgExportValidator.d.mts.map +1 -1
  88. package/dist/v1/libs/tools/TinyPkgExportValidator.mjs +320 -57
  89. package/dist/v1/libs/worker/engine/TinyWebWorkerEngine.cjs +0 -1
  90. package/dist/v1/libs/worker/engine/TinyWebWorkerEngine.d.mts +0 -1
  91. package/dist/v1/libs/worker/engine/TinyWebWorkerEngine.d.mts.map +1 -1
  92. package/dist/v1/libs/worker/engine/TinyWebWorkerEngine.mjs +0 -1
  93. package/dist/v1/webTemplates/bootstrap/5.3/scss/background/_background-grid.scss +15 -0
  94. package/dist/v1/webTemplates/bootstrap/5.3/scss/components/buttons/_buttons-contrast.scss +208 -0
  95. package/dist/v1/webTemplates/bootstrap/5.3/scss/components/buttons/_buttons-ghost.scss +89 -0
  96. package/dist/v1/webTemplates/bootstrap/5.3/scss/components/icon/_cube-icon.scss +65 -0
  97. package/dist/v1/webTemplates/bootstrap/5.3/scss/components/icon/_sphere-pulse.scss +39 -0
  98. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/_badges.scss +90 -0
  99. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/_bootstrap-overrides.scss +495 -0
  100. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/_buttons.scss +390 -0
  101. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/_colors.scss +213 -0
  102. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/_effects.scss +153 -0
  103. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/_forms-tones.scss +69 -0
  104. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/_forms.scss +323 -0
  105. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/_global.scss +31 -0
  106. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/_links.scss +47 -0
  107. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/_tables.scss +25 -0
  108. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/_theme.scss +21 -0
  109. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/_tokens.scss +161 -0
  110. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/_utilities.scss +81 -0
  111. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/_variables.scss +63 -0
  112. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/plugins/_form-tone-mixins.scss +236 -0
  113. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/plugins/_sizing.scss +68 -0
  114. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/plugins/_tone-mixins.scss +392 -0
  115. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/plugins/_typography.scss +112 -0
  116. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/plugins/background/_tiny_gradient_1.scss +131 -0
  117. package/dist/v1/webTemplates/bootstrap/5.3/scss/themes/deepstrap/plugins/colors/_pink.scss +47 -0
  118. package/dist/v1/webTemplates/multiformats/14.0/IPFSHasher/index.cjs +2 -2
  119. package/docs/v1/Exports.md +33 -2
  120. package/docs/v1/README.md +9 -0
  121. package/docs/v1/basics/youtube.md +204 -0
  122. package/docs/v1/libs/html/loader/TinyFetchLoader.md +114 -0
  123. package/docs/v1/libs/html/loader/TinyImageLoader.md +141 -0
  124. package/docs/v1/libs/html/loader/TinyMediaCache.md +166 -0
  125. package/docs/v1/libs/html/loader/TinyMediaLoader.md +300 -0
  126. package/docs/v1/libs/tools/TinyPkgExportValidator.md +55 -0
  127. package/docs/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters.md +0 -4
  128. package/docs/v1/webTemplates/bootstrap/5.3/DeepStrap.md +177 -0
  129. package/package.json +281 -17
  130. /package/dist/v1/webTemplates/bootstrap/5.3/scss/input/{Placeholder-Colors-Fix.scss → _placeholder-colors-fix.scss} +0 -0
  131. /package/dist/v1/webTemplates/bootstrap/5.3/scss/spacing/{Spacing-Plus.scss → _spacing-plus.scss} +0 -0
@@ -0,0 +1,277 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ /**
6
+ * @fileoverview Bounds-checked binary cursor shared by every media probe.
7
+ * Every read either returns the requested value or throws {@link TinyNeedMoreData},
8
+ * which is what makes the incremental parsing possible: the probe catches the
9
+ * sentinel, keeps the buffered bytes and retries once the next chunk arrives.
10
+ */
11
+
12
+ /**
13
+ * Signals that the buffer does not hold enough bytes to satisfy a read.
14
+ * It is a control-flow signal, not a failure.
15
+ * @augments Error
16
+ */
17
+ class TinyNeedMoreData extends Error {
18
+ /**
19
+ * Exception thrown when the current buffer does not contain enough bytes to fulfill a read request.
20
+ * @param {string} [message] - The error message.
21
+ */
22
+ constructor(message = 'The buffer does not hold enough bytes to satisfy the read.') {
23
+ super(message);
24
+ this.name = 'TinyNeedMoreData';
25
+ }
26
+ }
27
+
28
+ /**
29
+ * A forward-only, bounds-checked cursor over a {@link Uint8Array}.
30
+ */
31
+ class TinyBufferReader {
32
+ /** @type {Uint8Array} */
33
+ #bytes;
34
+ /** @type {DataView} */
35
+ #view;
36
+ /** @type {number} */
37
+ #offset;
38
+ /** @type {number} */
39
+ #limit;
40
+
41
+ /**
42
+ * Initializes a new bounds-checked binary reader.
43
+ * @param {Uint8Array} bytes - The backing buffer.
44
+ * @param {number} [offset] - The first readable byte.
45
+ * @param {number} [limit] - The byte after the last readable byte.
46
+ * @throws {TypeError} If `bytes` is not a Uint8Array.
47
+ * @throws {RangeError} If `offset` or `limit` is out of bounds.
48
+ */
49
+ constructor(bytes, offset = 0, limit = bytes.length) {
50
+ if (!(bytes instanceof Uint8Array)) {
51
+ throw new TypeError('The "bytes" argument must be a Uint8Array.');
52
+ }
53
+ if (!Number.isInteger(offset) || offset < 0 || offset > bytes.length) {
54
+ throw new RangeError('The "offset" argument is out of bounds.');
55
+ }
56
+ if (!Number.isInteger(limit) || limit < offset || limit > bytes.length) {
57
+ throw new RangeError('The "limit" argument is out of bounds.');
58
+ }
59
+ this.#bytes = bytes;
60
+ this.#view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
61
+ this.#offset = offset;
62
+ this.#limit = limit;
63
+ }
64
+
65
+ /** @returns {number} The absolute cursor position. */
66
+ get offset() {
67
+ return this.#offset;
68
+ }
69
+
70
+ /** @returns {number} The byte after the last readable byte. */
71
+ get limit() {
72
+ return this.#limit;
73
+ }
74
+
75
+ /** @returns {number} The number of readable bytes left. */
76
+ get remaining() {
77
+ return this.#limit - this.#offset;
78
+ }
79
+
80
+ /** @returns {boolean} True when the cursor reached the limit. */
81
+ get eof() {
82
+ return this.#offset >= this.#limit;
83
+ }
84
+
85
+ /** @returns {Uint8Array} The full backing buffer. */
86
+ get buffer() {
87
+ return this.#bytes;
88
+ }
89
+
90
+ /**
91
+ * Checks if the buffer contains at least the specified number of readable bytes.
92
+ * @param {number} count - The number of bytes to test.
93
+ * @returns {boolean} True when at least `count` bytes are readable.
94
+ * @throws {TypeError} If `count` is not an integer.
95
+ */
96
+ has(count) {
97
+ if (!Number.isInteger(count)) {
98
+ throw new TypeError('The "count" argument must be an integer.');
99
+ }
100
+ return count >= 0 && this.#offset + count <= this.#limit;
101
+ }
102
+
103
+ /**
104
+ * Validates that the buffer has enough bytes to satisfy a read.
105
+ * Throws {@link TinyNeedMoreData} if the requested count exceeds the remaining bytes.
106
+ * @param {number} count - The number of bytes required.
107
+ * @returns {void}
108
+ * @throws {TypeError} If `count` is not an integer.
109
+ * @throws {RangeError} If `count` is negative.
110
+ * @throws {TinyNeedMoreData} If fewer than `count` bytes are readable.
111
+ */
112
+ #require(count) {
113
+ if (!Number.isInteger(count)) {
114
+ throw new TypeError('The "count" argument must be an integer.');
115
+ }
116
+ if (count < 0) {
117
+ throw new RangeError('The "count" argument must be a non-negative integer.');
118
+ }
119
+ if (!this.has(count)) {
120
+ throw new TinyNeedMoreData();
121
+ }
122
+ }
123
+
124
+ /**
125
+ * Moves the cursor to an absolute position in the buffer.
126
+ * @param {number} position - The absolute position to move to.
127
+ * @returns {TinyBufferReader} The current instance for chaining.
128
+ * @throws {RangeError} If `position` is not a positive integer.
129
+ */
130
+ seek(position) {
131
+ if (!Number.isInteger(position) || position < 0) {
132
+ throw new RangeError('The "position" argument must be a positive integer.');
133
+ }
134
+ this.#offset = position;
135
+ return this;
136
+ }
137
+
138
+ /**
139
+ * Skips a specified number of bytes in the buffer.
140
+ * @param {number} count - The number of bytes to skip.
141
+ * @returns {TinyBufferReader} The current instance for chaining.
142
+ * @throws {TinyNeedMoreData} If fewer than `count` bytes are readable.
143
+ */
144
+ skip(count) {
145
+ if (!Number.isInteger(count) || count < 0) {
146
+ throw new RangeError('The "count" argument must be a non-negative integer.');
147
+ }
148
+ this.#require(count);
149
+ this.#offset += count;
150
+ return this;
151
+ }
152
+
153
+ /**
154
+ * Reads the next unsigned 8-bit integer.
155
+ * @returns {number} The next unsigned 8-bit integer.
156
+ */
157
+ uint8() {
158
+ this.#require(1);
159
+ return this.#view.getUint8(this.#offset++);
160
+ }
161
+
162
+ /**
163
+ * Reads the next unsigned 16-bit big-endian integer.
164
+ * @returns {number} The next unsigned 16-bit big-endian integer.
165
+ */
166
+ uint16() {
167
+ this.#require(2);
168
+ const value = this.#view.getUint16(this.#offset);
169
+ this.#offset += 2;
170
+ return value;
171
+ }
172
+
173
+ /**
174
+ * Reads the next unsigned 16-bit little-endian integer.
175
+ * @returns {number} The next unsigned 16-bit little-endian integer.
176
+ */
177
+ uint16le() {
178
+ this.#require(2);
179
+ const value = this.#view.getUint16(this.#offset, true);
180
+ this.#offset += 2;
181
+ return value;
182
+ }
183
+
184
+ /**
185
+ * Reads the next unsigned 24-bit big-endian integer.
186
+ * @returns {number} The next unsigned 24-bit big-endian integer.
187
+ */
188
+ uint24() {
189
+ this.#require(3);
190
+ const value =
191
+ (this.#bytes[this.#offset] << 16) |
192
+ (this.#bytes[this.#offset + 1] << 8) |
193
+ this.#bytes[this.#offset + 2];
194
+ this.#offset += 3;
195
+ return value;
196
+ }
197
+
198
+ /**
199
+ * Reads the next unsigned 32-bit big-endian integer.
200
+ * @returns {number} The next unsigned 32-bit big-endian integer.
201
+ */
202
+ uint32() {
203
+ this.#require(4);
204
+ const value = this.#view.getUint32(this.#offset);
205
+ this.#offset += 4;
206
+ return value;
207
+ }
208
+
209
+ /**
210
+ * Reads the next unsigned 32-bit little-endian integer.
211
+ * @returns {number} The next unsigned 32-bit little-endian integer.
212
+ */
213
+ uint32le() {
214
+ this.#require(4);
215
+ const value = this.#view.getUint32(this.#offset, true);
216
+ this.#offset += 4;
217
+ return value;
218
+ }
219
+
220
+ /**
221
+ * Reads the next signed 32-bit little-endian integer.
222
+ * @returns {number} The next signed 32-bit little-endian integer.
223
+ */
224
+ int32le() {
225
+ this.#require(4);
226
+ const value = this.#view.getInt32(this.#offset, true);
227
+ this.#offset += 4;
228
+ return value;
229
+ }
230
+
231
+ /**
232
+ * Reads an unsigned 64-bit big-endian integer as a Number. Values above 2^53
233
+ * lose precision, which is acceptable for the box sizes and offsets we read.
234
+ * @returns {number} The decoded value.
235
+ */
236
+ uint64() {
237
+ const high = this.uint32();
238
+ const low = this.uint32();
239
+ return high * 0x100000000 + low;
240
+ }
241
+
242
+ /**
243
+ * Reads a fixed-length string using Latin-1 encoding.
244
+ * @param {number} length - The number of bytes to read.
245
+ * @returns {string} The decoded Latin-1 string.
246
+ */
247
+ ascii(length) {
248
+ if (!Number.isInteger(length) || length < 0) {
249
+ throw new RangeError('The "length" argument must be a non-negative integer.');
250
+ }
251
+ this.#require(length);
252
+ let value = '';
253
+ for (let i = 0; i < length; i += 1) {
254
+ value += String.fromCharCode(this.#bytes[this.#offset + i]);
255
+ }
256
+ this.#offset += length;
257
+ return value;
258
+ }
259
+
260
+ /**
261
+ * Extracts a view over a specified range of bytes from the buffer.
262
+ * @param {number} length - The number of bytes to read.
263
+ * @returns {Uint8Array} A view over the requested bytes.
264
+ */
265
+ bytes(length) {
266
+ if (!Number.isInteger(length) || length < 0) {
267
+ throw new RangeError('The "length" argument must be a non-negative integer.');
268
+ }
269
+ this.#require(length);
270
+ const slice = this.#bytes.subarray(this.#offset, this.#offset + length);
271
+ this.#offset += length;
272
+ return slice;
273
+ }
274
+ }
275
+
276
+ exports.TinyNeedMoreData = TinyNeedMoreData;
277
+ exports.default = TinyBufferReader;
@@ -0,0 +1,118 @@
1
+ /**
2
+ * @fileoverview Bounds-checked binary cursor shared by every media probe.
3
+ * Every read either returns the requested value or throws {@link TinyNeedMoreData},
4
+ * which is what makes the incremental parsing possible: the probe catches the
5
+ * sentinel, keeps the buffered bytes and retries once the next chunk arrives.
6
+ */
7
+ /**
8
+ * Signals that the buffer does not hold enough bytes to satisfy a read.
9
+ * It is a control-flow signal, not a failure.
10
+ * @augments Error
11
+ */
12
+ export declare class TinyNeedMoreData extends Error {
13
+ /**
14
+ * Exception thrown when the current buffer does not contain enough bytes to fulfill a read request.
15
+ * @param {string} [message] - The error message.
16
+ */
17
+ constructor(message?: string);
18
+ }
19
+ /**
20
+ * A forward-only, bounds-checked cursor over a {@link Uint8Array}.
21
+ */
22
+ export default class TinyBufferReader {
23
+ #private;
24
+ /**
25
+ * Initializes a new bounds-checked binary reader.
26
+ * @param {Uint8Array} bytes - The backing buffer.
27
+ * @param {number} [offset] - The first readable byte.
28
+ * @param {number} [limit] - The byte after the last readable byte.
29
+ * @throws {TypeError} If `bytes` is not a Uint8Array.
30
+ * @throws {RangeError} If `offset` or `limit` is out of bounds.
31
+ */
32
+ constructor(bytes: Uint8Array, offset?: number, limit?: number);
33
+ /** @returns {number} The absolute cursor position. */
34
+ get offset(): number;
35
+ /** @returns {number} The byte after the last readable byte. */
36
+ get limit(): number;
37
+ /** @returns {number} The number of readable bytes left. */
38
+ get remaining(): number;
39
+ /** @returns {boolean} True when the cursor reached the limit. */
40
+ get eof(): boolean;
41
+ /** @returns {Uint8Array} The full backing buffer. */
42
+ get buffer(): Uint8Array;
43
+ /**
44
+ * Checks if the buffer contains at least the specified number of readable bytes.
45
+ * @param {number} count - The number of bytes to test.
46
+ * @returns {boolean} True when at least `count` bytes are readable.
47
+ * @throws {TypeError} If `count` is not an integer.
48
+ */
49
+ has(count: number): boolean;
50
+ /**
51
+ * Moves the cursor to an absolute position in the buffer.
52
+ * @param {number} position - The absolute position to move to.
53
+ * @returns {TinyBufferReader} The current instance for chaining.
54
+ * @throws {RangeError} If `position` is not a positive integer.
55
+ */
56
+ seek(position: number): TinyBufferReader;
57
+ /**
58
+ * Skips a specified number of bytes in the buffer.
59
+ * @param {number} count - The number of bytes to skip.
60
+ * @returns {TinyBufferReader} The current instance for chaining.
61
+ * @throws {TinyNeedMoreData} If fewer than `count` bytes are readable.
62
+ */
63
+ skip(count: number): TinyBufferReader;
64
+ /**
65
+ * Reads the next unsigned 8-bit integer.
66
+ * @returns {number} The next unsigned 8-bit integer.
67
+ */
68
+ uint8(): number;
69
+ /**
70
+ * Reads the next unsigned 16-bit big-endian integer.
71
+ * @returns {number} The next unsigned 16-bit big-endian integer.
72
+ */
73
+ uint16(): number;
74
+ /**
75
+ * Reads the next unsigned 16-bit little-endian integer.
76
+ * @returns {number} The next unsigned 16-bit little-endian integer.
77
+ */
78
+ uint16le(): number;
79
+ /**
80
+ * Reads the next unsigned 24-bit big-endian integer.
81
+ * @returns {number} The next unsigned 24-bit big-endian integer.
82
+ */
83
+ uint24(): number;
84
+ /**
85
+ * Reads the next unsigned 32-bit big-endian integer.
86
+ * @returns {number} The next unsigned 32-bit big-endian integer.
87
+ */
88
+ uint32(): number;
89
+ /**
90
+ * Reads the next unsigned 32-bit little-endian integer.
91
+ * @returns {number} The next unsigned 32-bit little-endian integer.
92
+ */
93
+ uint32le(): number;
94
+ /**
95
+ * Reads the next signed 32-bit little-endian integer.
96
+ * @returns {number} The next signed 32-bit little-endian integer.
97
+ */
98
+ int32le(): number;
99
+ /**
100
+ * Reads an unsigned 64-bit big-endian integer as a Number. Values above 2^53
101
+ * lose precision, which is acceptable for the box sizes and offsets we read.
102
+ * @returns {number} The decoded value.
103
+ */
104
+ uint64(): number;
105
+ /**
106
+ * Reads a fixed-length string using Latin-1 encoding.
107
+ * @param {number} length - The number of bytes to read.
108
+ * @returns {string} The decoded Latin-1 string.
109
+ */
110
+ ascii(length: number): string;
111
+ /**
112
+ * Extracts a view over a specified range of bytes from the buffer.
113
+ * @param {number} length - The number of bytes to read.
114
+ * @returns {Uint8Array} A view over the requested bytes.
115
+ */
116
+ bytes(length: number): Uint8Array;
117
+ }
118
+ //# sourceMappingURL=TinyBufferReader.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TinyBufferReader.d.mts","sourceRoot":"","sources":["../../../../../../src/v1/libs/html/loader/utils/TinyBufferReader.mjs"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;GAIG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IACzC;;;OAGG;IACH,YAAY,OAAO,AAFhB,CACF,EADU,MAEuE,EAGjF;CACF;AAED;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,gBAAgB;;IAUnC;;;;;;;OAOG;IACH,YAAY,KAAK,EANN,UAMM,EAAE,MAAM,AALtB,CACA,EADQ,MAKkB,EAAE,KAAK,AAJjC,CACA,EADQ,MAIwC,EAclD;IAED,sDAAsD;IACtD,IAAI,MAAM,IADI,MAAM,CAGnB;IAED,+DAA+D;IAC/D,IAAI,KAAK,IADK,MAAM,CAGnB;IAED,2DAA2D;IAC3D,IAAI,SAAS,IADC,MAAM,CAGnB;IAED,iEAAiE;IACjE,IAAI,GAAG,IADO,OAAO,CAGpB;IAED,qDAAqD;IACrD,IAAI,MAAM,IADI,UAAU,CAGvB;IAED;;;;;OAKG;IACH,GAAG,CAAC,KAAK,EAJE,MAIF,GAHI,OAAO,CAQnB;IAuBD;;;;;OAKG;IACH,IAAI,CAAC,QAAQ,EAJF,MAIE,GAHA,gBAAgB,CAS5B;IAED;;;;;OAKG;IACH,IAAI,CAAC,KAAK,EAJC,MAID,GAHG,gBAAgB,CAU5B;IAED;;;OAGG;IACH,KAAK,IAFQ,MAAM,CAKlB;IAED;;;OAGG;IACH,MAAM,IAFO,MAAM,CAOlB;IAED;;;OAGG;IACH,QAAQ,IAFK,MAAM,CAOlB;IAED;;;OAGG;IACH,MAAM,IAFO,MAAM,CAUlB;IAED;;;OAGG;IACH,MAAM,IAFO,MAAM,CAOlB;IAED;;;OAGG;IACH,QAAQ,IAFK,MAAM,CAOlB;IAED;;;OAGG;IACH,OAAO,IAFM,MAAM,CAOlB;IAED;;;;OAIG;IACH,MAAM,IAFO,MAAM,CAMlB;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,EAHD,MAGC,GAFC,MAAM,CAalB;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,EAHD,MAGC,GAFC,UAAU,CAUtB;CACF"}
@@ -0,0 +1,247 @@
1
+ /**
2
+ * @fileoverview Bounds-checked binary cursor shared by every media probe.
3
+ * Every read either returns the requested value or throws {@link TinyNeedMoreData},
4
+ * which is what makes the incremental parsing possible: the probe catches the
5
+ * sentinel, keeps the buffered bytes and retries once the next chunk arrives.
6
+ */
7
+ /**
8
+ * Signals that the buffer does not hold enough bytes to satisfy a read.
9
+ * It is a control-flow signal, not a failure.
10
+ * @augments Error
11
+ */
12
+ export class TinyNeedMoreData extends Error {
13
+ /**
14
+ * Exception thrown when the current buffer does not contain enough bytes to fulfill a read request.
15
+ * @param {string} [message] - The error message.
16
+ */
17
+ constructor(message = 'The buffer does not hold enough bytes to satisfy the read.') {
18
+ super(message);
19
+ this.name = 'TinyNeedMoreData';
20
+ }
21
+ }
22
+ /**
23
+ * A forward-only, bounds-checked cursor over a {@link Uint8Array}.
24
+ */
25
+ export default class TinyBufferReader {
26
+ /** @type {Uint8Array} */
27
+ #bytes;
28
+ /** @type {DataView} */
29
+ #view;
30
+ /** @type {number} */
31
+ #offset;
32
+ /** @type {number} */
33
+ #limit;
34
+ /**
35
+ * Initializes a new bounds-checked binary reader.
36
+ * @param {Uint8Array} bytes - The backing buffer.
37
+ * @param {number} [offset] - The first readable byte.
38
+ * @param {number} [limit] - The byte after the last readable byte.
39
+ * @throws {TypeError} If `bytes` is not a Uint8Array.
40
+ * @throws {RangeError} If `offset` or `limit` is out of bounds.
41
+ */
42
+ constructor(bytes, offset = 0, limit = bytes.length) {
43
+ if (!(bytes instanceof Uint8Array)) {
44
+ throw new TypeError('The "bytes" argument must be a Uint8Array.');
45
+ }
46
+ if (!Number.isInteger(offset) || offset < 0 || offset > bytes.length) {
47
+ throw new RangeError('The "offset" argument is out of bounds.');
48
+ }
49
+ if (!Number.isInteger(limit) || limit < offset || limit > bytes.length) {
50
+ throw new RangeError('The "limit" argument is out of bounds.');
51
+ }
52
+ this.#bytes = bytes;
53
+ this.#view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
54
+ this.#offset = offset;
55
+ this.#limit = limit;
56
+ }
57
+ /** @returns {number} The absolute cursor position. */
58
+ get offset() {
59
+ return this.#offset;
60
+ }
61
+ /** @returns {number} The byte after the last readable byte. */
62
+ get limit() {
63
+ return this.#limit;
64
+ }
65
+ /** @returns {number} The number of readable bytes left. */
66
+ get remaining() {
67
+ return this.#limit - this.#offset;
68
+ }
69
+ /** @returns {boolean} True when the cursor reached the limit. */
70
+ get eof() {
71
+ return this.#offset >= this.#limit;
72
+ }
73
+ /** @returns {Uint8Array} The full backing buffer. */
74
+ get buffer() {
75
+ return this.#bytes;
76
+ }
77
+ /**
78
+ * Checks if the buffer contains at least the specified number of readable bytes.
79
+ * @param {number} count - The number of bytes to test.
80
+ * @returns {boolean} True when at least `count` bytes are readable.
81
+ * @throws {TypeError} If `count` is not an integer.
82
+ */
83
+ has(count) {
84
+ if (!Number.isInteger(count)) {
85
+ throw new TypeError('The "count" argument must be an integer.');
86
+ }
87
+ return count >= 0 && this.#offset + count <= this.#limit;
88
+ }
89
+ /**
90
+ * Validates that the buffer has enough bytes to satisfy a read.
91
+ * Throws {@link TinyNeedMoreData} if the requested count exceeds the remaining bytes.
92
+ * @param {number} count - The number of bytes required.
93
+ * @returns {void}
94
+ * @throws {TypeError} If `count` is not an integer.
95
+ * @throws {RangeError} If `count` is negative.
96
+ * @throws {TinyNeedMoreData} If fewer than `count` bytes are readable.
97
+ */
98
+ #require(count) {
99
+ if (!Number.isInteger(count)) {
100
+ throw new TypeError('The "count" argument must be an integer.');
101
+ }
102
+ if (count < 0) {
103
+ throw new RangeError('The "count" argument must be a non-negative integer.');
104
+ }
105
+ if (!this.has(count)) {
106
+ throw new TinyNeedMoreData();
107
+ }
108
+ }
109
+ /**
110
+ * Moves the cursor to an absolute position in the buffer.
111
+ * @param {number} position - The absolute position to move to.
112
+ * @returns {TinyBufferReader} The current instance for chaining.
113
+ * @throws {RangeError} If `position` is not a positive integer.
114
+ */
115
+ seek(position) {
116
+ if (!Number.isInteger(position) || position < 0) {
117
+ throw new RangeError('The "position" argument must be a positive integer.');
118
+ }
119
+ this.#offset = position;
120
+ return this;
121
+ }
122
+ /**
123
+ * Skips a specified number of bytes in the buffer.
124
+ * @param {number} count - The number of bytes to skip.
125
+ * @returns {TinyBufferReader} The current instance for chaining.
126
+ * @throws {TinyNeedMoreData} If fewer than `count` bytes are readable.
127
+ */
128
+ skip(count) {
129
+ if (!Number.isInteger(count) || count < 0) {
130
+ throw new RangeError('The "count" argument must be a non-negative integer.');
131
+ }
132
+ this.#require(count);
133
+ this.#offset += count;
134
+ return this;
135
+ }
136
+ /**
137
+ * Reads the next unsigned 8-bit integer.
138
+ * @returns {number} The next unsigned 8-bit integer.
139
+ */
140
+ uint8() {
141
+ this.#require(1);
142
+ return this.#view.getUint8(this.#offset++);
143
+ }
144
+ /**
145
+ * Reads the next unsigned 16-bit big-endian integer.
146
+ * @returns {number} The next unsigned 16-bit big-endian integer.
147
+ */
148
+ uint16() {
149
+ this.#require(2);
150
+ const value = this.#view.getUint16(this.#offset);
151
+ this.#offset += 2;
152
+ return value;
153
+ }
154
+ /**
155
+ * Reads the next unsigned 16-bit little-endian integer.
156
+ * @returns {number} The next unsigned 16-bit little-endian integer.
157
+ */
158
+ uint16le() {
159
+ this.#require(2);
160
+ const value = this.#view.getUint16(this.#offset, true);
161
+ this.#offset += 2;
162
+ return value;
163
+ }
164
+ /**
165
+ * Reads the next unsigned 24-bit big-endian integer.
166
+ * @returns {number} The next unsigned 24-bit big-endian integer.
167
+ */
168
+ uint24() {
169
+ this.#require(3);
170
+ const value = (this.#bytes[this.#offset] << 16) |
171
+ (this.#bytes[this.#offset + 1] << 8) |
172
+ this.#bytes[this.#offset + 2];
173
+ this.#offset += 3;
174
+ return value;
175
+ }
176
+ /**
177
+ * Reads the next unsigned 32-bit big-endian integer.
178
+ * @returns {number} The next unsigned 32-bit big-endian integer.
179
+ */
180
+ uint32() {
181
+ this.#require(4);
182
+ const value = this.#view.getUint32(this.#offset);
183
+ this.#offset += 4;
184
+ return value;
185
+ }
186
+ /**
187
+ * Reads the next unsigned 32-bit little-endian integer.
188
+ * @returns {number} The next unsigned 32-bit little-endian integer.
189
+ */
190
+ uint32le() {
191
+ this.#require(4);
192
+ const value = this.#view.getUint32(this.#offset, true);
193
+ this.#offset += 4;
194
+ return value;
195
+ }
196
+ /**
197
+ * Reads the next signed 32-bit little-endian integer.
198
+ * @returns {number} The next signed 32-bit little-endian integer.
199
+ */
200
+ int32le() {
201
+ this.#require(4);
202
+ const value = this.#view.getInt32(this.#offset, true);
203
+ this.#offset += 4;
204
+ return value;
205
+ }
206
+ /**
207
+ * Reads an unsigned 64-bit big-endian integer as a Number. Values above 2^53
208
+ * lose precision, which is acceptable for the box sizes and offsets we read.
209
+ * @returns {number} The decoded value.
210
+ */
211
+ uint64() {
212
+ const high = this.uint32();
213
+ const low = this.uint32();
214
+ return high * 0x100000000 + low;
215
+ }
216
+ /**
217
+ * Reads a fixed-length string using Latin-1 encoding.
218
+ * @param {number} length - The number of bytes to read.
219
+ * @returns {string} The decoded Latin-1 string.
220
+ */
221
+ ascii(length) {
222
+ if (!Number.isInteger(length) || length < 0) {
223
+ throw new RangeError('The "length" argument must be a non-negative integer.');
224
+ }
225
+ this.#require(length);
226
+ let value = '';
227
+ for (let i = 0; i < length; i += 1) {
228
+ value += String.fromCharCode(this.#bytes[this.#offset + i]);
229
+ }
230
+ this.#offset += length;
231
+ return value;
232
+ }
233
+ /**
234
+ * Extracts a view over a specified range of bytes from the buffer.
235
+ * @param {number} length - The number of bytes to read.
236
+ * @returns {Uint8Array} A view over the requested bytes.
237
+ */
238
+ bytes(length) {
239
+ if (!Number.isInteger(length) || length < 0) {
240
+ throw new RangeError('The "length" argument must be a non-negative integer.');
241
+ }
242
+ this.#require(length);
243
+ const slice = this.#bytes.subarray(this.#offset, this.#offset + length);
244
+ this.#offset += length;
245
+ return slice;
246
+ }
247
+ }