UNPKG

texturepacker-cli

Version:

NodeJS command-line interface for TexturePacker

2 lines (1 loc) 2.9 kB
"use strict";var p=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames,P=Object.getOwnPropertySymbols;var S=Object.prototype.hasOwnProperty,C=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,x=(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))C.call(t,i)&&T(r,i,t[i]);return r};var L=(r,t)=>{for(var i in t)p(r,i,{get:t[i],enumerable:!0})},v=(r,t,i,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of N(t))!S.call(r,e)&&e!==i&&p(r,e,{get:()=>t[e],enumerable:!(o=k(t,e))||o.enumerable});return r};var A=r=>v(p({},"__esModule",{value:!0}),r);var m=(r,t,i)=>new Promise((o,e)=>{var n=s=>{try{a(i.next(s))}catch(h){e(h)}},l=s=>{try{a(i.throw(s))}catch(h){e(h)}},a=s=>s.done?o(s.value):Promise.resolve(s.value).then(n,l);a((i=i.apply(r,t)).next())});var D={};L(D,{AlphaHandling:()=>d,DEFAULT_OPTIONS:()=>g,Format:()=>f,TexturePacker:()=>b,pack:()=>F,unpack:()=>R});module.exports=A(D);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 F(){return"pack"}var c=require("child_process");var y={maxBuffer:1/0,windowsHide:!0};function O(r,t){return m(this,null,function*(){return new Promise((i,o)=>{(0,c.execFile)(r,t,y,e=>{if(e)return o(new Error(e.message));i()})})})}function _(r,t){(0,c.execFileSync)(r,t,y)}var u=class u{get command(){return u.Command}get args(){let{fileList:t,format:i,data:o,trimMargin:e,alphaHandling:n,trimSpriteNames:l,disableRotation:a}=this._options;return[...t,"--format",i,"--data",o,"--trim-margin",e.toString(),"--alpha-handling",n,l?"--trim-sprite-names":"",a?"--disable-rotation":""].filter(s=>!!s)}get data(){return this._options.data}constructor(t){this._options=x(x({},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 m(this,null,function*(){let{command:t,args:i}=this;return O(t,i)})}runSync(){let{command:t,args:i}=this;_(t,i)}};u.Command="TexturePacker";var b=u;function R(){return"unpack"}0&&(module.exports={AlphaHandling,DEFAULT_OPTIONS,Format,TexturePacker,pack,unpack});