mediaguru 1.0.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.
Files changed (48) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/CODE_OF_CONDUCT.md +41 -0
  3. package/CONTRIBUTING.md +50 -0
  4. package/LICENSE +21 -0
  5. package/README.md +193 -0
  6. package/RELEASE.md +38 -0
  7. package/SECURITY.md +24 -0
  8. package/bin/mediaguru.js +2 -0
  9. package/dist/cli/interactive.d.ts +1 -0
  10. package/dist/cli/interactive.js +647 -0
  11. package/dist/core/batch/index.d.ts +16 -0
  12. package/dist/core/batch/index.js +66 -0
  13. package/dist/core/compress/index.d.ts +17 -0
  14. package/dist/core/compress/index.js +96 -0
  15. package/dist/core/config/index.d.ts +14 -0
  16. package/dist/core/config/index.js +56 -0
  17. package/dist/core/export/index.d.ts +12 -0
  18. package/dist/core/export/index.js +82 -0
  19. package/dist/core/image/index.d.ts +44 -0
  20. package/dist/core/image/index.js +206 -0
  21. package/dist/core/ocr/index.d.ts +14 -0
  22. package/dist/core/ocr/index.js +53 -0
  23. package/dist/core/pdf/index.d.ts +34 -0
  24. package/dist/core/pdf/index.js +121 -0
  25. package/dist/core/qr/index.d.ts +12 -0
  26. package/dist/core/qr/index.js +37 -0
  27. package/dist/core/screenshot/index.d.ts +12 -0
  28. package/dist/core/screenshot/index.js +46 -0
  29. package/dist/core/server/index.d.ts +5 -0
  30. package/dist/core/server/index.js +101 -0
  31. package/dist/core/text2img/index.d.ts +14 -0
  32. package/dist/core/text2img/index.js +64 -0
  33. package/dist/index.d.ts +1 -0
  34. package/dist/index.js +429 -0
  35. package/dist/plugins/index.d.ts +41 -0
  36. package/dist/plugins/index.js +61 -0
  37. package/dist/tests/test.d.ts +1 -0
  38. package/dist/tests/test.js +108 -0
  39. package/dist/tests/test_playwright.d.ts +1 -0
  40. package/dist/tests/test_playwright.js +60 -0
  41. package/dist/utils/branding.d.ts +6 -0
  42. package/dist/utils/branding.js +21 -0
  43. package/dist/utils/file.d.ts +7 -0
  44. package/dist/utils/file.js +29 -0
  45. package/dist/utils/templates.d.ts +9 -0
  46. package/dist/utils/templates.js +347 -0
  47. package/mediaguru-1.0.0.tgz +0 -0
  48. package/package.json +51 -0
@@ -0,0 +1,60 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import chalk from 'chalk';
4
+ import { PdfEngine } from '../core/pdf/index.js';
5
+ import { ScreenshotEngine } from '../core/screenshot/index.js';
6
+ import { Text2ImgEngine } from '../core/text2img/index.js';
7
+ import { ConfigManager } from '../core/config/index.js';
8
+ async function runPlaywrightTests() {
9
+ console.log(chalk.bold.magenta('========================================'));
10
+ console.log(chalk.bold.magenta(' Playwright Browser Validation Suite '));
11
+ console.log(chalk.bold.magenta('========================================\n'));
12
+ const testDir = './test_sandbox_playwright';
13
+ if (!fs.existsSync(testDir)) {
14
+ fs.mkdirSync(testDir, { recursive: true });
15
+ }
16
+ ConfigManager.update({
17
+ outputFolder: testDir,
18
+ });
19
+ // 1. Test Markdown to PDF
20
+ console.log(chalk.yellow('1. Testing Markdown-to-PDF Rendering...'));
21
+ const mdPath = path.join(testDir, 'sample.md');
22
+ fs.writeFileSync(mdPath, '# Hello MediaGuru\n\nThis PDF was generated via headless Chromium compilation.\n\n* Bullet item 1\n* Bullet item 2\n');
23
+ const pdfPath = await PdfEngine.markdownToPdf(mdPath);
24
+ if (fs.existsSync(pdfPath)) {
25
+ console.log(chalk.green(`✓ Markdown compiled successfully: ${pdfPath}`));
26
+ }
27
+ else {
28
+ throw new Error('Markdown-to-PDF failed.');
29
+ }
30
+ // 2. Test Website Screenshot
31
+ console.log(chalk.yellow('\n2. Testing Webpage Screenshot...'));
32
+ const scrPath = await ScreenshotEngine.capture('https://example.com', { fullPage: false });
33
+ if (fs.existsSync(scrPath)) {
34
+ console.log(chalk.green(`✓ Screenshot captured successfully: ${scrPath}`));
35
+ }
36
+ else {
37
+ throw new Error('Screenshot capture failed.');
38
+ }
39
+ // 3. Test Text-to-Image Poster Card
40
+ console.log(chalk.yellow('\n3. Testing Styled Poster Card Render...'));
41
+ const cardPath = await Text2ImgEngine.generate('Creative Coding with Antigravity', {
42
+ type: 'poster',
43
+ theme: 'glass',
44
+ title: 'INSPIRATION',
45
+ author: 'DeepMind Pair Programmer',
46
+ });
47
+ if (fs.existsSync(cardPath)) {
48
+ console.log(chalk.green(`✓ Premium visual poster card saved: ${cardPath}`));
49
+ }
50
+ else {
51
+ throw new Error('Text-to-Image template screenshot failed.');
52
+ }
53
+ console.log(chalk.bold.green('\n========================================'));
54
+ console.log(chalk.bold.green(' ALL PLAYWRIGHT TESTS PASSED! '));
55
+ console.log(chalk.bold.green('========================================\n'));
56
+ }
57
+ runPlaywrightTests().catch((err) => {
58
+ console.error(chalk.bold.red('\n❌ PLAYWRIGHT TEST SUITE FAILED:'), err);
59
+ process.exit(1);
60
+ });
@@ -0,0 +1,6 @@
1
+ export declare const BRANDS: {
2
+ header: string;
3
+ footer: string;
4
+ };
5
+ export declare function printHeader(): void;
6
+ export declare function printFooter(): void;
@@ -0,0 +1,21 @@
1
+ import chalk from 'chalk';
2
+ export const BRANDS = {
3
+ header: `
4
+ ${chalk.cyan.bold(' __ __ _ _ ____ ')}
5
+ ${chalk.cyan.bold('| \\/ | ___ __| (_) __ _ / ___| _ _ _ __ _ _ ')}
6
+ ${chalk.cyan.bold('| |\\/| |/ _ \\/ _` | |/ _` | | _ | | | | \'__| | | |')}
7
+ ${chalk.cyan.bold('| | | | __/ (_| | | (_| | |_| || |_| | | | |_| |')}
8
+ ${chalk.cyan.bold('|_| |_|\\___|\\__,_|_|\\__,_|\\____| \\__,_|_| \\__,_|')}
9
+ ${chalk.yellow.italic('Universal Media & Document Toolkit')}
10
+ `,
11
+ footer: `\n${chalk.dim('──────────────────────────────────────────────────')}\n` +
12
+ ` ${chalk.bold.cyan('MediaGuru')} • ${chalk.green('Powered by Kontyra')}\n` +
13
+ `${chalk.dim('──────────────────────────────────────────────────')}\n`,
14
+ };
15
+ export function printHeader() {
16
+ console.clear();
17
+ console.log(BRANDS.header);
18
+ }
19
+ export function printFooter() {
20
+ console.log(BRANDS.footer);
21
+ }
@@ -0,0 +1,7 @@
1
+ export declare function ensureDirectory(dirPath: string): void;
2
+ export declare function formatBytes(bytes: number, decimals?: number): string;
3
+ export declare function getFileStats(filePath: string): {
4
+ size: number;
5
+ formattedSize: string;
6
+ };
7
+ export declare function resolveOutputPath(inputPath: string, outputDir: string, defaultExt: string, suffix?: string): string;
@@ -0,0 +1,29 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ export function ensureDirectory(dirPath) {
4
+ if (!fs.existsSync(dirPath)) {
5
+ fs.mkdirSync(dirPath, { recursive: true });
6
+ }
7
+ }
8
+ export function formatBytes(bytes, decimals = 2) {
9
+ if (bytes === 0)
10
+ return '0 Bytes';
11
+ const k = 1024;
12
+ const dm = decimals < 0 ? 0 : decimals;
13
+ const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
14
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
15
+ return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
16
+ }
17
+ export function getFileStats(filePath) {
18
+ const stats = fs.statSync(filePath);
19
+ return {
20
+ size: stats.size,
21
+ formattedSize: formatBytes(stats.size),
22
+ };
23
+ }
24
+ export function resolveOutputPath(inputPath, outputDir, defaultExt, suffix = '') {
25
+ ensureDirectory(outputDir);
26
+ const baseName = path.basename(inputPath, path.extname(inputPath));
27
+ const ext = defaultExt.startsWith('.') ? defaultExt : `.${defaultExt}`;
28
+ return path.join(outputDir, `${baseName}${suffix}${ext}`);
29
+ }
@@ -0,0 +1,9 @@
1
+ export interface CardTemplateOptions {
2
+ text: string;
3
+ theme: 'dark' | 'light' | 'glass';
4
+ type: 'quote' | 'banner' | 'poster' | 'social';
5
+ title?: string;
6
+ author?: string;
7
+ }
8
+ export declare function getHtmlForPdf(htmlContent: string): string;
9
+ export declare function getHtmlForSocialCard(opts: CardTemplateOptions): string;
@@ -0,0 +1,347 @@
1
+ export function getHtmlForPdf(htmlContent) {
2
+ return `
3
+ <!DOCTYPE html>
4
+ <html>
5
+ <head>
6
+ <meta charset="utf-8">
7
+ <link rel="preconnect" href="https://fonts.googleapis.com">
8
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
9
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Playfair+Display:ital,wght@0,600;1,400&family=Fira+Code:wght@400;500&display=swap" rel="stylesheet">
10
+ <style>
11
+ body {
12
+ font-family: 'Inter', sans-serif;
13
+ color: #1e293b;
14
+ line-height: 1.6;
15
+ margin: 40px;
16
+ background: #ffffff;
17
+ }
18
+ h1, h2, h3, h4, h5, h6 {
19
+ color: #0f172a;
20
+ font-weight: 700;
21
+ margin-top: 1.5em;
22
+ margin-bottom: 0.5em;
23
+ }
24
+ h1 {
25
+ font-family: 'Playfair Display', serif;
26
+ font-size: 2.2em;
27
+ border-bottom: 2px solid #e2e8f0;
28
+ padding-bottom: 8px;
29
+ }
30
+ h2 {
31
+ font-size: 1.6em;
32
+ border-bottom: 1px solid #f1f5f9;
33
+ padding-bottom: 6px;
34
+ }
35
+ p {
36
+ margin-bottom: 1.2em;
37
+ }
38
+ code {
39
+ font-family: 'Fira Code', monospace;
40
+ background: #f1f5f9;
41
+ padding: 2px 6px;
42
+ border-radius: 4px;
43
+ font-size: 0.9em;
44
+ }
45
+ pre {
46
+ font-family: 'Fira Code', monospace;
47
+ background: #1e293b;
48
+ color: #f8fafc;
49
+ padding: 16px;
50
+ border-radius: 8px;
51
+ overflow-x: auto;
52
+ margin-bottom: 1.5em;
53
+ }
54
+ pre code {
55
+ background: transparent;
56
+ padding: 0;
57
+ color: inherit;
58
+ }
59
+ blockquote {
60
+ font-family: 'Playfair Display', serif;
61
+ font-style: italic;
62
+ border-left: 4px solid #3b82f6;
63
+ padding-left: 20px;
64
+ margin: 20px 0;
65
+ color: #475569;
66
+ }
67
+ table {
68
+ width: 100%;
69
+ border-collapse: collapse;
70
+ margin-bottom: 1.5em;
71
+ }
72
+ th, td {
73
+ border: 1px solid #e2e8f0;
74
+ padding: 10px 12px;
75
+ text-align: left;
76
+ }
77
+ th {
78
+ background: #f8fafc;
79
+ font-weight: 600;
80
+ }
81
+ img {
82
+ max-width: 100%;
83
+ height: auto;
84
+ border-radius: 8px;
85
+ }
86
+ .footer {
87
+ margin-top: 50px;
88
+ border-top: 1px solid #e2e8f0;
89
+ padding-top: 10px;
90
+ text-align: center;
91
+ font-size: 0.85em;
92
+ color: #94a3b8;
93
+ }
94
+ </style>
95
+ </head>
96
+ <body>
97
+ ${htmlContent}
98
+ <div class="footer">
99
+ Powered by Kontyra
100
+ </div>
101
+ </body>
102
+ </html>
103
+ `;
104
+ }
105
+ export function getHtmlForSocialCard(opts) {
106
+ const { text, theme, type, title = '', author = '' } = opts;
107
+ // Define dimension presets
108
+ let width = '1200px';
109
+ let height = '630px';
110
+ if (type === 'quote') {
111
+ width = '800px';
112
+ height = '800px';
113
+ }
114
+ else if (type === 'poster') {
115
+ width = '800px';
116
+ height = '1200px';
117
+ }
118
+ else if (type === 'banner') {
119
+ width = '1200px';
120
+ height = '400px';
121
+ }
122
+ // Themes CSS definitions
123
+ let backgroundStyle = '';
124
+ let textStyle = '';
125
+ let cardStyle = '';
126
+ if (theme === 'dark') {
127
+ backgroundStyle = 'background: radial-gradient(circle at 10% 20%, #1e1e24 0%, #0d0d11 90%);';
128
+ textStyle = 'color: #f8fafc;';
129
+ cardStyle = `
130
+ background: rgba(30, 30, 40, 0.4);
131
+ border: 1px solid rgba(255, 255, 255, 0.1);
132
+ box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
133
+ `;
134
+ }
135
+ else if (theme === 'light') {
136
+ backgroundStyle = 'background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);';
137
+ textStyle = 'color: #0f172a;';
138
+ cardStyle = `
139
+ background: rgba(255, 255, 255, 0.75);
140
+ border: 1px solid rgba(255, 255, 255, 0.4);
141
+ box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.08);
142
+ `;
143
+ }
144
+ else {
145
+ // Glassmorphism
146
+ backgroundStyle = 'background: linear-gradient(45deg, #ff9a9e 0%, #fecfef 99%, #fecfef 100%);';
147
+ textStyle = 'color: #1e1b4b;';
148
+ cardStyle = `
149
+ background: rgba(255, 255, 255, 0.25);
150
+ backdrop-filter: blur(16px);
151
+ -webkit-backdrop-filter: blur(16px);
152
+ border: 1px solid rgba(255, 255, 255, 0.3);
153
+ box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
154
+ `;
155
+ }
156
+ // Layout templates based on type
157
+ let contentHtml = '';
158
+ if (type === 'quote') {
159
+ contentHtml = `
160
+ <div class="quote-symbol">“</div>
161
+ <div class="quote-text">${text}</div>
162
+ ${author ? `<div class="quote-author">— ${author}</div>` : ''}
163
+ `;
164
+ }
165
+ else if (type === 'poster') {
166
+ contentHtml = `
167
+ ${title ? `<div class="poster-title">${title}</div>` : ''}
168
+ <div class="poster-separator"></div>
169
+ <div class="poster-body">${text}</div>
170
+ ${author ? `<div class="poster-footer">${author}</div>` : ''}
171
+ `;
172
+ }
173
+ else if (type === 'banner') {
174
+ contentHtml = `
175
+ <div class="banner-flex">
176
+ <div class="banner-body">
177
+ ${title ? `<div class="banner-title">${title}</div>` : ''}
178
+ <div class="banner-text">${text}</div>
179
+ </div>
180
+ </div>
181
+ `;
182
+ }
183
+ else {
184
+ // Standard social card
185
+ contentHtml = `
186
+ <div class="social-header">
187
+ ${title ? `<span class="social-category">${title}</span>` : `<span class="social-category">ANNOUNCEMENT</span>`}
188
+ </div>
189
+ <div class="social-title">${text}</div>
190
+ <div class="social-footer">
191
+ <div class="social-brand">Kontyra</div>
192
+ </div>
193
+ `;
194
+ }
195
+ return `
196
+ <!DOCTYPE html>
197
+ <html>
198
+ <head>
199
+ <meta charset="utf-8">
200
+ <link rel="preconnect" href="https://fonts.googleapis.com">
201
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
202
+ <link href="https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;800&family=Playfair+Display:ital,wght@0,600;1,400&family=Inter:wght@400;600&display=swap" rel="stylesheet">
203
+ <style>
204
+ body, html {
205
+ margin: 0;
206
+ padding: 0;
207
+ width: ${width};
208
+ height: ${height};
209
+ font-family: 'Outfit', 'Inter', sans-serif;
210
+ ${backgroundStyle}
211
+ display: flex;
212
+ justify-content: center;
213
+ align-items: center;
214
+ overflow: hidden;
215
+ box-sizing: border-box;
216
+ }
217
+
218
+ .card {
219
+ width: calc(100% - 80px);
220
+ height: calc(100% - 80px);
221
+ border-radius: 24px;
222
+ padding: 40px;
223
+ box-sizing: border-box;
224
+ display: flex;
225
+ flex-direction: column;
226
+ justify-content: space-between;
227
+ ${cardStyle}
228
+ ${textStyle}
229
+ }
230
+
231
+ /* Quote Styling */
232
+ .quote-symbol {
233
+ font-family: 'Playfair Display', serif;
234
+ font-size: 100px;
235
+ height: 40px;
236
+ line-height: 40px;
237
+ margin-top: -10px;
238
+ color: rgba(59, 130, 246, 0.8);
239
+ }
240
+ .quote-text {
241
+ font-family: 'Playfair Display', serif;
242
+ font-size: 32px;
243
+ line-height: 1.5;
244
+ font-style: italic;
245
+ font-weight: 400;
246
+ margin: 20px 0;
247
+ }
248
+ .quote-author {
249
+ font-size: 20px;
250
+ font-weight: 600;
251
+ text-transform: uppercase;
252
+ letter-spacing: 2px;
253
+ opacity: 0.8;
254
+ text-align: right;
255
+ }
256
+
257
+ /* Poster Styling */
258
+ .poster-title {
259
+ font-size: 40px;
260
+ font-weight: 800;
261
+ text-align: center;
262
+ letter-spacing: 2px;
263
+ text-transform: uppercase;
264
+ }
265
+ .poster-separator {
266
+ width: 100px;
267
+ height: 4px;
268
+ background: #3b82f6;
269
+ margin: 30px auto;
270
+ }
271
+ .poster-body {
272
+ font-size: 24px;
273
+ line-height: 1.6;
274
+ text-align: center;
275
+ margin: auto 0;
276
+ }
277
+ .poster-footer {
278
+ font-size: 18px;
279
+ font-weight: 600;
280
+ text-align: center;
281
+ opacity: 0.8;
282
+ letter-spacing: 1px;
283
+ }
284
+
285
+ /* Banner Styling */
286
+ .banner-flex {
287
+ display: flex;
288
+ height: 100%;
289
+ align-items: center;
290
+ }
291
+ .banner-body {
292
+ width: 100%;
293
+ }
294
+ .banner-title {
295
+ font-size: 22px;
296
+ font-weight: 600;
297
+ color: #3b82f6;
298
+ letter-spacing: 1px;
299
+ text-transform: uppercase;
300
+ margin-bottom: 8px;
301
+ }
302
+ .banner-text {
303
+ font-size: 36px;
304
+ font-weight: 800;
305
+ line-height: 1.3;
306
+ }
307
+
308
+ /* Social Card Styling */
309
+ .social-header {
310
+ display: flex;
311
+ justify-content: space-between;
312
+ align-items: center;
313
+ }
314
+ .social-category {
315
+ font-size: 14px;
316
+ font-weight: 800;
317
+ letter-spacing: 3px;
318
+ color: #3b82f6;
319
+ }
320
+ .social-title {
321
+ font-size: 46px;
322
+ font-weight: 800;
323
+ line-height: 1.3;
324
+ margin: auto 0;
325
+ }
326
+ .social-footer {
327
+ display: flex;
328
+ justify-content: space-between;
329
+ align-items: center;
330
+ border-top: 1px solid rgba(255, 255, 255, 0.1);
331
+ padding-top: 16px;
332
+ }
333
+ .social-brand {
334
+ font-weight: 800;
335
+ letter-spacing: 2px;
336
+ text-transform: uppercase;
337
+ }
338
+ </style>
339
+ </head>
340
+ <body>
341
+ <div class="card">
342
+ ${contentHtml}
343
+ </div>
344
+ </body>
345
+ </html>
346
+ `;
347
+ }
Binary file
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "mediaguru",
3
+ "version": "1.0.0",
4
+ "description": "MediaGuru universal document and media processing toolkit. Powered by Kontyra.",
5
+ "main": "dist/index.js",
6
+ "type": "module",
7
+ "bin": {
8
+ "mediaguru": "bin/mediaguru.js",
9
+ "mguru": "bin/mediaguru.js"
10
+ },
11
+ "scripts": {
12
+ "build": "tsc",
13
+ "watch": "tsc -w",
14
+ "start": "node bin/mediaguru.js",
15
+ "typecheck": "tsc --noEmit",
16
+ "test": "node dist/tests/test.js",
17
+ "test:browser": "node dist/tests/test_playwright.js"
18
+ },
19
+ "dependencies": {
20
+ "chalk": "^5.3.0",
21
+ "commander": "^12.0.0",
22
+ "csv-writer": "^1.6.0",
23
+ "dotenv": "^16.4.5",
24
+ "glob": "^10.3.10",
25
+ "inquirer": "^9.2.15",
26
+ "marked": "^12.0.1",
27
+ "ora": "^8.0.1",
28
+ "pdf-lib": "^1.17.1",
29
+ "pdf-parse": "^1.1.1",
30
+ "playwright": "^1.42.1",
31
+ "qrcode": "^1.5.3",
32
+ "sharp": "^0.33.2",
33
+ "tesseract.js": "^5.0.5"
34
+ },
35
+ "devDependencies": {
36
+ "@types/inquirer": "^9.0.7",
37
+ "@types/node": "^20.11.24",
38
+ "@types/qrcode": "^1.5.5",
39
+ "typescript": "^5.3.3"
40
+ },
41
+ "author": "Antigravity",
42
+ "license": "MIT",
43
+ "engines": {
44
+ "node": ">=18.0.0"
45
+ },
46
+ "kontyra": {
47
+ "poweredBy": "Powered by Kontyra",
48
+ "aiReady": true,
49
+ "aiImplemented": true
50
+ }
51
+ }