From 858998c8490900caed5f56a594542b4750110d87 Mon Sep 17 00:00:00 2001 From: Lukas Oppermann Date: Fri, 17 Sep 2021 12:33:40 +0200 Subject: [PATCH] added standard export format --- dist/plugin.js | 2 +- package-lock.json | 2 +- package.json | 2 +- src/utilities/version.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/plugin.js b/dist/plugin.js index 150d64fa..55012fe4 100644 --- a/dist/plugin.js +++ b/dist/plugin.js @@ -1 +1 @@ -!function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=64)}({1:function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));const r={generalSettings:"generalSettings",export:"export",sendSettings:"sendSettings",urlExport:"urlExport",help:"help",demo:"demo",openUrl:"openUrl",reset:"reset",saveSettings:"saveSettings",closePlugin:"closePlugin"}},2:function(e,t,n){"use strict";t.a=(e,t=2)=>{if(void 0===e)return;if("number"!=typeof e||"number"!=typeof t)throw new Error(`Invalid parameters, both value "${e}" (${typeof e}) and decimalPlaces "${t}" (${typeof t}) must be of type number`);const n=Math.pow(10,t);return Math.round(e*n)/n}},4:function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));const r={color:{label:"Colors",key:"color"},gradient:{label:"Gradients",key:"gradient"},font:{label:"Fonts",key:"font"},effect:{label:"Effects",key:"effect"},grid:{label:"Grids",key:"grid"},border:{label:"Borders",key:"border"},breakpoint:{label:"Breakpoints",key:"breakpoint"},radius:{label:"Radii",key:"radius"},size:{label:"Sizes",key:"size"},spacing:{label:"Spacing",key:"spacing"},motion:{label:"Motion",key:"motion"}}},5:function(e,t,n){"use strict";t.a={ui:{generalSettings:{width:550,height:685},export:{width:550,height:420},urlExport:{width:550,height:575}},key:{lastVersionSettingsOpened:"lastVersionSettingsOpened",fileId:"fileId",settings:"settings"},exclusionPrefixDefault:["_","."],fileExtensions:[{label:".tokens.json",value:".tokens.json"},{label:".tokens",value:".tokens"},{label:".json",value:".json"}]}},6:function(e,t,n){"use strict";n.d(t,"d",(function(){return R})),n.d(t,"a",(function(){return A})),n.d(t,"b",(function(){return O})),n.d(t,"c",(function(){return M}));var r=n(2);function i(e,t){(function(e){return"string"==typeof e&&-1!==e.indexOf(".")&&1===parseFloat(e)})(e)&&(e="100%");var n=function(e){return"string"==typeof e&&-1!==e.indexOf("%")}(e);return e=360===t?e:Math.min(t,Math.max(0,parseFloat(e))),n&&(e=parseInt(String(e*t),10)/100),Math.abs(e-t)<1e-6?1:e=360===t?(e<0?e%t+t:e%t)/parseFloat(String(t)):e%t/parseFloat(String(t))}function a(e){return Math.min(1,Math.max(0,e))}function o(e){return e=parseFloat(e),(isNaN(e)||e<0||e>1)&&(e=1),e}function s(e){return e<=1?100*Number(e)+"%":e}function u(e){return 1===e.length?"0"+e:String(e)}function l(e,t,n){e=i(e,255),t=i(t,255),n=i(n,255);var r=Math.max(e,t,n),a=Math.min(e,t,n),o=0,s=0,u=(r+a)/2;if(r===a)s=0,o=0;else{var l=r-a;switch(s=u>.5?l/(2-r-a):l/(r+a),r){case e:o=(t-n)/l+(t1&&(n-=1),n<1/6?e+6*n*(t-e):n<.5?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function f(e,t,n){e=i(e,255),t=i(t,255),n=i(n,255);var r=Math.max(e,t,n),a=Math.min(e,t,n),o=0,s=r,u=r-a,l=0===r?0:u/r;if(r===a)o=0;else{switch(r){case e:o=(t-n)/u+(t>16,g:(65280&e)>>8,b:255&e}}(t)),this.originalInput=t;var i=b(t);this.originalInput=t,this.r=i.r,this.g=i.g,this.b=i.b,this.a=i.a,this.roundA=Math.round(100*this.a)/100,this.format=null!==(r=n.format)&&void 0!==r?r:i.format,this.gradientType=n.gradientType,this.r<1&&(this.r=Math.round(this.r)),this.g<1&&(this.g=Math.round(this.g)),this.b<1&&(this.b=Math.round(this.b)),this.isValid=i.ok}return e.prototype.isDark=function(){return this.getBrightness()<128},e.prototype.isLight=function(){return!this.isDark()},e.prototype.getBrightness=function(){var e=this.toRgb();return(299*e.r+587*e.g+114*e.b)/1e3},e.prototype.getLuminance=function(){var e=this.toRgb(),t=e.r/255,n=e.g/255,r=e.b/255;return.2126*(t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4))+.7152*(n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4))+.0722*(r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4))},e.prototype.getAlpha=function(){return this.a},e.prototype.setAlpha=function(e){return this.a=o(e),this.roundA=Math.round(100*this.a)/100,this},e.prototype.toHsv=function(){var e=f(this.r,this.g,this.b);return{h:360*e.h,s:e.s,v:e.v,a:this.a}},e.prototype.toHsvString=function(){var e=f(this.r,this.g,this.b),t=Math.round(360*e.h),n=Math.round(100*e.s),r=Math.round(100*e.v);return 1===this.a?"hsv("+t+", "+n+"%, "+r+"%)":"hsva("+t+", "+n+"%, "+r+"%, "+this.roundA+")"},e.prototype.toHsl=function(){var e=l(this.r,this.g,this.b);return{h:360*e.h,s:e.s,l:e.l,a:this.a}},e.prototype.toHslString=function(){var e=l(this.r,this.g,this.b),t=Math.round(360*e.h),n=Math.round(100*e.s),r=Math.round(100*e.l);return 1===this.a?"hsl("+t+", "+n+"%, "+r+"%)":"hsla("+t+", "+n+"%, "+r+"%, "+this.roundA+")"},e.prototype.toHex=function(e){return void 0===e&&(e=!1),p(this.r,this.g,this.b,e)},e.prototype.toHexString=function(e){return void 0===e&&(e=!1),"#"+this.toHex(e)},e.prototype.toHex8=function(e){return void 0===e&&(e=!1),function(e,t,n,r,i){var a=[u(Math.round(e).toString(16)),u(Math.round(t).toString(16)),u(Math.round(n).toString(16)),u(d(r))];return i&&a[0].startsWith(a[0].charAt(1))&&a[1].startsWith(a[1].charAt(1))&&a[2].startsWith(a[2].charAt(1))&&a[3].startsWith(a[3].charAt(1))?a[0].charAt(0)+a[1].charAt(0)+a[2].charAt(0)+a[3].charAt(0):a.join("")}(this.r,this.g,this.b,this.a,e)},e.prototype.toHex8String=function(e){return void 0===e&&(e=!1),"#"+this.toHex8(e)},e.prototype.toRgb=function(){return{r:Math.round(this.r),g:Math.round(this.g),b:Math.round(this.b),a:this.a}},e.prototype.toRgbString=function(){var e=Math.round(this.r),t=Math.round(this.g),n=Math.round(this.b);return 1===this.a?"rgb("+e+", "+t+", "+n+")":"rgba("+e+", "+t+", "+n+", "+this.roundA+")"},e.prototype.toPercentageRgb=function(){var e=function(e){return Math.round(100*i(e,255))+"%"};return{r:e(this.r),g:e(this.g),b:e(this.b),a:this.a}},e.prototype.toPercentageRgbString=function(){var e=function(e){return Math.round(100*i(e,255))};return 1===this.a?"rgb("+e(this.r)+"%, "+e(this.g)+"%, "+e(this.b)+"%)":"rgba("+e(this.r)+"%, "+e(this.g)+"%, "+e(this.b)+"%, "+this.roundA+")"},e.prototype.toName=function(){if(0===this.a)return"transparent";if(this.a<1)return!1;for(var e="#"+p(this.r,this.g,this.b,!1),t=0,n=Object.entries(m);t=0;return t||!r||!e.startsWith("hex")&&"name"!==e?("rgb"===e&&(n=this.toRgbString()),"prgb"===e&&(n=this.toPercentageRgbString()),"hex"!==e&&"hex6"!==e||(n=this.toHexString()),"hex3"===e&&(n=this.toHexString(!0)),"hex4"===e&&(n=this.toHex8String(!0)),"hex8"===e&&(n=this.toHex8String()),"name"===e&&(n=this.toName()),"hsl"===e&&(n=this.toHslString()),"hsv"===e&&(n=this.toHsvString()),n||this.toHexString()):"name"===e&&0===this.a?this.toName():this.toRgbString()},e.prototype.toNumber=function(){return(Math.round(this.r)<<16)+(Math.round(this.g)<<8)+Math.round(this.b)},e.prototype.clone=function(){return new e(this.toString())},e.prototype.lighten=function(t){void 0===t&&(t=10);var n=this.toHsl();return n.l+=t/100,n.l=a(n.l),new e(n)},e.prototype.brighten=function(t){void 0===t&&(t=10);var n=this.toRgb();return n.r=Math.max(0,Math.min(255,n.r-Math.round(-t/100*255))),n.g=Math.max(0,Math.min(255,n.g-Math.round(-t/100*255))),n.b=Math.max(0,Math.min(255,n.b-Math.round(-t/100*255))),new e(n)},e.prototype.darken=function(t){void 0===t&&(t=10);var n=this.toHsl();return n.l-=t/100,n.l=a(n.l),new e(n)},e.prototype.tint=function(e){return void 0===e&&(e=10),this.mix("white",e)},e.prototype.shade=function(e){return void 0===e&&(e=10),this.mix("black",e)},e.prototype.desaturate=function(t){void 0===t&&(t=10);var n=this.toHsl();return n.s-=t/100,n.s=a(n.s),new e(n)},e.prototype.saturate=function(t){void 0===t&&(t=10);var n=this.toHsl();return n.s+=t/100,n.s=a(n.s),new e(n)},e.prototype.greyscale=function(){return this.desaturate(100)},e.prototype.spin=function(t){var n=this.toHsl(),r=(n.h+t)%360;return n.h=r<0?360+r:r,new e(n)},e.prototype.mix=function(t,n){void 0===n&&(n=50);var r=this.toRgb(),i=new e(t).toRgb(),a=n/100;return new e({r:(i.r-r.r)*a+r.r,g:(i.g-r.g)*a+r.g,b:(i.b-r.b)*a+r.b,a:(i.a-r.a)*a+r.a})},e.prototype.analogous=function(t,n){void 0===t&&(t=6),void 0===n&&(n=30);var r=this.toHsl(),i=360/n,a=[this];for(r.h=(r.h-(i*t>>1)+720)%360;--t;)r.h=(r.h+i)%360,a.push(new e(r));return a},e.prototype.complement=function(){var t=this.toHsl();return t.h=(t.h+180)%360,new e(t)},e.prototype.monochromatic=function(t){void 0===t&&(t=6);for(var n=this.toHsv(),r=n.h,i=n.s,a=n.v,o=[],s=1/t;t--;)o.push(new e({h:r,s:i,v:a})),a=(a+s)%1;return o},e.prototype.splitcomplement=function(){var t=this.toHsl(),n=t.h;return[this,new e({h:(n+72)%360,s:t.s,l:t.l}),new e({h:(n+216)%360,s:t.s,l:t.l})]},e.prototype.onBackground=function(t){var n=this.toRgb(),r=new e(t).toRgb();return new e({r:r.r+(n.r-r.r)*n.a,g:r.g+(n.g-r.g)*n.a,b:r.b+(n.b-r.b)*n.a})},e.prototype.triad=function(){return this.polyad(3)},e.prototype.tetrad=function(){return this.polyad(4)},e.prototype.polyad=function(t){for(var n=this.toHsl(),r=n.h,i=[this],a=360/t,o=1;o({r:Object(r.a)(255*e.r,0),g:Object(r.a)(255*e.g,0),b:Object(r.a)(255*e.b,0),a:Object(r.a)(t||e.a||1)}),A=e=>"SOLID"===e.type&&!0===e.visible?R(e.color,e.opacity||null):null,O=e=>`rgba(${e.r}, ${e.g}, ${e.b}, ${e.a})`,M=e=>{return(t=e,r={r:s(t.r),g:s(t.g),b:s(t.b)},void 0!==t.a&&(r.a=Number(t.a)),new w(r,n)).toHex8String();var t,n,r}},64:function(e,t,n){"use strict";n.r(t);var r=n(8),i=n(5),a=n(7);var o=function(e,t,n,r){return new(n||(n=Promise))((function(i,a){function o(e){try{u(r.next(e))}catch(e){a(e)}}function s(e){try{u(r.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}u((r=r.apply(e,t||[])).next())}))};var s=n(1);var u=function(e,t,n,r){return new(n||(n=Promise))((function(i,a){function o(e){try{u(r.next(e))}catch(e){a(e)}}function s(e){try{u(r.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}u((r=r.apply(e,t||[])).next())}))};var l=e=>u(void 0,void 0,void 0,(function*(){const t=yield e.clientStorage.getAsync(i.a.key.lastVersionSettingsOpened),n=((e,t="1.0.0")=>{const[n,r,i]=t.split("."),[a,o,s]=e.split(".");return n{let t=e.root.getPluginData(i.a.key.fileId);return void 0!==t&&""!==t||(e.root.setPluginData(i.a.key.fileId,e.root.name+" "+Math.floor(1e9*Math.random())),t=e.root.getPluginData(i.a.key.fileId)),t},f=n(4),p=n(6),d=n(2);const g={GRADIENT_LINEAR:"linear",GRADIENT_RADIAL:"radial",GRADIENT_ANGULAR:"angular",GRADIENT_DIAMOND:"diamond"},h=e=>["GRADIENT_LINEAR","GRADIENT_RADIAL","GRADIENT_ANGULAR","GRADIENT_DIAMOND"].includes(e.type),m=([[e,t],[n,r]])=>{const i=Math.atan2(r-t,n-e)*(180/Math.PI)+315;return i>360?i-360:i};var b=(e,t)=>e.map(e=>(e.paints=e.paints.filter(e=>"IMAGE"!==e.type),e)).filter(e=>e.paints.length>0).map(e=>({name:`${h(e.paints[0])?t.gradient[0]:t.color[0]}/${e.name}`,category:h(e.paints[0])?"gradient":"color",exportKey:h(e.paints[0])?f.a.gradient.key:f.a.color.key,description:e.description||null,values:e.paints.map(e=>(e=>"SOLID"===e.type?{fill:{value:Object(p.a)(e),type:"color"}}:["GRADIENT_LINEAR","GRADIENT_RADIAL","GRADIENT_ANGULAR","GRADIENT_DIAMOND"].includes(e.type)?{gradientType:{value:g[e.type],type:"string"},rotation:{value:m(e.gradientTransform),type:"number",unit:"degree"},stops:e.gradientStops.map(e=>({position:{value:Object(d.a)(e.position),type:"number"},color:{value:Object(p.d)(e.color),type:"color"}})),opacity:{value:Object(d.a)(e.opacity),type:"number"}}:null)(e))}));var y=(e,t)=>e.filter(e=>e.layoutGrids.length>0).map(e=>({name:`${t[0]}/${e.name}`,category:"grid",exportKey:f.a.grid.key,description:e.description||null,values:e.layoutGrids.map(e=>"GRID"===e.pattern?(e=>({pattern:{value:e.pattern.toLowerCase(),type:"string"},sectionSize:{value:e.sectionSize,unit:"pixel",type:"number"}}))(e):(e=>{return Object.assign(Object.assign(Object.assign({pattern:{value:e.pattern.toLowerCase(),type:"string"}},void 0!==e.sectionSize&&{sectionSize:{value:e.sectionSize,unit:"pixel",type:"number"}}),{gutterSize:{value:e.gutterSize,unit:"pixel",type:"number"},alignment:{value:e.alignment.toLowerCase(),type:"string"},count:(t=e.count,t===1/0?{value:"auto",type:"string"}:{value:t,type:"number"})}),void 0!==e.offset&&{offset:{value:e.offset,unit:"pixel",type:"number"}});var t})(e))}));const v={NONE:"none",UNDERLINE:"underline",STRIKETHROUGH:"line-through"},x={ORIGINAL:"none",UPPER:"uppercase",LOWER:"lowercase",TITLE:"capitalize"},k={thin:100,extralight:200,ultralight:200,light:300,normal:400,regular:400,medium:500,semibold:600,demibold:600,bold:700,extrabold:800,ultabold:800,black:900,heavy:900,super:900},S={normal:"normal",condensed:"condensed",expanded:"expanded",extended:"expanded"},w={normal:"normal",italic:"italic",oblique:"oblique"},R=e=>{const t=e.toLowerCase().split(" ");let n=t[0];return["extra","ultra","semi","demi"].includes(t[0])&&["bold","light"].includes(t[1])&&(n=`${t[0]}${t[1]}`),k[n]||400},A=e=>{const t=e.toLowerCase().split(" ");return S[t[t.length-1]]||S[t[t.length-2]]||"normal"},O=e=>{const t=e.toLowerCase().split(" ").pop();return w[t]||"normal"};var M=(e,t)=>e.map(e=>({name:`${t[0]}/${e.name}`,category:"font",exportKey:f.a.font.key,description:e.description||void 0,values:{fontSize:{value:e.fontSize,unit:"pixel",type:"number"},textDecoration:{value:v[e.textDecoration],type:"string"},fontFamily:{value:e.fontName.family,type:"string"},fontWeight:{value:R(e.fontName.style),type:"number"},fontStyle:{value:O(e.fontName.style),type:"string"},fontStretch:{value:A(e.fontName.style),type:"string"},_fontStyleOld:{value:e.fontName.style,type:"string"},letterSpacing:{value:Object(d.a)(e.letterSpacing.value),unit:e.letterSpacing.unit.toLowerCase(),type:"number"},lineHeight:{value:Object(d.a)(e.lineHeight.value)||"normal",unit:"pixels"===e.lineHeight.unit.toLowerCase()?"pixel":e.lineHeight.unit.toLowerCase(),type:Object.prototype.hasOwnProperty.call(e.lineHeight,"value")?"number":"string"},paragraphIndent:{value:e.paragraphIndent,unit:"pixel",type:"number"},paragraphSpacing:{value:e.paragraphSpacing,unit:"pixel",type:"number"},textCase:{value:x[e.textCase],type:"string"}}}));const E={LAYER_BLUR:"layerBlur",BACKGROUND_BLUR:"backgroundBlur",DROP_SHADOW:"dropShadow",INNER_SHADOW:"innerShadow"};var N=(e,t)=>e.filter(e=>e.effects.length>0).map(e=>({name:`${t[0]}/${e.name}`,category:"effect",exportKey:f.a.effect.key,description:e.description||null,values:e.effects.map(e=>"LAYER_BLUR"===e.type||"BACKGROUND_BLUR"===e.type?(e=>({effectType:{value:E[e.type],type:"string"},radius:{value:e.radius,unit:"pixel",type:"number"}}))(e):(e=>({effectType:{value:E[e.type],type:"string"},radius:{value:e.radius,unit:"pixel",type:"number"},color:{value:Object(p.d)(e.color),type:"color"},offset:{x:{value:e.offset.x,unit:"pixel",type:"number"},y:{value:e.offset.y,unit:"pixel",type:"number"}},spread:{value:e.spread,unit:"pixel",type:"number"}}))(e))}));const I=e=>t=>e.includes(t.name.substr(0,t.name.indexOf("/")).replace(/\s+/g,"")),j=e=>{if(Object.prototype.hasOwnProperty.call(e,"direction"))return{direction:{value:e.direction.toLowerCase(),type:"string"}}},C={CUSTOM_CUBIC_BEZIER:{},LINEAR:{type:"linear",easingFunctionCubicBezier:{x1:0,y1:0,x2:1,y2:1}},EASE_IN:{type:"ease-in",easingFunctionCubicBezier:{x1:.41999998688697815,y1:0,x2:1,y2:1}},EASE_OUT:{type:"ease-out",easingFunctionCubicBezier:{x1:0,y1:0,x2:.5799999833106995,y2:1}},EASE_IN_AND_OUT:{type:"ease-in-out",easingFunctionCubicBezier:{x1:.41999998688697815,y1:0,x2:.5799999833106995,y2:1}},EASE_IN_BACK:{type:"ease-in-back",easingFunctionCubicBezier:{x1:.30000001192092896,y1:-.05000000074505806,x2:.699999988079071,y2:-.5}},EASE_OUT_BACK:{type:"ease-out-back",easingFunctionCubicBezier:{x1:.44999998807907104,y1:1.4500000476837158,x2:.800000011920929,y2:1}},EASE_IN_AND_OUT_BACK:{type:"ease-in-out-back",easingFunctionCubicBezier:{x1:.699999988079071,y1:-.4000000059604645,x2:.4000000059604645,y2:1.399999976158142}}},L=e=>{if("type"in e&&void 0!==C[e.type])return"CUSTOM_CUBIC_BEZIER"===e.type&&(C.CUSTOM_CUBIC_BEZIER={type:"cubic-bezier",easingFunctionCubicBezier:{x1:e.easingFunctionCubicBezier.x1,y1:e.easingFunctionCubicBezier.y1,x2:e.easingFunctionCubicBezier.x2,y2:e.easingFunctionCubicBezier.y2}}),{easing:{value:C[e.type].type,type:"string"},easingFunction:{x1:{value:C[e.type].easingFunctionCubicBezier.x1,type:"number"},x2:{value:C[e.type].easingFunctionCubicBezier.x2,type:"number"},y1:{value:C[e.type].easingFunctionCubicBezier.y1,type:"number"},y2:{value:C[e.type].easingFunctionCubicBezier.y2,type:"number"}}}};var T=(e,t)=>e.filter(I(t)).filter(e=>{var t;return e.reactions.length>0&&"NODE"===(null===(t=e.reactions[0].action)||void 0===t?void 0:t.type)&&null!==e.reactions[0].action.transition}).map(e=>({name:e.name,category:"motion",exportKey:f.a.motion.key,description:e.description||null,values:Object.assign(Object.assign({transitionType:{value:e.reactions[0].action.transition.type.toLocaleLowerCase(),type:"string"},duration:{value:Math.round(1e3*(e.reactions[0].action.transition.duration+Number.EPSILON))/1e3,unit:"s",type:"number"}},L(e.reactions[0].action.transition.easing)),j(e.reactions[0].action.transition))}));var _=(e,t)=>e.filter(I(t)).map(e=>({name:e.name,category:"size",exportKey:f.a.size.key,description:e.description||null,values:{width:{value:Object(d.a)(e.width,2),unit:"pixel",type:"number"},height:{value:Object(d.a)(e.height,2),unit:"pixel",type:"number"}}}));var D=(e,t)=>e.filter(I(t)).map(e=>({name:e.name,category:"spacing",exportKey:f.a.spacing.key,description:e.description||null,values:{top:{value:Object(d.a)(e.paddingTop,2),unit:"pixel",type:"number"},right:{value:Object(d.a)(e.paddingRight,2),unit:"pixel",type:"number"},bottom:{value:Object(d.a)(e.paddingBottom,2),unit:"pixel",type:"number"},left:{value:Object(d.a)(e.paddingLeft,2),unit:"pixel",type:"number"}}}));const F={MITER:"miter",BEVEL:"bevel",ROUND:"round"},P={CENTER:"center",INSIDE:"inside",OUTSIDE:"outside"};var B=(e,t)=>e.filter(I(t)).filter(e=>e.strokes.length>0).map(e=>({name:e.name,category:"border",exportKey:f.a.border.key,description:e.description||null,values:{strokeAlign:{value:P[e.strokeAlign],type:"string"},dashPattern:{value:[...e.dashPattern],type:"string"},strokeCap:{value:"string"==typeof e.strokeCap?e.strokeCap.toLowerCase():"mixed",type:"string"},strokeJoin:{value:F[e.strokeJoin],type:"string"},strokeMiterLimit:{value:Object(d.a)(e.strokeMiterLimit),unit:"degree",type:"number"},strokeWeight:{value:e.strokeWeight,unit:"pixel",type:"number"},stroke:{value:e.strokes[0],type:"color"}}}));var z=(e,t)=>{const n=e=>({topLeft:{value:e.topLeftRadius||0,unit:"pixel",type:"number"},topRight:{value:e.topRightRadius||0,unit:"pixel",type:"number"},bottomRight:{value:e.bottomRightRadius||0,unit:"pixel",type:"number"},bottomLeft:{value:e.bottomLeftRadius||0,unit:"pixel",type:"number"}});return e.filter(I(t)).map(e=>{return{name:e.name,category:"radius",exportKey:f.a.radius.key,description:e.description||null,values:Object.assign(Object.assign({},"number"==typeof e.cornerRadius&&{radius:{value:e.cornerRadius,unit:"pixel",type:"number"}}),{radiusType:{value:(t=e.cornerRadius,"number"==typeof t?"single":"mixed"),type:"string"},radii:n(e),smoothing:{value:Object(d.a)(e.cornerSmoothing,2),comment:"Percent as decimal from 0.0 - 1.0",type:"number"}})};var t})};var H=(e,t)=>e.filter(I(t)).map(e=>({name:e.name,category:"breakpoint",exportKey:f.a.breakpoint.key,description:e.description||null,values:{width:{value:Object(d.a)(e.width,2),unit:"pixel",type:"number"},height:{value:Object(d.a)(e.height,2),unit:"pixel",type:"number"}}}));var G=(e,t)=>!(e=>[...i.a.exclusionPrefixDefault,...e])(t).includes(e.name.trim().substr(0,1));var U=e=>{const t=[];return e.forEach(e=>{t.push({name:e.name,description:e.description,paints:e.paints})}),t};var $=e=>{const t=[];return e.forEach(e=>{t.push({name:e.name,description:e.description,layoutGrids:e.layoutGrids})}),t};var K=e=>{return{name:e.name,description:e.description||void 0,bottomLeftRadius:e.bottomLeftRadius,bottomRightRadius:e.bottomRightRadius,topLeftRadius:e.topLeftRadius,topRightRadius:e.topRightRadius,cornerRadius:e.cornerRadius||void 0,cornerSmoothing:e.cornerSmoothing,strokes:(t=e.strokes,[...t].map(e=>Object(p.a)(e)).filter(e=>null!=e)),strokeWeight:e.strokeWeight,strokeStyleId:e.strokeStyleId,strokeMiterLimit:e.strokeMiterLimit,strokeJoin:e.strokeJoin,strokeCap:e.strokeCap,dashPattern:e.dashPattern,strokeAlign:e.strokeAlign,width:e.width,height:e.height,reactions:e.reactions||void 0,paddingTop:e.paddingTop||0,paddingRight:e.paddingRight||0,paddingBottom:e.paddingBottom||0,paddingLeft:e.paddingLeft||0};var t};const W=["COMPONENT","COMPONENT_SET","RECTANGLE","FRAME"];var q=e=>"COMPONENT_SET"!==e.parent.type&&W.includes(e.type);const J=e=>"FRAME"===e.type&&"_tokens"===e.name.trim().toLowerCase().substr(0,"_tokens".length);var V=e=>[...e.map(e=>e.findChildren(e=>J(e))).reduce((e,t)=>[...e,...t])].map(e=>e.findAll(e=>q(e))).reduce((e,t)=>[...e,...t],[]).map(e=>("RECTANGLE"!==e.type&&"FRAME"!==e.type||console.warn("Please use only main components and variants, other types may be deprecated as tokens in the future"),"COMPONENT_SET"===e.type?e.children.map(t=>{return Object.assign(Object.assign({},K(t)),{name:(n=e.name,r=t.name,`${n}/${r=r.split(",").filter(e=>!["_","."].includes(e.trim().substr(0,1))).map(e=>e.split("=")[1]).join("/")}`)});var n,r}):[K(e)])).reduce((e,t)=>[...e,...t],[]);var Z=e=>{const t=[];return e.forEach(e=>{t.push({name:e.name,description:e.description,fontSize:e.fontSize,textDecoration:e.textDecoration,fontName:e.fontName,letterSpacing:e.letterSpacing,lineHeight:e.lineHeight,paragraphIndent:e.paragraphIndent,paragraphSpacing:e.paragraphSpacing,textCase:e.textCase})}),t};var Q=e=>{const t=[];return e.forEach(e=>{t.push({name:e.name,description:e.description,effects:e.effects})}),t};var Y=(e,t)=>{const n=V([...e.root.children]),r=t.exclusionPrefix.split(",").map(e=>e.replace(/\s+/g,""));return{tokenFrames:n,paintStyles:U(e.getLocalPaintStyles()).filter(e=>G(e,r)),gridStyles:$(e.getLocalGridStyles()).filter(e=>G(e,r)),textStyles:Z(e.getLocalTextStyles()).filter(e=>G(e,r)),effectStyles:Q(e.getLocalEffectStyles()).filter(e=>G(e,r))}};const X=e=>e.split(",").map(e=>e.replace(/\s+/g,"")),ee=(e,t)=>{const n=Y(e,t);return[..._(n.tokenFrames,X(t.prefix.size)),...H(n.tokenFrames,X(t.prefix.breakpoint)),...D(n.tokenFrames,X(t.prefix.spacing)),...B(n.tokenFrames,X(t.prefix.border)),...z(n.tokenFrames,X(t.prefix.radius)),...T(n.tokenFrames,X(t.prefix.motion)),...b(n.paintStyles,{color:X(t.prefix.color),gradient:X(t.prefix.gradient)}),...y(n.gridStyles,X(t.prefix.grid)),...M(n.textStyles,X(t.prefix.font)),...N(n.effectStyles,X(t.prefix.effect))]};var te=function(e,t,n,r){return new(n||(n=Promise))((function(i,a){function o(e){try{u(r.next(e))}catch(e){a(e)}}function s(e){try{u(r.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}u((r=r.apply(e,t||[])).next())}))};if(figma.showUI(__html__,{visible:!1}),[s.a.export,s.a.urlExport,s.a.generalSettings].includes(figma.command)){(()=>te(void 0,void 0,void 0,(function*(){const e=(()=>{let e=figma.root.getPluginData(i.a.key.settings);return""===e?r.a:(e=JSON.parse(e),Object.fromEntries(Object.entries(r.a).map(([t,n])=>void 0!==n&&typeof e[t]!=typeof n?[t,r.a[t]]:[t,e[t]])))})(),t=yield l(figma);var n;figma.ui.resize(i.a.ui[figma.command].width,i.a.ui[figma.command].height),void 0!==t&&"patch"!==t&&figma.ui.resize(i.a.ui[figma.command].width,i.a.ui[figma.command].height+60),figma.ui.postMessage({command:figma.command,payload:{settings:Object.assign(Object.assign({},e),{accessToken:yield(n=c(figma),o(void 0,void 0,void 0,(function*(){const e=yield figma.clientStorage.getAsync("accessTokens");return void 0!==e&&e instanceof Object&&e[n]||""})))}),data:Object(a.a)(ee(figma,e)),versionDifference:t,metadata:{filename:figma.root.name}}}),figma.ui.show()})))()}figma.command===s.a.help&&figma.ui.postMessage({command:s.a.help,payload:{url:"https://github.com/lukasoppermann/design-tokens"}}),figma.command===s.a.demo&&figma.ui.postMessage({command:s.a.demo,payload:{url:"https://www.figma.com/file/2MQ759R5kJtzQn4qSHuqR7/Design-Tokens-for-Figma?node-id=231%3A2"}}),figma.command===s.a.reset&&(figma.root.setPluginData(i.a.key.settings,Object(a.a)(r.a)),figma.notify("⚙️ Settings have been reset."),figma.closePlugin()),figma.ui.onmessage=e=>te(void 0,void 0,void 0,(function*(){const{command:t,payload:n}=e;var u,l,f;t===s.a.closePlugin&&(void 0!==(null==n?void 0:n.notification)&&""!==(null==n?void 0:n.notification)&&figma.notify(n.notification),figma.ui.hide(),figma.closePlugin()),t===s.a.saveSettings&&(f=n.settings,f=Object.assign(Object.assign({},r.a),f),figma.root.setPluginData(i.a.key.settings,Object(a.a)(f)),yield(u=c(figma),l=n.accessToken,o(void 0,void 0,void 0,(function*(){const e=(yield figma.clientStorage.getAsync("accessTokens"))||{},t=Object.assign(Object.assign({},e),{[u]:l});return yield figma.clientStorage.setAsync("accessTokens",t)}))),n.closePlugin&&!0===n.closePlugin&&figma.closePlugin())}))},7:function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));const r=(e,t=!0)=>!0===t?JSON.stringify(e):JSON.stringify(e,null,2)},8:function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));const r={filename:"design-tokens",extension:".tokens.json",nameConversion:"default",tokenFormat:"standard",compression:!1,urlJsonCompression:!0,serverUrl:void 0,eventType:"update-tokens",accessToken:void 0,acceptHeader:"application/vnd.github.everest-preview+json",authType:"token",exclusionPrefix:"",keyInName:!1,prefixInName:!0,prefix:{color:"color",gradient:"gradient",font:"font",effect:"effect",grid:"grid",border:"border, borders",breakpoint:"breakpoint, breakpoints",radius:"radius, radii",size:"size, sizes",spacing:"spacing",motion:"motion"},exports:{color:!0,gradient:!0,font:!0,effect:!0,grid:!0,border:!0,breakpoint:!0,radius:!0,size:!0,spacing:!0,motion:!0}}}}); \ No newline at end of file +!function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=64)}({1:function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));const r={generalSettings:"generalSettings",export:"export",sendSettings:"sendSettings",urlExport:"urlExport",help:"help",demo:"demo",openUrl:"openUrl",reset:"reset",saveSettings:"saveSettings",closePlugin:"closePlugin"}},2:function(e,t,n){"use strict";t.a=(e,t=2)=>{if(void 0===e)return;if("number"!=typeof e||"number"!=typeof t)throw new Error(`Invalid parameters, both value "${e}" (${typeof e}) and decimalPlaces "${t}" (${typeof t}) must be of type number`);const n=Math.pow(10,t);return Math.round(e*n)/n}},4:function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));const r={color:{label:"Colors",key:"color"},gradient:{label:"Gradients",key:"gradient"},font:{label:"Fonts",key:"font"},effect:{label:"Effects",key:"effect"},grid:{label:"Grids",key:"grid"},border:{label:"Borders",key:"border"},breakpoint:{label:"Breakpoints",key:"breakpoint"},radius:{label:"Radii",key:"radius"},size:{label:"Sizes",key:"size"},spacing:{label:"Spacing",key:"spacing"},motion:{label:"Motion",key:"motion"}}},5:function(e,t,n){"use strict";t.a={ui:{generalSettings:{width:550,height:685},export:{width:550,height:420},urlExport:{width:550,height:575}},key:{lastVersionSettingsOpened:"lastVersionSettingsOpened",fileId:"fileId",settings:"settings"},exclusionPrefixDefault:["_","."],fileExtensions:[{label:".tokens.json",value:".tokens.json"},{label:".tokens",value:".tokens"},{label:".json",value:".json"}]}},6:function(e,t,n){"use strict";n.d(t,"d",(function(){return R})),n.d(t,"a",(function(){return A})),n.d(t,"b",(function(){return O})),n.d(t,"c",(function(){return M}));var r=n(2);function i(e,t){(function(e){return"string"==typeof e&&-1!==e.indexOf(".")&&1===parseFloat(e)})(e)&&(e="100%");var n=function(e){return"string"==typeof e&&-1!==e.indexOf("%")}(e);return e=360===t?e:Math.min(t,Math.max(0,parseFloat(e))),n&&(e=parseInt(String(e*t),10)/100),Math.abs(e-t)<1e-6?1:e=360===t?(e<0?e%t+t:e%t)/parseFloat(String(t)):e%t/parseFloat(String(t))}function a(e){return Math.min(1,Math.max(0,e))}function o(e){return e=parseFloat(e),(isNaN(e)||e<0||e>1)&&(e=1),e}function s(e){return e<=1?100*Number(e)+"%":e}function u(e){return 1===e.length?"0"+e:String(e)}function l(e,t,n){e=i(e,255),t=i(t,255),n=i(n,255);var r=Math.max(e,t,n),a=Math.min(e,t,n),o=0,s=0,u=(r+a)/2;if(r===a)s=0,o=0;else{var l=r-a;switch(s=u>.5?l/(2-r-a):l/(r+a),r){case e:o=(t-n)/l+(t1&&(n-=1),n<1/6?e+6*n*(t-e):n<.5?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function f(e,t,n){e=i(e,255),t=i(t,255),n=i(n,255);var r=Math.max(e,t,n),a=Math.min(e,t,n),o=0,s=r,u=r-a,l=0===r?0:u/r;if(r===a)o=0;else{switch(r){case e:o=(t-n)/u+(t>16,g:(65280&e)>>8,b:255&e}}(t)),this.originalInput=t;var i=b(t);this.originalInput=t,this.r=i.r,this.g=i.g,this.b=i.b,this.a=i.a,this.roundA=Math.round(100*this.a)/100,this.format=null!==(r=n.format)&&void 0!==r?r:i.format,this.gradientType=n.gradientType,this.r<1&&(this.r=Math.round(this.r)),this.g<1&&(this.g=Math.round(this.g)),this.b<1&&(this.b=Math.round(this.b)),this.isValid=i.ok}return e.prototype.isDark=function(){return this.getBrightness()<128},e.prototype.isLight=function(){return!this.isDark()},e.prototype.getBrightness=function(){var e=this.toRgb();return(299*e.r+587*e.g+114*e.b)/1e3},e.prototype.getLuminance=function(){var e=this.toRgb(),t=e.r/255,n=e.g/255,r=e.b/255;return.2126*(t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4))+.7152*(n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4))+.0722*(r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4))},e.prototype.getAlpha=function(){return this.a},e.prototype.setAlpha=function(e){return this.a=o(e),this.roundA=Math.round(100*this.a)/100,this},e.prototype.toHsv=function(){var e=f(this.r,this.g,this.b);return{h:360*e.h,s:e.s,v:e.v,a:this.a}},e.prototype.toHsvString=function(){var e=f(this.r,this.g,this.b),t=Math.round(360*e.h),n=Math.round(100*e.s),r=Math.round(100*e.v);return 1===this.a?"hsv("+t+", "+n+"%, "+r+"%)":"hsva("+t+", "+n+"%, "+r+"%, "+this.roundA+")"},e.prototype.toHsl=function(){var e=l(this.r,this.g,this.b);return{h:360*e.h,s:e.s,l:e.l,a:this.a}},e.prototype.toHslString=function(){var e=l(this.r,this.g,this.b),t=Math.round(360*e.h),n=Math.round(100*e.s),r=Math.round(100*e.l);return 1===this.a?"hsl("+t+", "+n+"%, "+r+"%)":"hsla("+t+", "+n+"%, "+r+"%, "+this.roundA+")"},e.prototype.toHex=function(e){return void 0===e&&(e=!1),p(this.r,this.g,this.b,e)},e.prototype.toHexString=function(e){return void 0===e&&(e=!1),"#"+this.toHex(e)},e.prototype.toHex8=function(e){return void 0===e&&(e=!1),function(e,t,n,r,i){var a=[u(Math.round(e).toString(16)),u(Math.round(t).toString(16)),u(Math.round(n).toString(16)),u(d(r))];return i&&a[0].startsWith(a[0].charAt(1))&&a[1].startsWith(a[1].charAt(1))&&a[2].startsWith(a[2].charAt(1))&&a[3].startsWith(a[3].charAt(1))?a[0].charAt(0)+a[1].charAt(0)+a[2].charAt(0)+a[3].charAt(0):a.join("")}(this.r,this.g,this.b,this.a,e)},e.prototype.toHex8String=function(e){return void 0===e&&(e=!1),"#"+this.toHex8(e)},e.prototype.toRgb=function(){return{r:Math.round(this.r),g:Math.round(this.g),b:Math.round(this.b),a:this.a}},e.prototype.toRgbString=function(){var e=Math.round(this.r),t=Math.round(this.g),n=Math.round(this.b);return 1===this.a?"rgb("+e+", "+t+", "+n+")":"rgba("+e+", "+t+", "+n+", "+this.roundA+")"},e.prototype.toPercentageRgb=function(){var e=function(e){return Math.round(100*i(e,255))+"%"};return{r:e(this.r),g:e(this.g),b:e(this.b),a:this.a}},e.prototype.toPercentageRgbString=function(){var e=function(e){return Math.round(100*i(e,255))};return 1===this.a?"rgb("+e(this.r)+"%, "+e(this.g)+"%, "+e(this.b)+"%)":"rgba("+e(this.r)+"%, "+e(this.g)+"%, "+e(this.b)+"%, "+this.roundA+")"},e.prototype.toName=function(){if(0===this.a)return"transparent";if(this.a<1)return!1;for(var e="#"+p(this.r,this.g,this.b,!1),t=0,n=Object.entries(m);t=0;return t||!r||!e.startsWith("hex")&&"name"!==e?("rgb"===e&&(n=this.toRgbString()),"prgb"===e&&(n=this.toPercentageRgbString()),"hex"!==e&&"hex6"!==e||(n=this.toHexString()),"hex3"===e&&(n=this.toHexString(!0)),"hex4"===e&&(n=this.toHex8String(!0)),"hex8"===e&&(n=this.toHex8String()),"name"===e&&(n=this.toName()),"hsl"===e&&(n=this.toHslString()),"hsv"===e&&(n=this.toHsvString()),n||this.toHexString()):"name"===e&&0===this.a?this.toName():this.toRgbString()},e.prototype.toNumber=function(){return(Math.round(this.r)<<16)+(Math.round(this.g)<<8)+Math.round(this.b)},e.prototype.clone=function(){return new e(this.toString())},e.prototype.lighten=function(t){void 0===t&&(t=10);var n=this.toHsl();return n.l+=t/100,n.l=a(n.l),new e(n)},e.prototype.brighten=function(t){void 0===t&&(t=10);var n=this.toRgb();return n.r=Math.max(0,Math.min(255,n.r-Math.round(-t/100*255))),n.g=Math.max(0,Math.min(255,n.g-Math.round(-t/100*255))),n.b=Math.max(0,Math.min(255,n.b-Math.round(-t/100*255))),new e(n)},e.prototype.darken=function(t){void 0===t&&(t=10);var n=this.toHsl();return n.l-=t/100,n.l=a(n.l),new e(n)},e.prototype.tint=function(e){return void 0===e&&(e=10),this.mix("white",e)},e.prototype.shade=function(e){return void 0===e&&(e=10),this.mix("black",e)},e.prototype.desaturate=function(t){void 0===t&&(t=10);var n=this.toHsl();return n.s-=t/100,n.s=a(n.s),new e(n)},e.prototype.saturate=function(t){void 0===t&&(t=10);var n=this.toHsl();return n.s+=t/100,n.s=a(n.s),new e(n)},e.prototype.greyscale=function(){return this.desaturate(100)},e.prototype.spin=function(t){var n=this.toHsl(),r=(n.h+t)%360;return n.h=r<0?360+r:r,new e(n)},e.prototype.mix=function(t,n){void 0===n&&(n=50);var r=this.toRgb(),i=new e(t).toRgb(),a=n/100;return new e({r:(i.r-r.r)*a+r.r,g:(i.g-r.g)*a+r.g,b:(i.b-r.b)*a+r.b,a:(i.a-r.a)*a+r.a})},e.prototype.analogous=function(t,n){void 0===t&&(t=6),void 0===n&&(n=30);var r=this.toHsl(),i=360/n,a=[this];for(r.h=(r.h-(i*t>>1)+720)%360;--t;)r.h=(r.h+i)%360,a.push(new e(r));return a},e.prototype.complement=function(){var t=this.toHsl();return t.h=(t.h+180)%360,new e(t)},e.prototype.monochromatic=function(t){void 0===t&&(t=6);for(var n=this.toHsv(),r=n.h,i=n.s,a=n.v,o=[],s=1/t;t--;)o.push(new e({h:r,s:i,v:a})),a=(a+s)%1;return o},e.prototype.splitcomplement=function(){var t=this.toHsl(),n=t.h;return[this,new e({h:(n+72)%360,s:t.s,l:t.l}),new e({h:(n+216)%360,s:t.s,l:t.l})]},e.prototype.onBackground=function(t){var n=this.toRgb(),r=new e(t).toRgb();return new e({r:r.r+(n.r-r.r)*n.a,g:r.g+(n.g-r.g)*n.a,b:r.b+(n.b-r.b)*n.a})},e.prototype.triad=function(){return this.polyad(3)},e.prototype.tetrad=function(){return this.polyad(4)},e.prototype.polyad=function(t){for(var n=this.toHsl(),r=n.h,i=[this],a=360/t,o=1;o({r:Object(r.a)(255*e.r,0),g:Object(r.a)(255*e.g,0),b:Object(r.a)(255*e.b,0),a:Object(r.a)(t||e.a||1)}),A=e=>"SOLID"===e.type&&!0===e.visible?R(e.color,e.opacity||null):null,O=e=>`rgba(${e.r}, ${e.g}, ${e.b}, ${e.a})`,M=e=>{return(t=e,r={r:s(t.r),g:s(t.g),b:s(t.b)},void 0!==t.a&&(r.a=Number(t.a)),new w(r,n)).toHex8String();var t,n,r}},64:function(e,t,n){"use strict";n.r(t);var r=n(8),i=n(5),a=n(7);var o=function(e,t,n,r){return new(n||(n=Promise))((function(i,a){function o(e){try{u(r.next(e))}catch(e){a(e)}}function s(e){try{u(r.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}u((r=r.apply(e,t||[])).next())}))};var s=n(1);var u=function(e,t,n,r){return new(n||(n=Promise))((function(i,a){function o(e){try{u(r.next(e))}catch(e){a(e)}}function s(e){try{u(r.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}u((r=r.apply(e,t||[])).next())}))};var l=e=>u(void 0,void 0,void 0,(function*(){const t=yield e.clientStorage.getAsync(i.a.key.lastVersionSettingsOpened),n=((e,t="1.0.0")=>{const[n,r,i]=t.split("."),[a,o,s]=e.split(".");return n{let t=e.root.getPluginData(i.a.key.fileId);return void 0!==t&&""!==t||(e.root.setPluginData(i.a.key.fileId,e.root.name+" "+Math.floor(1e9*Math.random())),t=e.root.getPluginData(i.a.key.fileId)),t},f=n(4),p=n(6),d=n(2);const g={GRADIENT_LINEAR:"linear",GRADIENT_RADIAL:"radial",GRADIENT_ANGULAR:"angular",GRADIENT_DIAMOND:"diamond"},h=e=>["GRADIENT_LINEAR","GRADIENT_RADIAL","GRADIENT_ANGULAR","GRADIENT_DIAMOND"].includes(e.type),m=([[e,t],[n,r]])=>{const i=Math.atan2(r-t,n-e)*(180/Math.PI)+315;return i>360?i-360:i};var b=(e,t)=>e.map(e=>(e.paints=e.paints.filter(e=>"IMAGE"!==e.type),e)).filter(e=>e.paints.length>0).map(e=>({name:`${h(e.paints[0])?t.gradient[0]:t.color[0]}/${e.name}`,category:h(e.paints[0])?"gradient":"color",exportKey:h(e.paints[0])?f.a.gradient.key:f.a.color.key,description:e.description||null,values:e.paints.map(e=>(e=>"SOLID"===e.type?{fill:{value:Object(p.a)(e),type:"color"}}:["GRADIENT_LINEAR","GRADIENT_RADIAL","GRADIENT_ANGULAR","GRADIENT_DIAMOND"].includes(e.type)?{gradientType:{value:g[e.type],type:"string"},rotation:{value:m(e.gradientTransform),type:"number",unit:"degree"},stops:e.gradientStops.map(e=>({position:{value:Object(d.a)(e.position),type:"number"},color:{value:Object(p.d)(e.color),type:"color"}})),opacity:{value:Object(d.a)(e.opacity),type:"number"}}:null)(e))}));var y=(e,t)=>e.filter(e=>e.layoutGrids.length>0).map(e=>({name:`${t[0]}/${e.name}`,category:"grid",exportKey:f.a.grid.key,description:e.description||null,values:e.layoutGrids.map(e=>"GRID"===e.pattern?(e=>({pattern:{value:e.pattern.toLowerCase(),type:"string"},sectionSize:{value:e.sectionSize,unit:"pixel",type:"number"}}))(e):(e=>{return Object.assign(Object.assign(Object.assign({pattern:{value:e.pattern.toLowerCase(),type:"string"}},void 0!==e.sectionSize&&{sectionSize:{value:e.sectionSize,unit:"pixel",type:"number"}}),{gutterSize:{value:e.gutterSize,unit:"pixel",type:"number"},alignment:{value:e.alignment.toLowerCase(),type:"string"},count:(t=e.count,t===1/0?{value:"auto",type:"string"}:{value:t,type:"number"})}),void 0!==e.offset&&{offset:{value:e.offset,unit:"pixel",type:"number"}});var t})(e))}));const v={NONE:"none",UNDERLINE:"underline",STRIKETHROUGH:"line-through"},x={ORIGINAL:"none",UPPER:"uppercase",LOWER:"lowercase",TITLE:"capitalize"},k={thin:100,extralight:200,ultralight:200,light:300,normal:400,regular:400,medium:500,semibold:600,demibold:600,bold:700,extrabold:800,ultabold:800,black:900,heavy:900,super:900},S={normal:"normal",condensed:"condensed",expanded:"expanded",extended:"expanded"},w={normal:"normal",italic:"italic",oblique:"oblique"},R=e=>{const t=e.toLowerCase().split(" ");let n=t[0];return["extra","ultra","semi","demi"].includes(t[0])&&["bold","light"].includes(t[1])&&(n=`${t[0]}${t[1]}`),k[n]||400},A=e=>{const t=e.toLowerCase().split(" ");return S[t[t.length-1]]||S[t[t.length-2]]||"normal"},O=e=>{const t=e.toLowerCase().split(" ").pop();return w[t]||"normal"};var M=(e,t)=>e.map(e=>({name:`${t[0]}/${e.name}`,category:"font",exportKey:f.a.font.key,description:e.description||void 0,values:{fontSize:{value:e.fontSize,unit:"pixel",type:"number"},textDecoration:{value:v[e.textDecoration],type:"string"},fontFamily:{value:e.fontName.family,type:"string"},fontWeight:{value:R(e.fontName.style),type:"number"},fontStyle:{value:O(e.fontName.style),type:"string"},fontStretch:{value:A(e.fontName.style),type:"string"},_fontStyleOld:{value:e.fontName.style,type:"string"},letterSpacing:{value:Object(d.a)(e.letterSpacing.value),unit:e.letterSpacing.unit.toLowerCase(),type:"number"},lineHeight:{value:Object(d.a)(e.lineHeight.value)||"normal",unit:"pixels"===e.lineHeight.unit.toLowerCase()?"pixel":e.lineHeight.unit.toLowerCase(),type:Object.prototype.hasOwnProperty.call(e.lineHeight,"value")?"number":"string"},paragraphIndent:{value:e.paragraphIndent,unit:"pixel",type:"number"},paragraphSpacing:{value:e.paragraphSpacing,unit:"pixel",type:"number"},textCase:{value:x[e.textCase],type:"string"}}}));const E={LAYER_BLUR:"layerBlur",BACKGROUND_BLUR:"backgroundBlur",DROP_SHADOW:"dropShadow",INNER_SHADOW:"innerShadow"};var N=(e,t)=>e.filter(e=>e.effects.length>0).map(e=>({name:`${t[0]}/${e.name}`,category:"effect",exportKey:f.a.effect.key,description:e.description||null,values:e.effects.map(e=>"LAYER_BLUR"===e.type||"BACKGROUND_BLUR"===e.type?(e=>({effectType:{value:E[e.type],type:"string"},radius:{value:e.radius,unit:"pixel",type:"number"}}))(e):(e=>({effectType:{value:E[e.type],type:"string"},radius:{value:e.radius,unit:"pixel",type:"number"},color:{value:Object(p.d)(e.color),type:"color"},offset:{x:{value:e.offset.x,unit:"pixel",type:"number"},y:{value:e.offset.y,unit:"pixel",type:"number"}},spread:{value:e.spread,unit:"pixel",type:"number"}}))(e))}));const I=e=>t=>e.includes(t.name.substr(0,t.name.indexOf("/")).replace(/\s+/g,"")),j=e=>{if(Object.prototype.hasOwnProperty.call(e,"direction"))return{direction:{value:e.direction.toLowerCase(),type:"string"}}},C={CUSTOM_CUBIC_BEZIER:{},LINEAR:{type:"linear",easingFunctionCubicBezier:{x1:0,y1:0,x2:1,y2:1}},EASE_IN:{type:"ease-in",easingFunctionCubicBezier:{x1:.41999998688697815,y1:0,x2:1,y2:1}},EASE_OUT:{type:"ease-out",easingFunctionCubicBezier:{x1:0,y1:0,x2:.5799999833106995,y2:1}},EASE_IN_AND_OUT:{type:"ease-in-out",easingFunctionCubicBezier:{x1:.41999998688697815,y1:0,x2:.5799999833106995,y2:1}},EASE_IN_BACK:{type:"ease-in-back",easingFunctionCubicBezier:{x1:.30000001192092896,y1:-.05000000074505806,x2:.699999988079071,y2:-.5}},EASE_OUT_BACK:{type:"ease-out-back",easingFunctionCubicBezier:{x1:.44999998807907104,y1:1.4500000476837158,x2:.800000011920929,y2:1}},EASE_IN_AND_OUT_BACK:{type:"ease-in-out-back",easingFunctionCubicBezier:{x1:.699999988079071,y1:-.4000000059604645,x2:.4000000059604645,y2:1.399999976158142}}},L=e=>{if("type"in e&&void 0!==C[e.type])return"CUSTOM_CUBIC_BEZIER"===e.type&&(C.CUSTOM_CUBIC_BEZIER={type:"cubic-bezier",easingFunctionCubicBezier:{x1:e.easingFunctionCubicBezier.x1,y1:e.easingFunctionCubicBezier.y1,x2:e.easingFunctionCubicBezier.x2,y2:e.easingFunctionCubicBezier.y2}}),{easing:{value:C[e.type].type,type:"string"},easingFunction:{x1:{value:C[e.type].easingFunctionCubicBezier.x1,type:"number"},x2:{value:C[e.type].easingFunctionCubicBezier.x2,type:"number"},y1:{value:C[e.type].easingFunctionCubicBezier.y1,type:"number"},y2:{value:C[e.type].easingFunctionCubicBezier.y2,type:"number"}}}};var T=(e,t)=>e.filter(I(t)).filter(e=>{var t;return e.reactions.length>0&&"NODE"===(null===(t=e.reactions[0].action)||void 0===t?void 0:t.type)&&null!==e.reactions[0].action.transition}).map(e=>({name:e.name,category:"motion",exportKey:f.a.motion.key,description:e.description||null,values:Object.assign(Object.assign({transitionType:{value:e.reactions[0].action.transition.type.toLocaleLowerCase(),type:"string"},duration:{value:Math.round(1e3*(e.reactions[0].action.transition.duration+Number.EPSILON))/1e3,unit:"s",type:"number"}},L(e.reactions[0].action.transition.easing)),j(e.reactions[0].action.transition))}));var _=(e,t)=>e.filter(I(t)).map(e=>({name:e.name,category:"size",exportKey:f.a.size.key,description:e.description||null,values:{width:{value:Object(d.a)(e.width,2),unit:"pixel",type:"number"},height:{value:Object(d.a)(e.height,2),unit:"pixel",type:"number"}}}));var D=(e,t)=>e.filter(I(t)).map(e=>({name:e.name,category:"spacing",exportKey:f.a.spacing.key,description:e.description||null,values:{top:{value:Object(d.a)(e.paddingTop,2),unit:"pixel",type:"number"},right:{value:Object(d.a)(e.paddingRight,2),unit:"pixel",type:"number"},bottom:{value:Object(d.a)(e.paddingBottom,2),unit:"pixel",type:"number"},left:{value:Object(d.a)(e.paddingLeft,2),unit:"pixel",type:"number"}}}));const F={MITER:"miter",BEVEL:"bevel",ROUND:"round"},P={CENTER:"center",INSIDE:"inside",OUTSIDE:"outside"};var B=(e,t)=>e.filter(I(t)).filter(e=>e.strokes.length>0).map(e=>({name:e.name,category:"border",exportKey:f.a.border.key,description:e.description||null,values:{strokeAlign:{value:P[e.strokeAlign],type:"string"},dashPattern:{value:[...e.dashPattern],type:"string"},strokeCap:{value:"string"==typeof e.strokeCap?e.strokeCap.toLowerCase():"mixed",type:"string"},strokeJoin:{value:F[e.strokeJoin],type:"string"},strokeMiterLimit:{value:Object(d.a)(e.strokeMiterLimit),unit:"degree",type:"number"},strokeWeight:{value:e.strokeWeight,unit:"pixel",type:"number"},stroke:{value:e.strokes[0],type:"color"}}}));var z=(e,t)=>{const n=e=>({topLeft:{value:e.topLeftRadius||0,unit:"pixel",type:"number"},topRight:{value:e.topRightRadius||0,unit:"pixel",type:"number"},bottomRight:{value:e.bottomRightRadius||0,unit:"pixel",type:"number"},bottomLeft:{value:e.bottomLeftRadius||0,unit:"pixel",type:"number"}});return e.filter(I(t)).map(e=>{return{name:e.name,category:"radius",exportKey:f.a.radius.key,description:e.description||null,values:Object.assign(Object.assign({},"number"==typeof e.cornerRadius&&{radius:{value:e.cornerRadius,unit:"pixel",type:"number"}}),{radiusType:{value:(t=e.cornerRadius,"number"==typeof t?"single":"mixed"),type:"string"},radii:n(e),smoothing:{value:Object(d.a)(e.cornerSmoothing,2),comment:"Percent as decimal from 0.0 - 1.0",type:"number"}})};var t})};var H=(e,t)=>e.filter(I(t)).map(e=>({name:e.name,category:"breakpoint",exportKey:f.a.breakpoint.key,description:e.description||null,values:{width:{value:Object(d.a)(e.width,2),unit:"pixel",type:"number"},height:{value:Object(d.a)(e.height,2),unit:"pixel",type:"number"}}}));var G=(e,t)=>!(e=>[...i.a.exclusionPrefixDefault,...e])(t).includes(e.name.trim().substr(0,1));var U=e=>{const t=[];return e.forEach(e=>{t.push({name:e.name,description:e.description,paints:e.paints})}),t};var $=e=>{const t=[];return e.forEach(e=>{t.push({name:e.name,description:e.description,layoutGrids:e.layoutGrids})}),t};var K=e=>{return{name:e.name,description:e.description||void 0,bottomLeftRadius:e.bottomLeftRadius,bottomRightRadius:e.bottomRightRadius,topLeftRadius:e.topLeftRadius,topRightRadius:e.topRightRadius,cornerRadius:e.cornerRadius||void 0,cornerSmoothing:e.cornerSmoothing,strokes:(t=e.strokes,[...t].map(e=>Object(p.a)(e)).filter(e=>null!=e)),strokeWeight:e.strokeWeight,strokeStyleId:e.strokeStyleId,strokeMiterLimit:e.strokeMiterLimit,strokeJoin:e.strokeJoin,strokeCap:e.strokeCap,dashPattern:e.dashPattern,strokeAlign:e.strokeAlign,width:e.width,height:e.height,reactions:e.reactions||void 0,paddingTop:e.paddingTop||0,paddingRight:e.paddingRight||0,paddingBottom:e.paddingBottom||0,paddingLeft:e.paddingLeft||0};var t};const W=["COMPONENT","COMPONENT_SET","RECTANGLE","FRAME"];var q=e=>"COMPONENT_SET"!==e.parent.type&&W.includes(e.type);const J=e=>"FRAME"===e.type&&"_tokens"===e.name.trim().toLowerCase().substr(0,"_tokens".length);var V=e=>[...e.map(e=>e.findChildren(e=>J(e))).reduce((e,t)=>[...e,...t])].map(e=>e.findAll(e=>q(e))).reduce((e,t)=>[...e,...t],[]).map(e=>("RECTANGLE"!==e.type&&"FRAME"!==e.type||console.warn("Please use only main components and variants, other types may be deprecated as tokens in the future"),"COMPONENT_SET"===e.type?e.children.map(t=>{return Object.assign(Object.assign({},K(t)),{name:(n=e.name,r=t.name,`${n}/${r=r.split(",").filter(e=>!["_","."].includes(e.trim().substr(0,1))).map(e=>e.split("=")[1]).join("/")}`)});var n,r}):[K(e)])).reduce((e,t)=>[...e,...t],[]);var Z=e=>{const t=[];return e.forEach(e=>{t.push({name:e.name,description:e.description,fontSize:e.fontSize,textDecoration:e.textDecoration,fontName:e.fontName,letterSpacing:e.letterSpacing,lineHeight:e.lineHeight,paragraphIndent:e.paragraphIndent,paragraphSpacing:e.paragraphSpacing,textCase:e.textCase})}),t};var Q=e=>{const t=[];return e.forEach(e=>{t.push({name:e.name,description:e.description,effects:e.effects})}),t};var Y=(e,t)=>{const n=V([...e.root.children]),r=t.exclusionPrefix.split(",").map(e=>e.replace(/\s+/g,""));return{tokenFrames:n,paintStyles:U(e.getLocalPaintStyles()).filter(e=>G(e,r)),gridStyles:$(e.getLocalGridStyles()).filter(e=>G(e,r)),textStyles:Z(e.getLocalTextStyles()).filter(e=>G(e,r)),effectStyles:Q(e.getLocalEffectStyles()).filter(e=>G(e,r))}};const X=e=>e.split(",").map(e=>e.replace(/\s+/g,"")),ee=(e,t)=>{const n=Y(e,t);return[..._(n.tokenFrames,X(t.prefix.size)),...H(n.tokenFrames,X(t.prefix.breakpoint)),...D(n.tokenFrames,X(t.prefix.spacing)),...B(n.tokenFrames,X(t.prefix.border)),...z(n.tokenFrames,X(t.prefix.radius)),...T(n.tokenFrames,X(t.prefix.motion)),...b(n.paintStyles,{color:X(t.prefix.color),gradient:X(t.prefix.gradient)}),...y(n.gridStyles,X(t.prefix.grid)),...M(n.textStyles,X(t.prefix.font)),...N(n.effectStyles,X(t.prefix.effect))]};var te=function(e,t,n,r){return new(n||(n=Promise))((function(i,a){function o(e){try{u(r.next(e))}catch(e){a(e)}}function s(e){try{u(r.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}u((r=r.apply(e,t||[])).next())}))};if(figma.showUI(__html__,{visible:!1}),[s.a.export,s.a.urlExport,s.a.generalSettings].includes(figma.command)){(()=>te(void 0,void 0,void 0,(function*(){const e=(()=>{let e=figma.root.getPluginData(i.a.key.settings);return""===e?r.a:(e=JSON.parse(e),Object.fromEntries(Object.entries(r.a).map(([t,n])=>void 0!==n&&typeof e[t]!=typeof n?[t,r.a[t]]:[t,e[t]])))})(),t=yield l(figma);var n;figma.ui.resize(i.a.ui[figma.command].width,i.a.ui[figma.command].height),void 0!==t&&"patch"!==t&&figma.ui.resize(i.a.ui[figma.command].width,i.a.ui[figma.command].height+60),figma.ui.postMessage({command:figma.command,payload:{settings:Object.assign(Object.assign({},e),{accessToken:yield(n=c(figma),o(void 0,void 0,void 0,(function*(){const e=yield figma.clientStorage.getAsync("accessTokens");return void 0!==e&&e instanceof Object&&e[n]||""})))}),data:Object(a.a)(ee(figma,e)),versionDifference:t,metadata:{filename:figma.root.name}}}),figma.ui.show()})))()}figma.command===s.a.help&&figma.ui.postMessage({command:s.a.help,payload:{url:"https://github.com/lukasoppermann/design-tokens"}}),figma.command===s.a.demo&&figma.ui.postMessage({command:s.a.demo,payload:{url:"https://www.figma.com/file/2MQ759R5kJtzQn4qSHuqR7/Design-Tokens-for-Figma?node-id=231%3A2"}}),figma.command===s.a.reset&&(figma.root.setPluginData(i.a.key.settings,Object(a.a)(r.a)),figma.notify("⚙️ Settings have been reset."),figma.closePlugin()),figma.ui.onmessage=e=>te(void 0,void 0,void 0,(function*(){const{command:t,payload:n}=e;var u,l,f;t===s.a.closePlugin&&(void 0!==(null==n?void 0:n.notification)&&""!==(null==n?void 0:n.notification)&&figma.notify(n.notification),figma.ui.hide(),figma.closePlugin()),t===s.a.saveSettings&&(f=n.settings,f=Object.assign(Object.assign({},r.a),f),figma.root.setPluginData(i.a.key.settings,Object(a.a)(f)),yield(u=c(figma),l=n.accessToken,o(void 0,void 0,void 0,(function*(){const e=(yield figma.clientStorage.getAsync("accessTokens"))||{},t=Object.assign(Object.assign({},e),{[u]:l});return yield figma.clientStorage.setAsync("accessTokens",t)}))),n.closePlugin&&!0===n.closePlugin&&figma.closePlugin())}))},7:function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));const r=(e,t=!0)=>!0===t?JSON.stringify(e):JSON.stringify(e,null,2)},8:function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));const r={filename:"design-tokens",extension:".tokens.json",nameConversion:"default",tokenFormat:"standard",compression:!1,urlJsonCompression:!0,serverUrl:void 0,eventType:"update-tokens",accessToken:void 0,acceptHeader:"application/vnd.github.everest-preview+json",authType:"token",exclusionPrefix:"",keyInName:!1,prefixInName:!0,prefix:{color:"color",gradient:"gradient",font:"font",effect:"effect",grid:"grid",border:"border, borders",breakpoint:"breakpoint, breakpoints",radius:"radius, radii",size:"size, sizes",spacing:"spacing",motion:"motion"},exports:{color:!0,gradient:!0,font:!0,effect:!0,grid:!0,border:!0,breakpoint:!0,radius:!0,size:!0,spacing:!0,motion:!0}}}}); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 42aae98c..c71fb271 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "design-tokens", - "version": "5.1.1", + "version": "6.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 364ee769..3a6ada33 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "design-tokens", - "version": "5.1.1", + "version": "6.0.0", "description": "Export design tokens from Figma", "main": "code.js", "repository": { diff --git a/src/utilities/version.ts b/src/utilities/version.ts index 7b95e931..81470815 100644 --- a/src/utilities/version.ts +++ b/src/utilities/version.ts @@ -1,3 +1,3 @@ /* istanbul ignore file */ -const version = '5.1.1' +const version = '6.0.0' export default version