figma-image-to-design 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/package.json +26 -26
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ScreenshotToDesign={})}(this,(function(t){"use strict";function e(t,e,o,i){return new(o||(o=Promise))((function(r,n){function l(t){try{a(i.next(t))}catch(t){n(t)}}function s(t){try{a(i.throw(t))}catch(t){n(t)}}function a(t){var e;t.done?r(t.value):(e=t.value,e instanceof o?e:new o((function(t){t(e)}))).then(l,s)}a((i=i.apply(t,e||[])).next())}))}class o{static convertToDslSchema(t){return{id:t.elementId,name:t.elementName,type:t.elementType,enName:t.displayName,layout:this.convertLayoutConfiguration(t.layoutConfig),style:this.convertVisualStyle(t.styleConfig),i2dExt:this.convertProcessingMetadata(t.processingMeta),content:t.contentData?this.convertElementContent(t.contentData):void 0,component:t.componentSpec?this.convertComponentDefinition(t.componentSpec):void 0,children:t.childElements?t.childElements.map((t=>this.convertToDslSchema(t))):void 0}}static convertVisualColor(t){return{rgb:t.rgbValues,hex:t.hexCode}}static convertVisualStyle(t){const e={width:t.widthSpec,height:t.heightSpec};return t.textConfig&&(e.text={fontFamily:t.textConfig.fontFamily,fontSize:t.textConfig.fontSize,fontWeight:t.textConfig.fontWeight,fontStyle:t.textConfig.fontStyle,textAlign:t.textConfig.textAlign,textDecoration:t.textConfig.textDecoration}),t.borderConfig&&(e.border={borderColor:t.borderConfig.borderColor?this.convertVisualColor(t.borderConfig.borderColor):void 0,borderWidth:t.borderConfig.borderWidth,borderRadius:t.borderConfig.borderRadius}),t.backgroundSpec&&(e.background={backgroundColor:t.backgroundSpec.backgroundColor?this.convertVisualColor(t.backgroundSpec.backgroundColor):void 0}),t.textColor&&(e.color=this.convertVisualColor(t.textColor)),void 0!==t.paddingValues&&(e.padding=t.paddingValues),void 0!==t.opacityLevel&&(e.opacity=t.opacityLevel),void 0!==t.overflowMode&&(e.overflow=t.overflowMode),void 0!==t.rotationAngle&&(e.rotation=t.rotationAngle),t.textDetection&&(e.text_det=t.textDetection),t.textExtraction&&(e.text_ext=t.textExtraction),e}static convertLayoutConfiguration(t){return{positionType:t.positionMode,flexibleType:t.flexibleMode,flexAttrs:t.flexAttributes,absoluteAttrs:t.absoluteAttrs}}static convertElementContent(t){const e={};if(t.textValue&&(e.text=t.textValue),t.imageSource&&(e.imageUrl=t.imageSource),t.colorReference&&(e.colorTokenId=t.colorReference),t.componentReference&&(e.componentId=t.componentReference),t.componentAttributes){const o={};for(const[e,i]of Object.entries(t.componentAttributes))o[e]=i;e.componentProperties=o}return e}static convertComponentDefinition(t){return{id:t.componentId,name:t.componentName,code:t.sourceCode,properties:t.configOptions}}static convertProcessingMetadata(t){return{area:t.surfaceArea,yolo_confidence:t.detectionScore,text_is_containerized:t.textContainerized}}}var i,r,n;function l(t){return{r:parseInt(t.slice(1,3),16)/255,g:parseInt(t.slice(3,5),16)/255,b:parseInt(t.slice(5,7),16)/255}}function s(t,e){var o,i,r,n,l,a;const d="schema:id";if("children"in t)for(let u=0;u<t.children.length;u++){const c=t.children[u],v=c.getPluginData(d),y=null===(o=e.children)||void 0===o?void 0:o.find((t=>t.id===v));if(y){if("Absolute"===y.layout.positionType&&(null===(i=y.layout.absoluteAttrs)||void 0===i?void 0:i.align)){const[e,o]=y.layout.absoluteAttrs.align;let i=0,s=0;switch(e){case"LEFT":i=(null===(n=null===(r=y.layout.absoluteAttrs)||void 0===r?void 0:r.coord)||void 0===n?void 0:n[0])||0;break;case"RIGHT":i=t.width-c.width;break;case"CENTER":i=(t.width-c.width)/2}switch(o){case"TOP":s=(null===(a=null===(l=y.layout.absoluteAttrs)||void 0===l?void 0:l.coord)||void 0===a?void 0:a[1])||0;break;case"BOTTOM":s=t.height-c.height;break;case"CENTER":s=(t.height-c.height)/2}c.x=i,c.y=s}"children"in c&&c.children&&c.children.length>0&&s(c,y)}}}!function(t){t.Component="Component",t.Body="Body",t.Layer="Layer"}(i||(i={})),function(t){t.Flex="Flex"}(r||(r={})),function(t){t.Absolute="Absolute",t.Normal="Normal"}(n||(n={}));const a=["Inter","Roboto","Arial"],d=[];function u(t){return e(this,arguments,void 0,(function*(t,o=-1,i=-1){if((t=t.replace("http:","https:")).endsWith(".svg")){const r=figma.createFrame();return o>0&&i>0&&r.resize(o,i),r.backgrounds=[{type:"SOLID",color:{r:0,g:0,b:0},opacity:0}],function(t,o){e(this,arguments,void 0,(function*(t,e,o=-1,i=-1){try{const r=yield fetch(e),n=yield r.text(),l=figma.createNodeFromSvg(n);t.appendChild(l),o>0&&i>0&&(t.resize(o,i),l.resize(o,i))}catch(t){}}))}(r,t,o,i),r}const r=figma.createRectangle();return o>0&&i>0&&r.resize(o,i),r.fills=[{type:"SOLID",color:{r:1,g:1,b:1}}],function(t,o){e(this,void 0,void 0,(function*(){try{const e=yield fetch(o),i=yield e.arrayBuffer();let r=figma.createImage(new Uint8Array(i)).hash;t.fills=[{type:"IMAGE",scaleMode:"FILL",imageHash:r}]}catch(t){}}))}(r,t),r}))}function c(t){return e(this,void 0,void 0,(function*(){try{return t.length>=24&&137===t[0]&&80===t[1]&&78===t[2]&&71===t[3]?function(t){if(t.length<24)throw new Error("Invalid PNG file - too short");if(73!==t[12]||72!==t[13]||68!==t[14]||82!==t[15])throw new Error("Invalid PNG file - missing IHDR chunk");const e=t[16]<<24|t[17]<<16|t[18]<<8|t[19],o=t[20]<<24|t[21]<<16|t[22]<<8|t[23];return{width:e,height:o}}(t):{width:0,height:0}}catch(t){return{width:0,height:0}}}))}function v(t){return e(this,void 0,void 0,(function*(){const e=yield t.exportAsync({format:"PNG",constraint:{type:"SCALE",value:1}});let{width:o,height:i}=yield c(e);return(0==o||0==i||function(t,e,o,i){if(t<1||e<1)return!0;const r=(t,e)=>{let o=Math.abs(t-e);return o>(e>10?10:5)&&o/e>.3};return!(!r(t,o)&&!r(e,i))}(o,i,t.width,t.height))&&(o=t.width,i=t.height),{textWidth:o,textHeight:i}}))}const y="schema:id";class h{static createFigmaElementFromDSL(t){return e(this,arguments,void 0,(function*(t,o=null){let r;switch(t.type){case"Text":r=yield this.createTextElement(t);break;case"Image":r=yield this.createImageElement(t);break;case i.Component:case i.Body:r=this.createFrameElement(t,!1);break;case i.Layer:r=this.createFrameElement(t,!0);break;default:r=figma.createFrame()}if(this.applyBasicProperties(r,t),this.applyLayoutProperties(r,t),this.applyStyleProperties(r,t),o&&("TEXT"===r.type&&(yield function(t,o){return e(this,void 0,void 0,(function*(){var e,i,r,n,l,s;const a=o.textAutoResize,d=o.leadingTrim,u=Math.max(1,Number(o.fontSize)||12);try{const c=Number(null===(i=null===(e=t.style)||void 0===e?void 0:e.text_ext)||void 0===i?void 0:i.text_box_height)||12,y=Number(null===(n=null===(r=t.style)||void 0===r?void 0:r.width)||void 0===n?void 0:n.value)||12,h=Number(null===(s=null===(l=t.style)||void 0===l?void 0:l.height)||void 0===s?void 0:s.value)||12;o.resize(y,o.height),o.leadingTrim="CAP_HEIGHT",o.textAutoResize="WIDTH_AND_HEIGHT";let g=u,f=Math.max(0,g-20);g>200?f=Math.max(0,g-100):g>140?f=Math.max(0,g-50):g>90?f=Math.max(0,g-40):g>70?f=Math.max(0,g-35):g>40&&(f=Math.max(0,g-30));let b=g+10,m=g,p=.3,x=!1;for(;f<=b&&(g=(f+b)/2,!(g<1));){o.fontSize=g;const{textWidth:t,textHeight:e}=yield v(o);if(0===t||0===t)return o.fontSize=u,o.textAutoResize=a,void(o.leadingTrim=d);e<=c&&t<=y&&o.height<h&&o.width<y?(m=g,f=g+p,x=!0):b=g-p}if(!x){let t=f>10?10:5;for(;f>1;){b=f,f=Math.max(1,f-t),o.fontSize=f;const{textWidth:e,textHeight:i}=yield v(o);if(i<=c&&e<=y&&o.height<h&&o.width<y)break}for(;f<=b&&(g=(f+b)/2,!(g<1));){o.fontSize=g;const{textWidth:t,textHeight:e}=yield v(o);e<=c&&t<=y&&o.height<h&&o.width<y?(m=g,f=g+p):b=g-p}}let A=Math.floor(10*m)/10;A<=0&&(A=u),o.fontSize=A,o.textAutoResize=a,o.leadingTrim=d}catch(t){o.fontSize=u,o.textAutoResize=a,o.leadingTrim=d}}))}(t,r),function(t,e){var o,i,r;const n=e.characters;if(0==n.length||!n.includes("\n"))return;const l=Number(null===(i=null===(o=t.style)||void 0===o?void 0:o.text_ext)||void 0===i?void 0:i.text_box_height)||0;if(0==l)return;let s=l/(((null===(r=n.match(/\n/g))||void 0===r?void 0:r.length)||0)+1),a=e.fontSize;if(a>s)return;let d=a,u=s,c=d,v=u;for(;u-d>.3;){const t=(d+u)/2;if(e.lineHeight={unit:"PIXELS",value:t},e.height==l)break;if(e.height>l?u=t:d=t,d===c&&u===v)break;c=d,v=u}const y=(d+u)/2;e.lineHeight=y<a?{unit:"PIXELS",value:a}:{unit:"PIXELS",value:y}}(t,r)),o.appendChild(r)),t.children&&"FRAME"===r.type)for(let e of t.children)yield this.createFigmaElementFromDSL(e,r);return s(r,t),r}))}static createTextElement(t){return e(this,void 0,void 0,(function*(){var o,i,r,n,s,u,c,v,y,h,g,f,b,m,p,x,A,R,S,E,C,I;const T=figma.createText(),N=(null===(i=null===(o=t.style)||void 0===o?void 0:o.text)||void 0===i?void 0:i.fontFamily)||"Roboto";let D;D=(null===(n=null===(r=t.style)||void 0===r?void 0:r.text)||void 0===n?void 0:n.fontWeight)?function(t,e){return"number"==typeof e?e>=700?"Bold":e>=600?"inter"==t.toLowerCase()?"Semi Bold":"Semibold":e>=500?"Medium":e>=400?"Regular":e>=300?"Light":"Thin":e||"Regular"}(N,null===(u=null===(s=t.style)||void 0===s?void 0:s.text)||void 0===u?void 0:u.fontWeight):function(t,e){if("string"==typeof e)switch(e.toLowerCase()){case"medium":return"Medium";case"extra_bold":case"bold":case"semi_bold":return"inter"==t.toLowerCase()?"Semi Bold":"Semibold";case"regular":default:return"Regular";case"light":return"Light"}return e||"Regular"}(N,null===(v=null===(c=t.style)||void 0===c?void 0:c.text)||void 0===v?void 0:v.fontStyle);const L=yield function(t,o){return e(this,void 0,void 0,(function*(){let e={family:t,style:o};if(d.some((t=>{return i=e,(o=t).family===i.family&&o.style===i.style;var o,i})))return e;try{return yield figma.loadFontAsync(e),d.push(e),e}catch(t){}for(let t of a){e={family:t,style:"Regular"};try{return yield figma.loadFontAsync(e),d.push(e),e}catch(t){}}return null}))}(N,D);if(!L)return figma.createRectangle();t.style&&t.style.text&&t.style.text.fontStyle&&(t.style.text.fontStyle=L.family),T.fontName=L,T.characters=(null===(y=t.content)||void 0===y?void 0:y.text)||"",T.fontSize=(null===(g=null===(h=t.style)||void 0===h?void 0:h.text)||void 0===g?void 0:g.fontSize)||12;let M=null===(b=null===(f=t.style)||void 0===f?void 0:f.text)||void 0===b?void 0:b.textAlign;return T.textAlignHorizontal=M?M[0]:"LEFT",T.textAlignVertical=M?M[1]:"TOP",(null===(p=null===(m=t.style)||void 0===m?void 0:m.color)||void 0===p?void 0:p.hex)?T.fills=[{type:"SOLID",color:l(t.style.color.hex)}]:(null===(A=null===(x=t.style)||void 0===x?void 0:x.color)||void 0===A?void 0:A.rgb)&&(T.fills=[{type:"SOLID",color:{r:t.style.color.rgb[0]/255,g:t.style.color.rgb[1]/255,b:t.style.color.rgb[2]/255}}]),T.textAutoResize="WIDTH_AND_HEIGHT",(null===(R=t.style)||void 0===R?void 0:R.rotation)&&(T.rotation=t.style.rotation),"UNDERLINE"===(null===(E=null===(S=t.style)||void 0===S?void 0:S.text)||void 0===E?void 0:E.textDecoration)?T.textDecoration="UNDERLINE":"STRIKETHROUGH"===(null===(I=null===(C=t.style)||void 0===C?void 0:C.text)||void 0===I?void 0:I.textDecoration)&&(T.textDecoration="STRIKETHROUGH"),T}))}static createImageElement(t){return e(this,void 0,void 0,(function*(){var e,o,i,r,n,s,a,d;if(null===(e=t.content)||void 0===e?void 0:e.imageUrl)return yield u(null===(o=t.content)||void 0===o?void 0:o.imageUrl,null===(i=t.style)||void 0===i?void 0:i.width.value,null===(r=t.style)||void 0===r?void 0:r.height.value);if(null===(s=null===(n=t.style)||void 0===n?void 0:n.color)||void 0===s?void 0:s.hex){const e=figma.createRectangle();return e.fills=[{type:"SOLID",color:l(t.style.color.hex)}],e}if(null===(d=null===(a=t.style)||void 0===a?void 0:a.color)||void 0===d?void 0:d.rgb){const e=figma.createRectangle();return e.fills=[{type:"SOLID",color:{r:t.style.color.rgb[0]/255,g:t.style.color.rgb[1]/255,b:t.style.color.rgb[2]/255},opacity:Math.min((t.style.opacity||255)/255,1)}],e}return figma.createRectangle()}))}static createFrameElement(t,e){var o,i,r,n,s,a;const d=figma.createFrame();if(d.clipsContent=!1,null===(r=null===(i=null===(o=t.style)||void 0===o?void 0:o.background)||void 0===i?void 0:i.backgroundColor)||void 0===r?void 0:r.rgb){const o={type:"SOLID",color:{r:t.style.background.backgroundColor.rgb[0]/255,g:t.style.background.backgroundColor.rgb[1]/255,b:t.style.background.backgroundColor.rgb[2]/255},opacity:Math.min((t.style.opacity||255)/255,1)};e?d.fills=[o]:d.backgrounds=[o]}else if(null===(a=null===(s=null===(n=t.style)||void 0===n?void 0:n.background)||void 0===s?void 0:s.backgroundColor)||void 0===a?void 0:a.hex){const o={type:"SOLID",color:l(t.style.background.backgroundColor.hex)};e?d.fills=[o]:d.backgrounds=[o]}else d.backgrounds=[{type:"SOLID",color:{r:0,g:0,b:0},opacity:0}];return d}static applyBasicProperties(t,e){e.name&&(t.name=e.name,t.setPluginData(y,e.id))}static applyLayoutProperties(t,e){var o,i,l,s,a,d,u,c,v,y,h,g,f,b,m,p,x,A,R,S,E,C,I,T,N,D,L,M,k,w,z,F;const O={CENTER:"CENTER",MAX:"MAX",MIN:"MIN",SPACE_BETWEEN:"SPACE_BETWEEN"},P={CENTER:"CENTER",MAX:"MAX",MIN:"MIN",BASELINE:"BASELINE"};if(e.layout){if(e.layout.flexibleType===r.Flex&&"FRAME"===t.type){const r=t;if(r.layoutMode="HORIZONTAL"===(null===(o=e.layout.flexAttrs)||void 0===o?void 0:o.flexDirection)?"HORIZONTAL":"VERTICAL",r.counterAxisSizingMode="FIXED"===(null===(i=e.layout.flexAttrs)||void 0===i?void 0:i.counterAxisSizingMode)?"FIXED":"AUTO",(null===(l=e.style)||void 0===l?void 0:l.width)&&"FIXED"===e.style.width.sizing)"HORIZONTAL"==r.layoutMode?r.primaryAxisSizingMode="FIXED":r.counterAxisSizingMode="FIXED";if((null===(s=e.style)||void 0===s?void 0:s.height)&&"FIXED"===e.style.height.sizing)"VERTICAL"==r.layoutMode?r.primaryAxisSizingMode="FIXED":r.counterAxisSizingMode="FIXED";(null===(a=e.layout.flexAttrs)||void 0===a?void 0:a.axisAlign)&&(r.primaryAxisAlignItems=O[e.layout.flexAttrs.axisAlign[0]],r.counterAxisAlignItems=P[e.layout.flexAttrs.axisAlign[1]]),(null===(d=e.layout.flexAttrs)||void 0===d?void 0:d.gap)&&(Array.isArray(e.layout.flexAttrs.gap)?r.itemSpacing=e.layout.flexAttrs.gap[0]||0:r.itemSpacing=e.layout.flexAttrs.gap||0)}switch(e.layout.positionType){case n.Absolute:t.x=(null===(c=null===(u=e.layout.absoluteAttrs)||void 0===u?void 0:u.coord)||void 0===c?void 0:c[0])||0,t.y=(null===(y=null===(v=e.layout.absoluteAttrs)||void 0===v?void 0:v.coord)||void 0===y?void 0:y[1])||0,"constraints"in t&&(t.constraints={horizontal:"MAX",vertical:"MAX"});break;case n.Normal:(null===(h=e.layout.absoluteAttrs)||void 0===h?void 0:h.orginCoord)?(t.x=(null===(f=null===(g=e.layout.absoluteAttrs)||void 0===g?void 0:g.orginCoord)||void 0===f?void 0:f[0])||0,t.y=(null===(m=null===(b=e.layout.absoluteAttrs)||void 0===b?void 0:b.orginCoord)||void 0===m?void 0:m[1])||0):(null===(p=e.layout.absoluteAttrs)||void 0===p?void 0:p.coord)&&(t.x=(null===(A=null===(x=e.layout.absoluteAttrs)||void 0===x?void 0:x.coord)||void 0===A?void 0:A[0])||0,t.y=(null===(S=null===(R=e.layout.absoluteAttrs)||void 0===R?void 0:R.coord)||void 0===S?void 0:S[1])||0),"constraints"in t&&(t.constraints={horizontal:"MIN",vertical:"MIN"});break;default:(null===(E=e.layout.absoluteAttrs)||void 0===E?void 0:E.orginCoord)?(t.x=(null===(I=null===(C=e.layout.absoluteAttrs)||void 0===C?void 0:C.orginCoord)||void 0===I?void 0:I[0])||0,t.y=(null===(N=null===(T=e.layout.absoluteAttrs)||void 0===T?void 0:T.orginCoord)||void 0===N?void 0:N[1])||0):(null===(D=e.layout.absoluteAttrs)||void 0===D?void 0:D.coord)&&(t.x=(null===(M=null===(L=e.layout.absoluteAttrs)||void 0===L?void 0:L.coord)||void 0===M?void 0:M[0])||0,t.y=(null===(w=null===(k=e.layout.absoluteAttrs)||void 0===k?void 0:k.coord)||void 0===w?void 0:w[1])||0),"constraints"in t&&(t.constraints={horizontal:"MIN",vertical:"MIN"})}}if(null===(z=e.style)||void 0===z?void 0:z.width)switch(e.style.width.sizing){case"FIXED":"resize"in t&&t.resize(e.style.width.value,e.style.height.value);break;case"FILL":"constraints"in t&&(t.constraints={horizontal:"STRETCH",vertical:t.constraints.vertical})}if(null===(F=e.style)||void 0===F?void 0:F.height)switch(e.style.height.sizing){case"FIXED":case"FILL":"resize"in t&&t.resize(e.style.width.value,e.style.height.value)}}static applyStyleProperties(t,e){var o,i,r;if(null===(o=e.style)||void 0===o?void 0:o.border){if(!("strokes"in t)||!("strokeWeight"in t))return;(null===(i=e.style.border.borderColor)||void 0===i?void 0:i.hex)?t.strokes=[{type:"SOLID",color:l(e.style.border.borderColor.hex)}]:(null===(r=e.style.border.borderColor)||void 0===r?void 0:r.rgb)&&(t.strokes=[{type:"SOLID",color:{r:e.style.border.borderColor.rgb[0]/255,g:e.style.border.borderColor.rgb[1]/255,b:e.style.border.borderColor.rgb[2]/255}}]);const o=Array.isArray(e.style.border.borderWidth)?e.style.border.borderWidth[0]:e.style.border.borderWidth||0;if(t.strokeWeight=o,o>0&&(!t.strokes||0===t.strokes.length)&&(t.strokes=[{type:"SOLID",color:{r:0,g:0,b:0}}]),"FRAME"===t.type||"RECTANGLE"===t.type||"COMPONENT"===t.type||"INSTANCE"===t.type){const o=t;if(Array.isArray(e.style.border.borderRadius))4==e.style.border.borderRadius.length&&"topLeftRadius"in o?(o.topLeftRadius=Number(e.style.border.borderRadius[0]),o.topRightRadius=Number(e.style.border.borderRadius[1]),o.bottomRightRadius=Number(e.style.border.borderRadius[2]),o.bottomLeftRadius=Number(e.style.border.borderRadius[3])):"cornerRadius"in o&&"number"!=typeof o.cornerRadius&&(o.cornerRadius=Number(e.style.border.borderRadius[0]));else if("string"==typeof e.style.border.borderRadius)if(e.style.border.borderRadius.includes("%")){const t=Number(e.style.border.borderRadius.replace("%",""));"cornerRadius"in o&&"number"!=typeof o.cornerRadius&&(o.cornerRadius=e.style.width.value*(t/100))}else"cornerRadius"in o&&"number"!=typeof o.cornerRadius&&(o.cornerRadius=Number(e.style.border.borderRadius));else"cornerRadius"in o&&"number"!=typeof o.cornerRadius&&(o.cornerRadius=e.style.border.borderRadius||0)}}}}var g;t.DesignGenerateStatus=void 0,(g=t.DesignGenerateStatus||(t.DesignGenerateStatus={})).SUCCESS="SUCCESS",g.SCRIPT_ERROR="SCRIPT_ERROR",g.CONVERSION_ERROR="CONVERSION_ERROR";class f{constructor(){this.version="1.0.0"}getVersion(){return this.version}static init(){return new f}}t.DesignGenerator=class{static generateFromVisualElement(i){return e(this,void 0,void 0,(function*(){try{const e=o.convertToDslSchema(i);return yield h.createFigmaElementFromDSL(e,null),{message:"success",statusCode:200,status:t.DesignGenerateStatus.SUCCESS}}catch(e){return{message:(null==e?void 0:e.message)||"Unknown Error",statusCode:25203,status:t.DesignGenerateStatus.SCRIPT_ERROR}}}))}},t.default=f,Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ScreenshotToDesign={})}(this,(function(t){"use strict";function e(t,e,o,i){return new(o||(o=Promise))((function(r,n){function l(t){try{a(i.next(t))}catch(t){n(t)}}function s(t){try{a(i.throw(t))}catch(t){n(t)}}function a(t){var e;t.done?r(t.value):(e=t.value,e instanceof o?e:new o((function(t){t(e)}))).then(l,s)}a((i=i.apply(t,e||[])).next())}))}class o{static convertToDslSchema(t){return{id:t.elementId,name:t.elementName,type:t.elementType,enName:t.displayName,layout:this.convertLayoutConfiguration(t.layoutConfig),style:this.convertVisualStyle(t.styleConfig),i2dExt:this.convertProcessingMetadata(t.processingMeta),content:t.contentData?this.convertElementContent(t.contentData):void 0,component:t.componentSpec?this.convertComponentDefinition(t.componentSpec):void 0,children:t.childElements?t.childElements.map((t=>this.convertToDslSchema(t))):void 0}}static convertVisualColor(t){var e,o;return{rgb:null!==(e=t.rgbValues)&&void 0!==e?e:t.rgb,hex:null!==(o=t.hexCode)&&void 0!==o?o:t.hex}}static convertVisualStyle(t){const e={width:t.widthSpec,height:t.heightSpec};return t.textConfig&&(e.text={fontFamily:t.textConfig.fontFamily,fontSize:t.textConfig.fontSize,fontWeight:t.textConfig.fontWeight,fontStyle:t.textConfig.fontStyle,textAlign:t.textConfig.textAlign,textDecoration:t.textConfig.textDecoration}),t.borderConfig&&(e.border={borderColor:t.borderConfig.borderColor?this.convertVisualColor(t.borderConfig.borderColor):void 0,borderWidth:t.borderConfig.borderWidth,borderRadius:t.borderConfig.borderRadius}),t.backgroundSpec&&(e.background={backgroundColor:t.backgroundSpec.backgroundColor?this.convertVisualColor(t.backgroundSpec.backgroundColor):void 0}),t.textColor&&(e.color=this.convertVisualColor(t.textColor)),void 0!==t.paddingValues&&(e.padding=t.paddingValues),void 0!==t.opacityLevel&&(e.opacity=t.opacityLevel),void 0!==t.overflowMode&&(e.overflow=t.overflowMode),void 0!==t.rotationAngle&&(e.rotation=t.rotationAngle),t.textDetection&&(e.text_det=t.textDetection),t.textExtraction&&(e.text_ext=t.textExtraction),e}static convertLayoutConfiguration(t){return{positionType:t.positionMode,flexibleType:t.flexibleMode,flexAttrs:t.flexAttributes,absoluteAttrs:t.absoluteAttrs}}static convertElementContent(t){const e={};if(t.textValue&&(e.text=t.textValue),t.imageSource&&(e.imageUrl=t.imageSource),t.colorReference&&(e.colorTokenId=t.colorReference),t.componentReference&&(e.componentId=t.componentReference),t.componentAttributes){const o={};for(const[e,i]of Object.entries(t.componentAttributes))o[e]=i;e.componentProperties=o}return e}static convertComponentDefinition(t){return{id:t.componentId,name:t.componentName,code:t.sourceCode,properties:t.configOptions}}static convertProcessingMetadata(t){return{area:t.surfaceArea,yolo_confidence:t.detectionScore,text_is_containerized:t.textContainerized}}}var i,r,n;function l(t){return{r:parseInt(t.slice(1,3),16)/255,g:parseInt(t.slice(3,5),16)/255,b:parseInt(t.slice(5,7),16)/255}}function s(t,e){var o,i,r,n,l,a;const d="schema:id";if("children"in t)for(let u=0;u<t.children.length;u++){const c=t.children[u],v=c.getPluginData(d),y=null===(o=e.children)||void 0===o?void 0:o.find((t=>t.id===v));if(y){if("Absolute"===y.layout.positionType&&(null===(i=y.layout.absoluteAttrs)||void 0===i?void 0:i.align)){const[e,o]=y.layout.absoluteAttrs.align;let i=0,s=0;switch(e){case"LEFT":i=(null===(n=null===(r=y.layout.absoluteAttrs)||void 0===r?void 0:r.coord)||void 0===n?void 0:n[0])||0;break;case"RIGHT":i=t.width-c.width;break;case"CENTER":i=(t.width-c.width)/2}switch(o){case"TOP":s=(null===(a=null===(l=y.layout.absoluteAttrs)||void 0===l?void 0:l.coord)||void 0===a?void 0:a[1])||0;break;case"BOTTOM":s=t.height-c.height;break;case"CENTER":s=(t.height-c.height)/2}c.x=i,c.y=s}"children"in c&&c.children&&c.children.length>0&&s(c,y)}}}!function(t){t.Component="Component",t.Body="Body",t.Layer="Layer"}(i||(i={})),function(t){t.Flex="Flex"}(r||(r={})),function(t){t.Absolute="Absolute",t.Normal="Normal"}(n||(n={}));const a=["Inter","Roboto","Arial"],d=[];function u(t){return e(this,arguments,void 0,(function*(t,o=-1,i=-1){if((t=t.replace("http:","https:")).endsWith(".svg")){const r=figma.createFrame();return o>0&&i>0&&r.resize(o,i),r.backgrounds=[{type:"SOLID",color:{r:0,g:0,b:0},opacity:0}],function(t,o){e(this,arguments,void 0,(function*(t,e,o=-1,i=-1){try{const r=yield fetch(e),n=yield r.text(),l=figma.createNodeFromSvg(n);t.appendChild(l),o>0&&i>0&&(t.resize(o,i),l.resize(o,i))}catch(t){}}))}(r,t,o,i),r}const r=figma.createRectangle();return o>0&&i>0&&r.resize(o,i),r.fills=[{type:"SOLID",color:{r:1,g:1,b:1}}],function(t,o){e(this,void 0,void 0,(function*(){try{const e=yield fetch(o),i=yield e.arrayBuffer();let r=figma.createImage(new Uint8Array(i)).hash;t.fills=[{type:"IMAGE",scaleMode:"FILL",imageHash:r}]}catch(t){}}))}(r,t),r}))}function c(t){return e(this,void 0,void 0,(function*(){try{return t.length>=24&&137===t[0]&&80===t[1]&&78===t[2]&&71===t[3]?function(t){if(t.length<24)throw new Error("Invalid PNG file - too short");if(73!==t[12]||72!==t[13]||68!==t[14]||82!==t[15])throw new Error("Invalid PNG file - missing IHDR chunk");const e=t[16]<<24|t[17]<<16|t[18]<<8|t[19],o=t[20]<<24|t[21]<<16|t[22]<<8|t[23];return{width:e,height:o}}(t):{width:0,height:0}}catch(t){return{width:0,height:0}}}))}function v(t){return e(this,void 0,void 0,(function*(){const e=yield t.exportAsync({format:"PNG",constraint:{type:"SCALE",value:1}});let{width:o,height:i}=yield c(e);return(0==o||0==i||function(t,e,o,i){if(t<1||e<1)return!0;const r=(t,e)=>{let o=Math.abs(t-e);return o>(e>10?10:5)&&o/e>.3};return!(!r(t,o)&&!r(e,i))}(o,i,t.width,t.height))&&(o=t.width,i=t.height),{textWidth:o,textHeight:i}}))}const y="schema:id";class h{static createFigmaElementFromDSL(t){return e(this,arguments,void 0,(function*(t,o=null){let r;switch(t.type){case"Text":r=yield this.createTextElement(t);break;case"Image":r=yield this.createImageElement(t);break;case i.Component:case i.Body:r=this.createFrameElement(t,!1);break;case i.Layer:r=this.createFrameElement(t,!0);break;default:r=figma.createFrame()}if(this.applyBasicProperties(r,t),this.applyLayoutProperties(r,t),this.applyStyleProperties(r,t),o&&("TEXT"===r.type&&(yield function(t,o){return e(this,void 0,void 0,(function*(){var e,i,r,n,l,s;const a=o.textAutoResize,d=o.leadingTrim,u=Math.max(1,Number(o.fontSize)||12);try{const c=Number(null===(i=null===(e=t.style)||void 0===e?void 0:e.text_ext)||void 0===i?void 0:i.text_box_height)||12,y=Number(null===(n=null===(r=t.style)||void 0===r?void 0:r.width)||void 0===n?void 0:n.value)||12,h=Number(null===(s=null===(l=t.style)||void 0===l?void 0:l.height)||void 0===s?void 0:s.value)||12;o.resize(y,o.height),o.leadingTrim="CAP_HEIGHT",o.textAutoResize="WIDTH_AND_HEIGHT";let g=u,f=Math.max(0,g-20);g>200?f=Math.max(0,g-100):g>140?f=Math.max(0,g-50):g>90?f=Math.max(0,g-40):g>70?f=Math.max(0,g-35):g>40&&(f=Math.max(0,g-30));let b=g+10,m=g,p=.3,x=!1;for(;f<=b&&(g=(f+b)/2,!(g<1));){o.fontSize=g;const{textWidth:t,textHeight:e}=yield v(o);if(0===t||0===t)return o.fontSize=u,o.textAutoResize=a,void(o.leadingTrim=d);e<=c&&t<=y&&o.height<h&&o.width<y?(m=g,f=g+p,x=!0):b=g-p}if(!x){let t=f>10?10:5;for(;f>1;){b=f,f=Math.max(1,f-t),o.fontSize=f;const{textWidth:e,textHeight:i}=yield v(o);if(i<=c&&e<=y&&o.height<h&&o.width<y)break}for(;f<=b&&(g=(f+b)/2,!(g<1));){o.fontSize=g;const{textWidth:t,textHeight:e}=yield v(o);e<=c&&t<=y&&o.height<h&&o.width<y?(m=g,f=g+p):b=g-p}}let A=Math.floor(10*m)/10;A<=0&&(A=u),o.fontSize=A,o.textAutoResize=a,o.leadingTrim=d}catch(t){o.fontSize=u,o.textAutoResize=a,o.leadingTrim=d}}))}(t,r),function(t,e){var o,i,r;const n=e.characters;if(0==n.length||!n.includes("\n"))return;const l=Number(null===(i=null===(o=t.style)||void 0===o?void 0:o.text_ext)||void 0===i?void 0:i.text_box_height)||0;if(0==l)return;let s=l/(((null===(r=n.match(/\n/g))||void 0===r?void 0:r.length)||0)+1),a=e.fontSize;if(a>s)return;let d=a,u=s,c=d,v=u;for(;u-d>.3;){const t=(d+u)/2;if(e.lineHeight={unit:"PIXELS",value:t},e.height==l)break;if(e.height>l?u=t:d=t,d===c&&u===v)break;c=d,v=u}const y=(d+u)/2;e.lineHeight=y<a?{unit:"PIXELS",value:a}:{unit:"PIXELS",value:y}}(t,r)),o.appendChild(r)),t.children&&"FRAME"===r.type)for(let e of t.children)yield this.createFigmaElementFromDSL(e,r);return s(r,t),r}))}static createTextElement(t){return e(this,void 0,void 0,(function*(){var o,i,r,n,s,u,c,v,y,h,g,f,b,m,p,x,A,R,S,E,C,I;const T=figma.createText(),N=(null===(i=null===(o=t.style)||void 0===o?void 0:o.text)||void 0===i?void 0:i.fontFamily)||"Roboto";let D;D=(null===(n=null===(r=t.style)||void 0===r?void 0:r.text)||void 0===n?void 0:n.fontWeight)?function(t,e){return"number"==typeof e?e>=700?"Bold":e>=600?"inter"==t.toLowerCase()?"Semi Bold":"Semibold":e>=500?"Medium":e>=400?"Regular":e>=300?"Light":"Thin":e||"Regular"}(N,null===(u=null===(s=t.style)||void 0===s?void 0:s.text)||void 0===u?void 0:u.fontWeight):function(t,e){if("string"==typeof e)switch(e.toLowerCase()){case"medium":return"Medium";case"extra_bold":case"bold":case"semi_bold":return"inter"==t.toLowerCase()?"Semi Bold":"Semibold";case"regular":default:return"Regular";case"light":return"Light"}return e||"Regular"}(N,null===(v=null===(c=t.style)||void 0===c?void 0:c.text)||void 0===v?void 0:v.fontStyle);const L=yield function(t,o){return e(this,void 0,void 0,(function*(){let e={family:t,style:o};if(d.some((t=>{return i=e,(o=t).family===i.family&&o.style===i.style;var o,i})))return e;try{return yield figma.loadFontAsync(e),d.push(e),e}catch(t){}for(let t of a){e={family:t,style:"Regular"};try{return yield figma.loadFontAsync(e),d.push(e),e}catch(t){}}return null}))}(N,D);if(!L)return figma.createRectangle();t.style&&t.style.text&&t.style.text.fontStyle&&(t.style.text.fontStyle=L.family),T.fontName=L,T.characters=(null===(y=t.content)||void 0===y?void 0:y.text)||"",T.fontSize=(null===(g=null===(h=t.style)||void 0===h?void 0:h.text)||void 0===g?void 0:g.fontSize)||12;let M=null===(b=null===(f=t.style)||void 0===f?void 0:f.text)||void 0===b?void 0:b.textAlign;return T.textAlignHorizontal=M?M[0]:"LEFT",T.textAlignVertical=M?M[1]:"TOP",(null===(p=null===(m=t.style)||void 0===m?void 0:m.color)||void 0===p?void 0:p.hex)?T.fills=[{type:"SOLID",color:l(t.style.color.hex)}]:(null===(A=null===(x=t.style)||void 0===x?void 0:x.color)||void 0===A?void 0:A.rgb)&&(T.fills=[{type:"SOLID",color:{r:t.style.color.rgb[0]/255,g:t.style.color.rgb[1]/255,b:t.style.color.rgb[2]/255}}]),T.textAutoResize="WIDTH_AND_HEIGHT",(null===(R=t.style)||void 0===R?void 0:R.rotation)&&(T.rotation=t.style.rotation),"UNDERLINE"===(null===(E=null===(S=t.style)||void 0===S?void 0:S.text)||void 0===E?void 0:E.textDecoration)?T.textDecoration="UNDERLINE":"STRIKETHROUGH"===(null===(I=null===(C=t.style)||void 0===C?void 0:C.text)||void 0===I?void 0:I.textDecoration)&&(T.textDecoration="STRIKETHROUGH"),T}))}static createImageElement(t){return e(this,void 0,void 0,(function*(){var e,o,i,r,n,s,a,d;if(null===(e=t.content)||void 0===e?void 0:e.imageUrl)return yield u(null===(o=t.content)||void 0===o?void 0:o.imageUrl,null===(i=t.style)||void 0===i?void 0:i.width.value,null===(r=t.style)||void 0===r?void 0:r.height.value);if(null===(s=null===(n=t.style)||void 0===n?void 0:n.color)||void 0===s?void 0:s.hex){const e=figma.createRectangle();return e.fills=[{type:"SOLID",color:l(t.style.color.hex)}],e}if(null===(d=null===(a=t.style)||void 0===a?void 0:a.color)||void 0===d?void 0:d.rgb){const e=figma.createRectangle();return e.fills=[{type:"SOLID",color:{r:t.style.color.rgb[0]/255,g:t.style.color.rgb[1]/255,b:t.style.color.rgb[2]/255},opacity:Math.min((t.style.opacity||255)/255,1)}],e}return figma.createRectangle()}))}static createFrameElement(t,e){var o,i,r,n,s,a;const d=figma.createFrame();if(d.clipsContent=!1,null===(r=null===(i=null===(o=t.style)||void 0===o?void 0:o.background)||void 0===i?void 0:i.backgroundColor)||void 0===r?void 0:r.rgb){const o={type:"SOLID",color:{r:t.style.background.backgroundColor.rgb[0]/255,g:t.style.background.backgroundColor.rgb[1]/255,b:t.style.background.backgroundColor.rgb[2]/255},opacity:Math.min((t.style.opacity||255)/255,1)};e?d.fills=[o]:d.backgrounds=[o]}else if(null===(a=null===(s=null===(n=t.style)||void 0===n?void 0:n.background)||void 0===s?void 0:s.backgroundColor)||void 0===a?void 0:a.hex){const o={type:"SOLID",color:l(t.style.background.backgroundColor.hex)};e?d.fills=[o]:d.backgrounds=[o]}else d.backgrounds=[{type:"SOLID",color:{r:0,g:0,b:0},opacity:0}];return d}static applyBasicProperties(t,e){e.name&&(t.name=e.name,t.setPluginData(y,e.id))}static applyLayoutProperties(t,e){var o,i,l,s,a,d,u,c,v,y,h,g,f,b,m,p,x,A,R,S,E,C,I,T,N,D,L,M,k,w,z,F;const O={CENTER:"CENTER",MAX:"MAX",MIN:"MIN",SPACE_BETWEEN:"SPACE_BETWEEN"},P={CENTER:"CENTER",MAX:"MAX",MIN:"MIN",BASELINE:"BASELINE"};if(e.layout){if(e.layout.flexibleType===r.Flex&&"FRAME"===t.type){const r=t;if(r.layoutMode="HORIZONTAL"===(null===(o=e.layout.flexAttrs)||void 0===o?void 0:o.flexDirection)?"HORIZONTAL":"VERTICAL",r.counterAxisSizingMode="FIXED"===(null===(i=e.layout.flexAttrs)||void 0===i?void 0:i.counterAxisSizingMode)?"FIXED":"AUTO",(null===(l=e.style)||void 0===l?void 0:l.width)&&"FIXED"===e.style.width.sizing)"HORIZONTAL"==r.layoutMode?r.primaryAxisSizingMode="FIXED":r.counterAxisSizingMode="FIXED";if((null===(s=e.style)||void 0===s?void 0:s.height)&&"FIXED"===e.style.height.sizing)"VERTICAL"==r.layoutMode?r.primaryAxisSizingMode="FIXED":r.counterAxisSizingMode="FIXED";(null===(a=e.layout.flexAttrs)||void 0===a?void 0:a.axisAlign)&&(r.primaryAxisAlignItems=O[e.layout.flexAttrs.axisAlign[0]],r.counterAxisAlignItems=P[e.layout.flexAttrs.axisAlign[1]]),(null===(d=e.layout.flexAttrs)||void 0===d?void 0:d.gap)&&(Array.isArray(e.layout.flexAttrs.gap)?r.itemSpacing=e.layout.flexAttrs.gap[0]||0:r.itemSpacing=e.layout.flexAttrs.gap||0)}switch(e.layout.positionType){case n.Absolute:t.x=(null===(c=null===(u=e.layout.absoluteAttrs)||void 0===u?void 0:u.coord)||void 0===c?void 0:c[0])||0,t.y=(null===(y=null===(v=e.layout.absoluteAttrs)||void 0===v?void 0:v.coord)||void 0===y?void 0:y[1])||0,"constraints"in t&&(t.constraints={horizontal:"MAX",vertical:"MAX"});break;case n.Normal:(null===(h=e.layout.absoluteAttrs)||void 0===h?void 0:h.orginCoord)?(t.x=(null===(f=null===(g=e.layout.absoluteAttrs)||void 0===g?void 0:g.orginCoord)||void 0===f?void 0:f[0])||0,t.y=(null===(m=null===(b=e.layout.absoluteAttrs)||void 0===b?void 0:b.orginCoord)||void 0===m?void 0:m[1])||0):(null===(p=e.layout.absoluteAttrs)||void 0===p?void 0:p.coord)&&(t.x=(null===(A=null===(x=e.layout.absoluteAttrs)||void 0===x?void 0:x.coord)||void 0===A?void 0:A[0])||0,t.y=(null===(S=null===(R=e.layout.absoluteAttrs)||void 0===R?void 0:R.coord)||void 0===S?void 0:S[1])||0),"constraints"in t&&(t.constraints={horizontal:"MIN",vertical:"MIN"});break;default:(null===(E=e.layout.absoluteAttrs)||void 0===E?void 0:E.orginCoord)?(t.x=(null===(I=null===(C=e.layout.absoluteAttrs)||void 0===C?void 0:C.orginCoord)||void 0===I?void 0:I[0])||0,t.y=(null===(N=null===(T=e.layout.absoluteAttrs)||void 0===T?void 0:T.orginCoord)||void 0===N?void 0:N[1])||0):(null===(D=e.layout.absoluteAttrs)||void 0===D?void 0:D.coord)&&(t.x=(null===(M=null===(L=e.layout.absoluteAttrs)||void 0===L?void 0:L.coord)||void 0===M?void 0:M[0])||0,t.y=(null===(w=null===(k=e.layout.absoluteAttrs)||void 0===k?void 0:k.coord)||void 0===w?void 0:w[1])||0),"constraints"in t&&(t.constraints={horizontal:"MIN",vertical:"MIN"})}}if(null===(z=e.style)||void 0===z?void 0:z.width)switch(e.style.width.sizing){case"FIXED":"resize"in t&&t.resize(e.style.width.value,e.style.height.value);break;case"FILL":"constraints"in t&&(t.constraints={horizontal:"STRETCH",vertical:t.constraints.vertical})}if(null===(F=e.style)||void 0===F?void 0:F.height)switch(e.style.height.sizing){case"FIXED":case"FILL":"resize"in t&&t.resize(e.style.width.value,e.style.height.value)}}static applyStyleProperties(t,e){var o,i,r;if(null===(o=e.style)||void 0===o?void 0:o.border){if(!("strokes"in t)||!("strokeWeight"in t))return;(null===(i=e.style.border.borderColor)||void 0===i?void 0:i.hex)?t.strokes=[{type:"SOLID",color:l(e.style.border.borderColor.hex)}]:(null===(r=e.style.border.borderColor)||void 0===r?void 0:r.rgb)&&(t.strokes=[{type:"SOLID",color:{r:e.style.border.borderColor.rgb[0]/255,g:e.style.border.borderColor.rgb[1]/255,b:e.style.border.borderColor.rgb[2]/255}}]);const o=Array.isArray(e.style.border.borderWidth)?e.style.border.borderWidth[0]:e.style.border.borderWidth||0;if(t.strokeWeight=o,o>0&&(!t.strokes||0===t.strokes.length)&&(t.strokes=[{type:"SOLID",color:{r:0,g:0,b:0}}]),"FRAME"===t.type||"RECTANGLE"===t.type||"COMPONENT"===t.type||"INSTANCE"===t.type){const o=t;if(Array.isArray(e.style.border.borderRadius))4==e.style.border.borderRadius.length&&"topLeftRadius"in o?(o.topLeftRadius=Number(e.style.border.borderRadius[0]),o.topRightRadius=Number(e.style.border.borderRadius[1]),o.bottomRightRadius=Number(e.style.border.borderRadius[2]),o.bottomLeftRadius=Number(e.style.border.borderRadius[3])):"cornerRadius"in o&&"number"!=typeof o.cornerRadius&&(o.cornerRadius=Number(e.style.border.borderRadius[0]));else if("string"==typeof e.style.border.borderRadius)if(e.style.border.borderRadius.includes("%")){const t=Number(e.style.border.borderRadius.replace("%",""));"cornerRadius"in o&&"number"!=typeof o.cornerRadius&&(o.cornerRadius=e.style.width.value*(t/100))}else"cornerRadius"in o&&"number"!=typeof o.cornerRadius&&(o.cornerRadius=Number(e.style.border.borderRadius));else"cornerRadius"in o&&"number"!=typeof o.cornerRadius&&(o.cornerRadius=e.style.border.borderRadius||0)}}}}var g;t.DesignGenerateStatus=void 0,(g=t.DesignGenerateStatus||(t.DesignGenerateStatus={})).SUCCESS="SUCCESS",g.SCRIPT_ERROR="SCRIPT_ERROR",g.CONVERSION_ERROR="CONVERSION_ERROR";class f{constructor(){this.version="1.0.0"}getVersion(){return this.version}static init(){return new f}}t.DesignGenerator=class{static generateFromVisualElement(i){return e(this,void 0,void 0,(function*(){try{const e=o.convertToDslSchema(i);return yield h.createFigmaElementFromDSL(e,null),{message:"success",statusCode:200,status:t.DesignGenerateStatus.SUCCESS}}catch(e){return{message:(null==e?void 0:e.message)||"Unknown Error",statusCode:25203,status:t.DesignGenerateStatus.SCRIPT_ERROR}}}))}},t.default=f,Object.defineProperty(t,"__esModule",{value:!0})}));
|
package/package.json
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "figma-image-to-design",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "A powerful library for converting images and screenshots to design elements, specifically optimized for Figma plugin development",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
7
|
-
|
|
7
|
+
"dist"
|
|
8
8
|
],
|
|
9
9
|
"keywords": [
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
"figma",
|
|
11
|
+
"design",
|
|
12
|
+
"image-to-design",
|
|
13
|
+
"screenshot",
|
|
14
|
+
"ui-generation",
|
|
15
|
+
"design-automation",
|
|
16
|
+
"figma-plugin",
|
|
17
|
+
"visual-elements",
|
|
18
|
+
"dsl",
|
|
19
|
+
"codia"
|
|
20
20
|
],
|
|
21
21
|
"author": {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
"name": "Codia AI",
|
|
23
|
+
"email": "laurent@codia.ai",
|
|
24
|
+
"url": "https://codia.ai"
|
|
25
25
|
},
|
|
26
26
|
"license": "MIT",
|
|
27
27
|
"engines": {
|
|
28
|
-
|
|
28
|
+
"node": ">=14.0.0"
|
|
29
29
|
},
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public",
|
|
32
|
+
"registry": "https://registry.npmjs.org/"
|
|
33
|
+
},
|
|
34
|
+
"private": false,
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
|
|
36
|
+
"figma-api": "*"
|
|
37
37
|
},
|
|
38
38
|
"peerDependenciesMeta": {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
"figma-api": {
|
|
40
|
+
"optional": true
|
|
41
|
+
}
|
|
42
42
|
}
|
|
43
|
-
|
|
43
|
+
}
|