@efectoapp/mcp-server 0.1.21 → 0.1.22
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/README.md +6 -3
- package/dist/tools/output.d.ts +1 -4
- package/dist/tools/output.d.ts.map +1 -1
- package/dist/tools/output.js +49 -64
- package/dist/tools/output.js.map +1 -1
- package/dist/tools/render.d.ts +22 -0
- package/dist/tools/render.d.ts.map +1 -0
- package/dist/tools/render.js +148 -0
- package/dist/tools/render.js.map +1 -0
- package/dist/tools/state.d.ts +58 -1
- package/dist/tools/state.d.ts.map +1 -1
- package/dist/tools/state.js +1598 -192
- package/dist/tools/state.js.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -53,6 +53,9 @@ claude mcp add efecto -- npx @efectoapp/mcp-server
|
|
|
53
53
|
|
|
54
54
|
8. generate_url()
|
|
55
55
|
→ Returns shareable URL like https://efecto.app/canvas?lm=1&...
|
|
56
|
+
|
|
57
|
+
9. render_image({ format: "png" })
|
|
58
|
+
→ Returns the rendered image inline (base64) so you can see it
|
|
56
59
|
```
|
|
57
60
|
|
|
58
61
|
## Available Tools
|
|
@@ -90,7 +93,7 @@ Create a new poster.
|
|
|
90
93
|
|
|
91
94
|
| Parameter | Type | Default | Description |
|
|
92
95
|
|-----------|------|---------|-------------|
|
|
93
|
-
| `aspectRatio` | string | `"16
|
|
96
|
+
| `aspectRatio` | string | `"9:16"` | `"16:9"`, `"9:16"`, `"1:1"`, `"4:3"`, `"full"` |
|
|
94
97
|
| `backgroundColor` | string | `"#1a1a1a"` | Background color (hex) |
|
|
95
98
|
|
|
96
99
|
#### `set_background`
|
|
@@ -222,7 +225,7 @@ Returns a URL that opens in any browser with all effects applied.
|
|
|
222
225
|
|
|
223
226
|
#### `render_image`
|
|
224
227
|
|
|
225
|
-
Render the poster to an image (
|
|
228
|
+
Render the current poster to an image. Returns the image inline so the agent can see the rendered design. Uses local Puppeteer (headless Chrome) to capture the poster.
|
|
226
229
|
|
|
227
230
|
| Parameter | Type | Default | Description |
|
|
228
231
|
|-----------|------|---------|-------------|
|
|
@@ -231,7 +234,7 @@ Render the poster to an image (async).
|
|
|
231
234
|
| `height` | number | auto | Output height |
|
|
232
235
|
| `quality` | number | 90 | JPEG/WebP quality |
|
|
233
236
|
|
|
234
|
-
Returns
|
|
237
|
+
Returns the rendered image as base64-encoded inline content, plus a shareable URL.
|
|
235
238
|
|
|
236
239
|
## Development
|
|
237
240
|
|
package/dist/tools/output.d.ts
CHANGED
|
@@ -13,9 +13,6 @@ export declare const outputTools: Tool[];
|
|
|
13
13
|
* Handle output tool calls
|
|
14
14
|
*/
|
|
15
15
|
export declare function handleOutputTool(name: string, args: Record<string, unknown> | undefined): Promise<{
|
|
16
|
-
content: Array<
|
|
17
|
-
type: string;
|
|
18
|
-
text: string;
|
|
19
|
-
}>;
|
|
16
|
+
content: Array<Record<string, unknown>>;
|
|
20
17
|
}>;
|
|
21
18
|
//# sourceMappingURL=output.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/tools/output.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAA;
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/tools/output.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAA;AAQ9D,eAAO,MAAM,WAAW,EAAE,IAAI,EA6C7B,CAAA;AAgDD;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GACxC,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;CAAE,CAAC,CAyLtD"}
|
package/dist/tools/output.js
CHANGED
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.outputTools = void 0;
|
|
13
13
|
exports.handleOutputTool = handleOutputTool;
|
|
14
14
|
const state_js_1 = require("./state.js");
|
|
15
|
+
const render_js_1 = require("./render.js");
|
|
15
16
|
// Default API base URL (can be overridden via environment variable)
|
|
16
17
|
const API_BASE_URL = process.env.EFECTO_API_URL || 'https://efecto.app';
|
|
17
18
|
// Tool definitions
|
|
@@ -33,7 +34,7 @@ exports.outputTools = [
|
|
|
33
34
|
},
|
|
34
35
|
{
|
|
35
36
|
name: 'render_image',
|
|
36
|
-
description: 'Render the current poster to an image.
|
|
37
|
+
description: 'Render the current poster to an image. Returns the image inline so the agent can see the rendered design.',
|
|
37
38
|
inputSchema: {
|
|
38
39
|
type: 'object',
|
|
39
40
|
properties: {
|
|
@@ -107,12 +108,8 @@ function getDefaultDimensions(aspectRatio) {
|
|
|
107
108
|
*/
|
|
108
109
|
async function handleOutputTool(name, args) {
|
|
109
110
|
const params = args || {};
|
|
111
|
+
(0, state_js_1.ensurePoster)();
|
|
110
112
|
const poster = (0, state_js_1.getCurrentState)();
|
|
111
|
-
if (!poster) {
|
|
112
|
-
return {
|
|
113
|
-
content: [{ type: 'text', text: 'Error: No poster created. Use create_poster first.' }],
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
113
|
switch (name) {
|
|
117
114
|
case 'generate_url': {
|
|
118
115
|
const baseUrl = params.baseUrl || 'https://efecto.app';
|
|
@@ -187,91 +184,79 @@ async function handleOutputTool(name, args) {
|
|
|
187
184
|
const width = params.width || defaultDims.width;
|
|
188
185
|
const height = params.height || defaultDims.height;
|
|
189
186
|
const quality = params.quality || 90;
|
|
190
|
-
const asyncMode = params.async ?? true; // Default to async for MCP
|
|
191
187
|
const state = convertToLayerShareState(poster);
|
|
192
188
|
if (!state) {
|
|
193
189
|
return {
|
|
194
190
|
content: [{ type: 'text', text: 'Error: Failed to convert poster state' }],
|
|
195
191
|
};
|
|
196
192
|
}
|
|
193
|
+
// Step 1: Generate a shareable URL (same as generate_url)
|
|
194
|
+
let posterUrl = null;
|
|
195
|
+
const baseUrl = API_BASE_URL;
|
|
197
196
|
try {
|
|
198
|
-
|
|
199
|
-
// Sync mode returns binary which MCP cannot handle directly
|
|
200
|
-
const response = await fetch(`${API_BASE_URL}/api/v1/render`, {
|
|
197
|
+
const response = await fetch(`${API_BASE_URL}/api/v1/state/encode`, {
|
|
201
198
|
method: 'POST',
|
|
202
|
-
headers: {
|
|
203
|
-
|
|
204
|
-
},
|
|
205
|
-
body: JSON.stringify({
|
|
206
|
-
state,
|
|
207
|
-
format,
|
|
208
|
-
width,
|
|
209
|
-
height,
|
|
210
|
-
quality,
|
|
211
|
-
async: true, // Always use async for MCP to get JSON response
|
|
212
|
-
}),
|
|
199
|
+
headers: { 'Content-Type': 'application/json' },
|
|
200
|
+
body: JSON.stringify({ state, baseUrl }),
|
|
213
201
|
});
|
|
214
|
-
if (
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
let errorDetails;
|
|
218
|
-
if (contentType?.includes('application/json')) {
|
|
219
|
-
const errorJson = await response.json();
|
|
220
|
-
errorDetails = JSON.stringify(errorJson);
|
|
221
|
-
}
|
|
222
|
-
else {
|
|
223
|
-
errorDetails = await response.text();
|
|
224
|
-
}
|
|
225
|
-
return {
|
|
226
|
-
content: [
|
|
227
|
-
{
|
|
228
|
-
type: 'text',
|
|
229
|
-
text: JSON.stringify({
|
|
230
|
-
success: false,
|
|
231
|
-
error: `API error: ${response.status}`,
|
|
232
|
-
details: errorDetails,
|
|
233
|
-
}, null, 2),
|
|
234
|
-
},
|
|
235
|
-
],
|
|
236
|
-
};
|
|
202
|
+
if (response.ok) {
|
|
203
|
+
const result = (await response.json());
|
|
204
|
+
posterUrl = result.url;
|
|
237
205
|
}
|
|
238
|
-
|
|
239
|
-
|
|
206
|
+
}
|
|
207
|
+
catch (encodeError) {
|
|
208
|
+
// URL generation failed, will be handled below
|
|
209
|
+
console.error('URL encode failed:', encodeError);
|
|
210
|
+
}
|
|
211
|
+
if (!posterUrl) {
|
|
212
|
+
return {
|
|
213
|
+
content: [{
|
|
214
|
+
type: 'text',
|
|
215
|
+
text: JSON.stringify({
|
|
216
|
+
success: false,
|
|
217
|
+
error: 'Failed to generate poster URL for rendering',
|
|
218
|
+
details: 'Could not encode poster state to URL. Check that the Efecto API is reachable.',
|
|
219
|
+
}, null, 2),
|
|
220
|
+
}],
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
// Step 2: Render locally via Puppeteer
|
|
224
|
+
// Append _render=1 for clean UI-free rendering
|
|
225
|
+
const renderUrl = posterUrl + (posterUrl.includes('?') ? '&' : '?') + '_render=1';
|
|
226
|
+
try {
|
|
227
|
+
const result = await (0, render_js_1.renderPoster)(renderUrl, { width, height, format, quality });
|
|
240
228
|
return {
|
|
241
229
|
content: [
|
|
230
|
+
{
|
|
231
|
+
type: 'image',
|
|
232
|
+
data: result.base64,
|
|
233
|
+
mimeType: result.mimeType,
|
|
234
|
+
},
|
|
242
235
|
{
|
|
243
236
|
type: 'text',
|
|
244
237
|
text: JSON.stringify({
|
|
245
238
|
success: true,
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
statusUrl: `${API_BASE_URL}${result.statusUrl}`,
|
|
249
|
-
downloadUrl: `${API_BASE_URL}${result.downloadUrl}`,
|
|
250
|
-
message: 'Render job started. Poll the status URL to check progress, then download from downloadUrl when complete.',
|
|
239
|
+
url: posterUrl,
|
|
240
|
+
message: 'Poster rendered successfully. The image is shown above. Open the URL in a browser to view interactively.',
|
|
251
241
|
renderConfig: { format, width, height, quality },
|
|
252
242
|
}, null, 2),
|
|
253
243
|
},
|
|
254
244
|
],
|
|
255
245
|
};
|
|
256
246
|
}
|
|
257
|
-
catch (
|
|
247
|
+
catch (renderError) {
|
|
248
|
+
// Graceful degradation: return URL even if rendering fails
|
|
258
249
|
return {
|
|
259
|
-
content: [
|
|
260
|
-
{
|
|
250
|
+
content: [{
|
|
261
251
|
type: 'text',
|
|
262
252
|
text: JSON.stringify({
|
|
263
253
|
success: false,
|
|
264
|
-
error: '
|
|
265
|
-
details:
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
note: 'You can manually call the API with this configuration:',
|
|
269
|
-
endpoint: `POST ${API_BASE_URL}/api/v1/render`,
|
|
270
|
-
body: { state, format, width, height, quality, async: asyncMode },
|
|
271
|
-
},
|
|
254
|
+
error: 'Rendering failed, but URL is available',
|
|
255
|
+
details: renderError instanceof Error ? renderError.message : String(renderError),
|
|
256
|
+
url: posterUrl,
|
|
257
|
+
message: 'Could not render image locally. Open the URL in a browser to see the design.',
|
|
272
258
|
}, null, 2),
|
|
273
|
-
},
|
|
274
|
-
],
|
|
259
|
+
}],
|
|
275
260
|
};
|
|
276
261
|
}
|
|
277
262
|
}
|
package/dist/tools/output.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/tools/output.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/tools/output.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AA0GH,4CA4LC;AAnSD,yCAA0D;AAC1D,2CAA0C;AAE1C,oEAAoE;AACpE,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,oBAAoB,CAAA;AAEvE,mBAAmB;AACN,QAAA,WAAW,GAAW;IACjC;QACE,IAAI,EAAE,cAAc;QACpB,WAAW,EAAE,oHAAoH;QACjI,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,OAAO,EAAE;oBACP,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,+DAA+D;oBAC5E,OAAO,EAAE,oBAAoB;iBAC9B;aACF;YACD,QAAQ,EAAE,EAAE;SAC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yBACZ;qBACF;iBACF,CAAA;YACH,CAAC;YAAC,OAAO,WAAW,EAAE,CAAC;gBACrB,2DAA2D;gBAC3D,OAAO;oBACL,OAAO,EAAE,CAAC;4BACR,IAAI,EAAE,MAAM;4BACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gCACnB,OAAO,EAAE,KAAK;gCACd,KAAK,EAAE,wCAAwC;gCAC/C,OAAO,EAAE,WAAW,YAAY,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC;gCACjF,GAAG,EAAE,SAAS;gCACd,OAAO,EAAE,8EAA8E;6BACxF,EAAE,IAAI,EAAE,CAAC,CAAC;yBACZ,CAAC;iBACH,CAAA;YACH,CAAC;QACH,CAAC;QAED;YACE,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,wBAAwB,IAAI,EAAE,EAAE,CAAC;aAClE,CAAA;IACL,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local Poster Rendering
|
|
3
|
+
*
|
|
4
|
+
* Uses Puppeteer to render posters locally via headless Chrome.
|
|
5
|
+
* This allows the MCP server to return actual images that agents can see.
|
|
6
|
+
*/
|
|
7
|
+
export interface RenderOptions {
|
|
8
|
+
width?: number;
|
|
9
|
+
height?: number;
|
|
10
|
+
format?: string;
|
|
11
|
+
quality?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface RenderResult {
|
|
14
|
+
base64: string;
|
|
15
|
+
mimeType: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Render a poster by navigating to its URL in headless Chrome.
|
|
19
|
+
* The URL should already include `_render=1` for clean rendering.
|
|
20
|
+
*/
|
|
21
|
+
export declare function renderPoster(url: string, options?: RenderOptions): Promise<RenderResult>;
|
|
22
|
+
//# sourceMappingURL=render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/tools/render.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA6FH,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAChC,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,YAAY,CAAC,CA2DvB"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Local Poster Rendering
|
|
4
|
+
*
|
|
5
|
+
* Uses Puppeteer to render posters locally via headless Chrome.
|
|
6
|
+
* This allows the MCP server to return actual images that agents can see.
|
|
7
|
+
*/
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.renderPoster = renderPoster;
|
|
13
|
+
const puppeteer_1 = __importDefault(require("puppeteer"));
|
|
14
|
+
const fs_1 = require("fs");
|
|
15
|
+
// Common Chrome/Chromium paths by platform
|
|
16
|
+
const CHROME_PATHS = {
|
|
17
|
+
darwin: [
|
|
18
|
+
'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
|
|
19
|
+
'/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary',
|
|
20
|
+
'/Applications/Chromium.app/Contents/MacOS/Chromium',
|
|
21
|
+
],
|
|
22
|
+
linux: [
|
|
23
|
+
'/usr/bin/google-chrome',
|
|
24
|
+
'/usr/bin/google-chrome-stable',
|
|
25
|
+
'/usr/bin/chromium-browser',
|
|
26
|
+
'/usr/bin/chromium',
|
|
27
|
+
],
|
|
28
|
+
win32: [
|
|
29
|
+
'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe',
|
|
30
|
+
'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe',
|
|
31
|
+
],
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Find a Chrome/Chromium executable on the system.
|
|
35
|
+
* Falls back to puppeteer's bundled Chromium.
|
|
36
|
+
*/
|
|
37
|
+
function findChrome() {
|
|
38
|
+
const platform = process.platform;
|
|
39
|
+
const paths = CHROME_PATHS[platform] || [];
|
|
40
|
+
for (const p of paths) {
|
|
41
|
+
if ((0, fs_1.existsSync)(p)) {
|
|
42
|
+
return p;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// Fall back to puppeteer's bundled Chromium
|
|
46
|
+
return undefined; // puppeteer will use its bundled browser
|
|
47
|
+
}
|
|
48
|
+
// Reusable browser instance with launch guard to prevent concurrent launches
|
|
49
|
+
let browserInstance = null;
|
|
50
|
+
let launchPromise = null;
|
|
51
|
+
async function getBrowser() {
|
|
52
|
+
if (browserInstance?.connected) {
|
|
53
|
+
return browserInstance;
|
|
54
|
+
}
|
|
55
|
+
// Prevent concurrent launches — reuse in-flight promise
|
|
56
|
+
if (launchPromise) {
|
|
57
|
+
return launchPromise;
|
|
58
|
+
}
|
|
59
|
+
const executablePath = findChrome();
|
|
60
|
+
launchPromise = puppeteer_1.default.launch({
|
|
61
|
+
headless: true,
|
|
62
|
+
...(executablePath ? { executablePath } : {}),
|
|
63
|
+
// --no-sandbox is required for headless environments without a display server
|
|
64
|
+
args: [
|
|
65
|
+
'--no-sandbox',
|
|
66
|
+
'--disable-setuid-sandbox',
|
|
67
|
+
'--disable-dev-shm-usage',
|
|
68
|
+
'--disable-gpu',
|
|
69
|
+
'--disable-extensions',
|
|
70
|
+
'--no-first-run',
|
|
71
|
+
],
|
|
72
|
+
}).then(browser => {
|
|
73
|
+
browserInstance = browser;
|
|
74
|
+
launchPromise = null;
|
|
75
|
+
return browser;
|
|
76
|
+
}).catch(err => {
|
|
77
|
+
launchPromise = null;
|
|
78
|
+
throw err;
|
|
79
|
+
});
|
|
80
|
+
return launchPromise;
|
|
81
|
+
}
|
|
82
|
+
// Clean up browser on process exit
|
|
83
|
+
function cleanupBrowser() {
|
|
84
|
+
if (browserInstance) {
|
|
85
|
+
browserInstance.close().catch(() => { });
|
|
86
|
+
browserInstance = null;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
process.on('exit', cleanupBrowser);
|
|
90
|
+
process.on('SIGINT', () => { cleanupBrowser(); process.exit(0); });
|
|
91
|
+
process.on('SIGTERM', () => { cleanupBrowser(); process.exit(0); });
|
|
92
|
+
/**
|
|
93
|
+
* Render a poster by navigating to its URL in headless Chrome.
|
|
94
|
+
* The URL should already include `_render=1` for clean rendering.
|
|
95
|
+
*/
|
|
96
|
+
async function renderPoster(url, options = {}) {
|
|
97
|
+
const { width = 1080, height = 1920, format = 'png', quality = 90 } = options;
|
|
98
|
+
const mimeType = format === 'jpeg' ? 'image/jpeg' : format === 'webp' ? 'image/webp' : 'image/png';
|
|
99
|
+
const browser = await getBrowser();
|
|
100
|
+
const page = await browser.newPage();
|
|
101
|
+
page.setDefaultTimeout(30000);
|
|
102
|
+
try {
|
|
103
|
+
// Set viewport to requested dimensions
|
|
104
|
+
await page.setViewport({ width, height, deviceScaleFactor: 1 });
|
|
105
|
+
// Navigate to the poster URL
|
|
106
|
+
await page.goto(url, { waitUntil: 'networkidle2', timeout: 60000 });
|
|
107
|
+
// Wait for the render-ready signal from SceneRenderer
|
|
108
|
+
try {
|
|
109
|
+
await page.waitForSelector('[data-render-ready="true"]', { timeout: 30000 });
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
// If no render-ready signal, wait a bit for rendering
|
|
113
|
+
console.error('Warning: render-ready signal not found, waiting 3s...');
|
|
114
|
+
await new Promise(r => setTimeout(r, 3000));
|
|
115
|
+
}
|
|
116
|
+
// Extra wait for fonts/images to settle
|
|
117
|
+
await new Promise(r => setTimeout(r, 1500));
|
|
118
|
+
// Primary: extract canvas content via toDataURL
|
|
119
|
+
// Uses string evaluation because this runs in browser context (no DOM types in Node tsconfig)
|
|
120
|
+
// Select the LAST canvas: when dither effects are active, a WebGPU overlay canvas is
|
|
121
|
+
// appended after the Three.js canvas and contains the final composited output.
|
|
122
|
+
const evalScript = `(() => {
|
|
123
|
+
const canvases = document.querySelectorAll('canvas');
|
|
124
|
+
const c = canvases[canvases.length - 1];
|
|
125
|
+
if (!c) return null;
|
|
126
|
+
try { return c.toDataURL(${JSON.stringify(mimeType)}); } catch { return null; }
|
|
127
|
+
})()`;
|
|
128
|
+
const dataUrl = await page.evaluate(evalScript);
|
|
129
|
+
if (dataUrl) {
|
|
130
|
+
// Strip the data URL prefix to get raw base64
|
|
131
|
+
const base64 = dataUrl.replace(/^data:image\/[^;]+;base64,/, '');
|
|
132
|
+
return { base64, mimeType };
|
|
133
|
+
}
|
|
134
|
+
// Fallback: take a screenshot
|
|
135
|
+
console.error('Canvas toDataURL failed, falling back to screenshot');
|
|
136
|
+
const screenshotBuffer = await page.screenshot({
|
|
137
|
+
type: format === 'jpeg' ? 'jpeg' : format === 'webp' ? 'webp' : 'png',
|
|
138
|
+
...(format !== 'png' ? { quality } : {}),
|
|
139
|
+
fullPage: false,
|
|
140
|
+
});
|
|
141
|
+
const base64 = Buffer.from(screenshotBuffer).toString('base64');
|
|
142
|
+
return { base64, mimeType };
|
|
143
|
+
}
|
|
144
|
+
finally {
|
|
145
|
+
await page.close();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../src/tools/render.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;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CAAC,CAAA;YAChE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAA;QAC7B,CAAC;QAED,8BAA8B;QAC9B,OAAO,CAAC,KAAK,CAAC,qDAAqD,CAAC,CAAA;QACpE,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC;YAC7C,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK;YACrE,GAAG,CAAC,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACxC,QAAQ,EAAE,KAAK;SAChB,CAAC,CAAA;QAEF,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;QAC/D,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAA;IAC7B,CAAC;YAAS,CAAC;QACT,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;IACpB,CAAC;AACH,CAAC"}
|
package/dist/tools/state.d.ts
CHANGED
|
@@ -13,8 +13,17 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import type { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
15
15
|
type AspectRatio = '16:9' | '9:16' | '1:1' | '4:3' | '3:4' | 'full';
|
|
16
|
+
type LayoutMode = 'absolute' | 'row' | 'column';
|
|
17
|
+
type JustifyContent = 'start' | 'center' | 'end' | 'space-between' | 'space-around' | 'space-evenly';
|
|
18
|
+
type AlignItems = 'start' | 'center' | 'end';
|
|
19
|
+
interface LayoutPadding {
|
|
20
|
+
top: number;
|
|
21
|
+
right: number;
|
|
22
|
+
bottom: number;
|
|
23
|
+
left: number;
|
|
24
|
+
}
|
|
16
25
|
type EffectId = 'none' | 'ascii-standard' | 'ascii-blocks' | 'ascii-braille' | 'ascii-hatching' | 'ascii-matrix' | 'ascii-technical' | 'ascii-dense' | 'ascii-minimal' | 'dither-floyd-steinberg' | 'dither-atkinson' | 'dither-jarvis-judice-ninke' | 'dither-stucki' | 'dither-burkes' | 'dither-sierra' | 'dither-two-row-sierra' | 'dither-sierra-lite' | 'halftone-mono' | 'halftone-cmyk' | 'glitch-chromatic' | 'glitch-digital' | 'glitch-vhs' | 'glitch-weird' | 'art-kuwahara' | 'art-crosshatch' | 'art-lineart' | 'art-engraving' | 'art-stipple';
|
|
17
|
-
type PostProcessType = 'scanlines' | 'vignette' | 'chromatic-aberration' | 'curvature' | 'grain' | 'noise' | 'pixelate' | 'wave' | 'rgb-glitch' | 'brightness-contrast' | 'color-tint' | 'palette' | 'jitter' | 'bloom' | 'dot-screen' | 'sepia' | 'grid' | 'light-beams' | 'motion-blur';
|
|
26
|
+
type PostProcessType = 'scanlines' | 'vignette' | 'chromatic-aberration' | 'curvature' | 'grain' | 'noise' | 'pixelate' | 'wave' | 'rgb-glitch' | 'brightness-contrast' | 'color-tint' | 'palette' | 'jitter' | 'bloom' | 'dot-screen' | 'sepia' | 'grid' | 'light-beams' | 'motion-blur' | 'blob-tracking';
|
|
18
27
|
type TextAnimationType = 'wave' | 'rotate' | 'scale' | 'orbit' | 'bounce' | 'shake' | 'spiral' | 'typewriter' | 'glitch' | 'elastic' | 'cascade' | 'neon';
|
|
19
28
|
type StaggerMode = 'sequential' | 'random' | 'center-out' | 'edges-in';
|
|
20
29
|
interface TextAnimationSettings {
|
|
@@ -31,6 +40,9 @@ interface BaseAnimationParams {
|
|
|
31
40
|
loop: boolean;
|
|
32
41
|
}
|
|
33
42
|
type TextAnimationParams = BaseAnimationParams & Record<string, unknown>;
|
|
43
|
+
type FlexChildPositioning = 'flow' | 'absolute';
|
|
44
|
+
type FlexChildSizeMode = 'hug' | 'fixed' | 'fill';
|
|
45
|
+
type FlexChildAlignSelf = 'auto' | 'start' | 'center' | 'end' | 'stretch';
|
|
34
46
|
interface LayerTransform {
|
|
35
47
|
x: number;
|
|
36
48
|
y: number;
|
|
@@ -38,6 +50,8 @@ interface LayerTransform {
|
|
|
38
50
|
height: number;
|
|
39
51
|
rotation: number;
|
|
40
52
|
opacity: number;
|
|
53
|
+
originX?: number;
|
|
54
|
+
originY?: number;
|
|
41
55
|
}
|
|
42
56
|
interface BaseLayer {
|
|
43
57
|
id: string;
|
|
@@ -45,7 +59,31 @@ interface BaseLayer {
|
|
|
45
59
|
type: string;
|
|
46
60
|
visible: boolean;
|
|
47
61
|
locked: boolean;
|
|
62
|
+
positioning?: FlexChildPositioning;
|
|
63
|
+
flexSizeMode?: FlexChildSizeMode;
|
|
64
|
+
flexWidthMode?: FlexChildSizeMode;
|
|
65
|
+
flexHeightMode?: FlexChildSizeMode;
|
|
66
|
+
alignSelf?: FlexChildAlignSelf;
|
|
67
|
+
flexGrow?: number;
|
|
48
68
|
transform: LayerTransform;
|
|
69
|
+
shadow?: {
|
|
70
|
+
offsetX: number;
|
|
71
|
+
offsetY: number;
|
|
72
|
+
blur: number;
|
|
73
|
+
color: string;
|
|
74
|
+
opacity: number;
|
|
75
|
+
};
|
|
76
|
+
blendMode?: string;
|
|
77
|
+
margin?: {
|
|
78
|
+
top: number;
|
|
79
|
+
right: number;
|
|
80
|
+
bottom: number;
|
|
81
|
+
left: number;
|
|
82
|
+
};
|
|
83
|
+
minWidth?: number;
|
|
84
|
+
maxWidth?: number;
|
|
85
|
+
minHeight?: number;
|
|
86
|
+
maxHeight?: number;
|
|
49
87
|
}
|
|
50
88
|
interface TextLayer extends BaseLayer {
|
|
51
89
|
type: 'text';
|
|
@@ -56,6 +94,7 @@ interface TextLayer extends BaseLayer {
|
|
|
56
94
|
fontWeight: string;
|
|
57
95
|
color: string;
|
|
58
96
|
textAlign: 'left' | 'center' | 'right';
|
|
97
|
+
verticalAlign?: 'top' | 'middle' | 'bottom';
|
|
59
98
|
letterSpacing: number;
|
|
60
99
|
lineHeight: number;
|
|
61
100
|
textTransformMode?: 'scale' | 'box';
|
|
@@ -63,6 +102,11 @@ interface TextLayer extends BaseLayer {
|
|
|
63
102
|
frameWidthPx?: number;
|
|
64
103
|
frameHeightPx?: number;
|
|
65
104
|
autoSize?: 'none' | 'height' | 'widthAndHeight';
|
|
105
|
+
clipContent?: boolean;
|
|
106
|
+
textTransform?: 'uppercase' | 'lowercase' | 'capitalize';
|
|
107
|
+
textDecoration?: 'underline' | 'line-through' | 'overline';
|
|
108
|
+
textDecorationColor?: string;
|
|
109
|
+
textDecorationThickness?: number;
|
|
66
110
|
animation?: TextAnimationSettings;
|
|
67
111
|
}
|
|
68
112
|
interface ImageLayer extends BaseLayer {
|
|
@@ -134,6 +178,14 @@ interface PosterState {
|
|
|
134
178
|
canvas: {
|
|
135
179
|
aspectRatio: AspectRatio;
|
|
136
180
|
backgroundColor: string;
|
|
181
|
+
canvasColor?: string;
|
|
182
|
+
overflow?: 'visible' | 'hidden' | 'translucent';
|
|
183
|
+
layoutMode?: LayoutMode;
|
|
184
|
+
justifyContent?: JustifyContent;
|
|
185
|
+
alignItems?: AlignItems;
|
|
186
|
+
wrap?: boolean;
|
|
187
|
+
gap?: number;
|
|
188
|
+
padding?: LayoutPadding;
|
|
137
189
|
};
|
|
138
190
|
layers: Layer[];
|
|
139
191
|
effect?: {
|
|
@@ -155,6 +207,11 @@ interface PosterState {
|
|
|
155
207
|
};
|
|
156
208
|
postProcesses: PostProcessInstance[];
|
|
157
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* Ensure a poster exists. Restores from persisted file if needed,
|
|
212
|
+
* or auto-creates a default poster as a last resort.
|
|
213
|
+
*/
|
|
214
|
+
export declare function ensurePoster(): PosterState;
|
|
158
215
|
export declare function resetState(): void;
|
|
159
216
|
export declare function getCurrentState(): PosterState | null;
|
|
160
217
|
export declare const stateTools: Tool[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/tools/state.ts"],"names":[],"mappings":"AA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