@moneko/core 3.1.6 → 3.2.1-beta.0
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/common.js +1 -1
- package/lib/config.d.ts +3 -3
- package/lib/config.js +1 -1
- package/lib/coverage.js +2 -3
- package/lib/docs.js +1 -1
- package/lib/generate-api.js +2 -2
- package/lib/has-pkg.js +1 -1
- package/lib/html-plugin-option.js +1 -1
- package/lib/index.d.ts +5 -1
- package/lib/index.js +1 -1
- package/lib/locales.js +3 -3
- package/lib/minify.d.ts +1 -1
- package/lib/module.config.js +3 -3
- package/lib/paths.d.ts +1 -0
- package/lib/paths.js +1 -1
- package/lib/polyfills/replace-children.d.ts +1 -0
- package/lib/polyfills/replace-children.js +3 -0
- package/lib/process-env.d.ts +14 -2
- package/lib/process-env.js +7 -1
- package/lib/prod.js +2 -2
- package/lib/reactive-object.d.ts +1 -2
- package/lib/reactive-object.js +7 -1
- package/lib/swcrc.js +2 -2
- package/lib/utils.d.ts +1 -0
- package/lib/utils.js +4 -3
- package/lib/virtual-module-plugin.d.ts +1 -1
- package/package.json +3 -5
- package/typings/global.d.ts +9 -8
package/lib/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
|
|
1
|
+
import e from"fs";import t from"add-asset-html-webpack-plugin";import s from"html-webpack-plugin";import l from"webpack";import o from"webpackbar";import"./cleanup.js";import{CONFIG as n,PUBLICPATH as r}from"./config.js";import i from"./done.js";import a from"./html-add-entry-attr.js";import p from"./html-plugin-option.js";import{moduleFederation as c}from"./module-federation.js";import m from"./module.config.js";import u from"./paths.js";import{CUSTOMCONFIG as f,PACKAGENAME as d,PACKAGEVERSION as h,hasEslintConfig as j,hasStylelintConfig as y,isDev as b,isLibrary as g,isMicro as w}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:P,SourceMapDevToolPlugin:M,WatchIgnorePlugin:B}=l,D=[".eslintrc.js",".eslintrc.json",".eslintrc.yaml",".eslintrc.json"],A=[".stylelintrc",".stylelintrc.json",".stylelintrc.yaml",".stylelintrc.yml",".stylelintrc.js","stylelint.config.js","stylelint.config.cjs"],H=e.readdirSync(u.programPath),K=!1,L=!1;for(let e=0,t=H.length;e<t;e++)A.includes(H[e])&&(L=!0),D.includes(H[e])&&(K=!0);K||(K=j),L||(L=y);let F=L?(await import("stylelint-webpack-plugin")).default:null,J=K?(await import("eslint-webpack-plugin")).default:null,R=n.assetHtml.map(e=>({publicPath:"",...e}));export const outputConfig={path:v(g?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:`js/[${b?"name":"chunkhash"}].js`,assetModuleFilename:e=>{let t=e.filename;return t&&t.endsWith("?url")&&/(?:webworker|worker)(\.|\b).*\.(js|ts)\b/.test(t.replace("?url",""))?"worker/[name][ext]":"assets/[name][hash][ext]"},library:{name:d,type:"window"},globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${d}`,pathinfo:b,clean:!0,publicPath:r,asyncChunks:!0,charset:!0};let S={main:k("@app/entry")};n.polyfill&&Object.assign(S,{"dom-polyfills":[`${u.corePath}/polyfills/replace-children.js`]}),n.entry&&("string"==typeof n.entry?S={main:n.entry}:Object.keys(n.entry)&&Object.assign(S,n.entry)),n.output&&("string"==typeof n.output?outputConfig.path=n.output:Object.keys(n.output)&&Object.assign(outputConfig,n.output));let U=n.basename.split("/").filter(Boolean).length,W=`${Array(U).fill("..").join("/")+(U?"/":"")}404.html`,{pathSegmentsToKeep:_=U,path:z=W}=n.fixBrowserRouter||{},G=!1;n.cacheDirectory&&(G={type:"filesystem",store:"pack",allowCollectingMemory:!0,cacheDirectory:n.cacheDirectory,memoryCacheUnaffected:!0,name:`${f||"default"}-${b?"development":"production"}`,version:h});export const clientConfig={entry:S,stats:"errors-only",cache:G,infrastructureLogging:{level:"none"},target:"web",externalsPresets:n.externalsPresets,plugins:[new O,...c,J&&new J({fix:!0,threads:!0,extensions:["js","md","mdx","cjs","ejs","mjs","jsx","ts","tsx","json","html","coffee","vue"]}),F&&new F({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(p),n.fixBrowserRouter&&new s({filename:z,inject:!1,templateContent:()=>`<html lang="en"><head><title>${p.title}</title><script>const pathKeep = ${_||U};const l = window.location;l.replace(l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') + l.pathname.split('/').slice(0, 1 + pathKeep).join('/') + '/?/' + l.pathname.slice(1).split('/').slice(pathKeep).join('/').replace(/&/g, '~and~') + (l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') + l.hash);</script></head><body></body></html>`}),new t(R),w&&new a(e=>!!(e.match(/main\.(.*)\.bundle.js$/)||e.match("main.bundle.js"))),new P({"process.env":JSON.stringify(n.env)}),new B({paths:[/\.d\.ts$/]}),n.sourceMap&&new M(n.sourceMap),n.bar&&new o(n.bar),new i({done:()=>{!b&&n.seo&&x(),n.done?.(),b||setTimeout(()=>{process.exit(0)},2e3)}}),new C($),...n.plugins].filter(Boolean),experiments:{topLevelAwait:!0,asyncWebAssembly:!0,cacheUnaffected:!0,layers:!0,lazyCompilation:b&&{imports:!1,entries:!1},buildHttp:n.buildHttp,backCompat:!0,futureDefaults:!1,css:!1,outputModule:!1},resolve:{extensions:[".tsx",".ts",".js",".jsx",".wasm"],alias:n.alias,fallback:{path:!1,fs:!1,crypto:!1,assert:!1}},module:m,externals:n.externals,output:outputConfig};
|
package/lib/config.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const ENTRYPATH: Record<AppType, string>;
|
|
1
|
+
import type { ConfigType } from '.';
|
|
3
2
|
export declare const log: (msg: string) => void;
|
|
4
|
-
export declare const
|
|
3
|
+
export declare const isTsc: boolean;
|
|
4
|
+
export declare const CONFIG: ConfigType;
|
|
5
5
|
export declare const PUBLICPATH: string;
|
|
6
6
|
export declare let hasCustomRouter: boolean;
|
package/lib/config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{accessSync as e,constants as t}from"fs";import o from"readline";import s from"chalk";import{merge as r}from"webpack-merge";import i from"./paths.js";import{APPTYPE as a,CUSTOMCONFIG as
|
|
1
|
+
import{accessSync as e,constants as t}from"fs";import o from"readline";import s from"chalk";import{merge as r}from"webpack-merge";import i from"./paths.js";import{APPTYPE as a,CUSTOMCONFIG as n,FRAMEWORK as l,PACKAGENAME as c,coreName as m,jsxImportSource as p}from"./process-env.js";import{isFunction as u,readConf as d,resolveProgramPath as h}from"./utils.js";let f=["@moneko/core",`@moneko/${l}`,"neko-ui","antd","@antv","katex","font-pingfang-sc","font-pingfang-tc","react-photo-view","react-markdown-editor-lite","schema-design","@app",".cache/http/data"],g={library:{"@":h("site"),"@pkg":h("components"),[c]:h("components")},mobile:{},site:{},backstage:{},micro:{}},x={seo:!1,mode:"csr",compiler:"swc",bundleAnalyzer:!1,polyfill:!1,entry:{},minifier:{js:{},css:{}},sourceMap:{filename:"[file].map",publicPath:""},env:{NODE_ENV:process.env.NODE_ENV},basename:"/",publicPath:"/",rem:{designSize:"mobile"===a?375:1680},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:Object.assign({"@":h("src")},g[a]),moduleRules:[],prefixJsLoader:[],cssModules:[],importOnDemand:{},proxy:[],cacheDirectory:i.webpackCachePath,devServer:{allowedHosts:[".baidu.com"],host:"localhost",port:3e3,https:!1,compress:!1},htmlPluginOption:{template:`node_modules/${m}/template/index.html`,favicon:`node_modules/${m}/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:f,css:f,js:f,media:f,fonts:f,wasm:[]},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:{},buildHttp:{allowedUris:[],lockfileLocation:`${i.httpCachePath}/http.lock`,cacheLocation:`${i.httpCachePath}/data`,upgrade:!0}};export const log=e=>{o.cursorTo(process.stdout,0),process.stdout.write(e)};let C=x,w=null,b={},y={};try{w=i.defaultConfigPath,e(w,t.R_OK)}catch(e){w=null}if(w)try{let e=(await d(w,"index")).default;b=u(e)?e(process):e}catch(e){process.stdout.write(s.red(e))}if(n){let o=null;try{o=`${i.programPath}/config/${n}.ts`,e(o,t.R_OK)}catch(e){o=null}if(null!==o)try{let e=(await d(o,n)).default;y=u(e)?e(process):e}catch(e){process.stdout.write(s.red(e))}}C=r(C,b,y);export const isTsc="tsc"===C.compiler;isTsc&&C.minifier&&(C.minifier.js||Object.assign(C.minifier,{js:{type:"terser"}}),C.minifier.css||Object.assign(C.minifier,{css:{type:"cssnano"}})),!1===C.devtool&&(C.sourceMap=!1),!1===C.sourceMap&&(C.devtool=!1),C.fixBrowserRouter&&C.htmlPluginOption&&(C.htmlPluginOption.tags||(C.htmlPluginOption.tags=[]),C.htmlPluginOption.tags.push({textContent:"(function(l) {if (l.search[1] === '/' ) {var decoded = l.search.slice(1).split('&').map(function(s) {return s.replace(/~and~/g, '&')}).join('?');window.history.replaceState(null, null,l.pathname.slice(0, -1) + decoded + l.hash);}}(window.location))"}));export const CONFIG=C;export const PUBLICPATH=CONFIG.publicPath||"/";export let hasCustomRouter;try{e(`${CONFIG.alias["@"]}/router/index.ts`,t.R_OK),hasCustomRouter=!0}catch(e){hasCustomRouter=!1}global.NEKOCLICONFIG={CONFIG,log};
|
package/lib/coverage.js
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import{accessSync as e,constants as r,readFileSync as c}from"fs";import{Parser as o}from"xml2js";import t from"./paths.js";import{PACKAGENAME as a,isLibrary as s}from"./process-env.js";export const coverage={};if(s)try{e(t.coveragePath,r.R_OK);let s=new o({explicitArray:!1,async:!1}),i=c(t.coveragePath,{encoding:"utf-8"})
|
|
2
|
-
|
|
3
|
-
}catch(e){}
|
|
1
|
+
import{accessSync as e,constants as r,readFileSync as c}from"fs";import{Parser as o}from"xml2js";import t from"./paths.js";import{PACKAGENAME as a,isLibrary as s}from"./process-env.js";export const coverage={};if(s)try{e(t.coveragePath,r.R_OK);let s=new o({explicitArray:!1,async:!1}).parseString,i=c(t.coveragePath,{encoding:"utf-8"});s(i,(e,r)=>{if(!e){let e=r.coverage.project.metrics.$,c=r.coverage.project.package;Object.assign(coverage,{[a]:e}),c.forEach(e=>{Object.assign(coverage,{[e.$.name]:e.metrics.$})})}})}catch(e){// error
|
|
2
|
+
}
|
package/lib/docs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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"./config.js";import n from"./generate-api.js";import{FRAMEWORK as s,FRAMEWORKNAME as p,createElement as a,isLibrary as l,isReact as c,isSolid as d}from"./process-env.js";import m from"./reactive-object.js";import{resolveProgramPath as f}from"./utils.js";let u="@app/comment";export const docs=new m;let $={[u]:{}},g=`() => ${a}(SuspenseComp, { comp: $1 })`,b=`import { ${a}${d?",Dynamic":""} } from "${p}${d?"/web":""}";import SuspenseComp from "@app/suspense";`;// 要执行的函数
|
|
2
|
-
function h(e,r){let s=e.replace(RegExp(`^${i.alias["@pkg"]}`),""),p=t(s).replace(/^\//,""),l=[u,p].join("/"),m=s.split("/").pop()?.replace(/\.tsx?/,".md");if(!m)return;$[u][p]||($[u][p]={});let f=o(l,m);if("deleted"===r)$[u][p][m]&&delete $[u][p][m];else{let t=n(e);$[f]=t,t?$[u][p][m]=`rr(() => import(/* webpackChunkName: '${f}' */'${f}?raw').then((res) => ({default: ${c?"() =>":""}${a}(${d?"Dynamic":"'n-md'"}, {text: res.default, ${d?"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][p][m]&&delete $[u][p][m]}let h={};for(let e in $)if(Object.prototype.hasOwnProperty.call($,e)){let t=$[e];if(e===u)for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&(h[e]=Object.values(t[e]));else docs.setData(e,t)}docs.setData("@app/docs",`${b}export default ${JSON.stringify(h).replace(/"rr\((.+?)\)rr"/g,g)}`)}["react","solid"].includes(s)||(g="$1",b=""),l&&function(){let t=[],o=r(f("components"),{ignored:[/(
|
|
2
|
+
function h(e,r){let s=e.replace(RegExp(`^${i.alias["@pkg"]}`),""),p=t(s).replace(/^\//,""),l=[u,p].join("/"),m=s.split("/").pop()?.replace(/\.tsx?/,".md");if(!m)return;$[u][p]||($[u][p]={});let f=o(l,m);if("deleted"===r)$[u][p][m]&&delete $[u][p][m];else{let t=n(e);$[f]=t,t?$[u][p][m]=`rr(() => import(/* webpackChunkName: '${f}' */'${f}?raw').then((res) => ({default: ${c?"() =>":""}${a}(${d?"Dynamic":"'n-md'"}, {text: res.default, ${d?"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][p][m]&&delete $[u][p][m]}let h={};for(let e in $)if(Object.prototype.hasOwnProperty.call($,e)){let t=$[e];if(e===u)for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&(h[e]=Object.values(t[e]));else docs.setData(e,t)}docs.setData("@app/docs",`${b}export default ${JSON.stringify(h).replace(/"rr\((.+?)\)rr"/g,g)}`)}["react","solid"].includes(s)||(g="$1",b=""),l&&function(){let t=[],o=r(f("components"),{ignored:[/(^|\/)\../,/(^|\/)__tests__(\/|$)/],persistent:!0,ignoreInitial:!1});function i(t){return/\.tsx?$/.test(t)&&e(t).isFile()}o.on("add",e=>{i(e)&&(h(e,"added"),t.push(e))}),o.on("change",e=>{i(e)&&h(e,"change")}),o.on("unlink",e=>{i(e)&&(h(e,"deleted"),t.splice(t.indexOf(e),1))}),o.on("ready",()=>{t.forEach(e=>{h(e,"change")})}),process.on("SIGINT",function(){o.close()})}();
|
package/lib/generate-api.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{readFileSync as e}from"fs";import{dirname as t}from"path";import n from"typescript";import{CONFIG as r}from"./config.js";let{ScriptKind:l,ScriptTarget:o,SyntaxKind:i,createSourceFile:a,forEachChild:c,getLeadingCommentRanges:u,isInterfaceDeclaration:s,isQuestionToken:f,isPropertySignature:p,isFunctionTypeNode:m,isUnionTypeNode:g,isMethodSignature:$}=n,h={};function b(e){let t=u(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)
|
|
2
|
-
e=>p(e)&&e.type?.kind!==i.NeverKeyword||$(e)),q=[];if(N.length){N.forEach(e=>{let t=T(B($(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=B(e.name.getText());!r||r.startsWith("\\color")||($(e)||function(e){if(e.type){if(!g(e.type))return m(e.type);for(let t of e.type.types)if(m(t))return!0}return!1}(e)||t?.includes("=>")?r=`\\color{#f9a913}{${r}}`:/^
|
|
1
|
+
import{readFileSync as e}from"fs";import{dirname as t}from"path";import n from"typescript";import{CONFIG as r}from"./config.js";let{ScriptKind:l,ScriptTarget:o,SyntaxKind:i,createSourceFile:a,forEachChild:c,getLeadingCommentRanges:u,isInterfaceDeclaration:s,isQuestionToken:f,isPropertySignature:p,isFunctionTypeNode:m,isUnionTypeNode:g,isMethodSignature:$}=n,h={};function b(e){let t=u(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)return r[1].replace(/^\s*\* ?/gm,"").replace(/\s+$/,"").trim()}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 T(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.basename,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 B(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(u){let j=e(u,"utf-8"),w=a(u,j,o.Latest,!0,l.TS),E="";return c(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),a=d(o),c=k(o),u=x(o)?.split("|")||[],s=u.includes("comment"),j=u.includes("initial"),w=u.includes("optional"),E=u.includes("version"),S=u.includes("author"),v=c?`\\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;}">${T(B(e))}</n-tag>`),z=[c,v,a&&`\\color{#52c11b|1||0.9}{${a}}`,F.length>0&&`<sub>\`extends\`</sub> ${F.join(" ")}`].filter(Boolean).join(" "),K=`## ${z}`,N=e.members.filter(// 排除 never
|
|
2
|
+
e=>p(e)&&e.type?.kind!==i.NeverKeyword||$(e)),q=[];if(N.length){N.forEach(e=>{let t=T(B($(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=B(e.name.getText());!r||r.startsWith("\\color")||($(e)||function(e){if(e.type){if(!g(e.type))return m(e.type);for(let t of e.type.types)if(m(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&&B(k(n)),t,!j&&B(function(e){if(!e)return null;let t=e.match(/@default\s+([^\n]+)/);return t?t[1].trim():null}(n)),!E&&B(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)}),K+="\n";let l=["属性",!w&&"必要",r&&"说明","类型",n&&"默认值",t&&"版本",e&&"作者"].filter(Boolean).join("|");K+=`|${l}|`;let i=[":-",!w&&":-",r&&":-",":-",n&&":-",t&&":-",e&&":-"].filter(Boolean);K+="\n";let a=i.join("|");K+=`|${a}|`,q.forEach(l=>{K+="\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("|");K+=`|${o}|`}),K+="\n"}return K+="\n"}(e):n.isEnumDeclaration(e)&&(E+=function(e){let l=e.name.text,o=b(e),i=k(o),a=d(o);Object.assign(h,{[e.name.text]:t(e.getSourceFile().fileName).replace(r.alias["@pkg"],"")});let c=i?`\\color{|4||0.45}{${l}}`:l,u=[i,c,a&&`\\color{#52c11b|1||0.9}{${a}}`].filter(Boolean).join(" "),s=x(o)?.split("|")||[],f=s.includes("comment"),p=s.includes("version"),m=s.includes("author"),g=`## ${u}`;if(e.members.length){let t=[];e.members.forEach(e=>{let r=B(e.name.getText()),l=b(e),i=B(function(e){let t=e.initializer;return t&&n.isStringLiteral(t)?` '${t.text}'`:null}(e)),a=B(d(l)),c=B(k(l));!r||r.startsWith("\\color")||/^["'](.+)["']$/.test(r)||(r=`\\color{#4c81db}{${r}}`),t.push([r,!f&&c,i,!p&&a,!m&&(y(l)||y(o))]);// markdownContent += `| ${name} | ${comment} | ${value} | ${version} |`;
|
|
3
3
|
});let r=!1,l=!1,i=!1;t.forEach(e=>{!f&&e[1]&&(i=!0),!p&&e[3]&&(l=!0),!m&&e[4]&&(r=!0)}),g+="\n";let a=["属性",i&&"说明","值",l&&"版本",r&&"作者"].filter(Boolean).join("|");g+=`|${a}|`;let c=[":-",i&&":-",":-",l&&":-",r&&":-"].filter(Boolean);g+="\n";let u=c.join("|");g+=`|${u}|`,t.forEach(e=>{g+="\n";let t=[e[0]||"-",i&&(e[1]||"-"),e[2]||"-",l&&(e[3]||"-"),r&&(e[4]||"-")].filter(Boolean).join("|");g+=`|${t}|`})}return g+="\n\n"}(e))}),E}
|
package/lib/has-pkg.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{accessSync as o,constants as r}from"fs";import t from"./paths.js";export function hasPkg(a){let e
|
|
1
|
+
import{accessSync as o,constants as r}from"fs";import t from"./paths.js";export function hasPkg(a){let e;try{o(`${t.programPath}/node_modules/${a}/package.json`,r.R_OK),e=!0}catch(o){e=!1}return e}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{merge as e}from"webpack-merge";import t from"./app.js";import{CONFIG as i}from"./config.js";import o from"./paths.js";import{PACKAGENAME as a,
|
|
1
|
+
import{merge as e}from"webpack-merge";import t from"./app.js";import{CONFIG as i}from"./config.js";import o from"./paths.js";import{PACKAGENAME as a,coreName as r}from"./process-env.js";let{template:p,favicon:m,...n}=Object.assign({template:`node_modules/${r}/template/index.html`,favicon:`node_modules/${r}/template/favicon.ico`},i.htmlPluginOption||{}),l=e({title:i.env?.PROJECTNAME||a.toLocaleUpperCase()||"Title",filename:"index.html",hash:!1,minify:{collapseWhitespace:!0,removeComments:!0,removeRedundantAttributes:!1,removeScriptTypeAttributes:!1,removeStyleLinkTypeAttributes:!1,removeAttributeQuotes:!0,useShortDoctype:!0},meta:{charset:"UTF-8","X-UA-Compatible":{"http-equiv":"X-UA-Compatible",content:"IE=edge,Chrome=1"},HandheldFriendly:"true",MobileOptimized:"320","screen-orientation":"portrait","x5-orientation":"portrait",browsermode:"application","x5-page-mode":"app","msapplication-tap-highlight":"no",viewport:"width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no","apple-mobile-web-app-capable":"yes",renderer:"webkit",description:t.description||""},tags:[],template:`${o.programPath}/${p}`,favicon:`${o.programPath}/${m}`},n);export default l;
|
package/lib/index.d.ts
CHANGED
|
@@ -1 +1,5 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { default as paths } from './paths.js';
|
|
2
|
+
export { CUSTOMCONFIG, FRAMEWORKNAME, PACKAGENAME, PACKAGEVERSION, coreName, isDev, isLibrary, isMicro, } from './process-env.js';
|
|
3
|
+
export { realResolve, resolveNodeModulesPath, resolveProgramPath } from './utils.js';
|
|
4
|
+
export { getNetworkAdress, getIPv4, getPort } from './net.js';
|
|
5
|
+
export type * from '../typings/global.d.ts';
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{default as paths}from"./paths.js";export{CUSTOMCONFIG,FRAMEWORKNAME,PACKAGENAME,PACKAGEVERSION,coreName,isDev,isLibrary,isMicro}from"./process-env.js";export{realResolve,resolveNodeModulesPath,resolveProgramPath}from"./utils.js";export{getNetworkAdress,getIPv4,getPort}from"./net.js";
|
package/lib/locales.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{existsSync as e}from"fs";import{basename as t,join as o}from"path";import{watch as a}from"chokidar";import{CONFIG as l}from"./config.js";import r from"./esm.js";import{FRAMEWORK as n,isLibrary as s}from"./process-env.js";import c from"./reactive-object.js";import{
|
|
2
|
-
export function interpolateString(r,n){return r.replace(/\\\${\\w+}/g,function(r){var t=r.slice(2,-1);var e=n[t];return e!==void 0?e.toString():""})}function deepFreeze(o) { const p = Reflect.ownKeys(o);for (const k of p) {const v = o[k];if ((v && typeof v === "object") || typeof v === "function") {deepFreeze(v);}}return Object.freeze(o);}export const locales = ${JSON.stringify(e)};const _res = ${JSON.stringify(t)};const resources = deepFreeze(_res);${
|
|
3
|
-
async function
|
|
1
|
+
import{existsSync as e}from"fs";import{basename as t,join as o}from"path";import{watch as a}from"chokidar";import{CONFIG as l}from"./config.js";import r from"./esm.js";import{FRAMEWORK as n,isLibrary as s}from"./process-env.js";import c from"./reactive-object.js";import{empty as i,resolveProgramPath as g,tfc as f}from"./utils.js";let p={react:'import sso from "shared-store-object";',solid:'import { createEffect, createRoot, getOwner } from "solid-js";import { createStore } from "solid-js/store";'},u={react:'let storageKey="localizable.language",language=localStorage.getItem(storageKey)||"zh_CN",{translation:a,...defaultLocale}=Object.assign({title:"简体中文",language:"zh_CN",translation:{}},resources[language]||resources.zh_CN),localizable=sso({lang:defaultLocale,t:a});export function setLang(a){let{translation:e,...l}=resources[a]||{};e&&(localizable.lang=l,localizable.t=e,localStorage.setItem(storageKey,l.language))}export default localizable;',solid:'let locale=createRoot(()=>{let e="localizable.language",a=localStorage.getItem(e)||"zh_CN",{translation:l,...o}=Object.assign({title:"简体中文",language:"zh_CN",translation:{}},resources[a]||resources.zh_CN),[n,c]=createStore({lang:o,t:l});return createEffect(()=>{let a=resources[n.lang.language]?.translation;a&&(c("t",a),localStorage.setItem(e,n.lang.language))}),{localizable:n,setLocalizable:c,setLang:function(e){let{translation:a,...l}=resources[e]||{};a&&c("lang",l)}}},getOwner());export const setLocalizable=locale.setLocalizable;export const t=locale.localizable.t;export const lang=locale.localizable.lang;export const setLang=locale.setLang;'}[n];function d(e,t){return`${p[n]}
|
|
2
|
+
export function interpolateString(r,n){return r.replace(/\\\${\\w+}/g,function(r){var t=r.slice(2,-1);var e=n[t];return e!==void 0?e.toString():""})}function deepFreeze(o) { const p = Reflect.ownKeys(o);for (const k of p) {const v = o[k];if ((v && typeof v === "object") || typeof v === "function") {deepFreeze(v);}}return Object.freeze(o);}export const locales = ${JSON.stringify(e)};const _res = ${JSON.stringify(t)};const resources = deepFreeze(_res);${u}`}export const localesModuleName="@app/locales";export const locales=new c({[localesModuleName]:d([],{})});let m={};// 要执行的函数
|
|
3
|
+
async function z(e,o){let a=t(e).replace(/\.[^.]+$/,"");if("deleted"===o)delete m[a];else{let t=await import(r`${f(e)}`);Object.assign(m,{[a]:t.default})}let l=[],n={};for(let e in m)if(Object.prototype.hasOwnProperty.call(m,e)){let t=m[e],{language:o=a,title:r=o,icon:s,translation:c={}}=t;l.push({language:o,title:r,icon:s}),n[o]={language:o,title:r,icon:s,translation:c}}locales.setData(localesModuleName,d(l,n))}e(o(l.alias["@"],"./locales"))&&function(e,t){let o=[],l=a(e,{ignored:t,persistent:!0,ignoreInitial:!1});l.on("add",e=>{o.push(e),z(e,"added").finally(i)}),l.on("change",e=>{z(e,"change").finally(i)}),l.on("unlink",e=>{o.splice(o.indexOf(e),1),z(e,"deleted").finally(i)}),l.on("ready",()=>{o.forEach(e=>{z(e,"change").finally(i)})}),process.on("SIGINT",function(){l.close()})}(g(s?"site/locales":"src/locales"),[/^\..*/,/!\.ts$/,/\.d\.ts$/]);
|
package/lib/minify.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import TerserPlugin from 'terser-webpack-plugin';
|
|
2
|
-
import type { MinifierType, SwcOptions, TerserOptions } from '
|
|
2
|
+
import type { MinifierType, SwcOptions, TerserOptions } from '.';
|
|
3
3
|
import type { JsMinifyOptions } from '@swc/core';
|
|
4
4
|
type MinifyObject = {
|
|
5
5
|
terser: {
|
package/lib/module.config.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import e from"mini-css-extract-plugin";import s from"mini-svg-data-uri";import{CONFIG as t,PUBLICPATH as o}from"./config.js";import{hasPkg as
|
|
2
|
-
auto:e=>{for(let s=0,t=
|
|
3
|
-
localIdentName:"[path][name]__[local]",exportLocalsConvention:"dashesOnly"},importLoaders:2}},
|
|
1
|
+
import e from"mini-css-extract-plugin";import s from"mini-svg-data-uri";import{CONFIG as t,PUBLICPATH as o,isTsc as r}from"./config.js";import{hasPkg as l}from"./has-pkg.js";import a from"./modify-vars.js";import i from"./paths.js";import{FRAMEWORK as n,isDev as m,isLibrary as c,isMicro as d}from"./process-env.js";import p from"./swcrc.js";import u from"./tsloader.config.js";import{resolveNodeModulesPath as f,resolveProgramPath as y}from"./utils.js";let x={loader:`${i.corePath}/loader/css-unicode.cjs`},$=d?o:"../",g={loader:e.loader,options:{publicPath:"/"!==$?$:"../"}},j=l("@moneko/postcss")&&{loader:"postcss-loader",options:{postcssOptions:await import("@moneko/postcss")}};m&&(g="style-loader");let w=[...t.cssModules,`@moneko/${n}`,"neko-ui"].map(f),v=[...["src/styles/variables.less","src/styles/mixins.less","site/styles/variables.less","site/styles/mixins.less"].map(y)],b=["components","example","mock","site","src","server"].map(y),h=[g,m&&{loader:"@teamsupercell/typings-for-css-modules-loader",options:{verifyOnly:!m}},{loader:"css-loader",options:{modules:{// 根据文件名觉得是否启用cssModules | 排除 node_modules 和 *global.css 和 *global.less
|
|
2
|
+
auto:e=>{for(let s=0,t=w.length;s<t;s++)if(e&&e?.includes(w[s]))return/(.*(?<!\.?global\.(le|c)ss)$)/i.test(e);return/(^(?!.*node_modules))(.*(?<!\.?global\.(le|c)ss)$)/i.test(e)},// localIdentName: isDev ? '[path][name]__[local]' : '[hash:base64]',
|
|
3
|
+
localIdentName:"[path][name]__[local]",exportLocalsConvention:"dashesOnly"},importLoaders:2}},j,x,{loader:"less-loader",options:{sourceMap:!!t.sourceMap,lessOptions:{modifyVars:a,javascriptEnabled:!0}}},{loader:"style-resources-loader",options:{patterns:v}}].filter(Boolean),k={loader:r?"ts-loader":"swc-loader",options:r?u:p(m)};function O(e){return b.concat(t.rulesInclude?.[e]?.map(f)||[])}let B=O("media"),L={rules:[c&&{test:/\.mdx?$/i,include:[y("components")],exclude:[/(.+)\/examples\/(.+).mdx?$/i],enforce:"pre",use:[{loader:`${i.corePath}/loader/frontmatter.cjs`}]},{oneOf:[{resourceQuery:/raw/i,type:"asset/source"},{resourceQuery:/url/i,type:"asset/resource",generator:{filename:e=>{let s=e.filename;return s&&s.endsWith("wasm?url")?"wasm/[name][ext]":"assets/[name][ext]"}}},{test:/\.wasm$/i,type:"webassembly/async",include:O("wasm")},{test:/\.txt$/i,type:"asset/source"},{test:/\.ico$/i,type:"asset/inline",include:B},{test:/\.svg$/i,type:"asset/inline",generator:{dataUrl:e=>s(e.toString())},include:B},{test:/\.(gif|png|jpe?g|mp4)$/i,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/images/[name][ext]"},include:B},{test:/\.(eot|ttf|otf|woff|woff2)$/i,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/fonts/[name][ext]"},include:O("fonts")},{test:/\.less$/i,use:h,include:O("less")},{test:/\.css$/i,use:[g,"css-loader",j,x].filter(Boolean),include:O("css")},{test:/\.(cj|mj|t|j)s(|x)$/i,use:[...t.prefixJsLoader,k].filter(Boolean),include:O("js")},{test:/\.mdx?$/i,use:[...t.prefixJsLoader,k,{loader:"@mdx-js/loader",options:t.mdx}].filter(Boolean),include:b,exclude:[/(.+)\/examples\/(.+).mdx?$/i]},{test:/\.mdx?$/i,type:"asset/source",include:[/(.+)\/examples\/(.+).mdx?$/i]},{type:"asset/source",include:[/(.+)\/examples\/(.+).*?$/i]}]},...t.moduleRules].filter(e=>"object"==typeof e)};export default L;
|
package/lib/paths.d.ts
CHANGED
package/lib/paths.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as e,mkdirSync as o}from"fs";import a from"url";let
|
|
1
|
+
import{existsSync as e,mkdirSync as o}from"fs";import a from"url";let t=process.cwd(),c=`${t}/node_modules/.cache/.mo`;e(c)||o(c,{recursive:!0});export default{corePath:a.fileURLToPath(new URL(".",import.meta.url)),programPath:t,webpackCachePath:`${t}/node_modules/.temp_cache`,cachePath:c,httpCachePath:`${t}/node_modules/.cache/http`,swcCachePath:`${t}/node_modules/.swc`,defaultConfigPath:`${t}/config/index.ts`,coveragePath:`${t}/coverage/clover.xml`,pagesPath:`${t}/src/pages`,componentsPath:`${t}/components`};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare function replaceChildrenPolyfill(...nodes: (string | Node)[]): void;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
function e(...t){/**
|
|
2
|
+
* @ts-ignore */// eslint-disable-next-line consistent-this, no-invalid-this, @typescript-eslint/no-this-alias
|
|
3
|
+
let o=this,r=t.length,l=Array(r);for(let e=0;e<r;e++)l[e]=t[e];for(;o.firstChild;)o.removeChild(o.firstChild);l.forEach(function(e){"string"==typeof e?o.appendChild(document.createTextNode(e)):o.appendChild(e)})}Element.prototype.replaceChildren||(Element.prototype.replaceChildren=e),ShadowRoot.prototype.replaceChildren||(ShadowRoot.prototype.replaceChildren=e);
|
package/lib/process-env.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AppType, Framework } from '
|
|
1
|
+
import type { AppType, Framework } from '.';
|
|
2
2
|
export declare const APPTYPE: AppType;
|
|
3
3
|
export declare const FRAMEWORK: Framework;
|
|
4
4
|
export declare const isLibrary: boolean;
|
|
@@ -7,11 +7,23 @@ export declare const isReact: boolean;
|
|
|
7
7
|
export declare const isSolid: boolean;
|
|
8
8
|
export declare const jsxImportSource: string;
|
|
9
9
|
export declare const createElement: string;
|
|
10
|
+
/** 框架名称 */
|
|
10
11
|
export declare const FRAMEWORKNAME: string;
|
|
12
|
+
/** 应用名称 */
|
|
11
13
|
export declare const PACKAGENAME: string;
|
|
14
|
+
/** 版本号 */
|
|
12
15
|
export declare const PACKAGEVERSION: string;
|
|
13
|
-
|
|
16
|
+
/** core 包名 */
|
|
17
|
+
export declare const coreName: string;
|
|
18
|
+
/** 是否为本地开发环境 */
|
|
14
19
|
export declare const isDev: boolean;
|
|
20
|
+
/** 附加启动配置名称
|
|
21
|
+
* @example
|
|
22
|
+
* 当通过以下命令启动时, 此时 CUSTOMCONFIG 为 test
|
|
23
|
+
* ```sh
|
|
24
|
+
* npm run start --config=test
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
15
27
|
export declare const CUSTOMCONFIG: string | undefined;
|
|
16
28
|
export declare const hasEslintConfig: boolean;
|
|
17
29
|
export declare const hasStylelintConfig: boolean;
|
package/lib/process-env.js
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
import{readFileSync as e}from"fs";import o from"./paths.js";import t from"./yarn-argv.js";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]
|
|
1
|
+
import{readFileSync as e}from"fs";import o from"./paths.js";import t from"./yarn-argv.js";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 PACKAGENAME=process.env.npm_package_name;/** 版本号 */export const PACKAGEVERSION=process.env.npm_package_version;let s=e(`${o.corePath}/../package.json`,{encoding:"utf-8"});/** core 包名 */export const coreName=JSON.parse(s).name;/** 是否为本地开发环境 */export const isDev="development"===process.env.NODE_ENV;/** 附加启动配置名称
|
|
2
|
+
* @example
|
|
3
|
+
* 当通过以下命令启动时, 此时 CUSTOMCONFIG 为 test
|
|
4
|
+
* ```sh
|
|
5
|
+
* npm run start --config=test
|
|
6
|
+
* ```
|
|
7
|
+
*/export const CUSTOMCONFIG=process.env.npm_config_config||t.config;let n=Object.keys(process.env);export const hasEslintConfig=-1!==n.findIndex(e=>e.startsWith("npm_package_eslintConfig_"));export const hasStylelintConfig=-1!==n.findIndex(e=>e.startsWith("npm_package_stylelint_"));
|
package/lib/prod.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import e from"css-minimizer-webpack-plugin";import i from"mini-css-extract-plugin";import
|
|
1
|
+
import e from"css-minimizer-webpack-plugin";import i from"mini-css-extract-plugin";import m from"terser-webpack-plugin";import n from"webpack";import{BundleAnalyzerPlugin as o}from"webpack-bundle-analyzer";import{merge as s}from"webpack-merge";import{clientConfig as r}from"./common.js";import{CONFIG as t}from"./config.js";import{getMinifyOption as p}from"./minify.js";let{optimize:{MinChunkSizePlugin:l}}=n,{cssnanoMinify:u,swcMinify:a}=e,c="swc"===t.compiler,f=[];t.minifier&&(t.minifier.js&&f.push(new m(p(t.minifier.js?.type||(c?"swc":"terser"),t.minifier.js?.options))),t.minifier.css&&f.push(new e({minify:{swc:a,cssnano:u}[t.minifier.css?.type||(c?"swc":"cssnano")],minimizerOptions:t.minifier.css?.options})));let d={splitChunks:t.splitChunk,runtimeChunk:t.runtimeChunk,chunkIds:"named",moduleIds:"named",// parent chunk中解决了的chunk会被删除
|
|
2
2
|
removeAvailableModules:!0,// 删除空的chunks
|
|
3
3
|
removeEmptyChunks:!0,// 合并重复的chunk
|
|
4
4
|
mergeDuplicateChunks:!0,mangleWasmImports:!0,minimize:!0,minimizer:f},k=s(r,{devtool:!1===t.devtool||t.devtool?t.devtool:"cheap-module-source-map",mode:"production",optimization:d,plugins:[// 压缩 css
|
|
5
|
-
new i({filename:"style/[name].bundle.css",chunkFilename:"style/[name].chunk.css",experimentalUseImportModule:!0}),t.bundleAnalyzer&&new o(t.bundleAnalyzer),t.splitChunk&&new l
|
|
5
|
+
new i({filename:"style/[name].bundle.css",chunkFilename:"style/[name].chunk.css",experimentalUseImportModule:!0}),t.bundleAnalyzer&&new o(t.bundleAnalyzer),t.splitChunk&&new l({minChunkSize:1e4})].filter(Boolean)});export default[k];
|
package/lib/reactive-object.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import EventEmitter from 'events';
|
|
3
3
|
declare class ReactiveObject<T extends object = Record<string, string | undefined>> extends EventEmitter {
|
|
4
|
-
private data;
|
|
4
|
+
private readonly data;
|
|
5
5
|
constructor(props?: T);
|
|
6
6
|
setData(key: keyof T, value: T[keyof T]): void;
|
|
7
7
|
getData(key: keyof T): T[keyof T];
|
|
8
|
-
removeData(key: keyof T): void;
|
|
9
8
|
[Symbol.iterator](): Iterator<[keyof T, T[keyof T]]>;
|
|
10
9
|
}
|
|
11
10
|
export default ReactiveObject;
|
package/lib/reactive-object.js
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
import t from"events";class e extends t{constructor(t={}){super(),this.data=t}setData(t,e){e!==this.data[t]&&(this.data[t]=e,this.emit("change",t,e))}getData(t){return this.data[t]}removeData(
|
|
1
|
+
import t from"events";class e extends t{constructor(t={}){super(),this.data=t}setData(t,e){e!==this.data[t]&&(this.data[t]=e,this.emit("change",t,e))}getData(t){return this.data[t]}// removeData(key: keyof T) {
|
|
2
|
+
// if (Object.prototype.hasOwnProperty.call(this.data, key)) {
|
|
3
|
+
// delete this.data[key];
|
|
4
|
+
// this.emit('change', key, null);
|
|
5
|
+
// }
|
|
6
|
+
// }
|
|
7
|
+
// 实现迭代器接口
|
|
2
8
|
[Symbol.iterator](){let t=Object.keys(this.data),e=0;return{next:()=>{if(e<t.length){let a=t[e++];return{value:[a,this.data[a]],done:!1}}return{value:void 0,done:!0}}}}}export default e;
|
package/lib/swcrc.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{merge as e}from"webpack-merge";import{CONFIG as o}from"./config.js";import r from"./paths.js";import
|
|
2
|
-
|
|
1
|
+
import{merge as e}from"webpack-merge";import{CONFIG as o}from"./config.js";import r from"./paths.js";import s from"./polyfills.js";import{isReact as t,isSolid as n,jsxImportSource as c}from"./process-env.js";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 l={module:{type:"es6",resolveFully:!0},jsc:{parser:{syntax:"typescript",tsx:!0,decorators:!0,dynamicImport:!0},loose:!0,target:"es2017",externalHelpers:!0,transform:{legacyDecorator:!0,decoratorMetadata:!0,react:{runtime:"automatic",throwIfNamespace:!0,refresh:t&&a,development:a,importSource:c},optimizer:{simplify:!1}},experimental:{emitAssertForImportAttributes:!0,cacheRoot:r.swcCachePath,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||{})],n&&["@moneko/jsx-dom-expressions",o.jsxDomExpressions||{}]].filter(Boolean)}},sourceMaps:!0,parseMap:!0};return(o.polyfill&&(l.jsc.target=void 0,// swc polyfill,会复用 babel 链路,但效率比 babel 低
|
|
2
|
+
l.env={include:s(),mode:"usage",coreJs:"3.32.2"}),o.swcrc)?e(l,"function"==typeof o.swcrc?o.swcrc(a):o.swcrc):l});
|
package/lib/utils.d.ts
CHANGED
|
@@ -25,4 +25,5 @@ export declare const resolveNodeModulesPath: <T extends string>(src: T) => `${`n
|
|
|
25
25
|
export declare const realResolve: (url: string) => string;
|
|
26
26
|
export declare function isObject(target: unknown): target is object;
|
|
27
27
|
export declare function isFunction(target: unknown): target is (...args: unknown[]) => unknown;
|
|
28
|
+
export declare function empty(): void;
|
|
28
29
|
export {};
|
package/lib/utils.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{readFileSync as t,writeFileSync as e}from"fs";import{resolve as o}from"path";import{transformFileSync as r}from"@swc/core";import n from"./paths.js";import c from"./resolver-sync.js";let
|
|
1
|
+
import{readFileSync as t,writeFileSync as e}from"fs";import{resolve as o}from"path";import{transformFileSync as r}from"@swc/core";import n from"./paths.js";import c from"./resolver-sync.js";let p=/export\s+(?:async\s+)?(?:function|const)\s+(\w+)/g;/** 获取导出标识
|
|
2
2
|
* @param {string} path 文件地址
|
|
3
3
|
* @returns {string[]} 包含的标识
|
|
4
|
-
*/export function getExportTokens(e){let o;let r=t(e,{encoding:"utf-8"}),n=[];for(;o=
|
|
4
|
+
*/export function getExportTokens(e){let o;let r=t(e,{encoding:"utf-8"}),n=[];for(;o=p.exec(r);)n.includes(o[1])||n.push(o[1]);return n}let s={inputSourceMap:!1,sourceMaps:!1,module:{type:"es6"},jsc:{parser:{syntax:"typescript"},loose:!1}};export function tfc(t){return r(t,s).code||"{}"}export function readConf(t,o){let r=`${n.cachePath}/${o}.mjs`;return e(r,tfc(t),"utf-8"),import(r)}export function toUpperCaseString(t){return t?.replace(/\b\w/g,t=>t.toUpperCase()).replace(/\./g," ")}/** 位于项目根目录下的位置
|
|
5
5
|
* @param {string} src 路径
|
|
6
6
|
* @returns {string} 位于项目根目录下的位置
|
|
7
7
|
*/export function resolveProgramPath(t){return o(n.programPath,`./${t}`)}/** 位于项目根目录node_modules下的位置
|
|
@@ -11,4 +11,5 @@ import{readFileSync as t,writeFileSync as e}from"fs";import{resolve as o}from"pa
|
|
|
11
11
|
* @param {string} url 路径
|
|
12
12
|
* @returns {string} 模块真实入口路径
|
|
13
13
|
*/export const realResolve=t=>c.resolveSync({},n.programPath,t)||t;export function isObject(t){let e=typeof t;return null!==t&&("object"==e||"function"==e)}// eslint-disable-next-line no-unused-vars
|
|
14
|
-
export function isFunction(t){if(!isObject(t))return!1;let e=Object.prototype.toString.call(t);return"[object Function]"==e||"[object AsyncFunction]"==e||"[object GeneratorFunction]"==e||"[object Proxy]"==e}
|
|
14
|
+
export function isFunction(t){if(!isObject(t))return!1;let e=Object.prototype.toString.call(t);return"[object Function]"==e||"[object AsyncFunction]"==e||"[object GeneratorFunction]"==e||"[object Proxy]"==e}export function empty(){// empty void
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneko/core",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.2.1-beta.0",
|
|
4
4
|
"description": "core",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -19,15 +19,13 @@
|
|
|
19
19
|
"@swc/helpers": "0.5.3",
|
|
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.33.
|
|
23
|
-
"core-js-compat": "3.33.
|
|
22
|
+
"core-js": "3.33.2",
|
|
23
|
+
"core-js-compat": "3.33.2",
|
|
24
24
|
"cross-env": "7.0.3",
|
|
25
25
|
"css-loader": "6.8.1",
|
|
26
26
|
"css-minimizer-webpack-plugin": "5.0.1",
|
|
27
27
|
"external-remotes-plugin": "1.0.0",
|
|
28
28
|
"html-webpack-plugin": "5.5.3",
|
|
29
|
-
"less": "4.2.0",
|
|
30
|
-
"less-loader": "11.1.3",
|
|
31
29
|
"mini-css-extract-plugin": "2.7.6",
|
|
32
30
|
"mini-svg-data-uri": "1.4.4",
|
|
33
31
|
"style-loader": "3.3.3",
|
package/typings/global.d.ts
CHANGED
|
@@ -29,6 +29,14 @@ export type HtmlWebpackOption = HtmlWebpackPluginOptions & {
|
|
|
29
29
|
};
|
|
30
30
|
export type CssMinify = 'swc' | 'cssnano';
|
|
31
31
|
|
|
32
|
+
export type RulesInclude = {
|
|
33
|
+
less?: string[];
|
|
34
|
+
css?: string[];
|
|
35
|
+
js?: string[];
|
|
36
|
+
media?: string[];
|
|
37
|
+
fonts?: string[];
|
|
38
|
+
wasm?: string[];
|
|
39
|
+
};
|
|
32
40
|
export interface Theme {
|
|
33
41
|
primaryColor?: string;
|
|
34
42
|
infoColor?: string;
|
|
@@ -213,14 +221,7 @@ export declare type ConfigType<T extends 'tsc' | 'swc' = 'swc'> = {
|
|
|
213
221
|
moduleFederation: ModuleFederationOption[];
|
|
214
222
|
/** 跳过编译的模块 */
|
|
215
223
|
externals?: Configuration['externals'];
|
|
216
|
-
rulesInclude?:
|
|
217
|
-
less?: string[];
|
|
218
|
-
css?: string[];
|
|
219
|
-
js?: string[];
|
|
220
|
-
media?: string[];
|
|
221
|
-
fonts?: string[];
|
|
222
|
-
wasm?: string[];
|
|
223
|
-
};
|
|
224
|
+
rulesInclude?: RulesInclude;
|
|
224
225
|
/** bundle分析
|
|
225
226
|
* @default false
|
|
226
227
|
* @example
|