ae-agent-setup 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CSXS/manifest.xml +44 -0
- package/README.ja.md +249 -0
- package/README.md +249 -0
- package/bin/ae-agent-setup.mjs +337 -0
- package/client/CSInterface.js +1291 -0
- package/client/index.html +64 -0
- package/client/lib/bridge_utils.js +56 -0
- package/client/lib/logging.js +10 -0
- package/client/lib/request_handlers.js +468 -0
- package/client/lib/request_handlers_essential.js +35 -0
- package/client/lib/request_handlers_layer_structure.js +180 -0
- package/client/lib/request_handlers_scene.js +38 -0
- package/client/lib/request_handlers_shape.js +288 -0
- package/client/lib/request_handlers_timeline.js +115 -0
- package/client/lib/runtime.js +35 -0
- package/client/lib/server.js +33 -0
- package/client/main.js +1 -0
- package/host/index.jsx +11 -0
- package/host/json2.js +504 -0
- package/host/lib/common.jsx +128 -0
- package/host/lib/mutation_handlers.jsx +358 -0
- package/host/lib/mutation_keyframe_handlers.jsx +265 -0
- package/host/lib/mutation_layer_structure_handlers.jsx +235 -0
- package/host/lib/mutation_scene_handlers.jsx +1226 -0
- package/host/lib/mutation_shape_handlers.jsx +358 -0
- package/host/lib/mutation_timeline_handlers.jsx +137 -0
- package/host/lib/property_utils.jsx +105 -0
- package/host/lib/query_handlers.jsx +427 -0
- package/package.json +21 -0
- package/scripts/signing/build-zxp.sh +56 -0
- package/scripts/signing/create-dev-cert.sh +97 -0
- package/scripts/signing/install-zxp.sh +29 -0
- package/templates/skills/aftereffects-cli.SKILL.md +74 -0
- package/templates/skills/aftereffects-declarative.SKILL.md +112 -0
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
function parentLayer(childLayerId, parentLayerId) {
|
|
2
|
+
try {
|
|
3
|
+
ensureJSON();
|
|
4
|
+
var comp = app.project.activeItem;
|
|
5
|
+
if (!comp || !(comp instanceof CompItem)) {
|
|
6
|
+
return encodePayload({ status: "error", message: "Active composition not found." });
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
var child = comp.layer(childLayerId);
|
|
10
|
+
if (!child) {
|
|
11
|
+
return encodePayload({ status: "error", message: "Child layer with id " + childLayerId + " not found." });
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
var parent = null;
|
|
15
|
+
if (parentLayerId !== null && parentLayerId !== undefined) {
|
|
16
|
+
parent = comp.layer(parentLayerId);
|
|
17
|
+
if (!parent) {
|
|
18
|
+
return encodePayload({ status: "error", message: "Parent layer with id " + parentLayerId + " not found." });
|
|
19
|
+
}
|
|
20
|
+
if (parent.index === child.index) {
|
|
21
|
+
return encodePayload({ status: "error", message: "A layer cannot be parented to itself." });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
child.parent = parent;
|
|
26
|
+
|
|
27
|
+
return encodePayload({
|
|
28
|
+
status: "success",
|
|
29
|
+
childLayerId: child.index,
|
|
30
|
+
childLayerName: child.name,
|
|
31
|
+
parentLayerId: parent ? parent.index : null,
|
|
32
|
+
parentLayerName: parent ? parent.name : null
|
|
33
|
+
});
|
|
34
|
+
} catch (e) {
|
|
35
|
+
log("parentLayer() threw: " + e.toString());
|
|
36
|
+
return encodePayload({ status: "error", message: e.toString() });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function precomposeLayers(layerIdsJSON, name, moveAllAttributes) {
|
|
41
|
+
try {
|
|
42
|
+
ensureJSON();
|
|
43
|
+
var comp = app.project.activeItem;
|
|
44
|
+
if (!comp || !(comp instanceof CompItem)) {
|
|
45
|
+
return encodePayload({ status: "error", message: "Active composition not found." });
|
|
46
|
+
}
|
|
47
|
+
if (!name || String(name).length === 0) {
|
|
48
|
+
return encodePayload({ status: "error", message: "name is required." });
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
var layerIds = [];
|
|
52
|
+
try {
|
|
53
|
+
layerIds = JSON.parse(layerIdsJSON);
|
|
54
|
+
} catch (eParse) {
|
|
55
|
+
return encodePayload({ status: "error", message: "Invalid layerIds JSON: " + eParse.toString() });
|
|
56
|
+
}
|
|
57
|
+
if (!(layerIds instanceof Array) || layerIds.length === 0) {
|
|
58
|
+
return encodePayload({ status: "error", message: "layerIds must be a non-empty array." });
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
var indices = [];
|
|
62
|
+
for (var i = 0; i < layerIds.length; i++) {
|
|
63
|
+
var layerIndex = Number(layerIds[i]);
|
|
64
|
+
if (isNaN(layerIndex)) {
|
|
65
|
+
return encodePayload({ status: "error", message: "layerIds must contain only numbers." });
|
|
66
|
+
}
|
|
67
|
+
var layer = comp.layer(layerIndex);
|
|
68
|
+
if (!layer) {
|
|
69
|
+
return encodePayload({ status: "error", message: "Layer with id " + layerIndex + " not found." });
|
|
70
|
+
}
|
|
71
|
+
indices.push(layerIndex);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
var createdComp = comp.layers.precompose(indices, String(name), moveAllAttributes === true);
|
|
75
|
+
if (!createdComp) {
|
|
76
|
+
return encodePayload({ status: "error", message: "Failed to precompose layers." });
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return encodePayload({
|
|
80
|
+
status: "success",
|
|
81
|
+
compId: createdComp.id,
|
|
82
|
+
compName: createdComp.name,
|
|
83
|
+
layerIds: indices
|
|
84
|
+
});
|
|
85
|
+
} catch (e) {
|
|
86
|
+
log("precomposeLayers() threw: " + e.toString());
|
|
87
|
+
return encodePayload({ status: "error", message: e.toString() });
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function duplicateLayer(layerId) {
|
|
92
|
+
try {
|
|
93
|
+
ensureJSON();
|
|
94
|
+
var comp = app.project.activeItem;
|
|
95
|
+
if (!comp || !(comp instanceof CompItem)) {
|
|
96
|
+
return encodePayload({ status: "error", message: "Active composition not found." });
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
var layer = comp.layer(layerId);
|
|
100
|
+
if (!layer) {
|
|
101
|
+
return encodePayload({ status: "error", message: "Layer with id " + layerId + " not found." });
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
var duplicated = layer.duplicate();
|
|
105
|
+
if (!duplicated) {
|
|
106
|
+
return encodePayload({ status: "error", message: "Failed to duplicate layer." });
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return encodePayload({
|
|
110
|
+
status: "success",
|
|
111
|
+
sourceLayerId: layer.index,
|
|
112
|
+
sourceLayerName: layer.name,
|
|
113
|
+
duplicatedLayerId: duplicated.index,
|
|
114
|
+
duplicatedLayerName: duplicated.name
|
|
115
|
+
});
|
|
116
|
+
} catch (e) {
|
|
117
|
+
log("duplicateLayer() threw: " + e.toString());
|
|
118
|
+
return encodePayload({ status: "error", message: e.toString() });
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function moveLayerOrder(layerId, beforeLayerId, afterLayerId, toTop, toBottom) {
|
|
123
|
+
try {
|
|
124
|
+
ensureJSON();
|
|
125
|
+
var comp = app.project.activeItem;
|
|
126
|
+
if (!comp || !(comp instanceof CompItem)) {
|
|
127
|
+
return encodePayload({ status: "error", message: "Active composition not found." });
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
var layer = comp.layer(layerId);
|
|
131
|
+
if (!layer) {
|
|
132
|
+
return encodePayload({ status: "error", message: "Layer with id " + layerId + " not found." });
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
var hasBefore = beforeLayerId !== null && beforeLayerId !== undefined;
|
|
136
|
+
var hasAfter = afterLayerId !== null && afterLayerId !== undefined;
|
|
137
|
+
var hasTop = toTop === true;
|
|
138
|
+
var hasBottom = toBottom === true;
|
|
139
|
+
var selectorCount = 0;
|
|
140
|
+
if (hasBefore) selectorCount += 1;
|
|
141
|
+
if (hasAfter) selectorCount += 1;
|
|
142
|
+
if (hasTop) selectorCount += 1;
|
|
143
|
+
if (hasBottom) selectorCount += 1;
|
|
144
|
+
if (selectorCount !== 1) {
|
|
145
|
+
return encodePayload({
|
|
146
|
+
status: "error",
|
|
147
|
+
message: "Specify exactly one of beforeLayerId, afterLayerId, toTop, toBottom."
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (hasBefore) {
|
|
152
|
+
var beforeLayer = comp.layer(beforeLayerId);
|
|
153
|
+
if (!beforeLayer) {
|
|
154
|
+
return encodePayload({ status: "error", message: "beforeLayerId target not found." });
|
|
155
|
+
}
|
|
156
|
+
if (beforeLayer.index === layer.index) {
|
|
157
|
+
return encodePayload({ status: "error", message: "Cannot move layer relative to itself." });
|
|
158
|
+
}
|
|
159
|
+
layer.moveBefore(beforeLayer);
|
|
160
|
+
} else if (hasAfter) {
|
|
161
|
+
var afterLayer = comp.layer(afterLayerId);
|
|
162
|
+
if (!afterLayer) {
|
|
163
|
+
return encodePayload({ status: "error", message: "afterLayerId target not found." });
|
|
164
|
+
}
|
|
165
|
+
if (afterLayer.index === layer.index) {
|
|
166
|
+
return encodePayload({ status: "error", message: "Cannot move layer relative to itself." });
|
|
167
|
+
}
|
|
168
|
+
layer.moveAfter(afterLayer);
|
|
169
|
+
} else if (hasTop) {
|
|
170
|
+
layer.moveToBeginning();
|
|
171
|
+
} else if (hasBottom) {
|
|
172
|
+
layer.moveToEnd();
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return encodePayload({
|
|
176
|
+
status: "success",
|
|
177
|
+
layerId: layer.index,
|
|
178
|
+
layerName: layer.name
|
|
179
|
+
});
|
|
180
|
+
} catch (e) {
|
|
181
|
+
log("moveLayerOrder() threw: " + e.toString());
|
|
182
|
+
return encodePayload({ status: "error", message: e.toString() });
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function deleteLayer(layerId) {
|
|
187
|
+
try {
|
|
188
|
+
ensureJSON();
|
|
189
|
+
var comp = app.project.activeItem;
|
|
190
|
+
if (!comp || !(comp instanceof CompItem)) {
|
|
191
|
+
return encodePayload({ status: "error", message: "Active composition not found." });
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
var layer = comp.layer(layerId);
|
|
195
|
+
if (!layer) {
|
|
196
|
+
return encodePayload({ status: "error", message: "Layer with id " + layerId + " not found." });
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
var removedLayerId = layer.index;
|
|
200
|
+
var removedLayerName = layer.name;
|
|
201
|
+
layer.remove();
|
|
202
|
+
|
|
203
|
+
return encodePayload({
|
|
204
|
+
status: "success",
|
|
205
|
+
layerId: removedLayerId,
|
|
206
|
+
layerName: removedLayerName
|
|
207
|
+
});
|
|
208
|
+
} catch (e) {
|
|
209
|
+
log("deleteLayer() threw: " + e.toString());
|
|
210
|
+
return encodePayload({ status: "error", message: e.toString() });
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function deleteComp(compId, compName) {
|
|
215
|
+
try {
|
|
216
|
+
ensureJSON();
|
|
217
|
+
var comp = findCompByIdOrName(compId, compName);
|
|
218
|
+
if (!comp) {
|
|
219
|
+
return encodePayload({ status: "error", message: "Composition not found." });
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
var removedCompId = comp.id;
|
|
223
|
+
var removedCompName = comp.name;
|
|
224
|
+
comp.remove();
|
|
225
|
+
|
|
226
|
+
return encodePayload({
|
|
227
|
+
status: "success",
|
|
228
|
+
compId: removedCompId,
|
|
229
|
+
compName: removedCompName
|
|
230
|
+
});
|
|
231
|
+
} catch (e) {
|
|
232
|
+
log("deleteComp() threw: " + e.toString());
|
|
233
|
+
return encodePayload({ status: "error", message: e.toString() });
|
|
234
|
+
}
|
|
235
|
+
}
|