@utilix-tech/sdk 0.26.0 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -7154,6 +7154,7 @@ __export(units_exports, {
7154
7154
  calculateLoan: () => calculateLoan,
7155
7155
  calculateMarginMarkup: () => calculateMarginMarkup,
7156
7156
  calculatePercentageChange: () => calculatePercentageChange,
7157
+ calculateRuleOf72: () => calculateRuleOf72,
7157
7158
  calculateSimpleInterest: () => calculateSimpleInterest,
7158
7159
  calculateTax: () => calculateTax,
7159
7160
  calculateTimeValue: () => calculateTimeValue,
@@ -8771,6 +8772,39 @@ function calculateVideoBitrate(input) {
8771
8772
  }
8772
8773
  return { error: 'mode must be "size-from-bitrate" or "bitrate-from-size"' };
8773
8774
  }
8775
+ function calculateRuleOf72(value, direction) {
8776
+ if (!Number.isFinite(value) || value <= 0) return { error: "Value must be a positive number" };
8777
+ if (direction !== "rate-to-years" && direction !== "years-to-rate") {
8778
+ return { error: 'Direction must be "rate-to-years" or "years-to-rate"' };
8779
+ }
8780
+ const round4 = (n) => Math.round(n * 1e4) / 1e4;
8781
+ if (direction === "rate-to-years") {
8782
+ const ratePercent = value;
8783
+ const ruleOf72Estimate2 = 72 / ratePercent;
8784
+ const exactValue2 = Math.log(2) / Math.log(1 + ratePercent / 100);
8785
+ const errorPercent2 = (ruleOf72Estimate2 - exactValue2) / exactValue2 * 100;
8786
+ return {
8787
+ direction,
8788
+ ratePercent: round4(ratePercent),
8789
+ years: round4(exactValue2),
8790
+ ruleOf72Estimate: round4(ruleOf72Estimate2),
8791
+ exactValue: round4(exactValue2),
8792
+ errorPercent: round4(errorPercent2)
8793
+ };
8794
+ }
8795
+ const years = value;
8796
+ const ruleOf72Estimate = 72 / years;
8797
+ const exactValue = (Math.pow(2, 1 / years) - 1) * 100;
8798
+ const errorPercent = (ruleOf72Estimate - exactValue) / exactValue * 100;
8799
+ return {
8800
+ direction,
8801
+ ratePercent: round4(exactValue),
8802
+ years: round4(years),
8803
+ ruleOf72Estimate: round4(ruleOf72Estimate),
8804
+ exactValue: round4(exactValue),
8805
+ errorPercent: round4(errorPercent)
8806
+ };
8807
+ }
8774
8808
 
8775
8809
  // src/tools/network.ts
8776
8810
  var network_exports = {};
@@ -19198,10 +19232,12 @@ function vectorSimilarity(a, b) {
19198
19232
  var media_exports = {};
19199
19233
  __export(media_exports, {
19200
19234
  readExifData: () => readExifData,
19235
+ readFlacInfo: () => readFlacInfo,
19201
19236
  readIcoInfo: () => readIcoInfo,
19202
19237
  readId3Tags: () => readId3Tags,
19203
19238
  readImageInfo: () => readImageInfo,
19204
19239
  readPdfMetadata: () => readPdfMetadata,
19240
+ readVideoInfo: () => readVideoInfo,
19205
19241
  readWavInfo: () => readWavInfo
19206
19242
  });
19207
19243
  function readU32BE(bytes, offset) {
@@ -19958,6 +19994,349 @@ function readIcoInfo(bytes) {
19958
19994
  }
19959
19995
  return { imageCount: count, images };
19960
19996
  }
19997
+ var FLAC_TAG_FIELDS = {
19998
+ TITLE: "title",
19999
+ ARTIST: "artist",
20000
+ ALBUM: "album",
20001
+ DATE: "date",
20002
+ GENRE: "genre",
20003
+ TRACKNUMBER: "trackNumber"
20004
+ };
20005
+ function readU24BE(bytes, offset) {
20006
+ return bytes[offset] << 16 | bytes[offset + 1] << 8 | bytes[offset + 2];
20007
+ }
20008
+ function readVorbisComment(bytes, start, end) {
20009
+ let offset = start;
20010
+ if (offset + 4 > end) return null;
20011
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
20012
+ const vendorLength = view.getUint32(offset, true);
20013
+ offset += 4;
20014
+ if (offset + vendorLength > end) return null;
20015
+ const vendor = Buffer.from(bytes.subarray(offset, offset + vendorLength)).toString("utf8");
20016
+ offset += vendorLength;
20017
+ if (offset + 4 > end) return null;
20018
+ const commentCount = view.getUint32(offset, true);
20019
+ offset += 4;
20020
+ const tags = {};
20021
+ for (let i = 0; i < commentCount; i++) {
20022
+ if (offset + 4 > end) break;
20023
+ const commentLength = view.getUint32(offset, true);
20024
+ offset += 4;
20025
+ if (offset + commentLength > end) break;
20026
+ const comment = Buffer.from(bytes.subarray(offset, offset + commentLength)).toString("utf8");
20027
+ offset += commentLength;
20028
+ const eq = comment.indexOf("=");
20029
+ if (eq > 0) {
20030
+ const key = comment.slice(0, eq).toUpperCase();
20031
+ const value = comment.slice(eq + 1);
20032
+ tags[key] = value;
20033
+ }
20034
+ }
20035
+ return { vendor, tags };
20036
+ }
20037
+ function readFlacInfo(bytes) {
20038
+ if (bytes.length < 4) return { error: "File is too small to be a valid FLAC file" };
20039
+ if (readAscii4(bytes, 0) !== "fLaC") return { error: 'Not a FLAC file (missing "fLaC" marker)' };
20040
+ let offset = 4;
20041
+ let streamInfo = null;
20042
+ let vorbisComment = null;
20043
+ while (offset + 4 <= bytes.length) {
20044
+ const header = bytes[offset];
20045
+ const isLast = (header & 128) !== 0;
20046
+ const blockType = header & 127;
20047
+ const length = readU24BE(bytes, offset + 1);
20048
+ const dataStart = offset + 4;
20049
+ const dataEnd = dataStart + length;
20050
+ if (dataEnd > bytes.length) return { error: "Truncated metadata block" };
20051
+ if (blockType === 0) {
20052
+ if (length < 34) return { error: "Truncated STREAMINFO block" };
20053
+ const minBlockSize = bytes[dataStart] << 8 | bytes[dataStart + 1];
20054
+ const maxBlockSize = bytes[dataStart + 2] << 8 | bytes[dataStart + 3];
20055
+ const minFrameSize = readU24BE(bytes, dataStart + 4);
20056
+ const maxFrameSize = readU24BE(bytes, dataStart + 7);
20057
+ let packed = 0n;
20058
+ for (let i = 0; i < 8; i++) packed = packed << 8n | BigInt(bytes[dataStart + 10 + i]);
20059
+ const sampleRate = Number(packed >> 44n & 0xfffffn);
20060
+ const channels = Number(packed >> 41n & 0x7n) + 1;
20061
+ const bitsPerSample = Number(packed >> 36n & 0x1fn) + 1;
20062
+ const totalSamples = Number(packed & 0xfffffffffn);
20063
+ if (sampleRate <= 0) return { error: "Invalid sample rate in STREAMINFO block" };
20064
+ streamInfo = {
20065
+ sampleRate,
20066
+ channels,
20067
+ bitsPerSample,
20068
+ totalSamples,
20069
+ durationSeconds: Math.round(totalSamples / sampleRate * 1e3) / 1e3,
20070
+ minBlockSize,
20071
+ maxBlockSize,
20072
+ minFrameSize,
20073
+ maxFrameSize
20074
+ };
20075
+ } else if (blockType === 4) {
20076
+ vorbisComment = readVorbisComment(bytes, dataStart, dataEnd);
20077
+ }
20078
+ offset = dataEnd;
20079
+ if (isLast) break;
20080
+ }
20081
+ if (!streamInfo) return { error: "No STREAMINFO block found in this FLAC file" };
20082
+ const result = { ...streamInfo };
20083
+ if (vorbisComment) {
20084
+ result.vendor = vorbisComment.vendor;
20085
+ result.tags = vorbisComment.tags;
20086
+ for (const [key, field] of Object.entries(FLAC_TAG_FIELDS)) {
20087
+ if (vorbisComment.tags[key] !== void 0) result[field] = vorbisComment.tags[key];
20088
+ }
20089
+ }
20090
+ return result;
20091
+ }
20092
+ function readU64BE(bytes, offset) {
20093
+ return readU32BE(bytes, offset) * 4294967296 + readU32BE(bytes, offset + 4);
20094
+ }
20095
+ function readMp4Boxes(bytes, start, end) {
20096
+ const boxes = [];
20097
+ let offset = start;
20098
+ while (offset + 8 <= end) {
20099
+ let size = readU32BE(bytes, offset);
20100
+ const type = readAscii4(bytes, offset + 4);
20101
+ let headerSize = 8;
20102
+ if (size === 1) {
20103
+ if (offset + 16 > end) break;
20104
+ size = readU64BE(bytes, offset + 8);
20105
+ headerSize = 16;
20106
+ } else if (size === 0) {
20107
+ size = end - offset;
20108
+ }
20109
+ if (size < headerSize || offset + size > end) break;
20110
+ boxes.push({ type, start: offset + headerSize, end: offset + size });
20111
+ offset += size;
20112
+ }
20113
+ return boxes;
20114
+ }
20115
+ function findMp4Box(boxes, type) {
20116
+ return boxes.find((b) => b.type === type);
20117
+ }
20118
+ function parseMp4Mvhd(bytes, box) {
20119
+ const o = box.start;
20120
+ if (o >= box.end) return null;
20121
+ const version2 = bytes[o];
20122
+ if (version2 === 1) {
20123
+ if (o + 32 > box.end) return null;
20124
+ return { timescale: readU32BE(bytes, o + 20), duration: readU64BE(bytes, o + 24) };
20125
+ }
20126
+ if (o + 20 > box.end) return null;
20127
+ return { timescale: readU32BE(bytes, o + 12), duration: readU32BE(bytes, o + 16) };
20128
+ }
20129
+ function parseMp4Tkhd(bytes, box) {
20130
+ const o = box.start;
20131
+ if (o >= box.end) return null;
20132
+ const version2 = bytes[o];
20133
+ const fixedFieldsSize = version2 === 1 ? 4 + 8 + 8 + 4 + 4 + 8 : 4 + 4 + 4 + 4 + 4 + 4;
20134
+ const afterDuration = o + fixedFieldsSize;
20135
+ const matrixStart = afterDuration + 8 + 2 + 2 + 2 + 2;
20136
+ const widthOffset = matrixStart + 36;
20137
+ if (widthOffset + 8 > box.end) return null;
20138
+ return { width: readU32BE(bytes, widthOffset) / 65536, height: readU32BE(bytes, widthOffset + 4) / 65536 };
20139
+ }
20140
+ function parseMp4Hdlr(bytes, box) {
20141
+ const o = box.start;
20142
+ if (o + 12 > box.end) return null;
20143
+ return readAscii4(bytes, o + 8);
20144
+ }
20145
+ function parseMp4StsdCodec(bytes, box) {
20146
+ const o = box.start;
20147
+ if (o + 8 > box.end) return null;
20148
+ const entryCount = readU32BE(bytes, o + 4);
20149
+ if (entryCount < 1) return null;
20150
+ const entryStart = o + 8;
20151
+ if (entryStart + 8 > box.end) return null;
20152
+ return readAscii4(bytes, entryStart + 4);
20153
+ }
20154
+ function parseMp4StsdVideoDims(bytes, box) {
20155
+ const o = box.start;
20156
+ if (o + 8 > box.end) return null;
20157
+ const entryCount = readU32BE(bytes, o + 4);
20158
+ if (entryCount < 1) return null;
20159
+ const entryStart = o + 8;
20160
+ if (entryStart + 36 > box.end) return null;
20161
+ return {
20162
+ width: bytes[entryStart + 32] << 8 | bytes[entryStart + 33],
20163
+ height: bytes[entryStart + 34] << 8 | bytes[entryStart + 35]
20164
+ };
20165
+ }
20166
+ function parseMp4(bytes) {
20167
+ const topBoxes = readMp4Boxes(bytes, 0, bytes.length);
20168
+ const ftyp = findMp4Box(topBoxes, "ftyp");
20169
+ const moov = findMp4Box(topBoxes, "moov");
20170
+ if (!moov) return { error: "No moov box found (not a valid or fully-downloaded MP4 file)" };
20171
+ const result = { format: "mp4" };
20172
+ if (ftyp && ftyp.start + 4 <= ftyp.end) result.majorBrand = readAscii4(bytes, ftyp.start);
20173
+ const moovBoxes = readMp4Boxes(bytes, moov.start, moov.end);
20174
+ const mvhd = findMp4Box(moovBoxes, "mvhd");
20175
+ if (mvhd) {
20176
+ const info = parseMp4Mvhd(bytes, mvhd);
20177
+ if (info && info.timescale > 0) result.durationSeconds = Math.round(info.duration / info.timescale * 1e3) / 1e3;
20178
+ }
20179
+ for (const trak of moovBoxes.filter((b) => b.type === "trak")) {
20180
+ const trakBoxes = readMp4Boxes(bytes, trak.start, trak.end);
20181
+ const mdia = findMp4Box(trakBoxes, "mdia");
20182
+ if (!mdia) continue;
20183
+ const mdiaBoxes = readMp4Boxes(bytes, mdia.start, mdia.end);
20184
+ const hdlr = findMp4Box(mdiaBoxes, "hdlr");
20185
+ const handlerType = hdlr ? parseMp4Hdlr(bytes, hdlr) : null;
20186
+ const minf = findMp4Box(mdiaBoxes, "minf");
20187
+ if (!minf) continue;
20188
+ const stbl = findMp4Box(readMp4Boxes(bytes, minf.start, minf.end), "stbl");
20189
+ if (!stbl) continue;
20190
+ const stsd = findMp4Box(readMp4Boxes(bytes, stbl.start, stbl.end), "stsd");
20191
+ const codec = stsd ? parseMp4StsdCodec(bytes, stsd) : null;
20192
+ if (handlerType === "vide") {
20193
+ if (codec) result.videoCodec = codec;
20194
+ const tkhd = findMp4Box(trakBoxes, "tkhd");
20195
+ const dims = tkhd ? parseMp4Tkhd(bytes, tkhd) : null;
20196
+ if (dims && dims.width > 0 && dims.height > 0) {
20197
+ result.width = Math.round(dims.width);
20198
+ result.height = Math.round(dims.height);
20199
+ } else if (stsd) {
20200
+ const pixelDims = parseMp4StsdVideoDims(bytes, stsd);
20201
+ if (pixelDims && pixelDims.width > 0 && pixelDims.height > 0) {
20202
+ result.width = pixelDims.width;
20203
+ result.height = pixelDims.height;
20204
+ }
20205
+ }
20206
+ } else if (handlerType === "soun") {
20207
+ if (codec) result.audioCodec = codec;
20208
+ }
20209
+ }
20210
+ if (result.durationSeconds === void 0 && !result.videoCodec && !result.audioCodec) {
20211
+ return { error: "Could not find any usable track metadata in this MP4 file's moov box" };
20212
+ }
20213
+ return result;
20214
+ }
20215
+ function ebmlVintLength(firstByte) {
20216
+ if (firstByte === 0) return 0;
20217
+ let mask = 128;
20218
+ let length = 1;
20219
+ while (length <= 8 && (firstByte & mask) === 0) {
20220
+ mask >>= 1;
20221
+ length++;
20222
+ }
20223
+ return length;
20224
+ }
20225
+ function readEbmlId(bytes, offset) {
20226
+ if (offset >= bytes.length) return null;
20227
+ const length = ebmlVintLength(bytes[offset]);
20228
+ if (length === 0 || offset + length > bytes.length) return null;
20229
+ let id = 0;
20230
+ for (let i = 0; i < length; i++) id = id * 256 + bytes[offset + i];
20231
+ return { id, length };
20232
+ }
20233
+ function readEbmlSize(bytes, offset) {
20234
+ if (offset >= bytes.length) return null;
20235
+ const length = ebmlVintLength(bytes[offset]);
20236
+ if (length === 0 || offset + length > bytes.length) return null;
20237
+ const mask = 255 >> length;
20238
+ let value = bytes[offset] & mask;
20239
+ let allOnes = value === mask;
20240
+ for (let i = 1; i < length; i++) {
20241
+ value = value * 256 + bytes[offset + i];
20242
+ if (bytes[offset + i] !== 255) allOnes = false;
20243
+ }
20244
+ return { value, length, unknown: allOnes };
20245
+ }
20246
+ function readEbmlUint(bytes, offset, length) {
20247
+ let value = 0;
20248
+ for (let i = 0; i < length; i++) value = value * 256 + bytes[offset + i];
20249
+ return value;
20250
+ }
20251
+ function readEbmlFloat(bytes, offset, length) {
20252
+ if (offset + length > bytes.length) return 0;
20253
+ const view = new DataView(bytes.buffer, bytes.byteOffset + offset, length);
20254
+ if (length === 4) return view.getFloat32(0, false);
20255
+ if (length === 8) return view.getFloat64(0, false);
20256
+ return 0;
20257
+ }
20258
+ function ebmlChildren(bytes, start, end) {
20259
+ const children = [];
20260
+ let offset = start;
20261
+ while (offset < end) {
20262
+ const idInfo = readEbmlId(bytes, offset);
20263
+ if (!idInfo) break;
20264
+ const sizeInfo = readEbmlSize(bytes, offset + idInfo.length);
20265
+ if (!sizeInfo) break;
20266
+ const dataStart = offset + idInfo.length + sizeInfo.length;
20267
+ const dataEnd = sizeInfo.unknown ? end : Math.min(dataStart + sizeInfo.value, end);
20268
+ children.push({ id: idInfo.id, dataStart, dataEnd });
20269
+ offset = dataEnd;
20270
+ }
20271
+ return children;
20272
+ }
20273
+ var EBML_ID_SEGMENT = 408125543;
20274
+ var EBML_ID_INFO = 357149030;
20275
+ var EBML_ID_TIMECODE_SCALE = 2807729;
20276
+ var EBML_ID_DURATION = 17545;
20277
+ var EBML_ID_TRACKS = 374648427;
20278
+ var EBML_ID_TRACK_ENTRY = 174;
20279
+ var EBML_ID_TRACK_TYPE = 131;
20280
+ var EBML_ID_CODEC_ID = 134;
20281
+ var EBML_ID_VIDEO = 224;
20282
+ var EBML_ID_PIXEL_WIDTH = 176;
20283
+ var EBML_ID_PIXEL_HEIGHT = 186;
20284
+ var EBML_ID_CLUSTER = 524531317;
20285
+ function readVideoInfo(bytes) {
20286
+ if (bytes.length < 12) return { error: "File is too small to be a valid video file" };
20287
+ if (readAscii4(bytes, 4) === "ftyp") return parseMp4(bytes);
20288
+ if (bytes[0] === 26 && bytes[1] === 69 && bytes[2] === 223 && bytes[3] === 163) return parseWebm(bytes);
20289
+ return { error: 'Not a recognized MP4 or WebM file (missing an "ftyp" box or an EBML header signature)' };
20290
+ }
20291
+ function parseWebm(bytes) {
20292
+ const top = ebmlChildren(bytes, 0, bytes.length);
20293
+ const segment = top.find((c) => c.id === EBML_ID_SEGMENT);
20294
+ if (!segment) return { error: "No Segment element found (not a valid WebM/Matroska file)" };
20295
+ const result = { format: "webm" };
20296
+ let timecodeScale = 1e6;
20297
+ let rawDuration;
20298
+ for (const child of ebmlChildren(bytes, segment.dataStart, segment.dataEnd)) {
20299
+ if (child.id === EBML_ID_CLUSTER) break;
20300
+ if (child.id === EBML_ID_INFO) {
20301
+ for (const f of ebmlChildren(bytes, child.dataStart, child.dataEnd)) {
20302
+ if (f.id === EBML_ID_TIMECODE_SCALE) timecodeScale = readEbmlUint(bytes, f.dataStart, f.dataEnd - f.dataStart) || 1e6;
20303
+ else if (f.id === EBML_ID_DURATION) rawDuration = readEbmlFloat(bytes, f.dataStart, f.dataEnd - f.dataStart);
20304
+ }
20305
+ } else if (child.id === EBML_ID_TRACKS) {
20306
+ for (const entry of ebmlChildren(bytes, child.dataStart, child.dataEnd)) {
20307
+ if (entry.id !== EBML_ID_TRACK_ENTRY) continue;
20308
+ let trackType;
20309
+ let codecId;
20310
+ let pixelWidth;
20311
+ let pixelHeight;
20312
+ for (const f of ebmlChildren(bytes, entry.dataStart, entry.dataEnd)) {
20313
+ if (f.id === EBML_ID_TRACK_TYPE) trackType = readEbmlUint(bytes, f.dataStart, f.dataEnd - f.dataStart);
20314
+ else if (f.id === EBML_ID_CODEC_ID) codecId = Buffer.from(bytes.subarray(f.dataStart, f.dataEnd)).toString("ascii").replace(/\0+$/, "");
20315
+ else if (f.id === EBML_ID_VIDEO) {
20316
+ for (const v of ebmlChildren(bytes, f.dataStart, f.dataEnd)) {
20317
+ if (v.id === EBML_ID_PIXEL_WIDTH) pixelWidth = readEbmlUint(bytes, v.dataStart, v.dataEnd - v.dataStart);
20318
+ else if (v.id === EBML_ID_PIXEL_HEIGHT) pixelHeight = readEbmlUint(bytes, v.dataStart, v.dataEnd - v.dataStart);
20319
+ }
20320
+ }
20321
+ }
20322
+ if (trackType === 1) {
20323
+ if (codecId) result.videoCodec = codecId;
20324
+ if (pixelWidth) result.width = pixelWidth;
20325
+ if (pixelHeight) result.height = pixelHeight;
20326
+ } else if (trackType === 2) {
20327
+ if (codecId) result.audioCodec = codecId;
20328
+ }
20329
+ }
20330
+ }
20331
+ }
20332
+ if (rawDuration !== void 0 && timecodeScale > 0) {
20333
+ result.durationSeconds = Math.round(rawDuration * timecodeScale / 1e9 * 1e3) / 1e3;
20334
+ }
20335
+ if (result.durationSeconds === void 0 && !result.videoCodec && !result.audioCodec) {
20336
+ return { error: "Could not find any usable metadata in this WebM file's Segment element" };
20337
+ }
20338
+ return result;
20339
+ }
19961
20340
 
19962
20341
  // src/index.ts
19963
20342
  var version = "0.1.0";
package/dist/index.d.cts CHANGED
@@ -5,7 +5,7 @@ export { t as text } from './text-D1fySkCB.cjs';
5
5
  export { d as data } from './data-XRb0D7Zn.cjs';
6
6
  export { g as generators } from './generators-BGtRGpJZ.cjs';
7
7
  export { t as time } from './time-KqJjdqII.cjs';
8
- export { u as units } from './units-D2wEimKG.cjs';
8
+ export { u as units } from './units-COt5uI20.cjs';
9
9
  export { n as network } from './network-BJOjJnmY.cjs';
10
10
  export { a as api } from './api-DmTNE4c1.cjs';
11
11
  export { c as code } from './code-DaRvff2v.cjs';
@@ -13,7 +13,7 @@ export { c as color } from './color-tPwZCr9H.cjs';
13
13
  export { c as css } from './css-Cf7AMGM-.cjs';
14
14
  export { m as misc } from './misc-CA3N198T.cjs';
15
15
  export { a as ai_agent } from './ai_agent-B-c59NXD.cjs';
16
- export { m as media } from './media-9HEpTPGA.cjs';
16
+ export { m as media } from './media-cuxfzXxw.cjs';
17
17
 
18
18
  declare const version = "0.1.0";
19
19
 
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ export { t as text } from './text-D1fySkCB.js';
5
5
  export { d as data } from './data-XRb0D7Zn.js';
6
6
  export { g as generators } from './generators-BGtRGpJZ.js';
7
7
  export { t as time } from './time-KqJjdqII.js';
8
- export { u as units } from './units-D2wEimKG.js';
8
+ export { u as units } from './units-COt5uI20.js';
9
9
  export { n as network } from './network-BJOjJnmY.js';
10
10
  export { a as api } from './api-DmTNE4c1.js';
11
11
  export { c as code } from './code-DaRvff2v.js';
@@ -13,7 +13,7 @@ export { c as color } from './color-tPwZCr9H.js';
13
13
  export { c as css } from './css-Cf7AMGM-.js';
14
14
  export { m as misc } from './misc-CA3N198T.js';
15
15
  export { a as ai_agent } from './ai_agent-B-c59NXD.js';
16
- export { m as media } from './media-9HEpTPGA.js';
16
+ export { m as media } from './media-cuxfzXxw.js';
17
17
 
18
18
  declare const version = "0.1.0";
19
19
 
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- export { media_exports as media } from './chunk-XMKJYVKB.js';
2
- export { units_exports as units } from './chunk-HP6C4VBX.js';
1
+ export { media_exports as media } from './chunk-47DTCCQJ.js';
2
+ export { units_exports as units } from './chunk-I63BCOAG.js';
3
3
  export { network_exports as network } from './chunk-Y5OOP6WN.js';
4
4
  export { api_exports as api } from './chunk-52ZDKSIX.js';
5
5
  export { code_exports as code } from './chunk-LXKIPPDG.js';
@@ -131,9 +131,59 @@ interface IcoInfoError {
131
131
  * the same container format but a different type flag.
132
132
  */
133
133
  declare function readIcoInfo(bytes: Uint8Array): IcoInfo | IcoInfoError;
134
+ interface FlacInfo {
135
+ sampleRate: number;
136
+ channels: number;
137
+ bitsPerSample: number;
138
+ totalSamples: number;
139
+ durationSeconds: number;
140
+ minBlockSize: number;
141
+ maxBlockSize: number;
142
+ minFrameSize: number;
143
+ maxFrameSize: number;
144
+ vendor?: string;
145
+ title?: string;
146
+ artist?: string;
147
+ album?: string;
148
+ date?: string;
149
+ genre?: string;
150
+ trackNumber?: string;
151
+ tags?: Record<string, string>;
152
+ }
153
+ interface FlacInfoError {
154
+ error: string;
155
+ }
156
+ /**
157
+ * Read a FLAC file's STREAMINFO metadata block (sample rate, channels, bit
158
+ * depth, total samples, duration) and, if present, its VORBIS_COMMENT block
159
+ * (vendor string and tags like ARTIST/TITLE/ALBUM), directly from the file's
160
+ * metadata-block headers. No audio frame decoding is performed.
161
+ */
162
+ declare function readFlacInfo(bytes: Uint8Array): FlacInfo | FlacInfoError;
163
+ interface VideoInfo {
164
+ format: 'mp4' | 'webm';
165
+ durationSeconds?: number;
166
+ width?: number;
167
+ height?: number;
168
+ videoCodec?: string;
169
+ audioCodec?: string;
170
+ majorBrand?: string;
171
+ }
172
+ interface VideoInfoError {
173
+ error: string;
174
+ }
175
+ /**
176
+ * Read an MP4 (ISO BMFF) or WebM (EBML/Matroska) container's header boxes
177
+ * to report duration, resolution, and video/audio codec identifiers.
178
+ * No frame decoding, demuxing of sample data, or transcoding is performed;
179
+ * only the moov box (MP4) or Segment/Info/Tracks elements (WebM) are read.
180
+ */
181
+ declare function readVideoInfo(bytes: Uint8Array): VideoInfo | VideoInfoError;
134
182
 
135
183
  type media_ExifData = ExifData;
136
184
  type media_ExifError = ExifError;
185
+ type media_FlacInfo = FlacInfo;
186
+ type media_FlacInfoError = FlacInfoError;
137
187
  type media_IcoImageEntry = IcoImageEntry;
138
188
  type media_IcoInfo = IcoInfo;
139
189
  type media_IcoInfoError = IcoInfoError;
@@ -144,16 +194,20 @@ type media_ImageInfo = ImageInfo;
144
194
  type media_ImageInfoError = ImageInfoError;
145
195
  type media_PdfMetadata = PdfMetadata;
146
196
  type media_PdfMetadataError = PdfMetadataError;
197
+ type media_VideoInfo = VideoInfo;
198
+ type media_VideoInfoError = VideoInfoError;
147
199
  type media_WavInfo = WavInfo;
148
200
  type media_WavInfoError = WavInfoError;
149
201
  declare const media_readExifData: typeof readExifData;
202
+ declare const media_readFlacInfo: typeof readFlacInfo;
150
203
  declare const media_readIcoInfo: typeof readIcoInfo;
151
204
  declare const media_readId3Tags: typeof readId3Tags;
152
205
  declare const media_readImageInfo: typeof readImageInfo;
153
206
  declare const media_readPdfMetadata: typeof readPdfMetadata;
207
+ declare const media_readVideoInfo: typeof readVideoInfo;
154
208
  declare const media_readWavInfo: typeof readWavInfo;
155
209
  declare namespace media {
156
- export { type media_ExifData as ExifData, type media_ExifError as ExifError, type media_IcoImageEntry as IcoImageEntry, type media_IcoInfo as IcoInfo, type media_IcoInfoError as IcoInfoError, type media_Id3Tags as Id3Tags, type media_Id3TagsError as Id3TagsError, type media_ImageFormat as ImageFormat, type media_ImageInfo as ImageInfo, type media_ImageInfoError as ImageInfoError, type media_PdfMetadata as PdfMetadata, type media_PdfMetadataError as PdfMetadataError, type media_WavInfo as WavInfo, type media_WavInfoError as WavInfoError, media_readExifData as readExifData, media_readIcoInfo as readIcoInfo, media_readId3Tags as readId3Tags, media_readImageInfo as readImageInfo, media_readPdfMetadata as readPdfMetadata, media_readWavInfo as readWavInfo };
210
+ export { type media_ExifData as ExifData, type media_ExifError as ExifError, type media_FlacInfo as FlacInfo, type media_FlacInfoError as FlacInfoError, type media_IcoImageEntry as IcoImageEntry, type media_IcoInfo as IcoInfo, type media_IcoInfoError as IcoInfoError, type media_Id3Tags as Id3Tags, type media_Id3TagsError as Id3TagsError, type media_ImageFormat as ImageFormat, type media_ImageInfo as ImageInfo, type media_ImageInfoError as ImageInfoError, type media_PdfMetadata as PdfMetadata, type media_PdfMetadataError as PdfMetadataError, type media_VideoInfo as VideoInfo, type media_VideoInfoError as VideoInfoError, type media_WavInfo as WavInfo, type media_WavInfoError as WavInfoError, media_readExifData as readExifData, media_readFlacInfo as readFlacInfo, media_readIcoInfo as readIcoInfo, media_readId3Tags as readId3Tags, media_readImageInfo as readImageInfo, media_readPdfMetadata as readPdfMetadata, media_readVideoInfo as readVideoInfo, media_readWavInfo as readWavInfo };
157
211
  }
158
212
 
159
- export { type ExifData as E, type IcoImageEntry as I, type PdfMetadata as P, type WavInfo as W, type ExifError as a, type IcoInfo as b, type IcoInfoError as c, type Id3Tags as d, type Id3TagsError as e, type ImageFormat as f, type ImageInfo as g, type ImageInfoError as h, type PdfMetadataError as i, type WavInfoError as j, readIcoInfo as k, readId3Tags as l, media as m, readImageInfo as n, readPdfMetadata as o, readWavInfo as p, readExifData as r };
213
+ export { type ExifData as E, type FlacInfo as F, type IcoImageEntry as I, type PdfMetadata as P, type VideoInfo as V, type WavInfo as W, type ExifError as a, type FlacInfoError as b, type IcoInfo as c, type IcoInfoError as d, type Id3Tags as e, type Id3TagsError as f, type ImageFormat as g, type ImageInfo as h, type ImageInfoError as i, type PdfMetadataError as j, type VideoInfoError as k, type WavInfoError as l, media as m, readFlacInfo as n, readIcoInfo as o, readId3Tags as p, readImageInfo as q, readExifData as r, readPdfMetadata as s, readVideoInfo as t, readWavInfo as u };
@@ -131,9 +131,59 @@ interface IcoInfoError {
131
131
  * the same container format but a different type flag.
132
132
  */
133
133
  declare function readIcoInfo(bytes: Uint8Array): IcoInfo | IcoInfoError;
134
+ interface FlacInfo {
135
+ sampleRate: number;
136
+ channels: number;
137
+ bitsPerSample: number;
138
+ totalSamples: number;
139
+ durationSeconds: number;
140
+ minBlockSize: number;
141
+ maxBlockSize: number;
142
+ minFrameSize: number;
143
+ maxFrameSize: number;
144
+ vendor?: string;
145
+ title?: string;
146
+ artist?: string;
147
+ album?: string;
148
+ date?: string;
149
+ genre?: string;
150
+ trackNumber?: string;
151
+ tags?: Record<string, string>;
152
+ }
153
+ interface FlacInfoError {
154
+ error: string;
155
+ }
156
+ /**
157
+ * Read a FLAC file's STREAMINFO metadata block (sample rate, channels, bit
158
+ * depth, total samples, duration) and, if present, its VORBIS_COMMENT block
159
+ * (vendor string and tags like ARTIST/TITLE/ALBUM), directly from the file's
160
+ * metadata-block headers. No audio frame decoding is performed.
161
+ */
162
+ declare function readFlacInfo(bytes: Uint8Array): FlacInfo | FlacInfoError;
163
+ interface VideoInfo {
164
+ format: 'mp4' | 'webm';
165
+ durationSeconds?: number;
166
+ width?: number;
167
+ height?: number;
168
+ videoCodec?: string;
169
+ audioCodec?: string;
170
+ majorBrand?: string;
171
+ }
172
+ interface VideoInfoError {
173
+ error: string;
174
+ }
175
+ /**
176
+ * Read an MP4 (ISO BMFF) or WebM (EBML/Matroska) container's header boxes
177
+ * to report duration, resolution, and video/audio codec identifiers.
178
+ * No frame decoding, demuxing of sample data, or transcoding is performed;
179
+ * only the moov box (MP4) or Segment/Info/Tracks elements (WebM) are read.
180
+ */
181
+ declare function readVideoInfo(bytes: Uint8Array): VideoInfo | VideoInfoError;
134
182
 
135
183
  type media_ExifData = ExifData;
136
184
  type media_ExifError = ExifError;
185
+ type media_FlacInfo = FlacInfo;
186
+ type media_FlacInfoError = FlacInfoError;
137
187
  type media_IcoImageEntry = IcoImageEntry;
138
188
  type media_IcoInfo = IcoInfo;
139
189
  type media_IcoInfoError = IcoInfoError;
@@ -144,16 +194,20 @@ type media_ImageInfo = ImageInfo;
144
194
  type media_ImageInfoError = ImageInfoError;
145
195
  type media_PdfMetadata = PdfMetadata;
146
196
  type media_PdfMetadataError = PdfMetadataError;
197
+ type media_VideoInfo = VideoInfo;
198
+ type media_VideoInfoError = VideoInfoError;
147
199
  type media_WavInfo = WavInfo;
148
200
  type media_WavInfoError = WavInfoError;
149
201
  declare const media_readExifData: typeof readExifData;
202
+ declare const media_readFlacInfo: typeof readFlacInfo;
150
203
  declare const media_readIcoInfo: typeof readIcoInfo;
151
204
  declare const media_readId3Tags: typeof readId3Tags;
152
205
  declare const media_readImageInfo: typeof readImageInfo;
153
206
  declare const media_readPdfMetadata: typeof readPdfMetadata;
207
+ declare const media_readVideoInfo: typeof readVideoInfo;
154
208
  declare const media_readWavInfo: typeof readWavInfo;
155
209
  declare namespace media {
156
- export { type media_ExifData as ExifData, type media_ExifError as ExifError, type media_IcoImageEntry as IcoImageEntry, type media_IcoInfo as IcoInfo, type media_IcoInfoError as IcoInfoError, type media_Id3Tags as Id3Tags, type media_Id3TagsError as Id3TagsError, type media_ImageFormat as ImageFormat, type media_ImageInfo as ImageInfo, type media_ImageInfoError as ImageInfoError, type media_PdfMetadata as PdfMetadata, type media_PdfMetadataError as PdfMetadataError, type media_WavInfo as WavInfo, type media_WavInfoError as WavInfoError, media_readExifData as readExifData, media_readIcoInfo as readIcoInfo, media_readId3Tags as readId3Tags, media_readImageInfo as readImageInfo, media_readPdfMetadata as readPdfMetadata, media_readWavInfo as readWavInfo };
210
+ export { type media_ExifData as ExifData, type media_ExifError as ExifError, type media_FlacInfo as FlacInfo, type media_FlacInfoError as FlacInfoError, type media_IcoImageEntry as IcoImageEntry, type media_IcoInfo as IcoInfo, type media_IcoInfoError as IcoInfoError, type media_Id3Tags as Id3Tags, type media_Id3TagsError as Id3TagsError, type media_ImageFormat as ImageFormat, type media_ImageInfo as ImageInfo, type media_ImageInfoError as ImageInfoError, type media_PdfMetadata as PdfMetadata, type media_PdfMetadataError as PdfMetadataError, type media_VideoInfo as VideoInfo, type media_VideoInfoError as VideoInfoError, type media_WavInfo as WavInfo, type media_WavInfoError as WavInfoError, media_readExifData as readExifData, media_readFlacInfo as readFlacInfo, media_readIcoInfo as readIcoInfo, media_readId3Tags as readId3Tags, media_readImageInfo as readImageInfo, media_readPdfMetadata as readPdfMetadata, media_readVideoInfo as readVideoInfo, media_readWavInfo as readWavInfo };
157
211
  }
158
212
 
159
- export { type ExifData as E, type IcoImageEntry as I, type PdfMetadata as P, type WavInfo as W, type ExifError as a, type IcoInfo as b, type IcoInfoError as c, type Id3Tags as d, type Id3TagsError as e, type ImageFormat as f, type ImageInfo as g, type ImageInfoError as h, type PdfMetadataError as i, type WavInfoError as j, readIcoInfo as k, readId3Tags as l, media as m, readImageInfo as n, readPdfMetadata as o, readWavInfo as p, readExifData as r };
213
+ export { type ExifData as E, type FlacInfo as F, type IcoImageEntry as I, type PdfMetadata as P, type VideoInfo as V, type WavInfo as W, type ExifError as a, type FlacInfoError as b, type IcoInfo as c, type IcoInfoError as d, type Id3Tags as e, type Id3TagsError as f, type ImageFormat as g, type ImageInfo as h, type ImageInfoError as i, type PdfMetadataError as j, type VideoInfoError as k, type WavInfoError as l, media as m, readFlacInfo as n, readIcoInfo as o, readId3Tags as p, readImageInfo as q, readExifData as r, readPdfMetadata as s, readVideoInfo as t, readWavInfo as u };