@moneko/core 3.0.0-beta.76 → 3.0.0-beta.80
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/lib/generate-api.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
let e;import{existsSync as t,mkdirSync as n,readFile as r,readFileSync as l,statSync as o,unlink as i,writeFile as c}from"fs";import{dirname as
|
|
1
|
+
let e;import{existsSync as t,mkdirSync as n,readFile as r,readFileSync as l,statSync as o,unlink as i,writeFile as c}from"fs";import{dirname as u,join as s}from"path";import{watch as a}from"chokidar";import f from"typescript";import{CONFIG as p}from"./common.js";import{APPTYPE as m,apiCacheDir as g,frameworkCacheDir as $}from"./process-env.js";import{resolveProgramPath as d}from"./utils.js";import{alias as h}from"./webpack.common.js";let{ScriptKind:b,ScriptTarget:x,SyntaxKind:y,createSourceFile:j,forEachChild:k,getLeadingCommentRanges:T,isInterfaceDeclaration:E,isQuestionToken:S,isPropertySignature:w,isFunctionTypeNode:B,isUnionTypeNode:N,isMethodSignature:v}=f,F={};function O(e){let t=T(e.getSourceFile().text,e.pos);if(t){let n=e.getSourceFile().text.substring(t[0].pos,t[0].end),r=n.match(/\/\*\*([\s\S]*?)\*\//);if(r){let e=r[1].replace(/^\s*\* ?/gm,"").replace(/\s+$/,"").trim();return e}}return null}function _(e){if(!e)return null;let t=e.match(/@since\s+([^\n]+)/);return t?t[1].trim():null}function z(e){if(!e)return null;let t=e.match(/@author (\w+)\s*(?:<([^>]+)>)?/);if(t?.length){let e=t[1].trim(),n=t[2]?.trim(),r=/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(n);return n?r&&(n=`mailto:${n}`):n=`https://github.com/${e}`,`[${e}${r?" 📧":" ⎋"}](${n})`}return null}function I(e){if(!e)return null;let t=e.match(/@ignore\s+([^\n]+)/);return t?t[1].trim():null}let K=/(?<!['"])(unknown|any|void|bigint|object|undefined|null|boolean|number|string|symbol)(?!['"])/g;function q(e,t){if(!e)return null;let n=e.replace(/\b([A-Z][a-zA-Z0-9]*)\b/g,e=>{if(F[e]){let n=`/${[p.routeBaseName,F[e]].join("/").split("/").filter(Boolean).join("/")}`;return t?`[\\color{#009688}{${e}}](${n})`:`[${e}](${n})`}return t?`\\color{#009688}{${e}}`:e});return t&&(n=n.replace(K,e=>`\\color{#009688}{${e}}`)),n}function A(e){return(function(e){let t;if(!e)return null;let n=[];for(;t=/\\color{([^|}]*)\|?([^|}]*)\|?([^|}]*)\|?([^}]*)}{([^}]*)}/g.exec(e);)n.push(t[0]);return e.replace(/(\{|\}|\[|\]|\(|\)|=>|keyof|typeof|true|false)/g,e=>n.some(t=>t.includes(e))?e:`\\color{#569cd6}{${e}}`)})(e)?.replace(/^\s*\|\s*|\s*\|\s*$/gm,"").replace(/\n/g,"<br/>").replace(/\*/g,"\\*").replace(/\|/g,"\\|").replace(/(['"])((?:(?!\1).)*)\1/g,"\\color{#ce9178}{$1$2$1}")}function C(e){return e?e.replace(/^@[a-z].+/gm,"").replace(/(\n\s+)+/g,"<br />").replace(/\n/g,"<br />").replace(/(<br \/>)$/g,""):null}function L(){}let W={},Z={};function D(o,a){t($)||n($),t(g)||n(g);let p=o.replace(RegExp(`^${h["@pkg"]}`),""),m=u(p).replace(/^\//,""),d=s(g,m),T=p.split("/").pop()?.replace(/\.tsx?/,".md");if(!T)return;W[m]||(W[m]=[]);let K=W[m].indexOf(T),D=s(d,T);if("deleted"===a)delete Z[D],i(D,L),-1!==K&&W[m].splice(K,1);else{let e=function(e){let t=l(e,"utf-8"),n=j(e,t,x.Latest,!0,b.TS),r="";return k(n,e=>{E(e)?r+=function(e){let t=e.name.text;Object.assign(F,{[e.name.text]:u(e.getSourceFile().fileName).replace(h["@pkg"],"")});let n=O(e),r=_(n),l=C(n),o=I(n)?.split("|")||[],i=o.includes("comment"),c=o.includes("initial"),s=o.includes("optional"),a=o.includes("version"),p=o.includes("author"),m=l?`\\color{|4||0.45}{${t}}`:t,g=(function(e){let t=[];if(e.heritageClauses){for(let n of e.heritageClauses)if(n.token===f.SyntaxKind.ExtendsKeyword)for(let e of n.types)t.push(e.getText())}return t})(e)?.map(e=>`<n-tag color="#4c81db" css=".tag{gap:0px;}">${q(A(e))}</n-tag>`),$=[l,m,r&&`\\color{#52c11b|1||0.9}{${r}}`,g.length>0&&`<sub>\`extends\`</sub> ${g.join(" ")}`].filter(Boolean).join(" "),d=`## ${$}`,b=e.members.filter(e=>w(e)&&e.type?.kind!==y.NeverKeyword||v(e)),x=[];if(b.length){b.forEach(e=>{let t=q(A(v(e)?`(${e.parameters.map(e=>`${e.name.getText()}: ${e.type?.getText()||"any"}`).join(", ")}): ${e.type?.getText()||"any"}`:e.type?.getText()||"any"),!0),r=O(e),l=A(e.name.getText());!l||l.startsWith("\\color")||(v(e)||function(e){if(e.type){if(!N(e.type))return B(e.type);for(let t of e.type.types)if(B(t))return!0}return!1}(e)||t?.includes("=>")?l=`\\color{#f9a913}{${l}}`:/^("|')(.+)("|')$/.test(l)||(l=`\\color{#4c81db}{${l}}`));let o=e.questionToken&&S(e.questionToken);x.push([l,!s&&`\\color{${o?"#f9a913":"#52c11b"}\\|\\|\\|0.9}{${o?"✘":"✔"}}`,!i&&A(C(r)),t,!c&&A(function(e){if(!e)return null;let t=e.match(/@default\s+([^\n]+)/);return t?t[1].trim():null}(r)),!a&&A(_(r)),!p&&(z(r)||z(n))])});let e=!1,t=!1,r=!1,l=!1;x.forEach(n=>{!i&&n[2]&&(l=!0),!c&&n[4]&&(r=!0),!a&&n[5]&&(t=!0),!p&&n[6]&&(e=!0)}),d+="\n";let o=["属性",!s&&"必要",l&&"说明","类型",r&&"默认值",t&&"版本",e&&"作者"].filter(Boolean).join("|");d+=`|${o}|`;let u=[":-",!s&&":-",l&&":-",":-",r&&":-",t&&":-",e&&":-"].filter(Boolean);d+="\n";let f=u.join("|");d+=`|${f}|`,x.forEach(n=>{d+="\n";let o=[n[0]||"-",!s&&(n[1]||"-"),l&&(n[2]||"-"),n[3]||"-",r&&(n[4]||"-"),t&&(n[5]||"-"),e&&(n[6]||"-")].filter(Boolean).join("|");d+=`|${o}|`}),d+="\n"}return d+="\n"}(e):f.isEnumDeclaration(e)&&(r+=function(e){let t=e.name.text;Object.assign(F,{[e.name.text]:u(e.getSourceFile().fileName).replace(h["@pkg"],"")});let n=O(e),r=I(n)?.split("|")||[],l=r.includes("comment"),o=r.includes("version"),i=r.includes("author"),c=`## ${t}`;if(e.members.length){let t=[];e.members.forEach(e=>{let r=A(e.name.getText()),c=O(e),u=A(function(e){let t=e.initializer;return t&&f.isStringLiteral(t)?` '${t.text}'`:null}(e)),s=A(_(c)),a=A(C(c));!r||r.startsWith("\\color")||/^("|')(.+)("|')$/.test(r)||(r=`\\color{#4c81db}{${r}}`),t.push([r,!l&&a,u,!o&&s,!i&&(z(c)||z(n))])});let r=!1,u=!1,s=!1;t.forEach(e=>{!l&&e[1]&&(s=!0),!o&&e[3]&&(u=!0),!i&&e[4]&&(r=!0)}),c+="\n";let a=["属性",s&&"说明","值",u&&"版本",r&&"作者"].filter(Boolean).join("|");c+=`|${a}|`;let p=[":-",s&&":-",":-",u&&":-",r&&":-"].filter(Boolean);c+="\n";let m=p.join("|");c+=`|${m}|`,t.forEach(e=>{c+="\n";let t=[e[0]||"-",s&&(e[1]||"-"),e[2]||"-",u&&(e[3]||"-"),r&&(e[4]||"-")].filter(Boolean).join("|");c+=`|${t}|`})}return c+="\n\n"}(e))}),r}(o);if(e){let l=Z[D];l?l!==e&&(t(d)||n(d),c(D,e,"utf-8",L)):r(D,{encoding:"utf-8"},(r,l)=>{(r||l!==e)&&(Z[D]=l,t(d)||n(d),c(D,e,"utf-8",L))}),-1===K&&W[m].push(T)}else delete Z[D],i(D,L),-1!==K&&W[m].splice(K,1)}let G=`export default ${JSON.stringify(W)};`;e!==G&&(e=G,c(s(g,"index.js"),G,"utf-8",L))}"library"===m&&function(){let e=[],t=a(d("components"),{ignored:[/(^|[\\/\\])\../,/(^|[\\/\\])__tests__([\\/\\]|$)/],persistent:!0,ignoreInitial:!1});function n(e){return/\.tsx?$/.test(e)&&o(e).isFile()}t.on("add",t=>{n(t)&&(D(t,"added"),e.push(t))}),t.on("change",e=>{n(e)&&D(e,"change")}),t.on("unlink",t=>{n(t)&&(D(t,"deleted"),e.splice(e.indexOf(t),1))}),t.on("ready",()=>{e.forEach(e=>{D(e,"change")})}),process.on("SIGINT",function(){t.close()})}();
|
package/lib/swcrc.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{merge as e}from"webpack-merge";import{CONFIG as o}from"./common.js";import
|
|
1
|
+
import{merge as e}from"webpack-merge";import{CONFIG as o}from"./common.js";import{isReact as r,isSolid as s,jsxImportSource as t}from"./process-env.js";let n={env:{targets:["last 2 version","> 0.5%","ie 11","not dead"],mode:"entry",coreJs:"3"}};export const swcMinifyOption={compress:{top_retain:[],keep_infinity:!0,global_defs:{"@alert":"console.log"},pure_funcs:["console.log","console.warn","console.error","console.info"],toplevel:!1,drop_console:!0,drop_debugger:!0,module:!1,ecma:2015,ie8:!1,keep_classnames:void 0,keep_fnames:!1},mangle:!0};export default((a=!1)=>{let c={module:{type:"es6",ignoreDynamic:!0,strict:!0,strictMode:!0,lazy:!0,noInterop:!0},jsc:{parser:{syntax:"typescript",decorators:!0,dynamicImport:!0,tsx:!0},loose:!0,target:"es2022",externalHelpers:!0,transform:{legacyDecorator:!0,decoratorMetadata:!0,react:{runtime:"automatic",throwIfNamespace:!0,useBuiltins:!0,refresh:r&&a,development:a,importSource:t},optimizer:{simplify:!1}},experimental:{plugins:[["swc-plugin-another-transform-imports",function(e){for(let o=0,r=Object.keys(e),s=r.length;o<s;o++)e[r[o]].transform=`${r[o]}/${e[r[o]].transform}`,e[r[o]].style&&(e[r[o]].style=`${r[o]}/${e[r[o]].style}`);return e}(o.importOnDemand||{})],s&&["@moneko/jsx-dom-expressions",o.jsxDomExpressions||{}]].filter(Boolean)}},sourceMaps:!0,parseMap:!0},i=Object.assign(c,!a&&n);return o.swcrc&&(i=e(i,"function"==typeof o.swcrc?o.swcrc(a):o.swcrc)),i});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Compiler } from 'webpack';
|
|
2
|
+
interface VirtualModulePluginOption {
|
|
3
|
+
name: string;
|
|
4
|
+
contents: Record<string, any>;
|
|
5
|
+
}
|
|
6
|
+
declare class VirtualModulePlugin {
|
|
7
|
+
private options;
|
|
8
|
+
constructor(options: VirtualModulePluginOption);
|
|
9
|
+
apply(compiler: Compiler): void;
|
|
10
|
+
}
|
|
11
|
+
export default VirtualModulePlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import t from"webpack-virtual-modules";import{resolveNodeModulesPath as o}from"./utils.js";export default class{constructor(t){this.options=t}apply(i){let s=o(`${this.options.name}.js`),r=new t({[s]:JSON.stringify(this.options.contents)});r.apply(i),i.hooks.compilation.tap("VirtualModulePlugin",function(t){try{r.writeModule(s,JSON.stringify({a:2}))}catch(o){t.errors.push(o)}})}};
|
package/lib/webpack.common.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"fs";import t from"add-asset-html-webpack-plugin";import s from"html-webpack-plugin";import n from"webpack";import o from"webpackbar";import"./cleanup.js";import{CONFIG as l,ENTRYPATH as i,PUBLICPATH as a}from"./common.js";import r from"./done.js";import p from"./envFlags.js";import"./generate-api.js";import m from"./html-add-entry-attr.js";import c from"./html-plugin-option.js";import{moduleFederation as u}from"./module-federation.js";import d from"./module.config.js";import{APPTYPE as f,DEV as g,FRAMEWORK as j,PACKAGENAME as h,PROGRAMPATH as b,frameworkCacheDir as y,hasEslintConfig as w,hasStylelintConfig as x}from"./process-env.js";import"./routes.js";import{seo as k}from"./seo.js";import{resolveNodeModulesPath as v,resolveProgramPath as O}from"./utils.js";let
|
|
1
|
+
import e from"fs";import t from"add-asset-html-webpack-plugin";import s from"html-webpack-plugin";import n from"webpack";import o from"webpackbar";import"./cleanup.js";import{CONFIG as l,ENTRYPATH as i,PUBLICPATH as a}from"./common.js";import r from"./done.js";import p from"./envFlags.js";import"./generate-api.js";import m from"./html-add-entry-attr.js";import c from"./html-plugin-option.js";import{moduleFederation as u}from"./module-federation.js";import d from"./module.config.js";import{APPTYPE as f,DEV as g,FRAMEWORK as j,PACKAGENAME as h,PROGRAMPATH as b,frameworkCacheDir as y,hasEslintConfig as w,hasStylelintConfig as x}from"./process-env.js";import"./routes.js";import{seo as k}from"./seo.js";import{resolveNodeModulesPath as v,resolveProgramPath as O}from"./utils.js";import C from"./virtual-module-plugin.js";let P=[".eslintrc.js",".eslintrc.json",".eslintrc.yaml",".eslintrc.json"],$=[".stylelintrc",".stylelintrc.json",".stylelintrc.yaml",".stylelintrc.yml",".stylelintrc.js","stylelint.config.js","stylelint.config.cjs"],A=e.readdirSync(b),B=!1,S=!1;for(let e=0,t=A.length;e<t;e++)$.includes(A[e])&&(S=!0),P.includes(A[e])&&(B=!0);B||(B=w),S||(S=x);let T=S?(await import("stylelint-webpack-plugin")).default:null,M=B?(await import("eslint-webpack-plugin")).default:null;export const alias={"@":O("src"),"@framework-cache-dir":y};Object.assign(alias,l.alias),"library"===f&&Object.assign(alias,{"@":O("site"),"@pkg":O("components"),[h]:O("components")});let D=l.assetHtml.map(e=>({publicPath:"",...e}));export const outputConfig={path:O("library"===f?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:"js/[name].chunk.js",assetModuleFilename:"assets/[name][hash][ext][query]",library:{name:h,type:"window"},globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${h}`,pathinfo:g,clean:!0,publicPath:a};let F=v(`@moneko/${j}/lib/packages/${i[f]}/index.js`);"single-component"===f&&(Object.assign(alias,{[h]:O("umd")}),F=O(g?"example/index.ts":"src/index.ts"),outputConfig.path=O(g?"dist":"umd"),outputConfig.filename="index.js",outputConfig.globalObject="this",outputConfig.library={export:"default",name:h,type:"umd",umdNamedDefine:!0});let K={main:F};l.entry&&("string"==typeof l.entry?K=l.entry:Object.keys(l.entry)&&Object.assign(K,l.entry)),l.output&&("string"==typeof l.output?outputConfig.path=l.output:Object.keys(l.output)&&Object.assign(outputConfig,l.output));let L=l.routeBaseName.split("/").filter(Boolean).length,W=`${Array(L).fill("..").join("/")+(L?"/":"")}404.html`,{pathSegmentsToKeep:N=L,path:R=W}=l.fixBrowserRouter||{},_={entry:K,stats:"errors-only",infrastructureLogging:{level:"none"},target:"web",plugins:[new n.AutomaticPrefetchPlugin,...u,M&&new M({fix:!0,threads:!0,extensions:["js","md","mdx","cjs","ejs","mjs","jsx","ts","tsx","json","html","coffee","vue"]}),T&&new T({fix:!0,threads:!0,extensions:["css","scss","sass","less","ts","tsx","js","jsx"],exclude:["node_modules/","es/","lib/","docs/","coverage/","dist/"]}),l.htmlPluginOption&&new s(c),l.fixBrowserRouter&&new s({filename:R,inject:!1,templateContent:()=>`<html html><head><title>${c.title}</title><script>var pathSegmentsToKeep = ${N||L};var l = window.location;l.replace(l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') + l.pathname.split('/').slice(0, 1 + pathSegmentsToKeep).join('/') + '/?/' + l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/').replace(/&/g, '~and~') + (l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') + l.hash);</script></head><body></body></html>`}),new t(D),"single-spa"===f&&new m(e=>!!(e.match(/main\.(.*)\.bundle.js$/)||e.match("main.bundle.js"))),new n.DefinePlugin(p),new n.WatchIgnorePlugin({paths:[/\.d\.ts$/]}),l.sourceMap&&new n.SourceMapDevToolPlugin(l.sourceMap),l.bar&&new o(l.bar),new r({done:()=>{!g&&l.seo&&k(),l.done?.(),g||setTimeout(()=>{process.exit(0)},2e3)}}),new C({name:"env-flags",contents:p}),...l.plugins].filter(Boolean),experiments:{topLevelAwait:!0,syncWebAssembly:!0,asyncWebAssembly:!0},resolve:{extensions:[".tsx",".ts",".js",".jsx"],alias:alias,fallback:{path:!1,fs:!1,crypto:!1,assert:!1}},module:d,externals:l.externals,output:outputConfig};export default _;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneko/core",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.80",
|
|
4
4
|
"description": "core",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"webpack-cli": "5.1.4",
|
|
44
44
|
"webpack-dev-server": "4.15.1",
|
|
45
45
|
"webpack-merge": "5.9.0",
|
|
46
|
+
"webpack-virtual-modules": "0.5.0",
|
|
46
47
|
"webpackbar": "5.0.2",
|
|
47
48
|
"xml2js": "0.6.1"
|
|
48
49
|
},
|