texturepacker-cli
Version:
NodeJS command-line interface for TexturePacker
2 lines (1 loc) • 2.9 kB
JavaScript
;var p=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames,P=Object.getOwnPropertySymbols;var S=Object.prototype.hasOwnProperty,N=Object.prototype.propertyIsEnumerable;var T=(r,t,i)=>t in r?p(r,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):r[t]=i,h=(r,t)=>{for(var i in t||(t={}))S.call(t,i)&&T(r,i,t[i]);if(P)for(var i of P(t))N.call(t,i)&&T(r,i,t[i]);return r};var C=(r,t)=>{for(var i in t)p(r,i,{get:t[i],enumerable:!0})},E=(r,t,i,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of F(t))!S.call(r,e)&&e!==i&&p(r,e,{get:()=>t[e],enumerable:!(o=k(t,e))||o.enumerable});return r};var L=r=>E(p({},"__esModule",{value:!0}),r);var c=(r,t,i)=>new Promise((o,e)=>{var n=s=>{try{a(i.next(s))}catch(x){e(x)}},u=s=>{try{a(i.throw(s))}catch(x){e(x)}},a=s=>s.done?o(s.value):Promise.resolve(s.value).then(n,u);a((i=i.apply(r,t)).next())});var R={};C(R,{AlphaHandling:()=>d,DEFAULT_OPTIONS:()=>g,Format:()=>f,TexturePacker:()=>b,pack:()=>v,unpack:()=>A});module.exports=L(R);var d=(e=>(e.ClearTransparentPixels="ClearTransparentPixels",e.KeepTransparentPixels="KeepTransparentPixels",e.PremultiplyAlpha="PremultiplyAlpha",e.ReduceBorderArtifacts="ReduceBorderArtifacts",e))(d||{}),f=(n=>(n.Cocos2D="cocos2d",n.JSONHash="json",n.PixiJS="pixijs4",n.Spine="spine",n.XML="xml",n))(f||{});var g={fileList:[],format:"cocos2d",data:"",trimMargin:1,alphaHandling:"ClearTransparentPixels",trimSpriteNames:!1,disableRotation:!1};function v(){return"pack"}var m=require("child_process");var y={maxBuffer:1/0,windowsHide:!0};function O(r,t){return c(this,null,function*(){return new Promise((i,o)=>{(0,m.execFile)(r,t,y,e=>{if(e)return o(new Error(e.message));i()})})})}function _(r,t){(0,m.execFileSync)(r,t,y)}var l=class l{get command(){return l.Command}get args(){let{fileList:t,format:i,data:o,trimMargin:e,alphaHandling:n,trimSpriteNames:u,disableRotation:a}=this._options;return[...t,"--format",i,"--data",o,"--trim-margin",e.toString(),"--alpha-handling",n,u?"--trim-sprite-names":"",a?"--disable-rotation":""].filter(s=>!!s)}get data(){return this._options.data}constructor(t){this._options=h(h({},g),t)}setFileList(t){return this._options.fileList=t,this}setFormat(t){return this._options.format=t,this}setData(t){return this._options.data=t,this}setTrimMargin(t){return this._options.trimMargin=t,this}setAlphaHandling(t){return this._options.alphaHandling=t,this}trimSpriteNames(){return this._options.trimSpriteNames=!0,this}disableRotation(){return this._options.disableRotation=!0,this}toString(){return[this.command,...this.args].map(t=>`"${t}"`).join(" ")}run(){return c(this,null,function*(){let{command:t,args:i}=this;return O(t,i)})}runSync(){let{command:t,args:i}=this;_(t,i)}};l.Command="TexturePacker";var b=l;function A(){return"unpack"}0&&(module.exports={AlphaHandling,DEFAULT_OPTIONS,Format,TexturePacker,pack,unpack});