diff --git a/apps/app/package.json b/apps/app/package.json index 9aa7e23d..468b465c 100644 --- a/apps/app/package.json +++ b/apps/app/package.json @@ -66,6 +66,7 @@ "js-md5": "^0.7.3", "jszip": "^3.10.1", "lodash-es": "4.17.21", + "marked": "^17.0.3", "mitt": "^3.0.1", "monaco-editor": "0.52.2", "page-flip": "^2.0.7", diff --git a/apps/app/public/cdn/extend/marked.min.js b/apps/app/public/cdn/extend/marked.min.js deleted file mode 100644 index a91afe79..00000000 --- a/apps/app/public/cdn/extend/marked.min.js +++ /dev/null @@ -1,6 +0,0 @@ -/** - * marked v12.0.2 - a markdown parser - * Copyright (c) 2011-2024, Christopher Jeffrey. (MIT Licensed) - * https://github.com/markedjs/marked - */ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).marked={})}(this,(function(e){"use strict";function t(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}function n(t){e.defaults=t}e.defaults={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};const s=/[&<>"']/,r=new RegExp(s.source,"g"),i=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,l=new RegExp(i.source,"g"),o={"&":"&","<":"<",">":">",'"':""","'":"'"},a=e=>o[e];function c(e,t){if(t){if(s.test(e))return e.replace(r,a)}else if(i.test(e))return e.replace(l,a);return e}const h=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function p(e){return e.replace(h,((e,t)=>"colon"===(t=t.toLowerCase())?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""))}const u=/(^|[^\[])\^/g;function k(e,t){let n="string"==typeof e?e:e.source;t=t||"";const s={replace:(e,t)=>{let r="string"==typeof t?t:t.source;return r=r.replace(u,"$1"),n=n.replace(e,r),s},getRegex:()=>new RegExp(n,t)};return s}function g(e){try{e=encodeURI(e).replace(/%25/g,"%")}catch(e){return null}return e}const f={exec:()=>null};function d(e,t){const n=e.replace(/\|/g,((e,t,n)=>{let s=!1,r=t;for(;--r>=0&&"\\"===n[r];)s=!s;return s?"|":" |"})).split(/ \|/);let s=0;if(n[0].trim()||n.shift(),n.length>0&&!n[n.length-1].trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length0)return{type:"space",raw:t[0]}}code(e){const t=this.rules.block.code.exec(e);if(t){const e=t[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:x(e,"\n")}}}fences(e){const t=this.rules.block.fences.exec(e);if(t){const e=t[0],n=function(e,t){const n=e.match(/^(\s+)(?:```)/);if(null===n)return t;const s=n[1];return t.split("\n").map((e=>{const t=e.match(/^\s+/);if(null===t)return e;const[n]=t;return n.length>=s.length?e.slice(s.length):e})).join("\n")}(e,t[3]||"");return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:n}}}heading(e){const t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(/#$/.test(e)){const t=x(e,"#");this.options.pedantic?e=t.trim():t&&!/ $/.test(t)||(e=t.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){const t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:t[0]}}blockquote(e){const t=this.rules.block.blockquote.exec(e);if(t){let e=t[0].replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,"\n $1");e=x(e.replace(/^ *>[ \t]?/gm,""),"\n");const n=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(e);return this.lexer.state.top=n,{type:"blockquote",raw:t[0],tokens:s,text:e}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim();const s=n.length>1,r={type:"list",raw:"",ordered:s,start:s?+n.slice(0,-1):"",loose:!1,items:[]};n=s?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=s?n:"[*+-]");const i=new RegExp(`^( {0,3}${n})((?:[\t ][^\\n]*)?(?:\\n|$))`);let l="",o="",a=!1;for(;e;){let n=!1;if(!(t=i.exec(e)))break;if(this.rules.block.hr.test(e))break;l=t[0],e=e.substring(l.length);let s=t[2].split("\n",1)[0].replace(/^\t+/,(e=>" ".repeat(3*e.length))),c=e.split("\n",1)[0],h=0;this.options.pedantic?(h=2,o=s.trimStart()):(h=t[2].search(/[^ ]/),h=h>4?1:h,o=s.slice(h),h+=t[1].length);let p=!1;if(!s&&/^ *$/.test(c)&&(l+=c+"\n",e=e.substring(c.length+1),n=!0),!n){const t=new RegExp(`^ {0,${Math.min(3,h-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),n=new RegExp(`^ {0,${Math.min(3,h-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),r=new RegExp(`^ {0,${Math.min(3,h-1)}}(?:\`\`\`|~~~)`),i=new RegExp(`^ {0,${Math.min(3,h-1)}}#`);for(;e;){const a=e.split("\n",1)[0];if(c=a,this.options.pedantic&&(c=c.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),r.test(c))break;if(i.test(c))break;if(t.test(c))break;if(n.test(e))break;if(c.search(/[^ ]/)>=h||!c.trim())o+="\n"+c.slice(h);else{if(p)break;if(s.search(/[^ ]/)>=4)break;if(r.test(s))break;if(i.test(s))break;if(n.test(s))break;o+="\n"+c}p||c.trim()||(p=!0),l+=a+"\n",e=e.substring(a.length+1),s=c.slice(h)}}r.loose||(a?r.loose=!0:/\n *\n *$/.test(l)&&(a=!0));let u,k=null;this.options.gfm&&(k=/^\[[ xX]\] /.exec(o),k&&(u="[ ] "!==k[0],o=o.replace(/^\[[ xX]\] +/,""))),r.items.push({type:"list_item",raw:l,task:!!k,checked:u,loose:!1,text:o,tokens:[]}),r.raw+=l}r.items[r.items.length-1].raw=l.trimEnd(),r.items[r.items.length-1].text=o.trimEnd(),r.raw=r.raw.trimEnd();for(let e=0;e"space"===e.type)),n=t.length>0&&t.some((e=>/\n.*\n/.test(e.raw)));r.loose=n}if(r.loose)for(let e=0;e$/,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",s=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:n,title:s}}}table(e){const t=this.rules.block.table.exec(e);if(!t)return;if(!/[:|]/.test(t[2]))return;const n=d(t[1]),s=t[2].replace(/^\||\| *$/g,"").split("|"),r=t[3]&&t[3].trim()?t[3].replace(/\n[ \t]*$/,"").split("\n"):[],i={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===s.length){for(const e of s)/^ *-+: *$/.test(e)?i.align.push("right"):/^ *:-+: *$/.test(e)?i.align.push("center"):/^ *:-+ *$/.test(e)?i.align.push("left"):i.align.push(null);for(const e of n)i.header.push({text:e,tokens:this.lexer.inline(e)});for(const e of r)i.rows.push(d(e,i.header.length).map((e=>({text:e,tokens:this.lexer.inline(e)}))));return i}}lheading(e){const t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:"="===t[2].charAt(0)?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){const t=this.rules.block.paragraph.exec(e);if(t){const e="\n"===t[1].charAt(t[1].length-1)?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){const t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){const t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:c(t[1])}}tag(e){const t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&/^/i.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){const t=this.rules.inline.link.exec(e);if(t){const e=t[2].trim();if(!this.options.pedantic&&/^$/.test(e))return;const t=x(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{const e=function(e,t){if(-1===e.indexOf(t[1]))return-1;let n=0;for(let s=0;s-1){const n=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=""}}let n=t[2],s="";if(this.options.pedantic){const e=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(n);e&&(n=e[1],s=e[3])}else s=t[3]?t[3].slice(1,-1):"";return n=n.trim(),/^$/.test(e)?n.slice(1):n.slice(1,-1)),b(t,{href:n?n.replace(this.rules.inline.anyPunctuation,"$1"):n,title:s?s.replace(this.rules.inline.anyPunctuation,"$1"):s},t[0],this.lexer)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){const e=t[(n[2]||n[1]).replace(/\s+/g," ").toLowerCase()];if(!e){const e=n[0].charAt(0);return{type:"text",raw:e,text:e}}return b(n,e,n[0],this.lexer)}}emStrong(e,t,n=""){let s=this.rules.inline.emStrongLDelim.exec(e);if(!s)return;if(s[3]&&n.match(/[\p{L}\p{N}]/u))return;if(!(s[1]||s[2]||"")||!n||this.rules.inline.punctuation.exec(n)){const n=[...s[0]].length-1;let r,i,l=n,o=0;const a="*"===s[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(a.lastIndex=0,t=t.slice(-1*e.length+n);null!=(s=a.exec(t));){if(r=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!r)continue;if(i=[...r].length,s[3]||s[4]){l+=i;continue}if((s[5]||s[6])&&n%3&&!((n+i)%3)){o+=i;continue}if(l-=i,l>0)continue;i=Math.min(i,i+l+o);const t=[...s[0]][0].length,a=e.slice(0,n+s.index+t+i);if(Math.min(n,i)%2){const e=a.slice(1,-1);return{type:"em",raw:a,text:e,tokens:this.lexer.inlineTokens(e)}}const c=a.slice(2,-2);return{type:"strong",raw:a,text:c,tokens:this.lexer.inlineTokens(c)}}}}codespan(e){const t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(/\n/g," ");const n=/[^ ]/.test(e),s=/^ /.test(e)&&/ $/.test(e);return n&&s&&(e=e.substring(1,e.length-1)),e=c(e,!0),{type:"codespan",raw:t[0],text:e}}}br(e){const t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){const t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){const t=this.rules.inline.autolink.exec(e);if(t){let e,n;return"@"===t[2]?(e=c(t[1]),n="mailto:"+e):(e=c(t[1]),n=e),{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if("@"===t[2])e=c(t[0]),n="mailto:"+e;else{let s;do{s=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??""}while(s!==t[0]);e=c(t[0]),n="www."===t[1]?"http://"+t[0]:t[0]}return{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e){const t=this.rules.inline.text.exec(e);if(t){let e;return e=this.lexer.state.inRawBlock?t[0]:c(t[0]),{type:"text",raw:t[0],text:e}}}}const m=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,y=/(?:[*+-]|\d{1,9}[.)])/,$=k(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,y).replace(/blockCode/g,/ {4}/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).getRegex(),z=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,T=/(?!\s*\])(?:\\.|[^\[\]\\])+/,R=k(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label",T).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),_=k(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,y).getRegex(),A="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",S=/|$))/,I=k("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|\\n*|$)|\\n*|$)|)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))","i").replace("comment",S).replace("tag",A).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),E=k(z).replace("hr",m).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",A).getRegex(),q={blockquote:k(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",E).getRegex(),code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,def:R,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:m,html:I,lheading:$,list:_,newline:/^(?: *(?:\n|$))+/,paragraph:E,table:f,text:/^[^\n]+/},Z=k("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",m).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",A).getRegex(),L={...q,table:Z,paragraph:k(z).replace("hr",m).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Z).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",A).getRegex()},P={...q,html:k("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",S).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:f,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:k(z).replace("hr",m).replace("heading"," *#{1,6} *[^\n]").replace("lheading",$).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Q=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,v=/^( {2,}|\\)\n(?!\s*$)/,B="\\p{P}\\p{S}",C=k(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,B).getRegex(),M=k(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,B).getRegex(),O=k("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,B).getRegex(),D=k("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,B).getRegex(),j=k(/\\([punct])/,"gu").replace(/punct/g,B).getRegex(),H=k(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),U=k(S).replace("(?:--\x3e|$)","--\x3e").getRegex(),X=k("^comment|^|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^|^").replace("comment",U).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),F=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,N=k(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",F).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),G=k(/^!?\[(label)\]\[(ref)\]/).replace("label",F).replace("ref",T).getRegex(),J=k(/^!?\[(ref)\](?:\[\])?/).replace("ref",T).getRegex(),K={_backpedal:f,anyPunctuation:j,autolink:H,blockSkip:/\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g,br:v,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:f,emStrongLDelim:M,emStrongRDelimAst:O,emStrongRDelimUnd:D,escape:Q,link:N,nolink:J,punctuation:C,reflink:G,reflinkSearch:k("reflink|nolink(?!\\()","g").replace("reflink",G).replace("nolink",J).getRegex(),tag:X,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\t+" ".repeat(n.length)));e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some((s=>!!(n=s.call({lexer:this},e,t))&&(e=e.substring(n.raw.length),t.push(n),!0)))))if(n=this.tokenizer.space(e))e=e.substring(n.raw.length),1===n.raw.length&&t.length>0?t[t.length-1].raw+="\n":t.push(n);else if(n=this.tokenizer.code(e))e=e.substring(n.raw.length),s=t[t.length-1],!s||"paragraph"!==s.type&&"text"!==s.type?t.push(n):(s.raw+="\n"+n.raw,s.text+="\n"+n.text,this.inlineQueue[this.inlineQueue.length-1].src=s.text);else if(n=this.tokenizer.fences(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.heading(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.hr(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.blockquote(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.list(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.html(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.def(e))e=e.substring(n.raw.length),s=t[t.length-1],!s||"paragraph"!==s.type&&"text"!==s.type?this.tokens.links[n.tag]||(this.tokens.links[n.tag]={href:n.href,title:n.title}):(s.raw+="\n"+n.raw,s.text+="\n"+n.raw,this.inlineQueue[this.inlineQueue.length-1].src=s.text);else if(n=this.tokenizer.table(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.lheading(e))e=e.substring(n.raw.length),t.push(n);else{if(r=e,this.options.extensions&&this.options.extensions.startBlock){let t=1/0;const n=e.slice(1);let s;this.options.extensions.startBlock.forEach((e=>{s=e.call({lexer:this},n),"number"==typeof s&&s>=0&&(t=Math.min(t,s))})),t<1/0&&t>=0&&(r=e.substring(0,t+1))}if(this.state.top&&(n=this.tokenizer.paragraph(r)))s=t[t.length-1],i&&"paragraph"===s.type?(s.raw+="\n"+n.raw,s.text+="\n"+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=s.text):t.push(n),i=r.length!==e.length,e=e.substring(n.raw.length);else if(n=this.tokenizer.text(e))e=e.substring(n.raw.length),s=t[t.length-1],s&&"text"===s.type?(s.raw+="\n"+n.raw,s.text+="\n"+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=s.text):t.push(n);else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n,s,r,i,l,o,a=e;if(this.tokens.links){const e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(i=this.tokenizer.rules.inline.reflinkSearch.exec(a));)e.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(a=a.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+a.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(i=this.tokenizer.rules.inline.blockSkip.exec(a));)a=a.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+a.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;null!=(i=this.tokenizer.rules.inline.anyPunctuation.exec(a));)a=a.slice(0,i.index)+"++"+a.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;e;)if(l||(o=""),l=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some((s=>!!(n=s.call({lexer:this},e,t))&&(e=e.substring(n.raw.length),t.push(n),!0)))))if(n=this.tokenizer.escape(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.tag(e))e=e.substring(n.raw.length),s=t[t.length-1],s&&"text"===n.type&&"text"===s.type?(s.raw+=n.raw,s.text+=n.text):t.push(n);else if(n=this.tokenizer.link(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.reflink(e,this.tokens.links))e=e.substring(n.raw.length),s=t[t.length-1],s&&"text"===n.type&&"text"===s.type?(s.raw+=n.raw,s.text+=n.text):t.push(n);else if(n=this.tokenizer.emStrong(e,a,o))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.codespan(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.br(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.del(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.autolink(e))e=e.substring(n.raw.length),t.push(n);else if(this.state.inLink||!(n=this.tokenizer.url(e))){if(r=e,this.options.extensions&&this.options.extensions.startInline){let t=1/0;const n=e.slice(1);let s;this.options.extensions.startInline.forEach((e=>{s=e.call({lexer:this},n),"number"==typeof s&&s>=0&&(t=Math.min(t,s))})),t<1/0&&t>=0&&(r=e.substring(0,t+1))}if(n=this.tokenizer.inlineText(r))e=e.substring(n.raw.length),"_"!==n.raw.slice(-1)&&(o=n.raw.slice(-1)),l=!0,s=t[t.length-1],s&&"text"===s.type?(s.raw+=n.raw,s.text+=n.text):t.push(n);else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}else e=e.substring(n.raw.length),t.push(n);return t}}class se{options;constructor(t){this.options=t||e.defaults}code(e,t,n){const s=(t||"").match(/^\S*/)?.[0];return e=e.replace(/\n$/,"")+"\n",s?'
'+(n?e:c(e,!0))+"
\n":"
"+(n?e:c(e,!0))+"
\n"}blockquote(e){return`
\n${e}
\n`}html(e,t){return e}heading(e,t,n){return`${e}\n`}hr(){return"
\n"}list(e,t,n){const s=t?"ol":"ul";return"<"+s+(t&&1!==n?' start="'+n+'"':"")+">\n"+e+"\n"}listitem(e,t,n){return`
  • ${e}
  • \n`}checkbox(e){return"'}paragraph(e){return`

    ${e}

    \n`}table(e,t){return t&&(t=`${t}`),"\n\n"+e+"\n"+t+"
    \n"}tablerow(e){return`\n${e}\n`}tablecell(e,t){const n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`\n`}strong(e){return`${e}`}em(e){return`${e}`}codespan(e){return`${e}`}br(){return"
    "}del(e){return`${e}`}link(e,t,n){const s=g(e);if(null===s)return n;let r='
    ",r}image(e,t,n){const s=g(e);if(null===s)return n;let r=`${n}0&&"paragraph"===n.tokens[0].type?(n.tokens[0].text=e+" "+n.tokens[0].text,n.tokens[0].tokens&&n.tokens[0].tokens.length>0&&"text"===n.tokens[0].tokens[0].type&&(n.tokens[0].tokens[0].text=e+" "+n.tokens[0].tokens[0].text)):n.tokens.unshift({type:"text",text:e+" "}):o+=e+" "}o+=this.parse(n.tokens,i),l+=this.renderer.listitem(o,r,!!s)}n+=this.renderer.list(l,t,s);continue}case"html":{const e=r;n+=this.renderer.html(e.text,e.block);continue}case"paragraph":{const e=r;n+=this.renderer.paragraph(this.parseInline(e.tokens));continue}case"text":{let i=r,l=i.tokens?this.parseInline(i.tokens):i.text;for(;s+1{const r=e[s].flat(1/0);n=n.concat(this.walkTokens(r,t))})):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){const t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach((e=>{const n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach((e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){const n=t.renderers[e.name];t.renderers[e.name]=n?function(...t){let s=e.renderer.apply(this,t);return!1===s&&(s=n.apply(this,t)),s}:e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");const n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)})),n.extensions=t),e.renderer){const t=this.defaults.renderer||new se(this.defaults);for(const n in e.renderer){if(!(n in t))throw new Error(`renderer '${n}' does not exist`);if("options"===n)continue;const s=n,r=e.renderer[s],i=t[s];t[s]=(...e)=>{let n=r.apply(t,e);return!1===n&&(n=i.apply(t,e)),n||""}}n.renderer=t}if(e.tokenizer){const t=this.defaults.tokenizer||new w(this.defaults);for(const n in e.tokenizer){if(!(n in t))throw new Error(`tokenizer '${n}' does not exist`);if(["options","rules","lexer"].includes(n))continue;const s=n,r=e.tokenizer[s],i=t[s];t[s]=(...e)=>{let n=r.apply(t,e);return!1===n&&(n=i.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){const t=this.defaults.hooks||new le;for(const n in e.hooks){if(!(n in t))throw new Error(`hook '${n}' does not exist`);if("options"===n)continue;const s=n,r=e.hooks[s],i=t[s];le.passThroughHooks.has(n)?t[s]=e=>{if(this.defaults.async)return Promise.resolve(r.call(t,e)).then((e=>i.call(t,e)));const n=r.call(t,e);return i.call(t,n)}:t[s]=(...e)=>{let n=r.apply(t,e);return!1===n&&(n=i.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){const t=this.defaults.walkTokens,s=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(s.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}})),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return ne.lex(e,t??this.defaults)}parser(e,t){return ie.parse(e,t??this.defaults)}#e(e,t){return(n,s)=>{const r={...s},i={...this.defaults,...r};!0===this.defaults.async&&!1===r.async&&(i.silent||console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored."),i.async=!0);const l=this.#t(!!i.silent,!!i.async);if(null==n)return l(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof n)return l(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(i.hooks&&(i.hooks.options=i),i.async)return Promise.resolve(i.hooks?i.hooks.preprocess(n):n).then((t=>e(t,i))).then((e=>i.hooks?i.hooks.processAllTokens(e):e)).then((e=>i.walkTokens?Promise.all(this.walkTokens(e,i.walkTokens)).then((()=>e)):e)).then((e=>t(e,i))).then((e=>i.hooks?i.hooks.postprocess(e):e)).catch(l);try{i.hooks&&(n=i.hooks.preprocess(n));let s=e(n,i);i.hooks&&(s=i.hooks.processAllTokens(s)),i.walkTokens&&this.walkTokens(s,i.walkTokens);let r=t(s,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return l(e)}}}#t(e,t){return n=>{if(n.message+="\nPlease report this to https://github.com/markedjs/marked.",e){const e="

    An error occurred:

    "+c(n.message+"",!0)+"
    ";return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}}const ae=new oe;function ce(e,t){return ae.parse(e,t)}ce.options=ce.setOptions=function(e){return ae.setOptions(e),ce.defaults=ae.defaults,n(ce.defaults),ce},ce.getDefaults=t,ce.defaults=e.defaults,ce.use=function(...e){return ae.use(...e),ce.defaults=ae.defaults,n(ce.defaults),ce},ce.walkTokens=function(e,t){return ae.walkTokens(e,t)},ce.parseInline=ae.parseInline,ce.Parser=ie,ce.parser=ie.parse,ce.Renderer=se,ce.TextRenderer=re,ce.Lexer=ne,ce.lexer=ne.lex,ce.Tokenizer=w,ce.Hooks=le,ce.parse=ce;const he=ce.options,pe=ce.setOptions,ue=ce.use,ke=ce.walkTokens,ge=ce.parseInline,fe=ce,de=ie.parse,xe=ne.lex;e.Hooks=le,e.Lexer=ne,e.Marked=oe,e.Parser=ie,e.Renderer=se,e.TextRenderer=re,e.Tokenizer=w,e.getDefaults=t,e.lexer=xe,e.marked=ce,e.options=he,e.parse=fe,e.parseInline=ge,e.parser=de,e.setOptions=pe,e.use=ue,e.walkTokens=ke})); diff --git a/apps/app/public/lib/sdk/hooks.bundled.d.ts b/apps/app/public/lib/sdk/hooks.bundled.d.ts index d1939158..6db42890 100644 --- a/apps/app/public/lib/sdk/hooks.bundled.d.ts +++ b/apps/app/public/lib/sdk/hooks.bundled.d.ts @@ -7508,14 +7508,14 @@ declare const ftiframeOptionSchema: z.ZodObject<{ type FtiframeOption = z.infer; import { z } from 'zod'; -declare const ftimgDataSchema: z.ZodArray>; -type FtimgData = z.infer; +type SwimgData = z.infer; /** * 图片配置选项 Schema */ -declare const ftimgOptionSchema: z.ZodObject<{ +declare const swimgOptionSchema: z.ZodObject<{ cover: z.ZodString; url: z.ZodString; duration: z.ZodString; @@ -7576,7 +7576,7 @@ declare const ftimgOptionSchema: z.ZodObject<{ backdropFilterBlur: z.ZodNumber; backdropFilterSaturate: z.ZodNumber; }, z.core.$strip>; -type FtimgOption = z.infer; +type SwimgOption = z.infer; import { z } from 'zod'; /** @@ -19322,7 +19322,7 @@ declare enum MediaEnum { /** iframe */ FtIframe = "swiframe", /** 图片 */ - FtImg = "swimg", + SwImg = "swimg", /** 视频播放器 */ FtOpenVideo = "sw-open-video", /** 图片边框 */ @@ -19401,13 +19401,13 @@ declare enum TextEnum { /** 自定义折叠面板 */ CustomCollapse = "customCollapse", /** 富文本 */ - FtRichtext = "swRichtext", + SwRichtext = "swRichtext", /** 集合组件 */ FtCollection = "swcollection", /** 自定义表格列表 */ CustomTableList = "customTableList", /** 文本词云 */ - FtTextWordCloud = "swTextWordCloud", + SwTextWordCloud = "swTextWordCloud", /** 多行文本 */ FtMultiLine = "swmultiLine", /** 基础文本 */ diff --git a/apps/app/src/tests/statusAnimation/autoPropertyGroupDerivation.test.ts b/apps/app/src/tests/statusAnimation/autoPropertyGroupDerivation.test.ts index 4c814be9..4564589a 100644 --- a/apps/app/src/tests/statusAnimation/autoPropertyGroupDerivation.test.ts +++ b/apps/app/src/tests/statusAnimation/autoPropertyGroupDerivation.test.ts @@ -19,7 +19,7 @@ describe("自动属性组推导功能", () => { afterEach(() => { testUtils.cleanupTestEnvironment(); }); - it("应该为 FtImg 组件推导出正确的属性组", () => { + it("应该为 SwImg 组件推导出正确的属性组", () => { const groups = getComponentPropertyGroups(mediaEnum.SwImg); // 验证包含所有预期的属性组 diff --git a/apps/app/src/views/build/components/agentBI/hooks/useFigmaToBI.ts b/apps/app/src/views/build/components/agentBI/hooks/useFigmaToBI.ts index ed906635..6b1d9950 100644 --- a/apps/app/src/views/build/components/agentBI/hooks/useFigmaToBI.ts +++ b/apps/app/src/views/build/components/agentBI/hooks/useFigmaToBI.ts @@ -67,7 +67,7 @@ export const useFigmaToBI = createGlobalState(() => { /** * 将组件的 Figma 图片 URL 上传到 MinIO,返回上传后的新 URL。 - * 仅处理 FtImg 类型组件且 URL 为内网地址的情况,其他情况返回 null。 + * 仅处理 SwImg 类型组件且 URL 为内网地址的情况,其他情况返回 null。 * * @param component - 需要上传图片的 BI 组件 * @returns 上传成功后的 MinIO URL,失败或不需要上传时返回 null diff --git a/packages/material/package.json b/packages/material/package.json index d052ac36..679eb0da 100644 --- a/packages/material/package.json +++ b/packages/material/package.json @@ -58,6 +58,7 @@ "@screenwright/composables": "workspace:*", "@screenwright/core": "workspace:*", "@screenwright/types": "workspace:*", + "@tiptap/core": "3.31.3", "@tiptap/extension-color": "3.31.3", "@tiptap/extension-font-family": "3.31.3", "@tiptap/extension-text-align": "3.31.3", diff --git a/packages/types/src/schemas/components/media/swimg.ts b/packages/types/src/schemas/components/media/swimg.ts index f2b85f7b..7322ac84 100644 --- a/packages/types/src/schemas/components/media/swimg.ts +++ b/packages/types/src/schemas/components/media/swimg.ts @@ -1,7 +1,7 @@ import { z } from "zod"; /** - * 图片 (ftimg) + * 图片 (swimg) * 媒体 * * ## 数据结构 @@ -11,28 +11,28 @@ import { z } from "zod"; * * @example * ```typescript - * const data: FtimgData = [ + * const data: SwimgData = [ * { value: "image.png" } * ]; * ``` */ // Single data item Schema -const ftimgDataItemSchema = z.object({ +const swimgDataItemSchema = z.object({ value: z.string().describe("图片地址") }); // Data array Schema -export const ftimgDataSchema = z.array(ftimgDataItemSchema); +export const swimgDataSchema = z.array(swimgDataItemSchema); -export type FtimgData = z.infer; +export type SwimgData = z.infer; // ==================== Option Schema ==================== /** * 图片配置选项 Schema */ -export const ftimgOptionSchema = z.object({ +export const swimgOptionSchema = z.object({ // ============ 基础配置 ============ cover: z.string().describe("图片封面地址"), url: z.string().describe("图片地址"), @@ -107,4 +107,4 @@ export const ftimgOptionSchema = z.object({ backdropFilterSaturate: z.number().describe("背景饱和度") }); -export type FtimgOption = z.infer; +export type SwimgOption = z.infer; diff --git a/packages/types/src/schemas/components/propSchemaMap.ts b/packages/types/src/schemas/components/propSchemaMap.ts index 3ba2e4f2..b8b2a3a4 100644 --- a/packages/types/src/schemas/components/propSchemaMap.ts +++ b/packages/types/src/schemas/components/propSchemaMap.ts @@ -82,7 +82,7 @@ import { ctVideoPanelDataSchema, ctVideoPanelOptionSchema } from "./media/ctVide import { swEmbedAudioDataSchema, swEmbedAudioOptionSchema } from "./media/sw-embed-audio"; import { swOpenVideoDataSchema, swOpenVideoOptionSchema } from "./media/sw-open-video"; import { ftiframeDataSchema, ftiframeOptionSchema } from "./media/swiframe"; -import { ftimgDataSchema, ftimgOptionSchema } from "./media/swimg"; +import { swimgDataSchema, swimgOptionSchema } from "./media/swimg"; import { ftswiperDataSchema, ftswiperOptionSchema } from "./media/swswiper"; import { swSwiperCardDataSchema, swSwiperCardOptionSchema } from "./media/swSwiperCard"; import { ftvideoDataSchema, ftvideoOptionSchema } from "./media/swvideo"; @@ -156,7 +156,7 @@ export const componentPropSchemaMap = { rasterProgressBar: { data: rasterProgressBarDataSchema, option: rasterProgressBarOptionSchema }, "sw-embed-audio": { data: swEmbedAudioDataSchema, option: swEmbedAudioOptionSchema }, swiframe: { data: ftiframeDataSchema, option: ftiframeOptionSchema }, - swimg: { data: ftimgDataSchema, option: ftimgOptionSchema }, + swimg: { data: swimgDataSchema, option: swimgOptionSchema }, "sw-open-video": { data: swOpenVideoDataSchema, option: swOpenVideoOptionSchema }, swSwiperCard: { data: swSwiperCardDataSchema, option: swSwiperCardOptionSchema }, swswiper: { data: ftswiperDataSchema, option: ftswiperOptionSchema }, diff --git a/packages/types/src/schemas/components/text/swRichtext.ts b/packages/types/src/schemas/components/text/swRichtext.ts index 1fd13f0d..5ee4c58b 100644 --- a/packages/types/src/schemas/components/text/swRichtext.ts +++ b/packages/types/src/schemas/components/text/swRichtext.ts @@ -1,7 +1,7 @@ import { z } from "zod"; /** - * 富文本 (ftRichtext) + * 富文本 (swRichtext) * 文字 * * ## 数据结构 @@ -11,7 +11,7 @@ import { z } from "zod"; * * @example * ```typescript - * const data: FtRichtextData = [ + * const data: SwRichtextData = [ * { value: "

    这是富文本内容

    " } * ]; * ``` @@ -25,7 +25,7 @@ const swRichtextDataItemSchema = z.object({ // 数据数组 Schema export const swRichtextDataSchema = z.array(swRichtextDataItemSchema); -export type FtRichtextData = z.infer; +export type SwRichtextData = z.infer; // ==================== Option Schema ==================== @@ -47,4 +47,4 @@ export const swRichtextOptionSchema = z.object({ scrollInterval: z.number().describe("滚动间隔") }); -export type FtRichtextOption = z.infer; +export type SwRichtextOption = z.infer; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d0aa1cde..79f4f9b9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -222,6 +222,9 @@ importers: lodash-es: specifier: 4.17.21 version: 4.17.21 + marked: + specifier: ^17.0.3 + version: 17.0.3 mitt: specifier: ^3.0.1 version: 3.0.1 @@ -702,6 +705,9 @@ importers: '@screenwright/types': specifier: workspace:* version: link:../types + '@tiptap/core': + specifier: 3.31.3 + version: 3.31.3(@tiptap/pm@3.31.3) '@tiptap/extension-color': specifier: 3.31.3 version: 3.31.3(@tiptap/extension-text-style@3.31.3(@tiptap/core@3.31.3(@tiptap/pm@3.31.3))) diff --git a/servers/server/agent-workspace/types/hooks.d.ts b/servers/server/agent-workspace/types/hooks.d.ts index a168250d..592cf4e5 100644 --- a/servers/server/agent-workspace/types/hooks.d.ts +++ b/servers/server/agent-workspace/types/hooks.d.ts @@ -115,9 +115,9 @@ declare const ComponentFlatSchema: z.ZodObject<{ swSwiperCard: import("..").MediaEnum.FtSwiperCard; "sw-embed-audio": import("..").MediaEnum.FtEmbedAudio; swiframe: import("..").MediaEnum.FtIframe; - swimg: import("..").MediaEnum.FtImg; + swimg: import("..").MediaEnum.SwImg; "sw-open-video": import("..").MediaEnum.FtOpenVideo; - swimgBorder: import("..").MediaEnum.FtImgBorder; + swimgBorder: import("..").MediaEnum.SwImgBorder; swswiper: import("..").MediaEnum.FtSwiper; swSwiperV3: import("..").MediaEnum.FtSwiperV3; swvideo: import("..").MediaEnum.FtVideo; @@ -179,10 +179,10 @@ declare const ComponentFlatSchema: z.ZodObject<{ videoProgress: import("..").InteractiveEnum.videoProgress; }>, z.ZodEnum<{ customCollapse: import("..").TextEnum.CustomCollapse; - swRichtext: import("..").TextEnum.FtRichtext; + swRichtext: import("..").TextEnum.SwRichtext; swcollection: import("..").TextEnum.FtCollection; customTableList: import("..").TextEnum.CustomTableList; - swTextWordCloud: import("..").TextEnum.FtTextWordCloud; + swTextWordCloud: import("..").TextEnum.SwTextWordCloud; swmultiLine: import("..").TextEnum.FtMultiLine; swtext: import("..").TextEnum.FtText; swProgress: import("..").TextEnum.FtProgress; @@ -7511,14 +7511,14 @@ declare const ftiframeOptionSchema: z.ZodObject<{ type FtiframeOption = z.infer; import { z } from 'zod'; -declare const ftimgDataSchema: z.ZodArray>; -type FtimgData = z.infer; +type SwimgData = z.infer; /** * 图片配置选项 Schema */ -declare const ftimgOptionSchema: z.ZodObject<{ +declare const swimgOptionSchema: z.ZodObject<{ cover: z.ZodString; url: z.ZodString; duration: z.ZodString; @@ -7579,7 +7579,7 @@ declare const ftimgOptionSchema: z.ZodObject<{ backdropFilterBlur: z.ZodNumber; backdropFilterSaturate: z.ZodNumber; }, z.core.$strip>; -type FtimgOption = z.infer; +type SwimgOption = z.infer; import { z } from 'zod'; /** @@ -16589,9 +16589,9 @@ declare const mediaEnumSchema: z.ZodEnum<{ swSwiperCard: import("..").MediaEnum.FtSwiperCard; "sw-embed-audio": import("..").MediaEnum.FtEmbedAudio; swiframe: import("..").MediaEnum.FtIframe; - swimg: import("..").MediaEnum.FtImg; + swimg: import("..").MediaEnum.SwImg; "sw-open-video": import("..").MediaEnum.FtOpenVideo; - swimgBorder: import("..").MediaEnum.FtImgBorder; + swimgBorder: import("..").MediaEnum.SwImgBorder; swswiper: import("..").MediaEnum.FtSwiper; swSwiperV3: import("..").MediaEnum.FtSwiperV3; swvideo: import("..").MediaEnum.FtVideo; @@ -16649,10 +16649,10 @@ declare const interactiveEnumSchema: z.ZodEnum<{ /** 文本类型枚举 Schema */ declare const textEnumSchema: z.ZodEnum<{ customCollapse: import("..").TextEnum.CustomCollapse; - swRichtext: import("..").TextEnum.FtRichtext; + swRichtext: import("..").TextEnum.SwRichtext; swcollection: import("..").TextEnum.FtCollection; customTableList: import("..").TextEnum.CustomTableList; - swTextWordCloud: import("..").TextEnum.FtTextWordCloud; + swTextWordCloud: import("..").TextEnum.SwTextWordCloud; swmultiLine: import("..").TextEnum.FtMultiLine; swtext: import("..").TextEnum.FtText; swProgress: import("..").TextEnum.FtProgress; @@ -16752,9 +16752,9 @@ declare const allComponentTypeSchema: z.ZodUnion, z.ZodEnum<{ customCollapse: import("..").TextEnum.CustomCollapse; - swRichtext: import("..").TextEnum.FtRichtext; + swRichtext: import("..").TextEnum.SwRichtext; swcollection: import("..").TextEnum.FtCollection; customTableList: import("..").TextEnum.CustomTableList; - swTextWordCloud: import("..").TextEnum.FtTextWordCloud; + swTextWordCloud: import("..").TextEnum.SwTextWordCloud; swmultiLine: import("..").TextEnum.FtMultiLine; swtext: import("..").TextEnum.FtText; swProgress: import("..").TextEnum.FtProgress; @@ -18476,7 +18476,7 @@ interface FtProgressEvents { }; } interface FtTextWordCloudEvents { - [key: `${TextEnum.FtTextWordCloud}-${string}`]: { + [key: `${TextEnum.SwTextWordCloud}-${string}`]: { /** * @description 点击事件 */ @@ -19384,7 +19384,7 @@ declare enum MediaEnum { /** iframe */ FtIframe = "swiframe", /** 图片 */ - FtImg = "swimg", + SwImg = "swimg", /** 视频播放器 */ FtOpenVideo = "sw-open-video", /** 图片边框 */ @@ -19463,13 +19463,13 @@ declare enum TextEnum { /** 自定义折叠面板 */ CustomCollapse = "customCollapse", /** 富文本 */ - FtRichtext = "swRichtext", + SwRichtext = "swRichtext", /** 集合组件 */ FtCollection = "swcollection", /** 自定义表格列表 */ CustomTableList = "customTableList", /** 文本词云 */ - FtTextWordCloud = "swTextWordCloud", + SwTextWordCloud = "swTextWordCloud", /** 多行文本 */ FtMultiLine = "swmultiLine", /** 基础文本 */ diff --git a/servers/server/evals/cases/a-single-tool/a1-create-component.ts b/servers/server/evals/cases/a-single-tool/a1-create-component.ts index b3b667f7..9c951c2f 100644 --- a/servers/server/evals/cases/a-single-tool/a1-create-component.ts +++ b/servers/server/evals/cases/a-single-tool/a1-create-component.ts @@ -29,7 +29,7 @@ export const a1CreateComponent: EvalCase = { assert: (ctx): Assertion[] => { const created = newComponents(ctx.before, ctx.screen); - const wordClouds = hasProp(created, TextEnum.FtTextWordCloud); + const wordClouds = hasProp(created, TextEnum.SwTextWordCloud); return [ { @@ -48,7 +48,7 @@ export const a1CreateComponent: EvalCase = { detail: wordClouds.length > 0 ? `id=${wordClouds.map((c) => c.id).join(",")}` - : `新增组件的类型是 ${created.map((c) => c.component.prop).join(", ") || "(无)"},期望含 ${TextEnum.FtTextWordCloud}` + : `新增组件的类型是 ${created.map((c) => c.component.prop).join(", ") || "(无)"},期望含 ${TextEnum.SwTextWordCloud}` }, // 位置不较真「是不是在左边」——那是审美判断,agent 每次给的值都不一样。 // 真正会坏事的是把组件放到画布外面,那是能精确判定的。 diff --git a/servers/server/src/mastra/state/componentConversionState.ts b/servers/server/src/mastra/state/componentConversionState.ts index ae0bd5a9..71907ee4 100644 --- a/servers/server/src/mastra/state/componentConversionState.ts +++ b/servers/server/src/mastra/state/componentConversionState.ts @@ -2,12 +2,12 @@ import type { ComponentType } from "@screenwright/types"; import { FolderEnum, PanelEnum } from "@screenwright/types"; import { z } from "zod"; -import type { FtImg } from "@/mastra/workflows/figma-to-bi/steps/node-convert/strategies/FtImgStrategy"; +import type { SwImg } from "@/mastra/workflows/figma-to-bi/steps/node-convert/strategies/SwImgStrategy"; import { createPanelState, type FtPanel } from "@/mastra/workflows/figma-to-bi/steps/node-convert/strategies/FtPanelStrategy"; -import type { FtRichtext } from "@/mastra/workflows/figma-to-bi/steps/node-convert/strategies/FtRichtextStrategy"; +import type { SwRichtext } from "@/mastra/workflows/figma-to-bi/steps/node-convert/strategies/SwRichtextStrategy"; import type { FtSubtabs } from "@/mastra/workflows/figma-to-bi/steps/node-convert/strategies/FtSubtabStrategy"; import type { Group } from "@/mastra/workflows/figma-to-bi/steps/node-convert/strategies/GroupStrategy"; @@ -17,7 +17,7 @@ import type { IValueStore } from "./stateManager"; /** * 支持的组件类型联合 */ -export type ConvertedComponent = FtRichtext | FtImg | Group | FtPanel | FtSubtabs; +export type ConvertedComponent = SwRichtext | SwImg | Group | FtPanel | FtSubtabs; /** * 组件转换条目 diff --git a/servers/server/src/mastra/state/nodeClassificationState.ts b/servers/server/src/mastra/state/nodeClassificationState.ts index f2eca60e..c357b507 100644 --- a/servers/server/src/mastra/state/nodeClassificationState.ts +++ b/servers/server/src/mastra/state/nodeClassificationState.ts @@ -13,8 +13,8 @@ export const nodeClassificationSchema = z.object({ .enum([ PanelEnum.dynamicPanel, FolderEnum.group, - MediaEnum.FtImg, - TextEnum.FtRichtext, + MediaEnum.SwImg, + TextEnum.SwRichtext, InteractiveEnum.Subtabs, "merge", "root" diff --git a/servers/server/src/mastra/tools/utils.ts b/servers/server/src/mastra/tools/utils.ts index 7fd45387..1c13474e 100644 --- a/servers/server/src/mastra/tools/utils.ts +++ b/servers/server/src/mastra/tools/utils.ts @@ -13,9 +13,9 @@ import type { NormalizedNode } from "../types/normalized-node-types"; let _idSeq = Date.now(); const nextId = (): number => ++_idSeq; -export const FT_IMG_MODULE_ID = 43; +export const SW_IMG_MODULE_ID = 43; -export const FT_RICHTEXT_MODULE_ID = 113; +export const SW_RICHTEXT_MODULE_ID = 113; export const FT_PANEL_MODULE_ID = 69; diff --git a/servers/server/src/mastra/workflows/figma-to-bi/adapters/codia-to-normalized.ts b/servers/server/src/mastra/workflows/figma-to-bi/adapters/codia-to-normalized.ts index 03b87de0..624b65ed 100644 --- a/servers/server/src/mastra/workflows/figma-to-bi/adapters/codia-to-normalized.ts +++ b/servers/server/src/mastra/workflows/figma-to-bi/adapters/codia-to-normalized.ts @@ -478,7 +478,7 @@ function pairToNormalized(pair: YogaPair, scale: number, parentAbsX = 0, parentA // Codia 把"这里应该有张图"识别成 Image 类型节点,但没能提取出实际图片资源时 imageSource // 是空字符串——此时没有任何可用的图片/颜色兜底数据(backgroundConfig 也不存在),保留这个 - // 节点只会在下游转换出一个占位默认图的 ftImg 组件,内容与设计稿不符,故直接丢弃整个节点。 + // 节点只会在下游转换出一个占位默认图的 swImg 组件,内容与设计稿不符,故直接丢弃整个节点。 if (isImage && !imgLocalPath) { return null; } diff --git a/servers/server/src/mastra/workflows/figma-to-bi/steps/classification/rule-based-node-classifier.ts b/servers/server/src/mastra/workflows/figma-to-bi/steps/classification/rule-based-node-classifier.ts index 39921f4f..46955256 100644 --- a/servers/server/src/mastra/workflows/figma-to-bi/steps/classification/rule-based-node-classifier.ts +++ b/servers/server/src/mastra/workflows/figma-to-bi/steps/classification/rule-based-node-classifier.ts @@ -133,7 +133,7 @@ export class RuleBasedNodeClassifier { }; // 如果是图片节点,收集图片候选 - if (targetType === MediaEnum.FtImg) { + if (targetType === MediaEnum.SwImg) { this.collectImageCandidate(bfsNode, classification); } @@ -178,7 +178,7 @@ export class RuleBasedNodeClassifier { if (isImageNode(name)) { // 只有标记为 -image 的节点才转为图片 - return MediaEnum.FtImg; + return MediaEnum.SwImg; } if (isGroupNode(name)) { @@ -187,7 +187,7 @@ export class RuleBasedNodeClassifier { // 优先级 2: 检查节点类型 if (this.isTextNode(bfsNode.node)) { - return TextEnum.FtRichtext; + return TextEnum.SwRichtext; } // 优先级 3: 默认规则 @@ -197,7 +197,7 @@ export class RuleBasedNodeClassifier { } // 其余未打标记的非文本节点(GROUP/VECTOR/RECTANGLE/INSTANCE 等)统一收敛为图片 - return MediaEnum.FtImg; + return MediaEnum.SwImg; } /** diff --git a/servers/server/src/mastra/workflows/figma-to-bi/steps/node-convert/strategies/ConversionStrategyFactory.ts b/servers/server/src/mastra/workflows/figma-to-bi/steps/node-convert/strategies/ConversionStrategyFactory.ts index 7e37f9fc..4f159ca2 100644 --- a/servers/server/src/mastra/workflows/figma-to-bi/steps/node-convert/strategies/ConversionStrategyFactory.ts +++ b/servers/server/src/mastra/workflows/figma-to-bi/steps/node-convert/strategies/ConversionStrategyFactory.ts @@ -1,8 +1,8 @@ import { FolderEnum, InteractiveEnum, mediaEnum, PanelEnum, textEnum } from "@screenwright/types"; -import { FtImgStrategy } from "./FtImgStrategy"; +import { SwImgStrategy } from "./SwImgStrategy"; import { FtPanelStrategy } from "./FtPanelStrategy"; -import { FtRichtextStrategy } from "./FtRichtextStrategy"; +import { SwRichtextStrategy } from "./SwRichtextStrategy"; import { FtSubtabStrategy } from "./FtSubtabStrategy"; import { GroupStrategy } from "./GroupStrategy"; import type { ConvertStrategy } from "./types"; @@ -14,8 +14,8 @@ import type { ConvertStrategy } from "./types"; * 添加新组件类型时,只需在此注册一行,无需修改任何其他代码。 */ const strategyRegistry: Record = { - [textEnum.FtRichtext]: new FtRichtextStrategy(), - [mediaEnum.FtImg]: new FtImgStrategy(), + [textEnum.SwRichtext]: new SwRichtextStrategy(), + [mediaEnum.SwImg]: new SwImgStrategy(), [FolderEnum.group]: new GroupStrategy(), [PanelEnum.dynamicPanel]: new FtPanelStrategy(), [InteractiveEnum.Subtabs]: new FtSubtabStrategy() diff --git a/servers/server/src/mastra/workflows/figma-to-bi/steps/node-convert/strategies/FtImgStrategy.ts b/servers/server/src/mastra/workflows/figma-to-bi/steps/node-convert/strategies/SwImgStrategy.ts similarity index 85% rename from servers/server/src/mastra/workflows/figma-to-bi/steps/node-convert/strategies/FtImgStrategy.ts rename to servers/server/src/mastra/workflows/figma-to-bi/steps/node-convert/strategies/SwImgStrategy.ts index af6dc644..b6ed3349 100644 --- a/servers/server/src/mastra/workflows/figma-to-bi/steps/node-convert/strategies/FtImgStrategy.ts +++ b/servers/server/src/mastra/workflows/figma-to-bi/steps/node-convert/strategies/SwImgStrategy.ts @@ -3,7 +3,7 @@ import type { MediaEnum } from "@screenwright/types"; import { clampLayoutToMergeParent, extractLayout, - FT_IMG_MODULE_ID, + SW_IMG_MODULE_ID, getComponentDefaultConfigByModuleId, localPathToResourcePath, parseBackdropFilter, @@ -15,7 +15,7 @@ import type { NormalizedNode } from "@/mastra/types/normalized-node-types"; import type { ConvertParams, ConvertResult, ConvertStrategy } from "./types"; -export interface FtImgOption { +export interface SwImgOption { cover: string; url: string; duration: string; @@ -69,9 +69,9 @@ export interface FtImgOption { backdropFilterSaturate?: number; } -export type FtImgData = { value: string }[]; +export type SwImgData = { value: string }[]; -export type FtImg = ComponentType; +export type SwImg = ComponentType; function extractImageUrl(node: NormalizedNode): string { if (node.imgLocalPath) { @@ -80,8 +80,8 @@ function extractImageUrl(node: NormalizedNode): string { return "./assets/assets/defaultImg/default.png"; } -function convertNodeToFtImgOption(node: NormalizedNode): Partial { - const option: Partial = {}; +function convertNodeToSwImgOption(node: NormalizedNode): Partial { + const option: Partial = {}; if (node.opacity !== undefined && node.opacity !== 1) { option.opacity = node.opacity; @@ -115,15 +115,15 @@ function convertNodeToFtImgOption(node: NormalizedNode): Partial { return option; } -export class FtImgStrategy implements ConvertStrategy { +export class SwImgStrategy implements ConvertStrategy { async convert({ node }: ConvertParams): Promise { const { node: normalizedNode, zIndex, depth } = node; const imageUrl = extractImageUrl(normalizedNode); - const convertedOption = convertNodeToFtImgOption(normalizedNode); + const convertedOption = convertNodeToSwImgOption(normalizedNode); const layout = extractLayout(normalizedNode); - const component: FtImg = (await getComponentDefaultConfigByModuleId(FT_IMG_MODULE_ID)) as FtImg; + const component: SwImg = (await getComponentDefaultConfigByModuleId(SW_IMG_MODULE_ID)) as SwImg; setComponentBaseProps(component, normalizedNode, clampLayoutToMergeParent(normalizedNode.id, layout)); @@ -135,6 +135,6 @@ export class FtImgStrategy implements ConvertStrategy { }; component.zIndex = zIndex ?? depth; - return { component, message: "成功转换为 ftImg (默认)" }; + return { component, message: "成功转换为 swImg (默认)" }; } } diff --git a/servers/server/src/mastra/workflows/figma-to-bi/steps/node-convert/strategies/FtRichtextStrategy.ts b/servers/server/src/mastra/workflows/figma-to-bi/steps/node-convert/strategies/SwRichtextStrategy.ts similarity index 94% rename from servers/server/src/mastra/workflows/figma-to-bi/steps/node-convert/strategies/FtRichtextStrategy.ts rename to servers/server/src/mastra/workflows/figma-to-bi/steps/node-convert/strategies/SwRichtextStrategy.ts index 5196dffd..081a3b81 100644 --- a/servers/server/src/mastra/workflows/figma-to-bi/steps/node-convert/strategies/FtRichtextStrategy.ts +++ b/servers/server/src/mastra/workflows/figma-to-bi/steps/node-convert/strategies/SwRichtextStrategy.ts @@ -3,7 +3,7 @@ import { type TextEnum } from "@screenwright/types"; import type { ComponentFlatSchemaType } from "@/mastra/tools/utils"; import { extractLayout, - FT_RICHTEXT_MODULE_ID, + SW_RICHTEXT_MODULE_ID, getComponentDefaultConfigByModuleId, rgbaToCss, setComponentBaseProps @@ -13,7 +13,7 @@ import { isTextNode } from "@/mastra/workflows/figma-to-bi/utils/node-type-guard import type { ConvertParams, ConvertResult, ConvertStrategy } from "./types"; -export interface FtRichtextOption { +export interface SwRichtextOption { content: string; textAnimationType?: "" | "typingEffect" | "jumpingEffect" | "fallingEffect"; textAnimationTiming?: number; @@ -23,17 +23,17 @@ export interface FtRichtextOption { scrollInterval?: number; } -export type FtRichtextData = any[]; +export type SwRichtextData = any[]; -export type FtRichtext = ComponentFlatSchemaType & { +export type SwRichtext = ComponentFlatSchemaType & { component: { - prop: TextEnum.FtRichtext; + prop: TextEnum.SwRichtext; width: number; height: number; name: string; }; - option: FtRichtextOption; - data: FtRichtextData; + option: SwRichtextOption; + data: SwRichtextData; }; type FillStyle = { type: "solid"; color: string } | { type: "gradient"; gradientCss: string }; @@ -289,7 +289,7 @@ class RichTextHtmlGenerator { } } -function convertNodeToFtRichtextOption(_node: NormalizedNode, htmlContent: string): Partial { +function convertNodeToSwRichtextOption(_node: NormalizedNode, htmlContent: string): Partial { return { content: htmlContent, textAnimationType: "", @@ -298,23 +298,23 @@ function convertNodeToFtRichtextOption(_node: NormalizedNode, htmlContent: strin }; } -export class FtRichtextStrategy implements ConvertStrategy { +export class SwRichtextStrategy implements ConvertStrategy { async convert({ node }: ConvertParams): Promise { const { node: normalizedNode, zIndex, depth } = node; if (!isTextNode({ node: normalizedNode })) { - console.warn(`⚠️ 节点 ${normalizedNode.id} 被分类为 FtRichtext,但不是文本节点`); + console.warn(`⚠️ 节点 ${normalizedNode.id} 被分类为 SwRichtext,但不是文本节点`); } const htmlContent = new RichTextHtmlGenerator(normalizedNode).generate(); - const convertedOption = convertNodeToFtRichtextOption(normalizedNode, htmlContent); + const convertedOption = convertNodeToSwRichtextOption(normalizedNode, htmlContent); const layout = extractLayout(normalizedNode); // 富文本宽度补偿 5px:不同字体渲染宽度存在差异,原始布局宽度可能导致文字换行 layout.width = (layout.width || 316) + 5; layout.height = layout.height || 268; - const component: FtRichtext = (await getComponentDefaultConfigByModuleId(FT_RICHTEXT_MODULE_ID)) as FtRichtext; + const component: SwRichtext = (await getComponentDefaultConfigByModuleId(SW_RICHTEXT_MODULE_ID)) as SwRichtext; setComponentBaseProps(component, normalizedNode, layout); @@ -324,6 +324,6 @@ export class FtRichtextStrategy implements ConvertStrategy { }; component.zIndex = zIndex ?? depth; - return { component, message: "成功转换为 ftRichtext" }; + return { component, message: "成功转换为 swRichtext" }; } } diff --git a/servers/server/src/mastra/workflows/figma-to-bi/utils/convert-strategies.ts b/servers/server/src/mastra/workflows/figma-to-bi/utils/convert-strategies.ts index 4eb23d61..556e7cec 100644 --- a/servers/server/src/mastra/workflows/figma-to-bi/utils/convert-strategies.ts +++ b/servers/server/src/mastra/workflows/figma-to-bi/utils/convert-strategies.ts @@ -4,9 +4,9 @@ import type { ConvertedComponent } from "@/mastra/state/componentConversionState import type { BfsTraversalStepNode } from "@/mastra/types/bfs-traversal-types"; import type { NodeClassificationOutput } from "../steps/classification/rule-based-classification-step"; -import { FtImgStrategy } from "../steps/node-convert/strategies/FtImgStrategy"; +import { SwImgStrategy } from "../steps/node-convert/strategies/SwImgStrategy"; import { FtPanelStrategy } from "../steps/node-convert/strategies/FtPanelStrategy"; -import { FtRichtextStrategy } from "../steps/node-convert/strategies/FtRichtextStrategy"; +import { SwRichtextStrategy } from "../steps/node-convert/strategies/SwRichtextStrategy"; import { FtSubtabStrategy } from "../steps/node-convert/strategies/FtSubtabStrategy"; import { GroupStrategy } from "../steps/node-convert/strategies/GroupStrategy"; import { isSimpleImageNode, isTextNode } from "./node-type-guards"; @@ -29,16 +29,16 @@ export async function convertNodeByStrategy(params: ConvertNodeParams): Promise< try { switch (targetType) { - case textEnum.FtRichtext: { + case textEnum.SwRichtext: { if (!isTextNode({ node })) { - console.warn(`⚠️ 节点 ${nodeId} 被分类为 FtRichtext,但不是文本节点`); + console.warn(`⚠️ 节点 ${nodeId} 被分类为 SwRichtext,但不是文本节点`); } - const strategy = new FtRichtextStrategy(); + const strategy = new SwRichtextStrategy(); return strategy.convert({ node: postOrderNode, fileKey: "", workflowId: params.workflowId }); } - case mediaEnum.FtImg: { - const strategy = new FtImgStrategy(); + case mediaEnum.SwImg: { + const strategy = new SwImgStrategy(); if (isSimpleImageNode({ node })) { return strategy.convert({ node: postOrderNode, fileKey: "", workflowId: params.workflowId }); } diff --git a/servers/server/tests/adapters/codia/text1/codia-to-bi-components.test.ts b/servers/server/tests/adapters/codia/text1/codia-to-bi-components.test.ts index b220ba25..af3bb66a 100644 --- a/servers/server/tests/adapters/codia/text1/codia-to-bi-components.test.ts +++ b/servers/server/tests/adapters/codia/text1/codia-to-bi-components.test.ts @@ -3,9 +3,9 @@ import { beforeAll, describe, expect, it, vi } from "vitest"; import type { Data } from "@/mastra/types/codia"; import type { NodeConvertOutput } from "@/mastra/workflows/figma-to-bi/steps/node-convert/NodeConverter"; -import ftRichtextDefault from "../../../node-convert/richtext/ftRichtext.json"; +import swRichtextDefault from "../../../node-convert/richtext/swRichtext.json"; import mockResponse from "./data.mock.json"; -import ftImgDefault from "./ftImg.default-config.json"; +import swImgDefault from "./swImg.default-config.json"; import ftPanelDefault from "./ftPanel.default-config.json"; import { runCodiaToBIComponents } from "./helpers"; @@ -14,12 +14,12 @@ import { runCodiaToBIComponents } from "./helpers"; // // getComponentDefaultConfigByModuleId 是唯一的 DB 依赖,这里换成从 fundb 实际导出的 // 默认组件配置(43=图片 / 69=动态面板 / 113=富文本,见同目录 *.default-config.json 及 -// ../../../node-convert/richtext/ftRichtext.json),而不是手造的假数据。 +// ../../../node-convert/richtext/swRichtext.json),而不是手造的假数据。 const DEFAULT_CONFIG_BY_MODULE_ID: Record = { - 43: ftImgDefault.config, + 43: swImgDefault.config, 69: ftPanelDefault.config, - 113: ftRichtextDefault.config + 113: swRichtextDefault.config }; vi.mock("@/mastra/tools/utils", async () => { @@ -78,10 +78,10 @@ describe("Codia 真实样本:从设计稿一路转到 BI 组件", () => { expect(text.top).toBe(26); }); - it("普通图片节点转换为 ftImg 组件,url 直接透传 Codia CDN 直链", () => { + it("普通图片节点转换为 swImg 组件,url 直接透传 Codia CDN 直链", () => { const overlay = results.find((r) => r.nodeId === "ImageView_4650_747_2"); expect(overlay?.success).toBe(true); - expect(overlay?.targetType).toBe("swimg"); // MediaEnum.FtImg 的实际值 + expect(overlay?.targetType).toBe("swimg"); // MediaEnum.SwImg 的实际值 expect((overlay!.component as any).option.url).toBe( "https://static.codia.ai/s/image_8b9b6d0e-96cd-45a9-b18b-ea3ecfa608d1.png" ); diff --git a/servers/server/tests/adapters/codia/text1/helpers.ts b/servers/server/tests/adapters/codia/text1/helpers.ts index 38fd4944..72f3c192 100644 --- a/servers/server/tests/adapters/codia/text1/helpers.ts +++ b/servers/server/tests/adapters/codia/text1/helpers.ts @@ -17,7 +17,7 @@ let workflowSeq = 0; * * DB 依赖仅剩 getComponentDefaultConfigByModuleId(由调用方在测试文件里通过 * vi.mock("@/mastra/tools/utils") 换成真实 DB 导出的默认组件配置样本,见同目录 - * ftImg.default-config.json / ftPanel.default-config.json)。 + * swImg.default-config.json / ftPanel.default-config.json)。 */ export async function runCodiaToBIComponents(data: Data): Promise { const root = await convertCodiaToNormalizedNode(data); diff --git a/servers/server/tests/adapters/codia/text1/ftImg.default-config.json b/servers/server/tests/adapters/codia/text1/swImg.default-config.json similarity index 100% rename from servers/server/tests/adapters/codia/text1/ftImg.default-config.json rename to servers/server/tests/adapters/codia/text1/swImg.default-config.json diff --git a/servers/server/tests/node-convert/richtext/helpers.ts b/servers/server/tests/node-convert/richtext/helpers.ts index 187a0b0d..0842bb11 100644 --- a/servers/server/tests/node-convert/richtext/helpers.ts +++ b/servers/server/tests/node-convert/richtext/helpers.ts @@ -1,10 +1,10 @@ import type { FigmaNode } from "@/mastra/types/figma-type"; import type { NormalizedNode } from "@/mastra/types/normalized-node-types"; -import { FtRichtextStrategy } from "@/mastra/workflows/figma-to-bi/steps/node-convert/strategies/FtRichtextStrategy"; +import { SwRichtextStrategy } from "@/mastra/workflows/figma-to-bi/steps/node-convert/strategies/SwRichtextStrategy"; import { normalizeNodeLayout } from "@/mastra/workflows/figma-to-bi/steps/normalize-layout-step"; import { resolveNodeStyles } from "@/mastra/workflows/figma-to-bi/steps/resolve-styles-step"; -import ftRichtextData from "./ftRichtext.json"; +import swRichtextData from "./swRichtext.json"; interface MockData { globalVars: { styles: Record }; @@ -24,12 +24,12 @@ export function makeMockDefaultConfig() { moduleId: 113, zIndex: 0, openFilter: false, - ...ftRichtextData.config + ...swRichtextData.config }; } export async function runConvert(mockData: MockData) { - const strategy = new FtRichtextStrategy(); + const strategy = new SwRichtextStrategy(); const normalizedNode = buildNormalizedNode(mockData); return strategy.convert({ fileKey: "test-file-key", diff --git a/servers/server/tests/node-convert/richtext/ftRichtext.json b/servers/server/tests/node-convert/richtext/swRichtext.json similarity index 100% rename from servers/server/tests/node-convert/richtext/ftRichtext.json rename to servers/server/tests/node-convert/richtext/swRichtext.json diff --git a/servers/server/tests/node-convert/richtext/text1/FtRichtextStrategy.test.ts b/servers/server/tests/node-convert/richtext/text1/SwRichtextStrategy.test.ts similarity index 85% rename from servers/server/tests/node-convert/richtext/text1/FtRichtextStrategy.test.ts rename to servers/server/tests/node-convert/richtext/text1/SwRichtextStrategy.test.ts index 52240471..a1c47fc8 100644 --- a/servers/server/tests/node-convert/richtext/text1/FtRichtextStrategy.test.ts +++ b/servers/server/tests/node-convert/richtext/text1/SwRichtextStrategy.test.ts @@ -1,7 +1,7 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; import { getComponentDefaultConfigByModuleId } from "@/mastra/tools/utils"; -import type { FtRichtext } from "@/mastra/workflows/figma-to-bi/steps/node-convert/strategies/FtRichtextStrategy"; +import type { SwRichtext } from "@/mastra/workflows/figma-to-bi/steps/node-convert/strategies/SwRichtextStrategy"; import { makeMockDefaultConfig, runConvert } from "../helpers"; import mockData from "./data.mock.json"; @@ -32,7 +32,7 @@ vi.mock("@/mastra/storage/prisma", () => ({ // ── 测试套件 ──────────────────────────────────────────────────────── -describe("FtRichtextStrategy", () => { +describe("SwRichtextStrategy", () => { beforeEach(() => { vi.mocked(getComponentDefaultConfigByModuleId).mockResolvedValue( makeMockDefaultConfig() as unknown as Awaited> @@ -48,21 +48,21 @@ describe("FtRichtextStrategy", () => { it("convert,节点 name 为「智算中心、赋能中心、创新中心」,component.name 为该名称", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; expect(component.name).toBe("智算中心、赋能中心、创新中心"); }); it("convert,layout 高度从 layout_c06300 提取,component.height 为 36", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; expect(component.component.height).toBe(36); }); it("convert,layout 绝对坐标 x=0 y=0,left 为 0 top 为 0", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; expect(component.left).toBe(0); expect(component.top).toBe(0); @@ -70,7 +70,7 @@ describe("FtRichtextStrategy", () => { it("convert,option.content 应该是包裹在

    标签中的 HTML", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; const content = component.option.content; expect(content.startsWith(" { it("convert,option.content 应该包含完整原始文本", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; const content = component.option.content; expect(content).toContain("智算中心、"); @@ -89,7 +89,7 @@ describe("FtRichtextStrategy", () => { it("convert,base style 来自 style_b719c2,

    包含 font-family/font-size/font-weight", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; const content = component.option.content; const pStyle = /

    { it("convert,

    应包含来自 fill_9e843e 的有效 color(不含 NaN)", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; const content = component.option.content; const pStyle = /

    { it("convert,characterStyleOverrides 5-9 字符应该被 包裹", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; const content = component.option.content; // 5-9 字符为「赋能中心」 @@ -119,7 +119,7 @@ describe("FtRichtextStrategy", () => { it("convert, 应包含 override 的 font-size: 32px", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; const content = component.option.content; const spanMatch = /赋能中心<\/span>/.exec(content); @@ -129,7 +129,7 @@ describe("FtRichtextStrategy", () => { it("convert, 应包含 override 的蓝色 color", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; const content = component.option.content; const spanMatch = /赋能中心<\/span>/.exec(content); @@ -140,21 +140,21 @@ describe("FtRichtextStrategy", () => { it("convert,option.textAnimationType 为空字符串", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; expect(component.option.textAnimationType).toBe(""); }); it("convert,option.textAnimationTiming 为 50", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; expect(component.option.textAnimationTiming).toBe(50); }); it("convert,option.textAnimationDelay 为 0", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; expect(component.option.textAnimationDelay).toBe(0); }); diff --git a/servers/server/tests/node-convert/richtext/text2/FtRichtextStrategy.test.ts b/servers/server/tests/node-convert/richtext/text2/SwRichtextStrategy.test.ts similarity index 85% rename from servers/server/tests/node-convert/richtext/text2/FtRichtextStrategy.test.ts rename to servers/server/tests/node-convert/richtext/text2/SwRichtextStrategy.test.ts index cfeb3c17..e852798b 100644 --- a/servers/server/tests/node-convert/richtext/text2/FtRichtextStrategy.test.ts +++ b/servers/server/tests/node-convert/richtext/text2/SwRichtextStrategy.test.ts @@ -1,7 +1,7 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; import { getComponentDefaultConfigByModuleId } from "@/mastra/tools/utils"; -import type { FtRichtext } from "@/mastra/workflows/figma-to-bi/steps/node-convert/strategies/FtRichtextStrategy"; +import type { SwRichtext } from "@/mastra/workflows/figma-to-bi/steps/node-convert/strategies/SwRichtextStrategy"; import { makeMockDefaultConfig, runConvert } from "../helpers"; import mockData from "./data.mock.json"; @@ -32,7 +32,7 @@ vi.mock("@/mastra/storage/prisma", () => ({ // ── 测试套件 ──────────────────────────────────────────────────────── -describe("FtRichtextStrategy", () => { +describe("SwRichtextStrategy", () => { beforeEach(() => { vi.mocked(getComponentDefaultConfigByModuleId).mockResolvedValue( makeMockDefaultConfig() as unknown as Awaited> @@ -48,21 +48,21 @@ describe("FtRichtextStrategy", () => { it("convert,节点 name 为「政策、人才、资金、空间、场景」,component.name 为该名称", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; expect(component.name).toBe("政策、人才、资金、空间、场景"); }); it("convert,layout 高度从 layout_fae6b0 提取,component.height 为 30", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; expect(component.component.height).toBe(30); }); it("convert,layout 绝对坐标 x=0 y=0,left 为 0 top 为 0", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; expect(component.left).toBe(0); expect(component.top).toBe(0); @@ -70,7 +70,7 @@ describe("FtRichtextStrategy", () => { it("convert,option.content 应该是包裹在

    标签中的 HTML", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; const content = component.option.content; expect(content.startsWith(" { it("convert,option.content 应该包含完整原始文本", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; const content = component.option.content; expect(content).toContain("政策、人才、资金、空间、场景"); @@ -87,7 +87,7 @@ describe("FtRichtextStrategy", () => { it("convert,base style 来自 style_d92943,

    包含 font-family/font-size/font-weight", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; const content = component.option.content; const pStyle = /

    { it("convert,

    应包含来自 fill_b9cecd 的有效 color(不含 NaN)", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; const content = component.option.content; const pStyle = /

    { it("convert,百分比 letterSpacing 转换为 px(11.538...% * 26px ≈ 3px)", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; const content = component.option.content; const pStyle = /

    { it("convert,无 characterStyleOverrides,content 中不应出现 ", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; const content = component.option.content; expect(content).not.toMatch(/ { it("convert,option.textAnimationType 为空字符串", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; expect(component.option.textAnimationType).toBe(""); }); it("convert,option.textAnimationTiming 为 50", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; expect(component.option.textAnimationTiming).toBe(50); }); it("convert,option.textAnimationDelay 为 0", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; expect(component.option.textAnimationDelay).toBe(0); }); diff --git a/servers/server/tests/node-convert/richtext/text3/FtRichtextStrategy.test.ts b/servers/server/tests/node-convert/richtext/text3/SwRichtextStrategy.test.ts similarity index 85% rename from servers/server/tests/node-convert/richtext/text3/FtRichtextStrategy.test.ts rename to servers/server/tests/node-convert/richtext/text3/SwRichtextStrategy.test.ts index 91f98742..f6eb26ce 100644 --- a/servers/server/tests/node-convert/richtext/text3/FtRichtextStrategy.test.ts +++ b/servers/server/tests/node-convert/richtext/text3/SwRichtextStrategy.test.ts @@ -1,7 +1,7 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; import { getComponentDefaultConfigByModuleId } from "@/mastra/tools/utils"; -import type { FtRichtext } from "@/mastra/workflows/figma-to-bi/steps/node-convert/strategies/FtRichtextStrategy"; +import type { SwRichtext } from "@/mastra/workflows/figma-to-bi/steps/node-convert/strategies/SwRichtextStrategy"; import { makeMockDefaultConfig, runConvert } from "../helpers"; import mockData from "./data.mock.json"; @@ -32,7 +32,7 @@ vi.mock("@/mastra/storage/prisma", () => ({ // ── 测试套件 ──────────────────────────────────────────────────────── -describe("FtRichtextStrategy", () => { +describe("SwRichtextStrategy", () => { beforeEach(() => { vi.mocked(getComponentDefaultConfigByModuleId).mockResolvedValue( makeMockDefaultConfig() as unknown as Awaited> @@ -48,21 +48,21 @@ describe("FtRichtextStrategy", () => { it("convert,节点 name 为「欢迎来到思明区数字内容创作公共服务平台」,component.name 为该名称", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; expect(component.name).toBe("欢迎来到思明区数字内容创作公共服务平台"); }); it("convert,layout 高度从 layout_184df1 提取,component.height 为 164", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; expect(component.component.height).toBe(164); }); it("convert,layout 绝对坐标 x=0 y=0,left 为 0 top 为 0", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; expect(component.left).toBe(0); expect(component.top).toBe(0); @@ -70,7 +70,7 @@ describe("FtRichtextStrategy", () => { it("convert,option.content 应该是包裹在

    标签中的 HTML", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; const content = component.option.content; expect(content.startsWith(" { it("convert,option.content 应该包含完整原始文本", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; const content = component.option.content; expect(content).toContain("欢迎来到思明区数字内容创作公共服务平台"); @@ -87,7 +87,7 @@ describe("FtRichtextStrategy", () => { it("convert,base style 来自 style_072978,

    包含 font-family/font-size/font-weight", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; const content = component.option.content; const pStyle = /

    { it("convert,lineHeight 0.6097em < 1em 时应跳过,避免 CSS 行框压扁裁切字形", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; const content = component.option.content; const pStyle = /

    { it("convert,百分比 letterSpacing 转换为 px(6.0975...% * 164px ≈ 10px)", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; const content = component.option.content; const pStyle = /

    { it("convert,textAlignHorizontal=CENTER 应映射为 text-align: center", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; const content = component.option.content; const pStyle = /

    { it("convert,渐变填充应映射为 background + -webkit-background-clip: text", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; const content = component.option.content; const pStyle = /

    { it("convert,渐变填充场景下不应输出 color 属性", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; const content = component.option.content; const pStyle = /

    { it("convert,

    style 不应包含 NaN", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; const content = component.option.content; const pStyle = /

    { it("convert,无 characterStyleOverrides,content 中不应出现 ", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; const content = component.option.content; expect(content).not.toMatch(/ { it("convert,option.textAnimationType 为空字符串", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; expect(component.option.textAnimationType).toBe(""); }); it("convert,option.textAnimationTiming 为 50", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; expect(component.option.textAnimationTiming).toBe(50); }); it("convert,option.textAnimationDelay 为 0", async () => { const result = await runConvert(mockData); - const component = result.component as FtRichtext; + const component = result.component as SwRichtext; expect(component.option.textAnimationDelay).toBe(0); });