@moneko/core 3.0.0-beta.50 → 3.0.0-beta.52

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.
@@ -1,10 +1,9 @@
1
- import{readdir as e,stat as t,access as n,constants as r,existsSync as i,mkdirSync as l,readFile as s,readFileSync as o,rmdirSync as u,statSync as c,watch as p,writeFile as a,unlink as f}from"fs";import{join as g}from"path";import d from"typescript";import{APPTYPE as m,PROGRAMPATH as y,frameworkCacheDir as $}from"./process-env.js";let{ScriptKind:x,ScriptTarget:h,createSourceFile:b,forEachChild:F,getLeadingCommentRanges:T,isInterfaceDeclaration:C,isQuestionToken:S,isPropertySignature:j}=d;function D(e){let t=T(e.getSourceFile().text,e.pos);if(t){let n=e.getSourceFile().text.substring(t[0].pos,t[0].end);return n.replace(/\/\*\*?\s*|\s*\*\//g,"").trim()}return null}function k(e){if(!e)return null;let t=e.match(/@since\s+([^\n]+)/);return t?t[1].trim():null}function B(e){return e?.replace(/\*/g,"\\*").replace(/\|/g,"\\|")||"-"}let E=["#9C27B0","#673AB7","#3F51B5","#2196F3","#00BCD4","#009688","#4CAF50","#CDDC39","#FF9800","#795548"];function v(e){return e?e.replace(/\* @default\s+([^(|\n)]+)/,"").replace(/\* @since\s+([^\n]+)/,"").replace(/\* @see\s+{@link\s+(.+?)(?:\|(.+?))?}/,"").replace(/(\n\s+)+/g,"<br />").replace(/(<br \/>)$/g,""):null}function K(){}let O=g($,"./apis"),q={};function w(e,t){i($)||l($),i(O)||l(O);let n=e.split("/").slice(-2),r=g(O,n[0]),u=n[1].replace(/\.tsx?/,".md");i(r)||l(r),q[n[0]]||(q[n[0]]=[]);let c=q[n[0]].indexOf(u),p=g(r,u);if("deleted"===t)f(p,K),-1!==c&&q[n[0]].splice(c,1);else{let t=function(e){let t=o(e,"utf-8"),n=b(e,t,h.Latest,!0,x.TS),r="";return F(n,e=>{C(e)?r+=function(e){let t=D(e),n=k(t),r=v(t),i=e.name.text,l=r?`<n-typography type="secondary">${i}</n-typography>`:i,s=(function(e){let t=[];if(e.heritageClauses){for(let n of e.heritageClauses)if(n.token===d.SyntaxKind.ExtendsKeyword)for(let e of n.types)t.push(e.getText())}return t})(e)?.map((e,t)=>`<n-tag color="${E[t]}">${e}</n-tag>`),o=[r,l,n&&`<sup><n-typography type="success">${n}</n-typography></sup>`,s.length>0&&`<sub>\`extends\`</sub> ${s.join(" ")}`].filter(Boolean).join(" "),u=`## ${o}
2
-
1
+ import{existsSync as e,mkdirSync as t,readFile as n,readFileSync as r,rmdirSync as i,statSync as l,writeFile as s,unlink as o}from"fs";import{join as u}from"path";import{watch as c}from"chokidar";import p from"typescript";import{APPTYPE as a,PROGRAMPATH as f,frameworkCacheDir as g}from"./process-env.js";let{ScriptKind:m,ScriptTarget:d,createSourceFile:y,forEachChild:$,getLeadingCommentRanges:x,isInterfaceDeclaration:h,isQuestionToken:b,isPropertySignature:T}=p;function k(e){let t=x(e.getSourceFile().text,e.pos);if(t){let n=e.getSourceFile().text.substring(t[0].pos,t[0].end);return n.replace(/\/\*\*?\s*|\s*\*\//g,"").trim()}return null}function C(e){if(!e)return null;let t=e.match(/@since\s+([^\n]+)/);return t?t[1].trim():null}function F(e,t){if(!e)return t;if(!t)return null;let n=t;return e.replace(/@see\s+{@link\s+([^|}]+)(?:\|([^}]+))?}/g,(e,t,r)=>{let i=r||n;return n=n.replace(new RegExp(i),`[${i}](${t})`),""}),n}function S(e){return e?.replace(/\*/g,"\\*").replace(/\|/g,"\\|")||"-"}let j=["#9C27B0","#673AB7","#3F51B5","#2196F3","#00BCD4","#009688","#4CAF50","#CDDC39","#FF9800","#795548"];function B(e){return e?e.replace(/\* @default\s+([^(|\n)]+)/,"").replace(/\* @since\s+([^\n]+)/,"").replace(/\* @see\s+{@link\s+(.+?)(?:\|(.+?))?}/g,"").replace(/(\n\s+)+/g,"<br />").replace(/(<br \/>)$/g,""):null}function D(){}let E=u(g,"./apis"),I={};function q(i,l){e(g)||t(g),e(E)||t(E);let c=i.split("/").slice(-2),a=u(E,c[0]),f=c[1].replace(/\.tsx?/,".md");e(a)||t(a),I[c[0]]||(I[c[0]]=[]);let x=I[c[0]].indexOf(f),q=u(a,f);if("deleted"===l)o(q,D),-1!==x&&I[c[0]].splice(x,1);else{let e=function(e){let t=r(e,"utf-8"),n=y(e,t,d.Latest,!0,m.TS),i="";return $(n,e=>{h(e)?i+=function(e){let t=k(e),n=C(t),r=B(t),i=e.name.text,l=r?`<n-typography type="secondary">${i}</n-typography>`:i,s=(function(e){let t=[];if(e.heritageClauses){for(let n of e.heritageClauses)if(n.token===p.SyntaxKind.ExtendsKeyword)for(let e of n.types)t.push(e.getText())}return t})(e)?.map((e,n)=>`<n-tag color="${j[n]}" css=".tag{gap:0px;}">${F(t,e)}</n-tag>`),o=[r,l,n&&`<sup><n-typography type="success">${n}</n-typography></sup>`,s.length>0&&`<sub>\`extends\`</sub> ${s.join(" ")}`].filter(Boolean).join(" "),u=`## ${o}
3
2
  | 属性 | 必要 | 说明 | 类型 | 默认值 | 版本 |
4
3
  | :- | :-: | :- | :- | :- | :- |
5
- `;for(let t of e.members)if(j(t)){let e=B(t.name.getText()),n=t.questionToken&&S(t.questionToken),r=D(t),i=B(function(e){if(!e)return null;let t=e.match(/@default\s+([^\n]+)/);return t?t[1].trim():null}(r)),l=B(k(r)),s=function(e,t){if(!e||!t)return null;let n=e.match(/@see\s+{@link\s+([^|}]+)(?:\|([^}]+))?}/);if(n){let e=n[2]||t;return t.replace(new RegExp(e),`[${e}](${n[1]})`)}return t}(r,B(t.type?.getText())),o=B(v(r)),c=`<n-typography type="${n?"error":"success"}">${n?"✘":"✔"}</n-typography>`;u+=`| ${e} | ${c} | ${o} | ${s} | ${i} | ${l} |
6
- `}return u+"\n"}(e):d.isEnumDeclaration(e)&&(r+=function(e){let t=e.name.text,n=`## ${t}
4
+ `;for(let t of e.members)if(T(t)){let e=S(t.name.getText()),n=t.questionToken&&b(t.questionToken),r=k(t),i=S(function(e){if(!e)return null;let t=e.match(/@default\s+([^\n]+)/);return t?t[1].trim():null}(r)),l=S(C(r)),s=F(r,S(t.type?.getText())),o=S(B(r)),c=`<n-typography type="${n?"error":"success"}">${n?"✘":"✔"}</n-typography>`;u+=`| ${e} | ${c} | ${o} | ${s} | ${i} | ${l} |
5
+ `}return u+"\n"}(e):p.isEnumDeclaration(e)&&(i+=function(e){let t=e.name.text,n=`## ${t}
7
6
  | 属性 | 说明 | 值 | 版本 |
8
7
  | -- | -- | -- | -- |
9
- `;for(let t of e.members){let e=B(t.name.getText()),r=D(t),i=B(function(e){let t=e.initializer;return t&&d.isStringLiteral(t)?` '${t.text}'`:null}(t)),l=B(k(r)),s=B(r?.replace(/\* @since\s+([^\n]+)/,"").replace(/(\n\s+)+/g,"<br />").replace(/(<br \/>)$/g,""));n+=`| ${e} | ${s} | ${i} | ${l} |
10
- `}return n+"\n"}(e))}),r}(e);t?(a(p,t,"utf-8",K),-1===c&&q[n[0]].push(u)):(f(p,K),-1!==c&&q[n[0]].splice(c,1))}s(g(O,"index.js"),{encoding:"utf-8"},(e,t)=>{let n=`export default ${JSON.stringify(q)};`;if(e){a(g(O,"index.js"),n,"utf-8",K);return}t!==n&&a(g(O,"index.js"),n,"utf-8",K)})}if("library"===m){let i=g(y,"./components");!function n(r,i=1){e(r,(e,l)=>{e||l.forEach(e=>{let l=g(r,e);t(l,(t,r)=>{!t&&(i?r.isDirectory()&&n(l,i-1):r.isFile()&&(e.endsWith(".ts")||e.endsWith(".tsx"))&&w(l,"added"))})})})}(i),function(e){p(e,{recursive:!0},(t,i)=>{let l=g(e,i||"");c(l).isDirectory()||("change"===t?w(l,t):"rename"===t&&n(l,r.F_OK,e=>{e?w(l,"deleted"):w(l,"added")}))})}(i),process.on("SIGINT",function(){try{u(O,{recursive:!0})}catch(e){}process.exit()})}
8
+ `;for(let t of e.members){let e=S(t.name.getText()),r=k(t),i=S(function(e){let t=e.initializer;return t&&p.isStringLiteral(t)?` '${t.text}'`:null}(t)),l=S(C(r)),s=S(r?.replace(/\* @since\s+([^\n]+)/,"").replace(/(\n\s+)+/g,"<br />").replace(/(<br \/>)$/g,""));n+=`| ${e} | ${s} | ${i} | ${l} |
9
+ `}return n+"\n"}(e))}),i}(i);e?(s(q,e,"utf-8",D),-1===x&&I[c[0]].push(f)):(o(q,D),-1!==x&&I[c[0]].splice(x,1))}n(u(E,"index.js"),{encoding:"utf-8"},(e,t)=>{let n=`export default ${JSON.stringify(I)};`;if(e){s(u(E,"index.js"),n,"utf-8",D);return}t!==n&&s(u(E,"index.js"),n,"utf-8",D)})}if("library"===a){let e=u(f,"./components");!function(e){let t=c(e,{ignored:/(^|[\\/\\])\../,persistent:!0,ignoreInitial:!1});t.on("all",(e,t)=>{t&&l(t).isDirectory()||("change"===e?q(t,e):"add"===e?q(t,"added"):"unlink"===e&&q(t,"deleted"))})}(e),process.on("SIGINT",function(){try{i(E,{recursive:!0})}catch(e){}process.exit()})}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "3.0.0-beta.50",
3
+ "version": "3.0.0-beta.52",
4
4
  "description": "core",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",