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,6 +1,14 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { executeJsx } from '../../executor/jsx-runner.js';
|
|
3
|
-
import {
|
|
3
|
+
import { coordinateSystemSchema, resolveCoordinateSystem, } from '../session.js';
|
|
4
|
+
import { colorSchema, strokeSchema, COLOR_HELPERS_JSX, FONT_HELPERS_JSX, DESTRUCTIVE_ANNOTATIONS } from './shared.js';
|
|
5
|
+
/**
|
|
6
|
+
* modify_object — オブジェクトのプロパティ変更
|
|
7
|
+
* @see https://ai-scripting.docsforadobe.dev/jsobjref/PageItem/ — position, width, height, opacity, locked, hidden, name
|
|
8
|
+
*
|
|
9
|
+
* 注意: rotation の絶対角度指定は atan2(mValueB, mValueA) で現在角度を算出するため、
|
|
10
|
+
* skew/非等倍スケールされたオブジェクトでは不正確になる場合がある。
|
|
11
|
+
*/
|
|
4
12
|
const jsxCode = `
|
|
5
13
|
var preflight = preflightChecks();
|
|
6
14
|
if (preflight) {
|
|
@@ -13,28 +21,6 @@ if (preflight) {
|
|
|
13
21
|
${COLOR_HELPERS_JSX}
|
|
14
22
|
${FONT_HELPERS_JSX}
|
|
15
23
|
|
|
16
|
-
function findItemByUUID(uuid) {
|
|
17
|
-
var doc = app.activeDocument;
|
|
18
|
-
function search(items) {
|
|
19
|
-
for (var i = 0; i < items.length; i++) {
|
|
20
|
-
var item = items[i];
|
|
21
|
-
try {
|
|
22
|
-
if (item.note === uuid) return item;
|
|
23
|
-
} catch(e) {}
|
|
24
|
-
if (item.typename === "GroupItem") {
|
|
25
|
-
var found = search(item.pageItems);
|
|
26
|
-
if (found) return found;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
for (var li = 0; li < doc.layers.length; li++) {
|
|
32
|
-
var found = search(doc.layers[li].pageItems);
|
|
33
|
-
if (found) return found;
|
|
34
|
-
}
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
24
|
var item = findItemByUUID(params.uuid);
|
|
39
25
|
if (!item) {
|
|
40
26
|
writeResultFile(RESULT_PATH, { error: true, message: "No object found matching UUID: " + params.uuid });
|
|
@@ -44,15 +30,9 @@ if (preflight) {
|
|
|
44
30
|
|
|
45
31
|
if (props.position) {
|
|
46
32
|
try {
|
|
47
|
-
var
|
|
48
|
-
var
|
|
49
|
-
|
|
50
|
-
var ab = doc.artboards[doc.artboards.getActiveArtboardIndex()];
|
|
51
|
-
var abRect = ab.artboardRect;
|
|
52
|
-
px = abRect[0] + px;
|
|
53
|
-
py = abRect[1] + (-py);
|
|
54
|
-
}
|
|
55
|
-
item.position = [px, py];
|
|
33
|
+
var abRect = (coordSystem === "artboard-web") ? getActiveArtboardRect() : null;
|
|
34
|
+
var pos = webToAiPoint(props.position.x, props.position.y, coordSystem, abRect);
|
|
35
|
+
item.position = pos;
|
|
56
36
|
} catch(e) { errors.push("position: " + e.message); }
|
|
57
37
|
}
|
|
58
38
|
|
|
@@ -85,7 +65,18 @@ if (preflight) {
|
|
|
85
65
|
}
|
|
86
66
|
|
|
87
67
|
if (typeof props.rotation === "number") {
|
|
88
|
-
try {
|
|
68
|
+
try {
|
|
69
|
+
if (props.rotation_mode === "absolute") {
|
|
70
|
+
// 現在の回転角を Matrix から算出し、差分を rotate() に渡す
|
|
71
|
+
var m = item.matrix;
|
|
72
|
+
var currentRad = Math.atan2(m.mValueB, m.mValueA);
|
|
73
|
+
var currentDeg = currentRad * 180 / Math.PI;
|
|
74
|
+
var delta = props.rotation - currentDeg;
|
|
75
|
+
item.rotate(delta);
|
|
76
|
+
} else {
|
|
77
|
+
item.rotate(props.rotation);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
89
80
|
catch(e) { errors.push("rotation: " + e.message); }
|
|
90
81
|
}
|
|
91
82
|
|
|
@@ -95,7 +86,7 @@ if (preflight) {
|
|
|
95
86
|
}
|
|
96
87
|
|
|
97
88
|
if (typeof props.contents === "string") {
|
|
98
|
-
try { item.contents = props.contents; }
|
|
89
|
+
try { item.contents = props.contents.split(String.fromCharCode(10)).join(String.fromCharCode(13)); }
|
|
99
90
|
catch(e) { errors.push("contents: " + e.message); }
|
|
100
91
|
}
|
|
101
92
|
|
|
@@ -158,27 +149,20 @@ export function register(server) {
|
|
|
158
149
|
fill: colorSchema.describe('Fill color'),
|
|
159
150
|
stroke: strokeSchema.describe('Stroke settings'),
|
|
160
151
|
opacity: z.number().optional().describe('Opacity (0-100)'),
|
|
161
|
-
rotation: z.number().optional().describe('Rotation
|
|
152
|
+
rotation: z.number().optional().describe('Rotation in degrees. Default mode is "delta" (additive). Use rotation_mode: "absolute" for target angle.'),
|
|
153
|
+
rotation_mode: z.enum(['delta', 'absolute']).optional().default('delta').describe('delta = add to current rotation, absolute = set to exact angle'),
|
|
162
154
|
name: z.string().optional().describe('Object name'),
|
|
163
155
|
contents: z.string().optional().describe('Text contents (for text frames)'),
|
|
164
156
|
font_name: z.string().optional().describe('Font name for text frames (partial match supported)'),
|
|
165
157
|
font_size: z.number().optional().describe('Font size (for text frames)'),
|
|
166
158
|
})
|
|
167
159
|
.describe('Properties to modify'),
|
|
168
|
-
coordinate_system:
|
|
169
|
-
.enum(['artboard-web', 'document'])
|
|
170
|
-
.optional()
|
|
171
|
-
.default('artboard-web')
|
|
172
|
-
.describe('Coordinate system (artboard-web: artboard-relative Y-down, document: native Illustrator coordinates)'),
|
|
173
|
-
},
|
|
174
|
-
annotations: {
|
|
175
|
-
readOnlyHint: false,
|
|
176
|
-
destructiveHint: false,
|
|
177
|
-
idempotentHint: false,
|
|
178
|
-
openWorldHint: false,
|
|
160
|
+
coordinate_system: coordinateSystemSchema,
|
|
179
161
|
},
|
|
162
|
+
annotations: DESTRUCTIVE_ANNOTATIONS,
|
|
180
163
|
}, async (params) => {
|
|
181
|
-
const
|
|
164
|
+
const resolvedParams = { ...params, coordinate_system: await resolveCoordinateSystem(params.coordinate_system) };
|
|
165
|
+
const result = await executeJsx(jsxCode, resolvedParams, { activate: true });
|
|
182
166
|
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
183
167
|
});
|
|
184
168
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modify-object.js","sourceRoot":"","sources":["../../../src/tools/modify/modify-object.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"modify-object.js","sourceRoot":"","sources":["../../../src/tools/modify/modify-object.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EACL,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtH;;;;;;GAMG;A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0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"move-to-layer.d.ts","sourceRoot":"","sources":["../../../src/tools/modify/move-to-layer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAwDpE,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAuBhD"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { executeJsx } from '../../executor/jsx-runner.js';
|
|
3
|
+
import { WRITE_ANNOTATIONS } from './shared.js';
|
|
4
|
+
/**
|
|
5
|
+
* move_to_layer — オブジェクトを別レイヤーに移動
|
|
6
|
+
*
|
|
7
|
+
* @see https://ai-scripting.docsforadobe.dev/jsobjref/PageItem/ — PageItem.move()
|
|
8
|
+
*
|
|
9
|
+
* JSX API:
|
|
10
|
+
* PageItem.move(relativeObject: Layer, insertionLocation?: ElementPlacement) → PageItem
|
|
11
|
+
* ElementPlacement: PLACEATBEGINNING (最前面) | PLACEATEND (最背面)
|
|
12
|
+
*/
|
|
13
|
+
const jsxCode = `
|
|
14
|
+
var preflight = preflightChecks();
|
|
15
|
+
if (preflight) {
|
|
16
|
+
writeResultFile(RESULT_PATH, preflight);
|
|
17
|
+
} else {
|
|
18
|
+
try {
|
|
19
|
+
var params = readParamsFile(PARAMS_PATH);
|
|
20
|
+
var doc = app.activeDocument;
|
|
21
|
+
|
|
22
|
+
var targetLayer = null;
|
|
23
|
+
try {
|
|
24
|
+
targetLayer = doc.layers.getByName(params.target_layer);
|
|
25
|
+
} catch(e) {
|
|
26
|
+
writeResultFile(RESULT_PATH, { error: true, message: "Layer not found: " + params.target_layer });
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (targetLayer) {
|
|
30
|
+
var placement = (params.position === "end")
|
|
31
|
+
? ElementPlacement.PLACEATEND
|
|
32
|
+
: ElementPlacement.PLACEATBEGINNING;
|
|
33
|
+
|
|
34
|
+
var movedCount = 0;
|
|
35
|
+
for (var i = 0; i < params.uuids.length; i++) {
|
|
36
|
+
var item = findItemByUUID(params.uuids[i]);
|
|
37
|
+
if (item) {
|
|
38
|
+
item.move(targetLayer, placement);
|
|
39
|
+
movedCount++;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
writeResultFile(RESULT_PATH, {
|
|
44
|
+
success: true,
|
|
45
|
+
movedCount: movedCount,
|
|
46
|
+
targetLayer: params.target_layer
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
} catch (e) {
|
|
50
|
+
writeResultFile(RESULT_PATH, { error: true, message: "move_to_layer failed: " + e.message, line: e.line });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
`;
|
|
54
|
+
export function register(server) {
|
|
55
|
+
server.registerTool('move_to_layer', {
|
|
56
|
+
title: 'Move to Layer',
|
|
57
|
+
description: 'Move one or more objects to a different layer. Note: Illustrator will be activated (brought to foreground) during execution.',
|
|
58
|
+
inputSchema: {
|
|
59
|
+
uuids: z.array(z.string()).min(1).describe('UUIDs of objects to move'),
|
|
60
|
+
target_layer: z.string().describe('Target layer name'),
|
|
61
|
+
position: z
|
|
62
|
+
.enum(['beginning', 'end'])
|
|
63
|
+
.optional()
|
|
64
|
+
.default('beginning')
|
|
65
|
+
.describe('beginning = front of layer, end = back of layer'),
|
|
66
|
+
},
|
|
67
|
+
annotations: WRITE_ANNOTATIONS,
|
|
68
|
+
}, async (params) => {
|
|
69
|
+
const result = await executeJsx(jsxCode, params, { activate: true });
|
|
70
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=move-to-layer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"move-to-layer.js","sourceRoot":"","sources":["../../../src/tools/modify/move-to-layer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;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O,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAwDpE,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAsBhD"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { executeJsx } from '../../executor/jsx-runner.js';
|
|
3
|
+
import { invalidateAutoDetectCache } from '../session.js';
|
|
4
|
+
import { WRITE_ANNOTATIONS } from './shared.js';
|
|
5
|
+
/**
|
|
6
|
+
* open_document — ファイルパスからドキュメントを開く
|
|
7
|
+
*
|
|
8
|
+
* @see https://ai-scripting.docsforadobe.dev/jsobjref/Application/ — Application.open()
|
|
9
|
+
*
|
|
10
|
+
* JSX API:
|
|
11
|
+
* Application.open(file: File [, documentColorSpace: DocumentColorSpace]) → Document
|
|
12
|
+
*
|
|
13
|
+
* preflightChecks() はドキュメント未開封時にエラーを返すため、
|
|
14
|
+
* checkIllustratorVersion() のみ使用。
|
|
15
|
+
* handler 内で invalidateAutoDetectCache() を呼ぶ。
|
|
16
|
+
*/
|
|
17
|
+
const jsxCode = `
|
|
18
|
+
try {
|
|
19
|
+
var verErr = checkIllustratorVersion();
|
|
20
|
+
if (verErr) {
|
|
21
|
+
writeResultFile(RESULT_PATH, verErr);
|
|
22
|
+
} else {
|
|
23
|
+
var params = readParamsFile(PARAMS_PATH);
|
|
24
|
+
var openFile = new File(params.path);
|
|
25
|
+
if (!openFile.exists) {
|
|
26
|
+
writeResultFile(RESULT_PATH, { error: true, message: "File not found: " + params.path });
|
|
27
|
+
} else {
|
|
28
|
+
var colorSpace = null;
|
|
29
|
+
if (params.color_space === "RGB") colorSpace = DocumentColorSpace.RGB;
|
|
30
|
+
else if (params.color_space === "CMYK") colorSpace = DocumentColorSpace.CMYK;
|
|
31
|
+
|
|
32
|
+
var doc;
|
|
33
|
+
if (colorSpace) {
|
|
34
|
+
doc = app.open(openFile, colorSpace);
|
|
35
|
+
} else {
|
|
36
|
+
doc = app.open(openFile);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
var docName = doc.name;
|
|
40
|
+
var fullPath = "";
|
|
41
|
+
try { fullPath = doc.fullName.fsName; } catch(e) {}
|
|
42
|
+
writeResultFile(RESULT_PATH, {
|
|
43
|
+
success: true,
|
|
44
|
+
name: docName,
|
|
45
|
+
path: fullPath,
|
|
46
|
+
colorSpace: (doc.documentColorSpace === DocumentColorSpace.CMYK) ? "CMYK" : "RGB"
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
} catch (e) {
|
|
51
|
+
writeResultFile(RESULT_PATH, { error: true, message: "open_document failed: " + e.message, line: e.line });
|
|
52
|
+
}
|
|
53
|
+
`;
|
|
54
|
+
export function register(server) {
|
|
55
|
+
server.registerTool('open_document', {
|
|
56
|
+
title: 'Open Document',
|
|
57
|
+
description: 'Open an Illustrator document from a file path. Note: Illustrator will be activated (brought to foreground) during execution.',
|
|
58
|
+
inputSchema: {
|
|
59
|
+
path: z.string().describe('Absolute file path to open (.ai, .eps, .pdf, .svg, etc.)'),
|
|
60
|
+
color_space: z
|
|
61
|
+
.enum(['RGB', 'CMYK'])
|
|
62
|
+
.optional()
|
|
63
|
+
.describe('Force color space conversion on open. Omit to keep original.'),
|
|
64
|
+
},
|
|
65
|
+
annotations: WRITE_ANNOTATIONS,
|
|
66
|
+
}, async (params) => {
|
|
67
|
+
const result = await executeJsx(jsxCode, params, { activate: true });
|
|
68
|
+
invalidateAutoDetectCache();
|
|
69
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=open-document.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open-document.js","sourceRoot":"","sources":["../../../src/tools/modify/open-document.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8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+1,218 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { executeJsxHeavy } from '../../executor/jsx-runner.js';
|
|
3
|
+
import { coordinateSystemSchema, resolveCoordinateSystem, } from '../session.js';
|
|
4
|
+
import { WRITE_ANNOTATIONS } from './shared.js';
|
|
5
|
+
/**
|
|
6
|
+
* place_color_chips — ドキュメント使用色のカラーチップ配置
|
|
7
|
+
* @see https://ai-scripting.docsforadobe.dev/jsobjref/PathItems/ — PathItems.rectangle()
|
|
8
|
+
* @see https://ai-scripting.docsforadobe.dev/jsobjref/TextFrameItems/ — TextFrameItems.add()
|
|
9
|
+
*/
|
|
10
|
+
const jsxCode = `
|
|
11
|
+
var preflight = preflightChecks();
|
|
12
|
+
if (preflight) {
|
|
13
|
+
writeResultFile(RESULT_PATH, preflight);
|
|
14
|
+
} else {
|
|
15
|
+
try {
|
|
16
|
+
var params = readParamsFile(PARAMS_PATH);
|
|
17
|
+
var doc = app.activeDocument;
|
|
18
|
+
var abIdx = (typeof params.artboard_index === "number") ? params.artboard_index : doc.artboards.getActiveArtboardIndex();
|
|
19
|
+
var chipSize = (typeof params.chip_size === "number") ? params.chip_size : 30;
|
|
20
|
+
var position = params.position || "right";
|
|
21
|
+
var includeInfo = (typeof params.include_info === "boolean") ? params.include_info : true;
|
|
22
|
+
var layerName = params.layer_name || "Color Chips";
|
|
23
|
+
var isCMYKDoc = (doc.documentColorSpace === DocumentColorSpace.CMYK);
|
|
24
|
+
|
|
25
|
+
if (abIdx < 0 || abIdx >= doc.artboards.length) {
|
|
26
|
+
writeResultFile(RESULT_PATH, { error: true, message: "Artboard index out of range" });
|
|
27
|
+
} else {
|
|
28
|
+
var abRect = doc.artboards[abIdx].artboardRect;
|
|
29
|
+
|
|
30
|
+
// Collect unique colors
|
|
31
|
+
var colorMap = {};
|
|
32
|
+
var colorList = [];
|
|
33
|
+
|
|
34
|
+
function addColor(color) {
|
|
35
|
+
try {
|
|
36
|
+
var key = "";
|
|
37
|
+
if (color.typename === "CMYKColor") {
|
|
38
|
+
key = "cmyk_" + Math.round(color.cyan) + "_" + Math.round(color.magenta) + "_" + Math.round(color.yellow) + "_" + Math.round(color.black);
|
|
39
|
+
} else if (color.typename === "RGBColor") {
|
|
40
|
+
key = "rgb_" + Math.round(color.red) + "_" + Math.round(color.green) + "_" + Math.round(color.blue);
|
|
41
|
+
} else if (color.typename === "SpotColor") {
|
|
42
|
+
key = "spot_" + color.spot.name;
|
|
43
|
+
} else if (color.typename === "GrayColor") {
|
|
44
|
+
key = "gray_" + Math.round(color.gray);
|
|
45
|
+
} else {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (!colorMap[key]) {
|
|
49
|
+
colorMap[key] = true;
|
|
50
|
+
colorList.push({ color: color, key: key, info: colorToObject(color) });
|
|
51
|
+
}
|
|
52
|
+
} catch(e) {}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
for (var i = 0; i < doc.pathItems.length; i++) {
|
|
56
|
+
var item = doc.pathItems[i];
|
|
57
|
+
try { if (item.filled) addColor(item.fillColor); } catch(e) {}
|
|
58
|
+
try { if (item.stroked) addColor(item.strokeColor); } catch(e) {}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Get or create layer
|
|
62
|
+
var chipLayer = resolveTargetLayer(doc, layerName);
|
|
63
|
+
|
|
64
|
+
// Calculate start position
|
|
65
|
+
var startX, startY;
|
|
66
|
+
var gap = 8;
|
|
67
|
+
if (position === "right") {
|
|
68
|
+
startX = abRect[2] + 30; // 30pt right of artboard
|
|
69
|
+
startY = abRect[1]; // top of artboard
|
|
70
|
+
} else {
|
|
71
|
+
startX = abRect[0]; // left of artboard
|
|
72
|
+
startY = abRect[3] - 30; // 30pt below artboard
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
var placedCount = 0;
|
|
76
|
+
for (var ci = 0; ci < colorList.length; ci++) {
|
|
77
|
+
var entry = colorList[ci];
|
|
78
|
+
var chipX, chipY;
|
|
79
|
+
if (position === "right") {
|
|
80
|
+
chipX = startX;
|
|
81
|
+
chipY = startY - ci * (chipSize + gap);
|
|
82
|
+
} else {
|
|
83
|
+
chipX = startX + ci * (chipSize + gap + (includeInfo ? 80 : 0));
|
|
84
|
+
chipY = startY;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Create color chip rectangle
|
|
88
|
+
var rect = chipLayer.pathItems.rectangle(chipY, chipX, chipSize, chipSize);
|
|
89
|
+
try {
|
|
90
|
+
// Clone the color for the chip
|
|
91
|
+
if (entry.color.typename === "CMYKColor") {
|
|
92
|
+
var nc = new CMYKColor();
|
|
93
|
+
nc.cyan = entry.color.cyan;
|
|
94
|
+
nc.magenta = entry.color.magenta;
|
|
95
|
+
nc.yellow = entry.color.yellow;
|
|
96
|
+
nc.black = entry.color.black;
|
|
97
|
+
rect.fillColor = nc;
|
|
98
|
+
} else if (entry.color.typename === "RGBColor") {
|
|
99
|
+
var nr = new RGBColor();
|
|
100
|
+
nr.red = entry.color.red;
|
|
101
|
+
nr.green = entry.color.green;
|
|
102
|
+
nr.blue = entry.color.blue;
|
|
103
|
+
rect.fillColor = nr;
|
|
104
|
+
} else if (entry.color.typename === "SpotColor") {
|
|
105
|
+
var ns = new SpotColor();
|
|
106
|
+
ns.spot = entry.color.spot;
|
|
107
|
+
ns.tint = entry.color.tint;
|
|
108
|
+
rect.fillColor = ns;
|
|
109
|
+
} else if (entry.color.typename === "GrayColor") {
|
|
110
|
+
var ng = new GrayColor();
|
|
111
|
+
ng.gray = entry.color.gray;
|
|
112
|
+
rect.fillColor = ng;
|
|
113
|
+
}
|
|
114
|
+
} catch(e) {}
|
|
115
|
+
rect.stroked = true;
|
|
116
|
+
var strokeC = new GrayColor();
|
|
117
|
+
strokeC.gray = 80;
|
|
118
|
+
rect.strokeColor = strokeC;
|
|
119
|
+
rect.strokeWidth = 0.5;
|
|
120
|
+
|
|
121
|
+
// Add info text
|
|
122
|
+
if (includeInfo) {
|
|
123
|
+
var label = "";
|
|
124
|
+
var info = entry.info;
|
|
125
|
+
if (info.type === "cmyk") {
|
|
126
|
+
label = "C" + Math.round(info.c) + " M" + Math.round(info.m) + " Y" + Math.round(info.y) + " K" + Math.round(info.k);
|
|
127
|
+
} else if (info.type === "rgb") {
|
|
128
|
+
label = "R" + Math.round(info.r) + " G" + Math.round(info.g) + " B" + Math.round(info.b);
|
|
129
|
+
} else if (info.type === "spot") {
|
|
130
|
+
label = info.name;
|
|
131
|
+
} else if (info.type === "gray") {
|
|
132
|
+
label = "Gray " + Math.round(info.value) + "%";
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (label) {
|
|
136
|
+
var textX, textY;
|
|
137
|
+
if (position === "right") {
|
|
138
|
+
textX = chipX + chipSize + 6;
|
|
139
|
+
textY = chipY - 2;
|
|
140
|
+
} else {
|
|
141
|
+
textX = chipX;
|
|
142
|
+
textY = chipY - chipSize - 4;
|
|
143
|
+
}
|
|
144
|
+
var textFrame = chipLayer.textFrames.add();
|
|
145
|
+
textFrame.contents = label.split(String.fromCharCode(10)).join(String.fromCharCode(13));
|
|
146
|
+
textFrame.position = [textX, textY];
|
|
147
|
+
try {
|
|
148
|
+
textFrame.textRange.characterAttributes.size = 7;
|
|
149
|
+
// Set text to black/dark
|
|
150
|
+
if (isCMYKDoc) {
|
|
151
|
+
var tc = new CMYKColor();
|
|
152
|
+
tc.cyan = 0; tc.magenta = 0; tc.yellow = 0; tc.black = 100;
|
|
153
|
+
textFrame.textRange.characterAttributes.fillColor = tc;
|
|
154
|
+
} else {
|
|
155
|
+
var trgb = new RGBColor();
|
|
156
|
+
trgb.red = 0; trgb.green = 0; trgb.blue = 0;
|
|
157
|
+
textFrame.textRange.characterAttributes.fillColor = trgb;
|
|
158
|
+
}
|
|
159
|
+
} catch(e) {}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
placedCount++;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
writeResultFile(RESULT_PATH, {
|
|
167
|
+
success: true,
|
|
168
|
+
chipCount: placedCount,
|
|
169
|
+
layerName: layerName,
|
|
170
|
+
position: position
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
} catch (e) {
|
|
174
|
+
writeResultFile(RESULT_PATH, { error: true, message: "Place color chips failed: " + e.message, line: e.line });
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
`;
|
|
178
|
+
export function register(server) {
|
|
179
|
+
server.registerTool('place_color_chips', {
|
|
180
|
+
title: 'Place Color Chips',
|
|
181
|
+
description: 'Extract all unique colors from the document and place color chip swatches with labels outside the artboard',
|
|
182
|
+
inputSchema: {
|
|
183
|
+
artboard_index: z
|
|
184
|
+
.number()
|
|
185
|
+
.int()
|
|
186
|
+
.min(0)
|
|
187
|
+
.optional()
|
|
188
|
+
.describe('Target artboard (default: active artboard)'),
|
|
189
|
+
chip_size: z
|
|
190
|
+
.number()
|
|
191
|
+
.optional()
|
|
192
|
+
.default(30)
|
|
193
|
+
.describe('Chip size in points (default: 30)'),
|
|
194
|
+
position: z
|
|
195
|
+
.enum(['right', 'bottom'])
|
|
196
|
+
.optional()
|
|
197
|
+
.default('right')
|
|
198
|
+
.describe('Place chips to the right or below the artboard'),
|
|
199
|
+
include_info: z
|
|
200
|
+
.boolean()
|
|
201
|
+
.optional()
|
|
202
|
+
.default(true)
|
|
203
|
+
.describe('Include color value labels next to chips'),
|
|
204
|
+
layer_name: z
|
|
205
|
+
.string()
|
|
206
|
+
.optional()
|
|
207
|
+
.default('Color Chips')
|
|
208
|
+
.describe('Layer name for color chips'),
|
|
209
|
+
coordinate_system: coordinateSystemSchema,
|
|
210
|
+
},
|
|
211
|
+
annotations: WRITE_ANNOTATIONS,
|
|
212
|
+
}, async (params) => {
|
|
213
|
+
const resolvedParams = { ...params, coordinate_system: await resolveCoordinateSystem(params.coordinate_system) };
|
|
214
|
+
const result = await executeJsxHeavy(jsxCode, resolvedParams);
|
|
215
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
//# sourceMappingURL=place-color-chips.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"place-color-chips.js","sourceRoot":"","sources":["../../../src/tools/modify/place-color-chips.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EACL,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD;;;;GAIG;AACH,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuKf,CAAC;AAEF,MAAM,UAAU,QAAQ,CAAC,MAAiB;IACxC,MAAM,CAAC,YAAY,CACjB,mBAAmB,EACnB;QACE,KAAK,EAAE,mBAAmB;QAC1B,WAAW,EACT,4GAA4G;QAC9G,WAAW,EAAE;YACX,cAAc,EAAE,CAAC;iBACd,MAAM,EAAE;iBACR,GAAG,EAAE;iBACL,GAAG,CAAC,CAAC,CAAC;iBACN,QAAQ,EAAE;iBACV,QAAQ,CAAC,4CAA4C,CAAC;YACzD,SAAS,EAAE,CAAC;iBACT,MAAM,EAAE;iBACR,QAAQ,EAAE;iBACV,OAAO,CAAC,EAAE,CAAC;iBACX,QAAQ,CAAC,mCAAmC,CAAC;YAChD,QAAQ,EAAE,CAAC;iBACR,IAAI,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;iBACzB,QAAQ,EAAE;iBACV,OAAO,CAAC,OAAO,CAAC;iBAChB,QAAQ,CAAC,gDAAgD,CAAC;YAC7D,YAAY,EAAE,CAAC;iBACZ,OAAO,EAAE;iBACT,QAAQ,EAAE;iBACV,OAAO,CAAC,IAAI,CAAC;iBACb,QAAQ,CAAC,0CAA0C,CAAC;YACvD,UAAU,EAAE,CAAC;iBACV,MAAM,EAAE;iBACR,QAAQ,EAAE;iBACV,OAAO,CAAC,aAAa,CAAC;iBACtB,QAAQ,CAAC,4BAA4B,CAAC;YACzC,iBAAiB,EAAE,sBAAsB;SAC1C;QACD,WAAW,EAAE,iBAAiB;KAC/B,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,eAAe,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;QAC9D,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":"place-image.d.ts","sourceRoot":"","sources":["../../../src/tools/modify/place-image.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"place-image.d.ts","sourceRoot":"","sources":["../../../src/tools/modify/place-image.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AA8FpE,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA4BhD"}
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { executeJsx } from '../../executor/jsx-runner.js';
|
|
3
|
+
import { coordinateSystemSchema, resolveCoordinateSystem, } from '../session.js';
|
|
4
|
+
import { WRITE_ANNOTATIONS } from './shared.js';
|
|
5
|
+
/**
|
|
6
|
+
* place_image — 画像の配置(リンク/埋め込み)
|
|
7
|
+
* @see https://ai-scripting.docsforadobe.dev/jsobjref/PlacedItems/ — PlacedItems.add()
|
|
8
|
+
* @see https://ai-scripting.docsforadobe.dev/jsobjref/PlacedItem/ — file, embed()
|
|
9
|
+
*
|
|
10
|
+
* 注意: PlacedItem.file はリファレンスで read-only と記載されているが、
|
|
11
|
+
* PlacedItems.add() 後に設定する方法が PlacedItems のドキュメントで推奨されている。
|
|
12
|
+
*/
|
|
3
13
|
const jsxCode = `
|
|
4
14
|
var preflight = preflightChecks();
|
|
5
15
|
if (preflight) {
|
|
@@ -15,32 +25,17 @@ if (preflight) {
|
|
|
15
25
|
if (!imgFile.exists) {
|
|
16
26
|
writeResultFile(RESULT_PATH, { error: true, message: "Image file not found: " + filePath });
|
|
17
27
|
} else {
|
|
18
|
-
var targetLayer = doc.
|
|
19
|
-
if (params.layer_name) {
|
|
20
|
-
try {
|
|
21
|
-
targetLayer = doc.layers.getByName(params.layer_name);
|
|
22
|
-
} catch (e) {
|
|
23
|
-
targetLayer = doc.layers.add();
|
|
24
|
-
targetLayer.name = params.layer_name;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
28
|
+
var targetLayer = resolveTargetLayer(doc, params.layer_name);
|
|
27
29
|
|
|
28
30
|
var placed = targetLayer.placedItems.add();
|
|
29
31
|
placed.file = imgFile;
|
|
30
32
|
|
|
31
33
|
// Position
|
|
32
34
|
if (typeof params.x === "number" && typeof params.y === "number") {
|
|
33
|
-
var
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
var abRect = ab.artboardRect;
|
|
38
|
-
placed.left = abRect[0] + inputX;
|
|
39
|
-
placed.top = abRect[1] + (-inputY);
|
|
40
|
-
} else {
|
|
41
|
-
placed.left = inputX;
|
|
42
|
-
placed.top = inputY;
|
|
43
|
-
}
|
|
35
|
+
var abRect = (coordSystem === "artboard-web") ? getActiveArtboardRect() : null;
|
|
36
|
+
var pos = webToAiPoint(params.x, params.y, coordSystem, abRect);
|
|
37
|
+
placed.left = pos[0];
|
|
38
|
+
placed.top = pos[1];
|
|
44
39
|
}
|
|
45
40
|
|
|
46
41
|
if (params.name) {
|
|
@@ -55,16 +50,20 @@ if (preflight) {
|
|
|
55
50
|
placed.name = tag;
|
|
56
51
|
placed.embed();
|
|
57
52
|
// After embed(), 'placed' is no longer valid. Find the RasterItem by name.
|
|
53
|
+
var foundEmbedded = false;
|
|
58
54
|
for (var ri = 0; ri < doc.rasterItems.length; ri++) {
|
|
59
55
|
if (doc.rasterItems[ri].name === tag) {
|
|
60
56
|
resultItem = doc.rasterItems[ri];
|
|
57
|
+
foundEmbedded = true;
|
|
61
58
|
break;
|
|
62
59
|
}
|
|
63
60
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
if (!foundEmbedded) {
|
|
62
|
+
writeResultFile(RESULT_PATH, { error: true, message: "embed() succeeded but resulting RasterItem could not be found" });
|
|
63
|
+
return;
|
|
67
64
|
}
|
|
65
|
+
// タグ名をクリア(ユーザー指定名があれば復元、なければ空文字に)
|
|
66
|
+
resultItem.name = params.name || "";
|
|
68
67
|
}
|
|
69
68
|
|
|
70
69
|
var uuid = ensureUUID(resultItem);
|
|
@@ -102,20 +101,12 @@ export function register(server) {
|
|
|
102
101
|
.describe('Embed the image instead of linking (default: false)'),
|
|
103
102
|
layer_name: z.string().optional().describe('Target layer name'),
|
|
104
103
|
name: z.string().optional().describe('Object name'),
|
|
105
|
-
coordinate_system:
|
|
106
|
-
.enum(['artboard-web', 'document'])
|
|
107
|
-
.optional()
|
|
108
|
-
.default('artboard-web')
|
|
109
|
-
.describe('Coordinate system (artboard-web: artboard-relative Y-down, document: native Illustrator coordinates)'),
|
|
110
|
-
},
|
|
111
|
-
annotations: {
|
|
112
|
-
readOnlyHint: false,
|
|
113
|
-
destructiveHint: false,
|
|
114
|
-
idempotentHint: false,
|
|
115
|
-
openWorldHint: false,
|
|
104
|
+
coordinate_system: coordinateSystemSchema,
|
|
116
105
|
},
|
|
106
|
+
annotations: WRITE_ANNOTATIONS,
|
|
117
107
|
}, async (params) => {
|
|
118
|
-
const
|
|
108
|
+
const resolvedParams = { ...params, coordinate_system: await resolveCoordinateSystem(params.coordinate_system) };
|
|
109
|
+
const result = await executeJsx(jsxCode, resolvedParams, { activate: true });
|
|
119
110
|
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
120
111
|
});
|
|
121
112
|
}
|