ccc-tnt-psd2ui/npm-packages/win32-v3.4.+/ag-psd/dist/index.js
2023-07-24 10:36:46 +08:00

55 lines
6.0 KiB
JavaScript

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.writePsdBuffer = exports.writePsdUint8Array = exports.writePsd = exports.readPsd = exports.byteArrayToBase64 = exports.initializeCanvas = void 0;
var psdWriter_1 = require("./psdWriter");
var psdReader_1 = require("./psdReader");
__exportStar(require("./abr"), exports);
__exportStar(require("./csh"), exports);
var helpers_1 = require("./helpers");
Object.defineProperty(exports, "initializeCanvas", { enumerable: true, get: function () { return helpers_1.initializeCanvas; } });
__exportStar(require("./psd"), exports);
var base64_js_1 = require("base64-js");
exports.byteArrayToBase64 = base64_js_1.fromByteArray;
function readPsd(buffer, options) {
var reader = 'buffer' in buffer ?
(0, psdReader_1.createReader)(buffer.buffer, buffer.byteOffset, buffer.byteLength) :
(0, psdReader_1.createReader)(buffer);
return (0, psdReader_1.readPsd)(reader, options);
}
exports.readPsd = readPsd;
function writePsd(psd, options) {
var writer = (0, psdWriter_1.createWriter)();
(0, psdWriter_1.writePsd)(writer, psd, options);
return (0, psdWriter_1.getWriterBuffer)(writer);
}
exports.writePsd = writePsd;
function writePsdUint8Array(psd, options) {
var writer = (0, psdWriter_1.createWriter)();
(0, psdWriter_1.writePsd)(writer, psd, options);
return (0, psdWriter_1.getWriterBufferNoCopy)(writer);
}
exports.writePsdUint8Array = writePsdUint8Array;
function writePsdBuffer(psd, options) {
if (typeof Buffer === 'undefined') {
throw new Error('Buffer not supported on this platform');
}
return Buffer.from(writePsdUint8Array(psd, options));
}
exports.writePsdBuffer = writePsdBuffer;
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQ0EseUNBQTRIO0FBQzVILHlDQUFrRjtBQUNsRix3Q0FBc0I7QUFDdEIsd0NBQXNCO0FBQ3RCLHFDQUE2QztBQUFwQywyR0FBQSxnQkFBZ0IsT0FBQTtBQUN6Qix3Q0FBc0I7QUFDdEIsdUNBQTBDO0FBUzdCLFFBQUEsaUJBQWlCLEdBQUcseUJBQWEsQ0FBQztBQUUvQyxTQUFnQixPQUFPLENBQUMsTUFBZ0MsRUFBRSxPQUFxQjtJQUM5RSxJQUFNLE1BQU0sR0FBRyxRQUFRLElBQUksTUFBTSxDQUFDLENBQUM7UUFDbEMsSUFBQSx3QkFBWSxFQUFDLE1BQU0sQ0FBQyxNQUFNLEVBQUUsTUFBTSxDQUFDLFVBQVUsRUFBRSxNQUFNLENBQUMsVUFBVSxDQUFDLENBQUMsQ0FBQztRQUNuRSxJQUFBLHdCQUFZLEVBQUMsTUFBTSxDQUFDLENBQUM7SUFDdEIsT0FBTyxJQUFBLG1CQUFlLEVBQUMsTUFBTSxFQUFFLE9BQU8sQ0FBQyxDQUFDO0FBQ3pDLENBQUM7QUFMRCwwQkFLQztBQUVELFNBQWdCLFFBQVEsQ0FBQyxHQUFRLEVBQUUsT0FBc0I7SUFDeEQsSUFBTSxNQUFNLEdBQUcsSUFBQSx3QkFBWSxHQUFFLENBQUM7SUFDOUIsSUFBQSxvQkFBZ0IsRUFBQyxNQUFNLEVBQUUsR0FBRyxFQUFFLE9BQU8sQ0FBQyxDQUFDO0lBQ3ZDLE9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