illustrator-mcp-server 1.2.4 → 1.2.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/README.ja.md +525 -107
- package/README.md +510 -89
- package/dist/executor/jsx-runner.d.ts +1 -0
- package/dist/executor/jsx-runner.d.ts.map +1 -1
- package/dist/executor/jsx-runner.js +33 -19
- package/dist/executor/jsx-runner.js.map +1 -1
- package/dist/jsx/helpers/common.jsx +113 -7
- package/dist/prompts/print-preflight-workflow.d.ts +3 -0
- package/dist/prompts/print-preflight-workflow.d.ts.map +1 -0
- package/dist/prompts/print-preflight-workflow.js +45 -0
- package/dist/prompts/print-preflight-workflow.js.map +1 -0
- package/dist/prompts/quick-layout.d.ts +3 -0
- package/dist/prompts/quick-layout.d.ts.map +1 -0
- package/dist/prompts/quick-layout.js +42 -0
- package/dist/prompts/quick-layout.js.map +1 -0
- package/dist/prompts/registry.d.ts +3 -0
- package/dist/prompts/registry.d.ts.map +1 -0
- package/dist/prompts/registry.js +7 -0
- package/dist/prompts/registry.js.map +1 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +3 -1
- package/dist/server.js.map +1 -1
- package/dist/tools/export/export-pdf.d.ts.map +1 -1
- package/dist/tools/export/export-pdf.js +48 -18
- package/dist/tools/export/export-pdf.js.map +1 -1
- package/dist/tools/export/export.d.ts.map +1 -1
- package/dist/tools/export/export.js +41 -49
- package/dist/tools/export/export.js.map +1 -1
- package/dist/tools/modify/align-objects.d.ts +3 -0
- package/dist/tools/modify/align-objects.d.ts.map +1 -0
- package/dist/tools/modify/align-objects.js +195 -0
- package/dist/tools/modify/align-objects.js.map +1 -0
- package/dist/tools/modify/apply-color-profile.d.ts.map +1 -1
- package/dist/tools/modify/apply-color-profile.js +12 -10
- package/dist/tools/modify/apply-color-profile.js.map +1 -1
- package/dist/tools/modify/apply-graphic-style.d.ts +3 -0
- package/dist/tools/modify/apply-graphic-style.d.ts.map +1 -0
- package/dist/tools/modify/apply-graphic-style.js +100 -0
- package/dist/tools/modify/apply-graphic-style.js.map +1 -0
- package/dist/tools/modify/apply-text-style.d.ts +3 -0
- package/dist/tools/modify/apply-text-style.d.ts.map +1 -0
- package/dist/tools/modify/apply-text-style.js +117 -0
- package/dist/tools/modify/apply-text-style.js.map +1 -0
- package/dist/tools/modify/close-document.d.ts.map +1 -1
- package/dist/tools/modify/close-document.js +9 -9
- package/dist/tools/modify/close-document.js.map +1 -1
- package/dist/tools/modify/convert-to-outlines.d.ts.map +1 -1
- package/dist/tools/modify/convert-to-outlines.js +7 -29
- package/dist/tools/modify/convert-to-outlines.js.map +1 -1
- package/dist/tools/modify/create-document.d.ts.map +1 -1
- package/dist/tools/modify/create-document.js +8 -6
- package/dist/tools/modify/create-document.js.map +1 -1
- package/dist/tools/modify/create-ellipse.d.ts.map +1 -1
- package/dist/tools/modify/create-ellipse.js +15 -32
- package/dist/tools/modify/create-ellipse.js.map +1 -1
- package/dist/tools/modify/create-gradient.d.ts +3 -0
- package/dist/tools/modify/create-gradient.d.ts.map +1 -0
- package/dist/tools/modify/create-gradient.js +111 -0
- package/dist/tools/modify/create-gradient.js.map +1 -0
- package/dist/tools/modify/create-line.d.ts.map +1 -1
- package/dist/tools/modify/create-line.js +16 -36
- package/dist/tools/modify/create-line.js.map +1 -1
- package/dist/tools/modify/create-path-text.d.ts +3 -0
- package/dist/tools/modify/create-path-text.d.ts.map +1 -0
- package/dist/tools/modify/create-path-text.js +85 -0
- package/dist/tools/modify/create-path-text.js.map +1 -0
- package/dist/tools/modify/create-path.d.ts.map +1 -1
- package/dist/tools/modify/create-path.js +18 -38
- package/dist/tools/modify/create-path.js.map +1 -1
- package/dist/tools/modify/create-rectangle.d.ts.map +1 -1
- package/dist/tools/modify/create-rectangle.js +16 -32
- package/dist/tools/modify/create-rectangle.js.map +1 -1
- package/dist/tools/modify/create-text-frame.d.ts.map +1 -1
- package/dist/tools/modify/create-text-frame.js +27 -40
- package/dist/tools/modify/create-text-frame.js.map +1 -1
- package/dist/tools/modify/duplicate-objects.d.ts +3 -0
- package/dist/tools/modify/duplicate-objects.d.ts.map +1 -0
- package/dist/tools/modify/duplicate-objects.js +97 -0
- package/dist/tools/modify/duplicate-objects.js.map +1 -0
- package/dist/tools/modify/group-objects.d.ts +3 -0
- package/dist/tools/modify/group-objects.d.ts.map +1 -0
- package/dist/tools/modify/group-objects.js +79 -0
- package/dist/tools/modify/group-objects.js.map +1 -0
- package/dist/tools/modify/manage-artboards.d.ts +3 -0
- package/dist/tools/modify/manage-artboards.d.ts.map +1 -0
- package/dist/tools/modify/manage-artboards.js +142 -0
- package/dist/tools/modify/manage-artboards.js.map +1 -0
- package/dist/tools/modify/manage-datasets.d.ts +3 -0
- package/dist/tools/modify/manage-datasets.d.ts.map +1 -0
- package/dist/tools/modify/manage-datasets.js +126 -0
- package/dist/tools/modify/manage-datasets.js.map +1 -0
- package/dist/tools/modify/manage-layers.d.ts +3 -0
- package/dist/tools/modify/manage-layers.d.ts.map +1 -0
- package/dist/tools/modify/manage-layers.js +141 -0
- package/dist/tools/modify/manage-layers.js.map +1 -0
- package/dist/tools/modify/manage-linked-images.d.ts +3 -0
- package/dist/tools/modify/manage-linked-images.d.ts.map +1 -0
- package/dist/tools/modify/manage-linked-images.js +96 -0
- package/dist/tools/modify/manage-linked-images.js.map +1 -0
- package/dist/tools/modify/manage-swatches.d.ts +3 -0
- package/dist/tools/modify/manage-swatches.d.ts.map +1 -0
- package/dist/tools/modify/manage-swatches.js +78 -0
- package/dist/tools/modify/manage-swatches.js.map +1 -0
- package/dist/tools/modify/modify-object.d.ts.map +1 -1
- package/dist/tools/modify/modify-object.js +31 -47
- package/dist/tools/modify/modify-object.js.map +1 -1
- package/dist/tools/modify/move-to-layer.d.ts +3 -0
- package/dist/tools/modify/move-to-layer.d.ts.map +1 -0
- package/dist/tools/modify/move-to-layer.js +73 -0
- package/dist/tools/modify/move-to-layer.js.map +1 -0
- package/dist/tools/modify/open-document.d.ts +3 -0
- package/dist/tools/modify/open-document.d.ts.map +1 -0
- package/dist/tools/modify/open-document.js +72 -0
- package/dist/tools/modify/open-document.js.map +1 -0
- package/dist/tools/modify/place-color-chips.d.ts +3 -0
- package/dist/tools/modify/place-color-chips.d.ts.map +1 -0
- package/dist/tools/modify/place-color-chips.js +218 -0
- package/dist/tools/modify/place-color-chips.js.map +1 -0
- package/dist/tools/modify/place-image.d.ts.map +1 -1
- package/dist/tools/modify/place-image.js +26 -35
- package/dist/tools/modify/place-image.js.map +1 -1
- package/dist/tools/modify/place-symbol.d.ts +3 -0
- package/dist/tools/modify/place-symbol.d.ts.map +1 -0
- package/dist/tools/modify/place-symbol.js +96 -0
- package/dist/tools/modify/place-symbol.js.map +1 -0
- package/dist/tools/modify/replace-color.d.ts +3 -0
- package/dist/tools/modify/replace-color.d.ts.map +1 -0
- package/dist/tools/modify/replace-color.js +136 -0
- package/dist/tools/modify/replace-color.js.map +1 -0
- package/dist/tools/modify/resize-for-variation.d.ts +3 -0
- package/dist/tools/modify/resize-for-variation.d.ts.map +1 -0
- package/dist/tools/modify/resize-for-variation.js +169 -0
- package/dist/tools/modify/resize-for-variation.js.map +1 -0
- package/dist/tools/modify/save-document.d.ts +3 -0
- package/dist/tools/modify/save-document.d.ts.map +1 -0
- package/dist/tools/modify/save-document.js +63 -0
- package/dist/tools/modify/save-document.js.map +1 -0
- package/dist/tools/modify/set-z-order.d.ts +3 -0
- package/dist/tools/modify/set-z-order.d.ts.map +1 -0
- package/dist/tools/modify/set-z-order.js +60 -0
- package/dist/tools/modify/set-z-order.js.map +1 -0
- package/dist/tools/modify/shared.d.ts +49 -1
- package/dist/tools/modify/shared.d.ts.map +1 -1
- package/dist/tools/modify/shared.js +48 -4
- package/dist/tools/modify/shared.js.map +1 -1
- package/dist/tools/modify/undo.d.ts +3 -0
- package/dist/tools/modify/undo.d.ts.map +1 -0
- package/dist/tools/modify/undo.js +64 -0
- package/dist/tools/modify/undo.js.map +1 -0
- package/dist/tools/modify/ungroup-objects.d.ts +3 -0
- package/dist/tools/modify/ungroup-objects.d.ts.map +1 -0
- package/dist/tools/modify/ungroup-objects.js +67 -0
- package/dist/tools/modify/ungroup-objects.js.map +1 -0
- package/dist/tools/read/check-contrast.d.ts +3 -0
- package/dist/tools/read/check-contrast.d.ts.map +1 -0
- package/dist/tools/read/check-contrast.js +239 -0
- package/dist/tools/read/check-contrast.js.map +1 -0
- package/dist/tools/read/convert-coordinate.d.ts +3 -0
- package/dist/tools/read/convert-coordinate.d.ts.map +1 -0
- package/dist/tools/read/convert-coordinate.js +74 -0
- package/dist/tools/read/convert-coordinate.js.map +1 -0
- package/dist/tools/read/extract-design-tokens.d.ts +3 -0
- package/dist/tools/read/extract-design-tokens.d.ts.map +1 -0
- package/dist/tools/read/extract-design-tokens.js +258 -0
- package/dist/tools/read/extract-design-tokens.js.map +1 -0
- package/dist/tools/read/find-objects.d.ts.map +1 -1
- package/dist/tools/read/find-objects.js +16 -37
- package/dist/tools/read/find-objects.js.map +1 -1
- package/dist/tools/read/get-artboards.d.ts.map +1 -1
- package/dist/tools/read/get-artboards.js +15 -13
- package/dist/tools/read/get-artboards.js.map +1 -1
- package/dist/tools/read/get-colors.d.ts.map +1 -1
- package/dist/tools/read/get-colors.js +93 -15
- package/dist/tools/read/get-colors.js.map +1 -1
- package/dist/tools/read/get-document-info.d.ts.map +1 -1
- package/dist/tools/read/get-document-info.js +47 -19
- package/dist/tools/read/get-document-info.js.map +1 -1
- package/dist/tools/read/get-document-structure.d.ts.map +1 -1
- package/dist/tools/read/get-document-structure.js +16 -24
- package/dist/tools/read/get-document-structure.js.map +1 -1
- package/dist/tools/read/get-effects.d.ts.map +1 -1
- package/dist/tools/read/get-effects.js +32 -43
- package/dist/tools/read/get-effects.js.map +1 -1
- package/dist/tools/read/get-groups.d.ts.map +1 -1
- package/dist/tools/read/get-groups.js +22 -26
- package/dist/tools/read/get-groups.js.map +1 -1
- package/dist/tools/read/get-guidelines.d.ts.map +1 -1
- package/dist/tools/read/get-guidelines.js +13 -16
- package/dist/tools/read/get-guidelines.js.map +1 -1
- package/dist/tools/read/get-images.d.ts.map +1 -1
- package/dist/tools/read/get-images.js +43 -25
- package/dist/tools/read/get-images.js.map +1 -1
- package/dist/tools/read/get-layers.d.ts.map +1 -1
- package/dist/tools/read/get-layers.js +14 -15
- package/dist/tools/read/get-layers.js.map +1 -1
- package/dist/tools/read/get-overprint-info.d.ts.map +1 -1
- package/dist/tools/read/get-overprint-info.js +72 -63
- package/dist/tools/read/get-overprint-info.js.map +1 -1
- package/dist/tools/read/get-path-items.d.ts.map +1 -1
- package/dist/tools/read/get-path-items.js +26 -20
- package/dist/tools/read/get-path-items.js.map +1 -1
- package/dist/tools/read/get-selection.d.ts.map +1 -1
- package/dist/tools/read/get-selection.js +19 -33
- package/dist/tools/read/get-selection.js.map +1 -1
- package/dist/tools/read/get-separation-info.d.ts +3 -0
- package/dist/tools/read/get-separation-info.d.ts.map +1 -0
- package/dist/tools/read/get-separation-info.js +94 -0
- package/dist/tools/read/get-separation-info.js.map +1 -0
- package/dist/tools/read/get-symbols.d.ts.map +1 -1
- package/dist/tools/read/get-symbols.js +19 -23
- package/dist/tools/read/get-symbols.js.map +1 -1
- package/dist/tools/read/get-text-frame-detail.d.ts.map +1 -1
- package/dist/tools/read/get-text-frame-detail.js +270 -67
- package/dist/tools/read/get-text-frame-detail.js.map +1 -1
- package/dist/tools/read/list-fonts.d.ts +3 -0
- package/dist/tools/read/list-fonts.d.ts.map +1 -0
- package/dist/tools/read/list-fonts.js +78 -0
- package/dist/tools/read/list-fonts.js.map +1 -0
- package/dist/tools/read/list-text-frames.d.ts.map +1 -1
- package/dist/tools/read/list-text-frames.js +99 -36
- package/dist/tools/read/list-text-frames.js.map +1 -1
- package/dist/tools/registry.d.ts.map +1 -1
- package/dist/tools/registry.js +60 -0
- package/dist/tools/registry.js.map +1 -1
- package/dist/tools/session.d.ts +36 -0
- package/dist/tools/session.d.ts.map +1 -0
- package/dist/tools/session.js +246 -0
- package/dist/tools/session.js.map +1 -0
- package/dist/tools/utility/check-text-consistency.d.ts +3 -0
- package/dist/tools/utility/check-text-consistency.d.ts.map +1 -0
- package/dist/tools/utility/check-text-consistency.js +303 -0
- package/dist/tools/utility/check-text-consistency.js.map +1 -0
- package/dist/tools/utility/preflight-check.d.ts.map +1 -1
- package/dist/tools/utility/preflight-check.js +141 -43
- package/dist/tools/utility/preflight-check.js.map +1 -1
- package/dist/tools/utility/set-workflow.d.ts +3 -0
- package/dist/tools/utility/set-workflow.d.ts.map +1 -0
- package/dist/tools/utility/set-workflow.js +95 -0
- package/dist/tools/utility/set-workflow.js.map +1 -0
- package/dist/utils/image-header.d.ts.map +1 -1
- package/dist/utils/image-header.js +5 -1
- package/dist/utils/image-header.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { executeJsxHeavy } from '../../executor/jsx-runner.js';
|
|
3
|
+
import { WRITE_IDEMPOTENT_ANNOTATIONS, coerceBoolean } from '../modify/shared.js';
|
|
4
|
+
/**
|
|
5
|
+
* export — SVG/PNG/JPG/WebP 書き出し
|
|
6
|
+
* @see https://ai-scripting.docsforadobe.dev/jsobjref/Document/ — exportFile()
|
|
7
|
+
* @see https://ai-scripting.docsforadobe.dev/jsobjref/ExportOptionsPNG24/
|
|
8
|
+
* @see https://ai-scripting.docsforadobe.dev/jsobjref/ExportOptionsSVG/
|
|
9
|
+
* @see https://ai-scripting.docsforadobe.dev/jsobjref/ExportOptionsJPEG/
|
|
10
|
+
*
|
|
11
|
+
* 注意: SVGIdType / idType はリファレンスに記載がないが try/catch で安全に処理。
|
|
12
|
+
*/
|
|
3
13
|
const jsxCode = `
|
|
4
14
|
var preflight = preflightChecks();
|
|
5
15
|
if (preflight) {
|
|
@@ -39,27 +49,7 @@ if (preflight) {
|
|
|
39
49
|
} else {
|
|
40
50
|
// UUID target — find and select (UUID は item.note に格納)
|
|
41
51
|
targetType = "uuid";
|
|
42
|
-
|
|
43
|
-
for (var i = 0; i < items.length; i++) {
|
|
44
|
-
var item = items[i];
|
|
45
|
-
try {
|
|
46
|
-
if (item.note === uuid) return item;
|
|
47
|
-
} catch(ex) {}
|
|
48
|
-
if (item.typename === "GroupItem") {
|
|
49
|
-
try {
|
|
50
|
-
var child = findByUUID(item.pageItems, uuid);
|
|
51
|
-
if (child) return child;
|
|
52
|
-
} catch(ex2) {}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
// 全レイヤーを走査
|
|
58
|
-
var targetItem = null;
|
|
59
|
-
for (var li = 0; li < doc.layers.length; li++) {
|
|
60
|
-
targetItem = findByUUID(doc.layers[li].pageItems, target);
|
|
61
|
-
if (targetItem) break;
|
|
62
|
-
}
|
|
52
|
+
var targetItem = findItemByUUID(target);
|
|
63
53
|
if (!targetItem) {
|
|
64
54
|
writeResultFile(RESULT_PATH, { error: true, message: "No object found matching UUID: " + target });
|
|
65
55
|
targetType = "error";
|
|
@@ -70,8 +60,9 @@ if (preflight) {
|
|
|
70
60
|
}
|
|
71
61
|
}
|
|
72
62
|
|
|
63
|
+
var outFile = null;
|
|
73
64
|
if (targetType !== "error") {
|
|
74
|
-
|
|
65
|
+
outFile = new File(outputPath);
|
|
75
66
|
var parentFolder = outFile.parent;
|
|
76
67
|
if (!parentFolder.exists) {
|
|
77
68
|
writeResultFile(RESULT_PATH, { error: true, message: "Output directory does not exist: " + parentFolder.fsName });
|
|
@@ -80,10 +71,9 @@ if (preflight) {
|
|
|
80
71
|
}
|
|
81
72
|
|
|
82
73
|
if (targetType !== "error") {
|
|
83
|
-
var outFile = new File(outputPath);
|
|
84
|
-
|
|
85
74
|
// UUID指定かつラスタ形式の場合、一時ドキュメントにコピーして書き出す
|
|
86
|
-
var
|
|
75
|
+
var isUUIDTarget = (targetType === "selection" && target !== "selection");
|
|
76
|
+
var useIsolatedExport = (isUUIDTarget && (format === "png" || format === "jpg"));
|
|
87
77
|
|
|
88
78
|
if (useIsolatedExport) {
|
|
89
79
|
// 選択オブジェクトをコピー
|
|
@@ -96,6 +86,7 @@ if (preflight) {
|
|
|
96
86
|
|
|
97
87
|
// 一時ドキュメントを作成
|
|
98
88
|
var tempDoc = app.documents.add(doc.documentColorSpace, objW, objH);
|
|
89
|
+
try {
|
|
99
90
|
tempDoc.artboards[0].artboardRect = [0, objH, objW, 0];
|
|
100
91
|
|
|
101
92
|
// ペースト
|
|
@@ -142,8 +133,10 @@ if (preflight) {
|
|
|
142
133
|
tempDoc.exportFile(outFile, ExportType.JPEG, jpgOpts);
|
|
143
134
|
}
|
|
144
135
|
|
|
145
|
-
|
|
136
|
+
} finally {
|
|
137
|
+
// 一時ドキュメントを閉じる(エクスポート失敗時もリーク防止)
|
|
146
138
|
tempDoc.close(SaveOptions.DONOTSAVECHANGES);
|
|
139
|
+
}
|
|
147
140
|
|
|
148
141
|
} else {
|
|
149
142
|
// 従来の書き出しロジック(artboard / selection / SVG)
|
|
@@ -162,13 +155,15 @@ if (preflight) {
|
|
|
162
155
|
if (typeof svgOpts.embed_images !== "undefined") {
|
|
163
156
|
opts.embedRasterImages = svgOpts.embed_images;
|
|
164
157
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
158
|
+
try {
|
|
159
|
+
if (svgOpts.id_naming === "layer") {
|
|
160
|
+
opts.idType = SVGIdType.SVGIDMINIMAL;
|
|
161
|
+
} else if (svgOpts.id_naming === "object") {
|
|
162
|
+
opts.idType = SVGIdType.SVGIDUNIQUE;
|
|
163
|
+
} else {
|
|
164
|
+
opts.idType = SVGIdType.SVGIDREGULAR;
|
|
165
|
+
}
|
|
166
|
+
} catch (_) { /* SVGIdType may not exist in some ExtendScript versions */ }
|
|
172
167
|
if (typeof svgOpts.decimal_places === "number") {
|
|
173
168
|
opts.coordinatePrecision = svgOpts.decimal_places;
|
|
174
169
|
}
|
|
@@ -199,8 +194,6 @@ if (preflight) {
|
|
|
199
194
|
if (targetType === "artboard") {
|
|
200
195
|
doc.artboards.setActiveArtboardIndex(artboardIndex);
|
|
201
196
|
pngOpts.artBoardClipping = true;
|
|
202
|
-
pngOpts.saveMultipleArtboards = true;
|
|
203
|
-
pngOpts.artboardRange = String(artboardIndex + 1);
|
|
204
197
|
} else if (targetType === "selection") {
|
|
205
198
|
pngOpts.artBoardClipping = false;
|
|
206
199
|
}
|
|
@@ -218,8 +211,6 @@ if (preflight) {
|
|
|
218
211
|
if (targetType === "artboard") {
|
|
219
212
|
doc.artboards.setActiveArtboardIndex(artboardIndex);
|
|
220
213
|
jpgOpts.artBoardClipping = true;
|
|
221
|
-
jpgOpts.saveMultipleArtboards = true;
|
|
222
|
-
jpgOpts.artboardRange = String(artboardIndex + 1);
|
|
223
214
|
} else if (targetType === "selection") {
|
|
224
215
|
jpgOpts.artBoardClipping = false;
|
|
225
216
|
}
|
|
@@ -234,7 +225,13 @@ if (preflight) {
|
|
|
234
225
|
if (!verifyFile.exists) {
|
|
235
226
|
writeResultFile(RESULT_PATH, { error: true, message: "Export completed but output file was not created. The path may not be writable: " + outputPath });
|
|
236
227
|
} else {
|
|
237
|
-
|
|
228
|
+
var resultInfo = { success: true, output_path: outputPath, format: format };
|
|
229
|
+
if (format === "png" || format === "jpg") {
|
|
230
|
+
var effectiveDpi = (rasterOpts.dpi || 72) * scale;
|
|
231
|
+
resultInfo.dpi = effectiveDpi;
|
|
232
|
+
resultInfo.scale = scale;
|
|
233
|
+
}
|
|
234
|
+
writeResultFile(RESULT_PATH, resultInfo);
|
|
238
235
|
}
|
|
239
236
|
}
|
|
240
237
|
|
|
@@ -251,7 +248,7 @@ export function register(server) {
|
|
|
251
248
|
inputSchema: {
|
|
252
249
|
target: z
|
|
253
250
|
.string()
|
|
254
|
-
.describe('UUID, "artboard:<index>", or "selection"'),
|
|
251
|
+
.describe('UUID, "artboard:<index>", or "selection". When exporting a UUID target as PNG/JPG, a temporary document is created internally (selection state may change).'),
|
|
255
252
|
// WebP is not supported by ExtendScript API
|
|
256
253
|
// format: z.enum(['svg', 'png', 'webp', 'jpg']).describe('Export format'),
|
|
257
254
|
format: z.enum(['svg', 'png', 'jpg']).describe('Export format'),
|
|
@@ -259,9 +256,9 @@ export function register(server) {
|
|
|
259
256
|
scale: z.number().optional().default(1).describe('Scale factor'),
|
|
260
257
|
svg_options: z
|
|
261
258
|
.object({
|
|
262
|
-
text_outline:
|
|
263
|
-
css_properties:
|
|
264
|
-
embed_images:
|
|
259
|
+
text_outline: coerceBoolean.optional().describe('Convert text to outlines'),
|
|
260
|
+
css_properties: coerceBoolean.optional().describe('Export as CSS properties'),
|
|
261
|
+
embed_images: coerceBoolean.optional().describe('Embed raster images'),
|
|
265
262
|
id_naming: z
|
|
266
263
|
.enum(['layer', 'object', 'auto'])
|
|
267
264
|
.optional()
|
|
@@ -277,17 +274,12 @@ export function register(server) {
|
|
|
277
274
|
.string()
|
|
278
275
|
.optional()
|
|
279
276
|
.describe('"transparent", "white", or color code'),
|
|
280
|
-
antialiasing:
|
|
277
|
+
antialiasing: coerceBoolean.optional().describe('Anti-aliasing'),
|
|
281
278
|
})
|
|
282
279
|
.optional()
|
|
283
280
|
.describe('Raster export options'),
|
|
284
281
|
},
|
|
285
|
-
annotations:
|
|
286
|
-
readOnlyHint: false,
|
|
287
|
-
destructiveHint: false,
|
|
288
|
-
idempotentHint: true,
|
|
289
|
-
openWorldHint: false,
|
|
290
|
-
},
|
|
282
|
+
annotations: WRITE_IDEMPOTENT_ANNOTATIONS,
|
|
291
283
|
}, async (params) => {
|
|
292
284
|
const result = await executeJsxHeavy(jsxCode, params);
|
|
293
285
|
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.js","sourceRoot":"","sources":["../../../src/tools/export/export.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;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CAAC;IAChF,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"align-objects.d.ts","sourceRoot":"","sources":["../../../src/tools/modify/align-objects.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAyKpE,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAkChD"}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { executeJsx } from '../../executor/jsx-runner.js';
|
|
3
|
+
import { coordinateSystemSchema, resolveCoordinateSystem, } from '../session.js';
|
|
4
|
+
import { WRITE_ANNOTATIONS } from './shared.js';
|
|
5
|
+
/**
|
|
6
|
+
* align_objects — オブジェクトの整列・均等配置
|
|
7
|
+
* @see https://ai-scripting.docsforadobe.dev/jsobjref/PageItem/ — geometricBounds, position, translate()
|
|
8
|
+
*/
|
|
9
|
+
const jsxCode = `
|
|
10
|
+
var preflight = preflightChecks();
|
|
11
|
+
if (preflight) {
|
|
12
|
+
writeResultFile(RESULT_PATH, preflight);
|
|
13
|
+
} else {
|
|
14
|
+
try {
|
|
15
|
+
var params = readParamsFile(PARAMS_PATH);
|
|
16
|
+
var doc = app.activeDocument;
|
|
17
|
+
var uuids = params.uuids;
|
|
18
|
+
var alignment = params.alignment;
|
|
19
|
+
var distribute = params.distribute || null;
|
|
20
|
+
var reference = params.reference || "selection";
|
|
21
|
+
|
|
22
|
+
if (!alignment && !distribute) {
|
|
23
|
+
writeResultFile(RESULT_PATH, { error: true, message: "At least one of alignment or distribute must be specified" });
|
|
24
|
+
} else if (!uuids || uuids.length < 2) {
|
|
25
|
+
writeResultFile(RESULT_PATH, { error: true, message: "At least 2 UUIDs are required" });
|
|
26
|
+
} else {
|
|
27
|
+
// Collect items by UUID
|
|
28
|
+
var items = [];
|
|
29
|
+
for (var i = 0; i < uuids.length; i++) {
|
|
30
|
+
var found = findItemByUUID(uuids[i]);
|
|
31
|
+
if (found) {
|
|
32
|
+
items.push(found);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (items.length < 2) {
|
|
37
|
+
writeResultFile(RESULT_PATH, { error: true, message: "Could not find at least 2 objects with the given UUIDs" });
|
|
38
|
+
} else {
|
|
39
|
+
// Pre-cache all bounds (1回のDOM アクセスで済ませる)
|
|
40
|
+
var boundsCache = [];
|
|
41
|
+
for (var bi = 0; bi < items.length; bi++) {
|
|
42
|
+
boundsCache.push(items[bi].geometricBounds);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Get reference bounds
|
|
46
|
+
var refLeft, refRight, refTop, refBottom;
|
|
47
|
+
if (reference === "artboard") {
|
|
48
|
+
var abIdx = doc.artboards.getActiveArtboardIndex();
|
|
49
|
+
var abRect = getArtboardRectByIndex(abIdx);
|
|
50
|
+
if (!abRect) {
|
|
51
|
+
writeResultFile(RESULT_PATH, { error: true, message: "Could not resolve active artboard" });
|
|
52
|
+
items = []; // alignment/distribution をスキップ
|
|
53
|
+
} else {
|
|
54
|
+
refLeft = abRect[0];
|
|
55
|
+
refTop = abRect[1];
|
|
56
|
+
refRight = abRect[2];
|
|
57
|
+
refBottom = abRect[3];
|
|
58
|
+
}
|
|
59
|
+
} else {
|
|
60
|
+
refLeft = Infinity;
|
|
61
|
+
refTop = -Infinity;
|
|
62
|
+
refRight = -Infinity;
|
|
63
|
+
refBottom = Infinity;
|
|
64
|
+
for (var si = 0; si < boundsCache.length; si++) {
|
|
65
|
+
var sb = boundsCache[si];
|
|
66
|
+
if (sb[0] < refLeft) refLeft = sb[0];
|
|
67
|
+
if (sb[1] > refTop) refTop = sb[1];
|
|
68
|
+
if (sb[2] > refRight) refRight = sb[2];
|
|
69
|
+
if (sb[3] < refBottom) refBottom = sb[3];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Alignment
|
|
74
|
+
if (alignment) {
|
|
75
|
+
for (var ai = 0; ai < items.length; ai++) {
|
|
76
|
+
var b = boundsCache[ai];
|
|
77
|
+
var w = b[2] - b[0];
|
|
78
|
+
var h = b[1] - b[3];
|
|
79
|
+
|
|
80
|
+
if (alignment === "left") {
|
|
81
|
+
items[ai].position = [refLeft, b[1]];
|
|
82
|
+
} else if (alignment === "right") {
|
|
83
|
+
items[ai].position = [refRight - w, b[1]];
|
|
84
|
+
} else if (alignment === "center_h") {
|
|
85
|
+
var cx = (refLeft + refRight) / 2;
|
|
86
|
+
items[ai].position = [cx - w / 2, b[1]];
|
|
87
|
+
} else if (alignment === "top") {
|
|
88
|
+
items[ai].position = [b[0], refTop];
|
|
89
|
+
} else if (alignment === "bottom") {
|
|
90
|
+
items[ai].position = [b[0], refBottom + h];
|
|
91
|
+
} else if (alignment === "center_v") {
|
|
92
|
+
var cy = (refTop + refBottom) / 2;
|
|
93
|
+
items[ai].position = [b[0], cy + h / 2];
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Distribution (bounds を再取得 — alignment で位置が変わっている可能性あり)
|
|
99
|
+
if (distribute) {
|
|
100
|
+
// 整列後の bounds を再取得
|
|
101
|
+
var distBounds = [];
|
|
102
|
+
for (var dbi = 0; dbi < items.length; dbi++) {
|
|
103
|
+
distBounds.push(items[dbi].geometricBounds);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// ソート用のインデックス配列を構築(bounds と item の対応を維持)
|
|
107
|
+
var indices = [];
|
|
108
|
+
for (var ii = 0; ii < items.length; ii++) { indices.push(ii); }
|
|
109
|
+
|
|
110
|
+
if (distribute === "horizontal") {
|
|
111
|
+
indices.sort(function(a, b) { return distBounds[a][0] - distBounds[b][0]; });
|
|
112
|
+
var totalWidth = 0;
|
|
113
|
+
for (var di = 0; di < indices.length; di++) {
|
|
114
|
+
var db = distBounds[indices[di]];
|
|
115
|
+
totalWidth += (db[2] - db[0]);
|
|
116
|
+
}
|
|
117
|
+
var firstLeft = distBounds[indices[0]][0];
|
|
118
|
+
var lastRight = distBounds[indices[indices.length - 1]][2];
|
|
119
|
+
var totalSpace = (lastRight - firstLeft) - totalWidth;
|
|
120
|
+
var gap = totalSpace / (indices.length - 1);
|
|
121
|
+
var currentX = firstLeft;
|
|
122
|
+
for (var di2 = 0; di2 < indices.length; di2++) {
|
|
123
|
+
var idx = indices[di2];
|
|
124
|
+
var itemW = distBounds[idx][2] - distBounds[idx][0];
|
|
125
|
+
items[idx].position = [currentX, distBounds[idx][1]];
|
|
126
|
+
currentX += itemW + gap;
|
|
127
|
+
}
|
|
128
|
+
} else if (distribute === "vertical") {
|
|
129
|
+
indices.sort(function(a, b) { return distBounds[b][1] - distBounds[a][1]; });
|
|
130
|
+
var totalHeight = 0;
|
|
131
|
+
for (var dj = 0; dj < indices.length; dj++) {
|
|
132
|
+
var dbv = distBounds[indices[dj]];
|
|
133
|
+
totalHeight += (dbv[1] - dbv[3]);
|
|
134
|
+
}
|
|
135
|
+
var firstTop = distBounds[indices[0]][1];
|
|
136
|
+
var lastBottom = distBounds[indices[indices.length - 1]][3];
|
|
137
|
+
var totalSpaceV = (firstTop - lastBottom) - totalHeight;
|
|
138
|
+
var gapV = totalSpaceV / (indices.length - 1);
|
|
139
|
+
var currentY = firstTop;
|
|
140
|
+
for (var dj2 = 0; dj2 < indices.length; dj2++) {
|
|
141
|
+
var idxV = indices[dj2];
|
|
142
|
+
var itemH = distBounds[idxV][1] - distBounds[idxV][3];
|
|
143
|
+
items[idxV].position = [distBounds[idxV][0], currentY];
|
|
144
|
+
currentY -= itemH + gapV;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (items.length > 0) {
|
|
150
|
+
writeResultFile(RESULT_PATH, {
|
|
151
|
+
success: true,
|
|
152
|
+
alignedCount: items.length,
|
|
153
|
+
alignment: alignment || null,
|
|
154
|
+
distribute: distribute
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
} catch (e) {
|
|
160
|
+
writeResultFile(RESULT_PATH, { error: true, message: "Align failed: " + e.message, line: e.line });
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
`;
|
|
164
|
+
export function register(server) {
|
|
165
|
+
server.registerTool('align_objects', {
|
|
166
|
+
title: 'Align Objects',
|
|
167
|
+
description: 'Align and/or distribute multiple objects by their UUIDs',
|
|
168
|
+
inputSchema: {
|
|
169
|
+
uuids: z
|
|
170
|
+
.array(z.string())
|
|
171
|
+
.min(2)
|
|
172
|
+
.describe('UUIDs of objects to align (minimum 2)'),
|
|
173
|
+
alignment: z
|
|
174
|
+
.enum(['left', 'center_h', 'right', 'top', 'center_v', 'bottom'])
|
|
175
|
+
.optional()
|
|
176
|
+
.describe('Alignment direction'),
|
|
177
|
+
distribute: z
|
|
178
|
+
.enum(['horizontal', 'vertical'])
|
|
179
|
+
.optional()
|
|
180
|
+
.describe('Distribute objects evenly'),
|
|
181
|
+
reference: z
|
|
182
|
+
.enum(['selection', 'artboard'])
|
|
183
|
+
.optional()
|
|
184
|
+
.default('selection')
|
|
185
|
+
.describe('Align relative to selection bounding box or active artboard'),
|
|
186
|
+
coordinate_system: coordinateSystemSchema,
|
|
187
|
+
},
|
|
188
|
+
annotations: WRITE_ANNOTATIONS,
|
|
189
|
+
}, async (params) => {
|
|
190
|
+
const resolvedParams = { ...params, coordinate_system: await resolveCoordinateSystem(params.coordinate_system) };
|
|
191
|
+
const result = await executeJsx(jsxCode, resolvedParams);
|
|
192
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
//# sourceMappingURL=align-objects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"align-objects.js","sourceRoot":"","sources":["../../../src/tools/modify/align-objects.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;A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,EACD,KAAK,EAAE,MAAM,EAAE,EAAE;QACf,MAAM,cAAc,GAAG,EAAE,GAAG,MAAM,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC,MAAM,CAAC,iBAAiB,CAAC,EAAE,CAAC;QACjH,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;QACzD,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IAChF,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply-color-profile.d.ts","sourceRoot":"","sources":["../../../src/tools/modify/apply-color-profile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"apply-color-profile.d.ts","sourceRoot":"","sources":["../../../src/tools/modify/apply-color-profile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAuDpE,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAgBhD"}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { executeJsx } from '../../executor/jsx-runner.js';
|
|
3
|
+
import { DESTRUCTIVE_ANNOTATIONS } from './shared.js';
|
|
4
|
+
/**
|
|
5
|
+
* assign_color_profile — カラープロファイルの割り当て
|
|
6
|
+
*
|
|
7
|
+
* 注意: Document.colorProfileName はリファレンスに記載がないが、実際のIllustratorでは動作する。
|
|
8
|
+
*/
|
|
3
9
|
const jsxCode = `
|
|
4
10
|
var preflight = preflightChecks();
|
|
5
11
|
if (preflight) {
|
|
@@ -32,7 +38,8 @@ if (preflight) {
|
|
|
32
38
|
|
|
33
39
|
if (!hasError) {
|
|
34
40
|
writeResultFile(RESULT_PATH, {
|
|
35
|
-
|
|
41
|
+
assigned: true,
|
|
42
|
+
converted: false,
|
|
36
43
|
previousProfile: oldProfile,
|
|
37
44
|
newProfile: profile,
|
|
38
45
|
note: note
|
|
@@ -44,18 +51,13 @@ if (preflight) {
|
|
|
44
51
|
}
|
|
45
52
|
`;
|
|
46
53
|
export function register(server) {
|
|
47
|
-
server.registerTool('
|
|
48
|
-
title: '
|
|
49
|
-
description: '
|
|
54
|
+
server.registerTool('assign_color_profile', {
|
|
55
|
+
title: 'Assign Color Profile',
|
|
56
|
+
description: 'Assign (tag) a color profile to the document. WARNING: This only changes the profile tag — it does NOT convert color values (ICC conversion). For full conversion, use Edit > Convert to Profile in Illustrator. Note: Illustrator will be activated (brought to foreground) during execution.',
|
|
50
57
|
inputSchema: {
|
|
51
58
|
profile: z.string().describe('Color profile name or path'),
|
|
52
59
|
},
|
|
53
|
-
annotations:
|
|
54
|
-
readOnlyHint: false,
|
|
55
|
-
destructiveHint: true,
|
|
56
|
-
idempotentHint: true,
|
|
57
|
-
openWorldHint: false,
|
|
58
|
-
},
|
|
60
|
+
annotations: DESTRUCTIVE_ANNOTATIONS,
|
|
59
61
|
}, async (params) => {
|
|
60
62
|
const result = await executeJsx(jsxCode, params, { activate: true });
|
|
61
63
|
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply-color-profile.js","sourceRoot":"","sources":["../../../src/tools/modify/apply-color-profile.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"apply-color-profile.js","sourceRoot":"","sources":["../../../src/tools/modify/apply-color-profile.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD;;;;GAIG;AACH,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2Cf,CAAC;AAEF,MAAM,UAAU,QAAQ,CAAC,MAAiB;IACxC,MAAM,CAAC,YAAY,CACjB,sBAAsB,EACtB;QACE,KAAK,EAAE,sBAAsB;QAC7B,WAAW,EAAE,gSAAgS;QAC7S,WAAW,EAAE;YACX,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,4BAA4B,CAAC;SAC3D;QACD,WAAW,EAAE,uBAAuB;KACrC,EACD,KAAK,EAAE,MAAM,EAAE,EAAE;QACf,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QACrE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IAChF,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply-graphic-style.d.ts","sourceRoot":"","sources":["../../../src/tools/modify/apply-graphic-style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AA4EpE,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAoChD"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { executeJsx } from '../../executor/jsx-runner.js';
|
|
3
|
+
import { READ_ANNOTATIONS, WRITE_ANNOTATIONS, coerceBoolean } from './shared.js';
|
|
4
|
+
/**
|
|
5
|
+
* apply_graphic_style / list_graphic_styles
|
|
6
|
+
*
|
|
7
|
+
* @see https://ai-scripting.docsforadobe.dev/jsobjref/GraphicStyle/ — GraphicStyle.applyTo(), mergeTo()
|
|
8
|
+
*
|
|
9
|
+
* JSX API:
|
|
10
|
+
* Document.graphicStyles → GraphicStyles コレクション
|
|
11
|
+
* GraphicStyles.getByName(name: String) → GraphicStyle
|
|
12
|
+
* GraphicStyle.applyTo(artItem: PageItem) → void
|
|
13
|
+
* GraphicStyle.mergeTo(artItem: PageItem) → void
|
|
14
|
+
*/
|
|
15
|
+
const applyJsxCode = `
|
|
16
|
+
var preflight = preflightChecks();
|
|
17
|
+
if (preflight) {
|
|
18
|
+
writeResultFile(RESULT_PATH, preflight);
|
|
19
|
+
} else {
|
|
20
|
+
try {
|
|
21
|
+
var params = readParamsFile(PARAMS_PATH);
|
|
22
|
+
var doc = app.activeDocument;
|
|
23
|
+
|
|
24
|
+
var style = null;
|
|
25
|
+
try {
|
|
26
|
+
style = doc.graphicStyles.getByName(params.style_name);
|
|
27
|
+
} catch(e) {
|
|
28
|
+
writeResultFile(RESULT_PATH, { error: true, message: "Graphic style not found: " + params.style_name });
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (style) {
|
|
32
|
+
var appliedCount = 0;
|
|
33
|
+
for (var i = 0; i < params.uuids.length; i++) {
|
|
34
|
+
var item = findItemByUUID(params.uuids[i]);
|
|
35
|
+
if (item) {
|
|
36
|
+
if (params.merge === true) {
|
|
37
|
+
style.mergeTo(item);
|
|
38
|
+
} else {
|
|
39
|
+
style.applyTo(item);
|
|
40
|
+
}
|
|
41
|
+
appliedCount++;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
writeResultFile(RESULT_PATH, {
|
|
45
|
+
success: true,
|
|
46
|
+
styleName: params.style_name,
|
|
47
|
+
appliedCount: appliedCount,
|
|
48
|
+
merge: params.merge === true
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
} catch (e) {
|
|
52
|
+
writeResultFile(RESULT_PATH, { error: true, message: "apply_graphic_style failed: " + e.message, line: e.line });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
`;
|
|
56
|
+
const listJsxCode = `
|
|
57
|
+
var preflight = preflightChecks();
|
|
58
|
+
if (preflight) {
|
|
59
|
+
writeResultFile(RESULT_PATH, preflight);
|
|
60
|
+
} else {
|
|
61
|
+
try {
|
|
62
|
+
var doc = app.activeDocument;
|
|
63
|
+
var styles = [];
|
|
64
|
+
for (var i = 0; i < doc.graphicStyles.length; i++) {
|
|
65
|
+
styles.push({ index: i, name: doc.graphicStyles[i].name });
|
|
66
|
+
}
|
|
67
|
+
writeResultFile(RESULT_PATH, { count: styles.length, styles: styles });
|
|
68
|
+
} catch (e) {
|
|
69
|
+
writeResultFile(RESULT_PATH, { error: true, message: "list_graphic_styles failed: " + e.message, line: e.line });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
`;
|
|
73
|
+
export function register(server) {
|
|
74
|
+
server.registerTool('apply_graphic_style', {
|
|
75
|
+
title: 'Apply Graphic Style',
|
|
76
|
+
description: 'Apply a graphic style to objects. Note: Illustrator will be activated (brought to foreground) during execution.',
|
|
77
|
+
inputSchema: {
|
|
78
|
+
style_name: z.string().describe('Name of the graphic style to apply'),
|
|
79
|
+
uuids: z.array(z.string()).min(1).describe('UUIDs of target objects'),
|
|
80
|
+
merge: coerceBoolean
|
|
81
|
+
.optional()
|
|
82
|
+
.default(false)
|
|
83
|
+
.describe('true = merge with existing appearance, false = replace'),
|
|
84
|
+
},
|
|
85
|
+
annotations: WRITE_ANNOTATIONS,
|
|
86
|
+
}, async (params) => {
|
|
87
|
+
const result = await executeJsx(applyJsxCode, params, { activate: true });
|
|
88
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
89
|
+
});
|
|
90
|
+
server.registerTool('list_graphic_styles', {
|
|
91
|
+
title: 'List Graphic Styles',
|
|
92
|
+
description: 'List all graphic styles in the active document.',
|
|
93
|
+
inputSchema: {},
|
|
94
|
+
annotations: READ_ANNOTATIONS,
|
|
95
|
+
}, async (params) => {
|
|
96
|
+
const result = await executeJsx(listJsxCode, params);
|
|
97
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=apply-graphic-style.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply-graphic-style.js","sourceRoot":"","sources":["../../../src/tools/modify/apply-graphic-style.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjF;;;;;;;;;;GAUG;AACH,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwCpB,CAAC;AAEF,MAAM,WAAW,GAAG;;;;;;;;;;;;;;;;CAgBnB,CAAC;AAEF,MAAM,UAAU,QAAQ,CAAC,MAAiB;IACxC,MAAM,CAAC,YAAY,CACjB,qBAAqB,EACrB;QACE,KAAK,EAAE,qBAAqB;QAC5B,WAAW,EACT,iHAAiH;QACnH,WAAW,EAAE;YACX,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,oCAAoC,CAAC;YACrE,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,yBAAyB,CAAC;YACrE,KAAK,EAAE,aAAa;iBACjB,QAAQ,EAAE;iBACV,OAAO,CAAC,KAAK,CAAC;iBACd,QAAQ,CAAC,wDAAwD,CAAC;SACtE;QACD,WAAW,EAAE,iBAAiB;KAC/B,EACD,KAAK,EAA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