illustrator-mcp-server 1.2.3 → 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 +3 -0
- package/dist/tools/modify/close-document.d.ts.map +1 -0
- package/dist/tools/modify/close-document.js +46 -0
- package/dist/tools/modify/close-document.js.map +1 -0
- 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 +3 -0
- package/dist/tools/modify/create-document.d.ts.map +1 -0
- package/dist/tools/modify/create-document.js +67 -0
- package/dist/tools/modify/create-document.js.map +1 -0
- 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 +3 -0
- package/dist/tools/modify/place-image.d.ts.map +1 -0
- package/dist/tools/modify/place-image.js +113 -0
- package/dist/tools/modify/place-image.js.map +1 -0
- 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 +68 -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
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { executeJsx } from '../../executor/jsx-runner.js';
|
|
3
|
+
import { WRITE_ANNOTATIONS } from './shared.js';
|
|
4
|
+
/**
|
|
5
|
+
* set_z_order — オブジェクトの重ね順を変更
|
|
6
|
+
*
|
|
7
|
+
* @see https://ai-scripting.docsforadobe.dev/jsobjref/PageItem/ — PageItem.zOrder()
|
|
8
|
+
*
|
|
9
|
+
* JSX API:
|
|
10
|
+
* PageItem.zOrder(zOrderCmd: ZOrderMethod) → void
|
|
11
|
+
* ZOrderMethod: BRINGTOFRONT | BRINGFORWARD | SENDBACKWARD | SENDTOBACK
|
|
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
|
+
|
|
21
|
+
var item = findItemByUUID(params.uuid);
|
|
22
|
+
if (!item) {
|
|
23
|
+
writeResultFile(RESULT_PATH, { error: true, message: "Object not found: " + params.uuid });
|
|
24
|
+
} else {
|
|
25
|
+
var cmdMap = {
|
|
26
|
+
"bring_to_front": ZOrderMethod.BRINGTOFRONT,
|
|
27
|
+
"bring_forward": ZOrderMethod.BRINGFORWARD,
|
|
28
|
+
"send_backward": ZOrderMethod.SENDBACKWARD,
|
|
29
|
+
"send_to_back": ZOrderMethod.SENDTOBACK
|
|
30
|
+
};
|
|
31
|
+
item.zOrder(cmdMap[params.command]);
|
|
32
|
+
writeResultFile(RESULT_PATH, {
|
|
33
|
+
success: true,
|
|
34
|
+
uuid: params.uuid,
|
|
35
|
+
command: params.command,
|
|
36
|
+
newZIndex: getZIndex(item)
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
} catch (e) {
|
|
40
|
+
writeResultFile(RESULT_PATH, { error: true, message: "set_z_order failed: " + e.message, line: e.line });
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
44
|
+
export function register(server) {
|
|
45
|
+
server.registerTool('set_z_order', {
|
|
46
|
+
title: 'Set Z-Order',
|
|
47
|
+
description: 'Change the stacking order of an object. Note: Illustrator will be activated (brought to foreground) during execution.',
|
|
48
|
+
inputSchema: {
|
|
49
|
+
uuid: z.string().describe('UUID of the object'),
|
|
50
|
+
command: z
|
|
51
|
+
.enum(['bring_to_front', 'bring_forward', 'send_backward', 'send_to_back'])
|
|
52
|
+
.describe('Stacking order command'),
|
|
53
|
+
},
|
|
54
|
+
annotations: WRITE_ANNOTATIONS,
|
|
55
|
+
}, async (params) => {
|
|
56
|
+
const result = await executeJsx(jsxCode, params, { activate: true });
|
|
57
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=set-z-order.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-z-order.js","sourceRoot":"","sources":["../../../src/tools/modify/set-z-order.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD;;;;;;;;GAQG;AACH,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8Bf,CAAC;AAEF,MAAM,UAAU,QAAQ,CAAC,MAAiB;IACxC,MAAM,CAAC,YAAY,CACjB,aAAa,EACb;QACE,KAAK,EAAE,aAAa;QACpB,WAAW,EACT,uHAAuH;QACzH,WAAW,EAAE;YACX,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,oBAAoB,CAAC;YAC/C,OAAO,EAAE,CAAC;iBACP,IAAI,CAAC,CAAC,gBAAgB,EAAE,eAAe,EAAE,eAAe,EAAE,cAAc,CAAC,CAAC;iBAC1E,QAAQ,CAAC,wBAAwB,CAAC;SACtC;QACD,WAAW,EAAE,iBAAiB;KAC/B,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"}
|
|
@@ -1,4 +1,46 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
export declare const coerceBoolean: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodBoolean>;
|
|
3
|
+
export declare const READ_ANNOTATIONS: {
|
|
4
|
+
readonly readOnlyHint: true;
|
|
5
|
+
readonly destructiveHint: false;
|
|
6
|
+
readonly idempotentHint: true;
|
|
7
|
+
readonly openWorldHint: false;
|
|
8
|
+
};
|
|
9
|
+
export declare const WRITE_ANNOTATIONS: {
|
|
10
|
+
readonly readOnlyHint: false;
|
|
11
|
+
readonly destructiveHint: false;
|
|
12
|
+
readonly idempotentHint: false;
|
|
13
|
+
readonly openWorldHint: false;
|
|
14
|
+
};
|
|
15
|
+
export declare const WRITE_IDEMPOTENT_ANNOTATIONS: {
|
|
16
|
+
readonly readOnlyHint: false;
|
|
17
|
+
readonly destructiveHint: false;
|
|
18
|
+
readonly idempotentHint: true;
|
|
19
|
+
readonly openWorldHint: false;
|
|
20
|
+
};
|
|
21
|
+
export declare const DESTRUCTIVE_ANNOTATIONS: {
|
|
22
|
+
readonly readOnlyHint: false;
|
|
23
|
+
readonly destructiveHint: true;
|
|
24
|
+
readonly idempotentHint: false;
|
|
25
|
+
readonly openWorldHint: false;
|
|
26
|
+
};
|
|
27
|
+
export declare const cmykColorSchema: z.ZodObject<{
|
|
28
|
+
type: z.ZodLiteral<"cmyk">;
|
|
29
|
+
c: z.ZodNumber;
|
|
30
|
+
m: z.ZodNumber;
|
|
31
|
+
y: z.ZodNumber;
|
|
32
|
+
k: z.ZodNumber;
|
|
33
|
+
}, z.core.$strip>;
|
|
34
|
+
export declare const rgbColorSchema: z.ZodObject<{
|
|
35
|
+
type: z.ZodLiteral<"rgb">;
|
|
36
|
+
r: z.ZodNumber;
|
|
37
|
+
g: z.ZodNumber;
|
|
38
|
+
b: z.ZodNumber;
|
|
39
|
+
}, z.core.$strip>;
|
|
40
|
+
export declare const grayColorSchema: z.ZodObject<{
|
|
41
|
+
type: z.ZodLiteral<"gray">;
|
|
42
|
+
value: z.ZodNumber;
|
|
43
|
+
}, z.core.$strip>;
|
|
2
44
|
export declare const colorSchema: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
3
45
|
type: z.ZodLiteral<"cmyk">;
|
|
4
46
|
c: z.ZodNumber;
|
|
@@ -10,6 +52,9 @@ export declare const colorSchema: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodOb
|
|
|
10
52
|
r: z.ZodNumber;
|
|
11
53
|
g: z.ZodNumber;
|
|
12
54
|
b: z.ZodNumber;
|
|
55
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
56
|
+
type: z.ZodLiteral<"gray">;
|
|
57
|
+
value: z.ZodNumber;
|
|
13
58
|
}, z.core.$strip>, z.ZodObject<{
|
|
14
59
|
type: z.ZodLiteral<"none">;
|
|
15
60
|
}, z.core.$strip>], "type">>;
|
|
@@ -25,11 +70,14 @@ export declare const strokeSchema: z.ZodOptional<z.ZodObject<{
|
|
|
25
70
|
r: z.ZodNumber;
|
|
26
71
|
g: z.ZodNumber;
|
|
27
72
|
b: z.ZodNumber;
|
|
73
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
74
|
+
type: z.ZodLiteral<"gray">;
|
|
75
|
+
value: z.ZodNumber;
|
|
28
76
|
}, z.core.$strip>, z.ZodObject<{
|
|
29
77
|
type: z.ZodLiteral<"none">;
|
|
30
78
|
}, z.core.$strip>], "type">>;
|
|
31
79
|
width: z.ZodOptional<z.ZodNumber>;
|
|
32
80
|
}, z.core.$strip>>;
|
|
33
81
|
export declare const FONT_HELPERS_JSX = "\nfunction findFontCandidates(fontName) {\n var candidates = [];\n var searchLower = fontName.toLowerCase();\n for (var fi = 0; fi < app.textFonts.length; fi++) {\n var f = app.textFonts[fi];\n if (f.name.toLowerCase().indexOf(searchLower) >= 0 ||\n (f.family && f.family.toLowerCase().indexOf(searchLower) >= 0)) {\n candidates.push({ name: f.name, family: f.family });\n if (candidates.length >= 10) break;\n }\n }\n return candidates;\n}\n";
|
|
34
|
-
export declare const COLOR_HELPERS_JSX = "\nfunction createColor(colorObj) {\n if (!colorObj || colorObj.type === \"none\") return new NoColor();\n if (colorObj.type === \"cmyk\") {\n var c = new CMYKColor();\n c.cyan = colorObj.c;\n c.magenta = colorObj.m;\n c.yellow = colorObj.y;\n c.black = colorObj.k;\n return c;\n }\n if (colorObj.type === \"rgb\") {\n var c = new RGBColor();\n c.red = colorObj.r;\n c.green = colorObj.g;\n c.blue = colorObj.b;\n return c;\n }\n return new NoColor();\n}\n\nfunction applyOptionalFill(item, colorObj) {\n if (typeof colorObj === \"undefined\") return;\n if (!colorObj || colorObj.type === \"none\") {\n item.filled = false;\n return;\n }\n item.fillColor = createColor(colorObj);\n item.filled = true;\n}\n\nfunction applyStroke(item, strokeObj, defaultStroked) {\n if (!strokeObj) {\n item.stroked = defaultStroked;\n return;\n }\n if (typeof strokeObj.width === \"number\") {\n item.strokeWidth = strokeObj.width;\n }\n if (strokeObj.color && strokeObj.color.type === \"none\") {\n item.stroked = false;\n return;\n }\n if (strokeObj.color) {\n item.strokeColor = createColor(strokeObj.color);\n
|
|
82
|
+
export declare const COLOR_HELPERS_JSX = "\nfunction createColor(colorObj) {\n if (!colorObj || colorObj.type === \"none\") return new NoColor();\n if (colorObj.type === \"cmyk\") {\n var c = new CMYKColor();\n c.cyan = colorObj.c;\n c.magenta = colorObj.m;\n c.yellow = colorObj.y;\n c.black = colorObj.k;\n return c;\n }\n if (colorObj.type === \"rgb\") {\n var c = new RGBColor();\n c.red = colorObj.r;\n c.green = colorObj.g;\n c.blue = colorObj.b;\n return c;\n }\n if (colorObj.type === \"gray\") {\n var c = new GrayColor();\n c.gray = colorObj.value;\n return c;\n }\n return new NoColor();\n}\n\nfunction applyOptionalFill(item, colorObj) {\n if (typeof colorObj === \"undefined\") return;\n if (!colorObj || colorObj.type === \"none\") {\n item.filled = false;\n return;\n }\n item.fillColor = createColor(colorObj);\n item.filled = true;\n}\n\nfunction applyStroke(item, strokeObj, defaultStroked) {\n if (!strokeObj) {\n item.stroked = defaultStroked;\n return;\n }\n if (typeof strokeObj.width === \"number\") {\n item.strokeWidth = strokeObj.width;\n }\n if (strokeObj.color && strokeObj.color.type === \"none\") {\n item.stroked = false;\n return;\n }\n if (strokeObj.color) {\n item.strokeColor = createColor(strokeObj.color);\n item.stroked = true;\n }\n}\n";
|
|
35
83
|
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/tools/modify/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/tools/modify/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,aAAa,2DASzB,CAAC;AAIF,eAAO,MAAM,gBAAgB;;;;;CAKnB,CAAC;AAEX,eAAO,MAAM,iBAAiB;;;;;CAKpB,CAAC;AAEX,eAAO,MAAM,4BAA4B;;;;;CAK/B,CAAC;AAEX,eAAO,MAAM,uBAAuB;;;;;CAK1B,CAAC;AAEX,eAAO,MAAM,eAAe;;;;;;iBAM1B,CAAC;AAEH,eAAO,MAAM,cAAc;;;;;iBAKzB,CAAC;AAEH,eAAO,MAAM,eAAe;;;iBAG1B,CAAC;AAMH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;4BAEX,CAAC;AAEd,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;kBAKZ,CAAC;AAEd,eAAO,MAAM,gBAAgB,8dAc5B,CAAC;AAEF,eAAO,MAAM,iBAAiB,+yCAqD7B,CAAC"}
|
|
@@ -1,22 +1,61 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
|
|
2
|
+
// --- boolean coerce (MCP クライアントが "true"/"false" 文字列を送る場合の対策) ---
|
|
3
|
+
export const coerceBoolean = z.preprocess((val) => {
|
|
4
|
+
if (typeof val === 'string') {
|
|
5
|
+
if (val === 'true')
|
|
6
|
+
return true;
|
|
7
|
+
if (val === 'false')
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
return val;
|
|
11
|
+
}, z.boolean());
|
|
12
|
+
// --- 共通 annotations 定数 ---
|
|
13
|
+
export const READ_ANNOTATIONS = {
|
|
14
|
+
readOnlyHint: true,
|
|
15
|
+
destructiveHint: false,
|
|
16
|
+
idempotentHint: true,
|
|
17
|
+
openWorldHint: false,
|
|
18
|
+
};
|
|
19
|
+
export const WRITE_ANNOTATIONS = {
|
|
20
|
+
readOnlyHint: false,
|
|
21
|
+
destructiveHint: false,
|
|
22
|
+
idempotentHint: false,
|
|
23
|
+
openWorldHint: false,
|
|
24
|
+
};
|
|
25
|
+
export const WRITE_IDEMPOTENT_ANNOTATIONS = {
|
|
26
|
+
readOnlyHint: false,
|
|
27
|
+
destructiveHint: false,
|
|
28
|
+
idempotentHint: true,
|
|
29
|
+
openWorldHint: false,
|
|
30
|
+
};
|
|
31
|
+
export const DESTRUCTIVE_ANNOTATIONS = {
|
|
32
|
+
readOnlyHint: false,
|
|
33
|
+
destructiveHint: true,
|
|
34
|
+
idempotentHint: false,
|
|
35
|
+
openWorldHint: false,
|
|
36
|
+
};
|
|
37
|
+
export const cmykColorSchema = z.object({
|
|
3
38
|
type: z.literal('cmyk').describe('Color type'),
|
|
4
39
|
c: z.number().describe('Cyan'),
|
|
5
40
|
m: z.number().describe('Magenta'),
|
|
6
41
|
y: z.number().describe('Yellow'),
|
|
7
42
|
k: z.number().describe('Black'),
|
|
8
43
|
});
|
|
9
|
-
const rgbColorSchema = z.object({
|
|
44
|
+
export const rgbColorSchema = z.object({
|
|
10
45
|
type: z.literal('rgb').describe('Color type'),
|
|
11
46
|
r: z.number().describe('Red'),
|
|
12
47
|
g: z.number().describe('Green'),
|
|
13
48
|
b: z.number().describe('Blue'),
|
|
14
49
|
});
|
|
50
|
+
export const grayColorSchema = z.object({
|
|
51
|
+
type: z.literal('gray').describe('Color type'),
|
|
52
|
+
value: z.number().min(0).max(100).describe('Gray value (0-100)'),
|
|
53
|
+
});
|
|
15
54
|
const noColorSchema = z.object({
|
|
16
55
|
type: z.literal('none').describe('Color type'),
|
|
17
56
|
});
|
|
18
57
|
export const colorSchema = z
|
|
19
|
-
.discriminatedUnion('type', [cmykColorSchema, rgbColorSchema, noColorSchema])
|
|
58
|
+
.discriminatedUnion('type', [cmykColorSchema, rgbColorSchema, grayColorSchema, noColorSchema])
|
|
20
59
|
.optional();
|
|
21
60
|
export const strokeSchema = z
|
|
22
61
|
.object({
|
|
@@ -57,6 +96,11 @@ function createColor(colorObj) {
|
|
|
57
96
|
c.blue = colorObj.b;
|
|
58
97
|
return c;
|
|
59
98
|
}
|
|
99
|
+
if (colorObj.type === "gray") {
|
|
100
|
+
var c = new GrayColor();
|
|
101
|
+
c.gray = colorObj.value;
|
|
102
|
+
return c;
|
|
103
|
+
}
|
|
60
104
|
return new NoColor();
|
|
61
105
|
}
|
|
62
106
|
|
|
@@ -84,8 +128,8 @@ function applyStroke(item, strokeObj, defaultStroked) {
|
|
|
84
128
|
}
|
|
85
129
|
if (strokeObj.color) {
|
|
86
130
|
item.strokeColor = createColor(strokeObj.color);
|
|
131
|
+
item.stroked = true;
|
|
87
132
|
}
|
|
88
|
-
item.stroked = true;
|
|
89
133
|
}
|
|
90
134
|
`;
|
|
91
135
|
//# sourceMappingURL=shared.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../src/tools/modify/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../src/tools/modify/shared.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"undo.d.ts","sourceRoot":"","sources":["../../../src/tools/modify/undo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AA6CpE,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAyBhD"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { executeJsx } from '../../executor/jsx-runner.js';
|
|
3
|
+
import { DESTRUCTIVE_ANNOTATIONS } from './shared.js';
|
|
4
|
+
/**
|
|
5
|
+
* undo — Illustrator の操作を取り消し/やり直し
|
|
6
|
+
*
|
|
7
|
+
* @see https://ai-scripting.docsforadobe.dev/jsobjref/Application/ — Application.undo(), Application.redo()
|
|
8
|
+
*
|
|
9
|
+
* JSX API:
|
|
10
|
+
* Application.undo() → void
|
|
11
|
+
* Application.redo() → void
|
|
12
|
+
*
|
|
13
|
+
* ドキュメント不要。checkIllustratorVersion() のみ使用。
|
|
14
|
+
*/
|
|
15
|
+
const jsxCode = `
|
|
16
|
+
try {
|
|
17
|
+
var verErr = checkIllustratorVersion();
|
|
18
|
+
if (verErr) {
|
|
19
|
+
writeResultFile(RESULT_PATH, verErr);
|
|
20
|
+
} else {
|
|
21
|
+
var params = readParamsFile(PARAMS_PATH);
|
|
22
|
+
var action = params.action || "undo";
|
|
23
|
+
var count = params.count || 1;
|
|
24
|
+
|
|
25
|
+
for (var i = 0; i < count; i++) {
|
|
26
|
+
if (action === "undo") {
|
|
27
|
+
app.undo();
|
|
28
|
+
} else {
|
|
29
|
+
app.redo();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
writeResultFile(RESULT_PATH, {
|
|
34
|
+
success: true,
|
|
35
|
+
action: action,
|
|
36
|
+
count: count
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
} catch (e) {
|
|
40
|
+
writeResultFile(RESULT_PATH, { error: true, message: "undo failed: " + e.message, line: e.line });
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
43
|
+
export function register(server) {
|
|
44
|
+
server.registerTool('undo', {
|
|
45
|
+
title: 'Undo / Redo',
|
|
46
|
+
description: 'Undo or redo actions in Illustrator. Note: Illustrator will be activated (brought to foreground) during execution.',
|
|
47
|
+
inputSchema: {
|
|
48
|
+
action: z.enum(['undo', 'redo']).optional().default('undo'),
|
|
49
|
+
count: z
|
|
50
|
+
.number()
|
|
51
|
+
.int()
|
|
52
|
+
.min(1)
|
|
53
|
+
.max(20)
|
|
54
|
+
.optional()
|
|
55
|
+
.default(1)
|
|
56
|
+
.describe('Number of times to undo/redo (max 20)'),
|
|
57
|
+
},
|
|
58
|
+
annotations: DESTRUCTIVE_ANNOTATIONS,
|
|
59
|
+
}, async (params) => {
|
|
60
|
+
const result = await executeJsx(jsxCode, params, { activate: true });
|
|
61
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=undo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"undo.js","sourceRoot":"","sources":["../../../src/tools/modify/undo.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;;;;;;;;;;GAUG;AACH,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2Bf,CAAC;AAEF,MAAM,UAAU,QAAQ,CAAC,MAAiB;IACxC,MAAM,CAAC,YAAY,CACjB,MAAM,EACN;QACE,KAAK,EAAE,aAAa;QACpB,WAAW,EACT,oHAAoH;QACtH,WAAW,EAAE;YACX,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC;YAC3D,KAAK,EAAE,CAAC;iBACL,MAAM,EAAE;iBACR,GAAG,EAAE;iBACL,GAAG,CAAC,CAAC,CAAC;iBACN,GAAG,CAAC,EAAE,CAAC;iBACP,QAAQ,EAAE;iBACV,OAAO,CAAC,CAAC,CAAC;iBACV,QAAQ,CAAC,uCAAuC,CAAC;SACrD;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":"ungroup-objects.d.ts","sourceRoot":"","sources":["../../../src/tools/modify/ungroup-objects.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAwDpE,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAiBhD"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { executeJsx } from '../../executor/jsx-runner.js';
|
|
3
|
+
import { DESTRUCTIVE_ANNOTATIONS } from './shared.js';
|
|
4
|
+
/**
|
|
5
|
+
* ungroup_objects — グループを解除し子要素を親レイヤーに移動
|
|
6
|
+
*
|
|
7
|
+
* @see https://ai-scripting.docsforadobe.dev/jsobjref/GroupItem/ — GroupItem, PageItem.move()
|
|
8
|
+
*
|
|
9
|
+
* JSX API:
|
|
10
|
+
* PageItem.move(relativeObject, insertionLocation: ElementPlacement) → PageItem
|
|
11
|
+
* GroupItem.remove() → void (空グループを削除)
|
|
12
|
+
*
|
|
13
|
+
* ライブコレクション回避のため、先に children 配列に収集してから move する。
|
|
14
|
+
* ライブコレクションの注意: pageItems は live collection なので反復中に変化する
|
|
15
|
+
*/
|
|
16
|
+
const jsxCode = `
|
|
17
|
+
var preflight = preflightChecks();
|
|
18
|
+
if (preflight) {
|
|
19
|
+
writeResultFile(RESULT_PATH, preflight);
|
|
20
|
+
} else {
|
|
21
|
+
try {
|
|
22
|
+
var params = readParamsFile(PARAMS_PATH);
|
|
23
|
+
var doc = app.activeDocument;
|
|
24
|
+
|
|
25
|
+
var group = findItemByUUID(params.uuid);
|
|
26
|
+
if (!group) {
|
|
27
|
+
writeResultFile(RESULT_PATH, { error: true, message: "Object not found: " + params.uuid });
|
|
28
|
+
} else if (group.typename !== "GroupItem") {
|
|
29
|
+
writeResultFile(RESULT_PATH, { error: true, message: "Object is not a group (type: " + group.typename + ")" });
|
|
30
|
+
} else {
|
|
31
|
+
var childUuids = [];
|
|
32
|
+
var children = [];
|
|
33
|
+
for (var ci = 0; ci < group.pageItems.length; ci++) {
|
|
34
|
+
children.push(group.pageItems[ci]);
|
|
35
|
+
}
|
|
36
|
+
for (var mi = 0; mi < children.length; mi++) {
|
|
37
|
+
var childUuid = ensureUUID(children[mi]);
|
|
38
|
+
childUuids.push(childUuid);
|
|
39
|
+
children[mi].move(group, ElementPlacement.PLACEBEFORE);
|
|
40
|
+
}
|
|
41
|
+
group.remove();
|
|
42
|
+
|
|
43
|
+
writeResultFile(RESULT_PATH, {
|
|
44
|
+
success: true,
|
|
45
|
+
releasedCount: childUuids.length,
|
|
46
|
+
childUuids: childUuids
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
} catch (e) {
|
|
50
|
+
writeResultFile(RESULT_PATH, { error: true, message: "ungroup_objects failed: " + e.message, line: e.line });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
`;
|
|
54
|
+
export function register(server) {
|
|
55
|
+
server.registerTool('ungroup_objects', {
|
|
56
|
+
title: 'Ungroup Objects',
|
|
57
|
+
description: 'Ungroup a group, releasing its children to the parent layer. Note: Illustrator will be activated (brought to foreground) during execution.',
|
|
58
|
+
inputSchema: {
|
|
59
|
+
uuid: z.string().describe('UUID of the group to ungroup'),
|
|
60
|
+
},
|
|
61
|
+
annotations: DESTRUCTIVE_ANNOTATIONS,
|
|
62
|
+
}, async (params) => {
|
|
63
|
+
const result = await executeJsx(jsxCode, params, { activate: true });
|
|
64
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=ungroup-objects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ungroup-objects.js","sourceRoot":"","sources":["../../../src/tools/modify/ungroup-objects.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;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCf,CAAC;AAEF,MAAM,UAAU,QAAQ,CAAC,MAAiB;IACxC,MAAM,CAAC,YAAY,CACjB,iBAAiB,EACjB;QACE,KAAK,EAAE,iBAAiB;QACxB,WAAW,EACT,4IAA4I;QAC9I,WAAW,EAAE;YACX,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,8BAA8B,CAAC;SAC1D;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":"check-contrast.d.ts","sourceRoot":"","sources":["../../../src/tools/read/check-contrast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AA8IpE,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA2JhD"}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { executeJsx } from '../../executor/jsx-runner.js';
|
|
3
|
+
import { READ_ANNOTATIONS } from '../modify/shared.js';
|
|
4
|
+
/**
|
|
5
|
+
* check_contrast — WCAG コントラスト比チェック
|
|
6
|
+
*
|
|
7
|
+
* 既知の問題: GrayColor の gray プロパティの解釈がリファレンス(0=黒, 100=白)と
|
|
8
|
+
* インク量解釈(0=白, 100=黒)で矛盾あり。現在のコードはインク量解釈を使用。
|
|
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 autoDetect = (params && params.auto_detect === true);
|
|
19
|
+
|
|
20
|
+
if (autoDetect) {
|
|
21
|
+
// Collect all objects with colors and bounds for overlap analysis
|
|
22
|
+
var colorItems = [];
|
|
23
|
+
|
|
24
|
+
// Path items
|
|
25
|
+
for (var i = 0; i < doc.pathItems.length; i++) {
|
|
26
|
+
var item = doc.pathItems[i];
|
|
27
|
+
try {
|
|
28
|
+
var b = item.geometricBounds;
|
|
29
|
+
var info = {
|
|
30
|
+
uuid: ensureUUID(item),
|
|
31
|
+
name: item.name || "",
|
|
32
|
+
type: getItemType(item),
|
|
33
|
+
bounds: { left: b[0], top: b[1], right: b[2], bottom: b[3] },
|
|
34
|
+
fillColor: null,
|
|
35
|
+
strokeColor: null
|
|
36
|
+
};
|
|
37
|
+
try { if (item.filled) info.fillColor = colorToObject(item.fillColor); } catch(e2) {}
|
|
38
|
+
try { if (item.stroked) info.strokeColor = colorToObject(item.strokeColor); } catch(e2) {}
|
|
39
|
+
if (info.fillColor || info.strokeColor) colorItems.push(info);
|
|
40
|
+
} catch(e) {}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Text frames (foreground text)
|
|
44
|
+
for (var ti = 0; ti < doc.textFrames.length; ti++) {
|
|
45
|
+
var tf = doc.textFrames[ti];
|
|
46
|
+
try {
|
|
47
|
+
var tb = tf.geometricBounds;
|
|
48
|
+
var tInfo = {
|
|
49
|
+
uuid: ensureUUID(tf),
|
|
50
|
+
name: tf.name || tf.contents.substring(0, 30),
|
|
51
|
+
type: "text",
|
|
52
|
+
bounds: { left: tb[0], top: tb[1], right: tb[2], bottom: tb[3] },
|
|
53
|
+
fillColor: null,
|
|
54
|
+
strokeColor: null
|
|
55
|
+
};
|
|
56
|
+
try {
|
|
57
|
+
if (tf.textRanges.length > 0) {
|
|
58
|
+
tInfo.fillColor = colorToObject(tf.textRanges[0].characterAttributes.fillColor);
|
|
59
|
+
}
|
|
60
|
+
} catch(e2) {}
|
|
61
|
+
if (tInfo.fillColor) colorItems.push(tInfo);
|
|
62
|
+
} catch(e) {}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
writeResultFile(RESULT_PATH, { colorItems: colorItems });
|
|
66
|
+
} else {
|
|
67
|
+
// Manual mode: just return success, calculation done in Node.js
|
|
68
|
+
writeResultFile(RESULT_PATH, { colorItems: [] });
|
|
69
|
+
}
|
|
70
|
+
} catch (e) {
|
|
71
|
+
writeResultFile(RESULT_PATH, { error: true, message: e.message, line: e.line });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
`;
|
|
75
|
+
function colorToRGB(color) {
|
|
76
|
+
if (color.type === 'rgb' && color.r !== undefined) {
|
|
77
|
+
return { r: color.r, g: color.g, b: color.b };
|
|
78
|
+
}
|
|
79
|
+
if (color.type === 'cmyk' && color.c !== undefined) {
|
|
80
|
+
// Simple CMYK to RGB conversion (no ICC profile)
|
|
81
|
+
const c = color.c / 100;
|
|
82
|
+
const m = color.m / 100;
|
|
83
|
+
const y = color.y / 100;
|
|
84
|
+
const k = color.k / 100;
|
|
85
|
+
return {
|
|
86
|
+
r: Math.round(255 * (1 - c) * (1 - k)),
|
|
87
|
+
g: Math.round(255 * (1 - m) * (1 - k)),
|
|
88
|
+
b: Math.round(255 * (1 - y) * (1 - k)),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
if (color.type === 'gray') {
|
|
92
|
+
const v = Math.round(255 * (1 - (color.value ?? 0) / 100));
|
|
93
|
+
return { r: v, g: v, b: v };
|
|
94
|
+
}
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
function relativeLuminance(r, g, b) {
|
|
98
|
+
const [rs, gs, bs] = [r / 255, g / 255, b / 255].map((c) => c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4));
|
|
99
|
+
return 0.2126 * rs + 0.7152 * gs + 0.0722 * bs;
|
|
100
|
+
}
|
|
101
|
+
function contrastRatio(l1, l2) {
|
|
102
|
+
const lighter = Math.max(l1, l2);
|
|
103
|
+
const darker = Math.min(l1, l2);
|
|
104
|
+
return (lighter + 0.05) / (darker + 0.05);
|
|
105
|
+
}
|
|
106
|
+
function boundsOverlap(a, b) {
|
|
107
|
+
return a.left < b.right && a.right > b.left && a.top > b.bottom && a.bottom < b.top;
|
|
108
|
+
}
|
|
109
|
+
export function register(server) {
|
|
110
|
+
server.registerTool('check_contrast', {
|
|
111
|
+
title: 'Check Contrast',
|
|
112
|
+
description: 'Check WCAG color contrast ratios. Manual mode: provide two colors. Auto mode: detect overlapping foreground/background pairs in the document. Note: GrayColor uses ink-quantity interpretation (0=white, 100=black), which differs from the API reference.',
|
|
113
|
+
inputSchema: {
|
|
114
|
+
color1: z
|
|
115
|
+
.object({
|
|
116
|
+
type: z.enum(['cmyk', 'rgb', 'gray']),
|
|
117
|
+
c: z.number().optional(),
|
|
118
|
+
m: z.number().optional(),
|
|
119
|
+
y: z.number().optional(),
|
|
120
|
+
k: z.number().optional(),
|
|
121
|
+
r: z.number().optional(),
|
|
122
|
+
g: z.number().optional(),
|
|
123
|
+
b: z.number().optional(),
|
|
124
|
+
value: z.number().optional(),
|
|
125
|
+
})
|
|
126
|
+
.optional()
|
|
127
|
+
.describe('First color (manual mode)'),
|
|
128
|
+
color2: z
|
|
129
|
+
.object({
|
|
130
|
+
type: z.enum(['cmyk', 'rgb', 'gray']),
|
|
131
|
+
c: z.number().optional(),
|
|
132
|
+
m: z.number().optional(),
|
|
133
|
+
y: z.number().optional(),
|
|
134
|
+
k: z.number().optional(),
|
|
135
|
+
r: z.number().optional(),
|
|
136
|
+
g: z.number().optional(),
|
|
137
|
+
b: z.number().optional(),
|
|
138
|
+
value: z.number().optional(),
|
|
139
|
+
})
|
|
140
|
+
.optional()
|
|
141
|
+
.describe('Second color (manual mode)'),
|
|
142
|
+
auto_detect: z
|
|
143
|
+
.boolean()
|
|
144
|
+
.optional()
|
|
145
|
+
.default(false)
|
|
146
|
+
.describe('Auto-detect overlapping foreground/background color pairs in the document'),
|
|
147
|
+
},
|
|
148
|
+
annotations: READ_ANNOTATIONS,
|
|
149
|
+
}, async (params) => {
|
|
150
|
+
// Manual mode
|
|
151
|
+
if (params.color1 && params.color2) {
|
|
152
|
+
const rgb1 = colorToRGB(params.color1);
|
|
153
|
+
const rgb2 = colorToRGB(params.color2);
|
|
154
|
+
if (!rgb1 || !rgb2) {
|
|
155
|
+
return { content: [{ type: 'text', text: JSON.stringify({ error: true, message: 'Could not convert colors to RGB' }) }] };
|
|
156
|
+
}
|
|
157
|
+
const l1 = relativeLuminance(rgb1.r, rgb1.g, rgb1.b);
|
|
158
|
+
const l2 = relativeLuminance(rgb2.r, rgb2.g, rgb2.b);
|
|
159
|
+
const ratio = Math.round(contrastRatio(l1, l2) * 100) / 100;
|
|
160
|
+
return {
|
|
161
|
+
content: [
|
|
162
|
+
{
|
|
163
|
+
type: 'text',
|
|
164
|
+
text: JSON.stringify({
|
|
165
|
+
contrastRatio: ratio,
|
|
166
|
+
wcagAA_normal: ratio >= 4.5,
|
|
167
|
+
wcagAA_large: ratio >= 3,
|
|
168
|
+
wcagAAA: ratio >= 7,
|
|
169
|
+
color1_rgb: rgb1,
|
|
170
|
+
color2_rgb: rgb2,
|
|
171
|
+
}, null, 2),
|
|
172
|
+
},
|
|
173
|
+
],
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
// Auto-detect mode
|
|
177
|
+
const result = (await executeJsx(jsxCode, params));
|
|
178
|
+
if (result.error) {
|
|
179
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
180
|
+
}
|
|
181
|
+
const items = result.colorItems;
|
|
182
|
+
const pairs = [];
|
|
183
|
+
// Find overlapping pairs (text on shape, smaller on larger)
|
|
184
|
+
for (let i = 0; i < items.length; i++) {
|
|
185
|
+
for (let j = 0; j < items.length; j++) {
|
|
186
|
+
if (i === j)
|
|
187
|
+
continue;
|
|
188
|
+
const fg = items[i];
|
|
189
|
+
const bg = items[j];
|
|
190
|
+
// Foreground should be text or smaller
|
|
191
|
+
if (fg.type !== 'text' && fg.type !== 'path')
|
|
192
|
+
continue;
|
|
193
|
+
if (!fg.fillColor || !bg.fillColor)
|
|
194
|
+
continue;
|
|
195
|
+
if (!boundsOverlap(fg.bounds, bg.bounds))
|
|
196
|
+
continue;
|
|
197
|
+
// Background should be larger (area comparison)
|
|
198
|
+
const fgArea = (fg.bounds.right - fg.bounds.left) * (fg.bounds.top - fg.bounds.bottom);
|
|
199
|
+
const bgArea = (bg.bounds.right - bg.bounds.left) * (bg.bounds.top - bg.bounds.bottom);
|
|
200
|
+
if (fgArea >= bgArea)
|
|
201
|
+
continue;
|
|
202
|
+
const fgRgb = colorToRGB(fg.fillColor);
|
|
203
|
+
const bgRgb = colorToRGB(bg.fillColor);
|
|
204
|
+
if (!fgRgb || !bgRgb)
|
|
205
|
+
continue;
|
|
206
|
+
const l1 = relativeLuminance(fgRgb.r, fgRgb.g, fgRgb.b);
|
|
207
|
+
const l2 = relativeLuminance(bgRgb.r, bgRgb.g, bgRgb.b);
|
|
208
|
+
const ratio = Math.round(contrastRatio(l1, l2) * 100) / 100;
|
|
209
|
+
pairs.push({
|
|
210
|
+
foreground: { color: fg.fillColor, uuid: fg.uuid, name: fg.name },
|
|
211
|
+
background: { color: bg.fillColor, uuid: bg.uuid, name: bg.name },
|
|
212
|
+
contrastRatio: ratio,
|
|
213
|
+
wcagAA_normal: ratio >= 4.5,
|
|
214
|
+
wcagAA_large: ratio >= 3,
|
|
215
|
+
wcagAAA: ratio >= 7,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
// Deduplicate and sort by contrast ratio (worst first)
|
|
220
|
+
const seen = new Set();
|
|
221
|
+
const unique = pairs.filter((p) => {
|
|
222
|
+
const key = `${p.foreground.uuid}-${p.background.uuid}`;
|
|
223
|
+
if (seen.has(key))
|
|
224
|
+
return false;
|
|
225
|
+
seen.add(key);
|
|
226
|
+
return true;
|
|
227
|
+
});
|
|
228
|
+
unique.sort((a, b) => a.contrastRatio - b.contrastRatio);
|
|
229
|
+
return {
|
|
230
|
+
content: [
|
|
231
|
+
{
|
|
232
|
+
type: 'text',
|
|
233
|
+
text: JSON.stringify({ pairCount: unique.length, pairs: unique }, null, 2),
|
|
234
|
+
},
|
|
235
|
+
],
|
|
236
|
+
};
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
//# sourceMappingURL=check-contrast.js.map
|