@moneko/core 3.0.0-beta.115 → 3.0.0-beta.116
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/app.js +1 -1
- package/lib/common.js +1 -12
- package/lib/docs.js +1 -1
- package/lib/generate-api.js +1 -1
- package/lib/module.config.js +1 -1
- package/lib/process-env.d.ts +2 -0
- package/lib/process-env.js +1 -1
- package/lib/routes.js +1 -1
- package/lib/webpack.common.js +1 -1
- package/package.json +3 -3
- package/typings/global.d.ts +1 -7
package/lib/app.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import o from"fs";import e from"path";import{CONFIG as t}from"./common.js";import r from"./html-plugin-option.js";import{APPTYPE as s,PACKAGENAME as i,PROGRAMPATH as m,programInfo as
|
|
1
|
+
import o from"fs";import e from"path";import{CONFIG as t}from"./common.js";import r from"./html-plugin-option.js";import{APPTYPE as s,PACKAGENAME as i,PROGRAMPATH as m,isLibrary as p,programInfo as f}from"./process-env.js";import{toUpperCaseString as n}from"./utils.js";let c=p?"site":"src",l={...f,base:t.routeBaseName,routerMode:t.routerMode,mode:t.mode,locales:o.existsSync(e.join(m,`./${c}/locales`)),favicon:r.favicon,prefixCls:t.prefixCls,theme:t.theme,type:s,persist:o.existsSync(e.join(m,`./${c}/persist.ts`)),projectName:JSON.stringify(n(i)),iconfont:t.iconfont};export default l;
|
package/lib/common.js
CHANGED
|
@@ -1,12 +1 @@
|
|
|
1
|
-
import{accessSync as e,constants as t}from"fs";import{join as o}from"path";import s from"readline";import r from"chalk";import{merge as i}from"webpack-merge";import{APPTYPE as n,CUSTOMCONFIG as
|
|
2
|
-
(function(l) {
|
|
3
|
-
if (l.search[1] === '/' ) {
|
|
4
|
-
var decoded = l.search.slice(1).split('&').map(function(s) {
|
|
5
|
-
return s.replace(/~and~/g, '&')
|
|
6
|
-
}).join('?');
|
|
7
|
-
window.history.replaceState(null, null,
|
|
8
|
-
l.pathname.slice(0, -1) + decoded + l.hash
|
|
9
|
-
);
|
|
10
|
-
}
|
|
11
|
-
}(window.location))
|
|
12
|
-
`}));export const CONFIG=w;export const PUBLICPATH=CONFIG.publicPath||"/";export let hasCustomRouter=!1;try{e(o(CONFIG.alias["@"],"./router/index.ts"),t.R_OK),hasCustomRouter=!0}catch(e){hasCustomRouter=!1}global.NEKOCLICONFIG={CONFIG,log};
|
|
1
|
+
import{accessSync as e,constants as t}from"fs";import{join as o}from"path";import s from"readline";import r from"chalk";import{merge as i}from"webpack-merge";import{APPTYPE as n,CUSTOMCONFIG as a,FRAMEWORK as l,PACKAGENAME as c,PROGRAMPATH as m,jsxImportSource as p,pkgName as u}from"./process-env.js";import{isFunction as d,readConf as h,resolveProgramPath as f}from"./utils.js";export const ENTRYPATH={mobile:"mobile",site:"site",backstage:"backstage",micro:"micro",library:"library"};let g=[`@moneko/${l}`,"neko-ui","antd","@antv","katex","font-pingfang-sc","font-pingfang-tc","react-photo-view","react-markdown-editor-lite","schema-design","@app"],x={library:{"@":f("site"),"@pkg":f("components"),[c]:f("components")},mobile:{},site:{},backstage:{},micro:{}},b={seo:!1,mode:"csr",compiler:"swc",bundleAnalyzer:{analyzerMode:"static",reportFilename:"report.html",openAnalyzer:!1},entry:{},minifier:{js:{},css:{}},sourceMap:{filename:"[file].map",publicPath:""},env:{},routeBaseName:"/",publicPath:"/",rem:{designSize:"mobile"===n?375:1680},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:Object.assign({"@":f("src")},x[n]),layoutSider:{},moduleRules:[],prefixJsLoader:[],cssModules:[],importOnDemand:{},proxy:[],cacheDirectory:`${m}/node_modules/.temp_cache`,devServer:{allowedHosts:[".baidu.com"],host:"localhost",port:3e3,https:!1,compress:!1},htmlPluginOption:{template:`./node_modules/${u}/template/index.html`,favicon:`./node_modules/${u}/template/favicon.ico`,tags:[]},assetHtml:[],routerMode:"browser",fixBrowserRouter:!1,plugins:[],splitChunk:{chunks:"all",minSize:1024,minChunks:1,cacheGroups:{route:{test:/[\\/].git[\\/]router/,priority:-10,reuseExistingChunk:!0,name:"route"},example:{test:/[\\/].git[\\/]example/,priority:-10,reuseExistingChunk:!0,name:"example"}}},runtimeChunk:"single",moduleFederation:[],rulesInclude:{less:g,css:g,js:g,media:g,fonts:g},mdx:{jsxImportSource:p,useDynamicImport:!0,remarkPlugins:[],rehypePlugins:[]},jsxDomExpressions:{moduleName:"solid-js/web",builtIns:["For","Show","Switch","Match","Suspense","SuspenseList","Portal","Index","Dynamic","ErrorBoundary"],contextToCustomElements:!0,wrapConditionals:!0,generate:"dom",hydratable:!1},bar:{name:"编译中",color:"#6f42c1"},virtualModule:{},normalizeCss:!0,externalsPresets:{}};export const log=e=>{s.cursorTo(process.stdout,0),process.stdout.write(e)};let y=b,C=null,w={},k={};try{C=o(m,"./config/index.ts"),e(C,t.R_OK)}catch(e){C=null}if(C)try{let e=(await h(C,"index")).default;w=d(e)?e(process):e}catch(e){process.stdout.write(r.red(e))}if(a){let s=null;try{s=o(m,`./config/${a}.ts`),e(s,t.R_OK)}catch(e){s=null}if(null!==s)try{let e=(await h(s,a)).default;k=d(e)?e(process):e}catch(e){process.stdout.write(r.red(e))}}"tsc"===(y=i(y,w,k)).compiler&&y.minifier&&(y.minifier.js||Object.assign(y.minifier,{js:{type:"terser"}}),y.minifier.css||Object.assign(y.minifier,{css:{type:"cssnano"}})),!1===y.devtool&&(y.sourceMap=!1),!1===y.sourceMap&&(y.devtool=!1),y.fixBrowserRouter&&y.htmlPluginOption&&(y.htmlPluginOption.tags||(y.htmlPluginOption.tags=[]),y.htmlPluginOption.tags.push({textContent:'!function(n){var a=location.search.slice(1);if("/"===a[0]){for(var o=[],c=decodeURIComponent(a).split("&"),e=0,t=c.length;e<t;e++)o.push(c[e].replace(/~and~/g,"&"));var l=o.join("&");l!==a&&window.history.replaceState(null,null,"".concat(n.pathname.slice(0,-1),"?").concat(l).concat(n.hash))}}(window.location);'}));export const CONFIG=y;export const PUBLICPATH=CONFIG.publicPath||"/";export let hasCustomRouter=!1;try{e(o(CONFIG.alias["@"],"./router/index.ts"),t.R_OK),hasCustomRouter=!0}catch(e){hasCustomRouter=!1}global.NEKOCLICONFIG={CONFIG,log};
|
package/lib/docs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{statSync as e}from"fs";import{dirname as t,join as o}from"path";import{watch as r}from"chokidar";import{CONFIG as i}from"./common.js";import n from"./generate-api.js";import s from"./object-listener.js";import{
|
|
1
|
+
import{statSync as e}from"fs";import{dirname as t,join as o}from"path";import{watch as r}from"chokidar";import{CONFIG as i}from"./common.js";import n from"./generate-api.js";import s from"./object-listener.js";import{FRAMEWORK as p,FRAMEWORKNAME as l,createElement as a,isLibrary as c,isSolid as m}from"./process-env.js";import{resolveProgramPath as d}from"./utils.js";let f="@app/comment";export const docs=s({});let u={[f]:{}},$=`() => ${a}(SuspenseComp, { comp: $1 })`,g=`import { ${a} } from "${l}";import { SuspenseComp } from "@moneko/${p}";`;function b(e,r){let s=e.replace(RegExp(`^${i.alias["@pkg"]}`),""),p=t(s).replace(/^\//,""),l=[f,p].join("/"),c=s.split("/").pop()?.replace(/\.tsx?/,".md");if(!c)return;u[f][p]||(u[f][p]={});let m=o(l,c);if("deleted"===r)u[f][p][c]&&delete u[f][p][c];else{let t=n(e);u[m]=t,t?u[f][p][c]=`rr(() => import(/* webpackChunkName: '${m}' */'${m}?raw').then((res) => ({default: ${a}(Dynamic, {text: res.default, component: 'n-md', css: 'table td a {display:inline-flex;align-items:center;gap:2px;}table td a n-img{display:inline-block;overflow:hidden;border-radius:var(--border-radius);inline-size:18px;block-size:18px;}'})})))rr`:u[f][p][c]&&delete u[f][p][c]}let d={};for(let e in u[f])Object.prototype.hasOwnProperty.call(u[f],e)&&(d[e]=Object.values(u[f][e]));let b={...u};delete b[f],Object.assign(docs.data,{...b,"@app/docs":`${g}export default ${JSON.stringify(d).replace(/"rr\((.+?)\)rr"/g,$)}`})}["react","solid"].includes(p)||($="$1",g=""),m&&(g=`import { Dynamic } from "${l}/web";${g}`),c&&function(){let t=[],o=r(d("components"),{ignored:[/(^|[\\/\\])\../,/(^|[\\/\\])__tests__([\\/\\]|$)/],persistent:!0,ignoreInitial:!1});function i(t){return/\.tsx?$/.test(t)&&e(t).isFile()}o.on("add",e=>{i(e)&&(b(e,"added"),t.push(e))}),o.on("change",e=>{i(e)&&b(e,"change")}),o.on("unlink",e=>{i(e)&&(b(e,"deleted"),t.splice(t.indexOf(e),1))}),o.on("ready",()=>{t.forEach(e=>{b(e,"change")})}),process.on("SIGINT",function(){o.close()})}();
|
package/lib/generate-api.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readFileSync as e}from"fs";import{dirname as t}from"path";import n from"typescript";import{CONFIG as r}from"./common.js";let{ScriptKind:l,ScriptTarget:o,SyntaxKind:i,createSourceFile:u,forEachChild:a,getLeadingCommentRanges:c,isInterfaceDeclaration:s,isQuestionToken:f,isPropertySignature:m,isFunctionTypeNode:p,isUnionTypeNode:g
|
|
1
|
+
import{readFileSync as e}from"fs";import{dirname as t}from"path";import n from"typescript";import{CONFIG as r}from"./common.js";let{ScriptKind:l,ScriptTarget:o,SyntaxKind:i,createSourceFile:u,forEachChild:a,getLeadingCommentRanges:c,isInterfaceDeclaration:s,isQuestionToken:f,isPropertySignature:m,isFunctionTypeNode:p,isUnionTypeNode:$,isMethodSignature:g}=n,h={};function b(e){let t=c(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 d(e){if(!e)return null;let t=e.match(/@since\s+([^\n]+)/);return t?t[1].trim():null}function y(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}](${n})`}return null}function x(e){if(!e)return null;let t=e.match(/@ignore\s+([^\n]+)/);return t?t[1].trim():null}let j=/(?<!['"])(unknown|any|void|bigint|object|undefined|null|boolean|number|string|symbol)(?!['"])/g;function B(e,t){if(!e)return null;let n=e.replace(/\b([A-Z][a-zA-Z0-9]*)\b/g,e=>{if(h[e]){let n=`/${[r.routeBaseName,h[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(j,e=>`\\color{#009688}{${e}}`)),n}function T(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 k(e){return e?e.replace(/^@[a-z].+/gm,"").replace(/(\n\s+)+/g,"<br />").replace(/\n/g,"<br />").replace(/(<br \/>)$/g,""):null}export default function w(c){let j=e(c,"utf-8"),w=u(c,j,o.Latest,!0,l.TS),E="";return a(w,e=>{s(e)?E+=function(e){let l=e.name.text;Object.assign(h,{[e.name.text]:t(e.getSourceFile().fileName).replace(r.alias["@pkg"],"")});let o=b(e),u=d(o),a=k(o),c=x(o)?.split("|")||[],s=c.includes("comment"),j=c.includes("initial"),w=c.includes("optional"),E=c.includes("version"),S=c.includes("author"),v=a?`\\color{|4||0.45}{${l}}`:l,F=(function(e){let t=[];if(e.heritageClauses){for(let r of e.heritageClauses)if(r.token===n.SyntaxKind.ExtendsKeyword)for(let e of r.types)t.push(e.getText())}return t})(e)?.map(e=>`<n-tag color="#4c81db" css=".tag{gap:0px;}">${B(T(e))}</n-tag>`),N=[a,v,u&&`\\color{#52c11b|1||0.9}{${u}}`,F.length>0&&`<sub>\`extends\`</sub> ${F.join(" ")}`].filter(Boolean).join(" "),z=`## ${N}`,K=e.members.filter(e=>m(e)&&e.type?.kind!==i.NeverKeyword||g(e)),q=[];if(K.length){K.forEach(e=>{let t=B(T(g(e)?`(${e.parameters.map(e=>`${e.name.getText()}: ${e.type?.getText()||"any"}`).join(", ")}): ${e.type?.getText()||"any"}`:e.type?.getText()||"any"),!0),n=b(e),r=T(e.name.getText());!r||r.startsWith("\\color")||(g(e)||function(e){if(e.type){if(!$(e.type))return p(e.type);for(let t of e.type.types)if(p(t))return!0}return!1}(e)||t?.includes("=>")?r=`\\color{#f9a913}{${r}}`:/^("|')(.+)("|')$/.test(r)||(r=`\\color{#4c81db}{${r}}`));let l=e.questionToken&&f(e.questionToken);q.push([r,!w&&`\\color{${l?"#f9a913":"#52c11b"}\\|\\|\\|0.9}{${l?"✘":"✔"}}`,!s&&T(k(n)),t,!j&&T(function(e){if(!e)return null;let t=e.match(/@default\s+([^\n]+)/);return t?t[1].trim():null}(n)),!E&&T(d(n)),!S&&(y(n)||y(o))])});let e=!1,t=!1,n=!1,r=!1;q.forEach(l=>{!s&&l[2]&&(r=!0),!j&&l[4]&&(n=!0),!E&&l[5]&&(t=!0),!S&&l[6]&&(e=!0)}),z+="\n";let l=["属性",!w&&"必要",r&&"说明","类型",n&&"默认值",t&&"版本",e&&"作者"].filter(Boolean).join("|");z+=`|${l}|`;let i=[":-",!w&&":-",r&&":-",":-",n&&":-",t&&":-",e&&":-"].filter(Boolean);z+="\n";let u=i.join("|");z+=`|${u}|`,q.forEach(l=>{z+="\n";let o=[l[0]||"-",!w&&(l[1]||"-"),r&&(l[2]||"-"),l[3]||"-",n&&(l[4]||"-"),t&&(l[5]||"-"),e&&(l[6]||"-")].filter(Boolean).join("|");z+=`|${o}|`}),z+="\n"}return z+="\n"}(e):n.isEnumDeclaration(e)&&(E+=function(e){let l=e.name.text,o=b(e),i=k(o),u=d(o);Object.assign(h,{[e.name.text]:t(e.getSourceFile().fileName).replace(r.alias["@pkg"],"")});let a=i?`\\color{|4||0.45}{${l}}`:l,c=[i,a,u&&`\\color{#52c11b|1||0.9}{${u}}`].filter(Boolean).join(" "),s=x(o)?.split("|")||[],f=s.includes("comment"),m=s.includes("version"),p=s.includes("author"),$=`## ${c}`;if(e.members.length){let t=[];e.members.forEach(e=>{let r=T(e.name.getText()),l=b(e),i=T(function(e){let t=e.initializer;return t&&n.isStringLiteral(t)?` '${t.text}'`:null}(e)),u=T(d(l)),a=T(k(l));!r||r.startsWith("\\color")||/^("|')(.+)("|')$/.test(r)||(r=`\\color{#4c81db}{${r}}`),t.push([r,!f&&a,i,!m&&u,!p&&(y(l)||y(o))])});let r=!1,l=!1,i=!1;t.forEach(e=>{!f&&e[1]&&(i=!0),!m&&e[3]&&(l=!0),!p&&e[4]&&(r=!0)}),$+="\n";let u=["属性",i&&"说明","值",l&&"版本",r&&"作者"].filter(Boolean).join("|");$+=`|${u}|`;let a=[":-",i&&":-",":-",l&&":-",r&&":-"].filter(Boolean);$+="\n";let c=a.join("|");$+=`|${c}|`,t.forEach(e=>{$+="\n";let t=[e[0]||"-",i&&(e[1]||"-"),e[2]||"-",l&&(e[3]||"-"),r&&(e[4]||"-")].filter(Boolean).join("|");$+=`|${t}|`})}return $+="\n\n"}(e))}),E}
|
package/lib/module.config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolve as e}from"path";import s from"mini-css-extract-plugin";import o from"mini-svg-data-uri";import{CONFIG as t,PUBLICPATH as r}from"./common.js";import{hasPkg as l}from"./has-pkg.js";import a from"./modifyVars.js";import{
|
|
1
|
+
import{resolve as e}from"path";import s from"mini-css-extract-plugin";import o from"mini-svg-data-uri";import{CONFIG as t,PUBLICPATH as r}from"./common.js";import{hasPkg as l}from"./has-pkg.js";import a from"./modifyVars.js";import{DEV as n,FRAMEWORK as i,__dirname as c,isMicro as m}from"./process-env.js";import p from"./swcrc.js";import d from"./tsloader.config.js";import{resolveNodeModulesPath as u,resolveProgramPath as f}from"./utils.js";let y=m?r:"../",x={loader:s.loader,options:{publicPath:"/"!==y?y:"../"}},g=l("@moneko/postcss")&&{loader:"postcss-loader",options:{postcssOptions:await import("@moneko/postcss")}};n&&(x="style-loader");let $=[...t.cssModules,`@moneko/${i}`,"neko-ui"].map(u),j=[...["src/styles/variables/*.less","src/styles/mixins/*.less","site/styles/variables/*.less","site/styles/mixins/*.less"].map(f)],v=["components","example","mock","site","src","server"].map(f),b=[x,{loader:"@teamsupercell/typings-for-css-modules-loader",options:{verifyOnly:!n}},{loader:"css-loader",options:{modules:{auto:e=>{for(let s=0,o=$.length;s<o;s++)if(e&&e?.includes($[s]))return/(.*(?<!\.?global\.(le|c)ss)$)/i.test(e);return/(^(?!.*node_modules))(.*(?<!\.?global\.(le|c)ss)$)/i.test(e)},localIdentName:"[path][name]__[local]",exportLocalsConvention:"dashesOnly"},importLoaders:2}},g,"css-unicode-loader",{loader:"less-loader",options:{sourceMap:!!t.sourceMap,lessOptions:{modifyVars:a,javascriptEnabled:!0}}},{loader:"style-resources-loader",options:{patterns:j}}].filter(Boolean),w={loader:"tsc"===t.compiler?"ts-loader":"swc-loader",options:"tsc"===t.compiler?d:p(n)},h={rules:[{test:/\.mdx?$/,include:[f("components")],exclude:[/(.+)\/examples\/(.+).mdx?$/i],enforce:"pre",use:[{loader:e(c,"./loader/frontmatter.cjs")}]},{oneOf:[{resourceQuery:/raw/,type:"asset/source"},{test:/\.wasm$/,type:"webassembly/async"},{test:/\.txt$/,type:"asset/source"},{test:/\.(gif|png|jpe?g|ico|mp4)$/i,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/images/[name][ext][query]"},include:v.concat(t.rulesInclude?.media?.map(u)||[])},{test:/\.svg$/,type:"asset/inline",generator:{dataUrl:e=>o("string"!=typeof e?e.toString():e)}},{test:/\.(eot|ttf|otf|woff(|2))$/,type:"asset",generator:{filename:"assets/fonts/[name][ext][query]"},include:v.concat(t.rulesInclude?.fonts?.map(u)||[])},{test:/\.less$/,use:b,include:v.concat(t.rulesInclude?.less?.map(u)||[])},{test:/\.css$/,use:[x,"css-loader",g,"css-unicode-loader"].filter(Boolean),include:v.concat(t.rulesInclude?.css?.map(u)||[])},{test:/\.(cj|mj|t|j)s(|x)$/,use:[...t.prefixJsLoader,w].filter(Boolean),include:v.concat(t.rulesInclude?.js?.map(u)||[])},{test:/\.mdx?$/,use:[...t.prefixJsLoader,w,{loader:"@mdx-js/loader",options:t.mdx}].filter(Boolean),include:v,exclude:[/(.+)\/examples\/(.+).mdx?$/i]},{test:/\.mdx?$/,type:"asset/source",include:[/(.+)\/examples\/(.+).mdx?$/i]},{type:"asset/source",include:[/(.+)\/examples\/(.+).*?$/i]}]},...t.moduleRules]};export default h;
|
package/lib/process-env.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import type { AppType, Framework } from '../typings/global.js';
|
|
|
2
2
|
export declare const __dirname: string;
|
|
3
3
|
export declare const APPTYPE: AppType;
|
|
4
4
|
export declare const FRAMEWORK: Framework;
|
|
5
|
+
export declare const isLibrary: boolean;
|
|
6
|
+
export declare const isMicro: boolean;
|
|
5
7
|
export declare const isReact: boolean;
|
|
6
8
|
export declare const isSolid: boolean;
|
|
7
9
|
export declare const jsxImportSource: string;
|
package/lib/process-env.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as e,mkdirSync as o,readFileSync as r}from"fs";import{join as t}from"path";import s from"url";import{hasPkg as n}from"./has-pkg.js";import{resolveProgramPath as p}from"./utils.js";import c from"./yarn-argv.js";export const __dirname=s.fileURLToPath(new URL(".",import.meta.url));export const APPTYPE=process.env.APPTYPE;export const FRAMEWORK=process.env.FRAMEWORK;export const isReact="react"===FRAMEWORK;export const isSolid="solid"===FRAMEWORK;export const jsxImportSource={react:"react",solid:"solid-js/h"}[FRAMEWORK];export const createElement={react:"createElement",solid:"createComponent"}[FRAMEWORK];export const FRAMEWORKNAME={react:"react",solid:"solid-js"}[FRAMEWORK];export const PROGRAMPATH=process.cwd();export const PACKAGENAME=process.env.npm_package_name;export const PACKAGEVERSION=process.env.npm_package_version;let a=r(t(__dirname,"../package.json"),{encoding:"utf-8"});export const pkgName=JSON.parse(a).name;export const DEV="development"===process.env.NODE_ENV;export const cacheDir=t(PROGRAMPATH,"./node_modules/.cache/.mo/");e(cacheDir)||o(cacheDir,{recursive:!0});export const NODE_ENV=process.env.NODE_ENV;export const CUSTOMCONFIG=process.env.npm_config_config||c.config;export let hasEslintConfig=!!Object.keys(process.env).filter(e=>e.startsWith("npm_package_eslintConfig_")).length;export let hasStylelintConfig=!!Object.keys(process.env).filter(e=>e.startsWith("npm_package_stylelint_")).length;export const hasAntd=n("antd");export const programInfo={name:PACKAGENAME,version:PACKAGEVERSION,type:APPTYPE,description:process.env.npm_package_description,author:{name:process.env.npm_package_author_name,email:process.env.npm_package_author_email,url:process.env.npm_package_author_url},repository:{type:process.env.npm_package_repository_type,url:process.env.npm_package_repository_url,directory:process.env.npm_package_repository_directory}};if(parseInt(process.versions.node)>14){let e=r(p("package.json"),{encoding:"utf-8"}),{description:o,author:t,repository:s,eslintConfig:n,stylelint:c}=JSON.parse(e);programInfo.author="string"==typeof t?{name:t}:t,programInfo.repository="string"==typeof t?{url:s}:s,programInfo.description=o,hasEslintConfig=!!n,hasStylelintConfig=!!c}
|
|
1
|
+
import{existsSync as e,mkdirSync as o,readFileSync as r}from"fs";import{join as t}from"path";import s from"url";import{hasPkg as n}from"./has-pkg.js";import{resolveProgramPath as p}from"./utils.js";import c from"./yarn-argv.js";export const __dirname=s.fileURLToPath(new URL(".",import.meta.url));export const APPTYPE=process.env.APPTYPE;export const FRAMEWORK=process.env.FRAMEWORK;export const isLibrary="library"===APPTYPE;export const isMicro="micro"===APPTYPE;export const isReact="react"===FRAMEWORK;export const isSolid="solid"===FRAMEWORK;export const jsxImportSource={react:"react",solid:"solid-js/h"}[FRAMEWORK];export const createElement={react:"createElement",solid:"createComponent"}[FRAMEWORK];export const FRAMEWORKNAME={react:"react",solid:"solid-js"}[FRAMEWORK];export const PROGRAMPATH=process.cwd();export const PACKAGENAME=process.env.npm_package_name;export const PACKAGEVERSION=process.env.npm_package_version;let a=r(t(__dirname,"../package.json"),{encoding:"utf-8"});export const pkgName=JSON.parse(a).name;export const DEV="development"===process.env.NODE_ENV;export const cacheDir=t(PROGRAMPATH,"./node_modules/.cache/.mo/");e(cacheDir)||o(cacheDir,{recursive:!0});export const NODE_ENV=process.env.NODE_ENV;export const CUSTOMCONFIG=process.env.npm_config_config||c.config;export let hasEslintConfig=!!Object.keys(process.env).filter(e=>e.startsWith("npm_package_eslintConfig_")).length;export let hasStylelintConfig=!!Object.keys(process.env).filter(e=>e.startsWith("npm_package_stylelint_")).length;export const hasAntd=n("antd");export const programInfo={name:PACKAGENAME,version:PACKAGEVERSION,type:APPTYPE,description:process.env.npm_package_description,author:{name:process.env.npm_package_author_name,email:process.env.npm_package_author_email,url:process.env.npm_package_author_url},repository:{type:process.env.npm_package_repository_type,url:process.env.npm_package_repository_url,directory:process.env.npm_package_repository_directory}};if(parseInt(process.versions.node)>14){let e=r(p("package.json"),{encoding:"utf-8"}),{description:o,author:t,repository:s,eslintConfig:n,stylelint:c}=JSON.parse(e);programInfo.author="string"==typeof t?{name:t}:t,programInfo.repository="string"==typeof t?{url:s}:s,programInfo.description=o,hasEslintConfig=!!n,hasStylelintConfig=!!c}
|
package/lib/routes.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
let e,t;import{readFileSync as r,readdirSync as o,statSync as s}from"fs";import{join as
|
|
1
|
+
let e,t;import{readFileSync as r,readdirSync as o,statSync as s}from"fs";import{join as n,relative as a}from"path";import{watch as i}from"chokidar";import{load as l}from"js-yaml";import{hasCustomRouter as p}from"./common.js";import c from"./object-listener.js";import{FRAMEWORK as m,FRAMEWORKNAME as u,PROGRAMPATH as d,createElement as f,isLibrary as g}from"./process-env.js";let x=/^---\n([\s\S]+?)\n---\n/;function h(e){return e.replace(/\$/g,":").replace(/^index\.tsx?$/,"/").replace(/^README\.mdx?$/,"/")}function $(e,t){let{regex:i,alia:p,base:c=e,outputSource:m}=t,u=o(e);return u.reduce((o,u)=>{let d=n(e,u),f=s(d);if(f.isDirectory()){let e=$(d,{...t,base:c});if(e.length>0){let t={},r={path:h(u),key:h(a(c,d))};if(m)Object.assign(t,{children:e});else{let o=e.findIndex(e=>"/"===e.path||r.path===e.path),s=e.splice(o,1)[0];e.length?Object.assign(t,{children:[{...s,path:r.path===s.path?"/":s.path},...e]}):Object.assign(t,s)}o.push(Object.assign(t,r))}}else if(i.test(d)){let e=r(d,{encoding:"utf-8"}),t=function(e){let t=e.match(x);return t&&t[1]?t[1].trim():null}(e),s=t?l(t):{},i=a(c,d),u=h(i);o.push(Object.assign({path:u.split("/").slice(-2,-1)?.join("")||"/",key:u.replace(/\/?index.tsx?$/,"/").replace(/\/?README.mdx?$/,"/").split("/").filter(Boolean).join("/"),meta:{...s}},p&&{component:`rr(() => import(/* webpackChunkName: '${i}' */'${n(p,i)}'))rr`},m&&{codes:function(e){let t;let r={},o=/```(.+?)\n([\s\S]*?)\n```/g;for(;null!==(t=o.exec(e));){let[,e="jsx",o]=t,s=e.split(" ").pop()||"jsx";r[s]=o.trim()}return Object.keys(r).length?r:{jsx:e}}(e.replace(x,"").replace(/^\n+|\n+$/g,""))}))}return o},[])}let j=n(d,"./components");export const route=c({name:"@app/routes",data:"export default []"});export const example=c({name:"@app/example",data:{}});let b=`() => ${f}(SuspenseComp, { comp: $1 })`,O=`import { ${f} } from "${u}";import { SuspenseComp } from "@moneko/${m}";`;p&&(O+=`import merge from "@moneko/${m}/lib/merge.js";import customRouter from "@/router";`),["react","solid"].includes(m)||(b="$1",O="");export let routes=[];function k(e,t,r){let o=i(e,{ignored:(e,r)=>{if(r)return!r?.isDirectory()&&t.test(e)},persistent:!0,ignoreInitial:!1});o.on("add",()=>{r()}).on("change",()=>{r()}).on("unlink",()=>{r()}),process.on("SIGINT",function(){o.close()})}let y=n(d,"./src/pages");g?(k(j,/(?<!README\.mdx?)$/,function(){clearTimeout(e),e=setTimeout(()=>{clearTimeout(e),routes=$(j,{regex:/README\.mdx?$/,alia:"@pkg"});let t=JSON.stringify(routes).replace(/"rr\((.+?)\)rr"/g,b).slice(1,-1);Object.assign(route.data,{data:`${O}const routes = [{ path: "/", children: [{ path: "/" }, ${t}] }];
|
|
2
2
|
export default ${p?'merge([...routes, ...customRouter], "path")':"routes"}`})},100)}),k(j,/(?<!\/examples\/(.+)\.md)$/,function(){clearTimeout(t),t=setTimeout(()=>{clearTimeout(t);let e={};$(j,{regex:/\/examples\/(.+)\.md$/,outputSource:!0}).forEach(t=>{let r=[example.data.name,t.key].filter(Boolean).join("/"),o=t.children?.[0].children?.filter(e=>e.codes)?.map(e=>({title:e.path.replace(/.md$/,""),order:0,...e.meta,codes:e.codes})).sort((e,t)=>e.order-t.order);Object.assign(e,{[r]:`export default ${JSON.stringify(o)};`})}),Object.assign(example.data,{data:e})},100)})):k(y,/(?<!index\.tsx?)$/,function(){clearTimeout(e),e=setTimeout(()=>{clearTimeout(e),routes=$(y,{regex:/index\.tsx?$/,alia:"@/pages"});let t=JSON.stringify(routes).replace(/"rr\((.+?)\)rr"/g,b).slice(1,-1);Object.assign(route.data,{data:`${O}const routes = [{ path: "/", children: [{ path: "/" }, ${t}] }];
|
|
3
3
|
export default ${p?'merge([...routes, ...customRouter], "path")':"routes"}`})},100)});
|
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 o from"webpack";import
|
|
1
|
+
import e from"fs";import t from"add-asset-html-webpack-plugin";import s from"html-webpack-plugin";import o from"webpack";import l from"webpackbar";import"./cleanup.js";import{CONFIG as n,PUBLICPATH as r}from"./common.js";import i from"./define.js";import a from"./done.js";import p from"./html-add-entry-attr.js";import m from"./html-plugin-option.js";import{moduleFederation as c}from"./module-federation.js";import u from"./module.config.js";import{CUSTOMCONFIG as f,DEV as h,PACKAGENAME as d,PROGRAMPATH as j,hasEslintConfig as y,hasStylelintConfig as g,isLibrary as w,isMicro as b}from"./process-env.js";import{seo as x}from"./seo.js";import{resolveNodeModulesPath as k,resolveProgramPath as v}from"./utils.js";import C from"./virtual-module-plugin.js";import $ from"./virtual-modules.js";let{AutomaticPrefetchPlugin:O,DefinePlugin:B,SourceMapDevToolPlugin:P,WatchIgnorePlugin:A}=o,M=[".eslintrc.js",".eslintrc.json",".eslintrc.yaml",".eslintrc.json"],S=[".stylelintrc",".stylelintrc.json",".stylelintrc.yaml",".stylelintrc.yml",".stylelintrc.js","stylelint.config.js","stylelint.config.cjs"],T=e.readdirSync(j),D=!1,K=!1;for(let e=0,t=T.length;e<t;e++)S.includes(T[e])&&(K=!0),M.includes(T[e])&&(D=!0);D||(D=y),K||(K=g);let L=K?(await import("stylelint-webpack-plugin")).default:null,F=D?(await import("eslint-webpack-plugin")).default:null,R=n.assetHtml.map(e=>({publicPath:"",...e}));export const outputConfig={path:v(w?"docs":"dist"),filename:"js/[chunkhash].js",chunkFilename:"js/[chunkhash].js",assetModuleFilename:"assets/[hash][ext][query]",library:{name:d,type:"window"},globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${d}`,pathinfo:h,clean:!0,publicPath:r,asyncChunks:!0};let W={main:k("@app/entry")};n.entry&&("string"==typeof n.entry?W=n.entry:Object.keys(n.entry)&&Object.assign(W,n.entry)),n.output&&("string"==typeof n.output?outputConfig.path=n.output:Object.keys(n.output)&&Object.assign(outputConfig,n.output));let _=n.routeBaseName.split("/").filter(Boolean).length,q=`${Array(_).fill("..").join("/")+(_?"/":"")}404.html`,{pathSegmentsToKeep:G=_,path:H=q}=n.fixBrowserRouter||{},J=!1;n.cacheDirectory&&(J={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:n.cacheDirectory,memoryCacheUnaffected:!0,name:`${f||"default"}-${h?"development":"production"}`});export const clientConfig={entry:W,stats:"errors-only",cache:J,infrastructureLogging:{level:"none"},target:"web",externalsPresets:n.externalsPresets,plugins:[new O,...c,F&&new F({fix:!0,threads:!0,extensions:["js","md","mdx","cjs","ejs","mjs","jsx","ts","tsx","json","html","coffee","vue"]}),L&&new L({fix:!0,threads:!0,extensions:["css","scss","sass","less","ts","tsx","js","jsx"],exclude:["node_modules/","es/","lib/","docs/","coverage/","dist/"]}),n.htmlPluginOption&&new s(m),n.fixBrowserRouter&&new s({filename:H,inject:!1,templateContent:()=>`<html html><head><title>${m.title}</title><script>var pathSegmentsToKeep = ${G||_};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(R),b&&new p(e=>!!(e.match(/main\.(.*)\.bundle.js$/)||e.match("main.bundle.js"))),new B(i),new A({paths:[/\.d\.ts$/]}),n.sourceMap&&new P(n.sourceMap),n.bar&&new l(n.bar),new a({done:()=>{!h&&n.seo&&x(),n.done?.(),h||setTimeout(()=>{process.exit(0)},2e3)}}),new C($),...n.plugins].filter(Boolean),experiments:{topLevelAwait:!0,syncWebAssembly:!0,asyncWebAssembly:!0},resolve:{extensions:[".tsx",".ts",".js",".jsx"],alias:n.alias,fallback:{path:!1,fs:!1,crypto:!1,assert:!1}},module:u,externals:n.externals,output:outputConfig};
|
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.116",
|
|
4
4
|
"description": "core",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -19,14 +19,14 @@
|
|
|
19
19
|
"@swc/helpers": "0.5.1",
|
|
20
20
|
"@teamsupercell/typings-for-css-modules-loader": "2.5.2",
|
|
21
21
|
"add-asset-html-webpack-plugin": "6.0.0",
|
|
22
|
-
"core-js": "3.32.
|
|
22
|
+
"core-js": "3.32.1",
|
|
23
23
|
"cross-env": "7.0.3",
|
|
24
24
|
"css-loader": "6.8.1",
|
|
25
25
|
"css-minimizer-webpack-plugin": "5.0.1",
|
|
26
26
|
"css-unicode-loader": "1.0.3",
|
|
27
27
|
"external-remotes-plugin": "1.0.0",
|
|
28
28
|
"html-webpack-plugin": "5.5.3",
|
|
29
|
-
"less": "4.
|
|
29
|
+
"less": "4.2.0",
|
|
30
30
|
"less-loader": "11.1.3",
|
|
31
31
|
"mini-css-extract-plugin": "2.7.6",
|
|
32
32
|
"mini-svg-data-uri": "1.4.4",
|
package/typings/global.d.ts
CHANGED
|
@@ -16,13 +16,7 @@ import type {
|
|
|
16
16
|
import type { State } from 'webpackbar';
|
|
17
17
|
|
|
18
18
|
export type MinifierType = 'swc' | 'terser';
|
|
19
|
-
export declare type AppType =
|
|
20
|
-
| 'single-component'
|
|
21
|
-
| 'mobile'
|
|
22
|
-
| 'site'
|
|
23
|
-
| 'backstage'
|
|
24
|
-
| 'micro'
|
|
25
|
-
| 'library';
|
|
19
|
+
export declare type AppType = 'mobile' | 'site' | 'backstage' | 'micro' | 'library';
|
|
26
20
|
export declare type Framework = 'react' | 'solid';
|
|
27
21
|
export type TerserOptions = MinifyOptions;
|
|
28
22
|
export type SwcOptions = JsMinifyOptions;
|