@xyo-network/image-thumbnail-plugin 2.99.3 → 2.99.5
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/neutral/Plugin.d.cts +3 -3
- package/dist/neutral/Plugin.d.mts +3 -3
- package/dist/neutral/Plugin.d.ts +3 -3
- package/dist/neutral/Witness/Params.d.cts +1 -1
- package/dist/neutral/Witness/Params.d.mts +1 -1
- package/dist/neutral/Witness/Params.d.ts +1 -1
- package/dist/neutral/Witness/Witness.d.cts +2 -2
- package/dist/neutral/Witness/Witness.d.mts +2 -2
- package/dist/neutral/Witness/Witness.d.ts +2 -2
- package/dist/neutral/Witness/ffmpeg/fluent/index.d.cts +1 -1
- package/dist/neutral/Witness/ffmpeg/fluent/index.d.mts +1 -1
- package/dist/neutral/Witness/ffmpeg/fluent/index.d.ts +1 -1
- package/dist/neutral/Witness/ffmpeg/index.d.cts +2 -2
- package/dist/neutral/Witness/ffmpeg/index.d.mts +2 -2
- package/dist/neutral/Witness/ffmpeg/index.d.ts +2 -2
- package/dist/neutral/Witness/ffmpeg/spawn/index.d.cts +2 -2
- package/dist/neutral/Witness/ffmpeg/spawn/index.d.mts +2 -2
- package/dist/neutral/Witness/ffmpeg/spawn/index.d.ts +2 -2
- package/dist/neutral/Witness/index.d.cts +3 -3
- package/dist/neutral/Witness/index.d.mts +3 -3
- package/dist/neutral/Witness/index.d.ts +3 -3
- package/dist/neutral/Witness/lib/index.d.cts +3 -3
- package/dist/neutral/Witness/lib/index.d.mts +3 -3
- package/dist/neutral/Witness/lib/index.d.ts +3 -3
- package/dist/neutral/index.cjs +113 -85
- package/dist/neutral/index.cjs.map +1 -1
- package/dist/neutral/index.d.cts +2 -2
- package/dist/neutral/index.d.mts +2 -2
- package/dist/neutral/index.d.ts +2 -2
- package/dist/neutral/{index.js → index.mjs} +116 -86
- package/dist/neutral/index.mjs.map +1 -0
- package/dist/node/Plugin.d.cts +3 -3
- package/dist/node/Plugin.d.mts +3 -3
- package/dist/node/Plugin.d.ts +3 -3
- package/dist/node/Witness/Params.d.cts +1 -1
- package/dist/node/Witness/Params.d.mts +1 -1
- package/dist/node/Witness/Params.d.ts +1 -1
- package/dist/node/Witness/Witness.d.cts +2 -2
- package/dist/node/Witness/Witness.d.mts +2 -2
- package/dist/node/Witness/Witness.d.ts +2 -2
- package/dist/node/Witness/ffmpeg/fluent/index.d.cts +1 -1
- package/dist/node/Witness/ffmpeg/fluent/index.d.mts +1 -1
- package/dist/node/Witness/ffmpeg/fluent/index.d.ts +1 -1
- package/dist/node/Witness/ffmpeg/index.d.cts +2 -2
- package/dist/node/Witness/ffmpeg/index.d.mts +2 -2
- package/dist/node/Witness/ffmpeg/index.d.ts +2 -2
- package/dist/node/Witness/ffmpeg/spawn/index.d.cts +2 -2
- package/dist/node/Witness/ffmpeg/spawn/index.d.mts +2 -2
- package/dist/node/Witness/ffmpeg/spawn/index.d.ts +2 -2
- package/dist/node/Witness/index.d.cts +3 -3
- package/dist/node/Witness/index.d.mts +3 -3
- package/dist/node/Witness/index.d.ts +3 -3
- package/dist/node/Witness/lib/index.d.cts +3 -3
- package/dist/node/Witness/lib/index.d.mts +3 -3
- package/dist/node/Witness/lib/index.d.ts +3 -3
- package/dist/node/index.cjs +122 -93
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +2 -2
- package/dist/node/index.d.mts +2 -2
- package/dist/node/index.d.ts +2 -2
- package/dist/node/{index.js → index.mjs} +126 -94
- package/dist/node/index.mjs.map +1 -0
- package/package.json +27 -27
- package/src/Plugin.ts +1 -1
- package/src/Witness/Params.ts +1 -1
- package/src/Witness/Witness.ts +10 -10
- package/src/Witness/ffmpeg/fluent/getVideoFrameAsImageFluent.ts +1 -1
- package/src/Witness/ffmpeg/fluent/index.ts +1 -1
- package/src/Witness/ffmpeg/index.ts +2 -2
- package/src/Witness/ffmpeg/spawn/getVideoFrameAsImage.ts +1 -1
- package/src/Witness/ffmpeg/spawn/index.ts +2 -2
- package/src/Witness/index.ts +3 -3
- package/src/Witness/lib/checkIpfsUrl.ts +3 -3
- package/src/Witness/lib/index.ts +3 -3
- package/src/index.ts +2 -2
- package/dist/neutral/index.js.map +0 -1
- package/dist/node/index.js.map +0 -1
package/dist/node/Plugin.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ImageThumbnailDiviner } from '@xyo-network/diviner-image-thumbnail';
|
|
2
|
-
import { ImageThumbnailWitness } from './Witness/index.
|
|
2
|
+
import { ImageThumbnailWitness } from './Witness/index.ts';
|
|
3
3
|
export declare const ImageThumbnailPlugin: () => import("@xyo-network/payloadset-plugin").PayloadSetDualPlugin<ImageThumbnailWitness<import("@xylabs/object").BaseParamsFields & {
|
|
4
4
|
account?: import("@xyo-network/account-model").AccountInstance | "random";
|
|
5
5
|
addToResolvers?: boolean;
|
|
@@ -9,7 +9,7 @@ export declare const ImageThumbnailPlugin: () => import("@xyo-network/payloadset
|
|
|
9
9
|
schema: "network.xyo.image.thumbnail.witness.config";
|
|
10
10
|
} & {
|
|
11
11
|
dataUrlPassthrough?: boolean;
|
|
12
|
-
encoding?: import("./Witness/Config.
|
|
12
|
+
encoding?: import("./Witness/Config.ts").ImageThumbnailEncoding;
|
|
13
13
|
height?: number;
|
|
14
14
|
ipfsGateway?: string;
|
|
15
15
|
maxAsyncProcesses?: number;
|
|
@@ -17,7 +17,7 @@ export declare const ImageThumbnailPlugin: () => import("@xyo-network/payloadset
|
|
|
17
17
|
maxCacheEntries?: number;
|
|
18
18
|
quality?: number;
|
|
19
19
|
runExclusive?: boolean;
|
|
20
|
-
schema: import("./Witness/Config.
|
|
20
|
+
schema: import("./Witness/Config.ts").ImageThumbnailWitnessConfigSchema;
|
|
21
21
|
width?: number;
|
|
22
22
|
}, "schema"> & {
|
|
23
23
|
schema: "network.xyo.image.thumbnail.witness.config";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AnyConfigSchema } from '@xyo-network/module-model';
|
|
2
2
|
import { WitnessParams } from '@xyo-network/witness-model';
|
|
3
|
-
import { ImageThumbnailWitnessConfig } from './Config.
|
|
3
|
+
import { ImageThumbnailWitnessConfig } from './Config.ts';
|
|
4
4
|
export type ImageThumbnailWitnessParams = WitnessParams<AnyConfigSchema<ImageThumbnailWitnessConfig>, {
|
|
5
5
|
loaders?: string[];
|
|
6
6
|
}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AnyConfigSchema } from '@xyo-network/module-model';
|
|
2
2
|
import { WitnessParams } from '@xyo-network/witness-model';
|
|
3
|
-
import { ImageThumbnailWitnessConfig } from './Config.
|
|
3
|
+
import { ImageThumbnailWitnessConfig } from './Config.ts';
|
|
4
4
|
export type ImageThumbnailWitnessParams = WitnessParams<AnyConfigSchema<ImageThumbnailWitnessConfig>, {
|
|
5
5
|
loaders?: string[];
|
|
6
6
|
}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AnyConfigSchema } from '@xyo-network/module-model';
|
|
2
2
|
import { WitnessParams } from '@xyo-network/witness-model';
|
|
3
|
-
import { ImageThumbnailWitnessConfig } from './Config.
|
|
3
|
+
import { ImageThumbnailWitnessConfig } from './Config.ts';
|
|
4
4
|
export type ImageThumbnailWitnessParams = WitnessParams<AnyConfigSchema<ImageThumbnailWitnessConfig>, {
|
|
5
5
|
loaders?: string[];
|
|
6
6
|
}>;
|
|
@@ -2,8 +2,8 @@ import { AbstractWitness } from '@xyo-network/abstract-witness';
|
|
|
2
2
|
import { ImageThumbnail } from '@xyo-network/image-thumbnail-payload-plugin';
|
|
3
3
|
import { Schema } from '@xyo-network/payload-model';
|
|
4
4
|
import { UrlPayload } from '@xyo-network/url-payload-plugin';
|
|
5
|
-
import { ImageThumbnailEncoding } from './Config.
|
|
6
|
-
import { ImageThumbnailWitnessParams } from './Params.
|
|
5
|
+
import { ImageThumbnailEncoding } from './Config.ts';
|
|
6
|
+
import { ImageThumbnailWitnessParams } from './Params.ts';
|
|
7
7
|
export interface ImageThumbnailWitnessError extends Error {
|
|
8
8
|
name: 'ImageThumbnailWitnessError';
|
|
9
9
|
url: string;
|
|
@@ -2,8 +2,8 @@ import { AbstractWitness } from '@xyo-network/abstract-witness';
|
|
|
2
2
|
import { ImageThumbnail } from '@xyo-network/image-thumbnail-payload-plugin';
|
|
3
3
|
import { Schema } from '@xyo-network/payload-model';
|
|
4
4
|
import { UrlPayload } from '@xyo-network/url-payload-plugin';
|
|
5
|
-
import { ImageThumbnailEncoding } from './Config.
|
|
6
|
-
import { ImageThumbnailWitnessParams } from './Params.
|
|
5
|
+
import { ImageThumbnailEncoding } from './Config.ts';
|
|
6
|
+
import { ImageThumbnailWitnessParams } from './Params.ts';
|
|
7
7
|
export interface ImageThumbnailWitnessError extends Error {
|
|
8
8
|
name: 'ImageThumbnailWitnessError';
|
|
9
9
|
url: string;
|
|
@@ -2,8 +2,8 @@ import { AbstractWitness } from '@xyo-network/abstract-witness';
|
|
|
2
2
|
import { ImageThumbnail } from '@xyo-network/image-thumbnail-payload-plugin';
|
|
3
3
|
import { Schema } from '@xyo-network/payload-model';
|
|
4
4
|
import { UrlPayload } from '@xyo-network/url-payload-plugin';
|
|
5
|
-
import { ImageThumbnailEncoding } from './Config.
|
|
6
|
-
import { ImageThumbnailWitnessParams } from './Params.
|
|
5
|
+
import { ImageThumbnailEncoding } from './Config.ts';
|
|
6
|
+
import { ImageThumbnailWitnessParams } from './Params.ts';
|
|
7
7
|
export interface ImageThumbnailWitnessError extends Error {
|
|
8
8
|
name: 'ImageThumbnailWitnessError';
|
|
9
9
|
url: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './getVideoFrameAsImageFluent.
|
|
1
|
+
export * from './getVideoFrameAsImageFluent.ts';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './getVideoFrameAsImageFluent.
|
|
1
|
+
export * from './getVideoFrameAsImageFluent.ts';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './getVideoFrameAsImageFluent.
|
|
1
|
+
export * from './getVideoFrameAsImageFluent.ts';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './fluent/index.
|
|
2
|
-
export * from './spawn/index.
|
|
1
|
+
export * from './fluent/index.ts';
|
|
2
|
+
export * from './spawn/index.ts';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './fluent/index.
|
|
2
|
-
export * from './spawn/index.
|
|
1
|
+
export * from './fluent/index.ts';
|
|
2
|
+
export * from './spawn/index.ts';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './fluent/index.
|
|
2
|
-
export * from './spawn/index.
|
|
1
|
+
export * from './fluent/index.ts';
|
|
2
|
+
export * from './spawn/index.ts';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './executeFfmpeg.
|
|
2
|
-
export * from './getVideoFrameAsImage.
|
|
1
|
+
export * from './executeFfmpeg.ts';
|
|
2
|
+
export * from './getVideoFrameAsImage.ts';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './executeFfmpeg.
|
|
2
|
-
export * from './getVideoFrameAsImage.
|
|
1
|
+
export * from './executeFfmpeg.ts';
|
|
2
|
+
export * from './getVideoFrameAsImage.ts';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './executeFfmpeg.
|
|
2
|
-
export * from './getVideoFrameAsImage.
|
|
1
|
+
export * from './executeFfmpeg.ts';
|
|
2
|
+
export * from './getVideoFrameAsImage.ts';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './Config.
|
|
2
|
-
export * from './Params.
|
|
3
|
-
export * from './Witness.
|
|
1
|
+
export * from './Config.ts';
|
|
2
|
+
export * from './Params.ts';
|
|
3
|
+
export * from './Witness.ts';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './Config.
|
|
2
|
-
export * from './Params.
|
|
3
|
-
export * from './Witness.
|
|
1
|
+
export * from './Config.ts';
|
|
2
|
+
export * from './Params.ts';
|
|
3
|
+
export * from './Witness.ts';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './Config.
|
|
2
|
-
export * from './Params.
|
|
3
|
-
export * from './Witness.
|
|
1
|
+
export * from './Config.ts';
|
|
2
|
+
export * from './Params.ts';
|
|
3
|
+
export * from './Witness.ts';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './checkIpfsUrl.
|
|
2
|
-
export * from './createDataUrl.
|
|
3
|
-
export * from './resolveDynamicSvg.
|
|
1
|
+
export * from './checkIpfsUrl.ts';
|
|
2
|
+
export * from './createDataUrl.ts';
|
|
3
|
+
export * from './resolveDynamicSvg.ts';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './checkIpfsUrl.
|
|
2
|
-
export * from './createDataUrl.
|
|
3
|
-
export * from './resolveDynamicSvg.
|
|
1
|
+
export * from './checkIpfsUrl.ts';
|
|
2
|
+
export * from './createDataUrl.ts';
|
|
3
|
+
export * from './resolveDynamicSvg.ts';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './checkIpfsUrl.
|
|
2
|
-
export * from './createDataUrl.
|
|
3
|
-
export * from './resolveDynamicSvg.
|
|
1
|
+
export * from './checkIpfsUrl.ts';
|
|
2
|
+
export * from './createDataUrl.ts';
|
|
3
|
+
export * from './resolveDynamicSvg.ts';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/node/index.cjs
CHANGED
|
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __reflectGet = Reflect.get;
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
11
|
var __export = (target, all) => {
|
|
9
12
|
for (var name in all)
|
|
10
13
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -27,6 +30,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
30
|
mod
|
|
28
31
|
));
|
|
29
32
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
33
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
34
|
+
var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
|
|
30
35
|
|
|
31
36
|
// src/index.ts
|
|
32
37
|
var src_exports = {};
|
|
@@ -71,7 +76,8 @@ var import_node_os = require("os");
|
|
|
71
76
|
var import_node_stream = require("stream");
|
|
72
77
|
var import_fluent_ffmpeg = __toESM(require("fluent-ffmpeg"), 1);
|
|
73
78
|
var import_uuid = require("uuid");
|
|
74
|
-
var
|
|
79
|
+
var _a;
|
|
80
|
+
var FfmpegOutputStream = (_a = class extends import_node_stream.Writable {
|
|
75
81
|
chunks = [];
|
|
76
82
|
constructor(options) {
|
|
77
83
|
super(options);
|
|
@@ -81,16 +87,18 @@ var FfmpegOutputStream = class extends import_node_stream.Writable {
|
|
|
81
87
|
callback();
|
|
82
88
|
}
|
|
83
89
|
/**
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
toBuffer = () => Buffer.concat(this.chunks);
|
|
89
|
-
};
|
|
90
|
-
var getVideoFrameAsImageFluent = async (videoBuffer) => {
|
|
90
|
+
* Collects the output from ffmpeg into a buffer.
|
|
91
|
+
* @returns A buffer containing the concatenated
|
|
92
|
+
* output from ffmpeg.
|
|
93
|
+
*/
|
|
94
|
+
toBuffer = /* @__PURE__ */ __name(() => Buffer.concat(this.chunks), "toBuffer");
|
|
95
|
+
}, __name(_a, "FfmpegOutputStream"), _a);
|
|
96
|
+
var getVideoFrameAsImageFluent = /* @__PURE__ */ __name(async (videoBuffer) => {
|
|
91
97
|
const tmpFile = `/${(0, import_node_os.tmpdir)()}/${(0, import_uuid.v4)()}`;
|
|
92
98
|
try {
|
|
93
|
-
await (0, import_promises.writeFile)(tmpFile, new Uint8Array(videoBuffer), {
|
|
99
|
+
await (0, import_promises.writeFile)(tmpFile, new Uint8Array(videoBuffer), {
|
|
100
|
+
encoding: "binary"
|
|
101
|
+
});
|
|
94
102
|
const imageBuffer = await new Promise((resolve, reject) => {
|
|
95
103
|
const ffmpegOutput = new FfmpegOutputStream();
|
|
96
104
|
(0, import_fluent_ffmpeg.default)().on("error", (err) => reject(err.message)).on("end", () => resolve(ffmpegOutput.toBuffer())).input(tmpFile).takeFrames(1).withNoAudio().outputOptions("-f image2pipe").videoCodec("png").pipe(ffmpegOutput);
|
|
@@ -102,12 +110,12 @@ var getVideoFrameAsImageFluent = async (videoBuffer) => {
|
|
|
102
110
|
} catch {
|
|
103
111
|
}
|
|
104
112
|
}
|
|
105
|
-
};
|
|
113
|
+
}, "getVideoFrameAsImageFluent");
|
|
106
114
|
|
|
107
115
|
// src/Witness/lib/checkIpfsUrl.ts
|
|
108
116
|
var import_assert = require("@xylabs/assert");
|
|
109
117
|
var allowIpfsIoRepair = true;
|
|
110
|
-
var checkIpfsUrl = (urlToCheck, ipfsGateway) => {
|
|
118
|
+
var checkIpfsUrl = /* @__PURE__ */ __name((urlToCheck, ipfsGateway) => {
|
|
111
119
|
try {
|
|
112
120
|
const url = new URL(urlToCheck);
|
|
113
121
|
let protocol = url.protocol;
|
|
@@ -136,19 +144,19 @@ var checkIpfsUrl = (urlToCheck, ipfsGateway) => {
|
|
|
136
144
|
} catch {
|
|
137
145
|
return urlToCheck;
|
|
138
146
|
}
|
|
139
|
-
};
|
|
147
|
+
}, "checkIpfsUrl");
|
|
140
148
|
|
|
141
149
|
// src/Witness/lib/createDataUrl.ts
|
|
142
150
|
var import_base64_js = require("base64-js");
|
|
143
|
-
var createDataUrl = (data, contextType, encoding = "base64") => {
|
|
151
|
+
var createDataUrl = /* @__PURE__ */ __name((data, contextType, encoding = "base64") => {
|
|
144
152
|
return `data:${contextType};${encoding},${(0, import_base64_js.fromByteArray)(new Uint8Array(data))}`;
|
|
145
|
-
};
|
|
153
|
+
}, "createDataUrl");
|
|
146
154
|
|
|
147
155
|
// src/Witness/lib/resolveDynamicSvg.ts
|
|
148
156
|
var import_axios = require("@xylabs/axios");
|
|
149
157
|
var import_base64_js2 = require("base64-js");
|
|
150
158
|
var import_xml2js = require("xml2js");
|
|
151
|
-
var resolveDynamicSvg = async (base64Bytes) => {
|
|
159
|
+
var resolveDynamicSvg = /* @__PURE__ */ __name(async (base64Bytes) => {
|
|
152
160
|
const decoder = new TextDecoder();
|
|
153
161
|
const bytes = (0, import_base64_js2.toByteArray)(base64Bytes);
|
|
154
162
|
const svg = decoder.decode(bytes);
|
|
@@ -164,24 +172,38 @@ var resolveDynamicSvg = async (base64Bytes) => {
|
|
|
164
172
|
])
|
|
165
173
|
);
|
|
166
174
|
const image = imageResults.map(([href, response]) => {
|
|
167
|
-
var
|
|
175
|
+
var _a2;
|
|
168
176
|
if (response.data) {
|
|
169
177
|
const sourceBuffer = Buffer.from(response.data, "binary");
|
|
170
|
-
return {
|
|
178
|
+
return {
|
|
179
|
+
$: {
|
|
180
|
+
href: `data:${(_a2 = response.headers["content-type"]) == null ? void 0 : _a2.toString()};base64,${sourceBuffer.toString("base64")}`
|
|
181
|
+
}
|
|
182
|
+
};
|
|
171
183
|
} else {
|
|
172
|
-
return {
|
|
184
|
+
return {
|
|
185
|
+
$: {
|
|
186
|
+
href
|
|
187
|
+
}
|
|
188
|
+
};
|
|
173
189
|
}
|
|
174
190
|
});
|
|
175
|
-
const updatedSVG = {
|
|
191
|
+
const updatedSVG = {
|
|
192
|
+
...svgObj,
|
|
193
|
+
svg: {
|
|
194
|
+
...svgNode,
|
|
195
|
+
image
|
|
196
|
+
}
|
|
197
|
+
};
|
|
176
198
|
const builder = new import_xml2js.Builder();
|
|
177
199
|
return builder.buildObject(updatedSVG);
|
|
178
|
-
};
|
|
200
|
+
}, "resolveDynamicSvg");
|
|
179
201
|
|
|
180
202
|
// src/Witness/Witness.ts
|
|
181
|
-
var gm = import_gm.default.subClass({
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
203
|
+
var gm = import_gm.default.subClass({
|
|
204
|
+
imageMagick: "7+"
|
|
205
|
+
});
|
|
206
|
+
var _ImageThumbnailWitness = class _ImageThumbnailWitness extends import_abstract_witness.AbstractWitness {
|
|
185
207
|
_semaphore = new import_async_mutex.Semaphore(this.maxAsyncProcesses);
|
|
186
208
|
get encoding() {
|
|
187
209
|
return this.config.encoding ?? "PNG";
|
|
@@ -233,50 +255,42 @@ var ImageThumbnailWitness = class _ImageThumbnailWitness extends import_abstract
|
|
|
233
255
|
throw new Error("ImageMagick is required for this witness");
|
|
234
256
|
}
|
|
235
257
|
const urlPayloads = payloads.filter((payload) => payload.schema === import_url_payload_plugin.UrlSchema);
|
|
236
|
-
const process = async () => {
|
|
237
|
-
return (0, import_lodash.compact)(
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
const newSvgDataUrl = createDataUrl(import_node_buffer.Buffer.from(newSvg), contentType);
|
|
259
|
-
cookedDataBuffer = _ImageThumbnailWitness.bufferFromDataUrl(newSvgDataUrl) ?? dataBuffer;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
result = await this.processMedia(
|
|
263
|
-
cookedDataBuffer,
|
|
264
|
-
{
|
|
265
|
-
schema: import_image_thumbnail_payload_plugin2.ImageThumbnailSchema,
|
|
266
|
-
sourceUrl: url
|
|
267
|
-
},
|
|
268
|
-
contentType
|
|
269
|
-
);
|
|
258
|
+
const process = /* @__PURE__ */ __name(async () => {
|
|
259
|
+
return (0, import_lodash.compact)(await Promise.all(urlPayloads.map(async ({ url }) => {
|
|
260
|
+
let result;
|
|
261
|
+
const dataBuffer = _ImageThumbnailWitness.bufferFromDataUrl(url);
|
|
262
|
+
if (dataBuffer) {
|
|
263
|
+
if (this.config.dataUrlPassthrough) {
|
|
264
|
+
result = {
|
|
265
|
+
schema: import_image_thumbnail_payload_plugin2.ImageThumbnailSchema,
|
|
266
|
+
sourceHash: await _ImageThumbnailWitness.binaryToSha256(dataBuffer),
|
|
267
|
+
sourceUrl: url,
|
|
268
|
+
url
|
|
269
|
+
};
|
|
270
|
+
} else {
|
|
271
|
+
let cookedDataBuffer = dataBuffer;
|
|
272
|
+
const urlParts = url.split(";");
|
|
273
|
+
const [, contentType] = urlParts[0].split(":");
|
|
274
|
+
if (contentType.startsWith("image/svg")) {
|
|
275
|
+
const [encoding, byteString] = urlParts[1].split(",");
|
|
276
|
+
if (encoding === "base64") {
|
|
277
|
+
const newSvg = await resolveDynamicSvg(byteString);
|
|
278
|
+
const newSvgDataUrl = createDataUrl(import_node_buffer.Buffer.from(newSvg), contentType);
|
|
279
|
+
cookedDataBuffer = _ImageThumbnailWitness.bufferFromDataUrl(newSvgDataUrl) ?? dataBuffer;
|
|
270
280
|
}
|
|
271
|
-
} else {
|
|
272
|
-
const mutatedUrl = checkIpfsUrl(url, this.ipfsGateway);
|
|
273
|
-
result = await this.fromHttp(mutatedUrl, url);
|
|
274
281
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
282
|
+
result = await this.processMedia(cookedDataBuffer, {
|
|
283
|
+
schema: import_image_thumbnail_payload_plugin2.ImageThumbnailSchema,
|
|
284
|
+
sourceUrl: url
|
|
285
|
+
}, contentType);
|
|
286
|
+
}
|
|
287
|
+
} else {
|
|
288
|
+
const mutatedUrl = checkIpfsUrl(url, this.ipfsGateway);
|
|
289
|
+
result = await this.fromHttp(mutatedUrl, url);
|
|
290
|
+
}
|
|
291
|
+
return result;
|
|
292
|
+
})));
|
|
293
|
+
}, "process");
|
|
280
294
|
return this.config.runExclusive ? await this._semaphore.runExclusive(() => process()) : process();
|
|
281
295
|
}
|
|
282
296
|
async createThumbnailDataUrl(sourceBuffer, encoding) {
|
|
@@ -292,17 +306,17 @@ var ImageThumbnailWitness = class _ImageThumbnailWitness extends import_abstract
|
|
|
292
306
|
return createDataUrl(thumb, "image/png");
|
|
293
307
|
}
|
|
294
308
|
/**
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
309
|
+
* Creates an image thumbnail from a video.
|
|
310
|
+
* @param videoBuffer The input video buffer.
|
|
311
|
+
* @returns An buffer containing an image thumbnail for the video.
|
|
312
|
+
*/
|
|
299
313
|
async createThumbnailFromVideo(videoBuffer) {
|
|
300
314
|
const imageBuffer = await getVideoFrameAsImageFluent(videoBuffer);
|
|
301
315
|
return this.createThumbnailDataUrl(imageBuffer);
|
|
302
316
|
}
|
|
303
317
|
// eslint-disable-next-line complexity
|
|
304
318
|
async fromHttp(url, sourceUrl) {
|
|
305
|
-
var
|
|
319
|
+
var _a2, _b, _c;
|
|
306
320
|
let response;
|
|
307
321
|
let dnsResult;
|
|
308
322
|
try {
|
|
@@ -333,7 +347,7 @@ var ImageThumbnailWitness = class _ImageThumbnailWitness extends import_abstract
|
|
|
333
347
|
schema: import_image_thumbnail_payload_plugin2.ImageThumbnailSchema,
|
|
334
348
|
sourceUrl: sourceUrl ?? url
|
|
335
349
|
};
|
|
336
|
-
if (((
|
|
350
|
+
if (((_a2 = axiosError == null ? void 0 : axiosError.response) == null ? void 0 : _a2.status) !== void 0) {
|
|
337
351
|
result2.http = result2.http ?? {};
|
|
338
352
|
result2.http.status = (_b = axiosError == null ? void 0 : axiosError.response) == null ? void 0 : _b.status;
|
|
339
353
|
}
|
|
@@ -361,21 +375,24 @@ var ImageThumbnailWitness = class _ImageThumbnailWitness extends import_abstract
|
|
|
361
375
|
return result;
|
|
362
376
|
}
|
|
363
377
|
async processMedia(sourceBuffer, imageThumbnail, contentType) {
|
|
364
|
-
var
|
|
365
|
-
const [mediaType, fileType] = (contentType == null ? void 0 : contentType.split("/")) ?? [
|
|
378
|
+
var _a2, _b, _c, _d, _e;
|
|
379
|
+
const [mediaType, fileType] = (contentType == null ? void 0 : contentType.split("/")) ?? [
|
|
380
|
+
"",
|
|
381
|
+
""
|
|
382
|
+
];
|
|
366
383
|
imageThumbnail.mime = imageThumbnail.mime ?? {};
|
|
367
384
|
imageThumbnail.mime.returned = mediaType;
|
|
368
385
|
try {
|
|
369
386
|
imageThumbnail.mime.detected = await import_file_type.default.fromBuffer(sourceBuffer);
|
|
370
387
|
} catch (ex) {
|
|
371
388
|
const error = ex;
|
|
372
|
-
(
|
|
389
|
+
(_a2 = this.logger) == null ? void 0 : _a2.error(`FileType error: ${error.message}`);
|
|
373
390
|
}
|
|
374
|
-
const processImage = async (encoding2) => {
|
|
391
|
+
const processImage = /* @__PURE__ */ __name(async (encoding2) => {
|
|
375
392
|
imageThumbnail.sourceHash = await _ImageThumbnailWitness.binaryToSha256(sourceBuffer);
|
|
376
393
|
imageThumbnail.url = await this.createThumbnailDataUrl(sourceBuffer, encoding2);
|
|
377
|
-
};
|
|
378
|
-
const processVideo = async () => {
|
|
394
|
+
}, "processImage");
|
|
395
|
+
const processVideo = /* @__PURE__ */ __name(async () => {
|
|
379
396
|
if (import_hasbin.default.sync("ffmpeg")) {
|
|
380
397
|
imageThumbnail.sourceHash = await _ImageThumbnailWitness.binaryToSha256(sourceBuffer);
|
|
381
398
|
imageThumbnail.url = await this.createThumbnailFromVideo(sourceBuffer);
|
|
@@ -383,7 +400,7 @@ var ImageThumbnailWitness = class _ImageThumbnailWitness extends import_abstract
|
|
|
383
400
|
imageThumbnail.mime = imageThumbnail.mime ?? {};
|
|
384
401
|
imageThumbnail.mime.invalid = true;
|
|
385
402
|
}
|
|
386
|
-
};
|
|
403
|
+
}, "processVideo");
|
|
387
404
|
let encoding = "PNG";
|
|
388
405
|
switch (fileType.toUpperCase()) {
|
|
389
406
|
case "GIF": {
|
|
@@ -408,7 +425,10 @@ var ImageThumbnailWitness = class _ImageThumbnailWitness extends import_abstract
|
|
|
408
425
|
break;
|
|
409
426
|
}
|
|
410
427
|
default: {
|
|
411
|
-
const [detectedMediaType] = ((_c = (_b = imageThumbnail.mime.detected) == null ? void 0 : _b.mime) == null ? void 0 : _c.split("/")) ?? [
|
|
428
|
+
const [detectedMediaType] = ((_c = (_b = imageThumbnail.mime.detected) == null ? void 0 : _b.mime) == null ? void 0 : _c.split("/")) ?? [
|
|
429
|
+
"",
|
|
430
|
+
""
|
|
431
|
+
];
|
|
412
432
|
switch (detectedMediaType) {
|
|
413
433
|
case "image": {
|
|
414
434
|
await processImage();
|
|
@@ -431,21 +451,30 @@ var ImageThumbnailWitness = class _ImageThumbnailWitness extends import_abstract
|
|
|
431
451
|
return imageThumbnail;
|
|
432
452
|
}
|
|
433
453
|
};
|
|
454
|
+
__name(_ImageThumbnailWitness, "ImageThumbnailWitness");
|
|
455
|
+
__publicField(_ImageThumbnailWitness, "configSchemas", [
|
|
456
|
+
...__superGet(_ImageThumbnailWitness, _ImageThumbnailWitness, "configSchemas"),
|
|
457
|
+
ImageThumbnailWitnessConfigSchema
|
|
458
|
+
]);
|
|
459
|
+
__publicField(_ImageThumbnailWitness, "defaultConfigSchema", ImageThumbnailWitnessConfigSchema);
|
|
460
|
+
var ImageThumbnailWitness = _ImageThumbnailWitness;
|
|
434
461
|
|
|
435
462
|
// src/Plugin.ts
|
|
436
|
-
var ImageThumbnailPlugin = () => (0, import_payloadset_plugin.createPayloadSetDualPlugin)(
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
463
|
+
var ImageThumbnailPlugin = /* @__PURE__ */ __name(() => (0, import_payloadset_plugin.createPayloadSetDualPlugin)({
|
|
464
|
+
required: {
|
|
465
|
+
[import_image_thumbnail_payload_plugin3.ImageThumbnailSchema]: 1
|
|
466
|
+
},
|
|
467
|
+
schema: import_payload_model.PayloadSetSchema
|
|
468
|
+
}, {
|
|
469
|
+
diviner: /* @__PURE__ */ __name(async (params) => {
|
|
470
|
+
const result = await import_diviner_image_thumbnail.ImageThumbnailDiviner.create(params);
|
|
471
|
+
return result;
|
|
472
|
+
}, "diviner"),
|
|
473
|
+
witness: /* @__PURE__ */ __name(async (params) => {
|
|
474
|
+
const result = await ImageThumbnailWitness.create(params);
|
|
475
|
+
return result;
|
|
476
|
+
}, "witness")
|
|
477
|
+
}), "ImageThumbnailPlugin");
|
|
449
478
|
|
|
450
479
|
// src/index.ts
|
|
451
480
|
__reExport(src_exports, require("@xyo-network/diviner-image-thumbnail"), module.exports);
|