136 lines
5.1 KiB
JavaScript
136 lines
5.1 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-webp/binding.js
|
|
var require_binding = __commonJS({
|
|
"../../node_modules/bare-webp/binding.js"(exports, module) {
|
|
module.exports = __require.addon();
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-webp/index.js
|
|
var require_bare_webp = __commonJS({
|
|
"../../node_modules/bare-webp/index.js"(exports) {
|
|
var binding = require_binding();
|
|
exports.decode = function decode(image) {
|
|
const { width, height, data } = binding.decode(image);
|
|
return {
|
|
width,
|
|
height,
|
|
data: Buffer.from(data)
|
|
};
|
|
};
|
|
exports.decodeAnimated = function decodeAnimated(image) {
|
|
const decoder = binding.animatedDecoderInit(image);
|
|
const { width, height, loops } = binding.animatedDecoderGetInfo(decoder);
|
|
const frames = {
|
|
next() {
|
|
const frame = binding.animatedDecoderGetNextFrame(
|
|
decoder,
|
|
image
|
|
// Keep a reference for lifetime management
|
|
);
|
|
if (frame === null) {
|
|
return {
|
|
done: true
|
|
};
|
|
}
|
|
const { data, timestamp } = frame;
|
|
return {
|
|
done: false,
|
|
value: {
|
|
width,
|
|
height,
|
|
timestamp,
|
|
data: Buffer.from(data)
|
|
}
|
|
};
|
|
},
|
|
[Symbol.iterator]() {
|
|
return frames;
|
|
}
|
|
};
|
|
return {
|
|
width,
|
|
height,
|
|
loops,
|
|
frames
|
|
};
|
|
};
|
|
exports.encode = function encode(image, opts = {}) {
|
|
const { quality = 90 } = opts;
|
|
const buffer = binding.encode(
|
|
image.data,
|
|
image.width,
|
|
image.height,
|
|
clamp(quality, 0, 100)
|
|
);
|
|
return Buffer.from(buffer);
|
|
};
|
|
exports.encodeAnimated = function encodeAnimated(image, opts = {}) {
|
|
const { quality = 90 } = opts;
|
|
const encoder = binding.animatedEncoderInit(image.width, image.height);
|
|
for (const { data, timestamp } of image.frames) {
|
|
binding.animatedEncoderAddFrame(
|
|
encoder,
|
|
data,
|
|
image.width,
|
|
image.height,
|
|
clamp(quality, 0, 100),
|
|
timestamp
|
|
);
|
|
}
|
|
return Buffer.from(binding.animatedEncoderAssemble(encoder));
|
|
};
|
|
function clamp(value, min, max) {
|
|
return Math.max(min, Math.min(max, value));
|
|
}
|
|
}
|
|
});
|
|
|
|
// ../../bare-lib-entry-bareWebp.js
|
|
var bare_lib_entry_bareWebp_exports = {};
|
|
__export(bare_lib_entry_bareWebp_exports, {
|
|
default: () => bare_lib_entry_bareWebp_default
|
|
});
|
|
var import_bare_webp = __toESM(require_bare_webp());
|
|
var bare_lib_entry_bareWebp_default = import_bare_webp.default;
|
|
return __toCommonJS(bare_lib_entry_bareWebp_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]["bareWebp"]=v;})();
|