Files
bare-operating-system/packages/bare-os-seeder/kernel/lib/bare/bundles/bareExif.js
T
2026-04-04 01:20:57 -04:00

168 lines
6.6 KiB
JavaScript

var __bare_os_bundle_exports__ = (() => {
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
}) : x)(function(x) {
if (typeof require !== "undefined") return require.apply(this, arguments);
throw Error('Dynamic require of "' + x + '" is not supported');
});
var __commonJS = (cb, mod) => function __require2() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// ../../node_modules/bare-exif/binding.js
var require_binding = __commonJS({
"../../node_modules/bare-exif/binding.js"(exports, module) {
module.exports = __require.addon();
}
});
// ../../node_modules/bare-exif/index.js
var require_bare_exif = __commonJS({
"../../node_modules/bare-exif/index.js"(exports) {
var binding = require_binding();
exports.constants = {
tags: binding.tags,
ifds: binding.ifds,
formats: binding.formats,
byteOrders: binding.byteOrders
};
var EXIFEntry = class {
constructor(data) {
this._handle = data.handle;
this.tag = data.tag;
this.format = data.format;
this.components = data.components;
this.data = data.data;
this.size = data.size;
this.byteOrder = data.byte_order;
}
#readComponent(index) {
const { formats, byteOrders } = binding;
const littleEndian = this.byteOrder === byteOrders.INTEL;
const view = new DataView(this.data);
switch (this.format) {
case formats.BYTE:
return view.getUint8(index);
case formats.SBYTE:
return view.getInt8(index);
case formats.SHORT:
return view.getUint16(index * 2, littleEndian);
case formats.SSHORT:
return view.getInt16(index * 2, littleEndian);
case formats.LONG:
return view.getUint32(index * 4, littleEndian);
case formats.SLONG:
return view.getInt32(index * 4, littleEndian);
case formats.FLOAT:
return view.getFloat32(index * 4, littleEndian);
case formats.DOUBLE:
return view.getFloat64(index * 8, littleEndian);
case formats.RATIONAL: {
return {
numerator: view.getUint32(index * 4, littleEndian),
denominator: view.getUint32(index * 4 + 4, littleEndian)
};
}
case formats.SRATIONAL: {
return {
numerator: view.getInt32(index * 4, littleEndian),
denominator: view.getInt32(index * 4 + 4, littleEndian)
};
}
case formats.ASCII: {
let text = "";
for (let i = 0; i < view.byteLength; i++) {
const c = view.getUint8(i);
if (c === 0) break;
text += String.fromCharCode(c);
}
return text;
}
case formats.UNDEFINED:
return Buffer.from(this.data);
default:
return null;
}
}
read() {
if (!this.components || this.components < 0) return null;
if (this.components === 1 || this.format === binding.formats.ASCII || this.format === binding.formats.UNDEFINED) {
return this.#readComponent(0);
}
const values = [];
for (let i = 0; i < this.components; i++) {
values.push(this.#readComponent(i));
}
return values;
}
value() {
return binding.entryValue(this._handle);
}
destroy() {
if (this._handle === null) return;
binding.destroyEntry(this._handle);
this._handle = null;
}
[Symbol.dispose]() {
this.destroy();
}
};
exports.Data = class EXIFData {
constructor(data) {
this._handle = binding.initData(data.buffer, data.byteOffset, data.byteLength);
}
entry(tag) {
const data = binding.entry(this._handle, tag);
if (!data) return null;
return new EXIFEntry(data);
}
destroy() {
if (this._handle === null) return;
binding.destroyData(this._handle);
this._handle = null;
}
[Symbol.dispose]() {
this.destroy();
}
};
}
});
// ../../bare-lib-entry-bareExif.js
var bare_lib_entry_bareExif_exports = {};
__export(bare_lib_entry_bareExif_exports, {
default: () => bare_lib_entry_bareExif_default
});
var import_bare_exif = __toESM(require_bare_exif());
var bare_lib_entry_bareExif_default = import_bare_exif.default;
return __toCommonJS(bare_lib_entry_bareExif_exports);
})();
;(function(){var g=globalThis;var s="__bare_os_stdlib__";g[s]=g[s]||{};var e=typeof __bare_os_bundle_exports__!=="undefined"?__bare_os_bundle_exports__:void 0;var v=e!=null&&typeof e==="object"&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e;g[s]["bareExif"]=v;})();