new(all): Adobe Illustrator CONVERT keyword support.
This commit is contained in:
parent
e7f377c887
commit
94a7fa0267
3 changed files with 70 additions and 35 deletions
|
@ -103,6 +103,7 @@
|
|||
"@types/node": "22.5.2",
|
||||
"@types/validator": "13.12.1",
|
||||
"adm-zip": "0.5.16",
|
||||
"ai2html": "^0.121.1",
|
||||
"alasql": "4.5.1",
|
||||
"any-shell-escape": "0.1.1",
|
||||
"arraybuffer-to-buffer": "0.0.7",
|
||||
|
|
|
@ -33,6 +33,7 @@ import { setFlagsFromString } from 'v8';
|
|||
import { runInNewContext } from 'vm';
|
||||
import { IgApiClient } from 'instagram-private-api';
|
||||
import { readFile } from 'fs';
|
||||
import ai2html from 'ai2html';
|
||||
import path, { resolve } from 'path';
|
||||
import { GBLog, GBMinInstance } from 'botlib';
|
||||
import { GBConfigService } from '../../core.gbapp/services/GBConfigService.js';
|
||||
|
@ -1663,7 +1664,7 @@ export class SystemKeywords {
|
|||
/**
|
||||
* Converts a drive file from a place to another .
|
||||
*
|
||||
* Supported sources csv, doc, docx, odp, ods, odt, pot, potm, potx, pps,
|
||||
* Supported sources ai, csv, doc, docx, odp, ods, odt, pot, potm, potx, pps,
|
||||
* ppsx, ppsxm, ppt, pptm, pptx, rtf, xls, xlsx
|
||||
*
|
||||
* @example
|
||||
|
@ -1688,6 +1689,13 @@ export class SystemKeywords {
|
|||
const srcPath = urlJoin(root, src);
|
||||
const dstPath = urlJoin(packagePath, dest);
|
||||
|
||||
|
||||
if (path.extname(srcPath) === 'ai'){
|
||||
|
||||
// TODO: To be done.
|
||||
|
||||
} else {
|
||||
|
||||
// Checks if the destination contains subfolders that
|
||||
// need to be created.
|
||||
|
||||
|
@ -1726,6 +1734,7 @@ export class SystemKeywords {
|
|||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a secure and unique password.
|
||||
|
@ -2889,6 +2898,30 @@ export class SystemKeywords {
|
|||
await this.setMemoryContext({ pid, erase: true });
|
||||
}
|
||||
|
||||
public async convertAI2HTML(aiFilePath) {
|
||||
|
||||
// Convert the AI file to HTML and assets
|
||||
const result = await ai2html.convertFile(aiFilePath, {
|
||||
outputFormat: 'html',
|
||||
outputWriteMethod: 'write-file',
|
||||
outputPath: path.dirname(aiFilePath),
|
||||
useDocumentSettings: true,
|
||||
});
|
||||
|
||||
// Get the generated HTML file path
|
||||
const htmlFilePath = result.outputFiles.find((file) => file.endsWith('.html')).filePath;
|
||||
|
||||
// Read the HTML content
|
||||
const htmlContent = await fs.readFile(htmlFilePath, 'utf8');
|
||||
|
||||
// Save the HTML and assets to a cache directory
|
||||
const cacheDir = path.join('work', 'cache');
|
||||
await fs.mkdir(cacheDir, { recursive: true });
|
||||
const cacheFilePath = path.join(cacheDir, path.basename(htmlFilePath));
|
||||
await fs.writeFile(cacheFilePath, htmlContent);
|
||||
|
||||
return cacheFilePath;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -58,6 +58,7 @@ import shell from 'any-shell-escape';
|
|||
import { exec } from 'child_process';
|
||||
import prism from 'prism-media';
|
||||
|
||||
|
||||
import SpeechToTextV1 from 'ibm-watson/speech-to-text/v1.js';
|
||||
import TextToSpeechV1 from 'ibm-watson/text-to-speech/v1.js';
|
||||
import { IamAuthenticator } from 'ibm-watson/auth/index.js';
|
||||
|
|
Loading…
Add table
Reference in a new issue