var fs = require("fs");
var iconv = require('iconv-lite');

//暂时用作测试用
return

var data = iconv.decode(fs.readFileSync("./lotties/checkTip.json"), "utf-8");//GBK
//反序列化
data = JSON.parse(data);

//原文件，到时考虑把assets里的图片拿出来

//开始删东西
delete data.ddd;
//遍历删除图层东西
for (var i = 0; i < data.layers.length; i++) {
    var l = data.layers[i];
    //是否3d,后缀,sr,ap,开始时间，混合模式，特效
    ["ddd", "cl", "sr", "ao", "st", "bm","ef"].forEach((e) => { delete l[e]; });
    //ks删除
    ["o", "r", "p", "a", "s"].forEach((e) => {
        var d = l.ks[e];
        //ix不知道干嘛用，删了
        delete d.ix;
        //删除k里数据
        if (d.k.length && typeof d.k[0] == "object") {
            d.k.forEach((ee) => {
                ["i", "o", "ti", "to"].forEach((eee) => { delete ee[eee]; })
            })
        }
    })
}



//导出代码到src的lotties文件夹，名字就是lottie动画名字，资源名字临时处理了，首页加载动画用图层的nm，bonustime用refid
var endPath = './src/lotties';
if (!fs.existsSync(endPath)) fs.mkdirSync(endPath);
//导出对象直接用lottie动画名字
var endFile = `export const ${data.nm} = ${JSON.stringify(data, "", "\t")}`
//文件名字用lottie动画名字
fs.writeFileSync(endPath + "/" + data.nm + ".ts", endFile);


