@bgord/bun 0.21.7 → 0.22.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/image-blur-noop.adapter.d.ts +5 -0
- package/dist/image-blur-noop.adapter.d.ts.map +1 -0
- package/dist/image-blur-noop.adapter.js +6 -0
- package/dist/image-blur-noop.adapter.js.map +1 -0
- package/dist/image-blur-sharp.adapter.d.ts +5 -0
- package/dist/image-blur-sharp.adapter.d.ts.map +1 -0
- package/dist/image-blur-sharp.adapter.js +79 -0
- package/dist/image-blur-sharp.adapter.js.map +1 -0
- package/dist/image-blur.port.d.ts +18 -0
- package/dist/image-blur.port.d.ts.map +1 -0
- package/dist/image-blur.port.js +2 -0
- package/dist/image-blur.port.js.map +1 -0
- package/dist/image-compressor-noop.adapter.d.ts +5 -0
- package/dist/image-compressor-noop.adapter.d.ts.map +1 -0
- package/dist/image-compressor-noop.adapter.js +6 -0
- package/dist/image-compressor-noop.adapter.js.map +1 -0
- package/dist/image-compressor-sharp.adapter.d.ts +6 -0
- package/dist/image-compressor-sharp.adapter.d.ts.map +1 -0
- package/dist/image-compressor-sharp.adapter.js +81 -0
- package/dist/image-compressor-sharp.adapter.js.map +1 -0
- package/dist/image-compressor.port.d.ts +18 -0
- package/dist/image-compressor.port.d.ts.map +1 -0
- package/dist/image-compressor.port.js +2 -0
- package/dist/image-compressor.port.js.map +1 -0
- package/dist/image-exif-clear-noop.adapter.d.ts +5 -0
- package/dist/image-exif-clear-noop.adapter.d.ts.map +1 -0
- package/dist/image-exif-clear-noop.adapter.js +6 -0
- package/dist/image-exif-clear-noop.adapter.js.map +1 -0
- package/dist/image-exif-clear-sharp.adapter.d.ts +5 -0
- package/dist/image-exif-clear-sharp.adapter.d.ts.map +1 -0
- package/dist/image-exif-clear-sharp.adapter.js +77 -0
- package/dist/image-exif-clear-sharp.adapter.js.map +1 -0
- package/dist/image-exif-clear.port.d.ts +16 -0
- package/dist/image-exif-clear.port.d.ts.map +1 -0
- package/dist/image-exif-clear.port.js +2 -0
- package/dist/image-exif-clear.port.js.map +1 -0
- package/dist/image-formatter-noop.adapter.d.ts +6 -0
- package/dist/image-formatter-noop.adapter.d.ts.map +1 -0
- package/dist/image-formatter-noop.adapter.js +8 -0
- package/dist/image-formatter-noop.adapter.js.map +1 -0
- package/dist/image-formatter-sharp.adapter.d.ts +5 -0
- package/dist/image-formatter-sharp.adapter.d.ts.map +1 -0
- package/dist/image-formatter-sharp.adapter.js +83 -0
- package/dist/image-formatter-sharp.adapter.js.map +1 -0
- package/dist/image-formatter.port.d.ts +17 -0
- package/dist/image-formatter.port.d.ts.map +1 -0
- package/dist/image-formatter.port.js +2 -0
- package/dist/image-formatter.port.js.map +1 -0
- package/dist/image-info-noop.adapter.d.ts +13 -0
- package/dist/image-info-noop.adapter.d.ts.map +1 -0
- package/dist/image-info-noop.adapter.js +16 -0
- package/dist/image-info-noop.adapter.js.map +1 -0
- package/dist/image-info-sharp.adapter.d.ts +11 -0
- package/dist/image-info-sharp.adapter.d.ts.map +1 -0
- package/dist/image-info-sharp.adapter.js +83 -0
- package/dist/image-info-sharp.adapter.js.map +1 -0
- package/dist/image-info.port.d.ts +12 -0
- package/dist/image-info.port.d.ts.map +1 -0
- package/dist/image-info.port.js +2 -0
- package/dist/image-info.port.js.map +1 -0
- package/dist/image-resizer-noop.adapter.d.ts +5 -0
- package/dist/image-resizer-noop.adapter.d.ts.map +1 -0
- package/dist/image-resizer-noop.adapter.js +6 -0
- package/dist/image-resizer-noop.adapter.js.map +1 -0
- package/dist/image-resizer-sharp.adapter.d.ts +5 -0
- package/dist/image-resizer-sharp.adapter.d.ts.map +1 -0
- package/dist/image-resizer-sharp.adapter.js +88 -0
- package/dist/image-resizer-sharp.adapter.js.map +1 -0
- package/dist/image-resizer.port.d.ts +18 -0
- package/dist/image-resizer.port.d.ts.map +1 -0
- package/dist/image-resizer.port.js +2 -0
- package/dist/image-resizer.port.js.map +1 -0
- package/dist/index.d.ts +18 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -2
- package/dist/index.js.map +1 -1
- package/dist/open-graph.service.d.ts +0 -5
- package/dist/open-graph.service.d.ts.map +1 -1
- package/dist/open-graph.service.js +2 -10
- package/dist/open-graph.service.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/readme.md +18 -2
- package/src/image-blur-noop.adapter.ts +7 -0
- package/src/image-blur-sharp.adapter.ts +24 -0
- package/src/image-blur.port.ts +20 -0
- package/src/image-compressor-noop.adapter.ts +7 -0
- package/src/image-compressor-sharp.adapter.ts +26 -0
- package/src/image-compressor.port.ts +20 -0
- package/src/image-exif-clear-noop.adapter.ts +7 -0
- package/src/image-exif-clear-sharp.adapter.ts +20 -0
- package/src/image-exif-clear.port.ts +18 -0
- package/src/image-formatter-noop.adapter.ts +10 -0
- package/src/image-formatter-sharp.adapter.ts +29 -0
- package/src/image-formatter.port.ts +19 -0
- package/src/image-info-noop.adapter.ts +15 -0
- package/src/image-info-sharp.adapter.ts +27 -0
- package/src/image-info.port.ts +7 -0
- package/src/image-resizer-noop.adapter.ts +7 -0
- package/src/image-resizer-sharp.adapter.ts +32 -0
- package/src/image-resizer.port.ts +20 -0
- package/src/index.ts +18 -2
- package/src/open-graph.service.ts +12 -12
- package/dist/image-compressor.service.d.ts +0 -14
- package/dist/image-compressor.service.d.ts.map +0 -1
- package/dist/image-compressor.service.js +0 -19
- package/dist/image-compressor.service.js.map +0 -1
- package/dist/image-exif.service.d.ts +0 -18
- package/dist/image-exif.service.d.ts.map +0 -1
- package/dist/image-exif.service.js +0 -21
- package/dist/image-exif.service.js.map +0 -1
- package/src/image-compressor.service.ts +0 -30
- package/src/image-exif.service.ts +0 -36
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ImageBlurPort, ImageBlurStrategy } from "./image-blur.port";
|
|
2
|
+
export declare class ImageBlurNoopAdapter implements ImageBlurPort {
|
|
3
|
+
blur(recipe: ImageBlurStrategy): Promise<import("@bgord/tools").FilePathRelative | import("@bgord/tools").FilePathAbsolute>;
|
|
4
|
+
}
|
|
5
|
+
//# sourceMappingURL=image-blur-noop.adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-blur-noop.adapter.d.ts","sourceRoot":"","sources":["../src/image-blur-noop.adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE1E,qBAAa,oBAAqB,YAAW,aAAa;IAClD,IAAI,CAAC,MAAM,EAAE,iBAAiB;CAGrC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-blur-noop.adapter.js","sourceRoot":"","sources":["../src/image-blur-noop.adapter.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,oBAAoB;IAC/B,KAAK,CAAC,IAAI,CAAC,MAAyB;QAClC,OAAO,MAAM,CAAC,QAAQ,KAAK,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;IAC1E,CAAC;CACF"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ImageBlurPort, ImageBlurStrategy } from "./image-blur.port";
|
|
2
|
+
export declare class ImageBlurSharpAdapter implements ImageBlurPort {
|
|
3
|
+
blur(recipe: ImageBlurStrategy): Promise<import("@bgord/tools").FilePathRelative | import("@bgord/tools").FilePathAbsolute>;
|
|
4
|
+
}
|
|
5
|
+
//# sourceMappingURL=image-blur-sharp.adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-blur-sharp.adapter.d.ts","sourceRoot":"","sources":["../src/image-blur-sharp.adapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE1E,qBAAa,qBAAsB,YAAW,aAAa;IACnD,IAAI,CAAC,MAAM,EAAE,iBAAiB;CAkBrC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
2
|
+
if (value !== null && value !== void 0) {
|
|
3
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
4
|
+
var dispose, inner;
|
|
5
|
+
if (async) {
|
|
6
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
7
|
+
dispose = value[Symbol.asyncDispose];
|
|
8
|
+
}
|
|
9
|
+
if (dispose === void 0) {
|
|
10
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
11
|
+
dispose = value[Symbol.dispose];
|
|
12
|
+
if (async) inner = dispose;
|
|
13
|
+
}
|
|
14
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
15
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
16
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
17
|
+
}
|
|
18
|
+
else if (async) {
|
|
19
|
+
env.stack.push({ async: true });
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
24
|
+
return function (env) {
|
|
25
|
+
function fail(e) {
|
|
26
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
27
|
+
env.hasError = true;
|
|
28
|
+
}
|
|
29
|
+
var r, s = 0;
|
|
30
|
+
function next() {
|
|
31
|
+
while (r = env.stack.pop()) {
|
|
32
|
+
try {
|
|
33
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
34
|
+
if (r.dispose) {
|
|
35
|
+
var result = r.dispose.call(r.value);
|
|
36
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
37
|
+
}
|
|
38
|
+
else s |= 1;
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
fail(e);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
45
|
+
if (env.hasError) throw env.error;
|
|
46
|
+
}
|
|
47
|
+
return next();
|
|
48
|
+
};
|
|
49
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
50
|
+
var e = new Error(message);
|
|
51
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
|
+
});
|
|
53
|
+
import fs from "node:fs/promises";
|
|
54
|
+
import sharp from "sharp";
|
|
55
|
+
export class ImageBlurSharpAdapter {
|
|
56
|
+
async blur(recipe) {
|
|
57
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
58
|
+
try {
|
|
59
|
+
const final = recipe.strategy === "output_path" ? recipe.output : recipe.input;
|
|
60
|
+
const filename = final.getFilename();
|
|
61
|
+
const temporary = final.withFilename(filename.withSuffix("-blurred"));
|
|
62
|
+
const extension = String(final.getFilename().getExtension());
|
|
63
|
+
const format = (extension === "jpg" ? "jpeg" : extension);
|
|
64
|
+
const pipeline = sharp(recipe.input.get());
|
|
65
|
+
const _sharp_ = __addDisposableResource(env_1, { [Symbol.dispose]: () => pipeline.destroy() }, false);
|
|
66
|
+
await pipeline.rotate().blur(recipe.sigma).toFormat(format).toFile(temporary.get());
|
|
67
|
+
await fs.rename(temporary.get(), final.get());
|
|
68
|
+
return final;
|
|
69
|
+
}
|
|
70
|
+
catch (e_1) {
|
|
71
|
+
env_1.error = e_1;
|
|
72
|
+
env_1.hasError = true;
|
|
73
|
+
}
|
|
74
|
+
finally {
|
|
75
|
+
__disposeResources(env_1);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=image-blur-sharp.adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-blur-sharp.adapter.js","sourceRoot":"","sources":["../src/image-blur-sharp.adapter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,MAAM,OAAO,qBAAqB;IAChC,KAAK,CAAC,IAAI,CAAC,MAAyB;;;YAClC,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,KAAK,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;YAE/E,MAAM,QAAQ,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;YACrC,MAAM,SAAS,GAAG,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC;YAEtE,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,YAAY,EAAE,CAAC,CAAC;YAC7D,MAAM,MAAM,GAAG,CAAC,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAA2B,CAAC;YAEpF,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;YAC3C,MAAM,OAAO,kCAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,QAAA,CAAC;YAE/D,MAAM,QAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,CAAC;YAEpF,MAAM,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;YAE9C,OAAO,KAAK,CAAC;;;;;;;;;KACd;CACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type * as tools from "@bgord/tools";
|
|
2
|
+
type ImageBlurOutputPathStrategy = {
|
|
3
|
+
strategy: "output_path";
|
|
4
|
+
input: tools.FilePathRelative | tools.FilePathAbsolute;
|
|
5
|
+
output: tools.FilePathRelative | tools.FilePathAbsolute;
|
|
6
|
+
sigma?: number;
|
|
7
|
+
};
|
|
8
|
+
type ImageBlurInPlaceStrategy = {
|
|
9
|
+
strategy: "in_place";
|
|
10
|
+
input: tools.FilePathRelative | tools.FilePathAbsolute;
|
|
11
|
+
sigma?: number;
|
|
12
|
+
};
|
|
13
|
+
export type ImageBlurStrategy = ImageBlurOutputPathStrategy | ImageBlurInPlaceStrategy;
|
|
14
|
+
export interface ImageBlurPort {
|
|
15
|
+
blur(recipe: ImageBlurStrategy): Promise<tools.FilePathRelative | tools.FilePathAbsolute>;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=image-blur.port.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-blur.port.d.ts","sourceRoot":"","sources":["../src/image-blur.port.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAE3C,KAAK,2BAA2B,GAAG;IACjC,QAAQ,EAAE,aAAa,CAAC;IACxB,KAAK,EAAE,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC,gBAAgB,CAAC;IACvD,MAAM,EAAE,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC,gBAAgB,CAAC;IACxD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,KAAK,wBAAwB,GAAG;IAC9B,QAAQ,EAAE,UAAU,CAAC;IACrB,KAAK,EAAE,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC,gBAAgB,CAAC;IACvD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,2BAA2B,GAAG,wBAAwB,CAAC;AAEvF,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC,gBAAgB,CAAC,CAAC;CAC3F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-blur.port.js","sourceRoot":"","sources":["../src/image-blur.port.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ImageCompressorPort, ImageCompressorStrategy } from "./image-compressor.port";
|
|
2
|
+
export declare class ImageCompressorNoopAdapter implements ImageCompressorPort {
|
|
3
|
+
compress(recipe: ImageCompressorStrategy): Promise<import("@bgord/tools").FilePathRelative | import("@bgord/tools").FilePathAbsolute>;
|
|
4
|
+
}
|
|
5
|
+
//# sourceMappingURL=image-compressor-noop.adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-compressor-noop.adapter.d.ts","sourceRoot":"","sources":["../src/image-compressor-noop.adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAE5F,qBAAa,0BAA2B,YAAW,mBAAmB;IAC9D,QAAQ,CAAC,MAAM,EAAE,uBAAuB;CAG/C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-compressor-noop.adapter.js","sourceRoot":"","sources":["../src/image-compressor-noop.adapter.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,0BAA0B;IACrC,KAAK,CAAC,QAAQ,CAAC,MAA+B;QAC5C,OAAO,MAAM,CAAC,QAAQ,KAAK,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;IAC1E,CAAC;CACF"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ImageCompressorPort, ImageCompressorStrategy } from "./image-compressor.port";
|
|
2
|
+
export declare class ImageCompressorSharpAdapter implements ImageCompressorPort {
|
|
3
|
+
private static readonly DEFAULT_QUALITY;
|
|
4
|
+
compress(recipe: ImageCompressorStrategy): Promise<import("@bgord/tools").FilePathRelative | import("@bgord/tools").FilePathAbsolute>;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=image-compressor-sharp.adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-compressor-sharp.adapter.d.ts","sourceRoot":"","sources":["../src/image-compressor-sharp.adapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAE5F,qBAAa,2BAA4B,YAAW,mBAAmB;IACrE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAM;IAEvC,QAAQ,CAAC,MAAM,EAAE,uBAAuB;CAkB/C"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
2
|
+
if (value !== null && value !== void 0) {
|
|
3
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
4
|
+
var dispose, inner;
|
|
5
|
+
if (async) {
|
|
6
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
7
|
+
dispose = value[Symbol.asyncDispose];
|
|
8
|
+
}
|
|
9
|
+
if (dispose === void 0) {
|
|
10
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
11
|
+
dispose = value[Symbol.dispose];
|
|
12
|
+
if (async) inner = dispose;
|
|
13
|
+
}
|
|
14
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
15
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
16
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
17
|
+
}
|
|
18
|
+
else if (async) {
|
|
19
|
+
env.stack.push({ async: true });
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
24
|
+
return function (env) {
|
|
25
|
+
function fail(e) {
|
|
26
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
27
|
+
env.hasError = true;
|
|
28
|
+
}
|
|
29
|
+
var r, s = 0;
|
|
30
|
+
function next() {
|
|
31
|
+
while (r = env.stack.pop()) {
|
|
32
|
+
try {
|
|
33
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
34
|
+
if (r.dispose) {
|
|
35
|
+
var result = r.dispose.call(r.value);
|
|
36
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
37
|
+
}
|
|
38
|
+
else s |= 1;
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
fail(e);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
45
|
+
if (env.hasError) throw env.error;
|
|
46
|
+
}
|
|
47
|
+
return next();
|
|
48
|
+
};
|
|
49
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
50
|
+
var e = new Error(message);
|
|
51
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
|
+
});
|
|
53
|
+
import fs from "node:fs/promises";
|
|
54
|
+
import sharp from "sharp";
|
|
55
|
+
export class ImageCompressorSharpAdapter {
|
|
56
|
+
static DEFAULT_QUALITY = 85;
|
|
57
|
+
async compress(recipe) {
|
|
58
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
59
|
+
try {
|
|
60
|
+
const quality = recipe.quality ?? ImageCompressorSharpAdapter.DEFAULT_QUALITY;
|
|
61
|
+
const final = recipe.strategy === "output_path" ? recipe.output : recipe.input;
|
|
62
|
+
const filename = final.getFilename();
|
|
63
|
+
const temporary = final.withFilename(filename.withSuffix("-compressed"));
|
|
64
|
+
const extension = final.getFilename().getExtension();
|
|
65
|
+
const format = (extension === "jpg" ? "jpeg" : extension);
|
|
66
|
+
const pipeline = sharp(recipe.input.get());
|
|
67
|
+
const _sharp_ = __addDisposableResource(env_1, { [Symbol.dispose]: () => pipeline.destroy() }, false);
|
|
68
|
+
await pipeline.rotate().toFormat(format, { quality }).toFile(temporary.get());
|
|
69
|
+
await fs.rename(temporary.get(), final.get());
|
|
70
|
+
return final;
|
|
71
|
+
}
|
|
72
|
+
catch (e_1) {
|
|
73
|
+
env_1.error = e_1;
|
|
74
|
+
env_1.hasError = true;
|
|
75
|
+
}
|
|
76
|
+
finally {
|
|
77
|
+
__disposeResources(env_1);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=image-compressor-sharp.adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-compressor-sharp.adapter.js","sourceRoot":"","sources":["../src/image-compressor-sharp.adapter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,MAAM,OAAO,2BAA2B;IAC9B,MAAM,CAAU,eAAe,GAAG,EAAE,CAAC;IAE7C,KAAK,CAAC,QAAQ,CAAC,MAA+B;;;YAC5C,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,2BAA2B,CAAC,eAAe,CAAC;YAE9E,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,KAAK,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;YAC/E,MAAM,QAAQ,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;YACrC,MAAM,SAAS,GAAG,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC;YAEzE,MAAM,SAAS,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC,YAAY,EAAE,CAAC;YACrD,MAAM,MAAM,GAAG,CAAC,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAA2B,CAAC;YAEpF,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;YAC3C,MAAM,OAAO,kCAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,QAAA,CAAC;YAE/D,MAAM,QAAQ,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,CAAC;YAC9E,MAAM,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;YAE9C,OAAO,KAAK,CAAC;;;;;;;;;KACd"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type * as tools from "@bgord/tools";
|
|
2
|
+
type ImageCompressorOutputPathStrategy = {
|
|
3
|
+
strategy: "output_path";
|
|
4
|
+
input: tools.FilePathRelative | tools.FilePathAbsolute;
|
|
5
|
+
output: tools.FilePathRelative | tools.FilePathAbsolute;
|
|
6
|
+
quality?: number;
|
|
7
|
+
};
|
|
8
|
+
type ImageCompressorInPlaceStrategy = {
|
|
9
|
+
strategy: "in_place";
|
|
10
|
+
input: tools.FilePathRelative | tools.FilePathAbsolute;
|
|
11
|
+
quality?: number;
|
|
12
|
+
};
|
|
13
|
+
export type ImageCompressorStrategy = ImageCompressorInPlaceStrategy | ImageCompressorOutputPathStrategy;
|
|
14
|
+
export interface ImageCompressorPort {
|
|
15
|
+
compress(recipe: ImageCompressorStrategy): Promise<tools.FilePathRelative | tools.FilePathAbsolute>;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=image-compressor.port.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-compressor.port.d.ts","sourceRoot":"","sources":["../src/image-compressor.port.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAE3C,KAAK,iCAAiC,GAAG;IACvC,QAAQ,EAAE,aAAa,CAAC;IACxB,KAAK,EAAE,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC,gBAAgB,CAAC;IACvD,MAAM,EAAE,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC,gBAAgB,CAAC;IACxD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,KAAK,8BAA8B,GAAG;IACpC,QAAQ,EAAE,UAAU,CAAC;IACrB,KAAK,EAAE,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC,gBAAgB,CAAC;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,8BAA8B,GAAG,iCAAiC,CAAC;AAEzG,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,MAAM,EAAE,uBAAuB,GAAG,OAAO,CAAC,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC,gBAAgB,CAAC,CAAC;CACrG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-compressor.port.js","sourceRoot":"","sources":["../src/image-compressor.port.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ImageExifClearPort, ImageExifClearStrategy } from "./image-exif-clear.port";
|
|
2
|
+
export declare class ImageExifClearNoopAdapter implements ImageExifClearPort {
|
|
3
|
+
clear(recipe: ImageExifClearStrategy): Promise<import("@bgord/tools").FilePathRelative | import("@bgord/tools").FilePathAbsolute>;
|
|
4
|
+
}
|
|
5
|
+
//# sourceMappingURL=image-exif-clear-noop.adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-exif-clear-noop.adapter.d.ts","sourceRoot":"","sources":["../src/image-exif-clear-noop.adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAE1F,qBAAa,yBAA0B,YAAW,kBAAkB;IAC5D,KAAK,CAAC,MAAM,EAAE,sBAAsB;CAG3C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-exif-clear-noop.adapter.js","sourceRoot":"","sources":["../src/image-exif-clear-noop.adapter.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,yBAAyB;IACpC,KAAK,CAAC,KAAK,CAAC,MAA8B;QACxC,OAAO,MAAM,CAAC,QAAQ,KAAK,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;IAC1E,CAAC;CACF"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ImageExifClearPort, ImageExifClearStrategy } from "./image-exif-clear.port";
|
|
2
|
+
export declare class ImageExifClearSharpAdapter implements ImageExifClearPort {
|
|
3
|
+
clear(recipe: ImageExifClearStrategy): Promise<import("@bgord/tools").FilePathRelative | import("@bgord/tools").FilePathAbsolute>;
|
|
4
|
+
}
|
|
5
|
+
//# sourceMappingURL=image-exif-clear-sharp.adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-exif-clear-sharp.adapter.d.ts","sourceRoot":"","sources":["../src/image-exif-clear-sharp.adapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAE1F,qBAAa,0BAA2B,YAAW,kBAAkB;IAC7D,KAAK,CAAC,MAAM,EAAE,sBAAsB;CAc3C"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
2
|
+
if (value !== null && value !== void 0) {
|
|
3
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
4
|
+
var dispose, inner;
|
|
5
|
+
if (async) {
|
|
6
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
7
|
+
dispose = value[Symbol.asyncDispose];
|
|
8
|
+
}
|
|
9
|
+
if (dispose === void 0) {
|
|
10
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
11
|
+
dispose = value[Symbol.dispose];
|
|
12
|
+
if (async) inner = dispose;
|
|
13
|
+
}
|
|
14
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
15
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
16
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
17
|
+
}
|
|
18
|
+
else if (async) {
|
|
19
|
+
env.stack.push({ async: true });
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
24
|
+
return function (env) {
|
|
25
|
+
function fail(e) {
|
|
26
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
27
|
+
env.hasError = true;
|
|
28
|
+
}
|
|
29
|
+
var r, s = 0;
|
|
30
|
+
function next() {
|
|
31
|
+
while (r = env.stack.pop()) {
|
|
32
|
+
try {
|
|
33
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
34
|
+
if (r.dispose) {
|
|
35
|
+
var result = r.dispose.call(r.value);
|
|
36
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
37
|
+
}
|
|
38
|
+
else s |= 1;
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
fail(e);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
45
|
+
if (env.hasError) throw env.error;
|
|
46
|
+
}
|
|
47
|
+
return next();
|
|
48
|
+
};
|
|
49
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
50
|
+
var e = new Error(message);
|
|
51
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
|
+
});
|
|
53
|
+
import fs from "node:fs/promises";
|
|
54
|
+
import sharp from "sharp";
|
|
55
|
+
export class ImageExifClearSharpAdapter {
|
|
56
|
+
async clear(recipe) {
|
|
57
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
58
|
+
try {
|
|
59
|
+
const final = recipe.strategy === "output_path" ? recipe.output : recipe.input;
|
|
60
|
+
const filename = final.getFilename();
|
|
61
|
+
const temporary = final.withFilename(filename.withSuffix("-exif-cleared"));
|
|
62
|
+
const pipeline = sharp(recipe.input.get());
|
|
63
|
+
const _sharp_ = __addDisposableResource(env_1, { [Symbol.dispose]: () => pipeline.destroy() }, false);
|
|
64
|
+
await pipeline.rotate().toFile(temporary.get());
|
|
65
|
+
await fs.rename(temporary.get(), final.get());
|
|
66
|
+
return final;
|
|
67
|
+
}
|
|
68
|
+
catch (e_1) {
|
|
69
|
+
env_1.error = e_1;
|
|
70
|
+
env_1.hasError = true;
|
|
71
|
+
}
|
|
72
|
+
finally {
|
|
73
|
+
__disposeResources(env_1);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=image-exif-clear-sharp.adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-exif-clear-sharp.adapter.js","sourceRoot":"","sources":["../src/image-exif-clear-sharp.adapter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,MAAM,OAAO,0BAA0B;IACrC,KAAK,CAAC,KAAK,CAAC,MAA8B;;;YACxC,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,KAAK,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;YAE/E,MAAM,QAAQ,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;YACrC,MAAM,SAAS,GAAG,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC;YAE3E,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;YAC3C,MAAM,OAAO,kCAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,QAAA,CAAC;YAE/D,MAAM,QAAQ,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,CAAC;YAChD,MAAM,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;YAE9C,OAAO,KAAK,CAAC;;;;;;;;;KACd;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type * as tools from "@bgord/tools";
|
|
2
|
+
type ImageExifClearOutputPathStrategy = {
|
|
3
|
+
strategy: "output_path";
|
|
4
|
+
input: tools.FilePathRelative | tools.FilePathAbsolute;
|
|
5
|
+
output: tools.FilePathRelative | tools.FilePathAbsolute;
|
|
6
|
+
};
|
|
7
|
+
type ImageExifClearInPlaceStrategy = {
|
|
8
|
+
strategy: "in_place";
|
|
9
|
+
input: tools.FilePathRelative | tools.FilePathAbsolute;
|
|
10
|
+
};
|
|
11
|
+
export type ImageExifClearStrategy = ImageExifClearInPlaceStrategy | ImageExifClearOutputPathStrategy;
|
|
12
|
+
export interface ImageExifClearPort {
|
|
13
|
+
clear(recipe: ImageExifClearStrategy): Promise<tools.FilePathRelative | tools.FilePathAbsolute>;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=image-exif-clear.port.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-exif-clear.port.d.ts","sourceRoot":"","sources":["../src/image-exif-clear.port.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAE3C,KAAK,gCAAgC,GAAG;IACtC,QAAQ,EAAE,aAAa,CAAC;IACxB,KAAK,EAAE,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC,gBAAgB,CAAC;IACvD,MAAM,EAAE,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC,gBAAgB,CAAC;CACzD,CAAC;AAEF,KAAK,6BAA6B,GAAG;IACnC,QAAQ,EAAE,UAAU,CAAC;IACrB,KAAK,EAAE,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC,gBAAgB,CAAC;CACxD,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,6BAA6B,GAAG,gCAAgC,CAAC;AAEtG,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC,gBAAgB,CAAC,CAAC;CACjG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-exif-clear.port.js","sourceRoot":"","sources":["../src/image-exif-clear.port.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type * as tools from "@bgord/tools";
|
|
2
|
+
import type { ImageFormatterPort, ImageFormatterStrategy } from "./image-formatter.port";
|
|
3
|
+
export declare class ImageFormatterNoopAdapter implements ImageFormatterPort {
|
|
4
|
+
format(recipe: ImageFormatterStrategy): Promise<tools.FilePathRelative | tools.FilePathAbsolute>;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=image-formatter-noop.adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-formatter-noop.adapter.d.ts","sourceRoot":"","sources":["../src/image-formatter-noop.adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEzF,qBAAa,yBAA0B,YAAW,kBAAkB;IAC5D,MAAM,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC,gBAAgB,CAAC;CAKvG"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export class ImageFormatterNoopAdapter {
|
|
2
|
+
async format(recipe) {
|
|
3
|
+
return recipe.strategy === "output_path"
|
|
4
|
+
? recipe.output
|
|
5
|
+
: recipe.input.withFilename(recipe.input.getFilename().withExtension(recipe.to));
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=image-formatter-noop.adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-formatter-noop.adapter.js","sourceRoot":"","sources":["../src/image-formatter-noop.adapter.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,yBAAyB;IACpC,KAAK,CAAC,MAAM,CAAC,MAA8B;QACzC,OAAO,MAAM,CAAC,QAAQ,KAAK,aAAa;YACtC,CAAC,CAAC,MAAM,CAAC,MAAM;YACf,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;IACrF,CAAC;CACF"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ImageFormatterPort, ImageFormatterStrategy } from "./image-formatter.port";
|
|
2
|
+
export declare class ImageFormatterSharpAdapter implements ImageFormatterPort {
|
|
3
|
+
format(recipe: ImageFormatterStrategy): Promise<import("@bgord/tools").FilePathRelative | import("@bgord/tools").FilePathAbsolute>;
|
|
4
|
+
}
|
|
5
|
+
//# sourceMappingURL=image-formatter-sharp.adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-formatter-sharp.adapter.d.ts","sourceRoot":"","sources":["../src/image-formatter-sharp.adapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEzF,qBAAa,0BAA2B,YAAW,kBAAkB;IAC7D,MAAM,CAAC,MAAM,EAAE,sBAAsB;CAuB5C"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
2
|
+
if (value !== null && value !== void 0) {
|
|
3
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
4
|
+
var dispose, inner;
|
|
5
|
+
if (async) {
|
|
6
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
7
|
+
dispose = value[Symbol.asyncDispose];
|
|
8
|
+
}
|
|
9
|
+
if (dispose === void 0) {
|
|
10
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
11
|
+
dispose = value[Symbol.dispose];
|
|
12
|
+
if (async) inner = dispose;
|
|
13
|
+
}
|
|
14
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
15
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
16
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
17
|
+
}
|
|
18
|
+
else if (async) {
|
|
19
|
+
env.stack.push({ async: true });
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
24
|
+
return function (env) {
|
|
25
|
+
function fail(e) {
|
|
26
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
27
|
+
env.hasError = true;
|
|
28
|
+
}
|
|
29
|
+
var r, s = 0;
|
|
30
|
+
function next() {
|
|
31
|
+
while (r = env.stack.pop()) {
|
|
32
|
+
try {
|
|
33
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
34
|
+
if (r.dispose) {
|
|
35
|
+
var result = r.dispose.call(r.value);
|
|
36
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
37
|
+
}
|
|
38
|
+
else s |= 1;
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
fail(e);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
45
|
+
if (env.hasError) throw env.error;
|
|
46
|
+
}
|
|
47
|
+
return next();
|
|
48
|
+
};
|
|
49
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
50
|
+
var e = new Error(message);
|
|
51
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
|
+
});
|
|
53
|
+
import fs from "node:fs/promises";
|
|
54
|
+
import sharp from "sharp";
|
|
55
|
+
export class ImageFormatterSharpAdapter {
|
|
56
|
+
async format(recipe) {
|
|
57
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
58
|
+
try {
|
|
59
|
+
const final = recipe.strategy === "output_path"
|
|
60
|
+
? recipe.output
|
|
61
|
+
: recipe.input.withFilename(recipe.input.getFilename().withExtension(recipe.to));
|
|
62
|
+
const temporary = final.withFilename(final.getFilename().withSuffix("-formatted"));
|
|
63
|
+
const finalExtension = String(final.getFilename().getExtension());
|
|
64
|
+
const encoder = (finalExtension === "jpg" ? "jpeg" : finalExtension);
|
|
65
|
+
const pipeline = sharp((recipe.strategy === "output_path" ? recipe.input : recipe.input).get());
|
|
66
|
+
const _sharp_ = __addDisposableResource(env_1, { [Symbol.dispose]: () => pipeline.destroy() }, false);
|
|
67
|
+
await pipeline.toFormat(encoder).toFile(temporary.get());
|
|
68
|
+
await fs.rename(temporary.get(), final.get());
|
|
69
|
+
if (recipe.strategy === "in_place" && final.get() !== recipe.input.get()) {
|
|
70
|
+
await fs.unlink(recipe.input.get());
|
|
71
|
+
}
|
|
72
|
+
return final;
|
|
73
|
+
}
|
|
74
|
+
catch (e_1) {
|
|
75
|
+
env_1.error = e_1;
|
|
76
|
+
env_1.hasError = true;
|
|
77
|
+
}
|
|
78
|
+
finally {
|
|
79
|
+
__disposeResources(env_1);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=image-formatter-sharp.adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-formatter-sharp.adapter.js","sourceRoot":"","sources":["../src/image-formatter-sharp.adapter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,MAAM,OAAO,0BAA0B;IACrC,KAAK,CAAC,MAAM,CAAC,MAA8B;;;YACzC,MAAM,KAAK,GACT,MAAM,CAAC,QAAQ,KAAK,aAAa;gBAC/B,CAAC,CAAC,MAAM,CAAC,MAAM;gBACf,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;YAErF,MAAM,SAAS,GAAG,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC;YAEnF,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,YAAY,EAAE,CAAC,CAAC;YAClE,MAAM,OAAO,GAAG,CAAC,cAAc,KAAK,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,cAAc,CAA2B,CAAC;YAE/F,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,QAAQ,KAAK,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;YAChG,MAAM,OAAO,kCAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,QAAA,CAAC;YAE/D,MAAM,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,CAAC;YACzD,MAAM,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;YAE9C,IAAI,MAAM,CAAC,QAAQ,KAAK,UAAU,IAAI,KAAK,CAAC,GAAG,EAAE,KAAK,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,CAAC;gBACzE,MAAM,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;YACtC,CAAC;YAED,OAAO,KAAK,CAAC;;;;;;;;;KACd;CACF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type * as tools from "@bgord/tools";
|
|
2
|
+
type ImageFormatterOutputPathStrategy = {
|
|
3
|
+
strategy: "output_path";
|
|
4
|
+
input: tools.FilePathRelative | tools.FilePathAbsolute;
|
|
5
|
+
output: tools.FilePathRelative | tools.FilePathAbsolute;
|
|
6
|
+
};
|
|
7
|
+
type ImageFormatterInPlaceStrategy = {
|
|
8
|
+
strategy: "in_place";
|
|
9
|
+
input: tools.FilePathRelative | tools.FilePathAbsolute;
|
|
10
|
+
to: tools.ExtensionType;
|
|
11
|
+
};
|
|
12
|
+
export type ImageFormatterStrategy = ImageFormatterInPlaceStrategy | ImageFormatterOutputPathStrategy;
|
|
13
|
+
export interface ImageFormatterPort {
|
|
14
|
+
format(recipe: ImageFormatterStrategy): Promise<tools.FilePathRelative | tools.FilePathAbsolute>;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=image-formatter.port.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-formatter.port.d.ts","sourceRoot":"","sources":["../src/image-formatter.port.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAE3C,KAAK,gCAAgC,GAAG;IACtC,QAAQ,EAAE,aAAa,CAAC;IACxB,KAAK,EAAE,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC,gBAAgB,CAAC;IACvD,MAAM,EAAE,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC,gBAAgB,CAAC;CACzD,CAAC;AAEF,KAAK,6BAA6B,GAAG;IACnC,QAAQ,EAAE,UAAU,CAAC;IACrB,KAAK,EAAE,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC,gBAAgB,CAAC;IACvD,EAAE,EAAE,KAAK,CAAC,aAAa,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,6BAA6B,GAAG,gCAAgC,CAAC;AAEtG,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC,gBAAgB,CAAC,CAAC;CAClG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-formatter.port.js","sourceRoot":"","sources":["../src/image-formatter.port.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as tools from "@bgord/tools";
|
|
2
|
+
import type { ImageInfoPort } from "./image-info.port";
|
|
3
|
+
export declare class ImageInfoNoopAdapter implements ImageInfoPort {
|
|
4
|
+
private readonly mime;
|
|
5
|
+
constructor(mime: tools.Mime);
|
|
6
|
+
inspect(_filePath: tools.FilePathRelative | tools.FilePathAbsolute): Promise<{
|
|
7
|
+
width: number & import("zod/v4").$brand<"Width">;
|
|
8
|
+
height: number & import("zod/v4").$brand<"Height">;
|
|
9
|
+
mime: tools.Mime;
|
|
10
|
+
size: tools.Size;
|
|
11
|
+
}>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=image-info-noop.adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-info-noop.adapter.d.ts","sourceRoot":"","sources":["../src/image-info-noop.adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,qBAAa,oBAAqB,YAAW,aAAa;IAC5C,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,KAAK,CAAC,IAAI;IAEvC,OAAO,CAAC,SAAS,EAAE,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC,gBAAgB;;;;;;CAQzE"}
|