apexify.js 4.7.95 → 4.8.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/cjs/ai/ApexAI.d.ts.map +1 -1
- package/dist/cjs/ai/ApexAI.js +42 -23
- package/dist/cjs/ai/ApexAI.js.map +1 -1
- package/dist/cjs/ai/ApexModules.d.ts.map +1 -1
- package/dist/cjs/ai/ApexModules.js +35 -21
- package/dist/cjs/ai/ApexModules.js.map +1 -1
- package/dist/cjs/ai/buttons/tools.js +8 -8
- package/dist/cjs/ai/buttons/tools.js.map +1 -1
- package/dist/cjs/ai/functions/tokenizer.d.ts +10 -0
- package/dist/cjs/ai/functions/tokenizer.d.ts.map +1 -0
- package/dist/cjs/ai/functions/tokenizer.js +64 -0
- package/dist/cjs/ai/functions/tokenizer.js.map +1 -0
- package/dist/cjs/ai/modals/electronHub/chatmodels.d.ts.map +1 -0
- package/dist/cjs/ai/{modals-chat → modals}/electronHub/chatmodels.js +8 -11
- package/dist/cjs/ai/modals/electronHub/chatmodels.js.map +1 -0
- package/dist/cjs/ai/modals/electronHub/imageModels.d.ts.map +1 -0
- package/dist/cjs/ai/{modals-chat → modals}/electronHub/imageModels.js +9 -5
- package/dist/cjs/ai/modals/electronHub/imageModels.js.map +1 -0
- package/dist/cjs/ai/modals/electronHub/songModels.d.ts.map +1 -0
- package/dist/cjs/ai/modals/electronHub/songModels.js.map +1 -0
- package/dist/cjs/ai/modals/electronHub/speechModels.d.ts.map +1 -0
- package/dist/cjs/ai/{modals-chat → modals}/electronHub/speechModels.js +4 -1
- package/dist/cjs/ai/modals/electronHub/speechModels.js.map +1 -0
- package/dist/cjs/ai/modals/electronHub/videoModels.d.ts.map +1 -0
- package/dist/cjs/ai/modals/electronHub/videoModels.js.map +1 -0
- package/dist/cjs/ai/modals/groq/chatgroq.d.ts.map +1 -0
- package/dist/cjs/ai/modals/groq/chatgroq.js.map +1 -0
- package/dist/cjs/ai/modals/groq/imageAnalyzer.d.ts.map +1 -0
- package/dist/cjs/ai/modals/groq/imageAnalyzer.js.map +1 -0
- package/dist/cjs/ai/modals/groq/whisper.d.ts.map +1 -0
- package/dist/cjs/ai/{modals-chat → modals}/groq/whisper.js +34 -33
- package/dist/cjs/ai/modals/groq/whisper.js.map +1 -0
- package/dist/cjs/ai/modals/hercai/chatModels.d.ts.map +1 -0
- package/dist/cjs/ai/modals/hercai/chatModels.js.map +1 -0
- package/dist/cjs/ai/utils.d.ts +1 -1
- package/dist/cjs/ai/utils.d.ts.map +1 -1
- package/dist/cjs/ai/utils.js +1 -1
- package/dist/cjs/ai/utils.js.map +1 -1
- package/dist/cjs/canvas/ApexPainter.d.ts +20 -15
- package/dist/cjs/canvas/ApexPainter.d.ts.map +1 -1
- package/dist/cjs/canvas/ApexPainter.js +143 -23
- package/dist/cjs/canvas/ApexPainter.js.map +1 -1
- package/dist/cjs/canvas/utils/Image/imageProperties.d.ts.map +1 -1
- package/dist/cjs/canvas/utils/Image/imageProperties.js +47 -24
- package/dist/cjs/canvas/utils/Image/imageProperties.js.map +1 -1
- package/dist/cjs/canvas/utils/types.d.ts +21 -12
- package/dist/cjs/canvas/utils/types.d.ts.map +1 -1
- package/dist/cjs/canvas/utils/types.js.map +1 -1
- package/dist/cjs/canvas/utils/utils.d.ts +2 -2
- package/dist/cjs/canvas/utils/utils.d.ts.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/ai/ApexAI.d.ts.map +1 -1
- package/dist/esm/ai/ApexAI.js +42 -23
- package/dist/esm/ai/ApexAI.js.map +1 -1
- package/dist/esm/ai/ApexModules.d.ts.map +1 -1
- package/dist/esm/ai/ApexModules.js +35 -21
- package/dist/esm/ai/ApexModules.js.map +1 -1
- package/dist/esm/ai/buttons/tools.js +8 -8
- package/dist/esm/ai/buttons/tools.js.map +1 -1
- package/dist/esm/ai/functions/tokenizer.d.ts +10 -0
- package/dist/esm/ai/functions/tokenizer.d.ts.map +1 -0
- package/dist/esm/ai/functions/tokenizer.js +64 -0
- package/dist/esm/ai/functions/tokenizer.js.map +1 -0
- package/dist/esm/ai/modals/electronHub/chatmodels.d.ts.map +1 -0
- package/dist/esm/ai/{modals-chat → modals}/electronHub/chatmodels.js +8 -11
- package/dist/esm/ai/modals/electronHub/chatmodels.js.map +1 -0
- package/dist/esm/ai/modals/electronHub/imageModels.d.ts.map +1 -0
- package/dist/esm/ai/{modals-chat → modals}/electronHub/imageModels.js +9 -5
- package/dist/esm/ai/modals/electronHub/imageModels.js.map +1 -0
- package/dist/esm/ai/modals/electronHub/songModels.d.ts.map +1 -0
- package/dist/esm/ai/modals/electronHub/songModels.js.map +1 -0
- package/dist/esm/ai/modals/electronHub/speechModels.d.ts.map +1 -0
- package/dist/esm/ai/{modals-chat → modals}/electronHub/speechModels.js +4 -1
- package/dist/esm/ai/modals/electronHub/speechModels.js.map +1 -0
- package/dist/esm/ai/modals/electronHub/videoModels.d.ts.map +1 -0
- package/dist/esm/ai/modals/electronHub/videoModels.js.map +1 -0
- package/dist/esm/ai/modals/groq/chatgroq.d.ts.map +1 -0
- package/dist/esm/ai/modals/groq/chatgroq.js.map +1 -0
- package/dist/esm/ai/modals/groq/imageAnalyzer.d.ts.map +1 -0
- package/dist/esm/ai/modals/groq/imageAnalyzer.js.map +1 -0
- package/dist/esm/ai/modals/groq/whisper.d.ts.map +1 -0
- package/dist/esm/ai/{modals-chat → modals}/groq/whisper.js +34 -33
- package/dist/esm/ai/modals/groq/whisper.js.map +1 -0
- package/dist/esm/ai/modals/hercai/chatModels.d.ts.map +1 -0
- package/dist/esm/ai/modals/hercai/chatModels.js.map +1 -0
- package/dist/esm/ai/utils.d.ts +1 -1
- package/dist/esm/ai/utils.d.ts.map +1 -1
- package/dist/esm/ai/utils.js +1 -1
- package/dist/esm/ai/utils.js.map +1 -1
- package/dist/esm/canvas/ApexPainter.d.ts +20 -15
- package/dist/esm/canvas/ApexPainter.d.ts.map +1 -1
- package/dist/esm/canvas/ApexPainter.js +143 -23
- package/dist/esm/canvas/ApexPainter.js.map +1 -1
- package/dist/esm/canvas/utils/Image/imageProperties.d.ts.map +1 -1
- package/dist/esm/canvas/utils/Image/imageProperties.js +47 -24
- package/dist/esm/canvas/utils/Image/imageProperties.js.map +1 -1
- package/dist/esm/canvas/utils/types.d.ts +21 -12
- package/dist/esm/canvas/utils/types.d.ts.map +1 -1
- package/dist/esm/canvas/utils/types.js.map +1 -1
- package/dist/esm/canvas/utils/utils.d.ts +2 -2
- package/dist/esm/canvas/utils/utils.d.ts.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/ai/ApexAI.ts +69 -48
- package/lib/ai/ApexModules.ts +45 -33
- package/lib/ai/buttons/tools.ts +8 -8
- package/lib/ai/functions/tokenizer.ts +69 -0
- package/lib/ai/modals/electronHub/chatmodels.ts +57 -0
- package/lib/ai/{modals-chat → modals}/electronHub/imageModels.ts +17 -13
- package/lib/ai/{modals-chat → modals}/electronHub/speechModels.ts +5 -1
- package/lib/ai/modals/groq/whisper.ts +114 -0
- package/lib/ai/utils.ts +1 -1
- package/lib/canvas/ApexPainter.ts +214 -45
- package/lib/canvas/utils/Image/imageProperties.ts +67 -24
- package/lib/canvas/utils/types.ts +22 -14
- package/lib/canvas/utils/utils.ts +4 -2
- package/package.json +2 -2
- package/dist/cjs/ai/modals-chat/electronHub/chatmodels.d.ts.map +0 -1
- package/dist/cjs/ai/modals-chat/electronHub/chatmodels.js.map +0 -1
- package/dist/cjs/ai/modals-chat/electronHub/imageModels.d.ts.map +0 -1
- package/dist/cjs/ai/modals-chat/electronHub/imageModels.js.map +0 -1
- package/dist/cjs/ai/modals-chat/electronHub/songModels.d.ts.map +0 -1
- package/dist/cjs/ai/modals-chat/electronHub/songModels.js.map +0 -1
- package/dist/cjs/ai/modals-chat/electronHub/speechModels.d.ts.map +0 -1
- package/dist/cjs/ai/modals-chat/electronHub/speechModels.js.map +0 -1
- package/dist/cjs/ai/modals-chat/electronHub/videoModels.d.ts.map +0 -1
- package/dist/cjs/ai/modals-chat/electronHub/videoModels.js.map +0 -1
- package/dist/cjs/ai/modals-chat/groq/chatgroq.d.ts.map +0 -1
- package/dist/cjs/ai/modals-chat/groq/chatgroq.js.map +0 -1
- package/dist/cjs/ai/modals-chat/groq/imageAnalyzer.d.ts.map +0 -1
- package/dist/cjs/ai/modals-chat/groq/imageAnalyzer.js.map +0 -1
- package/dist/cjs/ai/modals-chat/groq/whisper.d.ts.map +0 -1
- package/dist/cjs/ai/modals-chat/groq/whisper.js.map +0 -1
- package/dist/cjs/ai/modals-chat/hercai/chatModels.d.ts.map +0 -1
- package/dist/cjs/ai/modals-chat/hercai/chatModels.js.map +0 -1
- package/dist/esm/ai/modals-chat/electronHub/chatmodels.d.ts.map +0 -1
- package/dist/esm/ai/modals-chat/electronHub/chatmodels.js.map +0 -1
- package/dist/esm/ai/modals-chat/electronHub/imageModels.d.ts.map +0 -1
- package/dist/esm/ai/modals-chat/electronHub/imageModels.js.map +0 -1
- package/dist/esm/ai/modals-chat/electronHub/songModels.d.ts.map +0 -1
- package/dist/esm/ai/modals-chat/electronHub/songModels.js.map +0 -1
- package/dist/esm/ai/modals-chat/electronHub/speechModels.d.ts.map +0 -1
- package/dist/esm/ai/modals-chat/electronHub/speechModels.js.map +0 -1
- package/dist/esm/ai/modals-chat/electronHub/videoModels.d.ts.map +0 -1
- package/dist/esm/ai/modals-chat/electronHub/videoModels.js.map +0 -1
- package/dist/esm/ai/modals-chat/groq/chatgroq.d.ts.map +0 -1
- package/dist/esm/ai/modals-chat/groq/chatgroq.js.map +0 -1
- package/dist/esm/ai/modals-chat/groq/imageAnalyzer.d.ts.map +0 -1
- package/dist/esm/ai/modals-chat/groq/imageAnalyzer.js.map +0 -1
- package/dist/esm/ai/modals-chat/groq/whisper.d.ts.map +0 -1
- package/dist/esm/ai/modals-chat/groq/whisper.js.map +0 -1
- package/dist/esm/ai/modals-chat/hercai/chatModels.d.ts.map +0 -1
- package/dist/esm/ai/modals-chat/hercai/chatModels.js.map +0 -1
- package/lib/ai/modals-chat/electronHub/chatmodels.ts +0 -64
- package/lib/ai/modals-chat/groq/whisper.ts +0 -113
- /package/dist/cjs/ai/{modals-chat → modals}/electronHub/chatmodels.d.ts +0 -0
- /package/dist/cjs/ai/{modals-chat → modals}/electronHub/imageModels.d.ts +0 -0
- /package/dist/cjs/ai/{modals-chat → modals}/electronHub/songModels.d.ts +0 -0
- /package/dist/cjs/ai/{modals-chat → modals}/electronHub/songModels.js +0 -0
- /package/dist/cjs/ai/{modals-chat → modals}/electronHub/speechModels.d.ts +0 -0
- /package/dist/cjs/ai/{modals-chat → modals}/electronHub/videoModels.d.ts +0 -0
- /package/dist/cjs/ai/{modals-chat → modals}/electronHub/videoModels.js +0 -0
- /package/dist/cjs/ai/{modals-chat → modals}/groq/chatgroq.d.ts +0 -0
- /package/dist/cjs/ai/{modals-chat → modals}/groq/chatgroq.js +0 -0
- /package/dist/cjs/ai/{modals-chat → modals}/groq/imageAnalyzer.d.ts +0 -0
- /package/dist/cjs/ai/{modals-chat → modals}/groq/imageAnalyzer.js +0 -0
- /package/dist/cjs/ai/{modals-chat → modals}/groq/whisper.d.ts +0 -0
- /package/dist/cjs/ai/{modals-chat → modals}/hercai/chatModels.d.ts +0 -0
- /package/dist/cjs/ai/{modals-chat → modals}/hercai/chatModels.js +0 -0
- /package/dist/esm/ai/{modals-chat → modals}/electronHub/chatmodels.d.ts +0 -0
- /package/dist/esm/ai/{modals-chat → modals}/electronHub/imageModels.d.ts +0 -0
- /package/dist/esm/ai/{modals-chat → modals}/electronHub/songModels.d.ts +0 -0
- /package/dist/esm/ai/{modals-chat → modals}/electronHub/songModels.js +0 -0
- /package/dist/esm/ai/{modals-chat → modals}/electronHub/speechModels.d.ts +0 -0
- /package/dist/esm/ai/{modals-chat → modals}/electronHub/videoModels.d.ts +0 -0
- /package/dist/esm/ai/{modals-chat → modals}/electronHub/videoModels.js +0 -0
- /package/dist/esm/ai/{modals-chat → modals}/groq/chatgroq.d.ts +0 -0
- /package/dist/esm/ai/{modals-chat → modals}/groq/chatgroq.js +0 -0
- /package/dist/esm/ai/{modals-chat → modals}/groq/imageAnalyzer.d.ts +0 -0
- /package/dist/esm/ai/{modals-chat → modals}/groq/imageAnalyzer.js +0 -0
- /package/dist/esm/ai/{modals-chat → modals}/groq/whisper.d.ts +0 -0
- /package/dist/esm/ai/{modals-chat → modals}/hercai/chatModels.d.ts +0 -0
- /package/dist/esm/ai/{modals-chat → modals}/hercai/chatModels.js +0 -0
- /package/lib/ai/{modals-chat → modals}/electronHub/songModels.ts +0 -0
- /package/lib/ai/{modals-chat → modals}/electronHub/videoModels.ts +0 -0
- /package/lib/ai/{modals-chat → modals}/groq/chatgroq.ts +0 -0
- /package/lib/ai/{modals-chat → modals}/groq/imageAnalyzer.ts +0 -0
- /package/lib/ai/{modals-chat → modals}/hercai/chatModels.ts +0 -0
|
@@ -13,15 +13,14 @@ const https_1 = __importDefault(require("https"));
|
|
|
13
13
|
* Gets the file size of a given path.
|
|
14
14
|
*/
|
|
15
15
|
function getFileSize(filePath) {
|
|
16
|
-
|
|
17
|
-
return stats.size;
|
|
16
|
+
return fs_1.default.statSync(filePath).size;
|
|
18
17
|
}
|
|
19
18
|
/**
|
|
20
19
|
* Creates a readable stream from a local file or a remote URL.
|
|
21
20
|
*/
|
|
22
21
|
async function createReadableStream(filepathOrUrl) {
|
|
23
|
-
const maxFileSizeBytes = 25 * 1024 * 1024;
|
|
24
|
-
if (filepathOrUrl.startsWith(
|
|
22
|
+
const maxFileSizeBytes = 25 * 1024 * 1024; // 25MB limit
|
|
23
|
+
if (filepathOrUrl.startsWith("http")) {
|
|
25
24
|
const parsedUrl = new url_1.URL(filepathOrUrl);
|
|
26
25
|
const fileExtension = path_1.default.extname(parsedUrl.pathname);
|
|
27
26
|
const tempFilePath = `temp-file-${Date.now()}${fileExtension}`;
|
|
@@ -29,38 +28,31 @@ async function createReadableStream(filepathOrUrl) {
|
|
|
29
28
|
const file = fs_1.default.createWriteStream(tempFilePath);
|
|
30
29
|
const request = https_1.default.get(filepathOrUrl, (response) => {
|
|
31
30
|
let fileSize = 0;
|
|
32
|
-
response.on(
|
|
31
|
+
response.on("data", (chunk) => {
|
|
33
32
|
fileSize += chunk.length;
|
|
34
33
|
if (fileSize > maxFileSizeBytes) {
|
|
35
|
-
request.destroy();
|
|
34
|
+
request.destroy();
|
|
36
35
|
file.close();
|
|
37
|
-
fs_1.default.unlink(tempFilePath, () => {
|
|
38
|
-
|
|
39
|
-
});
|
|
40
|
-
return; // Ensure function stops here
|
|
36
|
+
fs_1.default.unlink(tempFilePath, () => resolve({ stream: null, error: "File size exceeds the limit (25MB)" }));
|
|
37
|
+
return;
|
|
41
38
|
}
|
|
42
39
|
});
|
|
43
40
|
response.pipe(file);
|
|
44
|
-
file.on(
|
|
45
|
-
file.close(
|
|
46
|
-
|
|
47
|
-
resolve(fs_1.default.createReadStream(tempFilePath));
|
|
48
|
-
}
|
|
49
|
-
});
|
|
41
|
+
file.on("finish", () => {
|
|
42
|
+
file.close();
|
|
43
|
+
resolve({ stream: fs_1.default.createReadStream(tempFilePath), tempFilePath }); // ✅ Ensure fs.ReadStream
|
|
50
44
|
});
|
|
51
45
|
});
|
|
52
|
-
request.on(
|
|
53
|
-
fs_1.default.unlink(tempFilePath, () =>
|
|
54
|
-
reject(err);
|
|
55
|
-
});
|
|
46
|
+
request.on("error", (err) => {
|
|
47
|
+
fs_1.default.unlink(tempFilePath, () => reject(err));
|
|
56
48
|
});
|
|
57
49
|
});
|
|
58
50
|
}
|
|
59
51
|
else {
|
|
60
52
|
if (getFileSize(filepathOrUrl) > maxFileSizeBytes) {
|
|
61
|
-
return
|
|
53
|
+
return { stream: null, error: "File size exceeds the limit (25MB)" };
|
|
62
54
|
}
|
|
63
|
-
return fs_1.default.createReadStream(filepathOrUrl);
|
|
55
|
+
return { stream: fs_1.default.createReadStream(filepathOrUrl) }; // ✅ Ensure fs.ReadStream
|
|
64
56
|
}
|
|
65
57
|
}
|
|
66
58
|
/**
|
|
@@ -72,36 +64,45 @@ async function whisper(prompt, filepath, lang, API_KEY) {
|
|
|
72
64
|
apiKey: API_KEY || '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',
|
|
73
65
|
});
|
|
74
66
|
// Ensure filepath is properly resolved
|
|
75
|
-
const resolvedFilePath = filepath.startsWith(
|
|
67
|
+
const resolvedFilePath = filepath.startsWith("http") || path_1.default.isAbsolute(filepath)
|
|
76
68
|
? filepath
|
|
77
69
|
: path_1.default.join(process.cwd(), filepath);
|
|
78
|
-
const fileStream = await createReadableStream(resolvedFilePath);
|
|
79
|
-
if (
|
|
80
|
-
return
|
|
81
|
-
|
|
70
|
+
const { stream: fileStream, tempFilePath, error } = await createReadableStream(resolvedFilePath);
|
|
71
|
+
if (error)
|
|
72
|
+
return error;
|
|
73
|
+
if (!fileStream)
|
|
74
|
+
return "Failed to create a readable file stream.";
|
|
75
|
+
// ✅ Ensure `fileStream` is a valid `fs.ReadStream`
|
|
82
76
|
const transcription = await groq.audio.transcriptions.create({
|
|
83
|
-
file: fileStream,
|
|
77
|
+
file: fileStream, // ✅ Ensure correct type
|
|
84
78
|
model: "whisper-large-v3-turbo",
|
|
85
79
|
prompt: prompt,
|
|
86
80
|
temperature: 1,
|
|
87
|
-
language: lang ||
|
|
81
|
+
language: lang || "eng",
|
|
88
82
|
response_format: "verbose_json",
|
|
89
83
|
});
|
|
84
|
+
// ✅ Delete the temp file if it was downloaded from a URL
|
|
85
|
+
if (tempFilePath && fs_1.default.existsSync(tempFilePath)) {
|
|
86
|
+
fs_1.default.unlinkSync(tempFilePath);
|
|
87
|
+
}
|
|
90
88
|
return transcription.text;
|
|
91
89
|
}
|
|
92
90
|
catch (err) {
|
|
93
91
|
if (err?.status) {
|
|
94
92
|
switch (err.status) {
|
|
95
|
-
case 400:
|
|
96
|
-
|
|
97
|
-
case
|
|
93
|
+
case 400:
|
|
94
|
+
return "Bad request, try again after a minute.";
|
|
95
|
+
case 429:
|
|
96
|
+
return "Rate limit exceeded, try again later or provide your own API key.";
|
|
97
|
+
case 401:
|
|
98
|
+
return "Invalid API key provided.";
|
|
98
99
|
default:
|
|
99
100
|
console.error(err);
|
|
100
101
|
return "An unknown error occurred.";
|
|
101
102
|
}
|
|
102
103
|
}
|
|
103
104
|
console.error(err);
|
|
104
|
-
return
|
|
105
|
+
return "An unknown error occurred.";
|
|
105
106
|
}
|
|
106
107
|
}
|
|
107
108
|
//# sourceMappingURL=whisper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whisper.js","sourceRoot":"","sources":["../../../../../lib/ai/modals/groq/whisper.ts"],"names":[],"mappings":";;;;;AA6DA,0BAoDC;AAjHD,wDAA4B;AAC5B,4CAAoB;AACpB,gDAAwB;AACxB,6BAA0B;AAC1B,kDAA0B;AAE1B;;GAEG;AACH,SAAS,WAAW,CAAC,QAAgB;IACjC,OAAO,YAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,KAAK,UAAU,oBAAoB,CAAC,aAAqB;IACrD,MAAM,gBAAgB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,aAAa;IAExD,IAAI,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QACnC,MAAM,SAAS,GAAG,IAAI,SAAG,CAAC,aAAa,CAAC,CAAC;QACzC,MAAM,aAAa,GAAG,cAAI,CAAC,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QACvD,MAAM,YAAY,GAAG,aAAa,IAAI,CAAC,GAAG,EAAE,GAAG,aAAa,EAAE,CAAC;QAE/D,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACnC,MAAM,IAAI,GAAG,YAAE,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC;YAChD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aAAa,CAAC,IAAI,CAAC;IAC9B,CAAC;IAAC,OAAO,GAAQ,EAAE,CAAC;QAChB,IAAI,GAAG,EAAE,MAAM,EAAE,CAAC;YACd,QAAQ,GAAG,CAAC,MAAM,EAAE,CAAC;gBACjB,KAAK,GAAG;oBACJ,OAAO,wCAAwC,CAAC;gBACpD,KAAK,GAAG;oBACJ,OAAO,mEAAmE,CAAC;gBAC/E,KAAK,GAAG;oBACJ,OAAO,2BAA2B,CAAC;gBACvC;oBACI,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;oBACnB,OAAO,4BAA4B,CAAC;YAC5C,CAAC;QACL,CAAC;QACD,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnB,OAAO,4BAA4B,CAAC;IACxC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chatModels.d.ts","sourceRoot":"","sources":["../../../../../lib/ai/modals/hercai/chatModels.ts"],"names":[],"mappings":"AAEA,KAAK,YAAY,GAAG,IAAI,GAAG,QAAQ,GAAG,OAAO,GAAG,WAAW,GAAG,QAAQ,GAAG,YAAY,GAAG,WAAW,GAAG,cAAc,GAAG,UAAU,GAAG,WAAW,CAAA;AAE/I,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAA;CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAevJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chatModels.js","sourceRoot":"","sources":["../../../../../lib/ai/modals/hercai/chatModels.ts"],"names":[],"mappings":";;AAIA,gCAeC;AAnBD,mCAAgC;AAChC,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC,6CAA6C,CAAC,CAAC;AAGlE,KAAK,UAAU,UAAU,CAAC,MAAc,EAAE,KAAmB,EAAE,YAAqB,EAAE,MAAyC;IAClI,IAAI,CAAC;QAED,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,EAAE,EAAE,CAAC;YACvC,OAAO,CAAC,MAAM,MAAM,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;QACnF,CAAC;aAAM,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAE9I,OAAO,CAAC,MAAM,MAAM,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;QAChG,CAAC;aAAM,CAAC;YACJ,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;QAC3C,CAAC;IACL,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QACd,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QACzB,OAAO,kCAAkC,CAAC;IAC9C,CAAC;AACL,CAAC"}
|
package/dist/esm/ai/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFile } from "./functions/readFiles";
|
|
2
2
|
import { ApexChat, ApexImagine, ApexListener, ApexVideo, ApexText2Speech, resetHistory } from "./ApexModules";
|
|
3
3
|
import { typeWriter } from "./functions/typeWriter";
|
|
4
|
-
import { groqAnalyzer } from "./modals
|
|
4
|
+
import { groqAnalyzer } from "./modals/groq/imageAnalyzer";
|
|
5
5
|
export { readFile, ApexChat, ApexImagine, ApexListener, typeWriter, groqAnalyzer, ApexVideo, ApexText2Speech, resetHistory };
|
|
6
6
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../lib/ai/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC9G,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAE;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../lib/ai/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC9G,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAE;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAG3D,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,SAAS,EACT,eAAe,EACf,YAAY,EACb,CAAC"}
|
package/dist/esm/ai/utils.js
CHANGED
|
@@ -12,6 +12,6 @@ Object.defineProperty(exports, "ApexText2Speech", { enumerable: true, get: funct
|
|
|
12
12
|
Object.defineProperty(exports, "resetHistory", { enumerable: true, get: function () { return ApexModules_1.resetHistory; } });
|
|
13
13
|
const typeWriter_1 = require("./functions/typeWriter");
|
|
14
14
|
Object.defineProperty(exports, "typeWriter", { enumerable: true, get: function () { return typeWriter_1.typeWriter; } });
|
|
15
|
-
const imageAnalyzer_1 = require("./modals
|
|
15
|
+
const imageAnalyzer_1 = require("./modals/groq/imageAnalyzer");
|
|
16
16
|
Object.defineProperty(exports, "groqAnalyzer", { enumerable: true, get: function () { return imageAnalyzer_1.groqAnalyzer; } });
|
|
17
17
|
//# sourceMappingURL=utils.js.map
|
package/dist/esm/ai/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../lib/ai/utils.ts"],"names":[],"mappings":";;;AAAA,qDAAiD;AAO/C,yFAPO,oBAAQ,OAOP;AANV,+CAA8G;AAO5G,yFAPO,sBAAQ,OAOP;AACR,4FARiB,yBAAW,OAQjB;AACX,6FAT8B,0BAAY,OAS9B;AAGZ,0FAZ4C,uBAAS,OAY5C;AACT,gGAbuD,6BAAe,OAavD;AACf,6FAdwE,0BAAY,OAcxE;AAbd,uDAAqD;AASnD,2FATO,uBAAU,OASP;AARZ
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../lib/ai/utils.ts"],"names":[],"mappings":";;;AAAA,qDAAiD;AAO/C,yFAPO,oBAAQ,OAOP;AANV,+CAA8G;AAO5G,yFAPO,sBAAQ,OAOP;AACR,4FARiB,yBAAW,OAQjB;AACX,6FAT8B,0BAAY,OAS9B;AAGZ,0FAZ4C,uBAAS,OAY5C;AACT,gGAbuD,6BAAe,OAavD;AACf,6FAdwE,0BAAY,OAcxE;AAbd,uDAAqD;AASnD,2FATO,uBAAU,OASP;AARZ,+DAA2D;AASzD,6FATO,4BAAY,OASP"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { OutputFormat, CanvasConfig, TextObject, ImageProperties, GIFOptions, GIFResults, CustomOptions, cropOptions,
|
|
1
|
+
import { PathLike } from "fs";
|
|
2
|
+
import { OutputFormat, CanvasConfig, TextObject, ImageProperties, GIFOptions, GIFResults, CustomOptions, cropOptions, Frame, PatternOptions, ExtractFramesOptions, ResizeOptions, MaskOptions, BlendOptions } from "./utils/utils";
|
|
3
3
|
interface CanvasResults {
|
|
4
4
|
buffer: Buffer;
|
|
5
5
|
canvas: CanvasConfig;
|
|
@@ -30,14 +30,14 @@ export declare class ApexPainter {
|
|
|
30
30
|
duration: number;
|
|
31
31
|
}[], options: GIFOptions): Promise<GIFResults | any>;
|
|
32
32
|
resize(resizeOptions: ResizeOptions): Promise<Buffer<ArrayBufferLike>>;
|
|
33
|
-
imgConverter(
|
|
34
|
-
|
|
35
|
-
colorsFilter(
|
|
36
|
-
colorAnalysis(
|
|
33
|
+
imgConverter(source: string, newExtension: string): Promise<Buffer<ArrayBufferLike>>;
|
|
34
|
+
effects(source: string, filters: any[]): Promise<Buffer<ArrayBufferLike>>;
|
|
35
|
+
colorsFilter(source: string, filterColor: any, opacity?: number): Promise<any>;
|
|
36
|
+
colorAnalysis(source: string): Promise<{
|
|
37
37
|
color: string;
|
|
38
38
|
frequency: string;
|
|
39
39
|
}[]>;
|
|
40
|
-
colorsRemover(
|
|
40
|
+
colorsRemover(source: string, colorToRemove: {
|
|
41
41
|
red: number;
|
|
42
42
|
green: number;
|
|
43
43
|
blue: number;
|
|
@@ -51,7 +51,7 @@ export declare class ApexPainter {
|
|
|
51
51
|
y: number;
|
|
52
52
|
};
|
|
53
53
|
opacity?: number;
|
|
54
|
-
}[], baseImageBuffer: Buffer): Promise<Buffer>;
|
|
54
|
+
}[], baseImageBuffer: Buffer, defaultBlendMode?: 'source-over' | 'source-in' | 'source-out' | 'source-atop' | 'destination-over' | 'destination-in' | 'destination-out' | 'destination-atop' | 'lighter' | 'copy' | 'xor' | 'multiply' | 'screen' | 'overlay' | 'darken' | 'lighten' | 'color-dodge' | 'color-burn' | 'hard-light' | 'soft-light' | 'difference' | 'exclusion' | 'hue' | 'saturation' | 'color' | 'luminosity'): Promise<Buffer>;
|
|
55
55
|
createChart(data: any, type: {
|
|
56
56
|
chartType: string;
|
|
57
57
|
chartNumber: number;
|
|
@@ -65,7 +65,7 @@ export declare class ApexPainter {
|
|
|
65
65
|
* @param {Object} options - Options to customize the pattern.
|
|
66
66
|
* @returns {Promise<Buffer>} - The adjusted image buffer.
|
|
67
67
|
*/
|
|
68
|
-
|
|
68
|
+
patterns(buffer: Buffer, options: PatternOptions): Promise<Buffer<ArrayBufferLike>>;
|
|
69
69
|
/**
|
|
70
70
|
* Fills the specified area with a gradient.
|
|
71
71
|
* @param ctx The rendering context of the canvas.
|
|
@@ -75,7 +75,7 @@ export declare class ApexPainter {
|
|
|
75
75
|
* @param x The x offset of the area.
|
|
76
76
|
* @param y The y offset of the area.
|
|
77
77
|
*/
|
|
78
|
-
fillWithGradient
|
|
78
|
+
private fillWithGradient;
|
|
79
79
|
/**
|
|
80
80
|
* Draws a dots pattern in the specified area.
|
|
81
81
|
* @param ctx The rendering context of the canvas.
|
|
@@ -85,7 +85,7 @@ export declare class ApexPainter {
|
|
|
85
85
|
* @param x The x offset of the area.
|
|
86
86
|
* @param y The y offset of the area.
|
|
87
87
|
*/
|
|
88
|
-
drawDotsPattern
|
|
88
|
+
private drawDotsPattern;
|
|
89
89
|
/**
|
|
90
90
|
* Draws a stripes pattern in the specified area.
|
|
91
91
|
* @param ctx The rendering context of the canvas.
|
|
@@ -95,7 +95,7 @@ export declare class ApexPainter {
|
|
|
95
95
|
* @param x The x offset of the area.
|
|
96
96
|
* @param y The y offset of the area.
|
|
97
97
|
*/
|
|
98
|
-
drawStripesPattern
|
|
98
|
+
private drawStripesPattern;
|
|
99
99
|
/**
|
|
100
100
|
* Draws a grid pattern in the specified area.
|
|
101
101
|
* @param ctx The rendering context of the canvas.
|
|
@@ -105,7 +105,7 @@ export declare class ApexPainter {
|
|
|
105
105
|
* @param x The x offset of the area.
|
|
106
106
|
* @param y The y offset of the area.
|
|
107
107
|
*/
|
|
108
|
-
drawGridPattern
|
|
108
|
+
private drawGridPattern;
|
|
109
109
|
/**
|
|
110
110
|
* Draws a checkerboard pattern in the specified area.
|
|
111
111
|
* @param ctx The rendering context of the canvas.
|
|
@@ -115,7 +115,7 @@ export declare class ApexPainter {
|
|
|
115
115
|
* @param x The x offset of the area.
|
|
116
116
|
* @param y The y offset of the area.
|
|
117
117
|
*/
|
|
118
|
-
drawCheckerboardPattern
|
|
118
|
+
private drawCheckerboardPattern;
|
|
119
119
|
/**
|
|
120
120
|
* Draws a custom image pattern in the specified area.
|
|
121
121
|
* @param ctx The rendering context of the canvas.
|
|
@@ -125,7 +125,12 @@ export declare class ApexPainter {
|
|
|
125
125
|
* @param x The x offset of the area.
|
|
126
126
|
* @param y The y offset of the area.
|
|
127
127
|
*/
|
|
128
|
-
drawCustomPattern
|
|
128
|
+
private drawCustomPattern;
|
|
129
|
+
private drawWavePattern;
|
|
130
|
+
private drawNoisePattern;
|
|
131
|
+
private drawDiagonalCheckerboardPattern;
|
|
132
|
+
masking(source: string | Buffer | PathLike | Uint8Array, maskSource: string | Buffer | PathLike | Uint8Array, options?: MaskOptions): Promise<Buffer>;
|
|
133
|
+
gradientBlend(source: string | Buffer | PathLike | Uint8Array, options: BlendOptions): Promise<Buffer>;
|
|
129
134
|
animate(frames: Frame[], defaultDuration: number, defaultWidth?: number, defaultHeight?: number, options?: {
|
|
130
135
|
gif?: boolean;
|
|
131
136
|
gifPath?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApexPainter.d.ts","sourceRoot":"","sources":["../../../lib/canvas/ApexPainter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ApexPainter.d.ts","sourceRoot":"","sources":["../../../lib/canvas/ApexPainter.ts"],"names":[],"mappings":"AAKA,OAAW,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAElC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,WAAW,EAGiB,KAAK,EACrI,cAAc,EAAE,oBAAoB,EAA+B,aAAa,EAAoB,WAAW,EAAE,YAAY,EAC7H,MAAM,eAAe,CAAC;AAEzB,UAAU,aAAa;IACrB,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AQvB,MAAM,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,CAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,iBAAiB,CAAC;CAoBxG"}
|
|
@@ -113,7 +113,6 @@ class ApexPainter {
|
|
|
113
113
|
if (mergedTextOptions.fontPath) {
|
|
114
114
|
canvas_1.GlobalFonts.registerFromPath(path_1.default.join(process.cwd(), mergedTextOptions.fontPath), (mergedTextOptions.fontName || 'customFont'));
|
|
115
115
|
}
|
|
116
|
-
const size = { width: existingImage.width, height: existingImage.height };
|
|
117
116
|
(0, utils_1.drawText)(ctx, mergedTextOptions);
|
|
118
117
|
}
|
|
119
118
|
return canvas.toBuffer("image/png");
|
|
@@ -261,29 +260,30 @@ class ApexPainter {
|
|
|
261
260
|
async resize(resizeOptions) {
|
|
262
261
|
return (0, utils_1.resizingImg)(resizeOptions);
|
|
263
262
|
}
|
|
264
|
-
async imgConverter(
|
|
265
|
-
return (0, utils_1.converter)(
|
|
263
|
+
async imgConverter(source, newExtension) {
|
|
264
|
+
return (0, utils_1.converter)(source, newExtension);
|
|
266
265
|
}
|
|
267
|
-
async
|
|
268
|
-
return (0, utils_1.imgEffects)(
|
|
266
|
+
async effects(source, filters) {
|
|
267
|
+
return (0, utils_1.imgEffects)(source, filters);
|
|
269
268
|
}
|
|
270
|
-
async colorsFilter(
|
|
271
|
-
return (0, utils_1.applyColorFilters)(
|
|
269
|
+
async colorsFilter(source, filterColor, opacity) {
|
|
270
|
+
return (0, utils_1.applyColorFilters)(source, filterColor, opacity);
|
|
272
271
|
}
|
|
273
|
-
async colorAnalysis(
|
|
274
|
-
return (0, utils_1.detectColors)(
|
|
272
|
+
async colorAnalysis(source) {
|
|
273
|
+
return (0, utils_1.detectColors)(source);
|
|
275
274
|
}
|
|
276
|
-
async colorsRemover(
|
|
277
|
-
return (0, utils_1.removeColor)(
|
|
275
|
+
async colorsRemover(source, colorToRemove) {
|
|
276
|
+
return (0, utils_1.removeColor)(source, colorToRemove);
|
|
278
277
|
}
|
|
279
278
|
async removeBackground(imageURL, apiKey) {
|
|
280
279
|
return (0, utils_1.bgRemoval)(imageURL, apiKey);
|
|
281
280
|
}
|
|
282
|
-
async blend(layers, baseImageBuffer) {
|
|
281
|
+
async blend(layers, baseImageBuffer, defaultBlendMode = 'source-over') {
|
|
283
282
|
try {
|
|
284
283
|
const baseImage = await (0, canvas_1.loadImage)(baseImageBuffer);
|
|
285
284
|
const canvas = (0, canvas_1.createCanvas)(baseImage.width, baseImage.height);
|
|
286
285
|
const ctx = canvas.getContext('2d');
|
|
286
|
+
ctx.globalCompositeOperation = defaultBlendMode;
|
|
287
287
|
ctx.drawImage(baseImage, 0, 0);
|
|
288
288
|
for (const layer of layers) {
|
|
289
289
|
const layerImage = await (0, canvas_1.loadImage)(layer.image);
|
|
@@ -292,7 +292,7 @@ class ApexPainter {
|
|
|
292
292
|
ctx.drawImage(layerImage, layer.position?.x || 0, layer.position?.y || 0);
|
|
293
293
|
}
|
|
294
294
|
ctx.globalAlpha = 1.0;
|
|
295
|
-
ctx.globalCompositeOperation =
|
|
295
|
+
ctx.globalCompositeOperation = defaultBlendMode; // Reset to user-defined default
|
|
296
296
|
return canvas.toBuffer('image/png');
|
|
297
297
|
}
|
|
298
298
|
catch (error) {
|
|
@@ -370,12 +370,8 @@ class ApexPainter {
|
|
|
370
370
|
}
|
|
371
371
|
const shapeNames = ['circle', 'square', 'triangle', 'pentagon', 'hexagon', 'heptagon', 'octagon', 'star', 'kite', 'arrow', 'star', 'oval', 'heart', 'diamond', 'trapezoid', 'cloud'];
|
|
372
372
|
const isShape = shapeNames.includes(source.toLowerCase());
|
|
373
|
-
if (opacity !== undefined) {
|
|
374
|
-
ctx.globalAlpha = opacity;
|
|
375
|
-
}
|
|
376
373
|
if (isShape) {
|
|
377
|
-
(0, utils_1.drawShape)(ctx, { source, x, y, width, height, rotation, borderRadius, stroke, shadow, isFilled, color, gradient, borderPosition, filling });
|
|
378
|
-
ctx.globalAlpha = 1.0;
|
|
374
|
+
(0, utils_1.drawShape)(ctx, { source, x, y, width, height, opacity, rotation, borderRadius, stroke, shadow, isFilled, color, gradient, borderPosition, filling });
|
|
379
375
|
return;
|
|
380
376
|
}
|
|
381
377
|
let loadedImage;
|
|
@@ -402,6 +398,9 @@ class ApexPainter {
|
|
|
402
398
|
ctx.translate(focusX, focusY);
|
|
403
399
|
ctx.scale(scale, scale);
|
|
404
400
|
}
|
|
401
|
+
if (opacity !== undefined) {
|
|
402
|
+
ctx.globalAlpha = opacity;
|
|
403
|
+
}
|
|
405
404
|
if (blur > 0) {
|
|
406
405
|
ctx.filter = `blur(${blur}px)`;
|
|
407
406
|
}
|
|
@@ -411,9 +410,12 @@ class ApexPainter {
|
|
|
411
410
|
throw new Error('Under construction');
|
|
412
411
|
}
|
|
413
412
|
(0, utils_1.imageRadius)(ctx, loadedImage, x, y, width, height, borderRadius, borderPosition);
|
|
413
|
+
ctx.globalAlpha = 1.0;
|
|
414
|
+
if (stroke?.opacity)
|
|
415
|
+
ctx.globalAlpha = stroke.opacity;
|
|
414
416
|
(0, utils_1.applyStroke)(ctx, stroke, x, y, width, height, undefined);
|
|
415
|
-
ctx.restore();
|
|
416
417
|
ctx.globalAlpha = 1.0;
|
|
418
|
+
ctx.restore();
|
|
417
419
|
}
|
|
418
420
|
async extractFrames(videoSource, options) {
|
|
419
421
|
const frames = [];
|
|
@@ -485,7 +487,7 @@ class ApexPainter {
|
|
|
485
487
|
* @param {Object} options - Options to customize the pattern.
|
|
486
488
|
* @returns {Promise<Buffer>} - The adjusted image buffer.
|
|
487
489
|
*/
|
|
488
|
-
async
|
|
490
|
+
async patterns(buffer, options) {
|
|
489
491
|
const img = await (0, canvas_1.loadImage)(buffer);
|
|
490
492
|
const canvas = (0, canvas_1.createCanvas)(img.width, img.height);
|
|
491
493
|
const ctx = canvas.getContext('2d');
|
|
@@ -521,6 +523,15 @@ class ApexPainter {
|
|
|
521
523
|
case 'custom':
|
|
522
524
|
await this.drawCustomPattern(ctx, width, height, options, x, y);
|
|
523
525
|
break;
|
|
526
|
+
case 'noise':
|
|
527
|
+
await this.drawNoisePattern(ctx, width, height, x, y);
|
|
528
|
+
break;
|
|
529
|
+
case 'waves':
|
|
530
|
+
await this.drawWavePattern(ctx, width, height, options, x, y);
|
|
531
|
+
break;
|
|
532
|
+
case 'diagonal-checkerboard':
|
|
533
|
+
await this.drawDiagonalCheckerboardPattern(ctx, width, height, options, x, y);
|
|
534
|
+
break;
|
|
524
535
|
default:
|
|
525
536
|
throw new Error('Invalid pattern type specified.');
|
|
526
537
|
}
|
|
@@ -663,6 +674,115 @@ class ApexPainter {
|
|
|
663
674
|
ctx.fillRect(0, 0, width, height);
|
|
664
675
|
ctx.resetTransform();
|
|
665
676
|
}
|
|
677
|
+
async drawWavePattern(ctx, width, height, options, x = 0, y = 0) {
|
|
678
|
+
const color = options.color || 'black';
|
|
679
|
+
const waveHeight = options.size || 10;
|
|
680
|
+
const frequency = options.spacing || 20;
|
|
681
|
+
ctx.strokeStyle = color;
|
|
682
|
+
ctx.lineWidth = 2;
|
|
683
|
+
for (let posY = y; posY < y + height; posY += frequency) {
|
|
684
|
+
ctx.beginPath();
|
|
685
|
+
for (let posX = x; posX < x + width; posX += 5) {
|
|
686
|
+
const waveY = posY + Math.sin(posX / frequency) * waveHeight;
|
|
687
|
+
ctx.lineTo(posX, waveY);
|
|
688
|
+
}
|
|
689
|
+
ctx.stroke();
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
async drawNoisePattern(ctx, width, height, x = 0, y = 0) {
|
|
693
|
+
const imageData = ctx.createImageData(width, height);
|
|
694
|
+
const data = imageData.data;
|
|
695
|
+
for (let i = 0; i < data.length; i += 4) {
|
|
696
|
+
const gray = Math.random() * 255;
|
|
697
|
+
data[i] = gray;
|
|
698
|
+
data[i + 1] = gray;
|
|
699
|
+
data[i + 2] = gray;
|
|
700
|
+
data[i + 3] = Math.random() * 255;
|
|
701
|
+
}
|
|
702
|
+
ctx.putImageData(imageData, x, y);
|
|
703
|
+
}
|
|
704
|
+
async drawDiagonalCheckerboardPattern(ctx, width, height, options, x = 0, y = 0) {
|
|
705
|
+
const color1 = options.color || 'black';
|
|
706
|
+
const color2 = options.secondaryColor || 'white';
|
|
707
|
+
const size = options.size || 20;
|
|
708
|
+
ctx.save();
|
|
709
|
+
ctx.translate(x + width / 2, y + height / 2);
|
|
710
|
+
ctx.rotate(Math.PI / 4);
|
|
711
|
+
ctx.translate(-width / 2, -height / 2);
|
|
712
|
+
for (let posY = 0; posY < height; posY += size) {
|
|
713
|
+
for (let posX = 0; posX < width; posX += size) {
|
|
714
|
+
ctx.fillStyle = (Math.floor(posX / size) + Math.floor(posY / size)) % 2 === 0 ? color1 : color2;
|
|
715
|
+
ctx.fillRect(posX, posY, size, size);
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
ctx.restore();
|
|
719
|
+
}
|
|
720
|
+
async masking(source, maskSource, options = { type: "alpha" }) {
|
|
721
|
+
const img = await (0, canvas_1.loadImage)(source);
|
|
722
|
+
const mask = await (0, canvas_1.loadImage)(maskSource);
|
|
723
|
+
const canvas = (0, canvas_1.createCanvas)(img.width, img.height);
|
|
724
|
+
const ctx = canvas.getContext("2d");
|
|
725
|
+
ctx.drawImage(img, 0, 0, img.width, img.height);
|
|
726
|
+
const maskCanvas = (0, canvas_1.createCanvas)(img.width, img.height);
|
|
727
|
+
const maskCtx = maskCanvas.getContext("2d");
|
|
728
|
+
maskCtx.drawImage(mask, 0, 0, img.width, img.height);
|
|
729
|
+
const maskData = maskCtx.getImageData(0, 0, img.width, img.height);
|
|
730
|
+
const imgData = ctx.getImageData(0, 0, img.width, img.height);
|
|
731
|
+
for (let i = 0; i < maskData.data.length; i += 4) {
|
|
732
|
+
let alphaValue = 255;
|
|
733
|
+
if (options.type === "grayscale") {
|
|
734
|
+
const grayscale = maskData.data[i] * 0.3 + maskData.data[i + 1] * 0.59 + maskData.data[i + 2] * 0.11;
|
|
735
|
+
alphaValue = grayscale >= (options.threshold ?? 128) ? 255 : 0;
|
|
736
|
+
}
|
|
737
|
+
else if (options.type === "alpha") {
|
|
738
|
+
alphaValue = maskData.data[i + 3];
|
|
739
|
+
}
|
|
740
|
+
else if (options.type === "color" && options.colorKey) {
|
|
741
|
+
const colorMatch = maskData.data[i] === parseInt(options.colorKey.slice(1, 3), 16) &&
|
|
742
|
+
maskData.data[i + 1] === parseInt(options.colorKey.slice(3, 5), 16) &&
|
|
743
|
+
maskData.data[i + 2] === parseInt(options.colorKey.slice(5, 7), 16);
|
|
744
|
+
alphaValue = colorMatch ? 0 : 255;
|
|
745
|
+
}
|
|
746
|
+
if (options.invert)
|
|
747
|
+
alphaValue = 255 - alphaValue;
|
|
748
|
+
imgData.data[i + 3] = alphaValue;
|
|
749
|
+
}
|
|
750
|
+
ctx.putImageData(imgData, 0, 0);
|
|
751
|
+
return canvas.toBuffer("image/png");
|
|
752
|
+
}
|
|
753
|
+
async gradientBlend(source, options) {
|
|
754
|
+
const img = await (0, canvas_1.loadImage)(source);
|
|
755
|
+
const canvas = (0, canvas_1.createCanvas)(img.width, img.height);
|
|
756
|
+
const ctx = canvas.getContext("2d");
|
|
757
|
+
ctx.drawImage(img, 0, 0, img.width, img.height);
|
|
758
|
+
let gradient;
|
|
759
|
+
if (options.type === "linear") {
|
|
760
|
+
const angle = options.angle ?? 0;
|
|
761
|
+
const radians = (angle * Math.PI) / 180;
|
|
762
|
+
const x1 = img.width / 2 - (Math.cos(radians) * img.width) / 2;
|
|
763
|
+
const y1 = img.height / 2 - (Math.sin(radians) * img.height) / 2;
|
|
764
|
+
const x2 = img.width / 2 + (Math.cos(radians) * img.width) / 2;
|
|
765
|
+
const y2 = img.height / 2 + (Math.sin(radians) * img.height) / 2;
|
|
766
|
+
gradient = ctx.createLinearGradient(x1, y1, x2, y2);
|
|
767
|
+
}
|
|
768
|
+
else if (options.type === "radial") {
|
|
769
|
+
gradient = ctx.createRadialGradient(img.width / 2, img.height / 2, 0, img.width / 2, img.height / 2, Math.max(img.width, img.height));
|
|
770
|
+
}
|
|
771
|
+
else {
|
|
772
|
+
gradient = ctx.createConicGradient(Math.PI, img.width / 2, img.height / 2);
|
|
773
|
+
}
|
|
774
|
+
options.colors.forEach(({ stop, color }) => gradient.addColorStop(stop, color));
|
|
775
|
+
ctx.fillStyle = gradient;
|
|
776
|
+
ctx.globalCompositeOperation = options.blendMode ?? "multiply";
|
|
777
|
+
ctx.fillRect(0, 0, img.width, img.height);
|
|
778
|
+
if (options.maskSource) {
|
|
779
|
+
const mask = await (0, canvas_1.loadImage)(options.maskSource);
|
|
780
|
+
ctx.globalCompositeOperation = "destination-in";
|
|
781
|
+
ctx.drawImage(mask, 0, 0, img.width, img.height);
|
|
782
|
+
}
|
|
783
|
+
ctx.globalCompositeOperation = "source-over";
|
|
784
|
+
return canvas.toBuffer("image/png");
|
|
785
|
+
}
|
|
666
786
|
async animate(frames, defaultDuration, defaultWidth = 800, defaultHeight = 600, options) {
|
|
667
787
|
const buffers = [];
|
|
668
788
|
const isNode = typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
|
|
@@ -717,7 +837,7 @@ class ApexPainter {
|
|
|
717
837
|
fillStyle = gradient;
|
|
718
838
|
}
|
|
719
839
|
if (frame.pattern) {
|
|
720
|
-
const patternImage = await (0, canvas_1.loadImage)(frame.pattern.
|
|
840
|
+
const patternImage = await (0, canvas_1.loadImage)(frame.pattern.source);
|
|
721
841
|
const pattern = ctx.createPattern(patternImage, frame.pattern.repeat || 'repeat');
|
|
722
842
|
fillStyle = pattern;
|
|
723
843
|
}
|
|
@@ -728,8 +848,8 @@ class ApexPainter {
|
|
|
728
848
|
ctx.fillStyle = fillStyle;
|
|
729
849
|
ctx.fillRect(0, 0, width, height);
|
|
730
850
|
}
|
|
731
|
-
if (frame.
|
|
732
|
-
const image = await (0, canvas_1.loadImage)(frame.
|
|
851
|
+
if (frame.source) {
|
|
852
|
+
const image = await (0, canvas_1.loadImage)(frame.source);
|
|
733
853
|
ctx.globalCompositeOperation = frame.blendMode || 'source-over';
|
|
734
854
|
ctx.drawImage(image, 0, 0, width, height);
|
|
735
855
|
}
|