This repository has been archived by the owner on Oct 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
/
aftereffects.js
69 lines (51 loc) · 1.8 KB
/
aftereffects.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*jshint asi:true evil:true laxbreak:true*/
var aftereffects = exports
var aeEval = require('./lib/aftereffects-eval')
var PSLIB_PATHS = [
__dirname + '/lib/ExtendScript/index-ae.jsxinc',
]
function pathToImport(path){ return '#include "' + path + '"' }
var PSLIB_SCRIPT = PSLIB_PATHS.map(pathToImport).join('\n')
var TMP_IMPORT_PATHS = []
////////////////////////////////////////////////////////////////////////////////
var execFile = require('child_process').execFile
var TEMPLATE = function(){
var transaction = $TRANSACTION
var result
function transactionWrapper(){ result = transaction() }
if (!(app.documents.length)) transactionWrapper()
else app.activeDocument.suspendHistory(decodeURIComponent("$NAME"), "transactionWrapper()")
return result
}
aftereffects.setAppName = function(appName){
aeEval.NAME = appName
return aftereffects
}
aftereffects.include = function(paths){
if (paths && paths.length)
for (var index = -1, length = paths.length; ++index < length;)
TMP_IMPORT_PATHS.push(paths[index])
return this
}
var aeStream = require('./lib/aftereffects-stream').aeStream
aftereffects.createStream = function(jsx, args){
return aeStream(jsx, args, jsx_header())
}
function jsx_header(){
var script = PSLIB_SCRIPT + '\n' + TMP_IMPORT_PATHS.map(pathToImport).join('\n') + '\n'
TMP_IMPORT_PATHS.length = 0
return script
}
////////////////////////////////////////////////////////////////////////////////
if (module.id == '.') {
aftereffects.debug = true
aftereffects.createStream(function(stream){
// app.open(File(psd))
//
// PSFakeDOM.getLayersArray().forEach(function(layer){
// stream.writeln(JSON.stringify(layer.layerID))
// // $.sleep(100)
// })
}, [/*__dirname + '/test/stuff/some stuff.psd'*/])
.pipe(process.stdout)
}