Uh oh!
There was an error while loading. Please reload this page.
This repository was archived by the owner on Jan 10, 2020. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork 297
Expand file tree
/
Copy pathkeyframes-cli.js
More file actions
Latest commit
executable file
·65 lines (59 loc) · 1.94 KB
/
Copy pathkeyframes-cli.js
File metadata and controls
executable file
·65 lines (59 loc) · 1.94 KB
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
#!/usr/bin/env node
/**
* Copyright (c) 2016-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
'use strict';
constevalInAE=require('./(lib)/MudBrickLayer/node/evalInAE');
constAECompToKeyframesAnimation=require('./(lib)/keyframes/AECompToKeyframesAnimation');
constfs=require('fs');
constargv=require('minimist')(process.argv.slice(2));
functionmain(){
functionget_selectedComp_jsx(send){
VirtualTween.ENABLED=false;// disable slow tween rendering
if(app.project.activeItem){
varitems=app.project.items;
varfiles=[];
for(vari=1;i<=app.project.items.length;++i){
varitem=items[i]
if(item.file){
files.push(item.toJSON());
}
}
varactiveItem=app.project.activeItem.toJSON();
activeItem['files']=files;
send(activeItem);
}
}
evalInAE(get_selectedComp_jsx)
.on('data',(layer)=>{
if(argv['raw']){
fs.writeFileSync(layer.name+'.raw.json',JSON.stringify(layer,null,2));
}else{
constkfDoc=AECompToKeyframesAnimation(layer);
if(layer.files.length>0){
constbitmaps={};
for(leti=0;i<layer.files.length;++i){
constitem=layer.files[i];
if(fs.existsSync(item.file)){
constdata=fs.readFileSync(item.file);
bitmaps[item.name]=newBuffer(data).toString('base64');
}
}
kfDoc['bitmaps']=bitmaps;
}
fs.writeFileSync(layer.name+'.kf.json',JSON.stringify(kfDoc,null,2));
}
})
.on('error',(error)=>console.error(error))
.on('end',()=>{})
;
}
module.exports=main;
if(module.id=='.'){
main();
}